onadit 0.0.1 → 1.0.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 (1085) hide show
  1. package/README.dev.md +124 -0
  2. package/README.md +194 -2
  3. package/dist/src/auth/keychain.d.ts +42 -0
  4. package/dist/src/auth/keychain.d.ts.map +1 -0
  5. package/dist/src/auth/keychain.js +177 -0
  6. package/dist/src/auth/keychain.js.map +1 -0
  7. package/dist/src/auth/middleware.d.ts +21 -0
  8. package/dist/src/auth/middleware.d.ts.map +1 -0
  9. package/dist/src/auth/middleware.js +93 -0
  10. package/dist/src/auth/middleware.js.map +1 -0
  11. package/dist/src/auth/rate-limit.d.ts +16 -0
  12. package/dist/src/auth/rate-limit.d.ts.map +1 -0
  13. package/dist/src/auth/rate-limit.js +38 -0
  14. package/dist/src/auth/rate-limit.js.map +1 -0
  15. package/dist/src/auth/rotation.d.ts +67 -0
  16. package/dist/src/auth/rotation.d.ts.map +1 -0
  17. package/dist/src/auth/rotation.js +190 -0
  18. package/dist/src/auth/rotation.js.map +1 -0
  19. package/dist/src/backfill/project-context-batch-constructor.d.ts +127 -0
  20. package/dist/src/backfill/project-context-batch-constructor.d.ts.map +1 -0
  21. package/dist/src/backfill/project-context-batch-constructor.js +210 -0
  22. package/dist/src/backfill/project-context-batch-constructor.js.map +1 -0
  23. package/dist/src/capture/assistant-text-lookup.d.ts +31 -0
  24. package/dist/src/capture/assistant-text-lookup.d.ts.map +1 -0
  25. package/dist/src/capture/assistant-text-lookup.js +222 -0
  26. package/dist/src/capture/assistant-text-lookup.js.map +1 -0
  27. package/dist/src/capture/auto-capture.d.ts +322 -0
  28. package/dist/src/capture/auto-capture.d.ts.map +1 -0
  29. package/dist/src/capture/auto-capture.js +1167 -0
  30. package/dist/src/capture/auto-capture.js.map +1 -0
  31. package/dist/src/capture/auto-repair.d.ts +125 -0
  32. package/dist/src/capture/auto-repair.d.ts.map +1 -0
  33. package/dist/src/capture/auto-repair.js +280 -0
  34. package/dist/src/capture/auto-repair.js.map +1 -0
  35. package/dist/src/capture/batch-budget.d.ts +90 -0
  36. package/dist/src/capture/batch-budget.d.ts.map +1 -0
  37. package/dist/src/capture/batch-budget.js +148 -0
  38. package/dist/src/capture/batch-budget.js.map +1 -0
  39. package/dist/src/capture/claude-cli-triage-provider.d.ts +28 -0
  40. package/dist/src/capture/claude-cli-triage-provider.d.ts.map +1 -0
  41. package/dist/src/capture/claude-cli-triage-provider.js +101 -0
  42. package/dist/src/capture/claude-cli-triage-provider.js.map +1 -0
  43. package/dist/src/capture/codex-cli-triage-provider.d.ts +17 -0
  44. package/dist/src/capture/codex-cli-triage-provider.d.ts.map +1 -0
  45. package/dist/src/capture/codex-cli-triage-provider.js +91 -0
  46. package/dist/src/capture/codex-cli-triage-provider.js.map +1 -0
  47. package/dist/src/capture/cursor-capture.d.ts +89 -0
  48. package/dist/src/capture/cursor-capture.d.ts.map +1 -0
  49. package/dist/src/capture/cursor-capture.js +121 -0
  50. package/dist/src/capture/cursor-capture.js.map +1 -0
  51. package/dist/src/capture/observability.d.ts +131 -0
  52. package/dist/src/capture/observability.d.ts.map +1 -0
  53. package/dist/src/capture/observability.js +181 -0
  54. package/dist/src/capture/observability.js.map +1 -0
  55. package/dist/src/capture/openai-triage-provider.d.ts +92 -0
  56. package/dist/src/capture/openai-triage-provider.d.ts.map +1 -0
  57. package/dist/src/capture/openai-triage-provider.js +267 -0
  58. package/dist/src/capture/openai-triage-provider.js.map +1 -0
  59. package/dist/src/capture/recover-quarantine.d.ts +273 -0
  60. package/dist/src/capture/recover-quarantine.d.ts.map +1 -0
  61. package/dist/src/capture/recover-quarantine.js +581 -0
  62. package/dist/src/capture/recover-quarantine.js.map +1 -0
  63. package/dist/src/capture/review-queue-index.d.ts +51 -0
  64. package/dist/src/capture/review-queue-index.d.ts.map +1 -0
  65. package/dist/src/capture/review-queue-index.js +204 -0
  66. package/dist/src/capture/review-queue-index.js.map +1 -0
  67. package/dist/src/capture/review-queue.d.ts +47 -0
  68. package/dist/src/capture/review-queue.d.ts.map +1 -0
  69. package/dist/src/capture/review-queue.js +116 -0
  70. package/dist/src/capture/review-queue.js.map +1 -0
  71. package/dist/src/capture/sources.d.ts +53 -0
  72. package/dist/src/capture/sources.d.ts.map +1 -0
  73. package/dist/src/capture/sources.js +55 -0
  74. package/dist/src/capture/sources.js.map +1 -0
  75. package/dist/src/capture/stored-statements.d.ts +9 -0
  76. package/dist/src/capture/stored-statements.d.ts.map +1 -0
  77. package/dist/src/capture/stored-statements.js +63 -0
  78. package/dist/src/capture/stored-statements.js.map +1 -0
  79. package/dist/src/capture/triage-classification.d.ts +92 -0
  80. package/dist/src/capture/triage-classification.d.ts.map +1 -0
  81. package/dist/src/capture/triage-classification.js +94 -0
  82. package/dist/src/capture/triage-classification.js.map +1 -0
  83. package/dist/src/capture/triage-lane.d.ts +39 -0
  84. package/dist/src/capture/triage-lane.d.ts.map +1 -0
  85. package/dist/src/capture/triage-lane.js +217 -0
  86. package/dist/src/capture/triage-lane.js.map +1 -0
  87. package/dist/src/capture/triage-provider-factory.d.ts +36 -0
  88. package/dist/src/capture/triage-provider-factory.d.ts.map +1 -0
  89. package/dist/src/capture/triage-provider-factory.js +55 -0
  90. package/dist/src/capture/triage-provider-factory.js.map +1 -0
  91. package/dist/src/capture/triage-provider.d.ts +82 -0
  92. package/dist/src/capture/triage-provider.d.ts.map +1 -0
  93. package/dist/src/capture/triage-provider.js +126 -0
  94. package/dist/src/capture/triage-provider.js.map +1 -0
  95. package/dist/src/capture/triage.d.ts +30 -0
  96. package/dist/src/capture/triage.d.ts.map +1 -0
  97. package/dist/src/capture/triage.js +50 -0
  98. package/dist/src/capture/triage.js.map +1 -0
  99. package/dist/src/capture/user-statements-recheck.d.ts +22 -0
  100. package/dist/src/capture/user-statements-recheck.d.ts.map +1 -0
  101. package/dist/src/capture/user-statements-recheck.js +181 -0
  102. package/dist/src/capture/user-statements-recheck.js.map +1 -0
  103. package/dist/src/capture/user-statements.d.ts +84 -0
  104. package/dist/src/capture/user-statements.d.ts.map +1 -0
  105. package/dist/src/capture/user-statements.js +617 -0
  106. package/dist/src/capture/user-statements.js.map +1 -0
  107. package/dist/src/cli/agent-homes.d.ts +15 -0
  108. package/dist/src/cli/agent-homes.d.ts.map +1 -0
  109. package/dist/src/cli/agent-homes.js +45 -0
  110. package/dist/src/cli/agent-homes.js.map +1 -0
  111. package/dist/src/cli/commands/backfill.d.ts +3 -0
  112. package/dist/src/cli/commands/backfill.d.ts.map +1 -0
  113. package/dist/src/cli/commands/backfill.js +1379 -0
  114. package/dist/src/cli/commands/backfill.js.map +1 -0
  115. package/dist/src/cli/commands/brief.d.ts +12 -0
  116. package/dist/src/cli/commands/brief.d.ts.map +1 -0
  117. package/dist/src/cli/commands/brief.js +131 -0
  118. package/dist/src/cli/commands/brief.js.map +1 -0
  119. package/dist/src/cli/commands/bulk-ingest.d.ts +3 -0
  120. package/dist/src/cli/commands/bulk-ingest.d.ts.map +1 -0
  121. package/dist/src/cli/commands/bulk-ingest.js +126 -0
  122. package/dist/src/cli/commands/bulk-ingest.js.map +1 -0
  123. package/dist/src/cli/commands/capture-recover.d.ts +40 -0
  124. package/dist/src/cli/commands/capture-recover.d.ts.map +1 -0
  125. package/dist/src/cli/commands/capture-recover.js +194 -0
  126. package/dist/src/cli/commands/capture-recover.js.map +1 -0
  127. package/dist/src/cli/commands/capture.d.ts +12 -0
  128. package/dist/src/cli/commands/capture.d.ts.map +1 -0
  129. package/dist/src/cli/commands/capture.js +304 -0
  130. package/dist/src/cli/commands/capture.js.map +1 -0
  131. package/dist/src/cli/commands/chunk-backfill.d.ts +13 -0
  132. package/dist/src/cli/commands/chunk-backfill.d.ts.map +1 -0
  133. package/dist/src/cli/commands/chunk-backfill.js +157 -0
  134. package/dist/src/cli/commands/chunk-backfill.js.map +1 -0
  135. package/dist/src/cli/commands/compact.d.ts +3 -0
  136. package/dist/src/cli/commands/compact.d.ts.map +1 -0
  137. package/dist/src/cli/commands/compact.js +70 -0
  138. package/dist/src/cli/commands/compact.js.map +1 -0
  139. package/dist/src/cli/commands/cursor-probe.d.ts +20 -0
  140. package/dist/src/cli/commands/cursor-probe.d.ts.map +1 -0
  141. package/dist/src/cli/commands/cursor-probe.js +162 -0
  142. package/dist/src/cli/commands/cursor-probe.js.map +1 -0
  143. package/dist/src/cli/commands/doctor.d.ts +6 -0
  144. package/dist/src/cli/commands/doctor.d.ts.map +1 -0
  145. package/dist/src/cli/commands/doctor.js +259 -0
  146. package/dist/src/cli/commands/doctor.js.map +1 -0
  147. package/dist/src/cli/commands/feedback.d.ts +34 -0
  148. package/dist/src/cli/commands/feedback.d.ts.map +1 -0
  149. package/dist/src/cli/commands/feedback.js +214 -0
  150. package/dist/src/cli/commands/feedback.js.map +1 -0
  151. package/dist/src/cli/commands/hooks-install.d.ts +66 -0
  152. package/dist/src/cli/commands/hooks-install.d.ts.map +1 -0
  153. package/dist/src/cli/commands/hooks-install.js +228 -0
  154. package/dist/src/cli/commands/hooks-install.js.map +1 -0
  155. package/dist/src/cli/commands/import.d.ts +19 -0
  156. package/dist/src/cli/commands/import.d.ts.map +1 -0
  157. package/dist/src/cli/commands/import.js +258 -0
  158. package/dist/src/cli/commands/import.js.map +1 -0
  159. package/dist/src/cli/commands/ingest.d.ts +3 -0
  160. package/dist/src/cli/commands/ingest.d.ts.map +1 -0
  161. package/dist/src/cli/commands/ingest.js +80 -0
  162. package/dist/src/cli/commands/ingest.js.map +1 -0
  163. package/dist/src/cli/commands/mcp-install.d.ts +65 -0
  164. package/dist/src/cli/commands/mcp-install.d.ts.map +1 -0
  165. package/dist/src/cli/commands/mcp-install.js +306 -0
  166. package/dist/src/cli/commands/mcp-install.js.map +1 -0
  167. package/dist/src/cli/commands/menubar.d.ts +127 -0
  168. package/dist/src/cli/commands/menubar.d.ts.map +1 -0
  169. package/dist/src/cli/commands/menubar.js +585 -0
  170. package/dist/src/cli/commands/menubar.js.map +1 -0
  171. package/dist/src/cli/commands/onboard-first-run.d.ts +5 -0
  172. package/dist/src/cli/commands/onboard-first-run.d.ts.map +1 -0
  173. package/dist/src/cli/commands/onboard-first-run.js +156 -0
  174. package/dist/src/cli/commands/onboard-first-run.js.map +1 -0
  175. package/dist/src/cli/commands/onboard.d.ts +336 -0
  176. package/dist/src/cli/commands/onboard.d.ts.map +1 -0
  177. package/dist/src/cli/commands/onboard.js +1873 -0
  178. package/dist/src/cli/commands/onboard.js.map +1 -0
  179. package/dist/src/cli/commands/rebuild.d.ts +12 -0
  180. package/dist/src/cli/commands/rebuild.d.ts.map +1 -0
  181. package/dist/src/cli/commands/rebuild.js +167 -0
  182. package/dist/src/cli/commands/rebuild.js.map +1 -0
  183. package/dist/src/cli/commands/reconcile.d.ts +3 -0
  184. package/dist/src/cli/commands/reconcile.d.ts.map +1 -0
  185. package/dist/src/cli/commands/reconcile.js +68 -0
  186. package/dist/src/cli/commands/reconcile.js.map +1 -0
  187. package/dist/src/cli/commands/reindex.d.ts +3 -0
  188. package/dist/src/cli/commands/reindex.d.ts.map +1 -0
  189. package/dist/src/cli/commands/reindex.js +66 -0
  190. package/dist/src/cli/commands/reindex.js.map +1 -0
  191. package/dist/src/cli/commands/review.d.ts +13 -0
  192. package/dist/src/cli/commands/review.d.ts.map +1 -0
  193. package/dist/src/cli/commands/review.js +401 -0
  194. package/dist/src/cli/commands/review.js.map +1 -0
  195. package/dist/src/cli/commands/save.d.ts +3 -0
  196. package/dist/src/cli/commands/save.d.ts.map +1 -0
  197. package/dist/src/cli/commands/save.js +111 -0
  198. package/dist/src/cli/commands/save.js.map +1 -0
  199. package/dist/src/cli/commands/search.d.ts +37 -0
  200. package/dist/src/cli/commands/search.d.ts.map +1 -0
  201. package/dist/src/cli/commands/search.js +118 -0
  202. package/dist/src/cli/commands/search.js.map +1 -0
  203. package/dist/src/cli/commands/setup.d.ts +30 -0
  204. package/dist/src/cli/commands/setup.d.ts.map +1 -0
  205. package/dist/src/cli/commands/setup.js +122 -0
  206. package/dist/src/cli/commands/setup.js.map +1 -0
  207. package/dist/src/cli/commands/stats.d.ts +3 -0
  208. package/dist/src/cli/commands/stats.d.ts.map +1 -0
  209. package/dist/src/cli/commands/stats.js +42 -0
  210. package/dist/src/cli/commands/stats.js.map +1 -0
  211. package/dist/src/cli/commands/status.d.ts +17 -0
  212. package/dist/src/cli/commands/status.d.ts.map +1 -0
  213. package/dist/src/cli/commands/status.js +206 -0
  214. package/dist/src/cli/commands/status.js.map +1 -0
  215. package/dist/src/cli/commands/token-issue.d.ts +3 -0
  216. package/dist/src/cli/commands/token-issue.d.ts.map +1 -0
  217. package/dist/src/cli/commands/token-issue.js +33 -0
  218. package/dist/src/cli/commands/token-issue.js.map +1 -0
  219. package/dist/src/cli/commands/triage.d.ts +3 -0
  220. package/dist/src/cli/commands/triage.d.ts.map +1 -0
  221. package/dist/src/cli/commands/triage.js +127 -0
  222. package/dist/src/cli/commands/triage.js.map +1 -0
  223. package/dist/src/cli/commands/uninstall.d.ts +85 -0
  224. package/dist/src/cli/commands/uninstall.d.ts.map +1 -0
  225. package/dist/src/cli/commands/uninstall.js +512 -0
  226. package/dist/src/cli/commands/uninstall.js.map +1 -0
  227. package/dist/src/cli/commands/update.d.ts +105 -0
  228. package/dist/src/cli/commands/update.d.ts.map +1 -0
  229. package/dist/src/cli/commands/update.js +559 -0
  230. package/dist/src/cli/commands/update.js.map +1 -0
  231. package/dist/src/cli/default-config-path.d.ts +15 -0
  232. package/dist/src/cli/default-config-path.d.ts.map +1 -0
  233. package/dist/src/cli/default-config-path.js +28 -0
  234. package/dist/src/cli/default-config-path.js.map +1 -0
  235. package/dist/src/cli/feedback/feedback-config.d.ts +67 -0
  236. package/dist/src/cli/feedback/feedback-config.d.ts.map +1 -0
  237. package/dist/src/cli/feedback/feedback-config.js +169 -0
  238. package/dist/src/cli/feedback/feedback-config.js.map +1 -0
  239. package/dist/src/cli/feedback/feedback-history.d.ts +11 -0
  240. package/dist/src/cli/feedback/feedback-history.d.ts.map +1 -0
  241. package/dist/src/cli/feedback/feedback-history.js +145 -0
  242. package/dist/src/cli/feedback/feedback-history.js.map +1 -0
  243. package/dist/src/cli/feedback/feedback-payload.d.ts +74 -0
  244. package/dist/src/cli/feedback/feedback-payload.d.ts.map +1 -0
  245. package/dist/src/cli/feedback/feedback-payload.js +10 -0
  246. package/dist/src/cli/feedback/feedback-payload.js.map +1 -0
  247. package/dist/src/cli/feedback/feedback-relay.d.ts +15 -0
  248. package/dist/src/cli/feedback/feedback-relay.d.ts.map +1 -0
  249. package/dist/src/cli/feedback/feedback-relay.js +47 -0
  250. package/dist/src/cli/feedback/feedback-relay.js.map +1 -0
  251. package/dist/src/cli/feedback/feedback-status.d.ts +11 -0
  252. package/dist/src/cli/feedback/feedback-status.d.ts.map +1 -0
  253. package/dist/src/cli/feedback/feedback-status.js +122 -0
  254. package/dist/src/cli/feedback/feedback-status.js.map +1 -0
  255. package/dist/src/cli/feedback/invite.d.ts +17 -0
  256. package/dist/src/cli/feedback/invite.d.ts.map +1 -0
  257. package/dist/src/cli/feedback/invite.js +73 -0
  258. package/dist/src/cli/feedback/invite.js.map +1 -0
  259. package/dist/src/cli/feedback/relay-secret-store.d.ts +32 -0
  260. package/dist/src/cli/feedback/relay-secret-store.d.ts.map +1 -0
  261. package/dist/src/cli/feedback/relay-secret-store.js +137 -0
  262. package/dist/src/cli/feedback/relay-secret-store.js.map +1 -0
  263. package/dist/src/cli/hooks-writers/claude-code-policy-script.d.ts +35 -0
  264. package/dist/src/cli/hooks-writers/claude-code-policy-script.d.ts.map +1 -0
  265. package/dist/src/cli/hooks-writers/claude-code-policy-script.js +122 -0
  266. package/dist/src/cli/hooks-writers/claude-code-policy-script.js.map +1 -0
  267. package/dist/src/cli/hooks-writers/claude-code.d.ts +63 -0
  268. package/dist/src/cli/hooks-writers/claude-code.d.ts.map +1 -0
  269. package/dist/src/cli/hooks-writers/claude-code.js +289 -0
  270. package/dist/src/cli/hooks-writers/claude-code.js.map +1 -0
  271. package/dist/src/cli/hooks-writers/codex.d.ts +16 -0
  272. package/dist/src/cli/hooks-writers/codex.d.ts.map +1 -0
  273. package/dist/src/cli/hooks-writers/codex.js +17 -0
  274. package/dist/src/cli/hooks-writers/codex.js.map +1 -0
  275. package/dist/src/cli/hooks-writers/errors.d.ts +16 -0
  276. package/dist/src/cli/hooks-writers/errors.d.ts.map +1 -0
  277. package/dist/src/cli/hooks-writers/errors.js +24 -0
  278. package/dist/src/cli/hooks-writers/errors.js.map +1 -0
  279. package/dist/src/cli/hooks-writers/index.d.ts +23 -0
  280. package/dist/src/cli/hooks-writers/index.d.ts.map +1 -0
  281. package/dist/src/cli/hooks-writers/index.js +34 -0
  282. package/dist/src/cli/hooks-writers/index.js.map +1 -0
  283. package/dist/src/cli/hooks-writers/state.d.ts +43 -0
  284. package/dist/src/cli/hooks-writers/state.d.ts.map +1 -0
  285. package/dist/src/cli/hooks-writers/state.js +225 -0
  286. package/dist/src/cli/hooks-writers/state.js.map +1 -0
  287. package/dist/src/cli/hooks-writers/types.d.ts +28 -0
  288. package/dist/src/cli/hooks-writers/types.d.ts.map +1 -0
  289. package/dist/src/cli/hooks-writers/types.js +8 -0
  290. package/dist/src/cli/hooks-writers/types.js.map +1 -0
  291. package/dist/src/cli/http-client.d.ts +128 -0
  292. package/dist/src/cli/http-client.d.ts.map +1 -0
  293. package/dist/src/cli/http-client.js +401 -0
  294. package/dist/src/cli/http-client.js.map +1 -0
  295. package/dist/src/cli/index.d.ts +4 -0
  296. package/dist/src/cli/index.d.ts.map +1 -0
  297. package/dist/src/cli/index.js +99 -0
  298. package/dist/src/cli/index.js.map +1 -0
  299. package/dist/src/cli/job-poller.d.ts +13 -0
  300. package/dist/src/cli/job-poller.d.ts.map +1 -0
  301. package/dist/src/cli/job-poller.js +29 -0
  302. package/dist/src/cli/job-poller.js.map +1 -0
  303. package/dist/src/cli/mcp-config-writers/codex-toml.d.ts +20 -0
  304. package/dist/src/cli/mcp-config-writers/codex-toml.d.ts.map +1 -0
  305. package/dist/src/cli/mcp-config-writers/codex-toml.js +918 -0
  306. package/dist/src/cli/mcp-config-writers/codex-toml.js.map +1 -0
  307. package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.d.ts +11 -0
  308. package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.d.ts.map +1 -0
  309. package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.js +152 -0
  310. package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.js.map +1 -0
  311. package/dist/src/cli/mcp-config-writers/errors.d.ts +17 -0
  312. package/dist/src/cli/mcp-config-writers/errors.d.ts.map +1 -0
  313. package/dist/src/cli/mcp-config-writers/errors.js +13 -0
  314. package/dist/src/cli/mcp-config-writers/errors.js.map +1 -0
  315. package/dist/src/cli/mcp-config-writers/index.d.ts +28 -0
  316. package/dist/src/cli/mcp-config-writers/index.d.ts.map +1 -0
  317. package/dist/src/cli/mcp-config-writers/index.js +70 -0
  318. package/dist/src/cli/mcp-config-writers/index.js.map +1 -0
  319. package/dist/src/cli/mcp-config-writers/json-config.d.ts +20 -0
  320. package/dist/src/cli/mcp-config-writers/json-config.d.ts.map +1 -0
  321. package/dist/src/cli/mcp-config-writers/json-config.js +301 -0
  322. package/dist/src/cli/mcp-config-writers/json-config.js.map +1 -0
  323. package/dist/src/cli/mcp-config-writers/left-in-folder.d.ts +18 -0
  324. package/dist/src/cli/mcp-config-writers/left-in-folder.d.ts.map +1 -0
  325. package/dist/src/cli/mcp-config-writers/left-in-folder.js +140 -0
  326. package/dist/src/cli/mcp-config-writers/left-in-folder.js.map +1 -0
  327. package/dist/src/cli/mcp-config-writers/redact.d.ts +28 -0
  328. package/dist/src/cli/mcp-config-writers/redact.d.ts.map +1 -0
  329. package/dist/src/cli/mcp-config-writers/redact.js +48 -0
  330. package/dist/src/cli/mcp-config-writers/redact.js.map +1 -0
  331. package/dist/src/cli/mcp-config-writers/types.d.ts +46 -0
  332. package/dist/src/cli/mcp-config-writers/types.d.ts.map +1 -0
  333. package/dist/src/cli/mcp-config-writers/types.js +5 -0
  334. package/dist/src/cli/mcp-config-writers/types.js.map +1 -0
  335. package/dist/src/cli/output.d.ts +8 -0
  336. package/dist/src/cli/output.d.ts.map +1 -0
  337. package/dist/src/cli/output.js +34 -0
  338. package/dist/src/cli/output.js.map +1 -0
  339. package/dist/src/cli/postinstall-menubar.d.ts +38 -0
  340. package/dist/src/cli/postinstall-menubar.d.ts.map +1 -0
  341. package/dist/src/cli/postinstall-menubar.js +139 -0
  342. package/dist/src/cli/postinstall-menubar.js.map +1 -0
  343. package/dist/src/cli/status/friend-header.d.ts +61 -0
  344. package/dist/src/cli/status/friend-header.d.ts.map +1 -0
  345. package/dist/src/cli/status/friend-header.js +727 -0
  346. package/dist/src/cli/status/friend-header.js.map +1 -0
  347. package/dist/src/cli/status/local-signals.d.ts +89 -0
  348. package/dist/src/cli/status/local-signals.d.ts.map +1 -0
  349. package/dist/src/cli/status/local-signals.js +194 -0
  350. package/dist/src/cli/status/local-signals.js.map +1 -0
  351. package/dist/src/cli/token.d.ts +37 -0
  352. package/dist/src/cli/token.d.ts.map +1 -0
  353. package/dist/src/cli/token.js +105 -0
  354. package/dist/src/cli/token.js.map +1 -0
  355. package/dist/src/cli/ui.d.ts +47 -0
  356. package/dist/src/cli/ui.d.ts.map +1 -0
  357. package/dist/src/cli/ui.js +166 -0
  358. package/dist/src/cli/ui.js.map +1 -0
  359. package/dist/src/cli/uninstall/mcp-uninstall.d.ts +33 -0
  360. package/dist/src/cli/uninstall/mcp-uninstall.d.ts.map +1 -0
  361. package/dist/src/cli/uninstall/mcp-uninstall.js +116 -0
  362. package/dist/src/cli/uninstall/mcp-uninstall.js.map +1 -0
  363. package/dist/src/config/loader.d.ts +9 -0
  364. package/dist/src/config/loader.d.ts.map +1 -0
  365. package/dist/src/config/loader.js +73 -0
  366. package/dist/src/config/loader.js.map +1 -0
  367. package/dist/src/config/schema.d.ts +956 -0
  368. package/dist/src/config/schema.d.ts.map +1 -0
  369. package/dist/src/config/schema.js +339 -0
  370. package/dist/src/config/schema.js.map +1 -0
  371. package/dist/src/diagnostics/claude-preflight.d.ts +35 -0
  372. package/dist/src/diagnostics/claude-preflight.d.ts.map +1 -0
  373. package/dist/src/diagnostics/claude-preflight.js +90 -0
  374. package/dist/src/diagnostics/claude-preflight.js.map +1 -0
  375. package/dist/src/diagnostics/codex-preflight.d.ts +43 -0
  376. package/dist/src/diagnostics/codex-preflight.d.ts.map +1 -0
  377. package/dist/src/diagnostics/codex-preflight.js +128 -0
  378. package/dist/src/diagnostics/codex-preflight.js.map +1 -0
  379. package/dist/src/diagnostics/doctor.d.ts +125 -0
  380. package/dist/src/diagnostics/doctor.d.ts.map +1 -0
  381. package/dist/src/diagnostics/doctor.js +450 -0
  382. package/dist/src/diagnostics/doctor.js.map +1 -0
  383. package/dist/src/diagnostics/install-layout.d.ts +40 -0
  384. package/dist/src/diagnostics/install-layout.d.ts.map +1 -0
  385. package/dist/src/diagnostics/install-layout.js +55 -0
  386. package/dist/src/diagnostics/install-layout.js.map +1 -0
  387. package/dist/src/diagnostics/memory-coverage.d.ts +54 -0
  388. package/dist/src/diagnostics/memory-coverage.d.ts.map +1 -0
  389. package/dist/src/diagnostics/memory-coverage.js +272 -0
  390. package/dist/src/diagnostics/memory-coverage.js.map +1 -0
  391. package/dist/src/diagnostics/notify.d.ts +107 -0
  392. package/dist/src/diagnostics/notify.d.ts.map +1 -0
  393. package/dist/src/diagnostics/notify.js +217 -0
  394. package/dist/src/diagnostics/notify.js.map +1 -0
  395. package/dist/src/diagnostics/repair-prompt.d.ts +49 -0
  396. package/dist/src/diagnostics/repair-prompt.d.ts.map +1 -0
  397. package/dist/src/diagnostics/repair-prompt.js +223 -0
  398. package/dist/src/diagnostics/repair-prompt.js.map +1 -0
  399. package/dist/src/ingestion/bulk-ingest.d.ts +11 -0
  400. package/dist/src/ingestion/bulk-ingest.d.ts.map +1 -0
  401. package/dist/src/ingestion/bulk-ingest.js +11 -0
  402. package/dist/src/ingestion/bulk-ingest.js.map +1 -0
  403. package/dist/src/ingestion/chunk-meta.d.ts +85 -0
  404. package/dist/src/ingestion/chunk-meta.d.ts.map +1 -0
  405. package/dist/src/ingestion/chunk-meta.js +167 -0
  406. package/dist/src/ingestion/chunk-meta.js.map +1 -0
  407. package/dist/src/ingestion/chunk-text.d.ts +39 -0
  408. package/dist/src/ingestion/chunk-text.d.ts.map +1 -0
  409. package/dist/src/ingestion/chunk-text.js +114 -0
  410. package/dist/src/ingestion/chunk-text.js.map +1 -0
  411. package/dist/src/ingestion/cursor/cursor-store.d.ts +177 -0
  412. package/dist/src/ingestion/cursor/cursor-store.d.ts.map +1 -0
  413. package/dist/src/ingestion/cursor/cursor-store.js +242 -0
  414. package/dist/src/ingestion/cursor/cursor-store.js.map +1 -0
  415. package/dist/src/ingestion/cursor/enrich-roots.d.ts +16 -0
  416. package/dist/src/ingestion/cursor/enrich-roots.d.ts.map +1 -0
  417. package/dist/src/ingestion/cursor/enrich-roots.js +22 -0
  418. package/dist/src/ingestion/cursor/enrich-roots.js.map +1 -0
  419. package/dist/src/ingestion/cursor/vscdb-reader.d.ts +32 -0
  420. package/dist/src/ingestion/cursor/vscdb-reader.d.ts.map +1 -0
  421. package/dist/src/ingestion/cursor/vscdb-reader.js +113 -0
  422. package/dist/src/ingestion/cursor/vscdb-reader.js.map +1 -0
  423. package/dist/src/ingestion/cursor/workspace-root.d.ts +96 -0
  424. package/dist/src/ingestion/cursor/workspace-root.d.ts.map +1 -0
  425. package/dist/src/ingestion/cursor/workspace-root.js +187 -0
  426. package/dist/src/ingestion/cursor/workspace-root.js.map +1 -0
  427. package/dist/src/ingestion/extractor.d.ts +16 -0
  428. package/dist/src/ingestion/extractor.d.ts.map +1 -0
  429. package/dist/src/ingestion/extractor.js +85 -0
  430. package/dist/src/ingestion/extractor.js.map +1 -0
  431. package/dist/src/ingestion/extractors/docx.d.ts +3 -0
  432. package/dist/src/ingestion/extractors/docx.d.ts.map +1 -0
  433. package/dist/src/ingestion/extractors/docx.js +20 -0
  434. package/dist/src/ingestion/extractors/docx.js.map +1 -0
  435. package/dist/src/ingestion/extractors/pdf.d.ts +3 -0
  436. package/dist/src/ingestion/extractors/pdf.d.ts.map +1 -0
  437. package/dist/src/ingestion/extractors/pdf.js +32 -0
  438. package/dist/src/ingestion/extractors/pdf.js.map +1 -0
  439. package/dist/src/ingestion/historical-campaign.d.ts +340 -0
  440. package/dist/src/ingestion/historical-campaign.d.ts.map +1 -0
  441. package/dist/src/ingestion/historical-campaign.js +1010 -0
  442. package/dist/src/ingestion/historical-campaign.js.map +1 -0
  443. package/dist/src/ingestion/ignored-paths.d.ts +20 -0
  444. package/dist/src/ingestion/ignored-paths.d.ts.map +1 -0
  445. package/dist/src/ingestion/ignored-paths.js +45 -0
  446. package/dist/src/ingestion/ignored-paths.js.map +1 -0
  447. package/dist/src/ingestion/inbox-core/conversation-fingerprint.d.ts +2 -0
  448. package/dist/src/ingestion/inbox-core/conversation-fingerprint.d.ts.map +1 -0
  449. package/dist/src/ingestion/inbox-core/conversation-fingerprint.js +27 -0
  450. package/dist/src/ingestion/inbox-core/conversation-fingerprint.js.map +1 -0
  451. package/dist/src/ingestion/inbox-core/conversation-key.d.ts +2 -0
  452. package/dist/src/ingestion/inbox-core/conversation-key.d.ts.map +1 -0
  453. package/dist/src/ingestion/inbox-core/conversation-key.js +31 -0
  454. package/dist/src/ingestion/inbox-core/conversation-key.js.map +1 -0
  455. package/dist/src/ingestion/inbox-core/extensions.d.ts +3 -0
  456. package/dist/src/ingestion/inbox-core/extensions.d.ts.map +1 -0
  457. package/dist/src/ingestion/inbox-core/extensions.js +16 -0
  458. package/dist/src/ingestion/inbox-core/extensions.js.map +1 -0
  459. package/dist/src/ingestion/inbox-core/idempotency.d.ts +2 -0
  460. package/dist/src/ingestion/inbox-core/idempotency.d.ts.map +1 -0
  461. package/dist/src/ingestion/inbox-core/idempotency.js +22 -0
  462. package/dist/src/ingestion/inbox-core/idempotency.js.map +1 -0
  463. package/dist/src/ingestion/inbox-core/index.d.ts +20 -0
  464. package/dist/src/ingestion/inbox-core/index.d.ts.map +1 -0
  465. package/dist/src/ingestion/inbox-core/index.js +20 -0
  466. package/dist/src/ingestion/inbox-core/index.js.map +1 -0
  467. package/dist/src/ingestion/inbox-core/source-detection.d.ts +2 -0
  468. package/dist/src/ingestion/inbox-core/source-detection.d.ts.map +1 -0
  469. package/dist/src/ingestion/inbox-core/source-detection.js +23 -0
  470. package/dist/src/ingestion/inbox-core/source-detection.js.map +1 -0
  471. package/dist/src/ingestion/inbox-core/source-sniffer.d.ts +11 -0
  472. package/dist/src/ingestion/inbox-core/source-sniffer.d.ts.map +1 -0
  473. package/dist/src/ingestion/inbox-core/source-sniffer.js +69 -0
  474. package/dist/src/ingestion/inbox-core/source-sniffer.js.map +1 -0
  475. package/dist/src/ingestion/inbox-core/zip-sniffer.d.ts +70 -0
  476. package/dist/src/ingestion/inbox-core/zip-sniffer.d.ts.map +1 -0
  477. package/dist/src/ingestion/inbox-core/zip-sniffer.js +161 -0
  478. package/dist/src/ingestion/inbox-core/zip-sniffer.js.map +1 -0
  479. package/dist/src/ingestion/inbox-watcher.d.ts +12 -0
  480. package/dist/src/ingestion/inbox-watcher.d.ts.map +1 -0
  481. package/dist/src/ingestion/inbox-watcher.js +83 -0
  482. package/dist/src/ingestion/inbox-watcher.js.map +1 -0
  483. package/dist/src/ingestion/indexer.d.ts +39 -0
  484. package/dist/src/ingestion/indexer.d.ts.map +1 -0
  485. package/dist/src/ingestion/indexer.js +111 -0
  486. package/dist/src/ingestion/indexer.js.map +1 -0
  487. package/dist/src/ingestion/metadata-extraction.d.ts +56 -0
  488. package/dist/src/ingestion/metadata-extraction.d.ts.map +1 -0
  489. package/dist/src/ingestion/metadata-extraction.js +151 -0
  490. package/dist/src/ingestion/metadata-extraction.js.map +1 -0
  491. package/dist/src/ingestion/parsers/chatgpt-web.d.ts +29 -0
  492. package/dist/src/ingestion/parsers/chatgpt-web.d.ts.map +1 -0
  493. package/dist/src/ingestion/parsers/chatgpt-web.js +100 -0
  494. package/dist/src/ingestion/parsers/chatgpt-web.js.map +1 -0
  495. package/dist/src/ingestion/parsers/claude-code-jsonl.d.ts +26 -0
  496. package/dist/src/ingestion/parsers/claude-code-jsonl.d.ts.map +1 -0
  497. package/dist/src/ingestion/parsers/claude-code-jsonl.js +125 -0
  498. package/dist/src/ingestion/parsers/claude-code-jsonl.js.map +1 -0
  499. package/dist/src/ingestion/parsers/claude-desktop-sessions.d.ts +17 -0
  500. package/dist/src/ingestion/parsers/claude-desktop-sessions.d.ts.map +1 -0
  501. package/dist/src/ingestion/parsers/claude-desktop-sessions.js +112 -0
  502. package/dist/src/ingestion/parsers/claude-desktop-sessions.js.map +1 -0
  503. package/dist/src/ingestion/parsers/claude-web.d.ts +24 -0
  504. package/dist/src/ingestion/parsers/claude-web.d.ts.map +1 -0
  505. package/dist/src/ingestion/parsers/claude-web.js +75 -0
  506. package/dist/src/ingestion/parsers/claude-web.js.map +1 -0
  507. package/dist/src/ingestion/parsers/codex-jsonl.d.ts +18 -0
  508. package/dist/src/ingestion/parsers/codex-jsonl.d.ts.map +1 -0
  509. package/dist/src/ingestion/parsers/codex-jsonl.js +150 -0
  510. package/dist/src/ingestion/parsers/codex-jsonl.js.map +1 -0
  511. package/dist/src/ingestion/parsers/gemini-web.d.ts +16 -0
  512. package/dist/src/ingestion/parsers/gemini-web.d.ts.map +1 -0
  513. package/dist/src/ingestion/parsers/gemini-web.js +170 -0
  514. package/dist/src/ingestion/parsers/gemini-web.js.map +1 -0
  515. package/dist/src/ingestion/parsers/grok-cli.d.ts +19 -0
  516. package/dist/src/ingestion/parsers/grok-cli.d.ts.map +1 -0
  517. package/dist/src/ingestion/parsers/grok-cli.js +126 -0
  518. package/dist/src/ingestion/parsers/grok-cli.js.map +1 -0
  519. package/dist/src/ingestion/parsers/grok-web.d.ts +40 -0
  520. package/dist/src/ingestion/parsers/grok-web.d.ts.map +1 -0
  521. package/dist/src/ingestion/parsers/grok-web.js +67 -0
  522. package/dist/src/ingestion/parsers/grok-web.js.map +1 -0
  523. package/dist/src/ingestion/parsers/turns.d.ts +36 -0
  524. package/dist/src/ingestion/parsers/turns.d.ts.map +1 -0
  525. package/dist/src/ingestion/parsers/turns.js +25 -0
  526. package/dist/src/ingestion/parsers/turns.js.map +1 -0
  527. package/dist/src/ingestion/parsers/types.d.ts +47 -0
  528. package/dist/src/ingestion/parsers/types.d.ts.map +1 -0
  529. package/dist/src/ingestion/parsers/types.js +26 -0
  530. package/dist/src/ingestion/parsers/types.js.map +1 -0
  531. package/dist/src/ingestion/report-cards.d.ts +75 -0
  532. package/dist/src/ingestion/report-cards.d.ts.map +1 -0
  533. package/dist/src/ingestion/report-cards.js +224 -0
  534. package/dist/src/ingestion/report-cards.js.map +1 -0
  535. package/dist/src/ingestion/scanner.d.ts +48 -0
  536. package/dist/src/ingestion/scanner.d.ts.map +1 -0
  537. package/dist/src/ingestion/scanner.js +131 -0
  538. package/dist/src/ingestion/scanner.js.map +1 -0
  539. package/dist/src/ingestion/skip-quarantine.d.ts +10 -0
  540. package/dist/src/ingestion/skip-quarantine.d.ts.map +1 -0
  541. package/dist/src/ingestion/skip-quarantine.js +35 -0
  542. package/dist/src/ingestion/skip-quarantine.js.map +1 -0
  543. package/dist/src/ingestion/staging.d.ts +109 -0
  544. package/dist/src/ingestion/staging.d.ts.map +1 -0
  545. package/dist/src/ingestion/staging.js +411 -0
  546. package/dist/src/ingestion/staging.js.map +1 -0
  547. package/dist/src/ingestion/watcher.d.ts +65 -0
  548. package/dist/src/ingestion/watcher.d.ts.map +1 -0
  549. package/dist/src/ingestion/watcher.js +182 -0
  550. package/dist/src/ingestion/watcher.js.map +1 -0
  551. package/dist/src/jobs/codex-override-handler.d.ts +3 -0
  552. package/dist/src/jobs/codex-override-handler.d.ts.map +1 -0
  553. package/dist/src/jobs/codex-override-handler.js +16 -0
  554. package/dist/src/jobs/codex-override-handler.js.map +1 -0
  555. package/dist/src/jobs/handlers/compact.d.ts +30 -0
  556. package/dist/src/jobs/handlers/compact.d.ts.map +1 -0
  557. package/dist/src/jobs/handlers/compact.js +360 -0
  558. package/dist/src/jobs/handlers/compact.js.map +1 -0
  559. package/dist/src/jobs/handlers/dedupe-conversations.d.ts +134 -0
  560. package/dist/src/jobs/handlers/dedupe-conversations.d.ts.map +1 -0
  561. package/dist/src/jobs/handlers/dedupe-conversations.js +371 -0
  562. package/dist/src/jobs/handlers/dedupe-conversations.js.map +1 -0
  563. package/dist/src/jobs/handlers/ingest.d.ts +13 -0
  564. package/dist/src/jobs/handlers/ingest.d.ts.map +1 -0
  565. package/dist/src/jobs/handlers/ingest.js +557 -0
  566. package/dist/src/jobs/handlers/ingest.js.map +1 -0
  567. package/dist/src/jobs/handlers/optimize.d.ts +11 -0
  568. package/dist/src/jobs/handlers/optimize.d.ts.map +1 -0
  569. package/dist/src/jobs/handlers/optimize.js +12 -0
  570. package/dist/src/jobs/handlers/optimize.js.map +1 -0
  571. package/dist/src/jobs/handlers/reconcile.d.ts +57 -0
  572. package/dist/src/jobs/handlers/reconcile.d.ts.map +1 -0
  573. package/dist/src/jobs/handlers/reconcile.js +685 -0
  574. package/dist/src/jobs/handlers/reconcile.js.map +1 -0
  575. package/dist/src/jobs/handlers/reindex.d.ts +38 -0
  576. package/dist/src/jobs/handlers/reindex.d.ts.map +1 -0
  577. package/dist/src/jobs/handlers/reindex.js +63 -0
  578. package/dist/src/jobs/handlers/reindex.js.map +1 -0
  579. package/dist/src/jobs/handlers/save.d.ts +10 -0
  580. package/dist/src/jobs/handlers/save.d.ts.map +1 -0
  581. package/dist/src/jobs/handlers/save.js +316 -0
  582. package/dist/src/jobs/handlers/save.js.map +1 -0
  583. package/dist/src/jobs/handlers/triage.d.ts +47 -0
  584. package/dist/src/jobs/handlers/triage.d.ts.map +1 -0
  585. package/dist/src/jobs/handlers/triage.js +95 -0
  586. package/dist/src/jobs/handlers/triage.js.map +1 -0
  587. package/dist/src/jobs/maintenance-scheduler.d.ts +30 -0
  588. package/dist/src/jobs/maintenance-scheduler.d.ts.map +1 -0
  589. package/dist/src/jobs/maintenance-scheduler.js +41 -0
  590. package/dist/src/jobs/maintenance-scheduler.js.map +1 -0
  591. package/dist/src/jobs/queue.d.ts +157 -0
  592. package/dist/src/jobs/queue.d.ts.map +1 -0
  593. package/dist/src/jobs/queue.js +759 -0
  594. package/dist/src/jobs/queue.js.map +1 -0
  595. package/dist/src/jobs/types.d.ts +53 -0
  596. package/dist/src/jobs/types.d.ts.map +1 -0
  597. package/dist/src/jobs/types.js +33 -0
  598. package/dist/src/jobs/types.js.map +1 -0
  599. package/dist/src/jobs/worker-entry.d.ts +10 -0
  600. package/dist/src/jobs/worker-entry.d.ts.map +1 -0
  601. package/dist/src/jobs/worker-entry.js +252 -0
  602. package/dist/src/jobs/worker-entry.js.map +1 -0
  603. package/dist/src/jobs/worker-process.d.ts +67 -0
  604. package/dist/src/jobs/worker-process.d.ts.map +1 -0
  605. package/dist/src/jobs/worker-process.js +227 -0
  606. package/dist/src/jobs/worker-process.js.map +1 -0
  607. package/dist/src/jobs/worker.d.ts +11 -0
  608. package/dist/src/jobs/worker.d.ts.map +1 -0
  609. package/dist/src/jobs/worker.js +14 -0
  610. package/dist/src/jobs/worker.js.map +1 -0
  611. package/dist/src/main.d.ts +2 -0
  612. package/dist/src/main.d.ts.map +1 -0
  613. package/dist/src/main.js +683 -0
  614. package/dist/src/main.js.map +1 -0
  615. package/dist/src/mcp/capture-diagnostics.d.ts +51 -0
  616. package/dist/src/mcp/capture-diagnostics.d.ts.map +1 -0
  617. package/dist/src/mcp/capture-diagnostics.js +127 -0
  618. package/dist/src/mcp/capture-diagnostics.js.map +1 -0
  619. package/dist/src/mcp/errors.d.ts +8 -0
  620. package/dist/src/mcp/errors.d.ts.map +1 -0
  621. package/dist/src/mcp/errors.js +69 -0
  622. package/dist/src/mcp/errors.js.map +1 -0
  623. package/dist/src/mcp/memory-diagnostics.d.ts +6 -0
  624. package/dist/src/mcp/memory-diagnostics.d.ts.map +1 -0
  625. package/dist/src/mcp/memory-diagnostics.js +51 -0
  626. package/dist/src/mcp/memory-diagnostics.js.map +1 -0
  627. package/dist/src/mcp/names.d.ts +48 -0
  628. package/dist/src/mcp/names.d.ts.map +1 -0
  629. package/dist/src/mcp/names.js +77 -0
  630. package/dist/src/mcp/names.js.map +1 -0
  631. package/dist/src/mcp/server.d.ts +19 -0
  632. package/dist/src/mcp/server.d.ts.map +1 -0
  633. package/dist/src/mcp/server.js +184 -0
  634. package/dist/src/mcp/server.js.map +1 -0
  635. package/dist/src/mcp/stdio.d.ts +2 -0
  636. package/dist/src/mcp/stdio.d.ts.map +1 -0
  637. package/dist/src/mcp/stdio.js +8 -0
  638. package/dist/src/mcp/stdio.js.map +1 -0
  639. package/dist/src/mcp/tools/context-pack.d.ts +35 -0
  640. package/dist/src/mcp/tools/context-pack.d.ts.map +1 -0
  641. package/dist/src/mcp/tools/context-pack.js +279 -0
  642. package/dist/src/mcp/tools/context-pack.js.map +1 -0
  643. package/dist/src/mcp/tools/conversations-search.d.ts +38 -0
  644. package/dist/src/mcp/tools/conversations-search.d.ts.map +1 -0
  645. package/dist/src/mcp/tools/conversations-search.js +79 -0
  646. package/dist/src/mcp/tools/conversations-search.js.map +1 -0
  647. package/dist/src/mcp/tools/evidence-feedback.d.ts +60 -0
  648. package/dist/src/mcp/tools/evidence-feedback.d.ts.map +1 -0
  649. package/dist/src/mcp/tools/evidence-feedback.js +62 -0
  650. package/dist/src/mcp/tools/evidence-feedback.js.map +1 -0
  651. package/dist/src/mcp/tools/log-outcome.d.ts +72 -0
  652. package/dist/src/mcp/tools/log-outcome.d.ts.map +1 -0
  653. package/dist/src/mcp/tools/log-outcome.js +59 -0
  654. package/dist/src/mcp/tools/log-outcome.js.map +1 -0
  655. package/dist/src/mcp/tools/open-evidence.d.ts +37 -0
  656. package/dist/src/mcp/tools/open-evidence.d.ts.map +1 -0
  657. package/dist/src/mcp/tools/open-evidence.js +72 -0
  658. package/dist/src/mcp/tools/open-evidence.js.map +1 -0
  659. package/dist/src/mcp/tools/save.d.ts +37 -0
  660. package/dist/src/mcp/tools/save.d.ts.map +1 -0
  661. package/dist/src/mcp/tools/save.js +65 -0
  662. package/dist/src/mcp/tools/save.js.map +1 -0
  663. package/dist/src/mcp/tools/search.d.ts +37 -0
  664. package/dist/src/mcp/tools/search.d.ts.map +1 -0
  665. package/dist/src/mcp/tools/search.js +95 -0
  666. package/dist/src/mcp/tools/search.js.map +1 -0
  667. package/dist/src/mcp/tools/status.d.ts +31 -0
  668. package/dist/src/mcp/tools/status.d.ts.map +1 -0
  669. package/dist/src/mcp/tools/status.js +63 -0
  670. package/dist/src/mcp/tools/status.js.map +1 -0
  671. package/dist/src/observability/coverage.d.ts +100 -0
  672. package/dist/src/observability/coverage.d.ts.map +1 -0
  673. package/dist/src/observability/coverage.js +178 -0
  674. package/dist/src/observability/coverage.js.map +1 -0
  675. package/dist/src/observability/embedding-events.d.ts +52 -0
  676. package/dist/src/observability/embedding-events.d.ts.map +1 -0
  677. package/dist/src/observability/embedding-events.js +149 -0
  678. package/dist/src/observability/embedding-events.js.map +1 -0
  679. package/dist/src/observability/index-events.d.ts +70 -0
  680. package/dist/src/observability/index-events.d.ts.map +1 -0
  681. package/dist/src/observability/index-events.js +148 -0
  682. package/dist/src/observability/index-events.js.map +1 -0
  683. package/dist/src/observability/onboarding-metric.d.ts +131 -0
  684. package/dist/src/observability/onboarding-metric.d.ts.map +1 -0
  685. package/dist/src/observability/onboarding-metric.js +352 -0
  686. package/dist/src/observability/onboarding-metric.js.map +1 -0
  687. package/dist/src/observability/retrieval-feedback.d.ts +82 -0
  688. package/dist/src/observability/retrieval-feedback.d.ts.map +1 -0
  689. package/dist/src/observability/retrieval-feedback.js +231 -0
  690. package/dist/src/observability/retrieval-feedback.js.map +1 -0
  691. package/dist/src/observability/rift-context.d.ts +53 -0
  692. package/dist/src/observability/rift-context.d.ts.map +1 -0
  693. package/dist/src/observability/rift-context.js +141 -0
  694. package/dist/src/observability/rift-context.js.map +1 -0
  695. package/dist/src/observability/staleness.d.ts +43 -0
  696. package/dist/src/observability/staleness.d.ts.map +1 -0
  697. package/dist/src/observability/staleness.js +74 -0
  698. package/dist/src/observability/staleness.js.map +1 -0
  699. package/dist/src/observability/tool-usage-stats.d.ts +139 -0
  700. package/dist/src/observability/tool-usage-stats.d.ts.map +1 -0
  701. package/dist/src/observability/tool-usage-stats.js +245 -0
  702. package/dist/src/observability/tool-usage-stats.js.map +1 -0
  703. package/dist/src/observability/tool-usage.d.ts +231 -0
  704. package/dist/src/observability/tool-usage.d.ts.map +1 -0
  705. package/dist/src/observability/tool-usage.js +489 -0
  706. package/dist/src/observability/tool-usage.js.map +1 -0
  707. package/dist/src/observability/version-check.d.ts +75 -0
  708. package/dist/src/observability/version-check.d.ts.map +1 -0
  709. package/dist/src/observability/version-check.js +198 -0
  710. package/dist/src/observability/version-check.js.map +1 -0
  711. package/dist/src/onboarding/capture-switch.d.ts +20 -0
  712. package/dist/src/onboarding/capture-switch.d.ts.map +1 -0
  713. package/dist/src/onboarding/capture-switch.js +52 -0
  714. package/dist/src/onboarding/capture-switch.js.map +1 -0
  715. package/dist/src/onboarding/daemon-control.d.ts +33 -0
  716. package/dist/src/onboarding/daemon-control.d.ts.map +1 -0
  717. package/dist/src/onboarding/daemon-control.js +92 -0
  718. package/dist/src/onboarding/daemon-control.js.map +1 -0
  719. package/dist/src/onboarding/env-file.d.ts +18 -0
  720. package/dist/src/onboarding/env-file.d.ts.map +1 -0
  721. package/dist/src/onboarding/env-file.js +89 -0
  722. package/dist/src/onboarding/env-file.js.map +1 -0
  723. package/dist/src/onboarding/search-by-meaning.d.ts +35 -0
  724. package/dist/src/onboarding/search-by-meaning.d.ts.map +1 -0
  725. package/dist/src/onboarding/search-by-meaning.js +163 -0
  726. package/dist/src/onboarding/search-by-meaning.js.map +1 -0
  727. package/dist/src/onboarding/setup-page.d.ts +7 -0
  728. package/dist/src/onboarding/setup-page.d.ts.map +1 -0
  729. package/dist/src/onboarding/setup-page.js +823 -0
  730. package/dist/src/onboarding/setup-page.js.map +1 -0
  731. package/dist/src/onboarding/setup-session.d.ts +22 -0
  732. package/dist/src/onboarding/setup-session.d.ts.map +1 -0
  733. package/dist/src/onboarding/setup-session.js +80 -0
  734. package/dist/src/onboarding/setup-session.js.map +1 -0
  735. package/dist/src/onboarding/setup-state.d.ts +117 -0
  736. package/dist/src/onboarding/setup-state.d.ts.map +1 -0
  737. package/dist/src/onboarding/setup-state.js +267 -0
  738. package/dist/src/onboarding/setup-state.js.map +1 -0
  739. package/dist/src/onboarding/voyage-validate.d.ts +22 -0
  740. package/dist/src/onboarding/voyage-validate.d.ts.map +1 -0
  741. package/dist/src/onboarding/voyage-validate.js +96 -0
  742. package/dist/src/onboarding/voyage-validate.js.map +1 -0
  743. package/dist/src/providers/anthropic-digest.d.ts +23 -0
  744. package/dist/src/providers/anthropic-digest.d.ts.map +1 -0
  745. package/dist/src/providers/anthropic-digest.js +91 -0
  746. package/dist/src/providers/anthropic-digest.js.map +1 -0
  747. package/dist/src/providers/basic-metadata-extraction.d.ts +60 -0
  748. package/dist/src/providers/basic-metadata-extraction.d.ts.map +1 -0
  749. package/dist/src/providers/basic-metadata-extraction.js +114 -0
  750. package/dist/src/providers/basic-metadata-extraction.js.map +1 -0
  751. package/dist/src/providers/claude-cli-metadata-extraction.d.ts +47 -0
  752. package/dist/src/providers/claude-cli-metadata-extraction.d.ts.map +1 -0
  753. package/dist/src/providers/claude-cli-metadata-extraction.js +130 -0
  754. package/dist/src/providers/claude-cli-metadata-extraction.js.map +1 -0
  755. package/dist/src/providers/claude-cli-runner.d.ts +92 -0
  756. package/dist/src/providers/claude-cli-runner.d.ts.map +1 -0
  757. package/dist/src/providers/claude-cli-runner.js +598 -0
  758. package/dist/src/providers/claude-cli-runner.js.map +1 -0
  759. package/dist/src/providers/claude-input-limit.d.ts +32 -0
  760. package/dist/src/providers/claude-input-limit.d.ts.map +1 -0
  761. package/dist/src/providers/claude-input-limit.js +32 -0
  762. package/dist/src/providers/claude-input-limit.js.map +1 -0
  763. package/dist/src/providers/codex-cli-digest.d.ts +12 -0
  764. package/dist/src/providers/codex-cli-digest.d.ts.map +1 -0
  765. package/dist/src/providers/codex-cli-digest.js +70 -0
  766. package/dist/src/providers/codex-cli-digest.js.map +1 -0
  767. package/dist/src/providers/codex-cli-metadata-extraction.d.ts +15 -0
  768. package/dist/src/providers/codex-cli-metadata-extraction.d.ts.map +1 -0
  769. package/dist/src/providers/codex-cli-metadata-extraction.js +78 -0
  770. package/dist/src/providers/codex-cli-metadata-extraction.js.map +1 -0
  771. package/dist/src/providers/codex-cli-model.d.ts +110 -0
  772. package/dist/src/providers/codex-cli-model.d.ts.map +1 -0
  773. package/dist/src/providers/codex-cli-model.js +338 -0
  774. package/dist/src/providers/codex-cli-model.js.map +1 -0
  775. package/dist/src/providers/codex-cli-runner.d.ts +70 -0
  776. package/dist/src/providers/codex-cli-runner.d.ts.map +1 -0
  777. package/dist/src/providers/codex-cli-runner.js +745 -0
  778. package/dist/src/providers/codex-cli-runner.js.map +1 -0
  779. package/dist/src/providers/codex-input-limit.d.ts +43 -0
  780. package/dist/src/providers/codex-input-limit.d.ts.map +1 -0
  781. package/dist/src/providers/codex-input-limit.js +70 -0
  782. package/dist/src/providers/codex-input-limit.js.map +1 -0
  783. package/dist/src/providers/conversation-generation.d.ts +21 -0
  784. package/dist/src/providers/conversation-generation.d.ts.map +1 -0
  785. package/dist/src/providers/conversation-generation.js +132 -0
  786. package/dist/src/providers/conversation-generation.js.map +1 -0
  787. package/dist/src/providers/ollama-embed.d.ts +23 -0
  788. package/dist/src/providers/ollama-embed.d.ts.map +1 -0
  789. package/dist/src/providers/ollama-embed.js +137 -0
  790. package/dist/src/providers/ollama-embed.js.map +1 -0
  791. package/dist/src/providers/ollama.d.ts +42 -0
  792. package/dist/src/providers/ollama.d.ts.map +1 -0
  793. package/dist/src/providers/ollama.js +169 -0
  794. package/dist/src/providers/ollama.js.map +1 -0
  795. package/dist/src/providers/openai-metadata-extraction.d.ts +120 -0
  796. package/dist/src/providers/openai-metadata-extraction.d.ts.map +1 -0
  797. package/dist/src/providers/openai-metadata-extraction.js +225 -0
  798. package/dist/src/providers/openai-metadata-extraction.js.map +1 -0
  799. package/dist/src/providers/operator-overrides.d.ts +24 -0
  800. package/dist/src/providers/operator-overrides.d.ts.map +1 -0
  801. package/dist/src/providers/operator-overrides.js +84 -0
  802. package/dist/src/providers/operator-overrides.js.map +1 -0
  803. package/dist/src/providers/placeholder-embed.d.ts +56 -0
  804. package/dist/src/providers/placeholder-embed.d.ts.map +1 -0
  805. package/dist/src/providers/placeholder-embed.js +64 -0
  806. package/dist/src/providers/placeholder-embed.js.map +1 -0
  807. package/dist/src/providers/shared-request.d.ts +22 -0
  808. package/dist/src/providers/shared-request.d.ts.map +1 -0
  809. package/dist/src/providers/shared-request.js +63 -0
  810. package/dist/src/providers/shared-request.js.map +1 -0
  811. package/dist/src/providers/stub.d.ts +19 -0
  812. package/dist/src/providers/stub.d.ts.map +1 -0
  813. package/dist/src/providers/stub.js +74 -0
  814. package/dist/src/providers/stub.js.map +1 -0
  815. package/dist/src/providers/types.d.ts +100 -0
  816. package/dist/src/providers/types.d.ts.map +1 -0
  817. package/dist/src/providers/types.js +63 -0
  818. package/dist/src/providers/types.js.map +1 -0
  819. package/dist/src/providers/voyage.d.ts +55 -0
  820. package/dist/src/providers/voyage.d.ts.map +1 -0
  821. package/dist/src/providers/voyage.js +179 -0
  822. package/dist/src/providers/voyage.js.map +1 -0
  823. package/dist/src/retrieval/brief.d.ts +26 -0
  824. package/dist/src/retrieval/brief.d.ts.map +1 -0
  825. package/dist/src/retrieval/brief.js +268 -0
  826. package/dist/src/retrieval/brief.js.map +1 -0
  827. package/dist/src/retrieval/canonical-files.d.ts +79 -0
  828. package/dist/src/retrieval/canonical-files.d.ts.map +1 -0
  829. package/dist/src/retrieval/canonical-files.js +432 -0
  830. package/dist/src/retrieval/canonical-files.js.map +1 -0
  831. package/dist/src/retrieval/compact.d.ts +306 -0
  832. package/dist/src/retrieval/compact.d.ts.map +1 -0
  833. package/dist/src/retrieval/compact.js +810 -0
  834. package/dist/src/retrieval/compact.js.map +1 -0
  835. package/dist/src/retrieval/context-pack.d.ts +344 -0
  836. package/dist/src/retrieval/context-pack.d.ts.map +1 -0
  837. package/dist/src/retrieval/context-pack.js +1483 -0
  838. package/dist/src/retrieval/context-pack.js.map +1 -0
  839. package/dist/src/retrieval/conversation-dedup.d.ts +54 -0
  840. package/dist/src/retrieval/conversation-dedup.d.ts.map +1 -0
  841. package/dist/src/retrieval/conversation-dedup.js +162 -0
  842. package/dist/src/retrieval/conversation-dedup.js.map +1 -0
  843. package/dist/src/retrieval/current-truth.d.ts +360 -0
  844. package/dist/src/retrieval/current-truth.d.ts.map +1 -0
  845. package/dist/src/retrieval/current-truth.js +766 -0
  846. package/dist/src/retrieval/current-truth.js.map +1 -0
  847. package/dist/src/retrieval/cwd.d.ts +25 -0
  848. package/dist/src/retrieval/cwd.d.ts.map +1 -0
  849. package/dist/src/retrieval/cwd.js +48 -0
  850. package/dist/src/retrieval/cwd.js.map +1 -0
  851. package/dist/src/retrieval/degraded.d.ts +20 -0
  852. package/dist/src/retrieval/degraded.d.ts.map +1 -0
  853. package/dist/src/retrieval/degraded.js +43 -0
  854. package/dist/src/retrieval/degraded.js.map +1 -0
  855. package/dist/src/retrieval/evidence-key.d.ts +48 -0
  856. package/dist/src/retrieval/evidence-key.d.ts.map +1 -0
  857. package/dist/src/retrieval/evidence-key.js +131 -0
  858. package/dist/src/retrieval/evidence-key.js.map +1 -0
  859. package/dist/src/retrieval/feedback-ranking.d.ts +49 -0
  860. package/dist/src/retrieval/feedback-ranking.d.ts.map +1 -0
  861. package/dist/src/retrieval/feedback-ranking.js +138 -0
  862. package/dist/src/retrieval/feedback-ranking.js.map +1 -0
  863. package/dist/src/retrieval/git-state.d.ts +62 -0
  864. package/dist/src/retrieval/git-state.d.ts.map +1 -0
  865. package/dist/src/retrieval/git-state.js +192 -0
  866. package/dist/src/retrieval/git-state.js.map +1 -0
  867. package/dist/src/retrieval/group-by-parent.d.ts +38 -0
  868. package/dist/src/retrieval/group-by-parent.d.ts.map +1 -0
  869. package/dist/src/retrieval/group-by-parent.js +40 -0
  870. package/dist/src/retrieval/group-by-parent.js.map +1 -0
  871. package/dist/src/retrieval/hybrid.d.ts +75 -0
  872. package/dist/src/retrieval/hybrid.d.ts.map +1 -0
  873. package/dist/src/retrieval/hybrid.js +151 -0
  874. package/dist/src/retrieval/hybrid.js.map +1 -0
  875. package/dist/src/retrieval/lexical.d.ts +33 -0
  876. package/dist/src/retrieval/lexical.d.ts.map +1 -0
  877. package/dist/src/retrieval/lexical.js +379 -0
  878. package/dist/src/retrieval/lexical.js.map +1 -0
  879. package/dist/src/retrieval/locator-boost.d.ts +37 -0
  880. package/dist/src/retrieval/locator-boost.d.ts.map +1 -0
  881. package/dist/src/retrieval/locator-boost.js +129 -0
  882. package/dist/src/retrieval/locator-boost.js.map +1 -0
  883. package/dist/src/retrieval/passages.d.ts +24 -0
  884. package/dist/src/retrieval/passages.d.ts.map +1 -0
  885. package/dist/src/retrieval/passages.js +160 -0
  886. package/dist/src/retrieval/passages.js.map +1 -0
  887. package/dist/src/retrieval/post-filter.d.ts +32 -0
  888. package/dist/src/retrieval/post-filter.d.ts.map +1 -0
  889. package/dist/src/retrieval/post-filter.js +57 -0
  890. package/dist/src/retrieval/post-filter.js.map +1 -0
  891. package/dist/src/retrieval/project-index.d.ts +71 -0
  892. package/dist/src/retrieval/project-index.d.ts.map +1 -0
  893. package/dist/src/retrieval/project-index.js +348 -0
  894. package/dist/src/retrieval/project-index.js.map +1 -0
  895. package/dist/src/retrieval/recall-hint.d.ts +22 -0
  896. package/dist/src/retrieval/recall-hint.d.ts.map +1 -0
  897. package/dist/src/retrieval/recall-hint.js +33 -0
  898. package/dist/src/retrieval/recall-hint.js.map +1 -0
  899. package/dist/src/retrieval/receipt.d.ts +57 -0
  900. package/dist/src/retrieval/receipt.d.ts.map +1 -0
  901. package/dist/src/retrieval/receipt.js +122 -0
  902. package/dist/src/retrieval/receipt.js.map +1 -0
  903. package/dist/src/retrieval/report-demotion.d.ts +46 -0
  904. package/dist/src/retrieval/report-demotion.d.ts.map +1 -0
  905. package/dist/src/retrieval/report-demotion.js +169 -0
  906. package/dist/src/retrieval/report-demotion.js.map +1 -0
  907. package/dist/src/retrieval/reranker.d.ts +119 -0
  908. package/dist/src/retrieval/reranker.d.ts.map +1 -0
  909. package/dist/src/retrieval/reranker.js +220 -0
  910. package/dist/src/retrieval/reranker.js.map +1 -0
  911. package/dist/src/retrieval/stitch-chunks.d.ts +76 -0
  912. package/dist/src/retrieval/stitch-chunks.d.ts.map +1 -0
  913. package/dist/src/retrieval/stitch-chunks.js +113 -0
  914. package/dist/src/retrieval/stitch-chunks.js.map +1 -0
  915. package/dist/src/retrieval/vector.d.ts +71 -0
  916. package/dist/src/retrieval/vector.d.ts.map +1 -0
  917. package/dist/src/retrieval/vector.js +147 -0
  918. package/dist/src/retrieval/vector.js.map +1 -0
  919. package/dist/src/runtime/legacy-migration.d.ts +27 -0
  920. package/dist/src/runtime/legacy-migration.d.ts.map +1 -0
  921. package/dist/src/runtime/legacy-migration.js +140 -0
  922. package/dist/src/runtime/legacy-migration.js.map +1 -0
  923. package/dist/src/runtime/legacy-name-guard.d.ts +35 -0
  924. package/dist/src/runtime/legacy-name-guard.d.ts.map +1 -0
  925. package/dist/src/runtime/legacy-name-guard.js +58 -0
  926. package/dist/src/runtime/legacy-name-guard.js.map +1 -0
  927. package/dist/src/runtime/rift-env.d.ts +14 -0
  928. package/dist/src/runtime/rift-env.d.ts.map +1 -0
  929. package/dist/src/runtime/rift-env.js +79 -0
  930. package/dist/src/runtime/rift-env.js.map +1 -0
  931. package/dist/src/runtime/voyage-key-source.d.ts +46 -0
  932. package/dist/src/runtime/voyage-key-source.d.ts.map +1 -0
  933. package/dist/src/runtime/voyage-key-source.js +97 -0
  934. package/dist/src/runtime/voyage-key-source.js.map +1 -0
  935. package/dist/src/runtime/watcher-startup.d.ts +2 -0
  936. package/dist/src/runtime/watcher-startup.d.ts.map +1 -0
  937. package/dist/src/runtime/watcher-startup.js +4 -0
  938. package/dist/src/runtime/watcher-startup.js.map +1 -0
  939. package/dist/src/security/archive.d.ts +23 -0
  940. package/dist/src/security/archive.d.ts.map +1 -0
  941. package/dist/src/security/archive.js +163 -0
  942. package/dist/src/security/archive.js.map +1 -0
  943. package/dist/src/security/paths.d.ts +21 -0
  944. package/dist/src/security/paths.d.ts.map +1 -0
  945. package/dist/src/security/paths.js +67 -0
  946. package/dist/src/security/paths.js.map +1 -0
  947. package/dist/src/server/app.d.ts +29 -0
  948. package/dist/src/server/app.d.ts.map +1 -0
  949. package/dist/src/server/app.js +356 -0
  950. package/dist/src/server/app.js.map +1 -0
  951. package/dist/src/server/build-info.d.ts +8 -0
  952. package/dist/src/server/build-info.d.ts.map +1 -0
  953. package/dist/src/server/build-info.js +61 -0
  954. package/dist/src/server/build-info.js.map +1 -0
  955. package/dist/src/server/lifecycle.d.ts +30 -0
  956. package/dist/src/server/lifecycle.d.ts.map +1 -0
  957. package/dist/src/server/lifecycle.js +59 -0
  958. package/dist/src/server/lifecycle.js.map +1 -0
  959. package/dist/src/server/middleware/multipart.d.ts +51 -0
  960. package/dist/src/server/middleware/multipart.d.ts.map +1 -0
  961. package/dist/src/server/middleware/multipart.js +86 -0
  962. package/dist/src/server/middleware/multipart.js.map +1 -0
  963. package/dist/src/server/routes/compact.d.ts +37 -0
  964. package/dist/src/server/routes/compact.d.ts.map +1 -0
  965. package/dist/src/server/routes/compact.js +80 -0
  966. package/dist/src/server/routes/compact.js.map +1 -0
  967. package/dist/src/server/routes/context.d.ts +12 -0
  968. package/dist/src/server/routes/context.d.ts.map +1 -0
  969. package/dist/src/server/routes/context.js +73 -0
  970. package/dist/src/server/routes/context.js.map +1 -0
  971. package/dist/src/server/routes/conversations-search.d.ts +4 -0
  972. package/dist/src/server/routes/conversations-search.d.ts.map +1 -0
  973. package/dist/src/server/routes/conversations-search.js +287 -0
  974. package/dist/src/server/routes/conversations-search.js.map +1 -0
  975. package/dist/src/server/routes/enqueue.d.ts +11 -0
  976. package/dist/src/server/routes/enqueue.d.ts.map +1 -0
  977. package/dist/src/server/routes/enqueue.js +17 -0
  978. package/dist/src/server/routes/enqueue.js.map +1 -0
  979. package/dist/src/server/routes/friend-status.d.ts +481 -0
  980. package/dist/src/server/routes/friend-status.d.ts.map +1 -0
  981. package/dist/src/server/routes/friend-status.js +675 -0
  982. package/dist/src/server/routes/friend-status.js.map +1 -0
  983. package/dist/src/server/routes/ingest.d.ts +15 -0
  984. package/dist/src/server/routes/ingest.d.ts.map +1 -0
  985. package/dist/src/server/routes/ingest.js +142 -0
  986. package/dist/src/server/routes/ingest.js.map +1 -0
  987. package/dist/src/server/routes/jobs.d.ts +10 -0
  988. package/dist/src/server/routes/jobs.d.ts.map +1 -0
  989. package/dist/src/server/routes/jobs.js +29 -0
  990. package/dist/src/server/routes/jobs.js.map +1 -0
  991. package/dist/src/server/routes/mcp-usage.d.ts +17 -0
  992. package/dist/src/server/routes/mcp-usage.d.ts.map +1 -0
  993. package/dist/src/server/routes/mcp-usage.js +17 -0
  994. package/dist/src/server/routes/mcp-usage.js.map +1 -0
  995. package/dist/src/server/routes/reconcile.d.ts +4 -0
  996. package/dist/src/server/routes/reconcile.d.ts.map +1 -0
  997. package/dist/src/server/routes/reconcile.js +62 -0
  998. package/dist/src/server/routes/reconcile.js.map +1 -0
  999. package/dist/src/server/routes/reindex.d.ts +4 -0
  1000. package/dist/src/server/routes/reindex.d.ts.map +1 -0
  1001. package/dist/src/server/routes/reindex.js +77 -0
  1002. package/dist/src/server/routes/reindex.js.map +1 -0
  1003. package/dist/src/server/routes/retrieval-feedback.d.ts +3 -0
  1004. package/dist/src/server/routes/retrieval-feedback.d.ts.map +1 -0
  1005. package/dist/src/server/routes/retrieval-feedback.js +290 -0
  1006. package/dist/src/server/routes/retrieval-feedback.js.map +1 -0
  1007. package/dist/src/server/routes/save.d.ts +52 -0
  1008. package/dist/src/server/routes/save.d.ts.map +1 -0
  1009. package/dist/src/server/routes/save.js +127 -0
  1010. package/dist/src/server/routes/save.js.map +1 -0
  1011. package/dist/src/server/routes/search.d.ts +5 -0
  1012. package/dist/src/server/routes/search.d.ts.map +1 -0
  1013. package/dist/src/server/routes/search.js +689 -0
  1014. package/dist/src/server/routes/search.js.map +1 -0
  1015. package/dist/src/server/routes/setup.d.ts +46 -0
  1016. package/dist/src/server/routes/setup.d.ts.map +1 -0
  1017. package/dist/src/server/routes/setup.js +322 -0
  1018. package/dist/src/server/routes/setup.js.map +1 -0
  1019. package/dist/src/server/routes/stats.d.ts +10 -0
  1020. package/dist/src/server/routes/stats.d.ts.map +1 -0
  1021. package/dist/src/server/routes/stats.js +15 -0
  1022. package/dist/src/server/routes/stats.js.map +1 -0
  1023. package/dist/src/server/routes/status.d.ts +20 -0
  1024. package/dist/src/server/routes/status.d.ts.map +1 -0
  1025. package/dist/src/server/routes/status.js +31 -0
  1026. package/dist/src/server/routes/status.js.map +1 -0
  1027. package/dist/src/server/routes/triage.d.ts +4 -0
  1028. package/dist/src/server/routes/triage.d.ts.map +1 -0
  1029. package/dist/src/server/routes/triage.js +97 -0
  1030. package/dist/src/server/routes/triage.js.map +1 -0
  1031. package/dist/src/server/save-quality.d.ts +21 -0
  1032. package/dist/src/server/save-quality.d.ts.map +1 -0
  1033. package/dist/src/server/save-quality.js +51 -0
  1034. package/dist/src/server/save-quality.js.map +1 -0
  1035. package/dist/src/server/serving-marker.d.ts +85 -0
  1036. package/dist/src/server/serving-marker.d.ts.map +1 -0
  1037. package/dist/src/server/serving-marker.js +226 -0
  1038. package/dist/src/server/serving-marker.js.map +1 -0
  1039. package/dist/src/storage/atomic.d.ts +8 -0
  1040. package/dist/src/storage/atomic.d.ts.map +1 -0
  1041. package/dist/src/storage/atomic.js +22 -0
  1042. package/dist/src/storage/atomic.js.map +1 -0
  1043. package/dist/src/storage/chunk-backfill.d.ts +39 -0
  1044. package/dist/src/storage/chunk-backfill.d.ts.map +1 -0
  1045. package/dist/src/storage/chunk-backfill.js +295 -0
  1046. package/dist/src/storage/chunk-backfill.js.map +1 -0
  1047. package/dist/src/storage/db.d.ts +15 -0
  1048. package/dist/src/storage/db.d.ts.map +1 -0
  1049. package/dist/src/storage/db.js +47 -0
  1050. package/dist/src/storage/db.js.map +1 -0
  1051. package/dist/src/storage/filter.d.ts +42 -0
  1052. package/dist/src/storage/filter.d.ts.map +1 -0
  1053. package/dist/src/storage/filter.js +70 -0
  1054. package/dist/src/storage/filter.js.map +1 -0
  1055. package/dist/src/storage/fts.d.ts +47 -0
  1056. package/dist/src/storage/fts.d.ts.map +1 -0
  1057. package/dist/src/storage/fts.js +86 -0
  1058. package/dist/src/storage/fts.js.map +1 -0
  1059. package/dist/src/storage/integrity.d.ts +11 -0
  1060. package/dist/src/storage/integrity.d.ts.map +1 -0
  1061. package/dist/src/storage/integrity.js +66 -0
  1062. package/dist/src/storage/integrity.js.map +1 -0
  1063. package/dist/src/storage/maintenance.d.ts +27 -0
  1064. package/dist/src/storage/maintenance.d.ts.map +1 -0
  1065. package/dist/src/storage/maintenance.js +66 -0
  1066. package/dist/src/storage/maintenance.js.map +1 -0
  1067. package/dist/src/storage/rebuild.d.ts +71 -0
  1068. package/dist/src/storage/rebuild.d.ts.map +1 -0
  1069. package/dist/src/storage/rebuild.js +605 -0
  1070. package/dist/src/storage/rebuild.js.map +1 -0
  1071. package/dist/src/storage/report-card-backfill.d.ts +20 -0
  1072. package/dist/src/storage/report-card-backfill.d.ts.map +1 -0
  1073. package/dist/src/storage/report-card-backfill.js +114 -0
  1074. package/dist/src/storage/report-card-backfill.js.map +1 -0
  1075. package/dist/src/storage/shadow-swap.d.ts +20 -0
  1076. package/dist/src/storage/shadow-swap.d.ts.map +1 -0
  1077. package/dist/src/storage/shadow-swap.js +163 -0
  1078. package/dist/src/storage/shadow-swap.js.map +1 -0
  1079. package/dist/src/storage/tables.d.ts +147 -0
  1080. package/dist/src/storage/tables.d.ts.map +1 -0
  1081. package/dist/src/storage/tables.js +290 -0
  1082. package/dist/src/storage/tables.js.map +1 -0
  1083. package/operator/swiftbar/render-menu.py +475 -0
  1084. package/operator/swiftbar/rift.10s.sh +201 -0
  1085. package/package.json +57 -3
