@nxuss/lemma 1.37.0 → 1.39.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 (284) hide show
  1. package/README.md +9 -6
  2. package/bin/brain-ingest.js +86 -27
  3. package/bin/doctor.js +31 -4
  4. package/bin/init.js +98 -60
  5. package/dashboard/dist/assets/index-DNTQXLER.css +1 -0
  6. package/dashboard/dist/assets/index-DzL_Zu3m.js +452 -0
  7. package/dashboard/dist/index.html +2 -2
  8. package/dist/cjs/cli/gitHooks.d.ts +9 -2
  9. package/dist/cjs/cli/gitHooks.d.ts.map +1 -1
  10. package/dist/cjs/cli/gitHooks.js +31 -4
  11. package/dist/cjs/cli/gitHooks.js.map +1 -1
  12. package/dist/cjs/cli/hostHooks.d.ts +13 -1
  13. package/dist/cjs/cli/hostHooks.d.ts.map +1 -1
  14. package/dist/cjs/cli/hostHooks.js +34 -4
  15. package/dist/cjs/cli/hostHooks.js.map +1 -1
  16. package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
  17. package/dist/cjs/cli/lemma-proxy.js +42 -5
  18. package/dist/cjs/cli/lemma-proxy.js.map +1 -1
  19. package/dist/cjs/infra/analyzers/index.d.ts +0 -2
  20. package/dist/cjs/infra/analyzers/index.d.ts.map +1 -1
  21. package/dist/cjs/infra/analyzers/index.js +1 -6
  22. package/dist/cjs/infra/analyzers/index.js.map +1 -1
  23. package/dist/cjs/infra/cli.d.ts +4 -0
  24. package/dist/cjs/infra/cli.d.ts.map +1 -1
  25. package/dist/cjs/infra/cli.js +6 -199
  26. package/dist/cjs/infra/cli.js.map +1 -1
  27. package/dist/cjs/infra/index.d.ts +1 -3
  28. package/dist/cjs/infra/index.d.ts.map +1 -1
  29. package/dist/cjs/infra/index.js +1 -16
  30. package/dist/cjs/infra/index.js.map +1 -1
  31. package/dist/cjs/infra/mcp-tools.d.ts.map +1 -1
  32. package/dist/cjs/infra/mcp-tools.js +8 -453
  33. package/dist/cjs/infra/mcp-tools.js.map +1 -1
  34. package/dist/cjs/infra/types.d.ts +0 -101
  35. package/dist/cjs/infra/types.d.ts.map +1 -1
  36. package/dist/cjs/infra/types.js +2 -1
  37. package/dist/cjs/infra/types.js.map +1 -1
  38. package/dist/cjs/mcp/index.js +33 -10
  39. package/dist/cjs/mcp/index.js.map +1 -1
  40. package/dist/cjs/mcp/prompts.d.ts +1 -1
  41. package/dist/cjs/mcp/prompts.d.ts.map +1 -1
  42. package/dist/cjs/mcp/prompts.js +8 -21
  43. package/dist/cjs/mcp/prompts.js.map +1 -1
  44. package/dist/cjs/mcp/tool-profiles.d.ts +8 -3
  45. package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
  46. package/dist/cjs/mcp/tool-profiles.js +25 -54
  47. package/dist/cjs/mcp/tool-profiles.js.map +1 -1
  48. package/dist/cjs/mcp/tools/memory.d.ts +8 -0
  49. package/dist/cjs/mcp/tools/memory.d.ts.map +1 -1
  50. package/dist/cjs/mcp/tools/memory.js +154 -125
  51. package/dist/cjs/mcp/tools/memory.js.map +1 -1
  52. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  53. package/dist/cjs/mcp/tools.js +11 -6
  54. package/dist/cjs/mcp/tools.js.map +1 -1
  55. package/dist/cjs/mcp/workspaceShared.d.ts.map +1 -1
  56. package/dist/cjs/mcp/workspaceShared.js +13 -12
  57. package/dist/cjs/mcp/workspaceShared.js.map +1 -1
  58. package/dist/cjs/proxy/ProjectRegistry.d.ts +44 -0
  59. package/dist/cjs/proxy/ProjectRegistry.d.ts.map +1 -1
  60. package/dist/cjs/proxy/ProjectRegistry.js +92 -3
  61. package/dist/cjs/proxy/ProjectRegistry.js.map +1 -1
  62. package/dist/cjs/subconscious/HostRecall.d.ts +36 -3
  63. package/dist/cjs/subconscious/HostRecall.d.ts.map +1 -1
  64. package/dist/cjs/subconscious/HostRecall.js +164 -37
  65. package/dist/cjs/subconscious/HostRecall.js.map +1 -1
  66. package/dist/cjs/subconscious/NarrowEvidence.d.ts +47 -0
  67. package/dist/cjs/subconscious/NarrowEvidence.d.ts.map +1 -0
  68. package/dist/cjs/subconscious/NarrowEvidence.js +252 -0
  69. package/dist/cjs/subconscious/NarrowEvidence.js.map +1 -0
  70. package/dist/cjs/subconscious/TheBrainV2.d.ts +37 -0
  71. package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
  72. package/dist/cjs/subconscious/TheBrainV2.js +147 -15
  73. package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
  74. package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts.map +1 -1
  75. package/dist/cjs/subconscious/freshness/LocalFsResolver.js +17 -0
  76. package/dist/cjs/subconscious/freshness/LocalFsResolver.js.map +1 -1
  77. package/dist/cjs/subconscious/recallDigest.d.ts +42 -0
  78. package/dist/cjs/subconscious/recallDigest.d.ts.map +1 -0
  79. package/dist/cjs/subconscious/recallDigest.js +94 -0
  80. package/dist/cjs/subconscious/recallDigest.js.map +1 -0
  81. package/dist/cjs/utils/OtherLanguageSymbols.d.ts +31 -0
  82. package/dist/cjs/utils/OtherLanguageSymbols.d.ts.map +1 -0
  83. package/dist/cjs/utils/OtherLanguageSymbols.js +283 -0
  84. package/dist/cjs/utils/OtherLanguageSymbols.js.map +1 -0
  85. package/dist/cjs/utils/SavingsLedger.d.ts +27 -0
  86. package/dist/cjs/utils/SavingsLedger.d.ts.map +1 -1
  87. package/dist/cjs/utils/SavingsLedger.js +51 -0
  88. package/dist/cjs/utils/SavingsLedger.js.map +1 -1
  89. package/dist/cjs/utils/StoreDraft.d.ts +12 -0
  90. package/dist/cjs/utils/StoreDraft.d.ts.map +1 -1
  91. package/dist/cjs/utils/StoreDraft.js +53 -1
  92. package/dist/cjs/utils/StoreDraft.js.map +1 -1
  93. package/dist/cjs/utils/SymbolSurgicalContext.d.ts +2 -0
  94. package/dist/cjs/utils/SymbolSurgicalContext.d.ts.map +1 -1
  95. package/dist/cjs/utils/SymbolSurgicalContext.js +1 -0
  96. package/dist/cjs/utils/SymbolSurgicalContext.js.map +1 -1
  97. package/dist/cjs/utils/reportSavings.d.ts +17 -4
  98. package/dist/cjs/utils/reportSavings.d.ts.map +1 -1
  99. package/dist/cjs/utils/reportSavings.js +67 -22
  100. package/dist/cjs/utils/reportSavings.js.map +1 -1
  101. package/dist/esm/cli/gitHooks.d.ts +9 -2
  102. package/dist/esm/cli/gitHooks.d.ts.map +1 -1
  103. package/dist/esm/cli/gitHooks.js +31 -4
  104. package/dist/esm/cli/gitHooks.js.map +1 -1
  105. package/dist/esm/cli/hostHooks.d.ts +13 -1
  106. package/dist/esm/cli/hostHooks.d.ts.map +1 -1
  107. package/dist/esm/cli/hostHooks.js +32 -3
  108. package/dist/esm/cli/hostHooks.js.map +1 -1
  109. package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
  110. package/dist/esm/cli/lemma-proxy.js +42 -5
  111. package/dist/esm/cli/lemma-proxy.js.map +1 -1
  112. package/dist/esm/infra/analyzers/index.d.ts +0 -2
  113. package/dist/esm/infra/analyzers/index.d.ts.map +1 -1
  114. package/dist/esm/infra/analyzers/index.js +0 -2
  115. package/dist/esm/infra/analyzers/index.js.map +1 -1
  116. package/dist/esm/infra/cli.d.ts +4 -0
  117. package/dist/esm/infra/cli.d.ts.map +1 -1
  118. package/dist/esm/infra/cli.js +6 -199
  119. package/dist/esm/infra/cli.js.map +1 -1
  120. package/dist/esm/infra/index.d.ts +1 -3
  121. package/dist/esm/infra/index.d.ts.map +1 -1
  122. package/dist/esm/infra/index.js +1 -3
  123. package/dist/esm/infra/index.js.map +1 -1
  124. package/dist/esm/infra/mcp-tools.d.ts.map +1 -1
  125. package/dist/esm/infra/mcp-tools.js +9 -454
  126. package/dist/esm/infra/mcp-tools.js.map +1 -1
  127. package/dist/esm/infra/types.d.ts +0 -101
  128. package/dist/esm/infra/types.d.ts.map +1 -1
  129. package/dist/esm/infra/types.js +2 -1
  130. package/dist/esm/infra/types.js.map +1 -1
  131. package/dist/esm/mcp/index.js +33 -10
  132. package/dist/esm/mcp/index.js.map +1 -1
  133. package/dist/esm/mcp/prompts.d.ts +1 -1
  134. package/dist/esm/mcp/prompts.d.ts.map +1 -1
  135. package/dist/esm/mcp/prompts.js +8 -21
  136. package/dist/esm/mcp/prompts.js.map +1 -1
  137. package/dist/esm/mcp/tool-profiles.d.ts +8 -3
  138. package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
  139. package/dist/esm/mcp/tool-profiles.js +25 -54
  140. package/dist/esm/mcp/tool-profiles.js.map +1 -1
  141. package/dist/esm/mcp/tools/memory.d.ts +8 -0
  142. package/dist/esm/mcp/tools/memory.d.ts.map +1 -1
  143. package/dist/esm/mcp/tools/memory.js +156 -128
  144. package/dist/esm/mcp/tools/memory.js.map +1 -1
  145. package/dist/esm/mcp/tools.d.ts.map +1 -1
  146. package/dist/esm/mcp/tools.js +12 -7
  147. package/dist/esm/mcp/tools.js.map +1 -1
  148. package/dist/esm/mcp/workspaceShared.d.ts.map +1 -1
  149. package/dist/esm/mcp/workspaceShared.js +13 -12
  150. package/dist/esm/mcp/workspaceShared.js.map +1 -1
  151. package/dist/esm/proxy/ProjectRegistry.d.ts +44 -0
  152. package/dist/esm/proxy/ProjectRegistry.d.ts.map +1 -1
  153. package/dist/esm/proxy/ProjectRegistry.js +91 -2
  154. package/dist/esm/proxy/ProjectRegistry.js.map +1 -1
  155. package/dist/esm/subconscious/HostRecall.d.ts +36 -3
  156. package/dist/esm/subconscious/HostRecall.d.ts.map +1 -1
  157. package/dist/esm/subconscious/HostRecall.js +159 -36
  158. package/dist/esm/subconscious/HostRecall.js.map +1 -1
  159. package/dist/esm/subconscious/NarrowEvidence.d.ts +47 -0
  160. package/dist/esm/subconscious/NarrowEvidence.d.ts.map +1 -0
  161. package/dist/esm/subconscious/NarrowEvidence.js +211 -0
  162. package/dist/esm/subconscious/NarrowEvidence.js.map +1 -0
  163. package/dist/esm/subconscious/TheBrainV2.d.ts +37 -0
  164. package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
  165. package/dist/esm/subconscious/TheBrainV2.js +146 -14
  166. package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
  167. package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts.map +1 -1
  168. package/dist/esm/subconscious/freshness/LocalFsResolver.js +17 -0
  169. package/dist/esm/subconscious/freshness/LocalFsResolver.js.map +1 -1
  170. package/dist/esm/subconscious/recallDigest.d.ts +42 -0
  171. package/dist/esm/subconscious/recallDigest.d.ts.map +1 -0
  172. package/dist/esm/subconscious/recallDigest.js +87 -0
  173. package/dist/esm/subconscious/recallDigest.js.map +1 -0
  174. package/dist/esm/utils/OtherLanguageSymbols.d.ts +31 -0
  175. package/dist/esm/utils/OtherLanguageSymbols.d.ts.map +1 -0
  176. package/dist/esm/utils/OtherLanguageSymbols.js +275 -0
  177. package/dist/esm/utils/OtherLanguageSymbols.js.map +1 -0
  178. package/dist/esm/utils/SavingsLedger.d.ts +27 -0
  179. package/dist/esm/utils/SavingsLedger.d.ts.map +1 -1
  180. package/dist/esm/utils/SavingsLedger.js +51 -0
  181. package/dist/esm/utils/SavingsLedger.js.map +1 -1
  182. package/dist/esm/utils/StoreDraft.d.ts +12 -0
  183. package/dist/esm/utils/StoreDraft.d.ts.map +1 -1
  184. package/dist/esm/utils/StoreDraft.js +52 -1
  185. package/dist/esm/utils/StoreDraft.js.map +1 -1
  186. package/dist/esm/utils/SymbolSurgicalContext.d.ts +2 -0
  187. package/dist/esm/utils/SymbolSurgicalContext.d.ts.map +1 -1
  188. package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
  189. package/dist/esm/utils/SymbolSurgicalContext.js.map +1 -1
  190. package/dist/esm/utils/reportSavings.d.ts +17 -4
  191. package/dist/esm/utils/reportSavings.d.ts.map +1 -1
  192. package/dist/esm/utils/reportSavings.js +65 -22
  193. package/dist/esm/utils/reportSavings.js.map +1 -1
  194. package/package.json +2 -1
  195. package/dashboard/dist/assets/index-BoeQau6n.css +0 -1
  196. package/dashboard/dist/assets/index-Clf3qR64.js +0 -451
  197. package/dist/cjs/infra/analyzers/DriftDetector.d.ts +0 -4
  198. package/dist/cjs/infra/analyzers/DriftDetector.d.ts.map +0 -1
  199. package/dist/cjs/infra/analyzers/DriftDetector.js +0 -88
  200. package/dist/cjs/infra/analyzers/DriftDetector.js.map +0 -1
  201. package/dist/cjs/infra/analyzers/InfraAnalyzer.d.ts +0 -3
  202. package/dist/cjs/infra/analyzers/InfraAnalyzer.d.ts.map +0 -1
  203. package/dist/cjs/infra/analyzers/InfraAnalyzer.js +0 -73
  204. package/dist/cjs/infra/analyzers/InfraAnalyzer.js.map +0 -1
  205. package/dist/cjs/infra/config.d.ts +0 -17
  206. package/dist/cjs/infra/config.d.ts.map +0 -1
  207. package/dist/cjs/infra/config.js +0 -111
  208. package/dist/cjs/infra/config.js.map +0 -1
  209. package/dist/cjs/infra/errorCause.d.ts +0 -36
  210. package/dist/cjs/infra/errorCause.d.ts.map +0 -1
  211. package/dist/cjs/infra/errorCause.js +0 -143
  212. package/dist/cjs/infra/errorCause.js.map +0 -1
  213. package/dist/cjs/infra/providers/InfraProvider.d.ts +0 -9
  214. package/dist/cjs/infra/providers/InfraProvider.d.ts.map +0 -1
  215. package/dist/cjs/infra/providers/InfraProvider.js +0 -3
  216. package/dist/cjs/infra/providers/InfraProvider.js.map +0 -1
  217. package/dist/cjs/infra/providers/JenkinsProvider.d.ts +0 -16
  218. package/dist/cjs/infra/providers/JenkinsProvider.d.ts.map +0 -1
  219. package/dist/cjs/infra/providers/JenkinsProvider.js +0 -193
  220. package/dist/cjs/infra/providers/JenkinsProvider.js.map +0 -1
  221. package/dist/cjs/infra/providers/OKDProvider.d.ts +0 -24
  222. package/dist/cjs/infra/providers/OKDProvider.d.ts.map +0 -1
  223. package/dist/cjs/infra/providers/OKDProvider.js +0 -296
  224. package/dist/cjs/infra/providers/OKDProvider.js.map +0 -1
  225. package/dist/cjs/infra/providers/TerraformProvider.d.ts +0 -17
  226. package/dist/cjs/infra/providers/TerraformProvider.d.ts.map +0 -1
  227. package/dist/cjs/infra/providers/TerraformProvider.js +0 -111
  228. package/dist/cjs/infra/providers/TerraformProvider.js.map +0 -1
  229. package/dist/cjs/infra/providers/index.d.ts +0 -9
  230. package/dist/cjs/infra/providers/index.d.ts.map +0 -1
  231. package/dist/cjs/infra/providers/index.js +0 -34
  232. package/dist/cjs/infra/providers/index.js.map +0 -1
  233. package/dist/cjs/infra/templates/jenkins/index.d.ts +0 -15
  234. package/dist/cjs/infra/templates/jenkins/index.d.ts.map +0 -1
  235. package/dist/cjs/infra/templates/jenkins/index.js +0 -128
  236. package/dist/cjs/infra/templates/jenkins/index.js.map +0 -1
  237. package/dist/cjs/infra/templates/okd/index.d.ts +0 -31
  238. package/dist/cjs/infra/templates/okd/index.d.ts.map +0 -1
  239. package/dist/cjs/infra/templates/okd/index.js +0 -149
  240. package/dist/cjs/infra/templates/okd/index.js.map +0 -1
  241. package/dist/esm/infra/analyzers/DriftDetector.d.ts +0 -4
  242. package/dist/esm/infra/analyzers/DriftDetector.d.ts.map +0 -1
  243. package/dist/esm/infra/analyzers/DriftDetector.js +0 -84
  244. package/dist/esm/infra/analyzers/DriftDetector.js.map +0 -1
  245. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +0 -3
  246. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts.map +0 -1
  247. package/dist/esm/infra/analyzers/InfraAnalyzer.js +0 -70
  248. package/dist/esm/infra/analyzers/InfraAnalyzer.js.map +0 -1
  249. package/dist/esm/infra/config.d.ts +0 -17
  250. package/dist/esm/infra/config.d.ts.map +0 -1
  251. package/dist/esm/infra/config.js +0 -101
  252. package/dist/esm/infra/config.js.map +0 -1
  253. package/dist/esm/infra/errorCause.d.ts +0 -36
  254. package/dist/esm/infra/errorCause.d.ts.map +0 -1
  255. package/dist/esm/infra/errorCause.js +0 -138
  256. package/dist/esm/infra/errorCause.js.map +0 -1
  257. package/dist/esm/infra/providers/InfraProvider.d.ts +0 -9
  258. package/dist/esm/infra/providers/InfraProvider.d.ts.map +0 -1
  259. package/dist/esm/infra/providers/InfraProvider.js +0 -2
  260. package/dist/esm/infra/providers/InfraProvider.js.map +0 -1
  261. package/dist/esm/infra/providers/JenkinsProvider.d.ts +0 -16
  262. package/dist/esm/infra/providers/JenkinsProvider.d.ts.map +0 -1
  263. package/dist/esm/infra/providers/JenkinsProvider.js +0 -186
  264. package/dist/esm/infra/providers/JenkinsProvider.js.map +0 -1
  265. package/dist/esm/infra/providers/OKDProvider.d.ts +0 -24
  266. package/dist/esm/infra/providers/OKDProvider.d.ts.map +0 -1
  267. package/dist/esm/infra/providers/OKDProvider.js +0 -292
  268. package/dist/esm/infra/providers/OKDProvider.js.map +0 -1
  269. package/dist/esm/infra/providers/TerraformProvider.d.ts +0 -17
  270. package/dist/esm/infra/providers/TerraformProvider.d.ts.map +0 -1
  271. package/dist/esm/infra/providers/TerraformProvider.js +0 -107
  272. package/dist/esm/infra/providers/TerraformProvider.js.map +0 -1
  273. package/dist/esm/infra/providers/index.d.ts +0 -9
  274. package/dist/esm/infra/providers/index.d.ts.map +0 -1
  275. package/dist/esm/infra/providers/index.js +0 -27
  276. package/dist/esm/infra/providers/index.js.map +0 -1
  277. package/dist/esm/infra/templates/jenkins/index.d.ts +0 -15
  278. package/dist/esm/infra/templates/jenkins/index.d.ts.map +0 -1
  279. package/dist/esm/infra/templates/jenkins/index.js +0 -124
  280. package/dist/esm/infra/templates/jenkins/index.js.map +0 -1
  281. package/dist/esm/infra/templates/okd/index.d.ts +0 -31
  282. package/dist/esm/infra/templates/okd/index.d.ts.map +0 -1
  283. package/dist/esm/infra/templates/okd/index.js +0 -142
  284. package/dist/esm/infra/templates/okd/index.js.map +0 -1
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MEMORY_TOOL_HANDLERS = exports.MEMORY_TOOL_DEFINITIONS = void 0;
13
+ exports.looksLikeLogbook = looksLikeLogbook;
13
14
  const fs_1 = __importDefault(require("fs"));
