open-code is a lightweight, CLI-based Coding Agent that acts as an assistant for your Rust projects. It reads all .rs files in your current working directory, constructs a global context of your codebase, and sends it alongside your prompt to Google Gemini AI models to generate highly relevant, context-aware coding solutions.
- Codebase Context-Aware: Automatically scans your directory recursively for
.rsfiles and attaches them to your queries. - Provider Management: Connect and switch between different AI providers easily.
- Model Selection: Switch between various supported models on the fly.
- Secure Configuration: Stores credentials and settings locally in your system's default configuration directory (e.g.,
~/.config/open-code/config.json).
- Prerequisites: Ensure you have Rust and Cargo installed.
- Build the project:
cargo build --release
- Run the binary:
The compiled binary will be located in
target/release/open-code. You can move it to your path or run it directly:./target/release/open-code --help
Before using the agent, you need to register and select an AI provider (e.g., Google Gemini).
Fetches and lists all compatible providers from the central registry.
open-code providers listSave your API key for a selected provider.
open-code providers login --provider <PROVIDER_NAME> --api_key <YOUR_API_KEY>Example:
open-code providers login --provider gemini --api_key AIzaSyD...Choose which logged-in provider to use for queries.
open-code providers set --provider <PROVIDER_NAME>Remove saved credentials for a provider.
open-code providers logout --provider <PROVIDER_NAME>Once an active provider is set, you can configure which model should process your prompts.
Lists all models available under your currently active provider.
open-code modelsSet your active model.
open-code models set --model <MODEL_NAME>Example:
open-code models set --model gemini-1.5-flashRun the agent within any Rust project directory. The agent recursively collects all .rs files, combines them with your custom prompt, and contacts the active AI model.
open-code agent -p "<your prompt/question here>"Example:
open-code agent -p "Refactor the load_config function to use better error handling"All credentials and configurations are stored locally on your machine at:
- Linux/macOS:
~/.config/open-code/config.json - Windows:
%APPDATA%\open-code\config.json