A Rust-based AI coding agent with Terminal User Interface (TUI).
Status: Complete and working! Real conversations with Claude.
Phase 1 - TUI Foundation:
- ✅ Ratatui + Crossterm TUI skeleton
- ✅ Split-screen layout (chat history top, input bottom, status bar middle)
- ✅ Multi-line text input using tui-textarea
- ✅ Event-driven architecture with tokio async runtime
- ✅ 60 FPS rendering (16ms tick interval)
- ✅ Keyboard controls:
Enterto submit messageShift+Enterto insert new lineCtrl+Cto quit gracefully
Phase 2 - Claude API Integration:
- ✅ Real Claude API integration with streaming responses
- ✅ Token-by-token display - see Claude think in real-time
- ✅ Multi-turn conversations - maintains full chat history
- ✅ Automatic text wrapping - handles long messages gracefully
- ✅ Smart scrolling system:
- Keyboard scroll (↑/↓, PgUp/PgDn, Home/End)
- Mouse wheel support
- Auto-scroll to bottom with manual override
- Visual scroll indicator (percentage + offset)
- ✅ Clean message formatting with spacing between messages
- ✅ Loading indicators - clear "Generating..." status
- ✅ Error handling - network errors displayed clearly
- ✅ Configuration system - TOML-based API key management
UI/UX Enhancements:
- ✅ Modern Chat Design - Slack/Discord-inspired clean interface
- ✅ Unified Rounded Borders - All components use consistent rounded style
- ✅ High-Contrast Colors - Light color variants (LightCyan, LightGreen, LightBlue, LightRed) for 30-80% better visibility
- ✅ Emoji Role Icons - Instant visual identification (👤 User, 🤖 AI, ℹ️ System,
⚠️ Error) - ✅ Generous Spacing - 2x message gaps, wider padding for comfortable reading
- ✅ Two-Line Message Layout - Role header separated from content with indentation
- ✅ Improved Streaming Indicators - Shows
⋯while waiting,▌cursor while typing - ✅ Cohesive Container Styling - All borders, titles, and colors follow unified design language
OperationKernel/
├── Cargo.toml # Dependencies and build config
├── src/
│ ├── main.rs # Entry point, event loop
│ ├── agent.rs # UI-agnostic agent loop (LLM + tools + conversation)
│ ├── event.rs # Event types
│ ├── config/ # Configuration system
│ │ ├── mod.rs # Config loading/saving
│ │ └── station.rs # Station (LLM provider) definitions
│ ├── llm/ # LLM integration
│ │ ├── mod.rs # Module exports
│ │ ├── types.rs # Message, StreamChunk types
│ │ └── anthropic.rs # Claude API client with SSE streaming
│ ├── tool/ # Tool system (bash/read/write/grep/...)
│ ├── process/ # Background processes (bash_output/kill_shell)
│ └── tui/ # Terminal UI
│ ├── mod.rs # Module exports
│ ├── app.rs # App state and rendering
│ └── input.rs # Input widget wrapper
Total: ~750 lines of Rust code
第一次运行时,会自动生成配置文件:~/.config/ok/config.toml
快速配置 Claude API:
# 打开配置文件
vim ~/.config/ok/config.toml
# 或使用你喜欢的编辑器
code ~/.config/ok/config.toml
nano ~/.config/ok/config.toml配置示例:
default_station = "claude"
[[stations]]
id = "claude"
name = "Claude 3.5 Sonnet"
provider = "anthropic"
api_key = "sk-ant-api03-your-key-here" # 替换为你的 Claude API Key
model = "claude-3-5-sonnet-20241022"📖 详细配置说明: 查看 CONFIG.md
# Build the project
cargo build
# Run the application
cargo run部分集成测试是“真实联网测试”,通过 OperationKernel/tests/config.toml 配置(例如 web_fetch / web_search)。
cp OperationKernel/tests/config.example.toml OperationKernel/tests/config.toml然后按需把 web_fetch.enabled / web_search.enabled 设为 true,并填入真实的 web_search.brave_api_key。
- All tools treat the process
PWDas the project root (working_dir), and tool outputs will echo it back. - File tools (
read/write/edit/glob/grep/notebook_edit) only allow paths insideworking_dir(plus the system temp directory like/tmpon Linux/macOS) to prevent “searching random folders” by mistake. - Prefer
glob/grepwith relative paths (e.g../src/**) instead offind /....
Usage:
- Type your message (use
Shift+Enterfor multi-line) - Press
Enterto submit - Watch Claude respond in real-time (streaming)
- Press
Ctrl+Cto quit
- Clean Architecture: UI-agnostic agent core + TUI rendering
- Agent Runner:
src/agent.rsmanages streaming + tool loop - Async-First: Built on Tokio for future network operations
- Type-Safe: Zero unsafe code, leveraging Rust's type system
- Efficient Rendering: Only redraws on events, 60 FPS capable
- Error Handling: Proper error propagation with anyhow
ratatui 0.28- Terminal UI frameworkcrossterm 0.28- Cross-platform terminal manipulationtui-textarea 0.6- Multi-line text input widgettokio 1- Async runtimefutures 0.3- Async stream utilitiesanyhow 1- Error handling
Phase 3 will add:
- Permissions / policy layer for dangerous tools
- More agent capabilities (planning, memory, routing)
- Provider adapters (Gemini/Codex, etc.) will be done last
- Compiles with zero errors ✅
- Split screen layout ✅
- Multi-line text input ✅
- Ctrl+C quits gracefully ✅
- 60 FPS rendering capability ✅
Philosophy: "先做了,再慢慢修复问题" (Build first, iterate later)