contextpro-mcp 0.0.0-stage → 1.5.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 (466) hide show
  1. package/CHANGELOG.md +425 -0
  2. package/INSTALL.md +218 -0
  3. package/INSTRUCTIONS.md +33 -0
  4. package/LICENSE +21 -0
  5. package/NOTICE +12 -0
  6. package/README.md +89 -2
  7. package/SECURITY.md +29 -0
  8. package/agent-guide.md +354 -0
  9. package/agent-instructions.md +1 -0
  10. package/build/core/agent-setup.d.ts +5 -0
  11. package/build/core/agent-setup.d.ts.map +1 -0
  12. package/build/core/agent-setup.js +95 -0
  13. package/build/core/agent-setup.js.map +1 -0
  14. package/build/core/artifacts.d.ts +64 -0
  15. package/build/core/artifacts.d.ts.map +1 -0
  16. package/build/core/artifacts.js +370 -0
  17. package/build/core/artifacts.js.map +1 -0
  18. package/build/core/bounded-source.d.ts +15 -0
  19. package/build/core/bounded-source.d.ts.map +1 -0
  20. package/build/core/bounded-source.js +78 -0
  21. package/build/core/bounded-source.js.map +1 -0
  22. package/build/core/changed-since.d.ts +20 -0
  23. package/build/core/changed-since.d.ts.map +1 -0
  24. package/build/core/changed-since.js +43 -0
  25. package/build/core/changed-since.js.map +1 -0
  26. package/build/core/chat-model.d.ts +8 -0
  27. package/build/core/chat-model.d.ts.map +1 -0
  28. package/build/core/chat-model.js +135 -0
  29. package/build/core/chat-model.js.map +1 -0
  30. package/build/core/clustering.d.ts +6 -0
  31. package/build/core/clustering.d.ts.map +1 -0
  32. package/build/core/clustering.js +201 -0
  33. package/build/core/clustering.js.map +1 -0
  34. package/build/core/context-metadata.d.ts +50 -0
  35. package/build/core/context-metadata.d.ts.map +1 -0
  36. package/build/core/context-metadata.js +118 -0
  37. package/build/core/context-metadata.js.map +1 -0
  38. package/build/core/data-dir.d.ts +5 -0
  39. package/build/core/data-dir.d.ts.map +1 -0
  40. package/build/core/data-dir.js +61 -0
  41. package/build/core/data-dir.js.map +1 -0
  42. package/build/core/db-native.d.ts +28 -0
  43. package/build/core/db-native.d.ts.map +1 -0
  44. package/build/core/db-native.js +120 -0
  45. package/build/core/db-native.js.map +1 -0
  46. package/build/core/db.d.ts +294 -0
  47. package/build/core/db.d.ts.map +1 -0
  48. package/build/core/db.js +1047 -0
  49. package/build/core/db.js.map +1 -0
  50. package/build/core/doctor.d.ts +13 -0
  51. package/build/core/doctor.d.ts.map +1 -0
  52. package/build/core/doctor.js +55 -0
  53. package/build/core/doctor.js.map +1 -0
  54. package/build/core/efficiency.d.ts +16 -0
  55. package/build/core/efficiency.d.ts.map +1 -0
  56. package/build/core/efficiency.js +170 -0
  57. package/build/core/efficiency.js.map +1 -0
  58. package/build/core/embedding-tracker.d.ts +25 -0
  59. package/build/core/embedding-tracker.d.ts.map +1 -0
  60. package/build/core/embedding-tracker.js +228 -0
  61. package/build/core/embedding-tracker.js.map +1 -0
  62. package/build/core/embeddings.d.ts +90 -0
  63. package/build/core/embeddings.d.ts.map +1 -0
  64. package/build/core/embeddings.js +693 -0
  65. package/build/core/embeddings.js.map +1 -0
  66. package/build/core/evidence-state.d.ts +42 -0
  67. package/build/core/evidence-state.d.ts.map +1 -0
  68. package/build/core/evidence-state.js +153 -0
  69. package/build/core/evidence-state.js.map +1 -0
  70. package/build/core/extractor-stamp.d.ts +10 -0
  71. package/build/core/extractor-stamp.d.ts.map +1 -0
  72. package/build/core/extractor-stamp.js +51 -0
  73. package/build/core/extractor-stamp.js.map +1 -0
  74. package/build/core/feature-brief-cache.d.ts +37 -0
  75. package/build/core/feature-brief-cache.d.ts.map +1 -0
  76. package/build/core/feature-brief-cache.js +100 -0
  77. package/build/core/feature-brief-cache.js.map +1 -0
  78. package/build/core/file-fingerprint.d.ts +15 -0
  79. package/build/core/file-fingerprint.d.ts.map +1 -0
  80. package/build/core/file-fingerprint.js +24 -0
  81. package/build/core/file-fingerprint.js.map +1 -0
  82. package/build/core/graph-analytics.d.ts +46 -0
  83. package/build/core/graph-analytics.d.ts.map +1 -0
  84. package/build/core/graph-analytics.js +371 -0
  85. package/build/core/graph-analytics.js.map +1 -0
  86. package/build/core/hub.d.ts +23 -0
  87. package/build/core/hub.d.ts.map +1 -0
  88. package/build/core/hub.js +123 -0
  89. package/build/core/hub.js.map +1 -0
  90. package/build/core/ignore-dirs.d.ts +7 -0
  91. package/build/core/ignore-dirs.d.ts.map +1 -0
  92. package/build/core/ignore-dirs.js +84 -0
  93. package/build/core/ignore-dirs.js.map +1 -0
  94. package/build/core/index-freshness.d.ts +15 -0
  95. package/build/core/index-freshness.d.ts.map +1 -0
  96. package/build/core/index-freshness.js +96 -0
  97. package/build/core/index-freshness.js.map +1 -0
  98. package/build/core/index-reconcile.d.ts +28 -0
  99. package/build/core/index-reconcile.d.ts.map +1 -0
  100. package/build/core/index-reconcile.js +129 -0
  101. package/build/core/index-reconcile.js.map +1 -0
  102. package/build/core/local-daemon.d.ts +5 -0
  103. package/build/core/local-daemon.d.ts.map +1 -0
  104. package/build/core/local-daemon.js +282 -0
  105. package/build/core/local-daemon.js.map +1 -0
  106. package/build/core/memory-graph.d.ts +68 -0
  107. package/build/core/memory-graph.d.ts.map +1 -0
  108. package/build/core/memory-graph.js +152 -0
  109. package/build/core/memory-graph.js.map +1 -0
  110. package/build/core/native-repair.d.ts +12 -0
  111. package/build/core/native-repair.d.ts.map +1 -0
  112. package/build/core/native-repair.js +167 -0
  113. package/build/core/native-repair.js.map +1 -0
  114. package/build/core/native-runtime.d.ts +12 -0
  115. package/build/core/native-runtime.d.ts.map +1 -0
  116. package/build/core/native-runtime.js +38 -0
  117. package/build/core/native-runtime.js.map +1 -0
  118. package/build/core/pagerank.d.ts +29 -0
  119. package/build/core/pagerank.d.ts.map +1 -0
  120. package/build/core/pagerank.js +90 -0
  121. package/build/core/pagerank.js.map +1 -0
  122. package/build/core/parser-process.d.ts +21 -0
  123. package/build/core/parser-process.d.ts.map +1 -0
  124. package/build/core/parser-process.js +103 -0
  125. package/build/core/parser-process.js.map +1 -0
  126. package/build/core/parser-worker.d.ts +2 -0
  127. package/build/core/parser-worker.d.ts.map +1 -0
  128. package/build/core/parser-worker.js +17 -0
  129. package/build/core/parser-worker.js.map +1 -0
  130. package/build/core/parser.d.ts +66 -0
  131. package/build/core/parser.d.ts.map +1 -0
  132. package/build/core/parser.js +750 -0
  133. package/build/core/parser.js.map +1 -0
  134. package/build/core/path-guard.d.ts +6 -0
  135. package/build/core/path-guard.d.ts.map +1 -0
  136. package/build/core/path-guard.js +55 -0
  137. package/build/core/path-guard.js.map +1 -0
  138. package/build/core/process-lifecycle.d.ts +30 -0
  139. package/build/core/process-lifecycle.d.ts.map +1 -0
  140. package/build/core/process-lifecycle.js +129 -0
  141. package/build/core/process-lifecycle.js.map +1 -0
  142. package/build/core/project-config.d.ts +83 -0
  143. package/build/core/project-config.d.ts.map +1 -0
  144. package/build/core/project-config.js +302 -0
  145. package/build/core/project-config.js.map +1 -0
  146. package/build/core/project-graph.d.ts +69 -0
  147. package/build/core/project-graph.d.ts.map +1 -0
  148. package/build/core/project-graph.js +874 -0
  149. package/build/core/project-graph.js.map +1 -0
  150. package/build/core/provider-config.d.ts +15 -0
  151. package/build/core/provider-config.d.ts.map +1 -0
  152. package/build/core/provider-config.js +67 -0
  153. package/build/core/provider-config.js.map +1 -0
  154. package/build/core/provider-usage.d.ts +21 -0
  155. package/build/core/provider-usage.d.ts.map +1 -0
  156. package/build/core/provider-usage.js +52 -0
  157. package/build/core/provider-usage.js.map +1 -0
  158. package/build/core/python-language-server.d.ts +23 -0
  159. package/build/core/python-language-server.d.ts.map +1 -0
  160. package/build/core/python-language-server.js +217 -0
  161. package/build/core/python-language-server.js.map +1 -0
  162. package/build/core/python-runtime-identity.d.ts +3 -0
  163. package/build/core/python-runtime-identity.d.ts.map +1 -0
  164. package/build/core/python-runtime-identity.js +53 -0
  165. package/build/core/python-runtime-identity.js.map +1 -0
  166. package/build/core/reconcile-scheduler.d.ts +20 -0
  167. package/build/core/reconcile-scheduler.d.ts.map +1 -0
  168. package/build/core/reconcile-scheduler.js +58 -0
  169. package/build/core/reconcile-scheduler.js.map +1 -0
  170. package/build/core/request-context.d.ts +7 -0
  171. package/build/core/request-context.d.ts.map +1 -0
  172. package/build/core/request-context.js +17 -0
  173. package/build/core/request-context.js.map +1 -0
  174. package/build/core/request-root.d.ts +19 -0
  175. package/build/core/request-root.d.ts.map +1 -0
  176. package/build/core/request-root.js +26 -0
  177. package/build/core/request-root.js.map +1 -0
  178. package/build/core/root-guard.d.ts +9 -0
  179. package/build/core/root-guard.d.ts.map +1 -0
  180. package/build/core/root-guard.js +64 -0
  181. package/build/core/root-guard.js.map +1 -0
  182. package/build/core/roots-detect.d.ts +17 -0
  183. package/build/core/roots-detect.d.ts.map +1 -0
  184. package/build/core/roots-detect.js +63 -0
  185. package/build/core/roots-detect.js.map +1 -0
  186. package/build/core/runtime-session.d.ts +5 -0
  187. package/build/core/runtime-session.d.ts.map +1 -0
  188. package/build/core/runtime-session.js +10 -0
  189. package/build/core/runtime-session.js.map +1 -0
  190. package/build/core/scip-index.d.ts +71 -0
  191. package/build/core/scip-index.d.ts.map +1 -0
  192. package/build/core/scip-index.js +343 -0
  193. package/build/core/scip-index.js.map +1 -0
  194. package/build/core/semantic-diff.d.ts +32 -0
  195. package/build/core/semantic-diff.d.ts.map +1 -0
  196. package/build/core/semantic-diff.js +259 -0
  197. package/build/core/semantic-diff.js.map +1 -0
  198. package/build/core/source-context.d.ts +3 -0
  199. package/build/core/source-context.d.ts.map +1 -0
  200. package/build/core/source-context.js +86 -0
  201. package/build/core/source-context.js.map +1 -0
  202. package/build/core/source-mask.d.ts +8 -0
  203. package/build/core/source-mask.d.ts.map +1 -0
  204. package/build/core/source-mask.js +156 -0
  205. package/build/core/source-mask.js.map +1 -0
  206. package/build/core/source-mutation.d.ts +16 -0
  207. package/build/core/source-mutation.d.ts.map +1 -0
  208. package/build/core/source-mutation.js +193 -0
  209. package/build/core/source-mutation.js.map +1 -0
  210. package/build/core/sql-schema.d.ts +59 -0
  211. package/build/core/sql-schema.d.ts.map +1 -0
  212. package/build/core/sql-schema.js +218 -0
  213. package/build/core/sql-schema.js.map +1 -0
  214. package/build/core/startup-health.d.ts +40 -0
  215. package/build/core/startup-health.d.ts.map +1 -0
  216. package/build/core/startup-health.js +132 -0
  217. package/build/core/startup-health.js.map +1 -0
  218. package/build/core/team-ledger.d.ts +60 -0
  219. package/build/core/team-ledger.d.ts.map +1 -0
  220. package/build/core/team-ledger.js +171 -0
  221. package/build/core/team-ledger.js.map +1 -0
  222. package/build/core/test-impact.d.ts +23 -0
  223. package/build/core/test-impact.d.ts.map +1 -0
  224. package/build/core/test-impact.js +131 -0
  225. package/build/core/test-impact.js.map +1 -0
  226. package/build/core/tool-metrics.d.ts +29 -0
  227. package/build/core/tool-metrics.d.ts.map +1 -0
  228. package/build/core/tool-metrics.js +74 -0
  229. package/build/core/tool-metrics.js.map +1 -0
  230. package/build/core/tool-profile.d.ts +12 -0
  231. package/build/core/tool-profile.d.ts.map +1 -0
  232. package/build/core/tool-profile.js +102 -0
  233. package/build/core/tool-profile.js.map +1 -0
  234. package/build/core/tool-trace.d.ts +8 -0
  235. package/build/core/tool-trace.d.ts.map +1 -0
  236. package/build/core/tool-trace.js +70 -0
  237. package/build/core/tool-trace.js.map +1 -0
  238. package/build/core/tree-sitter-runtime.d.ts +20 -0
  239. package/build/core/tree-sitter-runtime.d.ts.map +1 -0
  240. package/build/core/tree-sitter-runtime.js +324 -0
  241. package/build/core/tree-sitter-runtime.js.map +1 -0
  242. package/build/core/tree-sitter.d.ts +6 -0
  243. package/build/core/tree-sitter.d.ts.map +1 -0
  244. package/build/core/tree-sitter.js +24 -0
  245. package/build/core/tree-sitter.js.map +1 -0
  246. package/build/core/typescript-reference-process.d.ts +30 -0
  247. package/build/core/typescript-reference-process.d.ts.map +1 -0
  248. package/build/core/typescript-reference-process.js +124 -0
  249. package/build/core/typescript-reference-process.js.map +1 -0
  250. package/build/core/typescript-reference-worker.d.ts +2 -0
  251. package/build/core/typescript-reference-worker.d.ts.map +1 -0
  252. package/build/core/typescript-reference-worker.js +14 -0
  253. package/build/core/typescript-reference-worker.js.map +1 -0
  254. package/build/core/typescript-references.d.ts +71 -0
  255. package/build/core/typescript-references.d.ts.map +1 -0
  256. package/build/core/typescript-references.js +392 -0
  257. package/build/core/typescript-references.js.map +1 -0
  258. package/build/core/typescript-skeleton.d.ts +5 -0
  259. package/build/core/typescript-skeleton.d.ts.map +1 -0
  260. package/build/core/typescript-skeleton.js +49 -0
  261. package/build/core/typescript-skeleton.js.map +1 -0
  262. package/build/core/walker.d.ts +16 -0
  263. package/build/core/walker.d.ts.map +1 -0
  264. package/build/core/walker.js +152 -0
  265. package/build/core/walker.js.map +1 -0
  266. package/build/core/workspace-router.d.ts +28 -0
  267. package/build/core/workspace-router.d.ts.map +1 -0
  268. package/build/core/workspace-router.js +93 -0
  269. package/build/core/workspace-router.js.map +1 -0
  270. package/build/core/worktree-gc.d.ts +16 -0
  271. package/build/core/worktree-gc.d.ts.map +1 -0
  272. package/build/core/worktree-gc.js +69 -0
  273. package/build/core/worktree-gc.js.map +1 -0
  274. package/build/core/worktree-overlay.d.ts +22 -0
  275. package/build/core/worktree-overlay.d.ts.map +1 -0
  276. package/build/core/worktree-overlay.js +84 -0
  277. package/build/core/worktree-overlay.js.map +1 -0
  278. package/build/core/worktree-root-guard.d.ts +8 -0
  279. package/build/core/worktree-root-guard.d.ts.map +1 -0
  280. package/build/core/worktree-root-guard.js +82 -0
  281. package/build/core/worktree-root-guard.js.map +1 -0
  282. package/build/core/worktree-seed.d.ts +14 -0
  283. package/build/core/worktree-seed.d.ts.map +1 -0
  284. package/build/core/worktree-seed.js +98 -0
  285. package/build/core/worktree-seed.js.map +1 -0
  286. package/build/git/shadow.d.ts +40 -0
  287. package/build/git/shadow.d.ts.map +1 -0
  288. package/build/git/shadow.js +298 -0
  289. package/build/git/shadow.js.map +1 -0
  290. package/build/index.d.ts +3 -0
  291. package/build/index.d.ts.map +1 -0
  292. package/build/index.js +634 -0
  293. package/build/index.js.map +1 -0
  294. package/build/tools/agentic-context.d.ts +86 -0
  295. package/build/tools/agentic-context.d.ts.map +1 -0
  296. package/build/tools/agentic-context.js +1546 -0
  297. package/build/tools/agentic-context.js.map +1 -0
  298. package/build/tools/blast-radius.d.ts +24 -0
  299. package/build/tools/blast-radius.d.ts.map +1 -0
  300. package/build/tools/blast-radius.js +231 -0
  301. package/build/tools/blast-radius.js.map +1 -0
  302. package/build/tools/changed-since.d.ts +7 -0
  303. package/build/tools/changed-since.d.ts.map +1 -0
  304. package/build/tools/changed-since.js +68 -0
  305. package/build/tools/changed-since.js.map +1 -0
  306. package/build/tools/compiler-actions.d.ts +26 -0
  307. package/build/tools/compiler-actions.d.ts.map +1 -0
  308. package/build/tools/compiler-actions.js +121 -0
  309. package/build/tools/compiler-actions.js.map +1 -0
  310. package/build/tools/context-tree.d.ts +9 -0
  311. package/build/tools/context-tree.d.ts.map +1 -0
  312. package/build/tools/context-tree.js +131 -0
  313. package/build/tools/context-tree.js.map +1 -0
  314. package/build/tools/context.d.ts +37 -0
  315. package/build/tools/context.d.ts.map +1 -0
  316. package/build/tools/context.js +800 -0
  317. package/build/tools/context.js.map +1 -0
  318. package/build/tools/diff.d.ts +9 -0
  319. package/build/tools/diff.d.ts.map +1 -0
  320. package/build/tools/diff.js +176 -0
  321. package/build/tools/diff.js.map +1 -0
  322. package/build/tools/directory-prior.d.ts +16 -0
  323. package/build/tools/directory-prior.d.ts.map +1 -0
  324. package/build/tools/directory-prior.js +121 -0
  325. package/build/tools/directory-prior.js.map +1 -0
  326. package/build/tools/discovery-documents.d.ts +11 -0
  327. package/build/tools/discovery-documents.d.ts.map +1 -0
  328. package/build/tools/discovery-documents.js +71 -0
  329. package/build/tools/discovery-documents.js.map +1 -0
  330. package/build/tools/discovery-hints.d.ts +25 -0
  331. package/build/tools/discovery-hints.d.ts.map +1 -0
  332. package/build/tools/discovery-hints.js +329 -0
  333. package/build/tools/discovery-hints.js.map +1 -0
  334. package/build/tools/efficiency-report.d.ts +13 -0
  335. package/build/tools/efficiency-report.d.ts.map +1 -0
  336. package/build/tools/efficiency-report.js +78 -0
  337. package/build/tools/efficiency-report.js.map +1 -0
  338. package/build/tools/evidence-retrieval.d.ts +33 -0
  339. package/build/tools/evidence-retrieval.d.ts.map +1 -0
  340. package/build/tools/evidence-retrieval.js +200 -0
  341. package/build/tools/evidence-retrieval.js.map +1 -0
  342. package/build/tools/exact-references.d.ts +10 -0
  343. package/build/tools/exact-references.d.ts.map +1 -0
  344. package/build/tools/exact-references.js +351 -0
  345. package/build/tools/exact-references.js.map +1 -0
  346. package/build/tools/explain.d.ts +14 -0
  347. package/build/tools/explain.d.ts.map +1 -0
  348. package/build/tools/explain.js +370 -0
  349. package/build/tools/explain.js.map +1 -0
  350. package/build/tools/feature-brief.d.ts +7 -0
  351. package/build/tools/feature-brief.d.ts.map +1 -0
  352. package/build/tools/feature-brief.js +89 -0
  353. package/build/tools/feature-brief.js.map +1 -0
  354. package/build/tools/feature-hub.d.ts +15 -0
  355. package/build/tools/feature-hub.d.ts.map +1 -0
  356. package/build/tools/feature-hub.js +404 -0
  357. package/build/tools/feature-hub.js.map +1 -0
  358. package/build/tools/file-skeleton.d.ts +7 -0
  359. package/build/tools/file-skeleton.d.ts.map +1 -0
  360. package/build/tools/file-skeleton.js +190 -0
  361. package/build/tools/file-skeleton.js.map +1 -0
  362. package/build/tools/grep.d.ts +25 -0
  363. package/build/tools/grep.d.ts.map +1 -0
  364. package/build/tools/grep.js +341 -0
  365. package/build/tools/grep.js.map +1 -0
  366. package/build/tools/impact-delta.d.ts +7 -0
  367. package/build/tools/impact-delta.d.ts.map +1 -0
  368. package/build/tools/impact-delta.js +102 -0
  369. package/build/tools/impact-delta.js.map +1 -0
  370. package/build/tools/memory-tools.d.ts +69 -0
  371. package/build/tools/memory-tools.d.ts.map +1 -0
  372. package/build/tools/memory-tools.js +366 -0
  373. package/build/tools/memory-tools.js.map +1 -0
  374. package/build/tools/planning-helpers.d.ts +26 -0
  375. package/build/tools/planning-helpers.d.ts.map +1 -0
  376. package/build/tools/planning-helpers.js +269 -0
  377. package/build/tools/planning-helpers.js.map +1 -0
  378. package/build/tools/project-graph.d.ts +19 -0
  379. package/build/tools/project-graph.d.ts.map +1 -0
  380. package/build/tools/project-graph.js +259 -0
  381. package/build/tools/project-graph.js.map +1 -0
  382. package/build/tools/propose-commit.d.ts +9 -0
  383. package/build/tools/propose-commit.d.ts.map +1 -0
  384. package/build/tools/propose-commit.js +156 -0
  385. package/build/tools/propose-commit.js.map +1 -0
  386. package/build/tools/register-tools.d.ts +18 -0
  387. package/build/tools/register-tools.d.ts.map +1 -0
  388. package/build/tools/register-tools.js +1131 -0
  389. package/build/tools/register-tools.js.map +1 -0
  390. package/build/tools/reindex.d.ts +76 -0
  391. package/build/tools/reindex.d.ts.map +1 -0
  392. package/build/tools/reindex.js +871 -0
  393. package/build/tools/reindex.js.map +1 -0
  394. package/build/tools/related.d.ts +6 -0
  395. package/build/tools/related.d.ts.map +1 -0
  396. package/build/tools/related.js +143 -0
  397. package/build/tools/related.js.map +1 -0
  398. package/build/tools/repo-map.d.ts +59 -0
  399. package/build/tools/repo-map.d.ts.map +1 -0
  400. package/build/tools/repo-map.js +270 -0
  401. package/build/tools/repo-map.js.map +1 -0
  402. package/build/tools/resolve-symbol.d.ts +41 -0
  403. package/build/tools/resolve-symbol.d.ts.map +1 -0
  404. package/build/tools/resolve-symbol.js +250 -0
  405. package/build/tools/resolve-symbol.js.map +1 -0
  406. package/build/tools/retrieval-helpers.d.ts +35 -0
  407. package/build/tools/retrieval-helpers.d.ts.map +1 -0
  408. package/build/tools/retrieval-helpers.js +302 -0
  409. package/build/tools/retrieval-helpers.js.map +1 -0
  410. package/build/tools/scip-index.d.ts +12 -0
  411. package/build/tools/scip-index.d.ts.map +1 -0
  412. package/build/tools/scip-index.js +66 -0
  413. package/build/tools/scip-index.js.map +1 -0
  414. package/build/tools/scoped-discovery.d.ts +7 -0
  415. package/build/tools/scoped-discovery.d.ts.map +1 -0
  416. package/build/tools/scoped-discovery.js +89 -0
  417. package/build/tools/scoped-discovery.js.map +1 -0
  418. package/build/tools/search.d.ts +62 -0
  419. package/build/tools/search.d.ts.map +1 -0
  420. package/build/tools/search.js +419 -0
  421. package/build/tools/search.js.map +1 -0
  422. package/build/tools/semantic-diff.d.ts +7 -0
  423. package/build/tools/semantic-diff.d.ts.map +1 -0
  424. package/build/tools/semantic-diff.js +45 -0
  425. package/build/tools/semantic-diff.js.map +1 -0
  426. package/build/tools/semantic-identifiers.d.ts +51 -0
  427. package/build/tools/semantic-identifiers.d.ts.map +1 -0
  428. package/build/tools/semantic-identifiers.js +522 -0
  429. package/build/tools/semantic-identifiers.js.map +1 -0
  430. package/build/tools/semantic-navigate.d.ts +18 -0
  431. package/build/tools/semantic-navigate.d.ts.map +1 -0
  432. package/build/tools/semantic-navigate.js +413 -0
  433. package/build/tools/semantic-navigate.js.map +1 -0
  434. package/build/tools/semantic-search.d.ts +30 -0
  435. package/build/tools/semantic-search.d.ts.map +1 -0
  436. package/build/tools/semantic-search.js +466 -0
  437. package/build/tools/semantic-search.js.map +1 -0
  438. package/build/tools/sql-schema.d.ts +23 -0
  439. package/build/tools/sql-schema.d.ts.map +1 -0
  440. package/build/tools/sql-schema.js +155 -0
  441. package/build/tools/sql-schema.js.map +1 -0
  442. package/build/tools/static-analysis.d.ts +7 -0
  443. package/build/tools/static-analysis.d.ts.map +1 -0
  444. package/build/tools/static-analysis.js +331 -0
  445. package/build/tools/static-analysis.js.map +1 -0
  446. package/build/tools/status.d.ts +74 -0
  447. package/build/tools/status.d.ts.map +1 -0
  448. package/build/tools/status.js +227 -0
  449. package/build/tools/status.js.map +1 -0
  450. package/build/tools/symbolic-edit.d.ts +57 -0
  451. package/build/tools/symbolic-edit.d.ts.map +1 -0
  452. package/build/tools/symbolic-edit.js +500 -0
  453. package/build/tools/symbolic-edit.js.map +1 -0
  454. package/build/tools/test-impact.d.ts +7 -0
  455. package/build/tools/test-impact.d.ts.map +1 -0
  456. package/build/tools/test-impact.js +34 -0
  457. package/build/tools/test-impact.js.map +1 -0
  458. package/build/tools/test-map.d.ts +8 -0
  459. package/build/tools/test-map.d.ts.map +1 -0
  460. package/build/tools/test-map.js +75 -0
  461. package/build/tools/test-map.js.map +1 -0
  462. package/docs/README.md +35 -0
  463. package/docs/architecture.md +35 -0
  464. package/docs/configuration.md +207 -0
  465. package/docs/maintenance.md +77 -0
  466. package/package.json +80 -4
