A Rust 2024 CLI agent for interacting with OpenAI-compatible LLM APIs.
Rigel is a conversational LLM agent that integrates filesystem tools into an interactive CLI session. It connects to OpenAI-compatible servers and provides deterministic filesystem operations within the current directory context. All tools work only within the current directory where Rigel started - absolute paths and parent references are rejected for security reasons.
Rigel reads a TOML configuration file from ~/.rigel/config.toml that declares the MCP servers whose tools are exposed to the agent:
[mcpServers.local]
type = "stdio"
command = "node"
args = ["server.js"]
[mcpServers.local.env]
RUST_LOG = "debug"
[mcpServers.remote]
type = "http"
url = "https://example.com/mcp"Each server entry declares its transport with the type key:
"stdio"— launch a local process:command(required),argsandenv(optional)"http"— connect to a remote endpoint:url(required)
If the file is missing, Rigel refuses to start and instructs you to run rigel init for basic initialization. If the file cannot be parsed, Rigel starts with no MCP servers.
# Clone the repository
git clone <repository-url>
cd rigel
# Build the project
cargo build
# Run help command
cargo run -- --help# Connect to an OpenAI-compatible API (base URL is required)
cargo run -- -b <api-base-url>
# Optionally provide API key for authenticated endpoints
cargo run -- -b <api-base-url> -k <api-key>
# Start Rigel with a local OpenAI-compatible server
cargo run -- -b http://localhost:8000/v1
# Run tests
cargo test --all-targets
# Format Rust code
cargo fmt --all -- --check
# Run clippy checks
cargo clippy --all-targets --all-features# Clone the repository
git clone <repository-url>
cd rigel
# Run help command
cargo run -- --help
# Start Rigel with a local OpenAI-compatible server
cargo run -- --base-url http://localhost:8000/v1
# Build the project
cargo build
# Run tests
cargo test --all-targets
# Format Rust code
cargo fmt --all -- --check
# Run clippy checks
cargo clippy --all-targets --all-featuresrigel/
├── src/
│ ├── cmd/ # CLI argument parsing and options
│ ├── controllers/ # Request orchestration layer
│ ├── entities/ # Domain entities
│ ├── prompts/ # System prompts for LLM interaction
│ ├── shared/ # Terminal IO and shared utilities
│ ├── tools/ # Agent callable filesystem tools
│ └── use_cases/ # Application workflows (chat, model selection)
├── Cargo.toml # Rust package metadata and dependencies
├── Cargo.lock # Resolved dependency versions
└── README.md # This file
The CLI entry point is defined in src/cmd/cli.rs. It provides:
- Base URL: Required OpenAI-compatible API base URL; Rigel calls
/modelsand/chat/completionsbelow it - API Key: Optional bearer authentication for API endpoints
cargo run -- -b <api-base-url> -k <api-key>Located in src/controllers/chat_controller.rs, the IndexController orchestrates agent operations:
- Establishes connection to an OpenAI-compatible server
- Selects available models deterministically
- Initializes chat with system prompt
- Manages conversation turns (default: 12)
- Routes filesystem tools to appropriate agents
Rigel provides a suite of filesystem operations, each with narrow responsibilities:
| Tool | Description |
|---|---|
create_file |
Create new files and missing parent directories |
read_file |
Read file content (returns SHA-256 revision) |
apply_patch |
UTF-8 text edits with revision checking |
create_directory |
Create directories recursively |
delete_path |
Delete a file or directory recursively |
find_paths |
Find files and directories by name |
list_directory |
Inspect directory contents |
rename_path |
Rename a file or directory without overwrite |
search_text |
Search exact, case-sensitive file text |
run_command |
Run build, test, format, or program commands |
fetch_url |
Fetch readable text from an HTTP or HTTPS URL |
Security Constraints: All tools work only within the current directory where Rigel started. Current directory-relative paths are validated; absolute paths and parent references (..) are rejected. The current directory is protected from delete/move operations.
- Chat: Interactive conversation with LLM models
- Model Selection: Deterministic model selection based on terminal output
- Use Rust 2024 edition
- Four-space indentation with trailing commas in multiline constructs
snake_casefor modules, functions, and variablesPascalCasefor structs and traitsSCREAMING_SNAKE_CASEfor constants
Return anyhow::Result at application boundaries. Use concrete error types where library-style APIs benefit from them. Errors should be intelligible and provide actionable next steps.
- Use Rust's built-in test framework
- Name tests after observable behavior
- Write tests for success, failure, and edge cases
- Unit tests must not perform I/O operations
Contributions are welcome! Please follow these guidelines:
- Keep commits focused and concise
- Use title-cased imperative subjects (e.g., "Refactor chat loop")
- Document behavior changes in pull requests
- Include verification commands for testing
- Link to relevant issues
This project is licensed under the MIT License. See the LICENSE file for details.