@bevel-software/platform-core-backend 0.25.2 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (733) hide show
  1. package/agent-guide/access-control.md +251 -0
  2. package/agent-guide/conventions.md +35 -0
  3. package/agent-guide/directory-structure.md +145 -0
  4. package/agent-guide/finding-things.md +7 -0
  5. package/agent-guide/html-views.md +83 -0
  6. package/agent-guide/introduction.md +27 -0
  7. package/agent-guide/new-knowledge-base.md +24 -0
  8. package/agent-guide/skills.md +47 -0
  9. package/agent-guide/tool-manuals.md +227 -0
  10. package/agent-guide/where-a-new-file-goes.md +36 -0
  11. package/dist/assets.d.ts +26 -0
  12. package/dist/assets.d.ts.map +1 -1
  13. package/dist/assets.js +35 -2
  14. package/dist/assets.js.map +1 -1
  15. package/dist/core/catalog-revision.d.ts +19 -1
  16. package/dist/core/catalog-revision.d.ts.map +1 -1
  17. package/dist/core/catalog-revision.js +14 -3
  18. package/dist/core/catalog-revision.js.map +1 -1
  19. package/dist/core/core-ports.d.ts +11 -0
  20. package/dist/core/core-ports.d.ts.map +1 -1
  21. package/dist/core/core-ports.js.map +1 -1
  22. package/dist/core/create-core-server.d.ts +5 -0
  23. package/dist/core/create-core-server.d.ts.map +1 -1
  24. package/dist/core/create-core-server.js +65 -3
  25. package/dist/core/create-core-server.js.map +1 -1
  26. package/dist/core/create-core-services.d.ts +35 -0
  27. package/dist/core/create-core-services.d.ts.map +1 -1
  28. package/dist/core/create-core-services.js +114 -12
  29. package/dist/core/create-core-services.js.map +1 -1
  30. package/dist/core/lifecycle.d.ts +16 -1
  31. package/dist/core/lifecycle.d.ts.map +1 -1
  32. package/dist/core/lifecycle.js +18 -1
  33. package/dist/core/lifecycle.js.map +1 -1
  34. package/dist/core-config.d.ts +21 -0
  35. package/dist/core-config.d.ts.map +1 -1
  36. package/dist/core-config.js +22 -1
  37. package/dist/core-config.js.map +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +2 -2
  41. package/dist/index.js.map +1 -1
  42. package/dist/modules/access/access-control.interface.d.ts +17 -0
  43. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  44. package/dist/modules/access/access-control.service.d.ts +2 -0
  45. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  46. package/dist/modules/access/access-control.service.js +27 -0
  47. package/dist/modules/access/access-control.service.js.map +1 -1
  48. package/dist/modules/access/directory-sync-bot.js +1 -1
  49. package/dist/modules/access/directory-sync-bot.js.map +1 -1
  50. package/dist/modules/agent-guide/agent-guide.d.ts +145 -0
  51. package/dist/modules/agent-guide/agent-guide.d.ts.map +1 -0
  52. package/dist/modules/agent-guide/agent-guide.js +199 -0
  53. package/dist/modules/agent-guide/agent-guide.js.map +1 -0
  54. package/dist/modules/agent-guide/agent-guide.tools.d.ts +24 -0
  55. package/dist/modules/agent-guide/agent-guide.tools.d.ts.map +1 -0
  56. package/dist/modules/agent-guide/agent-guide.tools.js +100 -0
  57. package/dist/modules/agent-guide/agent-guide.tools.js.map +1 -0
  58. package/dist/modules/agent-guide/index.d.ts +4 -0
  59. package/dist/modules/agent-guide/index.d.ts.map +1 -0
  60. package/dist/modules/agent-guide/index.js +4 -0
  61. package/dist/modules/agent-guide/index.js.map +1 -0
  62. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +3 -2
  63. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
  64. package/dist/modules/agent-instructions/agent-instructions.routes.js +3 -2
  65. package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
  66. package/dist/modules/agent-instructions/compose.d.ts +14 -6
  67. package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
  68. package/dist/modules/agent-instructions/compose.js +28 -8
  69. package/dist/modules/agent-instructions/compose.js.map +1 -1
  70. package/dist/modules/agent-instructions/index.d.ts +1 -1
  71. package/dist/modules/agent-instructions/index.d.ts.map +1 -1
  72. package/dist/modules/agent-instructions/index.js +1 -1
  73. package/dist/modules/agent-instructions/index.js.map +1 -1
  74. package/dist/modules/agent-instructions/shared-file-rules.d.ts +10 -50
  75. package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -1
  76. package/dist/modules/agent-instructions/shared-file-rules.js +51 -104
  77. package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -1
  78. package/dist/modules/audit/agent-audit.service.d.ts +21 -2
  79. package/dist/modules/audit/agent-audit.service.d.ts.map +1 -1
  80. package/dist/modules/audit/agent-audit.service.js +43 -2
  81. package/dist/modules/audit/agent-audit.service.js.map +1 -1
  82. package/dist/modules/audit/agent-connection.routes.d.ts +34 -0
  83. package/dist/modules/audit/agent-connection.routes.d.ts.map +1 -0
  84. package/dist/modules/audit/agent-connection.routes.js +38 -0
  85. package/dist/modules/audit/agent-connection.routes.js.map +1 -0
  86. package/dist/modules/audit/audit.contract.d.ts +24 -0
  87. package/dist/modules/audit/audit.contract.d.ts.map +1 -1
  88. package/dist/modules/audit/audit.contract.js.map +1 -1
  89. package/dist/modules/audit/index.d.ts +1 -0
  90. package/dist/modules/audit/index.d.ts.map +1 -1
  91. package/dist/modules/audit/index.js +1 -0
  92. package/dist/modules/audit/index.js.map +1 -1
  93. package/dist/modules/auth/account.routes.d.ts.map +1 -1
  94. package/dist/modules/auth/account.routes.js +10 -3
  95. package/dist/modules/auth/account.routes.js.map +1 -1
  96. package/dist/modules/auth/auth.middleware.d.ts +7 -0
  97. package/dist/modules/auth/auth.middleware.d.ts.map +1 -1
  98. package/dist/modules/auth/auth.middleware.js +1 -1
  99. package/dist/modules/auth/auth.middleware.js.map +1 -1
  100. package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
  101. package/dist/modules/code-mode/code-mode.tool.js +11 -3
  102. package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
  103. package/dist/modules/database/core-schema.d.ts +96 -0
  104. package/dist/modules/database/core-schema.d.ts.map +1 -1
  105. package/dist/modules/database/core-schema.js +32 -3
  106. package/dist/modules/database/core-schema.js.map +1 -1
  107. package/dist/modules/embed/account-link.service.d.ts +42 -0
  108. package/dist/modules/embed/account-link.service.d.ts.map +1 -0
  109. package/dist/modules/embed/account-link.service.js +50 -0
  110. package/dist/modules/embed/account-link.service.js.map +1 -0
  111. package/dist/modules/embed/embed-link.d.ts +58 -0
  112. package/dist/modules/embed/embed-link.d.ts.map +1 -0
  113. package/dist/modules/embed/embed-link.js +160 -0
  114. package/dist/modules/embed/embed-link.js.map +1 -0
  115. package/dist/modules/embed/embed.errors.d.ts +30 -0
  116. package/dist/modules/embed/embed.errors.d.ts.map +1 -0
  117. package/dist/modules/embed/embed.errors.js +42 -0
  118. package/dist/modules/embed/embed.errors.js.map +1 -0
  119. package/dist/modules/embed/embed.interface.d.ts +204 -0
  120. package/dist/modules/embed/embed.interface.d.ts.map +1 -0
  121. package/dist/modules/embed/embed.interface.js +2 -0
  122. package/dist/modules/embed/embed.interface.js.map +1 -0
  123. package/dist/modules/embed/embed.routes.d.ts +59 -0
  124. package/dist/modules/embed/embed.routes.d.ts.map +1 -0
  125. package/dist/modules/embed/embed.routes.js +343 -0
  126. package/dist/modules/embed/embed.routes.js.map +1 -0
  127. package/dist/modules/embed/embed.service.d.ts +169 -0
  128. package/dist/modules/embed/embed.service.d.ts.map +1 -0
  129. package/dist/modules/embed/embed.service.js +627 -0
  130. package/dist/modules/embed/embed.service.js.map +1 -0
  131. package/dist/modules/embed/embed.tools.d.ts +51 -0
  132. package/dist/modules/embed/embed.tools.d.ts.map +1 -0
  133. package/dist/modules/embed/embed.tools.js +170 -0
  134. package/dist/modules/embed/embed.tools.js.map +1 -0
  135. package/dist/modules/embed/mcp-app.d.ts +64 -0
  136. package/dist/modules/embed/mcp-app.d.ts.map +1 -0
  137. package/dist/modules/embed/mcp-app.js +147 -0
  138. package/dist/modules/embed/mcp-app.js.map +1 -0
  139. package/dist/modules/embed/mcp-app.routes.d.ts +21 -0
  140. package/dist/modules/embed/mcp-app.routes.d.ts.map +1 -0
  141. package/dist/modules/embed/mcp-app.routes.js +36 -0
  142. package/dist/modules/embed/mcp-app.routes.js.map +1 -0
  143. package/dist/modules/github-app/github-app.connection.d.ts +15 -0
  144. package/dist/modules/github-app/github-app.connection.d.ts.map +1 -1
  145. package/dist/modules/github-app/github-app.connection.js +34 -3
  146. package/dist/modules/github-app/github-app.connection.js.map +1 -1
  147. package/dist/modules/kb-fs/locking-filesystem.d.ts +65 -0
  148. package/dist/modules/kb-fs/locking-filesystem.d.ts.map +1 -1
  149. package/dist/modules/kb-fs/locking-filesystem.js +300 -0
  150. package/dist/modules/kb-fs/locking-filesystem.js.map +1 -1
  151. package/dist/modules/kb-sync/kb-sync.interface.d.ts +5 -0
  152. package/dist/modules/kb-sync/kb-sync.interface.d.ts.map +1 -1
  153. package/dist/modules/kb-sync/kb-sync.service.d.ts.map +1 -1
  154. package/dist/modules/kb-sync/kb-sync.service.js +6 -0
  155. package/dist/modules/kb-sync/kb-sync.service.js.map +1 -1
  156. package/dist/modules/mcp/mcp-auth.middleware.d.ts.map +1 -1
  157. package/dist/modules/mcp/mcp-auth.middleware.js +2 -1
  158. package/dist/modules/mcp/mcp-auth.middleware.js.map +1 -1
  159. package/dist/modules/mcp/mcp.service.d.ts +57 -3
  160. package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
  161. package/dist/modules/mcp/mcp.service.js +177 -24
  162. package/dist/modules/mcp/mcp.service.js.map +1 -1
  163. package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts +24 -0
  164. package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
  165. package/dist/modules/mcp/oauth/bevel-oauth-provider.js +32 -4
  166. package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
  167. package/dist/modules/mcp/tool-schema-guard.d.ts +105 -0
  168. package/dist/modules/mcp/tool-schema-guard.d.ts.map +1 -0
  169. package/dist/modules/mcp/tool-schema-guard.js +171 -0
  170. package/dist/modules/mcp/tool-schema-guard.js.map +1 -0
  171. package/dist/modules/onboarding/onboarding.contract.d.ts +80 -0
  172. package/dist/modules/onboarding/onboarding.contract.d.ts.map +1 -0
  173. package/dist/modules/onboarding/onboarding.contract.js +7 -0
  174. package/dist/modules/onboarding/onboarding.contract.js.map +1 -0
  175. package/dist/modules/onboarding/onboarding.routes.d.ts +18 -0
  176. package/dist/modules/onboarding/onboarding.routes.d.ts.map +1 -0
  177. package/dist/modules/onboarding/onboarding.routes.js +81 -0
  178. package/dist/modules/onboarding/onboarding.routes.js.map +1 -0
  179. package/dist/modules/onboarding/starter-pack.service.d.ts +213 -0
  180. package/dist/modules/onboarding/starter-pack.service.d.ts.map +1 -0
  181. package/dist/modules/onboarding/starter-pack.service.js +492 -0
  182. package/dist/modules/onboarding/starter-pack.service.js.map +1 -0
  183. package/dist/modules/onboarding/starter-packs.d.ts +78 -0
  184. package/dist/modules/onboarding/starter-packs.d.ts.map +1 -0
  185. package/dist/modules/onboarding/starter-packs.js +156 -0
  186. package/dist/modules/onboarding/starter-packs.js.map +1 -0
  187. package/dist/modules/plugins/index.d.ts +1 -1
  188. package/dist/modules/plugins/index.d.ts.map +1 -1
  189. package/dist/modules/plugins/index.js +1 -1
  190. package/dist/modules/plugins/index.js.map +1 -1
  191. package/dist/modules/plugins/plugin-provision.service.d.ts +19 -0
  192. package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
  193. package/dist/modules/plugins/plugin-provision.service.js +18 -1
  194. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  195. package/dist/modules/plugins/plugins.routes.d.ts +0 -36
  196. package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
  197. package/dist/modules/plugins/plugins.routes.js +31 -0
  198. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  199. package/dist/modules/plugins/plugins.tools.d.ts +36 -2
  200. package/dist/modules/plugins/plugins.tools.d.ts.map +1 -1
  201. package/dist/modules/plugins/plugins.tools.js +71 -14
  202. package/dist/modules/plugins/plugins.tools.js.map +1 -1
  203. package/dist/modules/settings/deployment-settings.service.d.ts +34 -7
  204. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
  205. package/dist/modules/settings/deployment-settings.service.js +148 -54
  206. package/dist/modules/settings/deployment-settings.service.js.map +1 -1
  207. package/dist/modules/settings/repository-source.d.ts +1 -0
  208. package/dist/modules/settings/repository-source.d.ts.map +1 -1
  209. package/dist/modules/settings/repository-source.js +3 -3
  210. package/dist/modules/settings/repository-source.js.map +1 -1
  211. package/dist/modules/settings/setup.routes.d.ts.map +1 -1
  212. package/dist/modules/settings/setup.routes.js +3 -6
  213. package/dist/modules/settings/setup.routes.js.map +1 -1
  214. package/dist/modules/skills/skills.tools.d.ts.map +1 -1
  215. package/dist/modules/skills/skills.tools.js +103 -43
  216. package/dist/modules/skills/skills.tools.js.map +1 -1
  217. package/dist/modules/tool-auth/connection-key-rejection.d.ts +10 -1
  218. package/dist/modules/tool-auth/connection-key-rejection.d.ts.map +1 -1
  219. package/dist/modules/tool-auth/connection-key-rejection.js +11 -3
  220. package/dist/modules/tool-auth/connection-key-rejection.js.map +1 -1
  221. package/dist/modules/tool-auth/external-api-key.interface.d.ts +8 -0
  222. package/dist/modules/tool-auth/external-api-key.interface.d.ts.map +1 -1
  223. package/dist/modules/tool-auth/external-api-key.service.d.ts +24 -2
  224. package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
  225. package/dist/modules/tool-auth/external-api-key.service.js +59 -2
  226. package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
  227. package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -1
  228. package/dist/modules/tool-auth/tool-auth.middleware.js +9 -4
  229. package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -1
  230. package/dist/modules/tool-helpers/index.d.ts +28 -1
  231. package/dist/modules/tool-helpers/index.d.ts.map +1 -1
  232. package/dist/modules/tool-helpers/index.js +28 -1
  233. package/dist/modules/tool-helpers/index.js.map +1 -1
  234. package/dist/modules/tool-helpers/route-argument-check.d.ts +10 -0
  235. package/dist/modules/tool-helpers/route-argument-check.d.ts.map +1 -0
  236. package/dist/modules/tool-helpers/route-argument-check.js +132 -0
  237. package/dist/modules/tool-helpers/route-argument-check.js.map +1 -0
  238. package/dist/modules/tool-helpers/route-tool-schemas.d.ts +89 -0
  239. package/dist/modules/tool-helpers/route-tool-schemas.d.ts.map +1 -0
  240. package/dist/modules/tool-helpers/route-tool-schemas.js +113 -0
  241. package/dist/modules/tool-helpers/route-tool-schemas.js.map +1 -0
  242. package/dist/modules/tool-helpers/tool-def.d.ts +71 -0
  243. package/dist/modules/tool-helpers/tool-def.d.ts.map +1 -1
  244. package/dist/modules/tool-helpers/tool-def.js +70 -6
  245. package/dist/modules/tool-helpers/tool-def.js.map +1 -1
  246. package/dist/modules/tool-helpers/tool-handler.d.ts +46 -6
  247. package/dist/modules/tool-helpers/tool-handler.d.ts.map +1 -1
  248. package/dist/modules/tool-helpers/tool-handler.js +157 -8
  249. package/dist/modules/tool-helpers/tool-handler.js.map +1 -1
  250. package/dist/modules/tool-helpers/tool.contract.d.ts +9 -0
  251. package/dist/modules/tool-helpers/tool.contract.d.ts.map +1 -1
  252. package/dist/modules/tool-helpers/tool.contract.js.map +1 -1
  253. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +23 -4
  254. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
  255. package/dist/modules/tool-manuals/tool-manuals.contract.js.map +1 -1
  256. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -0
  257. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  258. package/dist/modules/tool-manuals/tool-manuals.service.js +14 -0
  259. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  260. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +7 -0
  261. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
  262. package/dist/modules/tool-manuals/tool-manuals.tools.js +77 -38
  263. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  264. package/dist/modules/tool-registry/description-length.d.ts +20 -16
  265. package/dist/modules/tool-registry/description-length.d.ts.map +1 -1
  266. package/dist/modules/tool-registry/description-length.js +50 -30
  267. package/dist/modules/tool-registry/description-length.js.map +1 -1
  268. package/dist/modules/tool-registry/guide-first.d.ts +27 -0
  269. package/dist/modules/tool-registry/guide-first.d.ts.map +1 -0
  270. package/dist/modules/tool-registry/guide-first.js +40 -0
  271. package/dist/modules/tool-registry/guide-first.js.map +1 -0
  272. package/dist/modules/tool-registry/tool-registry.d.ts +6 -0
  273. package/dist/modules/tool-registry/tool-registry.d.ts.map +1 -1
  274. package/dist/modules/tool-registry/tool-registry.js +9 -2
  275. package/dist/modules/tool-registry/tool-registry.js.map +1 -1
  276. package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts +449 -0
  277. package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts.map +1 -0
  278. package/dist/modules/workflow/agent-tools/change-request-read-shape.js +481 -0
  279. package/dist/modules/workflow/agent-tools/change-request-read-shape.js.map +1 -0
  280. package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts +126 -0
  281. package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts.map +1 -0
  282. package/dist/modules/workflow/agent-tools/change-request-read.tools.js +611 -0
  283. package/dist/modules/workflow/agent-tools/change-request-read.tools.js.map +1 -0
  284. package/dist/modules/workflow/agent-tools/change-request-summary.d.ts +12 -1
  285. package/dist/modules/workflow/agent-tools/change-request-summary.d.ts.map +1 -1
  286. package/dist/modules/workflow/agent-tools/change-request-summary.js +5 -1
  287. package/dist/modules/workflow/agent-tools/change-request-summary.js.map +1 -1
  288. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +8 -1
  289. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
  290. package/dist/modules/workflow/agent-tools/workflow.tools.js +133 -37
  291. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  292. package/dist/modules/workflow/file-lock.service.d.ts +29 -5
  293. package/dist/modules/workflow/file-lock.service.d.ts.map +1 -1
  294. package/dist/modules/workflow/file-lock.service.js +62 -5
  295. package/dist/modules/workflow/file-lock.service.js.map +1 -1
  296. package/dist/modules/workflow/git/git.service.d.ts +282 -14
  297. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  298. package/dist/modules/workflow/git/git.service.js +627 -126
  299. package/dist/modules/workflow/git/git.service.js.map +1 -1
  300. package/dist/modules/workflow/git/merge-commit.d.ts +73 -0
  301. package/dist/modules/workflow/git/merge-commit.d.ts.map +1 -0
  302. package/dist/modules/workflow/git/merge-commit.js +89 -0
  303. package/dist/modules/workflow/git/merge-commit.js.map +1 -0
  304. package/dist/modules/workflow/git/node-git-runner.d.ts +15 -0
  305. package/dist/modules/workflow/git/node-git-runner.d.ts.map +1 -1
  306. package/dist/modules/workflow/git/node-git-runner.js +78 -6
  307. package/dist/modules/workflow/git/node-git-runner.js.map +1 -1
  308. package/dist/modules/workflow/git/pull-request.service.d.ts +94 -1
  309. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  310. package/dist/modules/workflow/git/pull-request.service.js +332 -37
  311. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  312. package/dist/modules/workflow/pending-commits.service.d.ts +15 -0
  313. package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -1
  314. package/dist/modules/workflow/pending-commits.service.js +25 -1
  315. package/dist/modules/workflow/pending-commits.service.js.map +1 -1
  316. package/dist/modules/workflow/pending-commits.worker.d.ts +6 -1
  317. package/dist/modules/workflow/pending-commits.worker.d.ts.map +1 -1
  318. package/dist/modules/workflow/pending-commits.worker.js +23 -6
  319. package/dist/modules/workflow/pending-commits.worker.js.map +1 -1
  320. package/dist/modules/workflow/recovery-bot.js +1 -1
  321. package/dist/modules/workflow/recovery-bot.js.map +1 -1
  322. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts +35 -0
  323. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
  324. package/dist/modules/workflow/review-workflow/review-workflow.service.js +180 -13
  325. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  326. package/dist/modules/workflow/sanitize-error.d.ts +16 -0
  327. package/dist/modules/workflow/sanitize-error.d.ts.map +1 -1
  328. package/dist/modules/workflow/sanitize-error.js +45 -0
  329. package/dist/modules/workflow/sanitize-error.js.map +1 -1
  330. package/dist/modules/workflow/workflow.routes.d.ts +6 -2
  331. package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
  332. package/dist/modules/workflow/workflow.routes.js +7 -2
  333. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  334. package/dist/modules/workflow/workflow.service.d.ts +187 -15
  335. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  336. package/dist/modules/workflow/workflow.service.js +808 -106
  337. package/dist/modules/workflow/workflow.service.js.map +1 -1
  338. package/dist/modules/workspace/agent-download.builder.d.ts +105 -0
  339. package/dist/modules/workspace/agent-download.builder.d.ts.map +1 -0
  340. package/dist/modules/workspace/agent-download.builder.js +238 -0
  341. package/dist/modules/workspace/agent-download.builder.js.map +1 -0
  342. package/dist/modules/workspace/agent-download.routes.d.ts +77 -0
  343. package/dist/modules/workspace/agent-download.routes.d.ts.map +1 -0
  344. package/dist/modules/workspace/agent-download.routes.js +156 -0
  345. package/dist/modules/workspace/agent-download.routes.js.map +1 -0
  346. package/dist/modules/workspace/agent-download.store.d.ts +225 -0
  347. package/dist/modules/workspace/agent-download.store.d.ts.map +1 -0
  348. package/dist/modules/workspace/agent-download.store.js +423 -0
  349. package/dist/modules/workspace/agent-download.store.js.map +1 -0
  350. package/dist/modules/workspace/agent-upload.store.d.ts +10 -1
  351. package/dist/modules/workspace/agent-upload.store.d.ts.map +1 -1
  352. package/dist/modules/workspace/agent-upload.store.js +16 -6
  353. package/dist/modules/workspace/agent-upload.store.js.map +1 -1
  354. package/dist/modules/workspace/file-readers/raw-mime.d.ts +6 -0
  355. package/dist/modules/workspace/file-readers/raw-mime.d.ts.map +1 -0
  356. package/dist/modules/workspace/file-readers/raw-mime.js +38 -0
  357. package/dist/modules/workspace/file-readers/raw-mime.js.map +1 -0
  358. package/dist/modules/workspace/file-readers/text-reader.d.ts +5 -5
  359. package/dist/modules/workspace/file-readers/text-reader.d.ts.map +1 -1
  360. package/dist/modules/workspace/file-readers/text-reader.js +5 -8
  361. package/dist/modules/workspace/file-readers/text-reader.js.map +1 -1
  362. package/dist/modules/workspace/first-run.d.ts +111 -0
  363. package/dist/modules/workspace/first-run.d.ts.map +1 -0
  364. package/dist/modules/workspace/first-run.js +181 -0
  365. package/dist/modules/workspace/first-run.js.map +1 -0
  366. package/dist/modules/workspace/move-links.d.ts +92 -0
  367. package/dist/modules/workspace/move-links.d.ts.map +1 -0
  368. package/dist/modules/workspace/move-links.js +173 -0
  369. package/dist/modules/workspace/move-links.js.map +1 -0
  370. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  371. package/dist/modules/workspace/startup/steps/seed-tree.js +24 -39
  372. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  373. package/dist/modules/workspace/startup/steps/template-files.step.d.ts +58 -52
  374. package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
  375. package/dist/modules/workspace/startup/steps/template-files.step.js +209 -223
  376. package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
  377. package/dist/modules/workspace/startup/steps/template-source.d.ts +5 -3
  378. package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
  379. package/dist/modules/workspace/startup/steps/template-source.js +5 -3
  380. package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
  381. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  382. package/dist/modules/workspace/workspace.routes.js +63 -22
  383. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  384. package/dist/modules/workspace/workspace.service.d.ts +75 -2
  385. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  386. package/dist/modules/workspace/workspace.service.js +197 -24
  387. package/dist/modules/workspace/workspace.service.js.map +1 -1
  388. package/dist/modules/workspace/workspace.tools.d.ts +68 -1
  389. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  390. package/dist/modules/workspace/workspace.tools.js +642 -71
  391. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  392. package/dist/modules/write-access/write-access.d.ts.map +1 -1
  393. package/dist/modules/write-access/write-access.js +9 -0
  394. package/dist/modules/write-access/write-access.js.map +1 -1
  395. package/dist/shared/domain-errors.d.ts +84 -1
  396. package/dist/shared/domain-errors.d.ts.map +1 -1
  397. package/dist/shared/domain-errors.js +100 -12
  398. package/dist/shared/domain-errors.js.map +1 -1
  399. package/dist/shared/git.contract.d.ts +10 -1
  400. package/dist/shared/git.contract.d.ts.map +1 -1
  401. package/dist/shared/git.contract.js.map +1 -1
  402. package/dist/shared/hidden-tools.d.ts +44 -0
  403. package/dist/shared/hidden-tools.d.ts.map +1 -0
  404. package/dist/shared/hidden-tools.js +13 -0
  405. package/dist/shared/hidden-tools.js.map +1 -0
  406. package/dist/shared/utf8-text.d.ts +15 -0
  407. package/dist/shared/utf8-text.d.ts.map +1 -0
  408. package/dist/shared/utf8-text.js +20 -0
  409. package/dist/shared/utf8-text.js.map +1 -0
  410. package/dist/tenancy/static-tenant-source.d.ts +2 -1
  411. package/dist/tenancy/static-tenant-source.d.ts.map +1 -1
  412. package/dist/tenancy/static-tenant-source.js +9 -2
  413. package/dist/tenancy/static-tenant-source.js.map +1 -1
  414. package/kb-template/.bevelignore +0 -5
  415. package/mcp-app/page.html +349 -0
  416. package/migrations/0017_atlassian_account_links.sql +37 -0
  417. package/migrations/meta/0017_snapshot.json +2396 -0
  418. package/migrations/meta/_journal.json +8 -1
  419. package/package.json +6 -3
  420. package/src/__tests__/kb-layout-config.test.ts +10 -100
  421. package/src/__tests__/packaged-assets-ship.test.ts +66 -0
  422. package/src/assets.ts +38 -2
  423. package/src/core/__tests__/catalog-revision.test.ts +40 -0
  424. package/src/core/__tests__/gated-boot.test.ts +1 -0
  425. package/src/core/__tests__/lifecycle.test.ts +14 -0
  426. package/src/core/catalog-revision.ts +15 -2
  427. package/src/core/core-ports.ts +11 -0
  428. package/src/core/create-core-server.ts +78 -3
  429. package/src/core/create-core-services.ts +168 -10
  430. package/src/core/lifecycle.ts +28 -2
  431. package/src/core-config.ts +24 -1
  432. package/src/index.ts +2 -2
  433. package/src/modules/access/__tests__/access-control.atref-batch.test.ts +58 -0
  434. package/src/modules/access/__tests__/access-control.platform-restore.test.ts +8 -7
  435. package/src/modules/access/__tests__/access-control.service.test.ts +19 -0
  436. package/src/modules/access/__tests__/access-personal-plugin.test.ts +1 -18
  437. package/src/modules/access/access-control.interface.ts +28 -0
  438. package/src/modules/access/access-control.service.ts +37 -0
  439. package/src/modules/access/directory-sync-bot.ts +1 -1
  440. package/src/modules/agent-guide/__tests__/agent-guide.test.ts +386 -0
  441. package/src/modules/agent-guide/__tests__/agent-guide.tools.test.ts +207 -0
  442. package/src/modules/agent-guide/agent-guide.tools.ts +122 -0
  443. package/src/modules/agent-guide/agent-guide.ts +300 -0
  444. package/src/modules/agent-guide/index.ts +22 -0
  445. package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +39 -118
  446. package/src/modules/agent-instructions/agent-instructions.routes.ts +3 -2
  447. package/src/modules/agent-instructions/compose.ts +26 -8
  448. package/src/modules/agent-instructions/index.ts +0 -3
  449. package/src/modules/agent-instructions/shared-file-rules.ts +50 -112
  450. package/src/modules/audit/__tests__/agent-audit.service.test.ts +64 -4
  451. package/src/modules/audit/__tests__/agent-connection.routes.test.ts +102 -0
  452. package/src/modules/audit/agent-audit.service.ts +58 -3
  453. package/src/modules/audit/agent-connection.routes.ts +56 -0
  454. package/src/modules/audit/audit.contract.ts +26 -0
  455. package/src/modules/audit/index.ts +1 -0
  456. package/src/modules/auth/__tests__/account.routes.test.ts +5 -3
  457. package/src/modules/auth/account.routes.ts +10 -3
  458. package/src/modules/auth/auth.middleware.ts +1 -1
  459. package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +18 -2
  460. package/src/modules/code-mode/code-mode.tool.ts +13 -2
  461. package/src/modules/database/core-schema.ts +33 -3
  462. package/src/modules/embed/__tests__/account-links.migration.test.ts +98 -0
  463. package/src/modules/embed/__tests__/embed-link.test.ts +122 -0
  464. package/src/modules/embed/__tests__/embed.routes.test.ts +362 -0
  465. package/src/modules/embed/__tests__/embed.service.lock.test.ts +193 -0
  466. package/src/modules/embed/__tests__/embed.service.test.ts +805 -0
  467. package/src/modules/embed/__tests__/embed.tools.test.ts +304 -0
  468. package/src/modules/embed/__tests__/mcp-app.test.ts +207 -0
  469. package/src/modules/embed/account-link.service.ts +76 -0
  470. package/src/modules/embed/embed-link.ts +180 -0
  471. package/src/modules/embed/embed.errors.ts +43 -0
  472. package/src/modules/embed/embed.interface.ts +203 -0
  473. package/src/modules/embed/embed.routes.ts +363 -0
  474. package/src/modules/embed/embed.service.ts +705 -0
  475. package/src/modules/embed/embed.tools.ts +206 -0
  476. package/src/modules/embed/mcp-app.routes.ts +41 -0
  477. package/src/modules/embed/mcp-app.ts +173 -0
  478. package/src/modules/github-app/__tests__/github-app.test.ts +76 -0
  479. package/src/modules/github-app/github-app.connection.ts +38 -4
  480. package/src/modules/kb-fs/__tests__/move-with-edits.test.ts +304 -0
  481. package/src/modules/kb-fs/locking-filesystem.ts +287 -0
  482. package/src/modules/kb-sync/__tests__/kb-sync.service.test.ts +35 -0
  483. package/src/modules/kb-sync/kb-sync.interface.ts +2 -0
  484. package/src/modules/kb-sync/kb-sync.service.ts +6 -0
  485. package/src/modules/mcp/__tests__/bevel-oauth-provider.test.ts +68 -11
  486. package/src/modules/mcp/__tests__/fake-downstream-mcp-server.ts +14 -3
  487. package/src/modules/mcp/__tests__/mcp-proxy-helpers.test.ts +37 -2
  488. package/src/modules/mcp/__tests__/mcp.app.e2e.test.ts +200 -0
  489. package/src/modules/mcp/__tests__/mcp.e2e.test.ts +252 -0
  490. package/src/modules/mcp/__tests__/mcp.service.test.ts +42 -24
  491. package/src/modules/mcp/__tests__/tool-call-interface.e2e.test.ts +499 -0
  492. package/src/modules/mcp/__tests__/tool-schema-guard.test.ts +266 -0
  493. package/src/modules/mcp/mcp-auth.middleware.ts +2 -1
  494. package/src/modules/mcp/mcp.service.ts +218 -31
  495. package/src/modules/mcp/oauth/bevel-oauth-provider.ts +42 -4
  496. package/src/modules/mcp/tool-schema-guard.ts +196 -0
  497. package/src/modules/onboarding/__tests__/onboarding.routes.test.ts +163 -0
  498. package/src/modules/onboarding/__tests__/starter-pack.service.test.ts +635 -0
  499. package/src/modules/onboarding/__tests__/starter-packs.test.ts +169 -0
  500. package/src/modules/onboarding/onboarding.contract.ts +85 -0
  501. package/src/modules/onboarding/onboarding.routes.ts +85 -0
  502. package/src/modules/onboarding/starter-pack.service.ts +580 -0
  503. package/src/modules/onboarding/starter-packs.ts +182 -0
  504. package/src/modules/plugins/__tests__/plugins.tools.test.ts +177 -4
  505. package/src/modules/plugins/index.ts +1 -0
  506. package/src/modules/plugins/plugin-provision.service.ts +22 -1
  507. package/src/modules/plugins/plugins.routes.ts +29 -0
  508. package/src/modules/plugins/plugins.tools.ts +75 -15
  509. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +176 -56
  510. package/src/modules/settings/__tests__/repository-source.test.ts +9 -0
  511. package/src/modules/settings/deployment-settings.service.ts +144 -55
  512. package/src/modules/settings/repository-source.ts +4 -4
  513. package/src/modules/settings/setup.routes.ts +3 -6
  514. package/src/modules/skills/__tests__/skills.tools.description.test.ts +95 -0
  515. package/src/modules/skills/skills.tools.ts +112 -46
  516. package/src/modules/tool-auth/__tests__/connection-key-rejection.test.ts +32 -0
  517. package/src/modules/tool-auth/__tests__/external-api-key.service.test.ts +65 -0
  518. package/src/modules/tool-auth/connection-key-rejection.ts +13 -3
  519. package/src/modules/tool-auth/external-api-key.interface.ts +9 -0
  520. package/src/modules/tool-auth/external-api-key.service.ts +61 -4
  521. package/src/modules/tool-auth/tool-auth.middleware.ts +13 -4
  522. package/src/modules/tool-helpers/__tests__/branch-declaration.test.ts +502 -0
  523. package/src/modules/tool-helpers/__tests__/route-argument-check.test.ts +337 -0
  524. package/src/modules/tool-helpers/index.ts +34 -1
  525. package/src/modules/tool-helpers/route-argument-check.ts +149 -0
  526. package/src/modules/tool-helpers/route-tool-schemas.ts +171 -0
  527. package/src/modules/tool-helpers/tool-def.ts +132 -7
  528. package/src/modules/tool-helpers/tool-handler.ts +196 -8
  529. package/src/modules/tool-helpers/tool.contract.ts +9 -0
  530. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +57 -0
  531. package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +73 -4
  532. package/src/modules/tool-manuals/tool-manuals.contract.ts +24 -4
  533. package/src/modules/tool-manuals/tool-manuals.service.ts +17 -0
  534. package/src/modules/tool-manuals/tool-manuals.tools.ts +86 -38
  535. package/src/modules/tool-registry/__tests__/own-tool-schemas.test.ts +173 -0
  536. package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +81 -66
  537. package/src/modules/tool-registry/description-length.ts +57 -32
  538. package/src/modules/tool-registry/guide-first.ts +41 -0
  539. package/src/modules/tool-registry/tool-registry.ts +9 -2
  540. package/src/modules/workflow/__tests__/apply-failure.test.ts +6 -1
  541. package/src/modules/workflow/__tests__/file-lock.service.deletion-gate.test.ts +104 -0
  542. package/src/modules/workflow/__tests__/pending-commits.repository-replaced.test.ts +66 -0
  543. package/src/modules/workflow/__tests__/pending-commits.worker.test.ts +31 -2
  544. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +110 -6
  545. package/src/modules/workflow/__tests__/sanitize-error.test.ts +89 -1
  546. package/src/modules/workflow/__tests__/workflow.routes.push-refused.test.ts +202 -0
  547. package/src/modules/workflow/__tests__/workflow.service.branch-in-use.test.ts +6 -6
  548. package/src/modules/workflow/__tests__/workflow.service.delete-branch.test.ts +1026 -0
  549. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +468 -10
  550. package/src/modules/workflow/__tests__/workflow.service.folder-proposals.test.ts +4 -0
  551. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +5 -4
  552. package/src/modules/workflow/__tests__/workflow.service.update-from-target.test.ts +54 -2
  553. package/src/modules/workflow/agent-tools/__tests__/change-request-read-shape.test.ts +705 -0
  554. package/src/modules/workflow/agent-tools/__tests__/change-request-read.tools.test.ts +1554 -0
  555. package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +150 -4
  556. package/src/modules/workflow/agent-tools/change-request-read-shape.ts +712 -0
  557. package/src/modules/workflow/agent-tools/change-request-read.tools.ts +759 -0
  558. package/src/modules/workflow/agent-tools/change-request-summary.ts +5 -1
  559. package/src/modules/workflow/agent-tools/workflow.tools.ts +137 -35
  560. package/src/modules/workflow/file-lock.service.ts +67 -5
  561. package/src/modules/workflow/git/__tests__/git.service.appliedChange.test.ts +285 -0
  562. package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +124 -0
  563. package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +164 -0
  564. package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +334 -0
  565. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +48 -1
  566. package/src/modules/workflow/git/__tests__/node-git-runner.test.ts +231 -2
  567. package/src/modules/workflow/git/__tests__/pull-request.service.list-fetch.test.ts +72 -2
  568. package/src/modules/workflow/git/__tests__/pull-request.service.placeholder.test.ts +24 -2
  569. package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +620 -1
  570. package/src/modules/workflow/git/git.service.ts +714 -133
  571. package/src/modules/workflow/git/merge-commit.ts +88 -0
  572. package/src/modules/workflow/git/node-git-runner.ts +82 -7
  573. package/src/modules/workflow/git/pull-request.service.ts +380 -54
  574. package/src/modules/workflow/pending-commits.service.ts +29 -1
  575. package/src/modules/workflow/pending-commits.worker.ts +24 -6
  576. package/src/modules/workflow/recovery-bot.ts +1 -1
  577. package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +7 -1
  578. package/src/modules/workflow/review-workflow/__tests__/merge-records-own-commit.test.ts +407 -0
  579. package/src/modules/workflow/review-workflow/review-workflow.service.ts +191 -12
  580. package/src/modules/workflow/sanitize-error.ts +50 -0
  581. package/src/modules/workflow/workflow.routes.ts +7 -2
  582. package/src/modules/workflow/workflow.service.ts +886 -112
  583. package/src/modules/workspace/__tests__/agent-downloads.test.ts +823 -0
  584. package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +4 -3
  585. package/src/modules/workspace/__tests__/first-run.test.ts +234 -0
  586. package/src/modules/workspace/__tests__/git-internals.security.test.ts +5 -2
  587. package/src/modules/workspace/__tests__/md-links.test.ts +353 -0
  588. package/src/modules/workspace/__tests__/move-links.test.ts +261 -0
  589. package/src/modules/workspace/__tests__/rest-tool-arguments.test.ts +219 -0
  590. package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +3 -0
  591. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +102 -0
  592. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +52 -5
  593. package/src/modules/workspace/__tests__/workspace.routes.folder-zip-access.test.ts +190 -0
  594. package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +21 -10
  595. package/src/modules/workspace/__tests__/workspace.service.forget-clone-races.test.ts +8 -4
  596. package/src/modules/workspace/__tests__/workspace.service.test.ts +50 -8
  597. package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +33 -55
  598. package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +44 -1
  599. package/src/modules/workspace/__tests__/workspace.tools.test.ts +664 -34
  600. package/src/modules/workspace/agent-download.builder.ts +308 -0
  601. package/src/modules/workspace/agent-download.routes.ts +183 -0
  602. package/src/modules/workspace/agent-download.store.ts +533 -0
  603. package/src/modules/workspace/agent-upload.store.ts +23 -7
  604. package/src/modules/workspace/file-readers/raw-mime.ts +40 -0
  605. package/src/modules/workspace/file-readers/text-reader.ts +5 -8
  606. package/src/modules/workspace/first-run.ts +222 -0
  607. package/src/modules/workspace/move-links.ts +237 -0
  608. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +191 -489
  609. package/src/modules/workspace/startup/steps/seed-tree.ts +23 -38
  610. package/src/modules/workspace/startup/steps/template-files.step.ts +217 -249
  611. package/src/modules/workspace/startup/steps/template-source.ts +5 -3
  612. package/src/modules/workspace/workspace.routes.ts +64 -22
  613. package/src/modules/workspace/workspace.service.ts +202 -25
  614. package/src/modules/workspace/workspace.tools.ts +707 -68
  615. package/src/modules/write-access/__tests__/write-access.test.ts +13 -0
  616. package/src/modules/write-access/write-access.ts +9 -0
  617. package/src/shared/domain-errors.ts +123 -11
  618. package/src/shared/git.contract.ts +8 -1
  619. package/src/shared/hidden-tools.ts +45 -0
  620. package/src/shared/utf8-text.ts +21 -0
  621. package/src/tenancy/__tests__/static-tenant-source.test.ts +1 -0
  622. package/src/tenancy/static-tenant-source.ts +10 -2
  623. package/starter-packs/README.md +103 -0
  624. package/starter-packs/engineering/KnowledgeBase/About us.md +9 -0
  625. package/starter-packs/engineering/KnowledgeBase/Architecture.md +9 -0
  626. package/starter-packs/engineering/KnowledgeBase/Glossary.md +9 -0
  627. package/starter-packs/engineering/KnowledgeBase/How we ship.md +9 -0
  628. package/starter-packs/engineering/Plugins/engineering-starter/LICENSE +21 -0
  629. package/starter-packs/engineering/Plugins/engineering-starter/SOURCE.md +20 -0
  630. package/starter-packs/engineering/Plugins/engineering-starter/access.md +19 -0
  631. package/starter-packs/engineering/Plugins/engineering-starter/plugin.json +10 -0
  632. package/starter-packs/engineering/Plugins/engineering-starter/skills/office-hours/SKILL.md +171 -0
  633. package/starter-packs/engineering/Plugins/engineering-starter/skills/office-hours/sections/phase-2a-startup-diagnostic.md +157 -0
  634. package/starter-packs/engineering/Plugins/engineering-starter/skills/office-hours/sections/phase-2b-builder-brainstorm.md +39 -0
  635. package/starter-packs/engineering/Plugins/engineering-starter/skills/plan-ceo-review/SKILL.md +144 -0
  636. package/starter-packs/engineering/Plugins/engineering-starter/skills/plan-eng-review/SKILL.md +144 -0
  637. package/starter-packs/engineering/Plugins/engineering-starter/skills/review/SKILL.md +80 -0
  638. package/starter-packs/engineering/Plugins/engineering-starter/skills/review/checklist.md +184 -0
  639. package/starter-packs/engineering/pack.yaml +11 -0
  640. package/starter-packs/general/KnowledgeBase/About us.md +9 -0
  641. package/starter-packs/general/KnowledgeBase/Glossary.md +9 -0
  642. package/starter-packs/general/KnowledgeBase/How we work.md +9 -0
  643. package/starter-packs/general/Plugins/general-starter/LICENSE +202 -0
  644. package/starter-packs/general/Plugins/general-starter/SOURCE.md +10 -0
  645. package/starter-packs/general/Plugins/general-starter/access.md +19 -0
  646. package/starter-packs/general/Plugins/general-starter/plugin.json +10 -0
  647. package/starter-packs/general/Plugins/general-starter/skills/memory-management/SKILL.md +332 -0
  648. package/starter-packs/general/Plugins/general-starter/skills/productivity-start/SKILL.md +163 -0
  649. package/starter-packs/general/Plugins/general-starter/skills/productivity-update/SKILL.md +167 -0
  650. package/starter-packs/general/Plugins/general-starter/skills/task-management/SKILL.md +83 -0
  651. package/starter-packs/general/pack.yaml +10 -0
  652. package/starter-packs/operations/KnowledgeBase/Glossary.md +9 -0
  653. package/starter-packs/operations/KnowledgeBase/How we work.md +9 -0
  654. package/starter-packs/operations/KnowledgeBase/Processes.md +9 -0
  655. package/starter-packs/operations/KnowledgeBase/Tools we use.md +9 -0
  656. package/starter-packs/operations/KnowledgeBase/Vendors.md +9 -0
  657. package/starter-packs/operations/Plugins/operations-starter/LICENSE +202 -0
  658. package/starter-packs/operations/Plugins/operations-starter/SOURCE.md +10 -0
  659. package/starter-packs/operations/Plugins/operations-starter/access.md +19 -0
  660. package/starter-packs/operations/Plugins/operations-starter/plugin.json +10 -0
  661. package/starter-packs/operations/Plugins/operations-starter/skills/capacity-plan/SKILL.md +111 -0
  662. package/starter-packs/operations/Plugins/operations-starter/skills/change-request/SKILL.md +119 -0
  663. package/starter-packs/operations/Plugins/operations-starter/skills/compliance-tracking/SKILL.md +44 -0
  664. package/starter-packs/operations/Plugins/operations-starter/skills/process-doc/SKILL.md +80 -0
  665. package/starter-packs/operations/Plugins/operations-starter/skills/process-optimization/SKILL.md +39 -0
  666. package/starter-packs/operations/Plugins/operations-starter/skills/risk-assessment/SKILL.md +40 -0
  667. package/starter-packs/operations/Plugins/operations-starter/skills/runbook/SKILL.md +85 -0
  668. package/starter-packs/operations/Plugins/operations-starter/skills/status-report/SKILL.md +75 -0
  669. package/starter-packs/operations/Plugins/operations-starter/skills/vendor-review/SKILL.md +102 -0
  670. package/starter-packs/operations/pack.yaml +12 -0
  671. package/starter-packs/sales/KnowledgeBase/About us.md +9 -0
  672. package/starter-packs/sales/KnowledgeBase/Customers.md +9 -0
  673. package/starter-packs/sales/KnowledgeBase/Glossary.md +9 -0
  674. package/starter-packs/sales/KnowledgeBase/How we sell.md +9 -0
  675. package/starter-packs/sales/KnowledgeBase/Objections.md +9 -0
  676. package/starter-packs/sales/KnowledgeBase/Pricing.md +9 -0
  677. package/starter-packs/sales/Plugins/sales-starter/LICENSE +202 -0
  678. package/starter-packs/sales/Plugins/sales-starter/SOURCE.md +10 -0
  679. package/starter-packs/sales/Plugins/sales-starter/access.md +19 -0
  680. package/starter-packs/sales/Plugins/sales-starter/plugin.json +10 -0
  681. package/starter-packs/sales/Plugins/sales-starter/skills/account-context/SKILL.md +94 -0
  682. package/starter-packs/sales/Plugins/sales-starter/skills/account-plan/SKILL.md +95 -0
  683. package/starter-packs/sales/Plugins/sales-starter/skills/account-research/SKILL.md +99 -0
  684. package/starter-packs/sales/Plugins/sales-starter/skills/account-tiering/SKILL.md +101 -0
  685. package/starter-packs/sales/Plugins/sales-starter/skills/call-prep/SKILL.md +111 -0
  686. package/starter-packs/sales/Plugins/sales-starter/skills/call-summary/SKILL.md +111 -0
  687. package/starter-packs/sales/Plugins/sales-starter/skills/close-plan/SKILL.md +106 -0
  688. package/starter-packs/sales/Plugins/sales-starter/skills/competitive-intelligence/SKILL.md +102 -0
  689. package/starter-packs/sales/Plugins/sales-starter/skills/create-an-asset/SKILL.md +105 -0
  690. package/starter-packs/sales/Plugins/sales-starter/skills/crm-hygiene-check/SKILL.md +103 -0
  691. package/starter-packs/sales/Plugins/sales-starter/skills/customer-health/SKILL.md +108 -0
  692. package/starter-packs/sales/Plugins/sales-starter/skills/customer-voice/SKILL.md +94 -0
  693. package/starter-packs/sales/Plugins/sales-starter/skills/daily-briefing/SKILL.md +61 -0
  694. package/starter-packs/sales/Plugins/sales-starter/skills/deal-advance-gap/SKILL.md +102 -0
  695. package/starter-packs/sales/Plugins/sales-starter/skills/deal-review/SKILL.md +105 -0
  696. package/starter-packs/sales/Plugins/sales-starter/skills/deal-signals/SKILL.md +96 -0
  697. package/starter-packs/sales/Plugins/sales-starter/skills/deal-slip-scenario/SKILL.md +104 -0
  698. package/starter-packs/sales/Plugins/sales-starter/skills/draft-outreach/SKILL.md +116 -0
  699. package/starter-packs/sales/Plugins/sales-starter/skills/end-of-day/SKILL.md +114 -0
  700. package/starter-packs/sales/Plugins/sales-starter/skills/expansion-whitespace/SKILL.md +97 -0
  701. package/starter-packs/sales/Plugins/sales-starter/skills/forecast/SKILL.md +100 -0
  702. package/starter-packs/sales/Plugins/sales-starter/skills/handle-objection/SKILL.md +93 -0
  703. package/starter-packs/sales/Plugins/sales-starter/skills/inbox-sweep/SKILL.md +114 -0
  704. package/starter-packs/sales/Plugins/sales-starter/skills/lead-triage/SKILL.md +106 -0
  705. package/starter-packs/sales/Plugins/sales-starter/skills/log-activity/SKILL.md +111 -0
  706. package/starter-packs/sales/Plugins/sales-starter/skills/pipeline-review/SKILL.md +97 -0
  707. package/starter-packs/sales/Plugins/sales-starter/skills/renewal-radar/SKILL.md +95 -0
  708. package/starter-packs/sales/Plugins/sales-starter/skills/rep-context/SKILL.md +90 -0
  709. package/starter-packs/sales/Plugins/sales-starter/skills/route-lead/SKILL.md +111 -0
  710. package/starter-packs/sales/Plugins/sales-starter/skills/sales-setup/SKILL.md +200 -0
  711. package/starter-packs/sales/Plugins/sales-starter/skills/schedule-meeting/SKILL.md +99 -0
  712. package/starter-packs/sales/Plugins/sales-starter/skills/stakeholder-map/SKILL.md +107 -0
  713. package/starter-packs/sales/Plugins/sales-starter/skills/team-pipeline/SKILL.md +105 -0
  714. package/starter-packs/sales/Plugins/sales-starter/skills/update-opportunity/SKILL.md +112 -0
  715. package/starter-packs/sales/Plugins/sales-starter/skills/weekly-wrap/SKILL.md +90 -0
  716. package/starter-packs/sales/Plugins/sales-starter/skills/win-loss-review/SKILL.md +88 -0
  717. package/starter-packs/sales/pack.yaml +13 -0
  718. package/starter-packs/support/KnowledgeBase/Escalations.md +9 -0
  719. package/starter-packs/support/KnowledgeBase/Glossary.md +9 -0
  720. package/starter-packs/support/KnowledgeBase/Known issues.md +9 -0
  721. package/starter-packs/support/KnowledgeBase/Products.md +9 -0
  722. package/starter-packs/support/KnowledgeBase/Tone of voice.md +9 -0
  723. package/starter-packs/support/Plugins/support-starter/LICENSE +202 -0
  724. package/starter-packs/support/Plugins/support-starter/SOURCE.md +10 -0
  725. package/starter-packs/support/Plugins/support-starter/access.md +19 -0
  726. package/starter-packs/support/Plugins/support-starter/plugin.json +10 -0
  727. package/starter-packs/support/Plugins/support-starter/skills/customer-escalation/SKILL.md +246 -0
  728. package/starter-packs/support/Plugins/support-starter/skills/customer-research/SKILL.md +250 -0
  729. package/starter-packs/support/Plugins/support-starter/skills/draft-response/SKILL.md +416 -0
  730. package/starter-packs/support/Plugins/support-starter/skills/kb-article/SKILL.md +350 -0
  731. package/starter-packs/support/Plugins/support-starter/skills/ticket-triage/SKILL.md +273 -0
  732. package/starter-packs/support/pack.yaml +12 -0
  733. package/kb-template/AGENTS.md +0 -730
