ai-prompt-guide-mcp 1.0.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 (887) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +271 -0
  3. package/dist/__tests__/config-loading.test.d.ts +5 -0
  4. package/dist/__tests__/config-loading.test.d.ts.map +1 -0
  5. package/dist/__tests__/config-loading.test.js +127 -0
  6. package/dist/__tests__/config-loading.test.js.map +1 -0
  7. package/dist/__tests__/config-logging.test.d.ts +5 -0
  8. package/dist/__tests__/config-logging.test.d.ts.map +1 -0
  9. package/dist/__tests__/config-logging.test.js +146 -0
  10. package/dist/__tests__/config-logging.test.js.map +1 -0
  11. package/dist/__tests__/config-path-resolution.test.d.ts +5 -0
  12. package/dist/__tests__/config-path-resolution.test.d.ts.map +1 -0
  13. package/dist/__tests__/config-path-resolution.test.js +88 -0
  14. package/dist/__tests__/config-path-resolution.test.js.map +1 -0
  15. package/dist/__tests__/config-path-validation.test.d.ts +6 -0
  16. package/dist/__tests__/config-path-validation.test.d.ts.map +1 -0
  17. package/dist/__tests__/config-path-validation.test.js +203 -0
  18. package/dist/__tests__/config-path-validation.test.js.map +1 -0
  19. package/dist/__tests__/config-precedence.test.d.ts +5 -0
  20. package/dist/__tests__/config-precedence.test.d.ts.map +1 -0
  21. package/dist/__tests__/config-precedence.test.js +200 -0
  22. package/dist/__tests__/config-precedence.test.js.map +1 -0
  23. package/dist/__tests__/config-types.test.d.ts +5 -0
  24. package/dist/__tests__/config-types.test.d.ts.map +1 -0
  25. package/dist/__tests__/config-types.test.js +189 -0
  26. package/dist/__tests__/config-types.test.js.map +1 -0
  27. package/dist/__tests__/config.test.d.ts +5 -0
  28. package/dist/__tests__/config.test.d.ts.map +1 -0
  29. package/dist/__tests__/config.test.js +229 -0
  30. package/dist/__tests__/config.test.js.map +1 -0
  31. package/dist/config.d.ts +87 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +498 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/constants/defaults.d.ts +78 -0
  36. package/dist/constants/defaults.d.ts.map +1 -0
  37. package/dist/constants/defaults.js +78 -0
  38. package/dist/constants/defaults.js.map +1 -0
  39. package/dist/document-cache.d.ts +485 -0
  40. package/dist/document-cache.d.ts.map +1 -0
  41. package/dist/document-cache.hierarchical.test.d.ts +2 -0
  42. package/dist/document-cache.hierarchical.test.d.ts.map +1 -0
  43. package/dist/document-cache.hierarchical.test.js +243 -0
  44. package/dist/document-cache.hierarchical.test.js.map +1 -0
  45. package/dist/document-cache.js +965 -0
  46. package/dist/document-cache.js.map +1 -0
  47. package/dist/document-cache.test.d.ts +8 -0
  48. package/dist/document-cache.test.d.ts.map +1 -0
  49. package/dist/document-cache.test.js +624 -0
  50. package/dist/document-cache.test.js.map +1 -0
  51. package/dist/document-manager.d.ts +252 -0
  52. package/dist/document-manager.d.ts.map +1 -0
  53. package/dist/document-manager.js +760 -0
  54. package/dist/document-manager.js.map +1 -0
  55. package/dist/document-manager.race-condition.test.d.ts +8 -0
  56. package/dist/document-manager.race-condition.test.d.ts.map +1 -0
  57. package/dist/document-manager.race-condition.test.js +139 -0
  58. package/dist/document-manager.race-condition.test.js.map +1 -0
  59. package/dist/fingerprint-index.d.ts +177 -0
  60. package/dist/fingerprint-index.d.ts.map +1 -0
  61. package/dist/fingerprint-index.js +374 -0
  62. package/dist/fingerprint-index.js.map +1 -0
  63. package/dist/fingerprint-index.test.d.ts +15 -0
  64. package/dist/fingerprint-index.test.d.ts.map +1 -0
  65. package/dist/fingerprint-index.test.js +482 -0
  66. package/dist/fingerprint-index.test.js.map +1 -0
  67. package/dist/fsio.d.ts +76 -0
  68. package/dist/fsio.d.ts.map +1 -0
  69. package/dist/fsio.js +506 -0
  70. package/dist/fsio.js.map +1 -0
  71. package/dist/index.d.ts +6 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +20 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/markdown-tools.test.d.ts +5 -0
  76. package/dist/markdown-tools.test.d.ts.map +1 -0
  77. package/dist/markdown-tools.test.js +200 -0
  78. package/dist/markdown-tools.test.js.map +1 -0
  79. package/dist/parse.d.ts +19 -0
  80. package/dist/parse.d.ts.map +1 -0
  81. package/dist/parse.js +144 -0
  82. package/dist/parse.js.map +1 -0
  83. package/dist/prompts/__tests__/prompt-loader.test.d.ts +5 -0
  84. package/dist/prompts/__tests__/prompt-loader.test.d.ts.map +1 -0
  85. package/dist/prompts/__tests__/prompt-loader.test.js +300 -0
  86. package/dist/prompts/__tests__/prompt-loader.test.js.map +1 -0
  87. package/dist/prompts/prompt-loader.d.ts +58 -0
  88. package/dist/prompts/prompt-loader.d.ts.map +1 -0
  89. package/dist/prompts/prompt-loader.js +215 -0
  90. package/dist/prompts/prompt-loader.js.map +1 -0
  91. package/dist/prompts/prompt-validator.d.ts +30 -0
  92. package/dist/prompts/prompt-validator.d.ts.map +1 -0
  93. package/dist/prompts/prompt-validator.js +65 -0
  94. package/dist/prompts/prompt-validator.js.map +1 -0
  95. package/dist/prompts/types.d.ts +46 -0
  96. package/dist/prompts/types.d.ts.map +1 -0
  97. package/dist/prompts/types.js +14 -0
  98. package/dist/prompts/types.js.map +1 -0
  99. package/dist/prompts/workflow-prompts.d.ts +42 -0
  100. package/dist/prompts/workflow-prompts.d.ts.map +1 -0
  101. package/dist/prompts/workflow-prompts.js +61 -0
  102. package/dist/prompts/workflow-prompts.js.map +1 -0
  103. package/dist/sections.d.ts +67 -0
  104. package/dist/sections.d.ts.map +1 -0
  105. package/dist/sections.hierarchical.test.d.ts +8 -0
  106. package/dist/sections.hierarchical.test.d.ts.map +1 -0
  107. package/dist/sections.hierarchical.test.js +397 -0
  108. package/dist/sections.hierarchical.test.js.map +1 -0
  109. package/dist/sections.js +1229 -0
  110. package/dist/sections.js.map +1 -0
  111. package/dist/server/default-dependencies.d.ts +134 -0
  112. package/dist/server/default-dependencies.d.ts.map +1 -0
  113. package/dist/server/default-dependencies.js +176 -0
  114. package/dist/server/default-dependencies.js.map +1 -0
  115. package/dist/server/dependencies.d.ts +161 -0
  116. package/dist/server/dependencies.d.ts.map +1 -0
  117. package/dist/server/dependencies.js +50 -0
  118. package/dist/server/dependencies.js.map +1 -0
  119. package/dist/server/index.d.ts +10 -0
  120. package/dist/server/index.d.ts.map +1 -0
  121. package/dist/server/index.js +9 -0
  122. package/dist/server/index.js.map +1 -0
  123. package/dist/server/middleware/error-handling.d.ts +52 -0
  124. package/dist/server/middleware/error-handling.d.ts.map +1 -0
  125. package/dist/server/middleware/error-handling.js +76 -0
  126. package/dist/server/middleware/error-handling.js.map +1 -0
  127. package/dist/server/middleware/index.d.ts +7 -0
  128. package/dist/server/middleware/index.d.ts.map +1 -0
  129. package/dist/server/middleware/index.js +7 -0
  130. package/dist/server/middleware/index.js.map +1 -0
  131. package/dist/server/middleware/logging.d.ts +29 -0
  132. package/dist/server/middleware/logging.d.ts.map +1 -0
  133. package/dist/server/middleware/logging.js +49 -0
  134. package/dist/server/middleware/logging.js.map +1 -0
  135. package/dist/server/middleware/session-management.d.ts +38 -0
  136. package/dist/server/middleware/session-management.d.ts.map +1 -0
  137. package/dist/server/middleware/session-management.js +66 -0
  138. package/dist/server/middleware/session-management.js.map +1 -0
  139. package/dist/server/request-handlers/index.d.ts +5 -0
  140. package/dist/server/request-handlers/index.d.ts.map +1 -0
  141. package/dist/server/request-handlers/index.js +5 -0
  142. package/dist/server/request-handlers/index.js.map +1 -0
  143. package/dist/server/request-handlers/prompt-handlers.d.ts +13 -0
  144. package/dist/server/request-handlers/prompt-handlers.d.ts.map +1 -0
  145. package/dist/server/request-handlers/prompt-handlers.js +80 -0
  146. package/dist/server/request-handlers/prompt-handlers.js.map +1 -0
  147. package/dist/server/request-handlers/tool-handlers.d.ts +11 -0
  148. package/dist/server/request-handlers/tool-handlers.d.ts.map +1 -0
  149. package/dist/server/request-handlers/tool-handlers.js +85 -0
  150. package/dist/server/request-handlers/tool-handlers.js.map +1 -0
  151. package/dist/server/server-factory.d.ts +68 -0
  152. package/dist/server/server-factory.d.ts.map +1 -0
  153. package/dist/server/server-factory.js +135 -0
  154. package/dist/server/server-factory.js.map +1 -0
  155. package/dist/server/transport/stdio-transport.d.ts +9 -0
  156. package/dist/server/transport/stdio-transport.d.ts.map +1 -0
  157. package/dist/server/transport/stdio-transport.js +11 -0
  158. package/dist/server/transport/stdio-transport.js.map +1 -0
  159. package/dist/session/index.d.ts +5 -0
  160. package/dist/session/index.d.ts.map +1 -0
  161. package/dist/session/index.js +7 -0
  162. package/dist/session/index.js.map +1 -0
  163. package/dist/session/session-store.d.ts +74 -0
  164. package/dist/session/session-store.d.ts.map +1 -0
  165. package/dist/session/session-store.js +150 -0
  166. package/dist/session/session-store.js.map +1 -0
  167. package/dist/session/types.d.ts +96 -0
  168. package/dist/session/types.d.ts.map +1 -0
  169. package/dist/session/types.js +9 -0
  170. package/dist/session/types.js.map +1 -0
  171. package/dist/shared/__tests__/addressing-system.batch-cache.test.d.ts +12 -0
  172. package/dist/shared/__tests__/addressing-system.batch-cache.test.d.ts.map +1 -0
  173. package/dist/shared/__tests__/addressing-system.batch-cache.test.js +306 -0
  174. package/dist/shared/__tests__/addressing-system.batch-cache.test.js.map +1 -0
  175. package/dist/shared/__tests__/addressing-system.hierarchical.test.d.ts +6 -0
  176. package/dist/shared/__tests__/addressing-system.hierarchical.test.d.ts.map +1 -0
  177. package/dist/shared/__tests__/addressing-system.hierarchical.test.js +205 -0
  178. package/dist/shared/__tests__/addressing-system.hierarchical.test.js.map +1 -0
  179. package/dist/shared/__tests__/addressing-system.lru.test.d.ts +6 -0
  180. package/dist/shared/__tests__/addressing-system.lru.test.d.ts.map +1 -0
  181. package/dist/shared/__tests__/addressing-system.lru.test.js +159 -0
  182. package/dist/shared/__tests__/addressing-system.lru.test.js.map +1 -0
  183. package/dist/shared/__tests__/addressing-system.relative-paths.test.d.ts +14 -0
  184. package/dist/shared/__tests__/addressing-system.relative-paths.test.d.ts.map +1 -0
  185. package/dist/shared/__tests__/addressing-system.relative-paths.test.js +249 -0
  186. package/dist/shared/__tests__/addressing-system.relative-paths.test.js.map +1 -0
  187. package/dist/shared/__tests__/document-analysis-enhanced.test.d.ts +9 -0
  188. package/dist/shared/__tests__/document-analysis-enhanced.test.d.ts.map +1 -0
  189. package/dist/shared/__tests__/document-analysis-enhanced.test.js +419 -0
  190. package/dist/shared/__tests__/document-analysis-enhanced.test.js.map +1 -0
  191. package/dist/shared/__tests__/document-analysis.test.d.ts +8 -0
  192. package/dist/shared/__tests__/document-analysis.test.d.ts.map +1 -0
  193. package/dist/shared/__tests__/document-analysis.test.js +904 -0
  194. package/dist/shared/__tests__/document-analysis.test.js.map +1 -0
  195. package/dist/shared/__tests__/keyword-utils-integration.test.d.ts +9 -0
  196. package/dist/shared/__tests__/keyword-utils-integration.test.d.ts.map +1 -0
  197. package/dist/shared/__tests__/keyword-utils-integration.test.js +317 -0
  198. package/dist/shared/__tests__/keyword-utils-integration.test.js.map +1 -0
  199. package/dist/shared/__tests__/link-utils.test.d.ts +5 -0
  200. package/dist/shared/__tests__/link-utils.test.d.ts.map +1 -0
  201. package/dist/shared/__tests__/link-utils.test.js +560 -0
  202. package/dist/shared/__tests__/link-utils.test.js.map +1 -0
  203. package/dist/shared/__tests__/link-validation.test.d.ts +5 -0
  204. package/dist/shared/__tests__/link-validation.test.d.ts.map +1 -0
  205. package/dist/shared/__tests__/link-validation.test.js +473 -0
  206. package/dist/shared/__tests__/link-validation.test.js.map +1 -0
  207. package/dist/shared/__tests__/reference-extractor.test.d.ts +8 -0
  208. package/dist/shared/__tests__/reference-extractor.test.d.ts.map +1 -0
  209. package/dist/shared/__tests__/reference-extractor.test.js +260 -0
  210. package/dist/shared/__tests__/reference-extractor.test.js.map +1 -0
  211. package/dist/shared/__tests__/reference-loader.test.d.ts +8 -0
  212. package/dist/shared/__tests__/reference-loader.test.d.ts.map +1 -0
  213. package/dist/shared/__tests__/reference-loader.test.js +622 -0
  214. package/dist/shared/__tests__/reference-loader.test.js.map +1 -0
  215. package/dist/shared/__tests__/section-operations.append.test.d.ts +8 -0
  216. package/dist/shared/__tests__/section-operations.append.test.d.ts.map +1 -0
  217. package/dist/shared/__tests__/section-operations.append.test.js +150 -0
  218. package/dist/shared/__tests__/section-operations.append.test.js.map +1 -0
  219. package/dist/shared/__tests__/section-operations.test.d.ts +7 -0
  220. package/dist/shared/__tests__/section-operations.test.d.ts.map +1 -0
  221. package/dist/shared/__tests__/section-operations.test.js +118 -0
  222. package/dist/shared/__tests__/section-operations.test.js.map +1 -0
  223. package/dist/shared/__tests__/slug-utils.test.d.ts +5 -0
  224. package/dist/shared/__tests__/slug-utils.test.d.ts.map +1 -0
  225. package/dist/shared/__tests__/slug-utils.test.js +542 -0
  226. package/dist/shared/__tests__/slug-utils.test.js.map +1 -0
  227. package/dist/shared/__tests__/task-operations.test.d.ts +9 -0
  228. package/dist/shared/__tests__/task-operations.test.d.ts.map +1 -0
  229. package/dist/shared/__tests__/task-operations.test.js +257 -0
  230. package/dist/shared/__tests__/task-operations.test.js.map +1 -0
  231. package/dist/shared/__tests__/task-validation.test.d.ts +6 -0
  232. package/dist/shared/__tests__/task-validation.test.d.ts.map +1 -0
  233. package/dist/shared/__tests__/task-validation.test.js +129 -0
  234. package/dist/shared/__tests__/task-validation.test.js.map +1 -0
  235. package/dist/shared/__tests__/task-view-utilities.test.d.ts +5 -0
  236. package/dist/shared/__tests__/task-view-utilities.test.d.ts.map +1 -0
  237. package/dist/shared/__tests__/task-view-utilities.test.js +312 -0
  238. package/dist/shared/__tests__/task-view-utilities.test.js.map +1 -0
  239. package/dist/shared/__tests__/tool-integration.array-validation.test.d.ts +7 -0
  240. package/dist/shared/__tests__/tool-integration.array-validation.test.d.ts.map +1 -0
  241. package/dist/shared/__tests__/tool-integration.array-validation.test.js +169 -0
  242. package/dist/shared/__tests__/tool-integration.array-validation.test.js.map +1 -0
  243. package/dist/shared/__tests__/tool-integration.hierarchical.test.d.ts +7 -0
  244. package/dist/shared/__tests__/tool-integration.hierarchical.test.d.ts.map +1 -0
  245. package/dist/shared/__tests__/tool-integration.hierarchical.test.js +204 -0
  246. package/dist/shared/__tests__/tool-integration.hierarchical.test.js.map +1 -0
  247. package/dist/shared/__tests__/workflow-prompt-utilities.test.d.ts +8 -0
  248. package/dist/shared/__tests__/workflow-prompt-utilities.test.d.ts.map +1 -0
  249. package/dist/shared/__tests__/workflow-prompt-utilities.test.js +722 -0
  250. package/dist/shared/__tests__/workflow-prompt-utilities.test.js.map +1 -0
  251. package/dist/shared/addressing-system.d.ts +799 -0
  252. package/dist/shared/addressing-system.d.ts.map +1 -0
  253. package/dist/shared/addressing-system.js +1074 -0
  254. package/dist/shared/addressing-system.js.map +1 -0
  255. package/dist/shared/document-analysis/__tests__/keyword-utils.test.d.ts +8 -0
  256. package/dist/shared/document-analysis/__tests__/keyword-utils.test.d.ts.map +1 -0
  257. package/dist/shared/document-analysis/__tests__/keyword-utils.test.js +601 -0
  258. package/dist/shared/document-analysis/__tests__/keyword-utils.test.js.map +1 -0
  259. package/dist/shared/document-analysis/index.d.ts +67 -0
  260. package/dist/shared/document-analysis/index.d.ts.map +1 -0
  261. package/dist/shared/document-analysis/index.js +166 -0
  262. package/dist/shared/document-analysis/index.js.map +1 -0
  263. package/dist/shared/document-analysis/keyword-utils.d.ts +405 -0
  264. package/dist/shared/document-analysis/keyword-utils.d.ts.map +1 -0
  265. package/dist/shared/document-analysis/keyword-utils.js +1147 -0
  266. package/dist/shared/document-analysis/keyword-utils.js.map +1 -0
  267. package/dist/shared/document-analysis/reference-validation.d.ts +27 -0
  268. package/dist/shared/document-analysis/reference-validation.d.ts.map +1 -0
  269. package/dist/shared/document-analysis/reference-validation.js +173 -0
  270. package/dist/shared/document-analysis/reference-validation.js.map +1 -0
  271. package/dist/shared/document-analysis/related-docs.d.ts +27 -0
  272. package/dist/shared/document-analysis/related-docs.d.ts.map +1 -0
  273. package/dist/shared/document-analysis/related-docs.js +459 -0
  274. package/dist/shared/document-analysis/related-docs.js.map +1 -0
  275. package/dist/shared/document-analysis/types.d.ts +89 -0
  276. package/dist/shared/document-analysis/types.d.ts.map +1 -0
  277. package/dist/shared/document-analysis/types.js +41 -0
  278. package/dist/shared/document-analysis/types.js.map +1 -0
  279. package/dist/shared/document-analysis.d.ts +15 -0
  280. package/dist/shared/document-analysis.d.ts.map +1 -0
  281. package/dist/shared/document-analysis.js +16 -0
  282. package/dist/shared/document-analysis.js.map +1 -0
  283. package/dist/shared/document-manager-factory.d.ts +32 -0
  284. package/dist/shared/document-manager-factory.d.ts.map +1 -0
  285. package/dist/shared/document-manager-factory.js +75 -0
  286. package/dist/shared/document-manager-factory.js.map +1 -0
  287. package/dist/shared/index.d.ts +5 -0
  288. package/dist/shared/index.d.ts.map +1 -0
  289. package/dist/shared/index.js +7 -0
  290. package/dist/shared/index.js.map +1 -0
  291. package/dist/shared/link-analysis.d.ts +84 -0
  292. package/dist/shared/link-analysis.d.ts.map +1 -0
  293. package/dist/shared/link-analysis.js +213 -0
  294. package/dist/shared/link-analysis.js.map +1 -0
  295. package/dist/shared/link-context.d.ts +23 -0
  296. package/dist/shared/link-context.d.ts.map +1 -0
  297. package/dist/shared/link-context.js +172 -0
  298. package/dist/shared/link-context.js.map +1 -0
  299. package/dist/shared/link-utils.d.ts +33 -0
  300. package/dist/shared/link-utils.d.ts.map +1 -0
  301. package/dist/shared/link-utils.js +301 -0
  302. package/dist/shared/link-utils.js.map +1 -0
  303. package/dist/shared/link-validation.d.ts +79 -0
  304. package/dist/shared/link-validation.d.ts.map +1 -0
  305. package/dist/shared/link-validation.js +340 -0
  306. package/dist/shared/link-validation.js.map +1 -0
  307. package/dist/shared/namespace-analysis.d.ts +10 -0
  308. package/dist/shared/namespace-analysis.d.ts.map +1 -0
  309. package/dist/shared/namespace-analysis.js +100 -0
  310. package/dist/shared/namespace-analysis.js.map +1 -0
  311. package/dist/shared/namespace-constants.d.ts +69 -0
  312. package/dist/shared/namespace-constants.d.ts.map +1 -0
  313. package/dist/shared/namespace-constants.js +97 -0
  314. package/dist/shared/namespace-constants.js.map +1 -0
  315. package/dist/shared/path-utilities.d.ts +13 -0
  316. package/dist/shared/path-utilities.d.ts.map +1 -0
  317. package/dist/shared/path-utilities.js +39 -0
  318. package/dist/shared/path-utilities.js.map +1 -0
  319. package/dist/shared/reference-extractor.d.ts +121 -0
  320. package/dist/shared/reference-extractor.d.ts.map +1 -0
  321. package/dist/shared/reference-extractor.js +195 -0
  322. package/dist/shared/reference-extractor.js.map +1 -0
  323. package/dist/shared/reference-loader.d.ts +163 -0
  324. package/dist/shared/reference-loader.d.ts.map +1 -0
  325. package/dist/shared/reference-loader.js +265 -0
  326. package/dist/shared/reference-loader.js.map +1 -0
  327. package/dist/shared/section-operations.d.ts +14 -0
  328. package/dist/shared/section-operations.d.ts.map +1 -0
  329. package/dist/shared/section-operations.js +115 -0
  330. package/dist/shared/section-operations.js.map +1 -0
  331. package/dist/shared/slug-utils.d.ts +109 -0
  332. package/dist/shared/slug-utils.d.ts.map +1 -0
  333. package/dist/shared/slug-utils.js +302 -0
  334. package/dist/shared/slug-utils.js.map +1 -0
  335. package/dist/shared/task-operations.d.ts +152 -0
  336. package/dist/shared/task-operations.d.ts.map +1 -0
  337. package/dist/shared/task-operations.js +416 -0
  338. package/dist/shared/task-operations.js.map +1 -0
  339. package/dist/shared/task-utilities.d.ts +63 -0
  340. package/dist/shared/task-utilities.d.ts.map +1 -0
  341. package/dist/shared/task-utilities.js +86 -0
  342. package/dist/shared/task-utilities.js.map +1 -0
  343. package/dist/shared/task-validation.d.ts +50 -0
  344. package/dist/shared/task-validation.d.ts.map +1 -0
  345. package/dist/shared/task-validation.js +97 -0
  346. package/dist/shared/task-validation.js.map +1 -0
  347. package/dist/shared/task-view-utilities.d.ts +109 -0
  348. package/dist/shared/task-view-utilities.d.ts.map +1 -0
  349. package/dist/shared/task-view-utilities.js +255 -0
  350. package/dist/shared/task-view-utilities.js.map +1 -0
  351. package/dist/shared/utilities.d.ts +14 -0
  352. package/dist/shared/utilities.d.ts.map +1 -0
  353. package/dist/shared/utilities.js +23 -0
  354. package/dist/shared/utilities.js.map +1 -0
  355. package/dist/shared/utilities.test.d.ts +5 -0
  356. package/dist/shared/utilities.test.d.ts.map +1 -0
  357. package/dist/shared/utilities.test.js +422 -0
  358. package/dist/shared/utilities.test.js.map +1 -0
  359. package/dist/shared/validation-utils.d.ts +57 -0
  360. package/dist/shared/validation-utils.d.ts.map +1 -0
  361. package/dist/shared/validation-utils.js +63 -0
  362. package/dist/shared/validation-utils.js.map +1 -0
  363. package/dist/shared/workflow-prompt-utilities.d.ts +64 -0
  364. package/dist/shared/workflow-prompt-utilities.d.ts.map +1 -0
  365. package/dist/shared/workflow-prompt-utilities.js +163 -0
  366. package/dist/shared/workflow-prompt-utilities.js.map +1 -0
  367. package/dist/slug.d.ts +9 -0
  368. package/dist/slug.d.ts.map +1 -0
  369. package/dist/slug.js +40 -0
  370. package/dist/slug.js.map +1 -0
  371. package/dist/template-loader.d.ts +6 -0
  372. package/dist/template-loader.d.ts.map +1 -0
  373. package/dist/template-loader.js +8 -0
  374. package/dist/template-loader.js.map +1 -0
  375. package/dist/tools/__tests__/create-document-self-reference.test.d.ts +2 -0
  376. package/dist/tools/__tests__/create-document-self-reference.test.d.ts.map +1 -0
  377. package/dist/tools/__tests__/create-document-self-reference.test.js +124 -0
  378. package/dist/tools/__tests__/create-document-self-reference.test.js.map +1 -0
  379. package/dist/tools/__tests__/create-document-workflow-regression.test.d.ts +16 -0
  380. package/dist/tools/__tests__/create-document-workflow-regression.test.d.ts.map +1 -0
  381. package/dist/tools/__tests__/create-document-workflow-regression.test.js +655 -0
  382. package/dist/tools/__tests__/create-document-workflow-regression.test.js.map +1 -0
  383. package/dist/tools/__tests__/create-document.test.d.ts +2 -0
  384. package/dist/tools/__tests__/create-document.test.d.ts.map +1 -0
  385. package/dist/tools/__tests__/create-document.test.js +255 -0
  386. package/dist/tools/__tests__/create-document.test.js.map +1 -0
  387. package/dist/tools/__tests__/delete-document.test.d.ts +7 -0
  388. package/dist/tools/__tests__/delete-document.test.d.ts.map +1 -0
  389. package/dist/tools/__tests__/delete-document.test.js +311 -0
  390. package/dist/tools/__tests__/delete-document.test.js.map +1 -0
  391. package/dist/tools/__tests__/edit-document.test.d.ts +2 -0
  392. package/dist/tools/__tests__/edit-document.test.d.ts.map +1 -0
  393. package/dist/tools/__tests__/edit-document.test.js +644 -0
  394. package/dist/tools/__tests__/edit-document.test.js.map +1 -0
  395. package/dist/tools/__tests__/error-scenarios.test.d.ts +5 -0
  396. package/dist/tools/__tests__/error-scenarios.test.d.ts.map +1 -0
  397. package/dist/tools/__tests__/error-scenarios.test.js +105 -0
  398. package/dist/tools/__tests__/error-scenarios.test.js.map +1 -0
  399. package/dist/tools/__tests__/mocks/document-manager.mock.d.ts +99 -0
  400. package/dist/tools/__tests__/mocks/document-manager.mock.d.ts.map +1 -0
  401. package/dist/tools/__tests__/mocks/document-manager.mock.js +457 -0
  402. package/dist/tools/__tests__/mocks/document-manager.mock.js.map +1 -0
  403. package/dist/tools/__tests__/mocks/filesystem.mock.d.ts +103 -0
  404. package/dist/tools/__tests__/mocks/filesystem.mock.d.ts.map +1 -0
  405. package/dist/tools/__tests__/mocks/filesystem.mock.js +247 -0
  406. package/dist/tools/__tests__/mocks/filesystem.mock.js.map +1 -0
  407. package/dist/tools/__tests__/move-document.test.d.ts +12 -0
  408. package/dist/tools/__tests__/move-document.test.d.ts.map +1 -0
  409. package/dist/tools/__tests__/move-document.test.js +214 -0
  410. package/dist/tools/__tests__/move-document.test.js.map +1 -0
  411. package/dist/tools/__tests__/move.test.d.ts +13 -0
  412. package/dist/tools/__tests__/move.test.d.ts.map +1 -0
  413. package/dist/tools/__tests__/move.test.js +939 -0
  414. package/dist/tools/__tests__/move.test.js.map +1 -0
  415. package/dist/tools/__tests__/section.integration.improved.test.d.ts +5 -0
  416. package/dist/tools/__tests__/section.integration.improved.test.d.ts.map +1 -0
  417. package/dist/tools/__tests__/section.integration.improved.test.js +199 -0
  418. package/dist/tools/__tests__/section.integration.improved.test.js.map +1 -0
  419. package/dist/tools/__tests__/section.integration.test.d.ts +5 -0
  420. package/dist/tools/__tests__/section.integration.test.d.ts.map +1 -0
  421. package/dist/tools/__tests__/section.integration.test.js +637 -0
  422. package/dist/tools/__tests__/section.integration.test.js.map +1 -0
  423. package/dist/tools/__tests__/setup/test-environment.d.ts +111 -0
  424. package/dist/tools/__tests__/setup/test-environment.d.ts.map +1 -0
  425. package/dist/tools/__tests__/setup/test-environment.js +322 -0
  426. package/dist/tools/__tests__/setup/test-environment.js.map +1 -0
  427. package/dist/tools/__tests__/suggestion-generator.test.d.ts +8 -0
  428. package/dist/tools/__tests__/suggestion-generator.test.d.ts.map +1 -0
  429. package/dist/tools/__tests__/suggestion-generator.test.js +508 -0
  430. package/dist/tools/__tests__/suggestion-generator.test.js.map +1 -0
  431. package/dist/tools/__tests__/task-consistency.test.d.ts +11 -0
  432. package/dist/tools/__tests__/task-consistency.test.d.ts.map +1 -0
  433. package/dist/tools/__tests__/task-consistency.test.js +93 -0
  434. package/dist/tools/__tests__/task-consistency.test.js.map +1 -0
  435. package/dist/tools/__tests__/task-status-parsing.test.d.ts +15 -0
  436. package/dist/tools/__tests__/task-status-parsing.test.d.ts.map +1 -0
  437. package/dist/tools/__tests__/task-status-parsing.test.js +126 -0
  438. package/dist/tools/__tests__/task-status-parsing.test.js.map +1 -0
  439. package/dist/tools/__tests__/view-section-boundary.test.d.ts +2 -0
  440. package/dist/tools/__tests__/view-section-boundary.test.d.ts.map +1 -0
  441. package/dist/tools/__tests__/view-section-boundary.test.js +132 -0
  442. package/dist/tools/__tests__/view-section-boundary.test.js.map +1 -0
  443. package/dist/tools/__tests__/write-operations-integration.test.d.ts +8 -0
  444. package/dist/tools/__tests__/write-operations-integration.test.d.ts.map +1 -0
  445. package/dist/tools/__tests__/write-operations-integration.test.js +136 -0
  446. package/dist/tools/__tests__/write-operations-integration.test.js.map +1 -0
  447. package/dist/tools/browse/content-analyzer.d.ts +27 -0
  448. package/dist/tools/browse/content-analyzer.d.ts.map +1 -0
  449. package/dist/tools/browse/content-analyzer.js +150 -0
  450. package/dist/tools/browse/content-analyzer.js.map +1 -0
  451. package/dist/tools/browse/dependency-analyzer.d.ts +63 -0
  452. package/dist/tools/browse/dependency-analyzer.d.ts.map +1 -0
  453. package/dist/tools/browse/dependency-analyzer.js +261 -0
  454. package/dist/tools/browse/dependency-analyzer.js.map +1 -0
  455. package/dist/tools/browse/folder-navigator.d.ts +35 -0
  456. package/dist/tools/browse/folder-navigator.d.ts.map +1 -0
  457. package/dist/tools/browse/folder-navigator.js +154 -0
  458. package/dist/tools/browse/folder-navigator.js.map +1 -0
  459. package/dist/tools/browse/index.d.ts +10 -0
  460. package/dist/tools/browse/index.d.ts.map +1 -0
  461. package/dist/tools/browse/index.js +14 -0
  462. package/dist/tools/browse/index.js.map +1 -0
  463. package/dist/tools/browse/relationship-classifier.d.ts +9 -0
  464. package/dist/tools/browse/relationship-classifier.d.ts.map +1 -0
  465. package/dist/tools/browse/relationship-classifier.js +38 -0
  466. package/dist/tools/browse/relationship-classifier.js.map +1 -0
  467. package/dist/tools/browse/search-engine.d.ts +69 -0
  468. package/dist/tools/browse/search-engine.d.ts.map +1 -0
  469. package/dist/tools/browse/search-engine.js +197 -0
  470. package/dist/tools/browse/search-engine.js.map +1 -0
  471. package/dist/tools/create/__tests__/file-creator.test.d.ts +6 -0
  472. package/dist/tools/create/__tests__/file-creator.test.d.ts.map +1 -0
  473. package/dist/tools/create/__tests__/file-creator.test.js +138 -0
  474. package/dist/tools/create/__tests__/file-creator.test.js.map +1 -0
  475. package/dist/tools/create/__tests__/template-processor.test.d.ts +6 -0
  476. package/dist/tools/create/__tests__/template-processor.test.d.ts.map +1 -0
  477. package/dist/tools/create/__tests__/template-processor.test.js +130 -0
  478. package/dist/tools/create/__tests__/template-processor.test.js.map +1 -0
  479. package/dist/tools/create/file-creator.d.ts +35 -0
  480. package/dist/tools/create/file-creator.d.ts.map +1 -0
  481. package/dist/tools/create/file-creator.js +103 -0
  482. package/dist/tools/create/file-creator.js.map +1 -0
  483. package/dist/tools/create/index.d.ts +6 -0
  484. package/dist/tools/create/index.d.ts.map +1 -0
  485. package/dist/tools/create/index.js +7 -0
  486. package/dist/tools/create/index.js.map +1 -0
  487. package/dist/tools/create/pipeline.d.ts +39 -0
  488. package/dist/tools/create/pipeline.d.ts.map +1 -0
  489. package/dist/tools/create/pipeline.js +112 -0
  490. package/dist/tools/create/pipeline.js.map +1 -0
  491. package/dist/tools/create/suggestion-generator.d.ts +47 -0
  492. package/dist/tools/create/suggestion-generator.d.ts.map +1 -0
  493. package/dist/tools/create/suggestion-generator.js +51 -0
  494. package/dist/tools/create/suggestion-generator.js.map +1 -0
  495. package/dist/tools/create/template-processor.d.ts +27 -0
  496. package/dist/tools/create/template-processor.d.ts.map +1 -0
  497. package/dist/tools/create/template-processor.js +74 -0
  498. package/dist/tools/create/template-processor.js.map +1 -0
  499. package/dist/tools/create/validation-processor.d.ts +48 -0
  500. package/dist/tools/create/validation-processor.d.ts.map +1 -0
  501. package/dist/tools/create/validation-processor.js +107 -0
  502. package/dist/tools/create/validation-processor.js.map +1 -0
  503. package/dist/tools/executor.d.ts +19 -0
  504. package/dist/tools/executor.d.ts.map +1 -0
  505. package/dist/tools/executor.js +53 -0
  506. package/dist/tools/executor.js.map +1 -0
  507. package/dist/tools/implementations/__tests__/browse-documents.test.d.ts +8 -0
  508. package/dist/tools/implementations/__tests__/browse-documents.test.d.ts.map +1 -0
  509. package/dist/tools/implementations/__tests__/browse-documents.test.js +319 -0
  510. package/dist/tools/implementations/__tests__/browse-documents.test.js.map +1 -0
  511. package/dist/tools/implementations/__tests__/complete-coordinator-task.test.d.ts +7 -0
  512. package/dist/tools/implementations/__tests__/complete-coordinator-task.test.d.ts.map +1 -0
  513. package/dist/tools/implementations/__tests__/complete-coordinator-task.test.js +440 -0
  514. package/dist/tools/implementations/__tests__/complete-coordinator-task.test.js.map +1 -0
  515. package/dist/tools/implementations/__tests__/complete-subagent-task.test.d.ts +14 -0
  516. package/dist/tools/implementations/__tests__/complete-subagent-task.test.d.ts.map +1 -0
  517. package/dist/tools/implementations/__tests__/complete-subagent-task.test.js +851 -0
  518. package/dist/tools/implementations/__tests__/complete-subagent-task.test.js.map +1 -0
  519. package/dist/tools/implementations/__tests__/complete-task-notes.test.d.ts +6 -0
  520. package/dist/tools/implementations/__tests__/complete-task-notes.test.d.ts.map +1 -0
  521. package/dist/tools/implementations/__tests__/complete-task-notes.test.js +157 -0
  522. package/dist/tools/implementations/__tests__/complete-task-notes.test.js.map +1 -0
  523. package/dist/tools/implementations/__tests__/complete-task.test.d.ts +14 -0
  524. package/dist/tools/implementations/__tests__/complete-task.test.d.ts.map +1 -0
  525. package/dist/tools/implementations/__tests__/complete-task.test.js +867 -0
  526. package/dist/tools/implementations/__tests__/complete-task.test.js.map +1 -0
  527. package/dist/tools/implementations/__tests__/continue-task.test.d.ts +11 -0
  528. package/dist/tools/implementations/__tests__/continue-task.test.d.ts.map +1 -0
  529. package/dist/tools/implementations/__tests__/continue-task.test.js +845 -0
  530. package/dist/tools/implementations/__tests__/continue-task.test.js.map +1 -0
  531. package/dist/tools/implementations/__tests__/coordinator-task.test.d.ts +7 -0
  532. package/dist/tools/implementations/__tests__/coordinator-task.test.d.ts.map +1 -0
  533. package/dist/tools/implementations/__tests__/coordinator-task.test.js +495 -0
  534. package/dist/tools/implementations/__tests__/coordinator-task.test.js.map +1 -0
  535. package/dist/tools/implementations/__tests__/get-guide.test.d.ts +8 -0
  536. package/dist/tools/implementations/__tests__/get-guide.test.d.ts.map +1 -0
  537. package/dist/tools/implementations/__tests__/get-guide.test.js +242 -0
  538. package/dist/tools/implementations/__tests__/get-guide.test.js.map +1 -0
  539. package/dist/tools/implementations/__tests__/get-workflow.test.d.ts +8 -0
  540. package/dist/tools/implementations/__tests__/get-workflow.test.d.ts.map +1 -0
  541. package/dist/tools/implementations/__tests__/get-workflow.test.js +232 -0
  542. package/dist/tools/implementations/__tests__/get-workflow.test.js.map +1 -0
  543. package/dist/tools/implementations/__tests__/search-documents.test.d.ts +8 -0
  544. package/dist/tools/implementations/__tests__/search-documents.test.d.ts.map +1 -0
  545. package/dist/tools/implementations/__tests__/search-documents.test.js +336 -0
  546. package/dist/tools/implementations/__tests__/search-documents.test.js.map +1 -0
  547. package/dist/tools/implementations/__tests__/start-coordinator-task.test.d.ts +7 -0
  548. package/dist/tools/implementations/__tests__/start-coordinator-task.test.d.ts.map +1 -0
  549. package/dist/tools/implementations/__tests__/start-coordinator-task.test.js +177 -0
  550. package/dist/tools/implementations/__tests__/start-coordinator-task.test.js.map +1 -0
  551. package/dist/tools/implementations/__tests__/start-subagent-task.test.d.ts +11 -0
  552. package/dist/tools/implementations/__tests__/start-subagent-task.test.d.ts.map +1 -0
  553. package/dist/tools/implementations/__tests__/start-subagent-task.test.js +846 -0
  554. package/dist/tools/implementations/__tests__/start-subagent-task.test.js.map +1 -0
  555. package/dist/tools/implementations/__tests__/start-task.test.d.ts +11 -0
  556. package/dist/tools/implementations/__tests__/start-task.test.d.ts.map +1 -0
  557. package/dist/tools/implementations/__tests__/start-task.test.js +828 -0
  558. package/dist/tools/implementations/__tests__/start-task.test.js.map +1 -0
  559. package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.d.ts +8 -0
  560. package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.d.ts.map +1 -0
  561. package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.js +199 -0
  562. package/dist/tools/implementations/__tests__/subagent-task-batch-operations.test.js.map +1 -0
  563. package/dist/tools/implementations/__tests__/subagent-task.test.d.ts +7 -0
  564. package/dist/tools/implementations/__tests__/subagent-task.test.d.ts.map +1 -0
  565. package/dist/tools/implementations/__tests__/subagent-task.test.js +720 -0
  566. package/dist/tools/implementations/__tests__/subagent-task.test.js.map +1 -0
  567. package/dist/tools/implementations/__tests__/task-batch-operations.test.d.ts +8 -0
  568. package/dist/tools/implementations/__tests__/task-batch-operations.test.d.ts.map +1 -0
  569. package/dist/tools/implementations/__tests__/task-batch-operations.test.js +200 -0
  570. package/dist/tools/implementations/__tests__/task-batch-operations.test.js.map +1 -0
  571. package/dist/tools/implementations/__tests__/task.test.d.ts +7 -0
  572. package/dist/tools/implementations/__tests__/task.test.d.ts.map +1 -0
  573. package/dist/tools/implementations/__tests__/task.test.js +578 -0
  574. package/dist/tools/implementations/__tests__/task.test.js.map +1 -0
  575. package/dist/tools/implementations/__tests__/view-coordinator-task.test.d.ts +13 -0
  576. package/dist/tools/implementations/__tests__/view-coordinator-task.test.d.ts.map +1 -0
  577. package/dist/tools/implementations/__tests__/view-coordinator-task.test.js +1404 -0
  578. package/dist/tools/implementations/__tests__/view-coordinator-task.test.js.map +1 -0
  579. package/dist/tools/implementations/__tests__/view-document.linked-context.test.d.ts +8 -0
  580. package/dist/tools/implementations/__tests__/view-document.linked-context.test.d.ts.map +1 -0
  581. package/dist/tools/implementations/__tests__/view-document.linked-context.test.js +235 -0
  582. package/dist/tools/implementations/__tests__/view-document.linked-context.test.js.map +1 -0
  583. package/dist/tools/implementations/__tests__/view-document.simplification.test.d.ts +9 -0
  584. package/dist/tools/implementations/__tests__/view-document.simplification.test.d.ts.map +1 -0
  585. package/dist/tools/implementations/__tests__/view-document.simplification.test.js +160 -0
  586. package/dist/tools/implementations/__tests__/view-document.simplification.test.js.map +1 -0
  587. package/dist/tools/implementations/__tests__/view-task.test.d.ts +12 -0
  588. package/dist/tools/implementations/__tests__/view-task.test.d.ts.map +1 -0
  589. package/dist/tools/implementations/__tests__/view-task.test.js +1158 -0
  590. package/dist/tools/implementations/__tests__/view-task.test.js.map +1 -0
  591. package/dist/tools/implementations/browse-documents.d.ts +36 -0
  592. package/dist/tools/implementations/browse-documents.d.ts.map +1 -0
  593. package/dist/tools/implementations/browse-documents.js +123 -0
  594. package/dist/tools/implementations/browse-documents.js.map +1 -0
  595. package/dist/tools/implementations/complete-coordinator-task.d.ts +53 -0
  596. package/dist/tools/implementations/complete-coordinator-task.d.ts.map +1 -0
  597. package/dist/tools/implementations/complete-coordinator-task.js +159 -0
  598. package/dist/tools/implementations/complete-coordinator-task.js.map +1 -0
  599. package/dist/tools/implementations/complete-subagent-task.d.ts +47 -0
  600. package/dist/tools/implementations/complete-subagent-task.d.ts.map +1 -0
  601. package/dist/tools/implementations/complete-subagent-task.js +141 -0
  602. package/dist/tools/implementations/complete-subagent-task.js.map +1 -0
  603. package/dist/tools/implementations/complete-task.d.ts +32 -0
  604. package/dist/tools/implementations/complete-task.d.ts.map +1 -0
  605. package/dist/tools/implementations/complete-task.hierarchical.test.d.ts +8 -0
  606. package/dist/tools/implementations/complete-task.hierarchical.test.d.ts.map +1 -0
  607. package/dist/tools/implementations/complete-task.hierarchical.test.js +363 -0
  608. package/dist/tools/implementations/complete-task.hierarchical.test.js.map +1 -0
  609. package/dist/tools/implementations/complete-task.js +122 -0
  610. package/dist/tools/implementations/complete-task.js.map +1 -0
  611. package/dist/tools/implementations/continue-task.d.ts +48 -0
  612. package/dist/tools/implementations/continue-task.d.ts.map +1 -0
  613. package/dist/tools/implementations/continue-task.js +167 -0
  614. package/dist/tools/implementations/continue-task.js.map +1 -0
  615. package/dist/tools/implementations/coordinator-task.d.ts +72 -0
  616. package/dist/tools/implementations/coordinator-task.d.ts.map +1 -0
  617. package/dist/tools/implementations/coordinator-task.js +169 -0
  618. package/dist/tools/implementations/coordinator-task.js.map +1 -0
  619. package/dist/tools/implementations/create-document.d.ts +12 -0
  620. package/dist/tools/implementations/create-document.d.ts.map +1 -0
  621. package/dist/tools/implementations/create-document.js +15 -0
  622. package/dist/tools/implementations/create-document.js.map +1 -0
  623. package/dist/tools/implementations/delete-document.d.ts +16 -0
  624. package/dist/tools/implementations/delete-document.d.ts.map +1 -0
  625. package/dist/tools/implementations/delete-document.js +70 -0
  626. package/dist/tools/implementations/delete-document.js.map +1 -0
  627. package/dist/tools/implementations/edit-document.d.ts +8 -0
  628. package/dist/tools/implementations/edit-document.d.ts.map +1 -0
  629. package/dist/tools/implementations/edit-document.js +118 -0
  630. package/dist/tools/implementations/edit-document.js.map +1 -0
  631. package/dist/tools/implementations/get-guide.d.ts +13 -0
  632. package/dist/tools/implementations/get-guide.d.ts.map +1 -0
  633. package/dist/tools/implementations/get-guide.js +64 -0
  634. package/dist/tools/implementations/get-guide.js.map +1 -0
  635. package/dist/tools/implementations/get-workflow.d.ts +12 -0
  636. package/dist/tools/implementations/get-workflow.d.ts.map +1 -0
  637. package/dist/tools/implementations/get-workflow.js +71 -0
  638. package/dist/tools/implementations/get-workflow.js.map +1 -0
  639. package/dist/tools/implementations/index.d.ts +24 -0
  640. package/dist/tools/implementations/index.d.ts.map +1 -0
  641. package/dist/tools/implementations/index.js +24 -0
  642. package/dist/tools/implementations/index.js.map +1 -0
  643. package/dist/tools/implementations/manage-document.d.ts +8 -0
  644. package/dist/tools/implementations/manage-document.d.ts.map +1 -0
  645. package/dist/tools/implementations/manage-document.js +180 -0
  646. package/dist/tools/implementations/manage-document.js.map +1 -0
  647. package/dist/tools/implementations/move-document.d.ts +12 -0
  648. package/dist/tools/implementations/move-document.d.ts.map +1 -0
  649. package/dist/tools/implementations/move-document.js +72 -0
  650. package/dist/tools/implementations/move-document.js.map +1 -0
  651. package/dist/tools/implementations/move.d.ts +24 -0
  652. package/dist/tools/implementations/move.d.ts.map +1 -0
  653. package/dist/tools/implementations/move.js +167 -0
  654. package/dist/tools/implementations/move.js.map +1 -0
  655. package/dist/tools/implementations/search-documents.d.ts +39 -0
  656. package/dist/tools/implementations/search-documents.d.ts.map +1 -0
  657. package/dist/tools/implementations/search-documents.js +246 -0
  658. package/dist/tools/implementations/search-documents.js.map +1 -0
  659. package/dist/tools/implementations/section.d.ts +42 -0
  660. package/dist/tools/implementations/section.d.ts.map +1 -0
  661. package/dist/tools/implementations/section.hierarchical.test.d.ts +8 -0
  662. package/dist/tools/implementations/section.hierarchical.test.d.ts.map +1 -0
  663. package/dist/tools/implementations/section.hierarchical.test.js +299 -0
  664. package/dist/tools/implementations/section.hierarchical.test.js.map +1 -0
  665. package/dist/tools/implementations/section.js +244 -0
  666. package/dist/tools/implementations/section.js.map +1 -0
  667. package/dist/tools/implementations/section.test.d.ts +5 -0
  668. package/dist/tools/implementations/section.test.d.ts.map +1 -0
  669. package/dist/tools/implementations/section.test.js +371 -0
  670. package/dist/tools/implementations/section.test.js.map +1 -0
  671. package/dist/tools/implementations/start-coordinator-task.d.ts +44 -0
  672. package/dist/tools/implementations/start-coordinator-task.d.ts.map +1 -0
  673. package/dist/tools/implementations/start-coordinator-task.js +125 -0
  674. package/dist/tools/implementations/start-coordinator-task.js.map +1 -0
  675. package/dist/tools/implementations/start-subagent-task.d.ts +53 -0
  676. package/dist/tools/implementations/start-subagent-task.d.ts.map +1 -0
  677. package/dist/tools/implementations/start-subagent-task.js +179 -0
  678. package/dist/tools/implementations/start-subagent-task.js.map +1 -0
  679. package/dist/tools/implementations/start-task.d.ts +48 -0
  680. package/dist/tools/implementations/start-task.d.ts.map +1 -0
  681. package/dist/tools/implementations/start-task.js +216 -0
  682. package/dist/tools/implementations/start-task.js.map +1 -0
  683. package/dist/tools/implementations/subagent-task.d.ts +98 -0
  684. package/dist/tools/implementations/subagent-task.d.ts.map +1 -0
  685. package/dist/tools/implementations/subagent-task.js +277 -0
  686. package/dist/tools/implementations/subagent-task.js.map +1 -0
  687. package/dist/tools/implementations/task.d.ts +97 -0
  688. package/dist/tools/implementations/task.d.ts.map +1 -0
  689. package/dist/tools/implementations/task.hierarchical.test.d.ts +8 -0
  690. package/dist/tools/implementations/task.hierarchical.test.d.ts.map +1 -0
  691. package/dist/tools/implementations/task.hierarchical.test.js +333 -0
  692. package/dist/tools/implementations/task.hierarchical.test.js.map +1 -0
  693. package/dist/tools/implementations/task.js +235 -0
  694. package/dist/tools/implementations/task.js.map +1 -0
  695. package/dist/tools/implementations/view-coordinator-task.d.ts +61 -0
  696. package/dist/tools/implementations/view-coordinator-task.d.ts.map +1 -0
  697. package/dist/tools/implementations/view-coordinator-task.js +295 -0
  698. package/dist/tools/implementations/view-coordinator-task.js.map +1 -0
  699. package/dist/tools/implementations/view-document.d.ts +84 -0
  700. package/dist/tools/implementations/view-document.d.ts.map +1 -0
  701. package/dist/tools/implementations/view-document.js +287 -0
  702. package/dist/tools/implementations/view-document.js.map +1 -0
  703. package/dist/tools/implementations/view-section.d.ts +28 -0
  704. package/dist/tools/implementations/view-section.d.ts.map +1 -0
  705. package/dist/tools/implementations/view-section.hierarchical.test.d.ts +8 -0
  706. package/dist/tools/implementations/view-section.hierarchical.test.d.ts.map +1 -0
  707. package/dist/tools/implementations/view-section.hierarchical.test.js +318 -0
  708. package/dist/tools/implementations/view-section.hierarchical.test.js.map +1 -0
  709. package/dist/tools/implementations/view-section.js +167 -0
  710. package/dist/tools/implementations/view-section.js.map +1 -0
  711. package/dist/tools/implementations/view-subagent-task.d.ts +46 -0
  712. package/dist/tools/implementations/view-subagent-task.d.ts.map +1 -0
  713. package/dist/tools/implementations/view-subagent-task.js +283 -0
  714. package/dist/tools/implementations/view-subagent-task.js.map +1 -0
  715. package/dist/tools/implementations/view-task.d.ts +43 -0
  716. package/dist/tools/implementations/view-task.d.ts.map +1 -0
  717. package/dist/tools/implementations/view-task.hierarchical.test.d.ts +8 -0
  718. package/dist/tools/implementations/view-task.hierarchical.test.d.ts.map +1 -0
  719. package/dist/tools/implementations/view-task.hierarchical.test.js +420 -0
  720. package/dist/tools/implementations/view-task.hierarchical.test.js.map +1 -0
  721. package/dist/tools/implementations/view-task.js +280 -0
  722. package/dist/tools/implementations/view-task.js.map +1 -0
  723. package/dist/tools/index.d.ts +6 -0
  724. package/dist/tools/index.d.ts.map +1 -0
  725. package/dist/tools/index.js +6 -0
  726. package/dist/tools/index.js.map +1 -0
  727. package/dist/tools/registry.d.ts +10 -0
  728. package/dist/tools/registry.d.ts.map +1 -0
  729. package/dist/tools/registry.js +132 -0
  730. package/dist/tools/registry.js.map +1 -0
  731. package/dist/tools/schemas/__tests__/get-guide-schemas.test.d.ts +8 -0
  732. package/dist/tools/schemas/__tests__/get-guide-schemas.test.d.ts.map +1 -0
  733. package/dist/tools/schemas/__tests__/get-guide-schemas.test.js +216 -0
  734. package/dist/tools/schemas/__tests__/get-guide-schemas.test.js.map +1 -0
  735. package/dist/tools/schemas/__tests__/get-workflow-schemas.test.d.ts +8 -0
  736. package/dist/tools/schemas/__tests__/get-workflow-schemas.test.d.ts.map +1 -0
  737. package/dist/tools/schemas/__tests__/get-workflow-schemas.test.js +229 -0
  738. package/dist/tools/schemas/__tests__/get-workflow-schemas.test.js.map +1 -0
  739. package/dist/tools/schemas/browse-documents-schemas.d.ts +47 -0
  740. package/dist/tools/schemas/browse-documents-schemas.d.ts.map +1 -0
  741. package/dist/tools/schemas/browse-documents-schemas.js +48 -0
  742. package/dist/tools/schemas/browse-documents-schemas.js.map +1 -0
  743. package/dist/tools/schemas/complete-coordinator-task-schemas.d.ts +41 -0
  744. package/dist/tools/schemas/complete-coordinator-task-schemas.d.ts.map +1 -0
  745. package/dist/tools/schemas/complete-coordinator-task-schemas.js +42 -0
  746. package/dist/tools/schemas/complete-coordinator-task-schemas.js.map +1 -0
  747. package/dist/tools/schemas/complete-subagent-task-schemas.d.ts +38 -0
  748. package/dist/tools/schemas/complete-subagent-task-schemas.d.ts.map +1 -0
  749. package/dist/tools/schemas/complete-subagent-task-schemas.js +41 -0
  750. package/dist/tools/schemas/complete-subagent-task-schemas.js.map +1 -0
  751. package/dist/tools/schemas/complete-task-schemas.d.ts +33 -0
  752. package/dist/tools/schemas/complete-task-schemas.d.ts.map +1 -0
  753. package/dist/tools/schemas/complete-task-schemas.js +36 -0
  754. package/dist/tools/schemas/complete-task-schemas.js.map +1 -0
  755. package/dist/tools/schemas/continue-task-schemas.d.ts +27 -0
  756. package/dist/tools/schemas/continue-task-schemas.d.ts.map +1 -0
  757. package/dist/tools/schemas/continue-task-schemas.js +28 -0
  758. package/dist/tools/schemas/continue-task-schemas.js.map +1 -0
  759. package/dist/tools/schemas/coordinator-task-schemas.d.ts +87 -0
  760. package/dist/tools/schemas/coordinator-task-schemas.d.ts.map +1 -0
  761. package/dist/tools/schemas/coordinator-task-schemas.js +80 -0
  762. package/dist/tools/schemas/coordinator-task-schemas.js.map +1 -0
  763. package/dist/tools/schemas/create-document-schemas.d.ts +61 -0
  764. package/dist/tools/schemas/create-document-schemas.d.ts.map +1 -0
  765. package/dist/tools/schemas/create-document-schemas.js +143 -0
  766. package/dist/tools/schemas/create-document-schemas.js.map +1 -0
  767. package/dist/tools/schemas/delete-document-schemas.d.ts +24 -0
  768. package/dist/tools/schemas/delete-document-schemas.d.ts.map +1 -0
  769. package/dist/tools/schemas/delete-document-schemas.js +25 -0
  770. package/dist/tools/schemas/delete-document-schemas.js.map +1 -0
  771. package/dist/tools/schemas/edit-document-schemas.d.ts +27 -0
  772. package/dist/tools/schemas/edit-document-schemas.d.ts.map +1 -0
  773. package/dist/tools/schemas/edit-document-schemas.js +28 -0
  774. package/dist/tools/schemas/edit-document-schemas.js.map +1 -0
  775. package/dist/tools/schemas/get-guide-schemas.d.ts +35 -0
  776. package/dist/tools/schemas/get-guide-schemas.d.ts.map +1 -0
  777. package/dist/tools/schemas/get-guide-schemas.js +66 -0
  778. package/dist/tools/schemas/get-guide-schemas.js.map +1 -0
  779. package/dist/tools/schemas/get-workflow-schemas.d.ts +35 -0
  780. package/dist/tools/schemas/get-workflow-schemas.d.ts.map +1 -0
  781. package/dist/tools/schemas/get-workflow-schemas.js +67 -0
  782. package/dist/tools/schemas/get-workflow-schemas.js.map +1 -0
  783. package/dist/tools/schemas/manage-document-schemas.d.ts +59 -0
  784. package/dist/tools/schemas/manage-document-schemas.d.ts.map +1 -0
  785. package/dist/tools/schemas/manage-document-schemas.js +83 -0
  786. package/dist/tools/schemas/manage-document-schemas.js.map +1 -0
  787. package/dist/tools/schemas/move-document-schemas.d.ts +25 -0
  788. package/dist/tools/schemas/move-document-schemas.d.ts.map +1 -0
  789. package/dist/tools/schemas/move-document-schemas.js +26 -0
  790. package/dist/tools/schemas/move-document-schemas.js.map +1 -0
  791. package/dist/tools/schemas/move-schemas.d.ts +43 -0
  792. package/dist/tools/schemas/move-schemas.d.ts.map +1 -0
  793. package/dist/tools/schemas/move-schemas.js +43 -0
  794. package/dist/tools/schemas/move-schemas.js.map +1 -0
  795. package/dist/tools/schemas/search-documents-schemas.d.ts +77 -0
  796. package/dist/tools/schemas/search-documents-schemas.d.ts.map +1 -0
  797. package/dist/tools/schemas/search-documents-schemas.js +78 -0
  798. package/dist/tools/schemas/search-documents-schemas.js.map +1 -0
  799. package/dist/tools/schemas/section-schemas.d.ts +361 -0
  800. package/dist/tools/schemas/section-schemas.d.ts.map +1 -0
  801. package/dist/tools/schemas/section-schemas.js +182 -0
  802. package/dist/tools/schemas/section-schemas.js.map +1 -0
  803. package/dist/tools/schemas/start-coordinator-task-schemas.d.ts +30 -0
  804. package/dist/tools/schemas/start-coordinator-task-schemas.d.ts.map +1 -0
  805. package/dist/tools/schemas/start-coordinator-task-schemas.js +31 -0
  806. package/dist/tools/schemas/start-coordinator-task-schemas.js.map +1 -0
  807. package/dist/tools/schemas/start-subagent-task-schemas.d.ts +29 -0
  808. package/dist/tools/schemas/start-subagent-task-schemas.d.ts.map +1 -0
  809. package/dist/tools/schemas/start-subagent-task-schemas.js +40 -0
  810. package/dist/tools/schemas/start-subagent-task-schemas.js.map +1 -0
  811. package/dist/tools/schemas/start-task-schemas.d.ts +23 -0
  812. package/dist/tools/schemas/start-task-schemas.d.ts.map +1 -0
  813. package/dist/tools/schemas/start-task-schemas.js +39 -0
  814. package/dist/tools/schemas/start-task-schemas.js.map +1 -0
  815. package/dist/tools/schemas/subagent-task-schemas.d.ts +93 -0
  816. package/dist/tools/schemas/subagent-task-schemas.d.ts.map +1 -0
  817. package/dist/tools/schemas/subagent-task-schemas.js +81 -0
  818. package/dist/tools/schemas/subagent-task-schemas.js.map +1 -0
  819. package/dist/tools/schemas/task-schemas.d.ts +88 -0
  820. package/dist/tools/schemas/task-schemas.d.ts.map +1 -0
  821. package/dist/tools/schemas/task-schemas.js +80 -0
  822. package/dist/tools/schemas/task-schemas.js.map +1 -0
  823. package/dist/tools/schemas/view-coordinator-task-schemas.d.ts +27 -0
  824. package/dist/tools/schemas/view-coordinator-task-schemas.d.ts.map +1 -0
  825. package/dist/tools/schemas/view-coordinator-task-schemas.js +46 -0
  826. package/dist/tools/schemas/view-coordinator-task-schemas.js.map +1 -0
  827. package/dist/tools/schemas/view-document-schemas.d.ts +152 -0
  828. package/dist/tools/schemas/view-document-schemas.d.ts.map +1 -0
  829. package/dist/tools/schemas/view-document-schemas.js +70 -0
  830. package/dist/tools/schemas/view-document-schemas.js.map +1 -0
  831. package/dist/tools/schemas/view-section-schemas.d.ts +31 -0
  832. package/dist/tools/schemas/view-section-schemas.d.ts.map +1 -0
  833. package/dist/tools/schemas/view-section-schemas.js +56 -0
  834. package/dist/tools/schemas/view-section-schemas.js.map +1 -0
  835. package/dist/tools/schemas/view-subagent-task-schemas.d.ts +31 -0
  836. package/dist/tools/schemas/view-subagent-task-schemas.d.ts.map +1 -0
  837. package/dist/tools/schemas/view-subagent-task-schemas.js +65 -0
  838. package/dist/tools/schemas/view-subagent-task-schemas.js.map +1 -0
  839. package/dist/tools/schemas/view-task-schemas.d.ts +31 -0
  840. package/dist/tools/schemas/view-task-schemas.d.ts.map +1 -0
  841. package/dist/tools/schemas/view-task-schemas.js +62 -0
  842. package/dist/tools/schemas/view-task-schemas.js.map +1 -0
  843. package/dist/tools/types.d.ts +98 -0
  844. package/dist/tools/types.d.ts.map +1 -0
  845. package/dist/tools/types.js +9 -0
  846. package/dist/tools/types.js.map +1 -0
  847. package/dist/tools-manager.d.ts +8 -0
  848. package/dist/tools-manager.d.ts.map +1 -0
  849. package/dist/tools-manager.js +9 -0
  850. package/dist/tools-manager.js.map +1 -0
  851. package/dist/types/core.d.ts +71 -0
  852. package/dist/types/core.d.ts.map +1 -0
  853. package/dist/types/core.js +5 -0
  854. package/dist/types/core.js.map +1 -0
  855. package/dist/types/index.d.ts +5 -0
  856. package/dist/types/index.d.ts.map +1 -0
  857. package/dist/types/index.js +5 -0
  858. package/dist/types/index.js.map +1 -0
  859. package/dist/types/linking.d.ts +97 -0
  860. package/dist/types/linking.d.ts.map +1 -0
  861. package/dist/types/linking.js +5 -0
  862. package/dist/types/linking.js.map +1 -0
  863. package/dist/utils/__tests__/path-handler.archive.test.d.ts +8 -0
  864. package/dist/utils/__tests__/path-handler.archive.test.d.ts.map +1 -0
  865. package/dist/utils/__tests__/path-handler.archive.test.js +163 -0
  866. package/dist/utils/__tests__/path-handler.archive.test.js.map +1 -0
  867. package/dist/utils/error-formatter.d.ts +32 -0
  868. package/dist/utils/error-formatter.d.ts.map +1 -0
  869. package/dist/utils/error-formatter.js +79 -0
  870. package/dist/utils/error-formatter.js.map +1 -0
  871. package/dist/utils/logger.d.ts +21 -0
  872. package/dist/utils/logger.d.ts.map +1 -0
  873. package/dist/utils/logger.js +154 -0
  874. package/dist/utils/logger.js.map +1 -0
  875. package/dist/utils/path-handler.d.ts +52 -0
  876. package/dist/utils/path-handler.d.ts.map +1 -0
  877. package/dist/utils/path-handler.js +129 -0
  878. package/dist/utils/path-handler.js.map +1 -0
  879. package/dist/utils/security-audit-logger.d.ts +64 -0
  880. package/dist/utils/security-audit-logger.d.ts.map +1 -0
  881. package/dist/utils/security-audit-logger.js +56 -0
  882. package/dist/utils/security-audit-logger.js.map +1 -0
  883. package/dist/utils/virtual-path-resolver.d.ts +126 -0
  884. package/dist/utils/virtual-path-resolver.d.ts.map +1 -0
  885. package/dist/utils/virtual-path-resolver.js +171 -0
  886. package/dist/utils/virtual-path-resolver.js.map +1 -0
  887. package/package.json +82 -0
