Metadata-Version: 2.4
Name: codemedic
Version: 1.0.0
Summary: Intelligent Python debugging library – explains errors, identifies root causes, and suggests fixes.
Author-email: Aravind Adityaa M <aravindadityaa912006@gmail.com>
Maintainer-email: Aravind Adityaa M <aravindadityaa912006@gmail.com>
License: MIT License
        
        Copyright (c) 2026 CodeMedic Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/aravindadityxa/codemedic
Project-URL: Repository, https://github.com/aravindadityxa/codemedic
Project-URL: Documentation, https://github.com/aravindadityxa/codemedic#readme
Project-URL: Bug Tracker, https://github.com/aravindadityxa/codemedic/issues
Project-URL: Changelog, https://github.com/aravindadityxa/codemedic/blob/main/CHANGELOG.md
Project-URL: Releases, https://github.com/aravindadityxa/codemedic/releases
Keywords: python,debugging,exceptions,traceback,ast,cli,developer-tools,static-analysis,security,error-analysis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Education
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich>=13.7.0
Requires-Dist: click>=8.1.0
Provides-Extra: dev
Requires-Dist: pytest>=8.2.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: flake8>=7.0.0; extra == "dev"
Requires-Dist: black>=24.4.0; extra == "dev"
Requires-Dist: isort>=5.13.0; extra == "dev"
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
Dynamic: license-file

# CodeMedic

Intelligent Python debugging library. Explains errors in plain English, identifies root causes, and suggests practical fixes.

[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![PyPI version](https://img.shields.io/pypi/v/codemedic.svg)](https://pypi.org/project/codemedic/)
[![Tests](https://github.com/aravindadityxa/codemedic/actions/workflows/ci.yml/badge.svg)](https://github.com/aravindadityxa/codemedic/actions)

## Features

- **Human-friendly explanations** – Beginner and professional modes
- **Root cause analysis** – Pinpoints the exact file, line, and variable state
- **Fix suggestions** – Non-destructive patch recommendations with confidence scores
- **Static analysis** – 14 AST-based checks for common issues
- **Security scanning** – Detects `eval()`, pickle, hardcoded secrets, weak hashes
- **Multiple report formats** – HTML, JSON, Markdown
- **Terminal UI** – Rich formatting with syntax highlighting
- **Extensible knowledge base** – 40+ built-in exceptions, customizable

## Installation

```bash
pip install codemedic
```

Requires Python 3.11+.

## Usage

### Command Line

Run a script with full error analysis:
```bash
codemedic run script.py
```

Analyze for static issues:
```bash
codemedic analyze script.py
```

Explain an exception:
```bash
codemedic explain TypeError
```

Show system diagnostics:
```bash
codemedic doctor
```

Generate report from a previous result:
```bash
codemedic report --format html --input result.json
```

### Python API

Analyze a file:
```python
from codemedic import Runner

runner = Runner(mode="beginner")
result = runner.run_file("script.py")

if not result.success:
    print(result.explanation["simple_explanation"])
    for fix in result.fixes:
        print(f"Line {fix.line_number}: {fix.description}")
```

Analyze a callable:
```python
from codemedic import Runner

def process_data():
    return data["key"]

runner = Runner()
result = runner.run_with_capture(process_data)

if not result.success:
    print(result.trace.exception_type)
```

Generate reports:
```python
from codemedic import Runner, ReportGenerator, Config

config = Config(output_folder="./reports")
runner = Runner(config=config)

result = runner.run_file("script.py")
if not result.success:
    gen = ReportGenerator(config)
    gen.generate(result.to_dict(), format="html")
    gen.generate(result.to_dict(), format="json")
```

Static analysis:
```python
from codemedic import CodeAnalyzer

analyzer = CodeAnalyzer()
issues = analyzer.analyze_file("script.py")

for issue in issues:
    print(f"[{issue.severity}] Line {issue.line}: {issue.message}")
```

Security scanning:
```python
from codemedic.security import check_file

warnings = check_file("script.py")
for w in warnings:
    print(f"[{w.code}] {w.message}: {w.recommendation}")
```

## Architecture

- `runner.py` – Script execution and exception capture
- `trace.py` – Stack frame collection and structuring
- `explanations.py` – Explanation generation
- `fixer.py` – Patch suggestion generator
- `analyzer.py` – Static analysis (AST-based checks)
- `security.py` – Security scanning
- `database.py` – SQLite knowledge base (40+ exceptions)
- `formatter.py` – Terminal UI with Rich
- `report.py` – HTML, JSON, Markdown report generation
- `cli.py` – Command-line interface
- `config.py` – Configuration management
- `utils.py` – Shared utilities

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

MIT. See [LICENSE](LICENSE).
