blun-king-cli 9.1.196 → 9.1.198
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/bin/mistake-relevance-policy.cjs +18 -0
- package/blun.mjs +10 -6
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
isLowInformationPersonalMemoryQuery,
|
|
5
|
+
} = require('./personal-memory-performance-policy.cjs');
|
|
6
|
+
|
|
3
7
|
const DEFAULT_MAX_CHARS = 3_000;
|
|
4
8
|
const DEFAULT_MAX_SECTIONS = 5;
|
|
5
9
|
const RECENT_USER_MESSAGES = 4;
|
|
@@ -41,6 +45,19 @@ function recentUserText(history, limit = RECENT_USER_MESSAGES) {
|
|
|
41
45
|
.join('\n');
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
function isLowInformationMistakeTurn(history) {
|
|
49
|
+
if (!Array.isArray(history)) return false;
|
|
50
|
+
const message = history.findLast((entry) => entry?.role === 'user');
|
|
51
|
+
if (message === undefined) return false;
|
|
52
|
+
if (typeof message.content === 'string') {
|
|
53
|
+
return isLowInformationPersonalMemoryQuery(message.content);
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(message.content)) return false;
|
|
56
|
+
const hasAttachment = message.content.some((part) => part?.type !== 'text' && part?.type !== 'think');
|
|
57
|
+
if (hasAttachment) return false;
|
|
58
|
+
return isLowInformationPersonalMemoryQuery(textFromMessage(message));
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
function splitSections(source) {
|
|
45
62
|
const text = String(source || '').replace(/\r\n?/gu, '\n').trim();
|
|
46
63
|
if (!text) return [];
|
|
@@ -178,6 +195,7 @@ module.exports = {
|
|
|
178
195
|
DEFAULT_MAX_CHARS,
|
|
179
196
|
DEFAULT_MAX_SECTIONS,
|
|
180
197
|
RECENT_USER_MESSAGES,
|
|
198
|
+
isLowInformationMistakeTurn,
|
|
181
199
|
recentUserText,
|
|
182
200
|
selectRelevantMistakeContent,
|
|
183
201
|
selectRelevantMistakeSources,
|
package/blun.mjs
CHANGED
|
@@ -231476,11 +231476,11 @@ async function readProjectMistakeSources(agent) {
|
|
|
231476
231476
|
}
|
|
231477
231477
|
return sources;
|
|
231478
231478
|
}
|
|
231479
|
-
var MistakeMdInjector, recentUserText, selectRelevantMistakeSources;
|
|
231479
|
+
var MistakeMdInjector, isLowInformationMistakeTurn, recentUserText, selectRelevantMistakeSources;
|
|
231480
231480
|
var init_mistake_md = __esmMin((() => {
|
|
231481
231481
|
init_injector();
|
|
231482
231482
|
init_mistake_md_writer();
|
|
231483
|
-
({ recentUserText, selectRelevantMistakeSources } = createRequire(import.meta.url)("./bin/mistake-relevance-policy.cjs"));
|
|
231483
|
+
({ isLowInformationMistakeTurn, recentUserText, selectRelevantMistakeSources } = createRequire(import.meta.url)("./bin/mistake-relevance-policy.cjs"));
|
|
231484
231484
|
MistakeMdInjector = class extends DynamicInjector {
|
|
231485
231485
|
injectionVariant = "mistake_md";
|
|
231486
231486
|
reserveChecked = false;
|
|
@@ -231514,6 +231514,7 @@ var init_mistake_md = __esmMin((() => {
|
|
|
231514
231514
|
}
|
|
231515
231515
|
async getInjection() {
|
|
231516
231516
|
try {
|
|
231517
|
+
if (isLowInformationMistakeTurn(this.agent.context.history)) return void 0;
|
|
231517
231518
|
const sources = await readProjectMistakeSources(this.agent);
|
|
231518
231519
|
const sharedContent = await withMistakeLock(this.mistakeDir, async () => {
|
|
231519
231520
|
try {
|
|
@@ -260296,7 +260297,7 @@ async function budgetToolResultForModel(options) {
|
|
|
260296
260297
|
return persistToolResultForModel(options, text);
|
|
260297
260298
|
}
|
|
260298
260299
|
function reusableReadSourcePath(options) {
|
|
260299
|
-
if (options.toolName !== "Read" || options.result.isError === true
|
|
260300
|
+
if (options.toolName !== "Read" || options.result.isError === true) return;
|
|
260300
260301
|
const path = options.toolArgs?.path;
|
|
260301
260302
|
if (typeof path !== "string" || path.trim().length === 0) return;
|
|
260302
260303
|
return path;
|
|
@@ -260318,7 +260319,6 @@ function referenceReadSourceForModel(options, text, outputPath) {
|
|
|
260318
260319
|
async function persistToolResultForModel(options, knownText) {
|
|
260319
260320
|
const text = knownText ?? persistableToolResultText(options.result.output);
|
|
260320
260321
|
if (text === void 0) return options.result;
|
|
260321
|
-
if (options.result.truncated === true) return options.result;
|
|
260322
260322
|
if (options.homedir === void 0) return options.result;
|
|
260323
260323
|
const outputPath = await saveToolResult({
|
|
260324
260324
|
homedir: options.homedir,
|
|
@@ -260331,7 +260331,7 @@ async function persistToolResultForModel(options, knownText) {
|
|
|
260331
260331
|
text,
|
|
260332
260332
|
previewChars: TOOL_RESULT_PREVIEW_CHARS
|
|
260333
260333
|
}));
|
|
260334
|
-
const output = renderPersistedToolResult(options.toolName, options.toolCallId, text, outputPath);
|
|
260334
|
+
const output = renderPersistedToolResult(options.toolName, options.toolCallId, text, outputPath, options.result.truncated === true);
|
|
260335
260335
|
return options.result.isError === true ? {
|
|
260336
260336
|
...options.result,
|
|
260337
260337
|
output,
|
|
@@ -260364,10 +260364,14 @@ async function saveToolResult(options, text) {
|
|
|
260364
260364
|
return;
|
|
260365
260365
|
}
|
|
260366
260366
|
}
|
|
260367
|
-
function renderPersistedToolResult(toolName, toolCallId, text, outputPath) {
|
|
260367
|
+
function renderPersistedToolResult(toolName, toolCallId, text, outputPath, toolTruncated = false) {
|
|
260368
260368
|
const lines = [
|
|
260369
260369
|
TOOL_RESULT_OFFLOAD_MARKER,
|
|
260370
260370
|
`Tool output exceeded ${String(TOOL_RESULT_MAX_CHARS)} characters; showing a preview only.`,
|
|
260371
|
+
...(toolTruncated ? [
|
|
260372
|
+
"The tool had already truncated its raw output; the complete returned result was stored.",
|
|
260373
|
+
"stored_result_scope: tool_truncated_output"
|
|
260374
|
+
] : []),
|
|
260371
260375
|
`tool_name: ${toolName}`,
|
|
260372
260376
|
`tool_call_id: ${toolCallId}`,
|
|
260373
260377
|
`output_size_chars: ${String(text.length)}`,
|