@@ -0,0 +1,1483 @@
1
+ /**
2
+ * Slice 3: ContextPack retrieval primitive.
3
+ *
4
+ * Builds a compact, bucketed view of prior context for an active task.
5
+ * Reuses hybrid search; never returns raw transcripts.
6
+ *
7
+ * Buckets:
8
+ * - decisions: strings pulled from matching conversations' `decisions` JSON
9
+ * - constraints: MUST/NEVER/DO-NOT style lines pulled from matching docs
10
+ * - examples: compact pointers to prior conversations (title+summary+expand)
11
+ * - rules: compact pointers to project docs (title+snippet+expand)
12
+ *
13
+ * Hard caps (locked contract):
14
+ * - each text item <= 200 chars
15
+ * - each snippet <= 200 chars
16
+ * - max_per_bucket default 3, ceiling 10
17
+ * - max_bytes default 6144, ceiling 16384
18
+ *
19
+ * Nothing here embeds or writes — pure assembly on top of hybridSearch
20
+ * plus direct row lookups for the decisions/constraints extraction.
21
+ */
22
+ import fs from "node:fs";
23
+ import path from "node:path";
24
+ import { EMBED_WAIT_MS, hybridSearch, sharedEmbedding } from "./hybrid.js";
25
+ import { rerank } from "./reranker.js";
26
+ import { getTable } from "../storage/tables.js";
27
+ import { resolveCwdRoot } from "./cwd.js";
28
+ import { getProjectIndex, resolveProjectRoot } from "./project-index.js";
29
+ import { computeContentSize } from "./compact.js";
30
+ import { extractPassages } from "./passages.js";
31
+ import { decodeUserStatement, MAX_QUOTE_CHARS, } from "../capture/user-statements.js";
32
+ import { groupByParent, rankedKey } from "./group-by-parent.js";
33
+ import { collapseConversationDuplicates, convDedupEnabled, poolHasChunkMarkers, } from "./conversation-dedup.js";
34
+ import { parentKeyForRow } from "../ingestion/chunk-meta.js";
35
+ import { inFilter } from "../storage/filter.js";
36
+ import { classifyClaimType, classifyEvidenceIntent, partitionEvidence, } from "./current-truth.js";
37
+ import { probeGitStates, resolveRepoRoot, } from "./git-state.js";
38
+ import { canonicalEvidenceInputs, canonicalFilesEnabled, cleanItemText, holdsQuestionSubject, selectCanonicalSections, } from "./canonical-files.js";
39
+ // --- Locked caps ---
40
+ export const ITEM_TEXT_MAX = 200;
41
+ export const SNIPPET_MAX = 200;
42
+ /** Task-matching passage per example card. */
43
+ export const PASSAGE_MAX = 360;
44
+ export const DEFAULT_MAX_PER_BUCKET = 3;
45
+ export const MAX_PER_BUCKET_CEILING = 10;
46
+ /**
47
+ * Default envelope. 6 KB since passages were added (2026-09-24): at 4 KB the
48
+ * passages pushed the third example card out of every frozen-task pack; at
49
+ * 6 KB none were trimmed (packs measured 4.0–5.3 KB).
50
+ */
51
+ export const DEFAULT_MAX_BYTES = 6144;
52
+ export const MAX_BYTES_CEILING = 16384;
53
+ /** Request `task` is echoed in the response, so it counts against `max_bytes`. Capped to keep the envelope small. */
54
+ export const TASK_MAX = 1024;
55
+ /**
56
+ * Minimum `S_sim` for a ranked candidate to feed the `decisions` /
57
+ * `examples` buckets. Below this floor we prefer an empty bucket over
58
+ * confidently-worded unrelated content — Slice 5 validation showed
59
+ * that when the task has no real match in the corpus, decisions from
60
+ * the top-ranked-but-unrelated row still come back, and an agent has
61
+ * no way to tell they're noise.
62
+ *
63
+ * `S_sim` is cosine similarity in [0,1] for vector / hybrid results
64
+ * and max-normalized BM25 for lexical-only. The floor is deliberately
65
+ * low (0.3): genuine weak matches still pass, but rows that are
66
+ * essentially keyword-free or cosine-orthogonal drop out. Constraints
67
+ * and rules are already heavily filtered (marker matching + engine-
68
+ * owned-path exclusion), so we only apply the floor to the two
69
+ * "free-text content" buckets where noise is most costly.
70
+ */
71
+ export const DECISIONS_RELEVANCE_FLOOR = 0.3;
72
+ export const EXAMPLES_RELEVANCE_FLOOR = 0.3;
73
+ /**
74
+ * Equal-relevance band for {@link sortByRelevanceFirst}. Two candidates
75
+ * whose relevance signals (`max(S_sim, bm25_normalized)`) sit within
76
+ * this absolute delta are treated as effectively tied and fall through
77
+ * to the composite-score tie-breaker. Small enough to keep genuinely
78
+ * better relevance on top, wide enough that floating-point noise and
79
+ * trivial ranking jitter don't cause ping-pong between near-equal rows.
80
+ */
81
+ export const RELEVANCE_TIE_EPSILON = 0.02;
82
+ /**
83
+ * A sentence the user said is on the task's subject when it shares two of its
84
+ * subject words, or when it is this close to the task in meaning. Short rules
85
+ * rarely repeat two words of a task ("Inter, or any good looking sans font."
86
+ * for a task about the website's font), so the word test alone drops them.
87
+ *
88
+ * The bar is cosine similarity, and each model has its own scale, so each
89
+ * measured model has its own bar. Both were set against the owner's stored
90
+ * statements and past task strings (4,615 pairs) to let through the same
91
+ * small share of pairs, about 0.6%: on voyage-3-lite the 99th percentile is
92
+ * 0.44 and on voyage-4-lite at 512 dimensions 0.48. At these bars both font
93
+ * rules pass on a short question and on a long task description, the lowest
94
+ * at 0.497 on voyage-3-lite. A model that was not measured keeps the word
95
+ * test alone.
96
+ */
97
+ export const STATEMENT_CLOSENESS_MIN = {
98
+ "voyage-3-lite": 0.47,
99
+ "voyage-4-lite": 0.5,
100
+ };
101
+ const STATEMENT_CLOSENESS_PROVIDER = "voyage";
102
+ /**
103
+ * The most sentences one pack sends to be compared. A session keeps every
104
+ * statement the user made, so a long one can hold hundreds; the rest are
105
+ * compared by the next packs, and the pack says it is partial until then.
106
+ */
107
+ export const STATEMENT_COMPARE_MAX = 200;
108
+ /** Statement vectors kept for the life of the process: a stored sentence never changes. */
109
+ const STATEMENT_VECTOR_CACHE_MAX = 5_000;
110
+ const statementVectors = new Map();
111
+ /** Test hook: forget the kept statement vectors. */
112
+ export function resetStatementVectorCache() {
113
+ statementVectors.clear();
114
+ }
115
+ // Fetch more candidates than we keep so we have headroom to extract
116
+ // decisions/constraints from multiple sources and dedupe downstream.
117
+ const CANDIDATE_FETCH_MULTIPLIER = 4;
118
+ /** Tables that feed the rules / constraints buckets. */
119
+ const DOC_TABLES = ["structured_docs", "structured_docs_local"];
120
+ /** Tracker sections read per pack; each bucket then takes its own cap from them. */
121
+ const TRACKER_SECTION_POOL = 24;
122
+ /** Same floor as examples: below it an other-project document is noise. */
123
+ export const OTHER_PROJECTS_RELEVANCE_FLOOR = 0.3;
124
+ /**
125
+ * The task names work outside this project ("from another project", "pour un
126
+ * autre client"). Other-project documents then get their budget first;
127
+ * otherwise they only use what the project's own evidence leaves free.
128
+ */
129
+ const ASKS_OTHER_PROJECTS = /\b(?:an)?other\s+(?:projects?|clients?|repos?|repositor(?:y|ies))\b|\bcross[- ]project\b|\belsewhere\b|\bautres?\s+(?:projets?|clients?)\b|\bailleurs\b/i;
130
+ // --- Project-first retrieval ---
131
+ /**
132
+ * Project rows lead only when they are nearly as relevant as the best
133
+ * candidate overall; otherwise a question about another project asked from
134
+ * this repo would surface weak local matches first.
135
+ */
136
+ export const PROJECT_FIRST_RELEVANCE_RATIO = 0.8;
137
+ async function resolvePackProjects(cwd) {
138
+ const index = getProjectIndex();
139
+ const root = cwd ? resolveProjectRoot(cwd) : null;
140
+ if (!index || !root)
141
+ return { current: null, otherProjectOf: () => undefined };
142
+ const { byRoot, projectById } = await index.rowsByProject();
143
+ const rowIds = byRoot.get(root) ?? [];
144
+ return {
145
+ current: rowIds.length ? { root, rowIds, idSet: new Set(rowIds) } : null,
146
+ otherProjectOf: (rowId) => {
147
+ const home = projectById.get(rowId);
148
+ return home && home !== root ? path.basename(home) : undefined;
149
+ },
150
+ };
151
+ }
152
+ function mergeCandidates(a, b) {
153
+ const byId = new Map();
154
+ for (const c of [...a, ...b]) {
155
+ const prev = byId.get(c.id);
156
+ if (!prev)
157
+ byId.set(c.id, c);
158
+ else
159
+ byId.set(c.id, { ...prev, raw_sim: Math.max(prev.raw_sim, c.raw_sim), raw_bm25: Math.max(prev.raw_bm25, c.raw_bm25) });
160
+ }
161
+ return [...byId.values()];
162
+ }
163
+ /**
164
+ * For a task that asks for work from other projects: sessions that ran in
165
+ * another project lead, when close to the best of them. The reverse of
166
+ * {@link projectFirst}, which would bury exactly what was asked for.
167
+ */
168
+ export function otherProjectsFirst(ranked, isOtherProject) {
169
+ const rel = (r) => Math.max(r.factors.S_sim, r.bm25_normalized);
170
+ const others = ranked.filter((r) => isOtherProject(r.id));
171
+ const best = others.reduce((m, r) => Math.max(m, rel(r)), 0);
172
+ const leadSet = new Set(others.filter((r) => rel(r) >= best * PROJECT_FIRST_RELEVANCE_RATIO));
173
+ return [...leadSet, ...ranked.filter((r) => !leadSet.has(r))];
174
+ }
175
+ /** Stable-partition: close-to-best project rows first, everything else after. */
176
+ export function projectFirst(ranked, idSet) {
177
+ const rel = (r) => Math.max(r.factors.S_sim, r.bm25_normalized);
178
+ const best = ranked.reduce((m, r) => Math.max(m, rel(r)), 0);
179
+ const lead = ranked.filter((r) => idSet.has(r.id) && rel(r) >= best * PROJECT_FIRST_RELEVANCE_RATIO);
180
+ const leadSet = new Set(lead);
181
+ return [...lead, ...ranked.filter((r) => !leadSet.has(r))];
182
+ }
183
+ // --- Public entry ---
184
+ export async function buildContextPack(opts) {
185
+ const maxPerBucket = clamp(opts.maxPerBucket ?? DEFAULT_MAX_PER_BUCKET, 1, MAX_PER_BUCKET_CEILING);
186
+ const maxBytes = clamp(opts.maxBytes ?? DEFAULT_MAX_BYTES, 512, MAX_BYTES_CEILING);
187
+ const cwdMatch = opts.cwd && opts.sources ? resolveCwdRoot(opts.cwd, opts.sources) : null;
188
+ const sourcePathPrefix = cwdMatch?.rootPath;
189
+ // Fetch candidates in two lanes in parallel: conversations and documents.
190
+ // These feed different buckets, so running them separately lets each bucket
191
+ // draw on its own candidate pool without one starving the other.
192
+ //
193
+ // The docs lane uses scope="all" restricted to the structured_docs table,
194
+ // because scope="documents" would also require `source_scope='document'`
195
+ // — excluding project-scoped files like CLAUDE.md / AGENTS.md / PRD.md
196
+ // that are the whole point of the `rules` bucket. Restricting the table
197
+ // (instead of filtering afterwards) keeps the docs lane from re-running the
198
+ // conversation search, and one shared embedding serves both lanes.
199
+ const fetchK = maxPerBucket * CANDIDATE_FETCH_MULTIPLIER;
200
+ const embedding = opts.embedding ? sharedEmbedding(opts.embedding) : undefined;
201
+ const { current: project, otherProjectOf } = await resolvePackProjects(opts.cwd);
202
+ const asksOtherProjects = ASKS_OTHER_PROJECTS.test(opts.task);
203
+ const [convRes, docRes, projRes, otherRes] = await Promise.all([
204
+ hybridSearch(opts.task, embedding, {
205
+ scope: "conversations",
206
+ top_k: fetchK,
207
+ ...(opts.since ? { since: opts.since } : {}),
208
+ }),
209
+ hybridSearch(opts.task, embedding, {
210
+ scope: "all",
211
+ tables: DOC_TABLES,
212
+ top_k: fetchK,
213
+ ...(opts.since ? { since: opts.since } : {}),
214
+ ...(sourcePathPrefix ? { sourcePathPrefix } : {}),
215
+ }),
216
+ // Project-first lane: the same search restricted to conversations captured
217
+ // in this project, so project history is not crowded out by the archive.
218
+ // When the task asks for other projects it is the reverse: everything
219
+ // but this project's sessions, so they cannot crowd out the others.
220
+ project
221
+ ? hybridSearch(opts.task, embedding, {
222
+ scope: "conversations",
223
+ tables: ["conversations_hot"],
224
+ ...(asksOtherProjects
225
+ ? { excludeConversationIds: project.rowIds }
226
+ : { conversationIds: project.rowIds }),
227
+ top_k: fetchK,
228
+ ...(opts.since ? { since: opts.since } : {}),
229
+ })
230
+ : Promise.resolve(null),
231
+ // Other-projects lane: the docs lane above is locked to this project, so
232
+ // a document in another configured project is never a candidate there.
233
+ // The same search with this project left out finds it. Left out in the
234
+ // query: filtered afterwards, a project with many matching documents
235
+ // would fill top_k and leave no room for anyone else's.
236
+ sourcePathPrefix
237
+ ? hybridSearch(opts.task, embedding, {
238
+ scope: "all",
239
+ tables: DOC_TABLES,
240
+ top_k: fetchK,
241
+ excludeSourcePathPrefix: `${sourcePathPrefix.replace(/\/+$/, "")}/`,
242
+ ...(opts.since ? { since: opts.since } : {}),
243
+ })
244
+ : Promise.resolve(null),
245
+ ]);
246
+ let degraded = convRes.degraded || docRes.degraded;
247
+ let degradedReason = convRes.degraded_reason ?? docRes.degraded_reason;
248
+ // Rerank the project lane together with the global lane: BM25 is normalized
249
+ // over the pool, so a separately reranked project pool would inflate weak
250
+ // project matches.
251
+ let convRanked = rerank(toRerankInput(mergeCandidates(convRes.candidates, projRes?.candidates ?? [])));
252
+ if (project) {
253
+ // Half the pool is held for the lane's side: this project's sessions, or
254
+ // everyone else's when the task asks for other projects.
255
+ const held = convRanked.filter((r) => project.idSet.has(r.id) !== asksOtherProjects);
256
+ const rest = convRanked.filter((r) => project.idSet.has(r.id) === asksOtherProjects);
257
+ convRanked = [...held.slice(0, Math.ceil(fetchK / 2)), ...rest];
258
+ }
259
+ convRanked = convRanked.slice(0, fetchK);
260
+ let docRanked = rerank(toRerankInput(docRes.candidates.filter((c) => c.source_table === "structured_docs" ||
261
+ c.source_table === "structured_docs_local"))).slice(0, fetchK);
262
+ const otherRanked = otherRes
263
+ ? rerank(toRerankInput(otherRes.candidates)).slice(0, fetchK)
264
+ : [];
265
+ // Fetch raw rows for the top ranked results so we can pull `decisions`,
266
+ // `content`, `metadata.title`, `source_path`, etc.
267
+ const [convRows, docRows, otherRows] = await Promise.all([
268
+ fetchRowsById(convRanked),
269
+ fetchRowsById(docRanked),
270
+ fetchRowsById(otherRanked),
271
+ ]);
272
+ // Collapse chunk siblings so one long conversation/document contributes a
273
+ // single card downstream (decisions / examples / rules / evidence) instead of
274
+ // one per chunk. No-op for unchunked/legacy rows (parentKeyForRow → null).
275
+ const parentKeyOf = (rows) => (r) => {
276
+ const row = rows.get(rankedKey(r));
277
+ return row ? parentKeyForRow(r.source_table, row) : null;
278
+ };
279
+ const convGrouped = groupByParent(convRanked, parentKeyOf(convRows));
280
+ convRanked = convGrouped.ranked;
281
+ docRanked = groupByParent(docRanked, parentKeyOf(docRows)).ranked;
282
+ // Collapse near-duplicate conversation captures (same task re-captured across
283
+ // sessions = distinct rows groupByParent can't merge) so one card per topic
284
+ // reaches decisions/examples/evidence instead of N redundant copies.
285
+ // Conversation rows only; docs pass through. Flag-gated (RIFT_CONV_DEDUP),
286
+ // provable no-op when off. Skipped when the conversation pool has chunk markers
287
+ // (best-chunk text would false-merge distinct conversations — see conversation-dedup).
288
+ let foldedCaptures = new Map();
289
+ if (convDedupEnabled() && !poolHasChunkMarkers(convGrouped)) {
290
+ const collapsed = collapseConversationDuplicates(convRanked);
291
+ convRanked = collapsed.ranked;
292
+ foldedCaptures = collapsed.foldedMembersById;
293
+ }
294
+ // Drop any doc candidates whose source_path points into engine-internal or
295
+ // build-artifact directories. These rows are not project rules — they are
296
+ // raw conversation snapshots, embedding cache files, quarantine drops,
297
+ // compiled JS/TS, node_modules, worktree copies, etc. — and they crowd
298
+ // real project-rule files (CLAUDE.md / AGENTS.md / PROJECT_STATE.md /
299
+ // TODO.md) out of the `rules` and `constraints` buckets. Conversation
300
+ // content is still reachable via `convRanked`.
301
+ const docRankedClean = docRanked.filter((r) => !shouldExcludeDocFromRules(docRows.get(rankedKey(r))?.["source_path"]));
302
+ // Constraints layer an extra filter on top via the contract helper:
303
+ // one-shot agent prompts (`*-prompt.md`) routinely carry "Hard
304
+ // Constraints" sections that match `extractConstraintLines`'s marker
305
+ // gate but are scaffolding, not durable project law. They stay
306
+ // eligible for `rules` (legitimate doc-level evidence) but must not
307
+ // lead `constraints` as project law. Calling
308
+ // `shouldExcludeDocFromConstraints` here — rather than composing the
309
+ // two helpers inline — keeps the constraint-exclusion contract in one
310
+ // place, so any future per-bucket exclusion is picked up automatically.
311
+ const docRankedForConstraints = docRanked.filter((r) => !shouldExcludeDocFromConstraints(docRows.get(rankedKey(r))?.["source_path"]));
312
+ // Re-sort the conversation candidates by query relevance before
313
+ // extracting `decisions` and `examples`. The global rerank() composite
314
+ // weights S_sim at only 55% — quality/tier/freshness can pull a
315
+ // high-confidence but tangential row above a more relevant one, which
316
+ // is the exact REX failure the relevance-first slice closes
317
+ // (docs/feedback/2026-05-14-fact-checking-rex.md, P1 #5). The re-sort
318
+ // is local to the context-pack path; onadit_search and the global
319
+ // reranker are intentionally unchanged.
320
+ const convSorted = sortByRelevanceFirst(convRanked);
321
+ const convByRelevance = asksOtherProjects
322
+ ? otherProjectsFirst(convSorted, (id) => otherProjectOf(id) !== undefined)
323
+ : project
324
+ ? projectFirst(convSorted, project.idSet)
325
+ : convSorted;
326
+ // Tracker sections read live (canonical-file lane). Trackers aren't indexed,
327
+ // and auto-captured sessions carry no extracted decisions, so without this
328
+ // the decisions and constraints a project wrote down never reach the pack.
329
+ // opts.cwd is the agent's working dir, often a SUBDIR (src/, tests/). The
330
+ // canonical files live at the repo root, so resolve the git top-level first
331
+ // (same resolution probeGitStates does) — otherwise we'd look in the subdir,
332
+ // find nothing, and silently no-op. Falls back to cwd outside a git repo.
333
+ const trackerMatches = canonicalFilesEnabled() && opts.cwd
334
+ ? selectCanonicalSections({
335
+ projectRoot: resolveRepoRoot(opts.cwd),
336
+ query: opts.task,
337
+ maxSections: TRACKER_SECTION_POOL,
338
+ })
339
+ : [];
340
+ // Tracker cards fill the slots the search-ranked cards leave free; they
341
+ // never take one. The lane matches on words, and a tracker note that only
342
+ // mentions the subject must not replace a decision that is about it. A
343
+ // tracker section that loses its slot here still reaches the agent as a
344
+ // current-truth card. Each bucket reads the whole pool, so a rule further
345
+ // down is not lost to the cap.
346
+ const convForDecisions = filterByRelevance(convByRelevance, DECISIONS_RELEVANCE_FLOOR);
347
+ // A session captured more than once is shown once, but each capture holds
348
+ // the statements found in it. So every capture of a shown session is read
349
+ // for what the user stated, and for nothing else.
350
+ const convForStatements = convForDecisions.flatMap((r) => [r, ...(foldedCaptures.get(rankedKey(r)) ?? [])]);
351
+ const statementOnlyIds = new Set(convForDecisions.flatMap((r) => foldedCaptures.get(rankedKey(r)) ?? []).map((r) => r.id));
352
+ // Not after a degraded search: the task's vector did not arrive in time
353
+ // there, and asking for it again would hold the pack a second time. That
354
+ // pack is already marked partial.
355
+ const closeness = embedding && !convRes.degraded
356
+ ? await statementCloseness(convForStatements, convRows, opts.task, embedding, opts.statementWaitMs ?? EMBED_WAIT_MS)
357
+ : NO_CLOSENESS;
358
+ // Sentences were waiting and were not compared: the pack may lack a rule
359
+ // the next one will hold, so it says so rather than look complete.
360
+ if (closeness.missed) {
361
+ degraded = true;
362
+ degradedReason ??= closeness.missed;
363
+ }
364
+ const decisions = [
365
+ ...extractDecisions(convForStatements, convRows, maxPerBucket, otherProjectOf, opts.task, closeness, statementOnlyIds),
366
+ ...trackerDecisions(trackerMatches),
367
+ ].slice(0, maxPerBucket);
368
+ const examples = buildExamples(filterByRelevance(convByRelevance, EXAMPLES_RELEVANCE_FLOOR), convRows, maxPerBucket, opts.task, otherProjectOf);
369
+ const rules = buildRules(docRankedClean, docRows, maxPerBucket);
370
+ const otherProjects = cwdMatch && opts.sources
371
+ ? buildOtherProjects(groupByParent(otherRanked, parentKeyOf(otherRows)).ranked, otherRows, cwdMatch.rootPath, opts.sources, maxPerBucket)
372
+ : [];
373
+ // Rules the user stated in a session come last: they are past discussion,
374
+ // and a rule written in a document or a live tracker outranks it.
375
+ const constraints = [
376
+ ...extractConstraints(docRankedForConstraints, docRows, maxPerBucket),
377
+ ...trackerConstraints(trackerMatches),
378
+ ...userConstraints(convForStatements, convRows, maxPerBucket, otherProjectOf, opts.task, closeness),
379
+ ].slice(0, maxPerBucket);
380
+ // Current Truth Mode v0/v1 — intent-aware evidence partition. Reuses
381
+ // the already-retrieved conv + doc hits; does not change ranking or
382
+ // fetch anything new. v1 adds the git-state probe below so file-backed
383
+ // evidence carries a tracked/untracked/modified/deleted/newer_on_disk
384
+ // signal into the partitioner. See src/retrieval/current-truth.ts +
385
+ // src/retrieval/git-state.ts.
386
+ const intent = classifyEvidenceIntent(opts.task);
387
+ const claimType = classifyClaimType(opts.task);
388
+ // v1: probe git state once per buildContextPack call. We only probe
389
+ // when a project root is available (opts.cwd) — without one, every
390
+ // path returns "unknown" anyway, and we'd be paying for a no-op git
391
+ // invocation. Conversations don't carry source_paths suitable for
392
+ // git probing, so the input set is just the document hits.
393
+ const gitStateInputs = [];
394
+ if (opts.cwd) {
395
+ for (const r of docRankedClean) {
396
+ const row = docRows.get(rankedKey(r));
397
+ const sourcePath = row?.["source_path"] || undefined;
398
+ if (!sourcePath)
399
+ continue;
400
+ const indexedAt = row?.["indexed_at"] || undefined;
401
+ gitStateInputs.push({ sourcePath, indexedAt });
402
+ }
403
+ }
404
+ const gitStateBySourcePath = opts.cwd
405
+ ? probeGitStates(gitStateInputs, { projectRoot: opts.cwd })
406
+ : new Map();
407
+ const evidenceInputs = [
408
+ ...convByRelevance.map((r) => ({
409
+ ranked: r,
410
+ row: convRows.get(rankedKey(r)),
411
+ kind: "conversation",
412
+ })),
413
+ ...docRankedClean.map((r) => {
414
+ const row = docRows.get(rankedKey(r));
415
+ const sourcePath = row?.["source_path"] || undefined;
416
+ const gs = sourcePath ? gitStateBySourcePath.get(sourcePath) : undefined;
417
+ const input = {
418
+ ranked: r,
419
+ row,
420
+ kind: "document",
421
+ };
422
+ if (gs)
423
+ input.gitState = gs;
424
+ return input;
425
+ }),
426
+ ];
427
+ // Tracker sections lead the evidence as tracker-tier inputs. The partitioner
428
+ // below is UNCHANGED and decides placement BY INTENT: tracker docs lead
429
+ // `current_truth` for current_truth/blended, and stay `current_truth`
430
+ // background under reasoning_archive ("what did we decide …" classifies as
431
+ // reasoning_archive, the exact case this lane must cover). No matches, no
432
+ // inputs.
433
+ evidenceInputs.unshift(...canonicalEvidenceInputs(trackerMatches.slice(0, maxPerBucket * 3)));
434
+ const partition = partitionEvidence(evidenceInputs, {
435
+ intent,
436
+ claimType,
437
+ maxPerSection: maxPerBucket,
438
+ ...(opts.cwd ? { projectRoot: opts.cwd } : {}),
439
+ ...(opts.selfReportsRoot ? { selfReportsRoot: opts.selfReportsRoot } : {}),
440
+ });
441
+ // The fallback list names files a project often keeps. Someone who keeps
442
+ // none of them must not be told to go and read them.
443
+ if (opts.cwd) {
444
+ const roots = [opts.cwd, resolveRepoRoot(opts.cwd) ?? opts.cwd];
445
+ partition.recommended_live_files = partition.recommended_live_files.filter((f) => path.isAbsolute(f.path) || roots.some((root) => fs.existsSync(path.join(root, f.path))));
446
+ }
447
+ const assembled = enforceBudget({ decisions, constraints, examples, rules }, {
448
+ maxBytes,
449
+ task: opts.task,
450
+ intent,
451
+ partition,
452
+ otherProjects,
453
+ otherProjectsFirst: asksOtherProjects,
454
+ degraded,
455
+ ...(degradedReason ? { degradedReason } : {}),
456
+ ...(embedding ? {} : { lexical: true }),
457
+ ...(project ? { projectScope: { root: project.root, conversations: project.rowIds.length } } : {}),
458
+ });
459
+ const pack = {
460
+ task: opts.task,
461
+ intent,
462
+ decisions: assembled.decisions,
463
+ constraints: assembled.constraints,
464
+ examples: assembled.examples,
465
+ rules: assembled.rules,
466
+ total_bytes: assembled.totalBytes,
467
+ truncated: assembled.truncated,
468
+ degraded,
469
+ };
470
+ if (assembled.partition.current_truth.length > 0)
471
+ pack.current_truth = assembled.partition.current_truth;
472
+ if (assembled.partition.past_reasoning.length > 0)
473
+ pack.past_reasoning = assembled.partition.past_reasoning;
474
+ if (assembled.partition.older_memory.length > 0)
475
+ pack.older_memory = assembled.partition.older_memory;
476
+ if (assembled.partition.discounted.length > 0)
477
+ pack.discounted = assembled.partition.discounted;
478
+ if (assembled.partition.recommended_live_files.length > 0)
479
+ pack.recommended_live_files = assembled.partition.recommended_live_files;
480
+ if (assembled.partition.conflicts.length > 0)
481
+ pack.conflicts = assembled.partition.conflicts;
482
+ if (assembled.partition.current_truth_caveat)
483
+ pack.current_truth_caveat = assembled.partition.current_truth_caveat;
484
+ if (assembled.otherProjects.length > 0)
485
+ pack.other_projects = assembled.otherProjects;
486
+ if (degradedReason)
487
+ pack.degraded_reason = degradedReason;
488
+ if (!embedding)
489
+ pack.mode = "lexical";
490
+ if (project)
491
+ pack.project_scope = { root: project.root, conversations: project.rowIds.length };
492
+ return pack;
493
+ }
494
+ /**
495
+ * Drop candidates whose best available relevance signal falls below
496
+ * `floor`. Combines semantic similarity (`S_sim`) and normalized BM25
497
+ * via `max()` so a strong keyword match keeps a row that happens to
498
+ * score weakly on the embedding axis, and a strong semantic match
499
+ * keeps a row that happens to share no tokens. Both signals live in
500
+ * `[0,1]`. Exported so tests can exercise the floor directly with
501
+ * synthetic `RankedResult`s.
502
+ */
503
+ export function filterByRelevance(ranked, floor) {
504
+ return ranked.filter((r) => Math.max(r.factors.S_sim, r.bm25_normalized) >= floor);
505
+ }
506
+ /**
507
+ * Re-sort ranked candidates so that query relevance dominates ordering,
508
+ * with the composite rerank score acting only as a tie-breaker.
509
+ *
510
+ * Primary key: `max(S_sim, bm25_normalized)`, descending — the same
511
+ * dual-channel signal `filterByRelevance` already uses, so semantic
512
+ * and keyword evidence are treated symmetrically. Two candidates whose
513
+ * primary keys are within `epsilon` ({@link RELEVANCE_TIE_EPSILON})
514
+ * fall through to the composite `score`, descending — preserving the
515
+ * freshness / quality / tier ordering that the PRD-6.2 reranker
516
+ * encodes when relevance is effectively equal. ID is a final
517
+ * tie-breaker for determinism.
518
+ *
519
+ * Slice motivation: the global reranker weights `S_sim` at only 55%
520
+ * of the composite score, so a confidently-captured but tangential row
521
+ * could outrank a clearly more relevant lower-confidence row in the
522
+ * `decisions` and `examples` buckets. This helper is applied only to
523
+ * the conversation pipeline that feeds those two buckets; `onadit_search`
524
+ * and the global reranker are intentionally untouched. See
525
+ * docs/feedback/2026-05-14-fact-checking-rex.md (P1 #5) for the REX
526
+ * trace that motivated the change.
527
+ *
528
+ * Pure / non-mutating: returns a new array.
529
+ */
530
+ export function sortByRelevanceFirst(ranked, epsilon = RELEVANCE_TIE_EPSILON) {
531
+ const withKey = ranked.map((r) => ({
532
+ r,
533
+ rel: Math.max(r.factors.S_sim, r.bm25_normalized),
534
+ }));
535
+ withKey.sort((a, b) => {
536
+ if (Math.abs(a.rel - b.rel) > epsilon)
537
+ return b.rel - a.rel;
538
+ if (a.r.score !== b.r.score)
539
+ return b.r.score - a.r.score;
540
+ return a.r.id < b.r.id ? -1 : a.r.id > b.r.id ? 1 : 0;
541
+ });
542
+ return withKey.map((x) => x.r);
543
+ }
544
+ // --- Bucket builders ---
545
+ function extractDecisions(ranked, rows, cap, otherProjectOf, task, closeness, statementOnlyIds = new Set()) {
546
+ const out = [];
547
+ const seen = new Set();
548
+ for (const r of ranked) {
549
+ if (out.length >= cap)
550
+ break;
551
+ const row = rows.get(rankedKey(r));
552
+ if (!row)
553
+ continue;
554
+ const raw = row["decisions"];
555
+ const list = parseJsonStringArray(raw);
556
+ if (list.length === 0)
557
+ continue;
558
+ const timestamp = row["indexed_at"] || undefined;
559
+ const source = row["source"] || "conversation";
560
+ for (const d of list) {
561
+ if (out.length >= cap)
562
+ break;
563
+ const quote = userQuote(d, "decision", r, row, task, closeness);
564
+ // A folded capture adds the user's sentences only: its saved decisions
565
+ // are the shown capture's, and would repeat them.
566
+ if (quote === "skip" || (!quote && statementOnlyIds.has(r.id)))
567
+ continue;
568
+ const text = quote?.text ?? truncate(collapseWhitespace(d), ITEM_TEXT_MAX);
569
+ if (!text)
570
+ continue;
571
+ const key = text.toLowerCase();
572
+ if (seen.has(key))
573
+ continue;
574
+ seen.add(key);
575
+ const card = { text, source_id: r.id, source, ...quote?.ref };
576
+ if (timestamp)
577
+ card.timestamp = timestamp;
578
+ const otherProject = otherProjectOf(r.id);
579
+ if (otherProject)
580
+ card.project = otherProject;
581
+ out.push(card);
582
+ }
583
+ }
584
+ return out;
585
+ }
586
+ /** What a session is about, short enough to sit on every card that cites it. */
587
+ const SESSION_LABEL_MAX = 80;
588
+ const NO_CLOSENESS = { close: new Set() };
589
+ /**
590
+ * Compare the task with the user's sentences that the word test would drop,
591
+ * in the candidate sessions only. Nothing new leaves the machine: the task is
592
+ * already embedded for the search and each sentence is part of a transcript
593
+ * embedded at capture. A failed or slow request leaves the word test in
594
+ * charge and is reported as `missed`; its late answer still fills the cache,
595
+ * so the next pack for the same sessions has it.
596
+ */
597
+ async function statementCloseness(ranked, rows, task, embedding, waitMs) {
598
+ const bar = embedding.name === STATEMENT_CLOSENESS_PROVIDER ? STATEMENT_CLOSENESS_MIN[embedding.model] : undefined;
599
+ if (bar === undefined)
600
+ return NO_CLOSENESS;
601
+ const quotes = new Set();
602
+ for (const r of ranked) {
603
+ for (const entry of parseJsonStringArray(rows.get(rankedKey(r))?.["decisions"])) {
604
+ const quote = decodeUserStatement(entry)?.quote;
605
+ if (quote && quote.length <= MAX_QUOTE_CHARS && !holdsQuestionSubject(quote, task))
606
+ quotes.add(quote);
607
+ }
608
+ }
609
+ if (quotes.size === 0)
610
+ return NO_CLOSENESS;
611
+ const key = (quote) => `${embedding.model}\u0000${quote}`;
612
+ const uncompared = [...quotes].filter((q) => !statementVectors.has(key(q)));
613
+ const missing = uncompared.slice(0, STATEMENT_COMPARE_MAX);
614
+ const waiting = uncompared.length - missing.length;
615
+ const fetched = (async () => {
616
+ if (missing.length === 0)
617
+ return;
618
+ const vectors = await embedding.embedBatch(missing);
619
+ for (const [i, quote] of missing.entries()) {
620
+ const vector = vectors[i];
621
+ if (!vector)
622
+ continue;
623
+ if (statementVectors.size >= STATEMENT_VECTOR_CACHE_MAX) {
624
+ statementVectors.delete(statementVectors.keys().next().value);
625
+ }
626
+ statementVectors.set(key(quote), vector);
627
+ }
628
+ })();
629
+ let timer;
630
+ const deadline = new Promise((_, reject) => {
631
+ timer = setTimeout(() => reject(new Error(`no answer within ${waitMs} ms`)), waitMs);
632
+ });
633
+ try {
634
+ const [taskVector] = await Promise.race([Promise.all([embedding.embed(task), fetched]), deadline]);
635
+ const close = new Set();
636
+ for (const quote of quotes) {
637
+ const vector = statementVectors.get(key(quote));
638
+ if (vector && cosine(taskVector, vector) >= bar)
639
+ close.add(quote);
640
+ }
641
+ if (waiting === 0)
642
+ return { close };
643
+ return {
644
+ close,
645
+ missed: `partial pack: ${waiting} of your own statements are still to be compared with the task; a rule you stated may be missing`,
646
+ };
647
+ }
648
+ catch (err) {
649
+ fetched.catch(() => undefined);
650
+ const cause = err instanceof Error ? err.message : String(err);
651
+ return {
652
+ close: NO_CLOSENESS.close,
653
+ missed: `partial pack: your own statements were not compared with the task (${cause}); a rule you stated may be missing`,
654
+ };
655
+ }
656
+ finally {
657
+ clearTimeout(timer);
658
+ }
659
+ }
660
+ function cosine(a, b) {
661
+ if (a.length !== b.length)
662
+ return 0;
663
+ let dot = 0;
664
+ let normA = 0;
665
+ let normB = 0;
666
+ for (let i = 0; i < a.length; i++) {
667
+ dot += a[i] * b[i];
668
+ normA += a[i] * a[i];
669
+ normB += b[i] * b[i];
670
+ }
671
+ return normA && normB ? dot / Math.sqrt(normA * normB) : 0;
672
+ }
673
+ /**
674
+ * Read one entry of a row's `decisions` column as a sentence the user typed.
675
+ * Null for an entry capture did not mark (a manual save or an import), which
676
+ * keeps its existing treatment. "skip" for a marked entry of the other kind, or
677
+ * one that does not hold the question's subject: a session can match the task
678
+ * while most of what the user ruled in it is about something else.
679
+ */
680
+ function userQuote(entry, kind, r, row, task, closeness) {
681
+ const statement = decodeUserStatement(entry);
682
+ if (!statement)
683
+ return null;
684
+ if (statement.kind !== kind)
685
+ return "skip";
686
+ if (!holdsQuestionSubject(statement.quote, task) && !closeness.close.has(statement.quote))
687
+ return "skip";
688
+ // Whole or not at all. Cut short, a rule can lose the clause that limits
689
+ // it and still read as something the user said.
690
+ const text = collapseWhitespace(statement.quote);
691
+ if (text.length > MAX_QUOTE_CHARS)
692
+ return "skip";
693
+ const ref = {
694
+ said_by: "user",
695
+ session: truncate(collapseWhitespace(row["summary"] || ""), SESSION_LABEL_MAX),
696
+ source_table: r.source_table,
697
+ };
698
+ const offset = (row["content"] || "").indexOf(statement.quote);
699
+ if (offset >= 0)
700
+ ref.offset = offset;
701
+ return { text, ref };
702
+ }
703
+ /**
704
+ * Rules the user stated in a captured session of this project. A rule set in
705
+ * another project's session is not this project's rule, so it is left out.
706
+ */
707
+ function userConstraints(ranked, rows, cap, otherProjectOf, task, closeness) {
708
+ const out = [];
709
+ const seen = new Set();
710
+ for (const r of ranked) {
711
+ if (out.length >= cap)
712
+ break;
713
+ const row = rows.get(rankedKey(r));
714
+ if (!row || otherProjectOf(r.id))
715
+ continue;
716
+ for (const entry of parseJsonStringArray(row["decisions"])) {
717
+ if (out.length >= cap)
718
+ break;
719
+ const quote = userQuote(entry, "constraint", r, row, task, closeness);
720
+ if (!quote || quote === "skip")
721
+ continue;
722
+ const key = quote.text.toLowerCase();
723
+ if (seen.has(key))
724
+ continue;
725
+ seen.add(key);
726
+ const card = {
727
+ text: quote.text,
728
+ source_id: r.id,
729
+ source: row["source"] || "conversation",
730
+ ...quote.ref,
731
+ };
732
+ const timestamp = row["indexed_at"] || undefined;
733
+ if (timestamp)
734
+ card.timestamp = timestamp;
735
+ out.push(card);
736
+ }
737
+ }
738
+ return out;
739
+ }
740
+ /** Matched items under a tracker's decisions heading, as decision cards. */
741
+ function trackerDecisions(matches) {
742
+ const out = [];
743
+ for (const m of matches) {
744
+ if (m.group !== "decision")
745
+ continue;
746
+ const text = truncate(collapseWhitespace(cleanItemText(m.section.text)), ITEM_TEXT_MAX);
747
+ if (!text)
748
+ continue;
749
+ const sourcePath = `${m.fileName}:${m.section.line}`;
750
+ const card = {
751
+ text,
752
+ source_id: `canonical:${sourcePath}`,
753
+ source: "tracker",
754
+ source_path: sourcePath,
755
+ };
756
+ const date = /^\d{4}-\d{2}-\d{2}/.exec(text)?.[0];
757
+ if (date)
758
+ card.timestamp = date;
759
+ out.push(card);
760
+ }
761
+ return out;
762
+ }
763
+ /** A tracker heading whose items are standing rules as written. */
764
+ const GUARDRAIL_HEADING = /\b(guardrails?|constraints?)\b/i;
765
+ /** Trackers are often written in French; the doc-lane markers are English only. */
766
+ const FRENCH_MARKER_AT_START = /^(?:ne\s+(?:pas|rien|jamais|plus)|jamais|toujours|interdit)\b/i;
767
+ /**
768
+ * Constraint clauses from matched tracker items. A tracker states its rules
769
+ * mid-sentence ("Keep email parked; do not add another source during the
770
+ * pilot"), so each item is split into clauses before the marker test.
771
+ */
772
+ function trackerConstraints(matches) {
773
+ const out = [];
774
+ const seen = new Set();
775
+ for (const m of matches) {
776
+ const item = cleanItemText(m.section.text);
777
+ const clauses = item.split(/(?<=[.;:])\s+|\s+—\s+|\n/);
778
+ const lines = GUARDRAIL_HEADING.test(m.section.parent)
779
+ ? [collapseWhitespace(item)]
780
+ : [
781
+ ...extractConstraintLines(clauses.join("\n")),
782
+ ...clauses
783
+ .map((clause) => collapseWhitespace(clause.replace(/[.;]+\s*$/, "")))
784
+ .filter((clause) => FRENCH_MARKER_AT_START.test(clause)),
785
+ ];
786
+ const sourcePath = `${m.fileName}:${m.section.line}`;
787
+ for (const line of lines) {
788
+ const text = truncate(line, ITEM_TEXT_MAX);
789
+ const key = text.toLowerCase();
790
+ if (!text || seen.has(key))
791
+ continue;
792
+ seen.add(key);
793
+ out.push({ text, source_id: `canonical:${sourcePath}`, source_path: sourcePath });
794
+ }
795
+ }
796
+ return out;
797
+ }
798
+ function buildExamples(ranked, rows, cap, task, otherProjectOf) {
799
+ const out = [];
800
+ for (const r of ranked) {
801
+ if (out.length >= cap)
802
+ break;
803
+ const row = rows.get(rankedKey(r));
804
+ const fullContent = row?.["content"] || r.content || "";
805
+ const summary = truncate(collapseWhitespace(row?.["summary"] || fullContent), SNIPPET_MAX);
806
+ if (!summary)
807
+ continue;
808
+ const title = deriveExampleTitle(row, summary);
809
+ const source = row?.["source"] || "conversation";
810
+ const timestamp = row?.["indexed_at"] || undefined;
811
+ const { content_bytes, content_tokens_estimate } = computeContentSize(fullContent);
812
+ const card = {
813
+ id: r.id,
814
+ title,
815
+ source,
816
+ summary,
817
+ content_bytes,
818
+ content_tokens_estimate,
819
+ expand: {
820
+ route: "/search",
821
+ // Size fields are mirrored into `expand.params` so an agent that
822
+ // copy-pastes the pointer sees the warning at the exact moment it
823
+ // decides whether to spend context on `detail="full"`.
824
+ params: {
825
+ id: r.id,
826
+ tier: r.source_table === "conversations_cold" ? "cold" : "hot",
827
+ source_table: r.source_table,
828
+ detail: "full",
829
+ content_bytes,
830
+ content_tokens_estimate,
831
+ },
832
+ },
833
+ };
834
+ if (timestamp)
835
+ card.timestamp = timestamp;
836
+ const otherProject = otherProjectOf(r.id);
837
+ if (otherProject)
838
+ card.project = otherProject;
839
+ const [passage] = extractPassages(fullContent, task, { max: 1, windowChars: PASSAGE_MAX });
840
+ if (passage) {
841
+ card.passage = {
842
+ text: passage.text,
843
+ offset: passage.start,
844
+ matched: `${passage.terms_matched}/${passage.terms_total}`,
845
+ };
846
+ }
847
+ out.push(card);
848
+ }
849
+ return out;
850
+ }
851
+ function buildRules(ranked, rows, cap) {
852
+ const out = [];
853
+ for (const r of ranked) {
854
+ if (out.length >= cap)
855
+ break;
856
+ const row = rows.get(rankedKey(r));
857
+ const content = row?.["content"] || r.content || "";
858
+ const snippet = truncate(collapseWhitespace(content), SNIPPET_MAX);
859
+ if (!snippet)
860
+ continue;
861
+ const sourcePath = row?.["source_path"] || "";
862
+ const title = deriveRuleTitle(row, sourcePath, snippet);
863
+ const { content_bytes, content_tokens_estimate } = computeContentSize(content);
864
+ const card = {
865
+ id: r.id,
866
+ title,
867
+ snippet,
868
+ content_bytes,
869
+ content_tokens_estimate,
870
+ expand: {
871
+ route: "/search",
872
+ params: {
873
+ id: r.id,
874
+ tier: "structured_doc",
875
+ source_table: r.source_table,
876
+ detail: "full",
877
+ content_bytes,
878
+ content_tokens_estimate,
879
+ },
880
+ },
881
+ };
882
+ if (sourcePath)
883
+ card.source_path = sourcePath;
884
+ out.push(card);
885
+ }
886
+ return out;
887
+ }
888
+ /**
889
+ * Documents that match the task and sit in a configured project other than
890
+ * the current one. They become reference cards labelled with their project,
891
+ * and stay out of rules, constraints and current truth: another project's
892
+ * "NEVER" is not this project's law.
893
+ */
894
+ function buildOtherProjects(ranked, rows, currentRoot, sources, cap) {
895
+ const out = [];
896
+ for (const r of filterByRelevance(ranked, OTHER_PROJECTS_RELEVANCE_FLOOR)) {
897
+ if (out.length >= cap)
898
+ break;
899
+ const row = rows.get(rankedKey(r));
900
+ const sourcePath = row?.["source_path"] || "";
901
+ if (!sourcePath || shouldExcludeDocFromRules(sourcePath))
902
+ continue;
903
+ const home = resolveCwdRoot(sourcePath, sources);
904
+ if (!home || home.rootPath === currentRoot)
905
+ continue;
906
+ const content = row?.["content"] || r.content || "";
907
+ const snippet = truncate(collapseWhitespace(content), SNIPPET_MAX);
908
+ if (!snippet)
909
+ continue;
910
+ const { content_bytes, content_tokens_estimate } = computeContentSize(content);
911
+ out.push({
912
+ id: r.id,
913
+ title: deriveRuleTitle(row, sourcePath, snippet),
914
+ project: home.projectName,
915
+ snippet,
916
+ source_path: sourcePath,
917
+ content_bytes,
918
+ content_tokens_estimate,
919
+ expand: {
920
+ route: "/search",
921
+ params: {
922
+ id: r.id,
923
+ tier: "structured_doc",
924
+ source_table: r.source_table,
925
+ detail: "full",
926
+ content_bytes,
927
+ content_tokens_estimate,
928
+ },
929
+ },
930
+ });
931
+ }
932
+ return out;
933
+ }
934
+ /**
935
+ * Pull constraint-shaped lines out of the matching rule documents. Looks
936
+ * for classic imperative markers (MUST/MUST NOT/NEVER/DO NOT/ALWAYS/AVOID)
937
+ * which are the idiom for CLAUDE.md / AGENTS.md / PRD-style project rules.
938
+ * Falls back silently if none found — constraints is the bucket most
939
+ * likely to be empty, by design.
940
+ */
941
+ function extractConstraints(ranked, rows, cap) {
942
+ const out = [];
943
+ const seen = new Set();
944
+ for (const r of ranked) {
945
+ if (out.length >= cap)
946
+ break;
947
+ const row = rows.get(rankedKey(r));
948
+ const content = row?.["content"] || r.content;
949
+ if (!content)
950
+ continue;
951
+ const lines = extractConstraintLines(content);
952
+ if (lines.length === 0)
953
+ continue;
954
+ const sourcePath = row?.["source_path"] || undefined;
955
+ for (const line of lines) {
956
+ if (out.length >= cap)
957
+ break;
958
+ const text = truncate(line, ITEM_TEXT_MAX);
959
+ const key = text.toLowerCase();
960
+ if (seen.has(key))
961
+ continue;
962
+ seen.add(key);
963
+ const card = { text, source_id: r.id };
964
+ if (sourcePath)
965
+ card.source_path = sourcePath;
966
+ out.push(card);
967
+ }
968
+ }
969
+ return out;
970
+ }
971
+ /**
972
+ * The idiom we are matching is project-law: "MUST run pnpm check",
973
+ * "NEVER commit secrets", "Do not modify files outside this repo".
974
+ * Real constraints put the imperative word at the start of the line.
975
+ * Mid-line occurrences are almost always narrative prose, JSON values,
976
+ * or quoted excerpts — we'd rather drop those than admit them.
977
+ */
978
+ const MARKER_AT_START = /^(?:MUST(?:\s+NOT)?|NEVER|DO\s+NOT|DON'T|ALWAYS|AVOID|REQUIRED|FORBIDDEN)\b/i;
979
+ /** Bullet or numbered list prefix, stripped before checking for the marker. */
980
+ const LIST_PREFIX = /^\s*(?:[-*+]|\d+[.)]|\(\d+\))\s+/;
981
+ /** Leading markdown emphasis (`**`, `__`), stripped before checking. */
982
+ const EMPHASIS_PREFIX = /^(?:\*+|_+)\s*/;
983
+ /**
984
+ * Reject lines that look like a JSON/YAML fragment, a quoted transcript
985
+ * snippet, or other structured-data debris. These are the classic
986
+ * false-positive shapes from Slice 5 validation: raw conversation JSON
987
+ * and excerpt blobs that happen to contain marker words inside quoted
988
+ * values get pulled into the `constraints` bucket as if they were
989
+ * project law.
990
+ */
991
+ function looksLikeStructuredFragment(line) {
992
+ // JSON key-value: `"content": "..."`, `"excerpt": "..."`, etc.
993
+ if (/^"[^"]+"\s*:/.test(line))
994
+ return true;
995
+ // JSON structural punctuation anywhere — a real constraint line would
996
+ // not contain `{` or `}`.
997
+ if (/[{}]/.test(line))
998
+ return true;
999
+ // Line opens with a quote or backtick → quoted transcript/code snippet.
1000
+ if (/^["'`]/.test(line))
1001
+ return true;
1002
+ return false;
1003
+ }
1004
+ export function extractConstraintLines(content) {
1005
+ const out = [];
1006
+ for (const raw of content.split(/\r?\n/)) {
1007
+ const trimmed = raw.trim();
1008
+ if (!trimmed)
1009
+ continue;
1010
+ if (looksLikeStructuredFragment(trimmed))
1011
+ continue;
1012
+ const body = trimmed.replace(LIST_PREFIX, "").replace(EMPHASIS_PREFIX, "");
1013
+ if (!MARKER_AT_START.test(body))
1014
+ continue;
1015
+ const cleaned = collapseWhitespace(body.replace(/[.?!]+\s*$/, ""));
1016
+ out.push(cleaned);
1017
+ }
1018
+ return out;
1019
+ }
1020
+ /**
1021
+ * Greedy round-robin fill: start with empty buckets, pull one item at a
1022
+ * time from each input bucket in a fixed order, add only if it fits in
1023
+ * the remaining budget. Guarantees each bucket gets a fair shot even
1024
+ * when one bucket's items would otherwise crowd the budget.
1025
+ *
1026
+ * `totalBytes` is seeded from the serialized response envelope (task +
1027
+ * degraded flags + empty-bucket overhead) so the returned value reflects
1028
+ * the whole payload, not just bucket contents — `max_bytes` is a contract
1029
+ * on response size.
1030
+ */
1031
+ function enforceBudget(input, ctx) {
1032
+ const { maxBytes } = ctx;
1033
+ const order = [
1034
+ "decisions",
1035
+ "constraints",
1036
+ "rules",
1037
+ "examples",
1038
+ ];
1039
+ const queues = {
1040
+ decisions: [...input.decisions],
1041
+ constraints: [...input.constraints],
1042
+ examples: [...input.examples],
1043
+ rules: [...input.rules],
1044
+ };
1045
+ const output = {
1046
+ decisions: [],
1047
+ constraints: [],
1048
+ examples: [],
1049
+ rules: [],
1050
+ };
1051
+ // Current-truth-mode partition shares the same byte budget. We seed
1052
+ // outputs with copies and copy-back any items that fit. Recommended
1053
+ // live files are small and high-value — fill first.
1054
+ const partitionOut = {
1055
+ current_truth: [],
1056
+ past_reasoning: [],
1057
+ older_memory: [],
1058
+ discounted: [],
1059
+ recommended_live_files: [],
1060
+ conflicts: [],
1061
+ ...(ctx.partition.current_truth_caveat
1062
+ ? { current_truth_caveat: ctx.partition.current_truth_caveat }
1063
+ : {}),
1064
+ };
1065
+ const partitionQueues = {
1066
+ current_truth: [...ctx.partition.current_truth],
1067
+ past_reasoning: [...ctx.partition.past_reasoning],
1068
+ older_memory: [...ctx.partition.older_memory],
1069
+ discounted: [...ctx.partition.discounted],
1070
+ recommended_live_files: [...ctx.partition.recommended_live_files],
1071
+ conflicts: [...ctx.partition.conflicts],
1072
+ };
1073
+ let totalBytes = envelopeBytes(output, ctx);
1074
+ let truncated = false;
1075
+ // Pass 1: conflicts + recommended_live_files — small, high-value entries
1076
+ // the asker needs first (a surfaced conflict is the whole point of the
1077
+ // mode). Fill conflicts before live files; both before the bulk buckets.
1078
+ while (partitionQueues.conflicts.length > 0) {
1079
+ const item = partitionQueues.conflicts[0];
1080
+ const added = itemBytes(item);
1081
+ if (totalBytes + added > maxBytes) {
1082
+ truncated = true;
1083
+ break;
1084
+ }
1085
+ partitionQueues.conflicts.shift();
1086
+ partitionOut.conflicts.push(item);
1087
+ totalBytes += added;
1088
+ }
1089
+ while (partitionQueues.recommended_live_files.length > 0) {
1090
+ const item = partitionQueues.recommended_live_files[0];
1091
+ const added = itemBytes(item);
1092
+ if (totalBytes + added > maxBytes) {
1093
+ truncated = true;
1094
+ break;
1095
+ }
1096
+ partitionQueues.recommended_live_files.shift();
1097
+ partitionOut.recommended_live_files.push(item);
1098
+ totalBytes += added;
1099
+ }
1100
+ // Pass 1b: the best tracker section read live is placed before the
1101
+ // round-robin, so the project's own current answer is never lost to the
1102
+ // budget. The other tracker sections take their turn below like any card.
1103
+ if (partitionQueues.current_truth[0]?.id.startsWith("canonical:")) {
1104
+ const item = partitionQueues.current_truth[0];
1105
+ const added = itemBytes(item);
1106
+ if (totalBytes + added > maxBytes) {
1107
+ truncated = true;
1108
+ }
1109
+ else {
1110
+ partitionQueues.current_truth.shift();
1111
+ partitionOut.current_truth.push(item);
1112
+ totalBytes += added;
1113
+ }
1114
+ }
1115
+ // Other-project documents: before the round-robin when the task asks for
1116
+ // them, after it otherwise, so by default they never take a byte from the
1117
+ // project's own evidence.
1118
+ const otherQueue = [...ctx.otherProjects];
1119
+ const otherOut = [];
1120
+ const fillOtherProjects = () => {
1121
+ while (otherQueue.length > 0) {
1122
+ const item = otherQueue[0];
1123
+ // The section key itself (`,"other_projects":[]`) ships with the first card.
1124
+ const added = itemBytes(item) + (otherOut.length === 0 ? OTHER_PROJECTS_KEY_BYTES : 0);
1125
+ if (totalBytes + added > maxBytes) {
1126
+ truncated = true;
1127
+ break;
1128
+ }
1129
+ otherQueue.shift();
1130
+ otherOut.push(item);
1131
+ totalBytes += added;
1132
+ }
1133
+ };
1134
+ if (ctx.otherProjectsFirst)
1135
+ fillOtherProjects();
1136
+ // Pass 2: round-robin across legacy buckets and partition sections so
1137
+ // every section gets a fair shot even when one would otherwise crowd
1138
+ // the budget.
1139
+ const partitionOrder = [
1140
+ "current_truth",
1141
+ "past_reasoning",
1142
+ "older_memory",
1143
+ "discounted",
1144
+ ];
1145
+ let progressed = true;
1146
+ while (progressed) {
1147
+ progressed = false;
1148
+ for (const key of order) {
1149
+ const q = queues[key];
1150
+ if (q.length === 0)
1151
+ continue;
1152
+ const item = q[0];
1153
+ const addedBytes = itemBytes(item);
1154
+ if (totalBytes + addedBytes > maxBytes) {
1155
+ truncated = true;
1156
+ continue;
1157
+ }
1158
+ q.shift();
1159
+ output[key].push(item);
1160
+ totalBytes += addedBytes;
1161
+ progressed = true;
1162
+ }
1163
+ for (const key of partitionOrder) {
1164
+ const q = partitionQueues[key];
1165
+ if (q.length === 0)
1166
+ continue;
1167
+ const item = q[0];
1168
+ const added = itemBytes(item);
1169
+ if (totalBytes + added > maxBytes) {
1170
+ truncated = true;
1171
+ continue;
1172
+ }
1173
+ q.shift();
1174
+ partitionOut[key].push(item);
1175
+ totalBytes += added;
1176
+ progressed = true;
1177
+ }
1178
+ }
1179
+ // Pass 3: a rule the user stated about this task that the rotation left out
1180
+ // takes the place of other past discussion, which is what it is itself: the
1181
+ // last cards of the discounted, older-memory and past-reasoning sections,
1182
+ // in that order. Nothing else gives way to it: not a document's or a
1183
+ // tracker's rule, a decision, current truth or a conflict. And it is not
1184
+ // shown while a rule that outranks it in the bucket is still waiting.
1185
+ while (queues.constraints[0]?.said_by === "user") {
1186
+ const item = queues.constraints[0];
1187
+ const needed = totalBytes + itemBytes(item) - maxBytes;
1188
+ const givesWay = [];
1189
+ let freed = 0;
1190
+ for (const key of USER_RULE_REPLACES) {
1191
+ for (let i = partitionOut[key].length - 1; i >= 0 && freed < needed; i--) {
1192
+ freed += itemBytes(partitionOut[key][i]);
1193
+ givesWay.push(key);
1194
+ }
1195
+ }
1196
+ if (freed < needed)
1197
+ break;
1198
+ for (const key of givesWay) {
1199
+ // Back on its queue, so the pack still says something was left out.
1200
+ const card = partitionOut[key].pop();
1201
+ partitionQueues[key].unshift(card);
1202
+ totalBytes -= itemBytes(card);
1203
+ }
1204
+ queues.constraints.shift();
1205
+ output.constraints.push(item);
1206
+ totalBytes += itemBytes(item);
1207
+ }
1208
+ if (!ctx.otherProjectsFirst)
1209
+ fillOtherProjects();
1210
+ // Any items still sitting in the queues were dropped for budget.
1211
+ for (const key of order) {
1212
+ if (queues[key].length > 0) {
1213
+ truncated = true;
1214
+ break;
1215
+ }
1216
+ }
1217
+ if (!truncated) {
1218
+ for (const key of partitionOrder) {
1219
+ if (partitionQueues[key].length > 0) {
1220
+ truncated = true;
1221
+ break;
1222
+ }
1223
+ }
1224
+ if (partitionQueues.recommended_live_files.length > 0)
1225
+ truncated = true;
1226
+ if (partitionQueues.conflicts.length > 0)
1227
+ truncated = true;
1228
+ }
1229
+ return {
1230
+ decisions: output.decisions,
1231
+ constraints: output.constraints,
1232
+ examples: output.examples,
1233
+ rules: output.rules,
1234
+ partition: partitionOut,
1235
+ otherProjects: otherOut,
1236
+ totalBytes,
1237
+ truncated,
1238
+ };
1239
+ }
1240
+ /** The sections a user's own rule may take room from, first to give way first. */
1241
+ const USER_RULE_REPLACES = ["discounted", "older_memory", "past_reasoning"];
1242
+ const OTHER_PROJECTS_KEY_BYTES = Buffer.byteLength(',"other_projects":[]', "utf-8");
1243
+ function envelopeBytes(buckets, ctx) {
1244
+ // Full serialized response envelope, including echoed `task`, `degraded`
1245
+ // flags, and a worst-case integer placeholder for `total_bytes`. Used as
1246
+ // the starting-point byte count so `max_bytes` bounds the whole payload,
1247
+ // not just the bucket contents. The intent field is small but
1248
+ // included so the budget reflects its real serialized cost.
1249
+ const envelope = {
1250
+ task: ctx.task,
1251
+ intent: ctx.intent,
1252
+ decisions: buckets.decisions,
1253
+ constraints: buckets.constraints,
1254
+ examples: buckets.examples,
1255
+ rules: buckets.rules,
1256
+ total_bytes: ctx.maxBytes,
1257
+ truncated: true,
1258
+ degraded: ctx.degraded,
1259
+ };
1260
+ // v2: the caveat is a fixed-size string that always ships when set;
1261
+ // count it up front so a thin budget doesn't push the envelope over.
1262
+ // Conflicts and live files are filled item-by-item in the passes above,
1263
+ // so they're not pre-counted here.
1264
+ if (ctx.partition.current_truth_caveat)
1265
+ envelope["current_truth_caveat"] = ctx.partition.current_truth_caveat;
1266
+ if (ctx.degradedReason)
1267
+ envelope["degraded_reason"] = ctx.degradedReason;
1268
+ if (ctx.lexical)
1269
+ envelope["mode"] = "lexical";
1270
+ if (ctx.projectScope)
1271
+ envelope["project_scope"] = ctx.projectScope;
1272
+ return Buffer.byteLength(JSON.stringify(envelope), "utf-8");
1273
+ }
1274
+ function itemBytes(item) {
1275
+ return Buffer.byteLength(JSON.stringify(item), "utf-8") + 1; // +1 for comma
1276
+ }
1277
+ // --- Utilities ---
1278
+ function toRerankInput(cands) {
1279
+ return cands.map((c) => {
1280
+ const entry = {
1281
+ id: c.id,
1282
+ content: c.content,
1283
+ raw_sim: c.raw_sim,
1284
+ raw_bm25: c.raw_bm25,
1285
+ source_table: c.source_table,
1286
+ retrieval_method: c.retrieval_method,
1287
+ };
1288
+ if (c.indexed_at)
1289
+ entry.indexed_at = c.indexed_at;
1290
+ if (c.quality)
1291
+ entry.quality = c.quality;
1292
+ return entry;
1293
+ });
1294
+ }
1295
+ async function fetchRowsById(ranked) {
1296
+ const byTable = new Map();
1297
+ for (const r of ranked) {
1298
+ const arr = byTable.get(r.source_table) ?? [];
1299
+ arr.push(r.id);
1300
+ byTable.set(r.source_table, arr);
1301
+ }
1302
+ // Keyed by rankedKey — (source_table, id), not bare id — so a doc id present
1303
+ // in both the cloud and local tables can't have one row overwrite the other
1304
+ // and misattribute evidence. Look up via get(rankedKey(r)).
1305
+ const out = new Map();
1306
+ await Promise.all([...byTable].map(async ([tableName, ids]) => {
1307
+ if (ids.length === 0)
1308
+ return;
1309
+ const table = getTable(tableName);
1310
+ // Everything but the stored vector, which nothing downstream reads.
1311
+ const columns = (await table.schema()).fields
1312
+ .map((f) => f.name)
1313
+ .filter((name) => name !== "embedding");
1314
+ const rows = (await table
1315
+ .query()
1316
+ .select(columns)
1317
+ .where(inFilter("id", ids, { validateAsRowId: true }))
1318
+ .limit(ids.length)
1319
+ .toArray());
1320
+ for (const row of rows) {
1321
+ out.set(rankedKey({ source_table: tableName, id: row["id"] }), row);
1322
+ }
1323
+ }));
1324
+ return out;
1325
+ }
1326
+ function parseJsonStringArray(raw) {
1327
+ if (typeof raw !== "string" || !raw)
1328
+ return [];
1329
+ try {
1330
+ const parsed = JSON.parse(raw);
1331
+ if (!Array.isArray(parsed))
1332
+ return [];
1333
+ return parsed.filter((x) => typeof x === "string" && !!x.trim());
1334
+ }
1335
+ catch {
1336
+ return [];
1337
+ }
1338
+ }
1339
+ function deriveExampleTitle(row, summary) {
1340
+ const topics = parseJsonStringArray(row?.["topics"]);
1341
+ if (topics.length > 0)
1342
+ return truncate(topics.slice(0, 3).join(", "), 120);
1343
+ return truncate(firstLine(summary) || "(conversation)", 120);
1344
+ }
1345
+ function deriveRuleTitle(row, sourcePath, snippet) {
1346
+ const metaTitle = readMetadataTitle(row);
1347
+ if (metaTitle)
1348
+ return truncate(metaTitle, 120);
1349
+ if (sourcePath) {
1350
+ const base = sourcePath.split("/").filter(Boolean).pop();
1351
+ if (base)
1352
+ return truncate(base, 120);
1353
+ }
1354
+ return truncate(firstLine(snippet) || "(document)", 120);
1355
+ }
1356
+ function readMetadataTitle(row) {
1357
+ const meta = row?.["metadata"];
1358
+ if (typeof meta !== "string" || !meta)
1359
+ return null;
1360
+ try {
1361
+ const parsed = JSON.parse(meta);
1362
+ const t = parsed["title"];
1363
+ if (typeof t === "string" && t.trim())
1364
+ return t.trim();
1365
+ }
1366
+ catch {
1367
+ // ignore
1368
+ }
1369
+ return null;
1370
+ }
1371
+ function firstLine(text) {
1372
+ for (const line of text.split(/\r?\n/)) {
1373
+ const t = line.trim();
1374
+ if (t)
1375
+ return t.replace(/^#+\s*/, "").replace(/^[-*]\s+/, "");
1376
+ }
1377
+ return "";
1378
+ }
1379
+ function truncate(text, max) {
1380
+ if (text.length <= max)
1381
+ return text;
1382
+ return text.slice(0, max);
1383
+ }
1384
+ function collapseWhitespace(text) {
1385
+ return text.replace(/\s+/g, " ").trim();
1386
+ }
1387
+ function clamp(n, lo, hi) {
1388
+ if (n < lo)
1389
+ return lo;
1390
+ if (n > hi)
1391
+ return hi;
1392
+ return n;
1393
+ }
1394
+ /**
1395
+ * True when `source_path` points into a `data/raw/conversations/**` directory.
1396
+ * Those are raw conversation JSON snapshots that sometimes get indexed as
1397
+ * `structured_docs` because they live under a watched source path; they are
1398
+ * not project rule documents and must not populate `rules` / `constraints`.
1399
+ */
1400
+ export function isRawConversationPath(p) {
1401
+ return typeof p === "string" && /\/data\/raw\/conversations\//.test(p);
1402
+ }
1403
+ /**
1404
+ * Baseline engine-owned / build-artifact path exclusion for both the
1405
+ * `rules` and `constraints` buckets. The `constraints` bucket layers an
1406
+ * additional filter on top — see {@link shouldExcludeDocFromConstraints}
1407
+ * — to keep one-shot agent prompts out of the project-law surface while
1408
+ * still allowing them to be cited as `rules` doc evidence.
1409
+ *
1410
+ * Explicitly enumerates engine-owned subdirectories under `data/` rather
1411
+ * than matching `data/` wholesale, so user-facing locations the daemon
1412
+ * legitimately watches (notably `data/imports/`) remain eligible:
1413
+ * - `/data/raw/` — raw conversation snapshots
1414
+ * - `/data/embeddings/` — cloud embedding cache
1415
+ * - `/data/embeddings-local/` — local embedding cache
1416
+ * - `/data/quarantine/` — failed ingest drops
1417
+ * - `/data/review-queue/` — review-pipeline state
1418
+ * - `/data/inbox/` — pre-ingest staging
1419
+ * - `/data/observability/` — metrics / logs
1420
+ * - `/data/triage-results/` — batch triage output
1421
+ * - `/data/lancedb/` — the vector store itself
1422
+ * - `/dist/` — compiled JS/TS build artifacts
1423
+ * - `/node_modules/` — third-party dependencies
1424
+ * - `/.git/` — git internals
1425
+ * - `/.codex-worktrees/` — ephemeral worktrees created by codex runs
1426
+ * Rule-bearing human-authored files under `src/`, `docs/`, `reports/`,
1427
+ * `data/imports/`, or at the project root (CLAUDE.md, AGENTS.md,
1428
+ * PROJECT_STATE.md, TODO.md, …) are untouched.
1429
+ */
1430
+ const EXCLUDED_RULE_PATH_PATTERNS = [
1431
+ /\/data\/raw\//,
1432
+ /\/data\/embeddings\//,
1433
+ /\/data\/embeddings-local\//,
1434
+ /\/data\/quarantine\//,
1435
+ /\/data\/review-queue\//,
1436
+ /\/data\/inbox\//,
1437
+ /\/data\/observability\//,
1438
+ /\/data\/triage-results\//,
1439
+ /\/data\/lancedb\//,
1440
+ /\/dist\//,
1441
+ /\/node_modules\//,
1442
+ /\/\.git\//,
1443
+ /\/\.codex-worktrees\//,
1444
+ ];
1445
+ export function shouldExcludeDocFromRules(p) {
1446
+ if (typeof p !== "string")
1447
+ return false;
1448
+ return EXCLUDED_RULE_PATH_PATTERNS.some((rx) => rx.test(p));
1449
+ }
1450
+ /**
1451
+ * True when `source_path`'s basename ends with `-prompt.md` — the naming
1452
+ * convention this project uses for one-shot agent prompts (e.g.
1453
+ * `reports/insights/2026-05-03-opus-rift-intelligence-snapshot-prompt.md`,
1454
+ * `docs/05-claude-code-challenge-prompt.md`). These files routinely
1455
+ * include `Hard Constraints` sections such as "Do not modify, create,
1456
+ * delete, move, or rewrite any repository file." which match the
1457
+ * imperative-marker gate in {@link extractConstraintLines} but are
1458
+ * one-shot scaffolding, not durable project law — surfacing them in the
1459
+ * `constraints` bucket erodes trust in the bucket as a whole
1460
+ * (`docs/feedback/2026-05-14-fact-checking-rex.md`, P1 #6).
1461
+ *
1462
+ * Intentionally narrow: only files whose basename ends in literal
1463
+ * `-prompt.md` match. A spec doc like `docs/02-agent-access-without-prompting.md`
1464
+ * (ends in `-prompting.md`), a playbook like `prompts-overview.md`, or a
1465
+ * mid-name occurrence like `prompt-engineering-notes.md` are untouched.
1466
+ * Over-filtering a real project rule is worse than letting some prompt
1467
+ * noise through.
1468
+ */
1469
+ export function isPromptArtifactPath(p) {
1470
+ return typeof p === "string" && /-prompt\.md$/i.test(p);
1471
+ }
1472
+ /**
1473
+ * Per-bucket exclusion for the `constraints` surface. Combines the
1474
+ * baseline engine/build filter with the one-shot prompt-artifact filter
1475
+ * so an agent prompt can still appear in `rules` (as legitimate doc
1476
+ * evidence — "this is what we instructed Opus") without contributing
1477
+ * its imperative-marker lines to `constraints` (as if they were project
1478
+ * law).
1479
+ */
1480
+ export function shouldExcludeDocFromConstraints(p) {
1481
+ return shouldExcludeDocFromRules(p) || isPromptArtifactPath(p);
1482
+ }
1483
+ //# sourceMappingURL=context-pack.js.map