docorbit 0.1.0 → 0.1.2
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/README.md +29 -15
- package/bin/docorbit.js +2 -2
- package/dist/apps/cli/src/commands/add.d.ts +7 -0
- package/dist/apps/cli/src/commands/add.js +35 -0
- package/dist/apps/cli/src/commands/api.d.ts +2 -0
- package/dist/apps/cli/src/commands/api.js +35 -0
- package/dist/apps/cli/src/commands/context.d.ts +10 -0
- package/dist/apps/cli/src/commands/context.js +36 -0
- package/dist/apps/cli/src/commands/dashboard.d.ts +8 -0
- package/dist/apps/cli/src/commands/dashboard.js +43 -0
- package/dist/apps/cli/src/commands/diff.d.ts +2 -0
- package/dist/apps/cli/src/commands/diff.js +29 -0
- package/dist/apps/cli/src/commands/evaluate.d.ts +11 -0
- package/dist/apps/cli/src/commands/evaluate.js +101 -0
- package/dist/apps/cli/src/commands/examples.d.ts +2 -0
- package/dist/apps/cli/src/commands/examples.js +36 -0
- package/dist/apps/cli/src/commands/export.d.ts +11 -0
- package/dist/apps/cli/src/commands/export.js +72 -0
- package/dist/apps/cli/src/commands/impact.d.ts +2 -0
- package/dist/apps/cli/src/commands/impact.js +30 -0
- package/dist/apps/cli/src/commands/init.d.ts +5 -0
- package/dist/apps/cli/src/commands/init.js +52 -0
- package/dist/apps/cli/src/commands/inspect.d.ts +5 -0
- package/dist/apps/cli/src/commands/inspect.js +24 -0
- package/dist/apps/cli/src/commands/mcp.d.ts +8 -0
- package/dist/apps/cli/src/commands/mcp.js +49 -0
- package/dist/apps/cli/src/commands/pitfalls.d.ts +2 -0
- package/dist/apps/cli/src/commands/pitfalls.js +35 -0
- package/dist/apps/cli/src/commands/recipes.d.ts +2 -0
- package/dist/apps/cli/src/commands/recipes.js +33 -0
- package/dist/apps/cli/src/commands/search.d.ts +11 -0
- package/dist/apps/cli/src/commands/search.js +36 -0
- package/dist/apps/cli/src/commands/update.d.ts +6 -0
- package/dist/apps/cli/src/commands/update.js +53 -0
- package/dist/apps/cli/src/commands/verify.d.ts +2 -0
- package/dist/apps/cli/src/commands/verify.js +44 -0
- package/dist/apps/cli/src/formatters/colors.d.ts +21 -0
- package/dist/apps/cli/src/formatters/colors.js +22 -0
- package/dist/apps/cli/src/formatters/inspection.d.ts +3 -0
- package/dist/apps/cli/src/formatters/inspection.js +88 -0
- package/dist/apps/cli/src/formatters/knowledge.d.ts +5 -0
- package/dist/apps/cli/src/formatters/knowledge.js +229 -0
- package/dist/apps/cli/src/formatters/retrieval.d.ts +3 -0
- package/dist/apps/cli/src/formatters/retrieval.js +61 -0
- package/{apps/cli/src/formatters/terminal.ts → dist/apps/cli/src/formatters/terminal.d.ts} +0 -1
- package/dist/apps/cli/src/formatters/terminal.js +5 -0
- package/dist/apps/cli/src/formatters/verification.d.ts +4 -0
- package/dist/apps/cli/src/formatters/verification.js +102 -0
- package/dist/apps/cli/src/index.d.ts +1 -0
- package/dist/apps/cli/src/index.js +376 -0
- package/dist/packages/core/src/dashboard/server.d.ts +33 -0
- package/dist/packages/core/src/dashboard/server.js +267 -0
- package/dist/packages/core/src/dashboard/ui.d.ts +5 -0
- package/{packages/core/src/dashboard/ui.ts → dist/packages/core/src/dashboard/ui.js} +2 -2
- package/dist/packages/core/src/implementation-service.d.ts +73 -0
- package/dist/packages/core/src/implementation-service.js +325 -0
- package/{packages/core/src/index.ts → dist/packages/core/src/index.d.ts} +0 -1
- package/dist/packages/core/src/index.js +6 -0
- package/dist/packages/core/src/inspector.d.ts +22 -0
- package/dist/packages/core/src/inspector.js +38 -0
- package/dist/packages/core/src/pipeline.d.ts +45 -0
- package/dist/packages/core/src/pipeline.js +246 -0
- package/dist/packages/crawler/src/config.d.ts +2 -0
- package/dist/packages/crawler/src/config.js +10 -0
- package/dist/packages/crawler/src/fetcher.d.ts +31 -0
- package/dist/packages/crawler/src/fetcher.js +139 -0
- package/dist/packages/crawler/src/index.js +2 -0
- package/dist/packages/discovery/src/index.d.ts +11 -0
- package/dist/packages/discovery/src/index.js +29 -0
- package/dist/packages/discovery/src/provider.d.ts +12 -0
- package/dist/packages/discovery/src/provider.js +30 -0
- package/dist/packages/discovery/src/providers/generic.d.ts +7 -0
- package/dist/packages/discovery/src/providers/generic.js +94 -0
- package/dist/packages/discovery/src/providers/github.d.ts +7 -0
- package/dist/packages/discovery/src/providers/github.js +52 -0
- package/dist/packages/discovery/src/providers/llms-txt.d.ts +7 -0
- package/dist/packages/discovery/src/providers/llms-txt.js +60 -0
- package/dist/packages/discovery/src/providers/markdown.d.ts +7 -0
- package/dist/packages/discovery/src/providers/markdown.js +38 -0
- package/dist/packages/discovery/src/providers/openapi.d.ts +7 -0
- package/dist/packages/discovery/src/providers/openapi.js +77 -0
- package/dist/packages/discovery/src/providers/sitemap.d.ts +7 -0
- package/dist/packages/discovery/src/providers/sitemap.js +53 -0
- package/dist/packages/discovery/src/providers/skill.d.ts +7 -0
- package/dist/packages/discovery/src/providers/skill.js +46 -0
- package/dist/packages/discovery/src/ranker.d.ts +6 -0
- package/dist/packages/discovery/src/ranker.js +107 -0
- package/dist/packages/evaluation/src/dataset.d.ts +2 -0
- package/dist/packages/evaluation/src/dataset.js +944 -0
- package/dist/packages/evaluation/src/index.js +8 -0
- package/dist/packages/evaluation/src/runner.d.ts +7 -0
- package/dist/packages/evaluation/src/runner.js +196 -0
- package/dist/packages/evaluation/src/strategies/context7-runner.d.ts +24 -0
- package/dist/packages/evaluation/src/strategies/context7-runner.js +229 -0
- package/dist/packages/evaluation/src/strategies/docorbit-runner.d.ts +5 -0
- package/dist/packages/evaluation/src/strategies/docorbit-runner.js +210 -0
- package/dist/packages/evaluation/src/strategies/firecrawl-runner.d.ts +24 -0
- package/dist/packages/evaluation/src/strategies/firecrawl-runner.js +151 -0
- package/dist/packages/evaluation/src/strategies/web-search-runner.d.ts +32 -0
- package/dist/packages/evaluation/src/strategies/web-search-runner.js +161 -0
- package/dist/packages/evaluation/src/types.d.ts +15 -0
- package/dist/packages/evaluation/src/types.js +1 -0
- package/dist/packages/evaluation/src/version-matcher.d.ts +11 -0
- package/dist/packages/evaluation/src/version-matcher.js +61 -0
- package/dist/packages/export/src/agents-md.d.ts +19 -0
- package/dist/packages/export/src/agents-md.js +170 -0
- package/dist/packages/export/src/claude-md.d.ts +17 -0
- package/dist/packages/export/src/claude-md.js +118 -0
- package/dist/packages/export/src/docs-map.d.ts +14 -0
- package/dist/packages/export/src/docs-map.js +118 -0
- package/dist/packages/export/src/index.js +6 -0
- package/dist/packages/export/src/llms-txt.d.ts +15 -0
- package/dist/packages/export/src/llms-txt.js +73 -0
- package/dist/packages/export/src/service.d.ts +23 -0
- package/dist/packages/export/src/service.js +210 -0
- package/dist/packages/export/src/skill-md.d.ts +14 -0
- package/dist/packages/export/src/skill-md.js +107 -0
- package/{packages/mcp/src/index.ts → dist/packages/mcp/src/index.d.ts} +2 -35
- package/dist/packages/mcp/src/index.js +6 -0
- package/dist/packages/mcp/src/resources/index.d.ts +12 -0
- package/dist/packages/mcp/src/resources/index.js +165 -0
- package/dist/packages/mcp/src/server.d.ts +30 -0
- package/dist/packages/mcp/src/server.js +243 -0
- package/dist/packages/mcp/src/tools/analyze-impact.d.ts +6 -0
- package/dist/packages/mcp/src/tools/analyze-impact.js +64 -0
- package/dist/packages/mcp/src/tools/check-api.d.ts +6 -0
- package/dist/packages/mcp/src/tools/check-api.js +74 -0
- package/dist/packages/mcp/src/tools/diff-docs.d.ts +6 -0
- package/dist/packages/mcp/src/tools/diff-docs.js +58 -0
- package/dist/packages/mcp/src/tools/export-context.d.ts +6 -0
- package/dist/packages/mcp/src/tools/export-context.js +61 -0
- package/dist/packages/mcp/src/tools/find-api.d.ts +6 -0
- package/dist/packages/mcp/src/tools/find-api.js +91 -0
- package/dist/packages/mcp/src/tools/find-example.d.ts +6 -0
- package/dist/packages/mcp/src/tools/find-example.js +92 -0
- package/dist/packages/mcp/src/tools/find-pitfall.d.ts +6 -0
- package/dist/packages/mcp/src/tools/find-pitfall.js +85 -0
- package/dist/packages/mcp/src/tools/find-recipe.d.ts +6 -0
- package/dist/packages/mcp/src/tools/find-recipe.js +89 -0
- package/dist/packages/mcp/src/tools/get-doc.d.ts +6 -0
- package/dist/packages/mcp/src/tools/get-doc.js +118 -0
- package/dist/packages/mcp/src/tools/get-docs-map.d.ts +6 -0
- package/dist/packages/mcp/src/tools/get-docs-map.js +54 -0
- package/dist/packages/mcp/src/tools/get-version.d.ts +6 -0
- package/dist/packages/mcp/src/tools/get-version.js +104 -0
- package/dist/packages/mcp/src/tools/implementation-context.d.ts +6 -0
- package/dist/packages/mcp/src/tools/implementation-context.js +102 -0
- package/dist/packages/mcp/src/tools/index.d.ts +19 -0
- package/dist/packages/mcp/src/tools/index.js +41 -0
- package/dist/packages/mcp/src/tools/ingest-doc.d.ts +6 -0
- package/dist/packages/mcp/src/tools/ingest-doc.js +264 -0
- package/dist/packages/mcp/src/tools/list-sources.d.ts +6 -0
- package/dist/packages/mcp/src/tools/list-sources.js +76 -0
- package/dist/packages/mcp/src/tools/search-docs.d.ts +6 -0
- package/dist/packages/mcp/src/tools/search-docs.js +113 -0
- package/dist/packages/mcp/src/tools/types.d.ts +22 -0
- package/dist/packages/mcp/src/tools/types.js +1 -0
- package/dist/packages/mcp/src/transports/http.d.ts +31 -0
- package/dist/packages/mcp/src/transports/http.js +215 -0
- package/dist/packages/mcp/src/transports/stdio.d.ts +22 -0
- package/dist/packages/mcp/src/transports/stdio.js +86 -0
- package/{packages/mcp/src/transports/types.ts → dist/packages/mcp/src/transports/types.d.ts} +2 -3
- package/dist/packages/mcp/src/transports/types.js +1 -0
- package/dist/packages/mcp/src/types.d.ts +89 -0
- package/dist/packages/mcp/src/types.js +7 -0
- package/dist/packages/normalizer/src/example-indexer.d.ts +5 -0
- package/dist/packages/normalizer/src/example-indexer.js +200 -0
- package/dist/packages/normalizer/src/html.d.ts +13 -0
- package/dist/packages/normalizer/src/html.js +221 -0
- package/{packages/normalizer/src/index.ts → dist/packages/normalizer/src/index.d.ts} +0 -1
- package/dist/packages/normalizer/src/index.js +7 -0
- package/dist/packages/normalizer/src/llms.d.ts +3 -0
- package/dist/packages/normalizer/src/llms.js +71 -0
- package/dist/packages/normalizer/src/openapi/endpoint-parser.d.ts +11 -0
- package/dist/packages/normalizer/src/openapi/endpoint-parser.js +357 -0
- package/dist/packages/normalizer/src/openapi/schema-resolver.d.ts +10 -0
- package/dist/packages/normalizer/src/openapi/schema-resolver.js +82 -0
- package/dist/packages/normalizer/src/openapi.js +2 -0
- package/dist/packages/normalizer/src/page.d.ts +13 -0
- package/dist/packages/normalizer/src/page.js +150 -0
- package/dist/packages/normalizer/src/pitfall-extractor.d.ts +6 -0
- package/dist/packages/normalizer/src/pitfall-extractor.js +153 -0
- package/dist/packages/normalizer/src/slicer.d.ts +30 -0
- package/dist/packages/normalizer/src/slicer.js +360 -0
- package/dist/packages/retrieval/src/engine.d.ts +17 -0
- package/dist/packages/retrieval/src/engine.js +93 -0
- package/{packages/retrieval/src/index.ts → dist/packages/retrieval/src/index.d.ts} +0 -1
- package/dist/packages/retrieval/src/index.js +6 -0
- package/dist/packages/retrieval/src/intent.d.ts +6 -0
- package/dist/packages/retrieval/src/intent.js +39 -0
- package/dist/packages/retrieval/src/packer.d.ts +2 -0
- package/dist/packages/retrieval/src/packer.js +108 -0
- package/dist/packages/retrieval/src/recipe-engine.d.ts +18 -0
- package/dist/packages/retrieval/src/recipe-engine.js +265 -0
- package/dist/packages/retrieval/src/scorer.d.ts +13 -0
- package/dist/packages/retrieval/src/scorer.js +110 -0
- package/dist/packages/retrieval/src/weights.d.ts +3 -0
- package/dist/packages/retrieval/src/weights.js +28 -0
- package/dist/packages/security/src/annotations.d.ts +10 -0
- package/dist/packages/security/src/annotations.js +100 -0
- package/dist/packages/security/src/index.js +2 -0
- package/dist/packages/security/src/ssrf.d.ts +17 -0
- package/dist/packages/security/src/ssrf.js +132 -0
- package/dist/packages/shared/src/errors.d.ts +22 -0
- package/dist/packages/shared/src/errors.js +44 -0
- package/dist/packages/shared/src/hashing.d.ts +3 -0
- package/dist/packages/shared/src/hashing.js +21 -0
- package/dist/packages/shared/src/index.js +3 -0
- package/dist/packages/shared/src/types.d.ts +715 -0
- package/dist/packages/shared/src/types.js +1 -0
- package/dist/packages/storage/src/db.d.ts +11 -0
- package/dist/packages/storage/src/db.js +128 -0
- package/dist/packages/storage/src/index.js +10 -0
- package/dist/packages/storage/src/interfaces.d.ts +83 -0
- package/dist/packages/storage/src/interfaces.js +1 -0
- package/dist/packages/storage/src/repositories/api-repository.d.ts +16 -0
- package/dist/packages/storage/src/repositories/api-repository.js +169 -0
- package/dist/packages/storage/src/repositories/chunk-repository.d.ts +32 -0
- package/dist/packages/storage/src/repositories/chunk-repository.js +250 -0
- package/dist/packages/storage/src/repositories/example-repository.d.ts +16 -0
- package/dist/packages/storage/src/repositories/example-repository.js +158 -0
- package/dist/packages/storage/src/repositories/page-repository.d.ts +16 -0
- package/dist/packages/storage/src/repositories/page-repository.js +161 -0
- package/dist/packages/storage/src/repositories/pitfall-repository.d.ts +15 -0
- package/dist/packages/storage/src/repositories/pitfall-repository.js +144 -0
- package/dist/packages/storage/src/repositories/source-repository.d.ts +33 -0
- package/dist/packages/storage/src/repositories/source-repository.js +153 -0
- package/dist/packages/storage/src/repository.d.ts +92 -0
- package/dist/packages/storage/src/repository.js +157 -0
- package/dist/packages/storage/src/schema.d.ts +2 -0
- package/{packages/storage/src/schema.ts → dist/packages/storage/src/schema.js} +0 -3
- package/dist/packages/storage/src/search-tokens.d.ts +6 -0
- package/dist/packages/storage/src/search-tokens.js +26 -0
- package/dist/packages/verification/src/diff-engine.d.ts +18 -0
- package/dist/packages/verification/src/diff-engine.js +218 -0
- package/dist/packages/verification/src/extractor.d.ts +29 -0
- package/dist/packages/verification/src/extractor.js +302 -0
- package/dist/packages/verification/src/impact-scanner.d.ts +9 -0
- package/dist/packages/verification/src/impact-scanner.js +181 -0
- package/dist/packages/verification/src/index.js +5 -0
- package/dist/packages/verification/src/services.d.ts +55 -0
- package/dist/packages/verification/src/services.js +189 -0
- package/dist/packages/verification/src/verifier.d.ts +15 -0
- package/dist/packages/verification/src/verifier.js +315 -0
- package/dist/packages/workspace/src/detector.d.ts +7 -0
- package/dist/packages/workspace/src/detector.js +117 -0
- package/dist/packages/workspace/src/ecosystems/cargo.d.ts +10 -0
- package/dist/packages/workspace/src/ecosystems/cargo.js +69 -0
- package/dist/packages/workspace/src/ecosystems/composer.d.ts +7 -0
- package/dist/packages/workspace/src/ecosystems/composer.js +40 -0
- package/dist/packages/workspace/src/ecosystems/go.d.ts +7 -0
- package/dist/packages/workspace/src/ecosystems/go.js +49 -0
- package/{packages/workspace/src/ecosystems/index.ts → dist/packages/workspace/src/ecosystems/index.d.ts} +2 -24
- package/dist/packages/workspace/src/ecosystems/index.js +21 -0
- package/dist/packages/workspace/src/ecosystems/maven.d.ts +7 -0
- package/dist/packages/workspace/src/ecosystems/maven.js +28 -0
- package/dist/packages/workspace/src/ecosystems/npm.d.ts +10 -0
- package/dist/packages/workspace/src/ecosystems/npm.js +73 -0
- package/dist/packages/workspace/src/ecosystems/pub.d.ts +7 -0
- package/dist/packages/workspace/src/ecosystems/pub.js +34 -0
- package/dist/packages/workspace/src/ecosystems/pypi.d.ts +9 -0
- package/dist/packages/workspace/src/ecosystems/pypi.js +94 -0
- package/dist/packages/workspace/src/ecosystems/rubygems.d.ts +7 -0
- package/dist/packages/workspace/src/ecosystems/rubygems.js +25 -0
- package/dist/packages/workspace/src/ecosystems/types.d.ts +9 -0
- package/dist/packages/workspace/src/ecosystems/types.js +1 -0
- package/dist/packages/workspace/src/index.js +5 -0
- package/dist/packages/workspace/src/lockfile.d.ts +21 -0
- package/dist/packages/workspace/src/lockfile.js +153 -0
- package/dist/packages/workspace/src/resolver.d.ts +39 -0
- package/dist/packages/workspace/src/resolver.js +164 -0
- package/dist/packages/workspace/src/semver.d.ts +33 -0
- package/dist/packages/workspace/src/semver.js +235 -0
- package/package.json +13 -9
- package/apps/cli/bin/docorbit.js +0 -8
- package/apps/cli/src/commands/add.ts +0 -44
- package/apps/cli/src/commands/api.ts +0 -38
- package/apps/cli/src/commands/context.ts +0 -47
- package/apps/cli/src/commands/dashboard.ts +0 -55
- package/apps/cli/src/commands/diff.ts +0 -30
- package/apps/cli/src/commands/evaluate.ts +0 -133
- package/apps/cli/src/commands/examples.ts +0 -39
- package/apps/cli/src/commands/export.ts +0 -89
- package/apps/cli/src/commands/impact.ts +0 -31
- package/apps/cli/src/commands/init.ts +0 -69
- package/apps/cli/src/commands/inspect.ts +0 -30
- package/apps/cli/src/commands/mcp.ts +0 -72
- package/apps/cli/src/commands/pitfalls.ts +0 -38
- package/apps/cli/src/commands/recipes.ts +0 -35
- package/apps/cli/src/commands/search.ts +0 -48
- package/apps/cli/src/commands/update.ts +0 -73
- package/apps/cli/src/commands/verify.ts +0 -48
- package/apps/cli/src/formatters/colors.ts +0 -23
- package/apps/cli/src/formatters/inspection.ts +0 -102
- package/apps/cli/src/formatters/knowledge.ts +0 -272
- package/apps/cli/src/formatters/retrieval.ts +0 -74
- package/apps/cli/src/formatters/verification.ts +0 -126
- package/apps/cli/src/index.ts +0 -409
- package/packages/core/src/dashboard/server.ts +0 -314
- package/packages/core/src/implementation-service.ts +0 -451
- package/packages/core/src/inspector.ts +0 -71
- package/packages/core/src/pipeline.ts +0 -331
- package/packages/crawler/src/config.ts +0 -12
- package/packages/crawler/src/fetcher.ts +0 -185
- package/packages/discovery/src/index.ts +0 -31
- package/packages/discovery/src/provider.ts +0 -47
- package/packages/discovery/src/providers/generic.ts +0 -98
- package/packages/discovery/src/providers/github.ts +0 -61
- package/packages/discovery/src/providers/llms-txt.ts +0 -73
- package/packages/discovery/src/providers/markdown.ts +0 -48
- package/packages/discovery/src/providers/openapi.ts +0 -91
- package/packages/discovery/src/providers/sitemap.ts +0 -62
- package/packages/discovery/src/providers/skill.ts +0 -54
- package/packages/discovery/src/ranker.ts +0 -123
- package/packages/evaluation/src/dataset.ts +0 -963
- package/packages/evaluation/src/runner.ts +0 -241
- package/packages/evaluation/src/strategies/context7-runner.ts +0 -269
- package/packages/evaluation/src/strategies/docorbit-runner.ts +0 -228
- package/packages/evaluation/src/strategies/firecrawl-runner.ts +0 -172
- package/packages/evaluation/src/strategies/web-search-runner.ts +0 -194
- package/packages/evaluation/src/types.ts +0 -34
- package/packages/evaluation/src/version-matcher.ts +0 -73
- package/packages/export/src/agents-md.ts +0 -200
- package/packages/export/src/claude-md.ts +0 -141
- package/packages/export/src/docs-map.ts +0 -150
- package/packages/export/src/llms-txt.ts +0 -96
- package/packages/export/src/service.ts +0 -250
- package/packages/export/src/skill-md.ts +0 -128
- package/packages/mcp/src/resources/index.ts +0 -189
- package/packages/mcp/src/server.ts +0 -278
- package/packages/mcp/src/tools/analyze-impact.ts +0 -74
- package/packages/mcp/src/tools/check-api.ts +0 -86
- package/packages/mcp/src/tools/diff-docs.ts +0 -68
- package/packages/mcp/src/tools/export-context.ts +0 -73
- package/packages/mcp/src/tools/find-api.ts +0 -99
- package/packages/mcp/src/tools/find-example.ts +0 -100
- package/packages/mcp/src/tools/find-pitfall.ts +0 -94
- package/packages/mcp/src/tools/find-recipe.ts +0 -98
- package/packages/mcp/src/tools/get-doc.ts +0 -130
- package/packages/mcp/src/tools/get-docs-map.ts +0 -64
- package/packages/mcp/src/tools/get-version.ts +0 -118
- package/packages/mcp/src/tools/implementation-context.ts +0 -88
- package/packages/mcp/src/tools/index.ts +0 -59
- package/packages/mcp/src/tools/list-sources.ts +0 -85
- package/packages/mcp/src/tools/search-docs.ts +0 -123
- package/packages/mcp/src/tools/types.ts +0 -28
- package/packages/mcp/src/transports/http.ts +0 -256
- package/packages/mcp/src/transports/stdio.ts +0 -105
- package/packages/mcp/src/types.ts +0 -102
- package/packages/normalizer/src/example-indexer.ts +0 -240
- package/packages/normalizer/src/html.ts +0 -253
- package/packages/normalizer/src/llms.ts +0 -83
- package/packages/normalizer/src/openapi/endpoint-parser.ts +0 -406
- package/packages/normalizer/src/openapi/schema-resolver.ts +0 -111
- package/packages/normalizer/src/page.ts +0 -184
- package/packages/normalizer/src/pitfall-extractor.ts +0 -190
- package/packages/normalizer/src/slicer.ts +0 -455
- package/packages/retrieval/src/engine.ts +0 -120
- package/packages/retrieval/src/intent.ts +0 -43
- package/packages/retrieval/src/packer.ts +0 -145
- package/packages/retrieval/src/recipe-engine.ts +0 -313
- package/packages/retrieval/src/scorer.ts +0 -139
- package/packages/retrieval/src/weights.ts +0 -31
- package/packages/security/src/annotations.ts +0 -112
- package/packages/security/src/ssrf.ts +0 -153
- package/packages/shared/src/errors.ts +0 -53
- package/packages/shared/src/hashing.ts +0 -23
- package/packages/shared/src/types.ts +0 -881
- package/packages/storage/src/db.ts +0 -72
- package/packages/storage/src/interfaces.ts +0 -115
- package/packages/storage/src/repositories/api-repository.ts +0 -219
- package/packages/storage/src/repositories/chunk-repository.ts +0 -316
- package/packages/storage/src/repositories/example-repository.ts +0 -206
- package/packages/storage/src/repositories/page-repository.ts +0 -205
- package/packages/storage/src/repositories/pitfall-repository.ts +0 -188
- package/packages/storage/src/repositories/source-repository.ts +0 -205
- package/packages/storage/src/repository.ts +0 -256
- package/packages/storage/src/search-tokens.ts +0 -28
- package/packages/verification/src/diff-engine.ts +0 -258
- package/packages/verification/src/extractor.ts +0 -339
- package/packages/verification/src/impact-scanner.ts +0 -203
- package/packages/verification/src/services.ts +0 -238
- package/packages/verification/src/verifier.ts +0 -375
- package/packages/workspace/src/detector.ts +0 -143
- package/packages/workspace/src/ecosystems/cargo.ts +0 -84
- package/packages/workspace/src/ecosystems/composer.ts +0 -42
- package/packages/workspace/src/ecosystems/go.ts +0 -54
- package/packages/workspace/src/ecosystems/maven.ts +0 -34
- package/packages/workspace/src/ecosystems/npm.ts +0 -83
- package/packages/workspace/src/ecosystems/pub.ts +0 -40
- package/packages/workspace/src/ecosystems/pypi.ts +0 -100
- package/packages/workspace/src/ecosystems/rubygems.ts +0 -30
- package/packages/workspace/src/ecosystems/types.ts +0 -18
- package/packages/workspace/src/lockfile.ts +0 -194
- package/packages/workspace/src/resolver.ts +0 -234
- package/packages/workspace/src/semver.ts +0 -259
- /package/{packages/crawler/src/index.ts → dist/packages/crawler/src/index.d.ts} +0 -0
- /package/{packages/evaluation/src/index.ts → dist/packages/evaluation/src/index.d.ts} +0 -0
- /package/{packages/export/src/index.ts → dist/packages/export/src/index.d.ts} +0 -0
- /package/{packages/normalizer/src/openapi.ts → dist/packages/normalizer/src/openapi.d.ts} +0 -0
- /package/{packages/security/src/index.ts → dist/packages/security/src/index.d.ts} +0 -0
- /package/{packages/shared/src/index.ts → dist/packages/shared/src/index.d.ts} +0 -0
- /package/{packages/storage/src/index.ts → dist/packages/storage/src/index.d.ts} +0 -0
- /package/{packages/verification/src/index.ts → dist/packages/verification/src/index.d.ts} +0 -0
- /package/{packages/workspace/src/index.ts → dist/packages/workspace/src/index.d.ts} +0 -0
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import type {
|
|
4
|
-
DocsLock,
|
|
5
|
-
LockedDoc,
|
|
6
|
-
WorkspaceScanResult,
|
|
7
|
-
ProjectDependency,
|
|
8
|
-
DocVersionMatch,
|
|
9
|
-
} from '../../shared/src/index.ts';
|
|
10
|
-
import type { DocOrbitRepository } from '../../storage/src/index.ts';
|
|
11
|
-
import { resolveDocVersion } from './semver.ts';
|
|
12
|
-
|
|
13
|
-
export const DOCS_LOCK_FILENAME = 'docs.lock';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Reads and parses docs.lock from a project directory if present.
|
|
17
|
-
*/
|
|
18
|
-
export function readDocsLock(projectDir: string): DocsLock | null {
|
|
19
|
-
const filePath = join(projectDir, DOCS_LOCK_FILENAME);
|
|
20
|
-
if (!existsSync(filePath)) return null;
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const raw = readFileSync(filePath, 'utf-8');
|
|
24
|
-
const parsed = JSON.parse(raw);
|
|
25
|
-
if (parsed && parsed.version === 1 && typeof parsed.dependencies === 'object') {
|
|
26
|
-
return parsed as DocsLock;
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
// Malformed lockfile
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Deterministically writes a docs.lock file to project directory.
|
|
36
|
-
* Sorts dependency keys alphabetically and uses 2-space indentation.
|
|
37
|
-
*/
|
|
38
|
-
export function writeDocsLock(projectDir: string, lock: DocsLock): void {
|
|
39
|
-
const filePath = join(projectDir, DOCS_LOCK_FILENAME);
|
|
40
|
-
|
|
41
|
-
// Sort dependency keys alphabetically
|
|
42
|
-
const sortedDeps: Record<string, LockedDoc> = {};
|
|
43
|
-
for (const key of Object.keys(lock.dependencies).sort()) {
|
|
44
|
-
sortedDeps[key] = lock.dependencies[key];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const deterministicLock: DocsLock = {
|
|
48
|
-
version: 1,
|
|
49
|
-
workspaceRoot: lock.workspaceRoot,
|
|
50
|
-
dependencies: sortedDeps,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const serialized = JSON.stringify(deterministicLock, null, 2) + '\n';
|
|
54
|
-
writeFileSync(filePath, serialized, 'utf-8');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Helper to match a project dependency to an ingested source in the repository.
|
|
59
|
-
*/
|
|
60
|
-
function findMatchingSource(dep: ProjectDependency, repo: DocOrbitRepository) {
|
|
61
|
-
const sources = repo.listSources();
|
|
62
|
-
const depClean = dep.name.toLowerCase().replace(/^@[^/]+\//, ''); // e.g. @stripe/stripe-js -> stripe-js
|
|
63
|
-
|
|
64
|
-
for (const src of sources) {
|
|
65
|
-
const srcUrl = src.url.toLowerCase();
|
|
66
|
-
// Direct match: URL or metadata contains dependency name
|
|
67
|
-
if (
|
|
68
|
-
srcUrl.includes(depClean) ||
|
|
69
|
-
srcUrl.includes(dep.name.toLowerCase()) ||
|
|
70
|
-
(src.metadata && String(src.metadata.name || '').toLowerCase() === depClean)
|
|
71
|
-
) {
|
|
72
|
-
return src;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Generates a DocsLock manifest from workspace scan result and repository state.
|
|
80
|
-
* Preserves timestamps for unchanged documentation snapshots to prevent lockfile churn.
|
|
81
|
-
*/
|
|
82
|
-
export function generateDocsLock(
|
|
83
|
-
scanResult: WorkspaceScanResult,
|
|
84
|
-
repo: DocOrbitRepository,
|
|
85
|
-
existingLock?: DocsLock | null
|
|
86
|
-
): DocsLock {
|
|
87
|
-
const lockedDeps: Record<string, LockedDoc> = {};
|
|
88
|
-
const allSnapshots = repo.listSnapshots();
|
|
89
|
-
|
|
90
|
-
// Detect duplicate package names across monorepo packages
|
|
91
|
-
const nameCounts = new Map<string, number>();
|
|
92
|
-
for (const dep of scanResult.dependencies) {
|
|
93
|
-
nameCounts.set(dep.name, (nameCounts.get(dep.name) || 0) + 1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
for (const dep of scanResult.dependencies) {
|
|
97
|
-
// Monorepo key disambiguation
|
|
98
|
-
const isMulti = (nameCounts.get(dep.name) || 0) > 1;
|
|
99
|
-
const depKey = isMulti && dep.packagePath && dep.packagePath !== '.'
|
|
100
|
-
? `${dep.packagePath}:${dep.name}`
|
|
101
|
-
: dep.name;
|
|
102
|
-
|
|
103
|
-
// Check if we have documentation for this dependency
|
|
104
|
-
const matchingSource = findMatchingSource(dep, repo);
|
|
105
|
-
if (!matchingSource) continue;
|
|
106
|
-
|
|
107
|
-
// Find snapshots for matching source
|
|
108
|
-
const sourceSnapshots = allSnapshots.filter(s => s.sourceId === matchingSource.id);
|
|
109
|
-
if (sourceSnapshots.length === 0) continue;
|
|
110
|
-
|
|
111
|
-
// Gather available versions from snapshots
|
|
112
|
-
const versionToSnapshot = new Map<string, typeof sourceSnapshots[0]>();
|
|
113
|
-
for (const snap of sourceSnapshots) {
|
|
114
|
-
const v = snap.docVersion || 'latest';
|
|
115
|
-
if (!versionToSnapshot.has(v)) {
|
|
116
|
-
versionToSnapshot.set(v, snap);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const availableVersions = Array.from(versionToSnapshot.keys());
|
|
121
|
-
const projectVersion = dep.resolvedVersion || dep.requestedVersion;
|
|
122
|
-
const resolution = resolveDocVersion(projectVersion, availableVersions, dep.name);
|
|
123
|
-
|
|
124
|
-
const selectedSnapshot = versionToSnapshot.get(resolution.selectedDocVersion) || sourceSnapshots[0];
|
|
125
|
-
const snapshotHash = selectedSnapshot.snapshotHash;
|
|
126
|
-
|
|
127
|
-
// Deterministic timestamp preservation:
|
|
128
|
-
// If existingLock already has this dependency with identical snapshotHash and resolvedVersion, keep the timestamp
|
|
129
|
-
const existing = existingLock?.dependencies[depKey];
|
|
130
|
-
const isUnchanged =
|
|
131
|
-
existing &&
|
|
132
|
-
existing.snapshotHash === snapshotHash &&
|
|
133
|
-
existing.resolvedDependencyVersion === (dep.resolvedVersion || dep.requestedVersion) &&
|
|
134
|
-
existing.docVersion === resolution.selectedDocVersion;
|
|
135
|
-
|
|
136
|
-
const retrievedAt = isUnchanged ? existing.retrievedAt : new Date().toISOString();
|
|
137
|
-
|
|
138
|
-
lockedDeps[depKey] = {
|
|
139
|
-
name: dep.name,
|
|
140
|
-
ecosystem: dep.ecosystem,
|
|
141
|
-
requestedVersion: dep.requestedVersion,
|
|
142
|
-
resolvedDependencyVersion: dep.resolvedVersion || dep.requestedVersion,
|
|
143
|
-
sourceFile: dep.sourceFile,
|
|
144
|
-
docSourceUrl: matchingSource.url,
|
|
145
|
-
docVersion: resolution.selectedDocVersion,
|
|
146
|
-
matchType: resolution.matchType,
|
|
147
|
-
confidence: resolution.confidence,
|
|
148
|
-
snapshotId: selectedSnapshot.id,
|
|
149
|
-
snapshotHash,
|
|
150
|
-
retrievedAt,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
version: 1,
|
|
156
|
-
workspaceRoot: scanResult.workspaceRoot,
|
|
157
|
-
dependencies: lockedDeps,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Selectively or globally updates docs.lock for a project.
|
|
163
|
-
*/
|
|
164
|
-
export function updateDocsLock(
|
|
165
|
-
scanResult: WorkspaceScanResult,
|
|
166
|
-
repo: DocOrbitRepository,
|
|
167
|
-
existingLock: DocsLock,
|
|
168
|
-
specificDependency?: string
|
|
169
|
-
): DocsLock {
|
|
170
|
-
if (!specificDependency) {
|
|
171
|
-
// Full update: regenerate with existing lock as baseline for unchanged items
|
|
172
|
-
return generateDocsLock(scanResult, repo, existingLock);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Selective update: only force refresh of specific dependency
|
|
176
|
-
const updated = generateDocsLock(scanResult, repo, existingLock);
|
|
177
|
-
const resultDeps = { ...existingLock.dependencies };
|
|
178
|
-
|
|
179
|
-
for (const [key, doc] of Object.entries(updated.dependencies)) {
|
|
180
|
-
if (doc.name === specificDependency || key === specificDependency) {
|
|
181
|
-
// Force new timestamp for the target dependency being updated
|
|
182
|
-
resultDeps[key] = {
|
|
183
|
-
...doc,
|
|
184
|
-
retrievedAt: new Date().toISOString(),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
version: 1,
|
|
191
|
-
workspaceRoot: scanResult.workspaceRoot,
|
|
192
|
-
dependencies: resultDeps,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DocsLock,
|
|
3
|
-
ProjectDependency,
|
|
4
|
-
WorkspaceScanResult,
|
|
5
|
-
VersionResolutionResult,
|
|
6
|
-
} from '../../shared/src/index.ts';
|
|
7
|
-
import type { DocOrbitRepository } from '../../storage/src/index.ts';
|
|
8
|
-
import { readDocsLock } from './lockfile.ts';
|
|
9
|
-
import { detectWorkspaceDependencies } from './detector.ts';
|
|
10
|
-
import { resolveDocVersion } from './semver.ts';
|
|
11
|
-
|
|
12
|
-
export interface ResolvedProjectContext {
|
|
13
|
-
projectDir: string;
|
|
14
|
-
hasLockfile: boolean;
|
|
15
|
-
matchedDependency?: {
|
|
16
|
-
name: string;
|
|
17
|
-
projectVersion: string;
|
|
18
|
-
targetDocVersion: string;
|
|
19
|
-
targetSnapshotId?: string;
|
|
20
|
-
confidence: number;
|
|
21
|
-
matchType: string;
|
|
22
|
-
};
|
|
23
|
-
allDependencies: ProjectDependency[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Normalizes query string for token matching against dependency names.
|
|
28
|
-
*/
|
|
29
|
-
function normalizeQueryTokens(query: string): Set<string> {
|
|
30
|
-
const tokens = query
|
|
31
|
-
.toLowerCase()
|
|
32
|
-
.replace(/[^\w\s-]/g, ' ')
|
|
33
|
-
.split(/\s+/)
|
|
34
|
-
.filter(t => t.length > 1);
|
|
35
|
-
|
|
36
|
-
const set = new Set(tokens);
|
|
37
|
-
// Add common aliases
|
|
38
|
-
if (set.has('nextjs') || set.has('next.js')) {
|
|
39
|
-
set.add('next');
|
|
40
|
-
}
|
|
41
|
-
if (set.has('reactjs') || set.has('react.js')) {
|
|
42
|
-
set.add('react');
|
|
43
|
-
}
|
|
44
|
-
if (set.has('vuejs') || set.has('vue.js')) {
|
|
45
|
-
set.add('vue');
|
|
46
|
-
}
|
|
47
|
-
return set;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Resolves project context and detects if a query targets a specific dependency in the project.
|
|
52
|
-
* Uses docs.lock if present for zero-overhead deterministic pinned resolution,
|
|
53
|
-
* or falls back to live manifest scanning and resolution.
|
|
54
|
-
*/
|
|
55
|
-
export function resolveProjectContext(
|
|
56
|
-
projectDir: string,
|
|
57
|
-
query: string,
|
|
58
|
-
repo: DocOrbitRepository
|
|
59
|
-
): ResolvedProjectContext {
|
|
60
|
-
const lock = readDocsLock(projectDir);
|
|
61
|
-
const queryTokens = normalizeQueryTokens(query);
|
|
62
|
-
|
|
63
|
-
if (lock) {
|
|
64
|
-
// 1. Check locked dependencies
|
|
65
|
-
for (const [key, lockedDoc] of Object.entries(lock.dependencies)) {
|
|
66
|
-
const cleanName = lockedDoc.name.toLowerCase().replace(/^@[^/]+\//, '');
|
|
67
|
-
const parts = cleanName.split(/[-_.]/);
|
|
68
|
-
|
|
69
|
-
const matches =
|
|
70
|
-
queryTokens.has(lockedDoc.name.toLowerCase()) ||
|
|
71
|
-
queryTokens.has(cleanName) ||
|
|
72
|
-
parts.some(p => p.length > 2 && queryTokens.has(p));
|
|
73
|
-
|
|
74
|
-
if (matches) {
|
|
75
|
-
return {
|
|
76
|
-
projectDir,
|
|
77
|
-
hasLockfile: true,
|
|
78
|
-
matchedDependency: {
|
|
79
|
-
name: lockedDoc.name,
|
|
80
|
-
projectVersion: lockedDoc.resolvedDependencyVersion,
|
|
81
|
-
targetDocVersion: lockedDoc.docVersion,
|
|
82
|
-
targetSnapshotId: lockedDoc.snapshotId,
|
|
83
|
-
confidence: lockedDoc.confidence,
|
|
84
|
-
matchType: lockedDoc.matchType,
|
|
85
|
-
},
|
|
86
|
-
allDependencies: Object.values(lock.dependencies).map(d => ({
|
|
87
|
-
name: d.name,
|
|
88
|
-
ecosystem: d.ecosystem,
|
|
89
|
-
requestedVersion: d.requestedVersion,
|
|
90
|
-
resolvedVersion: d.resolvedDependencyVersion,
|
|
91
|
-
sourceFile: d.sourceFile,
|
|
92
|
-
})),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
projectDir,
|
|
99
|
-
hasLockfile: true,
|
|
100
|
-
allDependencies: Object.values(lock.dependencies).map(d => ({
|
|
101
|
-
name: d.name,
|
|
102
|
-
ecosystem: d.ecosystem,
|
|
103
|
-
requestedVersion: d.requestedVersion,
|
|
104
|
-
resolvedVersion: d.resolvedDependencyVersion,
|
|
105
|
-
sourceFile: d.sourceFile,
|
|
106
|
-
})),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 2. Fallback: scan workspace manifests directly
|
|
111
|
-
const scan = detectWorkspaceDependencies(projectDir);
|
|
112
|
-
const allSnapshots = repo.listSnapshots();
|
|
113
|
-
const allSources = repo.listSources();
|
|
114
|
-
|
|
115
|
-
for (const dep of scan.dependencies) {
|
|
116
|
-
const cleanName = dep.name.toLowerCase().replace(/^@[^/]+\//, '');
|
|
117
|
-
const parts = cleanName.split(/[-_.]/);
|
|
118
|
-
|
|
119
|
-
const matches =
|
|
120
|
-
queryTokens.has(dep.name.toLowerCase()) ||
|
|
121
|
-
queryTokens.has(cleanName) ||
|
|
122
|
-
parts.some(p => p.length > 2 && queryTokens.has(p));
|
|
123
|
-
|
|
124
|
-
if (matches) {
|
|
125
|
-
// Find matching source
|
|
126
|
-
const src = allSources.find(s => {
|
|
127
|
-
const u = s.url.toLowerCase();
|
|
128
|
-
return u.includes(cleanName) || u.includes(dep.name.toLowerCase());
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
if (src) {
|
|
132
|
-
const snapshots = allSnapshots.filter(s => s.sourceId === src.id);
|
|
133
|
-
const availableVersions = snapshots.map(s => s.docVersion || 'latest');
|
|
134
|
-
const projectVer = dep.resolvedVersion || dep.requestedVersion;
|
|
135
|
-
const resolution = resolveDocVersion(projectVer, availableVersions, dep.name);
|
|
136
|
-
|
|
137
|
-
const chosenSnapshot = snapshots.find(
|
|
138
|
-
s => (s.docVersion || 'latest') === resolution.selectedDocVersion
|
|
139
|
-
) || snapshots[0];
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
projectDir,
|
|
143
|
-
hasLockfile: false,
|
|
144
|
-
matchedDependency: {
|
|
145
|
-
name: dep.name,
|
|
146
|
-
projectVersion: projectVer,
|
|
147
|
-
targetDocVersion: resolution.selectedDocVersion,
|
|
148
|
-
targetSnapshotId: chosenSnapshot?.id,
|
|
149
|
-
confidence: resolution.confidence,
|
|
150
|
-
matchType: resolution.matchType,
|
|
151
|
-
},
|
|
152
|
-
allDependencies: scan.dependencies,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
projectDir,
|
|
160
|
-
hasLockfile: false,
|
|
161
|
-
allDependencies: scan.dependencies,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface WorkspaceMatch {
|
|
166
|
-
dependency: ProjectDependency;
|
|
167
|
-
targetVersion: string;
|
|
168
|
-
confidence: number;
|
|
169
|
-
snapshotId?: string;
|
|
170
|
-
matchedBy: string;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface WorkspaceResolutionSummary {
|
|
174
|
-
matches: WorkspaceMatch[];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export class WorkspaceResolver {
|
|
178
|
-
private repo: DocOrbitRepository;
|
|
179
|
-
|
|
180
|
-
constructor(repo: DocOrbitRepository) {
|
|
181
|
-
this.repo = repo;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
resolveProjectContext(projectDir: string, query: string): ResolvedProjectContext {
|
|
185
|
-
return resolveProjectContext(projectDir, query, this.repo);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
scanWorkspace(projectDir: string): WorkspaceScanResult {
|
|
189
|
-
return detectWorkspaceDependencies(projectDir);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
resolveWorkspace(scan: WorkspaceScanResult, _existingLock?: DocsLock | null): WorkspaceResolutionSummary {
|
|
193
|
-
const allSnapshots = this.repo.listSnapshots();
|
|
194
|
-
const allSources = this.repo.listSources();
|
|
195
|
-
const matches: WorkspaceMatch[] = [];
|
|
196
|
-
|
|
197
|
-
for (const dep of scan.dependencies) {
|
|
198
|
-
const cleanName = dep.name.toLowerCase().replace(/^@[^/]+\//, '');
|
|
199
|
-
const src = allSources.find(s => {
|
|
200
|
-
const u = s.url.toLowerCase();
|
|
201
|
-
return u.includes(cleanName) || u.includes(dep.name.toLowerCase()) ||
|
|
202
|
-
(s.metadata && String(s.metadata.name || '').toLowerCase() === cleanName);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (!src) continue;
|
|
206
|
-
|
|
207
|
-
const snapshots = allSnapshots.filter(s => s.sourceId === src.id);
|
|
208
|
-
if (snapshots.length === 0) continue;
|
|
209
|
-
|
|
210
|
-
const availableVersions = snapshots.map(s => s.docVersion || 'latest');
|
|
211
|
-
const projectVer = dep.resolvedVersion || dep.requestedVersion;
|
|
212
|
-
const resolution = resolveDocVersion(projectVer, availableVersions, dep.name);
|
|
213
|
-
|
|
214
|
-
const chosenSnapshot = snapshots.find(
|
|
215
|
-
s => (s.docVersion || 'latest') === resolution.selectedDocVersion
|
|
216
|
-
) || snapshots[0];
|
|
217
|
-
|
|
218
|
-
matches.push({
|
|
219
|
-
dependency: dep,
|
|
220
|
-
targetVersion: resolution.selectedDocVersion,
|
|
221
|
-
confidence: resolution.confidence,
|
|
222
|
-
snapshotId: chosenSnapshot?.id,
|
|
223
|
-
matchedBy: resolution.matchType,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return { matches };
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
resolveVersion(projectVersion: string, availableDocVersions: string[], packageName?: string): VersionResolutionResult {
|
|
231
|
-
return resolveDocVersion(projectVersion, availableDocVersions, packageName);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DocVersionMatch,
|
|
3
|
-
VersionResolutionResult,
|
|
4
|
-
} from '../../shared/src/index.ts';
|
|
5
|
-
|
|
6
|
-
export interface ParsedSemVer {
|
|
7
|
-
major: number;
|
|
8
|
-
minor: number;
|
|
9
|
-
patch: number;
|
|
10
|
-
prerelease?: string;
|
|
11
|
-
raw: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Parses a version string into semantic components.
|
|
16
|
-
* Handles standard SemVer, leading 'v', partial versions ('14', '14.2'),
|
|
17
|
-
* and prereleases ('15.0.0-rc.1', '14.2.0-canary').
|
|
18
|
-
*/
|
|
19
|
-
export function parseSemVer(versionStr: string): ParsedSemVer | null {
|
|
20
|
-
if (!versionStr || typeof versionStr !== 'string') return null;
|
|
21
|
-
|
|
22
|
-
const cleaned = versionStr.trim().replace(/^[v=]/, '');
|
|
23
|
-
// Match major, optional minor, optional patch, optional prerelease
|
|
24
|
-
const match = cleaned.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?/);
|
|
25
|
-
if (!match) return null;
|
|
26
|
-
|
|
27
|
-
const major = parseInt(match[1], 10);
|
|
28
|
-
const minor = match[2] !== undefined ? parseInt(match[2], 10) : 0;
|
|
29
|
-
const patch = match[3] !== undefined ? parseInt(match[3], 10) : 0;
|
|
30
|
-
const prerelease = match[4];
|
|
31
|
-
|
|
32
|
-
return { major, minor, patch, prerelease, raw: versionStr.trim() };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Deterministic SemVer comparison.
|
|
37
|
-
* Returns negative if v1 < v2, positive if v1 > v2, 0 if v1 == v2.
|
|
38
|
-
* Prereleases have lower precedence than normal releases (e.g. 15.0.0-rc.1 < 15.0.0).
|
|
39
|
-
*/
|
|
40
|
-
export function compareVersions(v1: string, v2: string): number {
|
|
41
|
-
const p1 = parseSemVer(v1);
|
|
42
|
-
const p2 = parseSemVer(v2);
|
|
43
|
-
|
|
44
|
-
if (!p1 && !p2) return v1.localeCompare(v2);
|
|
45
|
-
if (!p1) return -1;
|
|
46
|
-
if (!p2) return 1;
|
|
47
|
-
|
|
48
|
-
if (p1.major !== p2.major) return p1.major - p2.major;
|
|
49
|
-
if (p1.minor !== p2.minor) return p1.minor - p2.minor;
|
|
50
|
-
if (p1.patch !== p2.patch) return p1.patch - p2.patch;
|
|
51
|
-
|
|
52
|
-
// Prerelease comparison:
|
|
53
|
-
// 1.0.0-alpha < 1.0.0 (version with prerelease is lower than version without)
|
|
54
|
-
if (p1.prerelease && !p2.prerelease) return -1;
|
|
55
|
-
if (!p1.prerelease && p2.prerelease) return 1;
|
|
56
|
-
if (p1.prerelease && p2.prerelease) {
|
|
57
|
-
return p1.prerelease.localeCompare(p2.prerelease);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Evaluates whether a concrete version satisfies a SemVer range specification.
|
|
65
|
-
* Supports '^', '~', '>=', '<=', '<', '>', '*', 'x', space-separated and '||'.
|
|
66
|
-
*/
|
|
67
|
-
export function satisfiesRange(version: string, range: string): boolean {
|
|
68
|
-
if (!range || range === '*' || range === 'latest' || range === 'x') {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const ver = parseSemVer(version);
|
|
73
|
-
if (!ver) return false;
|
|
74
|
-
|
|
75
|
-
// Handle disjunction (||)
|
|
76
|
-
if (range.includes('||')) {
|
|
77
|
-
return range.split('||').some(r => satisfiesRange(version, r.trim()));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Handle conjunction (space separated conditions e.g. ">=14.0.0 <15.0.0")
|
|
81
|
-
const clauses = range.trim().split(/\s+/).filter(Boolean);
|
|
82
|
-
if (clauses.length > 1) {
|
|
83
|
-
return clauses.every(c => satisfiesRange(version, c));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const single = clauses[0];
|
|
87
|
-
|
|
88
|
-
// Caret ranges: ^14.2.0 -> >=14.2.0 <15.0.0 (or for 0.x: ^0.2.3 -> >=0.2.3 <0.3.0)
|
|
89
|
-
if (single.startsWith('^')) {
|
|
90
|
-
const base = parseSemVer(single.slice(1));
|
|
91
|
-
if (!base) return false;
|
|
92
|
-
if (ver.major !== base.major) return false;
|
|
93
|
-
if (base.major === 0) {
|
|
94
|
-
if (ver.minor !== base.minor) return false;
|
|
95
|
-
return ver.patch >= base.patch;
|
|
96
|
-
}
|
|
97
|
-
if (ver.minor < base.minor) return false;
|
|
98
|
-
if (ver.minor === base.minor && ver.patch < base.patch) return false;
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Tilde ranges: ~14.2.0 -> >=14.2.0 <14.3.0
|
|
103
|
-
if (single.startsWith('~')) {
|
|
104
|
-
const base = parseSemVer(single.slice(1));
|
|
105
|
-
if (!base) return false;
|
|
106
|
-
if (ver.major !== base.major || ver.minor !== base.minor) return false;
|
|
107
|
-
return ver.patch >= base.patch;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Wildcard ranges: 14.x or 14.*
|
|
111
|
-
const wildcardMatch = single.match(/^(\d+)(?:\.(\d+|\*|x))?(?:\.(\d+|\*|x))?$/);
|
|
112
|
-
if (wildcardMatch) {
|
|
113
|
-
const wMajor = parseInt(wildcardMatch[1], 10);
|
|
114
|
-
const wMinor = wildcardMatch[2];
|
|
115
|
-
if (ver.major !== wMajor) return false;
|
|
116
|
-
if (wMinor && wMinor !== '*' && wMinor !== 'x') {
|
|
117
|
-
if (ver.minor !== parseInt(wMinor, 10)) return false;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Comparison operators: >=, <=, >, <, =
|
|
123
|
-
const compMatch = single.match(/^(>=|<=|>|<|=)(.+)$/);
|
|
124
|
-
if (compMatch) {
|
|
125
|
-
const op = compMatch[1];
|
|
126
|
-
const target = compMatch[2].trim();
|
|
127
|
-
const cmp = compareVersions(version, target);
|
|
128
|
-
if (op === '>=') return cmp >= 0;
|
|
129
|
-
if (op === '<=') return cmp <= 0;
|
|
130
|
-
if (op === '>') return cmp > 0;
|
|
131
|
-
if (op === '<') return cmp < 0;
|
|
132
|
-
if (op === '=') return cmp === 0;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Direct equality check
|
|
136
|
-
const targetVer = parseSemVer(single);
|
|
137
|
-
if (targetVer) {
|
|
138
|
-
return (
|
|
139
|
-
ver.major === targetVer.major &&
|
|
140
|
-
ver.minor === targetVer.minor &&
|
|
141
|
-
ver.patch === targetVer.patch
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Deterministically resolves a project's dependency version to the best available
|
|
150
|
-
* documentation version using the hierarchical confidence ladder:
|
|
151
|
-
* exact (1.0) -> major_minor (0.95) -> major (0.90) -> range (0.85) -> latest_fallback (0.50) -> unresolved (0.0)
|
|
152
|
-
*
|
|
153
|
-
* Never claims exact match when documentation is coarse (e.g. 'v14' or 'latest').
|
|
154
|
-
*/
|
|
155
|
-
export function resolveDocVersion(
|
|
156
|
-
projectVersion: string,
|
|
157
|
-
availableDocVersions: string[],
|
|
158
|
-
dependencyName: string = 'package'
|
|
159
|
-
): VersionResolutionResult {
|
|
160
|
-
if (!availableDocVersions || availableDocVersions.length === 0) {
|
|
161
|
-
return {
|
|
162
|
-
dependencyName,
|
|
163
|
-
projectVersion,
|
|
164
|
-
selectedDocVersion: 'unresolved',
|
|
165
|
-
matchType: 'unresolved',
|
|
166
|
-
confidence: 0.0,
|
|
167
|
-
availableVersions: [],
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const cleaned = projectVersion.replace(/^[\^~=v><\s]+/, '');
|
|
172
|
-
const pVer = parseSemVer(projectVersion) || parseSemVer(cleaned);
|
|
173
|
-
const cleanTarget = projectVersion.replace(/^[v=]/, '');
|
|
174
|
-
|
|
175
|
-
// 1. Exact match (e.g. project '14.2.3' and doc '14.2.3' or 'v14.2.3')
|
|
176
|
-
const exactMatch = availableDocVersions.find(v => {
|
|
177
|
-
const c = v.replace(/^[v=]/, '');
|
|
178
|
-
return c === cleanTarget;
|
|
179
|
-
});
|
|
180
|
-
if (exactMatch) {
|
|
181
|
-
return {
|
|
182
|
-
dependencyName,
|
|
183
|
-
projectVersion,
|
|
184
|
-
selectedDocVersion: exactMatch,
|
|
185
|
-
matchType: 'exact',
|
|
186
|
-
confidence: 1.0,
|
|
187
|
-
availableVersions: availableDocVersions,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (pVer) {
|
|
192
|
-
// 2. Major.Minor match (e.g. project '14.2.3' and doc 'v14.2' or '14.2')
|
|
193
|
-
const mmTarget = `${pVer.major}.${pVer.minor}`;
|
|
194
|
-
const mmMatch = availableDocVersions.find(v => {
|
|
195
|
-
const c = v.replace(/^[v=]/, '');
|
|
196
|
-
return c === mmTarget || c === `${mmTarget}.x`;
|
|
197
|
-
});
|
|
198
|
-
if (mmMatch) {
|
|
199
|
-
return {
|
|
200
|
-
dependencyName,
|
|
201
|
-
projectVersion,
|
|
202
|
-
selectedDocVersion: mmMatch,
|
|
203
|
-
matchType: 'major_minor',
|
|
204
|
-
confidence: 0.95,
|
|
205
|
-
availableVersions: availableDocVersions,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// 3. Major match (e.g. project '14.2.3' and doc 'v14', '14.x', or '14')
|
|
210
|
-
const majorTarget = `${pVer.major}`;
|
|
211
|
-
const majorMatch = availableDocVersions.find(v => {
|
|
212
|
-
const c = v.replace(/^[v=]/, '');
|
|
213
|
-
return c === majorTarget || c === `${majorTarget}.x` || c === `${majorTarget}.*`;
|
|
214
|
-
});
|
|
215
|
-
if (majorMatch) {
|
|
216
|
-
return {
|
|
217
|
-
dependencyName,
|
|
218
|
-
projectVersion,
|
|
219
|
-
selectedDocVersion: majorMatch,
|
|
220
|
-
matchType: 'major',
|
|
221
|
-
confidence: 0.90,
|
|
222
|
-
availableVersions: availableDocVersions,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// 4. SemVer range satisfaction (find doc version that satisfies project version range or vice versa)
|
|
227
|
-
const rangeMatch = availableDocVersions
|
|
228
|
-
.filter(v => !['latest', 'stable', 'current', 'main', 'default'].includes(v.toLowerCase()))
|
|
229
|
-
.find(v => {
|
|
230
|
-
return satisfiesRange(projectVersion, v) || satisfiesRange(v, projectVersion);
|
|
231
|
-
});
|
|
232
|
-
if (rangeMatch) {
|
|
233
|
-
return {
|
|
234
|
-
dependencyName,
|
|
235
|
-
projectVersion,
|
|
236
|
-
selectedDocVersion: rangeMatch,
|
|
237
|
-
matchType: 'range',
|
|
238
|
-
confidence: 0.85,
|
|
239
|
-
availableVersions: availableDocVersions,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// 5. Fallback: 'latest' / 'stable' / 'current' or highest available version
|
|
245
|
-
const latestCandidate = availableDocVersions.find(v =>
|
|
246
|
-
['latest', 'stable', 'current', 'main', 'default'].includes(v.toLowerCase())
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
const fallbackVersion = latestCandidate || availableDocVersions[0];
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
dependencyName,
|
|
253
|
-
projectVersion,
|
|
254
|
-
selectedDocVersion: fallbackVersion,
|
|
255
|
-
matchType: 'latest_fallback',
|
|
256
|
-
confidence: 0.50,
|
|
257
|
-
availableVersions: availableDocVersions,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|