Move the modules rank_todo.py shares into bin/file_io/, inside reload's fingerprint
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
!agents/
|
||||
!agents/*.md
|
||||
!bin/
|
||||
!bin/file_io/
|
||||
!bin/file_io/*.py
|
||||
!bin/loop-claude
|
||||
!bin/loop_claude/
|
||||
!bin/loop_claude/**/
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
import pathlib
|
||||
import typing
|
||||
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
|
||||
|
||||
def make_private(folder: pathlib.Path) -> None:
|
||||
@@ -5,7 +5,7 @@ import pathlib
|
||||
import shutil
|
||||
import uuid
|
||||
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.paths import Paths
|
||||
|
||||
NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
from loop_claude.claude_code.entries import assistant_parts, human_text, loop_text, parse_entry, part_text, tool_call
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
|
||||
JUDGED_TOOL_INPUT = 400
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import json
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.file_writes import replace_json
|
||||
from file_io.failure import Failure
|
||||
from file_io.writes import replace_json
|
||||
|
||||
|
||||
# A failure only warns: the interrupt still runs, and the human answers Claude Code's trust dialog.
|
||||
|
||||
@@ -3,9 +3,9 @@ import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.claude_code.transcript import first_timestamped_line
|
||||
from loop_claude.file_writes import make_private, replace_file
|
||||
from file_io.writes import make_private, replace_file
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.claude_code.session import session_files
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
import uuid
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.claude_code.transcript import human_turns, read_transcript
|
||||
from loop_claude.stop import needs_human, needs_terminal, Stop
|
||||
from loop_claude.paths import Paths
|
||||
|
||||
@@ -4,7 +4,7 @@ import re
|
||||
import typing
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.claude_code.entries import hit_limit, limit_said, parse_entry, structured_output
|
||||
from loop_claude.cycle.limited import Limited
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
import typing
|
||||
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, Hu
|
||||
from loop_claude.cycle.archive import archive
|
||||
from loop_claude.claude_code.session import delete_session, Session, session_open, transcript_file
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle.interrupt import interrupt
|
||||
from loop_claude.cycle.judge import judge
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.claude_code.transcript import part_line
|
||||
from loop_claude.project.records import QUOTE_SOURCES
|
||||
|
||||
@@ -33,8 +33,8 @@ Every claude loop-claude starts runs the project's model, saved per <key> in
|
||||
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.
|
||||
A change to bin/loop-claude, bin/file_io/**/*.py 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
|
||||
|
||||
@@ -8,6 +8,7 @@ import typing
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
PACKAGES = ("file_io", "loop_claude")
|
||||
RELOAD_FLAG = "--reloaded"
|
||||
T = typing.TypeVar("T")
|
||||
|
||||
@@ -36,7 +37,7 @@ def decode_handed(handed: str, kind: type[T]) -> T | None:
|
||||
|
||||
def fingerprint(launcher: pathlib.Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
for path in [launcher, *sorted((launcher.parent / "loop_claude").rglob("*.py"))]:
|
||||
for path in [launcher, *sorted(path for package in PACKAGES for path in (launcher.parent / package).rglob("*.py"))]:
|
||||
try:
|
||||
content = path.read_bytes()
|
||||
except OSError as failure:
|
||||
|
||||
@@ -6,10 +6,10 @@ import typing
|
||||
|
||||
from loop_claude.claude_code.model_catalog import catalog_models
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.stop import needs_human, needs_terminal, Stop
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.file_writes import replace_json
|
||||
from file_io.writes import replace_json
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from loop_claude.project.checkout import read_checkout_file
|
||||
from loop_claude.markdown_sections import sections
|
||||
from file_io.markdown import sections
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
|
||||
+3
-4
@@ -57,10 +57,9 @@ import pathlib
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Kept inside loop_claude/ so reload's fingerprint covers them.
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude.markdown_sections import FENCE, sections
|
||||
from loop_claude.file_writes import replace_file
|
||||
from file_io.failure import Failure
|
||||
from file_io.markdown import FENCE, sections
|
||||
from file_io.writes import replace_file
|
||||
|
||||
EXEMPTIONS = ("", "decision", "defect", "principle", "question", "security")
|
||||
ITEMS_HEADER = "| ID | Release | Exempt | Item | R | S | A | G | Goals | Score |"
|
||||
|
||||
@@ -20,11 +20,12 @@ from loop_claude.cycle import archive, interrupt, judge, retry, run, states, wor
|
||||
from loop_claude.project import checkout, model_choice, records
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.claude_code import entries, session, transcript, trust
|
||||
from loop_claude.failure import Failure
|
||||
from loop_claude import file_writes, markdown_sections, paths
|
||||
from file_io.failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle.limited import Limited
|
||||
from loop_claude.loop import main, reload
|
||||
from file_io import markdown, writes
|
||||
from loop_claude import paths
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
CWD = pathlib.Path("/c")
|
||||
@@ -397,12 +398,12 @@ class Records(unittest.TestCase):
|
||||
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"
|
||||
self.assertEqual(markdown_sections.sections(text), {"Goals": ["1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority"], "Empty": [""], "Audience": ["me", "again"]})
|
||||
self.assertEqual(markdown.sections(text), {"Goals": ["1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority"], "Empty": [""], "Audience": ["me", "again"]})
|
||||
|
||||
def test_closes_a_fence_only_on_its_own_marker(self):
|
||||
text = "## Goals\n````md\n~~~\n## Quoted\n```\n````\n ~~~\n## Also quoted\n ~~~\n1. one\n## Audience\nme\n"
|
||||
self.assertEqual(list(markdown_sections.sections(text)), ["Goals", "Audience"])
|
||||
self.assertEqual(list(markdown_sections.sections("```\nquoted:\n```python\n## Inside\n```\n## Goals\n1. one\n")), ["Goals"])
|
||||
self.assertEqual(list(markdown.sections(text)), ["Goals", "Audience"])
|
||||
self.assertEqual(list(markdown.sections("```\nquoted:\n```python\n## Inside\n```\n## Goals\n1. one\n")), ["Goals"])
|
||||
|
||||
|
||||
class Render(unittest.TestCase):
|
||||
@@ -606,7 +607,7 @@ class ReplaceFile(unittest.TestCase):
|
||||
def test_removes_what_it_staged_when_the_replace_fails(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
os.mkdir(os.path.join(root, "in-the-way"))
|
||||
self.assertEqual(file_writes.replace_file(pathlib.Path(root, "in-the-way"), b"data"), Failure("Is a directory"))
|
||||
self.assertEqual(writes.replace_file(pathlib.Path(root, "in-the-way"), b"data"), Failure("Is a directory"))
|
||||
self.assertEqual(os.listdir(root), ["in-the-way"])
|
||||
|
||||
|
||||
|
||||
@@ -670,14 +670,15 @@ class Reload(unittest.TestCase):
|
||||
worker(append=["loop-claude", "\ndef\n"]), judge(),
|
||||
worker(replace=["loop-claude", "\ndef\n", "\n# edited\n"]), judge(),
|
||||
worker(append=["loop_claude/nested/edited.py", "# edited\n"]), judge(),
|
||||
worker(append=["file_io/writes.py", "# edited\n"]), judge(),
|
||||
worker(),
|
||||
])
|
||||
self.assertEqual(run.code, 130)
|
||||
self.assertEqual(run.roles(), ["worker", "judge"] * 4)
|
||||
self.assertEqual(run.roles(), ["worker", "judge"] * 5)
|
||||
self.assertIn("keeping the running script", run.stderr)
|
||||
reloads = [json.loads(argv[1]) for argv in run.starts if argv[:1] == ["--reloaded"]]
|
||||
self.assertEqual(reloads, [{"cycle_number": cycle, "root": str(checkout.root), "task": TASK} for cycle in (2, 3)])
|
||||
self.assertIn("=== cycle 4 ===", run.stdout)
|
||||
self.assertEqual(reloads, [{"cycle_number": cycle, "root": str(checkout.root), "task": TASK} for cycle in (2, 3, 4)])
|
||||
self.assertIn("=== cycle 5 ===", run.stdout)
|
||||
|
||||
outside = checkout.temp / "outside"
|
||||
outside.mkdir()
|
||||
|
||||
@@ -7,7 +7,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from loop_claude.failure import Failure
|
||||
from file_io.failure import Failure
|
||||
import rank_todo
|
||||
from test_python_floor import ROOT
|
||||
|
||||
|
||||
+1
-1
@@ -11,5 +11,5 @@ class Types(unittest.TestCase):
|
||||
self.assertIsNotNone(floor, "README.md's Install names `Python 3.N or newer`")
|
||||
if shutil.which("uv") is None:
|
||||
self.fail("uv on PATH fetches mypy; see README.md's Test line")
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "-m", "rank_todo", "-m", "statusline", "-p", "loop_claude"], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "-m", "rank_todo", "-m", "statusline", "-p", "file_io", "-p", "loop_claude"], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
|
||||
|
||||
Reference in New Issue
Block a user