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(mcp): pass CLI refusals through; needsYou waits for #702 [A9,P6]
Corey Olson5d532a2e8590
diff --git a/docs/api.md b/docs/api.mdindex c3c21f45..db5ea22e 100644--- a/docs/api.md+++ b/docs/api.md@@ -198,16 +198,16 @@ It answers `initialize` with `protocolVersion` (the client's, when it is `2025-0| Tool | Input schema | Mirrors | Result || --- | --- | --- | --- |-| `board_status` | `{}` | `pullboard status` and `pullboard list` | the `status` document plus `items` (open and active items) and `needsYou`: the `decisions`, `holds` and `spec` fields of the view's board projection, unshaped, as the view's Needs-you reads them |-| `show_item` | `{id: integer >= 1}` | `pullboard show <id>` | the `show` document |+| `board_status` | `{}` | `pullboard status` and `pullboard list` | the `status` document plus `items` (open and active items) and `needsYou`: the `decisions` and `holds` fields of the view's board projection, unshaped, as the view's Needs-you reads them; spec rows that need the person come with #702 |+| `show_item` | `{id: integer}` | `pullboard show <id>` | the `show` document || `shout` | `{to: string, text: string}` | `pullboard shout <to> <text>` | the `shout` document || `capture_idea` | `{text: string}` | `pullboard shout coordinator "idea: <text>"` | the `shout` document; until ideas become their own kind of item, an idea is a shout to the coordinator whose text starts `idea: ` |-`needsYou` is read-only and comes from the same projection as the local API's board state and the view: `decisions` are the open decisions addressed to the person, `holds` the held lanes, and `spec` every row of the project's spec file with its `status`, so the person's rows are those `pending` or `draft`. Building that projection reads every item and the spec file's history, so `board_status` is slower on large boards than the other tools.+`needsYou` is read-only and comes from the same projection as the local API's board state and the view: `decisions` are the open decisions addressed to the person and `holds` the held lanes. It carries no spec rows yet; spec rows that need the person come with #702. Building that projection reads every item and the spec file's history, so `board_status` is slower on large boards than the other tools.-Every input schema sets `additionalProperties: false`; an unknown or mistyped argument returns `BAD_REQUEST`. No argument names an author, a seat or a channel: the author of every move is the agent of the checkout the server runs in.+Every input schema sets `additionalProperties: false`; an unknown argument or a value of the wrong type returns `BAD_REQUEST`. A value of the right type goes to the CLI as it is, so a blank shout returns the CLI's `EMPTY_SHOUT` and item `0` its `USAGE`. No argument names an author, a seat or a channel: the author of every move is the agent of the checkout the server runs in.-Each tool runs the CLI command it mirrors through the same engine as the terminal and the local API, with the API's move arguments, so a move records the same events and a refusal carries the CLI's own `code`, `message` and `next`. A result's `content` is one `text` part holding the versioned JSON document, which `structuredContent` repeats. A refusal is a result with `isError: true` and the versioned refusal document. A tool name the server does not offer gets JSON-RPC error `-32602` with an `UNKNOWN_TOOL` refusal in `data`.+Each tool runs the CLI command it mirrors through the same engine as the terminal and the local API, with its arguments as distinct argv entries after `--`, so a move records the same events and a refusal carries the CLI's own `code`, `message` and `next`. A result's `content` is one `text` part holding the versioned JSON document, which `structuredContent` repeats. A refusal is a result with `isError: true` and the versioned refusal document. A tool name the server does not offer gets JSON-RPC error `-32602` with an `UNKNOWN_TOOL` refusal in `data`.A person's own moves never come through MCP (P6). A tool call that names one (approving or declining rows, answering a decision, signing off) returns `HUMAN_REQUIRED` before any argument is read, whatever the client claims in its arguments, `_meta`, `clientInfo` or environment, and from any seat, including the main checkout. Every engine call the server makes also carries the `mcp` channel, which the CLI's own person check refuses. The refusal's `next` says to ask the coordinator to bring the call to the person. Live notifications over MCP are not offered yet.diff --git a/src/cli.js b/src/cli.jsindex 264f7b1a..d68e42f7 100644--- a/src/cli.js+++ b/src/cli.js@@ -1539,7 +1539,6 @@ async function launchBackgroundView(io, port, projectRoot) {}}-/** Serve API v1 until a shutdown signal, printing its address before waiting (A2). *//*** Serve MCP over stdio as this checkout's agent (A9). Stdout carries only the protocol, so the command* takes no --json; each tool call runs its own CLI command, with its own relay sync, through main.@@ -1552,6 +1551,7 @@ async function mcpHere(io, { first, values }) {return serveMcp({ cwd: io.cwd, input: io.stdin, output: io.stdout, log: io.stderr, runCommand: main });}+/** Serve API v1 until a shutdown signal, printing its address before waiting (A2). */async function serveHere(io, values) {traceServeStartup('serve-context-start');const ctx = context(io);diff --git a/src/mcp.js b/src/mcp.jsindex 411fbb0f..074c0ce7 100644--- a/src/mcp.js+++ b/src/mcp.js@@ -3,13 +3,12 @@* coordinate on it as that agent (A9), and never make a person's move (P6). It is newline-delimited* JSON-RPC 2.0 on stdin and stdout, hand-written because Pullboard has no dependencies, and it opens* no network connection (P5). Every tool runs the CLI command it mirrors through the same `main` the- * terminal and the local API use, with the API's move layer (moveArgs), so a refusal reaches the- * client with the CLI's own code and next step.+ * terminal and the local API use, with its arguments as distinct argv entries after --, the form the+ * API's moveArgs builds, so a refusal reaches the client with the CLI's own code and next step.*/import { COORDINATOR } from './config.js';import { VERSION } from './help.js';import { refusalDocument } from './json.js';-import { moveArgs } from './api-moves.js';import { Refused } from './refused.js';import { projectState } from './serve.js';@@ -29,7 +28,7 @@ const PERSON_MOVE = /approv|declin|answer|sign_?off|decide|decision/u;export const MCP_TOOLS = Object.freeze([{name: 'board_status',- description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and needsYou: the decisions, holds and spec fields of the view\'s own board projection, as the view\'s Needs-you reads them. Mirrors pullboard status and pullboard list. It builds the full board projection, so it is slower on large boards.',+ description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and needsYou: the decisions and holds fields of the view\'s own board projection, as the view\'s Needs-you reads them; spec rows that need the person come with #702. Mirrors pullboard status and pullboard list. It builds the full board projection, so it is slower on large boards.',inputSchema: { type: 'object', properties: {}, additionalProperties: false },},{@@ -37,7 +36,7 @@ export const MCP_TOOLS = Object.freeze([description: 'One item in full: its criterion, the check and criterion frozen at claim, its verdicts and its thread. Mirrors pullboard show <id>.',inputSchema: {type: 'object',- properties: { id: { type: 'integer', minimum: 1, description: 'The item id, as on the board.' } },+ properties: { id: { type: 'integer', description: 'The item id, as on the board.' } },required: ['id'],additionalProperties: false,},@@ -48,8 +47,8 @@ export const MCP_TOOLS = Object.freeze([inputSchema: {type: 'object',properties: {- to: { type: 'string', minLength: 1, description: 'A lane, an agent id, or all.' },- text: { type: 'string', minLength: 1, description: 'What to say.' },+ to: { type: 'string', description: 'A lane, an agent id, or all.' },+ text: { type: 'string', description: 'What to say.' },},required: ['to', 'text'],additionalProperties: false,@@ -60,7 +59,7 @@ export const MCP_TOOLS = Object.freeze([description: 'Capture an idea for the coordinator: it goes as a shout to the coordinator, marked as an idea. Mirrors pullboard shout coordinator "idea: <text>".',inputSchema: {type: 'object',- properties: { text: { type: 'string', minLength: 1, description: 'The idea, in a sentence or two.' } },+ properties: { text: { type: 'string', description: 'The idea, in a sentence or two.' } },required: ['text'],additionalProperties: false,},@@ -87,11 +86,12 @@ function validateArguments(tool, args) {for (const [key, rule] of Object.entries(schema.properties)) {const value = args[key];if (value === undefined) continue;- if (rule.type === 'integer' && (!Number.isSafeInteger(value) || value < (rule.minimum ?? -Infinity))) {- throw new Refused('BAD_REQUEST', `${tool.name} needs ${key} as a positive whole number; use the item id from the board`);+ // Types only: a blank text or an id the board rejects reaches the CLI, so its own refusal comes back.+ if (rule.type === 'integer' && !Number.isSafeInteger(value)) {+ throw new Refused('BAD_REQUEST', `${tool.name} needs ${key} as a whole number; use the item id from the board`);}- if (rule.type === 'string' && (typeof value !== 'string' || !value.trim())) {- throw new Refused('BAD_REQUEST', `${tool.name} needs ${key} as nonempty text; use the tool's input schema`);+ if (rule.type === 'string' && typeof value !== 'string') {+ throw new Refused('BAD_REQUEST', `${tool.name} needs ${key} as text; use the tool's input schema`);}}return args;@@ -151,22 +151,24 @@ async function callTool(runCommand, cwd, name, args) {const list = await runCli(runCommand, cwd, ['list', '--json']);if (list.status) return toolResult(list.document, true);// Needs-you comes from the view's own projection, unshaped and read-only: one builder, no second query.- const { decisions, holds, spec } = projectState(cwd);+ const { decisions, holds } = projectState(cwd);const { version, ...summary } = status.document;return toolResult({version,...summary,items: list.document.items,- needsYou: { decisions, holds, spec },+ needsYou: { decisions, holds },}, false);}if (name === 'show_item') {- const shown = await runCli(runCommand, cwd, ['show', String(input.id), '--json']);+ const shown = await runCli(runCommand, cwd, ['show', '--json', '--', String(input.id)]);return toolResult(shown.document, Boolean(shown.status));}+ // The CLI's own shout argv, positionals after --, as moveArgs builds it. moveArgs refuses blank text+ // before the engine runs, so the text goes straight to the CLI, whose shout refuses it as EMPTY_SHOUT.const argv = name === 'shout'- ? moveArgs({ verb: 'shout', args: { to: input.to, text: input.text } })- : moveArgs({ verb: 'shout', args: { to: COORDINATOR, text: `${IDEA_PREFIX}${input.text}` } });+ ? ['shout', '--json', '--', input.to, input.text]+ : ['shout', '--json', '--', COORDINATOR, input.text.trim() ? `${IDEA_PREFIX}${input.text}` : input.text];const moved = await runCli(runCommand, cwd, argv);return toolResult(moved.document, Boolean(moved.status));}diff --git a/test/mcp.test.js b/test/mcp.test.jsindex 94844b3d..56dc2499 100644--- a/test/mcp.test.js+++ b/test/mcp.test.js@@ -235,11 +235,12 @@ test('[A9,P5] an MCP client reads the board and shouts as its agent', async (t)assert.equal(status.structuredContent.me.id, box.agent, 'status reads as the seat\'s agent');assert.ok(status.structuredContent.items.some((item) => item.item_id === itemId && item.item_status === 'open'), 'status lists the open item');assert.deepEqual(status.structuredContent.needsYou.decisions.map((ask) => ask.shout_id), [decisionId], 'Needs-you carries the person\'s open decision');- assert.ok(status.structuredContent.needsYou.spec.some((row) => row.id === 'G2' && row.status === 'draft'), 'Needs-you carries the draft row');// One builder: needsYou is the view's own projection, unshaped, never a query of the tool's own.+ // Spec rows that need the person come with #702, so needsYou carries decisions and holds only.+ assert.deepEqual(Object.keys(status.structuredContent.needsYou).sort(), ['decisions', 'holds'], 'needsYou carries no spec rows until #702');const projection = JSON.parse(JSON.stringify(projectState(box.web)));- assert.deepEqual(status.structuredContent.needsYou, { decisions: projection.decisions, holds: projection.holds, spec: projection.spec },- 'needsYou is projectState\'s decisions, holds and spec for the same board');+ assert.deepEqual(status.structuredContent.needsYou, { decisions: projection.decisions, holds: projection.holds },+ 'needsYou is projectState\'s decisions and holds for the same board');assert.deepEqual(JSON.parse(status.content[0].text), status.structuredContent, 'the text content is the same document');const shown = await client.call('show_item', { id: itemId });@@ -278,6 +279,21 @@ test('[A9,P5] an MCP client reads the board and shouts as its agent', async (t)const missing = await client.call('show_item', { id: 999 });assert.equal(missing.isError, true);assert.deepEqual(missing.structuredContent, cli(box, box.web, ['show', '999']).document);+ // Values of the right type reach the CLI, so its own refusal comes back: EMPTY_SHOUT and USAGE.+ const blank = await client.call('shout', { to: 'coordinator', text: ' ' });+ const cliBlank = cli(box, box.web, ['shout', 'coordinator', ' '], box.sessionA);+ assert.equal(cliBlank.document.error.code, 'EMPTY_SHOUT');+ assert.equal(blank.isError, true);+ assert.deepEqual(blank.structuredContent, cliBlank.document, 'a blank shout is the CLI\'s EMPTY_SHOUT');+ const blankIdea = await client.call('capture_idea', { text: ' ' });+ assert.equal(blankIdea.structuredContent.error.code, 'EMPTY_SHOUT', 'a blank idea is the CLI\'s EMPTY_SHOUT');+ const zero = await client.call('show_item', { id: 0 });+ const cliZero = cli(box, box.web, ['show', '0']);+ assert.equal(cliZero.document.error.code, 'USAGE');+ assert.equal(zero.isError, true);+ assert.deepEqual(zero.structuredContent, cliZero.document, 'item 0 is the CLI\'s USAGE');+ const mistyped = await client.call('show_item', { id: '12' });+ assert.equal(mistyped.structuredContent.error.code, 'BAD_REQUEST', 'a value of the wrong type is still refused');// Arguments are exactly the schema's: no argument can name another author, seat or channel.const spoofed = await client.call('shout', { to: 'all', text: 'from someone else', from: 'person' });