@cachly-dev/mcp-server 0.10.56 โ†’ 0.10.58

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 (338) hide show
  1. package/.github/workflows/eas-build-android.yml +58 -0
  2. package/.github/workflows/eas-update.yml +55 -0
  3. package/.github/workflows/publish.yml +2 -2
  4. package/BENCH.md +91 -0
  5. package/CHANGELOG.md +44 -0
  6. package/README.md +6 -34
  7. package/STRATEGY.md +228 -0
  8. package/apps/travel-chaos-organizer/.env.example +49 -0
  9. package/apps/travel-chaos-organizer/DEPLOY.md +328 -0
  10. package/apps/travel-chaos-organizer/Makefile +57 -0
  11. package/apps/travel-chaos-organizer/README.md +159 -0
  12. package/apps/travel-chaos-organizer/backend/.env.example +10 -0
  13. package/apps/travel-chaos-organizer/backend/Dockerfile +25 -0
  14. package/apps/travel-chaos-organizer/backend/alembic/env.py +56 -0
  15. package/apps/travel-chaos-organizer/backend/alembic/script.py.mako +24 -0
  16. package/apps/travel-chaos-organizer/backend/alembic/versions/.gitkeep +0 -0
  17. package/apps/travel-chaos-organizer/backend/alembic/versions/0001_stripe_customer_id.py +24 -0
  18. package/apps/travel-chaos-organizer/backend/alembic/versions/0002_telegram_chat_id.py +24 -0
  19. package/apps/travel-chaos-organizer/backend/alembic.ini +39 -0
  20. package/apps/travel-chaos-organizer/backend/app/__init__.py +0 -0
  21. package/apps/travel-chaos-organizer/backend/app/auth/__init__.py +0 -0
  22. package/apps/travel-chaos-organizer/backend/app/auth/keycloak.py +81 -0
  23. package/apps/travel-chaos-organizer/backend/app/config.py +66 -0
  24. package/apps/travel-chaos-organizer/backend/app/db/__init__.py +0 -0
  25. package/apps/travel-chaos-organizer/backend/app/db/database.py +20 -0
  26. package/apps/travel-chaos-organizer/backend/app/db/migrations/001_init.sql +71 -0
  27. package/apps/travel-chaos-organizer/backend/app/db/migrations/002_telemetry_freemium.sql +31 -0
  28. package/apps/travel-chaos-organizer/backend/app/db/migrations/003_telegram_chat_id.sql +4 -0
  29. package/apps/travel-chaos-organizer/backend/app/db/migrations/004_stripe_and_email.sql +5 -0
  30. package/apps/travel-chaos-organizer/backend/app/limiter.py +4 -0
  31. package/apps/travel-chaos-organizer/backend/app/logging_config.py +25 -0
  32. package/apps/travel-chaos-organizer/backend/app/main.py +77 -0
  33. package/apps/travel-chaos-organizer/backend/app/models/__init__.py +0 -0
  34. package/apps/travel-chaos-organizer/backend/app/models/schemas.py +142 -0
  35. package/apps/travel-chaos-organizer/backend/app/routers/__init__.py +0 -0
  36. package/apps/travel-chaos-organizer/backend/app/routers/admin.py +237 -0
  37. package/apps/travel-chaos-organizer/backend/app/routers/cache.py +13 -0
  38. package/apps/travel-chaos-organizer/backend/app/routers/events.py +29 -0
  39. package/apps/travel-chaos-organizer/backend/app/routers/export.py +122 -0
  40. package/apps/travel-chaos-organizer/backend/app/routers/inbox.py +122 -0
  41. package/apps/travel-chaos-organizer/backend/app/routers/items.py +130 -0
  42. package/apps/travel-chaos-organizer/backend/app/routers/mail.py +108 -0
  43. package/apps/travel-chaos-organizer/backend/app/routers/parse.py +303 -0
  44. package/apps/travel-chaos-organizer/backend/app/routers/payments.py +179 -0
  45. package/apps/travel-chaos-organizer/backend/app/routers/trips.py +134 -0
  46. package/apps/travel-chaos-organizer/backend/app/routers/users.py +169 -0
  47. package/apps/travel-chaos-organizer/backend/app/routers/waitlist.py +37 -0
  48. package/apps/travel-chaos-organizer/backend/app/services/__init__.py +0 -0
  49. package/apps/travel-chaos-organizer/backend/app/services/cache.py +131 -0
  50. package/apps/travel-chaos-organizer/backend/app/services/drip.py +128 -0
  51. package/apps/travel-chaos-organizer/backend/app/services/email.py +61 -0
  52. package/apps/travel-chaos-organizer/backend/app/services/errors.py +44 -0
  53. package/apps/travel-chaos-organizer/backend/app/services/notifier.py +10 -0
  54. package/apps/travel-chaos-organizer/backend/app/services/ollama.py +101 -0
  55. package/apps/travel-chaos-organizer/backend/app/services/parser.py +22 -0
  56. package/apps/travel-chaos-organizer/backend/app/services/quota.py +85 -0
  57. package/apps/travel-chaos-organizer/backend/app/services/sentry.py +11 -0
  58. package/apps/travel-chaos-organizer/backend/app/services/telemetry.py +35 -0
  59. package/apps/travel-chaos-organizer/backend/pytest.ini +4 -0
  60. package/apps/travel-chaos-organizer/backend/requirements-dev.txt +6 -0
  61. package/apps/travel-chaos-organizer/backend/requirements.txt +25 -0
  62. package/apps/travel-chaos-organizer/backend/tests/__init__.py +0 -0
  63. package/apps/travel-chaos-organizer/backend/tests/conftest.py +223 -0
  64. package/apps/travel-chaos-organizer/backend/tests/test_admin.py +99 -0
  65. package/apps/travel-chaos-organizer/backend/tests/test_cache.py +142 -0
  66. package/apps/travel-chaos-organizer/backend/tests/test_drip.py +32 -0
  67. package/apps/travel-chaos-organizer/backend/tests/test_e2e_chain.py +121 -0
  68. package/apps/travel-chaos-organizer/backend/tests/test_export.py +48 -0
  69. package/apps/travel-chaos-organizer/backend/tests/test_inbox.py +107 -0
  70. package/apps/travel-chaos-organizer/backend/tests/test_items.py +138 -0
  71. package/apps/travel-chaos-organizer/backend/tests/test_mail.py +113 -0
  72. package/apps/travel-chaos-organizer/backend/tests/test_ollama.py +145 -0
  73. package/apps/travel-chaos-organizer/backend/tests/test_parse_url.py +98 -0
  74. package/apps/travel-chaos-organizer/backend/tests/test_parser.py +72 -0
  75. package/apps/travel-chaos-organizer/backend/tests/test_payments.py +163 -0
  76. package/apps/travel-chaos-organizer/backend/tests/test_quota.py +46 -0
  77. package/apps/travel-chaos-organizer/backend/tests/test_search.py +67 -0
  78. package/apps/travel-chaos-organizer/backend/tests/test_trips.py +123 -0
  79. package/apps/travel-chaos-organizer/backend/tests/test_users.py +52 -0
  80. package/apps/travel-chaos-organizer/backups/.gitkeep +0 -0
  81. package/apps/travel-chaos-organizer/caddy/Caddyfile +27 -0
  82. package/apps/travel-chaos-organizer/docker-compose.node1.yml +31 -0
  83. package/apps/travel-chaos-organizer/docker-compose.override.yml +14 -0
  84. package/apps/travel-chaos-organizer/docker-compose.yml +128 -0
  85. package/apps/travel-chaos-organizer/frontend/.env.example +13 -0
  86. package/apps/travel-chaos-organizer/frontend/app/(app)/_layout.tsx +80 -0
  87. package/apps/travel-chaos-organizer/frontend/app/(app)/inbox.tsx +166 -0
  88. package/apps/travel-chaos-organizer/frontend/app/(app)/search.tsx +130 -0
  89. package/apps/travel-chaos-organizer/frontend/app/(app)/settings.tsx +381 -0
  90. package/apps/travel-chaos-organizer/frontend/app/(app)/trips/[id].tsx +346 -0
  91. package/apps/travel-chaos-organizer/frontend/app/(app)/trips.tsx +363 -0
  92. package/apps/travel-chaos-organizer/frontend/app/(app)/upgrade/cancel.tsx +34 -0
  93. package/apps/travel-chaos-organizer/frontend/app/(app)/upgrade/success.tsx +35 -0
  94. package/apps/travel-chaos-organizer/frontend/app/(auth)/login.tsx +91 -0
  95. package/apps/travel-chaos-organizer/frontend/app/_layout.tsx +71 -0
  96. package/apps/travel-chaos-organizer/frontend/app/auth.tsx +29 -0
  97. package/apps/travel-chaos-organizer/frontend/app/index.tsx +16 -0
  98. package/apps/travel-chaos-organizer/frontend/app/onboarding.tsx +119 -0
  99. package/apps/travel-chaos-organizer/frontend/app.config.ts +54 -0
  100. package/apps/travel-chaos-organizer/frontend/assets/adaptive-icon.svg +66 -0
  101. package/apps/travel-chaos-organizer/frontend/assets/icon.svg +79 -0
  102. package/apps/travel-chaos-organizer/frontend/assets/splash.svg +15 -0
  103. package/apps/travel-chaos-organizer/frontend/components/BottomSheet.tsx +102 -0
  104. package/apps/travel-chaos-organizer/frontend/components/ConfettiCannon.tsx +107 -0
  105. package/apps/travel-chaos-organizer/frontend/components/ConfirmDialog.tsx +109 -0
  106. package/apps/travel-chaos-organizer/frontend/components/ErrorBoundary.tsx +45 -0
  107. package/apps/travel-chaos-organizer/frontend/components/FileUploadButton.tsx +19 -0
  108. package/apps/travel-chaos-organizer/frontend/components/ImportSheet.tsx +155 -0
  109. package/apps/travel-chaos-organizer/frontend/components/OfflineBadge.tsx +55 -0
  110. package/apps/travel-chaos-organizer/frontend/components/QRCodeViewer.tsx +80 -0
  111. package/apps/travel-chaos-organizer/frontend/components/ScoreRing.tsx +39 -0
  112. package/apps/travel-chaos-organizer/frontend/components/Screen.tsx +39 -0
  113. package/apps/travel-chaos-organizer/frontend/components/Skeleton.tsx +70 -0
  114. package/apps/travel-chaos-organizer/frontend/components/SwipeableInboxItem.tsx +121 -0
  115. package/apps/travel-chaos-organizer/frontend/components/SwipeableTimelineItem.tsx +70 -0
  116. package/apps/travel-chaos-organizer/frontend/components/TimelineItem.tsx +73 -0
  117. package/apps/travel-chaos-organizer/frontend/components/TimelineItemDetail.tsx +130 -0
  118. package/apps/travel-chaos-organizer/frontend/components/Toast.tsx +60 -0
  119. package/apps/travel-chaos-organizer/frontend/components/ToastContext.tsx +42 -0
  120. package/apps/travel-chaos-organizer/frontend/components/TripCard.tsx +146 -0
  121. package/apps/travel-chaos-organizer/frontend/components/TripQRModal.tsx +70 -0
  122. package/apps/travel-chaos-organizer/frontend/components/UpgradeBanner.tsx +44 -0
  123. package/apps/travel-chaos-organizer/frontend/eas.json +22 -0
  124. package/apps/travel-chaos-organizer/frontend/hooks/useInbox.ts +24 -0
  125. package/apps/travel-chaos-organizer/frontend/hooks/useNetworkSync.ts +60 -0
  126. package/apps/travel-chaos-organizer/frontend/hooks/useTrips.ts +112 -0
  127. package/apps/travel-chaos-organizer/frontend/lib/api.ts +223 -0
  128. package/apps/travel-chaos-organizer/frontend/lib/auth.ts +93 -0
  129. package/apps/travel-chaos-organizer/frontend/lib/db.ts +86 -0
  130. package/apps/travel-chaos-organizer/frontend/lib/fileCache.ts +54 -0
  131. package/apps/travel-chaos-organizer/frontend/lib/haptics.ts +13 -0
  132. package/apps/travel-chaos-organizer/frontend/lib/notifications.ts +112 -0
  133. package/apps/travel-chaos-organizer/frontend/lib/offlineQueue.ts +145 -0
  134. package/apps/travel-chaos-organizer/frontend/lib/quota.tsx +43 -0
  135. package/apps/travel-chaos-organizer/frontend/lib/sentry.ts +28 -0
  136. package/apps/travel-chaos-organizer/frontend/lib/shareIntent.ts +44 -0
  137. package/apps/travel-chaos-organizer/frontend/package-lock.json +13221 -0
  138. package/apps/travel-chaos-organizer/frontend/package.json +44 -0
  139. package/apps/travel-chaos-organizer/frontend/tsconfig.json +23 -0
  140. package/apps/travel-chaos-organizer/keycloak/realm-export.json +59 -0
  141. package/apps/travel-chaos-organizer/landing/index.html +773 -0
  142. package/apps/travel-chaos-organizer/scripts/backup.sh +14 -0
  143. package/apps/travel-chaos-organizer/scripts/configure-env.sh +82 -0
  144. package/apps/travel-chaos-organizer/scripts/deploy.sh +54 -0
  145. package/apps/travel-chaos-organizer/scripts/health-check.sh +36 -0
  146. package/apps/travel-chaos-organizer/scripts/migrate.sh +7 -0
  147. package/apps/travel-chaos-organizer/scripts/server-setup.sh +85 -0
  148. package/apps/travel-chaos-organizer/scripts/smoke-test.sh +29 -0
  149. package/apps/travel-chaos-organizer/scripts/verify-tracking.sh +71 -0
  150. package/apps/travel-chaos-organizer/telegram-bot/.env.example +3 -0
  151. package/apps/travel-chaos-organizer/telegram-bot/Dockerfile +6 -0
  152. package/apps/travel-chaos-organizer/telegram-bot/bot.py +504 -0
  153. package/apps/travel-chaos-organizer/telegram-bot/requirements.txt +3 -0
  154. package/dist/packages/telegram-notify/client.d.ts +19 -0
  155. package/dist/packages/telegram-notify/client.js +75 -0
  156. package/dist/packages/telegram-notify/client.js.map +1 -0
  157. package/dist/src/__tests__/auth.test.js.map +1 -0
  158. package/dist/{__tests__ โ†’ src/__tests__}/brain-flow.test.js +141 -0
  159. package/dist/src/__tests__/brain-flow.test.js.map +1 -0
  160. package/dist/src/__tests__/confidence.test.js.map +1 -0
  161. package/dist/src/__tests__/e2e/api-auth.test.js.map +1 -0
  162. package/dist/src/__tests__/e2e/api-health.test.js.map +1 -0
  163. package/dist/src/__tests__/e2e/cli.test.js.map +1 -0
  164. package/dist/src/__tests__/e2e/config.js.map +1 -0
  165. package/dist/src/__tests__/e2e/funnel.test.js.map +1 -0
  166. package/dist/src/__tests__/e2e/mcp-tools.test.js.map +1 -0
  167. package/dist/src/__tests__/e2e/provisioning.test.js.map +1 -0
  168. package/dist/{__tests__ โ†’ src/__tests__}/handlers-unit.test.js +0 -2
  169. package/dist/src/__tests__/handlers-unit.test.js.map +1 -0
  170. package/dist/src/__tests__/namespace.test.js.map +1 -0
  171. package/dist/src/__tests__/rerank.test.js +115 -0
  172. package/dist/src/__tests__/rerank.test.js.map +1 -0
  173. package/dist/src/auth.js.map +1 -0
  174. package/dist/src/bench/cachly-bench.d.ts +35 -0
  175. package/dist/src/bench/cachly-bench.js +182 -0
  176. package/dist/src/bench/cachly-bench.js.map +1 -0
  177. package/dist/src/bench/fixtures.d.ts +37 -0
  178. package/dist/src/bench/fixtures.js +225 -0
  179. package/dist/src/bench/fixtures.js.map +1 -0
  180. package/dist/src/ckg.js.map +1 -0
  181. package/dist/src/confidence.js.map +1 -0
  182. package/dist/src/embeddings.js.map +1 -0
  183. package/dist/{handlers โ†’ src/handlers}/advanced.d.ts +1 -1
  184. package/dist/{handlers โ†’ src/handlers}/advanced.js +1 -2
  185. package/dist/src/handlers/advanced.js.map +1 -0
  186. package/dist/{handlers โ†’ src/handlers}/brain.js +361 -191
  187. package/dist/src/handlers/brain.js.map +1 -0
  188. package/dist/src/handlers/cache.js.map +1 -0
  189. package/dist/{handlers โ†’ src/handlers}/context.js +9 -4
  190. package/dist/src/handlers/context.js.map +1 -0
  191. package/dist/{handlers โ†’ src/handlers}/fedbrain.d.ts +6 -0
  192. package/dist/{handlers โ†’ src/handlers}/fedbrain.js +19 -7
  193. package/dist/src/handlers/fedbrain.js.map +1 -0
  194. package/dist/src/handlers/instances.js.map +1 -0
  195. package/dist/{handlers โ†’ src/handlers}/roadmap.d.ts +1 -1
  196. package/dist/{handlers โ†’ src/handlers}/roadmap.js +8 -4
  197. package/dist/src/handlers/roadmap.js.map +1 -0
  198. package/dist/src/handlers/syndicate.js.map +1 -0
  199. package/dist/src/handlers/tco.d.ts +16 -0
  200. package/dist/src/handlers/tco.js +303 -0
  201. package/dist/src/handlers/tco.js.map +1 -0
  202. package/dist/{handlers โ†’ src/handlers}/team.js +58 -7
  203. package/dist/src/handlers/team.js.map +1 -0
  204. package/dist/{index.js โ†’ src/index.js} +207 -429
  205. package/dist/src/index.js.map +1 -0
  206. package/dist/src/namespace.js.map +1 -0
  207. package/dist/src/notifier.d.ts +5 -0
  208. package/dist/src/notifier.js +6 -0
  209. package/dist/src/notifier.js.map +1 -0
  210. package/dist/src/rerank.d.ts +55 -0
  211. package/dist/src/rerank.js +111 -0
  212. package/dist/src/rerank.js.map +1 -0
  213. package/dist/{search.js โ†’ src/search.js} +2 -2
  214. package/dist/src/search.js.map +1 -0
  215. package/dist/src/search.test.d.ts +1 -0
  216. package/dist/{search.test.js โ†’ src/search.test.js} +1 -1
  217. package/dist/src/search.test.js.map +1 -0
  218. package/dist/{tools.d.ts โ†’ src/tools.d.ts} +226 -0
  219. package/dist/{tools.js โ†’ src/tools.js} +196 -0
  220. package/dist/src/tools.js.map +1 -0
  221. package/dist/src/utils.js.map +1 -0
  222. package/eslint.config.js +1 -1
  223. package/package.json +8 -7
  224. package/packages/telegram-notify/SPLIT_PLAN.md +106 -0
  225. package/packages/telegram-notify/client.ts +88 -0
  226. package/packages/telegram-notify/emojis.json +22 -0
  227. package/packages/telegram-notify/pyproject.toml +17 -0
  228. package/packages/telegram-notify/telegram_notify/__init__.py +3 -0
  229. package/packages/telegram-notify/telegram_notify/client.py +87 -0
  230. package/packages/telegram-notify/telegram_notify/emojis.json +22 -0
  231. package/scripts/generate-icons.js +28 -0
  232. package/server.json +3 -3
  233. package/smithery.yaml +27 -16
  234. package/src/__tests__/auth.test.ts +1 -1
  235. package/src/__tests__/brain-flow.test.ts +175 -1
  236. package/src/__tests__/e2e/api-health.test.ts +1 -1
  237. package/src/__tests__/handlers-unit.test.ts +1 -2
  238. package/src/__tests__/rerank.test.ts +130 -0
  239. package/src/bench/cachly-bench.ts +217 -0
  240. package/src/bench/fixtures.ts +256 -0
  241. package/src/handlers/advanced.ts +2 -6
  242. package/src/handlers/brain.ts +371 -194
  243. package/src/handlers/cache.ts +1 -2
  244. package/src/handlers/context.ts +10 -6
  245. package/src/handlers/fedbrain.ts +21 -12
  246. package/src/handlers/roadmap.ts +8 -4
  247. package/src/handlers/syndicate.ts +7 -4
  248. package/src/handlers/tco.ts +345 -0
  249. package/src/handlers/team.ts +70 -10
  250. package/src/index.ts +193 -419
  251. package/src/notifier.ts +5 -0
  252. package/src/rerank.ts +148 -0
  253. package/src/search.test.ts +1 -1
  254. package/src/search.ts +2 -2
  255. package/src/tools.ts +210 -0
  256. package/tsconfig.json +2 -3
  257. package/vitest.config.ts +2 -0
  258. package/dist/__tests__/auth.test.js.map +0 -1
  259. package/dist/__tests__/brain-flow.test.js.map +0 -1
  260. package/dist/__tests__/brain-predict-failures.test.d.ts +0 -17
  261. package/dist/__tests__/brain-predict-failures.test.js +0 -339
  262. package/dist/__tests__/brain-predict-failures.test.js.map +0 -1
  263. package/dist/__tests__/confidence.test.js.map +0 -1
  264. package/dist/__tests__/e2e/api-auth.test.js.map +0 -1
  265. package/dist/__tests__/e2e/api-health.test.js.map +0 -1
  266. package/dist/__tests__/e2e/cli.test.js.map +0 -1
  267. package/dist/__tests__/e2e/config.js.map +0 -1
  268. package/dist/__tests__/e2e/funnel.test.js.map +0 -1
  269. package/dist/__tests__/e2e/mcp-tools.test.js.map +0 -1
  270. package/dist/__tests__/e2e/provisioning.test.js.map +0 -1
  271. package/dist/__tests__/handlers-unit.test.js.map +0 -1
  272. package/dist/__tests__/namespace.test.js.map +0 -1
  273. package/dist/auth.js.map +0 -1
  274. package/dist/ckg.js.map +0 -1
  275. package/dist/confidence.js.map +0 -1
  276. package/dist/embeddings.js.map +0 -1
  277. package/dist/handlers/advanced.js.map +0 -1
  278. package/dist/handlers/brain.js.map +0 -1
  279. package/dist/handlers/cache.js.map +0 -1
  280. package/dist/handlers/context.js.map +0 -1
  281. package/dist/handlers/fedbrain.js.map +0 -1
  282. package/dist/handlers/instances.js.map +0 -1
  283. package/dist/handlers/roadmap.js.map +0 -1
  284. package/dist/handlers/syndicate.js.map +0 -1
  285. package/dist/handlers/team.js.map +0 -1
  286. package/dist/index.js.map +0 -1
  287. package/dist/namespace.js.map +0 -1
  288. package/dist/search.js.map +0 -1
  289. package/dist/search.test.js.map +0 -1
  290. package/dist/tools.js.map +0 -1
  291. package/dist/utils.js.map +0 -1
  292. package/src/__tests__/brain-predict-failures.test.ts +0 -430
  293. /package/dist/{__tests__ โ†’ src/__tests__}/auth.test.d.ts +0 -0
  294. /package/dist/{__tests__ โ†’ src/__tests__}/auth.test.js +0 -0
  295. /package/dist/{__tests__ โ†’ src/__tests__}/brain-flow.test.d.ts +0 -0
  296. /package/dist/{__tests__ โ†’ src/__tests__}/confidence.test.d.ts +0 -0
  297. /package/dist/{__tests__ โ†’ src/__tests__}/confidence.test.js +0 -0
  298. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/api-auth.test.d.ts +0 -0
  299. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/api-auth.test.js +0 -0
  300. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/api-health.test.d.ts +0 -0
  301. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/api-health.test.js +0 -0
  302. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/cli.test.d.ts +0 -0
  303. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/cli.test.js +0 -0
  304. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/config.d.ts +0 -0
  305. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/config.js +0 -0
  306. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/funnel.test.d.ts +0 -0
  307. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/funnel.test.js +0 -0
  308. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/mcp-tools.test.d.ts +0 -0
  309. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/mcp-tools.test.js +0 -0
  310. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/provisioning.test.d.ts +0 -0
  311. /package/dist/{__tests__ โ†’ src/__tests__}/e2e/provisioning.test.js +0 -0
  312. /package/dist/{__tests__ โ†’ src/__tests__}/handlers-unit.test.d.ts +0 -0
  313. /package/dist/{__tests__ โ†’ src/__tests__}/namespace.test.d.ts +0 -0
  314. /package/dist/{__tests__ โ†’ src/__tests__}/namespace.test.js +0 -0
  315. /package/dist/{search.test.d.ts โ†’ src/__tests__/rerank.test.d.ts} +0 -0
  316. /package/dist/{auth.d.ts โ†’ src/auth.d.ts} +0 -0
  317. /package/dist/{auth.js โ†’ src/auth.js} +0 -0
  318. /package/dist/{ckg.d.ts โ†’ src/ckg.d.ts} +0 -0
  319. /package/dist/{ckg.js โ†’ src/ckg.js} +0 -0
  320. /package/dist/{confidence.d.ts โ†’ src/confidence.d.ts} +0 -0
  321. /package/dist/{confidence.js โ†’ src/confidence.js} +0 -0
  322. /package/dist/{embeddings.d.ts โ†’ src/embeddings.d.ts} +0 -0
  323. /package/dist/{embeddings.js โ†’ src/embeddings.js} +0 -0
  324. /package/dist/{handlers โ†’ src/handlers}/brain.d.ts +0 -0
  325. /package/dist/{handlers โ†’ src/handlers}/cache.d.ts +0 -0
  326. /package/dist/{handlers โ†’ src/handlers}/cache.js +0 -0
  327. /package/dist/{handlers โ†’ src/handlers}/context.d.ts +0 -0
  328. /package/dist/{handlers โ†’ src/handlers}/instances.d.ts +0 -0
  329. /package/dist/{handlers โ†’ src/handlers}/instances.js +0 -0
  330. /package/dist/{handlers โ†’ src/handlers}/syndicate.d.ts +0 -0
  331. /package/dist/{handlers โ†’ src/handlers}/syndicate.js +0 -0
  332. /package/dist/{handlers โ†’ src/handlers}/team.d.ts +0 -0
  333. /package/dist/{index.d.ts โ†’ src/index.d.ts} +0 -0
  334. /package/dist/{namespace.d.ts โ†’ src/namespace.d.ts} +0 -0
  335. /package/dist/{namespace.js โ†’ src/namespace.js} +0 -0
  336. /package/dist/{search.d.ts โ†’ src/search.d.ts} +0 -0
  337. /package/dist/{utils.d.ts โ†’ src/utils.d.ts} +0 -0
  338. /package/dist/{utils.js โ†’ src/utils.js} +0 -0
