@link-assistant/hive-mind 0.44.0 → 0.46.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 +16 -0
- package/package.json +1 -1
- package/src/claude.budget-stats.lib.mjs +50 -0
- package/src/claude.lib.mjs +5 -0
- package/src/claude.prompts.lib.mjs +1 -1
- package/src/hive.config.lib.mjs +10 -0
- package/src/hive.mjs +3 -3
- package/src/solve.config.lib.mjs +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 0.46.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a436ee4: Add --prompt-case-studies CLI option for comprehensive issue analysis. When enabled, instructs the AI to download logs, create case study documentation in ./docs/case-studies/issue-{id}/, perform deep analysis, reconstruct timeline, identify root causes, and propose solutions. Works only with --tool claude, disabled by default.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 1110e7a: Add comprehensive changeset documentation to CONTRIBUTING.md explaining how contributors should use the changesets workflow for version management and changelog generation
|
|
12
|
+
|
|
13
|
+
## 0.45.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 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.
|
|
18
|
+
|
|
3
19
|
## 0.44.0
|
|
4
20
|
|
|
5
21
|
### 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) {
|
|
@@ -145,7 +145,7 @@ Initial research.
|
|
|
145
145
|
- When you are fixing a bug, please make sure you first find the actual root cause, do as many experiments as needed.
|
|
146
146
|
- When you are fixing a bug and code does not have enough tracing/logs, add them and make sure they stay in the code, but are switched off by default.
|
|
147
147
|
- When you need latest comments on pull request (sorted newest first), use appropriate GitHub API commands.
|
|
148
|
-
- When you need latest comments on issue (sorted newest first), use appropriate GitHub API commands.${argv && argv.promptGeneralPurposeSubAgent ? '\n - When the task is big and requires processing of lots of files or folders, you should use the `general-purpose` sub agents to delegate work. Each separate file or folder can be delegated to a sub agent for more efficient processing.' : ''}
|
|
148
|
+
- When you need latest comments on issue (sorted newest first), use appropriate GitHub API commands.${argv && argv.promptGeneralPurposeSubAgent ? '\n - When the task is big and requires processing of lots of files or folders, you should use the `general-purpose` sub agents to delegate work. Each separate file or folder can be delegated to a sub agent for more efficient processing.' : ''}${argv && argv.promptCaseStudies ? `\n - When working on this issue, create a comprehensive case study in the ./docs/case-studies/issue-${issueNumber}/ directory. Download all logs and data related to the issue to the repository. Perform deep case study analysis by searching online for additional facts and data, reconstructing the timeline/sequence of events, identifying root causes of the problem, and proposing possible solutions. Include files like README.md (executive summary, problem statement, timeline, root cause), TECHNICAL_SUMMARY.md (deep technical analysis), ANALYSIS.md (detailed investigation findings), improvements.md (proposed solutions), and supporting logs/data files.` : ''}
|
|
149
149
|
|
|
150
150
|
Solution development and testing.
|
|
151
151
|
- When issue is solvable, implement code with tests.
|
package/src/hive.config.lib.mjs
CHANGED
|
@@ -251,11 +251,21 @@ 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.',
|
|
257
262
|
default: false
|
|
258
263
|
})
|
|
264
|
+
.option('prompt-case-studies', {
|
|
265
|
+
type: 'boolean',
|
|
266
|
+
description: 'Create comprehensive case study documentation for the issue including logs, analysis, timeline, root cause investigation, and proposed solutions. Organizes findings into ./docs/case-studies/issue-{id}/ directory. Only supported for --tool claude.',
|
|
267
|
+
default: false
|
|
268
|
+
})
|
|
259
269
|
.parserConfiguration({
|
|
260
270
|
'boolean-negation': true,
|
|
261
271
|
'strip-dashed': false,
|
package/src/hive.mjs
CHANGED
|
@@ -758,7 +758,7 @@ async function worker(workerId) {
|
|
|
758
758
|
const interactiveModeFlag = argv.interactiveMode ? ' --interactive-mode' : '';
|
|
759
759
|
const promptExploreSubAgentFlag = argv.promptExploreSubAgent ? ' --prompt-explore-sub-agent' : '';
|
|
760
760
|
const promptIssueReportingFlag = argv.promptIssueReporting ? ' --prompt-issue-reporting' : '';
|
|
761
|
-
|
|
761
|
+
const promptCaseStudiesFlag = argv.promptCaseStudies ? ' --prompt-case-studies' : '';
|
|
762
762
|
// Use spawn to get real-time streaming output while avoiding command-stream's automatic quote addition
|
|
763
763
|
const { spawn } = await import('child_process');
|
|
764
764
|
|
|
@@ -808,9 +808,10 @@ async function worker(workerId) {
|
|
|
808
808
|
if (argv.interactiveMode) args.push('--interactive-mode');
|
|
809
809
|
if (argv.promptExploreSubAgent) args.push('--prompt-explore-sub-agent');
|
|
810
810
|
if (argv.promptIssueReporting) args.push('--prompt-issue-reporting');
|
|
811
|
+
if (argv.promptCaseStudies) args.push('--prompt-case-studies');
|
|
811
812
|
|
|
812
813
|
// Log the actual command being executed so users can investigate/reproduce
|
|
813
|
-
const command = `${solveCommand} "${issueUrl}" --model ${argv.model}${toolFlag}${forkFlag}${autoForkFlag}${verboseFlag}${attachLogsFlag}${targetBranchFlag}${logDirFlag}${dryRunFlag}${skipToolConnectionCheckFlag}${autoContinueFlag}${thinkFlag}${promptPlanSubAgentFlag}${noSentryFlag}${watchFlag}${prefixForkNameWithOwnerNameFlag}${interactiveModeFlag}${promptExploreSubAgentFlag}${promptIssueReportingFlag}`;
|
|
814
|
+
const command = `${solveCommand} "${issueUrl}" --model ${argv.model}${toolFlag}${forkFlag}${autoForkFlag}${verboseFlag}${attachLogsFlag}${targetBranchFlag}${logDirFlag}${dryRunFlag}${skipToolConnectionCheckFlag}${autoContinueFlag}${thinkFlag}${promptPlanSubAgentFlag}${noSentryFlag}${watchFlag}${prefixForkNameWithOwnerNameFlag}${interactiveModeFlag}${promptExploreSubAgentFlag}${promptIssueReportingFlag}${promptCaseStudiesFlag}`;
|
|
814
815
|
await log(` 📋 Command: ${command}`);
|
|
815
816
|
|
|
816
817
|
let exitCode = 0;
|
|
@@ -1497,5 +1498,4 @@ try {
|
|
|
1497
1498
|
console.error('\nPlease report this issue at: https://github.com/link-assistant/hive-mind/issues');
|
|
1498
1499
|
process.exit(1);
|
|
1499
1500
|
}
|
|
1500
|
-
|
|
1501
1501
|
} // End of main execution block
|
package/src/solve.config.lib.mjs
CHANGED
|
@@ -255,11 +255,21 @@ 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.',
|
|
261
266
|
default: false
|
|
262
267
|
})
|
|
268
|
+
.option('prompt-case-studies', {
|
|
269
|
+
type: 'boolean',
|
|
270
|
+
description: 'Create comprehensive case study documentation for the issue including logs, analysis, timeline, root cause investigation, and proposed solutions. Organizes findings into ./docs/case-studies/issue-{id}/ directory. Only supported for --tool claude.',
|
|
271
|
+
default: false
|
|
272
|
+
})
|
|
263
273
|
.parserConfiguration({
|
|
264
274
|
'boolean-negation': true
|
|
265
275
|
})
|