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(hooks): fall back to the main checkout's install [I6]

Corey Olson72a83d9874db
diff --git a/src/hooks.js b/src/hooks.js
index 5596b8f4..55624982 100644
--- a/src/hooks.js
+++ b/src/hooks.js
@@ -305,8 +305,8 @@ export function prePushProblems(root, refsText) {
}
/**
- * The shell script for one hook: it runs pullboard from the repo's own install when there is one,
- * else from the PATH.
+ * The shell script for one hook: it runs pullboard from this checkout's install, else the main
+ * checkout's, which a fresh agent worktree shares, else the PATH.
*
* @param {string} hook
* @returns {string}
@@ -317,7 +317,10 @@ export function hookScript(hook) {
'#!/bin/sh',
`# ${HOOK_MARK}: runs the pullboard ${hook} checks. Edit pullboard.json, not this file.`,
'root=$(git rev-parse --show-toplevel)',
- `if [ -x "$root/node_modules/.bin/pullboard" ]; then exec "$root/node_modules/.bin/pullboard" hook ${hook}${args}; fi`,
+ 'main=$(git rev-parse --path-format=absolute --git-common-dir)/..',
+ 'for bin in "$root/node_modules/.bin/pullboard" "$main/node_modules/.bin/pullboard"; do',
+ ` if [ -x "$bin" ]; then exec "$bin" hook ${hook}${args}; fi`,
+ 'done',
`if command -v pullboard >/dev/null 2>&1; then exec pullboard hook ${hook}${args}; fi`,
'echo "pullboard is not installed; npm i -D @pullboard/local, or npm i -g @pullboard/local" >&2',
'exit 1',
diff --git a/src/init.js b/src/init.js
index 61845b21..214685d0 100644
--- a/src/init.js
+++ b/src/init.js
@@ -107,11 +107,11 @@ function writeAgentDocs(root) {
}
/**
- * The session hook's command: pullboard from the repo's own install when there is one, else from the
- * PATH, and silence when neither is there, so a session never fails to start over it.
+ * The session hook's command: pullboard from this checkout's install, else the main checkout's,
+ * else the PATH, and silence when there is none, so a session never fails to start over it.
*/
export const RESUME_HOOK =
- '[ -x node_modules/.bin/pullboard ] && exec node_modules/.bin/pullboard resume; command -v pullboard >/dev/null && exec pullboard resume; true';
+ 'm=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)/..; for p in node_modules/.bin/pullboard "$m/node_modules/.bin/pullboard"; do [ -x "$p" ] && exec "$p" resume; done; command -v pullboard >/dev/null && exec pullboard resume; true';
/**
* Have Claude Code run `pullboard resume` whenever a session starts, resumes or is compacted (I6), so
diff --git a/test/e2e.test.js b/test/e2e.test.js
index f35ee8a1..c2f27703 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -654,3 +654,25 @@ test('the run pack names verified items that touched the same files, so a cold a
const packs = join(box.dir, 'repo', '.git', 'worktrees', runner.split('/').at(-1), 'pullboard', 'packs');
assert.match(readFileSync(join(packs, '2-light-1.md'), 'utf8'), /## Finished items that touched the same files\n- #1 Greet: web\/page.js\nFollow the patterns/);
});
+
+test('a fresh worktree with no install of its own runs pullboard from the main checkout, for git hooks and the session hook [I6]', () => {
+ const box = project();
+ const bare = { ...box.env, PATH: '/usr/bin:/bin' };
+ const commit = () => spawnSync('git', ['commit', '-q', '-m', 'feat(web): page [G1]'], { cwd: box.web, env: bare, encoding: 'utf8' });
+ const { command } = JSON.parse(readFileSync(join(box.web, '.claude', 'settings.json'), 'utf8')).hooks.SessionStart[0].hooks[0];
+ const resume = () => spawnSync('sh', ['-c', command], { cwd: box.web, env: bare, encoding: 'utf8' });
+ mkdirSync(join(box.web, 'web'));
+ writeFileSync(join(box.web, 'web', 'page.html'), '<h1>Hi</h1>');
+ box.git(box.web, 'add', '-A');
+ const refused = commit();
+ assert.notEqual(refused.status, 0);
+ assert.match(refused.stderr, /pullboard is not installed/);
+ assert.deepEqual([resume().status, resume().stdout], [0, ''], 'no install anywhere: the session still starts, silently');
+ const bin = join(box.repo, 'node_modules', '.bin');
+ mkdirSync(bin, { recursive: true });
+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${BIN}" "$@"\n`);
+ chmodSync(join(bin, 'pullboard'), 0o755);
+ const committed = commit();
+ assert.equal(committed.status, 0, committed.stderr);
+ assert.match(resume().stdout, /^resume: web-1, web lane/);
+});