Write the review folder under the state folder into the generated settings.json #807
@@ -70,7 +70,7 @@ build-release and build-epic run every claude in the loop's Claude home, `~/.loc
|
||||
|
||||
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. The home follows the clone whose build-release or build-epic ran last, so run only the release clone's, never the development clone's: that one would point every running loop at unreleased rules.
|
||||
|
||||
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. `settings.json` names only the default review folder, `~/.local/state/build-release/larv-review`, in `additionalDirectories`: where `XDG_STATE_HOME` moves that folder, add it to the loop's home's `settings.json` yourself, and again each time build-release or build-epic builds the home, or an interactive session asks before a reviewer writes its report. Back up these four folders:
|
||||
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. The loop's home lets a session write the review folder, `larv-review/` in the state folder, wherever `XDG_STATE_HOME` puts it. Back up these four folders:
|
||||
|
||||
- `~/.config/build-release/`: each project's config, a client project's plan and records, and `models.json`, the model of each project, which build-release and build-epic write. A project's `env-file`, if you keep it here as below, puts credentials in the backup, so keep the backup private.
|
||||
- `~/.local/state/build-release/transcripts`: every transcript build-release keeps. Where you set `BUILD_RELEASE_TRANSCRIPTS`, back up the folder it names instead.
|
||||
|
||||
+16
-12
@@ -17,6 +17,8 @@ from text_files.file_writes import replace_file
|
||||
LINKED = ("CLAUDE.md", "agents", "rules", "skills")
|
||||
# Stands for the clone's folder in the clone's settings.json. Every value that holds it is a shell command, such as a hook's.
|
||||
CLONE = "{clone}"
|
||||
# Stands for the review folder, the one under the state folder where each reviewer writes its report, which a session may write.
|
||||
REVIEWS = "{reviews}"
|
||||
# The file in the home that names the clone and the commit the home was built from.
|
||||
BUILT_FROM = "built-from"
|
||||
|
||||
@@ -28,10 +30,10 @@ class Git(typing.Protocol):
|
||||
def __call__(self, *args: str, cwd: str | None = None) -> str | Failure: ...
|
||||
|
||||
|
||||
def unready(home: pathlib.Path, clone: pathlib.Path, claude: Claude, git: Git) -> str | None:
|
||||
def unready(home: pathlib.Path, clone: pathlib.Path, reviews: pathlib.Path, claude: Claude, git: Git) -> str | None:
|
||||
"""Builds the home from clone, or refreshes it where the clone's commit changed since. Then why a claude cannot run in the home yet, said for the person to act on; None where one can."""
|
||||
try:
|
||||
built = refreshed(home, clone, claude, git)
|
||||
built = refreshed(home, clone, reviews, claude, git)
|
||||
if isinstance(built, Failure):
|
||||
return f"could not build the loop's Claude home, {home}: {built.reason}"
|
||||
status = claude(["auth", "status"])
|
||||
@@ -61,11 +63,11 @@ def printed(done: subprocess.CompletedProcess[str]) -> str:
|
||||
return " ".join((done.stderr or done.stdout).split()) or f"it printed nothing and exited {done.returncode}"
|
||||
|
||||
|
||||
def refreshed(home: pathlib.Path, clone: pathlib.Path, claude: Claude, git: Git) -> Failure | None:
|
||||
def refreshed(home: pathlib.Path, clone: pathlib.Path, reviews: pathlib.Path, claude: Claude, git: Git) -> Failure | None:
|
||||
commit = git("rev-parse", "HEAD", cwd=str(clone))
|
||||
if isinstance(commit, Failure):
|
||||
return commit
|
||||
built_from = f"{clone} at {commit.strip()}\n"
|
||||
built_from = f"{clone} at {commit.strip()}, reviews in {reviews}\n"
|
||||
home.mkdir(parents=True, exist_ok=True)
|
||||
# Several loops start at once after an update: one refreshes the home, and the others wait and find it done.
|
||||
with open(home / ".refresh-lock", "w", encoding="utf-8") as lock:
|
||||
@@ -74,7 +76,7 @@ def refreshed(home: pathlib.Path, clone: pathlib.Path, claude: Claude, git: Git)
|
||||
if stamp.is_file() and stamp.read_text(encoding="utf-8") == built_from:
|
||||
return None
|
||||
# The stamp is written last, so a refresh that failed halfway runs again.
|
||||
return linked(home, clone) or settings_written(home, clone) or plugins_installed(clone, claude) or replace_file(stamp, built_from.encode())
|
||||
return linked(home, clone) or settings_written(home, clone, reviews) or plugins_installed(clone, claude) or replace_file(stamp, built_from.encode())
|
||||
|
||||
|
||||
def linked(home: pathlib.Path, clone: pathlib.Path) -> Failure | None:
|
||||
@@ -87,9 +89,9 @@ def linked(home: pathlib.Path, clone: pathlib.Path) -> Failure | None:
|
||||
return None
|
||||
|
||||
|
||||
def settings_written(home: pathlib.Path, clone: pathlib.Path) -> Failure | None:
|
||||
"""Writes the home's settings.json: the clone's, with the clone's folder in place of CLONE, and the model the home's file holds."""
|
||||
settings = placed(json.loads((clone / "settings.json").read_text(encoding="utf-8")), shlex.quote(str(clone)))
|
||||
def settings_written(home: pathlib.Path, clone: pathlib.Path, reviews: pathlib.Path) -> Failure | None:
|
||||
"""Writes the home's settings.json: the clone's, with the clone's folder in place of CLONE and the review folder in place of REVIEWS, and the model the home's file holds."""
|
||||
settings = placed(json.loads((clone / "settings.json").read_text(encoding="utf-8")), {CLONE: shlex.quote(str(clone)), REVIEWS: str(reviews)})
|
||||
generated = home / "settings.json"
|
||||
try:
|
||||
old = json.loads(generated.read_text(encoding="utf-8")) if generated.is_file() else {}
|
||||
@@ -103,13 +105,15 @@ def settings_written(home: pathlib.Path, clone: pathlib.Path) -> Failure | None:
|
||||
return replace_file(generated, (json.dumps(settings, indent=2, sort_keys=True) + "\n").encode())
|
||||
|
||||
|
||||
def placed(value: typing.Any, clone: str) -> typing.Any:
|
||||
def placed(value: typing.Any, stand_for: dict[str, str]) -> typing.Any:
|
||||
if isinstance(value, str):
|
||||
return value.replace(CLONE, clone)
|
||||
for name, replacement in stand_for.items():
|
||||
value = value.replace(name, replacement)
|
||||
return value
|
||||
if isinstance(value, list):
|
||||
return [placed(each, clone) for each in value]
|
||||
return [placed(each, stand_for) for each in value]
|
||||
if isinstance(value, dict):
|
||||
return {key: placed(each, clone) for key, each in value.items()}
|
||||
return {key: placed(each, stand_for) for key, each in value.items()}
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ SETTINGS = {
|
||||
"enabledPlugins": {"code-review@official": True, "frontend-design@official": False, "lsp@other": True},
|
||||
"extraKnownMarketplaces": {"official": {"source": {"repo": "anthropics/official", "source": "github"}}, "other": {"source": {"repo": "someone/other", "source": "github"}}, "unused": {"source": {"repo": "someone/unused", "source": "github"}}},
|
||||
"hooks": {"PreToolUse": [{"hooks": [{"command": "{clone}/bin/rule-hook", "type": "command"}]}]},
|
||||
"permissions": {"additionalDirectories": ["{reviews}", "~/code"], "defaultMode": "bypassPermissions"},
|
||||
"tui": "fullscreen",
|
||||
}
|
||||
SIGNED_IN = json.dumps({"loggedIn": True, "authMethod": "claude.ai"})
|
||||
@@ -31,6 +32,7 @@ class Home(unittest.TestCase):
|
||||
(self.clone / "settings.json").write_text(json.dumps(SETTINGS), encoding="utf-8")
|
||||
self.home = self.temp / "share" / "claude-home"
|
||||
self.commit: str | Failure = "1a2b3c\n"
|
||||
self.reviews = self.temp / "state" / "build-release" / "larv-review"
|
||||
self.status = SIGNED_IN
|
||||
# The exit code of each `claude plugin` command, by its last argument; 0 for one not named.
|
||||
self.exits: dict[str, int] = {}
|
||||
@@ -43,7 +45,7 @@ class Home(unittest.TestCase):
|
||||
return subprocess.CompletedProcess(args, self.exits.get(args[-1], 0), "", f"no {args[-1]}\nin the marketplace\n")
|
||||
|
||||
def unready(self) -> str | None:
|
||||
return unready(self.home, self.clone, self.claude, lambda *args, cwd=None: self.commit if (args, cwd) == (("rev-parse", "HEAD"), str(self.clone)) else Failure(f"unexpected git {args} in {cwd}"))
|
||||
return unready(self.home, self.clone, self.reviews, self.claude, lambda *args, cwd=None: self.commit if (args, cwd) == (("rev-parse", "HEAD"), str(self.clone)) else Failure(f"unexpected git {args} in {cwd}"))
|
||||
|
||||
def settings(self) -> dict[str, object]:
|
||||
read: dict[str, object] = json.loads((self.home / "settings.json").read_text(encoding="utf-8"))
|
||||
@@ -64,6 +66,19 @@ class Home(unittest.TestCase):
|
||||
self.assertEqual(self.settings()["tui"], "fullscreen")
|
||||
self.assertEqual(json.loads((self.clone / "settings.json").read_text(encoding="utf-8")), SETTINGS)
|
||||
|
||||
def test_the_generated_settings_let_a_session_write_the_review_folder_wherever_the_state_folder_is(self) -> None:
|
||||
self.unready()
|
||||
|
||||
self.assertEqual(self.settings()["permissions"], {"additionalDirectories": [str(self.reviews), "~/code"], "defaultMode": "bypassPermissions"})
|
||||
|
||||
def test_a_moved_review_folder_refreshes_the_home(self) -> None:
|
||||
self.unready()
|
||||
self.reviews = self.temp / "elsewhere" / "build-release" / "larv-review"
|
||||
|
||||
self.assertIsNone(self.unready())
|
||||
|
||||
self.assertEqual(self.settings()["permissions"]["additionalDirectories"][0], str(self.reviews)) # type: ignore[index]
|
||||
|
||||
def test_it_adds_each_enabled_plugins_marketplace_then_installs_each_enabled_plugin(self) -> None:
|
||||
self.unready()
|
||||
|
||||
@@ -133,7 +148,7 @@ class Home(unittest.TestCase):
|
||||
def claude(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.CompletedProcess(args, 1, stdout, stderr) if args == ["auth", "status"] else subprocess.CompletedProcess(args, 0, "", "")
|
||||
|
||||
reason = unready(self.home, self.clone, claude, lambda *args, cwd=None: "1a2b3c\n")
|
||||
reason = unready(self.home, self.clone, self.reviews, claude, lambda *args, cwd=None: "1a2b3c\n")
|
||||
|
||||
self.assertEqual(reason, f"could not ask claude who is signed in to the loop's Claude home, {self.home}: {said}")
|
||||
|
||||
@@ -174,7 +189,7 @@ class Home(unittest.TestCase):
|
||||
def missing(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
raise FileNotFoundError(2, "No such file or directory", "claude")
|
||||
|
||||
reason = unready(self.home, self.clone, missing, lambda *args, cwd=None: "1a2b3c\n")
|
||||
reason = unready(self.home, self.clone, self.reviews, 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'")
|
||||
|
||||
@@ -182,7 +197,7 @@ class Home(unittest.TestCase):
|
||||
def stalled(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
raise subprocess.TimeoutExpired(["claude", *args], 600)
|
||||
|
||||
reason = unready(self.home, self.clone, stalled, lambda *args, cwd=None: "1a2b3c\n")
|
||||
reason = unready(self.home, self.clone, self.reviews, stalled, lambda *args, cwd=None: "1a2b3c\n")
|
||||
|
||||
self.assertEqual(reason, f"could not build the loop's Claude home, {self.home}: Command '['claude', 'plugin', 'marketplace', 'add', 'anthropics/official']' timed out after 600 seconds")
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from text_files.file_writes import replace_file
|
||||
from forge.commands import Run, runner
|
||||
from machine_load.slots import slot_folder
|
||||
from claude_home.home import unready
|
||||
from review_rules.review_folder import reports_folder
|
||||
|
||||
# Seconds before a Python script build-release runs is stopped, so a hung one, such as chunk-preflight, cannot hold the loop.
|
||||
PYTHON_TIMEOUT = 600
|
||||
@@ -127,7 +128,7 @@ def system_effects(home: pathlib.Path, env: typing.Mapping[str, str], backends:
|
||||
"""
|
||||
return Effects(
|
||||
claude=lambda args, cwd, stdin: subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=claude_environment(env, home), input=stdin, text=True),
|
||||
claude_home=lambda: unready(claude_home(env, home), RELEASE_ROOT, lambda args: subprocess.run(["claude", *args], capture_output=True, env=claude_environment(env, home), stdin=subprocess.DEVNULL, text=True, timeout=home_timeout), git_repo.git),
|
||||
claude_home=lambda: unready(claude_home(env, home), RELEASE_ROOT, reports_folder(home, env), lambda args: subprocess.run(["claude", *args], capture_output=True, env=claude_environment(env, home), stdin=subprocess.DEVNULL, text=True, timeout=home_timeout), git_repo.git),
|
||||
claude_on_terminal=claude_on_terminal,
|
||||
discard_typed=lambda: termios.tcflush(sys.stdin, termios.TCIFLUSH),
|
||||
dm=lambda text, directory: notify(text, directory, home, env, backends),
|
||||
|
||||
@@ -4078,3 +4078,20 @@ Read most (opens and searches):
|
||||
- `bin/cut_release/patch.py` 3
|
||||
- `CLAUDE.md` 2
|
||||
- `bin/cut_release/trace.py` 2
|
||||
|
||||
## Reading cost, chunk 81ec393bb45c, finished 2026-12-04T03:05:01Z
|
||||
|
||||
305346 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `README.md` 35
|
||||
- `docs/decisions.md` 13
|
||||
- `bin/build_release/test_black_box.py` 12
|
||||
- `bin/self_update/test_self_update.py` 9
|
||||
- `CLAUDE.md` 6
|
||||
- `bin/build_epic/main.py` 6
|
||||
- `bin/larv_review/reviewer_header.py` 6
|
||||
- `bin/review_replay/replay.py` 6
|
||||
- `todo.md` 6
|
||||
- `bin/build-release` 5
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@
|
||||
},
|
||||
"permissions": {
|
||||
"additionalDirectories": [
|
||||
"~/.local/state/build-release/larv-review",
|
||||
"{reviews}",
|
||||
"~/code"
|
||||
],
|
||||
"defaultMode": "bypassPermissions"
|
||||
|
||||
Reference in New Issue
Block a user