packages/cli/src/acp/README.md
This directory contains the implementation of the Agent Client Protocol (ACP) for the Gemini CLI. The ACP allows external clients (like IDE extensions) to communicate with the Gemini CLI agent over a structured JSON-RPC based protocol.
Following Phase 1 of the modularization refactor, the ACP client is organized
into the following specialized modules, all sharing the acp prefix for
consistency:
AgentSideConnection using line-delimited JSON (ndjson).GeminiAgent
class. This is the main entry point for incoming JSON-RPC messages. It
implements the protocol methods and delegates session-specific work to the
manager and individual sessions.newSession), loading (loadSession),
and configuration, isolating session state from the RPC routing.@path file resolution, tool execution, command
interception, and streaming updates back to the client./memory, /init) sent via ACP prompts.Tests are co-located with the source files:
acpRpcDispatcher.test.ts: Tests for initialization, authentication, and
handler delegation.acpSessionManager.test.ts: Tests for session lifecycle and configuration.acpSession.test.ts: Tests for prompt loops, tool execution, and @path
resolution.acpResume.test.ts: Integration tests for loading/resuming sessions.To run specific tests, use Vitest with the workspace filter:
# General pattern
npm test -w @google/gemini-cli -- src/acp/<test-file-name>.ts
# Example
npm test -w @google/gemini-cli -- src/acp/acpRpcDispatcher.test.ts
Note: You may need to ensure your environment has Node available. If running in a restricted environment, try sourcing NVM first:
source ~/.nvm/nvm.sh && nvm use default && npm test -w @google/gemini-cli -- src/acp/acpSession.test.ts
GeminiAgent in acpRpcDispatcher.ts
and register it in the AgentSideConnection setup if necessary.Session class in acpSession.ts.acpUtils.ts.any assertions. Use Zod schemas to validate
untrusted input from the protocol.