# Editor (ACP)

`openprogram acp` is the agent side of [ACP](https://agentclientprotocol.com), the Agent Client Protocol. Zed speaks it natively, so no extension is needed. The editor launches the command; it speaks JSON-RPC on stdin and stdout and exits when the editor disconnects.

## Zed

Add this under `agent_servers` in `settings.json` (`cmd-shift-p` → `zed: open settings file`), then pick **OpenProgram** from the Agent Panel's new-thread menu. If `openprogram` is not on Zed's `PATH`, use `which openprogram` as `command`.

```
{
  "agent_servers": {
    "OpenProgram": {
      "type": "custom",
      "command": "openprogram",
      "args": ["acp"],
      "env": {}
    }
  }
}
```

| Flag | Effect |
| --- | --- |
| `--agent <id>` | Run sessions as this agent instead of `main`, with its own system prompt and tools |
| `--permission <mode>` | `bypass` (Bypass permissions, default), `auto`, `ask`, `plan` or `acceptEdits`: [Permissions](https://fzkuji.github.io/OpenProgram/docs/capabilities/permissions.html) |

```
"args": ["acp", "--agent", "coding", "--permission", "acceptEdits"]
```

## What works

| Feature | Behaviour |
| --- | --- |
| Working directory | Tools start in the folder the editor opens the thread in, which becomes the conversation's project, as with `openprogram --print`. A folder that cannot be opened as a project runs in the home folder, with a warning on stderr. |
| Project marker | The first prompt registers the folder as a project, shows it again in the App if you had hidden it, and writes its marker, `.openprogram/project.json`, into the folder; add `.openprogram/` to `.gitignore` to keep it out of a repository. A thread you never prompt leaves nothing behind. |
| Streaming | Token by token; reasoning as a separate thought stream when the model produces one |
| Tool calls | Reported at start and finish with arguments and result; file tools report the path so Zed can follow |
| Editor context | An attached selection or file goes into the prompt under its path; the model can read more |
| Permission prompts | **Allow**, **Always allow**, **Reject**. Always allow writes a persistent rule for that tool to the project's settings, as in the Web UI. The turn goes on after the answer within the same prompt. An editor that answers the request with an error, or not within 10 minutes, rejects it. Questions the agent asks you have no ACP form and are declined. |
| System access | A step that needs system access, such as Accessibility, cannot be granted from an editor: the turn stops and the prompt fails with an error naming the access. |
| Cancellation | Stopping a thread stops the model request in flight, starts no other, and withdraws any open prompt |
| Errors | A turn that fails, such as on a provider error, answers the prompt with a JSON-RPC error carrying the reason, also when it fails after a permission answer. A turn that stops where the editor cannot move it on, paused from the App or needing reconciliation, ends the prompt with an error too; continue it in OpenProgram. |
| Resuming | Reopened threads replay from the session store. Sessions are ordinary ones, visible in [Web](https://fzkuji.github.io/OpenProgram/docs/interfaces/web.html) and the [TUI](https://fzkuji.github.io/OpenProgram/docs/interfaces/tui.html) and continuable from either. |

## Scope

- Sessions run with local owner authority, which is what allows approval prompts. Do not expose the command over a network transport.
- MCP servers passed in `session/new` are ignored; OpenProgram uses its own [MCP configuration](https://fzkuji.github.io/OpenProgram/docs/capabilities/mcp.html). Audio prompts are not supported.
- Protocol version 1: `initialize`, `session/new`, `session/load`, `session/prompt`, `session/cancel` from the editor; `session/update`, `session/request_permission` back.
