Skip to content

Repository files navigation

aicli

An open-source AI coding terminal assistant — multi-model, git-native, privacy-first.

CI License Go Version Release

⚡ aicli  │  gpt-4o  │  myproject

  You: explain the auth middleware and suggest improvements
  
  Assistant: The auth middleware in src/middleware/auth.go uses JWT...
  ▌

Features

  • 🤖 Multi-model — OpenAI, Anthropic Claude, Google Gemini, Ollama (local), OpenRouter, and any OpenAI-compatible API
  • 🌿 Git-native — every AI edit creates a checkpoint; /undo reverts instantly
  • 🛡️ Privacy-first — run fully local with Ollama; no forced telemetry
  • 🤖 Agent mode — autonomous plan→execute→reflect loop with human-in-the-loop approval
  • 🔧 Built-in tools — read/write files, run commands, search code, fetch URLs
  • Fast — single Go binary, no runtime dependencies
  • 🖥️ Cross-platform — Linux, macOS, Windows

Installation

Starter setup

# 1. Clone the repo
git clone https://github.com/Devn913/aicli.git
cd aicli

# 2. Install Go
brew install go

# 3. Install aicli
go install ./cmd/aicli

# 4. Add Go binaries to PATH
export PATH="$PATH:$(go env GOPATH)/bin"

# 5. Create a starter config
aicli init --provider openrouter

Homebrew (macOS / Linux)

brew install Devn913/tap/aicli

Go install

go install github.com/Devn913/aicli/cmd/aicli@latest

Download binary

Grab the latest binary from Releases for your platform.

Build from source

git clone https://github.com/Devn913/aicli.git
cd aicli
go install ./cmd/aicli

Quick Start

# 1. Initialize config
aicli init --provider openrouter

# 2. Set your API key (or use Ollama for local models)
export OPENROUTER_API_KEY=sk-...

# 3. Start the interactive TUI
aicli

# 4. Or ask a single question
aicli ask "what does the middleware do?"

# 5. Run an autonomous agent task inside the TUI
#    then use /agent <task>

Using local models (no API key needed)

# Install Ollama: https://ollama.com
ollama pull llama3.2

# Use it with aicli
aicli --provider ollama

Supported Providers

Provider Models Free tier Local
OpenAI GPT-4o, o3, o1, GPT-4o-mini
Anthropic Claude Sonnet, Opus, Haiku
Google Gemini Gemini 2.5 Pro/Flash ✅ via aistudio
Ollama Llama 3.2, Qwen2.5, Mistral, any
OpenRouter 200+ models ✅ some
OpenAI-compatible Any (set base_url) varies varies

Configuration

Config is loaded in this order (highest precedence last):

  1. Built-in defaults
  2. ~/.config/aicli/config.toml (user)
  3. .aicli/config.toml (project — commit this for team settings)
  4. Environment variables
# .aicli/config.toml

[provider]
default = "openrouter"   # or "ollama" for local

[providers.openai]
model = "gpt-4o"
# API key: set OPENAI_API_KEY env var

[providers.anthropic]
model = "claude-sonnet-4-5"
# API key: set ANTHROPIC_API_KEY env var

[providers.ollama]
base_url = "http://localhost:11434"
model    = "llama3.2"

[providers.openrouter]
base_url = "https://openrouter.ai/api/v1"
model    = "anthropic/claude-sonnet-4-5"

[providers.gemini]
model    = "gemini-2.5-flash"

[agent]
confirm_dangerous = true   # ask before writing files / running commands
max_iterations    = 50

[editing]
diff_preview = true        # show diff before applying

Environment variables

Variable Description
OPENAI_API_KEY OpenAI API key
ANTHROPIC_API_KEY Anthropic API key
GEMINI_API_KEY Google Gemini API key
OPENROUTER_API_KEY OpenRouter API key
AICLI_PROVIDER Override active provider
AICLI_MODEL Override active model

CLI Reference

aicli                    Interactive TUI chat (default)
aicli init               Create a starter config
aicli ask <question>     Single question, non-interactive
aicli providers          List configured providers
aicli version            Print version

Flags:
  --provider   Override provider (openai|anthropic|ollama|openrouter|gemini)
  --model      Override model name
  --help       Show help
  --version    Print version

Slash Commands (inside TUI)

Command Description
/add <file> Add file to conversation context
/drop <file> Remove file from context
/clear Clear conversation history
/undo Restore last checkpoint (revert AI edits)
/diff Show git diff
/commit [msg] Git commit AI changes
/tokens Show token usage for this session
/agent <task> Run autonomous agent task
/model <name> Switch model mid-session
/help Show all commands

Agent Mode

Agent mode runs a plan→execute→reflect loop. The agent can read/write files, run commands, and search code to complete multi-step tasks.

# From CLI
aicli
# then use:
/agent refactor the database layer to use connection pooling

# From TUI (type in the chat box)
/agent write tests for all untested functions in src/services/

By default, the agent asks for confirmation before writing files or running shell commands (confirm_dangerous = true).


Safety

  • Checkpoints: before any file edit, a checkpoint is saved in .aicli/checkpoints/. Use /undo to revert.
  • Confirmation: review write and run_command actions carefully before approving them in agent mode.
  • No secrets in config: API keys go in env vars or system keychain — never in .aicli/config.toml.
  • Secret scanning: aicli warns before sending file content containing detected credentials to an LLM.

Project Structure

cmd/aicli/          Entry point
internal/
  agent/            Autonomous agent loop
  chat/             Conversation management + streaming
  cli/              Bubble Tea TUI
  config/           Config loading (TOML + env)
  editing/          File editing + checkpointing
  git/              Git integration
  providers/        LLM provider abstraction
    openai/         OpenAI + compatible APIs
    anthropic/      Anthropic Claude
    ollama/         Ollama local models
  tools/            Built-in agent tools
pkg/types/          Shared types

Contributing

See CONTRIBUTING.md. All contributions welcome.

Roadmap

  • v0.1 — MVP: multi-provider TUI, file editing, agent mode, git integration
  • v0.2 — Repo map (tree-sitter AST), real-time streaming, context engine
  • v0.5 — Local embeddings, semantic search, session memory, plugin SDK
  • v1.0 — LSP integration, shell sandboxing, audit log, secret scanner

License

Apache 2.0 © 2026 Devn913

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages