blun-king-cli 9.1.564 → 9.1.566

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 (88) hide show
  1. package/LIESMICH.txt +2 -2
  2. package/README.md +1 -1
  3. package/agent-spine-plugin/.claude-plugin/marketplace.json +20 -20
  4. package/agent-spine-plugin/.claude-plugin/plugin.json +14 -14
  5. package/agent-spine-plugin/.codex-plugin/plugin.json +34 -34
  6. package/agent-spine-plugin/.mcp.json +8 -8
  7. package/agent-spine-plugin/CONTRIBUTING.md +52 -0
  8. package/agent-spine-plugin/LICENSE +186 -186
  9. package/agent-spine-plugin/README.md +406 -0
  10. package/agent-spine-plugin/SECURITY.md +47 -0
  11. package/agent-spine-plugin/assets/agentspine-banner.svg +32 -32
  12. package/agent-spine-plugin/bin/agentspine-mcp.js +4 -4
  13. package/agent-spine-plugin/bin/agentspine.js +7 -7
  14. package/agent-spine-plugin/blun.plugin.json +33 -33
  15. package/agent-spine-plugin/hooks/codex.json +47 -47
  16. package/agent-spine-plugin/hooks/hooks.json +106 -106
  17. package/agent-spine-plugin/hooks/version.json +5 -5
  18. package/agent-spine-plugin/package.json +69 -69
  19. package/agent-spine-plugin/scripts/check-hosts.js +199 -199
  20. package/agent-spine-plugin/skill/SKILL.md +76 -76
  21. package/agent-spine-plugin/skills/agent-spine/SKILL.md +85 -85
  22. package/agent-spine-plugin/src/cli.js +1488 -1442
  23. package/agent-spine-plugin/src/hook.js +882 -861
  24. package/agent-spine-plugin/src/index.js +94 -93
  25. package/agent-spine-plugin/src/lib/acceptance.js +333 -333
  26. package/agent-spine-plugin/src/lib/attention.js +755 -755
  27. package/agent-spine-plugin/src/lib/audit.js +351 -342
  28. package/agent-spine-plugin/src/lib/authentication.js +515 -515
  29. package/agent-spine-plugin/src/lib/briefing.js +317 -317
  30. package/agent-spine-plugin/src/lib/catalog.js +167 -167
  31. package/agent-spine-plugin/src/lib/channel-runtime.js +665 -665
  32. package/agent-spine-plugin/src/lib/context.js +154 -154
  33. package/agent-spine-plugin/src/lib/continuity.js +338 -338
  34. package/agent-spine-plugin/src/lib/coordination.js +577 -577
  35. package/agent-spine-plugin/src/lib/documents.js +217 -217
  36. package/agent-spine-plugin/src/lib/feed-transport.js +499 -499
  37. package/agent-spine-plugin/src/lib/filesystem-retry.js +32 -32
  38. package/agent-spine-plugin/src/lib/gateway-runtime.js +1623 -760
  39. package/agent-spine-plugin/src/lib/graph.js +337 -337
  40. package/agent-spine-plugin/src/lib/hook-audit.js +29 -29
  41. package/agent-spine-plugin/src/lib/https-transport.js +392 -392
  42. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +40 -40
  43. package/agent-spine-plugin/src/lib/indexed-memory.js +281 -281
  44. package/agent-spine-plugin/src/lib/learning.js +6923 -6466
  45. package/agent-spine-plugin/src/lib/object-transport.js +206 -206
  46. package/agent-spine-plugin/src/lib/owned-file-lock.js +143 -143
  47. package/agent-spine-plugin/src/lib/paths.js +109 -109
  48. package/agent-spine-plugin/src/lib/peer-transport.js +283 -283
  49. package/agent-spine-plugin/src/lib/persona-runtime.js +581 -581
  50. package/agent-spine-plugin/src/lib/preflight.js +702 -702
  51. package/agent-spine-plugin/src/lib/runtime.js +13 -13
  52. package/agent-spine-plugin/src/lib/selfstarter.js +911 -866
  53. package/agent-spine-plugin/src/lib/sharing.js +969 -969
  54. package/agent-spine-plugin/src/lib/source-roots.js +530 -498
  55. package/agent-spine-plugin/src/lib/sqlite-transport.js +501 -501
  56. package/agent-spine-plugin/src/lib/telegram-adapter.js +119 -119
  57. package/agent-spine-plugin/src/lib/voice-runtime.js +39 -39
  58. package/agent-spine-plugin/src/mcp.js +597 -572
  59. package/agent-spine-plugin/src/version.js +1 -1
  60. package/agent-spine-plugin/src/worker.js +210 -195
  61. package/bin/active-steer-priority-policy.cjs +24 -0
  62. package/bin/launcher-runtime.js +8 -1
  63. package/bin/mnemo-tool-agent-policy.cjs +22 -0
  64. package/bin/native-runtime-cache.cjs +76 -0
  65. package/bin/thinking-activity-status-policy.cjs +132 -0
  66. package/bin/thinking-only-guard.cjs +75 -0
  67. package/bin/tool-call-loop-policy.cjs +53 -0
  68. package/bin/turn-thinking-policy.cjs +25 -1
  69. package/blun.mjs +556 -63
  70. package/package.json +4 -1
  71. package/standard-skills/translate-native/LICENSE +21 -21
  72. package/standard-skills/translate-native/references/evaluation-protocol.md +95 -95
  73. package/standard-skills/translate-native/references/native-orthography.md +79 -79
  74. package/standard-skills/translate-native/references/native-translation-standard.md +94 -94
  75. package/standard-skills/translate-native/references/structured-content.md +72 -72
  76. package/standard-skills/translate-native/references/translationese-review.md +77 -77
  77. package/standard-skills/translate-native/scripts/blun_language_guard.py +697 -697
  78. package/standard-skills/translate-native/scripts/check_diacritics.py +353 -353
  79. package/standard-skills/translate-native/scripts/guard_service_client.py +264 -264
  80. package/standard-skills/translate-native/scripts/language_gateway.py +62 -62
  81. package/standard-skills/translate-native/scripts/language_quality.py +377 -377
  82. package/standard-skills/translate-native/scripts/pre_output_guard.py +64 -64
  83. package/standard-skills/translate-native/scripts/translation_guard.py +916 -916
  84. package/standard-tools/language-guard/blun_language_guard.py +697 -697
  85. package/standard-tools/language-guard/check_diacritics.py +353 -353
  86. package/standard-tools/language-guard/guard_service_client.py +264 -264
  87. package/standard-tools/language-guard/language_quality.py +377 -377
  88. package/standard-tools/language-guard/translation_guard.py +916 -916
