@voybio/ace-swarm 0.1.0

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 (334) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/LICENSE +186 -0
  3. package/README.md +229 -0
  4. package/assets/.agents/ACE/ACE-Init/AGENTS.md +210 -0
  5. package/assets/.agents/ACE/ACE-Init/instructions.md +118 -0
  6. package/assets/.agents/ACE/ACE_coders/AGENTS.md +154 -0
  7. package/assets/.agents/ACE/ACE_coders/INSTRUCTIONS.md +216 -0
  8. package/assets/.agents/ACE/AGENT_REGISTRY.md +70 -0
  9. package/assets/.agents/ACE/AGENT_REGISTRY_7.md +9 -0
  10. package/assets/.agents/ACE/DIRECTIVE_KERNEL.md +234 -0
  11. package/assets/.agents/ACE/UI/AGENTS.md +115 -0
  12. package/assets/.agents/ACE/UI/instructions.md +178 -0
  13. package/assets/.agents/ACE/VOS/ACE_VOS_MISSING_INFO_MATRIX.md +42 -0
  14. package/assets/.agents/ACE/VOS/AGENTS.md +72 -0
  15. package/assets/.agents/ACE/VOS/instructions.md +211 -0
  16. package/assets/.agents/ACE/agent-astgrep/AGENTS.md +123 -0
  17. package/assets/.agents/ACE/agent-astgrep/instructions.md +91 -0
  18. package/assets/.agents/ACE/agent-builder/AGENTS.md +172 -0
  19. package/assets/.agents/ACE/agent-builder/instructions.md +137 -0
  20. package/assets/.agents/ACE/agent-docs/AGENTS.md +159 -0
  21. package/assets/.agents/ACE/agent-docs/instructions.md +133 -0
  22. package/assets/.agents/ACE/agent-eval/AGENTS.md +46 -0
  23. package/assets/.agents/ACE/agent-eval/instructions.md +56 -0
  24. package/assets/.agents/ACE/agent-memory/AGENTS.md +49 -0
  25. package/assets/.agents/ACE/agent-memory/instructions.md +50 -0
  26. package/assets/.agents/ACE/agent-observability/AGENTS.md +46 -0
  27. package/assets/.agents/ACE/agent-observability/instructions.md +50 -0
  28. package/assets/.agents/ACE/agent-ops/AGENTS.md +201 -0
  29. package/assets/.agents/ACE/agent-ops/instructions.md +136 -0
  30. package/assets/.agents/ACE/agent-qa/AGENTS.md +189 -0
  31. package/assets/.agents/ACE/agent-qa/instructions.md +121 -0
  32. package/assets/.agents/ACE/agent-release/AGENTS.md +48 -0
  33. package/assets/.agents/ACE/agent-release/instructions.md +49 -0
  34. package/assets/.agents/ACE/agent-research/AGENTS.md +160 -0
  35. package/assets/.agents/ACE/agent-research/instructions.md +118 -0
  36. package/assets/.agents/ACE/agent-security/AGENTS.md +48 -0
  37. package/assets/.agents/ACE/agent-security/instructions.md +50 -0
  38. package/assets/.agents/ACE/agent-skeptic/AGENTS.md +178 -0
  39. package/assets/.agents/ACE/agent-skeptic/instructions.md +196 -0
  40. package/assets/.agents/ACE/agent-spec/AGENTS.md +169 -0
  41. package/assets/.agents/ACE/agent-spec/instructions.md +116 -0
  42. package/assets/.agents/ACE/orchestrator/AGENTS.md +365 -0
  43. package/assets/.agents/ACE/orchestrator/instructions.md +231 -0
  44. package/assets/.agents/skills/ace-orchestrator/SKILL.md +63 -0
  45. package/assets/.agents/skills/ace-orchestrator/references/engineering-bootstrap-playbook.md +360 -0
  46. package/assets/.agents/skills/astgrep-index/SKILL.md +58 -0
  47. package/assets/.agents/skills/codemunch/SKILL.md +65 -0
  48. package/assets/.agents/skills/codemunch/references/ast-driven-protocol.md +543 -0
  49. package/assets/.agents/skills/codesnipe/SKILL.md +64 -0
  50. package/assets/.agents/skills/codesnipe/references/dual-codebase-playbook.md +671 -0
  51. package/assets/.agents/skills/eval-harness/SKILL.md +203 -0
  52. package/assets/.agents/skills/handoff-lint/SKILL.md +164 -0
  53. package/assets/.agents/skills/incident-commander/SKILL.md +174 -0
  54. package/assets/.agents/skills/landing-review-watcher/SKILL.md +68 -0
  55. package/assets/.agents/skills/memory-curator/SKILL.md +179 -0
  56. package/assets/.agents/skills/problem-triage/SKILL.md +57 -0
  57. package/assets/.agents/skills/problem-triage/agents/openai.yaml +3 -0
  58. package/assets/.agents/skills/release-sentry/SKILL.md +189 -0
  59. package/assets/.agents/skills/risk-quant/SKILL.md +190 -0
  60. package/assets/.agents/skills/schema-forge/SKILL.md +174 -0
  61. package/assets/.agents/skills/skill-auditor/SKILL.md +52 -0
  62. package/assets/.agents/skills/state-auditor/SKILL.md +182 -0
  63. package/assets/.github/hooks/ace-copilot.json +68 -0
  64. package/assets/agent-state/ACE_WORKFLOW.md +131 -0
  65. package/assets/agent-state/ARTIFACT_MANIFEST.json +5 -0
  66. package/assets/agent-state/AST_GREP_COMMANDS.md +121 -0
  67. package/assets/agent-state/AST_GREP_INDEX.json +13 -0
  68. package/assets/agent-state/AST_GREP_INDEX.md +15 -0
  69. package/assets/agent-state/DECISIONS.md +7 -0
  70. package/assets/agent-state/EVIDENCE_LOG.md +7 -0
  71. package/assets/agent-state/HANDOFF.json +24 -0
  72. package/assets/agent-state/INTERFACE_REGISTRY.md +75 -0
  73. package/assets/agent-state/MODULES/gates/gate-autonomy.json +7 -0
  74. package/assets/agent-state/MODULES/gates/gate-completeness.json +7 -0
  75. package/assets/agent-state/MODULES/gates/gate-correctness.json +7 -0
  76. package/assets/agent-state/MODULES/gates/gate-evaluation.json +7 -0
  77. package/assets/agent-state/MODULES/gates/gate-operability.json +7 -0
  78. package/assets/agent-state/MODULES/gates/gate-security.json +7 -0
  79. package/assets/agent-state/MODULES/gates/gate-typescript-public-surface.json +7 -0
  80. package/assets/agent-state/MODULES/registry.json +41 -0
  81. package/assets/agent-state/MODULES/roles/capability-astgrep.json +49 -0
  82. package/assets/agent-state/MODULES/roles/capability-build.json +39 -0
  83. package/assets/agent-state/MODULES/roles/capability-docs.json +38 -0
  84. package/assets/agent-state/MODULES/roles/capability-eval.json +20 -0
  85. package/assets/agent-state/MODULES/roles/capability-memory.json +20 -0
  86. package/assets/agent-state/MODULES/roles/capability-observability.json +20 -0
  87. package/assets/agent-state/MODULES/roles/capability-ops.json +45 -0
  88. package/assets/agent-state/MODULES/roles/capability-qa.json +40 -0
  89. package/assets/agent-state/MODULES/roles/capability-release.json +21 -0
  90. package/assets/agent-state/MODULES/roles/capability-research.json +44 -0
  91. package/assets/agent-state/MODULES/roles/capability-security.json +21 -0
  92. package/assets/agent-state/MODULES/roles/capability-skeptic.json +48 -0
  93. package/assets/agent-state/MODULES/roles/capability-spec.json +42 -0
  94. package/assets/agent-state/MODULES/schemas/ACE_RUNTIME_PROFILE.schema.json +289 -0
  95. package/assets/agent-state/MODULES/schemas/ARTIFACT_MANIFEST.schema.json +185 -0
  96. package/assets/agent-state/MODULES/schemas/HANDOFF.agent-state.schema.json +124 -0
  97. package/assets/agent-state/MODULES/schemas/HANDOFF.schema.json +55 -0
  98. package/assets/agent-state/MODULES/schemas/RUNTIME_EXECUTOR_SESSION_REGISTRY.schema.json +290 -0
  99. package/assets/agent-state/MODULES/schemas/RUNTIME_TOOL_SPEC_REGISTRY.schema.json +144 -0
  100. package/assets/agent-state/MODULES/schemas/STATUS_EVENT.schema.json +84 -0
  101. package/assets/agent-state/MODULES/schemas/SWARM_HANDOFF.schema.json +138 -0
  102. package/assets/agent-state/MODULES/schemas/TRACKER_SNAPSHOT.schema.json +134 -0
  103. package/assets/agent-state/MODULES/schemas/VERICIFY_BRIDGE_SNAPSHOT.schema.json +157 -0
  104. package/assets/agent-state/MODULES/schemas/VERICIFY_PROCESS_POST_LOG.schema.json +93 -0
  105. package/assets/agent-state/MODULES/schemas/WORKSPACE_SESSION_REGISTRY.schema.json +133 -0
  106. package/assets/agent-state/PROVENANCE_LOG.md +28 -0
  107. package/assets/agent-state/QUALITY_GATES.md +15 -0
  108. package/assets/agent-state/RISKS.md +8 -0
  109. package/assets/agent-state/SCOPE.md +20 -0
  110. package/assets/agent-state/SKILL_CATALOG.md +48 -0
  111. package/assets/agent-state/STATUS.md +8 -0
  112. package/assets/agent-state/STATUS_EVENTS.ndjson +1 -0
  113. package/assets/agent-state/TASK.md +18 -0
  114. package/assets/agent-state/TEAL_CONFIG.md +117 -0
  115. package/assets/agent-state/handoff-registry.json +5 -0
  116. package/assets/agent-state/index-fingerprints.json +7 -0
  117. package/assets/agent-state/index.json +32 -0
  118. package/assets/agent-state/run-ledger.json +5 -0
  119. package/assets/agent-state/runtime-executor-sessions.json +5 -0
  120. package/assets/agent-state/runtime-tool-specs.json +5 -0
  121. package/assets/agent-state/runtime-workspaces.json +5 -0
  122. package/assets/agent-state/todo-state.json +7 -0
  123. package/assets/agent-state/tracker-snapshot.json +7 -0
  124. package/assets/agent-state/vericify/ace-bridge.json +60 -0
  125. package/assets/agent-state/vericify/process-posts.json +5 -0
  126. package/assets/instructions/ACE.instructions.md +187 -0
  127. package/assets/instructions/ACE_Coder.instructions.md +146 -0
  128. package/assets/instructions/ACE_UI.instructions.md +178 -0
  129. package/assets/instructions/ACE_VOS.instructions.md +211 -0
  130. package/assets/scripts/ace-hook-dispatch.mjs +538 -0
  131. package/assets/scripts/bootstrap-workspace.sh +27 -0
  132. package/assets/scripts/copilot-hook-dispatch.mjs +3 -0
  133. package/assets/scripts/eval-harness.sh +68 -0
  134. package/assets/scripts/render-mcp-configs.sh +396 -0
  135. package/assets/tasks/README.md +48 -0
  136. package/assets/tasks/SWARM_HANDOFF.example.json +53 -0
  137. package/assets/tasks/SWARM_HANDOFF.example_ui_to_coders.json +55 -0
  138. package/assets/tasks/SWARM_HANDOFF.example_vos_to_ui.json +55 -0
  139. package/assets/tasks/SWARM_HANDOFF.template.json +52 -0
  140. package/assets/tasks/cli_work_split.md +22 -0
  141. package/assets/tasks/lessons.md +17 -0
  142. package/assets/tasks/role_tasks.md +206 -0
  143. package/assets/tasks/todo.md +23 -0
  144. package/dist/ace-autonomy.d.ts +137 -0
  145. package/dist/ace-autonomy.js +472 -0
  146. package/dist/ace-context.d.ts +29 -0
  147. package/dist/ace-context.js +240 -0
  148. package/dist/ace-internal-tools.d.ts +8 -0
  149. package/dist/ace-internal-tools.js +76 -0
  150. package/dist/ace-server-instructions.d.ts +12 -0
  151. package/dist/ace-server-instructions.js +324 -0
  152. package/dist/agent-runtime/role-adapters.d.ts +29 -0
  153. package/dist/agent-runtime/role-adapters.js +573 -0
  154. package/dist/astgrep-index.d.ts +24 -0
  155. package/dist/astgrep-index.js +476 -0
  156. package/dist/cli.d.ts +3 -0
  157. package/dist/cli.js +591 -0
  158. package/dist/git-ops.d.ts +53 -0
  159. package/dist/git-ops.js +238 -0
  160. package/dist/handoff-registry.d.ts +71 -0
  161. package/dist/handoff-registry.js +422 -0
  162. package/dist/helpers.d.ts +126 -0
  163. package/dist/helpers.js +1687 -0
  164. package/dist/index-store.d.ts +51 -0
  165. package/dist/index-store.js +328 -0
  166. package/dist/index.d.ts +3 -0
  167. package/dist/index.js +7 -0
  168. package/dist/internal-tool-runtime.d.ts +21 -0
  169. package/dist/internal-tool-runtime.js +136 -0
  170. package/dist/job-scheduler.d.ts +175 -0
  171. package/dist/job-scheduler.js +1217 -0
  172. package/dist/kanban.d.ts +27 -0
  173. package/dist/kanban.js +339 -0
  174. package/dist/local-model-runtime.d.ts +40 -0
  175. package/dist/local-model-runtime.js +174 -0
  176. package/dist/model-bridge.d.ts +54 -0
  177. package/dist/model-bridge.js +587 -0
  178. package/dist/orchestrator-supervisor.d.ts +100 -0
  179. package/dist/orchestrator-supervisor.js +399 -0
  180. package/dist/problem-triage.d.ts +23 -0
  181. package/dist/problem-triage.js +448 -0
  182. package/dist/prompts.d.ts +7 -0
  183. package/dist/prompts.js +628 -0
  184. package/dist/public-surface.d.ts +30 -0
  185. package/dist/public-surface.js +316 -0
  186. package/dist/resources.d.ts +7 -0
  187. package/dist/resources.js +545 -0
  188. package/dist/run-ledger.d.ts +36 -0
  189. package/dist/run-ledger.js +257 -0
  190. package/dist/runtime-command.d.ts +18 -0
  191. package/dist/runtime-command.js +76 -0
  192. package/dist/runtime-executor.d.ts +104 -0
  193. package/dist/runtime-executor.js +985 -0
  194. package/dist/runtime-profile.d.ts +116 -0
  195. package/dist/runtime-profile.js +532 -0
  196. package/dist/runtime-tool-specs.d.ts +68 -0
  197. package/dist/runtime-tool-specs.js +527 -0
  198. package/dist/safe-edit.d.ts +52 -0
  199. package/dist/safe-edit.js +255 -0
  200. package/dist/schemas.d.ts +44 -0
  201. package/dist/schemas.js +830 -0
  202. package/dist/semantic-cache.d.ts +147 -0
  203. package/dist/semantic-cache.js +552 -0
  204. package/dist/semantic-hash.d.ts +83 -0
  205. package/dist/semantic-hash.js +346 -0
  206. package/dist/server.d.ts +10 -0
  207. package/dist/server.js +46 -0
  208. package/dist/shared.d.ts +136 -0
  209. package/dist/shared.js +269 -0
  210. package/dist/skill-auditor.d.ts +26 -0
  211. package/dist/skill-auditor.js +184 -0
  212. package/dist/skill-catalog.d.ts +60 -0
  213. package/dist/skill-catalog.js +305 -0
  214. package/dist/status-events.d.ts +40 -0
  215. package/dist/status-events.js +269 -0
  216. package/dist/store/ace-packed-store.d.ts +69 -0
  217. package/dist/store/ace-packed-store.js +434 -0
  218. package/dist/store/bootstrap-store.d.ts +46 -0
  219. package/dist/store/bootstrap-store.js +242 -0
  220. package/dist/store/catalog-builder.d.ts +21 -0
  221. package/dist/store/catalog-builder.js +68 -0
  222. package/dist/store/importer.d.ts +19 -0
  223. package/dist/store/importer.js +157 -0
  224. package/dist/store/knowledge-bake.d.ts +59 -0
  225. package/dist/store/knowledge-bake.js +339 -0
  226. package/dist/store/materializers/hook-context-materializer.d.ts +25 -0
  227. package/dist/store/materializers/hook-context-materializer.js +100 -0
  228. package/dist/store/materializers/host-file-materializer.d.ts +37 -0
  229. package/dist/store/materializers/host-file-materializer.js +271 -0
  230. package/dist/store/materializers/todo-syncer.d.ts +30 -0
  231. package/dist/store/materializers/todo-syncer.js +140 -0
  232. package/dist/store/materializers/vericify-projector.d.ts +38 -0
  233. package/dist/store/materializers/vericify-projector.js +239 -0
  234. package/dist/store/repositories/discovery-repository.d.ts +24 -0
  235. package/dist/store/repositories/discovery-repository.js +58 -0
  236. package/dist/store/repositories/handoff-repository.d.ts +31 -0
  237. package/dist/store/repositories/handoff-repository.js +67 -0
  238. package/dist/store/repositories/ledger-repository.d.ts +26 -0
  239. package/dist/store/repositories/ledger-repository.js +49 -0
  240. package/dist/store/repositories/runtime-kv-repository.d.ts +16 -0
  241. package/dist/store/repositories/runtime-kv-repository.js +36 -0
  242. package/dist/store/repositories/scheduler-repository.d.ts +50 -0
  243. package/dist/store/repositories/scheduler-repository.js +123 -0
  244. package/dist/store/repositories/session-repository.d.ts +33 -0
  245. package/dist/store/repositories/session-repository.js +82 -0
  246. package/dist/store/repositories/todo-repository.d.ts +31 -0
  247. package/dist/store/repositories/todo-repository.js +77 -0
  248. package/dist/store/repositories/tracker-repository.d.ts +25 -0
  249. package/dist/store/repositories/tracker-repository.js +43 -0
  250. package/dist/store/repositories/vericify-repository.d.ts +32 -0
  251. package/dist/store/repositories/vericify-repository.js +58 -0
  252. package/dist/store/skills-install.d.ts +28 -0
  253. package/dist/store/skills-install.js +86 -0
  254. package/dist/store/state-reader.d.ts +49 -0
  255. package/dist/store/state-reader.js +111 -0
  256. package/dist/store/store-artifacts.d.ts +12 -0
  257. package/dist/store/store-artifacts.js +138 -0
  258. package/dist/store/store-snapshot.d.ts +19 -0
  259. package/dist/store/store-snapshot.js +140 -0
  260. package/dist/store/topology-bake.d.ts +15 -0
  261. package/dist/store/topology-bake.js +215 -0
  262. package/dist/store/types.d.ts +155 -0
  263. package/dist/store/types.js +35 -0
  264. package/dist/store/workspace-snapshot.d.ts +26 -0
  265. package/dist/store/workspace-snapshot.js +107 -0
  266. package/dist/store/write-queue.d.ts +7 -0
  267. package/dist/store/write-queue.js +26 -0
  268. package/dist/todo-state.d.ts +41 -0
  269. package/dist/todo-state.js +399 -0
  270. package/dist/tools-agent.d.ts +7 -0
  271. package/dist/tools-agent.js +1542 -0
  272. package/dist/tools-discovery.d.ts +6 -0
  273. package/dist/tools-discovery.js +178 -0
  274. package/dist/tools-drift.d.ts +13 -0
  275. package/dist/tools-drift.js +357 -0
  276. package/dist/tools-files.d.ts +6 -0
  277. package/dist/tools-files.js +679 -0
  278. package/dist/tools-framework.d.ts +7 -0
  279. package/dist/tools-framework.js +1414 -0
  280. package/dist/tools-git.d.ts +6 -0
  281. package/dist/tools-git.js +183 -0
  282. package/dist/tools-handoff.d.ts +32 -0
  283. package/dist/tools-handoff.js +489 -0
  284. package/dist/tools-lifecycle.d.ts +6 -0
  285. package/dist/tools-lifecycle.js +205 -0
  286. package/dist/tools-memory.d.ts +6 -0
  287. package/dist/tools-memory.js +260 -0
  288. package/dist/tools-scheduler.d.ts +6 -0
  289. package/dist/tools-scheduler.js +228 -0
  290. package/dist/tools-skills.d.ts +3 -0
  291. package/dist/tools-skills.js +104 -0
  292. package/dist/tools-todo.d.ts +6 -0
  293. package/dist/tools-todo.js +154 -0
  294. package/dist/tools.d.ts +9 -0
  295. package/dist/tools.js +33 -0
  296. package/dist/tracker-adapters.d.ts +74 -0
  297. package/dist/tracker-adapters.js +776 -0
  298. package/dist/tracker-sync.d.ts +10 -0
  299. package/dist/tracker-sync.js +84 -0
  300. package/dist/tui/agent-runner.d.ts +137 -0
  301. package/dist/tui/agent-runner.js +466 -0
  302. package/dist/tui/agent-worker.d.ts +10 -0
  303. package/dist/tui/agent-worker.js +347 -0
  304. package/dist/tui/chat.d.ts +84 -0
  305. package/dist/tui/chat.js +368 -0
  306. package/dist/tui/commands.d.ts +57 -0
  307. package/dist/tui/commands.js +432 -0
  308. package/dist/tui/dashboard.d.ts +24 -0
  309. package/dist/tui/dashboard.js +110 -0
  310. package/dist/tui/index.d.ts +114 -0
  311. package/dist/tui/index.js +1059 -0
  312. package/dist/tui/input.d.ts +49 -0
  313. package/dist/tui/input.js +336 -0
  314. package/dist/tui/layout.d.ts +116 -0
  315. package/dist/tui/layout.js +367 -0
  316. package/dist/tui/ollama.d.ts +116 -0
  317. package/dist/tui/ollama.js +192 -0
  318. package/dist/tui/openai-compatible.d.ts +63 -0
  319. package/dist/tui/openai-compatible.js +370 -0
  320. package/dist/tui/provider-discovery.d.ts +59 -0
  321. package/dist/tui/provider-discovery.js +530 -0
  322. package/dist/tui/renderer.d.ts +166 -0
  323. package/dist/tui/renderer.js +304 -0
  324. package/dist/tui/tabs.d.ts +70 -0
  325. package/dist/tui/tabs.js +208 -0
  326. package/dist/tui/telemetry.d.ts +56 -0
  327. package/dist/tui/telemetry.js +106 -0
  328. package/dist/vericify-bridge.d.ts +146 -0
  329. package/dist/vericify-bridge.js +571 -0
  330. package/dist/vericify-context.d.ts +10 -0
  331. package/dist/vericify-context.js +72 -0
  332. package/dist/workspace-manager.d.ts +107 -0
  333. package/dist/workspace-manager.js +636 -0
  334. package/package.json +83 -0
