Metadata-Version: 2.4
Name: getaigit
Version: 0.1.0
Summary: Correlate AI coding sessions with git history — attribution, churn, and blame overlay.
Project-URL: Homepage, https://getaigit.com
Project-URL: Repository, https://github.com/getaigit/getaigit
Project-URL: Issues, https://github.com/getaigit/getaigit/issues
License: Apache-2.0
License-File: LICENSE
Keywords: ai,attribution,blame,claude,copilot,git
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Requires-Dist: gitpython>=3.1
Requires-Dist: python-tlsh>=4.5.0
Requires-Dist: rich>=13.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# aigit

**Correlate AI coding sessions with git history.**

aigit tracks which lines of your codebase were written by an AI assistant — and which weren't. It works by matching code blocks from AI session logs to git commits via fuzzy hashing, then surfacing that attribution as a `git blame`-style overlay and CI report.

```
   4 a1b2c3d  [claude_c 100%] def greet(name: str) -> str:
   5 a1b2c3d  [claude_c 100%]     return f"Hello, {name}!"
   6 a1b2c3d
   7 f9e8d7c                   def farewell(name: str) -> str:
   8 f9e8d7c                       return f"Goodbye, {name}!"
```

## Why

As AI-assisted coding becomes the norm, teams lose visibility into:

- What percentage of the codebase is AI-authored
- Whether AI-generated code has higher churn or bug rates than hand-written code
- Which specific commits introduced AI-generated code and from what prompt

## Install

```bash
pip install aigit
```

Requires Python 3.10+ and git.

## Quick start

```bash
# 1. Index your AI sessions and git history
aigit index

# 2. View blame with AI attribution overlay
aigit blame src/myfile.py

# 3. See repo-wide AI% stats
aigit stats

# 4. Generate a CI report
aigit ci --format=markdown
```

## Supported AI tools

| Tool | Status |
|------|--------|
| Claude Code | Supported (auto-discovers `~/.claude/projects/`) |
| OpenAI Codex | Coming soon |
| Cursor | Planned |
| Devin / OpenCode | Planned |

The provider system is pluggable — see [CONTRIBUTING.md](CONTRIBUTING.md) to add your tool.

## Commands

### `aigit index`

Reads AI sessions and walks git history to build a local attribution database at `.aigit/attribution.db`.

```bash
aigit index                          # auto-discover Claude Code sessions
aigit index --sessions ./my-exports  # point to a custom session directory
aigit index --provider codex         # use a different provider
```

### `aigit blame <file>`

Annotates `git blame` output with AI attribution. Lines written by an AI are highlighted with the tool name and confidence score.

```bash
aigit blame src/app.py
aigit blame src/app.py --show-prompt   # also show the prompt that generated each line
```

### `aigit stats`

Shows AI attribution statistics across the repository.

```bash
aigit stats                    # repo-wide summary
aigit stats --file src/app.py  # single file
aigit stats --top 50           # show top 50 files (default: 20)
```

Example output:

```
aigit stats  —  3 sessions, 142 code blocks indexed

File                              AI lines  Total   AI%    Tools
────────────────────────────────  ────────  ──────  ─────  ─────────────
src/api/routes.py                      87     120  72.5%  claude_code:87
src/core/engine.py                     54      98  55.1%  claude_code:54
tests/test_routes.py                   41      60  68.3%  claude_code:41

Repo-wide: 182 / 450 lines (40.4% AI-attributed)
```

### `aigit ci`

Emits a machine-readable report for CI pipelines.

```bash
aigit ci                        # markdown (default)
aigit ci --format=json          # JSON
aigit ci --output=report.md     # write to file
```

## CI integration (GitHub Actions)

Add this workflow to post an AI attribution report on every pull request:

```yaml
# .github/workflows/aigit-report.yml
name: aigit AI Attribution Report
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  aigit-report:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - run: pip install aigit
      - run: aigit index
      - run: aigit ci --format=markdown --output=aigit-report.md
      - uses: marocchino/sticky-pull-request-comment@v2
        with:
          path: aigit-report.md
          header: aigit-attribution
```

## How it works

1. **Session ingestion** — reads AI tool session logs and extracts code blocks (both markdown fences and file write operations)
2. **Tiered fuzzy matching** — compares code blocks against git diff hunks using:
   - Exact SHA-256 match → 100% confidence
   - TLSH fuzzy hash distance < 30 → 90% confidence
   - TLSH fuzzy hash distance < 100 → 70% confidence
3. **Attribution storage** — stores matches in a local SQLite database (`.aigit/attribution.db`)
4. **Blame overlay** — runs `git blame` and annotates lines where the originating commit matched an AI code block

## Contributing

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

## License

Apache 2.0 — see [LICENSE](LICENSE).
