@bevel-software/platform-core-backend 0.14.0 → 0.15.1

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 (385) hide show
  1. package/THIRD-PARTY-NOTICES.md +6 -6
  2. package/dist/core/catalog-cache-invalidation.d.ts +29 -0
  3. package/dist/core/catalog-cache-invalidation.d.ts.map +1 -0
  4. package/dist/core/catalog-cache-invalidation.js +71 -0
  5. package/dist/core/catalog-cache-invalidation.js.map +1 -0
  6. package/dist/core/create-core-server.d.ts.map +1 -1
  7. package/dist/core/create-core-server.js +99 -8
  8. package/dist/core/create-core-server.js.map +1 -1
  9. package/dist/core/create-core-services.d.ts +18 -1
  10. package/dist/core/create-core-services.d.ts.map +1 -1
  11. package/dist/core/create-core-services.js +96 -43
  12. package/dist/core/create-core-services.js.map +1 -1
  13. package/dist/modules/access/access-control.interface.d.ts +18 -6
  14. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  15. package/dist/modules/access/access-control.service.d.ts +26 -1
  16. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  17. package/dist/modules/access/access-control.service.js +213 -71
  18. package/dist/modules/access/access-control.service.js.map +1 -1
  19. package/dist/modules/access/access.routes.d.ts.map +1 -1
  20. package/dist/modules/access/access.routes.js +59 -7
  21. package/dist/modules/access/access.routes.js.map +1 -1
  22. package/dist/modules/access-model/access-grammar.d.ts +51 -1
  23. package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
  24. package/dist/modules/access-model/access-grammar.js +95 -1
  25. package/dist/modules/access-model/access-grammar.js.map +1 -1
  26. package/dist/modules/access-model/group-files.d.ts.map +1 -1
  27. package/dist/modules/access-model/group-files.js +4 -1
  28. package/dist/modules/access-model/group-files.js.map +1 -1
  29. package/dist/modules/access-model/plugin-principals.d.ts +49 -0
  30. package/dist/modules/access-model/plugin-principals.d.ts.map +1 -0
  31. package/dist/modules/access-model/plugin-principals.js +125 -0
  32. package/dist/modules/access-model/plugin-principals.js.map +1 -0
  33. package/dist/modules/database/core-schema.d.ts +326 -0
  34. package/dist/modules/database/core-schema.d.ts.map +1 -1
  35. package/dist/modules/database/core-schema.js +52 -0
  36. package/dist/modules/database/core-schema.js.map +1 -1
  37. package/dist/modules/kb-sync/index.d.ts +6 -0
  38. package/dist/modules/kb-sync/index.d.ts.map +1 -0
  39. package/dist/modules/kb-sync/index.js +5 -0
  40. package/dist/modules/kb-sync/index.js.map +1 -0
  41. package/dist/modules/kb-sync/kb-sync.interface.d.ts +77 -0
  42. package/dist/modules/kb-sync/kb-sync.interface.d.ts.map +1 -0
  43. package/dist/modules/kb-sync/kb-sync.interface.js +2 -0
  44. package/dist/modules/kb-sync/kb-sync.interface.js.map +1 -0
  45. package/dist/modules/kb-sync/kb-sync.routes.d.ts +70 -0
  46. package/dist/modules/kb-sync/kb-sync.routes.d.ts.map +1 -0
  47. package/dist/modules/kb-sync/kb-sync.routes.js +135 -0
  48. package/dist/modules/kb-sync/kb-sync.routes.js.map +1 -0
  49. package/dist/modules/kb-sync/kb-sync.service.d.ts +45 -0
  50. package/dist/modules/kb-sync/kb-sync.service.d.ts.map +1 -0
  51. package/dist/modules/kb-sync/kb-sync.service.js +183 -0
  52. package/dist/modules/kb-sync/kb-sync.service.js.map +1 -0
  53. package/dist/modules/kb-sync/sync-auth.d.ts +59 -0
  54. package/dist/modules/kb-sync/sync-auth.d.ts.map +1 -0
  55. package/dist/modules/kb-sync/sync-auth.js +62 -0
  56. package/dist/modules/kb-sync/sync-auth.js.map +1 -0
  57. package/dist/modules/kb-sync/sync-payload.d.ts +32 -0
  58. package/dist/modules/kb-sync/sync-payload.d.ts.map +1 -0
  59. package/dist/modules/kb-sync/sync-payload.js +105 -0
  60. package/dist/modules/kb-sync/sync-payload.js.map +1 -0
  61. package/dist/modules/marketplace/git-http.routes.d.ts +42 -0
  62. package/dist/modules/marketplace/git-http.routes.d.ts.map +1 -0
  63. package/dist/modules/marketplace/git-http.routes.js +190 -0
  64. package/dist/modules/marketplace/git-http.routes.js.map +1 -0
  65. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts +23 -0
  66. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts.map +1 -0
  67. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js +59 -0
  68. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js.map +1 -0
  69. package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts +59 -0
  70. package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts.map +1 -0
  71. package/dist/modules/marketplace/github-facade/github-facade-codes.store.js +96 -0
  72. package/dist/modules/marketplace/github-facade/github-facade-codes.store.js.map +1 -0
  73. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts +99 -0
  74. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts.map +1 -0
  75. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js +147 -0
  76. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js.map +1 -0
  77. package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts +47 -0
  78. package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts.map +1 -0
  79. package/dist/modules/marketplace/github-facade/github-facade.routes.js +228 -0
  80. package/dist/modules/marketplace/github-facade/github-facade.routes.js.map +1 -0
  81. package/dist/modules/marketplace/github-facade/github-facade.service.d.ts +109 -0
  82. package/dist/modules/marketplace/github-facade/github-facade.service.d.ts.map +1 -0
  83. package/dist/modules/marketplace/github-facade/github-facade.service.js +172 -0
  84. package/dist/modules/marketplace/github-facade/github-facade.service.js.map +1 -0
  85. package/dist/modules/marketplace/github-facade/index.d.ts +6 -0
  86. package/dist/modules/marketplace/github-facade/index.d.ts.map +1 -0
  87. package/dist/modules/marketplace/github-facade/index.js +6 -0
  88. package/dist/modules/marketplace/github-facade/index.js.map +1 -0
  89. package/dist/modules/marketplace/index.d.ts +4 -0
  90. package/dist/modules/marketplace/index.d.ts.map +1 -0
  91. package/dist/modules/marketplace/index.js +4 -0
  92. package/dist/modules/marketplace/index.js.map +1 -0
  93. package/dist/modules/marketplace/marketplace-repo.service.d.ts +122 -0
  94. package/dist/modules/marketplace/marketplace-repo.service.d.ts.map +1 -0
  95. package/dist/modules/marketplace/marketplace-repo.service.js +300 -0
  96. package/dist/modules/marketplace/marketplace-repo.service.js.map +1 -0
  97. package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
  98. package/dist/modules/mcp/oauth/bevel-oauth-provider.js +4 -0
  99. package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
  100. package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts +14 -8
  101. package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts.map +1 -1
  102. package/dist/modules/mcp/oauth/oauth-consent.routes.js +13 -1
  103. package/dist/modules/mcp/oauth/oauth-consent.routes.js.map +1 -1
  104. package/dist/modules/mcp/oauth/oauth-state.d.ts +13 -2
  105. package/dist/modules/mcp/oauth/oauth-state.d.ts.map +1 -1
  106. package/dist/modules/mcp/oauth/oauth-state.js +3 -1
  107. package/dist/modules/mcp/oauth/oauth-state.js.map +1 -1
  108. package/dist/modules/plugins/compile/compile-marketplace.d.ts +97 -0
  109. package/dist/modules/plugins/compile/compile-marketplace.d.ts.map +1 -0
  110. package/dist/modules/plugins/compile/compile-marketplace.js +240 -0
  111. package/dist/modules/plugins/compile/compile-marketplace.js.map +1 -0
  112. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +66 -0
  113. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -0
  114. package/dist/modules/plugins/compile/marketplace-compiler.service.js +132 -0
  115. package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -0
  116. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +37 -0
  117. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -0
  118. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +135 -0
  119. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -0
  120. package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts +45 -0
  121. package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts.map +1 -0
  122. package/dist/modules/plugins/discovery/bundle-dialect/registry.js +147 -0
  123. package/dist/modules/plugins/discovery/bundle-dialect/registry.js.map +1 -0
  124. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +37 -0
  125. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -0
  126. package/dist/modules/plugins/discovery/kb-plugin-source.js +107 -0
  127. package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -0
  128. package/dist/modules/plugins/discovery/native.source.d.ts +15 -0
  129. package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -0
  130. package/dist/modules/plugins/discovery/native.source.js +102 -0
  131. package/dist/modules/plugins/discovery/native.source.js.map +1 -0
  132. package/dist/modules/plugins/discovery/plugin-source.d.ts +96 -0
  133. package/dist/modules/plugins/discovery/plugin-source.d.ts.map +1 -0
  134. package/dist/modules/plugins/discovery/plugin-source.js +2 -0
  135. package/dist/modules/plugins/discovery/plugin-source.js.map +1 -0
  136. package/dist/modules/plugins/index.d.ts +10 -1
  137. package/dist/modules/plugins/index.d.ts.map +1 -1
  138. package/dist/modules/plugins/index.js +8 -0
  139. package/dist/modules/plugins/index.js.map +1 -1
  140. package/dist/modules/plugins/plugin-links.d.ts +66 -0
  141. package/dist/modules/plugins/plugin-links.d.ts.map +1 -0
  142. package/dist/modules/plugins/plugin-links.js +160 -0
  143. package/dist/modules/plugins/plugin-links.js.map +1 -0
  144. package/dist/modules/plugins/plugin-links.service.d.ts +114 -0
  145. package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -0
  146. package/dist/modules/plugins/plugin-links.service.js +304 -0
  147. package/dist/modules/plugins/plugin-links.service.js.map +1 -0
  148. package/dist/modules/plugins/plugin-provision.service.d.ts +39 -3
  149. package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
  150. package/dist/modules/plugins/plugin-provision.service.js +152 -52
  151. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  152. package/dist/modules/plugins/plugin-rename.service.d.ts +69 -0
  153. package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -0
  154. package/dist/modules/plugins/plugin-rename.service.js +245 -0
  155. package/dist/modules/plugins/plugin-rename.service.js.map +1 -0
  156. package/dist/modules/plugins/plugins.contract.d.ts +27 -1
  157. package/dist/modules/plugins/plugins.contract.d.ts.map +1 -1
  158. package/dist/modules/plugins/plugins.routes.d.ts +7 -1
  159. package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
  160. package/dist/modules/plugins/plugins.routes.js +120 -12
  161. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  162. package/dist/modules/plugins/plugins.service.d.ts +50 -3
  163. package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
  164. package/dist/modules/plugins/plugins.service.js +108 -47
  165. package/dist/modules/plugins/plugins.service.js.map +1 -1
  166. package/dist/modules/settings/deployment-settings.service.d.ts +9 -0
  167. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
  168. package/dist/modules/settings/deployment-settings.service.js +82 -2
  169. package/dist/modules/settings/deployment-settings.service.js.map +1 -1
  170. package/dist/modules/settings/setup.routes.d.ts +26 -0
  171. package/dist/modules/settings/setup.routes.d.ts.map +1 -1
  172. package/dist/modules/settings/setup.routes.js +9 -1
  173. package/dist/modules/settings/setup.routes.js.map +1 -1
  174. package/dist/modules/skills/index.d.ts +1 -0
  175. package/dist/modules/skills/index.d.ts.map +1 -1
  176. package/dist/modules/skills/index.js +1 -0
  177. package/dist/modules/skills/index.js.map +1 -1
  178. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
  179. package/dist/modules/skills/pending-skills.service.js +9 -4
  180. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  181. package/dist/modules/skills/skill-access-requests.routes.d.ts +38 -0
  182. package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -0
  183. package/dist/modules/skills/skill-access-requests.routes.js +168 -0
  184. package/dist/modules/skills/skill-access-requests.routes.js.map +1 -0
  185. package/dist/modules/skills/skills.contract.d.ts +31 -0
  186. package/dist/modules/skills/skills.contract.d.ts.map +1 -1
  187. package/dist/modules/skills/skills.routes.d.ts +28 -3
  188. package/dist/modules/skills/skills.routes.d.ts.map +1 -1
  189. package/dist/modules/skills/skills.routes.js +42 -3
  190. package/dist/modules/skills/skills.routes.js.map +1 -1
  191. package/dist/modules/skills/skills.service.d.ts +4 -0
  192. package/dist/modules/skills/skills.service.d.ts.map +1 -1
  193. package/dist/modules/skills/skills.service.js +83 -22
  194. package/dist/modules/skills/skills.service.js.map +1 -1
  195. package/dist/modules/tool-auth/external-api-key.interface.d.ts +18 -1
  196. package/dist/modules/tool-auth/external-api-key.interface.d.ts.map +1 -1
  197. package/dist/modules/tool-auth/external-api-key.interface.js +2 -1
  198. package/dist/modules/tool-auth/external-api-key.interface.js.map +1 -1
  199. package/dist/modules/tool-auth/external-api-key.service.d.ts +13 -4
  200. package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
  201. package/dist/modules/tool-auth/external-api-key.service.js +26 -9
  202. package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
  203. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +36 -0
  204. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
  205. package/dist/modules/tool-manuals/mcp-json-discovery.js +130 -92
  206. package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
  207. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +6 -1
  208. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  209. package/dist/modules/tool-manuals/tool-manuals.service.js +18 -25
  210. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  211. package/dist/modules/workflow/git/git.service.d.ts +40 -2
  212. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  213. package/dist/modules/workflow/git/git.service.js +227 -54
  214. package/dist/modules/workflow/git/git.service.js.map +1 -1
  215. package/dist/modules/workflow/git/pull-request.service.d.ts +6 -0
  216. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  217. package/dist/modules/workflow/git/pull-request.service.js +8 -0
  218. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  219. package/dist/modules/workflow/workflow.service.d.ts +52 -1
  220. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  221. package/dist/modules/workflow/workflow.service.js +242 -9
  222. package/dist/modules/workflow/workflow.service.js.map +1 -1
  223. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +35 -0
  224. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -0
  225. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +121 -0
  226. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -0
  227. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  228. package/dist/modules/workspace/startup/steps/seed-tree.js +46 -2
  229. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  230. package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
  231. package/dist/modules/workspace/startup/steps/template-files.step.js +112 -25
  232. package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
  233. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  234. package/dist/modules/workspace/workspace.routes.js +9 -9
  235. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  236. package/dist/modules/workspace/workspace.service.d.ts +33 -0
  237. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  238. package/dist/modules/workspace/workspace.service.js +110 -16
  239. package/dist/modules/workspace/workspace.service.js.map +1 -1
  240. package/dist/shared/domain-errors.d.ts +20 -0
  241. package/dist/shared/domain-errors.d.ts.map +1 -1
  242. package/dist/shared/domain-errors.js +29 -0
  243. package/dist/shared/domain-errors.js.map +1 -1
  244. package/dist/shared/fs-errors.d.ts +8 -0
  245. package/dist/shared/fs-errors.d.ts.map +1 -0
  246. package/dist/shared/fs-errors.js +11 -0
  247. package/dist/shared/fs-errors.js.map +1 -0
  248. package/dist/shared/fs-walk.d.ts +20 -6
  249. package/dist/shared/fs-walk.d.ts.map +1 -1
  250. package/dist/shared/fs-walk.js +35 -27
  251. package/dist/shared/fs-walk.js.map +1 -1
  252. package/dist/shared/kb-walk.d.ts +52 -0
  253. package/dist/shared/kb-walk.d.ts.map +1 -0
  254. package/dist/shared/kb-walk.js +76 -0
  255. package/dist/shared/kb-walk.js.map +1 -0
  256. package/dist/shared/path-order.d.ts +18 -0
  257. package/dist/shared/path-order.d.ts.map +1 -0
  258. package/dist/shared/path-order.js +35 -0
  259. package/dist/shared/path-order.js.map +1 -0
  260. package/dist/shared/ttl-cache.d.ts +28 -1
  261. package/dist/shared/ttl-cache.d.ts.map +1 -1
  262. package/dist/shared/ttl-cache.js +33 -1
  263. package/dist/shared/ttl-cache.js.map +1 -1
  264. package/kb-template/.bevelignore +1 -1
  265. package/kb-template/AGENTS.md +95 -30
  266. package/kb-template/Skills/.gitkeep +0 -0
  267. package/migrations/0005_github_facade.sql +25 -0
  268. package/migrations/meta/0005_snapshot.json +1717 -0
  269. package/migrations/meta/_journal.json +7 -0
  270. package/package.json +6 -6
  271. package/src/__tests__/kb-layout-config.test.ts +110 -0
  272. package/src/core/__tests__/catalog-cache-invalidation.test.ts +146 -0
  273. package/src/core/catalog-cache-invalidation.ts +92 -0
  274. package/src/core/create-core-server.ts +123 -7
  275. package/src/core/create-core-services.ts +162 -41
  276. package/src/modules/access/__tests__/access-control.invalidate-race.test.ts +86 -0
  277. package/src/modules/access/__tests__/access-control.service.test.ts +19 -3
  278. package/src/modules/access/__tests__/access-plugin-principals.test.ts +368 -0
  279. package/src/modules/access/__tests__/groups-admin.service.test.ts +8 -0
  280. package/src/modules/access/access-control.interface.ts +20 -9
  281. package/src/modules/access/access-control.service.ts +240 -78
  282. package/src/modules/access/access.routes.ts +96 -14
  283. package/src/modules/access-model/__tests__/access-grammar.test.ts +18 -0
  284. package/src/modules/access-model/__tests__/plugin-token-canonical.test.ts +40 -0
  285. package/src/modules/access-model/access-grammar.ts +114 -2
  286. package/src/modules/access-model/group-files.ts +4 -0
  287. package/src/modules/access-model/plugin-principals.ts +137 -0
  288. package/src/modules/database/core-schema.ts +54 -0
  289. package/src/modules/kb-sync/__tests__/kb-sync.routes.test.ts +297 -0
  290. package/src/modules/kb-sync/__tests__/kb-sync.service.test.ts +295 -0
  291. package/src/modules/kb-sync/__tests__/sync-auth.test.ts +118 -0
  292. package/src/modules/kb-sync/__tests__/sync-payload.test.ts +148 -0
  293. package/src/modules/kb-sync/index.ts +19 -0
  294. package/src/modules/kb-sync/kb-sync.interface.ts +79 -0
  295. package/src/modules/kb-sync/kb-sync.routes.ts +197 -0
  296. package/src/modules/kb-sync/kb-sync.service.ts +201 -0
  297. package/src/modules/kb-sync/sync-auth.ts +118 -0
  298. package/src/modules/kb-sync/sync-payload.ts +143 -0
  299. package/src/modules/marketplace/__tests__/github-facade.test.ts +443 -0
  300. package/src/modules/marketplace/__tests__/marketplace-git.test.ts +179 -0
  301. package/src/modules/marketplace/git-http.routes.ts +193 -0
  302. package/src/modules/marketplace/github-facade/github-facade-admin.routes.ts +78 -0
  303. package/src/modules/marketplace/github-facade/github-facade-codes.store.ts +145 -0
  304. package/src/modules/marketplace/github-facade/github-facade-credentials.service.ts +208 -0
  305. package/src/modules/marketplace/github-facade/github-facade.routes.ts +268 -0
  306. package/src/modules/marketplace/github-facade/github-facade.service.ts +221 -0
  307. package/src/modules/marketplace/github-facade/index.ts +25 -0
  308. package/src/modules/marketplace/index.ts +3 -0
  309. package/src/modules/marketplace/marketplace-repo.service.ts +337 -0
  310. package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -0
  311. package/src/modules/mcp/oauth/oauth-consent.routes.ts +24 -2
  312. package/src/modules/mcp/oauth/oauth-state.ts +15 -3
  313. package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +163 -0
  314. package/src/modules/plugins/__tests__/compile-marketplace.test.ts +294 -0
  315. package/src/modules/plugins/__tests__/plugin-index.service.test.ts +56 -12
  316. package/src/modules/plugins/__tests__/plugin-links.service.test.ts +287 -0
  317. package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +205 -5
  318. package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +394 -0
  319. package/src/modules/plugins/__tests__/plugins.routes.test.ts +80 -33
  320. package/src/modules/plugins/compile/compile-marketplace.ts +403 -0
  321. package/src/modules/plugins/compile/marketplace-compiler.service.ts +150 -0
  322. package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +329 -0
  323. package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +140 -0
  324. package/src/modules/plugins/discovery/bundle-dialect/registry.ts +175 -0
  325. package/src/modules/plugins/discovery/kb-plugin-source.ts +114 -0
  326. package/src/modules/plugins/discovery/native.source.ts +122 -0
  327. package/src/modules/plugins/discovery/plugin-source.ts +99 -0
  328. package/src/modules/plugins/index.ts +10 -0
  329. package/src/modules/plugins/plugin-links.service.ts +363 -0
  330. package/src/modules/plugins/plugin-links.ts +184 -0
  331. package/src/modules/plugins/plugin-provision.service.ts +160 -54
  332. package/src/modules/plugins/plugin-rename.service.ts +298 -0
  333. package/src/modules/plugins/plugins.contract.ts +28 -1
  334. package/src/modules/plugins/plugins.routes.ts +128 -11
  335. package/src/modules/plugins/plugins.service.ts +106 -53
  336. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +57 -0
  337. package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +77 -0
  338. package/src/modules/settings/deployment-settings.service.ts +95 -2
  339. package/src/modules/settings/setup.routes.ts +24 -0
  340. package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +128 -0
  341. package/src/modules/skills/__tests__/skills.service.test.ts +85 -0
  342. package/src/modules/skills/index.ts +1 -0
  343. package/src/modules/skills/pending-skills.service.ts +7 -5
  344. package/src/modules/skills/skill-access-requests.routes.ts +199 -0
  345. package/src/modules/skills/skills.contract.ts +32 -0
  346. package/src/modules/skills/skills.routes.ts +59 -3
  347. package/src/modules/skills/skills.service.ts +84 -22
  348. package/src/modules/tool-auth/external-api-key.interface.ts +20 -1
  349. package/src/modules/tool-auth/external-api-key.service.ts +31 -13
  350. package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +24 -1
  351. package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +2 -0
  352. package/src/modules/tool-manuals/mcp-json-discovery.ts +154 -88
  353. package/src/modules/tool-manuals/tool-manuals.service.ts +14 -23
  354. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
  355. package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -0
  356. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +2 -2
  357. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +119 -2
  358. package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +437 -0
  359. package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +3 -3
  360. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +47 -4
  361. package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +253 -0
  362. package/src/modules/workflow/git/git.service.ts +239 -56
  363. package/src/modules/workflow/git/pull-request.service.ts +9 -0
  364. package/src/modules/workflow/workflow.service.ts +260 -9
  365. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +6 -7
  366. package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +93 -0
  367. package/src/modules/workspace/__tests__/workspace.service.missing-branch.test.ts +28 -0
  368. package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +42 -12
  369. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +219 -4
  370. package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +129 -0
  371. package/src/modules/workspace/startup/steps/seed-tree.ts +44 -2
  372. package/src/modules/workspace/startup/steps/template-files.step.ts +131 -27
  373. package/src/modules/workspace/workspace.routes.ts +9 -17
  374. package/src/modules/workspace/workspace.service.ts +107 -16
  375. package/src/shared/__tests__/filename.test.ts +0 -0
  376. package/src/shared/__tests__/fs-walk.test.ts +22 -1
  377. package/src/shared/__tests__/kb-walk.test.ts +107 -0
  378. package/src/shared/__tests__/path-order.test.ts +24 -0
  379. package/src/shared/__tests__/ttl-cache.test.ts +55 -0
  380. package/src/shared/domain-errors.ts +29 -0
  381. package/src/shared/fs-errors.ts +10 -0
  382. package/src/shared/fs-walk.ts +38 -23
  383. package/src/shared/kb-walk.ts +95 -0
  384. package/src/shared/path-order.ts +33 -0
  385. package/src/shared/ttl-cache.ts +33 -1
@@ -157,6 +157,35 @@ export class PullRebaseConflictError extends WorkflowDomainError {
157
157
  this.name = 'PullRebaseConflictError';
158
158
  }
159
159
  }
160
+ /**
161
+ * The clone's branch no longer exists on origin: the fetch that refreshes
162
+ * `refs/remotes/origin/<branch>` found no such ref. Distinct from an
163
+ * unreachable remote — the host answered, and the answer was "gone" — so a
164
+ * caller can treat the clone as stale rather than the sync as failed. 410.
165
+ */
166
+ export class RemoteBranchGoneError extends WorkflowDomainError {
167
+ branch;
168
+ kind = 'remote-branch-gone';
169
+ constructor(branch) {
170
+ super(`Branch "${branch}" no longer exists on the remote.`, 410, {
171
+ kind: 'remote-branch-gone',
172
+ branch,
173
+ });
174
+ this.branch = branch;
175
+ this.name = 'RemoteBranchGoneError';
176
+ }
177
+ }
178
+ /**
179
+ * Whether a failed clone or fetch failed because origin has no such branch, as
180
+ * opposed to being unreachable or refusing the credential. Git's wording for
181
+ * the two shapes: `Remote branch <x> not found in upstream origin` (clone) and
182
+ * `couldn't find remote ref refs/heads/<x>` (fetch). The ONE classifier for
183
+ * this fact — the workspace bootstrap and the git layer both consult it, so
184
+ * a wording learned by one is learned by both.
185
+ */
186
+ export function isMissingRemoteBranchFailure(message) {
187
+ return /Remote branch .* not found in upstream|couldn't find remote ref/i.test(message);
188
+ }
160
189
  /**
161
190
  * Generic 400 for workflow-input validation (malformed branch names, missing
162
191
  * fields, etc.). Carries an optional payload so callers can attach typed
@@ -1 +1 @@
1
- {"version":3,"file":"domain-errors.js","sourceRoot":"","sources":["../../src/shared/domain-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAS;IACf,OAAO,CAA2B;IAC3C,YAAY,OAAe,EAAE,MAAc,EAAE,OAAiC;QAC5E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,mBAAmB;IACjB;IAArC,YAAY,MAAc,EAAW,UAAkB;QACrD,KAAK,CAAC,wBAAwB,UAAU,MAAM,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC;QAD1B,eAAU,GAAV,UAAU,CAAQ;QAErD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,mBAAmB;IACtC;IAA6B;IAAlD,YAAqB,UAAkB,EAAW,MAAc;QAC9D,KAAK,CAAC,WAAW,UAAU,oBAAoB,MAAM,kBAAkB,EAAE,GAAG,CAAC,CAAC;QAD3D,eAAU,GAAV,UAAU,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAE9D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAsB,SAAQ,mBAAmB;IAEvC;IADZ,IAAI,GAAG,mBAA4B,CAAC;IAC7C,YAAqB,UAAkB;QACrC,KAAK,CACH,uBAAuB,UAAU,kBAAkB,EACnD,GAAG,EACH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AAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether a filesystem error means "there is no such path" — the one failure
3
+ * a reader may treat as an ordinary answer. Everything else (permissions,
4
+ * I/O, a loop) is a failure to READ what is there, and a caller that folds
5
+ * it into absence turns an outage into a wrong answer.
6
+ */
7
+ export declare function isAbsence(err: unknown): boolean;
8
+ //# sourceMappingURL=fs-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-errors.d.ts","sourceRoot":"","sources":["../../src/shared/fs-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAG/C"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Whether a filesystem error means "there is no such path" — the one failure
3
+ * a reader may treat as an ordinary answer. Everything else (permissions,
4
+ * I/O, a loop) is a failure to READ what is there, and a caller that folds
5
+ * it into absence turns an outage into a wrong answer.
6
+ */
7
+ export function isAbsence(err) {
8
+ const code = err?.code;
9
+ return code === 'ENOENT' || code === 'ENOTDIR';
10
+ }
11
+ //# sourceMappingURL=fs-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-errors.js","sourceRoot":"","sources":["../../src/shared/fs-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,MAAM,IAAI,GAAI,GAAiC,EAAE,IAAI,CAAC;IACtD,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AACjD,CAAC"}
@@ -1,9 +1,23 @@
1
+ import { isSkippedEntry } from './kb-walk.js';
2
+ export { isSkippedEntry };
1
3
  /**
2
- * The ONE recursive file walk for catalog scanners: relative (`/`-separated,
3
- * sorted) paths of files under `root` whose basename matches. A missing root
4
- * yields `[]`; dot-entries (incl. `.git`) are skipped. Scanners with different
5
- * semantics (the skills scanner's stop-at-skill-folder walk, the access
6
- * resolver's dir chains) deliberately keep their own walks.
4
+ * The file listing catalog scanners want, on top of {@link walkKb}: relative
5
+ * (`/`-separated, sorted) paths of files under `root` whose basename matches.
6
+ * A missing root yields `[]`; skipped entries are never entered.
7
+ *
8
+ * A directory that cannot be listed is SKIPPED by default — right for a
9
+ * catalog, which shows what it can. A caller that must see EVERYTHING or
10
+ * nothing passes `strict`, and the listing throws a {@link WalkError} naming
11
+ * the directory instead: a list with a hole in it is not a list of every
12
+ * file, and the caller can say WHICH hole rather than pass a raw errno up.
7
13
  */
