import os OUTPUT_SNAPSHOT = "api_code_snapshot.md" # Расширения файлов для включения в снимок ALLOWED_EXTENSIONS = {'.py', '.json', '.md', '.sh', '.ini', '.js', '.html', '.css'} EXCLUDE_DIRS = {'.git', '__pycache__', 'venv', '.venv', 'output', 'logs', 'extracted_project'} EXCLUDE_FILES = {OUTPUT_SNAPSHOT, 'scud_context_api.tar.gz', 'context_memory.db'} print(f"🔄 Сборка полного контекстного слепка проекта в {OUTPUT_SNAPSHOT}...") with open(OUTPUT_SNAPSHOT, 'w', encoding='utf-8') as out: out.write("# 📦 ПОЛНЫЙ ИСХОДНЫЙ КОД И КОНФИГУРАЦИЯ ПРОЕКТА scud_context_api\n\n") for root, dirs, files in os.walk('.'): dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS] for file in sorted(files): ext = os.path.splitext(file)[1].lower() if ext in ALLOWED_EXTENSIONS and file not in EXCLUDE_FILES: filepath = os.path.join(root, file) out.write(f"## File: `{filepath}`\n") out.write("```" + (ext.replace('.', '') if ext != '.md' else '') + "\n") try: with open(filepath, 'r', encoding='utf-8', errors='replace') as f: out.write(f.read()) except Exception as e: out.write(f"// Ошибка чтения файла: {e}\n") out.write("\n```\n\n") print(f"✓ Успешно создан слепок проекта: {OUTPUT_SNAPSHOT} ({os.path.getsize(OUTPUT_SNAPSHOT):,} bytes)")