blun-king-cli 9.1.486 → 9.1.489

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LIESMICH.txt +28 -7
  3. package/README.md +16 -3
  4. package/agent-spine-plugin/.claude-plugin/marketplace.json +20 -0
  5. package/agent-spine-plugin/.claude-plugin/plugin.json +14 -0
  6. package/agent-spine-plugin/.codex-plugin/plugin.json +34 -0
  7. package/agent-spine-plugin/.mcp.json +8 -0
  8. package/agent-spine-plugin/CHANGELOG.md +277 -0
  9. package/agent-spine-plugin/LICENSE +186 -0
  10. package/agent-spine-plugin/README.md +342 -0
  11. package/agent-spine-plugin/assets/agentspine-banner.svg +32 -0
  12. package/agent-spine-plugin/bin/agentspine-mcp.js +4 -0
  13. package/agent-spine-plugin/bin/agentspine.js +7 -0
  14. package/agent-spine-plugin/blun.plugin.json +33 -0
  15. package/agent-spine-plugin/docs/acceptance.md +61 -0
  16. package/agent-spine-plugin/docs/architecture.md +183 -0
  17. package/agent-spine-plugin/docs/attention.md +121 -0
  18. package/agent-spine-plugin/docs/automatic-continuity.md +79 -0
  19. package/agent-spine-plugin/docs/channel-runtime.md +92 -0
  20. package/agent-spine-plugin/docs/coordination.md +138 -0
  21. package/agent-spine-plugin/docs/feed-transport.md +99 -0
  22. package/agent-spine-plugin/docs/gateway-runtime.md +109 -0
  23. package/agent-spine-plugin/docs/harness-reference.md +45 -0
  24. package/agent-spine-plugin/docs/host-integration.md +129 -0
  25. package/agent-spine-plugin/docs/https-transport.md +116 -0
  26. package/agent-spine-plugin/docs/learning.md +98 -0
  27. package/agent-spine-plugin/docs/object-transport.md +93 -0
  28. package/agent-spine-plugin/docs/peer-transport.md +88 -0
  29. package/agent-spine-plugin/docs/preservation-contract.md +53 -0
  30. package/agent-spine-plugin/docs/quality-gates.md +50 -0
  31. package/agent-spine-plugin/docs/relationships.md +67 -0
  32. package/agent-spine-plugin/docs/releasing.md +83 -0
  33. package/agent-spine-plugin/docs/roadmap.md +307 -0
  34. package/agent-spine-plugin/docs/selfstarter.md +88 -0
  35. package/agent-spine-plugin/docs/session-briefing.md +74 -0
  36. package/agent-spine-plugin/docs/shared-memory.md +259 -0
  37. package/agent-spine-plugin/docs/source-roots.md +86 -0
  38. package/agent-spine-plugin/docs/sqlite-transport.md +76 -0
  39. package/agent-spine-plugin/hooks/hooks.json +95 -0
  40. package/agent-spine-plugin/hooks/version.json +5 -0
  41. package/agent-spine-plugin/package.json +69 -0
  42. package/agent-spine-plugin/scripts/check-hosts.js +193 -0
  43. package/agent-spine-plugin/scripts/check-install.js +551 -0
  44. package/agent-spine-plugin/scripts/check-syntax.js +29 -0
  45. package/agent-spine-plugin/scripts/github-actions.js +11 -0
  46. package/agent-spine-plugin/scripts/release-check.js +127 -0
  47. package/agent-spine-plugin/scripts/run-acceptance.js +19 -0
  48. package/agent-spine-plugin/scripts/run-checks.js +46 -0
  49. package/agent-spine-plugin/scripts/run-tests-hermetic.js +73 -0
  50. package/agent-spine-plugin/skill/SKILL.md +76 -0
  51. package/agent-spine-plugin/skills/agent-spine/SKILL.md +84 -0
  52. package/agent-spine-plugin/spine-example/1-identity.md +12 -0
  53. package/agent-spine-plugin/spine-example/2-voice.md +6 -0
  54. package/agent-spine-plugin/spine-example/3-conduct.md +8 -0
  55. package/agent-spine-plugin/spine-example/4-history.md +4 -0
  56. package/agent-spine-plugin/src/cli.js +950 -0
  57. package/agent-spine-plugin/src/hook.js +646 -0
  58. package/agent-spine-plugin/src/index.js +84 -0
  59. package/agent-spine-plugin/src/lib/acceptance.js +294 -0
  60. package/agent-spine-plugin/src/lib/attention.js +755 -0
  61. package/agent-spine-plugin/src/lib/audit.js +308 -0
  62. package/agent-spine-plugin/src/lib/authentication.js +513 -0
  63. package/agent-spine-plugin/src/lib/briefing.js +305 -0
  64. package/agent-spine-plugin/src/lib/catalog.js +142 -0
  65. package/agent-spine-plugin/src/lib/channel-runtime.js +665 -0
  66. package/agent-spine-plugin/src/lib/context.js +154 -0
  67. package/agent-spine-plugin/src/lib/continuity.js +333 -0
  68. package/agent-spine-plugin/src/lib/coordination.js +577 -0
  69. package/agent-spine-plugin/src/lib/documents.js +199 -0
  70. package/agent-spine-plugin/src/lib/feed-transport.js +497 -0
  71. package/agent-spine-plugin/src/lib/filesystem-retry.js +27 -0
  72. package/agent-spine-plugin/src/lib/gateway-runtime.js +760 -0
  73. package/agent-spine-plugin/src/lib/graph.js +284 -0
  74. package/agent-spine-plugin/src/lib/https-transport.js +392 -0
  75. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +40 -0
  76. package/agent-spine-plugin/src/lib/indexed-memory.js +281 -0
  77. package/agent-spine-plugin/src/lib/learning.js +645 -0
  78. package/agent-spine-plugin/src/lib/object-transport.js +206 -0
  79. package/agent-spine-plugin/src/lib/paths.js +60 -0
  80. package/agent-spine-plugin/src/lib/peer-transport.js +283 -0
  81. package/agent-spine-plugin/src/lib/persona-runtime.js +503 -0
  82. package/agent-spine-plugin/src/lib/runtime.js +13 -0
  83. package/agent-spine-plugin/src/lib/selfstarter.js +819 -0
  84. package/agent-spine-plugin/src/lib/sharing.js +969 -0
  85. package/agent-spine-plugin/src/lib/source-roots.js +451 -0
  86. package/agent-spine-plugin/src/lib/sqlite-transport.js +501 -0
  87. package/agent-spine-plugin/src/lib/telegram-adapter.js +119 -0
  88. package/agent-spine-plugin/src/lib/voice-runtime.js +39 -0
  89. package/agent-spine-plugin/src/mcp.js +526 -0
  90. package/agent-spine-plugin/src/version.js +1 -0
  91. package/agent-spine-plugin/src/worker.js +178 -0
  92. package/bin/identity-context-policy.cjs +51 -1
  93. package/bin/launcher-runtime.js +42 -1
  94. package/bin/plugin-bootstrap.js +68 -27
  95. package/bin/repeated-user-message-projection.cjs +6 -0
  96. package/bin/turn-thinking-policy.cjs +5 -4
  97. package/bin/turn-tool-performance-policy.cjs +16 -2
  98. package/blun.mjs +187 -35
  99. package/package.json +3 -1
