@link-assistant/hive-mind 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/claude.budget-stats.lib.mjs +50 -0
- package/src/claude.lib.mjs +5 -0
- package/src/hive.config.lib.mjs +5 -0
- package/src/solve.config.lib.mjs +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 0.45.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 81f8da0: Add `--tokens-budget-stats` option for detailed token usage analysis. This experimental feature shows context window usage and output token usage in absolute values and ratios when using `--tool claude`. Disabled by default.
|
|
8
|
+
|
|
3
9
|
## 0.44.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Token budget statistics display module
|
|
3
|
+
// Extracted from claude.lib.mjs to maintain file line limits
|
|
4
|
+
|
|
5
|
+
import { formatNumber } from './claude.lib.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Display token budget statistics (context window usage and ratios)
|
|
9
|
+
* @param {Object} usage - Usage data for a model
|
|
10
|
+
* @param {Function} log - Logging function
|
|
11
|
+
*/
|
|
12
|
+
export const displayBudgetStats = async (usage, log) => {
|
|
13
|
+
const modelInfo = usage.modelInfo;
|
|
14
|
+
if (!modelInfo?.limit) {
|
|
15
|
+
await log('\n ⚠️ Budget stats not available (no model limits found)');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
await log('\n 📊 Token Budget Statistics:');
|
|
20
|
+
|
|
21
|
+
// Context window usage
|
|
22
|
+
if (modelInfo.limit.context) {
|
|
23
|
+
const contextLimit = modelInfo.limit.context;
|
|
24
|
+
// Input tokens include regular input + cache creation + cache read
|
|
25
|
+
const totalInputUsed = usage.inputTokens + usage.cacheCreationTokens + usage.cacheReadTokens;
|
|
26
|
+
const contextUsageRatio = totalInputUsed / contextLimit;
|
|
27
|
+
const contextUsagePercent = (contextUsageRatio * 100).toFixed(2);
|
|
28
|
+
|
|
29
|
+
await log(' Context window:');
|
|
30
|
+
await log(` Used: ${formatNumber(totalInputUsed)} tokens`);
|
|
31
|
+
await log(` Limit: ${formatNumber(contextLimit)} tokens`);
|
|
32
|
+
await log(` Ratio: ${contextUsageRatio.toFixed(4)} (${contextUsagePercent}%)`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Output tokens usage
|
|
36
|
+
if (modelInfo.limit.output) {
|
|
37
|
+
const outputLimit = modelInfo.limit.output;
|
|
38
|
+
const outputUsageRatio = usage.outputTokens / outputLimit;
|
|
39
|
+
const outputUsagePercent = (outputUsageRatio * 100).toFixed(2);
|
|
40
|
+
|
|
41
|
+
await log(' Output tokens:');
|
|
42
|
+
await log(` Used: ${formatNumber(usage.outputTokens)} tokens`);
|
|
43
|
+
await log(` Limit: ${formatNumber(outputLimit)} tokens`);
|
|
44
|
+
await log(` Ratio: ${outputUsageRatio.toFixed(4)} (${outputUsagePercent}%)`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Total session tokens (input + cache_creation + output)
|
|
48
|
+
const totalSessionTokens = usage.inputTokens + usage.cacheCreationTokens + usage.outputTokens;
|
|
49
|
+
await log(` Total session tokens: ${formatNumber(totalSessionTokens)}`);
|
|
50
|
+
};
|
package/src/claude.lib.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { reportError } from './sentry.lib.mjs';
|
|
|
13
13
|
import { timeouts, retryLimits } from './config.lib.mjs';
|
|
14
14
|
import { detectUsageLimit, formatUsageLimitMessage } from './usage-limit.lib.mjs';
|
|
15
15
|
import { createInteractiveHandler } from './interactive-mode.lib.mjs';
|
|
16
|
+
import { displayBudgetStats } from './claude.budget-stats.lib.mjs';
|
|
16
17
|
/**
|
|
17
18
|
* Format numbers with spaces as thousands separator (no commas)
|
|
18
19
|
* Per issue #667: Use spaces for thousands, . for decimals
|
|
@@ -1279,6 +1280,10 @@ export const executeClaudeCommand = async (params) => {
|
|
|
1279
1280
|
const usage = tokenUsage.modelUsage[modelId];
|
|
1280
1281
|
await log(`\n 📊 ${usage.modelName || modelId}:`);
|
|
1281
1282
|
await displayModelUsage(usage, log);
|
|
1283
|
+
// Display budget stats if flag is enabled
|
|
1284
|
+
if (argv.tokensBudgetStats && usage.modelInfo?.limit) {
|
|
1285
|
+
await displayBudgetStats(usage, log);
|
|
1286
|
+
}
|
|
1282
1287
|
}
|
|
1283
1288
|
// Show totals if multiple models were used
|
|
1284
1289
|
if (modelIds.length > 1) {
|
package/src/hive.config.lib.mjs
CHANGED
|
@@ -251,6 +251,11 @@ export const createYargsConfig = (yargsInstance) => {
|
|
|
251
251
|
description: 'Prompt AI to use general-purpose sub agents for processing large tasks with multiple files/folders. Only supported for --tool claude.',
|
|
252
252
|
default: false
|
|
253
253
|
})
|
|
254
|
+
.option('tokens-budget-stats', {
|
|
255
|
+
type: 'boolean',
|
|
256
|
+
description: '[EXPERIMENTAL] Show detailed token budget statistics including context window usage and ratios. Only supported for --tool claude.',
|
|
257
|
+
default: false
|
|
258
|
+
})
|
|
254
259
|
.option('prompt-issue-reporting', {
|
|
255
260
|
type: 'boolean',
|
|
256
261
|
description: 'Enable automatic issue creation for spotted bugs/errors not related to main task. Issues will include reproducible examples, workarounds, and fix suggestions. Works for both current and third-party repositories. Only supported for --tool claude.',
|
package/src/solve.config.lib.mjs
CHANGED
|
@@ -255,6 +255,11 @@ export const createYargsConfig = (yargsInstance) => {
|
|
|
255
255
|
description: 'Prompt AI to use general-purpose sub agents for processing large tasks with multiple files/folders. Only supported for --tool claude.',
|
|
256
256
|
default: false
|
|
257
257
|
})
|
|
258
|
+
.option('tokens-budget-stats', {
|
|
259
|
+
type: 'boolean',
|
|
260
|
+
description: '[EXPERIMENTAL] Show detailed token budget statistics including context window usage and ratios. Only supported for --tool claude.',
|
|
261
|
+
default: false
|
|
262
|
+
})
|
|
258
263
|
.option('prompt-issue-reporting', {
|
|
259
264
|
type: 'boolean',
|
|
260
265
|
description: 'Enable automatic issue creation for spotted bugs/errors not related to main task. Issues will include reproducible examples, workarounds, and fix suggestions. Works for both current and third-party repositories. Only supported for --tool claude.',
|