memory-journal-mcp 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/README.md +165 -124
  2. package/dist/audit/interceptor.d.ts.map +1 -1
  3. package/dist/auth/authorization-server-discovery.d.ts.map +1 -1
  4. package/dist/auth/middleware.d.ts +11 -22
  5. package/dist/auth/middleware.d.ts.map +1 -1
  6. package/dist/auth/scope-map.d.ts.map +1 -1
  7. package/dist/auth/scopes.d.ts.map +1 -1
  8. package/dist/auth/token-validator.d.ts.map +1 -1
  9. package/dist/auth/transport-agnostic.d.ts +4 -0
  10. package/dist/auth/transport-agnostic.d.ts.map +1 -1
  11. package/dist/auth/validation.d.ts +1 -0
  12. package/dist/auth/validation.d.ts.map +1 -1
  13. package/dist/{chunk-6RCZ4IYV.js → chunk-4FZCHFB5.js} +28 -5
  14. package/dist/{chunk-AIWHVEOW.js → chunk-D2FY6XS5.js} +99 -7
  15. package/dist/chunk-FZLB6NAV.js +746 -0
  16. package/dist/{chunk-NVXCRDCO.js → chunk-LE6ZWUPK.js} +216 -138
  17. package/dist/chunk-SGJU2DHU.js +2102 -0
  18. package/dist/{chunk-2UIMA6JF.js → chunk-T7SROBBV.js} +32375 -29351
  19. package/dist/{chunk-IYZWMAA4.js → chunk-Y6MMKR2Z.js} +957 -1333
  20. package/dist/cli/commands/admin.d.ts +1 -1
  21. package/dist/cli/commands/admin.d.ts.map +1 -1
  22. package/dist/cli/commands/entry-payload.d.ts +38 -0
  23. package/dist/cli/commands/entry-payload.d.ts.map +1 -0
  24. package/dist/cli/commands/entry.d.ts +10 -0
  25. package/dist/cli/commands/entry.d.ts.map +1 -1
  26. package/dist/cli/commands/exec.d.ts.map +1 -1
  27. package/dist/cli/commands/io.d.ts +1 -0
  28. package/dist/cli/commands/io.d.ts.map +1 -1
  29. package/dist/cli/commands/visualize.d.ts.map +1 -1
  30. package/dist/cli/index.js +7 -10
  31. package/dist/cli/schemas.d.ts +14 -1
  32. package/dist/cli/schemas.d.ts.map +1 -1
  33. package/dist/cli/server-options-builder.d.ts.map +1 -1
  34. package/dist/cli.js +7 -10
  35. package/dist/codemode/api/journal-api.d.ts +5 -23
  36. package/dist/codemode/api/journal-api.d.ts.map +1 -1
  37. package/dist/codemode/api/key-normalizer.d.ts +8 -0
  38. package/dist/codemode/api/key-normalizer.d.ts.map +1 -0
  39. package/dist/codemode/api/param-normalizer.d.ts +2 -4
  40. package/dist/codemode/api/param-normalizer.d.ts.map +1 -1
  41. package/dist/codemode/api/project-registry-ops.d.ts +26 -0
  42. package/dist/codemode/api/project-registry-ops.d.ts.map +1 -0
  43. package/dist/codemode/api/sandbox-bindings.d.ts +25 -0
  44. package/dist/codemode/api/sandbox-bindings.d.ts.map +1 -0
  45. package/dist/codemode/api/types.d.ts.map +1 -1
  46. package/dist/codemode/api-constants.d.ts +3 -39
  47. package/dist/codemode/api-constants.d.ts.map +1 -1
  48. package/dist/codemode/constants/examples-and-params.d.ts +31 -0
  49. package/dist/codemode/constants/examples-and-params.d.ts.map +1 -0
  50. package/dist/codemode/constants/method-aliases.d.ts +8 -0
  51. package/dist/codemode/constants/method-aliases.d.ts.map +1 -0
  52. package/dist/codemode/normalizers/domain-tool-interceptions.d.ts +6 -0
  53. package/dist/codemode/normalizers/domain-tool-interceptions.d.ts.map +1 -0
  54. package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts +6 -0
  55. package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts.map +1 -0
  56. package/dist/codemode/normalizers/generic-interceptions.d.ts +6 -0
  57. package/dist/codemode/normalizers/generic-interceptions.d.ts.map +1 -0
  58. package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts +6 -0
  59. package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts.map +1 -0
  60. package/dist/codemode/normalizers/shared-utils.d.ts +31 -0
  61. package/dist/codemode/normalizers/shared-utils.d.ts.map +1 -0
  62. package/dist/codemode/param-normalizer.d.ts +5 -1
  63. package/dist/codemode/param-normalizer.d.ts.map +1 -1
  64. package/dist/codemode/proxy-helpers.d.ts +34 -0
  65. package/dist/codemode/proxy-helpers.d.ts.map +1 -0
  66. package/dist/codemode/proxy-namespaces.d.ts +30 -0
  67. package/dist/codemode/proxy-namespaces.d.ts.map +1 -0
  68. package/dist/codemode/security.d.ts +11 -0
  69. package/dist/codemode/security.d.ts.map +1 -1
  70. package/dist/codemode/type-generator.d.ts.map +1 -1
  71. package/dist/codemode/types.d.ts.map +1 -1
  72. package/dist/codemode/worker/mj-shim-domains.d.ts +15 -0
  73. package/dist/codemode/worker/mj-shim-domains.d.ts.map +1 -0
  74. package/dist/codemode/worker/mj-shim-proxy.d.ts +18 -0
  75. package/dist/codemode/worker/mj-shim-proxy.d.ts.map +1 -0
  76. package/dist/codemode/worker/namespace-shims.d.ts +32 -0
  77. package/dist/codemode/worker/namespace-shims.d.ts.map +1 -0
  78. package/dist/codemode/worker/node-shims.d.ts +65 -0
  79. package/dist/codemode/worker/node-shims.d.ts.map +1 -0
  80. package/dist/codemode/worker/prototype-hardening.d.ts +18 -0
  81. package/dist/codemode/worker/prototype-hardening.d.ts.map +1 -0
  82. package/dist/codemode/worker/result-compactor.d.ts +20 -0
  83. package/dist/codemode/worker/result-compactor.d.ts.map +1 -0
  84. package/dist/codemode/worker/sandbox-globals.d.ts +19 -0
  85. package/dist/codemode/worker/sandbox-globals.d.ts.map +1 -0
  86. package/dist/codemode/worker-api-proxy.d.ts +1 -6
  87. package/dist/codemode/worker-api-proxy.d.ts.map +1 -1
  88. package/dist/codemode/worker-result-proxy.d.ts.map +1 -1
  89. package/dist/codemode/worker-sandbox.d.ts.map +1 -1
  90. package/dist/constants/instructions/admin.d.ts +1 -1
  91. package/dist/constants/instructions/admin.d.ts.map +1 -1
  92. package/dist/constants/instructions/base.d.ts +2 -2
  93. package/dist/constants/instructions/base.d.ts.map +1 -1
  94. package/dist/constants/instructions/codemode.d.ts +1 -1
  95. package/dist/constants/instructions/codemode.d.ts.map +1 -1
  96. package/dist/constants/instructions/core.d.ts +1 -1
  97. package/dist/constants/instructions/core.d.ts.map +1 -1
  98. package/dist/constants/instructions/github.d.ts +1 -1
  99. package/dist/constants/instructions/github.d.ts.map +1 -1
  100. package/dist/constants/instructions/gotchas.d.ts +1 -1
  101. package/dist/constants/instructions/gotchas.d.ts.map +1 -1
  102. package/dist/constants/instructions/io.d.ts +1 -1
  103. package/dist/constants/instructions/io.d.ts.map +1 -1
  104. package/dist/constants/instructions/templates.d.ts +1 -1
  105. package/dist/constants/instructions/templates.d.ts.map +1 -1
  106. package/dist/constants/server-instructions.d.ts +2 -2
  107. package/dist/constants/server-instructions.d.ts.map +1 -1
  108. package/dist/database/core/interfaces.d.ts +6 -6
  109. package/dist/database/core/interfaces.d.ts.map +1 -1
  110. package/dist/database/sqlite-adapter/adapter-delegates.d.ts +161 -0
  111. package/dist/database/sqlite-adapter/adapter-delegates.d.ts.map +1 -0
  112. package/dist/database/sqlite-adapter/backup.d.ts.map +1 -1
  113. package/dist/database/sqlite-adapter/database-adapter.d.ts +17 -147
  114. package/dist/database/sqlite-adapter/database-adapter.d.ts.map +1 -1
  115. package/dist/database/sqlite-adapter/entries/crud-read.d.ts +16 -0
  116. package/dist/database/sqlite-adapter/entries/crud-read.d.ts.map +1 -0
  117. package/dist/database/sqlite-adapter/entries/crud-write.d.ts +62 -0
  118. package/dist/database/sqlite-adapter/entries/crud-write.d.ts.map +1 -0
  119. package/dist/database/sqlite-adapter/entries/crud.d.ts +3 -92
  120. package/dist/database/sqlite-adapter/entries/crud.d.ts.map +1 -1
  121. package/dist/database/sqlite-adapter/entries/importance.d.ts +7 -0
  122. package/dist/database/sqlite-adapter/entries/importance.d.ts.map +1 -1
  123. package/dist/database/sqlite-adapter/entries/index.d.ts +9 -4
  124. package/dist/database/sqlite-adapter/entries/index.d.ts.map +1 -1
  125. package/dist/database/sqlite-adapter/entries/revisions.d.ts +16 -0
  126. package/dist/database/sqlite-adapter/entries/revisions.d.ts.map +1 -0
  127. package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts +37 -0
  128. package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts.map +1 -0
  129. package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts +31 -0
  130. package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts.map +1 -0
  131. package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts +44 -0
  132. package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts.map +1 -0
  133. package/dist/database/sqlite-adapter/entries/search/index.d.ts +1 -1
  134. package/dist/database/sqlite-adapter/entries/search/index.d.ts.map +1 -1
  135. package/dist/database/sqlite-adapter/entries/search/query.d.ts +3 -82
  136. package/dist/database/sqlite-adapter/entries/search/query.d.ts.map +1 -1
  137. package/dist/database/sqlite-adapter/entries/statistics.d.ts.map +1 -1
  138. package/dist/database/sqlite-adapter/insights/cross-project.d.ts +42 -0
  139. package/dist/database/sqlite-adapter/insights/cross-project.d.ts.map +1 -0
  140. package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts +17 -0
  141. package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts.map +1 -0
  142. package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts +29 -0
  143. package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts.map +1 -0
  144. package/dist/database/sqlite-adapter/insights-operations.d.ts +11 -50
  145. package/dist/database/sqlite-adapter/insights-operations.d.ts.map +1 -1
  146. package/dist/database/sqlite-adapter/lifecycle-operations.d.ts.map +1 -1
  147. package/dist/database/sqlite-adapter/members.d.ts.map +1 -1
  148. package/dist/database/sqlite-adapter/native-connection.d.ts +5 -0
  149. package/dist/database/sqlite-adapter/native-connection.d.ts.map +1 -1
  150. package/dist/database/sqlite-adapter/relationships.d.ts +1 -2
  151. package/dist/database/sqlite-adapter/relationships.d.ts.map +1 -1
  152. package/dist/database/sqlite-adapter/tags.d.ts.map +1 -1
  153. package/dist/database/sqlite-adapter/vector-operations.d.ts.map +1 -1
  154. package/dist/filtering/tool-constants.d.ts +1 -1
  155. package/dist/{fts-T466O2JP.js → fts-YHUVPPYF.js} +2 -2
  156. package/dist/github/commit-references/enricher.d.ts.map +1 -1
  157. package/dist/github/github-integration/projects.d.ts.map +1 -1
  158. package/dist/handlers/prompts/adversarial-helpers.d.ts +75 -0
  159. package/dist/handlers/prompts/adversarial-helpers.d.ts.map +1 -0
  160. package/dist/handlers/prompts/adversarial.d.ts +3 -5
  161. package/dist/handlers/prompts/adversarial.d.ts.map +1 -1
  162. package/dist/handlers/prompts/cms-supervisor.d.ts +8 -0
  163. package/dist/handlers/prompts/cms-supervisor.d.ts.map +1 -0
  164. package/dist/handlers/prompts/index.d.ts.map +1 -1
  165. package/dist/handlers/prompts/optimizer.d.ts.map +1 -1
  166. package/dist/handlers/prompts/workflow.d.ts.map +1 -1
  167. package/dist/handlers/resources/core/briefing/context-section.d.ts.map +1 -1
  168. package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts +57 -0
  169. package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts.map +1 -0
  170. package/dist/handlers/resources/core/briefing/github-section.d.ts +23 -20
  171. package/dist/handlers/resources/core/briefing/github-section.d.ts.map +1 -1
  172. package/dist/handlers/resources/core/briefing/system-section.d.ts.map +1 -1
  173. package/dist/handlers/resources/core/briefing/user-message.d.ts.map +1 -1
  174. package/dist/handlers/resources/help.d.ts.map +1 -1
  175. package/dist/handlers/resources/index.d.ts.map +1 -1
  176. package/dist/handlers/resources/shared.d.ts +1 -0
  177. package/dist/handlers/resources/shared.d.ts.map +1 -1
  178. package/dist/handlers/resources/staleness.d.ts.map +1 -1
  179. package/dist/handlers/tools/admin/batch-tools.d.ts.map +1 -1
  180. package/dist/handlers/tools/admin/core-tools.d.ts.map +1 -1
  181. package/dist/handlers/tools/admin/index.d.ts.map +1 -1
  182. package/dist/handlers/tools/admin/lifecycle-tools.d.ts.map +1 -1
  183. package/dist/handlers/tools/admin/project-tools.d.ts +1 -1
  184. package/dist/handlers/tools/admin/project-tools.d.ts.map +1 -1
  185. package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts +609 -0
  186. package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts.map +1 -0
  187. package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts +136 -0
  188. package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts.map +1 -0
  189. package/dist/handlers/tools/admin/schemas.d.ts +2 -733
  190. package/dist/handlers/tools/admin/schemas.d.ts.map +1 -1
  191. package/dist/handlers/tools/admin/update_configuration.d.ts +14 -0
  192. package/dist/handlers/tools/admin/update_configuration.d.ts.map +1 -1
  193. package/dist/handlers/tools/admin/vector-tools.d.ts.map +1 -1
  194. package/dist/handlers/tools/analytics.d.ts.map +1 -1
  195. package/dist/handlers/tools/arg-interceptions.d.ts +51 -0
  196. package/dist/handlers/tools/arg-interceptions.d.ts.map +1 -0
  197. package/dist/handlers/tools/codemode/code-healer.d.ts +11 -0
  198. package/dist/handlers/tools/codemode/code-healer.d.ts.map +1 -0
  199. package/dist/handlers/tools/codemode/handler.d.ts +4 -23
  200. package/dist/handlers/tools/codemode/handler.d.ts.map +1 -1
  201. package/dist/handlers/tools/codemode/json-entry-recovery.d.ts +13 -0
  202. package/dist/handlers/tools/codemode/json-entry-recovery.d.ts.map +1 -0
  203. package/dist/handlers/tools/codemode/payload-synthesizer.d.ts +17 -0
  204. package/dist/handlers/tools/codemode/payload-synthesizer.d.ts.map +1 -0
  205. package/dist/handlers/tools/codemode/secure-dispatcher.d.ts +25 -0
  206. package/dist/handlers/tools/codemode/secure-dispatcher.d.ts.map +1 -0
  207. package/dist/handlers/tools/codemode/sql-recovery.d.ts +14 -0
  208. package/dist/handlers/tools/codemode/sql-recovery.d.ts.map +1 -0
  209. package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts +21 -0
  210. package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts.map +1 -0
  211. package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts +4 -0
  212. package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts.map +1 -0
  213. package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts +19 -0
  214. package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts.map +1 -0
  215. package/dist/handlers/tools/core/dummy-healing/index.d.ts +7 -0
  216. package/dist/handlers/tools/core/dummy-healing/index.d.ts.map +1 -0
  217. package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts +12 -0
  218. package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts.map +1 -0
  219. package/dist/handlers/tools/core/dummy-healing.d.ts +1 -29
  220. package/dist/handlers/tools/core/dummy-healing.d.ts.map +1 -1
  221. package/dist/handlers/tools/core/index.d.ts +1 -1
  222. package/dist/handlers/tools/core/index.d.ts.map +1 -1
  223. package/dist/handlers/tools/core/schemas.d.ts +33 -9
  224. package/dist/handlers/tools/core/schemas.d.ts.map +1 -1
  225. package/dist/handlers/tools/core/staleness-tools.d.ts +17 -0
  226. package/dist/handlers/tools/core/staleness-tools.d.ts.map +1 -1
  227. package/dist/handlers/tools/core/tools.d.ts.map +1 -1
  228. package/dist/handlers/tools/git.d.ts +5 -11
  229. package/dist/handlers/tools/git.d.ts.map +1 -1
  230. package/dist/handlers/tools/github/close-issue-tool.d.ts +6 -0
  231. package/dist/handlers/tools/github/close-issue-tool.d.ts.map +1 -0
  232. package/dist/handlers/tools/github/create-issue-tool.d.ts +6 -0
  233. package/dist/handlers/tools/github/create-issue-tool.d.ts.map +1 -0
  234. package/dist/handlers/tools/github/issue-tools.d.ts +3 -0
  235. package/dist/handlers/tools/github/issue-tools.d.ts.map +1 -1
  236. package/dist/handlers/tools/github/kanban-tools.d.ts.map +1 -1
  237. package/dist/handlers/tools/github/milestone-tools.d.ts.map +1 -1
  238. package/dist/handlers/tools/index.d.ts +2 -2
  239. package/dist/handlers/tools/index.d.ts.map +1 -1
  240. package/dist/handlers/tools/io/schemas.d.ts +5 -2
  241. package/dist/handlers/tools/io/schemas.d.ts.map +1 -1
  242. package/dist/handlers/tools/relationships.d.ts.map +1 -1
  243. package/dist/handlers/tools/schemas/constants-and-primitives.d.ts +53 -0
  244. package/dist/handlers/tools/schemas/constants-and-primitives.d.ts.map +1 -0
  245. package/dist/handlers/tools/schemas/hallucination-healer.d.ts +8 -0
  246. package/dist/handlers/tools/schemas/hallucination-healer.d.ts.map +1 -0
  247. package/dist/handlers/tools/schemas/output-schemas.d.ts +247 -0
  248. package/dist/handlers/tools/schemas/output-schemas.d.ts.map +1 -0
  249. package/dist/handlers/tools/schemas.d.ts +4 -306
  250. package/dist/handlers/tools/schemas.d.ts.map +1 -1
  251. package/dist/handlers/tools/search/cross-team.d.ts +14 -0
  252. package/dist/handlers/tools/search/cross-team.d.ts.map +1 -1
  253. package/dist/handlers/tools/search/helpers.d.ts.map +1 -1
  254. package/dist/handlers/tools/search/hybrid.d.ts.map +1 -1
  255. package/dist/handlers/tools/search/misc-tools.d.ts.map +1 -1
  256. package/dist/handlers/tools/search/schemas.d.ts +6 -3
  257. package/dist/handlers/tools/search/schemas.d.ts.map +1 -1
  258. package/dist/handlers/tools/search/search-entries.d.ts.map +1 -1
  259. package/dist/handlers/tools/search/semantic-search.d.ts.map +1 -1
  260. package/dist/handlers/tools/team/admin-tools/batch.d.ts.map +1 -1
  261. package/dist/handlers/tools/team/admin-tools/crud.d.ts.map +1 -1
  262. package/dist/handlers/tools/team/backup-tools.d.ts.map +1 -1
  263. package/dist/handlers/tools/team/core-tools.d.ts.map +1 -1
  264. package/dist/handlers/tools/team/helpers.d.ts.map +1 -1
  265. package/dist/handlers/tools/team/io-tools.d.ts.map +1 -1
  266. package/dist/handlers/tools/team/member-tools.d.ts.map +1 -1
  267. package/dist/handlers/tools/team/rbac.d.ts.map +1 -1
  268. package/dist/handlers/tools/team/relationship-tools.d.ts.map +1 -1
  269. package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts +618 -0
  270. package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts.map +1 -0
  271. package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts +464 -0
  272. package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts.map +1 -0
  273. package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts +525 -0
  274. package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts.map +1 -0
  275. package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts +419 -0
  276. package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts.map +1 -0
  277. package/dist/handlers/tools/team/schemas.d.ts +5 -2002
  278. package/dist/handlers/tools/team/schemas.d.ts.map +1 -1
  279. package/dist/handlers/tools/team/search-tools.d.ts.map +1 -1
  280. package/dist/handlers/tools/team/vector-tools.d.ts.map +1 -1
  281. package/dist/index.js +6 -9
  282. package/dist/markdown/exporter.d.ts.map +1 -1
  283. package/dist/markdown/importer.d.ts.map +1 -1
  284. package/dist/observability/latency-tracker.d.ts.map +1 -1
  285. package/dist/observability/metrics-server.d.ts +1 -1
  286. package/dist/observability/metrics-server.d.ts.map +1 -1
  287. package/dist/observability/token-estimator.d.ts.map +1 -1
  288. package/dist/{security-utils-HNTROJAG.js → security-utils-P4P6A2DG.js} +1 -1
  289. package/dist/server/digest-reporter.d.ts +1 -0
  290. package/dist/server/digest-reporter.d.ts.map +1 -1
  291. package/dist/server/mcp-server/core.d.ts.map +1 -1
  292. package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts +6 -0
  293. package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts.map +1 -0
  294. package/dist/server/mcp-server/tool-registration/index.d.ts +4 -0
  295. package/dist/server/mcp-server/tool-registration/index.d.ts.map +1 -0
  296. package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts +4 -0
  297. package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts.map +1 -0
  298. package/dist/server/mcp-server/tool-registration/register-tools.d.ts +18 -0
  299. package/dist/server/mcp-server/tool-registration/register-tools.d.ts.map +1 -0
  300. package/dist/server/mcp-server/tool-registration.d.ts +1 -17
  301. package/dist/server/mcp-server/tool-registration.d.ts.map +1 -1
  302. package/dist/server/registration.d.ts +2 -0
  303. package/dist/server/registration.d.ts.map +1 -1
  304. package/dist/server/scheduler.d.ts +1 -0
  305. package/dist/server/scheduler.d.ts.map +1 -1
  306. package/dist/server/subscription-manager.d.ts +2 -0
  307. package/dist/server/subscription-manager.d.ts.map +1 -1
  308. package/dist/tools-BOQV7QD3.js +6 -0
  309. package/dist/transports/http/security.d.ts.map +1 -1
  310. package/dist/transports/http/server/http-transport.d.ts +25 -0
  311. package/dist/transports/http/server/http-transport.d.ts.map +1 -0
  312. package/dist/transports/http/server/index.d.ts +3 -30
  313. package/dist/transports/http/server/index.d.ts.map +1 -1
  314. package/dist/transports/http/server/legacy-sse.d.ts.map +1 -1
  315. package/dist/transports/http/server/protocol-handlers.d.ts +9 -0
  316. package/dist/transports/http/server/protocol-handlers.d.ts.map +1 -0
  317. package/dist/types/entities.d.ts +41 -1
  318. package/dist/types/entities.d.ts.map +1 -1
  319. package/dist/types/index.d.ts +11 -4
  320. package/dist/types/index.d.ts.map +1 -1
  321. package/dist/utils/config-manager.d.ts +2 -0
  322. package/dist/utils/config-manager.d.ts.map +1 -1
  323. package/dist/utils/error-helpers.d.ts.map +1 -1
  324. package/dist/utils/issue-logger.d.ts.map +1 -1
  325. package/dist/utils/mcp-logger.d.ts +14 -2
  326. package/dist/utils/mcp-logger.d.ts.map +1 -1
  327. package/dist/utils/security-utils.d.ts.map +1 -1
  328. package/dist/utils/vector-index-helpers.d.ts +1 -1
  329. package/dist/utils/vector-index-helpers.d.ts.map +1 -1
  330. package/dist/utils/workspace-resolver.d.ts.map +1 -1
  331. package/dist/vector/vector-search-manager/manager.d.ts +2 -2
  332. package/dist/vector/vector-search-manager/manager.d.ts.map +1 -1
  333. package/dist/vector/vector-search-manager/rebuild.d.ts.map +1 -1
  334. package/dist/vendor/lib-agent-exec/interceptors/git-interceptor.d.ts.map +1 -1
  335. package/dist/vendor/lib-agent-exec/schema.d.ts +18 -18
  336. package/dist/vendor/lib-agent-exec/schema.d.ts.map +1 -1
  337. package/dist/vendor/lib-agent-exec/stream-manager.d.ts.map +1 -1
  338. package/dist/worker-script.js +2662 -2645
  339. package/package.json +3 -4
  340. package/skills/memory-journal-mcp/SKILL.md +8 -8
  341. package/dist/auth/context.d.ts +0 -7
  342. package/dist/auth/context.d.ts.map +0 -1
  343. package/dist/chunk-ELMJYRTT.js +0 -29
  344. package/dist/chunk-F6WSLZVN.js +0 -675
  345. package/dist/chunk-JVGY2GHK.js +0 -776
  346. package/dist/chunk-KWSBCSFM.js +0 -411
  347. package/dist/chunk-SP5D3XYY.js +0 -1550
  348. package/dist/chunk-XJMEPP36.js +0 -57
  349. package/dist/database/core/entry-columns.d.ts +0 -8
  350. package/dist/database/core/entry-columns.d.ts.map +0 -1
  351. package/dist/database/core/schema.d.ts +0 -69
  352. package/dist/database/core/schema.d.ts.map +0 -1
  353. package/dist/error-helpers-STR7IPUR.js +0 -2
  354. package/dist/git-runner-6OE7PVKA.js +0 -1
  355. package/dist/journal-api-UG43ZD7Y.js +0 -1289
  356. package/dist/tools-RBNFDWIE.js +0 -9
