Skip to content

feat: Markdown report generator (python cli.py report)#32

Open
jakduch wants to merge 4 commits into
josepe98:mainfrom
jakduch:feat/markdown-report
Open

feat: Markdown report generator (python cli.py report)#32
jakduch wants to merge 4 commits into
josepe98:mainfrom
jakduch:feat/markdown-report

Conversation

@jakduch
Copy link
Copy Markdown
Collaborator

@jakduch jakduch commented May 23, 2026

What does this add and why do you believe it belongs in this dashboard?

Adds python3 cli.py report — a Markdown usage-report generator that turns the same data the dashboard renders into a self-contained, copy-pasteable summary you can drop straight into chat, an issue, a stand-up note, or a PR description.

The existing CLI surface (today, week, stats) is great for a quick glance in the terminal, but the output is ANSI-coloured tables that don't travel — sharing them means screenshots of the dashboard or hand-typed numbers. A personal usage dashboard isn't only useful when you're looking at it; the moments that matter are the ones where you need to explain here's what my week on Claude actually cost to a teammate, a manager paying the bill, or your future self in a budget thread. Markdown is the lingua franca of those venues. One command, python cli.py report --period 7d, produces a clean section with totals, by-model and by-tool breakdowns, ready to paste. It fills the gap between the live dashboard and any asynchronous conversation about cost — no new dependencies, no new files outside cli.py and tests/.

Sample invocations:

python3 cli.py report                          # 30-day report to stdout
python3 cli.py report --period 7d                  # last week
python3 cli.py report --period all --out usage.md  # write to file

Changes:

  • New helpers _period_bounds(period) and _in_range(day, start, end) in cli.py
  • New build_report(period, db_path=None) pulls dashboard data and adds a by-tool breakdown
  • New cmd_report(period, out) CLI entry — prints to stdout, or writes to --out FILE
  • Supports --period 7d|30d|all (default 30d)
  • Graceful: a missing DB still produces a valid markdown skeleton with zeroed totals
  • Wired into USAGE, COMMANDS, and main() dispatch
  • tests/test_report.py — 18 new unit tests covering period bounds, empty-DB skeleton, seeded-DB content, file-output flow, and CLI registration

Checklist

Code correctness

  • All calcCost() calls pass 6 arguments: (model, inp, out, cache_read, cache_creation, cache_1h)
  • JavaScript template literals use bare backticks (`), not escaped ones (\`)
  • No JS variables referenced before they are defined
  • No new third-party dependencies introduced

Tests

  • python3 -m unittest discover -s tests -v — all passing (208 ran, 6 skipped)
  • python3 -m unittest tests.test_browser -v — no such module on this branch; full discover suite green instead
  • New behaviour is covered by at least one test

Scope

  • This is a single concern — one feature or fix per PR
  • Only touches existing files (dashboard.py, scanner.py, cli.py, pricing.py, cowork.py, tests/) — or I've explained below why a new file is needed

Note: tests/test_report.py is new — required to cover the new build_report / cmd_report surface; all other changes are confined to cli.py.

Adds 'python3 cli.py report' producing a self-contained Markdown
usage summary suitable for sharing or pasting into PRs/issues.

- New helpers: _period_bounds(period), _in_range(day, start, end)
- New build_report(period, db_path) — pulls dashboard data + a
  by-tool breakdown straight from the turns table
- New cmd_report(period, out) — prints to stdout or writes --out FILE
- Supports --period 7d|30d|all (default 30d)
- Graceful: missing DB still produces a valid markdown skeleton
- Wired into USAGE, COMMANDS dict, and main() dispatch
- 18 new unit tests in tests/test_report.py
@jakduch jakduch force-pushed the feat/markdown-report branch from 7b25079 to 6045019 Compare May 24, 2026 19:18
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
@josepe98 josepe98 closed this May 25, 2026
@josepe98 josepe98 reopened this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants