@bevel-software/platform-core-backend 0.4.1 → 0.5.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 (305) hide show
  1. package/THIRD-PARTY-NOTICES.md +6118 -0
  2. package/dist/core/core-ports.d.ts +15 -0
  3. package/dist/core/core-ports.d.ts.map +1 -1
  4. package/dist/core/core-ports.js.map +1 -1
  5. package/dist/core/create-core-server.d.ts.map +1 -1
  6. package/dist/core/create-core-server.js +40 -6
  7. package/dist/core/create-core-server.js.map +1 -1
  8. package/dist/core/create-core-services.d.ts +17 -1
  9. package/dist/core/create-core-services.d.ts.map +1 -1
  10. package/dist/core/create-core-services.js +153 -29
  11. package/dist/core/create-core-services.js.map +1 -1
  12. package/dist/core-config.d.ts +70 -21
  13. package/dist/core-config.d.ts.map +1 -1
  14. package/dist/core-config.js +134 -58
  15. package/dist/core-config.js.map +1 -1
  16. package/dist/modules/access/access-control.interface.d.ts +6 -0
  17. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  18. package/dist/modules/access/access-control.service.d.ts +74 -5
  19. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  20. package/dist/modules/access/access-control.service.js +116 -15
  21. package/dist/modules/access/access-control.service.js.map +1 -1
  22. package/dist/modules/access/access-declarations.d.ts +93 -0
  23. package/dist/modules/access/access-declarations.d.ts.map +1 -0
  24. package/dist/modules/access/access-declarations.js +168 -0
  25. package/dist/modules/access/access-declarations.js.map +1 -0
  26. package/dist/modules/access/access-mutation.service.js +4 -4
  27. package/dist/modules/access/access-mutation.service.js.map +1 -1
  28. package/dist/modules/access/access-splice.d.ts +16 -1
  29. package/dist/modules/access/access-splice.d.ts.map +1 -1
  30. package/dist/modules/access/access-splice.js +40 -21
  31. package/dist/modules/access/access-splice.js.map +1 -1
  32. package/dist/modules/access/access.routes.d.ts.map +1 -1
  33. package/dist/modules/access/access.routes.js +51 -0
  34. package/dist/modules/access/access.routes.js.map +1 -1
  35. package/dist/modules/access/creator-access.d.ts +8 -0
  36. package/dist/modules/access/creator-access.d.ts.map +1 -1
  37. package/dist/modules/access/creator-access.js +21 -2
  38. package/dist/modules/access/creator-access.js.map +1 -1
  39. package/dist/modules/admin/admin-access.service.d.ts +1 -1
  40. package/dist/modules/admin/admin-access.service.d.ts.map +1 -1
  41. package/dist/modules/admin/admin-access.service.js +3 -2
  42. package/dist/modules/admin/admin-access.service.js.map +1 -1
  43. package/dist/modules/auth/auth.routes.d.ts.map +1 -1
  44. package/dist/modules/auth/auth.routes.js +50 -1
  45. package/dist/modules/auth/auth.routes.js.map +1 -1
  46. package/dist/modules/auth/auth.service.d.ts +39 -10
  47. package/dist/modules/auth/auth.service.d.ts.map +1 -1
  48. package/dist/modules/auth/auth.service.js +38 -16
  49. package/dist/modules/auth/auth.service.js.map +1 -1
  50. package/dist/modules/database/core-schema.d.ts +124 -0
  51. package/dist/modules/database/core-schema.d.ts.map +1 -1
  52. package/dist/modules/database/core-schema.js +45 -0
  53. package/dist/modules/database/core-schema.js.map +1 -1
  54. package/dist/modules/groups/group-provision.service.d.ts +130 -0
  55. package/dist/modules/groups/group-provision.service.d.ts.map +1 -0
  56. package/dist/modules/groups/group-provision.service.js +288 -0
  57. package/dist/modules/groups/group-provision.service.js.map +1 -0
  58. package/dist/modules/groups/groups.contract.d.ts +106 -0
  59. package/dist/modules/groups/groups.contract.d.ts.map +1 -0
  60. package/dist/modules/groups/groups.contract.js +36 -0
  61. package/dist/modules/groups/groups.contract.js.map +1 -0
  62. package/dist/modules/groups/groups.routes.d.ts +42 -0
  63. package/dist/modules/groups/groups.routes.d.ts.map +1 -0
  64. package/dist/modules/groups/groups.routes.js +379 -0
  65. package/dist/modules/groups/groups.routes.js.map +1 -0
  66. package/dist/modules/groups/groups.service.d.ts +60 -0
  67. package/dist/modules/groups/groups.service.d.ts.map +1 -0
  68. package/dist/modules/groups/groups.service.js +172 -0
  69. package/dist/modules/groups/groups.service.js.map +1 -0
  70. package/dist/modules/groups/index.d.ts +7 -0
  71. package/dist/modules/groups/index.d.ts.map +1 -0
  72. package/dist/modules/groups/index.js +6 -0
  73. package/dist/modules/groups/index.js.map +1 -0
  74. package/dist/modules/groups/join-proposals.d.ts +53 -0
  75. package/dist/modules/groups/join-proposals.d.ts.map +1 -0
  76. package/dist/modules/groups/join-proposals.js +67 -0
  77. package/dist/modules/groups/join-proposals.js.map +1 -0
  78. package/dist/modules/groups/join-requests.service.d.ts +81 -0
  79. package/dist/modules/groups/join-requests.service.d.ts.map +1 -0
  80. package/dist/modules/groups/join-requests.service.js +135 -0
  81. package/dist/modules/groups/join-requests.service.js.map +1 -0
  82. package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +20 -0
  83. package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
  84. package/dist/modules/secrets-vault/secrets-vault.routes.js +59 -11
  85. package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
  86. package/dist/modules/settings/deployment-settings.service.d.ts +129 -0
  87. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -0
  88. package/dist/modules/settings/deployment-settings.service.js +368 -0
  89. package/dist/modules/settings/deployment-settings.service.js.map +1 -0
  90. package/dist/modules/settings/setup.routes.d.ts +49 -0
  91. package/dist/modules/settings/setup.routes.d.ts.map +1 -0
  92. package/dist/modules/settings/setup.routes.js +292 -0
  93. package/dist/modules/settings/setup.routes.js.map +1 -0
  94. package/dist/modules/skills/index.d.ts +2 -1
  95. package/dist/modules/skills/index.d.ts.map +1 -1
  96. package/dist/modules/skills/index.js +1 -0
  97. package/dist/modules/skills/index.js.map +1 -1
  98. package/dist/modules/skills/pending-skills.service.d.ts +40 -0
  99. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -0
  100. package/dist/modules/skills/pending-skills.service.js +147 -0
  101. package/dist/modules/skills/pending-skills.service.js.map +1 -0
  102. package/dist/modules/skills/skills.contract.d.ts +32 -3
  103. package/dist/modules/skills/skills.contract.d.ts.map +1 -1
  104. package/dist/modules/skills/skills.contract.js +1 -1
  105. package/dist/modules/skills/skills.routes.d.ts +3 -2
  106. package/dist/modules/skills/skills.routes.d.ts.map +1 -1
  107. package/dist/modules/skills/skills.routes.js +18 -1
  108. package/dist/modules/skills/skills.routes.js.map +1 -1
  109. package/dist/modules/skills/skills.service.d.ts +22 -0
  110. package/dist/modules/skills/skills.service.d.ts.map +1 -1
  111. package/dist/modules/skills/skills.service.js +24 -12
  112. package/dist/modules/skills/skills.service.js.map +1 -1
  113. package/dist/modules/tool-manuals/index.d.ts +1 -1
  114. package/dist/modules/tool-manuals/index.d.ts.map +1 -1
  115. package/dist/modules/tool-manuals/index.js.map +1 -1
  116. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +47 -2
  117. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
  118. package/dist/modules/tool-manuals/tool-manuals.contract.js +1 -1
  119. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +4 -0
  120. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
  121. package/dist/modules/tool-manuals/tool-manuals.routes.js +23 -0
  122. package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
  123. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +3 -1
  124. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  125. package/dist/modules/tool-manuals/tool-manuals.service.js +84 -17
  126. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  127. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
  128. package/dist/modules/tool-manuals/tool-manuals.tools.js +6 -2
  129. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  130. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
  131. package/dist/modules/workflow/agent-tools/workflow.tools.js +4 -2
  132. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  133. package/dist/modules/workflow/event-bus.d.ts +11 -0
  134. package/dist/modules/workflow/event-bus.d.ts.map +1 -1
  135. package/dist/modules/workflow/event-bus.js +22 -0
  136. package/dist/modules/workflow/event-bus.js.map +1 -1
  137. package/dist/modules/workflow/file-lock.service.d.ts +9 -0
  138. package/dist/modules/workflow/file-lock.service.d.ts.map +1 -1
  139. package/dist/modules/workflow/file-lock.service.js +16 -0
  140. package/dist/modules/workflow/file-lock.service.js.map +1 -1
  141. package/dist/modules/workflow/git/branch-name.d.ts +1 -1
  142. package/dist/modules/workflow/git/branch-name.d.ts.map +1 -1
  143. package/dist/modules/workflow/git/branch-name.js +1 -1
  144. package/dist/modules/workflow/git/branch-name.js.map +1 -1
  145. package/dist/modules/workflow/git/git.service.d.ts +31 -2
  146. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  147. package/dist/modules/workflow/git/git.service.js +144 -52
  148. package/dist/modules/workflow/git/git.service.js.map +1 -1
  149. package/dist/modules/workflow/git/pull-request.service.d.ts +12 -6
  150. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  151. package/dist/modules/workflow/git/pull-request.service.js +19 -9
  152. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  153. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
  154. package/dist/modules/workflow/review-workflow/review-workflow.service.js +12 -3
  155. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  156. package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
  157. package/dist/modules/workflow/workflow.routes.js +95 -14
  158. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  159. package/dist/modules/workflow/workflow.service.d.ts +92 -3
  160. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  161. package/dist/modules/workflow/workflow.service.js +381 -108
  162. package/dist/modules/workflow/workflow.service.js.map +1 -1
  163. package/dist/modules/workspace/bevel-ignore.d.ts +5 -0
  164. package/dist/modules/workspace/bevel-ignore.d.ts.map +1 -1
  165. package/dist/modules/workspace/bevel-ignore.js +5 -1
  166. package/dist/modules/workspace/bevel-ignore.js.map +1 -1
  167. package/dist/modules/workspace/kb-seed.interface.d.ts +1 -1
  168. package/dist/modules/workspace/kb-seed.service.d.ts +60 -5
  169. package/dist/modules/workspace/kb-seed.service.d.ts.map +1 -1
  170. package/dist/modules/workspace/kb-seed.service.js +228 -51
  171. package/dist/modules/workspace/kb-seed.service.js.map +1 -1
  172. package/dist/modules/workspace/workspace.routes.d.ts +2 -1
  173. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  174. package/dist/modules/workspace/workspace.routes.js +51 -18
  175. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  176. package/dist/modules/workspace/workspace.service.d.ts +16 -4
  177. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  178. package/dist/modules/workspace/workspace.service.js +36 -9
  179. package/dist/modules/workspace/workspace.service.js.map +1 -1
  180. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  181. package/dist/modules/workspace/workspace.tools.js +8 -3
  182. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  183. package/dist/shared/kb-layout.test.js +2 -2
  184. package/dist/test-setup.d.ts +2 -0
  185. package/dist/test-setup.d.ts.map +1 -0
  186. package/dist/test-setup.js +18 -0
  187. package/dist/test-setup.js.map +1 -0
  188. package/kb-template/.bevelignore +6 -2
  189. package/kb-template/AGENTS.md +272 -0
  190. package/kb-template/KnowledgeBase/How to get started.md +65 -0
  191. package/kb-template/access.md +36 -36
  192. package/migrations/0002_user_onboarding_done.sql +1 -0
  193. package/migrations/0003_deployment_settings.sql +9 -0
  194. package/migrations/meta/0001_snapshot.json +1486 -0
  195. package/migrations/meta/0002_snapshot.json +1493 -0
  196. package/migrations/meta/0003_snapshot.json +1552 -0
  197. package/migrations/meta/_journal.json +15 -1
  198. package/package.json +5 -4
  199. package/src/__tests__/branch-model.test.ts +79 -0
  200. package/src/__tests__/core-config.admin.test.ts +114 -0
  201. package/src/__tests__/database-url.test.ts +70 -0
  202. package/src/core/core-ports.ts +15 -0
  203. package/src/core/create-core-server.ts +55 -6
  204. package/src/core/create-core-services.ts +201 -36
  205. package/src/core-config.ts +139 -59
  206. package/src/modules/access/__tests__/access-declarations.test.ts +195 -0
  207. package/src/modules/access/__tests__/access-md-format.test.ts +191 -0
  208. package/src/modules/access/__tests__/access-splice.test.ts +21 -0
  209. package/src/modules/access/__tests__/access.routes.overrides.test.ts +214 -0
  210. package/src/modules/access/access-control.interface.ts +11 -0
  211. package/src/modules/access/access-control.service.ts +113 -15
  212. package/src/modules/access/access-declarations.ts +251 -0
  213. package/src/modules/access/access-mutation.service.ts +4 -4
  214. package/src/modules/access/access-splice.ts +64 -21
  215. package/src/modules/access/access.routes.ts +61 -0
  216. package/src/modules/access/creator-access.ts +22 -2
  217. package/src/modules/admin/admin-access.service.ts +4 -3
  218. package/src/modules/auth/__tests__/auth.service.test.ts +57 -0
  219. package/src/modules/auth/__tests__/onboarding-done.route.test.ts +147 -0
  220. package/src/modules/auth/auth.routes.ts +50 -1
  221. package/src/modules/auth/auth.service.ts +55 -17
  222. package/src/modules/database/core-schema.ts +46 -0
  223. package/src/modules/groups/__tests__/group-index.service.test.ts +225 -0
  224. package/src/modules/groups/__tests__/group-provision.service.test.ts +247 -0
  225. package/src/modules/groups/__tests__/groups.routes.test.ts +493 -0
  226. package/src/modules/groups/__tests__/join-proposals.test.ts +101 -0
  227. package/src/modules/groups/__tests__/join-requests.service.test.ts +175 -0
  228. package/src/modules/groups/group-provision.service.ts +328 -0
  229. package/src/modules/groups/groups.contract.ts +107 -0
  230. package/src/modules/groups/groups.routes.ts +433 -0
  231. package/src/modules/groups/groups.service.ts +193 -0
  232. package/src/modules/groups/index.ts +17 -0
  233. package/src/modules/groups/join-proposals.ts +114 -0
  234. package/src/modules/groups/join-requests.service.ts +185 -0
  235. package/src/modules/secrets-vault/__tests__/oauth-return-to.route.test.ts +283 -0
  236. package/src/modules/secrets-vault/secrets-vault.routes.ts +68 -12
  237. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +256 -0
  238. package/src/modules/settings/__tests__/setup.routes.test.ts +201 -0
  239. package/src/modules/settings/deployment-settings.service.ts +419 -0
  240. package/src/modules/settings/setup.routes.ts +317 -0
  241. package/src/modules/skills/__tests__/pending-skills.service.test.ts +240 -0
  242. package/src/modules/skills/__tests__/skills.service.test.ts +13 -13
  243. package/src/modules/skills/index.ts +3 -0
  244. package/src/modules/skills/pending-skills.service.ts +168 -0
  245. package/src/modules/skills/skills.contract.ts +34 -3
  246. package/src/modules/skills/skills.routes.ts +23 -2
  247. package/src/modules/skills/skills.service.ts +24 -16
  248. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +262 -0
  249. package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -2
  250. package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +61 -23
  251. package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +156 -156
  252. package/src/modules/tool-manuals/index.ts +2 -0
  253. package/src/modules/tool-manuals/tool-manuals.contract.ts +50 -2
  254. package/src/modules/tool-manuals/tool-manuals.routes.ts +21 -0
  255. package/src/modules/tool-manuals/tool-manuals.service.ts +86 -17
  256. package/src/modules/tool-manuals/tool-manuals.tools.ts +206 -202
  257. package/src/modules/workflow/__tests__/event-bus.test.ts +35 -0
  258. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +251 -5
  259. package/src/modules/workflow/agent-tools/workflow.tools.ts +4 -2
  260. package/src/modules/workflow/event-bus.ts +25 -0
  261. package/src/modules/workflow/file-lock.service.ts +17 -0
  262. package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +9 -49
  263. package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +101 -0
  264. package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +219 -211
  265. package/src/modules/workflow/git/__tests__/git.service.fileContentsAtCommit.test.ts +132 -0
  266. package/src/modules/workflow/git/__tests__/git.service.logForFile.test.ts +4 -2
  267. package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +275 -272
  268. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +5 -0
  269. package/src/modules/workflow/git/__tests__/pull-request.service.viewer-can-cancel.test.ts +44 -0
  270. package/src/modules/workflow/git/branch-name.ts +5 -1
  271. package/src/modules/workflow/git/git.service.ts +159 -62
  272. package/src/modules/workflow/git/pull-request.service.ts +22 -11
  273. package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +4 -1
  274. package/src/modules/workflow/review-workflow/review-workflow.service.ts +12 -3
  275. package/src/modules/workflow/workflow.routes.ts +91 -13
  276. package/src/modules/workflow/workflow.service.ts +353 -13
  277. package/src/modules/workspace/__tests__/kb-seed.service.test.ts +255 -24
  278. package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +236 -233
  279. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +179 -176
  280. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +320 -303
  281. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +337 -276
  282. package/src/modules/workspace/__tests__/workspace.tools.test.ts +14 -6
  283. package/src/modules/workspace/bevel-ignore.ts +66 -62
  284. package/src/modules/workspace/kb-seed.interface.ts +1 -1
  285. package/src/modules/workspace/kb-seed.service.ts +247 -53
  286. package/src/modules/workspace/workspace.routes.ts +54 -18
  287. package/src/modules/workspace/workspace.service.ts +45 -7
  288. package/src/modules/workspace/workspace.tools.ts +922 -917
  289. package/src/shared/__tests__/frontmatter-id.test.ts +53 -0
  290. package/src/shared/__tests__/join-request.test.ts +96 -0
  291. package/src/shared/__tests__/kb-layout.group.test.ts +45 -0
  292. package/src/shared/kb-layout.test.ts +2 -2
  293. package/src/test-setup.ts +18 -0
  294. package/kb-template/Agents/README.md +0 -38
  295. package/kb-template/CLAUDE.md +0 -419
  296. package/kb-template/Data/.gitkeep +0 -0
  297. package/kb-template/Data/README.md +0 -39
  298. package/kb-template/KnowledgeBase/README.md +0 -37
  299. package/kb-template/Pipelines/.gitkeep +0 -0
  300. package/kb-template/Pipelines/README.md +0 -38
  301. package/kb-template/Skills/.gitkeep +0 -0
  302. package/kb-template/Skills/README.md +0 -32
  303. package/kb-template/Tools/.gitkeep +0 -0
  304. package/kb-template/Tools/README.md +0 -42
  305. /package/kb-template/{Agents → Groups}/.gitkeep +0 -0