@@ -0,0 +1,305 @@
1
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
2
+ import { basename, dirname, extname, relative, resolve } from "node:path";
3
+ import { ALL_MCP_CLIENTS, listAvailableSkills, readSkillInstructions, } from "./helpers.js";
4
+ import { listStoreKeysByPathSync, parseVirtualStorePath, readStoreBlobByPathSync, readVirtualStorePathSync, toVirtualStorePath, } from "./store/store-snapshot.js";
5
+ function stripQuotes(value) {
6
+ return value.replace(/^["']+|["']+$/g, "").trim();
7
+ }
8
+ function parseSimpleYamlBlock(raw) {
9
+ const result = {};
10
+ const lines = raw.replace(/\r\n/g, "\n").split("\n");
11
+ let currentKey;
12
+ for (const line of lines) {
13
+ if (!line.trim())
14
+ continue;
15
+ const keyMatch = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
16
+ if (keyMatch) {
17
+ currentKey = keyMatch[1];
18
+ result[currentKey] = stripQuotes(keyMatch[2] ?? "");
19
+ continue;
20
+ }
21
+ if (currentKey && /^[ \t]+/.test(line)) {
22
+ const nextValue = stripQuotes(line.trim());
23
+ result[currentKey] = result[currentKey]
24
+ ? `${result[currentKey]} ${nextValue}`.trim()
25
+ : nextValue;
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ export function parseSkillFrontmatter(raw) {
31
+ const normalized = raw.replace(/\r\n/g, "\n");
32
+ if (!normalized.startsWith("---\n")) {
33
+ return { attributes: {}, body: normalized, has_frontmatter: false };
34
+ }
35
+ const endIndex = normalized.indexOf("\n---\n", 4);
36
+ if (endIndex === -1) {
37
+ return { attributes: {}, body: normalized, has_frontmatter: false };
38
+ }
39
+ const frontmatter = normalized.slice(4, endIndex);
40
+ const body = normalized.slice(endIndex + 5);
41
+ return {
42
+ attributes: parseSimpleYamlBlock(frontmatter),
43
+ body,
44
+ has_frontmatter: true,
45
+ };
46
+ }
47
+ function extractHeadings(markdown) {
48
+ return [...markdown.matchAll(/^##\s+(.+)$/gm)].map((match) => match[1].trim());
49
+ }
50
+ function normalizeHeading(heading) {
51
+ return heading
52
+ .toLowerCase()
53
+ .replace(/[`*_]/g, "")
54
+ .replace(/[^a-z0-9]+/g, " ")
55
+ .trim();
56
+ }
57
+ function hasHeading(headings, terms) {
58
+ return headings.some((heading) => terms.some((term) => heading.includes(term)));
59
+ }
60
+ function bodyMentionsAny(markdown, terms) {
61
+ const text = markdown.toLowerCase();
62
+ return terms.some((term) => text.includes(term));
63
+ }
64
+ function descriptionLooksTriggerAware(description) {
65
+ const text = description.toLowerCase();
66
+ return [
67
+ "when the user",
68
+ "use when",
69
+ "use this",
70
+ "trigger when",
71
+ "asks for",
72
+ "when a task",
73
+ ].some((term) => text.includes(term));
74
+ }
75
+ function hasValidationSurface(markdown, headings) {
76
+ return (hasHeading(headings, ["validation", "verify", "verification", "test", "tests", "canary"]) ||
77
+ bodyMentionsAny(markdown, [
78
+ "validation command",
79
+ "expected evidence",
80
+ "trigger canary",
81
+ "functional canary",
82
+ "baseline comparison",
83
+ "verify by",
84
+ "run this check",
85
+ ]));
86
+ }
87
+ function hasPortabilityNotes(markdown, headings) {
88
+ return (hasHeading(headings, [
89
+ "compatibility",
90
+ "portability",
91
+ "portable",
92
+ "cross platform",
93
+ "cross-platform",
94
+ "client adapters",
95
+ "adapter policy",
96
+ ]) ||
97
+ bodyMentionsAny(markdown, [
98
+ "portable source of truth",
99
+ "portable contract",
100
+ "portable skill",
101
+ "vendor-neutral",
102
+ "cross-platform",
103
+ "cross platform",
104
+ "client-specific",
105
+ "optional overlay",
106
+ "optional adapter",
107
+ "works without",
108
+ ]));
109
+ }
110
+ function resolveOpenAiYamlPath(skillPath) {
111
+ const parsed = parseVirtualStorePath(skillPath);
112
+ if (parsed) {
113
+ const parts = parsed.key.split("/");
114
+ const skillName = parts[2] ?? "";
115
+ const key = `knowledge/skills/${skillName}/agents/openai.yaml`;
116
+ return readStoreBlobByPathSync(parsed.storePath, key)
117
+ ? toVirtualStorePath(parsed.storePath, key)
118
+ : undefined;
119
+ }
120
+ const agentsPath = resolve(dirname(skillPath), "agents", "openai.yaml");
121
+ return existsSync(agentsPath) ? agentsPath : undefined;
122
+ }
123
+ const KNOWN_ADAPTER_CLIENTS = [...ALL_MCP_CLIENTS, "openai", "vscode"];
124
+ const ADAPTER_EXTENSIONS = new Set([".yaml", ".yml", ".json", ".jsonc", ".toml", ".md"]);
125
+ function detectAdapterClient(relativePath) {
126
+ const lower = relativePath.toLowerCase();
127
+ for (const client of KNOWN_ADAPTER_CLIENTS) {
128
+ if (lower.includes(client))
129
+ return client;
130
+ }
131
+ const stem = basename(lower, extname(lower)).replace(/[^a-z0-9]+/g, "-");
132
+ return stem || "generic";
133
+ }
134
+ function listSkillAdapterOverlays(skillPath) {
135
+ const parsed = parseVirtualStorePath(skillPath);
136
+ if (parsed) {
137
+ const skillName = parsed.key.split("/")[2] ?? "";
138
+ const prefix = `knowledge/skills/${skillName}/agents/`;
139
+ return listStoreKeysByPathSync(parsed.storePath, prefix)
140
+ .filter((key) => key.toLowerCase() !== `${prefix}readme.md`)
141
+ .filter((key) => ADAPTER_EXTENSIONS.has(extname(key).toLowerCase()))
142
+ .map((key) => {
143
+ const relativePath = key.slice(prefix.length);
144
+ return {
145
+ client: detectAdapterClient(relativePath),
146
+ format: extname(relativePath).slice(1) || "unknown",
147
+ path: toVirtualStorePath(parsed.storePath, key),
148
+ relative_path: relativePath,
149
+ };
150
+ })
151
+ .sort((a, b) => a.relative_path.localeCompare(b.relative_path));
152
+ }
153
+ const agentsRoot = resolve(dirname(skillPath), "agents");
154
+ if (!existsSync(agentsRoot))
155
+ return [];
156
+ const overlays = [];
157
+ const walk = (dirPath) => {
158
+ const entries = readdirSync(dirPath, { withFileTypes: true });
159
+ for (const entry of entries) {
160
+ if (entry.name.startsWith("."))
161
+ continue;
162
+ const absolutePath = resolve(dirPath, entry.name);
163
+ if (entry.isDirectory()) {
164
+ walk(absolutePath);
165
+ continue;
166
+ }
167
+ const extension = extname(entry.name).toLowerCase();
168
+ const relativePath = relative(agentsRoot, absolutePath).replace(/\\/g, "/");
169
+ if (!ADAPTER_EXTENSIONS.has(extension))
170
+ continue;
171
+ if (relativePath.toLowerCase() === "readme.md")
172
+ continue;
173
+ overlays.push({
174
+ client: detectAdapterClient(relativePath),
175
+ format: extension.slice(1) || "unknown",
176
+ path: absolutePath,
177
+ relative_path: relativePath,
178
+ });
179
+ }
180
+ };
181
+ walk(agentsRoot);
182
+ return overlays.sort((a, b) => a.relative_path.localeCompare(b.relative_path));
183
+ }
184
+ export function readSkillCatalogEntry(skill) {
185
+ const raw = skill.source === "store" || !existsSync(skill.path)
186
+ ? readVirtualStorePathSync(skill.path) ?? readSkillInstructions(skill.name)
187
+ : readFileSync(skill.path, "utf-8");
188
+ const parsed = parseSkillFrontmatter(raw);
189
+ const headings = extractHeadings(parsed.body);
190
+ const normalizedHeadings = headings.map(normalizeHeading);
191
+ const fileBacked = existsSync(skill.path);
192
+ const openaiYamlPath = resolveOpenAiYamlPath(skill.path);
193
+ const openaiMetadata = openaiYamlPath
194
+ ? parseSimpleYamlBlock(fileBacked && existsSync(openaiYamlPath)
195
+ ? readFileSync(openaiYamlPath, "utf-8")
196
+ : readVirtualStorePathSync(openaiYamlPath) ?? "")
197
+ : {};
198
+ const adapterOverlays = listSkillAdapterOverlays(skill.path);
199
+ const adapterOverlayClients = [...new Set(adapterOverlays.map((overlay) => overlay.client))];
200
+ const hasReferencesDir = fileBacked
201
+ ? existsSync(resolve(dirname(skill.path), "references"))
202
+ : (() => {
203
+ const parsed = parseVirtualStorePath(skill.path);
204
+ if (!parsed)
205
+ return false;
206
+ const skillName = parsed.key.split("/")[2] ?? "";
207
+ return listStoreKeysByPathSync(parsed.storePath, `knowledge/skills/${skillName}/references/`).length > 0;
208
+ })();
209
+ return {
210
+ ...skill,
211
+ description: parsed.attributes.description?.trim() ?? "",
212
+ headings,
213
+ normalized_headings: normalizedHeadings,
214
+ line_count: raw.replace(/\r\n/g, "\n").split("\n").length,
215
+ has_frontmatter: parsed.has_frontmatter,
216
+ has_openai_yaml: Boolean(openaiYamlPath),
217
+ openai_yaml_path: openaiYamlPath,
218
+ openai_metadata: openaiMetadata,
219
+ has_inputs_section: hasHeading(normalizedHeadings, ["inputs", "input"]),
220
+ has_workflow_section: hasHeading(normalizedHeadings, [
221
+ "workflow",
222
+ "steps",
223
+ "process",
224
+ "procedure",
225
+ ]),
226
+ has_outputs_section: hasHeading(normalizedHeadings, [
227
+ "outputs",
228
+ "output",
229
+ "artifacts",
230
+ "resulting artifacts",
231
+ ]),
232
+ has_failure_policy: hasHeading(normalizedHeadings, [
233
+ "failure",
234
+ "troubleshooting",
235
+ "fallback",
236
+ ]),
237
+ has_use_cases_section: hasHeading(normalizedHeadings, [
238
+ "use cases",
239
+ "canonical use cases",
240
+ "examples",
241
+ ]),
242
+ has_references_dir: hasReferencesDir,
243
+ has_validation_surface: hasValidationSurface(parsed.body, normalizedHeadings),
244
+ has_portability_notes: hasPortabilityNotes(parsed.body, normalizedHeadings),
245
+ has_optional_adapters: adapterOverlays.length > 0,
246
+ adapter_overlay_clients: adapterOverlayClients,
247
+ adapter_overlays: adapterOverlays,
248
+ };
249
+ }
250
+ export function listSkillCatalogEntries() {
251
+ return listAvailableSkills().map((skill) => readSkillCatalogEntry(skill));
252
+ }
253
+ export function summarizeSkillCatalog(entries = listSkillCatalogEntries()) {
254
+ const longSkills = entries
255
+ .filter((entry) => entry.line_count > 500)
256
+ .map((entry) => ({ name: entry.name, line_count: entry.line_count }));
257
+ const missingCoreSections = entries
258
+ .filter((entry) => !entry.has_inputs_section ||
259
+ !entry.has_workflow_section ||
260
+ !entry.has_outputs_section ||
261
+ !entry.has_failure_policy)
262
+ .map((entry) => entry.name);
263
+ const missingUseCases = entries
264
+ .filter((entry) => !entry.has_use_cases_section)
265
+ .map((entry) => entry.name);
266
+ const missingValidationSurface = entries
267
+ .filter((entry) => !entry.has_validation_surface)
268
+ .map((entry) => entry.name);
269
+ const missingPortabilityNotes = entries
270
+ .filter((entry) => !entry.has_portability_notes)
271
+ .map((entry) => entry.name);
272
+ const progressiveDisclosureGaps = entries
273
+ .filter((entry) => entry.line_count > 500 && !entry.has_references_dir)
274
+ .map((entry) => entry.name);
275
+ const adapterClients = [...new Set(entries.flatMap((entry) => entry.adapter_overlay_clients))].sort((a, b) => a.localeCompare(b));
276
+ const portableContractReadySkills = entries.filter((entry) => entry.has_frontmatter &&
277
+ descriptionLooksTriggerAware(entry.description) &&
278
+ entry.has_use_cases_section &&
279
+ entry.has_inputs_section &&
280
+ entry.has_workflow_section &&
281
+ entry.has_outputs_section &&
282
+ entry.has_failure_policy).length;
283
+ return {
284
+ total_skills: entries.length,
285
+ with_openai_yaml: entries.filter((entry) => entry.has_openai_yaml).length,
286
+ with_adapter_overlays: entries.filter((entry) => entry.has_optional_adapters).length,
287
+ adapter_clients: adapterClients,
288
+ with_frontmatter: entries.filter((entry) => entry.has_frontmatter).length,
289
+ trigger_aware_descriptions: entries.filter((entry) => descriptionLooksTriggerAware(entry.description)).length,
290
+ with_validation_surface: entries.filter((entry) => entry.has_validation_surface).length,
291
+ with_portability_notes: entries.filter((entry) => entry.has_portability_notes).length,
292
+ portable_contract_ready_skills: portableContractReadySkills,
293
+ long_skills: longSkills,
294
+ skills_missing_core_sections: missingCoreSections,
295
+ skills_missing_use_cases: missingUseCases,
296
+ skills_missing_validation_surface: missingValidationSurface,
297
+ skills_missing_portability_notes: missingPortabilityNotes,
298
+ progressive_disclosure_gaps: progressiveDisclosureGaps,
299
+ };
300
+ }
301
+ export function findSkillCatalogEntry(name, entries = listSkillCatalogEntries()) {
302
+ const target = name.trim().toLowerCase();
303
+ return entries.find((entry) => entry.name.toLowerCase() === target);
304
+ }
305
+ //# sourceMappingURL=skill-catalog.js.map
@@ -0,0 +1,40 @@
1
+ export declare const STATUS_EVENTS_REL_PATH = "agent-state/STATUS_EVENTS.ndjson";
2
+ export type StatusEventStatus = "started" | "in_progress" | "pass" | "fail" | "blocked" | "done";
3
+ export interface AppendStatusEventInput {
4
+ source_module: string;
5
+ event_type: string;
6
+ status: StatusEventStatus;
7
+ summary: string;
8
+ payload?: Record<string, unknown>;
9
+ trace_id?: string;
10
+ objective_id?: string;
11
+ decision_id?: string;
12
+ }
13
+ export interface StatusEventRecord {
14
+ schema_version: "1.0.0";
15
+ event_id: string;
16
+ trace_id: string;
17
+ timestamp: string;
18
+ source_module: string;
19
+ event_type: string;
20
+ status: StatusEventStatus;
21
+ objective_id?: string;
22
+ decision_id?: string;
23
+ payload: Record<string, unknown>;
24
+ }
25
+ export declare function waitForPendingStatusEventMirrors(): Promise<void>;
26
+ export declare function appendStatusEvent(input: AppendStatusEventInput): {
27
+ path: string;
28
+ event: StatusEventRecord;
29
+ };
30
+ /**
31
+ * Concurrency-safe variant of appendStatusEvent.
32
+ * Use this from async tool handlers where parallel subagents may fire.
33
+ */
34
+ export declare function appendStatusEventSafe(input: AppendStatusEventInput): Promise<{
35
+ path: string;
36
+ event: StatusEventRecord;
37
+ }>;
38
+ export declare function readStatusEvents(limit?: number): StatusEventRecord[];
39
+ export declare function getStatusEventsPath(): string;
40
+ //# sourceMappingURL=status-events.d.ts.map
@@ -0,0 +1,269 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { existsSync } from "node:fs";
3
+ import { resolveWorkspaceRoot, resolveWorkspaceArtifactPath as resolveWorkspaceArtifactPathHelper, safeRead, safeWrite, } from "./helpers.js";
4
+ import { isReadError } from "./shared.js";
5
+ import { validateStatusEventPayload, PROVENANCE_CRITICAL_EVENT_TYPES } from "./schemas.js";
6
+ import { openStore } from "./store/ace-packed-store.js";
7
+ import { VericifyProjector } from "./store/materializers/vericify-projector.js";
8
+ import { TrackerRepository } from "./store/repositories/tracker-repository.js";
9
+ import { getWorkspaceStorePath, listStoreKeysSync, readStoreJsonSync, storeExistsSync, } from "./store/store-snapshot.js";
10
+ import { operationalArtifactVirtualPath } from "./store/store-artifacts.js";
11
+ import { withStoreWriteQueue } from "./store/write-queue.js";
12
+ export const STATUS_EVENTS_REL_PATH = "agent-state/STATUS_EVENTS.ndjson";
13
+ const STATUS_EVENTS_ARCHIVE_REL = "agent-state/STATUS_EVENTS-archive.ndjson";
14
+ const MAX_EVENT_LINES = 2000;
15
+ const _fileLocks = new Map();
16
+ let trackerMirrorChain = Promise.resolve();
17
+ function workspaceRoot() {
18
+ return resolveWorkspaceRoot();
19
+ }
20
+ function buildStatusEvent(input) {
21
+ return {
22
+ schema_version: "1.0.0",
23
+ event_id: randomUUID(),
24
+ trace_id: input.trace_id ?? randomUUID(),
25
+ timestamp: new Date().toISOString(),
26
+ source_module: input.source_module,
27
+ event_type: input.event_type,
28
+ status: input.status,
29
+ objective_id: input.objective_id,
30
+ decision_id: input.decision_id,
31
+ payload: {
32
+ summary: input.summary,
33
+ ...(input.payload ?? {}),
34
+ },
35
+ };
36
+ }
37
+ function validateStatusEvent(event) {
38
+ const isProvenanceCritical = PROVENANCE_CRITICAL_EVENT_TYPES.has(event.event_type);
39
+ const validation = validateStatusEventPayload(event, {
40
+ provenanceCritical: isProvenanceCritical,
41
+ });
42
+ if (!validation.ok) {
43
+ throw new Error(`Status event failed validation (${validation.schema}): ${validation.errors.join("; ")}`);
44
+ }
45
+ }
46
+ function resolveWorkspaceArtifactPath(filePath) {
47
+ return resolveWorkspaceArtifactPathHelper(filePath, "write");
48
+ }
49
+ function safeReadWorkspaceFile(filePath) {
50
+ return safeRead(filePath);
51
+ }
52
+ function safeWriteWorkspaceFile(filePath, content) {
53
+ return safeWrite(filePath, content);
54
+ }
55
+ async function withDynamicFileLock(path, fn) {
56
+ const key = resolveWorkspaceArtifactPath(path);
57
+ const prev = _fileLocks.get(key) ?? Promise.resolve();
58
+ let releaseLock;
59
+ const next = new Promise((resolveLock) => {
60
+ releaseLock = resolveLock;
61
+ });
62
+ _fileLocks.set(key, next);
63
+ await prev;
64
+ try {
65
+ return await fn();
66
+ }
67
+ finally {
68
+ releaseLock();
69
+ if (_fileLocks.get(key) === next)
70
+ _fileLocks.delete(key);
71
+ }
72
+ }
73
+ function readExistingNdjson() {
74
+ const existing = safeReadWorkspaceFile(STATUS_EVENTS_REL_PATH);
75
+ if (isReadError(existing)) {
76
+ return "";
77
+ }
78
+ return existing.trimEnd();
79
+ }
80
+ function rotateIfNeeded(content) {
81
+ const lines = content.split("\n").filter((l) => l.trim().length > 0);
82
+ if (lines.length <= MAX_EVENT_LINES)
83
+ return content;
84
+ const excess = lines.splice(0, lines.length - MAX_EVENT_LINES);
85
+ const archiveContent = excess.join("\n") + "\n";
86
+ const existingArchive = safeReadWorkspaceFile(STATUS_EVENTS_ARCHIVE_REL);
87
+ const archiveFull = isReadError(existingArchive)
88
+ ? archiveContent
89
+ : existingArchive.trimEnd() + "\n" + archiveContent;
90
+ safeWriteWorkspaceFile(STATUS_EVENTS_ARCHIVE_REL, archiveFull);
91
+ return lines.join("\n") + "\n";
92
+ }
93
+ async function mirrorStatusEventToStore(event) {
94
+ const root = workspaceRoot();
95
+ const storePath = getWorkspaceStorePath(root);
96
+ if (!existsSync(storePath))
97
+ return;
98
+ await withStoreWriteQueue(storePath, async () => {
99
+ const store = await openStore(storePath);
100
+ try {
101
+ const tracker = new TrackerRepository(store);
102
+ await tracker.emit({
103
+ kind: event.event_type,
104
+ agent: event.source_module,
105
+ summary: typeof event.payload.summary === "string"
106
+ ? event.payload.summary
107
+ : event.event_type,
108
+ metadata: {
109
+ ...event.payload,
110
+ status: event.status,
111
+ trace_id: event.trace_id,
112
+ objective_id: event.objective_id,
113
+ decision_id: event.decision_id,
114
+ event_id: event.event_id,
115
+ },
116
+ });
117
+ await store.commit();
118
+ const projector = new VericifyProjector(store, root);
119
+ await projector.projectStatusEvents();
120
+ await store.commit();
121
+ }
122
+ finally {
123
+ await store.close();
124
+ }
125
+ });
126
+ }
127
+ function scheduleStatusEventMirror(event) {
128
+ const snapshot = JSON.parse(JSON.stringify(event));
129
+ trackerMirrorChain = trackerMirrorChain
130
+ .catch(() => { })
131
+ .then(() => mirrorStatusEventToStore(snapshot))
132
+ .catch(() => { });
133
+ }
134
+ export async function waitForPendingStatusEventMirrors() {
135
+ await trackerMirrorChain.catch(() => { });
136
+ }
137
+ async function appendStatusEventStoreBacked(event) {
138
+ const root = workspaceRoot();
139
+ const storePath = getWorkspaceStorePath(root);
140
+ return withStoreWriteQueue(storePath, async () => {
141
+ const store = await openStore(storePath);
142
+ try {
143
+ const tracker = new TrackerRepository(store);
144
+ await tracker.emit({
145
+ kind: event.event_type,
146
+ agent: event.source_module,
147
+ summary: typeof event.payload.summary === "string"
148
+ ? event.payload.summary
149
+ : event.event_type,
150
+ metadata: {
151
+ ...event.payload,
152
+ status: event.status,
153
+ trace_id: event.trace_id,
154
+ objective_id: event.objective_id,
155
+ decision_id: event.decision_id,
156
+ event_id: event.event_id,
157
+ },
158
+ });
159
+ await store.commit();
160
+ const projector = new VericifyProjector(store, root);
161
+ await projector.projectStatusEvents();
162
+ await store.commit();
163
+ return {
164
+ path: operationalArtifactVirtualPath(root, STATUS_EVENTS_REL_PATH),
165
+ event,
166
+ };
167
+ }
168
+ finally {
169
+ await store.close();
170
+ }
171
+ });
172
+ }
173
+ export function appendStatusEvent(input) {
174
+ const event = buildStatusEvent(input);
175
+ validateStatusEvent(event);
176
+ // Atomic append under file lock to prevent lost writes under parallelism
177
+ const existing = readExistingNdjson();
178
+ const line = JSON.stringify(event);
179
+ const combined = existing.length > 0 ? `${existing}\n${line}\n` : `${line}\n`;
180
+ const next = rotateIfNeeded(combined);
181
+ const path = safeWriteWorkspaceFile(STATUS_EVENTS_REL_PATH, next);
182
+ scheduleStatusEventMirror(event);
183
+ return { path, event };
184
+ }
185
+ /**
186
+ * Concurrency-safe variant of appendStatusEvent.
187
+ * Use this from async tool handlers where parallel subagents may fire.
188
+ */
189
+ export async function appendStatusEventSafe(input) {
190
+ return withDynamicFileLock(STATUS_EVENTS_REL_PATH, async () => {
191
+ const event = buildStatusEvent(input);
192
+ validateStatusEvent(event);
193
+ if (storeExistsSync(workspaceRoot())) {
194
+ return appendStatusEventStoreBacked(event);
195
+ }
196
+ return appendStatusEvent(input);
197
+ });
198
+ }
199
+ function mapStoreTrackerEvent(record) {
200
+ const metadata = record.metadata ?? {};
201
+ const status = typeof metadata.status === "string" &&
202
+ ["started", "in_progress", "pass", "fail", "blocked", "done"].includes(metadata.status)
203
+ ? metadata.status
204
+ : "in_progress";
205
+ const payload = { ...metadata };
206
+ delete payload.status;
207
+ delete payload.trace_id;
208
+ delete payload.objective_id;
209
+ delete payload.decision_id;
210
+ delete payload.event_id;
211
+ if (typeof payload.summary !== "string") {
212
+ payload.summary = record.summary;
213
+ }
214
+ return {
215
+ schema_version: "1.0.0",
216
+ event_id: typeof metadata.event_id === "string" ? metadata.event_id : record.id,
217
+ trace_id: typeof metadata.trace_id === "string" ? metadata.trace_id : record.id,
218
+ timestamp: new Date(record.ts).toISOString(),
219
+ source_module: record.agent ?? "system",
220
+ event_type: record.kind,
221
+ status,
222
+ objective_id: typeof metadata.objective_id === "string" ? metadata.objective_id : undefined,
223
+ decision_id: typeof metadata.decision_id === "string" ? metadata.decision_id : undefined,
224
+ payload,
225
+ };
226
+ }
227
+ function readStoreBackedStatusEvents(limit) {
228
+ const root = workspaceRoot();
229
+ if (!storeExistsSync(root))
230
+ return [];
231
+ const records = listStoreKeysSync(root, "state/tracker/")
232
+ .filter((key) => key !== "state/tracker/__seq")
233
+ .map((key) => readStoreJsonSync(root, key))
234
+ .filter((entry) => Boolean(entry))
235
+ .sort((a, b) => a.ts - b.ts);
236
+ return records.slice(Math.max(0, records.length - limit)).map(mapStoreTrackerEvent);
237
+ }
238
+ export function readStatusEvents(limit = 100) {
239
+ const storeEvents = readStoreBackedStatusEvents(limit);
240
+ if (storeEvents.length > 0) {
241
+ return storeEvents;
242
+ }
243
+ const raw = safeReadWorkspaceFile(STATUS_EVENTS_REL_PATH);
244
+ if (raw.startsWith("[FILE NOT FOUND]") || raw.startsWith("[ACCESS DENIED]")) {
245
+ return [];
246
+ }
247
+ const lines = raw
248
+ .split(/\r?\n/)
249
+ .map((line) => line.trim())
250
+ .filter(Boolean);
251
+ const parsed = [];
252
+ for (const line of lines.slice(Math.max(0, lines.length - limit))) {
253
+ try {
254
+ const row = JSON.parse(line);
255
+ parsed.push(row);
256
+ }
257
+ catch {
258
+ // Ignore malformed legacy rows; validation is enforced on future appends.
259
+ }
260
+ }
261
+ return parsed;
262
+ }
263
+ export function getStatusEventsPath() {
264
+ if (storeExistsSync(workspaceRoot())) {
265
+ return operationalArtifactVirtualPath(workspaceRoot(), STATUS_EVENTS_REL_PATH);
266
+ }
267
+ return resolveWorkspaceArtifactPath(STATUS_EVENTS_REL_PATH);
268
+ }
269
+ //# sourceMappingURL=status-events.js.map
@@ -0,0 +1,69 @@
1
+ /**
2
+ * AcePackedStore
3
+ *
4
+ * Custom single-file store that implements Zarrita's AsyncReadable + AsyncWritable
5
+ * interfaces over a packed binary file at `.agents/ACE/ace-state.zarr`.
6
+ *
7
+ * File format:
8
+ * [ Header 64 bytes ] magic(8) version(4) flags(4) index_offset(8) index_length(8) reserved(32)
9
+ * [ Chunk region ] chunk_0: [uint32 length][bytes] ... chunk_N: [uint32 length][bytes]
10
+ * [ Index region ] UTF-8 JSON: { key → { offset, length } }
11
+ *
12
+ * Write protocol:
13
+ * 1. Append new chunk to end of chunk region.
14
+ * 2. Update in-memory index.
15
+ * 3. On commit(): rewrite index region → update header → fsync.
16
+ *
17
+ * Compaction:
18
+ * Write live chunks to temp file → validate → atomic rename.
19
+ *
20
+ * Locking:
21
+ * Advisory flock-style via a `.lock` sidecar file (PID + timestamp).
22
+ * Stale detection: lock held >30s and PID not alive → break lock.
23
+ */
24
+ import { IAcePackedStore, UnifiedEntry, EntryFilter, TopologyEntry, ContentSourceCode } from "./types.js";
25
+ export declare class AcePackedStore implements IAcePackedStore {
26
+ private storePath;
27
+ private lockPath;
28
+ private readOnly;
29
+ private index;
30
+ private chunkEnd;
31
+ private fh;
32
+ private dirty;
33
+ private entryCounter;
34
+ open(path: string, opts?: {
35
+ readOnly?: boolean;
36
+ }): Promise<void>;
37
+ private _initNewStore;
38
+ private _loadExistingStore;
39
+ commit(): Promise<void>;
40
+ compact(): Promise<void>;
41
+ close(): Promise<void>;
42
+ get(key: string): Promise<Uint8Array | undefined>;
43
+ set(key: string, value: Uint8Array): Promise<void>;
44
+ delete(key: string): Promise<boolean>;
45
+ list(): AsyncGenerator<string>;
46
+ getJSON<T>(key: string): Promise<T | undefined>;
47
+ setJSON(key: string, value: unknown): Promise<void>;
48
+ getBlob(key: string): Promise<string | undefined>;
49
+ setBlob(key: string, content: string): Promise<void>;
50
+ appendEntry(entry: Omit<UnifiedEntry, "id" | "ts">): Promise<UnifiedEntry>;
51
+ getEntries(filter?: EntryFilter): Promise<UnifiedEntry[]>;
52
+ getEntry(key: string): Promise<UnifiedEntry | undefined>;
53
+ getTopology(kind: string): Promise<TopologyEntry[]>;
54
+ setTopology(kind: string, entries: TopologyEntry[]): Promise<void>;
55
+ getAgentInstruction(agent: string, file: string): Promise<string | undefined>;
56
+ setAgentInstruction(agent: string, file: string, content: string, source?: ContentSourceCode): Promise<void>;
57
+ listAgents(): Promise<string[]>;
58
+ getSkillContent(skill: string, file: string): Promise<string | undefined>;
59
+ setSkillContent(skill: string, file: string, content: string, source?: ContentSourceCode): Promise<void>;
60
+ listSkills(): Promise<string[]>;
61
+ /** Dead space ratio — used to decide if compaction is needed */
62
+ get deadSpaceRatio(): number;
63
+ /** Number of entries in the unified log */
64
+ get entryCount(): number;
65
+ }
66
+ export declare function openStore(storePath: string, opts?: {
67
+ readOnly?: boolean;
68
+ }): Promise<AcePackedStore>;
69
+ //# sourceMappingURL=ace-packed-store.d.ts.map