Skip to content
camaloloPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

68 Commits

Folders and files

Repository files navigation

AI CLI

Description

AI CLI is a Rust application that acts as a provider-agnostic AI assistant within a sandboxed terminal environment. It supports any OpenAI-compatible API to assist with coding tasks, file operations, online searches, email sending, and shell commands. The application takes initiative to provide solutions, execute commands, and analyze results without explicit user confirmation.

Usage

# Interactive REPL mode (default)
cargo run

# One-shot mode — print response and exit
cargo run -- --prompt "explain this codebase"

# Debug mode — writes tool execution and API details to debug.log
cargo run -- --debug

REPL Commands

Command Action
/exit, /quit, /q Exit the REPL
/clear Clear conversation history
/model Print the current model name

EOF (Ctrl-D) also exits.

Tools

The AI has access to the following tools, all auto-approved:

Tool Description
execute_command Run shell commands in a sandboxed environment (bubblewrap on Linux)
file_editor Read, write, search, search-and-replace, and apply diffs to files
search_online Web search via the Tavily Search API
scrape_url Extract readable content from a URL with optional summarization
send_email Send emails via SMTP
alpha_vantage_query Query the Alpha Vantage API for stock/financial data

Configuration

Create ~/.aicli.conf (INI format):

# AI Provider (Required)
PROVIDER=openai          # openai, ollama, zai, or any openai-compatible provider
API_BASE_URL=            # custom endpoint (empty = provider default)
MODEL=gpt-4o-mini
API_KEY=your_api_key_here

# SMTP (Optional — for send_email tool)
SMTP_SERVER=localhost
SMTP_USERNAME=
SMTP_PASSWORD=
DESTINATION_EMAIL=
SENDER_EMAIL=

# Search APIs (Optional)
TAVILY_API_KEY=
ALPHA_VANTAGE_API_KEY=

Environment variables prefixed with AICLI_ override config file values (e.g., AICLI_API_KEY overrides API_KEY).

Supported Providers

  • OpenAI (and any OpenAI-compatible API): Set PROVIDER=openai, optionally API_BASE_URL for custom endpoints.
  • Ollama (local LLMs): Set PROVIDER=ollama, MODEL=llama3, API_BASE_URL=http://localhost:11434.
  • ZAI: Set PROVIDER=zai, MODEL=glm-5.2.

Modules

Module Responsibility
src/main.rs Entry point, argument parsing, interactive REPL loop
src/agent.rs LLM agent builder, streaming prompt, conversation history, CliHook
src/tools/ Tool implementations (rig Tool trait), shared ToolCtx
src/config.rs Configuration loading from ~/.aicli.conf and AICLI_ env vars
src/command.rs Sandboxed command execution (bubblewrap on Linux)
src/file_edit.rs File operations with sandbox path validation
src/search.rs Tavily web search implementation
src/scrape.rs URL scraping with SSRF protection and content extraction
src/email.rs SMTP email sending
src/alpha_vantage.rs Alpha Vantage financial data queries
src/sandbox.rs Sandbox root directory management
src/patch.rs Unified diff application
src/http.rs Shared async HTTP client
src/shell.rs Shell detection for system prompt
src/utils.rs Debug logging, text truncation, summarization

Debug Mode

Run with --debug to log to debug.log in the current directory:

cargo run -- --debug

Logs include: provider configuration, tool calls and results, command execution output, API request/response details, and SMTP activity.

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages