Skip to content

feat(setup): add native Pi client support - #1376

Merged
morluto merged 5 commits into
morluto:mainfrom
rasatpetabit:feat/pi-client-support
Oct 10, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
rasatpetabit:feat/pi-client-support

Conversation

@rasatpetabit

@rasatpetabit rasatpetabit commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 pi client, so rea setup cannot discover or register Pi and rea doctor cannot diagnose a Pi registration. This adds --client pi as 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 by PI_CODING_AGENT_DIR (MCP docs, agent-directory resolver). Reusing OMP's behavior would select the wrong file and misread Pi's enabled: 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:

rea setup --client pi --dry-run --json
rea setup --client pi --yes --json
rea doctor --client pi --json

Change and scope

  • Add the client identifier / display name / dialect pi / Pi / pi.
  • Resolve the config path with Pi's agent-directory semantics: unset or empty selects the default; ~ 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.
  • Parse existing Pi config files as strict JSON, matching Pi's loader (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.
  • Write an ordinary stdio registration. Doctor accepts omitted or explicit stdio, reports other transports as invalid, and treats enabled: false as disabled.
  • Keep OMP profiles and enabledServers/disabledServers handling OMP-only.
  • Keep a malformed PI_CODING_AGENT_DIR from breaking other clients. Previously, an invalid value (for example file:///agent%2fdir) threw during client enumeration, so even rea setup --client codex failed. 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.
  • Reuse the existing bundled-skill installation to ~/.agents/skills, which Pi discovers.
  • Document user scope, strict JSON, trusted-project .pi/mcp.json overrides, /mcp replacement 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

  • Semantic owner and earliest changed stage: supported-client registry and client configuration-path resolution (SupportedClients.ts), then configuration parsing (ClientConfigurationDocument.ts).
  • CLI and MCP/tool-catalog contract: additive pi value for the existing --client option on setup, doctor, and uninstall; no MCP tool or result-schema change.
  • Provider, bridge, target-format, or platform compatibility: none for providers. Pi path resolution is platform-aware.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Process execution, authorization, cleanup, or containment impact: uses the existing dry-run/approval, ownership, backup, readback, and uninstall machinery. A malformed Pi config or override fails closed without mutation.
  • Generated metadata (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/enabled doctor states, and a strict-JSON matrix (comment, trailing comma, BOM-prefixed, empty, whitespace-only, BOM-only): parse rejected, setup fails before writing, doctor invalid, 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; malformed PI_CODING_AGENT_DIR with scoped Codex setup/doctor; missing-file creation; and malformed-file needs_human with 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 pi client (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:

    • Pi connected over stdio and discovered 139 tools.
    • Pi automatically discovered the shared skill.
    • A trusted-project enabled: false override was honored.
    • Pi rejects the malformed files that REA now refuses.
    • The missing-file path initializes a config Pi loads.

    No Pi CLI, LLM, or interactive session was launched.

  • User-visible CLI/MCP output (trimmed, temporary home shown as ~):

    // rea setup --client pi --dry-run --json  (existing mcp.json with an unrelated server)
    { "status": "planned",
      "plannedActions": [
        { "id": "configure_client:pi", "target": "~/.pi/agent/mcp.json", "operation": "update",
          "detail": "Add the REA MCP registration for Pi; preserve unrelated configuration. …",
          "backupPath": "~/.pi/agent/mcp.json.rea.backup" },
        { "id": "install_skill", "target": "~/.agents/skills/reverse-engineer-anything", … } ],
      "appliedActions": [] }
    
    // rea setup --client pi --yes --json
    { "status": "ready", "appliedActions": ["configured_pi", "installed_skill"],
      "clients": { "pi": { "status": "configured", "backupPath": "~/.pi/agent/mcp.json.rea.backup" } } }
    
    // rea doctor --client pi --json
    { "healthy": true,
      "scope_checks": [ …, { "name": "registration:pi", "ok": true, "detail": "~/.pi/agent/mcp.json" } ] }
    
    // rea setup --client pi --dry-run --json  (mcp.json containing a // comment; exit 1)
    { "status": "needs_human", "plannedActions": [], "appliedActions": [],
      "remediation": "Pi: The existing configuration is malformed. Repair it before setup applies any other changes." }
  • 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_DIR forms are tested against Pi's resolver semantics, not through the live loader.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

On c0713c8 rebased onto main at a9f5dad, 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 tests

  • npm run verify:test-discovery — passed, 698 files discovered exactly once

  • npm run check — passed, including verify:architecture-guards; only existing lint warnings remain

  • npm run docs:check — passed

  • npm run verify:package — passed

  • npm pack --dry-run — passed, 1,052 files

  • Packaged 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 unmodified main on this host:

    • firmwareIntegration.test.ts (7 cases) and firmwareMcp.test.ts (1 case) fail with Unsupported tool version 26.6.4; accepted releases are Binwalk 3.1.x.
    • On this Ubuntu 26.04 host, realpath('/usr/bin/true') is /usr/bin/gnutrue. The firmware test fixture detects its fake engine by a /true path 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

  • Breaking changes or migration steps: none. Existing clients are unchanged, including their parsing tolerance. Running Pi sessions need /reload to pick up a new registration.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux only, using Pi's real config/skill/MCP loaders. No provider behavior changed, so no Hopper/Ghidra/IDA run. Windows paths are covered by unit tests only.
  • Package or release metadata impact: additive supported-client metadata through existing generators; no version bump.
  • Security, privacy, process, or containment review: the focus is selecting the right destination file, isolating other clients from a malformed Pi override, preserving unrelated configuration, and failing closed on malformed or disabled registrations. No credentials are stored and nothing new is executed.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

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, and npm pack --dry-run passed. 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.

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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I tested this on Linux. Everything passed. The Pi (MIT) setup works end to end.

Edit: added the Pi license.

Tests

  • The four Pi test files: 113 of 113 passed.
  • Full npm test: 6,106 passed, 89 skipped, none failed. 687 test files passed. 11 were skipped. It took 9.6 minutes.
  • The firmware tests passed here too. On this box, /usr/bin/true is not a link to gnutrue. That fits what you found.
  • Typecheck passed. Oxlint passed with warnings only.

Real use

I used a fresh, empty home folder.

  • Dry run planned two steps. It wrote nothing.
  • Setup without --yes asked for approval. It wrote nothing.
  • Setup with --yes wrote ~/.pi/agent/mcp.json. It also added the skill under ~/.agents/skills.
  • Doctor said healthy. The Pi entry was "aligned".
  • A second setup did nothing, as it should.
  • I started the saved command by hand. It listed 139 tools.
  • Uninstall took out the REA entry and the skill.

I also tried two more cases.

  • A file with another server: setup kept it. Uninstall left the same data as before.
  • A file with a comment: setup refused and changed nothing.

Small notes

  • Uninstall leaves an empty mcp.json and a backup file. OMP does the same, so this is not new.
  • Oxlint shows one new warning. It is in ClientRegistrationStatus.ts. The status function is now 102 lines. The limit is 100. The PR text says only old warnings remain.

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.

  • Pi itself. It is not installed here. N0zoM1z0 covered it with Pi 1.1.0.
  • Windows paths.
  • The full npm run check. Part of it needs a git repo. I tested from an export, not a clone. Passed from a real clone.
  • docs:check, verify:package and npm pack.

Thanks for this, Richard!

Test setup
  • Box: Fedora 44 (Nobara) on x86-64
  • Node: 24.18.0
  • Head: commit c0713c8
  • Other: npm 11.16.0

🤖 Generated with Claude Code (Opus 5.5) 🦊

# Conflicts:
#	src/application/SupportedClients.ts
@morluto
morluto merged commit 9e22da8 into morluto:main Oct 10, 2026
18 checks passed
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

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.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 npm pack all passed.

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 983b070d4 in fake home folders.

Pi and Hermes check Result
Pi alone, file with another server Kept the other server. Uninstall gave back the same data.
Pi file with a comment Refused. Wrote nothing.
Pi and Hermes in one setup Pi skill in ~/.agents/skills. Hermes skill in ~/.hermes/skills. Doctor: both aligned.
Hermes first, then doctor for Pi Skill missing, which is right. Pi's folder was empty.
Then Pi setup No Hermes file changed.
Then Hermes setup again No actions. No Pi file changed.
Uninstall Removed both entries and both skills.
Old Not run item Result
npm run check from a clone Pass. Oxlint: 502 warnings, no errors.
npm run docs:check Pass
npm run verify:package Pass. 139 tools. Repeat setup made no change.
npm pack Pass. 1,059 files, 1.3 MB. Has the skill. No tests or source.

The 102-line function warning from my first comment is gone on main.

Small notes

  • rea uninstall has no --client option. So I could not remove Pi and keep Hermes. It removes both.
  • The bundled SKILL.md lists client IDs, but pi, hermes and qwen_code are missing from that list.

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

  • Pi itself. It is not installed here, but N0zoM1z0 covered the real Pi run. Ran Pi 1.2.0 without a model: pi mcp list connected.
  • Windows paths.
  • Uninstalling one client and keeping the other, since uninstall has no option for that. (Still true on main.)

Thanks, rasatpetabit, for the Pi client and the strict JSON handling.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB
  • Node: 24.18.0, npm 11.16.0
  • Head: 983b070d4 (merge 9e22da845)

🤖 Generated with Claude Code (Opus 5.5) 🦊

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
* 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]>
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@CassieFox23

Copy link
Copy Markdown
Contributor

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

  • I installed Pi 1.2.0 from npm into a temp folder, with an empty home folder.
  • I ran rea setup --client pi --yes from main. It wrote ~/.pi/agent/mcp.json and the skill, both inside that empty home folder.
  • I ran pi mcp list. Pi started the saved REA command by itself. The output said: rea: connected, 207 tools (codemode, global). Exit code 0.

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

  • rea uninstall still has no --client option. Its only option is --purge-data. So removing one client and keeping the other is not possible yet.
  • The bundled SKILL.md still leaves pi, hermes and qwen_code out of its client list. The connection-and-recovery.md file next to it has all three.

Still not run

  • Pi with a model. I would need a model endpoint, and I used none.
  • Windows paths.
  • Removing one client and keeping the other. There is no option for it.
Commands
npm 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 --help

I ran Pi with env -i, so it saw only the empty home folder. I deleted the Pi install afterward.

Test setup

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto morluto added the area: setup Setup, packaging, upgrade, install, Doctor, and client registration label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior area: setup Setup, packaging, upgrade, install, Doctor, and client registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants