38 lines
2.3 KiB
Python
38 lines
2.3 KiB
Python
"""Pickle to runs.pkl one flat list of the archived reviewer runs of the projects on claude-opus-5-5, with or without findings, each with its round number from the prompt."""
|
|
import json, pathlib, pickle, re, sys
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "bin"))
|
|
from claude_code.entries import AssistantTurn, parse_entry, Text, UserText
|
|
from transcript_archive.project_key import checkout_of
|
|
from failure import Failure
|
|
from claude_code.transcript import first_timestamped_line, read_transcript
|
|
from review_replay.rounds import recorded_findings, stamp_seconds
|
|
|
|
home = pathlib.Path.home()
|
|
root = home / ".claude/loop-claude-transcripts"
|
|
models = json.loads((home / ".claude/loop-claude-models.json").read_text())
|
|
REV = {"stability-reviewer","product-owner-reviewer","prose-reviewer","override-reviewer","systems-architect","principles-auditor"}
|
|
runs = []
|
|
for key, m in models.items():
|
|
if m != "claude-opus-5-5": continue
|
|
for chunk in sorted(p for p in (root/key).glob("*") if p.is_dir()):
|
|
copies = sorted(chunk.glob("*.jsonl"))
|
|
began = parse_entry(first_timestamped_line(copies[0].read_bytes())) if copies else None
|
|
if not began or not began.timestamp: continue
|
|
for meta in sorted(chunk.glob("session/*/subagents/*.meta.json")):
|
|
d = json.loads(meta.read_text())
|
|
at = d.get("agentType")
|
|
if at not in REV: continue
|
|
entries = read_transcript(str(meta.with_name(meta.name.removesuffix(".meta.json")+".jsonl")))
|
|
if isinstance(entries, Failure) or not entries: continue
|
|
first = entries[0]
|
|
prompt = first.text if isinstance(first, UserText) else ""
|
|
texts = [p.text for e in entries if isinstance(e, AssistantTurn) for p in e.parts if isinstance(p, Text) and p.text]
|
|
rep = texts[-1] if texts else ""
|
|
mm = re.search(r"([a-z-]+)-round-(\d+)(-rerun)?\.md", prompt)
|
|
runs.append(dict(key=key, checkout=checkout_of(key, home), chunk=str(chunk), began=stamp_seconds(began.timestamp),
|
|
reviewer=at, at=first.timestamp, branch=first.git_branch, prompt=prompt, report=rep,
|
|
findings=recorded_findings(rep), roundfile=mm.group(0) if mm else None,
|
|
rnd=int(mm.group(2)) if mm else None, meta=str(meta)))
|
|
pickle.dump(runs, open("runs.pkl","wb"))
|
|
print(len(runs))
|