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(init): init takes a product and an architecture blueprint [S1,I1]

Corey Olson281b3ef97813
diff --git a/docs/api.md b/docs/api.md
index 6d09e627..d76b0c46 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -291,6 +291,8 @@ Decision moves keep the CLI's routing: `shout` with `args.decision: true` may om
Only the coordinator runs `spec apply`. It preflights every pending row against the exact source text, refusing stale decisions before writing any file. Approval changes the status to `approved`; decline changes it to `wont` with the person's reason as the row text, preserving trailing fields. SSH-enabled approvals carry one signed `row-decision` receipt binding the file, source, replacement, decision, reason and row text. Apply copies that same receipt into `.pullboard/signoffs.jsonl`; it remains a current exact-text sign-off. Commit the changed files and receipts together.
+`init` and `blueprint add` take `--blueprint` more than once, and the blueprints land in the order given. A board takes at most one product blueprint and one architecture blueprint (kind `infrastructure` fills the architecture slot), and any number of practice and beyond-code ones; a second product or architecture blueprint is refused with `BLUEPRINT_KIND_TAKEN`, naming both, before anything is written. A rule or question whose row text an earlier blueprint in the same command drafted is drafted once: the later blueprint cites that row and lists it in `shared` as `{ key, id }`. Each starter item in `items` carries `blueprint`, the name of the blueprint that filed it, and its add appends a `note` fact `blueprint starter: {"blueprint":"<name>","version":<version>,"key":"<key>"}` to the item. With several blueprints, `blueprint add` returns the first blueprint's fields with every blueprint's `rows`, `items`, `proposedLanes` and `checksNotRun`, and each one's own result in `blueprints`; `init` returns the first in `blueprint` and all of them in `blueprints`.
+
To answer a pending question row (`<ask>: <default>. Choices: a, b.`, as `blueprint add` writes it), the person runs `spec answer <id> "<choice or text>"`, or the local view sends `spec-answer` with `args: {row: "B1", answer: "Postgres"}`. A listed choice matches in any case and keeps its listed spelling; other text joins the choices last. It refuses agent shells, agent worktrees and the API channel, records the same exact-row approval receipt, whose JSON `decisions` carry an `answer` read back from the signed text (never stored on its own), and the row leaves pending when the coordinator runs `spec apply`. `spec check` errors on a question that was pending at the trunk tip and now differs with no matching person decision.
To approve new wording, the person uses `spec approve <one-id> --text "exact proposed text"`, or `spec-approve` with `args: {ids: "G1", text: "exact proposed text"}`. This records the same exact-row receipt; files wait for coordinator apply. Text must be one nonempty line without a field separator. Pre-commit checks the staged row against that person decision or a verified staged SSH sign-off; unstaged receipts cannot authorize a commit.
diff --git a/src/blueprint-set.js b/src/blueprint-set.js
new file mode 100644
index 00000000..c60ceb82
--- /dev/null
+++ b/src/blueprint-set.js
@@ -0,0 +1,106 @@
+/**
+ * Several blueprints in one init or blueprint add [S1,I1]: --blueprint repeats, and the blueprints
+ * land in the order given. A board takes at most one product blueprint and one architecture
+ * blueprint, one per deployable (research U110), and any number of practice and beyond-code ones.
+ * A rule or question text two of them share is drafted once, by the first, and the later blueprint
+ * cites that row. Every starter item keeps the name of the blueprint that filed it.
+ */
+import { readBlueprint } from './blueprints.js';
+import { Refused } from './refused.js';
+
+/**
+ * The kinds a board takes one of, by the slot each fills. Why infrastructure fills the
+ * architecture slot: the bundled serverless and data-pipeline blueprints say infrastructure today,
+ * and #719 renames that kind to architecture, so both spellings name the same slot.
+ */
+const ONE_PER_BOARD = { product: 'product', infrastructure: 'architecture', architecture: 'architecture' };
+
+/**
+ * The slot a blueprint fills, product or architecture, or null for a kind a board takes any number of.
+ *
+ * @param {{ kind?: string }} blueprint
+ * @returns {string | null}
+ */
+export function blueprintSlot(blueprint) {
+ return ONE_PER_BOARD[blueprint.kind] ?? null;
+}
+
+/**
+ * Read every named blueprint, in the order given, before anything is written, so an unknown name
+ * or a clash leaves the repository as it was. The same blueprint version named twice is read once.
+ * A second product or architecture blueprint is refused with BLUEPRINT_KIND_TAKEN naming both.
+ *
+ * @param {string[]} references - Bundled names or paths, as --blueprint gave them.
+ * @param {string} cwd
+ * @param {string} command - The command to name in the next step, such as "init".
+ * @returns {{ reference: string, blueprint: import('./blueprints.js').Blueprint }[]}
+ */
+export function readBlueprints(references, cwd, command) {
+ const read = [];
+ for (const reference of references) {
+ const blueprint = readBlueprint(reference, cwd);
+ if (read.some((entry) => entry.blueprint.name === blueprint.name && entry.blueprint.version === blueprint.version)) continue;
+ const slot = blueprintSlot(blueprint);
+ const holder = slot && read.find((entry) => blueprintSlot(entry.blueprint) === slot);
+ if (holder) {
+ const keep = read.map((entry) => `--blueprint ${entry.reference}`).join(' ');
+ throw new Refused('BLUEPRINT_KIND_TAKEN',
+ `${holder.blueprint.name} and ${blueprint.name} are both ${slot} blueprints, and a board takes one ${slot} blueprint; keep one of them: pullboard ${command} ${keep}`,
+ `name one ${slot} blueprint: pullboard ${command} ${keep}`);
+ }
+ read.push({ reference, blueprint });
+ }
+ return read;
+}
+
+/**
+ * The result blueprint add gives for several blueprints: the first blueprint's own fields, as one
+ * add gives them, with the rows, items, lanes and stored checks of all of them, and each one's own
+ * summary in blueprints, in the order they landed.
+ *
+ * @param {any[]} added - Each blueprint's summary from its add, in order.
+ * @returns {any}
+ */
+export function combinedSummary(added) {
+ return { ...added[0], rows: added.flatMap((entry) => entry.rows), items: added.flatMap((entry) => entry.items),
+ gate: added.find((entry) => entry.gate)?.gate ?? null, marked: added.every((entry) => entry.marked),
+ proposedLanes: [...new Map(added.flatMap((entry) => entry.proposedLanes).map((lane) => [lane.name, lane])).values()],
+ checksNotRun: added.flatMap((entry) => entry.checksNotRun), blueprints: added };
+}
+
+/**
+ * What init's JSON result says about one blueprint it added.
+ *
+ * @param {any} added - The blueprint's summary from its add.
+ * @returns {any}
+ */
+export function initBlueprintResult(added) {
+ return { name: added.blueprint.name, title: added.blueprint.title, section: added.section, waiting: added.rows.length,
+ items: added.items.length, gate: added.gate, checksNotRun: added.checksNotRun, shared: added.shared ?? [] };
+}
+
+/**
+ * The line init and blueprint add print for rows a blueprint shares with one added before it:
+ * the rows it cites from there instead of drafting them again. Empty when it shares none.
+ *
+ * @param {any} added - The blueprint's summary from its add.
+ * @returns {string[]}
+ */
+export function sharedRowLines(added) {
+ const shared = added.shared ?? [];
+ if (!shared.length) return [];
+ return [`${added.blueprint.name} shares ${shared.map((row) => row.id).join(', ')} with an earlier blueprint, so each is drafted once`];
+}
+
+/**
+ * The note fact blueprint add records on each starter item it files, so the item keeps the name of
+ * its blueprint: the blueprint's name and version and the starter's key, as JSON after a fixed
+ * prefix. The text is the link #734 reads back with blueprint starters, so either reads the other.
+ *
+ * @param {{ name: string, version: number }} blueprint
+ * @param {string} key - The starter's key in the blueprint.
+ * @returns {string}
+ */
+export function blueprintStarterNote(blueprint, key) {
+ return `blueprint starter: ${JSON.stringify({ blueprint: blueprint.name, version: blueprint.version, key })}`;
+}
diff --git a/src/blueprints.js b/src/blueprints.js
index 98f80bff..08358266 100644
--- a/src/blueprints.js
+++ b/src/blueprints.js
@@ -358,18 +358,20 @@ export function landBlueprint(blueprint, answers) {
* the blueprint's section (found by title, or new), and plans every starter item. A retry after a
* failure part way (the under-way marker is there) files no rows and plans only the starters not
* yet on the board, found by title and the row ids they cite. A finished add (the marker is there)
- * plans nothing.
+ * plans nothing. A rule or question whose row text is in drafted, drafted by a blueprint added
+ * before it in the same command, files no row: its key takes that row's id, and it is listed in
+ * shared, so a text two blueprints share is drafted once (#720).
*
* @param {Blueprint} blueprint
- * @param {{ source: string, spec: any, doctrine: any, existingItems: { id: number, title: string, specIds: string[] }[], gate: string }} board
+ * @param {{ source: string, spec: any, doctrine: any, existingItems: { id: number, title: string, specIds: string[] }[], gate: string, drafted?: Map<string, string> }} board
* source is SPEC.md's text and spec its parse; doctrine is loadDoctrine's result; existingItems
- * are the items on the board; gate is pullboard.json's gate now.
- * @returns {{ marked: boolean, resumed: boolean, section: { prefix: string, name: string, isNew: boolean }, rows: { key: string, id: string, status: string, text: string, line: string }[], specRows: string, specAfter: string, ids: Record<string, string>, items: { key: string, title: string, specIds: string[], after: string[], lane?: string, route: string, criterion: string, brief: string }[], existing: Record<string, number>, gate: string | null }}
+ * are the items on the board; gate is pullboard.json's gate now; drafted maps row text to row id.
+ * @returns {{ marked: boolean, resumed: boolean, section: { prefix: string, name: string, isNew: boolean }, rows: { key: string, id: string, status: string, text: string, line: string }[], shared: { key: string, id: string }[], specRows: string, specAfter: string, ids: Record<string, string>, items: { key: string, title: string, specIds: string[], after: string[], lane?: string, route: string, criterion: string, brief: string }[], existing: Record<string, number>, gate: string | null }}
* specRows is the text to write before the items (rows and the under-way marker), specAfter the
* text once they are all added (the finished marker); existing maps starter keys already on the
* board to their item ids.
*/
-export function planBlueprint(blueprint, { source, spec, doctrine, existingItems = [], gate }) {
+export function planBlueprint(blueprint, { source, spec, doctrine, existingItems = [], gate, drafted = new Map() }) {
const marker = blueprintMarker(blueprint);
const lines = source.split(/\r?\n/u);
const marked = lines.some((text) => text.trim() === marker);
@@ -387,8 +389,9 @@ export function planBlueprint(blueprint, { source, spec, doctrine, existingItems
const name = existingSection ? existingSection.name : `${prefix} · ${blueprint.title.trim()}`;
const section = { prefix, name, isNew: !existingSection };
const gateToSet = !gate?.trim() && blueprint.gate ? blueprint.gate : null;
- if (marked) return { marked, resumed: false, section, rows: [], specRows: source, specAfter: source, ids: {}, items: [], existing: {}, gate: null };
+ if (marked) return { marked, resumed: false, section, rows: [], shared: [], specRows: source, specAfter: source, ids: {}, items: [], existing: {}, gate: null };
const rows = [];
+ const shared = [];
let ids;
let specRows = source;
if (resumed) ids = addingIds(addingLine, blueprint);
@@ -401,15 +404,24 @@ export function planBlueprint(blueprint, { source, spec, doctrine, existingItems
return id;
};
ids = {};
+ /** True when an earlier blueprint in this command drafted the same text: the key cites its row. */
+ const reuse = (key, text) => {
+ if (!drafted.has(text)) return false;
+ ids[key] = drafted.get(text);
+ shared.push({ key, id: ids[key] });
+ return true;
+ };
for (const rule of blueprint.rules) {
- const id = allocate();
const text = ruleText(rule);
+ if (reuse(rule.key, text)) continue;
+ const id = allocate();
ids[rule.key] = id;
rows.push({ key: rule.key, id, status: 'draft', text, line: `- ${id} [draft, ${rule.tier}] ${text} | gate: ${rule.gate}` });
}
for (const question of blueprint.questions) {
- const id = allocate();
const text = questionText(question);
+ if (reuse(question.key, text)) continue;
+ const id = allocate();
ids[question.key] = id;
rows.push({ key: question.key, id, status: 'pending', text, line: `- ${id} [pending, must] ${text} | gate: review` });
}
@@ -426,7 +438,7 @@ export function planBlueprint(blueprint, { source, spec, doctrine, existingItems
items.push({ key: item.key, title: item.title.trim(), specIds, after: item.after,
...(item.lane ? { lane: item.lane } : {}), ...(item.check ? { check: item.check } : {}), route: item.route, criterion: item.criterion, brief: item.brief });
}
- return { marked, resumed, section, rows, specRows, specAfter, ids, items, existing, gate: gateToSet };
+ return { marked, resumed, section, rows, shared, specRows, specAfter, ids, items, existing, gate: gateToSet };
}
/**
diff --git a/src/cli.js b/src/cli.js
index ccf54309..41404723 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -62,6 +62,7 @@ import {
unmetRows,
} from './spec.js';
import { answerQuestion, bundledBlueprints, landBlueprint, planBlueprint, readBlueprint, repoAnswers, saveBlueprint } from './blueprints.js';
+import { blueprintStarterNote, combinedSummary, initBlueprintResult, readBlueprints, sharedRowLines } from './blueprint-set.js';
import { briefFiles } from './brief.js';
import { commitFirst, commitOwnerLines, commitOwners, coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';
import { checkBaseline, prepareCheckBaseline, sayCheckBaseline, refuseCheckSyntax } from './check-baseline.js';
@@ -260,7 +261,7 @@ const OPTIONS = {
gate: { type: 'string' },
aim: { type: 'boolean' },
section: { type: 'string' },
- blueprint: { type: 'string' },
+ blueprint: { type: 'string', multiple: true },
route: { type: 'string' },
family: { type: 'string' },
model: { type: 'string' },
@@ -1660,10 +1661,10 @@ function setupCommands(io, { first, second, rest = [], values }) {
return {
init: async () => {
const info = repoInfo(io.cwd);
- // A named blueprint is read and checked before anything is written, so an unknown name
- // or a broken file or a URL leaves the repository untouched (#678). Past that, init adds the
- // blueprint exactly as pullboard blueprint add does, through the same function.
- const blueprint = values.blueprint === undefined ? null : readBlueprint(values.blueprint, io.cwd);
+ // Every named blueprint is read and checked before anything is written, so an unknown name,
+ // a broken file, a URL or a second product blueprint leaves the repository untouched (#678,
+ // #720). Past that, init adds each blueprint exactly as pullboard blueprint add does.
+ const blueprints = readBlueprints(values.blueprint ?? [], io.cwd, 'init');
const model = optionalModel(values.model);
const linked = relayLinked(info.root);
const ctx = linked && model !== undefined ? context(io) : null;
@@ -1691,17 +1692,19 @@ function setupCommands(io, { first, second, rest = [], values }) {
{ lane: COORDINATOR, path: info.root, model },
]));
// Keep blueprint initialization and the person's unwritten lane proposals in the same result.
- const added = blueprint ? await addBlueprintHere(io, values.blueprint, { report: false, blueprint }) : null;
+ const drafted = new Map();
+ const landed = [];
+ for (const { reference, blueprint } of blueprints) landed.push(await addBlueprintHere(io, reference, { report: false, blueprint, drafted }));
io.result?.({ root: info.root, notes, proposedLanes: proposeLanes(info.root),
- ...(added ? { blueprint: { name: added.blueprint.name, title: added.blueprint.title,
- section: added.section, waiting: added.rows.length, items: added.items.length, gate: added.gate, checksNotRun: added.checksNotRun } } : {}) });
+ ...(landed.length ? { blueprint: initBlueprintResult(landed[0]), blueprints: landed.map(initBlueprintResult) } : {}) });
const staging = notes.at(-1)?.startsWith('git add -f -- ') ? notes.at(-1) : null;
(staging ? notes.slice(0, -1) : notes).forEach((note) => io.say(note));
- if (added) {
+ for (const added of landed) {
io.say(`added the ${added.blueprint.title} blueprint: ${added.rows.length} ${added.rows.length === 1 ? 'row waits' : 'rows wait'} for your approval in SPEC.md (${added.section}), `
+ `${added.items.length} starter ${added.items.length === 1 ? 'item' : 'items'} filed${added.proposedLanes.length ? ` in the ${added.proposedLanes.map((lane) => lane.name).join(' and ')} lane, proposed above and not written until the person accepts` : ''}${added.gate ? `, gate set to ${added.gate}` : ''}`);
for (const note of askedLaneNotes(added.items, loadConfig(info.root))) io.say(` ${note}`);
if (added.checksNotRun.length) io.say(` checks stored, not run: ${added.checksNotRun.map((id) => `#${id}`).join(', ')}; no check baseline ran, so read each check before work starts: pullboard show <id>`);
+ for (const line of sharedRowLines(added)) io.say(` ${line}`);
}
if (await registerProjectAndLink(info.root, new Date(), loadConfig(info.root), io)) io.say('registered this project on this machine, so pullboard view lists it');
io.say(agentSessionDigest()
@@ -2372,12 +2375,13 @@ function reportSubmission(ctx, id, commit, gate, doctrine = []) {
*
* @param {any} io
* @param {string} reference - A bundled blueprint name or a path to a blueprint file, relative to io.cwd.
- * @param {{ report?: boolean, blueprint?: ReturnType<typeof readBlueprint> }} [options]
+ * @param {{ report?: boolean, blueprint?: ReturnType<typeof readBlueprint>, drafted?: Map<string, string> }} [options]
+ * drafted is the row text to id map shared by the blueprints of one command (see addBlueprint).
* @returns {Promise<BlueprintAdded>}
*/
-export async function addBlueprintHere(io, reference, { report = true, blueprint = readBlueprint(reference, io.cwd) } = {}) {
+export async function addBlueprintHere(io, reference, { report = true, blueprint = readBlueprint(reference, io.cwd), drafted } = {}) {
const ctx = context(io);
- return await withBoard(ctx, async (board) => await addBlueprint(ctx, board, whoAmI(ctx, board), blueprint, { report }));
+ return await withBoard(ctx, async (board) => await addBlueprint(ctx, board, whoAmI(ctx, board), blueprint, { report, drafted }));
}
/**
@@ -2390,6 +2394,7 @@ export async function addBlueprintHere(io, reference, { report = true, blueprint
* @property {boolean} marked - This blueprint version was already on the board, so nothing was added.
* @property {number[]} checksNotRun - New items that carry a check; no check baseline ran for them.
* @property {{ name: string, owns: string[] }[]} proposedLanes - Proposed, unwritten lanes new starters were filed in.
+ * @property {{ key: string, id: string }[]} shared - Keys that cite a row an earlier blueprint in the same command drafted.
*/
/**
@@ -2402,11 +2407,14 @@ export async function addBlueprintHere(io, reference, { report = true, blueprint
* @param {any} board
* @param {{ id: string }} me
* @param {import('./blueprints.js').Blueprint} blueprint
- * @param {{ report?: boolean }} [options] - With report false, print nothing and set no JSON result.
+ * @param {{ report?: boolean, result?: boolean, drafted?: Map<string, string> }} [options] - With report false,
+ * print nothing and set no JSON result; with result false, print but set no JSON result. drafted
+ * holds the rows earlier blueprints of this command drafted, by text; this add files no row
+ * twice and adds its own (#720).
* @returns {Promise<BlueprintAdded>}
*/
-async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {
- const io = report ? ctx.io : { say: () => {} };
+async function addBlueprint(ctx, board, me, blueprint, { report = true, result = report, drafted = new Map() } = {}) {
+ const io = report ? (result ? ctx.io : { say: (text) => ctx.io.say(text) }) : { say: () => {} };
const spec = loadSpec(ctx.info.root, ctx.config);
if (!spec.exists) throw new Refused('NO_SPEC', `no ${ctx.config.spec}; run: pullboard init`);
const malformed = [[spec.file, spec.problems], [ctx.doctrine.repo.file, ctx.doctrine.repo.problems]].find(([, problems]) => problems.length);
@@ -2418,7 +2426,8 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {
// only: nothing runs and nothing is fetched (#725).
const plan = planBlueprint(landBlueprint(blueprint, repoAnswers(ctx.info.root)), { source, spec, doctrine: ctx.doctrine,
existingItems: store.listItems(board, { all: true }).map((item) => ({ id: item.item_id, title: item.item_title, specIds: item.item_spec_ids ? item.item_spec_ids.split(',') : [] })),
- gate: String(JSON.parse(configSource).gate ?? '') });
+ gate: String(JSON.parse(configSource).gate ?? ''), drafted });
+ for (const row of plan.rows) drafted.set(row.text, row.id);
// Every starter is checked before anything is written, so a refusal leaves the board as it was.
// Starters go to a build lane, never the coordinator's; a proposed lane is named, not written (#732).
const proposals = proposeLanes(ctx.info.root, ctx.config);
@@ -2453,6 +2462,8 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {
item.after = afterKeys.map((before) => byKey[before]).filter(Boolean);
const id = await ordered(ctx, board, 'addItem', [item]);
byKey[key] = id;
+ // The starter keeps its blueprint's name, in the link #734 reads back (#720).
+ await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: 'note', text: blueprintStarterNote(blueprint, key) }]);
added.push({ id, key, title: item.title, lane: item.lane, ...(asked ? { askedLane: asked } : {}), specIds: item.specIds, after: item.after, ...(item.check ? { check: item.check } : {}) });
}
} catch (error) {
@@ -2467,7 +2478,7 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {
if (plan.specAfter !== source && !files.some((file) => file.file === ctx.config.spec)) files.unshift({ file: ctx.config.spec });
const rows = plan.rows.map(({ key, id, status, text }) => ({ key, id, status, text }));
const summary = { blueprint: { name: blueprint.name, title: blueprint.title, version: blueprint.version },
- section: plan.section.name, rows, items: added, gate: plan.gate, marked: plan.marked, proposedLanes: added.length ? proposedLanes : [],
+ section: plan.section.name, rows, items: added.map((item) => ({ ...item, blueprint: blueprint.name })), gate: plan.gate, shared: plan.shared, marked: plan.marked, proposedLanes: added.length ? proposedLanes : [],
// Item checks are stored and never run during add; the caller tells the reader so.
checksNotRun: added.filter((item) => item.check).map((item) => item.id) };
io.result?.(summary);
@@ -2482,6 +2493,7 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {
if (checked.length) io.say(` checks stored, not run: ${checked.map((item) => `#${item.id}`).join(', ')}; no check baseline ran during add, so read each check before work starts: pullboard show <id>`);
for (const note of [...askedLaneNotes(added, ctx.config), ...starterLaneNotes(summary.proposedLanes)]) io.say(` ${note}`);
if (plan.gate) io.say(` gate set in ${CONFIG_FILE}: ${plan.gate}`);
+ for (const line of sharedRowLines(summary)) io.say(` ${line}`);
const changed = files.map((file) => file.file);
io.say(`next: the person approves the rows in pullboard view or with pullboard spec approve <ids>${changed.length ? `; commit ${changed.join(' and ')}` : ''}`);
return summary;
@@ -2860,10 +2872,16 @@ function workCommands(io, args) {
};
return {
blueprint: () => act(async (ctx, board, me) => {
- if (first !== 'add' || !second || rest.length) {
- throw new Refused('USAGE', `pullboard blueprint add <name or file> | save [file]; bundled: ${bundledBlueprints().join(', ')}`);
+ const references = [...(second ? [second] : []), ...(values.blueprint ?? [])];
+ if (first !== 'add' || !references.length || rest.length) {
+ throw new Refused('USAGE', `pullboard blueprint add <name or file> [--blueprint <name or file>]... | save [file]; bundled: ${bundledBlueprints().join(', ')}`);
}
- await addBlueprint(ctx, board, me, readBlueprint(second, io.cwd));
+ // Several blueprints land in the order given, as one result; one lands exactly as before (#720).
+ const listed = readBlueprints(references, io.cwd, 'blueprint add');
+ const drafted = new Map();
+ const landed = [];
+ for (const { blueprint } of listed) landed.push(await addBlueprint(ctx, board, me, blueprint, { result: listed.length === 1, drafted }));
+ if (listed.length > 1) io.result?.(combinedSummary(landed));
return 0;
}),
fact: () => act(async (ctx, board, me) => {
diff --git a/src/help.js b/src/help.js
index f04bad16..a022d17b 100644
--- a/src/help.js
+++ b/src/help.js
@@ -10,7 +10,7 @@ Nothing ships until a second agent verifies it.
Set up
pullboard tour see it work: a reject and its rework, scripted, in thirty seconds
- pullboard init [--model <name>] [--blueprint <name or file>] config, SPEC.md, agent instructions, git hooks, board; optional coordinator model
+ pullboard init [--model <name>] [--blueprint <name or file>]... config, SPEC.md, agent instructions, git hooks, board; optional coordinator model
pullboard worktree <lane> --model <name> [--route light] [--family <name>] make and join a worktree for a new agent
pullboard.json worktrees: inside or beside; init defaults to inside
pullboard join <lane> --model <name> [--route light] [--family <name>] register this worktree as an agent
@@ -169,8 +169,9 @@ Spec
pullboard spec draft <text> [--section <letter>] [--aim] [--gate "<gate>"] any agent appends a draft row; never approves it
--section chooses the section prefix; defaults to G
Defaults to must and gate review.
- pullboard blueprint add <name or file> add a blueprint's rules and questions as drafts, and its starter items
+ pullboard blueprint add <name or file> [--blueprint <name or file>]... add a blueprint's rules and questions as drafts, and its starter items
bundled: web-app; nothing is approved, and a repeat adds nothing
+ several land in order: one product, one architecture, any practice; a shared rule is drafted once
pullboard blueprint save [file] [--name <name>] [--title "<title>"] write approved rules and answered questions as a blueprint
never items, notes, paths, emails or names; file defaults to <project>.blueprint.json
pullboard spec signers add [--key <path>] [--by <principal>] opt into SSH-signed sign-offs
@@ -251,8 +252,8 @@ const HELP_ALIASES = {
lifecycle: { usage: 'pullboard lifecycle', source: null },
escalate: { usage: 'pullboard escalate <id> --note "..." [--note-file <file>]', source: 'escalate <id> --note "what was tried and how it failed"', extraFlags: ['--note-file <file>'] },
'view export': { usage: 'pullboard view --export <dir>', source: 'view' },
- blueprint: { usage: 'pullboard blueprint add <name or file>', source: 'blueprint add' },
- 'blueprint add': { usage: 'pullboard blueprint add <name or file>', source: 'blueprint add' },
+ blueprint: { usage: 'pullboard blueprint add <name or file> [--blueprint <name or file>]...', source: 'blueprint add' },
+ 'blueprint add': { usage: 'pullboard blueprint add <name or file> [--blueprint <name or file>]...', source: 'blueprint add' },
'spec check': { usage: 'pullboard spec check', source: 'spec check' },
'spec view': { usage: 'pullboard spec view [--out file]', source: 'spec view' },
'spec show': { usage: 'pullboard spec show <id>', source: 'spec show', onlyFlags: [] },
@@ -270,7 +271,7 @@ const HELP_ALIASES = {
const HELP_FLAG_EXPLANATIONS = {
'--after': 'claiming waits until those items are verified',
- '--blueprint': 'start from a bundled blueprint or a JSON file',
+ '--blueprint': 'start from a bundled blueprint or a JSON file; repeat it for one product, one architecture and any practice blueprints',
'--brief': 'what a cold agent needs',
'--check': 'the command that proves it',
'--family': 'records the family name',
diff --git a/src/next-steps.js b/src/next-steps.js
index 83fd45c4..57d096be 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -68,6 +68,7 @@ export const NEXT_STEPS = Object.freeze({
BLOCKED: 'take another item with pullboard next, or shout the lane it waits on: pullboard shout <lane> "<text>"',
BLUEPRINT_EXISTS: 'choose a file that does not exist: pullboard blueprint save <new-file>',
BLUEPRINT_ITEM_UNCHECKED: 'give the starter item named in the message a criterion and a check command, then run pullboard blueprint add <file> again',
+ BLUEPRINT_KIND_TAKEN: 'keep at most one product and one architecture blueprint, then run the same command again',
BLUEPRINT_URL: 'download and read the blueprint yourself, then run pullboard blueprint add <local-file>',
BOARD_BUSY: 'wait for the other pullboard process to finish, then retry',
BOARD_NOT_WRITABLE: 'give the agent write access to the repo\'s .git/pullboard folder, or run the command outside the sandbox',
diff --git a/src/templates.js b/src/templates.js
index 86f78deb..5f05dfc1 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -109,6 +109,8 @@ This repo runs on pullboard: a work board, lanes and a spec that live in git. No
${doctrineText(doctrine)}
+**Several blueprints.** \`pullboard init\` and \`pullboard blueprint add\` take \`--blueprint\` more than once, such as \`pullboard init --blueprint web-app --blueprint serverless\`: at most one product and one architecture blueprint, and any number of practice and beyond-code ones. They land in the order given, a rule two of them share is drafted once, and each starter item keeps the name of its blueprint.
+
**Role guides.** \`pullboard prompt run\`, \`decompose\`, \`plan\`, \`signoff\`, \`review\` and \`verify\` print the guide for each role. Claude Code also has them as skills. The agent in the main checkout runs the whole team by the run guide (the pullboard-run skill).
**Who you are.** An agent is its worktree. The main checkout is the coordinator. Every other agent gets its own worktree, already joined to one lane, from the main checkout:
diff --git a/test/api.test.js b/test/api.test.js
index 008edff9..807ab9f7 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -626,6 +626,12 @@ test('[A1] command results match the catalog across roots and subcommands', () =
assert.equal(json(box, repo, 'spec', ['draft', 'A draft API catalogue row'], 'draft').id, 'G2');
writeFileSync(join(box.dir, 'catalog-blueprint.json'), `${JSON.stringify({ blueprint: 1, name: 'catalog', title: 'Catalog', version: 1, rules: [{ key: 'R1', text: 'A catalog rule.', why: 'the API lists it.' }] })}\n`);
assert.equal(json(box, repo, 'blueprint', ['add', join(box.dir, 'catalog-blueprint.json')], 'add').rows[0].status, 'draft');
+ // Two blueprints in one add give one catalog result, the shared rule drafted once (#720).
+ const pair = (name, kind, rules) => writeFileSync(join(box.dir, `${name}.json`), `${JSON.stringify({ blueprint: 1, name, title: name, version: 1, kind, rules })}\n`);
+ pair('catalog-product', 'product', [{ key: 'R1', text: 'A paired catalog rule.', why: 'the API lists it.' }]);
+ pair('catalog-practice', 'practice', [{ key: 'R1', text: 'A paired catalog rule.', why: 'the API lists it.' }, { key: 'R2', text: 'A practice catalog rule.', why: 'the API lists it.' }]);
+ const paired = json(box, repo, 'blueprint', ['add', join(box.dir, 'catalog-product.json'), '--blueprint', join(box.dir, 'catalog-practice.json')], 'add');
+ assert.deepEqual([paired.rows.length, paired.blueprints.length, paired.blueprints[1].shared.length], [2, 2, 1], 'two blueprints land as one result');
mkdirSync(join(repo, 'test'));
writeFileSync(join(repo, 'test', 'proof.test.js'), "import { test } from 'node:test';\ntest('proof [G1]', () => {});\n");
box.git(repo, 'add', 'SPEC.md', 'test/proof.test.js');
diff --git a/test/blueprint.test.js b/test/blueprint.test.js
index d8a50622..9866dda6 100644
--- a/test/blueprint.test.js
+++ b/test/blueprint.test.js
@@ -683,6 +683,111 @@ test('starter items land in a build lane, never the coordinator lane [S1,I1]', (
assert.match(said.stdout, /to accept, run: pullboard lane add app --owns app\//u, 'blueprint add prints the command that accepts it');
});
+/** The bundled blueprint of this name, as its file says. */
+function bundled(name) {
+ return JSON.parse(readFileSync(resolve(import.meta.dirname, `../src/blueprints/${name}.json`), 'utf8'));
+}
+
+/** Every row text a blueprint drafts, rules then questions, as SPEC.md carries them. */
+function draftedTexts(blueprint) {
+ return [...blueprint.rules.map((rule) => `${rule.text} Why: ${rule.why}`),
+ ...(blueprint.questions ?? []).map((question) => `${question.ask}: ${question.default ?? '(choose one)'}. Choices: ${question.choices.join(', ')}.`)];
+}
+
+test('init takes a product and an architecture blueprint together [S1,I1]', () => {
+ const product = bundled('web-app');
+ const architecture = bundled('serverless');
+ // A practice blueprint that shares one rule with web-app and one question with serverless.
+ const practice = { blueprint: 1, name: 'house-rules', title: 'House rules', version: 1, kind: 'practice', prefix: 'HR',
+ rules: [product.rules[0], { key: 'HR1', text: 'Every change names the row it serves.', why: 'a reviewer reads the bar before the code.' }],
+ questions: [architecture.questions[0]],
+ items: [{ key: '1', title: 'Every commit cites a row', cites: [product.rules[0].key, 'HR1', architecture.questions[0].key], route: 'mid',
+ criterion: 'Every commit names the spec row it serves; test/cites.test.js fails on one that does not.', brief: 'Files:\n- test/cites.test.js\nTest:\n- test/cites.test.js fails on a commit that cites no row', check: 'npm test -- test/cites.test.js' }] };
+ const box = emptyRepo();
+ const practiceFile = join(box.dir, 'house-rules.json');
+ writeFileSync(practiceFile, `${JSON.stringify(practice)}\n`);
+
+ const started = box.run('init', '--blueprint', 'web-app', '--blueprint', 'serverless', '--blueprint', practiceFile, '--json');
+ assert.equal(started.status, 0, started.stdout + started.stderr);
+ const result = JSON.parse(started.stdout);
+ assert.deepEqual(result.blueprints.map((entry) => entry.name), ['web-app', 'serverless', 'house-rules'], 'every blueprint lands, in the order given');
+ assert.equal(result.blueprint.name, 'web-app', 'the first blueprint keeps the single-blueprint field');
+
+ // Rules from every blueprint are drafted in the order given, each in its own section.
+ const source = readFileSync(join(box.repo, 'SPEC.md'), 'utf8');
+ const spec = parseSpec(source);
+ const sectionOf = (title) => spec.sections.findIndex((entry) => entry.name.endsWith(`· ${title}`));
+ const order = [product, architecture, practice].map((blueprint) => sectionOf(blueprint.title));
+ assert.ok(order.every((index) => index >= 0), `each blueprint has its own section: ${spec.sections.map((entry) => entry.name).join(', ')}`);
+ assert.deepEqual([...order].sort((a, b) => a - b), order, 'the sections follow the order the blueprints were given');
+ const rowsIn = (blueprint) => spec.rows.filter((row) => row.section === spec.sections[sectionOf(blueprint.title)].name);
+ assert.deepEqual(rowsIn(product).map((row) => row.text), draftedTexts(product), 'the product blueprint drafts all its rows, in its order');
+ assert.deepEqual(rowsIn(architecture).map((row) => row.text), draftedTexts(architecture), 'the architecture blueprint drafts all its rows, in its order');
+
+ // A rule text two blueprints share is drafted once: the practice blueprint drafts only its own rule.
+ assert.deepEqual(rowsIn(practice).map((row) => row.text), [`${practice.rules[1].text} Why: ${practice.rules[1].why}`], 'shared rows are not drafted again');
+ for (const text of new Set([...draftedTexts(product), ...draftedTexts(architecture), ...draftedTexts(practice)])) {
+ assert.equal(spec.rows.filter((row) => row.text === text).length, 1, `drafted once: ${text}`);
+ }
+ assert.ok(spec.rows.every((row) => row.status !== 'approved'), 'nothing is approved for the person');
+ const sharedRule = rowsIn(product)[0].id;
+ const sharedQuestion = rowsIn(architecture)[architecture.rules.length].id;
+ assert.deepEqual(result.blueprints[2].shared.map((row) => row.id), [sharedRule, sharedQuestion], 'the result names the rows it shares');
+
+ // Starter items keep their blueprint name, and the shared starter cites the row already drafted.
+ const items = JSON.parse(box.run('list', '--json').stdout).items ?? [];
+ assert.equal(items.length, product.items.length + architecture.items.length + practice.items.length, 'every starter is filed once');
+ const owner = (item) => {
+ const note = JSON.parse(box.run('show', String(item.item_id), '--json').stdout).thread
+ .find((entry) => entry.kind === 'note' && entry.text?.startsWith('blueprint starter: '));
+ return note ? JSON.parse(note.text.slice('blueprint starter: '.length)).blueprint : null;
+ };
+ const byTitle = (title) => items.find((item) => item.item_title === title);
+ for (const blueprint of [product, architecture, practice]) {
+ for (const starter of blueprint.items) assert.equal(owner(byTitle(starter.title)), blueprint.name, `${starter.title} keeps its blueprint name`);
+ }
+ const own = rowsIn(practice)[0].id;
+ assert.equal(byTitle(practice.items[0].title).item_spec_ids, [sharedRule, own, sharedQuestion].join(','), 'the shared starter cites the rows already drafted');
+
+ // blueprint add takes --blueprint more than once too, and each starter it files names its blueprint.
+ const board = freshBoard();
+ const added = json(board, 'blueprint', 'add', 'web-app', '--blueprint', 'serverless');
+ assert.deepEqual(added.blueprints.map((entry) => entry.blueprint.name), ['web-app', 'serverless']);
+ assert.deepEqual(added.items.map((item) => item.blueprint), [...product.items.map(() => 'web-app'), ...architecture.items.map(() => 'serverless')]);
+ assert.equal(added.rows.length, draftedTexts(product).length + draftedTexts(architecture).length);
+ assert.ok(added.rows.every((row) => ['draft', 'pending'].includes(row.status)), 'rows wait as drafts or pending');
+});
+
+test('a second blueprint of the same kind is refused [S1,I1]', () => {
+ // A second product blueprint: refused before anything is written, naming both.
+ for (const [first, second, kind] of [['web-app', 'ios-app', 'product'], ['serverless', 'data-pipeline', 'architecture']]) {
+ const box = emptyRepo();
+ const refused = box.run('init', '--blueprint', first, '--blueprint', second, '--json');
+ assert.notEqual(refused.status, 0, refused.stdout);
+ const { error } = JSON.parse(refused.stdout);
+ assert.equal(error.code, 'BLUEPRINT_KIND_TAKEN');
+ assert.match(error.message, new RegExp(`${first} and ${second} are both ${kind} blueprints`, 'u'), 'the refusal names both');
+ assert.deepEqual(readdirSync(box.repo).filter((name) => name !== '.git'), [], 'nothing is written');
+ assert.equal(existsSync(join(box.repo, '.git', 'pullboard')), false, 'no board is created');
+ }
+
+ // blueprint add refuses the same way and leaves SPEC.md as it was.
+ const board = freshBoard();
+ const before = readFileSync(join(board.repo, 'SPEC.md'), 'utf8');
+ const refused = board.run('blueprint', 'add', 'web-app', '--blueprint', 'website', '--json');
+ assert.notEqual(refused.status, 0, refused.stdout);
+ assert.equal(JSON.parse(refused.stdout).error.code, 'BLUEPRINT_KIND_TAKEN');
+ assert.match(JSON.parse(refused.stdout).error.message, /web-app and website are both product blueprints/u);
+ assert.equal(readFileSync(join(board.repo, 'SPEC.md'), 'utf8'), before, 'SPEC.md is unchanged');
+
+ // Any number of practice and beyond-code blueprints sit beside one product and one architecture.
+ const many = emptyRepo();
+ const names = ['web-app', 'serverless', 'test-reliability', 'research', 'writing'];
+ const landed = many.run('init', ...names.flatMap((name) => ['--blueprint', name]), '--json');
+ assert.equal(landed.status, 0, landed.stdout + landed.stderr);
+ assert.deepEqual(JSON.parse(landed.stdout).blueprints.map((entry) => entry.name), names);
+});
+
const e2e = createE2eHelpers();
after(e2e.cleanup);