From 71f056927d213df0880c3a80b66ff27e2778092d Mon Sep 17 00:00:00 2001 From: Pratik Bhavsar Date: Wed, 30 Sep 2026 18:28:52 +0530 Subject: [PATCH 001/116] feat: add Work insights with a local Jet classifier Label sessions locally (area, work type, complexity, pushback) with Jet in the user's Ollama so the new Work page can show what spend went into: monthly allocation, workstreams, cost by work type, rework, and model right-sizing. Opt-in, paced, pausable, loopback-only; labels persist, text never does. Co-Authored-By: Claude Code --- AGENTS.md | 7 +- README.md | 24 + menubar/TokenMeterMenuBar.swift | 74 ++ page.html | 344 +++++++- scripts/setup-work-classifier | 102 +++ specs/2026-09-30-work-insights-design.md | 237 +++++ specs/AGENTS.md | 7 +- specs/ARCHITECTURE.md | 25 +- specs/SECURITY.md | 6 + specs/USER_GUIDE.md | 24 + tests/test_git_delivery.py | 2 +- tests/test_meter.py | 9 +- tests/test_work_insights.py | 595 +++++++++++++ token_meter/app.py | 348 +++++++- token_meter/domain/work.py | 266 ++++++ token_meter/platforms/base.py | 4 + token_meter/platforms/common.py | 3 + token_meter/platforms/linux.py | 19 + token_meter/platforms/macos.py | 19 + token_meter/platforms/unsupported.py | 3 + token_meter/platforms/windows.py | 3 + token_meter/services/work_insights.py | 1027 ++++++++++++++++++++++ 22 files changed, 3132 insertions(+), 16 deletions(-) create mode 100755 scripts/setup-work-classifier create mode 100644 specs/2026-09-30-work-insights-design.md create mode 100644 tests/test_work_insights.py create mode 100644 token_meter/domain/work.py create mode 100644 token_meter/services/work_insights.py diff --git a/AGENTS.md b/AGENTS.md index bb029690..c50a75ea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,6 +25,8 @@ Token Meter reads local agent traces, calculates clearly labeled usage estimates | `token_meter/projections.py` | Explicit allowlisted public compatibility projections | | `page.html` | Entire browser dashboard: markup, styles, routing, and JavaScript | | `menubar/TokenMeterMenuBar.swift` | Native AppKit companion, preferences, notifications | +| `token_meter/services/work_insights.py` | Opt-in local classifier: queue, pacing, pause, loopback Ollama client, label ledger | +| `token_meter/domain/work.py` | Work page aggregation over cached summaries and content-free labels | | `token_meter_mcp.py` | Bounded MCP interface; evidence is read-only except explicit confirmed session-budget changes | | `tests/test_meter.py` | Server, parser, UI-contract, installer, and Swift-source tests | | `tests/test_mcp_server.py` | MCP contract and privacy tests | @@ -49,7 +51,7 @@ Token Meter reads local agent traces, calculates clearly labeled usage estimates | `python3 -m unittest discover -s tests -v` | Run all unit and contract tests | | `PYTHONPYCACHEPREFIX=/private/tmp/token-meter-pycache python3 -m py_compile meter.py token_meter_mcp.py $(find token_meter -type f -name '*.py' -print)` | Compile Python without polluting the repo | | `node -e "const fs=require('fs');const h=fs.readFileSync('page.html','utf8');const m=h.match(/