mcp-adr-analysis-server 2.1.9 → 2.1.19

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 (408) hide show
  1. package/README.md +55 -8
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/index.d.ts +78 -2
  4. package/dist/src/index.d.ts.map +1 -1
  5. package/dist/src/index.js +1793 -577
  6. package/dist/src/index.js.map +1 -1
  7. package/dist/src/prompts/index.d.ts.map +1 -1
  8. package/dist/src/prompts/index.js +23 -6
  9. package/dist/src/prompts/index.js.map +1 -1
  10. package/dist/src/prompts/validated-pattern-prompts.d.ts +33 -0
  11. package/dist/src/prompts/validated-pattern-prompts.d.ts.map +1 -0
  12. package/dist/src/prompts/validated-pattern-prompts.js +337 -0
  13. package/dist/src/prompts/validated-pattern-prompts.js.map +1 -0
  14. package/dist/src/resources/adr-by-id-resource.d.ts +116 -0
  15. package/dist/src/resources/adr-by-id-resource.d.ts.map +1 -0
  16. package/dist/src/resources/adr-by-id-resource.js +213 -0
  17. package/dist/src/resources/adr-by-id-resource.js.map +1 -0
  18. package/dist/src/resources/code-quality-resource.d.ts +105 -0
  19. package/dist/src/resources/code-quality-resource.d.ts.map +1 -0
  20. package/dist/src/resources/code-quality-resource.js +282 -0
  21. package/dist/src/resources/code-quality-resource.js.map +1 -0
  22. package/dist/src/resources/deployment-history-resource.d.ts +214 -0
  23. package/dist/src/resources/deployment-history-resource.d.ts.map +1 -0
  24. package/dist/src/resources/deployment-history-resource.js +308 -0
  25. package/dist/src/resources/deployment-history-resource.js.map +1 -0
  26. package/dist/src/resources/deployment-status-resource.d.ts +256 -0
  27. package/dist/src/resources/deployment-status-resource.d.ts.map +1 -0
  28. package/dist/src/resources/deployment-status-resource.js +665 -0
  29. package/dist/src/resources/deployment-status-resource.js.map +1 -0
  30. package/dist/src/resources/environment-analysis-resource.d.ts +237 -0
  31. package/dist/src/resources/environment-analysis-resource.d.ts.map +1 -0
  32. package/dist/src/resources/environment-analysis-resource.js +646 -0
  33. package/dist/src/resources/environment-analysis-resource.js.map +1 -0
  34. package/dist/src/resources/index.d.ts +6 -2
  35. package/dist/src/resources/index.d.ts.map +1 -1
  36. package/dist/src/resources/index.js +247 -492
  37. package/dist/src/resources/index.js.map +1 -1
  38. package/dist/src/resources/memory-snapshots-resource.d.ts +180 -0
  39. package/dist/src/resources/memory-snapshots-resource.d.ts.map +1 -0
  40. package/dist/src/resources/memory-snapshots-resource.js +847 -0
  41. package/dist/src/resources/memory-snapshots-resource.js.map +1 -0
  42. package/dist/src/resources/pattern-base-code-by-platform-resource.d.ts +35 -0
  43. package/dist/src/resources/pattern-base-code-by-platform-resource.d.ts.map +1 -0
  44. package/dist/src/resources/pattern-base-code-by-platform-resource.js +72 -0
  45. package/dist/src/resources/pattern-base-code-by-platform-resource.js.map +1 -0
  46. package/dist/src/resources/pattern-by-name-resource.d.ts +53 -0
  47. package/dist/src/resources/pattern-by-name-resource.d.ts.map +1 -0
  48. package/dist/src/resources/pattern-by-name-resource.js +200 -0
  49. package/dist/src/resources/pattern-by-name-resource.js.map +1 -0
  50. package/dist/src/resources/pattern-sources-by-platform-resource.d.ts +26 -0
  51. package/dist/src/resources/pattern-sources-by-platform-resource.d.ts.map +1 -0
  52. package/dist/src/resources/pattern-sources-by-platform-resource.js +59 -0
  53. package/dist/src/resources/pattern-sources-by-platform-resource.js.map +1 -0
  54. package/dist/src/resources/project-metrics-resource.d.ts +180 -0
  55. package/dist/src/resources/project-metrics-resource.d.ts.map +1 -0
  56. package/dist/src/resources/project-metrics-resource.js +487 -0
  57. package/dist/src/resources/project-metrics-resource.js.map +1 -0
  58. package/dist/src/resources/project-status-resource.d.ts +75 -0
  59. package/dist/src/resources/project-status-resource.d.ts.map +1 -0
  60. package/dist/src/resources/project-status-resource.js +189 -0
  61. package/dist/src/resources/project-status-resource.js.map +1 -0
  62. package/dist/src/resources/research-by-topic-resource.d.ts +21 -0
  63. package/dist/src/resources/research-by-topic-resource.d.ts.map +1 -0
  64. package/dist/src/resources/research-by-topic-resource.js +125 -0
  65. package/dist/src/resources/research-by-topic-resource.js.map +1 -0
  66. package/dist/src/resources/research-index-resource.d.ts +100 -0
  67. package/dist/src/resources/research-index-resource.d.ts.map +1 -0
  68. package/dist/src/resources/research-index-resource.js +200 -0
  69. package/dist/src/resources/research-index-resource.js.map +1 -0
  70. package/dist/src/resources/resource-cache.d.ts +144 -0
  71. package/dist/src/resources/resource-cache.d.ts.map +1 -0
  72. package/dist/src/resources/resource-cache.js +316 -0
  73. package/dist/src/resources/resource-cache.js.map +1 -0
  74. package/dist/src/resources/resource-router.d.ts +45 -0
  75. package/dist/src/resources/resource-router.d.ts.map +1 -0
  76. package/dist/src/resources/resource-router.js +96 -0
  77. package/dist/src/resources/resource-router.js.map +1 -0
  78. package/dist/src/resources/rule-by-id-resource.d.ts +38 -0
  79. package/dist/src/resources/rule-by-id-resource.d.ts.map +1 -0
  80. package/dist/src/resources/rule-by-id-resource.js +104 -0
  81. package/dist/src/resources/rule-by-id-resource.js.map +1 -0
  82. package/dist/src/resources/rule-catalog-resource.d.ts +126 -0
  83. package/dist/src/resources/rule-catalog-resource.d.ts.map +1 -0
  84. package/dist/src/resources/rule-catalog-resource.js +224 -0
  85. package/dist/src/resources/rule-catalog-resource.js.map +1 -0
  86. package/dist/src/resources/rule-generation-resource.d.ts +80 -0
  87. package/dist/src/resources/rule-generation-resource.d.ts.map +1 -0
  88. package/dist/src/resources/rule-generation-resource.js +282 -0
  89. package/dist/src/resources/rule-generation-resource.js.map +1 -0
  90. package/dist/src/resources/technology-by-name-resource.d.ts +43 -0
  91. package/dist/src/resources/technology-by-name-resource.d.ts.map +1 -0
  92. package/dist/src/resources/technology-by-name-resource.js +176 -0
  93. package/dist/src/resources/technology-by-name-resource.js.map +1 -0
  94. package/dist/src/resources/todo-by-id-resource.d.ts +46 -0
  95. package/dist/src/resources/todo-by-id-resource.d.ts.map +1 -0
  96. package/dist/src/resources/todo-by-id-resource.js +192 -0
  97. package/dist/src/resources/todo-by-id-resource.js.map +1 -0
  98. package/dist/src/resources/todo-list-resource.d.ts +96 -0
  99. package/dist/src/resources/todo-list-resource.d.ts.map +1 -0
  100. package/dist/src/resources/todo-list-resource.js +209 -0
  101. package/dist/src/resources/todo-list-resource.js.map +1 -0
  102. package/dist/src/resources/validated-pattern-by-platform-resource.d.ts +14 -0
  103. package/dist/src/resources/validated-pattern-by-platform-resource.d.ts.map +1 -0
  104. package/dist/src/resources/validated-pattern-by-platform-resource.js +45 -0
  105. package/dist/src/resources/validated-pattern-by-platform-resource.js.map +1 -0
  106. package/dist/src/resources/validated-patterns-catalog-resource.d.ts +36 -0
  107. package/dist/src/resources/validated-patterns-catalog-resource.d.ts.map +1 -0
  108. package/dist/src/resources/validated-patterns-catalog-resource.js +57 -0
  109. package/dist/src/resources/validated-patterns-catalog-resource.js.map +1 -0
  110. package/dist/src/templates/domain-knowledge-templates.d.ts.map +1 -1
  111. package/dist/src/templates/domain-knowledge-templates.js +49 -49
  112. package/dist/src/templates/domain-knowledge-templates.js.map +1 -1
  113. package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -1
  114. package/dist/src/tools/adr-bootstrap-validation-tool.js +214 -4
  115. package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -1
  116. package/dist/src/tools/adr-suggestion-tool.d.ts +2 -2
  117. package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
  118. package/dist/src/tools/adr-suggestion-tool.js +129 -12
  119. package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
  120. package/dist/src/tools/adr-validation-tool.d.ts +98 -0
  121. package/dist/src/tools/adr-validation-tool.d.ts.map +1 -0
  122. package/dist/src/tools/adr-validation-tool.js +372 -0
  123. package/dist/src/tools/adr-validation-tool.js.map +1 -0
  124. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts +262 -0
  125. package/dist/src/tools/bootstrap-validation-loop-tool.d.ts.map +1 -0
  126. package/dist/src/tools/bootstrap-validation-loop-tool.js +1934 -0
  127. package/dist/src/tools/bootstrap-validation-loop-tool.js.map +1 -0
  128. package/dist/src/tools/conversation-memory-tool.d.ts +48 -0
  129. package/dist/src/tools/conversation-memory-tool.d.ts.map +1 -0
  130. package/dist/src/tools/conversation-memory-tool.js +254 -0
  131. package/dist/src/tools/conversation-memory-tool.js.map +1 -0
  132. package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -1
  133. package/dist/src/tools/deployment-analysis-tool.js +82 -6
  134. package/dist/src/tools/deployment-analysis-tool.js.map +1 -1
  135. package/dist/src/tools/deployment-guidance-tool.d.ts.map +1 -1
  136. package/dist/src/tools/deployment-guidance-tool.js +126 -25
  137. package/dist/src/tools/deployment-guidance-tool.js.map +1 -1
  138. package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
  139. package/dist/src/tools/deployment-readiness-tool.js +166 -5
  140. package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
  141. package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
  142. package/dist/src/tools/environment-analysis-tool.js +36 -1
  143. package/dist/src/tools/environment-analysis-tool.js.map +1 -1
  144. package/dist/src/tools/expand-analysis-tool.d.ts +23 -0
  145. package/dist/src/tools/expand-analysis-tool.d.ts.map +1 -0
  146. package/dist/src/tools/expand-analysis-tool.js +107 -0
  147. package/dist/src/tools/expand-analysis-tool.js.map +1 -0
  148. package/dist/src/tools/get-server-context-tool.d.ts +67 -0
  149. package/dist/src/tools/get-server-context-tool.d.ts.map +1 -0
  150. package/dist/src/tools/get-server-context-tool.js +75 -0
  151. package/dist/src/tools/get-server-context-tool.js.map +1 -0
  152. package/dist/src/tools/interactive-adr-planning-tool.d.ts.map +1 -1
  153. package/dist/src/tools/interactive-adr-planning-tool.js +82 -9
  154. package/dist/src/tools/interactive-adr-planning-tool.js.map +1 -1
  155. package/dist/src/tools/llm-cloud-management-tool.d.ts +62 -0
  156. package/dist/src/tools/llm-cloud-management-tool.d.ts.map +1 -0
  157. package/dist/src/tools/llm-cloud-management-tool.js +202 -0
  158. package/dist/src/tools/llm-cloud-management-tool.js.map +1 -0
  159. package/dist/src/tools/llm-database-management-tool.d.ts +62 -0
  160. package/dist/src/tools/llm-database-management-tool.d.ts.map +1 -0
  161. package/dist/src/tools/llm-database-management-tool.js +203 -0
  162. package/dist/src/tools/llm-database-management-tool.js.map +1 -0
  163. package/dist/src/tools/llm-web-search-tool.d.ts +59 -0
  164. package/dist/src/tools/llm-web-search-tool.d.ts.map +1 -0
  165. package/dist/src/tools/llm-web-search-tool.js +165 -0
  166. package/dist/src/tools/llm-web-search-tool.js.map +1 -0
  167. package/dist/src/tools/mcp-planning-tool.d.ts.map +1 -1
  168. package/dist/src/tools/mcp-planning-tool.js +10 -3
  169. package/dist/src/tools/mcp-planning-tool.js.map +1 -1
  170. package/dist/src/tools/memory-loading-tool.d.ts.map +1 -1
  171. package/dist/src/tools/memory-loading-tool.js +4 -2
  172. package/dist/src/tools/memory-loading-tool.js.map +1 -1
  173. package/dist/src/tools/perform-research-tool.d.ts +61 -0
  174. package/dist/src/tools/perform-research-tool.d.ts.map +1 -0
  175. package/dist/src/tools/perform-research-tool.js +324 -0
  176. package/dist/src/tools/perform-research-tool.js.map +1 -0
  177. package/dist/src/tools/research-question-tool.d.ts.map +1 -1
  178. package/dist/src/tools/research-question-tool.js +11 -9
  179. package/dist/src/tools/research-question-tool.js.map +1 -1
  180. package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -1
  181. package/dist/src/tools/review-existing-adrs-tool.js +42 -3
  182. package/dist/src/tools/review-existing-adrs-tool.js.map +1 -1
  183. package/dist/src/tools/tool-chain-orchestrator.d.ts +15 -94
  184. package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
  185. package/dist/src/tools/tool-chain-orchestrator.js +2 -2
  186. package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
  187. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +25 -120
  188. package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
  189. package/dist/src/tools/troubleshoot-guided-workflow-tool.js +91 -2
  190. package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
  191. package/dist/src/types/ape-framework.d.ts +50 -283
  192. package/dist/src/types/ape-framework.d.ts.map +1 -1
  193. package/dist/src/types/conversation-context.d.ts.map +1 -1
  194. package/dist/src/types/conversation-context.js +12 -12
  195. package/dist/src/types/conversation-context.js.map +1 -1
  196. package/dist/src/types/conversation-memory.d.ts +184 -0
  197. package/dist/src/types/conversation-memory.d.ts.map +1 -0
  198. package/dist/src/types/conversation-memory.js +8 -0
  199. package/dist/src/types/conversation-memory.js.map +1 -0
  200. package/dist/src/types/index.d.ts +112 -339
  201. package/dist/src/types/index.d.ts.map +1 -1
  202. package/dist/src/types/knowledge-generation.d.ts +96 -401
  203. package/dist/src/types/knowledge-generation.d.ts.map +1 -1
  204. package/dist/src/types/knowledge-graph-schemas.d.ts +77 -715
  205. package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
  206. package/dist/src/types/knowledge-graph-schemas.js +8 -8
  207. package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
  208. package/dist/src/types/memory-entities.d.ts +1230 -6164
  209. package/dist/src/types/memory-entities.d.ts.map +1 -1
  210. package/dist/src/types/memory-entities.js +8 -8
  211. package/dist/src/types/memory-entities.js.map +1 -1
  212. package/dist/src/types/reflexion-framework.d.ts +35 -264
  213. package/dist/src/types/reflexion-framework.d.ts.map +1 -1
  214. package/dist/src/types/reflexion-framework.js +1 -1
  215. package/dist/src/types/reflexion-framework.js.map +1 -1
  216. package/dist/src/types/state-reinforcement.d.ts +87 -0
  217. package/dist/src/types/state-reinforcement.d.ts.map +1 -0
  218. package/dist/src/types/state-reinforcement.js +5 -0
  219. package/dist/src/types/state-reinforcement.js.map +1 -0
  220. package/dist/src/types/tiered-response.d.ts +61 -0
  221. package/dist/src/types/tiered-response.d.ts.map +1 -0
  222. package/dist/src/types/tiered-response.js +8 -0
  223. package/dist/src/types/tiered-response.js.map +1 -0
  224. package/dist/src/types/tool-context.d.ts +50 -0
  225. package/dist/src/types/tool-context.d.ts.map +1 -0
  226. package/dist/src/types/tool-context.js +20 -0
  227. package/dist/src/types/tool-context.js.map +1 -0
  228. package/dist/src/utils/adr-action-analyzer.d.ts +23 -0
  229. package/dist/src/utils/adr-action-analyzer.d.ts.map +1 -0
  230. package/dist/src/utils/adr-action-analyzer.js +323 -0
  231. package/dist/src/utils/adr-action-analyzer.js.map +1 -0
  232. package/dist/src/utils/adr-context-detector.d.ts +33 -0
  233. package/dist/src/utils/adr-context-detector.d.ts.map +1 -0
  234. package/dist/src/utils/adr-context-detector.js +279 -0
  235. package/dist/src/utils/adr-context-detector.js.map +1 -0
  236. package/dist/src/utils/adr-discovery.d.ts +28 -2
  237. package/dist/src/utils/adr-discovery.d.ts.map +1 -1
  238. package/dist/src/utils/adr-discovery.js +91 -7
  239. package/dist/src/utils/adr-discovery.js.map +1 -1
  240. package/dist/src/utils/adr-knowledge-initializer.d.ts +54 -0
  241. package/dist/src/utils/adr-knowledge-initializer.d.ts.map +1 -0
  242. package/dist/src/utils/adr-knowledge-initializer.js +240 -0
  243. package/dist/src/utils/adr-knowledge-initializer.js.map +1 -0
  244. package/dist/src/utils/adr-timeline-extractor.d.ts +21 -0
  245. package/dist/src/utils/adr-timeline-extractor.d.ts.map +1 -0
  246. package/dist/src/utils/adr-timeline-extractor.js +294 -0
  247. package/dist/src/utils/adr-timeline-extractor.js.map +1 -0
  248. package/dist/src/utils/adr-timeline-types.d.ts +234 -0
  249. package/dist/src/utils/adr-timeline-types.d.ts.map +1 -0
  250. package/dist/src/utils/adr-timeline-types.js +7 -0
  251. package/dist/src/utils/adr-timeline-types.js.map +1 -0
  252. package/dist/src/utils/ai-executor.d.ts +36 -0
  253. package/dist/src/utils/ai-executor.d.ts.map +1 -1
  254. package/dist/src/utils/ai-executor.js +39 -3
  255. package/dist/src/utils/ai-executor.js.map +1 -1
  256. package/dist/src/utils/apply-cot-enhancement.d.ts.map +1 -1
  257. package/dist/src/utils/apply-cot-enhancement.js +15 -15
  258. package/dist/src/utils/apply-cot-enhancement.js.map +1 -1
  259. package/dist/src/utils/automatic-prompt-engineering.d.ts.map +1 -1
  260. package/dist/src/utils/automatic-prompt-engineering.js +68 -58
  261. package/dist/src/utils/automatic-prompt-engineering.js.map +1 -1
  262. package/dist/src/utils/conditional-request.d.ts +105 -0
  263. package/dist/src/utils/conditional-request.d.ts.map +1 -0
  264. package/dist/src/utils/conditional-request.js +186 -0
  265. package/dist/src/utils/conditional-request.js.map +1 -0
  266. package/dist/src/utils/config.d.ts +72 -18
  267. package/dist/src/utils/config.d.ts.map +1 -1
  268. package/dist/src/utils/config.js +75 -0
  269. package/dist/src/utils/config.js.map +1 -1
  270. package/dist/src/utils/context-document-manager.d.ts +112 -0
  271. package/dist/src/utils/context-document-manager.d.ts.map +1 -0
  272. package/dist/src/utils/context-document-manager.js +351 -0
  273. package/dist/src/utils/context-document-manager.js.map +1 -0
  274. package/dist/src/utils/conversation-memory-manager.d.ts +86 -0
  275. package/dist/src/utils/conversation-memory-manager.d.ts.map +1 -0
  276. package/dist/src/utils/conversation-memory-manager.js +443 -0
  277. package/dist/src/utils/conversation-memory-manager.js.map +1 -0
  278. package/dist/src/utils/dag-executor.d.ts +106 -0
  279. package/dist/src/utils/dag-executor.d.ts.map +1 -0
  280. package/dist/src/utils/dag-executor.js +420 -0
  281. package/dist/src/utils/dag-executor.js.map +1 -0
  282. package/dist/src/utils/deployment-analysis.d.ts.map +1 -1
  283. package/dist/src/utils/deployment-analysis.js +17 -9
  284. package/dist/src/utils/deployment-analysis.js.map +1 -1
  285. package/dist/src/utils/deployment-type-registry.d.ts +52 -0
  286. package/dist/src/utils/deployment-type-registry.d.ts.map +1 -0
  287. package/dist/src/utils/deployment-type-registry.js +543 -0
  288. package/dist/src/utils/deployment-type-registry.js.map +1 -0
  289. package/dist/src/utils/dynamic-deployment-intelligence.d.ts +117 -0
  290. package/dist/src/utils/dynamic-deployment-intelligence.d.ts.map +1 -0
  291. package/dist/src/utils/dynamic-deployment-intelligence.js +445 -0
  292. package/dist/src/utils/dynamic-deployment-intelligence.js.map +1 -0
  293. package/dist/src/utils/environment-analysis.d.ts.map +1 -1
  294. package/dist/src/utils/environment-analysis.js +63 -44
  295. package/dist/src/utils/environment-analysis.js.map +1 -1
  296. package/dist/src/utils/environment-capability-registry.d.ts +101 -0
  297. package/dist/src/utils/environment-capability-registry.d.ts.map +1 -0
  298. package/dist/src/utils/environment-capability-registry.js +489 -0
  299. package/dist/src/utils/environment-capability-registry.js.map +1 -0
  300. package/dist/src/utils/index.d.ts +3 -3
  301. package/dist/src/utils/index.d.ts.map +1 -1
  302. package/dist/src/utils/index.js +3 -3
  303. package/dist/src/utils/index.js.map +1 -1
  304. package/dist/src/utils/knowledge-generation.d.ts.map +1 -1
  305. package/dist/src/utils/knowledge-generation.js +61 -35
  306. package/dist/src/utils/knowledge-generation.js.map +1 -1
  307. package/dist/src/utils/knowledge-graph-manager.d.ts +19 -0
  308. package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
  309. package/dist/src/utils/knowledge-graph-manager.js +165 -1
  310. package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
  311. package/dist/src/utils/llm-artifact-detector.d.ts.map +1 -1
  312. package/dist/src/utils/llm-artifact-detector.js +28 -24
  313. package/dist/src/utils/llm-artifact-detector.js.map +1 -1
  314. package/dist/src/utils/mermaid-diagrams.d.ts +101 -0
  315. package/dist/src/utils/mermaid-diagrams.d.ts.map +1 -0
  316. package/dist/src/utils/mermaid-diagrams.js +445 -0
  317. package/dist/src/utils/mermaid-diagrams.js.map +1 -0
  318. package/dist/src/utils/monitoring.d.ts +249 -0
  319. package/dist/src/utils/monitoring.d.ts.map +1 -0
  320. package/dist/src/utils/monitoring.js +513 -0
  321. package/dist/src/utils/monitoring.js.map +1 -0
  322. package/dist/src/utils/pattern-contribution-helper.d.ts +60 -0
  323. package/dist/src/utils/pattern-contribution-helper.d.ts.map +1 -0
  324. package/dist/src/utils/pattern-contribution-helper.js +308 -0
  325. package/dist/src/utils/pattern-contribution-helper.js.map +1 -0
  326. package/dist/src/utils/pattern-loader.d.ts +183 -0
  327. package/dist/src/utils/pattern-loader.d.ts.map +1 -0
  328. package/dist/src/utils/pattern-loader.js +200 -0
  329. package/dist/src/utils/pattern-loader.js.map +1 -0
  330. package/dist/src/utils/pattern-research-utility.d.ts +107 -0
  331. package/dist/src/utils/pattern-research-utility.d.ts.map +1 -0
  332. package/dist/src/utils/pattern-research-utility.js +360 -0
  333. package/dist/src/utils/pattern-research-utility.js.map +1 -0
  334. package/dist/src/utils/pattern-to-dag-converter.d.ts +62 -0
  335. package/dist/src/utils/pattern-to-dag-converter.d.ts.map +1 -0
  336. package/dist/src/utils/pattern-to-dag-converter.js +265 -0
  337. package/dist/src/utils/pattern-to-dag-converter.js.map +1 -0
  338. package/dist/src/utils/platform-detector.d.ts +86 -0
  339. package/dist/src/utils/platform-detector.d.ts.map +1 -0
  340. package/dist/src/utils/platform-detector.js +509 -0
  341. package/dist/src/utils/platform-detector.js.map +1 -0
  342. package/dist/src/utils/prompt-composition.d.ts.map +1 -1
  343. package/dist/src/utils/prompt-composition.js +1 -4
  344. package/dist/src/utils/prompt-composition.js.map +1 -1
  345. package/dist/src/utils/reflexion.d.ts.map +1 -1
  346. package/dist/src/utils/reflexion.js +51 -42
  347. package/dist/src/utils/reflexion.js.map +1 -1
  348. package/dist/src/utils/research-integration.d.ts.map +1 -1
  349. package/dist/src/utils/research-integration.js +8 -2
  350. package/dist/src/utils/research-integration.js.map +1 -1
  351. package/dist/src/utils/research-orchestrator.d.ts +209 -0
  352. package/dist/src/utils/research-orchestrator.d.ts.map +1 -0
  353. package/dist/src/utils/research-orchestrator.js +863 -0
  354. package/dist/src/utils/research-orchestrator.js.map +1 -0
  355. package/dist/src/utils/research-questions.d.ts.map +1 -1
  356. package/dist/src/utils/research-questions.js +4 -1
  357. package/dist/src/utils/research-questions.js.map +1 -1
  358. package/dist/src/utils/resource-extractor.d.ts +57 -0
  359. package/dist/src/utils/resource-extractor.d.ts.map +1 -0
  360. package/dist/src/utils/resource-extractor.js +323 -0
  361. package/dist/src/utils/resource-extractor.js.map +1 -0
  362. package/dist/src/utils/resource-versioning.d.ts +124 -0
  363. package/dist/src/utils/resource-versioning.d.ts.map +1 -0
  364. package/dist/src/utils/resource-versioning.js +272 -0
  365. package/dist/src/utils/resource-versioning.js.map +1 -0
  366. package/dist/src/utils/root-manager.d.ts +118 -0
  367. package/dist/src/utils/root-manager.d.ts.map +1 -0
  368. package/dist/src/utils/root-manager.js +154 -0
  369. package/dist/src/utils/root-manager.js.map +1 -0
  370. package/dist/src/utils/rule-generation.d.ts.map +1 -1
  371. package/dist/src/utils/rule-generation.js +4 -1
  372. package/dist/src/utils/rule-generation.js.map +1 -1
  373. package/dist/src/utils/server-context-generator.d.ts +47 -0
  374. package/dist/src/utils/server-context-generator.d.ts.map +1 -0
  375. package/dist/src/utils/server-context-generator.js +666 -0
  376. package/dist/src/utils/server-context-generator.js.map +1 -0
  377. package/dist/src/utils/state-reinforcement-manager.d.ts +60 -0
  378. package/dist/src/utils/state-reinforcement-manager.d.ts.map +1 -0
  379. package/dist/src/utils/state-reinforcement-manager.js +200 -0
  380. package/dist/src/utils/state-reinforcement-manager.js.map +1 -0
  381. package/dist/src/utils/system-card-manager.d.ts +194 -0
  382. package/dist/src/utils/system-card-manager.d.ts.map +1 -0
  383. package/dist/src/utils/system-card-manager.js +336 -0
  384. package/dist/src/utils/system-card-manager.js.map +1 -0
  385. package/dist/src/utils/tiered-response-manager.d.ts +40 -0
  386. package/dist/src/utils/tiered-response-manager.d.ts.map +1 -0
  387. package/dist/src/utils/tiered-response-manager.js +243 -0
  388. package/dist/src/utils/tiered-response-manager.js.map +1 -0
  389. package/dist/src/utils/tree-sitter-analyzer.d.ts.map +1 -1
  390. package/dist/src/utils/tree-sitter-analyzer.js +83 -11
  391. package/dist/src/utils/tree-sitter-analyzer.js.map +1 -1
  392. package/dist/src/utils/validated-pattern-definitions.d.ts +219 -0
  393. package/dist/src/utils/validated-pattern-definitions.d.ts.map +1 -0
  394. package/dist/src/utils/validated-pattern-definitions.js +1511 -0
  395. package/dist/src/utils/validated-pattern-definitions.js.map +1 -0
  396. package/package.json +21 -12
  397. package/dist/src/prompts/todo-prompts.d.ts +0 -49
  398. package/dist/src/prompts/todo-prompts.d.ts.map +0 -1
  399. package/dist/src/prompts/todo-prompts.js +0 -824
  400. package/dist/src/prompts/todo-prompts.js.map +0 -1
  401. package/dist/src/types/todo-json-schemas.d.ts +0 -17
  402. package/dist/src/types/todo-json-schemas.d.ts.map +0 -1
  403. package/dist/src/types/todo-json-schemas.js +0 -9
  404. package/dist/src/types/todo-json-schemas.js.map +0 -1
  405. package/dist/src/utils/todo-file-watcher.d.ts +0 -14
  406. package/dist/src/utils/todo-file-watcher.d.ts.map +0 -1
  407. package/dist/src/utils/todo-file-watcher.js +0 -25
  408. package/dist/src/utils/todo-file-watcher.js.map +0 -1
