Skip to content

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.

feat(spec): a refused person answer names the command to paste [S1,B26]

Corey Olson07346535160c
diff --git a/src/cli.js b/src/cli.js
index ecaf27ff..21ffb992 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -71,6 +71,7 @@ import {
import {
AGENT_SESSION_IDS,
agentSessionDigest,
+ personCommand,
requirePersonChannel,
personShout,
} from './person.js';
@@ -4018,7 +4019,7 @@ async function specCommand(io, { first, second, rest, values }) {
});
}
if (first === 'answer') {
- requirePersonChannel(io.personChannel);
+ requirePersonChannel(io.personChannel, process.env, { command: personCommand(ctx.info, ['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.js
index 539c4b97..e8dbfb51 100644
--- a/src/person.js
+++ b/src/person.js
@@ -1,5 +1,7 @@
/** 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';
@@ -31,16 +33,34 @@ export function agentSessionDigest(environment = process.env) {
return createHash('sha256').update(JSON.stringify(identity)).digest('hex');
}
+/** Quote one shell word so a person can paste it as is. */
+function shellWord(word) {
+ return /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${String(word).replaceAll("'", "'\\''")}'`;
+}
+
+/**
+ * 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.
+ *
+ * @param {{ commonDir: string }} info
+ * @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;
+ return `cd ${shellWord(main)} && pullboard ${words.filter((word) => word !== undefined && word !== '').map(shellWord).join(' ')}`;
+}
+
/** Refuse terminal person actions in an agent shell; only the authenticated view adapter supplies view. */
-export function requirePersonChannel(channel = 'terminal', environment = process.env) {
+export function requirePersonChannel(channel = 'terminal', environment = process.env, { command } = {}) {
+ const relay = command ? `the person pastes this into their own terminal (not an agent's), or answers in pullboard view: ${command}` : undefined;
if (!['terminal', 'view'].includes(channel)) {
throw 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; run pullboard view, the person’s channel, and let the person act there');
+ 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);
}
if (channel === 'terminal' && remoteShell(environment)) {
- throw new Refused('B26_PERSON_CHANNEL', 'this is a remote SSH shell, not the person’s terminal; run pullboard view, the person’s channel, and let the person act there');
+ throw new Refused('B26_PERSON_CHANNEL', 'this is a remote SSH shell, not the person’s terminal; run pullboard view, the person’s channel, and let the person act there', relay);
}
return channel;
}
@@ -51,7 +71,7 @@ export function requireRelayOnChannel(channel = 'terminal', environment = proces
throw 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; run pullboard view, the person’s channel, and let the person act there');
+ 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);
}
return channel;
}
diff --git a/test/spec.test.js b/test/spec.test.js
index 8d51a6ac..40e9dd1a 100644
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@ -1016,3 +1016,20 @@ test('a changed approved draft needs a new decision before apply [S1,I1,P6]', t
const applied = JSON.parse(runIn(box, box.root, ['resume', '--json']).stdout);
assert.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 });
+ 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');
+ const error = JSON.parse(refused.stdout).error;
+ assert.equal(error.code, 'B26_PERSON_CHANNEL');
+ assert.match(error.message, /relay the command below to the person verbatim/u);
+ const pasted = error.next.slice(error.next.lastIndexOf(': cd ') + 2);
+ assert.equal(pasted, `cd ${box.root} && pullboard spec answer B2 'Redis on the host'\\''s port'`, 'the id and the proposed choice, quoted, with no placeholder');
+ assert.equal(readFileSync(join(box.root, box.specName), 'utf8'), before);
+ // The person pastes it into their own terminal and it is recorded.
+ const 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");
+});