feat: Markdown report generator (python cli.py report)#32
Open
jakduch wants to merge 4 commits into
Open
Conversation
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
7b25079 to
6045019
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 outsidecli.pyandtests/.Sample invocations:
Changes:
_period_bounds(period)and_in_range(day, start, end)incli.pybuild_report(period, db_path=None)pulls dashboard data and adds a by-tool breakdowncmd_report(period, out)CLI entry — prints to stdout, or writes to--out FILE--period 7d|30d|all(default30d)USAGE,COMMANDS, andmain()dispatchtests/test_report.py— 18 new unit tests covering period bounds, empty-DB skeleton, seeded-DB content, file-output flow, and CLI registrationChecklist
Code correctness
calcCost()calls pass 6 arguments:(model, inp, out, cache_read, cache_creation, cache_1h)`), not escaped ones (\`)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 insteadScope
dashboard.py,scanner.py,cli.py,pricing.py,cowork.py,tests/) — or I've explained below why a new file is neededNote:
tests/test_report.pyis new — required to cover the newbuild_report/cmd_reportsurface; all other changes are confined tocli.py.