{"id":46618979,"url":"https://github.com/fortunto2/rust-code","last_synced_at":"2026-04-22T22:02:56.226Z","repository":{"id":342160828,"uuid":"1173063589","full_name":"fortunto2/rust-code","owner":"fortunto2","description":"AI-powered terminal coding agent in Rust — TUI, BAML agent loop, fuzzy search, tmux background tasks, skills, MCP support","archived":false,"fork":false,"pushed_at":"2026-04-22T17:25:08.000Z","size":5981,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-22T18:16:36.283Z","etag":null,"topics":["ai-agent","baml","cli","coding-assistant","gemini","mcp","ratatui","rust","terminal","tmux","tui"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fortunto2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-05T01:11:30.000Z","updated_at":"2026-04-22T17:25:10.000Z","dependencies_parsed_at":"2026-03-09T23:01:14.014Z","dependency_job_id":"1a22be4e-cb28-4766-979a-fea08c1cfa0f","html_url":"https://github.com/fortunto2/rust-code","commit_stats":null,"previous_names":["fortunto2/rust-code"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fortunto2/rust-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunto2%2Frust-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunto2%2Frust-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunto2%2Frust-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunto2%2Frust-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fortunto2","download_url":"https://codeload.github.com/fortunto2/rust-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunto2%2Frust-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32154782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T17:06:48.269Z","status":"ssl_error","status_checked_at":"2026-04-22T17:06:19.037Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","baml","cli","coding-assistant","gemini","mcp","ratatui","rust","terminal","tmux","tui"],"created_at":"2026-03-07T21:04:19.661Z","updated_at":"2026-04-22T22:02:56.219Z","avatar_url":"https://github.com/fortunto2.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-code\n\n[![Crates.io](https://img.shields.io/crates/v/rust-code)](https://crates.io/crates/rust-code)\n[![GitHub Release](https://img.shields.io/github/v/release/fortunto2/rust-code)](https://github.com/fortunto2/rust-code/releases)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n`rust-code` is a terminal coding agent written in Rust.\n\nIt combines a Ratatui-based TUI, typed tool execution, fuzzy navigation, session history, and an SGR-driven agent loop so you can work on a codebase without leaving the terminal.\n\n![Fuzzy File Search with preview](docs/assets/screenshot-file-search.png)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/screenshot-bg-tasks.png\" width=\"32%\" alt=\"BG Tasks — realtime tmux preview\"\u003e\n  \u003cimg src=\"docs/assets/screenshot-symbols.png\" width=\"32%\" alt=\"Project Symbols\"\u003e\n  \u003cimg src=\"docs/assets/screenshot-skills.png\" width=\"32%\" alt=\"Skills Browser\"\u003e\n\u003c/p\u003e\n\n## Install\n\nHomebrew (macOS, auto-installs tmux):\n\n```bash\nbrew install fortunto2/tap/rust-code\n```\n\nOne-liner (downloads binary + installs dependencies via `doctor`):\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/fortunto2/rust-code/master/install.sh | bash\n```\n\nFrom crates.io:\n\n```bash\ncargo install rust-code\nrust-code doctor --fix   # installs tmux, ripgrep, etc.\n```\n\nRun it:\n\n```bash\nrust-code                                          # interactive TUI\nrust-code -p \"Find the bug in src/main.rs\"         # headless mode\nrust-code --resume                                 # continue last session\nrust-code --resume \"refactor\"                      # fuzzy-search sessions by topic\nrust-code -p \"build feature X\" --loop 5            # autonomous loop (BigHead mode)\nrust-code -p \"improve yourself\" --evolve           # self-evolution mode\n```\n\n## Features\n\n- **Interactive TUI** — chat UI built with `ratatui` and `crossterm`\n- **SGR agent loop** — typed tool execution with fallback chain (Gemini Pro → Flash → Flash Lite)\n- **22 built-in tools** — file read/write/edit/patch, bash (fg + bg), search, git, memory, tasks, agent swarm, MCP, OpenAPI\n- **Agent swarm** — spawn child agents with roles, wait/cancel, parallel task execution\n- **Task management** — persistent kanban board via `.tasks/*.md`\n- **Fuzzy file search** (`Ctrl+P`) — fast file navigation with `nucleo` and live file preview\n- **Project symbol search** (`F6`) — browse functions, structs, enums with code preview\n- **Background tasks** (`F7`) — run long commands in `tmux` windows with realtime output preview\n- **Skills system** (`F9`) — browse, search, and install agent skills from [skills.sh](https://skills.sh) registry\n- **MCP support** — connect external tool servers via `.mcp.json` (e.g. Playwright, codegraph, Supabase)\n- **OpenAPI → Tool** — any API as one tool: load spec → fuzzy search endpoints → call. 10 popular APIs pre-configured (GitHub, Cloudflare, Stripe, OpenAI, etc.) + APIs.guru directory (2800+ APIs). TOML registry at `~/.sgr-agent/apis.toml`\n- **Git integration** — diff sidebar, history viewer, stage and commit from the agent\n- **Session persistence** — chat history in `.rust-code/session_*.jsonl`, resume with `--resume`\n- **Open-in-editor** — jump to file:line in `$EDITOR` from any panel\n- **BigHead mode** (`--loop N`) — autonomous task loop with circuit breaker, control file, and `\u003csolo:done/\u003e` signal\n- **Self-evolution** (`--evolve`) — agent evaluates its own runs, patches code, rebuilds, and restarts\n\n### Background Tasks (tmux)\n\nThe agent can run long-lived commands (dev servers, watchers, builds) in named `tmux` windows via `BashBgTool`. Press `F7` to see all running tasks with realtime log output. `Ctrl+O` to attach, `Ctrl+K` to kill.\n\nRequires `tmux` installed (`brew install tmux`).\n\n### Skills\n\nSkills are reusable agent instructions (markdown files) that teach the agent domain-specific workflows. Browse the [skills.sh](https://skills.sh) registry with `F9`, or from CLI:\n\n```bash\nrust-code skills search \"deploy\"\nrust-code skills add tavily-ai/skills/web-search\n```\n\nInstalled skills are injected into the agent context automatically.\n\n### MCP (Model Context Protocol)\n\nConnect external tool servers by adding `.mcp.json` in your project or home directory:\n\n```json\n{\n  \"mcpServers\": {\n    \"playwright\": {\n      \"command\": \"npx\",\n      \"args\": [\"@playwright/mcp@latest\"]\n    }\n  }\n}\n```\n\nThe agent discovers MCP tools at startup and can call them via `McpToolCall`.\n\n## Setup \u0026 Providers\n\nOn first launch, `rust-code` runs an interactive `setup` wizard to configure your preferred LLM backends and verifies authentication using `rust-code doctor`.\n\nYou can also run these manually:\n\n```bash\nrust-code setup\nrust-code doctor\n```\n\nSupported providers include:\n\n- **Google AI** via `GEMINI_API_KEY`\n- **Vertex AI** via `VERTEX_PROJECT` (uses Google Cloud ADC or service account)\n- **Anthropic** via `ANTHROPIC_API_KEY`\n- **OpenRouter** via `OPENROUTER_API_KEY`\n- **Ollama** (local via `OLLAMA_HOST`)\n\nAt least one provider must be configured before launching `rust-code`.\n\nExamples:\n\n```bash\nexport GEMINI_API_KEY=\"...\"\nrust-code\n```\n\n```bash\nexport GOOGLE_CLOUD_PROJECT=\"my-project\"\nrust-code\n```\n\n```bash\nexport OPENROUTER_API_KEY=\"...\"\nrust-code\n```\n\nNotes:\n\n- Default: Gemini 3.1 Pro Preview with fallback to Flash and Flash Lite.\n- Provider configuration: `~/.rust-code/config.toml` or `rust-code setup` or `rust-code config set`.\n- Vertex AI uses `global` region by default (not `us-central1`).\n\n## Quick Start\n\n1. `cd` into the repository you want to work on.\n2. Create an `AGENTS.md` file in that repo.\n3. Export one provider credential.\n4. Launch `rust-code`.\n5. Start with a direct task like `review this repo`, `fix the failing test`, or `add a new command`.\n\n## AGENTS.md\n\n`rust-code` works best when the target repository contains an `AGENTS.md` file with project-specific instructions.\n\nRecommended contents:\n\n- stack and framework versions\n- architecture constraints\n- code style rules\n- test/build commands\n- migration or release rules\n- prompt or tool-schema rules\n- file locations that must be edited first\n\nExample:\n\n```md\n# Agent Instructions\n\n## Stack\n- Rust 2024\n- Tokio\n- Ratatui\n\n## Rules\n- Prefer minimal patches\n- Run `cargo check` after code changes\n- Do not edit generated files directly\n- Run `make check` before committing\n\n## Commands\n- Build: `cargo build`\n- Check: `cargo check`\n- Test: `cargo test`\n```\n\nThe more concrete this file is, the better the agent performs.\n\n## Sessions and Local State\n\n`rust-code` stores local state in `.rust-code/`:\n\n- `.rust-code/context/` for persistent agent guidance files\n- `.rust-code/session_*.jsonl` for chat/session history\n\nUse `--resume` to reopen the latest saved session:\n\n```bash\nrust-code --resume\n```\n\n## TUI Shortcuts\n\nMain shortcuts currently exposed by the UI:\n\n- `Enter`: send message\n- `Ctrl+P`: file search\n- `Ctrl+H`: session history\n- `Ctrl+G`: refresh git sidebar\n- `Tab`: focus sidebar\n- `Ctrl+C`: quit\n- `F1`: diff channel\n- `F2`: git history\n- `F3`: files\n- `F4`: sessions\n- `F5`: refresh\n- `F6`: symbols\n- `F7`: background tasks\n- `F10`: channels\n- `F12`: quit\n\nInside side panels:\n\n- `Esc`: close panel\n- `Ctrl+I`: insert selected item into the prompt\n- `Ctrl+O`: open or attach, where supported\n\nBackground tasks are backed by `tmux`, so having `tmux` installed is useful if you want long-running task inspection from the UI.\n\n## CLI\n\n```text\nUsage: rust-code [COMMAND] [OPTIONS]\n\nCommands:\n  setup       Interactive provider setup wizard\n  doctor      Check system deps and API auth (--fix to auto-install)\n  skills      Manage agent skills (add, remove, search, list, catalog)\n  sessions    List or search past chat sessions\n  mcp         Show MCP server status and tools\n  config      Set default provider (show, set, reset)\n  task        Manage project tasks (list, show, create, done, update)\n\nOptions:\n  -p, --prompt \u003cPROMPT\u003e    Run in headless mode with a prompt\n  -r, --resume [TOPIC]     Resume last session or fuzzy-search by topic\n  -s, --session \u003cPATH\u003e     Resume specific session file\n      --cwd \u003cPATH\u003e         Working directory for headless mode\n      --model \u003cNAME\u003e       Override model name\n      --intent \u003cMODE\u003e      Intent mode: auto, ask, build, plan\n      --local              Use local Ollama model\n      --codex              Use ChatGPT Plus/Pro via Codex proxy\n      --gemini-cli         Use Gemini CLI as LLM backend\n      --loop \u003cN\u003e           Autonomous loop (BigHead mode)\n      --max-hours \u003cFLOAT\u003e  Time limit for loop/evolve mode\n      --evolve             Self-evolution mode\n  -h, --help               Print help\n  -V, --version            Print version\n```\n\n### OpenAPI → Tool\n\nConvert any REST API into a searchable, callable tool — no code generation needed.\n\n```bash\n# The agent can search and call APIs on the fly:\n# \"search github repos\" → finds GET /search/repositories → calls it\n```\n\n- 10 popular APIs pre-configured: GitHub (1093 endpoints), Cloudflare (2656), Stripe, OpenAI, Supabase, PostHog, Slack, Linear, Vercel, Sentry\n- APIs.guru fallback: 2800+ APIs searchable by name\n- Auto-cache specs to `~/.sgr-agent/openapi-cache/`\n- TOML registry at `~/.sgr-agent/apis.toml` for custom APIs\n- Auto-detect auth from env vars (`GITHUB_TOKEN`, `STRIPE_SECRET_KEY`, etc.)\n- Full `$ref` resolution, path-level parameter inheritance, YAML support\n\n### BigHead Mode (Autonomous Loop)\n\nRun the agent in a loop for autonomous task execution:\n\n```bash\nrust-code -p \"build a CLI tool for air quality\" --loop 10 --max-hours 2\n```\n\n- Circuit breaker: stops after 3 consecutive identical failures\n- Control file: `.rust-code/loop-control` (write `stop`, `pause`, `skip`)\n- Signal: agent outputs `\u003csolo:done/\u003e` when task is complete\n- Skills: `--loop` auto-loads `skills/bighead/SKILL.md`\n\n### Self-Evolution\n\nThe agent can evaluate and improve itself:\n\n```bash\nrust-code -p \"improve your error handling\" --evolve\n```\n\n- Evaluates each run: error rate, loop warnings, patch failures, steps\n- Analyzes session history for recurring patterns\n- Proposes and applies improvements to its own code\n- Rebuilds and restarts via `RESTART_AGENT` signal\n- Evolution log: `.rust-code/evolution.jsonl`\n\n## Development\n\nThe workspace consists of 5 crates:\n\n| Crate | What |\n|-------|------|\n| `rc-cli` | Main binary — TUI, headless mode, 22 tools, agent loop |\n| `sgr-agent` | LLM client + agent framework + session/memory/tools/providers/OpenAPI |\n| `sgr-agent-tui` | Shared TUI shell — chat panel, fuzzy picker, focus system |\n| `solograph` | MCP server for code intelligence |\n| `genai` | Local fork of rust-genai — multi-provider LLM client |\n\n```bash\nmake build    # dev build\nmake test     # run all tests (450+ in sgr-agent alone)\nmake lint     # clippy on sgr-agent + sgr-agent-tui + solograph (-D warnings)\nmake check    # test + clippy + fmt (pre-commit gate)\nmake install  # build + strip + install to /usr/local/bin\nmake audit    # unused deps + large files audit\nmake help     # show all targets\n```\n\n## Built With\n\n| What | Crate / Link |\n|------|-------------|\n| Agent architecture | [Schema-Guided Reasoning (SGR)](https://abdullin.com/schema-guided-reasoning/) — typed tool dispatch via union types |\n| LLM client | [rust-genai](https://github.com/jeremychone/rust-genai) (local fork) — multi-provider Rust client (Gemini, OpenAI, Anthropic, Ollama, etc.) |\n| TUI framework | [Ratatui](https://github.com/ratatui/ratatui) + [Crossterm](https://github.com/crossterm-rs/crossterm) |\n| Text input | [tui-textarea](https://github.com/rhysd/tui-textarea) |\n| Fuzzy search | [Nucleo](https://github.com/helix-editor/nucleo) (from Helix editor) |\n| Async runtime | [Tokio](https://tokio.rs) |\n| MCP client | [rmcp](https://github.com/modelcontextprotocol/rust-sdk) — Rust SDK for Model Context Protocol |\n| CLI | [Clap](https://github.com/clap-rs/clap) |\n| File traversal | [ignore](https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore) (from ripgrep, respects `.gitignore`) |\n| Skills registry | [skills.sh](https://skills.sh) |\n| Background tasks | [tmux](https://github.com/tmux/tmux) |\n\n## Status\n\nThe crate is published on crates.io:\n\n- https://crates.io/crates/rust-code\n\nRelease artifacts (Linux x86_64 + macOS aarch64) are published on GitHub when you push a tag matching `v*`.\n\n## Comparison with Other Terminal Agents\n\n| | rust-code | Claude Code | [claw-code](https://github.com/instructkr/claw-code) | Codex CLI | Aider |\n|---|---|---|---|---|---|\n| **Language** | Rust | TypeScript | Rust | TypeScript | Python |\n| **LLM providers** | Gemini, OpenAI, Anthropic, Vertex, Ollama, OpenRouter | Anthropic only | Anthropic (+ OpenAI via [openai-oxide](https://crates.io/crates/openai-oxide)) | OpenAI only | Multi-provider |\n| **Agent variants** | 6 (structured, tool-calling, flexible, hybrid, planning, clarification) | 1 | 1 | 1 | 1 |\n| **Loop detection** | 4-tier (exact, semantic, output stagnation, frequency churn) | Unknown | None | None | None |\n| **Context compaction** | LLM-based + incremental | LLM-based | Heuristic (no LLM) | Sliding window | Repo map |\n| **Memory** | JSONL typed entries + GC + token budget | File-based | None | None | Repo map |\n| **Tools** | 27+ with fuzzy matching | 20+ | 19 | ~10 | Edit/shell |\n| **MCP support** | Yes (rmcp) | Yes | Yes (stdio) | Yes | No |\n| **OpenAPI → Tool** | 11 pre-configured APIs + APIs.guru (2800+) | No | No | No | No |\n| **Background tasks** | Yes (tmux) | No | No | No | No |\n| **Agent swarm** | Yes (multi-agent) | Yes (Agent tool) | Agent tool (stub) | No | No |\n| **Self-evolution** | Yes (`--evolve`) | No | No | No | No |\n| **Autonomous loop** | Yes (`--loop N`) | No | No | Yes | No |\n| **TUI** | Full (ratatui) | Inline terminal | Inline REPL | Inline terminal | Inline terminal |\n| **Session resume** | Yes (fuzzy search) | Yes | Yes | No | Yes |\n| **Config layering** | Global → project → local → env → CLI | 5-level JSON merge | 2-level | Env only | YAML |\n| **License** | MIT | Proprietary | MIT | Apache-2.0 | Apache-2.0 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortunto2%2Frust-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortunto2%2Frust-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortunto2%2Frust-code/lists"}