YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
AgentOpsCLI
AgentOpsCLI is a commercial-grade, production-oriented AI coding agent and terminal operations platform implemented entirely in Python.
It provides an agentic pair-programming loop with native local Ollama support, OpenAI-compatible APIs, Anthropic Messages API, transparent multi-provider routing, intelligent context discovery, and safe agent tools.
Key Features
- Unified Multi-Provider Support: Seamlessly interact with local models via Ollama (
llama3.1:8b,qwen2.5-coder:14b), OpenAI (gpt-4o,o3-mini), Anthropic (claude-3-5-sonnet), and Google Gemini. - Intelligent Model Router: Real-time scoring by observed latency, cost, and health, with automatic circuit breaking and bounded fallback.
- Local-Only Privacy Mode: Strict privacy enforcement (
LOCAL_ONLY=true) guarantees that no code or project data ever leaves your machine. - Project-Aware Context Engine: Respects
.gitignoreand default exclusions (.git,node_modules,__pycache__,.venv, binaries, and large files), ranking files by relevance to fit strict token budgets. - Safe Agent Tools:
read_file: Workspace containment and directory traversal protection.edit_file: Generates colored unified diff previews and enforces explicit user confirmation before writing changes atomically.run_command: Enforces approval before execution, applies strict timeouts, and automatically masks credentials and secrets in output.
- Session & Cost Management: Persistent atomic storage in
~/.agentops/sessions, resuming past conversations, and tracking input/output tokens and estimated costs. - Rich Terminal Interface: Syntax-highlighted code blocks and diffs, real-time streaming, and interactive slash commands (
/help,/model,/provider,/sessions,/cost,/doctor,/clear).
Architecture Overview
agentops/
βββ cli/
β βββ main.py # Command-line entrypoint & argument parser
β βββ commands/ # doctor, profile, mcp, auth, tasks, sessions
βββ core/
β βββ agent.py # AgentOpsEngine main agentic execution loop
β βββ conversation.py # Conversation turns and system prompts
β βββ events.py # Event emitter and streaming lifecycle
β βββ errors.py # Typed error hierarchy
βββ providers/
β βββ base.py # BaseProvider interface & data models
β βββ ollama.py # Native Ollama client (streaming & local inference)
β βββ openai_compatible.py # OpenAI / DeepSeek / vLLM adapter
β βββ anthropic.py # Anthropic Messages API adapter
β βββ gemini.py # Google Gemini adapter
β βββ registry.py # Provider lifecycle registry
βββ router/
β βββ router.py # SmartRouter transparent routing engine
β βββ scoring.py # Latency, cost, and reliability scoring
β βββ policies.py # Task complexity classification & privacy rules
β βββ fallback.py # Circuit breaking and bounded retries
βββ context/
β βββ indexer.py # Workspace file discovery and filtering
β βββ ignore.py # Gitignore pattern matching
β βββ token_budget.py # Token limits and safe truncation
β βββ builder.py # Relevance ranking & delimited context assembler
βββ tools/
β βββ base.py # BaseTool interface & JSON schema generation
β βββ read_file.py # Safe file reader
β βββ edit_file.py # Diff preview & atomic file editor
β βββ run_command.py # Sandboxed command execution & secret masking
β βββ diff.py # Unified diff generation & ANSI formatting
β βββ registry.py # Tool discovery and execution registry
βββ sessions/
β βββ store.py # Atomic session persistence
β βββ history.py # Session & Turn models
β βββ costs.py # Token & USD cost tracking
βββ security/
β βββ paths.py # Path boundary validation & traversal protection
β βββ approvals.py # Explicit human approval enforcement
β βββ secrets.py # Secret & credential redaction
βββ ui/
βββ terminal.py # Rich terminal renderer
βββ repl.py # Interactive prompt loop
βββ themes.py # Dark & Light palettes
βββ shortcuts.py # Slash command handlers
Requirements & Installation
Requirements
- Python 3.10, 3.11, or 3.12
- Git
Installation
Install via pip in editable development mode:
git clone https://github.com/mohdshamii/AgentOps-CLI.git
cd AgentOps-CLI
pip install -r requirements-dev.txt
pip install -e .
Verify the installation:
agentops --version
agentops doctor
The CLI executable is registered as agentops, with backward-compatible aliases mycodecli and agentopscli.
Quickstart & Daily Use
1. Interactive Session (Default)
Start the interactive REPL:
agentops
Inside the REPL, type queries or use slash commands:
/helpβ Display shortcuts and commands/model <name>β Inspect or switch the active model/provider <name>β Inspect or switch the active provider/sessionsβ List saved conversations/costβ View token usage and estimated cost/doctorβ Run runtime health diagnostics/clearβ Clear the terminal screen/exitβ Exit safely
2. Print / Pipe Mode (Non-interactive)
agentops -p "Explain the router architecture in agentops/router/router.py"
Output formatted as JSON for CI or automation:
agentops -p "List all functions in calculator.py" --output-format json
3. Provider Setup & Profiles
Configure a profile quickly:
# Set up for local Ollama
agentops profile init --provider ollama --model llama3.1:8b --goal coding
# Auto-detect best provider
agentops profile auto
Configuration Reference
Configuration can be set via .env, environment variables, .agentops-profile.json, or agentops.yaml.
| Variable | Description | Default |
|---|---|---|
PREFERRED_PROVIDER |
Default provider (ollama, openai, anthropic, gemini) |
ollama |
ROUTER_MODE |
Router mode (smart, fixed) |
smart |
ROUTER_STRATEGY |
Routing strategy (balanced, latency, cost) |
balanced |
ROUTER_FALLBACK |
Automatically fall back on error (true, false) |
true |
LOCAL_ONLY |
Enforce strict local-only privacy (true, false) |
false |
OLLAMA_BASE_URL |
Ollama service endpoint | http://localhost:11434 |
OPENAI_API_KEY |
OpenAI API key | None |
ANTHROPIC_API_KEY |
Anthropic Claude API key | None |
GEMINI_API_KEY |
Google Gemini API key | None |
Security & Privacy Guarantees
- Path Boundary Containment: Every file operation strictly validates that target paths resolve within the active workspace root. Path traversal attempts (
../../) raise immediate security violations. - Explicit Approval Workflow:
- File edits show a unified diff and require user confirmation before applying.
- Terminal commands show the exact command and working directory and require explicit approval.
- The agent cannot approve its own actions.
- Secret Redaction: API keys and tokens matching credential patterns are masked automatically in command output and logs.
Testing
Run the test suite:
pytest -v
All 80 tests cover unit components and end-to-end integration workflows without external network dependencies.
License
This project incorporates third-party open-source components with verified MIT and BSD-family licenses. For full details, see THIRD_PARTY_LICENSES.