claude-code-acp 0.3.1__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/PKG-INFO +81 -40
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/README.md +80 -39
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/pyproject.toml +1 -1
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/src/claude_code_acp/__init__.py +1 -1
- claude_code_acp-0.3.4/src/claude_code_acp/acp_client.py +688 -0
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/src/claude_code_acp/agent.py +71 -2
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/uv.lock +1 -1
- claude_code_acp-0.3.1/src/claude_code_acp/acp_client.py +0 -374
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/.github/workflows/publish.yml +0 -0
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/.gitignore +0 -0
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/LICENSE +0 -0
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/src/claude_code_acp/__main__.py +0 -0
- {claude_code_acp-0.3.1 → claude_code_acp-0.3.4}/src/claude_code_acp/client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-code-acp
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: ACP-compatible agent for Claude Code (Python version)
|
|
5
5
|
Project-URL: Homepage, https://github.com/yazelin/claude-code-acp-py
|
|
6
6
|
Project-URL: Repository, https://github.com/yazelin/claude-code-acp-py
|
|
@@ -234,6 +234,43 @@ gemini = AcpClient(command="gemini", args=["--experimental-acp"])
|
|
|
234
234
|
ts_claude = AcpClient(command="npx", args=["@zed-industries/claude-code-acp"])
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
+
### File Operation Handlers
|
|
238
|
+
|
|
239
|
+
AcpClient supports intercepting file read/write operations for security or custom handling:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
@client.on_file_read
|
|
243
|
+
async def handle_read(path: str) -> str | None:
|
|
244
|
+
"""Intercept file reads. Return content to override, or None to proceed."""
|
|
245
|
+
print(f"📖 Reading: {path}")
|
|
246
|
+
return None # Proceed with normal read
|
|
247
|
+
|
|
248
|
+
@client.on_file_write
|
|
249
|
+
async def handle_write(path: str, content: str) -> bool:
|
|
250
|
+
"""Intercept file writes. Return True to allow, False to block."""
|
|
251
|
+
print(f"📝 Writing: {path}")
|
|
252
|
+
response = input("Allow write? [y/N]: ")
|
|
253
|
+
return response.lower() == "y"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Terminal Operation Handlers
|
|
257
|
+
|
|
258
|
+
AcpClient supports intercepting terminal/shell execution for security:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
@client.on_terminal_create
|
|
262
|
+
async def handle_terminal(command: str, cwd: str) -> bool:
|
|
263
|
+
"""Intercept shell commands. Return True to allow, False to block."""
|
|
264
|
+
print(f"🖥️ Command: {command} in {cwd}")
|
|
265
|
+
response = input("Allow execution? [y/N]: ")
|
|
266
|
+
return response.lower() == "y"
|
|
267
|
+
|
|
268
|
+
@client.on_terminal_output
|
|
269
|
+
async def handle_output(terminal_id: str, output: str) -> None:
|
|
270
|
+
"""Receive terminal output in real-time."""
|
|
271
|
+
print(output, end="")
|
|
272
|
+
```
|
|
273
|
+
|
|
237
274
|
### AcpClient vs ClaudeClient
|
|
238
275
|
|
|
239
276
|
| Feature | `ClaudeClient` | `AcpClient` |
|
|
@@ -255,48 +292,52 @@ ts_claude = AcpClient(command="npx", args=["@zed-industries/claude-code-acp"])
|
|
|
255
292
|
|
|
256
293
|
## Architecture
|
|
257
294
|
|
|
295
|
+
This package provides **three ways** to use Claude:
|
|
296
|
+
|
|
297
|
+
### Method A: Editor via ACP (ClaudeAcpAgent)
|
|
298
|
+
|
|
299
|
+
For Zed, Neovim, and other ACP-compatible editors:
|
|
300
|
+
|
|
258
301
|
```
|
|
259
|
-
|
|
260
|
-
│
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
│ ACP SERVER (for editors) ACP CLIENT (for Python apps) │
|
|
264
|
-
│ ───────────────────────── ──────────────────────────── │
|
|
265
|
-
│ │
|
|
266
|
-
│ ┌─────────────┐ ┌─────────────┐ │
|
|
267
|
-
│ │ Zed/Neovim │ │ Your Python │ │
|
|
268
|
-
│ │ Editor │ │ App │ │
|
|
269
|
-
│ └──────┬──────┘ └──────┬──────┘ │
|
|
270
|
-
│ │ │ │
|
|
271
|
-
│ │ ACP │ uses │
|
|
272
|
-
│ ▼ ▼ │
|
|
273
|
-
│ ┌──────────────────┐ ┌─────────────────┐ │
|
|
274
|
-
│ │ ClaudeAcpAgent │ │ AcpClient │───┐ │
|
|
275
|
-
│ │ (ACP Server) │ │ (ACP Client) │ │ │
|
|
276
|
-
│ └────────┬─────────┘ └────────┬────────┘ │ │
|
|
277
|
-
│ │ │ │ can connect to │
|
|
278
|
-
│ │ │ ACP │ any ACP agent │
|
|
279
|
-
│ ▼ ▼ │ │
|
|
280
|
-
│ ┌──────────────────┐ ┌─────────────────┐ │ │
|
|
281
|
-
│ │ ClaudeClient │ │ claude-code-acp│◄─┘ │
|
|
282
|
-
│ │ (Python wrapper) │ │ Gemini CLI │ │
|
|
283
|
-
│ └────────┬─────────┘ │ Other agents │ │
|
|
284
|
-
│ │ └─────────────────┘ │
|
|
285
|
-
│ │ │
|
|
286
|
-
│ ▼ │
|
|
287
|
-
│ ┌──────────────────┐ │
|
|
288
|
-
│ │ Claude Agent SDK │ │
|
|
289
|
-
│ └────────┬─────────┘ │
|
|
290
|
-
│ │ │
|
|
291
|
-
│ ▼ │
|
|
292
|
-
│ ┌──────────────────┐ │
|
|
293
|
-
│ │ Claude CLI │ │
|
|
294
|
-
│ │ (Subscription) │ │
|
|
295
|
-
│ └──────────────────┘ │
|
|
296
|
-
│ │
|
|
297
|
-
└──────────────────────────────────────────────────────────────────────────────┘
|
|
302
|
+
┌──────────┐ ACP Protocol ┌─────────────────┐ SDK ┌────────────┐
|
|
303
|
+
│ Zed │ ────── stdio ───────► │ ClaudeAcpAgent │ ──────────► │ Claude CLI │
|
|
304
|
+
│ Editor │ │ (ACP Server) │ │ │
|
|
305
|
+
└──────────┘ └─────────────────┘ └────────────┘
|
|
298
306
|
```
|
|
299
307
|
|
|
308
|
+
### Method B: Python Direct (ClaudeClient)
|
|
309
|
+
|
|
310
|
+
For Python apps that want simple, direct access to Claude (**no ACP protocol**):
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
┌──────────┐ direct call ┌─────────────────┐ SDK ┌────────────┐
|
|
314
|
+
│ Python │ ──── in-process ───► │ ClaudeClient │ ──────────► │ Claude CLI │
|
|
315
|
+
│ App │ │ │ │ │
|
|
316
|
+
└──────────┘ └─────────────────┘ └────────────┘
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Method C: Python via ACP (AcpClient)
|
|
320
|
+
|
|
321
|
+
For Python apps that want to connect to **any** ACP-compatible agent:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
┌──────────┐ ACP Protocol ┌─────────────────┐
|
|
325
|
+
│ Python │ ────── stdio ───────► │ Any ACP Agent │
|
|
326
|
+
│ App │ │ │
|
|
327
|
+
│ │ │ • claude-code │
|
|
328
|
+
│ AcpClient│ │ • gemini │
|
|
329
|
+
│ │ │ • custom agents │
|
|
330
|
+
└──────────┘ └─────────────────┘
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Summary
|
|
334
|
+
|
|
335
|
+
| Component | Uses ACP? | Purpose |
|
|
336
|
+
|-----------|-----------|---------|
|
|
337
|
+
| `ClaudeAcpAgent` | Yes (Server) | Let editors connect to Claude |
|
|
338
|
+
| `ClaudeClient` | **No** | Simplest way for Python apps |
|
|
339
|
+
| `AcpClient` | Yes (Client) | Connect to any ACP agent |
|
|
340
|
+
|
|
300
341
|
---
|
|
301
342
|
|
|
302
343
|
## What We Built
|
|
@@ -211,6 +211,43 @@ gemini = AcpClient(command="gemini", args=["--experimental-acp"])
|
|
|
211
211
|
ts_claude = AcpClient(command="npx", args=["@zed-industries/claude-code-acp"])
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
+
### File Operation Handlers
|
|
215
|
+
|
|
216
|
+
AcpClient supports intercepting file read/write operations for security or custom handling:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
@client.on_file_read
|
|
220
|
+
async def handle_read(path: str) -> str | None:
|
|
221
|
+
"""Intercept file reads. Return content to override, or None to proceed."""
|
|
222
|
+
print(f"📖 Reading: {path}")
|
|
223
|
+
return None # Proceed with normal read
|
|
224
|
+
|
|
225
|
+
@client.on_file_write
|
|
226
|
+
async def handle_write(path: str, content: str) -> bool:
|
|
227
|
+
"""Intercept file writes. Return True to allow, False to block."""
|
|
228
|
+
print(f"📝 Writing: {path}")
|
|
229
|
+
response = input("Allow write? [y/N]: ")
|
|
230
|
+
return response.lower() == "y"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Terminal Operation Handlers
|
|
234
|
+
|
|
235
|
+
AcpClient supports intercepting terminal/shell execution for security:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
@client.on_terminal_create
|
|
239
|
+
async def handle_terminal(command: str, cwd: str) -> bool:
|
|
240
|
+
"""Intercept shell commands. Return True to allow, False to block."""
|
|
241
|
+
print(f"🖥️ Command: {command} in {cwd}")
|
|
242
|
+
response = input("Allow execution? [y/N]: ")
|
|
243
|
+
return response.lower() == "y"
|
|
244
|
+
|
|
245
|
+
@client.on_terminal_output
|
|
246
|
+
async def handle_output(terminal_id: str, output: str) -> None:
|
|
247
|
+
"""Receive terminal output in real-time."""
|
|
248
|
+
print(output, end="")
|
|
249
|
+
```
|
|
250
|
+
|
|
214
251
|
### AcpClient vs ClaudeClient
|
|
215
252
|
|
|
216
253
|
| Feature | `ClaudeClient` | `AcpClient` |
|
|
@@ -232,48 +269,52 @@ ts_claude = AcpClient(command="npx", args=["@zed-industries/claude-code-acp"])
|
|
|
232
269
|
|
|
233
270
|
## Architecture
|
|
234
271
|
|
|
272
|
+
This package provides **three ways** to use Claude:
|
|
273
|
+
|
|
274
|
+
### Method A: Editor via ACP (ClaudeAcpAgent)
|
|
275
|
+
|
|
276
|
+
For Zed, Neovim, and other ACP-compatible editors:
|
|
277
|
+
|
|
235
278
|
```
|
|
236
|
-
|
|
237
|
-
│
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
│ ACP SERVER (for editors) ACP CLIENT (for Python apps) │
|
|
241
|
-
│ ───────────────────────── ──────────────────────────── │
|
|
242
|
-
│ │
|
|
243
|
-
│ ┌─────────────┐ ┌─────────────┐ │
|
|
244
|
-
│ │ Zed/Neovim │ │ Your Python │ │
|
|
245
|
-
│ │ Editor │ │ App │ │
|
|
246
|
-
│ └──────┬──────┘ └──────┬──────┘ │
|
|
247
|
-
│ │ │ │
|
|
248
|
-
│ │ ACP │ uses │
|
|
249
|
-
│ ▼ ▼ │
|
|
250
|
-
│ ┌──────────────────┐ ┌─────────────────┐ │
|
|
251
|
-
│ │ ClaudeAcpAgent │ │ AcpClient │───┐ │
|
|
252
|
-
│ │ (ACP Server) │ │ (ACP Client) │ │ │
|
|
253
|
-
│ └────────┬─────────┘ └────────┬────────┘ │ │
|
|
254
|
-
│ │ │ │ can connect to │
|
|
255
|
-
│ │ │ ACP │ any ACP agent │
|
|
256
|
-
│ ▼ ▼ │ │
|
|
257
|
-
│ ┌──────────────────┐ ┌─────────────────┐ │ │
|
|
258
|
-
│ │ ClaudeClient │ │ claude-code-acp│◄─┘ │
|
|
259
|
-
│ │ (Python wrapper) │ │ Gemini CLI │ │
|
|
260
|
-
│ └────────┬─────────┘ │ Other agents │ │
|
|
261
|
-
│ │ └─────────────────┘ │
|
|
262
|
-
│ │ │
|
|
263
|
-
│ ▼ │
|
|
264
|
-
│ ┌──────────────────┐ │
|
|
265
|
-
│ │ Claude Agent SDK │ │
|
|
266
|
-
│ └────────┬─────────┘ │
|
|
267
|
-
│ │ │
|
|
268
|
-
│ ▼ │
|
|
269
|
-
│ ┌──────────────────┐ │
|
|
270
|
-
│ │ Claude CLI │ │
|
|
271
|
-
│ │ (Subscription) │ │
|
|
272
|
-
│ └──────────────────┘ │
|
|
273
|
-
│ │
|
|
274
|
-
└──────────────────────────────────────────────────────────────────────────────┘
|
|
279
|
+
┌──────────┐ ACP Protocol ┌─────────────────┐ SDK ┌────────────┐
|
|
280
|
+
│ Zed │ ────── stdio ───────► │ ClaudeAcpAgent │ ──────────► │ Claude CLI │
|
|
281
|
+
│ Editor │ │ (ACP Server) │ │ │
|
|
282
|
+
└──────────┘ └─────────────────┘ └────────────┘
|
|
275
283
|
```
|
|
276
284
|
|
|
285
|
+
### Method B: Python Direct (ClaudeClient)
|
|
286
|
+
|
|
287
|
+
For Python apps that want simple, direct access to Claude (**no ACP protocol**):
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
┌──────────┐ direct call ┌─────────────────┐ SDK ┌────────────┐
|
|
291
|
+
│ Python │ ──── in-process ───► │ ClaudeClient │ ──────────► │ Claude CLI │
|
|
292
|
+
│ App │ │ │ │ │
|
|
293
|
+
└──────────┘ └─────────────────┘ └────────────┘
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Method C: Python via ACP (AcpClient)
|
|
297
|
+
|
|
298
|
+
For Python apps that want to connect to **any** ACP-compatible agent:
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
┌──────────┐ ACP Protocol ┌─────────────────┐
|
|
302
|
+
│ Python │ ────── stdio ───────► │ Any ACP Agent │
|
|
303
|
+
│ App │ │ │
|
|
304
|
+
│ │ │ • claude-code │
|
|
305
|
+
│ AcpClient│ │ • gemini │
|
|
306
|
+
│ │ │ • custom agents │
|
|
307
|
+
└──────────┘ └─────────────────┘
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Summary
|
|
311
|
+
|
|
312
|
+
| Component | Uses ACP? | Purpose |
|
|
313
|
+
|-----------|-----------|---------|
|
|
314
|
+
| `ClaudeAcpAgent` | Yes (Server) | Let editors connect to Claude |
|
|
315
|
+
| `ClaudeClient` | **No** | Simplest way for Python apps |
|
|
316
|
+
| `AcpClient` | Yes (Client) | Connect to any ACP agent |
|
|
317
|
+
|
|
277
318
|
---
|
|
278
319
|
|
|
279
320
|
## What We Built
|