diff --git a/CHANGELOG.md b/CHANGELOG.md index a3c6d9a4..4e9314ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Added `claude-release`, which opens claude in the loop's Claude home with the setup loaded, in the folder you run it in, and passes every argument on to claude; `README.md` → Install says how it differs from the claude you start from your own `~/.claude`. - **The project and its repo are named `dev-factory`, in the README, the docs, the prose and the tools; the repo moved from `claude-config` on the forge.** Before you update, point each clone at the new URL, as `README.md` → Install clones it: `git remote set-url origin `. First finish the project's open chunks and stop its running `build-release`: neither the tmux session `loop-claude-config` nor a claude session named `A claude-config build-release ` is found under the new key. Then rename the setup's development clone from `~/code/claude-config` to `~/code/dev-factory`, where the tools expect it. A project's key is its clone's path relative to `~/code`, so the rename gives the project a new key. After it, set `checkout = "~/code/dev-factory"` in the project's `config.toml`, move its folder `~/.config/build-release/claude-config/` to `~/.config/build-release/dev-factory/`, move its folder under the transcripts root the same way (`~/.local/state/build-release/transcripts/`, unless `BUILD_RELEASE_TRANSCRIPTS` names another), and rename its entry in `~/.config/build-release/models.json`. The Docker image the README builds for `task-bench` is tagged `dev-factory-task-bench`, not `claude-config-task-bench`: build it again. - **The rules, agents, skills and each tool's text name a file of the setup as the setup's, as in the setup's `rules/todo-items.md`, and a project's config names one as `setup:`, as in `standards = "setup:skills/larv-review/standards"`.** Both hold wherever the release is cloned; `CLAUDE.md` → "Vocabulary" defines the setup. The loop's Claude home links `bin/` and `principles/` too, and `task-bench gather` runs its claude in that home, where it exits 1 until someone is signed in. - `.gitignore` ignores only what the repo generates, in place of an allowlist that kept a Claude home's files out of the clone. A checkout in `~/.claude` that moves past 0.17.0 would list its credentials, transcripts and memory files as untracked: run `echo '*' >> .git/info/exclude` in it, or leave it on 0.17.0. diff --git a/README.md b/README.md index 0e2271c7..b77faf31 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,9 @@ build-release and build-epic run every claude in the loop's Claude home, `~/.loc - every plugin the clone's `settings.json` enables, which build-release or build-epic installs; - what Claude Code keeps in its home: your sign-in there, the sessions and the memory files. -Sign in to the loop's home once. Until you have, build-release and build-epic stop and print the line to run, `CLAUDE_CONFIG_DIR=~/.local/share/build-release/claude-home claude`: type `/login` in the claude it opens. A model you pick there with `/model` stays in the generated `settings.json`. The loop's home has no theme or status line of yours: those stay in your own `~/.claude`, for the claude you start yourself. build-release or build-epic builds the home again once the clone holds another commit, as after `self-update`, and keeps the sign-in, the model and the sessions. It builds the home again when you change `XDG_STATE_HOME`, too. The home follows the clone whose build-release, build-epic or `task-bench gather` ran last, so run only the release clone's, never the development clone's: that one would point every running loop at unreleased rules. +Sign in to the loop's home once. Until you have, build-release and build-epic stop and print the line to run, `CLAUDE_CONFIG_DIR=~/.local/share/build-release/claude-home claude`: type `/login` in the claude it opens. A model you pick there with `/model` stays in the generated `settings.json`. The loop's home has no theme or status line of yours: those stay in your own `~/.claude`, for the claude you start yourself. build-release or build-epic builds the home again once the clone holds another commit, as after `self-update`, and keeps the sign-in, the model and the sessions. It builds the home again when you change `XDG_STATE_HOME`, too. The home follows the clone whose build-release, build-epic, `task-bench gather` or `claude-release` ran last, so run only the release clone's, never the development clone's: that one would point every running loop at unreleased rules. + +To work in the loop's home yourself, for a manual `/larv-review` or a planning talk, run `~/build-release/bin/claude-release` in the project's checkout. It builds or refreshes the home first, as above, then runs claude there and passes every argument on, so `--resume`, `-p` and `--model` work as with plain claude. Where nobody has signed in to the home yet, type `/login` in the claude it opens. The home's `settings.json` bypasses permissions, and Claude Code may still ask you to trust the folder. The setup's hooks, such as `rule-hook`, which refuses a tool call that breaks a rule a program can check, run in every claude in the loop's home: the loop's sessions and `claude-release`. The claude you start from your own `~/.claude` loads neither the setup nor its hooks. The setup keeps each project's config, and what you choose for a project, in the config folder, `~/.config/build-release/`. Its tools keep their own state, such as transcripts, review reports and locks, in the state folder, `~/.local/state/build-release/`. The loop's Claude home is in the data folder, `~/.local/share/build-release/`, which holds what build-release builds again and what Claude Code writes. Where `XDG_CONFIG_HOME` holds an absolute path, the config folder is `build-release/` under that path instead, and likewise the state folder under `XDG_STATE_HOME` and the data folder under `XDG_DATA_HOME`; this README spells the defaults. Set such a variable in the environment Claude Code starts in, since rule-hook reads it there. Back up these four folders: @@ -216,13 +218,14 @@ It applies only those commits on the newest tag, tests them with `ci.sh`, tags a ## Tools -build-release, build-epic and `task-bench gather` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts no tool on your shell's `PATH`: there, and in a claude you start from it yourself, call each by its path, `~/build-release/bin/`, from the project's checkout. Run `cut-release` from the development clone instead, as Release says. The tools under `~/build-release` are the release's; test a change to one from `~/code/dev-factory/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading. +build-release, build-epic, `task-bench gather` and `claude-release` put the release's tools first on the `PATH` of every claude they start, so this README and the rules name each tool bare, as in `metric-bench`. Install puts no tool on your shell's `PATH`: there, and in a claude you start by any other means, call each by its path, `~/build-release/bin/`, from the project's checkout. Run `cut-release` from the development clone instead, as Release says. The tools under `~/build-release` are the release's; test a change to one from `~/code/dev-factory/bin`. The tools are listed in alphabetical order, and the packages under `bin/` follow under their own heading. - `build-epic ` runs the chunks of one Jira epic whose items span repos, or have none, each in its own window of the tmux session `epic-`, on the same cycle, judge and interrupt as build-release. The epic's description is its record: goals, audience, scoring and decisions. Before it starts chunks, build-epic plans each open issue that no label places yet, as "Set up a project" says. It files a sub-task per repo where the issue changes several repos. Otherwise it labels the issue with where it is worked, and asks you where that is unclear. It plans no issue your team filed a sub-task under: those sub-tasks run instead, each under a label of its own, and your team closes the issue. Then, where two or more issues may start, it scores each of them that holds no scores, and moves the issues that build-epic itself filed into order of score on the board. An open issue runs once a label names its repo or marks it as Claude's, in order of score, as many at once as a line such as `**Max parallel chunks:** 2` in the epic's description allows, 1 without it, and as each repo's `parallel-chunks` allows. A chunk whose pull request waits on a gate parks. An open task of yours that blocks another issue gets a window that DMs you once and reads the epic every minute; once you close the task, the issues it blocked may start. `build-epic --dry-run` prints what `build-epic ` would write to Jira and which chunks it would start, and does neither; run it before the first real run on a team's epic. `--help` lists what it prints and leaves out. build-epic closes the epic only once you confirm every goal. Install → "Set up a project" says how to set it up; `build-epic --help` states the flags and the contract. - `build-epic-e2e` runs `build-epic` against a sandbox epic on a real Jira site, as Test says. - `build-release ` runs a project's next chunks, each in its own tmux window, cycle after cycle; `build-release --help` states its contract. - `chunk-pr open|sync|ready|push|merge|clean|open-epic` opens a chunk's pull request as a draft, brings its branch level with origin's default branch, marks it ready and merges it once its checks pass, with `gh` on a GitHub origin and `tea` elsewhere. Where the project's config sets `epic-branch`, the pull request goes into the epic's working branch instead, `push` pushes later commits and asks the auto-reviewer for a review, and `open-epic` opens the pull request from that branch into the default branch. The chunks of one project merge one at a time: in its turn, `merge` brings the branch level again, finishes the plan items its `--finish` flags name, and waits for the checks. Under `merge = "human"` it then marks the pull request ready and leaves the merge to a person. Once the pull request is merged, `clean` removes the chunk's worktree and branch and fast-forwards the main checkout. `chunk-pr --help` states the steps. - `chunk-preflight` finds the mechanical facts a chunk starts from, and with `--worktree` makes its worktree; `build-release` runs it with `--worktree` before it routes each chunk, and `chunk-preflight --help` lists the facts. +- `claude-release […]` runs claude in the loop's Claude home with the setup loaded, in the folder you run it in, and passes every argument on to claude; Install says why you'd want that. - `command-patterns [] [--calls ]` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release, and with `--calls ` saves each call as a JSON line; `command-patterns --help` states the columns and the line's keys. - `compress-archives` gzips each transcript in build-release's archive and each file in the review folders 30 days after it last changed, keeping all of them; Install's crontab line runs it daily. - `cut-release [--patch ]` cuts the next release of the development clone it ships in, and with `--patch` a patch release of only the commits named, as Release says. diff --git a/bin/build_release/loop/usage.py b/bin/build_release/loop/usage.py index 39e7ed2d..dad45336 100644 --- a/bin/build_release/loop/usage.py +++ b/bin/build_release/loop/usage.py @@ -31,6 +31,7 @@ build-release runs every claude in the loop's Claude home, ~/.local/share/build- which it builds from the clone it ships in before it starts anything. Until someone has signed in there, it stops and prints the command to sign in with. README.md → Install says what the home holds. +`claude-release […]` runs claude in that home, for you to talk to. build-release needs tmux 3.2 or later, and checks that too before it starts anything. Each chunk runs in its own window of one tmux session per project, named loop-, such as diff --git a/bin/claude-release b/bin/claude-release new file mode 100755 index 00000000..e9c46dca --- /dev/null +++ b/bin/claude-release @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +import os +import pathlib +import sys + +# Said before the first import of the setup's code, which an older Python cannot read. +if sys.version_info < (3, 14): + sys.exit(f"claude-release needs Python 3.14 or later as python3 on PATH; it found Python {sys.version.split()[0]}") + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) + +from claude_release import main +from loop_effects import effects + +sys.exit(main.main(sys.argv[1:], pathlib.Path.cwd(), effects.system_effects(pathlib.Path.home(), os.environ))) diff --git a/bin/claude_home/home.py b/bin/claude_home/home.py index 1ffe3000..2001d83c 100644 --- a/bin/claude_home/home.py +++ b/bin/claude_home/home.py @@ -19,6 +19,8 @@ LINKED = ("CLAUDE.md", "agents", "bin", "principles", "rules", "skills") CLONE = "{clone}" # Stands for the reports folder, which holds every chunk's review folder, in the clone's settings.json. Every value that holds it is a path, so unlike CLONE it isn't shell-quoted. REPORTS = "{reports}" +# What `unready` says first where nobody has signed in to the home yet. +SIGNED_OUT = "nobody is signed in to the loop's Claude home" # The file in the home that names the clone, its commit and the reports folder the home was built from. BUILT_FROM = "built-from" @@ -45,7 +47,12 @@ def unready(home: pathlib.Path, clone: pathlib.Path, reports: pathlib.Path, clau if signed: return None # /login is typed in a claude that runs in the home: docs/decisions.md → `Claude Code in a home of its own`. - return f"nobody is signed in to the loop's Claude home; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once" + return f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR={shlex.quote(str(home))} claude` and type /login there, once" + + +def only_signed_out(reason: str) -> bool: + """Whether a reason `unready` gave is that nobody has signed in yet.""" + return reason.startswith(SIGNED_OUT) def signed_in(status: str) -> bool | None: diff --git a/bin/claude_home/test_home.py b/bin/claude_home/test_home.py index 62b053e3..a874a2b1 100644 --- a/bin/claude_home/test_home.py +++ b/bin/claude_home/test_home.py @@ -8,7 +8,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from claude_home.home import unready +from claude_home.home import only_signed_out, unready SETTINGS = { "enabledPlugins": {"code-review@official": True, "frontend-design@official": False, "lsp@other": True}, @@ -141,6 +141,7 @@ class Home(unittest.TestCase): self.status = SIGNED_OUT self.assertEqual(self.unready(), f"nobody is signed in to the loop's Claude home; run `CLAUDE_CONFIG_DIR={self.home} claude` and type /login there, once") + self.assertTrue(only_signed_out(self.unready() or "")) def test_a_status_that_says_nobody_is_signed_in_or_out_quotes_what_claude_said(self) -> None: for stdout, stderr, said in (("", "Error: the settings\nare broken\n", "Error: the settings are broken"), ("Not logged in\n", "", "Not logged in"), ('{"authMethod": "none"}', "", '{"authMethod": "none"}'), ("3", "", "3"), ('{"loggedIn": "yes"}', "", '{"loggedIn": "yes"}'), ("", "", "it printed nothing and exited 1")): @@ -192,6 +193,7 @@ class Home(unittest.TestCase): reason = unready(self.home, self.clone, self.reports, missing, lambda *args, cwd=None: "1a2b3c\n") self.assertEqual(reason, f"could not build the loop's Claude home, {self.home}: [Errno 2] No such file or directory: 'claude'") + self.assertFalse(only_signed_out(reason)) def test_a_claude_that_is_stopped_after_its_time_stops(self) -> None: def stalled(args: list[str]) -> subprocess.CompletedProcess[str]: diff --git a/bin/claude_release/__init__.py b/bin/claude_release/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/bin/claude_release/main.py b/bin/claude_release/main.py new file mode 100644 index 00000000..65e059a3 --- /dev/null +++ b/bin/claude_release/main.py @@ -0,0 +1,18 @@ +import pathlib +import sys + +from loop_effects.effects import Effects +from claude_home.home import only_signed_out + + +# A command of its own, since `build-release claude` would take a task that starts with "claude" for this command. +def main(argv: list[str], cwd: pathlib.Path, effects: Effects) -> int: + """Runs claude on the terminal in cwd with argv as its arguments, in the loop's Claude home. Returns claude's exit code as a shell reports it, or 1 where the home isn't ready for a reason other than a missing sign-in.""" + not_ready = effects.claude_home() + # A missing sign-in doesn't stop it: the login is typed in this claude. + if not_ready and not only_signed_out(not_ready): + print(not_ready, file=sys.stderr) + return 1 + code = effects.claude_on_terminal(argv, str(cwd), {}) + # subprocess reports a claude that a signal ended as minus the signal's number, which sys.exit would turn into 256 minus it. + return 128 - code if code < 0 else code diff --git a/bin/claude_release/test_main.py b/bin/claude_release/test_main.py new file mode 100644 index 00000000..d760ca4c --- /dev/null +++ b/bin/claude_release/test_main.py @@ -0,0 +1,46 @@ +import contextlib +import io +import pathlib +import sys +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from loop_effects.doubles import FakeEffects +from claude_release import main +from claude_home.home import SIGNED_OUT + + +class ClaudeRelease(unittest.TestCase): + def run_main(self, args: list[str], fake: FakeEffects) -> tuple[int, str]: + err = io.StringIO() + with contextlib.redirect_stderr(err): + return main.main(args, pathlib.Path("/project"), fake.effects()), err.getvalue() + + def test_passes_every_argument_on_to_claude_in_the_folder_it_runs_in(self): + fake = FakeEffects(on_terminal_claude=[0]) + code, err = self.run_main(["--resume", "abc", "--model", "opus", "-p", "hi"], fake) + self.assertEqual((code, err, fake.made("claude_on_terminal"), fake.terminal_folders), (0, "", [["--resume", "abc", "--model", "opus", "-p", "hi"]], ["/project"])) + # The effect adds the home and the tools' PATH to the environment; the command doesn't add anything. + self.assertEqual(fake.terminal_environments, [{}]) + + def test_exits_with_the_code_of_claude(self): + self.assertEqual(self.run_main([], FakeEffects(on_terminal_claude=[3]))[0], 3) + + def test_opens_claude_where_nobody_is_signed_in_yet_for_the_login_typed_there(self): + fake = FakeEffects(on_terminal_claude=[0]) + fake.home_unready = f"{SIGNED_OUT}; run `CLAUDE_CONFIG_DIR=/h claude` and type /login there, once" + self.assertEqual((self.run_main([], fake)[0], len(fake.made("claude_on_terminal"))), (0, 1)) + + def test_exits_as_a_shell_reports_a_claude_that_a_signal_ended(self): + self.assertEqual(self.run_main([], FakeEffects(on_terminal_claude=[-15]))[0], 143) + + def test_stops_where_the_home_cannot_be_built(self): + fake = FakeEffects() + fake.home_unready = "could not build the loop's Claude home, /h: disk full" + code, err = self.run_main(["--resume"], fake) + self.assertEqual((code, err, fake.made("claude_on_terminal")), (1, "could not build the loop's Claude home, /h: disk full\n", [])) + + +if __name__ == "__main__": + unittest.main() diff --git a/todo.md b/todo.md index 7c809baf..44feae7b 100644 --- a/todo.md +++ b/todo.md @@ -12,8 +12,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 486 | 0.18.0 | | owner | **Open an interactive claude with the setup loaded through one wrapper command, which sets the generated home and `PATH` and passes every argument on to claude.** | 2 | 1 | 1 | 2 | 3 | 2 by 2 | 0.5 | -| 577 | 0.18.0 | 486 | owner | **Test in the gate that a container holding only a stock Claude Code runs a chunk from a clone, against a mock Messages API, and that the run leaves the container's own `~/.claude` as it was.** | 3 | 1 | 2 | 4 | 6 | 3 by 9, 2 by 5 | 5.2 | +| 577 | 0.18.0 | | owner | **Test in the gate that a container holding only a stock Claude Code runs a chunk from a clone, against a mock Messages API, and that the run leaves the container's own `~/.claude` as it was.** | 3 | 1 | 2 | 4 | 6 | 3 by 9, 2 by 5 | 5.2 | | 578 | 0.18.0 | 577 | owner | **Ship one chunk of this repo, to a merged pull request, from a clone of `main` that runs in the generated home, beside the untouched `~/.claude`.** | 1 | 2 | 1 | 2 | 1 | 2 by 4 | 1.2 | | 585 | 0.19.0 | | | **Give this repo an `AGENTS.md` like any project, and drop the decision and the rule that say it keeps none.** | 3 | 1 | 3 | 5 | 4 | code health by 3 | 3.1 | | 580 | 0.19.0 | | | **Call no scoring run for a release already cut whose last item the chunk moved to a later release.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3, 1.5 by 3 | 1.6 | @@ -102,21 +101,6 @@ ## Details -### 486. Open an interactive claude with the setup loaded through one wrapper command, which sets the generated home and `PATH` and passes every argument on to claude. - -Part of the standalone-install plan lilleman approved on 2026-11-20, as reshaped on 2026-12-03 when 0.18.0 was planned. Once the loop has its own home, the person's own claude no longer loads this setup or its rule-hook; this command is how they opt in, for a manual `/larv-review` or a planning talk. `--resume`, `-p` and `--model` work as with plain claude, and permissions come from the setup's `settings.json`. A panel seated as the audience picks its spelling; `build-release claude` was the proposal. Say in the README that only the loop's sessions and this command get rule-hook's guards. - -Where the wrapper lives is not predictable: a panel picks its spelling, and `build-release claude` would be a subcommand of the loop's command, whose package item 485 renames first. So the list names the loop's files as they are today and leaves out a new launcher. - -Touches: - -- `bin/build_release/loop/main.py`: `run_loop` (small) -- `bin/build_release/loop/usage.py`: `HELP` (small) -- `bin/build_release/loop/test_main.py` -- `bin/loop_effects/effects.py`: `claude_on_terminal` (small) -- `.gitignore` -- `README.md`: `## Install` (small), `## Tools` (small) - ### 577. Test in the gate that a container holding only a stock Claude Code runs a chunk from a clone, against a mock Messages API, and that the run leaves the container's own `~/.claude` as it was. Part of the standalone-install plan lilleman approved on 2026-11-20, as reshaped on 2026-12-03 when 0.18.0 was planned. Split from item 494, which keeps the newcomer's README. The probes behind the decision "Claude Code in a home of its own" already ran a mock Messages API at `ANTHROPIC_BASE_URL`. The test fails where goal 3 breaks: it compares `~/.claude` before and after the run. Give the container a memory and a swap limit, and run it under `run-heavy`.