This file provides guidance to Claude Code when working with this repository.
VS Code extension that connects to a running Polyphon instance for multi-voice AI conversations, with code context awareness.
npm install
npm run build # type-check (tsc --noEmit) then esbuild production bundles
npm run dev # esbuild one-shot build (non-production)
npm run package # build + vsce package → .vsix
npm run lint # eslint src/Development mode (recommended): Open this folder (not the parent polyphon-ai/ directory) in VS Code and press F5. This runs npm run dev, then launches an Extension Development Host window with the extension loaded from source. After making changes, run npm run dev in the terminal and press Cmd+R in the host window to reload — no reinstall needed.
Install from VSIX:
npm run buildnpm run packageto produce a.vsix- In VS Code: Extensions → ⋯ → Install from VSIX
src/
extension.ts # Activate/deactivate, register views, commands, status bar
PolyphonManager.ts # PolyphonClient lifecycle — connect, reconnect, settings watch
SidebarProvider.ts # WebviewViewProvider — orchestrates extension↔webview messages, API calls
StatusBarItem.ts # Connection indicator in the VS Code status bar
context.ts # Code context helpers (active file, selection, diagnostics)
webview/
index.ts # Webview bundle entry — DOM setup, message handling (NO vscode imports)
ConversationView.ts # Multi-voice thread renderer (NO vscode or Node imports)
parseMention.ts # @VoiceName mention extraction
media/
icon.svg # Monochrome activity bar icon
style.css # Webview styles using VS Code CSS variables (--vscode-*)
dist/
extension.js # Extension host bundle (CJS, Node)
webview.js # Webview bundle (IIFE, browser)
esbuild produces two separate bundles:
- Extension host (
src/extension.ts→dist/extension.js): CJS, Node platform,vscodeand Node builtins are external - Webview (
src/webview/index.ts→dist/webview.js): IIFE, browser platform, no Node APIs
The @polyphon-ai/js SDK (uses node:net) is only imported in the extension host — never in the webview.
All communication is via postMessage. See SidebarProvider.ts for messages sent to the webview and src/webview/index.ts for messages sent back.
Extension → Webview: state, profile, compositions, sessions, sessionCreated, voices, messages, userMessage, showPending, chunk, streamDone, streamError, sendEnabled, prefillInput, focusCompositionSelect
Webview → Extension: ready, reconnect, selectComposition, newSession, selectSession, send
- Requires Polyphon to already be running on port 7432 (configurable)
- Connection auto-starts on activation; auto-reconnects every 5 seconds on drop
- Sessions are created with
source: 'vscode'and filtered to show only VS Code sessions in the sidebar - Code context (file path, selection, diagnostics) is attached to the message content when the user enables it — the webview displays only the plain user text
ConversationView.tsandparseMention.tsare intentionally free of VS Code and Node.js imports
| Setting | Default | Description |
|---|---|---|
polyphon.host |
127.0.0.1 |
Polyphon API host |
polyphon.port |
7432 |
Polyphon API port |
polyphon.token |
"" |
API token (use 'Polyphon: Read Local API Token' to auto-populate) |
Part of the polyphon-ai workspace. See ../CLAUDE.md for how all projects relate.