@@ -3,7 +3,8 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
- import { AGENTS_DIR, DATA_DIR, KNOWLEDGE_BASE_DIR, PIPELINES_DIR, SKILLS_DIR, TOOLS_DIR, } from '@bevel-software/platform-shared';
6
+ import { KNOWLEDGE_BASE_DIR, GROUPS_DIR } from '@bevel-software/platform-shared';
7
+ import { IGNORE_FILENAME } from './bevel-ignore.js';
7
8
  const execFileAsync = promisify(execFile);
8
9
  /**
9
10
  * Fallback committer identity for seed commits. Mirrors the workspace clone's
@@ -18,24 +19,51 @@ const BOT_EMAIL = 'bevel-workflow@bevel.software';
18
19
  *
19
20
  * Two kinds:
20
21
  * - {@link REQUIRED_FILES}: repo-root files added when the file is missing.
21
- * - {@link REQUIRED_DIRS}: well-known root dirs the app expects to exist; when a
22
- * dir is entirely absent it's created by adding its `<dir>/.gitkeep`. Keyed on
23
- * the *directory's* existence, not the `.gitkeep` file — so a branch that
24
- * already has content under `KnowledgeBase/` never gets a pointless placeholder.
22
+ * - {@link CORE_REQUIRED_DIRS} (plus any `extraDirs`): well-known root dirs the
23
+ * app expects to exist; when a dir is entirely absent it's created by adding
24
+ * its `<dir>/.gitkeep`. Keyed on the *directory's* existence, not the
25
+ * `.gitkeep` file — so a branch that already has content under
26
+ * `KnowledgeBase/` never gets a pointless placeholder.
25
27
  *
26
28
  * `roles.yaml` is in neither, and is not part of the template at all: it is
27
- * generated from `SEED_ADMIN_EMAILS` (see {@link renderRolesYaml}) and written
29
+ * generated from `ADMIN_EMAIL` (see {@link renderRolesYaml}) and written
28
30
  * directly, so a repo can't be seeded with a stale hard-coded Admin list.
29
31
  */
