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(hooks): preserve missing-install and doctor contracts [I6]
Corey Olsond5893abc1c29
diff --git a/src/agent-hooks.js b/src/agent-hooks.jsindex a5c45fa9..dcd1e05d 100644--- a/src/agent-hooks.js+++ b/src/agent-hooks.js@@ -20,9 +20,18 @@ export const LEGACY_RESUME_HOOK ='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';const SOURCES = [['Claude Code', '.claude/settings.json'], ['Codex', '.codex/hooks.json']];+/** Resolve the same local/main/PATH installations as I6; a missing executable is a silent no-op. */+export function agentHookCommand(event) {+ if (!AGENT_HOOK_EVENTS.includes(event)) throw new Error('unsupported agent hook event');+ return '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" hook ${event}; done; `+ + `command -v pullboard >/dev/null || exit 0; exec pullboard hook ${event}`;+}+/** Recognize only the exact command this installer owns. */function owned(handler) {- return handler?.type === 'command' && AGENT_HOOK_EVENTS.some(event => handler.command === `pullboard hook ${event}`);+ return handler?.type === 'command' && AGENT_HOOK_EVENTS.some(event => handler.command === agentHookCommand(event)+ || handler.command === `pullboard hook ${event}`);}/** Never follow project configuration through a symlink into a user's home. */@@ -63,19 +72,23 @@ export function configureAgentHooks(root, { remove = false, legacyResume = LEGAC&& !(vendor === 'Claude Code' && legacyResume && event === 'SessionStart' && handler?.command === legacyResume));return hooks.length || Object.keys(group).some(key => key !== 'hooks') ? [{ ...group, hooks }] : [];});- if (!remove) kept.push({ hooks: [{ type: 'command', command: `pullboard hook ${event}`, timeout: 5 }] });+ if (!remove) kept.push({ hooks: [{ type: 'command', command: agentHookCommand(event), timeout: 5 }] });if (kept.length) value.hooks[event] = kept;else delete value.hooks[event];}if (!Object.keys(value.hooks).length) delete value.hooks;- if (JSON.stringify(value) !== before) {+ const changed = JSON.stringify(value) !== before;+ if (changed) {mkdirSync(dirname(join(root, name)), { recursive: true });const temporary = join(root, name) + `.${process.pid}.tmp`;writeFileSync(temporary, JSON.stringify(value, null, 2) + '\n', { mode: 0o600 });renameSync(temporary, join(root, name));onWrite(name);}- return `${remove ? 'removed' : 'installed'} Pullboard's ${vendor} agent nudges in ${name}${vendor === 'Codex' && !remove ? '; review and trust them with /hooks' : ''}`;+ if (remove) return `removed Pullboard's ${vendor} agent nudges from ${name}`;+ return vendor === 'Claude Code'+ ? `${changed ? 'added a' : 'kept the'} Claude Code session hook and Stop reminder in ${name}`+ : `${changed ? 'installed' : 'kept'} Codex agent nudges in ${name}; review and trust them with /hooks`;} catch {return `${vendor} agent hook warning: kept ${name} unchanged; repair its project-local JSON and run pullboard hooks`;}@@ -88,8 +101,9 @@ export function agentHookStatus(root) {let events = [];try {const value = settingsAt(root, name);- events = AGENT_HOOK_EVENTS.filter(event => value.hooks?.[event]?.some(group => group.hooks.some(handler => owned(handler) && handler.command === `pullboard hook ${event}`)));+ events = AGENT_HOOK_EVENTS.filter(event => value.hooks?.[event]?.some(group => group.hooks.some(handler => owned(handler)+ && [agentHookCommand(event), `pullboard hook ${event}`].includes(handler.command))));} catch { /* Invalid configuration remains visibly inactive. */ }- return { vendor, events, trust: vendor === 'Codex' ? 'unverified' : null };+ return { vendor, configured: existsSync(join(root, name)), events, trust: vendor === 'Codex' ? 'unverified' : null };});}diff --git a/src/commands/doctor.js b/src/commands/doctor.jsindex dad38074..573db046 100644--- a/src/commands/doctor.js+++ b/src/commands/doctor.js@@ -42,7 +42,7 @@ export function run(io) {message: formatSnapshotLimit(oversizedSnapshot),next: 'reduce the sealed board snapshot below the relay limit, then run pullboard status' });io.result?.({ problems, agentHooks });- for (const hook of agentHooks) io.say(`${hook.vendor} agent hooks: ${hook.events.join(', ') || 'not installed'}${hook.trust ? '; trust unverified: the Stop reminder may be off; review /hooks' : ''}`);+ for (const hook of agentHooks.filter(hook => hook.configured)) io.say(`${hook.vendor} agent hooks: ${hook.events.join(', ') || 'not installed'}${hook.trust ? '; trust unverified: the Stop reminder may be off; review /hooks' : ''}`);if (!problems.length) {io.say('board is clean');return 0;diff --git a/test/e2e-cli.test.js b/test/e2e-cli.test.jsindex 65562f9c..1dba495d 100644--- a/test/e2e-cli.test.js+++ b/test/e2e-cli.test.js@@ -52,12 +52,13 @@ test('init adds a Claude Code session hook that runs resume, and keeps every othassert.deepEqual(settings.sandbox, { filesystem: { allowWrite: [box.env.PULLBOARD_MACHINE_HOME] } });assert.deepEqual(Object.keys(settings).sort(), ['hooks', 'permissions', 'sandbox'], 'init adds no other top-level setting');assert.deepEqual(Object.keys(settings.hooks).sort(), ['SessionStart', 'Stop'], 'init adds no other hook event');- assert.deepEqual(settings.hooks.Stop, mine.hooks.Stop);+ assert.deepEqual(settings.hooks.Stop.slice(0, mine.hooks.Stop.length), mine.hooks.Stop);+ assert.equal(settings.hooks.Stop.length, mine.hooks.Stop.length + 1, 'only the new nonblocking Stop nudge is appended');assert.equal(settings.hooks.SessionStart.length, 1);const { command } = settings.hooks.SessionStart[0].hooks[0];const card = spawnSync('sh', ['-c', command], { cwd: repo, env: box.env, encoding: 'utf8' });assert.equal(card.status, 0, card.stderr);- assert.match(card.stdout, /^resume: coordinator/);+ assert.match(JSON.parse(card.stdout).hookSpecificOutput.additionalContext, /^resume: coordinator/);const bare = spawnSync('sh', ['-c', command], { cwd: repo, env: { ...box.env, PATH: '/usr/bin:/bin' }, encoding: 'utf8' });assert.equal(bare.status, 0, 'without pullboard installed, the session still starts');assert.equal(bare.stdout, '');@@ -212,7 +213,7 @@ test('a fresh worktree with no install of its own runs pullboard from the main cchmodSync(join(bin, 'pullboard'), 0o755);const committed = commit();assert.equal(committed.status, 0, committed.stderr);- assert.match(resume().stdout, /^resume: web-1 \(Test Model\), web lane/);+ assert.match(JSON.parse(resume().stdout).hookSpecificOutput.additionalContext, /^resume: web-1 \(Test Model\), web lane/);});test('the gate reaches the agent as a digest: one line when green, the failure when red; the whole output stays in the git dir [V10]', () => {diff --git a/test/hooks.test.js b/test/hooks.test.jsindex 3ae457b8..2a2616a8 100644--- a/test/hooks.test.js+++ b/test/hooks.test.js@@ -46,10 +46,15 @@ test("a hook nudges and never blocks, fails open on error or timeout, and init massert.equal(configured[1].description, codexMine.description);for (const settings of configured) for (const event of ['SessionStart', 'Stop']) {const handlers = settings.hooks[event].flatMap(group => group.hooks);- assert.equal(handlers.filter(handler => handler.command === `pullboard hook ${event}`).length, 1);- const handler = handlers.find(handler => handler.command === `pullboard hook ${event}`);+ assert.equal(handlers.filter(handler => handler.command.includes(`hook ${event}`)).length, 1);+ const handler = handlers.find(handler => handler.command.includes(`hook ${event}`));assert.equal(handler.type, 'command');assert.ok(handler.timeout > 0);+ assert.equal(handler.command.includes('\n'), false, 'the installation is one thin resolver line');+ const missing = runFixtureChild('/bin/sh', ['-c', handler.command], { cwd: box.dir,+ env: { ...box.env, PATH: '/usr/bin:/bin' }, encoding: 'utf8' });+ assert.equal(missing.status, 0, 'missing executable cannot break the vendor session');+ assert.equal(missing.stdout, '');}const once = [readFileSync(claude, 'utf8'), readFileSync(codex, 'utf8')];assert.equal(box.run(box.repo, 'hooks').code, 0);