@descent-vtt/spec-harness 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjF,OAAO,EACL,eAAe,EACf,UAAU,EACV,SAAS,EACT,gBAAgB,GAKjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,EAA4C,MAAM,gBAAgB,CAAC;AAElH,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAE9B,MAAM,CAAC,MAAM,YAAY,GACvB,yEAAyE;IACzE,iKAAiK;IACjK,mJAAmJ;IACnJ,sGAAsG;IACtG,kGAAkG,CAAC;AAErG,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qEAAqE,EAAE,CAAC;AAC7H,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,6HAA6H;CAC3I,CAAC;AAEF,2EAA2E;AAC3E,SAAS,MAAM,CAAC,IAAgB;I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C,GAAG,CAAC,oBAAoB,CAAC,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7H,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9J,yEAAyE;IACzE,+DAA+D;IAC/D,uEAAuE;IACvE,yEAAyE;IACzE,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACxE,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * `spec-harness mcp`: the round's questions, served over the Model Context\n * Protocol on stdio (ADR-0008). The protocol is spec-core's `jsonrpc` module;\n * this file is the five tools, the four prompts, and nothing else. Every\n * request reads the repository afresh: a brief edited a minute ago is the\n * brief the next answer uses.\n */\n\nimport { readFileSync } from 'node:fs';\nimport { Readable } from 'node:stream';\nimport { fileURLToPath } from 'node:url';\n\nimport { describeMeasured } from './audit.js';\nimport { findActive } from './briefs.js';\nimport { briefIdFromBranch } from './branch.js';\nimport { titleOf } from './context.js';\nimport { createReader } from './reader.js';\nimport { buildContext, checkPaths, raiseEscalation, runAudit } from './round.js';\nimport type { BriefRow } from './types.js';\nimport {\n createMcpServer,\n serveLines,\n toolError,\n unknownArguments,\n type JsonObject,\n type PromptDefinition,\n type ToolDefinition,\n type ToolOutcome,\n} from './vendor/spec-core/jsonrpc/index.js';\nimport { describeActive, openWorkspace, version, type CliIO, type Options, type Workspace } from './workspace.js';\n\nconst reader = createReader();\n\nexport const INSTRUCTIONS =\n 'spec-harness keeps a round of work inside the brief a person approved. ' +\n 'Call start_round before working: it returns the brief, the scope you may write, what you must not touch, the rules in force and the documents the brief cites. ' +\n 'Call check_path before writing a file you are unsure of. A protected file needs a ruling: call request_escalation and stop until a person rules. ' +\n 'Call audit_round when the work is done, and fix what it reports; archiving is a person\\'s decision. ' +\n 'For the architecture rules themselves, spec-guard\\'s own server answers get_architectural_rules.';\n\nconst briefProperty = { type: 'string', description: 'The brief id. Omit to use the brief the branch or SPEC_BRIEF names.' };\nconst baseProperty = {\n type: 'string',\n description: 'The branch the round is measured from, whose allowed signers a ruling is verified against. Omit to use the configured base.',\n};\n\n/** The `base` argument, or the tool error for one that is not a string. */\nfunction baseOf(args: JsonObject): { base: string | undefined } | ToolOutcome {\n const base = args['base'];\n if (base !== undefined && typeof base !== 'string') return toolError('\"base\" must be a string.');\n return { base };\n}\n\nasync function round(workspace: Workspace, env: CliIO['env'], id: unknown): Promise<{ brief: BriefRow; briefs: BriefRow[] } | ToolOutcome> {\n if (id !== undefined && typeof id !== 'string') return toolError('\"brief\" must be a string.');\n const briefs = await workspace.siblings.briefs();\n const fromBranch = briefIdFromBranch(workspace.config.branches, workspace.branch);\n const active = findActive(briefs, { flag: id, environment: env['SPEC_BRIEF'], branch: fromBranch });\n const { brief, note, problem } = describeActive(active);\n if (problem !== null) return toolError(problem);\n if (brief === null) return toolError(note);\n return { brief, briefs };\n}\n\nexport function tools(workspace: Workspace, env: CliIO['env']): ToolDefinition[] {\n const readOnly = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };\n return [\n {\n descriptor: {\n name: 'start_round',\n title: 'Start a round',\n description:\n 'Everything needed to start the round: the brief in full, the files it may write and must not change, signed rulings, the briefs it depends on, the architecture rules in force for its scope, and the documents it cites.',\n inputSchema: { type: 'object', properties: { brief: briefProperty, base: baseProperty }, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['brief', 'base']);\n if (unknown) return unknown;\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const packet = await buildContext(workspace, found.brief, found.briefs, reader, base.base);\n return {\n text: packet.markdown,\n structured: {\n brief: found.brief.id,\n included: [...packet.included],\n omitted: [...packet.omitted],\n unresolved: [...packet.unresolved],\n unclosedFrontMatter: [...packet.unclosedFrontMatter],\n unreadableFrontMatter: [...packet.unreadableFrontMatter],\n unreadableScope: [...packet.unreadableScope],\n unreadableProtections: [...packet.unreadableProtections],\n unreadableRulingPaths: [...packet.unreadableRulingPaths],\n },\n };\n },\n },\n {\n descriptor: {\n name: 'check_path',\n title: 'May the round write these files',\n description:\n 'For each path: allowed (in scope, or covered by a signed ruling), outside the scope, or refused (protected by the brief). Works for files that do not exist yet.',\n inputSchema: {\n type: 'object',\n properties: {\n paths: { type: 'array', items: { type: 'string' }, description: 'Paths relative to the project root, or absolute inside it.' },\n brief: briefProperty,\n base: baseProperty,\n },\n required: ['paths'],\n additionalProperties: false,\n },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['paths', 'brief', 'base']);\n if (unknown) return unknown;\n const paths = args['paths'];\n if (!Array.isArray(paths) || !paths.every((p) => typeof p === 'string') || paths.length === 0) {\n return toolError('\"paths\" must be a non-empty array of strings.');\n }\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const decisions = await checkPaths(workspace, found.brief, undefined, paths as string[], workspace.root, reader, base.base);\n const text = decisions.map((d) => `${d.verdict}: ${d.message}${d.verdict === 'allow' ? '' : `. Next: ${d.hint}`}`).join('\\n');\n return { text, structured: { decisions: decisions.map((d) => ({ ...d })) } };\n },\n },\n {\n descriptor: {\n name: 'request_escalation',\n title: 'Ask a person to rule',\n description:\n 'When the round cannot be finished without changing something the brief protects, record the request and stop. A person reads the memo and rules; only a ruling they sign lets the change through.',\n inputSchema: {\n type: 'object',\n properties: {\n paths: { type: 'array', items: { type: 'string' }, description: 'The protected files the round needs to change.' },\n reason: { type: 'string', description: 'Why the round cannot be done without them.' },\n options: {\n type: 'array',\n items: { type: 'object', properties: { label: { type: 'string' }, consequence: { type: 'string' } }, required: ['label', 'consequence'] },\n description: 'The choices the person has, each with what it costs.',\n },\n recommendation: { type: 'string', description: 'Which option you recommend, and why.' },\n brief: briefProperty,\n },\n required: ['paths', 'reason'],\n additionalProperties: false,\n },\n annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: false },\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['paths', 'reason', 'options', 'recommendation', 'brief']);\n if (unknown) return unknown;\n const paths = args['paths'];\n const reason = args['reason'];\n if (!Array.isArray(paths) || !paths.every((p) => typeof p === 'string') || paths.length === 0) return toolError('\"paths\" must be a non-empty array of strings.');\n if (typeof reason !== 'string' || reason.trim() === '') return toolError('\"reason\" is required.');\n const rawOptions = args['options'] ?? [];\n if (!Array.isArray(rawOptions)) return toolError('\"options\" must be an array.');\n const options = rawOptions.map((o) => ({ label: String((o as JsonObject)['label'] ?? ''), consequence: String((o as JsonObject)['consequence'] ?? '') }));\n const recommendation = args['recommendation'];\n if (recommendation !== undefined && typeof recommendation !== 'string') return toolError('\"recommendation\" must be a string.');\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const { request, memo } = await raiseEscalation(workspace, found.brief, { paths: paths as string[], reason, options, recommendation: recommendation ?? null });\n return { text: `${memo}\\nStop here until a person rules on ${request.id}.`, structured: { id: request.id } };\n },\n },\n {\n descriptor: {\n name: 'audit_round',\n title: 'Audit the round',\n description:\n 'Did the round stay inside the lines: what the archive would refuse (open boxes, protected files, files outside the scope), the brief\\'s own assertions, unverified rulings, every dependency added and every package allowed to run install scripts.',\n inputSchema: { type: 'object', properties: { brief: briefProperty, base: baseProperty }, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['brief', 'base']);\n if (unknown) return unknown;\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const result = await runAudit(workspace, found.brief, reader, base.base);\n const { counts, findings, measured } = result.report;\n // What was measured beside what was found: \"nothing found\" from an\n // audit that ran no goal is not a round that is done.\n const text =\n findings.length === 0\n ? 'The audit found nothing in what it measured.'\n : findings.map((f) => `${f.severity} ${f.rule}: ${f.message}. Next: ${f.hint}`).join('\\n');\n return {\n text: `${text}\\n\\n${describeMeasured(measured)}\\n\\n${counts.error} error(s), ${counts.warning} warning(s), ${counts.note} note(s)`,\n structured: { counts, measured: { ...measured }, findings: findings.map((f) => ({ ...f })) },\n };\n },\n },\n {\n descriptor: {\n name: 'list_rounds',\n title: 'List the rounds',\n description: 'The live briefs: status, wave, what each waits on, and which are ready to start.',\n inputSchema: { type: 'object', properties: {}, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, []);\n if (unknown) return unknown;\n const live = (await workspace.siblings.briefs()).filter((brief) => brief.phase === 'live');\n const text = live\n .map((b) => `${[b.id, titleOf(b)].filter((part) => part !== null).join(' ')} - ${b.status ?? 'unknown'}, wave ${b.wave ?? '-'}, ${b.ready ? 'ready' : `waits on ${b.waitingOn.join(', ')}`}`)\n .join('\\n');\n return { text: text === '' ? 'No live brief.' : text, structured: { briefs: live.map((b) => ({ ...b, title: titleOf(b) })) } };\n },\n },\n ];\n}\n\nconst SKILLS: readonly { name: string; title: string; argument: string; description: string }[] = [\n { name: 'draft-brief', title: 'Draft a brief', argument: 'request', description: 'What the round should achieve, in the person\\'s words.' },\n { name: 'split-goal', title: 'Split a goal into rounds', argument: 'goal', description: 'The goal to split.' },\n { name: 'run-round', title: 'Run a round', argument: 'brief', description: 'The brief id.' },\n { name: 'close-round', title: 'Close a round', argument: 'brief', description: 'The brief id.' },\n];\n\nfunction skillText(name: string): string {\n // The package ships the skills beside dist/ (package.json's files), so one\n // that cannot be read is a broken install, and the request fails saying so\n // rather than serving an empty prompt.\n const text = readFileSync(fileURLToPath(new URL(`../skills/${name}/SKILL.md`, import.meta.url)), 'utf8');\n // Every skill opens with its front matter (tests/source.test.ts), so the\n // anchor is equivalent to its mutant here.\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n/, '').trim();\n}\n\nexport function prompts(): PromptDefinition[] {\n return SKILLS.map((skill) => ({\n descriptor: {\n name: skill.name,\n title: skill.title,\n arguments: [{ name: skill.argument, description: skill.description, required: false }],\n },\n async get(args: Readonly<Record<string, string>>): Promise<JsonObject> {\n const given = args[skill.argument];\n const text = `${skillText(skill.name)}${given === undefined || given === '' ? '' : `\\n\\n${skill.argument}: ${given}`}`;\n return { description: skill.title, messages: [{ role: 'user', content: { type: 'text', text } }] };\n },\n }));\n}\n\nexport async function mcpCommand(options: Options, io: CliIO): Promise<number> {\n // Claude Code starts a plugin's server in the plugin's directory, and names\n // the project in CLAUDE_PROJECT_DIR; the server answers for the project.\n const workspace = await openWorkspace({ ...options, root: options.root ?? (io.env['CLAUDE_PROJECT_DIR'] || undefined) }, io);\n const handle = createMcpServer({ name: 'spec-harness', version: version(), instructions: INSTRUCTIONS, tools: tools(workspace, io.env), prompts: prompts() });\n // A session handed over whole, as a test hands it, is served as a client\n // would stream it on stdin. Only the built command line serves\n // process.stdin, and the suite spawns it from dist/, outside the sweep\n // (tests/integration/mcp.test.ts), so a mutant that ignores it survives.\n const input = io.stdin === undefined ? process.stdin : Readable.from([Buffer.from(await io.stdin())]);\n await serveLines(input, (line) => io.stdout.write(`${line}\\n`), handle);\n return 0;\n}\n"]}
1
+ {"version":3,"file":"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AE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;QACrG,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAgB,EAAE,EAAS;IAC1D,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7H,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9J,yEAAyE;IACzE,+DAA+D;IAC/D,uEAAuE;IACvE,yEAAyE;IACzE,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACxE,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * `spec-harness mcp`: the round's questions, served over the Model Context\n * Protocol on stdio (ADR-0008). The protocol is spec-core's `jsonrpc` module;\n * this file is the five tools, the four prompts, and nothing else. Every\n * request reads the repository afresh: a brief edited a minute ago is the\n * brief the next answer uses.\n */\n\nimport { readFileSync } from 'node:fs';\nimport { Readable } from 'node:stream';\nimport { fileURLToPath } from 'node:url';\n\nimport { describeMeasured } from './audit.js';\nimport { findActive } from './briefs.js';\nimport { briefIdFromBranch } from './branch.js';\nimport { titleOf } from './context.js';\nimport { createReader } from './reader.js';\nimport { buildContext, checkPaths, raiseEscalation, runAudit } from './round.js';\nimport type { EscalationOption } from './rulings.js';\nimport type { BriefRow } from './types.js';\nimport { emptyValue, isBlank, type ValuedOption } from './usage.js';\nimport {\n createMcpServer,\n serveLines,\n toolError,\n unknownArguments,\n type JsonObject,\n type PromptDefinition,\n type ToolDefinition,\n type ToolOutcome,\n} from './vendor/spec-core/jsonrpc/index.js';\nimport { describeActive, openWorkspace, version, type CliIO, type Options, type Workspace } from './workspace.js';\n\nconst reader = createReader();\n\nexport const INSTRUCTIONS =\n 'spec-harness keeps a round of work inside the brief a person approved. ' +\n 'Call start_round before working: it returns the brief, the scope you may write, what you must not touch, the rules in force and the documents the brief cites. ' +\n 'Call check_path before writing a file you are unsure of. A protected file needs a ruling: call request_escalation and stop until a person rules. ' +\n 'Call audit_round when the work is done, and fix what it reports; archiving is a person\\'s decision. ' +\n 'For the architecture rules themselves, spec-guard\\'s own server answers get_architectural_rules.';\n\nconst briefProperty = { type: 'string', description: 'The brief id. Omit to use the brief the branch or SPEC_BRIEF names; an empty id is refused.' };\nconst baseProperty = {\n type: 'string',\n description:\n 'The branch the round is measured from, whose allowed signers a ruling is verified against. Omit to use the configured base; an empty one is refused.',\n};\n\n/**\n * The tool error for an argument that is given and names nothing, in the\n * words the command line has for its option. Read as left out, an empty\n * `brief` was answered for the branch's brief and an empty `base` with no\n * ruling verified, and nothing told the agent that neither was the answer to\n * what it had asked.\n */\nfunction namesNothing(argument: string, option: ValuedOption, value: string): ToolOutcome {\n return toolError(`${emptyValue(`\"${argument}\"`, option, value)}.`);\n}\n\n/** The `base` argument, or the tool error for one that is not a string, or names no commit. */\nfunction baseOf(args: JsonObject): { base: string | undefined } | ToolOutcome {\n const base = args['base'];\n if (base !== undefined && typeof base !== 'string') return toolError('\"base\" must be a string.');\n if (base !== undefined && isBlank(base)) return namesNothing('base', 'base', base);\n return { base };\n}\n\n/** The `paths` argument, or the tool error for one that is no list of files, or has a place that names none. */\nfunction pathsOf(args: JsonObject): { paths: string[] } | ToolOutcome {\n const paths = args['paths'];\n if (!Array.isArray(paths) || !paths.every((p) => typeof p === 'string') || paths.length === 0) {\n return toolError('\"paths\" must be a non-empty array of strings.');\n }\n const empty = paths.findIndex(isBlank);\n if (empty !== -1) return namesNothing(`paths[${empty}]`, 'path', paths[empty] as string);\n return { paths };\n}\n\n/**\n * The `options` argument as the memo's choices, or the tool error for one\n * the memo cannot be written with: a choice is its label, and one without\n * was written as a number and two empty stars. What a choice costs may be\n * left out, and the memo then gives the choice alone.\n */\nfunction optionsOf(args: JsonObject): { options: EscalationOption[] } | ToolOutcome {\n const raw = args['options'] ?? [];\n if (!Array.isArray(raw)) return toolError('\"options\" must be an array.');\n const options: EscalationOption[] = [];\n for (const [index, item] of raw.entries()) {\n // An item that is no object has no label, and is refused for that.\n const entry = (item ?? {}) as JsonObject;\n const label = entry['label'];\n const consequence = entry['consequence'] ?? '';\n if (typeof label !== 'string') return toolError(`\"options[${index}].label\" must be a string.`);\n if (isBlank(label)) return toolError(`\"options[${index}].label\" is ${JSON.stringify(label)}, which names no choice; give the option a label, or leave the option out.`);\n if (typeof consequence !== 'string') return toolError(`\"options[${index}].consequence\" must be a string.`);\n options.push({ label: label.trim(), consequence: consequence.trim() });\n }\n return { options };\n}\n\nasync function round(workspace: Workspace, env: CliIO['env'], id: unknown): Promise<{ brief: BriefRow; briefs: BriefRow[] } | ToolOutcome> {\n if (id !== undefined && typeof id !== 'string') return toolError('\"brief\" must be a string.');\n if (id !== undefined && isBlank(id)) return namesNothing('brief', 'brief', id);\n const briefs = await workspace.siblings.briefs();\n const fromBranch = briefIdFromBranch(workspace.config.branches, workspace.branch);\n const active = findActive(briefs, { flag: id, environment: env['SPEC_BRIEF'], branch: fromBranch });\n const { brief, note, problem } = describeActive(active);\n if (problem !== null) return toolError(problem);\n if (brief === null) return toolError(note);\n return { brief, briefs };\n}\n\nexport function tools(workspace: Workspace, env: CliIO['env']): ToolDefinition[] {\n const readOnly = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };\n return [\n {\n descriptor: {\n name: 'start_round',\n title: 'Start a round',\n description:\n 'Everything needed to start the round: the brief in full, the files it may write and must not change, signed rulings, the briefs it depends on, the architecture rules in force for its scope, and the documents it cites.',\n inputSchema: { type: 'object', properties: { brief: briefProperty, base: baseProperty }, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['brief', 'base']);\n if (unknown) return unknown;\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const packet = await buildContext(workspace, found.brief, found.briefs, reader, base.base);\n return {\n text: packet.markdown,\n structured: {\n brief: found.brief.id,\n included: [...packet.included],\n omitted: [...packet.omitted],\n unresolved: [...packet.unresolved],\n unclosedFrontMatter: [...packet.unclosedFrontMatter],\n unreadableFrontMatter: [...packet.unreadableFrontMatter],\n unreadableScope: [...packet.unreadableScope],\n unreadableProtections: [...packet.unreadableProtections],\n unreadableRulingPaths: [...packet.unreadableRulingPaths],\n },\n };\n },\n },\n {\n descriptor: {\n name: 'check_path',\n title: 'May the round write these files',\n description:\n 'For each path: allowed (in scope, or covered by a signed ruling), outside the scope, or refused (protected by the brief). Works for files that do not exist yet.',\n inputSchema: {\n type: 'object',\n properties: {\n paths: { type: 'array', items: { type: 'string' }, description: 'Paths relative to the project root, or absolute inside it. An empty one is refused.' },\n brief: briefProperty,\n base: baseProperty,\n },\n required: ['paths'],\n additionalProperties: false,\n },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['paths', 'brief', 'base']);\n if (unknown) return unknown;\n const given = pathsOf(args);\n if ('text' in given) return given;\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const decisions = await checkPaths(workspace, found.brief, undefined, given.paths, workspace.root, reader, base.base);\n const text = decisions.map((d) => `${d.verdict}: ${d.message}${d.verdict === 'allow' ? '' : `. Next: ${d.hint}`}`).join('\\n');\n return { text, structured: { decisions: decisions.map((d) => ({ ...d })) } };\n },\n },\n {\n descriptor: {\n name: 'request_escalation',\n title: 'Ask a person to rule',\n description:\n 'When the round cannot be finished without changing something the brief protects, record the request and stop. A person reads the memo and rules; only a ruling they sign lets the change through.',\n inputSchema: {\n type: 'object',\n properties: {\n paths: { type: 'array', items: { type: 'string' }, description: 'The protected files the round needs to change. An empty one is refused.' },\n reason: { type: 'string', description: 'Why the round cannot be done without them. It is required, and may not be empty.' },\n options: {\n type: 'array',\n items: { type: 'object', properties: { label: { type: 'string' }, consequence: { type: 'string' } }, required: ['label', 'consequence'] },\n description: 'The choices the person has, each with what it costs. A choice whose label is empty is refused.',\n },\n recommendation: { type: 'string', description: 'Which option you recommend, and why. Omit it when there is none: an empty one is refused.' },\n brief: briefProperty,\n },\n required: ['paths', 'reason'],\n additionalProperties: false,\n },\n annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: false },\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['paths', 'reason', 'options', 'recommendation', 'brief']);\n if (unknown) return unknown;\n // Every part of the memo before anything is written: a person rules\n // on what it says, and cannot rule on a part that says nothing.\n const given = pathsOf(args);\n if ('text' in given) return given;\n const reason = args['reason'];\n if (typeof reason !== 'string' || isBlank(reason)) return toolError('\"reason\" is required.');\n const choices = optionsOf(args);\n if ('text' in choices) return choices;\n const recommendation = args['recommendation'];\n if (recommendation !== undefined && typeof recommendation !== 'string') return toolError('\"recommendation\" must be a string.');\n if (recommendation !== undefined && isBlank(recommendation)) return namesNothing('recommendation', 'recommend', recommendation);\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const { request, memo } = await raiseEscalation(workspace, found.brief, {\n paths: given.paths,\n reason,\n options: choices.options,\n recommendation: recommendation ?? null,\n });\n return { text: `${memo}\\nStop here until a person rules on ${request.id}.`, structured: { id: request.id } };\n },\n },\n {\n descriptor: {\n name: 'audit_round',\n title: 'Audit the round',\n description:\n 'Did the round stay inside the lines: what the archive would refuse (open boxes, protected files, files outside the scope), the brief\\'s own assertions, unverified rulings, every dependency added and every package allowed to run install scripts.',\n inputSchema: { type: 'object', properties: { brief: briefProperty, base: baseProperty }, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, ['brief', 'base']);\n if (unknown) return unknown;\n const base = baseOf(args);\n if ('text' in base) return base;\n const found = await round(workspace, env, args['brief']);\n if ('text' in found) return found;\n const result = await runAudit(workspace, found.brief, reader, base.base);\n const { counts, findings, measured } = result.report;\n // What was measured beside what was found: \"nothing found\" from an\n // audit that ran no goal is not a round that is done.\n const text =\n findings.length === 0\n ? 'The audit found nothing in what it measured.'\n : findings.map((f) => `${f.severity} ${f.rule}: ${f.message}. Next: ${f.hint}`).join('\\n');\n return {\n text: `${text}\\n\\n${describeMeasured(measured)}\\n\\n${counts.error} error(s), ${counts.warning} warning(s), ${counts.note} note(s)`,\n structured: { counts, measured: { ...measured }, findings: findings.map((f) => ({ ...f })) },\n };\n },\n },\n {\n descriptor: {\n name: 'list_rounds',\n title: 'List the rounds',\n description: 'The live briefs: status, wave, what each waits on, and which are ready to start.',\n inputSchema: { type: 'object', properties: {}, additionalProperties: false },\n annotations: readOnly,\n },\n async call(args: JsonObject): Promise<ToolOutcome> {\n const unknown = unknownArguments(args, []);\n if (unknown) return unknown;\n const live = (await workspace.siblings.briefs()).filter((brief) => brief.phase === 'live');\n const text = live\n .map((b) => `${[b.id, titleOf(b)].filter((part) => part !== null).join(' ')} - ${b.status ?? 'unknown'}, wave ${b.wave ?? '-'}, ${b.ready ? 'ready' : `waits on ${b.waitingOn.join(', ')}`}`)\n .join('\\n');\n return { text: text === '' ? 'No live brief.' : text, structured: { briefs: live.map((b) => ({ ...b, title: titleOf(b) })) } };\n },\n },\n ];\n}\n\nconst SKILLS: readonly { name: string; title: string; argument: string; description: string }[] = [\n { name: 'draft-brief', title: 'Draft a brief', argument: 'request', description: 'What the round should achieve, in the person\\'s words.' },\n { name: 'split-goal', title: 'Split a goal into rounds', argument: 'goal', description: 'The goal to split.' },\n { name: 'run-round', title: 'Run a round', argument: 'brief', description: 'The brief id.' },\n { name: 'close-round', title: 'Close a round', argument: 'brief', description: 'The brief id.' },\n];\n\nfunction skillText(name: string): string {\n // The package ships the skills beside dist/ (package.json's files), so one\n // that cannot be read is a broken install, and the request fails saying so\n // rather than serving an empty prompt.\n const text = readFileSync(fileURLToPath(new URL(`../skills/${name}/SKILL.md`, import.meta.url)), 'utf8');\n // Every skill opens with its front matter (tests/source.test.ts), so the\n // anchor is equivalent to its mutant here.\n return text.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n/, '').trim();\n}\n\nexport function prompts(): PromptDefinition[] {\n return SKILLS.map((skill) => ({\n descriptor: {\n name: skill.name,\n title: skill.title,\n arguments: [{ name: skill.argument, description: skill.description, required: false }],\n },\n async get(args: Readonly<Record<string, string>>): Promise<JsonObject> {\n const given = args[skill.argument];\n const text = `${skillText(skill.name)}${given === undefined || given === '' ? '' : `\\n\\n${skill.argument}: ${given}`}`;\n return { description: skill.title, messages: [{ role: 'user', content: { type: 'text', text } }] };\n },\n }));\n}\n\nexport async function mcpCommand(options: Options, io: CliIO): Promise<number> {\n // Claude Code starts a plugin's server in the plugin's directory, and names\n // the project in CLAUDE_PROJECT_DIR; the server answers for the project.\n const workspace = await openWorkspace({ ...options, root: options.root ?? (io.env['CLAUDE_PROJECT_DIR'] || undefined) }, io);\n const handle = createMcpServer({ name: 'spec-harness', version: version(), instructions: INSTRUCTIONS, tools: tools(workspace, io.env), prompts: prompts() });\n // A session handed over whole, as a test hands it, is served as a client\n // would stream it on stdin. Only the built command line serves\n // process.stdin, and the suite spawns it from dist/, outside the sweep\n // (tests/integration/mcp.test.ts), so a mutant that ignores it survives.\n const input = io.stdin === undefined ? process.stdin : Readable.from([Buffer.from(await io.stdin())]);\n await serveLines(input, (line) => io.stdout.write(`${line}\\n`), handle);\n return 0;\n}\n"]}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * What a command line that parsed has still to be before it runs.
3
+ *
4
+ * The parser says what was typed. Whether it names anything was left to each
5
+ * command, and most never asked: an option another command reads was taken
6
+ * and did nothing, an argument no command asked for was dropped, and an
7
+ * option given an empty value, as `--root "$DIR"` is where the variable is
8
+ * not set, was read as the option left out. Each run then answered a
9
+ * question nobody had put, exit 0, where a tool never falls back to its
10
+ * defaults and reports clean (spec-core ADR-0005).
11
+ *
12
+ * Pure: the command line as it was read, and the line that refuses it, or
13
+ * `null`. The one thing only the disk knows, whether `--root` is a
14
+ * directory, is asked of the caller.
15
+ */
16
+ /** A command line as the parser read it; what `parseOptions` returns is one. */
17
+ export interface CommandLine {
18
+ readonly command: string | undefined;
19
+ readonly positionals: readonly string[];
20
+ /** The long name of every option on it, in the order given. */
21
+ readonly given: readonly string[];
22
+ readonly brief: string | undefined;
23
+ readonly base: string | undefined;
24
+ readonly root: string | undefined;
25
+ readonly paths: readonly string[];
26
+ readonly reason: string | undefined;
27
+ readonly options: readonly string[];
28
+ readonly recommend: string | undefined;
29
+ readonly show: string | undefined;
30
+ readonly id: string | undefined;
31
+ }
32
+ /** Whether a value names nothing: empty, or only space. */
33
+ export declare function isBlank(value: string): boolean;
34
+ /**
35
+ * The options that take a value, and what an empty one fails to name.
36
+ * `--format` and `--at` are not here: each takes one of a few words, and the
37
+ * parser refuses any other, the empty one with them. Nor is `--note`, which
38
+ * `rule` refuses by name itself.
39
+ */
40
+ declare const VALUED: {
41
+ readonly brief: {
42
+ readonly of: (line: CommandLine) => readonly string[];
43
+ readonly says: "names no brief; give it a brief's id, or leave it out for the one SPEC_BRIEF or the branch names";
44
+ };
45
+ readonly base: {
46
+ readonly of: (line: CommandLine) => readonly string[];
47
+ readonly says: 'names no commit; give it a branch or a commit, or leave it out for the configured base';
48
+ };
49
+ readonly root: {
50
+ readonly of: (line: CommandLine) => readonly string[];
51
+ readonly says: 'names no directory; give it one, or leave it out to run in the current directory';
52
+ };
53
+ readonly path: {
54
+ readonly of: (line: CommandLine) => readonly string[];
55
+ readonly says: 'names no file; give it the path of a file';
56
+ };
57
+ readonly reason: {
58
+ readonly of: (line: CommandLine) => readonly string[];
59
+ readonly says: 'gives no reason; say why the round cannot be done without the file';
60
+ };
61
+ readonly option: {
62
+ readonly of: (line: CommandLine) => readonly string[];
63
+ readonly says: 'names no choice; give it "<label>: <cost>", or leave it out';
64
+ };
65
+ readonly recommend: {
66
+ readonly of: (line: CommandLine) => readonly string[];
67
+ readonly says: 'recommends nothing; say which option and why, or leave it out';
68
+ };
69
+ readonly show: {
70
+ readonly of: (line: CommandLine) => readonly string[];
71
+ readonly says: 'names no escalation; give it an id, as spec-harness escalate --list prints them';
72
+ };
73
+ readonly id: {
74
+ readonly of: (line: CommandLine) => readonly string[];
75
+ readonly says: "names no probe; give it a probe's id, or leave it out to run every probe";
76
+ };
77
+ };
78
+ export type ValuedOption = keyof typeof VALUED;
79
+ /**
80
+ * The line for a value that names nothing. `subject` is the input as its
81
+ * caller knows it: `--brief` on a command line, `"brief"` in a tool call. The
82
+ * value is shown as JSON, where a tab or a line break in it can be seen.
83
+ */
84
+ export declare function emptyValue(subject: string, option: ValuedOption, value: string): string;
85
+ /**
86
+ * Every command, with what it reads of a command line. An option is listed
87
+ * for a command only where the command's answer depends on it: `init`
88
+ * chooses the base itself and the server is told the brief by each call, so
89
+ * neither takes `--base` or `--brief`, and taking them would tell someone
90
+ * the base or the brief had been set.
91
+ */
92
+ declare const SHAPE: {
93
+ readonly context: {
94
+ readonly limit: {
95
+ readonly most: 1;
96
+ readonly takes: "one argument at most, a brief's id";
97
+ };
98
+ readonly argument: {
99
+ readonly role: 'the brief';
100
+ readonly instead: "give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names";
101
+ };
102
+ readonly options: readonly ["brief", "base", "root", "format"];
103
+ };
104
+ readonly guard: {
105
+ readonly options: readonly ["brief", "base", "root", "format", "strict"];
106
+ readonly limit: null;
107
+ readonly argument: {
108
+ readonly role: 'a path';
109
+ readonly instead: 'give it the paths the round would write';
110
+ };
111
+ };
112
+ readonly hook: {
113
+ readonly options: readonly ["brief", "base", "root"];
114
+ readonly limit: {
115
+ readonly most: 1;
116
+ readonly takes: 'one argument, "claude" or "git"';
117
+ };
118
+ };
119
+ readonly escalate: {
120
+ readonly limit: {
121
+ readonly most: 0;
122
+ readonly takes: 'no argument';
123
+ };
124
+ readonly options: readonly ["brief", "root", "format", "path", "reason", "option", "recommend", "list", "show"];
125
+ };
126
+ readonly rule: {
127
+ readonly options: readonly ["root", "format", "allow", "deny", "note"];
128
+ readonly limit: {
129
+ readonly most: 1;
130
+ readonly takes: "one argument, the escalation's id";
131
+ };
132
+ readonly argument: {
133
+ readonly role: 'the escalation';
134
+ readonly instead: 'give it an id, as spec-harness escalate --list prints them';
135
+ };
136
+ };
137
+ readonly rulings: {
138
+ readonly limit: {
139
+ readonly most: 1;
140
+ readonly takes: "one argument at most, a brief's id";
141
+ };
142
+ readonly argument: {
143
+ readonly role: 'the brief';
144
+ readonly instead: "give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names";
145
+ };
146
+ readonly options: readonly ["brief", "base", "root", "format"];
147
+ };
148
+ readonly audit: {
149
+ readonly limit: {
150
+ readonly most: 1;
151
+ readonly takes: "one argument at most, a brief's id";
152
+ };
153
+ readonly argument: {
154
+ readonly role: 'the brief';
155
+ readonly instead: "give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names";
156
+ };
157
+ readonly options: readonly ["brief", "base", "root", "format", "strict"];
158
+ };
159
+ readonly probe: {
160
+ readonly limit: {
161
+ readonly most: 1;
162
+ readonly takes: "one argument at most, a brief's id";
163
+ };
164
+ readonly argument: {
165
+ readonly role: 'the brief';
166
+ readonly instead: "give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names";
167
+ };
168
+ readonly options: readonly ["brief", "base", "root", "format", "id", "at"];
169
+ };
170
+ readonly premises: {
171
+ readonly limit: {
172
+ readonly most: 0;
173
+ readonly takes: 'no argument';
174
+ };
175
+ readonly options: readonly ["brief", "root", "format", "strict"];
176
+ };
177
+ readonly init: {
178
+ readonly limit: {
179
+ readonly most: 0;
180
+ readonly takes: 'no argument';
181
+ };
182
+ readonly options: readonly ["root", "format", "write", "git-hook"];
183
+ };
184
+ readonly mcp: {
185
+ readonly limit: {
186
+ readonly most: 0;
187
+ readonly takes: 'no argument';
188
+ };
189
+ readonly options: readonly ["root"];
190
+ };
191
+ readonly doctor: {
192
+ readonly limit: {
193
+ readonly most: 0;
194
+ readonly takes: 'no argument';
195
+ };
196
+ readonly options: readonly ["brief", "base", "root", "format", "strict"];
197
+ readonly reports: readonly ["brief", "base"];
198
+ };
199
+ };
200
+ /** Every command there is: the command line dispatches on these names and no other. */
201
+ export type Command = keyof typeof SHAPE;
202
+ /**
203
+ * Why the command line is refused, or `null` when the command can run:
204
+ * an option it does not read, an argument it does not take, a value or an
205
+ * argument that names nothing, a `--root` that is no directory. Asked once a
206
+ * command is known and neither `--help` nor `--version` answers instead; a
207
+ * command with no shape is none, which its caller says.
208
+ */
209
+ export declare function refusal(line: CommandLine, isDirectory: (path: string) => boolean): string | null;
210
+ export {};
package/dist/usage.js ADDED
@@ -0,0 +1,148 @@
1
+ /**
2
+ * What a command line that parsed has still to be before it runs.
3
+ *
4
+ * The parser says what was typed. Whether it names anything was left to each
5
+ * command, and most never asked: an option another command reads was taken
6
+ * and did nothing, an argument no command asked for was dropped, and an
7
+ * option given an empty value, as `--root "$DIR"` is where the variable is
8
+ * not set, was read as the option left out. Each run then answered a
9
+ * question nobody had put, exit 0, where a tool never falls back to its
10
+ * defaults and reports clean (spec-core ADR-0005).
11
+ *
12
+ * Pure: the command line as it was read, and the line that refuses it, or
13
+ * `null`. The one thing only the disk knows, whether `--root` is a
14
+ * directory, is asked of the caller.
15
+ */
16
+ /** Whether a value names nothing: empty, or only space. */
17
+ export function isBlank(value) {
18
+ return value.trim() === '';
19
+ }
20
+ // An option left out has no value to refuse, and a value that names something
21
+ // is passed over as none is: the empty list is equivalent to its mutant.
22
+ const one = (value) => (value === undefined ? [] : [value]);
23
+ /**
24
+ * The options that take a value, and what an empty one fails to name.
25
+ * `--format` and `--at` are not here: each takes one of a few words, and the
26
+ * parser refuses any other, the empty one with them. Nor is `--note`, which
27
+ * `rule` refuses by name itself.
28
+ */
29
+ const VALUED = {
30
+ brief: { of: (line) => one(line.brief), says: "names no brief; give it a brief's id, or leave it out for the one SPEC_BRIEF or the branch names" },
31
+ base: { of: (line) => one(line.base), says: 'names no commit; give it a branch or a commit, or leave it out for the configured base' },
32
+ root: { of: (line) => one(line.root), says: 'names no directory; give it one, or leave it out to run in the current directory' },
33
+ path: { of: (line) => line.paths, says: 'names no file; give it the path of a file' },
34
+ reason: { of: (line) => one(line.reason), says: 'gives no reason; say why the round cannot be done without the file' },
35
+ option: { of: (line) => line.options, says: 'names no choice; give it "<label>: <cost>", or leave it out' },
36
+ recommend: { of: (line) => one(line.recommend), says: 'recommends nothing; say which option and why, or leave it out' },
37
+ show: { of: (line) => one(line.show), says: 'names no escalation; give it an id, as spec-harness escalate --list prints them' },
38
+ id: { of: (line) => one(line.id), says: "names no probe; give it a probe's id, or leave it out to run every probe" },
39
+ };
40
+ /**
41
+ * The line for a value that names nothing. `subject` is the input as its
42
+ * caller knows it: `--brief` on a command line, `"brief"` in a tool call. The
43
+ * value is shown as JSON, where a tab or a line break in it can be seen.
44
+ */
45
+ export function emptyValue(subject, option, value) {
46
+ return `${subject} is ${JSON.stringify(value)}, which ${VALUED[option].says}`;
47
+ }
48
+ const NO_ARGUMENT = { limit: { most: 0, takes: 'no argument' } };
49
+ const ONE_BRIEF = {
50
+ limit: { most: 1, takes: "one argument at most, a brief's id" },
51
+ argument: { role: 'the brief', instead: "give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names" },
52
+ };
53
+ /**
54
+ * Every command, with what it reads of a command line. An option is listed
55
+ * for a command only where the command's answer depends on it: `init`
56
+ * chooses the base itself and the server is told the brief by each call, so
57
+ * neither takes `--base` or `--brief`, and taking them would tell someone
58
+ * the base or the brief had been set.
59
+ */
60
+ const SHAPE = {
61
+ context: { options: ['brief', 'base', 'root', 'format'], ...ONE_BRIEF },
62
+ guard: {
63
+ options: ['brief', 'base', 'root', 'format', 'strict'],
64
+ limit: null,
65
+ argument: { role: 'a path', instead: 'give it the paths the round would write' },
66
+ },
67
+ hook: { options: ['brief', 'base', 'root'], limit: { most: 1, takes: 'one argument, "claude" or "git"' } },
68
+ escalate: { options: ['brief', 'root', 'format', 'path', 'reason', 'option', 'recommend', 'list', 'show'], ...NO_ARGUMENT },
69
+ rule: {
70
+ options: ['root', 'format', 'allow', 'deny', 'note'],
71
+ limit: { most: 1, takes: "one argument, the escalation's id" },
72
+ argument: { role: 'the escalation', instead: 'give it an id, as spec-harness escalate --list prints them' },
73
+ },
74
+ rulings: { options: ['brief', 'base', 'root', 'format'], ...ONE_BRIEF },
75
+ audit: { options: ['brief', 'base', 'root', 'format', 'strict'], ...ONE_BRIEF },
76
+ probe: { options: ['brief', 'base', 'root', 'format', 'id', 'at'], ...ONE_BRIEF },
77
+ premises: { options: ['brief', 'root', 'format', 'strict'], ...NO_ARGUMENT },
78
+ init: { options: ['root', 'format', 'write', 'git-hook'], ...NO_ARGUMENT },
79
+ mcp: { options: ['root'], ...NO_ARGUMENT },
80
+ // A diagnosis says what is wrong with what it was given, where a command
81
+ // that acts on it stops: a brief or a base that names nothing is a line of
82
+ // doctor's report.
83
+ doctor: { options: ['brief', 'base', 'root', 'format', 'strict'], ...NO_ARGUMENT, reports: ['brief', 'base'] },
84
+ };
85
+ // A map, since a command is a word a person types and an object answers to
86
+ // more names than it was given: `constructor` has no shape.
87
+ const SHAPES = new Map(Object.entries(SHAPE));
88
+ function listed(options) {
89
+ const names = options.map((option) => `--${option}`);
90
+ // Every command reads at least `--root`, so a list is never empty.
91
+ if (names.length === 1)
92
+ return `its only option is ${names[0]}`;
93
+ return `its options are ${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
94
+ }
95
+ /**
96
+ * Whether the line is Claude Code's hook. It is exempt from every refusal
97
+ * here, and read as each release since 0.1.0 read it: the line lives in
98
+ * settings files and in the plugin of every release, which this one cannot
99
+ * rewrite, and exit 2 from it holds every write of a session, the write that
100
+ * would fix the line among them. An option the parser itself does not know
101
+ * is exit 2 there, as it always was.
102
+ */
103
+ function isClaudeHook(line) {
104
+ return line.command === 'hook' && line.positionals[0] === 'claude';
105
+ }
106
+ /**
107
+ * Why the command line is refused, or `null` when the command can run:
108
+ * an option it does not read, an argument it does not take, a value or an
109
+ * argument that names nothing, a `--root` that is no directory. Asked once a
110
+ * command is known and neither `--help` nor `--version` answers instead; a
111
+ * command with no shape is none, which its caller says.
112
+ */
113
+ export function refusal(line, isDirectory) {
114
+ const { command, positionals } = line;
115
+ // No shape is kept under `undefined`, so the first check is the compiler's,
116
+ // and its mutant is equivalent.
117
+ if (command === undefined)
118
+ return null;
119
+ const shape = SHAPES.get(command);
120
+ if (shape === undefined || isClaudeHook(line))
121
+ return null;
122
+ const stray = line.given.find((option) => !shape.options.includes(option));
123
+ if (stray !== undefined)
124
+ return `${command} does not take --${stray}; ${listed(shape.options)}`;
125
+ if (shape.limit !== null && positionals.length > shape.limit.most) {
126
+ return `${command} takes ${shape.limit.takes}, not ${positionals.map((argument) => JSON.stringify(argument)).join(', ')}`;
127
+ }
128
+ for (const [option, valued] of Object.entries(VALUED)) {
129
+ if (shape.reports?.includes(option))
130
+ continue;
131
+ const empty = valued.of(line).find(isBlank);
132
+ if (empty !== undefined)
133
+ return emptyValue(`--${option}`, option, empty);
134
+ }
135
+ const empty = positionals.find(isBlank);
136
+ if (shape.argument !== undefined && empty !== undefined) {
137
+ return `${command} was given ${JSON.stringify(empty)} as ${shape.argument.role}, which names none; ${shape.argument.instead}`;
138
+ }
139
+ // An empty one was refused above, so this is a path that was meant: a file,
140
+ // or a directory that is not there. git starts in neither, and the run
141
+ // ended saying the path was outside a work tree, which named neither the
142
+ // option nor what was wrong with what it was given.
143
+ if (line.root !== undefined && !isDirectory(line.root)) {
144
+ return `--root is "${line.root}", which is not a directory; give it one that exists, or leave it out to run in the current directory`;
145
+ }
146
+ return null;
147
+ }
148
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH,2DAA2D;AAC3D,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAQD,8EAA8E;AAC9E,yEAAyE;AACzE,MAAM,GAAG,GAAG,CAAC,KAAyB,EAAqB,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,kGAAkG,EAAE;IAClJ,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,wFAAwF,EAAE;IACtI,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,E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AC;IACD,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAA6B,EAAE,CAAC;QAClF,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;YAAE,SAAS;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,UAAU,CAAC,KAAK,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxD,OAAO,GAAG,OAAO,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,uBAAuB,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChI,CAAC;IACD,4EAA4E;IAC5E,uEAAuE;IACvE,yEAAyE;IACzE,oDAAoD;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,OAAO,cAAc,IAAI,CAAC,IAAI,uGAAuG,CAAC;IACxI,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * What a command line that parsed has still to be before it runs.\n *\n * The parser says what was typed. Whether it names anything was left to each\n * command, and most never asked: an option another command reads was taken\n * and did nothing, an argument no command asked for was dropped, and an\n * option given an empty value, as `--root \"$DIR\"` is where the variable is\n * not set, was read as the option left out. Each run then answered a\n * question nobody had put, exit 0, where a tool never falls back to its\n * defaults and reports clean (spec-core ADR-0005).\n *\n * Pure: the command line as it was read, and the line that refuses it, or\n * `null`. The one thing only the disk knows, whether `--root` is a\n * directory, is asked of the caller.\n */\n\n/** A command line as the parser read it; what `parseOptions` returns is one. */\nexport interface CommandLine {\n readonly command: string | undefined;\n readonly positionals: readonly string[];\n /** The long name of every option on it, in the order given. */\n readonly given: readonly string[];\n readonly brief: string | undefined;\n readonly base: string | undefined;\n readonly root: string | undefined;\n readonly paths: readonly string[];\n readonly reason: string | undefined;\n readonly options: readonly string[];\n readonly recommend: string | undefined;\n readonly show: string | undefined;\n readonly id: string | undefined;\n}\n\n/** Whether a value names nothing: empty, or only space. */\nexport function isBlank(value: string): boolean {\n return value.trim() === '';\n}\n\ninterface Valued {\n readonly of: (line: CommandLine) => readonly string[];\n /** What is said of a value that names nothing, and what to do instead. */\n readonly says: string;\n}\n\n// An option left out has no value to refuse, and a value that names something\n// is passed over as none is: the empty list is equivalent to its mutant.\nconst one = (value: string | undefined): readonly string[] => (value === undefined ? [] : [value]);\n\n/**\n * The options that take a value, and what an empty one fails to name.\n * `--format` and `--at` are not here: each takes one of a few words, and the\n * parser refuses any other, the empty one with them. Nor is `--note`, which\n * `rule` refuses by name itself.\n */\nconst VALUED = {\n brief: { of: (line) => one(line.brief), says: \"names no brief; give it a brief's id, or leave it out for the one SPEC_BRIEF or the branch names\" },\n base: { of: (line) => one(line.base), says: 'names no commit; give it a branch or a commit, or leave it out for the configured base' },\n root: { of: (line) => one(line.root), says: 'names no directory; give it one, or leave it out to run in the current directory' },\n path: { of: (line) => line.paths, says: 'names no file; give it the path of a file' },\n reason: { of: (line) => one(line.reason), says: 'gives no reason; say why the round cannot be done without the file' },\n option: { of: (line) => line.options, says: 'names no choice; give it \"<label>: <cost>\", or leave it out' },\n recommend: { of: (line) => one(line.recommend), says: 'recommends nothing; say which option and why, or leave it out' },\n show: { of: (line) => one(line.show), says: 'names no escalation; give it an id, as spec-harness escalate --list prints them' },\n id: { of: (line) => one(line.id), says: \"names no probe; give it a probe's id, or leave it out to run every probe\" },\n} as const satisfies Record<string, Valued>;\n\nexport type ValuedOption = keyof typeof VALUED;\n\n/**\n * The line for a value that names nothing. `subject` is the input as its\n * caller knows it: `--brief` on a command line, `\"brief\"` in a tool call. The\n * value is shown as JSON, where a tab or a line break in it can be seen.\n */\nexport function emptyValue(subject: string, option: ValuedOption, value: string): string {\n return `${subject} is ${JSON.stringify(value)}, which ${VALUED[option].says}`;\n}\n\ninterface Shape {\n /** The options the command reads, by their long names. */\n readonly options: readonly string[];\n /** The most arguments it takes, with that said for the refusal of one more; `null` where it takes any number. */\n readonly limit: { readonly most: number; readonly takes: string } | null;\n /** What an argument of it is, and what to do about an empty one; absent where it takes none, or says so itself. */\n readonly argument?: { readonly role: string; readonly instead: string };\n /** The options whose empty value the command says in its own report. */\n readonly reports?: readonly string[];\n}\n\nconst NO_ARGUMENT = { limit: { most: 0, takes: 'no argument' } } as const;\nconst ONE_BRIEF = {\n limit: { most: 1, takes: \"one argument at most, a brief's id\" },\n argument: { role: 'the brief', instead: \"give it a brief's id, or leave it out for the one --brief, SPEC_BRIEF or the branch names\" },\n} as const;\n\n/**\n * Every command, with what it reads of a command line. An option is listed\n * for a command only where the command's answer depends on it: `init`\n * chooses the base itself and the server is told the brief by each call, so\n * neither takes `--base` or `--brief`, and taking them would tell someone\n * the base or the brief had been set.\n */\nconst SHAPE = {\n context: { options: ['brief', 'base', 'root', 'format'], ...ONE_BRIEF },\n guard: {\n options: ['brief', 'base', 'root', 'format', 'strict'],\n limit: null,\n argument: { role: 'a path', instead: 'give it the paths the round would write' },\n },\n hook: { options: ['brief', 'base', 'root'], limit: { most: 1, takes: 'one argument, \"claude\" or \"git\"' } },\n escalate: { options: ['brief', 'root', 'format', 'path', 'reason', 'option', 'recommend', 'list', 'show'], ...NO_ARGUMENT },\n rule: {\n options: ['root', 'format', 'allow', 'deny', 'note'],\n limit: { most: 1, takes: \"one argument, the escalation's id\" },\n argument: { role: 'the escalation', instead: 'give it an id, as spec-harness escalate --list prints them' },\n },\n rulings: { options: ['brief', 'base', 'root', 'format'], ...ONE_BRIEF },\n audit: { options: ['brief', 'base', 'root', 'format', 'strict'], ...ONE_BRIEF },\n probe: { options: ['brief', 'base', 'root', 'format', 'id', 'at'], ...ONE_BRIEF },\n premises: { options: ['brief', 'root', 'format', 'strict'], ...NO_ARGUMENT },\n init: { options: ['root', 'format', 'write', 'git-hook'], ...NO_ARGUMENT },\n mcp: { options: ['root'], ...NO_ARGUMENT },\n // A diagnosis says what is wrong with what it was given, where a command\n // that acts on it stops: a brief or a base that names nothing is a line of\n // doctor's report.\n doctor: { options: ['brief', 'base', 'root', 'format', 'strict'], ...NO_ARGUMENT, reports: ['brief', 'base'] },\n} as const satisfies Record<string, Shape>;\n\n/** Every command there is: the command line dispatches on these names and no other. */\nexport type Command = keyof typeof SHAPE;\n\n// A map, since a command is a word a person types and an object answers to\n// more names than it was given: `constructor` has no shape.\nconst SHAPES: ReadonlyMap<string, Shape> = new Map(Object.entries(SHAPE));\n\nfunction listed(options: readonly string[]): string {\n const names = options.map((option) => `--${option}`);\n // Every command reads at least `--root`, so a list is never empty.\n if (names.length === 1) return `its only option is ${names[0] as string}`;\n return `its options are ${names.slice(0, -1).join(', ')} and ${names.at(-1) as string}`;\n}\n\n/**\n * Whether the line is Claude Code's hook. It is exempt from every refusal\n * here, and read as each release since 0.1.0 read it: the line lives in\n * settings files and in the plugin of every release, which this one cannot\n * rewrite, and exit 2 from it holds every write of a session, the write that\n * would fix the line among them. An option the parser itself does not know\n * is exit 2 there, as it always was.\n */\nfunction isClaudeHook(line: CommandLine): boolean {\n return line.command === 'hook' && line.positionals[0] === 'claude';\n}\n\n/**\n * Why the command line is refused, or `null` when the command can run:\n * an option it does not read, an argument it does not take, a value or an\n * argument that names nothing, a `--root` that is no directory. Asked once a\n * command is known and neither `--help` nor `--version` answers instead; a\n * command with no shape is none, which its caller says.\n */\nexport function refusal(line: CommandLine, isDirectory: (path: string) => boolean): string | null {\n const { command, positionals } = line;\n // No shape is kept under `undefined`, so the first check is the compiler's,\n // and its mutant is equivalent.\n if (command === undefined) return null;\n const shape = SHAPES.get(command);\n if (shape === undefined || isClaudeHook(line)) return null;\n const stray = line.given.find((option) => !shape.options.includes(option));\n if (stray !== undefined) return `${command} does not take --${stray}; ${listed(shape.options)}`;\n if (shape.limit !== null && positionals.length > shape.limit.most) {\n return `${command} takes ${shape.limit.takes}, not ${positionals.map((argument) => JSON.stringify(argument)).join(', ')}`;\n }\n for (const [option, valued] of Object.entries(VALUED) as [ValuedOption, Valued][]) {\n if (shape.reports?.includes(option)) continue;\n const empty = valued.of(line).find(isBlank);\n if (empty !== undefined) return emptyValue(`--${option}`, option, empty);\n }\n const empty = positionals.find(isBlank);\n if (shape.argument !== undefined && empty !== undefined) {\n return `${command} was given ${JSON.stringify(empty)} as ${shape.argument.role}, which names none; ${shape.argument.instead}`;\n }\n // An empty one was refused above, so this is a path that was meant: a file,\n // or a directory that is not there. git starts in neither, and the run\n // ended saying the path was outside a work tree, which named neither the\n // option nor what was wrong with what it was given.\n if (line.root !== undefined && !isDirectory(line.root)) {\n return `--root is \"${line.root}\", which is not a directory; give it one that exists, or leave it out to run in the current directory`;\n }\n return null;\n}\n"]}
@@ -30,6 +30,8 @@ export declare function version(): string;
30
30
  export interface Options {
31
31
  readonly command: string | undefined;
32
32
  readonly positionals: readonly string[];
33
+ /** The long name of every option given, in the order given: what tells an option left out from one a command does not read. */
34
+ readonly given: readonly string[];
33
35
  readonly brief: string | undefined;
34
36
  readonly base: string | undefined;
35
37
  readonly root: string | undefined;
package/dist/workspace.js CHANGED
@@ -74,6 +74,7 @@ export function parseOptions(argv) {
74
74
  return {
75
75
  command,
76
76
  positionals: positionals.slice(1),
77
+ given: Object.keys(values),
77
78
  brief: values.brief,
78
79
  base: values.base,
79
80
  root: values.root,