Public: anyone can read this; the crew can change it.

src/crew/runner.ts and src/crew/autonomy.ts split into modules of one concept each, with the same behaviour #16785

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

src/crew/runner.ts is split into five modules, with the same behaviour. It went from 2,736 to 2,025 lines. autonomy.ts is not touched; the issue asks for it as its own pull, and this one doesn't close #15368.

Notes

opened this

src/crew/runner.ts is split into five modules, with the same behaviour. It went from 2,736 to 2,025 lines. autonomy.ts is not touched; the issue asks for it as its own pull, and this one doesn't close #15368.

bun x tsc --noEmit and bun scripts/gate.ts are clean. 433 tests that name the runner passed, including test/crew.test.ts, crew-wrapup, crew-clone-git, module-state and tui-steer. I did not run the whole suite or the other 660-odd tests scripts/fast.ts would reach; the forge runs the full check on push.

New modules in src/crew/, each cut out of runner.ts as written:

  • steer.ts holds the sessions listening and what a person says to one, with listenForSteer, steerable and steerRun. It adds stopSteering so runner.ts no longer reaches into the steering map.
  • meter.ts holds Outcome, Meter, usageKind, meterLive and meterUsage.
  • clone.ts holds forkFor, readsAsClone, prepareClone, CLONE_EXCLUDES and GIT_TRANSFER_MS.
  • land_work.ts holds landWork.
  • credential_env.ts holds credentialEnv and holdModelCredential.

What stays in runner.ts: runner.ts re-exports every name it used to export, so no caller changed. I left work (about 1,160 lines) whole. Splitting it means changing how its local state is passed around, which is more than a same-behaviour move.

Tests changed:

  • In test/module-state.baseline.txt, steering now sits under src/crew/steer.ts.
  • The #14747 source-reading test in test/crew-clone-git.test.ts read prepareClone and landWork out of runner.ts text. It now reads clone.ts and land_work.ts and makes the same assertions.

I added no dependencies and no new logic, so there was nothing for bun scripts/similar.ts to match. The commit says No door and No look, since nothing under src/web/, pages, routes or tools changed.

To try it, run bun test test/crew.test.ts test/crew-clone-git.test.ts test/module-state.test.ts.

Closes #15368

2 earlier comments
commented

src/crew/runner.ts is split into five modules, with the same behaviour. It went from 2,736 to 2,025 lines. autonomy.ts is not touched; the issue asks for it as its own pull, and this one doesn't close #15368.

bun x tsc --noEmit and bun scripts/gate.ts are clean. 433 tests that name the runner passed, including test/crew.test.ts, crew-wrapup, crew-clone-git, module-state and tui-steer. I did not run the whole suite or the other 660-odd tests scripts/fast.ts would reach; the forge runs the full check on push.

New modules in src/crew/, each cut out of runner.ts as written:

  • steer.ts holds the sessions listening and what a person says to one, with listenForSteer, steerable and steerRun. It adds stopSteering so runner.ts no longer reaches into the steering map.
  • meter.ts holds Outcome, Meter, usageKind, meterLive and meterUsage.
  • clone.ts holds forkFor, readsAsClone, prepareClone, CLONE_EXCLUDES and GIT_TRANSFER_MS.
  • land_work.ts holds landWork.
  • credential_env.ts holds credentialEnv and holdModelCredential.

What stays in runner.ts: runner.ts re-exports every name it used to export, so no caller changed. I left work (about 1,160 lines) whole. Splitting it means changing how its local state is passed around, which is more than a same-behaviour move.

Tests changed:

  • In test/module-state.baseline.txt, steering now sits under src/crew/steer.ts.
  • The #14747 source-reading test in test/crew-clone-git.test.ts read prepareClone and landWork out of runner.ts text. It now reads clone.ts and land_work.ts and makes the same assertions.

I added no dependencies and no new logic, so there was nothing for bun scripts/similar.ts to match. The commit says No door and No look, since nothing under src/web/, pages, routes or tools changed.

To try it, run bun test test/crew.test.ts test/crew-clone-git.test.ts test/module-state.test.ts.

commented

This pull splits src/crew/runner.ts into five modules (steer, meter, clone, land_work, credential_env) with the same behaviour. It does not split autonomy.ts or work(). Those two are now their own issues. The pull is a title-only mismatch: it should be retitled "Split runner.ts into steer, meter, clone, land_work and credential_env modules". I can't change the title from here.

  • autonomy.ts (point 1): I took the second option you offered. It has its own issue, #16788, and it is not split here. #16788 is not linked to #15368 yet.
  • work() (point 4): runner.ts is still about 2,000 lines, and work() is about 1,160 of them. I did not split it here. It has its own issue, #16789, which is also not linked to #15368 yet.
  • One import path per name (point 2): I deleted the re-export lines from runner.ts. These callers now import from steer.ts, clone.ts and credential_env.ts directly:
    • in src/: actions/runs.ts, crew/one_shot.ts, crew/conversation.ts and crew/dispatch.ts;
    • in test/: sealed-git, tui-steer, child-credit, review-head-fetch and boundary-tokens-crew.
  • Leftover mess (point 3):
    • The mangled node:fs import in runner.ts is now one line.
    • I collapsed the blank-line runs in runner.ts and credential_env.ts. I made the same collapse in meter.ts, clone.ts and land_work.ts, which changed nothing there.
    • I fixed the misindented dir, in land_work.ts.
    • In steer.ts, the steerRun doc comment had ended up above steerable, so I moved each comment back to its own function.
  • New test: stopSteering is covered in test/tui-steer.test.ts. After stopSteering, steerable is false, and a late unlisten from the stopped session does nothing. I did not run it against a version with the removal broken.

Checks: bun x tsc --noEmit is clean and bun scripts/gate.ts --fix rewrapped nothing. I ran the touched test files plus crew-devices, review-failed-start, crew-guard and apps-adversarial, and all passed. crew.test.ts and crew-wrapup.test.ts passed too. I did not run the full suite, because scripts/fast.ts named 3,266 files for this change.

To try it: open / on the preview, which should answer as before. Nothing visible changes, because only imports and file layout moved.

I added an empty "Try:" commit because the pre-push hook refused the push without one. It also carries "No door:", since no page, action, route or tool changed.

🤖 Generated with Claude Code

commented

This pull splits src/crew/runner.ts only. src/crew/autonomy.ts is not touched, despite the title, and work() is not split. Both are tracked as their own issues, and #15368 now waits on them: #16788 for autonomy.ts and #16789 for work().

  • New modules: runner.ts is split into steer.ts, meter.ts, clone.ts, land_work.ts and credential_env.ts. The code is moved without changes, so behaviour is the same.
  • Imports:
    • Callers in src/ and test/ import from the new modules directly, and runner.ts no longer re-exports their names.
    • In runner.ts, the imports of the new modules are back in the import block at the top, and credential_env.ts is imported once.
    • The export { crewRoot, workdirFor } line was already on main, so it stays.
  • Clean-up from the cut: the node:fs import is one line again, the extra blank-line runs are gone, the dir, in land_work.ts is re-indented, and the doc comments in steer.ts sit above the right functions again.
  • New test: test/tui-steer.test.ts covers stopSteering. After a run stops, steerable is false, and an unlisten arriving later does nothing.

Checks: the type check (bun x tsc --noEmit) and bun scripts/gate.ts --fix are clean, and these test files pass: tui-steer, crew-devices, review-failed-start, boundary-tokens-crew and crew-guard. The full suite was not run here; the forge runs it on the push.

To try it: open / on the preview; it answers as before. Nothing visible changes, because only module layout and imports moved.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs