Kilo Code is an open source AI coding agent for VS Code that generates code from natural language, automates tasks, and supports 500+ AI models.
This is a pnpm monorepo using Turbo for task orchestration:
src/ - VSCode extension (core logic, API providers, tools)webview-ui/ - React frontend (chat UI, settings)cli/ - Standalone CLI packagepackages/ - Shared packages (types, ipc, telemetry, cloud)jetbrains/ - JetBrains plugin (Kotlin + Node.js host)apps/ - E2E tests, Storybook, docsKey source directories:
src/api/providers/ - AI provider implementations (50+ providers)src/core/tools/ - Tool implementations (ReadFile, ApplyDiff, ExecuteCommand, etc.)src/services/ - Services (MCP, browser, checkpoints, code-index)packages/agent-runtime/ - Standalone agent runtime (runs extension without VS Code)The @kilocode/agent-runtime package enables running Kilo Code agents as isolated Node.js processes without VS Code.
┌─────────────────────┐ fork() ┌─────────────────────┐
│ CLI / Manager │ ───────────────▶│ Agent Process │
│ │◀───── IPC ─────▶│ (extension host) │
└─────────────────────┘ └─────────────────────┘
Agents are forked processes configured via the AGENT_CONFIG environment variable:
import { fork } from "child_process"
const agent = fork(require.resolve("@kilocode/agent-runtime/process"), [], {
env: {
AGENT_CONFIG: JSON.stringify({
workspace: "/path/to/project",
providerSettings: { apiProvider: "anthropic", apiKey: "..." },
mode: "code",
autoApprove: false,
}),
},
stdio: ["pipe", "pipe", "pipe", "ipc"],
})
agent.on("message", (msg) => {
if (msg.type === "ready") {
agent.send({ type: "sendMessage", payload: { type: "newTask", text: "Fix the bug" } })
}
})
| Direction | Type | Description |
|---|---|---|
| Parent → Agent | sendMessage |
Send user message to extension |
| Parent → Agent | injectConfig |
Update extension configuration |
| Parent → Agent | shutdown |
Gracefully terminate agent |
| Agent → Parent | ready |
Agent initialized |
| Agent → Parent | message |
Extension message |
| Agent → Parent | stateChange |
State updated |
Code running in agent processes can check for the AGENT_CONFIG environment variable. This is set by the agent manager when spawning processes:
if (process.env.AGENT_CONFIG) {
// Running as spawned agent - disable worker pools, etc.
}
The Agent Manager follows a read-shared, write-isolated pattern:
provider.getState()Write: Inject state via AGENT_CONFIG env var when spawning - each agent gets isolated config
fork(agentRuntimePath, [], {
env: { AGENT_CONFIG: JSON.stringify({ workspace, providerSettings, mode, sessionId }) }
})
This ensures parallel agents have independent state with no race conditions or file I/O conflicts.
pnpm install # Install all dependencies
pnpm build # Build extension (.vsix)
pnpm lint # Run ESLint
pnpm check-types # TypeScript type checking
.kilocode/skills/translation/SKILL.md - Translation and localization guidelines.kilocode/workflows/add-missing-translations.md - Run /add-missing-translations to find and fix missing translationsEach PR requires a changeset unless it's documentation-only or internal tooling. Create one with:
pnpm changeset
Format (in .changeset/<random-name>.md):
---
"kilo-code": patch
---
Brief description of the change
patch for fixes, minor for features, major for breaking changes"@kilocode/cli": patch insteadKeep changesets concise and feature-oriented as they appear directly in release notes.
Kilo Code is a fork of Roo Code. We periodically merge upstream changes using scripts in scripts/kilocode/.
To minimize merge conflicts when syncing with upstream, mark Kilo Code-specific changes in shared code with kilocode_change comments.
Single line:
const value = 42 // kilocode_change
Multi-line:
// kilocode_change start
const foo = 1
const bar = 2
// kilocode_change end
New files:
// kilocode_change - new file
Code in these directories is Kilo Code-specific and doesn't need markers:
cli/ - CLI packagejetbrains/ - JetBrains pluginagent-manager/ directorieskilocode in filename or directory namesrc/services/ghost/ - Ghost serviceAll modifications to core extension code (files that exist in upstream Roo Code) require markers:
src/ (except Kilo-specific subdirectories listed above)webview-ui/packages/ (shared packages)Keep changes to core extension code minimal to reduce merge conflicts during upstream syncs.
Test Coverage:
vi, describe, test, it, etc functions are defined by default in tsconfig.json and therefore don't need to be imported from vitestpackage.json file that specifies vitest in devDependenciespnpm test <relative-path-from-workspace-root>cd src && pnpm test path/to/test-file (don't include src/ in path)cd webview-ui && pnpm test src/path/to/test-filesrc/tests/user.spec.ts, run cd src && pnpm test tests/user.spec.ts NOT pnpm test src/tests/user.spec.ts.spec.ts / .spec.tsx.test.ts / .test.tsx (match existing CLI convention)Lint Rules:
Error Handling:
Styling Guidelines:
<div className="text-md text-vscode-descriptionForeground mb-2" /> instead of style objects