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.2.tar.gz (13.7 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.2-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aidbg-0.1.2.tar.gz
  • Upload date:
  • Size: 13.7 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.2.tar.gz
Algorithm Hash digest
SHA256 2cb6b5f40539be0c71bbd72a0a7ad6282cf62bef2f3949250114a4c3a7b7a51c
MD5 c1ed524a8f2963c2ef234222ef08f455
BLAKE2b-256 5a75c2e742ca7416a0b5c0c0121dbd095ec326fbf627cf293dfe8cc3f9de9354

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aidbg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a52f490aa5798c12104579c41d5e572dbb57b5cb1c14a4286d2237b8c1236b
MD5 d45ed15ea9d1b7bfb0a6e23b2f679fed
BLAKE2b-256 8027754382f89621974eb9400e5f9f1a276c2bb3307247e443434be7d65f63a1

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