Metadata-Version: 2.4
Name: smarty-jones
Version: 0.1.3
Summary: A lightweight debugging assistant that provides AI-powered error analysis
Author: Frank Siderio
Author-email: Frank Siderio <franksiderio@yahoo.com>
Maintainer-email: Frank Siderio <franksiderio@yahoo.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/FrankSiderio/smarty-jones
Project-URL: Repository, https://github.com/FrankSiderio/smarty-jones
Project-URL: Bug Tracker, https://github.com/FrankSiderio/smarty-jones/issues
Keywords: debugging,error-analysis,ai,llm,python,exception-handling,development-tools,code-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-openai>=0.1.0
Requires-Dist: langchain-core>=0.1.0
Dynamic: author
Dynamic: license-file
Dynamic: requires-python

# 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

```bash
pip install smarty-jones
```

## Quick Start

```python
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

```python
# 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

```python
# 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:
```python
# ✅ 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

```python
SmartyJonesHandler.uninstall()  # Removes the exception handler
```

## Development

```bash
# 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.
