[PR #6347] fix(cli): delegate rea mcp add to setup --client on Windows (#5811) #7295

Open
opened 2026-11-01 21:46:50 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6347
Author: @agnaylor
Created: 10/22/2026
Status: 🔄 Open

Base: main ← Head: pr/windows-mcp-add-5811


📝 Commits (6)

  • a8d32e5 fix(cli): delegate rea mcp add to setup --client on Windows (#5811)
  • aecb360 Merge upstream main into pr/windows-mcp-add-5811 (keep the Windows delegation ahead of the shared output-control parsing)
  • 6087800 Merge upstream main into pr/windows-mcp-add-5811 (skip the Windows delegation during shell completion, keep it otherwise)
  • 5b52a7b Merge upstream main into pr/windows-mcp-add-5811 (restore upstream's versions of six files a previous merge commit's hook had reformatted)
  • cd3b197 Merge upstream main 425776174 into pr/windows-mcp-add-5811
  • 607f787 fix(cli): ship the Windows mcp add delegation in the compiled runtime and select it with Incur's builtin split

📊 Changes

5 files changed (+276 additions, -2 deletions)

View changed files

📝 scripts/rea.mjs (+15 -1)
➕ src/cli/windowsMcpAdd.ts (+135 -0)
📝 src/cliOutput.ts (+1 -0)
📝 tests/boundary/cli/dispatcher.test.ts (+1 -1)
➕ tests/boundary/cli/windowsMcpAdd.test.ts (+124 -0)

📄 Description

Summary

Fixes #5811. On Windows, rea mcp add --agent <id> failed before touching any client configuration because Incur's registration spawns a bare npx, which Node cannot execute without a shell on Windows (spawn npx ENOENT). REA's own rea setup --client <id> already registers the same agents on Windows through the verified launcher, so the dispatcher now delegates to it there and says so.

Problem and expected behavior

Trigger: node scripts/rea.mjs mcp add --agent codex on Windows 11 with Node 24. Observed: spawn npx ENOENT. Expected: the agent is registered, or REA refuses with a reason it can stand behind.

Change and scope

src/cli/windowsMcpAdd.ts decides, for win32 and mcp add only, whether to delegate. It selects the command from the shared builtin argument split (splitIncurBuiltinArguments over normalizeCliArguments), so output flags in any position (rea --json mcp add, rea mcp --json add) are recognized and kept, and --help, -h, --schema and --llms go to Incur unchanged. It ships in the compiled CLI runtime through src/cliOutput.ts, the launcher's existing entry, so the package needs no new file. --agent values map to setup client ids (claude-code becomes claude_code), --dry-run and output flags with their values pass through, and --yes is added so setup does not prompt. Options setup cannot honor are refused with a message instead of being dropped silently: --no-global (setup registers globally only), --command / -c (setup registers its own launcher), and a missing --agent (Incur's auto-detection is the part that spawns npx). Other platforms and other commands are untouched. scripts/rea.mjs applies the decision before Incur sees the arguments, and skips it in shell-completion mode (COMPLETE=<shell>), where the words on the line are completion input rather than a command.

Contribution scope: an ordinary fix within an existing boundary; no maintainer scope decision needed (no target execution, injection, mutation or protection recovery).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the CLI dispatcher (scripts/rea.mjs), before Incur; command selection reuses the builtin argument owner in src/cliBuiltinArguments.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (ordinary fix).
  • CLI and MCP/tool-catalog contract: rea mcp add on Windows now behaves like rea setup --client; three option combinations exit 1 with a stated refusal instead of failing with ENOENT. No MCP catalog change.
  • Provider, bridge, target-format, or platform compatibility: Windows only; Linux and macOS unchanged (covered by tests).
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none; the helper is part of dist/cli-runtime, which the package already ships.

Expected effects:

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added: tests/boundary/cli/windowsMcpAdd.test.ts (17 tests): no change off Windows or for other commands; agent-name mapping; delegation keeps --dry-run and output flags and adds --yes; mcp add is selected with output flags before, between and after the command words, including a valued flag whose value is add; help, -h and --schema are left to Incur; refusals for --no-global, --command, -c and a missing --agent; on a real Windows host, mcp add --agent codex --dry-run through scripts/rea.mjs prints the delegation note and a planned configure_client:codex without writing, and mcp add --help shows Incur's help. tests/boundary/cli/dispatcher.test.ts stubs the new cliOutput export like the others.
  • Base reproduction: before the change, the same command on Windows ended with spawn npx ENOENT (captured in the author's evidence log); after, exit 0 with the plan.
  • User-visible output on Windows 11 with Node 24.22.1, branch head aecb360aa:
Windows: rea mcp add delegates to rea setup --client codex --dry-run because Incur's registration cannot spawn npx here (#5811).
T  REA setup plan
◆  Ready to review
│  UPDATE  Codex
│          C:Users<user>.codexconfig.toml
│          backup: C:Users<user>.codexconfig.toml.rea.backup
│          Add the REA MCP registration for Codex; preserve unrelated configuration. ...
│  INSTALL  REA reverse-engineering skill
—  Dry run complete. No changes were made.
  • Remaining proof gaps: the non-dry-run write path was exercised only through rea setup's own existing coverage; --no-global users must register the project entry by hand, as the refusal says. After merging main 8d8d85ba2 the live Windows test first failed on the author's host only because main now requires Node.js >=24.22.1 (#6315) and the host still had 24.19.0; after upgrading the host to 24.22.1 it passes.

Validation performed

  • npm run test:focused -- tests/boundary/cli/windowsMcpAdd.test.ts tests/boundary/cli/dispatcher.test.ts on Windows 11 (Ales), Node 24.22.1, merged with main 425776174 — 30 passed (30), including both live Windows tests
  • npm run build:cached and npm run check:fast — 3 of 3 and 2 of 2 tasks successful
  • Packed entrypoint: npm pack, extracted, then from the extracted package/: node scripts/rea.mjs --version printed 6.7.0, mcp add --help exited 0, and --json mcp add --agent codex --dry-run printed the delegation note and a JSON plan with configure_client:codex (dependencies linked from the checkout's node_modules)
  • COMPLETE=bash node scripts/rea.mjs mcp add --agent codex on Windows — no delegation note and no setup plan, so completion is untouched (manual check; no automated test covers this path)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. On Windows, rea mcp add --no-global and --command now fail fast with a reason instead of failing with ENOENT.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows 11 real run (dry-run); Linux and macOS by unit tests only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process is spawned; delegation reuses setup's verified launcher resolution.

Author readiness

Human owner: @agnaylor

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6347 **Author:** [@agnaylor](https://github.com/agnaylor) **Created:** 10/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/windows-mcp-add-5811` --- ### 📝 Commits (6) - [`a8d32e5`](https://github.com/morluto/rea/commit/a8d32e521fc2df1148e03abb5d50259f65486a90) fix(cli): delegate rea mcp add to setup --client on Windows (#5811) - [`aecb360`](https://github.com/morluto/rea/commit/aecb360aa9e72695a91f42a07242f3cec220e1e3) Merge upstream main into pr/windows-mcp-add-5811 (keep the Windows delegation ahead of the shared output-control parsing) - [`6087800`](https://github.com/morluto/rea/commit/608780032f828b640870ea903d11689f1c7a01de) Merge upstream main into pr/windows-mcp-add-5811 (skip the Windows delegation during shell completion, keep it otherwise) - [`5b52a7b`](https://github.com/morluto/rea/commit/5b52a7b0c1542191d43a4e5202e69a65458a17ac) Merge upstream main into pr/windows-mcp-add-5811 (restore upstream's versions of six files a previous merge commit's hook had reformatted) - [`cd3b197`](https://github.com/morluto/rea/commit/cd3b1973d5d14e1fc64740fa1cd2cd7acbbd4c07) Merge upstream main 425776174 into pr/windows-mcp-add-5811 - [`607f787`](https://github.com/morluto/rea/commit/607f787c94b9b8feeec9cad4b0b6d60bf7ba789c) fix(cli): ship the Windows mcp add delegation in the compiled runtime and select it with Incur's builtin split ### 📊 Changes **5 files changed** (+276 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `scripts/rea.mjs` (+15 -1) ➕ `src/cli/windowsMcpAdd.ts` (+135 -0) 📝 `src/cliOutput.ts` (+1 -0) 📝 `tests/boundary/cli/dispatcher.test.ts` (+1 -1) ➕ `tests/boundary/cli/windowsMcpAdd.test.ts` (+124 -0) </details> ### 📄 Description ## Summary Fixes #5811. On Windows, `rea mcp add --agent <id>` failed before touching any client configuration because Incur's registration spawns a bare `npx`, which Node cannot execute without a shell on Windows (`spawn npx ENOENT`). REA's own `rea setup --client <id>` already registers the same agents on Windows through the verified launcher, so the dispatcher now delegates to it there and says so. ## Problem and expected behavior Trigger: `node scripts/rea.mjs mcp add --agent codex` on Windows 11 with Node 24. Observed: `spawn npx ENOENT`. Expected: the agent is registered, or REA refuses with a reason it can stand behind. ## Change and scope `src/cli/windowsMcpAdd.ts` decides, for `win32` and `mcp add` only, whether to delegate. It selects the command from the shared builtin argument split (`splitIncurBuiltinArguments` over `normalizeCliArguments`), so output flags in any position (`rea --json mcp add`, `rea mcp --json add`) are recognized and kept, and `--help`, `-h`, `--schema` and `--llms` go to Incur unchanged. It ships in the compiled CLI runtime through `src/cliOutput.ts`, the launcher's existing entry, so the package needs no new file. `--agent` values map to setup client ids (`claude-code` becomes `claude_code`), `--dry-run` and output flags with their values pass through, and `--yes` is added so setup does not prompt. Options setup cannot honor are refused with a message instead of being dropped silently: `--no-global` (setup registers globally only), `--command` / `-c` (setup registers its own launcher), and a missing `--agent` (Incur's auto-detection is the part that spawns `npx`). Other platforms and other commands are untouched. `scripts/rea.mjs` applies the decision before Incur sees the arguments, and skips it in shell-completion mode (`COMPLETE=<shell>`), where the words on the line are completion input rather than a command. Contribution scope: an ordinary fix within an existing boundary; no maintainer scope decision needed (no target execution, injection, mutation or protection recovery). ## Contract and boundary impact - Semantic owner and earliest changed stage: the CLI dispatcher (`scripts/rea.mjs`), before Incur; command selection reuses the builtin argument owner in `src/cliBuiltinArguments.ts`. - Contribution scope fit and linked maintainer decision: not applicable (ordinary fix). - CLI and MCP/tool-catalog contract: `rea mcp add` on Windows now behaves like `rea setup --client`; three option combinations exit 1 with a stated refusal instead of failing with ENOENT. No MCP catalog change. - Provider, bridge, target-format, or platform compatibility: Windows only; Linux and macOS unchanged (covered by tests). - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none; the helper is part of `dist/cli-runtime`, which the package already ships. Expected effects: - [x] Documentation or usability only; no target interaction. ## Evidence and regression coverage - Tests added: `tests/boundary/cli/windowsMcpAdd.test.ts` (17 tests): no change off Windows or for other commands; agent-name mapping; delegation keeps `--dry-run` and output flags and adds `--yes`; `mcp add` is selected with output flags before, between and after the command words, including a valued flag whose value is `add`; help, `-h` and `--schema` are left to Incur; refusals for `--no-global`, `--command`, `-c` and a missing `--agent`; on a real Windows host, `mcp add --agent codex --dry-run` through `scripts/rea.mjs` prints the delegation note and a planned `configure_client:codex` without writing, and `mcp add --help` shows Incur's help. `tests/boundary/cli/dispatcher.test.ts` stubs the new `cliOutput` export like the others. - Base reproduction: before the change, the same command on Windows ended with `spawn npx ENOENT` (captured in the author's evidence log); after, exit 0 with the plan. - User-visible output on Windows 11 with Node 24.22.1, branch head aecb360aa: ```text Windows: rea mcp add delegates to rea setup --client codex --dry-run because Incur's registration cannot spawn npx here (#5811). T REA setup plan ◆ Ready to review │ UPDATE Codex │ C:Users<user>.codexconfig.toml │ backup: C:Users<user>.codexconfig.toml.rea.backup │ Add the REA MCP registration for Codex; preserve unrelated configuration. ... │ INSTALL REA reverse-engineering skill — Dry run complete. No changes were made. ``` - Remaining proof gaps: the non-dry-run write path was exercised only through `rea setup`'s own existing coverage; `--no-global` users must register the project entry by hand, as the refusal says. After merging main 8d8d85ba2 the live Windows test first failed on the author's host only because main now requires Node.js >=24.22.1 (#6315) and the host still had 24.19.0; after upgrading the host to 24.22.1 it passes. ## Validation performed - `npm run test:focused -- tests/boundary/cli/windowsMcpAdd.test.ts tests/boundary/cli/dispatcher.test.ts` on Windows 11 (Ales), Node 24.22.1, merged with main 425776174 — 30 passed (30), including both live Windows tests - `npm run build:cached` and `npm run check:fast` — 3 of 3 and 2 of 2 tasks successful - Packed entrypoint: `npm pack`, extracted, then from the extracted `package/`: `node scripts/rea.mjs --version` printed 6.7.0, `mcp add --help` exited 0, and `--json mcp add --agent codex --dry-run` printed the delegation note and a JSON plan with `configure_client:codex` (dependencies linked from the checkout's `node_modules`) - `COMPLETE=bash node scripts/rea.mjs mcp add --agent codex` on Windows — no delegation note and no setup plan, so completion is untouched (manual check; no automated test covers this path) ## Compatibility, safety, and release - Breaking changes or migration steps: none. On Windows, `rea mcp add --no-global` and `--command` now fail fast with a reason instead of failing with ENOENT. - Real Hopper/Ghidra, browser, or OS coverage: Windows 11 real run (dry-run); Linux and macOS by unit tests only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new process is spawned; delegation reuses setup's verified launcher resolution. ## Author readiness Human owner: @agnaylor - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7295
No description provided.