koda-cli 0.1.2

A high-performance AI coding agent built in Rust
Documentation
# Koda ๐Ÿป

A high-performance AI coding agent built in Rust.

Single compiled binary. Multi-provider LLM support. Zero runtime dependencies.

## Philosophy

**Koda is a personal coding agent.** It's built for a single developer at a keyboard,
not for enterprise teams or platform integrations. This focus drives every design decision:

- **Single binary, zero runtime deps.** `cargo install koda-cli` and you're done.
  No Node.js, no Python, no Docker. Works offline with local models (LM Studio)
  or online with cloud providers.
- **Built-in tools for the core coding loop.** File ops, search, shell, web fetch,
  memory, and agents are compiled in โ€” always available, zero latency, zero config.
- **MCP for everything else.** Need GitHub API, databases, Slack? Connect external
  MCP servers via `.mcp.json`. Koda stays lean; the ecosystem handles the long tail.
- **Ask Koda what it can do.** Just ask โ€” "what can you do?" or "what tools do you
  have?" Koda's capabilities are embedded in its system prompt, so it can always
  describe its own tools, commands, and features accurately.

## Install

```bash
# From crates.io
cargo install koda-cli

# From source
git clone https://github.com/lijunzh/koda.git
cd koda && cargo build --release -p koda-cli
# Binary is at target/release/koda
```

On first run, an onboarding wizard guides you through provider and API key setup.

## Quick Start

```bash
koda                              # Interactive REPL (auto-detects LM Studio)
koda --provider anthropic         # Use a cloud provider
koda -p "fix the bug in auth.rs"  # Headless one-shot
echo "explain this" | koda        # Piped input
```

## Features

- **17 built-in tools** โ€” file ops, search, shell, web fetch, memory, agents, task tracking, AST analysis
- **MCP support** โ€” connect to any [MCP server]https://modelcontextprotocol.io via `.mcp.json` (same format as Claude Code / Cursor)
- **6 LLM providers** โ€” LM Studio, OpenAI, Anthropic, Gemini, Groq, Grok
- **5 embedded agents** โ€” default, code reviewer, security auditor, test writer, release engineer
- **Approval modes** โ€” plan (read-only) / normal (smart confirm) / yolo (auto-approve) via `/trust`
- **Diff preview** โ€” see exactly what changes before approving Edit, Write, Delete
- **Loop detection** โ€” catches repeated tool calls with configurable iteration caps
- **Parallel execution** โ€” concurrent tool calls and sub-agent orchestration
- **Smart context** โ€” auto-compact (configurable threshold), sliding window, prompt caching (Anthropic)
- **Extended thinking** โ€” structured thinking block display with configurable budgets
- **Image analysis** โ€” `@image.png` or drag-and-drop for multi-modal input
- **Git integration** โ€” `/diff` review, commit message generation
- **Headless mode** โ€” `koda -p "prompt"` with JSON output for CI/CD
- **Persistent memory** โ€” project (`MEMORY.md`) and global (`~/.config/koda/memory.md`)

### ๐ŸŒณ AST Code Analysis

Koda natively understands the structure of your codebase using embedded `tree-sitter` parsers.
- **Built-in languages:** Rust, Python, JavaScript, TypeScript โ€” instant function/class extraction and call graphs.
- **Extending with MCP:** Need Go, C++, or Java? Connect a community Tree-sitter MCP server via `.mcp.json`.

## REPL Commands

| Command | Description |
|---------|-------------|
| `/help` | Command palette (select & execute) |
| `/agent` | List available sub-agents |
| `/compact` | Summarize conversation to reclaim context |
| `/cost` | Show token usage for this session |
| `/diff` | Show/review uncommitted changes |
| `/mcp` | MCP servers: status, add, remove, restart |
| `/memory` | View/save project & global memory |
| `/model` | Pick a model (โ†‘โ†“ arrow keys) |
| `/provider` | Switch LLM provider |
| `/sessions` | List, resume, or delete sessions |
| `/trust` | Switch approval mode (plan/normal/yolo) |
| `/exit` | Quit Koda |

**Tips:** `@file` to attach context ยท Tab to autocomplete ยท `Shift+Tab` to cycle trust mode ยท `Alt+Enter` for multi-line

### Keyboard Shortcuts

| Key | Context | Action |
|-----|---------|--------|
| **Tab** | At prompt | Autocomplete (`/commands`, `@files`, `/model names`) |
| **Alt+Enter** | At prompt | Insert newline (multi-line input) |
| **Ctrl+C** | During inference | Cancel the current turn |
| **Ctrl+C ร—2** | During inference | Force quit Koda |
| **Ctrl+C** | At prompt (with text) | Clear the line |
| **Esc** | At prompt | Clear the line |
| **Shift+Tab** | At prompt | Cycle trust mode (plan โ†’ normal โ†’ yolo) |
| **Ctrl+D** | At prompt (empty) | Exit Koda |
| **โ†‘/โ†“** | At prompt | Browse command history |

## MCP (Model Context Protocol)

Koda connects to external [MCP servers](https://modelcontextprotocol.io) for additional tools.
Create a `.mcp.json` in your project root (same format as Claude Code / Cursor):

```json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "$GITHUB_TOKEN" }
    }
  }
}
```

Servers auto-connect on startup. MCP tools appear alongside built-in tools with
namespaced names (e.g. `github.create_issue`). Manage at runtime with `/mcp`.

User-level servers go in `~/.config/koda/mcp.json` (merged, project overrides).

## Architecture

Koda is a Cargo workspace with two crates:

```
koda/
โ”œโ”€โ”€ koda-core/    # Engine library (providers, tools, inference, DB) โ€” zero terminal deps
โ””โ”€โ”€ koda-cli/     # CLI binary (REPL, display, approval UI)
```

The engine communicates through `EngineEvent` (output) and `EngineCommand` (input) enums
over async channels. See [DESIGN.md](DESIGN.md) for architectural decisions.

## Documentation

- **[DESIGN.md]DESIGN.md** โ€” Design decisions and rationale
- **[CHANGELOG.md]CHANGELOG.md** โ€” Release history
- **[CLAUDE.md]CLAUDE.md** โ€” Developer guide for AI assistants
- **[GitHub Issues]https://github.com/lijunzh/koda/issues** โ€” Roadmap and release tracking

## Development

```bash
cargo test --workspace --features koda-core/test-support  # Run all 284 tests
cargo clippy --workspace      # Lint
cargo run -p koda-cli         # Run locally
```

## License

MIT