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.
- package/.claude/commands/commit.md +37 -0
- package/.claude/hooks/post-edit-check.sh +41 -0
- package/.claude/settings.local.json.example +40 -0
- package/.claude/skills/atomic-commits/SKILL.md +53 -0
- package/.claude-plugin/plugin.json +13 -0
- package/.editorconfig +15 -0
- package/.github/workflows/auto-release.yml +59 -0
- package/.github/workflows/ci.yml +142 -0
- package/.github/workflows/release.yml +66 -0
- package/.github/workflows/update-marketplace.yml +96 -0
- package/.husky/pre-commit +47 -0
- package/.husky/pre-push +29 -0
- package/.versionrc.json +28 -0
- package/CHANGELOG.md +410 -0
- package/CLAUDE.md +109 -0
- package/LICENSE +21 -0
- package/NOTICE +47 -0
- package/README.md +1546 -0
- package/SECURITY.md +65 -0
- package/bun.lock +1758 -0
- package/commands/add-folder.md +48 -0
- package/commands/add-repo.md +50 -0
- package/commands/cancel.md +63 -0
- package/commands/check-status.md +78 -0
- package/commands/crawl.md +51 -0
- package/commands/index.md +48 -0
- package/commands/remove-store.md +52 -0
- package/commands/search.md +79 -0
- package/commands/search.sh +63 -0
- package/commands/stores.md +54 -0
- package/commands/suggest.md +82 -0
- package/dist/chunk-5QMHZUC4.js +3617 -0
- package/dist/chunk-5QMHZUC4.js.map +1 -0
- package/dist/chunk-BICFAWMN.js +656 -0
- package/dist/chunk-BICFAWMN.js.map +1 -0
- package/dist/chunk-J7J6LXOJ.js +958 -0
- package/dist/chunk-J7J6LXOJ.js.map +1 -0
- package/dist/chunk-L2YVNC63.js +59 -0
- package/dist/chunk-L2YVNC63.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1429 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +11 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/watch.service-YAIKKDCF.js +7 -0
- package/dist/watch.service-YAIKKDCF.js.map +1 -0
- package/dist/workers/background-worker-cli.d.ts +1 -0
- package/dist/workers/background-worker-cli.js +310 -0
- package/dist/workers/background-worker-cli.js.map +1 -0
- package/docs/plans/2024-12-17-ai-search-quality-implementation.md +752 -0
- package/docs/plans/2024-12-17-ai-search-quality-testing-design.md +201 -0
- package/docs/plans/2025-12-16-bluera-knowledge-cli.md +2951 -0
- package/docs/plans/2025-12-16-phase2-features.md +1518 -0
- package/docs/plans/2025-12-17-hil-implementation.md +926 -0
- package/docs/plans/2025-12-17-hil-quality-testing.md +224 -0
- package/docs/plans/2025-12-17-search-quality-phase1-implementation.md +1416 -0
- package/docs/plans/2025-12-17-search-quality-testing-v2-design.md +212 -0
- package/docs/plans/2025-12-28-ai-agent-optimization.md +1630 -0
- package/eslint-rules/require-skip-comment.js +81 -0
- package/eslint.config.js +61 -0
- package/hooks/check-dependencies.sh +110 -0
- package/hooks/format-search-results.py +132 -0
- package/hooks/hooks.json +27 -0
- package/hooks/job-status-hook.sh +51 -0
- package/knip.json +43 -0
- package/mcp.plugin.json +12 -0
- package/package.json +103 -0
- package/python/crawl_worker.py +275 -0
- package/python/requirements.txt +2 -0
- package/scripts/readme-version-updater.cjs +18 -0
- package/skills/advanced-workflows/SKILL.md +273 -0
- package/skills/atomic-commits/SKILL.md +77 -0
- package/skills/knowledge-search/SKILL.md +54 -0
- package/skills/search-optimization/SKILL.md +396 -0
- package/skills/store-lifecycle/SKILL.md +470 -0
- package/skills/when-to-query/SKILL.md +66 -0
- package/src/analysis/ast-parser.test.ts +423 -0
- package/src/analysis/ast-parser.ts +192 -0
- package/src/analysis/code-graph.test.ts +698 -0
- package/src/analysis/code-graph.ts +245 -0
- package/src/analysis/dependency-usage-analyzer.test.ts +799 -0
- package/src/analysis/dependency-usage-analyzer.ts +405 -0
- package/src/analysis/go-ast-parser.test.ts +531 -0
- package/src/analysis/go-ast-parser.ts +478 -0
- package/src/analysis/parser-factory.test.ts +132 -0
- package/src/analysis/parser-factory.ts +44 -0
- package/src/analysis/python-ast-parser.test.ts +210 -0
- package/src/analysis/python-ast-parser.ts +34 -0
- package/src/analysis/repo-url-resolver.test.ts +533 -0
- package/src/analysis/repo-url-resolver.ts +233 -0
- package/src/analysis/rust-ast-parser.test.ts +568 -0
- package/src/analysis/rust-ast-parser.ts +477 -0
- package/src/analysis/tree-sitter-parser.test.ts +297 -0
- package/src/analysis/tree-sitter-parser.ts +223 -0
- package/src/cli/commands/crawl.test.ts +942 -0
- package/src/cli/commands/crawl.ts +141 -0
- package/src/cli/commands/index-cmd.test.ts +722 -0
- package/src/cli/commands/index-cmd.ts +105 -0
- package/src/cli/commands/mcp.test.ts +218 -0
- package/src/cli/commands/mcp.ts +18 -0
- package/src/cli/commands/plugin-api.test.ts +313 -0
- package/src/cli/commands/plugin-api.ts +45 -0
- package/src/cli/commands/search.test.ts +911 -0
- package/src/cli/commands/search.ts +113 -0
- package/src/cli/commands/serve.test.ts +329 -0
- package/src/cli/commands/serve.ts +28 -0
- package/src/cli/commands/setup.test.ts +820 -0
- package/src/cli/commands/setup.ts +153 -0
- package/src/cli/commands/store.test.ts +1003 -0
- package/src/cli/commands/store.ts +167 -0
- package/src/cli/index.ts +7 -0
- package/src/cli/program.ts +59 -0
- package/src/crawl/article-converter.test.ts +604 -0
- package/src/crawl/article-converter.ts +98 -0
- package/src/crawl/bridge.test.ts +674 -0
- package/src/crawl/bridge.ts +236 -0
- package/src/crawl/claude-client.test.ts +663 -0
- package/src/crawl/claude-client.ts +234 -0
- package/src/crawl/intelligent-crawler.test.ts +931 -0
- package/src/crawl/intelligent-crawler.ts +428 -0
- package/src/crawl/markdown-utils.test.ts +703 -0
- package/src/crawl/markdown-utils.ts +228 -0
- package/src/crawl/schemas.ts +114 -0
- package/src/db/embeddings.test.ts +63 -0
- package/src/db/embeddings.ts +69 -0
- package/src/db/index.ts +2 -0
- package/src/db/lance.test.ts +390 -0
- package/src/db/lance.ts +164 -0
- package/src/defaults/repos.ts +67 -0
- package/src/index.ts +107 -0
- package/src/mcp/cache.test.ts +202 -0
- package/src/mcp/cache.ts +103 -0
- package/src/mcp/commands/index.ts +20 -0
- package/src/mcp/commands/job.commands.ts +54 -0
- package/src/mcp/commands/meta.commands.ts +54 -0
- package/src/mcp/commands/registry.ts +183 -0
- package/src/mcp/commands/store.commands.ts +75 -0
- package/src/mcp/handlers/execute.handler.test.ts +179 -0
- package/src/mcp/handlers/execute.handler.ts +24 -0
- package/src/mcp/handlers/index.ts +43 -0
- package/src/mcp/handlers/job.handler.test.ts +189 -0
- package/src/mcp/handlers/job.handler.ts +116 -0
- package/src/mcp/handlers/search.handler.test.ts +334 -0
- package/src/mcp/handlers/search.handler.ts +209 -0
- package/src/mcp/handlers/store.handler.test.ts +415 -0
- package/src/mcp/handlers/store.handler.ts +295 -0
- package/src/mcp/schemas/index.test.ts +315 -0
- package/src/mcp/schemas/index.ts +138 -0
- package/src/mcp/server.test.ts +36 -0
- package/src/mcp/server.ts +162 -0
- package/src/mcp/types.ts +41 -0
- package/src/plugin/commands.test.ts +789 -0
- package/src/plugin/commands.ts +257 -0
- package/src/plugin/dependency-analyzer.test.ts +380 -0
- package/src/plugin/dependency-analyzer.ts +147 -0
- package/src/plugin/git-clone.test.ts +332 -0
- package/src/plugin/git-clone.ts +57 -0
- package/src/server/app.test.ts +752 -0
- package/src/server/app.ts +119 -0
- package/src/server/index.test.ts +477 -0
- package/src/server/index.ts +1 -0
- package/src/services/chunking.service.test.ts +363 -0
- package/src/services/chunking.service.ts +350 -0
- package/src/services/code-graph.service.test.ts +304 -0
- package/src/services/code-graph.service.ts +302 -0
- package/src/services/code-unit.service.test.ts +596 -0
- package/src/services/code-unit.service.ts +115 -0
- package/src/services/config.service.test.ts +127 -0
- package/src/services/config.service.ts +69 -0
- package/src/services/index.service.test.ts +1002 -0
- package/src/services/index.service.ts +266 -0
- package/src/services/index.ts +75 -0
- package/src/services/job.service.test.ts +418 -0
- package/src/services/job.service.ts +246 -0
- package/src/services/project-root.service.test.ts +506 -0
- package/src/services/project-root.service.ts +112 -0
- package/src/services/search.service.test.ts +1105 -0
- package/src/services/search.service.ts +892 -0
- package/src/services/services.test.ts +38 -0
- package/src/services/snippet.service.test.ts +205 -0
- package/src/services/snippet.service.ts +166 -0
- package/src/services/store.service.test.ts +474 -0
- package/src/services/store.service.ts +225 -0
- package/src/services/watch.service.test.ts +553 -0
- package/src/services/watch.service.ts +71 -0
- package/src/types/brands.test.ts +45 -0
- package/src/types/brands.ts +32 -0
- package/src/types/config.ts +79 -0
- package/src/types/document.ts +30 -0
- package/src/types/index.ts +66 -0
- package/src/types/job.ts +46 -0
- package/src/types/progress.ts +9 -0
- package/src/types/result.test.ts +44 -0
- package/src/types/result.ts +41 -0
- package/src/types/search.ts +95 -0
- package/src/types/store.test.ts +69 -0
- package/src/types/store.ts +47 -0
- package/src/utils/type-guards.test.ts +346 -0
- package/src/utils/type-guards.ts +61 -0
- package/src/workers/background-worker-cli.ts +105 -0
- package/src/workers/background-worker.test.ts +178 -0
- package/src/workers/background-worker.ts +294 -0
- package/src/workers/spawn-worker.test.ts +128 -0
- package/src/workers/spawn-worker.ts +49 -0
- package/tests/analysis/ast-parser.test.ts +98 -0
- package/tests/analysis/code-graph.test.ts +60 -0
- package/tests/fixtures/README.md +114 -0
- package/tests/fixtures/code-snippets/api/error-handling.ts +267 -0
- package/tests/fixtures/code-snippets/api/rest-controller.ts +303 -0
- package/tests/fixtures/code-snippets/auth/jwt-auth.ts +213 -0
- package/tests/fixtures/code-snippets/auth/oauth-flow.ts +245 -0
- package/tests/fixtures/code-snippets/database/repository-pattern.ts +272 -0
- package/tests/fixtures/corpus/VERSION.md +25 -0
- package/tests/fixtures/corpus/articles/jwt-authentication.md +97 -0
- package/tests/fixtures/corpus/articles/react-hooks-patterns.md +127 -0
- package/tests/fixtures/corpus/articles/typescript-generics.md +111 -0
- package/tests/fixtures/corpus/documentation/express-middleware.md +71 -0
- package/tests/fixtures/corpus/documentation/express-routing.md +83 -0
- package/tests/fixtures/corpus/documentation/node-streams.md +78 -0
- package/tests/fixtures/corpus/oss-repos/express/History.md +3871 -0
- package/tests/fixtures/corpus/oss-repos/express/LICENSE +24 -0
- package/tests/fixtures/corpus/oss-repos/express/Readme.md +276 -0
- package/tests/fixtures/corpus/oss-repos/express/SECURITY.md +56 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/Makefile +17 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/README.md +34 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/middleware.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/run +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/README.md +29 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/index.js +134 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/foot.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/head.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/login.ejs +21 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/db.js +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/index.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/users.js +19 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/cookie-sessions/index.js +25 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/cookies/index.js +53 -0
- 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
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/amazing.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/notes/groceries.txt +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/index.js +40 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/index.js +57 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/public/stylesheets/style.css +4 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/footer.html +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/header.html +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/users.html +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error/index.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/index.js +103 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/404.ejs +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/500.ejs +8 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/error_header.ejs +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/footer.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/index.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/hello-world/index.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/index.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/views/index.md +4 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v1.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v2.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/index.js +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/main/index.js +5 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/index.js +31 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/edit.ejs +17 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/show.ejs +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/index.js +41 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/edit.hbs +27 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/list.hbs +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/show.hbs +31 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user-pet/index.js +22 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/db.js +16 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/index.js +95 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/lib/boot.js +83 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/public/style.css +14 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/404.ejs +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/5xx.ejs +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/online/index.js +61 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/params/index.js +74 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/resource/index.js +95 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-map/index.js +75 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-middleware/index.js +90 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/index.js +55 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/post.js +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/public/style.css +24 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/site.js +5 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/user.js +47 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/footer.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/header.ejs +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/index.ejs +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/posts/index.ejs +12 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/edit.ejs +23 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/index.ejs +14 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/view.ejs +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/index.js +61 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/client.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/index.html +21 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/session/index.js +37 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/session/redis.js +39 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/index.js +43 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/css/style.css +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/hello.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/js/app.js +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/vhost/index.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/github-view.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/index.js +48 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/index.js +155 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/user.js +36 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/views/index.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/web-service/index.js +117 -0
- package/tests/fixtures/corpus/oss-repos/express/index.js +11 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/application.js +631 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/express.js +81 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/request.js +514 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/response.js +1053 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/utils.js +271 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/view.js +205 -0
- package/tests/fixtures/corpus/oss-repos/express/package.json +99 -0
- package/tests/fixtures/corpus/oss-repos/express/test/Route.js +274 -0
- package/tests/fixtures/corpus/oss-repos/express/test/Router.js +636 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/auth.js +117 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/content-negotiation.js +49 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookie-sessions.js +38 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookies.js +71 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/downloads.js +47 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/ejs.js +17 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error-pages.js +99 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error.js +29 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/hello-world.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/markdown.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/multi-router.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/mvc.js +132 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/params.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/resource.js +68 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-map.js +45 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-separation.js +97 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/vhost.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/web-service.js +105 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.all.js +38 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.engine.js +83 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.head.js +66 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.js +120 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.listen.js +55 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.locals.js +26 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.options.js +116 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.param.js +323 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.render.js +374 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.request.js +143 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.response.js +143 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.route.js +197 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.router.js +1217 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.routes.error.js +62 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.use.js +542 -0
- package/tests/fixtures/corpus/oss-repos/express/test/config.js +207 -0
- package/tests/fixtures/corpus/oss-repos/express/test/exports.js +82 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.json.js +755 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.raw.js +513 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.static.js +815 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.text.js +566 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.urlencoded.js +828 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/% of dogs.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/.name +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/index.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/post/index.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/broken.send +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/name.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/email.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/empty.txt +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/local_layout/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/nums.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/pets/names.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/snow /342/230/203/.gitkeep +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/index.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/tobi.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/middleware.basic.js +42 -0
- package/tests/fixtures/corpus/oss-repos/express/test/regression.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.accepts.js +125 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsCharsets.js +50 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsEncodings.js +39 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsLanguages.js +57 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.baseUrl.js +88 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.fresh.js +70 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.get.js +60 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.host.js +156 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.hostname.js +188 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.ip.js +113 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.ips.js +71 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.is.js +169 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.path.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.protocol.js +113 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.query.js +106 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.range.js +104 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.route.js +28 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.secure.js +101 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.signedCookies.js +37 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.stale.js +50 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.subdomains.js +173 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.xhr.js +42 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.append.js +116 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.attachment.js +79 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.clearCookie.js +62 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.cookie.js +295 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.download.js +487 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.format.js +248 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.get.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.json.js +186 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.jsonp.js +344 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.links.js +65 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.locals.js +40 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.location.js +316 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.redirect.js +214 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.render.js +367 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.send.js +569 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendFile.js +913 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendStatus.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.set.js +124 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.status.js +206 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.type.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.vary.js +90 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/env.js +3 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/tmpl.js +36 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/utils.js +86 -0
- package/tests/fixtures/corpus/oss-repos/express/test/utils.js +83 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/Dockerfile +11 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/devcontainer.json +21 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/docker-compose.yml +18 -0
- package/tests/fixtures/corpus/oss-repos/hono/.eslintignore +1 -0
- package/tests/fixtures/corpus/oss-repos/hono/.eslintrc.cjs +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.gitpod.yml +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.prettierrc +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-default.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-dom.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/setup-vitest.ts +47 -0
- package/tests/fixtures/corpus/oss-repos/hono/LICENSE +21 -0
- package/tests/fixtures/corpus/oss-repos/hono/README.md +91 -0
- package/tests/fixtures/corpus/oss-repos/hono/build.ts +80 -0
- package/tests/fixtures/corpus/oss-repos/hono/bun.lockb +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/bunfig.toml +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/codecov.yml +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/CODE_OF_CONDUCT.md +128 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/CONTRIBUTING.md +62 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/MIGRATION.md +295 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.png +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.pxm +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.svg +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.png +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.pxm +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/jsr.json +119 -0
- package/tests/fixtures/corpus/oss-repos/hono/package.cjs.json +3 -0
- package/tests/fixtures/corpus/oss-repos/hono/package.json +650 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +492 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/types.ts +144 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/conninfo.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/serve-static.ts +35 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/server.ts +30 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/ssg.ts +27 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/websocket.ts +110 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +120 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/conninfo.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static-module.ts +12 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +39 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/utils.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/websocket.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/conninfo.ts +17 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/deno.d.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/serve-static.ts +40 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/ssg.ts +27 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/websocket.ts +51 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/conninfo.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/handler.ts +189 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/index.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/handler.ts +10 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/mod.ts +1 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/handler.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/index.ts +5 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/types.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/conninfo.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/handler.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +214 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/index.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +180 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/utils.ts +54 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/compose.ts +94 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +914 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +81 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +85 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/types.ts +45 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/cookie/index.ts +130 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/common.ts +243 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +220 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/dev/index.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +246 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/html/index.ts +56 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/middleware.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +388 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/utils.ts +71 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/sse.ts +89 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/stream.ts +36 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/text.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/testing/index.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/websocket/index.ts +57 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +523 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/http-exception.ts +78 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/index.ts +51 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/base.ts +419 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/children.ts +20 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/components.ts +195 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/constants.ts +5 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/context.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/client.ts +89 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/components.ts +39 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/context.ts +52 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +246 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/hooks/index.ts +91 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/index.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +398 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-dev-runtime.ts +22 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-runtime.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +772 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/server.ts +70 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/utils.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +426 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/index.ts +114 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/common.ts +11 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +196 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-elements.ts +924 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-dev-runtime.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-runtime.ts +18 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/streaming.ts +184 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/types.ts +41 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +36 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/basic-auth/index.ts +128 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/bearer-auth/index.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/body-limit/index.ts +115 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cache/index.ts +127 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/combine/index.ts +153 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/compress/index.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/context-storage/index.ts +55 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cors/index.ts +141 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/csrf/index.ts +90 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/etag/index.ts +88 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/ip-restriction/index.ts +178 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +158 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/jwt.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/logger/index.ts +93 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/method-override/index.ts +146 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/powered-by/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/pretty-json/index.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/request-id.ts +59 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/permissions-policy.ts +86 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/secure-headers.ts +319 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +140 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timeout/index.ts +58 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/timing.ts +225 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/trailing-slash/index.ts +71 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +24 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +20 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/request.ts +403 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/router.ts +132 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +54 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +274 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/trie.ts +74 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/router.ts +69 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +205 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/router.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router.ts +103 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +2009 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/basic-auth.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +225 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/buffer.ts +65 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/concurrent.ts +55 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +230 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/crypto.ts +65 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/filepath.ts +56 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/handler.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/html.ts +182 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/http-status.ts +69 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/ipaddr.ts +113 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwa.ts +23 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jws.ts +226 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwt.ts +114 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/types.ts +83 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/utf8.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/mime.ts +142 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/stream.ts +96 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +105 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/url.ts +310 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +151 -0
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.build.json +23 -0
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.json +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/vitest.config.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/yarn.lock +6232 -0
- package/tests/fixtures/documentation/api-reference.md +412 -0
- package/tests/fixtures/documentation/architecture.md +214 -0
- package/tests/fixtures/documentation/deployment-guide.md +420 -0
- package/tests/fixtures/github-readmes/express.md +133 -0
- package/tests/fixtures/github-readmes/nextjs.md +106 -0
- package/tests/fixtures/github-readmes/react.md +74 -0
- package/tests/fixtures/github-readmes/typescript.md +93 -0
- package/tests/fixtures/github-readmes/vite.md +79 -0
- package/tests/fixtures/queries/core.json +125 -0
- package/tests/fixtures/queries/extended.json +427 -0
- package/tests/fixtures/queries/generated/.gitkeep +0 -0
- package/tests/fixtures/test-server.ts +267 -0
- package/tests/helpers/performance-metrics.ts +387 -0
- package/tests/helpers/search-relevance.ts +381 -0
- package/tests/integration/cli-consistency.test.ts +299 -0
- package/tests/integration/cli.test.ts +69 -0
- package/tests/integration/e2e-workflow.test.ts +612 -0
- package/tests/integration/python-bridge.test.ts +183 -0
- package/tests/integration/search-quality.test.ts +718 -0
- package/tests/integration/stress.test.ts +326 -0
- package/tests/mcp/server.test.ts +15 -0
- package/tests/scripts/schemas/evaluation.json +44 -0
- package/tests/scripts/schemas/query-generation.json +21 -0
- package/tests/services/code-unit.service.test.ts +47 -0
- package/tests/services/search.progressive-context.test.ts +35 -0
- package/tsconfig.json +34 -0
- package/tsup.config.ts +15 -0
- package/turndown-plugin-gfm.d.ts +29 -0
- package/vitest.config.ts +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/job.service.ts","../src/types/result.ts","../src/services/config.service.ts","../src/types/config.ts","../src/services/project-root.service.ts","../src/services/store.service.ts","../src/types/brands.ts","../src/plugin/git-clone.ts","../src/services/code-unit.service.ts","../src/services/search.service.ts","../src/services/index.service.ts","../src/services/chunking.service.ts","../src/services/code-graph.service.ts","../src/analysis/code-graph.ts","../src/analysis/ast-parser.ts","../src/analysis/tree-sitter-parser.ts","../src/analysis/rust-ast-parser.ts","../src/analysis/go-ast-parser.ts","../src/analysis/parser-factory.ts","../src/analysis/python-ast-parser.ts","../src/db/lance.ts","../src/db/embeddings.ts","../src/crawl/bridge.ts","../src/crawl/schemas.ts","../src/services/index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { randomUUID } from 'crypto';\nimport type {\n Job,\n CreateJobParams,\n UpdateJobParams,\n JobStatus\n} from '../types/job.js';\nimport { Result, ok, err } from '../types/result.js';\n\nexport class JobService {\n private readonly jobsDir: string;\n\n constructor(dataDir?: string) {\n // Default to ~/.local/share/bluera-knowledge/jobs\n const baseDir = dataDir ?? path.join(\n process.env['HOME'] ?? process.env['USERPROFILE'] ?? '.',\n '.local/share/bluera-knowledge'\n );\n this.jobsDir = path.join(baseDir, 'jobs');\n\n // Ensure jobs directory exists\n if (!fs.existsSync(this.jobsDir)) {\n fs.mkdirSync(this.jobsDir, { recursive: true });\n }\n }\n\n /**\n * Create a new job\n */\n createJob(params: CreateJobParams): Job {\n const job: Job = {\n id: `job_${randomUUID().replace(/-/g, '').substring(0, 12)}`,\n type: params.type,\n status: 'pending',\n progress: 0,\n message: params.message ?? `${params.type} job created`,\n details: params.details,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString()\n };\n\n // Write job to file\n this.writeJob(job);\n\n return job;\n }\n\n /**\n * Update an existing job\n */\n updateJob(jobId: string, updates: UpdateJobParams): void {\n const job = this.getJob(jobId);\n\n if (!job) {\n throw new Error(`Job ${jobId} not found`);\n }\n\n // Merge updates\n if (updates.status !== undefined) {\n job.status = updates.status;\n }\n if (updates.progress !== undefined) {\n job.progress = updates.progress;\n }\n if (updates.message !== undefined) {\n job.message = updates.message;\n }\n if (updates.details !== undefined) {\n job.details = { ...job.details, ...updates.details };\n }\n\n job.updatedAt = new Date().toISOString();\n\n // Write updated job\n this.writeJob(job);\n }\n\n /**\n * Get a job by ID\n */\n getJob(jobId: string): Job | null {\n const jobFile = path.join(this.jobsDir, `${jobId}.json`);\n\n if (!fs.existsSync(jobFile)) {\n return null;\n }\n\n try {\n const content = fs.readFileSync(jobFile, 'utf-8');\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return JSON.parse(content) as Job;\n } catch (error) {\n console.error(`Error reading job ${jobId}:`, error);\n return null;\n }\n }\n\n /**\n * List all jobs with optional status filter\n */\n listJobs(statusFilter?: JobStatus | JobStatus[]): Job[] {\n if (!fs.existsSync(this.jobsDir)) {\n return [];\n }\n\n const files = fs.readdirSync(this.jobsDir);\n const jobs: Job[] = [];\n\n for (const file of files) {\n if (!file.endsWith('.json') || file.endsWith('.pid')) {\n continue;\n }\n\n try {\n const content = fs.readFileSync(path.join(this.jobsDir, file), 'utf-8');\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const job = JSON.parse(content) as Job;\n\n if (statusFilter !== undefined) {\n const filters = Array.isArray(statusFilter) ? statusFilter : [statusFilter];\n if (filters.includes(job.status)) {\n jobs.push(job);\n }\n } else {\n jobs.push(job);\n }\n } catch (error) {\n console.error(`Error reading job file ${file}:`, error);\n }\n }\n\n // Sort by updated time (most recent first)\n jobs.sort((a, b) =>\n new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()\n );\n\n return jobs;\n }\n\n /**\n * List active jobs (pending or running)\n */\n listActiveJobs(): Job[] {\n return this.listJobs(['pending', 'running']);\n }\n\n /**\n * Cancel a job\n */\n cancelJob(jobId: string): Result<void> {\n const job = this.getJob(jobId);\n\n if (!job) {\n return err(new Error(`Job ${jobId} not found`));\n }\n\n if (job.status === 'completed' || job.status === 'failed') {\n return err(new Error(`Cannot cancel ${job.status} job`));\n }\n\n if (job.status === 'cancelled') {\n return ok(undefined);\n }\n\n // Update job status\n this.updateJob(jobId, {\n status: 'cancelled',\n message: 'Job cancelled by user',\n details: { cancelledAt: new Date().toISOString() }\n });\n\n // Kill worker process if it exists\n const pidFile = path.join(this.jobsDir, `${jobId}.pid`);\n if (fs.existsSync(pidFile)) {\n try {\n const pid = parseInt(fs.readFileSync(pidFile, 'utf-8'), 10);\n process.kill(pid, 'SIGTERM');\n } catch {\n // Process may have already exited, ignore\n }\n // Always delete the PID file, even if kill failed\n try {\n fs.unlinkSync(pidFile);\n } catch {\n // Ignore if file already deleted\n }\n }\n\n return ok(undefined);\n }\n\n /**\n * Clean up old completed/failed/cancelled jobs\n */\n cleanupOldJobs(olderThanHours: number = 24): number {\n const jobs = this.listJobs();\n const cutoffTime = Date.now() - (olderThanHours * 60 * 60 * 1000);\n let cleaned = 0;\n\n for (const job of jobs) {\n if (\n (job.status === 'completed' || job.status === 'failed' || job.status === 'cancelled') &&\n new Date(job.updatedAt).getTime() < cutoffTime\n ) {\n const jobFile = path.join(this.jobsDir, `${job.id}.json`);\n try {\n fs.unlinkSync(jobFile);\n cleaned++;\n } catch (error) {\n console.error(`Error deleting job file ${job.id}:`, error);\n }\n }\n }\n\n return cleaned;\n }\n\n /**\n * Delete a specific job\n */\n deleteJob(jobId: string): boolean {\n const jobFile = path.join(this.jobsDir, `${jobId}.json`);\n\n if (!fs.existsSync(jobFile)) {\n return false;\n }\n\n try {\n fs.unlinkSync(jobFile);\n return true;\n } catch (error) {\n console.error(`Error deleting job ${jobId}:`, error);\n return false;\n }\n }\n\n /**\n * Write job to file\n */\n private writeJob(job: Job): void {\n const jobFile = path.join(this.jobsDir, `${job.id}.json`);\n fs.writeFileSync(jobFile, JSON.stringify(job, null, 2), 'utf-8');\n }\n}\n","export type Result<T, E = Error> =\n | { readonly success: true; readonly data: T }\n | { readonly success: false; readonly error: E };\n\nexport function ok<T>(data: T): Result<T, never> {\n return { success: true, data };\n}\n\nexport function err<E>(error: E): Result<never, E> {\n return { success: false, error };\n}\n\nexport function isOk<T, E>(result: Result<T, E>): result is { success: true; data: T } {\n return result.success;\n}\n\nexport function isErr<T, E>(result: Result<T, E>): result is { success: false; error: E } {\n return !result.success;\n}\n\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (isOk(result)) {\n return result.data;\n }\n // Type guard ensures result has 'error' property\n if (isErr(result)) {\n if (result.error instanceof Error) {\n throw result.error;\n }\n throw new Error(String(result.error));\n }\n // This should never happen due to discriminated union\n throw new Error('Invalid result type');\n}\n\nexport function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T {\n if (isOk(result)) {\n return result.data;\n }\n return defaultValue;\n}\n","import { readFile, writeFile, mkdir } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { homedir } from 'node:os';\nimport type { AppConfig } from '../types/config.js';\nimport { DEFAULT_CONFIG } from '../types/config.js';\nimport { ProjectRootService } from './project-root.service.js';\n\nexport class ConfigService {\n private readonly configPath: string;\n private readonly dataDir: string;\n private config: AppConfig | null = null;\n\n constructor(\n configPath = `${homedir()}/.bluera/bluera-knowledge/config.json`,\n dataDir?: string,\n projectRoot?: string\n ) {\n this.configPath = configPath;\n\n if (dataDir !== undefined && dataDir !== '') {\n // Explicit dataDir provided, use it as-is\n this.dataDir = dataDir;\n } else {\n // Resolve project root using hierarchical detection\n const root = projectRoot ?? ProjectRootService.resolve();\n // Expand relative default path against project root\n this.dataDir = this.expandPath(DEFAULT_CONFIG.dataDir, root);\n }\n }\n\n async load(): Promise<AppConfig> {\n if (this.config !== null) {\n return this.config;\n }\n\n try {\n const content = await readFile(this.configPath, 'utf-8');\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.config = { ...DEFAULT_CONFIG, ...JSON.parse(content) } as AppConfig;\n } catch {\n this.config = { ...DEFAULT_CONFIG };\n }\n\n return this.config;\n }\n\n async save(config: AppConfig): Promise<void> {\n await mkdir(dirname(this.configPath), { recursive: true });\n await writeFile(this.configPath, JSON.stringify(config, null, 2));\n this.config = config;\n }\n\n resolveDataDir(): string {\n return this.dataDir;\n }\n\n private expandPath(path: string, baseDir: string): string {\n // Expand ~ to home directory\n if (path.startsWith('~')) {\n return path.replace('~', homedir());\n }\n // Resolve relative paths against base directory (not process.cwd())\n if (!path.startsWith('/')) {\n return resolve(baseDir, path);\n }\n // Return absolute paths as-is\n return path;\n }\n}\n","export interface EmbeddingConfig {\n readonly model: string;\n readonly batchSize: number;\n readonly dimensions: number;\n}\n\nexport interface IndexingConfig {\n readonly concurrency: number;\n readonly chunkSize: number;\n readonly chunkOverlap: number;\n readonly ignorePatterns: readonly string[];\n}\n\nexport interface SearchConfig {\n readonly defaultMode: 'vector' | 'fts' | 'hybrid';\n readonly defaultLimit: number;\n readonly minScore: number;\n readonly rrf: {\n readonly k: number;\n readonly vectorWeight: number;\n readonly ftsWeight: number;\n };\n}\n\nexport interface CrawlConfig {\n readonly userAgent: string;\n readonly timeout: number;\n readonly maxConcurrency: number;\n}\n\nexport interface ServerConfig {\n readonly port: number;\n readonly host: string;\n}\n\nexport interface AppConfig {\n readonly version: number;\n readonly dataDir: string;\n readonly embedding: EmbeddingConfig;\n readonly indexing: IndexingConfig;\n readonly search: SearchConfig;\n readonly crawl: CrawlConfig;\n readonly server: ServerConfig;\n}\n\nexport const DEFAULT_CONFIG: AppConfig = {\n version: 1,\n dataDir: '.bluera/bluera-knowledge/data',\n embedding: {\n model: 'Xenova/all-MiniLM-L6-v2',\n batchSize: 32,\n dimensions: 384,\n },\n indexing: {\n concurrency: 4,\n chunkSize: 1000,\n chunkOverlap: 150,\n ignorePatterns: ['node_modules/**', '.git/**', '*.min.js', '*.map'],\n },\n search: {\n defaultMode: 'hybrid',\n defaultLimit: 10,\n minScore: 0.5,\n rrf: {\n k: 40,\n vectorWeight: 0.7,\n ftsWeight: 0.3,\n },\n },\n crawl: {\n userAgent: 'BlueraKnowledge/1.0',\n timeout: 30000,\n maxConcurrency: 3,\n },\n server: {\n port: 3847,\n host: '127.0.0.1',\n },\n};\n","import { existsSync, statSync, realpathSync } from 'node:fs';\nimport { dirname, join, normalize, sep } from 'node:path';\n\nexport interface ProjectRootOptions {\n readonly projectRoot?: string | undefined;\n}\n\n/**\n * Service for resolving the project root directory using a hierarchical detection strategy.\n *\n * Resolution hierarchy:\n * 1. Explicit projectRoot option (highest priority)\n * 2. PROJECT_ROOT environment variable (set by plugin commands)\n * 3. PWD environment variable (set by MCP server and shells)\n * 4. Git root detection (walk up to find .git directory)\n * 5. process.cwd() (fallback)\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class ProjectRootService {\n /**\n * Resolve project root directory using hierarchical detection.\n */\n static resolve(options?: ProjectRootOptions): string {\n // 1. Check explicit option first\n if (options?.projectRoot !== undefined && options.projectRoot !== '') {\n return this.normalize(options.projectRoot);\n }\n\n // 2. Check PROJECT_ROOT environment variable (plugin commands)\n const projectRootEnv = process.env['PROJECT_ROOT'];\n if (projectRootEnv !== undefined && projectRootEnv !== '') {\n return this.normalize(projectRootEnv);\n }\n\n // 3. Check PWD environment variable (MCP server, shells)\n const pwdEnv = process.env['PWD'];\n if (pwdEnv !== undefined && pwdEnv !== '') {\n return this.normalize(pwdEnv);\n }\n\n // 4. Try git root detection\n const gitRoot = this.findGitRoot(process.cwd());\n if (gitRoot !== null) {\n return gitRoot;\n }\n\n // 5. Fallback to process.cwd()\n return process.cwd();\n }\n\n /**\n * Find git repository root by walking up the directory tree looking for .git\n */\n static findGitRoot(startPath: string): string | null {\n let currentPath = normalize(startPath);\n const root = normalize(sep); // Root filesystem (/ on Unix, C:\\ on Windows)\n\n // Walk up directory tree\n while (currentPath !== root) {\n const gitPath = join(currentPath, '.git');\n\n if (existsSync(gitPath)) {\n try {\n const stats = statSync(gitPath);\n // .git can be a directory (normal repo) or file (submodule/worktree)\n if (stats.isDirectory() || stats.isFile()) {\n return currentPath;\n }\n } catch {\n // Ignore stat errors, continue searching\n }\n }\n\n // Move up one directory\n const parentPath = dirname(currentPath);\n if (parentPath === currentPath) {\n // Reached root without finding .git\n break;\n }\n currentPath = parentPath;\n }\n\n return null;\n }\n\n /**\n * Normalize path by resolving symlinks and normalizing separators\n */\n static normalize(path: string): string {\n try {\n // Resolve symlinks to real path\n const realPath = realpathSync(path);\n // Normalize separators\n return normalize(realPath);\n } catch {\n // If realpath fails (path doesn't exist), just normalize\n return normalize(path);\n }\n }\n\n /**\n * Validate that a path exists and is a directory\n */\n static validate(path: string): boolean {\n try {\n const stats = statSync(path);\n return stats.isDirectory();\n } catch {\n return false;\n }\n }\n}\n","import { readFile, writeFile, mkdir, stat } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { randomUUID } from 'node:crypto';\nimport type { Store, FileStore, RepoStore, WebStore, StoreType } from '../types/store.js';\nimport type { StoreId } from '../types/brands.js';\nimport { createStoreId } from '../types/brands.js';\nimport type { Result } from '../types/result.js';\nimport { ok, err } from '../types/result.js';\nimport { cloneRepository } from '../plugin/git-clone.js';\n\nexport interface CreateStoreInput {\n name: string;\n type: StoreType;\n path?: string | undefined;\n url?: string | undefined;\n description?: string | undefined;\n tags?: string[] | undefined;\n branch?: string | undefined;\n depth?: number | undefined;\n}\n\ninterface StoreRegistry {\n stores: Store[];\n}\n\nexport class StoreService {\n private readonly dataDir: string;\n private registry: StoreRegistry = { stores: [] };\n\n constructor(dataDir: string) {\n this.dataDir = dataDir;\n }\n\n async initialize(): Promise<void> {\n await mkdir(this.dataDir, { recursive: true });\n await this.loadRegistry();\n }\n\n async create(input: CreateStoreInput): Promise<Result<Store>> {\n const existing = await this.getByName(input.name);\n if (existing !== undefined) {\n return err(new Error(`Store with name \"${input.name}\" already exists`));\n }\n\n const id = createStoreId(randomUUID());\n const now = new Date();\n\n let store: Store;\n\n switch (input.type) {\n case 'file': {\n if (input.path === undefined) {\n return err(new Error('Path is required for file stores'));\n }\n // Normalize path to absolute path (security: prevents path confusion)\n const normalizedPath = resolve(input.path);\n // Validate directory exists\n try {\n const stats = await stat(normalizedPath);\n if (!stats.isDirectory()) {\n return err(new Error(`Path is not a directory: ${normalizedPath}`));\n }\n } catch {\n return err(new Error(`Directory does not exist: ${normalizedPath}`));\n }\n store = {\n type: 'file',\n id,\n name: input.name,\n path: normalizedPath,\n description: input.description,\n tags: input.tags,\n status: 'ready',\n createdAt: now,\n updatedAt: now,\n } satisfies FileStore;\n break;\n }\n\n case 'repo': {\n let repoPath = input.path;\n\n // If URL provided, clone it\n if (input.url !== undefined) {\n const cloneDir = join(this.dataDir, 'repos', id);\n const result = await cloneRepository({\n url: input.url,\n targetDir: cloneDir,\n ...(input.branch !== undefined ? { branch: input.branch } : {}),\n depth: input.depth ?? 1\n });\n\n if (!result.success) {\n return err(result.error);\n }\n repoPath = result.data;\n }\n\n if (repoPath === undefined) {\n return err(new Error('Path or URL required for repo stores'));\n }\n\n // Normalize path to absolute path (security: prevents path confusion)\n const normalizedRepoPath = resolve(repoPath);\n\n store = {\n type: 'repo',\n id,\n name: input.name,\n path: normalizedRepoPath,\n url: input.url,\n branch: input.branch,\n description: input.description,\n tags: input.tags,\n status: 'ready',\n createdAt: now,\n updatedAt: now,\n } satisfies RepoStore;\n break;\n }\n\n case 'web':\n if (input.url === undefined) {\n return err(new Error('URL is required for web stores'));\n }\n store = {\n type: 'web',\n id,\n name: input.name,\n url: input.url,\n depth: input.depth ?? 1,\n description: input.description,\n tags: input.tags,\n status: 'ready',\n createdAt: now,\n updatedAt: now,\n } satisfies WebStore;\n break;\n }\n\n this.registry.stores.push(store);\n await this.saveRegistry();\n\n return ok(store);\n }\n\n async list(type?: StoreType): Promise<Store[]> {\n if (type !== undefined) {\n return Promise.resolve(this.registry.stores.filter((s) => s.type === type));\n }\n return Promise.resolve([...this.registry.stores]);\n }\n\n async get(id: StoreId): Promise<Store | undefined> {\n return Promise.resolve(this.registry.stores.find((s) => s.id === id));\n }\n\n async getByName(name: string): Promise<Store | undefined> {\n return Promise.resolve(this.registry.stores.find((s) => s.name === name));\n }\n\n async getByIdOrName(idOrName: string): Promise<Store | undefined> {\n return Promise.resolve(this.registry.stores.find((s) => s.id === idOrName || s.name === idOrName));\n }\n\n async update(id: StoreId, updates: Partial<Pick<Store, 'name' | 'description' | 'tags'>>): Promise<Result<Store>> {\n const index = this.registry.stores.findIndex((s) => s.id === id);\n if (index === -1) {\n return err(new Error(`Store not found: ${id}`));\n }\n\n const store = this.registry.stores[index];\n if (store === undefined) {\n return err(new Error(`Store not found: ${id}`));\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const updated = {\n ...store,\n ...updates,\n updatedAt: new Date(),\n } as Store;\n\n this.registry.stores[index] = updated;\n await this.saveRegistry();\n\n return ok(updated);\n }\n\n async delete(id: StoreId): Promise<Result<void>> {\n const index = this.registry.stores.findIndex((s) => s.id === id);\n if (index === -1) {\n return err(new Error(`Store not found: ${id}`));\n }\n\n this.registry.stores.splice(index, 1);\n await this.saveRegistry();\n\n return ok(undefined);\n }\n\n private async loadRegistry(): Promise<void> {\n const registryPath = join(this.dataDir, 'stores.json');\n try {\n const content = await readFile(registryPath, 'utf-8');\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const data = JSON.parse(content) as { stores: Store[] };\n this.registry = {\n stores: data.stores.map((s) => ({\n ...s,\n id: createStoreId(s.id),\n createdAt: new Date(s.createdAt),\n updatedAt: new Date(s.updatedAt),\n })),\n };\n } catch {\n this.registry = { stores: [] };\n }\n }\n\n private async saveRegistry(): Promise<void> {\n const registryPath = join(this.dataDir, 'stores.json');\n await writeFile(registryPath, JSON.stringify(this.registry, null, 2));\n }\n}\n","// Branded type symbols\ndeclare const StoreIdBrand: unique symbol;\ndeclare const DocumentIdBrand: unique symbol;\n\n// Branded types\nexport type StoreId = string & { readonly [StoreIdBrand]: typeof StoreIdBrand };\nexport type DocumentId = string & { readonly [DocumentIdBrand]: typeof DocumentIdBrand };\n\n// Valid ID pattern: alphanumeric, hyphens, underscores\nconst ID_PATTERN = /^[a-zA-Z0-9_-]+$/;\n\nexport function isStoreId(value: string): value is StoreId {\n return value.length > 0 && ID_PATTERN.test(value);\n}\n\nexport function isDocumentId(value: string): value is DocumentId {\n return value.length > 0 && ID_PATTERN.test(value);\n}\n\nexport function createStoreId(value: string): StoreId {\n if (!isStoreId(value)) {\n throw new Error(`Invalid store ID: ${value}`);\n }\n return value;\n}\n\nexport function createDocumentId(value: string): DocumentId {\n if (!isDocumentId(value)) {\n throw new Error(`Invalid document ID: ${value}`);\n }\n return value;\n}\n","import { spawn } from 'node:child_process';\nimport { mkdir } from 'node:fs/promises';\nimport type { Result } from '../types/result.js';\nimport { ok, err } from '../types/result.js';\n\nexport interface CloneOptions {\n url: string;\n targetDir: string;\n branch?: string;\n depth?: number;\n}\n\nexport async function cloneRepository(\n options: CloneOptions\n): Promise<Result<string>> {\n const { url, targetDir, branch, depth = 1 } = options;\n\n await mkdir(targetDir, { recursive: true });\n\n const args = ['clone', '--depth', String(depth)];\n if (branch !== undefined) {\n args.push('--branch', branch);\n }\n args.push(url, targetDir);\n\n return new Promise((resolve) => {\n const git = spawn('git', args, { stdio: ['ignore', 'pipe', 'pipe'] });\n\n let stderr = '';\n git.stderr.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n git.on('close', (code: number | null) => {\n if (code === 0) {\n resolve(ok(targetDir));\n } else {\n resolve(err(new Error(`Git clone failed: ${stderr}`)));\n }\n });\n });\n}\n\nexport function isGitUrl(source: string): boolean {\n return source.startsWith('http://') ||\n source.startsWith('https://') ||\n source.startsWith('git@');\n}\n\nexport function extractRepoName(url: string): string {\n const match = /\\/([^/]+?)(\\.git)?$/.exec(url);\n const name = match?.[1];\n if (name === undefined) {\n return 'repository';\n }\n return name;\n}\n","export interface CodeUnit {\n type: 'function' | 'class' | 'interface' | 'type' | 'const' | 'documentation' | 'example';\n name: string;\n signature: string;\n fullContent: string;\n startLine: number;\n endLine: number;\n language: string;\n}\n\nexport class CodeUnitService {\n extractCodeUnit(code: string, symbolName: string, language: string): CodeUnit | undefined {\n const lines = code.split('\\n');\n\n // Find the line containing the symbol\n let startLine = -1;\n let type: CodeUnit['type'] = 'function';\n\n // NOTE: Now supports function declarations, class declarations, and arrow functions (const/let/var).\n // Does not handle interfaces or type definitions yet.\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? '';\n\n if (line.includes(`function ${symbolName}`)) {\n startLine = i + 1; // 1-indexed\n type = 'function';\n break;\n }\n\n if (line.includes(`class ${symbolName}`)) {\n startLine = i + 1;\n type = 'class';\n break;\n }\n\n // Check for arrow functions: const/let/var name = ...\n if (line.match(new RegExp(`(?:const|let|var)\\\\s+${symbolName}\\\\s*=`))) {\n startLine = i + 1;\n type = 'const';\n break;\n }\n }\n\n if (startLine === -1) return undefined;\n\n // Find end line (naive: next empty line or next top-level declaration)\n let endLine = startLine;\n let braceCount = 0;\n let foundFirstBrace = false;\n\n // NOTE: This brace counting does not handle braces inside strings or comments.\n // It may incorrectly determine boundaries if code contains braces in string literals.\n for (let i = startLine - 1; i < lines.length; i++) {\n const line = lines[i] ?? '';\n\n for (const char of line) {\n if (char === '{') {\n braceCount++;\n foundFirstBrace = true;\n }\n if (char === '}') braceCount--;\n }\n\n if (foundFirstBrace && braceCount === 0) {\n endLine = i + 1;\n break;\n }\n }\n\n const fullContent = lines.slice(startLine - 1, endLine).join('\\n');\n\n // Extract signature (first line, cleaned)\n const firstLine = lines[startLine - 1] ?? '';\n const signature = this.extractSignature(firstLine, symbolName, type);\n\n return {\n type,\n name: symbolName,\n signature,\n fullContent,\n startLine,\n endLine,\n language\n };\n }\n\n private extractSignature(line: string, name: string, type: string): string {\n // Remove 'export', 'async', trim whitespace\n const sig = line.replace(/^\\s*export\\s+/, '').replace(/^\\s*async\\s+/, '').trim();\n\n if (type === 'function') {\n // Extract just \"functionName(params): returnType\"\n // TODO: This regex is limited and may not handle complex return types, generics, or multiline signatures\n const match = sig.match(/function\\s+(\\w+\\([^)]*\\):\\s*\\w+)/);\n if (match?.[1] !== undefined && match[1].length > 0) return match[1];\n }\n\n if (type === 'class') {\n return `class ${name}`;\n }\n\n if (type === 'const') {\n // For arrow functions, extract the variable declaration part\n // Example: const myFunc = (param: string): void => ...\n // Returns: const myFunc = (param: string): void\n const arrowMatch = sig.match(new RegExp(`((?:const|let|var)\\\\s+${name}\\\\s*=\\\\s*(?:async\\\\s+)?\\\\([^)]*\\\\)(?::\\\\s*[^=]+)?)`));\n if (arrowMatch?.[1] != null && arrowMatch[1] !== '') return arrowMatch[1].trim();\n\n // Fallback for simple arrow functions without params\n return `const ${name}`;\n }\n\n return sig;\n }\n}\n","import type { LanceStore } from '../db/lance.js';\nimport type { EmbeddingEngine } from '../db/embeddings.js';\nimport type { SearchQuery, SearchResponse, SearchResult, DetailLevel } from '../types/search.js';\nimport type { StoreId } from '../types/brands.js';\nimport { CodeUnitService } from './code-unit.service.js';\nimport type { CodeUnit } from '../types/search.js';\nimport type { CodeGraphService } from './code-graph.service.js';\nimport type { CodeGraph } from '../analysis/code-graph.js';\n\n/**\n * Query intent classification for context-aware ranking.\n * Phase 1: Different intents prioritize different content types.\n */\nexport type QueryIntent = 'how-to' | 'implementation' | 'conceptual' | 'comparison' | 'debugging';\n\n/**\n * Intent-based file type multipliers - CONSERVATIVE version.\n * Applied on top of base file-type boosts.\n * Lessons learned: Too-aggressive penalties hurt when corpus lacks ideal content.\n * These values provide gentle guidance rather than dramatic reranking.\n */\nconst INTENT_FILE_BOOSTS: Record<QueryIntent, Record<string, number>> = {\n 'how-to': {\n 'documentation-primary': 1.3, // Strong boost for docs\n 'documentation': 1.2,\n 'example': 1.5, // Examples are ideal for \"how to\"\n 'source': 0.85, // Moderate penalty - source might still have good content\n 'source-internal': 0.7, // Stronger penalty - internal code less useful\n 'test': 0.8,\n 'config': 0.7,\n 'other': 0.9,\n },\n 'implementation': {\n 'documentation-primary': 0.95,\n 'documentation': 1.0,\n 'example': 1.0,\n 'source': 1.1, // Slight boost for source code\n 'source-internal': 1.05, // Internal code can be relevant\n 'test': 1.0,\n 'config': 0.95,\n 'other': 1.0,\n },\n 'conceptual': {\n 'documentation-primary': 1.1,\n 'documentation': 1.05,\n 'example': 1.0,\n 'source': 0.95,\n 'source-internal': 0.9,\n 'test': 0.9,\n 'config': 0.85,\n 'other': 0.95,\n },\n 'comparison': {\n 'documentation-primary': 1.15,\n 'documentation': 1.1,\n 'example': 1.05,\n 'source': 0.9,\n 'source-internal': 0.85,\n 'test': 0.9,\n 'config': 0.85,\n 'other': 0.95,\n },\n 'debugging': {\n 'documentation-primary': 1.0,\n 'documentation': 1.0,\n 'example': 1.05,\n 'source': 1.0, // Source code helps with debugging\n 'source-internal': 0.95,\n 'test': 1.05, // Tests can show expected behavior\n 'config': 0.9,\n 'other': 1.0,\n },\n};\n\n// Known frameworks/technologies for context-aware boosting\nconst FRAMEWORK_PATTERNS: Array<{ pattern: RegExp; terms: string[] }> = [\n { pattern: /\\bexpress\\b/i, terms: ['express', 'expressjs', 'express.js'] },\n { pattern: /\\bhono\\b/i, terms: ['hono'] },\n { pattern: /\\bzod\\b/i, terms: ['zod'] },\n { pattern: /\\breact\\b/i, terms: ['react', 'reactjs', 'react.js'] },\n { pattern: /\\bvue\\b/i, terms: ['vue', 'vuejs', 'vue.js', 'vue3'] },\n { pattern: /\\bnode\\b/i, terms: ['node', 'nodejs', 'node.js'] },\n { pattern: /\\btypescript\\b/i, terms: ['typescript', 'ts'] },\n { pattern: /\\bjwt\\b/i, terms: ['jwt', 'jsonwebtoken', 'json-web-token'] },\n];\n\n/**\n * Classify the intent of a search query.\n * This helps adjust ranking based on what kind of answer the user wants.\n */\nfunction classifyQueryIntent(query: string): QueryIntent {\n const q = query.toLowerCase();\n\n // How-to patterns: user wants to learn how to use/do something\n const howToPatterns = [\n /how (do|can|should|would) (i|you|we)/i,\n /how to\\b/i,\n /what('s| is) the (best |right |correct )?(way|approach) to/i,\n /i (need|want|have) to/i,\n /show me how/i,\n /\\bwhat's the syntax\\b/i,\n /\\bhow do i (use|create|make|set up|configure|implement|add|get)\\b/i,\n /\\bi'm (trying|building|creating|making)\\b/i,\n ];\n\n // Implementation patterns: user wants to understand internals\n const implementationPatterns = [\n /how (does|is) .* (implemented|work internally)/i,\n /\\binternal(ly)?\\b/i,\n /\\bsource code\\b/i,\n /\\bunder the hood\\b/i,\n /\\bimplementation (of|details?)\\b/i,\n ];\n\n // Comparison patterns: user is deciding between options\n const comparisonPatterns = [\n /\\b(vs\\.?|versus)\\b/i,\n /\\bdifference(s)? between\\b/i,\n /\\bcompare\\b/i,\n /\\bshould (i|we) use .* or\\b/i,\n /\\bwhat's the difference\\b/i,\n /\\bwhich (one|is better)\\b/i,\n /\\bwhen (should|to) use\\b/i,\n ];\n\n // Debugging patterns: user is troubleshooting a problem\n const debuggingPatterns = [\n /\\b(error|bug|issue|problem|crash|fail|broken|wrong)\\b/i,\n /\\bdoesn't (work|compile|run)\\b/i,\n /\\bisn't (working|updating|rendering)\\b/i,\n /\\bwhy (is|does|doesn't|isn't)\\b/i,\n /\\bwhat('s| is) (wrong|happening|going on)\\b/i,\n /\\bwhat am i doing wrong\\b/i,\n /\\bnot (working|updating|showing)\\b/i,\n /\\bhow do i (fix|debug|solve|resolve)\\b/i,\n ];\n\n // Conceptual patterns: user wants to understand a concept\n const conceptualPatterns = [\n /\\bwhat (is|are)\\b/i,\n /\\bexplain\\b/i,\n /\\bwhat does .* (mean|do)\\b/i,\n /\\bhow does .* work\\b/i,\n /\\bwhat('s| is) the (purpose|point|idea)\\b/i,\n ];\n\n // Check patterns in order of specificity\n if (implementationPatterns.some(p => p.test(q))) {\n return 'implementation';\n }\n\n if (debuggingPatterns.some(p => p.test(q))) {\n return 'debugging';\n }\n\n if (comparisonPatterns.some(p => p.test(q))) {\n return 'comparison';\n }\n\n if (howToPatterns.some(p => p.test(q))) {\n return 'how-to';\n }\n\n if (conceptualPatterns.some(p => p.test(q))) {\n return 'conceptual';\n }\n\n // Default to how-to as most queries are seeking practical usage\n return 'how-to';\n}\n\ninterface RRFConfig {\n k: number;\n vectorWeight: number;\n ftsWeight: number;\n}\n\nexport class SearchService {\n private readonly lanceStore: LanceStore;\n private readonly embeddingEngine: EmbeddingEngine;\n private readonly rrfConfig: RRFConfig;\n private readonly codeUnitService: CodeUnitService;\n private readonly codeGraphService: CodeGraphService | undefined;\n private readonly graphCache: Map<string, CodeGraph | null>;\n\n constructor(\n lanceStore: LanceStore,\n embeddingEngine: EmbeddingEngine,\n // Lower k value (20 vs 60) produces more differentiated scores for top results\n rrfConfig: RRFConfig = { k: 20, vectorWeight: 0.6, ftsWeight: 0.4 },\n codeGraphService?: CodeGraphService\n ) {\n this.lanceStore = lanceStore;\n this.embeddingEngine = embeddingEngine;\n this.rrfConfig = rrfConfig;\n this.codeUnitService = new CodeUnitService();\n this.codeGraphService = codeGraphService;\n this.graphCache = new Map();\n }\n\n /**\n * Load code graph for a store, with caching.\n * Returns null if no graph is available.\n */\n private async loadGraphForStore(storeId: StoreId): Promise<CodeGraph | null> {\n if (!this.codeGraphService) return null;\n\n const cached = this.graphCache.get(storeId);\n if (cached !== undefined) return cached;\n\n const graph = await this.codeGraphService.loadGraph(storeId);\n const result = graph ?? null;\n this.graphCache.set(storeId, result);\n return result;\n }\n\n async search(query: SearchQuery): Promise<SearchResponse> {\n const startTime = Date.now();\n const mode = query.mode ?? 'hybrid';\n const limit = query.limit ?? 10;\n const stores = query.stores ?? [];\n const detail = query.detail ?? 'minimal';\n\n let allResults: SearchResult[] = [];\n\n // Fetch more results than needed to allow for deduplication\n const fetchLimit = limit * 3;\n\n if (mode === 'vector') {\n allResults = await this.vectorSearch(query.query, stores, fetchLimit, query.threshold);\n } else if (mode === 'fts') {\n allResults = await this.ftsSearch(query.query, stores, fetchLimit);\n } else {\n // Hybrid: combine vector and FTS with RRF\n allResults = await this.hybridSearch(query.query, stores, fetchLimit, query.threshold);\n }\n\n // Deduplicate by source file - keep best chunk per source (considers query relevance)\n const dedupedResults = this.deduplicateBySource(allResults, query.query);\n const resultsToEnhance = dedupedResults.slice(0, limit);\n\n // Load code graphs for stores in results (for contextual/full detail levels)\n const graphs = new Map<string, CodeGraph | null>();\n if (detail === 'contextual' || detail === 'full') {\n const storeIds = new Set(resultsToEnhance.map(r => r.metadata.storeId));\n for (const storeId of storeIds) {\n graphs.set(storeId, await this.loadGraphForStore(storeId));\n }\n }\n\n // Enhance results with progressive context\n const enhancedResults = resultsToEnhance.map(r => {\n const graph = graphs.get(r.metadata.storeId) ?? null;\n return this.addProgressiveContext(r, query.query, detail, graph);\n });\n\n return {\n query: query.query,\n mode,\n stores,\n results: enhancedResults,\n totalResults: enhancedResults.length,\n timeMs: Date.now() - startTime,\n };\n }\n\n /**\n * Deduplicate results by source file path.\n * Keeps the best chunk for each unique source, considering both score and query relevance.\n */\n private deduplicateBySource(results: SearchResult[], query: string): SearchResult[] {\n const bySource = new Map<string, SearchResult>();\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(t => t.length > 2);\n\n for (const result of results) {\n // Use file path as the source key, fallback to document ID\n const sourceKey = result.metadata.path ?? result.metadata.url ?? result.id;\n\n const existing = bySource.get(sourceKey);\n if (!existing) {\n bySource.set(sourceKey, result);\n } else {\n // Compare: prefer chunk with more query terms in content\n const existingTermCount = this.countQueryTerms(existing.content, queryTerms);\n const newTermCount = this.countQueryTerms(result.content, queryTerms);\n\n // Prefer chunk with more query terms, or higher score if same\n if (newTermCount > existingTermCount ||\n (newTermCount === existingTermCount && result.score > existing.score)) {\n bySource.set(sourceKey, result);\n }\n }\n }\n\n // Return results sorted by score\n return Array.from(bySource.values()).sort((a, b) => b.score - a.score);\n }\n\n /**\n * Count how many query terms appear in the content.\n */\n private countQueryTerms(content: string, queryTerms: string[]): number {\n const lowerContent = content.toLowerCase();\n return queryTerms.filter(term => lowerContent.includes(term)).length;\n }\n\n private async vectorSearch(\n query: string,\n stores: readonly StoreId[],\n limit: number,\n threshold?: number\n ): Promise<SearchResult[]> {\n const queryVector = await this.embeddingEngine.embed(query);\n const results: SearchResult[] = [];\n\n for (const storeId of stores) {\n const hits = await this.lanceStore.search(storeId, queryVector, limit, threshold);\n results.push(...hits.map(r => ({\n id: r.id,\n score: r.score,\n content: r.content,\n metadata: r.metadata,\n })));\n }\n\n return results.sort((a, b) => b.score - a.score).slice(0, limit);\n }\n\n private async ftsSearch(\n query: string,\n stores: readonly StoreId[],\n limit: number\n ): Promise<SearchResult[]> {\n const results: SearchResult[] = [];\n\n for (const storeId of stores) {\n const hits = await this.lanceStore.fullTextSearch(storeId, query, limit);\n results.push(...hits.map(r => ({\n id: r.id,\n score: r.score,\n content: r.content,\n metadata: r.metadata,\n })));\n }\n\n return results.sort((a, b) => b.score - a.score).slice(0, limit);\n }\n\n private async hybridSearch(\n query: string,\n stores: readonly StoreId[],\n limit: number,\n threshold?: number\n ): Promise<SearchResult[]> {\n // Phase 1: Classify query intent for context-aware ranking\n const intent = classifyQueryIntent(query);\n\n // Get both result sets\n const [vectorResults, ftsResults] = await Promise.all([\n this.vectorSearch(query, stores, limit * 2, threshold),\n this.ftsSearch(query, stores, limit * 2),\n ]);\n\n // Build rank maps\n const vectorRanks = new Map<string, number>();\n const ftsRanks = new Map<string, number>();\n const allDocs = new Map<string, SearchResult>();\n\n vectorResults.forEach((r, i) => {\n vectorRanks.set(r.id, i + 1);\n allDocs.set(r.id, r);\n });\n\n ftsResults.forEach((r, i) => {\n ftsRanks.set(r.id, i + 1);\n if (!allDocs.has(r.id)) {\n allDocs.set(r.id, r);\n }\n });\n\n // Calculate RRF scores with file-type boosting and preserve ranking metadata\n const rrfScores: Array<{\n id: string;\n score: number;\n result: SearchResult;\n metadata: {\n vectorRank?: number;\n ftsRank?: number;\n vectorRRF: number;\n ftsRRF: number;\n fileTypeBoost: number;\n frameworkBoost: number;\n };\n }> = [];\n const { k, vectorWeight, ftsWeight } = this.rrfConfig;\n\n for (const [id, result] of allDocs) {\n const vectorRank = vectorRanks.get(id) ?? Infinity;\n const ftsRank = ftsRanks.get(id) ?? Infinity;\n\n const vectorRRF = vectorRank !== Infinity ? vectorWeight / (k + vectorRank) : 0;\n const ftsRRF = ftsRank !== Infinity ? ftsWeight / (k + ftsRank) : 0;\n\n // Apply file-type boost (base + intent-adjusted)\n const fileTypeBoost = this.getFileTypeBoost(\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n result.metadata['fileType'] as string | undefined,\n intent\n );\n\n // Apply framework context boost\n const frameworkBoost = this.getFrameworkContextBoost(query, result);\n\n const metadata: {\n vectorRank?: number;\n ftsRank?: number;\n vectorRRF: number;\n ftsRRF: number;\n fileTypeBoost: number;\n frameworkBoost: number;\n } = {\n vectorRRF,\n ftsRRF,\n fileTypeBoost,\n frameworkBoost,\n };\n\n if (vectorRank !== Infinity) {\n metadata.vectorRank = vectorRank;\n }\n if (ftsRank !== Infinity) {\n metadata.ftsRank = ftsRank;\n }\n\n rrfScores.push({\n id,\n score: (vectorRRF + ftsRRF) * fileTypeBoost * frameworkBoost,\n result,\n metadata,\n });\n }\n\n // Sort by RRF score\n const sorted = rrfScores.sort((a, b) => b.score - a.score).slice(0, limit);\n\n // Normalize scores to 0-1 range for better interpretability\n if (sorted.length > 0) {\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n if (first === undefined || last === undefined) {\n return sorted.map(r => ({\n ...r.result,\n score: r.score,\n rankingMetadata: r.metadata,\n }));\n }\n const maxScore = first.score;\n const minScore = last.score;\n const range = maxScore - minScore;\n\n if (range > 0) {\n return sorted.map(r => ({\n ...r.result,\n score: (r.score - minScore) / range,\n rankingMetadata: r.metadata,\n }));\n }\n }\n\n return sorted.map(r => ({\n ...r.result,\n score: r.score,\n rankingMetadata: r.metadata,\n }));\n }\n\n async searchAllStores(\n query: SearchQuery,\n storeIds: StoreId[]\n ): Promise<SearchResponse> {\n return this.search({\n ...query,\n stores: storeIds,\n });\n }\n\n /**\n * Get a score multiplier based on file type and query intent.\n * Documentation files get a strong boost to surface them higher.\n * Phase 4: Strengthened boosts for better documentation ranking.\n * Phase 1: Intent-based adjustments for context-aware ranking.\n */\n private getFileTypeBoost(fileType: string | undefined, intent: QueryIntent): number {\n // Base file-type boosts\n let baseBoost: number;\n switch (fileType) {\n case 'documentation-primary':\n baseBoost = 1.8; // README, guides get very strong boost\n break;\n case 'documentation':\n baseBoost = 1.5; // docs/, tutorials/ get strong boost\n break;\n case 'example':\n baseBoost = 1.4; // examples/, demos/ are highly valuable\n break;\n case 'source':\n baseBoost = 1.0; // Source code baseline\n break;\n case 'source-internal':\n baseBoost = 0.75; // Internal implementation files (not too harsh)\n break;\n case 'test':\n baseBoost = 0.7; // Tests significantly lower\n break;\n case 'config':\n baseBoost = 0.5; // Config files rarely answer questions\n break;\n default:\n baseBoost = 1.0;\n }\n\n // Apply intent-based multiplier\n const intentBoosts = INTENT_FILE_BOOSTS[intent];\n const intentMultiplier = intentBoosts[fileType ?? 'other'] ?? 1.0;\n\n return baseBoost * intentMultiplier;\n }\n\n /**\n * Get a score multiplier based on framework context.\n * If query mentions a framework, boost results from that framework's files.\n */\n private getFrameworkContextBoost(query: string, result: SearchResult): number {\n const path = result.metadata.path ?? result.metadata.url ?? '';\n const content = result.content.toLowerCase();\n const pathLower = path.toLowerCase();\n\n // Check if query mentions any known frameworks\n for (const { pattern, terms } of FRAMEWORK_PATTERNS) {\n if (pattern.test(query)) {\n // Query mentions this framework - check if result is from that framework\n const resultMatchesFramework = terms.some(term =>\n pathLower.includes(term) || content.includes(term)\n );\n\n if (resultMatchesFramework) {\n return 1.5; // Strong boost for matching framework\n } else {\n return 0.8; // Moderate penalty for non-matching when framework is specified\n }\n }\n }\n\n return 1.0; // No framework context in query\n }\n\n private addProgressiveContext(\n result: SearchResult,\n query: string,\n detail: DetailLevel,\n graph: CodeGraph | null\n ): SearchResult {\n const enhanced = { ...result };\n\n // Layer 1: Always add summary\n const path = result.metadata.path ?? result.metadata.url ?? 'unknown';\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const fileType = result.metadata['fileType'] as string | undefined;\n\n // Try to extract code unit\n const codeUnit = this.extractCodeUnitFromResult(result);\n const symbolName = codeUnit?.name ?? this.extractSymbolName(result.content);\n\n enhanced.summary = {\n type: this.inferType(fileType, codeUnit),\n name: symbolName,\n signature: codeUnit?.signature ?? '',\n purpose: this.generatePurpose(result.content, query),\n location: `${path}${codeUnit ? ':' + String(codeUnit.startLine) : ''}`,\n relevanceReason: this.generateRelevanceReason(result, query)\n };\n\n // Layer 2: Add context if requested\n if (detail === 'contextual' || detail === 'full') {\n // Get usage stats from code graph if available\n const usage = this.getUsageFromGraph(graph, path, symbolName);\n\n enhanced.context = {\n interfaces: this.extractInterfaces(result.content),\n keyImports: this.extractImports(result.content),\n relatedConcepts: this.extractConcepts(result.content, query),\n usage\n };\n }\n\n // Layer 3: Add full context if requested\n if (detail === 'full') {\n // Get related code from graph if available\n const relatedCode = this.getRelatedCodeFromGraph(graph, path, symbolName);\n\n enhanced.full = {\n completeCode: codeUnit?.fullContent ?? result.content,\n relatedCode,\n documentation: this.extractDocumentation(result.content),\n tests: undefined\n };\n }\n\n return enhanced;\n }\n\n private extractCodeUnitFromResult(result: SearchResult): CodeUnit | undefined {\n const path = result.metadata.path;\n if (path === undefined || path === '') return undefined;\n\n const ext = path.split('.').pop() ?? '';\n const language = ext === 'ts' || ext === 'tsx' ? 'typescript' :\n ext === 'js' || ext === 'jsx' ? 'javascript' : ext;\n\n // Try to find a symbol name in the content\n const symbolName = this.extractSymbolName(result.content);\n if (symbolName === '') return undefined;\n\n return this.codeUnitService.extractCodeUnit(result.content, symbolName, language);\n }\n\n private extractSymbolName(content: string): string {\n // Extract function or class name\n const funcMatch = content.match(/(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)/);\n if (funcMatch !== null && funcMatch[1] !== undefined && funcMatch[1] !== '') return funcMatch[1];\n\n const classMatch = content.match(/(?:export\\s+)?class\\s+(\\w+)/);\n if (classMatch !== null && classMatch[1] !== undefined && classMatch[1] !== '') return classMatch[1];\n\n const constMatch = content.match(/(?:export\\s+)?const\\s+(\\w+)/);\n if (constMatch !== null && constMatch[1] !== undefined && constMatch[1] !== '') return constMatch[1];\n\n // Fallback: return \"(anonymous)\" for unnamed symbols\n return '(anonymous)';\n }\n\n private inferType(fileType: string | undefined, codeUnit: CodeUnit | undefined): import('../types/search.js').ResultSummary['type'] {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n if (codeUnit) return codeUnit.type as import('../types/search.js').ResultSummary['type'];\n if (fileType === 'documentation' || fileType === 'documentation-primary') return 'documentation';\n return 'function';\n }\n\n private generatePurpose(content: string, query: string): string {\n // Extract first line of JSDoc comment if present\n const docMatch = content.match(/\\/\\*\\*\\s*\\n\\s*\\*\\s*([^\\n]+)/);\n if (docMatch !== null && docMatch[1] !== undefined && docMatch[1] !== '') return docMatch[1].trim();\n\n const lines = content.split('\\n');\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(t => t.length > 2);\n\n // Helper to check if line is skippable (imports, declarations)\n const shouldSkip = (cleaned: string): boolean => {\n return cleaned.startsWith('import ') ||\n cleaned.startsWith('export ') ||\n cleaned.startsWith('interface ') ||\n cleaned.startsWith('type ');\n };\n\n // Helper to score a line based on query term matches\n const scoreLine = (cleaned: string): number => {\n const lowerLine = cleaned.toLowerCase();\n return queryTerms.filter(term => lowerLine.includes(term)).length;\n };\n\n // Helper to check if line is meaningful (length, not a comment)\n const isMeaningful = (cleaned: string): boolean => {\n if (cleaned.length === 0) return false;\n if (cleaned.startsWith('//') || cleaned.startsWith('/*')) return false;\n // Accept Markdown headings\n if (cleaned.startsWith('#') && cleaned.length > 3) return true;\n // Accept lines 15+ chars\n return cleaned.length >= 15;\n };\n\n // First pass: find lines with query terms, preferring complete sentences\n let bestLine: string | null = null;\n let bestScore = 0;\n\n for (const line of lines) {\n const cleaned = line.trim();\n if (shouldSkip(cleaned) || !isMeaningful(cleaned)) continue;\n\n let score = scoreLine(cleaned);\n \n // Boost score for complete sentences (end with period, !, ?)\n if (/[.!?]$/.test(cleaned)) {\n score += 0.5;\n }\n \n // Boost score for code examples (contains function calls or assignments)\n // Favor complete patterns: function calls WITH arguments, assignments with values\n if (/\\w+\\([^)]*\\)|=\\s*\\w+\\(|=>/.test(cleaned)) {\n score += 0.6; // Enhanced boost to preserve code examples in snippets\n }\n \n if (score > bestScore) {\n bestScore = score;\n bestLine = cleaned;\n }\n }\n\n // If we found a line with query terms, use it\n if (bestLine !== null && bestLine !== '' && bestScore > 0) {\n if (bestLine.length > 150) {\n const firstSentence = bestLine.match(/^[^.!?]+[.!?]/);\n if (firstSentence && firstSentence[0].length >= 20 && firstSentence[0].length <= 150) {\n return firstSentence[0].trim();\n }\n return bestLine.substring(0, 147) + '...';\n }\n return bestLine;\n }\n\n // Fallback: first meaningful line (original logic)\n for (const line of lines) {\n const cleaned = line.trim();\n if (shouldSkip(cleaned) || !isMeaningful(cleaned)) continue;\n\n if (cleaned.length > 150) {\n const firstSentence = cleaned.match(/^[^.!?]+[.!?]/);\n if (firstSentence && firstSentence[0].length >= 20 && firstSentence[0].length <= 150) {\n return firstSentence[0].trim();\n }\n return cleaned.substring(0, 147) + '...';\n }\n\n return cleaned;\n }\n\n return 'Code related to query';\n }\n\n private generateRelevanceReason(result: SearchResult, query: string): string {\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(t => t.length > 2);\n const contentLower = result.content.toLowerCase();\n\n const matchedTerms = queryTerms.filter(term => contentLower.includes(term));\n\n if (matchedTerms.length > 0) {\n return `Matches: ${matchedTerms.join(', ')}`;\n }\n\n return 'Semantically similar to query';\n }\n\n private extractInterfaces(content: string): string[] {\n const interfaces: string[] = [];\n const matches = content.matchAll(/interface\\s+(\\w+)/g);\n for (const match of matches) {\n if (match[1] !== undefined && match[1] !== '') interfaces.push(match[1]);\n }\n return interfaces;\n }\n\n private extractImports(content: string): string[] {\n const imports: string[] = [];\n const matches = content.matchAll(/import\\s+.*?from\\s+['\"]([^'\"]+)['\"]/g);\n for (const match of matches) {\n if (match[1] !== undefined && match[1] !== '') imports.push(match[1]);\n }\n return imports.slice(0, 5); // Top 5\n }\n\n private extractConcepts(content: string, _query: string): string[] {\n // TODO: Use _query parameter to prioritize query-related concepts in future enhancement\n\n // Common stopwords to filter out\n const stopwords = new Set([\n 'this', 'that', 'these', 'those', 'from', 'with', 'have', 'will',\n 'would', 'should', 'could', 'about', 'been', 'were', 'being',\n 'function', 'return', 'const', 'import', 'export', 'default',\n 'type', 'interface', 'class', 'extends', 'implements', 'async',\n 'await', 'then', 'catch', 'throw', 'error', 'undefined', 'null',\n 'true', 'false', 'void', 'number', 'string', 'boolean', 'object',\n 'array', 'promise', 'callback', 'resolve', 'reject', 'value',\n 'param', 'params', 'args', 'props', 'options', 'config', 'data'\n ]);\n\n // Simple keyword extraction\n const words = content.toLowerCase().match(/\\b[a-z]{4,}\\b/g) ?? [];\n const frequency = new Map<string, number>();\n\n for (const word of words) {\n // Skip stopwords\n if (stopwords.has(word)) continue;\n\n frequency.set(word, (frequency.get(word) ?? 0) + 1);\n }\n\n return Array.from(frequency.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, 5)\n .map(([word]) => word);\n }\n\n private extractDocumentation(content: string): string {\n const docMatch = content.match(/\\/\\*\\*([\\s\\S]*?)\\*\\//);\n if (docMatch !== null && docMatch[1] !== undefined && docMatch[1] !== '') {\n return docMatch[1]\n .split('\\n')\n .map(line => line.replace(/^\\s*\\*\\s?/, '').trim())\n .filter(line => line.length > 0)\n .join('\\n');\n }\n return '';\n }\n\n /**\n * Get usage stats from code graph.\n * Returns default values if no graph is available.\n */\n private getUsageFromGraph(\n graph: CodeGraph | null,\n filePath: string,\n symbolName: string\n ): { calledBy: number; calls: number } {\n if (!graph || symbolName === '' || symbolName === '(anonymous)') {\n return { calledBy: 0, calls: 0 };\n }\n\n const nodeId = `${filePath}:${symbolName}`;\n return {\n calledBy: graph.getCalledByCount(nodeId),\n calls: graph.getCallsCount(nodeId)\n };\n }\n\n /**\n * Get related code from graph.\n * Returns callers and callees for the symbol.\n */\n private getRelatedCodeFromGraph(\n graph: CodeGraph | null,\n filePath: string,\n symbolName: string\n ): Array<{ file: string; summary: string; relationship: string }> {\n if (!graph || symbolName === '' || symbolName === '(anonymous)') {\n return [];\n }\n\n const nodeId = `${filePath}:${symbolName}`;\n const related: Array<{ file: string; summary: string; relationship: string }> = [];\n\n // Get callers (incoming edges)\n const incoming = graph.getIncomingEdges(nodeId);\n for (const edge of incoming) {\n if (edge.type === 'calls') {\n // Parse file:symbol from edge.from\n const [file, symbol] = this.parseNodeId(edge.from);\n related.push({\n file,\n summary: symbol ? `${symbol}()` : 'unknown',\n relationship: 'calls this'\n });\n }\n }\n\n // Get callees (outgoing edges)\n const outgoing = graph.getEdges(nodeId);\n for (const edge of outgoing) {\n if (edge.type === 'calls') {\n // Parse file:symbol from edge.to\n const [file, symbol] = this.parseNodeId(edge.to);\n related.push({\n file,\n summary: symbol ? `${symbol}()` : 'unknown',\n relationship: 'called by this'\n });\n }\n }\n\n // Limit to top 10 related items\n return related.slice(0, 10);\n }\n\n /**\n * Parse a node ID into file path and symbol name.\n */\n private parseNodeId(nodeId: string): [string, string] {\n const lastColon = nodeId.lastIndexOf(':');\n if (lastColon === -1) {\n return [nodeId, ''];\n }\n return [nodeId.substring(0, lastColon), nodeId.substring(lastColon + 1)];\n }\n}\n","import { readFile, readdir } from 'node:fs/promises';\nimport { join, extname, basename } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport type { LanceStore } from '../db/lance.js';\nimport type { EmbeddingEngine } from '../db/embeddings.js';\nimport type { Store, FileStore, RepoStore } from '../types/store.js';\nimport type { Document } from '../types/document.js';\nimport { createDocumentId } from '../types/brands.js';\nimport type { Result } from '../types/result.js';\nimport { ok, err } from '../types/result.js';\nimport { ChunkingService } from './chunking.service.js';\nimport type { ProgressCallback } from '../types/progress.js';\nimport type { CodeGraphService } from './code-graph.service.js';\n\ninterface IndexResult {\n documentsIndexed: number;\n chunksCreated: number;\n timeMs: number;\n}\n\ninterface IndexOptions {\n chunkSize?: number;\n chunkOverlap?: number;\n codeGraphService?: CodeGraphService;\n}\n\nconst TEXT_EXTENSIONS = new Set([\n '.txt', '.md', '.js', '.ts', '.jsx', '.tsx', '.json', '.yaml', '.yml',\n '.html', '.css', '.scss', '.less', '.py', '.rb', '.go', '.rs', '.java',\n '.c', '.cpp', '.h', '.hpp', '.sh', '.bash', '.zsh', '.sql', '.xml',\n]);\n\nexport class IndexService {\n private readonly lanceStore: LanceStore;\n private readonly embeddingEngine: EmbeddingEngine;\n private readonly chunker: ChunkingService;\n private readonly codeGraphService: CodeGraphService | undefined;\n\n constructor(\n lanceStore: LanceStore,\n embeddingEngine: EmbeddingEngine,\n options: IndexOptions = {}\n ) {\n this.lanceStore = lanceStore;\n this.embeddingEngine = embeddingEngine;\n this.chunker = new ChunkingService({\n chunkSize: options.chunkSize ?? 768,\n chunkOverlap: options.chunkOverlap ?? 100,\n });\n this.codeGraphService = options.codeGraphService;\n }\n\n async indexStore(store: Store, onProgress?: ProgressCallback): Promise<Result<IndexResult>> {\n try {\n if (store.type === 'file' || store.type === 'repo') {\n return await this.indexFileStore(store, onProgress);\n }\n\n return err(new Error(`Indexing not supported for store type: ${store.type}`));\n } catch (error) {\n return err(error instanceof Error ? error : new Error(String(error)));\n }\n }\n\n private async indexFileStore(store: FileStore | RepoStore, onProgress?: ProgressCallback): Promise<Result<IndexResult>> {\n const startTime = Date.now();\n const files = await this.scanDirectory(store.path);\n const documents: Document[] = [];\n let filesProcessed = 0;\n\n // Collect source files for code graph building\n const sourceFiles: Array<{ path: string; content: string }> = [];\n\n // Emit start event\n onProgress?.({\n type: 'start',\n current: 0,\n total: files.length,\n message: 'Starting index'\n });\n\n for (const filePath of files) {\n const content = await readFile(filePath, 'utf-8');\n const fileHash = createHash('md5').update(content).digest('hex');\n // Pass file path for semantic Markdown chunking\n const chunks = this.chunker.chunk(content, filePath);\n\n // Determine file type for ranking\n const ext = extname(filePath).toLowerCase();\n const fileName = basename(filePath).toLowerCase();\n const fileType = this.classifyFileType(ext, fileName, filePath);\n\n // Collect source files for code graph\n if (['.ts', '.tsx', '.js', '.jsx'].includes(ext)) {\n sourceFiles.push({ path: filePath, content });\n }\n\n for (const chunk of chunks) {\n const vector = await this.embeddingEngine.embed(chunk.content);\n const chunkId = chunks.length > 1\n ? `${store.id}-${fileHash}-${String(chunk.chunkIndex)}`\n : `${store.id}-${fileHash}`;\n\n const doc: Document = {\n id: createDocumentId(chunkId),\n content: chunk.content,\n vector,\n metadata: {\n type: chunks.length > 1 ? 'chunk' : 'file',\n storeId: store.id,\n path: filePath,\n indexedAt: new Date(),\n fileHash,\n chunkIndex: chunk.chunkIndex,\n totalChunks: chunk.totalChunks,\n // New metadata for ranking\n fileType,\n sectionHeader: chunk.sectionHeader,\n functionName: chunk.functionName,\n hasDocComments: /\\/\\*\\*[\\s\\S]*?\\*\\//.test(chunk.content),\n docSummary: chunk.docSummary,\n },\n };\n documents.push(doc);\n }\n filesProcessed++;\n\n // Emit progress event\n onProgress?.({\n type: 'progress',\n current: filesProcessed,\n total: files.length,\n message: `Indexing ${filePath}`\n });\n }\n\n if (documents.length > 0) {\n await this.lanceStore.addDocuments(store.id, documents);\n }\n\n // Build and save code graph if service is available and we have source files\n if (this.codeGraphService && sourceFiles.length > 0) {\n const graph = await this.codeGraphService.buildGraph(sourceFiles);\n await this.codeGraphService.saveGraph(store.id, graph);\n }\n\n // Emit complete event\n onProgress?.({\n type: 'complete',\n current: files.length,\n total: files.length,\n message: 'Indexing complete'\n });\n\n return ok({\n documentsIndexed: filesProcessed,\n chunksCreated: documents.length,\n timeMs: Date.now() - startTime,\n });\n }\n\n private async scanDirectory(dir: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n // Skip common ignored directories\n if (!['node_modules', '.git', 'dist', 'build'].includes(entry.name)) {\n files.push(...(await this.scanDirectory(fullPath)));\n }\n } else if (entry.isFile()) {\n const ext = extname(entry.name).toLowerCase();\n if (TEXT_EXTENSIONS.has(ext)) {\n files.push(fullPath);\n }\n }\n }\n\n return files;\n }\n\n /**\n * Classify file type for ranking purposes.\n * Documentation files rank higher than source code for documentation queries.\n * Phase 4: Enhanced to detect internal implementation files.\n */\n private classifyFileType(ext: string, fileName: string, filePath: string): string {\n // Documentation files\n if (ext === '.md') {\n // CHANGELOG files get their own category for intent-based penalties\n if (fileName === 'changelog.md' || fileName === 'changes.md' || /changelog/i.test(fileName)) {\n return 'changelog';\n }\n // Special doc files get highest priority\n if (['readme.md', 'migration.md', 'contributing.md'].includes(fileName)) {\n return 'documentation-primary';\n }\n // Check path for documentation indicators\n if (/\\/(docs?|documentation|guides?|tutorials?|articles?)\\//i.test(filePath)) {\n return 'documentation';\n }\n return 'documentation';\n }\n\n // Test files\n if (/\\.(test|spec)\\.[jt]sx?$/.test(fileName) || /\\/__tests__\\//.test(filePath)) {\n return 'test';\n }\n\n // Example files\n if (/\\/examples?\\//.test(filePath) || fileName.includes('example')) {\n return 'example';\n }\n\n // Config files\n if (/^(tsconfig|package|\\.eslint|\\.prettier|vite\\.config|next\\.config)/i.test(fileName)) {\n return 'config';\n }\n\n // Source code - distinguish between internal and public-facing\n if (['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java'].includes(ext)) {\n // Internal implementation files (monorepo packages, lib internals)\n // These patterns indicate internal/core implementation code\n if (this.isInternalImplementation(filePath, fileName)) {\n return 'source-internal';\n }\n return 'source';\n }\n\n return 'other';\n }\n\n /**\n * Detect if a source file is internal implementation code.\n * Internal code should rank lower than public-facing APIs and docs.\n */\n private isInternalImplementation(filePath: string, fileName: string): boolean {\n const pathLower = filePath.toLowerCase();\n const fileNameLower = fileName.toLowerCase();\n\n // Monorepo internal packages (like Vue's packages/*/src/)\n if (/\\/packages\\/[^/]+\\/src\\//.test(pathLower)) {\n // Exception: index files often export public APIs\n if (fileNameLower === 'index.ts' || fileNameLower === 'index.js') {\n return false;\n }\n return true;\n }\n\n // Internal/core directories\n if (/\\/(internal|lib\\/core|core\\/src|_internal|private)\\//.test(pathLower)) {\n return true;\n }\n\n // Compiler/transform internals (often not what users want)\n if (/\\/(compiler|transforms?|parse|codegen)\\//.test(pathLower) &&\n !fileNameLower.includes('readme') && !fileNameLower.includes('index')) {\n return true;\n }\n\n return false;\n }\n}\n","export interface ChunkConfig {\n chunkSize: number;\n chunkOverlap: number;\n}\n\nexport interface Chunk {\n content: string;\n chunkIndex: number;\n totalChunks: number;\n startOffset: number;\n endOffset: number;\n /** Section header if this chunk starts a markdown section */\n sectionHeader?: string | undefined;\n /** Function or class name if this chunk contains a code declaration */\n functionName?: string | undefined;\n /** JSDoc/comment summary extracted from this chunk */\n docSummary?: string | undefined;\n}\n\nexport class ChunkingService {\n private readonly chunkSize: number;\n private readonly chunkOverlap: number;\n\n constructor(config: ChunkConfig) {\n this.chunkSize = config.chunkSize;\n this.chunkOverlap = config.chunkOverlap;\n }\n\n /**\n * Chunk text content. Uses semantic chunking for Markdown and code files,\n * falling back to sliding window for other content.\n */\n chunk(text: string, filePath?: string): Chunk[] {\n // Use semantic chunking for Markdown files\n if (filePath !== undefined && filePath !== '' && /\\.md$/i.test(filePath)) {\n return this.chunkMarkdown(text);\n }\n\n // Use semantic chunking for TypeScript/JavaScript files\n if (filePath !== undefined && filePath !== '' && /\\.(ts|tsx|js|jsx)$/i.test(filePath)) {\n return this.chunkCode(text);\n }\n\n return this.chunkSlidingWindow(text);\n }\n\n /**\n * Semantic chunking for Markdown files.\n * Splits on section headers to keep related content together.\n */\n private chunkMarkdown(text: string): Chunk[] {\n // Match markdown headers (# through ####)\n const headerRegex = /^(#{1,4})\\s+(.+)$/gm;\n const sections: Array<{ header: string; content: string; startOffset: number }> = [];\n\n let lastIndex = 0;\n let lastHeader = '';\n let match: RegExpExecArray | null;\n\n while ((match = headerRegex.exec(text)) !== null) {\n // Save previous section\n if (match.index > lastIndex) {\n const content = text.slice(lastIndex, match.index).trim();\n if (content) {\n sections.push({\n header: lastHeader,\n content: content,\n startOffset: lastIndex,\n });\n }\n }\n lastHeader = match[2] ?? '';\n lastIndex = match.index;\n }\n\n // Add final section\n const finalContent = text.slice(lastIndex).trim();\n if (finalContent) {\n sections.push({\n header: lastHeader,\n content: finalContent,\n startOffset: lastIndex,\n });\n }\n\n // If no sections found, fall back to sliding window\n if (sections.length === 0) {\n return this.chunkSlidingWindow(text);\n }\n\n // Convert sections to chunks, splitting large sections if needed\n const chunks: Chunk[] = [];\n\n for (const section of sections) {\n if (section.content.length <= this.chunkSize) {\n // Section fits in one chunk\n chunks.push({\n content: section.content,\n chunkIndex: chunks.length,\n totalChunks: 0,\n startOffset: section.startOffset,\n endOffset: section.startOffset + section.content.length,\n sectionHeader: section.header || undefined,\n });\n } else {\n // Split large section using sliding window\n const sectionChunks = this.chunkSlidingWindow(section.content);\n for (const subChunk of sectionChunks) {\n chunks.push({\n ...subChunk,\n chunkIndex: chunks.length,\n startOffset: section.startOffset + subChunk.startOffset,\n endOffset: section.startOffset + subChunk.endOffset,\n sectionHeader: section.header || undefined,\n });\n }\n }\n }\n\n // Set totalChunks\n for (const chunk of chunks) {\n chunk.totalChunks = chunks.length;\n }\n\n return chunks;\n }\n\n /**\n * Semantic chunking for TypeScript/JavaScript code files.\n * Splits on top-level declarations to keep functions/classes together.\n */\n private chunkCode(text: string): Chunk[] {\n // Match top-level declarations with optional JSDoc/comments before them\n const declarationRegex = /^(?:\\/\\*\\*[\\s\\S]*?\\*\\/\\s*)?(?:export\\s+)?(?:async\\s+)?(?:function|class|interface|type|const|let|var|enum)\\s+(\\w+)/gm;\n const declarations: Array<{ startOffset: number; endOffset: number; name?: string }> = [];\n\n let match: RegExpExecArray | null;\n while ((match = declarationRegex.exec(text)) !== null) {\n const name = match[1];\n const decl: { startOffset: number; endOffset: number; name?: string } = {\n startOffset: match.index,\n endOffset: match.index,\n };\n if (name !== undefined) {\n decl.name = name;\n }\n declarations.push(decl);\n }\n\n // If no declarations found, use sliding window\n if (declarations.length === 0) {\n return this.chunkSlidingWindow(text);\n }\n\n // Find end of each declaration using brace-aware boundary detection\n for (let i = 0; i < declarations.length; i++) {\n const currentDecl = declarations[i];\n const nextDecl = declarations[i + 1];\n if (currentDecl === undefined) continue;\n\n // For declarations that likely have braces (functions, classes, enums)\n // use smart boundary detection\n const declText = text.slice(currentDecl.startOffset);\n if (/^(?:\\/\\*\\*[\\s\\S]*?\\*\\/\\s*)?(?:export\\s+)?(?:async\\s+)?(?:function|class|enum)\\s+/m.test(declText)) {\n const boundary = this.findDeclarationEnd(declText);\n if (boundary > 0) {\n currentDecl.endOffset = currentDecl.startOffset + boundary;\n } else {\n // Fall back to next declaration or EOF\n currentDecl.endOffset = nextDecl !== undefined ? nextDecl.startOffset : text.length;\n }\n } else {\n // For other declarations (interface, type, const, let, var), use next declaration or EOF\n currentDecl.endOffset = nextDecl !== undefined ? nextDecl.startOffset : text.length;\n }\n }\n\n const chunks: Chunk[] = [];\n\n for (const decl of declarations) {\n const content = text.slice(decl.startOffset, decl.endOffset).trim();\n\n if (content.length <= this.chunkSize) {\n // Declaration fits in one chunk\n chunks.push({\n content,\n chunkIndex: chunks.length,\n totalChunks: 0,\n startOffset: decl.startOffset,\n endOffset: decl.endOffset,\n functionName: decl.name,\n });\n } else {\n // Split large declaration with sliding window\n const declChunks = this.chunkSlidingWindow(content);\n for (const subChunk of declChunks) {\n chunks.push({\n ...subChunk,\n chunkIndex: chunks.length,\n startOffset: decl.startOffset + subChunk.startOffset,\n endOffset: decl.startOffset + subChunk.endOffset,\n functionName: decl.name,\n });\n }\n }\n }\n\n // Set totalChunks\n for (const chunk of chunks) {\n chunk.totalChunks = chunks.length;\n }\n\n return chunks.length > 0 ? chunks : this.chunkSlidingWindow(text);\n }\n\n /**\n * Find the end of a code declaration by counting braces while ignoring\n * braces inside strings and comments.\n * Returns the offset where the declaration ends, or -1 if not found.\n */\n private findDeclarationEnd(text: string): number {\n let braceCount = 0;\n let inString = false;\n let inSingleLineComment = false;\n let inMultiLineComment = false;\n let stringChar = '';\n let i = 0;\n let foundFirstBrace = false;\n\n // Find the first opening brace\n while (i < text.length) {\n const char = text[i];\n const nextChar = i + 1 < text.length ? text[i + 1] : '';\n\n // Handle comments\n if (!inString && !inMultiLineComment && char === '/' && nextChar === '/') {\n inSingleLineComment = true;\n i += 2;\n continue;\n }\n\n if (!inString && !inSingleLineComment && char === '/' && nextChar === '*') {\n inMultiLineComment = true;\n i += 2;\n continue;\n }\n\n if (inMultiLineComment && char === '*' && nextChar === '/') {\n inMultiLineComment = false;\n i += 2;\n continue;\n }\n\n if (inSingleLineComment && char === '\\n') {\n inSingleLineComment = false;\n i++;\n continue;\n }\n\n // Skip if in comment\n if (inSingleLineComment || inMultiLineComment) {\n i++;\n continue;\n }\n\n // Handle strings\n if (!inString && (char === '\"' || char === \"'\" || char === '`')) {\n inString = true;\n stringChar = char;\n i++;\n continue;\n }\n\n if (inString && char === '\\\\') {\n // Skip escaped character\n i += 2;\n continue;\n }\n\n if (inString && char === stringChar) {\n inString = false;\n stringChar = '';\n i++;\n continue;\n }\n\n // Skip if in string\n if (inString) {\n i++;\n continue;\n }\n\n // Count braces\n if (char === '{') {\n braceCount++;\n foundFirstBrace = true;\n } else if (char === '}') {\n braceCount--;\n if (foundFirstBrace && braceCount === 0) {\n // Found the closing brace\n return i + 1;\n }\n }\n\n i++;\n }\n\n // If we didn't find a complete declaration, return -1\n return -1;\n }\n\n /**\n * Traditional sliding window chunking for non-Markdown content.\n */\n private chunkSlidingWindow(text: string): Chunk[] {\n if (text.length <= this.chunkSize) {\n return [{\n content: text,\n chunkIndex: 0,\n totalChunks: 1,\n startOffset: 0,\n endOffset: text.length,\n }];\n }\n\n const chunks: Chunk[] = [];\n const step = this.chunkSize - this.chunkOverlap;\n let start = 0;\n\n while (start < text.length) {\n const end = Math.min(start + this.chunkSize, text.length);\n chunks.push({\n content: text.slice(start, end),\n chunkIndex: chunks.length,\n totalChunks: 0,\n startOffset: start,\n endOffset: end,\n });\n start += step;\n if (end === text.length) break;\n }\n\n // Set totalChunks\n for (const chunk of chunks) {\n chunk.totalChunks = chunks.length;\n }\n\n return chunks;\n }\n}\n","import { readFile, writeFile, mkdir } from 'node:fs/promises';\nimport { join, dirname } from 'node:path';\nimport { CodeGraph, type GraphNode } from '../analysis/code-graph.js';\nimport { ASTParser } from '../analysis/ast-parser.js';\nimport { RustASTParser } from '../analysis/rust-ast-parser.js';\nimport { GoASTParser } from '../analysis/go-ast-parser.js';\nimport { ParserFactory } from '../analysis/parser-factory.js';\nimport type { PythonBridge } from '../crawl/bridge.js';\nimport type { StoreId } from '../types/brands.js';\n\ninterface SerializedGraph {\n nodes: Array<{\n id: string;\n file: string;\n type: string;\n name: string;\n exported: boolean;\n startLine: number;\n endLine: number;\n signature?: string;\n }>;\n edges: Array<{\n from: string;\n to: string;\n type: string;\n confidence: number;\n }>;\n}\n\n/**\n * Service for building, persisting, and querying code graphs.\n * Code graphs track relationships between code elements (functions, classes, etc.)\n * for enhanced search context.\n */\nexport class CodeGraphService {\n private readonly dataDir: string;\n private readonly parser: ASTParser;\n private readonly parserFactory: ParserFactory;\n private readonly graphCache: Map<string, CodeGraph>;\n\n constructor(dataDir: string, pythonBridge?: PythonBridge) {\n this.dataDir = dataDir;\n this.parser = new ASTParser();\n this.parserFactory = new ParserFactory(pythonBridge);\n this.graphCache = new Map();\n }\n\n /**\n * Build a code graph from source files.\n */\n async buildGraph(files: Array<{ path: string; content: string }>): Promise<CodeGraph> {\n const graph = new CodeGraph();\n\n for (const file of files) {\n const ext = file.path.split('.').pop() ?? '';\n if (!['ts', 'tsx', 'js', 'jsx', 'py', 'rs', 'go'].includes(ext)) continue;\n\n // Parse nodes (functions, classes, etc.) using the factory\n const nodes = await this.parserFactory.parseFile(file.path, file.content);\n graph.addNodes(nodes, file.path);\n\n // Parse imports and add edges\n if (ext === 'rs') {\n // Use RustASTParser for Rust imports\n const rustParser = new RustASTParser();\n const imports = rustParser.extractImports(file.content);\n for (const imp of imports) {\n if (!imp.isType) {\n graph.addImport(file.path, imp.source, imp.specifiers);\n }\n }\n } else if (ext === 'go') {\n // Use GoASTParser for Go imports\n const goParser = new GoASTParser();\n const imports = goParser.extractImports(file.content);\n for (const imp of imports) {\n if (!imp.isType) {\n graph.addImport(file.path, imp.source, imp.specifiers);\n }\n }\n } else if (ext !== 'py') {\n // Use ASTParser for JS/TS imports (Python imports handled by Python parser)\n const imports = this.parser.extractImports(file.content);\n for (const imp of imports) {\n if (!imp.isType) {\n graph.addImport(file.path, imp.source, imp.specifiers);\n }\n }\n }\n\n // Analyze call relationships for each function/method\n for (const node of nodes) {\n const lines = file.content.split('\\n');\n\n if (node.type === 'function') {\n // Extract the function body for call analysis\n const functionCode = lines.slice(node.startLine - 1, node.endLine).join('\\n');\n graph.analyzeCallRelationships(functionCode, file.path, node.name);\n } else if (node.type === 'class' && node.methods !== undefined) {\n // For classes, analyze each method separately\n for (const method of node.methods) {\n const methodCode = lines.slice(method.startLine - 1, method.endLine).join('\\n');\n graph.analyzeCallRelationships(methodCode, file.path, `${node.name}.${method.name}`);\n }\n }\n }\n }\n\n return graph;\n }\n\n /**\n * Save a code graph for a store.\n */\n async saveGraph(storeId: StoreId, graph: CodeGraph): Promise<void> {\n const graphPath = this.getGraphPath(storeId);\n await mkdir(dirname(graphPath), { recursive: true });\n\n const serialized = graph.toJSON();\n await writeFile(graphPath, JSON.stringify(serialized, null, 2));\n }\n\n /**\n * Load a code graph for a store.\n * Returns undefined if no graph exists.\n */\n async loadGraph(storeId: StoreId): Promise<CodeGraph | undefined> {\n // Check cache first\n const cached = this.graphCache.get(storeId);\n if (cached) return cached;\n\n const graphPath = this.getGraphPath(storeId);\n\n try {\n const content = await readFile(graphPath, 'utf-8');\n const parsed: unknown = JSON.parse(content);\n\n // Validate structure\n if (!this.isSerializedGraph(parsed)) {\n return undefined;\n }\n\n const serialized = parsed;\n const graph = new CodeGraph();\n\n // Restore nodes\n for (const node of serialized.nodes) {\n const nodeType = this.validateNodeType(node.type);\n if (!nodeType) continue;\n\n // Method nodes are added directly to the graph since they're already separate nodes\n if (nodeType === 'method') {\n const graphNode: GraphNode = {\n id: node.id,\n file: node.file,\n type: 'method',\n name: node.name,\n exported: node.exported,\n startLine: node.startLine,\n endLine: node.endLine\n };\n if (node.signature !== undefined) {\n graphNode.signature = node.signature;\n }\n graph.addGraphNode(graphNode);\n continue;\n }\n\n const codeNode: {\n type: 'function' | 'class' | 'interface' | 'type' | 'const';\n name: string;\n exported: boolean;\n startLine: number;\n endLine: number;\n signature?: string;\n } = {\n type: nodeType,\n name: node.name,\n exported: node.exported,\n startLine: node.startLine,\n endLine: node.endLine,\n };\n if (node.signature !== undefined) {\n codeNode.signature = node.signature;\n }\n graph.addNodes([codeNode], node.file);\n }\n\n // Restore edges\n for (const edge of serialized.edges) {\n const edgeType = this.validateEdgeType(edge.type);\n if (!edgeType) continue;\n\n graph.addEdge({\n from: edge.from,\n to: edge.to,\n type: edgeType,\n confidence: edge.confidence\n });\n }\n\n this.graphCache.set(storeId, graph);\n return graph;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Get usage stats for a code element.\n */\n getUsageStats(graph: CodeGraph, filePath: string, symbolName: string): { calledBy: number; calls: number } {\n const nodeId = `${filePath}:${symbolName}`;\n return {\n calledBy: graph.getCalledByCount(nodeId),\n calls: graph.getCallsCount(nodeId)\n };\n }\n\n /**\n * Get related code (callers and callees) for a code element.\n */\n getRelatedCode(graph: CodeGraph, filePath: string, symbolName: string): Array<{ id: string; relationship: string }> {\n const nodeId = `${filePath}:${symbolName}`;\n const related: Array<{ id: string; relationship: string }> = [];\n\n // Get callers (incoming call edges)\n const incoming = graph.getIncomingEdges(nodeId);\n for (const edge of incoming) {\n if (edge.type === 'calls') {\n related.push({ id: edge.from, relationship: 'calls this' });\n }\n }\n\n // Get callees (outgoing call edges)\n const outgoing = graph.getEdges(nodeId);\n for (const edge of outgoing) {\n if (edge.type === 'calls') {\n related.push({ id: edge.to, relationship: 'called by this' });\n }\n }\n\n return related;\n }\n\n /**\n * Clear cached graphs.\n */\n clearCache(): void {\n this.graphCache.clear();\n }\n\n private getGraphPath(storeId: StoreId): string {\n return join(this.dataDir, 'graphs', `${storeId}.json`);\n }\n\n /**\n * Type guard for SerializedGraph structure.\n */\n private isSerializedGraph(value: unknown): value is SerializedGraph {\n if (typeof value !== 'object' || value === null) return false;\n // Use 'in' operator for property checking\n if (!('nodes' in value) || !('edges' in value)) return false;\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- narrowed via 'in' checks above\n const obj = value as { nodes: unknown; edges: unknown };\n return Array.isArray(obj.nodes) && Array.isArray(obj.edges);\n }\n\n /**\n * Type guard for valid node types.\n */\n private isValidNodeType(type: string): type is 'function' | 'class' | 'interface' | 'type' | 'const' | 'method' {\n return ['function', 'class', 'interface', 'type', 'const', 'method'].includes(type);\n }\n\n /**\n * Validate and return a node type, or undefined if invalid.\n */\n private validateNodeType(type: string): 'function' | 'class' | 'interface' | 'type' | 'const' | 'method' | undefined {\n if (this.isValidNodeType(type)) {\n return type;\n }\n return undefined;\n }\n\n /**\n * Type guard for valid edge types.\n */\n private isValidEdgeType(type: string): type is 'calls' | 'imports' | 'extends' | 'implements' {\n return ['calls', 'imports', 'extends', 'implements'].includes(type);\n }\n\n /**\n * Validate and return an edge type, or undefined if invalid.\n */\n private validateEdgeType(type: string): 'calls' | 'imports' | 'extends' | 'implements' | undefined {\n if (this.isValidEdgeType(type)) {\n return type;\n }\n return undefined;\n }\n}\n","import type { CodeNode } from './ast-parser.js';\n\nexport interface GraphNode {\n id: string;\n file: string;\n type: 'function' | 'class' | 'interface' | 'type' | 'const' | 'method';\n name: string;\n exported: boolean;\n startLine: number;\n endLine: number;\n signature?: string;\n}\n\nexport interface GraphEdge {\n from: string;\n to: string;\n type: 'calls' | 'imports' | 'extends' | 'implements';\n confidence: number;\n}\n\nexport class CodeGraph {\n private readonly nodes: Map<string, GraphNode> = new Map<string, GraphNode>();\n private readonly edges: Map<string, GraphEdge[]> = new Map<string, GraphEdge[]>();\n\n addNodes(nodes: CodeNode[], file: string): void {\n for (const node of nodes) {\n const id = `${file}:${node.name}`;\n\n const graphNode: GraphNode = {\n id,\n file,\n type: node.type,\n name: node.name,\n exported: node.exported,\n startLine: node.startLine,\n endLine: node.endLine\n };\n\n if (node.signature !== undefined) {\n graphNode.signature = node.signature;\n }\n\n this.nodes.set(id, graphNode);\n\n // Initialize edges array for this node\n if (!this.edges.has(id)) {\n this.edges.set(id, []);\n }\n\n // If this is a class with methods, create separate nodes for each method\n if (node.type === 'class' && node.methods !== undefined) {\n for (const method of node.methods) {\n const methodId = `${file}:${node.name}.${method.name}`;\n\n const methodNode: GraphNode = {\n id: methodId,\n file,\n type: 'method',\n name: method.name,\n exported: node.exported, // Methods inherit export status from class\n startLine: method.startLine,\n endLine: method.endLine,\n signature: method.signature\n };\n\n this.nodes.set(methodId, methodNode);\n\n // Initialize edges array for this method\n if (!this.edges.has(methodId)) {\n this.edges.set(methodId, []);\n }\n }\n }\n }\n }\n\n addImport(fromFile: string, toFile: string, specifiers: string[]): void {\n // Normalize the toFile path (resolve relative imports)\n const resolvedTo = this.resolveImportPath(fromFile, toFile);\n\n for (const spec of specifiers) {\n const edge: GraphEdge = {\n from: fromFile,\n to: `${resolvedTo}:${spec}`,\n type: 'imports',\n confidence: 1.0\n };\n\n const edges = this.edges.get(fromFile) ?? [];\n edges.push(edge);\n this.edges.set(fromFile, edges);\n }\n }\n\n analyzeCallRelationships(code: string, file: string, functionName: string): void {\n const nodeId = `${file}:${functionName}`;\n\n // Simple regex-based call detection (can be enhanced with AST later)\n const callPattern = /\\b([a-zA-Z_$][a-zA-Z0-9_$]*)\\s*\\(/g;\n const calls = new Set<string>();\n\n let match;\n while ((match = callPattern.exec(code)) !== null) {\n if (match[1] !== undefined && match[1] !== '') {\n calls.add(match[1]);\n }\n }\n\n const edges = this.edges.get(nodeId) ?? [];\n\n for (const calledFunction of calls) {\n // Try to find the called function in the graph\n const targetNode = this.findNodeByName(calledFunction);\n\n if (targetNode) {\n edges.push({\n from: nodeId,\n to: targetNode.id,\n type: 'calls',\n confidence: 0.8 // Lower confidence for regex-based detection\n });\n } else {\n // Unknown function, possibly from import\n edges.push({\n from: nodeId,\n to: `unknown:${calledFunction}`,\n type: 'calls',\n confidence: 0.5\n });\n }\n }\n\n this.edges.set(nodeId, edges);\n }\n\n getNode(id: string): GraphNode | undefined {\n return this.nodes.get(id);\n }\n\n getEdges(nodeId: string): GraphEdge[] {\n return this.edges.get(nodeId) ?? [];\n }\n\n /**\n * Add an edge to the graph (used when restoring from serialized data)\n */\n addEdge(edge: GraphEdge): void {\n const edges = this.edges.get(edge.from) ?? [];\n edges.push(edge);\n this.edges.set(edge.from, edges);\n }\n\n /**\n * Add a graph node directly (used when restoring from serialized data)\n */\n addGraphNode(node: GraphNode): void {\n this.nodes.set(node.id, node);\n\n // Initialize edges array for this node if it doesn't exist\n if (!this.edges.has(node.id)) {\n this.edges.set(node.id, []);\n }\n }\n\n /**\n * Get edges where this node is the target (callers of this function)\n */\n getIncomingEdges(nodeId: string): GraphEdge[] {\n const incoming: GraphEdge[] = [];\n for (const edges of this.edges.values()) {\n for (const edge of edges) {\n if (edge.to === nodeId) {\n incoming.push(edge);\n }\n }\n }\n return incoming;\n }\n\n /**\n * Count how many nodes call this node\n */\n getCalledByCount(nodeId: string): number {\n return this.getIncomingEdges(nodeId)\n .filter(e => e.type === 'calls')\n .length;\n }\n\n /**\n * Count how many nodes this node calls\n */\n getCallsCount(nodeId: string): number {\n return this.getEdges(nodeId)\n .filter(e => e.type === 'calls')\n .length;\n }\n\n getAllNodes(): GraphNode[] {\n return Array.from(this.nodes.values());\n }\n\n private findNodeByName(name: string): GraphNode | undefined {\n for (const node of this.nodes.values()) {\n if (node.name === name) {\n return node;\n }\n }\n return undefined;\n }\n\n private resolveImportPath(fromFile: string, importPath: string): string {\n // Simple resolution - can be enhanced\n if (importPath.startsWith('.')) {\n // Relative import\n const fromDir = fromFile.split('/').slice(0, -1).join('/');\n const parts = importPath.split('/');\n\n let resolved = fromDir;\n for (const part of parts) {\n if (part === '..') {\n resolved = resolved.split('/').slice(0, -1).join('/');\n } else if (part !== '.') {\n resolved += '/' + part;\n }\n }\n\n return resolved.replace(/\\.js$/, '');\n }\n\n // Package import\n return importPath;\n }\n\n toJSON(): { nodes: GraphNode[]; edges: Array<{ from: string; to: string; type: string }> } {\n const allEdges: GraphEdge[] = [];\n for (const edges of this.edges.values()) {\n allEdges.push(...edges);\n }\n\n return {\n nodes: Array.from(this.nodes.values()),\n edges: allEdges.map(e => ({ from: e.from, to: e.to, type: e.type }))\n };\n }\n}\n","import { parse, type ParserPlugin } from '@babel/parser';\nimport type { NodePath } from '@babel/traverse';\nimport traverseModule from '@babel/traverse';\nimport * as t from '@babel/types';\n\n// Handle both ESM and CJS module formats\ntype TraverseFunction = (ast: t.File, visitor: Record<string, unknown>) => void;\nfunction getTraverse(mod: unknown): TraverseFunction {\n if (typeof mod === 'function') {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return mod as TraverseFunction;\n }\n if (mod !== null && typeof mod === 'object' && 'default' in mod) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const withDefault = mod as { default: unknown };\n if (typeof withDefault.default === 'function') {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return withDefault.default as TraverseFunction;\n }\n }\n throw new Error('Invalid traverse module export');\n}\nconst traverse = getTraverse(traverseModule);\n\nexport interface CodeNode {\n type: 'function' | 'class' | 'interface' | 'type' | 'const';\n name: string;\n exported: boolean;\n async?: boolean;\n startLine: number;\n endLine: number;\n signature?: string;\n methods?: Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }>;\n}\n\nexport interface ImportInfo {\n source: string;\n specifiers: string[];\n isType: boolean;\n}\n\nexport class ASTParser {\n parse(code: string, language: 'typescript' | 'javascript'): CodeNode[] {\n try {\n const plugins: ParserPlugin[] = ['jsx'];\n if (language === 'typescript') {\n plugins.push('typescript');\n }\n\n const ast = parse(code, {\n sourceType: 'module',\n plugins\n });\n\n const nodes: CodeNode[] = [];\n\n traverse(ast, {\n FunctionDeclaration: (path: NodePath<t.FunctionDeclaration>) => {\n const node = path.node;\n if (!node.id) return;\n\n const exported = path.parent.type === 'ExportNamedDeclaration' ||\n path.parent.type === 'ExportDefaultDeclaration';\n\n nodes.push({\n type: 'function',\n name: node.id.name,\n exported,\n async: node.async,\n startLine: node.loc?.start.line ?? 0,\n endLine: node.loc?.end.line ?? 0,\n signature: this.extractFunctionSignature(node)\n });\n },\n\n ClassDeclaration: (path: NodePath<t.ClassDeclaration>) => {\n const node = path.node;\n if (!node.id) return;\n\n const exported = path.parent.type === 'ExportNamedDeclaration' ||\n path.parent.type === 'ExportDefaultDeclaration';\n\n const methods: CodeNode['methods'] = [];\n\n for (const member of node.body.body) {\n if (t.isClassMethod(member) && t.isIdentifier(member.key)) {\n methods.push({\n name: member.key.name,\n async: member.async,\n signature: this.extractMethodSignature(member),\n startLine: member.loc?.start.line ?? 0,\n endLine: member.loc?.end.line ?? 0\n });\n }\n }\n\n nodes.push({\n type: 'class',\n name: node.id.name,\n exported,\n startLine: node.loc?.start.line ?? 0,\n endLine: node.loc?.end.line ?? 0,\n methods\n });\n },\n\n TSInterfaceDeclaration: (path: NodePath<t.TSInterfaceDeclaration>) => {\n const node = path.node;\n\n const exported = path.parent.type === 'ExportNamedDeclaration';\n\n nodes.push({\n type: 'interface',\n name: node.id.name,\n exported,\n startLine: node.loc?.start.line ?? 0,\n endLine: node.loc?.end.line ?? 0\n });\n }\n });\n\n return nodes;\n } catch {\n // Return empty array for malformed code\n return [];\n }\n }\n\n extractImports(code: string): ImportInfo[] {\n try {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx']\n });\n\n const imports: ImportInfo[] = [];\n\n traverse(ast, {\n ImportDeclaration: (path: NodePath<t.ImportDeclaration>) => {\n const node = path.node;\n const specifiers: string[] = [];\n\n for (const spec of node.specifiers) {\n if (t.isImportDefaultSpecifier(spec)) {\n specifiers.push(spec.local.name);\n } else if (t.isImportSpecifier(spec)) {\n specifiers.push(spec.local.name);\n } else if (t.isImportNamespaceSpecifier(spec)) {\n specifiers.push(spec.local.name);\n }\n }\n\n imports.push({\n source: node.source.value,\n specifiers,\n isType: node.importKind === 'type'\n });\n }\n });\n\n return imports;\n } catch {\n // Return empty array for malformed code\n return [];\n }\n }\n\n private extractFunctionSignature(node: t.FunctionDeclaration): string {\n const params = node.params.map(p => {\n if (t.isIdentifier(p)) return p.name;\n return 'param';\n }).join(', ');\n\n return `${node.id?.name ?? 'anonymous'}(${params})`;\n }\n\n private extractMethodSignature(node: t.ClassMethod): string {\n const params = node.params.map(p => {\n if (t.isIdentifier(p)) return p.name;\n return 'param';\n }).join(', ');\n\n const name = t.isIdentifier(node.key) ? node.key.name : 'method';\n return `${name}(${params})`;\n }\n}\n","import Parser from 'tree-sitter';\nimport Rust from 'tree-sitter-rust';\nimport Go from 'tree-sitter-go';\n\n/**\n * Tree-sitter infrastructure for parsing Rust and Go code.\n * Provides utilities for AST traversal, querying, and position conversion.\n */\n\nexport interface TreeSitterPosition {\n row: number;\n column: number;\n}\n\nexport interface TreeSitterNode {\n type: string;\n text: string;\n startPosition: TreeSitterPosition;\n endPosition: TreeSitterPosition;\n startIndex: number;\n endIndex: number;\n childCount: number;\n namedChildCount: number;\n children: TreeSitterNode[];\n namedChildren: TreeSitterNode[];\n parent: TreeSitterNode | null;\n nextSibling: TreeSitterNode | null;\n previousSibling: TreeSitterNode | null;\n firstChild: TreeSitterNode | null;\n lastChild: TreeSitterNode | null;\n firstNamedChild: TreeSitterNode | null;\n lastNamedChild: TreeSitterNode | null;\n child(index: number): TreeSitterNode | null;\n namedChild(index: number): TreeSitterNode | null;\n childForFieldName(fieldName: string): TreeSitterNode | null;\n descendantsOfType(type: string | string[]): TreeSitterNode[];\n}\n\nexport interface TreeSitterTree {\n rootNode: TreeSitterNode;\n edit(delta: unknown): void;\n walk(): unknown;\n}\n\n/**\n * Initialize a tree-sitter parser for Rust\n */\nexport function createRustParser(): Parser {\n const parser = new Parser();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- tree-sitter-rust lacks TypeScript definitions\n parser.setLanguage(Rust as Parser.Language);\n return parser;\n}\n\n/**\n * Parse Rust source code into an AST\n */\nexport function parseRustCode(code: string): TreeSitterTree | null {\n try {\n const parser = createRustParser();\n return parser.parse(code);\n } catch {\n // Return null for malformed code\n return null;\n }\n}\n\n/**\n * Initialize a tree-sitter parser for Go\n */\nexport function createGoParser(): Parser {\n const parser = new Parser();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- tree-sitter-go lacks TypeScript definitions\n parser.setLanguage(Go as Parser.Language);\n return parser;\n}\n\n/**\n * Parse Go source code into an AST\n */\nexport function parseGoCode(code: string): TreeSitterTree | null {\n try {\n const parser = createGoParser();\n return parser.parse(code);\n } catch {\n // Return null for malformed code\n return null;\n }\n}\n\n/**\n * Convert tree-sitter position (0-indexed) to line number (1-indexed)\n */\nexport function positionToLineNumber(position: TreeSitterPosition): number {\n return position.row + 1;\n}\n\n/**\n * Get the text content of a node\n */\nexport function getNodeText(node: TreeSitterNode): string {\n return node.text;\n}\n\n/**\n * Get all children of a specific type\n */\nexport function getChildrenOfType(\n node: TreeSitterNode,\n type: string\n): TreeSitterNode[] {\n return node.children.filter(child => child.type === type);\n}\n\n/**\n * Get the first child of a specific type\n */\nexport function getFirstChildOfType(\n node: TreeSitterNode,\n type: string\n): TreeSitterNode | null {\n return node.children.find(child => child.type === type) ?? null;\n}\n\n/**\n * Get child by field name (e.g., \"name\", \"body\", \"parameters\")\n */\nexport function getChildByFieldName(\n node: TreeSitterNode,\n fieldName: string\n): TreeSitterNode | null {\n return node.childForFieldName(fieldName);\n}\n\n/**\n * Check if node has a visibility modifier (pub)\n */\nexport function hasVisibilityModifier(node: TreeSitterNode): boolean {\n return node.children.some(child => child.type === 'visibility_modifier');\n}\n\n/**\n * Get visibility modifier text (e.g., \"pub\", \"pub(crate)\")\n */\nexport function getVisibilityModifier(node: TreeSitterNode): string | null {\n const visNode = node.children.find(child => child.type === 'visibility_modifier');\n return visNode !== undefined ? visNode.text : null;\n}\n\n/**\n * Check if a function is async\n */\nexport function isAsyncFunction(node: TreeSitterNode): boolean {\n // Check for 'async' keyword in function_item or function_signature_item\n return node.children.some(child => child.type === 'async' || child.text === 'async');\n}\n\n/**\n * Check if a function is unsafe\n */\nexport function isUnsafeFunction(node: TreeSitterNode): boolean {\n return node.children.some(child => child.type === 'unsafe' || child.text === 'unsafe');\n}\n\n/**\n * Extract function signature including generics and parameters\n */\nexport function getFunctionSignature(node: TreeSitterNode): string {\n // Extract the full signature by getting text from name to return type\n const nameNode = getChildByFieldName(node, 'name');\n const parametersNode = getChildByFieldName(node, 'parameters');\n const returnTypeNode = getChildByFieldName(node, 'return_type');\n const typeParametersNode = getChildByFieldName(node, 'type_parameters');\n\n if (nameNode === null) {\n return '';\n }\n\n let signature = nameNode.text;\n\n // Add type parameters (generics)\n if (typeParametersNode !== null) {\n signature += typeParametersNode.text;\n }\n\n // Add parameters\n if (parametersNode !== null) {\n signature += parametersNode.text;\n }\n\n // Add return type\n if (returnTypeNode !== null) {\n signature += ' ' + returnTypeNode.text;\n }\n\n return signature;\n}\n\n/**\n * Query nodes of specific type from the tree\n * @param tree The tree-sitter tree\n * @param nodeType The type of nodes to find (e.g., 'function_item', 'struct_item')\n * @returns Array of matching nodes\n */\nexport function queryNodesByType(\n tree: TreeSitterTree,\n nodeType: string | string[]\n): TreeSitterNode[] {\n const types = Array.isArray(nodeType) ? nodeType : [nodeType];\n return tree.rootNode.descendantsOfType(types);\n}\n\n/**\n * Extract use statement import path\n */\nexport function extractImportPath(useNode: TreeSitterNode): string {\n // Get the use_declaration argument\n const argumentNode = getChildByFieldName(useNode, 'argument');\n if (argumentNode === null) {\n return '';\n }\n return argumentNode.text;\n}\n","import type { CodeNode, ImportInfo } from './ast-parser.js';\nimport {\n parseRustCode,\n queryNodesByType,\n positionToLineNumber,\n getChildByFieldName,\n hasVisibilityModifier,\n isAsyncFunction,\n getFunctionSignature,\n extractImportPath,\n type TreeSitterNode,\n type TreeSitterTree\n} from './tree-sitter-parser.js';\n\n/**\n * Parser for Rust code using tree-sitter\n * Extracts functions, structs, traits, types, constants, and imports\n */\nexport class RustASTParser {\n /**\n * Parse Rust code into CodeNode array\n * @param code Rust source code\n * @param filePath File path for error context\n * @returns Array of CodeNode objects representing Rust constructs\n */\n parse(code: string, _filePath: string): CodeNode[] {\n try {\n const tree = parseRustCode(code);\n if (tree === null) {\n // Malformed code - return empty array\n return [];\n }\n\n const nodes: CodeNode[] = [];\n\n // Parse functions\n const functions = this.parseFunctions(tree);\n nodes.push(...functions);\n\n // Parse structs\n const structs = this.parseStructs(tree);\n nodes.push(...structs);\n\n // Parse traits\n const traits = this.parseTraits(tree);\n nodes.push(...traits);\n\n // Parse type aliases\n const types = this.parseTypeAliases(tree);\n nodes.push(...types);\n\n // Parse constants and statics\n const constants = this.parseConstants(tree);\n nodes.push(...constants);\n\n // Parse impl blocks and attach methods to structs\n this.parseImplBlocks(tree, nodes);\n\n return nodes;\n } catch {\n // Return empty array for any parsing errors\n return [];\n }\n }\n\n /**\n * Extract imports from Rust code\n * @param code Rust source code\n * @returns Array of ImportInfo objects\n */\n extractImports(code: string): ImportInfo[] {\n try {\n const tree = parseRustCode(code);\n if (tree === null) {\n return [];\n }\n\n const useDeclarations = queryNodesByType(tree, 'use_declaration');\n const imports: ImportInfo[] = [];\n\n for (const useNode of useDeclarations) {\n const importPath = extractImportPath(useNode);\n if (importPath === '') {\n continue;\n }\n\n // Parse the import path to extract module and specifiers\n const { source, specifiers } = this.parseImportPath(importPath);\n\n imports.push({\n source,\n specifiers,\n isType: false // Rust doesn't distinguish type-only imports at syntax level\n });\n }\n\n return imports;\n } catch {\n return [];\n }\n }\n\n /**\n * Parse function declarations (excluding impl block methods)\n */\n private parseFunctions(tree: TreeSitterTree): CodeNode[] {\n const functionNodes = queryNodesByType(tree, 'function_item');\n const nodes: CodeNode[] = [];\n\n for (const fnNode of functionNodes) {\n // Skip functions inside impl blocks - they'll be handled as methods\n if (this.isInsideImplBlock(fnNode)) {\n continue;\n }\n\n const nameNode = getChildByFieldName(fnNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = hasVisibilityModifier(fnNode);\n const async = isAsyncFunction(fnNode);\n const startLine = positionToLineNumber(fnNode.startPosition);\n const endLine = positionToLineNumber(fnNode.endPosition);\n const signature = getFunctionSignature(fnNode);\n\n nodes.push({\n type: 'function',\n name,\n exported,\n async,\n startLine,\n endLine,\n signature\n });\n }\n\n return nodes;\n }\n\n /**\n * Check if a node is inside an impl block\n */\n private isInsideImplBlock(node: TreeSitterNode): boolean {\n let current = node.parent;\n while (current !== null) {\n if (current.type === 'impl_item') {\n return true;\n }\n current = current.parent;\n }\n return false;\n }\n\n /**\n * Parse struct definitions\n */\n private parseStructs(tree: TreeSitterTree): CodeNode[] {\n const structNodes = queryNodesByType(tree, 'struct_item');\n const nodes: CodeNode[] = [];\n\n for (const structNode of structNodes) {\n const nameNode = getChildByFieldName(structNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = hasVisibilityModifier(structNode);\n const startLine = positionToLineNumber(structNode.startPosition);\n const endLine = positionToLineNumber(structNode.endPosition);\n\n // Get type parameters (generics) if present\n const typeParamsNode = getChildByFieldName(structNode, 'type_parameters');\n const signature = typeParamsNode !== null\n ? `${name}${typeParamsNode.text}`\n : name;\n\n nodes.push({\n type: 'class',\n name,\n exported,\n startLine,\n endLine,\n signature,\n methods: [] // Will be populated by parseImplBlocks\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse trait definitions\n */\n private parseTraits(tree: TreeSitterTree): CodeNode[] {\n const traitNodes = queryNodesByType(tree, 'trait_item');\n const nodes: CodeNode[] = [];\n\n for (const traitNode of traitNodes) {\n const nameNode = getChildByFieldName(traitNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = hasVisibilityModifier(traitNode);\n const startLine = positionToLineNumber(traitNode.startPosition);\n const endLine = positionToLineNumber(traitNode.endPosition);\n\n // Get type parameters (generics) if present\n const typeParamsNode = getChildByFieldName(traitNode, 'type_parameters');\n const signature = typeParamsNode !== null\n ? `${name}${typeParamsNode.text}`\n : name;\n\n // Extract trait methods\n const methods = this.extractTraitMethods(traitNode);\n\n nodes.push({\n type: 'interface',\n name,\n exported,\n startLine,\n endLine,\n signature,\n methods\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse type aliases\n */\n private parseTypeAliases(tree: TreeSitterTree): CodeNode[] {\n const typeNodes = queryNodesByType(tree, 'type_item');\n const nodes: CodeNode[] = [];\n\n for (const typeNode of typeNodes) {\n const nameNode = getChildByFieldName(typeNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = hasVisibilityModifier(typeNode);\n const startLine = positionToLineNumber(typeNode.startPosition);\n const endLine = positionToLineNumber(typeNode.endPosition);\n\n // Get the full type alias definition\n const valueNode = getChildByFieldName(typeNode, 'type');\n const signature = valueNode !== null\n ? `${name} = ${valueNode.text}`\n : name;\n\n nodes.push({\n type: 'type',\n name,\n exported,\n startLine,\n endLine,\n signature\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse constants and statics\n */\n private parseConstants(tree: TreeSitterTree): CodeNode[] {\n const constNodes = queryNodesByType(tree, ['const_item', 'static_item']);\n const nodes: CodeNode[] = [];\n\n for (const constNode of constNodes) {\n const nameNode = getChildByFieldName(constNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = hasVisibilityModifier(constNode);\n const startLine = positionToLineNumber(constNode.startPosition);\n const endLine = positionToLineNumber(constNode.endPosition);\n\n // Get type annotation\n const typeNode = getChildByFieldName(constNode, 'type');\n const signature = typeNode !== null\n ? `${name}: ${typeNode.text}`\n : name;\n\n nodes.push({\n type: 'const',\n name,\n exported,\n startLine,\n endLine,\n signature\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse impl blocks and attach methods to corresponding structs\n */\n private parseImplBlocks(tree: TreeSitterTree, nodes: CodeNode[]): void {\n const implNodes = queryNodesByType(tree, 'impl_item');\n\n for (const implNode of implNodes) {\n // Get the type being implemented\n const typeNode = getChildByFieldName(implNode, 'type');\n if (typeNode === null) {\n continue;\n }\n\n const typeName = typeNode.text;\n\n // Extract methods from impl block\n const methods = this.extractImplMethods(implNode);\n\n // Find the corresponding struct and attach methods\n const structNode = nodes.find(\n node => node.type === 'class' && node.name === typeName\n );\n\n if (structNode !== undefined && structNode.methods !== undefined) {\n structNode.methods.push(...methods);\n }\n }\n }\n\n /**\n * Extract methods from trait definition\n */\n private extractTraitMethods(traitNode: TreeSitterNode): Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> {\n const methods: Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> = [];\n\n // Get declaration_list (trait body)\n const bodyNode = getChildByFieldName(traitNode, 'body');\n if (bodyNode === null) {\n return methods;\n }\n\n // Find all function_signature_item nodes (trait method declarations)\n const functionSignatures = bodyNode.descendantsOfType('function_signature_item');\n\n for (const fnSigNode of functionSignatures) {\n const nameNode = getChildByFieldName(fnSigNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const async = isAsyncFunction(fnSigNode);\n const signature = getFunctionSignature(fnSigNode);\n const startLine = positionToLineNumber(fnSigNode.startPosition);\n const endLine = positionToLineNumber(fnSigNode.endPosition);\n\n methods.push({\n name,\n async,\n signature,\n startLine,\n endLine\n });\n }\n\n return methods;\n }\n\n /**\n * Extract methods from impl block\n */\n private extractImplMethods(implNode: TreeSitterNode): Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> {\n const methods: Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> = [];\n\n // Get declaration_list (impl body)\n const bodyNode = getChildByFieldName(implNode, 'body');\n if (bodyNode === null) {\n return methods;\n }\n\n // Find all function_item nodes (impl methods)\n const functionItems = bodyNode.descendantsOfType('function_item');\n\n for (const fnNode of functionItems) {\n const nameNode = getChildByFieldName(fnNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const async = isAsyncFunction(fnNode);\n const signature = getFunctionSignature(fnNode);\n const startLine = positionToLineNumber(fnNode.startPosition);\n const endLine = positionToLineNumber(fnNode.endPosition);\n\n methods.push({\n name,\n async,\n signature,\n startLine,\n endLine\n });\n }\n\n return methods;\n }\n\n /**\n * Parse import path into source and specifiers\n * Examples:\n * - \"std::collections::HashMap\" -> { source: \"std::collections\", specifiers: [\"HashMap\"] }\n * - \"crate::utils::*\" -> { source: \"crate::utils\", specifiers: [\"*\"] }\n * - \"super::Type\" -> { source: \"super\", specifiers: [\"Type\"] }\n */\n private parseImportPath(importPath: string): { source: string; specifiers: string[] } {\n // Remove whitespace\n const path = importPath.trim();\n\n // Handle glob imports (use std::io::*)\n if (path.includes('::*')) {\n const source = path.replace('::*', '');\n return { source, specifiers: ['*'] };\n }\n\n // Handle scoped imports: use std::io::{Read, Write}\n const scopedMatch = path.match(/^(.+)::\\{(.+)\\}$/);\n if (scopedMatch !== null) {\n const source = scopedMatch[1] ?? '';\n const specifiersStr = scopedMatch[2] ?? '';\n const specifiers = specifiersStr.split(',').map(s => s.trim());\n return { source, specifiers };\n }\n\n // Handle simple imports: use std::collections::HashMap\n const parts = path.split('::');\n if (parts.length > 1) {\n const specifiers = [parts[parts.length - 1] ?? ''];\n const source = parts.slice(0, -1).join('::');\n return { source, specifiers };\n }\n\n // Single item import\n return { source: '', specifiers: [path] };\n }\n}\n","import type { CodeNode, ImportInfo } from './ast-parser.js';\nimport {\n parseGoCode,\n queryNodesByType,\n positionToLineNumber,\n getChildByFieldName,\n getFunctionSignature,\n getFirstChildOfType,\n type TreeSitterNode,\n type TreeSitterTree\n} from './tree-sitter-parser.js';\n\n/**\n * Parser for Go code using tree-sitter\n * Extracts functions, methods, structs, interfaces, types, constants, and imports\n */\nexport class GoASTParser {\n /**\n * Parse Go code into CodeNode array\n * @param code Go source code\n * @param filePath File path for error context\n * @returns Array of CodeNode objects representing Go constructs\n */\n parse(code: string, _filePath: string): CodeNode[] {\n try {\n const tree = parseGoCode(code);\n if (tree === null) {\n // Malformed code - return empty array\n return [];\n }\n\n const nodes: CodeNode[] = [];\n\n // Parse functions\n const functions = this.parseFunctions(tree);\n nodes.push(...functions);\n\n // Parse structs\n const structs = this.parseStructs(tree);\n nodes.push(...structs);\n\n // Parse interfaces\n const interfaces = this.parseInterfaces(tree);\n nodes.push(...interfaces);\n\n // Parse type aliases\n const types = this.parseTypeAliases(tree);\n nodes.push(...types);\n\n // Parse constants and variables\n const constants = this.parseConstants(tree);\n nodes.push(...constants);\n\n // Parse methods and attach to structs\n this.parseMethods(tree, nodes);\n\n return nodes;\n } catch {\n // Return empty array for any parsing errors\n return [];\n }\n }\n\n /**\n * Extract imports from Go code\n * @param code Go source code\n * @returns Array of ImportInfo objects\n */\n extractImports(code: string): ImportInfo[] {\n try {\n const tree = parseGoCode(code);\n if (tree === null) {\n return [];\n }\n\n const imports: ImportInfo[] = [];\n const importDecls = queryNodesByType(tree, 'import_declaration');\n\n for (const importDecl of importDecls) {\n const importSpecs = importDecl.descendantsOfType('import_spec');\n\n for (const spec of importSpecs) {\n const pathNode = getChildByFieldName(spec, 'path');\n if (pathNode === null) {\n continue;\n }\n\n // Extract string content from interpreted_string_literal\n const stringContent = pathNode.descendantsOfType('interpreted_string_literal_content')[0];\n const path = stringContent !== undefined ? stringContent.text : pathNode.text.replace(/\"/g, '');\n\n if (path !== '') {\n imports.push({\n source: path,\n specifiers: [],\n isType: false\n });\n }\n }\n }\n\n return imports;\n } catch {\n return [];\n }\n }\n\n /**\n * Parse function declarations\n */\n private parseFunctions(tree: TreeSitterTree): CodeNode[] {\n const functionNodes = queryNodesByType(tree, 'function_declaration');\n const nodes: CodeNode[] = [];\n\n for (const fnNode of functionNodes) {\n const nameNode = getChildByFieldName(fnNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(fnNode.startPosition);\n const endLine = positionToLineNumber(fnNode.endPosition);\n const signature = getFunctionSignature(fnNode);\n\n nodes.push({\n type: 'function',\n name,\n exported,\n async: false,\n startLine,\n endLine,\n signature\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse struct definitions\n */\n private parseStructs(tree: TreeSitterTree): CodeNode[] {\n const typeDecls = queryNodesByType(tree, 'type_declaration');\n const nodes: CodeNode[] = [];\n\n for (const typeDecl of typeDecls) {\n // Get type_spec child node\n const typeSpec = getFirstChildOfType(typeDecl, 'type_spec');\n if (typeSpec === null) {\n continue;\n }\n\n const nameNode = getChildByFieldName(typeSpec, 'name');\n const typeNode = getChildByFieldName(typeSpec, 'type');\n\n if (nameNode === null || typeNode === null) {\n continue;\n }\n\n // Check if it's a struct type\n if (typeNode.type !== 'struct_type') {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(typeDecl.startPosition);\n const endLine = positionToLineNumber(typeDecl.endPosition);\n\n nodes.push({\n type: 'class',\n name,\n exported,\n startLine,\n endLine,\n signature: name,\n methods: []\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse interface definitions\n */\n private parseInterfaces(tree: TreeSitterTree): CodeNode[] {\n const typeDecls = queryNodesByType(tree, 'type_declaration');\n const nodes: CodeNode[] = [];\n\n for (const typeDecl of typeDecls) {\n const typeSpec = getFirstChildOfType(typeDecl, 'type_spec');\n if (typeSpec === null) {\n continue;\n }\n\n const nameNode = getChildByFieldName(typeSpec, 'name');\n const typeNode = getChildByFieldName(typeSpec, 'type');\n\n if (nameNode === null || typeNode === null) {\n continue;\n }\n\n // Check if it's an interface type\n if (typeNode.type !== 'interface_type') {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(typeDecl.startPosition);\n const endLine = positionToLineNumber(typeDecl.endPosition);\n\n // Extract interface methods\n const methods = this.extractInterfaceMethods(typeNode);\n\n nodes.push({\n type: 'interface',\n name,\n exported,\n startLine,\n endLine,\n signature: name,\n methods\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse type aliases\n */\n private parseTypeAliases(tree: TreeSitterTree): CodeNode[] {\n const typeDecls = queryNodesByType(tree, 'type_declaration');\n const nodes: CodeNode[] = [];\n\n for (const typeDecl of typeDecls) {\n const typeSpec = getFirstChildOfType(typeDecl, 'type_spec');\n if (typeSpec === null) {\n continue;\n }\n\n const nameNode = getChildByFieldName(typeSpec, 'name');\n const typeNode = getChildByFieldName(typeSpec, 'type');\n\n if (nameNode === null || typeNode === null) {\n continue;\n }\n\n // Skip struct and interface types (handled by other methods)\n if (typeNode.type === 'struct_type' || typeNode.type === 'interface_type') {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(typeDecl.startPosition);\n const endLine = positionToLineNumber(typeDecl.endPosition);\n const signature = `${name} = ${typeNode.text}`;\n\n nodes.push({\n type: 'type',\n name,\n exported,\n startLine,\n endLine,\n signature\n });\n }\n\n return nodes;\n }\n\n /**\n * Parse constants and variables\n */\n private parseConstants(tree: TreeSitterTree): CodeNode[] {\n const nodes: CodeNode[] = [];\n\n // Parse const declarations\n const constDecls = queryNodesByType(tree, 'const_declaration');\n for (const constDecl of constDecls) {\n const specs = constDecl.descendantsOfType('const_spec');\n for (const spec of specs) {\n const nameNode = getChildByFieldName(spec, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(spec.startPosition);\n const endLine = positionToLineNumber(spec.endPosition);\n\n const typeNode = getChildByFieldName(spec, 'type');\n const signature = typeNode !== null\n ? `${name}: ${typeNode.text}`\n : name;\n\n nodes.push({\n type: 'const',\n name,\n exported,\n startLine,\n endLine,\n signature\n });\n }\n }\n\n // Parse var declarations\n const varDecls = queryNodesByType(tree, 'var_declaration');\n for (const varDecl of varDecls) {\n const specs = varDecl.descendantsOfType('var_spec');\n for (const spec of specs) {\n const nameNode = getChildByFieldName(spec, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const exported = this.isExported(name);\n const startLine = positionToLineNumber(spec.startPosition);\n const endLine = positionToLineNumber(spec.endPosition);\n\n const typeNode = getChildByFieldName(spec, 'type');\n const signature = typeNode !== null\n ? `${name}: ${typeNode.text}`\n : name;\n\n nodes.push({\n type: 'const',\n name,\n exported,\n startLine,\n endLine,\n signature\n });\n }\n }\n\n return nodes;\n }\n\n /**\n * Parse methods and attach to corresponding structs\n */\n private parseMethods(tree: TreeSitterTree, nodes: CodeNode[]): void {\n const methodNodes = queryNodesByType(tree, 'method_declaration');\n\n for (const methodNode of methodNodes) {\n const receiverType = this.getReceiverType(methodNode);\n if (receiverType === null) {\n continue;\n }\n\n const nameNode = getChildByFieldName(methodNode, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const signature = getFunctionSignature(methodNode);\n const startLine = positionToLineNumber(methodNode.startPosition);\n const endLine = positionToLineNumber(methodNode.endPosition);\n\n // Find the corresponding struct and attach method\n const structNode = nodes.find(\n node => node.type === 'class' && node.name === receiverType\n );\n\n if (structNode !== undefined && structNode.methods !== undefined) {\n structNode.methods.push({\n name,\n async: false,\n signature,\n startLine,\n endLine\n });\n }\n }\n }\n\n /**\n * Extract methods from interface definition\n */\n private extractInterfaceMethods(interfaceNode: TreeSitterNode): Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> {\n const methods: Array<{\n name: string;\n async: boolean;\n signature: string;\n startLine: number;\n endLine: number;\n }> = [];\n\n const methodElems = interfaceNode.descendantsOfType('method_elem');\n\n for (const methodElem of methodElems) {\n const nameNode = getChildByFieldName(methodElem, 'name');\n if (nameNode === null) {\n continue;\n }\n\n const name = nameNode.text;\n const signature = getFunctionSignature(methodElem);\n const startLine = positionToLineNumber(methodElem.startPosition);\n const endLine = positionToLineNumber(methodElem.endPosition);\n\n methods.push({\n name,\n async: false,\n signature,\n startLine,\n endLine\n });\n }\n\n return methods;\n }\n\n /**\n * Get the receiver type name for a method\n */\n private getReceiverType(methodNode: TreeSitterNode): string | null {\n const receiverNode = getChildByFieldName(methodNode, 'receiver');\n if (receiverNode === null) {\n return null;\n }\n\n const paramDecl = getFirstChildOfType(receiverNode, 'parameter_declaration');\n if (paramDecl === null) {\n return null;\n }\n\n const typeNode = getChildByFieldName(paramDecl, 'type');\n if (typeNode === null) {\n return null;\n }\n\n // Handle pointer receivers (*Type)\n if (typeNode.type === 'pointer_type') {\n const innerType = typeNode.children.find(\n child => child.type === 'type_identifier'\n );\n return innerType !== undefined ? innerType.text : null;\n }\n\n // Handle value receivers (Type)\n if (typeNode.type === 'type_identifier') {\n return typeNode.text;\n }\n\n return null;\n }\n\n /**\n * Check if a name is exported (starts with uppercase letter)\n */\n private isExported(name: string): boolean {\n if (name.length === 0) {\n return false;\n }\n const firstChar = name[0];\n if (firstChar === undefined) {\n return false;\n }\n return firstChar === firstChar.toUpperCase();\n }\n}\n","import path from 'node:path';\nimport type { PythonBridge } from '../crawl/bridge.js';\nimport { ASTParser, type CodeNode } from './ast-parser.js';\nimport { PythonASTParser } from './python-ast-parser.js';\nimport { RustASTParser } from './rust-ast-parser.js';\nimport { GoASTParser } from './go-ast-parser.js';\n\nexport class ParserFactory {\n constructor(private readonly pythonBridge?: PythonBridge) {}\n\n async parseFile(filePath: string, code: string): Promise<CodeNode[]> {\n const ext = path.extname(filePath);\n\n if (['.ts', '.tsx'].includes(ext)) {\n const parser = new ASTParser();\n return parser.parse(code, 'typescript');\n }\n\n if (['.js', '.jsx'].includes(ext)) {\n const parser = new ASTParser();\n return parser.parse(code, 'javascript');\n }\n\n if (ext === '.py') {\n if (!this.pythonBridge) {\n throw new Error('Python bridge not available for parsing Python files');\n }\n const parser = new PythonASTParser(this.pythonBridge);\n return await parser.parse(code, filePath);\n }\n\n if (ext === '.rs') {\n const parser = new RustASTParser();\n return parser.parse(code, filePath);\n }\n\n if (ext === '.go') {\n const parser = new GoASTParser();\n return parser.parse(code, filePath);\n }\n\n return [];\n }\n}\n","import type { PythonBridge, ParsePythonResult } from '../crawl/bridge.js';\nimport type { CodeNode } from './ast-parser.js';\n\nexport class PythonASTParser {\n constructor(private readonly bridge: PythonBridge) {}\n\n async parse(code: string, filePath: string): Promise<CodeNode[]> {\n const result: ParsePythonResult = await this.bridge.parsePython(code, filePath);\n\n return result.nodes.map(node => {\n const codeNode: CodeNode = {\n type: node.type,\n name: node.name,\n exported: node.exported,\n startLine: node.startLine,\n endLine: node.endLine,\n };\n\n if (node.async !== undefined) {\n codeNode.async = node.async;\n }\n\n if (node.signature !== undefined) {\n codeNode.signature = node.signature;\n }\n\n if (node.methods !== undefined) {\n codeNode.methods = node.methods;\n }\n\n return codeNode;\n });\n }\n}\n","import * as lancedb from '@lancedb/lancedb';\nimport type { Table, Connection } from '@lancedb/lancedb';\nimport type { Document, DocumentMetadata } from '../types/document.js';\nimport type { StoreId, DocumentId } from '../types/brands.js';\nimport { createDocumentId } from '../types/brands.js';\n\ninterface LanceDocument {\n id: string;\n content: string;\n vector: number[];\n metadata: string; // JSON serialized\n [key: string]: unknown;\n}\n\ninterface SearchHit {\n id: string;\n content: string;\n metadata: string;\n _distance: number;\n}\n\nexport class LanceStore {\n private connection: Connection | null = null;\n private readonly tables: Map<string, Table> = new Map();\n private readonly dataDir: string;\n\n constructor(dataDir: string) {\n this.dataDir = dataDir;\n }\n\n async initialize(storeId: StoreId): Promise<void> {\n if (this.connection === null) {\n this.connection = await lancedb.connect(this.dataDir);\n }\n\n const tableName = this.getTableName(storeId);\n const tableNames = await this.connection.tableNames();\n\n if (!tableNames.includes(tableName)) {\n // Create table with initial schema\n const table = await this.connection.createTable(tableName, [\n {\n id: '__init__',\n content: '',\n vector: new Array(384).fill(0),\n metadata: '{}',\n },\n ]);\n // Delete the init row\n await table.delete('id = \"__init__\"');\n this.tables.set(tableName, table);\n } else {\n const table = await this.connection.openTable(tableName);\n this.tables.set(tableName, table);\n }\n }\n\n async addDocuments(storeId: StoreId, documents: Document[]): Promise<void> {\n const table = await this.getTable(storeId);\n const lanceDocuments: LanceDocument[] = documents.map((doc) => ({\n id: doc.id,\n content: doc.content,\n vector: [...doc.vector],\n metadata: JSON.stringify(doc.metadata),\n }));\n await table.add(lanceDocuments);\n }\n\n async deleteDocuments(storeId: StoreId, documentIds: DocumentId[]): Promise<void> {\n const table = await this.getTable(storeId);\n const idList = documentIds.map((id) => `\"${id}\"`).join(', ');\n await table.delete(`id IN (${idList})`);\n }\n\n async search(\n storeId: StoreId,\n vector: number[],\n limit: number,\n threshold?: number\n ): Promise<Array<{ id: DocumentId; content: string; score: number; metadata: DocumentMetadata }>> {\n const table = await this.getTable(storeId);\n let query = table.vectorSearch(vector).limit(limit);\n\n if (threshold !== undefined) {\n query = query.distanceType('cosine');\n }\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const results = (await query.toArray()) as SearchHit[];\n\n return results\n .filter((r) => {\n if (threshold === undefined) return true;\n const score = 1 - r._distance;\n return score >= threshold;\n })\n .map((r) => ({\n id: createDocumentId(r.id),\n content: r.content,\n score: 1 - r._distance,\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n metadata: JSON.parse(r.metadata) as DocumentMetadata,\n }));\n }\n\n async createFtsIndex(storeId: StoreId): Promise<void> {\n const table = await this.getTable(storeId);\n await table.createIndex('content', {\n config: lancedb.Index.fts(),\n });\n }\n\n async fullTextSearch(\n storeId: StoreId,\n query: string,\n limit: number\n ): Promise<Array<{ id: DocumentId; content: string; score: number; metadata: DocumentMetadata }>> {\n const table = await this.getTable(storeId);\n\n try {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const results = await table\n .search(query, 'fts')\n .limit(limit)\n .toArray() as Array<{ id: string; content: string; metadata: string; score: number }>;\n\n return results.map((r) => ({\n id: createDocumentId(r.id),\n content: r.content,\n score: r.score,\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n metadata: JSON.parse(r.metadata) as DocumentMetadata,\n }));\n } catch {\n // FTS index may not exist, return empty\n return [];\n }\n }\n\n async deleteStore(storeId: StoreId): Promise<void> {\n const tableName = this.getTableName(storeId);\n if (this.connection !== null) {\n await this.connection.dropTable(tableName);\n this.tables.delete(tableName);\n }\n }\n\n private getTableName(storeId: StoreId): string {\n return `documents_${storeId}`;\n }\n\n private async getTable(storeId: StoreId): Promise<Table> {\n const tableName = this.getTableName(storeId);\n let table = this.tables.get(tableName);\n if (table === undefined) {\n await this.initialize(storeId);\n table = this.tables.get(tableName);\n }\n if (table === undefined) {\n throw new Error(`Table not found for store: ${storeId}`);\n }\n return table;\n }\n}\n","import { pipeline, env, type FeatureExtractionPipeline } from '@huggingface/transformers';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\n// Set cache directory to ~/.cache/huggingface-transformers (outside node_modules)\n// This allows CI caching and prevents model re-downloads on each npm install\nenv.cacheDir = join(homedir(), '.cache', 'huggingface-transformers');\n\nexport class EmbeddingEngine {\n private extractor: FeatureExtractionPipeline | null = null;\n private readonly modelName: string;\n private readonly dimensions: number;\n\n constructor(modelName = 'Xenova/all-MiniLM-L6-v2', dimensions = 384) {\n this.modelName = modelName;\n this.dimensions = dimensions;\n }\n\n async initialize(): Promise<void> {\n if (this.extractor !== null) return;\n // @ts-expect-error TS2590: TypeScript can't represent the complex union type from pipeline()\n // This is a known limitation with @huggingface/transformers overloaded signatures\n this.extractor = await pipeline('feature-extraction', this.modelName, {\n dtype: 'fp32',\n });\n }\n\n async embed(text: string): Promise<number[]> {\n if (this.extractor === null) {\n await this.initialize();\n }\n if (this.extractor === null) {\n throw new Error('Failed to initialize embedding model');\n }\n const output = await this.extractor(text, {\n pooling: 'mean',\n normalize: true,\n });\n const result = Array.from(output.data);\n return result.map(v => Number(v));\n }\n\n async embedBatch(texts: string[]): Promise<number[][]> {\n const BATCH_SIZE = 32; // Process 32 chunks in parallel\n const results: number[][] = [];\n\n for (let i = 0; i < texts.length; i += BATCH_SIZE) {\n const batch = texts.slice(i, i + BATCH_SIZE);\n\n // Process batch in parallel using Promise.all\n const batchResults = await Promise.all(\n batch.map(text => this.embed(text))\n );\n\n results.push(...batchResults);\n\n // Small delay between batches to prevent memory issues\n if (i + BATCH_SIZE < texts.length) {\n await new Promise(resolve => setTimeout(resolve, 100));\n }\n }\n\n return results;\n }\n\n getDimensions(): number {\n return this.dimensions;\n }\n}\n","import { spawn, type ChildProcess } from 'node:child_process';\nimport { createInterface } from 'node:readline';\nimport { randomUUID } from 'node:crypto';\nimport { ZodError } from 'zod';\nimport {\n type CrawlResult,\n type HeadlessResult,\n type ParsePythonResult,\n type CrawledLink,\n validateCrawlResult,\n validateHeadlessResult,\n validateParsePythonResult,\n} from './schemas.js';\n\n// Re-export for backwards compatibility\nexport type { CrawledLink, ParsePythonResult };\n\ntype PendingResult = CrawlResult | HeadlessResult | ParsePythonResult;\n\ninterface PendingRequest {\n resolve: (v: PendingResult) => void;\n reject: (e: Error) => void;\n timeout: NodeJS.Timeout;\n method: 'crawl' | 'fetch_headless' | 'parse_python';\n}\n\nexport class PythonBridge {\n private process: ChildProcess | null = null;\n private readonly pending: Map<string, PendingRequest> = new Map();\n private stoppingIntentionally = false;\n\n start(): Promise<void> {\n if (this.process) return Promise.resolve();\n\n this.process = spawn('python3', ['python/crawl_worker.py'], {\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n // Add error handler for process spawn errors\n this.process.on('error', (err) => {\n console.error('Python bridge process error:', err);\n this.rejectAllPending(new Error(`Process error: ${err.message}`));\n });\n\n // Add exit handler to detect non-zero exits\n this.process.on('exit', (code, signal) => {\n if (code !== 0 && code !== null) {\n console.error(`Python bridge process exited with code ${String(code)}`);\n this.rejectAllPending(new Error(`Process exited with code ${String(code)}`));\n } else if (signal && !this.stoppingIntentionally) {\n // Only log if we didn't intentionally stop the process\n console.error(`Python bridge process killed with signal ${signal}`);\n this.rejectAllPending(new Error(`Process killed with signal ${signal}`));\n }\n this.process = null;\n this.stoppingIntentionally = false;\n });\n\n // Add stderr logging\n if (this.process.stderr) {\n const stderrRl = createInterface({ input: this.process.stderr });\n stderrRl.on('line', (line) => {\n console.error('Python bridge stderr:', line);\n });\n }\n\n if (this.process.stdout === null) {\n this.process = null; // Clean up partial state\n return Promise.reject(new Error('Python bridge process stdout is null'));\n }\n const rl = createInterface({ input: this.process.stdout });\n rl.on('line', (line) => {\n // Filter out non-JSON lines (crawl4ai verbose output)\n if (!line.trim().startsWith('{')) {\n return;\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n const response = JSON.parse(line) as {\n id: string;\n error?: { message: string };\n result?: PendingResult;\n };\n const pending = this.pending.get(response.id);\n if (pending !== undefined) {\n if (response.error !== undefined) {\n clearTimeout(pending.timeout);\n this.pending.delete(response.id);\n pending.reject(new Error(response.error.message));\n } else if (response.result !== undefined) {\n clearTimeout(pending.timeout);\n this.pending.delete(response.id);\n\n // Validate response structure based on method type\n try {\n let validated: PendingResult;\n if (pending.method === 'crawl') {\n validated = validateCrawlResult(response.result);\n } else if (pending.method === 'fetch_headless') {\n validated = validateHeadlessResult(response.result);\n } else {\n validated = validateParsePythonResult(response.result);\n }\n pending.resolve(validated);\n } catch (error: unknown) {\n // Log validation failure with original response for debugging\n if (error instanceof ZodError) {\n console.error('Python bridge response validation failed:', error.issues);\n console.error('Original response:', JSON.stringify(response.result));\n pending.reject(new Error(`Invalid response format from Python bridge: ${error.message}`));\n } else {\n const errorMessage = error instanceof Error ? error.message : String(error);\n pending.reject(new Error(`Response validation error: ${errorMessage}`));\n }\n }\n }\n // If neither result nor error, leave pending (will timeout)\n }\n } catch (err) {\n console.error('Failed to parse JSON response from Python bridge:', err, 'Line:', line);\n }\n });\n\n return Promise.resolve();\n }\n\n async crawl(url: string, timeoutMs: number = 30000): Promise<CrawlResult> {\n if (!this.process) await this.start();\n\n const id = randomUUID();\n const request = {\n jsonrpc: '2.0',\n id,\n method: 'crawl',\n params: { url },\n };\n\n return new Promise((resolve, reject) => {\n // Set up timeout\n const timeout = setTimeout(() => {\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n reject(new Error(`Crawl timeout after ${String(timeoutMs)}ms for URL: ${url}`));\n }\n }, timeoutMs);\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.pending.set(id, { resolve: resolve as (v: PendingResult) => void, reject, timeout, method: 'crawl' });\n if (this.process === null || this.process.stdin === null) {\n reject(new Error('Python bridge process not available'));\n return;\n }\n this.process.stdin.write(JSON.stringify(request) + '\\n');\n });\n }\n\n async fetchHeadless(url: string, timeoutMs: number = 60000): Promise<HeadlessResult> {\n if (!this.process) await this.start();\n\n const id = randomUUID();\n const request = {\n jsonrpc: '2.0',\n id,\n method: 'fetch_headless',\n params: { url },\n };\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n reject(new Error(`Headless fetch timeout after ${String(timeoutMs)}ms for URL: ${url}`));\n }\n }, timeoutMs);\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.pending.set(id, { resolve: resolve as (v: PendingResult) => void, reject, timeout, method: 'fetch_headless' });\n if (this.process === null || this.process.stdin === null) {\n reject(new Error('Python bridge process not available'));\n return;\n }\n this.process.stdin.write(JSON.stringify(request) + '\\n');\n });\n }\n\n async parsePython(code: string, filePath: string, timeoutMs: number = 10000): Promise<ParsePythonResult> {\n if (!this.process) await this.start();\n\n const id = randomUUID();\n const request = {\n jsonrpc: '2.0',\n id,\n method: 'parse_python',\n params: { code, filePath },\n };\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n const pending = this.pending.get(id);\n if (pending) {\n this.pending.delete(id);\n reject(new Error(`Python parsing timeout after ${String(timeoutMs)}ms for file: ${filePath}`));\n }\n }, timeoutMs);\n\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.pending.set(id, { resolve: resolve as (v: PendingResult) => void, reject, timeout, method: 'parse_python' });\n if (this.process === null || this.process.stdin === null) {\n reject(new Error('Python bridge process not available'));\n return;\n }\n this.process.stdin.write(JSON.stringify(request) + '\\n');\n });\n }\n\n stop(): Promise<void> {\n if (this.process) {\n this.stoppingIntentionally = true;\n this.rejectAllPending(new Error('Python bridge stopped'));\n this.process.kill();\n this.process = null;\n }\n return Promise.resolve();\n }\n\n private rejectAllPending(error: Error): void {\n for (const pending of this.pending.values()) {\n clearTimeout(pending.timeout);\n pending.reject(error);\n }\n this.pending.clear();\n }\n}\n","import { z } from 'zod';\n\n// Schema for crawl4ai link objects (matches CrawledLink interface)\n// This validates the actual runtime structure from Python\nexport const CrawledLinkSchema = z.object({\n href: z.string(),\n text: z.string(),\n title: z.string().optional(),\n base_domain: z.string().optional(),\n head_data: z.unknown().optional(),\n head_extraction_status: z.unknown().optional(),\n head_extraction_error: z.unknown().optional(),\n intrinsic_score: z.number().optional(),\n contextual_score: z.unknown().optional(),\n total_score: z.unknown().optional(),\n});\n\n// Schema for individual crawl page result\nconst CrawlPageSchema = z.object({\n url: z.string(),\n title: z.string(),\n content: z.string(),\n links: z.array(z.string()),\n crawledAt: z.string(),\n});\n\n// Schema for full crawl response\nexport const CrawlResultSchema = z.object({\n pages: z.array(CrawlPageSchema),\n});\n\n// Schema for headless fetch response\n// Supports both link objects and plain strings\nexport const HeadlessResultSchema = z.object({\n html: z.string(),\n markdown: z.string(),\n links: z.array(z.union([CrawledLinkSchema, z.string()])),\n});\n\n// Type exports derived from schemas (single source of truth)\nexport type CrawlResult = z.infer<typeof CrawlResultSchema>;\nexport type HeadlessResult = z.infer<typeof HeadlessResultSchema>;\nexport type CrawledLink = z.infer<typeof CrawledLinkSchema>;\n\n/**\n * Validates a headless fetch response from Python bridge.\n * Throws ZodError if the response doesn't match the expected schema.\n *\n * @param data - Raw data from Python bridge\n * @returns Validated HeadlessResult\n * @throws {z.ZodError} If validation fails\n */\nexport function validateHeadlessResult(data: unknown): HeadlessResult {\n return HeadlessResultSchema.parse(data);\n}\n\n/**\n * Validates a crawl response from Python bridge.\n * Throws ZodError if the response doesn't match the expected schema.\n *\n * @param data - Raw data from Python bridge\n * @returns Validated CrawlResult\n * @throws {z.ZodError} If validation fails\n */\nexport function validateCrawlResult(data: unknown): CrawlResult {\n return CrawlResultSchema.parse(data);\n}\n\n// Schema for Python AST parsing response\nconst MethodInfoSchema = z.object({\n name: z.string(),\n async: z.boolean(),\n signature: z.string(),\n startLine: z.number(),\n endLine: z.number(),\n calls: z.array(z.string()),\n});\n\nconst CodeNodeSchema = z.object({\n type: z.enum(['function', 'class']),\n name: z.string(),\n exported: z.boolean(),\n startLine: z.number(),\n endLine: z.number(),\n async: z.boolean().optional(),\n signature: z.string().optional(),\n calls: z.array(z.string()).optional(),\n methods: z.array(MethodInfoSchema).optional(),\n});\n\nconst ImportInfoSchema = z.object({\n source: z.string(),\n imported: z.string(),\n alias: z.string().optional().nullable(),\n});\n\nexport const ParsePythonResultSchema = z.object({\n nodes: z.array(CodeNodeSchema),\n imports: z.array(ImportInfoSchema),\n});\n\nexport type ParsePythonResult = z.infer<typeof ParsePythonResultSchema>;\n\n/**\n * Validates a Python AST parsing response from Python bridge.\n * Throws ZodError if the response doesn't match the expected schema.\n *\n * @param data - Raw data from Python bridge\n * @returns Validated ParsePythonResult\n * @throws {z.ZodError} If validation fails\n */\nexport function validateParsePythonResult(data: unknown): ParsePythonResult {\n return ParsePythonResultSchema.parse(data);\n}\n","import { ConfigService } from './config.service.js';\nimport { StoreService } from './store.service.js';\nimport { SearchService } from './search.service.js';\nimport { IndexService } from './index.service.js';\nimport { CodeGraphService } from './code-graph.service.js';\nimport { LanceStore } from '../db/lance.js';\nimport { EmbeddingEngine } from '../db/embeddings.js';\nimport { PythonBridge } from '../crawl/bridge.js';\n\nexport { ConfigService } from './config.service.js';\nexport { StoreService } from './store.service.js';\nexport { SearchService } from './search.service.js';\nexport { IndexService } from './index.service.js';\nexport { JobService } from './job.service.js';\nexport { WatchService } from './watch.service.js';\nexport { ChunkingService } from './chunking.service.js';\nexport { CodeGraphService } from './code-graph.service.js';\n\nexport interface ServiceContainer {\n config: ConfigService;\n store: StoreService;\n search: SearchService;\n index: IndexService;\n lance: LanceStore;\n embeddings: EmbeddingEngine;\n codeGraph: CodeGraphService;\n pythonBridge: PythonBridge;\n}\n\nexport async function createServices(\n configPath?: string,\n dataDir?: string,\n projectRoot?: string\n): Promise<ServiceContainer> {\n const config = new ConfigService(configPath, dataDir, projectRoot);\n const appConfig = await config.load();\n const resolvedDataDir = config.resolveDataDir();\n\n const lance = new LanceStore(resolvedDataDir);\n const embeddings = new EmbeddingEngine(\n appConfig.embedding.model,\n appConfig.embedding.dimensions\n );\n\n await embeddings.initialize();\n\n const store = new StoreService(resolvedDataDir);\n await store.initialize();\n\n const pythonBridge = new PythonBridge();\n await pythonBridge.start();\n\n const codeGraph = new CodeGraphService(resolvedDataDir, pythonBridge);\n const search = new SearchService(lance, embeddings, undefined, codeGraph);\n const index = new IndexService(lance, embeddings, { codeGraphService: codeGraph });\n\n return {\n config,\n store,\n search,\n index,\n lance,\n embeddings,\n codeGraph,\n pythonBridge,\n };\n}\n\n/**\n * Cleanly shut down all services, stopping background processes.\n * Call this after CLI commands complete to allow the process to exit.\n */\nexport async function destroyServices(services: ServiceContainer): Promise<void> {\n await services.pythonBridge.stop();\n}\n"],"mappings":";AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,kBAAkB;;;ACEpB,SAAS,GAAM,MAA2B;AAC/C,SAAO,EAAE,SAAS,MAAM,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,aAC2B;AAC3B,QAAM,SAAS,IAAI,cAAc,YAAY,SAAS,WAAW;AACjE,QAAM,YAAY,MAAM,OAAO,KAAK;AACpC,QAAM,kBAAkB,OAAO,eAAe;AAE9C,QAAM,QAAQ,IAAI,WAAW,eAAe;AAC5C,QAAM,aAAa,IAAI;AAAA,IACrB,UAAU,UAAU;AAAA,IACpB,UAAU,UAAU;AAAA,EACtB;AAEA,QAAM,WAAW,WAAW;AAE5B,QAAM,QAAQ,IAAI,aAAa,eAAe;AAC9C,QAAM,MAAM,WAAW;AAEvB,QAAM,eAAe,IAAI,aAAa;AACtC,QAAM,aAAa,MAAM;AAEzB,QAAM,YAAY,IAAI,iBAAiB,iBAAiB,YAAY;AACpE,QAAM,SAAS,IAAI,cAAc,OAAO,YAAY,QAAW,SAAS;AACxE,QAAM,QAAQ,IAAI,aAAa,OAAO,YAAY,EAAE,kBAAkB,UAAU,CAAC;AAEjF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAMA,eAAsB,gBAAgB,UAA2C;AAC/E,QAAM,SAAS,aAAa,KAAK;AACnC;","names":["dirname","path","dirname","path","readFile","writeFile","mkdir","join","resolve","randomUUID","mkdir","mkdir","resolve","mkdir","randomUUID","resolve","join","readFile","writeFile","t","path","readFile","join","readFile","join","readFile","writeFile","mkdir","join","dirname","path","path","path","path","path","mkdir","dirname","writeFile","readFile","join","homedir","join","resolve","spawn","randomUUID","spawn","err","randomUUID","resolve"]}
|