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
package/dist/index.js ADDED
@@ -0,0 +1,1429 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ runMCPServer
4
+ } from "./chunk-J7J6LXOJ.js";
5
+ import {
6
+ IntelligentCrawler
7
+ } from "./chunk-BICFAWMN.js";
8
+ import {
9
+ ASTParser,
10
+ createDocumentId,
11
+ createServices,
12
+ createStoreId,
13
+ destroyServices,
14
+ err,
15
+ extractRepoName,
16
+ ok
17
+ } from "./chunk-5QMHZUC4.js";
18
+ import "./chunk-L2YVNC63.js";
19
+
20
+ // src/index.ts
21
+ import { homedir as homedir2 } from "os";
22
+ import { join as join4 } from "path";
23
+
24
+ // src/cli/program.ts
25
+ import { Command } from "commander";
26
+ import { readFileSync } from "fs";
27
+ import { fileURLToPath } from "url";
28
+ import { dirname, join } from "path";
29
+ function getVersion() {
30
+ const __filename2 = fileURLToPath(import.meta.url);
31
+ const __dirname2 = dirname(__filename2);
32
+ const content = readFileSync(join(__dirname2, "../package.json"), "utf-8");
33
+ const pkg = JSON.parse(content);
34
+ return pkg.version;
35
+ }
36
+ var version = getVersion();
37
+ function createProgram() {
38
+ const program2 = new Command();
39
+ program2.name("bluera-knowledge").description("CLI tool for managing knowledge stores with semantic search").version(version);
40
+ program2.option("-c, --config <path>", "Path to config file").option("-d, --data-dir <path>", "Data directory").option("-p, --project-root <path>", "Project root directory (for resolving relative paths)").option("-f, --format <format>", "Output format: json | table | plain", "table").option("-q, --quiet", "Suppress non-essential output").option("-v, --verbose", "Enable verbose logging");
41
+ return program2;
42
+ }
43
+ function getGlobalOptions(program2) {
44
+ const opts = program2.opts();
45
+ return {
46
+ config: opts.config,
47
+ dataDir: opts.dataDir,
48
+ projectRoot: opts.projectRoot,
49
+ format: opts.format,
50
+ quiet: opts.quiet,
51
+ verbose: opts.verbose
52
+ };
53
+ }
54
+
55
+ // src/cli/commands/store.ts
56
+ import { Command as Command2 } from "commander";
57
+ function createStoreCommand(getOptions) {
58
+ const store = new Command2("store").description("Manage knowledge stores (collections of indexed documents)");
59
+ store.command("list").description("Show all stores with their type (file/repo/web) and ID").option("-t, --type <type>", "Filter by type: file, repo, or web").action(async (options) => {
60
+ const globalOpts = getOptions();
61
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
62
+ try {
63
+ const stores = await services.store.list(options.type);
64
+ if (globalOpts.format === "json") {
65
+ console.log(JSON.stringify(stores, null, 2));
66
+ } else if (globalOpts.quiet === true) {
67
+ for (const s of stores) {
68
+ console.log(s.name);
69
+ }
70
+ } else {
71
+ if (stores.length === 0) {
72
+ console.log("No stores found.");
73
+ } else {
74
+ console.log("\nStores:\n");
75
+ for (const s of stores) {
76
+ console.log(` ${s.name} (${s.type}) - ${s.id}`);
77
+ }
78
+ console.log("");
79
+ }
80
+ }
81
+ } finally {
82
+ await destroyServices(services);
83
+ }
84
+ });
85
+ store.command("create <name>").description("Create a new store pointing to a local path or URL").requiredOption("-t, --type <type>", "Store type: file (local dir), repo (git), web (crawled site)").requiredOption("-s, --source <path>", "Local path for file/repo stores, URL for web stores").option("-d, --description <desc>", "Optional description for the store").option("--tags <tags>", "Comma-separated tags for filtering").action(async (name, options) => {
86
+ const globalOpts = getOptions();
87
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
88
+ try {
89
+ const result = await services.store.create({
90
+ name,
91
+ type: options.type,
92
+ path: options.type !== "web" ? options.source : void 0,
93
+ url: options.type === "web" ? options.source : void 0,
94
+ description: options.description,
95
+ tags: options.tags?.split(",").map((t) => t.trim())
96
+ });
97
+ if (result.success) {
98
+ if (globalOpts.format === "json") {
99
+ console.log(JSON.stringify(result.data, null, 2));
100
+ } else {
101
+ console.log(`
102
+ Created store: ${result.data.name} (${result.data.id})
103
+ `);
104
+ }
105
+ } else {
106
+ console.error(`Error: ${result.error.message}`);
107
+ process.exit(1);
108
+ }
109
+ } finally {
110
+ await destroyServices(services);
111
+ }
112
+ });
113
+ store.command("info <store>").description("Show store details: ID, type, path/URL, timestamps").action(async (storeIdOrName) => {
114
+ const globalOpts = getOptions();
115
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
116
+ try {
117
+ const s = await services.store.getByIdOrName(storeIdOrName);
118
+ if (s === void 0) {
119
+ console.error(`Error: Store not found: ${storeIdOrName}`);
120
+ process.exit(3);
121
+ }
122
+ if (globalOpts.format === "json") {
123
+ console.log(JSON.stringify(s, null, 2));
124
+ } else {
125
+ console.log(`
126
+ Store: ${s.name}`);
127
+ console.log(` ID: ${s.id}`);
128
+ console.log(` Type: ${s.type}`);
129
+ if ("path" in s) console.log(` Path: ${s.path}`);
130
+ if ("url" in s && s.url !== void 0) console.log(` URL: ${s.url}`);
131
+ if (s.description !== void 0) console.log(` Description: ${s.description}`);
132
+ console.log(` Created: ${s.createdAt.toISOString()}`);
133
+ console.log(` Updated: ${s.updatedAt.toISOString()}`);
134
+ console.log("");
135
+ }
136
+ } finally {
137
+ await destroyServices(services);
138
+ }
139
+ });
140
+ store.command("delete <store>").description("Remove store and its indexed documents from LanceDB").option("-f, --force", "Delete without confirmation prompt").option("-y, --yes", "Alias for --force").action(async (storeIdOrName, options) => {
141
+ const globalOpts = getOptions();
142
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
143
+ try {
144
+ const s = await services.store.getByIdOrName(storeIdOrName);
145
+ if (s === void 0) {
146
+ console.error(`Error: Store not found: ${storeIdOrName}`);
147
+ process.exit(3);
148
+ }
149
+ const skipConfirmation = options.force === true || options.yes === true;
150
+ if (!skipConfirmation) {
151
+ if (!process.stdin.isTTY) {
152
+ console.error("Error: Use --force or -y to delete without confirmation in non-interactive mode");
153
+ process.exit(1);
154
+ }
155
+ const readline = await import("readline");
156
+ const rl = readline.createInterface({
157
+ input: process.stdin,
158
+ output: process.stdout
159
+ });
160
+ const answer = await new Promise((resolve) => {
161
+ rl.question(`Delete store "${s.name}"? [y/N] `, resolve);
162
+ });
163
+ rl.close();
164
+ if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
165
+ console.log("Cancelled.");
166
+ process.exit(0);
167
+ }
168
+ }
169
+ const result = await services.store.delete(s.id);
170
+ if (result.success) {
171
+ console.log(`Deleted store: ${s.name}`);
172
+ } else {
173
+ console.error(`Error: ${result.error.message}`);
174
+ process.exit(1);
175
+ }
176
+ } finally {
177
+ await destroyServices(services);
178
+ }
179
+ });
180
+ return store;
181
+ }
182
+
183
+ // src/cli/commands/search.ts
184
+ import { Command as Command3 } from "commander";
185
+ function createSearchCommand(getOptions) {
186
+ const search = new Command3("search").description("Search indexed documents using vector similarity + full-text matching").argument("<query>", "Search query").option("-s, --stores <stores>", "Limit search to specific stores (comma-separated IDs or names)").option("-m, --mode <mode>", "vector (embeddings only), fts (text only), hybrid (both, default)", "hybrid").option("-n, --limit <count>", "Maximum results to return (default: 10)", "10").option("-t, --threshold <score>", "Minimum score 0-1; omit low-relevance results").option("--include-content", "Show full document content, not just preview snippet").option("--detail <level>", "Context detail: minimal, contextual, full (default: minimal)", "minimal").action(async (query, options) => {
187
+ const globalOpts = getOptions();
188
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
189
+ try {
190
+ let storeIds = (await services.store.list()).map((s) => s.id);
191
+ if (options.stores !== void 0) {
192
+ const requestedStores = options.stores.split(",").map((s) => s.trim());
193
+ const resolvedStores = [];
194
+ for (const requested of requestedStores) {
195
+ const store = await services.store.getByIdOrName(requested);
196
+ if (store !== void 0) {
197
+ resolvedStores.push(store.id);
198
+ } else {
199
+ console.error(`Error: Store not found: ${requested}`);
200
+ process.exit(3);
201
+ }
202
+ }
203
+ storeIds = resolvedStores;
204
+ }
205
+ if (storeIds.length === 0) {
206
+ console.error("No stores to search. Create a store first.");
207
+ process.exit(1);
208
+ }
209
+ for (const storeId of storeIds) {
210
+ await services.lance.initialize(storeId);
211
+ }
212
+ const results = await services.search.search({
213
+ query,
214
+ stores: storeIds,
215
+ mode: options.mode ?? "hybrid",
216
+ limit: parseInt(options.limit ?? "10", 10),
217
+ threshold: options.threshold !== void 0 ? parseFloat(options.threshold) : void 0,
218
+ includeContent: options.includeContent,
219
+ detail: options.detail ?? "minimal"
220
+ });
221
+ if (globalOpts.format === "json") {
222
+ console.log(JSON.stringify(results, null, 2));
223
+ } else if (globalOpts.quiet === true) {
224
+ for (const r of results.results) {
225
+ const path = r.metadata.path ?? r.metadata.url ?? "unknown";
226
+ console.log(path);
227
+ }
228
+ } else {
229
+ console.log(`
230
+ Search: "${query}"`);
231
+ console.log(`Mode: ${results.mode} | Detail: ${String(options.detail)} | Stores: ${String(results.stores.length)} | Results: ${String(results.totalResults)} | Time: ${String(results.timeMs)}ms
232
+ `);
233
+ if (results.results.length === 0) {
234
+ console.log("No results found.\n");
235
+ } else {
236
+ for (let i = 0; i < results.results.length; i++) {
237
+ const r = results.results[i];
238
+ if (r === void 0) continue;
239
+ if (r.summary) {
240
+ console.log(`${String(i + 1)}. [${r.score.toFixed(2)}] ${r.summary.type}: ${r.summary.name}`);
241
+ console.log(` ${r.summary.location}`);
242
+ console.log(` ${r.summary.purpose}`);
243
+ if (r.context && options.detail !== "minimal") {
244
+ console.log(` Imports: ${r.context.keyImports.slice(0, 3).join(", ")}`);
245
+ console.log(` Related: ${r.context.relatedConcepts.slice(0, 3).join(", ")}`);
246
+ }
247
+ console.log();
248
+ } else {
249
+ const path = r.metadata.path ?? r.metadata.url ?? "unknown";
250
+ console.log(`${String(i + 1)}. [${r.score.toFixed(2)}] ${path}`);
251
+ const preview = r.highlight ?? r.content.slice(0, 150).replace(/\n/g, " ") + (r.content.length > 150 ? "..." : "");
252
+ console.log(` ${preview}
253
+ `);
254
+ }
255
+ }
256
+ }
257
+ }
258
+ } finally {
259
+ await destroyServices(services);
260
+ }
261
+ });
262
+ return search;
263
+ }
264
+
265
+ // src/cli/commands/index-cmd.ts
266
+ import { Command as Command4 } from "commander";
267
+ import ora from "ora";
268
+ function createIndexCommand(getOptions) {
269
+ const index = new Command4("index").description("Scan store files, chunk text, generate embeddings, save to LanceDB").argument("<store>", "Store ID or name").option("--force", "Re-index all files even if unchanged").action(async (storeIdOrName, _options) => {
270
+ const globalOpts = getOptions();
271
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
272
+ try {
273
+ const store = await services.store.getByIdOrName(storeIdOrName);
274
+ if (store === void 0) {
275
+ console.error(`Error: Store not found: ${storeIdOrName}`);
276
+ process.exit(3);
277
+ }
278
+ const isInteractive = process.stdout.isTTY && globalOpts.quiet !== true && globalOpts.format !== "json";
279
+ let spinner;
280
+ if (isInteractive) {
281
+ spinner = ora(`Indexing store: ${store.name}`).start();
282
+ } else if (globalOpts.quiet !== true && globalOpts.format !== "json") {
283
+ console.log(`Indexing store: ${store.name}`);
284
+ }
285
+ await services.lance.initialize(store.id);
286
+ const result = await services.index.indexStore(store, (event) => {
287
+ if (event.type === "progress") {
288
+ if (spinner) {
289
+ spinner.text = `Indexing: ${String(event.current)}/${String(event.total)} files - ${event.message}`;
290
+ }
291
+ }
292
+ });
293
+ if (result.success) {
294
+ if (globalOpts.format === "json") {
295
+ console.log(JSON.stringify(result.data, null, 2));
296
+ } else {
297
+ const message = `Indexed ${String(result.data.documentsIndexed)} documents, ${String(result.data.chunksCreated)} chunks in ${String(result.data.timeMs)}ms`;
298
+ if (spinner !== void 0) {
299
+ spinner.succeed(message);
300
+ } else if (globalOpts.quiet !== true) {
301
+ console.log(message);
302
+ }
303
+ }
304
+ } else {
305
+ const message = `Error: ${result.error.message}`;
306
+ if (spinner !== void 0) {
307
+ spinner.fail(message);
308
+ } else {
309
+ console.error(message);
310
+ }
311
+ process.exit(4);
312
+ }
313
+ } finally {
314
+ await destroyServices(services);
315
+ }
316
+ });
317
+ index.command("watch <store>").description("Watch store directory; re-index when files change").option("--debounce <ms>", "Wait N ms after last change before re-indexing (default: 1000)", "1000").action(async (storeIdOrName, options) => {
318
+ const globalOpts = getOptions();
319
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
320
+ const store = await services.store.getByIdOrName(storeIdOrName);
321
+ if (store === void 0 || store.type !== "file" && store.type !== "repo") {
322
+ console.error(`Error: File/repo store not found: ${storeIdOrName}`);
323
+ process.exit(3);
324
+ }
325
+ const { WatchService } = await import("./watch.service-YAIKKDCF.js");
326
+ const watchService = new WatchService(services.index, services.lance);
327
+ if (globalOpts.quiet !== true) {
328
+ console.log(`Watching ${store.name} for changes...`);
329
+ }
330
+ await watchService.watch(store, parseInt(options.debounce ?? "1000", 10), () => {
331
+ if (globalOpts.quiet !== true) {
332
+ console.log(`Re-indexed ${store.name}`);
333
+ }
334
+ });
335
+ process.on("SIGINT", () => {
336
+ void (async () => {
337
+ await watchService.unwatchAll();
338
+ process.exit(0);
339
+ })().catch(() => {
340
+ });
341
+ });
342
+ });
343
+ return index;
344
+ }
345
+
346
+ // src/cli/commands/serve.ts
347
+ import { Command as Command5 } from "commander";
348
+ import { serve } from "@hono/node-server";
349
+
350
+ // src/server/app.ts
351
+ import { Hono } from "hono";
352
+ import { cors } from "hono/cors";
353
+ import { z } from "zod";
354
+ var CreateStoreBodySchema = z.object({
355
+ name: z.string().min(1, "Store name must be a non-empty string"),
356
+ type: z.enum(["file", "repo", "web"]),
357
+ path: z.string().min(1).optional(),
358
+ url: z.string().min(1).optional(),
359
+ description: z.string().optional(),
360
+ tags: z.array(z.string()).optional(),
361
+ branch: z.string().optional(),
362
+ depth: z.number().int().positive().optional()
363
+ }).refine(
364
+ (data) => {
365
+ switch (data.type) {
366
+ case "file":
367
+ return data.path !== void 0;
368
+ case "web":
369
+ return data.url !== void 0;
370
+ case "repo":
371
+ return data.path !== void 0 || data.url !== void 0;
372
+ }
373
+ },
374
+ { message: "Missing required field: file stores need path, web stores need url, repo stores need path or url" }
375
+ );
376
+ var SearchBodySchema = z.object({
377
+ query: z.string().min(1, "Query must be a non-empty string"),
378
+ detail: z.enum(["minimal", "contextual", "full"]).optional(),
379
+ limit: z.number().int().positive().optional(),
380
+ stores: z.array(z.string()).optional()
381
+ });
382
+ function createApp(services) {
383
+ const app = new Hono();
384
+ app.use("*", cors());
385
+ app.get("/health", (c) => c.json({ status: "ok" }));
386
+ app.get("/api/stores", async (c) => {
387
+ const stores = await services.store.list();
388
+ return c.json(stores);
389
+ });
390
+ app.post("/api/stores", async (c) => {
391
+ const jsonData = await c.req.json();
392
+ const parseResult = CreateStoreBodySchema.safeParse(jsonData);
393
+ if (!parseResult.success) {
394
+ return c.json({ error: parseResult.error.issues[0]?.message ?? "Invalid request body" }, 400);
395
+ }
396
+ const result = await services.store.create(parseResult.data);
397
+ if (result.success) {
398
+ return c.json(result.data, 201);
399
+ }
400
+ return c.json({ error: result.error.message }, 400);
401
+ });
402
+ app.get("/api/stores/:id", async (c) => {
403
+ const store = await services.store.getByIdOrName(c.req.param("id"));
404
+ if (!store) return c.json({ error: "Not found" }, 404);
405
+ return c.json(store);
406
+ });
407
+ app.delete("/api/stores/:id", async (c) => {
408
+ const store = await services.store.getByIdOrName(c.req.param("id"));
409
+ if (!store) return c.json({ error: "Not found" }, 404);
410
+ const result = await services.store.delete(store.id);
411
+ if (result.success) return c.json({ deleted: true });
412
+ return c.json({ error: result.error.message }, 400);
413
+ });
414
+ app.post("/api/search", async (c) => {
415
+ const jsonData = await c.req.json();
416
+ const parseResult = SearchBodySchema.safeParse(jsonData);
417
+ if (!parseResult.success) {
418
+ return c.json({ error: parseResult.error.issues[0]?.message ?? "Invalid request body" }, 400);
419
+ }
420
+ const storeIds = (await services.store.list()).map((s) => s.id);
421
+ for (const id of storeIds) {
422
+ await services.lance.initialize(id);
423
+ }
424
+ const requestedStores = parseResult.data.stores !== void 0 ? parseResult.data.stores.map((s) => createStoreId(s)) : storeIds;
425
+ const query = {
426
+ query: parseResult.data.query,
427
+ detail: parseResult.data.detail ?? "minimal",
428
+ limit: parseResult.data.limit ?? 10,
429
+ stores: requestedStores
430
+ };
431
+ const results = await services.search.search(query);
432
+ return c.json(results);
433
+ });
434
+ app.post("/api/stores/:id/index", async (c) => {
435
+ const store = await services.store.getByIdOrName(c.req.param("id"));
436
+ if (!store) return c.json({ error: "Not found" }, 404);
437
+ await services.lance.initialize(store.id);
438
+ const result = await services.index.indexStore(store);
439
+ if (result.success) return c.json(result.data);
440
+ return c.json({ error: result.error.message }, 400);
441
+ });
442
+ return app;
443
+ }
444
+
445
+ // src/cli/commands/serve.ts
446
+ function createServeCommand(getOptions) {
447
+ return new Command5("serve").description("Start HTTP API server for programmatic search access").option("-p, --port <port>", "Port to listen on (default: 3847)", "3847").option("--host <host>", "Bind address (default: 127.0.0.1, use 0.0.0.0 for all interfaces)", "127.0.0.1").action(async (options) => {
448
+ const globalOpts = getOptions();
449
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
450
+ const app = createApp(services);
451
+ const port = parseInt(options.port ?? "3847", 10);
452
+ const host = options.host ?? "127.0.0.1";
453
+ console.log(`Starting server on http://${host}:${String(port)}`);
454
+ serve({
455
+ fetch: app.fetch,
456
+ port,
457
+ hostname: host
458
+ });
459
+ });
460
+ }
461
+
462
+ // src/cli/commands/crawl.ts
463
+ import { Command as Command6 } from "commander";
464
+ import { createHash } from "crypto";
465
+ import ora2 from "ora";
466
+ function createCrawlCommand(getOptions) {
467
+ return new Command6("crawl").description("Crawl web pages with natural language control and index into store").argument("<url>", "URL to crawl").argument("<store>", "Target web store to add crawled content to").option("--crawl <instruction>", 'Natural language instruction for what to crawl (e.g., "all Getting Started pages")').option("--extract <instruction>", 'Natural language instruction for what to extract (e.g., "extract API references")').option("--simple", "Use simple BFS mode instead of intelligent crawling").option("--max-pages <number>", "Maximum number of pages to crawl", "50").option("--headless", "Use headless browser for JavaScript-rendered sites").action(async (url, storeIdOrName, cmdOptions) => {
468
+ const globalOpts = getOptions();
469
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
470
+ const store = await services.store.getByIdOrName(storeIdOrName);
471
+ if (!store || store.type !== "web") {
472
+ console.error(`Error: Web store not found: ${storeIdOrName}`);
473
+ process.exit(3);
474
+ }
475
+ const maxPages = cmdOptions.maxPages !== void 0 ? parseInt(cmdOptions.maxPages) : 50;
476
+ const isInteractive = process.stdout.isTTY && globalOpts.quiet !== true && globalOpts.format !== "json";
477
+ let spinner;
478
+ if (isInteractive) {
479
+ const mode = cmdOptions.simple === true ? "simple" : "intelligent";
480
+ spinner = ora2(`Crawling ${url} (${mode} mode)`).start();
481
+ } else if (globalOpts.quiet !== true && globalOpts.format !== "json") {
482
+ console.log(`Crawling ${url}`);
483
+ }
484
+ const crawler = new IntelligentCrawler();
485
+ let pagesIndexed = 0;
486
+ crawler.on("progress", (progress) => {
487
+ if (spinner) {
488
+ if (progress.type === "strategy") {
489
+ spinner.text = progress.message !== void 0 ? progress.message : "Analyzing crawl strategy...";
490
+ } else if (progress.type === "page") {
491
+ const url2 = progress.currentUrl !== void 0 ? progress.currentUrl : "unknown";
492
+ spinner.text = `Crawling ${String(progress.pagesVisited + 1)}/${String(maxPages)} - ${url2}`;
493
+ } else if (progress.type === "extraction") {
494
+ const url2 = progress.currentUrl !== void 0 ? progress.currentUrl : "unknown";
495
+ spinner.text = `Extracting from ${url2}...`;
496
+ } else if (progress.type === "error" && progress.message !== void 0) {
497
+ spinner.warn(progress.message);
498
+ }
499
+ }
500
+ });
501
+ try {
502
+ await services.lance.initialize(store.id);
503
+ const docs = [];
504
+ for await (const result of crawler.crawl(url, {
505
+ ...cmdOptions.crawl !== void 0 && { crawlInstruction: cmdOptions.crawl },
506
+ ...cmdOptions.extract !== void 0 && { extractInstruction: cmdOptions.extract },
507
+ maxPages,
508
+ ...cmdOptions.simple !== void 0 && { simple: cmdOptions.simple },
509
+ useHeadless: cmdOptions.headless ?? false
510
+ })) {
511
+ const contentToEmbed = result.extracted !== void 0 ? result.extracted : result.markdown;
512
+ const vector = await services.embeddings.embed(contentToEmbed);
513
+ docs.push({
514
+ id: createDocumentId(`${store.id}-${createHash("md5").update(result.url).digest("hex")}`),
515
+ content: contentToEmbed,
516
+ vector,
517
+ metadata: {
518
+ type: "web",
519
+ storeId: store.id,
520
+ url: result.url,
521
+ title: result.title,
522
+ extracted: result.extracted !== void 0,
523
+ depth: result.depth,
524
+ indexedAt: /* @__PURE__ */ new Date()
525
+ }
526
+ });
527
+ pagesIndexed++;
528
+ }
529
+ if (docs.length > 0) {
530
+ if (spinner) {
531
+ spinner.text = "Indexing documents...";
532
+ }
533
+ await services.lance.addDocuments(store.id, docs);
534
+ }
535
+ const crawlResult = {
536
+ success: true,
537
+ store: store.name,
538
+ url,
539
+ pagesCrawled: pagesIndexed,
540
+ mode: cmdOptions.simple === true ? "simple" : "intelligent",
541
+ hadCrawlInstruction: cmdOptions.crawl !== void 0,
542
+ hadExtractInstruction: cmdOptions.extract !== void 0
543
+ };
544
+ if (globalOpts.format === "json") {
545
+ console.log(JSON.stringify(crawlResult, null, 2));
546
+ } else if (spinner !== void 0) {
547
+ spinner.succeed(`Crawled and indexed ${String(pagesIndexed)} pages`);
548
+ } else if (globalOpts.quiet !== true) {
549
+ console.log(`Crawled and indexed ${String(pagesIndexed)} pages`);
550
+ }
551
+ } catch (error) {
552
+ const message = `Crawl failed: ${error instanceof Error ? error.message : String(error)}`;
553
+ if (spinner) {
554
+ spinner.fail(message);
555
+ } else {
556
+ console.error(`Error: ${message}`);
557
+ }
558
+ process.exit(6);
559
+ } finally {
560
+ await crawler.stop();
561
+ await destroyServices(services);
562
+ }
563
+ });
564
+ }
565
+
566
+ // src/cli/commands/setup.ts
567
+ import { Command as Command7 } from "commander";
568
+ import { spawnSync } from "child_process";
569
+ import { existsSync } from "fs";
570
+ import { mkdir } from "fs/promises";
571
+ import { join as join2 } from "path";
572
+ import { homedir } from "os";
573
+ import ora3 from "ora";
574
+
575
+ // src/defaults/repos.ts
576
+ var DEFAULT_REPOS = [
577
+ {
578
+ url: "git@github.com:ericbuess/claude-code-docs.git",
579
+ name: "claude-code-docs",
580
+ description: "Claude Code documentation",
581
+ tags: ["claude", "docs", "claude-code"]
582
+ },
583
+ {
584
+ url: "git@github.com:anthropics/claude-code.git",
585
+ name: "claude-code",
586
+ description: "Claude Code CLI tool source",
587
+ tags: ["claude", "cli", "anthropic"]
588
+ },
589
+ {
590
+ url: "git@github.com:anthropics/claude-agent-sdk-python.git",
591
+ name: "claude-agent-sdk-python",
592
+ description: "Claude Agent SDK for Python",
593
+ tags: ["claude", "sdk", "python", "agents"]
594
+ },
595
+ {
596
+ url: "git@github.com:anthropics/skills.git",
597
+ name: "claude-skills",
598
+ description: "Claude skills and capabilities",
599
+ tags: ["claude", "skills"]
600
+ },
601
+ {
602
+ url: "git@github.com:anthropics/claude-quickstarts.git",
603
+ name: "claude-quickstarts",
604
+ description: "Claude quickstart examples and tutorials",
605
+ tags: ["claude", "examples", "tutorials"]
606
+ },
607
+ {
608
+ url: "git@github.com:anthropics/claude-plugins-official.git",
609
+ name: "claude-plugins",
610
+ description: "Official Claude plugins",
611
+ tags: ["claude", "plugins"]
612
+ },
613
+ {
614
+ url: "git@github.com:anthropics/claude-agent-sdk-typescript.git",
615
+ name: "claude-agent-sdk-typescript",
616
+ description: "Claude Agent SDK for TypeScript",
617
+ tags: ["claude", "sdk", "typescript", "agents"]
618
+ },
619
+ {
620
+ url: "git@github.com:anthropics/claude-agent-sdk-demos.git",
621
+ name: "claude-agent-sdk-demos",
622
+ description: "Claude Agent SDK demo applications",
623
+ tags: ["claude", "sdk", "demos", "examples"]
624
+ }
625
+ ];
626
+
627
+ // src/cli/commands/setup.ts
628
+ var DEFAULT_REPOS_DIR = join2(homedir(), ".bluera", "bluera-knowledge", "repos");
629
+ function createSetupCommand(getOptions) {
630
+ const setup = new Command7("setup").description("Quick-start with pre-configured Claude/Anthropic documentation repos");
631
+ setup.command("repos").description("Clone repos to ~/.bluera/bluera-knowledge/repos/, create stores, index all content").option("--repos-dir <path>", "Clone destination (default: ~/.bluera/bluera-knowledge/repos/)", DEFAULT_REPOS_DIR).option("--skip-clone", "Don't clone; assume repos already exist locally").option("--skip-index", "Clone and create stores but don't index yet").option("--only <names>", "Only process matching repos (comma-separated, partial match)").option("--list", "Print available repos without cloning/indexing").action(async (options) => {
632
+ const globalOpts = getOptions();
633
+ if (options.list === true) {
634
+ console.log("\nDefault repositories:\n");
635
+ for (const repo of DEFAULT_REPOS) {
636
+ console.log(` ${repo.name}`);
637
+ console.log(` URL: ${repo.url}`);
638
+ console.log(` Description: ${repo.description}`);
639
+ console.log(` Tags: ${repo.tags.join(", ")}`);
640
+ console.log("");
641
+ }
642
+ return;
643
+ }
644
+ const services = await createServices(globalOpts.config, globalOpts.dataDir);
645
+ try {
646
+ let repos = DEFAULT_REPOS;
647
+ if (options.only !== void 0 && options.only !== "") {
648
+ const onlyNames = options.only.split(",").map((n) => n.trim().toLowerCase());
649
+ repos = DEFAULT_REPOS.filter(
650
+ (r) => onlyNames.some((n) => r.name.toLowerCase().includes(n))
651
+ );
652
+ if (repos.length === 0) {
653
+ console.error(`No repos matched: ${options.only}`);
654
+ console.log("Available repos:", DEFAULT_REPOS.map((r) => r.name).join(", "));
655
+ process.exit(1);
656
+ }
657
+ }
658
+ console.log(`
659
+ Setting up ${String(repos.length)} repositories...
660
+ `);
661
+ await mkdir(options.reposDir, { recursive: true });
662
+ for (const repo of repos) {
663
+ const repoPath = join2(options.reposDir, repo.name);
664
+ const spinner = ora3(`Processing ${repo.name}`).start();
665
+ try {
666
+ if (options.skipClone !== true) {
667
+ if (existsSync(repoPath)) {
668
+ spinner.text = `${repo.name}: Already cloned, pulling latest...`;
669
+ const pullResult = spawnSync("git", ["pull", "--ff-only"], { cwd: repoPath, stdio: "pipe" });
670
+ if (pullResult.status !== 0) {
671
+ spinner.text = `${repo.name}: Pull skipped (local changes)`;
672
+ }
673
+ } else {
674
+ spinner.text = `${repo.name}: Cloning...`;
675
+ const cloneResult = spawnSync("git", ["clone", repo.url, repoPath], { stdio: "pipe" });
676
+ if (cloneResult.status !== 0) {
677
+ const errorMessage = cloneResult.stderr.length > 0 ? cloneResult.stderr.toString() : "Git clone failed";
678
+ throw new Error(errorMessage);
679
+ }
680
+ }
681
+ }
682
+ spinner.text = `${repo.name}: Creating store...`;
683
+ const existingStore = await services.store.getByIdOrName(repo.name);
684
+ let storeId;
685
+ if (existingStore) {
686
+ storeId = existingStore.id;
687
+ spinner.text = `${repo.name}: Store already exists`;
688
+ } else {
689
+ const result = await services.store.create({
690
+ name: repo.name,
691
+ type: "repo",
692
+ path: repoPath,
693
+ description: repo.description,
694
+ tags: repo.tags
695
+ });
696
+ if (!result.success) {
697
+ throw new Error(result.error instanceof Error ? result.error.message : String(result.error));
698
+ }
699
+ storeId = result.data.id;
700
+ }
701
+ if (options.skipIndex !== true) {
702
+ spinner.text = `${repo.name}: Indexing...`;
703
+ const store = await services.store.getByIdOrName(storeId);
704
+ if (store) {
705
+ await services.lance.initialize(store.id);
706
+ const indexResult = await services.index.indexStore(store, (event) => {
707
+ if (event.type === "progress") {
708
+ spinner.text = `${repo.name}: Indexing ${String(event.current)}/${String(event.total)} files`;
709
+ }
710
+ });
711
+ if (indexResult.success) {
712
+ spinner.succeed(
713
+ `${repo.name}: ${String(indexResult.data.documentsIndexed)} docs, ${String(indexResult.data.chunksCreated)} chunks`
714
+ );
715
+ } else {
716
+ throw new Error(indexResult.error instanceof Error ? indexResult.error.message : String(indexResult.error));
717
+ }
718
+ }
719
+ } else {
720
+ spinner.succeed(`${repo.name}: Ready (indexing skipped)`);
721
+ }
722
+ } catch (error) {
723
+ spinner.fail(`${repo.name}: ${error instanceof Error ? error.message : String(error)}`);
724
+ }
725
+ }
726
+ console.log('\nSetup complete! Use "bluera-knowledge search <query>" to search.\n');
727
+ } finally {
728
+ await destroyServices(services);
729
+ }
730
+ });
731
+ return setup;
732
+ }
733
+
734
+ // src/cli/commands/mcp.ts
735
+ import { Command as Command8 } from "commander";
736
+ function createMCPCommand(getOptions) {
737
+ const mcp = new Command8("mcp").description("Start MCP (Model Context Protocol) server for AI agent integration").action(async () => {
738
+ const opts = getOptions();
739
+ await runMCPServer({
740
+ dataDir: opts.dataDir,
741
+ config: opts.config
742
+ });
743
+ });
744
+ return mcp;
745
+ }
746
+
747
+ // src/cli/commands/plugin-api.ts
748
+ import { Command as Command9 } from "commander";
749
+
750
+ // src/analysis/dependency-usage-analyzer.ts
751
+ import { readFile, readdir } from "fs/promises";
752
+ import { existsSync as existsSync2 } from "fs";
753
+ import { join as join3, extname } from "path";
754
+ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
755
+ ".ts",
756
+ ".tsx",
757
+ ".js",
758
+ ".jsx",
759
+ ".mjs",
760
+ ".cjs",
761
+ ".py",
762
+ ".rb",
763
+ ".go",
764
+ ".java",
765
+ ".rs",
766
+ ".php",
767
+ ".md",
768
+ ".txt",
769
+ ".json",
770
+ ".yml",
771
+ ".yaml",
772
+ ".toml"
773
+ ]);
774
+ function isRecord(value) {
775
+ return typeof value === "object" && value !== null && !Array.isArray(value);
776
+ }
777
+ var DependencyUsageAnalyzer = class {
778
+ astParser;
779
+ constructor() {
780
+ this.astParser = new ASTParser();
781
+ }
782
+ async analyze(projectRoot, onProgress) {
783
+ const startTime = Date.now();
784
+ try {
785
+ const declaredDeps = await this.readDeclaredDependencies(projectRoot);
786
+ if (declaredDeps.size === 0) {
787
+ return ok({
788
+ usages: [],
789
+ totalFilesScanned: 0,
790
+ skippedFiles: 0,
791
+ analysisTimeMs: Date.now() - startTime
792
+ });
793
+ }
794
+ const files = await this.scanDirectory(projectRoot);
795
+ if (files.length === 0) {
796
+ return ok({
797
+ usages: [],
798
+ totalFilesScanned: 0,
799
+ skippedFiles: 0,
800
+ analysisTimeMs: Date.now() - startTime
801
+ });
802
+ }
803
+ const usageMap = /* @__PURE__ */ new Map();
804
+ let processedCount = 0;
805
+ let skippedCount = 0;
806
+ for (const filePath of files) {
807
+ try {
808
+ const content = await readFile(filePath, "utf-8");
809
+ const imports = this.extractImportsForFile(filePath, content);
810
+ for (const importInfo of imports) {
811
+ const packageName = this.extractPackageName(importInfo.source);
812
+ if (packageName !== null && declaredDeps.has(packageName)) {
813
+ const dep = declaredDeps.get(packageName);
814
+ if (dep !== void 0) {
815
+ this.incrementUsage(
816
+ usageMap,
817
+ packageName,
818
+ filePath,
819
+ dep.isDev,
820
+ dep.language
821
+ );
822
+ }
823
+ }
824
+ }
825
+ processedCount++;
826
+ if (onProgress !== void 0 && processedCount % 10 === 0) {
827
+ onProgress(processedCount, files.length, `Analyzed ${String(processedCount)}/${String(files.length)} files`);
828
+ }
829
+ } catch {
830
+ skippedCount++;
831
+ }
832
+ }
833
+ const sortedUsages = Array.from(usageMap.values()).sort((a, b) => b.importCount - a.importCount);
834
+ return ok({
835
+ usages: sortedUsages,
836
+ totalFilesScanned: processedCount,
837
+ skippedFiles: skippedCount,
838
+ analysisTimeMs: Date.now() - startTime
839
+ });
840
+ } catch (error) {
841
+ const errorObj = new Error(
842
+ error instanceof Error ? error.message : "Unknown error during analysis"
843
+ );
844
+ errorObj.name = "ANALYSIS_ERROR";
845
+ return err(errorObj);
846
+ }
847
+ }
848
+ extractPackageName(importSource) {
849
+ if (importSource.startsWith(".") || importSource.startsWith("/")) {
850
+ return null;
851
+ }
852
+ if (importSource.startsWith("node:")) {
853
+ return null;
854
+ }
855
+ if (importSource.startsWith("@")) {
856
+ const parts = importSource.split("/");
857
+ if (parts.length >= 2 && parts[0] !== void 0 && parts[1] !== void 0) {
858
+ return `${parts[0]}/${parts[1]}`;
859
+ }
860
+ return null;
861
+ }
862
+ const firstPart = importSource.split("/")[0];
863
+ return firstPart ?? null;
864
+ }
865
+ extractImportsForFile(filePath, content) {
866
+ const ext = extname(filePath);
867
+ if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
868
+ try {
869
+ return this.astParser.extractImports(content);
870
+ } catch {
871
+ return this.extractImportsRegex(content, "javascript");
872
+ }
873
+ }
874
+ if (ext === ".py") {
875
+ return this.extractImportsRegex(content, "python");
876
+ }
877
+ return [];
878
+ }
879
+ extractImportsRegex(content, language) {
880
+ const imports = [];
881
+ if (language === "javascript") {
882
+ const importPattern = /import\s+.*?from\s+['"]([^'"]+)['"]/g;
883
+ const requirePattern = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
884
+ for (const match of content.matchAll(importPattern)) {
885
+ if (match[1] !== void 0) imports.push({ source: match[1] });
886
+ }
887
+ for (const match of content.matchAll(requirePattern)) {
888
+ if (match[1] !== void 0) imports.push({ source: match[1] });
889
+ }
890
+ } else {
891
+ const importPattern = /^import\s+([a-zA-Z0-9_]+)/gm;
892
+ const fromPattern = /^from\s+([a-zA-Z0-9_]+)/gm;
893
+ for (const match of content.matchAll(importPattern)) {
894
+ if (match[1] !== void 0) imports.push({ source: match[1] });
895
+ }
896
+ for (const match of content.matchAll(fromPattern)) {
897
+ if (match[1] !== void 0) imports.push({ source: match[1] });
898
+ }
899
+ }
900
+ return imports;
901
+ }
902
+ incrementUsage(usageMap, packageName, filePath, isDevDependency, language) {
903
+ const existing = usageMap.get(packageName);
904
+ if (existing) {
905
+ existing.importCount++;
906
+ if (!existing.files.includes(filePath)) {
907
+ existing.fileCount++;
908
+ existing.files.push(filePath);
909
+ }
910
+ } else {
911
+ usageMap.set(packageName, {
912
+ packageName,
913
+ importCount: 1,
914
+ fileCount: 1,
915
+ files: [filePath],
916
+ isDevDependency,
917
+ language
918
+ });
919
+ }
920
+ }
921
+ async scanDirectory(dir) {
922
+ const files = [];
923
+ try {
924
+ const entries = await readdir(dir, { withFileTypes: true });
925
+ for (const entry of entries) {
926
+ const fullPath = join3(dir, entry.name);
927
+ if (entry.isDirectory()) {
928
+ if (!["node_modules", ".git", "dist", "build", "coverage", "__pycache__", ".venv", "venv"].includes(entry.name)) {
929
+ files.push(...await this.scanDirectory(fullPath));
930
+ }
931
+ } else if (entry.isFile()) {
932
+ const ext = extname(entry.name);
933
+ if (TEXT_EXTENSIONS.has(ext)) {
934
+ files.push(fullPath);
935
+ }
936
+ }
937
+ }
938
+ } catch {
939
+ }
940
+ return files;
941
+ }
942
+ async readDeclaredDependencies(projectRoot) {
943
+ const deps = /* @__PURE__ */ new Map();
944
+ const packageJsonPath = join3(projectRoot, "package.json");
945
+ if (existsSync2(packageJsonPath)) {
946
+ try {
947
+ const content = await readFile(packageJsonPath, "utf-8");
948
+ const parsed = JSON.parse(content);
949
+ if (isRecord(parsed)) {
950
+ if (isRecord(parsed["dependencies"])) {
951
+ for (const name of Object.keys(parsed["dependencies"])) {
952
+ deps.set(name, { name, isDev: false, language: "javascript" });
953
+ }
954
+ }
955
+ if (isRecord(parsed["devDependencies"])) {
956
+ for (const name of Object.keys(parsed["devDependencies"])) {
957
+ deps.set(name, { name, isDev: true, language: "javascript" });
958
+ }
959
+ }
960
+ }
961
+ } catch {
962
+ }
963
+ }
964
+ const reqPath = join3(projectRoot, "requirements.txt");
965
+ if (existsSync2(reqPath)) {
966
+ try {
967
+ const content = await readFile(reqPath, "utf-8");
968
+ const lines = content.split("\n");
969
+ for (const line of lines) {
970
+ const trimmed = line.trim();
971
+ if (trimmed === "" || trimmed.startsWith("#")) continue;
972
+ const match = /^([a-zA-Z0-9_-]+)/.exec(trimmed);
973
+ if (match !== null && match[1] !== void 0) {
974
+ const name = match[1].toLowerCase();
975
+ deps.set(name, { name, isDev: false, language: "python" });
976
+ }
977
+ }
978
+ } catch {
979
+ }
980
+ }
981
+ const pyprojectPath = join3(projectRoot, "pyproject.toml");
982
+ if (existsSync2(pyprojectPath)) {
983
+ try {
984
+ const content = await readFile(pyprojectPath, "utf-8");
985
+ const depMatches = content.matchAll(/"([a-zA-Z0-9_-]+)"/g);
986
+ for (const match of depMatches) {
987
+ if (match[1] !== void 0) {
988
+ const name = match[1].toLowerCase();
989
+ deps.set(name, { name, isDev: false, language: "python" });
990
+ }
991
+ }
992
+ } catch {
993
+ }
994
+ }
995
+ const cargoPath = join3(projectRoot, "Cargo.toml");
996
+ if (existsSync2(cargoPath)) {
997
+ try {
998
+ const content = await readFile(cargoPath, "utf-8");
999
+ const inDepsSection = /\[dependencies\]([\s\S]*?)(?=\n\[|$)/;
1000
+ const depsMatch = inDepsSection.exec(content);
1001
+ if (depsMatch !== null && depsMatch[1] !== void 0) {
1002
+ const depsSection = depsMatch[1];
1003
+ const cratePattern = /^([a-zA-Z0-9_-]+)\s*=/gm;
1004
+ for (const match of depsSection.matchAll(cratePattern)) {
1005
+ if (match[1] !== void 0) {
1006
+ deps.set(match[1], { name: match[1], isDev: false, language: "rust" });
1007
+ }
1008
+ }
1009
+ }
1010
+ const inDevDepsSection = /\[dev-dependencies\]([\s\S]*?)(?=\n\[|$)/;
1011
+ const devDepsMatch = inDevDepsSection.exec(content);
1012
+ if (devDepsMatch !== null && devDepsMatch[1] !== void 0) {
1013
+ const devDepsSection = devDepsMatch[1];
1014
+ const cratePattern = /^([a-zA-Z0-9_-]+)\s*=/gm;
1015
+ for (const match of devDepsSection.matchAll(cratePattern)) {
1016
+ if (match[1] !== void 0) {
1017
+ deps.set(match[1], { name: match[1], isDev: true, language: "rust" });
1018
+ }
1019
+ }
1020
+ }
1021
+ } catch {
1022
+ }
1023
+ }
1024
+ const goModPath = join3(projectRoot, "go.mod");
1025
+ if (existsSync2(goModPath)) {
1026
+ try {
1027
+ const content = await readFile(goModPath, "utf-8");
1028
+ const requirePattern = /^\s*([a-zA-Z0-9._/-]+)\s+v[\d.]+/gm;
1029
+ for (const match of content.matchAll(requirePattern)) {
1030
+ if (match[1] !== void 0 && !match[1].startsWith("//")) {
1031
+ deps.set(match[1], { name: match[1], isDev: false, language: "go" });
1032
+ }
1033
+ }
1034
+ } catch {
1035
+ }
1036
+ }
1037
+ return deps;
1038
+ }
1039
+ };
1040
+
1041
+ // src/analysis/repo-url-resolver.ts
1042
+ function isObject(value) {
1043
+ return typeof value === "object" && value !== null;
1044
+ }
1045
+ var RepoUrlResolver = class {
1046
+ /**
1047
+ * Find the GitHub repository URL for a package
1048
+ */
1049
+ async findRepoUrl(packageName, language = "javascript") {
1050
+ let registryUrl = null;
1051
+ switch (language) {
1052
+ case "javascript":
1053
+ registryUrl = await this.tryNpmRegistry(packageName);
1054
+ break;
1055
+ case "python":
1056
+ registryUrl = await this.tryPyPiRegistry(packageName);
1057
+ break;
1058
+ case "rust":
1059
+ registryUrl = await this.tryCratesRegistry(packageName);
1060
+ break;
1061
+ case "go":
1062
+ registryUrl = await this.tryGoModule(packageName);
1063
+ break;
1064
+ }
1065
+ if (registryUrl !== null) {
1066
+ return { url: registryUrl, confidence: "high", source: "registry" };
1067
+ }
1068
+ return { url: null, confidence: "low", source: "fallback" };
1069
+ }
1070
+ /**
1071
+ * Query NPM registry for package metadata
1072
+ */
1073
+ async tryNpmRegistry(packageName) {
1074
+ try {
1075
+ const response = await fetch(`https://registry.npmjs.org/${packageName}`);
1076
+ if (!response.ok) {
1077
+ return null;
1078
+ }
1079
+ const data = await response.json();
1080
+ if (!isObject(data)) {
1081
+ return null;
1082
+ }
1083
+ if ("repository" in data) {
1084
+ const repo = data["repository"];
1085
+ if (isObject(repo) && "url" in repo) {
1086
+ const urlValue = repo["url"];
1087
+ const url = String(urlValue);
1088
+ return this.normalizeRepoUrl(url);
1089
+ }
1090
+ if (typeof repo === "string") {
1091
+ return this.normalizeRepoUrl(repo);
1092
+ }
1093
+ }
1094
+ return null;
1095
+ } catch {
1096
+ return null;
1097
+ }
1098
+ }
1099
+ /**
1100
+ * Query PyPI registry for package metadata
1101
+ */
1102
+ async tryPyPiRegistry(packageName) {
1103
+ try {
1104
+ const response = await fetch(`https://pypi.org/pypi/${packageName}/json`);
1105
+ if (!response.ok) {
1106
+ return null;
1107
+ }
1108
+ const data = await response.json();
1109
+ if (!isObject(data)) {
1110
+ return null;
1111
+ }
1112
+ if ("info" in data) {
1113
+ const info = data["info"];
1114
+ if (isObject(info) && "project_urls" in info) {
1115
+ const projectUrls = info["project_urls"];
1116
+ if (isObject(projectUrls)) {
1117
+ const urlKeys = ["Source", "Repository", "Code", "Homepage"];
1118
+ for (const key of urlKeys) {
1119
+ if (key in projectUrls) {
1120
+ const urlValue = projectUrls[key];
1121
+ const url = String(urlValue);
1122
+ if (url.includes("github.com")) {
1123
+ return this.normalizeRepoUrl(url);
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+ }
1129
+ }
1130
+ return null;
1131
+ } catch {
1132
+ return null;
1133
+ }
1134
+ }
1135
+ /**
1136
+ * Query crates.io registry for Rust crate metadata
1137
+ */
1138
+ async tryCratesRegistry(crateName) {
1139
+ try {
1140
+ const response = await fetch(`https://crates.io/api/v1/crates/${crateName}`, {
1141
+ headers: {
1142
+ // crates.io requires a User-Agent header
1143
+ "User-Agent": "bluera-knowledge (https://github.com/blueraai/bluera-knowledge)"
1144
+ }
1145
+ });
1146
+ if (!response.ok) {
1147
+ return null;
1148
+ }
1149
+ const data = await response.json();
1150
+ if (!isObject(data)) {
1151
+ return null;
1152
+ }
1153
+ if ("crate" in data) {
1154
+ const crate = data["crate"];
1155
+ if (isObject(crate) && "repository" in crate) {
1156
+ const repo = crate["repository"];
1157
+ if (typeof repo === "string") {
1158
+ return this.normalizeRepoUrl(repo);
1159
+ }
1160
+ }
1161
+ }
1162
+ return null;
1163
+ } catch {
1164
+ return null;
1165
+ }
1166
+ }
1167
+ /**
1168
+ * Resolve Go module to GitHub repository
1169
+ * Go modules often use GitHub URLs directly (e.g., github.com/gorilla/mux)
1170
+ */
1171
+ async tryGoModule(moduleName) {
1172
+ try {
1173
+ if (moduleName.startsWith("github.com/")) {
1174
+ const parts = moduleName.split("/");
1175
+ const owner = parts[1];
1176
+ const repo = parts[2];
1177
+ if (owner !== void 0 && repo !== void 0) {
1178
+ return `https://github.com/${owner}/${repo}`;
1179
+ }
1180
+ }
1181
+ const response = await fetch(`https://proxy.golang.org/${moduleName}/@latest`, {
1182
+ headers: {
1183
+ "User-Agent": "bluera-knowledge (https://github.com/blueraai/bluera-knowledge)"
1184
+ }
1185
+ });
1186
+ if (!response.ok) {
1187
+ return null;
1188
+ }
1189
+ return null;
1190
+ } catch {
1191
+ return null;
1192
+ }
1193
+ }
1194
+ /**
1195
+ * Normalize various repository URL formats to standard GitHub URL
1196
+ */
1197
+ normalizeRepoUrl(url) {
1198
+ let normalized = url.replace(/^git\+/, "");
1199
+ normalized = normalized.replace(/\.git$/, "");
1200
+ normalized = normalized.replace(/^git:\/\//, "https://");
1201
+ normalized = normalized.replace(/^ssh:\/\/git@/, "https://");
1202
+ normalized = normalized.replace(/^git@github\.com:/, "https://github.com/");
1203
+ if (normalized.includes("github.com")) {
1204
+ return normalized;
1205
+ }
1206
+ return null;
1207
+ }
1208
+ };
1209
+
1210
+ // src/plugin/commands.ts
1211
+ import ora4 from "ora";
1212
+ async function handleAddRepo(args) {
1213
+ const services = await createServices(void 0, void 0, process.env["PWD"]);
1214
+ const storeName = args.name ?? extractRepoName(args.url);
1215
+ console.log(`Cloning ${args.url}...`);
1216
+ const result = await services.store.create({
1217
+ name: storeName,
1218
+ type: "repo",
1219
+ url: args.url,
1220
+ ...args.branch !== void 0 ? { branch: args.branch } : {}
1221
+ });
1222
+ if (!result.success) {
1223
+ console.error(`Error: ${result.error.message}`);
1224
+ process.exit(1);
1225
+ }
1226
+ console.log(`Created store: ${storeName} (${result.data.id})`);
1227
+ if ("path" in result.data) {
1228
+ console.log(`Location: ${result.data.path}`);
1229
+ }
1230
+ console.log("\nIndexing...");
1231
+ const indexResult = await services.index.indexStore(result.data);
1232
+ if (indexResult.success) {
1233
+ console.log(`Indexed ${String(indexResult.data.documentsIndexed)} files`);
1234
+ } else {
1235
+ console.error(`Indexing failed: ${indexResult.error.message}`);
1236
+ }
1237
+ }
1238
+ async function handleAddFolder(args) {
1239
+ const services = await createServices(void 0, void 0, process.env["PWD"]);
1240
+ const { basename } = await import("path");
1241
+ const storeName = args.name ?? basename(args.path);
1242
+ console.log(`Adding folder: ${args.path}...`);
1243
+ const result = await services.store.create({
1244
+ name: storeName,
1245
+ type: "file",
1246
+ path: args.path
1247
+ });
1248
+ if (!result.success) {
1249
+ console.error(`Error: ${result.error.message}`);
1250
+ process.exit(1);
1251
+ }
1252
+ console.log(`Created store: ${storeName} (${result.data.id})`);
1253
+ if ("path" in result.data) {
1254
+ console.log(`Location: ${result.data.path}`);
1255
+ }
1256
+ console.log("\nIndexing...");
1257
+ const indexResult = await services.index.indexStore(result.data);
1258
+ if (indexResult.success) {
1259
+ console.log(`Indexed ${String(indexResult.data.documentsIndexed)} files`);
1260
+ } else {
1261
+ console.error(`Indexing failed: ${indexResult.error.message}`);
1262
+ }
1263
+ }
1264
+ async function handleStores() {
1265
+ const services = await createServices(void 0, void 0, process.env["PWD"]);
1266
+ const stores = await services.store.list();
1267
+ if (stores.length === 0) {
1268
+ console.log("No stores found.");
1269
+ console.log("\nCreate a store with:");
1270
+ console.log(" /bluera-knowledge:add-repo <url> --name=<name>");
1271
+ console.log(" /bluera-knowledge:add-folder <path> --name=<name>");
1272
+ return;
1273
+ }
1274
+ console.log("| Name | Type | ID | Source |");
1275
+ console.log("|------|------|----|--------------------|");
1276
+ for (const store of stores) {
1277
+ const name = store.name;
1278
+ const type = store.type;
1279
+ const id = store.id;
1280
+ let source = "";
1281
+ if ("url" in store && store.url !== void 0) {
1282
+ source = store.url;
1283
+ } else if ("path" in store) {
1284
+ source = store.path;
1285
+ }
1286
+ console.log(`| ${name} | ${type} | ${id.substring(0, 8)}... | ${source} |`);
1287
+ }
1288
+ }
1289
+ async function handleSuggest() {
1290
+ const projectRoot = process.env["PWD"] ?? process.cwd();
1291
+ console.log("Analyzing project dependencies...\n");
1292
+ const services = await createServices(void 0, void 0, projectRoot);
1293
+ const analyzer = new DependencyUsageAnalyzer();
1294
+ const resolver = new RepoUrlResolver();
1295
+ const spinner = ora4("Scanning source files...").start();
1296
+ const result = await analyzer.analyze(projectRoot, (current, total, message) => {
1297
+ spinner.text = `${message} (${String(current)}/${String(total)})`;
1298
+ });
1299
+ spinner.stop();
1300
+ if (!result.success) {
1301
+ console.error(`Error: ${result.error.message}`);
1302
+ process.exit(1);
1303
+ }
1304
+ const { usages, totalFilesScanned, skippedFiles } = result.data;
1305
+ console.log(`\u2714 Scanned ${String(totalFilesScanned)} files${skippedFiles > 0 ? ` (skipped ${String(skippedFiles)})` : ""}
1306
+ `);
1307
+ if (usages.length === 0) {
1308
+ console.log("No external dependencies found in this project.");
1309
+ console.log("\nMake sure you have a package.json or requirements.txt file.");
1310
+ return;
1311
+ }
1312
+ const existingStores = await services.store.list();
1313
+ const existingRepoNames = new Set(existingStores.map((s) => s.name));
1314
+ const newUsages = usages.filter((u) => !existingRepoNames.has(u.packageName));
1315
+ if (newUsages.length === 0) {
1316
+ console.log("\u2714 All dependencies are already in knowledge stores!");
1317
+ return;
1318
+ }
1319
+ const topSuggestions = newUsages.slice(0, 5);
1320
+ console.log("Top dependencies by usage in this project:\n");
1321
+ topSuggestions.forEach((usage, i) => {
1322
+ console.log(`${String(i + 1)}. ${usage.packageName}`);
1323
+ console.log(` ${String(usage.importCount)} imports across ${String(usage.fileCount)} files
1324
+ `);
1325
+ });
1326
+ console.log("Searching for repository URLs...\n");
1327
+ for (const usage of topSuggestions) {
1328
+ const repoResult = await resolver.findRepoUrl(
1329
+ usage.packageName,
1330
+ usage.language
1331
+ );
1332
+ if (repoResult.url !== null) {
1333
+ console.log(`\u2714 ${usage.packageName}: ${repoResult.url}`);
1334
+ console.log(` /bluera-knowledge:add-repo ${repoResult.url} --name=${usage.packageName}
1335
+ `);
1336
+ } else {
1337
+ console.log(`\u2717 ${usage.packageName}: Could not find repository URL`);
1338
+ console.log(` You can manually add it: /bluera-knowledge:add-repo <url> --name=${usage.packageName}
1339
+ `);
1340
+ }
1341
+ }
1342
+ console.log("Use the commands above to add repositories to your knowledge stores.");
1343
+ }
1344
+
1345
+ // src/cli/commands/plugin-api.ts
1346
+ function createAddRepoCommand(_getOptions) {
1347
+ return new Command9("add-repo").description("Clone and index a library source repository").argument("<url>", "Git repository URL").option("--name <name>", "Store name (defaults to repo name)").option("--branch <branch>", "Git branch to clone").action(async (url, options) => {
1348
+ await handleAddRepo({ url, ...options });
1349
+ });
1350
+ }
1351
+ function createAddFolderCommand(_getOptions) {
1352
+ return new Command9("add-folder").description("Index a local folder of reference material").argument("<path>", "Folder path to index").option("--name <name>", "Store name (defaults to folder name)").action(async (path, options) => {
1353
+ await handleAddFolder({ path, ...options });
1354
+ });
1355
+ }
1356
+ function createStoresCommand(_getOptions) {
1357
+ return new Command9("stores").description("List all indexed library stores").action(async () => {
1358
+ await handleStores();
1359
+ });
1360
+ }
1361
+ function createSuggestCommand(_getOptions) {
1362
+ return new Command9("suggest").description("Suggest important dependencies to add to knowledge stores").action(async () => {
1363
+ await handleSuggest();
1364
+ });
1365
+ }
1366
+
1367
+ // src/index.ts
1368
+ var DEFAULT_DATA_DIR = join4(homedir2(), ".bluera", "bluera-knowledge", "data");
1369
+ var DEFAULT_CONFIG = join4(homedir2(), ".bluera", "bluera-knowledge", "config.json");
1370
+ var DEFAULT_REPOS_DIR2 = join4(homedir2(), ".bluera", "bluera-knowledge", "repos");
1371
+ function formatCommandHelp(cmd, indent = "") {
1372
+ const lines = [];
1373
+ const name = cmd.name();
1374
+ const desc = cmd.description();
1375
+ const args = cmd.registeredArguments.map((a) => {
1376
+ const req = a.required;
1377
+ return req ? `<${a.name()}>` : `[${a.name()}]`;
1378
+ }).join(" ");
1379
+ lines.push(`${indent}${name}${args ? " " + args : ""}`);
1380
+ if (desc) {
1381
+ lines.push(`${indent} ${desc}`);
1382
+ }
1383
+ const options = cmd.options.filter((o) => o.flags !== "-h, --help");
1384
+ for (const opt of options) {
1385
+ lines.push(`${indent} ${opt.flags.padEnd(28)} ${opt.description}`);
1386
+ }
1387
+ const subcommands = cmd.commands.filter((c) => c.name() !== "help");
1388
+ for (const sub of subcommands) {
1389
+ lines.push("");
1390
+ lines.push(...formatCommandHelp(sub, indent + " "));
1391
+ }
1392
+ return lines;
1393
+ }
1394
+ function printFullHelp(program2) {
1395
+ console.log("bluera-knowledge - CLI tool for managing knowledge stores with semantic search\n");
1396
+ console.log("Paths:");
1397
+ console.log(` data ${DEFAULT_DATA_DIR}`);
1398
+ console.log(` config ${DEFAULT_CONFIG}`);
1399
+ console.log(` repos ${DEFAULT_REPOS_DIR2}`);
1400
+ console.log("\nGlobal options:");
1401
+ const globalOpts = program2.options.filter((o) => o.flags !== "-h, --help" && o.flags !== "-V, --version");
1402
+ for (const opt of globalOpts) {
1403
+ console.log(` ${opt.flags.padEnd(28)} ${opt.description}`);
1404
+ }
1405
+ console.log("\nCommands:\n");
1406
+ const commands = program2.commands.filter((c) => c.name() !== "help");
1407
+ for (const cmd of commands) {
1408
+ console.log(formatCommandHelp(cmd).join("\n"));
1409
+ console.log("");
1410
+ }
1411
+ }
1412
+ var program = createProgram();
1413
+ program.addCommand(createAddRepoCommand(() => getGlobalOptions(program)));
1414
+ program.addCommand(createAddFolderCommand(() => getGlobalOptions(program)));
1415
+ program.addCommand(createStoresCommand(() => getGlobalOptions(program)));
1416
+ program.addCommand(createSuggestCommand(() => getGlobalOptions(program)));
1417
+ program.addCommand(createStoreCommand(() => getGlobalOptions(program)));
1418
+ program.addCommand(createSearchCommand(() => getGlobalOptions(program)));
1419
+ program.addCommand(createIndexCommand(() => getGlobalOptions(program)));
1420
+ program.addCommand(createServeCommand(() => getGlobalOptions(program)));
1421
+ program.addCommand(createCrawlCommand(() => getGlobalOptions(program)));
1422
+ program.addCommand(createSetupCommand(() => getGlobalOptions(program)));
1423
+ program.addCommand(createMCPCommand(() => getGlobalOptions(program)));
1424
+ if (process.argv.length <= 2) {
1425
+ printFullHelp(program);
1426
+ process.exit(0);
1427
+ }
1428
+ program.parse();
1429
+ //# sourceMappingURL=index.js.map