Skip to main content
Glama
README.md
# AI Coding Orchestrator (`aico` V2)

A production-quality local CLI application designed to orchestrate specialized coding agents:

* **Codex CLI** β†’ Lead Software Architect, Core Developer, and Complex Problem Solver.
* **Antigravity / AGY CLI** β†’ Quality Assurance, Reviewer, Regression Tester, and Small-Fix Agent.
* **Extended Agents** β†’ **Claude**, **Gemini**, and **Local LLMs** (via Ollama / OpenAI-compatible endpoints).

`aico` manages state machines, workflow transitions, Git worktree isolation, prompt templating, parallel test execution, AST security scanning, human-in-the-loop approvals, MCP server integration, and comprehensive reporting.

---

## πŸ—οΈ Architecture

```
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚      USER / CLI        β”‚
                    β”‚         (aico)         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                        TASK RECEIVED
                                β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  GIT & WORKTREE CHECK  β”‚
                    β”‚ Zero-Impact Isolation  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       CODEX CLI        β”‚
                    β”‚  β€’ Architecture Design β”‚
                    β”‚  β€’ Core Implementation β”‚
                    β”‚  β€’ Complex Fixes       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚        AGY CLI         β”‚
                    β”‚  β€’ Review & Test Plan  β”‚
                    β”‚  β€’ Parallel Validation β”‚
                    β”‚  β€’ AST Security Audit  β”‚
                    β”‚  β€’ Issue Classificationβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Issue Classification Branch β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                        β”‚                        β”‚
     PASS                   SMALL_FIX           COMPLEX / ARCH / BUG / SEC
       β”‚                        β”‚                        β”‚
       β–Ό                        β–Ό                        β–Ό
PARALLEL VALIDATION          AGY FIX                 CODEX FIX
(Test, Lint, Type,           (Local)                 (Deep Fix)
 Build, Security)               β”‚                        β”‚
       β”‚                        β–Ό                        β–Ό
       β–Ό                    AGY RETEST               AGY RETEST
     DONE                       β”‚                        β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## πŸš€ V2 Features & Enhancements

1. **🌿 Zero-Impact Git Worktree Isolation (`--worktree` / `-w`)**:
   - Executes all agent actions inside an isolated Git worktree without touching your active editor files or unstaged changes.
   - Automatically syncs and merges when the task completes successfully.

2. **⚑ Parallel Quality & Test Engine (`aico test`)**:
   - Concurrently executes Unit Tests, Linters (`ruff`/`eslint`), Typecheckers (`mypy`/`tsc`), Builds, and Security Audits in worker thread pools.

3. **πŸ›‘οΈ Built-in AST & Static Security Scanner (`aico scan`)**:
   - Real-time detection of SQL Injection risks, command injection (`shell=True`), hardcoded JWT secrets, weak cryptography (MD5/SHA1), and unsafe dynamic execution (`eval`/`exec`).

4. **πŸ”Ά Human-In-The-Loop (HITL) Mode (`--interactive` / `-i`)**:
   - Interactive checkpoint approval before architectural changes or security fixes with direct prompt guidance injection (`[A]pprove`, `[E]dit guidance`, `[R]eject`, `[Q]uit`).

5. **🎯 Granular Multi-Tier Model Routing**:
   - Configure distinct models per phase (e.g. `o3-mini` / `claude-3-7-sonnet` for architecture, `gemini-2.0-flash` for test review, `gpt-4o-mini` for small fixes).

6. **πŸ”Œ Model Context Protocol (MCP) Server (`aico mcp`)**:
   - Run `aico` as a standard MCP server for seamless integration with Cursor, Antigravity IDE, Claude Desktop, and other MCP clients.

7. **πŸ€– Extended Agent Support**:
   - Built-in adapters for **Claude CLI**, **Gemini CLI**, and **Local LLMs** (Ollama / OpenAI-compatible).

---

## πŸ“¦ Installation & Setup

```bash
cd /var/www/html/ai-coding-orchestrator
pip install -e .
```

Verify installation:
```bash
aico doctor
```

---

## πŸ’» CLI Command Reference

| Command | Description |
| :--- | :--- |
| `aico` | Launch interactive prompt session |
| `aico "task"` | Run a direct task in current working directory |
| `aico run "task"` | Explicit task run |
| `aico run -w "task"` | Run in an isolated **Git worktree** (zero-impact) |
| `aico run -i "task"` | Run with **Interactive Human-In-The-Loop** checkpoints |
| `aico test` | Run parallel test, lint, typecheck, build, and security checks |
| `aico scan` | Run static AST & regex security vulnerability scan |
| `aico mcp` | Start Model Context Protocol (MCP) JSON-RPC stdio server |
| `aico resume` | Resume interrupted task from saved `.ai-orchestrator/state.json` |
| `aico status` | Inspect current task state, iterations, and metrics |
| `aico logs` | View unified logs (`--agent codex`, `--agent agy`) |
| `aico stop` | Abort and cancel active task |
| `aico config show` | View current configuration |
| `aico config set <key> <val>` | Update configuration key |
| `aico doctor` | Run health checks for Codex, AGY, and Git |

---

## βš™οΈ Configuration (`~/.aico/config.yaml`)

```yaml
codex:
  command: "codex"
  timeout: 3600
  flags: ["exec", "--dangerously-bypass-approvals-and-sandbox"]
  model: null
  architecture_model: null
  implementation_model: null
  fix_model: null

