Skip to content

Add Pi coding-agent provider#3818

Open
ahmadaccino wants to merge 5 commits into
pingdotgg:mainfrom
ahmadaccino:feat/pi-provider
Open

Add Pi coding-agent provider#3818
ahmadaccino wants to merge 5 commits into
pingdotgg:mainfrom
ahmadaccino:feat/pi-provider

Conversation

@ahmadaccino

@ahmadaccino ahmadaccino commented Jul 9, 2026

Copy link
Copy Markdown

Summary

  • Adds Pi (@earendil-works/pi-coding-agent) as a selectable coding-agent provider, alongside Codex / Claude / Cursor / Grok / OpenCode.
  • Integrates via Pi's native pi --mode rpc JSONL protocol over the shared Effect ChildProcessSpawner. The Pi package is a types-only devDependency — the user's installed pi binary is the runtime, so nothing heavy is bundled.
  • Disabled by default and gated behind the normal provider settings — no behavior change for anyone who doesn't enable Pi.
  • Mirrors the existing providers' structure end-to-end (driver / adapter / provider snapshot / text generation / web settings) so Pi stays consistent and low-surprise — it is not a special case.

What's included

Server (apps/server)

  • PiRpcClient — typed JSONL transport over ChildProcessSpawner (stdin-writer + stdout-reader fibers, request/response correlation, scoped teardown) plus pure, unit-tested parse/extract helpers.
  • PiAdapter — per-thread sessions, text_delta streaming, tool lifecycle, finalize on agent_end, mid-turn steer, image attachments, in-session model switch + thinking level, and fork-based rollback. Emits the same canonical runtime events as the other adapters (including thread.started for projection parity, and exitKind: "error" on unexpected exit).
  • Tool-approval gate driven by runtimeMode (like Claude/Cursor): a bundled, default-deny Pi extension is injected via --extension and verified with a get_commands load handshake (fail-closed), bridging Pi's extension_ui requests to the canonical approval / user-input events.
  • PiProviderpi --version probe, live model discovery (get_available_models), and a models-based auth verdict (mirrors OpenCode).
  • PiTextGeneration — stateless RPC + get_last_assistant_text, reusing the shared JSON extractor.

Contracts & web

  • PiSettings + driver-kind wiring; pi.rpc.* runtime raw sources.
  • Pi surfaced in provider settings, the model picker, and icons — identical wiring to the other drivers.

Docs

  • Adds docs/providers/pi.md; lists Pi (and Grok) in the README.

Testing

  • vp check
  • vp run typecheck
  • vp test (server, contracts, and web suites; new Pi unit + integration tests included)
  • Live-validated against a real pi install: session lifecycle, mid-turn steer, model/thinking switch, fork rollback, and the tool-approval round-trip (default-deny gate blocking bash).
  • Not run: vp run lint:mobile (no native mobile changes).

Notes


Note

Medium Risk
Large new subprocess and tool-approval path, but it mirrors existing providers, defaults off, and fails closed when the approval gate cannot load.

Overview
Adds Pi as a first-class, disabled-by-default coding-agent provider wired like Codex/Claude/Cursor: driver, adapter, health/model snapshot, text generation, contracts, settings UI, and docs.

The server talks to the user’s pi --mode rpc process over a new JSONL RPC transport, mapping Pi events into the shared runtime model (streaming, tools, approvals, user prompts, model/thinking switches, fork-based rollback). Tool approval loads a bundled Pi extension at build time and refuses to start gated sessions unless the extension registers its sentinel command. Pi is removed from the “coming soon” add-provider list and promoted to the live picker (Early Access).

Reviewed by Cursor Bugbot for commit ab7cefa. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Pi coding-agent as a provider with RPC adapter, text generation, and tool approval gate

  • Adds a full Pi provider integration: settings schema, driver registration, UI icons, and model discovery via a short-lived pi --mode rpc session.
  • Introduces PiAdapter that manages per-thread RPC sessions, streams assistant/reasoning events, and bridges tool approval and user-input requests via Pi's extension-ui protocol.
  • Introduces PiTextGeneration that prompts the Pi CLI in RPC mode and returns schema-validated, sanitized commit messages, PR content, branch names, and thread titles.
  • Bundles a t3-approvals Pi extension that blocks tool calls by default and requires explicit user confirmation unless T3_PI_APPROVAL_MODE=auto-accept-edits.
  • For the pi provider, resolveModelSlug returns an empty string instead of falling back to a default model, since available models are discovered live per account.
  • Risk: the Pi CLI binary must be installed and accessible; missing binary reports a distinct "not installed" status rather than a generic error.

Macroscope summarized ab7cefa.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a613f2cf-319d-4d4a-bd8d-c4c7e409b6a4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/textGeneration/PiTextGeneration.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiProvider.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/assets/pi/t3-approvals.ts
Comment thread apps/server/src/provider/Layers/PiRpcClient.ts
Comment thread apps/server/src/provider/Layers/PiProvider.ts Outdated
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiRpcClient.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiRpcClient.ts Outdated
Comment thread apps/server/scripts/cli.ts
Comment thread packages/contracts/src/model.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
@macroscopeapp

macroscopeapp Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

4 blocking correctness issues found. Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

You can customize Macroscope's approvability policy. Learn more.

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect service conventions: two issues in the new PiTextGeneration.ts. Both have a canonical precedent in the same directory (OpenCodeTextGeneration.ts).

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/textGeneration/PiTextGeneration.ts Outdated
Comment thread apps/server/src/textGeneration/PiTextGeneration.ts Outdated
Comment thread apps/server/src/provider/Layers/PiRpcClient.ts
Comment thread apps/server/src/textGeneration/PiTextGeneration.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts Outdated
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
- PiSettings/PiSettingsPatch (enabled, binaryPath, customModels) on ServerSettings
- pi driver kind display name + MODEL_SLUG_ALIASES passthrough entry
- pi.rpc.event / pi.rpc.extension-ui runtime raw sources
RPC-mode (pi --mode rpc) driver over the Effect ChildProcessSpawner:
- PiRpcClient JSONL transport + pure parsing/extraction helpers
- PiAdapter: sessions, text_delta streaming, tool lifecycle, finalize on the
  terminal agent_end, mid-turn steer, image attachments, in-session model switch
  + thinking level, fork-based rollback; thread.started for projection parity;
  unexpected-exit reported as error
- Approval gate driven by runtimeMode (like Claude/Cursor): bundled default-deny
  t3-approvals extension injected via -e with a get_commands load handshake
  (fail-closed); extension_ui <-> canonical approval/user-input bridge
- PiProvider: version probe, live model discovery, models-based auth verdict
- PiTextGeneration via stateless RPC + get_last_assistant_text + shared JSON extract
- @earendil-works/pi-coding-agent devDependency (types only); ship the gate asset
Also ignore local agent scratch dirs (.pi-subagents, .repos/pi-pr-analysis).
Comment thread apps/server/src/provider/Layers/PiProvider.ts
Comment thread apps/server/src/textGeneration/PiTextGeneration.ts Outdated
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/Layers/PiAdapter.ts
Comment thread apps/server/src/provider/assets/pi/t3-approvals.ts
maxschulmeister added a commit to maxschulmeister/t3code that referenced this pull request Jul 13, 2026
Local merge of Add Pi coding-agent provider for DMG build.
@harshav167

harshav167 commented Jul 16, 2026

Copy link
Copy Markdown

Hi @ahmadaccino, are you still actively maintaining this PR and open to contributions? I would like to help finish and harden the full Pi integration. If so, would you prefer focused PRs or commits against your feat/pi-provider branch, or should I continue the work on a separate branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants