@bike4mind/cli 0.2.21-feat-cli-context-compaction.18206 → 0.2.21-feat-chat-completion-migration.18296
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/{artifactExtractor-GANN5ZGT.js → artifactExtractor-PP7R3E65.js} +1 -1
- package/dist/{chunk-4UPFBOWT.js → chunk-26XR542X.js} +2 -2
- package/dist/{chunk-3NN5PD22.js → chunk-4BFLLSR7.js} +2 -2
- package/dist/{chunk-HXWD4UGK.js → chunk-BBVPH66I.js} +1 -1
- package/dist/{chunk-QZAVSLFW.js → chunk-BITOLFV7.js} +13 -0
- package/dist/{chunk-NAIQUTDD.js → chunk-JQ45RATF.js} +2 -2
- package/dist/{chunk-CC3VKAAL.js → chunk-VFQF2JIT.js} +0 -4
- package/dist/commands/mcpCommand.js +1 -1
- package/dist/{create-EZHKFCZQ.js → create-UVWSWG56.js} +3 -3
- package/dist/index.js +29 -335
- package/dist/{llmMarkdownGenerator-L5I7ENTP.js → llmMarkdownGenerator-6RXUWUT5.js} +1 -1
- package/dist/{markdownGenerator-XVAVZGQA.js → markdownGenerator-FKQ6VE2A.js} +1 -1
- package/dist/{mementoService-C34LNDCN.js → mementoService-3ABUZ34J.js} +3 -3
- package/dist/{src-2ENQ4HWZ.js → src-2D7OKAUF.js} +2 -2
- package/dist/{src-J7E4QLQO.js → src-IUTQJO5R.js} +1 -1
- package/dist/{subtractCredits-5SDCKUXU.js → subtractCredits-WVQIB2XJ.js} +3 -3
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CurationArtifactType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BITOLFV7.js";
|
|
5
5
|
|
|
6
6
|
// ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
|
|
7
7
|
var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BadRequestError,
|
|
4
4
|
secureParameters
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BBVPH66I.js";
|
|
6
6
|
import {
|
|
7
7
|
CompletionApiUsageTransaction,
|
|
8
8
|
GenericCreditDeductTransaction,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
TextGenerationUsageTransaction,
|
|
13
13
|
TransferCreditTransaction,
|
|
14
14
|
VideoGenerationUsageTransaction
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BITOLFV7.js";
|
|
16
16
|
|
|
17
17
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
18
18
|
import { z } from "zod";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BBVPH66I.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BITOLFV7.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -2238,6 +2238,8 @@ var SettingKeySchema = z21.enum([
|
|
|
2238
2238
|
"EnableEnhancedDateTime",
|
|
2239
2239
|
"EnableHistoricalFeatures",
|
|
2240
2240
|
"EnableAstronomyFeatures",
|
|
2241
|
+
// ARCHITECTURE TRANSITION
|
|
2242
|
+
"EnableArchitectureTransition",
|
|
2241
2243
|
// STREAMING RESILIENCE SETTINGS
|
|
2242
2244
|
"EnableStreamIdleTimeout",
|
|
2243
2245
|
"StreamIdleTimeoutSeconds",
|
|
@@ -2616,6 +2618,7 @@ var API_SERVICE_GROUPS = {
|
|
|
2616
2618
|
{ key: "EnableResearchEngine", order: 8 },
|
|
2617
2619
|
{ key: "EnableReactViewer", order: 9 },
|
|
2618
2620
|
{ key: "EnableDeepResearch", order: 10 },
|
|
2621
|
+
{ key: "EnableArchitectureTransition", order: 11 },
|
|
2619
2622
|
{ key: "EnableKnowledgeBaseSearch", order: 11 },
|
|
2620
2623
|
{ key: "EnableStreamIdleTimeout", order: 12 },
|
|
2621
2624
|
{ key: "StreamIdleTimeoutSeconds", order: 13 },
|
|
@@ -3724,6 +3727,16 @@ var settingsMap = {
|
|
|
3724
3727
|
group: API_SERVICE_GROUPS.DATETIME_ASTRONOMY.id,
|
|
3725
3728
|
order: 3
|
|
3726
3729
|
}),
|
|
3730
|
+
// Architecture Transition
|
|
3731
|
+
EnableArchitectureTransition: makeBooleanSetting({
|
|
3732
|
+
key: "EnableArchitectureTransition",
|
|
3733
|
+
name: "Enable Architecture Transition",
|
|
3734
|
+
defaultValue: false,
|
|
3735
|
+
description: "Enable the transition to the new Simplified Hexagonal Architecture pattern. When enabled, new features will use the core/infra separation pattern.",
|
|
3736
|
+
category: "Experimental",
|
|
3737
|
+
group: API_SERVICE_GROUPS.EXPERIMENTAL.id,
|
|
3738
|
+
order: 11
|
|
3739
|
+
}),
|
|
3727
3740
|
// Streaming Resilience Settings
|
|
3728
3741
|
EnableStreamIdleTimeout: makeBooleanSetting({
|
|
3729
3742
|
key: "EnableStreamIdleTimeout",
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BBVPH66I.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BITOLFV7.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -38,7 +38,6 @@ var CliConfigSchema = z.object({
|
|
|
38
38
|
maxTokens: z.number(),
|
|
39
39
|
temperature: z.number(),
|
|
40
40
|
autoSave: z.boolean(),
|
|
41
|
-
autoCompact: z.boolean().optional().default(true),
|
|
42
41
|
theme: z.enum(["light", "dark"]),
|
|
43
42
|
exportFormat: z.enum(["markdown", "json"]),
|
|
44
43
|
maxIterations: z.number().nullable().default(10),
|
|
@@ -71,7 +70,6 @@ var ProjectConfigSchema = z.object({
|
|
|
71
70
|
maxTokens: z.number().optional(),
|
|
72
71
|
temperature: z.number().optional(),
|
|
73
72
|
autoSave: z.boolean().optional(),
|
|
74
|
-
autoCompact: z.boolean().optional(),
|
|
75
73
|
theme: z.enum(["light", "dark"]).optional(),
|
|
76
74
|
exportFormat: z.enum(["markdown", "json"]).optional(),
|
|
77
75
|
enableSkillTool: z.boolean().optional()
|
|
@@ -87,7 +85,6 @@ var ProjectLocalConfigSchema = z.object({
|
|
|
87
85
|
maxTokens: z.number().optional(),
|
|
88
86
|
temperature: z.number().optional(),
|
|
89
87
|
autoSave: z.boolean().optional(),
|
|
90
|
-
autoCompact: z.boolean().optional(),
|
|
91
88
|
theme: z.enum(["light", "dark"]).optional(),
|
|
92
89
|
exportFormat: z.enum(["markdown", "json"]).optional(),
|
|
93
90
|
enableSkillTool: z.boolean().optional()
|
|
@@ -115,7 +112,6 @@ var DEFAULT_CONFIG = {
|
|
|
115
112
|
maxTokens: 4096,
|
|
116
113
|
temperature: 0.7,
|
|
117
114
|
autoSave: true,
|
|
118
|
-
autoCompact: true,
|
|
119
115
|
theme: "dark",
|
|
120
116
|
exportFormat: "markdown",
|
|
121
117
|
maxIterations: 10,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createFabFile,
|
|
4
4
|
createFabFileSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-4BFLLSR7.js";
|
|
6
|
+
import "./chunk-BBVPH66I.js";
|
|
7
|
+
import "./chunk-BITOLFV7.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
createFabFile,
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
getEffectiveApiKey,
|
|
5
5
|
getOpenWeatherKey,
|
|
6
6
|
getSerperKey
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JQ45RATF.js";
|
|
8
8
|
import {
|
|
9
9
|
ConfigStore
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-VFQF2JIT.js";
|
|
11
|
+
import "./chunk-26XR542X.js";
|
|
12
|
+
import "./chunk-4BFLLSR7.js";
|
|
13
13
|
import {
|
|
14
14
|
BFLImageService,
|
|
15
15
|
BaseStorage,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
OpenAIBackend,
|
|
22
22
|
OpenAIImageService,
|
|
23
23
|
XAIImageService
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-BBVPH66I.js";
|
|
25
25
|
import {
|
|
26
26
|
AiEvents,
|
|
27
27
|
ApiKeyEvents,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
XAI_IMAGE_MODELS,
|
|
78
78
|
b4mLLMTools,
|
|
79
79
|
getMcpProviderMetadata
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-BITOLFV7.js";
|
|
81
81
|
import {
|
|
82
82
|
Logger
|
|
83
83
|
} from "./chunk-OCYRD7D6.js";
|
|
@@ -87,7 +87,7 @@ import "./chunk-BPFEGDC7.js";
|
|
|
87
87
|
import React19, { useState as useState8, useEffect as useEffect4, useCallback, useRef as useRef3 } from "react";
|
|
88
88
|
import { render, Box as Box18, Text as Text18, useApp, useInput as useInput7 } from "ink";
|
|
89
89
|
import { execSync } from "child_process";
|
|
90
|
-
import { v4 as
|
|
90
|
+
import { v4 as uuidv410 } from "uuid";
|
|
91
91
|
|
|
92
92
|
// src/components/App.tsx
|
|
93
93
|
import React13, { useState as useState4 } from "react";
|
|
@@ -628,15 +628,6 @@ var COMMANDS = [
|
|
|
628
628
|
{
|
|
629
629
|
name: "agents:reload",
|
|
630
630
|
description: "Reload agent definitions from disk"
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
name: "context",
|
|
634
|
-
description: "Show context window usage"
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
name: "compact",
|
|
638
|
-
description: "Compact conversation into new session",
|
|
639
|
-
args: "[instructions]"
|
|
640
631
|
}
|
|
641
632
|
];
|
|
642
633
|
function getAllCommandNames() {
|
|
@@ -1348,19 +1339,6 @@ function buildConfigItems(availableModels) {
|
|
|
1348
1339
|
}
|
|
1349
1340
|
})
|
|
1350
1341
|
},
|
|
1351
|
-
{
|
|
1352
|
-
key: "autoCompact",
|
|
1353
|
-
label: "Auto Compact",
|
|
1354
|
-
type: "boolean",
|
|
1355
|
-
getValue: (config) => config.preferences.autoCompact ?? true,
|
|
1356
|
-
setValue: (config, value) => ({
|
|
1357
|
-
...config,
|
|
1358
|
-
preferences: {
|
|
1359
|
-
...config.preferences,
|
|
1360
|
-
autoCompact: value
|
|
1361
|
-
}
|
|
1362
|
-
})
|
|
1363
|
-
},
|
|
1364
1342
|
{
|
|
1365
1343
|
key: "theme",
|
|
1366
1344
|
label: "Theme",
|
|
@@ -9811,6 +9789,7 @@ var QuestStartBodySchema = z138.object({
|
|
|
9811
9789
|
enableMementos: z138.boolean().optional(),
|
|
9812
9790
|
enableArtifacts: z138.boolean().optional(),
|
|
9813
9791
|
enableAgents: z138.boolean().optional(),
|
|
9792
|
+
agentIds: z138.array(z138.string()).optional(),
|
|
9814
9793
|
promptMeta: PromptMetaZodSchema,
|
|
9815
9794
|
tools: z138.array(z138.union([b4mLLMTools, z138.string()])).optional(),
|
|
9816
9795
|
mcpServers: z138.array(z138.string()).optional(),
|
|
@@ -11114,19 +11093,6 @@ async function loadContextFiles(projectDir) {
|
|
|
11114
11093
|
errors
|
|
11115
11094
|
};
|
|
11116
11095
|
}
|
|
11117
|
-
function extractCompactInstructions(contextContent) {
|
|
11118
|
-
const regex = /^#{1,2}\s*Compact\s*Instructions\s*$/im;
|
|
11119
|
-
const match = contextContent.match(regex);
|
|
11120
|
-
if (!match || match.index === void 0) {
|
|
11121
|
-
return void 0;
|
|
11122
|
-
}
|
|
11123
|
-
const startIndex = match.index + match[0].length;
|
|
11124
|
-
const remainingContent = contextContent.slice(startIndex);
|
|
11125
|
-
const nextHeadingMatch = remainingContent.match(/^#{1,2}\s+\S/m);
|
|
11126
|
-
const endIndex = nextHeadingMatch?.index ?? remainingContent.length;
|
|
11127
|
-
const content = remainingContent.slice(0, endIndex).trim();
|
|
11128
|
-
return content || void 0;
|
|
11129
|
-
}
|
|
11130
11096
|
|
|
11131
11097
|
// src/utils/formatStep.ts
|
|
11132
11098
|
var MAX_INPUT_LENGTH = 500;
|
|
@@ -11204,152 +11170,6 @@ var formatStep = (step) => {
|
|
|
11204
11170
|
return step;
|
|
11205
11171
|
};
|
|
11206
11172
|
|
|
11207
|
-
// src/utils/tokenCounter.ts
|
|
11208
|
-
import { get_encoding } from "tiktoken";
|
|
11209
|
-
var DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
11210
|
-
var TokenCounter = class {
|
|
11211
|
-
constructor() {
|
|
11212
|
-
this.encoder = null;
|
|
11213
|
-
}
|
|
11214
|
-
getEncoder() {
|
|
11215
|
-
if (!this.encoder) {
|
|
11216
|
-
this.encoder = get_encoding("cl100k_base");
|
|
11217
|
-
}
|
|
11218
|
-
return this.encoder;
|
|
11219
|
-
}
|
|
11220
|
-
/**
|
|
11221
|
-
* Count tokens in a text string
|
|
11222
|
-
*/
|
|
11223
|
-
countTokens(text) {
|
|
11224
|
-
return this.getEncoder().encode(text).length;
|
|
11225
|
-
}
|
|
11226
|
-
/**
|
|
11227
|
-
* Count tokens used in a session including system prompt
|
|
11228
|
-
*/
|
|
11229
|
-
countSessionTokens(session, systemPrompt) {
|
|
11230
|
-
const systemPromptTokens = this.countTokens(systemPrompt);
|
|
11231
|
-
const messageTokens = session.messages.reduce((sum2, msg) => sum2 + this.countTokens(msg.content), 0);
|
|
11232
|
-
return {
|
|
11233
|
-
systemPromptTokens,
|
|
11234
|
-
messageTokens,
|
|
11235
|
-
totalTokens: systemPromptTokens + messageTokens
|
|
11236
|
-
};
|
|
11237
|
-
}
|
|
11238
|
-
/**
|
|
11239
|
-
* Get context window size for a model
|
|
11240
|
-
* Falls back to DEFAULT_CONTEXT_WINDOW if model info not available
|
|
11241
|
-
*/
|
|
11242
|
-
getContextWindow(modelId, availableModels) {
|
|
11243
|
-
const model = availableModels?.find((m) => m.id === modelId);
|
|
11244
|
-
return model?.contextWindow || DEFAULT_CONTEXT_WINDOW;
|
|
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
|
-
}
|
|
11259
|
-
/**
|
|
11260
|
-
* Free encoder resources when done
|
|
11261
|
-
*/
|
|
11262
|
-
dispose() {
|
|
11263
|
-
if (this.encoder) {
|
|
11264
|
-
this.encoder.free();
|
|
11265
|
-
this.encoder = null;
|
|
11266
|
-
}
|
|
11267
|
-
}
|
|
11268
|
-
};
|
|
11269
|
-
var tokenCounter = null;
|
|
11270
|
-
function getTokenCounter() {
|
|
11271
|
-
if (!tokenCounter) {
|
|
11272
|
-
tokenCounter = new TokenCounter();
|
|
11273
|
-
}
|
|
11274
|
-
return tokenCounter;
|
|
11275
|
-
}
|
|
11276
|
-
|
|
11277
|
-
// src/utils/compaction.ts
|
|
11278
|
-
import { v4 as uuidv410 } from "uuid";
|
|
11279
|
-
function buildCompactionPrompt(messages, options = {}) {
|
|
11280
|
-
const preserveCount = (options.preserveRecentExchanges ?? 2) * 2;
|
|
11281
|
-
if (messages.length <= preserveCount) {
|
|
11282
|
-
return {
|
|
11283
|
-
prompt: "",
|
|
11284
|
-
preservedMessages: messages
|
|
11285
|
-
};
|
|
11286
|
-
}
|
|
11287
|
-
const messagesToSummarize = messages.slice(0, -preserveCount);
|
|
11288
|
-
const preservedMessages = messages.slice(-preserveCount);
|
|
11289
|
-
let prompt = `You are summarizing a conversation for context continuity. Create a concise summary that captures:
|
|
11290
|
-
|
|
11291
|
-
- Key decisions made
|
|
11292
|
-
- Important context established
|
|
11293
|
-
- Files and code discussed
|
|
11294
|
-
- Current task state
|
|
11295
|
-
- Any pending items or next steps
|
|
11296
|
-
|
|
11297
|
-
`;
|
|
11298
|
-
if (options.claudeMdInstructions) {
|
|
11299
|
-
prompt += `Project-specific compaction instructions:
|
|
11300
|
-
${options.claudeMdInstructions}
|
|
11301
|
-
|
|
11302
|
-
`;
|
|
11303
|
-
}
|
|
11304
|
-
if (options.userInstructions) {
|
|
11305
|
-
prompt += `Additional focus: ${options.userInstructions}
|
|
11306
|
-
|
|
11307
|
-
`;
|
|
11308
|
-
}
|
|
11309
|
-
prompt += `CONVERSATION TO SUMMARIZE:
|
|
11310
|
-
|
|
11311
|
-
`;
|
|
11312
|
-
const roleLabels = {
|
|
11313
|
-
user: "User",
|
|
11314
|
-
assistant: "Assistant",
|
|
11315
|
-
system: "System"
|
|
11316
|
-
};
|
|
11317
|
-
for (const msg of messagesToSummarize) {
|
|
11318
|
-
const roleLabel = roleLabels[msg.role] || "System";
|
|
11319
|
-
const content = msg.content.length > 2e3 ? msg.content.slice(0, 2e3) + "...[truncated]" : msg.content;
|
|
11320
|
-
prompt += `**${roleLabel}:** ${content}
|
|
11321
|
-
|
|
11322
|
-
`;
|
|
11323
|
-
}
|
|
11324
|
-
prompt += `
|
|
11325
|
-
Provide a concise summary (aim for 500-1000 words) that an AI assistant can use to continue this conversation with full context.`;
|
|
11326
|
-
return { prompt, preservedMessages };
|
|
11327
|
-
}
|
|
11328
|
-
function createCompactedSession(originalSession, summary, preservedMessages) {
|
|
11329
|
-
const summaryMessage = {
|
|
11330
|
-
id: uuidv410(),
|
|
11331
|
-
role: "system",
|
|
11332
|
-
content: `[Previous conversation summary]
|
|
11333
|
-
|
|
11334
|
-
${summary}`,
|
|
11335
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
11336
|
-
};
|
|
11337
|
-
return {
|
|
11338
|
-
id: uuidv410(),
|
|
11339
|
-
name: `${originalSession.name} (compacted)`,
|
|
11340
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11341
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11342
|
-
model: originalSession.model,
|
|
11343
|
-
messages: [summaryMessage, ...preservedMessages],
|
|
11344
|
-
metadata: {
|
|
11345
|
-
totalTokens: 0,
|
|
11346
|
-
totalCost: 0,
|
|
11347
|
-
toolCallCount: 0,
|
|
11348
|
-
compactedFrom: originalSession.id
|
|
11349
|
-
}
|
|
11350
|
-
};
|
|
11351
|
-
}
|
|
11352
|
-
|
|
11353
11173
|
// src/utils/argumentSubstitution.ts
|
|
11354
11174
|
function substituteArguments(template, args) {
|
|
11355
11175
|
let result = template;
|
|
@@ -12443,7 +12263,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
12443
12263
|
// package.json
|
|
12444
12264
|
var package_default = {
|
|
12445
12265
|
name: "@bike4mind/cli",
|
|
12446
|
-
version: "0.2.21-feat-
|
|
12266
|
+
version: "0.2.21-feat-chat-completion-migration.18296+aa06dcea9",
|
|
12447
12267
|
type: "module",
|
|
12448
12268
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
12449
12269
|
license: "UNLICENSED",
|
|
@@ -12550,10 +12370,10 @@ var package_default = {
|
|
|
12550
12370
|
},
|
|
12551
12371
|
devDependencies: {
|
|
12552
12372
|
"@bike4mind/agents": "0.1.0",
|
|
12553
|
-
"@bike4mind/common": "2.45.1-feat-
|
|
12554
|
-
"@bike4mind/mcp": "1.25.1-feat-
|
|
12555
|
-
"@bike4mind/services": "2.43.1-feat-
|
|
12556
|
-
"@bike4mind/utils": "2.3.1-feat-
|
|
12373
|
+
"@bike4mind/common": "2.45.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
12374
|
+
"@bike4mind/mcp": "1.25.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
12375
|
+
"@bike4mind/services": "2.43.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
12376
|
+
"@bike4mind/utils": "2.3.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
12557
12377
|
"@types/better-sqlite3": "^7.6.13",
|
|
12558
12378
|
"@types/diff": "^5.0.9",
|
|
12559
12379
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -12570,7 +12390,7 @@ var package_default = {
|
|
|
12570
12390
|
optionalDependencies: {
|
|
12571
12391
|
"@vscode/ripgrep": "^1.17.0"
|
|
12572
12392
|
},
|
|
12573
|
-
gitHead: "
|
|
12393
|
+
gitHead: "aa06dcea929891b25d596b5a0a0a2102fc35cab9"
|
|
12574
12394
|
};
|
|
12575
12395
|
|
|
12576
12396
|
// src/config/constants.ts
|
|
@@ -13397,8 +13217,7 @@ function CliApp() {
|
|
|
13397
13217
|
sessionSelector: null,
|
|
13398
13218
|
orchestrator: null,
|
|
13399
13219
|
agentStore: null,
|
|
13400
|
-
abortController: null
|
|
13401
|
-
contextContent: ""
|
|
13220
|
+
abortController: null
|
|
13402
13221
|
});
|
|
13403
13222
|
const [isInitialized, setIsInitialized] = useState8(false);
|
|
13404
13223
|
const [initError, setInitError] = useState8(null);
|
|
@@ -13512,7 +13331,7 @@ function CliApp() {
|
|
|
13512
13331
|
if (!isAuthenticated) {
|
|
13513
13332
|
console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
|
|
13514
13333
|
const minimalSession = {
|
|
13515
|
-
id:
|
|
13334
|
+
id: uuidv410(),
|
|
13516
13335
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
13517
13336
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13518
13337
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -13556,7 +13375,7 @@ function CliApp() {
|
|
|
13556
13375
|
}
|
|
13557
13376
|
llm.currentModel = modelInfo.id;
|
|
13558
13377
|
const newSession = {
|
|
13559
|
-
id:
|
|
13378
|
+
id: uuidv410(),
|
|
13560
13379
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
13561
13380
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13562
13381
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -13745,10 +13564,8 @@ ${contextResult.mergedContent}` : "";
|
|
|
13745
13564
|
// Store models for ConfigEditor
|
|
13746
13565
|
orchestrator,
|
|
13747
13566
|
// Store orchestrator for step handler updates
|
|
13748
|
-
agentStore
|
|
13567
|
+
agentStore
|
|
13749
13568
|
// Store agent store for agent management commands
|
|
13750
|
-
contextContent: contextResult.mergedContent
|
|
13751
|
-
// Store raw context for compact instructions
|
|
13752
13569
|
}));
|
|
13753
13570
|
setStoreSession(newSession);
|
|
13754
13571
|
setIsInitialized(true);
|
|
@@ -13815,13 +13632,13 @@ ${contextResult.mergedContent}` : "";
|
|
|
13815
13632
|
messageContent = multimodalMessage.content;
|
|
13816
13633
|
}
|
|
13817
13634
|
const userMessage = {
|
|
13818
|
-
id:
|
|
13635
|
+
id: uuidv410(),
|
|
13819
13636
|
role: "user",
|
|
13820
13637
|
content: userMessageContent,
|
|
13821
13638
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
13822
13639
|
};
|
|
13823
13640
|
const pendingAssistantMessage = {
|
|
13824
|
-
id:
|
|
13641
|
+
id: uuidv410(),
|
|
13825
13642
|
role: "assistant",
|
|
13826
13643
|
content: "...",
|
|
13827
13644
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -13974,37 +13791,6 @@ ${contextResult.mergedContent}` : "";
|
|
|
13974
13791
|
console.log("\u{1F4A1} Run /login to authenticate with your B4M account.\n");
|
|
13975
13792
|
return;
|
|
13976
13793
|
}
|
|
13977
|
-
const config = state.config;
|
|
13978
|
-
let activeSession = state.session;
|
|
13979
|
-
if (config?.preferences.autoCompact !== false && activeSession.messages.length >= 6) {
|
|
13980
|
-
const tokenCounter2 = getTokenCounter();
|
|
13981
|
-
const contextWindow = tokenCounter2.getContextWindow(activeSession.model, state.availableModels);
|
|
13982
|
-
const threshold = contextWindow * 0.8;
|
|
13983
|
-
const systemPrompt = buildCoreSystemPrompt(state.contextContent || "");
|
|
13984
|
-
const contextUsage = tokenCounter2.countSessionTokens(activeSession, systemPrompt);
|
|
13985
|
-
if (contextUsage.totalTokens >= threshold) {
|
|
13986
|
-
console.log("\n\u26A0\uFE0F Context window 80% full. Auto-compacting...\n");
|
|
13987
|
-
useCliStore.getState().setIsThinking(true);
|
|
13988
|
-
try {
|
|
13989
|
-
const { prompt: compactionPrompt, preservedMessages } = buildCompactionPrompt(activeSession.messages, {
|
|
13990
|
-
claudeMdInstructions: extractCompactInstructions(state.contextContent || "")
|
|
13991
|
-
});
|
|
13992
|
-
if (compactionPrompt) {
|
|
13993
|
-
const result = await state.agent.run(compactionPrompt, { maxIterations: 1 });
|
|
13994
|
-
await state.sessionStore.save(activeSession);
|
|
13995
|
-
const newSession = createCompactedSession(activeSession, result.finalAnswer, preservedMessages);
|
|
13996
|
-
await logger.initialize(newSession.id);
|
|
13997
|
-
setState((prev) => ({ ...prev, session: newSession }));
|
|
13998
|
-
setStoreSession(newSession);
|
|
13999
|
-
useCliStore.getState().clearPendingMessages();
|
|
14000
|
-
console.log("\u2705 Auto-compacted. Continuing with your message...\n");
|
|
14001
|
-
activeSession = newSession;
|
|
14002
|
-
}
|
|
14003
|
-
} finally {
|
|
14004
|
-
useCliStore.getState().setIsThinking(false);
|
|
14005
|
-
}
|
|
14006
|
-
}
|
|
14007
|
-
}
|
|
14008
13794
|
useCliStore.getState().setIsThinking(true);
|
|
14009
13795
|
const abortController = new AbortController();
|
|
14010
13796
|
setState((prev) => ({ ...prev, abortController }));
|
|
@@ -14017,13 +13803,13 @@ ${contextResult.mergedContent}` : "";
|
|
|
14017
13803
|
userMessageContent = message;
|
|
14018
13804
|
}
|
|
14019
13805
|
const userMessage = {
|
|
14020
|
-
id:
|
|
13806
|
+
id: uuidv410(),
|
|
14021
13807
|
role: "user",
|
|
14022
13808
|
content: userMessageContent,
|
|
14023
13809
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14024
13810
|
};
|
|
14025
13811
|
const pendingAssistantMessage = {
|
|
14026
|
-
id:
|
|
13812
|
+
id: uuidv410(),
|
|
14027
13813
|
role: "assistant",
|
|
14028
13814
|
content: "...",
|
|
14029
13815
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14032,14 +13818,14 @@ ${contextResult.mergedContent}` : "";
|
|
|
14032
13818
|
}
|
|
14033
13819
|
};
|
|
14034
13820
|
const sessionWithUserMessage = {
|
|
14035
|
-
...
|
|
14036
|
-
messages: [...
|
|
13821
|
+
...state.session,
|
|
13822
|
+
messages: [...state.session.messages, userMessage],
|
|
14037
13823
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
14038
13824
|
};
|
|
14039
13825
|
setState((prev) => ({ ...prev, session: sessionWithUserMessage }));
|
|
14040
13826
|
setStoreSession(sessionWithUserMessage);
|
|
14041
13827
|
useCliStore.getState().addPendingMessage(pendingAssistantMessage);
|
|
14042
|
-
const recentMessages =
|
|
13828
|
+
const recentMessages = state.session.messages.slice(-20);
|
|
14043
13829
|
const previousMessages = recentMessages.filter((msg) => msg.role === "user" || msg.role === "assistant").map((msg) => ({
|
|
14044
13830
|
role: msg.role,
|
|
14045
13831
|
content: msg.content
|
|
@@ -14091,7 +13877,7 @@ ${contextResult.mergedContent}` : "";
|
|
|
14091
13877
|
const currentSession = useCliStore.getState().session;
|
|
14092
13878
|
if (currentSession) {
|
|
14093
13879
|
const cancelMessage = {
|
|
14094
|
-
id:
|
|
13880
|
+
id: uuidv410(),
|
|
14095
13881
|
role: "assistant",
|
|
14096
13882
|
content: "\u26A0\uFE0F Operation cancelled by user",
|
|
14097
13883
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14142,13 +13928,13 @@ ${contextResult.mergedContent}` : "";
|
|
|
14142
13928
|
isError = true;
|
|
14143
13929
|
}
|
|
14144
13930
|
const userMessage = {
|
|
14145
|
-
id:
|
|
13931
|
+
id: uuidv410(),
|
|
14146
13932
|
role: "user",
|
|
14147
13933
|
content: `$ ${command}`,
|
|
14148
13934
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14149
13935
|
};
|
|
14150
13936
|
const assistantMessage = {
|
|
14151
|
-
id:
|
|
13937
|
+
id: uuidv410(),
|
|
14152
13938
|
role: "assistant",
|
|
14153
13939
|
content: isError ? `\u274C Error:
|
|
14154
13940
|
${output}` : output.trim() || "(no output)",
|
|
@@ -14591,7 +14377,7 @@ Custom Commands:
|
|
|
14591
14377
|
console.clear();
|
|
14592
14378
|
const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
|
|
14593
14379
|
const newSession = {
|
|
14594
|
-
id:
|
|
14380
|
+
id: uuidv410(),
|
|
14595
14381
|
name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
|
|
14596
14382
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14597
14383
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14774,98 +14560,6 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
14774
14560
|
}
|
|
14775
14561
|
break;
|
|
14776
14562
|
}
|
|
14777
|
-
case "context": {
|
|
14778
|
-
if (!state.session) {
|
|
14779
|
-
console.log("No active session");
|
|
14780
|
-
break;
|
|
14781
|
-
}
|
|
14782
|
-
const tokenCounter2 = getTokenCounter();
|
|
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() || [];
|
|
14792
|
-
const systemPrompt = buildCoreSystemPrompt(state.contextContent || "");
|
|
14793
|
-
const usage = tokenCounter2.countSessionTokens(state.session, systemPrompt);
|
|
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);
|
|
14799
|
-
console.log("\n\u{1F4CA} Context Usage:");
|
|
14800
|
-
console.log(`[${bar}] ${usagePercent.toFixed(1)}%`);
|
|
14801
|
-
console.log(`${(totalWithTools / 1e3).toFixed(1)}k / ${(contextWindow / 1e3).toFixed(0)}k tokens
|
|
14802
|
-
`);
|
|
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
|
-
);
|
|
14822
|
-
if (usagePercent >= 80) {
|
|
14823
|
-
console.log(`
|
|
14824
|
-
\u26A0\uFE0F Warning: Context is ${usagePercent.toFixed(0)}% full`);
|
|
14825
|
-
console.log(" Run /compact to summarize and free space");
|
|
14826
|
-
}
|
|
14827
|
-
console.log("");
|
|
14828
|
-
break;
|
|
14829
|
-
}
|
|
14830
|
-
case "compact": {
|
|
14831
|
-
if (!state.session || !state.agent) {
|
|
14832
|
-
console.log("No active session");
|
|
14833
|
-
break;
|
|
14834
|
-
}
|
|
14835
|
-
if (state.session.messages.length < 6) {
|
|
14836
|
-
console.log("Not enough messages to compact (need at least 6)");
|
|
14837
|
-
break;
|
|
14838
|
-
}
|
|
14839
|
-
const userInstructions = args.join(" ") || void 0;
|
|
14840
|
-
const { prompt: compactionPrompt, preservedMessages } = buildCompactionPrompt(state.session.messages, {
|
|
14841
|
-
userInstructions,
|
|
14842
|
-
claudeMdInstructions: extractCompactInstructions(state.contextContent || "")
|
|
14843
|
-
});
|
|
14844
|
-
if (!compactionPrompt) {
|
|
14845
|
-
console.log("Not enough messages to compact");
|
|
14846
|
-
break;
|
|
14847
|
-
}
|
|
14848
|
-
console.log("\u{1F5DC}\uFE0F Compacting conversation...\n");
|
|
14849
|
-
useCliStore.getState().setIsThinking(true);
|
|
14850
|
-
try {
|
|
14851
|
-
const result = await state.agent.run(compactionPrompt, { maxIterations: 1 });
|
|
14852
|
-
const summary = result.finalAnswer;
|
|
14853
|
-
await state.sessionStore.save(state.session);
|
|
14854
|
-
const oldSessionName = state.session.name;
|
|
14855
|
-
const newSession = createCompactedSession(state.session, summary, preservedMessages);
|
|
14856
|
-
await logger.initialize(newSession.id);
|
|
14857
|
-
setState((prev) => ({ ...prev, session: newSession }));
|
|
14858
|
-
setStoreSession(newSession);
|
|
14859
|
-
useCliStore.getState().clearPendingMessages();
|
|
14860
|
-
console.log("\u2705 Conversation compacted");
|
|
14861
|
-
console.log(`\u{1F4DD} New session: ${newSession.name}`);
|
|
14862
|
-
console.log(`\u{1F4BE} Previous session preserved: ${oldSessionName}
|
|
14863
|
-
`);
|
|
14864
|
-
} finally {
|
|
14865
|
-
useCliStore.getState().setIsThinking(false);
|
|
14866
|
-
}
|
|
14867
|
-
break;
|
|
14868
|
-
}
|
|
14869
14563
|
case "project-config": {
|
|
14870
14564
|
const projectDir = state.configStore.getProjectConfigDir();
|
|
14871
14565
|
const config = await state.configStore.get();
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findMostSimilarMemento,
|
|
4
4
|
getRelevantMementos
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-JQ45RATF.js";
|
|
6
|
+
import "./chunk-BBVPH66I.js";
|
|
7
|
+
import "./chunk-BITOLFV7.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
findMostSimilarMemento,
|
|
@@ -132,8 +132,8 @@ import {
|
|
|
132
132
|
validateMermaidSyntax,
|
|
133
133
|
warmUpSettingsCache,
|
|
134
134
|
withRetry
|
|
135
|
-
} from "./chunk-
|
|
136
|
-
import "./chunk-
|
|
135
|
+
} from "./chunk-BBVPH66I.js";
|
|
136
|
+
import "./chunk-BITOLFV7.js";
|
|
137
137
|
import {
|
|
138
138
|
Logger,
|
|
139
139
|
NotificationDeduplicator,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
SubtractCreditsSchema,
|
|
4
4
|
subtractCredits
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-26XR542X.js";
|
|
6
|
+
import "./chunk-BBVPH66I.js";
|
|
7
|
+
import "./chunk-BITOLFV7.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
SubtractCreditsSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.21-feat-
|
|
3
|
+
"version": "0.2.21-feat-chat-completion-migration.18296+aa06dcea9",
|
|
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-
|
|
111
|
-
"@bike4mind/mcp": "1.25.1-feat-
|
|
112
|
-
"@bike4mind/services": "2.43.1-feat-
|
|
113
|
-
"@bike4mind/utils": "2.3.1-feat-
|
|
110
|
+
"@bike4mind/common": "2.45.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
111
|
+
"@bike4mind/mcp": "1.25.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
112
|
+
"@bike4mind/services": "2.43.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
113
|
+
"@bike4mind/utils": "2.3.1-feat-chat-completion-migration.18296+aa06dcea9",
|
|
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": "aa06dcea929891b25d596b5a0a0a2102fc35cab9"
|
|
131
131
|
}
|