@@ -0,0 +1,2102 @@
1
+ import { resolveProjectContext } from './chunk-D2FY6XS5.js';
2
+ import { createRequire } from 'module';
3
+
4
+ var require2 = createRequire(import.meta.url);
5
+ var pkg = require2("../package.json");
6
+ var VERSION = pkg.version;
7
+
8
+ // src/codemode/constants/method-aliases.ts
9
+ function mapToTarget(keys, target) {
10
+ const out = {};
11
+ for (const k of keys) out[k] = target;
12
+ return out;
13
+ }
14
+ var SHARED_PROJECT_ALIASES = {
15
+ ...mapToTarget(
16
+ [
17
+ "getProject",
18
+ "getProjectByName",
19
+ "get_project_by_name",
20
+ "getProjectByNumber",
21
+ "get_project_by_number",
22
+ "findProject",
23
+ "find_project",
24
+ "mj_get_project",
25
+ "mjGetProject"
26
+ ],
27
+ "getProject"
28
+ ),
29
+ ...mapToTarget(
30
+ ["listProjects", "list_projects", "mj_list_projects", "mjListProjects", "projects"],
31
+ "listProjects"
32
+ )
33
+ };
34
+ var SHARED_HEALTH_ALIASES = mapToTarget(
35
+ [
36
+ "serverInfo",
37
+ "server_info",
38
+ "serverHealth",
39
+ "server_health",
40
+ "health",
41
+ "status",
42
+ "adapters",
43
+ "list_adapters",
44
+ "listAdapters",
45
+ "get_adapters",
46
+ "getAdapters"
47
+ ],
48
+ "getStatistics"
49
+ );
50
+ var SHARED_GREP_SEARCH_ALIASES = mapToTarget(
51
+ [
52
+ "grep",
53
+ "grepSearch",
54
+ "grep_search",
55
+ "fileSearch",
56
+ "file_search",
57
+ "findInFiles",
58
+ "find_in_files",
59
+ "find",
60
+ "search",
61
+ "query",
62
+ "queryEntries",
63
+ "query_entries"
64
+ ],
65
+ "searchEntries"
66
+ );
67
+ var METHOD_ALIASES = {
68
+ core: {
69
+ ...mapToTarget(
70
+ [
71
+ "create",
72
+ "add",
73
+ "newEntry",
74
+ "addEntry",
75
+ "insert",
76
+ "write",
77
+ "log",
78
+ "record",
79
+ "note",
80
+ "save",
81
+ "execute",
82
+ "executeCode",
83
+ "execute_code",
84
+ "quick",
85
+ "createEntryMinimal",
86
+ "appendInsight",
87
+ "writeQuery",
88
+ "updateMemory",
89
+ "update_memory",
90
+ "createMemory",
91
+ "create_memory",
92
+ "addMemory",
93
+ "add_memory",
94
+ "saveMemory",
95
+ "save_memory",
96
+ "recordMemory",
97
+ "record_memory",
98
+ "setMemory",
99
+ "set_memory",
100
+ "updateJournal",
101
+ "update_journal",
102
+ "sessionSummary",
103
+ "append",
104
+ "appendEntry",
105
+ "append_entry",
106
+ "logJournal",
107
+ "log_journal",
108
+ "logEntry",
109
+ "log_entry",
110
+ "insertJournal",
111
+ "insert_journal",
112
+ "addJournal",
113
+ "add_journal",
114
+ "saveJournalEntry",
115
+ "save_journal_entry",
116
+ "createJournalEntry",
117
+ "create_journal_entry",
118
+ "create_entry",
119
+ "mj_create_entry",
120
+ "mjCreateEntry",
121
+ "add_entry",
122
+ "mj_add_entry",
123
+ "mjAddEntry"
124
+ ],
125
+ "createEntry"
126
+ ),
127
+ ...mapToTarget(
128
+ ["get", "getEntry", "fetch", "read", "get_entry_by_id", "viewFile", "view_file", "readFile", "read_file"],
129
+ "getEntryById"
130
+ ),
131
+ ...mapToTarget(
132
+ [
133
+ "recent",
134
+ "getRecent",
135
+ "list",
136
+ "entries",
137
+ "all",
138
+ "latest",
139
+ "get_recent_entries",
140
+ "select",
141
+ "sql",
142
+ "executeSql",
143
+ "execSql",
144
+ "execute_sql",
145
+ "exec_sql",
146
+ "fetchEntries",
147
+ "getAll",
148
+ "listDir",
149
+ "list_dir"
150
+ ],
151
+ "getRecentEntries"
152
+ ),
153
+ ...mapToTarget(["tags", "getTags", "get_tags", "list_tags"], "listTags"),
154
+ ...mapToTarget(
155
+ ["read_resource", "readResource", "memory_read_resource", "memoryReadResource", "get_resource", "getResource"],
156
+ "readResource"
157
+ ),
158
+ ...mapToTarget(["history", "revisions", "get_entry_history"], "getEntryHistory"),
159
+ ...mapToTarget(["schema", "getSchema", "get_schema", "database", "getDatabase", "get_database", "getDb", "get_db"], "getStatistics"),
160
+ ...SHARED_PROJECT_ALIASES,
161
+ ...SHARED_HEALTH_ALIASES,
162
+ ...SHARED_GREP_SEARCH_ALIASES,
163
+ listEntries: "searchEntries",
164
+ create_entry_minimal: "createEntryMinimal",
165
+ search_audit_log: "searchAuditLog",
166
+ update: "updateEntry",
167
+ delete: "deleteEntry",
168
+ updateEntry: "updateEntry",
169
+ deleteEntry: "deleteEntry",
170
+ update_entry: "updateEntry",
171
+ delete_entry: "deleteEntry"
172
+ },
173
+ search: {
174
+ ...SHARED_GREP_SEARCH_ALIASES,
175
+ ...mapToTarget(
176
+ [
177
+ "lookup",
178
+ "findEntries",
179
+ "find_entries",
180
+ "listEntries",
181
+ "list_entries",
182
+ "entries",
183
+ "readQuery",
184
+ "read_query",
185
+ "select",
186
+ "sql",
187
+ "executeSql",
188
+ "execSql",
189
+ "sqlQuery",
190
+ "querySql",
191
+ "execute_sql",
192
+ "exec_sql",
193
+ "search_entries"
194
+ ],
195
+ "searchEntries"
196
+ ),
197
+ byDate: "searchByDateRange",
198
+ similar: "semanticSearch",
199
+ stats: "getVectorIndexStats",
200
+ deleted: "listDeletedEntries",
201
+ trash: "listDeletedEntries",
202
+ crossSearch: "crossTeamSearch",
203
+ search_by_date_range: "searchByDateRange",
204
+ semantic_search: "semanticSearch",
205
+ get_vector_index_stats: "getVectorIndexStats",
206
+ list_deleted_entries: "listDeletedEntries",
207
+ cross_team_search: "crossTeamSearch"
208
+ },
209
+ analytics: {
210
+ ...mapToTarget(
211
+ [
212
+ "stats",
213
+ "getStats",
214
+ "statistics",
215
+ "schema",
216
+ "getSchema",
217
+ "get_schema",
218
+ "tables",
219
+ "getTables",
220
+ "get_tables",
221
+ "describe",
222
+ "databaseInfo",
223
+ "getDatabaseInfo",
224
+ "get_database_info",
225
+ "database",
226
+ "getDatabase",
227
+ "get_database",
228
+ "getDb",
229
+ "get_db",
230
+ "db",
231
+ "dbStats",
232
+ "getDbStats",
233
+ "get_db_stats",
234
+ "dbInfo",
235
+ "getDbInfo",
236
+ "get_db_info",
237
+ "get_statistics"
238
+ ],
239
+ "getStatistics"
240
+ ),
241
+ ...SHARED_HEALTH_ALIASES,
242
+ ...mapToTarget(
243
+ ["insights", "getInsights", "getProjects", "listProjects", "list_projects", "projects", "get_cross_project_insights"],
244
+ "getCrossProjectInsights"
245
+ )
246
+ },
247
+ relationships: {
248
+ link: "linkEntries",
249
+ graph: "visualizeRelationships",
250
+ link_entries: "linkEntries",
251
+ visualize_relationships: "visualizeRelationships"
252
+ },
253
+ io: {
254
+ dump: "exportEntries",
255
+ md: "exportMarkdown",
256
+ importMd: "importMarkdown",
257
+ importNotion: "importExternal",
258
+ importObsidian: "importExternal",
259
+ export_entries: "exportEntries",
260
+ export_markdown: "exportMarkdown",
261
+ import_markdown: "importMarkdown",
262
+ import_external: "importExternal"
263
+ },
264
+ admin: {
265
+ ...mapToTarget(
266
+ [
267
+ "edit",
268
+ "update",
269
+ "editEntry",
270
+ "modifyEntry",
271
+ "modify",
272
+ "updateMemory",
273
+ "update_memory",
274
+ "setMemory",
275
+ "set_memory",
276
+ "updateJournal",
277
+ "update_journal",
278
+ "saveMemory",
279
+ "save_memory",
280
+ "update_entry"
281
+ ],
282
+ "updateEntry"
283
+ ),
284
+ ...mapToTarget(["remove", "delete", "removeEntry", "delete_entry"], "deleteEntry"),
285
+ ...mapToTarget(["restore", "restoreEntry", "restore_entry"], "restoreEntry"),
286
+ ...mapToTarget(
287
+ ["batchCreate", "bulkCreate", "createEntries", "batchCreateEntry", "batch_create_entries"],
288
+ "batchCreateEntries"
289
+ ),
290
+ ...mapToTarget(["batchUpdate", "bulkUpdate", "updateEntries", "batch_update_entries"], "batchUpdateEntries"),
291
+ ...mapToTarget(["batchDelete", "bulkDelete", "deleteEntries", "batch_delete_entries"], "batchDeleteEntries"),
292
+ ...mapToTarget(["config", "configure", "update_configuration"], "updateConfiguration"),
293
+ ...mapToTarget(["auditLog", "audit", "search_audit_log"], "searchAuditLog"),
294
+ ...SHARED_PROJECT_ALIASES,
295
+ ...SHARED_HEALTH_ALIASES,
296
+ rebuild: "rebuildVectorIndex",
297
+ rebuild_vector_index: "rebuildVectorIndex",
298
+ addVector: "addToVectorIndex",
299
+ add_to_vector_index: "addToVectorIndex",
300
+ mergeTags: "mergeTags",
301
+ merge_tags: "mergeTags",
302
+ registerProject: "registerProject",
303
+ register_project: "registerProject",
304
+ updateProject: "updateProject",
305
+ update_project: "updateProject",
306
+ deleteProject: "deleteProject",
307
+ removeProject: "deleteProject",
308
+ delete_project: "deleteProject"
309
+ },
310
+ github: {
311
+ issues: "getGithubIssues",
312
+ issue: "getGithubIssue",
313
+ prs: "getGithubPrs",
314
+ pr: "getGithubPr",
315
+ context: "getGithubContext",
316
+ kanban: "getKanbanBoard",
317
+ moveKanban: "moveKanbanItem",
318
+ addKanban: "addKanbanItem",
319
+ deleteKanban: "deleteKanbanItem",
320
+ milestones: "getGithubMilestones",
321
+ milestone: "getGithubMilestone",
322
+ createMilestone: "createGithubMilestone",
323
+ updateMilestone: "updateGithubMilestone",
324
+ deleteMilestone: "deleteGithubMilestone",
325
+ repoInsights: "getRepoInsights",
326
+ createIssue: "createGithubIssueWithEntry",
327
+ closeIssue: "closeGithubIssueWithEntry",
328
+ copilotReviews: "getCopilotReviews",
329
+ get_github_issues: "getGithubIssues",
330
+ get_github_issue: "getGithubIssue",
331
+ get_github_prs: "getGithubPrs",
332
+ get_github_pr: "getGithubPr",
333
+ get_github_context: "getGithubContext",
334
+ get_kanban_board: "getKanbanBoard",
335
+ move_kanban_item: "moveKanbanItem",
336
+ add_kanban_item: "addKanbanItem",
337
+ delete_kanban_item: "deleteKanbanItem",
338
+ get_github_milestones: "getGithubMilestones",
339
+ get_github_milestone: "getGithubMilestone",
340
+ create_github_milestone: "createGithubMilestone",
341
+ update_github_milestone: "updateGithubMilestone",
342
+ delete_github_milestone: "deleteGithubMilestone",
343
+ get_repo_insights: "getRepoInsights",
344
+ create_github_issue_with_entry: "createGithubIssueWithEntry",
345
+ close_github_issue_with_entry: "closeGithubIssueWithEntry",
346
+ get_copilot_reviews: "getCopilotReviews"
347
+ },
348
+ backup: {
349
+ save: "backupJournal",
350
+ create: "backupJournal",
351
+ backup: "backupJournal",
352
+ list: "listBackups",
353
+ restore: "restoreBackup",
354
+ cleanup: "cleanupBackups",
355
+ backup_journal: "backupJournal",
356
+ list_backups: "listBackups",
357
+ restore_backup: "restoreBackup",
358
+ cleanup_backups: "cleanupBackups"
359
+ },
360
+ team: {
361
+ ...mapToTarget(
362
+ ["create", "createEntry", "create_entry", "addEntry", "sessionSummary", "teamSessionSummary"],
363
+ "teamCreateEntry"
364
+ ),
365
+ ...mapToTarget(
366
+ ["recent", "listEntries", "teamListEntries", "list", "entries", "teamList"],
367
+ "teamGetRecent"
368
+ ),
369
+ ...mapToTarget(
370
+ ["batchCreate", "batchCreateEntries", "bulkCreate", "createEntries", "batchCreateEntry"],
371
+ "teamBatchCreateEntries"
372
+ ),
373
+ ...mapToTarget(["batchUpdate", "batchUpdateEntries", "bulkUpdate", "updateEntries"], "teamBatchUpdateEntries"),
374
+ ...mapToTarget(["batchDelete", "batchDeleteEntries", "bulkDelete", "deleteEntries"], "teamBatchDeleteEntries"),
375
+ ...mapToTarget(
376
+ ["insights", "searchProjects", "listProjects", "getProjects"],
377
+ "teamGetCrossProjectInsights"
378
+ ),
379
+ ...mapToTarget(["updateRole", "changeRole", "setRole"], "teamUpdateMemberRole"),
380
+ find: "teamSearch",
381
+ search: "teamSearch",
382
+ get: "teamGetEntryById",
383
+ read: "teamGetEntryById",
384
+ tags: "teamListTags",
385
+ byDate: "teamSearchByDateRange",
386
+ update: "teamUpdateEntry",
387
+ edit: "teamUpdateEntry",
388
+ delete: "teamDeleteEntry",
389
+ restore: "teamRestoreEntry",
390
+ teamRestore: "teamRestoreEntry",
391
+ mergeTags: "teamMergeTags",
392
+ stats: "teamGetStatistics",
393
+ link: "teamLinkEntries",
394
+ linkEntries: "teamLinkEntries",
395
+ graph: "teamVisualizeRelationships",
396
+ visualizeRelationships: "teamVisualizeRelationships",
397
+ export: "teamExportEntries",
398
+ exportEntries: "teamExportEntries",
399
+ exportMarkdown: "teamExportMarkdown",
400
+ md: "teamExportMarkdown",
401
+ importMarkdown: "teamImportMarkdown",
402
+ importMd: "teamImportMarkdown",
403
+ importNotion: "teamImportExternal",
404
+ importObsidian: "teamImportExternal",
405
+ importExternal: "teamImportExternal",
406
+ trash: "teamListDeletedEntries",
407
+ deleted: "teamListDeletedEntries",
408
+ backup: "teamBackup",
409
+ listBackups: "teamListBackups",
410
+ semanticSearch: "teamSemanticSearch",
411
+ vectorStats: "teamGetVectorIndexStats",
412
+ rebuildIndex: "teamRebuildVectorIndex",
413
+ addToIndex: "teamAddToVectorIndex",
414
+ collaborationMatrix: "teamGetCollaborationMatrix",
415
+ addMember: "teamAddMember",
416
+ removeMember: "teamRemoveMember",
417
+ members: "teamListMembers",
418
+ listMembers: "teamListMembers",
419
+ getMember: "teamGetMember",
420
+ addAlias: "teamAddAuthorAlias",
421
+ removeAlias: "teamRemoveAuthorAlias",
422
+ aliases: "teamListAuthorAliases",
423
+ listAliases: "teamListAuthorAliases",
424
+ resolveAuthor: "teamResolveAuthor",
425
+ consolidate: "teamConsolidateAuthors",
426
+ consolidateAuthors: "teamConsolidateAuthors"
427
+ },
428
+ git: {
429
+ history: "getCommitHistory",
430
+ log: "getCommitHistory",
431
+ commits: "getCommitHistory",
432
+ search: "searchCommits",
433
+ find: "searchCommits",
434
+ release: "getReleaseInfo",
435
+ unreleased: "getUnreleasedCommits",
436
+ analyze: "analyzeCommitPatterns",
437
+ get_commit_history: "getCommitHistory",
438
+ search_commits: "searchCommits",
439
+ get_release_info: "getReleaseInfo",
440
+ get_unreleased_commits: "getUnreleasedCommits",
441
+ analyze_commit_patterns: "analyzeCommitPatterns"
442
+ }
443
+ };
444
+
445
+ // src/codemode/constants/examples-and-params.ts
446
+ var GROUP_EXAMPLES = {
447
+ core: [
448
+ 'mj.core.createEntry({ content: "Implemented Code Mode" })',
449
+ "mj.core.getEntryById({ entry_id: 1 })",
450
+ "mj.core.getRecentEntries({ limit: 10 })",
451
+ 'mj.core.createEntryMinimal({ content: "Quick note" })',
452
+ "mj.core.listTags()"
453
+ ],
454
+ search: [
455
+ 'mj.search.searchEntries({ query: "performance" })',
456
+ 'mj.search.searchEntries({ query: "performance", mode: "hybrid" })',
457
+ 'mj.search.searchByDateRange({ start_date: "2026-03-01", end_date: "2026-03-11" })',
458
+ 'mj.search.semanticSearch({ query: "authentication patterns" })',
459
+ "mj.search.semanticSearch({ entry_id: 42 })"
460
+ ],
461
+ analytics: [
462
+ "mj.analytics.getStatistics()",
463
+ "mj.analytics.getCrossProjectInsights()",
464
+ "mj.analytics.getProjects()"
465
+ ],
466
+ relationships: [
467
+ 'mj.relationships.linkEntries({ from_entry_id: 1, to_entry_id: 2, relationship_type: "implements" })',
468
+ "mj.relationships.visualizeRelationships({ entry_id: 1 })"
469
+ ],
470
+ io: [
471
+ 'mj.io.exportEntries({ format: "json" })',
472
+ 'mj.io.exportMarkdown({ output_dir: "./export" })',
473
+ 'mj.io.importMarkdown({ source_dir: "./import" })',
474
+ 'mj.io.importExternal({ source_dir: "./import", source_format: "notion" })'
475
+ ],
476
+ admin: [
477
+ 'mj.admin.updateEntry({ entry_id: 1, content: "Updated content" })',
478
+ "mj.admin.deleteEntry({ entry_id: 1 })",
479
+ "mj.admin.restoreEntry({ entry_id: 1 })",
480
+ 'mj.admin.mergeTags({ source_tag: "old", target_tag: "new" })',
481
+ 'mj.admin.batchCreateEntries({ entries: [{ content: "First" }, { content: "Second" }] })',
482
+ "mj.admin.rebuildVectorIndex()",
483
+ "mj.admin.addToVectorIndex({ entry_id: 1 })"
484
+ ],
485
+ github: [
486
+ 'mj.github.getGithubIssues({ state: "open" })',
487
+ 'mj.github.getGithubPrs({ state: "open" })',
488
+ "mj.github.getKanbanBoard({ project_number: 1 })",
489
+ "mj.github.addKanbanItem({ project_number: 1, issue_number: 123 })",
490
+ "mj.github.getGithubMilestones()",
491
+ "mj.github.getRepoInsights()"
492
+ ],
493
+ backup: [
494
+ "mj.backup.backupJournal()",
495
+ "mj.backup.listBackups()",
496
+ 'mj.backup.restoreBackup({ filename: "backup-2026-03-11.db" })'
497
+ ],
498
+ team: [
499
+ 'mj.team.teamCreateEntry({ content: "Team update" })',
500
+ "mj.team.teamGetRecent({ limit: 5 })",
501
+ 'mj.team.teamSearch({ query: "release" })',
502
+ "mj.team.teamGetEntryById({ entry_id: 1 })",
503
+ "mj.team.teamListTags()",
504
+ 'mj.team.teamUpdateEntry({ entry_id: 1, content: "Updated" })',
505
+ "mj.team.teamRestoreEntry({ entry_id: 1 })",
506
+ 'mj.team.teamBatchCreateEntries({ entries: [{ content: "Team A" }] })',
507
+ "mj.team.teamGetStatistics()",
508
+ 'mj.team.teamExportEntries({ format: "json" })',
509
+ "mj.team.teamBackup()",
510
+ 'mj.team.teamSemanticSearch({ query: "deployment" })',
511
+ "mj.team.teamGetCrossProjectInsights()"
512
+ ],
513
+ git: [
514
+ "mj.git.getCommitHistory({ maxCount: 10 })",
515
+ 'mj.git.searchCommits({ query: "fix" })',
516
+ "mj.git.getReleaseInfo()",
517
+ "mj.git.getUnreleasedCommits()",
518
+ "mj.git.analyzeCommitPatterns({ maxCount: 20 })"
519
+ ]
520
+ };
521
+ var POSITIONAL_PARAM_MAP = {
522
+ // Core
523
+ createEntry: "content",
524
+ getEntryById: "entry_id",
525
+ getRecentEntries: "limit",
526
+ createEntryMinimal: "content",
527
+ testSimple: "message",
528
+ writeQuery: "content",
529
+ getEntryHistory: "entry_id",
530
+ // Search
531
+ searchEntries: "query",
532
+ searchByDateRange: ["start_date", "end_date"],
533
+ semanticSearch: "query",
534
+ crossTeamSearch: "query",
535
+ listDeletedEntries: "limit",
536
+ // Relationships
537
+ linkEntries: ["from_entry_id", "to_entry_id", "relationship_type"],
538
+ link_entries: ["from_entry_id", "to_entry_id", "relationship_type"],
539
+ visualizeRelationships: "entry_id",
540
+ visualize_relationships: "entry_id",
541
+ // Export
542
+ exportEntries: "format",
543
+ exportMarkdown: "output_dir",
544
+ importMarkdown: "source_dir",
545
+ importExternal: "source_dir",
546
+ // Admin
547
+ updateEntry: "entry_id",
548
+ deleteEntry: "entry_id",
549
+ restoreEntry: "entry_id",
550
+ addToVectorIndex: "entry_id",
551
+ mergeTags: ["source_tag", "target_tag"],
552
+ batchCreateEntries: "entries",
553
+ batchUpdateEntries: "updates",
554
+ batchDeleteEntries: "entry_ids",
555
+ searchAuditLog: "tool_name",
556
+ updateConfiguration: "tool_filter",
557
+ registerProject: ["name", "absolute_path", "project_number"],
558
+ updateProject: ["name", "new_name", "absolute_path", "project_number"],
559
+ deleteProject: "name",
560
+ getProject: "name",
561
+ getProjectByName: "name",
562
+ get_project_by_name: "name",
563
+ getProjectByNumber: "name",
564
+ get_project_by_number: "name",
565
+ findProject: "name",
566
+ find_project: "name",
567
+ // GitHub
568
+ getGithubIssue: "issue_number",
569
+ getGithubPr: "pr_number",
570
+ getKanbanBoard: "project_number",
571
+ moveKanbanItem: ["item_id", "target_status"],
572
+ addKanbanItem: "issue_number",
573
+ deleteKanbanItem: "item_id",
574
+ getGithubMilestone: "milestone_number",
575
+ createGithubMilestone: "title",
576
+ updateGithubMilestone: "milestone_number",
577
+ deleteGithubMilestone: "milestone_number",
578
+ createGithubIssueWithEntry: "title",
579
+ closeGithubIssueWithEntry: "issue_number",
580
+ getCopilotReviews: "pr_number",
581
+ // Backup
582
+ backupJournal: "name",
583
+ restoreBackup: ["filename", "confirm"],
584
+ cleanupBackups: "keep_count",
585
+ // Team
586
+ teamCreateEntry: "content",
587
+ teamGetRecent: "limit",
588
+ teamSearch: "query",
589
+ teamGetEntryById: "entry_id",
590
+ teamSearchByDateRange: ["start_date", "end_date"],
591
+ teamUpdateEntry: "entry_id",
592
+ teamDeleteEntry: "entry_id",
593
+ teamRestoreEntry: "entry_id",
594
+ teamMergeTags: ["source_tag", "target_tag"],
595
+ teamBatchCreateEntries: "entries",
596
+ teamBatchUpdateEntries: "updates",
597
+ teamBatchDeleteEntries: "entry_ids",
598
+ teamLinkEntries: ["from_entry_id", "to_entry_id", "relationship_type"],
599
+ teamVisualizeRelationships: "entry_id",
600
+ teamExportEntries: "format",
601
+ teamExportMarkdown: "output_dir",
602
+ teamImportMarkdown: "source_dir",
603
+ teamImportExternal: "source_dir",
604
+ teamSemanticSearch: "query",
605
+ teamAddToVectorIndex: "entry_id",
606
+ teamAddAuthorAlias: ["alias", "canonical_author"],
607
+ teamRemoveAuthorAlias: "alias",
608
+ teamListAuthorAliases: "canonical_author",
609
+ teamResolveAuthor: "author",
610
+ teamConsolidateAuthors: "canonical_author",
611
+ // Team Members
612
+ teamAddMember: ["author", "role"],
613
+ teamRemoveMember: "author",
614
+ teamUpdateMemberRole: ["author", "role"],
615
+ teamGetMember: "author",
616
+ // Git
617
+ getCommitHistory: "maxCount",
618
+ searchCommits: "query",
619
+ getReleaseInfo: "ref",
620
+ analyzeCommitPatterns: "maxCount"
621
+ };
622
+ var GROUP_PREFIX_MAP = {
623
+ core: "",
624
+ search: "",
625
+ analytics: "",
626
+ relationships: "",
627
+ io: "",
628
+ admin: "",
629
+ github: "",
630
+ backup: "",
631
+ team: "",
632
+ git: "",
633
+ codemode: "mj_"
634
+ };
635
+ var KEEP_PREFIX_GROUPS = /* @__PURE__ */ new Set(["github", "team"]);
636
+
637
+ // src/codemode/api/git-api.ts
638
+ function applyGitInterceptions(methodName, args) {
639
+ const gitMethods = [
640
+ "get_commit_history",
641
+ "getCommitHistory",
642
+ "search_commits",
643
+ "searchCommits",
644
+ "get_release_info",
645
+ "getReleaseInfo",
646
+ "get_unreleased_commits",
647
+ "getUnreleasedCommits",
648
+ "analyze_commit_patterns",
649
+ "analyzeCommitPatterns"
650
+ ];
651
+ if (gitMethods.includes(methodName) && args.length === 1 && typeof args[0] === "object" && args[0] !== null) {
652
+ const obj = args[0];
653
+ for (const key of ["text", "message", "description", "q", "search"]) {
654
+ if (obj[key] !== void 0 && obj["query"] === void 0 && (methodName.includes("search_commits") || methodName.includes("searchCommits"))) {
655
+ obj["query"] = obj[key];
656
+ Reflect.deleteProperty(obj, key);
657
+ }
658
+ }
659
+ if (obj["keep"] !== void 0 && obj["maxCount"] === void 0 && obj["max_count"] === void 0) {
660
+ obj["maxCount"] = obj["keep"];
661
+ delete obj["keep"];
662
+ }
663
+ if (obj["limit"] !== void 0 && obj["maxCount"] === void 0 && obj["max_count"] === void 0) {
664
+ obj["maxCount"] = obj["limit"];
665
+ delete obj["limit"];
666
+ }
667
+ if (!methodName.includes("search") && (obj["q"] !== void 0 || obj["query"] !== void 0 || obj["search"] !== void 0)) {
668
+ return { error: {
669
+ success: false,
670
+ error: `${methodName} does not support search queries (q/query/search). It only retrieves history or analysis.`,
671
+ code: "VALIDATION_ERROR",
672
+ category: "validation",
673
+ suggestion: "Remove the query parameter, or use search_commits for text search.",
674
+ recoverable: true
675
+ } };
676
+ }
677
+ return { args: [obj] };
678
+ }
679
+ return null;
680
+ }
681
+
682
+ // src/codemode/normalizers/shared-utils.ts
683
+ function isRecord(val) {
684
+ return typeof val === "object" && val !== null && !Array.isArray(val);
685
+ }
686
+ function safeString(val) {
687
+ if (typeof val === "string") return val;
688
+ if (typeof val === "number" || typeof val === "boolean") return String(val);
689
+ if (typeof val === "object" && val !== null) {
690
+ try {
691
+ return JSON.stringify(val, null, 2);
692
+ } catch {
693
+ return "";
694
+ }
695
+ }
696
+ return "";
697
+ }
698
+ var PARAM_ALIASES = {
699
+ text: "content",
700
+ body: "content",
701
+ note: "content",
702
+ title: "content",
703
+ entry: "entry_id",
704
+ q: "query",
705
+ issue: "issue_number",
706
+ pr: "pr_number",
707
+ pr_id: "pr_number",
708
+ project: "project_number",
709
+ project_id: "project_number",
710
+ project_name: "project_number",
711
+ projectName: "project_number",
712
+ proj: "project_number",
713
+ milestone_id: "milestone_number",
714
+ issue_id: "issue_number",
715
+ pull_request_id: "pr_number",
716
+ pull_number: "pr_number",
717
+ user: "target_user",
718
+ assignee: "target_user",
719
+ repo_name: "repo",
720
+ version: "expected_version",
721
+ search: "query",
722
+ term: "query",
723
+ keyword: "query",
724
+ source: "source_tag",
725
+ target: "target_tag",
726
+ from: "from_entry_id",
727
+ to: "to_entry_id",
728
+ kind: "entry_type",
729
+ format_type: "format",
730
+ webhook: "report_webhook_url",
731
+ comment: "resolution",
732
+ resolution_comment: "resolution",
733
+ severity: "flag_type",
734
+ sort: "sort_by",
735
+ order_by: "sort_by",
736
+ order: "sort_by",
737
+ keep: "keep_count",
738
+ path: "source_dir",
739
+ impactScore: "impact_score",
740
+ trustScore: "trust_score",
741
+ validationStatus: "validation_status",
742
+ team_id: "workspace_id",
743
+ team: "workspace_id"
744
+ };
745
+ var ENTRY_TYPE_ALIASES = {
746
+ "session-summary": "retrospective",
747
+ "session_summary": "retrospective",
748
+ "team-session-summary": "retrospective",
749
+ "team_session_summary": "retrospective",
750
+ "team session summary": "retrospective",
751
+ "summary": "retrospective",
752
+ "bug": "bug_fix",
753
+ "feature": "feature_implementation",
754
+ "note": "technical_note",
755
+ "technical-note": "technical_note",
756
+ "reflection": "personal_reflection",
757
+ "decision": "project_decision",
758
+ "review": "code_review",
759
+ "code": "technical_note",
760
+ "coding": "technical_note",
761
+ "progress": "development_note",
762
+ "status": "development_note",
763
+ "update": "development_note",
764
+ "test": "system_integration_test",
765
+ "testing": "system_integration_test",
766
+ "task": "technical_note"
767
+ };
768
+ var TAG_ALIASES = {
769
+ "session_summary": "session-summary",
770
+ "team_session_summary": "session-summary",
771
+ "team-session-summary": "session-summary",
772
+ "team session summary": "session-summary",
773
+ "commit_narrative": "commit-narrative",
774
+ "bug_fix": "bug-fix",
775
+ "feature_implementation": "feature"
776
+ };
777
+ function deduplicateSectionHeader(str, headerRegexStr) {
778
+ let count = 0;
779
+ return str.replace(new RegExp(headerRegexStr, "gim"), (match) => {
780
+ count++;
781
+ return count === 1 ? match : "";
782
+ });
783
+ }
784
+ function healSessionSummaryContent(content, options) {
785
+ let healed = content;
786
+ if (options?.normalizeSynonyms !== false) {
787
+ healed = healed.replace(/^#+\s+(?:Accomplishments|Completed|Done|What I did|What we did)\s*$/gim, "## Accomplished");
788
+ healed = healed.replace(/^#+\s+(?:Blockers|Unfinished|Unfinished\/?Blocked|Blocked)\s*$/gim, "## Unfinished / Blocked");
789
+ healed = healed.replace(/^#+\s+(?:Next Session|Context|Next steps)\s*$/gim, "## Context for Next Session");
790
+ }
791
+ healed = healed.replace(/(?:^#+\s+Accomplished\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Accomplished\n- None.\n");
792
+ healed = healed.replace(/(?:^#+\s+Unfinished \/ Blocked\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Unfinished / Blocked\n- None.\n");
793
+ healed = healed.replace(/(?:^#+\s+Context for Next Session\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Context for Next Session\n- None.\n");
794
+ healed = healed.replace(/(?:^#+\s+Commits\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Commits\n- None.\n");
795
+ healed = deduplicateSectionHeader(healed, "^#+\\s+Accomplished");
796
+ healed = deduplicateSectionHeader(healed, "^#+\\s+Unfinished \\/ Blocked");
797
+ healed = deduplicateSectionHeader(healed, "^#+\\s+Context for Next Session");
798
+ healed = deduplicateSectionHeader(healed, "^#+\\s+Commits");
799
+ if (options?.usePeriodOnNone === true) {
800
+ const requiredHeaders = [
801
+ "## Accomplished",
802
+ "## Unfinished / Blocked",
803
+ "## Context for Next Session",
804
+ "## Commits"
805
+ ];
806
+ for (const header of requiredHeaders) {
807
+ const cleanHeader = header.replace(/^#+\s+/, "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/ /g, "\\s*");
808
+ const regex = new RegExp(`#+\\s+${cleanHeader}`, "i");
809
+ if (!regex.test(healed)) {
810
+ healed += `
811
+
812
+ ${header}
813
+ - None.`;
814
+ }
815
+ }
816
+ } else {
817
+ if (!/#+\s+Accomplished/i.test(healed)) healed += "\n\n## Accomplished\n- \n";
818
+ if (!/#+\s+Unfinished \/ Blocked/i.test(healed)) healed += "\n\n## Unfinished / Blocked\n- None\n";
819
+ if (!/#+\s+Context for Next Session/i.test(healed)) healed += "\n\n## Context for Next Session\n- \n";
820
+ if (!/#+\s+Commits/i.test(healed)) healed += "\n\n## Commits\n- None\n";
821
+ }
822
+ return healed.trim();
823
+ }
824
+ function healAutoContext(result) {
825
+ if (!("auto_context" in result)) return;
826
+ const ac = result["auto_context"];
827
+ if (typeof ac === "string") {
828
+ try {
829
+ const parsed = JSON.parse(ac.replace(/'/g, '"'));
830
+ if (!isRecord(parsed)) return;
831
+ let changed = false;
832
+ for (const alias of ["commit_shas", "shas", "commit_sha", "commitShas"]) {
833
+ if (alias in parsed) {
834
+ parsed["commits"] = parsed[alias];
835
+ Reflect.deleteProperty(parsed, alias);
836
+ changed = true;
837
+ }
838
+ }
839
+ if ("commits" in parsed && typeof parsed["commits"] === "string") {
840
+ parsed["commits"] = [parsed["commits"]];
841
+ changed = true;
842
+ }
843
+ if (changed) {
844
+ result["auto_context"] = JSON.stringify(parsed);
845
+ }
846
+ } catch {
847
+ }
848
+ } else if (isRecord(ac)) {
849
+ for (const alias of ["commit_shas", "shas", "commit_sha", "commitShas"]) {
850
+ if (alias in ac) {
851
+ ac["commits"] = ac[alias];
852
+ Reflect.deleteProperty(ac, alias);
853
+ }
854
+ }
855
+ if ("commits" in ac && typeof ac["commits"] === "string") {
856
+ ac["commits"] = [ac["commits"]];
857
+ }
858
+ }
859
+ }
860
+
861
+ // src/codemode/normalizers/generic-interceptions.ts
862
+ var NUMERIC_ID_KEYS = [
863
+ "entry_id",
864
+ "entryId",
865
+ "id",
866
+ "from_entry_id",
867
+ "fromEntryId",
868
+ "to_entry_id",
869
+ "toEntryId",
870
+ "project_number",
871
+ "projectNumber",
872
+ "issue_number",
873
+ "issueNumber",
874
+ "pr_number",
875
+ "prNumber",
876
+ "milestone_number",
877
+ "milestoneNumber",
878
+ "offset",
879
+ "limit"
880
+ ];
881
+ var EXECUTE_METHODS = /* @__PURE__ */ new Set([
882
+ "execute",
883
+ "execute_code",
884
+ "executeCode",
885
+ "mj_execute_code",
886
+ "mjExecuteCode",
887
+ "mysql_execute_code",
888
+ "mysqlExecuteCode"
889
+ ]);
890
+ var CREATE_ENTRY_METHODS = /* @__PURE__ */ new Set([
891
+ "create_entry",
892
+ "createEntry",
893
+ "team_create_entry",
894
+ "teamCreateEntry"
895
+ ]);
896
+ function applyGenericInterceptions(methodName, args) {
897
+ if (EXECUTE_METHODS.has(methodName) && args.length === 1 && typeof args[0] === "string") {
898
+ args = [{ code: args[0] }];
899
+ }
900
+ if (CREATE_ENTRY_METHODS.has(methodName) && args.length === 1 && typeof args[0] === "string") {
901
+ args = [{ content: args[0] }];
902
+ }
903
+ if (args.length === 2 && typeof args[0] === "string" && isRecord(args[1])) {
904
+ const firstStr = args[0].trim();
905
+ const mergedObj = { ...args[1] };
906
+ if (mergedObj["workspace_id"] === void 0 && mergedObj["workspaceId"] === void 0) {
907
+ mergedObj["workspace_id"] = firstStr;
908
+ } else if (mergedObj["title"] === void 0 && mergedObj["content"] === void 0) {
909
+ mergedObj["title"] = firstStr;
910
+ }
911
+ args = [mergedObj];
912
+ }
913
+ if (args.length !== 1 || !isRecord(args[0])) return { args };
914
+ const obj = { ...args[0] };
915
+ args[0] = obj;
916
+ cleanSdkMetadataKeys(obj);
917
+ normalizeSearchGrepAliases(methodName, obj);
918
+ extractMetadataContextAliases(obj);
919
+ coerceNumericStringIds(obj);
920
+ normalizeGenericFieldAliases(obj);
921
+ if (CREATE_ENTRY_METHODS.has(methodName)) {
922
+ resolveCreateEntryProjectContext(obj);
923
+ }
924
+ if (typeof obj["sort_by"] === "string") {
925
+ const lowerSort = obj["sort_by"].toLowerCase();
926
+ if (lowerSort.endsWith("_asc")) {
927
+ obj["sort_by"] = obj["sort_by"].replace(/_asc$/i, "");
928
+ obj["sort_order"] ??= "asc";
929
+ } else if (lowerSort.endsWith("_desc")) {
930
+ obj["sort_by"] = obj["sort_by"].replace(/_desc$/i, "");
931
+ obj["sort_order"] ??= "desc";
932
+ }
933
+ }
934
+ if (EXECUTE_METHODS.has(methodName)) {
935
+ normalizeExecuteCodeAliases(obj);
936
+ } else if (obj["repo"] !== void 0 && obj["repo_name"] === void 0) {
937
+ obj["repo_name"] = obj["repo"];
938
+ delete obj["repo"];
939
+ }
940
+ for (const [src, dst] of [["item_type", "type"], ["category", "type"], ["metadata", "context"]]) {
941
+ if (obj[src] !== void 0 && obj[dst] === void 0) {
942
+ obj[dst] = obj[src];
943
+ Reflect.deleteProperty(obj, src);
944
+ }
945
+ }
946
+ if (CREATE_ENTRY_METHODS.has(methodName) || methodName === "update_entry" || methodName === "updateEntry") {
947
+ synthesizeEntryMutationFields(obj);
948
+ }
949
+ if (obj["search"] !== void 0 && obj["query"] === void 0) {
950
+ obj["query"] = obj["search"];
951
+ delete obj["search"];
952
+ }
953
+ if (["import_external", "importExternal", "team_import_external", "teamImportExternal"].includes(methodName) && obj["source_dir"] === void 0 && obj["filename"] !== void 0) {
954
+ obj["source_dir"] = obj["filename"];
955
+ delete obj["filename"];
956
+ }
957
+ return { args };
958
+ }
959
+ function cleanSdkMetadataKeys(obj) {
960
+ for (const k of ["_u_r_i", "_uri"]) {
961
+ if (obj[k] !== void 0) {
962
+ if (obj["uri"] === void 0 && obj["Uri"] === void 0) obj["uri"] = obj[k];
963
+ Reflect.deleteProperty(obj, k);
964
+ }
965
+ }
966
+ if (obj["_url"] !== void 0) {
967
+ if (obj["url"] === void 0 && obj["Url"] === void 0) obj["url"] = obj["_url"];
968
+ delete obj["_url"];
969
+ }
970
+ delete obj["_server_name"];
971
+ delete obj["_tool_name"];
972
+ delete obj["_meta"];
973
+ for (const key of Object.keys(obj)) {
974
+ if (key.startsWith("_") && key !== "_journal") {
975
+ const strippedKey = key.replace(/^_+/, "");
976
+ if (strippedKey.length > 0 && obj[strippedKey] === void 0) obj[strippedKey] = obj[key];
977
+ Reflect.deleteProperty(obj, key);
978
+ }
979
+ }
980
+ }
981
+ function normalizeSearchGrepAliases(methodName, obj) {
982
+ const lower = methodName.toLowerCase();
983
+ if (!lower.includes("search") && !lower.includes("grep") && !lower.includes("find")) return;
984
+ if (obj["search_path"] === void 0) {
985
+ const p = obj["searchPath"] ?? obj["SearchPath"] ?? obj["path"] ?? obj["Path"] ?? obj["dir"] ?? obj["directory"] ?? obj["cwd"];
986
+ if (typeof p === "string") obj["search_path"] = p;
987
+ }
988
+ if (obj["query"] === void 0) {
989
+ const q = obj["Query"] ?? obj["pattern"] ?? obj["text"] ?? obj["search"] ?? obj["q"];
990
+ if (typeof q === "string") obj["query"] = q;
991
+ }
992
+ if (obj["file_pattern"] === void 0) {
993
+ const fp = obj["filePattern"] ?? obj["FilePattern"] ?? obj["include"];
994
+ if (typeof fp === "string") obj["file_pattern"] = fp;
995
+ }
996
+ if (obj["case_insensitive"] === void 0) {
997
+ const ci = obj["caseInsensitive"] ?? obj["CaseInsensitive"] ?? obj["ignore_case"] ?? obj["ignoreCase"];
998
+ if (typeof ci === "boolean") obj["case_insensitive"] = ci;
999
+ }
1000
+ if (obj["is_regex"] === void 0) {
1001
+ const ir = obj["isRegex"] ?? obj["IsRegex"] ?? obj["regex"];
1002
+ if (typeof ir === "boolean") obj["is_regex"] = ir;
1003
+ }
1004
+ if (obj["match_per_line"] === void 0) {
1005
+ const mpl = obj["matchPerLine"] ?? obj["MatchPerLine"];
1006
+ if (typeof mpl === "boolean") obj["match_per_line"] = mpl;
1007
+ }
1008
+ }
1009
+ function extractMetadataContextAliases(obj) {
1010
+ const metaObj = isRecord(obj["metadata"]) ? obj["metadata"] : isRecord(obj["context"]) ? obj["context"] : void 0;
1011
+ if (!metaObj) return;
1012
+ obj["project_number"] ??= metaObj["project_number"] ?? metaObj["projectNumber"];
1013
+ obj["session_id"] ??= metaObj["session_id"] ?? metaObj["sessionId"];
1014
+ obj["type"] ??= metaObj["type"] ?? metaObj["entry_type"] ?? metaObj["category"];
1015
+ obj["tags"] ??= metaObj["tags"];
1016
+ obj["workspace_id"] ??= metaObj["workspace_id"] ?? metaObj["workspaceId"];
1017
+ }
1018
+ function coerceNumericStringIds(obj) {
1019
+ for (const key of NUMERIC_ID_KEYS) {
1020
+ const val = obj[key];
1021
+ if (typeof val === "string") {
1022
+ const strVal = val.trim();
1023
+ if (/^-?\d+$/.test(strVal)) {
1024
+ const parsed = parseInt(strVal, 10);
1025
+ if (!isNaN(parsed)) obj[key] = parsed;
1026
+ } else if ((key === "project_number" || key === "projectNumber") && /^p-?\d+$/i.test(strVal)) {
1027
+ const parsed = parseInt(strVal.replace(/^p-?/i, ""), 10);
1028
+ if (!isNaN(parsed)) obj[key] = parsed;
1029
+ } else if (key === "project_number" || key === "projectNumber") {
1030
+ Reflect.deleteProperty(obj, key);
1031
+ }
1032
+ }
1033
+ }
1034
+ }
1035
+ function normalizeGenericFieldAliases(obj) {
1036
+ for (const [src, dst] of [
1037
+ ["user", "target_user"],
1038
+ ["severity", "flag_type"],
1039
+ ["msg", "message"],
1040
+ ["sort", "sort_by"],
1041
+ ["sortBy", "sort_by"],
1042
+ ["orderBy", "sort_by"],
1043
+ ["order_by", "sort_by"],
1044
+ ["validation", "validation_status"],
1045
+ ["validationStatus", "validation_status"]
1046
+ ]) {
1047
+ if (obj[src] !== void 0) {
1048
+ if (obj[dst] === void 0) obj[dst] = obj[src];
1049
+ Reflect.deleteProperty(obj, src);
1050
+ }
1051
+ }
1052
+ for (const [aliasKey, targetKey] of [
1053
+ ["confidence", "trust_score"],
1054
+ ["trust", "trust_score"],
1055
+ ["trustScore", "trust_score"],
1056
+ ["impact", "impact_score"],
1057
+ ["impactScore", "impact_score"]
1058
+ ]) {
1059
+ if (obj[aliasKey] !== void 0) {
1060
+ if (obj[targetKey] === void 0) {
1061
+ obj[targetKey] = typeof obj[aliasKey] === "string" ? Number(obj[aliasKey]) : obj[aliasKey];
1062
+ }
1063
+ Reflect.deleteProperty(obj, aliasKey);
1064
+ }
1065
+ }
1066
+ if (obj["validation_status"] !== void 0 && obj["validation_status"] !== null) {
1067
+ const vs = typeof obj["validation_status"] === "string" ? obj["validation_status"].trim().toLowerCase() : obj["validation_status"];
1068
+ if (vs === true || typeof vs === "string" && ["pass", "success", "ok", "passed", "validated", "valid", "verified", "true", "1"].includes(vs)) {
1069
+ obj["validation_status"] = "passed";
1070
+ } else if (vs === false || typeof vs === "string" && ["fail", "failed", "error", "failing", "false", "0"].includes(vs)) {
1071
+ obj["validation_status"] = "failed";
1072
+ } else if (typeof vs === "string" && !["passed", "none", "failed"].includes(vs)) {
1073
+ obj["validation_status"] = "none";
1074
+ }
1075
+ }
1076
+ for (const projAlias of ["project_name", "projectName"]) {
1077
+ if (obj[projAlias] !== void 0) {
1078
+ if (obj["project_number"] === void 0) {
1079
+ const num = Number(obj[projAlias]);
1080
+ const strVal = typeof obj[projAlias] === "string" || typeof obj[projAlias] === "number" ? String(obj[projAlias]) : "";
1081
+ if (!Number.isNaN(num) && strVal.trim() !== "") obj["project_number"] = num;
1082
+ }
1083
+ Reflect.deleteProperty(obj, projAlias);
1084
+ }
1085
+ }
1086
+ if (obj["project"] !== void 0) {
1087
+ if (obj["project_number"] === void 0) {
1088
+ const num = Number(obj["project"]);
1089
+ const strVal = typeof obj["project"] === "string" || typeof obj["project"] === "number" ? String(obj["project"]) : "";
1090
+ if (!Number.isNaN(num) && strVal.trim() !== "") {
1091
+ obj["project_number"] = num;
1092
+ } else if (typeof obj["project"] === "string" && obj["project"].trim() !== "") {
1093
+ const existingTags = Array.isArray(obj["tags"]) ? obj["tags"].filter((t) => typeof t === "string") : [];
1094
+ obj["tags"] = [...existingTags, obj["project"].trim()];
1095
+ }
1096
+ }
1097
+ delete obj["project"];
1098
+ }
1099
+ }
1100
+ function resolveCreateEntryProjectContext(obj) {
1101
+ let projNum = typeof obj["project_number"] === "number" ? obj["project_number"] : void 0;
1102
+ if (typeof obj["project_number"] === "string") {
1103
+ const cleaned = obj["project_number"].trim();
1104
+ let parsedNum = Number(cleaned);
1105
+ if (Number.isNaN(parsedNum) && /^p-?\d+$/i.test(cleaned)) {
1106
+ parsedNum = Number(cleaned.replace(/^p-?/i, ""));
1107
+ }
1108
+ if (!Number.isNaN(parsedNum) && cleaned !== "") {
1109
+ projNum = parsedNum;
1110
+ obj["project_number"] = parsedNum;
1111
+ } else {
1112
+ if (obj["workspace_id"] === void 0 || obj["workspace_id"] === null || obj["workspace_id"] === "" || obj["workspace_id"] === "default") {
1113
+ obj["workspace_id"] = cleaned;
1114
+ }
1115
+ delete obj["project_number"];
1116
+ }
1117
+ }
1118
+ const content = typeof obj["content"] === "string" ? obj["content"] : void 0;
1119
+ const tags = Array.isArray(obj["tags"]) ? obj["tags"].filter((t) => typeof t === "string") : void 0;
1120
+ const resolved = resolveProjectContext({
1121
+ ...typeof obj["workspace_id"] === "string" ? { workspace_id: obj["workspace_id"] } : {},
1122
+ ...projNum !== void 0 ? { project_number: projNum } : {},
1123
+ ...content !== void 0 ? { content } : {},
1124
+ ...tags !== void 0 ? { tags } : {}
1125
+ });
1126
+ if (resolved.workspaceId !== void 0 && resolved.workspaceId !== "" && (obj["workspace_id"] === void 0 || obj["workspace_id"] === null || obj["workspace_id"] === "" || obj["workspace_id"] === "default")) {
1127
+ if (resolved.workspaceId !== "default") {
1128
+ obj["workspace_id"] = resolved.workspaceId;
1129
+ } else if (process.env["MCP_WORKSPACE_ID"] !== void 0 && process.env["MCP_WORKSPACE_ID"] !== "") {
1130
+ obj["workspace_id"] = process.env["MCP_WORKSPACE_ID"];
1131
+ } else {
1132
+ obj["workspace_id"] = "default";
1133
+ }
1134
+ }
1135
+ if (obj["project_number"] === void 0 && resolved.projectNumber !== void 0) {
1136
+ obj["project_number"] = resolved.projectNumber;
1137
+ }
1138
+ }
1139
+ function normalizeExecuteCodeAliases(obj) {
1140
+ if (obj["repo_name"] !== void 0 && obj["repo"] === void 0) {
1141
+ obj["repo"] = obj["repo_name"];
1142
+ delete obj["repo_name"];
1143
+ }
1144
+ if (obj["code"] !== void 0) return;
1145
+ const codeAlias = obj["script"] ?? obj["js"] ?? obj["javascript"] ?? obj["query"] ?? obj["command"] ?? obj["content"] ?? obj["eval"] ?? obj["source"] ?? obj["body"] ?? obj["expression"] ?? obj["fn"] ?? obj["exec"] ?? obj["code_snippet"] ?? obj["raw_code"] ?? obj["statement"] ?? obj["statements"] ?? obj["codeBlock"] ?? obj["code_block"] ?? obj["script_content"] ?? obj["js_code"] ?? obj["code_string"] ?? obj["action"] ?? obj["task"] ?? obj["instruction"] ?? obj["instructions"] ?? obj["input"] ?? obj["payload"] ?? obj["text"];
1146
+ if (typeof codeAlias === "string") obj["code"] = codeAlias;
1147
+ else if (isRecord(obj["payload"])) obj["code"] = JSON.stringify(obj["payload"]);
1148
+ else if (isRecord(obj["entry"])) obj["code"] = JSON.stringify(obj["entry"]);
1149
+ else if (isRecord(obj["input"])) obj["code"] = JSON.stringify(obj["input"]);
1150
+ else if (obj["action"] !== void 0 || obj["task"] !== void 0 || obj["notes"] !== void 0 || obj["changes"] !== void 0) {
1151
+ obj["code"] = JSON.stringify(obj);
1152
+ } else {
1153
+ for (const [k, v] of Object.entries(obj)) {
1154
+ if (typeof v === "string" && v.trim().length > 0 && !["repo", "workspace_id", "expected_version", "auto_version", "project_number"].includes(k)) {
1155
+ obj["code"] = v;
1156
+ break;
1157
+ }
1158
+ }
1159
+ }
1160
+ }
1161
+ function synthesizeEntryMutationFields(obj) {
1162
+ if (obj["type"] !== void 0 && obj["entry_type"] === void 0) {
1163
+ obj["entry_type"] = obj["type"];
1164
+ delete obj["type"];
1165
+ }
1166
+ if (typeof obj["entry_type"] === "string") {
1167
+ const etLower = obj["entry_type"].toLowerCase().trim();
1168
+ if (["bug", "bugfix", "bug_fix", "bug-fix", "hotfix", "defect"].includes(etLower)) obj["entry_type"] = "bug_fix";
1169
+ else if (["progress", "status", "development"].includes(etLower)) obj["entry_type"] = "development_note";
1170
+ else if (etLower === "feature") obj["entry_type"] = "feature_implementation";
1171
+ else if (etLower === "meeting") obj["entry_type"] = "meeting_notes";
1172
+ else if (["task", "chore", "refactor", "fix", "update", "technical", "note", "documentation", "code", "coding"].includes(etLower)) {
1173
+ obj["entry_type"] = "technical_note";
1174
+ } else if (["session-summary", "session_summary", "team-session-summary", "team_session_summary", "team session summary"].includes(etLower)) {
1175
+ obj["entry_type"] = "retrospective";
1176
+ }
1177
+ }
1178
+ const contentParts = [];
1179
+ const consumeGroup = (keys, format) => {
1180
+ let found;
1181
+ for (const k of keys) {
1182
+ if (found === void 0 && obj[k] !== void 0) found = obj[k];
1183
+ Reflect.deleteProperty(obj, k);
1184
+ }
1185
+ if (found !== void 0) {
1186
+ const s = format(found);
1187
+ if (s !== "") contentParts.push(s);
1188
+ }
1189
+ };
1190
+ consumeGroup(["title", "heading", "subject", "name"], (v) => {
1191
+ const s = safeString(v);
1192
+ return s !== "" ? `# ${s}` : "";
1193
+ });
1194
+ consumeGroup(["description", "details", "summary", "notes", "text", "message"], safeString);
1195
+ consumeGroup(["context"], (v) => {
1196
+ const s = safeString(v);
1197
+ return s !== "" ? `**Context:** ${s}` : "";
1198
+ });
1199
+ consumeGroup(["focus", "goal", "objective"], (v) => {
1200
+ const s = safeString(v);
1201
+ return s !== "" ? `**Focus:** ${s}` : "";
1202
+ });
1203
+ consumeGroup(["resolution", "fix", "solution", "result"], (v) => {
1204
+ const s = safeString(v);
1205
+ return s !== "" ? `**Resolution:** ${s}` : "";
1206
+ });
1207
+ consumeGroup(["artifacts", "files", "changes", "modified_files"], (v) => {
1208
+ const s = Array.isArray(v) ? v.map(safeString).join(", ") : safeString(v);
1209
+ return s !== "" ? `**Artifacts:** ${s}` : "";
1210
+ });
1211
+ consumeGroup(["findings", "results", "key_findings", "discoveries"], (v) => {
1212
+ const s = Array.isArray(v) ? v.map((f) => `- ${safeString(f)}`).join("\n") : safeString(v);
1213
+ return s !== "" ? `**Findings:**
1214
+ ${s}` : "";
1215
+ });
1216
+ if (obj["content"] !== void 0) {
1217
+ const existing = safeString(obj["content"]);
1218
+ if (contentParts.length > 0) {
1219
+ obj["content"] = existing !== "" ? `${existing}
1220
+
1221
+ ${contentParts.join("\n\n")}` : contentParts.join("\n\n");
1222
+ }
1223
+ } else if (contentParts.length > 0) {
1224
+ obj["content"] = contentParts.join("\n\n");
1225
+ }
1226
+ if (typeof obj["content"] === "string") {
1227
+ obj["content"] = obj["content"].replace(/\\+'/g, "'").replace(/\\+"/g, '"');
1228
+ }
1229
+ }
1230
+
1231
+ // src/codemode/normalizers/entry-and-search-interceptions.ts
1232
+ var SEARCH_METHODS = /* @__PURE__ */ new Set([
1233
+ "search_entries",
1234
+ "searchEntries",
1235
+ "team_search",
1236
+ "teamSearch",
1237
+ "search_by_date_range",
1238
+ "searchByDateRange",
1239
+ "team_search_by_date_range",
1240
+ "teamSearchByDateRange",
1241
+ "semantic_search",
1242
+ "semanticSearch",
1243
+ "team_semantic_search",
1244
+ "teamSemanticSearch",
1245
+ "cross_team_search",
1246
+ "crossTeamSearch"
1247
+ ]);
1248
+ var EXACT_MATCH_SEARCH_METHODS = /* @__PURE__ */ new Set([
1249
+ "search_entries",
1250
+ "searchEntries",
1251
+ "team_search",
1252
+ "teamSearch",
1253
+ "search_by_date_range",
1254
+ "searchByDateRange",
1255
+ "team_search_by_date_range",
1256
+ "teamSearchByDateRange",
1257
+ "cross_team_search",
1258
+ "crossTeamSearch"
1259
+ ]);
1260
+ var SINGLE_ID_METHODS = /* @__PURE__ */ new Set([
1261
+ "delete_entry",
1262
+ "deleteEntry",
1263
+ "restore_entry",
1264
+ "restoreEntry",
1265
+ "get_entry_by_id",
1266
+ "getEntryById",
1267
+ "team_get_entry_by_id",
1268
+ "teamGetEntryById",
1269
+ "get_entry_history",
1270
+ "getEntryHistory",
1271
+ "add_to_vector_index",
1272
+ "addToVectorIndex",
1273
+ "team_add_to_vector_index",
1274
+ "teamAddToVectorIndex",
1275
+ "add_to_index",
1276
+ "addToIndex",
1277
+ "update_entry",
1278
+ "updateEntry",
1279
+ "team_update_entry",
1280
+ "teamUpdateEntry",
1281
+ "edit",
1282
+ "update",
1283
+ "team_delete_entry",
1284
+ "teamDeleteEntry",
1285
+ "delete",
1286
+ "team_restore_entry",
1287
+ "teamRestoreEntry",
1288
+ "restore",
1289
+ "team_restore",
1290
+ "teamRestore"
1291
+ ]);
1292
+ var CREATE_METHODS = /* @__PURE__ */ new Set([
1293
+ "create_entry",
1294
+ "createEntry",
1295
+ "team_create_entry",
1296
+ "teamCreateEntry",
1297
+ "add_entry",
1298
+ "addEntry",
1299
+ "mj_add_entry",
1300
+ "mjAddEntry",
1301
+ "create_journal_entry",
1302
+ "createJournalEntry",
1303
+ "insert_entry",
1304
+ "insertEntry"
1305
+ ]);
1306
+ var SESSION_SUMMARY_METHODS = /* @__PURE__ */ new Set([
1307
+ "create_entry",
1308
+ "createEntry",
1309
+ "team_create_entry",
1310
+ "teamCreateEntry",
1311
+ "update_entry",
1312
+ "updateEntry",
1313
+ "team_update_entry",
1314
+ "teamUpdateEntry"
1315
+ ]);
1316
+ function validationError(error, suggestion) {
1317
+ return {
1318
+ error: {
1319
+ success: false,
1320
+ error,
1321
+ code: "VALIDATION_ERROR",
1322
+ category: "validation",
1323
+ suggestion,
1324
+ recoverable: true
1325
+ }
1326
+ };
1327
+ }
1328
+ function applyEntryAndSearchInterceptions(methodName, args) {
1329
+ if (SEARCH_METHODS.has(methodName) && args.length === 1 && isRecord(args[0])) {
1330
+ const obj = { ...args[0] };
1331
+ args[0] = obj;
1332
+ const isDateRange = ["search_by_date_range", "searchByDateRange", "team_search_by_date_range", "teamSearchByDateRange"].includes(methodName);
1333
+ if (isDateRange && ["q", "query", "text", "message", "description", "keep", "path"].some((k) => obj[k] !== void 0)) {
1334
+ return validationError(
1335
+ `${methodName} does not support search queries. It only searches by date.`,
1336
+ "Use team_search (or search_entries) if you want to search by text, or remove the text/query parameters."
1337
+ );
1338
+ }
1339
+ for (const alias of ["q", "text", "message", "description", "path", "keep"]) {
1340
+ if (obj[alias] !== void 0 && obj["query"] === void 0) {
1341
+ obj["query"] = obj[alias];
1342
+ Reflect.deleteProperty(obj, alias);
1343
+ }
1344
+ }
1345
+ if (obj["start"] !== void 0 && obj["start_date"] === void 0) {
1346
+ obj["start_date"] = obj["start"];
1347
+ delete obj["start"];
1348
+ }
1349
+ if (obj["end"] !== void 0 && obj["end_date"] === void 0) {
1350
+ obj["end_date"] = obj["end"];
1351
+ delete obj["end"];
1352
+ }
1353
+ if (typeof obj["limit"] === "string") {
1354
+ const parsed = parseInt(obj["limit"], 10);
1355
+ if (!isNaN(parsed)) obj["limit"] = parsed;
1356
+ }
1357
+ if (!["search_entries", "searchEntries", "team_search", "teamSearch"].includes(methodName) && obj["mode"] !== void 0) {
1358
+ return validationError(
1359
+ `${methodName} does not support the 'mode' parameter.`,
1360
+ "Remove the mode parameter or use search_entries instead."
1361
+ );
1362
+ }
1363
+ }
1364
+ if (EXACT_MATCH_SEARCH_METHODS.has(methodName) && args.length === 1 && isRecord(args[0])) {
1365
+ const obj = { ...args[0] };
1366
+ args[0] = obj;
1367
+ if ("exact_match" in obj) {
1368
+ const isFuzzy = obj["exact_match"] === false;
1369
+ obj["fuzzy_match"] = isFuzzy;
1370
+ if (methodName !== "cross_team_search" && methodName !== "crossTeamSearch") obj["auto_correct"] = isFuzzy;
1371
+ delete obj["exact_match"];
1372
+ } else if (obj["fuzzy_match"] === true && !("auto_correct" in obj)) {
1373
+ if (methodName !== "cross_team_search" && methodName !== "crossTeamSearch") obj["auto_correct"] = true;
1374
+ }
1375
+ if (typeof obj["start_date"] === "string" && (obj["end_date"] === void 0 || obj["end_date"] === null || obj["end_date"] === "")) {
1376
+ obj["end_date"] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1377
+ }
1378
+ if ((methodName === "team_search" || methodName === "teamSearch" || methodName === "team_search_by_date_range" || methodName === "teamSearchByDateRange") && obj["project_number"] == null) {
1379
+ const tags = Array.isArray(obj["tags"]) ? obj["tags"] : void 0;
1380
+ const entryType = typeof obj["entry_type"] === "string" ? obj["entry_type"] : void 0;
1381
+ const isFlagSearch = Boolean(tags && tags.length > 0 && tags.every((t) => typeof t === "string" && t.startsWith("flag:"))) || entryType === "flag";
1382
+ if (!isFlagSearch) {
1383
+ const label = methodName.includes("date") ? "Cross-project team date range searches" : "Cross-project team searches";
1384
+ return validationError(
1385
+ `${label} are only permitted for flags. Provide a project_number or filter by entry_type="flag" or flag:* tags.`,
1386
+ 'Provide a project_number, or use tags starting with "flag:" or entry_type="flag"'
1387
+ );
1388
+ }
1389
+ }
1390
+ }
1391
+ if (SINGLE_ID_METHODS.has(methodName)) {
1392
+ const singleRes = applySingleIdInterception(methodName, args);
1393
+ if ("error" in singleRes) return singleRes;
1394
+ args = singleRes.args;
1395
+ }
1396
+ if ((methodName === "update_entry" || methodName === "updateEntry") && args.length === 2 && (typeof args[0] === "number" || typeof args[0] === "string") && isRecord(args[1])) {
1397
+ const asNum = typeof args[0] === "string" ? parseInt(args[0], 10) : args[0];
1398
+ if (!isNaN(asNum)) args = [{ entry_id: asNum, ...args[1] }];
1399
+ }
1400
+ return applyBatchAndMutationInterceptions(methodName, args);
1401
+ }
1402
+ function applySingleIdInterception(methodName, args) {
1403
+ if (args.length === 0) {
1404
+ return validationError(`${methodName} requires an 'entry_id' parameter.`, "Provide { entry_id: number } as the argument");
1405
+ }
1406
+ if (args.length !== 1) return { args };
1407
+ if (Array.isArray(args[0])) {
1408
+ return validationError(
1409
+ `${methodName} only accepts a single entry. To process multiple entries, use the batch equivalent (e.g., batch_delete_entries).`,
1410
+ "Use a batch method or pass a single object like { entry_id: number }"
1411
+ );
1412
+ }
1413
+ if (isRecord(args[0])) {
1414
+ const obj = { ...args[0] };
1415
+ args[0] = obj;
1416
+ if (["ids", "entry_ids", "entry_id", "id"].some((k) => Array.isArray(obj[k]))) {
1417
+ return validationError(
1418
+ `${methodName} only accepts a single entry_id. To process multiple entries, use the batch equivalent.`,
1419
+ "Use a batch method (e.g. batch_delete_entries) or pass { entry_id: number }"
1420
+ );
1421
+ }
1422
+ const idVal = obj["entry_id"] ?? obj["entryId"] ?? obj["id"] ?? obj["path"] ?? obj["keep"];
1423
+ if (idVal === void 0) {
1424
+ return validationError(`${methodName} requires an 'entry_id' parameter.`, "Provide { entry_id: number, ... } as the argument");
1425
+ }
1426
+ for (const k of ["path", "keep"]) {
1427
+ if (obj[k] !== void 0 && obj["entry_id"] === void 0) {
1428
+ obj["entry_id"] = obj[k];
1429
+ Reflect.deleteProperty(obj, k);
1430
+ }
1431
+ }
1432
+ if (["q", "query", "mode", "search"].some((k) => obj[k] !== void 0) && !["update_entry", "updateEntry", "team_update_entry", "teamUpdateEntry"].includes(methodName)) {
1433
+ return validationError(
1434
+ `${methodName} does not support q, query, search, or mode parameters. It operates on a single entry by entry_id.`,
1435
+ "Remove these parameters. Provide only the entry_id."
1436
+ );
1437
+ }
1438
+ if (typeof idVal === "string" && isNaN(parseInt(idVal, 10))) {
1439
+ return validationError(
1440
+ `${methodName} requires a numeric entry_id, but received a non-numeric string ('${idVal}'). Journal entries use auto-incrementing integer IDs.`,
1441
+ "Provide a numeric ID."
1442
+ );
1443
+ }
1444
+ } else if (typeof args[0] === "number" || typeof args[0] === "string") {
1445
+ const asNum = typeof args[0] === "string" ? parseInt(args[0], 10) : args[0];
1446
+ if (!isNaN(asNum)) {
1447
+ args[0] = { entry_id: asNum };
1448
+ } else {
1449
+ return validationError(
1450
+ `${methodName} requires a numeric entry_id, but received a non-numeric string ('${args[0]}'). Journal entries use auto-incrementing integer IDs.`,
1451
+ "Provide a numeric ID."
1452
+ );
1453
+ }
1454
+ }
1455
+ return { args };
1456
+ }
1457
+ function applyBatchAndMutationInterceptions(methodName, args) {
1458
+ if (["batch_create_entries", "batchCreateEntries", "team_batch_create_entries", "teamBatchCreateEntries"].includes(methodName) && args.length === 1) {
1459
+ if (Array.isArray(args[0])) args[0] = { entries: args[0] };
1460
+ else if (isRecord(args[0]) && !("entries" in args[0])) {
1461
+ return validationError(`${methodName} requires an 'entries' array.`, "Provide { entries: [...] } as the argument");
1462
+ }
1463
+ }
1464
+ if (["batch_update_entries", "batchUpdateEntries", "team_batch_update_entries", "teamBatchUpdateEntries"].includes(methodName) && args.length === 1) {
1465
+ if (Array.isArray(args[0])) args[0] = { updates: args[0] };
1466
+ else if (isRecord(args[0]) && !("updates" in args[0])) {
1467
+ return validationError(`${methodName} requires an 'updates' array.`, "Provide { updates: [...] } as the argument");
1468
+ }
1469
+ }
1470
+ if (["batch_delete_entries", "batchDeleteEntries", "team_batch_delete_entries", "teamBatchDeleteEntries"].includes(methodName)) {
1471
+ if (args.length === 1 && typeof args[0] === "string") {
1472
+ args[0] = { entry_ids: args[0].split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n)) };
1473
+ } else if (args.length === 1 && Array.isArray(args[0])) {
1474
+ if (args[0].some((id) => typeof id === "string")) {
1475
+ return validationError(
1476
+ "batch_delete_entries expects an array of numeric IDs, but received an array containing strings.",
1477
+ "Ensure all IDs in the array are numbers. Use parseInt() if necessary."
1478
+ );
1479
+ }
1480
+ args[0] = { entry_ids: args[0] };
1481
+ } else if (args.length > 1 && args.every((a) => typeof a === "number")) {
1482
+ args = [{ entry_ids: args }];
1483
+ } else if (args.length === 1 && isRecord(args[0]) && !("entry_ids" in args[0])) {
1484
+ return validationError(`${methodName} requires an 'entry_ids' array.`, "Provide { entry_ids: [...] } as the argument");
1485
+ }
1486
+ }
1487
+ if (["update_entry", "updateEntry", "team_update_entry", "teamUpdateEntry"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1488
+ const obj = { ...args[0] };
1489
+ args[0] = obj;
1490
+ if (obj["keep"] !== void 0 && obj["is_archived"] === void 0) {
1491
+ obj["is_archived"] = obj["keep"] === false || obj["keep"] === 0 || obj["keep"] === "";
1492
+ delete obj["keep"];
1493
+ }
1494
+ for (const alias of ["text", "message", "description"]) {
1495
+ if (obj[alias] !== void 0 && obj["content"] === void 0) {
1496
+ obj["content"] = obj[alias];
1497
+ Reflect.deleteProperty(obj, alias);
1498
+ }
1499
+ }
1500
+ if (["q", "query", "path", "mode", "search"].some((k) => obj[k] !== void 0)) {
1501
+ return validationError(
1502
+ `${methodName} does not support q, query, search, path, or mode parameters.`,
1503
+ "Remove these parameters. Use entry_id and content to update the entry."
1504
+ );
1505
+ }
1506
+ }
1507
+ if (["delete_entry", "deleteEntry", "team_delete_entry", "teamDeleteEntry"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1508
+ const obj = { ...args[0] };
1509
+ args[0] = obj;
1510
+ if (obj["version"] !== void 0 && obj["expected_version"] === void 0) {
1511
+ obj["expected_version"] = obj["version"];
1512
+ delete obj["version"];
1513
+ }
1514
+ if ((methodName === "delete_entry" || methodName === "deleteEntry") && obj["project_number"] !== void 0) {
1515
+ delete obj["project_number"];
1516
+ }
1517
+ }
1518
+ if (CREATE_METHODS.has(methodName) && args.length === 1 && isRecord(args[0])) {
1519
+ const obj = { ...args[0] };
1520
+ args[0] = obj;
1521
+ if (isRecord(obj["entry"])) {
1522
+ const nested = obj["entry"];
1523
+ delete obj["entry"];
1524
+ for (const [k, v] of Object.entries(nested)) {
1525
+ if (obj[k] === void 0 && v !== void 0) obj[k] = v;
1526
+ }
1527
+ }
1528
+ for (const aliasKey of [
1529
+ "entry",
1530
+ "text",
1531
+ "message",
1532
+ "description",
1533
+ "body",
1534
+ "instructions",
1535
+ "details",
1536
+ "notes",
1537
+ "summary",
1538
+ "markdown",
1539
+ "post",
1540
+ "journal_entry",
1541
+ "journalEntry",
1542
+ "entry_text",
1543
+ "entryText"
1544
+ ]) {
1545
+ if (obj[aliasKey] !== void 0) {
1546
+ if (obj["content"] === void 0 && typeof obj[aliasKey] === "string") obj["content"] = obj[aliasKey];
1547
+ Reflect.deleteProperty(obj, aliasKey);
1548
+ }
1549
+ }
1550
+ if (obj["auto_context"] !== void 0) {
1551
+ if (typeof obj["auto_context"] === "object" && obj["auto_context"] !== null) {
1552
+ try {
1553
+ obj["auto_context"] = JSON.stringify(obj["auto_context"]);
1554
+ } catch {
1555
+ return validationError(
1556
+ `${methodName}: auto_context could not be serialized to JSON. Ensure it is a plain object (e.g. { commits: ['<sha>'] }) or a valid JSON string.`,
1557
+ "Pass auto_context as either a JSON string (e.g. JSON.stringify({ commits: [sha] })) or a plain serializable object."
1558
+ );
1559
+ }
1560
+ } else if (typeof obj["auto_context"] !== "string") {
1561
+ return validationError(
1562
+ `${methodName}: auto_context must be a JSON string or plain object (received ${typeof obj["auto_context"]}).`,
1563
+ 'Pass auto_context as a JSON string, e.g. JSON.stringify({ commits: ["<sha>"] }), or as a plain object like { commits: ["<sha>"] }.'
1564
+ );
1565
+ }
1566
+ }
1567
+ if (["q", "query", "path", "mode", "keep", "search"].some((k) => obj[k] !== void 0)) {
1568
+ return validationError(
1569
+ `${methodName} does not support q, query, search, path, mode, or keep parameters. It creates a new journal entry.`,
1570
+ 'Remove these parameters. Ensure you are providing the "content" of the entry.'
1571
+ );
1572
+ }
1573
+ }
1574
+ if (SESSION_SUMMARY_METHODS.has(methodName) && args.length === 1 && isRecord(args[0])) {
1575
+ const obj = { ...args[0] };
1576
+ args[0] = obj;
1577
+ const tags = Array.isArray(obj["tags"]) ? obj["tags"] : void 0;
1578
+ const entryType = typeof obj["entry_type"] === "string" ? obj["entry_type"] : void 0;
1579
+ if (typeof obj["content"] === "string" && (tags?.includes("session-summary") || entryType === "retrospective")) {
1580
+ obj["content"] = healSessionSummaryContent(obj["content"], { normalizeSynonyms: true, usePeriodOnNone: false });
1581
+ }
1582
+ }
1583
+ return { args };
1584
+ }
1585
+
1586
+ // src/codemode/normalizers/github-and-backup-interceptions.ts
1587
+ var GITHUB_METHODS = [
1588
+ "get_github_issues",
1589
+ "getGithubIssues",
1590
+ "get_github_prs",
1591
+ "getGithubPrs",
1592
+ "get_github_issue",
1593
+ "getGithubIssue",
1594
+ "get_github_pr",
1595
+ "getGithubPr",
1596
+ "get_github_context",
1597
+ "getGithubContext",
1598
+ "get_kanban_board",
1599
+ "getKanbanBoard",
1600
+ "move_kanban_item",
1601
+ "moveKanbanItem",
1602
+ "add_kanban_item",
1603
+ "addKanbanItem",
1604
+ "delete_kanban_item",
1605
+ "deleteKanbanItem",
1606
+ "create_github_issue_with_entry",
1607
+ "createGithubIssueWithEntry",
1608
+ "close_github_issue_with_entry",
1609
+ "closeGithubIssueWithEntry",
1610
+ "get_github_milestones",
1611
+ "getGithubMilestones",
1612
+ "get_github_milestone",
1613
+ "getGithubMilestone",
1614
+ "create_github_milestone",
1615
+ "createGithubMilestone",
1616
+ "update_github_milestone",
1617
+ "updateGithubMilestone",
1618
+ "delete_github_milestone",
1619
+ "deleteGithubMilestone",
1620
+ "get_repo_insights",
1621
+ "getRepoInsights",
1622
+ "get_copilot_reviews",
1623
+ "getCopilotReviews"
1624
+ ];
1625
+ var BACKUP_METHODS = [
1626
+ "backup_journal",
1627
+ "backupJournal",
1628
+ "team_backup",
1629
+ "teamBackup",
1630
+ "list_backups",
1631
+ "listBackups",
1632
+ "team_list_backups",
1633
+ "teamListBackups",
1634
+ "restore_backup",
1635
+ "restoreBackup",
1636
+ "cleanup_backups",
1637
+ "cleanupBackups"
1638
+ ];
1639
+ function applyGithubAndBackupInterceptions(methodName, args) {
1640
+ if (GITHUB_METHODS.includes(methodName) && args.length === 1 && isRecord(args[0])) {
1641
+ const ghRes = applyGithubInterceptions(methodName, args[0]);
1642
+ if ("error" in ghRes) return ghRes;
1643
+ args[0] = ghRes.obj;
1644
+ }
1645
+ if (BACKUP_METHODS.includes(methodName) && args.length === 1 && isRecord(args[0])) {
1646
+ const bkRes = applyBackupInterceptions(methodName, args[0]);
1647
+ if ("error" in bkRes) return bkRes;
1648
+ args[0] = bkRes.obj;
1649
+ }
1650
+ return { args };
1651
+ }
1652
+ function applyGithubInterceptions(methodName, rawObj) {
1653
+ const obj = { ...rawObj };
1654
+ for (const key of ["text", "message", "description"]) {
1655
+ if (obj[key] !== void 0) {
1656
+ if (methodName.includes("create_github_issue") || methodName.includes("createGithubIssue")) {
1657
+ if (obj["body"] === void 0) {
1658
+ obj["body"] = obj[key];
1659
+ Reflect.deleteProperty(obj, key);
1660
+ }
1661
+ } else if (methodName.includes("create_github_milestone") || methodName.includes("createGithubMilestone") || methodName.includes("update_github_milestone") || methodName.includes("updateGithubMilestone")) {
1662
+ if (obj["title"] === void 0) {
1663
+ obj["title"] = obj[key];
1664
+ Reflect.deleteProperty(obj, key);
1665
+ }
1666
+ } else if (methodName.includes("close_github_issue") || methodName.includes("closeGithubIssue")) {
1667
+ if (obj["comment"] === void 0 && key !== "description") {
1668
+ obj["comment"] = obj[key];
1669
+ Reflect.deleteProperty(obj, key);
1670
+ } else if (obj["resolution_notes"] === void 0 && key === "description") {
1671
+ obj["resolution_notes"] = obj[key];
1672
+ delete obj["description"];
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ const hasStateParam = methodName.includes("get_github_issues") || methodName.includes("getGithubIssues") || methodName.includes("get_github_prs") || methodName.includes("getGithubPrs") || methodName.includes("get_github_milestones") || methodName.includes("getGithubMilestones");
1678
+ if (hasStateParam && obj["keep"] !== void 0 && obj["state"] === void 0) {
1679
+ if (obj["keep"] === true) obj["state"] = "open";
1680
+ else if (obj["keep"] === false) obj["state"] = "closed";
1681
+ else if (typeof obj["keep"] === "string") obj["state"] = obj["keep"];
1682
+ delete obj["keep"];
1683
+ }
1684
+ if (methodName.includes("get_kanban_board") || methodName.includes("getKanbanBoard")) {
1685
+ for (const k of ["keep", "path"]) {
1686
+ if (obj[k] !== void 0 && obj["project_number"] === void 0) {
1687
+ obj["project_number"] = obj[k];
1688
+ Reflect.deleteProperty(obj, k);
1689
+ }
1690
+ }
1691
+ }
1692
+ if (methodName.includes("move_kanban_item") || methodName.includes("moveKanbanItem")) {
1693
+ if (obj["keep"] !== void 0 && obj["item_id"] === void 0) {
1694
+ obj["item_id"] = obj["keep"];
1695
+ delete obj["keep"];
1696
+ }
1697
+ if (obj["path"] !== void 0 && obj["target_status"] === void 0) {
1698
+ obj["target_status"] = obj["path"];
1699
+ delete obj["path"];
1700
+ }
1701
+ }
1702
+ if (methodName.includes("add_kanban_item") || methodName.includes("addKanbanItem")) {
1703
+ if (obj["keep"] !== void 0 && obj["issue_number"] === void 0) {
1704
+ obj["issue_number"] = obj["keep"];
1705
+ delete obj["keep"];
1706
+ }
1707
+ }
1708
+ if (methodName.includes("delete_kanban_item") || methodName.includes("deleteKanbanItem")) {
1709
+ if (obj["keep"] !== void 0 && obj["item_id"] === void 0) {
1710
+ obj["item_id"] = obj["keep"];
1711
+ delete obj["keep"];
1712
+ }
1713
+ }
1714
+ if (methodName.includes("get_github_milestone") || methodName.includes("getGithubMilestone") || methodName.includes("update_github_milestone") || methodName.includes("updateGithubMilestone") || methodName.includes("delete_github_milestone") || methodName.includes("deleteGithubMilestone")) {
1715
+ if (obj["keep"] !== void 0 && obj["milestone_number"] === void 0) {
1716
+ obj["milestone_number"] = obj["keep"];
1717
+ delete obj["keep"];
1718
+ }
1719
+ }
1720
+ if (obj["mode"] !== void 0 && obj["summary_only"] === void 0) {
1721
+ obj["summary_only"] = obj["mode"] === "summary";
1722
+ delete obj["mode"];
1723
+ }
1724
+ if (hasStateParam && (obj["q"] !== void 0 || obj["query"] !== void 0 || obj["search"] !== void 0)) {
1725
+ return {
1726
+ error: {
1727
+ success: false,
1728
+ error: `${methodName} does not support search queries (q/query/search). It only supports listing by state (open/closed).`,
1729
+ code: "VALIDATION_ERROR",
1730
+ category: "validation",
1731
+ suggestion: "Remove the query parameter to list items, or use GitHub directly for complex searches.",
1732
+ recoverable: true
1733
+ }
1734
+ };
1735
+ }
1736
+ if ((methodName.includes("get_github_context") || methodName.includes("getGithubContext")) && obj["path"] !== void 0) {
1737
+ return {
1738
+ error: {
1739
+ success: false,
1740
+ error: "get_github_context does not take a 'path' parameter. It returns repository-wide context.",
1741
+ code: "VALIDATION_ERROR",
1742
+ category: "validation",
1743
+ suggestion: "Remove the path parameter.",
1744
+ recoverable: true
1745
+ }
1746
+ };
1747
+ }
1748
+ return { obj };
1749
+ }
1750
+ function applyBackupInterceptions(methodName, rawObj) {
1751
+ const obj = { ...rawObj };
1752
+ if (methodName.includes("backup_journal") || methodName.includes("backupJournal") || methodName.includes("team_backup") || methodName.includes("teamBackup")) {
1753
+ if (obj["name"] === void 0) {
1754
+ for (const k of ["description", "message", "text", "path", "q", "keep", "mode"]) {
1755
+ if (obj[k] !== void 0 && obj["name"] === void 0) obj["name"] = obj[k];
1756
+ Reflect.deleteProperty(obj, k);
1757
+ }
1758
+ }
1759
+ }
1760
+ if (methodName.includes("list_backups") || methodName.includes("listBackups") || methodName.includes("team_list_backups") || methodName.includes("teamListBackups")) {
1761
+ if (obj["q"] !== void 0 || obj["query"] !== void 0 || obj["search"] !== void 0 || obj["text"] !== void 0 || obj["message"] !== void 0 || obj["description"] !== void 0 || obj["path"] !== void 0 || obj["keep"] !== void 0 || obj["mode"] !== void 0) {
1762
+ return {
1763
+ error: {
1764
+ success: false,
1765
+ error: "list_backups does not support search queries or other parameters. It lists all available backups.",
1766
+ code: "VALIDATION_ERROR",
1767
+ category: "validation",
1768
+ suggestion: "Remove these parameters.",
1769
+ recoverable: true
1770
+ }
1771
+ };
1772
+ }
1773
+ if (obj["limit"] !== void 0) {
1774
+ return {
1775
+ error: {
1776
+ success: false,
1777
+ error: "list_backups does not support a limit parameter.",
1778
+ code: "VALIDATION_ERROR",
1779
+ category: "validation",
1780
+ suggestion: "Remove the limit parameter.",
1781
+ recoverable: true
1782
+ }
1783
+ };
1784
+ }
1785
+ }
1786
+ if (methodName.includes("restore_backup") || methodName.includes("restoreBackup")) {
1787
+ if (obj["filename"] === void 0) {
1788
+ for (const k of ["path", "file", "text", "message", "description", "q", "keep", "mode"]) {
1789
+ if (obj[k] !== void 0 && obj["filename"] === void 0) obj["filename"] = obj[k];
1790
+ Reflect.deleteProperty(obj, k);
1791
+ }
1792
+ }
1793
+ }
1794
+ if (methodName.includes("cleanup_backups") || methodName.includes("cleanupBackups")) {
1795
+ if (obj["keep_count"] === void 0) {
1796
+ for (const k of ["keep", "limit", "q", "mode", "text", "message", "description", "path"]) {
1797
+ if (obj[k] !== void 0 && obj["keep_count"] === void 0) obj["keep_count"] = obj[k];
1798
+ Reflect.deleteProperty(obj, k);
1799
+ }
1800
+ }
1801
+ }
1802
+ return { obj };
1803
+ }
1804
+
1805
+ // src/codemode/normalizers/domain-tool-interceptions.ts
1806
+ var IO_METHODS = [
1807
+ "export_entries",
1808
+ "exportEntries",
1809
+ "team_export_entries",
1810
+ "teamExportEntries",
1811
+ "export_markdown",
1812
+ "exportMarkdown",
1813
+ "team_export_markdown",
1814
+ "teamExportMarkdown",
1815
+ "import_markdown",
1816
+ "importMarkdown",
1817
+ "team_import_markdown",
1818
+ "teamImportMarkdown",
1819
+ "import_external",
1820
+ "importExternal",
1821
+ "team_import_external",
1822
+ "teamImportExternal"
1823
+ ];
1824
+ var ANALYTICS_METHODS = [
1825
+ "get_statistics",
1826
+ "getStatistics",
1827
+ "get_cross_project_insights",
1828
+ "getCrossProjectInsights",
1829
+ "team_get_statistics",
1830
+ "teamGetStatistics",
1831
+ "team_get_cross_project_insights",
1832
+ "teamGetCrossProjectInsights",
1833
+ "get_collaboration_matrix",
1834
+ "getCollaborationMatrix",
1835
+ "team_get_collaboration_matrix",
1836
+ "teamGetCollaborationMatrix"
1837
+ ];
1838
+ function validationErr(error, suggestion) {
1839
+ return { error: { success: false, error, code: "VALIDATION_ERROR", category: "validation", suggestion, recoverable: true } };
1840
+ }
1841
+ function remapKeys(obj, fromKeys, targetKey) {
1842
+ for (const k of fromKeys) {
1843
+ if (obj[k] !== void 0 && obj[targetKey] === void 0) {
1844
+ obj[targetKey] = obj[k];
1845
+ Reflect.deleteProperty(obj, k);
1846
+ }
1847
+ }
1848
+ }
1849
+ function hasAnyKey(obj, keys) {
1850
+ return keys.some((k) => obj[k] !== void 0);
1851
+ }
1852
+ function applyDomainToolInterceptions(methodName, args) {
1853
+ if (["update_configuration", "updateConfiguration", "config", "configure"].includes(methodName)) {
1854
+ if (args.length === 1 && isRecord(args[0])) {
1855
+ let obj = { ...args[0] };
1856
+ if (isRecord(obj["config"])) {
1857
+ obj = { ...obj, ...obj["config"] };
1858
+ delete obj["config"];
1859
+ }
1860
+ args[0] = obj;
1861
+ if (obj["update_notes"] !== void 0 || obj["notes"] !== void 0 || obj["text"] !== void 0 && obj["tool_filter"] === void 0 && obj["briefing"] === void 0) {
1862
+ return validationErr(
1863
+ "update_configuration is for changing server configuration (tool_filter, briefing). To create journal entries or update notes, use mj.core.createEntry({ ... }).",
1864
+ "Use mj.core.createEntry({ content: '...', project_number: 1 }) instead."
1865
+ );
1866
+ }
1867
+ const hasContextParam = ["maxTokens", "max_tokens", "temperature", "model", "top_p", "topP"].find((k) => k in obj);
1868
+ if (hasContextParam !== void 0) {
1869
+ return validationErr(
1870
+ `Unrecognized key: "${hasContextParam}". update_configuration is for configuring the memory-journal-mcp server and does not support changing LLM context parameters.`,
1871
+ `Remove '${hasContextParam}' from the payload. Only tool_filter and briefing preferences are supported.`
1872
+ );
1873
+ }
1874
+ }
1875
+ }
1876
+ if (IO_METHODS.includes(methodName) && args.length === 1 && isRecord(args[0])) {
1877
+ const ioRes = applyIoInterceptions(methodName, args[0]);
1878
+ if ("error" in ioRes) return ioRes;
1879
+ args[0] = ioRes.obj;
1880
+ }
1881
+ if (["team_get_vector_index_stats", "teamGetVectorIndexStats", "get_vector_index_stats", "getVectorIndexStats"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1882
+ const obj = { ...args[0] };
1883
+ args[0] = obj;
1884
+ if (hasAnyKey(obj, ["q", "query", "search", "text", "message", "description", "path"])) {
1885
+ return validationErr(`${methodName} does not support search queries. It returns overall index statistics.`, "Remove the search query parameter.");
1886
+ }
1887
+ }
1888
+ if (["rebuild_vector_index", "rebuildVectorIndex", "team_rebuild_vector_index", "teamRebuildVectorIndex"].includes(methodName) && args.length === 1 && (typeof args[0] === "boolean" || typeof args[0] === "string" || typeof args[0] === "number")) {
1889
+ args[0] = {};
1890
+ }
1891
+ if (["list_deleted_entries", "listDeletedEntries", "team_list_deleted_entries", "teamListDeletedEntries"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1892
+ const obj = { ...args[0] };
1893
+ args[0] = obj;
1894
+ if (hasAnyKey(obj, ["q", "query", "search", "text", "message", "description", "path", "mode"])) {
1895
+ return validationErr(`${methodName} does not support search queries, path, or mode. It returns all deleted entries.`, "Remove these parameters.");
1896
+ }
1897
+ remapKeys(obj, ["keep"], "limit");
1898
+ if ((methodName === "list_deleted_entries" || methodName === "listDeletedEntries") && obj["project_number"] !== void 0) {
1899
+ delete obj["project_number"];
1900
+ }
1901
+ if (obj["project_id"] !== void 0) delete obj["project_id"];
1902
+ }
1903
+ if (ANALYTICS_METHODS.includes(methodName) && args.length === 1 && isRecord(args[0])) {
1904
+ const obj = { ...args[0] };
1905
+ args[0] = obj;
1906
+ if (hasAnyKey(obj, ["q", "query", "search", "text", "message", "description", "path", "keep", "mode"])) {
1907
+ return validationErr(
1908
+ `${methodName} does not support search queries, content parameters, or modes. It returns analytical data.`,
1909
+ "Remove these parameters. Use search_entries or team_search if you want to find specific content."
1910
+ );
1911
+ }
1912
+ if (methodName.includes("get_statistics") || methodName.includes("getStatistics")) {
1913
+ const timeVal = obj["time"] ?? obj["timeframe"] ?? obj["period"];
1914
+ if (timeVal !== void 0) {
1915
+ if (obj["group_by"] === void 0 && typeof timeVal === "string") {
1916
+ const lower = timeVal.toLowerCase();
1917
+ obj["group_by"] = ["day", "week", "month"].includes(lower) ? lower : "month";
1918
+ }
1919
+ delete obj["time"];
1920
+ delete obj["timeframe"];
1921
+ delete obj["period"];
1922
+ }
1923
+ }
1924
+ if ((methodName.includes("get_cross_project_insights") || methodName.includes("getCrossProjectInsights")) && obj["limit"] !== void 0) {
1925
+ return validationErr("get_cross_project_insights does not accept a limit parameter. It analyzes all projects.", "Remove the limit parameter.");
1926
+ }
1927
+ }
1928
+ const ghBkRes = applyGithubAndBackupInterceptions(methodName, args);
1929
+ if ("error" in ghBkRes) return ghBkRes;
1930
+ args = ghBkRes.args;
1931
+ return applyMiscToolInterceptions(methodName, args);
1932
+ }
1933
+ function applyIoInterceptions(methodName, rawObj) {
1934
+ const obj = { ...rawObj };
1935
+ remapKeys(obj, ["keep"], "limit");
1936
+ if (hasAnyKey(obj, ["q", "query", "text", "search", "message", "description"])) {
1937
+ return validationErr(
1938
+ `${methodName} does not support text search or content parameters. It only exports/imports data.`,
1939
+ "To search for specific text, use search_entries (or team_search). Otherwise, remove the search/content parameters."
1940
+ );
1941
+ }
1942
+ if (obj["mode"] !== void 0) {
1943
+ return validationErr(`${methodName} does not support the 'mode' parameter.`, "Remove the mode parameter.");
1944
+ }
1945
+ if (["export_entries", "exportEntries", "team_export_entries", "teamExportEntries"].includes(methodName)) {
1946
+ if (hasAnyKey(obj, ["path", "output_dir", "file"])) {
1947
+ return validationErr(
1948
+ "export_entries returns the exported data directly and does not write to disk.",
1949
+ "Use export_markdown if you want to save files to a directory, or remove path/output_dir."
1950
+ );
1951
+ }
1952
+ }
1953
+ const isExportMd = methodName.includes("export_markdown") || methodName.includes("exportMarkdown") || methodName.includes("teamExportMarkdown") || methodName.includes("team_export_markdown");
1954
+ const isExternal = methodName.includes("import_external") || methodName.includes("importExternal") || methodName.includes("teamImportExternal") || methodName.includes("team_import_external");
1955
+ for (const key of ["path", "file", "filepath", "dir", "folder", "target", "source"]) {
1956
+ if (obj[key] !== void 0) {
1957
+ let didMap = false;
1958
+ if (isExportMd) {
1959
+ if (obj["output_dir"] === void 0) obj["output_dir"] = obj[key];
1960
+ didMap = true;
1961
+ } else if (methodName.toLowerCase().includes("import") && !(key === "source" && isExternal)) {
1962
+ if (obj["source_dir"] === void 0) obj["source_dir"] = obj[key];
1963
+ didMap = true;
1964
+ }
1965
+ if (didMap) Reflect.deleteProperty(obj, key);
1966
+ }
1967
+ }
1968
+ if (isExternal) {
1969
+ if (obj["url"] !== void 0 || obj["link"] !== void 0) {
1970
+ return validationErr(
1971
+ "import_external does not download from URLs. It imports from a local directory (source_dir).",
1972
+ "Provide a local directory path in source_dir."
1973
+ );
1974
+ }
1975
+ remapKeys(obj, ["format", "source"], "source_format");
1976
+ }
1977
+ return { obj };
1978
+ }
1979
+ function applyMiscToolInterceptions(methodName, args) {
1980
+ if (["link_entries", "linkEntries", "team_link_entries", "teamLinkEntries"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1981
+ const obj = { ...args[0] };
1982
+ args[0] = obj;
1983
+ remapKeys(obj, ["source", "from", "source_id", "from_id"], "from_entry_id");
1984
+ remapKeys(obj, ["target", "to", "target_id", "to_id", "dest"], "to_entry_id");
1985
+ remapKeys(obj, ["type", "rel"], "relationship_type");
1986
+ remapKeys(obj, ["notes", "message", "text"], "description");
1987
+ }
1988
+ if (["get_recent_entries", "getRecentEntries", "team_get_recent", "teamGetRecent"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
1989
+ const obj = { ...args[0] };
1990
+ args[0] = obj;
1991
+ if (hasAnyKey(obj, ["q", "query", "search"])) {
1992
+ return validationErr(
1993
+ `${methodName} does not support search queries. It only returns the most recent entries.`,
1994
+ "To search for specific text, use team_search (or search_entries) instead."
1995
+ );
1996
+ }
1997
+ remapKeys(obj, ["keep"], "limit");
1998
+ }
1999
+ if (["list_tags", "listTags", "team_list_tags", "teamListTags"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
2000
+ const obj = { ...args[0] };
2001
+ args[0] = obj;
2002
+ if (hasAnyKey(obj, ["q", "query", "search", "path", "mode", "keep"])) {
2003
+ return validationErr(`${methodName} does not support search queries, path, mode, or keep. It returns all tags.`, "Remove these parameters.");
2004
+ }
2005
+ }
2006
+ if (["test_simple", "testSimple", "test_error_handling", "testErrorHandling"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
2007
+ const obj = { ...args[0] };
2008
+ args[0] = obj;
2009
+ remapKeys(obj, ["text", "description"], "message");
2010
+ if (methodName === "test_error_handling" || methodName === "testErrorHandling") {
2011
+ remapKeys(obj, ["type"], "error_type");
2012
+ }
2013
+ }
2014
+ if (["merge_tags", "mergeTags", "team_merge_tags", "teamMergeTags"].includes(methodName) && args.length === 1 && isRecord(args[0])) {
2015
+ const obj = { ...args[0] };
2016
+ args[0] = obj;
2017
+ if (obj["source_tags"] !== void 0 && obj["source_tag"] === void 0) {
2018
+ obj["source_tag"] = Array.isArray(obj["source_tags"]) ? obj["source_tags"][0] : obj["source_tags"];
2019
+ delete obj["source_tags"];
2020
+ }
2021
+ remapKeys(obj, ["old_tag", "from"], "source_tag");
2022
+ remapKeys(obj, ["new_tag", "to"], "target_tag");
2023
+ if (typeof obj["source_tag"] === "string" && obj["source_tag"].includes(",")) {
2024
+ return validationErr(
2025
+ "merge_tags only accepts a single source_tag string, not a comma-separated list.",
2026
+ "Provide a single tag string for source_tag. To merge multiple tags, call this tool multiple times."
2027
+ );
2028
+ }
2029
+ }
2030
+ if ((methodName === "search_audit_log" || methodName === "searchAuditLog") && args.length === 1 && isRecord(args[0])) {
2031
+ const obj = { ...args[0] };
2032
+ args[0] = obj;
2033
+ remapKeys(obj, ["keep"], "limit");
2034
+ if (typeof obj["limit"] === "string") {
2035
+ const parsed = parseInt(obj["limit"], 10);
2036
+ if (!isNaN(parsed)) obj["limit"] = parsed;
2037
+ }
2038
+ }
2039
+ if ([
2040
+ "team_add_member",
2041
+ "teamAddMember",
2042
+ "team_update_member_role",
2043
+ "teamUpdateMemberRole",
2044
+ "team_remove_member",
2045
+ "teamRemoveMember",
2046
+ "team_get_member",
2047
+ "teamGetMember"
2048
+ ].includes(methodName) && args.length === 1 && isRecord(args[0])) {
2049
+ const obj = { ...args[0] };
2050
+ args[0] = obj;
2051
+ remapKeys(obj, ["path", "target", "user", "name", "account", "username", "member"], "author");
2052
+ remapKeys(obj, ["keep", "mode", "type", "level", "permission"], "role");
2053
+ }
2054
+ if ([
2055
+ "team_add_author_alias",
2056
+ "teamAddAuthorAlias",
2057
+ "team_remove_author_alias",
2058
+ "teamRemoveAuthorAlias",
2059
+ "team_list_author_aliases",
2060
+ "teamListAuthorAliases",
2061
+ "team_resolve_author",
2062
+ "teamResolveAuthor",
2063
+ "team_consolidate_authors",
2064
+ "teamConsolidateAuthors"
2065
+ ].includes(methodName) && args.length === 1 && isRecord(args[0])) {
2066
+ const obj = { ...args[0] };
2067
+ args[0] = obj;
2068
+ for (const key of ["q", "query", "search"]) {
2069
+ if (obj[key] !== void 0) {
2070
+ if (obj["canonical_author"] === void 0 && obj["author"] === void 0 && obj["alias"] === void 0) {
2071
+ obj["canonical_author"] = obj[key];
2072
+ obj["author"] = obj[key];
2073
+ obj["alias"] = obj[key];
2074
+ }
2075
+ Reflect.deleteProperty(obj, key);
2076
+ }
2077
+ }
2078
+ remapKeys(obj, ["text", "message", "description", "name", "from", "source"], "alias");
2079
+ remapKeys(obj, ["target", "to", "canonical", "dest"], "canonical_author");
2080
+ if (obj["author"] !== void 0 && obj["canonical_author"] === void 0 && obj["alias"] === void 0) {
2081
+ obj["canonical_author"] = obj["author"];
2082
+ }
2083
+ }
2084
+ return { args };
2085
+ }
2086
+
2087
+ // src/codemode/param-normalizer.ts
2088
+ function applyArgInterceptions(methodName, args) {
2089
+ const gitIntercept = applyGitInterceptions(methodName, args);
2090
+ if (gitIntercept) return gitIntercept;
2091
+ const genericRes = applyGenericInterceptions(methodName, args);
2092
+ if ("error" in genericRes) return genericRes;
2093
+ let currentArgs = genericRes.args;
2094
+ const domainRes = applyDomainToolInterceptions(methodName, currentArgs);
2095
+ if ("error" in domainRes) return domainRes;
2096
+ currentArgs = domainRes.args;
2097
+ const entrySearchRes = applyEntryAndSearchInterceptions(methodName, currentArgs);
2098
+ if ("error" in entrySearchRes) return entrySearchRes;
2099
+ return entrySearchRes;
2100
+ }
2101
+
2102
+ export { ENTRY_TYPE_ALIASES, GROUP_EXAMPLES, GROUP_PREFIX_MAP, KEEP_PREFIX_GROUPS, METHOD_ALIASES, PARAM_ALIASES, POSITIONAL_PARAM_MAP, TAG_ALIASES, VERSION, applyArgInterceptions, healAutoContext, healSessionSummaryContent, isRecord, safeString };