@@ -1,154 +1,154 @@
1
- import { readFile } from "node:fs/promises";
2
- import { dirname, join, relative, resolve } from "node:path";
3
- import { ancestorsBetween, canonicalPath, isInside } from "./paths.js";
4
- import { buildCatalog } from "./catalog.js";
5
- import { attachDocumentSnapshot, documentSnapshotContent } from "./documents.js";
6
- import { loadGraph } from "./graph.js";
7
-
8
- function depth(root, path) {
9
- const value = relative(root, dirname(path));
10
- return value ? value.split(/[\\/]/).length : 0;
11
- }
12
-
13
- function nativeDocuments(catalog, cwd, host, graph) {
14
- if (catalog.sourceRegistry) {
15
- return [...catalog.documents]
16
- .filter((document) => document.hosts.includes(host))
17
- .sort((left, right) => left.precedence - right.precedence || left.relativePath.localeCompare(right.relativePath));
18
- }
19
- const ancestors = new Set(ancestorsBetween(catalog.root, cwd));
20
- const inScope = catalog.documents.filter((document) => ancestors.has(dirname(document.path)));
21
- const selected = [];
22
-
23
- if (host === "codex") {
24
- for (const directory of ancestorsBetween(catalog.root, cwd)) {
25
- const local = inScope.filter((document) => dirname(document.path) === directory);
26
- const override = local.find((document) => document.name === "AGENTS.override.md");
27
- const regular = local.find((document) => document.name === "AGENTS.md");
28
- if (override || regular) selected.push(override || regular);
29
- }
30
- } else if (host === "claude") {
31
- selected.push(...inScope.filter((document) =>
32
- document.name === "CLAUDE.md" || document.name === "CLAUDE.local.md"
33
- ));
34
- } else {
35
- selected.push(...inScope.filter((document) => document.layer === "constitution"));
36
- }
37
-
38
- selected.push(...inScope.filter((document) => document.layer === "soul"));
39
- selected.push(...inScope.filter((document) => document.layer === "memory-index"));
40
- const inferredLayers = new Set(["constitution", "soul", "memory-index"]);
41
- const inferredPaths = new Set(graph.annotations
42
- .filter((annotation) => inferredLayers.has(annotation.layer))
43
- .map((annotation) => annotation.path));
44
- selected.push(...inScope.filter((document) => inferredPaths.has(document.relativePath)));
45
- return [...new Map(selected.map((document) => [document.relativePath, document])).values()];
46
- }
47
-
48
- function addLinkedDocuments(catalog, seed, graph) {
49
- const byPath = new Map(catalog.documents.map((document) => [document.relativePath, document]));
50
- const selected = new Map(seed.map((document) => [document.relativePath, document]));
51
- const queue = [...seed];
52
- while (queue.length) {
53
- const current = queue.shift();
54
- const learnedLinks = graph.edges
55
- .filter((edge) => edge.from === current.relativePath && edge.confidence >= 0.6)
56
- .map((edge) => edge.to);
57
- for (const linkedPath of [...current.links, ...learnedLinks]) {
58
- const linked = byPath.get(linkedPath);
59
- if (linked && !selected.has(linked.relativePath)) {
60
- selected.set(linked.relativePath, linked);
61
- queue.push(linked);
62
- }
63
- }
64
- }
65
- return [...selected.values()];
66
- }
67
-
68
- function precedence(layer) {
69
- if (layer === "constitution") return 0;
70
- if (layer === "soul") return 1;
71
- if (layer === "memory-index") return 2;
72
- if (layer === "memory-fact") return 3;
73
- return 4;
74
- }
75
-
76
- export async function resolveContext({ root = process.cwd(), cwd = root, host = "generic", maxBytes = 65536, includeContent = true, catalog: providedCatalog = null } = {}) {
77
- const canonicalRoot = await canonicalPath(root);
78
- const canonicalCwd = await canonicalPath(cwd);
79
- if (!isInside(canonicalRoot, canonicalCwd) && !providedCatalog?.sourceRegistry) {
80
- throw new Error(`cwd must be inside root: ${canonicalCwd}`);
81
- }
82
- const catalog = providedCatalog || await buildCatalog(canonicalRoot);
83
- if (catalog.root !== canonicalRoot) throw new Error("provided catalog belongs to a different project root");
84
- const { graph } = await loadGraph(canonicalRoot, catalog);
85
- const annotations = new Map(graph.annotations.map((annotation) => [annotation.path, annotation]));
86
- const seed = nativeDocuments(catalog, canonicalCwd, host, graph);
87
- const documents = addLinkedDocuments(catalog, seed, graph)
88
- .map((document) => {
89
- const annotation = annotations.get(document.relativePath);
90
- const resolved = {
91
- ...document,
92
- effectiveLayer: annotation?.layer || document.layer,
93
- authority: annotation ? "context-only" : document.authority,
94
- classificationSource: annotation ? "agent-overlay" : document.classificationSource
95
- };
96
- return attachDocumentSnapshot(resolved, documentSnapshotContent(document));
97
- })
98
- .sort((a, b) => catalog.sourceRegistry
99
- ? a.precedence - b.precedence || a.relativePath.localeCompare(b.relativePath)
100
- : precedence(a.effectiveLayer) - precedence(b.effectiveLayer) || depth(catalog.root, a.path) - depth(catalog.root, b.path) || a.relativePath.localeCompare(b.relativePath));
101
-
102
- let remaining = Math.max(0, Number(maxBytes) || 0);
103
- const resolved = [];
104
- for (const document of documents) {
105
- let content = null;
106
- let loaded = false;
107
- if (includeContent && document.bytes <= remaining) {
108
- const snapshot = documentSnapshotContent(document);
109
- content = snapshot ? snapshot.toString("utf8") : await readFile(document.path, "utf8");
110
- remaining -= Buffer.byteLength(content);
111
- loaded = true;
112
- }
113
- resolved.push({ ...document, content, loaded });
114
- }
115
-
116
- return {
117
- schema: "agentspine.context/v1",
118
- root: canonicalRoot,
119
- cwd: canonicalCwd,
120
- host,
121
- graph: {
122
- edges: graph.edges,
123
- annotations: graph.annotations,
124
- authority: "context-only"
125
- },
126
- conflicts: catalog.conflicts,
127
- budget: { maxBytes, remainingBytes: remaining },
128
- documents: resolved,
129
- omitted: resolved.filter((document) => !document.loaded).map((document) => document.relativePath),
130
- note: "Omitted content remains available byte-for-byte through agentspine read or the MCP read_document tool."
131
- };
132
- }
133
-
134
- export async function readDocument({ root = process.cwd(), path, offset = 0, length = 65536 }) {
135
- if (!path) throw new Error("path is required");
136
- const catalog = await buildCatalog(root);
137
- const absolute = resolve(catalog.root, path);
138
- const document = catalog.documents.find((item) => item.path === absolute);
139
- if (!document) throw new Error("path is not an indexed Markdown document");
140
- const buffer = await readFile(absolute);
141
- const start = Math.max(0, Number(offset) || 0);
142
- const end = Math.min(buffer.length, start + Math.max(0, Number(length) || 0));
143
- return {
144
- path: document.relativePath,
145
- sha256: document.sha256,
146
- offset: start,
147
- bytes: end - start,
148
- totalBytes: buffer.length,
149
- eof: end >= buffer.length,
150
- encoding: "utf8",
151
- content: buffer.subarray(start, end).toString("utf8"),
152
- contentBase64: buffer.subarray(start, end).toString("base64")
153
- };
154
- }
1
+ import { readFile } from "node:fs/promises";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
+ import { ancestorsBetween, canonicalPath, isInside } from "./paths.js";
4
+ import { buildCatalog } from "./catalog.js";
5
+ import { attachDocumentSnapshot, documentSnapshotContent } from "./documents.js";
6
+ import { loadGraph } from "./graph.js";
7
+
8
+ function depth(root, path) {
9
+ const value = relative(root, dirname(path));
10
+ return value ? value.split(/[\\/]/).length : 0;
11
+ }
12
+
13
+ function nativeDocuments(catalog, cwd, host, graph) {
14
+ if (catalog.sourceRegistry) {
15
+ return [...catalog.documents]
16
+ .filter((document) => document.hosts.includes(host))
17
+ .sort((left, right) => left.precedence - right.precedence || left.relativePath.localeCompare(right.relativePath));
18
+ }
19
+ const ancestors = new Set(ancestorsBetween(catalog.root, cwd));
20
+ const inScope = catalog.documents.filter((document) => ancestors.has(dirname(document.path)));
21
+ const selected = [];
22
+
23
+ if (host === "codex") {
24
+ for (const directory of ancestorsBetween(catalog.root, cwd)) {
25
+ const local = inScope.filter((document) => dirname(document.path) === directory);
26
+ const override = local.find((document) => document.name === "AGENTS.override.md");
27
+ const regular = local.find((document) => document.name === "AGENTS.md");
28
+ if (override || regular) selected.push(override || regular);
29
+ }
30
+ } else if (host === "claude") {
31
+ selected.push(...inScope.filter((document) =>
32
+ document.name === "CLAUDE.md" || document.name === "CLAUDE.local.md"
33
+ ));
34
+ } else {
35
+ selected.push(...inScope.filter((document) => document.layer === "constitution"));
36
+ }
37
+
38
+ selected.push(...inScope.filter((document) => document.layer === "soul"));
39
+ selected.push(...inScope.filter((document) => document.layer === "memory-index"));
40
+ const inferredLayers = new Set(["constitution", "soul", "memory-index"]);
41
+ const inferredPaths = new Set(graph.annotations
42
+ .filter((annotation) => inferredLayers.has(annotation.layer))
43
+ .map((annotation) => annotation.path));
44
+ selected.push(...inScope.filter((document) => inferredPaths.has(document.relativePath)));
45
+ return [...new Map(selected.map((document) => [document.relativePath, document])).values()];
46
+ }
47
+
48
+ function addLinkedDocuments(catalog, seed, graph) {
49
+ const byPath = new Map(catalog.documents.map((document) => [document.relativePath, document]));
50
+ const selected = new Map(seed.map((document) => [document.relativePath, document]));
51
+ const queue = [...seed];
52
+ while (queue.length) {
53
+ const current = queue.shift();
54
+ const learnedLinks = graph.edges
55
+ .filter((edge) => edge.from === current.relativePath && edge.confidence >= 0.6)
56
+ .map((edge) => edge.to);
57
+ for (const linkedPath of [...current.links, ...learnedLinks]) {
58
+ const linked = byPath.get(linkedPath);
59
+ if (linked && !selected.has(linked.relativePath)) {
60
+ selected.set(linked.relativePath, linked);
61
+ queue.push(linked);
62
+ }
63
+ }
64
+ }
65
+ return [...selected.values()];
66
+ }
67
+
68
+ function precedence(layer) {
69
+ if (layer === "constitution") return 0;
70
+ if (layer === "soul") return 1;
71
+ if (layer === "memory-index") return 2;
72
+ if (layer === "memory-fact") return 3;
73
+ return 4;
74
+ }
75
+
76
+ export async function resolveContext({ root = process.cwd(), cwd = root, host = "generic", maxBytes = 65536, includeContent = true, catalog: providedCatalog = null } = {}) {
77
+ const canonicalRoot = await canonicalPath(root);
78
+ const canonicalCwd = await canonicalPath(cwd);
79
+ if (!isInside(canonicalRoot, canonicalCwd) && !providedCatalog?.sourceRegistry) {
80
+ throw new Error(`cwd must be inside root: ${canonicalCwd}`);
81
+ }
82
+ const catalog = providedCatalog || await buildCatalog(canonicalRoot);
83
+ if (catalog.root !== canonicalRoot) throw new Error("provided catalog belongs to a different project root");
84
+ const { graph } = await loadGraph(canonicalRoot, catalog);
85
+ const annotations = new Map(graph.annotations.map((annotation) => [annotation.path, annotation]));
86
+ const seed = nativeDocuments(catalog, canonicalCwd, host, graph);
87
+ const documents = addLinkedDocuments(catalog, seed, graph)
88
+ .map((document) => {
89
+ const annotation = annotations.get(document.relativePath);
90
+ const resolved = {
91
+ ...document,
92
+ effectiveLayer: annotation?.layer || document.layer,
93
+ authority: annotation ? "context-only" : document.authority,
94
+ classificationSource: annotation ? "agent-overlay" : document.classificationSource
95
+ };
96
+ return attachDocumentSnapshot(resolved, documentSnapshotContent(document));
97
+ })
98
+ .sort((a, b) => catalog.sourceRegistry
99
+ ? a.precedence - b.precedence || a.relativePath.localeCompare(b.relativePath)
100
+ : precedence(a.effectiveLayer) - precedence(b.effectiveLayer) || depth(catalog.root, a.path) - depth(catalog.root, b.path) || a.relativePath.localeCompare(b.relativePath));
101
+
102
+ let remaining = Math.max(0, Number(maxBytes) || 0);
103
+ const resolved = [];
104
+ for (const document of documents) {
105
+ let content = null;
106
+ let loaded = false;
107
+ if (includeContent && document.bytes <= remaining) {
108
+ const snapshot = documentSnapshotContent(document);
109
+ content = snapshot ? snapshot.toString("utf8") : await readFile(document.path, "utf8");
110
+ remaining -= Buffer.byteLength(content);
111
+ loaded = true;
112
+ }
113
+ resolved.push({ ...document, content, loaded });
114
+ }
115
+
116
+ return {
117
+ schema: "agentspine.context/v1",
118
+ root: canonicalRoot,
119
+ cwd: canonicalCwd,
120
+ host,
121
+ graph: {
122
+ edges: graph.edges,
123
+ annotations: graph.annotations,
124
+ authority: "context-only"
125
+ },
126
+ conflicts: catalog.conflicts,
127
+ budget: { maxBytes, remainingBytes: remaining },
128
+ documents: resolved,
129
+ omitted: resolved.filter((document) => !document.loaded).map((document) => document.relativePath),
130
+ note: "Omitted content remains available byte-for-byte through agentspine read or the MCP read_document tool."
131
+ };
132
+ }
133
+
134
+ export async function readDocument({ root = process.cwd(), path, offset = 0, length = 65536 }) {
135
+ if (!path) throw new Error("path is required");
136
+ const catalog = await buildCatalog(root);
137
+ const absolute = resolve(catalog.root, path);
138
+ const document = catalog.documents.find((item) => item.path === absolute);
139
+ if (!document) throw new Error("path is not an indexed Markdown document");
140
+ const buffer = await readFile(absolute);
141
+ const start = Math.max(0, Number(offset) || 0);
142
+ const end = Math.min(buffer.length, start + Math.max(0, Number(length) || 0));
143
+ return {
144
+ path: document.relativePath,
145
+ sha256: document.sha256,
146
+ offset: start,
147
+ bytes: end - start,
148
+ totalBytes: buffer.length,
149
+ eof: end >= buffer.length,
150
+ encoding: "utf8",
151
+ content: buffer.subarray(start, end).toString("utf8"),
152
+ contentBase64: buffer.subarray(start, end).toString("base64")
153
+ };
154
+ }