blun-king-cli 9.1.200 → 9.1.202

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.
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const ERROR_MEMORY_MAX_CHARS = 2_800;
4
+
5
+ function buildCompactErrorMemoryReminder(patterns) {
6
+ const lines = [
7
+ '<error-memory-check>',
8
+ 'Vor Abschluss jede Regel pruefen; Verletzungen korrigieren oder offen benennen.',
9
+ ];
10
+
11
+ for (const pattern of patterns) {
12
+ const check = pattern.check ? ` | Pruefung: ${pattern.check}` : '';
13
+ lines.push(`${pattern.number}. ${pattern.rule}${check}`);
14
+ }
15
+
16
+ lines.push(
17
+ 'Arbeitsweise: 3-7 sichtbare Schritte; Werkzeuge proaktiv; nach zwei gleichen Fehlern Ansatz wechseln; Schritte erst nach echtem Nachweis abschliessen; nach Zielerreichung stoppen; Teilerfolg oder Scheitern mit Grund und naechstem Schritt offen melden.',
18
+ '</error-memory-check>',
19
+ );
20
+ return lines.join('\n');
21
+ }
22
+
23
+ function compactLegacyErrorMemoryReminder(text) {
24
+ const source = String(text);
25
+ if (!source.includes('<error-memory-check>') || !source.includes(' Regel: ')) return source;
26
+
27
+ const lines = source.split(/\r?\n/u);
28
+ const patterns = [];
29
+ for (let index = 0; index + 1 < lines.length; index += 1) {
30
+ const title = lines[index].match(/^\s*(\d+)\.\s+(.+)$/u);
31
+ const rule = lines[index + 1].match(/^\s*Regel:\s*(.+)$/u);
32
+ if (!title || !rule) continue;
33
+ const check = lines[index + 2]?.match(/^\s*Pruefung:\s*(.+)$/u);
34
+ patterns.push({
35
+ number: Number(title[1]),
36
+ title: title[2],
37
+ rule: rule[1],
38
+ check: check?.[1],
39
+ });
40
+ }
41
+ return patterns.length > 0 ? buildCompactErrorMemoryReminder(patterns) : source;
42
+ }
43
+
44
+ module.exports = {
45
+ ERROR_MEMORY_MAX_CHARS,
46
+ buildCompactErrorMemoryReminder,
47
+ compactLegacyErrorMemoryReminder,
48
+ };
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const LATEST_ONLY_INJECTION_VARIANTS = new Set(['mistake_md']);
3
+ const {
4
+ compactLegacyErrorMemoryReminder,
5
+ } = require('./error-memory-performance-policy.cjs');
6
+
7
+ const LATEST_ONLY_INJECTION_VARIANTS = new Set(['error-memory', 'mistake_md']);
4
8
 
5
9
  function repeatedInjectionKey(message) {
6
10
  if (message?.role !== 'user') return null;
@@ -34,7 +38,15 @@ function dedupeRepeatedInjections(history) {
34
38
  }
35
39
  if (seenTexts.has(key.text)) continue;
36
40
  seenTexts.add(key.text);
37
- kept.push(message);
41
+ if (key.variant === 'error-memory') {
42
+ const compactText = compactLegacyErrorMemoryReminder(key.text);
43
+ kept.push(compactText === key.text ? message : {
44
+ ...message,
45
+ content: [{ ...message.content[0], text: compactText }],
46
+ });
47
+ } else {
48
+ kept.push(message);
49
+ }
38
50
  }
39
51
 
40
52
  kept.reverse();
@@ -2,31 +2,41 @@
2
2
 
3
3
  const { createHash } = require('node:crypto');
4
4
 
5
- const SYSTEM_PROMPT_DIRECTORY_MAX_CHARS = 2_000;
5
+ const SYSTEM_PROMPT_DIRECTORY_MAX_CHARS = 1_000;
6
6
  const SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER =
7
7
  '... [directory overview shortened; use Glob, Grep, or Read for complete contents]';
8
+ const SYSTEM_PROMPT_DIRECTORY_TOP_LEVEL_MARKER =
9
+ '[top-level entries shown; nested contents omitted]';
8
10
 
9
11
  function boundSystemPromptDirectoryListing(value) {
10
12
  const listing = String(value ?? '');
11
13
  if (listing.length <= SYSTEM_PROMPT_DIRECTORY_MAX_CHARS) return listing;
12
14
 
15
+ const lines = listing.split(/\r?\n/u);
16
+ const hasNestedEntries = lines.some((line) => /^(?:│ | )+[├└]── /u.test(line));
17
+ const topLevelLines = lines.filter((line) => /^[├└]── /u.test(line));
18
+ const preferTopLevel = hasNestedEntries && topLevelLines.length > 0;
19
+ const candidateLines = preferTopLevel ? topLevelLines : lines;
20
+ const projectionMarker = preferTopLevel
21
+ ? `${SYSTEM_PROMPT_DIRECTORY_TOP_LEVEL_MARKER}\n`
22
+ : '';
13
23
  const contentBudget = Math.max(
14
24
  0,
15
25
  SYSTEM_PROMPT_DIRECTORY_MAX_CHARS
16
26
  - SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER.length
27
+ - projectionMarker.length
17
28
  - 1,
18
29
  );
19
- const lines = listing.split(/\r?\n/u);
20
30
  const kept = [];
21
31
  let used = 0;
22
- for (const line of lines) {
32
+ for (const line of candidateLines) {
23
33
  const added = line.length + (kept.length > 0 ? 1 : 0);
24
34
  if (used + added > contentBudget) break;
25
35
  kept.push(line);
26
36
  used += added;
27
37
  }
28
38
 
29
- return `${kept.join('\n')}\n${SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER}`;
39
+ return `${kept.join('\n')}\n${projectionMarker}${SYSTEM_PROMPT_DIRECTORY_TRUNCATED_MARKER}`;
30
40
  }
31
41
 
32
42
  function removeMarkdownSection(markdown, heading) {
package/blun.mjs CHANGED
@@ -79224,6 +79224,10 @@ var init_injector = __esmMin((() => {
79224
79224
  //#endregion
79225
79225
  //#region ../../packages/agent-core/src/agent/injection/error-memory.ts
79226
79226
  function buildErrorMemoryReminder(patterns) {
79227
+ try {
79228
+ const { buildCompactErrorMemoryReminder } = createRequire(import.meta.url)("./bin/error-memory-performance-policy.cjs");
79229
+ return buildCompactErrorMemoryReminder(patterns);
79230
+ } catch {}
79227
79231
  const lines = [];
79228
79232
  lines.push("<error-memory-check>");
79229
79233
  lines.push("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.200",
3
+ "version": "9.1.202",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {