Run every claude the loop starts in a Claude home generated outside the clone
CI / tests (pull_request) Successful in 4m45s
CI / tests (pull_request) Successful in 4m45s
This commit is contained in:
@@ -71,9 +71,9 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
|
||||
loop_run = loop_run_from(argv, cwd, effects)
|
||||
if isinstance(loop_run, Stop):
|
||||
return loop_run
|
||||
# Before anything starts: a worktree, a claude session or a tmux window.
|
||||
if reason := tmux.unusable(effects.tmux, fresh_prompt.DRIVER):
|
||||
return Stop(1, reason)
|
||||
# Before anything starts: a worktree, a claude session or a tmux window. One stop names everything that is the person's to do.
|
||||
if needs := [reason for reason in (tmux.unusable(effects.tmux, fresh_prompt.DRIVER), effects.claude_home()) if reason]:
|
||||
return Stop(1, "\n".join(needs))
|
||||
if loop_run.chunk is None:
|
||||
return windows_opened(loop_run, env, paths, launcher, effects, steps.start_chunks)
|
||||
pane = env.get("TMUX_PANE")
|
||||
|
||||
@@ -137,6 +137,15 @@ class WindowStarts(unittest.TestCase):
|
||||
self.assertEqual(self.run_loop(["do it"], fake), (Stop(1, "build-release runs each chunk in a tmux window, and needs tmux 3.2 or later; it found tmux 3.1c"), ""))
|
||||
self.assertEqual((fake.tmux_calls, self.asked), ([["-V"]], []))
|
||||
|
||||
def test_refuses_to_start_anything_until_a_claude_can_run_in_the_loops_claude_home_and_names_all_that_is_the_persons_at_once(self):
|
||||
fake = FakeEffects(git=["/r\n"], tmux_version="tmux 3.1c")
|
||||
fake.home_unready = "nobody is signed in"
|
||||
self.assertEqual(self.run_loop(["do it"], fake), (Stop(1, "build-release runs each chunk in a tmux window, and needs tmux 3.2 or later; it found tmux 3.1c\nnobody is signed in"), ""))
|
||||
fake = FakeEffects(git=["/r\n"])
|
||||
fake.home_unready = "nobody is signed in"
|
||||
self.assertEqual(self.run_loop(["do it"], fake), (Stop(1, "nobody is signed in"), ""))
|
||||
self.assertEqual(self.asked, [])
|
||||
|
||||
def test_prints_the_help_without_tmux(self):
|
||||
fake = FakeEffects(tmux_version="")
|
||||
self.assertEqual(self.run_loop(["--help"], fake)[0], Stop(0, usage.HELP))
|
||||
@@ -172,7 +181,7 @@ class WindowStarts(unittest.TestCase):
|
||||
run_cycle=lambda cycle: concluded.pop(0), closed_cycle=lambda *args: closed.pop(0), check_routing=lambda *args: None)
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
stop = main.run_loop(["--chunk", "item-3", "do it"], env, paths.paths_from(self.HOME, {}), launcher, CWD, effects, taken)
|
||||
loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".claude" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=paths.paths_from(self.HOME, {}), env=env, launcher=launcher, effects=effects)
|
||||
loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".local" / "share" / "build-release" / "claude-home" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=paths.paths_from(self.HOME, {}), env=env, launcher=launcher, effects=effects)
|
||||
self.assertEqual(stop, Stop(0, ""))
|
||||
self.assertEqual(cycles, [(main.LoopRun(1, "/r", "do it", "", chunk="item-3"), loop), (main.LoopRun(2, "/r", "do it", "", chunk="item-3"), loop)])
|
||||
self.assertEqual(started, [(main.LoopRun(2, "/r", "do it", "", chunk="item-3"), True, loop.paths, env, launcher, effects)])
|
||||
@@ -189,7 +198,7 @@ class WindowStarts(unittest.TestCase):
|
||||
return lambda *args: calls.append((name, *args)) or answers[name](*args)
|
||||
|
||||
stop = main.run_loop(["--chunk", "item-3", "do it"], env, home, launcher, CWD, effects, steps(lambda *args: self.fail(args), **{name: step(name) for name in answers}))
|
||||
self.loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".claude" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=home, env=env, launcher=launcher, effects=effects)
|
||||
self.loop = this_loop.Loop(root="/r", session=session.session_named("A r build-release item-3", self.HOME / ".local" / "share" / "build-release" / "claude-home" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=home, env=env, launcher=launcher, effects=effects)
|
||||
return stop, calls
|
||||
|
||||
def test_a_window_loop_hands_each_step_of_a_cycle_what_the_steps_before_it_made(self):
|
||||
|
||||
@@ -56,7 +56,7 @@ class ExitContract(unittest.TestCase):
|
||||
("agent_cycle/run.py", "close", "1", "failure.reason", read),
|
||||
("agent_cycle/run.py", "close", "1", "failure.reason", "a finished chunk's session cannot be deleted"),
|
||||
("build_release/loop/checkout.py", "checkout_root", "1", "found.reason", git),
|
||||
("build_release/loop/main.py", "run_loop", "1", "reason", "tmux is missing or older than 3.2"),
|
||||
("build_release/loop/main.py", "run_loop", "1", "'\\n'.join(needs)", "tmux is missing or older than 3.2, the loop's Claude home cannot be built, or nobody is signed in there"),
|
||||
("build_release/loop/main.py", "run_loop", "1", "f'{CHUNK_FLAG} is how build-release starts itself", "--chunk is given outside a tmux window"),
|
||||
("build_release/loop/main.py", "windows_opened", "1", "started.reason", "a chunk's window cannot be started"),
|
||||
("build_release/loop/main.py", "windows_opened", "1", "f\"`tmux {' '.join(shown)}` failed", "the tmux session cannot be put on the terminal"),
|
||||
|
||||
@@ -27,7 +27,11 @@ chunk starts a fresh session. Cycles continue until an exit below or Ctrl-C, eit
|
||||
that one chunk.
|
||||
Words: the setup's CLAUDE.md → "Vocabulary".
|
||||
|
||||
build-release needs tmux 3.2 or later, and checks it before it starts anything. Each chunk runs in
|
||||
build-release runs every claude in the loop's Claude home, ~/.local/share/build-release/claude-home,
|
||||
which it builds from the clone it ships in before it starts anything. Until someone has signed in
|
||||
there, it stops and prints the line that does so. README.md → Install says what the home holds.
|
||||
|
||||
build-release needs tmux 3.2 or later, and checks that first too. Each chunk runs in
|
||||
its own window of one tmux session per project, named loop-<key>, such as loop-claude-config. <key>
|
||||
is the checkout's path relative to ~/code, or to / outside it, with a dash for each character other
|
||||
than a letter, a digit, _ or -. The tmux session's @loop-root option names its checkout, and a
|
||||
@@ -169,7 +173,8 @@ window closes, so the next build-release <task> reads the plan again.
|
||||
Exit 1, saying why, when:
|
||||
- no task is given
|
||||
- git cannot start or finds no checkout
|
||||
- tmux is missing or older than 3.2
|
||||
- tmux is missing or older than 3.2, the loop's Claude home cannot be built, or nobody is signed
|
||||
in there
|
||||
- --chunk is given outside a tmux window
|
||||
- a chunk's window cannot be started, as when the project's config cannot be read, or the tmux
|
||||
session runs another checkout's chunks
|
||||
|
||||
Reference in New Issue
Block a user