@@ -13,6 +13,12 @@ import { sharedCommandConfig } from '../shared-args.internal.ts';
1313import { formatCurrency , formatModelsDisplay , formatNumber } from '../utils.internal.ts' ;
1414import { ResponsiveTable } from '../utils.table.ts' ;
1515
16+ // Constants for configurable values
17+ const RECENT_DAYS_DEFAULT = 3 ;
18+ const WARNING_THRESHOLD = 0.8 ;
19+ const COMPACT_WIDTH_THRESHOLD = 120 ;
20+ const DEFAULT_TERMINAL_WIDTH = 120 ;
21+
1622function formatBlockTime ( block : FiveHourBlock , compact = false ) : string {
1723 const start = compact
1824 ? block . startTime . toLocaleString ( undefined , {
@@ -97,7 +103,7 @@ export const blocksCommand = define({
97103 recent : {
98104 type : 'boolean' ,
99105 short : 'r' ,
100- description : ' Show blocks from last 3 days (including active)' ,
106+ description : ` Show blocks from last ${ RECENT_DAYS_DEFAULT } days (including active)` ,
101107 default : false ,
102108 } ,
103109 tokenLimit : {
@@ -148,7 +154,7 @@ export const blocksCommand = define({
148154
149155 // Apply filters
150156 if ( ctx . values . recent ) {
151- blocks = filterRecentBlocks ( blocks , 3 ) ;
157+ blocks = filterRecentBlocks ( blocks , RECENT_DAYS_DEFAULT ) ;
152158 }
153159
154160 if ( ctx . values . active ) {
@@ -197,7 +203,7 @@ export const blocksCommand = define({
197203 percentUsed : ( projection . totalTokens / limit ) * 100 ,
198204 status : projection . totalTokens > limit
199205 ? 'exceeds'
200- : projection . totalTokens > limit * 0.8 ? 'warning' : 'ok' ,
206+ : projection . totalTokens > limit * WARNING_THRESHOLD ? 'warning' : 'ok' ,
201207 }
202208 : undefined ;
203209 } ) ( )
@@ -258,7 +264,7 @@ export const blocksCommand = define({
258264 const percentUsed = ( projection . totalTokens / limit ) * 100 ;
259265 const status = percentUsed > 100
260266 ? pc . red ( 'EXCEEDS LIMIT' )
261- : percentUsed > 80
267+ : percentUsed > WARNING_THRESHOLD * 100
262268 ? pc . yellow ( 'WARNING' )
263269 : pc . green ( 'OK' ) ;
264270
@@ -297,8 +303,8 @@ export const blocksCommand = define({
297303 } ) ;
298304
299305 // Detect if we need compact formatting
300- const terminalWidth = process . stdout . columns || 120 ;
301- const useCompactFormat = terminalWidth < 120 ;
306+ const terminalWidth = process . stdout . columns || DEFAULT_TERMINAL_WIDTH ;
307+ const useCompactFormat = terminalWidth < COMPACT_WIDTH_THRESHOLD ;
302308
303309 for ( const block of blocks ) {
304310 if ( block . isGap ?? false ) {
0 commit comments