8
- export declare function walkFiles(root: string, match: (basename: string) => boolean): Promise<string[]>;
14
+ export declare function walkFiles(root: string, match: (basename: string) => boolean, opts?: {
15
+ strict?: boolean;
16
+ }): Promise<string[]>;
17
+ /** A strict listing's refusal: the directory (relative to the root, `''` for the root itself) it could not list. */
18
+ export declare class WalkError extends Error {
19
+ readonly relDir: string;
20
+ readonly cause: unknown;
21
+ constructor(relDir: string, cause: unknown);
22
+ }
9
23
  //# sourceMappingURL=fs-walk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs-walk.d.ts","sourceRoot":"","sources":["../../src/shared/fs-walk.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmBrG"}
1
+ {"version":3,"file":"fs-walk.d.ts","sourceRoot":"","sources":["../../src/shared/fs-walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,EACpC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,CAcnB;AAED,oHAAoH;AACpH,qBAAa,SAAU,SAAQ,KAAK;IAEhC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO;gBADd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO;CAK1B"}
@@ -1,34 +1,42 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs/promises';
1
+ import { walkKb, isSkippedEntry } from './kb-walk.js';
2
+ export { isSkippedEntry };
3
3
  /**
4
- * The ONE recursive file walk for catalog scanners: relative (`/`-separated,
5
- * sorted) paths of files under `root` whose basename matches. A missing root
6
- * yields `[]`; dot-entries (incl. `.git`) are skipped. Scanners with different
7
- * semantics (the skills scanner's stop-at-skill-folder walk, the access
8
- * resolver's dir chains) deliberately keep their own walks.
4
+ * The file listing catalog scanners want, on top of {@link walkKb}: relative
5
+ * (`/`-separated, sorted) paths of files under `root` whose basename matches.
6
+ * A missing root yields `[]`; skipped entries are never entered.
7
+ *
8
+ * A directory that cannot be listed is SKIPPED by default — right for a
9
+ * catalog, which shows what it can. A caller that must see EVERYTHING or
10
+ * nothing passes `strict`, and the listing throws a {@link WalkError} naming
11
+ * the directory instead: a list with a hole in it is not a list of every
12
+ * file, and the caller can say WHICH hole rather than pass a raw errno up.
9
13
  */
10
- export async function walkFiles(root, match) {
14
+ export async function walkFiles(root, match, opts = {}) {
11
15
  const out = [];
12
- const walk = async (dir, rel) => {
13
- let entries;
14
- try {
15
- entries = await fs.readdir(dir, { withFileTypes: true });
16
- }
17
- catch {
18
- return;
19
- }
20
- for (const entry of entries) {
21
- if (entry.name.startsWith('.'))
22
- continue;
23
- const childRel = rel ? `${rel}/${entry.name}` : entry.name;
24
- if (entry.isDirectory())
25
- await walk(path.join(dir, entry.name), childRel);
26
- else if (entry.isFile() && match(entry.name))
27
- out.push(childRel);
28
- }
29
- };
30
- await walk(root, '');
16
+ await walkKb(root, [
17
+ {
18
+ onFile(dir, name) {
19
+ if (match(name))
20
+ out.push(dir ? `${dir}/${name}` : name);
21
+ },
22
+ onHole(rel, err) {
23
+ if (opts.strict)
24
+ throw new WalkError(rel, err);
25
+ },
26
+ },
27
+ ]);
31
28
  out.sort();
32
29
  return out;
33
30
  }
31
+ /** A strict listing's refusal: the directory (relative to the root, `''` for the root itself) it could not list. */
32
+ export class WalkError extends Error {
33
+ relDir;
34
+ cause;
35
+ constructor(relDir, cause) {
36
+ super(`${relDir || '.'} could not be listed — ${cause instanceof Error ? cause.message : String(cause)}`);
37
+ this.relDir = relDir;
38
+ this.cause = cause;
39
+ this.name = 'WalkError';
40
+ }
41
+ }
34
42
  //# sourceMappingURL=fs-walk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs-walk.js","sourceRoot":"","sources":["../../src/shared/fs-walk.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,KAAoC;IAChF,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,KAAK,EAAE,GAAW,EAAE,GAAW,EAAiB,EAAE;QAC7D,IAAI,OAAmC,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS;YACzC,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAA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,GAAG,CAAC;AACb,CAAC;AAED,oHAAoH;AACpH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEvB;IACA;IAFX,YACW,MAAc,EACd,KAAc;QAEvB,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAHjG,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAS;QAGvB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * THE walk of a knowledge-base checkout.
3
+ *
4
+ * Every reader of the tree — the access resolver looking for rules, plugin
5
+ * discovery looking for manifests, a rename looking for grants, the catalog
6
+ * scanners — used to carry a recursive `readdir` loop of its own, each with
7
+ * its own skip list, its own idea of what an unreadable folder means and its
8
+ * own visiting order. Two loops that disagree on one of those are two
9
+ * answers to "what is in the tree", and every such disagreement was a bug.
10
+ *
11
+ * So there is one loop, and it decides three things once:
12
+ *
13
+ * - WHAT IS SKIPPED: {@link isSkippedEntry} — dot-entries (`.git`, a parked
14
+ * delete) and vendored dependencies. Nothing else is pruned; a listener
15
+ * that stops at a leaf of its own (a skill folder, a plugin folder)
16
+ * simply ignores what lies beneath it.
17
+ * - IN WHAT ORDER: each folder's entries in {@link comparePathComponents}
18
+ * order, so "first by path" means the same thing to every listener.
19
+ * - WHAT A HOLE IS: a folder that exists but could not be listed is
20
+ * reported as an event and in the result — never thrown, never silently
21
+ * skipped — so a reader can show what it saw and a writer can refuse.
22
+ * A folder that vanished between listing and visiting is not a hole.
23
+ *
24
+ * Listeners see the same events in the same order; what each makes of them
25
+ * is its own business (`.bevelignore` included — the explorer honours it,
26
+ * the resolver must not, so it is a listener's decision, not the walk's).
27
+ */
28
+ export declare function isSkippedEntry(name: string): boolean;
29
+ /** A directory entry as the walk presents it: a name and what it is. */
30
+ export interface WalkedEntry {
31
+ name: string;
32
+ isDirectory(): boolean;
33
+ isFile(): boolean;
34
+ }
35
+ export interface KbWalkListener {
36
+ /** A folder was listed. `rel` is repo-relative (`''` for the root); `entries` are its children, skipped ones removed, in walk order. */
37
+ onDir?(rel: string, entries: readonly WalkedEntry[]): void | Promise<void>;
38
+ /** A file was seen. `dir` is its folder (`''` for the root), `name` its basename. */
39
+ onFile?(dir: string, name: string): void | Promise<void>;
40
+ /** A folder that exists but could not be listed. */
41
+ onHole?(rel: string, err: unknown): void | Promise<void>;
42
+ }
43
+ export interface KbWalkResult {
44
+ /** Every folder that could not be listed, repo-relative (`''` for the root). */
45
+ holes: string[];
46
+ }
47
+ /**
48
+ * Walk the checkout at `root`, driving every listener from one traversal.
49
+ * A missing root is an empty tree. Listener errors propagate untouched.
50
+ */
51
+ export declare function walkKb(root: string, listeners: readonly KbWalkListener[]): Promise<KbWalkResult>;
52
+ //# sourceMappingURL=kb-walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kb-walk.d.ts","sourceRoot":"","sources":["../../src/shared/kb-walk.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,IAAI,OAAO,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,wIAAwI;IACxI,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,qFAAqF;IACrF,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,oDAAoD;IACpD,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAiCtG"}
@@ -0,0 +1,76 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs/promises';
3
+ import { isAbsence } from './fs-errors.js';
4
+ import { comparePathComponents } from './path-order.js';
5
+ /**
6
+ * THE walk of a knowledge-base checkout.
7
+ *
8
+ * Every reader of the tree — the access resolver looking for rules, plugin
9
+ * discovery looking for manifests, a rename looking for grants, the catalog
10
+ * scanners — used to carry a recursive `readdir` loop of its own, each with
11
+ * its own skip list, its own idea of what an unreadable folder means and its
12
+ * own visiting order. Two loops that disagree on one of those are two
13
+ * answers to "what is in the tree", and every such disagreement was a bug.
14
+ *
15
+ * So there is one loop, and it decides three things once:
16
+ *
17
+ * - WHAT IS SKIPPED: {@link isSkippedEntry} — dot-entries (`.git`, a parked
18
+ * delete) and vendored dependencies. Nothing else is pruned; a listener
19
+ * that stops at a leaf of its own (a skill folder, a plugin folder)
20
+ * simply ignores what lies beneath it.
21
+ * - IN WHAT ORDER: each folder's entries in {@link comparePathComponents}
22
+ * order, so "first by path" means the same thing to every listener.
23
+ * - WHAT A HOLE IS: a folder that exists but could not be listed is
24
+ * reported as an event and in the result — never thrown, never silently
25
+ * skipped — so a reader can show what it saw and a writer can refuse.
26
+ * A folder that vanished between listing and visiting is not a hole.
27
+ *
28
+ * Listeners see the same events in the same order; what each makes of them
29
+ * is its own business (`.bevelignore` included — the explorer honours it,
30
+ * the resolver must not, so it is a listener's decision, not the walk's).
31
+ */
32
+ export function isSkippedEntry(name) {
33
+ return name.startsWith('.') || name === 'node_modules';
34
+ }
35
+ /**
36
+ * Walk the checkout at `root`, driving every listener from one traversal.
37
+ * A missing root is an empty tree. Listener errors propagate untouched.
38
+ */
39
+ export async function walkKb(root, listeners) {
40
+ const holes = [];
41
+ const visit = async (abs, rel) => {
42
+ let listed;
43
+ try {
44
+ listed = await fs.readdir(abs, { withFileTypes: true });
45
+ }
46
+ catch (err) {
47
+ if (isAbsence(err)) {
48
+ // The root: a checkout without this tree, an empty walk. Deeper: a
49
+ // folder that vanished between listing and visiting — not a hole.
50
+ return;
51
+ }
52
+ holes.push(rel);
53
+ for (const l of listeners)
54
+ await l.onHole?.(rel, err);
55
+ return;
56
+ }
57
+ const entries = listed
58
+ .filter((e) => !isSkippedEntry(e.name) && (e.isDirectory() || e.isFile()))
59
+ .sort((a, b) => comparePathComponents(a.name, b.name));
60
+ for (const l of listeners)
61
+ await l.onDir?.(rel, entries);
62
+ for (const entry of entries) {
63
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
64
+ if (entry.isDirectory()) {
65
+ await visit(path.join(abs, entry.name), childRel);
66
+ }
67
+ else {
68
+ for (const l of listeners)
69
+ await l.onFile?.(rel, entry.name);
70
+ }
71
+ }
72
+ };
73
+ await visit(root, '');
74
+ return { holes };
75
+ }
76
+ //# sourceMappingURL=kb-walk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kb-walk.js","sourceRoot":"","sources":["../../src/shared/kb-walk.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,O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MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YAC3D,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,KAAK,MAAM,CAAC,IAAI,SAAS;oBAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The ONE ordering of repository paths: component by component, each
3
+ * component by `localeCompare`, a shorter path before its extensions. It is
4
+ * exactly the order a directory walk that sorts each level's entries visits
5
+ * them in — so a consumer that must agree with the walk on "first by path"
6
+ * (plugin discovery keeps the first of two folders sharing a slug; principal
7
+ * synthesis must pick the same one) sorts with this and nothing else. A
8
+ * whole-string `localeCompare` does not agree: it weighs the separator
9
+ * against the next character (`a-b/x` before `a/b/x`), the walk never does.
10
+ *
11
+ * TOTAL over distinct paths: two components the collation cannot tell apart
12
+ * (a precomposed `é` and its decomposed spelling) fall through to code-unit
13
+ * order, so no pair of distinct paths ever compares equal — an equal pair
14
+ * would leave "first" to whichever enumeration happened to run, and the two
15
+ * consumers could then pick different folders for one slug.
16
+ */
17
+ export declare function comparePathComponents(a: string, b: string): number;
18
+ //# sourceMappingURL=path-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-order.d.ts","sourceRoot":"","sources":["../../src/shared/path-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CASlE"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The ONE ordering of repository paths: component by component, each
3
+ * component by `localeCompare`, a shorter path before its extensions. It is
4
+ * exactly the order a directory walk that sorts each level's entries visits
5
+ * them in — so a consumer that must agree with the walk on "first by path"
6
+ * (plugin discovery keeps the first of two folders sharing a slug; principal
7
+ * synthesis must pick the same one) sorts with this and nothing else. A
8
+ * whole-string `localeCompare` does not agree: it weighs the separator
9
+ * against the next character (`a-b/x` before `a/b/x`), the walk never does.
10
+ *
11
+ * TOTAL over distinct paths: two components the collation cannot tell apart
12
+ * (a precomposed `é` and its decomposed spelling) fall through to code-unit
13
+ * order, so no pair of distinct paths ever compares equal — an equal pair
14
+ * would leave "first" to whichever enumeration happened to run, and the two
15
+ * consumers could then pick different folders for one slug.
16
+ */
17
+ export function comparePathComponents(a, b) {
18
+ const as = a.split('/');
19
+ const bs = b.split('/');
20
+ const n = Math.min(as.length, bs.length);
21
+ for (let i = 0; i < n; i++) {
22
+ const order = compareComponent(as[i], bs[i]);
23
+ if (order !== 0)
24
+ return order;
25
+ }
26
+ return as.length - bs.length;
27
+ }
28
+ /** One component against another: collation first, code units to break a tie. */
29
+ function compareComponent(a, b) {
30
+ const order = a.localeCompare(b);
31
+ if (order !== 0)
32
+ return order;
33
+ return a < b ? -1 : a > b ? 1 : 0;
34
+ }
35
+ //# sourceMappingURL=path-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-order.js","sourceRoot":"","sources":["../../src/shared/path-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CAAC,CAAS,EAAE,CAAS;IACxD,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC;QAC/C,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IAChC,CAAC;IACD,OAAO,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC;AAC/B,CAAC;AAED,iFAAiF;AACjF,SAAS,gBAAgB,CAAC,CAAS,EAAE,CAAS;IAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -8,9 +8,36 @@ export declare class TtlCache<T> {
8
8
  private readonly ttlMs;
9
9
  private readonly now;
10
10
  private entry;
11
+ /**
12
+ * Bumped by every `invalidate()`. A fetch carries the value this had when it
13
+ * started, and `set` refuses a value whose fetch straddled a drop — see there.
14
+ */
15
+ private generation;
11
16
  constructor(ttlMs: number, now?: () => number);
12
17
  get(): T | null;
13
- set(value: T): void;
18
+ /**
19
+ * Take a token BEFORE starting the fetch whose result you will `set`.
20
+ *
21
+ * Every caller of this cache reads the disk across an `await`, and the whole
22
+ * point of `invalidate()` is that it fires during exactly that window: the
23
+ * merge pulls the new tree in while a catalog read that started on the old
24
+ * one is still in flight. Without a token that late `set` wins, and the cache
25
+ * holds the PRE-invalidation scan for a fresh full TTL — the drop silently
26
+ * undone, and the staleness it existed to prevent restored.
27
+ */
28
+ begin(): number;
29
+ /**
30
+ * Store a value fetched under `token`. Required, not optional: a caller that
31
+ * could forget it is a caller that reintroduces the race above, and there are
32
+ * few enough call sites to make the token cheap.
33
+ *
34
+ * A stale token means an `invalidate()` landed mid-fetch, so this value
35
+ * describes a tree that is already gone: it is DISCARDED rather than stored.
36
+ * The fetcher still returns it to its own caller — that read is merely as old
37
+ * as the moment it started, which is true of any read — but the next caller
38
+ * re-scans instead of inheriting it.
39
+ */
40
+ set(value: T, token: number): void;
14
41
  invalidate(): void;
15
42
  }
16
43
  //# sourceMappingURL=ttl-cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ttl-cache.d.ts","sourceRoot":"","sources":["../../src/shared/ttl-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAInB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,OAAO,CAAC,KAAK,CAAyC;gBAGnC,KAAK,EAAE,MAAM,EACb,GAAG,GAAE,MAAM,MAAiB;IAG/C,GAAG,IAAI,CAAC,GAAG,IAAI;IAKf,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAInB,UAAU,IAAI,IAAI;CAGnB"}
1
+ {"version":3,"file":"ttl-cache.d.ts","sourceRoot":"","sources":["../../src/shared/ttl-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,QAAQ,CAAC,CAAC;IASnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATtB,OAAO,CAAC,KAAK,CAAyC;IACtD;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAK;gBAGJ,KAAK,EAAE,MAAM,EACb,GAAG,GAAE,MAAM,MAAiB;IAG/C,GAAG,IAAI,CAAC,GAAG,IAAI;IAKf;;;;;;;;;OASG;IACH,KAAK,IAAI,MAAM;IAIf;;;;;;;;;;OAUG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,UAAU,IAAI,IAAI;CAInB"}
@@ -8,6 +8,11 @@ export class TtlCache {
8
8
  ttlMs;
9
9
  now;
10
10
  entry = null;
11
+ /**
12
+ * Bumped by every `invalidate()`. A fetch carries the value this had when it
13
+ * started, and `set` refuses a value whose fetch straddled a drop — see there.
14
+ */
15
+ generation = 0;
11
16
  constructor(ttlMs, now = Date.now) {
12
17
  this.ttlMs = ttlMs;
13
18
  this.now = now;
@@ -17,11 +22,38 @@ export class TtlCache {
17
22
  return this.entry.value;
18
23
  return null;
19
24
  }
20
- set(value) {
25
+ /**
26
+ * Take a token BEFORE starting the fetch whose result you will `set`.
27
+ *
28
+ * Every caller of this cache reads the disk across an `await`, and the whole
29
+ * point of `invalidate()` is that it fires during exactly that window: the
30
+ * merge pulls the new tree in while a catalog read that started on the old
31
+ * one is still in flight. Without a token that late `set` wins, and the cache
32
+ * holds the PRE-invalidation scan for a fresh full TTL — the drop silently
33
+ * undone, and the staleness it existed to prevent restored.
34
+ */
35
+ begin() {
36
+ return this.generation;
37
+ }
38
+ /**
39
+ * Store a value fetched under `token`. Required, not optional: a caller that
40
+ * could forget it is a caller that reintroduces the race above, and there are
41
+ * few enough call sites to make the token cheap.
42
+ *
43
+ * A stale token means an `invalidate()` landed mid-fetch, so this value
44
+ * describes a tree that is already gone: it is DISCARDED rather than stored.
45
+ * The fetcher still returns it to its own caller — that read is merely as old
46
+ * as the moment it started, which is true of any read — but the next caller
47
+ * re-scans instead of inheriting it.
48
+ */
49
+ set(value, token) {
50
+ if (token !== this.generation)
51
+ return;
21
52
  this.entry = { at: this.now(), value };
22
53
  }
23
54
  invalidate() {
24
55
  this.entry = null;
56
+ this.generation++;
25
57
  }
26
58
  }
27
59
  //# sourceMappingURL=ttl-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ttl-cache.js","sourceRoot":"","sources":["../../src/shared/ttl-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IAIA;IACA;IAJX,KAAK,GAAoC,IAAI,CAAC;IAEtD,YACmB,KAAa,EACb,MAAoB,IAAI,CAAC,GAAG;QAD5B,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAyB;IAC5C,CAAC;IAEJ,GAAG;QACD,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC;IACzC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF"}
1
+ {"version":3,"file":"ttl-cache.js","sourceRoot":"","sources":["../../src/shared/ttl-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IASA;IACA;IATX,KAAK,GAAoC,IAAI,CAAC;IACtD;;;OAGG;IACK,UAAU,GAAG,CAAC,CAAC;IAEvB,YACmB,KAAa,EACb,MAAoB,IAAI,CAAC,GAAG;QAD5B,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAyB;IAC5C,CAAC;IAEJ,GAAG;QACD,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG,CAAC,KAAQ,EAAE,KAAa;QACzB,IAAI,KAAK,KAAK,IAAI,CAAC,UAAU;YAAE,OAAO;QACtC,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC;IACzC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACF"}
@@ -22,4 +22,4 @@ CLAUDE.md
22
22
  **/access.md
23
23
  roles.yaml
24
24
 
25
- Plugins/
25
+ {{pluginsDir}}/