spectra-cli 4.1.1 → 4.2.0
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 +1 -1
- package/dist/adapters/go-adapter.d.ts.map +1 -1
- package/dist/adapters/go-adapter.js +2 -0
- package/dist/adapters/go-adapter.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/java-adapter.d.ts.map +1 -1
- package/dist/adapters/java-adapter.js +2 -0
- package/dist/adapters/java-adapter.js.map +1 -1
- package/dist/adapters/language-adapter.d.ts +47 -9
- package/dist/adapters/language-adapter.d.ts.map +1 -1
- package/dist/adapters/python-adapter.d.ts +34 -6
- package/dist/adapters/python-adapter.d.ts.map +1 -1
- package/dist/adapters/python-adapter.js +157 -59
- package/dist/adapters/python-adapter.js.map +1 -1
- package/dist/adapters/ts-js-adapter.d.ts +13 -5
- package/dist/adapters/ts-js-adapter.d.ts.map +1 -1
- package/dist/adapters/ts-js-adapter.js +55 -14
- package/dist/adapters/ts-js-adapter.js.map +1 -1
- package/dist/batch/batch-orchestrator.d.ts +30 -4
- package/dist/batch/batch-orchestrator.d.ts.map +1 -1
- package/dist/batch/batch-orchestrator.js +284 -7
- package/dist/batch/batch-orchestrator.js.map +1 -1
- package/dist/batch/delta-regenerator.d.ts +2 -2
- package/dist/batch/delta-regenerator.d.ts.map +1 -1
- package/dist/batch/delta-regenerator.js.map +1 -1
- package/dist/batch/module-grouper.d.ts +2 -2
- package/dist/batch/module-grouper.d.ts.map +1 -1
- package/dist/batch/module-grouper.js +1 -1
- package/dist/batch/module-grouper.js.map +1 -1
- package/dist/cli/commands/graph.js +1 -1
- package/dist/cli/commands/graph.js.map +1 -1
- package/dist/cli/commands/index.d.ts +8 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +274 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/query.d.ts.map +1 -1
- package/dist/cli/commands/query.js +3 -1
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/index.js +9 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/parse-args.d.ts +13 -1
- package/dist/cli/utils/parse-args.d.ts.map +1 -1
- package/dist/cli/utils/parse-args.js +79 -2
- package/dist/cli/utils/parse-args.js.map +1 -1
- package/dist/core/ast-analyzer.d.ts.map +1 -1
- package/dist/core/ast-analyzer.js +79 -5
- package/dist/core/ast-analyzer.js.map +1 -1
- package/dist/core/import-resolver.d.ts +90 -0
- package/dist/core/import-resolver.d.ts.map +1 -0
- package/dist/core/import-resolver.js +273 -0
- package/dist/core/import-resolver.js.map +1 -0
- package/dist/core/query-mappers/base-mapper.d.ts +13 -0
- package/dist/core/query-mappers/base-mapper.d.ts.map +1 -1
- package/dist/core/query-mappers/go-mapper.d.ts +68 -0
- package/dist/core/query-mappers/go-mapper.d.ts.map +1 -1
- package/dist/core/query-mappers/go-mapper.js +421 -0
- package/dist/core/query-mappers/go-mapper.js.map +1 -1
- package/dist/core/query-mappers/java-mapper.d.ts +196 -0
- package/dist/core/query-mappers/java-mapper.d.ts.map +1 -1
- package/dist/core/query-mappers/java-mapper.js +600 -0
- package/dist/core/query-mappers/java-mapper.js.map +1 -1
- package/dist/core/query-mappers/python-mapper.d.ts +55 -0
- package/dist/core/query-mappers/python-mapper.d.ts.map +1 -1
- package/dist/core/query-mappers/python-mapper.js +273 -0
- package/dist/core/query-mappers/python-mapper.js.map +1 -1
- package/dist/core/query-mappers/typescript-mapper.d.ts +102 -0
- package/dist/core/query-mappers/typescript-mapper.d.ts.map +1 -1
- package/dist/core/query-mappers/typescript-mapper.js +470 -0
- package/dist/core/query-mappers/typescript-mapper.js.map +1 -1
- package/dist/core/single-spec-orchestrator.d.ts.map +1 -1
- package/dist/core/single-spec-orchestrator.js +146 -9
- package/dist/core/single-spec-orchestrator.js.map +1 -1
- package/dist/core/tree-sitter-analyzer.d.ts +6 -0
- package/dist/core/tree-sitter-analyzer.d.ts.map +1 -1
- package/dist/core/tree-sitter-analyzer.js +33 -1
- package/dist/core/tree-sitter-analyzer.js.map +1 -1
- package/dist/core/tree-sitter-fallback.d.ts +7 -4
- package/dist/core/tree-sitter-fallback.d.ts.map +1 -1
- package/dist/core/tree-sitter-fallback.js +157 -12
- package/dist/core/tree-sitter-fallback.js.map +1 -1
- package/dist/extraction/extraction-types.d.ts +25 -25
- package/dist/generator/index-generator.d.ts +3 -3
- package/dist/generator/index-generator.d.ts.map +1 -1
- package/dist/generator/index-generator.js +1 -1
- package/dist/generator/index-generator.js.map +1 -1
- package/dist/graph/directory-graph.d.ts +14 -4
- package/dist/graph/directory-graph.d.ts.map +1 -1
- package/dist/graph/directory-graph.js +71 -128
- package/dist/graph/directory-graph.js.map +1 -1
- package/dist/graph/mermaid-renderer.d.ts +8 -5
- package/dist/graph/mermaid-renderer.d.ts.map +1 -1
- package/dist/graph/mermaid-renderer.js +3 -3
- package/dist/graph/mermaid-renderer.js.map +1 -1
- package/dist/graph/topological-sort.d.ts +13 -6
- package/dist/graph/topological-sort.d.ts.map +1 -1
- package/dist/graph/topological-sort.js +2 -2
- package/dist/graph/topological-sort.js.map +1 -1
- package/dist/knowledge-graph/call-resolver.d.ts +64 -0
- package/dist/knowledge-graph/call-resolver.d.ts.map +1 -0
- package/dist/knowledge-graph/call-resolver.js +323 -0
- package/dist/knowledge-graph/call-resolver.js.map +1 -0
- package/dist/knowledge-graph/import-resolver.d.ts +114 -0
- package/dist/knowledge-graph/import-resolver.d.ts.map +1 -0
- package/dist/knowledge-graph/import-resolver.js +537 -0
- package/dist/knowledge-graph/import-resolver.js.map +1 -0
- package/dist/knowledge-graph/incremental.d.ts +110 -0
- package/dist/knowledge-graph/incremental.d.ts.map +1 -0
- package/dist/knowledge-graph/incremental.js +410 -0
- package/dist/knowledge-graph/incremental.js.map +1 -0
- package/dist/knowledge-graph/index.d.ts +74 -0
- package/dist/knowledge-graph/index.d.ts.map +1 -0
- package/dist/knowledge-graph/index.js +156 -0
- package/dist/knowledge-graph/index.js.map +1 -0
- package/dist/knowledge-graph/module-derivation.d.ts +238 -0
- package/dist/knowledge-graph/module-derivation.d.ts.map +1 -0
- package/dist/knowledge-graph/module-derivation.js +418 -0
- package/dist/knowledge-graph/module-derivation.js.map +1 -0
- package/dist/knowledge-graph/persistence.d.ts +270 -0
- package/dist/knowledge-graph/persistence.d.ts.map +1 -0
- package/dist/knowledge-graph/persistence.js +226 -0
- package/dist/knowledge-graph/persistence.js.map +1 -0
- package/dist/knowledge-graph/query-helpers.d.ts +164 -0
- package/dist/knowledge-graph/query-helpers.d.ts.map +1 -0
- package/dist/knowledge-graph/query-helpers.js +394 -0
- package/dist/knowledge-graph/query-helpers.js.map +1 -0
- package/dist/knowledge-graph/unified-graph.d.ts +310 -0
- package/dist/knowledge-graph/unified-graph.d.ts.map +1 -0
- package/dist/knowledge-graph/unified-graph.js +182 -0
- package/dist/knowledge-graph/unified-graph.js.map +1 -0
- package/dist/mcp/agent-context-tools.d.ts +104 -0
- package/dist/mcp/agent-context-tools.d.ts.map +1 -0
- package/dist/mcp/agent-context-tools.js +854 -0
- package/dist/mcp/agent-context-tools.js.map +1 -0
- package/dist/mcp/graph-tools.d.ts +20 -0
- package/dist/mcp/graph-tools.d.ts.map +1 -1
- package/dist/mcp/graph-tools.js +71 -11
- package/dist/mcp/graph-tools.js.map +1 -1
- package/dist/mcp/lib/response-helpers.d.ts +67 -0
- package/dist/mcp/lib/response-helpers.d.ts.map +1 -0
- package/dist/mcp/lib/response-helpers.js +103 -0
- package/dist/mcp/lib/response-helpers.js.map +1 -0
- package/dist/mcp/server.d.ts +3 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +9 -10
- package/dist/mcp/server.js.map +1 -1
- package/dist/models/call-site.d.ts +68 -0
- package/dist/models/call-site.d.ts.map +1 -0
- package/dist/models/call-site.js +60 -0
- package/dist/models/call-site.js.map +1 -0
- package/dist/models/code-skeleton.d.ts +78 -6
- package/dist/models/code-skeleton.d.ts.map +1 -1
- package/dist/models/code-skeleton.js +29 -0
- package/dist/models/code-skeleton.js.map +1 -1
- package/dist/models/drift-item.d.ts +4 -4
- package/dist/models/module-spec.d.ts +155 -94
- package/dist/models/module-spec.d.ts.map +1 -1
- package/dist/panoramic/adr-decision-pipeline.d.ts +53 -0
- package/dist/panoramic/adr-decision-pipeline.d.ts.map +1 -0
- package/dist/panoramic/adr-decision-pipeline.js +685 -0
- package/dist/panoramic/adr-decision-pipeline.js.map +1 -0
- package/dist/panoramic/api-surface-generator.d.ts +56 -0
- package/dist/panoramic/api-surface-generator.d.ts.map +1 -0
- package/dist/panoramic/api-surface-generator.js +1671 -0
- package/dist/panoramic/api-surface-generator.js.map +1 -0
- package/dist/panoramic/architecture-ir-builder.d.ts +19 -0
- package/dist/panoramic/architecture-ir-builder.d.ts.map +1 -0
- package/dist/panoramic/architecture-ir-builder.js +561 -0
- package/dist/panoramic/architecture-ir-builder.js.map +1 -0
- package/dist/panoramic/architecture-ir-exporters.d.ts +7 -0
- package/dist/panoramic/architecture-ir-exporters.d.ts.map +1 -0
- package/dist/panoramic/architecture-ir-exporters.js +183 -0
- package/dist/panoramic/architecture-ir-exporters.js.map +1 -0
- package/dist/panoramic/architecture-ir-generator.d.ts +36 -0
- package/dist/panoramic/architecture-ir-generator.d.ts.map +1 -0
- package/dist/panoramic/architecture-ir-generator.js +51 -0
- package/dist/panoramic/architecture-ir-generator.js.map +1 -0
- package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts +6 -0
- package/dist/panoramic/architecture-ir-mermaid-adapter.d.ts.map +1 -0
- package/dist/panoramic/architecture-ir-mermaid-adapter.js +98 -0
- package/dist/panoramic/architecture-ir-mermaid-adapter.js.map +1 -0
- package/dist/panoramic/architecture-ir-model.d.ts +87 -0
- package/dist/panoramic/architecture-ir-model.d.ts.map +1 -0
- package/dist/panoramic/architecture-ir-model.js +20 -0
- package/dist/panoramic/architecture-ir-model.js.map +1 -0
- package/dist/panoramic/architecture-narrative.d.ts +68 -0
- package/dist/panoramic/architecture-narrative.d.ts.map +1 -0
- package/dist/panoramic/architecture-narrative.js +401 -0
- package/dist/panoramic/architecture-narrative.js.map +1 -0
- package/dist/panoramic/architecture-overview-generator.d.ts +31 -0
- package/dist/panoramic/architecture-overview-generator.d.ts.map +1 -0
- package/dist/panoramic/architecture-overview-generator.js +454 -0
- package/dist/panoramic/architecture-overview-generator.js.map +1 -0
- package/dist/panoramic/architecture-overview-model.d.ts +77 -0
- package/dist/panoramic/architecture-overview-model.d.ts.map +1 -0
- package/dist/panoramic/architecture-overview-model.js +31 -0
- package/dist/panoramic/architecture-overview-model.js.map +1 -0
- package/dist/panoramic/batch-project-docs.d.ts.map +1 -1
- package/dist/panoramic/batch-project-docs.js +4 -2
- package/dist/panoramic/batch-project-docs.js.map +1 -1
- package/dist/panoramic/builders/component-view-builder.d.ts +25 -1
- package/dist/panoramic/builders/component-view-builder.d.ts.map +1 -1
- package/dist/panoramic/builders/component-view-builder.js +83 -3
- package/dist/panoramic/builders/component-view-builder.js.map +1 -1
- package/dist/panoramic/builders/doc-graph-builder.d.ts +2 -2
- package/dist/panoramic/builders/doc-graph-builder.d.ts.map +1 -1
- package/dist/panoramic/builders/doc-graph-builder.js.map +1 -1
- package/dist/panoramic/component-view-builder.d.ts +17 -0
- package/dist/panoramic/component-view-builder.d.ts.map +1 -0
- package/dist/panoramic/component-view-builder.js +652 -0
- package/dist/panoramic/component-view-builder.js.map +1 -0
- package/dist/panoramic/component-view-model.d.ts +127 -0
- package/dist/panoramic/component-view-model.d.ts.map +1 -0
- package/dist/panoramic/component-view-model.js +65 -0
- package/dist/panoramic/component-view-model.js.map +1 -0
- package/dist/panoramic/config-reference-generator.d.ts +78 -0
- package/dist/panoramic/config-reference-generator.d.ts.map +1 -0
- package/dist/panoramic/config-reference-generator.js +199 -0
- package/dist/panoramic/config-reference-generator.js.map +1 -0
- package/dist/panoramic/coverage-auditor.d.ts +95 -0
- package/dist/panoramic/coverage-auditor.d.ts.map +1 -0
- package/dist/panoramic/coverage-auditor.js +290 -0
- package/dist/panoramic/coverage-auditor.js.map +1 -0
- package/dist/panoramic/cross-package-analyzer.d.ts +112 -0
- package/dist/panoramic/cross-package-analyzer.d.ts.map +1 -0
- package/dist/panoramic/cross-package-analyzer.js +258 -0
- package/dist/panoramic/cross-package-analyzer.js.map +1 -0
- package/dist/panoramic/data-model-generator.d.ts +528 -0
- package/dist/panoramic/data-model-generator.d.ts.map +1 -0
- package/dist/panoramic/data-model-generator.js +647 -0
- package/dist/panoramic/data-model-generator.js.map +1 -0
- package/dist/panoramic/doc-graph-builder.d.ts +80 -0
- package/dist/panoramic/doc-graph-builder.d.ts.map +1 -0
- package/dist/panoramic/doc-graph-builder.js +352 -0
- package/dist/panoramic/doc-graph-builder.js.map +1 -0
- package/dist/panoramic/docs-bundle-manifest-reader.d.ts +26 -0
- package/dist/panoramic/docs-bundle-manifest-reader.d.ts.map +1 -0
- package/dist/panoramic/docs-bundle-manifest-reader.js +106 -0
- package/dist/panoramic/docs-bundle-manifest-reader.js.map +1 -0
- package/dist/panoramic/docs-bundle-orchestrator.d.ts +14 -0
- package/dist/panoramic/docs-bundle-orchestrator.d.ts.map +1 -0
- package/dist/panoramic/docs-bundle-orchestrator.js +538 -0
- package/dist/panoramic/docs-bundle-orchestrator.js.map +1 -0
- package/dist/panoramic/docs-bundle-profiles.d.ts +4 -0
- package/dist/panoramic/docs-bundle-profiles.d.ts.map +1 -0
- package/dist/panoramic/docs-bundle-profiles.js +82 -0
- package/dist/panoramic/docs-bundle-profiles.js.map +1 -0
- package/dist/panoramic/docs-bundle-types.d.ts +94 -0
- package/dist/panoramic/docs-bundle-types.d.ts.map +1 -0
- package/dist/panoramic/docs-bundle-types.js +10 -0
- package/dist/panoramic/docs-bundle-types.js.map +1 -0
- package/dist/panoramic/docs-quality-evaluator.d.ts +31 -0
- package/dist/panoramic/docs-quality-evaluator.d.ts.map +1 -0
- package/dist/panoramic/docs-quality-evaluator.js +941 -0
- package/dist/panoramic/docs-quality-evaluator.js.map +1 -0
- package/dist/panoramic/docs-quality-model.d.ts +125 -0
- package/dist/panoramic/docs-quality-model.d.ts.map +1 -0
- package/dist/panoramic/docs-quality-model.js +166 -0
- package/dist/panoramic/docs-quality-model.js.map +1 -0
- package/dist/panoramic/dynamic-scenarios-builder.d.ts +18 -0
- package/dist/panoramic/dynamic-scenarios-builder.d.ts.map +1 -0
- package/dist/panoramic/dynamic-scenarios-builder.js +316 -0
- package/dist/panoramic/dynamic-scenarios-builder.js.map +1 -0
- package/dist/panoramic/event-surface-generator.d.ts +52 -0
- package/dist/panoramic/event-surface-generator.d.ts.map +1 -0
- package/dist/panoramic/event-surface-generator.js +507 -0
- package/dist/panoramic/event-surface-generator.js.map +1 -0
- package/dist/panoramic/generator-registry.d.ts +1 -1
- package/dist/panoramic/generator-registry.d.ts.map +1 -1
- package/dist/panoramic/generator-registry.js +5 -2
- package/dist/panoramic/generator-registry.js.map +1 -1
- package/dist/panoramic/generators/cross-package-analyzer.d.ts +5 -5
- package/dist/panoramic/generators/cross-package-analyzer.d.ts.map +1 -1
- package/dist/panoramic/generators/cross-package-analyzer.js +1 -1
- package/dist/panoramic/generators/cross-package-analyzer.js.map +1 -1
- package/dist/panoramic/generators/data-model-generator.d.ts +27 -27
- package/dist/panoramic/graph/confidence-mapper.d.ts +18 -0
- package/dist/panoramic/graph/confidence-mapper.d.ts.map +1 -1
- package/dist/panoramic/graph/confidence-mapper.js +26 -0
- package/dist/panoramic/graph/confidence-mapper.js.map +1 -1
- package/dist/panoramic/graph/graph-builder.d.ts.map +1 -1
- package/dist/panoramic/graph/graph-builder.js +78 -0
- package/dist/panoramic/graph/graph-builder.js.map +1 -1
- package/dist/panoramic/graph/graph-paths.d.ts +8 -0
- package/dist/panoramic/graph/graph-paths.d.ts.map +1 -1
- package/dist/panoramic/graph/graph-paths.js +10 -0
- package/dist/panoramic/graph/graph-paths.js.map +1 -1
- package/dist/panoramic/graph/graph-query.d.ts +33 -2
- package/dist/panoramic/graph/graph-query.d.ts.map +1 -1
- package/dist/panoramic/graph/graph-query.js +69 -19
- package/dist/panoramic/graph/graph-query.js.map +1 -1
- package/dist/panoramic/graph/graph-types.d.ts +32 -3
- package/dist/panoramic/graph/graph-types.d.ts.map +1 -1
- package/dist/panoramic/hyperedges/schema.d.ts +6 -6
- package/dist/panoramic/interface-surface-generator.d.ts +50 -0
- package/dist/panoramic/interface-surface-generator.d.ts.map +1 -0
- package/dist/panoramic/interface-surface-generator.js +388 -0
- package/dist/panoramic/interface-surface-generator.js.map +1 -0
- package/dist/panoramic/interfaces.d.ts +2 -2
- package/dist/panoramic/mock-readme-generator.d.ts +90 -0
- package/dist/panoramic/mock-readme-generator.d.ts.map +1 -0
- package/dist/panoramic/mock-readme-generator.js +111 -0
- package/dist/panoramic/mock-readme-generator.js.map +1 -0
- package/dist/panoramic/models/component-view-model.d.ts +1 -1
- package/dist/panoramic/models/component-view-model.d.ts.map +1 -1
- package/dist/panoramic/models/component-view-model.js.map +1 -1
- package/dist/panoramic/narrative-provenance-adapter.d.ts +8 -0
- package/dist/panoramic/narrative-provenance-adapter.d.ts.map +1 -0
- package/dist/panoramic/narrative-provenance-adapter.js +99 -0
- package/dist/panoramic/narrative-provenance-adapter.js.map +1 -0
- package/dist/panoramic/parser-registry.d.ts +1 -1
- package/dist/panoramic/parser-registry.js +1 -1
- package/dist/panoramic/parsers/types.d.ts +6 -6
- package/dist/panoramic/pattern-hints-generator.d.ts +28 -0
- package/dist/panoramic/pattern-hints-generator.d.ts.map +1 -0
- package/dist/panoramic/pattern-hints-generator.js +218 -0
- package/dist/panoramic/pattern-hints-generator.js.map +1 -0
- package/dist/panoramic/pattern-hints-model.d.ts +89 -0
- package/dist/panoramic/pattern-hints-model.d.ts.map +1 -0
- package/dist/panoramic/pattern-hints-model.js +61 -0
- package/dist/panoramic/pattern-hints-model.js.map +1 -0
- package/dist/panoramic/pattern-knowledge-base.d.ts +31 -0
- package/dist/panoramic/pattern-knowledge-base.d.ts.map +1 -0
- package/dist/panoramic/pattern-knowledge-base.js +407 -0
- package/dist/panoramic/pattern-knowledge-base.js.map +1 -0
- package/dist/panoramic/pipelines/coverage-auditor.d.ts.map +1 -1
- package/dist/panoramic/pipelines/coverage-auditor.js +4 -2
- package/dist/panoramic/pipelines/coverage-auditor.js.map +1 -1
- package/dist/panoramic/pipelines/docs-bundle-orchestrator.js +13 -6
- package/dist/panoramic/pipelines/docs-bundle-orchestrator.js.map +1 -1
- package/dist/panoramic/pipelines/product-ux-docs.d.ts +5 -0
- package/dist/panoramic/pipelines/product-ux-docs.d.ts.map +1 -1
- package/dist/panoramic/pipelines/product-ux-docs.js +34 -6
- package/dist/panoramic/pipelines/product-ux-docs.js.map +1 -1
- package/dist/panoramic/product-ux-docs.d.ts +104 -0
- package/dist/panoramic/product-ux-docs.d.ts.map +1 -0
- package/dist/panoramic/product-ux-docs.js +817 -0
- package/dist/panoramic/product-ux-docs.js.map +1 -0
- package/dist/panoramic/qa/__tests__/citation.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/citation.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/citation.test.js +193 -0
- package/dist/panoramic/qa/__tests__/citation.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/debt-context.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/debt-context.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/debt-context.test.js +154 -0
- package/dist/panoramic/qa/__tests__/debt-context.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/graph-retriever.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/graph-retriever.test.js +148 -0
- package/dist/panoramic/qa/__tests__/graph-retriever.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/index.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/index.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/index.test.js +246 -0
- package/dist/panoramic/qa/__tests__/index.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/llm-caller.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/llm-caller.test.js +168 -0
- package/dist/panoramic/qa/__tests__/llm-caller.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/prompt-builder.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/prompt-builder.test.js +150 -0
- package/dist/panoramic/qa/__tests__/prompt-builder.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/qa-integration.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/qa-integration.test.js +296 -0
- package/dist/panoramic/qa/__tests__/qa-integration.test.js.map +1 -0
- package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts +2 -0
- package/dist/panoramic/qa/__tests__/rag-reranker.test.d.ts.map +1 -0
- package/dist/panoramic/qa/__tests__/rag-reranker.test.js +136 -0
- package/dist/panoramic/qa/__tests__/rag-reranker.test.js.map +1 -0
- package/dist/panoramic/qa/index.d.ts.map +1 -1
- package/dist/panoramic/qa/index.js +10 -3
- package/dist/panoramic/qa/index.js.map +1 -1
- package/dist/panoramic/runtime-topology-generator.d.ts +77 -0
- package/dist/panoramic/runtime-topology-generator.d.ts.map +1 -0
- package/dist/panoramic/runtime-topology-generator.js +676 -0
- package/dist/panoramic/runtime-topology-generator.js.map +1 -0
- package/dist/panoramic/runtime-topology-model.d.ts +145 -0
- package/dist/panoramic/runtime-topology-model.d.ts.map +1 -0
- package/dist/panoramic/runtime-topology-model.js +300 -0
- package/dist/panoramic/runtime-topology-model.js.map +1 -0
- package/dist/panoramic/troubleshooting-generator.d.ts +51 -0
- package/dist/panoramic/troubleshooting-generator.d.ts.map +1 -0
- package/dist/panoramic/troubleshooting-generator.js +451 -0
- package/dist/panoramic/troubleshooting-generator.js.map +1 -0
- package/dist/panoramic/utils/text-segmenter.d.ts +15 -0
- package/dist/panoramic/utils/text-segmenter.d.ts.map +1 -1
- package/dist/panoramic/utils/text-segmenter.js +38 -0
- package/dist/panoramic/utils/text-segmenter.js.map +1 -1
- package/dist/panoramic/workspace-index-generator.d.ts +148 -0
- package/dist/panoramic/workspace-index-generator.d.ts.map +1 -0
- package/dist/panoramic/workspace-index-generator.js +497 -0
- package/dist/panoramic/workspace-index-generator.js.map +1 -0
- package/dist/runtime-bootstrap.d.ts +9 -0
- package/dist/runtime-bootstrap.d.ts.map +1 -0
- package/dist/runtime-bootstrap.js +33 -0
- package/dist/runtime-bootstrap.js.map +1 -0
- package/dist/utils/file-scanner.js +1 -1
- package/dist/utils/file-scanner.js.map +1 -1
- package/package.json +12 -2
- package/plugins/spec-driver/.claude-plugin/plugin.json +1 -1
- package/plugins/spec-driver/README.md +18 -1
- package/plugins/spec-driver/agents/implement.md +20 -1
- package/plugins/spec-driver/agents/plan.md +20 -1
- package/plugins/spec-driver/agents/quality-review.md +20 -1
- package/plugins/spec-driver/agents/spec-review.md +20 -1
- package/plugins/spec-driver/agents/verify.md +20 -1
- package/plugins/spec-driver/docs/customization.md +134 -0
- package/plugins/spec-driver/docs/spectra-mcp-integration.md +165 -0
- package/plugins/spec-driver/lib/preference-rules.mjs +96 -0
- package/plugins/spec-driver/scripts/postinstall.sh +1 -1
- package/plugins/spec-driver/scripts/sync-preference-rules.mjs +148 -0
- package/plugins/spec-driver/skills/spec-driver-feature/SKILL.md +10 -0
- package/plugins/spec-driver/skills/spec-driver-fix/SKILL.md +10 -0
- package/plugins/spec-driver/skills/spec-driver-implement/SKILL.md +10 -0
- package/plugins/spec-driver/skills/spec-driver-refactor/SKILL.md +10 -0
- package/plugins/spec-driver/skills/spec-driver-story/SKILL.md +10 -0
- package/plugins/spec-driver/templates/preference-rules.md +39 -0
- package/plugins/spectra/.claude-plugin/plugin.json +1 -1
- package/plugins/spectra/README.md +48 -1
- package/plugins/spectra/hooks/post-commit.sh +40 -0
- package/templates/product-overview.hbs +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/knowledge-graph/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* module-derivation.ts — UnifiedGraph 派生 ModuleGraph 工具(Feature 156 W1.4 atomic switch)
|
|
3
|
+
*
|
|
4
|
+
* 角色:UnifiedGraph 的合法计算工具,不是过渡 shim。
|
|
5
|
+
* - 输入:UnifiedGraph(唯一 source of truth)
|
|
6
|
+
* - 输出:ModuleGraph 视图(含 inDegree / outDegree / level / SCC / topologicalOrder /
|
|
7
|
+
* mermaidSource,是 panoramic / batch / index-generator 等 17 consumer 的消费形态)
|
|
8
|
+
*
|
|
9
|
+
* 设计原则(FR-22 / AC-5 / NG-7):
|
|
10
|
+
* - ModuleGraph 与 UnifiedGraph 并行存在,是 UnifiedGraph 的派生视图(不是双轨数据源)
|
|
11
|
+
* - 类型名以 "Module" 为前缀,与 UnifiedGraph 的语义边界清晰分离
|
|
12
|
+
*
|
|
13
|
+
* 关键约束(FR-31):
|
|
14
|
+
* - 派生函数必须从**当次输入**(UnifiedGraph 参数)派生
|
|
15
|
+
* - 禁止读取 getCurrentUnifiedGraph() 全局 cache
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import type { UnifiedGraph } from './unified-graph.js';
|
|
19
|
+
import type { CodeSkeleton } from '../models/code-skeleton.js';
|
|
20
|
+
/** import 语义类型(commonjs-require 在 module 视图中归并到 static) */
|
|
21
|
+
export declare const ModuleImportTypeSchema: z.ZodEnum<["static", "dynamic", "type-only"]>;
|
|
22
|
+
export type ModuleImportType = z.infer<typeof ModuleImportTypeSchema>;
|
|
23
|
+
/** 模块图节点(kind === 'module' 的 UnifiedNode 派生) */
|
|
24
|
+
export declare const ModuleNodeSchema: z.ZodObject<{
|
|
25
|
+
source: z.ZodString;
|
|
26
|
+
isOrphan: z.ZodBoolean;
|
|
27
|
+
inDegree: z.ZodNumber;
|
|
28
|
+
outDegree: z.ZodNumber;
|
|
29
|
+
level: z.ZodNumber;
|
|
30
|
+
/** 节点所属的编程语言(多语言图合并时使用) */
|
|
31
|
+
language: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
source: string;
|
|
34
|
+
isOrphan: boolean;
|
|
35
|
+
inDegree: number;
|
|
36
|
+
outDegree: number;
|
|
37
|
+
level: number;
|
|
38
|
+
language?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
source: string;
|
|
41
|
+
isOrphan: boolean;
|
|
42
|
+
inDegree: number;
|
|
43
|
+
outDegree: number;
|
|
44
|
+
level: number;
|
|
45
|
+
language?: string | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
export type ModuleNode = z.infer<typeof ModuleNodeSchema>;
|
|
48
|
+
/** 模块间依赖边(depends-on 关系的 UnifiedEdge 派生) */
|
|
49
|
+
export declare const ModuleEdgeSchema: z.ZodObject<{
|
|
50
|
+
from: z.ZodString;
|
|
51
|
+
to: z.ZodString;
|
|
52
|
+
isCircular: z.ZodBoolean;
|
|
53
|
+
importType: z.ZodEnum<["static", "dynamic", "type-only"]>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
importType: "static" | "dynamic" | "type-only";
|
|
56
|
+
from: string;
|
|
57
|
+
to: string;
|
|
58
|
+
isCircular: boolean;
|
|
59
|
+
}, {
|
|
60
|
+
importType: "static" | "dynamic" | "type-only";
|
|
61
|
+
from: string;
|
|
62
|
+
to: string;
|
|
63
|
+
isCircular: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
export type ModuleEdge = z.infer<typeof ModuleEdgeSchema>;
|
|
66
|
+
/** 模块图强连通分量 */
|
|
67
|
+
export declare const ModuleStronglyConnectedSetSchema: z.ZodObject<{
|
|
68
|
+
id: z.ZodNumber;
|
|
69
|
+
modules: z.ZodArray<z.ZodString, "many">;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
id: number;
|
|
72
|
+
modules: string[];
|
|
73
|
+
}, {
|
|
74
|
+
id: number;
|
|
75
|
+
modules: string[];
|
|
76
|
+
}>;
|
|
77
|
+
export type ModuleStronglyConnectedSet = z.infer<typeof ModuleStronglyConnectedSetSchema>;
|
|
78
|
+
/** 模块依赖图(UnifiedGraph 派生视图) */
|
|
79
|
+
export declare const ModuleGraphSchema: z.ZodObject<{
|
|
80
|
+
projectRoot: z.ZodString;
|
|
81
|
+
modules: z.ZodArray<z.ZodObject<{
|
|
82
|
+
source: z.ZodString;
|
|
83
|
+
isOrphan: z.ZodBoolean;
|
|
84
|
+
inDegree: z.ZodNumber;
|
|
85
|
+
outDegree: z.ZodNumber;
|
|
86
|
+
level: z.ZodNumber;
|
|
87
|
+
/** 节点所属的编程语言(多语言图合并时使用) */
|
|
88
|
+
language: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
source: string;
|
|
91
|
+
isOrphan: boolean;
|
|
92
|
+
inDegree: number;
|
|
93
|
+
outDegree: number;
|
|
94
|
+
level: number;
|
|
95
|
+
language?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
source: string;
|
|
98
|
+
isOrphan: boolean;
|
|
99
|
+
inDegree: number;
|
|
100
|
+
outDegree: number;
|
|
101
|
+
level: number;
|
|
102
|
+
language?: string | undefined;
|
|
103
|
+
}>, "many">;
|
|
104
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
105
|
+
from: z.ZodString;
|
|
106
|
+
to: z.ZodString;
|
|
107
|
+
isCircular: z.ZodBoolean;
|
|
108
|
+
importType: z.ZodEnum<["static", "dynamic", "type-only"]>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
importType: "static" | "dynamic" | "type-only";
|
|
111
|
+
from: string;
|
|
112
|
+
to: string;
|
|
113
|
+
isCircular: boolean;
|
|
114
|
+
}, {
|
|
115
|
+
importType: "static" | "dynamic" | "type-only";
|
|
116
|
+
from: string;
|
|
117
|
+
to: string;
|
|
118
|
+
isCircular: boolean;
|
|
119
|
+
}>, "many">;
|
|
120
|
+
topologicalOrder: z.ZodArray<z.ZodString, "many">;
|
|
121
|
+
sccs: z.ZodArray<z.ZodObject<{
|
|
122
|
+
id: z.ZodNumber;
|
|
123
|
+
modules: z.ZodArray<z.ZodString, "many">;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
id: number;
|
|
126
|
+
modules: string[];
|
|
127
|
+
}, {
|
|
128
|
+
id: number;
|
|
129
|
+
modules: string[];
|
|
130
|
+
}>, "many">;
|
|
131
|
+
totalModules: z.ZodNumber;
|
|
132
|
+
totalEdges: z.ZodNumber;
|
|
133
|
+
analyzedAt: z.ZodString;
|
|
134
|
+
mermaidSource: z.ZodString;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
analyzedAt: string;
|
|
137
|
+
projectRoot: string;
|
|
138
|
+
edges: {
|
|
139
|
+
importType: "static" | "dynamic" | "type-only";
|
|
140
|
+
from: string;
|
|
141
|
+
to: string;
|
|
142
|
+
isCircular: boolean;
|
|
143
|
+
}[];
|
|
144
|
+
modules: {
|
|
145
|
+
source: string;
|
|
146
|
+
isOrphan: boolean;
|
|
147
|
+
inDegree: number;
|
|
148
|
+
outDegree: number;
|
|
149
|
+
level: number;
|
|
150
|
+
language?: string | undefined;
|
|
151
|
+
}[];
|
|
152
|
+
topologicalOrder: string[];
|
|
153
|
+
sccs: {
|
|
154
|
+
id: number;
|
|
155
|
+
modules: string[];
|
|
156
|
+
}[];
|
|
157
|
+
totalModules: number;
|
|
158
|
+
totalEdges: number;
|
|
159
|
+
mermaidSource: string;
|
|
160
|
+
}, {
|
|
161
|
+
analyzedAt: string;
|
|
162
|
+
projectRoot: string;
|
|
163
|
+
edges: {
|
|
164
|
+
importType: "static" | "dynamic" | "type-only";
|
|
165
|
+
from: string;
|
|
166
|
+
to: string;
|
|
167
|
+
isCircular: boolean;
|
|
168
|
+
}[];
|
|
169
|
+
modules: {
|
|
170
|
+
source: string;
|
|
171
|
+
isOrphan: boolean;
|
|
172
|
+
inDegree: number;
|
|
173
|
+
outDegree: number;
|
|
174
|
+
level: number;
|
|
175
|
+
language?: string | undefined;
|
|
176
|
+
}[];
|
|
177
|
+
topologicalOrder: string[];
|
|
178
|
+
sccs: {
|
|
179
|
+
id: number;
|
|
180
|
+
modules: string[];
|
|
181
|
+
}[];
|
|
182
|
+
totalModules: number;
|
|
183
|
+
totalEdges: number;
|
|
184
|
+
mermaidSource: string;
|
|
185
|
+
}>;
|
|
186
|
+
export type ModuleGraph = z.infer<typeof ModuleGraphSchema>;
|
|
187
|
+
/**
|
|
188
|
+
* 把 UnifiedGraph 派生成 ModuleGraph 视图。
|
|
189
|
+
*
|
|
190
|
+
* @param unified - 源 UnifiedGraph(必传,禁止从全局 cache 取)
|
|
191
|
+
* @param projectRoot - 项目根目录
|
|
192
|
+
* @returns ModuleGraph 视图
|
|
193
|
+
*/
|
|
194
|
+
export declare function deriveModuleGraph(unified: UnifiedGraph, projectRoot: string): ModuleGraph;
|
|
195
|
+
/**
|
|
196
|
+
* 从 CodeSkeleton Map 一站式派生 ModuleGraph。
|
|
197
|
+
*
|
|
198
|
+
* 适用场景:调用方已自行解析好 imports[].resolvedPath(如 python-adapter),
|
|
199
|
+
* 直接喂给 buildUnifiedGraph 派生 module 节点 + depends-on 边。
|
|
200
|
+
*
|
|
201
|
+
* @param codeSkeletons - filePath(相对项目根)→ CodeSkeleton(含 resolvedPath)
|
|
202
|
+
* @param projectRoot - 项目根目录(绝对路径)
|
|
203
|
+
* @param language - 可选:给所有 module 节点统一打 language 标签
|
|
204
|
+
*/
|
|
205
|
+
export declare function buildModuleGraphFromCodeSkeletons(codeSkeletons: ReadonlyMap<string, CodeSkeleton>, projectRoot: string, language?: CodeSkeleton['language']): ModuleGraph;
|
|
206
|
+
/**
|
|
207
|
+
* 创建空的 ModuleGraph(用于无文件或解析全失败的兜底场景)
|
|
208
|
+
*/
|
|
209
|
+
export declare function createEmptyModuleGraph(projectRoot: string): ModuleGraph;
|
|
210
|
+
/**
|
|
211
|
+
* TS/JS 项目级 ModuleGraph 构建器(W1.4:取代 legacy src/graph/dependency-graph.ts)。
|
|
212
|
+
*
|
|
213
|
+
* 流程:
|
|
214
|
+
* 1. scanFiles 收集 TS/JS 源文件
|
|
215
|
+
* 2. analyzeFileInternal(ast-analyzer + import-resolver)产出 CodeSkeleton(含 resolvedPath)
|
|
216
|
+
* 3. buildUnifiedGraph 派生 calls + depends-on 边
|
|
217
|
+
* 4. deriveModuleGraph 派生 ModuleGraph 视图
|
|
218
|
+
*/
|
|
219
|
+
export interface BuildModuleGraphOptions {
|
|
220
|
+
/** 用于过滤分析文件的 Glob 模式(默认 '^src/') */
|
|
221
|
+
includeOnly?: string;
|
|
222
|
+
/** 排除模式 */
|
|
223
|
+
excludePatterns?: string[];
|
|
224
|
+
/** tsconfig.json 路径 */
|
|
225
|
+
tsConfigPath?: string;
|
|
226
|
+
}
|
|
227
|
+
export declare class ProjectNotFoundError extends Error {
|
|
228
|
+
constructor(projectRoot: string);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 构建项目级 TS/JS ModuleGraph(取代 legacy buildGraph)。
|
|
232
|
+
*
|
|
233
|
+
* @param projectRoot - 项目根目录
|
|
234
|
+
* @param options - 构建选项
|
|
235
|
+
* @returns ModuleGraph
|
|
236
|
+
*/
|
|
237
|
+
export declare function buildModuleGraphForProject(projectRoot: string, options?: BuildModuleGraphOptions): Promise<ModuleGraph>;
|
|
238
|
+
//# sourceMappingURL=module-derivation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-derivation.d.ts","sourceRoot":"","sources":["../../src/knowledge-graph/module-derivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAe/D,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,+CAA6C,CAAC;AACjF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,gDAAgD;AAChD,eAAO,MAAM,gBAAgB;;;;;;IAM3B,2BAA2B;;;;;;;;;;;;;;;;EAE3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAe;AACf,eAAO,MAAM,gCAAgC;;;;;;;;;EAG3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,+BAA+B;AAC/B,eAAO,MAAM,iBAAiB;;;;;;;;QAtB5B,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC3B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAM5D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,GAClB,WAAW,CAkHb;AAED;;;;;;;;;GASG;AACH,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,EAChD,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,GAClC,WAAW,CAmBb;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAYvE;AAMD;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,uBAAuB;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,WAAW,EAAE,MAAM;CAIhC;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,WAAW,CAAC,CAqGtB"}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* module-derivation.ts — UnifiedGraph 派生 ModuleGraph 工具(Feature 156 W1.4 atomic switch)
|
|
3
|
+
*
|
|
4
|
+
* 角色:UnifiedGraph 的合法计算工具,不是过渡 shim。
|
|
5
|
+
* - 输入:UnifiedGraph(唯一 source of truth)
|
|
6
|
+
* - 输出:ModuleGraph 视图(含 inDegree / outDegree / level / SCC / topologicalOrder /
|
|
7
|
+
* mermaidSource,是 panoramic / batch / index-generator 等 17 consumer 的消费形态)
|
|
8
|
+
*
|
|
9
|
+
* 设计原则(FR-22 / AC-5 / NG-7):
|
|
10
|
+
* - ModuleGraph 与 UnifiedGraph 并行存在,是 UnifiedGraph 的派生视图(不是双轨数据源)
|
|
11
|
+
* - 类型名以 "Module" 为前缀,与 UnifiedGraph 的语义边界清晰分离
|
|
12
|
+
*
|
|
13
|
+
* 关键约束(FR-31):
|
|
14
|
+
* - 派生函数必须从**当次输入**(UnifiedGraph 参数)派生
|
|
15
|
+
* - 禁止读取 getCurrentUnifiedGraph() 全局 cache
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import * as fs from 'node:fs';
|
|
20
|
+
import { ts } from 'ts-morph';
|
|
21
|
+
import { detectSCCs, topologicalSort } from '../graph/topological-sort.js';
|
|
22
|
+
import { renderModuleGraph } from '../graph/mermaid-renderer.js';
|
|
23
|
+
import { buildUnifiedGraph } from './index.js';
|
|
24
|
+
import { analyzeFileInternal } from '../core/ast-analyzer.js';
|
|
25
|
+
import { scanFiles } from '../utils/file-scanner.js';
|
|
26
|
+
import { LanguageAdapterRegistry } from '../adapters/language-adapter-registry.js';
|
|
27
|
+
import { createLogger } from '../panoramic/utils/logger.js';
|
|
28
|
+
const logger = createLogger('module-derivation');
|
|
29
|
+
// ───────────────────────────────────────────────────────────
|
|
30
|
+
// ModuleGraph schema
|
|
31
|
+
// ───────────────────────────────────────────────────────────
|
|
32
|
+
/** import 语义类型(commonjs-require 在 module 视图中归并到 static) */
|
|
33
|
+
export const ModuleImportTypeSchema = z.enum(['static', 'dynamic', 'type-only']);
|
|
34
|
+
/** 模块图节点(kind === 'module' 的 UnifiedNode 派生) */
|
|
35
|
+
export const ModuleNodeSchema = z.object({
|
|
36
|
+
source: z.string().min(1),
|
|
37
|
+
isOrphan: z.boolean(),
|
|
38
|
+
inDegree: z.number().int().nonnegative(),
|
|
39
|
+
outDegree: z.number().int().nonnegative(),
|
|
40
|
+
level: z.number().int().nonnegative(),
|
|
41
|
+
/** 节点所属的编程语言(多语言图合并时使用) */
|
|
42
|
+
language: z.string().optional(),
|
|
43
|
+
});
|
|
44
|
+
/** 模块间依赖边(depends-on 关系的 UnifiedEdge 派生) */
|
|
45
|
+
export const ModuleEdgeSchema = z.object({
|
|
46
|
+
from: z.string().min(1),
|
|
47
|
+
to: z.string().min(1),
|
|
48
|
+
isCircular: z.boolean(),
|
|
49
|
+
importType: ModuleImportTypeSchema,
|
|
50
|
+
});
|
|
51
|
+
/** 模块图强连通分量 */
|
|
52
|
+
export const ModuleStronglyConnectedSetSchema = z.object({
|
|
53
|
+
id: z.number().int().nonnegative(),
|
|
54
|
+
modules: z.array(z.string().min(1)).min(1),
|
|
55
|
+
});
|
|
56
|
+
/** 模块依赖图(UnifiedGraph 派生视图) */
|
|
57
|
+
export const ModuleGraphSchema = z.object({
|
|
58
|
+
projectRoot: z.string().min(1),
|
|
59
|
+
modules: z.array(ModuleNodeSchema),
|
|
60
|
+
edges: z.array(ModuleEdgeSchema),
|
|
61
|
+
topologicalOrder: z.array(z.string()),
|
|
62
|
+
sccs: z.array(ModuleStronglyConnectedSetSchema),
|
|
63
|
+
totalModules: z.number().int().nonnegative(),
|
|
64
|
+
totalEdges: z.number().int().nonnegative(),
|
|
65
|
+
analyzedAt: z.string().datetime(),
|
|
66
|
+
mermaidSource: z.string(),
|
|
67
|
+
});
|
|
68
|
+
// ───────────────────────────────────────────────────────────
|
|
69
|
+
// 派生 API
|
|
70
|
+
// ───────────────────────────────────────────────────────────
|
|
71
|
+
/**
|
|
72
|
+
* 把 UnifiedGraph 派生成 ModuleGraph 视图。
|
|
73
|
+
*
|
|
74
|
+
* @param unified - 源 UnifiedGraph(必传,禁止从全局 cache 取)
|
|
75
|
+
* @param projectRoot - 项目根目录
|
|
76
|
+
* @returns ModuleGraph 视图
|
|
77
|
+
*/
|
|
78
|
+
export function deriveModuleGraph(unified, projectRoot) {
|
|
79
|
+
// ── 1. 过滤 module 节点 + depends-on 边 ──
|
|
80
|
+
const moduleIds = new Set();
|
|
81
|
+
for (const n of unified.nodes) {
|
|
82
|
+
if (n.kind === 'module')
|
|
83
|
+
moduleIds.add(n.id);
|
|
84
|
+
}
|
|
85
|
+
const dependsOnEdges = unified.edges.filter((e) => e.relation === 'depends-on');
|
|
86
|
+
// ── 2. 过滤掉指向非 module 节点的边 + 自引用 ──
|
|
87
|
+
const moduleEdges = dependsOnEdges.filter((e) => moduleIds.has(e.source) && moduleIds.has(e.target) && e.source !== e.target);
|
|
88
|
+
const edgeDrafts = moduleEdges.map((e) => ({
|
|
89
|
+
from: e.source,
|
|
90
|
+
to: e.target,
|
|
91
|
+
importType: parseImportType(e.metadata, e.evidence),
|
|
92
|
+
}));
|
|
93
|
+
// ── 4. 计算 inDegree / outDegree(线性扫描)──
|
|
94
|
+
const inDegrees = new Map();
|
|
95
|
+
const outDegrees = new Map();
|
|
96
|
+
for (const id of moduleIds) {
|
|
97
|
+
inDegrees.set(id, 0);
|
|
98
|
+
outDegrees.set(id, 0);
|
|
99
|
+
}
|
|
100
|
+
for (const e of edgeDrafts) {
|
|
101
|
+
outDegrees.set(e.from, (outDegrees.get(e.from) ?? 0) + 1);
|
|
102
|
+
inDegrees.set(e.to, (inDegrees.get(e.to) ?? 0) + 1);
|
|
103
|
+
}
|
|
104
|
+
// ── 5. 构造初始 ModuleNode 列表(level 暂置 0,topologicalSort 后回填)──
|
|
105
|
+
const nodes = [];
|
|
106
|
+
for (const id of moduleIds) {
|
|
107
|
+
const inDeg = inDegrees.get(id) ?? 0;
|
|
108
|
+
const outDeg = outDegrees.get(id) ?? 0;
|
|
109
|
+
nodes.push({
|
|
110
|
+
source: id,
|
|
111
|
+
isOrphan: inDeg === 0 && outDeg === 0,
|
|
112
|
+
inDegree: inDeg,
|
|
113
|
+
outDegree: outDeg,
|
|
114
|
+
level: 0,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// ── 6. 构造临时 ModuleGraph 供 detectSCCs / topologicalSort 消费 ──
|
|
118
|
+
const tempEdges = edgeDrafts.map((d) => ({
|
|
119
|
+
from: d.from,
|
|
120
|
+
to: d.to,
|
|
121
|
+
isCircular: false,
|
|
122
|
+
importType: d.importType,
|
|
123
|
+
}));
|
|
124
|
+
const tempGraph = {
|
|
125
|
+
projectRoot,
|
|
126
|
+
modules: nodes,
|
|
127
|
+
edges: tempEdges,
|
|
128
|
+
topologicalOrder: [],
|
|
129
|
+
sccs: [],
|
|
130
|
+
totalModules: nodes.length,
|
|
131
|
+
totalEdges: tempEdges.length,
|
|
132
|
+
analyzedAt: new Date().toISOString(),
|
|
133
|
+
mermaidSource: '',
|
|
134
|
+
};
|
|
135
|
+
// ── 7. SCC + topologicalSort(既有 Tarjan + Kahn 算法)──
|
|
136
|
+
const sccs = detectSCCs(tempGraph);
|
|
137
|
+
const sortResult = topologicalSort(tempGraph);
|
|
138
|
+
// ── 8. SCC 反查:构造 nodeId → sccIndex 映射;
|
|
139
|
+
// 仅当 source / target 在**同一** size>1 SCC 才标 isCircular = true。
|
|
140
|
+
const nodeToSccIndex = new Map();
|
|
141
|
+
for (let idx = 0; idx < sccs.length; idx++) {
|
|
142
|
+
const scc = sccs[idx];
|
|
143
|
+
if (scc.modules.length > 1) {
|
|
144
|
+
for (const m of scc.modules)
|
|
145
|
+
nodeToSccIndex.set(m, idx);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// ── 9. 重建最终 edges:填 isCircular(仅同一 SCC 内边标 true) ──
|
|
149
|
+
const finalEdges = edgeDrafts.map((d) => {
|
|
150
|
+
const fromScc = nodeToSccIndex.get(d.from);
|
|
151
|
+
const toScc = nodeToSccIndex.get(d.to);
|
|
152
|
+
const isCircular = fromScc !== undefined && fromScc === toScc;
|
|
153
|
+
return {
|
|
154
|
+
from: d.from,
|
|
155
|
+
to: d.to,
|
|
156
|
+
isCircular,
|
|
157
|
+
importType: d.importType,
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
// ── 10. 回填节点 level ──
|
|
161
|
+
for (const node of nodes) {
|
|
162
|
+
node.level = sortResult.levels.get(node.source) ?? 0;
|
|
163
|
+
}
|
|
164
|
+
// ── 11. 渲染 mermaid 源码 ──
|
|
165
|
+
const finalGraph = {
|
|
166
|
+
projectRoot,
|
|
167
|
+
modules: nodes,
|
|
168
|
+
edges: finalEdges,
|
|
169
|
+
topologicalOrder: sortResult.order,
|
|
170
|
+
sccs,
|
|
171
|
+
totalModules: nodes.length,
|
|
172
|
+
totalEdges: finalEdges.length,
|
|
173
|
+
analyzedAt: new Date().toISOString(),
|
|
174
|
+
mermaidSource: '',
|
|
175
|
+
};
|
|
176
|
+
finalGraph.mermaidSource = renderModuleGraph(finalGraph);
|
|
177
|
+
return finalGraph;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 从 CodeSkeleton Map 一站式派生 ModuleGraph。
|
|
181
|
+
*
|
|
182
|
+
* 适用场景:调用方已自行解析好 imports[].resolvedPath(如 python-adapter),
|
|
183
|
+
* 直接喂给 buildUnifiedGraph 派生 module 节点 + depends-on 边。
|
|
184
|
+
*
|
|
185
|
+
* @param codeSkeletons - filePath(相对项目根)→ CodeSkeleton(含 resolvedPath)
|
|
186
|
+
* @param projectRoot - 项目根目录(绝对路径)
|
|
187
|
+
* @param language - 可选:给所有 module 节点统一打 language 标签
|
|
188
|
+
*/
|
|
189
|
+
export function buildModuleGraphFromCodeSkeletons(codeSkeletons, projectRoot, language) {
|
|
190
|
+
if (codeSkeletons.size === 0) {
|
|
191
|
+
return createEmptyModuleGraph(projectRoot);
|
|
192
|
+
}
|
|
193
|
+
const unified = buildUnifiedGraph({ projectRoot, codeSkeletons });
|
|
194
|
+
const derived = deriveModuleGraph(unified, projectRoot);
|
|
195
|
+
if (language) {
|
|
196
|
+
for (const node of derived.modules) {
|
|
197
|
+
node.language = language;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const registry = LanguageAdapterRegistry.getInstance();
|
|
202
|
+
for (const node of derived.modules) {
|
|
203
|
+
const adapter = registry.getAdapter(node.source);
|
|
204
|
+
if (adapter)
|
|
205
|
+
node.language = adapter.id;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return derived;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* 创建空的 ModuleGraph(用于无文件或解析全失败的兜底场景)
|
|
212
|
+
*/
|
|
213
|
+
export function createEmptyModuleGraph(projectRoot) {
|
|
214
|
+
return {
|
|
215
|
+
projectRoot,
|
|
216
|
+
modules: [],
|
|
217
|
+
edges: [],
|
|
218
|
+
topologicalOrder: [],
|
|
219
|
+
sccs: [],
|
|
220
|
+
totalModules: 0,
|
|
221
|
+
totalEdges: 0,
|
|
222
|
+
analyzedAt: new Date().toISOString(),
|
|
223
|
+
mermaidSource: '',
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export class ProjectNotFoundError extends Error {
|
|
227
|
+
constructor(projectRoot) {
|
|
228
|
+
super(`项目目录不存在: ${projectRoot}`);
|
|
229
|
+
this.name = 'ProjectNotFoundError';
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 构建项目级 TS/JS ModuleGraph(取代 legacy buildGraph)。
|
|
234
|
+
*
|
|
235
|
+
* @param projectRoot - 项目根目录
|
|
236
|
+
* @param options - 构建选项
|
|
237
|
+
* @returns ModuleGraph
|
|
238
|
+
*/
|
|
239
|
+
export async function buildModuleGraphForProject(projectRoot, options = {}) {
|
|
240
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
241
|
+
if (!fs.existsSync(resolvedRoot)) {
|
|
242
|
+
throw new ProjectNotFoundError(projectRoot);
|
|
243
|
+
}
|
|
244
|
+
// ── 1. 扫描 TS/JS 源文件 ──
|
|
245
|
+
const registry = LanguageAdapterRegistry.getInstance();
|
|
246
|
+
const tsJsAdapter = registry.getAllAdapters().find((a) => a.id === 'ts-js');
|
|
247
|
+
const tsJsExts = tsJsAdapter
|
|
248
|
+
? new Set(tsJsAdapter.extensions)
|
|
249
|
+
: new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts']);
|
|
250
|
+
const includeOnlyRe = options.includeOnly ? new RegExp(options.includeOnly) : /^src\//;
|
|
251
|
+
const srcDir = path.join(resolvedRoot, 'src');
|
|
252
|
+
const scanRoot = fs.existsSync(srcDir) ? srcDir : resolvedRoot;
|
|
253
|
+
let scanResult;
|
|
254
|
+
try {
|
|
255
|
+
scanResult = scanFiles(scanRoot, {
|
|
256
|
+
projectRoot: resolvedRoot,
|
|
257
|
+
extensions: tsJsExts,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
logger.warn(`scanFiles 失败,回退到空模块图: ${String(err)}`);
|
|
262
|
+
return createEmptyModuleGraph(resolvedRoot);
|
|
263
|
+
}
|
|
264
|
+
const testPattern = tsJsAdapter?.getTestPatterns().filePattern;
|
|
265
|
+
const tsJsFiles = [];
|
|
266
|
+
for (const relToScan of scanResult.files) {
|
|
267
|
+
const absFile = path.isAbsolute(relToScan) ? relToScan : path.join(scanRoot, relToScan);
|
|
268
|
+
const rel = path.relative(resolvedRoot, absFile).split(path.sep).join('/');
|
|
269
|
+
if (!includeOnlyRe.test(rel))
|
|
270
|
+
continue;
|
|
271
|
+
if (testPattern && testPattern.test(rel))
|
|
272
|
+
continue;
|
|
273
|
+
if (rel.includes('__tests__') || rel.includes('__mocks__'))
|
|
274
|
+
continue;
|
|
275
|
+
tsJsFiles.push(rel);
|
|
276
|
+
}
|
|
277
|
+
if (tsJsFiles.length === 0) {
|
|
278
|
+
return createEmptyModuleGraph(resolvedRoot);
|
|
279
|
+
}
|
|
280
|
+
// ── 2. 解析 tsconfig path alias + baseUrl ──
|
|
281
|
+
const tsConfigPath = options.tsConfigPath
|
|
282
|
+
?? (fs.existsSync(path.join(resolvedRoot, 'tsconfig.json'))
|
|
283
|
+
? path.join(resolvedRoot, 'tsconfig.json')
|
|
284
|
+
: undefined);
|
|
285
|
+
const tsConfigInfo = tsConfigPath ? loadTsconfigAliases(tsConfigPath) : undefined;
|
|
286
|
+
const pathAliases = tsConfigInfo?.paths;
|
|
287
|
+
const baseUrl = tsConfigInfo?.baseUrl;
|
|
288
|
+
// ── 3. 调用 ast-analyzer 提取每个文件的 CodeSkeleton ──
|
|
289
|
+
const codeSkeletons = new Map();
|
|
290
|
+
const ANALYZE_CONCURRENCY = 8;
|
|
291
|
+
const analyzerOpts = {
|
|
292
|
+
projectRoot: resolvedRoot,
|
|
293
|
+
...(pathAliases ? { pathAliases } : {}),
|
|
294
|
+
...(baseUrl ? { baseUrl } : {}),
|
|
295
|
+
};
|
|
296
|
+
for (let i = 0; i < tsJsFiles.length; i += ANALYZE_CONCURRENCY) {
|
|
297
|
+
const batch = tsJsFiles.slice(i, i + ANALYZE_CONCURRENCY);
|
|
298
|
+
const batchResults = await Promise.all(batch.map(async (rel) => {
|
|
299
|
+
const absPath = path.join(resolvedRoot, rel);
|
|
300
|
+
try {
|
|
301
|
+
const sk = await analyzeFileInternal(absPath, analyzerOpts);
|
|
302
|
+
return { rel, sk };
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
logger.warn(`analyzeFile 失败(${rel}): ${String(err)}`);
|
|
306
|
+
return { rel, sk: null };
|
|
307
|
+
}
|
|
308
|
+
}));
|
|
309
|
+
for (const { rel, sk } of batchResults) {
|
|
310
|
+
if (sk) {
|
|
311
|
+
codeSkeletons.set(rel, normalizeSkeletonPaths(sk, resolvedRoot, rel));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (codeSkeletons.size === 0) {
|
|
316
|
+
return createEmptyModuleGraph(resolvedRoot);
|
|
317
|
+
}
|
|
318
|
+
// ── 4. 构建 UnifiedGraph ──
|
|
319
|
+
const unified = buildUnifiedGraph({
|
|
320
|
+
projectRoot: resolvedRoot,
|
|
321
|
+
codeSkeletons,
|
|
322
|
+
});
|
|
323
|
+
// ── 5. 派生 ModuleGraph + 给节点回填 language ──
|
|
324
|
+
const derived = deriveModuleGraph(unified, resolvedRoot);
|
|
325
|
+
for (const node of derived.modules) {
|
|
326
|
+
const adapter = registry.getAdapter(node.source);
|
|
327
|
+
if (adapter) {
|
|
328
|
+
node.language = adapter.id;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return derived;
|
|
332
|
+
}
|
|
333
|
+
// ───────────────────────────────────────────────────────────
|
|
334
|
+
// 内部辅助
|
|
335
|
+
// ───────────────────────────────────────────────────────────
|
|
336
|
+
/**
|
|
337
|
+
* 从 UnifiedEdge 解析 importType。
|
|
338
|
+
*
|
|
339
|
+
* 优先级:
|
|
340
|
+
* 1. edge.metadata.importType(结构化字段)
|
|
341
|
+
* 2. evidence 前缀(旧产物兼容)
|
|
342
|
+
* 3. 默认 'static'
|
|
343
|
+
*/
|
|
344
|
+
function parseImportType(metadata, evidence) {
|
|
345
|
+
const metaType = metadata?.importType;
|
|
346
|
+
if (typeof metaType === 'string') {
|
|
347
|
+
if (metaType === 'type-only')
|
|
348
|
+
return 'type-only';
|
|
349
|
+
if (metaType === 'dynamic')
|
|
350
|
+
return 'dynamic';
|
|
351
|
+
if (metaType === 'commonjs-require')
|
|
352
|
+
return 'static';
|
|
353
|
+
if (metaType === 'static')
|
|
354
|
+
return 'static';
|
|
355
|
+
}
|
|
356
|
+
if (evidence) {
|
|
357
|
+
if (evidence.startsWith('type-only:'))
|
|
358
|
+
return 'type-only';
|
|
359
|
+
if (evidence.startsWith('dynamic:'))
|
|
360
|
+
return 'dynamic';
|
|
361
|
+
if (evidence.startsWith('commonjs-require:'))
|
|
362
|
+
return 'static';
|
|
363
|
+
if (evidence.startsWith('static:'))
|
|
364
|
+
return 'static';
|
|
365
|
+
}
|
|
366
|
+
return 'static';
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* 把 CodeSkeleton 中的 imports[].resolvedPath 从绝对路径归一化为相对路径,
|
|
370
|
+
* 使其与 codeSkeletons Map 的 key(相对路径)对齐。
|
|
371
|
+
*/
|
|
372
|
+
function normalizeSkeletonPaths(sk, projectRoot, callerRel) {
|
|
373
|
+
const newImports = sk.imports.map((imp) => {
|
|
374
|
+
if (!imp.resolvedPath)
|
|
375
|
+
return imp;
|
|
376
|
+
const rel = path.relative(projectRoot, imp.resolvedPath).split(path.sep).join('/');
|
|
377
|
+
return { ...imp, resolvedPath: rel.startsWith('..') ? imp.resolvedPath : rel };
|
|
378
|
+
});
|
|
379
|
+
return { ...sk, filePath: callerRel, imports: newImports };
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* 解析 tsconfig.json(用 ts.parseJsonConfigFileContent,自动处理 extends 链 / baseUrl / paths)。
|
|
383
|
+
*
|
|
384
|
+
* 失败时返回 undefined(不阻断,按未配置 alias 处理)。
|
|
385
|
+
*/
|
|
386
|
+
function loadTsconfigAliases(tsconfigPath) {
|
|
387
|
+
try {
|
|
388
|
+
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
389
|
+
if (configFile.error || !configFile.config) {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(tsconfigPath));
|
|
393
|
+
const compilerOptions = parsedConfig.options;
|
|
394
|
+
const out = {};
|
|
395
|
+
if (compilerOptions.baseUrl) {
|
|
396
|
+
out.baseUrl = compilerOptions.baseUrl;
|
|
397
|
+
}
|
|
398
|
+
if (compilerOptions.paths) {
|
|
399
|
+
const paths = {};
|
|
400
|
+
for (const [k, v] of Object.entries(compilerOptions.paths)) {
|
|
401
|
+
if (Array.isArray(v) && v.length > 0) {
|
|
402
|
+
const baseForPaths = compilerOptions.baseUrl ?? path.dirname(tsconfigPath);
|
|
403
|
+
paths[k] = v
|
|
404
|
+
.filter((s) => typeof s === 'string')
|
|
405
|
+
.map((s) => (path.isAbsolute(s) ? s : path.resolve(baseForPaths, s)));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (Object.keys(paths).length > 0) {
|
|
409
|
+
out.paths = paths;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=module-derivation.js.map
|