Name each entry shape written_by_human checks, and annotate every parameter in loop_claude
This commit is contained in:
@@ -35,19 +35,22 @@ A change to bin/loop-claude or bin/loop_claude/**/*.py takes effect at the next
|
||||
loop-claude --help succeeds.
|
||||
"""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.claude_code.session import session_for
|
||||
from loop_claude.cycle.steps import Cycle, run_cycle
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.loop.reload import RELOAD_FLAG, LoopRun, decode_handed, exec_if_edited, fingerprint
|
||||
from loop_claude.outcome import Stop
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.project.checkout import checkout_root, project_name
|
||||
from loop_claude.project.models import project_models
|
||||
from loop_claude.project.premises import read_premises
|
||||
|
||||
|
||||
def main(argv, env, paths, launcher, cwd, effects: Effects) -> int:
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, cwd: pathlib.Path, effects: Effects) -> int:
|
||||
try:
|
||||
stop = run_loop(argv, env, paths, launcher, cwd, effects)
|
||||
except KeyboardInterrupt:
|
||||
@@ -57,7 +60,7 @@ def main(argv, env, paths, launcher, cwd, effects: Effects) -> int:
|
||||
return stop.code
|
||||
|
||||
|
||||
def run_loop(argv, env, paths, launcher, cwd, effects: Effects) -> Stop:
|
||||
def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher: pathlib.Path, cwd: pathlib.Path, effects: Effects) -> Stop:
|
||||
loop_run = loop_run_from(argv, cwd, effects)
|
||||
if isinstance(loop_run, Stop):
|
||||
return loop_run
|
||||
@@ -79,7 +82,7 @@ def run_loop(argv, env, paths, launcher, cwd, effects: Effects) -> Stop:
|
||||
return stop
|
||||
|
||||
|
||||
def loop_run_from(argv, cwd, effects: Effects) -> LoopRun | Stop:
|
||||
def loop_run_from(argv: list[str], cwd: pathlib.Path, effects: Effects) -> LoopRun | Stop:
|
||||
if argv[:1] != [RELOAD_FLAG]:
|
||||
task = " ".join(argv)
|
||||
if task in ("", "-h", "--help"):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
@@ -20,7 +21,7 @@ class LoopRun:
|
||||
task: str
|
||||
|
||||
|
||||
def decode_handed(handed, kind: type[T]) -> T | None:
|
||||
def decode_handed(handed: str, kind: type[T]) -> T | None:
|
||||
try:
|
||||
fields = json.loads(handed)
|
||||
except ValueError:
|
||||
@@ -33,7 +34,7 @@ def decode_handed(handed, kind: type[T]) -> T | None:
|
||||
return kind(**fields)
|
||||
|
||||
|
||||
def fingerprint(launcher) -> str:
|
||||
def fingerprint(launcher: pathlib.Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
for path in [launcher, *sorted((launcher.parent / "loop_claude").rglob("*.py"))]:
|
||||
try:
|
||||
@@ -44,7 +45,7 @@ def fingerprint(launcher) -> str:
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def exec_if_edited(launcher, baseline, loop_run, effects: Effects) -> Stop | None:
|
||||
def exec_if_edited(launcher: pathlib.Path, baseline: str, loop_run: LoopRun, effects: Effects) -> Stop | None:
|
||||
if fingerprint(launcher) == baseline:
|
||||
return None
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user