中文 | English
letcode is a terminal Agent written in Rust. It provides an opencode-style TUI based on Ratatui by default, while keeping a REPL CLI mode available.
cargo build
cargo test
cargo fmt --checkRun the default TUI:
cargo runRun the line-based CLI:
cargo run -- --cliCLI mode can also be selected with cli or repl. TUI can be selected explicitly with --tui or tui.
letcode loads configuration from:
~/.config/letcode/letcode.toml
Minimal example:
active_provider = "openai"
[global]
max_iterations = 64
max_tool_calls = 128
sessions_dir = "sessions"
log_file = "logs/combined.log"
[permissions]
mode = "default"
[providers.openai]
api_key = "YOUR_API_KEY"
base_url = "https://api.openai.com/v1"
protocol = "responses" # responses/completions
default_model = "gpt-5.5"
[providers.openai.models."gpt-5.5"]
display_name = "GPT-5.5"
supports_tools = true
supports_reasoning = true
reasoning_effort = "medium"
reasoning_summary = "auto"
text_verbosity = "medium"Provider API keys and base URLs can also come from environment variables. The variable names are generated from the provider name:
export OPENAI_API_KEY="..."
export OPENAI_BASE_URL="https://api.openai.com/v1"If the provider is named compat, the corresponding variables are COMPAT_API_KEY and COMPAT_BASE_URL.
Relative sessions_dir and log_file paths are resolved relative to the config file directory.
src/main.rs entry point, config loading, TUI/CLI selection
src/config.rs TOML config parsing and validation
src/agent.rs model loop, tool execution, turn lifecycle
src/tool.rs built-in tool registry and tool result model
src/permission.rs permission modes, scopes, and request classification
src/transcript.rs JSONL transcript persistence and restore helpers
src/subagent.rs subagent-related code
src/mcp.rs MCP tool discovery
src/tui/ Ratatui/Crossterm UI, runtime, state, events, rendering
This project is dual-licensed under the MIT License OR the Apache License 2.0. You may choose either license when using, modifying, or redistributing this project.
- MIT License: see LICENSE-MIT
- Apache License 2.0: see LICENSE-APACHE