Skip to main content

ai-cli

Sub-5ms streaming AI assistant & autonomous agent for Unix terminals with Rich markdown rendering and session memory.

Compatible with any OpenAI-compatible provider: Ollama, vLLM, LM Studio, Groq, OpenRouter, Together AI, OpenAI, and Antigravity / OMP.


⚡ Why ai-cli?

Most AI command-line tools (sgpt, llm, open-interpreter) pull in dozens of heavy Python packages (requests, pydantic, openai, click), resulting in 200ms–400ms startup latency before sending a single byte over the network.

ai-cli is engineered for speed, minimalism, and true Unix ergonomics:

  • Instant Startup (< 5ms) — starts and begins execution immediately.
  • 🤖 Autonomous Agent Mode (Default) — equipped with 5 essential tools (bash, read_file, write_file, search_web, fetch_web_page).
  • 🎨 Rich Terminal Markdown — syntax-highlighted code blocks, auto-aligned tables, blockquotes, and task checkboxes rendered cleanly in your terminal.
  • 🧠 Per-Terminal Session Memory — preserves conversation context automatically within the same terminal tab/session (scoped by shell Process ID).
  • 🌐 Zero-Key Web Search — live Google/Startpage + DuckDuckGo search integration without requiring third-party search API keys.
  • 🚀 Heavy Harness Handoff (-H) — hand off active conversation context to omp, claude, codex, or pi when a task outgrows a lightweight CLI.
  • 🚰 Pure Unix Pipelines — seamlessly handles stdin, trailing instructions, and outputs clean raw text when piped to files or other CLI tools.

📦 Installation

1. One-Line Install (Recommended)

curl -sSL https://raw.githubusercontent.com/Codder13/ai-cli/main/install.sh | bash

2. Manual / Git Clone

git clone https://github.com/Codder13/ai-cli.git ~/Projects/ai-cli
ln -sf ~/Projects/ai-cli/src/ai_cli/main.py ~/.local/bin/ai

3. Dependencies

Requires Python 3.8+ and rich for terminal markdown formatting:

pip install rich
# or on Arch Linux:
sudo pacman -S python-rich

🛠️ Usage

💡 No quotes required: You can type your prompts directly without quotation marks across all flags and commands!

1. Direct Asking & Autonomous Tasks (Default)

ai runs in agent mode by default, choosing when to search the web, read files, or execute commands to give you an accurate, grounded answer:

# Autonomous research & web searching
ai search the latest zig release and summarize changes

# Local codebase inspection & execution
ai inspect package.json and run the build script

# General knowledge
ai what is the biggest crater on the moon

2. Sandbox Security & Modification Bypass (-s / --no-sandbox)

By default, all command executions and file operations are protected in a strict read-only Bubblewrap (bwrap) sandbox:

  • 🔒 Read-Only System: Root (/), /etc, /usr, and project files cannot be accidentally modified.
  • 🔒 Isolated Secrets: ~/.ssh, ~/.gnupg, and ~/.aws are masked with empty filesystems.

To allow creating files, modifying code, or running system commands, pass -s (unquoted):

# Create files without quotes:
ai -s create this and that

# Write code and scripts:
ai -s create a python script that tests database connections

# Install system packages:
ai -s install ripgrep with pacman

3. Pure No-Tools Streaming (-n / --no-tools)

If you want instant, direct token streaming without tool execution:

ai -n explain quantum computing in 3 bullets

4. Unix Pipelines & Stdin

Pipe terminal output directly into ai with or without trailing instructions:

# Summarize git changes
git diff | ai summarize these changes in 3 bullet points

# Explain log errors
cat /var/log/nginx/error.log | tail -n 20 | ai explain these errors

# Pipe output cleanly to file (automatically strips ANSI formatting)
ai -n generate a json array of 5 fruits > fruits.json

5. Terminal Session Memory (Automatic)

ai automatically preserves conversation history within the same terminal tab/session:

 ai what is the largest file in this project
# ... Inspects directory and lists the largest file ... ai how can I optimize it
# ... Automatically remembers the file from the previous turn!

