Skip to content

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.

fix(cli): explain uncommitted init in worktrees [I1,I2]

Corey Olsone706f2810df1
diff --git a/src/cli.js b/src/cli.js
index 1ec82219..e2981c6b 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -491,6 +491,18 @@ function configHere(info) {
}
const mainRoot = resolve(info.commonDir, '..');
if (info.isMain || !existsSync(join(mainRoot, CONFIG_FILE))) throw error;
+ let setup;
+ try {
+ setup = uncommittedSetup(mainRoot, loadConfig(mainRoot));
+ } catch {
+ // Keep the existing recovery for invalid or incomplete main-checkout configuration.
+ }
+ if (setup) {
+ throw new Refused(
+ 'NO_CONFIG',
+ `this worktree has no ${CONFIG_FILE}, and the main checkout has uncommitted Pullboard setup files: ${setup.files.join(', ')}. Commit them in the main checkout first: ${setup.stage}`,
+ );
+ }
throw new Refused(
'NO_CONFIG',
`this worktree's commit has no ${CONFIG_FILE}, though the main checkout has one: make a new worktree from the main checkout, which says what to commit first: ${cdTo(mainRoot)} pullboard worktree <lane> --model "<model name>"`,
@@ -1246,6 +1258,12 @@ function resumeHere(io) {
} else if (dirty) {
say(`${plural(dirty, 'file')} uncommitted in the main checkout`);
}
+ if (isMain) {
+ const setup = uncommittedSetup(root, ctx.config);
+ if (setup) {
+ say(`The person must commit Pullboard's setup files before agents can use worktrees: ${setup.stage}`);
+ }
+ }
for (const request of card.requests) say(`request #${request.shout_id}: ${request.shout_text}; answer with pullboard answer ${request.shout_id} done, or declined <reason>`);
for (const item of card.holding) {
say(`holding #${item.item_id} ${item.item_title}, lease ${span(ctx, item.item_lease_until)} left${item.item_check ? `; check: ${item.item_check}` : ''}`);
@@ -1639,6 +1657,19 @@ function setupFiles(mainRoot, config) {
return [CONFIG_FILE, config.spec, config.practice, 'AGENTS.md', ...(inEach ? [hooks] : [])].filter(Boolean);
}
+/** Find setup files in the main checkout that a new worktree would not receive from HEAD. */
+function uncommittedSetup(mainRoot, config) {
+ if (headCommit(mainRoot) === null) return null;
+ const differ = differFromHead(mainRoot, setupFiles(mainRoot, config));
+ if (!differ.length) return null;
+ const words = differ.map(({ path }) => shellWord(path)).join(' ');
+ const force = differ.some(({ ignored }) => ignored) ? ' -f' : '';
+ return {
+ files: differ.map(({ path }) => path),
+ stage: `${cdTo(mainRoot)} git add${force} -- ${words}`,
+ };
+}
+
/**
* Refuse a worktree whose agent would start without pullboard's files as the main checkout has
* them: no config, rules or hooks, or older ones (I4). Name each file and how it differs, and the
diff --git a/test/e2e-items.test.js b/test/e2e-items.test.js
index 5f27ff88..4426c3ea 100644
--- a/test/e2e-items.test.js
+++ b/test/e2e-items.test.js
@@ -210,7 +210,7 @@ test('a hook git ignores is committed by force before a worktree; a deleted conf
assert.ok(box.run(box.web, 'next').err.includes(`restore it: cd ${box.web} && git checkout HEAD -- pullboard.json`), 'a linked worktree restores its own');
});
-test('a worktree whose commit has no pullboard.json is sent to the main checkout, never told to run init [C4]', () => {
+test('a worktree without config names uncommitted init files and committed main guidance [I1,I2]', () => {
const box = sandbox();
const repo = join(box.dir, 'repo');
mkdirSync(repo);
@@ -224,10 +224,18 @@ test('a worktree whose commit has no pullboard.json is sent to the main checkout
for (const command of [['next'], ['status'], ['join', 'web']]) {
const said = box.run(old, ...command);
assert.equal(said.code, 1, said.out);
- assert.match(said.err, /\[NO_CONFIG\] this worktree's commit has no pullboard\.json, though the main checkout has one: /);
- assert.ok(said.err.includes(`which says what to commit first: cd ${repo} && pullboard worktree <lane>`), said.err);
+ assert.match(said.err, /\[NO_CONFIG\] this worktree has no pullboard\.json, and the main checkout has uncommitted Pullboard setup files:/);
+ assert.ok(said.err.includes(`Commit them in the main checkout first: cd ${repo} && git add --`), said.err);
+ for (const path of ['pullboard.json', 'SPEC.md', 'DOCTRINE.md']) assert.ok(said.err.includes(path), said.err);
+ assert.ok(!said.err.includes('pullboard worktree <lane>'), said.err);
assert.ok(!said.err.includes('pullboard init'), `${command[0]} never says to run init`);
}
+ box.git(repo, 'add', '-A');
+ box.git(repo, 'commit', '-q', '-m', 'chore: commit pullboard init files');
+ const committedMain = box.run(old, 'next');
+ assert.equal(committedMain.code, 1, committedMain.out);
+ assert.match(committedMain.err, /\[NO_CONFIG\] this worktree's commit has no pullboard\.json, though the main checkout has one: /);
+ assert.ok(committedMain.err.includes(`which says what to commit first: cd ${repo} && pullboard worktree <lane>`), committedMain.err);
const plain = join(box.dir, 'plain');
mkdirSync(plain);
box.git(plain, 'init', '-q');
diff --git a/test/resume-flow.test.js b/test/resume-flow.test.js
index d7ca4bdc..7e1c94ef 100644
--- a/test/resume-flow.test.js
+++ b/test/resume-flow.test.js
@@ -16,7 +16,7 @@ const PRIVATE_CHANGELOG = `# Changelog\n\n## [0.8.7] - 2026-10-12\n\n### A new s
const LONG_CHANGELOG = `# Changelog\n\n## [0.8.9] - 2026-10-14\n\n### Nine\n\nNine paragraph.\n\n## [0.8.8] - 2026-10-13\n\n### Eight\n\nEight paragraph.\n\n## [0.8.7] - 2026-10-12\n\n### Seven\n\nSeven paragraph.\n\n## [0.8.6] - 2026-10-11\n\n### Six\n\nSix paragraph.\n\n## [0.8.5] - 2026-10-10\n\n### Five\n\nFive paragraph.\n\n## [0.8.4] - 2026-10-09\n\n### Added\n\nThis category heading is not a release headline.\n`;
/** Build an isolated copy of the production CLI at a chosen release version. */
-function releaseFixture(t, { previous = null, version = '0.8.7', changelog = PRIVATE_CHANGELOG, freshSetup = false } = {}) {
+function releaseFixture(t, { previous = null, version = '0.8.7', changelog = PRIVATE_CHANGELOG, freshSetup = false, historyBeforeInit = false } = {}) {
const root = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-resume-release-')));
t.after(() => rmSync(root, { recursive: true, force: true }));
const cli = join(root, 'cli');
@@ -37,6 +37,11 @@ function releaseFixture(t, { previous = null, version = '0.8.7', changelog = PRI
delete env.PULLBOARD_RELAY_TOKEN;
for (const name of [...AGENT_SHELL_MARKERS, ...SSH_SHELL_MARKERS]) delete env[name];
runFixtureGit(['init', '-q', '-b', 'main'], { cwd: repo, env });
+ if (historyBeforeInit) {
+ writeFileSync(join(repo, 'README.md'), '# Existing repository\n');
+ runFixtureGit(['add', 'README.md'], { cwd: repo, env });
+ runFixtureGit(['commit', '-q', '-m', 'chore: create existing repository'], { cwd: repo, env });
+ }
/** Run the copied production CLI in the selected real checkout. */
const run = (cwd, ...args) => runFixtureChild(process.execPath, [join(cli, 'bin/pullboard.js'), ...args], { cwd, env, encoding: 'utf8' });
/** Run Git with this fixture's private identity and configuration. */
@@ -51,6 +56,27 @@ function releaseFixture(t, { previous = null, version = '0.8.7', changelog = PRI
return { root, repo, run, git, env };
}
+/** Prove an older agent worktree gets the exact commit-first instruction from its main checkout. */
+test('a worktree names its main checkout\'s uncommitted init files [I1,I2]', (t) => {
+ const box = releaseFixture(t, { freshSetup: true, historyBeforeInit: true });
+ const oldHead = box.git(box.repo, 'rev-parse', 'HEAD');
+ const worktree = join(box.root, 'old-agent-worktree');
+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', worktree, oldHead);
+
+ const fromWorktree = box.run(worktree, 'status');
+ assert.equal(fromWorktree.status, 1, fromWorktree.failure || fromWorktree.stderr || fromWorktree.stdout);
+ assert.match(fromWorktree.stderr, /main checkout has uncommitted Pullboard setup files/u);
+ assert.ok(fromWorktree.stderr.includes(`cd ${box.repo} && git add`), fromWorktree.stderr);
+ for (const path of ['pullboard.json', 'SPEC.md', 'DOCTRINE.md']) assert.ok(fromWorktree.stderr.includes(path), fromWorktree.stderr);
+ assert.doesNotMatch(fromWorktree.stderr, /worktree <lane>/u);
+
+ const fromMain = box.run(box.repo, 'resume');
+ assert.equal(fromMain.status, 0, fromMain.failure || fromMain.stderr || fromMain.stdout);
+ assert.match(fromMain.stdout, /The person must commit Pullboard's setup files before agents can use worktrees/u);
+ assert.ok(fromMain.stdout.includes(`cd ${box.repo} && git add`), fromMain.stdout);
+ for (const path of ['pullboard.json', 'SPEC.md', 'DOCTRINE.md']) assert.ok(fromMain.stdout.includes(path), fromMain.stdout);
+});
+
test('resume says what is new once after an upgrade [N19]', t => {
const box = releaseFixture(t, { previous: '0.8.5' });
const otherCheckout = join(box.root, 'other-checkout');