Metadata-Version: 2.4
Name: codet
Version: 1.0.9
Summary: A cross-platform command-line tool for file processing and Git repository analysis with support for commit history tracking, code hotspot detection, and customizable filtering options
Home-page: https://github.com/host452b/codet
Author: clemente0620
Author-email: 
Classifier: Programming Language :: Python :: 3
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: colorlog>=6.0.0
Requires-Dist: gitpython>=3.1.0
Requires-Dist: prettytable>=3.12.0
Requires-Dist: tqdm>=4.60.0
Requires-Dist: openai>=1.84.0
Requires-Dist: dash>=2.14.0
Requires-Dist: plotly>=5.15.0
Requires-Dist: pandas
Requires-Dist: dash-bootstrap-components
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: black>=21.5b2; extra == "dev"
Requires-Dist: isort>=5.9.1; extra == "dev"
Requires-Dist: flake8>=3.9.2; extra == "dev"
Requires-Dist: twine>=3.4.1; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Codet

[![PyPI version](https://badge.fury.io/py/codet.svg)](https://pypi.org/project/codet/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/host452b/codet/actions/workflows/python-package-conda.yml/badge.svg)](https://github.com/host452b/codet/actions)

A cross-platform command-line tool for Git repository analysis. Profile commit history, detect code hotspots, generate diff reports, and optionally leverage AI for deeper insights. The generated git diff files integrate seamlessly with Cursor for collaborative development.

## Features

- **Commit history analysis** - browse and filter recent commits by time range, author, email, keyword, or commit hash
- **Code hotspot detection** - identify frequently modified files and directories to spot active areas
- **Flexible search modes** - union (match any condition) or intersection (match all conditions)
- **Diff report generation** - produce aggregated `.diff` report files for review in Cursor or other tools
- **AI-powered analysis** - optional OpenAI / Azure OpenAI integration for automated commit summarization
- **Interactive dashboard** - Plotly Dash visualization via the `codet-dash` command
- **JSON export** - structured per-commit JSON output for downstream pipelines (`-oj`)
- **Cross-platform** - works on Windows, macOS, and Linux

## Installation

### From PyPI

```bash
pip install codet
```

### From source

```bash
git clone https://github.com/host452b/codet.git
cd codet
pip install -e .
```

### Development dependencies

```bash
pip install -e ".[dev]"
```

## Quick Start

```bash
# analyze the current repo, last 7 days, with hotspot analysis
codet -d 7 -s

# search for keywords "Triton" and "cuda" in a cloned repo
git clone https://github.com/pytorch/pytorch.git
codet -d 7 -k Triton -k cuda -s -p pytorch

# filter by author email
codet -d 14 -e alice@example.com

# filter by commit hash (supports partial match)
codet -c abc1234

# intersection mode: must match ALL conditions
codet -d 7 -k feature -e dev@example.com -m intersection
```

## CLI Reference

```
usage: codet [-h] [--version] [-d DAYS] [-e EMAIL] [-u USER] [-k KEYWORD]
             [-c COMMIT] [-g] [-r] [-p PATH] [-s] [-m {union,intersection}]
             [-mo MODEL] [-to API_TOKEN] [-oe OPENAI_ENDPOINT]
             [-cp CUSTOM_PROMPT] [-f INPUT_FILE] [-oj]
```

### Basic Options

| Flag | Description | Default |
|------|-------------|---------|
| `-d`, `--days` | Look back N days for commits | `30` |
| `-e`, `--email` | Filter by author email (repeatable) | — |
| `-u`, `--user` | Filter by author name (repeatable) | — |
| `-k`, `--keyword` | Search keyword in commit diffs (repeatable) | — |
| `-c`, `--commit` | Filter by commit hash, supports partial match (repeatable) | — |
| `-g`, `--debug` | Enable debug logging | `False` |
| `-r`, `--recursive` | Recursively scan subdirectories for git repos | `True` |
| `-p`, `--path` | Path to analyze | current directory |
| `-s`, `--hotspot` | Enable code hotspot analysis | `True` |
| `-m`, `--mode` | Search mode: `union` or `intersection` | `union` |

### AI Options

Codet works with **any OpenAI-compatible API** — just pass the endpoint and model name:

| Flag | Description | Default |
|------|-------------|---------|
| `-mo`, `--model` | Model name as required by your provider (e.g., `gpt-4.1`, `openai/openai/gpt-5-nano`, `llama3`) | — |
| `-to`, `--api-token` | Bearer token (or set `AI_API_TOKEN` env var). If not set, AI analysis is skipped | — |
| `-oe`, `--openai-endpoint` | Base URL of the API (`/v1` is appended automatically if missing) | — |
| `-cp`, `--custom-prompt` | Custom prompt appended to AI analysis | — |
| `-f`, `--input-file` | Additional file to include in AI analysis | — |
| `-oj`, `--output-cook-json` | Export per-commit JSON reports to `json_cook/` | `False` |

**Examples with different providers:**

```bash
# Standard OpenAI
codet -d 10 -s -to $OPENAI_KEY -oe "https://api.openai.com/v1" -mo "gpt-4.1"

# Local Ollama
codet -d 10 -s -to ollama -oe "http://localhost:11434/v1" -mo "llama3"
```

## Dashboard

Codet includes an interactive Plotly Dash dashboard for visualizing analysis results.

```bash
# launch dashboard with JSON data directory
codet-dash --json-path json_cook/
```

## Output

### Diff Report

Each run generates a `git_patch_report_<timestamp>.diff` file containing aggregated patches with contextual metadata. Open it directly in Cursor for AI-assisted code review.

### JSON Export

With `-oj`, per-commit JSON files are written to `json_cook/<repo_name>/`, each containing commit metadata, changed files, and optional AI summaries.

## Development

```bash
git clone https://github.com/host452b/codet.git
cd codet
pip install -e ".[dev]"

# lint
flake8 . --max-line-length=127

# format
black .
isort .

# test
pytest
```

## License

MIT License. See [LICENSE](LICENSE) for details.
