Architecture
How Cortex Works
Cortex is a VS Code extension that integrates OpenCode as the agentic runtime (local server). Cortex adds the IDE layer β chat panel, local codebase context, Policy Brain, and Cursor/Windsurf-like workflows β inside your own editor. Models come from your OpenCode subscription.
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β VS Code UI β ββ β Cortex Ext. β ββ β OpenCode β
β (Sidebar + β β (TypeScript) β β (Server) β
β Inline) β β β β β
ββββββββββββββββ ββββββββββββββββ ββββββββ¬ββββββββ
β
βββββββββΌββββββββ
β OpenCode β
β models β
β (your sub) β
βββββββββββββββββ Components
- SidebarProvider β manages the chat panel lifecycle, message routing, Partsβrows timeline, and plan/build modes
- OpenCode Client β HTTP client for the local OpenCode server, with tool-hang watchdog and SSE status
- Theme engine β applies OpenCode Desktop themes in chat (GitHub catalog cache, custom ~/.config/opencode/themes, follow tui.json)
- Policy Brain β multi-tier rules/skills/memory/hooks injection (T0βT3) with Cursor + Cortex dual loaders
- Context Service β gathers relevant code context via lexical + embedding search (hash or MiniLM); incremental file updates keep the index coherent
- Inline Completion β provides ghost-text suggestions in the editor
- Plan Store β manages saved plans with checklists for the PlanβBuild workflow
Plan β Build Workflow
- Plan mode: Cortex analyzes your request and creates a structured plan with checklist
- Approval: You review and approve the plan
- Build mode: Cortex implements changes step by step, updating the checklist