@nxuss/lemma 1.16.1 → 1.18.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 (483) hide show
  1. package/bin/init.js +101 -11
  2. package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
  3. package/dist/cjs/cli/lemma-proxy.js +19 -11
  4. package/dist/cjs/cli/lemma-proxy.js.map +1 -1
  5. package/dist/cjs/cloud/TenantCache.d.ts.map +1 -1
  6. package/dist/cjs/cloud/TenantCache.js +0 -4
  7. package/dist/cjs/cloud/TenantCache.js.map +1 -1
  8. package/dist/cjs/cloud/identity/ApiKey.d.ts +32 -0
  9. package/dist/cjs/cloud/identity/ApiKey.d.ts.map +1 -0
  10. package/dist/cjs/cloud/identity/ApiKey.js +59 -0
  11. package/dist/cjs/cloud/identity/ApiKey.js.map +1 -0
  12. package/dist/cjs/cloud/identity/PlanPolicy.d.ts +79 -0
  13. package/dist/cjs/cloud/identity/PlanPolicy.d.ts.map +1 -0
  14. package/dist/cjs/cloud/identity/PlanPolicy.js +135 -0
  15. package/dist/cjs/cloud/identity/PlanPolicy.js.map +1 -0
  16. package/dist/cjs/cloud/identity/RateLimiter.d.ts +49 -0
  17. package/dist/cjs/cloud/identity/RateLimiter.d.ts.map +1 -0
  18. package/dist/cjs/cloud/identity/RateLimiter.js +75 -0
  19. package/dist/cjs/cloud/identity/RateLimiter.js.map +1 -0
  20. package/dist/cjs/cloud/identity/TenantResolver.d.ts +19 -0
  21. package/dist/cjs/cloud/identity/TenantResolver.d.ts.map +1 -0
  22. package/dist/cjs/cloud/identity/TenantResolver.js +40 -0
  23. package/dist/cjs/cloud/identity/TenantResolver.js.map +1 -0
  24. package/dist/cjs/cloud/identity/authenticateV2.d.ts +48 -0
  25. package/dist/cjs/cloud/identity/authenticateV2.d.ts.map +1 -0
  26. package/dist/cjs/cloud/identity/authenticateV2.js +66 -0
  27. package/dist/cjs/cloud/identity/authenticateV2.js.map +1 -0
  28. package/dist/cjs/cloud/identity/identityStore.d.ts +56 -0
  29. package/dist/cjs/cloud/identity/identityStore.d.ts.map +1 -0
  30. package/dist/cjs/cloud/identity/identityStore.js +99 -0
  31. package/dist/cjs/cloud/identity/identityStore.js.map +1 -0
  32. package/dist/cjs/cloud/identity/index.d.ts +14 -0
  33. package/dist/cjs/cloud/identity/index.d.ts.map +1 -0
  34. package/dist/cjs/cloud/identity/index.js +30 -0
  35. package/dist/cjs/cloud/identity/index.js.map +1 -0
  36. package/dist/cjs/cloud/metering/TokenCounter.d.ts +26 -0
  37. package/dist/cjs/cloud/metering/TokenCounter.d.ts.map +1 -0
  38. package/dist/cjs/cloud/metering/TokenCounter.js +80 -0
  39. package/dist/cjs/cloud/metering/TokenCounter.js.map +1 -0
  40. package/dist/cjs/cloud/metering/UsageLedger.d.ts +68 -0
  41. package/dist/cjs/cloud/metering/UsageLedger.d.ts.map +1 -0
  42. package/dist/cjs/cloud/metering/UsageLedger.js +106 -0
  43. package/dist/cjs/cloud/metering/UsageLedger.js.map +1 -0
  44. package/dist/cjs/cloud/metering/index.d.ts +12 -0
  45. package/dist/cjs/cloud/metering/index.d.ts.map +1 -0
  46. package/dist/cjs/cloud/metering/index.js +28 -0
  47. package/dist/cjs/cloud/metering/index.js.map +1 -0
  48. package/dist/cjs/cloud/scrub/StatelessScrubber.d.ts +53 -0
  49. package/dist/cjs/cloud/scrub/StatelessScrubber.d.ts.map +1 -0
  50. package/dist/cjs/cloud/scrub/StatelessScrubber.js +203 -0
  51. package/dist/cjs/cloud/scrub/StatelessScrubber.js.map +1 -0
  52. package/dist/cjs/cloud/scrub/index.d.ts +5 -0
  53. package/dist/cjs/cloud/scrub/index.d.ts.map +1 -0
  54. package/dist/cjs/cloud/scrub/index.js +21 -0
  55. package/dist/cjs/cloud/scrub/index.js.map +1 -0
  56. package/dist/cjs/cloud/store/FileBrainStore.d.ts +26 -0
  57. package/dist/cjs/cloud/store/FileBrainStore.d.ts.map +1 -0
  58. package/dist/cjs/cloud/store/FileBrainStore.js +219 -0
  59. package/dist/cjs/cloud/store/FileBrainStore.js.map +1 -0
  60. package/dist/cjs/cloud/store/PostgresBrainStore.d.ts +50 -0
  61. package/dist/cjs/cloud/store/PostgresBrainStore.d.ts.map +1 -0
  62. package/dist/cjs/cloud/store/PostgresBrainStore.js +181 -0
  63. package/dist/cjs/cloud/store/PostgresBrainStore.js.map +1 -0
  64. package/dist/cjs/cloud/store/index.d.ts +6 -0
  65. package/dist/cjs/cloud/store/index.d.ts.map +1 -0
  66. package/dist/cjs/cloud/store/index.js +22 -0
  67. package/dist/cjs/cloud/store/index.js.map +1 -0
  68. package/dist/cjs/cloud/types.d.ts +0 -4
  69. package/dist/cjs/cloud/types.d.ts.map +1 -1
  70. package/dist/cjs/cloud/types.js +1 -3
  71. package/dist/cjs/cloud/types.js.map +1 -1
  72. package/dist/cjs/cloud/v2/app.d.ts +15 -0
  73. package/dist/cjs/cloud/v2/app.d.ts.map +1 -0
  74. package/dist/cjs/cloud/v2/app.js +63 -0
  75. package/dist/cjs/cloud/v2/app.js.map +1 -0
  76. package/dist/cjs/cloud/v2/routes/index.d.ts +24 -0
  77. package/dist/cjs/cloud/v2/routes/index.d.ts.map +1 -0
  78. package/dist/cjs/cloud/v2/routes/index.js +35 -0
  79. package/dist/cjs/cloud/v2/routes/index.js.map +1 -0
  80. package/dist/cjs/cloud/v2/routes/memories.d.ts +83 -0
  81. package/dist/cjs/cloud/v2/routes/memories.d.ts.map +1 -0
  82. package/dist/cjs/cloud/v2/routes/memories.js +249 -0
  83. package/dist/cjs/cloud/v2/routes/memories.js.map +1 -0
  84. package/dist/cjs/cloud/v2/routes/recall.d.ts +33 -0
  85. package/dist/cjs/cloud/v2/routes/recall.d.ts.map +1 -0
  86. package/dist/cjs/cloud/v2/routes/recall.js +51 -0
  87. package/dist/cjs/cloud/v2/routes/recall.js.map +1 -0
  88. package/dist/cjs/cloud/v2/routes/scrub.d.ts +13 -0
  89. package/dist/cjs/cloud/v2/routes/scrub.d.ts.map +1 -0
  90. package/dist/cjs/cloud/v2/routes/scrub.js +82 -0
  91. package/dist/cjs/cloud/v2/routes/scrub.js.map +1 -0
  92. package/dist/cjs/cloud/v2/routes/usage.d.ts +18 -0
  93. package/dist/cjs/cloud/v2/routes/usage.d.ts.map +1 -0
  94. package/dist/cjs/cloud/v2/routes/usage.js +18 -0
  95. package/dist/cjs/cloud/v2/routes/usage.js.map +1 -0
  96. package/dist/cjs/cloud/v2/routes/verify.d.ts +35 -0
  97. package/dist/cjs/cloud/v2/routes/verify.d.ts.map +1 -0
  98. package/dist/cjs/cloud/v2/routes/verify.js +43 -0
  99. package/dist/cjs/cloud/v2/routes/verify.js.map +1 -0
  100. package/dist/cjs/cloud/v2/server.d.ts +27 -0
  101. package/dist/cjs/cloud/v2/server.d.ts.map +1 -0
  102. package/dist/cjs/cloud/v2/server.js +47 -0
  103. package/dist/cjs/cloud/v2/server.js.map +1 -0
  104. package/dist/cjs/contracts/api-v2.types.d.ts +103 -0
  105. package/dist/cjs/contracts/api-v2.types.d.ts.map +1 -0
  106. package/dist/cjs/contracts/api-v2.types.js +3 -0
  107. package/dist/cjs/contracts/api-v2.types.js.map +1 -0
  108. package/dist/cjs/contracts/errors.d.ts +40 -0
  109. package/dist/cjs/contracts/errors.d.ts.map +1 -0
  110. package/dist/cjs/contracts/errors.js +50 -0
  111. package/dist/cjs/contracts/errors.js.map +1 -0
  112. package/dist/cjs/contracts/evidence.d.ts +49 -0
  113. package/dist/cjs/contracts/evidence.d.ts.map +1 -0
  114. package/dist/cjs/contracts/evidence.js +12 -0
  115. package/dist/cjs/contracts/evidence.js.map +1 -0
  116. package/dist/cjs/contracts/index.d.ts +10 -0
  117. package/dist/cjs/contracts/index.d.ts.map +1 -0
  118. package/dist/cjs/contracts/index.js +26 -0
  119. package/dist/cjs/contracts/index.js.map +1 -0
  120. package/dist/cjs/contracts/store.d.ts +30 -0
  121. package/dist/cjs/contracts/store.d.ts.map +1 -0
  122. package/dist/cjs/contracts/store.js +3 -0
  123. package/dist/cjs/contracts/store.js.map +1 -0
  124. package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
  125. package/dist/cjs/mcp/tool-profiles.js +46 -1
  126. package/dist/cjs/mcp/tool-profiles.js.map +1 -1
  127. package/dist/cjs/mcp/tools.d.ts +2 -0
  128. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  129. package/dist/cjs/mcp/tools.js +319 -30
  130. package/dist/cjs/mcp/tools.js.map +1 -1
  131. package/dist/cjs/pr-review/bridge/BrainBridge.js +1 -1
  132. package/dist/cjs/pr-review/bridge/BrainBridge.js.map +1 -1
  133. package/dist/cjs/subconscious/BrainEmbeddings.d.ts +59 -0
  134. package/dist/cjs/subconscious/BrainEmbeddings.d.ts.map +1 -0
  135. package/dist/cjs/subconscious/BrainEmbeddings.js +222 -0
  136. package/dist/cjs/subconscious/BrainEmbeddings.js.map +1 -0
  137. package/dist/cjs/subconscious/GitIngest.js +2 -2
  138. package/dist/cjs/subconscious/GitIngest.js.map +1 -1
  139. package/dist/cjs/subconscious/TheBrainV2.d.ts +327 -9
  140. package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
  141. package/dist/cjs/subconscious/TheBrainV2.js +952 -98
  142. package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
  143. package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts +16 -0
  144. package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts.map +1 -0
  145. package/dist/cjs/subconscious/freshness/LocalFsResolver.js +74 -0
  146. package/dist/cjs/subconscious/freshness/LocalFsResolver.js.map +1 -0
  147. package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.d.ts +23 -0
  148. package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.d.ts.map +1 -0
  149. package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.js +24 -0
  150. package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.js.map +1 -0
  151. package/dist/cjs/subconscious/freshness/index.d.ts +10 -0
  152. package/dist/cjs/subconscious/freshness/index.d.ts.map +1 -0
  153. package/dist/cjs/subconscious/freshness/index.js +26 -0
  154. package/dist/cjs/subconscious/freshness/index.js.map +1 -0
  155. package/dist/cjs/utils/ConversationCheckpoint.js +1 -1
  156. package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -1
  157. package/dist/cjs/utils/ProjectIdentity.d.ts +12 -0
  158. package/dist/cjs/utils/ProjectIdentity.d.ts.map +1 -0
  159. package/dist/cjs/utils/ProjectIdentity.js +44 -0
  160. package/dist/cjs/utils/ProjectIdentity.js.map +1 -0
  161. package/dist/cjs/utils/PromptPatternCache.d.ts.map +1 -1
  162. package/dist/cjs/utils/PromptPatternCache.js +12 -2
  163. package/dist/cjs/utils/PromptPatternCache.js.map +1 -1
  164. package/dist/cjs/utils/RepeatGuard.d.ts.map +1 -1
  165. package/dist/cjs/utils/RepeatGuard.js +10 -2
  166. package/dist/cjs/utils/RepeatGuard.js.map +1 -1
  167. package/dist/cjs/utils/StateHashCache.d.ts +5 -0
  168. package/dist/cjs/utils/StateHashCache.d.ts.map +1 -1
  169. package/dist/cjs/utils/StateHashCache.js +40 -16
  170. package/dist/cjs/utils/StateHashCache.js.map +1 -1
  171. package/dist/esm/api/dashboardRoutes.d.ts +3 -3
  172. package/dist/esm/api/dashboardRoutes.js +1 -1
  173. package/dist/esm/api/server.d.ts +4 -4
  174. package/dist/esm/api/server.js +3 -3
  175. package/dist/esm/autopilot/AutopilotWatcher.js +3 -3
  176. package/dist/esm/autopilot/Notifier.d.ts +1 -1
  177. package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
  178. package/dist/esm/cli/lemma-proxy.js +33 -25
  179. package/dist/esm/cli/lemma-proxy.js.map +1 -1
  180. package/dist/esm/cli/stack.d.ts +4 -4
  181. package/dist/esm/cli/stack.js +5 -5
  182. package/dist/esm/cloud/KeyManager.d.ts +1 -1
  183. package/dist/esm/cloud/KeyManager.js +1 -1
  184. package/dist/esm/cloud/TenantCache.d.ts +1 -1
  185. package/dist/esm/cloud/TenantCache.d.ts.map +1 -1
  186. package/dist/esm/cloud/TenantCache.js +0 -4
  187. package/dist/esm/cloud/TenantCache.js.map +1 -1
  188. package/dist/esm/cloud/identity/ApiKey.d.ts +32 -0
  189. package/dist/esm/cloud/identity/ApiKey.d.ts.map +1 -0
  190. package/dist/esm/cloud/identity/ApiKey.js +49 -0
  191. package/dist/esm/cloud/identity/ApiKey.js.map +1 -0
  192. package/dist/esm/cloud/identity/PlanPolicy.d.ts +79 -0
  193. package/dist/esm/cloud/identity/PlanPolicy.d.ts.map +1 -0
  194. package/dist/esm/cloud/identity/PlanPolicy.js +129 -0
  195. package/dist/esm/cloud/identity/PlanPolicy.js.map +1 -0
  196. package/dist/esm/cloud/identity/RateLimiter.d.ts +49 -0
  197. package/dist/esm/cloud/identity/RateLimiter.d.ts.map +1 -0
  198. package/dist/esm/cloud/identity/RateLimiter.js +69 -0
  199. package/dist/esm/cloud/identity/RateLimiter.js.map +1 -0
  200. package/dist/esm/cloud/identity/TenantResolver.d.ts +19 -0
  201. package/dist/esm/cloud/identity/TenantResolver.d.ts.map +1 -0
  202. package/dist/esm/cloud/identity/TenantResolver.js +36 -0
  203. package/dist/esm/cloud/identity/TenantResolver.js.map +1 -0
  204. package/dist/esm/cloud/identity/authenticateV2.d.ts +48 -0
  205. package/dist/esm/cloud/identity/authenticateV2.d.ts.map +1 -0
  206. package/dist/esm/cloud/identity/authenticateV2.js +62 -0
  207. package/dist/esm/cloud/identity/authenticateV2.js.map +1 -0
  208. package/dist/esm/cloud/identity/identityStore.d.ts +56 -0
  209. package/dist/esm/cloud/identity/identityStore.d.ts.map +1 -0
  210. package/dist/esm/cloud/identity/identityStore.js +94 -0
  211. package/dist/esm/cloud/identity/identityStore.js.map +1 -0
  212. package/dist/esm/cloud/identity/index.d.ts +14 -0
  213. package/dist/esm/cloud/identity/index.d.ts.map +1 -0
  214. package/dist/esm/cloud/identity/index.js +14 -0
  215. package/dist/esm/cloud/identity/index.js.map +1 -0
  216. package/dist/esm/cloud/index.d.ts +3 -3
  217. package/dist/esm/cloud/index.js +3 -3
  218. package/dist/esm/cloud/metering/TokenCounter.d.ts +26 -0
  219. package/dist/esm/cloud/metering/TokenCounter.d.ts.map +1 -0
  220. package/dist/esm/cloud/metering/TokenCounter.js +76 -0
  221. package/dist/esm/cloud/metering/TokenCounter.js.map +1 -0
  222. package/dist/esm/cloud/metering/UsageLedger.d.ts +68 -0
  223. package/dist/esm/cloud/metering/UsageLedger.d.ts.map +1 -0
  224. package/dist/esm/cloud/metering/UsageLedger.js +98 -0
  225. package/dist/esm/cloud/metering/UsageLedger.js.map +1 -0
  226. package/dist/esm/cloud/metering/index.d.ts +12 -0
  227. package/dist/esm/cloud/metering/index.d.ts.map +1 -0
  228. package/dist/esm/cloud/metering/index.js +12 -0
  229. package/dist/esm/cloud/metering/index.js.map +1 -0
  230. package/dist/esm/cloud/scrub/StatelessScrubber.d.ts +53 -0
  231. package/dist/esm/cloud/scrub/StatelessScrubber.d.ts.map +1 -0
  232. package/dist/esm/cloud/scrub/StatelessScrubber.js +199 -0
  233. package/dist/esm/cloud/scrub/StatelessScrubber.js.map +1 -0
  234. package/dist/esm/cloud/scrub/index.d.ts +5 -0
  235. package/dist/esm/cloud/scrub/index.d.ts.map +1 -0
  236. package/dist/esm/cloud/scrub/index.js +5 -0
  237. package/dist/esm/cloud/scrub/index.js.map +1 -0
  238. package/dist/esm/cloud/server.d.ts +3 -3
  239. package/dist/esm/cloud/server.js +5 -5
  240. package/dist/esm/cloud/store/FileBrainStore.d.ts +26 -0
  241. package/dist/esm/cloud/store/FileBrainStore.d.ts.map +1 -0
  242. package/dist/esm/cloud/store/FileBrainStore.js +212 -0
  243. package/dist/esm/cloud/store/FileBrainStore.js.map +1 -0
  244. package/dist/esm/cloud/store/PostgresBrainStore.d.ts +50 -0
  245. package/dist/esm/cloud/store/PostgresBrainStore.d.ts.map +1 -0
  246. package/dist/esm/cloud/store/PostgresBrainStore.js +176 -0
  247. package/dist/esm/cloud/store/PostgresBrainStore.js.map +1 -0
  248. package/dist/esm/cloud/store/index.d.ts +6 -0
  249. package/dist/esm/cloud/store/index.d.ts.map +1 -0
  250. package/dist/esm/cloud/store/index.js +6 -0
  251. package/dist/esm/cloud/store/index.js.map +1 -0
  252. package/dist/esm/cloud/types.d.ts +0 -4
  253. package/dist/esm/cloud/types.d.ts.map +1 -1
  254. package/dist/esm/cloud/types.js +0 -2
  255. package/dist/esm/cloud/types.js.map +1 -1
  256. package/dist/esm/cloud/v2/app.d.ts +15 -0
  257. package/dist/esm/cloud/v2/app.d.ts.map +1 -0
  258. package/dist/esm/cloud/v2/app.js +57 -0
  259. package/dist/esm/cloud/v2/app.js.map +1 -0
  260. package/dist/esm/cloud/v2/routes/index.d.ts +24 -0
  261. package/dist/esm/cloud/v2/routes/index.d.ts.map +1 -0
  262. package/dist/esm/cloud/v2/routes/index.js +32 -0
  263. package/dist/esm/cloud/v2/routes/index.js.map +1 -0
  264. package/dist/esm/cloud/v2/routes/memories.d.ts +83 -0
  265. package/dist/esm/cloud/v2/routes/memories.d.ts.map +1 -0
  266. package/dist/esm/cloud/v2/routes/memories.js +238 -0
  267. package/dist/esm/cloud/v2/routes/memories.js.map +1 -0
  268. package/dist/esm/cloud/v2/routes/recall.d.ts +33 -0
  269. package/dist/esm/cloud/v2/routes/recall.d.ts.map +1 -0
  270. package/dist/esm/cloud/v2/routes/recall.js +47 -0
  271. package/dist/esm/cloud/v2/routes/recall.js.map +1 -0
  272. package/dist/esm/cloud/v2/routes/scrub.d.ts +13 -0
  273. package/dist/esm/cloud/v2/routes/scrub.d.ts.map +1 -0
  274. package/dist/esm/cloud/v2/routes/scrub.js +79 -0
  275. package/dist/esm/cloud/v2/routes/scrub.js.map +1 -0
  276. package/dist/esm/cloud/v2/routes/usage.d.ts +18 -0
  277. package/dist/esm/cloud/v2/routes/usage.d.ts.map +1 -0
  278. package/dist/esm/cloud/v2/routes/usage.js +15 -0
  279. package/dist/esm/cloud/v2/routes/usage.js.map +1 -0
  280. package/dist/esm/cloud/v2/routes/verify.d.ts +35 -0
  281. package/dist/esm/cloud/v2/routes/verify.d.ts.map +1 -0
  282. package/dist/esm/cloud/v2/routes/verify.js +39 -0
  283. package/dist/esm/cloud/v2/routes/verify.js.map +1 -0
  284. package/dist/esm/cloud/v2/server.d.ts +27 -0
  285. package/dist/esm/cloud/v2/server.d.ts.map +1 -0
  286. package/dist/esm/cloud/v2/server.js +44 -0
  287. package/dist/esm/cloud/v2/server.js.map +1 -0
  288. package/dist/esm/config/index.d.ts +1 -1
  289. package/dist/esm/config/index.js +1 -1
  290. package/dist/esm/consensus/index.d.ts +2 -2
  291. package/dist/esm/consensus/index.js +2 -2
  292. package/dist/esm/contracts/api-v2.types.d.ts +103 -0
  293. package/dist/esm/contracts/api-v2.types.d.ts.map +1 -0
  294. package/dist/esm/contracts/api-v2.types.js +2 -0
  295. package/dist/esm/contracts/api-v2.types.js.map +1 -0
  296. package/dist/esm/contracts/errors.d.ts +40 -0
  297. package/dist/esm/contracts/errors.d.ts.map +1 -0
  298. package/dist/esm/contracts/errors.js +45 -0
  299. package/dist/esm/contracts/errors.js.map +1 -0
  300. package/dist/esm/contracts/evidence.d.ts +49 -0
  301. package/dist/esm/contracts/evidence.d.ts.map +1 -0
  302. package/dist/esm/contracts/evidence.js +11 -0
  303. package/dist/esm/contracts/evidence.js.map +1 -0
  304. package/dist/esm/contracts/index.d.ts +10 -0
  305. package/dist/esm/contracts/index.d.ts.map +1 -0
  306. package/dist/esm/contracts/index.js +10 -0
  307. package/dist/esm/contracts/index.js.map +1 -0
  308. package/dist/esm/contracts/store.d.ts +30 -0
  309. package/dist/esm/contracts/store.d.ts.map +1 -0
  310. package/dist/esm/contracts/store.js +2 -0
  311. package/dist/esm/contracts/store.js.map +1 -0
  312. package/dist/esm/core/AgentRegistry.d.ts +1 -1
  313. package/dist/esm/core/AgentRegistry.js +1 -1
  314. package/dist/esm/core/DashboardBroadcaster.d.ts +3 -3
  315. package/dist/esm/core/DashboardBroadcaster.js +2 -2
  316. package/dist/esm/core/DashboardWebSocketServer.d.ts +1 -1
  317. package/dist/esm/core/DashboardWebSocketServer.js +1 -1
  318. package/dist/esm/core/GhostAlchemist.js +1 -1
  319. package/dist/esm/core/GhostListener.js +2 -2
  320. package/dist/esm/core/OrchestrationEngine.d.ts +3 -3
  321. package/dist/esm/core/OrchestrationEngine.js +2 -2
  322. package/dist/esm/core/SubconsciousEngine.d.ts +1 -1
  323. package/dist/esm/core/SubconsciousEngine.js +2 -2
  324. package/dist/esm/core/WebSocketServer.d.ts +2 -2
  325. package/dist/esm/core/WebSocketServer.js +1 -1
  326. package/dist/esm/core/index.d.ts +6 -6
  327. package/dist/esm/core/index.js +6 -6
  328. package/dist/esm/core/router.d.ts +3 -3
  329. package/dist/esm/core/router.js +1 -1
  330. package/dist/esm/db/database.js +1 -1
  331. package/dist/esm/embed.d.ts +2 -2
  332. package/dist/esm/embed.js +2 -2
  333. package/dist/esm/examples/basic-usage.js +1 -1
  334. package/dist/esm/index.d.ts +14 -14
  335. package/dist/esm/index.js +14 -14
  336. package/dist/esm/infra/analyzers/DriftDetector.d.ts +1 -1
  337. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +1 -1
  338. package/dist/esm/infra/analyzers/MonolithAnalyzer.d.ts +1 -1
  339. package/dist/esm/infra/analyzers/index.d.ts +3 -3
  340. package/dist/esm/infra/analyzers/index.js +3 -3
  341. package/dist/esm/infra/cli.js +2 -2
  342. package/dist/esm/infra/config.d.ts +1 -1
  343. package/dist/esm/infra/index.d.ts +5 -5
  344. package/dist/esm/infra/index.js +5 -5
  345. package/dist/esm/infra/mcp-tools.js +5 -5
  346. package/dist/esm/infra/providers/InfraProvider.d.ts +1 -1
  347. package/dist/esm/infra/providers/JenkinsProvider.d.ts +2 -2
  348. package/dist/esm/infra/providers/OKDProvider.d.ts +2 -2
  349. package/dist/esm/infra/providers/TerraformProvider.d.ts +2 -2
  350. package/dist/esm/infra/providers/index.d.ts +5 -5
  351. package/dist/esm/infra/providers/index.js +3 -3
  352. package/dist/esm/mcp/index.js +5 -5
  353. package/dist/esm/mcp/prompts.js +1 -1
  354. package/dist/esm/mcp/resources.js +2 -2
  355. package/dist/esm/mcp/tasks.js +1 -1
  356. package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
  357. package/dist/esm/mcp/tool-profiles.js +47 -2
  358. package/dist/esm/mcp/tool-profiles.js.map +1 -1
  359. package/dist/esm/mcp/tools.d.ts +2 -0
  360. package/dist/esm/mcp/tools.d.ts.map +1 -1
  361. package/dist/esm/mcp/tools.js +366 -78
  362. package/dist/esm/mcp/tools.js.map +1 -1
  363. package/dist/esm/observability/IdeContextSync.d.ts +1 -1
  364. package/dist/esm/observability/IdeContextSync.js +5 -5
  365. package/dist/esm/pr-review/PRReviewEngine.d.ts +1 -1
  366. package/dist/esm/pr-review/PRReviewEngine.js +4 -4
  367. package/dist/esm/pr-review/ReviewStore.d.ts +1 -1
  368. package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.d.ts +2 -2
  369. package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.js +1 -1
  370. package/dist/esm/pr-review/adapters/GitHubAdapter.d.ts +2 -2
  371. package/dist/esm/pr-review/adapters/GitHubAdapter.js +1 -1
  372. package/dist/esm/pr-review/adapters/GitLabAdapter.d.ts +2 -2
  373. package/dist/esm/pr-review/adapters/GitLabAdapter.js +1 -1
  374. package/dist/esm/pr-review/adapters/GitPlatformAdapter.d.ts +1 -1
  375. package/dist/esm/pr-review/adapters/index.d.ts +4 -4
  376. package/dist/esm/pr-review/adapters/index.js +3 -3
  377. package/dist/esm/pr-review/analyzers/QualityGrader.d.ts +1 -1
  378. package/dist/esm/pr-review/analyzers/RegressionDetector.d.ts +1 -1
  379. package/dist/esm/pr-review/analyzers/SecurityScanner.d.ts +1 -1
  380. package/dist/esm/pr-review/analyzers/StaticAnalyzer.d.ts +1 -1
  381. package/dist/esm/pr-review/analyzers/index.d.ts +8 -8
  382. package/dist/esm/pr-review/analyzers/index.js +4 -4
  383. package/dist/esm/pr-review/bridge/BrainBridge.d.ts +1 -1
  384. package/dist/esm/pr-review/bridge/BrainBridge.js +2 -2
  385. package/dist/esm/pr-review/bridge/BrainBridge.js.map +1 -1
  386. package/dist/esm/pr-review/bridge/index.d.ts +1 -1
  387. package/dist/esm/pr-review/bridge/index.js +1 -1
  388. package/dist/esm/pr-review/index.d.ts +4 -4
  389. package/dist/esm/pr-review/index.js +2 -2
  390. package/dist/esm/pr-review/reviewRunner.d.ts +2 -2
  391. package/dist/esm/pr-review/reviewRunner.js +6 -6
  392. package/dist/esm/pr-review/webhook/WebhookServer.js +1 -1
  393. package/dist/esm/pr-review/webhook/index.d.ts +1 -1
  394. package/dist/esm/pr-review/webhook/index.js +1 -1
  395. package/dist/esm/protocol/flows.d.ts +1 -1
  396. package/dist/esm/protocol/flows.js +1 -1
  397. package/dist/esm/protocol/index.d.ts +4 -4
  398. package/dist/esm/protocol/index.js +4 -4
  399. package/dist/esm/protocol/utils.d.ts +1 -1
  400. package/dist/esm/protocol/utils.js +2 -2
  401. package/dist/esm/protocol/validators.d.ts +1 -1
  402. package/dist/esm/protocol/validators.js +1 -1
  403. package/dist/esm/proxy/ContextInjector.d.ts +1 -1
  404. package/dist/esm/proxy/Gatekeeper.d.ts +1 -1
  405. package/dist/esm/security/SecurityMiddleware.d.ts +1 -1
  406. package/dist/esm/security/SecurityMiddleware.js +3 -3
  407. package/dist/esm/security/index.d.ts +4 -4
  408. package/dist/esm/security/index.js +4 -4
  409. package/dist/esm/speculative/SpeculativeCache.d.ts +2 -2
  410. package/dist/esm/speculative/SpeculativeEngine.d.ts +2 -2
  411. package/dist/esm/speculative/SpeculativeEngine.js +3 -3
  412. package/dist/esm/speculative/WorkerPool.d.ts +1 -1
  413. package/dist/esm/speculative/index.d.ts +4 -4
  414. package/dist/esm/speculative/index.js +4 -4
  415. package/dist/esm/subconscious/BrainEmbeddings.d.ts +59 -0
  416. package/dist/esm/subconscious/BrainEmbeddings.d.ts.map +1 -0
  417. package/dist/esm/subconscious/BrainEmbeddings.js +211 -0
  418. package/dist/esm/subconscious/BrainEmbeddings.js.map +1 -0
  419. package/dist/esm/subconscious/GitIngest.d.ts +1 -1
  420. package/dist/esm/subconscious/GitIngest.js +3 -3
  421. package/dist/esm/subconscious/GitIngest.js.map +1 -1
  422. package/dist/esm/subconscious/SemanticCache.d.ts +2 -2
  423. package/dist/esm/subconscious/SemanticCache.js +2 -2
  424. package/dist/esm/subconscious/SubconsciousEngine.d.ts +1 -1
  425. package/dist/esm/subconscious/SubconsciousEngine.js +3 -3
  426. package/dist/esm/subconscious/TheBrainV2.d.ts +327 -9
  427. package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
  428. package/dist/esm/subconscious/TheBrainV2.js +947 -98
  429. package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
  430. package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts +16 -0
  431. package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts.map +1 -0
  432. package/dist/esm/subconscious/freshness/LocalFsResolver.js +67 -0
  433. package/dist/esm/subconscious/freshness/LocalFsResolver.js.map +1 -0
  434. package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.d.ts +23 -0
  435. package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.d.ts.map +1 -0
  436. package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.js +20 -0
  437. package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.js.map +1 -0
  438. package/dist/esm/subconscious/freshness/index.d.ts +10 -0
  439. package/dist/esm/subconscious/freshness/index.d.ts.map +1 -0
  440. package/dist/esm/subconscious/freshness/index.js +10 -0
  441. package/dist/esm/subconscious/freshness/index.js.map +1 -0
  442. package/dist/esm/subconscious/index.d.ts +4 -4
  443. package/dist/esm/subconscious/index.js +4 -4
  444. package/dist/esm/utils/AffectedTests.js +1 -1
  445. package/dist/esm/utils/AutoContextBundle.d.ts +1 -1
  446. package/dist/esm/utils/AutoContextBundle.js +4 -4
  447. package/dist/esm/utils/BulkFileDigest.js +2 -2
  448. package/dist/esm/utils/ClipboardWatcher.js +2 -2
  449. package/dist/esm/utils/ContextCollapser.js +1 -1
  450. package/dist/esm/utils/ConversationCheckpoint.js +2 -2
  451. package/dist/esm/utils/ConversationCheckpoint.js.map +1 -1
  452. package/dist/esm/utils/ExecutiveReport.js +1 -1
  453. package/dist/esm/utils/OutputLedger.js +2 -2
  454. package/dist/esm/utils/ProjectIdentity.d.ts +12 -0
  455. package/dist/esm/utils/ProjectIdentity.d.ts.map +1 -0
  456. package/dist/esm/utils/ProjectIdentity.js +37 -0
  457. package/dist/esm/utils/ProjectIdentity.js.map +1 -0
  458. package/dist/esm/utils/PromptPatternCache.d.ts.map +1 -1
  459. package/dist/esm/utils/PromptPatternCache.js +12 -2
  460. package/dist/esm/utils/PromptPatternCache.js.map +1 -1
  461. package/dist/esm/utils/ReadWorkspaceCache.js +1 -1
  462. package/dist/esm/utils/RepeatGuard.d.ts.map +1 -1
  463. package/dist/esm/utils/RepeatGuard.js +10 -2
  464. package/dist/esm/utils/RepeatGuard.js.map +1 -1
  465. package/dist/esm/utils/SpeculativeWarmer.d.ts +1 -1
  466. package/dist/esm/utils/SpeculativeWarmer.js +2 -2
  467. package/dist/esm/utils/StateHashCache.d.ts +5 -0
  468. package/dist/esm/utils/StateHashCache.d.ts.map +1 -1
  469. package/dist/esm/utils/StateHashCache.js +40 -16
  470. package/dist/esm/utils/StateHashCache.js.map +1 -1
  471. package/dist/esm/utils/StructuralSearch.d.ts +1 -1
  472. package/dist/esm/utils/SurgicalASTInsert.js +1 -1
  473. package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
  474. package/dist/esm/utils/TestAutofixInterceptor.js +1 -1
  475. package/dist/esm/utils/WorkspaceSearch.js +0 -0
  476. package/dist/esm/utils/logger.js +1 -1
  477. package/dist/esm/utils/reportSavings.js +1 -1
  478. package/package.json +1 -1
  479. package/sdks/crewai/README.md +25 -0
  480. package/dist/cjs/package.json +0 -3
  481. package/dist/esm/package.json +0 -3
  482. package/sdks/crewai/dist/index.d.ts +0 -130
  483. package/sdks/crewai/dist/index.js +0 -308
