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): draft pending requirements with one command [N32]

Corey Olsond49e3db3fc48
diff --git a/src/cli.js b/src/cli.js
index abd16ac3..130918ed 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -174,6 +174,7 @@ function commandHelp(name) {
' pullboard spec view — agent or person: write the offline spec page',
' pullboard spec show <id> — agent or person: inspect one row and its sign-offs',
' pullboard spec unmet — agent or person: list approved rows without current sign-off',
+ ' pullboard spec draft <text> [--aim] [--gate "<gate>"] — any agent: append a pending row; never approve it',
' pullboard spec signoff <ids> — person: sign rows with evidence',
' pullboard spec signers add — person: register an SSH signing key',
' pullboard spec approve <ids> — person: decide from their own terminal or Pullboard View',
@@ -236,6 +237,8 @@ const OPTIONS = {
brief: { type: 'string' },
'brief-file': { type: 'string' },
text: { type: 'string' },
+ gate: { type: 'string' },
+ aim: { type: 'boolean' },
route: { type: 'string' },
family: { type: 'string' },
model: { type: 'string' },
@@ -1097,11 +1100,10 @@ function boardSetup(ctx, card) {
const quote = value => "'" + String(value).replaceAll("'", "'\\''") + "'";
/** Preserve all existing configuration when recording one setup answer. */
const configure = patch => `node -e ${quote(`const fs=require('node:fs');const p='pullboard.json';const c=JSON.parse(fs.readFileSync(p,'utf8'));${patch};fs.writeFileSync(p,JSON.stringify(c,null,2)+${JSON.stringify('\n')})`)}`;
- const proposedIds = rows.length ? rows.map(row => row.id).join(',') : 'G1,G2';
const steps = [
{ number: 1, done: approved.length > 0, question: 'Ask the person: what are we building, and who will use it? Draft a few requirements as pending, then ask the person to approve them.',
- command: rows.length ? `pullboard spec show ${quote(rows[0].id)}` : `node -e ${quote(`require('node:fs').appendFileSync(${JSON.stringify(ctx.config.spec)},${JSON.stringify('\n- G1 [pending, must] Describe the first thing the person wants. | gate: review\n- G2 [pending, must] Describe how the person will know it works. | gate: review\n')})`)}`,
- afterAnswer: `Replace the proposed text with the person’s answer; the person approves ${proposedIds} in Pullboard View or runs pullboard spec approve ${proposedIds} in their own terminal; then the coordinator runs pullboard spec apply.` },
+ command: 'pullboard spec draft "<text>"',
+ afterAnswer: 'Record each answer with pullboard spec draft "<text>"; the person approves the returned ids in Pullboard View or runs pullboard spec approve <ids> in their own terminal; then the coordinator runs pullboard spec apply.' },
{ number: 2, done: lanes.length > 0, question: `Ask the person: how should we divide the work? Suggested folders: ${folders.join(', ') || 'app/ (create it for the app)'}.`,
command: configure(`c.lanes[${JSON.stringify(lane)}]={owns:[${JSON.stringify(lane + '/')}]}`) },
{ number: 3, done: Boolean(ctx.config.gate?.trim()), question: `Ask the person: which command proves the build works? Suggested: ${detectGate(ctx.info.root) || 'choose the repo’s test command'}.`,
@@ -2716,11 +2718,12 @@ async function specCommand(io, { first, second, rest, values }) {
unmet: ['must'],
signoff: ['by', 'note', 'note-file'],
signers: ['key', 'by'],
+ draft: ['aim', 'gate'],
approve: ['by', 'text'],
decline: ['reason'],
apply: [],
}[first ?? '--json'];
- if (!commandFlags) throw new Refused('USAGE', 'use pullboard spec --json | check | view | show <id> | unmet [--must] | signoff <ids> | approve <ids> | decline <ids> --reason "why" | apply');
+ if (!commandFlags) throw new Refused('USAGE', 'use pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | approve <ids> | decline <ids> --reason "why" | apply');
const allowedFlags = [...new Set([...commandFlags, 'json'])];
for (const flag of Object.keys(values)) {
if (!allowedFlags.includes(flag)) {
@@ -2732,6 +2735,38 @@ async function specCommand(io, { first, second, rest, values }) {
if (!spec.exists) throw new Refused('NO_SPEC', `no ${ctx.config.spec}; run: pullboard init`);
const practice = ctx.doctrine;
const signoffs = readSignoffs(ctx.info.root);
+ if (first === 'draft') {
+ if (!second?.trim() || rest.length || /[\r\n|]/u.test(second)) {
+ throw new Refused('USAGE', 'give one nonempty, single-line requirement: pullboard spec draft "<text>"');
+ }
+ if (values.gate !== undefined && (!values.gate.trim() || /[\r\n|]/u.test(values.gate))) {
+ throw new Refused('USAGE', 'give one nonempty, single-line gate without a field separator, or omit --gate to use review');
+ }
+ const section = spec.sections[0];
+ if (!section) throw new Refused('NO_SECTION', `no section in ${ctx.config.spec}; add a section heading, then draft the requirement`);
+ const prefix = /^([A-Z][A-Z0-9]*)\s*[·.:-]/u.exec(section.name)?.[1];
+ if (!prefix) throw new Refused('SPEC_SECTION', `the first section "${section.name}" needs an id prefix such as G · Goals before drafting`);
+ const numbered = spec.rows.map((row) => new RegExp(`^${prefix}(\\d+)$`, 'u').exec(row.id)?.[1]).filter(Boolean).map(Number);
+ let next = Math.max(0, ...numbered) + 1;
+ while (spec.rows.some((row) => row.id === `${prefix}${next}`)) next += 1;
+ const id = `${prefix}${next}`;
+ const tier = values.aim ? 'aim' : 'must';
+ const gate = values.gate?.trim() ?? 'review';
+ const row = `- ${id} [pending, ${tier}] ${second.trim()} | gate: ${gate}`;
+ const source = readFileSync(spec.file, 'utf8');
+ const newline = source.includes('\r\n') ? '\r\n' : '\n';
+ const lines = source.split(/\r?\n/u);
+ const following = spec.sections.find((entry) => entry.line > section.line);
+ let insertion = following ? following.line - 1 : lines.length;
+ while (insertion > section.line && !lines[insertion - 1].trim()) insertion -= 1;
+ lines.splice(insertion, 0, row);
+ const after = lines.join(newline);
+ writeRowApply(ctx.info.root, { records: [], files: [{ file: ctx.config.spec, before: source, after }],
+ signoffs: { before: null, receipts: [] } });
+ io.result?.({ id, row: { id, status: 'pending', tier, text: second.trim(), gate, section: section.name } });
+ io.say(id);
+ return 0;
+ }
if (first === 'approve' || first === 'decline') {
requirePersonChannel(io.personChannel);
return withBoard(ctx, async (board) => {
@@ -2911,7 +2946,7 @@ async function specCommand(io, { first, second, rest, values }) {
io.say(`signed ${count} rows as ${by}; commit .pullboard/signoffs.jsonl`);
return 0;
}
- throw new Refused('USAGE', 'pullboard spec --json | check | view | show <id> | unmet [--must] | signoff <ids> | signers add | approve <ids> | decline <ids> --reason "why" | apply');
+ throw new Refused('USAGE', 'pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | signers add | approve <ids> | decline <ids> --reason "why" | apply');
}
/** Read one consent line without waiting for EOF in an interactive terminal [V2]. */
diff --git a/src/help.js b/src/help.js
index f41d3702..c326d0b7 100644
--- a/src/help.js
+++ b/src/help.js
@@ -143,6 +143,8 @@ Spec
pullboard spec view [--out file] the spec, open questions, sign-offs and doctrine as one page
pullboard spec show <id> | unmet [--must] | signoff <ids> [--by <principal>]
signoff: --note "what was checked" stays with the receipt
+ pullboard spec draft <text> [--aim] [--gate "<gate>"] any agent appends a pending row; never approves it
+ Defaults to must and gate review.
pullboard spec signers add [--key <path>] [--by <principal>] opt into SSH-signed sign-offs
principal defaults to Git user.email; --by overrides it
pullboard spec approve <ids> | decline <ids> --reason "why" the person's exact-row decision
@@ -166,7 +168,7 @@ const HELP_NAMES = [
'serve', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'skills', 'show', 'next', 'land',
'check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',
'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view',
- 'spec show', 'spec unmet', 'spec signoff', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook',
+ 'spec show', 'spec unmet', 'spec signoff', 'spec draft', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook',
'hook pre-commit', 'hook pre-merge-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help',
'roadmap', 'milestone',
];
@@ -195,6 +197,7 @@ const HELP_EXAMPLES = {
run: 'pullboard run --agent "node agent.js"', 'view export': 'pullboard view --export ./site',
'spec check': 'pullboard spec check',
'spec view': 'pullboard spec view', 'spec show': 'pullboard spec show G1',
+ 'spec draft': 'pullboard spec draft "Describe the first requirement"',
'spec unmet': 'pullboard spec unmet', 'spec signoff': 'pullboard spec signoff G1',
'spec signers add': 'pullboard spec signers add', help: 'pullboard help claim', version: 'pullboard --version',
};
diff --git a/src/json.js b/src/json.js
index 8a1754d8..82120b5b 100644
--- a/src/json.js
+++ b/src/json.js
@@ -74,6 +74,7 @@ export const JSON_SHAPES = {
'spec check': shape({ rows: 'array' }),
'spec view': shape({ path: 'string' }),
'spec show': shape({ row: 'object', standing: 'object' }),
+ 'spec draft': shape({ id: 'string', row: 'object' }),
'spec unmet': shape({ rows: 'array' }),
'spec signoff': shape({ count: 'number', by: 'string', ids: 'array', evidence: 'array' }),
'spec signers': shape({ added: 'boolean', by: 'string', path: 'string', initial: 'boolean' }),
diff --git a/test/api.test.js b/test/api.test.js
index 0c398433..c26fbdf5 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -590,9 +590,10 @@ test('[A1] command results match the catalog across roots and subcommands', () =
json(box, repo, 'spec', ['view', '--out', join(box.dir, 'spec.html')], 'view');
json(box, repo, 'spec', ['show', 'G1'], 'show');
json(box, repo, 'spec', ['unmet'], 'unmet');
+ assert.equal(json(box, repo, 'spec', ['draft', 'A pending API catalogue row'], 'draft').id, 'G2');
mkdirSync(join(repo, 'test'));
writeFileSync(join(repo, 'test', 'proof.test.js'), "import { test } from 'node:test';\ntest('proof [G1]', () => {});\n");
- box.git(repo, 'add', 'test/proof.test.js');
+ box.git(repo, 'add', 'SPEC.md', 'test/proof.test.js');
box.git(repo, 'commit', '-q', '-m', 'test: cite the fixture');
const signerKey = join(box.dir, 'signer-key');
execFileSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', signerKey], { stdio: 'pipe' });
diff --git a/test/resume-flow.test.js b/test/resume-flow.test.js
index 71cf108b..28d03942 100644
--- a/test/resume-flow.test.js
+++ b/test/resume-flow.test.js
@@ -276,6 +276,58 @@ test('agent resume keeps its next step without a coordinator flow alert [N32,R1,
assert.equal(Object.hasOwn(await box.run(['resume', '--json'], box.web), 'flow'), false);
});
+test('spec draft adds a pending row and resume names it [N32]', t => {
+ const box = releaseFixture(t, { freshSetup: true });
+ const initial = JSON.parse(box.run(box.repo, 'resume', '--json').stdout);
+ assert.equal(initial.setup.step, 1);
+ assert.match(initial.setup.command, /^pullboard spec draft/u);
+ assert.doesNotMatch(initial.setup.command, /node -e|appendFileSync/u);
+ assert.match(initial.setup.afterAnswer, /record each answer with pullboard spec draft/iu);
+
+ const help = box.run(box.repo, 'help', 'spec', '--json');
+ assert.equal(help.status, 0, help.failure || help.stderr);
+ assert.match(JSON.parse(help.stdout).help, /spec draft <text>.*any agent: append a pending row/u);
+
+ const first = box.run(box.repo, 'spec', 'draft', 'Describe the first requirement', '--json');
+ const second = box.run(box.repo, 'spec', 'draft', 'Describe the second requirement', '--aim', '--gate', 'node --test', '--json');
+ assert.equal(first.status, 0, first.failure || first.stderr);
+ assert.equal(second.status, 0, second.failure || second.stderr);
+ const rows = JSON.parse(box.run(box.repo, 'spec', '--json').stdout).rows;
+ assert.deepEqual(rows.filter(row => ['G1', 'G2'].includes(row.id)).map(({ id, status, tier, text, gate }) => ({ id, status, tier, text, gate })), [
+ { id: 'G1', status: 'pending', tier: 'must', text: 'Describe the first requirement', gate: 'review' },
+ { id: 'G2', status: 'pending', tier: 'aim', text: 'Describe the second requirement', gate: 'node --test' },
+ ], 'draft appends two sequential pending rows with the requested defaults');
+ assert.equal(JSON.parse(first.stdout).id, 'G1');
+ assert.equal(JSON.parse(second.stdout).id, 'G2');
+ const beforeEmpty = readFileSync(join(box.repo, 'SPEC.md'), 'utf8');
+ const empty = box.run(box.repo, 'spec', 'draft', ' ', '--json');
+ assert.notEqual(empty.status, 0);
+ assert.equal(JSON.parse(empty.stdout).error.code, 'USAGE');
+ assert.equal(readFileSync(join(box.repo, 'SPEC.md'), 'utf8'), beforeEmpty, 'an empty draft does not change the spec');
+
+ const next = JSON.parse(box.run(box.repo, 'resume', '--json').stdout);
+ assert.equal(next.setup.step, 1);
+ assert.match(next.setup.command, /^pullboard spec draft/u);
+
+ const custom = releaseFixture(t, { freshSetup: true });
+ const customSpec = [
+ '# Existing requirements', '', '## G · Goals',
+ '- G1 [approved, must] Keep the approved row. | gate: existing',
+ '- G3 [retired, aim] Keep the retired row. | gate: archive',
+ '- G5 [draft, must] Keep the draft row. | gate: review',
+ '- G6 [wont, aim] Keep the declined row. | gate: closed', '',
+ '## N · Notes', '- G2 [approved, must] Another section owns this id. | gate: existing', '',
+ ].join('\r\n');
+ writeFileSync(join(custom.repo, 'SPEC.md'), customSpec);
+ const customDraft = custom.run(custom.repo, 'spec', 'draft', 'Keep line endings intact', '--json');
+ assert.equal(customDraft.status, 0, customDraft.failure || customDraft.stderr);
+ assert.equal(JSON.parse(customDraft.stdout).id, 'G7');
+ const updatedSpec = readFileSync(join(custom.repo, 'SPEC.md'), 'utf8');
+ assert.equal(updatedSpec.replaceAll('\r\n', '').includes('\n'), false, 'draft preserves the source newline style');
+ assert.equal(updatedSpec, customSpec.replace('\r\n\r\n## N · Notes', '\r\n- G7 [pending, must] Keep line endings intact | gate: review\r\n\r\n## N · Notes'),
+ 'draft preserves every existing status row and inserts in the first section');
+});
+
test('coordinator resume finds the oldest unreserved item behind an older live review [N32,R1,R2]', async t => {
const box = fixture(t, { age: 190, otherAge: 181, reservation: 'live' });
alert(await box.run(['resume']), 'flow: unreviewed #2 waiting 3 h 1 min (> 3 h 0 min); bottleneck: not measured yet');
@@ -342,11 +394,14 @@ async function finishSetup(box, observe = () => {}) {
return setup;
}
const requirements = step(1);
- assert.match(requirements.afterAnswer, /person approves G1,G2 in Pullboard View or runs pullboard spec approve G1,G2 in their own terminal/u);
+ assert.match(requirements.afterAnswer, /person approves the returned ids in Pullboard View or runs pullboard spec approve <ids> in their own terminal/u);
assert.match(requirements.afterAnswer, /coordinator runs pullboard spec apply/u);
- recordSetupAnswer(box, requirements.command);
+ const drafted = ['Describe the first thing the person wants.', 'Describe how the person will know it works.']
+ .map(text => box.run(box.repo, 'spec', 'draft', text, '--json'));
+ for (const result of drafted) assert.equal(result.status, 0, result.failure || result.stderr || result.stdout);
+ const requirementIds = drafted.map(result => JSON.parse(result.stdout).id).join(',');
// The person decision is recorded through the real CLI in a synthetic, private person environment.
- for (const args of [['spec', 'approve', 'G1,G2'], ['spec', 'apply']]) {
+ for (const args of [['spec', 'approve', requirementIds], ['spec', 'apply']]) {
const result = box.run(box.repo, ...args);
assert.equal(result.status, 0, result.failure || result.stderr || result.stdout);
}