bluera-knowledge 0.13.3 → 0.14.1

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 (663) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/commands/uninstall.md +65 -0
  4. package/dist/{chunk-AOSDVRRH.js → chunk-AIS5S77C.js} +2 -2
  5. package/dist/{chunk-XL2UHMBL.js → chunk-UAWKTJWN.js} +134 -15
  6. package/dist/chunk-UAWKTJWN.js.map +1 -0
  7. package/dist/{chunk-AJI5DCKY.js → chunk-Y24ZJRZP.js} +8 -3
  8. package/dist/{chunk-AJI5DCKY.js.map → chunk-Y24ZJRZP.js.map} +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/mcp/server.js +2 -2
  11. package/dist/workers/background-worker-cli.js +2 -2
  12. package/hooks/check-dependencies.sh +46 -57
  13. package/package.json +12 -1
  14. package/.claude/commands/code-review.md +0 -15
  15. package/.claude/commands/commit.md +0 -34
  16. package/.claude/council-cache/1a43ed5977b8f29afc79a9bf5c4082ee5ad8338c42ab991a4241a48f80c1e46d.json +0 -7
  17. package/.claude/hooks/post-edit-check.sh +0 -40
  18. package/.claude/rules/code-quality.md +0 -12
  19. package/.claude/rules/git.md +0 -5
  20. package/.claude/rules/versioning.md +0 -7
  21. package/.claude/settings.local.json.example +0 -45
  22. package/.claude/skills/atomic-commits/SKILL.md +0 -61
  23. package/.claude/skills/code-review-repo/skill.md +0 -62
  24. package/.editorconfig +0 -15
  25. package/.env.example +0 -21
  26. package/.github/workflows/auto-release.yml +0 -64
  27. package/.github/workflows/ci.yml +0 -168
  28. package/.github/workflows/release.yml +0 -74
  29. package/.github/workflows/update-marketplace.yml +0 -96
  30. package/.husky/pre-commit +0 -48
  31. package/.husky/pre-push +0 -39
  32. package/.mcp.json +0 -11
  33. package/.prettierrc +0 -9
  34. package/.versionrc.json +0 -24
  35. package/CLAUDE.md +0 -110
  36. package/CONTRIBUTING.md +0 -307
  37. package/NOTICE +0 -47
  38. package/SECURITY.md +0 -65
  39. package/bun.lock +0 -2036
  40. package/dist/chunk-XL2UHMBL.js.map +0 -1
  41. package/docs/claude-code-best-practices.md +0 -458
  42. package/docs/cli.md +0 -170
  43. package/docs/commands.md +0 -392
  44. package/docs/crawler-architecture.md +0 -89
  45. package/docs/mcp-integration.md +0 -130
  46. package/docs/token-efficiency.md +0 -91
  47. package/eslint-rules/require-skip-comment.js +0 -81
  48. package/eslint.config.js +0 -103
  49. package/knip.json +0 -43
  50. package/scripts/test-mcp-dev.js +0 -260
  51. package/scripts/validate-npm-release.sh +0 -314
  52. package/src/analysis/adapter-registry.test.ts +0 -211
  53. package/src/analysis/adapter-registry.ts +0 -155
  54. package/src/analysis/ast-parser.test.ts +0 -470
  55. package/src/analysis/ast-parser.ts +0 -198
  56. package/src/analysis/code-graph.test.ts +0 -718
  57. package/src/analysis/code-graph.ts +0 -249
  58. package/src/analysis/dependency-usage-analyzer.test.ts +0 -619
  59. package/src/analysis/dependency-usage-analyzer.ts +0 -433
  60. package/src/analysis/go-ast-parser.test.ts +0 -531
  61. package/src/analysis/go-ast-parser.ts +0 -471
  62. package/src/analysis/language-adapter.ts +0 -127
  63. package/src/analysis/parser-factory.test.ts +0 -210
  64. package/src/analysis/parser-factory.ts +0 -52
  65. package/src/analysis/python-ast-parser.test.ts +0 -210
  66. package/src/analysis/python-ast-parser.ts +0 -34
  67. package/src/analysis/repo-url-resolver.test.ts +0 -533
  68. package/src/analysis/repo-url-resolver.ts +0 -233
  69. package/src/analysis/rust-ast-parser.test.ts +0 -568
  70. package/src/analysis/rust-ast-parser.ts +0 -467
  71. package/src/analysis/tree-sitter-parser.test.ts +0 -297
  72. package/src/analysis/tree-sitter-parser.ts +0 -217
  73. package/src/analysis/zil/index.ts +0 -34
  74. package/src/analysis/zil/zil-adapter.test.ts +0 -187
  75. package/src/analysis/zil/zil-adapter.ts +0 -121
  76. package/src/analysis/zil/zil-lexer.test.ts +0 -222
  77. package/src/analysis/zil/zil-lexer.ts +0 -239
  78. package/src/analysis/zil/zil-parser.test.ts +0 -210
  79. package/src/analysis/zil/zil-parser.ts +0 -360
  80. package/src/analysis/zil/zil-special-forms.ts +0 -193
  81. package/src/cli/commands/crawl.test.ts +0 -1086
  82. package/src/cli/commands/crawl.ts +0 -220
  83. package/src/cli/commands/index-cmd.test.ts +0 -733
  84. package/src/cli/commands/index-cmd.ts +0 -128
  85. package/src/cli/commands/mcp.test.ts +0 -218
  86. package/src/cli/commands/mcp.ts +0 -18
  87. package/src/cli/commands/plugin-api.test.ts +0 -373
  88. package/src/cli/commands/plugin-api.ts +0 -82
  89. package/src/cli/commands/search.test.ts +0 -1047
  90. package/src/cli/commands/search.ts +0 -197
  91. package/src/cli/commands/serve.test.ts +0 -371
  92. package/src/cli/commands/serve.ts +0 -43
  93. package/src/cli/commands/setup.test.ts +0 -895
  94. package/src/cli/commands/setup.ts +0 -176
  95. package/src/cli/commands/store.test.ts +0 -1370
  96. package/src/cli/commands/store.ts +0 -229
  97. package/src/cli/commands/sync.test.ts +0 -54
  98. package/src/cli/commands/sync.ts +0 -313
  99. package/src/cli/index.ts +0 -8
  100. package/src/cli/program.ts +0 -59
  101. package/src/crawl/article-converter.test.ts +0 -576
  102. package/src/crawl/article-converter.ts +0 -142
  103. package/src/crawl/bridge.test.ts +0 -796
  104. package/src/crawl/bridge.ts +0 -339
  105. package/src/crawl/claude-client.test.ts +0 -902
  106. package/src/crawl/claude-client.ts +0 -261
  107. package/src/crawl/intelligent-crawler.test.ts +0 -1028
  108. package/src/crawl/intelligent-crawler.ts +0 -478
  109. package/src/crawl/markdown-utils.test.ts +0 -703
  110. package/src/crawl/markdown-utils.ts +0 -225
  111. package/src/crawl/schemas.ts +0 -114
  112. package/src/db/embeddings.test.ts +0 -79
  113. package/src/db/embeddings.ts +0 -78
  114. package/src/db/index.ts +0 -2
  115. package/src/db/lance.test.ts +0 -479
  116. package/src/db/lance.ts +0 -190
  117. package/src/defaults/repos.ts +0 -67
  118. package/src/index.ts +0 -124
  119. package/src/logging/index.ts +0 -25
  120. package/src/logging/logger.test.ts +0 -75
  121. package/src/logging/logger.ts +0 -145
  122. package/src/logging/payload.test.ts +0 -152
  123. package/src/logging/payload.ts +0 -119
  124. package/src/mcp/cache.test.ts +0 -202
  125. package/src/mcp/cache.ts +0 -103
  126. package/src/mcp/commands/index.ts +0 -22
  127. package/src/mcp/commands/job.commands.ts +0 -48
  128. package/src/mcp/commands/meta.commands.ts +0 -54
  129. package/src/mcp/commands/registry.ts +0 -180
  130. package/src/mcp/commands/store.commands.ts +0 -75
  131. package/src/mcp/commands/sync.commands.test.ts +0 -371
  132. package/src/mcp/commands/sync.commands.ts +0 -263
  133. package/src/mcp/handlers/execute.handler.test.ts +0 -179
  134. package/src/mcp/handlers/execute.handler.ts +0 -23
  135. package/src/mcp/handlers/index.ts +0 -39
  136. package/src/mcp/handlers/job.handler.test.ts +0 -189
  137. package/src/mcp/handlers/job.handler.ts +0 -118
  138. package/src/mcp/handlers/search.handler.test.ts +0 -324
  139. package/src/mcp/handlers/search.handler.ts +0 -287
  140. package/src/mcp/handlers/store.handler.test.ts +0 -408
  141. package/src/mcp/handlers/store.handler.ts +0 -318
  142. package/src/mcp/plugin-mcp-config.test.ts +0 -71
  143. package/src/mcp/schemas/index.test.ts +0 -356
  144. package/src/mcp/schemas/index.ts +0 -155
  145. package/src/mcp/server.test.ts +0 -91
  146. package/src/mcp/server.ts +0 -235
  147. package/src/mcp/types.ts +0 -41
  148. package/src/plugin/commands.test.ts +0 -925
  149. package/src/plugin/commands.ts +0 -311
  150. package/src/plugin/dependency-analyzer.test.ts +0 -380
  151. package/src/plugin/dependency-analyzer.ts +0 -210
  152. package/src/plugin/git-clone.test.ts +0 -387
  153. package/src/plugin/git-clone.ts +0 -57
  154. package/src/scripts/validate-npm-release.test.ts +0 -70
  155. package/src/server/app.test.ts +0 -752
  156. package/src/server/app.ts +0 -128
  157. package/src/server/index.test.ts +0 -475
  158. package/src/server/index.ts +0 -1
  159. package/src/services/chunking.service.test.ts +0 -363
  160. package/src/services/chunking.service.ts +0 -380
  161. package/src/services/code-graph.service.test.ts +0 -298
  162. package/src/services/code-graph.service.ts +0 -326
  163. package/src/services/code-unit.service.test.ts +0 -693
  164. package/src/services/code-unit.service.ts +0 -234
  165. package/src/services/config.service.test.ts +0 -146
  166. package/src/services/config.service.ts +0 -92
  167. package/src/services/gitignore.service.test.ts +0 -157
  168. package/src/services/gitignore.service.ts +0 -132
  169. package/src/services/index.service.test.ts +0 -2301
  170. package/src/services/index.service.ts +0 -442
  171. package/src/services/index.ts +0 -119
  172. package/src/services/job.service.test.ts +0 -531
  173. package/src/services/job.service.ts +0 -298
  174. package/src/services/project-root.service.test.ts +0 -504
  175. package/src/services/project-root.service.ts +0 -112
  176. package/src/services/search.service.test.ts +0 -2263
  177. package/src/services/search.service.ts +0 -1341
  178. package/src/services/services.test.ts +0 -108
  179. package/src/services/snippet.service.test.ts +0 -213
  180. package/src/services/snippet.service.ts +0 -193
  181. package/src/services/store-definition.service.test.ts +0 -440
  182. package/src/services/store-definition.service.ts +0 -198
  183. package/src/services/store.service.test.ts +0 -843
  184. package/src/services/store.service.ts +0 -363
  185. package/src/services/token.service.test.ts +0 -45
  186. package/src/services/token.service.ts +0 -33
  187. package/src/services/watch.service.test.ts +0 -600
  188. package/src/services/watch.service.ts +0 -84
  189. package/src/types/brands.test.ts +0 -47
  190. package/src/types/brands.ts +0 -32
  191. package/src/types/config.ts +0 -79
  192. package/src/types/document.ts +0 -54
  193. package/src/types/index.ts +0 -73
  194. package/src/types/job.ts +0 -61
  195. package/src/types/progress.ts +0 -9
  196. package/src/types/result.test.ts +0 -54
  197. package/src/types/result.ts +0 -41
  198. package/src/types/search.ts +0 -105
  199. package/src/types/store-definition.test.ts +0 -492
  200. package/src/types/store-definition.ts +0 -129
  201. package/src/types/store.test.ts +0 -69
  202. package/src/types/store.ts +0 -47
  203. package/src/utils/type-guards.test.ts +0 -351
  204. package/src/utils/type-guards.ts +0 -61
  205. package/src/workers/background-worker-cli.test.ts +0 -35
  206. package/src/workers/background-worker-cli.ts +0 -149
  207. package/src/workers/background-worker.test.ts +0 -222
  208. package/src/workers/background-worker.ts +0 -322
  209. package/src/workers/pid-file.test.ts +0 -167
  210. package/src/workers/pid-file.ts +0 -82
  211. package/src/workers/spawn-worker.test.ts +0 -194
  212. package/src/workers/spawn-worker.ts +0 -70
  213. package/tests/analysis/ast-parser.test.ts +0 -98
  214. package/tests/analysis/code-graph.test.ts +0 -60
  215. package/tests/fixtures/README.md +0 -114
  216. package/tests/fixtures/code-snippets/api/error-handling.ts +0 -256
  217. package/tests/fixtures/code-snippets/api/rest-controller.ts +0 -297
  218. package/tests/fixtures/code-snippets/auth/jwt-auth.ts +0 -197
  219. package/tests/fixtures/code-snippets/auth/oauth-flow.ts +0 -245
  220. package/tests/fixtures/code-snippets/database/repository-pattern.ts +0 -280
  221. package/tests/fixtures/corpus/VERSION.md +0 -25
  222. package/tests/fixtures/corpus/articles/jwt-authentication.md +0 -97
  223. package/tests/fixtures/corpus/articles/react-hooks-patterns.md +0 -127
  224. package/tests/fixtures/corpus/articles/typescript-generics.md +0 -111
  225. package/tests/fixtures/corpus/documentation/express-middleware.md +0 -71
  226. package/tests/fixtures/corpus/documentation/express-routing.md +0 -83
  227. package/tests/fixtures/corpus/documentation/node-streams.md +0 -78
  228. package/tests/fixtures/corpus/oss-repos/express/History.md +0 -3871
  229. package/tests/fixtures/corpus/oss-repos/express/LICENSE +0 -24
  230. package/tests/fixtures/corpus/oss-repos/express/README.md +0 -276
  231. package/tests/fixtures/corpus/oss-repos/express/SECURITY.md +0 -56
  232. package/tests/fixtures/corpus/oss-repos/express/benchmarks/Makefile +0 -17
  233. package/tests/fixtures/corpus/oss-repos/express/benchmarks/README.md +0 -34
  234. package/tests/fixtures/corpus/oss-repos/express/benchmarks/middleware.js +0 -20
  235. package/tests/fixtures/corpus/oss-repos/express/benchmarks/run +0 -18
  236. package/tests/fixtures/corpus/oss-repos/express/examples/README.md +0 -29
  237. package/tests/fixtures/corpus/oss-repos/express/examples/auth/index.js +0 -134
  238. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/foot.ejs +0 -2
  239. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/head.ejs +0 -20
  240. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/login.ejs +0 -21
  241. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/db.js +0 -9
  242. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/index.js +0 -46
  243. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/users.js +0 -19
  244. package/tests/fixtures/corpus/oss-repos/express/examples/cookie-sessions/index.js +0 -25
  245. package/tests/fixtures/corpus/oss-repos/express/examples/cookies/index.js +0 -53
  246. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/CCTV/345/244/247/350/265/233/344/270/212/346/265/267/345/210/206/350/265/233/345/214/272.txt +0 -2
  247. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/amazing.txt +0 -1
  248. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/notes/groceries.txt +0 -3
  249. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/index.js +0 -40
  250. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/index.js +0 -57
  251. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/public/stylesheets/style.css +0 -4
  252. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/footer.html +0 -2
  253. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/header.html +0 -9
  254. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/users.html +0 -10
  255. package/tests/fixtures/corpus/oss-repos/express/examples/error/index.js +0 -53
  256. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/index.js +0 -103
  257. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/404.ejs +0 -3
  258. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/500.ejs +0 -8
  259. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/error_header.ejs +0 -10
  260. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/footer.ejs +0 -2
  261. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/index.ejs +0 -20
  262. package/tests/fixtures/corpus/oss-repos/express/examples/hello-world/index.js +0 -15
  263. package/tests/fixtures/corpus/oss-repos/express/examples/markdown/index.js +0 -44
  264. package/tests/fixtures/corpus/oss-repos/express/examples/markdown/views/index.md +0 -4
  265. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v1.js +0 -15
  266. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v2.js +0 -15
  267. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/index.js +0 -18
  268. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/main/index.js +0 -5
  269. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/index.js +0 -31
  270. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/edit.ejs +0 -17
  271. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/show.ejs +0 -15
  272. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/index.js +0 -41
  273. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/edit.hbs +0 -27
  274. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/list.hbs +0 -18
  275. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/show.hbs +0 -31
  276. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user-pet/index.js +0 -22
  277. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/db.js +0 -16
  278. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/index.js +0 -95
  279. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/lib/boot.js +0 -83
  280. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/public/style.css +0 -14
  281. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/404.ejs +0 -13
  282. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/5xx.ejs +0 -13
  283. package/tests/fixtures/corpus/oss-repos/express/examples/online/index.js +0 -61
  284. package/tests/fixtures/corpus/oss-repos/express/examples/params/index.js +0 -74
  285. package/tests/fixtures/corpus/oss-repos/express/examples/resource/index.js +0 -95
  286. package/tests/fixtures/corpus/oss-repos/express/examples/route-map/index.js +0 -75
  287. package/tests/fixtures/corpus/oss-repos/express/examples/route-middleware/index.js +0 -90
  288. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/index.js +0 -55
  289. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/post.js +0 -13
  290. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/public/style.css +0 -24
  291. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/site.js +0 -5
  292. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/user.js +0 -47
  293. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/footer.ejs +0 -2
  294. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/header.ejs +0 -9
  295. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/index.ejs +0 -10
  296. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/posts/index.ejs +0 -12
  297. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/edit.ejs +0 -23
  298. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/index.ejs +0 -14
  299. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/view.ejs +0 -9
  300. package/tests/fixtures/corpus/oss-repos/express/examples/search/index.js +0 -61
  301. package/tests/fixtures/corpus/oss-repos/express/examples/search/public/client.js +0 -15
  302. package/tests/fixtures/corpus/oss-repos/express/examples/search/public/index.html +0 -21
  303. package/tests/fixtures/corpus/oss-repos/express/examples/session/index.js +0 -37
  304. package/tests/fixtures/corpus/oss-repos/express/examples/session/redis.js +0 -39
  305. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/index.js +0 -43
  306. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/css/style.css +0 -3
  307. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/hello.txt +0 -1
  308. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/js/app.js +0 -1
  309. package/tests/fixtures/corpus/oss-repos/express/examples/vhost/index.js +0 -53
  310. package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/github-view.js +0 -53
  311. package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/index.js +0 -48
  312. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/index.js +0 -155
  313. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/user.js +0 -36
  314. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/views/index.ejs +0 -20
  315. package/tests/fixtures/corpus/oss-repos/express/examples/web-service/index.js +0 -117
  316. package/tests/fixtures/corpus/oss-repos/express/index.js +0 -11
  317. package/tests/fixtures/corpus/oss-repos/express/lib/application.js +0 -631
  318. package/tests/fixtures/corpus/oss-repos/express/lib/express.js +0 -81
  319. package/tests/fixtures/corpus/oss-repos/express/lib/request.js +0 -514
  320. package/tests/fixtures/corpus/oss-repos/express/lib/response.js +0 -1053
  321. package/tests/fixtures/corpus/oss-repos/express/lib/utils.js +0 -271
  322. package/tests/fixtures/corpus/oss-repos/express/lib/view.js +0 -205
  323. package/tests/fixtures/corpus/oss-repos/express/package.json +0 -99
  324. package/tests/fixtures/corpus/oss-repos/express/test/Route.js +0 -274
  325. package/tests/fixtures/corpus/oss-repos/express/test/Router.js +0 -636
  326. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/auth.js +0 -117
  327. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/content-negotiation.js +0 -49
  328. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookie-sessions.js +0 -38
  329. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookies.js +0 -71
  330. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/downloads.js +0 -47
  331. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/ejs.js +0 -17
  332. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error-pages.js +0 -99
  333. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error.js +0 -29
  334. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/hello-world.js +0 -21
  335. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/markdown.js +0 -21
  336. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/multi-router.js +0 -44
  337. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/mvc.js +0 -132
  338. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/params.js +0 -44
  339. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/resource.js +0 -68
  340. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-map.js +0 -45
  341. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-separation.js +0 -97
  342. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/vhost.js +0 -46
  343. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/web-service.js +0 -105
  344. package/tests/fixtures/corpus/oss-repos/express/test/app.all.js +0 -38
  345. package/tests/fixtures/corpus/oss-repos/express/test/app.engine.js +0 -83
  346. package/tests/fixtures/corpus/oss-repos/express/test/app.head.js +0 -66
  347. package/tests/fixtures/corpus/oss-repos/express/test/app.js +0 -120
  348. package/tests/fixtures/corpus/oss-repos/express/test/app.listen.js +0 -55
  349. package/tests/fixtures/corpus/oss-repos/express/test/app.locals.js +0 -26
  350. package/tests/fixtures/corpus/oss-repos/express/test/app.options.js +0 -116
  351. package/tests/fixtures/corpus/oss-repos/express/test/app.param.js +0 -323
  352. package/tests/fixtures/corpus/oss-repos/express/test/app.render.js +0 -374
  353. package/tests/fixtures/corpus/oss-repos/express/test/app.request.js +0 -143
  354. package/tests/fixtures/corpus/oss-repos/express/test/app.response.js +0 -143
  355. package/tests/fixtures/corpus/oss-repos/express/test/app.route.js +0 -197
  356. package/tests/fixtures/corpus/oss-repos/express/test/app.router.js +0 -1217
  357. package/tests/fixtures/corpus/oss-repos/express/test/app.routes.error.js +0 -62
  358. package/tests/fixtures/corpus/oss-repos/express/test/app.use.js +0 -542
  359. package/tests/fixtures/corpus/oss-repos/express/test/config.js +0 -207
  360. package/tests/fixtures/corpus/oss-repos/express/test/exports.js +0 -82
  361. package/tests/fixtures/corpus/oss-repos/express/test/express.json.js +0 -755
  362. package/tests/fixtures/corpus/oss-repos/express/test/express.raw.js +0 -513
  363. package/tests/fixtures/corpus/oss-repos/express/test/express.static.js +0 -815
  364. package/tests/fixtures/corpus/oss-repos/express/test/express.text.js +0 -566
  365. package/tests/fixtures/corpus/oss-repos/express/test/express.urlencoded.js +0 -828
  366. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/% of dogs.txt +0 -1
  367. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/.name +0 -1
  368. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/index.html +0 -1
  369. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/post/index.tmpl +0 -1
  370. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/broken.send +0 -0
  371. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/name.tmpl +0 -1
  372. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/user.tmpl +0 -1
  373. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/email.tmpl +0 -1
  374. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/empty.txt +0 -0
  375. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/local_layout/user.tmpl +0 -1
  376. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.tmpl +0 -1
  377. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.txt +0 -1
  378. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/nums.txt +0 -1
  379. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/pets/names.txt +0 -1
  380. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/snow /342/230/203/.gitkeep +0 -0
  381. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.html +0 -1
  382. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.txt +0 -1
  383. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.html +0 -1
  384. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.tmpl +0 -1
  385. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/index.html +0 -1
  386. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/tobi.txt +0 -1
  387. package/tests/fixtures/corpus/oss-repos/express/test/middleware.basic.js +0 -42
  388. package/tests/fixtures/corpus/oss-repos/express/test/regression.js +0 -20
  389. package/tests/fixtures/corpus/oss-repos/express/test/req.accepts.js +0 -125
  390. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsCharsets.js +0 -50
  391. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsEncodings.js +0 -39
  392. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsLanguages.js +0 -57
  393. package/tests/fixtures/corpus/oss-repos/express/test/req.baseUrl.js +0 -88
  394. package/tests/fixtures/corpus/oss-repos/express/test/req.fresh.js +0 -70
  395. package/tests/fixtures/corpus/oss-repos/express/test/req.get.js +0 -60
  396. package/tests/fixtures/corpus/oss-repos/express/test/req.host.js +0 -156
  397. package/tests/fixtures/corpus/oss-repos/express/test/req.hostname.js +0 -188
  398. package/tests/fixtures/corpus/oss-repos/express/test/req.ip.js +0 -113
  399. package/tests/fixtures/corpus/oss-repos/express/test/req.ips.js +0 -71
  400. package/tests/fixtures/corpus/oss-repos/express/test/req.is.js +0 -169
  401. package/tests/fixtures/corpus/oss-repos/express/test/req.path.js +0 -20
  402. package/tests/fixtures/corpus/oss-repos/express/test/req.protocol.js +0 -113
  403. package/tests/fixtures/corpus/oss-repos/express/test/req.query.js +0 -106
  404. package/tests/fixtures/corpus/oss-repos/express/test/req.range.js +0 -104
  405. package/tests/fixtures/corpus/oss-repos/express/test/req.route.js +0 -28
  406. package/tests/fixtures/corpus/oss-repos/express/test/req.secure.js +0 -101
  407. package/tests/fixtures/corpus/oss-repos/express/test/req.signedCookies.js +0 -37
  408. package/tests/fixtures/corpus/oss-repos/express/test/req.stale.js +0 -50
  409. package/tests/fixtures/corpus/oss-repos/express/test/req.subdomains.js +0 -173
  410. package/tests/fixtures/corpus/oss-repos/express/test/req.xhr.js +0 -42
  411. package/tests/fixtures/corpus/oss-repos/express/test/res.append.js +0 -116
  412. package/tests/fixtures/corpus/oss-repos/express/test/res.attachment.js +0 -79
  413. package/tests/fixtures/corpus/oss-repos/express/test/res.clearCookie.js +0 -62
  414. package/tests/fixtures/corpus/oss-repos/express/test/res.cookie.js +0 -295
  415. package/tests/fixtures/corpus/oss-repos/express/test/res.download.js +0 -487
  416. package/tests/fixtures/corpus/oss-repos/express/test/res.format.js +0 -248
  417. package/tests/fixtures/corpus/oss-repos/express/test/res.get.js +0 -21
  418. package/tests/fixtures/corpus/oss-repos/express/test/res.json.js +0 -186
  419. package/tests/fixtures/corpus/oss-repos/express/test/res.jsonp.js +0 -344
  420. package/tests/fixtures/corpus/oss-repos/express/test/res.links.js +0 -65
  421. package/tests/fixtures/corpus/oss-repos/express/test/res.locals.js +0 -40
  422. package/tests/fixtures/corpus/oss-repos/express/test/res.location.js +0 -316
  423. package/tests/fixtures/corpus/oss-repos/express/test/res.redirect.js +0 -214
  424. package/tests/fixtures/corpus/oss-repos/express/test/res.render.js +0 -367
  425. package/tests/fixtures/corpus/oss-repos/express/test/res.send.js +0 -569
  426. package/tests/fixtures/corpus/oss-repos/express/test/res.sendFile.js +0 -913
  427. package/tests/fixtures/corpus/oss-repos/express/test/res.sendStatus.js +0 -44
  428. package/tests/fixtures/corpus/oss-repos/express/test/res.set.js +0 -124
  429. package/tests/fixtures/corpus/oss-repos/express/test/res.status.js +0 -206
  430. package/tests/fixtures/corpus/oss-repos/express/test/res.type.js +0 -46
  431. package/tests/fixtures/corpus/oss-repos/express/test/res.vary.js +0 -90
  432. package/tests/fixtures/corpus/oss-repos/express/test/support/env.js +0 -3
  433. package/tests/fixtures/corpus/oss-repos/express/test/support/tmpl.js +0 -36
  434. package/tests/fixtures/corpus/oss-repos/express/test/support/utils.js +0 -86
  435. package/tests/fixtures/corpus/oss-repos/express/test/utils.js +0 -83
  436. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/Dockerfile +0 -11
  437. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/devcontainer.json +0 -21
  438. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/docker-compose.yml +0 -18
  439. package/tests/fixtures/corpus/oss-repos/hono/.eslintignore +0 -1
  440. package/tests/fixtures/corpus/oss-repos/hono/.eslintrc.cjs +0 -9
  441. package/tests/fixtures/corpus/oss-repos/hono/.gitpod.yml +0 -9
  442. package/tests/fixtures/corpus/oss-repos/hono/.prettierrc +0 -9
  443. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-default.ts +0 -15
  444. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-dom.ts +0 -15
  445. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/setup-vitest.ts +0 -47
  446. package/tests/fixtures/corpus/oss-repos/hono/LICENSE +0 -21
  447. package/tests/fixtures/corpus/oss-repos/hono/README.md +0 -91
  448. package/tests/fixtures/corpus/oss-repos/hono/build.ts +0 -80
  449. package/tests/fixtures/corpus/oss-repos/hono/bun.lockb +0 -0
  450. package/tests/fixtures/corpus/oss-repos/hono/bunfig.toml +0 -7
  451. package/tests/fixtures/corpus/oss-repos/hono/codecov.yml +0 -13
  452. package/tests/fixtures/corpus/oss-repos/hono/docs/CODE_OF_CONDUCT.md +0 -128
  453. package/tests/fixtures/corpus/oss-repos/hono/docs/CONTRIBUTING.md +0 -62
  454. package/tests/fixtures/corpus/oss-repos/hono/docs/MIGRATION.md +0 -295
  455. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.png +0 -0
  456. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.pxm +0 -0
  457. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.svg +0 -6
  458. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.png +0 -0
  459. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.pxm +0 -0
  460. package/tests/fixtures/corpus/oss-repos/hono/jsr.json +0 -119
  461. package/tests/fixtures/corpus/oss-repos/hono/package.cjs.json +0 -3
  462. package/tests/fixtures/corpus/oss-repos/hono/package.json +0 -650
  463. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +0 -492
  464. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/index.ts +0 -13
  465. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/types.ts +0 -144
  466. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/conninfo.ts +0 -28
  467. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/index.ts +0 -9
  468. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/serve-static.ts +0 -35
  469. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/server.ts +0 -30
  470. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/ssg.ts +0 -27
  471. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/websocket.ts +0 -110
  472. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +0 -120
  473. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/index.ts +0 -7
  474. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/conninfo.ts +0 -7
  475. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/index.ts +0 -8
  476. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static-module.ts +0 -12
  477. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +0 -39
  478. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/utils.ts +0 -50
  479. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/websocket.ts +0 -50
  480. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/conninfo.ts +0 -17
  481. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/deno.d.ts +0 -28
  482. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/index.ts +0 -9
  483. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/serve-static.ts +0 -40
  484. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/ssg.ts +0 -27
  485. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/websocket.ts +0 -51
  486. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/conninfo.ts +0 -15
  487. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/handler.ts +0 -189
  488. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/index.ts +0 -14
  489. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/handler.ts +0 -10
  490. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/index.ts +0 -6
  491. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/mod.ts +0 -1
  492. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/handler.ts +0 -34
  493. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/index.ts +0 -5
  494. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/types.ts +0 -14
  495. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/conninfo.ts +0 -8
  496. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/handler.ts +0 -9
  497. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/index.ts +0 -7
  498. package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +0 -214
  499. package/tests/fixtures/corpus/oss-repos/hono/src/client/index.ts +0 -14
  500. package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +0 -182
  501. package/tests/fixtures/corpus/oss-repos/hono/src/client/utils.ts +0 -54
  502. package/tests/fixtures/corpus/oss-repos/hono/src/compose.ts +0 -94
  503. package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +0 -917
  504. package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +0 -84
  505. package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/index.ts +0 -6
  506. package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +0 -85
  507. package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/index.ts +0 -6
  508. package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/types.ts +0 -45
  509. package/tests/fixtures/corpus/oss-repos/hono/src/helper/cookie/index.ts +0 -130
  510. package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/common.ts +0 -243
  511. package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +0 -220
  512. package/tests/fixtures/corpus/oss-repos/hono/src/helper/dev/index.ts +0 -79
  513. package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +0 -246
  514. package/tests/fixtures/corpus/oss-repos/hono/src/helper/html/index.ts +0 -56
  515. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/index.ts +0 -13
  516. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/middleware.ts +0 -79
  517. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +0 -388
  518. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/utils.ts +0 -71
  519. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/index.ts +0 -9
  520. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/sse.ts +0 -89
  521. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/stream.ts +0 -36
  522. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/text.ts +0 -15
  523. package/tests/fixtures/corpus/oss-repos/hono/src/helper/testing/index.ts +0 -26
  524. package/tests/fixtures/corpus/oss-repos/hono/src/helper/websocket/index.ts +0 -57
  525. package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +0 -523
  526. package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +0 -34
  527. package/tests/fixtures/corpus/oss-repos/hono/src/http-exception.ts +0 -78
  528. package/tests/fixtures/corpus/oss-repos/hono/src/index.ts +0 -51
  529. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/base.ts +0 -419
  530. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/children.ts +0 -20
  531. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/components.ts +0 -195
  532. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/constants.ts +0 -5
  533. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/context.ts +0 -50
  534. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/client.ts +0 -89
  535. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/components.ts +0 -39
  536. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/context.ts +0 -52
  537. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +0 -246
  538. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/hooks/index.ts +0 -91
  539. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/index.ts +0 -159
  540. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +0 -398
  541. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-dev-runtime.ts +0 -22
  542. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-runtime.ts +0 -7
  543. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +0 -772
  544. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/server.ts +0 -70
  545. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/utils.ts +0 -7
  546. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +0 -426
  547. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/index.ts +0 -114
  548. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/common.ts +0 -11
  549. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +0 -196
  550. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-elements.ts +0 -924
  551. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-dev-runtime.ts +0 -26
  552. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-runtime.ts +0 -18
  553. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/streaming.ts +0 -184
  554. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/types.ts +0 -41
  555. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +0 -36
  556. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/basic-auth/index.ts +0 -128
  557. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/bearer-auth/index.ts +0 -159
  558. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/body-limit/index.ts +0 -115
  559. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cache/index.ts +0 -127
  560. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/combine/index.ts +0 -153
  561. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/compress/index.ts +0 -79
  562. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/context-storage/index.ts +0 -55
  563. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cors/index.ts +0 -141
  564. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/csrf/index.ts +0 -90
  565. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/etag/index.ts +0 -88
  566. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/ip-restriction/index.ts +0 -178
  567. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +0 -158
  568. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/index.ts +0 -8
  569. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/jwt.ts +0 -159
  570. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/logger/index.ts +0 -93
  571. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/method-override/index.ts +0 -146
  572. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/powered-by/index.ts +0 -13
  573. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/pretty-json/index.ts +0 -50
  574. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/index.ts +0 -8
  575. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/request-id.ts +0 -59
  576. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/index.ts +0 -8
  577. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/permissions-policy.ts +0 -86
  578. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/secure-headers.ts +0 -319
  579. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +0 -140
  580. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timeout/index.ts +0 -58
  581. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/index.ts +0 -7
  582. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/timing.ts +0 -225
  583. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/trailing-slash/index.ts +0 -71
  584. package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +0 -24
  585. package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +0 -20
  586. package/tests/fixtures/corpus/oss-repos/hono/src/request.ts +0 -403
  587. package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/index.ts +0 -6
  588. package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/router.ts +0 -132
  589. package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/index.ts +0 -6
  590. package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +0 -54
  591. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/index.ts +0 -6
  592. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +0 -159
  593. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +0 -274
  594. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/trie.ts +0 -74
  595. package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/index.ts +0 -6
  596. package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/router.ts +0 -69
  597. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/index.ts +0 -6
  598. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +0 -205
  599. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/router.ts +0 -28
  600. package/tests/fixtures/corpus/oss-repos/hono/src/router.ts +0 -103
  601. package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +0 -2006
  602. package/tests/fixtures/corpus/oss-repos/hono/src/utils/basic-auth.ts +0 -26
  603. package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +0 -225
  604. package/tests/fixtures/corpus/oss-repos/hono/src/utils/buffer.ts +0 -65
  605. package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +0 -26
  606. package/tests/fixtures/corpus/oss-repos/hono/src/utils/concurrent.ts +0 -55
  607. package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +0 -230
  608. package/tests/fixtures/corpus/oss-repos/hono/src/utils/crypto.ts +0 -65
  609. package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +0 -34
  610. package/tests/fixtures/corpus/oss-repos/hono/src/utils/filepath.ts +0 -56
  611. package/tests/fixtures/corpus/oss-repos/hono/src/utils/handler.ts +0 -15
  612. package/tests/fixtures/corpus/oss-repos/hono/src/utils/html.ts +0 -182
  613. package/tests/fixtures/corpus/oss-repos/hono/src/utils/http-status.ts +0 -69
  614. package/tests/fixtures/corpus/oss-repos/hono/src/utils/ipaddr.ts +0 -113
  615. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/index.ts +0 -7
  616. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwa.ts +0 -23
  617. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jws.ts +0 -226
  618. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwt.ts +0 -114
  619. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/types.ts +0 -83
  620. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/utf8.ts +0 -7
  621. package/tests/fixtures/corpus/oss-repos/hono/src/utils/mime.ts +0 -142
  622. package/tests/fixtures/corpus/oss-repos/hono/src/utils/stream.ts +0 -96
  623. package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +0 -102
  624. package/tests/fixtures/corpus/oss-repos/hono/src/utils/url.ts +0 -310
  625. package/tests/fixtures/corpus/oss-repos/hono/src/validator/index.ts +0 -7
  626. package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +0 -151
  627. package/tests/fixtures/corpus/oss-repos/hono/tsconfig.build.json +0 -23
  628. package/tests/fixtures/corpus/oss-repos/hono/tsconfig.json +0 -28
  629. package/tests/fixtures/corpus/oss-repos/hono/vitest.config.ts +0 -34
  630. package/tests/fixtures/corpus/oss-repos/hono/yarn.lock +0 -6232
  631. package/tests/fixtures/documentation/api-reference.md +0 -412
  632. package/tests/fixtures/documentation/architecture.md +0 -214
  633. package/tests/fixtures/documentation/deployment-guide.md +0 -420
  634. package/tests/fixtures/github-readmes/express.md +0 -133
  635. package/tests/fixtures/github-readmes/nextjs.md +0 -106
  636. package/tests/fixtures/github-readmes/react.md +0 -74
  637. package/tests/fixtures/github-readmes/typescript.md +0 -93
  638. package/tests/fixtures/github-readmes/vite.md +0 -79
  639. package/tests/fixtures/queries/core.json +0 -125
  640. package/tests/fixtures/queries/extended.json +0 -427
  641. package/tests/fixtures/queries/generated/.gitkeep +0 -0
  642. package/tests/fixtures/test-server.ts +0 -268
  643. package/tests/helpers/performance-metrics.ts +0 -370
  644. package/tests/helpers/search-relevance.ts +0 -326
  645. package/tests/integration/cli-consistency.test.ts +0 -298
  646. package/tests/integration/cli.test.ts +0 -69
  647. package/tests/integration/e2e-workflow.test.ts +0 -614
  648. package/tests/integration/mcp.test.ts +0 -250
  649. package/tests/integration/python-bridge.test.ts +0 -193
  650. package/tests/integration/search-quality.test.ts +0 -720
  651. package/tests/integration/serve.test.ts +0 -260
  652. package/tests/integration/stress.test.ts +0 -326
  653. package/tests/mcp/server.test.ts +0 -15
  654. package/tests/scripts/schemas/evaluation.json +0 -44
  655. package/tests/scripts/schemas/query-generation.json +0 -21
  656. package/tests/services/code-unit.service.test.ts +0 -95
  657. package/tests/services/job.service.test.ts +0 -124
  658. package/tests/services/search.progressive-context.test.ts +0 -35
  659. package/tsconfig.json +0 -34
  660. package/tsup.config.ts +0 -15
  661. package/turndown-plugin-gfm.d.ts +0 -29
  662. package/vitest.config.ts +0 -90
  663. /package/dist/{chunk-AOSDVRRH.js.map → chunk-AIS5S77C.js.map} +0 -0
