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
feat(hooks): add bounded native agent nudges [I6]
Corey Olson7871b7ba27d6
diff --git a/src/agent-hook-work.js b/src/agent-hook-work.jsnew file mode 100644index 00000000..4d230c5a--- /dev/null+++ b/src/agent-hook-work.js@@ -0,0 +1,31 @@+/** Read ordinary local work for a native nudge; the parent bounds this whole worker [I6]. */+import { fileURLToPath } from 'node:url';++/** Session start uses normal resume; Stop only reads committed, unsubmitted work. */+async function work(event) {+ if (event === 'SessionStart') {+ const { main } = await import('./cli.js');+ process.exitCode = await main(['resume']);+ return;+ }+ const { repoInfo, headCommit, tryGit } = await import('./git.js');+ const { join } = await import('node:path');+ const store = await import('./board.js');+ const info = repoInfo(process.cwd());+ const board = store.openBoardForRead(join(info.commonDir, 'pullboard', 'board.sqlite'));+ if (!board) return;+ try {+ const agent = store.agentAt(board, info.root), head = headCommit(info.root);+ if (!agent || !head) return;+ const items = store.listItems(board, { all: true }).filter(item => item.item_status === 'claimed'+ && item.item_owner === agent.agent_id && item.item_claim_head && item.item_claim_head !== head+ && tryGit(info.root, ['merge-base', '--is-ancestor', item.item_claim_head, head]).status === 0+ && tryGit(info.root, ['diff', '--quiet', item.item_claim_head, head, '--']).status === 1);+ if (items.length) process.stdout.write(`Committed work on ${items.map(item => '#' + item.item_id).join(', ')} is not submitted. Run pullboard submit <id> when it is ready.\n`);+ } finally { store.closeBoard(board); }+}++if (process.argv[1] === fileURLToPath(import.meta.url)) {+ try { await work(process.argv[2]); }+ catch { process.exitCode = 1; }+}diff --git a/src/agent-hook.js b/src/agent-hook.jsnew file mode 100644index 00000000..dabd6253--- /dev/null+++ b/src/agent-hook.js@@ -0,0 +1,43 @@+/** Native hooks provide bounded context and warnings, never a blocking decision [I6]. */+import { spawn } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { AGENT_HOOK_EVENTS } from './agent-hooks.js';++/** Run a single owned worker group; no inherited vendor payload can choose executable arguments. */+export async function runAgentHook(io, event) {+ if (!AGENT_HOOK_EVENTS.includes(event)) return 0;+ let response;+ try {+ const result = await new Promise(resolveResult => {+ const child = spawn(process.execPath, [fileURLToPath(new URL('./agent-hook-work.js', import.meta.url)), event], {+ cwd: io.cwd, env: process.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'],+ });+ let text = '', timedOut = false, finished = false;+ /** Retain bounded public board context, excluding diagnostic stderr and vendor transcripts. */+ const capture = chunk => { if (text.length < 8192) text += chunk.toString('utf8').slice(0, 8192 - text.length); };+ child.stdout.on('data', capture);+ child.stderr.resume();+ /** Finish once even when a spawn error precedes the close notification. */+ const finish = status => {+ if (finished) return;+ finished = true; clearTimeout(timer);+ resolveResult({ status, text, timedOut });+ };+ const timer = setTimeout(() => {+ timedOut = true;+ // This process group was created for this one worker, never selected by executable name.+ if (child.exitCode === null && child.signalCode === null) {+ try { process.kill(-child.pid, 'SIGKILL'); } catch { /* A worker that already closed needs no signal. */ }+ }+ finish(null);+ }, 2000);+ child.once('error', () => finish(null));+ child.once('close', finish);+ });+ if (result.timedOut || result.status !== 0) response = { systemMessage: `Pullboard hook warning: ${result.timedOut ? 'the local nudge timed out' : 'the local nudge could not finish'}; continuing. Run pullboard resume manually.` };+ else if (event === 'SessionStart') response = { hookSpecificOutput: { hookEventName: event, additionalContext: result.text.trim() } };+ else response = result.text.trim() ? { systemMessage: result.text.trim() } : {};+ } catch { response = { systemMessage: 'Pullboard hook warning: the local nudge could not start; continuing. Run pullboard resume manually.' }; }+ io.stdout.write(JSON.stringify(response) + '\n');+ return 0;+}diff --git a/src/agent-hooks.js b/src/agent-hooks.jsnew file mode 100644index 00000000..a5c45fa9--- /dev/null+++ b/src/agent-hooks.js@@ -0,0 +1,95 @@+/** Project-local agent nudges never grant trust or replace another tool's hooks [I6]. */+import {+ existsSync,+ lstatSync,+ mkdirSync,+ readFileSync,+ realpathSync,+ renameSync,+ writeFileSync,+} from 'node:fs';+import {+ dirname,+ isAbsolute,+ join,+ relative,+} from 'node:path';++export const AGENT_HOOK_EVENTS = ['SessionStart', 'Stop'];+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']];++/** 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}`);+}++/** Never follow project configuration through a symlink into a user's home. */+function regularProjectPath(root, name) {+ const file = join(root, name), parent = dirname(file);+ for (const path of [parent, file]) {+ let stat;+ try { stat = lstatSync(path); } catch (error) { if (error.code === 'ENOENT') continue; throw error; }+ if (stat.isSymbolicLink()) return false;+ const inside = relative(realpathSync(root), realpathSync(path));+ if (inside === '..' || inside.startsWith('../') || isAbsolute(inside)) return false;+ }+ return !existsSync(file) || lstatSync(file).isFile();+}++/** Read an existing object without replacing malformed settings or hook arrays. */+function settingsAt(root, name) {+ 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 AGENT_HOOK_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]) => {+ try {+ if (remove && !existsSync(join(root, name))) return `${vendor} agent hooks are not installed`;+ const value = settingsAt(root, name), before = JSON.stringify(value);+ value.hooks ??= {};+ for (const event of AGENT_HOOK_EVENTS) {+ const groups = value.hooks[event] ?? [];+ const kept = groups.flatMap(group => {+ const hooks = group.hooks.filter(handler => !owned(handler)+ && !(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 (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) {+ 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' : ''}`;+ } catch {+ return `${vendor} agent hook warning: kept ${name} unchanged; repair its project-local JSON and run pullboard hooks`;+ }+ });+}++/** File presence is installation evidence, never proof that a vendor trusted a definition. */+export function agentHookStatus(root) {+ return SOURCES.map(([vendor, name]) => {+ 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}`)));+ } catch { /* Invalid configuration remains visibly inactive. */ }+ return { vendor, events, trust: vendor === 'Codex' ? 'unverified' : null };+ });+}diff --git a/src/cli-main.js b/src/cli-main.jsindex bc2553dc..240d9026 100644--- a/src/cli-main.js+++ b/src/cli-main.js@@ -51,6 +51,7 @@ const OPTIONS = {export: { type: 'string' },'no-open': { type: 'boolean' },'no-permissions': { type: 'boolean' },+ 'no-hooks': { type: 'boolean' },note: { type: 'string' },infra: { type: 'string' },'note-file': { type: 'string' },@@ -283,6 +284,11 @@ async function runMain(argv, streams) {&& !(command === 'join' && parsed.positionals[1] === (await import('./config.js')).COORDINATOR);needsRepo = !(parsed.values.help || parsed.values.version || command === 'help' || command === 'version');} catch { sync = false; needsRepo = false; }+ // Agent nudges never enter Git-hook identity, synchronization or refusal machinery.+ if (parsed?.positionals[0] === 'hook' && !parsed.values.help && !parsed.values.version+ && !['pre-commit', 'pre-merge-commit', 'commit-msg', 'pre-push'].includes(parsed.positionals[1])) {+ return (await import('./agent-hook.js')).runAgentHook(io, parsed.positionals[1]);+ }const git = needsRepo ? await import('./git.js') : null;git?.setResumeSourceFacts(parsed?.positionals[0] === 'resume');if (parsed) {diff --git a/src/commands/doctor.js b/src/commands/doctor.jsindex 4ff6faab..dad38074 100644--- a/src/commands/doctor.js+++ b/src/commands/doctor.js@@ -21,6 +21,7 @@ import {import {context,} from '../cli.js';+import { agentHookStatus } from '../agent-hooks.js';/** Run `pullboard doctor` and return its exit code. */export function run(io) {@@ -32,6 +33,7 @@ export function run(io) {return 1;}const ctx = context(io);+ const agentHooks = agentHookStatus(ctx.info.root);const problems = [...doctorProblems(ctx.file, ctx.info.root, tryGit, ctx.config, { isMain: ctx.allowSchemaUpgrade }), ...skillProblems(ctx.info.root), ...doctrineProblems(ctx.info.root, ctx.config), ...unlinkedRelayProjects()];const checkpointProblem = pendingCheckpointProblem(ctx.info.root);if (checkpointProblem) problems.push(checkpointProblem);@@ -39,7 +41,8 @@ export function run(io) {if (oversizedSnapshot) problems.push({ code: 'RELAY_SNAPSHOT_LIMIT',message: formatSnapshotLimit(oversizedSnapshot),next: 'reduce the sealed board snapshot below the relay limit, then run pullboard status' });- io.result?.({ problems });+ 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' : ''}`);if (!problems.length) {io.say('board is clean');return 0;diff --git a/src/commands/hooks.js b/src/commands/hooks.jsindex d6ecb200..89170903 100644--- a/src/commands/hooks.js+++ b/src/commands/hooks.js@@ -5,10 +5,13 @@ import {import {installHooks,} from '../hooks.js';+import { configureAgentHooks } from '../agent-hooks.js';/** Run `pullboard hooks` and return its exit code. */-export function run(io) {- const notes = installHooks(repoInfo(io.cwd).root);+export function run(io, { first } = {}) {+ const root = repoInfo(io.cwd).root;+ const notes = first === 'uninstall' ? configureAgentHooks(root, { remove: true })+ : [...installHooks(root), ...configureAgentHooks(root)];io.result?.({ notes });notes.forEach((note) => io.say(note));return 0;diff --git a/src/commands/init.js b/src/commands/init.jsindex f71cc9b4..fd0d09ec 100644--- a/src/commands/init.js+++ b/src/commands/init.js@@ -73,6 +73,7 @@ export async function run(io, { values }) {onWritten: setupPlan.written,model,permissions: !values['no-permissions'],+ agentHooks: !values['no-hooks'],openBoardHere: () => store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), io.clock, { isMain: codeIsFromMain() }),/** Keep a linked coordinator's canonical identity without writing a clone-local path. */register: (board, options) => {diff --git a/src/help.js b/src/help.jsindex d627754c..8cf45ed4 100644--- a/src/help.js+++ b/src/help.js@@ -16,7 +16,7 @@ Outside contributionsSet uppullboard tour see it work: a reject and its rework, scripted, in thirty seconds- pullboard init [--model <name>] [--blueprint <name or file>]... [--no-permissions] [--yes] [--verbose] short setup summary; --verbose shows recipes; --yes commits only setup's own files with your Git identity+ pullboard init [--model <name>] [--blueprint <name or file>]... [--no-permissions] [--no-hooks] [--yes] [--verbose] --no-hooks skips agent nudges; --yes commits only setup's own files with your Git identitypullboard worktree <lane> --model <name> [--route light] [--family <name>] make and join a worktree for a new agentpullboard.json worktrees: inside or beside; init defaults to insidepullboard join <lane> --model <name> [--route light] [--family <name>] [--parent <session-id>] register this worktree and its parent session@@ -70,7 +70,8 @@ Set uppullboard resume [--diagnostics] where you are: your claim, branch, what came back,unread shouts, what to do next; run it to start any sessionpullboard badge write board-derived Shields endpoint JSON to docs/badges/- pullboard hooks reinstall the git hooks (e.g. after a fresh clone)+ 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 blockWorkpullboard add <lane> <title> [--criterion "..."] [--specs G1.2,K3] [--after 3,4] [--parent <id>]@@ -366,7 +367,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 pre-commit|pre-merge-commit|commit-msg|pre-push', source: 'hook' },+ hook: { usage: 'pullboard hook SessionStart|Stop|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/src/init.js b/src/init.jsindex f30c9a79..005f8e4c 100644--- a/src/init.js+++ b/src/init.js@@ -37,6 +37,10 @@ import {} from './config.js';import { loadDoctrine } from './doctrine.js';import { installHooks } from './hooks.js';+import {+ configureAgentHooks,+ LEGACY_RESUME_HOOK,+} from './agent-hooks.js';import {detectGate,settingCommand,@@ -414,8 +418,7 @@ function writeAgentDocs(root, onWrite) {* 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 =- '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';+export const RESUME_HOOK = LEGACY_RESUME_HOOK;/*** The MCP server command: pullboard from this checkout's install, else the main checkout's, else the PATH (#961).@@ -689,37 +692,6 @@ function writeMcpConfig(root, onWrite) {return notes;}-/**- * Have Claude Code run `pullboard resume` whenever a session starts, resumes or is compacted (I6), so- * an agent picks its work up from the board rather than from a summary of it. The hook is merged- * into .claude/settings.json; every other setting stays as it was.- *- * @param {string} root- * @param {(path: string) => void} onWrite- * @returns {string} What happened.- */-function writeSessionHook(root, onWrite) {- const file = join(root, '.claude', 'settings.json');- let settings = {};- if (existsSync(file)) {- try {- settings = JSON.parse(readFileSync(file, 'utf8'));- } catch {- settings = null;- }- if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {- return 'kept .claude/settings.json, which is not a JSON object; add a SessionStart hook that runs pullboard resume';- }- }- const starts = settings.hooks?.SessionStart ?? [];- if (JSON.stringify(starts).includes('pullboard resume')) return 'kept the Claude Code session hook';- settings.hooks = { ...settings.hooks, SessionStart: [...starts, { hooks: [{ type: 'command', command: RESUME_HOOK, timeout: 30 }] }] };- mkdirSync(join(root, '.claude'), { recursive: true });- writeFileSync(file, `${JSON.stringify(settings, null, 2)}\n`);- onWrite('.claude/settings.json');- return 'added a Claude Code session hook: pullboard resume at every start and compaction';-}-/*** Merge Claude project rules and the exact machine-home sandbox write scope, preserving other settings.*@@ -831,7 +803,7 @@ function writeCodexLoopRules(root, gate, onWrite) {* @param {{ info: { root: string, isMain: boolean }, openBoardHere: () => any, register: Function, closeBoard: Function, model?: string, permissions?: boolean, onWritten?: (path: string) => void }} context* @returns {string[]} What happened, one line each.*/-export function initRepo({ info, openBoardHere, register, closeBoard, model, permissions = true, onWritten }) {+export function initRepo({ info, openBoardHere, register, closeBoard, model, permissions = true, agentHooks = true, onWritten }) {if (!info.isMain) {throw new Refused('NOT_MAIN', 'run init in the main checkout; worktrees join a lane instead');}@@ -856,7 +828,7 @@ export function initRepo({ info, openBoardHere, register, closeBoard, model, per...writeAgentDocs(root, onWrite),...installHooks(root, onWrite),...installSkills(root, onWrite),- writeSessionHook(root, onWrite),+ ...(agentHooks ? configureAgentHooks(root, { legacyResume: RESUME_HOOK, onWrite }) : ['skipped agent nudges (--no-hooks)']),...writeMcpConfig(root, onWrite),];if (gate && (!configured || configured === gate)) {diff --git a/test/hooks.test.js b/test/hooks.test.jsindex 1444ca1c..d32ce381 100644--- a/test/hooks.test.js+++ b/test/hooks.test.js@@ -5,7 +5,7 @@ import assert from 'node:assert/strict';import { spawnSync } from 'node:child_process';import { runFixtureExecFile as execFileSync, runFixtureChildAsync, runFixtureGit } from './fixture-child.js';import { runFixtureChild } from './fixture-child.js';-import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';@@ -32,6 +32,72 @@ test("a hook nudges and never blocks, fails open on error or timeout, and init massert.equal(response.continue === false || response.decision === 'block', false);assert.equal(response.hookSpecificOutput.hookEventName, 'SessionStart');assert.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' }] }] } };+ writeFileSync(claude, JSON.stringify(mine));+ writeFileSync(codex, JSON.stringify(codexMine));+ assert.equal(box.run(box.repo, 'hooks').code, 0);+ const configured = [claude, codex].map(file => JSON.parse(readFileSync(file, 'utf8')));+ 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]);+ assert.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(handler.type, 'command');+ assert.ok(handler.timeout > 0);+ }+ const once = [readFileSync(claude, 'utf8'), readFileSync(codex, 'utf8')];+ assert.equal(box.run(box.repo, 'hooks').code, 0);+ assert.deepEqual([readFileSync(claude, 'utf8'), readFileSync(codex, 'utf8')], once, 'merging twice is idempotent');++ const added = box.run(box.repo, 'add', 'web', 'Native stop reminder', '--criterion', 'committed work is named', '--json');+ assert.equal(added.code, 0, added.err);+ const id = JSON.parse(added.out).item.item_id;+ assert.equal(box.run(box.web, 'claim', String(id)).code, 0);+ assert.equal(e2e.commitFile(box, box.web, 'web/nudge.txt', 'committed work\n', 'feat(web): nudge work [G1]').status, 0);+ // Contract probes use current documented vendor envelopes, never an actual user's transcript.+ // https://learn.chatgpt.com/docs/hooks and https://code.claude.com/docs/en/hooks+ for (const vendor of ['codex', 'claude']) {+ const payload = { session_id: `private-${vendor}-fixture`, cwd: box.web, hook_event_name: 'Stop', stop_hook_active: false,+ ...(vendor === 'codex' ? { turn_id: 'private-turn', last_assistant_message: null } : { transcript_path: join(box.dir, 'private-unused.jsonl') }) };+ const stop = runFixtureChild(process.execPath, [e2e.BIN, 'hook', 'Stop'], { cwd: box.web, env: box.env, input: JSON.stringify(payload), encoding: 'utf8' });+ assert.equal(stop.status, 0, stop.stderr);+ const notice = JSON.parse(stop.stdout);+ assert.equal(notice.continue === false || notice.decision === 'block', false);+ assert.match(notice.systemMessage, new RegExp(`#${id}\\b`));+ }+ const broken = runFixtureChild(process.execPath, [e2e.BIN, 'hook', 'SessionStart'], { cwd: box.dir, env: box.env, encoding: 'utf8' });+ assert.equal(broken.status, 0);+ assert.match(JSON.parse(broken.stdout).systemMessage, /warning.*continuing/i);+ const unknown = runFixtureChild(process.execPath, [e2e.BIN, 'hook', 'FutureVendorEvent'], { cwd: box.dir, env: box.env, encoding: 'utf8' });+ assert.equal(unknown.status, 0);+ assert.equal(unknown.stdout, '');+ const slow = join(box.dir, 'slow-git');+ mkdirSync(slow);+ writeFileSync(join(slow, 'git'), '#!/bin/sh\nexec /bin/sleep 10\n');+ chmodSync(join(slow, 'git'), 0o755);+ const timeout = runFixtureChild(process.execPath, [e2e.BIN, 'hook', 'SessionStart'], {+ cwd: box.web, env: { ...box.env, PATH: `${slow}:${box.env.PATH}` }, encoding: 'utf8',+ });+ assert.equal(timeout.status, 0);+ assert.match(JSON.parse(timeout.stdout).systemMessage, /timed out.*continuing/i);+ const doctor = box.run(box.repo, 'doctor', '--json');+ const status = JSON.parse(doctor.out).agentHooks.find(hook => hook.vendor === 'Codex');+ assert.deepEqual(status.events, ['SessionStart', 'Stop']);+ assert.equal(status.trust, 'unverified', 'installation never fabricates vendor trust');+ assert.equal(box.run(box.repo, 'hooks', 'uninstall').code, 0);+ assert.deepEqual(JSON.parse(readFileSync(claude, 'utf8')), mine);+ assert.deepEqual(JSON.parse(readFileSync(codex, 'utf8')), codexMine);+ const disabled = join(box.dir, 'disabled');+ mkdirSync(disabled);+ box.git(disabled, 'init', '-q', '-b', 'main');+ assert.equal(box.run(disabled, 'init', '--no-hooks', '--no-permissions').code, 0);+ assert.equal(existsSync(join(disabled, '.codex/hooks.json')), false);+ assert.equal(existsSync(join(disabled, '.claude/settings.json')), false);});/** Make a private real repository for staged-diff hook tests, with cleanup tied to the test. */