Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(cli): give worktree setup an actionable model next step [I1,I2]
Corey Olson8c293fb668a5
diff --git a/src/cli.js b/src/cli.jsindex 9ccc8f9c..85bc6cf8 100644--- a/src/cli.js+++ b/src/cli.js@@ -606,10 +606,14 @@ async function bindCheckoutSession(io, positionals, values) {}/** Choose an explicitly supplied model or the standard environment fallback, refusing an unknown identity. */-function requiredModel(value, env = process.env) {+function requiredModel(value, env = process.env, commandNext) {const model = (value ?? env.PULLBOARD_MODEL ?? '').trim();if (!model || /[\u0000-\u001f\u007f-\u009f]/u.test(model)) {- throw new Refused('MODEL_REQUIRED', 'give --model "<model name>" or set PULLBOARD_MODEL in this shell before joining');+ const suffix = commandNext ? `; run pullboard ${commandNext} --model "<model name>"` : '';+ const message = commandNext+ ? `this session has not declared its model${suffix}`+ : 'give --model "<model name>" or set PULLBOARD_MODEL in this shell before joining';+ throw new Refused('MODEL_REQUIRED', message);}return model;}@@ -851,6 +855,7 @@ function agentRefusalText(message, code, name) {/** Read current display settings for text refusals; the structured error retains its stable identifiers. */function displayedRefusal(io, error) {+ if (error.code === 'MODEL_REQUIRED') return error.message.replace(/; run pullboard .+$/u, '');if (!['ALREADY_JOINED', 'HELD', 'ITEM_HELD', 'LANE_HELD', 'REVIEW_HELD', 'NOT_YOURS', 'NOT_YOUR_DECISION', 'NO_AGENT', 'NOT_YOUR_CHECKOUT', 'FACT_JUDGEMENT', 'RELAY_PERSON_ONLY', 'RELAY_SENDER_MISMATCH', 'SELF_SHOUT', 'NO_READER'].includes(error.code)) return error.message;try {const ctx = context(io);@@ -1624,7 +1629,7 @@ function setupCommands(io, { first, values }) {if (ctx.info.isMain) {if (first !== COORDINATOR) throw new Refused('MAIN_IS_COORDINATOR', 'the main checkout is the coordinator; join from a worktree: git worktree add ../<dir>');const route = values.route ?? 'strong';- const model = requiredModel(values.model);+ const model = requiredModel(values.model, process.env, `join ${shellWord(COORDINATOR)}${values.route ? ` --route ${shellWord(values.route)}` : ''}${values.family ? ` --family ${shellWord(values.family)}` : ''}`);if (relayLinked(ctx.info.root)) refuseRemoteCoordinatorModel(ctx, 'join coordinator');const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [{ lane: COORDINATOR, path: ctx.info.root, route, family: values.family, model },@@ -1638,7 +1643,7 @@ function setupCommands(io, { first, values }) {throw new Refused('NO_LANE', `no lane "${first ?? ''}"; lanes: ${laneNames(ctx.config).slice(1).join(', ') || 'none yet, declare them in pullboard.json'}`);}const route = values.route ?? 'strong';- const model = requiredModel(values.model);+ const model = requiredModel(values.model, process.env, `join ${shellWord(first)}${values.route ? ` --route ${shellWord(values.route)}` : ''}${values.family ? ` --family ${shellWord(values.family)}` : ''}`);const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [{ lane: first, path: ctx.info.root, route, family: values.family, model }]));const displayName = displayAgentName({ agent_id: id, agent_model: model }, ctx.config.agents.names);io.result?.({ agent: id, lane: first, route, path: ctx.info.root, model, displayName });@@ -1675,7 +1680,7 @@ async function worktreeFor(io, lane, route, family = null, model) {if (!store.ROUTES.includes(route)) {throw new Refused('BAD_ROUTE', `route "${route}" is strong (needs a frontier model) or light (any model can build it from the brief)`);}- model = requiredModel(model);+ model = requiredModel(model, process.env, `worktree ${shellWord(lane)}${route === 'strong' ? '' : ` --route ${shellWord(route)}`}${family ? ` --family ${shellWord(family)}` : ''}`);const mainRoot = resolve(ctx.info.commonDir, '..');refuseUncommittedSetup(mainRoot, ctx.config);const pathFor = (n) => join(dirname(mainRoot), `${basename(mainRoot)}-${lane}-${n}`);diff --git a/test/worktree-start.test.js b/test/worktree-start.test.jsnew file mode 100644index 00000000..6ad00ebf--- /dev/null+++ b/test/worktree-start.test.js@@ -0,0 +1,69 @@+/** A fresh main checkout uses its declared model for an agent worktree [I1,I2]. */+import assert from 'node:assert/strict';+import { join, resolve } from 'node:path';+import { after, test } from 'node:test';+import { createE2eHelpers } from './e2e-helpers.js';+import { runFixtureChild } from './fixture-child.js';++const e2e = createE2eHelpers();+after(e2e.cleanup);+const { sandbox, project } = e2e;+const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');++test("the README's worktree command works in a fresh repo [I1,I2]", () => {+ const box = sandbox();+ const { repo } = project('true', box);+ box.env.CODEX_THREAD_ID = 'main-owner-session';+ box.env.PULLBOARD_MODEL = 'Coordinator Session Model';+ const coordinator = box.run(repo, 'join', 'coordinator', '--model', 'Coordinator Session Model');+ assert.equal(coordinator.code, 0, coordinator.err || coordinator.out);++ box.env.PULLBOARD_MODEL = 'Session Worktree Model';+ const made = box.run(repo, 'worktree', 'web', '--json');+ assert.equal(made.code, 0, made.err || made.out);+ const madeResult = JSON.parse(made.out);+ assert.equal(madeResult.model, 'Session Worktree Model',+ 'worktree takes the model from PULLBOARD_MODEL');+ const joinedIdentity = box.run(madeResult.path, 'whoami', '--json');+ assert.equal(joinedIdentity.code, 0, joinedIdentity.err || joinedIdentity.out);+ const identity = JSON.parse(joinedIdentity.out);+ assert.equal(identity.lane, 'web');+ assert.equal(identity.model, 'Session Worktree Model', 'the created worktree is joined under its declared model');++ delete box.env.PULLBOARD_MODEL;+ const before = box.git(repo, 'worktree', 'list', '--porcelain');+ const missingWorktreeModel = runFixtureChild(process.execPath, [BIN, 'worktree', 'api'],+ { cwd: repo, env: box.env, encoding: 'utf8' });+ assert.equal(missingWorktreeModel.status, 1);+ assert.equal(missingWorktreeModel.stderr,+ 'pullboard: [MODEL_REQUIRED] this session has not declared its model\nnext: run pullboard worktree api --model "<model name>"\n');+ const missingWorktreeJson = box.run(repo, 'worktree', 'api', '--json');+ assert.equal(missingWorktreeJson.code, 1);+ assert.equal(JSON.parse(missingWorktreeJson.out).error.next,+ 'run pullboard worktree api --model "<model name>"');+ assert.equal(box.git(repo, 'worktree', 'list', '--porcelain'), before,+ 'missing model guidance does not create a worktree');+ assert.equal(box.tryGit(repo, 'rev-parse', '--verify', '--quiet', 'refs/heads/api/1').status, 1,+ 'missing model guidance does not create a branch');++ box.env.PULLBOARD_MODEL = 'Session Join Model';+ const envJoin = join(box.dir, 'env-join');+ box.git(repo, 'worktree', 'add', '-q', '--detach', envJoin, 'HEAD');+ const joined = box.run(envJoin, 'join', 'api');+ assert.equal(joined.code, 0, joined.err || joined.out);+ assert.match(joined.out, /joined as api-1 \(Session Join Model\)/,+ 'join takes the model from PULLBOARD_MODEL');++ delete box.env.PULLBOARD_MODEL;+ const missingJoin = join(box.dir, 'join-without-model');+ box.git(repo, 'worktree', 'add', '-q', '--detach', missingJoin, 'HEAD');+ const missingJoinModel = runFixtureChild(process.execPath, [BIN, 'join', 'api'],+ { cwd: missingJoin, env: box.env, encoding: 'utf8' });+ assert.equal(missingJoinModel.status, 1);+ assert.equal(missingJoinModel.stderr,+ 'pullboard: [MODEL_REQUIRED] this session has not declared its model\nnext: run pullboard join api --model "<model name>"\n');+ const missingJoinJson = box.run(missingJoin, 'join', 'api', '--json');+ assert.equal(missingJoinJson.code, 1);+ assert.equal(JSON.parse(missingJoinJson.out).error.next,+ 'run pullboard join api --model "<model name>"');+});