Metadata-Version: 2.4
Name: autobolt-cli
Version: 0.1.0
Summary: Autonomous self-improving SWE agent with persistent memory, project introspection, and real-world benchmark harness
License-Expression: MIT
Project-URL: Repository, https://github.com/hardikcube07/autobolt
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.28
Requires-Dist: rich>=13.0
Requires-Dist: fastapi>=0.100
Requires-Dist: uvicorn>=0.20
Requires-Dist: python-multipart>=0.0.6
Requires-Dist: duckduckgo_search>=6.0
Requires-Dist: lxml>=5.0
Dynamic: license-file

# Autobolt — Autonomous Coding Agent

**Autobolt** is an autonomous, self-improving SWE (Software Engineering) agent that writes code, runs tests, reads errors, fixes itself, and iterates until tests pass. It runs entirely locally via Ollama — no API costs, no data leaves your machine.

## Quick Start

```bash
# Install
pip install -e .

# CLI — chat with the agent
autobolt

# Server — web UI with WebSocket streaming
autobolt-server
# → http://localhost:8000

# Benchmark — measure solve rate on 10 built-in tasks
python -m distributed_agents.benchmark --model llama3.2:3b

# Real-world benchmark — run against real GitHub issues
python -m distributed_agents.real_benchmark --max-per-repo 3
```

## What It Does

| Mode | Command | What Happens |
|------|---------|-------------|
| Chat | `autobolt` | Interactive CLI. Type a task, agent uses tools to complete it. |
| Web UI | `autobolt-server` | Dark-theme chat at `http://localhost:8000`. Toggle "Auto Iterate" to write → test → fix → retest autonomously. |
| Benchmark | `benchmark` | Runs 10 predefined tasks (fib → rate-limiter). Reports solve rate, iterations, token cost, failure modes. |
| Real Benchmark | `real_benchmark` | Discovers real GitHub issues via merged PR references, clones repos, runs agent, reports solve rate per repo. |
| Dashboard | `http://localhost:8000/dashboard` | Charts: solve rate by difficulty/repo, token heatmap, iterations distribution. |

## Architecture

```
┌─────────────────────────────────────────────────────┐
│  CLI (Rich)           │  Web UI + WebSocket         │
├─────────────────────────────────────────────────────┤
│  Iterative Developer     │  LLM (Ollama)  │  Tools  │
│  write → test → fix →    │  qwen3 /       │  12 fn  │
│  retest (max 5 iters)    │  llama3        │  calls  │
├─────────────────────────────────────────────────────┤
│  Memory Store  │  Project Scanner  │  Change Planner │
│  (SQLite)      │  deps/scripts    │  dependency-    │
│                │  /conventions     │  ordered files  │
├─────────────────────────────────────────────────────┤
│  Auto Quality Gate  │  Benchmark Harness           │
│  lint/typecheck     │  built-in + real GitHub      │
│  after every edit   │  issue pipeline              │
└─────────────────────────────────────────────────────┘
```

## System Components

