Metadata-Version: 2.4
Name: shabah
Version: 0.1.0
Summary: Detect AI-generated API hallucinations in Python source code
Author: Shabah Contributors
License: MIT
Project-URL: Homepage, https://github.com/shabah/shabah
Project-URL: Repository, https://github.com/shabah/shabah
Project-URL: Documentation, https://shabah.dev
Keywords: static-analysis,ai-hallucination,linting,python
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Shabah

**Detects AI-generated API hallucinations before they reach production.**

Not a package scrapper. Not a linter. Shabah validates whether the functions and keyword arguments in your AI-written code actually exist in your installed libraries.

Zero dependencies. Offline. Sub-second scans.

```
$ shabah scan app.py

app.py:42
X UNKNOWN-KWARG: Unknown keyword argument: keep_first

  Found:    keep_first
  Hint:     Did you mean keep?
```

---

## Features

- **Unknown keyword argument detection** — flags parameters that don't exist in the real API (e.g. `keep_first=True` instead of `keep="first"`)
- **Import-aware resolution** — follows aliased imports (`import pandas as pd`) and from-imports (`from pandas import DataFrame`)
- **Live reflection** — resolves signatures against your installed packages, not a static database
- **CI-ready** — exits with non-zero when hallucinations are found

### Roadmap

- Fake method / attribute / module detection
- Deprecated API warnings
- Version mismatch analysis
- AI hallucination confidence scoring

---

## Installation

```bash
pip install shabah
```

Requires Python 3.12+.

---

## Usage

```bash
# Scan a single file
shabah scan app.py

# Scan an entire project
shabah scan src/

# Check the installation
shabah doctor

# Print version
shabah version
```

### Exit codes

| Code | Meaning          |
|------|------------------|
| 0    | No issues found  |
| 1    | Hallucinations detected |
| 2    | Internal error   |

---

## Example

Given this file:

```python
import pandas as pd

df = pd.DataFrame({"a": [1, 2, 3]})
result = df.drop_duplicates(
    keep_first=True,
    ignore_index=False,
)
```

Running `shabah scan app.py` produces:

```
app.py:5

✖ UNKNOWN-KWARG: Unknown keyword argument: keep_first

  Found:    keep_first
  Hint:     Did you mean keep?


app.py:6

✖ UNKNOWN-KWARG: Unknown keyword argument: ignore_index

  Found:    ignore_index


Scanned 1 file(s) | 2 error(s)
```

---

## How it works

1. **Parse** — the source file is parsed into an AST
2. **Resolve** — imports and variable assignments are resolved to their fully-qualified module paths
3. **Reflect** — live Python objects are inspected to extract real API signatures
4. **Match** — each call site's keyword arguments are compared against the real parameter list
5. **Report** — mismatches are formatted and displayed

---

## Project

```
shabah/
├── src/shabah/
│   ├── cli/          # Command-line interface
│   ├── parser/       # AST parsing and import resolution
│   ├── analyzer/     # Pipeline orchestration
│   ├── reflection/   # Live signature inspection
│   ├── tracker/      # Call resolution
│   ├── matcher/      # Keyword argument validation
│   ├── reporter/     # Diagnostic formatting
│   ├── models/       # Domain data structures
│   └── utils/        # Shared utilities
├── tests/
├── examples/
└── benchmarks/
```

---

## License

MIT
