# Scripts

Utilities and automation for the Athena project.

---

## What did I get done

Multi-repo "what did I get done" report generator with optional OpenRouter AI summaries. **→ [what_did_i_get_done/README.md](what_did_i_get_done/README.md)** for full documentation.

### Features

- **Multi-repo**: Discovers git repos under a root directory (sibling repos by default, or recursive).
- **Your commits only**: Uses `git config user.email` so only commits you authored are included; merge commits are excluded.
- **Time window**: Any `git log --since=...` value (e.g. `"24 hours ago"`, `"7 days ago"`, `"2025-01-01"`).
- **Optional AI summary**: With an OpenRouter API key, each repo’s commit list is summarized in 2–3 concise sentences.
- **Single Markdown file**: One report with a section per repo: optional summary + full commit list (hash, date, subject).

### Requirements

- **Python 3.7+** (standard library only; no pip install).
- **Git** on the PATH for each discovered repo.
- **OpenRouter API key** only if you want per-repo AI summaries (env `OPENROUTER_API_KEY` or `--openrouter-key`).

### Quick start

```bash
# From the athena repo: last 24 hours, sibling repos only, no AI
python scripts/what_did_i_get_done/what_did_i_get_done.py --no-ai

# Last 7 days, all repos under your GitHub folder, with AI summary
export OPENROUTER_API_KEY=sk-or-...
python scripts/what_did_i_get_done/what_did_i_get_done.py --root ~/Documents/GitHub --since "7 days ago"
```

Output is written to `what_did_i_get_done_YYYY-MM-DD_HHMM.md` in the current directory unless you set `-o path/to/report.md`.

---

## Command-line reference

| 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 (e.g. `7 days ago`, `2025-01-01`). |
| `--output` | `-o` | `what_did_i_get_done_<timestamp>.md` in cwd | Path of the generated Markdown file. |
| `--openrouter-key` | — | `OPENROUTER_API_KEY` env | API key for per-repo AI summaries. |
| `--openrouter-model` | — | `openai/gpt-4o-mini` | OpenRouter model id. |
| `--no-ai` | — | — | Disable AI summarization even if a key is set. |
| `--recursive` | `-r` | — | Discover repos recursively under `--root` (e.g. `org/repo`). |

### Default `--root` behavior

- If the **current directory is a git repo** (has `.git`), `--root` defaults to the **parent** of the current directory. That way, running the script from inside one repo (e.g. `athena`) still scans that repo and its siblings (e.g. other repos in `~/Documents/GitHub`).
- If the current directory is **not** a repo, `--root` defaults to the current directory, and only direct child directories that contain `.git` are considered repos.

---

## Repo discovery

- **Without `-r`**: Only **direct children** of `--root` are checked. Each child that contains a `.git` directory is treated as a repo. Example: `--root ~/Documents/GitHub` → `athena`, `other-project`, etc.
- **With `-r`**: The script walks `--root` recursively and treats any directory that contains a `.git` directory as a repo root. Use this when your layout is e.g. `~/Documents/GitHub/org/repo`.

Repos are processed in sorted order. The **author** is taken from the first repo’s `git config user.email` and reused for all repos so the same identity is used everywhere.

---

## OpenRouter (optional AI summaries)

If `OPENROUTER_API_KEY` is set (or you pass `--openrouter-key`) and you do **not** use `--no-ai`, the script calls OpenRouter once per repo that has commits. The model receives the repo name and the list of commits (hash, date, subject) and is asked to return 2–3 concise, information-dense sentences focusing on substantial changes.

- **Endpoint**: `https://openrouter.ai/api/v1/chat/completions`
- **Default model**: `openai/gpt-4o-mini` (override with `--openrouter-model`).
- **Failure handling**: If a request fails (network, rate limit, invalid key), that repo’s summary is omitted; the report still includes the commit list for that repo.

Get an API key at [OpenRouter](https://openrouter.ai/). You can use any model id they support (e.g. `anthropic/claude-3-haiku`, `openai/gpt-4o`).

---

## Output format

The generated Markdown looks like this:

```markdown
# What did I get done

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

---

## repo-name-one

Optional 2–3 sentence AI summary here if OpenRouter was used.

**Commits:**

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

## repo-name-two
...
```

Only repos that have at least one commit in the time window appear. Sections are ordered by repo name.

---

## Examples

**Last 24 hours, no AI, default root (sibling repos):**

```bash
python scripts/what_did_i_get_done/what_did_i_get_done.py --no-ai
```

**Last week, custom root, output to a specific file:**

```bash
python scripts/what_did_i_get_done/what_did_i_get_done.py --root ~/Documents/GitHub --since "7 days ago" -o ~/Desktop/weekly.md
```

**Recursive discovery (e.g. org/repo), with AI:**

```bash
export OPENROUTER_API_KEY=sk-or-...
python scripts/what_did_i_get_done/what_did_i_get_done.py --root ~/Documents/GitHub -r --since "1 week ago"
```

**Absolute date range, different model, no AI:**

```bash
python scripts/what_did_i_get_done/what_did_i_get_done.py --since "2026-02-01" --no-ai -o february.md
```

**Key from env, force no AI (e.g. in CI):**

```bash
python scripts/what_did_i_get_done/what_did_i_get_done.py --no-ai --since "24 hours ago"
```

---

## Troubleshooting

- **“No git repos found under …”**  
  Check that `--root` points to a directory that contains at least one subdirectory with a `.git` folder. Use `-r` if repos are nested (e.g. `org/repo`).

- **“No commits in the given time window for any repo.”**  
  The script exits 0 and writes nothing. Verify `--since` and that your `git config user.email` matches the author of the commits you expect.

- **No AI summary for a repo**  
  Either no OpenRouter key was set, `--no-ai` was used, or the OpenRouter request failed (check key, network, rate limits). The report still lists commits.

- **Wrong author**  
  Author is taken from the first discovered repo’s `git config user.email`. Ensure that repo (or your global git config) has the correct email.

---

## Other scripts in this directory

| Script | Purpose |
|--------|---------|
| `what_did_i_get_done/` | Multi-repo commit report with optional AI summaries ([README](what_did_i_get_done/README.md)) |
| `sync_version.py` | Keeps version strings in sync across Cargo.toml, README, OpenAPI, etc. |
| `sql2cql.py` | Converts or maps SQL to CQL for ScyllaDB. |
| `supabase_ipv4.py` / `supabase_ipv4_dumper.sh` | Supabase / IPv4-related helpers. |
| `ssl_enforcement.py` | SSL enforcement checks. |
| `xbp_dumper.py` | XBP dump utility. |
| `sequin/*.sql` | Sequin-related SQL (events, retention). |

For project-wide development commands and architecture, see the root [AGENTS.md](../AGENTS.md).
