Architecture Overview
This document provides a high-level overview of Kilo Code's architecture to help contributors understand how the different components fit together.
System Architecture
Kilo Code is a VS Code extension built with TypeScript that connects to various AI providers to deliver intelligent coding assistance. The architecture follows a layered approach:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β VS Code Extension β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β ββββββββββββββββββββ ββββββββββββββββββββ β β β Extension Host β β Webview UI β β β β (src/) ββββββΆβ (webview-ui/) β β β ββββββββββ¬ββββββββββ ββββββββββββββββββββ β β β β β β Messages β β βΌ β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β Core Services β β β ββββββββββββββ¬βββββββββββββ¬βββββββββββββ¬ββββββββββββββββββββββββ€ β β β Tools β Browser β MCP β Code Index β β β β Service β Session β Servers β Service β β β ββββββββββββββ΄βββββββββββββ΄βββββββββββββ΄ββββββββββββββββββββββββ β β β β β β API Calls β β βΌ β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β API Provider Layer β β β ββββββββββββββ¬βββββββββββββ¬βββββββββββββ¬ββββββββββββββββββββββββ€ β β β Anthropic β OpenAI β Kilo β OpenRouter β β β β API β API β Provider β API β β β ββββββββββββββ΄βββββββββββββ΄βββββββββββββ΄ββββββββββββββββββββββββ β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Features
For detailed documentation on current and planned features, see the Architecture Features page.
Key Concepts
Modes
Modes are configurable presets that customize Kilo Code's behavior:
- Define which tools are available
- Set custom system prompts
- Configure file restrictions
- Examples: Code, Architect, Debug, Ask
Model Context Protocol (MCP)
MCP enables extending Kilo Code with external tools:
- Servers provide additional capabilities
- Standardized protocol for tool communication
- Configured via
mcp.json
Checkpoints
Git-based state management for safe exploration:
- Creates commits to track changes
- Enables rolling back to previous states
- Shadow repository for isolation
Code Indexing
Semantic search over the codebase:
- Embeddings-based search
- Vector database storage (LanceDB/Qdrant)
- Automatic chunking and indexing
Development Patterns
Message Passing
The extension uses VS Code's webview message API:
// Extension β Webview
panel.webview.postMessage({ type: "response", data: ... });
// Webview β Extension
vscode.postMessage({ type: "request", data: ... });
Service Architecture
Services are typically singletons with clear interfaces:
class CodeIndexService {
private static instance: CodeIndexService
static getInstance(): CodeIndexService {
if (!this.instance) {
this.instance = new CodeIndexService()
}
return this.instance
}
}
Tool Implementation
Tools follow a consistent pattern:
interface Tool {
name: string
description: string
parameters: z.ZodSchema
execute(params: unknown): Promise<ToolResult>
}
Build System
The project uses:
- pnpm - Package management (monorepo workspaces)
- esbuild - Fast bundling for extension
- Vite - Webview UI development
- TypeScript - Type checking across all packages
- Vitest - Test runner
Testing
- Unit tests -
*.spec.tsfiles alongside source - Integration tests - E2E tests in
e2e/directory - Run tests:
cd src && pnpm testorcd webview-ui && pnpm test
Further Reading
- Development Environment - Setup guide
- Tools Reference - Available tools