11#!/usr/bin/env node
22
3- // This is a simple test script to verify the --tokenLog option works
3+ // This is a simple test script to verify the --tokenUsage option works
44
55import { execSync } from 'child_process' ;
66
77// Set up test environment
88const testPrompt = 'Hello, can you tell me what day it is today?' ;
99
10- // Test with different log levels
10+ // Test with different configurations
1111const testCases = [
12- { name : 'Default (debug)' , args : '--tokenLog=debug --log=debug' } ,
13- { name : 'Verbose level' , args : '--tokenLog=verbose --log=verbose' } ,
14- { name : 'Info level' , args : '--tokenLog=info --log=info' } ,
12+ { name : 'Without tokenUsage (debug level)' , args : '--log=debug' } ,
13+ { name : 'With tokenUsage flag' , args : '--tokenUsage --log=info' } ,
1514] ;
1615
17- console . log ( 'Testing --tokenLog option:\n' ) ;
16+ console . log ( 'Testing --tokenUsage option:\n' ) ;
1817
1918for ( const test of testCases ) {
2019 console . log ( `\n=== ${ test . name } ===` ) ;
2120 try {
22- // Run the CLI with tokenLog option
21+ // Run the CLI with tokenUsage option
2322 const cmd = `node --no-deprecation bin/cli.js ${ test . args } "${ testPrompt } "` ;
2423 console . log ( `Running: ${ cmd } \n` ) ;
2524
@@ -34,17 +33,12 @@ for (const test of testCases) {
3433 console . log ( '\n' ) ;
3534
3635 // Check if token usage info appears in the output
37- const hasTokenUsage = output . includes ( 'Token usage: ' ) ;
36+ const hasTokenUsage = output . includes ( '[ Token Usage ' ) ;
3837 console . log ( `Token usage info present: ${ hasTokenUsage ? '✅ Yes' : '❌ No' } ` ) ;
3938
40- // Check if cached tokens info appears in the output
41- const hasCachedTokens = output . includes ( 'cached' ) ;
42- console . log ( `Cached tokens info present: ${ hasCachedTokens ? '✅ Yes' : '❌ No' } ` ) ;
43-
44- // Check if cache hit rate appears in the output
45- const hasCacheHitRate = output . includes ( 'cache hit rate' ) ;
46- console . log ( `Cache hit rate info present: ${ hasCacheHitRate ? '✅ Yes' : '❌ No' } ` ) ;
47-
39+ // Check if token cost appears in the output
40+ const hasTokenCost = output . includes ( 'COST:' ) ;
41+ console . log ( `Token cost info present: ${ hasTokenCost ? '✅ Yes' : '❌ No' } ` ) ;
4842 } catch ( error ) {
4943 console . error ( `Error running test: ${ error . message } ` ) ;
5044 }
0 commit comments