-
-
Notifications
You must be signed in to change notification settings - Fork 430
refactor: rename five-hour terminology to session terminology #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a9b0d5c
refactor: rename FIVE_HOURS_MS to SESSION_DURATION_MS
ryoppippi 4c90d3d
refactor: rename five-hour-blocks files to session-blocks
ryoppippi 9b187a7
refactor: rename FiveHourBlock type to SessionBlock
ryoppippi 957ad36
refactor: update function names and type references
ryoppippi 459630f
refactor: update user-facing text to session terminology
ryoppippi 2d67512
fix: update test files to use session terminology
ryoppippi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| import process from 'node:process'; | ||
| import { define } from 'gunshi'; | ||
| import pc from 'picocolors'; | ||
| import { getDefaultClaudePath, loadFiveHourBlockData } from '../data-loader.ts'; | ||
| import { getDefaultClaudePath, loadSessionBlockData } from '../data-loader.ts'; | ||
| import { log, logger } from '../logger.ts'; | ||
| import { | ||
| calculateBurnRate, | ||
| filterRecentBlocks, | ||
| type FiveHourBlock, | ||
| projectBlockUsage, | ||
| } from '../five-hour-blocks.internal.ts'; | ||
| import { log, logger } from '../logger.ts'; | ||
| type SessionBlock, | ||
| } from '../session-blocks.internal.ts'; | ||
| import { sharedCommandConfig } from '../shared-args.internal.ts'; | ||
| import { formatCurrency, formatModelsDisplay, formatNumber } from '../utils.internal.ts'; | ||
| import { ResponsiveTable } from '../utils.table.ts'; | ||
|
|
@@ -19,7 +19,7 @@ const WARNING_THRESHOLD = 0.8; | |
| const COMPACT_WIDTH_THRESHOLD = 120; | ||
| const DEFAULT_TERMINAL_WIDTH = 120; | ||
|
|
||
| function formatBlockTime(block: FiveHourBlock, compact = false): string { | ||
| function formatBlockTime(block: SessionBlock, compact = false): string { | ||
| const start = compact | ||
| ? block.startTime.toLocaleString(undefined, { | ||
| month: '2-digit', | ||
|
|
@@ -91,7 +91,7 @@ function parseTokenLimit(value: string | undefined, maxFromAll: number): number | |
|
|
||
| export const blocksCommand = define({ | ||
| name: 'blocks', | ||
| description: 'Show usage report grouped by 5-hour billing blocks', | ||
| description: 'Show usage report grouped by session billing blocks', | ||
| args: { | ||
| ...sharedCommandConfig.args, | ||
| active: { | ||
|
|
@@ -118,7 +118,7 @@ export const blocksCommand = define({ | |
| logger.level = 0; | ||
| } | ||
|
|
||
| let blocks = await loadFiveHourBlockData({ | ||
| let blocks = await loadSessionBlockData({ | ||
| since: ctx.values.since, | ||
| until: ctx.values.until, | ||
| claudePath: getDefaultClaudePath(), | ||
|
|
@@ -158,13 +158,13 @@ export const blocksCommand = define({ | |
| } | ||
|
|
||
| if (ctx.values.active) { | ||
| blocks = blocks.filter((block: FiveHourBlock) => block.isActive); | ||
| blocks = blocks.filter((block: SessionBlock) => block.isActive); | ||
| if (blocks.length === 0) { | ||
| if (ctx.values.json) { | ||
| log(JSON.stringify({ blocks: [], message: 'No active block' })); | ||
| } | ||
| else { | ||
| logger.info('No active 5-hour block found.'); | ||
| logger.info('No active session block found.'); | ||
| } | ||
| process.exit(0); | ||
| } | ||
|
|
@@ -173,7 +173,7 @@ export const blocksCommand = define({ | |
| if (ctx.values.json) { | ||
| // JSON output | ||
| const jsonOutput = { | ||
| blocks: blocks.map((block: FiveHourBlock) => { | ||
| blocks: blocks.map((block: SessionBlock) => { | ||
| const burnRate = block.isActive ? calculateBurnRate(block) : null; | ||
| const projection = block.isActive ? projectBlockUsage(block) : null; | ||
|
|
||
|
|
@@ -218,15 +218,15 @@ export const blocksCommand = define({ | |
| // Table output | ||
| if (ctx.values.active && blocks.length === 1) { | ||
| // Detailed active block view | ||
| const block = blocks[0] as FiveHourBlock; | ||
| const block = blocks[0] as SessionBlock; | ||
| if (block == null) { | ||
| logger.warn('No active block found.'); | ||
| process.exit(0); | ||
| } | ||
| const burnRate = calculateBurnRate(block); | ||
| const projection = projectBlockUsage(block); | ||
|
|
||
| logger.box('Current 5-Hour Block Status'); | ||
| logger.box('Current Session Block Status'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const now = new Date(); | ||
| const elapsed = Math.round( | ||
|
|
@@ -279,7 +279,7 @@ export const blocksCommand = define({ | |
| } | ||
| else { | ||
| // Table view for multiple blocks | ||
| logger.box('Claude Code Token Usage Report - 5-Hour Blocks'); | ||
| logger.box('Claude Code Token Usage Report - Session Blocks'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // Calculate token limit if "max" is specified | ||
| const actualTokenLimit = parseTokenLimit(ctx.values.tokenLimit, maxTokensFromAll); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,8 @@ import { name, version } from '../package.json'; | |
| import { | ||
| getDefaultClaudePath, | ||
| loadDailyUsageData, | ||
| loadFiveHourBlockData, | ||
| loadMonthlyUsageData, | ||
| loadSessionBlockData, | ||
| loadSessionData, | ||
| } from './data-loader.ts'; | ||
| import { CostModes, dateSchema } from './types.internal.ts'; | ||
|
|
@@ -88,10 +88,10 @@ export function createMcpServer({ | |
|
|
||
| server.addTool({ | ||
| name: 'blocks', | ||
| description: 'Show usage report grouped by 5-hour billing blocks', | ||
| description: 'Show usage report grouped by session billing blocks', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| parameters: parametersSchema, | ||
| execute: async (args) => { | ||
| const blocksData = await loadFiveHourBlockData({ ...args, claudePath }); | ||
| const blocksData = await loadSessionBlockData({ ...args, claudePath }); | ||
| return JSON.stringify(blocksData); | ||
| }, | ||
| }); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a more detailed description to clarify what constitutes a 'session billing block'.
description: 'Show usage report grouped by session billing blocks, which represent a 5-hour period of activity'