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,144 @@
|
|
|
1
|
+
import { extractSearchTokens } from "../search-tokens.js";
|
|
2
|
+
export class PitfallRepository {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
savePitfalls(pitfalls) {
|
|
8
|
+
if (pitfalls.length === 0)
|
|
9
|
+
return;
|
|
10
|
+
const raw = this.db.getRawDb();
|
|
11
|
+
const insertPf = raw.prepare(`
|
|
12
|
+
INSERT INTO pitfalls (
|
|
13
|
+
id, chunk_id, page_id, snapshot_id, kind, title,
|
|
14
|
+
content, related_api, related_symbol, doc_version,
|
|
15
|
+
provenance_json, created_at
|
|
16
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
17
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
18
|
+
chunk_id = excluded.chunk_id,
|
|
19
|
+
kind = excluded.kind,
|
|
20
|
+
title = excluded.title,
|
|
21
|
+
content = excluded.content,
|
|
22
|
+
related_api = excluded.related_api,
|
|
23
|
+
related_symbol = excluded.related_symbol,
|
|
24
|
+
doc_version = excluded.doc_version,
|
|
25
|
+
provenance_json = excluded.provenance_json
|
|
26
|
+
`);
|
|
27
|
+
const insertFts = this.db.isFtsAvailable()
|
|
28
|
+
? raw.prepare(`
|
|
29
|
+
INSERT INTO pitfalls_fts (pitfall_id, kind, title, content, related_api, related_symbol)
|
|
30
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
31
|
+
`)
|
|
32
|
+
: null;
|
|
33
|
+
const deleteFts = this.db.isFtsAvailable()
|
|
34
|
+
? raw.prepare('DELETE FROM pitfalls_fts WHERE pitfall_id = ?')
|
|
35
|
+
: null;
|
|
36
|
+
raw.exec('BEGIN TRANSACTION;');
|
|
37
|
+
try {
|
|
38
|
+
for (const pf of pitfalls) {
|
|
39
|
+
insertPf.run(pf.id, pf.chunkId || null, pf.pageId, pf.snapshotId || 'snap_default', pf.kind, pf.title, pf.content || pf.message || '', pf.relatedApi || null, pf.relatedSymbol || null, pf.docVersion || null, pf.provenance ? JSON.stringify(pf.provenance) : null, pf.createdAt || new Date().toISOString());
|
|
40
|
+
if (insertFts && deleteFts) {
|
|
41
|
+
deleteFts.run(pf.id);
|
|
42
|
+
insertFts.run(pf.id, pf.kind, pf.title, pf.content || pf.message || '', pf.relatedApi || '', pf.relatedSymbol || '');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
raw.exec('COMMIT;');
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
raw.exec('ROLLBACK;');
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
getPitfallsBySnapshot(snapshotId) {
|
|
53
|
+
const raw = this.db.getRawDb();
|
|
54
|
+
const rows = raw.prepare('SELECT * FROM pitfalls WHERE snapshot_id = ?').all(snapshotId);
|
|
55
|
+
return rows.map(r => this.hydratePitfall(r));
|
|
56
|
+
}
|
|
57
|
+
searchPitfalls(query, options = {}) {
|
|
58
|
+
const raw = this.db.getRawDb();
|
|
59
|
+
const limit = options.limit || 10;
|
|
60
|
+
const term = query.trim();
|
|
61
|
+
let results = [];
|
|
62
|
+
// FTS attempt
|
|
63
|
+
if (this.db.isFtsAvailable() && term.length > 0) {
|
|
64
|
+
const cleanTokens = extractSearchTokens(term);
|
|
65
|
+
if (cleanTokens.length > 0) {
|
|
66
|
+
const sanitizedFts = cleanTokens
|
|
67
|
+
.map(t => t.length >= 4 ? `"${t.replace(/"/g, '""')}"*` : `"${t.replace(/"/g, '""')}"`)
|
|
68
|
+
.join(' OR ');
|
|
69
|
+
try {
|
|
70
|
+
let sql = `
|
|
71
|
+
SELECT pf.*, fts.rank as fts_rank
|
|
72
|
+
FROM pitfalls pf
|
|
73
|
+
JOIN pitfalls_fts fts ON pf.id = fts.pitfall_id
|
|
74
|
+
WHERE pitfalls_fts MATCH ?
|
|
75
|
+
`;
|
|
76
|
+
const params = [sanitizedFts];
|
|
77
|
+
if (options.kind) {
|
|
78
|
+
sql += ' AND pf.kind = ?';
|
|
79
|
+
params.push(options.kind);
|
|
80
|
+
}
|
|
81
|
+
if (options.docVersion) {
|
|
82
|
+
sql += ' AND (pf.doc_version = ? OR pf.doc_version IS NULL)';
|
|
83
|
+
params.push(options.docVersion);
|
|
84
|
+
}
|
|
85
|
+
sql += ' ORDER BY fts.rank LIMIT ?';
|
|
86
|
+
params.push(limit);
|
|
87
|
+
const rows = raw.prepare(sql).all(...params);
|
|
88
|
+
results = rows.map(r => this.hydratePitfall(r));
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Fall through to LIKE
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (results.length === 0) {
|
|
96
|
+
// LIKE fallback
|
|
97
|
+
let sql = 'SELECT * FROM pitfalls WHERE 1=1';
|
|
98
|
+
const params = [];
|
|
99
|
+
if (options.kind) {
|
|
100
|
+
sql += ' AND kind = ?';
|
|
101
|
+
params.push(options.kind);
|
|
102
|
+
}
|
|
103
|
+
if (options.docVersion) {
|
|
104
|
+
sql += ' AND (doc_version = ? OR doc_version IS NULL)';
|
|
105
|
+
params.push(options.docVersion);
|
|
106
|
+
}
|
|
107
|
+
if (term.length > 0) {
|
|
108
|
+
const tokens = extractSearchTokens(term);
|
|
109
|
+
if (tokens.length > 0) {
|
|
110
|
+
const tokenClauses = tokens.map(() => '(title LIKE ? OR content LIKE ? OR related_api LIKE ? OR related_symbol LIKE ?)');
|
|
111
|
+
sql += ` AND (${tokenClauses.join(' OR ')})`;
|
|
112
|
+
for (const t of tokens) {
|
|
113
|
+
const lp = `%${t}%`;
|
|
114
|
+
params.push(lp, lp, lp, lp);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
sql += ' ORDER BY kind LIMIT ?';
|
|
122
|
+
params.push(limit);
|
|
123
|
+
const rows = raw.prepare(sql).all(...params);
|
|
124
|
+
results = rows.map(r => this.hydratePitfall(r));
|
|
125
|
+
}
|
|
126
|
+
return results;
|
|
127
|
+
}
|
|
128
|
+
hydratePitfall(row) {
|
|
129
|
+
return {
|
|
130
|
+
id: String(row.id),
|
|
131
|
+
chunkId: row.chunk_id ? String(row.chunk_id) : undefined,
|
|
132
|
+
pageId: String(row.page_id),
|
|
133
|
+
snapshotId: String(row.snapshot_id),
|
|
134
|
+
kind: String(row.kind),
|
|
135
|
+
title: String(row.title),
|
|
136
|
+
content: String(row.content),
|
|
137
|
+
relatedApi: row.related_api ? String(row.related_api) : undefined,
|
|
138
|
+
relatedSymbol: row.related_symbol ? String(row.related_symbol) : undefined,
|
|
139
|
+
docVersion: row.doc_version ? String(row.doc_version) : undefined,
|
|
140
|
+
provenance: row.provenance_json ? JSON.parse(String(row.provenance_json)) : undefined,
|
|
141
|
+
createdAt: String(row.created_at),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DiscoveredSource, NormalizedPage } from '../../../shared/src/index.ts';
|
|
2
|
+
import type { DocOrbitDb } from '../db.ts';
|
|
3
|
+
export interface SnapshotRecord {
|
|
4
|
+
id: string;
|
|
5
|
+
sourceId: string;
|
|
6
|
+
snapshotHash: string;
|
|
7
|
+
pageCount: number;
|
|
8
|
+
capturedAt: string;
|
|
9
|
+
docVersion?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare class SourceRepository {
|
|
13
|
+
private db;
|
|
14
|
+
private hydratePageFn?;
|
|
15
|
+
constructor(db: DocOrbitDb, hydratePageFn?: (row: Record<string, unknown>) => NormalizedPage);
|
|
16
|
+
saveSource(source: DiscoveredSource): string;
|
|
17
|
+
getSource(id: string): (DiscoveredSource & {
|
|
18
|
+
id: string;
|
|
19
|
+
}) | null;
|
|
20
|
+
getSourceByUrl(url: string): (DiscoveredSource & {
|
|
21
|
+
id: string;
|
|
22
|
+
}) | null;
|
|
23
|
+
listSources(): Array<DiscoveredSource & {
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}>;
|
|
27
|
+
createSnapshot(sourceId: string, metadata?: Record<string, unknown>, docVersion?: string): string;
|
|
28
|
+
linkSnapshotPages(snapshotId: string, pageIds: string[]): void;
|
|
29
|
+
getSnapshot(snapshotId: string): SnapshotRecord | null;
|
|
30
|
+
listSnapshots(sourceId?: string): SnapshotRecord[];
|
|
31
|
+
getSnapshotPages(snapshotId: string): NormalizedPage[];
|
|
32
|
+
private mapSourceRow;
|
|
33
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { computeSha256 } from "../../../shared/src/index.js";
|
|
2
|
+
export class SourceRepository {
|
|
3
|
+
db;
|
|
4
|
+
hydratePageFn;
|
|
5
|
+
constructor(db, hydratePageFn) {
|
|
6
|
+
this.db = db;
|
|
7
|
+
this.hydratePageFn = hydratePageFn;
|
|
8
|
+
}
|
|
9
|
+
saveSource(source) {
|
|
10
|
+
const raw = this.db.getRawDb();
|
|
11
|
+
const id = `src_${computeSha256(source.url).slice(0, 16)}`;
|
|
12
|
+
const createdAt = new Date().toISOString();
|
|
13
|
+
const stmt = raw.prepare(`
|
|
14
|
+
INSERT INTO sources (
|
|
15
|
+
id, url, type, discovered_by, status, content_type,
|
|
16
|
+
confidence, authority, machine_readable, metadata, created_at
|
|
17
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
18
|
+
ON CONFLICT(url) DO UPDATE SET
|
|
19
|
+
type = excluded.type,
|
|
20
|
+
discovered_by = excluded.discovered_by,
|
|
21
|
+
status = excluded.status,
|
|
22
|
+
content_type = excluded.content_type,
|
|
23
|
+
confidence = excluded.confidence,
|
|
24
|
+
authority = excluded.authority,
|
|
25
|
+
machine_readable = excluded.machine_readable,
|
|
26
|
+
metadata = excluded.metadata
|
|
27
|
+
`);
|
|
28
|
+
stmt.run(id, source.url, source.type, source.discoveredBy || 'manual', source.status, source.contentType || null, source.confidence, source.authority, source.machineReadable ? 1 : 0, source.metadata ? JSON.stringify(source.metadata) : null, createdAt);
|
|
29
|
+
const row = raw.prepare('SELECT id FROM sources WHERE url = ?').get(source.url);
|
|
30
|
+
return row?.id || id;
|
|
31
|
+
}
|
|
32
|
+
getSource(id) {
|
|
33
|
+
const raw = this.db.getRawDb();
|
|
34
|
+
const row = raw.prepare('SELECT * FROM sources WHERE id = ?').get(id);
|
|
35
|
+
if (!row)
|
|
36
|
+
return null;
|
|
37
|
+
return this.mapSourceRow(row);
|
|
38
|
+
}
|
|
39
|
+
getSourceByUrl(url) {
|
|
40
|
+
const raw = this.db.getRawDb();
|
|
41
|
+
const row = raw.prepare('SELECT * FROM sources WHERE url = ?').get(url);
|
|
42
|
+
if (!row)
|
|
43
|
+
return null;
|
|
44
|
+
return this.mapSourceRow(row);
|
|
45
|
+
}
|
|
46
|
+
listSources() {
|
|
47
|
+
const raw = this.db.getRawDb();
|
|
48
|
+
const rows = raw.prepare('SELECT * FROM sources ORDER BY created_at DESC').all();
|
|
49
|
+
return rows.map(r => ({
|
|
50
|
+
...this.mapSourceRow(r),
|
|
51
|
+
createdAt: String(r.created_at),
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
createSnapshot(sourceId, metadata, docVersion) {
|
|
55
|
+
const raw = this.db.getRawDb();
|
|
56
|
+
const pages = raw.prepare('SELECT id, content_hash FROM pages WHERE source_id = ? ORDER BY id ASC').all(sourceId);
|
|
57
|
+
const combinedHash = computeSha256(pages.map(p => p.content_hash).join(':'));
|
|
58
|
+
const snapshotId = `snap_${combinedHash.slice(0, 16)}`;
|
|
59
|
+
const now = new Date().toISOString();
|
|
60
|
+
const version = docVersion || metadata?.docVersion || null;
|
|
61
|
+
const stmt = raw.prepare(`
|
|
62
|
+
INSERT INTO snapshots (id, source_id, snapshot_hash, page_count, captured_at, doc_version, metadata)
|
|
63
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
64
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
65
|
+
captured_at = excluded.captured_at,
|
|
66
|
+
page_count = excluded.page_count,
|
|
67
|
+
doc_version = COALESCE(excluded.doc_version, snapshots.doc_version),
|
|
68
|
+
metadata = excluded.metadata
|
|
69
|
+
`);
|
|
70
|
+
stmt.run(snapshotId, sourceId, combinedHash, pages.length, now, version, metadata ? JSON.stringify(metadata) : null);
|
|
71
|
+
// Link snapshot to page membership in snapshot_pages
|
|
72
|
+
const linkStmt = raw.prepare(`
|
|
73
|
+
INSERT OR REPLACE INTO snapshot_pages (snapshot_id, page_id, content_hash)
|
|
74
|
+
VALUES (?, ?, ?)
|
|
75
|
+
`);
|
|
76
|
+
for (const p of pages) {
|
|
77
|
+
linkStmt.run(snapshotId, p.id, p.content_hash);
|
|
78
|
+
}
|
|
79
|
+
return snapshotId;
|
|
80
|
+
}
|
|
81
|
+
linkSnapshotPages(snapshotId, pageIds) {
|
|
82
|
+
const raw = this.db.getRawDb();
|
|
83
|
+
const linkStmt = raw.prepare(`
|
|
84
|
+
INSERT OR REPLACE INTO snapshot_pages (snapshot_id, page_id, content_hash)
|
|
85
|
+
VALUES (?, ?, COALESCE((SELECT content_hash FROM pages WHERE id = ?), 'hash_default'))
|
|
86
|
+
`);
|
|
87
|
+
for (const pageId of pageIds) {
|
|
88
|
+
linkStmt.run(snapshotId, pageId, pageId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
getSnapshot(snapshotId) {
|
|
92
|
+
const raw = this.db.getRawDb();
|
|
93
|
+
const row = raw.prepare('SELECT * FROM snapshots WHERE id = ?').get(snapshotId);
|
|
94
|
+
if (!row)
|
|
95
|
+
return null;
|
|
96
|
+
return {
|
|
97
|
+
id: String(row.id),
|
|
98
|
+
sourceId: String(row.source_id),
|
|
99
|
+
snapshotHash: String(row.snapshot_hash),
|
|
100
|
+
pageCount: Number(row.page_count),
|
|
101
|
+
capturedAt: String(row.captured_at),
|
|
102
|
+
docVersion: row.doc_version ? String(row.doc_version) : undefined,
|
|
103
|
+
metadata: row.metadata ? JSON.parse(String(row.metadata)) : undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
listSnapshots(sourceId) {
|
|
107
|
+
const raw = this.db.getRawDb();
|
|
108
|
+
let sql = 'SELECT * FROM snapshots';
|
|
109
|
+
const params = [];
|
|
110
|
+
if (sourceId) {
|
|
111
|
+
sql += ' WHERE source_id = ?';
|
|
112
|
+
params.push(sourceId);
|
|
113
|
+
}
|
|
114
|
+
sql += ' ORDER BY captured_at DESC';
|
|
115
|
+
const rows = raw.prepare(sql).all(...params);
|
|
116
|
+
return rows.map(row => ({
|
|
117
|
+
id: String(row.id),
|
|
118
|
+
sourceId: String(row.source_id),
|
|
119
|
+
snapshotHash: String(row.snapshot_hash),
|
|
120
|
+
pageCount: Number(row.page_count),
|
|
121
|
+
capturedAt: String(row.captured_at),
|
|
122
|
+
docVersion: row.doc_version ? String(row.doc_version) : undefined,
|
|
123
|
+
metadata: row.metadata ? JSON.parse(String(row.metadata)) : undefined,
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
getSnapshotPages(snapshotId) {
|
|
127
|
+
const raw = this.db.getRawDb();
|
|
128
|
+
const rows = raw.prepare(`
|
|
129
|
+
SELECT p.* FROM pages p
|
|
130
|
+
JOIN snapshot_pages sp ON p.id = sp.page_id
|
|
131
|
+
WHERE sp.snapshot_id = ?
|
|
132
|
+
ORDER BY p.id ASC
|
|
133
|
+
`).all(snapshotId);
|
|
134
|
+
if (this.hydratePageFn) {
|
|
135
|
+
return rows.map(r => this.hydratePageFn(r));
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
mapSourceRow(row) {
|
|
140
|
+
return {
|
|
141
|
+
id: String(row.id),
|
|
142
|
+
url: String(row.url),
|
|
143
|
+
type: row.type,
|
|
144
|
+
discoveredBy: String(row.discovered_by),
|
|
145
|
+
status: row.status,
|
|
146
|
+
contentType: row.content_type ? String(row.content_type) : undefined,
|
|
147
|
+
confidence: Number(row.confidence),
|
|
148
|
+
authority: row.authority,
|
|
149
|
+
machineReadable: Number(row.machine_readable) === 1,
|
|
150
|
+
metadata: row.metadata ? JSON.parse(String(row.metadata)) : undefined,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { DiscoveredSource, NormalizedPage, DocumentChunk, ChunkCode, SymbolReference, ChunkRelationship, ChunkType, ApiEndpoint, IndexedExample, Pitfall, PitfallKind } from '../../shared/src/index.ts';
|
|
2
|
+
import type { DocOrbitDb } from './db.ts';
|
|
3
|
+
import type { Snapshot, ISourceRepository, IPageRepository, IChunkRepository, IApiRepository, IExampleRepository, IPitfallRepository } from './interfaces.ts';
|
|
4
|
+
import { SourceRepository } from './repositories/source-repository.ts';
|
|
5
|
+
import { PageRepository } from './repositories/page-repository.ts';
|
|
6
|
+
import { ChunkRepository } from './repositories/chunk-repository.ts';
|
|
7
|
+
import { ApiRepository } from './repositories/api-repository.ts';
|
|
8
|
+
import { ExampleRepository } from './repositories/example-repository.ts';
|
|
9
|
+
import { PitfallRepository } from './repositories/pitfall-repository.ts';
|
|
10
|
+
export type { Snapshot } from './interfaces.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Unified Facade for the DocOrbit database storage layer.
|
|
13
|
+
* Delegates domain responsibilities to specialized sub-repositories:
|
|
14
|
+
* - sources: ISourceRepository (sources, snapshots, snapshot-page links)
|
|
15
|
+
* - pages: IPageRepository (normalized pages, page links, page FTS)
|
|
16
|
+
* - chunks: IChunkRepository (document chunks, code, symbols, relationships, chunk FTS)
|
|
17
|
+
* - apis: IApiRepository (API endpoints, OpenAPI schemas, endpoint FTS)
|
|
18
|
+
* - examples: IExampleRepository (code examples, example FTS)
|
|
19
|
+
* - pitfalls: IPitfallRepository (pitfalls, gotchas, pitfall FTS)
|
|
20
|
+
*/
|
|
21
|
+
export declare class DocOrbitRepository implements ISourceRepository, IPageRepository, IChunkRepository, IApiRepository, IExampleRepository, IPitfallRepository {
|
|
22
|
+
readonly sources: SourceRepository;
|
|
23
|
+
readonly pages: PageRepository;
|
|
24
|
+
readonly chunks: ChunkRepository;
|
|
25
|
+
readonly apis: ApiRepository;
|
|
26
|
+
readonly examples: ExampleRepository;
|
|
27
|
+
readonly pitfalls: PitfallRepository;
|
|
28
|
+
readonly db: DocOrbitDb;
|
|
29
|
+
constructor(db: DocOrbitDb);
|
|
30
|
+
saveSource(source: DiscoveredSource): string;
|
|
31
|
+
getSource(id: string): DiscoveredSource | null;
|
|
32
|
+
getSourceByUrl(url: string): DiscoveredSource | null;
|
|
33
|
+
listSources(): DiscoveredSource[];
|
|
34
|
+
createSnapshot(sourceId: string, metadata?: Record<string, unknown>, docVersion?: string): string;
|
|
35
|
+
saveSnapshot(snapshot: Snapshot): void;
|
|
36
|
+
getSnapshot(id: string): Snapshot | null;
|
|
37
|
+
getLatestSnapshot(sourceId: string): Snapshot | null;
|
|
38
|
+
listSnapshots(sourceId: string): Snapshot[];
|
|
39
|
+
linkSnapshotPages(snapshotId: string, pageIds: string[]): void;
|
|
40
|
+
getSnapshotPages(snapshotId: string): NormalizedPage[];
|
|
41
|
+
savePage(page: NormalizedPage): void;
|
|
42
|
+
getPage(id: string): NormalizedPage | null;
|
|
43
|
+
getPageByUrl(normalizedUrl: string): NormalizedPage | null;
|
|
44
|
+
listPages(limit?: number, offset?: number): NormalizedPage[];
|
|
45
|
+
countPages(sourceId?: string): number;
|
|
46
|
+
savePageLinks(pageId: string, targetUrls: string[]): void;
|
|
47
|
+
getPageLinks(pageId: string): string[];
|
|
48
|
+
searchPagesFts(query: string, limit?: number): NormalizedPage[];
|
|
49
|
+
saveChunks(chunks: DocumentChunk[], relationships?: ChunkRelationship[], codeSnippets?: ChunkCode[], symbols?: SymbolReference[]): void;
|
|
50
|
+
getChunk(id: string): DocumentChunk | null;
|
|
51
|
+
getChunksByPage(pageId: string): DocumentChunk[];
|
|
52
|
+
getChunksBySnapshot(snapshotId: string): DocumentChunk[];
|
|
53
|
+
getChunksByVersion(docVersion: string): DocumentChunk[];
|
|
54
|
+
getChunkCode(chunkId: string): ChunkCode[];
|
|
55
|
+
getChunkSymbols(chunkId: string): SymbolReference[];
|
|
56
|
+
getChunkRelationships(chunkId: string): ChunkRelationship[];
|
|
57
|
+
countChunks(snapshotId?: string): number;
|
|
58
|
+
searchChunksFts(query: string, options?: {
|
|
59
|
+
limit?: number;
|
|
60
|
+
snapshotId?: string;
|
|
61
|
+
chunkType?: ChunkType;
|
|
62
|
+
docVersion?: string;
|
|
63
|
+
}): Array<{
|
|
64
|
+
chunk: DocumentChunk;
|
|
65
|
+
ftsRank: number;
|
|
66
|
+
symbols: SymbolReference[];
|
|
67
|
+
codeSnippets: ChunkCode[];
|
|
68
|
+
}>;
|
|
69
|
+
saveApiEndpoints(endpoints: ApiEndpoint[]): void;
|
|
70
|
+
getApiEndpoint(id: string): ApiEndpoint | null;
|
|
71
|
+
getApiEndpointsBySnapshot(snapshotId: string): ApiEndpoint[];
|
|
72
|
+
searchApiEndpoints(query: string, options?: {
|
|
73
|
+
method?: string;
|
|
74
|
+
docVersion?: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
}): ApiEndpoint[];
|
|
77
|
+
saveIndexedExamples(examples: IndexedExample[]): void;
|
|
78
|
+
getIndexedExamplesBySnapshot(snapshotId: string): IndexedExample[];
|
|
79
|
+
searchIndexedExamples(query: string, options?: {
|
|
80
|
+
language?: string;
|
|
81
|
+
framework?: string;
|
|
82
|
+
docVersion?: string;
|
|
83
|
+
limit?: number;
|
|
84
|
+
}): IndexedExample[];
|
|
85
|
+
savePitfalls(pitfalls: Pitfall[]): void;
|
|
86
|
+
getPitfallsBySnapshot(snapshotId: string): Pitfall[];
|
|
87
|
+
searchPitfalls(query: string, options?: {
|
|
88
|
+
kind?: PitfallKind;
|
|
89
|
+
docVersion?: string;
|
|
90
|
+
limit?: number;
|
|
91
|
+
}): Pitfall[];
|
|
92
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { SourceRepository } from "./repositories/source-repository.js";
|
|
2
|
+
import { PageRepository } from "./repositories/page-repository.js";
|
|
3
|
+
import { ChunkRepository } from "./repositories/chunk-repository.js";
|
|
4
|
+
import { ApiRepository } from "./repositories/api-repository.js";
|
|
5
|
+
import { ExampleRepository } from "./repositories/example-repository.js";
|
|
6
|
+
import { PitfallRepository } from "./repositories/pitfall-repository.js";
|
|
7
|
+
/**
|
|
8
|
+
* Unified Facade for the DocOrbit database storage layer.
|
|
9
|
+
* Delegates domain responsibilities to specialized sub-repositories:
|
|
10
|
+
* - sources: ISourceRepository (sources, snapshots, snapshot-page links)
|
|
11
|
+
* - pages: IPageRepository (normalized pages, page links, page FTS)
|
|
12
|
+
* - chunks: IChunkRepository (document chunks, code, symbols, relationships, chunk FTS)
|
|
13
|
+
* - apis: IApiRepository (API endpoints, OpenAPI schemas, endpoint FTS)
|
|
14
|
+
* - examples: IExampleRepository (code examples, example FTS)
|
|
15
|
+
* - pitfalls: IPitfallRepository (pitfalls, gotchas, pitfall FTS)
|
|
16
|
+
*/
|
|
17
|
+
export class DocOrbitRepository {
|
|
18
|
+
sources;
|
|
19
|
+
pages;
|
|
20
|
+
chunks;
|
|
21
|
+
apis;
|
|
22
|
+
examples;
|
|
23
|
+
pitfalls;
|
|
24
|
+
db;
|
|
25
|
+
constructor(db) {
|
|
26
|
+
this.db = db;
|
|
27
|
+
this.pages = new PageRepository(db);
|
|
28
|
+
this.sources = new SourceRepository(db, row => this.pages.hydratePage(row));
|
|
29
|
+
this.chunks = new ChunkRepository(db);
|
|
30
|
+
this.apis = new ApiRepository(db);
|
|
31
|
+
this.examples = new ExampleRepository(db);
|
|
32
|
+
this.pitfalls = new PitfallRepository(db);
|
|
33
|
+
}
|
|
34
|
+
// --- ISourceRepository Delegations ---
|
|
35
|
+
saveSource(source) {
|
|
36
|
+
return this.sources.saveSource(source);
|
|
37
|
+
}
|
|
38
|
+
getSource(id) {
|
|
39
|
+
return this.sources.getSource(id);
|
|
40
|
+
}
|
|
41
|
+
getSourceByUrl(url) {
|
|
42
|
+
return this.sources.getSourceByUrl(url);
|
|
43
|
+
}
|
|
44
|
+
listSources() {
|
|
45
|
+
return this.sources.listSources();
|
|
46
|
+
}
|
|
47
|
+
createSnapshot(sourceId, metadata, docVersion) {
|
|
48
|
+
return this.sources.createSnapshot(sourceId, metadata, docVersion);
|
|
49
|
+
}
|
|
50
|
+
saveSnapshot(snapshot) {
|
|
51
|
+
this.sources.saveSnapshot(snapshot);
|
|
52
|
+
}
|
|
53
|
+
getSnapshot(id) {
|
|
54
|
+
return this.sources.getSnapshot(id);
|
|
55
|
+
}
|
|
56
|
+
getLatestSnapshot(sourceId) {
|
|
57
|
+
return this.sources.getLatestSnapshot(sourceId);
|
|
58
|
+
}
|
|
59
|
+
listSnapshots(sourceId) {
|
|
60
|
+
return this.sources.listSnapshots(sourceId);
|
|
61
|
+
}
|
|
62
|
+
linkSnapshotPages(snapshotId, pageIds) {
|
|
63
|
+
this.sources.linkSnapshotPages(snapshotId, pageIds);
|
|
64
|
+
}
|
|
65
|
+
getSnapshotPages(snapshotId) {
|
|
66
|
+
return this.sources.getSnapshotPages(snapshotId);
|
|
67
|
+
}
|
|
68
|
+
// --- IPageRepository Delegations ---
|
|
69
|
+
savePage(page) {
|
|
70
|
+
this.pages.savePage(page);
|
|
71
|
+
}
|
|
72
|
+
getPage(id) {
|
|
73
|
+
return this.pages.getPage(id);
|
|
74
|
+
}
|
|
75
|
+
getPageByUrl(normalizedUrl) {
|
|
76
|
+
return this.pages.getPageByUrl(normalizedUrl);
|
|
77
|
+
}
|
|
78
|
+
listPages(limit, offset) {
|
|
79
|
+
return this.pages.listPages(limit, offset);
|
|
80
|
+
}
|
|
81
|
+
countPages(sourceId) {
|
|
82
|
+
return this.pages.countPages(sourceId);
|
|
83
|
+
}
|
|
84
|
+
savePageLinks(pageId, targetUrls) {
|
|
85
|
+
this.pages.savePageLinks(pageId, targetUrls);
|
|
86
|
+
}
|
|
87
|
+
getPageLinks(pageId) {
|
|
88
|
+
return this.pages.getPageLinks(pageId);
|
|
89
|
+
}
|
|
90
|
+
searchPagesFts(query, limit = 10) {
|
|
91
|
+
return this.pages.searchPagesFts(query, limit);
|
|
92
|
+
}
|
|
93
|
+
// --- IChunkRepository Delegations ---
|
|
94
|
+
saveChunks(chunks, relationships = [], codeSnippets = [], symbols = []) {
|
|
95
|
+
this.chunks.saveChunks(chunks, relationships, codeSnippets, symbols);
|
|
96
|
+
}
|
|
97
|
+
getChunk(id) {
|
|
98
|
+
return this.chunks.getChunk(id);
|
|
99
|
+
}
|
|
100
|
+
getChunksByPage(pageId) {
|
|
101
|
+
return this.chunks.getChunksByPage(pageId);
|
|
102
|
+
}
|
|
103
|
+
getChunksBySnapshot(snapshotId) {
|
|
104
|
+
return this.chunks.getChunksBySnapshot(snapshotId);
|
|
105
|
+
}
|
|
106
|
+
getChunksByVersion(docVersion) {
|
|
107
|
+
return this.chunks.getChunksByVersion(docVersion);
|
|
108
|
+
}
|
|
109
|
+
getChunkCode(chunkId) {
|
|
110
|
+
return this.chunks.getChunkCode(chunkId);
|
|
111
|
+
}
|
|
112
|
+
getChunkSymbols(chunkId) {
|
|
113
|
+
return this.chunks.getChunkSymbols(chunkId);
|
|
114
|
+
}
|
|
115
|
+
getChunkRelationships(chunkId) {
|
|
116
|
+
return this.chunks.getChunkRelationships(chunkId);
|
|
117
|
+
}
|
|
118
|
+
countChunks(snapshotId) {
|
|
119
|
+
return this.chunks.countChunks(snapshotId);
|
|
120
|
+
}
|
|
121
|
+
searchChunksFts(query, options = {}) {
|
|
122
|
+
return this.chunks.searchChunksFts(query, options);
|
|
123
|
+
}
|
|
124
|
+
// --- IApiRepository Delegations ---
|
|
125
|
+
saveApiEndpoints(endpoints) {
|
|
126
|
+
this.apis.saveApiEndpoints(endpoints);
|
|
127
|
+
}
|
|
128
|
+
getApiEndpoint(id) {
|
|
129
|
+
return this.apis.getApiEndpoint(id);
|
|
130
|
+
}
|
|
131
|
+
getApiEndpointsBySnapshot(snapshotId) {
|
|
132
|
+
return this.apis.getApiEndpointsBySnapshot(snapshotId);
|
|
133
|
+
}
|
|
134
|
+
searchApiEndpoints(query, options = {}) {
|
|
135
|
+
return this.apis.searchApiEndpoints(query, options);
|
|
136
|
+
}
|
|
137
|
+
// --- IExampleRepository Delegations ---
|
|
138
|
+
saveIndexedExamples(examples) {
|
|
139
|
+
this.examples.saveIndexedExamples(examples);
|
|
140
|
+
}
|
|
141
|
+
getIndexedExamplesBySnapshot(snapshotId) {
|
|
142
|
+
return this.examples.getIndexedExamplesBySnapshot(snapshotId);
|
|
143
|
+
}
|
|
144
|
+
searchIndexedExamples(query, options = {}) {
|
|
145
|
+
return this.examples.searchIndexedExamples(query, options);
|
|
146
|
+
}
|
|
147
|
+
// --- IPitfallRepository Delegations ---
|
|
148
|
+
savePitfalls(pitfalls) {
|
|
149
|
+
this.pitfalls.savePitfalls(pitfalls);
|
|
150
|
+
}
|
|
151
|
+
getPitfallsBySnapshot(snapshotId) {
|
|
152
|
+
return this.pitfalls.getPitfallsBySnapshot(snapshotId);
|
|
153
|
+
}
|
|
154
|
+
searchPitfalls(query, options = {}) {
|
|
155
|
+
return this.pitfalls.searchPitfalls(query, options);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS sources (\n id TEXT PRIMARY KEY,\n url TEXT UNIQUE NOT NULL,\n type TEXT NOT NULL,\n discovered_by TEXT NOT NULL,\n status TEXT NOT NULL,\n content_type TEXT,\n confidence REAL NOT NULL,\n authority TEXT NOT NULL,\n machine_readable INTEGER NOT NULL,\n metadata TEXT,\n created_at TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS pages (\n id TEXT PRIMARY KEY,\n source_id TEXT NOT NULL,\n title TEXT NOT NULL,\n url TEXT UNIQUE NOT NULL,\n content TEXT NOT NULL,\n content_hash TEXT NOT NULL,\n fetched_at TEXT NOT NULL,\n raw_bytes INTEGER NOT NULL,\n estimated_tokens INTEGER NOT NULL,\n headings_json TEXT,\n security_annotations_json TEXT,\n provenance_json TEXT,\n FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS links (\n id TEXT PRIMARY KEY,\n page_id TEXT NOT NULL,\n text TEXT NOT NULL,\n url TEXT NOT NULL,\n is_external INTEGER NOT NULL,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS code_examples (\n id TEXT PRIMARY KEY,\n page_id TEXT NOT NULL,\n language TEXT NOT NULL,\n code TEXT NOT NULL,\n caption TEXT,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS snapshots (\n id TEXT PRIMARY KEY,\n source_id TEXT NOT NULL,\n snapshot_hash TEXT NOT NULL,\n page_count INTEGER NOT NULL,\n captured_at TEXT NOT NULL,\n doc_version TEXT,\n metadata TEXT,\n FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS snapshot_pages (\n snapshot_id TEXT NOT NULL,\n page_id TEXT NOT NULL,\n content_hash TEXT NOT NULL,\n PRIMARY KEY (snapshot_id, page_id),\n FOREIGN KEY (snapshot_id) REFERENCES snapshots(id) ON DELETE CASCADE,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS chunks (\n id TEXT PRIMARY KEY,\n page_id TEXT NOT NULL,\n snapshot_id TEXT NOT NULL,\n title TEXT,\n section_path_json TEXT NOT NULL,\n content TEXT NOT NULL,\n chunk_type TEXT NOT NULL,\n language TEXT,\n token_estimate INTEGER NOT NULL,\n ordinal INTEGER NOT NULL,\n content_hash TEXT NOT NULL,\n doc_version TEXT,\n provenance_json TEXT,\n created_at TEXT NOT NULL,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS chunk_code (\n id TEXT PRIMARY KEY,\n chunk_id TEXT NOT NULL,\n language TEXT,\n code TEXT NOT NULL,\n FOREIGN KEY (chunk_id) REFERENCES chunks(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS symbol_references (\n id TEXT PRIMARY KEY,\n chunk_id TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL,\n FOREIGN KEY (chunk_id) REFERENCES chunks(id) ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS chunk_relationships (\n source_chunk_id TEXT NOT NULL,\n target_chunk_id TEXT NOT NULL,\n type TEXT NOT NULL,\n PRIMARY KEY (source_chunk_id, target_chunk_id, type)\n);\n\nCREATE INDEX IF NOT EXISTS idx_pages_source_id ON pages(source_id);\nCREATE INDEX IF NOT EXISTS idx_pages_content_hash ON pages(content_hash);\nCREATE INDEX IF NOT EXISTS idx_links_page_id ON links(page_id);\nCREATE INDEX IF NOT EXISTS idx_code_examples_page_id ON code_examples(page_id);\nCREATE INDEX IF NOT EXISTS idx_snapshots_source_id ON snapshots(source_id);\nCREATE INDEX IF NOT EXISTS idx_snapshots_doc_version ON snapshots(doc_version);\nCREATE INDEX IF NOT EXISTS idx_snapshot_pages_snapshot_id ON snapshot_pages(snapshot_id);\nCREATE INDEX IF NOT EXISTS idx_snapshot_pages_page_id ON snapshot_pages(page_id);\nCREATE INDEX IF NOT EXISTS idx_chunks_page_id ON chunks(page_id);\nCREATE INDEX IF NOT EXISTS idx_chunks_snapshot_id ON chunks(snapshot_id);\nCREATE INDEX IF NOT EXISTS idx_chunks_chunk_type ON chunks(chunk_type);\nCREATE INDEX IF NOT EXISTS idx_chunks_content_hash ON chunks(content_hash);\nCREATE INDEX IF NOT EXISTS idx_chunks_doc_version ON chunks(doc_version);\nCREATE INDEX IF NOT EXISTS idx_chunk_code_chunk_id ON chunk_code(chunk_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_references_chunk_id ON symbol_references(chunk_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_references_name ON symbol_references(name);\nCREATE INDEX IF NOT EXISTS idx_chunk_relationships_source ON chunk_relationships(source_chunk_id);\nCREATE INDEX IF NOT EXISTS idx_chunk_relationships_target ON chunk_relationships(target_chunk_id);\n\nCREATE TABLE IF NOT EXISTS api_endpoints (\n id TEXT PRIMARY KEY,\n page_id TEXT NOT NULL,\n snapshot_id TEXT NOT NULL,\n method TEXT NOT NULL,\n path TEXT NOT NULL,\n summary TEXT,\n description TEXT,\n operation_id TEXT,\n parameters_json TEXT NOT NULL,\n request_schema_json TEXT,\n response_schema_json TEXT,\n auth_json TEXT NOT NULL,\n errors_json TEXT NOT NULL,\n pagination_json TEXT,\n deprecated INTEGER NOT NULL,\n doc_version TEXT,\n provenance_json TEXT,\n created_at TEXT NOT NULL,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE INDEX IF NOT EXISTS idx_api_endpoints_page_id ON api_endpoints(page_id);\nCREATE INDEX IF NOT EXISTS idx_api_endpoints_snapshot_id ON api_endpoints(snapshot_id);\nCREATE INDEX IF NOT EXISTS idx_api_endpoints_method ON api_endpoints(method);\nCREATE INDEX IF NOT EXISTS idx_api_endpoints_path ON api_endpoints(path);\nCREATE INDEX IF NOT EXISTS idx_api_endpoints_doc_version ON api_endpoints(doc_version);\n\nCREATE TABLE IF NOT EXISTS indexed_examples (\n id TEXT PRIMARY KEY,\n chunk_id TEXT,\n page_id TEXT NOT NULL,\n snapshot_id TEXT NOT NULL,\n language TEXT NOT NULL,\n framework TEXT,\n task TEXT NOT NULL,\n code TEXT NOT NULL,\n source_url TEXT NOT NULL,\n source_authority TEXT NOT NULL,\n related_api TEXT,\n related_symbol TEXT,\n doc_version TEXT,\n provenance_json TEXT,\n created_at TEXT NOT NULL,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_page_id ON indexed_examples(page_id);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_snapshot_id ON indexed_examples(snapshot_id);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_chunk_id ON indexed_examples(chunk_id);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_language ON indexed_examples(language);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_framework ON indexed_examples(framework);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_doc_version ON indexed_examples(doc_version);\nCREATE INDEX IF NOT EXISTS idx_indexed_examples_related_api ON indexed_examples(related_api);\n\nCREATE TABLE IF NOT EXISTS pitfalls (\n id TEXT PRIMARY KEY,\n chunk_id TEXT,\n page_id TEXT NOT NULL,\n snapshot_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n title TEXT NOT NULL,\n content TEXT NOT NULL,\n related_api TEXT,\n related_symbol TEXT,\n doc_version TEXT,\n provenance_json TEXT,\n created_at TEXT NOT NULL,\n FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE\n);\n\nCREATE INDEX IF NOT EXISTS idx_pitfalls_page_id ON pitfalls(page_id);\nCREATE INDEX IF NOT EXISTS idx_pitfalls_snapshot_id ON pitfalls(snapshot_id);\nCREATE INDEX IF NOT EXISTS idx_pitfalls_chunk_id ON pitfalls(chunk_id);\nCREATE INDEX IF NOT EXISTS idx_pitfalls_kind ON pitfalls(kind);\nCREATE INDEX IF NOT EXISTS idx_pitfalls_doc_version ON pitfalls(doc_version);\nCREATE INDEX IF NOT EXISTS idx_pitfalls_related_api ON pitfalls(related_api);\n";
|
|
2
|
+
export declare const FTS_SCHEMA_SQL = "\nCREATE VIRTUAL TABLE IF NOT EXISTS pages_fts USING fts5(\n page_id UNINDEXED,\n title,\n content\n);\n\nCREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(\n chunk_id UNINDEXED,\n title,\n section_path,\n content,\n symbols\n);\n\nCREATE TRIGGER IF NOT EXISTS trg_chunks_delete AFTER DELETE ON chunks BEGIN\n DELETE FROM chunks_fts WHERE chunk_id = old.id;\nEND;\n\nCREATE VIRTUAL TABLE IF NOT EXISTS api_endpoints_fts USING fts5(\n endpoint_id UNINDEXED,\n method,\n path,\n summary,\n description,\n parameters\n);\n\nCREATE TRIGGER IF NOT EXISTS trg_api_endpoints_delete AFTER DELETE ON api_endpoints BEGIN\n DELETE FROM api_endpoints_fts WHERE endpoint_id = old.id;\nEND;\n\nCREATE VIRTUAL TABLE IF NOT EXISTS indexed_examples_fts USING fts5(\n example_id UNINDEXED,\n task,\n language,\n framework,\n code,\n related_api,\n related_symbol\n);\n\nCREATE TRIGGER IF NOT EXISTS trg_indexed_examples_delete AFTER DELETE ON indexed_examples BEGIN\n DELETE FROM indexed_examples_fts WHERE example_id = old.id;\nEND;\n\nCREATE VIRTUAL TABLE IF NOT EXISTS pitfalls_fts USING fts5(\n pitfall_id UNINDEXED,\n kind,\n title,\n content,\n related_api,\n related_symbol\n);\n\nCREATE TRIGGER IF NOT EXISTS trg_pitfalls_delete AFTER DELETE ON pitfalls BEGIN\n DELETE FROM pitfalls_fts WHERE pitfall_id = old.id;\nEND;\n";
|
|
@@ -205,7 +205,6 @@ CREATE INDEX IF NOT EXISTS idx_pitfalls_kind ON pitfalls(kind);
|
|
|
205
205
|
CREATE INDEX IF NOT EXISTS idx_pitfalls_doc_version ON pitfalls(doc_version);
|
|
206
206
|
CREATE INDEX IF NOT EXISTS idx_pitfalls_related_api ON pitfalls(related_api);
|
|
207
207
|
`;
|
|
208
|
-
|
|
209
208
|
export const FTS_SCHEMA_SQL = `
|
|
210
209
|
CREATE VIRTUAL TABLE IF NOT EXISTS pages_fts USING fts5(
|
|
211
210
|
page_id UNINDEXED,
|
|
@@ -265,5 +264,3 @@ CREATE TRIGGER IF NOT EXISTS trg_pitfalls_delete AFTER DELETE ON pitfalls BEGIN
|
|
|
265
264
|
DELETE FROM pitfalls_fts WHERE pitfall_id = old.id;
|
|
266
265
|
END;
|
|
267
266
|
`;
|
|
268
|
-
|
|
269
|
-
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SEARCH_STOPWORDS: Set<string>;
|
|
2
|
+
/**
|
|
3
|
+
* Extracts substantive tokens from query text, filtering out common stopwords
|
|
4
|
+
* and short words (< 3 chars), while falling back to short words if query has no substantive words.
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractSearchTokens(text: string): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const SEARCH_STOPWORDS = new Set([
|
|
2
|
+
'a', 'about', 'above', 'after', 'again', 'against', 'all', 'am', 'an', 'and', 'any', 'are',
|
|
3
|
+
'as', 'at', 'be', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'by',
|
|
4
|
+
'can', 'did', 'do', 'does', 'doing', 'down', 'during', 'each', 'few', 'for', 'from',
|
|
5
|
+
'further', 'had', 'has', 'have', 'having', 'he', 'her', 'here', 'hers', 'herself', 'him',
|
|
6
|
+
'himself', 'his', 'how', 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'itself', 'just',
|
|
7
|
+
'me', 'more', 'most', 'my', 'myself', 'no', 'nor', 'not', 'now', 'of', 'off', 'on',
|
|
8
|
+
'once', 'only', 'or', 'other', 'our', 'ours', 'ourselves', 'out', 'over', 'own', 'same',
|
|
9
|
+
'she', 'should', 'so', 'some', 'such', 'than', 'that', 'the', 'their', 'theirs', 'them',
|
|
10
|
+
'themselves', 'then', 'there', 'these', 'they', 'this', 'those', 'through', 'to', 'too',
|
|
11
|
+
'under', 'until', 'up', 'very', 'was', 'we', 'were', 'what', 'when', 'where', 'which',
|
|
12
|
+
'while', 'who', 'whom', 'why', 'with', 'you', 'your', 'yours', 'yourself', 'yourselves'
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Extracts substantive tokens from query text, filtering out common stopwords
|
|
16
|
+
* and short words (< 3 chars), while falling back to short words if query has no substantive words.
|
|
17
|
+
*/
|
|
18
|
+
export function extractSearchTokens(text) {
|
|
19
|
+
const words = text
|
|
20
|
+
.replace(/[^\w\s-]/g, ' ')
|
|
21
|
+
.trim()
|
|
22
|
+
.split(/\s+/)
|
|
23
|
+
.filter(w => w.length > 0);
|
|
24
|
+
const substantive = words.filter(w => w.length >= 3 && !SEARCH_STOPWORDS.has(w.toLowerCase()));
|
|
25
|
+
return substantive.length > 0 ? substantive : words.filter(w => w.length >= 2);
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocDiffResult } from '../../shared/src/index.ts';
|
|
2
|
+
import type { DocOrbitRepository } from '../../storage/src/index.ts';
|
|
3
|
+
export interface DiffOptions {
|
|
4
|
+
fromVersion?: string;
|
|
5
|
+
toVersion?: string;
|
|
6
|
+
fromSnapshotId?: string;
|
|
7
|
+
toSnapshotId?: string;
|
|
8
|
+
sourceId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class DocDiffEngine {
|
|
11
|
+
private repo;
|
|
12
|
+
constructor(repo: DocOrbitRepository);
|
|
13
|
+
diff(options: DiffOptions): DocDiffResult;
|
|
14
|
+
private getEndpoints;
|
|
15
|
+
private getPitfalls;
|
|
16
|
+
private detectEndpointModifications;
|
|
17
|
+
private computeContentDiffs;
|
|
18
|
+
}
|