@@ -0,0 +1,1074 @@
1
+ /**
2
+ * Central addressing system for consistent document/section/task addressing
3
+ *
4
+ * This module provides unified addressing patterns to prevent inconsistencies
5
+ * across the codebase in how documents, sections, and tasks are referenced.
6
+ *
7
+ * Key Features:
8
+ * - Type-safe addressing with validation
9
+ * - Flexible input format support (#slug, slug, /doc.md#slug)
10
+ * - Relative path structure (user-facing paths are relative to base folders)
11
+ * - Performance caching for repeated operations
12
+ * - Comparison utilities for address equality
13
+ * - Standard tool integration patterns
14
+ * - Comprehensive error handling
15
+ *
16
+ * Path Structure:
17
+ * - User-facing: /api/auth.md (relative to docs/ folder)
18
+ * - Internal: May include namespace prefixes for file operations
19
+ * - Archives: /archived/docs/... (explicit prefix per requirements)
20
+ */
21
+ import { pathToNamespace, pathToSlug } from './path-utilities.js';
22
+ import { normalizeSlugPath } from './slug-utils.js';
23
+ import { getGlobalLogger } from '../utils/logger.js';
24
+ const logger = getGlobalLogger();
25
+ /**
26
+ * Custom error types for addressing system
27
+ *
28
+ * These error classes provide consistent error handling throughout the addressing system
29
+ * with standardized error codes and contextual information for debugging and recovery.
30
+ */
31
+ /**
32
+ * Base error class for all addressing system errors
33
+ *
34
+ * Provides structured error information with error codes and contextual data
35
+ * for programmatic error handling and debugging.
36
+ *
37
+ * @param message - Human-readable error message
38
+ * @param code - Machine-readable error code for programmatic handling
39
+ * @param context - Additional context about the error for debugging
40
+ *
41
+ * @example Basic error handling
42
+ * ```typescript
43
+ * try {
44
+ * // Some addressing operation
45
+ * } catch (error) {
46
+ * if (error instanceof AddressingError) {
47
+ * console.error('Error code:', error.code);
48
+ * console.error('Context:', error.context);
49
+ * }
50
+ * }
51
+ * ```
52
+ *
53
+ * @example Error code checking
54
+ * ```typescript
55
+ * try {
56
+ * parseDocumentAddress('/invalid/path');
57
+ * } catch (error) {
58
+ * if (error instanceof AddressingError && error.code === 'DOCUMENT_NOT_FOUND') {
59
+ * // Handle missing document specifically
60
+ * }
61
+ * }
62
+ * ```
63
+ */
64
+ export class AddressingError extends Error {
65
+ code;
66
+ context;
67
+ constructor(message, code, context) {
68
+ super(message);
69
+ this.code = code;
70
+ this.context = context;
71
+ this.name = 'AddressingError';
72
+ }
73
+ }
74
+ /**
75
+ * Error thrown when a document cannot be found at the specified path
76
+ *
77
+ * This error indicates that the document path is valid but the document
78
+ * does not exist in the file system or document cache.
79
+ *
80
+ * @param path - The document path that was not found
81
+ *
82
+ * @example Handling missing documents
83
+ * ```typescript
84
+ * try {
85
+ * const doc = parseDocumentAddress('/missing/document.md');
86
+ * } catch (error) {
87
+ * if (error instanceof DocumentNotFoundError) {
88
+ * console.error('Document not found:', error.context.path);
89
+ * // Suggest creating the document or checking the path
90
+ * }
91
+ * }
92
+ * ```
93
+ *
94
+ * @example Recovery strategy
95
+ * ```typescript
96
+ * try {
97
+ * return parseDocumentAddress(documentPath);
98
+ * } catch (error) {
99
+ * if (error instanceof DocumentNotFoundError) {
100
+ * // Try alternative paths or suggest creation
101
+ * return suggestAlternativeDocuments(error.context.path);
102
+ * }
103
+ * throw error;
104
+ * }
105
+ * ```
106
+ */
107
+ export class DocumentNotFoundError extends AddressingError {
108
+ constructor(path) {
109
+ super(`Document not found: ${path}`, 'DOCUMENT_NOT_FOUND', { path });
110
+ }
111
+ }
112
+ /**
113
+ * Error thrown when a section cannot be found within a document
114
+ *
115
+ * This error indicates that the document exists but the specified section
116
+ * slug does not match any section in the document.
117
+ *
118
+ * @param slug - The section slug that was not found
119
+ * @param documentPath - The document path where the section was searched
120
+ *
121
+ * @example Handling missing sections
122
+ * ```typescript
123
+ * try {
124
+ * const section = parseSectionAddress('missing-section', '/api/auth.md');
125
+ * } catch (error) {
126
+ * if (error instanceof SectionNotFoundError) {
127
+ * console.error('Section not found:', error.context.slug);
128
+ * console.error('In document:', error.context.documentPath);
129
+ * // Suggest available sections or check section name
130
+ * }
131
+ * }
132
+ * ```
133
+ *
134
+ * @example Hierarchical section recovery
135
+ * ```typescript
136
+ * try {
137
+ * return parseSectionAddress(sectionSlug, documentPath);
138
+ * } catch (error) {
139
+ * if (error instanceof SectionNotFoundError) {
140
+ * const slug = error.context.slug;
141
+ * if (slug.includes('/')) {
142
+ * // Try parent section for hierarchical addresses
143
+ * const parentSlug = slug.split('/').slice(0, -1).join('/');
144
+ * console.log(`Section not found. Try parent section: ${parentSlug}`);
145
+ * }
146
+ * }
147
+ * throw error;
148
+ * }
149
+ * ```
150
+ */
151
+ export class SectionNotFoundError extends AddressingError {
152
+ constructor(slug, documentPath) {
153
+ super(`Section not found: ${slug} in ${documentPath}`, 'SECTION_NOT_FOUND', { slug, documentPath });
154
+ }
155
+ }
156
+ /**
157
+ * Error thrown when an address format is invalid or malformed
158
+ *
159
+ * This error indicates that the provided address string does not conform
160
+ * to expected patterns or contains invalid characters or structure.
161
+ *
162
+ * @param address - The invalid address that was provided
163
+ * @param reason - Specific reason why the address is invalid
164
+ *
165
+ * @example Handling invalid addresses
166
+ * ```typescript
167
+ * try {
168
+ * const doc = parseDocumentAddress('invalid-path');
169
+ * } catch (error) {
170
+ * if (error instanceof InvalidAddressError) {
171
+ * console.error('Invalid address:', error.context.address);
172
+ * console.error('Reason:', error.context.reason);
173
+ * // Provide guidance on correct address format
174
+ * }
175
+ * }
176
+ * ```
177
+ *
178
+ * @example Address format validation
179
+ * ```typescript
180
+ * function validateAndParseAddress(address: string) {
181
+ * try {
182
+ * return parseDocumentAddress(address);
183
+ * } catch (error) {
184
+ * if (error instanceof InvalidAddressError) {
185
+ * switch (error.context.reason) {
186
+ * case 'Document path must end with .md':
187
+ * return parseDocumentAddress(address + '.md');
188
+ * case 'Document path cannot be empty':
189
+ * throw new Error('Please provide a document path');
190
+ * default:
191
+ * throw error;
192
+ * }
193
+ * }
194
+ * throw error;
195
+ * }
196
+ * }
197
+ * ```
198
+ */
199
+ export class InvalidAddressError extends AddressingError {
200
+ constructor(address, reason) {
201
+ super(`Invalid address: ${address} - ${reason}`, 'INVALID_ADDRESS', { address, reason });
202
+ }
203
+ }
204
+ /**
205
+ * Address parsing cache optimized for batch operations
206
+ *
207
+ * This cache uses a simple Map for batch-scoped caching instead of persistent LRU caching.
208
+ * Cache entries are only valid for the current batch operation and are cleared after each batch.
209
+ *
210
+ * Benefits of batch-scoped caching:
211
+ * - Simpler implementation (no LRU logic needed)
212
+ * - Lower memory footprint (no persistent 1000-entry cache)
213
+ * - Same performance for batch operations (addresses cached within batch)
214
+ * - Clearer memory model (cache lifecycle tied to batch lifecycle)
215
+ */
216
+ class AddressCache {
217
+ batchCache = new Map();
218
+ batchStartTime = null;
219
+ BATCH_TIMEOUT_MS = 60000; // 1 minute
220
+ /**
221
+ * Check if batch cache has timed out and clear if needed
222
+ */
223
+ checkBatchTimeout() {
224
+ if (this.batchStartTime !== null && Date.now() - this.batchStartTime > this.BATCH_TIMEOUT_MS) {
225
+ logger.warn('Batch cache auto-cleared due to timeout', {
226
+ elapsedMs: Date.now() - this.batchStartTime,
227
+ timeoutMs: this.BATCH_TIMEOUT_MS,
228
+ cacheSize: this.batchCache.size
229
+ });
230
+ this.clearBatch();
231
+ }
232
+ }
233
+ /**
234
+ * Get document address from batch cache
235
+ */
236
+ getDocument(path) {
237
+ const address = this.batchCache.get(path);
238
+ if (address != null && 'slug' in address && 'namespace' in address) {
239
+ return address;
240
+ }
241
+ return undefined;
242
+ }
243
+ /**
244
+ * Set document address in batch cache
245
+ */
246
+ setDocument(path, address) {
247
+ this.batchStartTime ??= Date.now();
248
+ this.checkBatchTimeout();
249
+ this.batchCache.set(path, address);
250
+ }
251
+ /**
252
+ * Get section address from batch cache
253
+ */
254
+ getSection(key) {
255
+ const address = this.batchCache.get(key);
256
+ if (address != null && 'document' in address && !('isTask' in address)) {
257
+ return address;
258
+ }
259
+ return undefined;
260
+ }
261
+ /**
262
+ * Set section address in batch cache
263
+ */
264
+ setSection(key, address) {
265
+ this.batchCache.set(key, address);
266
+ }
267
+ /**
268
+ * Clear all batch cache entries
269
+ *
270
+ * This should be called after completing a batch operation to free memory
271
+ * and ensure fresh parsing for the next batch.
272
+ */
273
+ clearBatch() {
274
+ this.batchCache.clear();
275
+ this.batchStartTime = null;
276
+ }
277
+ /**
278
+ * Get batch cache statistics for debugging
279
+ *
280
+ * Returns the current size and all cache keys for monitoring and debugging
281
+ * batch caching behavior.
282
+ */
283
+ getBatchStats() {
284
+ return {
285
+ size: this.batchCache.size,
286
+ keys: Array.from(this.batchCache.keys())
287
+ };
288
+ }
289
+ /**
290
+ * Invalidate all cached addresses for a specific document
291
+ *
292
+ * This clears the batch cache entries for a document and its sections.
293
+ * Called when a document changes to ensure cache consistency.
294
+ */
295
+ invalidateDocument(docPath) {
296
+ // Remove the document itself
297
+ this.batchCache.delete(docPath);
298
+ // Remove all sections that belong to this document
299
+ const keysToRemove = [];
300
+ for (const [key, address] of this.batchCache.entries()) {
301
+ if ('document' in address && address.document.path === docPath) {
302
+ keysToRemove.push(key);
303
+ }
304
+ }
305
+ for (const key of keysToRemove) {
306
+ this.batchCache.delete(key);
307
+ }
308
+ }
309
+ }
310
+ const cache = new AddressCache();
311
+ /**
312
+ * Get global address cache instance for testing and batch management
313
+ *
314
+ * This allows external code to clear the batch cache and access statistics.
315
+ * Primarily used for:
316
+ * - Testing batch cache behavior
317
+ * - Clearing cache after batch operations
318
+ * - Monitoring cache statistics
319
+ */
320
+ export function getGlobalAddressCache() {
321
+ return cache;
322
+ }
323
+ /**
324
+ * Invalidate addressing cache entries for a specific document
325
+ *
326
+ * This should be called when a document changes to maintain cache consistency.
327
+ * Clears both the document entry and all section entries for that document.
328
+ */
329
+ export function invalidateAddressCache(docPath) {
330
+ cache.invalidateDocument(docPath);
331
+ }
332
+ /**
333
+ * Parse and normalize a document path with caching
334
+ *
335
+ * Accepts user-facing relative paths:
336
+ * - /api/auth.md (relative to docs/)
337
+ * - /active.md (relative to coordinator/)
338
+ * - /archived/docs/api/auth.md (explicit archive prefix)
339
+ *
340
+ * The system does NOT require or validate namespace prefixes like /docs/ or /coordinator/.
341
+ * Paths are relative to their base folders for cleaner user experience.
342
+ *
343
+ * @param docPath - Document path (relative to base folder)
344
+ * @returns Parsed and cached document address
345
+ * @throws {InvalidAddressError} When path format is invalid
346
+ *
347
+ * @example Regular document
348
+ * ```typescript
349
+ * const addr = parseDocumentAddress('/api/auth.md');
350
+ * // { path: '/api/auth.md', namespace: 'api', slug: 'auth' }
351
+ * ```
352
+ *
353
+ * @example Coordinator document
354
+ * ```typescript
355
+ * const addr = parseDocumentAddress('/active.md');
356
+ * // { path: '/active.md', namespace: 'root', slug: 'active' }
357
+ * ```
358
+ *
359
+ * @example Archived document
360
+ * ```typescript
361
+ * const addr = parseDocumentAddress('/archived/docs/api/auth.md');
362
+ * // { path: '/archived/docs/api/auth.md', namespace: 'archived/docs/api', slug: 'auth' }
363
+ * ```
364
+ */
365
+ export function parseDocumentAddress(docPath) {
366
+ if (typeof docPath !== 'string') {
367
+ throw new InvalidAddressError(String(docPath), 'Document path must be a string');
368
+ }
369
+ // Check cache first
370
+ const cached = cache.getDocument(docPath);
371
+ if (cached != null) {
372
+ return cached;
373
+ }
374
+ // Validate input
375
+ if (docPath.trim() === '') {
376
+ throw new InvalidAddressError(docPath, 'Document path cannot be empty');
377
+ }
378
+ // Normalize path - ensure it starts with /
379
+ const normalizedPath = docPath.startsWith('/') ? docPath : `/${docPath}`;
380
+ // Validate normalized path
381
+ if (!normalizedPath.endsWith('.md')) {
382
+ throw new InvalidAddressError(normalizedPath, 'Document path must end with .md');
383
+ }
384
+ // Create address
385
+ const address = {
386
+ path: normalizedPath,
387
+ slug: pathToSlug(normalizedPath),
388
+ namespace: pathToNamespace(normalizedPath),
389
+ normalizedPath,
390
+ cacheKey: normalizedPath
391
+ };
392
+ // Cache and return
393
+ cache.setDocument(docPath, address);
394
+ return address;
395
+ }
396
+ /**
397
+ * Normalize section input to handle # prefix with document context
398
+ *
399
+ * When a section reference starts with # but doesn't contain /, it's
400
+ * document-context addressing (e.g., "#overview" with context "/api/auth.md").
401
+ * Strip the # prefix and treat as plain slug for consistent parsing.
402
+ *
403
+ * @param section - Section reference that may have # prefix
404
+ * @returns Normalized section reference without leading # for context-based addressing
405
+ *
406
+ * @example Context-based addressing
407
+ * ```typescript
408
+ * normalizeSectionInput('#overview') // Returns: 'overview'
409
+ * normalizeSectionInput('overview') // Returns: 'overview'
410
+ * ```
411
+ *
412
+ * @example Full path (unchanged)
413
+ * ```typescript
414
+ * normalizeSectionInput('/doc.md#slug') // Returns: '/doc.md#slug'
415
+ * normalizeSectionInput('#api/auth/jwt') // Returns: '#api/auth/jwt'
416
+ * ```
417
+ */
418
+ function normalizeSectionInput(section) {
419
+ // If starts with # but contains no /, it's document-context addressing
420
+ // Strip the # and treat as plain slug
421
+ if (section.startsWith('#') && !section.includes('/')) {
422
+ return section.slice(1);
423
+ }
424
+ // Otherwise return as-is (plain slug or full path)
425
+ return section;
426
+ }
427
+ /**
428
+ * Normalize a hierarchical slug by removing # prefix and normalizing path components
429
+ *
430
+ * @param slug - Raw slug that may contain hierarchical paths
431
+ * @returns Normalized hierarchical slug
432
+ */
433
+ function normalizeHierarchicalSlug(slug) {
434
+ // Remove # prefix if present
435
+ let normalized = slug.startsWith('#') ? slug.substring(1) : slug;
436
+ // Normalize hierarchical path components
437
+ if (normalized.includes('/')) {
438
+ normalized = normalizeSlugPath(normalized);
439
+ }
440
+ return normalized;
441
+ }
442
+ /**
443
+ * Parse and normalize a section reference with caching
444
+ * Supports formats: "section", "#section", "/doc.md#section"
445
+ */
446
+ export function parseSectionAddress(sectionRef, contextDoc) {
447
+ // Input validation - early return for invalid type
448
+ if (typeof sectionRef !== 'string') {
449
+ throw new InvalidAddressError(String(sectionRef), 'Section reference must be a string');
450
+ }
451
+ // Normalize input to handle # prefix with document context
452
+ const normalizedRef = normalizeSectionInput(sectionRef);
453
+ // Check cache first - early return if cached
454
+ const cacheKey = `${sectionRef}|${contextDoc ?? ''}`;
455
+ const cached = cache.getSection(cacheKey);
456
+ if (cached != null) {
457
+ return cached;
458
+ }
459
+ // Parse section reference into document path and section slug
460
+ const { documentPath, sectionSlug } = parseSectionReference(normalizedRef, contextDoc);
461
+ // Normalize slug - early validation for empty slug
462
+ const normalizedSlug = normalizeHierarchicalSlug(sectionSlug);
463
+ if (normalizedSlug === '') {
464
+ throw new InvalidAddressError(sectionRef, 'Section slug cannot be empty');
465
+ }
466
+ // Build and cache section address
467
+ const document = parseDocumentAddress(documentPath);
468
+ const address = {
469
+ document,
470
+ slug: normalizedSlug,
471
+ fullPath: `${document.path}#${normalizedSlug}`,
472
+ cacheKey
473
+ };
474
+ cache.setSection(cacheKey, address);
475
+ return address;
476
+ }
477
+ /**
478
+ * Parse section reference string into document path and section slug
479
+ * Handles three formats: "section", "#section", "/doc.md#section"
480
+ */
481
+ function parseSectionReference(sectionRef, contextDoc) {
482
+ // Format detection: does reference include # separator?
483
+ if (!sectionRef.includes('#')) {
484
+ // Format: "section" - requires context document
485
+ if (contextDoc == null || contextDoc === '') {
486
+ throw new InvalidAddressError(sectionRef, 'Section reference requires context document or full path');
487
+ }
488
+ return {
489
+ documentPath: contextDoc,
490
+ sectionSlug: sectionRef
491
+ };
492
+ }
493
+ // Format: "/doc.md#section" or "#section"
494
+ const [docPart, ...slugParts] = sectionRef.split('#');
495
+ const sectionSlug = slugParts.join('#'); // Handle edge case of multiple # in slug
496
+ // Check if document part is empty (indicates #section format)
497
+ if (docPart === '' || docPart == null) {
498
+ // Format: "#section" - requires context document
499
+ if (contextDoc == null || contextDoc === '') {
500
+ throw new InvalidAddressError(sectionRef, 'Section reference "#section" requires context document');
501
+ }
502
+ return {
503
+ documentPath: contextDoc,
504
+ sectionSlug
505
+ };
506
+ }
507
+ // Format: "/doc.md#section" - document path provided
508
+ return {
509
+ documentPath: docPart,
510
+ sectionSlug
511
+ };
512
+ }
513
+ /**
514
+ * Parse and normalize a task reference with caching
515
+ * Tasks are special sections that live under a "Tasks" parent section
516
+ */
517
+ export function parseTaskAddress(taskRef, contextDoc) {
518
+ // Parse as a section first
519
+ const sectionAddr = parseSectionAddress(taskRef, contextDoc);
520
+ const address = {
521
+ document: sectionAddr.document,
522
+ slug: sectionAddr.slug,
523
+ fullPath: sectionAddr.fullPath,
524
+ isTask: true,
525
+ cacheKey: `task:${sectionAddr.cacheKey}`
526
+ };
527
+ return address;
528
+ }
529
+ /**
530
+ * Check if a section is a task by looking at document structure
531
+ */
532
+ export async function isTaskSection(sectionSlug, document) {
533
+ // Find Tasks section
534
+ const tasksSection = document.headings.find(h => h.slug === 'tasks' || h.title.toLowerCase() === 'tasks');
535
+ if (tasksSection == null)
536
+ return false;
537
+ // Check if this section is a child of Tasks section
538
+ const tasksIndex = document.headings.findIndex(h => h.slug === tasksSection.slug);
539
+ const sectionIndex = document.headings.findIndex(h => h.slug === sectionSlug);
540
+ if (tasksIndex === -1 || sectionIndex === -1 || sectionIndex <= tasksIndex) {
541
+ return false;
542
+ }
543
+ // Check depth - should be immediate child of Tasks
544
+ const section = document.headings[sectionIndex];
545
+ return section != null && section.depth === tasksSection.depth + 1;
546
+ }
547
+ /**
548
+ * Parse common tool parameters into standardized addresses
549
+ */
550
+ function standardizeToolParams(params) {
551
+ const document = parseDocumentAddress(params.document);
552
+ const result = { document };
553
+ if (params.section != null && params.section !== '') {
554
+ result.section = parseSectionAddress(params.section, document.path);
555
+ }
556
+ if (params.task != null && params.task !== '') {
557
+ result.task = parseTaskAddress(params.task, document.path);
558
+ }
559
+ return result;
560
+ }
561
+ /**
562
+ * Tool integration helpers - standard patterns for adopting the addressing system
563
+ *
564
+ * This class provides standardized methods for tools to consistently handle addressing,
565
+ * validation, formatting, and error handling across the MCP server.
566
+ */
567
+ export class ToolIntegration {
568
+ /**
569
+ * Standard parameter validation and parsing for document-based tools
570
+ *
571
+ * Validates and parses document/section/task addresses into standardized format.
572
+ * Throws AddressingError for validation failures with appropriate error codes.
573
+ *
574
+ * @param params - Parameters containing document and optional section/task references
575
+ * @returns Object with validated addresses and original params
576
+ * @throws {DocumentNotFoundError} When document path is invalid
577
+ * @throws {SectionNotFoundError} When section reference is invalid
578
+ * @throws {InvalidAddressError} When address format is malformed
579
+ * @throws {AddressingError} For general parameter validation failures
580
+ *
581
+ * @example Basic document validation (relative path)
582
+ * ```typescript
583
+ * const { addresses } = ToolIntegration.validateAndParse({
584
+ * document: '/api/auth.md' // Relative to docs/
585
+ * });
586
+ * // Returns: { addresses: { document: DocumentAddress }, params: {...} }
587
+ * ```
588
+ *
589
+ * @example Coordinator document
590
+ * ```typescript
591
+ * const { addresses } = ToolIntegration.validateAndParse({
592
+ * document: '/active.md' // Relative to coordinator/
593
+ * });
594
+ * ```
595
+ *
596
+ * @example Document with section
597
+ * ```typescript
598
+ * const { addresses } = ToolIntegration.validateAndParse({
599
+ * document: '/api/auth.md',
600
+ * section: 'jwt-tokens'
601
+ * });
602
+ * // Returns: { addresses: { document: DocumentAddress, section: SectionAddress }, params: {...} }
603
+ * ```
604
+ *
605
+ * @example Hierarchical section addressing
606
+ * ```typescript
607
+ * const { addresses } = ToolIntegration.validateAndParse({
608
+ * document: '/api/auth.md',
609
+ * section: 'authentication/jwt-tokens'
610
+ * });
611
+ * // Handles hierarchical paths automatically
612
+ * ```
613
+ */
614
+ static validateAndParse(params) {
615
+ try {
616
+ const addresses = standardizeToolParams({
617
+ document: params.document,
618
+ ...(params.section != null && { section: params.section }),
619
+ ...(params.task != null && { task: params.task })
620
+ });
621
+ return { addresses, params };
622
+ }
623
+ catch (error) {
624
+ if (error instanceof AddressingError) {
625
+ throw error;
626
+ }
627
+ throw new AddressingError(`Parameter validation failed: ${error instanceof Error ? error.message : String(error)}`, 'PARAMETER_VALIDATION_ERROR', { params });
628
+ }
629
+ }
630
+ /**
631
+ * Standard document info response format
632
+ *
633
+ * Provides consistent document information structure across all tools.
634
+ * Returns only the human-readable title, as slug and namespace can be
635
+ * derived from the document path in the response.
636
+ *
637
+ * @param document - Document address object
638
+ * @param metadata - Optional metadata containing document title
639
+ * @returns Standardized document info object with title only
640
+ *
641
+ * @example Basic document info
642
+ * ```typescript
643
+ * const docInfo = ToolIntegration.formatDocumentInfo(document);
644
+ * // Returns: { title: 'auth' }
645
+ * ```
646
+ *
647
+ * @example With metadata title
648
+ * ```typescript
649
+ * const docInfo = ToolIntegration.formatDocumentInfo(document, { title: 'Authentication Guide' });
650
+ * // Returns: { title: 'Authentication Guide' }
651
+ * ```
652
+ */
653
+ static formatDocumentInfo(document, metadata) {
654
+ return {
655
+ title: metadata?.title ?? document.slug
656
+ };
657
+ }
658
+ /**
659
+ * Standard section path formatting for responses with hierarchical indicator
660
+ *
661
+ * Formats section paths consistently with hierarchical indicators when applicable.
662
+ * Adds "(hierarchical)" suffix for sections containing forward slashes.
663
+ *
664
+ * @param section - Section address object
665
+ * @returns Formatted section path with hierarchical indicator if applicable
666
+ *
667
+ * @example Flat section
668
+ * ```typescript
669
+ * const path = ToolIntegration.formatSectionPath(flatSection);
670
+ * // Returns: '/api/auth.md#overview'
671
+ * ```
672
+ *
673
+ * @example Hierarchical section
674
+ * ```typescript
675
+ * const path = ToolIntegration.formatSectionPath(hierarchicalSection);
676
+ * // Returns: '/api/auth.md#authentication/jwt-tokens (hierarchical)'
677
+ * ```
678
+ */
679
+ static formatSectionPath(section) {
680
+ const path = section.fullPath;
681
+ return section.slug.includes('/') ? `${path} (hierarchical)` : path;
682
+ }
683
+ /**
684
+ * Standard task path formatting for responses
685
+ *
686
+ * Formats task paths with consistent "(task)" indicator.
687
+ *
688
+ * @param task - Task address object
689
+ * @returns Formatted task path with task indicator
690
+ *
691
+ * @example Task path formatting
692
+ * ```typescript
693
+ * const path = ToolIntegration.formatTaskPath(taskAddress);
694
+ * // Returns: '/project/setup.md#initialize-project (task)'
695
+ * ```
696
+ */
697
+ static formatTaskPath(task) {
698
+ return `${task.fullPath} (task)`;
699
+ }
700
+ /**
701
+ * Format hierarchical context for section addresses
702
+ *
703
+ * Provides detailed hierarchical information for sections with forward slashes.
704
+ * Returns null for flat sections to indicate no hierarchical structure.
705
+ *
706
+ * @param section - Section address object
707
+ * @returns Hierarchical context object or null for flat sections
708
+ *
709
+ * @example Flat section (returns null)
710
+ * ```typescript
711
+ * const context = ToolIntegration.formatHierarchicalContext(flatSection);
712
+ * // Returns: null
713
+ * ```
714
+ *
715
+ * @example Hierarchical section
716
+ * ```typescript
717
+ * const context = ToolIntegration.formatHierarchicalContext(hierarchicalSection);
718
+ * // Returns: {
719
+ * // full_path: 'authentication/jwt-tokens',
720
+ * // parent_path: 'authentication',
721
+ * // section_name: 'jwt-tokens',
722
+ * // depth: 2
723
+ * // }
724
+ * ```
725
+ */
726
+ static formatHierarchicalContext(section) {
727
+ if (!section.slug.includes('/')) {
728
+ return null;
729
+ }
730
+ const parts = section.slug.split('/');
731
+ return {
732
+ full_path: section.slug,
733
+ parent_path: parts.slice(0, -1).join('/'),
734
+ section_name: parts[parts.length - 1] ?? '',
735
+ depth: parts.length
736
+ };
737
+ }
738
+ /**
739
+ * Enhanced error formatting with hierarchical context
740
+ *
741
+ * Provides standardized error formatting with hierarchical-aware suggestions.
742
+ * Automatically adds helpful suggestions for hierarchical section errors.
743
+ *
744
+ * @param error - AddressingError to format
745
+ * @param suggestion - Optional custom suggestion to override defaults
746
+ * @returns Formatted error object with context and suggestions
747
+ *
748
+ * @example Basic error formatting
749
+ * ```typescript
750
+ * try {
751
+ * parseDocumentAddress('/invalid/path');
752
+ * } catch (error) {
753
+ * const formatted = ToolIntegration.formatHierarchicalError(error);
754
+ * // Returns: { error: 'Document not found: /invalid/path', context: { path: '/invalid/path' } }
755
+ * }
756
+ * ```
757
+ *
758
+ * @example Hierarchical section error with auto-suggestion
759
+ * ```typescript
760
+ * try {
761
+ * parseSectionAddress('auth/missing-section', '/api/guide.md');
762
+ * } catch (error) {
763
+ * const formatted = ToolIntegration.formatHierarchicalError(error);
764
+ * // Returns: {
765
+ * // error: 'Section not found: auth/missing-section',
766
+ * // context: { slug: 'auth/missing-section', documentPath: '/api/guide.md' },
767
+ * // suggestion: 'Section not found. Try checking parent section: auth'
768
+ * // }
769
+ * }
770
+ * ```
771
+ *
772
+ * @example Custom suggestion
773
+ * ```typescript
774
+ * const formatted = ToolIntegration.formatHierarchicalError(error, 'Check the document exists first');
775
+ * // Uses provided suggestion instead of auto-generated one
776
+ * ```
777
+ */
778
+ static formatHierarchicalError(error, suggestion) {
779
+ const result = {
780
+ error: error.message
781
+ };
782
+ if (error.context != null) {
783
+ result.context = error.context;
784
+ }
785
+ // Add hierarchical-aware suggestions with proper type safety
786
+ if (error instanceof SectionNotFoundError && error.context != null) {
787
+ if (ToolIntegration.hasSectionContext(error.context)) {
788
+ const slug = error.context.slug;
789
+ if (slug.includes('/')) {
790
+ const parentPath = slug.split('/').slice(0, -1).join('/');
791
+ result.suggestion = suggestion ?? `Section not found. Try checking parent section: ${parentPath}`;
792
+ }
793
+ else if (suggestion != null) {
794
+ result.suggestion = suggestion;
795
+ }
796
+ }
797
+ else if (suggestion != null) {
798
+ result.suggestion = suggestion;
799
+ }
800
+ }
801
+ else if (suggestion != null) {
802
+ result.suggestion = suggestion;
803
+ }
804
+ return result;
805
+ }
806
+ /**
807
+ * Type guard to safely check if error context has section-specific properties
808
+ *
809
+ * Provides type-safe validation for error context structure before accessing properties.
810
+ * Used internally by formatHierarchicalError for safe property access.
811
+ *
812
+ * @param context - Unknown context object to validate
813
+ * @returns True if context has required section properties
814
+ *
815
+ * @example Type guard usage
816
+ * ```typescript
817
+ * if (ToolIntegration.hasSectionContext(error.context)) {
818
+ * // TypeScript now knows context has slug and documentPath properties
819
+ * const slug = error.context.slug;
820
+ * const docPath = error.context.documentPath;
821
+ * }
822
+ * ```
823
+ */
824
+ static hasSectionContext(context) {
825
+ return (context != null &&
826
+ typeof context === 'object' &&
827
+ 'slug' in context &&
828
+ 'documentPath' in context &&
829
+ typeof context.slug === 'string' &&
830
+ typeof context.documentPath === 'string');
831
+ }
832
+ /**
833
+ * Clear batch cache after batch operations
834
+ *
835
+ * This helper provides a standardized way for tools to clear the batch cache
836
+ * after completing multi-item operations. Clearing the cache frees memory
837
+ * and ensures fresh parsing for the next batch.
838
+ *
839
+ * @example Clearing cache after batch section operations
840
+ * ```typescript
841
+ * // Process multiple section operations
842
+ * for (const op of operations) {
843
+ * const { addresses } = ToolIntegration.validateAndParse({
844
+ * document: op.document,
845
+ * section: op.section
846
+ * });
847
+ * // ... process operation
848
+ * }
849
+ *
850
+ * // Clear batch cache after all operations complete
851
+ * ToolIntegration.clearBatchCache();
852
+ * ```
853
+ */
854
+ static clearBatchCache() {
855
+ const cache = getGlobalAddressCache();
856
+ cache.clearBatch();
857
+ }
858
+ /**
859
+ * Common validation utilities to eliminate copy-paste patterns
860
+ */
861
+ /**
862
+ * Validate document parameter - standard pattern used across tools
863
+ *
864
+ * Ensures document parameter is a non-empty string with consistent error messaging.
865
+ *
866
+ * @param document - Document parameter to validate
867
+ * @returns Validated document string
868
+ * @throws {AddressingError} When document is not a non-empty string
869
+ *
870
+ * @example Valid document
871
+ * ```typescript
872
+ * const doc = ToolIntegration.validateDocumentParameter('/api/auth.md');
873
+ * // Returns: '/api/auth.md'
874
+ * ```
875
+ *
876
+ * @example Invalid document
877
+ * ```typescript
878
+ * try {
879
+ * ToolIntegration.validateDocumentParameter('');
880
+ * } catch (error) {
881
+ * // Throws: AddressingError with code 'INVALID_PARAMETER'
882
+ * }
883
+ * ```
884
+ */
885
+ static validateDocumentParameter(document) {
886
+ if (typeof document !== 'string' || document === '') {
887
+ throw new AddressingError('document parameter is required and must be a non-empty string', 'INVALID_PARAMETER');
888
+ }
889
+ return document;
890
+ }
891
+ /**
892
+ * Validate count limits with consistent error messages
893
+ *
894
+ * Validates that arrays don't exceed specified limits with standardized error messages.
895
+ *
896
+ * @param items - Array to validate count for
897
+ * @param maxCount - Maximum allowed count
898
+ * @param itemType - Type name for error messages
899
+ * @throws {AddressingError} When count exceeds limit
900
+ *
901
+ * @example Valid count
902
+ * ```typescript
903
+ * ToolIntegration.validateCountLimit(['a', 'b'], 5, 'documents');
904
+ * // Passes validation
905
+ * ```
906
+ *
907
+ * @example Count limit exceeded
908
+ * ```typescript
909
+ * try {
910
+ * ToolIntegration.validateCountLimit(['a', 'b', 'c'], 2, 'documents');
911
+ * } catch (error) {
912
+ * // Throws: AddressingError 'Too many documents. Maximum 2 documents allowed, got 3'
913
+ * }
914
+ * ```
915
+ */
916
+ static validateCountLimit(items, maxCount, itemType) {
917
+ if (items.length > maxCount) {
918
+ throw new AddressingError(`Too many ${itemType}. Maximum ${maxCount} ${itemType} allowed, got ${items.length}`, `TOO_MANY_${itemType.toUpperCase()}`);
919
+ }
920
+ }
921
+ /**
922
+ * Validate array parameter with type checking
923
+ *
924
+ * Validates and normalizes array parameters that can be strings or arrays.
925
+ * Converts single strings to single-element arrays for consistent handling.
926
+ *
927
+ * @param param - Parameter to validate (string or array of strings)
928
+ * @param paramName - Parameter name for error messages
929
+ * @returns Normalized array of strings
930
+ * @throws {AddressingError} When parameter is not string or array
931
+ *
932
+ * @example String parameter
933
+ * ```typescript
934
+ * const result = ToolIntegration.validateArrayParameter('single', 'documents');
935
+ * // Returns: ['single']
936
+ * ```
937
+ *
938
+ * @example Array parameter
939
+ * ```typescript
940
+ * const result = ToolIntegration.validateArrayParameter(['a', 'b'], 'documents');
941
+ * // Returns: ['a', 'b']
942
+ * ```
943
+ *
944
+ * @example Invalid parameter
945
+ * ```typescript
946
+ * try {
947
+ * ToolIntegration.validateArrayParameter(null, 'documents');
948
+ * } catch (error) {
949
+ * // Throws: AddressingError 'documents parameter is required and must be a string or array of strings'
950
+ * }
951
+ * ```
952
+ */
953
+ static validateArrayParameter(param, paramName) {
954
+ if (param == null || (typeof param !== 'string' && !Array.isArray(param))) {
955
+ throw new AddressingError(`${paramName} parameter is required and must be a string or array of strings`, 'INVALID_PARAMETER');
956
+ }
957
+ // Handle array parameter
958
+ if (Array.isArray(param)) {
959
+ return param;
960
+ }
961
+ // Handle string parameter - could be single value or JSON array string
962
+ const stringParam = param;
963
+ // Try to parse as JSON array if it looks like a JSON array
964
+ if (stringParam.trim().startsWith('[') && stringParam.trim().endsWith(']')) {
965
+ try {
966
+ const parsed = JSON.parse(stringParam);
967
+ if (Array.isArray(parsed)) {
968
+ return parsed;
969
+ }
970
+ }
971
+ catch {
972
+ // If JSON parsing fails, treat as single string value
973
+ // This handles malformed JSON gracefully
974
+ }
975
+ }
976
+ // Single string value
977
+ return [stringParam];
978
+ }
979
+ /**
980
+ * Validate string parameter with consistent error handling
981
+ *
982
+ * Ensures parameter is a non-empty string with standardized error messages.
983
+ * Prevents common validation inconsistencies across tools.
984
+ *
985
+ * @param param - Parameter to validate
986
+ * @param paramName - Parameter name for error messages
987
+ * @returns Validated string parameter
988
+ * @throws {AddressingError} When parameter is not a non-empty string
989
+ *
990
+ * @example Valid string parameter
991
+ * ```typescript
992
+ * const operation = ToolIntegration.validateStringParameter('edit', 'operation');
993
+ * // Returns: 'edit'
994
+ * ```
995
+ *
996
+ * @example Invalid string parameter
997
+ * ```typescript
998
+ * try {
999
+ * ToolIntegration.validateStringParameter('', 'operation');
1000
+ * } catch (error) {
1001
+ * // Throws: AddressingError with code 'INVALID_PARAMETER'
1002
+ * }
1003
+ * ```
1004
+ */
1005
+ static validateStringParameter(param, paramName) {
1006
+ if (typeof param !== 'string' || param.trim() === '') {
1007
+ throw new AddressingError(`${paramName} parameter is required and must be a non-empty string`, 'INVALID_PARAMETER');
1008
+ }
1009
+ return param.trim();
1010
+ }
1011
+ /**
1012
+ * Validate optional string parameter with consistent error handling
1013
+ *
1014
+ * Validates optional string parameters, returning undefined for null/undefined inputs.
1015
+ * Ensures non-empty strings when provided.
1016
+ *
1017
+ * @param param - Optional parameter to validate
1018
+ * @param paramName - Parameter name for error messages
1019
+ * @returns Validated string or undefined
1020
+ * @throws {AddressingError} When parameter is empty string or invalid type
1021
+ *
1022
+ * @example Valid optional parameter
1023
+ * ```typescript
1024
+ * const content = ToolIntegration.validateOptionalStringParameter('hello', 'content');
1025
+ * // Returns: 'hello'
1026
+ *
1027
+ * const content2 = ToolIntegration.validateOptionalStringParameter(undefined, 'content');
1028
+ * // Returns: undefined
1029
+ * ```
1030
+ */
1031
+ static validateOptionalStringParameter(param, paramName) {
1032
+ if (param == null || param === '') {
1033
+ return undefined;
1034
+ }
1035
+ if (typeof param !== 'string') {
1036
+ throw new AddressingError(`${paramName} parameter must be a string when provided`, 'INVALID_PARAMETER');
1037
+ }
1038
+ return param.trim();
1039
+ }
1040
+ /**
1041
+ * Validate operation parameter against allowed values
1042
+ *
1043
+ * Ensures operation parameter is one of the allowed values with consistent error messaging.
1044
+ * Prevents duplicate validation logic across tools.
1045
+ *
1046
+ * @param operation - Operation to validate
1047
+ * @param allowedOperations - Array of allowed operation values
1048
+ * @param toolName - Tool name for error context
1049
+ * @returns Validated operation string
1050
+ * @throws {AddressingError} When operation is not in allowed list
1051
+ *
1052
+ * @example Valid operation
1053
+ * ```typescript
1054
+ * const op = ToolIntegration.validateOperation('edit', ['list', 'create', 'edit'], 'task');
1055
+ * // Returns: 'edit'
1056
+ * ```
1057
+ *
1058
+ * @example Invalid operation
1059
+ * ```typescript
1060
+ * try {
1061
+ * ToolIntegration.validateOperation('invalid', ['list', 'create'], 'task');
1062
+ * } catch (error) {
1063
+ * // Throws: AddressingError 'Invalid operation: invalid. Must be one of: list, create'
1064
+ * }
1065
+ * ```
1066
+ */
1067
+ static validateOperation(operation, allowedOperations, toolName) {
1068
+ if (typeof operation !== 'string' || !allowedOperations.includes(operation)) {
1069
+ throw new AddressingError(`Invalid operation: ${String(operation)}. Must be one of: ${allowedOperations.join(', ')}`, 'INVALID_OPERATION', { operation, allowedOperations, toolName });
1070
+ }
1071
+ return operation;
1072
+ }
1073
+ }
1074
+ //# sourceMappingURL=addressing-system.js.map