@@ -5,50 +5,51 @@ import { execSync, execFileSync, spawn } from "child_process";
5
5
  import os from "os";
6
6
  import axios from "axios";
7
7
  import * as ts from "typescript";
8
- import { SemanticScrubber } from "../security/SemanticScrubber.js";
9
- import { ComplexityRouter } from "../proxy/ComplexityRouter.js";
10
- import { squeezeCode, squeezePrompt, pruneHistoryMessages, generateAstDiff } from "../utils/ContextSqueezer.js";
11
- import { reportSavings, reportCost } from "../utils/reportSavings.js";
12
- import { getProxyPort, safeResolvePath, logError, logWarn, estimateTokensFromResult, isCommandAllowed, loadAllowedCommands } from "./utils.js";
13
- import { computeFingerprint } from "../utils/FileFingerprint.js";
14
- import { analyzeBlameHeat } from "../utils/GitBlameHeat.js";
15
- import { analyzeTypeCoverage } from "../utils/TypeCoverage.js";
16
- import { buildImportTree } from "../utils/ImportTreeContext.js";
17
- import { readTokenBudgeted } from "../utils/TokenBudgetedReader.js";
18
- import { bulkFileDigest } from "../utils/BulkFileDigest.js";
19
- import { autoContextBundle } from "../utils/AutoContextBundle.js";
20
- import { checkRepeat, recordOutput } from "../utils/RepeatGuard.js";
21
- import { saveCheckpoint, loadLatestCheckpoint, loadRecentCheckpoints, buildCheckpointSummary } from "../utils/ConversationCheckpoint.js";
22
- import { runTestAutofix } from "../utils/TestAutofixInterceptor.js";
23
- import { findPattern, storePattern, getPatternStats } from "../utils/PromptPatternCache.js";
24
- import { runAnalysis, parseDiff } from "../pr-review/PRReviewEngine.js";
25
- import { ReviewStore } from "../pr-review/ReviewStore.js";
26
- import { runPRReview } from "../pr-review/reviewRunner.js";
27
- import { getBrain, deriveProjectId } from "../subconscious/TheBrainV2.js";
28
- import { collapseContext } from "../utils/ContextCollapser.js";
29
- import { getSymbolSurgicalContext } from "../utils/SymbolSurgicalContext.js";
30
- import { compressWormhole } from "../utils/WormholeCompressor.js";
31
- import { generateExecutiveReport } from "../utils/ExecutiveReport.js";
32
- import { surgicalASTInsert } from "../utils/SurgicalASTInsert.js";
33
- import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from "../infra/mcp-tools.js";
34
- import { resolveToolSurface, buildToolboxCatalog } from "./tool-profiles.js";
35
- import { lookupStateHash, storeStateHash } from "../utils/StateHashCache.js";
36
- import { recordReceiptEvent, getReceiptSummary, getLedgerLength } from "../utils/TokenReceipt.js";
37
- import { distillCommandOutput, buildDistillFooter, readRegion } from "../utils/CommandOutputDistiller.js";
38
- import { findMatch, reindentReplacement } from "../utils/PatchMatcher.js";
39
- import { registerTaskHandlers, runAsTask, TASK_CAPABLE_TOOLS } from "./tasks.js";
40
- import { searchWorkspace, groupSearchResults, parseExtensionFilter } from "../utils/WorkspaceSearch.js";
41
- import { rankCandidates } from "../utils/LocalPrefilter.js";
42
- import { checkAlreadySent, recordSent, getLastEmitted } from "../utils/ReadWorkspaceCache.js";
43
- import { shouldEmitDelta } from "../utils/OutputDelta.js";
44
- import { ledgerKey, checkOutput, recordOutput as recordLedgerOutput } from "../utils/OutputLedger.js";
45
- import { buildDepGraphMap, bfsDepGraph } from "../utils/DepGraph.js";
46
- import { getOrExtractSymbols } from "../utils/AstSymbolCache.js";
47
- import { warmNeighbors, registerSymbolExtractor } from "../utils/SpeculativeWarmer.js";
48
- import { findAffectedTests, formatAffectedTests, changedFilesFromGit } from "../utils/AffectedTests.js";
49
- import { mapSqueezedToOriginal, withLineNumbers, sequentialNumbers } from "../utils/LineNumberMap.js";
50
- import { fileOutline, formatOutline } from "../utils/FileOutline.js";
51
- import { getCachedSearch, setCachedSearch } from "../utils/SearchCache.js";
8
+ import { SemanticScrubber } from "../security/SemanticScrubber";
9
+ import { ComplexityRouter } from "../proxy/ComplexityRouter";
10
+ import { squeezeCode, squeezePrompt, pruneHistoryMessages, generateAstDiff, stripComments, stripImports, compactWhitespace } from "../utils/ContextSqueezer";
11
+ import { reportSavings, reportCost } from "../utils/reportSavings";
12
+ import { getProxyPort, safeResolvePath, logError, logWarn, estimateTokensFromResult, isCommandAllowed, loadAllowedCommands } from "./utils";
13
+ import { computeFingerprint } from "../utils/FileFingerprint";
14
+ import { detectProjectName } from "../utils/ProjectIdentity";
15
+ import { analyzeBlameHeat } from "../utils/GitBlameHeat";
16
+ import { analyzeTypeCoverage } from "../utils/TypeCoverage";
17
+ import { buildImportTree } from "../utils/ImportTreeContext";
18
+ import { readTokenBudgeted } from "../utils/TokenBudgetedReader";
19
+ import { bulkFileDigest } from "../utils/BulkFileDigest";
20
+ import { autoContextBundle } from "../utils/AutoContextBundle";
21
+ import { checkRepeat, recordOutput } from "../utils/RepeatGuard";
22
+ import { saveCheckpoint, loadLatestCheckpoint, loadRecentCheckpoints, buildCheckpointSummary } from "../utils/ConversationCheckpoint";
23
+ import { runTestAutofix } from "../utils/TestAutofixInterceptor";
24
+ import { findPattern, storePattern, getPatternStats } from "../utils/PromptPatternCache";
25
+ import { runAnalysis, parseDiff } from "../pr-review/PRReviewEngine";
26
+ import { ReviewStore } from "../pr-review/ReviewStore";
27
+ import { runPRReview } from "../pr-review/reviewRunner";
28
+ import { getBrain, deriveProjectId, currentGitContext } from "../subconscious/TheBrainV2";
29
+ import { collapseContext } from "../utils/ContextCollapser";
30
+ import { getSymbolSurgicalContext } from "../utils/SymbolSurgicalContext";
31
+ import { compressWormhole } from "../utils/WormholeCompressor";
32
+ import { generateExecutiveReport } from "../utils/ExecutiveReport";
33
+ import { surgicalASTInsert } from "../utils/SurgicalASTInsert";
34
+ import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from "../infra/mcp-tools";
35
+ import { resolveToolSurface, buildToolboxCatalog } from "./tool-profiles";
36
+ import { lookupStateHash, storeStateHash } from "../utils/StateHashCache";
37
+ import { recordReceiptEvent, getReceiptSummary, getLedgerLength } from "../utils/TokenReceipt";
38
+ import { distillCommandOutput, buildDistillFooter, readRegion } from "../utils/CommandOutputDistiller";
39
+ import { findMatch, reindentReplacement } from "../utils/PatchMatcher";
40
+ import { registerTaskHandlers, runAsTask, TASK_CAPABLE_TOOLS } from "./tasks";
41
+ import { searchWorkspace, groupSearchResults, parseExtensionFilter } from "../utils/WorkspaceSearch";
42
+ import { rankCandidates } from "../utils/LocalPrefilter";
43
+ import { checkAlreadySent, recordSent, getLastEmitted } from "../utils/ReadWorkspaceCache";
44
+ import { shouldEmitDelta } from "../utils/OutputDelta";
45
+ import { ledgerKey, checkOutput, recordOutput as recordLedgerOutput } from "../utils/OutputLedger";
46
+ import { buildDepGraphMap, bfsDepGraph } from "../utils/DepGraph";
47
+ import { getOrExtractSymbols } from "../utils/AstSymbolCache";
48
+ import { warmNeighbors, registerSymbolExtractor } from "../utils/SpeculativeWarmer";
49
+ import { findAffectedTests, formatAffectedTests, changedFilesFromGit } from "../utils/AffectedTests";
50
+ import { mapSqueezedToOriginal, withLineNumbers, sequentialNumbers } from "../utils/LineNumberMap";
51
+ import { fileOutline, formatOutline } from "../utils/FileOutline";
52
+ import { getCachedSearch, setCachedSearch } from "../utils/SearchCache";
52
53
  // ── Pro License Gate ──────────────────────────────────────────────────────────
