Skip to content

Add lcode acp: lcode inside editors over the Agent Client Protocol - #83

Merged
nasser1941 merged 1 commit into
mainfrom
feat/acp
Oct 5, 2026
Merged

nasser1941 merged 1 commit into
mainfrom
feat/acp

Conversation

@nasser1941

Copy link
Copy Markdown
Owner

Closes #49.

What

lcode acp runs lcode as the agent inside an editor, over the Agent Client Protocol, version 1 (the stable one).

  • Transport: newline-delimited JSON-RPC 2.0 on stdin/stdout. Requests run in their own threads, so cancellations and the editor's answers keep flowing during a request. Nothing else reaches stdout: print goes to stderr, and stdin is replaced so nothing can wait for typed input.
  • Mapping:
    • Streaming: the model's text and thinking arrive as agent_message_chunk / agent_thought_chunk.
    • Tool calls: tool_call → in_progress → completed / failed, with a kind (read, search, edit, execute, fetch, …), the files touched, and a whole-file diff for edits.
    • Permission questions go to session/request_permission (allow once, always allow for this session, reject).
    • Plan mode: plan approval goes through the same dialog, and current_mode_update follows when it switches the mode.
    • lcode's state: the permission modes are the session modes, the todo list becomes plan updates, and usage_update and session_info_update follow each request.
    • Sessions: session/load replays a saved lcode session.
    • Commands: /review and the user's own commands go in available_commands_update.
    • The editor's buffers: with fs.readTextFile/writeTextFile, the model reads what's in the editor (unsaved changes included), and edits go through the editor. The file on disk is kept in step for checkpoints.
    • MCP: servers the editor passes (stdio and http) join lcode's own.
    • Prompts: text, resource_link and embedded resource (inlined), and images (saved and attached, so lcode's vision handles them).
  • Agent hooks this needed: on_delta (streamed text and thinking), current_call, plan_review (an editor approves plans), and Toolbox.reader/writer. Permissions.approve may now return a message, and gets the permission key.
  • Fix: cancelling now also ends a request whose answer was cut off mid-stream. Before, it ended as if complete.
  • Docs: a new Editors page covering Zed (agent_servers with "type": "custom"), JetBrains (~/.jetbrains/acp.json), other ACP clients, what maps to what, and settings.

Tests

  • tests/test_acp.py (8 tests), with a pipe-connected editor stand-in and a scripted model. It covers:
    • initializing, sessions and unknown methods;
    • edit permissions with diffs and writes through the editor;
    • reject and always-allow;
    • reading unsaved buffers;
    • plan approval with plan and mode updates;
    • cancelling;
    • files, images and /review in prompts;
    • loading and replaying a session.
  • Real runs with the official ACP Python SDK (agent-client-protocol 0.12.1) as the client, which validates every message against its models, and Qwen3.6 35B through Ollama:
    1. Ask mode: fixing two bugs asked twice in the editor's dialog (allow_once/allow_always/reject_once) with whole-file diffs, and both edits went through fs/write_text_file.
    2. Unsaved buffer: a new session read calc.py and quoted a line that existed only in the editor's buffer.
    3. Plan mode: the plan was approved in the editor; the mode switched to auto-edit (current_mode_update), and the todo list arrived as plan updates.
    4. Cancel: session/cancel during a request returned stopReason: cancelled.
    5. Load: session/load in a new connection replayed the conversation.
  • Not run inside Zed or a JetBrains IDE. Those need a desktop session; the docs ask for the ACP log if something looks off.

🤖 Generated with Claude Code

lcode acp speaks ACP version 1 over stdio, so Zed, JetBrains IDEs,
Neovim, Emacs and other ACP editors can run lcode as their agent. The
model's text and thinking stream as message chunks; tool calls carry
their kind, files and whole-file diffs; permission questions and plan
approvals use the editor's dialog; lcode's permission modes are the
session's modes; the todo list is the editor's plan; saved sessions
load with their conversation replayed. Files are read from and written
through the editor's buffers when it supports that, and MCP servers
the editor passes join lcode's own. /review and your own commands are
offered as commands.

Cancelling now also ends a request whose answer was cut off mid-stream.

Closes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nasser1941
nasser1941 merged commit 99ffdc9 into main Oct 5, 2026
12 checks passed
@nasser1941
nasser1941 deleted the feat/acp branch October 5, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor integration through the Agent Client Protocol

1 participant