Skip to content

Commit 12a8407

Browse files
committed
docs: polish docs
1 parent 073beeb commit 12a8407

File tree

4 files changed

+116
-59
lines changed

4 files changed

+116
-59
lines changed

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,70 @@
1-
# Agent Client Protocol - Python SDK
1+
# Agent Client Protocol (Python)
22

3-
A Python implementation of the Agent Client Protocol (ACP) used by editors like Zed to talk to external agents over stdio.
3+
A Python implementation of the Agent Client Protocol (ACP). Use it to build agents that communicate with ACP-capable clients (e.g. Zed) over stdio.
44

5+
- Package name: `agent-client-protocol` (import as `acp`)
56
- Repository: https://github.com/psiace/agent-client-protocol-python
67
- Docs: https://psiace.github.io/agent-client-protocol-python/
78

8-
## What this provides
9-
10-
- Typed ACP client/agent primitives (`acp` package under `src/`)
11-
- A runnable example: a bridge that wraps mini-swe-agent as an ACP agent
12-
- Reference implementations under `reference/` for learning and comparison
13-
14-
## Quick start
15-
16-
Install the development environment:
9+
## Install
1710

1811
```bash
19-
make install
12+
pip install agent-client-protocol
13+
# or
14+
uv add agent-client-protocol
2015
```
2116

22-
Run quality checks:
17+
## Development (contributors)
2318

2419
```bash
25-
make check
20+
make install # set up venv
21+
make check # lint + typecheck
22+
make test # run tests
2623
```
2724

28-
Run tests:
25+
## Minimal agent example
2926

