@bevel-software/platform-core-backend 0.25.2 → 0.26.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 (248) hide show
  1. package/agent-guide/access-control.md +234 -0
  2. package/agent-guide/conventions.md +27 -0
  3. package/agent-guide/directory-structure.md +145 -0
  4. package/agent-guide/finding-things.md +7 -0
  5. package/agent-guide/introduction.md +27 -0
  6. package/agent-guide/skills.md +47 -0
  7. package/agent-guide/tool-manuals.md +217 -0
  8. package/agent-guide/where-a-new-file-goes.md +36 -0
  9. package/dist/assets.d.ts +7 -0
  10. package/dist/assets.d.ts.map +1 -1
  11. package/dist/assets.js +9 -0
  12. package/dist/assets.js.map +1 -1
  13. package/dist/core/core-ports.d.ts +11 -0
  14. package/dist/core/core-ports.d.ts.map +1 -1
  15. package/dist/core/core-ports.js.map +1 -1
  16. package/dist/core/create-core-server.d.ts.map +1 -1
  17. package/dist/core/create-core-server.js +13 -2
  18. package/dist/core/create-core-server.js.map +1 -1
  19. package/dist/core/create-core-services.d.ts +9 -0
  20. package/dist/core/create-core-services.d.ts.map +1 -1
  21. package/dist/core/create-core-services.js +14 -4
  22. package/dist/core/create-core-services.js.map +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/modules/access/access-control.interface.d.ts +9 -0
  28. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  29. package/dist/modules/access/access-control.service.d.ts +1 -0
  30. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  31. package/dist/modules/access/access-control.service.js +16 -0
  32. package/dist/modules/access/access-control.service.js.map +1 -1
  33. package/dist/modules/agent-guide/agent-guide.d.ts +139 -0
  34. package/dist/modules/agent-guide/agent-guide.d.ts.map +1 -0
  35. package/dist/modules/agent-guide/agent-guide.js +191 -0
  36. package/dist/modules/agent-guide/agent-guide.js.map +1 -0
  37. package/dist/modules/agent-guide/agent-guide.tools.d.ts +24 -0
  38. package/dist/modules/agent-guide/agent-guide.tools.d.ts.map +1 -0
  39. package/dist/modules/agent-guide/agent-guide.tools.js +100 -0
  40. package/dist/modules/agent-guide/agent-guide.tools.js.map +1 -0
  41. package/dist/modules/agent-guide/index.d.ts +4 -0
  42. package/dist/modules/agent-guide/index.d.ts.map +1 -0
  43. package/dist/modules/agent-guide/index.js +4 -0
  44. package/dist/modules/agent-guide/index.js.map +1 -0
  45. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +3 -2
  46. package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
  47. package/dist/modules/agent-instructions/agent-instructions.routes.js +3 -2
  48. package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
  49. package/dist/modules/agent-instructions/compose.d.ts +9 -6
  50. package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
  51. package/dist/modules/agent-instructions/compose.js +9 -6
  52. package/dist/modules/agent-instructions/compose.js.map +1 -1
  53. package/dist/modules/agent-instructions/index.d.ts +1 -1
  54. package/dist/modules/agent-instructions/index.d.ts.map +1 -1
  55. package/dist/modules/agent-instructions/index.js +1 -1
  56. package/dist/modules/agent-instructions/index.js.map +1 -1
  57. package/dist/modules/agent-instructions/shared-file-rules.d.ts +10 -50
  58. package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -1
  59. package/dist/modules/agent-instructions/shared-file-rules.js +32 -85
  60. package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -1
  61. package/dist/modules/mcp/mcp.service.d.ts +29 -2
  62. package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
  63. package/dist/modules/mcp/mcp.service.js +113 -16
  64. package/dist/modules/mcp/mcp.service.js.map +1 -1
  65. package/dist/modules/mcp/tool-schema-guard.d.ts +105 -0
  66. package/dist/modules/mcp/tool-schema-guard.d.ts.map +1 -0
  67. package/dist/modules/mcp/tool-schema-guard.js +171 -0
  68. package/dist/modules/mcp/tool-schema-guard.js.map +1 -0
  69. package/dist/modules/plugins/plugins.tools.d.ts +36 -2
  70. package/dist/modules/plugins/plugins.tools.d.ts.map +1 -1
  71. package/dist/modules/plugins/plugins.tools.js +71 -14
  72. package/dist/modules/plugins/plugins.tools.js.map +1 -1
  73. package/dist/modules/settings/deployment-settings.service.d.ts +0 -7
  74. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
  75. package/dist/modules/settings/deployment-settings.service.js +14 -53
  76. package/dist/modules/settings/deployment-settings.service.js.map +1 -1
  77. package/dist/modules/settings/setup.routes.d.ts.map +1 -1
  78. package/dist/modules/settings/setup.routes.js +3 -6
  79. package/dist/modules/settings/setup.routes.js.map +1 -1
  80. package/dist/modules/skills/skills.tools.d.ts.map +1 -1
  81. package/dist/modules/skills/skills.tools.js +58 -16
  82. package/dist/modules/skills/skills.tools.js.map +1 -1
  83. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +23 -4
  84. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
  85. package/dist/modules/tool-manuals/tool-manuals.contract.js.map +1 -1
  86. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -0
  87. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  88. package/dist/modules/tool-manuals/tool-manuals.service.js +14 -0
  89. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  90. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +7 -0
  91. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
  92. package/dist/modules/tool-manuals/tool-manuals.tools.js +66 -36
  93. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  94. package/dist/modules/tool-registry/description-length.d.ts +14 -14
  95. package/dist/modules/tool-registry/description-length.d.ts.map +1 -1
  96. package/dist/modules/tool-registry/description-length.js +24 -26
  97. package/dist/modules/tool-registry/description-length.js.map +1 -1
  98. package/dist/modules/tool-registry/guide-first.d.ts +23 -0
  99. package/dist/modules/tool-registry/guide-first.d.ts.map +1 -0
  100. package/dist/modules/tool-registry/guide-first.js +32 -0
  101. package/dist/modules/tool-registry/guide-first.js.map +1 -0
  102. package/dist/modules/tool-registry/tool-registry.d.ts +6 -0
  103. package/dist/modules/tool-registry/tool-registry.d.ts.map +1 -1
  104. package/dist/modules/tool-registry/tool-registry.js +9 -2
  105. package/dist/modules/tool-registry/tool-registry.js.map +1 -1
  106. package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts +449 -0
  107. package/dist/modules/workflow/agent-tools/change-request-read-shape.d.ts.map +1 -0
  108. package/dist/modules/workflow/agent-tools/change-request-read-shape.js +481 -0
  109. package/dist/modules/workflow/agent-tools/change-request-read-shape.js.map +1 -0
  110. package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts +73 -0
  111. package/dist/modules/workflow/agent-tools/change-request-read.tools.d.ts.map +1 -0
  112. package/dist/modules/workflow/agent-tools/change-request-read.tools.js +582 -0
  113. package/dist/modules/workflow/agent-tools/change-request-read.tools.js.map +1 -0
  114. package/dist/modules/workflow/agent-tools/change-request-summary.d.ts +12 -1
  115. package/dist/modules/workflow/agent-tools/change-request-summary.d.ts.map +1 -1
  116. package/dist/modules/workflow/agent-tools/change-request-summary.js +5 -1
  117. package/dist/modules/workflow/agent-tools/change-request-summary.js.map +1 -1
  118. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
  119. package/dist/modules/workflow/agent-tools/workflow.tools.js +9 -0
  120. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  121. package/dist/modules/workflow/git/git.service.d.ts +210 -13
  122. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  123. package/dist/modules/workflow/git/git.service.js +456 -91
  124. package/dist/modules/workflow/git/git.service.js.map +1 -1
  125. package/dist/modules/workflow/git/merge-commit.d.ts +73 -0
  126. package/dist/modules/workflow/git/merge-commit.d.ts.map +1 -0
  127. package/dist/modules/workflow/git/merge-commit.js +89 -0
  128. package/dist/modules/workflow/git/merge-commit.js.map +1 -0
  129. package/dist/modules/workflow/git/pull-request.service.d.ts +94 -1
  130. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  131. package/dist/modules/workflow/git/pull-request.service.js +332 -37
  132. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  133. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts +35 -0
  134. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
  135. package/dist/modules/workflow/review-workflow/review-workflow.service.js +178 -12
  136. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  137. package/dist/modules/workflow/workflow.routes.d.ts +6 -2
  138. package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
  139. package/dist/modules/workflow/workflow.routes.js +7 -2
  140. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  141. package/dist/modules/workflow/workflow.service.d.ts +4 -0
  142. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  143. package/dist/modules/workflow/workflow.service.js +3 -0
  144. package/dist/modules/workflow/workflow.service.js.map +1 -1
  145. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  146. package/dist/modules/workspace/startup/steps/seed-tree.js +22 -27
  147. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  148. package/dist/modules/workspace/startup/steps/template-files.step.d.ts +58 -52
  149. package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
  150. package/dist/modules/workspace/startup/steps/template-files.step.js +209 -223
  151. package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
  152. package/dist/modules/workspace/startup/steps/template-source.d.ts +5 -3
  153. package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
  154. package/dist/modules/workspace/startup/steps/template-source.js +5 -3
  155. package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
  156. package/dist/modules/workspace/workspace.tools.d.ts +10 -1
  157. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  158. package/dist/modules/workspace/workspace.tools.js +211 -18
  159. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  160. package/dist/shared/domain-errors.d.ts +11 -0
  161. package/dist/shared/domain-errors.d.ts.map +1 -1
  162. package/dist/shared/domain-errors.js +14 -0
  163. package/dist/shared/domain-errors.js.map +1 -1
  164. package/dist/shared/hidden-tools.d.ts +44 -0
  165. package/dist/shared/hidden-tools.d.ts.map +1 -0
  166. package/dist/shared/hidden-tools.js +13 -0
  167. package/dist/shared/hidden-tools.js.map +1 -0
  168. package/kb-template/.bevelignore +0 -5
  169. package/package.json +4 -3
  170. package/src/__tests__/kb-layout-config.test.ts +10 -100
  171. package/src/__tests__/packaged-assets-ship.test.ts +54 -0
  172. package/src/assets.ts +10 -0
  173. package/src/core/core-ports.ts +11 -0
  174. package/src/core/create-core-server.ts +13 -2
  175. package/src/core/create-core-services.ts +28 -4
  176. package/src/index.ts +2 -2
  177. package/src/modules/access/__tests__/access-control.atref-batch.test.ts +58 -0
  178. package/src/modules/access/__tests__/access-control.platform-restore.test.ts +8 -7
  179. package/src/modules/access/__tests__/access-personal-plugin.test.ts +1 -18
  180. package/src/modules/access/access-control.interface.ts +15 -0
  181. package/src/modules/access/access-control.service.ts +21 -0
  182. package/src/modules/agent-guide/__tests__/agent-guide.test.ts +328 -0
  183. package/src/modules/agent-guide/__tests__/agent-guide.tools.test.ts +189 -0
  184. package/src/modules/agent-guide/agent-guide.tools.ts +122 -0
  185. package/src/modules/agent-guide/agent-guide.ts +291 -0
  186. package/src/modules/agent-guide/index.ts +21 -0
  187. package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +28 -121
  188. package/src/modules/agent-instructions/agent-instructions.routes.ts +3 -2
  189. package/src/modules/agent-instructions/compose.ts +9 -6
  190. package/src/modules/agent-instructions/index.ts +0 -3
  191. package/src/modules/agent-instructions/shared-file-rules.ts +31 -93
  192. package/src/modules/mcp/__tests__/fake-downstream-mcp-server.ts +14 -3
  193. package/src/modules/mcp/__tests__/mcp.e2e.test.ts +250 -0
  194. package/src/modules/mcp/__tests__/mcp.service.test.ts +31 -23
  195. package/src/modules/mcp/__tests__/tool-schema-guard.test.ts +266 -0
  196. package/src/modules/mcp/mcp.service.ts +137 -19
  197. package/src/modules/mcp/tool-schema-guard.ts +196 -0
  198. package/src/modules/plugins/__tests__/plugins.tools.test.ts +154 -4
  199. package/src/modules/plugins/plugins.tools.ts +75 -15
  200. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +26 -55
  201. package/src/modules/settings/deployment-settings.service.ts +13 -54
  202. package/src/modules/settings/setup.routes.ts +3 -6
  203. package/src/modules/skills/__tests__/skills.tools.description.test.ts +91 -0
  204. package/src/modules/skills/skills.tools.ts +62 -16
  205. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +57 -0
  206. package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +73 -4
  207. package/src/modules/tool-manuals/tool-manuals.contract.ts +24 -4
  208. package/src/modules/tool-manuals/tool-manuals.service.ts +17 -0
  209. package/src/modules/tool-manuals/tool-manuals.tools.ts +74 -36
  210. package/src/modules/tool-registry/__tests__/own-tool-schemas.test.ts +160 -0
  211. package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +61 -59
  212. package/src/modules/tool-registry/description-length.ts +24 -26
  213. package/src/modules/tool-registry/guide-first.ts +34 -0
  214. package/src/modules/tool-registry/tool-registry.ts +9 -2
  215. package/src/modules/workflow/__tests__/apply-failure.test.ts +6 -1
  216. package/src/modules/workflow/agent-tools/__tests__/change-request-read-shape.test.ts +705 -0
  217. package/src/modules/workflow/agent-tools/__tests__/change-request-read.tools.test.ts +1518 -0
  218. package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +23 -2
  219. package/src/modules/workflow/agent-tools/change-request-read-shape.ts +712 -0
  220. package/src/modules/workflow/agent-tools/change-request-read.tools.ts +724 -0
  221. package/src/modules/workflow/agent-tools/change-request-summary.ts +5 -1
  222. package/src/modules/workflow/agent-tools/workflow.tools.ts +8 -0
  223. package/src/modules/workflow/git/__tests__/git.service.appliedChange.test.ts +285 -0
  224. package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +124 -0
  225. package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +334 -0
  226. package/src/modules/workflow/git/__tests__/pull-request.service.list-fetch.test.ts +72 -2
  227. package/src/modules/workflow/git/__tests__/pull-request.service.placeholder.test.ts +24 -2
  228. package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +620 -1
  229. package/src/modules/workflow/git/git.service.ts +537 -94
  230. package/src/modules/workflow/git/merge-commit.ts +88 -0
  231. package/src/modules/workflow/git/pull-request.service.ts +380 -54
  232. package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +7 -1
  233. package/src/modules/workflow/review-workflow/__tests__/merge-records-own-commit.test.ts +407 -0
  234. package/src/modules/workflow/review-workflow/review-workflow.service.ts +189 -11
  235. package/src/modules/workflow/workflow.routes.ts +7 -2
  236. package/src/modules/workflow/workflow.service.ts +7 -0
  237. package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +4 -3
  238. package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +21 -10
  239. package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +33 -55
  240. package/src/modules/workspace/__tests__/workspace.tools.test.ts +255 -22
  241. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +191 -489
  242. package/src/modules/workspace/startup/steps/seed-tree.ts +21 -27
  243. package/src/modules/workspace/startup/steps/template-files.step.ts +217 -249
  244. package/src/modules/workspace/startup/steps/template-source.ts +5 -3
  245. package/src/modules/workspace/workspace.tools.ts +226 -16
  246. package/src/shared/domain-errors.ts +15 -0
  247. package/src/shared/hidden-tools.ts +45 -0
  248. package/kb-template/AGENTS.md +0 -730
