@zoumo/gsd-pi-acp
v0.1.1
Published
ACP adapter for gsd and pi coding agents with dual backend support
Downloads
23
Maintainers
Readme
gsd-pi-acp
ACP (Agent Client Protocol) adapter for gsd and pi coding agents with dual backend support.
Fork notice: This project is forked from svkozak/gsd-pi-acp at version 0.0.24. See CHANGELOG for changes since the upstream baseline.
gsd-pi-acp communicates ACP JSON-RPC 2.0 over stdio to an ACP client (e.g. Zed editor) and spawns either gsd --mode rpc or pi --mode rpc, bridging requests/events between the two.
Dual Backend Support
gsd-pi-acp automatically detects which backend to use at startup:
- Auto-detection (default): Tries
gsdfirst, falls back topiif gsd is not available - Explicit override: Set
PI_ACP_PI_COMMANDenvironment variable to force a specific backend:PI_ACP_PI_COMMAND=gsd- use gsd backendPI_ACP_PI_COMMAND=pi- use pi backendPI_ACP_PI_COMMAND=/path/to/custom/binary- use custom binary
Session storage differs by backend:
- gsd backend: sessions stored in
~/.gsd/sessions/<cwd-hash>/ - pi backend: sessions stored in
~/.pi/agent/sessions/...
Status
This is an MVP-style adapter intended to be useful today and easy to iterate on. Some ACP features may be not implemented or are not supported (see Limitations). Development is centered around Zed editor support, other clients may have varying levels of compatibility.
Features
- Streams assistant output as ACP
agent_message_chunk - Maps gsd/pi tool execution to ACP
tool_call/tool_call_update- Tool call locations are surfaced when available for ACP clients that support opening the referenced file/context
- Relative file paths from gsd/pi are resolved against the session cwd before being emitted as ACP tool locations, which enables follow-along features in clients like Zed
- For
edit,gsd-pi-acpattempts to infer a 1-based line number from a uniqueoldTextmatch in the pre-edit file snapshot and includes it in the emitted tool location when possible - For
edit,gsd-pi-acpsnapshots the file before the tool runs and emits an ACP structured diff (oldText/newText) on completion when possible
- Session persistence
- gsd backend: sessions stored in
~/.gsd/sessions/<cwd-hash>/ - pi backend: sessions stored in
~/.pi/agent/sessions/... gsd-pi-acpstores a small session mapping file sosession/loadcan reattach to previous sessions
- gsd backend: sessions stored in
- Slash commands
- Loads file-based slash commands compatible with gsd/pi conventions
- Adds a small set of built-in commands for headless/editor usage
- Supports skill commands (if enabled in backend settings, they appear as
/skill:skill-namein the ACP client)
- Skills are loaded by gsd/pi directly and are available in ACP sessions
- MCP servers provided by ACP clients are written to
<cwd>/.gsd/mcp.jsonfor the gsd backend - (Zed)
gsd-pi-acpemits "startup info" block into the session (backend version, context, skills, prompts, extensions). You can disable it by settingquietStartup: truein backend settings (~/.gsd/settings.jsonor~/.pi/agent/settings.jsonor project-level settings). WhenquietStartupis enabled,gsd-pi-acpwill still emit a 'New version available' message if the installed backend version is outdated. - (Zed) Session history is supported in Zed starting with
v0.225.0. Session loading / history maps to backend session files. Sessions can be resumed both ingsd/piand in the ACP client.
Prerequisites
- Node.js 20+
gsdorpiinstalled and available on yourPATH(the adapter auto-detects which is available)- Configure your backend separately for model providers/API keys
Install gsd:
npm install -g gsd-pi@latestOr install pi:
npm install -g @mariozechner/pi-coding-agentInstall
From source (this fork)
git clone <this-repo>
cd gsd-pi-acp
npm install
npm run buildPoint your ACP client to the built dist/index.js:
"agent_servers": {
"gsd-pi": {
"type": "custom",
"command": "node",
"args": ["/path/to/gsd-pi-acp/dist/index.js"],
"env": {}
}
}Slash commands
gsd-pi-acp supports slash commands:
1) File-based commands (aka prompts)
Loaded from (depending on backend):
- gsd user commands:
~/.gsd/prompts/**/*.md - gsd project commands:
<cwd>/.gsd/prompts/**/*.md - pi user commands:
~/.pi/agent/prompts/**/*.md - pi project commands:
<cwd>/.pi/prompts/**/*.md
2) Built-in commands
/compact [instructions...]- run compaction (optionally with custom instructions)/autocompact on|off|toggle- toggle automatic compaction/export- export the current session to HTML in the sessioncwd/session- show session stats (tokens/messages/cost/session file)/name <name>- set session display name/steering- maps to Steering Mode, get/set/follow-up- maps to Follow-up Mode, get/set
Other built-in commands:
/model- maps to model selector in Zed/thinking- maps to 'mode' selector in Zed/clear- not implemented (use ACP client 'new' command)
3) Skill commands
- Skill commands can be enabled in backend settings and will appear in the slash command list in ACP client as
/skill:skill-name.
Note: Slash commands provided by extensions are not currently supported.
Debug Logging
Debug logging is opt-in via environment variable:
PI_ACP_DEBUG_LOG=1Log file: ~/.gsd/gsd-pi-acp/debug-{pid}-{YYYY-MM-DD}.log
Override path: PI_ACP_DEBUG_LOG_PATH=/absolute/path/to/log
Logs include: startup, backend detection, session lifecycle, RPC calls, subprocess stderr, errors, shutdown.
Authentication (ACP Registry support)
This agent supports Terminal Auth for the ACP Registry. In Zed, this will show an Authenticate banner that launches gsd or pi in a terminal. Launch your backend in a terminal for interactive login/setup:
gsd-pi-acp --terminal-loginYour ACP client can also invoke this automatically based on the agent's advertised authMethods.
Development
npm install
npm run dev # run from src via tsx
npm run build
npm run lint
npm run test # 134 testsProject layout:
src/acp/*- ACP server + translation layersrc/pi-rpc/*- gsd/pi subprocess wrapper (RPC protocol)src/backend/*- Backend configuration (gsd vs pi detection)src/logger.ts- Debug loggersrc/stdout-writer.ts- Stdout write helper
Limitations
- No ACP filesystem delegation (
fs/*) and no ACP terminal delegation (terminal/*). gsd/pi reads/writes and executes locally. - MCP servers are written to
.gsd/mcp.jsonfor gsd backend; pi backend does not support MCP pass-through. - Assistant streaming is currently sent as
agent_message_chunk(no separate thought stream).
License
MIT (see LICENSE).