30-
```bash
31-
make test
27+
```python
28+
# agent_main.py
29+
import asyncio
30+
from acp import Agent, AgentSideConnection, Client, InitializeRequest, InitializeResponse, PromptRequest, PromptResponse, SessionNotification, stdio_streams, PROTOCOL_VERSION
31+
from acp.schema import ContentBlock1, SessionUpdate2
32+
33+
class EchoAgent(Agent):
34+
def __init__(self, client: Client) -> None:
35+
self.client = client
36+
37+
async def initialize(self, _p: InitializeRequest) -> InitializeResponse:
38+
return InitializeResponse(protocolVersion=PROTOCOL_VERSION)
39+
40+
async def prompt(self, p: PromptRequest) -> PromptResponse:
41+
text = "".join([getattr(b, "text", "") for b in p.prompt if getattr(b, "type", None) == "text"]) or "(empty)"
42+
await self.client.sessionUpdate(SessionNotification(
43+
sessionId=p.sessionId,
44+
update=SessionUpdate2(sessionUpdate="agent_message_chunk", content=ContentBlock1(type="text", text=f"Echo: {text}")),
45+
))
46+
return PromptResponse(stopReason="end_turn")
47+
48+
async def main() -> None:
49+
reader, writer = await stdio_streams()
50+
AgentSideConnection(lambda c: EchoAgent(c), writer, reader)
51+
await asyncio.Event().wait()
52+
53+
if __name__ == "__main__":
54+
asyncio.run(main())
3255
```
3356

34-
## Example: Mini SWE Agent bridge
57+
Run this executable from your ACP-capable client (e.g. configure Zed to launch it). The library takes care of the stdio JSON-RPC transport.
3558

36-
A minimal ACP bridge for mini-swe-agent is provided under [`examples/mini_swe_agent`](file:///Users/psiace/OSS/agent-client-protocol-python/examples/mini_swe_agent/README.md). It shows how to:
59+
## Example: Mini SWE Agent bridge
3760

38-
- Parse a prompt from ACP content blocks
39-
- Stream agent output to the client with `session/update`
40-
- Map command execution to `tool_call` and `tool_call_update`
61+
A minimal ACP bridge for mini-swe-agent is provided under [`examples/mini_swe_agent`](examples/mini_swe_agent/README.md). It demonstrates:
4162

42-
See the example’s README or the docs quickstart for Zed configuration.
63+
- Parsing a prompt from ACP content blocks
64+
- Streaming agent output via `session/update`
65+
- Mapping command execution to `tool_call` and `tool_call_update`
4366

4467
## Documentation
4568

46-
- Getting started: [docs/index.md](docs/index.md)
4769
- Quickstart: [docs/quickstart.md](docs/quickstart.md)
48-
- Mini SWE Agent example details: [docs/mini-swe-agent.md](docs/mini-swe-agent.md)
49-
50-
## Notes
51-
52-
- The `reference/` directory contains educational examples and may include optional dependencies. These are not required to use the example bridge.
70+
- Mini SWE Agent example: [docs/mini-swe-agent.md](docs/mini-swe-agent.md)

docs/index.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1-
# Agent Client Protocol - Python SDK
1+
# Agent Client Protocol (Python)
22

3-
A Python implementation of the Agent Client Protocol (ACP) used by editors like Zed to talk to external agents over stdio.
3+
A Python implementation of the Agent Client Protocol (ACP). Build agents that communicate with ACP-capable clients (e.g. Zed) over stdio.
4+
5+
## Install
6+
7+
```bash
8+
pip install agent-client-protocol
9+
```
10+
11+
## Minimal usage
12+
13+
```python
14+
from acp import Agent, AgentSideConnection, Client, stdio_streams, PROTOCOL_VERSION, InitializeRequest, InitializeResponse, PromptRequest, PromptResponse
15+
from acp.schema import ContentBlock1, SessionUpdate2, SessionNotification
16+
17+
class MyAgent(Agent):
18+
def __init__(self, client: Client):
19+
self.client = client
20+
async def initialize(self, _p: InitializeRequest) -> InitializeResponse:
21+
return InitializeResponse(protocolVersion=PROTOCOL_VERSION)
22+
async def prompt(self, p: PromptRequest) -> PromptResponse:
23+
await self.client.sessionUpdate(SessionNotification(
24+
sessionId=p.sessionId,
25+
update=SessionUpdate2(sessionUpdate="agent_message_chunk", content=ContentBlock1(type="text", text="Hello from ACP")),
26+
))
27+
return PromptResponse(stopReason="end_turn")
28+
```
429

530
- Quickstart: [quickstart.md](quickstart.md)
631
- Mini SWE Agent example: [mini-swe-agent.md](mini-swe-agent.md)

docs/quickstart.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
11
# Quickstart
22

3-
This repository provides a Python implementation of the Agent Client Protocol (ACP) and a minimal example that bridges mini-swe-agent into an ACP agent.
3+
Use the published package to build an ACP agent, or run the included example.
44

5-
## Prerequisites
6-
7-
- Python 3.10+
8-
- A virtual environment for this repo (`make install` will create one with uv)
9-
- Zed editor (for running the example agent)
10-
11-
## Install
5+
## Install the SDK
126

137
```bash
14-
make install
8+
pip install agent-client-protocol
159
```
1610

17-
Run checks:
11+
## Minimal agent
1812

19-
```bash
20-
make check
13+
```python
14+
import asyncio
15+
from acp import Agent, AgentSideConnection, Client, InitializeRequest, InitializeResponse, PromptRequest, PromptResponse, SessionNotification, stdio_streams, PROTOCOL_VERSION
16+
from acp.schema import ContentBlock1, SessionUpdate2
17+
18+
class EchoAgent(Agent):
19+
def __init__(self, client: Client):
20+
self.client = client
21+
async def initialize(self, _p: InitializeRequest) -> InitializeResponse:
22+
return InitializeResponse(protocolVersion=PROTOCOL_VERSION)
23+
async def prompt(self, p: PromptRequest) -> PromptResponse:
24+
await self.client.sessionUpdate(SessionNotification(
25+
sessionId=p.sessionId,
26+
update=SessionUpdate2(sessionUpdate="agent_message_chunk", content=ContentBlock1(type="text", text="Hello from ACP")),
27+
))
28+
return PromptResponse(stopReason="end_turn")
29+
30+
async def main() -> None:
31+
reader, writer = await stdio_streams()
32+
AgentSideConnection(lambda c: EchoAgent(c), writer, reader)
33+
await asyncio.Event().wait()
34+
35+
if __name__ == "__main__":
36+
asyncio.run(main())
2137
```
2238

39+
Run this program from your ACP-capable client.
40+
2341
## Run the Mini SWE Agent bridge in Zed
2442