@@ -0,0 +1,199 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstat, opendir, readFile, realpath, stat } from "node:fs/promises";
3
+ import { basename, dirname, extname, join, relative, resolve } from "node:path";
4
+
5
+ const SKIP_DIRS = new Set([
6
+ ".git", ".hg", ".svn", ".next", ".nuxt", ".turbo", ".venv",
7
+ "build", "coverage", "dist", "node_modules", "target", "vendor"
8
+ ]);
9
+
10
+ const RULE_NAMES = new Set([
11
+ "AGENTS.md", "AGENTS.override.md", "CLAUDE.md", "CLAUDE.local.md",
12
+ "GEMINI.md", "CONSTITUTION.md", "RULES.md"
13
+ ]);
14
+
15
+ const MEMORY_NAMES = new Set(["MEMORY.md"]);
16
+ const SOUL_RE = /(^|[_-])(soul|persona|voice)([_-]|\.)/i;
17
+ const MEMORY_PATH_RE = /(^|\/)(memory|memories)(\/|$)/i;
18
+ const DOCUMENT_CONTENT = new WeakMap();
19
+
20
+ function sha256(buffer) {
21
+ return createHash("sha256").update(buffer).digest("hex");
22
+ }
23
+
24
+ function classify(relativePath) {
25
+ const name = basename(relativePath);
26
+ if (RULE_NAMES.has(name)) return { layer: "constitution", protected: true };
27
+ if (MEMORY_NAMES.has(name)) return { layer: "memory-index", protected: true };
28
+ if (SOUL_RE.test(name) || name === "SOUL.md") return { layer: "soul", protected: true };
29
+ if (MEMORY_PATH_RE.test(relativePath)) return { layer: "memory-fact", protected: true };
30
+ return { layer: "reference", protected: false };
31
+ }
32
+
33
+ function authorityFor(layer) {
34
+ if (layer === "constitution") return "host-instruction-candidate";
35
+ return "context-only";
36
+ }
37
+
38
+ function hostsFor(name) {
39
+ if (name === "AGENTS.md" || name === "AGENTS.override.md") return ["codex"];
40
+ if (name === "CLAUDE.md" || name === "CLAUDE.local.md") return ["claude"];
41
+ if (name === "GEMINI.md") return ["gemini"];
42
+ return ["generic"];
43
+ }
44
+
45
+ export function documentSnapshotContent(document) {
46
+ const value = DOCUMENT_CONTENT.get(document);
47
+ return value ? Buffer.from(value) : null;
48
+ }
49
+
50
+ export function attachDocumentSnapshot(document, buffer) {
51
+ if (buffer) DOCUMENT_CONTENT.set(document, Buffer.from(buffer));
52
+ return document;
53
+ }
54
+
55
+ export function markdownOutsideCode(text) {
56
+ let fence = null;
57
+ return String(text).split(/\r?\n/).map((line) => {
58
+ const marker = line.match(/^\s{0,3}(`{3,}|~{3,})/)?.[1] || null;
59
+ if (!fence && marker) { fence = marker[0]; return ""; }
60
+ if (fence && marker?.[0] === fence) { fence = null; return ""; }
61
+ if (fence) return "";
62
+ return line.replace(/`+[^`\n]*`+/g, "");
63
+ }).join("\n");
64
+ }
65
+
66
+ export async function indexExplicitDocuments(entries) {
67
+ const documents = [];
68
+ for (const entry of entries) {
69
+ let path;
70
+ let metadata;
71
+ let buffer;
72
+ if (entry.snapshot) {
73
+ path = entry.snapshot.path;
74
+ metadata = entry.snapshot.metadata;
75
+ buffer = Buffer.from(entry.snapshot.buffer);
76
+ if (buffer.byteLength !== metadata.bytes || sha256(buffer) !== metadata.sha256) {
77
+ throw new Error(`source snapshot integrity failed: ${entry.id}`);
78
+ }
79
+ } else {
80
+ const supplied = await lstat(entry.path);
81
+ if (supplied.isSymbolicLink() || !supplied.isFile()) throw new Error(`source is not a regular non-symlink file: ${entry.id}`);
82
+ path = await realpath(entry.path);
83
+ metadata = await lstat(path);
84
+ if (!metadata.isFile() || metadata.isSymbolicLink()) throw new Error(`source is not a regular non-symlink file: ${entry.id}`);
85
+ buffer = await readFile(path);
86
+ }
87
+ if (buffer.byteLength > (entry.maxBytes || 4 * 1024 * 1024)) throw new Error(`source exceeds its byte limit: ${entry.id}`);
88
+ const classification = classify(entry.id);
89
+ const document = {
90
+ path,
91
+ relativePath: entry.id,
92
+ name: basename(path),
93
+ ...classification,
94
+ layer: entry.layer || classification.layer,
95
+ protected: entry.protected ?? classification.protected,
96
+ authority: authorityFor(entry.layer || classification.layer),
97
+ classificationSource: "host-native-source-binding",
98
+ hosts: [entry.host],
99
+ bytes: buffer.byteLength,
100
+ modifiedAt: entry.snapshot ? metadata.modifiedAt : metadata.mtime.toISOString(),
101
+ sha256: entry.snapshot ? metadata.sha256 : sha256(buffer),
102
+ links: [],
103
+ sourceScope: entry.scope,
104
+ sourceBinding: entry.binding,
105
+ precedence: entry.precedence,
106
+ relevance: entry.relevance || null
107
+ };
108
+ attachDocumentSnapshot(document, entry.snapshot ? buffer : null);
109
+ documents.push(document);
110
+ }
111
+ return documents;
112
+ }
113
+
114
+ export function extractMarkdownLinks(text, filePath, root) {
115
+ const links = new Set();
116
+ text = markdownOutsideCode(text);
117
+ const patterns = [
118
+ /\[[^\]]*\]\(([^)]+\.md)(?:#[^)]+)?\)/gi,
119
+ /(?:^|\s)@([^\s`'\"]+\.md)(?:\s|$)/gim
120
+ ];
121
+ for (const pattern of patterns) {
122
+ for (const match of text.matchAll(pattern)) {
123
+ const raw = match[1].trim().replace(/^<|>$/g, "");
124
+ if (/^[a-z]+:/i.test(raw)) continue;
125
+ let decoded = raw;
126
+ try { decoded = decodeURIComponent(raw); } catch { /* Keep malformed URLs visible instead of failing the scan. */ }
127
+ const target = resolve(dirname(filePath), decoded);
128
+ const rel = relative(root, target).replaceAll("\\", "/");
129
+ if (!rel.startsWith("../") && rel !== "..") links.add(rel);
130
+ }
131
+ }
132
+ return [...links].sort();
133
+ }
134
+
135
+ async function walk(directory, found) {
136
+ const entries = [];
137
+ for await (const entry of await opendir(directory)) entries.push(entry);
138
+ entries.sort((a, b) => a.name.localeCompare(b.name));
139
+ for (const entry of entries) {
140
+ if (entry.isSymbolicLink()) continue;
141
+ const fullPath = join(directory, entry.name);
142
+ if (entry.isDirectory()) {
143
+ if (!SKIP_DIRS.has(entry.name)) await walk(fullPath, found);
144
+ } else if (entry.isFile() && extname(entry.name).toLowerCase() === ".md") {
145
+ found.push(fullPath);
146
+ }
147
+ }
148
+ }
149
+
150
+ export async function discoverDocuments(root) {
151
+ const files = [];
152
+ await walk(root, files);
153
+ const documents = new Array(files.length);
154
+ let cursor = 0;
155
+ async function worker() {
156
+ while (cursor < files.length) {
157
+ const index = cursor++;
158
+ const path = files[index];
159
+ const [buffer, metadata] = await Promise.all([readFile(path), stat(path)]);
160
+ const relativePath = relative(root, path).replaceAll("\\", "/");
161
+ const classification = classify(relativePath);
162
+ documents[index] = {
163
+ path,
164
+ relativePath,
165
+ name: basename(path),
166
+ ...classification,
167
+ authority: authorityFor(classification.layer),
168
+ classificationSource: "filename-and-path-hint",
169
+ hosts: hostsFor(basename(path)),
170
+ bytes: buffer.byteLength,
171
+ modifiedAt: metadata.mtime.toISOString(),
172
+ sha256: sha256(buffer),
173
+ links: extractMarkdownLinks(buffer.toString("utf8"), path, root)
174
+ };
175
+ }
176
+ }
177
+ const concurrency = Math.max(1, Math.min(16, files.length));
178
+ await Promise.all(Array.from({ length: concurrency }, () => worker()));
179
+
180
+ const byPath = new Map(documents.map((document) => [document.relativePath, document]));
181
+ const queue = documents.filter((document) => document.protected);
182
+ const visited = new Set(queue.map((document) => document.relativePath));
183
+ while (queue.length) {
184
+ const current = queue.shift();
185
+ for (const linkedPath of current.links) {
186
+ const linked = byPath.get(linkedPath);
187
+ if (linked && !visited.has(linkedPath)) {
188
+ linked.protected = true;
189
+ visited.add(linkedPath);
190
+ queue.push(linked);
191
+ }
192
+ }
193
+ }
194
+ return documents;
195
+ }
196
+
197
+ export function isRuleDocument(name) {
198
+ return RULE_NAMES.has(name);
199
+ }