blun-king-cli 9.1.642 → 9.1.644

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 (273) hide show
  1. package/LIESMICH.txt +18 -0
  2. package/README.md +20 -6
  3. package/bin/blun.js +3 -3
  4. package/bin/king.js +3 -3
  5. package/bin/launcher-mode.js +125 -126
  6. package/bin/launcher-runtime.js +603 -616
  7. package/bin/plugin-bootstrap.js +339 -405
  8. package/bin/rename-private-staging.cjs +2 -2
  9. package/bin/retired-bundled-plugins.cjs +84 -0
  10. package/bin/startup-security-host.cjs +105 -0
  11. package/bin/startup-security.cjs +9 -105
  12. package/bin/startup-warning-policy.cjs +22 -0
  13. package/bin/update-lease-installer.cjs +125 -0
  14. package/bin/update-lease-sockets.cjs +228 -0
  15. package/bin/update-lease.js +22 -327
  16. package/bin/verify-bundled-agent-sources.cjs +2 -4
  17. package/blun.mjs +78 -193
  18. package/bundled-agent-sources.json +1 -552
  19. package/package.json +4 -6
  20. package/tool-liveness642/index.cjs +7 -0
  21. package/tool-liveness642/queue-delivery.cjs +109 -0
  22. package/tool-liveness642/receipt.json +40 -0
  23. package/tool-liveness642/shell-yield.cjs +43 -0
  24. package/tool-liveness642/task-wait.cjs +45 -0
  25. package/versionierung/BELEG.json +43 -0
  26. package/versionierung/LIESMICH.md +5 -0
  27. package/versionierung/urspruenglicher-overlay-beleg.json +39 -0
  28. package/worker-host.mjs +48 -128
  29. package/agent-spine-plugin/.claude-plugin/marketplace.json +0 -20
  30. package/agent-spine-plugin/.claude-plugin/plugin.json +0 -14
  31. package/agent-spine-plugin/.codex-plugin/plugin.json +0 -47
  32. package/agent-spine-plugin/.mcp.json +0 -8
  33. package/agent-spine-plugin/CHANGELOG.md +0 -1614
  34. package/agent-spine-plugin/LICENSE +0 -186
  35. package/agent-spine-plugin/README.md +0 -432
  36. package/agent-spine-plugin/assets/agentspine-banner.svg +0 -32
  37. package/agent-spine-plugin/bin/agentspine-mcp.js +0 -4
  38. package/agent-spine-plugin/bin/agentspine.js +0 -7
  39. package/agent-spine-plugin/blun.plugin.json +0 -68
  40. package/agent-spine-plugin/docs/acceptance.md +0 -61
  41. package/agent-spine-plugin/docs/artifact-evaluation.md +0 -93
  42. package/agent-spine-plugin/docs/host-integration.md +0 -193
  43. package/agent-spine-plugin/docs/preflight-recall.md +0 -71
  44. package/agent-spine-plugin/docs/preservation-contract.md +0 -53
  45. package/agent-spine-plugin/docs/quality-gates.md +0 -50
  46. package/agent-spine-plugin/docs/session-timeline.md +0 -112
  47. package/agent-spine-plugin/docs/source-roots.md +0 -113
  48. package/agent-spine-plugin/docs/world-model.md +0 -119
  49. package/agent-spine-plugin/hooks/codex.json +0 -47
  50. package/agent-spine-plugin/hooks/hooks.json +0 -106
  51. package/agent-spine-plugin/hooks/version.json +0 -5
  52. package/agent-spine-plugin/package.json +0 -77
  53. package/agent-spine-plugin/scripts/check-codex-install.js +0 -226
  54. package/agent-spine-plugin/scripts/check-hosts.js +0 -208
  55. package/agent-spine-plugin/scripts/check-install-hook.js +0 -227
  56. package/agent-spine-plugin/scripts/check-install-selfstarter.js +0 -154
  57. package/agent-spine-plugin/scripts/check-install.js +0 -478
  58. package/agent-spine-plugin/scripts/check-line-budget.js +0 -58
  59. package/agent-spine-plugin/scripts/check-syntax.js +0 -29
  60. package/agent-spine-plugin/scripts/github-actions.js +0 -11
  61. package/agent-spine-plugin/scripts/hermetic-process.js +0 -191
  62. package/agent-spine-plugin/scripts/release-check.js +0 -150
  63. package/agent-spine-plugin/scripts/run-acceptance.js +0 -19
  64. package/agent-spine-plugin/scripts/run-checks.js +0 -50
  65. package/agent-spine-plugin/scripts/run-tests-hermetic.js +0 -112
  66. package/agent-spine-plugin/skills/agent-spine/SKILL.md +0 -99
  67. package/agent-spine-plugin/spine-example/1-identity.md +0 -12
  68. package/agent-spine-plugin/spine-example/2-voice.md +0 -6
  69. package/agent-spine-plugin/spine-example/3-conduct.md +0 -8
  70. package/agent-spine-plugin/spine-example/4-history.md +0 -4
  71. package/agent-spine-plugin/src/cli-agent.js +0 -315
  72. package/agent-spine-plugin/src/cli-attention.js +0 -95
  73. package/agent-spine-plugin/src/cli-autonomy.js +0 -36
  74. package/agent-spine-plugin/src/cli-common.js +0 -71
  75. package/agent-spine-plugin/src/cli-continuity.js +0 -116
  76. package/agent-spine-plugin/src/cli-core.js +0 -128
  77. package/agent-spine-plugin/src/cli-diagnostics.js +0 -291
  78. package/agent-spine-plugin/src/cli-host.js +0 -21
  79. package/agent-spine-plugin/src/cli-learning.js +0 -320
  80. package/agent-spine-plugin/src/cli-premortem.js +0 -16
  81. package/agent-spine-plugin/src/cli-sharing.js +0 -230
  82. package/agent-spine-plugin/src/cli.js +0 -181
  83. package/agent-spine-plugin/src/codex-reader-launcher.js +0 -182
  84. package/agent-spine-plugin/src/hook.js +0 -500
  85. package/agent-spine-plugin/src/index.js +0 -108
  86. package/agent-spine-plugin/src/lib/acceptance.js +0 -435
  87. package/agent-spine-plugin/src/lib/action-lesson-recall.js +0 -118
  88. package/agent-spine-plugin/src/lib/attention-context.js +0 -167
  89. package/agent-spine-plugin/src/lib/attention-events.js +0 -113
  90. package/agent-spine-plugin/src/lib/attention-privacy.js +0 -72
  91. package/agent-spine-plugin/src/lib/attention-schema.js +0 -164
  92. package/agent-spine-plugin/src/lib/attention-storage.js +0 -93
  93. package/agent-spine-plugin/src/lib/attention.js +0 -164
  94. package/agent-spine-plugin/src/lib/audit-premortem.js +0 -223
  95. package/agent-spine-plugin/src/lib/audit.js +0 -401
  96. package/agent-spine-plugin/src/lib/authentication.js +0 -515
  97. package/agent-spine-plugin/src/lib/autonomy-policy.js +0 -110
  98. package/agent-spine-plugin/src/lib/autonomy-store.js +0 -202
  99. package/agent-spine-plugin/src/lib/autonomy.js +0 -8
  100. package/agent-spine-plugin/src/lib/briefing.js +0 -493
  101. package/agent-spine-plugin/src/lib/catalog-document-read.js +0 -51
  102. package/agent-spine-plugin/src/lib/catalog.js +0 -167
  103. package/agent-spine-plugin/src/lib/channel-continuity.js +0 -19
  104. package/agent-spine-plugin/src/lib/channel-runtime.js +0 -665
  105. package/agent-spine-plugin/src/lib/codex-installation.js +0 -231
  106. package/agent-spine-plugin/src/lib/codex-skill-installation.js +0 -211
  107. package/agent-spine-plugin/src/lib/context.js +0 -156
  108. package/agent-spine-plugin/src/lib/continuity.js +0 -338
  109. package/agent-spine-plugin/src/lib/coordination.js +0 -577
  110. package/agent-spine-plugin/src/lib/delivery-agent-usage.js +0 -231
  111. package/agent-spine-plugin/src/lib/delivery-assignment.js +0 -220
  112. package/agent-spine-plugin/src/lib/delivery-command-actions.js +0 -462
  113. package/agent-spine-plugin/src/lib/delivery-knowledge.js +0 -78
  114. package/agent-spine-plugin/src/lib/delivery-premortem-binding.js +0 -107
  115. package/agent-spine-plugin/src/lib/delivery-premortem-closure.js +0 -171
  116. package/agent-spine-plugin/src/lib/delivery-premortem-codec.js +0 -45
  117. package/agent-spine-plugin/src/lib/delivery-premortem-correction.js +0 -101
  118. package/agent-spine-plugin/src/lib/delivery-premortem-file.js +0 -21
  119. package/agent-spine-plugin/src/lib/delivery-premortem-index.js +0 -493
  120. package/agent-spine-plugin/src/lib/delivery-premortem-inspection.js +0 -37
  121. package/agent-spine-plugin/src/lib/delivery-premortem-recovery.js +0 -120
  122. package/agent-spine-plugin/src/lib/delivery-premortem-rejection.js +0 -65
  123. package/agent-spine-plugin/src/lib/delivery-premortem-results.js +0 -28
  124. package/agent-spine-plugin/src/lib/delivery-premortem-session-guard.js +0 -46
  125. package/agent-spine-plugin/src/lib/delivery-premortem-write-ledger.js +0 -285
  126. package/agent-spine-plugin/src/lib/delivery-premortem.js +0 -499
  127. package/agent-spine-plugin/src/lib/delivery-shell-heredoc.js +0 -115
  128. package/agent-spine-plugin/src/lib/delivery-shell-substitutions.js +0 -111
  129. package/agent-spine-plugin/src/lib/delivery-shell-wrapper.js +0 -64
  130. package/agent-spine-plugin/src/lib/delivery-target.js +0 -73
  131. package/agent-spine-plugin/src/lib/delivery-verification.js +0 -445
  132. package/agent-spine-plugin/src/lib/documents.js +0 -239
  133. package/agent-spine-plugin/src/lib/feed-transport.js +0 -499
  134. package/agent-spine-plugin/src/lib/filesystem-retry.js +0 -34
  135. package/agent-spine-plugin/src/lib/gateway-common.js +0 -68
  136. package/agent-spine-plugin/src/lib/gateway-control.js +0 -370
  137. package/agent-spine-plugin/src/lib/gateway-delivery.js +0 -103
  138. package/agent-spine-plugin/src/lib/gateway-execution.js +0 -350
  139. package/agent-spine-plugin/src/lib/gateway-group-response.js +0 -128
  140. package/agent-spine-plugin/src/lib/gateway-host-fencing.js +0 -92
  141. package/agent-spine-plugin/src/lib/gateway-host-lifecycle.js +0 -193
  142. package/agent-spine-plugin/src/lib/gateway-inspection.js +0 -85
  143. package/agent-spine-plugin/src/lib/gateway-knowledge.js +0 -129
  144. package/agent-spine-plugin/src/lib/gateway-policy-provenance.js +0 -197
  145. package/agent-spine-plugin/src/lib/gateway-premortem-disposition.js +0 -82
  146. package/agent-spine-plugin/src/lib/gateway-premortem.js +0 -363
  147. package/agent-spine-plugin/src/lib/gateway-prepared-host.js +0 -28
  148. package/agent-spine-plugin/src/lib/gateway-runs.js +0 -345
  149. package/agent-spine-plugin/src/lib/gateway-runtime-identity.js +0 -31
  150. package/agent-spine-plugin/src/lib/gateway-runtime-records.js +0 -21
  151. package/agent-spine-plugin/src/lib/gateway-runtime.js +0 -18
  152. package/agent-spine-plugin/src/lib/gateway-state-transaction.js +0 -356
  153. package/agent-spine-plugin/src/lib/gateway-state.js +0 -344
  154. package/agent-spine-plugin/src/lib/graph.js +0 -337
  155. package/agent-spine-plugin/src/lib/hook-artifact-guards.js +0 -356
  156. package/agent-spine-plugin/src/lib/hook-audit.js +0 -43
  157. package/agent-spine-plugin/src/lib/hook-briefing-use.js +0 -78
  158. package/agent-spine-plugin/src/lib/hook-context.js +0 -441
  159. package/agent-spine-plugin/src/lib/hook-final-message.js +0 -26
  160. package/agent-spine-plugin/src/lib/hook-input.js +0 -27
  161. package/agent-spine-plugin/src/lib/hook-output.js +0 -284
  162. package/agent-spine-plugin/src/lib/hook-premortem.js +0 -257
  163. package/agent-spine-plugin/src/lib/hook-process-advisory.js +0 -36
  164. package/agent-spine-plugin/src/lib/hook-protection.js +0 -95
  165. package/agent-spine-plugin/src/lib/hook-stop-verification.js +0 -84
  166. package/agent-spine-plugin/src/lib/hook-timeline.js +0 -102
  167. package/agent-spine-plugin/src/lib/host-instruction-budget.js +0 -11
  168. package/agent-spine-plugin/src/lib/https-transport.js +0 -392
  169. package/agent-spine-plugin/src/lib/identifier-analysis.js +0 -446
  170. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +0 -40
  171. package/agent-spine-plugin/src/lib/indexed-memory.js +0 -298
  172. package/agent-spine-plugin/src/lib/knowledge-evidence.js +0 -431
  173. package/agent-spine-plugin/src/lib/learning-applications.js +0 -441
  174. package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +0 -114
  175. package/agent-spine-plugin/src/lib/learning-candidates.js +0 -274
  176. package/agent-spine-plugin/src/lib/learning-context.js +0 -137
  177. package/agent-spine-plugin/src/lib/learning-delivery-contracts.js +0 -310
  178. package/agent-spine-plugin/src/lib/learning-evaluation-contracts.js +0 -350
  179. package/agent-spine-plugin/src/lib/learning-evaluation-registration.js +0 -372
  180. package/agent-spine-plugin/src/lib/learning-evaluation-revocation.js +0 -292
  181. package/agent-spine-plugin/src/lib/learning-evidence-contracts.js +0 -321
  182. package/agent-spine-plugin/src/lib/learning-findings.js +0 -458
  183. package/agent-spine-plugin/src/lib/learning-measurement-contracts.js +0 -285
  184. package/agent-spine-plugin/src/lib/learning-measurements.js +0 -265
  185. package/agent-spine-plugin/src/lib/learning-outcome-contracts.js +0 -165
  186. package/agent-spine-plugin/src/lib/learning-outcomes.js +0 -343
  187. package/agent-spine-plugin/src/lib/learning-reconciliation.js +0 -290
  188. package/agent-spine-plugin/src/lib/learning-retry-contracts.js +0 -188
  189. package/agent-spine-plugin/src/lib/learning-schema.js +0 -229
  190. package/agent-spine-plugin/src/lib/learning-scope-targets.js +0 -424
  191. package/agent-spine-plugin/src/lib/learning-state-upgrade.js +0 -477
  192. package/agent-spine-plugin/src/lib/learning-status-configuration.js +0 -476
  193. package/agent-spine-plugin/src/lib/learning-storage.js +0 -203
  194. package/agent-spine-plugin/src/lib/learning-trial-recovery.js +0 -218
  195. package/agent-spine-plugin/src/lib/learning-validation-contracts.js +0 -375
  196. package/agent-spine-plugin/src/lib/learning-validation-renewal.js +0 -298
  197. package/agent-spine-plugin/src/lib/learning-validation-runtime.js +0 -234
  198. package/agent-spine-plugin/src/lib/learning.js +0 -36
  199. package/agent-spine-plugin/src/lib/lesson-recall-session.js +0 -172
  200. package/agent-spine-plugin/src/lib/mcp-autonomy-tools.js +0 -37
  201. package/agent-spine-plugin/src/lib/mcp-delivery-completion.js +0 -124
  202. package/agent-spine-plugin/src/lib/mcp-delivery-tools.js +0 -45
  203. package/agent-spine-plugin/src/lib/mcp-premortem.js +0 -68
  204. package/agent-spine-plugin/src/lib/mcp-runtime.js +0 -355
  205. package/agent-spine-plugin/src/lib/mcp-source-context.js +0 -61
  206. package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +0 -240
  207. package/agent-spine-plugin/src/lib/mcp-world-tools.js +0 -52
  208. package/agent-spine-plugin/src/lib/object-transport.js +0 -206
  209. package/agent-spine-plugin/src/lib/owned-file-lock.js +0 -182
  210. package/agent-spine-plugin/src/lib/paths.js +0 -109
  211. package/agent-spine-plugin/src/lib/peer-transport.js +0 -283
  212. package/agent-spine-plugin/src/lib/persona-runtime.js +0 -581
  213. package/agent-spine-plugin/src/lib/pre-answer-timeline-recall.js +0 -104
  214. package/agent-spine-plugin/src/lib/preflight-delivery-id.js +0 -27
  215. package/agent-spine-plugin/src/lib/preflight.js +0 -688
  216. package/agent-spine-plugin/src/lib/project-portfolio.js +0 -176
  217. package/agent-spine-plugin/src/lib/runtime.js +0 -13
  218. package/agent-spine-plugin/src/lib/selfstarter-core.js +0 -382
  219. package/agent-spine-plugin/src/lib/selfstarter-jobs.js +0 -149
  220. package/agent-spine-plugin/src/lib/selfstarter-lease.js +0 -204
  221. package/agent-spine-plugin/src/lib/selfstarter-policy.js +0 -90
  222. package/agent-spine-plugin/src/lib/selfstarter-workspace.js +0 -111
  223. package/agent-spine-plugin/src/lib/selfstarter.js +0 -11
  224. package/agent-spine-plugin/src/lib/session-timeline-auth.js +0 -316
  225. package/agent-spine-plugin/src/lib/session-timeline-codex.js +0 -69
  226. package/agent-spine-plugin/src/lib/session-timeline-contract.js +0 -56
  227. package/agent-spine-plugin/src/lib/session-timeline-enrollment-source.js +0 -38
  228. package/agent-spine-plugin/src/lib/session-timeline-enrollment-storage.js +0 -128
  229. package/agent-spine-plugin/src/lib/session-timeline-enrollment-transport.js +0 -15
  230. package/agent-spine-plugin/src/lib/session-timeline-enrollment.js +0 -478
  231. package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +0 -186
  232. package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +0 -73
  233. package/agent-spine-plugin/src/lib/session-timeline-host-receipt.js +0 -117
  234. package/agent-spine-plugin/src/lib/session-timeline-invocation.js +0 -201
  235. package/agent-spine-plugin/src/lib/session-timeline-king.js +0 -93
  236. package/agent-spine-plugin/src/lib/session-timeline-prior.js +0 -57
  237. package/agent-spine-plugin/src/lib/session-timeline-provider.js +0 -36
  238. package/agent-spine-plugin/src/lib/session-timeline-query.js +0 -56
  239. package/agent-spine-plugin/src/lib/session-timeline-results.js +0 -56
  240. package/agent-spine-plugin/src/lib/session-timeline-root.js +0 -11
  241. package/agent-spine-plugin/src/lib/session-timeline-search.js +0 -82
  242. package/agent-spine-plugin/src/lib/session-timeline-sid-acl.js +0 -213
  243. package/agent-spine-plugin/src/lib/session-timeline-source-open.js +0 -30
  244. package/agent-spine-plugin/src/lib/session-timeline-source.js +0 -80
  245. package/agent-spine-plugin/src/lib/session-timeline-state.js +0 -45
  246. package/agent-spine-plugin/src/lib/session-timeline-transport.js +0 -42
  247. package/agent-spine-plugin/src/lib/session-timeline-windows-acl.js +0 -145
  248. package/agent-spine-plugin/src/lib/session-timeline.js +0 -462
  249. package/agent-spine-plugin/src/lib/sharing.js +0 -969
  250. package/agent-spine-plugin/src/lib/source-roots.js +0 -475
  251. package/agent-spine-plugin/src/lib/source-tree-scan.js +0 -178
  252. package/agent-spine-plugin/src/lib/sqlite-transport.js +0 -501
  253. package/agent-spine-plugin/src/lib/task-knowledge-context.js +0 -99
  254. package/agent-spine-plugin/src/lib/telegram-adapter.js +0 -119
  255. package/agent-spine-plugin/src/lib/timeline-continuation-update.js +0 -100
  256. package/agent-spine-plugin/src/lib/timeline-tool-guard.js +0 -225
  257. package/agent-spine-plugin/src/lib/timeline-user-feedback.js +0 -216
  258. package/agent-spine-plugin/src/lib/timeline-world-capture.js +0 -233
  259. package/agent-spine-plugin/src/lib/voice-runtime.js +0 -39
  260. package/agent-spine-plugin/src/lib/world-knowledge.js +0 -306
  261. package/agent-spine-plugin/src/lib/world-model.js +0 -333
  262. package/agent-spine-plugin/src/mcp.js +0 -456
  263. package/agent-spine-plugin/src/version.js +0 -1
  264. package/agent-spine-plugin/src/worker.js +0 -257
  265. package/bin/agentspine-king-goal-inbox.mjs +0 -127
  266. package/bin/agentspine-king-goal-intake.mjs +0 -106
  267. package/bin/agentspine-king-host-runner.mjs +0 -109
  268. package/bin/agentspine-king-snapshot-policy.cjs +0 -80
  269. package/bin/agentspine-king-status-policy.mjs +0 -226
  270. package/bin/agentspine-king-worker-host.mjs +0 -160
  271. package/bin/managed-plugin-selection.cjs +0 -141
  272. package/bin/verify-agent-behavior.cjs +0 -122
  273. package/bin/verify-agent-components.cjs +0 -104
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readdir, readFile } from "node:fs/promises";
3
- import { extname, join, relative, resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- const ROOT = fileURLToPath(new URL("..", import.meta.url));
7
- const DEFAULT_LIMIT = 500;
8
- const JAVASCRIPT_EXTENSIONS = new Set([".js", ".mjs", ".cjs"]);
9
- const LEGACY_LIMITS = new Map(Object.entries({
10
- "src/lib/authentication.js": 515,
11
- "src/lib/channel-runtime.js": 665,
12
- "src/lib/coordination.js": 577,
13
- "src/lib/persona-runtime.js": 581,
14
- "src/lib/preflight.js": 702,
15
- "src/lib/sharing.js": 969,
16
- "src/lib/sqlite-transport.js": 501
17
- }));
18
-
19
- async function javascriptFiles(directory) {
20
- const files = [];
21
- for (const entry of await readdir(directory, { withFileTypes: true })) {
22
- const path = join(directory, entry.name);
23
- if (entry.isDirectory()) files.push(...await javascriptFiles(path));
24
- else if (entry.isFile() && JAVASCRIPT_EXTENSIONS.has(extname(entry.name))) files.push(path);
25
- }
26
- return files;
27
- }
28
-
29
- function physicalLines(content) {
30
- if (!content.length) return 0;
31
- const lines = content.split(/\r?\n/).length;
32
- return content.endsWith("\n") ? lines - 1 : lines;
33
- }
34
-
35
- export async function checkLineBudget(root = ROOT) {
36
- const files = (await Promise.all(["bin", "src", "test", "scripts"]
37
- .map((name) => javascriptFiles(join(root, name))))).flat();
38
- const measurements = await Promise.all(files.map(async (path) => {
39
- const name = relative(root, path).replaceAll("\\", "/");
40
- const lines = physicalLines(await readFile(path, "utf8"));
41
- return { name, lines, limit: LEGACY_LIMITS.get(name) ?? DEFAULT_LIMIT };
42
- }));
43
- const failures = measurements.filter((item) => item.lines > item.limit);
44
- const missing = [...LEGACY_LIMITS].filter(([name]) => !measurements.some((item) => item.name === name));
45
- return { ok: failures.length === 0 && missing.length === 0, defaultLimit: DEFAULT_LIMIT,
46
- legacyFiles: LEGACY_LIMITS.size, failures, missing: missing.map(([name]) => name), measurements };
47
- }
48
-
49
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
50
- const result = await checkLineBudget();
51
- if (!result.ok) {
52
- for (const item of result.failures) process.stderr.write(`${item.name}: ${item.lines} lines exceeds ${item.limit}\n`);
53
- for (const name of result.missing) process.stderr.write(`${name}: legacy budget entry no longer maps to a file\n`);
54
- process.exitCode = 1;
55
- } else {
56
- process.stdout.write(`Line budget passed: ${result.measurements.length} JavaScript files; new files <= ${result.defaultLimit}.\n`);
57
- }
58
- }
@@ -1,29 +0,0 @@
1
- import { opendir } from "node:fs/promises";
2
- import { extname, join } from "node:path";
3
- import { spawnSync } from "node:child_process";
4
-
5
- async function javascriptFiles(directory, files = []) {
6
- const entries = [];
7
- for await (const entry of await opendir(directory)) entries.push(entry);
8
- entries.sort((a, b) => a.name.localeCompare(b.name));
9
- for (const entry of entries) {
10
- const path = join(directory, entry.name);
11
- if (entry.isDirectory()) await javascriptFiles(path, files);
12
- else if (entry.isFile() && extname(entry.name) === ".js") files.push(path);
13
- }
14
- return files;
15
- }
16
-
17
- const files = [
18
- ...await javascriptFiles("src"),
19
- ...await javascriptFiles("bin"),
20
- ...await javascriptFiles("scripts")
21
- ];
22
- for (const file of files) {
23
- const result = spawnSync(process.execPath, ["--check", file], { encoding: "utf8" });
24
- if (result.status !== 0) {
25
- process.stderr.write(result.stderr || result.stdout);
26
- process.exit(result.status || 1);
27
- }
28
- }
29
- process.stdout.write(`Checked ${files.length} JavaScript files.\n`);
@@ -1,11 +0,0 @@
1
- function escapeWorkflowData(value) {
2
- return String(value).replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
3
- }
4
-
5
- function escapeWorkflowProperty(value) {
6
- return escapeWorkflowData(value).replaceAll(":", "%3A").replaceAll(",", "%2C");
7
- }
8
-
9
- export function githubErrorCommand(title, message) {
10
- return `::error title=${escapeWorkflowProperty(title)}::${escapeWorkflowData(message)}`;
11
- }
@@ -1,191 +0,0 @@
1
- import { spawn as nodeSpawn } from "node:child_process";
2
-
3
- export const DEFAULT_TEST_TIMEOUT_MS = 180_000;
4
- export const TIMEOUT_EXIT_CODE = 124;
5
-
6
- const MAX_CAPTURE_CHARS = 1_000_000;
7
- const TASKKILL_TIMEOUT_MS = 5_000;
8
-
9
- export function selectTestShard(files, spec) {
10
- if (!spec) return files;
11
- const match = /^([1-9]\d*)\/([1-9]\d*)$/.exec(spec);
12
- const index = +match?.[1]; const count = +match?.[2];
13
- if (!match || count < 2 || index > count) throw new Error("SHARD");
14
- return files.filter((_, i) => i % count === index - 1);
15
- }
16
-
17
- function running(child) {
18
- return child?.pid && child.exitCode === null && child.signalCode === null;
19
- }
20
-
21
- function waitForClose(child, timeoutMs) {
22
- if (!running(child)) return Promise.resolve(true);
23
- return new Promise((resolve) => {
24
- let timer;
25
- const closed = () => {
26
- clearTimeout(timer);
27
- resolve(true);
28
- };
29
- timer = setTimeout(() => {
30
- child.off("close", closed);
31
- resolve(false);
32
- }, timeoutMs);
33
- child.once("close", closed);
34
- });
35
- }
36
-
37
- function runTaskkill(pid, spawnProcess) {
38
- return new Promise((resolve) => {
39
- let killer;
40
- let settled = false;
41
- let timer;
42
- const finish = (success) => {
43
- if (settled) return;
44
- settled = true;
45
- clearTimeout(timer);
46
- resolve(success);
47
- };
48
- try {
49
- killer = spawnProcess("taskkill.exe", ["/pid", String(pid), "/T", "/F"], {
50
- shell: false, stdio: "ignore", windowsHide: true
51
- });
52
- } catch {
53
- finish(false);
54
- return;
55
- }
56
- timer = setTimeout(() => {
57
- try { killer.kill(); } catch {}
58
- finish(false);
59
- }, TASKKILL_TIMEOUT_MS);
60
- killer.once("error", () => finish(false));
61
- killer.once("close", (code) => finish(code === 0));
62
- });
63
- }
64
-
65
- function signalUnixGroup(child, signal) {
66
- try {
67
- process.kill(-child.pid, signal);
68
- return true;
69
- } catch (error) {
70
- if (error?.code === "ESRCH") return true;
71
- try { return child.kill(signal); } catch { return false; }
72
- }
73
- }
74
-
75
- export async function terminateProcessTree(child, {
76
- platform = process.platform,
77
- spawnProcess = nodeSpawn,
78
- graceMs = 1_000
79
- } = {}) {
80
- if (!running(child)) return { terminated: true, method: "already-closed" };
81
- let method;
82
- if (platform === "win32") {
83
- method = await runTaskkill(child.pid, spawnProcess) ? "taskkill-tree" : "taskkill-fallback";
84
- if (running(child) && method === "taskkill-fallback") {
85
- try { child.kill("SIGKILL"); } catch {}
86
- }
87
- } else {
88
- method = "process-group";
89
- signalUnixGroup(child, "SIGTERM");
90
- }
91
- if (await waitForClose(child, graceMs)) return { terminated: true, method };
92
- if (platform === "win32") {
93
- try { child.kill("SIGKILL"); } catch {}
94
- } else {
95
- signalUnixGroup(child, "SIGKILL");
96
- }
97
- return { terminated: await waitForClose(child, graceMs), method };
98
- }
99
-
100
- function appendCaptured(current, chunk) {
101
- if (current.length >= MAX_CAPTURE_CHARS) return current;
102
- const next = current + chunk;
103
- if (next.length <= MAX_CAPTURE_CHARS) return next;
104
- return next.slice(0, MAX_CAPTURE_CHARS) + "\n[output truncated by hermetic runner]\n";
105
- }
106
-
107
- function progressLine(stream, label, status) {
108
- stream?.write(`[${label}] ${status}\n`);
109
- }
110
-
111
- export function configuredTestTimeout(environment = process.env) {
112
- const raw = environment.AGENTSPINE_TEST_FILE_TIMEOUT_MS;
113
- if (raw === undefined || raw === "") return DEFAULT_TEST_TIMEOUT_MS;
114
- const value = Number(raw);
115
- if (!Number.isSafeInteger(value) || value < 1_000 || value > 900_000) {
116
- throw new Error("AGENTSPINE_TEST_FILE_TIMEOUT_MS must be an integer from 1000 to 900000");
117
- }
118
- return value;
119
- }
120
-
121
- export function runBoundedProcess({
122
- command,
123
- args = [],
124
- options = {},
125
- label,
126
- timeoutMs,
127
- terminationGraceMs = 1_000,
128
- progress = process.stdout,
129
- platform = process.platform,
130
- spawnProcess = nodeSpawn
131
- }) {
132
- if (!command || !label || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
133
- throw new Error("command, label, and a positive integer timeoutMs are required");
134
- }
135
- const startedAt = Date.now();
136
- progressLine(progress, label, "START");
137
- return new Promise((resolve) => {
138
- let child;
139
- try {
140
- child = spawnProcess(command, args, {
141
- ...options,
142
- detached: platform !== "win32",
143
- shell: false,
144
- stdio: ["ignore", "pipe", "pipe"],
145
- windowsHide: true
146
- });
147
- } catch (error) {
148
- progressLine(progress, label, `FAIL spawn: ${error.message}`);
149
- resolve({ code: 1, signal: null, timedOut: false, stdout: "", stderr: error.message,
150
- durationMs: Date.now() - startedAt });
151
- return;
152
- }
153
- let stdout = "";
154
- let stderr = "";
155
- let settled = false;
156
- let timedOut = false;
157
- child.stdout?.setEncoding("utf8");
158
- child.stderr?.setEncoding("utf8");
159
- child.stdout?.on("data", (chunk) => { stdout = appendCaptured(stdout, chunk); });
160
- child.stderr?.on("data", (chunk) => { stderr = appendCaptured(stderr, chunk); });
161
-
162
- const finish = (code, signal, error = null) => {
163
- if (settled) return;
164
- settled = true;
165
- clearTimeout(timer);
166
- const durationMs = Date.now() - startedAt;
167
- const finalCode = timedOut ? TIMEOUT_EXIT_CODE : (code ?? 1);
168
- if (timedOut) progressLine(progress, label, `TIMEOUT after ${timeoutMs}ms`);
169
- else if (finalCode === 0) progressLine(progress, label, `PASS in ${durationMs}ms`);
170
- else progressLine(progress, label, `FAIL with code ${finalCode}`);
171
- if (error) stderr = appendCaptured(stderr, error.message || String(error));
172
- if (timedOut) stderr = appendCaptured(stderr,
173
- `\nHermetic child timed out after ${timeoutMs}ms and its process tree was terminated.\n`);
174
- resolve({ code: finalCode, signal, timedOut, stdout, stderr, durationMs });
175
- };
176
- const timer = setTimeout(() => {
177
- timedOut = true;
178
- void terminateProcessTree(child, {
179
- platform, spawnProcess, graceMs: terminationGraceMs
180
- }).finally(() => {
181
- if (!settled) {
182
- child.stdout?.destroy();
183
- child.stderr?.destroy();
184
- finish(TIMEOUT_EXIT_CODE, "SIGKILL");
185
- }
186
- });
187
- }, timeoutMs);
188
- child.once("error", (error) => finish(1, null, error));
189
- child.once("close", (code, signal) => finish(code, signal));
190
- });
191
- }
@@ -1,150 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
- import { readFile } from "node:fs/promises";
4
- import { resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
8
- // Includes the bounded user-feedback candidate path; this is not semantic acceptance.
9
- // Measured code growth before documentation: 1874 packed / 7830 unpacked bytes.
10
- const MAX_PACKED_BYTES = 544 * 1024;
11
- const MAX_UNPACKED_BYTES = 2430 * 1024;
12
- const REQUIRED_PACKAGE_FILES = [
13
- "blun.plugin.json", ".claude-plugin/plugin.json", ".codex-plugin/plugin.json", ".mcp.json",
14
- "CHANGELOG.md", "LICENSE", "README.md", "bin/agentspine.js", "bin/agentspine-mcp.js",
15
- "src/codex-reader-launcher.js", "src/lib/codex-installation.js",
16
- "src/lib/codex-skill-installation.js", "src/cli-host.js",
17
- "docs/acceptance.md", "docs/source-roots.md", "docs/preflight-recall.md", "docs/preservation-contract.md",
18
- "docs/world-model.md", "docs/session-timeline.md", "scripts/run-acceptance.js", "skills/agent-spine/SKILL.md",
19
- "docs/artifact-evaluation.md", "src/lib/learning-artifact-evaluator.js",
20
- "src/lib/gateway-group-response.js", "src/lib/channel-continuity.js",
21
- "src/index.js", "src/mcp.js", "src/lib/mcp-world-tools.js", "src/lib/world-model.js", "src/lib/session-timeline.js",
22
- "src/lib/session-timeline-auth.js", "src/lib/session-timeline-results.js", "src/lib/session-timeline-state.js", "src/lib/mcp-timeline-tools.js", "src/worker.js",
23
- "src/lib/timeline-world-capture.js",
24
- "src/lib/timeline-user-feedback.js",
25
- "hooks/hooks.json", "hooks/codex.json", "hooks/version.json"
26
- ];
27
- const FORBIDDEN_PACKAGE_PATHS = [
28
- /(?:^|\/)\.env(?:\.|$)/i,
29
- /(?:^|\/)\.git(?:$|\/)/i,
30
- /(?:^|\/)\.agentspine(?:$|\/)/i,
31
- /(?:^|\/)(?:AGENTS|CLAUDE|SOUL|MEMORY)\.md$/i,
32
- /(?:^|\/)(?:test|\.github)(?:$|\/)/,
33
- /\.(?:key|pem|p12|pfx)$/i,
34
- /(?:^|\/)state\.json$/i,
35
- /(?:^|\/)(?:catalog|graph|world-model|attention|learning|coordination|sharing|sharing-trust|delegation-policy|session-timeline|lesson-recall-sessions)\.json$/,
36
- /(?:^|\/)session-timeline-head-[a-f0-9]+\.json$/
37
- ];
38
-
39
- function parse(argv) {
40
- const options = { root: process.cwd(), tag: null, allowDirty: false, skipPack: false, json: false };
41
- for (let index = 0; index < argv.length; index += 1) {
42
- const token = argv[index];
43
- if (token === "--root") options.root = argv[++index];
44
- else if (token === "--tag") options.tag = argv[++index];
45
- else if (token === "--allow-dirty") options.allowDirty = true;
46
- else if (token === "--skip-pack") options.skipPack = true;
47
- else if (token === "--json") options.json = true;
48
- else throw new Error(`unknown release-check argument: ${token}`);
49
- }
50
- options.root = resolve(options.root);
51
- return options;
52
- }
53
-
54
- async function json(root, path) {
55
- return JSON.parse(await readFile(resolve(root, path), "utf8"));
56
- }
57
-
58
- function command(root, args) {
59
- const npmCli = process.env.npm_execpath;
60
- const executable = npmCli ? process.execPath : (process.platform === "win32" ? "npm.cmd" : "npm");
61
- const commandArgs = npmCli ? [npmCli, ...args] : args;
62
- return spawnSync(executable, commandArgs, { cwd: root, encoding: "utf8" });
63
- }
64
-
65
- function git(root, args) {
66
- return spawnSync("git", args, { cwd: root, encoding: "utf8" });
67
- }
68
-
69
- function assert(condition, message) {
70
- if (!condition) throw new Error(message);
71
- }
72
-
73
- function validatePackageReport(report, version) {
74
- assert(Array.isArray(report) && report.length === 1, "npm pack report must describe exactly one package");
75
- const item = report[0];
76
- assert(item.version === version, "npm pack version does not match package.json");
77
- assert(typeof item.filename === "string" && item.filename.endsWith(`-${version}.tgz`), "npm pack filename is not versioned correctly");
78
- assert(typeof item.integrity === "string" && item.integrity.startsWith("sha512-"), "npm pack did not report SHA-512 integrity");
79
- assert(Number.isInteger(item.entryCount) && item.entryCount > 0 && item.entryCount <= 500, "npm package file count is outside the release limit");
80
- assert(Number.isInteger(item.size) && item.size > 0 && item.size <= MAX_PACKED_BYTES, "npm package exceeds the 544 KiB packed release limit");
81
- assert(Number.isInteger(item.unpackedSize) && item.unpackedSize > 0 && item.unpackedSize <= MAX_UNPACKED_BYTES, "npm package exceeds the 2430 KiB unpacked release limit");
82
- const paths = (item.files || []).map((file) => file.path);
83
- assert(paths.length === new Set(paths).size, "npm package contains duplicate paths");
84
- for (const path of REQUIRED_PACKAGE_FILES) assert(paths.includes(path), `npm package is missing required file: ${path}`);
85
- for (const path of paths) {
86
- assert(path && !path.startsWith("/") && !path.split("/").includes(".."), `npm package contains an unsafe path: ${path}`);
87
- assert(!FORBIDDEN_PACKAGE_PATHS.some((pattern) => pattern.test(path)), `npm package contains forbidden state or source material: ${path}`);
88
- }
89
- return {
90
- filename: item.filename, integrity: item.integrity, files: paths.length,
91
- packedSize: item.size, unpackedSize: item.unpackedSize
92
- };
93
- }
94
-
95
- export async function releaseCheck(options) {
96
- const [pkg, lock, blun, claude, codex, marketplace, hookVersion, changelog,
97
- runtimeVersionSource] = await Promise.all([
98
- json(options.root, "package.json"), json(options.root, "package-lock.json"),
99
- json(options.root, "blun.plugin.json"),
100
- json(options.root, ".claude-plugin/plugin.json"), json(options.root, ".codex-plugin/plugin.json"),
101
- json(options.root, ".claude-plugin/marketplace.json"), json(options.root, "hooks/version.json"),
102
- readFile(resolve(options.root, "CHANGELOG.md"), "utf8"),
103
- readFile(resolve(options.root, "src/version.js"), "utf8")
104
- ]);
105
- assert(SEMVER_RE.test(pkg.version || ""), "package version is not valid SemVer");
106
- const versions = [lock.version, lock.packages?.[""]?.version, blun.version, claude.version, codex.version, marketplace.plugins?.[0]?.version, hookVersion.version];
107
- assert(versions.every((version) => version === pkg.version), "release version differs across package and host manifests");
108
- const runtimeVersion = runtimeVersionSource.match(/^export const VERSION = "([^"]+)";\s*$/)?.[1];
109
- assert(runtimeVersion === pkg.version, "release version differs from src/version.js");
110
- assert(pkg.name === lock.name && pkg.name === lock.packages?.[""]?.name, "package name differs from package-lock.json");
111
- assert(codex.hooks === "./hooks/codex.json", "Codex release manifest must select hooks/codex.json");
112
- assert(pkg.repository?.url === "git+https://github.com/Maykbiletti/AgentSpine.git", "package repository must identify the public source repository exactly");
113
- if (options.tag) {
114
- assert(options.tag === `v${pkg.version}`, `release tag must be v${pkg.version}`);
115
- const escaped = pkg.version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
116
- assert(new RegExp(`^## \\[${escaped}\\] - \\d{4}-\\d{2}-\\d{2}$`, "m").test(changelog), `CHANGELOG.md needs a dated ${pkg.version} section`);
117
- }
118
- if (!options.allowDirty) {
119
- const status = git(options.root, ["status", "--porcelain"]);
120
- assert(status.status === 0, status.stderr || "git status failed");
121
- assert(status.stdout.trim() === "", "release worktree must be clean");
122
- }
123
- let packageReport = null;
124
- if (!options.skipPack) {
125
- const packed = command(options.root, ["pack", "--dry-run", "--ignore-scripts", "--json"]);
126
- assert(packed.status === 0, packed.stderr || "npm pack --dry-run failed");
127
- packageReport = validatePackageReport(JSON.parse(packed.stdout), pkg.version);
128
- }
129
- return {
130
- ok: true,
131
- version: pkg.version,
132
- tag: options.tag,
133
- cleanRequired: !options.allowDirty,
134
- package: packageReport,
135
- authority: "release-metadata-only"
136
- };
137
- }
138
-
139
- async function main() {
140
- const options = parse(process.argv.slice(2));
141
- const result = await releaseCheck(options);
142
- process.stdout.write(`${JSON.stringify(result, null, options.json ? 2 : 0)}\n`);
143
- }
144
-
145
- if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
146
- main().catch((error) => {
147
- process.stderr.write(`AgentSpine release check failed: ${error.message}\n`);
148
- process.exitCode = 1;
149
- });
150
- }
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- import { resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { renderAcceptanceReport, runVisibleAcceptance } from "../src/lib/acceptance.js";
5
-
6
- export async function main(argv = process.argv.slice(2)) {
7
- const unknown = argv.filter((item) => item !== "--json");
8
- if (unknown.length) throw new Error(`unknown acceptance argument: ${unknown[0]}`);
9
- const report = await runVisibleAcceptance();
10
- process.stdout.write(argv.includes("--json") ? `${JSON.stringify(report, null, 2)}\n` : renderAcceptanceReport(report));
11
- return report;
12
- }
13
-
14
- if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
15
- main().catch((error) => {
16
- process.stderr.write(`AgentSpine acceptance failed: ${error.message}\n`);
17
- process.exitCode = 1;
18
- });
19
- }
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
3
- import { resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { githubErrorCommand } from "./github-actions.js";
6
-
7
- const CHECKS = [
8
- { title: "Syntax check", script: "lint" },
9
- { title: "Line budget", script: "line-budget" },
10
- { title: "Host manifest check", script: "host:check" },
11
- // Exercise the copied-bundle hook deadlines before the hermetic suite creates
12
- // hundreds of short-lived Windows processes. The deadlines and assertions stay
13
- // unchanged; this removes residual runner load from the installed-host probe.
14
- { title: "Installed bundle check", script: "host:install-check" },
15
- { title: "Hermetic test suite", script: "test" },
16
- { title: "Runtime smoke test", script: "smoke" },
17
- { title: "Self audit", script: "audit:self" }
18
- ];
19
-
20
- function runNpmScript(script) {
21
- const npmExecPath = process.env.npm_execpath;
22
- const executable = npmExecPath ? process.execPath : (process.platform === "win32" ? "npm.cmd" : "npm");
23
- const args = npmExecPath ? [npmExecPath, "run", script] : ["run", script];
24
- return new Promise((resolve, reject) => {
25
- const child = spawn(executable, args, { stdio: "inherit", shell: false, windowsHide: true });
26
- child.once("error", reject);
27
- child.once("close", (code) => resolve(code ?? 1));
28
- });
29
- }
30
-
31
- export async function runChecks({
32
- checks = CHECKS, runCommand = runNpmScript, githubActions = process.env.GITHUB_ACTIONS === "true", output = process.stderr
33
- } = {}) {
34
- for (const check of checks) {
35
- let code;
36
- try { code = await runCommand(check.script); }
37
- catch (error) {
38
- if (githubActions) output.write(githubErrorCommand(check.title, error.message) + "\n");
39
- else output.write(`${check.title} failed: ${error.message}\n`);
40
- return 1;
41
- }
42
- if (code !== 0) {
43
- if (githubActions) output.write(githubErrorCommand(check.title, `npm run ${check.script} exited with code ${code}`) + "\n");
44
- return code;
45
- }
46
- }
47
- return 0;
48
- }
49
-
50
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) process.exitCode = await runChecks();
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env node
2
- import { cpus, tmpdir } from "node:os";
3
- import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
4
- import { join, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { githubErrorCommand } from "./github-actions.js";
7
- import { configuredTestTimeout, runBoundedProcess, selectTestShard } from "./hermetic-process.js";
8
-
9
- const root = resolve(fileURLToPath(new URL("..", import.meta.url)));
10
- const base = await mkdtemp(join(tmpdir(), "agentspine-hermetic-tests-"));
11
- const testFiles = selectTestShard((await readdir(join(root, "test")))
12
- .filter((name) => name.endsWith(".test.js")).sort(), process.env.AGENTSPINE_TEST_SHARD);
13
- const win=process.platform==="win32";
14
- const concurrency = Math.max(1, Math.min(win ? 3 : 4, cpus().length));
15
- const testTimeoutMs = configuredTestTimeout();
16
- const slowTestTimeouts = new Map([
17
- ["indexed-memory.test.js", 300_000]
18
- ]);
19
-
20
- function timeoutFor(file) {
21
- if (process.env.AGENTSPINE_TEST_FILE_TIMEOUT_MS) return testTimeoutMs;
22
- return slowTestTimeouts.get(file) || testTimeoutMs;
23
- }
24
-
25
- async function profileEnvironment(mode, index) {
26
- const profile = join(base, mode, String(index));
27
- const home = join(profile, "home"); const claude = join(profile, "claude"); const codex = join(profile, "codex");
28
- const state = join(profile, "state"); const xdgState = join(profile, "xdg-state"); const temporary = join(profile, "tmp");
29
- for (const directory of [home, claude, codex, state, xdgState, temporary]) await mkdir(directory, { recursive: true });
30
- if (mode === "populated") {
31
- await writeFile(join(claude, "CLAUDE.md"), "# Hermetic populated Claude profile\n\nSynthetic global source.\n");
32
- await writeFile(join(codex, "AGENTS.md"), "# Hermetic populated Codex profile\n\nSynthetic global source.\n");
33
- }
34
- const inherited = Object.fromEntries(Object.entries(process.env).filter(([key]) =>
35
- !/^(?:AGENTSPINE_|CLAUDE_|CODEX_|HOME$|USERPROFILE$|XDG_STATE_HOME$|TMPDIR$|TMP$|TEMP$|NODE_OPTIONS$|NODE_PATH$)/.test(key)));
36
- return { ...inherited, HOME: home, USERPROFILE: home, CLAUDE_CONFIG_DIR: claude, CODEX_HOME: codex,
37
- AGENTSPINE_STATE_DIR: state, XDG_STATE_HOME: xdgState, TMPDIR: temporary, TMP: temporary, TEMP: temporary,
38
- AGENTSPINE_HERMETIC_ROOT: profile, AGENTSPINE_TEST_PROFILE: mode };
39
- }
40
-
41
- async function runOne(file, mode, index) {
42
- const env = await profileEnvironment(mode, index);
43
- const result = await runBoundedProcess({
44
- command: process.execPath,
45
- args: ["--test", join(root, "test", file)],
46
- options: { cwd: root, env },
47
- label: `${mode} ${file}`,
48
- timeoutMs: timeoutFor(file)
49
- });
50
- return { ...result, file, mode };
51
- }
52
-
53
- async function runMode(mode) {
54
- const indexed = testFiles.map((file, index) => ({ file, index }));
55
- const results = [];
56
- const isolatedNames = new Set([
57
- "assignment-continuation-boundaries.test.js",
58
- "assignment-continuation.test.js",
59
- "codex-history.test.js",
60
- "hook-artifact-guards.test.js",
61
- "hook.test.js",
62
- "cross-provider-history.test.js",
63
- "delivery-completion.test.js",
64
- "hook-briefing-use.test.js",
65
- "king-history.test.js",
66
- "lesson-recall.test.js",
67
- "mcp-bounded-preflight.test.js",
68
- "mcp-bounded-recovery.test.js",
69
- "package.test.js",
70
- "portal-thread-continuity.test.js",
71
- "mcp.test.js",
72
- "owned-file-lock.test.js",
73
- "session-timeline-host-origin.test.js",
74
- "session-timeline-invocation.test.js",
75
- "timeline-natural-feedback.test.js"
76
- ]);
77
- if (win) for (const { file } of indexed) {
78
- if (file.includes("timeline") || file === "preflight-large-agents.test.js") isolatedNames.add(file);
79
- }
80
- const isolated = indexed.filter(item => isolatedNames.has(item.file));
81
- const queue = indexed.filter(item => !isolatedNames.has(item.file));
82
- for (const item of isolated) results.push(await runOne(item.file, mode, item.index));
83
- async function worker() { while (queue.length) { const item = queue.shift(); results.push(await runOne(item.file, mode, item.index)); } }
84
- await Promise.all(Array.from({ length: concurrency }, () => worker()));
85
- for (const result of results.sort((a, b) => a.file.localeCompare(b.file))) {
86
- if (result.code !== 0) {
87
- if (process.env.GITHUB_ACTIONS === "true") {
88
- process.stderr.write(githubErrorCommand(`${mode}: ${result.file}`, result.stdout + result.stderr) + "\n");
89
- }
90
- process.stderr.write("\n[" + mode + "] " + result.file + " failed\n" + result.stdout + result.stderr);
91
- }
92
- }
93
- return results;
94
- }
95
-
96
- let failed = false; let runnerError = null;
97
- try {
98
- for (const mode of ["empty", "populated"]) {
99
- const results = await runMode(mode); const failures = results.filter((item) => item.code !== 0);
100
- process.stdout.write("Hermetic " + mode + " profile: " + (results.length - failures.length) + "/" + results.length + " test files passed\n");
101
- if (failures.length) failed = true;
102
- }
103
- } catch (error) { runnerError = error; }
104
- try { await rm(base, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }); }
105
- catch (error) { runnerError = runnerError ? new AggregateError([runnerError, error], "Hermetic test run and cleanup failed") : error; }
106
- if (runnerError) {
107
- if (process.env.GITHUB_ACTIONS === "true") {
108
- process.stderr.write(githubErrorCommand("Hermetic test runner", runnerError.stack || runnerError.message) + "\n");
109
- }
110
- throw runnerError;
111
- }
112
- if (failed) process.exitCode = 1;