25-
Install mini-swe-agent into this repo’s venv.
43+
Install `mini-swe-agent` (or at least its core dependencies) into the same environment that will run the example:
2644

2745
```bash
28-
./.venv/bin/pip install mini-swe-agent
46+
pip install mini-swe-agent
2947
```
3048

3149
Add an agent server to Zed’s `settings.json`:
@@ -34,12 +52,11 @@ Add an agent server to Zed’s `settings.json`:
3452
{
3553
"agent_servers": {
3654
"Mini SWE Agent (Python)": {
37-
"command": "/absolute/path/to/agent-client-protocol-python/.venv/bin/python",
55+
"command": "/abs/path/to/python",
3856
"args": [
39-
"/absolute/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
57+
"/abs/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
4058
],
4159
"env": {
42-
"PYTHONPATH": "/absolute/path/to/agent-client-protocol-python/src",
4360
"MINI_SWE_MODEL": "openrouter/openai/gpt-4o-mini",
4461
"MINI_SWE_MODEL_KWARGS": "{\"api_base\":\"https://openrouter.ai/api/v1\"}",
4562
"OPENROUTER_API_KEY": "sk-or-..."
@@ -51,4 +68,4 @@ Add an agent server to Zed’s `settings.json`:
5168

5269
In Zed, open the Agents panel and select "Mini SWE Agent (Python)".
5370

54-
For details on behavior and message mapping, see [mini-swe-agent.md](mini-swe-agent.md).
71+
See [mini-swe-agent.md](mini-swe-agent.md) for behavior and message mapping details.

examples/mini_swe_agent/README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
A minimal Agent Client Protocol (ACP) bridge that wraps mini-swe-agent so it can be run by Zed as an external agent over stdio.
44

5-
## Configure in Zed (using this repo’s venv)
5+
## Configure in Zed
66

7-
Add an `agent_servers` entry to Zed’s `settings.json`. Point `command` to this repo’s venv Python and `args` to this example script:
7+
Add an `agent_servers` entry to Zed’s `settings.json`. Point `command` to the Python interpreter that has both `agent-client-protocol` and `mini-swe-agent` installed, and `args` to this example script:
88

99
```json
1010
{
1111
"agent_servers": {
1212
"Mini SWE Agent (Python)": {
13-
"command": "/absolute/path/to/agent-client-protocol-python/.venv/bin/python",
13+
"command": "/abs/path/to/python",
1414
"args": [
15-
"/absolute/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
15+
"/abs/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
1616
],
1717
"env": {
18-
"PYTHONPATH": "/absolute/path/to/agent-client-protocol-python/src",
1918
"MINI_SWE_MODEL": "openrouter/openai/gpt-4o-mini",
2019
"MINI_SWE_MODEL_KWARGS": "{\"api_base\":\"https://openrouter.ai/api/v1\"}",
2120
"OPENROUTER_API_KEY": "sk-or-..."
@@ -26,9 +25,7 @@ Add an `agent_servers` entry to Zed’s `settings.json`. Point `command` to this
2625
```
2726

2827
Notes
29-
- `command` must be the absolute path to this repository’s venv Python.
30-
- `args` must point to this example script.
31-
- `PYTHONPATH` must point to this repository’s `src` so the `acp` package can be imported.
28+
- If you install `agent-client-protocol` from PyPI, you do not need to set `PYTHONPATH`.
3229
- Using OpenRouter:
3330
- Set `MINI_SWE_MODEL` to a model supported by OpenRouter (e.g. `openrouter/openai/gpt-4o-mini`, `openrouter/anthropic/claude-3.5-sonnet`).
3431
- Set `MINI_SWE_MODEL_KWARGS` to a JSON containing `api_base`: `{ "api_base": "https://openrouter.ai/api/v1" }`.
@@ -37,10 +34,10 @@ Notes
3734

3835
## Requirements
3936

40-
Install mini-swe-agent (or at least its core deps) into this repo’s venv:
37+
Install mini-swe-agent (or at least its core deps) into the same environment:
4138

4239
```bash
43-
/path/to/.venv/bin/pip install mini-swe-agent
40+
pip install agent-client-protocol mini-swe-agent
4441
# or: pip install litellm jinja2 tenacity
4542
```
4643

0 commit comments

Comments
 (0)