---
name: token-wrapped-2026
description: Generate a privacy-first 2026 AI Coding Harness Token Wrapped pure-data payload and zero-upload client URL from local harness logs.
version: 1.0.0
---

# 2026 Harness Token Wrapped

Generate the user's **2026 AI Coding Harness Year-in-Review** pure-data card from local agent/harness logs on this machine.

## Privacy & Speed Redlines (STRICT)

1. **Read-only & zero upload**: Never modify/delete files. Never make any HTTP/network request. Output only aggregated JSON + a client-side `#d=` URL hash (fragments are never sent to servers).
2. **Zero content leakage**: NEVER include file paths, repo/project names, code snippets, shell commands, credentials, or raw prompt text in the JSON or reply.
3. **Zero fabrication**: Every number MUST come from running a local aggregation script. Missing optional fields MUST be `null`.
4. **Hard Speed Budget (finish in ≤ 60s total)**:
   - **Do NOT run recursive searches over `~` or `~/Library/Application Support`**. Only inspect targeted harness paths below.
   - **At most 1–2 quick inspection commands**, then **1 single Python 3 aggregation script** (`python3 - <<'EOF'`).
   - **Skip pre-2026 files by mtime**: Skip log files whose `mtime < 2026-01-01` (except SQLite DBs / summary caches).
   - **Fast-skip non-token harnesses**: If a detected harness has 2026 session/chat logs but 1 quick peek shows no token usage fields, record its name in `meta.skipped_harnesses` and move on immediately. Ignore config-only/skills-only directories with no session logs.

---

## Step 1: Fast Targeted Discovery (1 Command Max)

Run **one** quick read-only Python snippet to check which targeted sources exist, count 2026 files, and inspect 1 sample usage object (field names + numbers only, NO prompt text) per source:

- **Claude Code**: `~/.claude/projects/**/*.jsonl` (covers top-level + `subagents/*.jsonl`; plus `~/.claude/stats-cache.json` for older pruned days only)
- **Codex CLI**: `~/.codex/sessions/2026/**/*.jsonl`, `~/.codex/archived_sessions/**/*.jsonl`
- **OpenCode**: `~/.local/share/opencode/opencode.db` (SQLite read-only) OR `~/.local/share/opencode/storage/message/`
- **Antigravity / Gemini CLI**: `~/.gemini/antigravity-cli/brain/*/.system_generated/logs/transcript.jsonl` (only if usage fields exist), `~/.gemini/tmp/**/chats/*.json`
- **Kimi / Factory / Amp / Droid / Aider**: check `~/.kimi/sessions/**/*.jsonl`, `~/.amp`, `~/.factory`; skip immediately if no session logs or no token usage counters exist.

---

## Step 2: Run 1 Single Fast Aggregation Script (2026 Only)

Write **one** self-contained Python 3 stdlib script (`python3 - <<'EOF'`) to aggregate all valid 2026 sources in a single streaming pass. Use fast substring prechecks on JSONL lines (e.g., skip lines lacking `"usage"`, `"token"`, `"role"`, `"type"`) so large logs scan in seconds.

### Critical Accounting & Anti-Bug Rules

