bluera-knowledge 0.9.21

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 (652) hide show
  1. package/.claude/commands/commit.md +37 -0
  2. package/.claude/hooks/post-edit-check.sh +41 -0
  3. package/.claude/settings.local.json.example +40 -0
  4. package/.claude/skills/atomic-commits/SKILL.md +53 -0
  5. package/.claude-plugin/plugin.json +13 -0
  6. package/.editorconfig +15 -0
  7. package/.github/workflows/auto-release.yml +59 -0
  8. package/.github/workflows/ci.yml +142 -0
  9. package/.github/workflows/release.yml +66 -0
  10. package/.github/workflows/update-marketplace.yml +96 -0
  11. package/.husky/pre-commit +47 -0
  12. package/.husky/pre-push +29 -0
  13. package/.versionrc.json +28 -0
  14. package/CHANGELOG.md +410 -0
  15. package/CLAUDE.md +109 -0
  16. package/LICENSE +21 -0
  17. package/NOTICE +47 -0
  18. package/README.md +1546 -0
  19. package/SECURITY.md +65 -0
  20. package/bun.lock +1758 -0
  21. package/commands/add-folder.md +48 -0
  22. package/commands/add-repo.md +50 -0
  23. package/commands/cancel.md +63 -0
  24. package/commands/check-status.md +78 -0
  25. package/commands/crawl.md +51 -0
  26. package/commands/index.md +48 -0
  27. package/commands/remove-store.md +52 -0
  28. package/commands/search.md +79 -0
  29. package/commands/search.sh +63 -0
  30. package/commands/stores.md +54 -0
  31. package/commands/suggest.md +82 -0
  32. package/dist/chunk-5QMHZUC4.js +3617 -0
  33. package/dist/chunk-5QMHZUC4.js.map +1 -0
  34. package/dist/chunk-BICFAWMN.js +656 -0
  35. package/dist/chunk-BICFAWMN.js.map +1 -0
  36. package/dist/chunk-J7J6LXOJ.js +958 -0
  37. package/dist/chunk-J7J6LXOJ.js.map +1 -0
  38. package/dist/chunk-L2YVNC63.js +59 -0
  39. package/dist/chunk-L2YVNC63.js.map +1 -0
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.js +1429 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/mcp/server.d.ts +15 -0
  44. package/dist/mcp/server.js +11 -0
  45. package/dist/mcp/server.js.map +1 -0
  46. package/dist/watch.service-YAIKKDCF.js +7 -0
  47. package/dist/watch.service-YAIKKDCF.js.map +1 -0
  48. package/dist/workers/background-worker-cli.d.ts +1 -0
  49. package/dist/workers/background-worker-cli.js +310 -0
  50. package/dist/workers/background-worker-cli.js.map +1 -0
  51. package/docs/plans/2024-12-17-ai-search-quality-implementation.md +752 -0
  52. package/docs/plans/2024-12-17-ai-search-quality-testing-design.md +201 -0
  53. package/docs/plans/2025-12-16-bluera-knowledge-cli.md +2951 -0
  54. package/docs/plans/2025-12-16-phase2-features.md +1518 -0
  55. package/docs/plans/2025-12-17-hil-implementation.md +926 -0
  56. package/docs/plans/2025-12-17-hil-quality-testing.md +224 -0
  57. package/docs/plans/2025-12-17-search-quality-phase1-implementation.md +1416 -0
  58. package/docs/plans/2025-12-17-search-quality-testing-v2-design.md +212 -0
  59. package/docs/plans/2025-12-28-ai-agent-optimization.md +1630 -0
  60. package/eslint-rules/require-skip-comment.js +81 -0
  61. package/eslint.config.js +61 -0
  62. package/hooks/check-dependencies.sh +110 -0
  63. package/hooks/format-search-results.py +132 -0
  64. package/hooks/hooks.json +27 -0
  65. package/hooks/job-status-hook.sh +51 -0
  66. package/knip.json +43 -0
  67. package/mcp.plugin.json +12 -0
  68. package/package.json +103 -0
  69. package/python/crawl_worker.py +275 -0
  70. package/python/requirements.txt +2 -0
  71. package/scripts/readme-version-updater.cjs +18 -0
  72. package/skills/advanced-workflows/SKILL.md +273 -0
  73. package/skills/atomic-commits/SKILL.md +77 -0
  74. package/skills/knowledge-search/SKILL.md +54 -0
  75. package/skills/search-optimization/SKILL.md +396 -0
  76. package/skills/store-lifecycle/SKILL.md +470 -0
  77. package/skills/when-to-query/SKILL.md +66 -0
  78. package/src/analysis/ast-parser.test.ts +423 -0
  79. package/src/analysis/ast-parser.ts +192 -0
  80. package/src/analysis/code-graph.test.ts +698 -0
  81. package/src/analysis/code-graph.ts +245 -0
  82. package/src/analysis/dependency-usage-analyzer.test.ts +799 -0
  83. package/src/analysis/dependency-usage-analyzer.ts +405 -0
  84. package/src/analysis/go-ast-parser.test.ts +531 -0
  85. package/src/analysis/go-ast-parser.ts +478 -0
  86. package/src/analysis/parser-factory.test.ts +132 -0
  87. package/src/analysis/parser-factory.ts +44 -0
  88. package/src/analysis/python-ast-parser.test.ts +210 -0
  89. package/src/analysis/python-ast-parser.ts +34 -0
  90. package/src/analysis/repo-url-resolver.test.ts +533 -0
  91. package/src/analysis/repo-url-resolver.ts +233 -0
  92. package/src/analysis/rust-ast-parser.test.ts +568 -0
  93. package/src/analysis/rust-ast-parser.ts +477 -0
  94. package/src/analysis/tree-sitter-parser.test.ts +297 -0
  95. package/src/analysis/tree-sitter-parser.ts +223 -0
  96. package/src/cli/commands/crawl.test.ts +942 -0
  97. package/src/cli/commands/crawl.ts +141 -0
  98. package/src/cli/commands/index-cmd.test.ts +722 -0
  99. package/src/cli/commands/index-cmd.ts +105 -0
  100. package/src/cli/commands/mcp.test.ts +218 -0
  101. package/src/cli/commands/mcp.ts +18 -0
  102. package/src/cli/commands/plugin-api.test.ts +313 -0
  103. package/src/cli/commands/plugin-api.ts +45 -0
  104. package/src/cli/commands/search.test.ts +911 -0
  105. package/src/cli/commands/search.ts +113 -0
  106. package/src/cli/commands/serve.test.ts +329 -0
  107. package/src/cli/commands/serve.ts +28 -0
  108. package/src/cli/commands/setup.test.ts +820 -0
  109. package/src/cli/commands/setup.ts +153 -0
  110. package/src/cli/commands/store.test.ts +1003 -0
  111. package/src/cli/commands/store.ts +167 -0
  112. package/src/cli/index.ts +7 -0
  113. package/src/cli/program.ts +59 -0
  114. package/src/crawl/article-converter.test.ts +604 -0
  115. package/src/crawl/article-converter.ts +98 -0
  116. package/src/crawl/bridge.test.ts +674 -0
  117. package/src/crawl/bridge.ts +236 -0
  118. package/src/crawl/claude-client.test.ts +663 -0
  119. package/src/crawl/claude-client.ts +234 -0
  120. package/src/crawl/intelligent-crawler.test.ts +931 -0
  121. package/src/crawl/intelligent-crawler.ts +428 -0
  122. package/src/crawl/markdown-utils.test.ts +703 -0
  123. package/src/crawl/markdown-utils.ts +228 -0
  124. package/src/crawl/schemas.ts +114 -0
  125. package/src/db/embeddings.test.ts +63 -0
  126. package/src/db/embeddings.ts +69 -0
  127. package/src/db/index.ts +2 -0
  128. package/src/db/lance.test.ts +390 -0
  129. package/src/db/lance.ts +164 -0
  130. package/src/defaults/repos.ts +67 -0
  131. package/src/index.ts +107 -0
  132. package/src/mcp/cache.test.ts +202 -0
  133. package/src/mcp/cache.ts +103 -0
  134. package/src/mcp/commands/index.ts +20 -0
  135. package/src/mcp/commands/job.commands.ts +54 -0
  136. package/src/mcp/commands/meta.commands.ts +54 -0
  137. package/src/mcp/commands/registry.ts +183 -0
  138. package/src/mcp/commands/store.commands.ts +75 -0
  139. package/src/mcp/handlers/execute.handler.test.ts +179 -0
  140. package/src/mcp/handlers/execute.handler.ts +24 -0
  141. package/src/mcp/handlers/index.ts +43 -0
  142. package/src/mcp/handlers/job.handler.test.ts +189 -0
  143. package/src/mcp/handlers/job.handler.ts +116 -0
  144. package/src/mcp/handlers/search.handler.test.ts +334 -0
  145. package/src/mcp/handlers/search.handler.ts +209 -0
  146. package/src/mcp/handlers/store.handler.test.ts +415 -0
  147. package/src/mcp/handlers/store.handler.ts +295 -0
  148. package/src/mcp/schemas/index.test.ts +315 -0
  149. package/src/mcp/schemas/index.ts +138 -0
  150. package/src/mcp/server.test.ts +36 -0
  151. package/src/mcp/server.ts +162 -0
  152. package/src/mcp/types.ts +41 -0
  153. package/src/plugin/commands.test.ts +789 -0
  154. package/src/plugin/commands.ts +257 -0
  155. package/src/plugin/dependency-analyzer.test.ts +380 -0
  156. package/src/plugin/dependency-analyzer.ts +147 -0
  157. package/src/plugin/git-clone.test.ts +332 -0
  158. package/src/plugin/git-clone.ts +57 -0
  159. package/src/server/app.test.ts +752 -0
  160. package/src/server/app.ts +119 -0
  161. package/src/server/index.test.ts +477 -0
  162. package/src/server/index.ts +1 -0
  163. package/src/services/chunking.service.test.ts +363 -0
  164. package/src/services/chunking.service.ts +350 -0
  165. package/src/services/code-graph.service.test.ts +304 -0
  166. package/src/services/code-graph.service.ts +302 -0
  167. package/src/services/code-unit.service.test.ts +596 -0
  168. package/src/services/code-unit.service.ts +115 -0
  169. package/src/services/config.service.test.ts +127 -0
  170. package/src/services/config.service.ts +69 -0
  171. package/src/services/index.service.test.ts +1002 -0
  172. package/src/services/index.service.ts +266 -0
  173. package/src/services/index.ts +75 -0
  174. package/src/services/job.service.test.ts +418 -0
  175. package/src/services/job.service.ts +246 -0
  176. package/src/services/project-root.service.test.ts +506 -0
  177. package/src/services/project-root.service.ts +112 -0
  178. package/src/services/search.service.test.ts +1105 -0
  179. package/src/services/search.service.ts +892 -0
  180. package/src/services/services.test.ts +38 -0
  181. package/src/services/snippet.service.test.ts +205 -0
  182. package/src/services/snippet.service.ts +166 -0
  183. package/src/services/store.service.test.ts +474 -0
  184. package/src/services/store.service.ts +225 -0
  185. package/src/services/watch.service.test.ts +553 -0
  186. package/src/services/watch.service.ts +71 -0
  187. package/src/types/brands.test.ts +45 -0
  188. package/src/types/brands.ts +32 -0
  189. package/src/types/config.ts +79 -0
  190. package/src/types/document.ts +30 -0
  191. package/src/types/index.ts +66 -0
  192. package/src/types/job.ts +46 -0
  193. package/src/types/progress.ts +9 -0
  194. package/src/types/result.test.ts +44 -0
  195. package/src/types/result.ts +41 -0
  196. package/src/types/search.ts +95 -0
  197. package/src/types/store.test.ts +69 -0
  198. package/src/types/store.ts +47 -0
  199. package/src/utils/type-guards.test.ts +346 -0
  200. package/src/utils/type-guards.ts +61 -0
  201. package/src/workers/background-worker-cli.ts +105 -0
  202. package/src/workers/background-worker.test.ts +178 -0
  203. package/src/workers/background-worker.ts +294 -0
  204. package/src/workers/spawn-worker.test.ts +128 -0
  205. package/src/workers/spawn-worker.ts +49 -0
  206. package/tests/analysis/ast-parser.test.ts +98 -0
  207. package/tests/analysis/code-graph.test.ts +60 -0
  208. package/tests/fixtures/README.md +114 -0
  209. package/tests/fixtures/code-snippets/api/error-handling.ts +267 -0
  210. package/tests/fixtures/code-snippets/api/rest-controller.ts +303 -0
  211. package/tests/fixtures/code-snippets/auth/jwt-auth.ts +213 -0
  212. package/tests/fixtures/code-snippets/auth/oauth-flow.ts +245 -0
  213. package/tests/fixtures/code-snippets/database/repository-pattern.ts +272 -0
  214. package/tests/fixtures/corpus/VERSION.md +25 -0
  215. package/tests/fixtures/corpus/articles/jwt-authentication.md +97 -0
  216. package/tests/fixtures/corpus/articles/react-hooks-patterns.md +127 -0
  217. package/tests/fixtures/corpus/articles/typescript-generics.md +111 -0
  218. package/tests/fixtures/corpus/documentation/express-middleware.md +71 -0
  219. package/tests/fixtures/corpus/documentation/express-routing.md +83 -0
  220. package/tests/fixtures/corpus/documentation/node-streams.md +78 -0
  221. package/tests/fixtures/corpus/oss-repos/express/History.md +3871 -0
  222. package/tests/fixtures/corpus/oss-repos/express/LICENSE +24 -0
  223. package/tests/fixtures/corpus/oss-repos/express/Readme.md +276 -0
  224. package/tests/fixtures/corpus/oss-repos/express/SECURITY.md +56 -0
  225. package/tests/fixtures/corpus/oss-repos/express/benchmarks/Makefile +17 -0
  226. package/tests/fixtures/corpus/oss-repos/express/benchmarks/README.md +34 -0
  227. package/tests/fixtures/corpus/oss-repos/express/benchmarks/middleware.js +20 -0
  228. package/tests/fixtures/corpus/oss-repos/express/benchmarks/run +18 -0
  229. package/tests/fixtures/corpus/oss-repos/express/examples/README.md +29 -0
  230. package/tests/fixtures/corpus/oss-repos/express/examples/auth/index.js +134 -0
  231. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/foot.ejs +2 -0
  232. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/head.ejs +20 -0
  233. package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/login.ejs +21 -0
  234. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/db.js +9 -0
  235. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/index.js +46 -0
  236. package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/users.js +19 -0
  237. package/tests/fixtures/corpus/oss-repos/express/examples/cookie-sessions/index.js +25 -0
  238. package/tests/fixtures/corpus/oss-repos/express/examples/cookies/index.js +53 -0
  239. 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 +2 -0
  240. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/amazing.txt +1 -0
  241. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/notes/groceries.txt +3 -0
  242. package/tests/fixtures/corpus/oss-repos/express/examples/downloads/index.js +40 -0
  243. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/index.js +57 -0
  244. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/public/stylesheets/style.css +4 -0
  245. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/footer.html +2 -0
  246. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/header.html +9 -0
  247. package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/users.html +10 -0
  248. package/tests/fixtures/corpus/oss-repos/express/examples/error/index.js +53 -0
  249. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/index.js +103 -0
  250. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/404.ejs +3 -0
  251. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/500.ejs +8 -0
  252. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/error_header.ejs +10 -0
  253. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/footer.ejs +2 -0
  254. package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/index.ejs +20 -0
  255. package/tests/fixtures/corpus/oss-repos/express/examples/hello-world/index.js +15 -0
  256. package/tests/fixtures/corpus/oss-repos/express/examples/markdown/index.js +44 -0
  257. package/tests/fixtures/corpus/oss-repos/express/examples/markdown/views/index.md +4 -0
  258. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v1.js +15 -0
  259. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v2.js +15 -0
  260. package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/index.js +18 -0
  261. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/main/index.js +5 -0
  262. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/index.js +31 -0
  263. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/edit.ejs +17 -0
  264. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/show.ejs +15 -0
  265. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/index.js +41 -0
  266. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/edit.hbs +27 -0
  267. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/list.hbs +18 -0
  268. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/show.hbs +31 -0
  269. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user-pet/index.js +22 -0
  270. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/db.js +16 -0
  271. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/index.js +95 -0
  272. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/lib/boot.js +83 -0
  273. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/public/style.css +14 -0
  274. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/404.ejs +13 -0
  275. package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/5xx.ejs +13 -0
  276. package/tests/fixtures/corpus/oss-repos/express/examples/online/index.js +61 -0
  277. package/tests/fixtures/corpus/oss-repos/express/examples/params/index.js +74 -0
  278. package/tests/fixtures/corpus/oss-repos/express/examples/resource/index.js +95 -0
  279. package/tests/fixtures/corpus/oss-repos/express/examples/route-map/index.js +75 -0
  280. package/tests/fixtures/corpus/oss-repos/express/examples/route-middleware/index.js +90 -0
  281. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/index.js +55 -0
  282. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/post.js +13 -0
  283. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/public/style.css +24 -0
  284. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/site.js +5 -0
  285. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/user.js +47 -0
  286. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/footer.ejs +2 -0
  287. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/header.ejs +9 -0
  288. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/index.ejs +10 -0
  289. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/posts/index.ejs +12 -0
  290. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/edit.ejs +23 -0
  291. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/index.ejs +14 -0
  292. package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/view.ejs +9 -0
  293. package/tests/fixtures/corpus/oss-repos/express/examples/search/index.js +61 -0
  294. package/tests/fixtures/corpus/oss-repos/express/examples/search/public/client.js +15 -0
  295. package/tests/fixtures/corpus/oss-repos/express/examples/search/public/index.html +21 -0
  296. package/tests/fixtures/corpus/oss-repos/express/examples/session/index.js +37 -0
  297. package/tests/fixtures/corpus/oss-repos/express/examples/session/redis.js +39 -0
  298. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/index.js +43 -0
  299. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/css/style.css +3 -0
  300. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/hello.txt +1 -0
  301. package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/js/app.js +1 -0
  302. package/tests/fixtures/corpus/oss-repos/express/examples/vhost/index.js +53 -0
  303. package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/github-view.js +53 -0
  304. package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/index.js +48 -0
  305. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/index.js +155 -0
  306. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/user.js +36 -0
  307. package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/views/index.ejs +20 -0
  308. package/tests/fixtures/corpus/oss-repos/express/examples/web-service/index.js +117 -0
  309. package/tests/fixtures/corpus/oss-repos/express/index.js +11 -0
  310. package/tests/fixtures/corpus/oss-repos/express/lib/application.js +631 -0
  311. package/tests/fixtures/corpus/oss-repos/express/lib/express.js +81 -0
  312. package/tests/fixtures/corpus/oss-repos/express/lib/request.js +514 -0
  313. package/tests/fixtures/corpus/oss-repos/express/lib/response.js +1053 -0
  314. package/tests/fixtures/corpus/oss-repos/express/lib/utils.js +271 -0
  315. package/tests/fixtures/corpus/oss-repos/express/lib/view.js +205 -0
  316. package/tests/fixtures/corpus/oss-repos/express/package.json +99 -0
  317. package/tests/fixtures/corpus/oss-repos/express/test/Route.js +274 -0
  318. package/tests/fixtures/corpus/oss-repos/express/test/Router.js +636 -0
  319. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/auth.js +117 -0
  320. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/content-negotiation.js +49 -0
  321. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookie-sessions.js +38 -0
  322. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookies.js +71 -0
  323. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/downloads.js +47 -0
  324. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/ejs.js +17 -0
  325. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error-pages.js +99 -0
  326. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error.js +29 -0
  327. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/hello-world.js +21 -0
  328. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/markdown.js +21 -0
  329. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/multi-router.js +44 -0
  330. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/mvc.js +132 -0
  331. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/params.js +44 -0
  332. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/resource.js +68 -0
  333. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-map.js +45 -0
  334. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-separation.js +97 -0
  335. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/vhost.js +46 -0
  336. package/tests/fixtures/corpus/oss-repos/express/test/acceptance/web-service.js +105 -0
  337. package/tests/fixtures/corpus/oss-repos/express/test/app.all.js +38 -0
  338. package/tests/fixtures/corpus/oss-repos/express/test/app.engine.js +83 -0
  339. package/tests/fixtures/corpus/oss-repos/express/test/app.head.js +66 -0
  340. package/tests/fixtures/corpus/oss-repos/express/test/app.js +120 -0
  341. package/tests/fixtures/corpus/oss-repos/express/test/app.listen.js +55 -0
  342. package/tests/fixtures/corpus/oss-repos/express/test/app.locals.js +26 -0
  343. package/tests/fixtures/corpus/oss-repos/express/test/app.options.js +116 -0
  344. package/tests/fixtures/corpus/oss-repos/express/test/app.param.js +323 -0
  345. package/tests/fixtures/corpus/oss-repos/express/test/app.render.js +374 -0
  346. package/tests/fixtures/corpus/oss-repos/express/test/app.request.js +143 -0
  347. package/tests/fixtures/corpus/oss-repos/express/test/app.response.js +143 -0
  348. package/tests/fixtures/corpus/oss-repos/express/test/app.route.js +197 -0
  349. package/tests/fixtures/corpus/oss-repos/express/test/app.router.js +1217 -0
  350. package/tests/fixtures/corpus/oss-repos/express/test/app.routes.error.js +62 -0
  351. package/tests/fixtures/corpus/oss-repos/express/test/app.use.js +542 -0
  352. package/tests/fixtures/corpus/oss-repos/express/test/config.js +207 -0
  353. package/tests/fixtures/corpus/oss-repos/express/test/exports.js +82 -0
  354. package/tests/fixtures/corpus/oss-repos/express/test/express.json.js +755 -0
  355. package/tests/fixtures/corpus/oss-repos/express/test/express.raw.js +513 -0
  356. package/tests/fixtures/corpus/oss-repos/express/test/express.static.js +815 -0
  357. package/tests/fixtures/corpus/oss-repos/express/test/express.text.js +566 -0
  358. package/tests/fixtures/corpus/oss-repos/express/test/express.urlencoded.js +828 -0
  359. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/% of dogs.txt +1 -0
  360. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/.name +1 -0
  361. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/index.html +1 -0
  362. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/post/index.tmpl +1 -0
  363. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/broken.send +0 -0
  364. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/name.tmpl +1 -0
  365. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/user.tmpl +1 -0
  366. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/email.tmpl +1 -0
  367. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/empty.txt +0 -0
  368. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/local_layout/user.tmpl +1 -0
  369. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.tmpl +1 -0
  370. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.txt +1 -0
  371. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/nums.txt +1 -0
  372. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/pets/names.txt +1 -0
  373. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/snow /342/230/203/.gitkeep +0 -0
  374. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.html +1 -0
  375. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.txt +1 -0
  376. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.html +1 -0
  377. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.tmpl +1 -0
  378. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/index.html +1 -0
  379. package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/tobi.txt +1 -0
  380. package/tests/fixtures/corpus/oss-repos/express/test/middleware.basic.js +42 -0
  381. package/tests/fixtures/corpus/oss-repos/express/test/regression.js +20 -0
  382. package/tests/fixtures/corpus/oss-repos/express/test/req.accepts.js +125 -0
  383. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsCharsets.js +50 -0
  384. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsEncodings.js +39 -0
  385. package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsLanguages.js +57 -0
  386. package/tests/fixtures/corpus/oss-repos/express/test/req.baseUrl.js +88 -0
  387. package/tests/fixtures/corpus/oss-repos/express/test/req.fresh.js +70 -0
  388. package/tests/fixtures/corpus/oss-repos/express/test/req.get.js +60 -0
  389. package/tests/fixtures/corpus/oss-repos/express/test/req.host.js +156 -0
  390. package/tests/fixtures/corpus/oss-repos/express/test/req.hostname.js +188 -0
  391. package/tests/fixtures/corpus/oss-repos/express/test/req.ip.js +113 -0
  392. package/tests/fixtures/corpus/oss-repos/express/test/req.ips.js +71 -0
  393. package/tests/fixtures/corpus/oss-repos/express/test/req.is.js +169 -0
  394. package/tests/fixtures/corpus/oss-repos/express/test/req.path.js +20 -0
  395. package/tests/fixtures/corpus/oss-repos/express/test/req.protocol.js +113 -0
  396. package/tests/fixtures/corpus/oss-repos/express/test/req.query.js +106 -0
  397. package/tests/fixtures/corpus/oss-repos/express/test/req.range.js +104 -0
  398. package/tests/fixtures/corpus/oss-repos/express/test/req.route.js +28 -0
  399. package/tests/fixtures/corpus/oss-repos/express/test/req.secure.js +101 -0
  400. package/tests/fixtures/corpus/oss-repos/express/test/req.signedCookies.js +37 -0
  401. package/tests/fixtures/corpus/oss-repos/express/test/req.stale.js +50 -0
  402. package/tests/fixtures/corpus/oss-repos/express/test/req.subdomains.js +173 -0
  403. package/tests/fixtures/corpus/oss-repos/express/test/req.xhr.js +42 -0
  404. package/tests/fixtures/corpus/oss-repos/express/test/res.append.js +116 -0
  405. package/tests/fixtures/corpus/oss-repos/express/test/res.attachment.js +79 -0
  406. package/tests/fixtures/corpus/oss-repos/express/test/res.clearCookie.js +62 -0
  407. package/tests/fixtures/corpus/oss-repos/express/test/res.cookie.js +295 -0
  408. package/tests/fixtures/corpus/oss-repos/express/test/res.download.js +487 -0
  409. package/tests/fixtures/corpus/oss-repos/express/test/res.format.js +248 -0
  410. package/tests/fixtures/corpus/oss-repos/express/test/res.get.js +21 -0
  411. package/tests/fixtures/corpus/oss-repos/express/test/res.json.js +186 -0
  412. package/tests/fixtures/corpus/oss-repos/express/test/res.jsonp.js +344 -0
  413. package/tests/fixtures/corpus/oss-repos/express/test/res.links.js +65 -0
  414. package/tests/fixtures/corpus/oss-repos/express/test/res.locals.js +40 -0
  415. package/tests/fixtures/corpus/oss-repos/express/test/res.location.js +316 -0
  416. package/tests/fixtures/corpus/oss-repos/express/test/res.redirect.js +214 -0
  417. package/tests/fixtures/corpus/oss-repos/express/test/res.render.js +367 -0
  418. package/tests/fixtures/corpus/oss-repos/express/test/res.send.js +569 -0
  419. package/tests/fixtures/corpus/oss-repos/express/test/res.sendFile.js +913 -0
  420. package/tests/fixtures/corpus/oss-repos/express/test/res.sendStatus.js +44 -0
  421. package/tests/fixtures/corpus/oss-repos/express/test/res.set.js +124 -0
  422. package/tests/fixtures/corpus/oss-repos/express/test/res.status.js +206 -0
  423. package/tests/fixtures/corpus/oss-repos/express/test/res.type.js +46 -0
  424. package/tests/fixtures/corpus/oss-repos/express/test/res.vary.js +90 -0
  425. package/tests/fixtures/corpus/oss-repos/express/test/support/env.js +3 -0
  426. package/tests/fixtures/corpus/oss-repos/express/test/support/tmpl.js +36 -0
  427. package/tests/fixtures/corpus/oss-repos/express/test/support/utils.js +86 -0
  428. package/tests/fixtures/corpus/oss-repos/express/test/utils.js +83 -0
  429. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/Dockerfile +11 -0
  430. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/devcontainer.json +21 -0
  431. package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/docker-compose.yml +18 -0
  432. package/tests/fixtures/corpus/oss-repos/hono/.eslintignore +1 -0
  433. package/tests/fixtures/corpus/oss-repos/hono/.eslintrc.cjs +9 -0
  434. package/tests/fixtures/corpus/oss-repos/hono/.gitpod.yml +9 -0
  435. package/tests/fixtures/corpus/oss-repos/hono/.prettierrc +9 -0
  436. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-default.ts +15 -0
  437. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-dom.ts +15 -0
  438. package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/setup-vitest.ts +47 -0
  439. package/tests/fixtures/corpus/oss-repos/hono/LICENSE +21 -0
  440. package/tests/fixtures/corpus/oss-repos/hono/README.md +91 -0
  441. package/tests/fixtures/corpus/oss-repos/hono/build.ts +80 -0
  442. package/tests/fixtures/corpus/oss-repos/hono/bun.lockb +0 -0
  443. package/tests/fixtures/corpus/oss-repos/hono/bunfig.toml +7 -0
  444. package/tests/fixtures/corpus/oss-repos/hono/codecov.yml +13 -0
  445. package/tests/fixtures/corpus/oss-repos/hono/docs/CODE_OF_CONDUCT.md +128 -0
  446. package/tests/fixtures/corpus/oss-repos/hono/docs/CONTRIBUTING.md +62 -0
  447. package/tests/fixtures/corpus/oss-repos/hono/docs/MIGRATION.md +295 -0
  448. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.png +0 -0
  449. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.pxm +0 -0
  450. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.svg +6 -0
  451. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.png +0 -0
  452. package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.pxm +0 -0
  453. package/tests/fixtures/corpus/oss-repos/hono/jsr.json +119 -0
  454. package/tests/fixtures/corpus/oss-repos/hono/package.cjs.json +3 -0
  455. package/tests/fixtures/corpus/oss-repos/hono/package.json +650 -0
  456. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +492 -0
  457. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/index.ts +13 -0
  458. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/types.ts +144 -0
  459. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/conninfo.ts +28 -0
  460. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/index.ts +9 -0
  461. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/serve-static.ts +35 -0
  462. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/server.ts +30 -0
  463. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/ssg.ts +27 -0
  464. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/websocket.ts +110 -0
  465. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +120 -0
  466. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/index.ts +7 -0
  467. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/conninfo.ts +7 -0
  468. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/index.ts +8 -0
  469. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static-module.ts +12 -0
  470. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +39 -0
  471. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/utils.ts +50 -0
  472. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/websocket.ts +50 -0
  473. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/conninfo.ts +17 -0
  474. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/deno.d.ts +28 -0
  475. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/index.ts +9 -0
  476. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/serve-static.ts +40 -0
  477. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/ssg.ts +27 -0
  478. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/websocket.ts +51 -0
  479. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/conninfo.ts +15 -0
  480. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/handler.ts +189 -0
  481. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/index.ts +14 -0
  482. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/handler.ts +10 -0
  483. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/index.ts +6 -0
  484. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/mod.ts +1 -0
  485. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/handler.ts +34 -0
  486. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/index.ts +5 -0
  487. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/types.ts +14 -0
  488. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/conninfo.ts +8 -0
  489. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/handler.ts +9 -0
  490. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/index.ts +7 -0
  491. package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +214 -0
  492. package/tests/fixtures/corpus/oss-repos/hono/src/client/index.ts +14 -0
  493. package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +180 -0
  494. package/tests/fixtures/corpus/oss-repos/hono/src/client/utils.ts +54 -0
  495. package/tests/fixtures/corpus/oss-repos/hono/src/compose.ts +94 -0
  496. package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +914 -0
  497. package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +81 -0
  498. package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/index.ts +6 -0
  499. package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +85 -0
  500. package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/index.ts +6 -0
  501. package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/types.ts +45 -0
  502. package/tests/fixtures/corpus/oss-repos/hono/src/helper/cookie/index.ts +130 -0
  503. package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/common.ts +243 -0
  504. package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +220 -0
  505. package/tests/fixtures/corpus/oss-repos/hono/src/helper/dev/index.ts +79 -0
  506. package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +246 -0
  507. package/tests/fixtures/corpus/oss-repos/hono/src/helper/html/index.ts +56 -0
  508. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/index.ts +13 -0
  509. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/middleware.ts +79 -0
  510. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +388 -0
  511. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/utils.ts +71 -0
  512. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/index.ts +9 -0
  513. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/sse.ts +89 -0
  514. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/stream.ts +36 -0
  515. package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/text.ts +15 -0
  516. package/tests/fixtures/corpus/oss-repos/hono/src/helper/testing/index.ts +26 -0
  517. package/tests/fixtures/corpus/oss-repos/hono/src/helper/websocket/index.ts +57 -0
  518. package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +523 -0
  519. package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +34 -0
  520. package/tests/fixtures/corpus/oss-repos/hono/src/http-exception.ts +78 -0
  521. package/tests/fixtures/corpus/oss-repos/hono/src/index.ts +51 -0
  522. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/base.ts +419 -0
  523. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/children.ts +20 -0
  524. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/components.ts +195 -0
  525. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/constants.ts +5 -0
  526. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/context.ts +50 -0
  527. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/client.ts +89 -0
  528. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/components.ts +39 -0
  529. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/context.ts +52 -0
  530. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +246 -0
  531. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/hooks/index.ts +91 -0
  532. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/index.ts +159 -0
  533. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +398 -0
  534. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-dev-runtime.ts +22 -0
  535. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-runtime.ts +7 -0
  536. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +772 -0
  537. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/server.ts +70 -0
  538. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/utils.ts +7 -0
  539. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +426 -0
  540. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/index.ts +114 -0
  541. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/common.ts +11 -0
  542. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +196 -0
  543. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-elements.ts +924 -0
  544. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-dev-runtime.ts +26 -0
  545. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-runtime.ts +18 -0
  546. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/streaming.ts +184 -0
  547. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/types.ts +41 -0
  548. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +36 -0
  549. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/basic-auth/index.ts +128 -0
  550. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/bearer-auth/index.ts +159 -0
  551. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/body-limit/index.ts +115 -0
  552. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cache/index.ts +127 -0
  553. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/combine/index.ts +153 -0
  554. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/compress/index.ts +79 -0
  555. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/context-storage/index.ts +55 -0
  556. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cors/index.ts +141 -0
  557. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/csrf/index.ts +90 -0
  558. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/etag/index.ts +88 -0
  559. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/ip-restriction/index.ts +178 -0
  560. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +158 -0
  561. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/index.ts +8 -0
  562. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/jwt.ts +159 -0
  563. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/logger/index.ts +93 -0
  564. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/method-override/index.ts +146 -0
  565. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/powered-by/index.ts +13 -0
  566. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/pretty-json/index.ts +50 -0
  567. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/index.ts +8 -0
  568. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/request-id.ts +59 -0
  569. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/index.ts +8 -0
  570. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/permissions-policy.ts +86 -0
  571. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/secure-headers.ts +319 -0
  572. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +140 -0
  573. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timeout/index.ts +58 -0
  574. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/index.ts +7 -0
  575. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/timing.ts +225 -0
  576. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/trailing-slash/index.ts +71 -0
  577. package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +24 -0
  578. package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +20 -0
  579. package/tests/fixtures/corpus/oss-repos/hono/src/request.ts +403 -0
  580. package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/index.ts +6 -0
  581. package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/router.ts +132 -0
  582. package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/index.ts +6 -0
  583. package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +54 -0
  584. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/index.ts +6 -0
  585. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +159 -0
  586. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +274 -0
  587. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/trie.ts +74 -0
  588. package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/index.ts +6 -0
  589. package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/router.ts +69 -0
  590. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/index.ts +6 -0
  591. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +205 -0
  592. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/router.ts +28 -0
  593. package/tests/fixtures/corpus/oss-repos/hono/src/router.ts +103 -0
  594. package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +2009 -0
  595. package/tests/fixtures/corpus/oss-repos/hono/src/utils/basic-auth.ts +26 -0
  596. package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +225 -0
  597. package/tests/fixtures/corpus/oss-repos/hono/src/utils/buffer.ts +65 -0
  598. package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +26 -0
  599. package/tests/fixtures/corpus/oss-repos/hono/src/utils/concurrent.ts +55 -0
  600. package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +230 -0
  601. package/tests/fixtures/corpus/oss-repos/hono/src/utils/crypto.ts +65 -0
  602. package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +34 -0
  603. package/tests/fixtures/corpus/oss-repos/hono/src/utils/filepath.ts +56 -0
  604. package/tests/fixtures/corpus/oss-repos/hono/src/utils/handler.ts +15 -0
  605. package/tests/fixtures/corpus/oss-repos/hono/src/utils/html.ts +182 -0
  606. package/tests/fixtures/corpus/oss-repos/hono/src/utils/http-status.ts +69 -0
  607. package/tests/fixtures/corpus/oss-repos/hono/src/utils/ipaddr.ts +113 -0
  608. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/index.ts +7 -0
  609. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwa.ts +23 -0
  610. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jws.ts +226 -0
  611. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwt.ts +114 -0
  612. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/types.ts +83 -0
  613. package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/utf8.ts +7 -0
  614. package/tests/fixtures/corpus/oss-repos/hono/src/utils/mime.ts +142 -0
  615. package/tests/fixtures/corpus/oss-repos/hono/src/utils/stream.ts +96 -0
  616. package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +105 -0
  617. package/tests/fixtures/corpus/oss-repos/hono/src/utils/url.ts +310 -0
  618. package/tests/fixtures/corpus/oss-repos/hono/src/validator/index.ts +7 -0
  619. package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +151 -0
  620. package/tests/fixtures/corpus/oss-repos/hono/tsconfig.build.json +23 -0
  621. package/tests/fixtures/corpus/oss-repos/hono/tsconfig.json +28 -0
  622. package/tests/fixtures/corpus/oss-repos/hono/vitest.config.ts +34 -0
  623. package/tests/fixtures/corpus/oss-repos/hono/yarn.lock +6232 -0
  624. package/tests/fixtures/documentation/api-reference.md +412 -0
  625. package/tests/fixtures/documentation/architecture.md +214 -0
  626. package/tests/fixtures/documentation/deployment-guide.md +420 -0
  627. package/tests/fixtures/github-readmes/express.md +133 -0
  628. package/tests/fixtures/github-readmes/nextjs.md +106 -0
  629. package/tests/fixtures/github-readmes/react.md +74 -0
  630. package/tests/fixtures/github-readmes/typescript.md +93 -0
  631. package/tests/fixtures/github-readmes/vite.md +79 -0
  632. package/tests/fixtures/queries/core.json +125 -0
  633. package/tests/fixtures/queries/extended.json +427 -0
  634. package/tests/fixtures/queries/generated/.gitkeep +0 -0
  635. package/tests/fixtures/test-server.ts +267 -0
  636. package/tests/helpers/performance-metrics.ts +387 -0
  637. package/tests/helpers/search-relevance.ts +381 -0
  638. package/tests/integration/cli-consistency.test.ts +299 -0
  639. package/tests/integration/cli.test.ts +69 -0
  640. package/tests/integration/e2e-workflow.test.ts +612 -0
  641. package/tests/integration/python-bridge.test.ts +183 -0
  642. package/tests/integration/search-quality.test.ts +718 -0
  643. package/tests/integration/stress.test.ts +326 -0
  644. package/tests/mcp/server.test.ts +15 -0
  645. package/tests/scripts/schemas/evaluation.json +44 -0
  646. package/tests/scripts/schemas/query-generation.json +21 -0
  647. package/tests/services/code-unit.service.test.ts +47 -0
  648. package/tests/services/search.progressive-context.test.ts +35 -0
  649. package/tsconfig.json +34 -0
  650. package/tsup.config.ts +15 -0
  651. package/turndown-plugin-gfm.d.ts +29 -0
  652. package/vitest.config.ts +79 -0
