Show the judge a reply the human types while claude works
This commit was merged in pull request #118.
This commit is contained in:
@@ -10,5 +10,6 @@
|
||||
- `loop-claude`'s judge quotes the transcript for every verdict, and a verdict quoting nothing or interrupting without a question, or a `claude` the judge cannot start, is a failed judge run; a `claude` that cannot start for an interrupt exits 1.
|
||||
- `loop-claude`'s exit-2 message says what the human is needed for.
|
||||
- `loop-claude` counts an interrupt reply starting with `<` as typed.
|
||||
- `loop-claude`'s judge sees a reply the human types while claude works, and an interrupt counts one as typed.
|
||||
- `loop-claude`'s archive holds the raw `.jsonl` transcript, one copy per distinct transcript, named by its SHA-256, with the verdict beside it in `<sha256>.verdict.md`; a transcript it cannot archive exits 1.
|
||||
- `loop-claude` keeps the mode of `~/.claude.json` and of its models file when it rewrites them, and creates the models file 0600.
|
||||
|
||||
@@ -84,12 +84,23 @@ def user_entry_kind(entry):
|
||||
|
||||
def human_text(entry):
|
||||
"""What the human wrote in the entry, or None where Claude Code wrote it."""
|
||||
if (queued := queued_human_text(entry)) is not None:
|
||||
return queued
|
||||
if entry.get("type") != "user" or user_entry_kind(entry) is not UserEntryKind.HUMAN:
|
||||
return None
|
||||
text = content(entry)
|
||||
return text if isinstance(text, str) else "".join(part_text(part) or "" for part in parts(entry))
|
||||
|
||||
|
||||
# What the human types while claude works, written only as this entry:
|
||||
# {"type": "attachment", "attachment": {"type": "queued_command", "commandMode": "prompt", "origin": {"kind": "human"}, "prompt": "B"}}
|
||||
def queued_human_text(entry):
|
||||
attachment = entry.get("attachment") if entry.get("type") == "attachment" else None
|
||||
if not isinstance(attachment, dict) or attachment.get("type") != "queued_command" or not isinstance(origin := attachment.get("origin"), dict) or origin.get("kind") != "human":
|
||||
return None
|
||||
return prompt if isinstance(prompt := attachment.get("prompt"), str) else None
|
||||
|
||||
|
||||
# {"type": "text", "text": "ok"}
|
||||
def part_text(part):
|
||||
return part["text"] if isinstance(part, dict) and part.get("type") == "text" and isinstance(part.get("text"), str) else None
|
||||
|
||||
+11
-2
@@ -24,6 +24,10 @@ def human(content):
|
||||
return {"type": "user", "message": {"content": content}}
|
||||
|
||||
|
||||
def queued(prompt, kind):
|
||||
return {"type": "attachment", "attachment": {"type": "queued_command", "commandMode": "prompt", "origin": {"kind": kind}, "prompt": prompt}}
|
||||
|
||||
|
||||
class Sections(unittest.TestCase):
|
||||
def test_keeps_every_headed_section_with_its_bodies(self):
|
||||
text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n## Audience\nagain\n# Appendix\nnot audience\n"
|
||||
@@ -39,9 +43,11 @@ class Render(unittest.TestCase):
|
||||
human([{"type": "tool_result", "content": "not typed"}]),
|
||||
human("<command-name>/exit</command-name>"),
|
||||
human([{"type": "text", "text": "yes, "}, {"type": "text", "text": "merge it"}]),
|
||||
queued("B, while you work", "human"),
|
||||
queued("origin/main moved", "coordinator"),
|
||||
{**human("Continue the task; the previous run stopped before it was finished."), "promptSource": "sdk"},
|
||||
])
|
||||
self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it')
|
||||
self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it\n\n[human] B, while you work')
|
||||
|
||||
|
||||
class HumanTurns(unittest.TestCase):
|
||||
@@ -57,8 +63,11 @@ class HumanTurns(unittest.TestCase):
|
||||
{**human("the loop's own prompt"), "promptSource": "sdk"},
|
||||
human([{"type": "text", "text": "[Request interrupted by user]"}]),
|
||||
human([]),
|
||||
queued("typed while claude worked", "human"),
|
||||
queued("<task-notification>done</task-notification>", "task-notification"),
|
||||
{"type": "attachment", "attachment": {"type": "queued_command", "commandMode": "task-notification", "prompt": "<task-notification>done</task-notification>"}},
|
||||
assistant({"type": "text", "text": "said"}),
|
||||
]), 3)
|
||||
]), 4)
|
||||
|
||||
|
||||
class PartLine(unittest.TestCase):
|
||||
|
||||
@@ -8,7 +8,6 @@ The rebuild lifts every dimension, one chunk per item, until the last item opens
|
||||
|
||||
The places the panel on `rebuild` at 37edc9a named (`docs/decisions.md`), capping dimension first:
|
||||
|
||||
- **Show the judge a reply the human sends while claude works.** Claude Code 2.1.284 writes it as an `"attachment"` entry, which `render` drops, so the judge can rule on a question the human already answered during an interrupt.
|
||||
- **Score `rebuild` with the four-seat panel at 7.0 or above on every dimension and the overall, none below the last run, and open its PR into main for the human.** ⚠️ Leave that PR ready and unmerged: only the human merges it, after approving the whole rebuild. A dimension under the floor gets its places filed above this item.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
Reference in New Issue
Block a user