@bike4mind/cli 0.2.21-feat-cli-context-compaction.18205 → 0.2.21-feat-cli-context-compaction.18206
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/dist/index.js +52 -16
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -11243,6 +11243,19 @@ var TokenCounter = class {
|
|
|
11243
11243
|
const model = availableModels?.find((m) => m.id === modelId);
|
|
11244
11244
|
return model?.contextWindow || DEFAULT_CONTEXT_WINDOW;
|
|
11245
11245
|
}
|
|
11246
|
+
/**
|
|
11247
|
+
* Count tokens in tool schemas.
|
|
11248
|
+
* Tool schemas are sent as part of the API call and consume context.
|
|
11249
|
+
*/
|
|
11250
|
+
countToolSchemaTokens(tools2) {
|
|
11251
|
+
if (tools2.length === 0) return 0;
|
|
11252
|
+
const schemaText = tools2.map(
|
|
11253
|
+
({ toolSchema }) => `Tool: ${toolSchema.name}
|
|
11254
|
+
Description: ${toolSchema.description}
|
|
11255
|
+
Parameters: ${JSON.stringify(toolSchema.parameters)}`
|
|
11256
|
+
).join("\n\n");
|
|
11257
|
+
return this.countTokens(schemaText);
|
|
11258
|
+
}
|
|
11246
11259
|
/**
|
|
11247
11260
|
* Free encoder resources when done
|
|
11248
11261
|
*/
|
|
@@ -12430,7 +12443,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
12430
12443
|
// package.json
|
|
12431
12444
|
var package_default = {
|
|
12432
12445
|
name: "@bike4mind/cli",
|
|
12433
|
-
version: "0.2.21-feat-cli-context-compaction.
|
|
12446
|
+
version: "0.2.21-feat-cli-context-compaction.18206+8d5d112e9",
|
|
12434
12447
|
type: "module",
|
|
12435
12448
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
12436
12449
|
license: "UNLICENSED",
|
|
@@ -12537,10 +12550,10 @@ var package_default = {
|
|
|
12537
12550
|
},
|
|
12538
12551
|
devDependencies: {
|
|
12539
12552
|
"@bike4mind/agents": "0.1.0",
|
|
12540
|
-
"@bike4mind/common": "2.45.1-feat-cli-context-compaction.
|
|
12541
|
-
"@bike4mind/mcp": "1.25.1-feat-cli-context-compaction.
|
|
12542
|
-
"@bike4mind/services": "2.43.1-feat-cli-context-compaction.
|
|
12543
|
-
"@bike4mind/utils": "2.3.1-feat-cli-context-compaction.
|
|
12553
|
+
"@bike4mind/common": "2.45.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
12554
|
+
"@bike4mind/mcp": "1.25.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
12555
|
+
"@bike4mind/services": "2.43.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
12556
|
+
"@bike4mind/utils": "2.3.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
12544
12557
|
"@types/better-sqlite3": "^7.6.13",
|
|
12545
12558
|
"@types/diff": "^5.0.9",
|
|
12546
12559
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -12557,7 +12570,7 @@ var package_default = {
|
|
|
12557
12570
|
optionalDependencies: {
|
|
12558
12571
|
"@vscode/ripgrep": "^1.17.0"
|
|
12559
12572
|
},
|
|
12560
|
-
gitHead: "
|
|
12573
|
+
gitHead: "8d5d112e966582bf891f6028efbab996b7eaf5b7"
|
|
12561
12574
|
};
|
|
12562
12575
|
|
|
12563
12576
|
// src/config/constants.ts
|
|
@@ -14768,21 +14781,44 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
14768
14781
|
}
|
|
14769
14782
|
const tokenCounter2 = getTokenCounter();
|
|
14770
14783
|
const contextWindow = tokenCounter2.getContextWindow(state.session.model, state.availableModels);
|
|
14784
|
+
const corePromptTokens = tokenCounter2.countTokens(buildCoreSystemPrompt(""));
|
|
14785
|
+
const projectContextTokens = state.contextContent ? tokenCounter2.countTokens(state.contextContent) : 0;
|
|
14786
|
+
const commands = state.customCommandStore.getAllCommands();
|
|
14787
|
+
const skillsSection = buildSkillsPromptSection(commands);
|
|
14788
|
+
const skillsTokens = skillsSection ? tokenCounter2.countTokens(skillsSection) : 0;
|
|
14789
|
+
const mcpTools = state.mcpManager?.getTools() || [];
|
|
14790
|
+
const mcpToolsTokens = tokenCounter2.countToolSchemaTokens(mcpTools);
|
|
14791
|
+
const mcpToolCount = state.mcpManager?.getToolCount() || [];
|
|
14771
14792
|
const systemPrompt = buildCoreSystemPrompt(state.contextContent || "");
|
|
14772
14793
|
const usage = tokenCounter2.countSessionTokens(state.session, systemPrompt);
|
|
14773
|
-
const
|
|
14774
|
-
const
|
|
14775
|
-
const
|
|
14776
|
-
const
|
|
14777
|
-
const bar = "\u2588".repeat(filledWidth) + "\u2591".repeat(
|
|
14794
|
+
const totalWithTools = usage.totalTokens + mcpToolsTokens;
|
|
14795
|
+
const usagePercent = totalWithTools / contextWindow * 100;
|
|
14796
|
+
const BAR_WIDTH = 40;
|
|
14797
|
+
const filledWidth = Math.min(Math.round(usagePercent / 100 * BAR_WIDTH), BAR_WIDTH);
|
|
14798
|
+
const bar = "\u2588".repeat(filledWidth) + "\u2591".repeat(BAR_WIDTH - filledWidth);
|
|
14778
14799
|
console.log("\n\u{1F4CA} Context Usage:");
|
|
14779
14800
|
console.log(`[${bar}] ${usagePercent.toFixed(1)}%`);
|
|
14780
|
-
console.log(`${(
|
|
14801
|
+
console.log(`${(totalWithTools / 1e3).toFixed(1)}k / ${(contextWindow / 1e3).toFixed(0)}k tokens
|
|
14781
14802
|
`);
|
|
14782
|
-
console.log("Breakdown:");
|
|
14783
|
-
console.log(`
|
|
14784
|
-
|
|
14785
|
-
|
|
14803
|
+
console.log("System Prompt Breakdown:");
|
|
14804
|
+
console.log(` Core Instructions: ${corePromptTokens.toLocaleString()} tokens`);
|
|
14805
|
+
if (projectContextTokens > 0) {
|
|
14806
|
+
console.log(` Project Context: ${projectContextTokens.toLocaleString()} tokens (CLAUDE.md)`);
|
|
14807
|
+
}
|
|
14808
|
+
if (commands.length > 0) {
|
|
14809
|
+
console.log(` Skills Section: ${skillsTokens.toLocaleString()} tokens (${commands.length} skills)`);
|
|
14810
|
+
}
|
|
14811
|
+
if (mcpTools.length > 0) {
|
|
14812
|
+
console.log("\nMCP Tools:");
|
|
14813
|
+
console.log(` Total: ${mcpToolsTokens.toLocaleString()} tokens (${mcpTools.length} tools)`);
|
|
14814
|
+
for (const { serverName, count } of mcpToolCount) {
|
|
14815
|
+
console.log(` ${serverName}: ${count} tools`);
|
|
14816
|
+
}
|
|
14817
|
+
}
|
|
14818
|
+
console.log("\nConversation:");
|
|
14819
|
+
console.log(
|
|
14820
|
+
` Messages: ${usage.messageTokens.toLocaleString()} tokens (${state.session.messages.length} messages)`
|
|
14821
|
+
);
|
|
14786
14822
|
if (usagePercent >= 80) {
|
|
14787
14823
|
console.log(`
|
|
14788
14824
|
\u26A0\uFE0F Warning: Context is ${usagePercent.toFixed(0)}% full`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.21-feat-cli-context-compaction.
|
|
3
|
+
"version": "0.2.21-feat-cli-context-compaction.18206+8d5d112e9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@bike4mind/agents": "0.1.0",
|
|
110
|
-
"@bike4mind/common": "2.45.1-feat-cli-context-compaction.
|
|
111
|
-
"@bike4mind/mcp": "1.25.1-feat-cli-context-compaction.
|
|
112
|
-
"@bike4mind/services": "2.43.1-feat-cli-context-compaction.
|
|
113
|
-
"@bike4mind/utils": "2.3.1-feat-cli-context-compaction.
|
|
110
|
+
"@bike4mind/common": "2.45.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
111
|
+
"@bike4mind/mcp": "1.25.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
112
|
+
"@bike4mind/services": "2.43.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
113
|
+
"@bike4mind/utils": "2.3.1-feat-cli-context-compaction.18206+8d5d112e9",
|
|
114
114
|
"@types/better-sqlite3": "^7.6.13",
|
|
115
115
|
"@types/diff": "^5.0.9",
|
|
116
116
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"optionalDependencies": {
|
|
128
128
|
"@vscode/ripgrep": "^1.17.0"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "8d5d112e966582bf891f6028efbab996b7eaf5b7"
|
|
131
131
|
}
|