@kinqs/brainrouter-mcp-server 0.3.4

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 (337) hide show
  1. package/.env.example +144 -0
  2. package/README.md +56 -0
  3. package/agents/README.md +120 -0
  4. package/agents/code-reviewer.md +97 -0
  5. package/agents/security-auditor.md +101 -0
  6. package/agents/test-engineer.md +95 -0
  7. package/dist/__tests__/agent_mode.test.d.ts +1 -0
  8. package/dist/__tests__/api-routes.test.d.ts +1 -0
  9. package/dist/__tests__/api-routes.test.js +170 -0
  10. package/dist/__tests__/crypto.test.d.ts +1 -0
  11. package/dist/__tests__/crypto.test.js +28 -0
  12. package/dist/__tests__/host-integrations.test.d.ts +1 -0
  13. package/dist/__tests__/host-integrations.test.js +82 -0
  14. package/dist/__tests__/integration.test.d.ts +1 -0
  15. package/dist/__tests__/integration.test.js +50 -0
  16. package/dist/__tests__/loader.test.d.ts +1 -0
  17. package/dist/__tests__/loader.test.js +89 -0
  18. package/dist/__tests__/neural-spark.test.d.ts +1 -0
  19. package/dist/__tests__/neural-spark.test.js +112 -0
  20. package/dist/__tests__/pagination.test.d.ts +1 -0
  21. package/dist/__tests__/pagination.test.js +23 -0
  22. package/dist/__tests__/redaction.test.d.ts +1 -0
  23. package/dist/__tests__/redaction.test.js +17 -0
  24. package/dist/__tests__/registry.test.d.ts +1 -0
  25. package/dist/__tests__/registry.test.js +56 -0
  26. package/dist/__tests__/retry.test.d.ts +1 -0
  27. package/dist/__tests__/retry.test.js +30 -0
  28. package/dist/__tests__/skill-activation.test.d.ts +1 -0
  29. package/dist/__tests__/skill-activation.test.js +112 -0
  30. package/dist/__tests__/working-memory.test.d.ts +1 -0
  31. package/dist/__tests__/working-memory.test.js +200 -0
  32. package/dist/__tests__/workspace-paths.test.d.ts +1 -0
  33. package/dist/__tests__/workspace-paths.test.js +56 -0
  34. package/dist/__tests__/writer.test.d.ts +1 -0
  35. package/dist/__tests__/writer.test.js +94 -0
  36. package/dist/api/auth/crypto.d.ts +4 -0
  37. package/dist/api/auth/crypto.js +54 -0
  38. package/dist/api/middleware/auth.d.ts +12 -0
  39. package/dist/api/middleware/auth.js +90 -0
  40. package/dist/api/pagination.d.ts +18 -0
  41. package/dist/api/pagination.js +32 -0
  42. package/dist/api/routes/auth.d.ts +1 -0
  43. package/dist/api/routes/auth.js +130 -0
  44. package/dist/api/routes/chat-completions.d.ts +7 -0
  45. package/dist/api/routes/chat-completions.js +474 -0
  46. package/dist/api/routes/contradictions.d.ts +1 -0
  47. package/dist/api/routes/contradictions.js +28 -0
  48. package/dist/api/routes/evidence.d.ts +1 -0
  49. package/dist/api/routes/evidence.js +59 -0
  50. package/dist/api/routes/governance.d.ts +1 -0
  51. package/dist/api/routes/governance.js +95 -0
  52. package/dist/api/routes/graph.d.ts +1 -0
  53. package/dist/api/routes/graph.js +25 -0
  54. package/dist/api/routes/hooks.d.ts +1 -0
  55. package/dist/api/routes/hooks.js +88 -0
  56. package/dist/api/routes/memories.d.ts +1 -0
  57. package/dist/api/routes/memories.js +92 -0
  58. package/dist/api/routes/persona.d.ts +1 -0
  59. package/dist/api/routes/persona.js +9 -0
  60. package/dist/api/routes/scenes.d.ts +1 -0
  61. package/dist/api/routes/scenes.js +35 -0
  62. package/dist/api/routes/skills.d.ts +1 -0
  63. package/dist/api/routes/skills.js +14 -0
  64. package/dist/api/routes/stats.d.ts +1 -0
  65. package/dist/api/routes/stats.js +8 -0
  66. package/dist/api/routes/users.d.ts +1 -0
  67. package/dist/api/routes/users.js +82 -0
  68. package/dist/api/routes/working.d.ts +1 -0
  69. package/dist/api/routes/working.js +88 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +492 -0
  72. package/dist/integrations/claude-code.d.ts +12 -0
  73. package/dist/integrations/claude-code.js +35 -0
  74. package/dist/integrations/codex.d.ts +12 -0
  75. package/dist/integrations/codex.js +34 -0
  76. package/dist/integrations/generic-mcp.d.ts +52 -0
  77. package/dist/integrations/generic-mcp.js +118 -0
  78. package/dist/loader.d.ts +29 -0
  79. package/dist/loader.js +200 -0
  80. package/dist/memory/capture.d.ts +35 -0
  81. package/dist/memory/capture.js +230 -0
  82. package/dist/memory/config.d.ts +2 -0
  83. package/dist/memory/config.js +3 -0
  84. package/dist/memory/engine.d.ts +203 -0
  85. package/dist/memory/engine.js +626 -0
  86. package/dist/memory/llm-semaphore.d.ts +41 -0
  87. package/dist/memory/llm-semaphore.js +81 -0
  88. package/dist/memory/memory-type-config.d.ts +11 -0
  89. package/dist/memory/memory-type-config.js +65 -0
  90. package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
  91. package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
  92. package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
  93. package/dist/memory/pipeline/cognitive-dedup.js +38 -0
  94. package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
  95. package/dist/memory/pipeline/cognitive-extractor.js +183 -0
  96. package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
  97. package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
  98. package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
  99. package/dist/memory/pipeline/focus-direction-shift.js +27 -0
  100. package/dist/memory/pipeline/graph-builder.d.ts +11 -0
  101. package/dist/memory/pipeline/graph-builder.js +88 -0
  102. package/dist/memory/pipeline/graph-recall.d.ts +13 -0
  103. package/dist/memory/pipeline/graph-recall.js +55 -0
  104. package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
  105. package/dist/memory/pipeline/identity-distiller.js +40 -0
  106. package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
  107. package/dist/memory/pipeline/l1-contradiction.js +66 -0
  108. package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
  109. package/dist/memory/pipeline/l1-dedup.js +39 -0
  110. package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
  111. package/dist/memory/pipeline/l1-extractor.js +180 -0
  112. package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
  113. package/dist/memory/pipeline/l2-direction-shift.js +27 -0
  114. package/dist/memory/pipeline/l2-scene.d.ts +15 -0
  115. package/dist/memory/pipeline/l2-scene.js +140 -0
  116. package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
  117. package/dist/memory/pipeline/l3-distiller.js +40 -0
  118. package/dist/memory/pipeline/neural-spark.d.ts +27 -0
  119. package/dist/memory/pipeline/neural-spark.js +78 -0
  120. package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
  121. package/dist/memory/pipeline/skill-prewarm.js +127 -0
  122. package/dist/memory/pipeline/task-queue.d.ts +54 -0
  123. package/dist/memory/pipeline/task-queue.js +117 -0
  124. package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
  125. package/dist/memory/prompts/cognitive-contradiction.js +25 -0
  126. package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
  127. package/dist/memory/prompts/cognitive-extraction.js +114 -0
  128. package/dist/memory/prompts/core-identity.d.ts +6 -0
  129. package/dist/memory/prompts/core-identity.js +60 -0
  130. package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
  131. package/dist/memory/prompts/focus-direction-shift.js +32 -0
  132. package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
  133. package/dist/memory/prompts/focus-scene-cluster.js +33 -0
  134. package/dist/memory/prompts/focus-scene.d.ts +7 -0
  135. package/dist/memory/prompts/focus-scene.js +40 -0
  136. package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
  137. package/dist/memory/prompts/graph-extraction-batch.js +54 -0
  138. package/dist/memory/prompts/graph-extraction.d.ts +2 -0
  139. package/dist/memory/prompts/graph-extraction.js +53 -0
  140. package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
  141. package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
  142. package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
  143. package/dist/memory/prompts/l1-contradiction.js +25 -0
  144. package/dist/memory/prompts/l1-extraction.d.ts +10 -0
  145. package/dist/memory/prompts/l1-extraction.js +114 -0
  146. package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
  147. package/dist/memory/prompts/l2-direction-shift.js +32 -0
  148. package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
  149. package/dist/memory/prompts/l2-scene-cluster.js +33 -0
  150. package/dist/memory/prompts/l2-scene.d.ts +7 -0
  151. package/dist/memory/prompts/l2-scene.js +40 -0
  152. package/dist/memory/prompts/l3-persona.d.ts +6 -0
  153. package/dist/memory/prompts/l3-persona.js +60 -0
  154. package/dist/memory/recall.d.ts +47 -0
  155. package/dist/memory/recall.js +427 -0
  156. package/dist/memory/redaction.d.ts +1 -0
  157. package/dist/memory/redaction.js +24 -0
  158. package/dist/memory/retry.d.ts +13 -0
  159. package/dist/memory/retry.js +53 -0
  160. package/dist/memory/scheduler.d.ts +9 -0
  161. package/dist/memory/scheduler.js +16 -0
  162. package/dist/memory/skill-hints-loader.d.ts +30 -0
  163. package/dist/memory/skill-hints-loader.js +100 -0
  164. package/dist/memory/store/embedding.d.ts +16 -0
  165. package/dist/memory/store/embedding.js +68 -0
  166. package/dist/memory/store/reranker.d.ts +24 -0
  167. package/dist/memory/store/reranker.js +83 -0
  168. package/dist/memory/store/sqlite.d.ts +167 -0
  169. package/dist/memory/store/sqlite.js +1816 -0
  170. package/dist/memory/store/types.d.ts +101 -0
  171. package/dist/memory/store/types.js +1 -0
  172. package/dist/memory/types.d.ts +207 -0
  173. package/dist/memory/types.js +7 -0
  174. package/dist/memory/validation.d.ts +441 -0
  175. package/dist/memory/validation.js +129 -0
  176. package/dist/memory/working/canvas.d.ts +5 -0
  177. package/dist/memory/working/canvas.js +43 -0
  178. package/dist/memory/working/offload.d.ts +71 -0
  179. package/dist/memory/working/offload.js +211 -0
  180. package/dist/memory/working/step-log.d.ts +16 -0
  181. package/dist/memory/working/step-log.js +35 -0
  182. package/dist/registry.d.ts +34 -0
  183. package/dist/registry.js +305 -0
  184. package/dist/resolver.d.ts +17 -0
  185. package/dist/resolver.js +126 -0
  186. package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
  187. package/dist/scripts/validate-foreign-workspace-path.js +39 -0
  188. package/dist/tools/agent_memory_tools.d.ts +485 -0
  189. package/dist/tools/agent_memory_tools.js +793 -0
  190. package/dist/tools/create_skill.d.ts +46 -0
  191. package/dist/tools/create_skill.js +46 -0
  192. package/dist/tools/get_doc.d.ts +21 -0
  193. package/dist/tools/get_doc.js +24 -0
  194. package/dist/tools/get_persona.d.ts +15 -0
  195. package/dist/tools/get_persona.js +20 -0
  196. package/dist/tools/get_reference.d.ts +15 -0
  197. package/dist/tools/get_reference.js +20 -0
  198. package/dist/tools/get_skill.d.ts +34 -0
  199. package/dist/tools/get_skill.js +65 -0
  200. package/dist/tools/get_template_doc.d.ts +21 -0
  201. package/dist/tools/get_template_doc.js +24 -0
  202. package/dist/tools/list_docs.d.ts +15 -0
  203. package/dist/tools/list_docs.js +16 -0
  204. package/dist/tools/list_skills.d.ts +18 -0
  205. package/dist/tools/list_skills.js +17 -0
  206. package/dist/tools/list_template_docs.d.ts +15 -0
  207. package/dist/tools/list_template_docs.js +16 -0
  208. package/dist/tools/memory-engineering.d.ts +225 -0
  209. package/dist/tools/memory-engineering.js +284 -0
  210. package/dist/tools/memory-explain.d.ts +34 -0
  211. package/dist/tools/memory-explain.js +109 -0
  212. package/dist/tools/memory-governance.d.ts +171 -0
  213. package/dist/tools/memory-governance.js +224 -0
  214. package/dist/tools/memory-hooks.d.ts +67 -0
  215. package/dist/tools/memory-hooks.js +102 -0
  216. package/dist/tools/memory-working.d.ts +98 -0
  217. package/dist/tools/memory-working.js +101 -0
  218. package/dist/tools/memory_capture_turn.d.ts +66 -0
  219. package/dist/tools/memory_capture_turn.js +85 -0
  220. package/dist/tools/memory_consolidate.d.ts +55 -0
  221. package/dist/tools/memory_consolidate.js +176 -0
  222. package/dist/tools/memory_contradictions.d.ts +53 -0
  223. package/dist/tools/memory_contradictions.js +52 -0
  224. package/dist/tools/memory_graph_query.d.ts +51 -0
  225. package/dist/tools/memory_graph_query.js +35 -0
  226. package/dist/tools/memory_mark_cited.d.ts +43 -0
  227. package/dist/tools/memory_mark_cited.js +63 -0
  228. package/dist/tools/memory_recall.d.ts +77 -0
  229. package/dist/tools/memory_recall.js +81 -0
  230. package/dist/tools/memory_register_skill_hints.d.ts +49 -0
  231. package/dist/tools/memory_register_skill_hints.js +55 -0
  232. package/dist/tools/memory_resolve_session.d.ts +24 -0
  233. package/dist/tools/memory_resolve_session.js +133 -0
  234. package/dist/tools/memory_search.d.ts +146 -0
  235. package/dist/tools/memory_search.js +84 -0
  236. package/dist/tools/search_skills.d.ts +18 -0
  237. package/dist/tools/search_skills.js +17 -0
  238. package/dist/tools/update_doc.d.ts +24 -0
  239. package/dist/tools/update_doc.js +35 -0
  240. package/dist/tools/update_skill.d.ts +30 -0
  241. package/dist/tools/update_skill.js +80 -0
  242. package/dist/types.d.ts +81 -0
  243. package/dist/types.js +4 -0
  244. package/dist/writer.d.ts +30 -0
  245. package/dist/writer.js +220 -0
  246. package/docs/TEMPLATE ONLY +1 -0
  247. package/docs/api/API.md +64 -0
  248. package/docs/api/security/SECURITY.md +58 -0
  249. package/docs/deployment/DockerDeployment.md +30 -0
  250. package/docs/design/Design.md +59 -0
  251. package/docs/design/themes/apple.md +101 -0
  252. package/docs/design/themes/dieter-grid.md +100 -0
  253. package/docs/design/themes/gallery-white.md +100 -0
  254. package/docs/design/themes/pinterest.md +101 -0
  255. package/docs/design/themes/realty-open-house.md +101 -0
  256. package/docs/design/themes/vodafone.md +101 -0
  257. package/docs/hooks/Hooks.md +30 -0
  258. package/docs/schema/Schema.md +35 -0
  259. package/docs/strategy/ScalingStrategy.md +19 -0
  260. package/package.json +88 -0
  261. package/references/accessibility-checklist.md +160 -0
  262. package/references/orchestration-patterns.md +370 -0
  263. package/references/performance-checklist.md +153 -0
  264. package/references/security-checklist.md +134 -0
  265. package/references/testing-patterns.md +236 -0
  266. package/skills/agent/adr-skill/SKILL.md +299 -0
  267. package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
  268. package/skills/agent/bootstrap-skill/SKILL.md +103 -0
  269. package/skills/agent/context-engineering/SKILL.md +307 -0
  270. package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
  271. package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
  272. package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
  273. package/skills/agent/handover-skill/SKILL.md +112 -0
  274. package/skills/agent/idea-refine-skill/SKILL.md +185 -0
  275. package/skills/agent/idea-refine-skill/examples.md +238 -0
  276. package/skills/agent/idea-refine-skill/frameworks.md +99 -0
  277. package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
  278. package/skills/agent/interview-skill/SKILL.md +226 -0
  279. package/skills/agent/planning-skill/SKILL.md +270 -0
  280. package/skills/agent/skill-authoring/SKILL.md +189 -0
  281. package/skills/agent/source-driven-skill/SKILL.md +197 -0
  282. package/skills/agent/spec-driven-skill/SKILL.md +221 -0
  283. package/skills/agent/sync-skill/SKILL.md +92 -0
  284. package/skills/agent/using-agent-skills/SKILL.md +189 -0
  285. package/skills/api/a11y-skill/SKILL.md +88 -0
  286. package/skills/api/api-skill/SKILL.md +123 -0
  287. package/skills/api/auth-skill/SKILL.md +80 -0
  288. package/skills/api/debug-skill/SKILL.md +535 -0
  289. package/skills/api/performance-skill/SKILL.md +100 -0
  290. package/skills/api/testing-skill/SKILL.md +100 -0
  291. package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
  292. package/skills/codebase/code-simplification/SKILL.md +352 -0
  293. package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
  294. package/skills/codebase/concerns-skill/SKILL.md +89 -0
  295. package/skills/codebase/conventions-skill/SKILL.md +95 -0
  296. package/skills/codebase/doc-management-skill/SKILL.md +47 -0
  297. package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
  298. package/skills/communication/1-3-1-rule/SKILL.md +120 -0
  299. package/skills/design/brutalist-skill/SKILL.md +131 -0
  300. package/skills/design/concept-diagrams/SKILL.md +387 -0
  301. package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
  302. package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
  303. package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
  304. package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
  305. package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
  306. package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
  307. package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
  308. package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
  309. package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
  310. package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
  311. package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
  312. package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
  313. package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
  314. package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
  315. package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
  316. package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
  317. package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
  318. package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  319. package/skills/design/concept-diagrams/templates/template.html +174 -0
  320. package/skills/design/gpt-tasteskill/SKILL.md +114 -0
  321. package/skills/design/minimalist-skill/SKILL.md +116 -0
  322. package/skills/design/output-skill/SKILL.md +87 -0
  323. package/skills/design/redesign-skill/SKILL.md +213 -0
  324. package/skills/design/soft-skill/SKILL.md +132 -0
  325. package/skills/design/stitch-skill/EXAMPLE.md +121 -0
  326. package/skills/design/stitch-skill/SKILL.md +222 -0
  327. package/skills/design/taste-skill/SKILL.md +269 -0
  328. package/skills/devops/ci-cd-skill/SKILL.md +402 -0
  329. package/skills/devops/docker-skill/SKILL.md +297 -0
  330. package/skills/devops/domain-skill/SKILL.md +234 -0
  331. package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
  332. package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
  333. package/skills/lifecycle/migration-skill/SKILL.md +218 -0
  334. package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
  335. package/skills/memory/agent-memory/SKILL.md +122 -0
  336. package/skills/qa/browser-testing-skill/SKILL.md +314 -0
  337. package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