30
- const REQUIRED_FILES = ['access.md', 'CLAUDE.md', '.bevelignore', '.gitignore'];
31
- const REQUIRED_DIRS = [
32
- KNOWLEDGE_BASE_DIR,
33
- DATA_DIR,
34
- AGENTS_DIR,
35
- PIPELINES_DIR,
36
- SKILLS_DIR,
37
- TOOLS_DIR,
38
- ];
32
+ const REQUIRED_FILES = ['access.md', 'AGENTS.md', '.bevelignore', '.gitignore'];
33
+ /**
34
+ * The two roots CORE gives a knowledge base: the ontologies, and the groups
35
+ * that hold skills and tools.
36
+ *
37
+ * `Data/`, `Agents/` and `Pipelines/` are deliberately absent. They scaffold
38
+ * the agentic execution layer, which is not part of this platform — a core
39
+ * deployment that created them would be handing every operator three empty
40
+ * folders it has no feature to fill. A distribution that DOES own that layer
41
+ * passes them as `extraDirs` (and ships a template carrying their READMEs);
42
+ * the names stay reserved in `kb-layout.ts` either way, so a KB that has them
43
+ * still renders them as roots rather than folding them into Knowledge.
44
+ */
45
+ export const CORE_REQUIRED_DIRS = [KNOWLEDGE_BASE_DIR, GROUPS_DIR];
46
+ /**
47
+ * A reserved root must be ONE path segment — `Data`, not `Data/x`, `../x` or
48
+ * `/x`. The name is joined onto the repo root, so anything else writes outside
49
+ * the repo being seeded.
50
+ *
51
+ * Deliberately NOT a check against the reserved-root set in `kb-layout.ts`:
52
+ * `Data`, `Agents` and `Pipelines` are all in that set, and they are precisely
53
+ * what a distribution passes here. Being reserved is what makes a name worth
54
+ * claiming — the file tree renders it as its own root instead of folding it
55
+ * into Knowledge — so rejecting reserved names would reject the only real use.
56
+ */
57
+ function assertRootSegment(dir) {
58
+ if (!dir ||
59
+ dir === '.' ||
60
+ dir === '..' ||
61
+ dir.includes('/') ||
62
+ dir.includes('\\') ||
63
+ path.isAbsolute(dir)) {
64
+ throw new Error(`Reserved KB root must be a single path segment (no separators, no ".."); got "${dir}"`);
65
+ }
66
+ }
39
67
  /** Redact the token from any string that might surface in a log or error. */
