VS Code Extension Architecture

The VS Code extension (packages/biggi-vscode/) is the BIGGI client. It bundles the local runtime, starts one shared editor-owned server on demand, and drives that server through generated SDK HTTP calls plus global SSE.

ℹ️Scope

This page covers extension-host ownership, webview routing, Agent Manager, local terminal paths, recovery, bundled resources, and build outputs. It is not full extension feature inventory.

Shared server ownership

Embedded Runtime defines local-server authentication, directory routing, provider routing, persistence, and SSE contracts. This page starts at the VS Code client boundary.

Activation creates one BiggiConnectionService. It owns one ServerManager, one active SDK client, and one SSE adapter. ServerManager owns child process lifecycle. This editor-owned child is separate from detached local daemon managed by biggi daemon.

flowchart LR
  subgraph host ["VS Code extension host"]
    consumers["Sidebar, tabs, panels, services"]
    service["BiggiConnectionService"]
    manager["ServerManager"]
    sdk["Generated SDK client"]
    sse["SdkSSEAdapter"]
  end

  server["bin/biggi serve --port 0"]
  runtime["BIGGI local runtime"]

  consumers --> service
  service --> manager --> server
  service --> sdk --> server
  service --> sse -->|/global/event| server
  server --> runtime
AreaBehavior
StartupLazy on client demand; autocomplete prewarm can start server during activation
BinaryUses extension bin/biggi, or bin/biggi.exe on Windows
PortStarts biggi serve --port 0; the runtime server prefers 4096, then asks the OS for a free port
AuthenticationGenerates random 32-byte hex password per spawn and passes it as BIGGI_SERVER_PASSWORD; username defaults to biggi
ReuseSidebar, editor tabs, panels, Agent Manager, and host services share active server
ExitServerManager clears dead child; connection service clears SDK/SSE state and enters error state
ReplacementLater retry or connection attempt starts replacement server

Shared consumers

Shared service has more consumers than chat tabs:

FamilyConsumers
ChatSidebar provider and editor-tab providers
PanelsSettings, profile, sub-agent viewers, and Agent Manager
DiffDiff Viewer, Diff Virtual, and diff source catalog
Editor assistanceAutocomplete and commit-message generation
IntegrationsBrowser automation and MCP registration

New mutable state must account for concurrent consumers and multiple directory contexts on one process.

Webview bridge

Main chat webviews use host-mediated message bridge:

webview vscode.postMessage()
  -> BiggiProvider host handler
  -> generated SDK HTTP request
  -> embedded runtime
  -> /global/event SSE
  -> SdkSSEAdapter
  -> BiggiConnectionService subscribers
  -> BiggiProvider directory/session filtering and stream coalescing
  -> webview postMessage()

Global SSE carries wrapped events for multiple directories. Connection service broadcasts incoming payload plus directory to subscribers. Providers resolve session scope, maintain message-to-session lookup where events omit direct session ID, filter for relevant views, and coalesce high-frequency stream updates before posting UI messages.

Agent Manager

Agent Manager is extension feature, not separate product. It opens as editor tab and manages parallel sessions, optional worktrees, terminals, diffs, setup scripts, and extra editor windows.

AspectSidebarAgent Manager
Primary useOne active chat viewMulti-session orchestration
Git isolationWorkspace root by defaultOptional worktree per session
BackendShared biggi serve processSame shared process
Request routingWorkspace directorySession worktree path passed as SDK directory
Runtime instance keyNormalized workspace rootNormalized worktree directory

Agent Manager request path is:

session worktree path -> SDK directory -> runtime directory-routing middleware -> InstanceStore directory key

Agent Manager persists state in .biggi/agent-manager.json and worktrees under .biggi/worktrees/. Startup migration moves Agent Manager-owned data from legacy .biggi/ paths when target items do not already exist and repairs git worktree refs.

State boundaries

Directory-keyed runtime state is isolated by worktree path. Process-owned state remains shared because all Agent Manager sessions use one runtime process. Snapshot implementation state is directory-keyed, but slow-snapshot prompt guard belongs to shared Snapshot.Service scope. Managed Agent Manager prompts pass snapshotInitialization: "wait" so slow baseline setup waits without interrupting concurrently started sessions.

Terminal surfaces

VS Code extension has two terminal paths:

SurfaceOwnerUse
VS Code integrated terminalVS Code hostShell terminals and setup-script execution surfaced through editor
Runtime PTY WebSocket tabAgent Manager and embedded serverServer-created PTY session streamed over loopback WebSocket

Agent Manager PTY WebSocket URL uses auth_token=<base64 biggi:password> query mode because browser WebSocket API cannot attach Basic header. Webview CSP permits loopback HTTP and WebSocket origins for the active server port. The runtime also exposes a scope-bound, short-lived PTY ticket API as an alternate browser WebSocket auth mode.

Config split

Config ownerExamples
VS Code settingsbiggi-code.new.* extension UI, proxy, autocomplete, and integration settings
Runtime configGlobal and project biggi.jsonc, biggi.json, compatible OpenCode files, provider auth, tools, permissions, modes

Extension-specific behavior belongs in VS Code settings. Agent runtime behavior belongs in runtime config.

Bundled resources

ResourceBehavior
Runtime executablePlatform binary under extension bin/; Windows uses biggi.exe
Runtime Tree-sitter WASMCopied under bin/tree-sitter; backend spawn sets BIGGI_TREE_SITTER_WASM_DIR
Empty-window cwdUses extension global storage directory when no VS Code workspace folder exists
Empty-window indexingSets BIGGI_DISABLE_CODEBASE_INDEXING=vscode-no-workspace so the runtime reports indexing disabled

Speech-to-text and the hosted BIGGI Marketplace are not part of the current user-facing product. Do not document dormant implementation paths as available features without first shipping and enabling their complete user flow.

Recovery

Failure signalResponse
Missing SSE events for 15 secondsSSE adapter aborts attempt and reconnects
SSE reconnectStarts at 250 ms delay and backs off to 5 seconds until stream opens
Health pollEvery 10 seconds, checks /global/health with 3 second timeout; failure forces SSE reconnect
Server exitClears connection state, reports error, and lets later retry or connection attempt spawn replacement
Extension disposalStops polls, disposes SSE, and sends server process group termination with kill fallback

Builds

BuildSourceOutput
Extension hostsrc/extension.tsdist/extension.js
Sidebar and editor chat webviewwebview-ui/src/index.tsxdist/webview.js
Agent Manager webviewwebview-ui/agent-manager/index.tsxdist/agent-manager.js
Diff Viewer webviewwebview-ui/diff-viewer/index.tsxdist/diff-viewer.js
Diff Virtual webviewwebview-ui/diff-virtual/index.tsxdist/diff-virtual.js
Shared Shiki workersynthetic worker entrydist/shiki-worker.js

Extension host bundle targets Node/CommonJS. Browser webviews and shared worker use esbuild browser bundles. Run bun run typecheck, bun run lint, and targeted unit tests from packages/biggi-vscode/ after changing this area.

Source map

Paths below are relative to stemcat/biggi.

ConcernSource path
Activationpackages/biggi-vscode/src/extension.ts
Editor-owned server child processpackages/biggi-vscode/src/services/cli-backend/server-manager.ts
Shared SDK and SSE ownershippackages/biggi-vscode/src/services/cli-backend/connection-service.ts
SSE reconnect adapterpackages/biggi-vscode/src/services/cli-backend/sdk-sse-adapter.ts
Agent Managerpackages/biggi-vscode/src/agent-manager/
Build entriespackages/biggi-vscode/esbuild.js