@@ -142,6 +142,33 @@ function createAgentFixtureTree() {
142142 ] . join ( '\n' ) ,
143143 } ,
144144 } ,
145+ gemini : {
146+ project : {
147+ chats : {
148+ 'gemini-session.jsonl' : [
149+ JSON . stringify ( {
150+ sessionId : 'gemini-session' ,
151+ projectHash : 'project' ,
152+ startTime : '2026-01-02T00:00:00.000Z' ,
153+ } ) ,
154+ JSON . stringify ( {
155+ id : 'gemini-message' ,
156+ timestamp : '2026-01-02T00:00:00.000Z' ,
157+ type : 'gemini' ,
158+ model : 'gemini-test-model' ,
159+ tokens : {
160+ input : 110 ,
161+ output : 50 ,
162+ cached : 10 ,
163+ thoughts : 5 ,
164+ tool : 0 ,
165+ total : 165 ,
166+ } ,
167+ } ) ,
168+ ] . join ( '\n' ) ,
169+ } ,
170+ } ,
171+ } ,
145172 opencode : {
146173 storage : {
147174 message : {
@@ -401,14 +428,21 @@ describe('ccusage all-agent CLI', () => {
401428 expect . objectContaining ( {
402429 agent : 'all' ,
403430 cacheCreationTokens : 80 ,
404- cacheReadTokens : 50 ,
405- inputTokens : 500 ,
406- outputTokens : 250 ,
431+ cacheReadTokens : 60 ,
432+ inputTokens : 600 ,
433+ outputTokens : 300 ,
407434 period : '2026-01-02' ,
408- totalTokens : 870 ,
435+ totalTokens : 1035 ,
409436 } ) ,
410437 ) ;
411- expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [ 'amp' , 'claude' , 'codex' , 'opencode' , 'pi' ] ) ;
438+ expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [
439+ 'amp' ,
440+ 'claude' ,
441+ 'codex' ,
442+ 'gemini' ,
443+ 'opencode' ,
444+ 'pi' ,
445+ ] ) ;
412446 } ) ;
413447
414448 it ( 'passes agent namespace config to all-agent loaders' , async ( ) => {
@@ -444,14 +478,20 @@ describe('ccusage all-agent CLI', () => {
444478 expect . objectContaining ( {
445479 agent : 'all' ,
446480 cacheCreationTokens : 80 ,
447- cacheReadTokens : 40 ,
448- inputTokens : 400 ,
449- outputTokens : 200 ,
481+ cacheReadTokens : 50 ,
482+ inputTokens : 500 ,
483+ outputTokens : 250 ,
450484 period : '2026-01-02' ,
451- totalTokens : 720 ,
485+ totalTokens : 885 ,
452486 } ) ,
453487 ) ;
454- expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [ 'amp' , 'claude' , 'opencode' , 'pi' ] ) ;
488+ expect ( output . daily [ 0 ] ?. metadata ?. agents ) . toEqual ( [
489+ 'amp' ,
490+ 'claude' ,
491+ 'gemini' ,
492+ 'opencode' ,
493+ 'pi' ,
494+ ] ) ;
455495 } ) ;
456496
457497 it ( 'runs Codex daily JSON through the main ccusage namespace instead of the deprecated standalone wrapper' , async ( ) => {
@@ -482,6 +522,42 @@ describe('ccusage all-agent CLI', () => {
482522 ] ) ;
483523 } ) ;
484524
525+ it ( 'runs Gemini daily JSON through the main ccusage namespace' , async ( ) => {
526+ await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
527+
528+ const result = runCcusage (
529+ [ 'gemini' , 'daily' , '--offline' , '--json' , '--since' , '20260102' , '--until' , '20260102' ] ,
530+ createAgentCliEnv ( fixture . path ) ,
531+ ) ;
532+
533+ expect ( result . status ) . toBe ( 0 ) ;
534+ expect ( result . stderr ) . toBe ( '' ) ;
535+ const stdout = getStdout ( result ) . replace ( / \n $ / u, '' ) ;
536+ await mkdir ( snapshotRoot , { recursive : true } ) ;
537+ await expect ( stdout ) . toMatchFileSnapshot (
538+ path . join ( snapshotRoot , 'gemini-direct-daily-json.txt' ) ,
539+ ) ;
540+
541+ const output = JSON . parse ( stdout ) as {
542+ daily : Array < {
543+ inputTokens : number ;
544+ outputTokens : number ;
545+ cacheReadTokens : number ;
546+ totalTokens : number ;
547+ reasoningTokens ?: number ;
548+ } > ;
549+ } ;
550+ expect ( output . daily ) . toEqual ( [
551+ expect . objectContaining ( {
552+ inputTokens : 100 ,
553+ outputTokens : 50 ,
554+ cacheReadTokens : 10 ,
555+ totalTokens : 165 ,
556+ reasoningTokens : 5 ,
557+ } ) ,
558+ ] ) ;
559+ } ) ;
560+
485561 it ( 'runs Claude daily JSON through the main ccusage namespace while preserving the Claude Code optimized loader output shape' , async ( ) => {
486562 await using fixture = await createFixture ( createAgentFixtureTree ( ) ) ;
487563
@@ -643,10 +719,11 @@ describe('ccusage all-agent CLI', () => {
643719 await mkdir ( snapshotRoot , { recursive : true } ) ;
644720 await expect ( output ) . toMatchFileSnapshot ( path . join ( snapshotRoot , 'all-agent-daily-table.txt' ) ) ;
645721 expect ( output ) . toContain ( 'Coding (Agent) CLI Usage Report - Daily' ) ;
646- expect ( output ) . toContain ( 'Detected: Amp, Claude, Codex, OpenCode, pi-agent' ) ;
722+ expect ( output ) . toContain ( 'Detected: Amp, Claude, Codex, Gemini, OpenCode, pi-agent' ) ;
647723 expect ( output . match ( / 2 0 2 6 - 0 1 - 0 2 / gu) ) . toHaveLength ( 1 ) ;
648724 expect ( output ) . toContain ( 'Amp' ) ;
649725 expect ( output ) . toContain ( 'Codex' ) ;
726+ expect ( output ) . toContain ( 'Gemini' ) ;
650727 expect ( output ) . toContain ( 'OpenCode' ) ;
651728 expect ( output ) . toContain ( 'pi-agent' ) ;
652729 expect ( output ) . toContain ( '$' ) ;
0 commit comments