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(spec): person command cds to the real main checkout [S1,B26]
Corey Olson565525d597d8
diff --git a/src/cli.js b/src/cli.jsindex 21ffb992..861f1b50 100644--- a/src/cli.js+++ b/src/cli.js@@ -4019,7 +4019,7 @@ async function specCommand(io, { first, second, rest, values }) {});}if (first === 'answer') {- requirePersonChannel(io.personChannel, process.env, { command: personCommand(ctx.info, ['spec', 'answer', second, rest.join(' ')]) });+ requirePersonChannel(io.personChannel, process.env, { command: personCommand(primaryCheckoutRoot(ctx.info) ?? ctx.info.root, ['spec', 'answer', second, rest.join(' ')]) });return withBoard(ctx, async (board) => {const me = whoAmI(ctx, board);if (!ctx.info.isMain || me.id !== COORDINATOR) throw new Refused('B26_PERSON_APPROVAL', 'only the person answers a pending question, from the main checkout or the view', 'ask the person to answer it in pullboard view, or in their own terminal at the main checkout');diff --git a/src/person.js b/src/person.jsindex e8dbfb51..2a75e290 100644--- a/src/person.js+++ b/src/person.js@@ -1,7 +1,5 @@/** Person actions use the view when a terminal is remote or belongs to an agent [B26]. */import { createHash } from 'node:crypto';-import { basename } from 'node:path';-import { dirname } from 'node:path';import { COORDINATOR } from './config.js';import { Refused } from './refused.js';@@ -40,13 +38,14 @@ function shellWord(word) {/*** The exact command a person runs for a person-only action an agent proposed (#915): it changes to the main checkout,- * where person answers are taken, and quotes every word, so an agent relays it verbatim instead of a placeholder.+ * where person answers are taken, and quotes every word, so an agent relays it verbatim instead of a placeholder. The+ * caller resolves the main checkout from Git's worktree list, since a --separate-git-dir repository keeps its metadata+ * apart from its files.*- * @param {{ commonDir: string }} info+ * @param {string} main - the main checkout's folder* @param {string[]} words - the pullboard arguments, e.g. ['spec', 'answer', 'G3', 'Next.js']*/-export function personCommand(info, words) {- const main = basename(info.commonDir) === '.git' ? dirname(info.commonDir) : info.commonDir;+export function personCommand(main, words) {return `cd ${shellWord(main)} && pullboard ${words.filter((word) => word !== undefined && word !== '').map(shellWord).join(' ')}`;}@@ -71,7 +70,7 @@ export function requireRelayOnChannel(channel = 'terminal', environment = procesthrow new Refused('B26_PERSON_CHANNEL', 'person actions use the terminal or the view; run pullboard view, the person’s channel');}if (channel === 'terminal' && AGENT_SHELL_MARKERS.some((name) => Boolean(environment[name]))) {- throw new Refused('B26_PERSON_CHANNEL', `this terminal belongs to an agent; ${command ? 'relay the command below to the person verbatim' : 'run pullboard view, the person’s channel, and let the person act there'}`, relay);+ throw new Refused('B26_PERSON_CHANNEL', 'this terminal belongs to an agent; run pullboard view, the person’s channel, and let the person act there');}return channel;}diff --git a/test/spec.test.js b/test/spec.test.jsindex 40e9dd1a..1121e41d 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -11,6 +11,7 @@ import { pathToFileURL } from 'node:url';import { test } from 'node:test';import { standardDoctrine } from '../src/doctrine.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';+import { requireRelayOnChannel } from '../src/person.js';import { RECORDED_GENERIC_NEXT } from '../src/recorded-refusal.js';import {citedIds,@@ -355,7 +356,7 @@ test('the check command is part of the frozen bar; items without one keep their* A real repo and board with an isolated registry, so JSON exercises the command's lint and history* checks rather than just serializing the parser. Its files may use the configured names.*/-function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practice, specSource = SPEC, freshInit = false } = {}) {+function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practice, specSource = SPEC, freshInit = false, separateGitDir = false } = {}) {const root = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-spec-json-')));t.after(() => rmSync(root, { recursive: true, force: true }));const bin = join(root, '.bin');@@ -377,7 +378,10 @@ function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practiconst git = (...args) => runFixtureGit(args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });const command = (...args) => runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });const run = (...args) => command('spec', ...args);- git('init', '-q', '-b', 'main');+ // A --separate-git-dir repository keeps its Git metadata in another folder (#915).+ const metadata = separateGitDir ? realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-spec-git-'))) : null;+ if (metadata) t.after(() => rmSync(metadata, { recursive: true, force: true }));+ git('init', '-q', '-b', 'main', ...(metadata ? ['--separate-git-dir', join(metadata, 'repo.git')] : []));git('config', 'user.name', 'Test Agent');git('config', 'user.email', '[email protected]');const init = spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), 'init'], { cwd: root, env, encoding: 'utf8' });@@ -1017,8 +1021,15 @@ test('a changed approved draft needs a new decision before apply [S1,I1,P6]', tassert.doesNotMatch(applied.next, /spec apply|approve A1/u);});-test('a spec answer refused in an agent shell gives the person the exact command to paste [S1,B26]', (t) => {- const box = specBox(t, { specSource: QUESTION_SPEC });+test('a spec answer refused in an agent shell gives the person the exact command to paste [S1,B26]', async (t) => {+ for (const separateGitDir of [false, true]) await t.test(separateGitDir ? 'Git metadata in a separate folder' : 'a plain repository', (t) => answerCommandCase(t, separateGitDir));+ assert.throws(() => requireRelayOnChannel('terminal', { CLAUDECODE: '1' }), (error) => error.code === 'B26_PERSON_CHANNEL' && /run pullboard view/u.test(error.message),+ 'relay on keeps its own refusal in an agent shell');+});++/** Refuse a spec answer in an agent shell, then paste the returned command as the person would. */+function answerCommandCase(t, separateGitDir) {+ const box = specBox(t, { specSource: QUESTION_SPEC, separateGitDir });const before = readFileSync(join(box.root, box.specName), 'utf8');const refused = runIn(box, box.root, ['spec', 'answer', 'B2', "Redis on the host's port", '--json'], { ...box.env, CLAUDECODE: '1' });assert.notEqual(refused.status, 0, 'an agent shell never records a person answer');@@ -1032,4 +1043,4 @@ test('a spec answer refused in an agent shell gives the person the exact commandconst person = runFixtureChild('/bin/sh', ['-c', pasted.replace(/^cd \S+ && pullboard/u, `cd '${box.root}' && "${process.execPath}" "${resolve(import.meta.dirname, '../bin/pullboard.js')}"`) + ' --json'], { cwd: box.root, env: box.env, encoding: 'utf8' });assert.equal(person.status, 0, person.stdout + person.stderr);assert.equal(JSON.parse(person.stdout).decisions[0].answer, "Redis on the host's port");-});+}