|
|
3 месяцев назад | |
|---|---|---|
| .. | ||
| README.md | 4 месяцев назад | |
| agent.ts | 3 месяцев назад | |
| session.ts | 3 месяцев назад | |
| types.ts | 3 месяцев назад | |
This directory contains a clean, protocol-compliant implementation of the Agent Client Protocol for opencode.
The implementation follows a clean separation of concerns:
agent.ts - Implements the Agent interface from @agentclientprotocol/sdk
session/new, session/load)client.ts - Implements the Client interface for client-side capabilities
readTextFile, writeTextFile)session.ts - Session state management
server.ts - ACP server startup and lifecycle
types.ts - Type definitions for internal use
# Start the ACP server in the current directory
opencode acp
# Start in a specific directory
opencode acp --cwd /path/to/project
import { ACPServer } from "./acp/server"
await ACPServer.start()
Add to your Zed configuration (~/.config/zed/settings.json):
{
"agent_servers": {
"OpenCode": {
"command": "opencode",
"args": ["acp"]
}
}
}
This implementation follows the ACP specification v1:
✅ Initialization
initialize request/response with protocol version negotiationagentCapabilities)✅ Session Management
session/new - Create new conversation sessionssession/load - Resume existing sessions (basic support)cwd)✅ Prompting
session/prompt - Process user messages✅ Client Capabilities
session/update notificationssession/load doesn't restore actual conversation historysession/update notifications for progressive responses# Run ACP tests
bun test test/acp.test.ts
# Test manually with stdio
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}' | opencode acp
We use @agentclientprotocol/sdk instead of implementing JSON-RPC ourselves because:
Each component has a single responsibility:
This makes the codebase maintainable and testable.
ACP sessions map cleanly to opencode's internal session model:
session/new → creates internal Sessionsession/prompt → uses SessionPrompt.prompt()