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
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { validateTargetUrl } from "../../security/src/index.js";
|
|
2
|
+
import { SecureFetcher, DEFAULT_CRAWLER_CONFIG } from "../../crawler/src/index.js";
|
|
3
|
+
import { createDefaultDiscoveryCoordinator, rankSources } from "../../discovery/src/index.js";
|
|
4
|
+
import { buildNormalizedPage, parseLlmsTxt, isValidLlmsTxt, slicePageIntoChunks, parseOpenApiEndpoints, detectOpenApiSpec, extractIndexedExamples, extractPitfalls, } from "../../normalizer/src/index.js";
|
|
5
|
+
export class IngestionPipeline {
|
|
6
|
+
repository;
|
|
7
|
+
fetcher;
|
|
8
|
+
config;
|
|
9
|
+
policy;
|
|
10
|
+
allowLocalhostForTesting;
|
|
11
|
+
constructor(repository, options = {}) {
|
|
12
|
+
this.repository = repository;
|
|
13
|
+
this.config = {
|
|
14
|
+
...DEFAULT_CRAWLER_CONFIG,
|
|
15
|
+
...options.crawlerConfig,
|
|
16
|
+
};
|
|
17
|
+
this.allowLocalhostForTesting = options.allowLocalhostForTesting ?? false;
|
|
18
|
+
this.policy = {
|
|
19
|
+
purpose: 'conceptual',
|
|
20
|
+
maxPages: this.config.maxPages,
|
|
21
|
+
maxDepth: this.config.maxDepth || 2,
|
|
22
|
+
followLlmsReferences: true,
|
|
23
|
+
followExternalDomains: false,
|
|
24
|
+
...options.crawlPolicy,
|
|
25
|
+
};
|
|
26
|
+
this.fetcher = new SecureFetcher({
|
|
27
|
+
timeoutMs: this.config.timeoutMs,
|
|
28
|
+
maxBytes: this.config.maxBytesPerResponse,
|
|
29
|
+
maxRedirects: this.config.maxRedirects,
|
|
30
|
+
userAgent: this.config.userAgent,
|
|
31
|
+
allowLocalhostForTesting: this.allowLocalhostForTesting,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async ingest(targetUrl) {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
// 1. SSRF & Protocol validation before making any discovery probes
|
|
37
|
+
await validateTargetUrl(targetUrl, {
|
|
38
|
+
allowLocalhostForTesting: this.allowLocalhostForTesting,
|
|
39
|
+
});
|
|
40
|
+
const coordinator = createDefaultDiscoveryCoordinator();
|
|
41
|
+
const discovered = await coordinator.discoverAll(targetUrl, this.fetcher);
|
|
42
|
+
const sourceIds = {};
|
|
43
|
+
for (const s of discovered) {
|
|
44
|
+
const id = this.repository.saveSource(s);
|
|
45
|
+
sourceIds[s.url] = id;
|
|
46
|
+
}
|
|
47
|
+
const conceptualRank = rankSources(discovered, 'conceptual');
|
|
48
|
+
const apiRank = rankSources(discovered, 'api');
|
|
49
|
+
const primarySource = conceptualRank.recommended || discovered[0];
|
|
50
|
+
const primarySourceId = primarySource
|
|
51
|
+
? (sourceIds[primarySource.url] || this.repository.saveSource(primarySource))
|
|
52
|
+
: this.repository.saveSource({
|
|
53
|
+
url: targetUrl,
|
|
54
|
+
type: 'web',
|
|
55
|
+
discoveredBy: 'direct',
|
|
56
|
+
status: 'valid',
|
|
57
|
+
confidence: 1.0,
|
|
58
|
+
authority: 'official',
|
|
59
|
+
machineReadable: false,
|
|
60
|
+
});
|
|
61
|
+
const purposes = ['navigation', 'conceptual', 'api', 'examples', 'implementation'];
|
|
62
|
+
const selectedSources = purposes.map(p => {
|
|
63
|
+
const ranked = rankSources(discovered, p);
|
|
64
|
+
return {
|
|
65
|
+
purpose: p,
|
|
66
|
+
sourceId: ranked.recommended ? (sourceIds[ranked.recommended.url] || primarySourceId) : primarySourceId,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
const queue = [];
|
|
70
|
+
const visited = new Set();
|
|
71
|
+
const ingestedPages = [];
|
|
72
|
+
const warnings = [];
|
|
73
|
+
const errors = [];
|
|
74
|
+
let pagesDiscovered = 0;
|
|
75
|
+
const enqueue = (url, depth) => {
|
|
76
|
+
try {
|
|
77
|
+
const parsed = new URL(url);
|
|
78
|
+
const normalized = `${parsed.origin}${parsed.pathname}`;
|
|
79
|
+
pagesDiscovered++;
|
|
80
|
+
if (depth > this.policy.maxDepth)
|
|
81
|
+
return;
|
|
82
|
+
if (!visited.has(normalized) && queue.length < this.policy.maxPages) {
|
|
83
|
+
queue.push({ url: normalized, depth });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Ignore
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// 1. Prioritize targetUrl as the primary entry point (depth: 0)
|
|
91
|
+
enqueue(targetUrl, 0);
|
|
92
|
+
// 2. If an OpenAPI spec is available, enqueue it (depth: 0)
|
|
93
|
+
if (apiRank.recommended && apiRank.recommended.type === 'openapi' && apiRank.recommended.url !== targetUrl) {
|
|
94
|
+
enqueue(apiRank.recommended.url, 0);
|
|
95
|
+
}
|
|
96
|
+
// 3. If llms.txt or llms-full.txt is available, enqueue it (depth: 0)
|
|
97
|
+
const llmsFull = discovered.find(s => s.type === 'llms_full_txt' && s.status === 'valid');
|
|
98
|
+
const llms = discovered.find(s => s.type === 'llms_txt' && s.status === 'valid');
|
|
99
|
+
if (llmsFull && llmsFull.url !== targetUrl) {
|
|
100
|
+
enqueue(llmsFull.url, 0);
|
|
101
|
+
}
|
|
102
|
+
else if (llms && llms.url !== targetUrl) {
|
|
103
|
+
enqueue(llms.url, 0);
|
|
104
|
+
}
|
|
105
|
+
if (primarySource && primarySource.url !== targetUrl) {
|
|
106
|
+
enqueue(primarySource.url, 0);
|
|
107
|
+
}
|
|
108
|
+
const targetOrigin = new URL(targetUrl).origin;
|
|
109
|
+
while (queue.length > 0 && ingestedPages.length < this.policy.maxPages) {
|
|
110
|
+
const item = queue.shift();
|
|
111
|
+
const currentUrl = item.url;
|
|
112
|
+
const currentDepth = item.depth;
|
|
113
|
+
if (visited.has(currentUrl))
|
|
114
|
+
continue;
|
|
115
|
+
visited.add(currentUrl);
|
|
116
|
+
try {
|
|
117
|
+
const res = await this.fetcher.fetch(currentUrl);
|
|
118
|
+
if (res.status < 200 || res.status >= 300) {
|
|
119
|
+
errors.push({ url: currentUrl, error: `HTTP status ${res.status}` });
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const page = buildNormalizedPage({
|
|
123
|
+
sourceId: primarySourceId,
|
|
124
|
+
url: res.finalUrl || currentUrl,
|
|
125
|
+
rawContent: res.body,
|
|
126
|
+
contentType: res.contentType,
|
|
127
|
+
sourceUrl: primarySource?.url || targetUrl,
|
|
128
|
+
targetUrl,
|
|
129
|
+
discoveredBy: primarySource?.discoveredBy || 'direct',
|
|
130
|
+
fetchedAt: new Date().toISOString(),
|
|
131
|
+
});
|
|
132
|
+
this.repository.savePage(page);
|
|
133
|
+
ingestedPages.push(page);
|
|
134
|
+
// Subpage link discovery
|
|
135
|
+
if (isValidLlmsTxt(res.body)) {
|
|
136
|
+
if (this.policy.followLlmsReferences && currentDepth < this.policy.maxDepth) {
|
|
137
|
+
const llmsDoc = parseLlmsTxt(res.body, currentUrl);
|
|
138
|
+
for (const sec of llmsDoc.sections) {
|
|
139
|
+
for (const lnk of sec.links) {
|
|
140
|
+
if (ingestedPages.length + queue.length < this.policy.maxPages) {
|
|
141
|
+
try {
|
|
142
|
+
const parsedLnk = new URL(lnk.url);
|
|
143
|
+
if (this.policy.followExternalDomains || parsedLnk.origin === targetOrigin) {
|
|
144
|
+
enqueue(lnk.url, currentDepth + 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Ignore
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
if (currentDepth < this.policy.maxDepth) {
|
|
157
|
+
for (const lnk of page.links) {
|
|
158
|
+
if (ingestedPages.length + queue.length < this.policy.maxPages) {
|
|
159
|
+
try {
|
|
160
|
+
const linkUrl = new URL(lnk.url);
|
|
161
|
+
if (this.policy.followExternalDomains || linkUrl.origin === targetOrigin) {
|
|
162
|
+
enqueue(lnk.url, currentDepth + 1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
// Ignore
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
errors.push({ url: currentUrl, error: err instanceof Error ? err.message : String(err) });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const snapshotId = this.repository.createSnapshot(primarySourceId, {
|
|
178
|
+
targetUrl,
|
|
179
|
+
pageCount: ingestedPages.length,
|
|
180
|
+
ingestedAt: new Date().toISOString(),
|
|
181
|
+
});
|
|
182
|
+
// Milestone 2: Semantic slicing of pages into standalone DocumentChunks
|
|
183
|
+
let totalChunks = 0;
|
|
184
|
+
for (const p of ingestedPages) {
|
|
185
|
+
const slicingResult = slicePageIntoChunks(p, snapshotId);
|
|
186
|
+
this.repository.saveChunks(slicingResult.chunks, slicingResult.relationships, slicingResult.codeSnippets, slicingResult.symbols);
|
|
187
|
+
totalChunks += slicingResult.chunks.length;
|
|
188
|
+
// Milestone 4: API Endpoints
|
|
189
|
+
if (p.openApiSummary || detectOpenApiSpec(p.content, p.url)) {
|
|
190
|
+
const endpoints = parseOpenApiEndpoints(p.content, p.id, snapshotId, p.url, p.docVersion);
|
|
191
|
+
if (endpoints.length > 0) {
|
|
192
|
+
this.repository.saveApiEndpoints(endpoints);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Milestone 4: Indexed Examples
|
|
196
|
+
const examples = extractIndexedExamples(p, slicingResult.chunks, primarySource?.authority || 'official', p.docVersion, snapshotId);
|
|
197
|
+
if (examples.length > 0) {
|
|
198
|
+
this.repository.saveIndexedExamples(examples);
|
|
199
|
+
}
|
|
200
|
+
// Milestone 4: Pitfalls
|
|
201
|
+
const pitfalls = extractPitfalls(p, slicingResult.chunks, p.docVersion, snapshotId);
|
|
202
|
+
if (pitfalls.length > 0) {
|
|
203
|
+
this.repository.savePitfalls(pitfalls);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const durationMs = Date.now() - startTime;
|
|
207
|
+
let totalBytes = 0;
|
|
208
|
+
let totalEstimatedTokens = 0;
|
|
209
|
+
let totalCodeExamples = 0;
|
|
210
|
+
for (const p of ingestedPages) {
|
|
211
|
+
totalBytes += p.rawBytes;
|
|
212
|
+
totalEstimatedTokens += p.estimatedTokens;
|
|
213
|
+
totalCodeExamples += p.codeExamples.length;
|
|
214
|
+
if (p.securityAnnotations.length > 0) {
|
|
215
|
+
warnings.push(`Page "${p.url}" generated ${p.securityAnnotations.length} security alert(s).`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
targetUrl,
|
|
220
|
+
target: {
|
|
221
|
+
type: 'url',
|
|
222
|
+
value: targetUrl,
|
|
223
|
+
normalizedUrl: targetUrl,
|
|
224
|
+
},
|
|
225
|
+
primarySourceId,
|
|
226
|
+
sourcesDiscovered: discovered,
|
|
227
|
+
selectedSources,
|
|
228
|
+
pages: ingestedPages,
|
|
229
|
+
pagesDiscovered,
|
|
230
|
+
pagesFetched: visited.size,
|
|
231
|
+
pagesStored: ingestedPages.length,
|
|
232
|
+
snapshotId,
|
|
233
|
+
warnings,
|
|
234
|
+
errors,
|
|
235
|
+
durationMs,
|
|
236
|
+
stats: {
|
|
237
|
+
totalPages: ingestedPages.length,
|
|
238
|
+
totalBytes,
|
|
239
|
+
totalEstimatedTokens,
|
|
240
|
+
totalCodeExamples,
|
|
241
|
+
machineReadableSources: discovered.filter(s => s.status === 'valid' && s.machineReadable).length,
|
|
242
|
+
totalChunks,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const DEFAULT_CRAWLER_CONFIG = {
|
|
2
|
+
maxPages: 50,
|
|
3
|
+
maxDepth: 3,
|
|
4
|
+
maxBytesPerResponse: 10 * 1024 * 1024, // 10MB
|
|
5
|
+
timeoutMs: 10000, // 10 seconds
|
|
6
|
+
maxRedirects: 5,
|
|
7
|
+
concurrency: 5,
|
|
8
|
+
allowedProtocols: ['http:', 'https:'],
|
|
9
|
+
userAgent: 'DocOrbit/1.0 (+https://github.com/docorbit/docorbit)',
|
|
10
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SsrfValidationOptions } from '../../security/src/index.ts';
|
|
2
|
+
export interface FetchResult {
|
|
3
|
+
url: string;
|
|
4
|
+
finalUrl: string;
|
|
5
|
+
status: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
body: string;
|
|
9
|
+
contentType: string;
|
|
10
|
+
bytesRead: number;
|
|
11
|
+
}
|
|
12
|
+
export interface FetchOptions extends SsrfValidationOptions {
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
maxRedirects?: number;
|
|
16
|
+
userAgent?: string;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
method?: string;
|
|
19
|
+
fetchFn?: typeof fetch;
|
|
20
|
+
allowCrossDomainRedirects?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class SecureFetcher {
|
|
23
|
+
private timeoutMs;
|
|
24
|
+
private maxBytes;
|
|
25
|
+
private maxRedirects;
|
|
26
|
+
private userAgent;
|
|
27
|
+
private allowLocalhostForTesting;
|
|
28
|
+
private fetchFn;
|
|
29
|
+
constructor(defaults?: Partial<FetchOptions>);
|
|
30
|
+
fetch(urlStr: string, options?: FetchOptions): Promise<FetchResult>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { FetchTimeoutError, PayloadTooLargeError, DocOrbitError, } from "../../shared/src/index.js";
|
|
2
|
+
import { validateTargetUrl } from "../../security/src/index.js";
|
|
3
|
+
import { DEFAULT_CRAWLER_CONFIG } from "./config.js";
|
|
4
|
+
export class SecureFetcher {
|
|
5
|
+
timeoutMs;
|
|
6
|
+
maxBytes;
|
|
7
|
+
maxRedirects;
|
|
8
|
+
userAgent;
|
|
9
|
+
allowLocalhostForTesting;
|
|
10
|
+
fetchFn;
|
|
11
|
+
constructor(defaults = {}) {
|
|
12
|
+
this.timeoutMs = defaults.timeoutMs ?? DEFAULT_CRAWLER_CONFIG.timeoutMs;
|
|
13
|
+
this.maxBytes = defaults.maxBytes ?? DEFAULT_CRAWLER_CONFIG.maxBytesPerResponse;
|
|
14
|
+
this.maxRedirects = defaults.maxRedirects ?? DEFAULT_CRAWLER_CONFIG.maxRedirects;
|
|
15
|
+
this.userAgent = defaults.userAgent ?? DEFAULT_CRAWLER_CONFIG.userAgent;
|
|
16
|
+
this.allowLocalhostForTesting = defaults.allowLocalhostForTesting ?? false;
|
|
17
|
+
this.fetchFn = defaults.fetchFn ?? globalThis.fetch;
|
|
18
|
+
}
|
|
19
|
+
async fetch(urlStr, options = {}) {
|
|
20
|
+
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
|
21
|
+
const maxBytes = options.maxBytes ?? this.maxBytes;
|
|
22
|
+
const maxRedirects = options.maxRedirects ?? this.maxRedirects;
|
|
23
|
+
const userAgent = options.userAgent ?? this.userAgent;
|
|
24
|
+
const method = options.method ?? 'GET';
|
|
25
|
+
const allowLocalhost = options.allowLocalhostForTesting ?? this.allowLocalhostForTesting;
|
|
26
|
+
const activeFetch = options.fetchFn ?? this.fetchFn;
|
|
27
|
+
let currentUrl = urlStr;
|
|
28
|
+
let redirectCount = 0;
|
|
29
|
+
const seenRedirects = new Set();
|
|
30
|
+
seenRedirects.add(currentUrl);
|
|
31
|
+
while (redirectCount <= maxRedirects) {
|
|
32
|
+
// 1. SSRF & Protocol validation before making the hop
|
|
33
|
+
await validateTargetUrl(currentUrl, {
|
|
34
|
+
allowLocalhostForTesting: allowLocalhost,
|
|
35
|
+
});
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
const timeoutId = setTimeout(() => {
|
|
38
|
+
controller.abort(new FetchTimeoutError(`Request timed out after ${timeoutMs}ms`, timeoutMs));
|
|
39
|
+
}, timeoutMs);
|
|
40
|
+
try {
|
|
41
|
+
const reqHeaders = {
|
|
42
|
+
'User-Agent': userAgent,
|
|
43
|
+
Accept: 'text/html,application/xhtml+xml,text/plain,text/markdown,application/json,*/*',
|
|
44
|
+
...options.headers,
|
|
45
|
+
};
|
|
46
|
+
const res = await activeFetch(currentUrl, {
|
|
47
|
+
method,
|
|
48
|
+
headers: reqHeaders,
|
|
49
|
+
redirect: 'manual',
|
|
50
|
+
signal: controller.signal,
|
|
51
|
+
});
|
|
52
|
+
// 2. Handle HTTP redirects (301, 302, 303, 307, 308)
|
|
53
|
+
if ([301, 302, 303, 307, 308].includes(res.status)) {
|
|
54
|
+
const location = res.headers.get('location');
|
|
55
|
+
if (!location) {
|
|
56
|
+
throw new DocOrbitError(`Redirect response (${res.status}) missing Location header.`);
|
|
57
|
+
}
|
|
58
|
+
redirectCount++;
|
|
59
|
+
if (redirectCount > maxRedirects) {
|
|
60
|
+
throw new DocOrbitError(`Exceeded maximum allowed redirects (${maxRedirects}).`);
|
|
61
|
+
}
|
|
62
|
+
const nextUrl = new URL(location, currentUrl).href;
|
|
63
|
+
// Check for redirect loop
|
|
64
|
+
if (seenRedirects.has(nextUrl)) {
|
|
65
|
+
throw new DocOrbitError(`Redirect loop detected: "${nextUrl}" already visited in redirect chain.`);
|
|
66
|
+
}
|
|
67
|
+
seenRedirects.add(nextUrl);
|
|
68
|
+
// Enforce domain/origin policy
|
|
69
|
+
if (options.allowCrossDomainRedirects === false) {
|
|
70
|
+
const origOrigin = new URL(urlStr).origin;
|
|
71
|
+
const nextOrigin = new URL(nextUrl).origin;
|
|
72
|
+
if (origOrigin !== nextOrigin) {
|
|
73
|
+
throw new DocOrbitError(`Cross-origin redirect from "${origOrigin}" to "${nextOrigin}" prohibited by policy.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
currentUrl = nextUrl;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// 3. Extract response headers
|
|
80
|
+
const headers = {};
|
|
81
|
+
res.headers.forEach((val, key) => {
|
|
82
|
+
headers[key.toLowerCase()] = val;
|
|
83
|
+
});
|
|
84
|
+
const contentType = headers['content-type'] || 'application/octet-stream';
|
|
85
|
+
// 4. Stream response body with byte counting
|
|
86
|
+
let bytesRead = 0;
|
|
87
|
+
const chunks = [];
|
|
88
|
+
if (res.body) {
|
|
89
|
+
const reader = res.body.getReader();
|
|
90
|
+
try {
|
|
91
|
+
while (true) {
|
|
92
|
+
const { done, value } = await reader.read();
|
|
93
|
+
if (done)
|
|
94
|
+
break;
|
|
95
|
+
if (value) {
|
|
96
|
+
bytesRead += value.length;
|
|
97
|
+
if (bytesRead > maxBytes) {
|
|
98
|
+
controller.abort();
|
|
99
|
+
throw new PayloadTooLargeError(`Response exceeded maximum allowed size of ${maxBytes} bytes (read ${bytesRead} bytes).`, bytesRead, maxBytes);
|
|
100
|
+
}
|
|
101
|
+
chunks.push(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
reader.releaseLock();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const totalBuffer = Buffer.concat(chunks);
|
|
110
|
+
const bodyText = totalBuffer.toString('utf-8');
|
|
111
|
+
return {
|
|
112
|
+
url: urlStr,
|
|
113
|
+
finalUrl: currentUrl,
|
|
114
|
+
status: res.status,
|
|
115
|
+
statusText: res.statusText,
|
|
116
|
+
headers,
|
|
117
|
+
body: bodyText,
|
|
118
|
+
contentType,
|
|
119
|
+
bytesRead,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (err instanceof DocOrbitError)
|
|
124
|
+
throw err;
|
|
125
|
+
if (controller.signal.aborted) {
|
|
126
|
+
const reason = controller.signal.reason;
|
|
127
|
+
if (reason instanceof DocOrbitError)
|
|
128
|
+
throw reason;
|
|
129
|
+
throw new FetchTimeoutError(`Request timed out after ${timeoutMs}ms`, timeoutMs);
|
|
130
|
+
}
|
|
131
|
+
throw new DocOrbitError(`Fetch failure for "${currentUrl}": ${err instanceof Error ? err.message : String(err)}`);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
clearTimeout(timeoutId);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw new DocOrbitError(`Exceeded maximum allowed redirects (${maxRedirects}).`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DiscoveryCoordinator } from './provider.ts';
|
|
2
|
+
export * from './provider.ts';
|
|
3
|
+
export * from './ranker.ts';
|
|
4
|
+
export * from './providers/llms-txt.ts';
|
|
5
|
+
export * from './providers/openapi.ts';
|
|
6
|
+
export * from './providers/markdown.ts';
|
|
7
|
+
export * from './providers/sitemap.ts';
|
|
8
|
+
export * from './providers/github.ts';
|
|
9
|
+
export * from './providers/skill.ts';
|
|
10
|
+
export * from './providers/generic.ts';
|
|
11
|
+
export declare function createDefaultDiscoveryCoordinator(): DiscoveryCoordinator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DiscoveryCoordinator } from "./provider.js";
|
|
2
|
+
import { LlmsTxtProvider } from "./providers/llms-txt.js";
|
|
3
|
+
import { OpenApiProvider } from "./providers/openapi.js";
|
|
4
|
+
import { MarkdownProvider } from "./providers/markdown.js";
|
|
5
|
+
import { SitemapProvider } from "./providers/sitemap.js";
|
|
6
|
+
import { GithubProvider } from "./providers/github.js";
|
|
7
|
+
import { SkillProvider } from "./providers/skill.js";
|
|
8
|
+
import { GenericWebProvider } from "./providers/generic.js";
|
|
9
|
+
export * from "./provider.js";
|
|
10
|
+
export * from "./ranker.js";
|
|
11
|
+
export * from "./providers/llms-txt.js";
|
|
12
|
+
export * from "./providers/openapi.js";
|
|
13
|
+
export * from "./providers/markdown.js";
|
|
14
|
+
export * from "./providers/sitemap.js";
|
|
15
|
+
export * from "./providers/github.js";
|
|
16
|
+
export * from "./providers/skill.js";
|
|
17
|
+
export * from "./providers/generic.js";
|
|
18
|
+
export function createDefaultDiscoveryCoordinator() {
|
|
19
|
+
const coordinator = new DiscoveryCoordinator();
|
|
20
|
+
coordinator
|
|
21
|
+
.register(new LlmsTxtProvider())
|
|
22
|
+
.register(new OpenApiProvider())
|
|
23
|
+
.register(new MarkdownProvider())
|
|
24
|
+
.register(new SitemapProvider())
|
|
25
|
+
.register(new SkillProvider())
|
|
26
|
+
.register(new GithubProvider())
|
|
27
|
+
.register(new GenericWebProvider());
|
|
28
|
+
return coordinator;
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DiscoveredSource } from '../../shared/src/index.ts';
|
|
2
|
+
import { SecureFetcher } from '../../crawler/src/index.ts';
|
|
3
|
+
export interface DiscoveryProvider {
|
|
4
|
+
name: string;
|
|
5
|
+
discover(targetUrl: string, fetcher: SecureFetcher): Promise<DiscoveredSource[]>;
|
|
6
|
+
}
|
|
7
|
+
export declare class DiscoveryCoordinator {
|
|
8
|
+
private providers;
|
|
9
|
+
register(provider: DiscoveryProvider): this;
|
|
10
|
+
getProviders(): DiscoveryProvider[];
|
|
11
|
+
discoverAll(targetUrl: string, fetcher: SecureFetcher): Promise<DiscoveredSource[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class DiscoveryCoordinator {
|
|
2
|
+
providers = [];
|
|
3
|
+
register(provider) {
|
|
4
|
+
this.providers.push(provider);
|
|
5
|
+
return this;
|
|
6
|
+
}
|
|
7
|
+
getProviders() {
|
|
8
|
+
return [...this.providers];
|
|
9
|
+
}
|
|
10
|
+
async discoverAll(targetUrl, fetcher) {
|
|
11
|
+
const results = await Promise.allSettled(this.providers.map(p => p.discover(targetUrl, fetcher)));
|
|
12
|
+
const allSources = [];
|
|
13
|
+
for (const res of results) {
|
|
14
|
+
if (res.status === 'fulfilled') {
|
|
15
|
+
allSources.push(...res.value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Deduplicate sources by normalized URL
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const deduped = [];
|
|
21
|
+
for (const s of allSources) {
|
|
22
|
+
const normalizedUrl = s.url.replace(/\/$/, '').toLowerCase();
|
|
23
|
+
if (!seen.has(normalizedUrl)) {
|
|
24
|
+
seen.add(normalizedUrl);
|
|
25
|
+
deduped.push(s);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return deduped;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DiscoveredSource } from '../../../shared/src/index.ts';
|
|
2
|
+
import { SecureFetcher } from '../../../crawler/src/index.ts';
|
|
3
|
+
import type { DiscoveryProvider } from '../provider.ts';
|
|
4
|
+
export declare class GenericWebProvider implements DiscoveryProvider {
|
|
5
|
+
name: string;
|
|
6
|
+
discover(targetUrl: string, fetcher: SecureFetcher): Promise<DiscoveredSource[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export class GenericWebProvider {
|
|
2
|
+
name = 'generic_web';
|
|
3
|
+
async discover(targetUrl, fetcher) {
|
|
4
|
+
const results = [];
|
|
5
|
+
try {
|
|
6
|
+
const res = await fetcher.fetch(targetUrl, {
|
|
7
|
+
timeoutMs: 5000,
|
|
8
|
+
});
|
|
9
|
+
if (res.status >= 200 && res.status < 300) {
|
|
10
|
+
let framework = 'unknown';
|
|
11
|
+
const bodyLower = res.body.toLowerCase();
|
|
12
|
+
// Check generator meta tags or distinctive DOM anchors first
|
|
13
|
+
const metaGenerator = res.body.match(/<meta\b[^>]*\bname=["']generator["'][^>]*\bcontent=["']([^"']+)["']/i);
|
|
14
|
+
const generatorVal = metaGenerator ? metaGenerator[1].toLowerCase() : '';
|
|
15
|
+
if (generatorVal.includes('docusaurus') || res.body.includes('__docusaurus') || res.body.includes('docusaurus-plugin')) {
|
|
16
|
+
framework = 'docusaurus';
|
|
17
|
+
}
|
|
18
|
+
else if (generatorVal.includes('mintlify') || res.body.includes('_mintlify') || res.body.includes('mintlify.css') || res.body.includes('mintlify.com')) {
|
|
19
|
+
framework = 'mintlify';
|
|
20
|
+
}
|
|
21
|
+
else if (generatorVal.includes('nextra') || res.body.includes('__nextra')) {
|
|
22
|
+
framework = 'nextra';
|
|
23
|
+
}
|
|
24
|
+
else if (generatorVal.includes('gitbook') || res.body.includes('gitbook-root') || res.body.includes('data-gitbook')) {
|
|
25
|
+
framework = 'gitbook';
|
|
26
|
+
}
|
|
27
|
+
else if (generatorVal.includes('mkdocs') || res.body.includes('mkdocs')) {
|
|
28
|
+
framework = 'mkdocs';
|
|
29
|
+
}
|
|
30
|
+
else if (generatorVal.includes('sphinx') || res.body.includes('sphinxsidebar')) {
|
|
31
|
+
framework = 'sphinx';
|
|
32
|
+
}
|
|
33
|
+
// Section 18: Detect candidate doc sections without blindly crawling
|
|
34
|
+
const candidateSections = [];
|
|
35
|
+
const sectionRegex = /href=["']([^"'#?]+(?:\/docs|\/api|\/reference|\/guides|\/tutorials|\/changelog)[^"'#?]*)["']/gi;
|
|
36
|
+
let sMatch;
|
|
37
|
+
while ((sMatch = sectionRegex.exec(res.body)) !== null) {
|
|
38
|
+
try {
|
|
39
|
+
const secUrl = new URL(sMatch[1], targetUrl).href;
|
|
40
|
+
if (new URL(secUrl).origin === new URL(targetUrl).origin && !candidateSections.includes(secUrl)) {
|
|
41
|
+
candidateSections.push(secUrl);
|
|
42
|
+
if (candidateSections.length >= 10)
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Ignore
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const linkHeader = res.headers['link'];
|
|
51
|
+
if (linkHeader) {
|
|
52
|
+
const llmsMatch = linkHeader.match(/<([^>]+)>;\s*rel=["']?(?:llms-txt|alternate)["']?/i);
|
|
53
|
+
if (llmsMatch) {
|
|
54
|
+
try {
|
|
55
|
+
const fullLlmsUrl = new URL(llmsMatch[1], targetUrl).href;
|
|
56
|
+
results.push({
|
|
57
|
+
url: fullLlmsUrl,
|
|
58
|
+
type: 'llms_txt',
|
|
59
|
+
discoveredBy: `${this.name}:link-header`,
|
|
60
|
+
status: 'valid',
|
|
61
|
+
confidence: 0.99,
|
|
62
|
+
authority: 'official',
|
|
63
|
+
machineReadable: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
results.push({
|
|
72
|
+
url: res.finalUrl || targetUrl,
|
|
73
|
+
type: 'web',
|
|
74
|
+
discoveredBy: this.name,
|
|
75
|
+
status: 'valid',
|
|
76
|
+
contentType: res.contentType,
|
|
77
|
+
confidence: 0.85,
|
|
78
|
+
authority: 'official',
|
|
79
|
+
machineReadable: false,
|
|
80
|
+
metadata: {
|
|
81
|
+
framework,
|
|
82
|
+
status: res.status,
|
|
83
|
+
bytes: res.bytesRead,
|
|
84
|
+
candidateSections,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Continue
|
|
91
|
+
}
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DiscoveredSource } from '../../../shared/src/index.ts';
|
|
2
|
+
import { SecureFetcher } from '../../../crawler/src/index.ts';
|
|
3
|
+
import type { DiscoveryProvider } from '../provider.ts';
|
|
4
|
+
export declare class GithubProvider implements DiscoveryProvider {
|
|
5
|
+
name: string;
|
|
6
|
+
discover(targetUrl: string, fetcher: SecureFetcher): Promise<DiscoveredSource[]>;
|
|
7
|
+
}
|