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): guide the first run in its ecosystem [I1,I2]

Corey Olsonca7280213425
diff --git a/src/cli.js b/src/cli.js
index 7e37c1cf..e3cebc92 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -780,10 +780,12 @@ function setupCommands(io, { first, values }) {
closeBoard: store.closeBoard,
});
io.result?.({ root: info.root, notes });
- notes.forEach((note) => io.say(note));
+ 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 (registerProject(info.root, new Date(), loadConfig(info.root))) io.say('registered this project on this machine, so pullboard view lists it');
io.say('next: write SPEC.md rows, declare lanes in pullboard.json, then: pullboard add <lane> <title>');
io.say('with an agent: start a new Claude Code session here, which loads the pullboard skills, then tell it what to build; the pullboard-run skill runs the team');
+ if (staging) io.say(staging);
return 0;
},
hooks: () => {
@@ -1794,6 +1796,7 @@ async function runCommand(argv, io) {
}
if (values.help || !command || command === 'help') {
io.result?.({ help: HELP });
+ if (!command && !values.help) io.say('New here? pullboard tour, then pullboard init.');
io.say(HELP);
return 0;
}
diff --git a/src/hooks.js b/src/hooks.js
index 9e73ebc8..593e3f35 100644
--- a/src/hooks.js
+++ b/src/hooks.js
@@ -352,9 +352,10 @@ export function hookScript(hook) {
* and reported, so init never clobbers a repo's own hooks (I2).
*
* @param {string} root
+ * @param {(path: string) => void} [onWrite] Observe only files this installer actually writes.
* @returns {string[]} What happened, one line per hook.
*/
-export function installHooks(root) {
+export function installHooks(root, onWrite = () => {}) {
const dir = join(root, HOOKS_DIR);
mkdirSync(dir, { recursive: true });
const notes = [];
@@ -372,6 +373,7 @@ export function installHooks(root) {
}
writeFileSync(file, hookScript(hook));
chmodSync(file, 0o755);
+ onWrite(`${HOOKS_DIR}/${hook}`);
notes.push(`wrote ${HOOKS_DIR}/${hook}`);
}
const current = tryGit(root, ['config', '--get', 'core.hooksPath']).stdout;
diff --git a/src/init.js b/src/init.js
index 9f08fc56..890a4348 100644
--- a/src/init.js
+++ b/src/init.js
@@ -16,20 +16,26 @@ import { AGENTS_END, AGENTS_START, agentsBlock, configTemplate, practiceTemplate
const NPM_DEFAULT_TEST = 'echo "Error: no test specified" && exit 1';
/**
- * The gate to start with: `npm test` when the repo has a real test script, otherwise none yet.
+ * Detect an existing ecosystem's test command without running it during setup (I1, I2).
*
* @param {string} root
* @returns {string}
*/
export function detectGate(root) {
const file = join(root, 'package.json');
- if (!existsSync(file)) return '';
- try {
- const test = JSON.parse(readFileSync(file, 'utf8'))?.scripts?.test;
- return typeof test === 'string' && test.trim() && test !== NPM_DEFAULT_TEST ? 'npm test' : '';
- } catch {
- return '';
+ if (existsSync(file)) {
+ try {
+ const test = JSON.parse(readFileSync(file, 'utf8'))?.scripts?.test;
+ if (typeof test === 'string' && test.trim() && test.trim() !== NPM_DEFAULT_TEST) return 'npm test';
+ } catch { /* An unreadable package does not hide another ecosystem. */ }
+ }
+ if (existsSync(join(root, 'go.mod'))) return 'go test ./...';
+ if (existsSync(join(root, 'Cargo.toml'))) return 'cargo test';
+ if (['pytest.ini', '.pytest.ini', 'pytest.toml', '.pytest.toml', 'pyproject.toml', 'setup.py', 'requirements.txt'].some((name) => existsSync(join(root, name)))) return 'pytest';
+ for (const [name, section] of [['tox.ini', 'pytest'], ['setup.cfg', 'tool:pytest']]) {
+ if (existsSync(join(root, name)) && readFileSync(join(root, name), 'utf8').includes(`[${section}]`)) return 'pytest';
}
+ return '';
}
/**
@@ -71,11 +77,13 @@ function configuredGate(root) {
* @param {string} file
* @param {string} text
* @param {string} name
+ * @param {(path: string) => void} onWrite
* @returns {string} What happened.
*/
-function writeNew(file, text, name) {
+function writeNew(file, text, name, onWrite) {
if (existsSync(file)) return `kept ${name}`;
writeFileSync(file, text);
+ onWrite(name);
return `wrote ${name}`;
}
@@ -84,17 +92,20 @@ function writeNew(file, text, name) {
* has, and point CLAUDE.md at AGENTS.md so Claude Code reads the same rules.
*
* @param {string} root
+ * @param {(path: string) => void} onWrite
* @returns {string[]}
*/
-function writeAgentDocs(root) {
+function writeAgentDocs(root, onWrite) {
const notes = [];
const agents = join(root, 'AGENTS.md');
const block = agentsBlock(loadDoctrine(root, loadConfig(root)));
if (!existsSync(agents)) {
writeFileSync(agents, `# AGENTS.md\n\n${block}`);
+ onWrite('AGENTS.md');
notes.push('wrote AGENTS.md');
} else if (!readFileSync(agents, 'utf8').includes(AGENTS_START)) {
appendFileSync(agents, `\n${block}`);
+ onWrite('AGENTS.md');
notes.push('added the pullboard section to AGENTS.md');
} else {
const previous = readFileSync(agents, 'utf8');
@@ -106,6 +117,7 @@ function writeAgentDocs(root) {
if (updated === previous) notes.push('kept AGENTS.md');
else {
writeFileSync(agents, updated);
+ onWrite('AGENTS.md');
notes.push('updated the pullboard section in AGENTS.md');
}
}
@@ -113,9 +125,11 @@ function writeAgentDocs(root) {
const claude = join(root, 'CLAUDE.md');
if (!existsSync(claude)) {
writeFileSync(claude, '@AGENTS.md\n');
+ onWrite('CLAUDE.md');
notes.push('wrote CLAUDE.md (points at AGENTS.md)');
} else if (!readFileSync(claude, 'utf8').includes('AGENTS.md')) {
appendFileSync(claude, '\[email protected]\n');
+ onWrite('CLAUDE.md');
notes.push('pointed CLAUDE.md at AGENTS.md');
}
return notes;
@@ -134,9 +148,10 @@ export const RESUME_HOOK =
* into .claude/settings.json; every other setting stays as it was.
*
* @param {string} root
+ * @param {(path: string) => void} onWrite
* @returns {string} What happened.
*/
-function writeSessionHook(root) {
+function writeSessionHook(root, onWrite) {
const file = join(root, '.claude', 'settings.json');
let settings = {};
if (existsSync(file)) {
@@ -154,6 +169,7 @@ function writeSessionHook(root) {
settings.hooks = { ...settings.hooks, SessionStart: [...starts, { hooks: [{ type: 'command', command: RESUME_HOOK, timeout: 30 }] }] };
mkdirSync(join(root, '.claude'), { recursive: true });
writeFileSync(file, `${JSON.stringify(settings, null, 2)}\n`);
+ onWrite('.claude/settings.json');
return 'added a Claude Code session hook: pullboard resume at every start and compaction';
}
@@ -169,14 +185,17 @@ export function initRepo({ info, openBoardHere, register, closeBoard }) {
}
const { root } = info;
const gate = detectGate(root);
+ const written = [];
+ /** Record only paths setup actually writes; unrelated files never enter its staging command. */
+ const onWrite = (path) => written.push(path);
const notes = [
- writeNew(join(root, CONFIG_FILE), configTemplate(gate, detectFixers(root)), CONFIG_FILE),
- writeNew(join(root, 'SPEC.md'), specTemplate(basename(root)), 'SPEC.md'),
- writeNew(join(root, 'PRACTICE.md'), practiceTemplate(), 'PRACTICE.md'),
- ...writeAgentDocs(root),
- ...installHooks(root),
- ...installSkills(root),
- writeSessionHook(root),
+ writeNew(join(root, CONFIG_FILE), configTemplate(gate, detectFixers(root)), CONFIG_FILE, onWrite),
+ writeNew(join(root, 'SPEC.md'), specTemplate(basename(root), gate), 'SPEC.md', onWrite),
+ writeNew(join(root, 'PRACTICE.md'), practiceTemplate(), 'PRACTICE.md', onWrite),
+ ...writeAgentDocs(root, onWrite),
+ ...installHooks(root, onWrite),
+ ...installSkills(root, onWrite),
+ writeSessionHook(root, onWrite),
];
const board = openBoardHere();
try {
@@ -188,5 +207,6 @@ export function initRepo({ info, openBoardHere, register, closeBoard }) {
if (!configuredGate(root)) {
notes.push('no gate yet: set "gate" in pullboard.json to the command that proves the build');
}
+ if (written.length) notes.push(`git add -f -- ${written.map((path) => `'${path.replaceAll("'", "'\\''")}'`).join(' ')}`);
return notes;
}
diff --git a/src/skills.js b/src/skills.js
index f98e24fb..f31d7b4a 100644
--- a/src/skills.js
+++ b/src/skills.js
@@ -65,15 +65,17 @@ export function promptFor(root, role) {
* that is already there (I2).
*
* @param {string} root
+ * @param {(path: string) => void} [onWrite] Observe only newly written skill files.
* @returns {string[]} What happened.
*/
-export function installSkills(root) {
+export function installSkills(root, onWrite = () => {}) {
const written = [];
for (const [role, name] of Object.entries(ROLES)) {
const file = join(root, '.claude', 'skills', name, 'SKILL.md');
if (existsSync(file)) continue;
mkdirSync(join(root, '.claude', 'skills', name), { recursive: true });
writeFileSync(file, shippedSkill(role));
+ onWrite(`.claude/skills/${name}/SKILL.md`);
written.push(name);
}
return written.length
diff --git a/src/templates.js b/src/templates.js
index db4405a2..387ac9e6 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -33,9 +33,10 @@ export function configTemplate(gate, fix = []) {
* A starter SPEC.md with the row format shown by example.
*
* @param {string} project
+ * @param {string} [gate] Use the detected ecosystem's check in the fenced example.
* @returns {string}
*/
-export function specTemplate(project) {
+export function specTemplate(project, gate = 'the test that proves it') {
return `# ${project} spec
Every requirement is a row with an id. Agents build against approved rows; commits cite the ids they serve. \`pullboard spec check\` lints this file.
@@ -45,7 +46,7 @@ Statuses: approved = decided · draft = proposed · pending = open question · f
Write each requirement as one row under its section, in this format. The fence keeps the example out of the spec, so no placeholder id is ever committed; your own rows go below, outside it.
\`\`\`text
-- G1 [draft, must] The first thing the client needs, in one line. | gate: the test that proves it
+- G1 [draft, must] The first thing the client needs, in one line. | gate: ${gate || 'the test that proves it'}
- K1 [draft, must] A constraint, e.g. runs locally with no account. | gate: review
\`\`\`
diff --git a/test/newcomer.test.js b/test/newcomer.test.js
new file mode 100644
index 00000000..2e3e0522
--- /dev/null
+++ b/test/newcomer.test.js
@@ -0,0 +1,97 @@
+/** First-run guidance on private Git repos, including unrelated files setup must not stage [I1,I2]. */
+import assert from 'node:assert/strict';
+import { execFileSync, spawnSync } from 'node:child_process';
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { test } from 'node:test';
+
+const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
+
+/** Run setup in an isolated repository, without invoking any installed test tools. */
+function project(t) {
+ const root = mkdtempSync(join(tmpdir(), 'pullboard-newcomer-'));
+ t.after(() => rmSync(root, { recursive: true, force: true }));
+ const env = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(root, '.private-home') };
+ /** Read a private Git command's result without inheriting the maintainer's configuration. */
+ const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();
+ /** Preserve CLI output so guidance is checked exactly as a newcomer receives it. */
+ const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });
+ git('init', '-q', '-b', 'main');
+ return { root, env, git, run };
+}
+
+test('init ends with a working staging line for exactly its own writes [I1,I2]', (t) => {
+ const box = project(t);
+ writeFileSync(join(box.root, '.env.local'), 'LOCAL=1\n');
+ writeFileSync(join(box.root, 'notes.txt'), 'keep this out of the initial commit\n');
+ writeFileSync(join(box.root, '.gitignore'), '.claude/\n');
+ mkdirSync(join(box.root, '.githooks'));
+ writeFileSync(join(box.root, '.githooks', 'pre-commit'), '#!/bin/sh\n# My hook\n');
+ mkdirSync(join(box.root, '.claude', 'skills', 'pullboard-run'), { recursive: true });
+ writeFileSync(join(box.root, '.claude', 'skills', 'pullboard-run', 'SKILL.md'), '# My existing guide\n');
+ writeFileSync(join(box.root, 'CLAUDE.md'), '@AGENTS.md\n');
+ writeFileSync(join(box.root, 'AGENTS.md'), '# My instructions\n');
+ const result = box.run('init');
+ assert.equal(result.status, 0, result.stderr);
+ const command = result.stdout.trimEnd().split('\n').at(-1);
+ assert.match(command, /^git add -f -- /);
+ const staged = spawnSync('sh', ['-c', command], { cwd: box.root, env: box.env, encoding: 'utf8' });
+ assert.equal(staged.status, 0, staged.stderr);
+ assert.deepEqual(box.git('diff', '--cached', '--name-only').split('\n'), [
+ '.claude/settings.json',
+ '.claude/skills/pullboard-decompose/SKILL.md',
+ '.claude/skills/pullboard-plan/SKILL.md',
+ '.claude/skills/pullboard-signoff/SKILL.md',
+ '.claude/skills/pullboard-spec-review/SKILL.md',
+ '.claude/skills/pullboard-verify/SKILL.md',
+ '.githooks/commit-msg', '.githooks/pre-push',
+ 'AGENTS.md', 'PRACTICE.md', 'SPEC.md', 'pullboard.json',
+ ]);
+ assert.equal(readFileSync(join(box.root, '.env.local'), 'utf8'), 'LOCAL=1\n');
+ assert.equal(readFileSync(join(box.root, '.githooks', 'pre-commit'), 'utf8'), '#!/bin/sh\n# My hook\n');
+ box.git('reset', '-q');
+ const rerun = box.run('init');
+ assert.equal(rerun.status, 0, rerun.stderr);
+ const secondStage = rerun.stdout.trimEnd().split('\n').at(-1);
+ assert.match(secondStage, /^git add -f -- /);
+ assert.equal(spawnSync('sh', ['-c', secondStage], { cwd: box.root, env: box.env }).status, 0);
+ assert.deepEqual(box.git('diff', '--cached', '--name-only').split('\n'), ['.githooks/commit-msg', '.githooks/pre-push']);
+});
+
+test('init detects language gates and gives an example in the same ecosystem [I1,I2]', (t) => {
+ const cases = [
+ ['pyproject.toml', '[project]\nname = "example"\n', 'pytest'],
+ ['pytest.ini', '', 'pytest'],
+ ['setup.cfg', '[tool:pytest]\n', 'pytest'],
+ ['go.mod', 'module example.test/project\n', 'go test ./...'],
+ ['Cargo.toml', '[package]\nname = "example"\nversion = "0.1.0"\n', 'cargo test'],
+ ['package.json', JSON.stringify({ scripts: { test: 'node --test' } }), 'npm test'],
+ ];
+ for (const [file, text, gate] of cases) {
+ const box = project(t);
+ writeFileSync(join(box.root, file), text);
+ const result = box.run('init');
+ assert.equal(result.status, 0, `${file}: ${result.stderr}`);
+ assert.equal(JSON.parse(readFileSync(join(box.root, 'pullboard.json'), 'utf8')).gate, gate, file);
+ assert.ok(readFileSync(join(box.root, 'SPEC.md'), 'utf8').includes(`| gate: ${gate}\n`), file);
+ assert.doesNotMatch(result.stdout, /no gate yet/);
+ }
+ const mixed = project(t);
+ writeFileSync(join(mixed.root, 'package.json'), JSON.stringify({ scripts: { test: 'echo "Error: no test specified" && exit 1' } }));
+ writeFileSync(join(mixed.root, 'go.mod'), 'module example.test/project\n');
+ assert.equal(mixed.run('init').status, 0);
+ assert.equal(JSON.parse(readFileSync(join(mixed.root, 'pullboard.json'), 'utf8')).gate, 'go test ./...');
+});
+
+test('bare pullboard starts with the tour and init pointer; explicit help and JSON stay usable [I1,I2]', (t) => {
+ const box = project(t);
+ const bare = box.run();
+ assert.equal(bare.status, 0, bare.stderr);
+ assert.equal(bare.stdout.split('\n')[0], 'New here? pullboard tour, then pullboard init.');
+ assert.ok(bare.stdout.includes('pullboard next'));
+ assert.ok(!box.run('help').stdout.startsWith('New here?'));
+ const document = JSON.parse(box.run('--json').stdout);
+ assert.equal(typeof document.help, 'string');
+ assert.ok(document.help.includes('pullboard init'));
+});