#!/usr/bin/env python3 """Restore deleted _docs from Cursor agent transcript (2026-05-19 session).""" import json from pathlib import Path TRANSCRIPT = Path( r"C:\Users\Damian\.cursor\projects\c-xampp-htdocs-programdocursora-RPA-AUTOMATION-gema0" r"\agent-transcripts\48e39d2e-9ea6-4252-9060-aecce5b3df0b" r"\48e39d2e-9ea6-4252-9060-aecce5b3df0b.jsonl" ) OUT_DIR = Path(__file__).resolve().parents[1] / "_docs" / "archive" / "PLANOWANIE_PRZED_V10" TARGETS = [ "GEMA0_V7_MASTER_PLAN.md", "GEMA0_V8_RED_TEAM_AUDIT.md", "GEMA0_V9_BRUTAL_DIAGNOSIS.md", "GEMA_V8.5_BRUTAL_RISKS.md", "GEMA_V8_FRONTEND_MASTER_PLAN.md", "GEMA_V8_MASTER_PLAN.md", "GEMA_V8_TECHNOLOGY_ACCELERATORS.md", ] HEADER = ( "> **ARCHIWUM — odtworzone z transkryptu Cursor (2026-05-19)**\n" "> Usunięte przed `_docs/00_GEMA0_ULTIMATE_MASTERPLAN.md` (V10 APEX).\n" "> **Nie jest planem bieżącym.** Aktywny docs: " "[../../05_MAPA_PLANOW_V5_V10.md](../../05_MAPA_PLANOW_V5_V10.md), " "[../../00_GEMA0_ULTIMATE_MASTERPLAN.md](../../00_GEMA0_ULTIMATE_MASTERPLAN.md).\n" "> Źródło rozmowy: transkrypt sesji `48e39d2e-9ea6-4252-9060-aecce5b3df0b`.\n\n" ) def main() -> None: OUT_DIR.mkdir(parents=True, exist_ok=True) found: dict[str, str] = {} with TRANSCRIPT.open("r", encoding="utf-8") as f: for line in f: try: obj = json.loads(line) except json.JSONDecodeError: continue msg = obj.get("message", {}) for block in msg.get("content", []): if block.get("type") != "tool_use" or block.get("name") != "Write": continue inp = block.get("input", {}) path_str = inp.get("path", "").replace("\\", "/") for name in TARGETS: if path_str.endswith(name): found[name] = inp.get("contents", "") for name in TARGETS: body = found.get(name, "") if not body: raise SystemExit(f"Missing content for {name}") (OUT_DIR / name).write_text(HEADER + body, encoding="utf-8") print(f"OK {name} ({len(body)} chars)") print(f"Restored {len(TARGETS)} files -> {OUT_DIR}") if __name__ == "__main__": main() s