diff --git a/data/scud_orion_ai.db b/data/scud_orion_ai.db index 99f3030..6a455ae 100644 Binary files a/data/scud_orion_ai.db and b/data/scud_orion_ai.db differ diff --git a/data/scud_orion_ai_old.db b/data/scud_orion_ai_old.db new file mode 100644 index 0000000..99f3030 Binary files /dev/null and b/data/scud_orion_ai_old.db differ diff --git a/scripts/db_cli.py b/scripts/db_cli.py index deae354..3b86fff 100644 --- a/scripts/db_cli.py +++ b/scripts/db_cli.py @@ -193,6 +193,42 @@ def dump_all_to_excel(out_filename="db_dump_full.xlsx"): df.to_excel(writer, sheet_name=table[:31], index=False) print(f"[✓] Дамп успешно сохранен: {out_path}\n") +def print_system_prompts(): + """Выводит все системные промпты из базы данных.""" + print("\n" + "=" * 80) + print("📝 СИСТЕМНЫЕ ПРОМПТЫ (system_prompts):") + print("=" * 80) + with get_connection() as conn: + cursor = conn.cursor() + cursor.execute("SELECT id, name, is_active, updated_at, prompt_text FROM system_prompts ORDER BY id DESC") + rows = cursor.fetchall() + if not rows: + print("Таблица system_prompts пуста.") + else: + for r in rows: + print(f"ID: {r[0]} | Name: {r[1]} | Active: {r[2]} | Updated: {r[3]}") + print("-" * 80) + print(f"{r[4]}\n") + print("=" * 80 + "\n") + +def print_session_states(): + """Выводит текущие активные сессии и превью (session_states).""" + print("\n" + "=" * 80) + print("🔄 АКТИВНЫЕ СЕССИИ И ПРЕВЬЮ (session_states):") + print("=" * 80) + with get_connection() as conn: + cursor = conn.cursor() + cursor.execute("SELECT session_id, state_type, updated_at, pending_data FROM session_states") + rows = cursor.fetchall() + if not rows: + print("Таблица session_states пуста (нет активных превью).") + else: + for r in rows: + print(f"Session: {r[0]} | Type: {r[1]} | Updated: {r[2]}") + print("-" * 80) + print(f"Pending Data:\n{r[3]}\n") + print("=" * 80 + "\n") + def main(): help_text = """ @@ -204,11 +240,15 @@ CLI-утилита инспекции и управления SQLite базой scud [--snapshot ID] [--export-xlsx NAME] -- Инспекция логов СКУД и опциональный экспорт в Excel anomalies -- Посмотреть все найденные аномалии СКУД ⟷ 1С rules -- Посмотреть правила Базы Знаний ИИ из SQLite + prompts -- Посмотреть системные промпты (system_prompts) + sessions -- Посмотреть активные сессии и превью (session_states) dump [output.xlsx] -- Полный дамп всех таблиц БД в многостраничный Excel snapshot del [ID] или [--day ДД.ММ.ГГГГ] -- Удаление снапшотов по ID или за весь день ПРИМЕРЫ ЗАПУСКА: python scripts/db_cli.py stats + python scripts/db_cli.py prompts + python scripts/db_cli.py sessions python scripts/db_cli.py snapshots 04.08.2026 python scripts/db_cli.py scud --snapshot Y20260805-007 --export-xlsx вчера_1 python scripts/db_cli.py snapshot del Y20260805-007 @@ -219,7 +259,7 @@ CLI-утилита инспекции и управления SQLite базой formatter_class=argparse.RawDescriptionHelpFormatter, add_help=True ) - parser.add_argument('command', nargs='?', default=None, choices=['stats', 'snapshots', 'scud', 'anomalies', 'rules', 'dump', 'snapshot'], help="Основная команда") + parser.add_argument('command', nargs='?', default=None, choices=['stats', 'snapshots', 'scud', 'anomalies', 'rules', 'prompts', 'sessions', 'dump', 'snapshot'], help="Основная команда") parser.add_argument('action', nargs='?', default=None, help="Дополнительное действие (например, 'del')") parser.add_argument('param', nargs='?', default=None, help="Параметр (дата, ID снапшота или имя файла)") parser.add_argument('--snapshot', type=str, default=None, help="ID конкретного снапшота для инспекции") @@ -244,6 +284,10 @@ CLI-утилита инспекции и управления SQLite базой print_anomalies() elif args.command == 'rules': print_rules() + elif args.command == 'prompts': + print_system_prompts() + elif args.command == 'sessions': + print_session_states() elif args.command == 'dump': filename = args.param if args.param else "db_dump_full.xlsx" dump_all_to_excel(filename) diff --git a/scud_orion_ai_old.db b/scud_orion_ai_old.db new file mode 100644 index 0000000..e69de29