Title each decision by what holds now, and make the small fixes filed against bin/, the README, .gitignore and stability-reviewer
This commit is contained in:
@@ -10,12 +10,13 @@ on the terminal, every worktree first marked trusted in ~/.claude.json. An unfin
|
||||
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".
|
||||
|
||||
Exit 1: no task, not inside a checkout, no premises, a models file it cannot read or write, claude
|
||||
leaves no transcript or one it cannot read or archive, claude cannot start for an interrupt, a
|
||||
reload with unreadable state, or 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 verdict misses or
|
||||
mistypes a field, interrupts without a question, or quotes nothing in the transcript.
|
||||
Exit 1: no task, git cannot start or finds no checkout, no premises, a models file it cannot read or
|
||||
write, claude leaves no transcript or one it cannot read or archive, claude cannot start for an
|
||||
interrupt, a reload that cannot start or reads unreadable state, or 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 verdict 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.
|
||||
@@ -63,7 +64,8 @@ def run_loop(argv, env, paths, launcher, cwd) -> Stop:
|
||||
project = project_name(state.root, paths.code)
|
||||
session = session_for(project, paths)
|
||||
while True:
|
||||
exec_if_edited(launcher, baseline, state)
|
||||
if stop := exec_if_edited(launcher, baseline, state):
|
||||
return stop
|
||||
state = dataclasses.replace(state, cycle_number=state.cycle_number + 1)
|
||||
premises = read_premises(state.root)
|
||||
if isinstance(premises, Stop):
|
||||
|
||||
@@ -6,6 +6,8 @@ import subprocess
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.outcome import Stop
|
||||
|
||||
RELOAD_FLAG = "--reloaded"
|
||||
T = typing.TypeVar("T")
|
||||
|
||||
@@ -42,11 +44,15 @@ def fingerprint(launcher) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def exec_if_edited(launcher, baseline, state) -> None:
|
||||
def exec_if_edited(launcher, baseline, state) -> Stop | None:
|
||||
if fingerprint(launcher) == baseline:
|
||||
return
|
||||
trial = subprocess.run([sys.executable, launcher, "--help"], capture_output=True, text=True)
|
||||
if trial.returncode != 0:
|
||||
print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr)
|
||||
return
|
||||
os.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(state))])
|
||||
return None
|
||||
try:
|
||||
trial = subprocess.run([sys.executable, launcher, "--help"], capture_output=True, text=True)
|
||||
if trial.returncode != 0:
|
||||
print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr)
|
||||
return None
|
||||
os.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(state))])
|
||||
except OSError as failure:
|
||||
return Stop(1, f"could not reload loop-claude: {failure.strerror}; rerun loop-claude <task>")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user