@@ -0,0 +1,225 @@
1
+ export declare const memoryEngineeringToolSchemas: readonly [{
2
+ readonly name: "memory_debug_trace_save";
3
+ readonly description: "Save an engineering debug trace, including repro, cause, fix, verification, files, and commands.";
4
+ readonly inputSchema: {
5
+ readonly type: "object";
6
+ readonly properties: {
7
+ readonly userId: {
8
+ readonly type: "string";
9
+ };
10
+ readonly sessionKey: {
11
+ readonly type: "string";
12
+ };
13
+ readonly activeSkill: {
14
+ readonly type: "string";
15
+ };
16
+ readonly symptom: {
17
+ readonly type: "string";
18
+ };
19
+ readonly reproSteps: {
20
+ readonly type: "array";
21
+ readonly items: {
22
+ readonly type: "string";
23
+ };
24
+ };
25
+ readonly suspectedCause: {
26
+ readonly type: "string";
27
+ };
28
+ readonly confirmedCause: {
29
+ readonly type: "string";
30
+ };
31
+ readonly fixSummary: {
32
+ readonly type: "string";
33
+ };
34
+ readonly verificationResult: {
35
+ readonly type: "string";
36
+ };
37
+ readonly failedAttempt: {
38
+ readonly type: "string";
39
+ };
40
+ readonly filePaths: {
41
+ readonly type: "array";
42
+ readonly items: {
43
+ readonly type: "string";
44
+ };
45
+ };
46
+ readonly commands: {
47
+ readonly type: "array";
48
+ readonly items: {
49
+ readonly type: "string";
50
+ };
51
+ };
52
+ };
53
+ readonly required: readonly ["symptom"];
54
+ };
55
+ }, {
56
+ readonly name: "memory_debug_trace_search";
57
+ readonly description: "Search prior engineering debug traces by error, file, command, or symptom.";
58
+ readonly inputSchema: {
59
+ readonly type: "object";
60
+ readonly properties: {
61
+ readonly userId: {
62
+ readonly type: "string";
63
+ };
64
+ readonly query: {
65
+ readonly type: "string";
66
+ };
67
+ readonly limit: {
68
+ readonly type: "number";
69
+ };
70
+ };
71
+ readonly required: readonly ["query"];
72
+ };
73
+ }, {
74
+ readonly name: "memory_failed_attempts";
75
+ readonly description: "Return previously recorded failed attempts for a problem area.";
76
+ readonly inputSchema: {
77
+ readonly type: "object";
78
+ readonly properties: {
79
+ readonly userId: {
80
+ readonly type: "string";
81
+ };
82
+ readonly query: {
83
+ readonly type: "string";
84
+ };
85
+ readonly limit: {
86
+ readonly type: "number";
87
+ };
88
+ };
89
+ readonly required: readonly ["query"];
90
+ };
91
+ }, {
92
+ readonly name: "memory_file_history";
93
+ readonly description: "Return memories and evidence associated with a file path or symbol.";
94
+ readonly inputSchema: {
95
+ readonly type: "object";
96
+ readonly properties: {
97
+ readonly userId: {
98
+ readonly type: "string";
99
+ };
100
+ readonly filePath: {
101
+ readonly type: "string";
102
+ };
103
+ readonly limit: {
104
+ readonly type: "number";
105
+ };
106
+ };
107
+ readonly required: readonly ["filePath"];
108
+ };
109
+ }, {
110
+ readonly name: "memory_task_state";
111
+ readonly description: "Read current task or handover state for a repo/session.";
112
+ readonly inputSchema: {
113
+ readonly type: "object";
114
+ readonly properties: {
115
+ readonly userId: {
116
+ readonly type: "string";
117
+ };
118
+ readonly query: {
119
+ readonly type: "string";
120
+ };
121
+ readonly limit: {
122
+ readonly type: "number";
123
+ };
124
+ };
125
+ };
126
+ }, {
127
+ readonly name: "memory_task_update";
128
+ readonly description: "Write structured task progress, blockers, and next actions.";
129
+ readonly inputSchema: {
130
+ readonly type: "object";
131
+ readonly properties: {
132
+ readonly userId: {
133
+ readonly type: "string";
134
+ };
135
+ readonly sessionKey: {
136
+ readonly type: "string";
137
+ };
138
+ readonly activeSkill: {
139
+ readonly type: "string";
140
+ };
141
+ readonly status: {
142
+ readonly type: "string";
143
+ };
144
+ readonly completed: {
145
+ readonly type: "array";
146
+ readonly items: {
147
+ readonly type: "string";
148
+ };
149
+ };
150
+ readonly blockers: {
151
+ readonly type: "array";
152
+ readonly items: {
153
+ readonly type: "string";
154
+ };
155
+ };
156
+ readonly nextActions: {
157
+ readonly type: "array";
158
+ readonly items: {
159
+ readonly type: "string";
160
+ };
161
+ };
162
+ readonly filePaths: {
163
+ readonly type: "array";
164
+ readonly items: {
165
+ readonly type: "string";
166
+ };
167
+ };
168
+ };
169
+ readonly required: readonly ["status"];
170
+ };
171
+ }, {
172
+ readonly name: "memory_handover";
173
+ readonly description: "Generate a compact continuation note from current task memories.";
174
+ readonly inputSchema: {
175
+ readonly type: "object";
176
+ readonly properties: {
177
+ readonly userId: {
178
+ readonly type: "string";
179
+ };
180
+ readonly query: {
181
+ readonly type: "string";
182
+ };
183
+ readonly limit: {
184
+ readonly type: "number";
185
+ };
186
+ };
187
+ };
188
+ }, {
189
+ readonly name: "memory_verify";
190
+ readonly description: "Update verification status and confidence for a memory after re-checking it.";
191
+ readonly inputSchema: {
192
+ readonly type: "object";
193
+ readonly properties: {
194
+ readonly userId: {
195
+ readonly type: "string";
196
+ };
197
+ readonly recordId: {
198
+ readonly type: "string";
199
+ };
200
+ readonly confidence: {
201
+ readonly type: "number";
202
+ };
203
+ readonly status: {
204
+ readonly type: "string";
205
+ readonly enum: readonly ["active", "superseded", "archived", "needs_verification"];
206
+ };
207
+ readonly verificationStatus: {
208
+ readonly type: "string";
209
+ readonly enum: readonly ["", "verified", "unverified", "stale"];
210
+ };
211
+ readonly note: {
212
+ readonly type: "string";
213
+ };
214
+ };
215
+ readonly required: readonly ["recordId", "verificationStatus"];
216
+ };
217
+ }];
218
+ export declare function handleMemoryEngineeringTool(name: string, args: unknown, options?: {
219
+ defaultUserId?: string;
220
+ }): Promise<{
221
+ content: {
222
+ type: string;
223
+ text: string;
224
+ }[];
225
+ }>;
@@ -0,0 +1,284 @@
1
+ import { z } from "zod";
2
+ import { memoryEngine } from "../memory/engine.js";
3
+ const baseUser = { userId: z.string().optional() };
4
+ function effectiveUserId(userId, defaultUserId) {
5
+ return userId ?? defaultUserId ?? "default";
6
+ }
7
+ function toolResult(value) {
8
+ return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
9
+ }
10
+ const stringList = z.array(z.string()).optional().default([]);
11
+ export const memoryEngineeringToolSchemas = [
12
+ {
13
+ name: "memory_debug_trace_save",
14
+ description: "Save an engineering debug trace, including repro, cause, fix, verification, files, and commands.",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ userId: { type: "string" },
19
+ sessionKey: { type: "string" },
20
+ activeSkill: { type: "string" },
21
+ symptom: { type: "string" },
22
+ reproSteps: { type: "array", items: { type: "string" } },
23
+ suspectedCause: { type: "string" },
24
+ confirmedCause: { type: "string" },
25
+ fixSummary: { type: "string" },
26
+ verificationResult: { type: "string" },
27
+ failedAttempt: { type: "string" },
28
+ filePaths: { type: "array", items: { type: "string" } },
29
+ commands: { type: "array", items: { type: "string" } },
30
+ },
31
+ required: ["symptom"],
32
+ },
33
+ },
34
+ {
35
+ name: "memory_debug_trace_search",
36
+ description: "Search prior engineering debug traces by error, file, command, or symptom.",
37
+ inputSchema: {
38
+ type: "object",
39
+ properties: { userId: { type: "string" }, query: { type: "string" }, limit: { type: "number" } },
40
+ required: ["query"],
41
+ },
42
+ },
43
+ {
44
+ name: "memory_failed_attempts",
45
+ description: "Return previously recorded failed attempts for a problem area.",
46
+ inputSchema: {
47
+ type: "object",
48
+ properties: { userId: { type: "string" }, query: { type: "string" }, limit: { type: "number" } },
49
+ required: ["query"],
50
+ },
51
+ },
52
+ {
53
+ name: "memory_file_history",
54
+ description: "Return memories and evidence associated with a file path or symbol.",
55
+ inputSchema: {
56
+ type: "object",
57
+ properties: { userId: { type: "string" }, filePath: { type: "string" }, limit: { type: "number" } },
58
+ required: ["filePath"],
59
+ },
60
+ },
61
+ {
62
+ name: "memory_task_state",
63
+ description: "Read current task or handover state for a repo/session.",
64
+ inputSchema: {
65
+ type: "object",
66
+ properties: { userId: { type: "string" }, query: { type: "string" }, limit: { type: "number" } },
67
+ },
68
+ },
69
+ {
70
+ name: "memory_task_update",
71
+ description: "Write structured task progress, blockers, and next actions.",
72
+ inputSchema: {
73
+ type: "object",
74
+ properties: {
75
+ userId: { type: "string" },
76
+ sessionKey: { type: "string" },
77
+ activeSkill: { type: "string" },
78
+ status: { type: "string" },
79
+ completed: { type: "array", items: { type: "string" } },
80
+ blockers: { type: "array", items: { type: "string" } },
81
+ nextActions: { type: "array", items: { type: "string" } },
82
+ filePaths: { type: "array", items: { type: "string" } },
83
+ },
84
+ required: ["status"],
85
+ },
86
+ },
87
+ {
88
+ name: "memory_handover",
89
+ description: "Generate a compact continuation note from current task memories.",
90
+ inputSchema: {
91
+ type: "object",
92
+ properties: { userId: { type: "string" }, query: { type: "string" }, limit: { type: "number" } },
93
+ },
94
+ },
95
+ {
96
+ name: "memory_verify",
97
+ description: "Update verification status and confidence for a memory after re-checking it.",
98
+ inputSchema: {
99
+ type: "object",
100
+ properties: {
101
+ userId: { type: "string" },
102
+ recordId: { type: "string" },
103
+ confidence: { type: "number" },
104
+ status: { type: "string", enum: ["active", "superseded", "archived", "needs_verification"] },
105
+ verificationStatus: { type: "string", enum: ["", "verified", "unverified", "stale"] },
106
+ note: { type: "string" },
107
+ },
108
+ required: ["recordId", "verificationStatus"],
109
+ },
110
+ },
111
+ ];
112
+ export async function handleMemoryEngineeringTool(name, args, options) {
113
+ switch (name) {
114
+ case "memory_debug_trace_save": {
115
+ const params = z.object({
116
+ ...baseUser,
117
+ sessionKey: z.string().optional(),
118
+ activeSkill: z.string().optional(),
119
+ symptom: z.string().min(1),
120
+ reproSteps: stringList,
121
+ suspectedCause: z.string().optional(),
122
+ confirmedCause: z.string().optional(),
123
+ fixSummary: z.string().optional(),
124
+ verificationResult: z.string().optional(),
125
+ failedAttempt: z.string().optional(),
126
+ filePaths: stringList,
127
+ commands: stringList,
128
+ }).parse(args);
129
+ const userId = effectiveUserId(params.userId, options?.defaultUserId);
130
+ const records = [
131
+ memoryEngine.upsertEngineeringMemory({
132
+ userId,
133
+ sessionKey: params.sessionKey,
134
+ activeSkill: params.activeSkill,
135
+ type: "bug_finding",
136
+ content: `Bug finding: ${params.symptom}${params.confirmedCause ? `. Confirmed cause: ${params.confirmedCause}` : ""}`,
137
+ priority: 85,
138
+ sourceKind: "user_instruction",
139
+ filePaths: params.filePaths,
140
+ commands: params.commands,
141
+ }),
142
+ memoryEngine.upsertEngineeringMemory({
143
+ userId,
144
+ sessionKey: params.sessionKey,
145
+ activeSkill: params.activeSkill,
146
+ type: "debug_trace",
147
+ content: [
148
+ `Debug symptom: ${params.symptom}`,
149
+ params.reproSteps.length ? `Repro steps: ${params.reproSteps.join("; ")}` : "",
150
+ params.suspectedCause ? `Suspected cause: ${params.suspectedCause}` : "",
151
+ params.confirmedCause ? `Confirmed cause: ${params.confirmedCause}` : "",
152
+ ].filter(Boolean).join(". "),
153
+ priority: 80,
154
+ sourceKind: "user_instruction",
155
+ filePaths: params.filePaths,
156
+ commands: params.commands,
157
+ metadata: { reproSteps: params.reproSteps },
158
+ }),
159
+ ];
160
+ if (params.failedAttempt) {
161
+ records.push(memoryEngine.upsertEngineeringMemory({
162
+ userId,
163
+ sessionKey: params.sessionKey,
164
+ activeSkill: params.activeSkill,
165
+ type: "failed_attempt",
166
+ content: `Failed attempt: ${params.failedAttempt}`,
167
+ priority: 70,
168
+ filePaths: params.filePaths,
169
+ commands: params.commands,
170
+ }));
171
+ }
172
+ if (params.fixSummary) {
173
+ records.push(memoryEngine.upsertEngineeringMemory({
174
+ userId,
175
+ sessionKey: params.sessionKey,
176
+ activeSkill: params.activeSkill,
177
+ type: "fix_summary",
178
+ content: `Fix summary: ${params.fixSummary}`,
179
+ priority: 80,
180
+ filePaths: params.filePaths,
181
+ commands: params.commands,
182
+ }));
183
+ }
184
+ if (params.verificationResult) {
185
+ records.push(memoryEngine.upsertEngineeringMemory({
186
+ userId,
187
+ sessionKey: params.sessionKey,
188
+ activeSkill: params.activeSkill,
189
+ type: "verification_result",
190
+ content: `Verification result: ${params.verificationResult}`,
191
+ priority: 75,
192
+ sourceKind: "test_result",
193
+ verificationStatus: "verified",
194
+ filePaths: params.filePaths,
195
+ commands: params.commands,
196
+ }));
197
+ }
198
+ return toolResult({ records });
199
+ }
200
+ case "memory_debug_trace_search": {
201
+ const params = z.object({ ...baseUser, query: z.string(), limit: z.number().int().min(1).max(100).optional().default(20) }).parse(args);
202
+ const hits = memoryEngine.searchMemoryRecords(effectiveUserId(params.userId, options?.defaultUserId), params.query, params.limit)
203
+ .filter((hit) => ["bug_finding", "debug_trace", "fix_summary", "verification_result", "failed_attempt"].includes(hit.type));
204
+ return toolResult(hits);
205
+ }
206
+ case "memory_failed_attempts": {
207
+ const params = z.object({ ...baseUser, query: z.string(), limit: z.number().int().min(1).max(100).optional().default(20) }).parse(args);
208
+ const hits = memoryEngine.searchMemoryRecords(effectiveUserId(params.userId, options?.defaultUserId), params.query, params.limit)
209
+ .filter((hit) => hit.type === "failed_attempt");
210
+ return toolResult(hits);
211
+ }
212
+ case "memory_file_history": {
213
+ const params = z.object({ ...baseUser, filePath: z.string(), limit: z.number().int().min(1).max(100).optional().default(20) }).parse(args);
214
+ return toolResult(memoryEngine.getMemoriesByFilePath(effectiveUserId(params.userId, options?.defaultUserId), params.filePath, params.limit));
215
+ }
216
+ case "memory_task_state": {
217
+ const params = z.object({ ...baseUser, query: z.string().optional().default("task state handover blocked next actions"), limit: z.number().int().min(1).max(100).optional().default(20) }).parse(args ?? {});
218
+ const hits = memoryEngine.searchMemoryRecords(effectiveUserId(params.userId, options?.defaultUserId), params.query, params.limit)
219
+ .filter((hit) => ["task_state", "handover_note", "blocked_reason"].includes(hit.type));
220
+ return toolResult(hits);
221
+ }
222
+ case "memory_task_update": {
223
+ const params = z.object({
224
+ ...baseUser,
225
+ sessionKey: z.string().optional(),
226
+ activeSkill: z.string().optional(),
227
+ status: z.string().min(1),
228
+ completed: stringList,
229
+ blockers: stringList,
230
+ nextActions: stringList,
231
+ filePaths: stringList,
232
+ }).parse(args);
233
+ const userId = effectiveUserId(params.userId, options?.defaultUserId);
234
+ const record = memoryEngine.upsertEngineeringMemory({
235
+ userId,
236
+ sessionKey: params.sessionKey,
237
+ activeSkill: params.activeSkill,
238
+ type: params.blockers.length > 0 ? "blocked_reason" : "task_state",
239
+ content: [
240
+ `Task status: ${params.status}`,
241
+ params.completed.length ? `Completed: ${params.completed.join("; ")}` : "",
242
+ params.blockers.length ? `Blockers: ${params.blockers.join("; ")}` : "",
243
+ params.nextActions.length ? `Next actions: ${params.nextActions.join("; ")}` : "",
244
+ ].filter(Boolean).join(". "),
245
+ priority: params.blockers.length > 0 ? 85 : 80,
246
+ filePaths: params.filePaths,
247
+ metadata: {
248
+ completed: params.completed,
249
+ blockers: params.blockers,
250
+ nextActions: params.nextActions,
251
+ },
252
+ });
253
+ return toolResult(record);
254
+ }
255
+ case "memory_handover": {
256
+ const params = z.object({ ...baseUser, query: z.string().optional().default("handover task state next actions"), limit: z.number().int().min(1).max(50).optional().default(10) }).parse(args ?? {});
257
+ const hits = memoryEngine.searchMemoryRecords(effectiveUserId(params.userId, options?.defaultUserId), params.query, params.limit)
258
+ .filter((hit) => ["task_state", "handover_note", "blocked_reason", "fix_summary", "verification_result"].includes(hit.type));
259
+ return toolResult({
260
+ handover: hits.map((hit) => `- [${hit.type}] ${hit.content}`).join("\n"),
261
+ records: hits,
262
+ });
263
+ }
264
+ case "memory_verify": {
265
+ const params = z.object({
266
+ ...baseUser,
267
+ recordId: z.string(),
268
+ confidence: z.number().min(0).max(1).optional(),
269
+ status: z.enum(["active", "superseded", "archived", "needs_verification"]).optional(),
270
+ verificationStatus: z.enum(["", "verified", "unverified", "stale"]),
271
+ note: z.string().optional(),
272
+ }).parse(args);
273
+ const result = memoryEngine.updateMemory(effectiveUserId(params.userId, options?.defaultUserId), params.recordId, {
274
+ confidence: params.confidence,
275
+ status: params.status,
276
+ verificationStatus: params.verificationStatus,
277
+ note: params.note,
278
+ });
279
+ return toolResult(result);
280
+ }
281
+ default:
282
+ throw new Error(`Unknown engineering memory tool: ${name}`);
283
+ }
284
+ }
@@ -0,0 +1,34 @@
1
+ export declare const memoryExplainToolSchema: {
2
+ readonly name: "memory_explain_recall";
3
+ readonly description: string;
4
+ readonly inputSchema: {
5
+ readonly type: "object";
6
+ readonly properties: {
7
+ readonly query: {
8
+ readonly type: "string";
9
+ readonly description: "The query to explain recall for.";
10
+ };
11
+ readonly userId: {
12
+ readonly type: "string";
13
+ readonly description: "User ID to run explain against. Defaults to the authenticated user.";
14
+ };
15
+ readonly sessionKey: {
16
+ readonly type: "string";
17
+ readonly description: "Session key for the recall context.";
18
+ };
19
+ readonly activeSkill: {
20
+ readonly type: "string";
21
+ readonly description: "Active skill to simulate skill-boost scoring.";
22
+ };
23
+ };
24
+ readonly required: readonly ["query"];
25
+ };
26
+ };
27
+ export declare function handleMemoryExplainRecall(args: unknown, context: {
28
+ defaultUserId: string;
29
+ }): Promise<{
30
+ content: [{
31
+ type: "text";
32
+ text: string;
33
+ }];
34
+ }>;
@@ -0,0 +1,109 @@
1
+ import { z } from "zod";
2
+ import { memoryEngine } from "../memory/engine.js";
3
+ // ── Schema ────────────────────────────────────────────────────────────────────
4
+ export const memoryExplainToolSchema = {
5
+ name: "memory_explain_recall",
6
+ description: "Re-run a recall query in explain mode. Returns the full pipeline breakdown: FTS hits, vector hits, " +
7
+ "RRF scores, intent detected, type boosts, skill boost, reranker status, graph expansion, and per-record scores. " +
8
+ "Use this to debug why specific memories did or didn't surface for a query.",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ query: {
13
+ type: "string",
14
+ description: "The query to explain recall for.",
15
+ },
16
+ userId: {
17
+ type: "string",
18
+ description: "User ID to run explain against. Defaults to the authenticated user.",
19
+ },
20
+ sessionKey: {
21
+ type: "string",
22
+ description: "Session key for the recall context.",
23
+ },
24
+ activeSkill: {
25
+ type: "string",
26
+ description: "Active skill to simulate skill-boost scoring.",
27
+ },
28
+ },
29
+ required: ["query"],
30
+ },
31
+ };
32
+ const memoryExplainInputSchema = z.object({
33
+ query: z.string().min(1, "Query must not be empty"),
34
+ userId: z.string().optional(),
35
+ sessionKey: z.string().optional(),
36
+ activeSkill: z.string().optional(),
37
+ });
38
+ // ── Handler ───────────────────────────────────────────────────────────────────
39
+ export async function handleMemoryExplainRecall(args, context) {
40
+ const input = memoryExplainInputSchema.parse(args);
41
+ const userId = input.userId ?? context.defaultUserId;
42
+ const sessionKey = input.sessionKey ?? `explain_${Date.now()}`;
43
+ const result = await memoryEngine.explainRecall({
44
+ userId,
45
+ sessionKey,
46
+ query: input.query,
47
+ activeSkill: input.activeSkill,
48
+ });
49
+ const explanation = result.recallExplanation;
50
+ const lines = [
51
+ `## Recall Explain: "${input.query}"`,
52
+ "",
53
+ `**Strategy**: ${result.recallStrategy}`,
54
+ `**Duration**: ${explanation?.durationMs ?? 0}ms`,
55
+ `**Intent Detected**: ${explanation?.intentDetected ?? "none"}`,
56
+ "",
57
+ "### Search Hits",
58
+ `- FTS5 hits: ${explanation?.ftsHits ?? 0}`,
59
+ `- Vector hits: ${explanation?.vecHits ?? 0}`,
60
+ `- File-path expansion hits: ${explanation?.filePathHits ?? 0}`,
61
+ `- Top RRF score: ${explanation?.rrfTopScore?.toFixed(4) ?? "n/a"}`,
62
+ "",
63
+ "### Boosting",
64
+ `- Reranker used: ${explanation?.rerankerUsed ? "yes" : "no"} (candidates: ${explanation?.rerankerCandidates ?? 0})`,
65
+ `- Skill boost applied: ${explanation?.skillBoostApplied ? "yes" : "no"}`,
66
+ `- Graph expansion: ${explanation?.graphExpansion ? "yes" : "no"}`,
67
+ ];
68
+ if (explanation?.typeBoosts && Object.keys(explanation.typeBoosts).length > 0) {
69
+ lines.push("", "### Intent Type Boosts");
70
+ for (const [type, boost] of Object.entries(explanation.typeBoosts)) {
71
+ lines.push(`- ${type}: ${boost.toFixed(2)}×`);
72
+ }
73
+ }
74
+ if (explanation?.citationBoosts && Object.keys(explanation.citationBoosts).length > 0) {
75
+ lines.push("", "### Citation Boosts (recordId → boost)");
76
+ for (const [id, boost] of Object.entries(explanation.citationBoosts)) {
77
+ lines.push(`- ${id}: +${(boost * 100).toFixed(0)}%`);
78
+ }
79
+ }
80
+ const previewByRecordId = new Map();
81
+ for (const m of (result.recalledCognitiveMemories ?? [])) {
82
+ if (m?.recordId)
83
+ previewByRecordId.set(m.recordId, { type: m.type, content: m.content });
84
+ }
85
+ const shortenId = (id) => {
86
+ const tail = id.split(/[:_]/).pop() ?? id;
87
+ return tail.length > 12 ? tail.slice(0, 8) : tail;
88
+ };
89
+ const oneLine = (s, max = 100) => {
90
+ const flat = s.replace(/\s+/g, " ").trim();
91
+ return flat.length > max ? flat.slice(0, max - 1) + "…" : flat;
92
+ };
93
+ if (explanation?.scoredRecords && explanation.scoredRecords.length > 0) {
94
+ lines.push("", "### Ranked Results");
95
+ explanation.scoredRecords.forEach((r, i) => {
96
+ const preview = previewByRecordId.get(r.recordId);
97
+ const snippet = preview?.content ? oneLine(preview.content) : "";
98
+ lines.push(`${i + 1}. **[${r.type}]** ${r.finalScore.toFixed(4)} · \`${shortenId(r.recordId)}\``);
99
+ if (snippet)
100
+ lines.push(` ${snippet}`);
101
+ });
102
+ }
103
+ else {
104
+ lines.push("", "_(No memories matched this query)_");
105
+ }
106
+ return {
107
+ content: [{ type: "text", text: lines.join("\n") }],
108
+ };
109
+ }