Metadata-Version: 2.4
Name: checkemotion
Version: 0.2.1
Summary: Assign emotional personalities to Python functions via AST + runtime analysis
License: MIT
License-File: LICENSE
Keywords: ast,debugging,emotions,observability,profiling
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Description-Content-Type: text/markdown

  emotion-ai logo

emotion

  Give your Python functions feelings.
  A Python decorator that assigns emotional personalities to functions based on code structure and runtime behaviour.

---

## What It Does

| Feature | Description |
|---|---|
| 🎭 **Emotion assignment** | Each function gets an emotion based on its code structure: complexity, keywords, recursion, async, error-handling, etc. |
| 🌈 **Rich colorful CLI** | Every call prints ANSI 256-color output: emotion chip, intensity bar, valence badge, wall time, CPU time, memory, error count |
| 💬 **Inter-function conversation** | When two `conversation=True` functions run concurrently, they talk to each other in the terminal |
| 🔄 **Emotion drift** | Emotions evolve every 10 calls based on error rate, latency, and frequency |
| 🤝 **Social relationships** | Functions develop feelings toward each other: friendship, jealousy, respect, anger, pity… |
| 🔬 **Deep profiling** | Wall time, CPU time, heap delta, heap peak via `tracemalloc` — O(1) overhead per call |
| 🕸️ **Call graph** | Static AST scan builds a project-wide call graph; see who calls whom |

---

## Quick Demo

```python
from emotion import emotion

@emotion
def calculate_total(numbers: list) -> float:
    return sum(n for n in numbers if n > 0)

@emotion(conversation=True)
def validate_user(user_id: int, role: str) -> bool:
    try:
        assert user_id > 0
        assert role.strip()
        return True
    except AssertionError:
        return False

calculate_total([1, 2, 3, 4, 5])
validate_user(42, "admin")
```

**Terminal output:**

```
  😊  calculate_total  ▸  glad  [joy]  ░····  ▲ +
    ▸ awakened  Sums positive numbers and returns the total.

  │ ✓ done  😊 calculate_total  #1  ⏱ 0.1ms  cpu 0.01ms  mem +0.0KB  cc=2  err=0
```

---

## Installation

```bash
pip install emotion
```

Or clone and run directly:

```bash
git clone https://github.com/itsmohitrohilla/emotion.git
cd emotion
python examples/quickstart.py
```

---

## The `@emotion` Decorator

```python
# Bare — simplest form
@emotion
def my_function(x):
    return x * 2

# With options
@emotion(enabled=True, conversation=True, verbose=True)
def my_function(x):
    return x * 2
```

| Option | Default | Description |
|---|---|---|
| `enabled` | `True` | `False` → zero overhead, function unchanged |
| `conversation` | `False` | Functions talk to each other when running concurrently |
| `verbose` | `True` | `False` → silent mode, metrics still collected |

---

## Public API

```python
from emotion import (
    emotion,              # decorator
    build_report,         # build_report(name) → FunctionReport
    all_reports,          # all_reports(sort_by="call_count") → list
    describe,             # describe(func) → one-line string
    callers_of,           # callers_of(name) → list of caller names
    callees_of,           # callees_of(name) → list of callee names
    scan_directory,       # scan_directory(path) → build call graph
    get_all_names,        # list of all registered function names
    get_data,             # get_data(name) → raw registry dict
)
```

---

## Requirements

- Python 3.11+
- Zero external dependencies — pure stdlib
- **Optional**: [Ollama](https://ollama.ai) with `phi3.5:mini` for AI-generated descriptions