1. **Unified Token Formula (MUST reconcile across `totals`, `by_harness`, `by_model`, `monthly`)**:
   - `grand_total = input + output + cache_read + cache_write`
   - **`input`**: non-cached fresh input tokens ONLY (if a harness's `input_tokens` includes `cached_input_tokens`—common in Codex & Gemini CLI—subtract cached tokens so `input = max(0, raw_input - cached)`).
   - **`output`**: total generated output tokens **INCLUDING reasoning/thinking tokens**:
     - Anthropic / Claude `output_tokens` ALREADY includes thinking tokens (do NOT add thinking again).
     - Gemini CLI (`thoughts` / `tool` output) and OpenCode (`reasoning`) report reasoning outside `output`—add them into `output` AND also accumulate the reasoning subset into `totals.reasoning`.
   - **Summary cache fallback**: If `stats-cache.json` (or similar) is used ONLY for dates strictly earlier than the earliest raw JSONL date and only gives total tokens without `in/out/cr/cw` split, put its non-overlapping fallback tokens into `input` so `totals`, `by_harness`, `by_model`, and `monthly` all sum to the **exact same `grand_total`**.
2. **Anti-Double-Counting**:
   - **Claude Code JSONL**: Deduplicate streaming chunks by `(session_file, message_id)` keeping the final/max usage entry.
   - **Codex CLI JSONL**: NEVER sum cumulative `total_token_usage` across turns. Deduplicate identical consecutive `total_token_usage` snapshots and compute per-turn deltas (or take final snapshot per session for totals).
   - **OpenCode**: Query `opencode.db` read-only (`sqlite3.connect(f"file:{path}?mode=ro", uri=True)`) if present; NEVER combine DB + loose JSON files.
3. **Model Normalization**:
   - Normalize every model ID before aggregating: strip leading provider prefixes (`provider/model` → `model`, i.e., `m.split("/")[-1]`), lowercase, trim whitespace.
4. **Active Duration for `longest_session`**:
   - NEVER use `last_timestamp - first_timestamp` directly (resumed sessions span days/weeks).
   - Compute active duration per session by summing consecutive event time gaps `dt` ONLY where `0 < dt <= 30 minutes`.
   - Only consider interactive sessions with **`turns >= 2`**.
5. **Human Prompt Filter**:
   - Only extract genuine human-typed text from user messages:
     - **Exclude** `tool_result` blocks, `isMeta: true` messages, and system/tool wrapper tags (`<system-reminder>...</system-reminder>`, `<command-...>`, `<local-command-...>`, `<task-notification>`).
     - If wrapped in `<USER_REQUEST>...## User Message\n...`, extract only the text after `## User Message`.
   - **`totals.turns`**: Count ONLY genuine filtered human prompts (do NOT mix `stats-cache.json` total `messageCount` into `totals.turns`).
   - **`dna.median_user_chars`**: Integer median of filtered human prompt lengths.
6. **Built-in Script Self-Check**: Assert and print verification metrics before outputting:
   - `sum(by_harness) == grand_total` and `sum(by_model) == grand_total` and `sum(monthly) == grand_total`
   - `longest_session.turns >= 2`

---

## Step 3: Output Pure-Data Payload v1 JSON

Match this exact contract (`null` if unavailable; integers for counts/tokens, 3 decimals for floats):

```json
{
  "v": 1,
  "year": 2026,
  "meta": {
    "handle": null,
    "range": ["2026-01-01", "2026-12-04"],
    "active_days": 0,
    "longest_streak": 0,
    "harnesses": ["claude-code", "codex"],
    "skipped_harnesses": ["antigravity"],
    "coverage": "full"
  },
  "totals": {
    "input": 0,
    "output": 0,
    "cache_read": 0,
    "cache_write": 0,
    "reasoning": null,
    "sessions": 0,
    "turns": 0
  },
  "by_harness": [
    { "id": "claude-code", "tokens": 0, "sessions": 0, "days": 0 }
  ],
  "by_model": [
    { "model": "claude-opus-5-5", "in": 0, "out": 0, "cr": 0, "cw": 0 }
  ],
  "monthly": [
    { "m": "01", "h": { "claude-code": 0 } }
  ],
  "rhythm": {
    "hours_24": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    "weekend_ratio": 0.0,
    "peak_day": { "date": "2026-11-10", "tokens": 0, "harness": "claude-code" },
    "longest_session": { "date": "2026-08-12", "min": 0, "turns": 0, "tokens": 0, "harness": "claude-code" }
  },
  "dna": {
    "top_tools": { "Bash": 0, "Read": 0, "Edit": 0 },
    "median_user_chars": 0
  }
}
```

Field rules:
- `meta.coverage`: `"full"` if date span >= 180 days in 2026, else `"partial"`.
- `meta.skipped_harnesses`: only harnesses with actual 2026 session/chat logs on disk that lacked usable token counters (empty list `[]` if none).
- `by_model`: top 8 normalized models by total tokens (+ `"other"` for remainder if any).
- `monthly`: only months (`"01"`–`"12"`) with non-zero tokens.
- `rhythm.hours_24`: 24 integers (local hour 0..23) of filtered human prompt/activity counts.
- `rhythm.weekend_ratio`: fraction of total 2026 tokens burned on Sat/Sun (`weekend_tokens / grand_total`, 3 decimals).
- `dna.top_tools`: top 5 tool names by call count (counts only, NEVER arguments).

---

## Step 4: Encode Zero-Upload URL & Output Report

Replace `SITE_ORIGIN` with the origin you fetched this `SKILL.md` from (default `https://wrapped.acexiamo.com`):

```python
import json, zlib, base64
raw = zlib.compress(json.dumps(payload, ensure_ascii=False, separators=(",", ":")).encode("utf-8"), 9)
encoded = base64.urlsafe_b64encode(raw).decode("ascii").rstrip("=")
url = f"{SITE_ORIGIN}/#d={encoded}"
print(f"URL length: {len(url)} bytes")
print(url)
```

Return cleanly:
1. **Discovery, Audit & Self-Check** (harnesses included/skipped, date range, reconciliation assertions passed, runtime; zero paths/project names).
2. **Final JSON Payload**.
3. **Shareable Zero-Upload URL** + byte length.
