pi-acp  by svkozak

ACP adapter for AI coding agents

Created 5 months ago
382 stars

Top 74.6% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides an ACP (Agent Client Protocol) adapter for the pi coding agent, enabling seamless integration with ACP-compatible editors like Zed. It bridges pi's advanced coding assistance capabilities, including tool execution, session management, and skill invocation, with editor features such as code completion, context-aware tool calls, and session history, streamlining developer workflows.

How It Works

The adapter facilitates communication via ACP JSON-RPC 2.0 over stdio, spawning pi --mode rpc as a subprocess. It intelligently maps pi's tool executions to ACP tool_call and tool_call_update events, surfacing relevant file locations within the editor. Relative file paths from pi are resolved against the session's current working directory, enhancing context fidelity. The adapter also handles session persistence by maintaining a mapping file, allowing pi sessions to be resumed across restarts.

Quick Start & Requirements

  • Prerequisites: Node.js 22+, pi installed and available on PATH (npm install -g @mariozechner/pi-coding-agent). Configure pi separately for model providers and API keys.
  • Installation:
    • ACP Registry (e.g., Zed): Use zed: acp registry command.
    • npx (no global install): Configure editor's settings.json with type: "custom", command: "npx", args: ["-y", "pi-acp"].
    • Global install: npm install -g pi-acp. Configure editor's settings.json with type: "custom", command: "pi-acp".
    • From source: npm install, npm run build, point editor to dist/index.js.
  • Configuration: Set PI_ACP_ENABLE_EMBEDDED_CONTEXT=true environment variable to advertise embeddedContext support.
  • Links: Official quick-start examples for Zed are provided in the README.

Highlighted Details

  • Streams assistant output as agent_message_chunk for real-time feedback.
  • Maps pi tool execution to ACP tool_call/tool_call_update, surfacing locations and structured diffs for edits.
  • Supports session persistence via ~/.pi/pi-acp/session-map.json, enabling session resumption.
  • Loads file-based and built-in slash commands (e.g., /compact, /session, /model, /skill:skill-name).
  • Emits "startup info" block (version, context, skills, prompts) by default, configurable via quietStartup: true.
  • Session history is supported in compatible ACP clients (e.g., Zed v0.225.0+), mapping to pi session files.

Licensing & Compatibility

  • License: MIT.
  • Compatibility: Designed for ACP clients, with primary development focus on Zed editor. pi operates locally; no ACP filesystem or terminal delegation is provided.

Limitations & Caveats

This is an MVP-style adapter; some ACP features are unimplemented or unsupported. Development is centered around Zed editor compatibility, with other clients potentially exhibiting varying levels of support. Expect minor breaking changes. The adapter lacks ACP filesystem (fs/*) and terminal (terminal/*) delegation, as pi reads/writes and executes locally. MCP servers are accepted but not directly wired through to pi. Assistant streaming is consolidated into agent_message_chunk, and slash commands from pi extensions are not supported. The /clear command is also not implemented.

Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
11
Issues (30d)
14
Star History
144 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.