agy:
  command: "agy"
  timeout: 1800
  flags: ["--print", "--dangerously-skip-permissions"]
  model: null
  review_model: null
  testing_model: null
  fix_model: null

workflow:
  max_iterations: 5
  max_codex_attempts: 5
  max_agy_attempts: 5
  auto_resume: false
  stop_on_environment_issue: true
  interactive: false
  require_approval_on_architecture: false
  require_approval_on_security: false

git:
  enabled: true
  create_branch: true
  branch_prefix: "ai-orchestrator"
  auto_stash_uncommitted: false
  use_worktree: false

testing:
  run_tests: true
  run_lint: true
  run_typecheck: true
  run_build: true
  run_security_scan: true
  parallel: true
  max_workers: 4

safety:
  protect_uncommitted_changes: true
  allow_destructive_git: false
```

---

## πŸ“‚ Workspace Layout

```
.ai-orchestrator/
β”œβ”€β”€ state.json           # Machine-readable task state and transition history
β”œβ”€β”€ task.md              # Original user task
β”œβ”€β”€ architecture.md      # Architecture design from Codex
β”œβ”€β”€ final-report.md      # Comprehensive post-task markdown report
β”‚
β”œβ”€β”€ codex/
β”‚   β”œβ”€β”€ prompt.md        # Prompt sent to Codex
β”‚   β”œβ”€β”€ result.md        # Codex execution summary
β”‚   └── issues.md        # Issues addressed
β”‚
β”œβ”€β”€ agy/
β”‚   β”œβ”€β”€ prompt.md        # Prompt sent to AGY
β”‚   β”œβ”€β”€ test-plan.md     # Test plan created by AGY
β”‚   β”œβ”€β”€ result.md        # AGY validation results
β”‚   β”œβ”€β”€ issues.md        # Issues detected
β”‚   └── fixes.md         # Small fixes applied
β”‚
β”œβ”€β”€ logs/
β”‚   β”œβ”€β”€ orchestrator.log # Workflow state transitions
β”‚   β”œβ”€β”€ codex.log        # Raw stdout/stderr of Codex
β”‚   └── agy.log          # Raw stdout/stderr of AGY
β”‚
β”œβ”€β”€ worktrees/           # Isolated git worktrees (when enabled)
└── checkpoints/         # Git snapshots before major stages
```

---

## πŸ§ͺ Test Suite

Run the full test suite covering all V1 and V2 capabilities:

```bash
pytest -v
```

**65 unit & integration tests pass with 100% success rate.**