Sufini VS Code Adapter
VS Code AI client adapter for Sufini. Connects to the shared Runtime, registers as an IDE adapter, and performs Link AI session operations plus retrieval context injection.
Architecture
Browser → Repository → Runtime
↙ ↘
Cursor VS Code
The VS Code adapter is a thin AI client. Retrieval logic lives in Runtime — this extension only calls:
POST /kernel/sessions — Create / Link
GET /kernel/link-ai/active-session — Active session
POST /kernel/retrieve — Knowledge retrieval
DELETE /kernel/sessions/:id — Unlink
Retrieval hooks
The adapter uses only documented VS Code Copilot Agent Hook capabilities:
UserPromptSubmit creates the session's current request before calling Runtime retrieval,
then stages a short-lived pending context only if that request is still current. Its output is
always { "continue": true }.
PreToolUse injects a matching pending context once through its documented
additionalContext output and applies retrieval policy decisions.
SessionStart supplies compact, stable Sufini bootstrap guidance only.
PostToolUse records policy/audit information; Stop clears session-scoped pending state.
There is no documented hook that both receives every submitted prompt and injects query-specific
context into that same prompt before Copilot starts reasoning. As a result, query-specific context
is available before the first tool action, but is not guaranteed for direct no-tool responses.
Hooks are a VS Code Preview capability; when a hook or its documented context output is unavailable,
the adapter fails open and leaves normal Copilot behavior unchanged.
Pending context is claimed before PreToolUse constructs its response and consumed immediately
after that documented response is constructed. VS Code does not expose a later acknowledgement that
Copilot accepted or used additionalContext.
Run the focused hook-contract tests with:
npm run test:retrieval-hooks
Setup
cd extensions/vscode-project-brain
npm install
npm run compile
Install in VS Code: Extensions → Install from VSIX or run npm run install:vscode.
Commands
- Sufini: Link AI — Create a Kernel session for the current workspace
- Sufini: Unlink AI — Delete the active Kernel session
- Sufini: Sync Retrieval Context — Refresh workspace retrieval config
- Sufini: Test Retrieval — Run retrieval against the active session
- Sufini: Retrieval Diagnostics — Show the last retrieval trace
Configuration
projectBrain.vscode.bridge.port (default 17341) — Runtime WebSocket port; HTTP status port is port + 1
projectBrain.vscode.bridge.autoStart (default true) — Connect on launch
projectBrain.vscode.retrieval.confidenceThreshold (default 0.2)