Skip to content

Add Zed agent support via ACP proxy#851

Draft
Krishnachaitanyakc wants to merge 6 commits intogit-ai-project:mainfrom
Krishnachaitanyakc:feat/zed-acp-proxy-675
Draft

Add Zed agent support via ACP proxy#851
Krishnachaitanyakc wants to merge 6 commits intogit-ai-project:mainfrom
Krishnachaitanyakc:feat/zed-acp-proxy-675

Conversation

@Krishnachaitanyakc
Copy link
Copy Markdown
Contributor

Summary

Closes #675

  • Implements automatic checkpoint tracking for Zed via ACP (Agent Client Protocol) proxy
  • The proxy wraps a real agent (e.g., Claude Code), intercepting tool_call/tool_call_update notifications to create checkpoints automatically — no model cooperation needed
  • Architecture: Zed (ACP Client) ←stdio→ git-ai acp-proxy ←stdio→ Real Agent

New files

  • src/commands/acp_proxy.rs — Core ACP proxy with Content-Length framed I/O, two-thread forwarding, and background checkpoint spawning
  • src/commands/checkpoint_agent/zed_preset.rs — Preset for parsing hook input JSON from the proxy
  • src/mdm/agents/zed.rsZedInstaller that detects Zed and prints agent_servers setup instructions

Modified files

  • src/commands/git_ai_handlers.rs — Wire up acp-proxy command and zed checkpoint preset
  • Module declarations in mod.rs files

Test plan

  • cargo fmt -- --check passes
  • cargo build compiles with no warnings
  • 16 unit tests for acp_proxy.rs (message framing, file path extraction, tool call tracking, arg parsing)
  • 5 unit tests for zed_preset.rs (pre/post tool use, error cases)
  • 4 unit tests for zed.rs (name, id, config hooks flag, install instructions)
  • Manual: echo '{"hook_event_name":"PostToolUse","session_id":"s1","cwd":"/tmp","file_paths":["a.rs"]}' | git-ai checkpoint zed --hook-input stdin
  • Manual: git-ai acp-proxy -- echo "test" (verifies arg parsing and child spawn)

@dlight
Copy link
Copy Markdown

dlight commented Mar 29, 2026

Thank you for addressing that issue!

I don't know much about how git-ai works, but I'm surprised this approach is needed. I mean, if I use an external agent in Zed like Claude Code, shouldn't Claude Code hooks like pre-edit fire regardless of whether it is being driven by Zed or not? And most external agents Zed could use probably have git-ai support already.

Also I have a question. This proxy won't track edits of the first-party Zed Agent right?
I'm not entirely sure, but I think that in Zed ACP is used for external agents only.

(the Zed Agent is the default agent interface when you open the agent panel, to use external agents you need to select them when creating a new thread).

If this doesn't track edits from the first-party Zed Agent, I think this shouldn't close #675.

@Krishnachaitanyakc
Copy link
Copy Markdown
Contributor Author

Good points! You're right that Claude Code's hooks fire independently — running it through the ACP proxy would double-track edits. I'm adding a fix: the proxy sets GIT_AI_ACP_PROXY=1 on the child process, and the Claude preset skips when that env var is present (same pattern as the existing VS Code Copilot/Cursor filters).

The proxy is still useful for agents that don't have native git-ai integration.

Re: first-party Zed Agent — correct, ACP agent_servers is for external agents only. Zed doesn't expose hooks or events for its built-in agent's tool use, so there's no way to intercept those edits currently. I'll file a feature request with Zed for tool-use hooks. That said, this is a Zed-side limitation rather than a gap in this PR's approach.

Implements automatic checkpoint tracking for Zed by acting as a
transparent ACP (Agent Client Protocol) proxy between Zed and the
real agent. The proxy intercepts tool_call/tool_call_update
notifications to create checkpoints without requiring model
cooperation.

- Add acp_proxy command with Content-Length framed I/O, two-thread
  forwarding (Zed→Agent, Agent→Zed), and background checkpoint
  spawning
- Add zed_preset for parsing hook input from the ACP proxy
- Add ZedInstaller that detects Zed and prints agent_servers setup
  instructions
- Wire up "acp-proxy" command and "zed" checkpoint preset in handlers
Collapse nested if-let statements into a single if-let chain as
suggested by clippy::collapsible_if.
The ACP proxy now sets GIT_AI_ACP_PROXY=1 on the child process, and
the Claude preset skips checkpointing when that env var is present.
This prevents duplicate checkpoints when Claude Code's own hooks fire
alongside the proxy's tool-call interception.

Same pattern as the existing VS Code Copilot and Cursor filters.
The daemon's trace ingest worker processed side effects inline,
blocking the entire trace event pipeline. Under concurrent test load,
events backed up and tests timed out waiting for completion log entries.

- Spawn side effects via tokio::spawn for both Applied and QueuedFamily
  paths so the ingest worker returns immediately
- Split replace_pending_root_entry: fast BTreeMap update stays inline,
  drain moves to a new drain_family_sequencer method spawned async
- Fix pre-existing bug where completion log was skipped on side effect
  errors in the fast path (if/else if -> two separate if blocks)
- Increase daemon test sync timeouts (60s->120s total, 20s->30s idle)
  to provide margin under CI load
Reverts commits 4b0aab0 and a391bf0 which moved daemon side effects
into fire-and-forget tokio::spawn tasks. The spawned tasks wrote
completion logs asynchronously, causing the test sync mechanism to
timeout waiting for entries that were never written (or written too
late). This broke all amend and subdirs tests in daemon and
wrapper-daemon CI modes.

Restores synchronous side effect execution in ingest_trace_payload_fast
and inline drain in replace_pending_root_entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to Zed Agent

2 participants