Repository navigation
Description
Context
Freebuff has no editor-native integration. ACP (Agent Client Protocol) is what Zed, T3 Code and the Agent of Empires plugin already speak, driving an agent as a subprocess. #319 has been open since September 2025 with 19 👍 and no decision; a consuming plugin asked again on 2026-11-29 whether --acp is still planned.
Three attempts are open and none is merged: #1611 (the stdio surface; now pr:needs-work), #1672 (a draft adding admission and host fixes) and #1789 (the combined attempt: 27 files, +4,089). The review on #1789 is right about scope, provenance and size, and I am not asking to land it as-is. I know accepted public PRs are ported into the private tree rather than merged here, so this is the design conversation that review asked for, before more code. If you want one canonical thread for ACP, this is meant to be it; #1611 and #1672 are source material for the pieces below, not competitors, and they stay with their authors unless you want them consolidated.
Why the surface has to live in the official CLI
An external wrapper driving free mode is refused by the backend (third_party_client_warning, with a strike), and a self-compiled build is refused too. A separate ACP package is therefore not viable for free mode: the server has to be inside the official binary, using the same admission, instance metadata and device signing as the TUI. That constraint is what #1789 was built around, and why the pieces below keep the existing callFreebuffSession wire path instead of reimplementing it.
Decisions that belong to you
- Product direction. Is
--acpsomething you want in the official CLI at all — now, or after other work? "Not now" is a useful answer; I would rather have a no than another unmergeable PR. - Dependency.
@agentclientprotocol/sdk(official TS SDK; feat(acp): serve ACP over stdio with free-mode admission and host fixes #1789 resolved 2.7.0 from a^2.2.0range, where other CLI deps such as@opentui/coreare pinned exact), or a small in-tree NDJSON/JSON-RPC transport? The surface is four agent requests, one notification and one permission request back to the host, which is small enough to implement here. The SDK buys conformance and costs a vendor dependency incli/plus azodpeer range. No strong preference from me. - Admission and model ownership. Free-hour admission in the TUI lives in the React store (
useFreebuffSession), and the selected model inuseFreebuffModelStore; a headless process has no renderer. Extract both into one non-React module (my preference: one source of truth), or keep an ACP-local holder (no TUI risk, but two writers of the selected model)? - Verification. A contributor cannot prove a live free-mode turn, because every build they can make is refused. Do transport-level tests plus release QA count, or is there a maintainer-side way to smoke-test an allowlisted build with
--acp? - Terms. The Agent of Empires plugin asks whether a local ACP client may drive Freebuff under the Free Access terms — human-initiated turns, approvals clicked by the user, nothing unattended. That is your call, and it decides whether
--acpis useful to those hosts even if it ships.
Proposed v1 surface
initialize, session/new, session/prompt, session/cancel, session/set_mode. Newline-delimited JSON-RPC on stdio, stdout carrying protocol only. Sessions in memory. No session/load or session/list, no auth over ACP (the CLI login is the auth), no host-configured MCP servers, no ad/_meta surface, and no change to the free-mode allowlist.
One behaviour to call out: --acp implies --trust-agents, because an editor-spawned process has no TTY to answer the agent-directory prompt. That loads the workspace's .agents files and mcp.json without asking. If you would rather the host pass --trust-agents explicitly, that is a one-line change and a stricter default.
Proposed landing shape
Seven pieces, in this order, each reviewable and testable without an allowlisted build:
| # | Change | Main files | code / test | What it proves |
|---|---|---|---|---|
| 1 | SDK: fail-closed toolApproval hook |
sdk/src/run.ts, client.ts, index.ts |
64 / 178 | a handler that denies or throws never runs the tool |
| 2 | CLI: completions identify as Freebuff-CLI (lowercase user-agent) |
cli/src/utils/codebuff-client.ts |
6 / ~20 | fixes the 403 from duplicate UA headers |
| 3 | Headless free-mode admission | cli/src/acp/freebuff-session.ts |
360 / ~160 | one hour per process, released on exit, refusal states mapped |
| 4 | Pure event mapping (PrintModeEvent → ACP update) |
cli/src/acp/event-mapping.ts (extracted) |
~180 / ~120 | every event variant maps correctly, unknown tools included |
| 5 | ACP agent: sessions, modes, refusals, permissions, prompt | cli/src/acp/acp-agent.ts |
~650 / ~200 | a fake host gets a turn; a refusal is one notice + refusal; a denied tool never runs |
| 6 | --acp transport: flag in both parsers, early branch before TTY/OSC, stdout guard |
serve.ts, stdout-guard.ts, cli-args.ts, index.tsx |
185 / 138 | spawn → initialize → session/new; stdout is JSON only; nothing prompts on stdin |
| 7 | Docs | docs/acp.md |
~100 | wiring for Zed/T3, and what v1 does not do |
Values without ~ are measured from the current diff; the rest are estimates. Dependencies: 5 needs 1, 3 and 4; 6 needs 5 and owns process lifetime (connection close, SIGINT/SIGTERM, release ordering), so shutdown has one owner. Pieces 1, 2, 3 and 4 stand alone. Piece 5 is the largest; a further split (sessions/modes versus turn streaming) needs a refactor, so I left it whole rather than fake a seam.
Piece 4 is a move, not new behaviour: eventToUpdate, toolTitle, toolResultFailed and the AcpUpdate type are already pure, and splitting them out lets their test run without constructing the agent — the shape docs/testing.md asks for.
Removed from the tree, not carried over: NOTES.md (113 lines of research scratch), docs/acp-free-mode-ads.md (an ad proposal, out of scope), scripts/acp-live-blocker.md, and the three scripts/acp-*.ts harnesses (563 lines). The 1,583 lines of ACP tests become roughly 550, keeping four behaviours: tool-approval deny/throw, admission refusals, refusal-once, and the stdio handshake.
Even split, this is still ~1,450 lines of code plus ~100 of docs, so the gain is per-PR reviewability, not total volume.
Provenance and evidence
The code has three sources: #1611 (espetro), rodriveiga01/freebuff@9eec2f1 (admission and lifetime), and the host fixes collected in #1672. #1789 called that "carry forward", which is not an acceptable claim when two of the three are not in this repo's history. From here each PR is self-contained, with credit in the commit trailers and no references to branches you cannot fetch.
On evidence: #1789 mixed test numbers from before its last merge with a post-merge head. That one is on me. The rule from here is that every PR re-runs its own tests on its own head, and anything not run is listed as not run.
What I can bring
Patches for 1 and 2 now; 3–6 in whichever shape you pick in (2) and (3), one at a time, stopping at the first no. A single go from any maintainer is enough for me to start on 1 and 2, and I will ask before each next piece. #1789 would be closed as superseded rather than left open as a fourth competing ACP PR.
Activity