English · 한국어
The editor face of the Mirr Code core.
A thin, honest ACP client for VS Code. The extension owns the editor surface — chat, approvals, sessions, files, terminals — and the Mirr Code core owns the agent.
One ACP session per workspace folder, streamed as NDJSON JSON-RPC over mirr acp.
What this repo does
Chat webview — a sidebar chat with streamed message and thought chunks, plan updates, tool cards, and slash commands rendered inside a VS Code webview.
ACP client — AcpClient speaks ACP v1 to mirr acp over stdin/stdout: initialize, session/new|load|resume|prompt|cancel|list|close|delete, session/set_mode, session/set_config_option, and the _patty.io telemetry extension.
Tool approval gate — permission requests become native VS Code prompts. Ask, Auto, and Yolo modes come from the core's tool_approval config option; the extension never decides policy on its own. A new session starts at the core default; only a mode the person picked carries into the next new session in the same workspace.
Session lifecycle — per-folder sessions survive window reloads. session/load replays a persisted transcript; reconnect uses session/resume to avoid duplicating it.
Editor bridges — fs/read_text_file and fs/write_text_file see unsaved buffers; foreground commands can run in client-owned terminals. Both are gated on workspace trust.
Telemetry — the status bar tracks connection state and cache hit rate from _patty.io/session/status schema v1.
Controls — model, reasoning effort, work mode, tool approval, and collaboration mode are all read from the session's advertised configOptions and modes.
Mid-turn steering — while a turn runs, the composer sends guidance through the core's advertised _patty.io/session/steer method instead of cancelling; a separate stop control stays available.
Runtime reload — Mirr Code: Reload Extensions or a /reload submission calls the core's vendor reload method and reports whether it ran immediately or queued behind the active turn.
MCP pass-through — mirr-code.mcpServers entries are validated in the extension and sent with every session open, so the editor and core share one MCP set.
Editor tools - every session also gets a built-in vscode MCP server on loopback, so the agent can read diagnostics, open editors, the current selection, and definitions, references, and workspace symbols from VS Code's language services. Each session holds its own bearer token, and all tools are read-only. A mirr-code.mcpServers entry named vscode replaces it.
Edit review — every file edit the core proposes opens as a VS Code diff first. Each hunk is accepted by default; exclude any hunk, then apply. Nothing is written until you decide, and files changed while the diff is open are refused rather than overwritten.
Worktree sessions — Mirr Code: New Session in Worktree creates a git worktree beside the repo and opens it in its own window, so parallel sessions never share a working tree.
Diagnostics context — Mirr Code: Fix Diagnostics in This File sends the current file's Problems entries to the agent.
Account sign-in — when the core advertises _meta["patty.io"].account and no Patty account is connected, the chat shows a sign-in card. Mirr Code: Sign In starts the core's device flow, opens the approval page (trying $BROWSER and a shell browser first on SSH, WSL, and dev containers), and keeps the URL and user code visible so the flow can finish without a browser. The token stays in the core; the extension never stores it.
Setup bootstrap — on enterprise builds that advertise a terminal auth method, Mirr Code: Run initial setup runs mirr setup in a VS Code terminal, and auth-related failures offer the same action.
Design philosophy
- The core is the product. No agent logic lives here. If the core can change it, the extension reads it from ACP.
- Capabilities over assumptions. Controls appear only when the session advertises them; unknown
_meta is ignored rather than guessed.
- The editor is the sandbox. Unsaved buffers and host terminals are offered to the agent, but only inside a trusted workspace.
- Visible autonomy. Every turn is inspectable: streamed reasoning, plans, tool cards, approval gates, and usage.
- One contract, no forks. Wire names, config ids, and capability keys stay byte-identical to the Mirr Code core.
Architecture
┌────────────────────────────── VS Code window ───────────────────────────────┐
│ Chat webview (media/webview.js) │
│ ▲ │
│ │ webview protocol │
│ ▼ │
│ Extension host — MirrCodeChatProvider (src/extension.ts) │
│ ├── AcpClient (src/acpClient.ts) ⇄ NDJSON JSON-RPC ⇄ mirr acp │
│ ├── FileBridge (unsaved buffers, workspace-scoped) │
│ ├── TerminalBridge (client-owned terminals, trust-gated) │
│ └── Preview / resource mentions / slash commands │
└──────────────────────────────────────────────────────────────────────────────┘
│
Mirr Code core (single binary)
providers · tools · MCP · sessions · transcripts
Quick start
Prerequisites:
- Node.js 22 or newer
- VS Code 1.92 or newer
- Mirr Code CLI installed and configured —
mirr setup, then verify mirr acp starts
npm ci
npm run compile
npm run dev:host # opens a VS Code development host with a scratch workspace
If mirr is not on PATH, point the extension at it:
// settings.json
{ "mirr-code.binaryPath": "/usr/local/bin/mirr" }
For a normal local install, package the VSIX and install it:
npm run package:vsix
npm run verify:vsix-contents
code --install-extension dist/mirr-code-vscode.vsix
Common commands
| Command |
Purpose |
npm run compile |
Bundle the extension, webview, and tests with esbuild |
npm run watch |
Rebuild on change while working on the extension |
npm run dev:host |
Launch a VS Code development host with a scratch workspace |
npm run lint |
Type-check with tsc --noEmit |
npm test |
Compile and run the node:test suites |
npm run test:vscode |
Run the VS Code extension-host integration suite |
npm run smoke:acp |
Exercise a real mirr acp process end to end |
npm run debug:extension |
lint + unit + host + smoke in one shot |
npm run package:vsix |
Build dist/mirr-code-vscode.vsix |
npm run verify:vsix-contents |
Assert the VSIX contains exactly the expected files |
npm run package |
Publish-oriented vsce package |
Extension commands
| Command |
Purpose |
Mirr Code: Sign In |
Start the core's device-flow sign-in and open the approval page |
Mirr Code: New Session in Worktree |
Create a git worktree and open it as a new window |
Mirr Code: Remove Session Worktree |
Remove a worktree, with an explicit force path |
Mirr Code: Fix Diagnostics in This File |
Send the active file's Problems to the agent |
Mirr Code: Sign Out |
Revoke the credential and clear the account |
Mirr Code: Run initial setup |
Run mirr setup in a terminal (enterprise provider configuration) |
Mirr Code: Reload Extensions |
Rebuild the core runtime (also available as /reload) |
Mirr Code: Pick UI Language |
Switch between auto, Korean, and English |
Settings
| Setting |
Default |
Meaning |
mirr-code.binaryPath |
"" |
Absolute path to the CLI; empty resolves mirr from PATH |
mirr-code.model |
"" |
Startup provider/model passed to mirr acp --model |
mirr-code.uiLanguage |
ko |
UI language: auto, ko, en. Korean is the default. |
mirr-code.mcpServers |
[] |
MCP servers passed to the core: stdio (command, args, env) or HTTP (url, headers) |
mirr-code.autoStart |
false |
Start ACP when the chat view opens |
mirr-code.trace |
false |
Log JSON-RPC traffic to the Mirr Code output channel |
mirr-code.includeSelectionMode |
selectionOnly |
What the editor appends to prompts: off, selectionOnly, nearby |
mirr-code.sendShortcut |
enter |
Which key sends: enter (Shift+Enter for a new line) or ctrlEnter (Ctrl/Cmd+Enter sends, Enter for a new line) |
Repository layout
src/ Extension host: ACP client, bridges, webview controller, protocol types
media/ Webview bundle, styles, brand mark and icon
test/ node:test suites plus the VS Code extension-host harness
scripts/ ACP smoke, dev-host launcher, VSIX content verifier
docs/assets/ Branding assets used by this README
.github/ CI (Linux + Windows) and release/publish workflows
Working order
- Type-check first.
npm run lint must be clean before any test run.
- Unit tests next.
npm test covers protocol parsing, state reduction, and launch resolution.
- Then the host.
npm run test:vscode drives the real extension inside VS Code, including approvals, terminals, and disconnect recovery.
- Then the real core.
npm run smoke:acp must pass against an installed mirr before pushing changes that touch ACP.
- Wire strings are contracts.
_patty.io/session/status, _patty.io/session/status_update, and the ACP method names must match patty-io/mirr-code exactly. Never invent a namespace, and never rename one side alone.
- Extension ids are contracts. Settings, commands, views, and storage keys all use the
mirr-code.* prefix. Changing them is a user-visible migration, not a rename.
- Env vars are prefixed. Runtime and test switches use
MIRR_CODE_*.
- Localize user-facing text. Webview strings live in
src/webview/labels.ts (Korean and English). Host notifications go through src/localization.ts. Korean is the default UI.
- Package both ways. Before tagging, run
npm run package:vsix and npm run verify:vsix-contents.
Troubleshooting
- “Mirr Code CLI was not found on PATH” — install Mirr Code, set
mirr-code.binaryPath, or run mirr setup.
- Turns fail before streaming — the core has no account. Sign in from the chat card or
Mirr Code: Sign In; the core advertises patty-login when it supports in-editor sign-in. Enterprise builds that advertise patty-setup can run mirr setup instead.
- File and terminal tools are refused — the workspace is not trusted. Trust the folder; the bridges intentionally fail closed.
- Extension-host tests fail on Linux CI — they need a display; CI wraps them in
xvfb-run.
smoke:acp says “skipped” — no mirr binary was found. Set MIRR_CODE_BINARY, or MIRR_CODE_ACP_SMOKE_REQUIRED=1 to make absence fatal.
- Windows resolves a
.cmd shim — the launcher follows the patty-code npm layout to the packaged native executable when it can.
- The send button acts as stop instead of steering — the connected core did not advertise mid-turn steering. Older binaries keep the stop-only composer.
- Reload reports "not supported" — the core did not advertise
sessionReloadExtensions. Update the CLI.
- The UI is not in Korean — check
mirr-code.uiLanguage; the default is ko, and auto follows the VS Code display language.
Reference documents
License
Confidential and proprietary. Copyright © 2026 Patty Co., Ltd. All rights reserved.
This repository is for authorized Patty employees and contractors only; it may not be copied,
distributed, or used outside Patty without written permission. See LICENSE.txt.
MIRR CODE · one core · many surfaces · zero duplicated agent logic