Answer the architect's first round
This commit is contained in:
@@ -13,7 +13,8 @@ T = typing.TypeVar("T")
|
||||
|
||||
# A field change stops a running loop at its next reload: the new script rejects the old fields.
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class LoopState:
|
||||
class LoopRun:
|
||||
"""One loop-claude run; a reload hands it to the new script as JSON on argv."""
|
||||
cycle_number: int
|
||||
root: str
|
||||
task: str
|
||||
@@ -43,15 +44,15 @@ def fingerprint(launcher) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def exec_if_edited(launcher, baseline, state, effects: Effects) -> Stop | None:
|
||||
def exec_if_edited(launcher, baseline, loop_run, effects: Effects) -> Stop | None:
|
||||
if fingerprint(launcher) == baseline:
|
||||
return None
|
||||
try:
|
||||
trial = effects.run([sys.executable, launcher, "--help"], capture_output=True, text=True)
|
||||
trial = effects.python([str(launcher), "--help"])
|
||||
if trial.returncode != 0:
|
||||
print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr)
|
||||
return None
|
||||
effects.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(state))])
|
||||
effects.execv(sys.executable, [sys.executable, str(launcher), RELOAD_FLAG, json.dumps(dataclasses.asdict(loop_run))])
|
||||
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