# What did I get done

Generate a Markdown report of **your** git commits across **multiple repositories**, optionally with per-repo AI summaries via [OpenRouter](https://openrouter.ai/). Use it for status updates, weekly digests, or to see at a glance what changed where.

## Features

- **Multi-repo**: Discovers git repos under a root directory (sibling repos by default, or recursive)
- **Your commits only**: Uses `git config user.email`; merge commits excluded
- **Time window**: Any `git log --since=...` value (e.g. `"24 hours ago"`, `"7 days ago"`, `"2025-01-01"`)
- **Optional AI summary**: With OpenRouter, each repo gets a 2–3 sentence summary of substantial changes
- **Single output**: One Markdown file with a section per repo (summary + commit list)

## Requirements

- **Python 3.7+** — standard library only, no pip install
- **Git** on PATH
- **OpenRouter API key** — only if you want AI summaries (`OPENROUTER_API_KEY` or `--openrouter-key`)

## Quick start

```bash
# Last 24 hours, sibling repos, no AI
python what_did_i_get_done.py --no-ai

# Last 7 days, custom root, with AI summary
export OPENROUTER_API_KEY=sk-or-...
python what_did_i_get_done.py --root ~/Documents/GitHub --since "7 days ago"
```

Output: `what_did_i_get_done_YYYY-MM-DD_HHMM.md` in the current directory (override with `-o path`).

## Usage

### From this directory

```bash
cd scripts/what_did_i_get_done
python what_did_i_get_done.py [options]
```

### From repo root

```bash
python scripts/what_did_i_get_done/what_did_i_get_done.py [options]
```

## Options

| Option | Short | Default | Description |
|--------|-------|---------|-------------|
| `--root` | — | Parent of cwd if cwd is a repo, else cwd | Directory under which to discover git repos |
| `--since` | — | `24 hours ago` | Git-style time window |
| `--output` | `-o` | `what_did_i_get_done_<timestamp>.md` in cwd | Output file path |
| `--openrouter-key` | — | `OPENROUTER_API_KEY` env | API key for AI summaries |
| `--openrouter-model` | — | `openai/gpt-4o-mini` | OpenRouter model id |
| `--no-ai` | — | — | Disable AI even if key is set |
| `--recursive` | `-r` | — | Discover repos recursively (e.g. `org/repo`) |

### Default `--root`

- If cwd is a git repo → `--root` = parent of cwd (scans that repo + siblings)
- If cwd is not a repo → `--root` = cwd (scans direct children only)

## Repo discovery

- **Without `-r`**: Only direct children of `--root` with a `.git` directory
- **With `-r`**: Recursive walk; any dir with `.git` is a repo root

Author email is read from the first repo’s `git config user.email` and reused for all repos.

## OpenRouter (AI summaries)

With a valid API key and without `--no-ai`, the script calls OpenRouter once per repo that has commits. Each call gets the repo name and commit list; the model returns 2–3 concise sentences about substantial changes.

- **Endpoint**: `https://openrouter.ai/api/v1/chat/completions`
- **Default model**: `openai/gpt-4o-mini`
- On failure (network, rate limit, bad key): summary omitted; commits still listed

Get a key at [OpenRouter](https://openrouter.ai/). Override the model with `--openrouter-model` (e.g. `anthropic/claude-3-haiku`).

## Output format

```markdown
# What did I get done

**Time window:** 7 days ago  
**Date range:** 2026-03-03 (since: 7 days ago)

---

## athena

Optional 2–3 sentence AI summary here.

**Commits:**

- `abc1234` 2026-03-02 — feat: add new endpoint
- `def5678` 2026-03-01 — fix: handle empty body

## other-repo
...
```

## Examples

```bash
# Last week, custom output path
python what_did_i_get_done.py --root ~/Documents/GitHub --since "7 days ago" -o ~/Desktop/weekly.md

# Recursive discovery, with AI
export OPENROUTER_API_KEY=sk-or-...
python what_did_i_get_done.py --root ~/Documents/GitHub -r --since "1 week ago"

# Absolute date range, no AI
python what_did_i_get_done.py --since "2026-02-01" --no-ai -o february.md

# CI / automation: force no AI
python what_did_i_get_done.py --no-ai --since "24 hours ago"
```

## Troubleshooting

| Problem | Solution |
|---------|----------|
| No git repos found | Check `--root`; use `-r` if repos are nested |
| No commits in window | Verify `--since` and `git config user.email` |
| No AI summary | Check key, network; report still has commits |
| Wrong author | First repo’s `user.email` is used; fix global or repo config |

## License

Part of the Athena project.
