feat(harness): tht session documents --json read command

This commit is contained in:
2026-06-29 12:25:40 +02:00
parent 38cd4889f4
commit 03053b0716
3 changed files with 100 additions and 0 deletions
+24
View File
@@ -164,3 +164,27 @@ def delete_session(session_id: str, sessions_root: Path) -> None:
"""Hard-delete the session directory. SessionError if it does not exist."""
load_session(session_id, sessions_root) # raises SessionError if absent
shutil.rmtree(sessions_root / session_id)
def build_documents(manifest: SessionManifest, session_dir: Path) -> list[dict]:
"""Ordered, read-only document bundle for the UI panel. Only documents that exist
on disk are returned. CTE artifacts (F6) are intentionally excluded (intermediate)."""
docs: list[dict] = [{
"phase": "—", "key": "question", "title": "Domanda originale",
"format": "text", "content": manifest.question,
}]
spec = [
("question.md", "F3", "revised_question", "Domanda rivista", "markdown"),
("schema_linking.json", "F4", "schema_linking", "Schema linking", "schema-linking"),
("sql_final.sql", "F7", "sql", "SQL finale", "sql"),
("validation_report.md", "finalize", "validation_report", "Report di validazione", "markdown"),
("review_decisions.jsonl", "—", "decisions", "Decisioni", "decisions"),
]
for filename, phase, key, title, fmt in spec:
path = session_dir / filename
if path.exists():
docs.append({
"phase": phase, "key": key, "title": title,
"format": fmt, "content": path.read_text(),
})
return docs