@@ -0,0 +1,481 @@
1
+ /**
2
+ * The mapping from Hexis's change-request types to the shapes the five agent
3
+ * read tools answer in.
4
+ *
5
+ * The tools are named and shaped after GitHub's pull-request API — one tool per
6
+ * GitHub endpoint, the same filters, the same paging — but they SPEAK HEXIS
7
+ * (decision by Razvan, 2026-10-02, on the review of PR #347). An agent opens a
8
+ * change request with `open_change_request` and reads it back with these five;
9
+ * answering the first in Hexis's words and the second in GitHub's would make
10
+ * one request two vocabularies. So every field these answers share with
11
+ * `open_change_request`'s summary takes that summary's name — `url`, `number`,
12
+ * `title`, `state`, `sourceBranch`, `targetBranch`, `approvals`,
13
+ * `mergeBlockedReasons`, `files[].path`, `files[].change` — and the rest follow
14
+ * the same style (camelCase, Hexis's own words for Hexis's own facts).
15
+ *
16
+ * What that changed, against GitHub, and why each is the better answer here:
17
+ *
18
+ * - **State is Hexis's own.** GitHub has two states and a `merged` flag;
19
+ * Hexis has three — `open`, `merged`, `closed` — and reports them. A merged
20
+ * request is `state: "merged"`, not `closed` with `merged: true`: the flag
21
+ * exists on GitHub only because its model has nowhere else to put the fact,
22
+ * and an agent reading `state` should not have to read a second field to
23
+ * learn whether the change landed.
24
+ * - **One name per path.** GitHub names a pull-request file's path `filename`
25
+ * and a review comment's `path`; mirroring that inconsistency was the point
26
+ * while these tools wore GitHub's names, and is now just a trap. Every path
27
+ * in every answer is `path`, and a moved file's old name is `previousPath`,
28
+ * as `open_change_request` names them.
29
+ * - **A file's kind of change** is `change` — `added` / `changed` / `deleted`
30
+ * / `moved`, from the very function `open_change_request` uses
31
+ * ({@link changeKindOf}), not git's seven-way `status`. One request, one
32
+ * spelling of what happened to a file.
33
+ * - **Approvals are per FILE**, not per review submission, because that is
34
+ * what Hexis records. A reviewer's approvals at one staleness are gathered
35
+ * into one entry naming the files, which is as close to a GitHub review as
36
+ * Hexis's model honestly gets.
37
+ * - **`stale`, not `DISMISSED`.** Hexis's word for an approval a later push
38
+ * invalidated is `isStale`; a review entry reports `stale: true` rather
39
+ * than borrowing GitHub's review state.
40
+ * - **A reply names its parent `parentId`**, which is the argument
41
+ * `post_change_request_comment` takes to create one. Reading a comment and
42
+ * replying to it use the same word for the same thing.
43
+ *
44
+ * The tools' INPUTS are untouched and stay GitHub's (`state`, `head`, `base`,
45
+ * `author`, `per_page`, `page`, `include`): the ticket pins them by name, and
46
+ * they are the one part of the surface where matching GitHub's spelling helps —
47
+ * an agent that knows GitHub's list filters can use these without reading the
48
+ * schema. Only the ANSWERS are Hexis's.
49
+ *
50
+ * Pure, and deliberately so: every judgement these tools make about what a
51
+ * caller may see is either an access lookup (which belongs to the service) or
52
+ * one of the functions below (which belongs to a test that can read it). The
53
+ * tools file does the IO and calls in here for every decision.
54
+ */
55
+ import { canonicalEmail, hashEmail } from '../../../shared/email-identity.js';
56
+ import { changeKindOf } from './change-request-summary.js';
57
+ /** What the app says in place of an apply-failure reason the caller may not read. */
58
+ export const APPLY_FAILURE_REASON_WITHHELD = 'The reason names files you do not have access to read.';
59
+ export const PER_PAGE_DEFAULT = 30;
60
+ export const PER_PAGE_MAX = 100;
61
+ /**
62
+ * GitHub's `per_page` (default 30, at most 100) and `page` (from 1), read off
63
+ * whatever the caller sent. A value out of range is clamped rather than
64
+ * refused, because a tool call that asks for 500 wants as many as it can have.
65
+ */
66
+ export function pagingOf(args) {
67
+ const rawPer = typeof args.per_page === 'number' ? Math.trunc(args.per_page) : PER_PAGE_DEFAULT;
68
+ const rawPage = typeof args.page === 'number' ? Math.trunc(args.page) : 1;
69
+ return {
70
+ perPage: Math.min(PER_PAGE_MAX, Math.max(1, Number.isFinite(rawPer) ? rawPer : PER_PAGE_DEFAULT)),
71
+ page: Math.max(1, Number.isFinite(rawPage) ? rawPage : 1),
72
+ };
73
+ }
74
+ /**
75
+ * One page out of an already-filtered list. Paging runs AFTER the access
76
+ * filter, always: a page sliced before it would say by its own short length
77
+ * how many entries were withheld, which is the count's job to say and nobody
78
+ * else's.
79
+ */
80
+ export function pageOf(all, perPage, page) {
81
+ const start = (page - 1) * perPage;
82
+ return {
83
+ items: all.slice(start, start + perPage),
84
+ totalCount: all.length,
85
+ page,
86
+ perPage,
87
+ hasNextPage: start + perPage < all.length,
88
+ };
89
+ }
90
+ /**
91
+ * The Hexis states the `state` FILTER selects. The filter keeps GitHub's three
92
+ * words because the ticket names them, and `closed` there means "not open" —
93
+ * which over Hexis's states is `closed` (declined) and `merged` alike. The
94
+ * ANSWER still reports which of the two a request is.
95
+ */
96
+ export function statesFor(filter) {
97
+ if (filter === 'open')
98
+ return ['open'];
99
+ if (filter === 'closed')
100
+ return ['closed', 'merged'];
101
+ return ['open', 'closed', 'merged'];
102
+ }
103
+ /** The request's author: a hash-derived login, never an email. */
104
+ export function crAuthor(cr) {
105
+ const name = cr.appAuthor?.name ?? cr.author.name;
106
+ return { login: cr.author.login, ...(name ? { name } : {}) };
107
+ }
108
+ /**
109
+ * Whether `needle` names this request's author — an email (compared as the
110
+ * author hash, since the request stores no raw address) or a login. Mirrors
111
+ * `listPrsAuthoredBy`, so the tool's `author` filter and the app's "mine" list
112
+ * agree on who wrote what.
113
+ */
114
+ export function matchesAuthor(cr, needle) {
115
+ const wanted = canonicalEmail(needle);
116
+ if (!wanted)
117
+ return false;
118
+ if (wanted.includes('@'))
119
+ return !!(cr.authorId && cr.authorId === hashEmail(wanted));
120
+ return cr.author.login.toLowerCase() === wanted;
121
+ }
122
+ /** Whether `viewerEmail` opened this request. */
123
+ export function isAuthor(cr, viewerEmail) {
124
+ return !!(viewerEmail && cr.authorId && cr.authorId === hashEmail(viewerEmail));
125
+ }
126
+ /**
127
+ * Whether the caller may SEE a change request at all.
128
+ *
129
+ * Readable files, or authorship. Nothing else: a request every file of which
130
+ * is closed to the caller tells them, by existing, that somebody proposed a
131
+ * change to something they may not look at, and requirement 7 answers that
132
+ * with a 404 rather than an empty shell.
133
+ *
134
+ * A request with NO files resolved is not visible to a non-author either, and
135
+ * that is deliberate rather than an oversight: an empty file set is what both a
136
+ * request that genuinely changes nothing and a request whose diff could not be
137
+ * computed look like, and the two are indistinguishable from here. So an empty
138
+ * set proves no read access — the same rule `scopeApplyFailures` applies to the
139
+ * same question on the same lists.
140
+ *
141
+ * Since the 2026-10-02 decision this is a far smaller class than it was: a
142
+ * MERGED request's files are recovered from its merge commit, so being applied
143
+ * no longer hides a request from everyone but its author. What is left is a
144
+ * DECLINED request (no merge commit was ever written, and its branch is gone)
145
+ * and a clone that cannot resolve the commit at all.
146
+ */
147
+ export function maySeeChangeRequest(input) {
148
+ return input.isAuthor || input.readableFiles > 0;
149
+ }
150
+ /** A list row. `readable` / `withheld` come from the access filter. */
151
+ export function toCrSummary(cr, counts) {
152
+ return {
153
+ url: cr.url,
154
+ ...(cr.urlNote ? { urlNote: cr.urlNote } : {}),
155
+ number: cr.number,
156
+ title: cr.title,
157
+ state: cr.state,
158
+ author: crAuthor(cr),
159
+ sourceBranch: cr.branch,
160
+ targetBranch: cr.base,
161
+ createdAt: cr.createdAt,
162
+ updatedAt: cr.updatedAt ?? cr.createdAt,
163
+ changedFiles: counts.readable,
164
+ withheldFiles: counts.withheld,
165
+ // The same predicate the app's own list applies (`scopeApplyFailures`): a
166
+ // non-empty file set, every file readable. An empty set proves nothing,
167
+ // so it never grants the reason.
168
+ ...(cr.lastApplyFailure
169
+ ? {
170
+ lastApplyFailure: {
171
+ reason: counts.readable > 0 && counts.withheld === 0
172
+ ? cr.lastApplyFailure.reason
173
+ : APPLY_FAILURE_REASON_WITHHELD,
174
+ conflicts: cr.lastApplyFailure.conflicts,
175
+ at: cr.lastApplyFailure.at,
176
+ },
177
+ }
178
+ : {}),
179
+ };
180
+ }
181
+ /** A detail: the row, the author's description, and the gate as this caller sees it. */
182
+ export function toCrDetail(detail, counts, blockers, viewer) {
183
+ return {
184
+ ...toCrSummary(detail, counts),
185
+ // Empty rather than present-and-empty: a merged request read from its merge
186
+ // commit knows both commits, a declined one knows neither, and `''` would
187
+ // read as a sha nobody can look up.
188
+ ...(detail.headSha ? { headSha: detail.headSha } : {}),
189
+ ...(detail.baseSha ? { baseSha: detail.baseSha } : {}),
190
+ body: authorsDescription(detail.body),
191
+ mergeable: detail.mergeableInBevel,
192
+ mergeBlockedReasons: blockers.visible,
193
+ withheldMergeBlockedReasons: blockers.withheld,
194
+ viewer,
195
+ };
196
+ }
197
+ /**
198
+ * The part of a change-request body its AUTHOR wrote.
199
+ *
200
+ * A Hexis body is part human and part machine: `openChangeRequest` appends an
201
+ * `## Affected owners` block — one line per changed path, naming that path and
202
+ * its eligible approvers — to whatever the author typed. Returning the body
203
+ * verbatim NAMED every file of the request, including the ones this caller may
204
+ * not read: Local Testing caught a GTM-team reader being handed
205
+ * `- \`KnowledgeBase/Engineering/…\` — Admin` out of a request whose file list
206
+ * had correctly withheld that very path.
207
+ *
208
+ * So the generated block goes, and NOTHING ELSE does. The first cut at this
209
+ * copied the app's dialog, which drops everything from the first `##` heading
210
+ * on; Razvan's review (2026-10-02) asked for the narrower cut, because an
211
+ * author who writes their description in sections loses it from that heading
212
+ * onwards and is never told. The generated block is appended LAST and begins
213
+ * with a line that is exactly `## Affected owners`, so cutting at the LAST such
214
+ * line removes the machinery and keeps every heading a person wrote. (An author
215
+ * who writes that exact heading themselves loses their text from there — the
216
+ * safe direction, and the only way this can err.)
217
+ *
218
+ * Hexis's OWN hidden markers go too — the `<!--hexis:…-->` / `<!--bevel:…-->`
219
+ * comments older bodies carry identity in — and no other comment: an HTML
220
+ * comment the author wrote is the author's prose, like the rest.
221
+ *
222
+ * Who must approve each file is NOT lost by this — it is what
223
+ * `list_change_request_files` answers under `requiredApprovers`, per file and
224
+ * access-filtered, which is where a caller should read it from anyway.
225
+ *
226
+ * Two things this deliberately does not do. It does not vary by caller: one
227
+ * body for everyone is a body nobody has to reason about. And it does not touch
228
+ * the author's own prose, which may mention any path they chose to write about —
229
+ * that is a person's sentence, shown to every viewer in the app, not Hexis
230
+ * naming a file it was asked to withhold.
231
+ */
232
+ export function authorsDescription(body) {
233
+ const lines = body.split('\n');
234
+ const generated = lines.lastIndexOf('## Affected owners');
235
+ return (generated === -1 ? lines : lines.slice(0, generated))
236
+ .join('\n')
237
+ .replace(/<!--\s*(?:hexis|bevel)[:/][\s\S]*?-->/g, '')
238
+ .trim();
239
+ }
240
+ /**
241
+ * What this caller may do with the request.
242
+ *
243
+ * `mayMerge` reproduces what `mergePr` would accept, from the detail's own
244
+ * published fields: no hard block, and either nothing missing or an admin who
245
+ * may bypass what is. Deriving it here rather than asking a second time keeps
246
+ * the answer and the enforcement reading the same gate.
247
+ *
248
+ * `mayApprove` answers over `shownApprovals` — the approvals of the files this
249
+ * caller is SHOWN — and not over the request's whole approval set, which is why
250
+ * the set is passed in rather than read off `detail`. The two differ:
251
+ * `viewerCanApprove` is a WRITE grant at `origin/<base>`, and a write grant can
252
+ * hold for a file whose read verdict withholds it. Answering true off such a
253
+ * file would both contradict the contract ("at least one file they are shown")
254
+ * and tell the caller something about a file they were refused.
255
+ */
256
+ export function toCrViewer(detail, viewerIsAuthor, shownApprovals) {
257
+ const warnings = new Set(detail.mergeWarnings);
258
+ const hard = detail.mergeBlockedReasons.filter((r) => !warnings.has(r));
259
+ return {
260
+ // Nothing on a merged or declined request is there to approve, whatever
261
+ // write grant the caller holds on its files.
262
+ mayApprove: detail.state === 'open' && shownApprovals.some((a) => a.viewerCanApprove),
263
+ mayMerge: detail.state === 'open' &&
264
+ hard.length === 0 &&
265
+ (detail.mergeWarnings.length === 0 || detail.viewerCanBypassMerge),
266
+ isAuthor: viewerIsAuthor,
267
+ };
268
+ }
269
+ /**
270
+ * The merge blockers the caller may read.
271
+ *
272
+ * A gate warning quotes the path it waits on (`Waiting on approval for
273
+ * X from …`), so a blocker about a withheld file would name that file. Each
274
+ * blocker mentioning any withheld path is dropped and counted. Matching on the
275
+ * text rather than rebuilding the gate's sentences is deliberate: the gate owns
276
+ * its wording, and the only way this can err is by withholding a line that
277
+ * contains a withheld path as a substring — which is the safe direction.
278
+ */
279
+ export function visibleBlockers(reasons, withheldPaths) {
280
+ if (withheldPaths.length === 0)
281
+ return { visible: [...reasons], withheld: 0 };
282
+ const visible = reasons.filter((r) => !withheldPaths.some((p) => r.includes(p)));
283
+ return { visible, withheld: reasons.length - visible.length };
284
+ }
285
+ /**
286
+ * Whether the caller may read a changed file AT ALL.
287
+ *
288
+ * Both of its names must be readable. A moved file carries its old path in
289
+ * `previousPath`, and the diff of a move shows the content that was at that
290
+ * old path — so a file moved OUT of a folder the caller may not read is not
291
+ * readable here either, however open its new home is, and `previousPath` can
292
+ * never name a path they were refused. Fail-closed in the one direction that
293
+ * matters: a file with nowhere to hide is listed, a file with a hidden side is
294
+ * withheld and counted.
295
+ */
296
+ export function fileIsReadable(file, mayRead) {
297
+ if (!mayRead(file.path))
298
+ return false;
299
+ return file.previousPath === undefined || mayRead(file.previousPath);
300
+ }
301
+ /** Every path a changed file names — both sides of a move. */
302
+ export function pathsOf(file) {
303
+ return file.previousPath === undefined ? [file.path] : [file.path, file.previousPath];
304
+ }
305
+ /** A changed file plus its approval state. */
306
+ export function toCrFile(file, approval,
307
+ /** `open`: whether the request still is — an approval can be given on an open request only. */
308
+ opts) {
309
+ return {
310
+ path: file.path,
311
+ ...(file.previousPath ? { previousPath: file.previousPath } : {}),
312
+ change: changeKindOf(file.status),
313
+ additions: file.additions,
314
+ deletions: file.deletions,
315
+ // No `sha`. GitHub's file entry carries the blob sha at the head, and an
316
+ // earlier draft of this answer did too — but nothing in Hexis populates it:
317
+ // `GitService.prFilesForRange`, the only builder of `PullRequestFile` and
318
+ // the one that serves an open request and an applied one alike, writes
319
+ // `sha: ''` for every file. Answering a field whose every value is the empty
320
+ // string is worse than not answering it, because an agent that pins content
321
+ // or a diff on it gets no error (cubic P3 on #347). If a blob sha is wanted
322
+ // here, the git layer has to produce it first — `git diff --raw` carries
323
+ // both sides' blob shas — and the app's own change-request detail gets it in
324
+ // the same change.
325
+ ...(opts.patches && file.patch !== undefined ? { patch: file.patch } : {}),
326
+ isBinary: file.isBinary,
327
+ requiredApprovers: {
328
+ roles: approval?.eligibleApprovers.roles ?? [],
329
+ users: (approval?.eligibleApprovers.users ?? []).map((u) => ({
330
+ login: loginFor(u.email),
331
+ name: u.name,
332
+ email: u.email,
333
+ })),
334
+ },
335
+ // No approval entry at all means the lookup never ran (no workspace, an
336
+ // unwired enricher), which is exactly the "unknown" the flag reports — and
337
+ // it is reported the way `open_change_request` reports it: a present
338
+ // `approversUnknown`, absent when the set IS known, so the fail-closed
339
+ // reading is the one a caller gets by default.
340
+ ...(approval?.eligibilityResolved === true ? {} : { approversUnknown: true }),
341
+ approvedBy: (approval?.approvedBy ?? []).map(toCrFileApproval),
342
+ approved: approval?.isApproved === true,
343
+ inMergeGate: approval?.inMergeGate === true,
344
+ viewerMayApprove: opts.open && approval?.viewerCanApprove === true,
345
+ };
346
+ }
347
+ function toCrFileApproval(entry) {
348
+ return {
349
+ user: { login: loginFor(entry.email), name: entry.name, email: entry.email },
350
+ approvedAt: entry.approvedAt,
351
+ stale: entry.isStale,
352
+ selfApproval: entry.isSelfApproval,
353
+ };
354
+ }
355
+ /** The same hash-derived login the change-request summaries carry. */
356
+ export function loginFor(email) {
357
+ return `user-${hashEmail(email).slice(0, 12)}`;
358
+ }
359
+ /**
360
+ * The reviews of a change request, gathered out of its per-file approvals.
361
+ *
362
+ * Hexis records an approval per FILE; a review list wants one entry per review.
363
+ * One entry per (reviewer, staleness) is the closest honest join: it names the
364
+ * reviewer once and the files they approved, which is what the ticket's
365
+ * scenario asks to read back. A reviewer holding both a current and a stale
366
+ * approval appears twice — one entry for the files that still stand and one
367
+ * with `stale: true` for the ones the latest push invalidated.
368
+ *
369
+ * `mayShow` decides, per file, what this caller may be told. A review keeps the
370
+ * files they may read and counts the rest in its own `withheldFiles`; a review
371
+ * EVERY file of which is withheld is dropped and counted in `withheldReviews`,
372
+ * because naming the reviewer would itself say that somebody approved a change
373
+ * to something the caller may not look at. `submittedAt` is taken from the
374
+ * readable approvals alone, for the same reason.
375
+ *
376
+ * Hexis records nothing about who DECLINED a request — a rejection closes it
377
+ * and stores no reviewer — so no review entry can report one. A reviewer's
378
+ * objection lives in a comment, which `list_change_request_comments` returns.
379
+ */
380
+ export function toCrReviews(approvals, mayShow = () => true) {
381
+ const byReviewer = new Map();
382
+ for (const approval of approvals) {
383
+ const readable = mayShow(approval.path);
384
+ for (const entry of approval.approvedBy) {
385
+ const login = loginFor(entry.email);
386
+ const id = `${login}:${entry.isStale ? 'stale' : 'current'}`;
387
+ let review = byReviewer.get(id);
388
+ if (!review) {
389
+ review = {
390
+ id,
391
+ reviewer: { login, name: entry.name, email: entry.email },
392
+ stale: entry.isStale,
393
+ submittedAt: '',
394
+ files: [],
395
+ withheldFiles: 0,
396
+ };
397
+ byReviewer.set(id, review);
398
+ }
399
+ if (!readable) {
400
+ review.withheldFiles += 1;
401
+ continue;
402
+ }
403
+ review.files.push(approval.path);
404
+ if (entry.approvedAt > review.submittedAt)
405
+ review.submittedAt = entry.approvedAt;
406
+ }
407
+ }
408
+ const all = [...byReviewer.values()];
409
+ const reviews = all.filter((r) => r.files.length > 0);
410
+ return {
411
+ reviews: reviews.sort((a, b) => a.submittedAt.localeCompare(b.submittedAt) || a.id.localeCompare(b.id)),
412
+ withheldReviews: all.length - reviews.length,
413
+ };
414
+ }
415
+ /** A comment. Covers the file-anchored and the general ones — Hexis has one table. */
416
+ export function toCrComment(comment) {
417
+ return {
418
+ id: comment.id,
419
+ author: {
420
+ login: loginFor(comment.author.email),
421
+ name: comment.author.name,
422
+ email: comment.author.email,
423
+ },
424
+ body: comment.body,
425
+ ...(comment.path ? { path: comment.path } : {}),
426
+ ...(comment.line !== undefined ? { line: comment.line } : {}),
427
+ ...(comment.parentId ? { parentId: comment.parentId } : {}),
428
+ headSha: comment.headSha,
429
+ createdAt: comment.createdAt,
430
+ ...(comment.updatedAt ? { updatedAt: comment.updatedAt } : {}),
431
+ };
432
+ }
433
+ /**
434
+ * The comments the caller may read, replies included in the answer only when
435
+ * the comment they reply to is.
436
+ *
437
+ * A comment with no path is about the request as a whole, and a comment with
438
+ * one is as readable as that path is NAMEABLE here (`mayShow`, so a comment
439
+ * anchored to the new name of a file withheld for its old one goes with the
440
+ * file rather than announcing it). A REPLY is neither, quite: it carries no
441
+ * path of its own when it was posted without one, so judged on itself it is a
442
+ * general comment — and `post_change_request_comment` takes `parentId` without
443
+ * requiring `path`, so a reply to a comment on a withheld file was returned
444
+ * with its body and a `parentId` naming a comment the caller cannot see.
445
+ * Razvan's review (2026-10-02) asked for the rule the ticket states: a reply is
446
+ * shown only when its parent is.
447
+ *
448
+ * So a comment is visible when its OWN path may be shown (if it has one) AND
449
+ * its parent is visible, all the way up the chain. Both halves are needed:
450
+ * inheriting only would show a reply naming a withheld file under a readable
451
+ * parent, and checking only its own path would show it under a withheld one.
452
+ *
453
+ * Fail-closed at the edges. A `parentId` naming a comment that is not in this
454
+ * request's list (deleted, or from somewhere this answer cannot see) is not
455
+ * provably pathless, so the reply goes. A cycle — which the schema does not
456
+ * permit and a corrupted row could still hold — is unresolvable, so it goes
457
+ * too. Both are counted in the withheld total, never named.
458
+ */
459
+ export function visibleComments(comments, mayShow) {
460
+ const byId = new Map(comments.map((c) => [c.id, c]));
461
+ /** Memoised per id, so a long thread costs one walk and not one per reply. */
462
+ const verdicts = new Map();
463
+ const mayShowComment = (comment, seen) => {
464
+ const cached = verdicts.get(comment.id);
465
+ if (cached !== undefined)
466
+ return cached;
467
+ if (seen.has(comment.id))
468
+ return false;
469
+ seen.add(comment.id);
470
+ let verdict = !comment.path || mayShow(comment.path);
471
+ if (verdict && comment.parentId) {
472
+ const parent = byId.get(comment.parentId);
473
+ verdict = parent !== undefined && mayShowComment(parent, seen);
474
+ }
475
+ verdicts.set(comment.id, verdict);
476
+ return verdict;
477
+ };
478
+ const visible = comments.filter((c) => mayShowComment(c, new Set()));
479
+ return { visible, withheld: comments.length - visible.length };
480
+ }
481
+ //# sourceMappingURL=change-request-read-shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-request-read-shape.js","sourceRoot":"","sources":["../../../../src/modules/workflow/agent-tools/change-request-read-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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AAI,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,GAAG,MAAM,KAAK,SAAS,IAAI,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACjE,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACrE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,126 @@
1
+ import type { Router, RequestHandler } from 'express';
2
+ import type { ChangeRequestDetail } from '@bevel-software/platform-shared';
3
+ import type { IToolRegistry } from '../../tool-registry/tool.contract.js';
4
+ import { ToolError, type ToolContext } from '../../tool-helpers/tool.contract.js';
5
+ import type { ToolHandlerFactory } from '../../tool-helpers/tool-handler.js';
6
+ import type { KbContext } from '../../../shared/kb-context.js';
7
+ import type { IAccessControl } from '../../access/access-control.interface.js';
8
+ /**
9
+ * The five read tools over change requests, named and shaped after GitHub's
10
+ * pull-request API: `list_change_requests`, `get_change_request`,
11
+ * `list_change_request_files`, `list_change_request_reviews` and
12
+ * `list_change_request_comments`. The mapping lives in
13
+ * `change-request-read-shape.ts`; this file does the IO and the access
14
+ * filtering.
15
+ *
16
+ * They ANSWER in Hexis's own vocabulary, not GitHub's field names (Razvan's
17
+ * decision on the review of PR #347, 2026-10-02): every field shared with
18
+ * `open_change_request`'s summary takes that summary's name, and the rest follow
19
+ * its style, so an agent opens a change request and reads it back in one
20
+ * vocabulary. Their INPUTS keep GitHub's filter names, which the ticket pins.
21
+ * The shape module's header says what that changed, field by field.
22
+ *
23
+ * None of them writes anything — every handler is registered `write: false`,
24
+ * so a read-scoped connection key may call all five, and every service call
25
+ * below is a read.
26
+ *
27
+ * ## What the caller may see
28
+ *
29
+ * The app's own change-request routes serve the whole list and the whole
30
+ * detail to any signed-in viewer; only the file CONTENT routes gate per path
31
+ * (`canReadAtRef` at `origin/<base>`, with an unresolvable verdict as a
32
+ * denial). These tools apply that same content gate to the whole payload,
33
+ * because an agent's answer is the content: a file list, a reviewer's comment
34
+ * and a gate warning all name paths, and an agent hands what it reads to
35
+ * whoever it is talking to.
36
+ *
37
+ * So, per request:
38
+ *
39
+ * - every path is resolved at `origin/<base>` — the target's access tree, the
40
+ * one the request is asking to be judged against — in ONE batched lookup;
41
+ * - BOTH names of a moved file are resolved, and a file is readable only if
42
+ * both are: the diff of a move shows what was at the old path, so a file
43
+ * moved out of a closed folder stays closed, however open its new home.
44
+ * The LIST decides this over the same `touchedNodeFiles` pairs the detail
45
+ * does — a list that judged the flat `touchedNodePaths` could not see a
46
+ * move's old side, and advertised requests its own by-number tools
47
+ * answered 404 for;
48
+ * - files the caller may not read are left out and counted in
49
+ * `withheldFiles`, never named (decision 2 on the ticket);
50
+ * - comments on a withheld file, and gate blockers naming one, go the same
51
+ * way, with their own counts; a REPLY goes when the comment it replies to
52
+ * does, up the whole chain;
53
+ * - `body` is the author's own description, with the generated
54
+ * `## Affected owners` block cut off the end — see `authorsDescription`;
55
+ * - a request with no readable file and no claim of authorship answers 404,
56
+ * indistinguishable from a number that was never issued.
57
+ *
58
+ * ## Reading a request that is no longer open
59
+ *
60
+ * A MERGED request is read from the merge commit its row records: its branch is
61
+ * retired, but the commit holds exactly the change that landed, so its file list
62
+ * is recovered from there and filtered by access like an open request's (the
63
+ * 2026-10-02 decision). Nothing in that path touches the network — the commit is
64
+ * in the clone or it is not.
65
+ *
66
+ * A DECLINED request has no merge commit and no branch left to diff, so its file
67
+ * set cannot be resolved at all; it fails closed, and is therefore readable by
68
+ * its author alone. "We cannot tell what this request touched" is not "you may
69
+ * see it", and an empty path set is the same answer `scopeApplyFailures` already
70
+ * refuses to grant anything on. The same holds for any request whose file set
71
+ * does not resolve — an access tree that will not load at `origin/<base>`, or a
72
+ * clone that does not have the merge commit yet.
73
+ */
74
+ export declare function registerChangeRequestReadTools(registry: IToolRegistry, router: Router, toolAuth: RequestHandler, toolHandler: ToolHandlerFactory, accessControl: Pick<IAccessControl, 'canReadBatchAtRef'>, kb: Pick<KbContext, 'defaultWorkspaceId'>): void;
75
+ /**
76
+ * The detail of request `number` with the access filter applied, or a 404 —
77
+ * the one place the four by-number tools get their data, so they cannot
78
+ * drift on who may see what.
79
+ */
80
+ export interface ScopedDetail {
81
+ detail: ChangeRequestDetail;
82
+ /**
83
+ * Whether the caller may read one path of this request — the raw per-path
84
+ * verdict, as the access tree gives it at `origin/<base>`.
85
+ */
86
+ mayRead: (path: string) => boolean;
87
+ /**
88
+ * Whether this request may NAME `path` to the caller — `mayRead`, minus
89
+ * every name a withheld file goes by. The ONE verdict the tools below ask
90
+ * about a path, so none of them can decide it a second way.
91
+ *
92
+ * The two differ on exactly one shape, and it is the shape that leaks: a
93
+ * file moved out of a folder the caller may not read is readable under
94
+ * its NEW name, yet `fileIsReadable` withholds it whole (its diff shows the
95
+ * old path's content). Anything keyed on that new path — an approval, a
96
+ * comment anchored to it — would otherwise say the request touches a file
97
+ * the file tool refuses to list, under a name it refuses to print.
98
+ */
99
+ mayShow: (path: string) => boolean;
100
+ /** The request's files the caller may read, in the request's own order. */
101
+ readableFiles: ChangeRequestDetail['files'];
102
+ /**
103
+ * Every name the withheld files go by — for filtering the gate blockers and
104
+ * for deciding `mayShow`. NEVER answered: use `withheldFileCount` to report
105
+ * them.
106
+ */
107
+ withheldFilePaths: string[];
108
+ /** How many files are withheld. One per file, whatever its move names. */
109
+ withheldFileCount: number;
110
+ viewerIsAuthor: boolean;
111
+ }
112
+ /**
113
+ * The access scope of one change request, as every by-number read tool sees
114
+ * it — and as `delete_branch` does, so a deletion's preview or refusal never
115
+ * names a request `get_change_request` answers as not found.
116
+ */
117
+ export declare function changeRequestScope(accessControl: Pick<IAccessControl, 'canReadBatchAtRef'>, kb: Pick<KbContext, 'defaultWorkspaceId'>): {
118
+ repoGlobalWorkspaceId: (ctx: ToolContext) => Promise<string>;
119
+ readablePaths: (ctx: ToolContext, workspaceId: string, base: string, paths: string[]) => Promise<Set<string>>;
120
+ scopedDetail: (ctx: ToolContext, number: number, opts: {
121
+ patches: boolean;
122
+ }) => Promise<ScopedDetail>;
123
+ notFound: (number: number) => ToolError;
124
+ maySee: (ctx: ToolContext, number: number) => Promise<boolean>;
125
+ };
126
+ //# sourceMappingURL=change-request-read.tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-request-read.tools.d.ts","sourceRoot":"","sources":["../../../../src/modules/workflow/agent-tools/change-request-read.tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAEV,mBAAmB,EAGpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAoB,MAAM,qCAAqC,CAAC;AAEpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAsB/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE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