53
54
  const LICENSE_FILE = path.join(os.homedir(), '.lemma-cache', 'license.json');
54
55
  let _proStatusCache = null;
@@ -69,6 +70,10 @@ function isProUser() {
69
70
  const FREE_TOOLS = new Set([
70
71
  // Cache & Memory — the hook that shows instant value
71
72
  "smarter_cache", "state_hash_cache", "token_receipt", "search_memory", "store_memory", "downvote_memory", "verify_memory", "get_project_history",
73
+ // Memory upkeep. Deleting your own memories, re-verifying them, and getting them back out
74
+ // of the tool must never be behind a paywall — a user who cannot export or forget what a
75
+ // free tier collected does not really own it.
76
+ "forget_memory", "refresh_memory", "brain_stats", "brain_export", "brain_import",
72
77
  // Token optimization — shows what they're saving
73
78
  "token_budget", "squeeze_prompt", "turbosqueeze",
74
79
  // Utility — just enough to function
@@ -307,6 +312,81 @@ const toolDefinitions = [
307
312
  required: ["id"],
308
313
  },
309
314
  },
315
+ {
316
+ name: "forget_memory",
317
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
318
+ description: "Permanently delete one memory from the Brain by id. Use when a memory is flat wrong, was captured by mistake, or should never have been stored — not when it is merely a poor match for one query (that is downvote_memory, which keeps it around for a different question later). Deletion is irreversible and the id will not come back from another session's copy.",
319
+ inputSchema: {
320
+ type: "object",
321
+ properties: {
322
+ id: { type: "string", description: "The memory's id, from a search_memory or store_memory result." },
323
+ },
324
+ required: ["id"],
325
+ },
326
+ },
327
+ {
328
+ name: "refresh_memory",
329
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
330
+ description: "Re-anchor a STALE memory to the code as it stands now, keeping its id, hit count and derivedFrom links (storing a near-duplicate instead loses all three, and dedup often refuses it anyway). Call with just the id after you have verified the memory is still correct; pass filePaths/symbols instead when the code moved and it should track something new. Only call this once you have actually checked — it records your assertion that the memory is true today, it cannot verify that itself.",
331
+ inputSchema: {
332
+ type: "object",
333
+ properties: {
334
+ id: { type: "string", description: "The memory's id, from a search_memory or verify_memory result." },
335
+ filePaths: { type: "array", items: { type: "string" }, description: "New files to track instead of the current ones. Omit to re-hash whatever it already tracks." },
336
+ symbols: {
337
+ type: "array",
338
+ items: {
339
+ type: "object",
340
+ properties: {
341
+ filePath: { type: "string" },
342
+ symbolName: { type: "string" },
343
+ },
344
+ required: ["filePath", "symbolName"],
345
+ },
346
+ description: "New symbols to track instead of the current ones (e.g. the function was renamed or moved).",
347
+ },
348
+ },
349
+ required: ["id"],
350
+ },
351
+ },
352
+ {
353
+ name: "brain_stats",
354
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
355
+ description: "Health report for the Brain itself: entry count, how many memories no search has ever reused, how many were downvoted, what wrote them (manual vs. each auto-capture path), projects covered, and corpus size. Pass deep:true to also re-hash every tracked file and report the stale ratio — accurate but thousands of file reads on a large Brain.",
356
+ inputSchema: {
357
+ type: "object",
358
+ properties: {
359
+ deep: { type: "boolean", description: "Also compute the stale ratio by re-hashing all tracked evidence. Slow.", default: false },
360
+ },
361
+ },
362
+ },
363
+ {
364
+ name: "brain_export",
365
+ annotations: { readOnlyHint: true, idempotentHint: false, openWorldHint: false },
366
+ description: "Write memories to a portable NDJSON bundle for backup, moving to another machine, or sharing with a teammate. Defaults to this project's memories only, and to fresh ones only (a stale memory exported and imported elsewhere is just a wrong answer with a passport).",
367
+ inputSchema: {
368
+ type: "object",
369
+ properties: {
370
+ outPath: { type: "string", description: "Where to write the bundle (relative to the workspace root)." },
371
+ allProjects: { type: "boolean", description: "Export every project's memories, not just this one.", default: false },
372
+ domain: { type: "string", description: "Only export memories tagged with this domain." },
373
+ includeStale: { type: "boolean", description: "Include memories whose tracked evidence no longer matches.", default: false },
374
+ },
375
+ required: ["outPath"],
376
+ },
377
+ },
378
+ {
379
+ name: "brain_import",
380
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
381
+ description: "Merge a bundle written by brain_export into this Brain. Additive and non-destructive: an id already present keeps the newer version, and anything previously deleted with forget_memory stays deleted. Imported memories track the paths of the machine they came from, so most will read as stale here until refresh_memory re-anchors them.",
382
+ inputSchema: {
383
+ type: "object",
384
+ properties: {
385
+ path: { type: "string", description: "Path to the bundle file (relative to the workspace root)." },
386
+ },
387
+ required: ["path"],
388
+ },
389
+ },
310
390
  {
311
391
  name: "get_routing_advice",
312
392
  annotations: { readOnlyHint: true, openWorldHint: false },
@@ -1437,6 +1517,11 @@ const toolHandlers = {
1437
1517
  store_memory: handleStoreMemory,
1438
1518
  downvote_memory: handleDownvoteMemory,
1439
1519
  verify_memory: handleVerifyMemory,
1520
+ forget_memory: handleForgetMemory,
1521
+ refresh_memory: handleRefreshMemory,
1522
+ brain_stats: handleBrainStats,
1523
+ brain_export: handleBrainExport,
1524
+ brain_import: handleBrainImport,
1440
1525
  get_routing_advice: handleGetRoutingAdvice,
1441
1526
  auto_heal: handleAutoHeal,
1442
1527
  read_workspace_file: handleReadWorkspaceFile,
@@ -1715,7 +1800,9 @@ async function handleSearchMemory(args) {
1715
1800
  throw new Error("Query is required");
1716
1801
  try {
1717
1802
  const brain = getBrain();
1718
- const results = brain.search(query, limit, minSimilarity, { projectId: deriveProjectId(), domain, semanticDiff });
1803
+ // searchHybrid is search() plus one boolean check unless LEMMA_BRAIN_EMBEDDINGS is set,
1804
+ // so this costs nothing by default and picks up the semantic re-rank when it is enabled.
1805
+ const results = await brain.searchHybrid(query, limit, minSimilarity, { projectId: deriveProjectId(), domain, semanticDiff });
1719
1806
  if (results.length === 0) {
1720
1807
  recordReceiptEvent("reasoning", query.substring(0, 100), {
1721
1808
  tool: "search_memory",
@@ -1766,7 +1853,15 @@ async function handleSearchMemory(args) {
1766
1853
  }
1767
1854
  if (stale.length > 0) {
1768
1855
  const staleText = stale
1769
- .map((r, i) => `${formatResult(r, i)}\nSTALE — changed since stored: ${r.staleFiles.join(", ")}`)
1856
+ .map((r, i) => {
1857
+ // "You are on a different branch" and "someone rewrote this function" are the same
1858
+ // hash mismatch and completely different situations for the reader: the first is
1859
+ // usually not a reason to distrust the memory at all.
1860
+ const cause = r.staleCause === "branch-changed"
1861
+ ? `\nNOTE: stored on branch \`${r.storedOnBranch}\`, you are on \`${currentGitContext().branch || "an unknown branch"}\`. The difference may be the branch switch rather than an edit — check before discarding this.`
1862
+ : "";
1863
+ return `${formatResult(r, i)}\nSTALE — changed since stored: ${r.staleFiles.join(", ")}${cause}`;
1864
+ })
1770
1865
  .join("\n\n---\n\n");
1771
1866
  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}`);
1772
1867
  }
@@ -1800,7 +1895,7 @@ async function handleStoreMemory(args) {
1800
1895
  throw new Error("Query and response are required");
1801
1896
  try {
1802
1897
  const brain = getBrain();
1803
- const storeRes = brain.store(query, responseText, provider, 0.92, filePaths, undefined, outcome, symbols, claims, domain, derivedFrom);
1898
+ const storeRes = brain.store(query, responseText, provider, 0.92, filePaths, undefined, outcome, symbols, claims, domain, derivedFrom, { source: "manual" });
1804
1899
  // Storing a memory saves nothing — it only creates the chance of a saving later.
1805
1900
  // Crediting tokens here inflated the ledger on write and then credited the same
1806
1901
  // answer again on every read. The saving is booked by search_memory on a fresh hit.
@@ -1823,7 +1918,11 @@ async function handleStoreMemory(args) {
1823
1918
  ? `\n\n⚠️ ${storeRes.conflicts.length} existing ${storeRes.conflicts.length === 1 ? "memory shares" : "memories share"} a symbol with this one but disagree on outcome — review before trusting either:\n` +
1824
1919
  storeRes.conflicts.map((c) => ` - [${c.outcome}] ${c.id}: ${c.query.substring(0, 120)}`).join("\n")
1825
1920
  : "";
1826
- return { content: [{ type: "text", text: `Success: Memory stored. ${storeRes.reason}${trackingNote}${symbolNote}${outcomeNote}${claimsNote}${domainNote}${derivedFromNote}${conflictsNote}` }] };
1921
+ // The id is the handle for every follow-up action on this memory — derivedFrom on a
1922
+ // later store, verify_memory, refresh_memory, forget_memory. Without it the caller had
1923
+ // to search for the memory it had just written to do anything with it.
1924
+ const idNote = storeRes.id ? ` (id: ${storeRes.id})` : "";
1925
+ return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${outcomeNote}${claimsNote}${domainNote}${derivedFromNote}${conflictsNote}` }] };
1827
1926
  }
1828
1927
  catch (e) {
1829
1928
  logError("store_memory", e);
@@ -1843,6 +1942,138 @@ async function handleDownvoteMemory(args) {
1843
1942
  return { content: [{ type: "text", text: `Failed to downvote memory: ${e.message}` }] };
1844
1943
  }
1845
1944
  }
1945
+ /**
1946
+ * Deleting a memory is the one Brain operation with no undo, so it asks the client to
1947
+ * confirm where the client supports it, and echoes back what was destroyed where it doesn't
1948
+ * — an irreversible action must at minimum leave a record of what it removed.
1949
+ */
1950
+ async function handleForgetMemory(args) {
1951
+ const id = args?.id;
1952
+ if (!id)
1953
+ throw new Error("id is required");
1954
+ try {
1955
+ const brain = getBrain();
1956
+ const preview = brain.verifyByIds([id])[0];
1957
+ if (preview?.status === "unknown") {
1958
+ return { content: [{ type: "text", text: `No memory with id "${id}" in the Brain — nothing to delete.` }] };
1959
+ }
1960
+ const elicited = await tryElicitConfirmation(`Permanently delete Brain memory "${id}"? This cannot be undone.`);
1961
+ if (elicited.supported && !elicited.confirmed) {
1962
+ return { content: [{ type: "text", text: `Memory "${id}" was not deleted: declined during confirmation.` }] };
1963
+ }
1964
+ const result = brain.forget(id);
1965
+ if (!result.ok || !result.forgotten) {
1966
+ return { content: [{ type: "text", text: result.message }] };
1967
+ }
1968
+ return {
1969
+ content: [{
1970
+ type: "text",
1971
+ text: `${result.message}\n\nDeleted content, for the record (nothing else can recover it):\n stored: ${result.forgotten.timestamp}\n reused: ${result.forgotten.hits} time(s)\n query: ${result.forgotten.query.substring(0, 300)}`,
1972
+ }],
1973
+ };
1974
+ }
1975
+ catch (e) {
1976
+ logError("forget_memory", e);
1977
+ return { content: [{ type: "text", text: `Failed to delete memory: ${e.message}` }] };
1978
+ }
1979
+ }
1980
+ async function handleRefreshMemory(args) {
1981
+ const id = args?.id;
1982
+ if (!id)
1983
+ throw new Error("id is required");
1984
+ const filePaths = Array.isArray(args?.filePaths) ? args.filePaths.filter((p) => typeof p === "string" && p) : undefined;
1985
+ const symbols = Array.isArray(args?.symbols)
1986
+ ? args.symbols.filter((sym) => sym?.filePath && sym?.symbolName)
1987
+ : undefined;
1988
+ try {
1989
+ const result = getBrain().refresh(id, { filePaths, symbols });
1990
+ if (!result.ok)
1991
+ return { content: [{ type: "text", text: result.message }] };
1992
+ const retrackedNote = result.retracked && result.retracked.length > 0
1993
+ ? `\nNow tracking: ${result.retracked.join(", ")}`
1994
+ : "\nThis memory tracks no files or symbols, so there was nothing to re-anchor — its age clock was reset.";
1995
+ return { content: [{ type: "text", text: `${result.message}${retrackedNote}` }] };
1996
+ }
1997
+ catch (e) {
1998
+ logError("refresh_memory", e);
1999
+ return { content: [{ type: "text", text: `Failed to refresh memory: ${e.message}` }] };
2000
+ }
2001
+ }
2002
+ async function handleBrainStats(args) {
2003
+ try {
2004
+ const stats = getBrain().getStats({ deep: args?.deep === true });
2005
+ const lines = [];
2006
+ lines.push(`# Brain health`);
2007
+ lines.push(`Entries: ${stats.totalEntries} (${stats.totalTerms} indexed terms, ${((stats.corpusBytes || 0) / 1024).toFixed(0)} KB on disk)`);
2008
+ lines.push(`This session: ${stats.cacheHits} hit(s), ${stats.cacheMisses} miss(es)`);
2009
+ if (stats.totalEntries > 0) {
2010
+ const neverHitPct = ((stats.neverHit || 0) / stats.totalEntries) * 100;
2011
+ lines.push(`Never reused: ${stats.neverHit} (${neverHitPct.toFixed(0)}% — these are evicted first)`);
2012
+ lines.push(`Downvoted: ${stats.downvoted}`);
2013
+ lines.push(`Projects: ${stats.projects}${stats.unscopedEntries ? ` (+${stats.unscopedEntries} entries predating project scoping)` : ""}`);
2014
+ if (stats.oldestEntry)
2015
+ lines.push(`Oldest entry: ${stats.oldestEntry}`);
2016
+ if (stats.tombstones)
2017
+ lines.push(`Deleted ids still suppressed: ${stats.tombstones}`);
2018
+ const sources = Object.entries(stats.bySource || {}).sort((a, b) => b[1] - a[1]);
2019
+ if (sources.length > 0) {
2020
+ lines.push(`Written by: ${sources.map(([k, v]) => `${k}=${v}`).join(", ")}`);
2021
+ }
2022
+ }
2023
+ if (stats.staleEntries !== undefined) {
2024
+ lines.push(`Stale: ${stats.staleEntries} of the entries that track evidence (${((stats.staleRatio || 0) * 100).toFixed(0)}%) — refresh_memory re-anchors one, forget_memory drops it.`);
2025
+ }
2026
+ else {
2027
+ lines.push(`(stale ratio not computed — pass deep:true)`);
2028
+ }
2029
+ return { content: [{ type: "text", text: lines.join("\n") }] };
2030
+ }
2031
+ catch (e) {
2032
+ logError("brain_stats", e);
2033
+ return { content: [{ type: "text", text: `Failed to read Brain stats: ${e.message}` }] };
2034
+ }
2035
+ }
2036
+ async function handleBrainExport(args) {
2037
+ const outPath = args?.outPath;
2038
+ if (!outPath)
2039
+ throw new Error("outPath is required");
2040
+ try {
2041
+ const bundle = getBrain().exportBundle({
2042
+ // Scoped to this project unless asked otherwise: exporting every project's memories
2043
+ // by default is how a bundle meant for one teammate ends up carrying another client's
2044
+ // codebase notes with it.
2045
+ projectId: args?.allProjects === true ? undefined : deriveProjectId(),
2046
+ domain: typeof args?.domain === "string" && args.domain.trim() ? args.domain.trim() : undefined,
2047
+ includeStale: args?.includeStale === true,
2048
+ });
2049
+ const { resolved } = safeResolvePath(process.cwd(), outPath);
2050
+ fs.mkdirSync(path.dirname(resolved), { recursive: true });
2051
+ fs.writeFileSync(resolved, bundle.text, "utf8");
2052
+ const staleNote = bundle.skippedStale > 0
2053
+ ? ` Skipped ${bundle.skippedStale} stale memor${bundle.skippedStale === 1 ? "y" : "ies"} (pass includeStale:true to export those too).`
2054
+ : "";
2055
+ return { content: [{ type: "text", text: `Exported ${bundle.count} memor${bundle.count === 1 ? "y" : "ies"} to ${outPath}.${staleNote}` }] };
2056
+ }
2057
+ catch (e) {
2058
+ logError("brain_export", e);
2059
+ return { content: [{ type: "text", text: `Failed to export Brain: ${e.message}` }] };
2060
+ }
2061
+ }
2062
+ async function handleBrainImport(args) {
2063
+ const bundlePath = args?.path;
2064
+ if (!bundlePath)
2065
+ throw new Error("path is required");
2066
+ try {
2067
+ const { resolved } = safeResolvePath(process.cwd(), bundlePath);
2068
+ const text = fs.readFileSync(resolved, "utf8");
2069
+ const result = getBrain().importBundle(text);
2070
+ return { content: [{ type: "text", text: result.message }] };
2071
+ }
2072
+ catch (e) {
2073
+ logError("brain_import", e);
2074
+ return { content: [{ type: "text", text: `Failed to import Brain bundle: ${e.message}` }] };
2075
+ }
2076
+ }
1846
2077
  async function handleVerifyMemory(args) {
1847
2078
  const ids = Array.isArray(args?.ids) ? args.ids.filter((id) => typeof id === "string" && id) : [];
1848
2079
  const semanticDiff = args?.semanticDiff === true;
@@ -1904,7 +2135,7 @@ async function handleGetRoutingAdvice(args) {
1904
2135
  async function handleAutoHeal(args) {
1905
2136
  const apply = !!args?.apply;
1906
2137
  try {
1907
- const { performAutoHeal: heal } = await import("../cli/lemma-proxy.js");
2138
+ const { performAutoHeal: heal } = await import("../cli/lemma-proxy");
1908
2139
  const res = await heal(apply);
1909
2140
  return { content: [{ type: "text", text: JSON.stringify(res, null, 2) }] };
1910
2141
  }
@@ -2030,7 +2261,7 @@ async function handleReadWorkspaceFile(args) {
2030
2261
  `If you no longer hold that copy, re-fetch with force:true.`,
2031
2262
  ``,
2032
2263
  delta.body,
2033
- ].join("\n"),
2264
+ ].join("\n") + formatRecallNote(filePath),
2034
2265
  },
2035
2266
  ],
2036
2267
  };
@@ -2039,7 +2270,7 @@ async function handleReadWorkspaceFile(args) {
2039
2270
  }
2040
2271
  recordSent(resolved, view, dedup.hash, content);
2041
2272
  warmNeighbors(workspaceRoot, resolved);
2042
- return { content: [{ type: "text", text: rangeHeader + content }] };
2273
+ return { content: [{ type: "text", text: rangeHeader + content + formatRecallNote(filePath) }] };
2043
2274
  }
2044
2275
  catch (err) {
2045
2276
  logError("read_workspace_file", err);
@@ -2129,6 +2360,46 @@ function formatBlastRadiusNote(result) {
2129
2360
  const failedIds = result.failedHits.map((h) => h.id).join(", ");
2130
2361
  return `${base}\n⚠️ ${result.failedHits.length} of those document a PRIOR ATTEMPT THAT FAILED on related code: ${failedIds}. Review before continuing down this path.`;
2131
2362
  }
2363
+ /**
2364
+ * The read-side counterpart to formatBlastRadiusNote.
2365
+ *
2366
+ * Fase E made the write path proactive: a tool that stales memories says so on the spot.
2367
+ * The read path stayed entirely opt-in — the Brain only spoke when the agent remembered to
2368
+ * call search_memory, which is exactly the moment an agent that doesn't know a memory exists
2369
+ * has no reason to. This closes that asymmetry: reading code the Brain already has notes on
2370
+ * surfaces them, including any documented dead end, before the investigation restarts from
2371
+ * scratch.
2372
+ *
2373
+ * Same rules as the write-side note: advisory only, never blocks, never mutates, and adds no
2374
+ * tool schema (it enriches an existing response), so it costs nothing per turn. It reports
2375
+ * ids rather than content — pulling whole memories into every file read would spend far more
2376
+ * context than it saves; search_memory or verify_memory fetches the ones that matter.
2377
+ */
2378
+ const _recallNoted = new Set();
2379
+ function formatRecallNote(filePath, symbolName) {
2380
+ try {
2381
+ const result = getBrain().findBlastRadius(filePath, symbolName);
2382
+ if (result.hits.length === 0)
2383
+ return "";
2384
+ // Repeating the identical note on every read of the same file is nagging, not signal.
2385
+ // Keyed by the memory set, so a note reappears when the set genuinely changes.
2386
+ const ids = result.hits.map((h) => h.id).sort();
2387
+ const key = `${path.resolve(filePath)}::${symbolName || ""}::${ids.join(",")}`;
2388
+ if (_recallNoted.has(key))
2389
+ return "";
2390
+ _recallNoted.add(key);
2391
+ const subject = symbolName ? `\`${symbolName}\`` : "this file";
2392
+ const base = `\n\n🧠 The Brain already has ${result.hits.length} memor${result.hits.length === 1 ? "y" : "ies"} about ${subject}: ${ids.join(", ")}. Call verify_memory on them before investigating from scratch.`;
2393
+ if (result.failedHits.length === 0)
2394
+ return base;
2395
+ const failedIds = result.failedHits.map((h) => h.id).join(", ");
2396
+ return `${base}\n⚠️ ${result.failedHits.length} of those document an approach that was tried here and FAILED: ${failedIds}. Read those first so you don't repeat it.`;
2397
+ }
2398
+ catch {
2399
+ // A recall note must never be the reason a file read fails.
2400
+ return "";
2401
+ }
2402
+ }
2132
2403
  async function applyMatch(match, filePath, resolved, originalContent, searchContent, replaceContent) {
2133
2404
  let updatedContent;
2134
2405
  if (match.strategy === "exact" && match.charStart !== undefined && match.charEnd !== undefined) {
@@ -2694,11 +2965,27 @@ function buildLocalOnboarding(cwd) {
2694
2965
  catch { /* brain unavailable */ }
2695
2966
  return lines.join("\n");
2696
2967
  }
2968
+ // Re-exported for callers/tests that already import detectExpectedProjectName from here —
2969
+ // the actual implementation lives in ../utils/ProjectIdentity, shared with the proxy daemon
2970
+ // (src/cli/lemma-proxy.ts) so both sides compute "project name" exactly one way.
2971
+ export const detectExpectedProjectName = detectProjectName;
2697
2972
  async function handleGetProjectOnboarding(_args) {
2698
2973
  const cwd = process.cwd();
2699
2974
  try {
2700
2975
  const port = getProxyPort();
2701
- const response = await axios.get(`http://localhost:${port}/api/project/onboarding`, { timeout: 2000 });
2976
+ // The proxy daemon is one global process per machine, tracked by a single shared
2977
+ // ~/.lemma-cache/proxy.port file — every MCP client on the box points at whichever
2978
+ // daemon happens to be listening there, regardless of which project it's actually
2979
+ // running in. Its project identity is fixed to whatever cwd IT was started from, not
2980
+ // ours. Without expectedProject, a daemon started for a different project answers with
2981
+ // THAT project's stack/files/memories — a real cross-project data leak, not a cosmetic
2982
+ // bug. The route only returns `markdown` when this matches; otherwise we fall through
2983
+ // to the local (always correctly-scoped) generator below.
2984
+ const expectedProject = detectExpectedProjectName(cwd);
2985
+ const response = await axios.get(`http://localhost:${port}/api/project/onboarding`, {
2986
+ timeout: 2000,
2987
+ params: { expectedProject },
2988
+ });
2702
2989
  if (response.data?.markdown) {
2703
2990
  return { content: [{ type: "text", text: response.data.markdown }] };
2704
2991
  }
@@ -3223,30 +3510,31 @@ async function handleBatchToolCalls(args) {
3223
3510
  // ── TurboSqueeze ─────────────────────────────────────────────────
3224
3511
  async function handleTurboSqueeze(args) {
3225
3512
  const text = args?.text;
3226
- const stripComments = args?.stripComments !== false;
3227
- const stripImports = args?.stripImports !== false;
3513
+ const wantStripComments = args?.stripComments !== false;
3514
+ const wantStripImports = args?.stripImports !== false;
3228
3515
  const compactJson = args?.compactJson !== false;
3229
3516
  if (!text)
3230
3517
  throw new Error("text is required");
3518
+ // Delegates to the same stripComments/stripImports/compactWhitespace primitives
3519
+ // squeeze_prompt and the proxy's own cache-miss path use — this used to be a second,
3520
+ // independent regex implementation of the same job that had drifted out of sync: its
3521
+ // naive `//.*$` comment strip mangled any line containing a URL (http://, https://),
3522
+ // a case the shared stripComments already guards against. One implementation now.
3231
3523
  let squeezed = text;
3232
- // Strip multi-line comments
3233
- if (stripComments) {
3234
- squeezed = squeezed.replace(/\/\*[\s\S]*?\*\//g, '');
3235
- squeezed = squeezed.replace(/\/\/.*$/gm, '');
3236
- }
3237
- // Remove empty lines and trim whitespace
3238
- squeezed = squeezed.replace(/^\s*[\r\n]/gm, '\n');
3239
- squeezed = squeezed.replace(/^[ \t]+/gm, ' ');
3240
- squeezed = squeezed.replace(/[ \t]+$/gm, '');
3241
- // Strip imports
3242
- if (stripImports) {
3243
- squeezed = squeezed.replace(/^import\s+[\s\S]*?from\s+['"][\w@\/\.-]+['"];?\s*$/gm, '');
3244
- squeezed = squeezed.replace(/^import\s+['"][\w@\/\.-]+['"];?\s*$/gm, '');
3245
- squeezed = squeezed.replace(/^const\s+\w+\s*=\s*require\(['"][\w@\/\.-]+['"]\);?\s*$/gm, '');
3246
- squeezed = squeezed.replace(/^require\(['"][\w@\/\.-]+['"]\);?\s*$/gm, '');
3247
- }
3248
- // Compact JSON
3249
- if (compactJson) {
3524
+ if (wantStripComments)
3525
+ squeezed = stripComments(squeezed);
3526
+ if (wantStripImports)
3527
+ squeezed = stripImports(squeezed);
3528
+ squeezed = compactWhitespace(squeezed);
3529
+ // Compact JSON the one genuinely turbosqueeze-specific step, kept as-is, but only when
3530
+ // the input actually looks like JSON. Pre-existing bug found while consolidating this
3531
+ // function: these regexes ran unconditionally whenever compactJson wasn't explicitly
3532
+ // false, so ordinary code went through them too — `{ foo }` in an import statement came
3533
+ // out as `{foo}`, and the same regexes would just as happily squash braces in real
3534
+ // control-flow code. Gate on the input's own shape instead of trusting the caller only
3535
+ // ever sets compactJson for genuine JSON.
3536
+ const looksLikeJson = /^\s*[[{]/.test(squeezed);
3537
+ if (compactJson && looksLikeJson) {
3250
3538
  squeezed = squeezed.replace(/"\s*:\s*/g, '":');
3251
3539
  squeezed = squeezed.replace(/,\s*"/g, ',"');
3252
3540
  squeezed = squeezed.replace(/\[\s+/g, '[');
@@ -3259,7 +3547,7 @@ async function handleTurboSqueeze(args) {
3259
3547
  const ratio = text.length > 0 ? ((1 - squeezed.length / text.length) * 100).toFixed(1) : "0";
3260
3548
  const saved = Math.max(0, text.length - squeezed.length);
3261
3549
  try {
3262
- const { reportSavings } = await import("../utils/reportSavings.js");
3550
+ const { reportSavings } = await import("../utils/reportSavings");
3263
3551
  reportSavings({ source: "contextSqueeze", charsBefore: text.length, charsAfter: squeezed.length, toolName: "turbosqueeze" });
3264
3552
  }
3265
3553
  catch { }
@@ -3304,7 +3592,7 @@ async function handleCompressContext(args) {
3304
3592
  ...recent,
3305
3593
  ];
3306
3594
  try {
3307
- const { reportSavings } = await import("../utils/reportSavings.js");
3595
+ const { reportSavings } = await import("../utils/reportSavings");
3308
3596
  reportSavings({ source: "historyPrune", tokens: tokensSaved, toolName: "compress_context" });
3309
3597
  }
3310
3598
  catch { }
@@ -3331,7 +3619,7 @@ async function handleSmarterCache(args) {
3331
3619
  const responseText = topHit.response;
3332
3620
  const tokensSaved = Math.floor(responseText.length / 4);
3333
3621
  try {
3334
- const { reportSavings } = await import("../utils/reportSavings.js");
3622
+ const { reportSavings } = await import("../utils/reportSavings");
3335
3623
  reportSavings({ source: "cache", tokens: tokensSaved, toolName: "smarter_cache", query: query.substring(0, 100) });
3336
3624
  }
3337
3625
  catch { }
@@ -5047,7 +5335,7 @@ async function handleGetSymbolSurgicalContext(args) {
5047
5335
  filePath
5048
5336
  });
5049
5337
  return {
5050
- content: [{ type: "text", text: output }]
5338
+ content: [{ type: "text", text: output + formatRecallNote(filePath, symbolName) }]
5051
5339
  };
5052
5340
  }
5053
5341
  catch (err) {
@@ -5228,7 +5516,7 @@ async function handleSmartFileSlice(args) {
5228
5516
  resultText += `${i + 1}: ${lines[i]}\n`;
5229
5517
  }
5230
5518
  });
5231
- return { content: [{ type: "text", text: resultText }] };
5519
+ return { content: [{ type: "text", text: resultText + formatRecallNote(filePath) }] };
5232
5520
  }
5233
5521
  catch (e) {
5234
5522
  return { content: [{ type: "text", text: `Error slicing file: ${e.message}` }] };
@@ -5256,7 +5544,7 @@ function autoStoreGreenTests(command, workspaceRoot) {
5256
5544
  const domain = deriveDomainForFile(changed[0]);
5257
5545
  const query = `tests passing after changes to ${changed.slice(0, 5).join(", ")}${changed.length > 5 ? ` and ${changed.length - 5} more file(s)` : ""}`;
5258
5546
  const response = `\`${command}\` passed with these files changed (uncommitted at capture time):\n${changed.join("\n")}`;
5259
- const storeRes = getBrain().store(query, response, "test_oracle_auto", 0.92, changed, undefined, "confirmed", undefined, undefined, domain);
5547
+ const storeRes = getBrain().store(query, response, "test_oracle_auto", 0.92, changed, undefined, "confirmed", undefined, undefined, domain, undefined, { source: "auto-test" });
5260
5548
  if (!storeRes.stored)
5261
5549
  return "";
5262
5550
  return `\n\n[Lemma] Auto-captured this green state in Brain (${changed.length} file(s), tagged confirmed) — search_memory will surface it, and will flag it stale the moment any of these files change again.`;