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(merge): doctor and resume say when the hooks aren't wired [L3]
Corey Olson62e2de082594
diff --cc src/cli.jsindex 22cac1d9,d197be80..acd4bc45--- a/src/cli.js+++ b/src/cli.js@@@ -25,11 -25,10 +25,12 @@@ importpreCommitProblems,prePushProblems,pushesTrunk,+ unwiredHookProblems,} from './hooks.js';import { initRepo } from './init.js';-import { lifecycleHelp, lifecycleMarkdown } from './machine.js';+import { lifecycleMarkdown } from './machine.js';+import { HELP, VERSION } from './help.js';+export { HELP, VERSION };import { productLine, productProblems, productSummaries } from './products.js';import { isLane, laneNames, laneOf, outOfLane } from './lanes.js';import { Refused } from './refused.js';diff --cc test/doctor.test.jsindex 1a3d8926,a47de13b..c83fd89b--- a/test/doctor.test.js+++ b/test/doctor.test.js@@@ -1,9 -1,9 +1,9 @@@/** Integrity checks use throwaway git repositories and real board databases (A6). */import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';- import { join, resolve } from 'node:path';+ import { delimiter, join, resolve } from 'node:path';import { after, test } from 'node:test';import { DatabaseSync } from 'node:sqlite';import { SCHEMA_VERSION } from '../src/board.js';@@@ -86,6 -86,174 +86,174 @@@ test('doctor reports a clean board in oassert.deepEqual(readFileSync(box.dbFile), before);});+ test('doctor names an unwired hook and resume gives the repair line [L3]', () => {+ const box = boardBox();+ const hooks = join(box.root, '.husky');+ mkdirSync(hooks);+ box.git('config', 'core.hooksPath', '.husky');+ writeFileSync(join(hooks, 'pre-commit'), '#!/bin/sh\nnpx lint-staged\n');+ writeFileSync(join(hooks, 'pre-merge-commit'), '#!/bin/sh\npullboard hook pre-merge-commit "$@"\n');+ chmodSync(join(hooks, 'pre-commit'), 0o755);+ chmodSync(join(hooks, 'pre-merge-commit'), 0o755);+ const expected = 'active Git hook .husky/pre-commit does not call pullboard hook pre-commit';++ const doctor = box.run('doctor');+ assert.equal(doctor.status, 1);+ assert.equal(doctor.stdout.split('\n').filter((line) => line.includes(expected)).length, 1, doctor.stdout);+ assert.ok(doctor.stdout.includes(`${expected}; repair: add this line: pullboard hook pre-commit "$@"`), doctor.stdout);+ const resume = box.run('resume');+ assert.equal(resume.status, 0, resume.stderr);+ assert.equal(resume.stdout.split('\n').filter((line) => line.includes(expected)).length, 1, resume.stdout);+ assert.ok(resume.stdout.includes(`${expected}; add this line: pullboard hook pre-commit "$@"`), resume.stdout);+ const doctorJson = box.run('doctor', '--json');+ assert.equal(doctorJson.status, 1);+ const finding = { code: 'HOOK_UNWIRED', message: expected, next: 'add this line: pullboard hook pre-commit "$@"' };+ assert.deepEqual(JSON.parse(doctorJson.stdout).problems, [finding]);+ const resumeJson = box.run('resume', '--json');+ assert.equal(resumeJson.status, 0, resumeJson.stderr);+ assert.deepEqual(JSON.parse(resumeJson.stdout).hookProblems, [finding]);++ writeFileSync(join(hooks, 'pre-commit'), '#!/bin/sh\npullboard hook pre-commit "$@"\n');+ chmodSync(join(hooks, 'pre-commit'), 0o755);+ box.git('config', 'core.hooksPath', hooks);+ assert.doesNotMatch(box.run('doctor').stdout, /HOOK_UNWIRED|active Git hook/u);+ assert.doesNotMatch(box.run('resume').stdout, /HOOK_UNWIRED|active Git hook/u);+ });+++ /** Quote one private fixture path as a shell word without expanding user text. */+ function hookWord(value) { return "'" + value.replaceAll("'", "'\\''") + "'"; }++ /** Install a real CLI wrapper whose marker proves whether Git actually invokes Pullboard. */+ function executedHookBox() {+ const box = boardBox();+ const bin = join(box.dir, 'private-bin');+ const hooks = join(box.root, '.husky');+ const marker = join(box.dir, 'executed-hook');+ mkdirSync(bin); mkdirSync(hooks);+ writeFileSync(join(bin, 'pullboard'), '#!/bin/sh\nprintf \'%s\\n\' "$*" >> "$PULLBOARD_TEST_HOOK_MARKER"\nexec '+ + hookWord(process.execPath) + ' ' + hookWord(BIN) + ' "$@"\n');+ chmodSync(join(bin, 'pullboard'), 0o755);+ box.env.PATH = bin + delimiter + box.env.PATH;+ box.env.PULLBOARD_TEST_HOOK_MARKER = marker;+ box.git('config', 'core.hooksPath', '.husky');+ writeFileSync(join(hooks, 'pre-merge-commit'), '#!/bin/sh\npullboard hook pre-merge-commit "$@"\n');+ chmodSync(join(hooks, 'pre-merge-commit'), 0o755);+ return { ...box, hook: join(hooks, 'pre-commit'), marker };+ }++ test('doctor and resume accept env delegation that real Git executes [L3]', () => {+ const box = executedHookBox();+ for (const source of ['#!/bin/sh\nenv pullboard hook pre-commit "$@"\n',+ '#!/bin/sh\nexec env pullboard hook pre-commit "$@"\n']) {+ writeFileSync(box.hook, source); chmodSync(box.hook, 0o755);+ writeFileSync(box.marker, '');+ box.git('commit', '--allow-empty', '-q', '-m', 'chore: actual hook control');+ assert.match(readFileSync(box.marker, 'utf8'), /^hook pre-commit\n$/u,+ 'the real Git pre-commit hook invoked the actual submitted CLI once');+ writeFileSync(box.marker, '');+ const doctor = box.run('doctor');+ assert.equal(doctor.status, 0, 'an executed env delegation is wired');+ assert.equal(doctor.stdout, 'board is clean\n');+ const resume = box.run('resume');+ assert.equal(resume.status, 0);+ assert.doesNotMatch(resume.stdout, /active Git hook|HOOK_UNWIRED/u);+ assert.deepEqual(JSON.parse(box.run('doctor', '--json').stdout).problems, []);+ assert.deepEqual(JSON.parse(box.run('resume', '--json').stdout).hookProblems, []);+ assert.equal(readFileSync(box.marker, 'utf8'), '', 'diagnosis never executes the hook');+ assert.equal(readFileSync(box.hook, 'utf8'), source, 'diagnosis never edits the hook');+ }+ });++ test('doctor and resume accept env assignments that real Git executes [L3]', () => {+ const box = executedHookBox();+ for (const source of [+ '#!/bin/sh\nenv REVIEWER_HOOK_CONTROL=1 pullboard hook pre-commit "$@"\n',+ '#!/bin/sh\nexec env FIRST=one SECOND="two words" EMPTY= pullboard hook pre-commit "$@"\n',+ "#!/bin/sh\nenv FIRST='two words' SECOND=three pullboard hook pre-commit \"$@\"\n",+ ]) {+ writeFileSync(box.hook, source); chmodSync(box.hook, 0o755);+ writeFileSync(box.marker, '');+ box.git('commit', '--allow-empty', '-q', '-m', 'chore: actual hook control');+ assert.match(readFileSync(box.marker, 'utf8'), /^hook pre-commit\n$/u,+ 'the real Git pre-commit hook invoked the actual submitted CLI once');+ writeFileSync(box.marker, '');+ const doctor = box.run('doctor');+ assert.equal(doctor.status, 0, 'an executed env delegation is wired');+ assert.equal(doctor.stdout, 'board is clean\n');+ const resume = box.run('resume');+ assert.equal(resume.status, 0);+ assert.doesNotMatch(resume.stdout, /active Git hook|HOOK_UNWIRED/u);+ assert.deepEqual(JSON.parse(box.run('doctor', '--json').stdout).problems, []);+ assert.deepEqual(JSON.parse(box.run('resume', '--json').stdout).hookProblems, []);+ assert.equal(readFileSync(box.marker, 'utf8'), '', 'diagnosis never executes the hook');+ assert.equal(readFileSync(box.hook, 'utf8'), source, 'diagnosis never edits the hook');+ }+ });++ test('doctor and resume reject printed heredocs that real Git never executes [L3]', () => {+ const box = executedHookBox();+ const message = 'active Git hook .husky/pre-commit does not call pullboard hook pre-commit';+ const delegation = 'pullboard hook pre-commit "$@"';+ const finding = { code: 'HOOK_UNWIRED', message, next: 'add this line: ' + delegation };+ for (const source of [+ '#!/bin/sh\ncat <<\'DOCUMENTATION\'\npullboard hook pre-commit "$@"\nDOCUMENTATION\n',+ '#!/bin/sh\ncat <<DOCUMENTATION\npullboard hook pre-commit "$@"\nDOCUMENTATION\n',+ '#!/bin/sh\ncat <<-\'DOCUMENTATION\'\n\tpullboard hook pre-commit "$@"\n\tDOCUMENTATION\n',+ '#!/bin/sh\ncat <<FIRST <<"SECOND"\nexample\nFIRST\npullboard hook pre-commit "$@"\nSECOND\n',+ ]) {+ writeFileSync(box.hook, source); chmodSync(box.hook, 0o755);+ writeFileSync(box.marker, '');+ box.git('commit', '--allow-empty', '-q', '-m', 'chore: documentation control');+ assert.equal(readFileSync(box.marker, 'utf8'), '', 'Git only printed documentation; it never called the CLI');+ const doctor = box.run('doctor');+ assert.equal(doctor.status, 1, 'printed heredoc text cannot wire the active hook');+ assert.ok(doctor.stdout.includes(message + '; repair: ' + finding.next));+ const resume = box.run('resume');+ assert.equal(resume.status, 0);+ assert.ok(resume.stdout.includes(message + '; ' + finding.next));+ assert.deepEqual(JSON.parse(box.run('doctor', '--json').stdout).problems, [finding]);+ assert.deepEqual(JSON.parse(box.run('resume', '--json').stdout).hookProblems, [finding]);+ assert.equal(readFileSync(box.marker, 'utf8'), '', 'diagnosis never executes the printed example');+ assert.equal(readFileSync(box.hook, 'utf8'), source, 'diagnosis leaves documentation untouched');+ writeFileSync(box.hook, source + delegation + '\n');+ box.git('commit', '--allow-empty', '-q', '-m', 'chore: exact repair control');+ assert.match(readFileSync(box.marker, 'utf8'), /^hook pre-commit\n$/u, 'the exact repair line really invokes the CLI');+ assert.equal(box.run('doctor').stdout, 'board is clean\n');+ assert.doesNotMatch(box.run('resume').stdout, /active Git hook|HOOK_UNWIRED/u);+ }+ });++ test('text HELD refusal ends with the same next step as JSON [L3]', () => {+ const box = boardBox({ lanes: { web: { owns: ['web/'] } } });+ const added = box.run('add', 'web', 'Held refusal control', '--criterion', 'Do not edit a claimed item', '--json');+ assert.equal(added.status, 0, added.stderr || added.stdout);+ const id = JSON.parse(added.stdout).item.item_id;+ const created = box.run('worktree', 'web', '--json');+ assert.equal(created.status, 0, created.stderr || created.stdout);+ const agent = JSON.parse(created.stdout);- const claim = spawnSync(process.execPath, [BIN, 'claim', String(id), '--json'], { cwd: agent.path, env: box.env, encoding: 'utf8' });++ const claim = runFixtureChild(process.execPath, [BIN, 'claim', String(id), '--json'], { cwd: agent.path, env: box.env, encoding: 'utf8' });+ assert.equal(claim.status, 0, claim.stderr || claim.stdout);+ const text = box.run('edit', String(id), '--route', 'mid');+ const json = box.run('edit', String(id), '--route', 'mid', '--json');+ assert.equal(text.status, 1);+ assert.equal(json.status, 1);+ const refusal = JSON.parse(json.stdout).error;+ assert.equal(refusal.code, 'HELD');+ assert.ok(text.stderr.trimEnd().endsWith(`next: ${refusal.next}`), text.stderr);+ });++ test('text USAGE refusal ends with the same next step as JSON [L3]', () => {+ const box = boardBox();+ const text = box.run('status', '--not-a-real-flag');+ const json = box.run('status', '--not-a-real-flag', '--json');+ assert.equal(text.status, 2);+ assert.equal(json.status, 2);+ const refusal = JSON.parse(json.stdout).error;+ assert.equal(refusal.code, 'USAGE');+ assert.ok(text.stderr.trimEnd().endsWith(`next: ${refusal.next}`), text.stderr);+ });+test('commands and doctor explain how to repair core.bare without crossing a nested repo [A6, P4]', () => {const box = boardBox({ repoName: "O'Brien project" });const root = box.git('rev-parse', '--show-toplevel');diff --cc test/hooks.test.jsindex 73b802b1,937fe22a..4df57777--- a/test/hooks.test.js+++ b/test/hooks.test.js@@@ -2,8 -2,8 +2,8 @@@* The commit-message rules (C1, C2) and the pre-commit pattern checks on real staged changes.*/import assert from 'node:assert/strict';-import { execFileSync } from 'node:child_process';+import { runFixtureExecFile as execFileSync, runFixtureGit } from './fixture-child.js';- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+ import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';diff --cc test/view-port.test.jsindex f92cf5b6,252b0cf6..7825d1ba--- a/test/view-port.test.js+++ b/test/view-port.test.js@@@ -24,9 -24,15 +24,15 @@@ test("a named port that is busy is refuGIT_CONFIG_GLOBAL: '/dev/null',GIT_CONFIG_NOSYSTEM: '1',};- const result = spawnSync(process.execPath, [BIN, 'view', '--no-open', '--port', String(port)], {- cwd: dir, env, encoding: 'utf8', timeout: 20000,+ const result = runFixtureChild(process.execPath, [BIN, 'view', '--no-open', '--port', String(port)], {+ cwd: dir, env, encoding: 'utf8',});assert.equal(result.status, 1, `a refusal, not a crash or a hang: ${result.stderr}`);- assert.equal(result.stderr.trim(), `pullboard: [PORT_BUSY] port ${port} is in use: name another with --port, or leave --port out to take any free one`);+ const json = spawnSync(process.execPath, [BIN, 'view', '--no-open', '--port', String(port), '--json'], {+ cwd: dir, env, encoding: 'utf8', timeout: 20000,+ });+ assert.equal(json.status, 1, json.stderr);+ const refusal = JSON.parse(json.stdout).error;+ assert.equal(refusal.code, 'PORT_BUSY');+ assert.equal(result.stderr.trim(), `pullboard: [PORT_BUSY] port ${port} is in use: name another with --port, or leave --port out to take any free one\nnext: ${refusal.next}`);});