blun-king-cli 9.1.360 → 9.1.361

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,67 @@
1
+ 'use strict';
2
+
3
+ const CANONICAL_LATEST_DOMAINS = new Set([
4
+ 'goal', 'open_thread', 'next_trigger', 'expected_evidence',
5
+ ]);
6
+ const CONFIDENCE_MARGIN = 0.2;
7
+
8
+ function compareVariants(left, right) {
9
+ return right.maxConfidence - left.maxConfidence
10
+ || right.confirmations - left.confirmations
11
+ || right.latestOccurredAt - left.latestOccurredAt
12
+ || left.value.localeCompare(right.value);
13
+ }
14
+
15
+ function resolveCognitiveEvidenceGroup(entries) {
16
+ if (!Array.isArray(entries) || entries.length === 0) return null;
17
+ const ordered = [...entries].sort((left, right) => left.occurredAt - right.occurredAt
18
+ || left.index - right.index);
19
+ const latest = ordered.at(-1);
20
+ const distinctValues = new Set(ordered.map((item) => item.value));
21
+ if (distinctValues.size === 1) return { ...latest, revised: false, contested: false, conflict: false };
22
+ if (CANONICAL_LATEST_DOMAINS.has(latest.domain)) {
23
+ return { ...latest, revised: true, contested: false, conflict: false };
24
+ }
25
+
26
+ const variants = new Map();
27
+ for (const item of ordered) {
28
+ const variant = variants.get(item.value) ?? {
29
+ value: item.value,
30
+ maxConfidence: item.confidence,
31
+ confirmations: 0,
32
+ latestOccurredAt: item.occurredAt,
33
+ representative: item,
34
+ };
35
+ variant.confirmations += 1;
36
+ variant.latestOccurredAt = Math.max(variant.latestOccurredAt, item.occurredAt);
37
+ if (item.confidence > variant.maxConfidence
38
+ || item.confidence === variant.maxConfidence && item.occurredAt >= variant.representative.occurredAt) {
39
+ variant.maxConfidence = item.confidence;
40
+ variant.representative = item;
41
+ }
42
+ variants.set(item.value, variant);
43
+ }
44
+ const ranked = [...variants.values()].sort(compareVariants);
45
+ const strongest = ranked[0];
46
+ const runnerUp = ranked[1];
47
+ if (strongest.maxConfidence - runnerUp.maxConfidence >= CONFIDENCE_MARGIN - Number.EPSILON) {
48
+ return {
49
+ ...strongest.representative,
50
+ confidence: strongest.maxConfidence,
51
+ occurredAt: strongest.latestOccurredAt,
52
+ revised: false,
53
+ contested: true,
54
+ conflict: false,
55
+ };
56
+ }
57
+ return {
58
+ ...latest,
59
+ confidence: strongest.maxConfidence,
60
+ occurredAt: Math.max(...ranked.map((item) => item.latestOccurredAt)),
61
+ revised: false,
62
+ contested: false,
63
+ conflict: true,
64
+ };
65
+ }
66
+
67
+ module.exports = { resolveCognitiveEvidenceGroup };
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { resolveCognitiveEvidenceGroup } = require('./cognitive-effective-view.cjs');
4
+
3
5
  const FOCUS_DOMAINS = new Set(['self', 'team', 'goal', 'open_thread', 'next_trigger', 'expected_evidence']);
4
6
  const DOMAIN_WEIGHTS = new Map([
5
7
  ['goal', 60],
@@ -60,11 +62,11 @@ function buildCognitiveFocusProjection(state, { focusScopes, maxItems = 6, maxCh
60
62
  entries.sort((left, right) => left.occurredAt - right.occurredAt || left.index - right.index);
61
63
  const latest = entries.at(-1);
62
64
  if (!scopes.includes(latest.scope)) continue;
63
- const revised = entries.some((item) => item.value !== latest.value);
65
+ const effective = resolveCognitiveEvidenceGroup(entries);
66
+ if (!effective) continue;
64
67
  ranked.push({
65
- ...latest,
66
- revised,
67
- score: DOMAIN_WEIGHTS.get(latest.domain) + latest.confidence * 10,
68
+ ...effective,
69
+ score: DOMAIN_WEIGHTS.get(effective.domain) + effective.confidence * 10,
68
70
  });
69
71
  }
70
72
  ranked.sort((left, right) => right.score - left.score
@@ -72,7 +74,11 @@ function buildCognitiveFocusProjection(state, { focusScopes, maxItems = 6, maxCh
72
74
  if (ranked.length === 0) return null;
73
75
 
74
76
  const selected = ranked.slice(0, maxItems);
75
- const lines = selected.map((item) => `- ${LABELS.get(item.domain)}: ${item.value}${item.revised ? ' [revised]' : ''}`);
77
+ const lines = selected.map((item) => {
78
+ if (item.conflict) return `- Conflict: ${item.key} has incompatible evidence; verify before relying on it.`;
79
+ const marker = item.contested ? ' [contested; stronger evidence]' : item.revised ? ' [revised]' : '';
80
+ return `- ${LABELS.get(item.domain)}: ${item.value}${marker}`;
81
+ });
76
82
  while ([`Current durable focus (${lines.length} items):`, ...lines, SAFETY_LINE].join('\n').length > maxChars
77
83
  && lines.length > 0) lines.pop();
78
84
  if (lines.length === 0) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.360",
3
+ "version": "9.1.361",
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": {