@@ -0,0 +1,191 @@
1
+ /**
2
+ * The platform's agent guide: what every agent is told to read before its
3
+ * first read or change in a knowledge base — the layout, where a new file
4
+ * goes, the rules every file tool shares, access control, skills and tool
5
+ * manuals.
6
+ *
7
+ * It is TEXT THE CODE OWNS, not a file in the repository. It used to be
8
+ * written to every protected branch as `AGENTS.md` and refreshed on every
9
+ * start, which had three costs: a repository that already had an `AGENTS.md`
10
+ * of its own lost it or had to rename ours; a distribution that wanted to add
11
+ * to the guide had to fork the whole file and then drifted from every change
12
+ * made here; and the file sat in git history on every branch, hidden from the
13
+ * tree by an ignore rule it had to keep writing. Now the guide is composed
14
+ * from SECTIONS at the moment an agent asks for it — `get_agent_guide`, or a
15
+ * `read_file` of the guide's name at the repository root — and a distribution
16
+ * shapes it with a hook that sees the sections and returns the sections it
17
+ * wants (append, replace or drop by id), so what Hexis says reaches it without
18
+ * a copy to maintain.
19
+ *
20
+ * The sections ship as markdown files in the package's `agent-guide/` folder
21
+ * (see `assets.ts`), one per section, with the layout placeholders the old
22
+ * template carried (`{{knowledgeBaseDir}}`, `{{skillsDir}}`, `{{pluginsDir}}`,
23
+ * `{{agentsFile}}`). ONE section is computed rather than read: the rules every
24
+ * file tool shares, which the MCP handshake also sends — the same string in
25
+ * both places, from `shared-file-rules.ts`, so a rule cannot be changed in one
26
+ * and left stale in the other.
27
+ */
28
+ import fs from 'node:fs/promises';
29
+ import path from 'node:path';
30
+ import { renderKbLayoutPlaceholders, resolveKbLayout, } from '@bevel-software/platform-shared';
31
+ import { agentGuideDir } from '../../assets.js';
32
+ import { sharedFileRulesSection } from '../agent-instructions/shared-file-rules.js';
33
+ /** The computed section: the rules every file tool shares. */
34
+ export const WORKING_WITH_FILES_SECTION_ID = 'working-with-files';
35
+ /**
36
+ * Core's sections, in reading order. Every id but the shared-rules one names
37
+ * a file in the package's `agent-guide/` folder.
38
+ */
39
+ export const CORE_SECTION_IDS = Object.freeze([
40
+ 'introduction',
41
+ 'directory-structure',
42
+ 'where-a-new-file-goes',
43
+ WORKING_WITH_FILES_SECTION_ID,
44
+ 'access-control',
45
+ 'skills',
46
+ 'tool-manuals',
47
+ 'conventions',
48
+ 'finding-things',
49
+ ]);
50
+ /**
51
+ * The one line that proves a root guide file is the platform's and not the
52
+ * customer's: the blockquote the packaged guide opened with for as long as
53
+ * the guide was a file, under every release. Asked for WHERE the header put
54
+ * it — a blockquote line among the first lines of the file — and not anywhere
55
+ * in the text: a note of the organisation's own that quotes the platform's
56
+ * sentence in its body must not read as ours, because the consequence of the
57
+ * mistake is a deletion. Still read on every start, to take the copies
58
+ * earlier releases wrote out of the repository (see template-files.step.ts),
59
+ * and on every read of the guide's name, so a copy still on a draft is not
60
+ * served twice.
61
+ */
62
+ const MANAGED_GUIDE_HEADER_LINE = '> **This file is managed by the platform.**';
63
+ /** How far down a file the header's blockquote can sit: under the title and a sentence or two, never further. */
64
+ const MANAGED_GUIDE_HEADER_WITHIN_LINES = 12;
65
+ /** Whether `text` is a copy of the guide a release wrote to disk, of any vintage. */
66
+ export function isManagedGuide(text) {
67
+ return text
68
+ .split('\n', MANAGED_GUIDE_HEADER_WITHIN_LINES)
69
+ .some((line) => line.trimStart().startsWith(MANAGED_GUIDE_HEADER_LINE));
70
+ }
71
+ /** The raw section files, read once per process: the package does not change while it runs. */
72
+ let coreSectionFiles = null;
73
+ async function readCoreSectionFiles() {
74
+ const dir = agentGuideDir();
75
+ const entries = await Promise.all(CORE_SECTION_IDS.filter((id) => id !== WORKING_WITH_FILES_SECTION_ID).map(
76
+ // Line endings normalised: a checkout on Windows may carry CRLF, and the
77
+ // guide is one text with one ending wherever it is served from.
78
+ async (id) => [id, (await fs.readFile(path.join(dir, `${id}.md`), 'utf8')).replace(/\r\n?/g, '\n')]));
79
+ return new Map(entries);
80
+ }
81
+ /**
82
+ * Core's sections for `layout`: the files, placeholders unrendered, with the
83
+ * shared-rules section computed and in its place. What a distribution's hook
84
+ * is handed.
85
+ */
86
+ export async function coreAgentGuideSections(layout) {
87
+ coreSectionFiles ??= readCoreSectionFiles();
88
+ let files;
89
+ try {
90
+ files = await coreSectionFiles;
91
+ }
92
+ catch (err) {
93
+ // A failed read is not cached: the next composition tries the disk again.
94
+ coreSectionFiles = null;
95
+ throw err;
96
+ }
97
+ return CORE_SECTION_IDS.map((id) => id === WORKING_WITH_FILES_SECTION_ID
98
+ ? { id, body: sharedFileRulesSection(layout), literal: true }
99
+ : { id, body: files.get(id) });
100
+ }
101
+ /** The checkout folder's name when none is given — core's own default. */
102
+ const DEFAULT_KB_DIR_NAME = 'knowledge-base';
103
+ /**
104
+ * The guide's sections as an agent reads them: core's sections through the
105
+ * distribution's hook (when there is one), rendered for the layout, each
106
+ * with its title. The whole guide is these joined (see
107
+ * {@link composeAgentGuide}); `get_agent_guide` also serves one at a time.
108
+ *
109
+ * A hook may append, replace and drop sections, with ONE exception: the
110
+ * shared file rules ({@link WORKING_WITH_FILES_SECTION_ID}) must come back
111
+ * WITH TEXT IN THEM, as core's or as the hook's own replacement. A client
112
+ * that drops the handshake instructions has the guide as the only place to
113
+ * read the rules — a guide without them would leave agents nothing to read.
114
+ * A hook that drops the section, or hands it back empty, is a composition
115
+ * error, thrown rather than served. Judged on what would be SERVED — the
116
+ * rendered, trimmed body — so a replacement of whitespace is caught like a
117
+ * missing one, rather than passing the check and vanishing with the other
118
+ * empty sections below.
119
+ */
120
+ export async function agentGuideSections(layout, hook, context = {}) {
121
+ const resolved = resolveKbLayout(layout);
122
+ const core = await coreAgentGuideSections(resolved);
123
+ const sections = hook ? await hook(core, resolved) : core;
124
+ const kbDirName = context.kbDirName?.trim() || DEFAULT_KB_DIR_NAME;
125
+ const rendered = sections.map((section) => {
126
+ const body = (section.literal
127
+ ? section.body
128
+ : renderKbLayoutPlaceholders(section.body.replaceAll('{{kbDirName}}', () => kbDirName), resolved)).trim();
129
+ return { id: section.id, title: titleOf(body, section.id), body };
130
+ });
131
+ // Judged over EVERY section under the id — a hook may return the id twice
132
+ // — on what survives the empty-body filter below: one with text is enough.
133
+ const rules = rendered.filter((section) => section.id === WORKING_WITH_FILES_SECTION_ID);
134
+ if (!rules.some((section) => section.body.length > 0)) {
135
+ throw new Error(`The agent guide hook ${rules.length === 0 ? 'dropped' : 'emptied'} the "${WORKING_WITH_FILES_SECTION_ID}" ` +
136
+ 'section, which every file tool points at. Keep it, or replace it under the same id with the rules in it.');
137
+ }
138
+ return rendered.filter((section) => section.body.length > 0);
139
+ }
140
+ /**
141
+ * The heading's text, or the id when the section opens with no heading. An
142
+ * ATX heading may close with a run of `#` of its own (`## Custom ##`); that
143
+ * is a delimiter, not part of the title.
144
+ */
145
+ function titleOf(body, id) {
146
+ const first = body.split('\n', 1)[0] ?? '';
147
+ const heading = /^#{1,6}\s+(.*?)(?:\s+#+)?\s*$/.exec(first);
148
+ return heading ? heading[1].trim() : id;
149
+ }
150
+ /**
151
+ * The guide as an agent reads it whole: the sections joined by blank lines,
152
+ * ending in one newline.
153
+ */
154
+ export async function composeAgentGuide(layout, hook, context = {}) {
155
+ return joinGuideSections(await agentGuideSections(layout, hook, context));
156
+ }
157
+ /** The sections as one document, the way `composeAgentGuide` joins them. */
158
+ export function joinGuideSections(sections) {
159
+ return `${sections.map((section) => section.body).join('\n\n')}\n`;
160
+ }
161
+ /**
162
+ * What a `read_file` of the guide's name answers when the knowledge base has an
163
+ * `AGENTS.md` of its own: their text first, whole, then a rule and one line
164
+ * saying what follows, then the platform's guide. Theirs first because it is
165
+ * the more specific of the two, and the line between so neither is read as
166
+ * part of the other.
167
+ */
168
+ export const PLATFORM_GUIDE_SEPARATOR = "---\n\n_The text above is this knowledge base's own conventions file. The platform's guide follows; `get_agent_guide` returns it on its own._";
169
+ export function withPlatformGuideAppended(ownText, guide) {
170
+ // Their text as they wrote it, line endings normalised and the trailing
171
+ // newlines folded into the one blank line before the separator. Nothing
172
+ // else is touched: leading indentation and trailing spaces are markdown.
173
+ const own = ownText.replace(/\r\n?/g, '\n').replace(/\n+$/, '');
174
+ // A file with nothing in it has nothing to put first, and a separator
175
+ // above nothing would claim a conventions file that says nothing.
176
+ if (own.trim().length === 0)
177
+ return guide;
178
+ return `${own}\n\n${PLATFORM_GUIDE_SEPARATOR}\n\n${guide}`;
179
+ }
180
+ /** The one name the guide is read by: `AGENTS.md` at the repository root, the name coding agents look for. */
181
+ export const AGENT_GUIDE_FILE = 'AGENTS.md';
182
+ /**
183
+ * Whether a repository-relative path is where the guide is read — `AGENTS.md`
184
+ * at the repository root, exactly spelled, like every platform path. One
185
+ * name on every deployment: there is no setting for it any more.
186
+ */
187
+ export function isAgentGuidePath(repoRelativePath) {
188
+ const norm = repoRelativePath.replace(/^\.?\/+/, '').replace(/\/+$/, '');
189
+ return norm === AGENT_GUIDE_FILE;
190
+ }
191
+ //# sourceMappingURL=agent-guide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-guide.js","sourceRoot":"","sources":["../../../src/modules/agent-guide/agent-guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAEL,0BAA0B,EAC1B,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAyCpF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC/D,cAAc;IACd,qBAAqB;IACrB,uBAAuB;IACvB,6BAA6B;IAC7B,gBAAgB;IAChB,QAAQ;IACR,cAAc;IACd,aAAa;IACb,gBAAgB;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,yBAAyB,GAAG,6CAA6C,CAAC;AAEhF,iHAAiH;AACjH,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI;SACR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IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AACrE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,+IAA+I,CAAC;AAElJ,MAAM,UAAU,yBAAyB,CAAC,OAAe,EAAE,KAAa;IACtE,wEAAwE;IACxE,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChE,sEAAsE;IACtE,kEAAkE;IAClE,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,GAAG,GAAG,OAAO,wBAAwB,OAAO,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED,8GAA8G;AAC9G,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,gBAAwB;IACvD,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzE,OAAO,IAAI,KAAK,gBAAgB,CAAC;AACnC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Router, RequestHandler } from 'express';
2
+ import type { IToolRegistry } from '../tool-registry/tool.contract.js';
3
+ import { GET_AGENT_GUIDE_TOOL } from '../tool-registry/guide-first.js';
4
+ import type { ToolHandlerFactory } from '../tool-helpers/tool-handler.js';
5
+ import { type AgentGuideSectionsReader } from './agent-guide.js';
6
+ export { GET_AGENT_GUIDE_TOOL };
7
+ /**
8
+ * The one tool that returns the guide on its own — whole, or one section by
9
+ * id. It takes nothing else: the guide is the platform's text for this
10
+ * deployment, the same for every caller and every branch, and reading it
11
+ * touches no file — so no `branch`, no `sessionId`, and no access gate. The
12
+ * other way to the same text is a `read_file` of `AGENTS.md` at the
13
+ * repository root, which also carries the knowledge base's own `AGENTS.md`
14
+ * when it has one (see `agent-guide.ts`).
15
+ *
16
+ * Registered as a PROVIDER on both surfaces, so the description names the
17
+ * sections the guide has NOW — a distribution's hook may add its own — and
18
+ * the in-process agent and an external one are told the same thing to read
19
+ * first. This is the one tool the catalog does not open with "call
20
+ * get_agent_guide first" (see `tool-registry/guide-first.ts`): it is what
21
+ * that sentence points at, and says so itself.
22
+ */
23
+ export declare function registerAgentGuideTool(registry: IToolRegistry, router: Router, toolAuth: RequestHandler, toolHandler: ToolHandlerFactory, sections: AgentGuideSectionsReader): void;
24
+ //# sourceMappingURL=agent-guide.tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-guide.tools.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-guide/agent-guide.tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAIvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAuC,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEtG,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EAAE,wBAAwB,GACjC,IAAI,CAwFN"}
@@ -0,0 +1,100 @@
1
+ import { GET_AGENT_GUIDE_TOOL } from '../tool-registry/guide-first.js';
2
+ import { TOOL_DESCRIPTION_CAP } from '../tool-registry/description-length.js';
3
+ import { ToolError } from '../tool-helpers/tool.contract.js';
4
+ import { toolDef } from '../tool-helpers/tool-def.js';
5
+ import { AGENT_GUIDE_FILE, joinGuideSections } from './agent-guide.js';
6
+ export { GET_AGENT_GUIDE_TOOL };
7
+ /**
8
+ * The one tool that returns the guide on its own — whole, or one section by
9
+ * id. It takes nothing else: the guide is the platform's text for this
10
+ * deployment, the same for every caller and every branch, and reading it
11
+ * touches no file — so no `branch`, no `sessionId`, and no access gate. The
12
+ * other way to the same text is a `read_file` of `AGENTS.md` at the
13
+ * repository root, which also carries the knowledge base's own `AGENTS.md`
14
+ * when it has one (see `agent-guide.ts`).
15
+ *
16
+ * Registered as a PROVIDER on both surfaces, so the description names the
17
+ * sections the guide has NOW — a distribution's hook may add its own — and
18
+ * the in-process agent and an external one are told the same thing to read
19
+ * first. This is the one tool the catalog does not open with "call
20
+ * get_agent_guide first" (see `tool-registry/guide-first.ts`): it is what
21
+ * that sentence points at, and says so itself.
22
+ */
23
+ export function registerAgentGuideTool(registry, router, toolAuth, toolHandler, sections) {
24
+ const build = async () => {
25
+ const list = await sections();
26
+ const describe = (sectionList) => "The platform's guide to this knowledge base: its layout, where a new file goes, the rules every file tool " +
27
+ 'shares, access control, skills and tool manuals. ALWAYS call this first and read the guide before you do ' +
28
+ 'anything else in the platform. Returns `{ guide }` as markdown: the whole guide, or one section when ' +
29
+ '`section` names one. The same text comes back from `read_file` on `' +
30
+ AGENT_GUIDE_FILE +
31
+ "` at the KB root, after the knowledge base's own " +
32
+ AGENT_GUIDE_FILE +
33
+ ` when it has one. Sections: ${sectionList}.`;
34
+ // The description stays under the cap WHATEVER a distribution adds, in
35
+ // three steps: every id with its title; every id alone; as many ids as
36
+ // fit and a count of the rest. An id a client cut off the end would be a
37
+ // section an agent cannot ask for — so nothing is ever cut: the one
38
+ // complete list of sections is `sections` on the whole-guide response,
39
+ // which the description names when it cannot carry them all itself.
40
+ const titled = describe(list.map((s) => `\`${s.id}\` (${s.title})`).join(', '));
41
+ const ids = list.map((s) => `\`${s.id}\``);
42
+ const counted = (shown) => describe(shown === 0
43
+ ? `${ids.length}, named under \`sections\` in the whole-guide response`
44
+ : [...ids.slice(0, shown), `and ${ids.length - shown} more, all named under \`sections\` in the whole-guide response`].join(', '));
45
+ let description = titled.length <= TOOL_DESCRIPTION_CAP ? titled : describe(ids.join(', '));
46
+ for (let shown = ids.length; description.length > TOOL_DESCRIPTION_CAP && shown > 0; shown--) {
47
+ description = counted(shown - 1);
48
+ }
49
+ return toolDef({
50
+ name: GET_AGENT_GUIDE_TOOL,
51
+ description,
52
+ path: `/api/agent/tools/${GET_AGENT_GUIDE_TOOL}`,
53
+ inputs: {
54
+ type: 'object',
55
+ properties: {
56
+ section: {
57
+ type: 'string',
58
+ description: 'Optional: the id of one section to read instead of the whole guide (the ids are listed in this ' +
59
+ 'description, and every one under `sections` in the whole-guide response). Omit it for the whole guide.',
60
+ },
61
+ },
62
+ additionalProperties: false,
63
+ },
64
+ outputs: {
65
+ type: 'object',
66
+ properties: {
67
+ guide: { type: 'string', description: 'The guide, or the one section asked for, as markdown.' },
68
+ sections: {
69
+ type: 'array',
70
+ description: 'Without `section`: every section of the guide, in order, by id and heading — the complete list.',
71
+ items: {
72
+ type: 'object',
73
+ properties: { id: { type: 'string' }, title: { type: 'string' } },
74
+ required: ['id', 'title'],
75
+ },
76
+ },
77
+ section: { type: 'string', description: 'With `section`: the id of the section returned.' },
78
+ title: { type: 'string', description: 'With `section`: its heading.' },
79
+ },
80
+ required: ['guide'],
81
+ },
82
+ tags: ['workspace'],
83
+ });
84
+ };
85
+ registry.registerInternalTool(build);
86
+ registry.registerExternalTool(build);
87
+ router.post(`/agent/tools/${GET_AGENT_GUIDE_TOOL}`, toolAuth, toolHandler(async (args) => {
88
+ const list = await sections();
89
+ const wanted = typeof args.section === 'string' ? args.section.trim() : '';
90
+ if (!wanted)
91
+ return { guide: joinGuideSections(list), sections: list.map((s) => ({ id: s.id, title: s.title })) };
92
+ const one = list.find((s) => s.id === wanted);
93
+ if (!one) {
94
+ throw new ToolError(`The guide has no section "${wanted}". Sections: ${list.map((s) => `\`${s.id}\``).join(', ')}. ` +
95
+ 'Omit `section` for the whole guide.', 400);
96
+ }
97
+ return { guide: one.body, section: one.id, title: one.title };
98
+ }));
99
+ }
100
+ //# sourceMappingURL=agent-guide.tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-guide.tools.js","sourceRoot":"","sources":["../../../src/modules/agent-guide/agent-guide.tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAiC,MAAM,kBAAkB,CAAC;AAEtG,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAuB,EACvB,MAAc,EACd,QAAwB,EACxB,WAA+B,EAC/B,QAAkC;IAElC,MAAM,KAAK,GAAG,KAAK,IAAuB,EAAE;QAC1C,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,CAAC,WAAmB,EAAE,EAAE,CACvC,4GAA4G;YAC5G,2GAA2G;YAC3G,uGAAuG;YACvG,qEAAqE;YACrE,gBAAgB;YAChB,mDAAmD;YACnD,gBAAgB;YAChB,+BAA+B,WAAW,GAAG,CAAC;QAChD,uEAAuE;QACvE,uEAAuE;QACvE,yEAAyE;QACzE,oEAAoE;QACpE,uEAAuE;QACvE,oEAAoE;QACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAA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CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;QAClH,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,SAAS,CACjB,6BAA6B,MAAM,gBAAgB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;gBAC9F,qCAAqC,EACvC,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IAChE,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { AGENT_GUIDE_FILE, CORE_SECTION_IDS, PLATFORM_GUIDE_SEPARATOR, WORKING_WITH_FILES_SECTION_ID, agentGuideSections, composeAgentGuide, coreAgentGuideSections, isAgentGuidePath, isManagedGuide, joinGuideSections, withPlatformGuideAppended, type AgentGuideContext, type AgentGuideHook, type AgentGuideReader, type AgentGuideSection, type AgentGuideSectionsReader, type RenderedGuideSection, } from './agent-guide.js';
2
+ export { GET_AGENT_GUIDE_TOOL, registerAgentGuideTool } from './agent-guide.tools.js';
3
+ export { GUIDE_FIRST_SENTENCE, withGuideFirst } from '../tool-registry/guide-first.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-guide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { AGENT_GUIDE_FILE, CORE_SECTION_IDS, PLATFORM_GUIDE_SEPARATOR, WORKING_WITH_FILES_SECTION_ID, agentGuideSections, composeAgentGuide, coreAgentGuideSections, isAgentGuidePath, isManagedGuide, joinGuideSections, withPlatformGuideAppended, } from './agent-guide.js';
2
+ export { GET_AGENT_GUIDE_TOOL, registerAgentGuideTool } from './agent-guide.tools.js';
3
+ export { GUIDE_FIRST_SENTENCE, withGuideFirst } from '../tool-registry/guide-first.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/agent-guide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,GAO1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC"}
@@ -21,8 +21,9 @@ import type { AgentPreambleReader } from './read-preamble.js';
21
21
  export declare function createAgentInstructionsRoutes(manualAuth: RequestHandler, readPreamble: AgentPreambleReader,
22
22
  /**
23
23
  * The layout in effect, read per request — the shared file rules name the
24
- * managed guide, whose name the setup save may change without a restart.
25
- * Optional so a construction with no layout in hand gets `AGENTS.md`.
24
+ * guide by the name a deployment saved for it, which the setup save may
25
+ * change without a restart. Optional so a construction with no layout in
26
+ * hand gets `AGENTS.md`.
26
27
  */
27
28
  kbLayout?: () => KbLayout): express.Router;
28
29
  //# sourceMappingURL=agent-instructions.routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-instructions.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,mBAAmB;AACjC;;;;GAIG;AACH,QAAQ,CAAC,EAAE,MAAM,QAAQ,GACxB,OAAO,CAAC,MAAM,CAgBhB"}
1
+ {"version":3,"file":"agent-instructions.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,mBAAmB;AACjC;;;;;GAKG;AACH,QAAQ,CAAC,EAAE,MAAM,QAAQ,GACxB,OAAO,CAAC,MAAM,CAgBhB"}
@@ -22,8 +22,9 @@ import { composeAgentInstructions } from './compose.js';
22
22
  export function createAgentInstructionsRoutes(manualAuth, readPreamble,
23
23
  /**
24
24
  * The layout in effect, read per request — the shared file rules name the
25
- * managed guide, whose name the setup save may change without a restart.
26
- * Optional so a construction with no layout in hand gets `AGENTS.md`.
25
+ * guide by the name a deployment saved for it, which the setup save may
26
+ * change without a restart. Optional so a construction with no layout in
27
+ * hand gets `AGENTS.md`.
27
28
  */
28
29
  kbLayout) {
29
30
  const router = express.Router();
@@ -1 +1 @@
1
- {"version":3,"file":"agent-instructions.routes.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAgC,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAA0B,EAC1B,YAAiC;AACjC;;;;GAIG;AACH,QAAyB;IAEzB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAChE,uEAAuE;QACvE,uEAAuE;QACvE,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACzD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uCAAuC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"agent-instructions.routes.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAgC,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAA0B,EAC1B,YAAiC;AACjC;;;;;GAKG;AACH,QAAyB;IAEzB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAChE,uEAAuE;QACvE,uEAAuE;QACvE,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACzD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uCAAuC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -39,8 +39,10 @@ export declare const TOOL_PREFIX_LINE = "This organisation's knowledge base. Sea
39
39
  * `header` field carries and what the card shows as fixed and not editable;
40
40
  * the admin's preamble follows it.
41
41
  *
42
- * A FUNCTION of the layout, because the shared rules name the managed guide
43
- * and its file name is a deployment setting.
42
+ * A FUNCTION of the layout, because the shared rules name the platform files
43
+ * by the root names a deployment chose (`Skills/`, `Plugins/`), which are
44
+ * deployment settings. The guide's name is not one of them: it is `AGENTS.md`
45
+ * everywhere.
44
46
  */
45
47
  export declare function platformInstructions(layout: KbLayout): string;
46
48
  /**
@@ -88,10 +90,11 @@ export interface ComposedAgentInstructions {
88
90
  * unterminated `<!--` strips everything after it, so the most likely editing
89
91
  * slip withholds text rather than leaking it.
90
92
  *
91
- * `layout` decides only the guide's name inside the shared rules, and defaults
92
- * to the standard one — a caller with no layout in hand (a test, a surface that
93
- * predates the setting) gets `AGENTS.md`, which is what an unset name means
94
- * everywhere else.
93
+ * `layout` decides the root names the shared rules spell (`Skills/`,
94
+ * `Plugins/`, the knowledge folder) and defaults to the standard ones — a
95
+ * caller with no layout in hand (a test, a surface that predates the setting)
96
+ * gets the defaults. The guide's name is not among them: it is `AGENTS.md` on
97
+ * every deployment.
95
98
  */
96
99
  export declare function composeAgentInstructions(preamble: string | null, layout?: KbLayout): ComposedAgentInstructions;
97
100
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAEL,YAAY,EACZ,aAAa,EACb,eAAe,EAEf,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAExD,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,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G"}
@@ -50,8 +50,10 @@ export const TOOL_PREFIX_LINE = "This organisation's knowledge base. Search it b
50
50
  * `header` field carries and what the card shows as fixed and not editable;
51
51
  * the admin's preamble follows it.
52
52
  *
53
- * A FUNCTION of the layout, because the shared rules name the managed guide
54
- * and its file name is a deployment setting.
53
+ * A FUNCTION of the layout, because the shared rules name the platform files
54
+ * by the root names a deployment chose (`Skills/`, `Plugins/`), which are
55
+ * deployment settings. The guide's name is not one of them: it is `AGENTS.md`
56
+ * everywhere.
55
57
  */
56
58
  export function platformInstructions(layout) {
57
59
  return `${PLATFORM_HEADER}\n\n${sharedFileRulesSection(layout)}`;
@@ -76,10 +78,11 @@ export const PREAMBLE_TRUNCATION_MARKER = `[preamble truncated at ${PREAMBLE_CAP
76
78
  * unterminated `<!--` strips everything after it, so the most likely editing
77
79
  * slip withholds text rather than leaking it.
78
80
  *
79
- * `layout` decides only the guide's name inside the shared rules, and defaults
80
- * to the standard one — a caller with no layout in hand (a test, a surface that
81
- * predates the setting) gets `AGENTS.md`, which is what an unset name means
82
- * everywhere else.
81
+ * `layout` decides the root names the shared rules spell (`Skills/`,
82
+ * `Plugins/`, the knowledge folder) and defaults to the standard ones — a
83
+ * caller with no layout in hand (a test, a surface that predates the setting)
84
+ * gets the defaults. The guide's name is not among them: it is `AGENTS.md` on
85
+ * every deployment.
83
86
  */
84
87
  export function composeAgentInstructions(preamble, layout = DEFAULT_KB_LAYOUT) {
85
88
  const platform = platformInstructions(layout);
@@ -1 +1 @@
1
- {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E,QAAQ;AACR,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,iBAAiB,GAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBA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C,GAAG,CAAC;IAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { composeAgentInstructions, prefixToolDescription, platformInstructions, INSTRUCTIONS_CAP, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, type ComposedAgentInstructions, } from './compose.js';
2
- export { POINTER_GUIDE_NAME_BUDGET, SHARED_FILE_RULES_CAP, SHARED_RULES_POINTER_MAX, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, sharedRulesPointer, type SharedFileRule, } from './shared-file-rules.js';
2
+ export { SHARED_FILE_RULES_CAP, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, type SharedFileRule, } from './shared-file-rules.js';
3
3
  export { readAgentPreamble, type AgentPreambleReader, type PreambleWorkspace } from './read-preamble.js';
4
4
  export { createAgentInstructionsRoutes } from './agent-instructions.routes.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { composeAgentInstructions, prefixToolDescription, platformInstructions, INSTRUCTIONS_CAP, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, } from './compose.js';
2
- export { POINTER_GUIDE_NAME_BUDGET, SHARED_FILE_RULES_CAP, SHARED_RULES_POINTER_MAX, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, sharedRulesPointer, } from './shared-file-rules.js';
2
+ export { SHARED_FILE_RULES_CAP, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, } from './shared-file-rules.js';
3
3
  export { readAgentPreamble } from './read-preamble.js';
4
4
  export { createAgentInstructionsRoutes } from './agent-instructions.routes.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,GAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAoD,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,GAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,GAEvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAoD,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
@@ -14,19 +14,21 @@
14
14
  *
15
15
  * - the MCP `instructions` of the initialize handshake (see `compose.ts`),
16
16
  * which Claude Code, Claude Desktop and Cursor put in the system prompt;
17
- * - the platform-managed agent guide at the repository root (`AGENTS.md` by
18
- * default), rendered from `{{sharedFileRules}}` in the template — claude.ai
19
- * on the web, the Agent SDK and Cline drop `instructions`, and a guide the
20
- * agent is told to read before its first action is always available.
17
+ * - the platform's agent guide, which `get_agent_guide` returns and a
18
+ * `read_file` of the guide's name serves (see `modules/agent-guide`) —
19
+ * claude.ai on the web, the Agent SDK and Cline drop `instructions`, and a
20
+ * guide the agent is told to read before its first action is always
21
+ * available.
21
22
  *
22
23
  * Both places get the SAME string, from {@link sharedFileRulesSection} — not
23
24
  * two hand-mirrored copies. A rule written twice is a rule that drifts, and a
24
25
  * drifted rule is worse than a repeated one, because the agent cannot tell
25
- * which copy is current. Each description ends instead with
26
- * {@link sharedRulesPointer}, one sentence naming the section and the file.
26
+ * which copy is current. Each description opens instead with the one
27
+ * sentence sending the agent to the guide (`tool-registry/guide-first.ts`).
27
28
  *
28
- * Pure text, a function of the layout only: the guide's file name is a
29
- * deployment setting, so nothing here may snapshot `AGENTS.md`.
29
+ * Pure text, a function of the layout only: the guide's name is a deployment
30
+ * setting (an alias a deployment chose before the guide left the disk), so
31
+ * nothing here may snapshot `AGENTS.md`.
30
32
  */
31
33
  import { type KbLayout } from '@bevel-software/platform-shared';
32
34
  /** The heading the rules live under, in both places and in the pointer sentence. */
@@ -70,46 +72,4 @@ export declare function sharedFileRules(layout: KbLayout): readonly SharedFileRu
70
72
  * level and still reads as a block in the instructions blob.
71
73
  */
72
74
  export declare function sharedFileRulesSection(layout: KbLayout): string;
73
- /**
74
- * The longest guide file name the pointer sentence spells out. Beyond this it
75
- * names the guide by its ROLE instead (see {@link sharedRulesPointer}).
76
- *
77
- * There has to be a bound somewhere, because the pointer rides on every file
78
- * tool and a file name is not a fixed cost: `validateFilename` allows a name
79
- * of up to 255 bytes, so an unbounded pointer could reach 318 characters and
80
- * push `file_stat` to 1,428 — over the description cap, recreating on a
81
- * renamed deployment exactly the truncation this module exists to prevent, and
82
- * invisibly, because every measurement is taken under the default layout.
83
- *
84
- * 40 is well past any name a deployment plausibly picks
85
- * (`ENGINEERING-AGENT-CONVENTIONS.md` is 32) and the fallback below is only
86
- * reachable past it.
87
- */
88
- export declare const POINTER_GUIDE_NAME_BUDGET = 40;
89
- /**
90
- * The one sentence a tool description ends with, in place of the paragraphs it
91
- * used to carry. Short on purpose: it costs every description the same ~100
92
- * characters at worst, and its whole job is to name the section and the file
93
- * to read.
94
- *
95
- * BOUNDED BY CONSTRUCTION, which is what lets the description cap mean
96
- * something on a deployment that renamed its guide: a name within
97
- * {@link POINTER_GUIDE_NAME_BUDGET} is spelled out, and a longer one gets the
98
- * generic wording. Naming the file is the better sentence and wins whenever it
99
- * fits; a name past the budget is pathological, and there the choice is between
100
- * a sentence that says where to look and a catalog entry the client cuts. The
101
- * guide's own name is still in the section's first rule either way.
102
- *
103
- * An absent layout means the default one, as it does in
104
- * `composeAgentInstructions`: a caller reading the layout from configuration
105
- * gets `undefined` when none is set, and the pointer must still name a file.
106
- */
107
- export declare function sharedRulesPointer(layout?: KbLayout): string;
108
- /**
109
- * The most the pointer can ever cost a description, over every layout. What the
110
- * description cap is measured against, the way the tool prefix is measured at
111
- * ITS cap rather than at whatever the current admin wrote: a description that
112
- * only fits beside the short default guide name does not really fit.
113
- */
114
- export declare const SHARED_RULES_POINTER_MAX: number;
115
75
  //# sourceMappingURL=shared-file-rules.d.ts.map