How roovetgit/roo-code works
Project type and purpose
• Roo Code is an open-source VS Code extension paired with a React-based webview UI.
• It acts as an “autonomous coding agent,” orchestrating workspace file I/O, terminal commands, browser automation, and AI‐powered code assistance via pluggable model providers (OpenAI, Anthropic, Bedrock, etc.).
• The repo also contains an “evals” monorepo (CLI + Next.js web app) for benchmarking tasks, plus end-to-end and unit tests.
File structure
• Top‐level “src/” holds the extension’s TypeScript code (activate, api, core, services, integrations, tools).
• “webview-ui/” is a standalone Vite/React app delivering the in-editor chat interface.
• “evals/” is a separate workspace for CLI and Web evaluation apps.
• “e2e/” contains integration tests that spin up VS Code and drive the extension+webview.
• Configuration manifests include tsconfig.json, package.json, .github/workflows, changesets, pnpm/turbo configs.
README for additional insights
• Describes key features (modes, tools, MCP).
• Mentions extension host vs webview separation and external API/provider integrations.
Main components
a. VS Code Host & Extension Host Process
• “extension.ts” loads on activation.
• Core controllers (activate/handleTask, registerCommands, webviewMessageHandler).
• Service modules: file I/O, terminal (Execa), browser automation, tree-sitter, MCP server manager, telemetry (PostHog).
• API providers layer: fetchers + provider adapters for OpenAI, Anthropic, etc.
• Task persistence & checkpoint services.
b. Webview UI (React + Vite)
• Host: webview tab inside VS Code.
• UI components (chat view, settings, history).
• Context providers (React-Query, theme, translation).
• Messaging bridge (vs code postMessage ↔ extension).
c. External Dependencies
• AI provider endpoints (OpenAI, Anthropic, Vertex, custom OpenRouter).
• Optional MCP servers/agents (Model Context Protocol).
• Telemetry backend (PostHog).
d. Test Harnesses
• E2E: launches VS Code with extension + webview, drives commands via Webdriver.
• Unit tests: Jest/Vitest for core modules, providers, integrations.
Component interactions & data flow
• User interacts with the Chat UI → React dispatches a “sendPrompt” message → VS Code webviewMessageHandler receives it.
• Extension’s core logic assembles a tool-enabled prompt, picks a provider adapter → calls external AI API over HTTPS → receives streamed response.
• Response is transformed by the api/transform layer → sent back to Webview via postMessage → rendered in the chat UI.
• If file read/write or terminal commands are needed, core modules (services/fs, services/terminal, core/tools) execute them in the workspace.
• TelemetryService logs events to PostHog.
• CheckpointService persists intermediate states on disk.
• Custom Modes & MCP server modules allow plugging in additional capabilities via IPC or HTTP.
Architectural patterns & principles
• Layered & modular: Presentation (webview UI) ↔ Application core (extension host) ↔ Infrastructure (services, external APIs).
• Plugin architecture for AI providers (api/providers/) and tools (core/tools/).
• Event‐driven messaging between UI and extension host.
• Monorepo structure (pnpm workspaces + Turbo) for isolation of “evals” subproject and shared packages.