@bike4mind/cli 0.2.29-feat-cli-websocket-streaming.18842 → 0.2.29-feat-cli-websocket-streaming.18878
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 +123 -72
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3587,6 +3587,50 @@ function isReadOnlyTool(toolName, customCategories) {
|
|
|
3587
3587
|
return getToolCategory(toolName, customCategories) !== "prompt_always";
|
|
3588
3588
|
}
|
|
3589
3589
|
|
|
3590
|
+
// src/core/skillsPrompt.ts
|
|
3591
|
+
function getSkillDisplayName(cmd) {
|
|
3592
|
+
return cmd.displayName || cmd.name;
|
|
3593
|
+
}
|
|
3594
|
+
function formatSkillEntry(cmd) {
|
|
3595
|
+
const displayName = getSkillDisplayName(cmd);
|
|
3596
|
+
const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
|
|
3597
|
+
const nameDisplay = cmd.displayName && cmd.displayName !== cmd.name ? `**${displayName}** (\`${cmd.name}\`)` : `**${cmd.name}**`;
|
|
3598
|
+
return `- ${nameDisplay}${argHint}: ${cmd.description}
|
|
3599
|
+
`;
|
|
3600
|
+
}
|
|
3601
|
+
function formatSkillGroup(heading, commands) {
|
|
3602
|
+
if (commands.length === 0) {
|
|
3603
|
+
return "";
|
|
3604
|
+
}
|
|
3605
|
+
return `
|
|
3606
|
+
### ${heading}
|
|
3607
|
+
${commands.map(formatSkillEntry).join("")}`;
|
|
3608
|
+
}
|
|
3609
|
+
function filterAIVisibleSkills(commands) {
|
|
3610
|
+
return commands.filter((cmd) => !cmd.disableModelInvocation);
|
|
3611
|
+
}
|
|
3612
|
+
function filterSkillsByAllowedList(commands, allowedSkills) {
|
|
3613
|
+
if (!allowedSkills || allowedSkills.length === 0) {
|
|
3614
|
+
return commands;
|
|
3615
|
+
}
|
|
3616
|
+
return commands.filter((cmd) => allowedSkills.includes(cmd.name));
|
|
3617
|
+
}
|
|
3618
|
+
function buildSkillsPromptSection(commands, allowedSkills) {
|
|
3619
|
+
const filteredByAllowed = filterSkillsByAllowedList(commands, allowedSkills);
|
|
3620
|
+
const visibleCommands = filterAIVisibleSkills(filteredByAllowed);
|
|
3621
|
+
if (visibleCommands.length === 0) {
|
|
3622
|
+
return "";
|
|
3623
|
+
}
|
|
3624
|
+
const projectSkills = visibleCommands.filter((c) => c.source === "project");
|
|
3625
|
+
const globalSkills = visibleCommands.filter((c) => c.source === "global");
|
|
3626
|
+
return `
|
|
3627
|
+
|
|
3628
|
+
## Available Skills
|
|
3629
|
+
|
|
3630
|
+
Use the \`skill\` tool to invoke these. Example: skill({ skill: "commit" })
|
|
3631
|
+
` + formatSkillGroup("Project Skills", projectSkills) + formatSkillGroup("Global Skills", globalSkills);
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3590
3634
|
// src/core/prompts.ts
|
|
3591
3635
|
var TOOL_GREP_SEARCH = "grep_search";
|
|
3592
3636
|
var TOOL_GLOB_FILES = "glob_files";
|
|
@@ -3597,7 +3641,38 @@ var TOOL_BASH_EXECUTE = "bash_execute";
|
|
|
3597
3641
|
var TOOL_SUBAGENT_DELEGATE = "subagent_delegate";
|
|
3598
3642
|
var TOOL_WRITE_TODOS = "write_todos";
|
|
3599
3643
|
var EXPLORE_SUBAGENT_TYPE = "explore";
|
|
3600
|
-
function buildCoreSystemPrompt(contextSection
|
|
3644
|
+
function buildCoreSystemPrompt(contextSection, config) {
|
|
3645
|
+
let projectContextSection = "";
|
|
3646
|
+
let agentDirectoryContext = "";
|
|
3647
|
+
let skillsSection = "";
|
|
3648
|
+
if (typeof contextSection === "string") {
|
|
3649
|
+
projectContextSection = contextSection;
|
|
3650
|
+
if (config) {
|
|
3651
|
+
if (config.enableSkillTool !== false && config.customCommands && config.customCommands.length > 0) {
|
|
3652
|
+
skillsSection = buildSkillsPromptSection(config.customCommands);
|
|
3653
|
+
}
|
|
3654
|
+
if (config.agentStore) {
|
|
3655
|
+
agentDirectoryContext = config.agentStore.getDirectoryContext();
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
} else if (contextSection && typeof contextSection === "object") {
|
|
3659
|
+
config = contextSection;
|
|
3660
|
+
if (config.contextContent) {
|
|
3661
|
+
projectContextSection = `
|
|
3662
|
+
|
|
3663
|
+
## Project Context
|
|
3664
|
+
|
|
3665
|
+
Follow these project-specific instructions:
|
|
3666
|
+
|
|
3667
|
+
${config.contextContent}`;
|
|
3668
|
+
}
|
|
3669
|
+
if (config.enableSkillTool !== false && config.customCommands && config.customCommands.length > 0) {
|
|
3670
|
+
skillsSection = buildSkillsPromptSection(config.customCommands);
|
|
3671
|
+
}
|
|
3672
|
+
if (config.agentStore) {
|
|
3673
|
+
agentDirectoryContext = config.agentStore.getDirectoryContext();
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3601
3676
|
return `You are an autonomous AI assistant with access to tools. Your job is to help users by taking action and solving problems proactively.
|
|
3602
3677
|
|
|
3603
3678
|
CORE BEHAVIOR:
|
|
@@ -3627,12 +3702,8 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
3627
3702
|
|
|
3628
3703
|
SUBAGENT DELEGATION:
|
|
3629
3704
|
- You have access to specialized subagents via the ${TOOL_SUBAGENT_DELEGATE} tool
|
|
3630
|
-
-
|
|
3631
|
-
* explore: Fast read-only codebase search (e.g., "find all auth files", "locate API endpoints")
|
|
3632
|
-
* plan: Break down complex tasks into actionable steps
|
|
3633
|
-
* review: Analyze code quality and identify issues
|
|
3705
|
+
- ${agentDirectoryContext ? `${agentDirectoryContext}` : ""}
|
|
3634
3706
|
- Subagents keep the main conversation clean and run faster with optimized models
|
|
3635
|
-
- Delegate when you need to search extensively or analyze code structure
|
|
3636
3707
|
|
|
3637
3708
|
CODE SEARCH BEST PRACTICES:
|
|
3638
3709
|
When searching code, follow this hierarchy for speed and efficiency:
|
|
@@ -3689,7 +3760,7 @@ EXAMPLES:
|
|
|
3689
3760
|
- "what packages installed?" \u2192 ${TOOL_GLOB_FILES} "**/package.json" \u2192 ${TOOL_FILE_READ}
|
|
3690
3761
|
- "find all components using React hooks" \u2192 ${TOOL_SUBAGENT_DELEGATE}(task="find all components using React hooks", type="explore")
|
|
3691
3762
|
|
|
3692
|
-
Remember: Use context from previous messages to understand follow-up questions.${
|
|
3763
|
+
Remember: Use context from previous messages to understand follow-up questions.${projectContextSection}${skillsSection}`;
|
|
3693
3764
|
}
|
|
3694
3765
|
|
|
3695
3766
|
// ../../b4m-core/packages/services/dist/src/referService/generateCodes.js
|
|
@@ -13943,7 +14014,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
13943
14014
|
// package.json
|
|
13944
14015
|
var package_default = {
|
|
13945
14016
|
name: "@bike4mind/cli",
|
|
13946
|
-
version: "0.2.29-feat-cli-websocket-streaming.
|
|
14017
|
+
version: "0.2.29-feat-cli-websocket-streaming.18878+661239950",
|
|
13947
14018
|
type: "module",
|
|
13948
14019
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
13949
14020
|
license: "UNLICENSED",
|
|
@@ -14053,10 +14124,10 @@ var package_default = {
|
|
|
14053
14124
|
},
|
|
14054
14125
|
devDependencies: {
|
|
14055
14126
|
"@bike4mind/agents": "0.1.0",
|
|
14056
|
-
"@bike4mind/common": "2.50.1-feat-cli-websocket-streaming.
|
|
14057
|
-
"@bike4mind/mcp": "1.29.1-feat-cli-websocket-streaming.
|
|
14058
|
-
"@bike4mind/services": "2.48.1-feat-cli-websocket-streaming.
|
|
14059
|
-
"@bike4mind/utils": "2.5.1-feat-cli-websocket-streaming.
|
|
14127
|
+
"@bike4mind/common": "2.50.1-feat-cli-websocket-streaming.18878+661239950",
|
|
14128
|
+
"@bike4mind/mcp": "1.29.1-feat-cli-websocket-streaming.18878+661239950",
|
|
14129
|
+
"@bike4mind/services": "2.48.1-feat-cli-websocket-streaming.18878+661239950",
|
|
14130
|
+
"@bike4mind/utils": "2.5.1-feat-cli-websocket-streaming.18878+661239950",
|
|
14060
14131
|
"@types/better-sqlite3": "^7.6.13",
|
|
14061
14132
|
"@types/diff": "^5.0.9",
|
|
14062
14133
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -14073,7 +14144,7 @@ var package_default = {
|
|
|
14073
14144
|
optionalDependencies: {
|
|
14074
14145
|
"@vscode/ripgrep": "^1.17.0"
|
|
14075
14146
|
},
|
|
14076
|
-
gitHead: "
|
|
14147
|
+
gitHead: "661239950fcb26f7027596b319567a19d56fb1a7"
|
|
14077
14148
|
};
|
|
14078
14149
|
|
|
14079
14150
|
// src/config/constants.ts
|
|
@@ -14310,50 +14381,6 @@ ${expandedBody}
|
|
|
14310
14381
|
};
|
|
14311
14382
|
}
|
|
14312
14383
|
|
|
14313
|
-
// src/core/skillsPrompt.ts
|
|
14314
|
-
function getSkillDisplayName(cmd) {
|
|
14315
|
-
return cmd.displayName || cmd.name;
|
|
14316
|
-
}
|
|
14317
|
-
function formatSkillEntry(cmd) {
|
|
14318
|
-
const displayName = getSkillDisplayName(cmd);
|
|
14319
|
-
const argHint = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
|
|
14320
|
-
const nameDisplay = cmd.displayName && cmd.displayName !== cmd.name ? `**${displayName}** (\`${cmd.name}\`)` : `**${cmd.name}**`;
|
|
14321
|
-
return `- ${nameDisplay}${argHint}: ${cmd.description}
|
|
14322
|
-
`;
|
|
14323
|
-
}
|
|
14324
|
-
function formatSkillGroup(heading, commands) {
|
|
14325
|
-
if (commands.length === 0) {
|
|
14326
|
-
return "";
|
|
14327
|
-
}
|
|
14328
|
-
return `
|
|
14329
|
-
### ${heading}
|
|
14330
|
-
${commands.map(formatSkillEntry).join("")}`;
|
|
14331
|
-
}
|
|
14332
|
-
function filterAIVisibleSkills(commands) {
|
|
14333
|
-
return commands.filter((cmd) => !cmd.disableModelInvocation);
|
|
14334
|
-
}
|
|
14335
|
-
function filterSkillsByAllowedList(commands, allowedSkills) {
|
|
14336
|
-
if (!allowedSkills || allowedSkills.length === 0) {
|
|
14337
|
-
return commands;
|
|
14338
|
-
}
|
|
14339
|
-
return commands.filter((cmd) => allowedSkills.includes(cmd.name));
|
|
14340
|
-
}
|
|
14341
|
-
function buildSkillsPromptSection(commands, allowedSkills) {
|
|
14342
|
-
const filteredByAllowed = filterSkillsByAllowedList(commands, allowedSkills);
|
|
14343
|
-
const visibleCommands = filterAIVisibleSkills(filteredByAllowed);
|
|
14344
|
-
if (visibleCommands.length === 0) {
|
|
14345
|
-
return "";
|
|
14346
|
-
}
|
|
14347
|
-
const projectSkills = visibleCommands.filter((c) => c.source === "project");
|
|
14348
|
-
const globalSkills = visibleCommands.filter((c) => c.source === "global");
|
|
14349
|
-
return `
|
|
14350
|
-
|
|
14351
|
-
## Available Skills
|
|
14352
|
-
|
|
14353
|
-
Use the \`skill\` tool to invoke these. Example: skill({ skill: "commit" })
|
|
14354
|
-
` + formatSkillGroup("Project Skills", projectSkills) + formatSkillGroup("Global Skills", globalSkills);
|
|
14355
|
-
}
|
|
14356
|
-
|
|
14357
14384
|
// src/agents/SubagentOrchestrator.ts
|
|
14358
14385
|
var SubagentOrchestrator = class {
|
|
14359
14386
|
constructor(deps) {
|
|
@@ -14934,6 +14961,21 @@ Describe the expected output format here.
|
|
|
14934
14961
|
}
|
|
14935
14962
|
return { builtin, global, project, total: this.agents.size };
|
|
14936
14963
|
}
|
|
14964
|
+
/**
|
|
14965
|
+
* Generates a markdown "Phone Book" of available agents and their schemas.
|
|
14966
|
+
* This MUST be injected into the System Prompt of the parent agent.
|
|
14967
|
+
*/
|
|
14968
|
+
getDirectoryContext() {
|
|
14969
|
+
if (this.agents.size === 0) {
|
|
14970
|
+
return "No sub-agents are currently available.";
|
|
14971
|
+
}
|
|
14972
|
+
let context = "Use `subagent_delegate` for complex tasks requiring specialized analysis.\n";
|
|
14973
|
+
for (const [name, def] of this.agents) {
|
|
14974
|
+
context += ` - **${name}**: ${def.description}
|
|
14975
|
+
`;
|
|
14976
|
+
}
|
|
14977
|
+
return context;
|
|
14978
|
+
}
|
|
14937
14979
|
};
|
|
14938
14980
|
|
|
14939
14981
|
// src/agents/delegateTool.ts
|
|
@@ -16227,18 +16269,12 @@ function CliApp() {
|
|
|
16227
16269
|
for (const error of contextResult.errors) {
|
|
16228
16270
|
startupLog.push(`\u26A0\uFE0F Context file error: ${error}`);
|
|
16229
16271
|
}
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
${contextResult.mergedContent}` : "";
|
|
16237
|
-
if (enableSkillTool) {
|
|
16238
|
-
const commands = state.customCommandStore.getAllCommands();
|
|
16239
|
-
contextSection += buildSkillsPromptSection(commands);
|
|
16240
|
-
}
|
|
16241
|
-
const cliSystemPrompt = buildCoreSystemPrompt(contextSection);
|
|
16272
|
+
const cliSystemPrompt = buildCoreSystemPrompt({
|
|
16273
|
+
contextContent: contextResult.mergedContent,
|
|
16274
|
+
agentStore,
|
|
16275
|
+
customCommands: state.customCommandStore.getAllCommands(),
|
|
16276
|
+
enableSkillTool
|
|
16277
|
+
});
|
|
16242
16278
|
const maxIterations = config.preferences.maxIterations === null ? 999999 : config.preferences.maxIterations;
|
|
16243
16279
|
const agent = new ReActAgent({
|
|
16244
16280
|
userId: config.userId,
|
|
@@ -16570,7 +16606,12 @@ ${contextResult.mergedContent}` : "";
|
|
|
16570
16606
|
const tokenCounter2 = getTokenCounter();
|
|
16571
16607
|
const contextWindow = tokenCounter2.getContextWindow(activeSession.model, state.availableModels);
|
|
16572
16608
|
const threshold = contextWindow * 0.8;
|
|
16573
|
-
const systemPrompt = buildCoreSystemPrompt(
|
|
16609
|
+
const systemPrompt = buildCoreSystemPrompt({
|
|
16610
|
+
contextContent: state.contextContent,
|
|
16611
|
+
agentStore: state.agentStore || void 0,
|
|
16612
|
+
customCommands: state.customCommandStore.getAllCommands(),
|
|
16613
|
+
enableSkillTool: config?.preferences.enableSkillTool !== false
|
|
16614
|
+
});
|
|
16574
16615
|
const contextUsage = tokenCounter2.countSessionTokens(activeSession, systemPrompt);
|
|
16575
16616
|
if (contextUsage.totalTokens >= threshold) {
|
|
16576
16617
|
console.log("\n\u26A0\uFE0F Context window 80% full. Auto-compacting...\n");
|
|
@@ -17488,15 +17529,21 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
17488
17529
|
}
|
|
17489
17530
|
const tokenCounter2 = getTokenCounter();
|
|
17490
17531
|
const contextWindow = tokenCounter2.getContextWindow(state.session.model, state.availableModels);
|
|
17491
|
-
const corePromptTokens = tokenCounter2.countTokens(buildCoreSystemPrompt(
|
|
17532
|
+
const corePromptTokens = tokenCounter2.countTokens(buildCoreSystemPrompt());
|
|
17492
17533
|
const projectContextTokens = state.contextContent ? tokenCounter2.countTokens(state.contextContent) : 0;
|
|
17493
17534
|
const commands = state.customCommandStore.getAllCommands();
|
|
17494
17535
|
const skillsSection = buildSkillsPromptSection(commands);
|
|
17495
17536
|
const skillsTokens = skillsSection ? tokenCounter2.countTokens(skillsSection) : 0;
|
|
17537
|
+
const agentDirectoryTokens = state.agentStore ? tokenCounter2.countTokens(state.agentStore.getDirectoryContext()) : 0;
|
|
17496
17538
|
const mcpTools = state.mcpManager?.getTools() || [];
|
|
17497
17539
|
const mcpToolsTokens = tokenCounter2.countToolSchemaTokens(mcpTools);
|
|
17498
17540
|
const mcpToolCount = state.mcpManager?.getToolCount() || [];
|
|
17499
|
-
const systemPrompt = buildCoreSystemPrompt(
|
|
17541
|
+
const systemPrompt = buildCoreSystemPrompt({
|
|
17542
|
+
contextContent: state.contextContent,
|
|
17543
|
+
agentStore: state.agentStore || void 0,
|
|
17544
|
+
customCommands: commands,
|
|
17545
|
+
enableSkillTool: state.config?.preferences.enableSkillTool !== false
|
|
17546
|
+
});
|
|
17500
17547
|
const usage = tokenCounter2.countSessionTokens(state.session, systemPrompt);
|
|
17501
17548
|
const totalWithTools = usage.totalTokens + mcpToolsTokens;
|
|
17502
17549
|
const usagePercent = totalWithTools / contextWindow * 100;
|
|
@@ -17515,6 +17562,10 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
17515
17562
|
if (commands.length > 0) {
|
|
17516
17563
|
console.log(` Skills Section: ${skillsTokens.toLocaleString()} tokens (${commands.length} skills)`);
|
|
17517
17564
|
}
|
|
17565
|
+
if (agentDirectoryTokens > 0) {
|
|
17566
|
+
const agentCount = state.agentStore?.getAgentCount() || 0;
|
|
17567
|
+
console.log(` Agent Directory: ${agentDirectoryTokens.toLocaleString()} tokens (${agentCount} agents)`);
|
|
17568
|
+
}
|
|
17518
17569
|
if (mcpTools.length > 0) {
|
|
17519
17570
|
console.log("\nMCP Tools:");
|
|
17520
17571
|
console.log(` Total: ${mcpToolsTokens.toLocaleString()} tokens (${mcpTools.length} tools)`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.29-feat-cli-websocket-streaming.
|
|
3
|
+
"version": "0.2.29-feat-cli-websocket-streaming.18878+661239950",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@bike4mind/agents": "0.1.0",
|
|
113
|
-
"@bike4mind/common": "2.50.1-feat-cli-websocket-streaming.
|
|
114
|
-
"@bike4mind/mcp": "1.29.1-feat-cli-websocket-streaming.
|
|
115
|
-
"@bike4mind/services": "2.48.1-feat-cli-websocket-streaming.
|
|
116
|
-
"@bike4mind/utils": "2.5.1-feat-cli-websocket-streaming.
|
|
113
|
+
"@bike4mind/common": "2.50.1-feat-cli-websocket-streaming.18878+661239950",
|
|
114
|
+
"@bike4mind/mcp": "1.29.1-feat-cli-websocket-streaming.18878+661239950",
|
|
115
|
+
"@bike4mind/services": "2.48.1-feat-cli-websocket-streaming.18878+661239950",
|
|
116
|
+
"@bike4mind/utils": "2.5.1-feat-cli-websocket-streaming.18878+661239950",
|
|
117
117
|
"@types/better-sqlite3": "^7.6.13",
|
|
118
118
|
"@types/diff": "^5.0.9",
|
|
119
119
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"optionalDependencies": {
|
|
131
131
|
"@vscode/ripgrep": "^1.17.0"
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "661239950fcb26f7027596b319567a19d56fb1a7"
|
|
134
134
|
}
|