diff --git a/README.md b/README.md index 30d76b6..4b6cee5 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ With **`/skills` (Alt+K)**, install skills from Git, ZIP files, or local folders | **Workspace** | Independent agents | Up to four agents per workspace, with separate models, conversations, settings, and approvals | | **Workspace** | Named workspaces | Organize projects and switch workspaces while background agents keep working | | **AI** | Agent collaboration | Tag agents with `@` to ask questions, request reviews, and hand off independent tasks | -| **Agents** | External ACP agents | Run an Agent Client Protocol agent (for example Claude Code through an ACP adapter) in its own pane, with tool calls, diffs and permission prompts in the transcript. Opt-in; see [docs/acp.md](docs/acp.md) | +| **Agents** | External ACP agents | Run an Agent Client Protocol agent (for example Claude Code through an ACP adapter) in its own pane, with tool calls, diffs and permission prompts in the transcript. Opt-in; see [ACP setup](#external-agents-acp) | | **Memory** | Context snapshots | Save a conversation summary and import it into another agent | | **Memory** | Agent history | Search, preview, and restore closed agents with their conversation context | | **Tools** | File Explorer and Git review | Browse files, attach references, change directories, and inspect project diffs | @@ -254,7 +254,7 @@ Type `/` to see the autocomplete dropdown, or `!` to run a shell command. | `/agent-new` | Open an independent agent pane (Alt+N) | | `/agent-focus` | Switch agents; optional left/right (Alt+Left/Right) | | `/agent-close` | Close the current idle agent | -| `/agent-acp ` | Switch this pane to an external ACP agent (such as Claude Code through an adapter); `--new-panel` opens it in a new pane. Also `stop`, `list`, `status`, `restart`, `add`, `test`, `remove`, `enable`, `disable` ([details](docs/acp.md)) | +| `/agent-acp ` | Switch this pane to an external ACP agent (such as Claude Code through an adapter); `--new-panel` opens it in a new pane. Also `stop`, `list`, `status`, `restart`, `add`, `test`, `remove`, `enable`, `disable` ([details](#external-agents-acp)) | | `/agent-rename ` | Rename this agent | | `/agent-settings` | Edit this agent's model, behavior, and integrations (Alt+S) | | `/agent-file-explorer` | Browse this agent's files and folders (Alt+E) | @@ -506,10 +506,26 @@ An optional `acpAgents` section in `~/.mandocode/config.json` (read only from th The agent runs without a shell, from a real executable (`.exe`/ELF, never `.cmd`, `npx` or a shell), and MandoCode asks you to confirm the full command before the first start and again whenever it changes. Install the adapter yourself, at a pinned version; MandoCode never downloads anything. The agent signs in with its own tooling, and -`ANTHROPIC_API_KEY` is not passed to it unless you opt in. See [docs/acp.md](docs/acp.md) for setup, trust, permissions, -file access, the debug trace and what is not supported yet. MandoCode does not sandbox the agent: permission +`ANTHROPIC_API_KEY` is not passed to it unless you opt in. MandoCode does not sandbox the agent: permission questions are relayed, and the agent applies the answers itself. +Use `/agent-acp add codex` for Codex adapter installation and registration guidance. After registering an agent: + +```text +/agent-acp test codex +/agent-acp codex --new-panel +``` + +Replace `codex` with your configured agent name. Use `/agent-acp-mode` to choose its advertised permission mode, +`/model` to select an available model, and `/agent-acp stop` to return to the native conversation. Agent-provided +slash commands appear with the connected agent's name. Alt+V attaches an image when the agent supports image prompts. + +Changing folders restarts only that ACP pane and keeps the transcript. MandoCode attempts to continue its session; +if the adapter starts fresh, choose whether to carry recent text context. A project-change note tells the agent to +re-read files before the next request. `/clear` starts a fresh ACP conversation and discards pending context. +`/agent-acp --resume` requests the remembered session for this folder; `/agent-acp sessions` lists available +sessions when supported. Agent memory and session continuation depend on the adapter. + ### Config File Located at `~/.mandocode/config.json` diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a038db0..cf4d321 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,8 @@ All notable changes to MandoCode will be documented in this file. ### Added +- ACP folder changes retain the selected pane's transcript and attempt to continue its session in the new folder. If the adapter starts fresh, offer a bounded recent-text handoff or a fresh context. Send a project-change note before the next request so the agent rechecks old paths and files. Other ACP panes remain unchanged; `/clear` discards pending handoff context. Use the same concise folder-change wording as native conversations, without repeating the connection card or internal acknowledgment. + - Paste clipboard images into ACP prompts with Alt+V when the connected agent advertises image support. Send in-memory PNG image blocks with text, retain per-pane attachment references and size limits, and explain unsupported agents or expired images without sending an incomplete prompt. - ACP agent-provided commands appear in slash-command suggestions with the connected agent’s display name (for example `[Codex]`), descriptions, and input hints. Advertised commands and arguments are forwarded to the current agent as prompts; session updates replace the list, and MandoCode commands retain precedence on name collisions. diff --git a/docs/acp-codex.md b/docs/acp-codex.md deleted file mode 100644 index a49d8e9..0000000 --- a/docs/acp-codex.md +++ /dev/null @@ -1,85 +0,0 @@ -# Codex in an ACP pane - -MandoCode can use the maintained [Codex ACP adapter](https://github.com/agentclientprotocol/codex-acp) -through the existing ACP client. Codex owns model execution, its tools, and authentication. -MandoCode displays the conversation and relays permissions through the same pane integration used for other ACP agents. - -## Setup on Windows - -Install Node.js and sign in to Codex separately with `codex login`. MandoCode does not perform -the adapter's authentication flow or collect credentials. An existing compatible Codex login -can be reused; if authentication is required, finish it with Codex before reconnecting. - -Install a pinned adapter into a folder you control. For example, in PowerShell: - -```powershell -$adapterFolder = Join-Path $env:USERPROFILE '.mandocode\acp\codex' -npm install --prefix "$adapterFolder" --save-exact @agentclientprotocol/codex-acp@2.6.0 -Join-Path $adapterFolder 'node_modules\@agentclientprotocol\codex-acp\dist\index.js' -``` - -Copy the absolute path printed by the last command. In MandoCode, register it with: - -```text -/agent-acp add codex node "C:\Users\YOUR_NAME\.mandocode\acp\codex\node_modules\@agentclientprotocol\codex-acp\dist\index.js" -/agent-acp test codex -/agent-acp codex --new-panel -``` - -Replace `YOUR_NAME` with your Windows user folder. If Node is not on PATH, use the absolute -path to `node.exe`. The adapter's package includes a compatible Codex dependency; a separately -installed Codex executable can be selected using `CODEX_PATH` in the entry's environment. -Keep the installation's lock file to preserve the resolved dependency versions. - -`/agent-acp add codex` prints this setup guidance. It does not install an adapter or save a -configuration automatically. The normal launch confirmation still applies. MandoCode runs -Node directly, without `npx`, an npm shim, or a shell at launch time. - -Other operating systems can use the same npm package and register its absolute JavaScript -entry path with `node`. The live validation below was performed on Windows only. - -## Commands and boundaries - -- `/agent-acp-mode` opens the agent's mode picker, with its descriptions and current selection. For example, Codex can offer Read-only, Workspace access, Auto review, and Full access. These are agent-defined permission and behavior modes, not MandoCode's native approval settings. -- `/agent-acp-mode read-only` selects an advertised mode directly. Changes keep the conversation and are refused while the pane has active work. The selection applies to this session; it does not rewrite global Codex configuration. -- `/model` uses the adapter's advertised model configuration. Available models depend on the account and adapter. -- `/compact` and other agent-provided commands appear when the adapter advertises them. -- Alt+V attaches a clipboard image when the connected adapter advertises image prompt support. -- `/clear` starts another ACP conversation and preserves the native MandoCode conversation. -- `/copy` and `/copy-code` read the ACP conversation's last reply. -- `/agent-acp stop` returns to the native conversation. -- Folder changes follow the normal ACP restart and confirmation flow. - -Capability handling remains shared with other ACP agents. This setup does not add native -agent mentions, context handoff, or the proposed MandoCode MCP bridge. -The generic ACP restrictions still apply even if Codex itself advertises additional features. - -The adapter also supports API-key authentication. Existing `OPENAI_API_KEY` and `CODEX_API_KEY` -environment variables are not filtered by MandoCode. Check your Codex authentication setup -if you specifically intend to use an existing ChatGPT login instead of API billing. - -## Validation - -Validated on Windows with `@agentclientprotocol/codex-acp` 2.6.0: - -- ACP v1 initialization and session creation using existing login state, with API-key variables removed from the test process. -- MandoCode's actual `AcpClient` and process transport connected to the adapter and parsed its configuration options. -- Selected read-only mode, received a short streamed text reply, and closed the session and client successfully. -- The adapter accepted a `session/set_config_option` change for its `mode` option to `read-only`, then closed the session. The mode picker and its routing have automated coverage; its full interactive flow still needs a manual terminal check. -- Command tests cover setup guidance without saving an entry and explicit executable registration. - -This verifies the core connection and text path. Interactive permission menus, cancellation, -model changes, compaction, session restoration, and folder restarts need manual validation -with Codex before claiming those flows have been tested against this adapter. - -### Automated test results - -- Final full-suite validation: 1,919 passed, one skipped, and zero failed on each of net8.0 and net10.0. The skip is the existing symlink-creation test on this Windows machine; the junction guard has separate coverage. -- All 95 targeted activity, permission, transcript, and export checks pass on both frameworks, including expansion across live updates and tool-call identity across turns and panes. -- All 64 agent-command tests pass on both net8.0 and net10.0, including the two new Codex tests. -- The first full run had 1,893 passes, one skip, and one failure on each target: a Windows - file-access error in the concurrent config-save test on net8.0, and a command-notification - timeout on net10.0. These are not Codex-specific tests; their cause remains unresolved. -- The notification test passed in isolation. Unchanged main passed its config-save tests and - its complete net10.0 suite (1,892 passes, one skip). The final branch run above is clean; - the earlier failures are retained here as validation history rather than attributed to a known fix. diff --git a/docs/acp.md b/docs/acp.md deleted file mode 100644 index 57f353c..0000000 --- a/docs/acp.md +++ /dev/null @@ -1,414 +0,0 @@ -# ACP agents (Agent Client Protocol) - -MandoCode can run an external coding agent as a child process and talk to it over the -[Agent Client Protocol](https://agentclientprotocol.com) (ACP v1, JSON-RPC 2.0 over stdio, NDJSON). -Authentication is the agent's own business; MandoCode never handles agent tokens. - -The protocol layer lives in `src/MandoCode.Acp` (no UI dependencies, no third-party ACP libraries). -Schema: pinned to the release tag `v1.16.0` of `agentclientprotocol/agent-client-protocol` (checked to exist), vendored in -`tests/MandoCode.Tests/Acp/schema/schema.v1.json`. The tag is the schema release; the protocol version is still 1 -(`protocolVersion: 1` in `initialize`). - -## Quick start - -For Codex, see [Codex adapter setup and validation](acp-codex.md), or run `/agent-acp add codex` for setup guidance. - -1. Install an ACP adapter yourself, at a pinned version, for example for Claude Code the adapter validated below. No `npx`. -2. Add it (your own paths): `/agent-acp add claude node "C:\path\to\adapter\dist\index.js"`, or edit `acpAgents` in - `~/.mandocode/config.json`. -3. Check it: `/agent-acp test claude` (or `mandocode --acp-probe claude`). You are asked to confirm the command first. -4. Use it: `/agent-acp claude` switches the current pane to the agent (`--new-panel` opens it in a new pane instead). - Sign in to the agent with its own tooling beforehand (`claude auth login`). `/agent-acp stop` returns the pane to - MandoCode's own agent. - -Status of this first version: phases 1–2, plus switching a pane in place (originally planned for a later phase, and -without passing context: see "Deviations"). Not included: `terminal/*`, images, resuming sessions, handing a -conversation between the native agent and an ACP agent, asking an ACP agent with `@`, a settings tab for agents. -Open questions are marked **pending** below. - -**Security model in one paragraph.** MandoCode does not sandbox the agent. It decides what program runs (no shell, -real executables only, confirmed by hash, configured only in the user's own config) and what environment it gets -(no `ANTHROPIC_API_KEY` by default), and it relays the agent's permission questions; the agent applies the answers -itself. Treat an ACP agent as a program with your user's rights. - -## Launch rules - -An agent command is code that runs with your permissions, so launching is deliberately strict: - -- No shell: `ProcessStartInfo` with `UseShellExecute = false` and `ArgumentList`. - `cmd.exe`, `powershell`, `sh -c` and friends are refused. -- The command must resolve (through `PATH`, or as an absolute path) to a real executable: - `.exe` on Windows, ELF/Mach-O on Unix. `.cmd`, `.bat`, `.ps1` and `#!` scripts are refused: - *specify the path to an .exe or run the adapter as `node