@@ -1,2263 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi, beforeEach } from 'vitest';
2
- import { SearchService } from './search.service.js';
3
- import { LanceStore } from '../db/lance.js';
4
- import { EmbeddingEngine } from '../db/embeddings.js';
5
- import { createStoreId, createDocumentId } from '../types/brands.js';
6
- import { rm, mkdtemp } from 'node:fs/promises';
7
- import { tmpdir } from 'node:os';
8
- import { join } from 'node:path';
9
- import type { SearchResult } from '../types/search.js';
10
-
11
- describe('SearchService', () => {
12
- let searchService: SearchService;
13
- let lanceStore: LanceStore;
14
- let embeddingEngine: EmbeddingEngine;
15
- let tempDir: string;
16
- const storeId = createStoreId('test-store');
17
-
18
- beforeAll(async () => {
19
- tempDir = await mkdtemp(join(tmpdir(), 'search-test-'));
20
- lanceStore = new LanceStore(tempDir);
21
- embeddingEngine = new EmbeddingEngine();
22
-
23
- await embeddingEngine.initialize();
24
- await lanceStore.initialize(storeId);
25
-
26
- // Add test documents
27
- const texts = [
28
- 'TypeScript is a typed superset of JavaScript',
29
- 'Python is great for machine learning',
30
- 'React is a JavaScript library for building user interfaces',
31
- ];
32
-
33
- for (let i = 0; i < texts.length; i++) {
34
- const text = texts[i]!;
35
- const vector = await embeddingEngine.embed(text);
36
- await lanceStore.addDocuments(storeId, [
37
- {
38
- id: createDocumentId(`doc-${i}`),
39
- content: text,
40
- vector,
41
- metadata: {
42
- type: 'file',
43
- storeId,
44
- indexedAt: new Date(),
45
- },
46
- },
47
- ]);
48
- }
49
-
50
- searchService = new SearchService(lanceStore, embeddingEngine);
51
- }, 120000);
52
-
53
- afterAll(async () => {
54
- await rm(tempDir, { recursive: true, force: true });
55
- });
56
-
57
- it('searches with vector mode', async () => {
58
- const results = await searchService.search({
59
- query: 'JavaScript programming',
60
- stores: [storeId],
61
- mode: 'vector',
62
- limit: 10,
63
- });
64
-
65
- expect(results.results.length).toBeGreaterThan(0);
66
- expect(results.mode).toBe('vector');
67
- });
68
-
69
- it('returns results with scores', async () => {
70
- const results = await searchService.search({
71
- query: 'machine learning Python',
72
- stores: [storeId],
73
- mode: 'vector',
74
- limit: 10,
75
- });
76
-
77
- expect(results.results[0]?.score).toBeGreaterThan(0);
78
- expect(results.results[0]?.content).toContain('Python');
79
- });
80
-
81
- it('performs hybrid search combining vector and FTS', async () => {
82
- // First create FTS index
83
- await lanceStore.createFtsIndex(storeId);
84
-
85
- const results = await searchService.search({
86
- query: 'JavaScript programming',
87
- stores: [storeId],
88
- mode: 'hybrid',
89
- limit: 10,
90
- });
91
-
92
- expect(results.mode).toBe('hybrid');
93
- expect(results.results.length).toBeGreaterThan(0);
94
- // Hybrid should have RRF scores that differ from pure vector scores
95
- expect(results.results[0]?.score).toBeGreaterThan(0);
96
- });
97
- });
98
-
99
- describe('SearchService - RRF Ranking Algorithm', () => {
100
- let mockLanceStore: LanceStore;
101
- let mockEmbeddingEngine: EmbeddingEngine;
102
- let searchService: SearchService;
103
- const storeId = createStoreId('test-store');
104
-
105
- beforeEach(() => {
106
- mockLanceStore = {
107
- search: vi.fn(),
108
- fullTextSearch: vi.fn(),
109
- } as unknown as LanceStore;
110
-
111
- mockEmbeddingEngine = {
112
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
113
- } as unknown as EmbeddingEngine;
114
-
115
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
116
- });
117
-
118
- it('combines vector and FTS results with RRF', async () => {
119
- const vectorResults = [
120
- {
121
- id: createDocumentId('doc1'),
122
- score: 0.9,
123
- content: 'result 1',
124
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
125
- },
126
- {
127
- id: createDocumentId('doc2'),
128
- score: 0.8,
129
- content: 'result 2',
130
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
131
- },
132
- ];
133
-
134
- const ftsResults = [
135
- {
136
- id: createDocumentId('doc2'),
137
- score: 0.95,
138
- content: 'result 2',
139
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
140
- },
141
- {
142
- id: createDocumentId('doc3'),
143
- score: 0.85,
144
- content: 'result 3',
145
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
146
- },
147
- ];
148
-
149
- vi.mocked(mockLanceStore.search).mockResolvedValue(vectorResults);
150
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue(ftsResults);
151
-
152
- const results = await searchService.search({
153
- query: 'test query',
154
- stores: [storeId],
155
- mode: 'hybrid',
156
- limit: 10,
157
- });
158
-
159
- expect(results.results.length).toBeGreaterThan(0);
160
- // doc2 should rank higher as it appears in both results
161
- expect(results.results.some((r) => r.id === createDocumentId('doc2'))).toBe(true);
162
- });
163
-
164
- it('uses web RRF preset for web content (url metadata)', async () => {
165
- // Web content has url in metadata - should use web preset (k=30)
166
- vi.mocked(mockLanceStore.search).mockResolvedValue([
167
- {
168
- id: createDocumentId('doc1'),
169
- score: 0.9,
170
- content: 'result 1',
171
- metadata: {
172
- type: 'web' as const,
173
- storeId,
174
- indexedAt: new Date(),
175
- url: 'https://example.com/docs',
176
- },
177
- },
178
- ]);
179
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([
180
- {
181
- id: createDocumentId('doc1'),
182
- score: 0.95,
183
- content: 'result 1',
184
- metadata: {
185
- type: 'web' as const,
186
- storeId,
187
- indexedAt: new Date(),
188
- url: 'https://example.com/docs',
189
- },
190
- },
191
- ]);
192
-
193
- const results = await searchService.search({
194
- query: 'test query',
195
- stores: [storeId],
196
- mode: 'hybrid',
197
- limit: 10,
198
- });
199
-
200
- expect(results.results.length).toBe(1);
201
- expect(results.results[0]?.score).toBeGreaterThan(0);
202
- });
203
-
204
- it('uses code RRF preset for file content (path metadata)', async () => {
205
- // File content has path, no url - should use code preset (k=20)
206
- vi.mocked(mockLanceStore.search).mockResolvedValue([
207
- {
208
- id: createDocumentId('doc1'),
209
- score: 0.9,
210
- content: 'function test() {}',
211
- metadata: { type: 'file' as const, storeId, indexedAt: new Date(), path: '/src/test.ts' },
212
- },
213
- ]);
214
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([
215
- {
216
- id: createDocumentId('doc2'),
217
- score: 0.95,
218
- content: 'class Example {}',
219
- metadata: {
220
- type: 'file' as const,
221
- storeId,
222
- indexedAt: new Date(),
223
- path: '/src/example.ts',
224
- },
225
- },
226
- ]);
227
-
228
- const results = await searchService.search({
229
- query: 'test query',
230
- stores: [storeId],
231
- mode: 'hybrid',
232
- limit: 10,
233
- });
234
-
235
- expect(results.results.length).toBeGreaterThan(0);
236
- });
237
-
238
- it('handles documents appearing only in vector results', async () => {
239
- vi.mocked(mockLanceStore.search).mockResolvedValue([
240
- {
241
- id: createDocumentId('doc1'),
242
- score: 0.9,
243
- content: 'vector only',
244
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
245
- },
246
- ]);
247
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
248
-
249
- const results = await searchService.search({
250
- query: 'test query',
251
- stores: [storeId],
252
- mode: 'hybrid',
253
- limit: 10,
254
- });
255
-
256
- expect(results.results.length).toBe(1);
257
- expect(results.results[0]?.id).toBe(createDocumentId('doc1'));
258
- });
259
-
260
- it('handles documents appearing only in FTS results', async () => {
261
- vi.mocked(mockLanceStore.search).mockResolvedValue([]);
262
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([
263
- {
264
- id: createDocumentId('doc1'),
265
- score: 0.9,
266
- content: 'fts only',
267
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
268
- },
269
- ]);
270
-
271
- const results = await searchService.search({
272
- query: 'test query',
273
- stores: [storeId],
274
- mode: 'hybrid',
275
- limit: 10,
276
- });
277
-
278
- expect(results.results.length).toBe(1);
279
- expect(results.results[0]?.id).toBe(createDocumentId('doc1'));
280
- });
281
-
282
- it('normalizes scores to 0-1 range', async () => {
283
- vi.mocked(mockLanceStore.search).mockResolvedValue([
284
- {
285
- id: createDocumentId('doc1'),
286
- score: 0.9,
287
- content: 'result 1',
288
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
289
- },
290
- {
291
- id: createDocumentId('doc2'),
292
- score: 0.5,
293
- content: 'result 2',
294
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
295
- },
296
- ]);
297
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([
298
- {
299
- id: createDocumentId('doc1'),
300
- score: 0.95,
301
- content: 'result 1',
302
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
303
- },
304
- ]);
305
-
306
- const results = await searchService.search({
307
- query: 'test query',
308
- stores: [storeId],
309
- mode: 'hybrid',
310
- limit: 10,
311
- });
312
-
313
- // Scores should be normalized
314
- results.results.forEach((r) => {
315
- expect(r.score).toBeGreaterThanOrEqual(0);
316
- expect(r.score).toBeLessThanOrEqual(1);
317
- });
318
- });
319
-
320
- it('handles identical scores correctly', async () => {
321
- vi.mocked(mockLanceStore.search).mockResolvedValue([
322
- {
323
- id: createDocumentId('doc1'),
324
- score: 0.9,
325
- content: 'result 1',
326
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
327
- },
328
- {
329
- id: createDocumentId('doc2'),
330
- score: 0.9,
331
- content: 'result 2',
332
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
333
- },
334
- ]);
335
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
336
-
337
- const results = await searchService.search({
338
- query: 'test query',
339
- stores: [storeId],
340
- mode: 'hybrid',
341
- limit: 10,
342
- });
343
-
344
- expect(results.results.length).toBe(2);
345
- // Should handle identical scores without errors
346
- expect(results.results[0]?.score).toBeDefined();
347
- });
348
- });
349
-
350
- describe('SearchService - Query Intent Classification', () => {
351
- let mockLanceStore: LanceStore;
352
- let mockEmbeddingEngine: EmbeddingEngine;
353
- let searchService: SearchService;
354
- const storeId = createStoreId('test-store');
355
-
356
- beforeEach(() => {
357
- mockLanceStore = {
358
- search: vi.fn(),
359
- fullTextSearch: vi.fn(),
360
- } as unknown as LanceStore;
361
-
362
- mockEmbeddingEngine = {
363
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
364
- } as unknown as EmbeddingEngine;
365
-
366
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
367
- });
368
-
369
- it('classifies "how to" queries correctly', async () => {
370
- const howToQueries = [
371
- 'how to use React hooks',
372
- 'how do I create a component',
373
- 'show me how to configure',
374
- "what's the best way to implement",
375
- ];
376
-
377
- for (const query of howToQueries) {
378
- vi.mocked(mockLanceStore.search).mockResolvedValue([
379
- {
380
- id: createDocumentId('doc1'),
381
- score: 0.9,
382
- content: 'example code',
383
- metadata: {
384
- type: 'file' as const,
385
- storeId,
386
- indexedAt: new Date(),
387
- fileType: 'example',
388
- },
389
- },
390
- ]);
391
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
392
-
393
- const results = await searchService.search({
394
- query,
395
- stores: [storeId],
396
- mode: 'hybrid',
397
- limit: 10,
398
- });
399
-
400
- // Should boost example files for how-to queries
401
- expect(results.results.length).toBeGreaterThan(0);
402
- }
403
- });
404
-
405
- it('classifies "implementation" queries correctly', async () => {
406
- const implQueries = [
407
- 'how is React implemented',
408
- 'source code for useState',
409
- 'implementation details of router',
410
- 'under the hood of Vue',
411
- ];
412
-
413
- for (const query of implQueries) {
414
- vi.mocked(mockLanceStore.search).mockResolvedValue([
415
- {
416
- id: createDocumentId('doc1'),
417
- score: 0.9,
418
- content: 'internal implementation',
419
- metadata: {
420
- type: 'file' as const,
421
- storeId,
422
- indexedAt: new Date(),
423
- fileType: 'source-internal',
424
- },
425
- },
426
- ]);
427
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
428
-
429
- const results = await searchService.search({
430
- query,
431
- stores: [storeId],
432
- mode: 'hybrid',
433
- limit: 10,
434
- });
435
-
436
- expect(results.results.length).toBeGreaterThan(0);
437
- }
438
- });
439
-
440
- it('classifies "conceptual" queries correctly', async () => {
441
- const conceptQueries = [
442
- 'what is a React hook',
443
- 'explain virtual DOM',
444
- 'what does reconciliation mean',
445
- 'how does routing work',
446
- ];
447
-
448
- for (const query of conceptQueries) {
449
- vi.mocked(mockLanceStore.search).mockResolvedValue([
450
- {
451
- id: createDocumentId('doc1'),
452
- score: 0.9,
453
- content: 'concept explanation',
454
- metadata: {
455
- type: 'file' as const,
456
- storeId,
457
- indexedAt: new Date(),
458
- fileType: 'documentation',
459
- },
460
- },
461
- ]);
462
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
463
-
464
- const results = await searchService.search({
465
- query,
466
- stores: [storeId],
467
- mode: 'hybrid',
468
- limit: 10,
469
- });
470
-
471
- expect(results.results.length).toBeGreaterThan(0);
472
- }
473
- });
474
-
475
- it('classifies "comparison" queries correctly', async () => {
476
- const comparisonQueries = [
477
- 'React vs Vue',
478
- 'difference between hooks and classes',
479
- 'should I use Redux or Context',
480
- 'when to use useMemo',
481
- ];
482
-
483
- for (const query of comparisonQueries) {
484
- vi.mocked(mockLanceStore.search).mockResolvedValue([
485
- {
486
- id: createDocumentId('doc1'),
487
- score: 0.9,
488
- content: 'comparison guide',
489
- metadata: {
490
- type: 'file' as const,
491
- storeId,
492
- indexedAt: new Date(),
493
- fileType: 'documentation-primary',
494
- },
495
- },
496
- ]);
497
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
498
-
499
- const results = await searchService.search({
500
- query,
501
- stores: [storeId],
502
- mode: 'hybrid',
503
- limit: 10,
504
- });
505
-
506
- expect(results.results.length).toBeGreaterThan(0);
507
- }
508
- });
509
-
510
- it('classifies "debugging" queries correctly', async () => {
511
- const debugQueries = [
512
- 'error: cannot read property',
513
- 'React component not rendering',
514
- 'why is my hook not working',
515
- 'how to fix TypeScript error',
516
- ];
517
-
518
- for (const query of debugQueries) {
519
- vi.mocked(mockLanceStore.search).mockResolvedValue([
520
- {
521
- id: createDocumentId('doc1'),
522
- score: 0.9,
523
- content: 'troubleshooting guide',
524
- metadata: {
525
- type: 'file' as const,
526
- storeId,
527
- indexedAt: new Date(),
528
- fileType: 'test',
529
- },
530
- },
531
- ]);
532
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
533
-
534
- const results = await searchService.search({
535
- query,
536
- stores: [storeId],
537
- mode: 'hybrid',
538
- limit: 10,
539
- });
540
-
541
- expect(results.results.length).toBeGreaterThan(0);
542
- }
543
- });
544
-
545
- it('defaults to "how-to" for ambiguous queries', async () => {
546
- vi.mocked(mockLanceStore.search).mockResolvedValue([
547
- {
548
- id: createDocumentId('doc1'),
549
- score: 0.9,
550
- content: 'generic content',
551
- metadata: {
552
- type: 'file' as const,
553
- storeId,
554
- indexedAt: new Date(),
555
- fileType: 'documentation',
556
- },
557
- },
558
- ]);
559
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
560
-
561
- const results = await searchService.search({
562
- query: 'React components',
563
- stores: [storeId],
564
- mode: 'hybrid',
565
- limit: 10,
566
- });
567
-
568
- expect(results.results.length).toBeGreaterThan(0);
569
- });
570
- });
571
-
572
- describe('SearchService - Framework Context Boosting', () => {
573
- let mockLanceStore: LanceStore;
574
- let mockEmbeddingEngine: EmbeddingEngine;
575
- let searchService: SearchService;
576
- const storeId = createStoreId('test-store');
577
-
578
- beforeEach(() => {
579
- mockLanceStore = {
580
- search: vi.fn(),
581
- fullTextSearch: vi.fn(),
582
- } as unknown as LanceStore;
583
-
584
- mockEmbeddingEngine = {
585
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
586
- } as unknown as EmbeddingEngine;
587
-
588
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
589
- });
590
-
591
- it('boosts React-related results when query mentions React', async () => {
592
- vi.mocked(mockLanceStore.search).mockResolvedValue([
593
- {
594
- id: createDocumentId('react-doc'),
595
- score: 0.8,
596
- content: 'React component documentation',
597
- metadata: {
598
- type: 'file' as const,
599
- storeId,
600
- indexedAt: new Date(),
601
- path: '/docs/react/components.md',
602
- },
603
- },
604
- {
605
- id: createDocumentId('vue-doc'),
606
- score: 0.8,
607
- content: 'Vue component documentation',
608
- metadata: {
609
- type: 'file' as const,
610
- storeId,
611
- indexedAt: new Date(),
612
- path: '/docs/vue/components.md',
613
- },
614
- },
615
- ]);
616
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
617
-
618
- const results = await searchService.search({
619
- query: 'React hooks usage',
620
- stores: [storeId],
621
- mode: 'hybrid',
622
- limit: 10,
623
- });
624
-
625
- // React doc should rank higher
626
- expect(results.results[0]?.id).toBe(createDocumentId('react-doc'));
627
- });
628
-
629
- it('recognizes Express framework patterns', async () => {
630
- vi.mocked(mockLanceStore.search).mockResolvedValue([
631
- {
632
- id: createDocumentId('express-doc'),
633
- score: 0.8,
634
- content: 'Express middleware guide',
635
- metadata: {
636
- type: 'file' as const,
637
- storeId,
638
- indexedAt: new Date(),
639
- path: '/node_modules/express/README.md',
640
- },
641
- },
642
- ]);
643
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
644
-
645
- const results = await searchService.search({
646
- query: 'Express routing',
647
- stores: [storeId],
648
- mode: 'hybrid',
649
- limit: 10,
650
- });
651
-
652
- expect(results.results.length).toBeGreaterThan(0);
653
- });
654
-
655
- it('recognizes Vue framework patterns', async () => {
656
- vi.mocked(mockLanceStore.search).mockResolvedValue([
657
- {
658
- id: createDocumentId('vue-doc'),
659
- score: 0.8,
660
- content: 'Vue3 composition API',
661
- metadata: {
662
- type: 'file' as const,
663
- storeId,
664
- indexedAt: new Date(),
665
- path: '/docs/vue3/api.md',
666
- },
667
- },
668
- ]);
669
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
670
-
671
- const results = await searchService.search({
672
- query: 'Vue computed properties',
673
- stores: [storeId],
674
- mode: 'hybrid',
675
- limit: 10,
676
- });
677
-
678
- expect(results.results.length).toBeGreaterThan(0);
679
- });
680
-
681
- it('recognizes TypeScript framework patterns', async () => {
682
- vi.mocked(mockLanceStore.search).mockResolvedValue([
683
- {
684
- id: createDocumentId('ts-doc'),
685
- score: 0.8,
686
- content: 'TypeScript generics guide',
687
- metadata: {
688
- type: 'file' as const,
689
- storeId,
690
- indexedAt: new Date(),
691
- path: '/docs/typescript/generics.md',
692
- },
693
- },
694
- ]);
695
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
696
-
697
- const results = await searchService.search({
698
- query: 'TypeScript type inference',
699
- stores: [storeId],
700
- mode: 'hybrid',
701
- limit: 10,
702
- });
703
-
704
- expect(results.results.length).toBeGreaterThan(0);
705
- });
706
-
707
- it('handles queries without framework mentions', async () => {
708
- vi.mocked(mockLanceStore.search).mockResolvedValue([
709
- {
710
- id: createDocumentId('doc1'),
711
- score: 0.8,
712
- content: 'generic programming guide',
713
- metadata: {
714
- type: 'file' as const,
715
- storeId,
716
- indexedAt: new Date(),
717
- path: '/docs/general.md',
718
- },
719
- },
720
- ]);
721
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
722
-
723
- const results = await searchService.search({
724
- query: 'programming patterns',
725
- stores: [storeId],
726
- mode: 'hybrid',
727
- limit: 10,
728
- });
729
-
730
- expect(results.results.length).toBeGreaterThan(0);
731
- });
732
- });
733
-
734
- describe('SearchService - Deduplication Logic', () => {
735
- let mockLanceStore: LanceStore;
736
- let mockEmbeddingEngine: EmbeddingEngine;
737
- let searchService: SearchService;
738
- const storeId = createStoreId('test-store');
739
-
740
- beforeEach(() => {
741
- mockLanceStore = {
742
- search: vi.fn(),
743
- fullTextSearch: vi.fn(),
744
- } as unknown as LanceStore;
745
-
746
- mockEmbeddingEngine = {
747
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
748
- } as unknown as EmbeddingEngine;
749
-
750
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
751
- });
752
-
753
- it('deduplicates chunks from same source file', async () => {
754
- vi.mocked(mockLanceStore.search).mockResolvedValue([
755
- {
756
- id: createDocumentId('chunk1'),
757
- score: 0.9,
758
- content: 'first chunk with query term',
759
- metadata: {
760
- type: 'chunk' as const,
761
- storeId,
762
- indexedAt: new Date(),
763
- path: '/src/file.ts',
764
- chunkIndex: 0,
765
- totalChunks: 2,
766
- },
767
- },
768
- {
769
- id: createDocumentId('chunk2'),
770
- score: 0.85,
771
- content: 'second chunk with query term',
772
- metadata: {
773
- type: 'chunk' as const,
774
- storeId,
775
- indexedAt: new Date(),
776
- path: '/src/file.ts',
777
- chunkIndex: 1,
778
- totalChunks: 2,
779
- },
780
- },
781
- ]);
782
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
783
-
784
- const results = await searchService.search({
785
- query: 'query term',
786
- stores: [storeId],
787
- mode: 'hybrid',
788
- limit: 10,
789
- });
790
-
791
- // Should only return one result per source file
792
- expect(results.results.length).toBe(1);
793
- });
794
-
795
- it('keeps chunk with more query term matches', async () => {
796
- vi.mocked(mockLanceStore.search).mockResolvedValue([
797
- {
798
- id: createDocumentId('chunk1'),
799
- score: 0.9,
800
- content: 'test content',
801
- metadata: {
802
- type: 'chunk' as const,
803
- storeId,
804
- indexedAt: new Date(),
805
- path: '/src/file.ts',
806
- chunkIndex: 0,
807
- totalChunks: 2,
808
- },
809
- },
810
- {
811
- id: createDocumentId('chunk2'),
812
- score: 0.85,
813
- content: 'test content with React hooks and components',
814
- metadata: {
815
- type: 'chunk' as const,
816
- storeId,
817
- indexedAt: new Date(),
818
- path: '/src/file.ts',
819
- chunkIndex: 1,
820
- totalChunks: 2,
821
- },
822
- },
823
- ]);
824
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
825
-
826
- const results = await searchService.search({
827
- query: 'React hooks components',
828
- stores: [storeId],
829
- mode: 'hybrid',
830
- limit: 10,
831
- });
832
-
833
- // Should keep chunk2 as it has more query term matches
834
- expect(results.results[0]?.id).toBe(createDocumentId('chunk2'));
835
- });
836
-
837
- it('keeps different source files separate', async () => {
838
- vi.mocked(mockLanceStore.search).mockResolvedValue([
839
- {
840
- id: createDocumentId('file1'),
841
- score: 0.9,
842
- content: 'content from file 1',
843
- metadata: {
844
- type: 'file' as const,
845
- storeId,
846
- indexedAt: new Date(),
847
- path: '/src/file1.ts',
848
- },
849
- },
850
- {
851
- id: createDocumentId('file2'),
852
- score: 0.85,
853
- content: 'content from file 2',
854
- metadata: {
855
- type: 'file' as const,
856
- storeId,
857
- indexedAt: new Date(),
858
- path: '/src/file2.ts',
859
- },
860
- },
861
- ]);
862
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
863
-
864
- const results = await searchService.search({
865
- query: 'test query',
866
- stores: [storeId],
867
- mode: 'hybrid',
868
- limit: 10,
869
- });
870
-
871
- // Should keep both results as they're from different files
872
- expect(results.results.length).toBe(2);
873
- });
874
- });
875
-
876
- describe('SearchService - Progressive Context Enhancement', () => {
877
- let mockLanceStore: LanceStore;
878
- let mockEmbeddingEngine: EmbeddingEngine;
879
- let searchService: SearchService;
880
- const storeId = createStoreId('test-store');
881
-
882
- beforeEach(() => {
883
- mockLanceStore = {
884
- search: vi.fn(),
885
- fullTextSearch: vi.fn(),
886
- } as unknown as LanceStore;
887
-
888
- mockEmbeddingEngine = {
889
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
890
- } as unknown as EmbeddingEngine;
891
-
892
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
893
- });
894
-
895
- it('provides minimal detail level by default', async () => {
896
- vi.mocked(mockLanceStore.search).mockResolvedValue([
897
- {
898
- id: createDocumentId('doc1'),
899
- score: 0.9,
900
- content: 'function example() { return 42; }',
901
- metadata: {
902
- type: 'file' as const,
903
- storeId,
904
- indexedAt: new Date(),
905
- path: '/src/example.ts',
906
- },
907
- },
908
- ]);
909
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
910
-
911
- const results = await searchService.search({
912
- query: 'example function',
913
- stores: [storeId],
914
- mode: 'vector',
915
- limit: 10,
916
- });
917
-
918
- // Should have summary but not context or full
919
- expect(results.results[0]?.summary).toBeDefined();
920
- expect(results.results[0]?.context).toBeUndefined();
921
- expect(results.results[0]?.full).toBeUndefined();
922
- });
923
-
924
- it('provides contextual detail when requested', async () => {
925
- vi.mocked(mockLanceStore.search).mockResolvedValue([
926
- {
927
- id: createDocumentId('doc1'),
928
- score: 0.9,
929
- content: 'import React from "react";\n\nfunction Component() { return <div>Test</div>; }',
930
- metadata: {
931
- type: 'file' as const,
932
- storeId,
933
- indexedAt: new Date(),
934
- path: '/src/Component.tsx',
935
- },
936
- },
937
- ]);
938
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
939
-
940
- const results = await searchService.search({
941
- query: 'Component',
942
- stores: [storeId],
943
- mode: 'vector',
944
- limit: 10,
945
- detail: 'contextual',
946
- });
947
-
948
- // Should have summary and context but not full
949
- expect(results.results[0]?.summary).toBeDefined();
950
- expect(results.results[0]?.context).toBeDefined();
951
- expect(results.results[0]?.context?.keyImports).toBeDefined();
952
- expect(results.results[0]?.full).toBeUndefined();
953
- });
954
-
955
- it('provides full detail when requested', async () => {
956
- vi.mocked(mockLanceStore.search).mockResolvedValue([
957
- {
958
- id: createDocumentId('doc1'),
959
- score: 0.9,
960
- content: '/** Documentation */\nfunction example() { return 42; }',
961
- metadata: {
962
- type: 'file' as const,
963
- storeId,
964
- indexedAt: new Date(),
965
- path: '/src/example.ts',
966
- },
967
- },
968
- ]);
969
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
970
-
971
- const results = await searchService.search({
972
- query: 'example',
973
- stores: [storeId],
974
- mode: 'vector',
975
- limit: 10,
976
- detail: 'full',
977
- });
978
-
979
- // Should have summary, context, and full
980
- expect(results.results[0]?.summary).toBeDefined();
981
- expect(results.results[0]?.context).toBeDefined();
982
- expect(results.results[0]?.full).toBeDefined();
983
- expect(results.results[0]?.full?.completeCode).toBeDefined();
984
- });
985
-
986
- it('extracts function names correctly', async () => {
987
- vi.mocked(mockLanceStore.search).mockResolvedValue([
988
- {
989
- id: createDocumentId('doc1'),
990
- score: 0.9,
991
- content: 'export async function fetchData() { return data; }',
992
- metadata: {
993
- type: 'file' as const,
994
- storeId,
995
- indexedAt: new Date(),
996
- path: '/src/api.ts',
997
- },
998
- },
999
- ]);
1000
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1001
-
1002
- const results = await searchService.search({
1003
- query: 'fetchData',
1004
- stores: [storeId],
1005
- mode: 'vector',
1006
- limit: 10,
1007
- });
1008
-
1009
- expect(results.results[0]?.summary?.name).toBe('fetchData');
1010
- });
1011
-
1012
- it('extracts class names correctly', async () => {
1013
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1014
- {
1015
- id: createDocumentId('doc1'),
1016
- score: 0.9,
1017
- content: 'export class MyComponent { constructor() {} }',
1018
- metadata: {
1019
- type: 'file' as const,
1020
- storeId,
1021
- indexedAt: new Date(),
1022
- path: '/src/Component.ts',
1023
- },
1024
- },
1025
- ]);
1026
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1027
-
1028
- const results = await searchService.search({
1029
- query: 'MyComponent',
1030
- stores: [storeId],
1031
- mode: 'vector',
1032
- limit: 10,
1033
- });
1034
-
1035
- expect(results.results[0]?.summary?.name).toBe('MyComponent');
1036
- });
1037
- });
1038
-
1039
- describe('SearchService - Edge Cases', () => {
1040
- let mockLanceStore: LanceStore;
1041
- let mockEmbeddingEngine: EmbeddingEngine;
1042
- let searchService: SearchService;
1043
- const storeId = createStoreId('test-store');
1044
-
1045
- beforeEach(() => {
1046
- mockLanceStore = {
1047
- search: vi.fn(),
1048
- fullTextSearch: vi.fn(),
1049
- } as unknown as LanceStore;
1050
-
1051
- mockEmbeddingEngine = {
1052
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
1053
- } as unknown as EmbeddingEngine;
1054
-
1055
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
1056
- });
1057
-
1058
- it('handles empty query gracefully', async () => {
1059
- vi.mocked(mockLanceStore.search).mockResolvedValue([]);
1060
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1061
-
1062
- const results = await searchService.search({
1063
- query: '',
1064
- stores: [storeId],
1065
- mode: 'vector',
1066
- limit: 10,
1067
- });
1068
-
1069
- expect(results.results.length).toBe(0);
1070
- });
1071
-
1072
- it('handles no results gracefully', async () => {
1073
- vi.mocked(mockLanceStore.search).mockResolvedValue([]);
1074
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1075
-
1076
- const results = await searchService.search({
1077
- query: 'nonexistent term',
1078
- stores: [storeId],
1079
- mode: 'hybrid',
1080
- limit: 10,
1081
- });
1082
-
1083
- expect(results.results.length).toBe(0);
1084
- expect(results.totalResults).toBe(0);
1085
- });
1086
-
1087
- it('respects limit parameter', async () => {
1088
- const manyResults = Array.from({ length: 20 }, (_, i) => ({
1089
- id: createDocumentId(`doc${i}`),
1090
- score: 0.9 - i * 0.01,
1091
- content: `result ${i}`,
1092
- metadata: {
1093
- type: 'file' as const,
1094
- storeId,
1095
- indexedAt: new Date(),
1096
- path: `/src/file${i}.ts`,
1097
- },
1098
- }));
1099
-
1100
- vi.mocked(mockLanceStore.search).mockResolvedValue(manyResults);
1101
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1102
-
1103
- const results = await searchService.search({
1104
- query: 'test',
1105
- stores: [storeId],
1106
- mode: 'vector',
1107
- limit: 5,
1108
- });
1109
-
1110
- expect(results.results.length).toBeLessThanOrEqual(5);
1111
- });
1112
-
1113
- it('handles multiple stores correctly', async () => {
1114
- const store1 = createStoreId('store1');
1115
- const store2 = createStoreId('store2');
1116
-
1117
- vi.mocked(mockLanceStore.search).mockImplementation(async (storeId) => {
1118
- if (storeId === store1) {
1119
- return [
1120
- {
1121
- id: createDocumentId('doc1'),
1122
- score: 0.9,
1123
- content: 'from store 1',
1124
- metadata: { type: 'file' as const, storeId: store1, indexedAt: new Date() },
1125
- },
1126
- ];
1127
- }
1128
- return [
1129
- {
1130
- id: createDocumentId('doc2'),
1131
- score: 0.8,
1132
- content: 'from store 2',
1133
- metadata: { type: 'file' as const, storeId: store2, indexedAt: new Date() },
1134
- },
1135
- ];
1136
- });
1137
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1138
-
1139
- const results = await searchService.search({
1140
- query: 'test',
1141
- stores: [store1, store2],
1142
- mode: 'vector',
1143
- limit: 10,
1144
- });
1145
-
1146
- expect(results.results.length).toBe(2);
1147
- });
1148
-
1149
- it('returns timing information', async () => {
1150
- vi.mocked(mockLanceStore.search).mockResolvedValue([]);
1151
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1152
-
1153
- const results = await searchService.search({
1154
- query: 'test',
1155
- stores: [storeId],
1156
- mode: 'vector',
1157
- limit: 10,
1158
- });
1159
-
1160
- expect(results.timeMs).toBeGreaterThanOrEqual(0);
1161
- });
1162
-
1163
- it('handles threshold parameter for vector search', async () => {
1164
- // Setup: multiple results with varying scores
1165
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1166
- {
1167
- id: createDocumentId('doc1'),
1168
- score: 0.95,
1169
- content: 'high score',
1170
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1171
- },
1172
- {
1173
- id: createDocumentId('doc2'),
1174
- score: 0.5,
1175
- content: 'medium score',
1176
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1177
- },
1178
- {
1179
- id: createDocumentId('doc3'),
1180
- score: 0.3,
1181
- content: 'low score',
1182
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1183
- },
1184
- ]);
1185
-
1186
- // Search with high threshold
1187
- const results = await searchService.search({
1188
- query: 'test',
1189
- stores: [storeId],
1190
- mode: 'vector',
1191
- limit: 10,
1192
- threshold: 0.8,
1193
- });
1194
-
1195
- // Verify lanceStore.search was called (without checking threshold param - it's unused in LanceStore)
1196
- expect(vi.mocked(mockLanceStore.search)).toHaveBeenCalledWith(
1197
- storeId,
1198
- expect.anything(),
1199
- expect.anything()
1200
- );
1201
-
1202
- // Verify threshold filtering works: only high-score result should pass
1203
- // After normalization, the top result has score 1.0, and threshold 0.8 filters out lower ones
1204
- // The normalized scores are: doc1=1.0, doc2=0.31, doc3=0.0 (relative to max 0.95)
1205
- expect(results.results.length).toBe(1);
1206
- expect(results.results[0]?.id).toBe('doc1');
1207
- });
1208
- });
1209
-
1210
- describe('SearchService - Path Keyword Boosting', () => {
1211
- let mockLanceStore: LanceStore;
1212
- let mockEmbeddingEngine: EmbeddingEngine;
1213
- let searchService: SearchService;
1214
- const storeId = createStoreId('test-store');
1215
-
1216
- beforeEach(() => {
1217
- mockLanceStore = {
1218
- search: vi.fn(),
1219
- fullTextSearch: vi.fn(),
1220
- } as unknown as LanceStore;
1221
-
1222
- mockEmbeddingEngine = {
1223
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
1224
- } as unknown as EmbeddingEngine;
1225
-
1226
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
1227
- });
1228
-
1229
- it('boosts results when path contains query keywords', async () => {
1230
- // Two files with same base score, but one has "dispatcher" in the path
1231
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1232
- {
1233
- id: createDocumentId('generic-file'),
1234
- score: 0.85,
1235
- content: 'handles async operations',
1236
- metadata: {
1237
- type: 'file' as const,
1238
- storeId,
1239
- indexedAt: new Date(),
1240
- path: '/src/utils/helpers.py',
1241
- },
1242
- },
1243
- {
1244
- id: createDocumentId('dispatcher-file'),
1245
- score: 0.85,
1246
- content: 'handles async operations',
1247
- metadata: {
1248
- type: 'file' as const,
1249
- storeId,
1250
- indexedAt: new Date(),
1251
- path: '/src/async_dispatcher.py',
1252
- },
1253
- },
1254
- ]);
1255
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1256
-
1257
- const results = await searchService.search({
1258
- query: 'dispatcher',
1259
- stores: [storeId],
1260
- mode: 'hybrid',
1261
- limit: 10,
1262
- });
1263
-
1264
- // dispatcher-file should rank higher due to path keyword match
1265
- expect(results.results[0]?.id).toBe(createDocumentId('dispatcher-file'));
1266
- });
1267
-
1268
- it('boosts results with multiple path keyword matches', async () => {
1269
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1270
- {
1271
- id: createDocumentId('single-match'),
1272
- score: 0.85,
1273
- content: 'crawler implementation',
1274
- metadata: {
1275
- type: 'file' as const,
1276
- storeId,
1277
- indexedAt: new Date(),
1278
- path: '/src/crawler.py',
1279
- },
1280
- },
1281
- {
1282
- id: createDocumentId('double-match'),
1283
- score: 0.85,
1284
- content: 'crawler implementation',
1285
- metadata: {
1286
- type: 'file' as const,
1287
- storeId,
1288
- indexedAt: new Date(),
1289
- path: '/src/deep_crawling/crawler.py',
1290
- },
1291
- },
1292
- ]);
1293
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1294
-
1295
- const results = await searchService.search({
1296
- query: 'deep crawler',
1297
- stores: [storeId],
1298
- mode: 'hybrid',
1299
- limit: 10,
1300
- });
1301
-
1302
- // double-match should rank higher (both "deep" and "crawler" in path)
1303
- expect(results.results[0]?.id).toBe(createDocumentId('double-match'));
1304
- });
1305
-
1306
- it('ignores stop words when matching path keywords', async () => {
1307
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1308
- {
1309
- id: createDocumentId('doc1'),
1310
- score: 0.85,
1311
- content: 'configuration guide',
1312
- metadata: {
1313
- type: 'file' as const,
1314
- storeId,
1315
- indexedAt: new Date(),
1316
- path: '/src/config.ts',
1317
- },
1318
- },
1319
- ]);
1320
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1321
-
1322
- const results = await searchService.search({
1323
- query: 'how to configure',
1324
- stores: [storeId],
1325
- mode: 'hybrid',
1326
- limit: 10,
1327
- });
1328
-
1329
- // Should match "config" from "configure", not boost from "how" or "to"
1330
- expect(results.results.length).toBeGreaterThan(0);
1331
- });
1332
-
1333
- it('does not boost when path has no matching keywords', async () => {
1334
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1335
- {
1336
- id: createDocumentId('unrelated-path'),
1337
- score: 0.9,
1338
- content: 'dispatcher implementation details',
1339
- metadata: {
1340
- type: 'file' as const,
1341
- storeId,
1342
- indexedAt: new Date(),
1343
- path: '/src/utils/helpers.ts',
1344
- },
1345
- },
1346
- ]);
1347
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1348
-
1349
- const results = await searchService.search({
1350
- query: 'dispatcher',
1351
- stores: [storeId],
1352
- mode: 'hybrid',
1353
- limit: 10,
1354
- });
1355
-
1356
- // Should still return result (content matches), just no path boost
1357
- expect(results.results.length).toBe(1);
1358
- });
1359
- });
1360
-
1361
- describe('SearchService - Code Graph Integration', () => {
1362
- let mockLanceStore: LanceStore;
1363
- let mockEmbeddingEngine: EmbeddingEngine;
1364
- let mockCodeGraphService: { loadGraph: ReturnType<typeof vi.fn> };
1365
- let searchService: SearchService;
1366
- const storeId = createStoreId('test-store');
1367
-
1368
- beforeEach(() => {
1369
- mockLanceStore = {
1370
- search: vi.fn(),
1371
- fullTextSearch: vi.fn(),
1372
- } as unknown as LanceStore;
1373
-
1374
- mockEmbeddingEngine = {
1375
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
1376
- } as unknown as EmbeddingEngine;
1377
-
1378
- mockCodeGraphService = {
1379
- loadGraph: vi.fn(),
1380
- };
1381
-
1382
- // Create SearchService with mock codeGraphService
1383
- searchService = new SearchService(
1384
- mockLanceStore,
1385
- mockEmbeddingEngine,
1386
- mockCodeGraphService as unknown as import('./code-graph.service.js').CodeGraphService
1387
- );
1388
- });
1389
-
1390
- it('includes usage stats from code graph when detail is contextual', async () => {
1391
- // Create a mock CodeGraph with getCalledByCount and getCallsCount methods
1392
- const mockGraph = {
1393
- getCalledByCount: vi.fn().mockReturnValue(3),
1394
- getCallsCount: vi.fn().mockReturnValue(5),
1395
- getIncomingEdges: vi.fn().mockReturnValue([]),
1396
- getEdges: vi.fn().mockReturnValue([]),
1397
- };
1398
-
1399
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1400
-
1401
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1402
- {
1403
- id: createDocumentId('doc1'),
1404
- score: 0.9,
1405
- content: 'export function myFunction() { return 42; }',
1406
- metadata: {
1407
- type: 'file' as const,
1408
- storeId,
1409
- indexedAt: new Date(),
1410
- path: '/src/utils.ts',
1411
- },
1412
- },
1413
- ]);
1414
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1415
-
1416
- const results = await searchService.search({
1417
- query: 'myFunction',
1418
- stores: [storeId],
1419
- mode: 'vector',
1420
- limit: 10,
1421
- detail: 'contextual',
1422
- });
1423
-
1424
- expect(results.results.length).toBe(1);
1425
- expect(results.results[0]?.context).toBeDefined();
1426
- expect(results.results[0]?.context?.usage).toBeDefined();
1427
- expect(results.results[0]?.context?.usage?.calledBy).toBe(3);
1428
- expect(results.results[0]?.context?.usage?.calls).toBe(5);
1429
- expect(mockGraph.getCalledByCount).toHaveBeenCalledWith('/src/utils.ts:myFunction');
1430
- expect(mockGraph.getCallsCount).toHaveBeenCalledWith('/src/utils.ts:myFunction');
1431
- });
1432
-
1433
- it('returns zero usage stats when symbol is anonymous', async () => {
1434
- const mockGraph = {
1435
- getCalledByCount: vi.fn(),
1436
- getCallsCount: vi.fn(),
1437
- getIncomingEdges: vi.fn().mockReturnValue([]),
1438
- getEdges: vi.fn().mockReturnValue([]),
1439
- };
1440
-
1441
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1442
-
1443
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1444
- {
1445
- id: createDocumentId('doc1'),
1446
- score: 0.9,
1447
- // Content that matches no symbol patterns (no function/class/const keywords followed by identifiers)
1448
- content: 'This is just plain documentation text with no code symbols at all.',
1449
- metadata: {
1450
- type: 'file' as const,
1451
- storeId,
1452
- indexedAt: new Date(),
1453
- path: '/src/readme.md',
1454
- },
1455
- },
1456
- ]);
1457
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1458
-
1459
- const results = await searchService.search({
1460
- query: 'documentation text',
1461
- stores: [storeId],
1462
- mode: 'vector',
1463
- limit: 10,
1464
- detail: 'contextual',
1465
- });
1466
-
1467
- expect(results.results.length).toBe(1);
1468
- expect(results.results[0]?.context?.usage?.calledBy).toBe(0);
1469
- expect(results.results[0]?.context?.usage?.calls).toBe(0);
1470
- // Graph methods should NOT be called for anonymous symbols
1471
- expect(mockGraph.getCalledByCount).not.toHaveBeenCalled();
1472
- expect(mockGraph.getCallsCount).not.toHaveBeenCalled();
1473
- });
1474
-
1475
- it('returns zero usage stats when symbol is empty', async () => {
1476
- const mockGraph = {
1477
- getCalledByCount: vi.fn(),
1478
- getCallsCount: vi.fn(),
1479
- getIncomingEdges: vi.fn().mockReturnValue([]),
1480
- getEdges: vi.fn().mockReturnValue([]),
1481
- };
1482
-
1483
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1484
-
1485
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1486
- {
1487
- id: createDocumentId('doc1'),
1488
- score: 0.9,
1489
- content: ' \n\n ', // whitespace only content
1490
- metadata: {
1491
- type: 'file' as const,
1492
- storeId,
1493
- indexedAt: new Date(),
1494
- path: '/src/empty.ts',
1495
- },
1496
- },
1497
- ]);
1498
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1499
-
1500
- const results = await searchService.search({
1501
- query: 'empty content',
1502
- stores: [storeId],
1503
- mode: 'vector',
1504
- limit: 10,
1505
- detail: 'contextual',
1506
- });
1507
-
1508
- // Graph methods should NOT be called for symbols that can't be extracted
1509
- expect(mockGraph.getCalledByCount).not.toHaveBeenCalled();
1510
- });
1511
-
1512
- it('includes related code from graph when detail is full', async () => {
1513
- const mockGraph = {
1514
- getCalledByCount: vi.fn().mockReturnValue(2),
1515
- getCallsCount: vi.fn().mockReturnValue(1),
1516
- getIncomingEdges: vi.fn().mockReturnValue([
1517
- {
1518
- from: '/src/caller.ts:callerFunction',
1519
- to: '/src/utils.ts:myFunction',
1520
- type: 'calls',
1521
- confidence: 0.8,
1522
- },
1523
- {
1524
- from: '/src/main.ts:init',
1525
- to: '/src/utils.ts:myFunction',
1526
- type: 'calls',
1527
- confidence: 0.9,
1528
- },
1529
- ]),
1530
- getEdges: vi.fn().mockReturnValue([
1531
- {
1532
- from: '/src/utils.ts:myFunction',
1533
- to: '/src/helper.ts:helperFn',
1534
- type: 'calls',
1535
- confidence: 0.8,
1536
- },
1537
- ]),
1538
- };
1539
-
1540
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1541
-
1542
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1543
- {
1544
- id: createDocumentId('doc1'),
1545
- score: 0.9,
1546
- content:
1547
- '/** My function does stuff */\nexport function myFunction() { return helperFn(); }',
1548
- metadata: {
1549
- type: 'file' as const,
1550
- storeId,
1551
- indexedAt: new Date(),
1552
- path: '/src/utils.ts',
1553
- },
1554
- },
1555
- ]);
1556
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1557
-
1558
- const results = await searchService.search({
1559
- query: 'myFunction',
1560
- stores: [storeId],
1561
- mode: 'vector',
1562
- limit: 10,
1563
- detail: 'full',
1564
- });
1565
-
1566
- expect(results.results.length).toBe(1);
1567
- expect(results.results[0]?.full).toBeDefined();
1568
- expect(results.results[0]?.full?.relatedCode).toBeDefined();
1569
- expect(results.results[0]?.full?.relatedCode?.length).toBe(3);
1570
-
1571
- // Check incoming (callers)
1572
- const callers = results.results[0]?.full?.relatedCode?.filter(
1573
- (r) => r.relationship === 'calls this'
1574
- );
1575
- expect(callers?.length).toBe(2);
1576
- expect(
1577
- callers?.some((c) => c.file === '/src/caller.ts' && c.summary === 'callerFunction()')
1578
- ).toBe(true);
1579
- expect(callers?.some((c) => c.file === '/src/main.ts' && c.summary === 'init()')).toBe(true);
1580
-
1581
- // Check outgoing (callees)
1582
- const callees = results.results[0]?.full?.relatedCode?.filter(
1583
- (r) => r.relationship === 'called by this'
1584
- );
1585
- expect(callees?.length).toBe(1);
1586
- expect(callees?.[0]?.file).toBe('/src/helper.ts');
1587
- expect(callees?.[0]?.summary).toBe('helperFn()');
1588
- });
1589
-
1590
- it('returns empty related code for anonymous symbols', async () => {
1591
- const mockGraph = {
1592
- getCalledByCount: vi.fn(),
1593
- getCallsCount: vi.fn(),
1594
- getIncomingEdges: vi.fn(),
1595
- getEdges: vi.fn(),
1596
- };
1597
-
1598
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1599
-
1600
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1601
- {
1602
- id: createDocumentId('doc1'),
1603
- score: 0.9,
1604
- content: 'Just plain text without code symbols',
1605
- metadata: {
1606
- type: 'file' as const,
1607
- storeId,
1608
- indexedAt: new Date(),
1609
- path: '/src/notes.txt',
1610
- },
1611
- },
1612
- ]);
1613
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1614
-
1615
- const results = await searchService.search({
1616
- query: 'notes',
1617
- stores: [storeId],
1618
- mode: 'vector',
1619
- limit: 10,
1620
- detail: 'full',
1621
- });
1622
-
1623
- expect(results.results.length).toBe(1);
1624
- expect(results.results[0]?.full?.relatedCode).toEqual([]);
1625
- // Graph methods should NOT be called for anonymous symbols
1626
- expect(mockGraph.getIncomingEdges).not.toHaveBeenCalled();
1627
- expect(mockGraph.getEdges).not.toHaveBeenCalled();
1628
- });
1629
-
1630
- it('handles edges with non-calls type gracefully', async () => {
1631
- const mockGraph = {
1632
- getCalledByCount: vi.fn().mockReturnValue(0),
1633
- getCallsCount: vi.fn().mockReturnValue(0),
1634
- getIncomingEdges: vi.fn().mockReturnValue([
1635
- {
1636
- from: '/src/index.ts',
1637
- to: '/src/utils.ts:myFunction',
1638
- type: 'imports',
1639
- confidence: 1.0,
1640
- },
1641
- ]),
1642
- getEdges: vi.fn().mockReturnValue([
1643
- {
1644
- from: '/src/utils.ts:myFunction',
1645
- to: '/src/types.ts:MyInterface',
1646
- type: 'implements',
1647
- confidence: 1.0,
1648
- },
1649
- ]),
1650
- };
1651
-
1652
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1653
-
1654
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1655
- {
1656
- id: createDocumentId('doc1'),
1657
- score: 0.9,
1658
- content: 'export function myFunction() { return 42; }',
1659
- metadata: {
1660
- type: 'file' as const,
1661
- storeId,
1662
- indexedAt: new Date(),
1663
- path: '/src/utils.ts',
1664
- },
1665
- },
1666
- ]);
1667
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1668
-
1669
- const results = await searchService.search({
1670
- query: 'myFunction',
1671
- stores: [storeId],
1672
- mode: 'vector',
1673
- limit: 10,
1674
- detail: 'full',
1675
- });
1676
-
1677
- expect(results.results.length).toBe(1);
1678
- // No related code should be returned because edges are not 'calls' type
1679
- expect(results.results[0]?.full?.relatedCode).toEqual([]);
1680
- });
1681
-
1682
- it('parses node IDs without colons correctly', async () => {
1683
- const mockGraph = {
1684
- getCalledByCount: vi.fn().mockReturnValue(1),
1685
- getCallsCount: vi.fn().mockReturnValue(0),
1686
- getIncomingEdges: vi.fn().mockReturnValue([
1687
- // Edge with nodeId that has no colon (edge case)
1688
- { from: 'simpleNodeId', to: '/src/utils.ts:myFunction', type: 'calls', confidence: 0.8 },
1689
- ]),
1690
- getEdges: vi.fn().mockReturnValue([]),
1691
- };
1692
-
1693
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1694
-
1695
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1696
- {
1697
- id: createDocumentId('doc1'),
1698
- score: 0.9,
1699
- content: 'export function myFunction() { return 42; }',
1700
- metadata: {
1701
- type: 'file' as const,
1702
- storeId,
1703
- indexedAt: new Date(),
1704
- path: '/src/utils.ts',
1705
- },
1706
- },
1707
- ]);
1708
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1709
-
1710
- const results = await searchService.search({
1711
- query: 'myFunction',
1712
- stores: [storeId],
1713
- mode: 'vector',
1714
- limit: 10,
1715
- detail: 'full',
1716
- });
1717
-
1718
- expect(results.results.length).toBe(1);
1719
- const callers = results.results[0]?.full?.relatedCode?.filter(
1720
- (r) => r.relationship === 'calls this'
1721
- );
1722
- expect(callers?.length).toBe(1);
1723
- // When nodeId has no colon, file should be the whole nodeId and symbol should be empty -> 'unknown'
1724
- expect(callers?.[0]?.file).toBe('simpleNodeId');
1725
- expect(callers?.[0]?.summary).toBe('unknown');
1726
- });
1727
-
1728
- it('handles null graph gracefully', async () => {
1729
- mockCodeGraphService.loadGraph.mockResolvedValue(null);
1730
-
1731
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1732
- {
1733
- id: createDocumentId('doc1'),
1734
- score: 0.9,
1735
- content: 'export function myFunction() { return 42; }',
1736
- metadata: {
1737
- type: 'file' as const,
1738
- storeId,
1739
- indexedAt: new Date(),
1740
- path: '/src/utils.ts',
1741
- },
1742
- },
1743
- ]);
1744
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1745
-
1746
- const results = await searchService.search({
1747
- query: 'myFunction',
1748
- stores: [storeId],
1749
- mode: 'vector',
1750
- limit: 10,
1751
- detail: 'full',
1752
- });
1753
-
1754
- expect(results.results.length).toBe(1);
1755
- expect(results.results[0]?.context?.usage?.calledBy).toBe(0);
1756
- expect(results.results[0]?.context?.usage?.calls).toBe(0);
1757
- expect(results.results[0]?.full?.relatedCode).toEqual([]);
1758
- });
1759
-
1760
- it('limits related code to 10 items', async () => {
1761
- // Create 15 incoming edges
1762
- const manyIncomingEdges = Array.from({ length: 15 }, (_, i) => ({
1763
- from: `/src/file${i}.ts:func${i}`,
1764
- to: '/src/utils.ts:myFunction',
1765
- type: 'calls' as const,
1766
- confidence: 0.8,
1767
- }));
1768
-
1769
- const mockGraph = {
1770
- getCalledByCount: vi.fn().mockReturnValue(15),
1771
- getCallsCount: vi.fn().mockReturnValue(0),
1772
- getIncomingEdges: vi.fn().mockReturnValue(manyIncomingEdges),
1773
- getEdges: vi.fn().mockReturnValue([]),
1774
- };
1775
-
1776
- mockCodeGraphService.loadGraph.mockResolvedValue(mockGraph);
1777
-
1778
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1779
- {
1780
- id: createDocumentId('doc1'),
1781
- score: 0.9,
1782
- content: 'export function myFunction() { return 42; }',
1783
- metadata: {
1784
- type: 'file' as const,
1785
- storeId,
1786
- indexedAt: new Date(),
1787
- path: '/src/utils.ts',
1788
- },
1789
- },
1790
- ]);
1791
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1792
-
1793
- const results = await searchService.search({
1794
- query: 'myFunction',
1795
- stores: [storeId],
1796
- mode: 'vector',
1797
- limit: 10,
1798
- detail: 'full',
1799
- });
1800
-
1801
- expect(results.results.length).toBe(1);
1802
- // Should be limited to 10 related items
1803
- expect(results.results[0]?.full?.relatedCode?.length).toBe(10);
1804
- });
1805
- });
1806
-
1807
- describe('SearchService - Threshold Filtering', () => {
1808
- let mockLanceStore: LanceStore;
1809
- let mockEmbeddingEngine: EmbeddingEngine;
1810
- let searchService: SearchService;
1811
- const storeId = createStoreId('test-store');
1812
-
1813
- beforeEach(() => {
1814
- mockLanceStore = {
1815
- search: vi.fn(),
1816
- fullTextSearch: vi.fn(),
1817
- } as unknown as LanceStore;
1818
-
1819
- mockEmbeddingEngine = {
1820
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
1821
- } as unknown as EmbeddingEngine;
1822
-
1823
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
1824
- });
1825
-
1826
- it('applies threshold to normalized scores, not raw scores', async () => {
1827
- // Setup: 3 results with different raw scores
1828
- // In hybrid mode with RRF, ranks matter more than raw scores
1829
- // doc1 appears in both vector and FTS -> highest RRF score -> normalized to 1.0
1830
- // doc2 appears only in vector -> middle RRF score -> normalized to ~0.5
1831
- // doc3 appears only in vector, lowest rank -> lowest RRF score -> normalized to 0.0
1832
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1833
- {
1834
- id: createDocumentId('doc1'),
1835
- score: 0.9,
1836
- content: 'result 1',
1837
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1838
- },
1839
- {
1840
- id: createDocumentId('doc2'),
1841
- score: 0.7,
1842
- content: 'result 2',
1843
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1844
- },
1845
- {
1846
- id: createDocumentId('doc3'),
1847
- score: 0.5,
1848
- content: 'result 3',
1849
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1850
- },
1851
- ]);
1852
- // Add doc1 and doc2 to FTS results so they both have good RRF scores
1853
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([
1854
- {
1855
- id: createDocumentId('doc1'),
1856
- score: 0.9,
1857
- content: 'result 1',
1858
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1859
- },
1860
- {
1861
- id: createDocumentId('doc2'),
1862
- score: 0.7,
1863
- content: 'result 2',
1864
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1865
- },
1866
- ]);
1867
-
1868
- // With threshold 0.4, doc1 (1.0) and doc2 (~0.47) should pass
1869
- // doc3 (0.0) should be filtered out
1870
- const results = await searchService.search({
1871
- query: 'test query',
1872
- stores: [storeId],
1873
- mode: 'hybrid',
1874
- limit: 10,
1875
- threshold: 0.4,
1876
- });
1877
-
1878
- // Should return 2 results: scores >= 0.4 (normalized)
1879
- expect(results.results.length).toBe(2);
1880
- expect(results.results[0]?.id).toBe(createDocumentId('doc1'));
1881
- expect(results.results[1]?.id).toBe(createDocumentId('doc2'));
1882
-
1883
- // Verify normalized scores
1884
- expect(results.results[0]?.score).toBe(1.0);
1885
- expect(results.results[1]?.score).toBeGreaterThanOrEqual(0.4);
1886
-
1887
- // Verify doc3 was filtered out (its normalized score is 0.0)
1888
- expect(results.results.find((r) => r.id === createDocumentId('doc3'))).toBeUndefined();
1889
- });
1890
-
1891
- it('returns all results when threshold is 0', async () => {
1892
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1893
- {
1894
- id: createDocumentId('doc1'),
1895
- score: 0.9,
1896
- content: 'result 1',
1897
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1898
- },
1899
- {
1900
- id: createDocumentId('doc2'),
1901
- score: 0.1,
1902
- content: 'result 2',
1903
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1904
- },
1905
- ]);
1906
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1907
-
1908
- const results = await searchService.search({
1909
- query: 'test query',
1910
- stores: [storeId],
1911
- mode: 'hybrid',
1912
- limit: 10,
1913
- threshold: 0,
1914
- });
1915
-
1916
- // All results should be returned (scores >= 0)
1917
- expect(results.results.length).toBe(2);
1918
- });
1919
-
1920
- it('returns no results when threshold is higher than all scores', async () => {
1921
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1922
- {
1923
- id: createDocumentId('doc1'),
1924
- score: 0.9,
1925
- content: 'result 1',
1926
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1927
- },
1928
- {
1929
- id: createDocumentId('doc2'),
1930
- score: 0.8,
1931
- content: 'result 2',
1932
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1933
- },
1934
- ]);
1935
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
1936
-
1937
- // Threshold > 1.0 means no results pass
1938
- const results = await searchService.search({
1939
- query: 'test query',
1940
- stores: [storeId],
1941
- mode: 'hybrid',
1942
- limit: 10,
1943
- threshold: 1.1,
1944
- });
1945
-
1946
- expect(results.results.length).toBe(0);
1947
- });
1948
-
1949
- it('applies threshold in vector mode after score calculation', async () => {
1950
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1951
- {
1952
- id: createDocumentId('doc1'),
1953
- score: 0.9,
1954
- content: 'result 1',
1955
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1956
- },
1957
- {
1958
- id: createDocumentId('doc2'),
1959
- score: 0.3,
1960
- content: 'result 2',
1961
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1962
- },
1963
- ]);
1964
-
1965
- const results = await searchService.search({
1966
- query: 'test query',
1967
- stores: [storeId],
1968
- mode: 'vector',
1969
- limit: 10,
1970
- threshold: 0.5,
1971
- });
1972
-
1973
- // Only doc1 should pass (normalized score 1.0 >= 0.5)
1974
- // doc2 has normalized score 0.0 which is < 0.5
1975
- expect(results.results.length).toBe(1);
1976
- expect(results.results[0]?.id).toBe(createDocumentId('doc1'));
1977
- });
1978
-
1979
- it('maintains correct result count metadata after threshold filtering', async () => {
1980
- vi.mocked(mockLanceStore.search).mockResolvedValue([
1981
- {
1982
- id: createDocumentId('doc1'),
1983
- score: 0.9,
1984
- content: 'result 1',
1985
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1986
- },
1987
- {
1988
- id: createDocumentId('doc2'),
1989
- score: 0.5,
1990
- content: 'result 2',
1991
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1992
- },
1993
- {
1994
- id: createDocumentId('doc3'),
1995
- score: 0.1,
1996
- content: 'result 3',
1997
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
1998
- },
1999
- ]);
2000
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2001
-
2002
- const results = await searchService.search({
2003
- query: 'test query',
2004
- stores: [storeId],
2005
- mode: 'hybrid',
2006
- limit: 10,
2007
- threshold: 0.5,
2008
- });
2009
-
2010
- // Check response metadata
2011
- expect(results.totalResults).toBe(results.results.length);
2012
- expect(results.query).toBe('test query');
2013
- });
2014
- });
2015
-
2016
- describe('SearchService - Raw Score and Confidence', () => {
2017
- let mockLanceStore: LanceStore;
2018
- let mockEmbeddingEngine: EmbeddingEngine;
2019
- let searchService: SearchService;
2020
- const storeId = createStoreId('test-store');
2021
-
2022
- beforeEach(() => {
2023
- mockLanceStore = {
2024
- search: vi.fn(),
2025
- fullTextSearch: vi.fn(),
2026
- } as unknown as LanceStore;
2027
-
2028
- mockEmbeddingEngine = {
2029
- embed: vi.fn().mockResolvedValue([0.1, 0.2, 0.3]),
2030
- } as unknown as EmbeddingEngine;
2031
-
2032
- searchService = new SearchService(mockLanceStore, mockEmbeddingEngine);
2033
- });
2034
-
2035
- it('exposes rawVectorScore in rankingMetadata for hybrid search', async () => {
2036
- // Mock results with known raw vector scores
2037
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2038
- {
2039
- id: createDocumentId('doc1'),
2040
- score: 0.85, // Raw cosine similarity
2041
- content: 'vector result',
2042
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2043
- },
2044
- {
2045
- id: createDocumentId('doc2'),
2046
- score: 0.65,
2047
- content: 'another vector result',
2048
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2049
- },
2050
- ]);
2051
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2052
-
2053
- const results = await searchService.search({
2054
- query: 'test query',
2055
- stores: [storeId],
2056
- mode: 'hybrid',
2057
- limit: 10,
2058
- });
2059
-
2060
- // Verify results have rawVectorScore in rankingMetadata
2061
- expect(results.results.length).toBeGreaterThan(0);
2062
- const firstResult = results.results[0];
2063
- expect(firstResult?.rankingMetadata).toBeDefined();
2064
- expect(firstResult?.rankingMetadata?.rawVectorScore).toBeDefined();
2065
- expect(firstResult?.rankingMetadata?.rawVectorScore).toBe(0.85);
2066
- });
2067
-
2068
- it('returns confidence level based on maxRawScore', async () => {
2069
- // Mock results with high raw vector score (>= 0.5)
2070
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2071
- {
2072
- id: createDocumentId('doc1'),
2073
- score: 0.6, // High confidence threshold
2074
- content: 'high score result',
2075
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2076
- },
2077
- ]);
2078
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2079
-
2080
- const results = await searchService.search({
2081
- query: 'test query',
2082
- stores: [storeId],
2083
- mode: 'hybrid',
2084
- limit: 10,
2085
- });
2086
-
2087
- expect(results.confidence).toBe('high');
2088
- expect(results.maxRawScore).toBe(0.6);
2089
- });
2090
-
2091
- it('returns medium confidence for scores between 0.3 and 0.5', async () => {
2092
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2093
- {
2094
- id: createDocumentId('doc1'),
2095
- score: 0.4, // Medium confidence
2096
- content: 'medium score result',
2097
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2098
- },
2099
- ]);
2100
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2101
-
2102
- const results = await searchService.search({
2103
- query: 'test query',
2104
- stores: [storeId],
2105
- mode: 'hybrid',
2106
- limit: 10,
2107
- });
2108
-
2109
- expect(results.confidence).toBe('medium');
2110
- expect(results.maxRawScore).toBe(0.4);
2111
- });
2112
-
2113
- it('returns low confidence for scores below 0.3', async () => {
2114
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2115
- {
2116
- id: createDocumentId('doc1'),
2117
- score: 0.2, // Low confidence
2118
- content: 'low score result',
2119
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2120
- },
2121
- ]);
2122
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2123
-
2124
- const results = await searchService.search({
2125
- query: 'test query',
2126
- stores: [storeId],
2127
- mode: 'hybrid',
2128
- limit: 10,
2129
- });
2130
-
2131
- expect(results.confidence).toBe('low');
2132
- expect(results.maxRawScore).toBe(0.2);
2133
- });
2134
-
2135
- it('filters results with minRelevance based on raw score', async () => {
2136
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2137
- {
2138
- id: createDocumentId('doc1'),
2139
- score: 0.25, // Below minRelevance threshold
2140
- content: 'low relevance result',
2141
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2142
- },
2143
- ]);
2144
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2145
-
2146
- const results = await searchService.search({
2147
- query: 'irrelevant query',
2148
- stores: [storeId],
2149
- mode: 'hybrid',
2150
- limit: 10,
2151
- minRelevance: 0.4, // Filter out results below this raw score
2152
- });
2153
-
2154
- // Should return empty since max raw score (0.25) < minRelevance (0.4)
2155
- expect(results.results.length).toBe(0);
2156
- expect(results.confidence).toBe('low');
2157
- });
2158
-
2159
- it('returns results when maxRawScore meets minRelevance', async () => {
2160
- vi.mocked(mockLanceStore.search).mockResolvedValue([
2161
- {
2162
- id: createDocumentId('doc1'),
2163
- score: 0.5, // Above minRelevance threshold
2164
- content: 'relevant result',
2165
- metadata: { type: 'file' as const, storeId, indexedAt: new Date() },
2166
- },
2167
- ]);
2168
- vi.mocked(mockLanceStore.fullTextSearch).mockResolvedValue([]);
2169
-
2170
- const results = await searchService.search({
2171
- query: 'relevant query',
2172
- stores: [storeId],
2173
- mode: 'hybrid',
2174
- limit: 10,
2175
- minRelevance: 0.4,
2176
- });
2177
-
2178
- // Should return results since max raw score (0.5) >= minRelevance (0.4)
2179
- expect(results.results.length).toBe(1);
2180
- expect(results.confidence).toBe('high');
2181
- });
2182
- });
2183
-
2184
- describe('SearchService Environment Variables', () => {
2185
- afterEach(() => {
2186
- vi.unstubAllEnvs();
2187
- });
2188
-
2189
- it('uses default values when env vars are not set', async () => {
2190
- // Clear env vars to test defaults
2191
- vi.stubEnv('SEARCH_CONFIDENCE_HIGH', undefined as unknown as string);
2192
- vi.stubEnv('SEARCH_CONFIDENCE_MEDIUM', undefined as unknown as string);
2193
- vi.stubEnv('SEARCH_TEST_FILE_BOOST', undefined as unknown as string);
2194
-
2195
- const tempDir = await mkdtemp(join(tmpdir(), 'search-env-test-'));
2196
- const lanceStore = new LanceStore(tempDir);
2197
- const embeddingEngine = new EmbeddingEngine();
2198
- await embeddingEngine.initialize();
2199
-
2200
- const storeId = createStoreId('env-test-store');
2201
- await lanceStore.initialize(storeId);
2202
-
2203
- const text = 'test document';
2204
- const vector = await embeddingEngine.embed(text);
2205
- await lanceStore.addDocuments(storeId, [
2206
- {
2207
- id: createDocumentId('doc-1'),
2208
- content: text,
2209
- vector,
2210
- metadata: { type: 'file', storeId, indexedAt: new Date() },
2211
- },
2212
- ]);
2213
-
2214
- const searchService = new SearchService(lanceStore, embeddingEngine);
2215
-
2216
- // Should work with defaults (0.5 for high, 0.3 for medium)
2217
- const results = await searchService.search({ query: 'test', stores: [storeId] });
2218
- expect(results.results.length).toBeGreaterThan(0);
2219
- expect(results.confidence).toBeDefined();
2220
-
2221
- await rm(tempDir, { recursive: true });
2222
- });
2223
-
2224
- it('uses default test file boost when env var is not set', async () => {
2225
- vi.stubEnv('SEARCH_CONFIDENCE_HIGH', '0.5');
2226
- vi.stubEnv('SEARCH_CONFIDENCE_MEDIUM', '0.3');
2227
- vi.stubEnv('SEARCH_TEST_FILE_BOOST', undefined as unknown as string);
2228
-
2229
- const tempDir = await mkdtemp(join(tmpdir(), 'search-env-test-'));
2230
- const lanceStore = new LanceStore(tempDir);
2231
- const embeddingEngine = new EmbeddingEngine();
2232
- await embeddingEngine.initialize();
2233
-
2234
- const storeId = createStoreId('env-test-store');
2235
- await lanceStore.initialize(storeId);
2236
-
2237
- // Add a test file document with fileType: 'test'
2238
- const text = 'test document content';
2239
- const vector = await embeddingEngine.embed(text);
2240
- await lanceStore.addDocuments(storeId, [
2241
- {
2242
- id: createDocumentId('test-file'),
2243
- content: text,
2244
- vector,
2245
- metadata: {
2246
- type: 'file',
2247
- storeId,
2248
- indexedAt: new Date(),
2249
- filePath: 'tests/example.test.ts',
2250
- fileType: 'test', // Uses default SEARCH_TEST_FILE_BOOST (0.5)
2251
- },
2252
- },
2253
- ]);
2254
-
2255
- const searchService = new SearchService(lanceStore, embeddingEngine);
2256
-
2257
- // Should work with default test file boost
2258
- const results = await searchService.search({ query: 'test', stores: [storeId] });
2259
- expect(results.results.length).toBeGreaterThan(0);
2260
-
2261
- await rm(tempDir, { recursive: true });
2262
- });
2263
- });