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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(help): retain arguments in derived command help [C7,N37,O3]
Corey Olson2c86e0fb26a1
diff --git a/src/help.js b/src/help.jsindex e56cac6e..c0489717 100644--- a/src/help.js+++ b/src/help.js@@ -243,6 +243,7 @@ const HELP_EXAMPLES = {relay: 'pullboard relay on --all', 'relay recover': 'pullboard relay recover --skip 12','lane add': 'pullboard lane add web --owns apps/web/', lane: 'pullboard lane add web --owns apps/web/',roadmap: 'pullboard roadmap', rigor: 'pullboard rigor', milestone: 'pullboard milestone add "0.7.0" --items 12,13',+ 'milestone items': 'pullboard milestone items "0.7.0" --add 12,13',runner: 'pullboard runner add studio --slots 2 --browser 1', 'runner add': 'pullboard runner add studio --slots 2 --browser 1',edit: 'pullboard edit 12 --brief "Add the upload page"', release: 'pullboard release 12',land: 'pullboard land --max 4',@@ -334,10 +335,12 @@ function commandHelpRows(fullHelp, commandNames) {...Object.keys(HELP_ALIASES),...phrases.flatMap((name) => [name.split(' ')[0], name]),])];+ const expandedRows = rows.flatMap((row) => usageVariants(row.usage)+ .map((usage) => ({ usage, details: [`pullboard ${usage}`, ...row.details.slice(1)] })));return Object.fromEntries(names.map((name) => {const parts = name.split(' ');const alias = HELP_ALIASES[name];- const matches = alias?.source ? rows.filter((row) => row.usage === alias.source || row.usage.startsWith(`${alias.source} `)) : alias ? [] : rows.filter((row) => {+ const matches = alias?.source ? rows.filter((row) => row.usage === alias.source || row.usage.startsWith(`${alias.source} `)) : alias ? [] : expandedRows.filter((row) => {const tokens = row.usage.split(/\s+/u);if (!parts.every((part, index) => tokens[index] === part)) return false;const next = tokens[parts.length];@@ -419,6 +422,23 @@ function expandWords(words) {return phrases.filter(Boolean);}+/** Expand printed sibling commands into complete usages, retaining each branch's arguments and flags. */+function usageVariants(usage) {+ const branches = usage.split(/\s+\|\s+/u);+ const shared = branches.length > 1 ? commandWords(branches[0]).slice(0, -1) : [];+ return branches.flatMap((branch, index) => {+ const command = [...(index ? shared : []), branch.replace(/^pullboard\s+/u, '')].join(' ');+ const words = commandWords(command);+ const tail = command.slice(words.join(' ').length);+ return expandWords(words).flatMap((prefix) => {+ const base = prefix + tail;+ const optional = /^(.*?)\[([^\]]+)\](.*)$/u.exec(base);+ if (!optional || !optional[2].includes('|') || optional[2].trim().startsWith('-')) return [base];+ return [base, ...optional[2].split('|').map((choice) => `${optional[1]}${choice}${optional[3]}`)];+ });+ });+}+/** Read one printed usage, including sibling commands and optional literal subcommands. */function usagePhrases(usage) {const row = usage.replace(/^pullboard\s+/u, '').split(/\s{2,}/u, 1)[0];diff --git a/test/cli-help.test.js b/test/cli-help.test.jsindex 6256dfe0..fc019e54 100644--- a/test/cli-help.test.js+++ b/test/cli-help.test.js@@ -170,6 +170,10 @@ test('help names come from the command declarations [C7,N37]', async (t) => {assert.deepEqual(generated.commands['future-command']?.usages, ['pullboard future-command']);assert.equal(generated.overview, HELP.overview, 'a new declaration preserves the overview bytes');assert.equal(generated.all, HELP.all, 'a new declaration preserves the full-help bytes');+ assert.deepEqual(generated.commands['relay join'].usages, ['pullboard relay join <code> [--url <address>]']);+ assert.deepEqual(generated.commands['spec approve'].usages, ['pullboard spec approve <ids>']);+ assert.deepEqual(generated.commands['spec decline'].usages, ['pullboard spec decline <ids> --reason "why"']);+ assert.match(generated.commands['spec fit edit'].usages[0], /^pullboard spec fit edit <row id or #item>/u);const original = readFileSync(join(directory, 'cli.js'), 'utf8');const declaration = /function readCommands\(io, \{ first, second, rest, values \}\) \{\s*return \{/u;diff --git a/test/help-examples.test.js b/test/help-examples.test.jsindex 4e9f621f..cf422c09 100644--- a/test/help-examples.test.js+++ b/test/help-examples.test.js@@ -4,7 +4,7 @@ import { join } from 'node:path';import { test } from 'node:test';import { createE2eHelpers } from './e2e-helpers.js';-/** Read flags that appear outside optional square-bracket groups in a usage line. */+/** Read required flag groups, keeping mutually exclusive alternatives together. */function requiredFlags(usage) {const flags = [];let optionalDepth = 0;@@ -12,19 +12,30 @@ function requiredFlags(usage) {if (usage[index] === '[') optionalDepth += 1;else if (usage[index] === ']') optionalDepth = Math.max(0, optionalDepth - 1);else if (optionalDepth === 0 && usage.startsWith('--', index)) {- const match = usage.slice(index).match(/^--[a-z][a-z-]*/u);- if (match) flags.push(match[0]);+ const match = usage.slice(index).match(/^--[a-z][a-z-]*(?:\|--[a-z][a-z-]*)*/u);+ if (match) {+ flags.push(match[0].split('|'));+ index += match[0].length - 1;+ }}}- return [...new Set(flags)];+ return flags;}+test('help example flag groups preserve alternatives and optional nesting [O3]', () => {+ assert.deepEqual(requiredFlags('pullboard command --first <id> --add|--remove ids [--optional]'),+ [['--first'], ['--add', '--remove']]);+ assert.deepEqual(requiredFlags('pullboard command [--one [--nested]] --required'), [['--required']]);+});+test('every help example carries its required flags [O3]', async () => {const { HELP } = await import('../src/help.js');for (const [name, declaration] of Object.entries(HELP.commands)) {const usage = declaration.usages[0];- for (const flag of requiredFlags(usage)) {- assert.ok(declaration.example.split(/\s+/u).includes(flag), `${name}: ${declaration.example} must include ${flag} from ${usage}`);+ for (const alternatives of requiredFlags(usage)) {+ const present = alternatives.filter((flag) => declaration.example.split(/\s+/u).includes(flag));+ assert.equal(present.length, 1,+ `${name}: ${declaration.example} must include exactly one of ${alternatives.join('|')} from ${usage}`);}}});