Cody (VS Code extension)
IDE companion for the Cody CLI. Lets Cody open files, read diagnostics, and show inline diffs directly in your editor instead of only in the terminal.
What it does
On activation, this extension starts a small local MCP server and writes a
lockfile at ~/.cody/ide/<port>.lock describing how to reach it. When you
run cody from this editor's integrated terminal, the CLI finds that
lockfile, connects over an authenticated WebSocket, and calls back into the
editor for:
openFile — open a file, optionally with a text range selected
getDiagnostics — read current LSP/compiler diagnostics for a file or the whole workspace
openDiff — show a proposed change as a native diff view you can accept or reject
close_tab / closeAllDiffTabs — close diff tabs the CLI opened
The connection is authenticated with a random per-session token generated
at startup and checked on every WebSocket handshake (X-Cody-Ide-Authorization
header) — nothing is exposed beyond localhost, and the lockfile (which
contains that token) is written with 0600 permissions.
Status bar
While running, a status bar item shows the local port the IDE server is
listening on. Click it (or run Cody: Show Status from the command
palette) to confirm it's active.
Development
bun install
bun run build # esbuild bundle to dist/extension.js
bun run typecheck # tsc --noEmit
bun test test/ # protocol tests — spins up a real server, connects a
# real MCP client over a real WebSocket, and asserts
# on the exact wire shapes the CLI parses
src/mcpServer.ts, src/ideServer.ts, src/lockfile.ts, and
src/wsTransport.ts have no dependency on the vscode module and are
covered directly by test/protocol.test.ts. src/editorOpsVscode.ts is
the only file that touches the real VS Code API; it implements the
EditorOps interface from src/editorOps.ts that the MCP tool handlers
are written against, so the protocol layer can be tested without a running
VS Code instance.
Packaging
bun run package # requires @vscode/vsce, produces a .vsix