@@ -3,65 +3,46 @@ import { calculateConfidence, confidenceBadge, STRUCTURED_TEMPLATES, CONFIDENCE_
3
3
  import { ckgSlug, extractProblemConcept, ckgUpsertNode, ckgUpdateEdge } from '../ckg.js';
4
4
  import { safeJsonParse } from '../utils.js';
5
5
  import { keywordSearch, tokenize, splitMultiQuery, levenshtein, indexVocab as _indexVocab } from '../search.js';
6
+ import { rerankByQuality } from '../rerank.js';
6
7
  import { computeEmbedding, hasEmbedProvider } from '../embeddings.js';
7
8
  // โ”€โ”€ Changelog (shown once per version in session_start) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
8
- const MCP_VERSION = '0.10.56';
9
+ const MCP_VERSION = '0.10.58';
9
10
  const WHATS_NEW = {
10
- '0.10.56': [
11
- `๐Ÿ†• **What's new in cachly MCP v0.10.56:**`,
12
- ` ๐ŸŽ‰ session_start now shows a "๐ŸŽ‰ Your Brain bootstrapped from X commits" wow moment on second session`,
13
- ` ๐Ÿ“ฃ Setup flow now surfaces a teammate invite nudge โ€” helps you loop in your team`,
14
- ` ๐Ÿ“ Smithery listing rewritten: clearer value prop, better first-impression`,
11
+ '0.10.58': [
12
+ `๐Ÿงน Zero lint warnings โ€” all unused imports cleaned across every handler`,
13
+ `โœ… Build: 0 errors, 0 warnings ยท 379 tests green`,
15
14
  ],
16
- '0.10.55': [
17
- `๐Ÿ†• **What's new in cachly MCP v0.10.55:**`,
18
- ` โšก UX: API failure now shows a clear error instead of silently blocking for 30s`,
19
- ` โšก UX: provisioning wait reduced from 25s โ†’ 8s (Brain is usually ready sooner)`,
20
- ` ๐Ÿ”ง VS Code: setup spinner is now cancellable โ€” dismiss and MCP auto-connects later`,
21
- ` ๐Ÿง  VS Code: Brain Health panel shows offline-queued lessons with pending sync count`,
22
- ],
23
- '0.10.54': [
24
- `๐Ÿ†• **What's new in cachly MCP v${MCP_VERSION}:**`,
25
- ` ๐Ÿ‘€ Perf: first tool call no longer blocked by auto-session (was freezing for 30-120s on large repos)`,
26
- ` ๐Ÿ‘€ Perf: git history bootstrap runs in background โ€” session_start responds instantly`,
27
- ` ๐Ÿž Fixed: VS Code lessons now include author attribution (broken since launch)`,
28
- ],
29
- '0.10.53': [
30
- `๐Ÿ†• **What's new in cachly MCP v${MCP_VERSION}:**`,
31
- ` ๐Ÿ› Fixed: Brain bootstrap summary now visible in session_start (was silently discarded)`,
32
- ` ๐Ÿ› Fixed: team lessons now indexed correctly (\`ts\` field was stored as \`timestamp\`)`,
33
- ` โœจ New: proactive follow-up hints after \`learn_from_attempts\` (CKG co-occurrence patterns)`,
34
- ` โœจ New: author name attribution for VS Code lessons (set \`cachly.authorName\` in VS Code settings)`,
15
+ '0.10.57': [
16
+ `๐Ÿ†• **What's new in v${MCP_VERSION}:**`,
17
+ ` ๐Ÿ”ง **Critical fix** โ€” corrected the npm bin/main entry path (\`dist/src/index.js\`); 0.10.50โ€“0.10.52 shipped a broken entry point`,
18
+ ` ๐Ÿ”ง Version hygiene โ€” synced package.json, server.json, lockfile, MCP_VERSION; \`latest\` now points forward again`,
19
+ ` โœ… Accurate tool count (95) across README, server.json, CLI banners`,
20
+ ` โœ… Includes all Phase 2/3 work: quality reranking, Cachly-Bench, hybrid + CKG recall, team_confirm governance`,
35
21
  ],
36
22
  '0.10.52': [
37
- `๐Ÿ†• **What's new in cachly MCP v0.10.52:**`,
38
- ` ๐Ÿš€ Zero-click setup: Brain activates automatically on first call (no auth prompt needed)`,
39
- ` ๐Ÿ› Fixed: all Brain connections now use decrypted passwords (resolves AUTH errors for all users)`,
23
+ ` โœ… \`smart_recall\` โ€” CKG traversal as Layer 3: finds lessons that FIXED causal-graph-similar problems (๐Ÿ•ธ๏ธ causal graph badge)`,
24
+ ` โœ… Bench corpus expanded: governance adversarial pair proves review-boost end-to-end (+22% P@1 headline)`,
25
+ ` ๐Ÿ”ง Import cleanup: unused symbols removed from brain.ts (no functional change)`,
26
+ ` ๐Ÿ’ก \`smart_recall\` now shows keyword / semantic / CKG / hybrid match type for every result`,
40
27
  ],
41
- '0.10.50': [
42
- `๐Ÿ†• **What's new in cachly MCP v0.10.50:**`,
43
- ` ๐Ÿ› Fixed: Brain connection now works out of the box (was failing with AUTH error)`,
44
- ` ๐Ÿ› Fixed: TLS defaults to off for free-tier instances (no more TLS handshake failure)`,
45
- ` โœ… \`get_api_status\` correctly shows API key type instead of "invalid JWT format"`,
28
+ '0.10.51': [
29
+ ` โœ… \`team_confirm\` โ€” human review raises lesson recall ranking (๐Ÿ›ก๏ธ senior / โœ”๏ธ peer)`,
30
+ ` โœ… Governance-aware recall โ€” confirmed lessons outrank unreviewed auto-learned entries`,
46
31
  ],
47
- '0.10.46': [
48
- `๐Ÿ†• **What's new in v0.10.46:**`,
49
- ` โœ… \`brain_from_git\` โ€” auto-learns from your full git history on setup`,
50
- ` โœ… \`smart_recall\` โ€” semantic + keyword hybrid search, 3ร— more relevant results`,
51
- ` โœ… VS Code Extension โ€” Brain persists across all projects, zero config`,
52
- ` โœ… Device-flow auth โ€” zero-config login, no JWT needed in editor config`,
53
- ` โœ… Auto-provision โ€” Brain instance created automatically after first login`,
54
- ` โœ… JWT now persisted to ~/.claude/mcp.json โ€” survives editor restarts`,
55
- ` โœ… Confidence scoring โ€” every recalled fact shows staleness + reliability`,
56
- ` โœ… CKG (Causal Knowledge Graph) โ€” root-cause chains between bugs + fixes`,
32
+ '0.10.50': [
33
+ ` โœ… \`smart_recall\` โ€” unified keyword + semantic hybrid list (one ranked result, not two sections)`,
34
+ ` โœ… \`smart_recall\` โ€” "Brain saved you here" banner surfaces time saved inline per proven lesson`,
35
+ ` โœ… Quality reranking โ€” proven successes outrank symptom-dense failures (+11% Precision@1)`,
36
+ ` โœ… Cachly-Bench โ€” IR benchmark with CI regression guard (see BENCH.md for the proof)`,
37
+ ` ๐Ÿ”ง Contradiction resolution now persisted to Redis (90-day TTL)`,
38
+ ` ๐Ÿ’ก Run \`smart_recall\` to see your Brain's recall quality in action`,
57
39
  ],
58
- '0.10.0': [
59
- `๐Ÿ†• **What's new in v0.10.0:**`,
60
- ` โœ… Zero-friction setup โ€” auto-provisions your Brain, no manual config needed`,
61
- ` โœ… 10ร— faster briefings โ€” batch Redis fetches replace per-key loops`,
62
- ` โœ… Crash-proof data reads โ€” corrupted cache entries no longer break tools`,
63
- ` โœ… \`session_end\` warns when called without an active session`,
64
- ` โœ… \`get_api_status\` now shows live Redis ping + all instance statuses`,
40
+ '0.10.49': [
41
+ ` โœ… \`brain_from_git\` โ€” auto-seed your Brain from git history in seconds`,
42
+ ` โœ… \`brain_predict_failures\` โ€” predict CI/build failures before they happen`,
43
+ ` โœ… VS Code extension โ€” Brain status bar, ambient learning, CodeLens hints`,
44
+ ` โœ… Team Brain โ€” share lessons across your whole engineering team`,
45
+ ` ๐Ÿ”ง Stability โ€” auto-expiring memory keys, longer provisioning wait, robust recall`,
65
46
  ],
66
47
  };
67
48
  export const BRAIN_TOOL_NAMES = new Set([
@@ -117,6 +98,19 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
117
98
  await ckgUpdateEdge(redis, cId, 'contradicts', resId, false);
118
99
  }
119
100
  catch { /* non-critical */ }
101
+ // Persist a queryable resolution record โ€” so contradiction history survives
102
+ // (CKG edges alone aren't easily auditable). Bounded + TTL'd like other history.
103
+ try {
104
+ const resolutionKey = `cachly:contradictions:${topic}`;
105
+ const direction = prev.outcome === 'success' && outcome === 'failure'
106
+ ? 'kept-success' : 'overwrote-failure';
107
+ await redis.rpush(resolutionKey, JSON.stringify({
108
+ ts, prev_outcome: prev.outcome, new_outcome: outcome, direction,
109
+ }));
110
+ await redis.ltrim(resolutionKey, -50, -1);
111
+ await redis.expire(resolutionKey, 180 * 86400);
112
+ }
113
+ catch { /* non-critical */ }
120
114
  contradictionWarning.push(`๐Ÿ—ณ๏ธ Run \`madc_deliberate(topic="${topic}")\` to resolve via expert agent voting.`);
121
115
  }
122
116
  }
@@ -162,7 +156,7 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
162
156
  const depTopics = safeJsonParse(existing, []);
163
157
  if (!depTopics.includes(topic))
164
158
  depTopics.push(topic);
165
- await redis.set(depKey, JSON.stringify(depTopics), 'EX', 365 * 86400); // 1-year TTL
159
+ await redis.set(depKey, JSON.stringify(depTopics), 'EX', 90 * 86400);
166
160
  }
167
161
  const lessonObj = {
168
162
  topic,
@@ -184,11 +178,11 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
184
178
  version: 3,
185
179
  };
186
180
  const lesson = JSON.stringify(lessonObj);
187
- // Always append to the history list (audit log); cap at 200 entries to prevent unbounded growth
181
+ // Always append to the history list (audit log); keep last 100 entries, 90-day TTL
188
182
  const listKey = `cachly:lessons:${topic}`;
189
183
  await redis.rpush(listKey, lesson);
190
- await redis.ltrim(listKey, -200, -1);
191
- await redis.expire(listKey, 365 * 86400); // 1-year TTL
184
+ await redis.ltrim(listKey, -100, -1);
185
+ await redis.expire(listKey, 90 * 86400);
192
186
  // Update best key for success/partial; for failure only update if no success exists
193
187
  if (outcome === 'success' || outcome === 'partial') {
194
188
  await redis.set(`cachly:lesson:best:${topic}`, lesson);
@@ -322,45 +316,26 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
322
316
  }
323
317
  }
324
318
  catch { /* CKG updates are non-critical */ }
325
- // โ”€โ”€ Proactive follow-up suggestion (CKG co-occurrence patterns) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
326
- // After a successful fix, check if related concepts commonly follow it.
327
- // Uses CKG co-occurs edges with confidence > 0.4 and at least 2 trials.
328
- const proactiveSuggestions = [];
329
- if (outcome === 'success' || outcome === 'partial') {
330
- try {
331
- const conceptId = ckgSlug(topic);
332
- const fromEdgeKeys = await redis.smembers(`cachly:ckg:idx:from:${conceptId}`);
333
- for (const ek of fromEdgeKeys.slice(0, 20)) {
334
- const er = await redis.get(ek);
335
- if (!er)
336
- continue;
337
- const edge = safeJsonParse(er, null);
338
- if (!edge || edge.confidence < 0.4 || (edge.trials ?? 0) < 2)
339
- continue;
340
- if (edge.edgeType !== 'co-occurs' && edge.edgeType !== 'causes')
341
- continue;
342
- // Resolve related concept to a lesson key
343
- const relTopic = edge.to
344
- .replace(/^cause:/, '')
345
- .replace(/^tag:/, '')
346
- .replace(/^problem:/, '')
347
- .replace(/-/g, ':')
348
- .replace(/_/g, '-');
349
- const relRaw = await redis.get(`cachly:lesson:best:${relTopic}`);
350
- if (!relRaw)
351
- continue;
352
- const relLesson = safeJsonParse(relRaw, null);
353
- const displayTopic = relLesson?.topic ?? relTopic;
354
- if (!relLesson || !relLesson.what_worked || displayTopic === topic)
355
- continue;
356
- const pct = Math.round(edge.confidence * 100);
357
- if (proactiveSuggestions.length === 0)
358
- proactiveSuggestions.push('');
359
- proactiveSuggestions.push(`๐Ÿ”ฎ **Pattern detected:** \`${displayTopic}\` tends to follow this (${pct}% co-occurrence across ${edge.trials} sessions)`, ` โ†’ ${relLesson.what_worked.slice(0, 100)}${relLesson.what_worked.length > 100 ? 'โ€ฆ' : ''}`, ` โ†’ Pre-empt it now: \`recall_best_solution(topic="${displayTopic}")\``);
360
- break; // one proactive hint is enough
361
- }
362
- }
363
- catch { /* non-critical */ }
319
+ // โ”€โ”€ Ambient team propagation: if author is set + outcome is success,
320
+ // auto-store as a team lesson so knowledge is shared without a separate
321
+ // team_learn call. Tags gain 'team'; the lesson is attributed to the author.
322
+ // This makes team knowledge sharing the default, not the opt-in.
323
+ if (author && (outcome === 'success' || outcome === 'partial')) {
324
+ const teamLesson = {
325
+ topic, outcome, what_worked,
326
+ what_failed: what_failed ?? '',
327
+ severity,
328
+ author,
329
+ file_paths,
330
+ commands,
331
+ tags: [...new Set([...tags, 'team'])],
332
+ timestamp: new Date().toISOString(),
333
+ recall_count: 0,
334
+ version: 2,
335
+ auto_propagated: true,
336
+ };
337
+ const teamListKey = `cachly:lessons:${topic}`;
338
+ redis.rpush(teamListKey, JSON.stringify(teamLesson)).catch(() => { });
364
339
  }
365
340
  const emoji = outcome === 'success' ? 'โœ…' : outcome === 'partial' ? 'โš ๏ธ' : 'โŒ';
366
341
  const sevEmoji = severity === 'critical' ? '๐Ÿ”ด' : severity === 'major' ? '๐ŸŸก' : '๐ŸŸข';
@@ -379,12 +354,14 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
379
354
  isUpdate
380
355
  ? `โ™ป๏ธ Updated (recall count: ${recallCount} ยท audit entries: ${auditTrail.length})`
381
356
  : `๐Ÿ’ก Recall later with \`recall_best_solution(topic="${topic}")\``,
357
+ (author && (outcome === 'success' || outcome === 'partial'))
358
+ ? `๐Ÿ‘ฅ Auto-shared with team (by _${author}_) โ€” visible in \`team_recall\``
359
+ : '',
382
360
  depends_on.length > 0
383
361
  ? `๐Ÿ”— Depends on: ${depends_on.map(d => `\`${d}\``).join(', ')} โ†’ trace with \`trace_dependency\``
384
362
  : '',
385
363
  ...templateWarnings,
386
364
  ...iWasWrongWarning,
387
- ...proactiveSuggestions,
388
365
  ].filter(l => l !== '').join('\n');
389
366
  }
