Add profile usage summary command#4
Conversation
shahinyanm1-work
left a comment
There was a problem hiding this comment.
Thanks for picking this up — the structure is good and the tests are a nice touch. Two things blocking the merge plus a couple of smaller notes.
Blockers
-
requestKeyincludessessionId, so when a session gets forked (claude --resume <id> --fork-session, which aimux does automatically on cross-profile attach), the original transcript and the forked one share the samerequestIdbut live under different session ids. The dedupe key treats them as two requests and double-counts the tokens. DropsessionIdfrom the key when arequestIdis present —request:<requestId>is enough. -
The walker reads every
.jsonlunderprojects/without filtering subagent transcripts. Real installs have thousands of those (classifier, memory, task-journal, etc.) — each one is a real assistant turn withmessage.usage, so they'll inflate "unknown" by a huge factor.sessionScanner.tsalready has the logic —quickFirstLineType(path) === 'queue-operation'andparseSessionJsonl(path).isSubagent. Reuse those before parsing usage lines.
Should fix before merge
-
estimatedCostUsdis summed into the summary but never shown in the table. Either add aCOSTcolumn (formatted as$X.XX) or drop the field — right now it's dead work. -
In
requestKey, the fallback when no id/uuid/requestId is found isMath.random(). That defeats the dedupe — every line gets a unique key. Either use a stable surrogate like${sessionId}:line:${index}or justcontinueand skip the line.
Nit
usage.test.tscallssetAimuxDirinbeforeEachbut never restores it. If something else in the test run depends on the default aimux dir, it'll pick up the tmpdir from this test. Save the previous value and restore inafterEach.
Happy to discuss any of these if my read of the code is off. Once 1 and 2 are sorted I'll take another pass.
Re-posting from primary maintainer account.
Shahinyanm
left a comment
There was a problem hiding this comment.
Thanks for picking this up — structure is good and the tests are a nice touch. Two things blocking the merge plus a couple of smaller notes.
Blockers
-
requestKeyincludessessionId, so when a session gets forked (claude --resume <id> --fork-session, which aimux does automatically on cross-profile attach), the original transcript and the forked one share the samerequestIdbut live under different session ids. The dedupe key treats them as two requests and double-counts the tokens. DropsessionIdfrom the key when arequestIdis present —request:<requestId>is enough. -
The walker reads every
.jsonlunderprojects/without filtering subagent transcripts. Real installs have thousands of those (classifier, memory, task-journal, etc.) — each one is a real assistant turn withmessage.usage, so they'll inflate "unknown" by a huge factor.sessionScanner.tsalready has the logic —quickFirstLineType(path) === 'queue-operation'andparseSessionJsonl(path).isSubagent. Reuse those before parsing usage lines.
Should fix before merge
-
estimatedCostUsdis summed into the summary but never shown in the table. Either add aCOSTcolumn (formatted as$X.XX) or drop the field — right now it's dead work. -
In
requestKey, the fallback when no id/uuid/requestId is found isMath.random(). That defeats the dedupe — every line gets a unique key. Either use a stable surrogate like${sessionId}:line:${index}or justcontinueand skip the line.
Nit
usage.test.tscallssetAimuxDirinbeforeEachbut never restores it. If something else in the test run depends on the default aimux dir, it'll pick up the tmpdir from this test. Save the previous value and restore inafterEach.
Happy to discuss any of these if my read is off. Once 1 and 2 are sorted I'll take another pass.
Summary
aimux usageto summarize transcript token usage by profile--profile,--since, and--allfiltersunknownNotes
This builds on the existing session attribution logic from
.claude.jsonand aimux session history. Historical shared transcripts that cannot be mapped to a profile are intentionally shown asunknownrather than guessed.Closes #1
Test plan
npm testnpm run buildnode dist/cli.js usage --since 24h