14
15
  const path_1 = __importDefault(require("path"));
15
16
  const TheBrainV2_1 = require("../../subconscious/TheBrainV2");
@@ -19,7 +20,7 @@ const TokenReceipt_1 = require("../../utils/TokenReceipt");
19
20
  const utils_1 = require("../utils");
20
21
  const cognitiveMap_1 = require("../cognitiveMap");
21
22
  const SessionEvidence_1 = require("../../utils/SessionEvidence");
22
- const NearMiss_1 = require("../../subconscious/NearMiss");
23
+ const NarrowEvidence_1 = require("../../subconscious/NarrowEvidence");
23
24
  const ageLabel_1 = require("../../utils/ageLabel");
24
25
  const ExternalRefs_1 = require("../../subconscious/ExternalRefs");
25
26
  const TeamBrain_1 = require("../../subconscious/TeamBrain");
@@ -47,7 +48,7 @@ exports.MEMORY_TOOL_DEFINITIONS = [
47
48
  {
48
49
  name: "search_memory",
49
50
  annotations: { readOnlyHint: true, openWorldHint: false },
50
- description: "Search Lemma's semantic memory (The Brain) before investigating something from scratch — retrieves past solutions, fixes, and context from ALL your projects globally. Results split into 'fresh' (safe to reuse) and 'stale' (a tracked file changed since — re-verify before reusing). Never treat a stale result as current. If a returned memory turns out wrong once acted on, call downvote_memory with its id.",
51
+ description: "Search the Brain before investigating something from scratch: past fixes, traps, failed approaches and decisions from earlier sessions. Returns a ranked shortlist (headline, excerpt, fresh/STALE) — pick the one that answers your question and get_memory it for the body. Never treat a STALE result as current.",
51
52
  inputSchema: {
52
53
  type: "object",
53
54
  properties: {
@@ -55,8 +56,8 @@ exports.MEMORY_TOOL_DEFINITIONS = [
55
56
  limit: { type: "number", description: "Maximum results to return", default: 5 },
56
57
  minSimilarity: {
57
58
  type: "number",
58
- description: "Similarity floor (0.0-1.0) a memory must clear to be returned. Lowering this surfaces loosely related memories that are usually noise — leave it alone unless a known-relevant memory is being filtered out.",
59
- default: 0.75,
59
+ description: "Optional floor (0-1) on the ranking score. Off by default: the score ranks well but does not separate relevant from unrelated.",
60
+ default: 0,
60
61
  },
61
62
  domain: {
62
63
  type: "string",
@@ -64,7 +65,12 @@ exports.MEMORY_TOOL_DEFINITIONS = [
64
65
  },
65
66
  semanticDiff: {
66
67
  type: "boolean",
67
- description: "Don't count a comment/whitespace-only change as stale.",
68
+ description: "Don't count a comment/whitespace-only change as stale (default). Pass false to treat any edit to the tracked code as a change.",
69
+ default: true,
70
+ },
71
+ allProjects: {
72
+ type: "boolean",
73
+ description: "Also search memories from your other projects (labelled as such). Off by default: they may be confidential and rarely apply here.",
68
74
  default: false,
69
75
  },
70
76
  },
@@ -91,7 +97,7 @@ exports.MEMORY_TOOL_DEFINITIONS = [
91
97
  {
92
98
  name: "store_memory",
93
99
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
94
- description: "Save a verified solution, fix, decision or fact to the Brain so it needn't be re-investigated. Pass filePaths (or `symbols` for one function/class) so it goes stale when that code changes; if both are omitted, Lemma guesses from the files this session touched and flags it as a guess. outcome='failed' records a dead end. To correct or extend an existing memory use update_memory — storing a revision here creates a second entry and searches return a mix of both.",
100
+ description: "Save a verified fix, decision or fact so it needn't be re-investigated: what code and git can't tell the next session (root cause, trap, failed approach, how-to), not a log of what shipped. Pass filePaths (or `symbols`) so it goes stale when that code changes; omitted, Lemma guesses from files this session touched. outcome='failed' records a dead end. To correct a memory use update_memory — a re-store here leaves both versions.",
95
101
  inputSchema: {
96
102
  type: "object",
97
103
  properties: {
@@ -212,8 +218,8 @@ exports.MEMORY_TOOL_DEFINITIONS = [
212
218
  ids: { type: "array", items: { type: "string" }, description: "Entry and/or claim ids to revalidate, from a prior search_memory/store_memory result." },
213
219
  semanticDiff: {
214
220
  type: "boolean",
215
- description: "Don't count a comment/whitespace-only change as stale.",
216
- default: false,
221
+ description: "Don't count a comment/whitespace-only change as stale (default). Pass false to treat any edit to the tracked code as a change.",
222
+ default: true,
217
223
  },
218
224
  },
219
225
  required: ["ids"],
@@ -369,142 +375,113 @@ exports.MEMORY_TOOL_DEFINITIONS = [
369
375
  },
370
376
  },
371
377
  ];
378
+ /**
379
+ * Ids the last search_memory calls put on a shortlist. A get_memory of one of them is the
380
+ * moment a memory was actually reused, so that is where its hit and its saving are booked —
381
+ * listing a headline saves nothing by itself.
382
+ */
383
+ const _shortlisted = new Set();
384
+ const SHORTLIST_MEMORY = 200;
385
+ const EXCERPT_CHARS = 180;
386
+ function excerpt(text) {
387
+ const flat = String(typeof text === "string" ? text : JSON.stringify(text)).replace(/\s+/g, " ").trim();
388
+ return flat.length > EXCERPT_CHARS ? `${flat.slice(0, EXCERPT_CHARS - 1)}…` : flat;
389
+ }
390
+ /**
391
+ * search_memory answers with a ranked shortlist, not a verdict.
392
+ *
393
+ * It used to return a memory only above a 0.75 similarity floor and otherwise said
394
+ * "Investigate from scratch — there is nothing safe to reuse". Measured on Lemma's own Brain
395
+ * (18 questions a later session would really ask), the right memory ranked first 15 times and
396
+ * in the top three every time — and cleared the floor zero times. The score can't carry a
397
+ * floor: BM25 is normalized against the best candidate *of the same search*, so the top result
398
+ * of an unrelated question scores 0.54–0.66, the same band as a correct one (0.56–0.73). The
399
+ * ranking is good; deciding relevance from headlines is something the agent does well. So the
400
+ * Brain shortlists and the agent picks, then reads the one that answers with get_memory.
401
+ */
372
402
  async function handleSearchMemory(args) {
373
- const query = args?.query;
374
- const limit = args?.limit || 5;
375
- // A floor of 0 returns the nearest neighbour no matter how unrelated it is, and the
376
- // formatting below then presents it as a reusable memory. Match smarter_cache's
377
- // threshold so both paths agree on what counts as a hit.
378
- const minSimilarity = typeof args?.minSimilarity === "number" ? args.minSimilarity : utils_1.DEFAULT_MEMORY_SIMILARITY_FLOOR;
403
+ const query = typeof args?.query === "string" ? args.query : "";
404
+ const limit = Math.min(Math.max(Math.floor(args?.limit || 5), 1), 10);
405
+ // Explicit floors are still honoured; by default nothing is cut, for the reason above.
406
+ const minSimilarity = typeof args?.minSimilarity === "number" ? args.minSimilarity : 0;
379
407
  const domain = typeof args?.domain === "string" && args.domain.trim() ? args.domain.trim() : undefined;
380
- const semanticDiff = args?.semanticDiff === true;
408
+ const semanticDiff = args?.semanticDiff !== false;
381
409
  if (!query)
382
410
  throw new Error("Query is required");
383
411
  try {
384
412
  const brain = (0, TheBrainV2_1.getBrain)();
385
- // searchHybrid is search() plus one boolean check unless LEMMA_BRAIN_EMBEDDINGS is set,
386
- // so this costs nothing by default and picks up the semantic re-rank when it is enabled.
387
- const results = await brain.searchHybrid(query, limit, minSimilarity, { projectId: (0, TheBrainV2_1.deriveProjectId)(), domain, semanticDiff });
388
- if (results.length === 0) {
389
- (0, TokenReceipt_1.recordReceiptEvent)("reasoning", query.substring(0, 100), {
390
- tool: "search_memory",
391
- reason: `no memory above the ${minSimilarity} similarity floor`,
392
- });
393
- // searchHybrid already filtered anything below minSimilarity out of `results`, so the
394
- // near-miss check needs its own uncapped lookup — countStats:false, this must not
395
- // register as a second miss on top of the one searchHybrid just counted.
396
- const uncapped = brain.search(query, ORIENTATION_LIMIT, 0, { projectId: (0, TheBrainV2_1.deriveProjectId)(), domain, countStats: false });
397
- const nearMiss = (0, NearMiss_1.bucketNearMiss)(uncapped[0] ? { id: uncapped[0].id, query: uncapped[0].query, similarity: uncapped[0].similarity } : undefined, minSimilarity);
398
- // A miss that says nothing cannot tell "nothing related" from "something related at 60%".
399
- // These are for orientation only: below the floor, never reusable, never credited.
400
- const related = uncapped
401
- .filter((r) => r.similarity >= ORIENTATION_MIN)
402
- .map((r) => ` - ${r.id} (${(r.similarity * 100).toFixed(0)}%, stored ${(0, ageLabel_1.ageLabel)(r.timestamp)}): ${r.query.substring(0, 100)}`);
403
- const orientation = related.length > 0
404
- ? `\n\nBelow the reuse floor, for orientation only (not cache hits — get_memory to read, then verify against current state before relying on any):\n${related.join("\n")}`
405
- : "";
413
+ // countStats:false — appearing on a shortlist is not a reuse; get_memory books that.
414
+ const projectId = (0, TheBrainV2_1.deriveProjectId)();
415
+ adoptOnce(brain, projectId);
416
+ const results = await brain.searchHybrid(query, limit, minSimilarity, {
417
+ projectId,
418
+ allProjects: args?.allProjects === true,
419
+ domain,
420
+ semanticDiff,
421
+ countStats: false,
422
+ });
423
+ if (results.length === 0 && (0, TheBrainV2_1.tokenize)(query).length === 0) {
406
424
  return {
407
- content: [{
408
- type: "text",
409
- text: `No memory in Lemma's Brain scored at or above the ${(minSimilarity * 100).toFixed(0)}% similarity floor for this query. Investigate from scratch — there is nothing safe to reuse.${nearMiss.hint ? ` ${nearMiss.hint}` : ""}${orientation}`,
410
- }],
425
+ content: [{ type: "text", text: "This query has no searchable words (only stop words or symbols). Search with the error text, a symbol or file name, or the words of the question." }],
411
426
  };
412
427
  }
413
- // An entry that tracks nothing reports `fresh: true` vacuously (checkEntryFreshness has
414
- // nothing to compare) — it must NOT land in the verified-fresh bucket, be credited as a
415
- // cache hit, or be told "from cache". It gets its own UNTRACKED bucket instead.
416
- const fresh = results.filter((r) => r.fresh && !r.untracked);
417
- const stale = results.filter((r) => !r.fresh);
418
- const untracked = results.filter((r) => r.fresh && r.untracked);
419
- const formatClaims = (r) => {
420
- if (!Array.isArray(r.claims) || r.claims.length === 0)
421
- return "";
422
- const lines = r.claims.map((c) => c.fresh
423
- ? ` ✓ fresh: ${c.text}`
424
- : ` ✗ STALE (${(c.staleFiles || []).join(", ")}): ${c.text}`);
425
- const staleCount = r.claims.filter((c) => !c.fresh).length;
426
- return `\nClaims (${r.claims.length - staleCount}/${r.claims.length} still fresh — trust only the ✓ ones):\n${lines.join("\n")}`;
427
- };
428
- const formatResult = (r, i) => `Result ${i + 1} (id: ${r.id}, Similarity: ${(r.similarity * 100).toFixed(1)}%, stored ${(0, ageLabel_1.ageLabel)(r.timestamp)})${r.outcome === "failed" ? "\n⚠️ TAGGED AS A FAILED ATTEMPT — this was tried before and did NOT work. Do not repeat it; treat this as a warning, not a suggestion." : ""}${typeof r.tokensSaved === "number" && r.tokensSaved > 0
429
- ? `\n💰 This memory has saved ${r.tokensSaved} tokens across ${r.hits || "?"} reuse(s) — prefer it over re-deriving.`
430
- : ""}\nPrompt: ${r.query.substring(0, 300)}...\nResponse: ${typeof r.response === "string" ? r.response : JSON.stringify(r.response, null, 2)}${formatClaims(r)}${Array.isArray(r.evidence) && r.evidence.length > 0
431
- ? `\nEvidence: ${r.evidence.map((e) => {
432
- const sep = e.lastIndexOf("::");
433
- return sep > 0 ? `${relLabel(e.substring(0, sep))}::${e.substring(sep + 2)}` : relLabel(e);
434
- }).join(", ")}`
435
- : ""}${Array.isArray(r.whyShown) && r.whyShown.length > 0
436
- ? `\nWhy shown: ${r.whyShown.join(" · ")}`
437
- : ""}${Array.isArray(r.cosmeticChanges) && r.cosmeticChanges.length > 0
438
- ? `\n(comment/whitespace-only change, ignored under semanticDiff: ${r.cosmeticChanges.join(", ")})`
439
- : ""}`;
440
- if (fresh.length > 0) {
441
- // Only a fresh hit (or an untracked, purely conceptual entry) counts as a real
442
- // avoided re-investigation — this is the only case worth crediting as savings.
443
- const bestFresh = fresh[0];
444
- const { net: tokensSaved } = (0, squeeze_cache_1.netTokensSaved)(Math.max(400, String(bestFresh.response).length), query);
445
- (0, reportSavings_1.reportSavings)({ source: "cache", tokens: tokensSaved, toolName: "search_memory", query: query.substring(0, 100) });
446
- // Attribute the saving to the memory itself: the per-entry ROI ledger lives on the
447
- // entry (persisted, merged, imported), booked on the same event as the ledger above
448
- // so the two can never disagree about whether a reuse happened.
449
- brain.creditSavings(bestFresh.id, tokensSaved);
450
- (0, TokenReceipt_1.recordReceiptEvent)("semantic_cache_hit", query.substring(0, 100), {
451
- tool: "search_memory",
452
- similarity: bestFresh.similarity,
453
- tokensSaved,
454
- memoryId: bestFresh.id,
455
- });
456
- }
457
- else if (untracked.length > 0) {
458
- (0, TokenReceipt_1.recordReceiptEvent)("reasoning", query.substring(0, 100), {
459
- tool: "search_memory",
460
- reason: `${untracked.length} similar but UNTRACKED — no evidence to verify, not credited as a cache hit`,
461
- });
462
- }
463
- else {
464
- (0, TokenReceipt_1.recordReceiptEvent)("reasoning", query.substring(0, 100), {
465
- tool: "search_memory",
466
- reason: `${stale.length} similar memory/memories found but all stale — must re-verify`,
467
- });
468
- }
469
- const parts = [];
470
- if (fresh.length > 0) {
471
- parts.push(`Lemma found ${fresh.length} fresh ${fresh.length === 1 ? "memory" : "memories"} (from cache — say so if you use this):\n\n${fresh.map(formatResult).join("\n\n---\n\n")}`);
472
- }
473
- if (untracked.length > 0) {
474
- const untrackedText = untracked
475
- .map((r, i) => formatResult(r, i))
476
- .join("\n\n---\n\n");
477
- parts.push(`⚠️ ${untracked.length} ${untracked.length === 1 ? "memory is" : "memories are"} similar but UNTRACKED — ${untracked.length === 1 ? "it tracks" : "they track"} no files or symbols, so nothing was verified against current code (${untracked.length === 1 ? "it is" : "they are"} vacuously "fresh": there was nothing to check). ${untracked.length === 1 ? "It may" : "They may"} describe state that no longer exists — treat as a hint, re-verify against the repo before acting on it, and use update_memory/refresh_memory with filePaths/symbols so it becomes verifiable next time:\n\n${untrackedText}`);
428
+ if (results.length === 0) {
429
+ const why = minSimilarity > 0
430
+ ? `scored at or above the ${minSimilarity} floor you set`
431
+ : "shares a term with this query — nothing was learned about it in an earlier session";
432
+ (0, TokenReceipt_1.recordReceiptEvent)("reasoning", query.substring(0, 100), { tool: "search_memory", reason: `no memory ${why}` });
433
+ return { content: [{ type: "text", text: `No memory in Lemma's Brain ${why}. Investigate from scratch.` }] };
478
434
  }
479
- if (stale.length > 0) {
480
- const staleText = stale
481
- .map((r, i) => {
482
- // "You are on a different branch" and "someone rewrote this function" are the same
483
- // hash mismatch and completely different situations for the reader: the first is
484
- // usually not a reason to distrust the memory at all.
485
- const cause = r.staleCause === "branch-changed"
486
- ? `\nNOTE: stored on branch \`${r.storedOnBranch}\`, you are on \`${(0, TheBrainV2_1.currentGitContext)().branch || "an unknown branch"}\`. The difference may be the branch switch rather than an edit — check before discarding this.`
435
+ for (const r of results)
436
+ _shortlisted.add(r.id);
437
+ while (_shortlisted.size > SHORTLIST_MEMORY)
438
+ _shortlisted.delete(_shortlisted.values().next().value);
439
+ void (0, reportSavings_1.reportRecall)({ projectPath: process.cwd(), trigger: "search", memoryIds: results.map((r) => r.id) });
440
+ (0, TokenReceipt_1.recordReceiptEvent)("reasoning", query.substring(0, 100), { tool: "search_memory", reason: `shortlisted ${results.length} memories` });
441
+ const line = (r, i) => {
442
+ const verdict = !r.fresh
443
+ ? r.staleCause === "branch-changed"
444
+ ? `STALE — stored on branch ${r.storedOnBranch}, you are on ${(0, TheBrainV2_1.currentGitContext)().branch || "another branch"}`
445
+ : `STALE — changed since: ${(r.staleFiles || []).map(relLabel).join(", ")}`
446
+ : r.untracked
447
+ ? "untracked — tracks no files, nothing to check it against"
448
+ : "fresh";
449
+ const failed = r.outcome === "failed" ? " ⚠️ FAILED APPROACH — tried before and did not work" : "";
450
+ const origin = r.scope === "other-project"
451
+ ? ` ⚠️ FROM ANOTHER PROJECT (${r.ownerProject}) — do not assume it applies here`
452
+ : r.scope === "unscoped"
453
+ ? " [stored before memories were scoped to a project — may not be from this one]"
487
454
  : "";
488
- return `${formatResult(r, i)}\nSTALE — changed since stored: ${r.staleFiles.join(", ")}${cause}`;
489
- })
490
- .join("\n\n---\n\n");
491
- parts.push(`${stale.length} more ${stale.length === 1 ? "memory is" : "memories are"} similar but STALE (underlying file(s) changed) — do not reuse verbatim, re-verify against current file state:\n\n${staleText}`);
492
- }
493
- return { content: [{ type: "text", text: parts.join("\n\n===\n\n") }] };
455
+ return `${i + 1}. ${r.id} (${(0, ageLabel_1.ageLabel)(r.timestamp)}, ${verdict})${failed}${origin}\n ${r.query.replace(/\s+/g, " ").slice(0, 160)}\n ${excerpt(r.response)}`;
456
+ };
457
+ const text = `Closest memories in Lemma's Brain, best match first. Ranking is lexical: the right memory is usually here, but so are unrelated ones that share words — judge each by its headline.\n\n` +
458
+ `${results.map(line).join("\n\n")}\n\n` +
459
+ `If one answers your question, get_memory <id> for the full body before relying on it (a STALE one must be re-checked against the current code; a FAILED one is a warning, not a suggestion). If none does, investigate from scratch. A memory that turns out wrong: downvote_memory or forget_memory it.`;
460
+ return { content: [{ type: "text", text }] };
494
461
  }
495
462
  catch (e) {
496
463
  (0, utils_1.logError)("search_memory", e);
497
464
  return { content: [{ type: "text", text: `Local Search failed: ${e.message}` }] };
498
465
  }
499
466
  }
467
+ /** Memories from before projects existed are adopted once per process, from the repo root. */
468
+ let _adopted = false;
469
+ function adoptOnce(brain, projectId) {
470
+ if (_adopted)
471
+ return;
472
+ _adopted = true;
473
+ try {
474
+ brain.adoptUnscopedByEvidence(projectId, process.cwd());
475
+ }
476
+ catch (e) {
477
+ (0, utils_1.logError)("adoptUnscopedByEvidence", e);
478
+ }
479
+ }
500
480
  /** Relative-to-cwd label for a tracked absolute path, matching how the Brain reports them. */
501
481
  function relLabel(abs) {
502
482
  const rel = path_1.default.relative(process.cwd(), abs);
503
483
  return rel.startsWith("..") ? abs : rel;
504
484
  }
505
- /** How many below-floor candidates a miss lists, and the weakest one still worth naming. */
506
- const ORIENTATION_LIMIT = 3;
507
- const ORIENTATION_MIN = 0.3;
508
485
  /** External refs (commit / MR / issue) an entry carries, as one readable line; "" if none. */
509
486
  function refsLine(entry) {
510
487
  const refs = Array.isArray(entry.refs) ? entry.refs : [];
@@ -554,6 +531,18 @@ async function handleGetMemory(args) {
554
531
  return { content: [{ type: "text", text: `No memory with id "${id}" in the Brain. It may have been deleted with forget_memory, or evicted at capacity — search_memory can find it by content if it is still there under another id.` }] };
555
532
  }
556
533
  const [status] = brain.verifyByIds([id]);
534
+ // Opened from a search_memory shortlist: this is the reuse. Booked once per shortlisting,
535
+ // and only for a memory that was checked against code and still holds — the same rule the
536
+ // old above-the-floor hit followed.
537
+ if (_shortlisted.delete(id) && includeResponse) {
538
+ brain.recordReuse(id);
539
+ if (status?.status === "fresh") {
540
+ const { net: tokensSaved } = (0, squeeze_cache_1.netTokensSaved)(Math.max(400, entry.response.length), entry.query);
541
+ (0, reportSavings_1.reportSavings)({ source: "cache", tokens: tokensSaved, toolName: "search_memory", query: entry.query.substring(0, 100) });
542
+ brain.creditSavings(id, tokensSaved);
543
+ (0, TokenReceipt_1.recordReceiptEvent)("semantic_cache_hit", entry.query.substring(0, 100), { tool: "get_memory", tokensSaved, memoryId: id });
544
+ }
545
+ }
557
546
  const facts = [
558
547
  `stored ${entry.timestamp}`,
559
548
  ...(entry.refreshedAt ? [`re-anchored ${entry.refreshedAt}`] : []),
@@ -626,7 +615,19 @@ async function handleUpdateMemory(args) {
626
615
  const ok = (0, TheBrainV2_1.getBrain)().setRefs(id, refs);
627
616
  return { content: [{ type: "text", text: ok ? `External refs on "${id}" ${refs.length > 0 ? `set to: ${refs.map(ExternalRefs_1.describeRef).join(", ")}` : "cleared"}. Nothing else was changed.` : `No entry with id "${id}" in the Brain.` }] };
628
617
  }
629
- const result = (0, TheBrainV2_1.getBrain)().update(id, { query, response, filePaths, symbols, claims, outcome, domain, derivedFrom, supersededBy, refs });
618
+ // New files without symbols: track the symbols the memory names in them instead (see
619
+ // NarrowEvidence) — the text it is judged by is the new one when given, else the stored one.
620
+ let trackFiles = filePaths;
621
+ let trackSymbols = symbols;
622
+ if (filePaths && filePaths.length > 0 && !symbols) {
623
+ const current = (0, TheBrainV2_1.getBrain)().getEntry(id);
624
+ const narrowed = (0, NarrowEvidence_1.narrowEvidence)(filePaths, `${query ?? current?.query ?? ""}\n${response ?? current?.response ?? ""}`);
625
+ if (narrowed.symbols.length > 0) {
626
+ trackFiles = narrowed.filePaths;
627
+ trackSymbols = narrowed.symbols;
628
+ }
629
+ }
630
+ const result = (0, TheBrainV2_1.getBrain)().update(id, { query, response, filePaths: trackFiles, symbols: trackSymbols, claims, outcome, domain, derivedFrom, supersededBy, refs });
630
631
  if (!result.ok)
631
632
  return { content: [{ type: "text", text: result.message }] };
632
633
  (0, TokenReceipt_1.recordReceiptEvent)("tool_call", `update_memory: ${id}`, {
@@ -652,6 +653,20 @@ async function handleUpdateMemory(args) {
652
653
  return { content: [{ type: "text", text: `Failed to update memory: ${e.message}` }], isError: true };
653
654
  }
654
655
  }
656
+ /**
657
+ * A memory that reads as a log of what was done — "release v1.31.0: what shipped", "commit abc123:
658
+ * …", "hito v1.26.0". On Lemma's own repo these were most of the memories written on purpose and
659
+ * none was ever recalled: the next session asks why something breaks or how to do it, never what
660
+ * shipped on a date, and git log / the CHANGELOG answer that anyway. A how/why question is
661
+ * knowledge even when it mentions a release ("how to publish a release"), so it is let through.
662
+ */
663
+ function looksLikeLogbook(query) {
664
+ const q = query.toLowerCase();
665
+ if (/^(how|why|cómo|como|por qué|porque)\s/.test(q))
666
+ return false;
667
+ return (/^commit [0-9a-f]{7,}/.test(q) ||
668
+ /(?<![a-z])(what shipped|shipped|released?|milestone|hito|changelog|qué trae|qué se publicó|publicad[oa])(?![a-z])/.test(q));
669
+ }
655
670
  async function handleStoreMemory(args) {
656
671
  const query = args?.query;
657
672
  const responseText = args?.response;
@@ -674,6 +689,17 @@ async function handleStoreMemory(args) {
674
689
  autoEvidence = true;
675
690
  }
676
691
  }
692
+ // A whole file goes stale on any edit anywhere in it; the symbols the memory names in it go
693
+ // stale only when what it talks about changes (see NarrowEvidence).
694
+ let narrowedNote = "";
695
+ if (filePaths && filePaths.length > 0 && (!symbols || symbols.length === 0) && query && responseText) {
696
+ const narrowed = (0, NarrowEvidence_1.narrowEvidence)(filePaths, `${query}\n${responseText}`);
697
+ if (narrowed.symbols.length > 0) {
698
+ filePaths = narrowed.filePaths.length > 0 ? narrowed.filePaths : undefined;
699
+ symbols = narrowed.symbols;
700
+ narrowedNote = ` Tracking the symbols it names instead of their whole file (${narrowed.narrowed.join("; ")}) — an edit elsewhere in those files won't stale it; pass symbols explicitly to choose others.`;
701
+ }
702
+ }
677
703
  const claims = Array.isArray(args?.claims)
678
704
  ? args.claims.filter((c) => c?.text)
679
705
  : undefined;
@@ -726,10 +752,13 @@ async function handleStoreMemory(args) {
726
752
  // later store, verify_memory, refresh_memory, forget_memory. Without it the caller had
727
753
  // to search for the memory it had just written to do anything with it.
728
754
  const idNote = storeRes.id ? ` (id: ${storeRes.id})` : "";
755
+ const logbookNote = looksLikeLogbook(query)
756
+ ? "\n\n📓 This reads like a log of what was done or shipped. git log and the CHANGELOG already hold that, and log-style memories are the ones that never get recalled. If it contains what they don't — the root cause, the trap, the approach that failed, the non-obvious step — update_memory it so the key and body lead with that; otherwise forget_memory it."
757
+ : "";
729
758
  const scrubNote = storeRes.redactions > 0
730
759
  ? ` 🛡 ${storeRes.redactions} secret(s) redacted before storage — credentials are never persisted, only their placeholders.`
731
760
  : "";
732
- return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${autoEvidenceNote}${outcomeNote}${claimsNote}${domainNote}${refsNote}${derivedFromNote}${conflictsNote}${textConflictsNote}${scrubNote}` }] };
761
+ return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${autoEvidenceNote}${outcomeNote}${claimsNote}${domainNote}${refsNote}${derivedFromNote}${conflictsNote}${narrowedNote}${textConflictsNote}${scrubNote}${logbookNote}` }] };
733
762
  }
734
763
  catch (e) {
735
764
  (0, utils_1.logError)("store_memory", e);
@@ -1149,7 +1178,7 @@ async function handleBrainTeam(args) {
1149
1178
  }
1150
1179
  async function handleVerifyMemory(args) {
1151
1180
  const ids = Array.isArray(args?.ids) ? args.ids.filter((id) => typeof id === "string" && id) : [];
1152
- const semanticDiff = args?.semanticDiff === true;
1181
+ const semanticDiff = args?.semanticDiff !== false;
1153
1182
  if (ids.length === 0)
1154
1183
  throw new Error("ids is required and must be a non-empty array");
1155
1184
  try {