| Module | File | Purpose |
|--------|------|---------|
| **LLM Client** | `llm.py` | Ollama `/api/chat` wrapper. 600s timeout, 2048 output tokens. |
| **Tools** | `tools.py` | 12 function tools: read, write, edit, bash, glob, grep, ls, web_search, web_fetch, git_status, git_diff, git_log, think. Permission system with session-level approval. |
| **Iterative Developer** | `iterative_dev.py` | Core loop: write code → run tests → parse failures → feed back to LLM → retest. Parses pytest, jest, Go test, Cargo test output. Self-correction on no-tool-use (2 retries). |
| **Memory Store** | `memory_store.py` | SQLite with 4 tables (projects, sessions, tasks, tool_uses). Keyword-overlap similarity recall injects past context into system prompt. |
| **Project Scanner** | `project_scanner.py` | Auto-detects project type, package manager, dependencies, frameworks, scripts, test/lint/typecheck commands, code conventions (tabs vs spaces, quotes, semicolons). |
| **Auto Quality Gate** | `auto_quality.py` | Hooks after write/edit tools — auto-runs linter + typecheck, appends synthetic errors for LLM to fix before proceeding. |
| **Change Planner** | `change_planner.py` | Uses LLM to plan file creation/modification order respecting cross-file dependencies before making changes. |
| **GitHub Issue Scraper** | `github_scraper.py` | PR-first discovery: scans merged PRs → extracts referenced issue numbers. Filters by body length (>50 chars), diff size (<500 lines), test presence in diff. Installs repo dependencies. Checks out parent commit. Returns targeted test paths. |
| **Real Benchmark Runner** | `real_benchmark.py` | Runs agent against real GitHub issues across 12 repos (pytest, django, pydantic, celery, redis-py, aiohttp, fastapi, flask, httpx, rich, requests, sentry). Reports solve rate, iteration efficiency, token cost, failure modes, per-repo breakdown. CSV export. |
| **Built-in Benchmark** | `benchmark.py` | 10 calibration tasks (3 easy, 4 medium, 3 hard). Automated JSON report + formatted console output with difficulty breakdown and failure mode analysis. |
| **Task Queue** | `task_queue.py` | In-memory async job queue for long-running benchmarks. POST /benchmark → returns job_id → poll GET /tasks/{id}. Max 1 concurrent job. |
| **Server** | `server.py` | FastAPI server. Endpoints: /chat, /iterate, /project, /sessions, /session/{id}, /task/{id}, /tasks, /tasks/{job_id}, /benchmark/results, /dashboard. WebSocket /ws. |
| **CLI** | `main.py` | Rich-powered interactive CLI. Commands: `dev <task>`, `iterate <task>`, `history`, `recall <query>`, `cost`. Vision support (image paths). |

## Benchmark Results (Calibration Suite)

Model: `llama3.2:3b` via Ollama (19 tok/s on M2 Pro)

| Difficulty | Solved | Rate | First Try | Avg Iters | Avg Tokens |
|-----------|--------|------|-----------|-----------|-----------|
| Easy | 3/3 | 100% | 2/3 | 1.3 | 8,035 |
| Medium | 4/4 | 100% | 3/4 | 1.5 | 10,255 |
| Hard | 3/3 | 100% | 3/3 | 1.0 | 2,478 |
| **Total** | **10/10** | **100%** | **8/10 (80%)** | **1.3** | **7,256** |

> **Note:** These are calibration tasks, not real-world GitHub issues. The same agent achieved 0% on real issues with a small model (qwen3:8b). The bottleneck is model capability, not the agent platform. Swap in a stronger model (DeepSeek V3, GPT-4o) and the infrastructure scales.

## What It CAN'T Do (Yet)

| Gap | Cause | Status |
|-----|-------|--------|
| Navigate large unfamiliar codebases | 3B-8B models lack the context window and reasoning depth for surgical fixes in 100K+ line repos | Model limit — needs 30B+ or API-grade |
| Distinguish "my fault" from pre-existing failures | Parent commit may have unrelated test failures | Mitigated via targeted test paths from PR diff |
| Install complex build dependencies | Some repos need compiled extensions, system packages | Partial — pip install works for pure Python |
| Run full test suites quickly | 12-15 tok/s on M2 Pro = 15-35 min per issue | Switch to faster model or API fallback |

## Real-World Benchmark

12 configured repos with PR-first issue discovery. To run:

```bash
# Scan and run against all repos (takes hours on small models)
python -m distributed_agents.real_benchmark --max-per-repo 3 --max-retries 3

# Quick test on one issue
python -m distributed_agents.real_benchmark --issues "pytest-dev/pytest#14683"

# Export results as CSV
python -m distributed_agents.real_benchmark --export-csv results.csv
```

## Requirements

- Python 3.10+
- [Ollama](https://ollama.ai) with a model pulled (`llama3.2:3b`, `qwen3:8b`, etc.)
- Optional: [GitHub CLI](https://cli.github.com) (`gh`) for real-issue benchmark

## License

MIT
