vgxness 1.20.4 → 1.20.6

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 (375) hide show
  1. package/dist/adapters/claude/agent-renderer.js +82 -0
  2. package/dist/{mcp → adapters/claude/install}/claude-code-agent-config.js +64 -9
  3. package/dist/{mcp → adapters/claude/install}/claude-code-config.js +28 -6
  4. package/dist/{mcp → adapters/claude/install}/claude-code-project-memory.js +35 -5
  5. package/dist/{mcp → adapters/claude/install}/claude-code-scope.js +12 -3
  6. package/dist/{mcp → adapters/claude/install}/claude-code-user-config.js +26 -5
  7. package/dist/{mcp → adapters/claude/install}/claude-code-user-memory.js +47 -7
  8. package/dist/{mcp → adapters/claude/install}/client-install-claude-code-contract.js +45 -8
  9. package/dist/{mcp → adapters/claude/install}/client-install-claude-code.js +98 -14
  10. package/dist/adapters/json/agent-renderer.js +104 -0
  11. package/dist/adapters/opencode/agent-renderer.js +113 -0
  12. package/dist/{mcp → adapters/opencode/install}/client-install-opencode-contract.js +2 -2
  13. package/dist/{mcp → adapters/opencode/install}/client-install-opencode.js +1 -1
  14. package/dist/{mcp → adapters/opencode/install}/opencode-default-agent-config.js +2 -2
  15. package/dist/{mcp → adapters/opencode/install}/opencode-handoff-preview.js +60 -7
  16. package/dist/{mcp → adapters/opencode/install}/opencode-visibility.js +1 -1
  17. package/dist/adapters/provider-renderer.js +6 -0
  18. package/dist/agents/agent-activation-service.js +1 -263
  19. package/dist/agents/agent-lookup-contexts.js +1 -28
  20. package/dist/agents/agent-registry-service.js +1 -81
  21. package/dist/agents/agent-resolver.js +1 -287
  22. package/dist/agents/agent-seed-service.js +1 -157
  23. package/dist/agents/agent-seed-upgrade-service.js +1 -231
  24. package/dist/agents/agent-selector-resolver.js +1 -28
  25. package/dist/agents/boot-upgrade.js +1 -59
  26. package/dist/agents/canonical-agent-manifest.js +1 -245
  27. package/dist/agents/canonical-agent-projection.js +1 -236
  28. package/dist/agents/manager-profile-overlay-service.js +1 -60
  29. package/dist/agents/profile-model-routing.js +1 -30
  30. package/dist/agents/renderers/claude-renderer.js +1 -82
  31. package/dist/agents/renderers/index.js +1 -14
  32. package/dist/agents/renderers/json-renderer.js +1 -104
  33. package/dist/agents/renderers/opencode-renderer.js +1 -113
  34. package/dist/agents/renderers/provider-adapter.js +1 -6
  35. package/dist/agents/repositories/agent-seed-history.js +1 -128
  36. package/dist/agents/repositories/agents.js +1 -200
  37. package/dist/agents/repositories/manager-profile-overlays.js +1 -90
  38. package/dist/agents/schema.js +1 -1
  39. package/dist/application/agents/agent-activation-service.js +261 -0
  40. package/dist/application/agents/agent-lookup-contexts.js +28 -0
  41. package/dist/application/agents/agent-registry-service.js +81 -0
  42. package/dist/application/agents/agent-resolver.js +287 -0
  43. package/dist/application/agents/agent-seed-service.js +157 -0
  44. package/dist/application/agents/agent-seed-upgrade-service.js +231 -0
  45. package/dist/application/agents/agent-selector-resolver.js +28 -0
  46. package/dist/application/agents/boot-upgrade.js +59 -0
  47. package/dist/application/agents/canonical-agent-projection.js +236 -0
  48. package/dist/application/agents/manager-profile-overlay-service.js +68 -0
  49. package/dist/application/agents/profile-model-routing.js +30 -0
  50. package/dist/application/agents/renderers/claude-renderer.js +1 -0
  51. package/dist/application/agents/renderers/index.js +14 -0
  52. package/dist/application/agents/renderers/json-renderer.js +1 -0
  53. package/dist/application/agents/renderers/opencode-renderer.js +1 -0
  54. package/dist/application/agents/renderers/provider-adapter.js +1 -0
  55. package/dist/application/memory/active-work-preview.js +75 -0
  56. package/dist/application/memory/agent-memory-capture-service.js +498 -0
  57. package/dist/application/memory/import/dry-run-planner.js +58 -0
  58. package/dist/application/memory/import/index.js +3 -0
  59. package/dist/application/memory/import/observation-writer.js +226 -0
  60. package/dist/application/memory/import/package.js +179 -0
  61. package/dist/application/memory/memory-service.js +202 -0
  62. package/dist/application/memory/search.js +11 -0
  63. package/dist/{mcp → application/provider-setup}/provider-change-plan.js +74 -13
  64. package/dist/{mcp → application/provider-setup}/provider-doctor.js +201 -31
  65. package/dist/{mcp → application/provider-setup}/provider-health-types.js +1 -1
  66. package/dist/{mcp → application/provider-setup}/provider-status.js +170 -33
  67. package/dist/application/runs/execution-planning.js +180 -0
  68. package/dist/application/runs/operation-execution.js +1 -0
  69. package/dist/application/runs/operation-retry.js +129 -0
  70. package/dist/application/runs/resume-after-approval-result.js +88 -0
  71. package/dist/application/runs/run-insights.js +270 -0
  72. package/dist/application/runs/run-service.js +1480 -0
  73. package/dist/application/runs/run-snapshot-export-service.js +31 -0
  74. package/dist/application/runs/sandbox-process-execution.js +244 -0
  75. package/dist/application/runs/sandbox-worktree-planning.js +59 -0
  76. package/dist/application/runs/task-scoped-command-grant-service.js +224 -0
  77. package/dist/application/sdd/artifact-portability-service.js +137 -0
  78. package/dist/application/sdd/cockpit-read-model.js +195 -0
  79. package/dist/application/sdd/sdd-continuation-plan.js +265 -0
  80. package/dist/application/sdd/sdd-workflow-service.js +892 -0
  81. package/dist/application/skills/boot-seed.js +42 -0
  82. package/dist/application/skills/personal-skills.js +41 -0
  83. package/dist/application/skills/skill-export-service.js +34 -0
  84. package/dist/application/skills/skill-index-service.js +126 -0
  85. package/dist/application/skills/skill-payload.js +186 -0
  86. package/dist/application/skills/skill-registry-service.js +648 -0
  87. package/dist/application/skills/skill-resolver.js +368 -0
  88. package/dist/application/skills/skill-seed-service.js +242 -0
  89. package/dist/application/skills/skill-status-service.js +147 -0
  90. package/dist/cli/bun-bin.js +0 -0
  91. package/dist/cli/cli-flags.js +1 -387
  92. package/dist/cli/cli-help.js +1 -173
  93. package/dist/cli/cli-helpers.js +1 -77
  94. package/dist/cli/cli-types.js +1 -1
  95. package/dist/cli/commands/agent-skill-dispatcher.js +1 -700
  96. package/dist/cli/commands/index.js +1 -9
  97. package/dist/cli/commands/interactive-entrypoint-dispatcher.js +1 -14
  98. package/dist/cli/commands/mcp-dispatcher.js +1 -232
  99. package/dist/cli/commands/memory-sdd-dispatcher.js +1 -367
  100. package/dist/cli/commands/run-permission-dispatcher.js +1 -455
  101. package/dist/cli/commands/setup-dispatcher.js +1 -496
  102. package/dist/cli/commands/status-dispatcher.js +1 -130
  103. package/dist/cli/commands/verification-dispatcher.js +1 -47
  104. package/dist/cli/commands/workflow-dispatcher.js +1 -566
  105. package/dist/cli/dispatcher.js +1 -247
  106. package/dist/cli/doctor-renderer.js +1 -26
  107. package/dist/cli/home-tui-app.js +1 -411
  108. package/dist/cli/home-tui-controller.js +1 -314
  109. package/dist/cli/mcp-start-path.js +1 -21
  110. package/dist/cli/product-resume-renderer.js +1 -32
  111. package/dist/cli/product-status-renderer.js +1 -81
  112. package/dist/cli/sdd-renderer.js +1 -247
  113. package/dist/cli/setup-plan-renderer.js +1 -79
  114. package/dist/cli/setup-status-renderer.js +1 -50
  115. package/dist/cli/setup-tui-app.js +1 -130
  116. package/dist/cli/setup-tui-controller.js +1 -89
  117. package/dist/cli/tui/focus-reducer.js +1 -0
  118. package/dist/cli/tui/focus-types.js +1 -0
  119. package/dist/cli/tui/ink/app-shell.js +1 -0
  120. package/dist/cli/tui/ink/components.js +1 -38
  121. package/dist/cli/tui/ink/help-overlay.js +1 -0
  122. package/dist/cli/tui/ink/state-components.js +1 -0
  123. package/dist/cli/tui/ink/theme.js +1 -36
  124. package/dist/cli/tui/key-intents.js +1 -0
  125. package/dist/cli/tui/keymap.js +1 -20
  126. package/dist/cli/tui/navigation.js +1 -10
  127. package/dist/cli/tui/screen-registry.js +1 -0
  128. package/dist/cli/tui/terminal-capabilities.js +1 -12
  129. package/dist/cli/tui/tui-types.js +1 -1
  130. package/dist/cli/tui/visual/badges.js +1 -19
  131. package/dist/cli/tui/visual/footer.js +1 -27
  132. package/dist/cli/tui/visual/index.js +1 -3
  133. package/dist/cli/tui/visual/viewport.js +1 -11
  134. package/dist/cli/tui-render-helpers.js +1 -200
  135. package/dist/cli/verification-plan-renderer.js +1 -25
  136. package/dist/cli/verification-report-renderer.js +1 -19
  137. package/dist/domain/agents/canonical-agent-manifest.js +355 -0
  138. package/dist/domain/agents/schema.js +1 -0
  139. package/dist/domain/memory/active-work-topics.js +64 -0
  140. package/dist/domain/memory/memory-capture-schema.js +1 -0
  141. package/dist/domain/memory/schema.js +1 -0
  142. package/dist/domain/runs/schema.js +5 -0
  143. package/dist/domain/sdd/cockpit-types.js +1 -0
  144. package/dist/domain/sdd/schema.js +111 -0
  145. package/dist/domain/skills/schema.js +1 -0
  146. package/dist/governance/risk-classifier.js +2 -0
  147. package/dist/interfaces/cli/bun-bin.js +46 -0
  148. package/dist/interfaces/cli/cli-flags.js +391 -0
  149. package/dist/interfaces/cli/cli-help.js +173 -0
  150. package/dist/interfaces/cli/cli-helpers.js +77 -0
  151. package/dist/interfaces/cli/cli-types.js +1 -0
  152. package/dist/interfaces/cli/commands/agent-skill-dispatcher.js +700 -0
  153. package/dist/interfaces/cli/commands/index.js +9 -0
  154. package/dist/interfaces/cli/commands/interactive-entrypoint-dispatcher.js +14 -0
  155. package/dist/interfaces/cli/commands/mcp-dispatcher.js +252 -0
  156. package/dist/interfaces/cli/commands/memory-sdd-dispatcher.js +367 -0
  157. package/dist/interfaces/cli/commands/run-permission-dispatcher.js +460 -0
  158. package/dist/interfaces/cli/commands/setup-dispatcher.js +496 -0
  159. package/dist/interfaces/cli/commands/status-dispatcher.js +130 -0
  160. package/dist/interfaces/cli/commands/verification-dispatcher.js +47 -0
  161. package/dist/interfaces/cli/commands/workflow-dispatcher.js +566 -0
  162. package/dist/interfaces/cli/dispatcher.js +247 -0
  163. package/dist/interfaces/cli/doctor-renderer.js +26 -0
  164. package/dist/interfaces/cli/home-tui-app.js +462 -0
  165. package/dist/interfaces/cli/home-tui-controller.js +341 -0
  166. package/dist/interfaces/cli/index.js +27 -0
  167. package/dist/interfaces/cli/mcp-start-path.js +21 -0
  168. package/dist/interfaces/cli/product-resume-renderer.js +32 -0
  169. package/dist/interfaces/cli/product-status-renderer.js +81 -0
  170. package/dist/interfaces/cli/sdd-renderer.js +247 -0
  171. package/dist/interfaces/cli/setup-plan-renderer.js +79 -0
  172. package/dist/interfaces/cli/setup-status-renderer.js +50 -0
  173. package/dist/interfaces/cli/setup-tui-app.js +135 -0
  174. package/dist/interfaces/cli/setup-tui-controller.js +89 -0
  175. package/dist/interfaces/cli/tui/focus-reducer.js +60 -0
  176. package/dist/interfaces/cli/tui/focus-types.js +10 -0
  177. package/dist/interfaces/cli/tui/ink/app-shell.js +16 -0
  178. package/dist/interfaces/cli/tui/ink/components.js +38 -0
  179. package/dist/interfaces/cli/tui/ink/help-overlay.js +6 -0
  180. package/dist/interfaces/cli/tui/ink/state-components.js +22 -0
  181. package/dist/interfaces/cli/tui/ink/theme.js +36 -0
  182. package/dist/interfaces/cli/tui/key-intents.js +33 -0
  183. package/dist/interfaces/cli/tui/keymap.js +20 -0
  184. package/dist/interfaces/cli/tui/navigation.js +10 -0
  185. package/dist/interfaces/cli/tui/screen-registry.js +43 -0
  186. package/dist/interfaces/cli/tui/terminal-capabilities.js +12 -0
  187. package/dist/interfaces/cli/tui/tui-types.js +1 -0
  188. package/dist/interfaces/cli/tui/visual/badges.js +19 -0
  189. package/dist/interfaces/cli/tui/visual/footer.js +27 -0
  190. package/dist/interfaces/cli/tui/visual/index.js +3 -0
  191. package/dist/interfaces/cli/tui/visual/viewport.js +11 -0
  192. package/dist/interfaces/cli/tui-render-helpers.js +200 -0
  193. package/dist/interfaces/cli/verification-plan-renderer.js +25 -0
  194. package/dist/interfaces/cli/verification-report-renderer.js +19 -0
  195. package/dist/interfaces/mcp/contracts/agents.js +1 -0
  196. package/dist/interfaces/mcp/contracts/context.js +1 -0
  197. package/dist/interfaces/mcp/contracts/governance.js +1 -0
  198. package/dist/interfaces/mcp/contracts/index.js +1 -0
  199. package/dist/interfaces/mcp/contracts/memory.js +1 -0
  200. package/dist/interfaces/mcp/contracts/providers.js +1 -0
  201. package/dist/interfaces/mcp/contracts/runs.js +1 -0
  202. package/dist/interfaces/mcp/contracts/sdd.js +1 -0
  203. package/dist/interfaces/mcp/contracts/sessions.js +1 -0
  204. package/dist/interfaces/mcp/contracts/skills.js +1 -0
  205. package/dist/interfaces/mcp/contracts/verification.js +1 -0
  206. package/dist/interfaces/mcp/control-plane/handlers/agents.js +38 -0
  207. package/dist/interfaces/mcp/control-plane/handlers/context.js +12 -0
  208. package/dist/interfaces/mcp/control-plane/handlers/memory.js +95 -0
  209. package/dist/interfaces/mcp/control-plane/handlers/providers.js +19 -0
  210. package/dist/interfaces/mcp/control-plane/handlers/runs.js +134 -0
  211. package/dist/interfaces/mcp/control-plane/handlers/sdd.js +225 -0
  212. package/dist/interfaces/mcp/control-plane/handlers/sessions.js +39 -0
  213. package/dist/interfaces/mcp/control-plane/handlers/skills.js +82 -0
  214. package/dist/interfaces/mcp/control-plane/handlers/verification.js +11 -0
  215. package/dist/interfaces/mcp/control-plane/types.js +1 -0
  216. package/dist/interfaces/mcp/control-plane.js +235 -0
  217. package/dist/interfaces/mcp/schema.js +174 -0
  218. package/dist/interfaces/mcp/schemas/common.js +121 -0
  219. package/dist/interfaces/mcp/schemas/inputs/agents.js +69 -0
  220. package/dist/interfaces/mcp/schemas/inputs/context.js +32 -0
  221. package/dist/interfaces/mcp/schemas/inputs/governance.js +23 -0
  222. package/dist/interfaces/mcp/schemas/inputs/index.js +10 -0
  223. package/dist/interfaces/mcp/schemas/inputs/memory.js +50 -0
  224. package/dist/interfaces/mcp/schemas/inputs/providers.js +35 -0
  225. package/dist/interfaces/mcp/schemas/inputs/runs.js +146 -0
  226. package/dist/interfaces/mcp/schemas/inputs/sdd.js +102 -0
  227. package/dist/interfaces/mcp/schemas/inputs/sessions.js +32 -0
  228. package/dist/interfaces/mcp/schemas/inputs/skills.js +231 -0
  229. package/dist/interfaces/mcp/schemas/inputs/verification.js +9 -0
  230. package/dist/interfaces/mcp/schemas/outputs/index.js +2 -0
  231. package/dist/interfaces/mcp/schemas/outputs/providers.js +28 -0
  232. package/dist/interfaces/mcp/schemas/outputs/sdd.js +166 -0
  233. package/dist/interfaces/mcp/stdio-server.js +116 -0
  234. package/dist/interfaces/mcp/validation/agents.js +189 -0
  235. package/dist/interfaces/mcp/validation/common.js +415 -0
  236. package/dist/interfaces/mcp/validation/governance.js +50 -0
  237. package/dist/interfaces/mcp/validation/memory.js +133 -0
  238. package/dist/interfaces/mcp/validation/providers.js +94 -0
  239. package/dist/interfaces/mcp/validation/runs.js +514 -0
  240. package/dist/interfaces/mcp/validation/sdd.js +247 -0
  241. package/dist/interfaces/mcp/validation/sessions.js +51 -0
  242. package/dist/interfaces/mcp/validation/skills.js +685 -0
  243. package/dist/interfaces/mcp/validation/verification.js +24 -0
  244. package/dist/interfaces/mcp/validation.js +149 -0
  245. package/dist/mcp/control-plane-snapshot-service.js +65 -2
  246. package/dist/mcp/control-plane.js +1 -646
  247. package/dist/mcp/doctor.js +1 -1
  248. package/dist/mcp/index.js +17 -17
  249. package/dist/mcp/schema.js +1 -1072
  250. package/dist/mcp/stdio-server.js +1 -116
  251. package/dist/mcp/validation.js +1 -2239
  252. package/dist/memory/active-work-preview.js +1 -75
  253. package/dist/memory/active-work-topics.js +1 -64
  254. package/dist/memory/agent-memory-capture-service.js +1 -497
  255. package/dist/memory/import/dry-run-planner.js +1 -58
  256. package/dist/memory/import/index.js +1 -3
  257. package/dist/memory/import/observation-writer.js +1 -226
  258. package/dist/memory/import/package.js +1 -179
  259. package/dist/memory/memory-capture-schema.js +1 -1
  260. package/dist/memory/memory-service.js +1 -201
  261. package/dist/memory/repositories/artifacts.js +1 -67
  262. package/dist/memory/repositories/observations.js +1 -217
  263. package/dist/memory/repositories/sessions.js +1 -125
  264. package/dist/memory/repositories/traces.js +1 -78
  265. package/dist/memory/schema.js +1 -1
  266. package/dist/memory/search.js +1 -11
  267. package/dist/memory/sqlite/database.js +1 -228
  268. package/dist/memory/storage-paths.js +1 -72
  269. package/dist/payload/context-budget-policy.js +10 -0
  270. package/dist/payload/context-budget-service.js +26 -0
  271. package/dist/payload/payload-diagnostics.js +50 -0
  272. package/dist/permissions/explicit-request-authorization.js +126 -0
  273. package/dist/permissions/policy-evaluator.js +54 -14
  274. package/dist/runs/execution-planning.js +1 -178
  275. package/dist/runs/operation-execution.js +1 -1
  276. package/dist/runs/operation-retry.js +1 -129
  277. package/dist/runs/repositories/runs.js +1 -676
  278. package/dist/runs/repositories/task-scoped-command-grants.js +1 -462
  279. package/dist/runs/resume-after-approval-result.js +1 -84
  280. package/dist/runs/run-insights.js +1 -270
  281. package/dist/runs/run-service.js +1 -1439
  282. package/dist/runs/run-snapshot-export-service.js +1 -31
  283. package/dist/runs/sandbox-process-execution.js +1 -240
  284. package/dist/runs/sandbox-worktree-planning.js +1 -59
  285. package/dist/runs/schema.js +1 -5
  286. package/dist/runs/task-scoped-command-grant-service.js +1 -216
  287. package/dist/sdd/artifact-portability-service.js +1 -137
  288. package/dist/sdd/cockpit-read-model.js +1 -195
  289. package/dist/sdd/cockpit-types.js +1 -1
  290. package/dist/sdd/schema.js +1 -111
  291. package/dist/sdd/sdd-continuation-plan.js +1 -265
  292. package/dist/sdd/sdd-workflow-service.js +1 -822
  293. package/dist/setup/providers/claude-setup-adapter.js +11 -4
  294. package/dist/setup/providers/opencode-setup-adapter.js +10 -7
  295. package/dist/setup/setup-plan.js +20 -7
  296. package/dist/skills/boot-seed.js +1 -42
  297. package/dist/skills/personal-skills.js +1 -41
  298. package/dist/skills/repositories/skill-evaluation-requests.js +1 -190
  299. package/dist/skills/repositories/skill-evaluation-scenarios.js +1 -305
  300. package/dist/skills/repositories/skill-improvement-proposals.js +1 -355
  301. package/dist/skills/repositories/skills.js +1 -1077
  302. package/dist/skills/schema.js +1 -1
  303. package/dist/skills/skill-export-service.js +1 -34
  304. package/dist/skills/skill-index-service.js +1 -126
  305. package/dist/skills/skill-payload.js +1 -186
  306. package/dist/skills/skill-registry-service.js +1 -644
  307. package/dist/skills/skill-resolver.js +1 -368
  308. package/dist/skills/skill-seed-service.js +1 -242
  309. package/dist/skills/skill-status-service.js +1 -147
  310. package/dist/storage/agents/repositories/agent-seed-history.js +128 -0
  311. package/dist/storage/agents/repositories/agents.js +200 -0
  312. package/dist/storage/agents/repositories/manager-profile-overlays.js +90 -0
  313. package/dist/storage/memory/repositories/artifacts.js +67 -0
  314. package/dist/storage/memory/repositories/observations.js +217 -0
  315. package/dist/storage/memory/repositories/sessions.js +125 -0
  316. package/dist/storage/memory/repositories/traces.js +78 -0
  317. package/dist/storage/memory/sqlite/database.js +228 -0
  318. package/dist/storage/memory/storage-paths.js +72 -0
  319. package/dist/storage/runs/repositories/runs.js +676 -0
  320. package/dist/storage/runs/repositories/task-scoped-command-grants.js +464 -0
  321. package/dist/storage/skills/repositories/skill-evaluation-requests.js +190 -0
  322. package/dist/storage/skills/repositories/skill-evaluation-scenarios.js +305 -0
  323. package/dist/storage/skills/repositories/skill-improvement-proposals.js +355 -0
  324. package/dist/storage/skills/repositories/skills.js +1084 -0
  325. package/docs/architecture.md +2 -2
  326. package/docs/glossary.md +1 -1
  327. package/docs/mcp.md +1 -1
  328. package/docs/module-boundaries.md +114 -0
  329. package/docs/prd.md +1 -1
  330. package/docs/project-health-audit-v1.10.x.md +1 -1
  331. package/docs/providers.md +2 -2
  332. package/docs/safety.md +3 -3
  333. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/apply-progress.md +122 -0
  334. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/archive-report.md +61 -0
  335. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/design.md +66 -0
  336. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/proposal.md +79 -0
  337. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/spec.md +67 -0
  338. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/tasks.md +63 -0
  339. package/docs/sdd/archive/2026-06-26-ambitious-structure-reorganization/verify-report.md +71 -0
  340. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/apply-progress.md +68 -0
  341. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/archive-report.md +61 -0
  342. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/design.md +43 -0
  343. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/proposal.md +61 -0
  344. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/spec.md +31 -0
  345. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/tasks.md +27 -0
  346. package/docs/sdd/archive/2026-06-26-legacy-facade-cleanup/verify-report.md +58 -0
  347. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/apply-progress.md +65 -0
  348. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/archive-report.md +53 -0
  349. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/design.md +64 -0
  350. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/proposal.md +62 -0
  351. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/spec.md +51 -0
  352. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/tasks.md +50 -0
  353. package/docs/sdd/archive/2026-06-26-provider-install-adapter-boundary/verify-report.md +66 -0
  354. package/docs/storage.md +2 -2
  355. package/package.json +2 -2
  356. /package/dist/{mcp → adapters/claude/install}/claude-code-cli.js +0 -0
  357. /package/dist/{memory → storage/memory}/sqlite/migrations/001_initial.sql +0 -0
  358. /package/dist/{memory → storage/memory}/sqlite/migrations/002_observation_revisions.sql +0 -0
  359. /package/dist/{memory → storage/memory}/sqlite/migrations/003_agent_registry.sql +0 -0
  360. /package/dist/{memory → storage/memory}/sqlite/migrations/004_run_runtime.sql +0 -0
  361. /package/dist/{memory → storage/memory}/sqlite/migrations/005_run_approvals.sql +0 -0
  362. /package/dist/{memory → storage/memory}/sqlite/migrations/006_run_operation_attempts.sql +0 -0
  363. /package/dist/{memory → storage/memory}/sqlite/migrations/007_abandoned_operation_attempts.sql +0 -0
  364. /package/dist/{memory → storage/memory}/sqlite/migrations/008_run_execution_plan_events.sql +0 -0
  365. /package/dist/{memory → storage/memory}/sqlite/migrations/009_multiple_operation_attempts.sql +0 -0
  366. /package/dist/{memory → storage/memory}/sqlite/migrations/010_skill_registry.sql +0 -0
  367. /package/dist/{memory → storage/memory}/sqlite/migrations/011_skill_usage_resolution_outcomes.sql +0 -0
  368. /package/dist/{memory → storage/memory}/sqlite/migrations/012_skill_improvement_proposals.sql +0 -0
  369. /package/dist/{memory → storage/memory}/sqlite/migrations/013_skill_evaluation_scenarios.sql +0 -0
  370. /package/dist/{memory → storage/memory}/sqlite/migrations/014_manager_profile_overlays.sql +0 -0
  371. /package/dist/{memory → storage/memory}/sqlite/migrations/015_artifact_metadata.sql +0 -0
  372. /package/dist/{memory → storage/memory}/sqlite/migrations/016_agent_seed_history.sql +0 -0
  373. /package/dist/{memory → storage/memory}/sqlite/migrations/017_intent_signal_skill_targets.sql +0 -0
  374. /package/dist/{memory → storage/memory}/sqlite/migrations/018_skill_system_v2.sql +0 -0
  375. /package/dist/{memory → storage/memory}/sqlite/migrations/019_task_scoped_command_grants.sql +0 -0
