diff --git a/bin/rung_replay/archive.py b/bin/rung_replay/archive.py index 07db1335..92ecc91f 100644 --- a/bin/rung_replay/archive.py +++ b/bin/rung_replay/archive.py @@ -27,7 +27,7 @@ def archiving(effects: Effects, folder: pathlib.Path) -> Effects: def run(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedProcess[str]: proc = claude(args, cwd, prompt) - content = "\n".join([json.dumps({"type": HEADER, "args": args, "cwd": cwd, "prompt": prompt}, ensure_ascii=False), proc.stdout]) + content = "\n".join([json.dumps({"type": HEADER, "args": args, "cwd": cwd, "prompt": prompt, "returncode": proc.returncode, "stderr": proc.stderr}, ensure_ascii=False), proc.stdout]) try: folder.mkdir(mode=0o700, parents=True, exist_ok=True) (folder / f"{hashlib.sha256(content.encode()).hexdigest()}.jsonl").write_text(content, encoding="utf-8") diff --git a/bin/rung_replay/test_rung_replay.py b/bin/rung_replay/test_rung_replay.py index 72252265..f22a5082 100644 --- a/bin/rung_replay/test_rung_replay.py +++ b/bin/rung_replay/test_rung_replay.py @@ -111,7 +111,7 @@ class ArchivedRuns(unittest.TestCase): first, second = (path.read_text(encoding="utf-8").splitlines() for path in self.kept()) prompts = sorted((json.loads(lines[0]) for lines in (first, second)), key=lambda header: header["prompt"]) self.assertEqual(prompts, [ - {"type": "replay_run", "args": ["-p", "--agent", "prose-reviewer"], "cwd": "/clone", "prompt": prompt} for prompt in ("Review it.", "Review that.") + {"type": "replay_run", "args": ["-p", "--agent", "prose-reviewer"], "cwd": "/clone", "prompt": prompt, "returncode": 0, "stderr": ""} for prompt in ("Review it.", "Review that.") ]) self.assertEqual(first[1:], stream.splitlines()) @@ -126,7 +126,8 @@ class ArchivedRuns(unittest.TestCase): run([], "/r", "p") run([], "/r", "p") self.assertEqual(len(self.kept()), 1) - self.assertIn("half a stream", self.kept()[0].read_text(encoding="utf-8")) + kept = self.kept()[0].read_text(encoding="utf-8").splitlines() + self.assertEqual((json.loads(kept[0])["returncode"], json.loads(kept[0])["stderr"], kept[1]), (1, "boom", "half a stream")) def test_keeps_nothing_where_claude_did_not_start_and_says_where_it_could_not_keep_a_run(self): def missing(args, cwd, prompt):