A powerful AI-powered command-line interface agent that integrates with OpenRouter API to perform automated software development tasks. Built with Rust for performance and reliability.
- π€ AI-Powered: Leverages OpenRouter API to access various AI models
- π File Operations: Read, write, edit, and delete files and directories
- π» Terminal Integration: Execute shell commands and manage processes
- π― Multi-Step Tasks: Execute complex development workflows
- π Interactive Mode: Chat with the AI for iterative development
- β‘ Fast & Efficient: Built with Rust for optimal performance
- π§ Configurable: Customizable settings and model selection
- Rust (latest stable version)
- OpenRouter API key
- Git
- Clone the repository:
git clone https://github.com/your-username/ai-cli-agent.git
cd ai-cli-agent- Set up your OpenRouter API key:
export OPENROUTER_API_KEY="your_api_key_here"- Build the project:
cargo build --release- Run the test script to verify everything works:
chmod +x test_ai_agent.sh
./test_ai_agent.shcargo run -- execute "write a hello world program in python"# Read a file
cargo run -- read path/to/file.txt
# Write a file
cargo run -- write path/to/file.txt "Hello, World!"
# Edit a file
cargo run -- edit path/to/file.txt "change hello to hi"
# Delete a file
cargo run -- delete path/to/file.txt
# List directory
cargo run -- list path/to/directory# Run a command
cargo run -- run "ls -la"cargo run -- interactivecargo run -- execute --model "anthropic/claude-2" "write a rust program"cargo run -- execute --work-dir "/path/to/project" "analyze this codebase"cargo run -- execute --prompt "You are an expert Rust developer" "write a web server"The AI CLI Agent uses a configuration file located at ~/.config/ai-cli-agent/config.toml. You can customize various settings:
openrouter_api_key = "your_api_key_here"
model = "openai/gpt-4"
work_dir = "/path/to/your/project"
max_tokens = 4000
temperature = 0.7
timeout_seconds = 120
auto_save = true
backup_enabled = true
backup_dir = ".ai_cli_backups"The agent supports various models through OpenRouter:
openai/gpt-4openai/gpt-4-turboopenai/gpt-3.5-turboanthropic/claude-2anthropic/claude-instant-1google/palm-2-chat-bisongoogle/palm-2-codechat-bisonmeta-llama/llama-2-70b-chatmeta-llama/llama-2-13b-chatmistralai/mistral-7b-instructmistralai/mixtral-8x7b-instruct
cargo run -- execute "write a complete HTML snake game with CSS and JavaScript"cargo run -- edit snake.html "change the background to a gradient from blue to purple"cargo run -- execute "create a new Rust project with a simple web server using tokio"cargo run -- execute "analyze this codebase and suggest improvements"The AI agent understands structured responses in the following format:
WRITE_FILE: filename.html
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
RUN_COMMAND: npm install
npm install
EDIT_FILE: style.css
Change the background color to blue
ai-cli-agent/
βββ src/
β βββ main.rs # Main entry point
β βββ ai.rs # OpenRouter API integration
β βββ file_ops.rs # File operations
β βββ terminal.rs # Terminal operations
β βββ config.rs # Configuration management
β βββ utils.rs # Utility functions
βββ Cargo.toml # Rust dependencies
βββ test_ai_agent.sh # Test script
βββ README.md # This file
- Add new dependencies to
Cargo.toml - Implement the feature in the appropriate module
- Add CLI commands in
main.rs - Update the configuration if needed
- Add tests
Run the test script:
./test_ai_agent.shRun unit tests:
cargo test-
API Key Not Found
- Make sure you've set the
OPENROUTER_API_KEYenvironment variable - Check your configuration file
- Make sure you've set the
-
Permission Denied
- Ensure you have write permissions in the target directory
- Check file system permissions
-
Network Issues
- Verify your internet connection
- Check if OpenRouter API is accessible
-
Build Errors
- Ensure you have the latest Rust version
- Run
cargo cleanand try building again
Enable debug logging:
RUST_LOG=debug cargo run -- execute "your task"- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue on GitHub or contact the maintainers.
- OpenRouter for providing AI model access
- Rust community for excellent tools and libraries
- All contributors who have helped improve this project