Skip to main content

Smarty Jones

A super lightweight debugging assistant that provides AI-powered error analysis with minimal setup.

Features

  • AI-powered analysis: Uses Claude Sonnet via ChatOpenAI for intelligent error diagnosis
  • Auto source code analysis: Automatically reads and analyzes source code from stack traces
  • Rich context support: Pass files, directories, or complex nested data for better debugging
  • Zero configuration: Just install and one line to activate
  • Security first: Library-controlled prompts prevent prompt injection attacks

Installation

pip install smarty-jones

Quick Start

from smarty_jones import SmartyJonesHandler

# Install with your OpenAI-compatible endpoint
SmartyJonesHandler.install(
    endpoint_url="https://api.anthropic.com/v1/chat/completions",  # or your endpoint
    api_token="your-api-key",
    model="claude-4-6-sonnet"  # Optional, defaults to claude-4-6-sonnet
)

# Now any unhandled exception gets AI analysis
def test_function():
    return 1 / 0

test_function()  # This will trigger AI-powered error analysis

Advanced Usage

With Additional Context

# Pass additional context for better analysis
SmartyJonesHandler.install(
    endpoint_url="https://api.anthropic.com/v1/chat/completions",
    api_token="your-api-key",
    model="gpt-4",  # Use different model
    config_file="app.json",                    # Single file
    documentation="/path/to/docs/",            # Entire directory
    user_data={"session_id": "abc123"},        # Custom data
    business_rules="rules.yaml"                # Business context
)

Nested File Paths Support

# Complex nested structures with file paths
SmartyJonesHandler.install(
    endpoint_url="https://api.anthropic.com/v1/chat/completions", 
    api_token="your-api-key",
    model="claude-4-6-sonnet",  # Default model
    config={
        "business_rules_path": "rules.yaml", 
        "user_profiles": ["profile1.json", "profile2.json"]
    }
)

What You'll See

🤖 Smarty Jones Analysis:
========================================
📝 You're dividing by zero in line 15 of main.py
💡 Add a check: if denominator != 0 before division
🔍 Context: Variable 'denominator' was set to 0 in the loop above
📊 Confidence: 95%
========================================

Traceback (most recent call last):
  File "main.py", line 15, in <module>
    result = numerator / denominator
ZeroDivisionError: division by zero

How It Works

  1. Global Exception Hooking: Captures all unhandled exceptions automatically
  2. Source Code Analysis: Reads the actual source code from your stack trace
  3. Context Collection: Processes files, directories, and nested data structures
  4. AI Analysis: Sends structured data to Claude Sonnet for intelligent diagnosis
  5. Formatted Output: Returns clear, actionable debugging advice

Security Considerations

⚠️ Important: While Smarty Jones includes security protections, you are responsible for the files and data you pass as additional context.

What Smarty Jones Protects Against:

  • Blocks sensitive file types: Automatically excludes .env, .key, .pem, and other credential files
  • Content filtering: Redacts common secret patterns (API keys, passwords, tokens) from file contents
  • Prompt injection: Uses library-controlled prompts to prevent malicious input

Your Responsibility:

  • Review file paths: Ensure directories don't contain unintended sensitive files
  • Validate custom data: Check any custom context data before passing it
  • Use appropriate endpoints: Only use trusted AI service endpoints for your data

Best Practices:

# ✅ Good - specific files you control
SmartyJonesHandler.install(
    endpoint_url="...",
    config_file="./app/config.yaml",
    docs_path="./docs/"
)

# ⚠️ Risky - entire home directory
SmartyJonesHandler.install(
    endpoint_url="...",
    everything="~/"  # May contain sensitive files
)

Uninstalling

SmartyJonesHandler.uninstall()  # Removes the exception handler

Development

# Clone and install in development mode
git clone https://github.com/FrankSiderio/smarty-jones.git
cd smarty-jones
pip install -e .

# Run the test
python test_minimal.py

Security

  • No prompt injection: User data is passed as structured JSON, not interpolated into prompts
  • Library-controlled prompts: All AI instructions are hardcoded in the library
  • Local file reading: Only reads files you explicitly specify
  • Safe by default: Won't read system files or execute arbitrary code

Requirements

  • Python 3.8+
  • langchain-openai
  • langchain-core

Total dependencies: Just 2 lightweight packages!

License

MIT License - see LICENSE file for details.

Release files for smarty-jones 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smarty-jones 0.1.3
File Size Uploaded
smarty_jones-0.1.3.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smarty-jones 0.1.3
File Interpreter ABI Platform
smarty_jones-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / smarty_jones-0.1.3.tar.gz

Download URL smarty_jones-0.1.3.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b86c08895d401c72b4dd94f8063bf7c9adcdd58dca5266e0969be2efd7a57727
BLAKE2b-256 checksum
How to use checksums
f4efa34a73c5b7099ca50f7cc078330a1c6c576edf938314240621b618d5890a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / smarty_jones-0.1.3-py3-none-any.whl

Download URL smarty_jones-0.1.3-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86039692f35b84292060673fa6de4c09850c98d73e221d348529aa687f53b513
BLAKE2b-256 checksum
How to use checksums
45e29a1f96edb9bcab47f8f6ab4737147018bba879b81f191cb70581cf08f990
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page