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(core): preserve vendor hook boundaries for presence [B3,I6]
Corey Olsond1c55f6f0c2f
diff --git a/src/agent-hooks.js b/src/agent-hooks.jsindex 76e198be..7cec5791 100644--- a/src/agent-hooks.js+++ b/src/agent-hooks.js@@ -19,7 +19,7 @@ export const AGENT_HOOK_EVENTS = ['SessionStart', 'Stop'];const CLAUDE_HOOK_EVENTS = [...AGENT_HOOK_EVENTS, 'SessionEnd'];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']];+const SOURCES = [['Claude Code', '.claude/settings.json', CLAUDE_HOOK_EVENTS], ['Codex', '.codex/hooks.json', AGENT_HOOK_EVENTS]];/** Resolve the same local/main/PATH installations as I6; a missing executable is a silent no-op. */export function agentHookCommand(event) {@@ -49,24 +49,24 @@ function regularProjectPath(root, name) {}/** Read an existing object without replacing malformed settings or hook arrays. */-function settingsAt(root, name) {+function settingsAt(root, name, events) {if (!regularProjectPath(root, name)) throw new Error('configuration is not a regular project file');const value = existsSync(join(root, name)) ? JSON.parse(readFileSync(join(root, name), 'utf8')) : {};if (!value || typeof value !== 'object' || Array.isArray(value)|| value.hooks !== undefined && (!value.hooks || typeof value.hooks !== 'object' || Array.isArray(value.hooks))) throw new Error('configuration is not an object');- for (const event of CLAUDE_HOOK_EVENTS) if (value.hooks?.[event] !== undefined+ for (const event of events) if (value.hooks?.[event] !== undefined&& (!Array.isArray(value.hooks[event]) || value.hooks[event].some(group => !group || typeof group !== 'object' || !Array.isArray(group.hooks)))) throw new Error('hook groups are not arrays');return value;}/** Merge or remove only Pullboard's exact handlers, preserving unrelated settings and groups. */export function configureAgentHooks(root, { remove = false, legacyResume = LEGACY_RESUME_HOOK, onWrite = () => {} } = {}) {- return SOURCES.map(([vendor, name]) => {+ return SOURCES.map(([vendor, name, events]) => {try {if (remove && !existsSync(join(root, name))) return `${vendor} agent hooks are not installed`;- const value = settingsAt(root, name), before = JSON.stringify(value);+ const value = settingsAt(root, name, events), before = JSON.stringify(value);value.hooks ??= {};- for (const event of vendor === 'Claude Code' ? CLAUDE_HOOK_EVENTS : AGENT_HOOK_EVENTS) {+ for (const event of events) {const groups = value.hooks[event] ?? [];const kept = groups.flatMap(group => {const hooks = group.hooks.filter(handler => !owned(handler)@@ -103,11 +103,11 @@ export function configureAgentHooks(root, { remove = false, legacyResume = LEGAC/** File presence is installation evidence, never proof that a vendor trusted a definition. */export function agentHookStatus(root) {- return SOURCES.map(([vendor, name]) => {+ return SOURCES.map(([vendor, name, supportedEvents]) => {let events = [];try {- const value = settingsAt(root, name);- events = (vendor === 'Claude Code' ? CLAUDE_HOOK_EVENTS : AGENT_HOOK_EVENTS).filter(event => value.hooks?.[event]?.some(group => group.hooks.some(handler => owned(handler)+ const value = settingsAt(root, name, supportedEvents);+ events = supportedEvents.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, configured: existsSync(join(root, name)), events, trust: vendor === 'Codex' ? 'unverified' : null };diff --git a/src/help.js b/src/help.jsindex c8530cb5..c19e9ea8 100644--- a/src/help.js+++ b/src/help.js@@ -73,7 +73,7 @@ Set upunread shouts, what to do next; run it to start any sessionpullboard badge write board-derived Shields endpoint JSON to docs/badges/pullboard hooks [uninstall] install Git hooks and agent nudges; uninstall removes only Pullboard's agent nudges- pullboard hook SessionStart|Stop native agent nudges; errors/timeouts warn and never block+ pullboard hook SessionStart|Stop|SessionEnd native agent nudges; errors/timeouts warn and never blockWorkpullboard add <lane> <title> [--criterion "..."] [--specs G1.2,K3] [--after 3,4] [--parent <id>]@@ -384,7 +384,7 @@ const HELP_ALIASES = {'spec signers': { usage: 'pullboard spec signers add [--key <path>] [--by <principal>]', source: 'spec signers add' },'spec signers add': { usage: 'pullboard spec signers add [--key <path>] [--by <principal>]', source: 'spec signers add' },doctrine: { usage: 'pullboard doctrine check', source: 'doctrine check' },- hook: { usage: 'pullboard hook SessionStart|Stop|pre-commit|pre-merge-commit|commit-msg|pre-push', source: 'hook' },+ hook: { usage: 'pullboard hook SessionStart|Stop|SessionEnd|pre-commit|pre-merge-commit|commit-msg|pre-push', source: 'hook' },'gate set': { usage: 'pullboard gate set "<command>"', source: 'gate set' },'hook pre-commit': { usage: 'pullboard hook pre-commit', source: 'hook' },'hook pre-merge-commit': { usage: 'pullboard hook pre-merge-commit', source: 'hook' },diff --git a/test/hooks.test.js b/test/hooks.test.jsindex c5fd3eef..dcef0a64 100644--- a/test/hooks.test.js+++ b/test/hooks.test.js@@ -34,14 +34,14 @@ test("a hook nudges and never blocks, fails open on error or timeout, and init massert.match(response.hookSpecificOutput.additionalContext, /pullboard|work|claim/i);const claude = join(box.repo, '.claude/settings.json'), codex = join(box.repo, '.codex/hooks.json');const mine = { permissions: { allow: ['Bash(my-check)'] }, hooks: { Stop: [{ hooks: [{ type: 'command', command: 'echo my-stop' }] }] } };- const codexMine = { description: 'My existing hooks', hooks: { SessionStart: [{ matcher: 'startup', hooks: [{ type: 'command', command: 'echo my-start' }] }] } };+ const codexMine = { description: 'My existing hooks', hooks: { SessionEnd: 'unrelated vendor metadata', SessionStart: [{ matcher: 'startup', hooks: [{ type: 'command', command: 'echo my-start' }] }] } };writeFileSync(claude, JSON.stringify(mine));writeFileSync(codex, JSON.stringify(codexMine));assert.equal(box.run(box.repo, 'init', '--no-permissions').code, 0,'the actual init entrypoint merges existing agent hooks');const configured = [claude, codex].map(file => JSON.parse(readFileSync(file, 'utf8')));assert.ok(configured[0].hooks.SessionEnd.some(group => group.hooks.some(handler => handler.command.includes('hook SessionEnd'))));- assert.equal(Object.hasOwn(configured[1].hooks, 'SessionEnd'), false, 'Codex keeps its supported SessionStart and Stop definitions');+ assert.equal(configured[1].hooks.SessionEnd, codexMine.hooks.SessionEnd, 'Codex preserves unrelated event data and installs only its existing supported events');assert.deepEqual(configured[0].permissions, mine.permissions);assert.deepEqual(configured[0].hooks.Stop[0], mine.hooks.Stop[0]);assert.deepEqual(configured[1].hooks.SessionStart[0], codexMine.hooks.SessionStart[0]);