bluera-knowledge 0.13.3 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +14 -0
- package/commands/uninstall.md +65 -0
- package/dist/{chunk-AOSDVRRH.js → chunk-AIS5S77C.js} +2 -2
- package/dist/{chunk-XL2UHMBL.js → chunk-UAWKTJWN.js} +134 -15
- package/dist/chunk-UAWKTJWN.js.map +1 -0
- package/dist/{chunk-AJI5DCKY.js → chunk-Y24ZJRZP.js} +8 -3
- package/dist/{chunk-AJI5DCKY.js.map → chunk-Y24ZJRZP.js.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/hooks/check-dependencies.sh +46 -57
- package/package.json +12 -1
- package/.claude/commands/code-review.md +0 -15
- package/.claude/commands/commit.md +0 -34
- package/.claude/council-cache/1a43ed5977b8f29afc79a9bf5c4082ee5ad8338c42ab991a4241a48f80c1e46d.json +0 -7
- package/.claude/hooks/post-edit-check.sh +0 -40
- package/.claude/rules/code-quality.md +0 -12
- package/.claude/rules/git.md +0 -5
- package/.claude/rules/versioning.md +0 -7
- package/.claude/settings.local.json.example +0 -45
- package/.claude/skills/atomic-commits/SKILL.md +0 -61
- package/.claude/skills/code-review-repo/skill.md +0 -62
- package/.editorconfig +0 -15
- package/.env.example +0 -21
- package/.github/workflows/auto-release.yml +0 -64
- package/.github/workflows/ci.yml +0 -168
- package/.github/workflows/release.yml +0 -74
- package/.github/workflows/update-marketplace.yml +0 -96
- package/.husky/pre-commit +0 -48
- package/.husky/pre-push +0 -39
- package/.mcp.json +0 -11
- package/.prettierrc +0 -9
- package/.versionrc.json +0 -24
- package/CLAUDE.md +0 -110
- package/CONTRIBUTING.md +0 -307
- package/NOTICE +0 -47
- package/SECURITY.md +0 -65
- package/bun.lock +0 -2036
- package/dist/chunk-XL2UHMBL.js.map +0 -1
- package/docs/claude-code-best-practices.md +0 -458
- package/docs/cli.md +0 -170
- package/docs/commands.md +0 -392
- package/docs/crawler-architecture.md +0 -89
- package/docs/mcp-integration.md +0 -130
- package/docs/token-efficiency.md +0 -91
- package/eslint-rules/require-skip-comment.js +0 -81
- package/eslint.config.js +0 -103
- package/knip.json +0 -43
- package/scripts/test-mcp-dev.js +0 -260
- package/scripts/validate-npm-release.sh +0 -314
- package/src/analysis/adapter-registry.test.ts +0 -211
- package/src/analysis/adapter-registry.ts +0 -155
- package/src/analysis/ast-parser.test.ts +0 -470
- package/src/analysis/ast-parser.ts +0 -198
- package/src/analysis/code-graph.test.ts +0 -718
- package/src/analysis/code-graph.ts +0 -249
- package/src/analysis/dependency-usage-analyzer.test.ts +0 -619
- package/src/analysis/dependency-usage-analyzer.ts +0 -433
- package/src/analysis/go-ast-parser.test.ts +0 -531
- package/src/analysis/go-ast-parser.ts +0 -471
- package/src/analysis/language-adapter.ts +0 -127
- package/src/analysis/parser-factory.test.ts +0 -210
- package/src/analysis/parser-factory.ts +0 -52
- package/src/analysis/python-ast-parser.test.ts +0 -210
- package/src/analysis/python-ast-parser.ts +0 -34
- package/src/analysis/repo-url-resolver.test.ts +0 -533
- package/src/analysis/repo-url-resolver.ts +0 -233
- package/src/analysis/rust-ast-parser.test.ts +0 -568
- package/src/analysis/rust-ast-parser.ts +0 -467
- package/src/analysis/tree-sitter-parser.test.ts +0 -297
- package/src/analysis/tree-sitter-parser.ts +0 -217
- package/src/analysis/zil/index.ts +0 -34
- package/src/analysis/zil/zil-adapter.test.ts +0 -187
- package/src/analysis/zil/zil-adapter.ts +0 -121
- package/src/analysis/zil/zil-lexer.test.ts +0 -222
- package/src/analysis/zil/zil-lexer.ts +0 -239
- package/src/analysis/zil/zil-parser.test.ts +0 -210
- package/src/analysis/zil/zil-parser.ts +0 -360
- package/src/analysis/zil/zil-special-forms.ts +0 -193
- package/src/cli/commands/crawl.test.ts +0 -1086
- package/src/cli/commands/crawl.ts +0 -220
- package/src/cli/commands/index-cmd.test.ts +0 -733
- package/src/cli/commands/index-cmd.ts +0 -128
- package/src/cli/commands/mcp.test.ts +0 -218
- package/src/cli/commands/mcp.ts +0 -18
- package/src/cli/commands/plugin-api.test.ts +0 -373
- package/src/cli/commands/plugin-api.ts +0 -82
- package/src/cli/commands/search.test.ts +0 -1047
- package/src/cli/commands/search.ts +0 -197
- package/src/cli/commands/serve.test.ts +0 -371
- package/src/cli/commands/serve.ts +0 -43
- package/src/cli/commands/setup.test.ts +0 -895
- package/src/cli/commands/setup.ts +0 -176
- package/src/cli/commands/store.test.ts +0 -1370
- package/src/cli/commands/store.ts +0 -229
- package/src/cli/commands/sync.test.ts +0 -54
- package/src/cli/commands/sync.ts +0 -313
- package/src/cli/index.ts +0 -8
- package/src/cli/program.ts +0 -59
- package/src/crawl/article-converter.test.ts +0 -576
- package/src/crawl/article-converter.ts +0 -142
- package/src/crawl/bridge.test.ts +0 -796
- package/src/crawl/bridge.ts +0 -339
- package/src/crawl/claude-client.test.ts +0 -902
- package/src/crawl/claude-client.ts +0 -261
- package/src/crawl/intelligent-crawler.test.ts +0 -1028
- package/src/crawl/intelligent-crawler.ts +0 -478
- package/src/crawl/markdown-utils.test.ts +0 -703
- package/src/crawl/markdown-utils.ts +0 -225
- package/src/crawl/schemas.ts +0 -114
- package/src/db/embeddings.test.ts +0 -79
- package/src/db/embeddings.ts +0 -78
- package/src/db/index.ts +0 -2
- package/src/db/lance.test.ts +0 -479
- package/src/db/lance.ts +0 -190
- package/src/defaults/repos.ts +0 -67
- package/src/index.ts +0 -124
- package/src/logging/index.ts +0 -25
- package/src/logging/logger.test.ts +0 -75
- package/src/logging/logger.ts +0 -145
- package/src/logging/payload.test.ts +0 -152
- package/src/logging/payload.ts +0 -119
- package/src/mcp/cache.test.ts +0 -202
- package/src/mcp/cache.ts +0 -103
- package/src/mcp/commands/index.ts +0 -22
- package/src/mcp/commands/job.commands.ts +0 -48
- package/src/mcp/commands/meta.commands.ts +0 -54
- package/src/mcp/commands/registry.ts +0 -180
- package/src/mcp/commands/store.commands.ts +0 -75
- package/src/mcp/commands/sync.commands.test.ts +0 -371
- package/src/mcp/commands/sync.commands.ts +0 -263
- package/src/mcp/handlers/execute.handler.test.ts +0 -179
- package/src/mcp/handlers/execute.handler.ts +0 -23
- package/src/mcp/handlers/index.ts +0 -39
- package/src/mcp/handlers/job.handler.test.ts +0 -189
- package/src/mcp/handlers/job.handler.ts +0 -118
- package/src/mcp/handlers/search.handler.test.ts +0 -324
- package/src/mcp/handlers/search.handler.ts +0 -287
- package/src/mcp/handlers/store.handler.test.ts +0 -408
- package/src/mcp/handlers/store.handler.ts +0 -318
- package/src/mcp/plugin-mcp-config.test.ts +0 -71
- package/src/mcp/schemas/index.test.ts +0 -356
- package/src/mcp/schemas/index.ts +0 -155
- package/src/mcp/server.test.ts +0 -91
- package/src/mcp/server.ts +0 -235
- package/src/mcp/types.ts +0 -41
- package/src/plugin/commands.test.ts +0 -925
- package/src/plugin/commands.ts +0 -311
- package/src/plugin/dependency-analyzer.test.ts +0 -380
- package/src/plugin/dependency-analyzer.ts +0 -210
- package/src/plugin/git-clone.test.ts +0 -387
- package/src/plugin/git-clone.ts +0 -57
- package/src/scripts/validate-npm-release.test.ts +0 -70
- package/src/server/app.test.ts +0 -752
- package/src/server/app.ts +0 -128
- package/src/server/index.test.ts +0 -475
- package/src/server/index.ts +0 -1
- package/src/services/chunking.service.test.ts +0 -363
- package/src/services/chunking.service.ts +0 -380
- package/src/services/code-graph.service.test.ts +0 -298
- package/src/services/code-graph.service.ts +0 -326
- package/src/services/code-unit.service.test.ts +0 -693
- package/src/services/code-unit.service.ts +0 -234
- package/src/services/config.service.test.ts +0 -146
- package/src/services/config.service.ts +0 -92
- package/src/services/gitignore.service.test.ts +0 -157
- package/src/services/gitignore.service.ts +0 -132
- package/src/services/index.service.test.ts +0 -2301
- package/src/services/index.service.ts +0 -442
- package/src/services/index.ts +0 -119
- package/src/services/job.service.test.ts +0 -531
- package/src/services/job.service.ts +0 -298
- package/src/services/project-root.service.test.ts +0 -504
- package/src/services/project-root.service.ts +0 -112
- package/src/services/search.service.test.ts +0 -2263
- package/src/services/search.service.ts +0 -1341
- package/src/services/services.test.ts +0 -108
- package/src/services/snippet.service.test.ts +0 -213
- package/src/services/snippet.service.ts +0 -193
- package/src/services/store-definition.service.test.ts +0 -440
- package/src/services/store-definition.service.ts +0 -198
- package/src/services/store.service.test.ts +0 -843
- package/src/services/store.service.ts +0 -363
- package/src/services/token.service.test.ts +0 -45
- package/src/services/token.service.ts +0 -33
- package/src/services/watch.service.test.ts +0 -600
- package/src/services/watch.service.ts +0 -84
- package/src/types/brands.test.ts +0 -47
- package/src/types/brands.ts +0 -32
- package/src/types/config.ts +0 -79
- package/src/types/document.ts +0 -54
- package/src/types/index.ts +0 -73
- package/src/types/job.ts +0 -61
- package/src/types/progress.ts +0 -9
- package/src/types/result.test.ts +0 -54
- package/src/types/result.ts +0 -41
- package/src/types/search.ts +0 -105
- package/src/types/store-definition.test.ts +0 -492
- package/src/types/store-definition.ts +0 -129
- package/src/types/store.test.ts +0 -69
- package/src/types/store.ts +0 -47
- package/src/utils/type-guards.test.ts +0 -351
- package/src/utils/type-guards.ts +0 -61
- package/src/workers/background-worker-cli.test.ts +0 -35
- package/src/workers/background-worker-cli.ts +0 -149
- package/src/workers/background-worker.test.ts +0 -222
- package/src/workers/background-worker.ts +0 -322
- package/src/workers/pid-file.test.ts +0 -167
- package/src/workers/pid-file.ts +0 -82
- package/src/workers/spawn-worker.test.ts +0 -194
- package/src/workers/spawn-worker.ts +0 -70
- package/tests/analysis/ast-parser.test.ts +0 -98
- package/tests/analysis/code-graph.test.ts +0 -60
- package/tests/fixtures/README.md +0 -114
- package/tests/fixtures/code-snippets/api/error-handling.ts +0 -256
- package/tests/fixtures/code-snippets/api/rest-controller.ts +0 -297
- package/tests/fixtures/code-snippets/auth/jwt-auth.ts +0 -197
- package/tests/fixtures/code-snippets/auth/oauth-flow.ts +0 -245
- package/tests/fixtures/code-snippets/database/repository-pattern.ts +0 -280
- package/tests/fixtures/corpus/VERSION.md +0 -25
- package/tests/fixtures/corpus/articles/jwt-authentication.md +0 -97
- package/tests/fixtures/corpus/articles/react-hooks-patterns.md +0 -127
- package/tests/fixtures/corpus/articles/typescript-generics.md +0 -111
- package/tests/fixtures/corpus/documentation/express-middleware.md +0 -71
- package/tests/fixtures/corpus/documentation/express-routing.md +0 -83
- package/tests/fixtures/corpus/documentation/node-streams.md +0 -78
- package/tests/fixtures/corpus/oss-repos/express/History.md +0 -3871
- package/tests/fixtures/corpus/oss-repos/express/LICENSE +0 -24
- package/tests/fixtures/corpus/oss-repos/express/README.md +0 -276
- package/tests/fixtures/corpus/oss-repos/express/SECURITY.md +0 -56
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/Makefile +0 -17
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/README.md +0 -34
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/middleware.js +0 -20
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/run +0 -18
- package/tests/fixtures/corpus/oss-repos/express/examples/README.md +0 -29
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/index.js +0 -134
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/foot.ejs +0 -2
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/head.ejs +0 -20
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/login.ejs +0 -21
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/db.js +0 -9
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/index.js +0 -46
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/users.js +0 -19
- package/tests/fixtures/corpus/oss-repos/express/examples/cookie-sessions/index.js +0 -25
- package/tests/fixtures/corpus/oss-repos/express/examples/cookies/index.js +0 -53
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/CCTV/345/244/247/350/265/233/344/270/212/346/265/267/345/210/206/350/265/233/345/214/272.txt +0 -2
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/amazing.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/notes/groceries.txt +0 -3
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/index.js +0 -40
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/index.js +0 -57
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/public/stylesheets/style.css +0 -4
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/footer.html +0 -2
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/header.html +0 -9
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/users.html +0 -10
- package/tests/fixtures/corpus/oss-repos/express/examples/error/index.js +0 -53
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/index.js +0 -103
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/404.ejs +0 -3
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/500.ejs +0 -8
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/error_header.ejs +0 -10
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/footer.ejs +0 -2
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/index.ejs +0 -20
- package/tests/fixtures/corpus/oss-repos/express/examples/hello-world/index.js +0 -15
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/index.js +0 -44
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/views/index.md +0 -4
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v1.js +0 -15
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v2.js +0 -15
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/index.js +0 -18
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/main/index.js +0 -5
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/index.js +0 -31
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/edit.ejs +0 -17
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/show.ejs +0 -15
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/index.js +0 -41
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/edit.hbs +0 -27
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/list.hbs +0 -18
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/show.hbs +0 -31
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user-pet/index.js +0 -22
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/db.js +0 -16
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/index.js +0 -95
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/lib/boot.js +0 -83
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/public/style.css +0 -14
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/404.ejs +0 -13
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/5xx.ejs +0 -13
- package/tests/fixtures/corpus/oss-repos/express/examples/online/index.js +0 -61
- package/tests/fixtures/corpus/oss-repos/express/examples/params/index.js +0 -74
- package/tests/fixtures/corpus/oss-repos/express/examples/resource/index.js +0 -95
- package/tests/fixtures/corpus/oss-repos/express/examples/route-map/index.js +0 -75
- package/tests/fixtures/corpus/oss-repos/express/examples/route-middleware/index.js +0 -90
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/index.js +0 -55
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/post.js +0 -13
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/public/style.css +0 -24
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/site.js +0 -5
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/user.js +0 -47
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/footer.ejs +0 -2
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/header.ejs +0 -9
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/index.ejs +0 -10
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/posts/index.ejs +0 -12
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/edit.ejs +0 -23
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/index.ejs +0 -14
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/view.ejs +0 -9
- package/tests/fixtures/corpus/oss-repos/express/examples/search/index.js +0 -61
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/client.js +0 -15
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/index.html +0 -21
- package/tests/fixtures/corpus/oss-repos/express/examples/session/index.js +0 -37
- package/tests/fixtures/corpus/oss-repos/express/examples/session/redis.js +0 -39
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/index.js +0 -43
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/css/style.css +0 -3
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/hello.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/js/app.js +0 -1
- package/tests/fixtures/corpus/oss-repos/express/examples/vhost/index.js +0 -53
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/github-view.js +0 -53
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/index.js +0 -48
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/index.js +0 -155
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/user.js +0 -36
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/views/index.ejs +0 -20
- package/tests/fixtures/corpus/oss-repos/express/examples/web-service/index.js +0 -117
- package/tests/fixtures/corpus/oss-repos/express/index.js +0 -11
- package/tests/fixtures/corpus/oss-repos/express/lib/application.js +0 -631
- package/tests/fixtures/corpus/oss-repos/express/lib/express.js +0 -81
- package/tests/fixtures/corpus/oss-repos/express/lib/request.js +0 -514
- package/tests/fixtures/corpus/oss-repos/express/lib/response.js +0 -1053
- package/tests/fixtures/corpus/oss-repos/express/lib/utils.js +0 -271
- package/tests/fixtures/corpus/oss-repos/express/lib/view.js +0 -205
- package/tests/fixtures/corpus/oss-repos/express/package.json +0 -99
- package/tests/fixtures/corpus/oss-repos/express/test/Route.js +0 -274
- package/tests/fixtures/corpus/oss-repos/express/test/Router.js +0 -636
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/auth.js +0 -117
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/content-negotiation.js +0 -49
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookie-sessions.js +0 -38
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookies.js +0 -71
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/downloads.js +0 -47
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/ejs.js +0 -17
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error-pages.js +0 -99
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error.js +0 -29
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/hello-world.js +0 -21
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/markdown.js +0 -21
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/multi-router.js +0 -44
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/mvc.js +0 -132
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/params.js +0 -44
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/resource.js +0 -68
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-map.js +0 -45
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-separation.js +0 -97
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/vhost.js +0 -46
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/web-service.js +0 -105
- package/tests/fixtures/corpus/oss-repos/express/test/app.all.js +0 -38
- package/tests/fixtures/corpus/oss-repos/express/test/app.engine.js +0 -83
- package/tests/fixtures/corpus/oss-repos/express/test/app.head.js +0 -66
- package/tests/fixtures/corpus/oss-repos/express/test/app.js +0 -120
- package/tests/fixtures/corpus/oss-repos/express/test/app.listen.js +0 -55
- package/tests/fixtures/corpus/oss-repos/express/test/app.locals.js +0 -26
- package/tests/fixtures/corpus/oss-repos/express/test/app.options.js +0 -116
- package/tests/fixtures/corpus/oss-repos/express/test/app.param.js +0 -323
- package/tests/fixtures/corpus/oss-repos/express/test/app.render.js +0 -374
- package/tests/fixtures/corpus/oss-repos/express/test/app.request.js +0 -143
- package/tests/fixtures/corpus/oss-repos/express/test/app.response.js +0 -143
- package/tests/fixtures/corpus/oss-repos/express/test/app.route.js +0 -197
- package/tests/fixtures/corpus/oss-repos/express/test/app.router.js +0 -1217
- package/tests/fixtures/corpus/oss-repos/express/test/app.routes.error.js +0 -62
- package/tests/fixtures/corpus/oss-repos/express/test/app.use.js +0 -542
- package/tests/fixtures/corpus/oss-repos/express/test/config.js +0 -207
- package/tests/fixtures/corpus/oss-repos/express/test/exports.js +0 -82
- package/tests/fixtures/corpus/oss-repos/express/test/express.json.js +0 -755
- package/tests/fixtures/corpus/oss-repos/express/test/express.raw.js +0 -513
- package/tests/fixtures/corpus/oss-repos/express/test/express.static.js +0 -815
- package/tests/fixtures/corpus/oss-repos/express/test/express.text.js +0 -566
- package/tests/fixtures/corpus/oss-repos/express/test/express.urlencoded.js +0 -828
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/% of dogs.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/.name +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/index.html +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/post/index.tmpl +0 -1
- 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 +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/user.tmpl +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/email.tmpl +0 -1
- 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 +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.tmpl +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/nums.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/pets/names.txt +0 -1
- 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 +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.html +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.tmpl +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/index.html +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/tobi.txt +0 -1
- package/tests/fixtures/corpus/oss-repos/express/test/middleware.basic.js +0 -42
- package/tests/fixtures/corpus/oss-repos/express/test/regression.js +0 -20
- package/tests/fixtures/corpus/oss-repos/express/test/req.accepts.js +0 -125
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsCharsets.js +0 -50
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsEncodings.js +0 -39
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsLanguages.js +0 -57
- package/tests/fixtures/corpus/oss-repos/express/test/req.baseUrl.js +0 -88
- package/tests/fixtures/corpus/oss-repos/express/test/req.fresh.js +0 -70
- package/tests/fixtures/corpus/oss-repos/express/test/req.get.js +0 -60
- package/tests/fixtures/corpus/oss-repos/express/test/req.host.js +0 -156
- package/tests/fixtures/corpus/oss-repos/express/test/req.hostname.js +0 -188
- package/tests/fixtures/corpus/oss-repos/express/test/req.ip.js +0 -113
- package/tests/fixtures/corpus/oss-repos/express/test/req.ips.js +0 -71
- package/tests/fixtures/corpus/oss-repos/express/test/req.is.js +0 -169
- package/tests/fixtures/corpus/oss-repos/express/test/req.path.js +0 -20
- package/tests/fixtures/corpus/oss-repos/express/test/req.protocol.js +0 -113
- package/tests/fixtures/corpus/oss-repos/express/test/req.query.js +0 -106
- package/tests/fixtures/corpus/oss-repos/express/test/req.range.js +0 -104
- package/tests/fixtures/corpus/oss-repos/express/test/req.route.js +0 -28
- package/tests/fixtures/corpus/oss-repos/express/test/req.secure.js +0 -101
- package/tests/fixtures/corpus/oss-repos/express/test/req.signedCookies.js +0 -37
- package/tests/fixtures/corpus/oss-repos/express/test/req.stale.js +0 -50
- package/tests/fixtures/corpus/oss-repos/express/test/req.subdomains.js +0 -173
- package/tests/fixtures/corpus/oss-repos/express/test/req.xhr.js +0 -42
- package/tests/fixtures/corpus/oss-repos/express/test/res.append.js +0 -116
- package/tests/fixtures/corpus/oss-repos/express/test/res.attachment.js +0 -79
- package/tests/fixtures/corpus/oss-repos/express/test/res.clearCookie.js +0 -62
- package/tests/fixtures/corpus/oss-repos/express/test/res.cookie.js +0 -295
- package/tests/fixtures/corpus/oss-repos/express/test/res.download.js +0 -487
- package/tests/fixtures/corpus/oss-repos/express/test/res.format.js +0 -248
- package/tests/fixtures/corpus/oss-repos/express/test/res.get.js +0 -21
- package/tests/fixtures/corpus/oss-repos/express/test/res.json.js +0 -186
- package/tests/fixtures/corpus/oss-repos/express/test/res.jsonp.js +0 -344
- package/tests/fixtures/corpus/oss-repos/express/test/res.links.js +0 -65
- package/tests/fixtures/corpus/oss-repos/express/test/res.locals.js +0 -40
- package/tests/fixtures/corpus/oss-repos/express/test/res.location.js +0 -316
- package/tests/fixtures/corpus/oss-repos/express/test/res.redirect.js +0 -214
- package/tests/fixtures/corpus/oss-repos/express/test/res.render.js +0 -367
- package/tests/fixtures/corpus/oss-repos/express/test/res.send.js +0 -569
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendFile.js +0 -913
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendStatus.js +0 -44
- package/tests/fixtures/corpus/oss-repos/express/test/res.set.js +0 -124
- package/tests/fixtures/corpus/oss-repos/express/test/res.status.js +0 -206
- package/tests/fixtures/corpus/oss-repos/express/test/res.type.js +0 -46
- package/tests/fixtures/corpus/oss-repos/express/test/res.vary.js +0 -90
- package/tests/fixtures/corpus/oss-repos/express/test/support/env.js +0 -3
- package/tests/fixtures/corpus/oss-repos/express/test/support/tmpl.js +0 -36
- package/tests/fixtures/corpus/oss-repos/express/test/support/utils.js +0 -86
- package/tests/fixtures/corpus/oss-repos/express/test/utils.js +0 -83
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/Dockerfile +0 -11
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/devcontainer.json +0 -21
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/docker-compose.yml +0 -18
- package/tests/fixtures/corpus/oss-repos/hono/.eslintignore +0 -1
- package/tests/fixtures/corpus/oss-repos/hono/.eslintrc.cjs +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/.gitpod.yml +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/.prettierrc +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-default.ts +0 -15
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-dom.ts +0 -15
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/setup-vitest.ts +0 -47
- package/tests/fixtures/corpus/oss-repos/hono/LICENSE +0 -21
- package/tests/fixtures/corpus/oss-repos/hono/README.md +0 -91
- package/tests/fixtures/corpus/oss-repos/hono/build.ts +0 -80
- package/tests/fixtures/corpus/oss-repos/hono/bun.lockb +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/bunfig.toml +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/codecov.yml +0 -13
- package/tests/fixtures/corpus/oss-repos/hono/docs/CODE_OF_CONDUCT.md +0 -128
- package/tests/fixtures/corpus/oss-repos/hono/docs/CONTRIBUTING.md +0 -62
- package/tests/fixtures/corpus/oss-repos/hono/docs/MIGRATION.md +0 -295
- 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 +0 -6
- 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 +0 -119
- package/tests/fixtures/corpus/oss-repos/hono/package.cjs.json +0 -3
- package/tests/fixtures/corpus/oss-repos/hono/package.json +0 -650
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +0 -492
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/index.ts +0 -13
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/types.ts +0 -144
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/conninfo.ts +0 -28
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/index.ts +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/serve-static.ts +0 -35
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/server.ts +0 -30
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/ssg.ts +0 -27
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/websocket.ts +0 -110
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +0 -120
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/index.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/conninfo.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/index.ts +0 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static-module.ts +0 -12
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +0 -39
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/utils.ts +0 -50
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/websocket.ts +0 -50
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/conninfo.ts +0 -17
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/deno.d.ts +0 -28
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/index.ts +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/serve-static.ts +0 -40
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/ssg.ts +0 -27
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/websocket.ts +0 -51
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/conninfo.ts +0 -15
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/handler.ts +0 -189
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/index.ts +0 -14
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/handler.ts +0 -10
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/mod.ts +0 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/handler.ts +0 -34
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/index.ts +0 -5
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/types.ts +0 -14
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/conninfo.ts +0 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/handler.ts +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/index.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +0 -214
- package/tests/fixtures/corpus/oss-repos/hono/src/client/index.ts +0 -14
- package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +0 -182
- package/tests/fixtures/corpus/oss-repos/hono/src/client/utils.ts +0 -54
- package/tests/fixtures/corpus/oss-repos/hono/src/compose.ts +0 -94
- package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +0 -917
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +0 -84
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +0 -85
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/types.ts +0 -45
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/cookie/index.ts +0 -130
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/common.ts +0 -243
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +0 -220
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/dev/index.ts +0 -79
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +0 -246
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/html/index.ts +0 -56
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/index.ts +0 -13
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/middleware.ts +0 -79
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +0 -388
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/utils.ts +0 -71
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/index.ts +0 -9
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/sse.ts +0 -89
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/stream.ts +0 -36
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/text.ts +0 -15
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/testing/index.ts +0 -26
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/websocket/index.ts +0 -57
- package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +0 -523
- package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +0 -34
- package/tests/fixtures/corpus/oss-repos/hono/src/http-exception.ts +0 -78
- package/tests/fixtures/corpus/oss-repos/hono/src/index.ts +0 -51
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/base.ts +0 -419
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/children.ts +0 -20
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/components.ts +0 -195
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/constants.ts +0 -5
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/context.ts +0 -50
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/client.ts +0 -89
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/components.ts +0 -39
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/context.ts +0 -52
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +0 -246
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/hooks/index.ts +0 -91
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/index.ts +0 -159
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +0 -398
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-dev-runtime.ts +0 -22
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-runtime.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +0 -772
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/server.ts +0 -70
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/utils.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +0 -426
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/index.ts +0 -114
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/common.ts +0 -11
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +0 -196
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-elements.ts +0 -924
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-dev-runtime.ts +0 -26
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-runtime.ts +0 -18
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/streaming.ts +0 -184
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/types.ts +0 -41
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +0 -36
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/basic-auth/index.ts +0 -128
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/bearer-auth/index.ts +0 -159
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/body-limit/index.ts +0 -115
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cache/index.ts +0 -127
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/combine/index.ts +0 -153
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/compress/index.ts +0 -79
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/context-storage/index.ts +0 -55
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cors/index.ts +0 -141
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/csrf/index.ts +0 -90
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/etag/index.ts +0 -88
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/ip-restriction/index.ts +0 -178
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +0 -158
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/index.ts +0 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/jwt.ts +0 -159
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/logger/index.ts +0 -93
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/method-override/index.ts +0 -146
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/powered-by/index.ts +0 -13
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/pretty-json/index.ts +0 -50
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/index.ts +0 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/request-id.ts +0 -59
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/index.ts +0 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/permissions-policy.ts +0 -86
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/secure-headers.ts +0 -319
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +0 -140
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timeout/index.ts +0 -58
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/index.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/timing.ts +0 -225
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/trailing-slash/index.ts +0 -71
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +0 -24
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +0 -20
- package/tests/fixtures/corpus/oss-repos/hono/src/request.ts +0 -403
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/router.ts +0 -132
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +0 -54
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +0 -159
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +0 -274
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/trie.ts +0 -74
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/router.ts +0 -69
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/index.ts +0 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +0 -205
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/router.ts +0 -28
- package/tests/fixtures/corpus/oss-repos/hono/src/router.ts +0 -103
- package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +0 -2006
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/basic-auth.ts +0 -26
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +0 -225
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/buffer.ts +0 -65
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +0 -26
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/concurrent.ts +0 -55
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +0 -230
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/crypto.ts +0 -65
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +0 -34
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/filepath.ts +0 -56
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/handler.ts +0 -15
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/html.ts +0 -182
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/http-status.ts +0 -69
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/ipaddr.ts +0 -113
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/index.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwa.ts +0 -23
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jws.ts +0 -226
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwt.ts +0 -114
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/types.ts +0 -83
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/utf8.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/mime.ts +0 -142
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/stream.ts +0 -96
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +0 -102
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/url.ts +0 -310
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/index.ts +0 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +0 -151
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.build.json +0 -23
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.json +0 -28
- package/tests/fixtures/corpus/oss-repos/hono/vitest.config.ts +0 -34
- package/tests/fixtures/corpus/oss-repos/hono/yarn.lock +0 -6232
- package/tests/fixtures/documentation/api-reference.md +0 -412
- package/tests/fixtures/documentation/architecture.md +0 -214
- package/tests/fixtures/documentation/deployment-guide.md +0 -420
- package/tests/fixtures/github-readmes/express.md +0 -133
- package/tests/fixtures/github-readmes/nextjs.md +0 -106
- package/tests/fixtures/github-readmes/react.md +0 -74
- package/tests/fixtures/github-readmes/typescript.md +0 -93
- package/tests/fixtures/github-readmes/vite.md +0 -79
- package/tests/fixtures/queries/core.json +0 -125
- package/tests/fixtures/queries/extended.json +0 -427
- package/tests/fixtures/queries/generated/.gitkeep +0 -0
- package/tests/fixtures/test-server.ts +0 -268
- package/tests/helpers/performance-metrics.ts +0 -370
- package/tests/helpers/search-relevance.ts +0 -326
- package/tests/integration/cli-consistency.test.ts +0 -298
- package/tests/integration/cli.test.ts +0 -69
- package/tests/integration/e2e-workflow.test.ts +0 -614
- package/tests/integration/mcp.test.ts +0 -250
- package/tests/integration/python-bridge.test.ts +0 -193
- package/tests/integration/search-quality.test.ts +0 -720
- package/tests/integration/serve.test.ts +0 -260
- package/tests/integration/stress.test.ts +0 -326
- package/tests/mcp/server.test.ts +0 -15
- package/tests/scripts/schemas/evaluation.json +0 -44
- package/tests/scripts/schemas/query-generation.json +0 -21
- package/tests/services/code-unit.service.test.ts +0 -95
- package/tests/services/job.service.test.ts +0 -124
- package/tests/services/search.progressive-context.test.ts +0 -35
- package/tsconfig.json +0 -34
- package/tsup.config.ts +0 -15
- package/turndown-plugin-gfm.d.ts +0 -29
- package/vitest.config.ts +0 -90
- /package/dist/{chunk-AOSDVRRH.js.map → chunk-AIS5S77C.js.map} +0 -0
|
@@ -1,2301 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeAll, afterAll, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { IndexService, classifyWebContentType } from './index.service.js';
|
|
3
|
-
import { LanceStore } from '../db/lance.js';
|
|
4
|
-
import { EmbeddingEngine } from '../db/embeddings.js';
|
|
5
|
-
import { createStoreId } from '../types/brands.js';
|
|
6
|
-
import { rm, mkdtemp, writeFile, mkdir, symlink, chmod } from 'node:fs/promises';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import type { FileStore } from '../types/store.js';
|
|
10
|
-
import type { CodeGraphService } from './code-graph.service.js';
|
|
11
|
-
|
|
12
|
-
describe('IndexService', () => {
|
|
13
|
-
let indexService: IndexService;
|
|
14
|
-
let lanceStore: LanceStore;
|
|
15
|
-
let embeddingEngine: EmbeddingEngine;
|
|
16
|
-
let tempDir: string;
|
|
17
|
-
let testFilesDir: string;
|
|
18
|
-
const storeId = createStoreId('test-store');
|
|
19
|
-
|
|
20
|
-
beforeAll(async () => {
|
|
21
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-test-'));
|
|
22
|
-
testFilesDir = join(tempDir, 'files');
|
|
23
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
24
|
-
|
|
25
|
-
// Create test files
|
|
26
|
-
await writeFile(join(testFilesDir, 'test1.txt'), 'Hello world, this is a test file.');
|
|
27
|
-
await writeFile(join(testFilesDir, 'test2.md'), '# Heading\n\nSome markdown content here.');
|
|
28
|
-
|
|
29
|
-
lanceStore = new LanceStore(tempDir);
|
|
30
|
-
embeddingEngine = new EmbeddingEngine();
|
|
31
|
-
|
|
32
|
-
await embeddingEngine.initialize();
|
|
33
|
-
await lanceStore.initialize(storeId);
|
|
34
|
-
|
|
35
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
36
|
-
}, 120000);
|
|
37
|
-
|
|
38
|
-
afterAll(async () => {
|
|
39
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('indexes a file store', async () => {
|
|
43
|
-
const store: FileStore = {
|
|
44
|
-
type: 'file',
|
|
45
|
-
id: storeId,
|
|
46
|
-
name: 'Test Store',
|
|
47
|
-
path: testFilesDir,
|
|
48
|
-
createdAt: new Date(),
|
|
49
|
-
updatedAt: new Date(),
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const result = await indexService.indexStore(store);
|
|
53
|
-
|
|
54
|
-
expect(result.success).toBe(true);
|
|
55
|
-
if (result.success) {
|
|
56
|
-
expect(result.data.documentsIndexed).toBeGreaterThan(0);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('chunks large files', async () => {
|
|
61
|
-
// Create a large test file
|
|
62
|
-
const largeContent = 'This is test content. '.repeat(100); // ~2200 chars
|
|
63
|
-
await writeFile(join(testFilesDir, 'large.txt'), largeContent);
|
|
64
|
-
|
|
65
|
-
const store: FileStore = {
|
|
66
|
-
type: 'file',
|
|
67
|
-
id: storeId,
|
|
68
|
-
name: 'Test Store',
|
|
69
|
-
path: testFilesDir,
|
|
70
|
-
createdAt: new Date(),
|
|
71
|
-
updatedAt: new Date(),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const result = await indexService.indexStore(store);
|
|
75
|
-
|
|
76
|
-
expect(result.success).toBe(true);
|
|
77
|
-
if (result.success) {
|
|
78
|
-
expect(result.data.chunksCreated).toBeGreaterThan(result.data.documentsIndexed);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('IndexService - File Type Classification', () => {
|
|
84
|
-
let indexService: IndexService;
|
|
85
|
-
let lanceStore: LanceStore;
|
|
86
|
-
let embeddingEngine: EmbeddingEngine;
|
|
87
|
-
let tempDir: string;
|
|
88
|
-
let testFilesDir: string;
|
|
89
|
-
const storeId = createStoreId('test-store');
|
|
90
|
-
|
|
91
|
-
beforeAll(async () => {
|
|
92
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-filetype-test-'));
|
|
93
|
-
testFilesDir = join(tempDir, 'files');
|
|
94
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
95
|
-
|
|
96
|
-
lanceStore = new LanceStore(tempDir);
|
|
97
|
-
embeddingEngine = new EmbeddingEngine();
|
|
98
|
-
|
|
99
|
-
await embeddingEngine.initialize();
|
|
100
|
-
await lanceStore.initialize(storeId);
|
|
101
|
-
|
|
102
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
103
|
-
}, 120000);
|
|
104
|
-
|
|
105
|
-
afterAll(async () => {
|
|
106
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('classifies README.md as documentation-primary', async () => {
|
|
110
|
-
await writeFile(join(testFilesDir, 'README.md'), '# Project\n\nMain documentation.');
|
|
111
|
-
|
|
112
|
-
const store: FileStore = {
|
|
113
|
-
type: 'file',
|
|
114
|
-
id: storeId,
|
|
115
|
-
name: 'Test Store',
|
|
116
|
-
path: testFilesDir,
|
|
117
|
-
createdAt: new Date(),
|
|
118
|
-
updatedAt: new Date(),
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const result = await indexService.indexStore(store);
|
|
122
|
-
expect(result.success).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('classifies markdown files in docs/ as documentation', async () => {
|
|
126
|
-
const docsDir = join(testFilesDir, 'docs');
|
|
127
|
-
await mkdir(docsDir, { recursive: true });
|
|
128
|
-
await writeFile(join(docsDir, 'guide.md'), '# Guide\n\nTutorial content.');
|
|
129
|
-
|
|
130
|
-
const store: FileStore = {
|
|
131
|
-
type: 'file',
|
|
132
|
-
id: storeId,
|
|
133
|
-
name: 'Test Store',
|
|
134
|
-
path: testFilesDir,
|
|
135
|
-
createdAt: new Date(),
|
|
136
|
-
updatedAt: new Date(),
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const result = await indexService.indexStore(store);
|
|
140
|
-
expect(result.success).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('classifies test files correctly', async () => {
|
|
144
|
-
await writeFile(join(testFilesDir, 'app.test.ts'), 'describe("test", () => {});');
|
|
145
|
-
await writeFile(join(testFilesDir, 'app.spec.js'), 'it("works", () => {});');
|
|
146
|
-
|
|
147
|
-
const store: FileStore = {
|
|
148
|
-
type: 'file',
|
|
149
|
-
id: storeId,
|
|
150
|
-
name: 'Test Store',
|
|
151
|
-
path: testFilesDir,
|
|
152
|
-
createdAt: new Date(),
|
|
153
|
-
updatedAt: new Date(),
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const result = await indexService.indexStore(store);
|
|
157
|
-
expect(result.success).toBe(true);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('classifies example files correctly', async () => {
|
|
161
|
-
const examplesDir = join(testFilesDir, 'examples');
|
|
162
|
-
await mkdir(examplesDir, { recursive: true });
|
|
163
|
-
await writeFile(join(examplesDir, 'basic.ts'), 'const example = 42;');
|
|
164
|
-
|
|
165
|
-
const store: FileStore = {
|
|
166
|
-
type: 'file',
|
|
167
|
-
id: storeId,
|
|
168
|
-
name: 'Test Store',
|
|
169
|
-
path: testFilesDir,
|
|
170
|
-
createdAt: new Date(),
|
|
171
|
-
updatedAt: new Date(),
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const result = await indexService.indexStore(store);
|
|
175
|
-
expect(result.success).toBe(true);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('classifies config files correctly', async () => {
|
|
179
|
-
await writeFile(join(testFilesDir, 'tsconfig.json'), '{ "compilerOptions": {} }');
|
|
180
|
-
await writeFile(join(testFilesDir, 'package.json'), '{ "name": "test" }');
|
|
181
|
-
|
|
182
|
-
const store: FileStore = {
|
|
183
|
-
type: 'file',
|
|
184
|
-
id: storeId,
|
|
185
|
-
name: 'Test Store',
|
|
186
|
-
path: testFilesDir,
|
|
187
|
-
createdAt: new Date(),
|
|
188
|
-
updatedAt: new Date(),
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const result = await indexService.indexStore(store);
|
|
192
|
-
expect(result.success).toBe(true);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('classifies TypeScript source files', async () => {
|
|
196
|
-
await writeFile(join(testFilesDir, 'app.ts'), 'export function hello() {}');
|
|
197
|
-
|
|
198
|
-
const store: FileStore = {
|
|
199
|
-
type: 'file',
|
|
200
|
-
id: storeId,
|
|
201
|
-
name: 'Test Store',
|
|
202
|
-
path: testFilesDir,
|
|
203
|
-
createdAt: new Date(),
|
|
204
|
-
updatedAt: new Date(),
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const result = await indexService.indexStore(store);
|
|
208
|
-
expect(result.success).toBe(true);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('classifies JavaScript source files', async () => {
|
|
212
|
-
await writeFile(join(testFilesDir, 'app.js'), 'function hello() {}');
|
|
213
|
-
|
|
214
|
-
const store: FileStore = {
|
|
215
|
-
type: 'file',
|
|
216
|
-
id: storeId,
|
|
217
|
-
name: 'Test Store',
|
|
218
|
-
path: testFilesDir,
|
|
219
|
-
createdAt: new Date(),
|
|
220
|
-
updatedAt: new Date(),
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const result = await indexService.indexStore(store);
|
|
224
|
-
expect(result.success).toBe(true);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('classifies Python source files', async () => {
|
|
228
|
-
await writeFile(join(testFilesDir, 'app.py'), 'def hello():\n pass');
|
|
229
|
-
|
|
230
|
-
const store: FileStore = {
|
|
231
|
-
type: 'file',
|
|
232
|
-
id: storeId,
|
|
233
|
-
name: 'Test Store',
|
|
234
|
-
path: testFilesDir,
|
|
235
|
-
createdAt: new Date(),
|
|
236
|
-
updatedAt: new Date(),
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const result = await indexService.indexStore(store);
|
|
240
|
-
expect(result.success).toBe(true);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('classifies CHANGELOG.md separately', async () => {
|
|
244
|
-
await writeFile(join(testFilesDir, 'CHANGELOG.md'), '# Changelog\n\n## v1.0.0');
|
|
245
|
-
|
|
246
|
-
const store: FileStore = {
|
|
247
|
-
type: 'file',
|
|
248
|
-
id: storeId,
|
|
249
|
-
name: 'Test Store',
|
|
250
|
-
path: testFilesDir,
|
|
251
|
-
createdAt: new Date(),
|
|
252
|
-
updatedAt: new Date(),
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const result = await indexService.indexStore(store);
|
|
256
|
-
expect(result.success).toBe(true);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it('classifies MIGRATION.md as documentation-primary', async () => {
|
|
260
|
-
await writeFile(join(testFilesDir, 'MIGRATION.md'), '# Migration Guide\n\nSteps to upgrade.');
|
|
261
|
-
|
|
262
|
-
const store: FileStore = {
|
|
263
|
-
type: 'file',
|
|
264
|
-
id: storeId,
|
|
265
|
-
name: 'Test Store',
|
|
266
|
-
path: testFilesDir,
|
|
267
|
-
createdAt: new Date(),
|
|
268
|
-
updatedAt: new Date(),
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const result = await indexService.indexStore(store);
|
|
272
|
-
expect(result.success).toBe(true);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('classifies Go source files', async () => {
|
|
276
|
-
await writeFile(join(testFilesDir, 'main.go'), 'package main\n\nfunc main() {}');
|
|
277
|
-
|
|
278
|
-
const store: FileStore = {
|
|
279
|
-
type: 'file',
|
|
280
|
-
id: storeId,
|
|
281
|
-
name: 'Test Store',
|
|
282
|
-
path: testFilesDir,
|
|
283
|
-
createdAt: new Date(),
|
|
284
|
-
updatedAt: new Date(),
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
const result = await indexService.indexStore(store);
|
|
288
|
-
expect(result.success).toBe(true);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('classifies Rust source files', async () => {
|
|
292
|
-
await writeFile(join(testFilesDir, 'main.rs'), 'fn main() {}');
|
|
293
|
-
|
|
294
|
-
const store: FileStore = {
|
|
295
|
-
type: 'file',
|
|
296
|
-
id: storeId,
|
|
297
|
-
name: 'Test Store',
|
|
298
|
-
path: testFilesDir,
|
|
299
|
-
createdAt: new Date(),
|
|
300
|
-
updatedAt: new Date(),
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const result = await indexService.indexStore(store);
|
|
304
|
-
expect(result.success).toBe(true);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
describe('IndexService - Path Pattern Matching', () => {
|
|
309
|
-
let indexService: IndexService;
|
|
310
|
-
let lanceStore: LanceStore;
|
|
311
|
-
let embeddingEngine: EmbeddingEngine;
|
|
312
|
-
let tempDir: string;
|
|
313
|
-
let testFilesDir: string;
|
|
314
|
-
const storeId = createStoreId('test-store');
|
|
315
|
-
|
|
316
|
-
beforeAll(async () => {
|
|
317
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-path-test-'));
|
|
318
|
-
testFilesDir = join(tempDir, 'files');
|
|
319
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
320
|
-
|
|
321
|
-
lanceStore = new LanceStore(tempDir);
|
|
322
|
-
embeddingEngine = new EmbeddingEngine();
|
|
323
|
-
|
|
324
|
-
await embeddingEngine.initialize();
|
|
325
|
-
await lanceStore.initialize(storeId);
|
|
326
|
-
|
|
327
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
328
|
-
}, 120000);
|
|
329
|
-
|
|
330
|
-
afterAll(async () => {
|
|
331
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('skips node_modules directory', async () => {
|
|
335
|
-
const nodeModules = join(testFilesDir, 'node_modules');
|
|
336
|
-
await mkdir(nodeModules, { recursive: true });
|
|
337
|
-
await writeFile(join(nodeModules, 'package.js'), 'module.exports = {};');
|
|
338
|
-
await writeFile(join(testFilesDir, 'app.js'), 'console.log("app");');
|
|
339
|
-
|
|
340
|
-
const store: FileStore = {
|
|
341
|
-
type: 'file',
|
|
342
|
-
id: storeId,
|
|
343
|
-
name: 'Test Store',
|
|
344
|
-
path: testFilesDir,
|
|
345
|
-
createdAt: new Date(),
|
|
346
|
-
updatedAt: new Date(),
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
const result = await indexService.indexStore(store);
|
|
350
|
-
expect(result.success).toBe(true);
|
|
351
|
-
if (result.success) {
|
|
352
|
-
// Should only index app.js, not node_modules
|
|
353
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('skips .git directory', async () => {
|
|
358
|
-
const gitDir = join(testFilesDir, '.git');
|
|
359
|
-
await mkdir(gitDir, { recursive: true });
|
|
360
|
-
await writeFile(join(gitDir, 'config'), 'git config');
|
|
361
|
-
await writeFile(join(testFilesDir, 'app.js'), 'console.log("app");');
|
|
362
|
-
|
|
363
|
-
const store: FileStore = {
|
|
364
|
-
type: 'file',
|
|
365
|
-
id: storeId,
|
|
366
|
-
name: 'Test Store',
|
|
367
|
-
path: testFilesDir,
|
|
368
|
-
createdAt: new Date(),
|
|
369
|
-
updatedAt: new Date(),
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
const result = await indexService.indexStore(store);
|
|
373
|
-
expect(result.success).toBe(true);
|
|
374
|
-
if (result.success) {
|
|
375
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('skips dist directory', async () => {
|
|
380
|
-
const distDir = join(testFilesDir, 'dist');
|
|
381
|
-
await mkdir(distDir, { recursive: true });
|
|
382
|
-
await writeFile(join(distDir, 'bundle.js'), 'minified code');
|
|
383
|
-
await writeFile(join(testFilesDir, 'app.js'), 'console.log("app");');
|
|
384
|
-
|
|
385
|
-
const store: FileStore = {
|
|
386
|
-
type: 'file',
|
|
387
|
-
id: storeId,
|
|
388
|
-
name: 'Test Store',
|
|
389
|
-
path: testFilesDir,
|
|
390
|
-
createdAt: new Date(),
|
|
391
|
-
updatedAt: new Date(),
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
const result = await indexService.indexStore(store);
|
|
395
|
-
expect(result.success).toBe(true);
|
|
396
|
-
if (result.success) {
|
|
397
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('skips build directory', async () => {
|
|
402
|
-
const buildDir = join(testFilesDir, 'build');
|
|
403
|
-
await mkdir(buildDir, { recursive: true });
|
|
404
|
-
await writeFile(join(buildDir, 'output.js'), 'compiled code');
|
|
405
|
-
await writeFile(join(testFilesDir, 'app.js'), 'console.log("app");');
|
|
406
|
-
|
|
407
|
-
const store: FileStore = {
|
|
408
|
-
type: 'file',
|
|
409
|
-
id: storeId,
|
|
410
|
-
name: 'Test Store',
|
|
411
|
-
path: testFilesDir,
|
|
412
|
-
createdAt: new Date(),
|
|
413
|
-
updatedAt: new Date(),
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
const result = await indexService.indexStore(store);
|
|
417
|
-
expect(result.success).toBe(true);
|
|
418
|
-
if (result.success) {
|
|
419
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('indexes nested directories', async () => {
|
|
424
|
-
const srcDir = join(testFilesDir, 'src');
|
|
425
|
-
const utilsDir = join(srcDir, 'utils');
|
|
426
|
-
await mkdir(utilsDir, { recursive: true });
|
|
427
|
-
await writeFile(join(utilsDir, 'helper.ts'), 'export function help() {}');
|
|
428
|
-
|
|
429
|
-
const store: FileStore = {
|
|
430
|
-
type: 'file',
|
|
431
|
-
id: storeId,
|
|
432
|
-
name: 'Test Store',
|
|
433
|
-
path: testFilesDir,
|
|
434
|
-
createdAt: new Date(),
|
|
435
|
-
updatedAt: new Date(),
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
const result = await indexService.indexStore(store);
|
|
439
|
-
expect(result.success).toBe(true);
|
|
440
|
-
if (result.success) {
|
|
441
|
-
expect(result.data.documentsIndexed).toBeGreaterThan(0);
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
it('only indexes text files with supported extensions', async () => {
|
|
446
|
-
const isolatedDir = join(tempDir, 'isolated-test');
|
|
447
|
-
await mkdir(isolatedDir, { recursive: true });
|
|
448
|
-
await writeFile(join(isolatedDir, 'image.png'), 'binary data');
|
|
449
|
-
await writeFile(join(isolatedDir, 'video.mp4'), 'binary data');
|
|
450
|
-
await writeFile(join(isolatedDir, 'app.ts'), 'const x = 42;');
|
|
451
|
-
|
|
452
|
-
const store: FileStore = {
|
|
453
|
-
type: 'file',
|
|
454
|
-
id: storeId,
|
|
455
|
-
name: 'Test Store',
|
|
456
|
-
path: isolatedDir,
|
|
457
|
-
createdAt: new Date(),
|
|
458
|
-
updatedAt: new Date(),
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
const result = await indexService.indexStore(store);
|
|
462
|
-
expect(result.success).toBe(true);
|
|
463
|
-
if (result.success) {
|
|
464
|
-
// Should only index app.ts
|
|
465
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
describe('IndexService - Internal Implementation Detection', () => {
|
|
471
|
-
let indexService: IndexService;
|
|
472
|
-
let lanceStore: LanceStore;
|
|
473
|
-
let embeddingEngine: EmbeddingEngine;
|
|
474
|
-
let tempDir: string;
|
|
475
|
-
let testFilesDir: string;
|
|
476
|
-
const storeId = createStoreId('test-store');
|
|
477
|
-
|
|
478
|
-
beforeAll(async () => {
|
|
479
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-internal-test-'));
|
|
480
|
-
testFilesDir = join(tempDir, 'files');
|
|
481
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
482
|
-
|
|
483
|
-
lanceStore = new LanceStore(tempDir);
|
|
484
|
-
embeddingEngine = new EmbeddingEngine();
|
|
485
|
-
|
|
486
|
-
await embeddingEngine.initialize();
|
|
487
|
-
await lanceStore.initialize(storeId);
|
|
488
|
-
|
|
489
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
490
|
-
}, 120000);
|
|
491
|
-
|
|
492
|
-
afterAll(async () => {
|
|
493
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
it('detects monorepo internal files', async () => {
|
|
497
|
-
const packagesDir = join(testFilesDir, 'packages', 'core', 'src');
|
|
498
|
-
await mkdir(packagesDir, { recursive: true });
|
|
499
|
-
await writeFile(join(packagesDir, 'internal.ts'), 'export function internal() {}');
|
|
500
|
-
|
|
501
|
-
const store: FileStore = {
|
|
502
|
-
type: 'file',
|
|
503
|
-
id: storeId,
|
|
504
|
-
name: 'Test Store',
|
|
505
|
-
path: testFilesDir,
|
|
506
|
-
createdAt: new Date(),
|
|
507
|
-
updatedAt: new Date(),
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
const result = await indexService.indexStore(store);
|
|
511
|
-
expect(result.success).toBe(true);
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
it('treats index files as public API', async () => {
|
|
515
|
-
const packagesDir = join(testFilesDir, 'packages', 'core', 'src');
|
|
516
|
-
await mkdir(packagesDir, { recursive: true });
|
|
517
|
-
await writeFile(join(packagesDir, 'index.ts'), 'export * from "./api";');
|
|
518
|
-
|
|
519
|
-
const store: FileStore = {
|
|
520
|
-
type: 'file',
|
|
521
|
-
id: storeId,
|
|
522
|
-
name: 'Test Store',
|
|
523
|
-
path: testFilesDir,
|
|
524
|
-
createdAt: new Date(),
|
|
525
|
-
updatedAt: new Date(),
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
const result = await indexService.indexStore(store);
|
|
529
|
-
expect(result.success).toBe(true);
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
it('detects internal/ directory files', async () => {
|
|
533
|
-
const internalDir = join(testFilesDir, 'src', 'internal');
|
|
534
|
-
await mkdir(internalDir, { recursive: true });
|
|
535
|
-
await writeFile(join(internalDir, 'helper.ts'), 'function internal() {}');
|
|
536
|
-
|
|
537
|
-
const store: FileStore = {
|
|
538
|
-
type: 'file',
|
|
539
|
-
id: storeId,
|
|
540
|
-
name: 'Test Store',
|
|
541
|
-
path: testFilesDir,
|
|
542
|
-
createdAt: new Date(),
|
|
543
|
-
updatedAt: new Date(),
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
const result = await indexService.indexStore(store);
|
|
547
|
-
expect(result.success).toBe(true);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
it('detects compiler internal files', async () => {
|
|
551
|
-
const compilerDir = join(testFilesDir, 'src', 'compiler');
|
|
552
|
-
await mkdir(compilerDir, { recursive: true });
|
|
553
|
-
await writeFile(join(compilerDir, 'parser.ts'), 'function parse() {}');
|
|
554
|
-
|
|
555
|
-
const store: FileStore = {
|
|
556
|
-
type: 'file',
|
|
557
|
-
id: storeId,
|
|
558
|
-
name: 'Test Store',
|
|
559
|
-
path: testFilesDir,
|
|
560
|
-
createdAt: new Date(),
|
|
561
|
-
updatedAt: new Date(),
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
const result = await indexService.indexStore(store);
|
|
565
|
-
expect(result.success).toBe(true);
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
it('detects private directory files', async () => {
|
|
569
|
-
const privateDir = join(testFilesDir, 'private');
|
|
570
|
-
await mkdir(privateDir, { recursive: true });
|
|
571
|
-
await writeFile(join(privateDir, 'secret.ts'), 'const secret = "key";');
|
|
572
|
-
|
|
573
|
-
const store: FileStore = {
|
|
574
|
-
type: 'file',
|
|
575
|
-
id: storeId,
|
|
576
|
-
name: 'Test Store',
|
|
577
|
-
path: testFilesDir,
|
|
578
|
-
createdAt: new Date(),
|
|
579
|
-
updatedAt: new Date(),
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
const result = await indexService.indexStore(store);
|
|
583
|
-
expect(result.success).toBe(true);
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
describe('IndexService - Progress Callbacks', () => {
|
|
588
|
-
let indexService: IndexService;
|
|
589
|
-
let lanceStore: LanceStore;
|
|
590
|
-
let embeddingEngine: EmbeddingEngine;
|
|
591
|
-
let tempDir: string;
|
|
592
|
-
let testFilesDir: string;
|
|
593
|
-
const storeId = createStoreId('test-store');
|
|
594
|
-
|
|
595
|
-
beforeAll(async () => {
|
|
596
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-progress-test-'));
|
|
597
|
-
testFilesDir = join(tempDir, 'files');
|
|
598
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
599
|
-
|
|
600
|
-
lanceStore = new LanceStore(tempDir);
|
|
601
|
-
embeddingEngine = new EmbeddingEngine();
|
|
602
|
-
|
|
603
|
-
await embeddingEngine.initialize();
|
|
604
|
-
await lanceStore.initialize(storeId);
|
|
605
|
-
|
|
606
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
607
|
-
}, 120000);
|
|
608
|
-
|
|
609
|
-
afterAll(async () => {
|
|
610
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
it('emits start event', async () => {
|
|
614
|
-
await writeFile(join(testFilesDir, 'test.txt'), 'content');
|
|
615
|
-
|
|
616
|
-
const events: string[] = [];
|
|
617
|
-
const onProgress = vi.fn((event) => {
|
|
618
|
-
events.push(event.type);
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
const store: FileStore = {
|
|
622
|
-
type: 'file',
|
|
623
|
-
id: storeId,
|
|
624
|
-
name: 'Test Store',
|
|
625
|
-
path: testFilesDir,
|
|
626
|
-
createdAt: new Date(),
|
|
627
|
-
updatedAt: new Date(),
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
await indexService.indexStore(store, onProgress);
|
|
631
|
-
|
|
632
|
-
expect(events).toContain('start');
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it('emits progress events', async () => {
|
|
636
|
-
await writeFile(join(testFilesDir, 'test1.txt'), 'content 1');
|
|
637
|
-
await writeFile(join(testFilesDir, 'test2.txt'), 'content 2');
|
|
638
|
-
|
|
639
|
-
const events: string[] = [];
|
|
640
|
-
const onProgress = vi.fn((event) => {
|
|
641
|
-
events.push(event.type);
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
const store: FileStore = {
|
|
645
|
-
type: 'file',
|
|
646
|
-
id: storeId,
|
|
647
|
-
name: 'Test Store',
|
|
648
|
-
path: testFilesDir,
|
|
649
|
-
createdAt: new Date(),
|
|
650
|
-
updatedAt: new Date(),
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
await indexService.indexStore(store, onProgress);
|
|
654
|
-
|
|
655
|
-
expect(events).toContain('progress');
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
it('emits complete event', async () => {
|
|
659
|
-
await writeFile(join(testFilesDir, 'test.txt'), 'content');
|
|
660
|
-
|
|
661
|
-
const events: string[] = [];
|
|
662
|
-
const onProgress = vi.fn((event) => {
|
|
663
|
-
events.push(event.type);
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
const store: FileStore = {
|
|
667
|
-
type: 'file',
|
|
668
|
-
id: storeId,
|
|
669
|
-
name: 'Test Store',
|
|
670
|
-
path: testFilesDir,
|
|
671
|
-
createdAt: new Date(),
|
|
672
|
-
updatedAt: new Date(),
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
await indexService.indexStore(store, onProgress);
|
|
676
|
-
|
|
677
|
-
expect(events).toContain('complete');
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
it('provides progress counts', async () => {
|
|
681
|
-
await writeFile(join(testFilesDir, 'test1.txt'), 'content 1');
|
|
682
|
-
await writeFile(join(testFilesDir, 'test2.txt'), 'content 2');
|
|
683
|
-
|
|
684
|
-
const progressEvents: Array<{ current: number; total: number }> = [];
|
|
685
|
-
const onProgress = vi.fn((event) => {
|
|
686
|
-
if (event.type === 'progress') {
|
|
687
|
-
progressEvents.push({ current: event.current, total: event.total });
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
const store: FileStore = {
|
|
692
|
-
type: 'file',
|
|
693
|
-
id: storeId,
|
|
694
|
-
name: 'Test Store',
|
|
695
|
-
path: testFilesDir,
|
|
696
|
-
createdAt: new Date(),
|
|
697
|
-
updatedAt: new Date(),
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
await indexService.indexStore(store, onProgress);
|
|
701
|
-
|
|
702
|
-
expect(progressEvents.length).toBeGreaterThan(0);
|
|
703
|
-
expect(progressEvents[0]?.total).toBeGreaterThan(0);
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
it('maintains event sequence: start -> progress -> complete', async () => {
|
|
707
|
-
await writeFile(join(testFilesDir, 'test.txt'), 'content');
|
|
708
|
-
|
|
709
|
-
const events: string[] = [];
|
|
710
|
-
const onProgress = vi.fn((event) => {
|
|
711
|
-
events.push(event.type);
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
const store: FileStore = {
|
|
715
|
-
type: 'file',
|
|
716
|
-
id: storeId,
|
|
717
|
-
name: 'Test Store',
|
|
718
|
-
path: testFilesDir,
|
|
719
|
-
createdAt: new Date(),
|
|
720
|
-
updatedAt: new Date(),
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
await indexService.indexStore(store, onProgress);
|
|
724
|
-
|
|
725
|
-
expect(events[0]).toBe('start');
|
|
726
|
-
expect(events[events.length - 1]).toBe('complete');
|
|
727
|
-
});
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
describe('IndexService - Error Handling', () => {
|
|
731
|
-
let indexService: IndexService;
|
|
732
|
-
let lanceStore: LanceStore;
|
|
733
|
-
let embeddingEngine: EmbeddingEngine;
|
|
734
|
-
let tempDir: string;
|
|
735
|
-
const storeId = createStoreId('test-store');
|
|
736
|
-
|
|
737
|
-
beforeAll(async () => {
|
|
738
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-error-test-'));
|
|
739
|
-
|
|
740
|
-
lanceStore = new LanceStore(tempDir);
|
|
741
|
-
embeddingEngine = new EmbeddingEngine();
|
|
742
|
-
|
|
743
|
-
await embeddingEngine.initialize();
|
|
744
|
-
await lanceStore.initialize(storeId);
|
|
745
|
-
|
|
746
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
747
|
-
}, 120000);
|
|
748
|
-
|
|
749
|
-
afterAll(async () => {
|
|
750
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
it('handles non-existent directory', async () => {
|
|
754
|
-
const store: FileStore = {
|
|
755
|
-
type: 'file',
|
|
756
|
-
id: storeId,
|
|
757
|
-
name: 'Test Store',
|
|
758
|
-
path: '/nonexistent/path',
|
|
759
|
-
createdAt: new Date(),
|
|
760
|
-
updatedAt: new Date(),
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
const result = await indexService.indexStore(store);
|
|
764
|
-
|
|
765
|
-
expect(result.success).toBe(false);
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
it('handles empty directory', async () => {
|
|
769
|
-
const emptyDir = join(tempDir, 'empty');
|
|
770
|
-
await mkdir(emptyDir, { recursive: true });
|
|
771
|
-
|
|
772
|
-
const store: FileStore = {
|
|
773
|
-
type: 'file',
|
|
774
|
-
id: storeId,
|
|
775
|
-
name: 'Test Store',
|
|
776
|
-
path: emptyDir,
|
|
777
|
-
createdAt: new Date(),
|
|
778
|
-
updatedAt: new Date(),
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
const result = await indexService.indexStore(store);
|
|
782
|
-
|
|
783
|
-
expect(result.success).toBe(true);
|
|
784
|
-
if (result.success) {
|
|
785
|
-
expect(result.data.documentsIndexed).toBe(0);
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
it('handles directory with only ignored subdirectories', async () => {
|
|
790
|
-
const testDir = join(tempDir, 'test-ignored');
|
|
791
|
-
await mkdir(join(testDir, 'node_modules'), { recursive: true });
|
|
792
|
-
await mkdir(join(testDir, '.git'), { recursive: true });
|
|
793
|
-
|
|
794
|
-
const store: FileStore = {
|
|
795
|
-
type: 'file',
|
|
796
|
-
id: storeId,
|
|
797
|
-
name: 'Test Store',
|
|
798
|
-
path: testDir,
|
|
799
|
-
createdAt: new Date(),
|
|
800
|
-
updatedAt: new Date(),
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
const result = await indexService.indexStore(store);
|
|
804
|
-
|
|
805
|
-
expect(result.success).toBe(true);
|
|
806
|
-
if (result.success) {
|
|
807
|
-
expect(result.data.documentsIndexed).toBe(0);
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
describe('IndexService - Hash and Metadata', () => {
|
|
813
|
-
let indexService: IndexService;
|
|
814
|
-
let lanceStore: LanceStore;
|
|
815
|
-
let embeddingEngine: EmbeddingEngine;
|
|
816
|
-
let tempDir: string;
|
|
817
|
-
let testFilesDir: string;
|
|
818
|
-
const storeId = createStoreId('test-store');
|
|
819
|
-
|
|
820
|
-
beforeAll(async () => {
|
|
821
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-hash-test-'));
|
|
822
|
-
testFilesDir = join(tempDir, 'files');
|
|
823
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
824
|
-
|
|
825
|
-
lanceStore = new LanceStore(tempDir);
|
|
826
|
-
embeddingEngine = new EmbeddingEngine();
|
|
827
|
-
|
|
828
|
-
await embeddingEngine.initialize();
|
|
829
|
-
await lanceStore.initialize(storeId);
|
|
830
|
-
|
|
831
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
832
|
-
}, 120000);
|
|
833
|
-
|
|
834
|
-
afterAll(async () => {
|
|
835
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
it('generates file hashes for content tracking', async () => {
|
|
839
|
-
await writeFile(join(testFilesDir, 'test.txt'), 'unique content');
|
|
840
|
-
|
|
841
|
-
const store: FileStore = {
|
|
842
|
-
type: 'file',
|
|
843
|
-
id: storeId,
|
|
844
|
-
name: 'Test Store',
|
|
845
|
-
path: testFilesDir,
|
|
846
|
-
createdAt: new Date(),
|
|
847
|
-
updatedAt: new Date(),
|
|
848
|
-
};
|
|
849
|
-
|
|
850
|
-
const result = await indexService.indexStore(store);
|
|
851
|
-
|
|
852
|
-
expect(result.success).toBe(true);
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
it('includes chunk metadata', async () => {
|
|
856
|
-
const largeContent = 'This is a test. '.repeat(100);
|
|
857
|
-
await writeFile(join(testFilesDir, 'large.txt'), largeContent);
|
|
858
|
-
|
|
859
|
-
const store: FileStore = {
|
|
860
|
-
type: 'file',
|
|
861
|
-
id: storeId,
|
|
862
|
-
name: 'Test Store',
|
|
863
|
-
path: testFilesDir,
|
|
864
|
-
createdAt: new Date(),
|
|
865
|
-
updatedAt: new Date(),
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
const result = await indexService.indexStore(store);
|
|
869
|
-
|
|
870
|
-
expect(result.success).toBe(true);
|
|
871
|
-
if (result.success) {
|
|
872
|
-
expect(result.data.chunksCreated).toBeGreaterThan(0);
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
it('indexes Markdown with section headers', async () => {
|
|
877
|
-
const markdown = '# Section 1\n\nContent 1\n\n## Section 2\n\nContent 2';
|
|
878
|
-
await writeFile(join(testFilesDir, 'doc.md'), markdown);
|
|
879
|
-
|
|
880
|
-
const store: FileStore = {
|
|
881
|
-
type: 'file',
|
|
882
|
-
id: storeId,
|
|
883
|
-
name: 'Test Store',
|
|
884
|
-
path: testFilesDir,
|
|
885
|
-
createdAt: new Date(),
|
|
886
|
-
updatedAt: new Date(),
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
const result = await indexService.indexStore(store);
|
|
890
|
-
|
|
891
|
-
expect(result.success).toBe(true);
|
|
892
|
-
});
|
|
893
|
-
|
|
894
|
-
it('indexes code with function names', async () => {
|
|
895
|
-
const code =
|
|
896
|
-
'export function hello() {\n return "world";\n}\n\nfunction goodbye() {\n return "bye";\n}';
|
|
897
|
-
await writeFile(join(testFilesDir, 'code.ts'), code);
|
|
898
|
-
|
|
899
|
-
const store: FileStore = {
|
|
900
|
-
type: 'file',
|
|
901
|
-
id: storeId,
|
|
902
|
-
name: 'Test Store',
|
|
903
|
-
path: testFilesDir,
|
|
904
|
-
createdAt: new Date(),
|
|
905
|
-
updatedAt: new Date(),
|
|
906
|
-
};
|
|
907
|
-
|
|
908
|
-
const result = await indexService.indexStore(store);
|
|
909
|
-
|
|
910
|
-
expect(result.success).toBe(true);
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
it('detects JSDoc comments in chunks', async () => {
|
|
914
|
-
const code = '/** This is a doc comment */\nexport function documented() {}';
|
|
915
|
-
await writeFile(join(testFilesDir, 'documented.ts'), code);
|
|
916
|
-
|
|
917
|
-
const store: FileStore = {
|
|
918
|
-
type: 'file',
|
|
919
|
-
id: storeId,
|
|
920
|
-
name: 'Test Store',
|
|
921
|
-
path: testFilesDir,
|
|
922
|
-
createdAt: new Date(),
|
|
923
|
-
updatedAt: new Date(),
|
|
924
|
-
};
|
|
925
|
-
|
|
926
|
-
const result = await indexService.indexStore(store);
|
|
927
|
-
|
|
928
|
-
expect(result.success).toBe(true);
|
|
929
|
-
});
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
describe('IndexService - Custom Chunk Configuration', () => {
|
|
933
|
-
let lanceStore: LanceStore;
|
|
934
|
-
let embeddingEngine: EmbeddingEngine;
|
|
935
|
-
let tempDir: string;
|
|
936
|
-
let testFilesDir: string;
|
|
937
|
-
const storeId = createStoreId('test-store');
|
|
938
|
-
|
|
939
|
-
beforeAll(async () => {
|
|
940
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-chunk-config-test-'));
|
|
941
|
-
testFilesDir = join(tempDir, 'files');
|
|
942
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
943
|
-
|
|
944
|
-
lanceStore = new LanceStore(tempDir);
|
|
945
|
-
embeddingEngine = new EmbeddingEngine();
|
|
946
|
-
|
|
947
|
-
await embeddingEngine.initialize();
|
|
948
|
-
await lanceStore.initialize(storeId);
|
|
949
|
-
}, 120000);
|
|
950
|
-
|
|
951
|
-
afterAll(async () => {
|
|
952
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
it('uses custom chunk size', async () => {
|
|
956
|
-
const customService = new IndexService(lanceStore, embeddingEngine, {
|
|
957
|
-
chunkSize: 512,
|
|
958
|
-
chunkOverlap: 50,
|
|
959
|
-
});
|
|
960
|
-
|
|
961
|
-
const content = 'word '.repeat(200); // ~1000 chars
|
|
962
|
-
await writeFile(join(testFilesDir, 'test.txt'), content);
|
|
963
|
-
|
|
964
|
-
const store: FileStore = {
|
|
965
|
-
type: 'file',
|
|
966
|
-
id: storeId,
|
|
967
|
-
name: 'Test Store',
|
|
968
|
-
path: testFilesDir,
|
|
969
|
-
createdAt: new Date(),
|
|
970
|
-
updatedAt: new Date(),
|
|
971
|
-
};
|
|
972
|
-
|
|
973
|
-
const result = await customService.indexStore(store);
|
|
974
|
-
|
|
975
|
-
expect(result.success).toBe(true);
|
|
976
|
-
if (result.success) {
|
|
977
|
-
// With smaller chunk size, should create more chunks
|
|
978
|
-
expect(result.data.chunksCreated).toBeGreaterThan(1);
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
it('uses custom chunk overlap', async () => {
|
|
983
|
-
const customService = new IndexService(lanceStore, embeddingEngine, {
|
|
984
|
-
chunkSize: 768,
|
|
985
|
-
chunkOverlap: 200,
|
|
986
|
-
});
|
|
987
|
-
|
|
988
|
-
const content = 'word '.repeat(400);
|
|
989
|
-
await writeFile(join(testFilesDir, 'overlap-test.txt'), content);
|
|
990
|
-
|
|
991
|
-
const store: FileStore = {
|
|
992
|
-
type: 'file',
|
|
993
|
-
id: storeId,
|
|
994
|
-
name: 'Test Store',
|
|
995
|
-
path: testFilesDir,
|
|
996
|
-
createdAt: new Date(),
|
|
997
|
-
updatedAt: new Date(),
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
const result = await customService.indexStore(store);
|
|
1001
|
-
|
|
1002
|
-
expect(result.success).toBe(true);
|
|
1003
|
-
});
|
|
1004
|
-
});
|
|
1005
|
-
|
|
1006
|
-
describe('IndexService - Unsupported Store Types', () => {
|
|
1007
|
-
let indexService: IndexService;
|
|
1008
|
-
let lanceStore: LanceStore;
|
|
1009
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1010
|
-
let tempDir: string;
|
|
1011
|
-
const storeId = createStoreId('test-store');
|
|
1012
|
-
|
|
1013
|
-
beforeAll(async () => {
|
|
1014
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-unsupported-test-'));
|
|
1015
|
-
|
|
1016
|
-
lanceStore = new LanceStore(tempDir);
|
|
1017
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1018
|
-
|
|
1019
|
-
await embeddingEngine.initialize();
|
|
1020
|
-
await lanceStore.initialize(storeId);
|
|
1021
|
-
|
|
1022
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
1023
|
-
}, 120000);
|
|
1024
|
-
|
|
1025
|
-
afterAll(async () => {
|
|
1026
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
it('returns error for unsupported web store type', async () => {
|
|
1030
|
-
const store = {
|
|
1031
|
-
type: 'web' as const,
|
|
1032
|
-
id: storeId,
|
|
1033
|
-
name: 'Web Store',
|
|
1034
|
-
url: 'https://example.com',
|
|
1035
|
-
depth: 1,
|
|
1036
|
-
createdAt: new Date(),
|
|
1037
|
-
updatedAt: new Date(),
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
const result = await indexService.indexStore(store);
|
|
1041
|
-
|
|
1042
|
-
expect(result.success).toBe(false);
|
|
1043
|
-
if (!result.success) {
|
|
1044
|
-
expect(result.error.message).toContain('Indexing not supported for store type');
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
it('handles repo store type same as file store', async () => {
|
|
1049
|
-
const testFilesDir = join(tempDir, 'repo-files');
|
|
1050
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1051
|
-
await writeFile(join(testFilesDir, 'repo-file.ts'), 'export const repo = true;');
|
|
1052
|
-
|
|
1053
|
-
const store = {
|
|
1054
|
-
type: 'repo' as const,
|
|
1055
|
-
id: storeId,
|
|
1056
|
-
name: 'Repo Store',
|
|
1057
|
-
path: testFilesDir,
|
|
1058
|
-
url: 'https://github.com/example/repo',
|
|
1059
|
-
branch: 'main',
|
|
1060
|
-
createdAt: new Date(),
|
|
1061
|
-
updatedAt: new Date(),
|
|
1062
|
-
};
|
|
1063
|
-
|
|
1064
|
-
const result = await indexService.indexStore(store);
|
|
1065
|
-
|
|
1066
|
-
expect(result.success).toBe(true);
|
|
1067
|
-
if (result.success) {
|
|
1068
|
-
expect(result.data.documentsIndexed).toBe(1);
|
|
1069
|
-
}
|
|
1070
|
-
});
|
|
1071
|
-
});
|
|
1072
|
-
|
|
1073
|
-
describe('IndexService - Error Handling Edge Cases', () => {
|
|
1074
|
-
let lanceStore: LanceStore;
|
|
1075
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1076
|
-
let tempDir: string;
|
|
1077
|
-
const storeId = createStoreId('test-store');
|
|
1078
|
-
|
|
1079
|
-
beforeAll(async () => {
|
|
1080
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-error-edge-test-'));
|
|
1081
|
-
|
|
1082
|
-
lanceStore = new LanceStore(tempDir);
|
|
1083
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1084
|
-
|
|
1085
|
-
await embeddingEngine.initialize();
|
|
1086
|
-
await lanceStore.initialize(storeId);
|
|
1087
|
-
}, 120000);
|
|
1088
|
-
|
|
1089
|
-
afterAll(async () => {
|
|
1090
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
it('converts non-Error thrown values to Error', async () => {
|
|
1094
|
-
// Create a mock that throws a string instead of Error
|
|
1095
|
-
const mockLanceStore = {
|
|
1096
|
-
addDocuments: vi.fn().mockRejectedValue('string error'),
|
|
1097
|
-
createFtsIndex: vi.fn().mockResolvedValue(undefined),
|
|
1098
|
-
} as unknown as LanceStore;
|
|
1099
|
-
|
|
1100
|
-
const indexService = new IndexService(mockLanceStore, embeddingEngine);
|
|
1101
|
-
|
|
1102
|
-
const testFilesDir = join(tempDir, 'error-test');
|
|
1103
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1104
|
-
await writeFile(join(testFilesDir, 'test.ts'), 'const x = 1;');
|
|
1105
|
-
|
|
1106
|
-
const store = {
|
|
1107
|
-
type: 'file' as const,
|
|
1108
|
-
id: storeId,
|
|
1109
|
-
name: 'Test Store',
|
|
1110
|
-
path: testFilesDir,
|
|
1111
|
-
createdAt: new Date(),
|
|
1112
|
-
updatedAt: new Date(),
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
const result = await indexService.indexStore(store);
|
|
1116
|
-
|
|
1117
|
-
expect(result.success).toBe(false);
|
|
1118
|
-
if (!result.success) {
|
|
1119
|
-
expect(result.error).toBeInstanceOf(Error);
|
|
1120
|
-
expect(result.error.message).toBe('string error');
|
|
1121
|
-
}
|
|
1122
|
-
});
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
describe('IndexService - Code Graph Integration', () => {
|
|
1126
|
-
let lanceStore: LanceStore;
|
|
1127
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1128
|
-
let tempDir: string;
|
|
1129
|
-
let testFilesDir: string;
|
|
1130
|
-
const storeId = createStoreId('test-store');
|
|
1131
|
-
|
|
1132
|
-
beforeAll(async () => {
|
|
1133
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-codegraph-test-'));
|
|
1134
|
-
testFilesDir = join(tempDir, 'files');
|
|
1135
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1136
|
-
|
|
1137
|
-
lanceStore = new LanceStore(tempDir);
|
|
1138
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1139
|
-
|
|
1140
|
-
await embeddingEngine.initialize();
|
|
1141
|
-
await lanceStore.initialize(storeId);
|
|
1142
|
-
}, 120000);
|
|
1143
|
-
|
|
1144
|
-
afterAll(async () => {
|
|
1145
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1146
|
-
});
|
|
1147
|
-
|
|
1148
|
-
it('builds and saves code graph when codeGraphService is provided', async () => {
|
|
1149
|
-
const buildGraphMock = vi.fn().mockResolvedValue({ nodes: [], edges: [] });
|
|
1150
|
-
const saveGraphMock = vi.fn().mockResolvedValue(undefined);
|
|
1151
|
-
|
|
1152
|
-
const mockCodeGraphService = {
|
|
1153
|
-
buildGraph: buildGraphMock,
|
|
1154
|
-
saveGraph: saveGraphMock,
|
|
1155
|
-
} as unknown as CodeGraphService;
|
|
1156
|
-
|
|
1157
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, {
|
|
1158
|
-
codeGraphService: mockCodeGraphService,
|
|
1159
|
-
});
|
|
1160
|
-
|
|
1161
|
-
// Create TypeScript files (source files for code graph)
|
|
1162
|
-
await writeFile(join(testFilesDir, 'module.ts'), 'export function foo() { return 1; }');
|
|
1163
|
-
await writeFile(join(testFilesDir, 'utils.tsx'), 'export const Bar = () => <div />;');
|
|
1164
|
-
|
|
1165
|
-
const store: FileStore = {
|
|
1166
|
-
type: 'file',
|
|
1167
|
-
id: storeId,
|
|
1168
|
-
name: 'Test Store',
|
|
1169
|
-
path: testFilesDir,
|
|
1170
|
-
createdAt: new Date(),
|
|
1171
|
-
updatedAt: new Date(),
|
|
1172
|
-
};
|
|
1173
|
-
|
|
1174
|
-
const result = await indexService.indexStore(store);
|
|
1175
|
-
|
|
1176
|
-
expect(result.success).toBe(true);
|
|
1177
|
-
expect(buildGraphMock).toHaveBeenCalled();
|
|
1178
|
-
expect(saveGraphMock).toHaveBeenCalledWith(storeId, expect.anything());
|
|
1179
|
-
});
|
|
1180
|
-
|
|
1181
|
-
it('does not build code graph when no source files are present', async () => {
|
|
1182
|
-
const buildGraphMock = vi.fn();
|
|
1183
|
-
const saveGraphMock = vi.fn();
|
|
1184
|
-
|
|
1185
|
-
const mockCodeGraphService = {
|
|
1186
|
-
buildGraph: buildGraphMock,
|
|
1187
|
-
saveGraph: saveGraphMock,
|
|
1188
|
-
} as unknown as CodeGraphService;
|
|
1189
|
-
|
|
1190
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, {
|
|
1191
|
-
codeGraphService: mockCodeGraphService,
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
const isolatedDir = join(tempDir, 'no-source-files');
|
|
1195
|
-
await mkdir(isolatedDir, { recursive: true });
|
|
1196
|
-
// Only non-source files
|
|
1197
|
-
await writeFile(join(isolatedDir, 'readme.md'), '# Readme');
|
|
1198
|
-
await writeFile(join(isolatedDir, 'data.json'), '{}');
|
|
1199
|
-
|
|
1200
|
-
const store: FileStore = {
|
|
1201
|
-
type: 'file',
|
|
1202
|
-
id: storeId,
|
|
1203
|
-
name: 'Test Store',
|
|
1204
|
-
path: isolatedDir,
|
|
1205
|
-
createdAt: new Date(),
|
|
1206
|
-
updatedAt: new Date(),
|
|
1207
|
-
};
|
|
1208
|
-
|
|
1209
|
-
const result = await indexService.indexStore(store);
|
|
1210
|
-
|
|
1211
|
-
expect(result.success).toBe(true);
|
|
1212
|
-
expect(buildGraphMock).not.toHaveBeenCalled();
|
|
1213
|
-
expect(saveGraphMock).not.toHaveBeenCalled();
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
it('collects .js and .jsx files for code graph', async () => {
|
|
1217
|
-
const buildGraphMock = vi.fn().mockResolvedValue({ nodes: [], edges: [] });
|
|
1218
|
-
const saveGraphMock = vi.fn().mockResolvedValue(undefined);
|
|
1219
|
-
|
|
1220
|
-
const mockCodeGraphService = {
|
|
1221
|
-
buildGraph: buildGraphMock,
|
|
1222
|
-
saveGraph: saveGraphMock,
|
|
1223
|
-
} as unknown as CodeGraphService;
|
|
1224
|
-
|
|
1225
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, {
|
|
1226
|
-
codeGraphService: mockCodeGraphService,
|
|
1227
|
-
});
|
|
1228
|
-
|
|
1229
|
-
const jsDir = join(tempDir, 'js-files');
|
|
1230
|
-
await mkdir(jsDir, { recursive: true });
|
|
1231
|
-
await writeFile(join(jsDir, 'app.js'), 'function main() {}');
|
|
1232
|
-
await writeFile(join(jsDir, 'component.jsx'), 'export const App = () => null;');
|
|
1233
|
-
|
|
1234
|
-
const store: FileStore = {
|
|
1235
|
-
type: 'file',
|
|
1236
|
-
id: storeId,
|
|
1237
|
-
name: 'Test Store',
|
|
1238
|
-
path: jsDir,
|
|
1239
|
-
createdAt: new Date(),
|
|
1240
|
-
updatedAt: new Date(),
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
const result = await indexService.indexStore(store);
|
|
1244
|
-
|
|
1245
|
-
expect(result.success).toBe(true);
|
|
1246
|
-
expect(buildGraphMock).toHaveBeenCalled();
|
|
1247
|
-
// Verify the source files passed to buildGraph
|
|
1248
|
-
const sourceFiles = buildGraphMock.mock.calls[0][0] as Array<{ path: string; content: string }>;
|
|
1249
|
-
expect(sourceFiles.length).toBe(2);
|
|
1250
|
-
expect(sourceFiles.some((f) => f.path.endsWith('.js'))).toBe(true);
|
|
1251
|
-
expect(sourceFiles.some((f) => f.path.endsWith('.jsx'))).toBe(true);
|
|
1252
|
-
});
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
describe('classifyWebContentType', () => {
|
|
1256
|
-
describe('documentation-primary classification', () => {
|
|
1257
|
-
it('classifies API reference URLs', () => {
|
|
1258
|
-
expect(classifyWebContentType('https://example.com/api-reference/endpoints')).toBe(
|
|
1259
|
-
'documentation-primary'
|
|
1260
|
-
);
|
|
1261
|
-
expect(classifyWebContentType('https://example.com/api-docs/v2')).toBe(
|
|
1262
|
-
'documentation-primary'
|
|
1263
|
-
);
|
|
1264
|
-
expect(classifyWebContentType('https://example.com/apiref/methods')).toBe(
|
|
1265
|
-
'documentation-primary'
|
|
1266
|
-
);
|
|
1267
|
-
});
|
|
1268
|
-
|
|
1269
|
-
it('classifies API reference by title', () => {
|
|
1270
|
-
expect(classifyWebContentType('https://example.com/page', 'API Reference Guide')).toBe(
|
|
1271
|
-
'documentation-primary'
|
|
1272
|
-
);
|
|
1273
|
-
expect(classifyWebContentType('https://example.com/page', 'Complete API Documentation')).toBe(
|
|
1274
|
-
'documentation-primary'
|
|
1275
|
-
);
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
|
-
it('classifies getting started URLs', () => {
|
|
1279
|
-
expect(classifyWebContentType('https://example.com/getting-started')).toBe(
|
|
1280
|
-
'documentation-primary'
|
|
1281
|
-
);
|
|
1282
|
-
expect(classifyWebContentType('https://example.com/getting_started')).toBe(
|
|
1283
|
-
'documentation-primary'
|
|
1284
|
-
);
|
|
1285
|
-
expect(classifyWebContentType('https://example.com/gettingstarted')).toBe(
|
|
1286
|
-
'documentation-primary'
|
|
1287
|
-
);
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
it('classifies quickstart URLs', () => {
|
|
1291
|
-
expect(classifyWebContentType('https://example.com/quickstart')).toBe(
|
|
1292
|
-
'documentation-primary'
|
|
1293
|
-
);
|
|
1294
|
-
});
|
|
1295
|
-
|
|
1296
|
-
it('classifies tutorial URLs', () => {
|
|
1297
|
-
expect(classifyWebContentType('https://example.com/tutorial/basics')).toBe(
|
|
1298
|
-
'documentation-primary'
|
|
1299
|
-
);
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
it('classifies setup URLs', () => {
|
|
1303
|
-
expect(classifyWebContentType('https://example.com/setup')).toBe('documentation-primary');
|
|
1304
|
-
});
|
|
1305
|
-
|
|
1306
|
-
it('classifies getting started by title', () => {
|
|
1307
|
-
expect(classifyWebContentType('https://example.com/page', 'Getting Started with React')).toBe(
|
|
1308
|
-
'documentation-primary'
|
|
1309
|
-
);
|
|
1310
|
-
expect(classifyWebContentType('https://example.com/page', 'Quickstart Guide')).toBe(
|
|
1311
|
-
'documentation-primary'
|
|
1312
|
-
);
|
|
1313
|
-
expect(
|
|
1314
|
-
classifyWebContentType('https://example.com/page', 'Tutorial: Build Your First App')
|
|
1315
|
-
).toBe('documentation-primary');
|
|
1316
|
-
});
|
|
1317
|
-
});
|
|
1318
|
-
|
|
1319
|
-
describe('documentation classification', () => {
|
|
1320
|
-
it('classifies docs paths', () => {
|
|
1321
|
-
expect(classifyWebContentType('https://example.com/docs/intro')).toBe('documentation');
|
|
1322
|
-
expect(classifyWebContentType('https://example.com/documentation/advanced')).toBe(
|
|
1323
|
-
'documentation'
|
|
1324
|
-
);
|
|
1325
|
-
});
|
|
1326
|
-
|
|
1327
|
-
it('classifies reference paths', () => {
|
|
1328
|
-
expect(classifyWebContentType('https://example.com/reference/types')).toBe('documentation');
|
|
1329
|
-
});
|
|
1330
|
-
|
|
1331
|
-
it('classifies learn paths', () => {
|
|
1332
|
-
expect(classifyWebContentType('https://example.com/learn/basics')).toBe('documentation');
|
|
1333
|
-
});
|
|
1334
|
-
|
|
1335
|
-
it('classifies manual paths', () => {
|
|
1336
|
-
expect(classifyWebContentType('https://example.com/manual/chapter1')).toBe('documentation');
|
|
1337
|
-
});
|
|
1338
|
-
|
|
1339
|
-
it('classifies guide paths', () => {
|
|
1340
|
-
expect(classifyWebContentType('https://example.com/guide/installation')).toBe(
|
|
1341
|
-
'documentation'
|
|
1342
|
-
);
|
|
1343
|
-
});
|
|
1344
|
-
});
|
|
1345
|
-
|
|
1346
|
-
describe('example classification', () => {
|
|
1347
|
-
it('classifies examples paths', () => {
|
|
1348
|
-
expect(classifyWebContentType('https://example.com/examples/basic')).toBe('example');
|
|
1349
|
-
expect(classifyWebContentType('https://example.com/example/advanced')).toBe('example');
|
|
1350
|
-
});
|
|
1351
|
-
|
|
1352
|
-
it('classifies demos paths', () => {
|
|
1353
|
-
expect(classifyWebContentType('https://example.com/demos/interactive')).toBe('example');
|
|
1354
|
-
expect(classifyWebContentType('https://example.com/demo/live')).toBe('example');
|
|
1355
|
-
});
|
|
1356
|
-
|
|
1357
|
-
it('classifies samples paths', () => {
|
|
1358
|
-
expect(classifyWebContentType('https://example.com/samples/code')).toBe('example');
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
it('classifies cookbook paths', () => {
|
|
1362
|
-
expect(classifyWebContentType('https://example.com/cookbook/recipes')).toBe('example');
|
|
1363
|
-
});
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
describe('changelog classification', () => {
|
|
1367
|
-
it('classifies changelog paths', () => {
|
|
1368
|
-
// Note: URL must not contain /docs/, /doc/, etc. earlier in the path since those match first
|
|
1369
|
-
expect(classifyWebContentType('https://mysite.org/changelog')).toBe('changelog');
|
|
1370
|
-
});
|
|
1371
|
-
|
|
1372
|
-
it('classifies release notes paths', () => {
|
|
1373
|
-
expect(classifyWebContentType('https://mysite.org/release-notes')).toBe('changelog');
|
|
1374
|
-
expect(classifyWebContentType('https://mysite.org/release_notes')).toBe('changelog');
|
|
1375
|
-
expect(classifyWebContentType('https://mysite.org/releasenotes')).toBe('changelog');
|
|
1376
|
-
});
|
|
1377
|
-
});
|
|
1378
|
-
|
|
1379
|
-
describe('other classification', () => {
|
|
1380
|
-
it('classifies blog paths', () => {
|
|
1381
|
-
// Note: URL must not contain /docs/, /doc/, etc. earlier in the path since those match first
|
|
1382
|
-
expect(classifyWebContentType('https://mysite.org/blog/article')).toBe('other');
|
|
1383
|
-
});
|
|
1384
|
-
});
|
|
1385
|
-
|
|
1386
|
-
describe('default classification', () => {
|
|
1387
|
-
it('returns documentation for unrecognized paths', () => {
|
|
1388
|
-
// Note: URLs without recognizable patterns default to 'documentation'
|
|
1389
|
-
expect(classifyWebContentType('https://mysite.org/about')).toBe('documentation');
|
|
1390
|
-
expect(classifyWebContentType('https://mysite.org/')).toBe('documentation');
|
|
1391
|
-
});
|
|
1392
|
-
|
|
1393
|
-
it('handles undefined title', () => {
|
|
1394
|
-
expect(classifyWebContentType('https://mysite.org/page')).toBe('documentation');
|
|
1395
|
-
});
|
|
1396
|
-
|
|
1397
|
-
it('handles empty title', () => {
|
|
1398
|
-
expect(classifyWebContentType('https://mysite.org/page', '')).toBe('documentation');
|
|
1399
|
-
});
|
|
1400
|
-
});
|
|
1401
|
-
});
|
|
1402
|
-
|
|
1403
|
-
describe('IndexService - Additional File Type Classification', () => {
|
|
1404
|
-
let indexService: IndexService;
|
|
1405
|
-
let lanceStore: LanceStore;
|
|
1406
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1407
|
-
let tempDir: string;
|
|
1408
|
-
let testFilesDir: string;
|
|
1409
|
-
const storeId = createStoreId('test-store');
|
|
1410
|
-
|
|
1411
|
-
beforeAll(async () => {
|
|
1412
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-addl-filetype-test-'));
|
|
1413
|
-
testFilesDir = join(tempDir, 'files');
|
|
1414
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1415
|
-
|
|
1416
|
-
lanceStore = new LanceStore(tempDir);
|
|
1417
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1418
|
-
|
|
1419
|
-
await embeddingEngine.initialize();
|
|
1420
|
-
await lanceStore.initialize(storeId);
|
|
1421
|
-
|
|
1422
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
1423
|
-
}, 120000);
|
|
1424
|
-
|
|
1425
|
-
afterAll(async () => {
|
|
1426
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1427
|
-
});
|
|
1428
|
-
|
|
1429
|
-
it('classifies changes.md as changelog', async () => {
|
|
1430
|
-
await writeFile(join(testFilesDir, 'changes.md'), '# Changes\n\n## v1.0.0');
|
|
1431
|
-
|
|
1432
|
-
const store: FileStore = {
|
|
1433
|
-
type: 'file',
|
|
1434
|
-
id: storeId,
|
|
1435
|
-
name: 'Test Store',
|
|
1436
|
-
path: testFilesDir,
|
|
1437
|
-
createdAt: new Date(),
|
|
1438
|
-
updatedAt: new Date(),
|
|
1439
|
-
};
|
|
1440
|
-
|
|
1441
|
-
const result = await indexService.indexStore(store);
|
|
1442
|
-
expect(result.success).toBe(true);
|
|
1443
|
-
});
|
|
1444
|
-
|
|
1445
|
-
it('classifies files with changelog in name', async () => {
|
|
1446
|
-
await writeFile(join(testFilesDir, 'project-changelog.md'), '# Project Changelog');
|
|
1447
|
-
|
|
1448
|
-
const store: FileStore = {
|
|
1449
|
-
type: 'file',
|
|
1450
|
-
id: storeId,
|
|
1451
|
-
name: 'Test Store',
|
|
1452
|
-
path: testFilesDir,
|
|
1453
|
-
createdAt: new Date(),
|
|
1454
|
-
updatedAt: new Date(),
|
|
1455
|
-
};
|
|
1456
|
-
|
|
1457
|
-
const result = await indexService.indexStore(store);
|
|
1458
|
-
expect(result.success).toBe(true);
|
|
1459
|
-
});
|
|
1460
|
-
|
|
1461
|
-
it('classifies CONTRIBUTING.md as documentation-primary', async () => {
|
|
1462
|
-
await writeFile(join(testFilesDir, 'CONTRIBUTING.md'), '# Contributing\n\nHow to contribute.');
|
|
1463
|
-
|
|
1464
|
-
const store: FileStore = {
|
|
1465
|
-
type: 'file',
|
|
1466
|
-
id: storeId,
|
|
1467
|
-
name: 'Test Store',
|
|
1468
|
-
path: testFilesDir,
|
|
1469
|
-
createdAt: new Date(),
|
|
1470
|
-
updatedAt: new Date(),
|
|
1471
|
-
};
|
|
1472
|
-
|
|
1473
|
-
const result = await indexService.indexStore(store);
|
|
1474
|
-
expect(result.success).toBe(true);
|
|
1475
|
-
});
|
|
1476
|
-
|
|
1477
|
-
it('classifies files in documentation/ directory', async () => {
|
|
1478
|
-
const docDir = join(testFilesDir, 'documentation');
|
|
1479
|
-
await mkdir(docDir, { recursive: true });
|
|
1480
|
-
await writeFile(join(docDir, 'overview.md'), '# Overview');
|
|
1481
|
-
|
|
1482
|
-
const store: FileStore = {
|
|
1483
|
-
type: 'file',
|
|
1484
|
-
id: storeId,
|
|
1485
|
-
name: 'Test Store',
|
|
1486
|
-
path: testFilesDir,
|
|
1487
|
-
createdAt: new Date(),
|
|
1488
|
-
updatedAt: new Date(),
|
|
1489
|
-
};
|
|
1490
|
-
|
|
1491
|
-
const result = await indexService.indexStore(store);
|
|
1492
|
-
expect(result.success).toBe(true);
|
|
1493
|
-
});
|
|
1494
|
-
|
|
1495
|
-
it('classifies files in guides/ directory', async () => {
|
|
1496
|
-
const guidesDir = join(testFilesDir, 'guides');
|
|
1497
|
-
await mkdir(guidesDir, { recursive: true });
|
|
1498
|
-
await writeFile(join(guidesDir, 'setup.md'), '# Setup Guide');
|
|
1499
|
-
|
|
1500
|
-
const store: FileStore = {
|
|
1501
|
-
type: 'file',
|
|
1502
|
-
id: storeId,
|
|
1503
|
-
name: 'Test Store',
|
|
1504
|
-
path: testFilesDir,
|
|
1505
|
-
createdAt: new Date(),
|
|
1506
|
-
updatedAt: new Date(),
|
|
1507
|
-
};
|
|
1508
|
-
|
|
1509
|
-
const result = await indexService.indexStore(store);
|
|
1510
|
-
expect(result.success).toBe(true);
|
|
1511
|
-
});
|
|
1512
|
-
|
|
1513
|
-
it('classifies files in tutorials/ directory', async () => {
|
|
1514
|
-
const tutorialsDir = join(testFilesDir, 'tutorials');
|
|
1515
|
-
await mkdir(tutorialsDir, { recursive: true });
|
|
1516
|
-
await writeFile(join(tutorialsDir, 'basics.md'), '# Basics Tutorial');
|
|
1517
|
-
|
|
1518
|
-
const store: FileStore = {
|
|
1519
|
-
type: 'file',
|
|
1520
|
-
id: storeId,
|
|
1521
|
-
name: 'Test Store',
|
|
1522
|
-
path: testFilesDir,
|
|
1523
|
-
createdAt: new Date(),
|
|
1524
|
-
updatedAt: new Date(),
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
const result = await indexService.indexStore(store);
|
|
1528
|
-
expect(result.success).toBe(true);
|
|
1529
|
-
});
|
|
1530
|
-
|
|
1531
|
-
it('classifies files in articles/ directory', async () => {
|
|
1532
|
-
const articlesDir = join(testFilesDir, 'articles');
|
|
1533
|
-
await mkdir(articlesDir, { recursive: true });
|
|
1534
|
-
await writeFile(join(articlesDir, 'intro.md'), '# Introduction Article');
|
|
1535
|
-
|
|
1536
|
-
const store: FileStore = {
|
|
1537
|
-
type: 'file',
|
|
1538
|
-
id: storeId,
|
|
1539
|
-
name: 'Test Store',
|
|
1540
|
-
path: testFilesDir,
|
|
1541
|
-
createdAt: new Date(),
|
|
1542
|
-
updatedAt: new Date(),
|
|
1543
|
-
};
|
|
1544
|
-
|
|
1545
|
-
const result = await indexService.indexStore(store);
|
|
1546
|
-
expect(result.success).toBe(true);
|
|
1547
|
-
});
|
|
1548
|
-
|
|
1549
|
-
it('classifies files in __tests__/ directory as test', async () => {
|
|
1550
|
-
const testsDir = join(testFilesDir, '__tests__');
|
|
1551
|
-
await mkdir(testsDir, { recursive: true });
|
|
1552
|
-
await writeFile(join(testsDir, 'util.ts'), 'export function testHelper() {}');
|
|
1553
|
-
|
|
1554
|
-
const store: FileStore = {
|
|
1555
|
-
type: 'file',
|
|
1556
|
-
id: storeId,
|
|
1557
|
-
name: 'Test Store',
|
|
1558
|
-
path: testFilesDir,
|
|
1559
|
-
createdAt: new Date(),
|
|
1560
|
-
updatedAt: new Date(),
|
|
1561
|
-
};
|
|
1562
|
-
|
|
1563
|
-
const result = await indexService.indexStore(store);
|
|
1564
|
-
expect(result.success).toBe(true);
|
|
1565
|
-
});
|
|
1566
|
-
|
|
1567
|
-
it('classifies files with example in filename', async () => {
|
|
1568
|
-
await writeFile(join(testFilesDir, 'example-config.ts'), 'export const config = {};');
|
|
1569
|
-
|
|
1570
|
-
const store: FileStore = {
|
|
1571
|
-
type: 'file',
|
|
1572
|
-
id: storeId,
|
|
1573
|
-
name: 'Test Store',
|
|
1574
|
-
path: testFilesDir,
|
|
1575
|
-
createdAt: new Date(),
|
|
1576
|
-
updatedAt: new Date(),
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
const result = await indexService.indexStore(store);
|
|
1580
|
-
expect(result.success).toBe(true);
|
|
1581
|
-
});
|
|
1582
|
-
|
|
1583
|
-
it('classifies .eslintrc as config', async () => {
|
|
1584
|
-
await writeFile(join(testFilesDir, '.eslintrc.json'), '{}');
|
|
1585
|
-
|
|
1586
|
-
const store: FileStore = {
|
|
1587
|
-
type: 'file',
|
|
1588
|
-
id: storeId,
|
|
1589
|
-
name: 'Test Store',
|
|
1590
|
-
path: testFilesDir,
|
|
1591
|
-
createdAt: new Date(),
|
|
1592
|
-
updatedAt: new Date(),
|
|
1593
|
-
};
|
|
1594
|
-
|
|
1595
|
-
const result = await indexService.indexStore(store);
|
|
1596
|
-
expect(result.success).toBe(true);
|
|
1597
|
-
});
|
|
1598
|
-
|
|
1599
|
-
it('classifies .prettierrc as config', async () => {
|
|
1600
|
-
await writeFile(join(testFilesDir, '.prettierrc.json'), '{}');
|
|
1601
|
-
|
|
1602
|
-
const store: FileStore = {
|
|
1603
|
-
type: 'file',
|
|
1604
|
-
id: storeId,
|
|
1605
|
-
name: 'Test Store',
|
|
1606
|
-
path: testFilesDir,
|
|
1607
|
-
createdAt: new Date(),
|
|
1608
|
-
updatedAt: new Date(),
|
|
1609
|
-
};
|
|
1610
|
-
|
|
1611
|
-
const result = await indexService.indexStore(store);
|
|
1612
|
-
expect(result.success).toBe(true);
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
it('classifies vite.config as config', async () => {
|
|
1616
|
-
await writeFile(join(testFilesDir, 'vite.config.ts'), 'export default {};');
|
|
1617
|
-
|
|
1618
|
-
const store: FileStore = {
|
|
1619
|
-
type: 'file',
|
|
1620
|
-
id: storeId,
|
|
1621
|
-
name: 'Test Store',
|
|
1622
|
-
path: testFilesDir,
|
|
1623
|
-
createdAt: new Date(),
|
|
1624
|
-
updatedAt: new Date(),
|
|
1625
|
-
};
|
|
1626
|
-
|
|
1627
|
-
const result = await indexService.indexStore(store);
|
|
1628
|
-
expect(result.success).toBe(true);
|
|
1629
|
-
});
|
|
1630
|
-
|
|
1631
|
-
it('classifies next.config as config', async () => {
|
|
1632
|
-
await writeFile(join(testFilesDir, 'next.config.js'), 'module.exports = {};');
|
|
1633
|
-
|
|
1634
|
-
const store: FileStore = {
|
|
1635
|
-
type: 'file',
|
|
1636
|
-
id: storeId,
|
|
1637
|
-
name: 'Test Store',
|
|
1638
|
-
path: testFilesDir,
|
|
1639
|
-
createdAt: new Date(),
|
|
1640
|
-
updatedAt: new Date(),
|
|
1641
|
-
};
|
|
1642
|
-
|
|
1643
|
-
const result = await indexService.indexStore(store);
|
|
1644
|
-
expect(result.success).toBe(true);
|
|
1645
|
-
});
|
|
1646
|
-
|
|
1647
|
-
it('classifies .tsx files as source', async () => {
|
|
1648
|
-
await writeFile(join(testFilesDir, 'Component.tsx'), 'export const App = () => <div />;');
|
|
1649
|
-
|
|
1650
|
-
const store: FileStore = {
|
|
1651
|
-
type: 'file',
|
|
1652
|
-
id: storeId,
|
|
1653
|
-
name: 'Test Store',
|
|
1654
|
-
path: testFilesDir,
|
|
1655
|
-
createdAt: new Date(),
|
|
1656
|
-
updatedAt: new Date(),
|
|
1657
|
-
};
|
|
1658
|
-
|
|
1659
|
-
const result = await indexService.indexStore(store);
|
|
1660
|
-
expect(result.success).toBe(true);
|
|
1661
|
-
});
|
|
1662
|
-
|
|
1663
|
-
it('classifies .jsx files as source', async () => {
|
|
1664
|
-
await writeFile(join(testFilesDir, 'Component.jsx'), 'export const App = () => null;');
|
|
1665
|
-
|
|
1666
|
-
const store: FileStore = {
|
|
1667
|
-
type: 'file',
|
|
1668
|
-
id: storeId,
|
|
1669
|
-
name: 'Test Store',
|
|
1670
|
-
path: testFilesDir,
|
|
1671
|
-
createdAt: new Date(),
|
|
1672
|
-
updatedAt: new Date(),
|
|
1673
|
-
};
|
|
1674
|
-
|
|
1675
|
-
const result = await indexService.indexStore(store);
|
|
1676
|
-
expect(result.success).toBe(true);
|
|
1677
|
-
});
|
|
1678
|
-
|
|
1679
|
-
it('classifies .java files as source', async () => {
|
|
1680
|
-
await writeFile(join(testFilesDir, 'Main.java'), 'public class Main {}');
|
|
1681
|
-
|
|
1682
|
-
const store: FileStore = {
|
|
1683
|
-
type: 'file',
|
|
1684
|
-
id: storeId,
|
|
1685
|
-
name: 'Test Store',
|
|
1686
|
-
path: testFilesDir,
|
|
1687
|
-
createdAt: new Date(),
|
|
1688
|
-
updatedAt: new Date(),
|
|
1689
|
-
};
|
|
1690
|
-
|
|
1691
|
-
const result = await indexService.indexStore(store);
|
|
1692
|
-
expect(result.success).toBe(true);
|
|
1693
|
-
});
|
|
1694
|
-
|
|
1695
|
-
it('classifies unknown file types as other', async () => {
|
|
1696
|
-
await writeFile(join(testFilesDir, 'data.csv'), 'a,b,c\n1,2,3');
|
|
1697
|
-
|
|
1698
|
-
const store: FileStore = {
|
|
1699
|
-
type: 'file',
|
|
1700
|
-
id: storeId,
|
|
1701
|
-
name: 'Test Store',
|
|
1702
|
-
path: testFilesDir,
|
|
1703
|
-
createdAt: new Date(),
|
|
1704
|
-
updatedAt: new Date(),
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
const result = await indexService.indexStore(store);
|
|
1708
|
-
expect(result.success).toBe(true);
|
|
1709
|
-
});
|
|
1710
|
-
});
|
|
1711
|
-
|
|
1712
|
-
describe('IndexService - Additional Internal Implementation Detection', () => {
|
|
1713
|
-
let indexService: IndexService;
|
|
1714
|
-
let lanceStore: LanceStore;
|
|
1715
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1716
|
-
let tempDir: string;
|
|
1717
|
-
let testFilesDir: string;
|
|
1718
|
-
const storeId = createStoreId('test-store');
|
|
1719
|
-
|
|
1720
|
-
beforeAll(async () => {
|
|
1721
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-addl-internal-test-'));
|
|
1722
|
-
testFilesDir = join(tempDir, 'files');
|
|
1723
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1724
|
-
|
|
1725
|
-
lanceStore = new LanceStore(tempDir);
|
|
1726
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1727
|
-
|
|
1728
|
-
await embeddingEngine.initialize();
|
|
1729
|
-
await lanceStore.initialize(storeId);
|
|
1730
|
-
|
|
1731
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
1732
|
-
}, 120000);
|
|
1733
|
-
|
|
1734
|
-
afterAll(async () => {
|
|
1735
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1736
|
-
});
|
|
1737
|
-
|
|
1738
|
-
it('treats index.js in packages/*/src/ as public API', async () => {
|
|
1739
|
-
const pkgDir = join(testFilesDir, 'packages', 'ui', 'src');
|
|
1740
|
-
await mkdir(pkgDir, { recursive: true });
|
|
1741
|
-
await writeFile(join(pkgDir, 'index.js'), 'export * from "./components";');
|
|
1742
|
-
|
|
1743
|
-
const store: FileStore = {
|
|
1744
|
-
type: 'file',
|
|
1745
|
-
id: storeId,
|
|
1746
|
-
name: 'Test Store',
|
|
1747
|
-
path: testFilesDir,
|
|
1748
|
-
createdAt: new Date(),
|
|
1749
|
-
updatedAt: new Date(),
|
|
1750
|
-
};
|
|
1751
|
-
|
|
1752
|
-
const result = await indexService.indexStore(store);
|
|
1753
|
-
expect(result.success).toBe(true);
|
|
1754
|
-
});
|
|
1755
|
-
|
|
1756
|
-
it('detects lib/core/ directory files as internal', async () => {
|
|
1757
|
-
const libCoreDir = join(testFilesDir, 'lib', 'core');
|
|
1758
|
-
await mkdir(libCoreDir, { recursive: true });
|
|
1759
|
-
await writeFile(join(libCoreDir, 'internals.ts'), 'export function internal() {}');
|
|
1760
|
-
|
|
1761
|
-
const store: FileStore = {
|
|
1762
|
-
type: 'file',
|
|
1763
|
-
id: storeId,
|
|
1764
|
-
name: 'Test Store',
|
|
1765
|
-
path: testFilesDir,
|
|
1766
|
-
createdAt: new Date(),
|
|
1767
|
-
updatedAt: new Date(),
|
|
1768
|
-
};
|
|
1769
|
-
|
|
1770
|
-
const result = await indexService.indexStore(store);
|
|
1771
|
-
expect(result.success).toBe(true);
|
|
1772
|
-
});
|
|
1773
|
-
|
|
1774
|
-
it('detects core/src/ directory files as internal', async () => {
|
|
1775
|
-
const coreSrcDir = join(testFilesDir, 'core', 'src');
|
|
1776
|
-
await mkdir(coreSrcDir, { recursive: true });
|
|
1777
|
-
await writeFile(join(coreSrcDir, 'engine.ts'), 'export class Engine {}');
|
|
1778
|
-
|
|
1779
|
-
const store: FileStore = {
|
|
1780
|
-
type: 'file',
|
|
1781
|
-
id: storeId,
|
|
1782
|
-
name: 'Test Store',
|
|
1783
|
-
path: testFilesDir,
|
|
1784
|
-
createdAt: new Date(),
|
|
1785
|
-
updatedAt: new Date(),
|
|
1786
|
-
};
|
|
1787
|
-
|
|
1788
|
-
const result = await indexService.indexStore(store);
|
|
1789
|
-
expect(result.success).toBe(true);
|
|
1790
|
-
});
|
|
1791
|
-
|
|
1792
|
-
it('detects _internal/ directory files as internal', async () => {
|
|
1793
|
-
const internalDir = join(testFilesDir, '_internal');
|
|
1794
|
-
await mkdir(internalDir, { recursive: true });
|
|
1795
|
-
await writeFile(join(internalDir, 'utils.ts'), 'export function hidden() {}');
|
|
1796
|
-
|
|
1797
|
-
const store: FileStore = {
|
|
1798
|
-
type: 'file',
|
|
1799
|
-
id: storeId,
|
|
1800
|
-
name: 'Test Store',
|
|
1801
|
-
path: testFilesDir,
|
|
1802
|
-
createdAt: new Date(),
|
|
1803
|
-
updatedAt: new Date(),
|
|
1804
|
-
};
|
|
1805
|
-
|
|
1806
|
-
const result = await indexService.indexStore(store);
|
|
1807
|
-
expect(result.success).toBe(true);
|
|
1808
|
-
});
|
|
1809
|
-
|
|
1810
|
-
it('detects transforms/ directory files as internal', async () => {
|
|
1811
|
-
const transformsDir = join(testFilesDir, 'transforms');
|
|
1812
|
-
await mkdir(transformsDir, { recursive: true });
|
|
1813
|
-
await writeFile(join(transformsDir, 'optimize.ts'), 'export function transform() {}');
|
|
1814
|
-
|
|
1815
|
-
const store: FileStore = {
|
|
1816
|
-
type: 'file',
|
|
1817
|
-
id: storeId,
|
|
1818
|
-
name: 'Test Store',
|
|
1819
|
-
path: testFilesDir,
|
|
1820
|
-
createdAt: new Date(),
|
|
1821
|
-
updatedAt: new Date(),
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
const result = await indexService.indexStore(store);
|
|
1825
|
-
expect(result.success).toBe(true);
|
|
1826
|
-
});
|
|
1827
|
-
|
|
1828
|
-
it('detects parse/ directory files as internal', async () => {
|
|
1829
|
-
const parseDir = join(testFilesDir, 'parse');
|
|
1830
|
-
await mkdir(parseDir, { recursive: true });
|
|
1831
|
-
await writeFile(join(parseDir, 'lexer.ts'), 'export class Lexer {}');
|
|
1832
|
-
|
|
1833
|
-
const store: FileStore = {
|
|
1834
|
-
type: 'file',
|
|
1835
|
-
id: storeId,
|
|
1836
|
-
name: 'Test Store',
|
|
1837
|
-
path: testFilesDir,
|
|
1838
|
-
createdAt: new Date(),
|
|
1839
|
-
updatedAt: new Date(),
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
const result = await indexService.indexStore(store);
|
|
1843
|
-
expect(result.success).toBe(true);
|
|
1844
|
-
});
|
|
1845
|
-
|
|
1846
|
-
it('detects codegen/ directory files as internal', async () => {
|
|
1847
|
-
const codegenDir = join(testFilesDir, 'codegen');
|
|
1848
|
-
await mkdir(codegenDir, { recursive: true });
|
|
1849
|
-
await writeFile(join(codegenDir, 'generator.ts'), 'export class Generator {}');
|
|
1850
|
-
|
|
1851
|
-
const store: FileStore = {
|
|
1852
|
-
type: 'file',
|
|
1853
|
-
id: storeId,
|
|
1854
|
-
name: 'Test Store',
|
|
1855
|
-
path: testFilesDir,
|
|
1856
|
-
createdAt: new Date(),
|
|
1857
|
-
updatedAt: new Date(),
|
|
1858
|
-
};
|
|
1859
|
-
|
|
1860
|
-
const result = await indexService.indexStore(store);
|
|
1861
|
-
expect(result.success).toBe(true);
|
|
1862
|
-
});
|
|
1863
|
-
|
|
1864
|
-
it('does not mark readme in compiler dir as internal', async () => {
|
|
1865
|
-
const compilerDir = join(testFilesDir, 'src', 'compiler');
|
|
1866
|
-
await mkdir(compilerDir, { recursive: true });
|
|
1867
|
-
await writeFile(join(compilerDir, 'README.md'), '# Compiler Documentation');
|
|
1868
|
-
|
|
1869
|
-
const store: FileStore = {
|
|
1870
|
-
type: 'file',
|
|
1871
|
-
id: storeId,
|
|
1872
|
-
name: 'Test Store',
|
|
1873
|
-
path: testFilesDir,
|
|
1874
|
-
createdAt: new Date(),
|
|
1875
|
-
updatedAt: new Date(),
|
|
1876
|
-
};
|
|
1877
|
-
|
|
1878
|
-
const result = await indexService.indexStore(store);
|
|
1879
|
-
expect(result.success).toBe(true);
|
|
1880
|
-
});
|
|
1881
|
-
|
|
1882
|
-
it('does not mark index.ts in compiler dir as internal', async () => {
|
|
1883
|
-
const compilerDir = join(testFilesDir, 'src', 'compiler2');
|
|
1884
|
-
await mkdir(compilerDir, { recursive: true });
|
|
1885
|
-
await writeFile(join(compilerDir, 'index.ts'), 'export * from "./api";');
|
|
1886
|
-
|
|
1887
|
-
const store: FileStore = {
|
|
1888
|
-
type: 'file',
|
|
1889
|
-
id: storeId,
|
|
1890
|
-
name: 'Test Store',
|
|
1891
|
-
path: testFilesDir,
|
|
1892
|
-
createdAt: new Date(),
|
|
1893
|
-
updatedAt: new Date(),
|
|
1894
|
-
};
|
|
1895
|
-
|
|
1896
|
-
const result = await indexService.indexStore(store);
|
|
1897
|
-
expect(result.success).toBe(true);
|
|
1898
|
-
});
|
|
1899
|
-
});
|
|
1900
|
-
|
|
1901
|
-
describe('IndexService - Symlink Handling', () => {
|
|
1902
|
-
let indexService: IndexService;
|
|
1903
|
-
let lanceStore: LanceStore;
|
|
1904
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1905
|
-
let tempDir: string;
|
|
1906
|
-
let testFilesDir: string;
|
|
1907
|
-
const storeId = createStoreId('test-store');
|
|
1908
|
-
|
|
1909
|
-
beforeAll(async () => {
|
|
1910
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-symlink-test-'));
|
|
1911
|
-
testFilesDir = join(tempDir, 'files');
|
|
1912
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1913
|
-
|
|
1914
|
-
lanceStore = new LanceStore(tempDir);
|
|
1915
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1916
|
-
|
|
1917
|
-
await embeddingEngine.initialize();
|
|
1918
|
-
await lanceStore.initialize(storeId);
|
|
1919
|
-
|
|
1920
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
1921
|
-
}, 120000);
|
|
1922
|
-
|
|
1923
|
-
afterAll(async () => {
|
|
1924
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1925
|
-
});
|
|
1926
|
-
|
|
1927
|
-
it('skips symlinks (non-file, non-directory entries)', async () => {
|
|
1928
|
-
// Create a real file
|
|
1929
|
-
await writeFile(join(testFilesDir, 'real.ts'), 'export const real = true;');
|
|
1930
|
-
|
|
1931
|
-
// Create a symlink to the file (symlinks are neither isDirectory() nor isFile() when using withFileTypes)
|
|
1932
|
-
try {
|
|
1933
|
-
await symlink(join(testFilesDir, 'real.ts'), join(testFilesDir, 'link.ts'));
|
|
1934
|
-
} catch {
|
|
1935
|
-
// Symlink creation may fail on some systems/permissions - skip test in that case
|
|
1936
|
-
return;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
const store: FileStore = {
|
|
1940
|
-
type: 'file',
|
|
1941
|
-
id: storeId,
|
|
1942
|
-
name: 'Test Store',
|
|
1943
|
-
path: testFilesDir,
|
|
1944
|
-
createdAt: new Date(),
|
|
1945
|
-
updatedAt: new Date(),
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
const result = await indexService.indexStore(store);
|
|
1949
|
-
|
|
1950
|
-
expect(result.success).toBe(true);
|
|
1951
|
-
// The symlink should be processed if it points to a valid file
|
|
1952
|
-
// (on most systems, readdir with withFileTypes shows symlinks as isFile() if target is file)
|
|
1953
|
-
});
|
|
1954
|
-
});
|
|
1955
|
-
|
|
1956
|
-
describe('IndexService - Batch Embedding', () => {
|
|
1957
|
-
let indexService: IndexService;
|
|
1958
|
-
let lanceStore: LanceStore;
|
|
1959
|
-
let embeddingEngine: EmbeddingEngine;
|
|
1960
|
-
let tempDir: string;
|
|
1961
|
-
let testFilesDir: string;
|
|
1962
|
-
const storeId = createStoreId('batch-embed-test');
|
|
1963
|
-
|
|
1964
|
-
beforeAll(async () => {
|
|
1965
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-batch-embed-test-'));
|
|
1966
|
-
testFilesDir = join(tempDir, 'files');
|
|
1967
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1968
|
-
|
|
1969
|
-
lanceStore = new LanceStore(tempDir);
|
|
1970
|
-
embeddingEngine = new EmbeddingEngine();
|
|
1971
|
-
|
|
1972
|
-
await embeddingEngine.initialize();
|
|
1973
|
-
await lanceStore.initialize(storeId);
|
|
1974
|
-
|
|
1975
|
-
indexService = new IndexService(lanceStore, embeddingEngine);
|
|
1976
|
-
}, 120000);
|
|
1977
|
-
|
|
1978
|
-
afterAll(async () => {
|
|
1979
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
1980
|
-
});
|
|
1981
|
-
|
|
1982
|
-
beforeEach(async () => {
|
|
1983
|
-
// Clear test directory for fresh state
|
|
1984
|
-
await rm(testFilesDir, { recursive: true, force: true });
|
|
1985
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
1986
|
-
});
|
|
1987
|
-
|
|
1988
|
-
it('calls embedBatch instead of sequential embed for multiple chunks', async () => {
|
|
1989
|
-
// Create a file large enough to produce multiple chunks (>1500 chars)
|
|
1990
|
-
const largeContent = Array(50)
|
|
1991
|
-
.fill('This is a paragraph of text that will be chunked. ')
|
|
1992
|
-
.join('\n\n');
|
|
1993
|
-
await writeFile(join(testFilesDir, 'large.md'), largeContent);
|
|
1994
|
-
|
|
1995
|
-
const embedBatchSpy = vi.spyOn(embeddingEngine, 'embedBatch');
|
|
1996
|
-
|
|
1997
|
-
const store: FileStore = {
|
|
1998
|
-
type: 'file',
|
|
1999
|
-
id: storeId,
|
|
2000
|
-
name: 'Batch Embed Test Store',
|
|
2001
|
-
path: testFilesDir,
|
|
2002
|
-
createdAt: new Date(),
|
|
2003
|
-
updatedAt: new Date(),
|
|
2004
|
-
};
|
|
2005
|
-
|
|
2006
|
-
const result = await indexService.indexStore(store);
|
|
2007
|
-
|
|
2008
|
-
expect(result.success).toBe(true);
|
|
2009
|
-
if (result.success) {
|
|
2010
|
-
// Should have created multiple chunks
|
|
2011
|
-
expect(result.data.chunksCreated).toBeGreaterThan(1);
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
// embedBatch should be called (it internally uses embed via Promise.all)
|
|
2015
|
-
expect(embedBatchSpy).toHaveBeenCalled();
|
|
2016
|
-
// Verify batch was called with multiple items
|
|
2017
|
-
const callArgs = embedBatchSpy.mock.calls[0];
|
|
2018
|
-
expect(callArgs).toBeDefined();
|
|
2019
|
-
expect(callArgs[0].length).toBeGreaterThan(1);
|
|
2020
|
-
|
|
2021
|
-
embedBatchSpy.mockRestore();
|
|
2022
|
-
});
|
|
2023
|
-
|
|
2024
|
-
it('preserves chunk order when using batch embedding', async () => {
|
|
2025
|
-
// Create file with distinct, ordered sections that will produce multiple chunks
|
|
2026
|
-
const sections = Array(10)
|
|
2027
|
-
.fill(null)
|
|
2028
|
-
.map((_, i) => `# Section ${String(i + 1)}\n\n${'Content for section. '.repeat(50)}`)
|
|
2029
|
-
.join('\n\n');
|
|
2030
|
-
|
|
2031
|
-
await writeFile(join(testFilesDir, 'ordered.md'), sections);
|
|
2032
|
-
|
|
2033
|
-
const embedBatchSpy = vi.spyOn(embeddingEngine, 'embedBatch');
|
|
2034
|
-
|
|
2035
|
-
const store: FileStore = {
|
|
2036
|
-
type: 'file',
|
|
2037
|
-
id: storeId,
|
|
2038
|
-
name: 'Order Test Store',
|
|
2039
|
-
path: testFilesDir,
|
|
2040
|
-
createdAt: new Date(),
|
|
2041
|
-
updatedAt: new Date(),
|
|
2042
|
-
};
|
|
2043
|
-
|
|
2044
|
-
const result = await indexService.indexStore(store);
|
|
2045
|
-
|
|
2046
|
-
expect(result.success).toBe(true);
|
|
2047
|
-
if (result.success) {
|
|
2048
|
-
// Verify chunks are in correct order
|
|
2049
|
-
expect(result.data.chunksCreated).toBeGreaterThan(1);
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
// embedBatch should be called with chunks in order
|
|
2053
|
-
expect(embedBatchSpy).toHaveBeenCalled();
|
|
2054
|
-
const callArgs = embedBatchSpy.mock.calls[0];
|
|
2055
|
-
expect(callArgs).toBeDefined();
|
|
2056
|
-
|
|
2057
|
-
// Verify that if content has "Section 1", it comes before "Section 2" in the array
|
|
2058
|
-
const batchedTexts = callArgs[0];
|
|
2059
|
-
const section1Index = batchedTexts.findIndex((t: string) => t.includes('Section 1'));
|
|
2060
|
-
const section2Index = batchedTexts.findIndex((t: string) => t.includes('Section 2'));
|
|
2061
|
-
|
|
2062
|
-
// Section 1 should appear before Section 2 in the batch (or they may be in different chunks)
|
|
2063
|
-
if (section1Index !== -1 && section2Index !== -1) {
|
|
2064
|
-
expect(section1Index).toBeLessThan(section2Index);
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
embedBatchSpy.mockRestore();
|
|
2068
|
-
});
|
|
2069
|
-
|
|
2070
|
-
it('handles single-chunk files correctly', async () => {
|
|
2071
|
-
// Create a small file that won't be chunked
|
|
2072
|
-
await writeFile(join(testFilesDir, 'small.ts'), 'export const x = 42;');
|
|
2073
|
-
|
|
2074
|
-
const embedBatchSpy = vi.spyOn(embeddingEngine, 'embedBatch');
|
|
2075
|
-
|
|
2076
|
-
const store: FileStore = {
|
|
2077
|
-
type: 'file',
|
|
2078
|
-
id: storeId,
|
|
2079
|
-
name: 'Single Chunk Test Store',
|
|
2080
|
-
path: testFilesDir,
|
|
2081
|
-
createdAt: new Date(),
|
|
2082
|
-
updatedAt: new Date(),
|
|
2083
|
-
};
|
|
2084
|
-
|
|
2085
|
-
const result = await indexService.indexStore(store);
|
|
2086
|
-
|
|
2087
|
-
expect(result.success).toBe(true);
|
|
2088
|
-
if (result.success) {
|
|
2089
|
-
// Should have exactly one chunk
|
|
2090
|
-
expect(result.data.chunksCreated).toBe(1);
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
// embedBatch should still be called (with a single item)
|
|
2094
|
-
expect(embedBatchSpy).toHaveBeenCalled();
|
|
2095
|
-
|
|
2096
|
-
embedBatchSpy.mockRestore();
|
|
2097
|
-
});
|
|
2098
|
-
|
|
2099
|
-
it('handles multiple files with batch embedding', async () => {
|
|
2100
|
-
// Create multiple files to verify batch embedding works across files
|
|
2101
|
-
await writeFile(join(testFilesDir, 'file1.ts'), 'export const a = 1;');
|
|
2102
|
-
await writeFile(join(testFilesDir, 'file2.ts'), 'export const b = 2;');
|
|
2103
|
-
await writeFile(join(testFilesDir, 'file3.ts'), 'export const c = 3;');
|
|
2104
|
-
|
|
2105
|
-
const embedBatchSpy = vi.spyOn(embeddingEngine, 'embedBatch');
|
|
2106
|
-
|
|
2107
|
-
const multiStoreId = createStoreId('multi-file-test');
|
|
2108
|
-
await lanceStore.initialize(multiStoreId);
|
|
2109
|
-
|
|
2110
|
-
const multiIndexService = new IndexService(lanceStore, embeddingEngine);
|
|
2111
|
-
|
|
2112
|
-
const store: FileStore = {
|
|
2113
|
-
type: 'file',
|
|
2114
|
-
id: multiStoreId,
|
|
2115
|
-
name: 'Multi File Test Store',
|
|
2116
|
-
path: testFilesDir,
|
|
2117
|
-
createdAt: new Date(),
|
|
2118
|
-
updatedAt: new Date(),
|
|
2119
|
-
};
|
|
2120
|
-
|
|
2121
|
-
const result = await multiIndexService.indexStore(store);
|
|
2122
|
-
|
|
2123
|
-
expect(result.success).toBe(true);
|
|
2124
|
-
if (result.success) {
|
|
2125
|
-
// Should index all 3 files
|
|
2126
|
-
expect(result.data.documentsIndexed).toBe(3);
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
// embedBatch should be called once per file (3 times)
|
|
2130
|
-
expect(embedBatchSpy).toHaveBeenCalledTimes(3);
|
|
2131
|
-
|
|
2132
|
-
embedBatchSpy.mockRestore();
|
|
2133
|
-
});
|
|
2134
|
-
});
|
|
2135
|
-
|
|
2136
|
-
describe('IndexService - Parallel File Processing', () => {
|
|
2137
|
-
let lanceStore: LanceStore;
|
|
2138
|
-
let embeddingEngine: EmbeddingEngine;
|
|
2139
|
-
let tempDir: string;
|
|
2140
|
-
let testFilesDir: string;
|
|
2141
|
-
const storeId = createStoreId('parallel-test');
|
|
2142
|
-
|
|
2143
|
-
beforeAll(async () => {
|
|
2144
|
-
tempDir = await mkdtemp(join(tmpdir(), 'index-parallel-test-'));
|
|
2145
|
-
testFilesDir = join(tempDir, 'files');
|
|
2146
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
2147
|
-
|
|
2148
|
-
lanceStore = new LanceStore(tempDir);
|
|
2149
|
-
embeddingEngine = new EmbeddingEngine();
|
|
2150
|
-
|
|
2151
|
-
await embeddingEngine.initialize();
|
|
2152
|
-
await lanceStore.initialize(storeId);
|
|
2153
|
-
}, 120000);
|
|
2154
|
-
|
|
2155
|
-
afterAll(async () => {
|
|
2156
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
2157
|
-
});
|
|
2158
|
-
|
|
2159
|
-
beforeEach(async () => {
|
|
2160
|
-
// Clear test directory for fresh state
|
|
2161
|
-
await rm(testFilesDir, { recursive: true, force: true });
|
|
2162
|
-
await mkdir(testFilesDir, { recursive: true });
|
|
2163
|
-
});
|
|
2164
|
-
|
|
2165
|
-
it('uses concurrency option from IndexService constructor', async () => {
|
|
2166
|
-
// Create 10 test files
|
|
2167
|
-
for (let i = 0; i < 10; i++) {
|
|
2168
|
-
await writeFile(
|
|
2169
|
-
join(testFilesDir, `file${String(i)}.ts`),
|
|
2170
|
-
`export const x${String(i)} = ${String(i)};`
|
|
2171
|
-
);
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
// Track when files start being processed
|
|
2175
|
-
const processingTimestamps: number[] = [];
|
|
2176
|
-
const originalEmbedBatch = embeddingEngine.embedBatch.bind(embeddingEngine);
|
|
2177
|
-
|
|
2178
|
-
vi.spyOn(embeddingEngine, 'embedBatch').mockImplementation(async (texts: string[]) => {
|
|
2179
|
-
processingTimestamps.push(Date.now());
|
|
2180
|
-
// Small delay to simulate processing time
|
|
2181
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
2182
|
-
return originalEmbedBatch(texts);
|
|
2183
|
-
});
|
|
2184
|
-
|
|
2185
|
-
const concurrency = 4;
|
|
2186
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, { concurrency });
|
|
2187
|
-
|
|
2188
|
-
const parallelStoreId = createStoreId('parallel-concurrency-test');
|
|
2189
|
-
await lanceStore.initialize(parallelStoreId);
|
|
2190
|
-
|
|
2191
|
-
const store: FileStore = {
|
|
2192
|
-
type: 'file',
|
|
2193
|
-
id: parallelStoreId,
|
|
2194
|
-
name: 'Parallel Test Store',
|
|
2195
|
-
path: testFilesDir,
|
|
2196
|
-
createdAt: new Date(),
|
|
2197
|
-
updatedAt: new Date(),
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
|
-
const result = await indexService.indexStore(store);
|
|
2201
|
-
|
|
2202
|
-
expect(result.success).toBe(true);
|
|
2203
|
-
if (result.success) {
|
|
2204
|
-
expect(result.data.documentsIndexed).toBe(10);
|
|
2205
|
-
}
|
|
2206
|
-
|
|
2207
|
-
vi.restoreAllMocks();
|
|
2208
|
-
});
|
|
2209
|
-
|
|
2210
|
-
it('reports progress correctly with parallel processing', async () => {
|
|
2211
|
-
// Create test files
|
|
2212
|
-
for (let i = 0; i < 5; i++) {
|
|
2213
|
-
await writeFile(
|
|
2214
|
-
join(testFilesDir, `progress${String(i)}.ts`),
|
|
2215
|
-
`export const p${String(i)} = ${String(i)};`
|
|
2216
|
-
);
|
|
2217
|
-
}
|
|
2218
|
-
|
|
2219
|
-
const concurrency = 2;
|
|
2220
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, { concurrency });
|
|
2221
|
-
|
|
2222
|
-
const progressStoreId = createStoreId('progress-test');
|
|
2223
|
-
await lanceStore.initialize(progressStoreId);
|
|
2224
|
-
|
|
2225
|
-
const store: FileStore = {
|
|
2226
|
-
type: 'file',
|
|
2227
|
-
id: progressStoreId,
|
|
2228
|
-
name: 'Progress Test Store',
|
|
2229
|
-
path: testFilesDir,
|
|
2230
|
-
createdAt: new Date(),
|
|
2231
|
-
updatedAt: new Date(),
|
|
2232
|
-
};
|
|
2233
|
-
|
|
2234
|
-
const progressEvents: Array<{ type: string; current: number; total: number }> = [];
|
|
2235
|
-
const onProgress = (event: { type: string; current: number; total: number }): void => {
|
|
2236
|
-
progressEvents.push(event);
|
|
2237
|
-
};
|
|
2238
|
-
|
|
2239
|
-
const result = await indexService.indexStore(store, onProgress);
|
|
2240
|
-
|
|
2241
|
-
expect(result.success).toBe(true);
|
|
2242
|
-
|
|
2243
|
-
// Should have start event
|
|
2244
|
-
expect(progressEvents.some((e) => e.type === 'start')).toBe(true);
|
|
2245
|
-
|
|
2246
|
-
// Should have progress events
|
|
2247
|
-
const progressOnly = progressEvents.filter((e) => e.type === 'progress');
|
|
2248
|
-
expect(progressOnly.length).toBeGreaterThan(0);
|
|
2249
|
-
|
|
2250
|
-
// Should have complete event
|
|
2251
|
-
expect(progressEvents.some((e) => e.type === 'complete')).toBe(true);
|
|
2252
|
-
|
|
2253
|
-
// Current should never exceed total
|
|
2254
|
-
for (const event of progressEvents) {
|
|
2255
|
-
expect(event.current).toBeLessThanOrEqual(event.total);
|
|
2256
|
-
}
|
|
2257
|
-
});
|
|
2258
|
-
|
|
2259
|
-
it('continues processing remaining files if one file fails to read', async () => {
|
|
2260
|
-
// Create valid test files
|
|
2261
|
-
await writeFile(join(testFilesDir, 'valid1.ts'), 'export const a = 1;');
|
|
2262
|
-
await writeFile(join(testFilesDir, 'valid2.ts'), 'export const b = 2;');
|
|
2263
|
-
await writeFile(join(testFilesDir, 'valid3.ts'), 'export const c = 3;');
|
|
2264
|
-
|
|
2265
|
-
// Create a file that will fail to read (remove read permission)
|
|
2266
|
-
const unreadablePath = join(testFilesDir, 'unreadable.ts');
|
|
2267
|
-
await writeFile(unreadablePath, 'export const x = 999;');
|
|
2268
|
-
await chmod(unreadablePath, 0o000);
|
|
2269
|
-
|
|
2270
|
-
const concurrency = 2;
|
|
2271
|
-
const indexService = new IndexService(lanceStore, embeddingEngine, { concurrency });
|
|
2272
|
-
|
|
2273
|
-
const errorStoreId = createStoreId('error-handling-test');
|
|
2274
|
-
await lanceStore.initialize(errorStoreId);
|
|
2275
|
-
|
|
2276
|
-
const store: FileStore = {
|
|
2277
|
-
type: 'file',
|
|
2278
|
-
id: errorStoreId,
|
|
2279
|
-
name: 'Error Handling Test Store',
|
|
2280
|
-
path: testFilesDir,
|
|
2281
|
-
createdAt: new Date(),
|
|
2282
|
-
updatedAt: new Date(),
|
|
2283
|
-
};
|
|
2284
|
-
|
|
2285
|
-
// The indexing should either succeed with partial results or fail gracefully
|
|
2286
|
-
const result = await indexService.indexStore(store);
|
|
2287
|
-
|
|
2288
|
-
// Restore permissions for cleanup
|
|
2289
|
-
await chmod(unreadablePath, 0o644);
|
|
2290
|
-
|
|
2291
|
-
// With current implementation, it may fail completely on the first error
|
|
2292
|
-
// This test documents the current behavior
|
|
2293
|
-
if (result.success) {
|
|
2294
|
-
// If it succeeds, it should have indexed at least the valid files
|
|
2295
|
-
expect(result.data.documentsIndexed).toBeGreaterThanOrEqual(0);
|
|
2296
|
-
} else {
|
|
2297
|
-
// If it fails, it should have an error
|
|
2298
|
-
expect(result.error).toBeDefined();
|
|
2299
|
-
}
|
|
2300
|
-
});
|
|
2301
|
-
});
|