# Clear conversation memory for the current tab: ai -C    # or ai --clear

6. Handoff to Heavy Harnesses (-H / --handoff)

When a simple task evolves into a large-scale refactor, codebase overhaul, or multi-file debugging session, hand off your entire conversation session context to a full workspace agent:

# Handoff conversation to Oh My Pi / Hermes (default): ai -H Refactor all affected modules and run test suite

# Handoff to Claude Code: ai -H claude Fix all broken unit tests across the whole workspace

# Supported harnesses: omp, claude, codex, pi

7. Interactive Tool Approvals (-c / --confirm)

By default, ai executes safe tools autonomously. If you prefer human-in-the-loop confirmation before each action:

ai -c clean up temp and cache files in this directory

⚙️ Configuration Cascade

ai-cli resolves configuration in the following order:

  1. CLI Flags: -m, -u, -k, -s
  2. Environment Variables: AI_MODEL, AI_BASE_URL, AI_API_KEY
  3. Config File: ~/.config/ai/config.json
  4. OMP / AGM Config: ~/.omp/agent/models.yml (auto-detected)

Initialize a config template:

ai --init-config

This generates ~/.config/ai/config.json:

{
  "base_url": "https://api.openai.com/v1",
  "api_key": "your-api-key",
  "model": "gpt-4o-mini",
  "system_prompt": "You are a concise, helpful terminal assistant.",
  "temperature": 0.7,
  "require_approval": false
}

📖 CLI Reference

usage: ai [-h] [-n] [-c] [-y] [-m MODEL] [-u BASE_URL] [-k API_KEY]
          [-s SYSTEM] [-t TEMPERATURE] [--max-turns MAX_TURNS] [--init-config]
          [-v] [-C] [-H [HARNESS]]
          [prompt ...]

positional arguments:
  prompt                User prompt or instruction

options:
  -h, --help            Show this help message and exit
  -n, --no-tools        Disable tools and run in fast direct streaming completion mode
  -c, --confirm         Require manual confirmation for each tool action
  -y, --yes             Bypass confirmation and auto-approve all tool actions
  -m, --model MODEL     Model identifier (default: gemini-3.7-flash-high or config)
  -u, --base-url BASE   OpenAI-compatible API base URL
  -k, --api-key KEY     API authorization key
  -s, --system SYSTEM   Custom system prompt
  -t, --temperature T   Sampling temperature (0.0 - 2.0)
  --max-turns N         Maximum tool execution turns in agent mode (default: 25)
  --init-config         Create a default config template at ~/.config/ai/config.json
  -v, --version         Show version
  -C, --clear           Clear conversation memory for the current terminal session
  -H, --handoff [NAME]  Handoff session context to a heavy agent harness (omp, claude, codex, pi; default: omp)

📄 License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_flow_cli-0.8.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_flow_cli-0.8.0-py2.py3-none-any.whl (14.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ai_flow_cli-0.8.0.tar.gz.

File metadata

  • Download URL: ai_flow_cli-0.8.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ai_flow_cli-0.8.0.tar.gz
Algorithm Hash digest
SHA256 12bda7d75e83b4931f0bbe735f6962e7f7d59c7c80cf2a9c9175c243ddc5bf75
MD5 8981542d770c42aecd33b02c1b3c70f0
BLAKE2b-256 1da8694404b84f540b19b7321c99d8b8e4ac6871abe177970ad3348f26fbe827

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_flow_cli-0.8.0.tar.gz:

Publisher: release.yml on Codder13/ai-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_flow_cli-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ai_flow_cli-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ai_flow_cli-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b2b0f05c12011147b025153f81dd63b6b88b1d199cf55779eaecc9c43e850db5
MD5 6c3c2ca74273a0b4354b61d18a19e78a
BLAKE2b-256 71b5c624143d0d201ef40c27f57e92baaa077039a1ba9adf8b7c3e56fb946348

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_flow_cli-0.8.0-py2.py3-none-any.whl:

Publisher: release.yml on Codder13/ai-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page