@@ -0,0 +1,329 @@
1
+ import { basename, relative } from "node:path";
2
+ import { searchTerms } from "../core/embeddings.js";
3
+ import { isTestEvidence, isTestFile } from "./retrieval-helpers.js";
4
+ const BACKEND_DIRECTORY = /(?:^|\/)(?:api|backend|server|services?|workers?|scripts?)(?:\/|$)/i;
5
+ export const SCOPE_CLAUSE_BOUNDARY = /;|[.!?](?=\s|$)|(?:^|\s)(?:but|however|instead)(?=\s|$)|(?:,\s*|\s+(?:and|then)\s+)(?=(?:include|including|show|find|read|open|locate|search|review|inspect|in|under|inside|within)\b)/i;
6
+ // Ambiguous exclusions must introduce evidence, not behavior such as skipping comments.
7
+ const EXCLUDED_FILE_CLAUSE = /(?:^|[\s(])(?:exclude|excluding|ignore|ignoring|(?:(?:do\s+not|don't)\s+(?:read|include|open|show|find|locate|search|review|inspect)|skip(?:ping)?|omit(?:ting)?|avoid(?:ing)?|without)(?=\s+(?:(?:the|any|relevant|existing|historical|archived?|old)\s+)*(?:tests?|testing|fixtures?|mocks?|regressions?|coverage|assert|locales?|translations?|translate|i18n|l10n|locali[sz](?:ation|e)|wording|copy|strings?|messages?|lockfile|lock\s+file|integrity|resolved|transitive|dependencies|dependency|readme|roadmap|handoff|readiness|docs?|documentation|documents?|notes?|history|blog\s+(?:posts?|articles?)|reports?|plans?|specs?|specifications?|(?:task|design|implementation)\s+(?:plans?|specs?|specifications?)|(?:product|project|repository|api|setup|developer|user|security|compliance)\s+docs|(?:project|repository)\s+(?:instructions|status)|(?:repo(?:sitory)?|project|codebase)\s+(?:orientation|overview)|(?:orientation|overview)\s+(?:(?:of|to|the)\s+)*(?:repo(?:sitory)?|project|codebase)|(?:status|qa|audit)\s+(?:documents?|reports?)|agent\s+brief|[\w@./-]+\.[A-Za-z][\w]*)(?=\s|[;,.!?]|$)))(?=\s|:|$)/i;
8
+ /** A negative read is neither a requested file nor an instruction to read whole files. */
9
+ export function positiveDiscoveryQuery(query) {
10
+ return query.split(SCOPE_CLAUSE_BOUNDARY).map(clause => clause.split(EXCLUDED_FILE_CLAUSE)[0]).join(" ");
11
+ }
12
+ /** Keep explicit phrases and compound keys intact alongside prose keywords. */
13
+ export function queryLiterals(query) {
14
+ const quoted = [...query.matchAll(/(["'`])([^"'`\n]{2,200})\1/g)].map(match => match[2]);
15
+ const keys = query.match(/\b[A-Za-z][\w$]*(?:[._][A-Za-z][\w$]*)+\b/g) ?? [];
16
+ return [...new Set([...quoted, ...keys].map(text => text.normalize("NFC").toLowerCase()))].slice(0, 8);
17
+ }
18
+ /** Secondary evidence stays available, but must not crowd out implementations. */
19
+ export function discoveryPathWeight(query, path, exactSymbol = false, documentHeadings) {
20
+ if (/\.(?:md|mdx|rst|txt)$/i.test(path) && /(?:^|\/)(?:blog|posts)\//i.test(path)
21
+ && query.split(SCOPE_CLAUSE_BOUNDARY).some(clause => {
22
+ const negative = EXCLUDED_FILE_CLAUSE.exec(clause);
23
+ return negative && /\bblog\s+(?:posts?|articles?)\b/i.test(clause.slice(negative.index));
24
+ }))
25
+ return 0;
26
+ const documentStem = /\.(?:md|mdx|rst|txt)$/i.test(path) ? basename(path).replace(/\.[^.]+$/, "").toLowerCase() : undefined;
27
+ let mentionWeight;
28
+ for (const match of query.matchAll(/[\w@./-]+\.[A-Za-z][\w]*(?::\d+(?:-\d+)?)?|\b(?:readme|roadmap|handoff|readiness)\b/gi)) {
29
+ const token = match[0].replace(/:\d+(?:-\d+)?$/, "").replace(/^\.\//, "");
30
+ if (token.startsWith("/") || !(token === path || (!token.includes("/") && token === basename(path)) || path.endsWith(`/${token}`)
31
+ || token.toLowerCase() === documentStem))
32
+ continue;
33
+ const clause = query.slice(0, match.index + match[0].length).split(SCOPE_CLAUSE_BOUNDARY).at(-1) ?? "";
34
+ const negative = EXCLUDED_FILE_CLAUSE.test(clause);
35
+ // A repeated title alone cannot undo an earlier exclusion.
36
+ if (mentionWeight === 0 && !negative && token.toLowerCase() === documentStem
37
+ && !/\b(?:include|including|show|find|read|open|locate|search|review|inspect)\s+(?:(?:the|any|relevant|existing|historical|archived?|old)\s+)*$/i.test(clause.slice(0, -match[0].length)))
38
+ continue;
39
+ mentionWeight = negative ? 0 : 1;
40
+ }
41
+ if (mentionWeight !== undefined)
42
+ return mentionWeight;
43
+ if (documentStem !== undefined) {
44
+ const labels = `${path} ${documentHeadings ?? ""}`.replace(/[_-]/g, " ");
45
+ const excluded = new Set();
46
+ for (const clause of query.split(SCOPE_CLAUSE_BOUNDARY)) {
47
+ const negative = EXCLUDED_FILE_CLAUSE.exec(clause);
48
+ const action = negative ?? /\b(?:include|including|show|find|read|open|locate|search|review|inspect)\b/i.exec(clause);
49
+ if (!action)
50
+ continue;
51
+ const object = clause.slice(action.index + action[0].length);
52
+ if (/\b(?:historical|archived?|old)\b/i.test(object) && !/\b(?:archive[ds]?|historical|history|old)\b/i.test(labels))
53
+ continue;
54
+ for (const match of object.matchAll(/(?:^|,|\band\b)\s*(?:(?:the|any|relevant|existing|historical|archived?|old)\s+)*(?:(?:task|design|implementation)\s+)?(docs?|documentation|documents?|plans?|specs?|specifications?)\b(?![/.])/gi)) {
55
+ const category = /^doc/i.test(match[1]) ? "documents" : /^plan/i.test(match[1]) ? "plans" : "specifications";
56
+ const matches = category === "documents" || (category === "plans" ? /\bplans?\b/i : /\b(?:specs?|specifications?)\b/i).test(labels);
57
+ // A later category request may match an as-yet unread heading. Keep
58
+ // that candidate until the caller supplies its actual headings.
59
+ if (!matches && (negative || documentHeadings !== undefined))
60
+ continue;
61
+ if (negative)
62
+ excluded.add(category);
63
+ else {
64
+ excluded.delete(category);
65
+ excluded.delete("documents");
66
+ }
67
+ }
68
+ }
69
+ if (excluded.size)
70
+ return 0;
71
+ }
72
+ const excludesTests = query.split(SCOPE_CLAUSE_BOUNDARY).some(clause => {
73
+ const exclusion = EXCLUDED_FILE_CLAUSE.exec(clause);
74
+ return exclusion && /\b(?:tests?|testing|specs?|fixtures?|mocks?|regressions?|coverage|assert)\b/i.test(clause.slice(exclusion.index).replace(/[\w@./-]+\.[A-Za-z][\w]*/g, ""));
75
+ });
76
+ query = positiveDiscoveryQuery(query);
77
+ if (query.toLowerCase().includes(path.toLowerCase()))
78
+ return 1;
79
+ if (/\.(?:md|mdx|rst|txt)$/i.test(path) && /(?:^|\/)(?:archive[ds]?|historical|history)(?:\/|$)/i.test(path)
80
+ && !/\b(?:archive[ds]?|historical|history)\b|\bold\s+(?:(?:task|design|implementation|product|project|repository|api|setup|developer|user|security|compliance)\s+)?(?:docs?|documentation|documents?|readme|roadmap|handoff|notes?|reports?|plans?|specs?|specifications?)\b/i.test(query))
81
+ return .25;
82
+ if (isLockfile(path) && !wantsLockfile(query))
83
+ return .15;
84
+ if ((isTestEvidence(path) || /(?:^|\/)(?:tests?|__tests__|fixtures?)(?:\/|$)/i.test(path))
85
+ && (!exactSymbol || excludesTests)
86
+ && !/\b(?:tests?|testing|specs?|fixtures?|mocks?|regressions?|coverage|assert)\b/i.test(query))
87
+ return .2;
88
+ const locale = /(?:^|\/)(?:locales?|translations?|messages|i18n|l10n)(?:\/|\.)/i.test(path) && /\.(?:json|ya?ml|[cm]?[jt]sx?)$/i.test(path);
89
+ if (locale && !exactSymbol && !/\b(?:locales?|translations?|translate|i18n|l10n|locali[sz](?:ation|e)|wording|copy|strings?|messages?)\b/i.test(searchTerms(query).join(" ")))
90
+ return .2;
91
+ // Known report locations can repeat implementation terms without containing
92
+ // the implementation. An extension alone says nothing about that role: JSON
93
+ // configuration, Markdown content and CSV data can be primary source evidence.
94
+ const reportPath = /(?:^|\/)(?:reports|benchmark-results|test-results|coverage)\/|(?:^|\/)docs\/benchmarks\//i.test(path);
95
+ if (/\b(?:implementation|code|pipeline|source)\b/i.test(query)
96
+ && !/\b(?:report|reports|documentation|docs|results|dataset)\b/i.test(query)
97
+ && reportPath
98
+ && /\.(?:json|jsonl|md|csv)$/i.test(path))
99
+ return .35;
100
+ return 1;
101
+ }
102
+ /** A broad visual task should find renderers before incidental service prose. */
103
+ export function facetPathWeight(query, term, path) {
104
+ const prior = discoveryPathWeight(query, path);
105
+ const visualTerms = new Set(query.toLowerCase().match(/\b(?:visual|illustration|animation|layout|theme|accent|onboarding|ui)\b/g) ?? []);
106
+ // Preserve direct path/topic matches, including non-UI theme/config modules.
107
+ if (visualTerms.size >= 2 && !path.toLowerCase().includes(term) && /\.[jt]sx$/i.test(path))
108
+ return prior * 1.5;
109
+ return prior;
110
+ }
111
+ /** Hints select only known indexed paths; query text never becomes an unchecked read. */
112
+ export function mentionedFiles(root, query, files) {
113
+ const positive = positiveDiscoveryQuery(query);
114
+ const tokens = new Set((positive.match(/[\w@./-]+\.[A-Za-z][\w]*(?::\d+(?:-\d+)?)?/g) ?? [])
115
+ .map(token => token.replace(/:\d+(?:-\d+)?$/, "").replace(/^\.\//, "")));
116
+ // Uppercase runbook stems also name real documents; never invent a read path.
117
+ const stems = new Set(positive.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g) ?? []);
118
+ for (const file of files)
119
+ if (/\.(?:md|mdx|rst|txt)$/i.test(file.path) && stems.has(basename(file.path).replace(/\.[^.]+$/, "")))
120
+ tokens.add(file.path);
121
+ const paths = new Set(files.map(file => file.path));
122
+ const names = new Map();
123
+ for (const file of files) {
124
+ const name = basename(file.path);
125
+ names.set(name, names.has(name) ? null : file.path);
126
+ }
127
+ return [...new Set([...tokens].flatMap(token => {
128
+ const path = token.startsWith("/") ? relative(root, token) : token;
129
+ const suffixes = !token.startsWith("/") && token.includes("/") && !token.split("/").includes("..")
130
+ ? files.filter(file => file.path.endsWith(`/${token}`)) : [];
131
+ const match = paths.has(path) ? path : suffixes.length === 1 ? suffixes[0].path : names.get(token);
132
+ return match ? [match] : [];
133
+ }))];
134
+ }
135
+ /** Require both a UI scope and a broad navigation/orientation request. */
136
+ export function isUiOrientationQuery(query) {
137
+ query = positiveDiscoveryQuery(query);
138
+ const uiScope = /\b(?:ui|ux|frontend|front.end|user.facing|web app|website)\b/i.test(query);
139
+ // Routes/navigation/audit alone also occur in narrow coding requests. Only
140
+ // explicit overview language or a request to inventory product surfaces
141
+ // authorizes structural previews ahead of the ranked implementation.
142
+ const broad = /\b(?:orient|orientation|overview)\b/i.test(query)
143
+ || /\b(?:map|survey)\s+(?:(?:out|the|our|this|all)\s+)*(?:ui|ux|frontend|front.end|app(?:lication)?|web app)\s+(?:structure|architecture|navigation|routes|screens|components)\b/i.test(query)
144
+ || /\b(?:find|identify|list|show)\s+(?:(?:the|our|this)\s+)?(?:main|primary|key|all|product)\s+(?:(?:product|ui|ux|frontend|front.end|user.facing|web|app(?:lication)?|user)\s+)*(?:surfaces|screens|routes|components|journey)\b/i.test(query);
145
+ return uiScope && broad;
146
+ }
147
+ export function isOrientationQuery(query) {
148
+ query = positiveDiscoveryQuery(query);
149
+ return isUiOrientationQuery(query) || /\b(?:orient(?:ation)?|overview|understand)\b.*\b(?:repo(?:sitory)?|project|codebase)\b|\b(?:repo(?:sitory)?|project|codebase)\s+(?:orientation|overview)\b/i.test(query);
150
+ }
151
+ export function orientationFiles(db, files, query) {
152
+ if (isUiOrientationQuery(query))
153
+ return uiOrientationFiles(db, files, query);
154
+ const code = files.filter(file => /\.(?:[cm]?[jt]sx?|py|rs|go|java|cs|rb)$/.test(file.path) && !isTestFile(file.path));
155
+ const imports = new Map(files.map(file => [file.id, db.getImportsFrom(file.id)]));
156
+ const incoming = new Map();
157
+ for (const rows of imports.values())
158
+ for (const row of rows) {
159
+ if (row.target_file_id !== null)
160
+ incoming.set(row.target_file_id, (incoming.get(row.target_file_id) ?? 0) + 1);
161
+ }
162
+ const rank = (file) => (incoming.get(file.id) ?? 0) * 2 + imports.get(file.id).length;
163
+ const entry = code.filter(file => /(?:^|\/)(?:index|main|app|server|cli|__main__)\.[^/]+$/.test(file.path))
164
+ // At equal depth, a bootstrap with no callers is a stronger entry candidate
165
+ // than an imported app module, even if that module registers more imports.
166
+ .sort((a, b) => a.path.split("/").length - b.path.split("/").length
167
+ || (incoming.get(a.id) ?? 0) - (incoming.get(b.id) ?? 0)
168
+ || imports.get(b.id).length - imports.get(a.id).length || a.path.localeCompare(b.path))[0];
169
+ const hubs = code.filter(file => file !== entry).sort((a, b) => rank(b) - rank(a) || a.path.localeCompare(b.path));
170
+ // Include the leading hub's dependencies, not only ubiquitous utilities.
171
+ const hubDependencies = new Set(hubs[0] ? imports.get(hubs[0].id).map(row => row.target_file_id) : []);
172
+ const core = [...new Set([...hubs.slice(0, 1), ...hubs.filter(file => hubDependencies.has(file.id)).slice(0, 2), ...hubs])].slice(0, 3);
173
+ // The bootstrap also exposes architecture that shared utility rankings miss,
174
+ // such as a job service constructed beside the main client.
175
+ const entryDependencies = new Set(entry ? imports.get(entry.id).map(row => row.target_file_id) : []);
176
+ core.push(...hubs.filter(file => entryDependencies.has(file.id) && !core.includes(file)).slice(0, 2));
177
+ const selected = [
178
+ ...files.filter(file => /^(?:package.json|pyproject.toml|Cargo.toml|go.mod)$/.test(file.path)).slice(0, 1),
179
+ ...(entry ? [entry] : []), ...core,
180
+ ];
181
+ const ids = new Set(selected.map(file => file.id));
182
+ if (/\btests?\b/i.test(query)) {
183
+ const test = files.filter(file => isTestFile(file.path)).sort((a, b) => imports.get(b.id).filter(imp => ids.has(imp.target_file_id)).length - imports.get(a.id).filter(imp => ids.has(imp.target_file_id)).length || a.path.localeCompare(b.path))[0];
184
+ if (test)
185
+ selected.push(test);
186
+ }
187
+ const readme = files.find(file => /^readme\.(?:md|txt|rst)$/i.test(file.path));
188
+ if (readme)
189
+ selected.push(readme);
190
+ return [...new Set(selected.map(file => file.path))];
191
+ }
192
+ /** UI structure supplies candidates even when translated labels do not repeat
193
+ * English query terms. Import edges are heuristic, not resolved references. */
194
+ function uiOrientationFiles(db, files, query) {
195
+ const imports = new Map(files.map(file => [file.id, db.getImportsFrom(file.id)]));
196
+ let ui = files.filter(file => {
197
+ if (discoveryPathWeight(query, file.path) < 1)
198
+ return false;
199
+ if (BACKEND_DIRECTORY.test(file.path) || /\.server\.(?:[cm]?[jt]sx?|vue|svelte)$/i.test(file.path))
200
+ return false;
201
+ if (/\.(?:[jt]sx|vue|svelte)$/.test(file.path))
202
+ return true;
203
+ if (!/\.[cm]?[jt]s$/.test(file.path) || /\.d\.[cm]?ts$/.test(file.path))
204
+ return false;
205
+ const modules = imports.get(file.id).map(row => row.target_path);
206
+ const framework = modules.some(path => /^(?:@angular\/|react(?:-dom|-router(?:-dom)?)?(?:\/|$)|preact(?:\/|$)|lit(?:-element|-html)?(?:\/|$)|vue(?:\/|$)|svelte(?:\/|$)|solid-js(?:\/|$))/.test(path));
207
+ const uiPath = /(?:^|\/)(?:components?|pages?|screens?|views?|layouts?|navigation|client|frontend)(?:\/|$)|\.component\.[cm]?[jt]s$/i.test(file.path);
208
+ const entry = /^(?:app|main|router|routes|navigation)(?:\.[\w-]+)?\.[cm]?[jt]s$/i.test(basename(file.path));
209
+ const backend = modules.some(path => /^(?:express|fastify|koa|node:http)(?:\/|$)/.test(path));
210
+ return framework || uiPath || (entry && !backend);
211
+ });
212
+ const terms = new Set(searchTerms(query));
213
+ const appScopes = new Map();
214
+ for (const file of files) {
215
+ const match = file.path.match(/^(apps|packages)\/([^/]+)\//);
216
+ if (match)
217
+ appScopes.set(match[0], { container: match[1], name: match[2] });
218
+ }
219
+ const paths = (query.toLowerCase().match(/[\p{L}\p{N}_./@-]+/gu) ?? []).map(path => path.replace(/\.+$/, ""));
220
+ const explicitScopes = [...appScopes.keys()].filter(scope => {
221
+ const path = scope.toLowerCase(), bare = path.slice(0, -1);
222
+ return paths.some(token => token === bare || token.startsWith(path) || token.endsWith(`/${bare}`) || token.includes(`/${path}`));
223
+ });
224
+ // Prefer matching app names over shared-package names. An unrelated apps/
225
+ // entry must not prevent selecting a requested package-hosted application.
226
+ // Explicit paths can still select any package.
227
+ const genericNames = new Set(["ui", "ux", "shared", "common", "components"]);
228
+ const namedScopes = [...appScopes].filter(([, scope]) => {
229
+ // An unqualified "UI" request does not name a package called ui. Its
230
+ // explicit path remains available through explicitScopes above.
231
+ const words = searchTerms(scope.name).filter(word => !genericNames.has(word));
232
+ return words.length > 0 && words.every(word => terms.has(word));
233
+ }).map(([scope]) => scope);
234
+ // "Product frontend ... billing" names product as the application and billing
235
+ // as a feature. Prefer qualified application names over incidental topic words.
236
+ const qualifiedScopes = namedScopes.filter(scope => {
237
+ const name = searchTerms(appScopes.get(scope).name).filter(word => !genericNames.has(word))
238
+ .map(word => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\s_-]+");
239
+ const qualifier = "(?:frontend|front[- ]end|ui|ux|web\\s+app|apps?|applications?)";
240
+ return new RegExp(`(?<![\\p{L}\\p{N}_])${name}\\s+${qualifier}\\b|\\b(?:app|application)\\s+(?:(?:named|called)\\s+)?${name}(?![\\p{L}\\p{N}_])`, "iu").test(query);
241
+ });
242
+ const matchedScopes = qualifiedScopes.length ? qualifiedScopes : namedScopes;
243
+ const namedApps = matchedScopes.filter(scope => appScopes.get(scope).container === "apps");
244
+ const requestedScopes = explicitScopes.length ? explicitScopes : namedApps.length ? namedApps : matchedScopes;
245
+ if (requestedScopes.length)
246
+ ui = ui.filter(file => requestedScopes.some(scope => file.path.startsWith(scope)));
247
+ const ids = new Set(ui.map(file => file.id));
248
+ const incoming = new Map();
249
+ for (const file of ui)
250
+ for (const row of imports.get(file.id)) {
251
+ if (row.target_file_id !== null)
252
+ incoming.set(row.target_file_id, (incoming.get(row.target_file_id) ?? 0) + 1);
253
+ }
254
+ const overlap = (file) => searchTerms(basename(file.path)).filter(term => terms.has(term)).length;
255
+ // Prefer modules composing the UI. Ubiquitous leaf utilities/types can have
256
+ // many callers without explaining a screen, so bound their popularity bonus.
257
+ const rank = (file) => (imports.get(file.id) ?? []).filter(row => ids.has(row.target_file_id)).length * 2 + Math.min(4, incoming.get(file.id) ?? 0);
258
+ const sorted = [...ui].sort((a, b) => rank(b) - rank(a) || a.path.localeCompare(b.path));
259
+ const layouts = sorted.filter(file => /(?:^|\/)(?:_?layout|_app)\./i.test(file.path)).sort((a, b) => a.path.split("/").length - b.path.split("/").length || a.path.localeCompare(b.path)).slice(0, 1);
260
+ const routes = sorted.filter(file => /(?:^|\/)(?:page|index|app|main|router)\./i.test(file.path) && !layouts.includes(file)).slice(0, 2);
261
+ const navigation = sorted.filter(file => /(?:navigation|navbar|sidebar|app-shell)/i.test(basename(file.path))).slice(0, 2);
262
+ const hubs = sorted.filter(file => !layouts.includes(file) && !routes.includes(file)).slice(0, 2);
263
+ const topics = [];
264
+ // One popular feature must not occupy every feature slot. Prefer a direct
265
+ // basename match for each requested topic, then use structural rank as a tie.
266
+ for (const term of terms) {
267
+ const matches = ui.filter(file => searchTerms(basename(file.path)).includes(term));
268
+ matches.sort((a, b) => searchTerms(basename(a.path)).length - searchTerms(basename(b.path)).length || rank(b) - rank(a) || a.path.localeCompare(b.path));
269
+ if (matches[0] && !topics.includes(matches[0]))
270
+ topics.push(matches[0]);
271
+ }
272
+ // Reserve the entry/layout evidence before a long feature inventory fills
273
+ // the bounded candidate list, including when the response budget is small.
274
+ const selected = [...new Set([...layouts, ...routes, ...navigation, ...hubs, ...topics])].slice(0, 11);
275
+ if (/\b(?:styles?|tokens?|theme|css)\b/i.test(query)) {
276
+ const imported = new Set(selected.flatMap(file => (imports.get(file.id) ?? []).map(row => row.target_file_id)));
277
+ const scope = (path) => path.match(/^(?:apps|packages)\/[^/]+\//)?.[0] ?? "";
278
+ const scopes = new Set(selected.map(file => scope(file.path)));
279
+ const proximity = (file) => Math.max(0, ...selected.map(source => {
280
+ const a = file.path.split("/"), b = source.path.split("/");
281
+ let shared = 0;
282
+ while (shared < Math.min(a.length, b.length) - 1 && a[shared] === b[shared])
283
+ shared++;
284
+ return shared;
285
+ }));
286
+ const styles = files.filter(file => /\.(?:css|scss|sass|less)$/.test(file.path)
287
+ && discoveryPathWeight(query, file.path) >= 1
288
+ && !BACKEND_DIRECTORY.test(file.path)
289
+ && (imported.has(file.id) || (scopes.has(scope(file.path))
290
+ && (scope(file.path) !== "" || proximity(file) > 0
291
+ || /^(?:(?:assets|styles?|public\/(?:assets|styles?))\/|(?:globals?|styles?|theme)\.)/i.test(file.path)))));
292
+ styles.sort((a, b) => Number(imported.has(b.id)) - Number(imported.has(a.id)) || proximity(b) - proximity(a) || overlap(b) - overlap(a) || a.path.localeCompare(b.path));
293
+ if (styles[0])
294
+ selected.push(styles[0]);
295
+ }
296
+ return selected.map(file => file.path);
297
+ }
298
+ /** Mixed documentation/control requests often put decisive topics after the
299
+ * broad FTS query's token limit. Give each clause one bounded source candidate. */
300
+ export function documentTopicFiles(db, query) {
301
+ const generic = new Set("find main files file exact source ranges return include relevant code documentation docs and identify usage disclosures".split(" "));
302
+ const clauses = query.split(/[,;:]|\.\s|\band\b/i).map(clause => searchTerms(clause).filter(term => !generic.has(term))).filter(terms => terms.length).slice(0, 16);
303
+ if (clauses.length < 2)
304
+ return [];
305
+ const files = db.getAllFiles().filter(file => discoveryPathWeight(query, file.path) >= 1);
306
+ const selected = new Map();
307
+ for (const terms of clauses) {
308
+ const hits = db.searchFileText(terms.join(" "), 32, false, true).filter(hit => discoveryPathWeight(query, hit.path) >= 1);
309
+ // A partial basename match must never beat a complete multiword FTS hit.
310
+ const exact = files.filter(file => terms.every(term => searchTerms(basename(file.path)).includes(term)))
311
+ .sort((a, b) => a.path.localeCompare(b.path));
312
+ const paths = [...new Set([...exact.slice(0, 1).map(file => file.path), ...hits.slice(0, terms.length > 1 ? 2 : 1).map(hit => hit.path)])];
313
+ for (const path of paths) {
314
+ if (!selected.has(path) && selected.size >= 16)
315
+ continue;
316
+ const words = selected.get(path) ?? new Set();
317
+ terms.forEach(term => words.add(term));
318
+ selected.set(path, words);
319
+ }
320
+ }
321
+ return [...selected].map(([file, terms]) => ({ file, terms: [...terms] }));
322
+ }
323
+ export function isLockfile(path) {
324
+ return /(?:^|\/)(?:package-lock.json|npm-shrinkwrap.json|pnpm-lock.yaml|yarn.lock|bun.lockb?|Cargo.lock|poetry.lock|uv.lock|Gemfile.lock|go.sum)$/i.test(path);
325
+ }
326
+ export function wantsLockfile(query) {
327
+ return /lockfile|lock\s*file|package-lock|shrinkwrap|pnpm-lock|yarn\.lock|bun\.lock|cargo\.lock|poetry\.lock|uv\.lock|gemfile\.lock|go\.sum|\b(?:integrity|resolved|transitive|dependencies|dependency)\b/i.test(query);
328
+ }
329
+ //# sourceMappingURL=discovery-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-hints.js","sourceRoot":"","sources":["../../src/tools/discovery-hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,iBAAiB,GAAG,qEAAqE,CAAC;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAG,yLAAyL,CAAC;AAC/N,wFAAwF;AACxF,MAAM,oBAAoB,GAAG,ykCAAykC,CAAC;AAEvmC,0FAA0F;AAC1F,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3G,CAAC;AAED,+EAA+E;AAC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AC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,EAAE,CAAA,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrI,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,IAAI,EAAE;gBAAE,SAAS;YACzD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAU,CAAC;YACtD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAA,EAAE,CAAA,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAC,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAC,KAAK,CAAC,EAAC,EAAE,CAAA,CAAC,EAAC,IAAI,EAAC,KAAK,EAAC,CAAC,GAAG,KAAK,CAAC,EAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,4IAA4I,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjK,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,oMAAoM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1N,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type EfficiencyScope = "session" | "24h" | "7d" | "all";
2
+ export interface EfficiencyReportOptions {
3
+ rootDir: string;
4
+ scope?: EfficiencyScope;
5
+ sessionStartedAt?: number;
6
+ sessionId?: string;
7
+ inputCostPerMillion?: number;
8
+ contextproCostUsd?: number;
9
+ historyLimit?: number;
10
+ format?: "text" | "json";
11
+ }
12
+ export declare function getEfficiencyReport(options: EfficiencyReportOptions): Promise<string>;
13
+ //# sourceMappingURL=efficiency-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"efficiency-report.d.ts","sourceRoot":"","sources":["../../src/tools/efficiency-report.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAC/D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAYD,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsD3F"}
@@ -0,0 +1,78 @@
1
+ // Persistent, auditable context estimates with isolated MCP-session accounting.
2
+ import { getDB } from "../core/db.js";
3
+ import { getToolSchemaTokens, runtimeSessionId, runtimeSessionStartedAt } from "../core/runtime-session.js";
4
+ function sinceFor(scope, started) {
5
+ if (scope === "session")
6
+ return started ?? runtimeSessionStartedAt;
7
+ if (scope === "24h")
8
+ return Date.now() - 86_400_000;
9
+ if (scope === "7d")
10
+ return Date.now() - 7 * 86_400_000;
11
+ return undefined;
12
+ }
13
+ const fmt = (n) => Math.max(0, Math.round(n)).toLocaleString("en-US");
14
+ function nonnegative(value, label) {
15
+ if (value !== undefined && (!Number.isFinite(value) || value < 0))
16
+ throw new Error(`${label} must be a finite nonnegative number.`);
17
+ return value;
18
+ }
19
+ export async function getEfficiencyReport(options) {
20
+ const scope = options.scope ?? "session";
21
+ const since = sinceFor(scope, options.sessionStartedAt);
22
+ const sessionId = scope === "session" ? options.sessionId ?? runtimeSessionId : undefined;
23
+ const db = await getDB(options.rootDir);
24
+ const totals = db.getEfficiencyTotals(since, sessionId);
25
+ const byTool = db.getToolCallAggregates(since, sessionId).sort((a, b) => b.savedTokens - a.savedTokens);
26
+ const history = options.historyLimit === 0 ? [] : db.getToolSavingsHistory(options.historyLimit ?? 10, since, sessionId);
27
+ const rate = nonnegative(options.inputCostPerMillion, "inputCostPerMillion");
28
+ const operatingCost = nonnegative(options.contextproCostUsd, "contextproCostUsd");
29
+ const schemaTokens = scope === "session" ? getToolSchemaTokens() : null;
30
+ const netTokens = totals.sourceTokens - totals.outputTokens - totals.inputTokens - (schemaTokens ?? 0);
31
+ const avoided = Math.max(0, netTokens);
32
+ const cost = rate === undefined ? null : avoided * rate / 1_000_000;
33
+ const costText = cost === null ? "cost unavailable (model price not supplied)" : `$${cost.toFixed(4)} hypothetical input cost avoided`;
34
+ const finalSummary = `ContextPro: ${fmt(totals.calls)} tool calls; ~${fmt(avoided)} input tokens avoided versus full-file reads (estimate); ${costText}.`;
35
+ const report = {
36
+ scope, sessionId: sessionId ?? null, since: since === undefined ? null : new Date(since).toISOString(),
37
+ observed: { toolCalls: totals.calls, errors: totals.errors, averageMs: totals.avgMs, maxMs: totals.maxMs },
38
+ estimate: {
39
+ savedTokens: avoided,
40
+ sourceTokensRepresented: totals.sourceTokens,
41
+ responseTokens: totals.outputTokens,
42
+ requestTokens: totals.inputTokens,
43
+ toolSchemaTokens: schemaTokens,
44
+ netTokensAvoided: netTokens,
45
+ representedFileReferences: totals.representedFiles,
46
+ method: "UTF-8 bytes divided by four. Full-source baseline credits each represented file revision once per process session; subtract all request/response estimates and one advertised tool catalog for session reports. Historical rows may use the older per-call baseline.",
47
+ limitations: ["Not tokenizer measurements or a measured comparison against another agent.", "Client schema loading, repeated prompt history and cache behavior are unknown; one catalog is a scenario assumption.", "Non-session windows combine sessions and older estimates; catalog overhead is unavailable.", "History is bounded to the latest 5,000 calls per project; old periods may be incomplete."],
48
+ },
49
+ calls: { total: totals.calls, errors: totals.errors, averageMs: totals.avgMs, maxMs: totals.maxMs },
50
+ hypotheticalInputCostAvoided: cost === null ? null : {
51
+ usd: Number(cost.toFixed(6)), inputCostPerMillionTokens: rate,
52
+ contextproCostUsd: operatingCost ?? null,
53
+ netUsdAfterSuppliedCosts: operatingCost === undefined ? null : Number((cost - operatingCost).toFixed(6)),
54
+ note: "Scenario only: uncached input pricing, not actual billing savings. Net excludes operating costs unless supplied. No revenue is inferred.",
55
+ },
56
+ actualBillingSavingsUsd: null,
57
+ actualAgentTokensSaved: null,
58
+ finalSummary, byTool, recentSavings: history,
59
+ privacy: "Only numeric metrics, tool names and an opaque session ID are stored. Prompts, responses, source text, and file paths are never retained in efficiency history.",
60
+ };
61
+ if (options.format === "json")
62
+ return JSON.stringify(report, null, 2);
63
+ const lines = [
64
+ `ContextPro Efficiency — ${scope}`, finalSummary,
65
+ `Full-source baseline: ~${fmt(totals.sourceTokens)} tokens; requests: ~${fmt(totals.inputTokens)}; responses: ~${fmt(totals.outputTokens)}.`,
66
+ schemaTokens === null ? "Tool-catalog overhead: unavailable for this history window." : `Tool-catalog allowance: ~${fmt(schemaTokens)} tokens (one catalog; client behavior varies).`,
67
+ `Observed: ${fmt(totals.errors)} errors; average ${fmt(totals.avgMs)}ms per call.`,
68
+ ];
69
+ if (netTokens < 0)
70
+ lines.push(`Estimated overhead exceeds this baseline by ~${fmt(-netTokens)} tokens; no savings claimed.`);
71
+ if (cost !== null && operatingCost !== undefined)
72
+ lines.push(`Hypothetical net after supplied ContextPro costs: $${(cost - operatingCost).toFixed(4)}.`);
73
+ if (cost === null)
74
+ lines.push("Pass input_cost_per_million to calculate a price scenario; never guess a model price.");
75
+ lines.push("", "Method: " + report.estimate.method, "Actual agent-token savings and billing savings are unknown. Provider caching and ContextPro costs can change the result.", report.privacy);
76
+ return lines.join("\n");
77
+ }
78
+ //# sourceMappingURL=efficiency-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"efficiency-report.js","sourceRoot":"","sources":["../../src/tools/efficiency-report.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAa5G,SAAS,QAAQ,CAAC,KAAsB,EAAE,OAAgB;IACxD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,IAAI,uBAAuB,CAAC;IACnE,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC;IACpD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtF,SAAS,WAAW,CAAC,KAAyB,EAAE,KAAa;IAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,uCAAuC,CAAC,CAAC;IACpI,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAgC;IACxE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,SAAS,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EA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7H,IAAI,IAAI,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC,IAAI,GAAG,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACzJ,IAAI,IAAI,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,uFAAuF,CAAC,CAAC;IACvH,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,0HAA0H,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAChM,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type UnifiedSearchOptions } from "./search.js";
2
+ export type EvidenceRole = "implementation" | "dependency" | "caller" | "test";
3
+ export interface EvidenceCandidate {
4
+ path: string;
5
+ score: number;
6
+ reason: string;
7
+ symbols: string[];
8
+ roles: EvidenceRole[];
9
+ anchors: number[];
10
+ /** Absolute similarity, never a rank-derived confidence. */
11
+ semanticScore?: number;
12
+ }
13
+ export declare const connectedRetrievalEnabled: () => boolean;
14
+ export declare function retrieveEvidence(options: {
15
+ rootDir: string;
16
+ query: string;
17
+ graphHops?: 0 | 1 | 2;
18
+ graphMaxFiles?: number;
19
+ includeTests?: boolean;
20
+ preset?: UnifiedSearchOptions["preset"];
21
+ }): Promise<{
22
+ search: import("./search.js").UnifiedSearchData;
23
+ candidates: EvidenceCandidate[];
24
+ tests: {
25
+ path: string;
26
+ reason: string;
27
+ score: number;
28
+ }[];
29
+ limited: boolean;
30
+ relevanceNotice: string | undefined;
31
+ relationNotice: string | undefined;
32
+ }>;
33
+ //# sourceMappingURL=evidence-retrieval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-retrieval.d.ts","sourceRoot":"","sources":["../../src/tools/evidence-retrieval.ts"],"names":[],"mappings":"AAKA,OAAO,EAA6C,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKnG,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC/E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC/D,KAAK,EAAE,YAAY,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IACzC,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AACD,eAAO,MAAM,yBAAyB,QAAO,OAA8D,CAAC;AAE5G,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9E,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CACjE;;;;;;;;;;;GAuKA"}