codevault 1.8.3 → 1.8.5

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 (479) hide show
  1. package/README.md +33 -5
  2. package/dist/chunking/file-grouper.d.ts +1 -1
  3. package/dist/chunking/file-grouper.d.ts.map +1 -1
  4. package/dist/chunking/file-grouper.js +3 -3
  5. package/dist/chunking/file-grouper.js.map +1 -1
  6. package/dist/chunking/semantic-chunker.d.ts +1 -1
  7. package/dist/chunking/semantic-chunker.d.ts.map +1 -1
  8. package/dist/chunking/token-counter.d.ts +1 -1
  9. package/dist/chunking/token-counter.d.ts.map +1 -1
  10. package/dist/chunking/token-counter.js +16 -10
  11. package/dist/chunking/token-counter.js.map +1 -1
  12. package/dist/cli/commands/ask-cmd.js +15 -15
  13. package/dist/cli/commands/ask-cmd.js.map +1 -1
  14. package/dist/cli/commands/chat-cmd.d.ts.map +1 -1
  15. package/dist/cli/commands/chat-cmd.js +40 -40
  16. package/dist/cli/commands/chat-cmd.js.map +1 -1
  17. package/dist/cli/commands/config-cmd.d.ts.map +1 -1
  18. package/dist/cli/commands/config-cmd.js +61 -52
  19. package/dist/cli/commands/config-cmd.js.map +1 -1
  20. package/dist/cli/commands/context.d.ts.map +1 -1
  21. package/dist/cli/commands/context.js +20 -11
  22. package/dist/cli/commands/context.js.map +1 -1
  23. package/dist/cli/commands/index-cmd.d.ts.map +1 -1
  24. package/dist/cli/commands/index-cmd.js +109 -85
  25. package/dist/cli/commands/index-cmd.js.map +1 -1
  26. package/dist/cli/commands/info-cmd.d.ts.map +1 -1
  27. package/dist/cli/commands/info-cmd.js +12 -11
  28. package/dist/cli/commands/info-cmd.js.map +1 -1
  29. package/dist/cli/commands/interactive-config.d.ts.map +1 -1
  30. package/dist/cli/commands/interactive-config.js +60 -20
  31. package/dist/cli/commands/interactive-config.js.map +1 -1
  32. package/dist/cli/commands/search-cmd.d.ts.map +1 -1
  33. package/dist/cli/commands/search-cmd.js +22 -11
  34. package/dist/cli/commands/search-cmd.js.map +1 -1
  35. package/dist/cli/commands/search-with-code-cmd.d.ts.map +1 -1
  36. package/dist/cli/commands/search-with-code-cmd.js +25 -16
  37. package/dist/cli/commands/search-with-code-cmd.js.map +1 -1
  38. package/dist/cli/commands/update-cmd.d.ts.map +1 -1
  39. package/dist/cli/commands/update-cmd.js +16 -7
  40. package/dist/cli/commands/update-cmd.js.map +1 -1
  41. package/dist/cli/commands/watch-cmd.d.ts.map +1 -1
  42. package/dist/cli/commands/watch-cmd.js +21 -11
  43. package/dist/cli/commands/watch-cmd.js.map +1 -1
  44. package/dist/cli/index.js.map +1 -1
  45. package/dist/cli/utils.d.ts +56 -0
  46. package/dist/cli/utils.d.ts.map +1 -0
  47. package/dist/cli/utils.js +98 -0
  48. package/dist/cli/utils.js.map +1 -0
  49. package/dist/cli.js +0 -0
  50. package/dist/codemap/io.js.map +1 -1
  51. package/dist/config/constants.d.ts +4 -0
  52. package/dist/config/constants.d.ts.map +1 -1
  53. package/dist/config/constants.js +2 -0
  54. package/dist/config/constants.js.map +1 -1
  55. package/dist/config/loader.js.map +1 -1
  56. package/dist/context/packs.d.ts +2 -2
  57. package/dist/context/packs.d.ts.map +1 -1
  58. package/dist/context/packs.js +7 -4
  59. package/dist/context/packs.js.map +1 -1
  60. package/dist/core/IndexerEngine.d.ts +2 -0
  61. package/dist/core/IndexerEngine.d.ts.map +1 -1
  62. package/dist/core/IndexerEngine.js +34 -26
  63. package/dist/core/IndexerEngine.js.map +1 -1
  64. package/dist/core/SearchService.d.ts +2 -1
  65. package/dist/core/SearchService.d.ts.map +1 -1
  66. package/dist/core/SearchService.js +25 -18
  67. package/dist/core/SearchService.js.map +1 -1
  68. package/dist/core/batch-indexer.d.ts +4 -3
  69. package/dist/core/batch-indexer.d.ts.map +1 -1
  70. package/dist/core/batch-indexer.js +32 -35
  71. package/dist/core/batch-indexer.js.map +1 -1
  72. package/dist/core/indexing/FileProcessor.d.ts +1 -0
  73. package/dist/core/indexing/FileProcessor.d.ts.map +1 -1
  74. package/dist/core/indexing/FileProcessor.js +32 -9
  75. package/dist/core/indexing/FileProcessor.js.map +1 -1
  76. package/dist/core/indexing/IndexContext.d.ts +6 -4
  77. package/dist/core/indexing/IndexContext.d.ts.map +1 -1
  78. package/dist/core/indexing/IndexContext.js +3 -3
  79. package/dist/core/indexing/IndexContext.js.map +1 -1
  80. package/dist/core/indexing/IndexFinalizationStage.d.ts +6 -1
  81. package/dist/core/indexing/IndexFinalizationStage.d.ts.map +1 -1
  82. package/dist/core/indexing/IndexFinalizationStage.js +22 -3
  83. package/dist/core/indexing/IndexFinalizationStage.js.map +1 -1
  84. package/dist/core/indexing/IndexState.d.ts +3 -8
  85. package/dist/core/indexing/IndexState.d.ts.map +1 -1
  86. package/dist/core/indexing/IndexState.js.map +1 -1
  87. package/dist/core/indexing/PersistManager.d.ts +1 -1
  88. package/dist/core/indexing/PersistManager.d.ts.map +1 -1
  89. package/dist/core/indexing/PersistManager.js +17 -17
  90. package/dist/core/indexing/PersistManager.js.map +1 -1
  91. package/dist/core/indexing/chunk-pipeline.d.ts +33 -7
  92. package/dist/core/indexing/chunk-pipeline.d.ts.map +1 -1
  93. package/dist/core/indexing/chunk-pipeline.js +20 -8
  94. package/dist/core/indexing/chunk-pipeline.js.map +1 -1
  95. package/dist/core/metadata.d.ts +1 -1
  96. package/dist/core/metadata.d.ts.map +1 -1
  97. package/dist/core/metadata.js +1 -1
  98. package/dist/core/metadata.js.map +1 -1
  99. package/dist/core/search/CandidateRetriever.d.ts +1 -1
  100. package/dist/core/search/CandidateRetriever.d.ts.map +1 -1
  101. package/dist/core/search/CandidateRetriever.js +7 -5
  102. package/dist/core/search/CandidateRetriever.js.map +1 -1
  103. package/dist/core/search/HybridFusion.d.ts +1 -2
  104. package/dist/core/search/HybridFusion.d.ts.map +1 -1
  105. package/dist/core/search/HybridFusion.js +5 -17
  106. package/dist/core/search/HybridFusion.js.map +1 -1
  107. package/dist/core/search/ResultMapper.d.ts +0 -1
  108. package/dist/core/search/ResultMapper.d.ts.map +1 -1
  109. package/dist/core/search/ResultMapper.js +3 -14
  110. package/dist/core/search/ResultMapper.js.map +1 -1
  111. package/dist/core/search/SearchContextManager.d.ts +4 -1
  112. package/dist/core/search/SearchContextManager.d.ts.map +1 -1
  113. package/dist/core/search/SearchContextManager.js +19 -6
  114. package/dist/core/search/SearchContextManager.js.map +1 -1
  115. package/dist/core/search.d.ts.map +1 -1
  116. package/dist/core/search.js +9 -4
  117. package/dist/core/search.js.map +1 -1
  118. package/dist/core/types.d.ts +2 -2
  119. package/dist/core/types.d.ts.map +1 -1
  120. package/dist/database/db.d.ts +14 -14
  121. package/dist/database/db.d.ts.map +1 -1
  122. package/dist/database/db.js +14 -14
  123. package/dist/database/db.js.map +1 -1
  124. package/dist/indexer/merkle.js +1 -1
  125. package/dist/indexer/merkle.js.map +1 -1
  126. package/dist/languages/rules.d.ts +2 -1
  127. package/dist/languages/rules.d.ts.map +1 -1
  128. package/dist/languages/rules.js +14 -5
  129. package/dist/languages/rules.js.map +1 -1
  130. package/dist/languages/tree-sitter-loader.d.ts +24 -24
  131. package/dist/languages/tree-sitter-loader.d.ts.map +1 -1
  132. package/dist/languages/tree-sitter-loader.js +14 -10
  133. package/dist/languages/tree-sitter-loader.js.map +1 -1
  134. package/dist/mcp/handlers/context.d.ts +5 -11
  135. package/dist/mcp/handlers/context.d.ts.map +1 -1
  136. package/dist/mcp/handlers/context.js.map +1 -1
  137. package/dist/mcp/handlers/project.d.ts +9 -27
  138. package/dist/mcp/handlers/project.d.ts.map +1 -1
  139. package/dist/mcp/handlers/search.d.ts +24 -18
  140. package/dist/mcp/handlers/search.d.ts.map +1 -1
  141. package/dist/mcp/handlers/search.js +8 -2
  142. package/dist/mcp/handlers/search.js.map +1 -1
  143. package/dist/mcp/handlers/synthesis.d.ts +15 -11
  144. package/dist/mcp/handlers/synthesis.d.ts.map +1 -1
  145. package/dist/mcp/handlers/synthesis.js +4 -1
  146. package/dist/mcp/handlers/synthesis.js.map +1 -1
  147. package/dist/mcp/schemas.d.ts +2 -2
  148. package/dist/mcp/tools/ask-codebase.d.ts +10 -28
  149. package/dist/mcp/tools/ask-codebase.d.ts.map +1 -1
  150. package/dist/mcp/tools/ask-codebase.js +1 -1
  151. package/dist/mcp/tools/ask-codebase.js.map +1 -1
  152. package/dist/mcp/tools/use-context-pack.d.ts +14 -23
  153. package/dist/mcp/tools/use-context-pack.d.ts.map +1 -1
  154. package/dist/mcp/tools/use-context-pack.js +4 -3
  155. package/dist/mcp/tools/use-context-pack.js.map +1 -1
  156. package/dist/mcp-server.d.ts +1 -0
  157. package/dist/mcp-server.d.ts.map +1 -1
  158. package/dist/mcp-server.js +39 -24
  159. package/dist/mcp-server.js.map +1 -1
  160. package/dist/providers/base.d.ts +3 -2
  161. package/dist/providers/base.d.ts.map +1 -1
  162. package/dist/providers/base.js +3 -10
  163. package/dist/providers/base.js.map +1 -1
  164. package/dist/providers/chat-llm.d.ts +3 -2
  165. package/dist/providers/chat-llm.d.ts.map +1 -1
  166. package/dist/providers/chat-llm.js +13 -9
  167. package/dist/providers/chat-llm.js.map +1 -1
  168. package/dist/providers/mock.d.ts.map +1 -1
  169. package/dist/providers/mock.js +6 -5
  170. package/dist/providers/mock.js.map +1 -1
  171. package/dist/providers/openai.d.ts +2 -1
  172. package/dist/providers/openai.d.ts.map +1 -1
  173. package/dist/providers/openai.js +15 -19
  174. package/dist/providers/openai.js.map +1 -1
  175. package/dist/providers/token-counter.d.ts.map +1 -1
  176. package/dist/providers/token-counter.js +11 -3
  177. package/dist/providers/token-counter.js.map +1 -1
  178. package/dist/ranking/api-reranker.d.ts +1 -1
  179. package/dist/ranking/api-reranker.d.ts.map +1 -1
  180. package/dist/ranking/api-reranker.js +50 -13
  181. package/dist/ranking/api-reranker.js.map +1 -1
  182. package/dist/ranking/symbol-boost.d.ts.map +1 -1
  183. package/dist/ranking/symbol-boost.js +4 -11
  184. package/dist/ranking/symbol-boost.js.map +1 -1
  185. package/dist/search/bm25.d.ts +10 -0
  186. package/dist/search/bm25.d.ts.map +1 -1
  187. package/dist/search/bm25.js +16 -0
  188. package/dist/search/bm25.js.map +1 -1
  189. package/dist/search/hybrid.js.map +1 -1
  190. package/dist/search/scope.d.ts.map +1 -1
  191. package/dist/search/scope.js +3 -2
  192. package/dist/search/scope.js.map +1 -1
  193. package/dist/storage/encrypted-chunks.d.ts +3 -0
  194. package/dist/storage/encrypted-chunks.d.ts.map +1 -1
  195. package/dist/storage/encrypted-chunks.js +126 -47
  196. package/dist/storage/encrypted-chunks.js.map +1 -1
  197. package/dist/symbols/extract.d.ts.map +1 -1
  198. package/dist/symbols/extract.js +3 -2
  199. package/dist/symbols/extract.js.map +1 -1
  200. package/dist/symbols/graph.d.ts.map +1 -1
  201. package/dist/symbols/graph.js +14 -8
  202. package/dist/symbols/graph.js.map +1 -1
  203. package/dist/synthesis/conversational-synthesizer.d.ts +2 -1
  204. package/dist/synthesis/conversational-synthesizer.d.ts.map +1 -1
  205. package/dist/synthesis/conversational-synthesizer.js +6 -1
  206. package/dist/synthesis/conversational-synthesizer.js.map +1 -1
  207. package/dist/synthesis/markdown-formatter.d.ts.map +1 -1
  208. package/dist/synthesis/markdown-formatter.js +1 -1
  209. package/dist/synthesis/markdown-formatter.js.map +1 -1
  210. package/dist/synthesis/prompt-builder.d.ts.map +1 -1
  211. package/dist/synthesis/prompt-builder.js +42 -15
  212. package/dist/synthesis/prompt-builder.js.map +1 -1
  213. package/dist/synthesis/synthesizer.d.ts.map +1 -1
  214. package/dist/synthesis/synthesizer.js +23 -10
  215. package/dist/synthesis/synthesizer.js.map +1 -1
  216. package/dist/tests/api-reranker.test.d.ts +2 -0
  217. package/dist/tests/api-reranker.test.d.ts.map +1 -0
  218. package/dist/tests/api-reranker.test.js +575 -0
  219. package/dist/tests/api-reranker.test.js.map +1 -0
  220. package/dist/tests/bm25.test.d.ts +2 -0
  221. package/dist/tests/bm25.test.d.ts.map +1 -0
  222. package/dist/tests/bm25.test.js +340 -0
  223. package/dist/tests/bm25.test.js.map +1 -0
  224. package/dist/tests/chunking/file-grouper.test.d.ts +2 -0
  225. package/dist/tests/chunking/file-grouper.test.d.ts.map +1 -0
  226. package/dist/tests/chunking/file-grouper.test.js +495 -0
  227. package/dist/tests/chunking/file-grouper.test.js.map +1 -0
  228. package/dist/tests/chunking/semantic-chunker.test.d.ts +2 -0
  229. package/dist/tests/chunking/semantic-chunker.test.d.ts.map +1 -0
  230. package/dist/tests/chunking/semantic-chunker.test.js +509 -0
  231. package/dist/tests/chunking/semantic-chunker.test.js.map +1 -0
  232. package/dist/tests/chunking/token-counter.test.d.ts +2 -0
  233. package/dist/tests/chunking/token-counter.test.d.ts.map +1 -0
  234. package/dist/tests/chunking/token-counter.test.js +441 -0
  235. package/dist/tests/chunking/token-counter.test.js.map +1 -0
  236. package/dist/tests/cli/ask-cmd.test.d.ts +2 -0
  237. package/dist/tests/cli/ask-cmd.test.d.ts.map +1 -0
  238. package/dist/tests/cli/ask-cmd.test.js +152 -0
  239. package/dist/tests/cli/ask-cmd.test.js.map +1 -0
  240. package/dist/tests/cli/chat-cmd.test.d.ts +2 -0
  241. package/dist/tests/cli/chat-cmd.test.d.ts.map +1 -0
  242. package/dist/tests/cli/chat-cmd.test.js +118 -0
  243. package/dist/tests/cli/chat-cmd.test.js.map +1 -0
  244. package/dist/tests/cli/config-cmd.test.d.ts +2 -0
  245. package/dist/tests/cli/config-cmd.test.d.ts.map +1 -0
  246. package/dist/tests/cli/config-cmd.test.js +226 -0
  247. package/dist/tests/cli/config-cmd.test.js.map +1 -0
  248. package/dist/tests/cli/context.test.d.ts +2 -0
  249. package/dist/tests/cli/context.test.d.ts.map +1 -0
  250. package/dist/tests/cli/context.test.js +158 -0
  251. package/dist/tests/cli/context.test.js.map +1 -0
  252. package/dist/tests/cli/index-cmd.test.d.ts +2 -0
  253. package/dist/tests/cli/index-cmd.test.d.ts.map +1 -0
  254. package/dist/tests/cli/index-cmd.test.js +89 -0
  255. package/dist/tests/cli/index-cmd.test.js.map +1 -0
  256. package/dist/tests/cli/index.test.d.ts +2 -0
  257. package/dist/tests/cli/index.test.d.ts.map +1 -0
  258. package/dist/tests/cli/index.test.js +167 -0
  259. package/dist/tests/cli/index.test.js.map +1 -0
  260. package/dist/tests/cli/info-cmd.test.d.ts +2 -0
  261. package/dist/tests/cli/info-cmd.test.d.ts.map +1 -0
  262. package/dist/tests/cli/info-cmd.test.js +47 -0
  263. package/dist/tests/cli/info-cmd.test.js.map +1 -0
  264. package/dist/tests/cli/interactive-config.test.d.ts +2 -0
  265. package/dist/tests/cli/interactive-config.test.d.ts.map +1 -0
  266. package/dist/tests/cli/interactive-config.test.js +30 -0
  267. package/dist/tests/cli/interactive-config.test.js.map +1 -0
  268. package/dist/tests/cli/mcp-cmd.test.d.ts +2 -0
  269. package/dist/tests/cli/mcp-cmd.test.d.ts.map +1 -0
  270. package/dist/tests/cli/mcp-cmd.test.js +47 -0
  271. package/dist/tests/cli/mcp-cmd.test.js.map +1 -0
  272. package/dist/tests/cli/search-cmd.test.d.ts +2 -0
  273. package/dist/tests/cli/search-cmd.test.d.ts.map +1 -0
  274. package/dist/tests/cli/search-cmd.test.js +120 -0
  275. package/dist/tests/cli/search-cmd.test.js.map +1 -0
  276. package/dist/tests/cli/search-with-code-cmd.test.d.ts +2 -0
  277. package/dist/tests/cli/search-with-code-cmd.test.d.ts.map +1 -0
  278. package/dist/tests/cli/search-with-code-cmd.test.js +140 -0
  279. package/dist/tests/cli/search-with-code-cmd.test.js.map +1 -0
  280. package/dist/tests/cli/update-cmd.test.d.ts +2 -0
  281. package/dist/tests/cli/update-cmd.test.d.ts.map +1 -0
  282. package/dist/tests/cli/update-cmd.test.js +75 -0
  283. package/dist/tests/cli/update-cmd.test.js.map +1 -0
  284. package/dist/tests/cli/utils.test.d.ts +2 -0
  285. package/dist/tests/cli/utils.test.d.ts.map +1 -0
  286. package/dist/tests/cli/utils.test.js +119 -0
  287. package/dist/tests/cli/utils.test.js.map +1 -0
  288. package/dist/tests/cli/watch-cmd.test.d.ts +2 -0
  289. package/dist/tests/cli/watch-cmd.test.d.ts.map +1 -0
  290. package/dist/tests/cli/watch-cmd.test.js +84 -0
  291. package/dist/tests/cli/watch-cmd.test.js.map +1 -0
  292. package/dist/tests/cli-ui.test.d.ts +2 -0
  293. package/dist/tests/cli-ui.test.d.ts.map +1 -0
  294. package/dist/tests/cli-ui.test.js +608 -0
  295. package/dist/tests/cli-ui.test.js.map +1 -0
  296. package/dist/tests/codemap-io.test.d.ts +2 -0
  297. package/dist/tests/codemap-io.test.d.ts.map +1 -0
  298. package/dist/tests/codemap-io.test.js +992 -0
  299. package/dist/tests/codemap-io.test.js.map +1 -0
  300. package/dist/tests/config/apply-env.test.d.ts +2 -0
  301. package/dist/tests/config/apply-env.test.d.ts.map +1 -0
  302. package/dist/tests/config/apply-env.test.js +717 -0
  303. package/dist/tests/config/apply-env.test.js.map +1 -0
  304. package/dist/tests/config/constants.test.d.ts +2 -0
  305. package/dist/tests/config/constants.test.d.ts.map +1 -0
  306. package/dist/tests/config/constants.test.js +406 -0
  307. package/dist/tests/config/constants.test.js.map +1 -0
  308. package/dist/tests/config/loader.test.d.ts +2 -0
  309. package/dist/tests/config/loader.test.d.ts.map +1 -0
  310. package/dist/tests/config/loader.test.js +716 -0
  311. package/dist/tests/config/loader.test.js.map +1 -0
  312. package/dist/tests/config/resolver.test.d.ts +2 -0
  313. package/dist/tests/config/resolver.test.d.ts.map +1 -0
  314. package/dist/tests/config/resolver.test.js +402 -0
  315. package/dist/tests/config/resolver.test.js.map +1 -0
  316. package/dist/tests/config/types.test.d.ts +2 -0
  317. package/dist/tests/config/types.test.d.ts.map +1 -0
  318. package/dist/tests/config/types.test.js +460 -0
  319. package/dist/tests/config/types.test.js.map +1 -0
  320. package/dist/tests/context-packs.test.d.ts +2 -0
  321. package/dist/tests/context-packs.test.d.ts.map +1 -0
  322. package/dist/tests/context-packs.test.js +826 -0
  323. package/dist/tests/context-packs.test.js.map +1 -0
  324. package/dist/tests/conversational-synthesizer.test.d.ts +2 -0
  325. package/dist/tests/conversational-synthesizer.test.d.ts.map +1 -0
  326. package/dist/tests/conversational-synthesizer.test.js +595 -0
  327. package/dist/tests/conversational-synthesizer.test.js.map +1 -0
  328. package/dist/tests/database.test.d.ts +2 -0
  329. package/dist/tests/database.test.d.ts.map +1 -0
  330. package/dist/tests/database.test.js +965 -0
  331. package/dist/tests/database.test.js.map +1 -0
  332. package/dist/tests/encrypted-chunks.test.d.ts +2 -0
  333. package/dist/tests/encrypted-chunks.test.d.ts.map +1 -0
  334. package/dist/tests/encrypted-chunks.test.js +1470 -0
  335. package/dist/tests/encrypted-chunks.test.js.map +1 -0
  336. package/dist/tests/hybrid.test.d.ts +2 -0
  337. package/dist/tests/hybrid.test.d.ts.map +1 -0
  338. package/dist/tests/hybrid.test.js +456 -0
  339. package/dist/tests/hybrid.test.js.map +1 -0
  340. package/dist/tests/indexer/ChangeQueue.test.d.ts +12 -0
  341. package/dist/tests/indexer/ChangeQueue.test.d.ts.map +1 -0
  342. package/dist/tests/indexer/ChangeQueue.test.js +441 -0
  343. package/dist/tests/indexer/ChangeQueue.test.js.map +1 -0
  344. package/dist/tests/indexer/ProviderManager.test.d.ts +12 -0
  345. package/dist/tests/indexer/ProviderManager.test.d.ts.map +1 -0
  346. package/dist/tests/indexer/ProviderManager.test.js +290 -0
  347. package/dist/tests/indexer/ProviderManager.test.js.map +1 -0
  348. package/dist/tests/indexer/WatchService.test.d.ts +14 -0
  349. package/dist/tests/indexer/WatchService.test.d.ts.map +1 -0
  350. package/dist/tests/indexer/WatchService.test.js +667 -0
  351. package/dist/tests/indexer/WatchService.test.js.map +1 -0
  352. package/dist/tests/indexer/merkle.test.d.ts +11 -0
  353. package/dist/tests/indexer/merkle.test.d.ts.map +1 -0
  354. package/dist/tests/indexer/merkle.test.js +497 -0
  355. package/dist/tests/indexer/merkle.test.js.map +1 -0
  356. package/dist/tests/indexer/update.test.d.ts +10 -0
  357. package/dist/tests/indexer/update.test.d.ts.map +1 -0
  358. package/dist/tests/indexer/update.test.js +317 -0
  359. package/dist/tests/indexer/update.test.js.map +1 -0
  360. package/dist/tests/indexer/watch.test.d.ts +8 -0
  361. package/dist/tests/indexer/watch.test.d.ts.map +1 -0
  362. package/dist/tests/indexer/watch.test.js +95 -0
  363. package/dist/tests/indexer/watch.test.js.map +1 -0
  364. package/dist/tests/integration/index-search.integration.test.js +6 -4
  365. package/dist/tests/integration/index-search.integration.test.js.map +1 -1
  366. package/dist/tests/languages.test.d.ts +2 -0
  367. package/dist/tests/languages.test.d.ts.map +1 -0
  368. package/dist/tests/languages.test.js +575 -0
  369. package/dist/tests/languages.test.js.map +1 -0
  370. package/dist/tests/logger-redaction.test.d.ts +2 -0
  371. package/dist/tests/logger-redaction.test.d.ts.map +1 -0
  372. package/dist/tests/logger-redaction.test.js +48 -0
  373. package/dist/tests/logger-redaction.test.js.map +1 -0
  374. package/dist/tests/logger.test.d.ts +2 -0
  375. package/dist/tests/logger.test.d.ts.map +1 -0
  376. package/dist/tests/logger.test.js +468 -0
  377. package/dist/tests/logger.test.js.map +1 -0
  378. package/dist/tests/markdown-formatter.test.d.ts +2 -0
  379. package/dist/tests/markdown-formatter.test.d.ts.map +1 -0
  380. package/dist/tests/markdown-formatter.test.js +453 -0
  381. package/dist/tests/markdown-formatter.test.js.map +1 -0
  382. package/dist/tests/mcp/tools/use-context-pack.test.d.ts +7 -0
  383. package/dist/tests/mcp/tools/use-context-pack.test.d.ts.map +1 -0
  384. package/dist/tests/mcp/tools/use-context-pack.test.js +505 -0
  385. package/dist/tests/mcp/tools/use-context-pack.test.js.map +1 -0
  386. package/dist/tests/mutex.test.d.ts +2 -0
  387. package/dist/tests/mutex.test.d.ts.map +1 -0
  388. package/dist/tests/mutex.test.js +489 -0
  389. package/dist/tests/mutex.test.js.map +1 -0
  390. package/dist/tests/path-helpers.test.d.ts +2 -0
  391. package/dist/tests/path-helpers.test.d.ts.map +1 -0
  392. package/dist/tests/path-helpers.test.js +332 -0
  393. package/dist/tests/path-helpers.test.js.map +1 -0
  394. package/dist/tests/prompt-builder.test.d.ts +2 -0
  395. package/dist/tests/prompt-builder.test.d.ts.map +1 -0
  396. package/dist/tests/prompt-builder.test.js +417 -0
  397. package/dist/tests/prompt-builder.test.js.map +1 -0
  398. package/dist/tests/providers/base.test.d.ts +2 -0
  399. package/dist/tests/providers/base.test.d.ts.map +1 -0
  400. package/dist/tests/providers/base.test.js +299 -0
  401. package/dist/tests/providers/base.test.js.map +1 -0
  402. package/dist/tests/providers/chat-llm.test.d.ts +2 -0
  403. package/dist/tests/providers/chat-llm.test.d.ts.map +1 -0
  404. package/dist/tests/providers/chat-llm.test.js +435 -0
  405. package/dist/tests/providers/chat-llm.test.js.map +1 -0
  406. package/dist/tests/providers/index.test.d.ts +2 -0
  407. package/dist/tests/providers/index.test.d.ts.map +1 -0
  408. package/dist/tests/providers/index.test.js +204 -0
  409. package/dist/tests/providers/index.test.js.map +1 -0
  410. package/dist/tests/providers/mock.test.d.ts +2 -0
  411. package/dist/tests/providers/mock.test.d.ts.map +1 -0
  412. package/dist/tests/providers/mock.test.js +225 -0
  413. package/dist/tests/providers/mock.test.js.map +1 -0
  414. package/dist/tests/providers/openai.test.d.ts +2 -0
  415. package/dist/tests/providers/openai.test.d.ts.map +1 -0
  416. package/dist/tests/providers/openai.test.js +408 -0
  417. package/dist/tests/providers/openai.test.js.map +1 -0
  418. package/dist/tests/providers/token-counter.test.d.ts +2 -0
  419. package/dist/tests/providers/token-counter.test.d.ts.map +1 -0
  420. package/dist/tests/providers/token-counter.test.js +247 -0
  421. package/dist/tests/providers/token-counter.test.js.map +1 -0
  422. package/dist/tests/rate-limiter.test.js +392 -1
  423. package/dist/tests/rate-limiter.test.js.map +1 -1
  424. package/dist/tests/scope.test.d.ts +2 -0
  425. package/dist/tests/scope.test.d.ts.map +1 -0
  426. package/dist/tests/scope.test.js +529 -0
  427. package/dist/tests/scope.test.js.map +1 -0
  428. package/dist/tests/search-normalization.test.js.map +1 -1
  429. package/dist/tests/semantic-chunker.test.js.map +1 -1
  430. package/dist/tests/simple-lru.test.js +377 -0
  431. package/dist/tests/simple-lru.test.js.map +1 -1
  432. package/dist/tests/symbol-boost.test.js +730 -10
  433. package/dist/tests/symbol-boost.test.js.map +1 -1
  434. package/dist/tests/symbols-extract.test.d.ts +2 -0
  435. package/dist/tests/symbols-extract.test.d.ts.map +1 -0
  436. package/dist/tests/symbols-extract.test.js +536 -0
  437. package/dist/tests/symbols-extract.test.js.map +1 -0
  438. package/dist/tests/symbols-graph.test.d.ts +2 -0
  439. package/dist/tests/symbols-graph.test.d.ts.map +1 -0
  440. package/dist/tests/symbols-graph.test.js +656 -0
  441. package/dist/tests/symbols-graph.test.js.map +1 -0
  442. package/dist/tests/synthesizer.test.d.ts +2 -0
  443. package/dist/tests/synthesizer.test.d.ts.map +1 -0
  444. package/dist/tests/synthesizer.test.js +381 -0
  445. package/dist/tests/synthesizer.test.js.map +1 -0
  446. package/dist/types/codemap.d.ts +2 -2
  447. package/dist/types/codemap.d.ts.map +1 -1
  448. package/dist/types/codemap.js +17 -9
  449. package/dist/types/codemap.js.map +1 -1
  450. package/dist/types/context-pack.d.ts +5 -5
  451. package/dist/types/context-pack.d.ts.map +1 -1
  452. package/dist/types/context-pack.js +6 -3
  453. package/dist/types/context-pack.js.map +1 -1
  454. package/dist/utils/cli-ui.d.ts +1 -1
  455. package/dist/utils/cli-ui.d.ts.map +1 -1
  456. package/dist/utils/cli-ui.js +26 -26
  457. package/dist/utils/cli-ui.js.map +1 -1
  458. package/dist/utils/indexer-with-progress.d.ts.map +1 -1
  459. package/dist/utils/indexer-with-progress.js +0 -6
  460. package/dist/utils/indexer-with-progress.js.map +1 -1
  461. package/dist/utils/logger.d.ts +10 -1
  462. package/dist/utils/logger.d.ts.map +1 -1
  463. package/dist/utils/logger.js +158 -6
  464. package/dist/utils/logger.js.map +1 -1
  465. package/dist/utils/mutex.d.ts +7 -2
  466. package/dist/utils/mutex.d.ts.map +1 -1
  467. package/dist/utils/mutex.js +35 -7
  468. package/dist/utils/mutex.js.map +1 -1
  469. package/dist/utils/path-helpers.d.ts.map +1 -1
  470. package/dist/utils/path-helpers.js +5 -2
  471. package/dist/utils/path-helpers.js.map +1 -1
  472. package/dist/utils/rate-limiter.d.ts.map +1 -1
  473. package/dist/utils/rate-limiter.js +23 -4
  474. package/dist/utils/rate-limiter.js.map +1 -1
  475. package/dist/utils/simple-lru.d.ts +6 -0
  476. package/dist/utils/simple-lru.d.ts.map +1 -1
  477. package/dist/utils/simple-lru.js +26 -0
  478. package/dist/utils/simple-lru.js.map +1 -1
  479. package/package.json +1 -1
