Repository navigation
feat(setup): add native Pi client support - #1376
Conversation
Keep malformed Pi path evidence on its client entry so unrelated selected clients can complete setup and doctor. Preserve explicit Pi rejection and block filesystem operations rather than falling back to another directory.
Pi's installed MCP loader reads mcp.json with a bare JSON.parse and no BOM tolerance, so comments, trailing commas, a BOM, or an empty existing file yield loader errors and no servers. Parsing the Pi dialect with objectSchema.parse(JSON.parse(text)) before the shared empty/JSONC shortcut rejects those files at every mutation boundary instead of reporting configured registrations Pi cannot load. A missing file still initializes a fresh strict-JSON document, other dialects keep their JSONC/BOM/empty tolerance, and malformed files are never rewritten.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: I tested this on Linux. Everything passed. The Pi (MIT) setup works end to end. Edit: added the Pi license. Tests
Real use I used a fresh, empty home folder.
I also tried two more cases.
Small notes
Not run Edit: these ran on main after the merge, in the follow-up. All four passed. Still not run: Windows paths. N0zoM1z0 ran real Pi on Linux.
Thanks for this, Richard! Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
# Conflicts: # src/application/SupportedClients.ts
|
Verified native Pi 1.1.0 (@earendil-works/pi-coding-agent) against the merged implementation and a production-only installed REA tarball on Linux x64: plain chat, default codemode, all 139 server tools, actual skill read, Unicode analysis target and complete schema-valid Evidence written through Pi's native tool all passed. Owned shutdown was clean. Repeatable checks: #1511. Loopback model only; live provider/Windows and default OS-home skill discovery remain unverified. |
|
TL;DR: I rechecked Pi (MIT) setup on main after the merge, alone and next to Hermes Agent (MIT). Each skill landed in its own folder, and setting up one client left the other's files alone. The full check, the docs check, the package check and N0zoM1z0 already ran native Pi 1.1.0 against the merged code. This comment adds the shared-home checks and runs my old Not run list. All runs used main
The 102-line function warning from my first comment is gone on main. Small notes
Edit: I ran Pi 1.2.0 on main 9d6651e (#4131) after the merge. It connected to REA and listed 207 tools. Results are in my new comment. Still not run: a Pi turn with a model, Windows paths, and removing one client alone. Still not run
Thanks, rasatpetabit, for the Pi client and the strict JSON handling. Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
* feat(setup): add native Pi client support * fix(setup): isolate invalid Pi agent directory overrides Keep malformed Pi path evidence on its client entry so unrelated selected clients can complete setup and doctor. Preserve explicit Pi rejection and block filesystem operations rather than falling back to another directory. * fix(setup): parse Pi configuration as strict JSON Pi's installed MCP loader reads mcp.json with a bare JSON.parse and no BOM tolerance, so comments, trailing commas, a BOM, or an empty existing file yield loader errors and no servers. Parsing the Pi dialect with objectSchema.parse(JSON.parse(text)) before the shared empty/JSONC shortcut rejects those files at every mutation boundary instead of reporting configured registrations Pi cannot load. A missing file still initializes a fresh strict-JSON document, other dialects keep their JSONC/BOM/empty tolerance, and malformed files are never rewritten. --------- Co-authored-by: morluto <[email protected]>
|
TL;DR: This PR merged, so I ran my last open item on main: real Pi (MIT). Pi 1.2.0 read the config that REA setup wrote, connected, and listed 207 tools. I did not chat with a model through Pi. This comment is a record. The PR merged as 9e22da8 (#1376). My last comment listed three Not run items. I ran the first one on main at 9d6651e (#4131). Thanks, rasatpetabit, for the Pi client. What I ran
N0zoM1z0 already ran Pi 1.1.0 end to end, with a loopback model. This run adds a newer Pi, and the config that today's main writes. It does not add a model turn. Two small notes, checked on main
Still not run
Commandsnpm install --prefix <tmp>/pi <the Pi coding agent package, version 1.2.0>
HOME=<empty tmp home> node scripts/rea.mjs setup --client pi --yes
HOME=<empty tmp home> PI_OFFLINE=1 <tmp>/pi/node_modules/.bin/pi mcp list
HOME=<empty tmp home> node scripts/rea.mjs uninstall --helpI ran Pi with Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
Summary
Add first-class native Pi support to REA's existing client setup, doctor, and uninstall flows.
Pi users can already run REA's stdio MCP server by hand, but REA has no
piclient, sorea setupcannot discover or register Pi andrea doctorcannot diagnose a Pi registration. This adds--client pias a distinct client. It is not an alias of OMP (oh-my-pi), which uses a different directory, profiles, and server allow/deny lists.No Pi-specific issue or PR was found in this repository. This is a focused extension of the existing client-adapter system, alongside the separate OMP integration (#1301).
Problem and expected behavior
Pi reads user MCP registrations from
~/.pi/agent/mcp.json, or from the agent directory selected byPI_CODING_AGENT_DIR(MCP docs, agent-directory resolver). Reusing OMP's behavior would select the wrong file and misread Pi'senabled: false.Expected behavior: a scoped, additive registration that preserves unrelated configuration, installs REA's bundled skill where Pi already discovers skills, and works with the existing dry-run/approval, doctor, and owned-only uninstall flows:
Change and scope
pi/Pi/pi.~expansion; absolute paths; file URLs; relative paths resolved against the working directory (never silently replaced by the default); Windows native,~\, and Git Bash/MSYS, Cygwin, and WSL drive paths.JSON.parse). Comments, trailing commas, a byte-order mark, and empty files are reported as invalid and never rewritten. A missing file is created as valid JSON. Other clients keep their existing JSONC/BOM/empty-file tolerance.stdio, reports other transports as invalid, and treatsenabled: falseas disabled.enabledServers/disabledServershandling OMP-only.PI_CODING_AGENT_DIRfrom breaking other clients. Previously, an invalid value (for examplefile:///agent%2fdir) threw during client enumeration, so evenrea setup --client codexfailed. The error now stays on Pi's entry: scoped setup/doctor for other clients succeeds, and selecting Pi fails closed with remediation and no filesystem access to a fallback directory.~/.agents/skills, which Pi discovers..pi/mcp.jsonoverrides,/mcpreplacement extensions, and/reload.Not included: project-scope setup, installing Pi or analysis providers, provider/native-analysis changes, or MCP tool changes. Generated catalogs and
skills/are not committed.Contract and boundary impact
SupportedClients.ts), then configuration parsing (ClientConfigurationDocument.ts).pivalue for the existing--clientoption on setup, doctor, and uninstall; no MCP tool or result-schema change.docs/public/product-catalog.json), package, or installation impact: supported-client metadata derives from the registry through existing generators; no build outputs committed.Evidence and regression coverage
Tests added or updated:
tests/boundary/filesystem/piClientConfiguration.test.ts(new): path resolution across override forms and platforms, OMP isolation, preservation, idempotency, owned-only uninstall, transport/enableddoctor states, and a strict-JSON matrix (comment, trailing comma, BOM-prefixed, empty, whitespace-only, BOM-only): parse rejected, setup fails before writing, doctorinvalid, uninstall preserves bytes, no backup created. It also covers missing-file initialization and confirms another JSON client still accepts the same inputs.tests/boundary/cli/piClientSetup.test.ts(new): public CLI in an isolated temporary home covering plan → approval → apply → doctor → repeat → uninstall; malformedPI_CODING_AGENT_DIRwith scoped Codex setup/doctor; missing-file creation; and malformed-fileneeds_humanwith no planned or applied actions.clientConfigurationDialects.test.ts,clientLifecycle.test.ts: Pi added to the shared dialect and lifecycle tables.Base reproduction or other evidence: the new tests were written first and failed before each production change: missing
piclient (38 failed), strict-JSON parsing (7 failed), and the malformed-override case through the real CLI.Consumer check: a separate probe packed this branch, ran its packaged CLI in an isolated home, and then loaded the result with Pi v1.1.0's own modules (
loadMcpConfig,McpServerConnection, the skill loader). It confirmed:enabled: falseoverride was honored.No Pi CLI, LLM, or interactive session was launched.
User-visible CLI/MCP output (trimmed, temporary home shown as
~):Remaining proof gaps: Windows path handling is covered by unit tests on Linux, not a native Windows Pi run. The Pi check exercises Pi's real loaders, not a full interactive session. Non-default
PI_CODING_AGENT_DIRforms are tested against Pi's resolver semantics, not through the live loader.For evidence-bearing changes:
Validation performed
On
c0713c8rebased ontomainata9f5dad, with Node.js 24.18.0 / npm 11.16.0 (the repository pins):npm run test:focused --with the 10 client/configuration test files (Pi, OMP, dialects, lifecycle, Pi CLI, registration status, setup skill, transactions, BOM, update maintenance) — passed, 184 testsnpm run verify:test-discovery— passed, 698 files discovered exactly oncenpm run check— passed, includingverify:architecture-guards; only existing lint warnings remainnpm run docs:check— passednpm run verify:package— passednpm pack --dry-run— passed, 1,052 filesPackaged REA → Pi v1.1.0 loader probe described above — passed
npm test— 6,098 passed, 8 failed, 89 skipped. All 8 failures are in firmware tests this PR does not touch, and they also fail on unmodifiedmainon this host:firmwareIntegration.test.ts(7 cases) andfirmwareMcp.test.ts(1 case) fail withUnsupported tool version 26.6.4; accepted releases are Binwalk 3.1.x.realpath('/usr/bin/true')is/usr/bin/gnutrue. The firmware test fixture detects its fake engine by a/truepath suffix, so it misidentifies the engine and reports the wrong version. It is a fixture/host interaction, not a Binwalk installation issue; I can file it separately if useful.An earlier full run, before rebasing onto current
main, also had three timing failures in unchanged process tests (localToolContracts.test.ts,processCaptureNormalization.test.ts). Those passed in this run and when run alone.Compatibility, safety, and release
/reloadto pick up a new registration.Review checklist
type(scope): outcome.Maintainer validation after updating main
Updated the contributor branch to current main with merge commit
d335cff69, resolving the path-import conflict with the merged Qwen home fix without rewriting contributor commits. Review found no additional Pi-specific behavior correction needed beyond that integration conflict.On macOS with Node 24.18.0 / npm 11.16.0, 102 tests passed across Pi filesystem configuration, Pi public CLI setup, shared client lifecycle, and Qwen path coverage.
npm run check,npm run docs:check,npm run verify:package, andnpm pack --dry-runpassed. The package verifier discovered 139 MCP tools and verified the bundled skill and Skills 1.7.2 repository discovery. This maintainer pass did not repeat the contributor's native Pi loader probe or run a Windows/interactive Pi session.