40
68
  function redact(s) {
41
69
  const token = process.env.GITHUB_TOKEN;
@@ -48,7 +76,7 @@ function renderRolesYaml(adminEmails) {
48
76
  '# Role names are case- and whitespace-insensitive. The `Admin` role is special:\n' +
49
77
  '# only Admins may edit this file, and at least one Admin must always exist.\n' +
50
78
  '#\n' +
51
- '# Generated by the Bevel platform at KB-seed time from SEED_ADMIN_EMAILS.\n' +
79
+ '# Generated by the Bevel platform at KB-seed time from ADMIN_EMAIL.\n' +
52
80
  'roles:\n' +
53
81
  ' Admin:\n' +
54
82
  `${lines}\n`);
@@ -68,12 +96,8 @@ function renderRolesYaml(adminEmails) {
68
96
  * branch a user loads: it fills in any missing base files on that branch.
69
97
  */
70
98
  export class KbSeedService {
71
- kbRepoUrl;
72
99
  kbTemplateDir;
73
- protectedBranches;
74
- defaultBranch;
75
100
  seedAdminEmails;
76
- gitUsername;
77
101
  /** Single-flight: the first caller runs the remote pass; the rest await its result. */
78
102
  inFlight = null;
79
103
  /**
@@ -85,15 +109,49 @@ export class KbSeedService {
85
109
  * base when creating a missing protected branch.
86
110
  * @param seedAdminEmails Admins written into the generated `roles.yaml`.
87
111
  * @param gitUsername Basic-auth username for git-over-HTTPS (provider-specific).
112
+ * @param extraDirs Additional root folders this distribution reserves,
113
+ * on top of {@link CORE_REQUIRED_DIRS}. Their
114
+ * `.gitkeep` is written directly rather than copied,
115
+ * so a distribution can claim a root without also
116
+ * shipping a template entry for it.
88
117
  */
89
- constructor(kbRepoUrl, kbTemplateDir, protectedBranches, defaultBranch, seedAdminEmails, gitUsername = 'x-access-token') {
90
- this.kbRepoUrl = kbRepoUrl;
118
+ constructor(kbRepoUrl, kbTemplateDir, protectedBranches, defaultBranch, seedAdminEmails, gitUsername = 'x-access-token', extraDirs = []) {
91
119
  this.kbTemplateDir = kbTemplateDir;
92
- this.protectedBranches = protectedBranches;
93
- this.defaultBranch = defaultBranch;
94
120
  this.seedAdminEmails = seedAdminEmails;
95
- this.gitUsername = gitUsername;
121
+ // A getter is read per-operation, so a remote supplied through the setup
122
+ // screen is seeded against without restarting; a string is still accepted.
123
+ this.kbRepoUrl = typeof kbRepoUrl === 'function' ? kbRepoUrl : () => kbRepoUrl;
124
+ // Read when seeding, not at construction: the branch model can be supplied
125
+ // through the setup screen, which happens after this object exists.
126
+ this.protectedBranches =
127
+ typeof protectedBranches === 'function' ? protectedBranches : () => protectedBranches;
128
+ this.defaultBranch = typeof defaultBranch === 'function' ? defaultBranch : () => defaultBranch;
129
+ this.gitUsername = typeof gitUsername === 'function' ? gitUsername : () => gitUsername;
130
+ // NOT a getter, unlike its neighbours above: the reserved roots are named
131
+ // by the composition root in code, not collected on the setup screen, so
132
+ // there is nothing to re-read. Validated once, here — every entry is joined
133
+ // onto the repo root and onto `<dir>/.gitkeep`, so a separator or a `..`
134
+ // would write outside the repo being seeded, and a bad value should fail at
135
+ // boot beside the rest of the wiring rather than part-way through seeding
136
+ // somebody's knowledge base. Same contract as `KB_DIR_NAME` in `CoreConfig`.
137
+ for (const dir of extraDirs) {
138
+ assertRootSegment(dir);
139
+ // A root named after a required FILE is a typo with a silent outcome:
140
+ // the file is laid down first in both seed paths, so `ensureRequiredDirs`
141
+ // finds the path taken and skips it, and the directory the caller asked
142
+ // for never appears with nothing said about why.
143
+ if (REQUIRED_FILES.includes(dir)) {
144
+ throw new Error(`Reserved KB root "${dir}" collides with a required file of the same name`);
145
+ }
146
+ }
147
+ this.requiredDirs = [...CORE_REQUIRED_DIRS, ...extraDirs];
96
148
  }
149
+ kbRepoUrl;
150
+ protectedBranches;
151
+ defaultBranch;
152
+ gitUsername;
153
+ /** Root folders this deployment guarantees — core's two plus any extras. */
154
+ requiredDirs;
97
155
  ensureRemoteSeeded() {
98
156
  // Cache the promise, not just a boolean, so concurrent first-callers share
99
157
  // one run. On failure we clear it so a later call can retry (a transient
@@ -110,9 +168,11 @@ export class KbSeedService {
110
168
  const heads = await this.lsRemoteHeads();
111
169
  if (heads.size === 0) {
112
170
  if (this.seedAdminEmails.length === 0) {
113
- throw new Error(`KB remote ${redact(this.kbRepoUrl)} is empty and cannot be seeded: ` +
114
- 'set SEED_ADMIN_EMAILS to the initial Admin email(s). A seeded KB with ' +
115
- 'no Admin is unusable (access resolution requires at least one Admin).');
171
+ throw new Error(`KB remote ${redact(this.kbRepoUrl())} is empty and cannot be seeded: ` +
172
+ 'no initial Admin was supplied. A seeded KB with no Admin is unusable ' +
173
+ '(access resolution requires at least one Admin). Unreachable in ' +
174
+ 'normal operation — ADMIN_EMAIL is required at boot — so this guards ' +
175
+ 'a caller that constructed the seeder with an empty list.');
116
176
  }
117
177
  await this.seedEmptyRemote();
118
178
  return;
@@ -121,7 +181,7 @@ export class KbSeedService {
121
181
  // later `clone -b <branch>` succeeds. This creates the branch pointer only;
122
182
  // per-branch file top-up happens in `topUpWorkspace` when the branch loads.
123
183
  const base = this.pickBase(heads);
124
- for (const branch of this.protectedBranches) {
184
+ for (const branch of this.protectedBranches()) {
125
185
  if (!heads.has(branch)) {
126
186
  await this.createBranchOnRemote(branch, base);
127
187
  }
@@ -137,30 +197,51 @@ export class KbSeedService {
137
197
  * stays consistent with origin, and the top-up is retried on a future clone.
138
198
  */
139
199
  async topUpWorkspace(repoDir, branch) {
200
+ // Scaffolding lands on PROTECTED branches only. A draft or suggestions
201
+ // branch is somebody's change-in-waiting, and a seeder commit there
202
+ // surfaces as noise in their change request's diff against the default
203
+ // branch (a stray scaffolding file riding along in a skill proposal was
204
+ // exactly this). Whatever the protected branches are missing, they get
205
+ // when THEY load — and drafts fork from them.
206
+ if (!this.protectedBranches().includes(branch))
207
+ return;
140
208
  try {
141
209
  const added = [];
142
210
  for (const rel of REQUIRED_FILES) {
143
211
  if (!(await this.exists(path.join(repoDir, rel)))) {
144
212
  await this.copyTemplateFile(rel, repoDir);
145
213
  added.push(rel);
214
+ // Adding AGENTS.md to a knowledge base seeded before the rename
215
+ // leaves it VISIBLE: that repo's `.bevelignore` lists CLAUDE.md and
216
+ // knows nothing of the new name, so the conventions doc starts
217
+ // showing up in the file tree and the agent view. We created the
218
+ // mismatch by adding the file, so we close it here.
219
+ if (rel === 'AGENTS.md')
220
+ added.push(...(await this.mergeIgnorePattern(repoDir, rel)));
146
221
  }
147
222
  }
148
- for (const rootDir of REQUIRED_DIRS) {
149
- if (!(await this.exists(path.join(repoDir, rootDir)))) {
150
- const keep = `${rootDir}/.gitkeep`;
151
- await this.copyTemplateFile(keep, repoDir);
152
- added.push(keep);
153
- }
223
+ // AGENTS.md is MANAGED, not merely seeded: the platform owns its
224
+ // content, and a stale copy is replaced with the packaged template's on
225
+ // every top-up (each fresh clone of a protected branch — in practice,
226
+ // every server restart). The file's own header says so, which is what
227
+ // makes overwriting edits a stated contract instead of a surprise.
228
+ let agentsRefreshed = false;
229
+ if (!added.includes('AGENTS.md') &&
230
+ (await this.templateDiffers(repoDir, 'AGENTS.md'))) {
231
+ await this.copyTemplateFile('AGENTS.md', repoDir);
232
+ added.push('AGENTS.md');
233
+ agentsRefreshed = true;
154
234
  }
235
+ added.push(...(await this.ensureRequiredDirs(repoDir)));
155
236
  if (!(await this.exists(path.join(repoDir, 'roles.yaml')))) {
156
237
  if (this.seedAdminEmails.length > 0) {
157
238
  await fs.writeFile(path.join(repoDir, 'roles.yaml'), renderRolesYaml(this.seedAdminEmails), 'utf8');
158
239
  added.push('roles.yaml');
159
240
  }
160
241
  else {
161
- console.warn(`[kb-seed] Branch "${branch}" is missing roles.yaml but SEED_ADMIN_EMAILS ` +
162
- 'is unset — leaving it absent. Access resolution will fail until an ' +
163
- 'Admin roles.yaml exists; set SEED_ADMIN_EMAILS or add roles.yaml manually.');
242
+ console.warn(`[kb-seed] Branch "${branch}" is missing roles.yaml and ADMIN_EMAIL is ` +
243
+ 'unset — leaving it absent. Access resolution will fail until an ' +
244
+ 'Admin roles.yaml exists; set ADMIN_EMAIL or add roles.yaml manually.');
164
245
  }
165
246
  }
166
247
  if (added.length === 0)
@@ -170,7 +251,10 @@ export class KbSeedService {
170
251
  // values, so this is a harmless no-op there).
171
252
  await this.stampIdentity(repoDir);
172
253
  await this.git(repoDir, ['add', '--', ...added]);
173
- await this.git(repoDir, ['commit', '-m', `Add missing KB scaffolding: ${added.join(', ')}`]);
254
+ const message = agentsRefreshed && added.length === 1
255
+ ? 'Update AGENTS.md to the current platform template'
256
+ : `Add missing KB scaffolding: ${added.join(', ')}`;
257
+ await this.git(repoDir, ['commit', '-m', message]);
174
258
  try {
175
259
  await this.git(repoDir, ['push', 'origin', `HEAD:refs/heads/${branch}`]);
176
260
  console.log(`[kb-seed] Topped up "${branch}" with: ${added.join(', ')}`);
@@ -191,9 +275,9 @@ export class KbSeedService {
191
275
  }
192
276
  /** Prefer the default branch as a base, else the first protected branch present, else any head. */
193
277
  pickBase(heads) {
194
- if (heads.has(this.defaultBranch))
195
- return this.defaultBranch;
196
- const protectedPresent = this.protectedBranches.find((b) => heads.has(b));
278
+ if (heads.has(this.defaultBranch()))
279
+ return this.defaultBranch();
280
+ const protectedPresent = this.protectedBranches().find((b) => heads.has(b));
197
281
  if (protectedPresent)
198
282
  return protectedPresent;
199
283
  // Deterministic pick so repeated runs behave identically.
@@ -206,7 +290,7 @@ export class KbSeedService {
206
290
  if (token) {
207
291
  // The helper reads GITHUB_TOKEN at runtime, so the value never appears in argv.
208
292
  // Username is provider-specific; the token is always the Basic-auth password.
209
- args.push('-c', `credential.helper=!f() { echo "username=${this.gitUsername}"; echo "password=$GITHUB_TOKEN"; }; f`);
293
+ args.push('-c', `credential.helper=!f() { echo "username=${this.gitUsername()}"; echo "password=$GITHUB_TOKEN"; }; f`);
210
294
  }
211
295
  return args;
212
296
  }
@@ -229,7 +313,7 @@ export class KbSeedService {
229
313
  }
230
314
  /** Set of branch names on the remote (empty ⇒ uninitialised repo). */
231
315
  async lsRemoteHeads() {
232
- const out = await this.git(null, [...this.credArgs(), 'ls-remote', '--heads', this.kbRepoUrl]);
316
+ const out = await this.git(null, [...this.credArgs(), 'ls-remote', '--heads', this.kbRepoUrl()]);
233
317
  const heads = new Set();
234
318
  for (const line of out.split('\n')) {
235
319
  const m = line.match(/\srefs\/heads\/(.+)$/);
@@ -270,17 +354,110 @@ export class KbSeedService {
270
354
  await walk('');
271
355
  }
272
356
  /** Copy one template file (by repo-relative path) into `dest`, creating parents. */
357
+ /**
358
+ * Whether the repo's copy of `relPath` differs from the template's, modulo
359
+ * line endings — a CRLF checkout of identical content must read as "same",
360
+ * or the managed-file refresh would commit churn on every boot forever.
361
+ */
362
+ async templateDiffers(repoDir, relPath) {
363
+ const norm = (text) => text.replace(/\r\n?/g, '\n');
364
+ const [current, template] = await Promise.all([
365
+ fs.readFile(path.join(repoDir, relPath), 'utf8'),
366
+ fs.readFile(path.join(this.kbTemplateDir, relPath), 'utf8'),
367
+ ]);
368
+ return norm(current) !== norm(template);
369
+ }
273
370
  async copyTemplateFile(relPath, dest) {
274
371
  const from = path.join(this.kbTemplateDir, relPath);
275
372
  const to = path.join(dest, relPath);
276
373
  await fs.mkdir(path.dirname(to), { recursive: true });
277
374
  await fs.copyFile(from, to);
278
375
  }
376
+ /**
377
+ * Ensure `.bevelignore` carries `pattern`, appending it when absent. Returns
378
+ * the paths changed, for the commit.
379
+ *
380
+ * APPENDS — never rewrites. The file is the operator's, and every rule
381
+ * already in it is theirs to keep; this adds one line under a comment saying
382
+ * where it came from. Absent file, or a file that already lists the pattern,
383
+ * is a no-op, so running it on every clone changes nothing after the first.
384
+ *
385
+ * Matched line-wise rather than by substring: a rule for `Groups/AGENTS.md`
386
+ * is not a rule for the root `AGENTS.md`, and treating it as one would leave
387
+ * the mismatch this exists to close.
388
+ */
389
+ async mergeIgnorePattern(repoDir, pattern) {
390
+ const ignorePath = path.join(repoDir, IGNORE_FILENAME);
391
+ let current;
392
+ try {
393
+ current = await fs.readFile(ignorePath, 'utf8');
394
+ }
395
+ catch {
396
+ return []; // No ignore file — the template's copy arrives with the pattern in it.
397
+ }
398
+ const lines = current.split('\n').map((l) => l.trim());
399
+ if (lines.includes(pattern))
400
+ return [];
401
+ const separator = current.endsWith('\n') ? '' : '\n';
402
+ await fs.appendFile(ignorePath, `${separator}\n# Added by the platform: the conventions doc is not node content.\n${pattern}\n`, 'utf8');
403
+ return [IGNORE_FILENAME];
404
+ }
405
+ /**
406
+ * Create any reserved root folder this repo is missing, as an empty
407
+ * `<dir>/.gitkeep`. Returns the paths added, for the commit message.
408
+ *
409
+ * WRITTEN, not copied from the template. A `.gitkeep` is empty by definition,
410
+ * and requiring a template entry per root would mean a distribution could not
411
+ * reserve one without forking the packaged template.
412
+ *
413
+ * Keyed on the DIRECTORY's existence, not the `.gitkeep` file — a branch that
414
+ * already has content under `KnowledgeBase/` never gets a pointless
415
+ * placeholder alongside it.
416
+ */
417
+ async ensureRequiredDirs(repoDir) {
418
+ const added = [];
419
+ for (const rootDir of this.requiredDirs) {
420
+ const abs = path.join(repoDir, rootDir);
421
+ // `lstat`, not `exists`: `fs.access` answers "is there something here?",
422
+ // which is true of a FILE named `Groups` — and the old skip-if-present
423
+ // check then did nothing and reported success, leaving a knowledge base
424
+ // permanently missing a root it claims to guarantee. `lstat` rather than
425
+ // `stat` so a SYMLINK is rejected too: a link named `Groups` is not a KB
426
+ // layout, and one pointing outside the repo would make every later write
427
+ // into it land somewhere nobody asked for.
428
+ const found = await this.lstatOrNull(abs);
429
+ if (found) {
430
+ if (found.isDirectory())
431
+ continue;
432
+ throw new Error(`KB root "${rootDir}" exists but is not a directory ` +
433
+ `(${found.isSymbolicLink() ? 'symlink' : 'file'}). Remove or rename it — ` +
434
+ 'the platform requires this name to be a folder.');
435
+ }
436
+ await fs.mkdir(abs, { recursive: true });
437
+ await fs.writeFile(path.join(abs, '.gitkeep'), '', 'utf8');
438
+ added.push(`${rootDir}/.gitkeep`);
439
+ }
440
+ return added;
441
+ }
442
+ /** `lstat` without the throw — null when nothing is at `p`. */
443
+ async lstatOrNull(p) {
444
+ try {
445
+ return await fs.lstat(p);
446
+ }
447
+ catch {
448
+ return null;
449
+ }
450
+ }
279
451
  /** `git init` a temp repo, lay down the full template + generated roles.yaml, commit. */
280
452
  async buildSeedCommit(dir) {
281
- await this.git(dir, ['init', '-b', this.defaultBranch]);
453
+ await this.git(dir, ['init', '-b', this.defaultBranch()]);
282
454
  await this.stampIdentity(dir);
283
455
  await this.copyTemplateTree(dir);
456
+ // Reserved roots the template does not carry. Without this the seed commit
457
+ // would hold only what the template has, and a distribution's own roots
458
+ // would appear a step later, when the first clone gets topped up — the same
459
+ // folders, arriving in a second commit for no reason.
460
+ await this.ensureRequiredDirs(dir);
284
461
  await fs.writeFile(path.join(dir, 'roles.yaml'), renderRolesYaml(this.seedAdminEmails), 'utf8');
285
462
  await this.git(dir, ['add', '-A']);
286
463
  await this.git(dir, ['commit', '-m', 'Seed knowledge base from Bevel template']);
@@ -291,22 +468,22 @@ export class KbSeedService {
291
468
  await this.buildSeedCommit(dir);
292
469
  // Point every protected branch at the seed commit. The init branch is
293
470
  // already `defaultBranch`; create the rest as refs to HEAD.
294
- for (const branch of this.protectedBranches) {
295
- if (branch !== this.defaultBranch) {
471
+ for (const branch of this.protectedBranches()) {
472
+ if (branch !== this.defaultBranch()) {
296
473
  await this.git(dir, ['branch', branch]);
297
474
  }
298
475
  }
299
- await this.git(dir, ['remote', 'add', 'origin', this.kbRepoUrl]);
476
+ await this.git(dir, ['remote', 'add', 'origin', this.kbRepoUrl()]);
300
477
  // Push only the protected branches — never the stray init branch if it
301
478
  // isn't itself protected.
302
- await this.git(dir, [...this.credArgs(), 'push', '-u', 'origin', ...this.protectedBranches]);
303
- console.log(`[kb-seed] Seeded empty KB remote with branches: ${this.protectedBranches.join(', ')}`);
479
+ await this.git(dir, [...this.credArgs(), 'push', '-u', 'origin', ...this.protectedBranches()]);
480
+ console.log(`[kb-seed] Seeded empty KB remote with branches: ${this.protectedBranches().join(', ')}`);
304
481
  });
305
482
  }
306
483
  /** Create a missing protected branch on the remote, pointed at `base`'s tip. */
307
484
  async createBranchOnRemote(branch, base) {
308
485
  await this.withTempDir(async (dir) => {
309
- await this.git(dir, [...this.credArgs(), 'clone', '--depth', '1', '-b', base, this.kbRepoUrl, dir]);
486
+ await this.git(dir, [...this.credArgs(), 'clone', '--depth', '1', '-b', base, this.kbRepoUrl(), dir]);
310
487
  // Push base's fetched tip up under the new branch name.
311
488
  await this.git(dir, [...this.credArgs(), 'push', 'origin', `HEAD:refs/heads/${branch}`]);
312
489
  console.log(`[kb-seed] Created missing protected branch "${branch}" from "${base}"`);
@@ -1 +1 @@
1
- {"version":3,"file":"kb-seed.service.js","sourceRoot":"","sources":["../../../src/modules/workspace/kb-seed.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,iCAAiC,CAAC;AAGzC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C;;;GAGG;AACH,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAClC,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAElD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,cAAc,GAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AACnG,MAAM,aAAa,GAAsB;IACvC,kBAAkB;IAClB,QAAQ;IACR,UAAU;IACV,aAAa;IACb,UAAU;IACV,SAAS;CACV,CAAC;AAEF,6EAA6E;AAC7E,SAAS,MAAM,CAAC,CAAS;IACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACvC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CA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import express from 'express';
2
3
  import type { IWorkflowService } from '@bevel-software/platform-shared';
3
4
  import type { WorkspaceService } from './workspace.service.js';
@@ -21,5 +22,5 @@ import '../auth/auth.middleware.js';
21
22
  * exactly like the lock-aware filesystem the agent writes through. There
22
23
  * is no separate "share" step; save and share are fused.
23
24
  */
24
- export declare function createWorkspaceRoutes(workspaceService: WorkspaceService, authService: AuthService, workflowService: IWorkflowService, eventBus: WorkflowEventBus, accessControl: IAccessControl, kbDirName: string, creatorAccess: ICreatorAccess): express.Router;
25
+ export declare function createWorkspaceRoutes(workspaceService: WorkspaceService, authService: AuthService, workflowService: IWorkflowService, eventBus: WorkflowEventBus, accessControl: IAccessControl, kbDirName: string, creatorAccess: ICreatorAccess, adminAccess: IAdminAccessService): express.Router;
25
26
  //# sourceMappingURL=workspace.routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/workspace.routes.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,4BAA4B,CAAC;AAIpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,gBAAgB,EACjC,QAAQ,EAAE,gBAAgB,EAC1B,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAAC,MAAM,CAq+BhB"}
1
+ {"version":3,"file":"workspace.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/workspace.routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAWlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,4BAA4B,CAAC;AAIpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,gBAAgB,EACjC,QAAQ,EAAE,gBAAgB,EAC1B,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,cAAc,EAC7B,WAAW,EAAE,mBAAmB,GAC/B,OAAO,CAAC,MAAM,CAugChB"}
@@ -1,7 +1,8 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import { IGNORE_FILENAME } from './bevel-ignore.js';
3
4
  import express from 'express';
4
- import { AGENTS_DIR, DATA_DIR, DEFAULT_BRANCH, KNOWLEDGE_BASE_DIR, KNOWLEDGE_DIR, PIPELINES_DIR, SKILLS_DIR, TOOLS_DIR, } from '@bevel-software/platform-shared';
5
+ import { AGENTS_DIR, DATA_DIR, DEFAULT_BRANCH, KNOWLEDGE_BASE_DIR, KNOWLEDGE_DIR, PIPELINES_DIR, GROUPS_DIR, } from '@bevel-software/platform-shared';
5
6
  import { branchForWorkspaceId, FolderTooLargeError } from './workspace.service.js';
6
7
  import { resolveReadableMap, toKbRelative } from '../access/kb-read-filter.js';
7
8
  import { isRolesYamlPath, assertRolesYamlParsable } from '../access/roles-yaml-guard.js';
@@ -23,7 +24,7 @@ const MAX_UPLOAD_BYTES = 50 * 1024 * 1024; // 50 MB
23
24
  * exactly like the lock-aware filesystem the agent writes through. There
24
25
  * is no separate "share" step; save and share are fused.
25
26
  */
26
- export function createWorkspaceRoutes(workspaceService, authService, workflowService, eventBus, accessControl, kbDirName, creatorAccess) {
27
+ export function createWorkspaceRoutes(workspaceService, authService, workflowService, eventBus, accessControl, kbDirName, creatorAccess, adminAccess) {
27
28
  const router = express.Router();
28
29
  function authenticated(req, res) {
29
30
  if (!req.userId) {
@@ -406,20 +407,18 @@ export function createWorkspaceRoutes(workspaceService, authService, workflowSer
406
407
  // The structural top-level folders are always shown as folders, even to
407
408
  // a user who can't read into them. Their existence isn't sensitive
408
409
  // (every KB has them), and keeping them visible lets the explorer render
409
- // its Knowledge/Skills section view instead of collapsing to an empty
410
- // flat tree. `KnowledgeBase/`, `Data/`, `Agents/`, `Pipelines/`,
411
- // `Skills/` + `Tools/` are the current layout; a ROOT-LEVEL `Knowledge/`
412
- // is the legacy pre-split layout's knowledge root (kb-layout.ts calls it
413
- // the neutral bucket) and gets the same treatment so legacy clones don't
414
- // collapse. Only the folders themselves are forced visible — their
415
- // contents stay gated by the verdict above.
410
+ // its Knowledge/Groups section view instead of collapsing to an empty
411
+ // flat tree. A ROOT-LEVEL `Knowledge/` is the legacy pre-split layout's
412
+ // knowledge root (kb-layout.ts calls it the neutral bucket) and gets the
413
+ // same treatment so legacy clones don't collapse. Only the folders
414
+ // themselves are forced visible — their contents stay gated by the
415
+ // verdict above.
416
416
  const structuralRoots = new Set([
417
417
  KNOWLEDGE_BASE_DIR,
418
418
  DATA_DIR,
419
419
  AGENTS_DIR,
420
420
  PIPELINES_DIR,
421
- SKILLS_DIR,
422
- TOOLS_DIR,
421
+ GROUPS_DIR,
423
422
  KNOWLEDGE_DIR,
424
423
  ]);
425
424
  for (const wp of wsRelPaths) {
@@ -427,6 +426,27 @@ export function createWorkspaceRoutes(workspaceService, authService, workflowSer
427
426
  if (rel !== null && structuralRoots.has(rel))
428
427
  verdict.set(wp, true);
429
428
  }
429
+ // `.bevelignore` is ADMIN-ONLY. It is the file that decides what the file
430
+ // tree and the agent view show at all, so it is deployment configuration
431
+ // rather than knowledge — and it sits alone in being visible: its
432
+ // siblings (`.gitignore`, `roles.yaml`, `access.md`, `AGENTS.md`) are
433
+ // already hidden from every reader by the shipped ignore rules. Somebody
434
+ // who cannot act on it gains a puzzle; somebody who can needs to reach it.
435
+ //
436
+ // Read permission is deliberately NOT the lever. Everyone can read it —
437
+ // it has to be readable to be applied — so hiding it is a listing
438
+ // decision, made here, rather than an ACL fiction maintained in a file.
439
+ //
440
+ // Resolved through `AdminAccessService` rather than by asking whether
441
+ // this caller can write `roles.yaml` in THIS workspace: admin is settled
442
+ // on the default branch precisely so that editing `roles.yaml` on your
443
+ // own branch cannot promote you, and the same reasoning applies to
444
+ // anything gated on being an admin.
445
+ const ignoreFiles = wsRelPaths.filter((wp) => path.basename(wp) === IGNORE_FILENAME);
446
+ if (ignoreFiles.length > 0 && !(await adminAccess.isAdmin(userEmail))) {
447
+ for (const wp of ignoreFiles)
448
+ verdict.set(wp, false);
449
+ }
430
450
  return verdict;
431
451
  };
432
452
  }
@@ -503,16 +523,25 @@ export function createWorkspaceRoutes(workspaceService, authService, workflowSer
503
523
  '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
504
524
  '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
505
525
  };
506
- // SVG is active web content (it can carry <script>). Inline view
507
- // already trusts the source (the workspace owns its bytes), but a
508
- // saved-to-disk SVG that's later re-opened in a browser tab would
509
- // execute its scripts under the file:// origin — so when the user
510
- // explicitly downloads, force octet-stream to defang it.
526
+ // SVG is active web content (it can carry <script>), and it is active in
527
+ // BOTH directions: a saved-to-disk SVG re-opened later runs its scripts
528
+ // under the file:// origin, so a download is forced to octet-stream.
511
529
  const downloadMime = ext === '.svg' ? 'application/octet-stream' : (mimeTypes[ext] || 'application/octet-stream');
512
530
  res.setHeader('Content-Type', wantsDownload ? downloadMime : (mimeTypes[ext] || 'application/octet-stream'));
513
531
  // Block MIME-sniffing so a misdeclared file can't be promoted to
514
532
  // active content by the browser.
515
533
  res.setHeader('X-Content-Type-Options', 'nosniff');
534
+ // …and inline is a DOCUMENT the moment somebody opens this URL in a tab
535
+ // directly, where those scripts would run under THIS
536
+ // origin with this user's session — stored XSS for anyone who can write
537
+ // a file into the workspace. `sandbox` drops the document into a unique
538
+ // origin with scripting off. It applies to documents only, so the
539
+ // renderers' fetch → blob → <img> path is untouched, and that path is
540
+ // why the type stays `image/svg+xml`: browsers do not sniff SVG, and an
541
+ // octet-stream blob would simply not render.
542
+ if (!wantsDownload && ext === '.svg') {
543
+ res.setHeader('Content-Security-Policy', 'sandbox');
544
+ }
516
545
  if (wantsDownload) {
517
546
  // RFC 5987 UTF-8 filename encoding so unicode + spaces round-trip;
518
547
  // CR/LF stripped to block header injection via a crafted path.
@@ -770,7 +799,7 @@ export function createWorkspaceRoutes(workspaceService, authService, workflowSer
770
799
  res.status(400).json({ error: 'path query parameter is required' });
771
800
  return;
772
801
  }
773
- const { content } = req.body;
802
+ const { content, ifAbsent } = req.body;
774
803
  if (content === undefined) {
775
804
  res.status(400).json({ error: 'content is required in body' });
776
805
  return;
@@ -794,7 +823,11 @@ export function createWorkspaceRoutes(workspaceService, authService, workflowSer
794
823
  if (plan?.kind === 'seed-access-md')
795
824
  await seedCreatorAccessMd(id, user, plan);
796
825
  const toWrite = plan?.kind === 'frontmatter' ? plan.apply(content) : content;
797
- await withLock(id, user, filePath, () => workspaceService.writeFile(id, filePath, toWrite));
826
+ // `ifAbsent` = exclusive create: the service's `wx` write turns a
827
+ // concurrent or stale create against an existing file into a 409
828
+ // instead of a silent replace. `withLock`'s failure arm releases
829
+ // without committing, so the refusal leaves no trace.
830
+ await withLock(id, user, filePath, () => workspaceService.writeFile(id, filePath, toWrite, { failIfExists: ifAbsent === true }));
798
831
  res.json({ status: 'written' });
799
832
  }
800
833
  catch (err) {