Repository navigation
feat(cli): add projects command and sessions --list - #52
Merged
Merged
Conversation
RecentActivityBuilder and SessionBlockBuilder each summed a response's tokens, split cache writes by lifetime and priced them with their own copy of the same code, and a response total was spelled out again in StatsCacheBuilder and HourlyActivityBuilder. Add ModelTokenTotals for the per-model sums and cost, and TokenUsage.TotalTokens for a response's total, and use them everywhere.
Add per-session and per-project usage. SessionUsageBuilder aggregates the transcripts by the session id on each line, across files, for a range of local days: resumed copies are counted once and stay with the original session and project folder, a streamed response is counted once, and a model filter counts only matching assistant messages. DataService exposes GetSessionUsage and GetProjectUsage, with a project text filter. aimon projects and aimon sessions --list take the date range options, --top, --sort, --project, --model and --json, default to the last 30 days, and share their flow in UsageList. sessions without --list is unchanged and rejects the list options. Remove the unused SessionParser.ParseSessionSummary and SessionSummary.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Summary
aimon projects: token usage and estimated cost per project, ordered by--sort tokens|cost|sessions|messages.aimon sessions --list: the individual sessions, ordered by--sort tokens|cost|messages|duration|start.--from/--to,--last,--month),--top,--project,--modeland--json. A table gets a Messages column when ordered by messages; the project name is shortened from the left to fit the console width.sessionswithout--listis unchanged; giving it a range,--top,--sort,--projector--modelwithout--listis an error instead of being ignored.SessionUsageBuilderaggregates the transcripts per session for a range of local days. A session is identified by the session id on each line, so one resumed across several files is a single session, copied lines are counted once and stay with the original session and project folder (transcripts are named after their session, so a line's home transcript is counted first), and a streamed response is counted once.DataService.GetSessionUsage/GetProjectUsageexpose the result.ModelTokenTotals,TokenUsage.TotalTokens) instead of being copied in each builder.SessionParser.ParseSessionSummary/SessionSummary, and corrects the staleGetSessionSummariestext in CLAUDE.md.Behaviour notes
messagescounts transcript lines (a streamed response is several), anddurationis the wall-clock span between the first and last message, idle gaps included.aimon monthexactly. The cost here prices every message exactly (including 5-minute and 1-hour cache writes), so it differs a little frommonth, which scales an all-time model mix;monthalso counts a session once per day it was active.--modelfor sessions counts only the assistant messages of matching models.Test plan
dotnet build AIUsageMonitor.slnx(no warnings)dotnet test AIUsageMonitor.slnx(388 passed)projects,sessions --list(--top,--sort,--project,--model,--json, invalid ranges and options) against real local data; tokens and messages reconcile withaimon monthfor the same days