@@ -1,21 +1,741 @@
1
1
  import test from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { applySymbolBoost } from '../ranking/symbol-boost.js';
4
+ // ============================================================================
5
+ // Helper Functions
6
+ // ============================================================================
7
+ function createCodemap(entries) {
8
+ const codemap = {};
9
+ for (const [id, entry] of Object.entries(entries)) {
10
+ codemap[id] = {
11
+ file: entry.file || 'src/test.ts',
12
+ sha: entry.sha || `sha-${id}`,
13
+ lang: entry.lang || 'typescript',
14
+ symbol: entry.symbol || null,
15
+ symbol_neighbors: entry.symbol_neighbors || [],
16
+ symbol_signature: entry.symbol_signature,
17
+ symbol_parameters: entry.symbol_parameters,
18
+ ...entry,
19
+ };
20
+ }
21
+ return codemap;
22
+ }
23
+ function createResults(items) {
24
+ return items.map((item) => ({
25
+ id: item.id,
26
+ score: item.score,
27
+ }));
28
+ }
29
+ // ============================================================================
30
+ // applySymbolBoost - Empty/Invalid Input Handling
31
+ // ============================================================================
32
+ test('applySymbolBoost handles empty results array', () => {
33
+ const codemap = createCodemap({
34
+ chunk1: { symbol: 'testFunction' },
35
+ });
36
+ const results = [];
37
+ applySymbolBoost(results, { query: 'test', codemap });
38
+ assert.equal(results.length, 0);
39
+ });
40
+ test('applySymbolBoost handles null results', () => {
41
+ const codemap = createCodemap({
42
+ chunk1: { symbol: 'testFunction' },
43
+ });
44
+ // Should not throw
45
+ applySymbolBoost(null, { query: 'test', codemap });
46
+ });
47
+ test('applySymbolBoost handles undefined results', () => {
48
+ const codemap = createCodemap({
49
+ chunk1: { symbol: 'testFunction' },
50
+ });
51
+ // Should not throw
52
+ applySymbolBoost(undefined, { query: 'test', codemap });
53
+ });
54
+ test('applySymbolBoost handles non-array results', () => {
55
+ const codemap = createCodemap({
56
+ chunk1: { symbol: 'testFunction' },
57
+ });
58
+ // Should not throw
59
+ applySymbolBoost('not an array', { query: 'test', codemap });
60
+ });
61
+ test('applySymbolBoost handles null codemap', () => {
62
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
63
+ applySymbolBoost(results, { query: 'test', codemap: null });
64
+ // Score should remain unchanged
65
+ assert.equal(results[0].score, 0.5);
66
+ assert.equal(results[0].symbolBoost, undefined);
67
+ });
68
+ test('applySymbolBoost handles undefined codemap', () => {
69
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
70
+ applySymbolBoost(results, { query: 'test', codemap: undefined });
71
+ // Score should remain unchanged
72
+ assert.equal(results[0].score, 0.5);
73
+ });
74
+ test('applySymbolBoost handles empty codemap', () => {
75
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
76
+ const codemap = {};
77
+ applySymbolBoost(results, { query: 'test', codemap });
78
+ // Score should remain unchanged (no matching metadata)
79
+ assert.equal(results[0].score, 0.5);
80
+ assert.equal(results[0].symbolBoost, undefined);
81
+ });
82
+ test('applySymbolBoost handles result with no matching codemap entry', () => {
83
+ const codemap = createCodemap({
84
+ differentChunk: { symbol: 'testFunction' },
85
+ });
86
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
87
+ applySymbolBoost(results, { query: 'test', codemap });
88
+ // Score should remain unchanged
89
+ assert.equal(results[0].score, 0.5);
90
+ assert.equal(results[0].symbolBoost, undefined);
91
+ });
92
+ // ============================================================================
93
+ // applySymbolBoost - Score Capping (MAX_SYMBOL_BOOST = 0.45)
94
+ // ============================================================================
4
95
  test('applySymbolBoost caps total score at or below 1.0', () => {
5
- const codemap = {
96
+ const codemap = createCodemap({
6
97
  chunk1: {
7
- file: 'src/example.ts',
8
98
  symbol: 'processPayment',
9
99
  sha: 'sha-1',
10
- lang: 'typescript',
11
- symbol_neighbors: []
12
- }
13
- };
14
- const results = [
15
- { id: 'chunk1', score: 0.9, symbol: 'processPayment', symbolBoost: 0 }
16
- ];
100
+ symbol_neighbors: [],
101
+ },
102
+ });
103
+ const results = createResults([{ id: 'chunk1', score: 0.9 }]);
17
104
  applySymbolBoost(results, { query: 'process payment', codemap });
18
105
  assert.ok(results[0].score <= 1, 'score should not exceed 1.0');
19
- assert.ok(results[0].symbolBoost <= 0.45, 'boost should respect cap');
106
+ assert.ok(results[0].symbolBoost <= 0.45, 'boost should respect cap of 0.45');
107
+ });
108
+ test('applySymbolBoost caps symbolBoost at 0.45 even with high match strength', () => {
109
+ const codemap = createCodemap({
110
+ chunk1: {
111
+ symbol: 'processPaymentTransaction',
112
+ symbol_signature: 'processPaymentTransaction(amount, currency, recipient)',
113
+ symbol_parameters: ['amount', 'currency', 'recipient'],
114
+ sha: 'sha-1',
115
+ // Add neighbors that also match query
116
+ symbol_neighbors: ['sha-2'],
117
+ },
118
+ chunk2: {
119
+ symbol: 'validatePayment',
120
+ sha: 'sha-2',
121
+ },
122
+ });
123
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
124
+ applySymbolBoost(results, {
125
+ query: 'process payment transaction amount currency recipient validate',
126
+ codemap,
127
+ });
128
+ assert.ok(results[0].symbolBoost <= 0.45, 'symbolBoost must be capped at 0.45');
129
+ assert.ok(results[0].score <= 1.0, 'total score must not exceed 1.0');
130
+ });
131
+ test('applySymbolBoost ensures total score never exceeds 1.0 even with base score of 1.0', () => {
132
+ const codemap = createCodemap({
133
+ chunk1: {
134
+ symbol: 'testFunction',
135
+ sha: 'sha-1',
136
+ },
137
+ });
138
+ const results = createResults([{ id: 'chunk1', score: 1.0 }]);
139
+ applySymbolBoost(results, { query: 'test function', codemap });
140
+ assert.equal(results[0].score, 1.0, 'score should be capped at 1.0');
141
+ });
142
+ test('applySymbolBoost handles base score greater than 1.0 (normalizes to 1.0)', () => {
143
+ const codemap = createCodemap({
144
+ chunk1: {
145
+ symbol: 'testFunction',
146
+ sha: 'sha-1',
147
+ },
148
+ });
149
+ const results = createResults([{ id: 'chunk1', score: 1.5 }]);
150
+ applySymbolBoost(results, { query: 'test function', codemap });
151
+ // Base score should be clamped to 1.0, then boost added (capped at 1.0)
152
+ assert.ok(results[0].score <= 1.0, 'score should never exceed 1.0');
153
+ });
154
+ test('applySymbolBoost handles negative base score (normalizes to 0)', () => {
155
+ const codemap = createCodemap({
156
+ chunk1: {
157
+ symbol: 'testFunction',
158
+ sha: 'sha-1',
159
+ },
160
+ });
161
+ const results = createResults([{ id: 'chunk1', score: -0.5 }]);
162
+ applySymbolBoost(results, { query: 'test function', codemap });
163
+ // Base score should be clamped to 0, then boost added
164
+ assert.ok(results[0].score >= 0, 'score should never be negative');
165
+ });
166
+ // ============================================================================
167
+ // applySymbolBoost - Signature Matching
168
+ // ============================================================================
169
+ test('applySymbolBoost boosts when query contains exact symbol name', () => {
170
+ const codemap = createCodemap({
171
+ chunk1: {
172
+ symbol: 'calculateTotal',
173
+ sha: 'sha-1',
174
+ },
175
+ });
176
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
177
+ applySymbolBoost(results, { query: 'calculatetotal function', codemap });
178
+ assert.ok(results[0].symbolBoost > 0, 'should receive boost for exact symbol match');
179
+ assert.ok(results[0].symbolBoostSources.includes('signature'), 'source should include signature');
180
+ });
181
+ test('applySymbolBoost boosts for case-insensitive symbol match', () => {
182
+ const codemap = createCodemap({
183
+ chunk1: {
184
+ symbol: 'ProcessData',
185
+ sha: 'sha-1',
186
+ },
187
+ });
188
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
189
+ applySymbolBoost(results, { query: 'PROCESSDATA function', codemap });
190
+ assert.ok(results[0].symbolBoost > 0, 'should boost for case-insensitive match');
191
+ });
192
+ test('applySymbolBoost boosts when query matches symbol signature', () => {
193
+ const codemap = createCodemap({
194
+ chunk1: {
195
+ symbol: 'foo',
196
+ symbol_signature: 'calculateDiscount(price, rate)',
197
+ sha: 'sha-1',
198
+ },
199
+ });
200
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
201
+ applySymbolBoost(results, { query: 'calculatediscount(price, rate)', codemap });
202
+ assert.ok(results[0].symbolBoost > 0, 'should boost for signature match');
203
+ });
204
+ test('applySymbolBoost boosts for camelCase token matching', () => {
205
+ const codemap = createCodemap({
206
+ chunk1: {
207
+ symbol: 'getUserAccountDetails',
208
+ sha: 'sha-1',
209
+ },
210
+ });
211
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
212
+ applySymbolBoost(results, { query: 'user account details', codemap });
213
+ assert.ok(results[0].symbolBoost > 0, 'should boost for camelCase token matches');
214
+ assert.ok(results[0].symbolMatchStrength > 0, 'should set symbolMatchStrength');
215
+ });
216
+ test('applySymbolBoost boosts for underscore_separated token matching', () => {
217
+ const codemap = createCodemap({
218
+ chunk1: {
219
+ symbol: 'get_user_profile',
220
+ sha: 'sha-1',
221
+ },
222
+ });
223
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
224
+ applySymbolBoost(results, { query: 'user profile function', codemap });
225
+ assert.ok(results[0].symbolBoost > 0, 'should boost for underscore token matches');
226
+ });
227
+ test('applySymbolBoost does not boost for token-only matching when tokens are shorter than MIN_TOKEN_LENGTH (3)', () => {
228
+ // Note: The MIN_TOKEN_LENGTH check only applies to token-based regex matching,
229
+ // NOT to the direct symbol substring check. If the query contains the exact symbol
230
+ // (e.g., 'ab' in 'ab function'), it will still match via the substring check.
231
+ // This test verifies that short tokens from symbol splitting are skipped.
232
+ const codemap = createCodemap({
233
+ chunk1: {
234
+ symbol: 'XY', // 2 chars - when split, tokens are too short for regex matching
235
+ sha: 'sha-1',
236
+ },
237
+ });
238
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
239
+ // Query does NOT contain 'xy' as a substring, so substring check fails
240
+ // Token 'xy' is too short (< 3) so token-based regex matching is also skipped
241
+ applySymbolBoost(results, { query: 'different query here', codemap });
242
+ // Should not boost because neither substring nor token match works
243
+ assert.equal(results[0].symbolBoost, undefined, 'should not boost when no match');
244
+ });
245
+ test('applySymbolBoost boosts short symbol via substring match even if token too short', () => {
246
+ // This test verifies that the substring check bypasses the MIN_TOKEN_LENGTH restriction
247
+ const codemap = createCodemap({
248
+ chunk1: {
249
+ symbol: 'ab', // 2 chars - too short for token matching, but works for substring
250
+ sha: 'sha-1',
251
+ },
252
+ });
253
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
254
+ // Query contains 'ab' as substring, so it matches via substring check
255
+ applySymbolBoost(results, { query: 'ab function', codemap });
256
+ // Should boost because queryLower.includes('ab') is true
257
+ assert.ok(results[0].symbolBoost > 0, 'should boost via substring match');
258
+ });
259
+ test('applySymbolBoost handles symbol with null value', () => {
260
+ const codemap = createCodemap({
261
+ chunk1: {
262
+ symbol: null,
263
+ sha: 'sha-1',
264
+ },
265
+ });
266
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
267
+ applySymbolBoost(results, { query: 'test function', codemap });
268
+ // Should not throw and should not boost
269
+ assert.equal(results[0].symbolBoost, undefined);
270
+ });
271
+ test('applySymbolBoost handles empty symbol string', () => {
272
+ const codemap = createCodemap({
273
+ chunk1: {
274
+ symbol: '',
275
+ sha: 'sha-1',
276
+ },
277
+ });
278
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
279
+ applySymbolBoost(results, { query: 'test', codemap });
280
+ assert.equal(results[0].symbolBoost, undefined);
281
+ });
282
+ // ============================================================================
283
+ // applySymbolBoost - Parameter Matching
284
+ // ============================================================================
285
+ test('applySymbolBoost boosts when query matches function parameters', () => {
286
+ const codemap = createCodemap({
287
+ chunk1: {
288
+ symbol: 'calculateTax',
289
+ symbol_parameters: ['income', 'taxRate', 'deductions'],
290
+ sha: 'sha-1',
291
+ },
292
+ });
293
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
294
+ applySymbolBoost(results, { query: 'calculate income deductions', codemap });
295
+ assert.ok(results[0].symbolBoost > 0, 'should boost for parameter matches');
296
+ });
297
+ test('applySymbolBoost handles parameter with type annotations', () => {
298
+ const codemap = createCodemap({
299
+ chunk1: {
300
+ symbol: 'processOrder',
301
+ symbol_parameters: ['orderId: string', 'quantity: number', 'price: number'],
302
+ sha: 'sha-1',
303
+ },
304
+ });
305
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
306
+ applySymbolBoost(results, { query: 'order quantity price', codemap });
307
+ assert.ok(results[0].symbolBoost > 0, 'should boost for parameter name matches with types');
308
+ });
309
+ test('applySymbolBoost handles empty symbol_parameters array', () => {
310
+ const codemap = createCodemap({
311
+ chunk1: {
312
+ symbol: 'noParams',
313
+ symbol_parameters: [],
314
+ sha: 'sha-1',
315
+ },
316
+ });
317
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
318
+ applySymbolBoost(results, { query: 'noparams function', codemap });
319
+ // Should still boost for symbol match
320
+ assert.ok(results[0].symbolBoost > 0);
321
+ });
322
+ test('applySymbolBoost handles undefined symbol_parameters', () => {
323
+ const codemap = createCodemap({
324
+ chunk1: {
325
+ symbol: 'noParams',
326
+ sha: 'sha-1',
327
+ },
328
+ });
329
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
330
+ applySymbolBoost(results, { query: 'noparams', codemap });
331
+ // Should not throw
332
+ assert.ok(results[0].symbolBoost > 0 || results[0].symbolBoost === undefined);
333
+ });
334
+ test('applySymbolBoost ignores non-string parameters', () => {
335
+ const codemap = createCodemap({
336
+ chunk1: {
337
+ symbol: 'mixedParams',
338
+ symbol_parameters: ['validParam', 123, null, 'anotherValid'],
339
+ sha: 'sha-1',
340
+ },
341
+ });
342
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
343
+ // Should not throw
344
+ applySymbolBoost(results, { query: 'validparam anothervalid', codemap });
345
+ assert.ok(results[0].symbolBoost > 0);
346
+ });
347
+ // ============================================================================
348
+ // applySymbolBoost - Neighbor Matching
349
+ // ============================================================================
350
+ test('applySymbolBoost boosts when neighbor symbol matches query', () => {
351
+ const codemap = createCodemap({
352
+ chunk1: {
353
+ symbol: 'mainFunction',
354
+ sha: 'sha-1',
355
+ symbol_neighbors: ['sha-2'],
356
+ },
357
+ chunk2: {
358
+ symbol: 'helperUtility',
359
+ sha: 'sha-2',
360
+ },
361
+ });
362
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
363
+ applySymbolBoost(results, { query: 'helper utility', codemap });
364
+ assert.ok(results[0].symbolBoost > 0, 'should boost for neighbor match');
365
+ assert.ok(results[0].symbolBoostSources.includes('neighbor'), 'source should include neighbor');
366
+ assert.ok(results[0].symbolNeighborStrength > 0, 'should set symbolNeighborStrength');
367
+ });
368
+ test('applySymbolBoost finds best neighbor match among multiple neighbors', () => {
369
+ const codemap = createCodemap({
370
+ chunk1: {
371
+ symbol: 'mainFunction',
372
+ sha: 'sha-1',
373
+ symbol_neighbors: ['sha-2', 'sha-3', 'sha-4'],
374
+ },
375
+ chunk2: {
376
+ symbol: 'weakMatch',
377
+ sha: 'sha-2',
378
+ },
379
+ chunk3: {
380
+ symbol: 'strongMatchQueryTerms',
381
+ sha: 'sha-3',
382
+ },
383
+ chunk4: {
384
+ symbol: 'anotherWeak',
385
+ sha: 'sha-4',
386
+ },
387
+ });
388
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
389
+ applySymbolBoost(results, { query: 'strong match query terms', codemap });
390
+ assert.ok(results[0].symbolNeighborStrength > 0, 'should find best neighbor match');
391
+ });
392
+ test('applySymbolBoost handles empty symbol_neighbors array', () => {
393
+ const codemap = createCodemap({
394
+ chunk1: {
395
+ symbol: 'isolatedFunction',
396
+ sha: 'sha-1',
397
+ symbol_neighbors: [],
398
+ },
399
+ });
400
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
401
+ applySymbolBoost(results, { query: 'isolated', codemap });
402
+ // Should still work, just no neighbor boost
403
+ assert.equal(results[0].symbolNeighborStrength, undefined);
404
+ });
405
+ test('applySymbolBoost handles neighbor SHA not found in codemap', () => {
406
+ const codemap = createCodemap({
407
+ chunk1: {
408
+ symbol: 'mainFunction',
409
+ sha: 'sha-1',
410
+ symbol_neighbors: ['non-existent-sha'],
411
+ },
412
+ });
413
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
414
+ // Should not throw
415
+ applySymbolBoost(results, { query: 'main function', codemap });
416
+ assert.ok(results[0].symbolBoost >= 0 || results[0].symbolBoost === undefined);
417
+ });
418
+ test('applySymbolBoost handles undefined symbol_neighbors', () => {
419
+ const codemap = {
420
+ chunk1: {
421
+ file: 'test.ts',
422
+ sha: 'sha-1',
423
+ symbol: 'testSymbol',
424
+ },
425
+ };
426
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
427
+ // Should not throw
428
+ applySymbolBoost(results, { query: 'testsymbol', codemap });
429
+ assert.ok(typeof results[0].score === 'number');
430
+ });
431
+ // ============================================================================
432
+ // applySymbolBoost - Combined Signature and Neighbor Boost
433
+ // ============================================================================
434
+ test('applySymbolBoost combines signature and neighbor boosts', () => {
435
+ const codemap = createCodemap({
436
+ chunk1: {
437
+ symbol: 'processOrder',
438
+ sha: 'sha-1',
439
+ symbol_neighbors: ['sha-2'],
440
+ },
441
+ chunk2: {
442
+ symbol: 'validatePayment',
443
+ sha: 'sha-2',
444
+ },
445
+ });
446
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
447
+ applySymbolBoost(results, { query: 'process order validate payment', codemap });
448
+ // Should have both sources
449
+ assert.ok(results[0].symbolBoostSources.includes('signature'), 'should include signature');
450
+ assert.ok(results[0].symbolBoostSources.includes('neighbor'), 'should include neighbor');
451
+ assert.ok(results[0].symbolBoost > 0, 'combined boost should be positive');
452
+ assert.ok(results[0].symbolBoost <= 0.45, 'combined boost should still be capped');
453
+ });
454
+ // ============================================================================
455
+ // applySymbolBoost - Multiple Results Processing
456
+ // ============================================================================
457
+ test('applySymbolBoost processes multiple results independently', () => {
458
+ const codemap = createCodemap({
459
+ chunk1: { symbol: 'functionOne', sha: 'sha-1' },
460
+ chunk2: { symbol: 'functionTwo', sha: 'sha-2' },
461
+ chunk3: { symbol: 'noMatch', sha: 'sha-3' },
462
+ });
463
+ const results = createResults([
464
+ { id: 'chunk1', score: 0.6 },
465
+ { id: 'chunk2', score: 0.5 },
466
+ { id: 'chunk3', score: 0.4 },
467
+ ]);
468
+ applySymbolBoost(results, { query: 'function one two', codemap });
469
+ // chunk1 and chunk2 should be boosted, chunk3 should not
470
+ assert.ok(results[0].symbolBoost > 0, 'chunk1 should be boosted');
471
+ assert.ok(results[1].symbolBoost > 0, 'chunk2 should be boosted');
472
+ assert.equal(results[2].symbolBoost, undefined, 'chunk3 should not be boosted');
473
+ });
474
+ test('applySymbolBoost handles results with undefined score', () => {
475
+ const codemap = createCodemap({
476
+ chunk1: { symbol: 'testFunction', sha: 'sha-1' },
477
+ });
478
+ const results = [{ id: 'chunk1' }]; // score is undefined
479
+ applySymbolBoost(results, { query: 'testfunction', codemap });
480
+ // Should treat undefined score as 0
481
+ assert.ok(results[0].score >= 0, 'score should be >= 0');
482
+ assert.ok(results[0].score <= 1, 'score should be <= 1');
483
+ });
484
+ // ============================================================================
485
+ // applySymbolBoost - Regex Special Character Handling
486
+ // ============================================================================
487
+ test('applySymbolBoost handles symbols with regex special characters', () => {
488
+ const codemap = createCodemap({
489
+ chunk1: {
490
+ symbol: 'process$Value',
491
+ sha: 'sha-1',
492
+ },
493
+ });
494
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
495
+ // Should not throw due to unescaped regex special chars
496
+ applySymbolBoost(results, { query: 'process value', codemap });
497
+ // May or may not boost depending on token matching
498
+ assert.ok(typeof results[0].score === 'number');
499
+ });
500
+ test('applySymbolBoost handles query with regex special characters', () => {
501
+ const codemap = createCodemap({
502
+ chunk1: {
503
+ symbol: 'testFunction',
504
+ sha: 'sha-1',
505
+ },
506
+ });
507
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
508
+ // Should not throw
509
+ applySymbolBoost(results, { query: 'test.*function [regex]', codemap });
510
+ assert.ok(typeof results[0].score === 'number');
511
+ });
512
+ test('applySymbolBoost handles symbols with parentheses and brackets', () => {
513
+ const codemap = createCodemap({
514
+ chunk1: {
515
+ symbol: 'array[index]',
516
+ sha: 'sha-1',
517
+ },
518
+ });
519
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
520
+ // Should not throw
521
+ applySymbolBoost(results, { query: 'array index', codemap });
522
+ assert.ok(typeof results[0].score === 'number');
523
+ });
524
+ // ============================================================================
525
+ // applySymbolBoost - Edge Cases for Match Strength Calculation
526
+ // ============================================================================
527
+ test('applySymbolBoost gives higher weight to exact symbol match vs token match', () => {
528
+ const codemap = createCodemap({
529
+ exact: {
530
+ symbol: 'calculateTotal',
531
+ sha: 'sha-exact',
532
+ },
533
+ partial: {
534
+ symbol: 'calculateSomethingElse',
535
+ sha: 'sha-partial',
536
+ },
537
+ });
538
+ const resultsExact = createResults([{ id: 'exact', score: 0.5 }]);
539
+ const resultsPartial = createResults([{ id: 'partial', score: 0.5 }]);
540
+ applySymbolBoost(resultsExact, { query: 'calculatetotal', codemap });
541
+ applySymbolBoost(resultsPartial, { query: 'calculatetotal', codemap });
542
+ // Exact match should have higher or equal boost
543
+ const exactBoost = resultsExact[0].symbolBoost ?? 0;
544
+ const partialBoost = resultsPartial[0].symbolBoost ?? 0;
545
+ assert.ok(exactBoost >= partialBoost, 'exact match should have higher boost');
546
+ });
547
+ test('applySymbolBoost accumulates boost for multiple token matches', () => {
548
+ const codemap = createCodemap({
549
+ chunk1: {
550
+ symbol: 'getUserAccountBalanceHistory',
551
+ sha: 'sha-1',
552
+ },
553
+ });
554
+ const resultsSingle = createResults([{ id: 'chunk1', score: 0.5 }]);
555
+ const resultsMultiple = createResults([{ id: 'chunk1', score: 0.5 }]);
556
+ applySymbolBoost(resultsSingle, { query: 'user', codemap });
557
+ applySymbolBoost(resultsMultiple, { query: 'user account balance history', codemap });
558
+ const singleBoost = resultsSingle[0].symbolBoost ?? 0;
559
+ const multipleBoost = resultsMultiple[0].symbolBoost ?? 0;
560
+ assert.ok(multipleBoost >= singleBoost, 'multiple token matches should boost more');
561
+ });
562
+ // ============================================================================
563
+ // applySymbolBoost - Unicode and International Characters
564
+ // ============================================================================
565
+ test('applySymbolBoost handles unicode characters in symbol names', () => {
566
+ const codemap = createCodemap({
567
+ chunk1: {
568
+ symbol: 'getUsuarioNome',
569
+ sha: 'sha-1',
570
+ },
571
+ });
572
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
573
+ // Should not throw
574
+ applySymbolBoost(results, { query: 'usuario nome', codemap });
575
+ assert.ok(typeof results[0].score === 'number');
576
+ });
577
+ // ============================================================================
578
+ // applySymbolBoost - Very Long Symbols and Queries
579
+ // ============================================================================
580
+ test('applySymbolBoost handles very long symbol names', () => {
581
+ const longSymbol = 'a'.repeat(1000) + 'TestFunction';
582
+ const codemap = createCodemap({
583
+ chunk1: {
584
+ symbol: longSymbol,
585
+ sha: 'sha-1',
586
+ },
587
+ });
588
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
589
+ // Should not throw or hang
590
+ applySymbolBoost(results, { query: 'test function', codemap });
591
+ assert.ok(typeof results[0].score === 'number');
592
+ });
593
+ test('applySymbolBoost handles very long queries', () => {
594
+ const codemap = createCodemap({
595
+ chunk1: {
596
+ symbol: 'simpleFunction',
597
+ sha: 'sha-1',
598
+ },
599
+ });
600
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
601
+ const longQuery = 'simple function ' + 'extra '.repeat(500);
602
+ // Should not throw or hang
603
+ applySymbolBoost(results, { query: longQuery, codemap });
604
+ assert.ok(typeof results[0].score === 'number');
605
+ });
606
+ // ============================================================================
607
+ // applySymbolBoost - Mutation Verification
608
+ // ============================================================================
609
+ test('applySymbolBoost mutates results in place', () => {
610
+ const codemap = createCodemap({
611
+ chunk1: {
612
+ symbol: 'testFunction',
613
+ sha: 'sha-1',
614
+ },
615
+ });
616
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
617
+ const originalReference = results[0];
618
+ applySymbolBoost(results, { query: 'testfunction', codemap });
619
+ // Should be same reference, mutated
620
+ assert.strictEqual(results[0], originalReference, 'should mutate in place');
621
+ assert.ok(results[0].symbolBoost > 0, 'should have boost applied');
622
+ });
623
+ test('applySymbolBoost does not add properties when no boost applied', () => {
624
+ const codemap = createCodemap({
625
+ chunk1: {
626
+ symbol: 'completelyDifferent',
627
+ sha: 'sha-1',
628
+ },
629
+ });
630
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
631
+ applySymbolBoost(results, { query: 'xyz abc', codemap });
632
+ assert.equal(results[0].symbolBoost, undefined, 'should not add symbolBoost when no match');
633
+ assert.equal(results[0].symbolBoostSources, undefined, 'should not add symbolBoostSources');
634
+ });
635
+ // ============================================================================
636
+ // applySymbolBoost - Zero Score Handling
637
+ // ============================================================================
638
+ test('applySymbolBoost handles base score of exactly 0', () => {
639
+ const codemap = createCodemap({
640
+ chunk1: {
641
+ symbol: 'testFunction',
642
+ sha: 'sha-1',
643
+ },
644
+ });
645
+ const results = createResults([{ id: 'chunk1', score: 0 }]);
646
+ applySymbolBoost(results, { query: 'testfunction', codemap });
647
+ assert.ok(results[0].score >= 0, 'score should be >= 0');
648
+ assert.ok(results[0].score <= 0.45, 'score should be <= 0.45 (max boost)');
649
+ });
650
+ // ============================================================================
651
+ // applySymbolBoost - Large Codemap Performance
652
+ // ============================================================================
653
+ test('applySymbolBoost handles large codemap efficiently', () => {
654
+ // Create a large codemap
655
+ const entries = {};
656
+ for (let i = 0; i < 1000; i++) {
657
+ entries[`chunk${i}`] = {
658
+ symbol: `function${i}`,
659
+ sha: `sha-${i}`,
660
+ symbol_neighbors: i > 0 ? [`sha-${i - 1}`] : [],
661
+ };
662
+ }
663
+ const codemap = createCodemap(entries);
664
+ const results = createResults([
665
+ { id: 'chunk500', score: 0.5 },
666
+ { id: 'chunk999', score: 0.4 },
667
+ ]);
668
+ const start = Date.now();
669
+ applySymbolBoost(results, { query: 'function500 function999', codemap });
670
+ const elapsed = Date.now() - start;
671
+ assert.ok(elapsed < 1000, 'should complete in reasonable time');
672
+ assert.ok(results[0].symbolBoost > 0 || results[1].symbolBoost > 0, 'should find matches');
673
+ });
674
+ // ============================================================================
675
+ // applySymbolBoost - Regex Cache Behavior (buildQueryTokenRegex)
676
+ // ============================================================================
677
+ test('applySymbolBoost benefits from regex cache on repeated queries', () => {
678
+ const codemap = createCodemap({
679
+ chunk1: { symbol: 'processData', sha: 'sha-1' },
680
+ chunk2: { symbol: 'processInfo', sha: 'sha-2' },
681
+ });
682
+ // First call
683
+ const results1 = createResults([{ id: 'chunk1', score: 0.5 }]);
684
+ applySymbolBoost(results1, { query: 'process data', codemap });
685
+ // Second call with same tokens (should use cached regexes)
686
+ const results2 = createResults([{ id: 'chunk2', score: 0.5 }]);
687
+ applySymbolBoost(results2, { query: 'process info', codemap });
688
+ // Both should work correctly
689
+ assert.ok(results1[0].symbolBoost > 0);
690
+ assert.ok(results2[0].symbolBoost > 0);
691
+ });
692
+ // ============================================================================
693
+ // applySymbolBoost - Signature Weight Calculation Details
694
+ // ============================================================================
695
+ test('applySymbolBoost signature match gives weight 4 for exact symbol in query', () => {
696
+ const codemap = createCodemap({
697
+ chunk1: {
698
+ symbol: 'abc',
699
+ sha: 'sha-1',
700
+ },
701
+ });
702
+ const results = createResults([{ id: 'chunk1', score: 0.3 }]);
703
+ applySymbolBoost(results, { query: 'abc function call', codemap });
704
+ // Weight 4 / 4 = 1.0 strength, * 0.3 signature boost = 0.3
705
+ assert.ok(results[0].symbolMatchStrength === 1, 'full match should give strength 1');
706
+ });
707
+ test('applySymbolBoost handles signature with normalized whitespace', () => {
708
+ const codemap = createCodemap({
709
+ chunk1: {
710
+ symbol: 'foo',
711
+ symbol_signature: 'processData( input, output )',
712
+ sha: 'sha-1',
713
+ },
714
+ });
715
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
716
+ applySymbolBoost(results, { query: 'processdata( input, output )', codemap });
717
+ assert.ok(results[0].symbolBoost !== undefined || results[0].score === 0.5);
718
+ });
719
+ // ============================================================================
720
+ // applySymbolBoost - Non-Object Codemap Entry Handling
721
+ // ============================================================================
722
+ test('applySymbolBoost skips codemap entries without sha', () => {
723
+ const codemap = {
724
+ chunk1: {
725
+ file: 'test.ts',
726
+ sha: 'sha-1',
727
+ symbol: 'validSymbol',
728
+ symbol_neighbors: ['sha-invalid'],
729
+ },
730
+ chunk2: {
731
+ file: 'test.ts',
732
+ sha: undefined, // Invalid sha
733
+ symbol: 'invalidEntry',
734
+ },
735
+ };
736
+ const results = createResults([{ id: 'chunk1', score: 0.5 }]);
737
+ // Should not throw
738
+ applySymbolBoost(results, { query: 'valid symbol', codemap });
739
+ assert.ok(typeof results[0].score === 'number');
20
740
  });
21
741
  //# sourceMappingURL=symbol-boost.test.js.map