blun-king-cli 9.1.563 → 9.1.565

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 (85) hide show
  1. package/agent-spine-plugin/.claude-plugin/marketplace.json +20 -20
  2. package/agent-spine-plugin/.claude-plugin/plugin.json +14 -14
  3. package/agent-spine-plugin/.codex-plugin/plugin.json +34 -34
  4. package/agent-spine-plugin/.mcp.json +8 -8
  5. package/agent-spine-plugin/CONTRIBUTING.md +52 -0
  6. package/agent-spine-plugin/LICENSE +186 -186
  7. package/agent-spine-plugin/README.md +394 -0
  8. package/agent-spine-plugin/SECURITY.md +47 -0
  9. package/agent-spine-plugin/assets/agentspine-banner.svg +32 -32
  10. package/agent-spine-plugin/bin/agentspine-mcp.js +4 -4
  11. package/agent-spine-plugin/bin/agentspine.js +7 -7
  12. package/agent-spine-plugin/blun.plugin.json +33 -33
  13. package/agent-spine-plugin/hooks/codex.json +47 -47
  14. package/agent-spine-plugin/hooks/hooks.json +106 -106
  15. package/agent-spine-plugin/hooks/version.json +5 -5
  16. package/agent-spine-plugin/package.json +69 -69
  17. package/agent-spine-plugin/scripts/check-hosts.js +199 -199
  18. package/agent-spine-plugin/skill/SKILL.md +76 -76
  19. package/agent-spine-plugin/skills/agent-spine/SKILL.md +85 -85
  20. package/agent-spine-plugin/src/cli.js +1488 -1442
  21. package/agent-spine-plugin/src/hook.js +886 -812
  22. package/agent-spine-plugin/src/index.js +93 -93
  23. package/agent-spine-plugin/src/lib/acceptance.js +333 -333
  24. package/agent-spine-plugin/src/lib/attention.js +755 -755
  25. package/agent-spine-plugin/src/lib/audit.js +351 -342
  26. package/agent-spine-plugin/src/lib/authentication.js +515 -515
  27. package/agent-spine-plugin/src/lib/briefing.js +317 -317
  28. package/agent-spine-plugin/src/lib/catalog.js +167 -167
  29. package/agent-spine-plugin/src/lib/channel-runtime.js +665 -665
  30. package/agent-spine-plugin/src/lib/context.js +154 -154
  31. package/agent-spine-plugin/src/lib/continuity.js +338 -338
  32. package/agent-spine-plugin/src/lib/coordination.js +577 -577
  33. package/agent-spine-plugin/src/lib/documents.js +217 -217
  34. package/agent-spine-plugin/src/lib/feed-transport.js +499 -499
  35. package/agent-spine-plugin/src/lib/filesystem-retry.js +32 -32
  36. package/agent-spine-plugin/src/lib/gateway-runtime.js +1119 -760
  37. package/agent-spine-plugin/src/lib/graph.js +337 -337
  38. package/agent-spine-plugin/src/lib/hook-audit.js +29 -0
  39. package/agent-spine-plugin/src/lib/https-transport.js +392 -392
  40. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +40 -40
  41. package/agent-spine-plugin/src/lib/indexed-memory.js +281 -281
  42. package/agent-spine-plugin/src/lib/learning.js +6923 -6466
  43. package/agent-spine-plugin/src/lib/object-transport.js +206 -206
  44. package/agent-spine-plugin/src/lib/owned-file-lock.js +143 -143
  45. package/agent-spine-plugin/src/lib/paths.js +109 -109
  46. package/agent-spine-plugin/src/lib/peer-transport.js +283 -283
  47. package/agent-spine-plugin/src/lib/persona-runtime.js +581 -581
  48. package/agent-spine-plugin/src/lib/preflight.js +702 -702
  49. package/agent-spine-plugin/src/lib/runtime.js +13 -13
  50. package/agent-spine-plugin/src/lib/selfstarter.js +892 -819
  51. package/agent-spine-plugin/src/lib/sharing.js +969 -969
  52. package/agent-spine-plugin/src/lib/source-roots.js +529 -482
  53. package/agent-spine-plugin/src/lib/sqlite-transport.js +501 -501
  54. package/agent-spine-plugin/src/lib/telegram-adapter.js +119 -119
  55. package/agent-spine-plugin/src/lib/voice-runtime.js +39 -39
  56. package/agent-spine-plugin/src/mcp.js +597 -572
  57. package/agent-spine-plugin/src/version.js +1 -1
  58. package/agent-spine-plugin/src/worker.js +202 -195
  59. package/bin/active-steer-priority-policy.cjs +24 -0
  60. package/bin/launcher-runtime.js +8 -1
  61. package/bin/mnemo-tool-agent-policy.cjs +22 -0
  62. package/bin/thinking-activity-status-policy.cjs +132 -0
  63. package/bin/thinking-only-guard.cjs +75 -0
  64. package/bin/tool-call-loop-policy.cjs +53 -0
  65. package/bin/turn-thinking-policy.cjs +25 -1
  66. package/blun.mjs +554 -64
  67. package/package.json +4 -1
  68. package/standard-skills/translate-native/LICENSE +21 -21
  69. package/standard-skills/translate-native/references/evaluation-protocol.md +95 -95
  70. package/standard-skills/translate-native/references/native-orthography.md +79 -79
  71. package/standard-skills/translate-native/references/native-translation-standard.md +94 -94
  72. package/standard-skills/translate-native/references/structured-content.md +72 -72
  73. package/standard-skills/translate-native/references/translationese-review.md +77 -77
  74. package/standard-skills/translate-native/scripts/blun_language_guard.py +697 -697
  75. package/standard-skills/translate-native/scripts/check_diacritics.py +353 -353
  76. package/standard-skills/translate-native/scripts/guard_service_client.py +264 -264
  77. package/standard-skills/translate-native/scripts/language_gateway.py +62 -62
  78. package/standard-skills/translate-native/scripts/language_quality.py +377 -377
  79. package/standard-skills/translate-native/scripts/pre_output_guard.py +64 -64
  80. package/standard-skills/translate-native/scripts/translation_guard.py +916 -916
  81. package/standard-tools/language-guard/blun_language_guard.py +697 -697
  82. package/standard-tools/language-guard/check_diacritics.py +353 -353
  83. package/standard-tools/language-guard/guard_service_client.py +264 -264
  84. package/standard-tools/language-guard/language_quality.py +377 -377
  85. 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
+ }