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.

fix(init): one product per board after main's blueprint tests [S1,I1]

Corey Olson0662c6d29d9e
diff --git a/src/blueprint-set.js b/src/blueprint-set.js
index 2766ff87..c80301f4 100644
--- a/src/blueprint-set.js
+++ b/src/blueprint-set.js
@@ -146,3 +146,36 @@ export function sharedRowLines(added) {
export function blueprintStarterNote(blueprint, key) {
return `blueprint starter: ${JSON.stringify({ blueprint: blueprint.name, version: blueprint.version, key })}`;
}
+
+/**
+ * Add each blueprint in turn with one shared map of the rows drafted so far, by text, so a text
+ * two of them share is drafted once, by the first.
+ *
+ * @template T
+ * @param {T[]} list - The blueprints to add, in order.
+ * @param {(entry: T, drafted: Map<string, string>) => Promise<any>} add - Adds one and returns its summary.
+ * @returns {Promise<any[]>} Each blueprint's summary, in order.
+ */
+export async function landEach(list, add) {
+ const drafted = new Map();
+ const landed = [];
+ for (const entry of list) landed.push(await add(entry, drafted));
+ return landed;
+}
+
+/**
+ * The lines init prints for one blueprint it added: the summary, the starters that could not go to
+ * the lane they asked for, the checks stored and not run, and the rows it shares with one before it.
+ *
+ * @param {any} added - The blueprint's summary from its add.
+ * @param {string[]} laneNotes - askedLaneNotes for its starters.
+ * @returns {string[]}
+ */
+export function initBlueprintLines(added, laneNotes) {
+ const proposed = added.proposedLanes.length ? ` in the ${added.proposedLanes.map((lane) => lane.name).join(' and ')} lane, proposed above and not written until the person accepts` : '';
+ return [`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${proposed}${added.gate ? `, gate set to ${added.gate}` : ''}`,
+ ...laneNotes.map((note) => ` ${note}`),
+ ...(added.checksNotRun.length ? [` checks stored, not run: ${added.checksNotRun.map((id) => `#${id}`).join(', ')}; no check baseline ran, so read each check before work starts: pullboard show <id>`] : []),
+ ...sharedRowLines(added).map((line) => ` ${line}`)];
+}
diff --git a/src/cli.js b/src/cli.js
index 33bccdb9..864862eb 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -62,7 +62,7 @@ import {
unmetRows,
} from './spec.js';
import { answerQuestion, bundledBlueprints, landBlueprint, planBlueprint, readBlueprint, repoAnswers, saveBlueprint } from './blueprints.js';
-import { blueprintStarterNote, combinedSummary, initBlueprintResult, installedBlueprints, readBlueprints, sharedRowLines } from './blueprint-set.js';
+import { blueprintStarterNote, combinedSummary, initBlueprintLines, initBlueprintResult, installedBlueprints, landEach, 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';
@@ -1662,9 +1662,8 @@ function setupCommands(io, { first, second, rest = [], values }) {
return {
init: async () => {
const info = repoInfo(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.
+ // Every blueprint is read and checked before anything is written: an unknown name, a broken file, a URL
+ // or a second product leaves the repo untouched (#678, #720). Then each is added as blueprint add does.
const blueprints = readBlueprints(values.blueprint ?? [], io.cwd, 'init', installedBlueprints(info.root));
const model = optionalModel(values.model);
const linked = relayLinked(info.root);
@@ -1693,20 +1692,12 @@ 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 drafted = new Map();
- const landed = [];
- for (const { reference, blueprint } of blueprints) landed.push(await addBlueprintHere(io, reference, { report: false, blueprint, drafted }));
+ const landed = await landEach(blueprints, ({ reference, blueprint }, drafted) => addBlueprintHere(io, reference, { report: false, blueprint, drafted }));
io.result?.({ root: info.root, notes, proposedLanes: proposeLanes(info.root),
...(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));
- 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}`);
- }
+ for (const added of landed) initBlueprintLines(added, askedLaneNotes(added.items, loadConfig(info.root))).forEach((line) => 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()
? 'Next: run pullboard resume now to continue setup in this session; the new skills load next session, and setup does not need them.'
@@ -2383,8 +2374,7 @@ 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>, drafted?: Map<string, string> }} [options]
- * drafted is the row text to id map shared by the blueprints of one command (see addBlueprint).
+ * @param {{ report?: boolean, blueprint?: ReturnType<typeof readBlueprint>, drafted?: Map<string, string> }} [options] - drafted: see addBlueprint.
* @returns {Promise<BlueprintAdded>}
*/
export async function addBlueprintHere(io, reference, { report = true, blueprint = readBlueprint(reference, io.cwd), drafted } = {}) {
@@ -2415,10 +2405,8 @@ 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, 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).
+ * @param {{ report?: boolean, result?: boolean, drafted?: Map<string, string> }} [options] - report false prints nothing and sets no
+ * JSON result; result false prints but sets none. drafted: rows earlier blueprints of this command drafted, by text (#720).
* @returns {Promise<BlueprintAdded>}
*/
async function addBlueprint(ctx, board, me, blueprint, { report = true, result = report, drafted = new Map() } = {}) {
@@ -2881,14 +2869,10 @@ function workCommands(io, args) {
return {
blueprint: () => act(async (ctx, board, me) => {
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(', ')}`);
- }
+ 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(', ')}`);
// Several blueprints land in the order given, as one result; one lands exactly as before (#720).
const listed = readBlueprints(references, io.cwd, 'blueprint add', installedBlueprints(ctx.info.root));
- const drafted = new Map();
- const landed = [];
- for (const { blueprint } of listed) landed.push(await addBlueprint(ctx, board, me, blueprint, { result: listed.length === 1, drafted }));
+ const landed = await landEach(listed, ({ blueprint }, drafted) => addBlueprint(ctx, board, me, blueprint, { result: listed.length === 1, drafted }));
if (listed.length > 1) io.result?.(combinedSummary(landed));
return 0;
}),
diff --git a/test/blueprint.test.js b/test/blueprint.test.js
index 2058ed80..cfac872f 100644
--- a/test/blueprint.test.js
+++ b/test/blueprint.test.js
@@ -231,18 +231,26 @@ test('every bundled starter item carries a criterion and a check [S1,I1]', () =>
'test-reliability files one: find a flaky test by repeated runs, then make it deterministic');
// blueprint add files every bundled starter with its criterion and check, stored and never run.
- const box = freshBoard({ gate: 'true' });
- const expected = [];
+ // A board takes one product and one architecture blueprint (#720), so each goes to the first
+ // board that has room for its kind.
+ const boards = [];
for (const name of bundledBlueprints()) {
- const added = json(box, 'blueprint', 'add', name);
+ const kind = readBlueprint(name, process.cwd()).kind;
+ const single = ['product', 'architecture'].includes(kind);
+ let board = boards.find((entry) => !single || !entry.kinds.has(kind));
+ if (!board) boards.push(board = { box: freshBoard({ gate: 'true' }), kinds: new Set(), expected: [] });
+ if (single) board.kinds.add(kind);
+ const added = json(board.box, 'blueprint', 'add', name);
const items = readBlueprint(name, process.cwd()).items;
assert.equal(added.items.length, items.length, `${name} files every starter`);
assert.deepEqual(added.checksNotRun, added.items.map((item) => item.id), `${name}: every check is stored, none run`);
- expected.push(...items.map((item) => [item.title, item.criterion, item.check]));
+ board.expected.push(...items.map((item) => [item.title, item.criterion, item.check]));
+ }
+ for (const { box, expected } of boards) {
+ const filed = json(box, 'list', '--all').items.sort((a, b) => a.item_id - b.item_id);
+ assert.deepEqual(filed.map((item) => [item.item_title, item.item_criterion, item.item_check]), expected);
+ assert.ok(filed.every((item) => (item.item_check_baseline ?? null) === null), 'no check baseline ran');
}
- const filed = json(box, 'list', '--all').items.sort((a, b) => a.item_id - b.item_id);
- assert.deepEqual(filed.map((item) => [item.item_title, item.item_criterion, item.item_check]), expected);
- assert.ok(filed.every((item) => (item.item_check_baseline ?? null) === null), 'no check baseline ran');
// init --blueprint files them with both and prints that the checks are stored, not run.
const web = readBlueprint('web-app', process.cwd());
@@ -368,8 +376,9 @@ test('a drafted row records its rule source [S1,I1]', () => {
assert.match(empty.stdout, /source names where the row came from/u);
writeFileSync(join(box.repo, 'SPEC.md'), source);
- // A bundled architecture blueprint drafts its rows with the source it names.
- const serverless = json(box, 'blueprint', 'add', 'serverless');
+ // A bundled architecture blueprint drafts its rows with the source it names, on a board of its
+ // own, since this one already has an architecture blueprint (#720).
+ const serverless = json(freshBoard({ gate: 'true' }), 'blueprint', 'add', 'serverless');
for (const rule of readBlueprint('serverless', process.cwd()).rules) {
const drafted = serverless.rows.find((entry) => entry.key === rule.key);
assert.equal(drafted.source, `${rule.source.name} ${rule.source.id} ${rule.source.url}`, `serverless ${rule.key} keeps its source`);
@@ -757,7 +766,7 @@ test('a question with nothing to read has no default [S1,I1]', () => {
json(plain, 'blueprint', 'add', 'web-app');
assert.equal(pendingQuestion(plain.repo, 'The app is built with'), `The app is built with: (choose one). ${FRAMEWORKS}`, 'no known framework leaves the question unanswered');
// A blueprint without a default for a question it cannot detect is valid and files the same way.
- const own = { ...PUBLISHED, name: 'own', title: 'Own', prefix: 'OWN', items: [], questions: [{ key: 'Q1', ask: 'Its colour is', choices: ['Red', 'Blue'] }] };
+ const own = { ...PUBLISHED, name: 'own', title: 'Own', kind: 'practice', prefix: 'OWN', items: [], questions: [{ key: 'Q1', ask: 'Its colour is', choices: ['Red', 'Blue'] }] };
writeFileSync(join(plain.repo, 'own.json'), `${JSON.stringify(own)}\n`);
json(plain, 'blueprint', 'add', 'own.json');
assert.equal(pendingQuestion(plain.repo, 'Its colour is'), 'Its colour is: (choose one). Choices: Red, Blue.');