@@ -0,0 +1,1416 @@
1
+ # Search Quality Testing Phase 1 Implementation Plan
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** Build a valid, reproducible search quality testing system with real-world corpus and stable regression queries.
6
+
7
+ **Architecture:** Committed corpus (OSS repos + docs) indexed into dedicated test store, curated query sets in JSON, baseline comparison for regression detection.
8
+
9
+ **Tech Stack:** TypeScript, bkb CLI, Claude CLI for AI evaluation
10
+
11
+ ---
12
+
13
+ ### Task 1: Create Corpus Directory Structure
14
+
15
+ **Files:**
16
+ - Create: `tests/fixtures/corpus/VERSION.md`
17
+ - Create: `tests/fixtures/corpus/.gitkeep`
18
+
19
+ **Step 1: Create directory structure**
20
+
21
+ ```bash
22
+ mkdir -p tests/fixtures/corpus/oss-repos
23
+ mkdir -p tests/fixtures/corpus/documentation
24
+ mkdir -p tests/fixtures/corpus/articles
25
+ ```
26
+
27
+ **Step 2: Create VERSION.md**
28
+
29
+ Create `tests/fixtures/corpus/VERSION.md`:
30
+ ```markdown
31
+ # Test Corpus Version
32
+
33
+ ## Current Version: 1.0.0
34
+
35
+ ## Contents
36
+ - **oss-repos/zod**: Zod v3.24.0 (TypeScript schema validation)
37
+ - **oss-repos/hono**: Hono v4.6.0 (lightweight web framework)
38
+ - **documentation/**: Express.js and Node.js excerpts
39
+ - **articles/**: Curated technical articles
40
+
41
+ ## Last Updated
42
+ 2025-12-17
43
+
44
+ ## Maintenance
45
+ When updating corpus:
46
+ 1. Update version number above
47
+ 2. Update contents list
48
+ 3. Run `npm run test:corpus:index` to rebuild index
49
+ 4. Run `npm run test:search-quality -- --update-baseline` to set new baseline
50
+ ```
51
+
52
+ **Step 3: Commit**
53
+
54
+ ```bash
55
+ git add tests/fixtures/corpus/
56
+ git commit -m "chore: create corpus directory structure"
57
+ ```
58
+
59
+ ---
60
+
61
+ ### Task 2: Add Zod Repository to Corpus
62
+
63
+ **Files:**
64
+ - Create: `tests/fixtures/corpus/oss-repos/zod/` (multiple files)
65
+
66
+ **Step 1: Clone and clean Zod**
67
+
68
+ ```bash
69
+ cd tests/fixtures/corpus/oss-repos
70
+ git clone --depth 1 --branch v3.24.0 https://github.com/colinhacks/zod.git zod-temp
71
+ mv zod-temp zod
72
+ rm -rf zod/.git
73
+ rm -rf zod/node_modules
74
+ rm -rf zod/.github
75
+ rm -f zod/.gitignore zod/.gitattributes
76
+ ```
77
+
78
+ **Step 2: Keep only relevant content**
79
+
80
+ ```bash
81
+ cd zod
82
+ # Keep: README, docs, src (for code examples)
83
+ rm -rf playground deno vitest.config.ts logo.svg
84
+ # Remove test files (we want docs, not their tests)
85
+ find . -name "*.test.ts" -delete
86
+ find . -name "__tests__" -type d -exec rm -rf {} + 2>/dev/null || true
87
+ cd ../../../..
88
+ ```
89
+
90
+ **Step 3: Verify content**
91
+
92
+ ```bash
93
+ ls tests/fixtures/corpus/oss-repos/zod/
94
+ # Should show: README.md, src/, docs/ (if exists), package.json
95
+ find tests/fixtures/corpus/oss-repos/zod -name "*.md" | wc -l
96
+ # Should be at least 1 (README)
97
+ ```
98
+
99
+ **Step 4: Commit**
100
+
101
+ ```bash
102
+ git add tests/fixtures/corpus/oss-repos/zod/
103
+ git commit -m "feat(corpus): add Zod v3.24.0 to test corpus"
104
+ ```
105
+
106
+ ---
107
+
108
+ ### Task 3: Add Hono Repository to Corpus
109
+
110
+ **Files:**
111
+ - Create: `tests/fixtures/corpus/oss-repos/hono/` (multiple files)
112
+
113
+ **Step 1: Clone and clean Hono**
114
+
115
+ ```bash
116
+ cd tests/fixtures/corpus/oss-repos
117
+ git clone --depth 1 --branch v4.6.0 https://github.com/honojs/hono.git hono-temp
118
+ mv hono-temp hono
119
+ rm -rf hono/.git
120
+ rm -rf hono/node_modules
121
+ rm -rf hono/.github
122
+ rm -f hono/.gitignore hono/.gitattributes
123
+ ```
124
+
125
+ **Step 2: Keep only relevant content**
126
+
127
+ ```bash
128
+ cd hono
129
+ rm -rf runtime_tests benchmarks .vscode
130
+ find . -name "*.test.ts" -delete
131
+ find . -name "*.test.tsx" -delete
132
+ find . -name "__tests__" -type d -exec rm -rf {} + 2>/dev/null || true
133
+ cd ../../../..
134
+ ```
135
+
136
+ **Step 3: Verify content**
137
+
138
+ ```bash
139
+ ls tests/fixtures/corpus/oss-repos/hono/
140
+ find tests/fixtures/corpus/oss-repos/hono -name "*.md" | wc -l
141
+ ```
142
+
143
+ **Step 4: Commit**
144
+
145
+ ```bash
146
+ git add tests/fixtures/corpus/oss-repos/hono/
147
+ git commit -m "feat(corpus): add Hono v4.6.0 to test corpus"
148
+ ```
149
+
150
+ ---
151
+
152
+ ### Task 4: Add Documentation Excerpts
153
+
154
+ **Files:**
155
+ - Create: `tests/fixtures/corpus/documentation/express-routing.md`
156
+ - Create: `tests/fixtures/corpus/documentation/express-middleware.md`
157
+ - Create: `tests/fixtures/corpus/documentation/node-streams.md`
158
+
159
+ **Step 1: Create Express routing doc**
160
+
161
+ Create `tests/fixtures/corpus/documentation/express-routing.md`:
162
+ ```markdown
163
+ # Express Routing Guide
164
+
165
+ ## Basic Routing
166
+
167
+ Routing refers to how an application's endpoints (URIs) respond to client requests.
168
+
169
+ ```javascript
170
+ const express = require('express')
171
+ const app = express()
172
+
173
+ // respond with "hello world" when a GET request is made to the homepage
174
+ app.get('/', (req, res) => {
175
+ res.send('hello world')
176
+ })
177
+
178
+ // POST method route
179
+ app.post('/', (req, res) => {
180
+ res.send('POST request to the homepage')
181
+ })
182
+ ```
183
+
184
+ ## Route Methods
185
+
186
+ Express supports methods that correspond to all HTTP request methods: `get`, `post`, `put`, `delete`, `patch`, etc.
187
+
188
+ ```javascript
189
+ app.get('/user/:id', (req, res) => {
190
+ res.send(`User ${req.params.id}`)
191
+ })
192
+
193
+ app.put('/user/:id', (req, res) => {
194
+ res.send(`Updated user ${req.params.id}`)
195
+ })
196
+
197
+ app.delete('/user/:id', (req, res) => {
198
+ res.send(`Deleted user ${req.params.id}`)
199
+ })
200
+ ```
201
+
202
+ ## Route Parameters
203
+
204
+ Route parameters are named URL segments used to capture values at specific positions in the URL.
205
+
206
+ ```javascript
207
+ // Route path: /users/:userId/books/:bookId
208
+ // Request URL: /users/34/books/8989
209
+ // req.params: { "userId": "34", "bookId": "8989" }
210
+
211
+ app.get('/users/:userId/books/:bookId', (req, res) => {
212
+ res.send(req.params)
213
+ })
214
+ ```
215
+
216
+ ## Route Handlers
217
+
218
+ You can provide multiple callback functions that behave like middleware:
219
+
220
+ ```javascript
221
+ app.get('/example/b', (req, res, next) => {
222
+ console.log('the response will be sent by the next function ...')
223
+ next()
224
+ }, (req, res) => {
225
+ res.send('Hello from B!')
226
+ })
227
+ ```
228
+
229
+ ## express.Router
230
+
231
+ Use the `express.Router` class to create modular, mountable route handlers.
232
+
233
+ ```javascript
234
+ const router = express.Router()
235
+
236
+ router.get('/', (req, res) => {
237
+ res.send('Birds home page')
238
+ })
239
+
240
+ router.get('/about', (req, res) => {
241
+ res.send('About birds')
242
+ })
243
+
244
+ module.exports = router
245
+ ```
246
+ ```
247
+
248
+ **Step 2: Create Express middleware doc**
249
+
250
+ Create `tests/fixtures/corpus/documentation/express-middleware.md`:
251
+ ```markdown
252
+ # Express Middleware Guide
253
+
254
+ ## What is Middleware?
255
+
256
+ Middleware functions are functions that have access to the request object (`req`), the response object (`res`), and the `next` function in the application's request-response cycle.
257
+
258
+ Middleware functions can:
259
+ - Execute any code
260
+ - Make changes to the request and response objects
261
+ - End the request-response cycle
262
+ - Call the next middleware in the stack
263
+
264
+ ## Application-level Middleware
265
+
266
+ Bind application-level middleware to an instance of the app object using `app.use()` and `app.METHOD()`.
267
+
268
+ ```javascript
269
+ const express = require('express')
270
+ const app = express()
271
+
272
+ // Middleware with no mount path - executed for every request
273
+ app.use((req, res, next) => {
274
+ console.log('Time:', Date.now())
275
+ next()
276
+ })
277
+
278
+ // Middleware mounted on /user/:id
279
+ app.use('/user/:id', (req, res, next) => {
280
+ console.log('Request Type:', req.method)
281
+ next()
282
+ })
283
+ ```
284
+
285
+ ## Error-handling Middleware
286
+
287
+ Error-handling middleware always takes four arguments:
288
+
289
+ ```javascript
290
+ app.use((err, req, res, next) => {
291
+ console.error(err.stack)
292
+ res.status(500).send('Something broke!')
293
+ })
294
+ ```
295
+
296
+ ## Built-in Middleware
297
+
298
+ Express has built-in middleware functions:
299
+
300
+ - `express.static` - serves static assets
301
+ - `express.json` - parses JSON payloads
302
+ - `express.urlencoded` - parses URL-encoded payloads
303
+
304
+ ```javascript
305
+ app.use(express.json())
306
+ app.use(express.urlencoded({ extended: true }))
307
+ app.use(express.static('public'))
308
+ ```
309
+
310
+ ## Third-party Middleware
311
+
312
+ Common third-party middleware:
313
+
314
+ ```javascript
315
+ const cors = require('cors')
316
+ const helmet = require('helmet')
317
+ const morgan = require('morgan')
318
+
319
+ app.use(cors())
320
+ app.use(helmet())
321
+ app.use(morgan('dev'))
322
+ ```
323
+ ```
324
+
325
+ **Step 3: Create Node streams doc**
326
+
327
+ Create `tests/fixtures/corpus/documentation/node-streams.md`:
328
+ ```markdown
329
+ # Node.js Streams Guide
330
+
331
+ ## What are Streams?
332
+
333
+ Streams are collections of data that might not be available all at once and don't have to fit in memory. They're ideal for working with large amounts of data or data from external sources.
334
+
335
+ ## Types of Streams
336
+
337
+ 1. **Readable** - streams from which data can be read (e.g., `fs.createReadStream()`)
338
+ 2. **Writable** - streams to which data can be written (e.g., `fs.createWriteStream()`)
339
+ 3. **Duplex** - streams that are both Readable and Writable (e.g., `net.Socket`)
340
+ 4. **Transform** - Duplex streams that can modify data as it passes through
341
+
342
+ ## Reading from Streams
343
+
344
+ ```javascript
345
+ const fs = require('fs')
346
+
347
+ const readStream = fs.createReadStream('large-file.txt', 'utf8')
348
+
349
+ readStream.on('data', (chunk) => {
350
+ console.log('Received chunk:', chunk.length, 'bytes')
351
+ })
352
+
353
+ readStream.on('end', () => {
354
+ console.log('Finished reading')
355
+ })
356
+
357
+ readStream.on('error', (err) => {
358
+ console.error('Error:', err)
359
+ })
360
+ ```
361
+
362
+ ## Writing to Streams
363
+
364
+ ```javascript
365
+ const fs = require('fs')
366
+
367
+ const writeStream = fs.createWriteStream('output.txt')
368
+
369
+ writeStream.write('Hello, ')
370
+ writeStream.write('World!')
371
+ writeStream.end()
372
+
373
+ writeStream.on('finish', () => {
374
+ console.log('Finished writing')
375
+ })
376
+ ```
377
+
378
+ ## Piping Streams
379
+
380
+ The `pipe()` method connects a readable stream to a writable stream:
381
+
382
+ ```javascript
383
+ const fs = require('fs')
384
+
385
+ const readStream = fs.createReadStream('input.txt')
386
+ const writeStream = fs.createWriteStream('output.txt')
387
+
388
+ readStream.pipe(writeStream)
389
+ ```
390
+
391
+ ## Transform Streams
392
+
393
+ ```javascript
394
+ const { Transform } = require('stream')
395
+
396
+ const upperCaseTransform = new Transform({
397
+ transform(chunk, encoding, callback) {
398
+ this.push(chunk.toString().toUpperCase())
399
+ callback()
400
+ }
401
+ })
402
+
403
+ process.stdin
404
+ .pipe(upperCaseTransform)
405
+ .pipe(process.stdout)
406
+ ```
407
+ ```
408
+
409
+ **Step 4: Commit**
410
+
411
+ ```bash
412
+ git add tests/fixtures/corpus/documentation/
413
+ git commit -m "feat(corpus): add Express and Node.js documentation"
414
+ ```
415
+
416
+ ---
417
+
418
+ ### Task 5: Add Technical Articles
419
+
420
+ **Files:**
421
+ - Create: `tests/fixtures/corpus/articles/jwt-authentication.md`
422
+ - Create: `tests/fixtures/corpus/articles/typescript-generics.md`
423
+ - Create: `tests/fixtures/corpus/articles/react-hooks-patterns.md`
424
+
425
+ **Step 1: Create JWT authentication article**
426
+
427
+ Create `tests/fixtures/corpus/articles/jwt-authentication.md`:
428
+ ```markdown
429
+ # JWT Authentication in Node.js: A Complete Guide
430
+
431
+ ## What is JWT?
432
+
433
+ JSON Web Tokens (JWT) are an open standard (RFC 7519) for securely transmitting information between parties as a JSON object. JWTs are commonly used for authentication and authorization.
434
+
435
+ ## Structure of a JWT
436
+
437
+ A JWT consists of three parts separated by dots:
438
+
439
+ ```
440
+ header.payload.signature
441
+ ```
442
+
443
+ - **Header**: Contains the token type and signing algorithm
444
+ - **Payload**: Contains claims (user data)
445
+ - **Signature**: Verifies the token hasn't been tampered with
446
+
447
+ ## Implementing JWT Authentication
448
+
449
+ ### Installation
450
+
451
+ ```bash
452
+ npm install jsonwebtoken bcryptjs
453
+ ```
454
+
455
+ ### Creating Tokens
456
+
457
+ ```javascript
458
+ const jwt = require('jsonwebtoken')
459
+
460
+ function generateAccessToken(user) {
461
+ return jwt.sign(
462
+ { userId: user.id, email: user.email },
463
+ process.env.JWT_SECRET,
464
+ { expiresIn: '15m' }
465
+ )
466
+ }
467
+
468
+ function generateRefreshToken(user) {
469
+ return jwt.sign(
470
+ { userId: user.id },
471
+ process.env.JWT_REFRESH_SECRET,
472
+ { expiresIn: '7d' }
473
+ )
474
+ }
475
+ ```
476
+
477
+ ### Verifying Tokens
478
+
479
+ ```javascript
480
+ function authenticateToken(req, res, next) {
481
+ const authHeader = req.headers['authorization']
482
+ const token = authHeader && authHeader.split(' ')[1]
483
+
484
+ if (!token) {
485
+ return res.status(401).json({ error: 'Access token required' })
486
+ }
487
+
488
+ jwt.verify(token, process.env.JWT_SECRET, (err, user) => {
489
+ if (err) {
490
+ return res.status(403).json({ error: 'Invalid or expired token' })
491
+ }
492
+ req.user = user
493
+ next()
494
+ })
495
+ }
496
+ ```
497
+
498
+ ### Refresh Token Flow
499
+
500
+ ```javascript
501
+ app.post('/token/refresh', (req, res) => {
502
+ const { refreshToken } = req.body
503
+
504
+ if (!refreshToken) {
505
+ return res.status(401).json({ error: 'Refresh token required' })
506
+ }
507
+
508
+ jwt.verify(refreshToken, process.env.JWT_REFRESH_SECRET, (err, user) => {
509
+ if (err) {
510
+ return res.status(403).json({ error: 'Invalid refresh token' })
511
+ }
512
+
513
+ const accessToken = generateAccessToken({ id: user.userId })
514
+ res.json({ accessToken })
515
+ })
516
+ })
517
+ ```
518
+
519
+ ## Security Best Practices
520
+
521
+ 1. **Use short expiration times** for access tokens (15 minutes)
522
+ 2. **Store refresh tokens securely** (httpOnly cookies)
523
+ 3. **Implement token revocation** for logout
524
+ 4. **Use strong secrets** (at least 256 bits)
525
+ 5. **Always use HTTPS** in production
526
+ ```
527
+
528
+ **Step 2: Create TypeScript generics article**
529
+
530
+ Create `tests/fixtures/corpus/articles/typescript-generics.md`:
531
+ ```markdown
532
+ # TypeScript Generics: From Basics to Advanced Patterns
533
+
534
+ ## Why Generics?
535
+
536
+ Generics allow you to write reusable code that works with multiple types while maintaining type safety.
537
+
538
+ ## Basic Generic Functions
539
+
540
+ ```typescript
541
+ // Without generics - loses type information
542
+ function identity(arg: any): any {
543
+ return arg
544
+ }
545
+
546
+ // With generics - preserves type
547
+ function identity<T>(arg: T): T {
548
+ return arg
549
+ }
550
+
551
+ const str = identity<string>('hello') // string
552
+ const num = identity(42) // number (inferred)
553
+ ```
554
+
555
+ ## Generic Constraints
556
+
557
+ Constrain generics to types with specific properties:
558
+
559
+ ```typescript
560
+ interface HasLength {
561
+ length: number
562
+ }
563
+
564
+ function logLength<T extends HasLength>(arg: T): T {
565
+ console.log(arg.length)
566
+ return arg
567
+ }
568
+
569
+ logLength('hello') // OK
570
+ logLength([1, 2, 3]) // OK
571
+ logLength(123) // Error: number doesn't have length
572
+ ```
573
+
574
+ ## Generic Interfaces
575
+
576
+ ```typescript
577
+ interface Repository<T> {
578
+ find(id: string): Promise<T | null>
579
+ findAll(): Promise<T[]>
580
+ create(data: Omit<T, 'id'>): Promise<T>
581
+ update(id: string, data: Partial<T>): Promise<T>
582
+ delete(id: string): Promise<void>
583
+ }
584
+
585
+ interface User {
586
+ id: string
587
+ name: string
588
+ email: string
589
+ }
590
+
591
+ class UserRepository implements Repository<User> {
592
+ async find(id: string): Promise<User | null> {
593
+ // implementation
594
+ }
595
+ // ... other methods
596
+ }
597
+ ```
598
+
599
+ ## Conditional Types
600
+
601
+ ```typescript
602
+ type IsArray<T> = T extends any[] ? true : false
603
+
604
+ type A = IsArray<string[]> // true
605
+ type B = IsArray<number> // false
606
+
607
+ // Extract element type from array
608
+ type ElementType<T> = T extends (infer E)[] ? E : never
609
+
610
+ type C = ElementType<string[]> // string
611
+ ```
612
+
613
+ ## Mapped Types
614
+
615
+ ```typescript
616
+ type Readonly<T> = {
617
+ readonly [K in keyof T]: T[K]
618
+ }
619
+
620
+ type Partial<T> = {
621
+ [K in keyof T]?: T[K]
622
+ }
623
+
624
+ type Required<T> = {
625
+ [K in keyof T]-?: T[K]
626
+ }
627
+ ```
628
+
629
+ ## Utility Type Patterns
630
+
631
+ ```typescript
632
+ // Make specific keys optional
633
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
634
+
635
+ // Make specific keys required
636
+ type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
637
+
638
+ // Deep partial
639
+ type DeepPartial<T> = {
640
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]
641
+ }
642
+ ```
643
+ ```
644
+
645
+ **Step 3: Create React hooks article**
646
+
647
+ Create `tests/fixtures/corpus/articles/react-hooks-patterns.md`:
648
+ ```markdown
649
+ # React Hooks Patterns and Best Practices
650
+
651
+ ## Custom Hooks
652
+
653
+ Custom hooks let you extract component logic into reusable functions.
654
+
655
+ ### useLocalStorage
656
+
657
+ ```typescript
658
+ function useLocalStorage<T>(key: string, initialValue: T) {
659
+ const [storedValue, setStoredValue] = useState<T>(() => {
660
+ try {
661
+ const item = window.localStorage.getItem(key)
662
+ return item ? JSON.parse(item) : initialValue
663
+ } catch (error) {
664
+ return initialValue
665
+ }
666
+ })
667
+
668
+ const setValue = (value: T | ((val: T) => T)) => {
669
+ try {
670
+ const valueToStore = value instanceof Function ? value(storedValue) : value
671
+ setStoredValue(valueToStore)
672
+ window.localStorage.setItem(key, JSON.stringify(valueToStore))
673
+ } catch (error) {
674
+ console.error(error)
675
+ }
676
+ }
677
+
678
+ return [storedValue, setValue] as const
679
+ }
680
+ ```
681
+
682
+ ### useDebounce
683
+
684
+ ```typescript
685
+ function useDebounce<T>(value: T, delay: number): T {
686
+ const [debouncedValue, setDebouncedValue] = useState(value)
687
+
688
+ useEffect(() => {
689
+ const timer = setTimeout(() => {
690
+ setDebouncedValue(value)
691
+ }, delay)
692
+
693
+ return () => clearTimeout(timer)
694
+ }, [value, delay])
695
+
696
+ return debouncedValue
697
+ }
698
+
699
+ // Usage
700
+ function SearchComponent() {
701
+ const [query, setQuery] = useState('')
702
+ const debouncedQuery = useDebounce(query, 300)
703
+
704
+ useEffect(() => {
705
+ if (debouncedQuery) {
706
+ searchAPI(debouncedQuery)
707
+ }
708
+ }, [debouncedQuery])
709
+ }
710
+ ```
711
+
712
+ ### useFetch
713
+
714
+ ```typescript
715
+ interface FetchState<T> {
716
+ data: T | null
717
+ loading: boolean
718
+ error: Error | null
719
+ }
720
+
721
+ function useFetch<T>(url: string): FetchState<T> {
722
+ const [state, setState] = useState<FetchState<T>>({
723
+ data: null,
724
+ loading: true,
725
+ error: null,
726
+ })
727
+
728
+ useEffect(() => {
729
+ const controller = new AbortController()
730
+
731
+ async function fetchData() {
732
+ try {
733
+ setState(prev => ({ ...prev, loading: true }))
734
+ const response = await fetch(url, { signal: controller.signal })
735
+ if (!response.ok) throw new Error(response.statusText)
736
+ const data = await response.json()
737
+ setState({ data, loading: false, error: null })
738
+ } catch (error) {
739
+ if (error.name !== 'AbortError') {
740
+ setState({ data: null, loading: false, error })
741
+ }
742
+ }
743
+ }
744
+
745
+ fetchData()
746
+ return () => controller.abort()
747
+ }, [url])
748
+
749
+ return state
750
+ }
751
+ ```
752
+
753
+ ## Rules of Hooks
754
+
755
+ 1. **Only call hooks at the top level** - not inside loops, conditions, or nested functions
756
+ 2. **Only call hooks from React functions** - components or custom hooks
757
+ 3. **Name custom hooks with "use" prefix** - enables linting rules
758
+
759
+ ## Performance Patterns
760
+
761
+ ### useMemo for expensive calculations
762
+
763
+ ```typescript
764
+ const expensiveResult = useMemo(() => {
765
+ return computeExpensiveValue(a, b)
766
+ }, [a, b])
767
+ ```
768
+
769
+ ### useCallback for stable function references
770
+
771
+ ```typescript
772
+ const handleClick = useCallback(() => {
773
+ doSomething(id)
774
+ }, [id])
775
+ ```
776
+ ```
777
+
778
+ **Step 4: Commit**
779
+
780
+ ```bash
781
+ git add tests/fixtures/corpus/articles/
782
+ git commit -m "feat(corpus): add technical articles on JWT, TypeScript, React"
783
+ ```
784
+
785
+ ---
786
+
787
+ ### Task 6: Create Query Directory and Core Query Set
788
+
789
+ **Files:**
790
+ - Create: `tests/fixtures/queries/core.json`
791
+ - Create: `tests/fixtures/queries/generated/.gitkeep`
792
+
793
+ **Step 1: Create directory structure**
794
+
795
+ ```bash
796
+ mkdir -p tests/fixtures/queries/generated
797
+ touch tests/fixtures/queries/generated/.gitkeep
798
+ ```
799
+
800
+ **Step 2: Create core query set**
801
+
802
+ Create `tests/fixtures/queries/core.json`:
803
+ ```json
804
+ {
805
+ "version": "1.0.0",
806
+ "description": "Stable regression benchmark queries for search quality testing",
807
+ "queries": [
808
+ {
809
+ "id": "code-001",
810
+ "query": "zod schema validation",
811
+ "intent": "Find documentation or examples of Zod schema validation",
812
+ "category": "api-reference"
813
+ },
814
+ {
815
+ "id": "code-002",
816
+ "query": "express middleware error handling",
817
+ "intent": "Find how to handle errors in Express middleware",
818
+ "category": "code-pattern"
819
+ },
820
+ {
821
+ "id": "code-003",
822
+ "query": "JWT token authentication",
823
+ "intent": "Find JWT authentication implementation examples",
824
+ "category": "code-pattern"
825
+ },
826
+ {
827
+ "id": "code-004",
828
+ "query": "TypeScript generics constraints",
829
+ "intent": "Learn how to constrain generic types in TypeScript",
830
+ "category": "concept"
831
+ },
832
+ {
833
+ "id": "code-005",
834
+ "query": "React custom hooks",
835
+ "intent": "Find patterns for creating custom React hooks",
836
+ "category": "code-pattern"
837
+ },
838
+ {
839
+ "id": "code-006",
840
+ "query": "hono web framework routing",
841
+ "intent": "Find Hono framework routing documentation",
842
+ "category": "api-reference"
843
+ },
844
+ {
845
+ "id": "code-007",
846
+ "query": "node streams pipe",
847
+ "intent": "Learn how to pipe Node.js streams together",
848
+ "category": "concept"
849
+ },
850
+ {
851
+ "id": "code-008",
852
+ "query": "express route parameters",
853
+ "intent": "Find how to use route parameters in Express",
854
+ "category": "api-reference"
855
+ },
856
+ {
857
+ "id": "code-009",
858
+ "query": "useEffect cleanup function",
859
+ "intent": "Understand useEffect cleanup patterns in React",
860
+ "category": "concept"
861
+ },
862
+ {
863
+ "id": "code-010",
864
+ "query": "refresh token rotation",
865
+ "intent": "Find implementation of refresh token rotation for auth",
866
+ "category": "code-pattern"
867
+ },
868
+ {
869
+ "id": "code-011",
870
+ "query": "zod infer type from schema",
871
+ "intent": "Learn how to infer TypeScript types from Zod schemas",
872
+ "category": "api-reference"
873
+ },
874
+ {
875
+ "id": "code-012",
876
+ "query": "middleware next function",
877
+ "intent": "Understand how the next() function works in middleware",
878
+ "category": "concept"
879
+ },
880
+ {
881
+ "id": "code-013",
882
+ "query": "transform stream node",
883
+ "intent": "Find examples of Node.js Transform streams",
884
+ "category": "code-pattern"
885
+ },
886
+ {
887
+ "id": "code-014",
888
+ "query": "useMemo vs useCallback",
889
+ "intent": "Compare useMemo and useCallback hooks in React",
890
+ "category": "comparison"
891
+ },
892
+ {
893
+ "id": "code-015",
894
+ "query": "hono middleware context",
895
+ "intent": "Find how Hono handles middleware context",
896
+ "category": "api-reference"
897
+ }
898
+ ]
899
+ }
900
+ ```
901
+
902
+ **Step 3: Commit**
903
+
904
+ ```bash
905
+ git add tests/fixtures/queries/
906
+ git commit -m "feat(corpus): add core query set for regression testing"
907
+ ```
908
+
909
+ ---
910
+
911
+ ### Task 7: Create Corpus Index Script
912
+
913
+ **Files:**
914
+ - Create: `tests/scripts/corpus-index.ts`
915
+
916
+ **Step 1: Create the script**
917
+
918
+ Create `tests/scripts/corpus-index.ts`:
919
+ ```typescript
920
+ #!/usr/bin/env npx tsx
921
+
922
+ import { execSync } from 'node:child_process';
923
+ import { join, dirname } from 'node:path';
924
+ import { fileURLToPath } from 'node:url';
925
+ import { existsSync } from 'node:fs';
926
+
927
+ const __filename = fileURLToPath(import.meta.url);
928
+ const __dirname = dirname(__filename);
929
+ const ROOT_DIR = join(__dirname, '..', '..');
930
+ const CORPUS_DIR = join(__dirname, '..', 'fixtures', 'corpus');
931
+
932
+ const STORE_NAME = 'bluera-test-corpus';
933
+
934
+ function run(command: string, description: string): void {
935
+ console.log(`\nšŸ“Œ ${description}...`);
936
+ try {
937
+ execSync(command, {
938
+ cwd: ROOT_DIR,
939
+ stdio: 'inherit',
940
+ encoding: 'utf-8',
941
+ });
942
+ } catch (error) {
943
+ console.error(`āŒ Failed: ${description}`);
944
+ throw error;
945
+ }
946
+ }
947
+
948
+ async function main() {
949
+ console.log('šŸ”§ Corpus Index Setup');
950
+ console.log(` Store: ${STORE_NAME}`);
951
+ console.log(` Corpus: ${CORPUS_DIR}`);
952
+
953
+ // Verify corpus exists
954
+ if (!existsSync(CORPUS_DIR)) {
955
+ console.error(`āŒ Corpus directory not found: ${CORPUS_DIR}`);
956
+ process.exit(1);
957
+ }
958
+
959
+ // Check if store exists, delete if so
960
+ try {
961
+ execSync(`node dist/index.js store info ${STORE_NAME}`, {
962
+ cwd: ROOT_DIR,
963
+ stdio: 'pipe',
964
+ });
965
+ console.log(`\nāš ļø Store "${STORE_NAME}" exists, deleting...`);
966
+ run(`node dist/index.js store delete ${STORE_NAME} --force`, 'Deleting existing store');
967
+ } catch {
968
+ // Store doesn't exist, that's fine
969
+ }
970
+
971
+ // Create store
972
+ run(
973
+ `node dist/index.js store create ${STORE_NAME} --type file --source "${CORPUS_DIR}" --description "Test corpus for search quality benchmarks"`,
974
+ 'Creating test store'
975
+ );
976
+
977
+ // Index the store
978
+ run(
979
+ `node dist/index.js index ${STORE_NAME}`,
980
+ 'Indexing corpus'
981
+ );
982
+
983
+ // Show store info
984
+ run(
985
+ `node dist/index.js store info ${STORE_NAME}`,
986
+ 'Verifying store'
987
+ );
988
+
989
+ console.log('\nāœ… Corpus indexed successfully!');
990
+ console.log(` Run quality tests with: npm run test:search-quality`);
991
+ }
992
+
993
+ main().catch((error) => {
994
+ console.error('āŒ Setup failed:', error);
995
+ process.exit(1);
996
+ });
997
+ ```
998
+
999
+ **Step 2: Commit**
1000
+
1001
+ ```bash
1002
+ git add tests/scripts/corpus-index.ts
1003
+ git commit -m "feat: add corpus indexing script"
1004
+ ```
1005
+
1006
+ ---
1007
+
1008
+ ### Task 8: Update Quality Config for Corpus Store
1009
+
1010
+ **Files:**
1011
+ - Modify: `tests/quality-config.json`
1012
+
1013
+ **Step 1: Update config**
1014
+
1015
+ Replace `tests/quality-config.json`:
1016
+ ```json
1017
+ {
1018
+ "queryCount": 15,
1019
+ "searchLimit": 10,
1020
+ "searchMode": "hybrid",
1021
+ "stores": ["bluera-test-corpus"],
1022
+ "maxRetries": 3,
1023
+ "timeoutMs": 60000,
1024
+ "querySet": "core",
1025
+ "corpusVersion": "1.0.0"
1026
+ }
1027
+ ```
1028
+
1029
+ **Step 2: Commit**
1030
+
1031
+ ```bash
1032
+ git add tests/quality-config.json
1033
+ git commit -m "chore: configure quality tests to use corpus store"
1034
+ ```
1035
+
1036
+ ---
1037
+
1038
+ ### Task 9: Update Search Quality Types for Query Sets
1039
+
1040
+ **Files:**
1041
+ - Modify: `tests/scripts/search-quality.types.ts`
1042
+
1043
+ **Step 1: Add query set types**
1044
+
1045
+ Add to `tests/scripts/search-quality.types.ts` after the existing types:
1046
+ ```typescript
1047
+ // Query set types
1048
+ export interface CoreQuery {
1049
+ id: string;
1050
+ query: string;
1051
+ intent: string;
1052
+ category: 'code-pattern' | 'concept' | 'api-reference' | 'troubleshooting' | 'comparison';
1053
+ expectedSources?: string[];
1054
+ }
1055
+
1056
+ export interface QuerySet {
1057
+ version: string;
1058
+ description: string;
1059
+ queries: CoreQuery[];
1060
+ source?: 'curated' | 'ai-generated';
1061
+ generatedAt?: string;
1062
+ }
1063
+
1064
+ // Baseline types
1065
+ export interface BaselineScores {
1066
+ relevance: number;
1067
+ ranking: number;
1068
+ coverage: number;
1069
+ snippetQuality: number;
1070
+ overall: number;
1071
+ }
1072
+
1073
+ export interface Baseline {
1074
+ updatedAt: string;
1075
+ corpus: string;
1076
+ querySet: string;
1077
+ scores: BaselineScores;
1078
+ thresholds: {
1079
+ regression: number;
1080
+ improvement: number;
1081
+ };
1082
+ }
1083
+
1084
+ // Updated config type
1085
+ export interface QualityConfig {
1086
+ queryCount: number;
1087
+ searchLimit: number;
1088
+ searchMode: 'hybrid' | 'semantic' | 'keyword';
1089
+ stores: string[] | null;
1090
+ maxRetries: number;
1091
+ timeoutMs: number;
1092
+ querySet: 'core' | 'explore' | string;
1093
+ corpusVersion: string;
1094
+ }
1095
+ ```
1096
+
1097
+ **Step 2: Commit**
1098
+
1099
+ ```bash
1100
+ git add tests/scripts/search-quality.types.ts
1101
+ git commit -m "feat: add query set and baseline types"
1102
+ ```
1103
+
1104
+ ---
1105
+
1106
+ ### Task 10: Update Search Quality Script for Query Sets
1107
+
1108
+ **Files:**
1109
+ - Modify: `tests/scripts/search-quality.ts`
1110
+
1111
+ **Step 1: Add imports and query loading**
1112
+
1113
+ Add after the existing imports in `tests/scripts/search-quality.ts`:
1114
+ ```typescript
1115
+ import type {
1116
+ QualityConfig,
1117
+ QueryGenerationResult,
1118
+ EvaluationResult,
1119
+ QueryEvaluation,
1120
+ RunSummary,
1121
+ Scores,
1122
+ QuerySet,
1123
+ CoreQuery,
1124
+ Baseline,
1125
+ } from './search-quality.types.js';
1126
+ ```
1127
+
1128
+ Add new constants after SCHEMAS_DIR:
1129
+ ```typescript
1130
+ const QUERIES_DIR = join(__dirname, '..', 'fixtures', 'queries');
1131
+ const BASELINE_PATH = join(__dirname, '..', 'quality-results', 'baseline.json');
1132
+ ```
1133
+
1134
+ Add new function after loadSchema:
1135
+ ```typescript
1136
+ function loadQuerySet(name: string): QuerySet {
1137
+ if (name === 'explore') {
1138
+ throw new Error('Use generateQueries() for explore mode');
1139
+ }
1140
+
1141
+ const queryPath = join(QUERIES_DIR, `${name}.json`);
1142
+ if (!existsSync(queryPath)) {
1143
+ throw new Error(`Query set not found: ${queryPath}`);
1144
+ }
1145
+
1146
+ return JSON.parse(readFileSync(queryPath, 'utf-8')) as QuerySet;
1147
+ }
1148
+
1149
+ function loadBaseline(): Baseline | null {
1150
+ if (!existsSync(BASELINE_PATH)) {
1151
+ return null;
1152
+ }
1153
+ return JSON.parse(readFileSync(BASELINE_PATH, 'utf-8')) as Baseline;
1154
+ }
1155
+
1156
+ function saveBaseline(scores: Scores, config: QualityConfig): void {
1157
+ const baseline: Baseline = {
1158
+ updatedAt: new Date().toISOString().split('T')[0],
1159
+ corpus: config.corpusVersion,
1160
+ querySet: `${config.querySet}@${loadQuerySet(config.querySet).version}`,
1161
+ scores,
1162
+ thresholds: {
1163
+ regression: 0.05,
1164
+ improvement: 0.03,
1165
+ },
1166
+ };
1167
+ writeFileSync(BASELINE_PATH, JSON.stringify(baseline, null, 2));
1168
+ console.log(`\nāœ… Baseline saved to ${BASELINE_PATH}`);
1169
+ }
1170
+ ```
1171
+
1172
+ **Step 2: Update main function to support query sets**
1173
+
1174
+ Replace the main function query generation section:
1175
+ ```typescript
1176
+ async function main() {
1177
+ const startTime = Date.now();
1178
+ const config = loadConfig();
1179
+ const runId = generateRunId();
1180
+
1181
+ // Parse CLI arguments
1182
+ const args = process.argv.slice(2);
1183
+ const isExplore = args.includes('--explore');
1184
+ const updateBaseline = args.includes('--update-baseline');
1185
+ const setArg = args.find(a => a.startsWith('--set='));
1186
+ const querySetName = setArg ? setArg.split('=')[1] : (isExplore ? 'explore' : config.querySet);
1187
+
1188
+ console.log('šŸš€ AI Search Quality Testing');
1189
+ console.log(` Run ID: ${runId}`);
1190
+ console.log(` Query set: ${querySetName}`);
1191
+ console.log(` Search mode: ${config.searchMode}`);
1192
+ console.log(` Stores: ${config.stores?.join(', ') || 'all'}\n`);
1193
+
1194
+ // Load baseline for comparison
1195
+ const baseline = loadBaseline();
1196
+ if (baseline) {
1197
+ console.log(`šŸ“Š Baseline: ${baseline.querySet} (${baseline.updatedAt})`);
1198
+ console.log(` Overall: ${baseline.scores.overall}\n`);
1199
+ }
1200
+
1201
+ // Ensure results directory exists
1202
+ if (!existsSync(RESULTS_DIR)) {
1203
+ mkdirSync(RESULTS_DIR, { recursive: true });
1204
+ }
1205
+
1206
+ // Generate output filename
1207
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
1208
+ const outputPath = join(RESULTS_DIR, `${timestamp}.jsonl`);
1209
+
1210
+ // Get queries - either from file or generate
1211
+ let queries: Array<{ query: string; intent: string }>;
1212
+
1213
+ if (isExplore) {
1214
+ console.log('šŸ” Generating exploratory queries...');
1215
+ const generated = generateQueries(config);
1216
+ queries = generated.queries;
1217
+
1218
+ // Save generated queries
1219
+ const generatedPath = join(QUERIES_DIR, 'generated', `${timestamp}.json`);
1220
+ const generatedSet: QuerySet = {
1221
+ version: '1.0.0',
1222
+ description: `AI-generated queries from ${timestamp}`,
1223
+ queries: queries.map((q, i) => ({
1224
+ id: `gen-${i + 1}`,
1225
+ query: q.query,
1226
+ intent: q.intent,
1227
+ category: 'code-pattern' as const,
1228
+ })),
1229
+ source: 'ai-generated',
1230
+ generatedAt: new Date().toISOString(),
1231
+ };
1232
+ writeFileSync(generatedPath, JSON.stringify(generatedSet, null, 2));
1233
+ console.log(` Saved to: ${generatedPath}\n`);
1234
+ } else {
1235
+ const querySet = loadQuerySet(querySetName);
1236
+ console.log(`šŸ“‹ Loaded ${querySet.queries.length} queries from ${querySetName}.json\n`);
1237
+ queries = querySet.queries.map(q => ({ query: q.query, intent: q.intent }));
1238
+ }
1239
+
1240
+ // ... rest of main function continues with evaluation loop
1241
+ ```
1242
+
1243
+ **Step 3: Add baseline comparison to output**
1244
+
1245
+ Add after the summary generation in main():
1246
+ ```typescript
1247
+ // Compare to baseline
1248
+ if (baseline && !isExplore) {
1249
+ console.log('\nšŸ“Š Comparison to Baseline:');
1250
+ const dims = ['relevance', 'ranking', 'coverage', 'snippetQuality', 'overall'] as const;
1251
+
1252
+ for (const dim of dims) {
1253
+ const current = summary.averageScores[dim];
1254
+ const base = baseline.scores[dim];
1255
+ const diff = current - base;
1256
+ const diffStr = diff >= 0 ? `+${diff.toFixed(2)}` : diff.toFixed(2);
1257
+ const indicator = diff < -baseline.thresholds.regression ? 'āŒ' :
1258
+ diff > baseline.thresholds.improvement ? 'āœ…' : ' ';
1259
+ console.log(` ${dim.padEnd(15)} ${current.toFixed(2)} (${diffStr}) ${indicator}`);
1260
+ }
1261
+
1262
+ const hasRegression = dims.some(d =>
1263
+ summary.averageScores[d] - baseline.scores[d] < -baseline.thresholds.regression
1264
+ );
1265
+
1266
+ if (hasRegression) {
1267
+ console.log('\nāš ļø REGRESSION DETECTED - scores dropped below threshold');
1268
+ } else {
1269
+ console.log('\nāœ… No regressions detected');
1270
+ }
1271
+ }
1272
+
1273
+ // Update baseline if requested
1274
+ if (updateBaseline) {
1275
+ saveBaseline(summary.averageScores, config);
1276
+ }
1277
+ ```
1278
+
1279
+ **Step 4: Add writeFileSync to imports**
1280
+
1281
+ Update the fs import at the top:
1282
+ ```typescript
1283
+ import { readFileSync, appendFileSync, mkdirSync, existsSync, writeFileSync } from 'node:fs';
1284
+ ```
1285
+
1286
+ **Step 5: Commit**
1287
+
1288
+ ```bash
1289
+ git add tests/scripts/search-quality.ts
1290
+ git commit -m "feat: add query set support and baseline comparison"
1291
+ ```
1292
+
1293
+ ---
1294
+
1295
+ ### Task 11: Add NPM Scripts
1296
+
1297
+ **Files:**
1298
+ - Modify: `package.json`
1299
+
1300
+ **Step 1: Add new scripts**
1301
+
1302
+ Add to the scripts section of `package.json`:
1303
+ ```json
1304
+ "test:corpus:index": "npx tsx tests/scripts/corpus-index.ts",
1305
+ "test:search-quality": "npx tsx tests/scripts/search-quality.ts",
1306
+ "test:search-quality:explore": "npx tsx tests/scripts/search-quality.ts --explore",
1307
+ "test:search-quality:baseline": "npx tsx tests/scripts/search-quality.ts --update-baseline"
1308
+ ```
1309
+
1310
+ **Step 2: Commit**
1311
+
1312
+ ```bash
1313
+ git add package.json
1314
+ git commit -m "chore: add corpus and quality testing npm scripts"
1315
+ ```
1316
+
1317
+ ---
1318
+
1319
+ ### Task 12: Test the Full Pipeline
1320
+
1321
+ **Step 1: Build the project**
1322
+
1323
+ ```bash
1324
+ npm run build
1325
+ ```
1326
+
1327
+ **Step 2: Index the corpus**
1328
+
1329
+ ```bash
1330
+ npm run test:corpus:index
1331
+ ```
1332
+
1333
+ Expected output:
1334
+ ```
1335
+ šŸ”§ Corpus Index Setup
1336
+ Store: bluera-test-corpus
1337
+ Corpus: .../tests/fixtures/corpus
1338
+
1339
+ šŸ“Œ Creating test store...
1340
+ šŸ“Œ Indexing corpus...
1341
+ šŸ“Œ Verifying store...
1342
+
1343
+ āœ… Corpus indexed successfully!
1344
+ ```
1345
+
1346
+ **Step 3: Run quality tests**
1347
+
1348
+ ```bash
1349
+ npm run test:search-quality
1350
+ ```
1351
+
1352
+ Expected output:
1353
+ ```
1354
+ šŸš€ AI Search Quality Testing
1355
+ Run ID: xxxxxxxx
1356
+ Query set: core
1357
+ Search mode: hybrid
1358
+ Stores: bluera-test-corpus
1359
+
1360
+ šŸ“‹ Loaded 15 queries from core.json
1361
+
1362
+ šŸ“Š Evaluating search quality...
1363
+ [1/15] "zod schema validation" - overall: 0.XX
1364
+ ...
1365
+
1366
+ āœ“ Results written to tests/quality-results/YYYY-MM-DDTHH-MM-SS.jsonl
1367
+ šŸ“ˆ Average overall score: X.XX
1368
+ ```
1369
+
1370
+ **Step 4: Set baseline**
1371
+
1372
+ ```bash
1373
+ npm run test:search-quality:baseline
1374
+ ```
1375
+
1376
+ **Step 5: Run again to see comparison**
1377
+
1378
+ ```bash
1379
+ npm run test:search-quality
1380
+ ```
1381
+
1382
+ Expected: Shows baseline comparison with +/- indicators.
1383
+
1384
+ **Step 6: Commit any fixes**
1385
+
1386
+ ```bash
1387
+ git add -A
1388
+ git commit -m "fix: address issues from integration testing"
1389
+ ```
1390
+
1391
+ ---
1392
+
1393
+ ### Task 13: Final Verification and Cleanup
1394
+
1395
+ **Step 1: Verify all files committed**
1396
+
1397
+ ```bash
1398
+ git status
1399
+ ```
1400
+
1401
+ Should show clean working tree.
1402
+
1403
+ **Step 2: Run full test suite**
1404
+
1405
+ ```bash
1406
+ npm run test:run
1407
+ ```
1408
+
1409
+ All existing tests should pass.
1410
+
1411
+ **Step 3: Final commit if needed**
1412
+
1413
+ ```bash
1414
+ git add -A
1415
+ git commit -m "chore: phase 1 search quality testing complete"
1416
+ ```