@@ -0,0 +1,847 @@
1
+ /**
2
+ * Memory Snapshots Resource
3
+ *
4
+ * MCP Resource implementation for memory system snapshots and queries.
5
+ * Bridges to memory-loading-tool for actual operations.
6
+ *
7
+ * URI Templates:
8
+ * - adr://memory-snapshots/current - Current memory snapshot
9
+ * - adr://memory-snapshots/query - Query memory entities
10
+ * - adr://memory-snapshots/entity/{entityId} - Get specific entity
11
+ * - adr://memory-snapshots/related/{entityId} - Find related entities
12
+ * - adr://memory-snapshots/intelligence - Memory intelligence analysis
13
+ * - adr://memory-snapshots/load-adrs - Load ADRs into memory
14
+ *
15
+ * Query Parameters:
16
+ * - entityTypes: Filter by entity types (comma-separated)
17
+ * - tags: Filter by tags (comma-separated)
18
+ * - textQuery: Text search query
19
+ * - relationshipTypes: Filter by relationship types (comma-separated)
20
+ * - confidenceThreshold: Minimum confidence score (0-1)
21
+ * - relevanceThreshold: Minimum relevance score (0-1)
22
+ * - limit: Maximum results to return
23
+ * - sortBy: Sort order (relevance, confidence, lastModified, created, accessCount)
24
+ * - includeRelated: Include related entities (true/false)
25
+ * - relationshipDepth: Depth of relationships to traverse (1-5)
26
+ * - maxDepth: Maximum depth for find_related (1-10)
27
+ * - forceReload: Force reload of ADRs (true/false)
28
+ */
29
+ import { MemoryLoadingTool } from '../tools/memory-loading-tool.js';
30
+ import { EnhancedLogger } from '../utils/enhanced-logging.js';
31
+ import { ResourceCache } from './resource-cache.js';
32
+ export class MemorySnapshotsResource {
33
+ memoryLoadingTool;
34
+ logger;
35
+ cache;
36
+ CACHE_TTL = 5 * 60; // 5 minutes in seconds
37
+ constructor(memoryLoadingTool) {
38
+ this.memoryLoadingTool = memoryLoadingTool || new MemoryLoadingTool();
39
+ this.logger = new EnhancedLogger({});
40
+ this.cache = new ResourceCache();
41
+ }
42
+ /**
43
+ * Parse memory URI to extract operation and entity ID
44
+ */
45
+ parseUri(uri) {
46
+ // Remove protocol and base path
47
+ const path = uri.replace('adr://memory-snapshots/', '');
48
+ // Handle entity and related URIs with ID
49
+ if (path.startsWith('entity/')) {
50
+ return {
51
+ operation: 'entity',
52
+ entityId: path.replace('entity/', ''),
53
+ };
54
+ }
55
+ if (path.startsWith('related/')) {
56
+ return {
57
+ operation: 'related',
58
+ entityId: path.replace('related/', ''),
59
+ };
60
+ }
61
+ // Handle other operations
62
+ switch (path) {
63
+ case 'current':
64
+ return { operation: 'current' };
65
+ case 'query':
66
+ return { operation: 'query' };
67
+ case 'intelligence':
68
+ return { operation: 'intelligence' };
69
+ case 'load-adrs':
70
+ return { operation: 'load-adrs' };
71
+ default:
72
+ throw new Error(`Invalid memory URI: ${uri}`);
73
+ }
74
+ }
75
+ /**
76
+ * Parse query parameters from URI
77
+ */
78
+ parseQueryParams(uri) {
79
+ const queryString = uri.split('?')[1];
80
+ if (!queryString)
81
+ return {};
82
+ const params = {};
83
+ const pairs = queryString.split('&');
84
+ for (const pair of pairs) {
85
+ const [key, value] = pair.split('=');
86
+ if (key && value) {
87
+ params[decodeURIComponent(key)] = decodeURIComponent(value);
88
+ }
89
+ }
90
+ return params;
91
+ }
92
+ /**
93
+ * Convert query parameters to memory loading tool parameters
94
+ */
95
+ buildToolParams(operation, entityId, queryParams) {
96
+ const params = {};
97
+ // Set action based on operation
98
+ switch (operation) {
99
+ case 'current':
100
+ params.action = 'create_snapshot';
101
+ break;
102
+ case 'query':
103
+ params.action = 'query_entities';
104
+ break;
105
+ case 'entity':
106
+ params.action = 'get_entity';
107
+ params.entityId = entityId;
108
+ break;
109
+ case 'related':
110
+ params.action = 'find_related';
111
+ params.entityId = entityId;
112
+ if (queryParams['maxDepth']) {
113
+ params.maxDepth = parseInt(queryParams['maxDepth'], 10);
114
+ }
115
+ break;
116
+ case 'intelligence':
117
+ params.action = 'get_intelligence';
118
+ break;
119
+ case 'load-adrs':
120
+ params.action = 'load_adrs';
121
+ if (queryParams['forceReload']) {
122
+ params.forceReload = queryParams['forceReload'] === 'true';
123
+ }
124
+ break;
125
+ }
126
+ // Build query object for query_entities action
127
+ if (operation === 'query') {
128
+ params.query = {};
129
+ if (queryParams['entityTypes']) {
130
+ params.query.entityTypes = queryParams['entityTypes'].split(',');
131
+ }
132
+ if (queryParams['tags']) {
133
+ params.query.tags = queryParams['tags'].split(',');
134
+ }
135
+ if (queryParams['textQuery']) {
136
+ params.query.textQuery = queryParams['textQuery'];
137
+ }
138
+ if (queryParams['relationshipTypes']) {
139
+ params.query.relationshipTypes = queryParams['relationshipTypes'].split(',');
140
+ }
141
+ if (queryParams['confidenceThreshold']) {
142
+ params.query.confidenceThreshold = parseFloat(queryParams['confidenceThreshold']);
143
+ }
144
+ if (queryParams['relevanceThreshold']) {
145
+ params.query.relevanceThreshold = parseFloat(queryParams['relevanceThreshold']);
146
+ }
147
+ if (queryParams['limit']) {
148
+ params.query.limit = parseInt(queryParams['limit'], 10);
149
+ }
150
+ if (queryParams['sortBy']) {
151
+ params.query.sortBy = queryParams['sortBy'];
152
+ }
153
+ if (queryParams['includeRelated']) {
154
+ params.query.includeRelated = queryParams['includeRelated'] === 'true';
155
+ }
156
+ if (queryParams['relationshipDepth']) {
157
+ params.query.relationshipDepth = parseInt(queryParams['relationshipDepth'], 10);
158
+ }
159
+ }
160
+ return params;
161
+ }
162
+ /**
163
+ * Extract structured data from memory loading tool response
164
+ */
165
+ extractMemoryData(toolResponse) {
166
+ try {
167
+ const parsed = JSON.parse(toolResponse);
168
+ // Handle different response structures based on action
169
+ if (parsed.status === 'success') {
170
+ return parsed;
171
+ }
172
+ if (parsed.status === 'no_adrs_found') {
173
+ return {
174
+ status: 'empty',
175
+ message: parsed.message,
176
+ recommendations: parsed.recommendations || [],
177
+ };
178
+ }
179
+ if (parsed.status === 'not_found') {
180
+ return {
181
+ status: 'not_found',
182
+ message: parsed.message,
183
+ entityId: parsed.entityId,
184
+ };
185
+ }
186
+ return parsed;
187
+ }
188
+ catch {
189
+ // If JSON parsing fails, return raw text
190
+ return {
191
+ status: 'raw',
192
+ content: toolResponse,
193
+ };
194
+ }
195
+ }
196
+ /**
197
+ * Generate human-readable content from memory data
198
+ */
199
+ formatMemoryContent(operation, data, queryParams) {
200
+ const sections = [];
201
+ // Header
202
+ sections.push('# Memory Snapshots Resource');
203
+ sections.push(`Operation: ${operation}`);
204
+ sections.push('');
205
+ // Handle different operations
206
+ switch (operation) {
207
+ case 'current':
208
+ return this.formatSnapshotContent(data);
209
+ case 'query':
210
+ return this.formatQueryContent(data, queryParams);
211
+ case 'entity':
212
+ return this.formatEntityContent(data);
213
+ case 'related':
214
+ return this.formatRelatedContent(data);
215
+ case 'intelligence':
216
+ return this.formatIntelligenceContent(data);
217
+ case 'load-adrs':
218
+ return this.formatLoadAdrsContent(data);
219
+ default:
220
+ sections.push('## Raw Data');
221
+ sections.push('```json');
222
+ sections.push(JSON.stringify(data, null, 2));
223
+ sections.push('```');
224
+ }
225
+ return sections.join('\n');
226
+ }
227
+ formatSnapshotContent(data) {
228
+ const sections = [];
229
+ sections.push('# Memory Snapshot');
230
+ sections.push('');
231
+ if (data.status === 'success' && data.snapshot) {
232
+ const snapshot = data.snapshot;
233
+ sections.push('## Snapshot Information');
234
+ sections.push(`- **ID**: ${snapshot.id}`);
235
+ sections.push(`- **Timestamp**: ${snapshot.timestamp}`);
236
+ sections.push(`- **Version**: ${snapshot.version}`);
237
+ sections.push('');
238
+ sections.push('## Entity Summary');
239
+ sections.push(`- **Total Entities**: ${snapshot.entitySummary.totalEntities}`);
240
+ sections.push(`- **Average Confidence**: ${(snapshot.entitySummary.averageConfidence * 100).toFixed(1)}%`);
241
+ sections.push('');
242
+ sections.push('### Entities by Type');
243
+ for (const [type, count] of Object.entries(snapshot.entitySummary.byType)) {
244
+ sections.push(`- ${type}: ${count}`);
245
+ }
246
+ sections.push('');
247
+ sections.push('## Relationship Summary');
248
+ sections.push(`- **Total Relationships**: ${snapshot.relationshipSummary.totalRelationships}`);
249
+ sections.push('');
250
+ sections.push('### Relationships by Type');
251
+ for (const [type, count] of Object.entries(snapshot.relationshipSummary.byType)) {
252
+ sections.push(`- ${type}: ${count}`);
253
+ }
254
+ sections.push('');
255
+ sections.push('## Intelligence Summary');
256
+ sections.push(`- **Discovered Patterns**: ${snapshot.intelligenceSummary.discoveredPatterns}`);
257
+ sections.push(`- **Suggested Relationships**: ${snapshot.intelligenceSummary.suggestedRelationships}`);
258
+ sections.push(`- **Next Actions**: ${snapshot.intelligenceSummary.nextActions}`);
259
+ sections.push(`- **Knowledge Gaps**: ${snapshot.intelligenceSummary.knowledgeGaps}`);
260
+ }
261
+ else {
262
+ sections.push(`Status: ${data.status || 'unknown'}`);
263
+ sections.push('');
264
+ sections.push('```json');
265
+ sections.push(JSON.stringify(data, null, 2));
266
+ sections.push('```');
267
+ }
268
+ return sections.join('\n');
269
+ }
270
+ formatQueryContent(data, queryParams) {
271
+ const sections = [];
272
+ sections.push('# Memory Query Results');
273
+ sections.push('');
274
+ if (data.status === 'success' && data.entities) {
275
+ sections.push('## Query Information');
276
+ sections.push(`- **Total Results**: ${data.query.totalResults}`);
277
+ sections.push(`- **Returned**: ${data.query.returnedResults}`);
278
+ sections.push(`- **Execution Time**: ${data.query.executionTime}ms`);
279
+ sections.push('');
280
+ if (Object.keys(queryParams).length > 0) {
281
+ sections.push('### Applied Filters');
282
+ for (const [key, value] of Object.entries(queryParams)) {
283
+ sections.push(`- ${key}: ${value}`);
284
+ }
285
+ sections.push('');
286
+ }
287
+ sections.push('## Entities');
288
+ for (const entity of data.entities) {
289
+ sections.push(`### ${entity.title}`);
290
+ sections.push(`- **ID**: ${entity.id}`);
291
+ sections.push(`- **Type**: ${entity.type}`);
292
+ sections.push(`- **Confidence**: ${(entity.confidence * 100).toFixed(1)}%`);
293
+ if (entity.relevance !== undefined) {
294
+ sections.push(`- **Relevance**: ${(entity.relevance * 100).toFixed(1)}%`);
295
+ }
296
+ sections.push(`- **Access Count**: ${entity.accessCount}`);
297
+ sections.push(`- **Relationships**: ${entity.relationshipCount}`);
298
+ sections.push(`- **Tags**: ${entity.tags.join(', ')}`);
299
+ sections.push('');
300
+ sections.push(`**Description**: ${entity.description}`);
301
+ sections.push('');
302
+ if (entity.adrStatus) {
303
+ sections.push(`- **ADR Status**: ${entity.adrStatus}`);
304
+ sections.push(`- **Implementation Status**: ${entity.implementationStatus}`);
305
+ sections.push('');
306
+ }
307
+ if (entity.artifactType) {
308
+ sections.push(`- **Artifact Type**: ${entity.artifactType}`);
309
+ sections.push(`- **Format**: ${entity.format}`);
310
+ sections.push('');
311
+ }
312
+ }
313
+ if (data.relationships && data.relationships.length > 0) {
314
+ sections.push('## Relationships');
315
+ for (const rel of data.relationships) {
316
+ sections.push(`- **${rel.type}**: ${rel.sourceId} → ${rel.targetId}`);
317
+ sections.push(` - Strength: ${(rel.strength * 100).toFixed(1)}%`);
318
+ sections.push(` - Confidence: ${(rel.confidence * 100).toFixed(1)}%`);
319
+ }
320
+ sections.push('');
321
+ }
322
+ if (data.intelligence) {
323
+ sections.push('## Intelligence Insights');
324
+ if (data.intelligence.patterns && data.intelligence.patterns.length > 0) {
325
+ sections.push('### Patterns');
326
+ for (const pattern of data.intelligence.patterns) {
327
+ sections.push(`- ${pattern.pattern} (confidence: ${(pattern.confidence * 100).toFixed(1)}%)`);
328
+ }
329
+ sections.push('');
330
+ }
331
+ if (data.intelligence.recommendations && data.intelligence.recommendations.length > 0) {
332
+ sections.push('### Recommendations');
333
+ for (const rec of data.intelligence.recommendations) {
334
+ sections.push(`- ${rec.action}`);
335
+ }
336
+ sections.push('');
337
+ }
338
+ }
339
+ }
340
+ else {
341
+ sections.push(`Status: ${data.status || 'unknown'}`);
342
+ sections.push('');
343
+ sections.push('```json');
344
+ sections.push(JSON.stringify(data, null, 2));
345
+ sections.push('```');
346
+ }
347
+ return sections.join('\n');
348
+ }
349
+ formatEntityContent(data) {
350
+ const sections = [];
351
+ sections.push('# Memory Entity Details');
352
+ sections.push('');
353
+ if (data.status === 'success' && data.entity) {
354
+ const entity = data.entity;
355
+ sections.push('## Entity Information');
356
+ sections.push(`- **ID**: ${entity.id}`);
357
+ sections.push(`- **Title**: ${entity.title}`);
358
+ sections.push(`- **Type**: ${entity.type}`);
359
+ sections.push(`- **Confidence**: ${(entity.confidence * 100).toFixed(1)}%`);
360
+ if (entity.relevance !== undefined) {
361
+ sections.push(`- **Relevance**: ${(entity.relevance * 100).toFixed(1)}%`);
362
+ }
363
+ sections.push(`- **Created**: ${entity.created}`);
364
+ sections.push(`- **Last Modified**: ${entity.lastModified}`);
365
+ sections.push(`- **Tags**: ${entity.tags.join(', ')}`);
366
+ sections.push('');
367
+ sections.push('## Description');
368
+ sections.push(entity.description);
369
+ sections.push('');
370
+ sections.push('## Access Pattern');
371
+ sections.push(`- **Access Count**: ${entity.accessPattern.accessCount}`);
372
+ sections.push(`- **Last Access**: ${entity.accessPattern.lastAccess}`);
373
+ sections.push(`- **Access Frequency**: ${entity.accessPattern.accessFrequency}`);
374
+ sections.push('');
375
+ if (entity.evolution) {
376
+ sections.push('## Evolution');
377
+ sections.push(`- **Version**: ${entity.evolution.version}`);
378
+ sections.push(`- **Change Count**: ${entity.evolution.changeHistory.length}`);
379
+ sections.push('');
380
+ }
381
+ sections.push('## Direct Relationships');
382
+ for (const rel of entity.relationships) {
383
+ sections.push(`- **${rel.type}**: ${rel.relatedEntityId}`);
384
+ sections.push(` - Strength: ${(rel.strength * 100).toFixed(1)}%`);
385
+ }
386
+ sections.push('');
387
+ if (data.relatedEntities && data.relatedEntities.length > 0) {
388
+ sections.push('## Related Entities');
389
+ for (const related of data.relatedEntities) {
390
+ sections.push(`### ${related.title}`);
391
+ sections.push(`- **ID**: ${related.id}`);
392
+ sections.push(`- **Type**: ${related.type}`);
393
+ sections.push(`- **Confidence**: ${(related.confidence * 100).toFixed(1)}%`);
394
+ sections.push('');
395
+ }
396
+ }
397
+ if (data.intelligence &&
398
+ data.intelligence.suggestedActions &&
399
+ data.intelligence.suggestedActions.length > 0) {
400
+ sections.push('## Suggested Actions');
401
+ for (const action of data.intelligence.suggestedActions) {
402
+ sections.push(`- ${action.action}`);
403
+ }
404
+ sections.push('');
405
+ }
406
+ }
407
+ else if (data.status === 'not_found') {
408
+ sections.push(`⚠️ Entity not found: ${data.entityId}`);
409
+ }
410
+ else {
411
+ sections.push(`Status: ${data.status || 'unknown'}`);
412
+ sections.push('');
413
+ sections.push('```json');
414
+ sections.push(JSON.stringify(data, null, 2));
415
+ sections.push('```');
416
+ }
417
+ return sections.join('\n');
418
+ }
419
+ formatRelatedContent(data) {
420
+ const sections = [];
421
+ sections.push('# Related Entities');
422
+ sections.push('');
423
+ if (data.status === 'success') {
424
+ sections.push('## Query Information');
425
+ sections.push(`- **Source Entity**: ${data.sourceEntityId}`);
426
+ sections.push(`- **Max Depth**: ${data.maxDepth}`);
427
+ sections.push(`- **Total Related**: ${data.statistics.totalRelatedEntities}`);
428
+ sections.push('');
429
+ sections.push('## Statistics');
430
+ sections.push('### Path Distribution');
431
+ for (const [depth, count] of Object.entries(data.statistics.pathDistribution)) {
432
+ sections.push(`- ${depth}: ${count}`);
433
+ }
434
+ sections.push('');
435
+ sections.push('### Relationship Types');
436
+ for (const [type, count] of Object.entries(data.statistics.relationshipTypes)) {
437
+ sections.push(`- ${type}: ${count}`);
438
+ }
439
+ sections.push('');
440
+ sections.push('## Related Entities');
441
+ for (const entity of data.relatedEntities) {
442
+ sections.push(`### ${entity.title}`);
443
+ sections.push(`- **ID**: ${entity.id}`);
444
+ sections.push(`- **Type**: ${entity.type}`);
445
+ sections.push(`- **Confidence**: ${(entity.confidence * 100).toFixed(1)}%`);
446
+ sections.push(`- **Relevance**: ${(entity.relevance * 100).toFixed(1)}%`);
447
+ sections.push('');
448
+ sections.push(`**Description**: ${entity.description}`);
449
+ sections.push('');
450
+ }
451
+ sections.push('## Relationship Paths');
452
+ for (const path of data.relationshipPaths) {
453
+ sections.push(`### Depth ${path.depth} (${path.pathLength} entities)`);
454
+ sections.push('**Path**: ' + path.entities.join(' → '));
455
+ sections.push('');
456
+ sections.push('**Relationships**:');
457
+ for (const rel of path.relationshipChain) {
458
+ sections.push(`- ${rel.type} (strength: ${(rel.strength * 100).toFixed(1)}%)`);
459
+ }
460
+ sections.push('');
461
+ }
462
+ }
463
+ else {
464
+ sections.push(`Status: ${data.status || 'unknown'}`);
465
+ sections.push('');
466
+ sections.push('```json');
467
+ sections.push(JSON.stringify(data, null, 2));
468
+ sections.push('```');
469
+ }
470
+ return sections.join('\n');
471
+ }
472
+ formatIntelligenceContent(data) {
473
+ const sections = [];
474
+ sections.push('# Memory Intelligence');
475
+ sections.push('');
476
+ if (data.status === 'success' && data.intelligence) {
477
+ const intel = data.intelligence;
478
+ sections.push('## Context Awareness');
479
+ sections.push('### Current Context');
480
+ sections.push(`- **Project Phase**: ${intel.contextAwareness.currentContext.projectPhase}`);
481
+ sections.push(`- **Business Domain**: ${intel.contextAwareness.currentContext.businessDomain}`);
482
+ sections.push(`- **Technical Stack**: ${intel.contextAwareness.currentContext.technicalStack.join(', ')}`);
483
+ sections.push('');
484
+ if (intel.contextAwareness.recentContextChanges &&
485
+ intel.contextAwareness.recentContextChanges.length > 0) {
486
+ sections.push('### Recent Context Changes');
487
+ for (const change of intel.contextAwareness.recentContextChanges) {
488
+ sections.push(`- ${change.timestamp}: ${change.description || 'Context updated'}`);
489
+ }
490
+ sections.push('');
491
+ }
492
+ sections.push('## Pattern Recognition');
493
+ sections.push(`- **Pattern Confidence**: ${(intel.patternRecognition.patternConfidence * 100).toFixed(1)}%`);
494
+ sections.push('');
495
+ if (intel.patternRecognition.discoveredPatterns &&
496
+ intel.patternRecognition.discoveredPatterns.length > 0) {
497
+ sections.push('### Discovered Patterns');
498
+ for (const pattern of intel.patternRecognition.discoveredPatterns) {
499
+ sections.push(`#### ${pattern.pattern}`);
500
+ sections.push(`- **Confidence**: ${(pattern.confidence * 100).toFixed(1)}%`);
501
+ sections.push(`- **Frequency**: ${pattern.frequency}`);
502
+ sections.push(`- **Applicability Score**: ${(pattern.applicabilityScore * 100).toFixed(1)}%`);
503
+ sections.push(`- **Contexts**: ${pattern.contexts.join(', ')}`);
504
+ sections.push('');
505
+ }
506
+ }
507
+ if (intel.patternRecognition.emergentBehaviors &&
508
+ intel.patternRecognition.emergentBehaviors.length > 0) {
509
+ sections.push('### Emergent Behaviors');
510
+ for (const behavior of intel.patternRecognition.emergentBehaviors) {
511
+ sections.push(`- ${behavior}`);
512
+ }
513
+ sections.push('');
514
+ }
515
+ sections.push('## Relationship Inference');
516
+ if (intel.relationshipInference.suggestedRelationships &&
517
+ intel.relationshipInference.suggestedRelationships.length > 0) {
518
+ sections.push('### Suggested Relationships');
519
+ for (const rel of intel.relationshipInference.suggestedRelationships) {
520
+ sections.push(`- ${rel.sourceId} → ${rel.targetId} (${rel.type})`);
521
+ sections.push(` - Confidence: ${(rel.confidence * 100).toFixed(1)}%`);
522
+ sections.push(` - Reason: ${rel.reason}`);
523
+ }
524
+ sections.push('');
525
+ }
526
+ if (intel.relationshipInference.weakConnections &&
527
+ intel.relationshipInference.weakConnections.length > 0) {
528
+ sections.push('### Weak Connections');
529
+ for (const conn of intel.relationshipInference.weakConnections) {
530
+ sections.push(`- ${conn.sourceId} ↔ ${conn.targetId} (strength: ${(conn.strength * 100).toFixed(1)}%)`);
531
+ }
532
+ sections.push('');
533
+ }
534
+ if (intel.relationshipInference.conflictDetection &&
535
+ intel.relationshipInference.conflictDetection.length > 0) {
536
+ sections.push('### Conflict Detection');
537
+ for (const conflict of intel.relationshipInference.conflictDetection) {
538
+ sections.push(`- ${conflict.description}`);
539
+ sections.push(` - Severity: ${conflict.severity}`);
540
+ }
541
+ sections.push('');
542
+ }
543
+ sections.push('## Adaptive Recommendations');
544
+ if (intel.adaptiveRecommendations.nextActions &&
545
+ intel.adaptiveRecommendations.nextActions.length > 0) {
546
+ sections.push('### Next Actions');
547
+ for (const action of intel.adaptiveRecommendations.nextActions) {
548
+ sections.push(`#### ${action.action}`);
549
+ sections.push(`- **Priority**: ${action.priority}`);
550
+ sections.push(`- **Confidence**: ${(action.confidence * 100).toFixed(1)}%`);
551
+ sections.push(`- **Reason**: ${action.reason}`);
552
+ sections.push('');
553
+ }
554
+ }
555
+ if (intel.adaptiveRecommendations.knowledgeGaps &&
556
+ intel.adaptiveRecommendations.knowledgeGaps.length > 0) {
557
+ sections.push('### Knowledge Gaps');
558
+ for (const gap of intel.adaptiveRecommendations.knowledgeGaps) {
559
+ sections.push(`- ${gap.description} (impact: ${gap.impact})`);
560
+ }
561
+ sections.push('');
562
+ }
563
+ }
564
+ else {
565
+ sections.push(`Status: ${data.status || 'unknown'}`);
566
+ sections.push('');
567
+ sections.push('```json');
568
+ sections.push(JSON.stringify(data, null, 2));
569
+ sections.push('```');
570
+ }
571
+ return sections.join('\n');
572
+ }
573
+ formatLoadAdrsContent(data) {
574
+ const sections = [];
575
+ sections.push('# Load ADRs into Memory');
576
+ sections.push('');
577
+ if (data.status === 'success') {
578
+ sections.push(`✅ ${data.message}`);
579
+ sections.push('');
580
+ sections.push('## Summary');
581
+ sections.push(`- **Total ADRs**: ${data.summary.totalAdrs}`);
582
+ sections.push(`- **Entities Created**: ${data.summary.entitiesCreated}`);
583
+ sections.push(`- **Relationships Inferred**: ${data.summary.relationshipsInferred}`);
584
+ sections.push('');
585
+ sections.push('### Status Distribution');
586
+ for (const [status, count] of Object.entries(data.summary.statusDistribution)) {
587
+ sections.push(`- ${status}: ${count}`);
588
+ }
589
+ sections.push('');
590
+ if (data.summary.categoryDistribution) {
591
+ sections.push('### Category Distribution');
592
+ for (const [category, count] of Object.entries(data.summary.categoryDistribution)) {
593
+ sections.push(`- ${category}: ${count}`);
594
+ }
595
+ sections.push('');
596
+ }
597
+ sections.push('## Transformation Insights');
598
+ sections.push(`- **Average Confidence**: ${(data.transformation.averageConfidence * 100).toFixed(1)}%`);
599
+ sections.push(`- **Technical Stack**: ${data.transformation.technicalStackCoverage.join(', ')}`);
600
+ sections.push(`- **Business Domains**: ${data.transformation.businessDomains.join(', ')}`);
601
+ sections.push('');
602
+ sections.push('## Created Entities');
603
+ for (const entity of data.entities.slice(0, 10)) {
604
+ sections.push(`- **${entity.title}** (${entity.type})`);
605
+ sections.push(` - ID: ${entity.id}`);
606
+ sections.push(` - Confidence: ${(entity.confidence * 100).toFixed(1)}%`);
607
+ sections.push(` - Status: ${entity.status}`);
608
+ }
609
+ if (data.entities.length > 10) {
610
+ sections.push(`... and ${data.entities.length - 10} more`);
611
+ }
612
+ sections.push('');
613
+ sections.push('## Inferred Relationships');
614
+ for (const rel of data.relationships.slice(0, 10)) {
615
+ sections.push(`- **${rel.type}**: ${rel.sourceTitle} → ${rel.targetTitle}`);
616
+ sections.push(` - Strength: ${(rel.strength * 100).toFixed(1)}%`);
617
+ sections.push(` - Confidence: ${(rel.confidence * 100).toFixed(1)}%`);
618
+ }
619
+ if (data.relationships.length > 10) {
620
+ sections.push(`... and ${data.relationships.length - 10} more`);
621
+ }
622
+ }
623
+ else if (data.status === 'no_adrs_found') {
624
+ sections.push(`⚠️ ${data.message}`);
625
+ sections.push('');
626
+ if (data.recommendations && data.recommendations.length > 0) {
627
+ sections.push('## Recommendations');
628
+ for (const rec of data.recommendations) {
629
+ sections.push(`- ${rec}`);
630
+ }
631
+ }
632
+ }
633
+ else {
634
+ sections.push(`Status: ${data.status || 'unknown'}`);
635
+ sections.push('');
636
+ sections.push('```json');
637
+ sections.push(JSON.stringify(data, null, 2));
638
+ sections.push('```');
639
+ }
640
+ return sections.join('\n');
641
+ }
642
+ /**
643
+ * Handle resource read request
644
+ */
645
+ async read(uri) {
646
+ try {
647
+ this.logger.debug('Memory snapshots resource read', 'MemorySnapshotsResource', { uri });
648
+ // Check cache first
649
+ const cached = await this.cache.get(uri);
650
+ if (cached) {
651
+ this.logger.debug('Returning cached memory data', 'MemorySnapshotsResource', { uri });
652
+ return cached;
653
+ }
654
+ // Parse URI
655
+ const { operation, entityId } = this.parseUri(uri);
656
+ const queryParams = this.parseQueryParams(uri);
657
+ // Build tool parameters
658
+ const toolParams = this.buildToolParams(operation, entityId, queryParams);
659
+ // Execute memory loading tool
660
+ const toolResult = await this.memoryLoadingTool.execute(toolParams);
661
+ if (toolResult.isError || !toolResult.content || !toolResult.content[0]) {
662
+ throw new Error(toolResult.content?.[0]?.text || 'Tool execution failed');
663
+ }
664
+ // Extract and format data
665
+ const memoryData = this.extractMemoryData(toolResult.content[0].text);
666
+ const formattedContent = this.formatMemoryContent(operation, memoryData, queryParams);
667
+ const result = {
668
+ contents: [
669
+ {
670
+ uri,
671
+ mimeType: 'text/markdown',
672
+ text: formattedContent,
673
+ },
674
+ ],
675
+ };
676
+ // Cache the result (TTL in seconds)
677
+ this.cache.set(uri, result, this.CACHE_TTL);
678
+ return result;
679
+ }
680
+ catch (error) {
681
+ this.logger.error('Memory snapshots resource read failed', 'MemorySnapshotsResource', error instanceof Error ? error : undefined, { uri, error });
682
+ // Return error as resource content
683
+ return {
684
+ contents: [
685
+ {
686
+ uri,
687
+ mimeType: 'text/markdown',
688
+ text: `# Memory Snapshots Error\n\n⚠️ Failed to read memory resource:\n\n\`\`\`\n${error instanceof Error ? error.message : String(error)}\n\`\`\``,
689
+ },
690
+ ],
691
+ };
692
+ }
693
+ }
694
+ /**
695
+ * List available memory snapshot resources
696
+ */
697
+ listTemplates() {
698
+ return [
699
+ {
700
+ uriTemplate: 'adr://memory-snapshots/current',
701
+ name: 'Current Memory Snapshot',
702
+ description: 'Current snapshot of the memory system with entities and relationships',
703
+ mimeType: 'text/markdown',
704
+ },
705
+ {
706
+ uriTemplate: 'adr://memory-snapshots/query?entityTypes={types}&tags={tags}&textQuery={query}',
707
+ name: 'Query Memory Entities',
708
+ description: 'Query memory entities with filters and search criteria',
709
+ mimeType: 'text/markdown',
710
+ },
711
+ {
712
+ uriTemplate: 'adr://memory-snapshots/entity/{entityId}',
713
+ name: 'Memory Entity Details',
714
+ description: 'Detailed information about a specific memory entity',
715
+ mimeType: 'text/markdown',
716
+ },
717
+ {
718
+ uriTemplate: 'adr://memory-snapshots/related/{entityId}?maxDepth={depth}',
719
+ name: 'Related Entities',
720
+ description: 'Find entities related to a specific entity with configurable depth',
721
+ mimeType: 'text/markdown',
722
+ },
723
+ {
724
+ uriTemplate: 'adr://memory-snapshots/intelligence',
725
+ name: 'Memory Intelligence',
726
+ description: 'Intelligence analysis including patterns, relationships, and recommendations',
727
+ mimeType: 'text/markdown',
728
+ },
729
+ {
730
+ uriTemplate: 'adr://memory-snapshots/load-adrs?forceReload={true|false}',
731
+ name: 'Load ADRs into Memory',
732
+ description: 'Load ADRs from the configured directory into the memory system',
733
+ mimeType: 'text/markdown',
734
+ },
735
+ ];
736
+ }
737
+ }
738
+ /**
739
+ * Generate memory snapshots resource for knowledge graph and learning system access.
740
+ *
741
+ * Provides access to the MCP server's intelligent memory system including project analyses,
742
+ * recommendations, deployments, and learned patterns. Supports temporal queries and
743
+ * contextual retrieval for AI-enhanced decision making.
744
+ *
745
+ * **Query Parameters:**
746
+ * - `type`: Snapshot type - "current" (latest), "historical" (time-based), "all" (complete)
747
+ * - `projectId`: Filter by project identifier
748
+ * - `since`: ISO timestamp for historical queries (e.g., "2025-10-01T00:00:00Z")
749
+ * - `limit`: Maximum number of snapshots to return (default: 10, max: 100)
750
+ *
751
+ * **Memory System Features:**
752
+ * - Project analysis history with patterns and predictions
753
+ * - Recommendation tracking with success metrics
754
+ * - Deployment history with trend analysis
755
+ * - Configuration changes and their impacts
756
+ * - Cross-project learning and insights
757
+ *
758
+ * @param _params - URL path parameters (currently unused, reserved for future routing)
759
+ * @param searchParams - URL query parameters controlling snapshot selection
760
+ *
761
+ * @returns Promise resolving to resource generation result containing:
762
+ * - data: Memory snapshots with metadata, timestamps, and relationships
763
+ * - contentType: "application/json"
764
+ * - lastModified: ISO timestamp of snapshot generation
765
+ * - cacheKey: Unique identifier for caching
766
+ * - ttl: Cache duration (60 seconds for real-time memory access)
767
+ * - etag: Entity tag for cache validation
768
+ *
769
+ * @throws {Error} When memory system access fails or query parameters invalid
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * // Get current memory snapshot
774
+ * const current = await generateMemorySnapshotsResource({}, new URLSearchParams());
775
+ * console.log(`Total memories: ${current.data.summary.total}`);
776
+ * console.log(`Recent analyses: ${current.data.recent.analyses.length}`);
777
+ *
778
+ * // Get historical snapshots since specific date
779
+ * const historical = await generateMemorySnapshotsResource(
780
+ * {},
781
+ * new URLSearchParams('type=historical&since=2025-10-01T00:00:00Z&limit=50')
782
+ * );
783
+ *
784
+ * // Filter by project
785
+ * const projectMemory = await generateMemorySnapshotsResource(
786
+ * {},
787
+ * new URLSearchParams('projectId=mcp-adr-analysis-server')
788
+ * );
789
+ *
790
+ * // Expected output structure:
791
+ * {
792
+ * data: {
793
+ * snapshot: {
794
+ * id: "snapshot-2025-10-12",
795
+ * timestamp: "2025-10-12T17:00:00.000Z",
796
+ * type: "current"
797
+ * },
798
+ * summary: {
799
+ * total: 150,
800
+ * byType: {
801
+ * analysis: 50,
802
+ * recommendation: 40,
803
+ * deployment: 30,
804
+ * configuration: 20,
805
+ * interaction: 10
806
+ * }
807
+ * },
808
+ * recent: {
809
+ * analyses: [...],
810
+ * recommendations: [...],
811
+ * deployments: [...]
812
+ * },
813
+ * insights: {
814
+ * patterns: ["Frequent deployment on Fridays", "High test coverage correlates with success"],
815
+ * predictions: ["Next deployment likely to succeed (95% confidence)"]
816
+ * }
817
+ * },
818
+ * contentType: "application/json",
819
+ * cacheKey: "memory-snapshots:current",
820
+ * ttl: 60
821
+ * }
822
+ * ```
823
+ *
824
+ * @since v2.0.0
825
+ * @see {@link MemorySnapshotsResource} for underlying memory access implementation
826
+ */
827
+ export async function generateMemorySnapshotsResource(_params, searchParams) {
828
+ const resource = new MemorySnapshotsResource();
829
+ // Build URI with query parameters
830
+ let uri = 'adr://memory-snapshots/current';
831
+ if (searchParams && searchParams.toString()) {
832
+ uri += `?${searchParams.toString()}`;
833
+ }
834
+ const result = await resource.read(uri);
835
+ if (!result.contents || !result.contents[0]) {
836
+ throw new Error('Failed to generate memory snapshot');
837
+ }
838
+ return {
839
+ data: result.contents[0].text,
840
+ contentType: result.contents[0].mimeType,
841
+ lastModified: new Date().toISOString(),
842
+ cacheKey: `memory-snapshots-${searchParams?.toString() || 'current'}`,
843
+ ttl: 300, // 5 minutes
844
+ etag: `"memory-snapshots-${Date.now()}"`,
845
+ };
846
+ }
847
+ //# sourceMappingURL=memory-snapshots-resource.js.map