feat(server): add pi coding agent extension support#26
Conversation
Add @distracted/pi-extension package that integrates with pi coding agent. CLI now supports --setup pi, --remove pi, and --status shows pi config.
There was a problem hiding this comment.
Pull request overview
Adds first-class support for the Pi coding agent alongside Claude Code and OpenCode by wiring a new @distracted/pi-extension package into the local server’s hook and CLI setup flow.
Changes:
- Extends the server’s hook payload and setup/CLI plumbing to recognize Pi as an additional agent (
source: "pi",--setup/--remove pi, and--statusreporting). - Introduces the
@distracted/pi-extensionpackage that subscribes to Pi lifecycle events and posts standardized hook payloads to the local distracted server. - Updates documentation and lockfile metadata to describe/track the new Pi integration and the OpenCode config path.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/server/src/types.ts |
Extends HookPayload.source to include "pi" so server-side state can attribute hooks to the new agent. |
packages/server/src/setup/pi.ts |
Adds Pi setup/remove helpers that manage ~/.pi/agent/settings.json to register/unregister the @distracted/pi-extension. |
packages/server/src/setup/index.ts |
Plumbs Pi into the generic setup/remove/status orchestration (agent type union, menu labels, status aggregation, and dispatch). |
packages/server/src/bin.ts |
Extends CLI parsing/options and status output so --setup/--remove/--status understand the pi agent and include it in “all”. |
packages/server/README.md |
Documents Pi as a supported agent, its config location, and the updated CLI usage examples. |
packages/pi-extension/tsconfig.json |
Configures TypeScript compiler options for the new Pi extension package. |
packages/pi-extension/src/index.ts |
Implements the Pi extension: listens to Pi events, derives a session ID, and POSTs standardized hook payloads (including source: "pi") to the distracted server. |
packages/pi-extension/package.json |
Defines the published Pi extension package, including dev tooling and the pi.extensions entry that points to ./src/index.ts. |
packages/pi-extension/knip.json |
Sets up Knip to analyze the Pi extension entrypoint and ignore unused TypeBox dependency. |
packages/pi-extension/README.md |
Documents installation, configuration, lifecycle event mapping, and removal flow for the Pi extension (with one inaccurate claim about CLI-driven global install noted in review). |
bun.lock |
Updates the Bun lockfile to include the new @distracted/pi-extension workspace and its dependency tree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cwd?: string; | ||
| transcript_path?: string; | ||
| source?: "claude" | "opencode"; | ||
| source?: "claude" | "opencode" | "pi"; |
There was a problem hiding this comment.
Now that HookPayload.source includes the new "pi" variant, the HTTP handler in src/server.ts still only preserves "claude" and "opencode" values when mapping data.source into the HookPayload (all other values, including "pi", are dropped to undefined). To keep the type in sync with runtime behavior and ensure Pi-sourced hooks can be distinguished downstream, please update the source assignment in src/server.ts to also accept and forward "pi" as a valid value.
| source?: "claude" | "opencode" | "pi"; | |
| source?: "claude" | "opencode"; |
| This will: | ||
|
|
||
| 1. Install the extension globally (if needed) | ||
| 2. Configure pi's `~/.pi/agent/settings.json` to load the extension | ||
|
|
There was a problem hiding this comment.
The installation section claims that running bunx @distracted/server --setup pi will "Install the extension globally (if needed)", but the current @distracted/server implementation only updates ~/.pi/agent/settings.json and never performs a global @distracted/pi-extension install. To avoid confusing users who haven't installed the package yet, please either adjust this text to describe only the configuration step or add explicit instructions here (or in the server docs) to run npm install -g @distracted/pi-extension before using the CLI setup path.
Adds
@distracted/pi-extensionpackage that integrates with the pi coding agent. The extension subscribes to pi lifecycle events and sends hook payloads to the local server, same as Claude Code and OpenCode integrations.CLI changes:
--setup pi/--remove pito configure the extension--statusnow shows pi configuration state