Skip to main content

Local-first CLI AI debugger for Python projects

Project description

AI Debugger - aidbg

aidbg is a local-first, CLI-based AI debugging tool for Python projects.

It wraps program execution, detects runtime failures, collects minimal diagnostic context, and returns a structured debugging explanation using an LLM โ€” without running background processes or monitoring your system.

aidbg activates only when your program crashes, analyzes the error, prints a concise fix, and exits immediately.


โœจ Why aidbg?

Modern developers often copy-paste tracebacks into AI chat tools to debug errors.

aidbg removes that friction.

Instead of:

python app.py
# copy error
# open browser
# paste into AI

You do:

aidbg run app.py

And get:

  • Root Cause
  • Fix
  • Short Explanation

All inside your terminal.


๐Ÿ” Key Features

  • CLI-based execution wrapper

  • Event-driven (no background daemon)

  • Zero idle CPU usage

  • Minimal context collection

  • Token-controlled LLM responses

  • Guardrails against unsafe or hacky fixes

  • Multi-provider support:

    • Groq
    • OpenAI
    • Ollama (local)
  • Global and project-level configuration

  • Fully open-source core


๐Ÿง  How It Works

Execution Flow:

aidbg run app.py
  โ†’ executes script
  โ†’ detects crash (non-zero exit)
  โ†’ extracts traceback
  โ†’ collects minimal context
  โ†’ sends structured prompt to LLM
  โ†’ prints debugging result
  โ†’ exits

aidbg never:

  • Runs continuously
  • Monitors your system
  • Sends your full repository
  • Collects environment variables
  • Reads .env files
  • Uploads datasets

๐Ÿ“ฆ Installation

pip install aidbg

Or from source:

pip install -e .

โš™๏ธ Configuration

Initialize configuration:

aidbg init

Project-specific config:

aidbg init --local

Config priority:

  1. Project config (.aidbg/config.json)

  2. Global config (~/.aidbg/config.json)


๐Ÿ›  Usage

aidbg run app.py

Example output:

Root Cause:
Division by zero.

Fix:
Validate the divisor before performing the division.

Explanation:
Python raises ZeroDivisionError when the divisor is zero.

๐Ÿ” Privacy Model

aidbg follows a minimal context principle.

Collected:

  • Relevant traceback frames
  • Failing file + line number
  • Code snippet around failure
  • Shallow project structure (depth โ‰ค 2)
  • Python version
  • OS
  • requirements.txt (if present)

Never collected:

  • Full repository
  • Secrets
  • Environment variables
  • Binary files
  • Historical logs

๐Ÿงฉ Project Structure

aidbg/
โ”‚
โ”œโ”€ cli.py
โ”‚   Entry point for CLI commands.
โ”‚
โ”œโ”€ runner.py
โ”‚   Executes target Python script via subprocess.
โ”‚
โ”œโ”€ trigger.py
โ”‚   Crash detection and LLM orchestration logic.
โ”‚
โ”œโ”€ init.py
โ”‚   Interactive configuration (global / project).
โ”‚
โ”œโ”€ config.py
โ”‚   Configuration loading and priority resolution.
โ”‚
โ”œโ”€ prompt.py
โ”‚   LLM system and user prompt construction.
โ”‚
โ”œโ”€ logic/
โ”‚   โ”œโ”€ complexity.py
โ”‚   โ”‚   Error classification (simple vs complex).
โ”‚   โ””โ”€ token_budget.py
โ”‚       Fixed token budget logic.
โ”‚
โ”œโ”€ context/
โ”‚   โ”œโ”€ collector.py
โ”‚   โ”‚   Traceback parsing and file extraction.
โ”‚   โ”œโ”€ project_tree.py
โ”‚   โ”‚   Shallow project structure extraction.
โ”‚   โ”œโ”€ environment.py
โ”‚   โ”‚   Python version and OS detection.
โ”‚   โ””โ”€ dependencies.py
โ”‚       Lightweight dependency parsing.
โ”‚
โ”œโ”€ llm/
โ”‚   โ”œโ”€ base.py
โ”‚   โ”œโ”€ groq.py
โ”‚   โ”œโ”€ openai.py
โ”‚   โ””โ”€ ollama.py
โ”‚
โ””โ”€ tests/
    Basic unit tests for stability.

๐Ÿงช Testing

pytest

๐Ÿ“ˆ Roadmap

Phase 1 (Current):

  • CLI tool
  • Multi-provider support
  • Token-controlled responses
  • Guarded fix suggestions

Phase 2 (Planned):

  • Specialized lightweight debugging model
  • Optional hosted API
  • Possible commercial extension
  • The core CLI tool will remain open-source.

๐Ÿ“„ License

MIT License.

The open-source CLI tool is released under MIT. Future hosted APIs or proprietary debugging models may be released under separate commercial terms.


๐Ÿค Contributing

Pull requests welcome. Please keep contributions minimal, testable, and consistent with the local-first philosophy.

Project details


Download files

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

Source Distribution

aidbg-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

aidbg-0.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file aidbg-0.1.0.tar.gz.

File metadata

  • Download URL: aidbg-0.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aidbg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e80d3cea1a5e1d8e990fe2bfc73b0aaaa1220201e11312169168c960844a831
MD5 32bba585309e082b53122d708edc596d
BLAKE2b-256 51835fbc705d36530a734b2975883522b0d2fb710dcae64c9020b75f717dc706

See more details on using hashes here.

File details

Details for the file aidbg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aidbg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aidbg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00409205355a44df7b91cfe6bd2959d84f0184f986f031cc852591fbcb170248
MD5 8504565e715021d3ffb1b97d8cd54807
BLAKE2b-256 97934d2ef0bf26da2281a6bfdef098815ccb44c33f18fc22999d5c86c8162c7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page