@@ -87,7 +87,28 @@ function createAgentFixtureTree() {
8787 } ,
8888 } ,
8989 claude : {
90- projects : { } ,
90+ projects : {
91+ project : {
92+ 'session-id.jsonl' : JSON . stringify ( {
93+ timestamp : '2026-01-02T00:00:00.000Z' ,
94+ sessionId : 'claude-session' ,
95+ message : {
96+ role : 'assistant' ,
97+ id : 'claude-message' ,
98+ model : 'claude-sonnet-4-20250514' ,
99+ usage : {
100+ input_tokens : 100 ,
101+ output_tokens : 50 ,
102+ cache_creation_input_tokens : 20 ,
103+ cache_read_input_tokens : 10 ,
104+ } ,
105+ } ,
106+ requestId : 'claude-request' ,
107+ costUSD : 0.25 ,
108+ version : '1.0.0' ,
109+ } ) ,
110+ } ,
111+ } ,
91112 } ,
92113 codex : {
93114 sessions : {
@@ -374,18 +395,18 @@ describe('ccusage all-agent CLI', () => {
374395 expect ( output . daily [ 0 ] ) . toEqual (
375396 expect . objectContaining ( {
376397 agent : 'all' ,
377- cacheCreationTokens : 60 ,
378- cacheReadTokens : 40 ,
379- inputTokens : 400 ,
380- outputTokens : 200 ,
398+ cacheCreationTokens : 80 ,
399+ cacheReadTokens : 50 ,
400+ inputTokens : 500 ,
401+ outputTokens : 250 ,
381402 period : '2026-01-02' ,
382- totalTokens : 700 ,
403+ totalTokens : 880 ,
383404 } ) ,
384405 ) ;
385- expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [ 'amp' , 'codex' , 'opencode' , 'pi' ] ) ;
406+ expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [ 'amp' , 'claude' , ' codex', 'opencode' , 'pi' ] ) ;
386407 } ) ;
387408
388- it ( 'runs agent namespaces through the main ccusage command ' , async ( ) => {
409+ it ( 'runs Codex daily JSON through the main ccusage namespace instead of the deprecated standalone wrapper ' , async ( ) => {
389410 await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
390411
391412 const result = runCcusage (
@@ -413,7 +434,39 @@ describe('ccusage all-agent CLI', () => {
413434 ] ) ;
414435 } ) ;
415436
416- it ( 'passes offline mode through agent namespaces' , async ( ) => {
437+ it ( 'runs Claude daily JSON through the main ccusage namespace while preserving the Claude Code optimized loader output shape' , async ( ) => {
438+ await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
439+
440+ const result = runCcusage (
441+ [ 'claude' , '--offline' , '--json' , '--since' , '20260102' , '--until' , '20260102' ] ,
442+ createAgentCliEnv ( fixture . path ) ,
443+ ) ;
444+
445+ expect ( result . status ) . toBe ( 0 ) ;
446+ expect ( result . stderr ) . toBe ( '' ) ;
447+ const stdout = getStdout ( result ) . replace ( / \n $ / u, '' ) ;
448+ await mkdir ( snapshotRoot , { recursive : true } ) ;
449+ await expect ( stdout ) . toMatchFileSnapshot (
450+ path . join ( snapshotRoot , 'claude-direct-daily-json.txt' ) ,
451+ ) ;
452+ } ) ;
453+
454+ it ( 'runs pi-agent daily JSON through the main ccusage namespace with its agent-specific path option still available' , async ( ) => {
455+ await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
456+
457+ const result = runCcusage (
458+ [ 'pi' , '--offline' , '--json' , '--since' , '20260102' , '--until' , '20260102' ] ,
459+ createAgentCliEnv ( fixture . path ) ,
460+ ) ;
461+
462+ expect ( result . status ) . toBe ( 0 ) ;
463+ expect ( result . stderr ) . toBe ( '' ) ;
464+ const stdout = getStdout ( result ) . replace ( / \n $ / u, '' ) ;
465+ await mkdir ( snapshotRoot , { recursive : true } ) ;
466+ await expect ( stdout ) . toMatchFileSnapshot ( path . join ( snapshotRoot , 'pi-direct-daily-json.txt' ) ) ;
467+ } ) ;
468+
469+ it ( 'passes offline mode through OpenCode namespaces without fetching pricing from the network' , async ( ) => {
417470 await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
418471
419472 const result = runCcusage ( [ 'opencode' , '--offline' , '--json' ] , createAgentCliEnv ( fixture . path ) ) ;
@@ -503,7 +556,7 @@ describe('ccusage all-agent CLI', () => {
503556 await mkdir ( snapshotRoot , { recursive : true } ) ;
504557 await expect ( output ) . toMatchFileSnapshot ( path . join ( snapshotRoot , 'all-agent-daily-table.txt' ) ) ;
505558 expect ( output ) . toContain ( 'Coding Agent Usage Report - Daily' ) ;
506- expect ( output ) . toContain ( 'Detected: Amp, Codex, OpenCode, pi-agent' ) ;
559+ expect ( output ) . toContain ( 'Detected: Amp, Claude, Codex, OpenCode, pi-agent' ) ;
507560 expect ( output . match ( / 2 0 2 6 - 0 1 - 0 2 / gu) ) . toHaveLength ( 1 ) ;
508561 expect ( output ) . toContain ( 'Amp' ) ;
509562 expect ( output ) . toContain ( 'Codex' ) ;
0 commit comments