390
367
  case 'recall_best_solution': {
@@ -425,8 +402,29 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
425
402
  const suggestPin = updatedLesson.recall_count === 3 && !lesson.pinned
426
403
  ? `๐Ÿ“Œ **You've looked this up 3 times.** Consider pinning it for instant access: add \`pinned: true\` via \`learn_from_attempts\` to always surface it first.`
427
404
  : '';
405
+ // โ”€โ”€ Trust signal (today-safe consensus layer) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
406
+ // A lesson recalled many times โ€” or confirmed by multiple distinct
407
+ // authors โ€” has proven its value. Surface that as social proof.
408
+ const lessonAuthors = lesson.authors
409
+ ?? (lesson.author ? [lesson.author] : []);
410
+ const distinctAuthors = [...new Set(lessonAuthors.filter(Boolean))];
411
+ const rc = updatedLesson.recall_count;
412
+ let trustBadge = '';
413
+ if (distinctAuthors.length >= 2 && rc >= 5) {
414
+ trustBadge = `๐Ÿ† **Battle-tested** โ€” recalled ${rc}ร— ยท verified by ${distinctAuthors.length} developers. Trust this.`;
415
+ }
416
+ else if (rc >= 10) {
417
+ trustBadge = `๐Ÿ† **Battle-tested** โ€” recalled ${rc}ร—. This is one of your most-proven solutions.`;
418
+ }
419
+ else if (distinctAuthors.length >= 2) {
420
+ trustBadge = `โœ… **Team-verified** โ€” confirmed by ${distinctAuthors.length} developers.`;
421
+ }
422
+ else if (rc >= 5) {
423
+ trustBadge = `โœ… **Proven** โ€” recalled ${rc}ร— without contradiction.`;
424
+ }
428
425
  return [
429
426
  rememberWhen,
427
+ trustBadge,
430
428
  `${badge} **Best solution for \`${topic}\`** ${sevEmoji}${lesson.severity ? ` (${lesson.severity})` : ''} ยท recalled ${updatedLesson.recall_count}ร—`,
431
429
  ``,
432
430
  `**What worked:** ${lesson.what_worked}`,
@@ -476,57 +474,37 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
476
474
  const { instance_id, query, threshold = 0.78, } = args;
477
475
  const redis = await getConnection(instance_id);
478
476
  // โ”€โ”€ Layer 1: Keyword search across ALL brain data (always works, no embedding) โ”€โ”€
479
- const kwMatches = await keywordSearch(redis, ['cachly:ctx:*', 'cachly:lesson:best:*', 'cachly:idx:*'], query, 10);
480
- const lines = [`๐Ÿง  **Smart Recall** for: _"${query}"_\n`];
481
- // Show sub-query info if multi-topic was detected
482
- const subQueries = splitMultiQuery(query);
483
- if (subQueries.length > 1) {
484
- lines.push(`_Detected ${subQueries.length} sub-topics:_ ${subQueries.map((s, i) => `${i + 1}. "${s}"`).join(', ')}\n`);
485
- }
486
- if (kwMatches.length > 0) {
487
- lines.push(`### ๐Ÿ” BM25 Matches (${kwMatches.length})\n`);
488
- // Group by sub-query if multi-topic
489
- if (subQueries.length > 1) {
490
- const grouped = new Map();
491
- for (const m of kwMatches.slice(0, 12)) {
492
- const sq = m.subQuery ?? query;
493
- if (!grouped.has(sq))
494
- grouped.set(sq, []);
495
- grouped.get(sq).push(m);
496
- }
497
- for (const [sq, matches] of grouped) {
498
- lines.push(`**Topic: "${sq}"** (${matches.length} results)\n`);
499
- for (const m of matches.slice(0, 4)) {
500
- const label = m.key
501
- .replace('cachly:ctx:', '๐Ÿ“ ')
502
- .replace('cachly:lesson:best:', '๐Ÿ’ก ')
503
- .replace('cachly:idx:', '๐Ÿ“‚ ');
504
- const preview = m.content.slice(0, 300).replace(/\n/g, ' ');
505
- lines.push(` **${label}** _(BM25: ${m.score.toFixed(2)}, matched: ${m.matchedWords.join(', ')})_`);
506
- lines.push(` > ${preview}${m.content.length > 300 ? 'โ€ฆ' : ''}\n`);
477
+ const rawMatches = await keywordSearch(redis, ['cachly:ctx:*', 'cachly:lesson:best:*', 'cachly:idx:*'], query, 10);
478
+ // โ”€โ”€ Layer 1.5: Quality-aware rerank โ€” proven success lessons outrank
479
+ // text-similar failed attempts (the moat; see src/rerank.ts + Cachly-Bench). โ”€โ”€
480
+ const kwMatches = rerankByQuality(rawMatches);
481
+ const savedHere = [];
482
+ const lessonMatches = kwMatches.filter(m => m.key.startsWith('cachly:lesson:best:'));
483
+ for (const m of lessonMatches.slice(0, 5)) {
484
+ const existing = await redis.get(m.key).catch(() => null);
485
+ if (existing) {
486
+ const lesson = safeJsonParse(existing, null);
487
+ if (lesson) {
488
+ const updated = { ...lesson, recall_count: (lesson.recall_count ?? 0) + 1, verified_at: new Date().toISOString() };
489
+ redis.set(m.key, JSON.stringify(updated)).catch(() => { });
490
+ const sev = lesson.severity;
491
+ const savedMins = sev === 'critical' ? 240 : sev === 'major' ? 60 : 30;
492
+ redis.incrbyfloat(`cachly:stats:time_saved_mins:${instance_id}`, savedMins).catch(() => { });
493
+ // Surface banner for proven successes (recall_count >= 1 means it's been validated)
494
+ if (lesson.outcome === 'success' && (lesson.recall_count ?? 0) >= 1) {
495
+ savedHere.push({
496
+ topic: m.key.replace('cachly:lesson:best:', ''),
497
+ severity: sev ?? 'major',
498
+ recall_count: (lesson.recall_count ?? 0) + 1,
499
+ savedMins,
500
+ });
507
501
  }
508
502
  }
509
- // Summary: which sub-queries had matches
510
- const matched = [...grouped.keys()];
511
- const unmatched = subQueries.filter(sq => !matched.includes(sq));
512
- if (unmatched.length > 0) {
513
- lines.push(`\nโš ๏ธ **No results for:** ${unmatched.map(s => `"${s}"`).join(', ')}`);
514
- }
515
- }
516
- else {
517
- for (const m of kwMatches.slice(0, 8)) {
518
- const label = m.key
519
- .replace('cachly:ctx:', '๐Ÿ“ ')
520
- .replace('cachly:lesson:best:', '๐Ÿ’ก ')
521
- .replace('cachly:idx:', '๐Ÿ“‚ ');
522
- const preview = m.content.slice(0, 400).replace(/\n/g, ' ');
523
- lines.push(`**${label}** _(BM25: ${m.score.toFixed(2)}, matched: ${m.matchedWords.join(', ')})_`);
524
- lines.push(`> ${preview}${m.content.length > 400 ? 'โ€ฆ' : ''}\n`);
525
- }
526
503
  }
527
504
  }
528
- // โ”€โ”€ Layer 2: Semantic search (optional, only if embedding provider + vector_token available) โ”€โ”€
505
+ // โ”€โ”€ Layer 2: Semantic search (parallel, optional) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
529
506
  const inst = await apiFetch(`/api/v1/instances/${instance_id}`);
507
+ const semHits = [];
530
508
  if (inst.vector_token && hasEmbedProvider()) {
531
509
  try {
532
510
  const embedding = await computeEmbedding(query);
@@ -538,16 +516,13 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
538
516
  });
539
517
  if (searchRes.ok) {
540
518
  const results = (await searchRes.json());
541
- const semHits = results.filter(r => r.found && r.id);
542
- if (semHits.length > 0) {
543
- lines.push(`\n### ๐ŸŽฏ Semantic Matches (${semHits.length})\n`);
544
- for (const hit of semHits) {
545
- const parts = hit.id.replace('ctx:', '').split(':');
546
- const category = parts[0];
547
- const key = parts.slice(1).join(':');
548
- const content = await redis.get(`cachly:ctx:${category}:${key}`);
549
- lines.push(`**${key}** _(${((hit.similarity ?? 0) * 100).toFixed(0)}% similar)_`, `> ${content?.slice(0, 300) ?? '(evicted)'}${(content?.length ?? 0) > 300 ? 'โ€ฆ' : ''}\n`);
550
- }
519
+ for (const hit of results.filter(r => r.found && r.id)) {
520
+ const parts = hit.id.replace('ctx:', '').split(':');
521
+ const category = parts[0];
522
+ const key = parts.slice(1).join(':');
523
+ const redisKey = `cachly:ctx:${category}:${key}`;
524
+ const content = await redis.get(redisKey).catch(() => null);
525
+ semHits.push({ key: redisKey, similarity: hit.similarity ?? 0, content: content ?? '(evicted)' });
551
526
  }
552
527
  }
553
528
  }
@@ -555,7 +530,158 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
555
530
  // Semantic search failed silently โ€” keyword results are enough
556
531
  }
557
532
  }
558
- if (kwMatches.length === 0) {
533
+ const bm25Scores = kwMatches.map(m => m.score);
534
+ const bm25Min = bm25Scores.length ? Math.min(...bm25Scores) : 0;
535
+ const bm25Range = bm25Scores.length ? (Math.max(...bm25Scores) - bm25Min) || 1 : 1;
536
+ const bm25Norm = (s) => (s - bm25Min) / bm25Range;
537
+ const hybridMap = new Map();
538
+ for (const m of kwMatches) {
539
+ const n = bm25Norm(m.score);
540
+ hybridMap.set(m.key, {
541
+ key: m.key, content: m.content, bm25Score: n,
542
+ hybridScore: n * (semHits.length > 0 ? 0.7 : 1.0),
543
+ matchedWords: m.matchedWords, matchType: 'keyword', subQuery: m.subQuery,
544
+ });
545
+ }
546
+ for (const hit of semHits) {
547
+ const existing = hybridMap.get(hit.key);
548
+ if (existing) {
549
+ existing.semScore = hit.similarity;
550
+ existing.hybridScore = (existing.bm25Score ?? 0) * 0.6 + hit.similarity * 0.4;
551
+ existing.matchType = 'hybrid';
552
+ }
553
+ else {
554
+ hybridMap.set(hit.key, {
555
+ key: hit.key, content: hit.content, semScore: hit.similarity,
556
+ hybridScore: hit.similarity * 0.5, matchType: 'semantic',
557
+ });
558
+ }
559
+ }
560
+ // โ”€โ”€ Layer 3: CKG traversal โ€” follow "fixes" edges to find lessons that solved
561
+ // structurally similar problems, even when vocabulary differs โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
562
+ try {
563
+ const qTokens = tokenize(query).filter(t => t.length >= 4).slice(0, 4);
564
+ const candidateNodeIds = new Set();
565
+ for (const token of qTokens) {
566
+ const nodeStream = redis.scanStream({ match: `cachly:ckg:node:*${token}*`, count: 20 });
567
+ await new Promise((res, rej) => {
568
+ nodeStream.on('data', (batch) => {
569
+ for (const k of batch.slice(0, 5))
570
+ candidateNodeIds.add(k.replace('cachly:ckg:node:', ''));
571
+ });
572
+ nodeStream.on('end', res);
573
+ nodeStream.on('error', rej);
574
+ });
575
+ }
576
+ const seenFroms = new Set();
577
+ for (const nodeId of [...candidateNodeIds].slice(0, 12)) {
578
+ const inboundEdgeKeys = await redis.smembers(`cachly:ckg:idx:to:${nodeId}`);
579
+ for (const ek of inboundEdgeKeys.slice(0, 6)) {
580
+ const er = await redis.get(ek);
581
+ if (!er)
582
+ continue;
583
+ const edge = safeJsonParse(er, null);
584
+ if (!edge || edge.edgeType !== 'fixes' || edge.confidence < 0.35)
585
+ continue;
586
+ if (seenFroms.has(edge.from))
587
+ continue;
588
+ seenFroms.add(edge.from);
589
+ const lessonKey = `cachly:lesson:best:${edge.from}`;
590
+ const existing = hybridMap.get(lessonKey);
591
+ if (existing) {
592
+ // Already found by BM25/semantic โ€” boost with causal confirmation
593
+ existing.ckgScore = Math.max(existing.ckgScore ?? 0, edge.confidence);
594
+ existing.hybridScore = existing.hybridScore * 0.88 + edge.confidence * 0.12;
595
+ if (existing.matchType === 'keyword')
596
+ existing.matchType = 'hybrid';
597
+ }
598
+ else {
599
+ const content = await redis.get(lessonKey).catch(() => null);
600
+ if (!content)
601
+ continue;
602
+ hybridMap.set(lessonKey, {
603
+ key: lessonKey, content,
604
+ ckgScore: edge.confidence,
605
+ hybridScore: edge.confidence * 0.30, // CKG-only: lower than text hits
606
+ matchType: 'ckg',
607
+ });
608
+ }
609
+ }
610
+ }
611
+ }
612
+ catch { /* non-critical โ€” keyword + semantic always available */ }
613
+ const hybridResults = [...hybridMap.values()].sort((a, b) => b.hybridScore - a.hybridScore);
614
+ // โ”€โ”€ Build output โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
615
+ const lines = [`๐Ÿง  **Smart Recall** for: _"${query}"_\n`];
616
+ // "Brain saved you here" banner โ€” surfaces value inline for proven recalled lessons
617
+ const SORDER = { critical: 0, major: 1, minor: 2 };
618
+ const topLesson = savedHere.sort((a, b) => (SORDER[a.severity] ?? 1) - (SORDER[b.severity] ?? 1))[0];
619
+ if (topLesson) {
620
+ lines.push(`> ๐Ÿ’ก **Brain saved you ~${topLesson.savedMins}m here** โ€” ${topLesson.severity} issue from \`${topLesson.topic}\` recalled ${topLesson.recall_count}ร— proven\n`);
621
+ }
622
+ // Show sub-query info if multi-topic was detected
623
+ const subQueries = splitMultiQuery(query);
624
+ if (subQueries.length > 1) {
625
+ lines.push(`_Detected ${subQueries.length} sub-topics:_ ${subQueries.map((s, i) => `${i + 1}. "${s}"`).join(', ')}\n`);
626
+ }
627
+ if (hybridResults.length > 0) {
628
+ const hasCKG = hybridResults.some(r => r.ckgScore !== undefined);
629
+ const modeLabel = semHits.length > 0 && hasCKG
630
+ ? `keyword + semantic + CKG hybrid`
631
+ : semHits.length > 0
632
+ ? `keyword + semantic hybrid`
633
+ : hasCKG
634
+ ? `keyword + CKG hybrid`
635
+ : `keyword`;
636
+ lines.push(`### ๐Ÿ” Results (${hybridResults.length} โ€” ${modeLabel})\n`);
637
+ // Group by sub-query for multi-topic queries
638
+ if (subQueries.length > 1) {
639
+ const grouped = new Map();
640
+ for (const r of hybridResults.slice(0, 12)) {
641
+ const sq = r.subQuery ?? query;
642
+ if (!grouped.has(sq))
643
+ grouped.set(sq, []);
644
+ grouped.get(sq).push(r);
645
+ }
646
+ for (const [sq, results] of grouped) {
647
+ lines.push(`**Topic: "${sq}"** (${results.length} results)\n`);
648
+ for (const r of results.slice(0, 4)) {
649
+ const label = r.key.replace('cachly:ctx:', '๐Ÿ“ ').replace('cachly:lesson:best:', '๐Ÿ’ก ').replace('cachly:idx:', '๐Ÿ“‚ ');
650
+ const scorePart = r.matchType === 'ckg'
651
+ ? `CKG: ${(r.ckgScore ?? 0).toFixed(2)}, ๐Ÿ•ธ๏ธ causal graph`
652
+ : r.ckgScore !== undefined && r.bm25Score !== undefined
653
+ ? `BM25: ${(r.bm25Score).toFixed(2)}, CKG: ${(r.ckgScore).toFixed(2)}, ๐Ÿ”€ hybrid`
654
+ : r.matchType === 'hybrid'
655
+ ? `BM25: ${(r.bm25Score ?? 0).toFixed(2)}, sem: ${((r.semScore ?? 0) * 100).toFixed(0)}%, ๐Ÿ”€ hybrid`
656
+ : r.matchType === 'semantic'
657
+ ? `sem: ${((r.semScore ?? 0) * 100).toFixed(0)}%, ๐ŸŽฏ semantic`
658
+ : `BM25: ${(r.bm25Score ?? 0).toFixed(2)}, matched: ${r.matchedWords?.join(', ')}`;
659
+ const preview = r.content.slice(0, 300).replace(/\n/g, ' ');
660
+ lines.push(` **${label}** _(${scorePart})_`);
661
+ lines.push(` > ${preview}${r.content.length > 300 ? 'โ€ฆ' : ''}\n`);
662
+ }
663
+ }
664
+ const matched = [...grouped.keys()];
665
+ const unmatched = subQueries.filter(sq => !matched.includes(sq));
666
+ if (unmatched.length > 0) {
667
+ lines.push(`\nโš ๏ธ **No results for:** ${unmatched.map(s => `"${s}"`).join(', ')}`);
668
+ }
669
+ }
670
+ else {
671
+ for (const r of hybridResults.slice(0, 8)) {
672
+ const label = r.key.replace('cachly:ctx:', '๐Ÿ“ ').replace('cachly:lesson:best:', '๐Ÿ’ก ').replace('cachly:idx:', '๐Ÿ“‚ ');
673
+ const scorePart = r.matchType === 'hybrid'
674
+ ? `BM25: ${(r.bm25Score ?? 0).toFixed(2)}, sem: ${((r.semScore ?? 0) * 100).toFixed(0)}%, ๐Ÿ”€ hybrid`
675
+ : r.matchType === 'semantic'
676
+ ? `sem: ${((r.semScore ?? 0) * 100).toFixed(0)}%, ๐ŸŽฏ semantic`
677
+ : `BM25: ${(r.bm25Score ?? 0).toFixed(2)}, matched: ${r.matchedWords?.join(', ')}`;
678
+ const preview = r.content.slice(0, 400).replace(/\n/g, ' ');
679
+ lines.push(`**${label}** _(${scorePart})_`);
680
+ lines.push(`> ${preview}${r.content.length > 400 ? 'โ€ฆ' : ''}\n`);
681
+ }
682
+ }
683
+ }
684
+ else {
559
685
  lines.push(`โš ๏ธ No matches found for: "${query}"`);
560
686
  // Did-You-Mean: find nearest token in index vocab
561
687
  const queryTokens = tokenize(query);
@@ -734,25 +860,6 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
734
860
  lines.push('๐Ÿ’ก Run `brain_doctor` for a health-check and personalised tips.');
735
861
  lines.push('');
736
862
  }
737
- // โ”€โ”€ Bootstrap wow moment (shown once after first auto git-bootstrap) โ”€โ”€โ”€โ”€โ”€โ”€
738
- // brain_from_git fires in the background on the first session_start with
739
- // workspace_path. The result count is stored under a well-known key so the
740
- // NEXT session can celebrate it โ€” "๐ŸŽ‰ Your Brain bootstrapped from 87 commits!"
741
- if (!isFirstSession) {
742
- try {
743
- const bootstrapRaw = await redis.get('cachly:brain_from_git:auto_bootstrap_result');
744
- if (bootstrapRaw) {
745
- const br = safeJsonParse(bootstrapRaw, null);
746
- if (br && br.count > 0) {
747
- await redis.del('cachly:brain_from_git:auto_bootstrap_result'); // show once
748
- lines.push(`๐ŸŽ‰ **Your Brain bootstrapped from your git history โ€” ${br.count} patterns learned automatically.**`);
749
- lines.push(` Arrives pre-briefed. No setup needed. Share with a teammate: \`npx @cachly-dev/mcp-server@latest invite\``);
750
- lines.push('');
751
- }
752
- }
753
- }
754
- catch { /* non-critical */ }
755
- }
756
863
  // โ”€โ”€ Team-virality: first-team-briefing wow moment โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
757
864
  // When a user joins a team brain (has team lessons from colleagues but
758
865
  // has never been briefed on them), show a dedicated "Welcome to your
@@ -890,6 +997,29 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
890
997
  }
891
998
  // Brain health
892
999
  lines.push(`๐Ÿ“Š **Brain:** ${lessons.length} lessons ยท ${ctxCount} context entries`, '');
1000
+ // โ”€โ”€ ๐Ÿ“Œ Proven Laws โ€” auto-crystallized lessons (quick win 3) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1001
+ // A lesson that has proven itself (recalled โ‰ฅ CRYSTALLIZE_RECALLS times) or
1002
+ // was explicitly pinned becomes a "law" โ€” surfaced at the top of every
1003
+ // briefing so the most battle-tested knowledge is never buried. This is
1004
+ // the today-safe version of swarm crystallization: enough confirmations
1005
+ // auto-promote a lesson without any manual step.
1006
+ {
1007
+ const CRYSTALLIZE_RECALLS = 5;
1008
+ const laws = lessons
1009
+ .filter(l => l.outcome === 'success' && (l.pinned === true || (l.recall_count ?? 0) >= CRYSTALLIZE_RECALLS))
1010
+ .sort((a, b) => (b.recall_count ?? 0) - (a.recall_count ?? 0))
1011
+ .slice(0, 5);
1012
+ if (laws.length > 0) {
1013
+ lines.push(`๐Ÿ“Œ **Proven Laws** (auto-crystallized โ€” your most-trusted knowledge):`);
1014
+ for (const l of laws) {
1015
+ const sev = l.severity === 'critical' ? '๐Ÿ”ด' : l.severity === 'major' ? '๐ŸŸก' : '';
1016
+ const rc = l.recall_count ?? 0;
1017
+ const why = l.pinned === true ? 'pinned' : `recalled ${rc}ร—`;
1018
+ lines.push(` ๐Ÿ†${sev} \`${l.topic}\` _(${why})_ โ€” ${l.what_worked.slice(0, 100)}`);
1019
+ }
1020
+ lines.push('');
1021
+ }
1022
+ }
893
1023
  // โ”€โ”€ Layer 7: MCM Domain Coverage Map โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
894
1024
  if (lessons.length >= 3) {
895
1025
  const domainMap = new Map();
@@ -992,8 +1122,14 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
992
1122
  for (const l of topRecalled) {
993
1123
  const emoji = l.outcome === 'success' ? 'โœ…' : l.outcome === 'partial' ? 'โš ๏ธ' : 'โŒ';
994
1124
  const sev = l.severity === 'critical' ? '๐Ÿ”ด' : l.severity === 'major' ? '๐ŸŸก' : '';
995
- const rct = l.recall_count && l.recall_count > 1 ? ` _(${l.recall_count}ร— recalled)_` : '';
996
- lines.push(` ${emoji}${sev} \`${l.topic}\`${rct} โ€” ${l.what_worked.slice(0, 100)}`);
1125
+ const rc = l.recall_count ?? 0;
1126
+ const la = l.authors
1127
+ ?? (l.author ? [l.author] : []);
1128
+ const nAuthors = new Set(la.filter(Boolean)).size;
1129
+ const trust = (nAuthors >= 2 && rc >= 5) || rc >= 10 ? ' ๐Ÿ†'
1130
+ : nAuthors >= 2 || rc >= 5 ? ' โœ…' : '';
1131
+ const rct = rc > 1 ? ` _(${rc}ร— recalled)_` : '';
1132
+ lines.push(` ${emoji}${sev}${trust} \`${l.topic}\`${rct} โ€” ${l.what_worked.slice(0, 100)}`);
997
1133
  }
998
1134
  lines.push('');
999
1135
  }
@@ -1059,25 +1195,59 @@ export async function handleBrainTool(name, args, getConnection, apiFetch) {
1059
1195
  lines.push('');
1060
1196
  }
1061
1197
  // โ”€โ”€ ๐Ÿ”ฎ Predictive Pre-Warning โ€” intent-based danger detection โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1062
- // Fires BEFORE work starts. If focus area has known failure patterns โ†’ warn loudly.
1063
- if (focusTerms.length > 0) {
1064
- const dangerLessons = lessons.filter(l => {
1065
- if (l.outcome === 'success')
1066
- return false;
1067
- const topicCategory = l.topic.split(':')[0];
1068
- return focusTerms.some(term => l.topic.toLowerCase().includes(term) ||
1069
- topicCategory === term ||
1070
- (l.tags ?? []).some((t) => t.toLowerCase() === term));
1071
- });
1072
- if (dangerLessons.length >= 1) {
1073
- // Insert warning block right after the title line (index 1 = blank line after title)
1074
- const warning = [
1075
- `๐Ÿšจ **PRE-WARNING** โ€” Read this BEFORE starting:`,
1076
- ` Known pitfalls for **"${focus}"** (${dangerLessons.length} past failure${dangerLessons.length > 1 ? 's' : ''}):`,
1077
- ...dangerLessons.slice(0, 3).map(l => ` โŒ \`${l.topic}\` โ€” ${(l.what_failed ?? l.what_worked).slice(0, 80)}`),
1078
- '',
1079
- ];
1080
- lines.splice(2, 0, ...warning); // after '๐Ÿง  **Session Briefing**' + empty line
1198
+ // Fires BEFORE work starts. Uses explicit focus when given; otherwise
1199
+ // derives the likely work area from the last session's changed files +
1200
+ // summary (you usually keep working where you left off). This makes the
1201
+ // warning fire even when the caller forgets to pass `focus`.
1202
+ {
1203
+ // Common path noise / extensions to drop when deriving terms from files.
1204
+ const PATH_NOISE = new Set([
1205
+ 'src', 'lib', 'test', 'tests', 'dist', 'index', 'main', 'app',
1206
+ 'internal', 'pkg', 'cmd', 'node_modules', 'components', 'utils',
1207
+ 'ts', 'tsx', 'js', 'jsx', 'go', 'py', 'rs', 'java', 'json', 'yaml', 'yml',
1208
+ ]);
1209
+ const deriveTermsFromFiles = (files) => {
1210
+ const terms = new Set();
1211
+ for (const f of files) {
1212
+ for (const seg of f.toLowerCase().split(/[/\\._-]/)) {
1213
+ if (seg.length > 3 && !PATH_NOISE.has(seg))
1214
+ terms.add(seg);
1215
+ }
1216
+ }
1217
+ return [...terms];
1218
+ };
1219
+ let warnTerms = focusTerms;
1220
+ let warnLabel = focus;
1221
+ let derived = false;
1222
+ if (warnTerms.length === 0 && lastSession) {
1223
+ const fromFiles = deriveTermsFromFiles(lastSession.files_changed ?? []);
1224
+ const fromSummary = (lastSession.summary ?? '').toLowerCase()
1225
+ .replace(/[^a-z0-9\s:_-]/g, ' ').split(/\s+/).filter(t => t.length > 3 && !PATH_NOISE.has(t));
1226
+ warnTerms = [...new Set([...fromFiles, ...fromSummary])];
1227
+ warnLabel = 'where you left off last session';
1228
+ derived = true;
1229
+ }
1230
+ if (warnTerms.length > 0) {
1231
+ const dangerLessons = lessons.filter(l => {
1232
+ if (l.outcome === 'success')
1233
+ return false;
1234
+ const topicCategory = l.topic.split(':')[0];
1235
+ return warnTerms.some(term => l.topic.toLowerCase().includes(term) ||
1236
+ topicCategory === term ||
1237
+ (l.tags ?? []).some((t) => t.toLowerCase() === term));
1238
+ });
1239
+ if (dangerLessons.length >= 1) {
1240
+ const headline = derived
1241
+ ? ` You're likely to continue **${warnLabel}** โ€” ${dangerLessons.length} known pitfall${dangerLessons.length > 1 ? 's' : ''} there:`
1242
+ : ` Known pitfalls for **"${warnLabel}"** (${dangerLessons.length} past failure${dangerLessons.length > 1 ? 's' : ''}):`;
1243
+ const warning = [
1244
+ `๐Ÿšจ **PRE-WARNING** โ€” Read this BEFORE starting:`,
1245
+ headline,
1246
+ ...dangerLessons.slice(0, 3).map(l => ` โŒ \`${l.topic}\` โ€” ${(l.what_failed ?? l.what_worked).slice(0, 80)}`),
1247
+ '',
1248
+ ];
1249
+ lines.splice(2, 0, ...warning); // after '๐Ÿง  **Session Briefing**' + empty line
1250
+ }
1081
1251
  }
1082
1252
  }
1083
1253
  // โ”€โ”€ ๐Ÿ‘ฅ Team Telepathy โ€” what teammates learned this week โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€