A lightweight debugging assistant that provides AI-powered error analysis
Project description
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
- Global Exception Hooking: Captures all unhandled exceptions automatically
- Source Code Analysis: Reads the actual source code from your stack trace
- Context Collection: Processes files, directories, and nested data structures
- AI Analysis: Sends structured data to Claude Sonnet for intelligent diagnosis
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smarty_jones-0.1.3.tar.gz.
File metadata
- Download URL: smarty_jones-0.1.3.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b86c08895d401c72b4dd94f8063bf7c9adcdd58dca5266e0969be2efd7a57727
|
|
| MD5 |
0b7c1737db324c6d11d1ff40169203ff
|
|
| BLAKE2b-256 |
f4efa34a73c5b7099ca50f7cc078330a1c6c576edf938314240621b618d5890a
|
File details
Details for the file smarty_jones-0.1.3-py3-none-any.whl.
File metadata
- Download URL: smarty_jones-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86039692f35b84292060673fa6de4c09850c98d73e221d348529aa687f53b513
|
|
| MD5 |
204beb40c2f994d8da95adc4f891a752
|
|
| BLAKE2b-256 |
45e29a1f96edb9bcab47f8f6ab4737147018bba879b81f191cb70581cf08f990
|