diff --git a/.gitignore b/.gitignore index abba4dcf..24919d6e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ !bin/ !bin/* !bin/loop_claude/*.py +!bin/loop_claude/*/ +!bin/loop_claude/*/*.py !docs/ !docs/*.md !principles/ diff --git a/README.md b/README.md index 0ba7dd96..1bf70584 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Claude Code configuration -My personal `~/.claude`, version controlled: `CLAUDE.md` and `AGENTS.md` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold every project and every review to; `docs/` for decisions; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `statusline.sh`; `CHANGELOG.md` and `todo.md`; and the tools in `bin/`. +My personal `~/.claude`, version controlled: `CLAUDE.md` and `AGENTS.md` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold every project to; `docs/` for decisions; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `statusline.sh`; `CHANGELOG.md` and `todo.md`; and the tools in `bin/`. ## Goals diff --git a/agents/product-owner-reviewer.md b/agents/product-owner-reviewer.md index c253e899..9f252975 100644 --- a/agents/product-owner-reviewer.md +++ b/agents/product-owner-reviewer.md @@ -45,7 +45,7 @@ Before anything else, **read the shared principles** at `~/.claude/principles/`. ## Your Output Format -Verdict, severities, rounds and declines: ~/.claude/principles/review-findings.md. After the verdict: +Verdict, severities, rounds and declines: ~/.claude/skills/larv-review/review-findings.md. After the verdict: **Surface affected**: diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 62ea2850..10be9e9f 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -128,7 +128,7 @@ Every PR gets at least this sweep. ## Output Format -Verdict, severities, rounds and declines: ~/.claude/principles/review-findings.md. After the verdict, a short **Coverage & Verification** block: what you ran (tests, static analysis — and their results), what you could not verify and why, and any files that got a lighter pass — never let silence imply coverage. Then the findings, most severe first, each with: +Verdict, severities, rounds and declines: ~/.claude/skills/larv-review/review-findings.md. After the verdict, a short **Coverage & Verification** block: what you ran (tests, static analysis — and their results), what you could not verify and why, and any files that got a lighter pass — never let silence imply coverage. Then the findings, most severe first, each with: - **Location**: File and line/function - **Issue**: Clear description of the problem - **Risk**: What could go wrong in production diff --git a/agents/systems-architect.md b/agents/systems-architect.md index 5266bb77..24b8bb78 100644 --- a/agents/systems-architect.md +++ b/agents/systems-architect.md @@ -151,7 +151,7 @@ How a change ships — merge gate, pipeline, deployment, dependencies — is a d You are not a per-PR reviewer. The **stability-reviewer** runs on every change for code-level safety; you run deliberately, every so often, to check the system is still aligned — right goals, right contract, right foundations, sound structure. When you do look at a specific PR, it is because the work touches architectural fundamentals or reopens foundational choices, not for routine line-level review. Stage 0 blocks review as much as design: if the project's purpose and goals are not abundantly clear from its docs, this run's output is the clarifying questions plus a short draft to confirm — not a review; the review happens in a later invocation, once the answers are recorded in the README. -**Verdict and severities: ~/.claude/principles/review-findings.md.** A violation of a non-negotiable fundamental — functional-core/shell entanglement, a unit past a Fits in a head threshold without a stated reason, a method or file carrying more than one responsibility, unreasoned duplication of a core concept, or a broken/leaky external contract — is a 🔴: lead with it, and name the concrete restructuring. The most common instance: a pure transformation (a deterministic input→output computation) entangled inside an imperative-shell or orchestration method, where it could be a named, separately-testable function. The architectural defect being real, not its line count or "how much it works today," sets the severity; rate a non-fundamental finding by its eventual cost — the recorded horizon sets that cost; fundamentals stay 🔴 at every horizon (Core Philosophy: rigor follows the horizon). +**Verdict and severities: ~/.claude/skills/larv-review/review-findings.md.** A violation of a non-negotiable fundamental — functional-core/shell entanglement, a unit past a Fits in a head threshold without a stated reason, a method or file carrying more than one responsibility, unreasoned duplication of a core concept, or a broken/leaky external contract — is a 🔴: lead with it, and name the concrete restructuring. The most common instance: a pure transformation (a deterministic input→output computation) entangled inside an imperative-shell or orchestration method, where it could be a named, separately-testable function. The architectural defect being real, not its line count or "how much it works today," sets the severity; rate a non-fundamental finding by its eventual cost — the recorded horizon sets that cost; fundamentals stay 🔴 at every horizon (Core Philosophy: rigor follows the horizon). Focus on architectural alignment: - Does it still serve the project's goals and priorities, or has it quietly drifted from them? diff --git a/bin/loop_claude/claude_code/__init__.py b/bin/loop_claude/claude_code/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bin/loop_claude/claude_code.py b/bin/loop_claude/claude_code/formats.py similarity index 100% rename from bin/loop_claude/claude_code.py rename to bin/loop_claude/claude_code/formats.py diff --git a/bin/loop_claude/session.py b/bin/loop_claude/claude_code/session.py similarity index 87% rename from bin/loop_claude/session.py rename to bin/loop_claude/claude_code/session.py index 8198ce99..fcc33fc7 100644 --- a/bin/loop_claude/session.py +++ b/bin/loop_claude/claude_code/session.py @@ -5,8 +5,8 @@ import shutil import sys import uuid -from loop_claude.checkout import project_name -from loop_claude.claude_code import session_files, transcript_path +from loop_claude.project.checkout import project_name +from loop_claude.claude_code.formats import session_files, transcript_path NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec") diff --git a/bin/loop_claude/transcript.py b/bin/loop_claude/claude_code/transcript.py similarity index 89% rename from bin/loop_claude/transcript.py rename to bin/loop_claude/claude_code/transcript.py index 2ddf768e..e73ffdbb 100644 --- a/bin/loop_claude/transcript.py +++ b/bin/loop_claude/claude_code/transcript.py @@ -1,6 +1,6 @@ import json -from loop_claude.claude_code import assistant_parts, human_text, parse, part_text, tool_call +from loop_claude.claude_code.formats import assistant_parts, human_text, parse, part_text, tool_call from loop_claude.outcome import Failure diff --git a/bin/loop_claude/trust.py b/bin/loop_claude/claude_code/trust.py similarity index 91% rename from bin/loop_claude/trust.py rename to bin/loop_claude/claude_code/trust.py index 68d9b4e7..715254d5 100644 --- a/bin/loop_claude/trust.py +++ b/bin/loop_claude/claude_code/trust.py @@ -1,7 +1,7 @@ import json import sys -from loop_claude.claude_code import mark_trusted, trust_records +from loop_claude.claude_code.formats import mark_trusted, trust_records from loop_claude.file_writes import replace_json from loop_claude.outcome import Failure diff --git a/bin/loop_claude/claude_runs/__init__.py b/bin/loop_claude/claude_runs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bin/loop_claude/interrupt.py b/bin/loop_claude/claude_runs/interrupt.py similarity index 85% rename from bin/loop_claude/interrupt.py rename to bin/loop_claude/claude_runs/interrupt.py index 5a965f7d..8b291b27 100644 --- a/bin/loop_claude/interrupt.py +++ b/bin/loop_claude/claude_runs/interrupt.py @@ -2,10 +2,10 @@ import subprocess import sys from loop_claude import human -from loop_claude.checkout import checkouts +from loop_claude.project.checkout import checkouts from loop_claude.outcome import Failure, Stop -from loop_claude.transcript import human_turns, read -from loop_claude.trust import trust +from loop_claude.claude_code.transcript import human_turns, read +from loop_claude.claude_code.trust import trust TO = "answer the question above" diff --git a/bin/loop_claude/judge.py b/bin/loop_claude/claude_runs/judge.py similarity index 98% rename from bin/loop_claude/judge.py rename to bin/loop_claude/claude_runs/judge.py index 943586ad..d1908bd8 100644 --- a/bin/loop_claude/judge.py +++ b/bin/loop_claude/claude_runs/judge.py @@ -2,7 +2,7 @@ import itertools import json import subprocess -from loop_claude.claude_code import structured_output +from loop_claude.claude_code.formats import structured_output from loop_claude.outcome import Failure from loop_claude.retry import stop_or_sleep_a_minute diff --git a/bin/loop_claude/worker.py b/bin/loop_claude/claude_runs/worker.py similarity index 90% rename from bin/loop_claude/worker.py rename to bin/loop_claude/claude_runs/worker.py index ec73096f..836c2b72 100644 --- a/bin/loop_claude/worker.py +++ b/bin/loop_claude/claude_runs/worker.py @@ -1,8 +1,8 @@ import subprocess -from loop_claude.claude_code import assistant_parts, ends_stream, parse +from loop_claude.claude_code.formats import assistant_parts, ends_stream, parse from loop_claude.outcome import Failure -from loop_claude.transcript import part_line +from loop_claude.claude_code.transcript import part_line def run_worker(root, args): diff --git a/bin/loop_claude/cycle.py b/bin/loop_claude/cycle.py index 14055c31..2e2997ef 100644 --- a/bin/loop_claude/cycle.py +++ b/bin/loop_claude/cycle.py @@ -1,14 +1,14 @@ import hashlib import sys -from loop_claude.checkout import project_name +from loop_claude.project.checkout import project_name from loop_claude.file_writes import make_private, replace_file -from loop_claude.interrupt import interrupt -from loop_claude.judge import judge +from loop_claude.claude_runs.interrupt import interrupt +from loop_claude.claude_runs.judge import judge from loop_claude.outcome import Continue, Failure, Stop -from loop_claude.session import delete_session, session_for, transcript_file -from loop_claude.transcript import read, render -from loop_claude.worker import run_worker, worker_args +from loop_claude.claude_code.session import delete_session, session_for, transcript_file +from loop_claude.claude_code.transcript import read, render +from loop_claude.claude_runs.worker import run_worker, worker_args def run_cycle(root, task, premises, models, paths): diff --git a/bin/loop_claude/main.py b/bin/loop_claude/main.py index 37c2c262..6d331777 100644 --- a/bin/loop_claude/main.py +++ b/bin/loop_claude/main.py @@ -30,17 +30,17 @@ and read each cycle; a project without an entry, as on its first run, is asked f 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 +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 sys -from loop_claude.checkout import checkout_root +from loop_claude.project.checkout import checkout_root from loop_claude.cycle import run_cycle -from loop_claude.models import project_models +from loop_claude.project.models import project_models from loop_claude.outcome import Continue, Failure, Stop -from loop_claude.premises import read_premises +from loop_claude.project.premises import read_premises from loop_claude.reload import RELOAD_FLAG, decode_state, exec_if_edited, fingerprint from loop_claude.retry import stop_or_sleep_a_minute diff --git a/bin/loop_claude/paths.py b/bin/loop_claude/paths.py index 7f42eabe..ba1153bb 100644 --- a/bin/loop_claude/paths.py +++ b/bin/loop_claude/paths.py @@ -1,7 +1,7 @@ import dataclasses import pathlib -from loop_claude.claude_code import locations +from loop_claude.claude_code.formats import locations @dataclasses.dataclass(frozen=True) diff --git a/bin/loop_claude/project/__init__.py b/bin/loop_claude/project/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bin/loop_claude/checkout.py b/bin/loop_claude/project/checkout.py similarity index 100% rename from bin/loop_claude/checkout.py rename to bin/loop_claude/project/checkout.py diff --git a/bin/loop_claude/models.py b/bin/loop_claude/project/models.py similarity index 96% rename from bin/loop_claude/models.py rename to bin/loop_claude/project/models.py index fa02b44a..4b3d122e 100644 --- a/bin/loop_claude/models.py +++ b/bin/loop_claude/project/models.py @@ -3,8 +3,8 @@ import json import sys from loop_claude import human -from loop_claude.checkout import project_name -from loop_claude.claude_code import catalog +from loop_claude.project.checkout import project_name +from loop_claude.claude_code.formats import catalog from loop_claude.file_writes import replace_json from loop_claude.outcome import Stop diff --git a/bin/loop_claude/premises.py b/bin/loop_claude/project/premises.py similarity index 100% rename from bin/loop_claude/premises.py rename to bin/loop_claude/project/premises.py diff --git a/bin/loop_claude/reload.py b/bin/loop_claude/reload.py index 4e8f7af6..ba23f9b5 100644 --- a/bin/loop_claude/reload.py +++ b/bin/loop_claude/reload.py @@ -23,12 +23,12 @@ def decode_state(handed, kind): def fingerprint(launcher): digest = hashlib.sha256() - for path in [launcher, *sorted((launcher.parent / "loop_claude").glob("*.py"))]: + for path in [launcher, *sorted((launcher.parent / "loop_claude").rglob("*.py"))]: try: content = path.read_bytes() except OSError as failure: content = str(failure).encode() - digest.update(f"{path.name}\0{len(content)}\0".encode() + content) + digest.update(f"{path.relative_to(launcher.parent)}\0{len(content)}\0".encode() + content) return digest.hexdigest() diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 09e6a87b..28674499 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -7,8 +7,11 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) -from loop_claude import claude_code, file_writes, judge, main, premises, transcript +from loop_claude import file_writes, main +from loop_claude.claude_code import formats, transcript +from loop_claude.claude_runs import judge from loop_claude.outcome import Failure, Stop +from loop_claude.project import premises CWD = pathlib.Path("/c") @@ -68,9 +71,9 @@ class PartLine(unittest.TestCase): class Parse(unittest.TestCase): def test_yields_only_json_objects(self): - self.assertEqual(claude_code.parse('{"type": "user"}'), {"type": "user"}) - self.assertIsNone(claude_code.parse("not json")) - self.assertIsNone(claude_code.parse("[1, 2]")) + self.assertEqual(formats.parse('{"type": "user"}'), {"type": "user"}) + self.assertIsNone(formats.parse("not json")) + self.assertIsNone(formats.parse("[1, 2]")) class Grounded(unittest.TestCase): diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 90b8ce99..0a48d32f 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -9,7 +9,7 @@ You orchestrate, fix, and ship; reviewers only report. Run every reviewer synchr **Forge-neutral.** Five PR operations recur below: read a PR's diff, open a draft PR, read check status, mark ready, merge. Resolve the tooling from the remote per `~/.claude/CLAUDE.md` → "Git, commits, and PRs"; on any other forge, achieve the same intents through its CLI or API — discover how rather than assuming. A forge without a native draft state gets the closest equivalent (a `WIP:`/`Draft:` title prefix); note any approximation in the summary. -Words: `~/.claude/CLAUDE.md` → "Vocabulary". Findings, for every reviewer: ~/.claude/principles/review-findings.md. +Words: `~/.claude/CLAUDE.md` → "Vocabulary". Findings, for every reviewer: ~/.claude/skills/larv-review/review-findings.md. ## 1. Preconditions diff --git a/principles/review-findings.md b/skills/larv-review/review-findings.md similarity index 100% rename from principles/review-findings.md rename to skills/larv-review/review-findings.md diff --git a/todo.md b/todo.md index e11ccd80..b0495a52 100644 --- a/todo.md +++ b/todo.md @@ -8,7 +8,6 @@ The rebuild lifts every dimension: each item below is one chunk on a worktree ba The places the panel on `rebuild` at 37edc9a named (`docs/decisions.md`), capping dimension first: -- **Group `bin/loop_claude/`'s 18 flat modules, and move `principles/review-findings.md` beside larv-review.** Two seats; `claude_code.py` is the first group. - **Show the judge a reply the human sends while claude works.** Claude Code 2.1.284 writes it as an `"attachment"` entry, which `render` drops, so the judge can rule on a question the human already answered during an interrupt. - **Score `rebuild` with the four-seat panel at 7.0 or above on every dimension and the overall, none below the last run, and open its PR into main for the human.** ⚠️ Leave that PR ready and unmerged: only the human merges it, after approving the whole rebuild. A dimension under the floor gets its places filed above this item.