@@ -1,1077 +1 @@
1
- import { randomUUID } from 'node:crypto';
2
- export class SkillRepository {
3
- db;
4
- constructor(db) {
5
- this.db = db;
6
- }
7
- register(input) {
8
- const validation = validateSkill(input);
9
- if (!validation.ok)
10
- return validation;
11
- const result = this.db.transaction(() => {
12
- const existing = this.findByNaturalKey(input.project, input.scope, input.name);
13
- const id = existing?.id ?? randomUUID();
14
- const now = new Date().toISOString();
15
- this.db.connection
16
- .prepare(`
17
- INSERT INTO skills(id, project, scope, name, description, created_at, updated_at)
18
- VALUES (@id, @project, @scope, @name, @description, @createdAt, @updatedAt)
19
- ON CONFLICT(project, scope, name) DO UPDATE SET
20
- description=excluded.description,
21
- updated_at=excluded.updated_at
22
- `)
23
- .run({
24
- id,
25
- project: input.project,
26
- scope: input.scope,
27
- name: input.name,
28
- description: input.description,
29
- createdAt: existing?.created_at ?? now,
30
- updatedAt: now,
31
- });
32
- const read = this.getById(id);
33
- if (!read.ok)
34
- throw new Error(read.error.message);
35
- return read.value;
36
- });
37
- return result;
38
- }
39
- addVersion(input) {
40
- const validation = validateVersion(input);
41
- if (!validation.ok)
42
- return validation;
43
- const result = this.db.transaction(() => {
44
- const skill = this.getById(input.skillId);
45
- if (!skill.ok)
46
- throw new SkillRegistryValidationError(skill.error.message);
47
- const existing = this.findVersion(input.skillId, input.version);
48
- const id = existing?.id ?? randomUUID();
49
- const now = new Date().toISOString();
50
- const status = input.activate === true ? 'active' : (input.status ?? existing?.status ?? 'draft');
51
- this.db.connection
52
- .prepare(`
53
- INSERT INTO skill_versions(id, skill_id, version, source_kind, source_path, source_url, source_inline_metadata_json, compatibility_json, status, created_at)
54
- VALUES (@id, @skillId, @version, @sourceKind, @sourcePath, @sourceUrl, @sourceInlineMetadataJson, @compatibilityJson, @status, @createdAt)
55
- ON CONFLICT(skill_id, version) DO UPDATE SET
56
- source_kind=excluded.source_kind,
57
- source_path=excluded.source_path,
58
- source_url=excluded.source_url,
59
- source_inline_metadata_json=excluded.source_inline_metadata_json,
60
- compatibility_json=excluded.compatibility_json,
61
- status=excluded.status
62
- `)
63
- .run({
64
- id,
65
- skillId: input.skillId,
66
- version: input.version,
67
- sourceKind: input.source.kind,
68
- sourcePath: input.source.path ?? null,
69
- sourceUrl: input.source.url ?? null,
70
- sourceInlineMetadataJson: JSON.stringify(input.source.inlineMetadata ?? {}),
71
- compatibilityJson: JSON.stringify(input.compatibility ?? {}),
72
- status,
73
- createdAt: existing?.created_at ?? now,
74
- });
75
- if (input.activate === true) {
76
- this.db.connection.prepare('UPDATE skills SET current_version_id=?, updated_at=? WHERE id=?').run(id, now, input.skillId);
77
- }
78
- const read = this.getVersion(id);
79
- if (!read.ok)
80
- throw new Error(read.error.message);
81
- return read.value;
82
- });
83
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError) {
84
- return validationFailure(result.error.cause.message);
85
- }
86
- return result;
87
- }
88
- attach(input) {
89
- const validation = validateAttachment(input);
90
- if (!validation.ok)
91
- return validation;
92
- const result = this.db.transaction(() => {
93
- const skill = this.getById(input.skillId);
94
- if (!skill.ok)
95
- throw new SkillRegistryValidationError(skill.error.message);
96
- if (input.versionId !== undefined)
97
- assertVersionBelongsToSkill(this.db, input.versionId, input.skillId);
98
- const existing = this.db.connection
99
- .prepare('SELECT * FROM skill_attachments WHERE skill_id=? AND target_type=? AND target_key=?')
100
- .get(input.skillId, input.targetType, input.targetKey);
101
- const id = existing?.id ?? randomUUID();
102
- const now = new Date().toISOString();
103
- this.db.connection
104
- .prepare(`
105
- INSERT INTO skill_attachments(id, skill_id, version_id, target_type, target_key, metadata_json, created_at)
106
- VALUES (@id, @skillId, @versionId, @targetType, @targetKey, @metadataJson, @createdAt)
107
- ON CONFLICT(skill_id, target_type, target_key) DO UPDATE SET
108
- version_id=excluded.version_id,
109
- metadata_json=excluded.metadata_json
110
- `)
111
- .run({
112
- id,
113
- skillId: input.skillId,
114
- versionId: input.versionId ?? null,
115
- targetType: input.targetType,
116
- targetKey: input.targetKey,
117
- metadataJson: JSON.stringify(input.metadata ?? {}),
118
- createdAt: existing?.created_at ?? now,
119
- });
120
- const read = this.getAttachment(id);
121
- if (!read.ok)
122
- throw new Error(read.error.message);
123
- return read.value;
124
- });
125
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError) {
126
- return validationFailure(result.error.cause.message);
127
- }
128
- return result;
129
- }
130
- detach(skillId, targetType, targetKey) {
131
- try {
132
- const result = this.db.connection
133
- .prepare('DELETE FROM skill_attachments WHERE skill_id=? AND target_type=? AND target_key=?')
134
- .run(skillId, targetType, targetKey);
135
- return ok({ detached: result.changes > 0 });
136
- }
137
- catch (cause) {
138
- return fail('Failed to detach skill', cause);
139
- }
140
- }
141
- recordUsage(input) {
142
- const validation = validateUsage(input);
143
- if (!validation.ok)
144
- return validation;
145
- const result = this.db.transaction(() => {
146
- const skill = this.getById(input.skillId);
147
- if (!skill.ok)
148
- throw new SkillRegistryValidationError(skill.error.message);
149
- if (input.versionId !== undefined)
150
- assertVersionBelongsToSkill(this.db, input.versionId, input.skillId);
151
- const id = randomUUID();
152
- const now = new Date().toISOString();
153
- this.db.connection
154
- .prepare(`
155
- INSERT INTO skill_usage_records(id, skill_id, version_id, run_id, target_type, target_key, outcome, notes, created_at, workflow, phase, provider_adapter, agent_id, intent_json, evidence_json)
156
- VALUES (@id, @skillId, @versionId, @runId, @targetType, @targetKey, @outcome, @notes, @createdAt, @workflow, @phase, @providerAdapter, @agentId, @intentJson, @evidenceJson)
157
- `)
158
- .run({
159
- id,
160
- skillId: input.skillId,
161
- versionId: input.versionId ?? null,
162
- runId: input.runId ?? null,
163
- targetType: input.targetType ?? null,
164
- targetKey: input.targetKey ?? null,
165
- outcome: input.outcome,
166
- notes: input.notes ?? null,
167
- createdAt: now,
168
- workflow: input.workflow ?? null,
169
- phase: input.phase ?? null,
170
- providerAdapter: input.providerAdapter ?? null,
171
- agentId: input.agentId ?? null,
172
- intentJson: input.intent === undefined ? null : JSON.stringify(input.intent),
173
- evidenceJson: input.evidence === undefined ? null : JSON.stringify(input.evidence),
174
- });
175
- const read = this.getUsage(id);
176
- if (!read.ok)
177
- throw new Error(read.error.message);
178
- return read.value;
179
- });
180
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError) {
181
- return validationFailure(result.error.cause.message);
182
- }
183
- return result;
184
- }
185
- recordActivation(input) {
186
- const validation = validateActivation(input);
187
- if (!validation.ok)
188
- return validation;
189
- const result = this.db.transaction(() => {
190
- const skill = this.getById(input.skillId);
191
- if (!skill.ok)
192
- throw new SkillRegistryValidationError(skill.error.message);
193
- if (input.versionId !== undefined)
194
- assertVersionBelongsToSkill(this.db, input.versionId, input.skillId);
195
- if (skill.value.project !== input.project || skill.value.scope !== input.scope)
196
- throw new SkillRegistryValidationError('Skill does not belong to the requested project/scope');
197
- const id = randomUUID();
198
- const now = new Date().toISOString();
199
- this.db.connection
200
- .prepare(`
201
- INSERT INTO skill_activation_records(id, project, scope, skill_id, version_id, run_id, agent_id, workflow, phase, provider_adapter, intent_json, reason, payload_metadata_json, created_at)
202
- VALUES (@id, @project, @scope, @skillId, @versionId, @runId, @agentId, @workflow, @phase, @providerAdapter, @intentJson, @reason, @payloadMetadataJson, @createdAt)
203
- `)
204
- .run({
205
- id,
206
- project: input.project,
207
- scope: input.scope,
208
- skillId: input.skillId,
209
- versionId: input.versionId ?? null,
210
- runId: input.runId ?? null,
211
- agentId: input.agentId ?? null,
212
- workflow: input.workflow ?? null,
213
- phase: input.phase ?? null,
214
- providerAdapter: input.providerAdapter ?? null,
215
- intentJson: input.intent === undefined ? null : JSON.stringify(input.intent),
216
- reason: input.reason ?? null,
217
- payloadMetadataJson: JSON.stringify(input.payloadMetadata ?? {}),
218
- createdAt: now,
219
- });
220
- const read = this.getActivation(id);
221
- if (!read.ok)
222
- throw new Error(read.error.message);
223
- return read.value;
224
- });
225
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError) {
226
- return validationFailure(result.error.cause.message);
227
- }
228
- return result;
229
- }
230
- createDraft(input) {
231
- const validation = validateCreateDraft(input);
232
- if (!validation.ok)
233
- return validation;
234
- const result = this.db.transaction(() => {
235
- const existing = this.findByNaturalKey(input.project, input.scope ?? 'project', input.name);
236
- const skill = existing === undefined ? this.register({ project: input.project, scope: input.scope ?? 'project', name: input.name, description: input.description }) : ok(mapSkill(existing));
237
- if (!skill.ok)
238
- throw new SkillRegistryValidationError(skill.error.message);
239
- if (input.draftParentVersionId !== undefined)
240
- assertVersionBelongsToSkill(this.db, input.draftParentVersionId, skill.value.id);
241
- if (this.findVersion(skill.value.id, input.version) !== undefined)
242
- throw new SkillRegistryValidationError(`Skill version already exists: ${input.version}`);
243
- const now = new Date().toISOString();
244
- const id = randomUUID();
245
- this.db.connection
246
- .prepare(`
247
- INSERT INTO skill_versions(id, skill_id, version, source_kind, source_path, source_url, source_inline_metadata_json, compatibility_json, status, created_at, lifecycle_label, draft_parent_version_id, draft_revision, governance_json)
248
- VALUES (@id, @skillId, @version, @sourceKind, @sourcePath, @sourceUrl, @sourceInlineMetadataJson, @compatibilityJson, 'draft', @createdAt, 'draft', @draftParentVersionId, 1, @governanceJson)
249
- `)
250
- .run({
251
- id,
252
- skillId: skill.value.id,
253
- version: input.version,
254
- sourceKind: input.source.kind,
255
- sourcePath: input.source.path ?? null,
256
- sourceUrl: input.source.url ?? null,
257
- sourceInlineMetadataJson: JSON.stringify(input.source.inlineMetadata ?? {}),
258
- compatibilityJson: JSON.stringify(input.compatibility ?? {}),
259
- createdAt: now,
260
- draftParentVersionId: input.draftParentVersionId ?? null,
261
- governanceJson: JSON.stringify(input.governance ?? {}),
262
- });
263
- const version = this.getVersion(id);
264
- if (!version.ok)
265
- throw new Error(version.error.message);
266
- const after = versionSnapshot(version.value);
267
- const event = this.recordLifecycleEvent({
268
- project: skill.value.project,
269
- scope: skill.value.scope,
270
- skillId: skill.value.id,
271
- versionId: version.value.id,
272
- eventType: 'draft-created',
273
- actor: input.actor,
274
- ...(input.runId === undefined ? {} : { runId: input.runId }),
275
- ...(input.agentId === undefined ? {} : { agentId: input.agentId }),
276
- ...(input.reason === undefined ? {} : { reason: input.reason }),
277
- before: existing === undefined ? {} : { skillExisted: true, currentVersionId: existing.current_version_id ?? null },
278
- after,
279
- ...(input.evidence === undefined ? {} : { evidence: input.evidence }),
280
- });
281
- if (!event.ok)
282
- throw new Error(event.error.message);
283
- return { skill: skill.value, version: version.value, event: event.value };
284
- });
285
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError)
286
- return validationFailure(result.error.cause.message);
287
- return result;
288
- }
289
- updateDraft(input) {
290
- const validation = validateUpdateDraft(input);
291
- if (!validation.ok)
292
- return validation;
293
- const result = this.db.transaction(() => {
294
- const skill = resolveSkillForMutation(this, input.project, input.scope ?? 'project', input.skillId, input.name);
295
- const version = resolveVersionForMutation(this, skill.id, input.versionId, input.version);
296
- if (version.status !== 'draft')
297
- throw new SkillRegistryValidationError(`Cannot update ${version.status} skill versions; only draft versions can be updated`);
298
- if (input.expectedDraftRevision !== undefined && (version.draftRevision ?? 0) !== input.expectedDraftRevision) {
299
- throw new SkillRegistryValidationError(`Draft revision conflict: expected ${input.expectedDraftRevision}, found ${version.draftRevision ?? 0}`);
300
- }
301
- const before = versionSnapshot(version);
302
- const nextRevision = (version.draftRevision ?? 0) + 1;
303
- this.db.connection
304
- .prepare(`
305
- UPDATE skill_versions SET
306
- source_kind=COALESCE(@sourceKind, source_kind),
307
- source_path=@sourcePath,
308
- source_url=@sourceUrl,
309
- source_inline_metadata_json=COALESCE(@sourceInlineMetadataJson, source_inline_metadata_json),
310
- compatibility_json=COALESCE(@compatibilityJson, compatibility_json),
311
- draft_revision=@draftRevision,
312
- governance_json=COALESCE(@governanceJson, governance_json)
313
- WHERE id=@id
314
- `)
315
- .run({
316
- id: version.id,
317
- sourceKind: input.source?.kind ?? null,
318
- sourcePath: input.source === undefined ? (version.source.path ?? null) : (input.source.path ?? null),
319
- sourceUrl: input.source === undefined ? (version.source.url ?? null) : (input.source.url ?? null),
320
- sourceInlineMetadataJson: input.source === undefined ? null : JSON.stringify(input.source.inlineMetadata ?? {}),
321
- compatibilityJson: input.compatibility === undefined ? null : JSON.stringify(input.compatibility),
322
- draftRevision: nextRevision,
323
- governanceJson: input.governance === undefined ? null : JSON.stringify(input.governance),
324
- });
325
- const updated = this.getVersion(version.id);
326
- if (!updated.ok)
327
- throw new Error(updated.error.message);
328
- const event = this.recordLifecycleEvent({
329
- project: skill.project,
330
- scope: skill.scope,
331
- skillId: skill.id,
332
- versionId: updated.value.id,
333
- eventType: 'draft-updated',
334
- actor: input.actor,
335
- ...(input.runId === undefined ? {} : { runId: input.runId }),
336
- ...(input.agentId === undefined ? {} : { agentId: input.agentId }),
337
- ...(input.reason === undefined ? {} : { reason: input.reason }),
338
- before,
339
- after: versionSnapshot(updated.value),
340
- ...(input.evidence === undefined ? {} : { evidence: input.evidence }),
341
- });
342
- if (!event.ok)
343
- throw new Error(event.error.message);
344
- return { skill, version: updated.value, event: event.value };
345
- });
346
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError)
347
- return validationFailure(result.error.cause.message);
348
- return result;
349
- }
350
- publishVersion(input) {
351
- const validation = validatePublishVersion(input);
352
- if (!validation.ok)
353
- return validation;
354
- const result = this.db.transaction(() => {
355
- const skill = resolveSkillForMutation(this, input.project, input.scope ?? 'project', input.skillId, input.name);
356
- const version = resolveVersionForMutation(this, skill.id, input.versionId, input.version);
357
- if (version.status !== 'draft')
358
- throw new SkillRegistryValidationError(`Cannot publish ${version.status} skill versions; only draft versions can be published`);
359
- const before = { skill: { currentVersionId: skill.currentVersionId ?? null }, version: versionSnapshot(version) };
360
- const previousCurrentVersionId = skill.currentVersionId ?? null;
361
- const now = new Date().toISOString();
362
- this.db.connection
363
- .prepare(`
364
- UPDATE skill_versions SET status='active', lifecycle_label='published', published_at=@publishedAt, published_by=@publishedBy, governance_json=COALESCE(@governanceJson, governance_json)
365
- WHERE id=@id
366
- `)
367
- .run({ id: version.id, publishedAt: now, publishedBy: input.actor.id, governanceJson: input.governance === undefined ? null : JSON.stringify(input.governance) });
368
- this.db.connection.prepare('UPDATE skills SET current_version_id=?, updated_at=? WHERE id=?').run(version.id, now, skill.id);
369
- const updatedSkill = this.getById(skill.id);
370
- if (!updatedSkill.ok)
371
- throw new Error(updatedSkill.error.message);
372
- const updated = this.getVersion(version.id);
373
- if (!updated.ok)
374
- throw new Error(updated.error.message);
375
- const event = this.recordLifecycleEvent({
376
- project: updatedSkill.value.project,
377
- scope: updatedSkill.value.scope,
378
- skillId: updatedSkill.value.id,
379
- versionId: updated.value.id,
380
- eventType: 'version-published',
381
- actor: input.actor,
382
- ...(input.runId === undefined ? {} : { runId: input.runId }),
383
- ...(input.agentId === undefined ? {} : { agentId: input.agentId }),
384
- reason: input.reason,
385
- before,
386
- after: { skill: { currentVersionId: updated.value.id }, version: versionSnapshot(updated.value) },
387
- ...(input.evidence === undefined ? {} : { evidence: input.evidence }),
388
- });
389
- if (!event.ok)
390
- throw new Error(event.error.message);
391
- return { skill: updatedSkill.value, version: updated.value, event: event.value, previousCurrentVersionId };
392
- });
393
- if (!result.ok && result.error.cause instanceof SkillRegistryValidationError)
394
- return validationFailure(result.error.cause.message);
395
- return result;
396
- }
397
- getById(id) {
398
- try {
399
- const row = this.db.connection.prepare('SELECT * FROM skills WHERE id=?').get(id);
400
- return row ? ok(mapSkill(row)) : missing(`Skill not found: ${id}`);
401
- }
402
- catch (cause) {
403
- return fail('Failed to read skill', cause);
404
- }
405
- }
406
- getByName(project, scope, name) {
407
- try {
408
- const row = this.findByNaturalKey(project, scope, name);
409
- return row ? ok(mapSkill(row)) : missing(`Skill not found: ${project}/${scope}/${name}`);
410
- }
411
- catch (cause) {
412
- return fail('Failed to read skill by name', cause);
413
- }
414
- }
415
- getDetails(id) {
416
- const skill = this.getById(id);
417
- if (!skill.ok)
418
- return skill;
419
- const versions = this.listVersions(id);
420
- if (!versions.ok)
421
- return versions;
422
- const attachments = this.listAttachments(id);
423
- if (!attachments.ok)
424
- return attachments;
425
- const usage = this.listUsage(id);
426
- if (!usage.ok)
427
- return usage;
428
- const details = { ...skill.value, versions: versions.value, attachments: attachments.value, usage: usage.value };
429
- const currentVersion = versions.value.find((version) => version.id === skill.value.currentVersionId);
430
- if (currentVersion !== undefined)
431
- details.currentVersion = currentVersion;
432
- return ok(details);
433
- }
434
- list(filters = {}) {
435
- try {
436
- const where = [];
437
- const parameters = {};
438
- if (filters.project !== undefined) {
439
- where.push('project=@project');
440
- parameters.project = filters.project;
441
- }
442
- if (filters.scope !== undefined) {
443
- where.push('scope=@scope');
444
- parameters.scope = filters.scope;
445
- }
446
- const rows = this.db.connection
447
- .prepare(`
448
- SELECT * FROM skills
449
- ${where.length ? `WHERE ${where.join(' AND ')}` : ''}
450
- ORDER BY name ASC
451
- `)
452
- .all(parameters);
453
- return ok(rows.map((row) => {
454
- const summary = mapSkill(row);
455
- if (summary.currentVersionId !== undefined) {
456
- const version = this.getVersion(summary.currentVersionId);
457
- if (version.ok)
458
- summary.currentVersion = version.value;
459
- }
460
- return summary;
461
- }));
462
- }
463
- catch (cause) {
464
- return fail('Failed to list skills', cause);
465
- }
466
- }
467
- search(input) {
468
- try {
469
- const limit = normalizeLimit(input.limit);
470
- const where = ['s.project=@project', 's.scope=@scope'];
471
- const parameters = { project: input.project, scope: input.scope ?? 'project', limit };
472
- if (input.query !== undefined && input.query.trim().length > 0) {
473
- where.push('(s.name LIKE @query OR s.description LIKE @query OR cv.version LIKE @query)');
474
- parameters.query = `%${input.query.trim()}%`;
475
- }
476
- if (input.status !== undefined) {
477
- where.push('cv.status=@status');
478
- parameters.status = input.status;
479
- }
480
- if (input.sourceKind !== undefined) {
481
- where.push('cv.source_kind=@sourceKind');
482
- parameters.sourceKind = input.sourceKind;
483
- }
484
- const rows = this.db.connection
485
- .prepare(`
486
- SELECT
487
- s.*,
488
- cv.id AS current_version_row_id,
489
- cv.version AS current_version,
490
- cv.source_kind AS current_source_kind,
491
- cv.source_path AS current_source_path,
492
- cv.source_url AS current_source_url,
493
- cv.source_inline_metadata_json AS current_source_inline_metadata_json,
494
- cv.status AS current_status,
495
- (SELECT COUNT(*) FROM skill_versions sv WHERE sv.skill_id=s.id) AS version_count,
496
- (SELECT COUNT(*) FROM skill_attachments sa WHERE sa.skill_id=s.id) AS attachment_count
497
- FROM skills s
498
- LEFT JOIN skill_versions cv ON cv.id=s.current_version_id
499
- WHERE ${where.join(' AND ')}
500
- ORDER BY s.name ASC, s.id ASC
501
- LIMIT @limit
502
- `)
503
- .all(parameters);
504
- return ok(rows.map(mapSearchItem));
505
- }
506
- catch (cause) {
507
- return fail('Failed to search skills', cause);
508
- }
509
- }
510
- countSearchMatches(input) {
511
- try {
512
- const where = ['s.project=@project', 's.scope=@scope'];
513
- const parameters = { project: input.project, scope: input.scope ?? 'project' };
514
- if (input.query !== undefined && input.query.trim().length > 0) {
515
- where.push('(s.name LIKE @query OR s.description LIKE @query OR cv.version LIKE @query)');
516
- parameters.query = `%${input.query.trim()}%`;
517
- }
518
- if (input.status !== undefined) {
519
- where.push('cv.status=@status');
520
- parameters.status = input.status;
521
- }
522
- if (input.sourceKind !== undefined) {
523
- where.push('cv.source_kind=@sourceKind');
524
- parameters.sourceKind = input.sourceKind;
525
- }
526
- const row = this.db.connection
527
- .prepare(`SELECT COUNT(*) AS count FROM skills s LEFT JOIN skill_versions cv ON cv.id=s.current_version_id WHERE ${where.join(' AND ')}`)
528
- .get(parameters);
529
- return ok(row.count);
530
- }
531
- catch (cause) {
532
- return fail('Failed to count skill search matches', cause);
533
- }
534
- }
535
- getV2Counts(project, scope) {
536
- try {
537
- const versions = zeroVersionCounts();
538
- for (const row of this.db.connection
539
- .prepare(`SELECT sv.status AS status, COUNT(*) AS count FROM skill_versions sv JOIN skills s ON s.id=sv.skill_id WHERE s.project=? AND s.scope=? GROUP BY sv.status`)
540
- .all(project, scope)) {
541
- versions[row.status] = row.count;
542
- }
543
- const proposals = zeroProposalCounts();
544
- for (const row of this.db.connection
545
- .prepare(`SELECT p.status AS status, COUNT(*) AS count FROM skill_improvement_proposals p JOIN skills s ON s.id=p.skill_id WHERE s.project=? AND s.scope=? GROUP BY p.status`)
546
- .all(project, scope)) {
547
- proposals[row.status] = row.count;
548
- }
549
- const evaluationRequests = zeroEvaluationRequestCounts();
550
- for (const row of this.db.connection
551
- .prepare('SELECT status, COUNT(*) AS count FROM skill_evaluation_requests WHERE project=? AND scope=? GROUP BY status')
552
- .all(project, scope)) {
553
- evaluationRequests[row.status] = row.count;
554
- }
555
- const evaluationResults = zeroEvaluationResultCounts();
556
- for (const row of this.db.connection
557
- .prepare(`SELECT r.status AS status, COUNT(*) AS count FROM skill_evaluation_results r JOIN skill_evaluation_scenarios e ON e.id=r.scenario_id JOIN skills s ON s.id=e.skill_id WHERE s.project=? AND s.scope=? GROUP BY r.status`)
558
- .all(project, scope)) {
559
- evaluationResults[row.status] = row.count;
560
- }
561
- return ok({
562
- versions,
563
- attachments: countScoped(this.db, 'skill_attachments', project, scope),
564
- usageRecords: countScoped(this.db, 'skill_usage_records', project, scope),
565
- activationRecords: countDirectScoped(this.db, 'skill_activation_records', project, scope),
566
- improvementProposals: proposals,
567
- evaluationScenarios: countScoped(this.db, 'skill_evaluation_scenarios', project, scope),
568
- evaluationRequests,
569
- evaluationResults,
570
- drafts: versions.draft,
571
- deprecated: versions.deprecated,
572
- archived: versions.archived,
573
- });
574
- }
575
- catch (cause) {
576
- return fail('Failed to count skill registry v2 records', cause);
577
- }
578
- }
579
- listVersions(skillId) {
580
- try {
581
- const rows = this.db.connection.prepare('SELECT * FROM skill_versions WHERE skill_id=? ORDER BY created_at DESC, version DESC').all(skillId);
582
- return ok(rows.map(mapVersion));
583
- }
584
- catch (cause) {
585
- return fail('Failed to list skill versions', cause);
586
- }
587
- }
588
- listAttachments(skillId) {
589
- try {
590
- const rows = this.db.connection.prepare('SELECT * FROM skill_attachments WHERE skill_id=? ORDER BY target_type ASC, target_key ASC').all(skillId);
591
- return ok(rows.map(mapAttachment));
592
- }
593
- catch (cause) {
594
- return fail('Failed to list skill attachments', cause);
595
- }
596
- }
597
- listAttachmentsForTargets(targets) {
598
- try {
599
- if (targets.length === 0)
600
- return ok([]);
601
- const rows = [];
602
- const read = this.db.connection.prepare('SELECT * FROM skill_attachments WHERE target_type=? AND target_key=? ORDER BY created_at ASC, id ASC');
603
- for (const target of targets)
604
- rows.push(...read.all(target.targetType, target.targetKey));
605
- return ok(rows.map(mapAttachment));
606
- }
607
- catch (cause) {
608
- return fail('Failed to list skill attachments for targets', cause);
609
- }
610
- }
611
- listUsage(skillId) {
612
- try {
613
- const rows = this.db.connection.prepare('SELECT * FROM skill_usage_records WHERE skill_id=? ORDER BY created_at DESC').all(skillId);
614
- return ok(rows.map(mapUsage));
615
- }
616
- catch (cause) {
617
- return fail('Failed to list skill usage', cause);
618
- }
619
- }
620
- getVersion(id) {
621
- try {
622
- const row = this.db.connection.prepare('SELECT * FROM skill_versions WHERE id=?').get(id);
623
- return row ? ok(mapVersion(row)) : missing(`Skill version not found: ${id}`);
624
- }
625
- catch (cause) {
626
- return fail('Failed to read skill version', cause);
627
- }
628
- }
629
- getVersionBySkillVersion(skillId, version) {
630
- try {
631
- const row = this.findVersion(skillId, version);
632
- return row ? ok(mapVersion(row)) : missing(`Skill version not found: ${version}`);
633
- }
634
- catch (cause) {
635
- return fail('Failed to read skill version', cause);
636
- }
637
- }
638
- getAttachment(id) {
639
- try {
640
- const row = this.db.connection.prepare('SELECT * FROM skill_attachments WHERE id=?').get(id);
641
- return row ? ok(mapAttachment(row)) : missing(`Skill attachment not found: ${id}`);
642
- }
643
- catch (cause) {
644
- return fail('Failed to read skill attachment', cause);
645
- }
646
- }
647
- getUsage(id) {
648
- try {
649
- const row = this.db.connection.prepare('SELECT * FROM skill_usage_records WHERE id=?').get(id);
650
- return row ? ok(mapUsage(row)) : missing(`Skill usage record not found: ${id}`);
651
- }
652
- catch (cause) {
653
- return fail('Failed to read skill usage record', cause);
654
- }
655
- }
656
- getActivation(id) {
657
- try {
658
- const row = this.db.connection.prepare('SELECT * FROM skill_activation_records WHERE id=?').get(id);
659
- return row ? ok(mapActivation(row)) : missing(`Skill activation record not found: ${id}`);
660
- }
661
- catch (cause) {
662
- return fail('Failed to read skill activation record', cause);
663
- }
664
- }
665
- recordLifecycleEvent(input) {
666
- try {
667
- const id = randomUUID();
668
- const now = new Date().toISOString();
669
- this.db.connection
670
- .prepare(`
671
- INSERT INTO skill_lifecycle_events(id, project, scope, skill_id, version_id, event_type, actor_type, actor_id, run_id, agent_id, reason, before_json, after_json, evidence_json, created_at)
672
- VALUES (@id, @project, @scope, @skillId, @versionId, @eventType, @actorType, @actorId, @runId, @agentId, @reason, @beforeJson, @afterJson, @evidenceJson, @createdAt)
673
- `)
674
- .run({
675
- id,
676
- project: input.project,
677
- scope: input.scope,
678
- skillId: input.skillId,
679
- versionId: input.versionId ?? null,
680
- eventType: input.eventType,
681
- actorType: input.actor?.type ?? null,
682
- actorId: input.actor?.id ?? null,
683
- runId: input.runId ?? null,
684
- agentId: input.agentId ?? null,
685
- reason: input.reason ?? null,
686
- beforeJson: input.before === undefined ? null : JSON.stringify(input.before),
687
- afterJson: input.after === undefined ? null : JSON.stringify(input.after),
688
- evidenceJson: input.evidence === undefined ? null : JSON.stringify(input.evidence),
689
- createdAt: now,
690
- });
691
- const row = this.db.connection.prepare('SELECT * FROM skill_lifecycle_events WHERE id=?').get(id);
692
- return row ? ok(mapLifecycleEvent(row)) : missing(`Skill lifecycle event not found: ${id}`);
693
- }
694
- catch (cause) {
695
- return fail('Failed to record skill lifecycle event', cause);
696
- }
697
- }
698
- findByNaturalKey(project, scope, name) {
699
- return this.db.connection.prepare('SELECT * FROM skills WHERE project=? AND scope=? AND name=?').get(project, scope, name);
700
- }
701
- findVersion(skillId, version) {
702
- return this.db.connection.prepare('SELECT * FROM skill_versions WHERE skill_id=? AND version=?').get(skillId, version);
703
- }
704
- }
705
- function validateSkill(input) {
706
- if (!input.project.trim())
707
- return validationFailure('Skill project is required');
708
- if (!input.name.trim())
709
- return validationFailure('Skill name is required');
710
- if (!input.description.trim())
711
- return validationFailure('Skill description is required');
712
- return ok(undefined);
713
- }
714
- function validateVersion(input) {
715
- if (!input.skillId.trim())
716
- return validationFailure('Skill id is required');
717
- if (!input.version.trim())
718
- return validationFailure('Skill version is required');
719
- if (input.source.kind === 'path' && !input.source.path?.trim())
720
- return validationFailure('Path skill sources require source.path');
721
- if (input.source.kind === 'url' && !input.source.url?.trim())
722
- return validationFailure('URL skill sources require source.url');
723
- if (input.source.kind === 'inline' && (input.source.path !== undefined || input.source.url !== undefined))
724
- return validationFailure('Inline skill sources cannot include source.path or source.url');
725
- return ok(undefined);
726
- }
727
- function validateAttachment(input) {
728
- if (!input.skillId.trim())
729
- return validationFailure('Skill id is required');
730
- if (!input.targetKey.trim())
731
- return validationFailure('Skill attachment target key is required');
732
- return ok(undefined);
733
- }
734
- function validateUsage(input) {
735
- if (!input.skillId.trim())
736
- return validationFailure('Skill id is required');
737
- if (input.targetType !== undefined && !input.targetKey?.trim())
738
- return validationFailure('Skill usage target key is required when target type is set');
739
- if (input.targetType === undefined && input.targetKey !== undefined)
740
- return validationFailure('Skill usage target type is required when target key is set');
741
- if (input.versionId !== undefined && !input.versionId.trim())
742
- return validationFailure('Skill version id must not be empty');
743
- return ok(undefined);
744
- }
745
- function validateActivation(input) {
746
- if (!input.project.trim())
747
- return validationFailure('Skill activation project is required');
748
- if (!input.skillId.trim())
749
- return validationFailure('Skill id is required');
750
- if (input.versionId !== undefined && !input.versionId.trim())
751
- return validationFailure('Skill version id must not be empty');
752
- return ok(undefined);
753
- }
754
- function validateCreateDraft(input) {
755
- if (!input.project.trim())
756
- return validationFailure('Skill draft project is required');
757
- if (!input.name.trim())
758
- return validationFailure('Skill draft name is required');
759
- if (!input.description.trim())
760
- return validationFailure('Skill draft description is required');
761
- if (!input.version.trim())
762
- return validationFailure('Skill draft version is required');
763
- const source = validateSource(input.source);
764
- if (!source.ok)
765
- return source;
766
- return validateLifecycleActor(input.actor);
767
- }
768
- function validateUpdateDraft(input) {
769
- if (!input.project.trim())
770
- return validationFailure('Skill draft project is required');
771
- if ((input.skillId === undefined || !input.skillId.trim()) && (input.name === undefined || !input.name.trim()))
772
- return validationFailure('Either skillId or name is required');
773
- if ((input.versionId === undefined || !input.versionId.trim()) && (input.version === undefined || !input.version.trim()))
774
- return validationFailure('Either versionId or version is required');
775
- if (input.versionId !== undefined && input.version !== undefined)
776
- return validationFailure('Use either versionId or version, not both');
777
- if (input.source === undefined && input.compatibility === undefined && input.governance === undefined)
778
- return validationFailure('At least one draft update field is required');
779
- if (input.expectedDraftRevision !== undefined && (!Number.isSafeInteger(input.expectedDraftRevision) || input.expectedDraftRevision < 1)) {
780
- return validationFailure('expectedDraftRevision must be a positive safe integer');
781
- }
782
- if (input.source !== undefined) {
783
- const source = validateSource(input.source);
784
- if (!source.ok)
785
- return source;
786
- }
787
- return validateLifecycleActor(input.actor);
788
- }
789
- function validatePublishVersion(input) {
790
- if (!input.project.trim())
791
- return validationFailure('Skill publish project is required');
792
- if ((input.skillId === undefined || !input.skillId.trim()) && (input.name === undefined || !input.name.trim()))
793
- return validationFailure('Either skillId or name is required');
794
- if ((input.versionId === undefined || !input.versionId.trim()) && (input.version === undefined || !input.version.trim()))
795
- return validationFailure('Either versionId or version is required');
796
- if (input.versionId !== undefined && input.version !== undefined)
797
- return validationFailure('Use either versionId or version, not both');
798
- if (!input.reason.trim())
799
- return validationFailure('Publish reason is required');
800
- return validateLifecycleActor(input.actor);
801
- }
802
- function validateLifecycleActor(actor) {
803
- if (!['human', 'agent', 'system'].includes(actor.type))
804
- return validationFailure('Lifecycle actor type must be human, agent, or system');
805
- if (!actor.id.trim())
806
- return validationFailure('Lifecycle actor id is required');
807
- return ok(undefined);
808
- }
809
- function validateSource(source) {
810
- if (source.kind === 'path' && !source.path?.trim())
811
- return validationFailure('Path skill sources require source.path');
812
- if (source.kind === 'url' && !source.url?.trim())
813
- return validationFailure('URL skill sources require source.url');
814
- if (source.kind === 'inline' && (source.path !== undefined || source.url !== undefined))
815
- return validationFailure('Inline skill sources cannot include source.path or source.url');
816
- return ok(undefined);
817
- }
818
- function assertVersionBelongsToSkill(db, versionId, skillId) {
819
- const row = db.connection.prepare('SELECT skill_id FROM skill_versions WHERE id=?').get(versionId);
820
- if (row === undefined)
821
- throw new SkillRegistryValidationError(`Skill version not found: ${versionId}`);
822
- if (row.skill_id !== skillId)
823
- throw new SkillRegistryValidationError('Skill version must belong to the attached skill');
824
- }
825
- function mapSkill(row) {
826
- const skill = {
827
- id: row.id,
828
- project: row.project,
829
- scope: row.scope,
830
- name: row.name,
831
- description: row.description,
832
- createdAt: row.created_at,
833
- updatedAt: row.updated_at,
834
- };
835
- if (row.current_version_id !== null)
836
- skill.currentVersionId = row.current_version_id;
837
- return skill;
838
- }
839
- function mapSearchItem(row) {
840
- const source = mapNullableSource(row.current_source_kind, row.current_source_path, row.current_source_url, row.current_source_inline_metadata_json);
841
- const currentVersionId = row.current_version_row_id ?? null;
842
- return {
843
- id: row.id,
844
- project: row.project,
845
- scope: row.scope,
846
- name: row.name,
847
- description: row.description,
848
- currentVersionId,
849
- currentVersion: row.current_version ?? null,
850
- status: row.current_status ?? (row.current_version_id === null ? 'missing-current-version' : 'missing-current-version-record'),
851
- source,
852
- attachments: Number(row.attachment_count ?? 0),
853
- versions: Number(row.version_count ?? 0),
854
- };
855
- }
856
- function mapNullableSource(kind, path, url, inlineMetadataJson) {
857
- if (kind === null)
858
- return null;
859
- const source = { kind: kind };
860
- if (path !== null)
861
- source.path = path;
862
- if (url !== null)
863
- source.url = url;
864
- const inlineMetadata = JSON.parse(inlineMetadataJson ?? '{}');
865
- if (Object.keys(inlineMetadata).length > 0)
866
- source.inlineMetadata = inlineMetadata;
867
- return source;
868
- }
869
- function mapVersion(row) {
870
- const source = { kind: row.source_kind };
871
- if (row.source_path !== null)
872
- source.path = row.source_path;
873
- if (row.source_url !== null)
874
- source.url = row.source_url;
875
- const inlineMetadata = JSON.parse(row.source_inline_metadata_json ?? '{}');
876
- if (Object.keys(inlineMetadata).length > 0)
877
- source.inlineMetadata = inlineMetadata;
878
- const version = {
879
- id: row.id,
880
- skillId: row.skill_id,
881
- version: row.version,
882
- source,
883
- compatibility: JSON.parse(row.compatibility_json),
884
- status: row.status,
885
- createdAt: row.created_at,
886
- };
887
- if (row.lifecycle_label !== null && row.lifecycle_label !== undefined)
888
- version.lifecycleLabel = row.lifecycle_label;
889
- if (row.draft_parent_version_id !== null && row.draft_parent_version_id !== undefined)
890
- version.draftParentVersionId = row.draft_parent_version_id;
891
- if (row.draft_revision !== null && row.draft_revision !== undefined)
892
- version.draftRevision = row.draft_revision;
893
- if (row.governance_json !== null && row.governance_json !== undefined)
894
- version.governance = JSON.parse(row.governance_json);
895
- if (row.published_at !== null && row.published_at !== undefined)
896
- version.publishedAt = row.published_at;
897
- if (row.published_by !== null && row.published_by !== undefined)
898
- version.publishedBy = row.published_by;
899
- if (row.deprecated_at !== null && row.deprecated_at !== undefined)
900
- version.deprecatedAt = row.deprecated_at;
901
- if (row.archived_at !== null && row.archived_at !== undefined)
902
- version.archivedAt = row.archived_at;
903
- return version;
904
- }
905
- function mapLifecycleEvent(row) {
906
- const event = {
907
- id: row.id,
908
- project: row.project,
909
- scope: row.scope,
910
- skillId: row.skill_id,
911
- eventType: row.event_type,
912
- createdAt: row.created_at,
913
- };
914
- if (row.version_id !== null)
915
- event.versionId = row.version_id;
916
- if (row.actor_type !== null && row.actor_id !== null)
917
- event.actor = { type: row.actor_type, id: row.actor_id };
918
- if (row.run_id !== null)
919
- event.runId = row.run_id;
920
- if (row.agent_id !== null)
921
- event.agentId = row.agent_id;
922
- if (row.reason !== null)
923
- event.reason = row.reason;
924
- if (row.before_json !== null)
925
- event.before = JSON.parse(row.before_json);
926
- if (row.after_json !== null)
927
- event.after = JSON.parse(row.after_json);
928
- if (row.evidence_json !== null)
929
- event.evidence = JSON.parse(row.evidence_json);
930
- return event;
931
- }
932
- function resolveSkillForMutation(repository, project, scope, skillId, name) {
933
- const result = skillId !== undefined ? repository.getById(skillId) : repository.getByName(project, scope, name ?? '');
934
- if (!result.ok)
935
- throw new SkillRegistryValidationError(result.error.message);
936
- if (result.value.project !== project || result.value.scope !== scope)
937
- throw new SkillRegistryValidationError('Skill does not belong to the requested project/scope');
938
- return result.value;
939
- }
940
- function resolveVersionForMutation(repository, skillId, versionId, version) {
941
- const result = versionId !== undefined ? repository.getVersion(versionId) : repository.getVersionBySkillVersion(skillId, version ?? '');
942
- if (!result.ok)
943
- throw new SkillRegistryValidationError(result.error.message);
944
- if (result.value.skillId !== skillId)
945
- throw new SkillRegistryValidationError('Skill version must belong to the requested skill');
946
- return result.value;
947
- }
948
- function versionSnapshot(version) {
949
- return {
950
- id: version.id,
951
- skillId: version.skillId,
952
- version: version.version,
953
- status: version.status,
954
- draftRevision: version.draftRevision ?? null,
955
- lifecycleLabel: version.lifecycleLabel ?? null,
956
- publishedAt: version.publishedAt ?? null,
957
- publishedBy: version.publishedBy ?? null,
958
- };
959
- }
960
- function mapAttachment(row) {
961
- const attachment = {
962
- id: row.id,
963
- skillId: row.skill_id,
964
- targetType: row.target_type,
965
- targetKey: row.target_key,
966
- metadata: JSON.parse(row.metadata_json),
967
- createdAt: row.created_at,
968
- };
969
- if (row.version_id !== null)
970
- attachment.versionId = row.version_id;
971
- return attachment;
972
- }
973
- function mapUsage(row) {
974
- const usage = {
975
- id: row.id,
976
- skillId: row.skill_id,
977
- outcome: row.outcome,
978
- createdAt: row.created_at,
979
- };
980
- if (row.version_id !== null)
981
- usage.versionId = row.version_id;
982
- if (row.run_id !== null)
983
- usage.runId = row.run_id;
984
- if (row.target_type !== null)
985
- usage.targetType = row.target_type;
986
- if (row.target_key !== null)
987
- usage.targetKey = row.target_key;
988
- if (row.notes !== null)
989
- usage.notes = row.notes;
990
- if (row.workflow !== null)
991
- usage.workflow = row.workflow;
992
- if (row.phase !== null)
993
- usage.phase = row.phase;
994
- if (row.provider_adapter !== null)
995
- usage.providerAdapter = row.provider_adapter;
996
- if (row.agent_id !== null)
997
- usage.agentId = row.agent_id;
998
- if (row.intent_json !== null)
999
- usage.intent = JSON.parse(row.intent_json);
1000
- if (row.evidence_json !== null)
1001
- usage.evidence = JSON.parse(row.evidence_json);
1002
- return usage;
1003
- }
1004
- function mapActivation(row) {
1005
- const activation = {
1006
- id: row.id,
1007
- project: row.project,
1008
- scope: row.scope,
1009
- skillId: row.skill_id,
1010
- createdAt: row.created_at,
1011
- };
1012
- if (row.version_id !== null)
1013
- activation.versionId = row.version_id;
1014
- if (row.run_id !== null)
1015
- activation.runId = row.run_id;
1016
- if (row.agent_id !== null)
1017
- activation.agentId = row.agent_id;
1018
- if (row.workflow !== null)
1019
- activation.workflow = row.workflow;
1020
- if (row.phase !== null)
1021
- activation.phase = row.phase;
1022
- if (row.provider_adapter !== null)
1023
- activation.providerAdapter = row.provider_adapter;
1024
- if (row.intent_json !== null)
1025
- activation.intent = JSON.parse(row.intent_json);
1026
- if (row.reason !== null)
1027
- activation.reason = row.reason;
1028
- if (row.payload_metadata_json !== null)
1029
- activation.payloadMetadata = JSON.parse(row.payload_metadata_json);
1030
- return activation;
1031
- }
1032
- function ok(value) {
1033
- return { ok: true, value };
1034
- }
1035
- function missing(message) {
1036
- return { ok: false, error: { code: 'not_found', message } };
1037
- }
1038
- function validationFailure(message) {
1039
- return { ok: false, error: { code: 'validation_failed', message } };
1040
- }
1041
- function fail(message, cause) {
1042
- const error = { code: 'validation_failed', message };
1043
- if (cause !== undefined)
1044
- error.cause = cause;
1045
- return { ok: false, error };
1046
- }
1047
- class SkillRegistryValidationError extends Error {
1048
- }
1049
- function normalizeLimit(limit) {
1050
- if (limit === undefined)
1051
- return 25;
1052
- if (!Number.isSafeInteger(limit) || limit < 1)
1053
- return 25;
1054
- return Math.min(limit, 100);
1055
- }
1056
- function zeroVersionCounts() {
1057
- return { draft: 0, active: 0, deprecated: 0, archived: 0 };
1058
- }
1059
- function zeroProposalCounts() {
1060
- return { draft: 0, 'pending-approval': 0, approved: 0, rejected: 0, cancelled: 0, applied: 0 };
1061
- }
1062
- function zeroEvaluationResultCounts() {
1063
- return { passed: 0, failed: 0, 'needs-review': 0, 'not-applicable': 0 };
1064
- }
1065
- function zeroEvaluationRequestCounts() {
1066
- return { requested: 0, planned: 0, running: 0, completed: 0, failed: 0, cancelled: 0, skipped: 0 };
1067
- }
1068
- function countScoped(db, table, project, scope) {
1069
- const row = db.connection
1070
- .prepare(`SELECT COUNT(*) AS count FROM ${table} t JOIN skills s ON s.id=t.skill_id WHERE s.project=? AND s.scope=?`)
1071
- .get(project, scope);
1072
- return row.count;
1073
- }
1074
- function countDirectScoped(db, table, project, scope) {
1075
- const row = db.connection.prepare(`SELECT COUNT(*) AS count FROM ${table} WHERE project=? AND scope=?`).get(project, scope);
1076
- return row.count;
1077
- }
1
+ export * from '../../storage/skills/repositories/skills.js';