|
|
|
@@ -4,12 +4,26 @@ usage: loop-claude <task>
|
|
|
|
|
|
|
|
|
|
Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the
|
|
|
|
|
premises; the task runs at the checkout root. Each cycle a worker runs the task; a judge then reads
|
|
|
|
|
the transcript against them and rules whether the chunk, the work of one PR, is finished.
|
|
|
|
|
the transcript against the premises and rules whether the chunk, the work of one PR, is finished.
|
|
|
|
|
A question only the human can answer, or a release ready to cut, is an interrupt: `claude --resume`
|
|
|
|
|
on the terminal, every worktree first marked trusted in ~/.claude.json. An unfinished chunk resumes
|
|
|
|
|
its session next cycle; the next chunk starts a fresh session.
|
|
|
|
|
Cycles continue until an exit below or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary".
|
|
|
|
|
|
|
|
|
|
Each project has one session, named "A <key> loop-claude", where <key> is the checkout's path
|
|
|
|
|
relative to ~/code, or to / outside it. The session is deleted when its chunk finishes. At every
|
|
|
|
|
interrupt, and when the chunk finishes, the session's transcript is copied to
|
|
|
|
|
$LOOP_CLAUDE_TRANSCRIPTS/<key>/<sha256>.jsonl (default ~/.claude/loop-claude-transcripts), the
|
|
|
|
|
verdict beside it in <sha256>.verdict.md.
|
|
|
|
|
|
|
|
|
|
Every claude it starts runs the project's model, saved per <key> in ~/.claude/loop-claude-models.json
|
|
|
|
|
and read each cycle; a project without an entry, as on its first run, is asked for one.
|
|
|
|
|
LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, LOOP_CLAUDE_WORKER_MODEL for the worker and the
|
|
|
|
|
interrupt; with both set, nothing is asked.
|
|
|
|
|
|
|
|
|
|
A change to bin/loop-claude or bin/loop_claude/**/*.py takes effect at the next cycle boundary, once
|
|
|
|
|
loop-claude --help succeeds: the loop reloads into the edited script.
|
|
|
|
|
|
|
|
|
|
Exit 1, saying why, when:
|
|
|
|
|
- no task is given
|
|
|
|
|
- git cannot start or finds no checkout
|
|
|
|
@@ -20,28 +34,19 @@ Exit 1, saying why, when:
|
|
|
|
|
- a finished chunk's session cannot be deleted
|
|
|
|
|
- claude cannot start for an interrupt
|
|
|
|
|
- python cannot start for a reload
|
|
|
|
|
- a reload cannot read the cycle number, checkout root and task the edited script was handed, as
|
|
|
|
|
when the edit changed what one script hands the next
|
|
|
|
|
- a reload cannot read the cycle number, checkout root and task the running script handed it,
|
|
|
|
|
likely because the edit changed that handover
|
|
|
|
|
- the worker or the judge fails three times running, retried a minute apart within the cycle. A
|
|
|
|
|
worker fails when claude cannot start, exits non-zero, is killed, or ends without a result event;
|
|
|
|
|
a judge when claude cannot start or exits non-zero, or its reply misses or mistypes a field,
|
|
|
|
|
interrupts without a question, or quotes nothing in the transcript.
|
|
|
|
|
Exit 2: the human is needed, to pick the model or answer an interrupt, and stdin or stdout is not a
|
|
|
|
|
terminal, the input ends, or the interrupt ended with nothing typed. Rerunning resumes any
|
|
|
|
|
open session.
|
|
|
|
|
interrupts without a question, or quotes a line the transcript does not hold.
|
|
|
|
|
|
|
|
|
|
Each project has one session, "A <key> loop-claude", <key> being the checkout relative to ~/code,
|
|
|
|
|
or to / outside it, deleted when the chunk finishes. At every interrupt and when the chunk finishes
|
|
|
|
|
its transcript is copied to $LOOP_CLAUDE_TRANSCRIPTS/<key>/<sha256>.jsonl (default
|
|
|
|
|
~/.claude/loop-claude-transcripts), the verdict beside it in <sha256>.verdict.md.
|
|
|
|
|
Exit 2, when the human is needed and cannot answer:
|
|
|
|
|
- stdin or stdout is not a terminal, when a model must be picked or an interrupt answered
|
|
|
|
|
- the input ends while a model is picked
|
|
|
|
|
- an interrupt ends with nothing typed
|
|
|
|
|
Rerunning resumes any open session.
|
|
|
|
|
|
|
|
|
|
Every claude it starts runs the project's model, saved per <key> in ~/.claude/loop-claude-models.json
|
|
|
|
|
and read each cycle; a project without an entry, as on its first run, is asked for one.
|
|
|
|
|
LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, LOOP_CLAUDE_WORKER_MODEL for the worker and the
|
|
|
|
|
interrupt; with both set, nothing is asked.
|
|
|
|
|
|
|
|
|
|
A change to bin/loop-claude or bin/loop_claude/**/*.py takes effect at the next cycle boundary, once
|
|
|
|
|
loop-claude --help succeeds.
|
|
|
|
|
"""
|
|
|
|
|
import dataclasses
|
|
|
|
|
import pathlib
|
|
|
|
@@ -100,5 +105,5 @@ def loop_run_from(argv: list[str], cwd: pathlib.Path, effects: Effects) -> LoopR
|
|
|
|
|
return root if isinstance(root, Stop) else LoopRun(0, root, task)
|
|
|
|
|
loop_run = decode_handed(argv[1], LoopRun) if len(argv) == 2 else None
|
|
|
|
|
if not (loop_run and loop_run.root and loop_run.task):
|
|
|
|
|
return Stop(1, f"the reload cannot read the cycle number, checkout root and task the edited script was handed in {argv[1:]}, as when the edit changed what one script hands the next; rerun loop-claude <task>")
|
|
|
|
|
return Stop(1, f"the edited loop-claude cannot read the cycle number, checkout root and task the running one handed it, likely because the edit changed that handover; rerun loop-claude <task>. Handed: {' '.join(argv[1:])}")
|
|
|
|
|
return loop_run
|
|
|
|
|