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":"call-resolver.d.ts","sourceRoot":"","sources":["../../src/knowledge-graph/call-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMtE;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC1C,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC/C,WAAW,EAAE,CAkBf;AAiBD,UAAU,UAAU;IAClB,kEAAkE;IAClE,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,qDAAqD;IACrD,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACxC;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC/C,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAU1B;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC/C,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAe1B;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC/C,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAoCzB;AAED,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAC/C,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAqBvB;AAqJD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAStF"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 决策表(plan §3.2):
|
|
3
|
+
*
|
|
4
|
+
* | Stage | 条件 | confidence |
|
|
5
|
+
* |-------|------|-----------|
|
|
6
|
+
* | 1 free | calleeKind=free 且 callee 在同模块 export | high |
|
|
7
|
+
* | 2 member(双重验证)| className 在 moduleSymbol + callee 在 classMember | high |
|
|
8
|
+
* | 2 member(MRO 父类命中)| 自身 members 不含但 ≤8 层 MRO 父类含 | medium |
|
|
9
|
+
* | 2 member(占位)| 类可定位但 callee 既不在自身也不在 MRO | medium 占位 |
|
|
10
|
+
* | 2 member(类无法定位)| className 缺失或未导出 | medium |
|
|
11
|
+
* | 3 cross-module | import 表命中(非 star) | medium |
|
|
12
|
+
* | 3 cross-module(import \*)| 通配 import | low |
|
|
13
|
+
* | 4 super MRO | super() 且 ≤8 层 MRO 命中 | low |
|
|
14
|
+
* | 4 unresolved | dunder / decorator / 全部 fallthrough | low |
|
|
15
|
+
* | dynamic call | mapper 抽取层 skip,resolver 兜底 null | null(skip)|
|
|
16
|
+
*/
|
|
17
|
+
export function resolveCalls(callSites, codeSkeletons) {
|
|
18
|
+
// 预构建 4 个一次性索引(性能优化 + 算法清晰度)
|
|
19
|
+
const moduleSymbolIndex = buildModuleSymbolIndex(codeSkeletons);
|
|
20
|
+
const classMemberIndex = buildClassMemberIndex(codeSkeletons);
|
|
21
|
+
const importIndex = buildImportIndex(codeSkeletons);
|
|
22
|
+
const classMroIndex = buildClassMroIndex(codeSkeletons);
|
|
23
|
+
const edges = [];
|
|
24
|
+
for (const cs of callSites) {
|
|
25
|
+
const edge = resolveOne(cs, {
|
|
26
|
+
moduleSymbolIndex,
|
|
27
|
+
classMemberIndex,
|
|
28
|
+
importIndex,
|
|
29
|
+
classMroIndex,
|
|
30
|
+
});
|
|
31
|
+
if (edge)
|
|
32
|
+
edges.push(edge);
|
|
33
|
+
}
|
|
34
|
+
return edges;
|
|
35
|
+
}
|
|
36
|
+
export function buildModuleSymbolIndex(codeSkeletons) {
|
|
37
|
+
const idx = new Map();
|
|
38
|
+
for (const [filePath, sk] of codeSkeletons) {
|
|
39
|
+
const names = new Set();
|
|
40
|
+
for (const exp of sk.exports) {
|
|
41
|
+
names.add(exp.name);
|
|
42
|
+
}
|
|
43
|
+
idx.set(filePath, names);
|
|
44
|
+
}
|
|
45
|
+
return idx;
|
|
46
|
+
}
|
|
47
|
+
export function buildClassMemberIndex(codeSkeletons) {
|
|
48
|
+
const idx = new Map();
|
|
49
|
+
for (const [filePath, sk] of codeSkeletons) {
|
|
50
|
+
for (const exp of sk.exports) {
|
|
51
|
+
if (!exp.members || exp.members.length === 0)
|
|
52
|
+
continue;
|
|
53
|
+
// 仅 class / interface / struct / data_class 等"含方法"的类型才有意义
|
|
54
|
+
const classKey = `${filePath}::${exp.name}`;
|
|
55
|
+
const memberNames = new Set();
|
|
56
|
+
for (const m of exp.members) {
|
|
57
|
+
memberNames.add(m.name);
|
|
58
|
+
}
|
|
59
|
+
idx.set(classKey, memberNames);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return idx;
|
|
63
|
+
}
|
|
64
|
+
export function buildImportIndex(codeSkeletons) {
|
|
65
|
+
const idx = new Map();
|
|
66
|
+
for (const [filePath, sk] of codeSkeletons) {
|
|
67
|
+
const aliasToTarget = new Map();
|
|
68
|
+
const starImportTargets = new Set();
|
|
69
|
+
for (const imp of sk.imports) {
|
|
70
|
+
const target = imp.resolvedPath ?? null;
|
|
71
|
+
// namedImports:每个名字单独放索引
|
|
72
|
+
if (imp.namedImports && imp.namedImports.length > 0) {
|
|
73
|
+
for (const name of imp.namedImports) {
|
|
74
|
+
// import * 在 namedImports 中通常表现为 '*' 字符串
|
|
75
|
+
if (name === '*') {
|
|
76
|
+
if (target)
|
|
77
|
+
starImportTargets.add(target);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
aliasToTarget.set(name, target);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// defaultImport:作为别名直接放
|
|
85
|
+
if (imp.defaultImport) {
|
|
86
|
+
aliasToTarget.set(imp.defaultImport, target);
|
|
87
|
+
}
|
|
88
|
+
// 没有 named/default 时(如 Python 的 from X import * 或 import X),
|
|
89
|
+
// 把 moduleSpecifier 的最后一段 + 整个 module 作为 alias
|
|
90
|
+
if ((!imp.namedImports || imp.namedImports.length === 0) &&
|
|
91
|
+
!imp.defaultImport) {
|
|
92
|
+
const lastSeg = imp.moduleSpecifier.split('.').pop() ?? imp.moduleSpecifier;
|
|
93
|
+
aliasToTarget.set(lastSeg, target);
|
|
94
|
+
aliasToTarget.set(imp.moduleSpecifier, target);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
idx.set(filePath, { aliasToTarget, starImportTargets });
|
|
98
|
+
}
|
|
99
|
+
return idx;
|
|
100
|
+
}
|
|
101
|
+
export function buildClassMroIndex(codeSkeletons) {
|
|
102
|
+
const idx = new Map();
|
|
103
|
+
// 简化版:从 ExportSymbol.signature 中尝试解析继承关系(如 "class Foo(Bar, Baz):")。
|
|
104
|
+
// 这里只做 best-effort 提取;更完整的 MRO 解析留给后续 Feature。
|
|
105
|
+
// Codex P1 W-3 修订:用 bracket-aware split 而不是简单 split(','),避免 `Generic[T, U]` 拆坏
|
|
106
|
+
const SUPERCLASS_RE = /class\s+\w+\s*\(\s*([^)]+)\s*\)/;
|
|
107
|
+
for (const [filePath, sk] of codeSkeletons) {
|
|
108
|
+
for (const exp of sk.exports) {
|
|
109
|
+
if (exp.kind !== 'class' && exp.kind !== 'interface')
|
|
110
|
+
continue;
|
|
111
|
+
const match = SUPERCLASS_RE.exec(exp.signature);
|
|
112
|
+
if (!match || !match[1])
|
|
113
|
+
continue;
|
|
114
|
+
const supers = bracketAwareSplit(match[1])
|
|
115
|
+
.map((s) => s.trim())
|
|
116
|
+
.map((s) => stripGenericParams(s)) // `Generic[T]` → `Generic`
|
|
117
|
+
.filter((s) => s.length > 0 && s !== 'object');
|
|
118
|
+
if (supers.length > 0) {
|
|
119
|
+
idx.set(`${filePath}::${exp.name}`, supers);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return idx;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 仅在顶层 `,` 处分割(忽略括号 / 方括号 / 尖括号 / 圆括号内的逗号)。
|
|
127
|
+
* 用于解析类继承列表,避免 `Generic[T, U]` 被误拆。
|
|
128
|
+
*/
|
|
129
|
+
function bracketAwareSplit(input) {
|
|
130
|
+
const out = [];
|
|
131
|
+
let depth = 0;
|
|
132
|
+
let buf = '';
|
|
133
|
+
for (let i = 0; i < input.length; i++) {
|
|
134
|
+
const ch = input[i];
|
|
135
|
+
if (ch === '[' || ch === '(' || ch === '<')
|
|
136
|
+
depth++;
|
|
137
|
+
else if (ch === ']' || ch === ')' || ch === '>')
|
|
138
|
+
depth = Math.max(0, depth - 1);
|
|
139
|
+
if (ch === ',' && depth === 0) {
|
|
140
|
+
if (buf.length > 0)
|
|
141
|
+
out.push(buf);
|
|
142
|
+
buf = '';
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
buf += ch;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (buf.length > 0)
|
|
149
|
+
out.push(buf);
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
/** 剥离 `Generic[T, U]` 末尾的参数化部分,返回 `Generic`。 */
|
|
153
|
+
function stripGenericParams(name) {
|
|
154
|
+
const idx = name.indexOf('[');
|
|
155
|
+
if (idx < 0)
|
|
156
|
+
return name;
|
|
157
|
+
return name.slice(0, idx).trim();
|
|
158
|
+
}
|
|
159
|
+
// ───────────────────────────────────────────────────────────
|
|
160
|
+
// resolveOne — 单个 CallSite 走 4 阶段,返回 UnifiedEdge 或 null(skip)
|
|
161
|
+
// ───────────────────────────────────────────────────────────
|
|
162
|
+
const MAX_MRO_DEPTH = 8; // EC-4:MRO 死循环兜底
|
|
163
|
+
function resolveOne(cs, indices) {
|
|
164
|
+
const { moduleSymbolIndex, classMemberIndex, importIndex, classMroIndex } = indices;
|
|
165
|
+
// ─── Stage 1: free function ───
|
|
166
|
+
if (cs.calleeKind === 'free') {
|
|
167
|
+
const localExports = moduleSymbolIndex.get(cs.callerFile);
|
|
168
|
+
if (localExports?.has(cs.calleeName)) {
|
|
169
|
+
return mkEdge(cs, `${cs.callerFile}::${cs.calleeName}`, 'high');
|
|
170
|
+
}
|
|
171
|
+
// 否则 fallthrough 到 Stage 3(可能是 cross-module 但 calleeKind 标错为 free)
|
|
172
|
+
// 不立即返回,让后续 stage 处理
|
|
173
|
+
}
|
|
174
|
+
// ─── Stage 2: member(self.x / Class.x,Codex C-4 双重验证 + Codex P1 C-2 qualifier)───
|
|
175
|
+
if (cs.calleeKind === 'member') {
|
|
176
|
+
// Codex P1 C-2 修订:优先用 calleeQualifier 定位 className(Class.method 形式),
|
|
177
|
+
// 否则回退 callerContext(self.method / cls.method 形式)
|
|
178
|
+
const className = cs.calleeQualifier ?? extractClassName(cs.callerContext);
|
|
179
|
+
if (className && moduleSymbolIndex.get(cs.callerFile)?.has(className)) {
|
|
180
|
+
const classKey = `${cs.callerFile}::${className}`;
|
|
181
|
+
// 第一重验证:自身 class.members
|
|
182
|
+
if (classMemberIndex.get(classKey)?.has(cs.calleeName)) {
|
|
183
|
+
return mkEdge(cs, `${classKey}.${cs.calleeName}`, 'high');
|
|
184
|
+
}
|
|
185
|
+
// 第二重验证:MRO 父类(≤ MAX_MRO_DEPTH 层)
|
|
186
|
+
const mroEdge = lookupInMro(classKey, cs.calleeName, classMroIndex, classMemberIndex, importIndex.get(cs.callerFile));
|
|
187
|
+
if (mroEdge) {
|
|
188
|
+
return mkEdge(cs, mroEdge, 'medium');
|
|
189
|
+
}
|
|
190
|
+
// 类存在但方法既不在自身也不在 MRO 父类 — medium 占位
|
|
191
|
+
return mkEdge(cs, `${classKey}.${cs.calleeName}`, 'medium');
|
|
192
|
+
}
|
|
193
|
+
// className 不在本模块 export 表 — 尝试 importIndex(Class 来自其他模块)
|
|
194
|
+
if (className) {
|
|
195
|
+
const imports = importIndex.get(cs.callerFile);
|
|
196
|
+
const classFile = imports?.aliasToTarget.get(className);
|
|
197
|
+
if (classFile) {
|
|
198
|
+
const remoteClassKey = `${classFile}::${className}`;
|
|
199
|
+
if (classMemberIndex.get(remoteClassKey)?.has(cs.calleeName)) {
|
|
200
|
+
return mkEdge(cs, `${remoteClassKey}.${cs.calleeName}`, 'medium');
|
|
201
|
+
}
|
|
202
|
+
// 类来自外部但 members 不可见(可能是非项目模块)— medium 占位
|
|
203
|
+
return mkEdge(cs, `${remoteClassKey}.${cs.calleeName}`, 'medium');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// 类无法定位 — medium
|
|
207
|
+
return mkEdge(cs, `?::${cs.calleeName}`, 'medium');
|
|
208
|
+
}
|
|
209
|
+
// ─── Stage 3: cross-module ───
|
|
210
|
+
// calleeKind=cross-module 显式走,或 Stage 1 free 未命中 fallthrough
|
|
211
|
+
// Codex P1 C-2 修订:优先用 calleeQualifier 定位 module,否则回退 calleeName
|
|
212
|
+
if (cs.calleeKind === 'cross-module' || cs.calleeKind === 'free') {
|
|
213
|
+
const imports = importIndex.get(cs.callerFile);
|
|
214
|
+
if (imports) {
|
|
215
|
+
const lookupKey = cs.calleeQualifier ?? cs.calleeName;
|
|
216
|
+
const target = imports.aliasToTarget.get(lookupKey);
|
|
217
|
+
if (target) {
|
|
218
|
+
const isStar = imports.starImportTargets.has(target);
|
|
219
|
+
const tier = isStar ? 'low' : 'medium';
|
|
220
|
+
return mkEdge(cs, `${target}::${cs.calleeName}`, tier);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// ─── Stage 4: super / dunder / decorator / unresolved ───
|
|
225
|
+
if (cs.calleeKind === 'super') {
|
|
226
|
+
const className = extractClassName(cs.callerContext);
|
|
227
|
+
if (className) {
|
|
228
|
+
const classKey = `${cs.callerFile}::${className}`;
|
|
229
|
+
const mroTarget = lookupInMro(classKey, cs.calleeName, classMroIndex, classMemberIndex, importIndex.get(cs.callerFile));
|
|
230
|
+
if (mroTarget) {
|
|
231
|
+
return mkEdge(cs, mroTarget, 'low');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (cs.calleeKind === 'unresolved' ||
|
|
236
|
+
cs.calleeKind === 'dunder' ||
|
|
237
|
+
cs.calleeKind === 'decorator' ||
|
|
238
|
+
cs.calleeKind === 'super' ||
|
|
239
|
+
cs.calleeKind === 'free') {
|
|
240
|
+
// 全部 fallthrough — low confidence 占位
|
|
241
|
+
return mkEdge(cs, `?::${cs.calleeName}`, 'low');
|
|
242
|
+
}
|
|
243
|
+
// dynamic call / 未知 calleeKind — skip(不输出,不污染 precision)
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
// ───────────────────────────────────────────────────────────
|
|
247
|
+
// 辅助函数
|
|
248
|
+
// ───────────────────────────────────────────────────────────
|
|
249
|
+
/**
|
|
250
|
+
* 从 callerContext 字符串提取 className。
|
|
251
|
+
*
|
|
252
|
+
* 约定格式:
|
|
253
|
+
* - "ClassName.method" → "ClassName"
|
|
254
|
+
* - "method" / 无点号 → undefined(顶层函数)
|
|
255
|
+
* - "Outer.Inner.method" → "Inner"(取最后一个点之前的段)
|
|
256
|
+
*/
|
|
257
|
+
export function extractClassName(callerContext) {
|
|
258
|
+
if (!callerContext)
|
|
259
|
+
return undefined;
|
|
260
|
+
const lastDot = callerContext.lastIndexOf('.');
|
|
261
|
+
if (lastDot < 0)
|
|
262
|
+
return undefined;
|
|
263
|
+
// 取最后一个点之前的所有内容;如果还有点(嵌套),取最后一段
|
|
264
|
+
const beforeMethod = callerContext.slice(0, lastDot);
|
|
265
|
+
const lastDotInClass = beforeMethod.lastIndexOf('.');
|
|
266
|
+
if (lastDotInClass < 0)
|
|
267
|
+
return beforeMethod;
|
|
268
|
+
return beforeMethod.slice(lastDotInClass + 1);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* 在 ≤ MAX_MRO_DEPTH 层 MRO 父类中查找方法。
|
|
272
|
+
*
|
|
273
|
+
* 返回命中时的 target ID("file::Class.method" 形式);未命中返回 null。
|
|
274
|
+
* EC-4:硬上限防御类继承环。
|
|
275
|
+
*/
|
|
276
|
+
function lookupInMro(classKey, methodName, classMroIndex, classMemberIndex, callerImports) {
|
|
277
|
+
const visited = new Set();
|
|
278
|
+
const queue = [{ key: classKey, depth: 0 }];
|
|
279
|
+
while (queue.length > 0) {
|
|
280
|
+
const head = queue.shift();
|
|
281
|
+
if (!head)
|
|
282
|
+
break;
|
|
283
|
+
const { key, depth } = head;
|
|
284
|
+
if (visited.has(key) || depth >= MAX_MRO_DEPTH)
|
|
285
|
+
continue;
|
|
286
|
+
visited.add(key);
|
|
287
|
+
const supers = classMroIndex.get(key);
|
|
288
|
+
if (!supers)
|
|
289
|
+
continue;
|
|
290
|
+
for (const superName of supers) {
|
|
291
|
+
// 优先尝试同模块
|
|
292
|
+
const filePart = key.split('::')[0] ?? '';
|
|
293
|
+
const sameFileKey = `${filePart}::${superName}`;
|
|
294
|
+
if (classMemberIndex.get(sameFileKey)?.has(methodName)) {
|
|
295
|
+
return `${sameFileKey}.${methodName}`;
|
|
296
|
+
}
|
|
297
|
+
// 再尝试通过 import 表定位 superclass 所在 file
|
|
298
|
+
if (callerImports) {
|
|
299
|
+
const targetFile = callerImports.aliasToTarget.get(superName);
|
|
300
|
+
if (targetFile) {
|
|
301
|
+
const importedClassKey = `${targetFile}::${superName}`;
|
|
302
|
+
if (classMemberIndex.get(importedClassKey)?.has(methodName)) {
|
|
303
|
+
return `${importedClassKey}.${methodName}`;
|
|
304
|
+
}
|
|
305
|
+
queue.push({ key: importedClassKey, depth: depth + 1 });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// 加入 BFS 队列继续向上
|
|
309
|
+
queue.push({ key: sameFileKey, depth: depth + 1 });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
function mkEdge(cs, targetId, tier) {
|
|
315
|
+
return {
|
|
316
|
+
source: `${cs.callerFile}::${cs.callerContext ?? '<module>'}`,
|
|
317
|
+
target: targetId,
|
|
318
|
+
relation: 'calls',
|
|
319
|
+
confidence: tier,
|
|
320
|
+
directional: true,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=call-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-resolver.js","sourceRoot":"","sources":["../../src/knowledge-graph/call-resolver.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA0C,EAC1C,aAAgD;IAEhD,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAExD,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,EAAE;YAC1B,iBAAiB;YACjB,gBAA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AAU,KAAK,SAAS,EAAE,CAAC;oBACvD,IAAI,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC5D,OAAO,GAAG,gBAAgB,IAAI,UAAU,EAAE,CAAC;oBAC7C,CAAC;oBACD,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC1D,CAAC;YACH,CAAC;YACD,gBAAgB;YAChB,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CACb,EAAoB,EACpB,QAAgB,EAChB,IAAoB;IAEpB,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,KAAK,EAAE,CAAC,aAAa,IAAI,UAAU,EAAE;QAC7D,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature 152 — 通用 Import Path 智能解析模块
|
|
3
|
+
*
|
|
4
|
+
* 提供 Python + TypeScript/JavaScript 的 import 路径解析能力,
|
|
5
|
+
* 供 collectPythonCodeSkeletons(P3)和 collectTsJsCodeSkeletons(P4)调用。
|
|
6
|
+
*
|
|
7
|
+
* 设计原则:
|
|
8
|
+
* - 纯函数(pure function),无状态,零新 npm 依赖(CL-01)
|
|
9
|
+
* - 所有 resolvedPath 输出为相对 projectRoot 的 POSIX 路径(W-5 修复)
|
|
10
|
+
* - 解析失败时返回 { resolvedPath: null, kind: 'unresolved' },不抛异常(FR-2.4)
|
|
11
|
+
*
|
|
12
|
+
* 修复说明(Codex V3 对抗审查通过后的完整修订):
|
|
13
|
+
* - C-1:from . import nn 由 collect 层拆解为 ".nn" 后调用 resolver
|
|
14
|
+
* - C-2:alias-like 前缀(~/、#/、$/、@/)无 paths 命中时返回 unresolved
|
|
15
|
+
* - C-5 + N-2:isInsideProjectRoot 逐 path component 判断,避免字典序误判
|
|
16
|
+
* - W-1:相对路径指向 .json / .d.ts 文件时返回 external
|
|
17
|
+
* - W-5:所有 resolvedPath 输出 POSIX 格式(toPosix 包裹)
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* import 路径解析结果。
|
|
21
|
+
* resolvedPath 为相对 projectRoot 的 POSIX 路径;external/unresolved 时为 null。
|
|
22
|
+
*/
|
|
23
|
+
export interface ResolveResult {
|
|
24
|
+
/**
|
|
25
|
+
* 解析后的目标文件路径,相对于 projectRoot 的 POSIX 相对路径。
|
|
26
|
+
* 未命中(external / unresolved)时为 null。
|
|
27
|
+
*/
|
|
28
|
+
resolvedPath: string | null;
|
|
29
|
+
kind: 'module' | 'package-init' | 'relative-sibling' | 'relative' | 'paths-alias' | 'absolute' | 'external' | 'unresolved';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* TypeScript/JavaScript tsconfig.json 解析上下文。
|
|
33
|
+
* 由 findNearestTsConfig + buildTsConfigContext 协作生成。
|
|
34
|
+
*/
|
|
35
|
+
export interface TsConfigResolutionContext {
|
|
36
|
+
/** tsconfig.json 所在目录的绝对路径 */
|
|
37
|
+
configDir: string;
|
|
38
|
+
/**
|
|
39
|
+
* baseUrl 配置。
|
|
40
|
+
* - 用户未配置 baseUrl → null(跳过 baseUrl 解析)
|
|
41
|
+
* - 用户配置了 baseUrl → 相对 configDir 的字符串(如 "."、"src")
|
|
42
|
+
*/
|
|
43
|
+
baseUrl: string | null;
|
|
44
|
+
/** paths 映射(含 wildcard),key/value 保留原始 tsconfig 字符串 */
|
|
45
|
+
paths: Map<string, string[]>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 解析 Python import 路径。
|
|
49
|
+
*
|
|
50
|
+
* 支持 5 种场景(plan §5.1):
|
|
51
|
+
* 1. 绝对包路径(`pkg.engine` → `pkg/engine.py`)
|
|
52
|
+
* 2. `__init__.py` 兜底(包目录 import)
|
|
53
|
+
* 3. 相对 import(level ≥ 1,PEP 328:上溯 level-1 级目录)
|
|
54
|
+
* 4. 祖先包 import(from .. import X)
|
|
55
|
+
* 5. Python stdlib 内置模块返回 external
|
|
56
|
+
*
|
|
57
|
+
* C-1 修复说明:moduleSpec="." 时 stripped 为空,resolver 仅返回 __init__.py;
|
|
58
|
+
* collect 层须把 "from . import nn" 拆解为 resolvePythonImport(".nn", callerFile, root)。
|
|
59
|
+
*
|
|
60
|
+
* @param moduleSpec - import 说明符(如 "micrograd.engine"、".nn"、"..pkg")
|
|
61
|
+
* @param callerFile - 调用方文件的绝对路径
|
|
62
|
+
* @param projectRoot - 项目根目录绝对路径
|
|
63
|
+
* @returns ResolveResult(resolvedPath 为相对 projectRoot 的 POSIX 路径)
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolvePythonImport(moduleSpec: string, callerFile: string, projectRoot: string): ResolveResult;
|
|
66
|
+
/**
|
|
67
|
+
* 解析 TypeScript/JavaScript import 路径。
|
|
68
|
+
*
|
|
69
|
+
* 支持 4 种场景(plan §5.2):
|
|
70
|
+
* 1. 相对路径(`./engine`、`../utils`)按 .ts → .tsx → .js → .jsx → /index.ts 顺序候补
|
|
71
|
+
* 2. tsconfig paths alias(精确 key + wildcard,多 candidates 按数组顺序)
|
|
72
|
+
* 3. baseUrl 解析(baseUrl != null 时)
|
|
73
|
+
* 4. 外部包(npm bare 包名 / scoped 包)→ external
|
|
74
|
+
*
|
|
75
|
+
* 修复:
|
|
76
|
+
* - W-1:相对路径指向 .json / .d.ts 文件时返回 external(不入 callSites graph)
|
|
77
|
+
* - C-2:alias-like 前缀(~/、#/、$/、@/)无 paths 命中时返回 unresolved
|
|
78
|
+
*
|
|
79
|
+
* @param moduleSpec - import 说明符(如 "./engine"、"~/utils"、"express")
|
|
80
|
+
* @param callerFile - 调用方文件的绝对路径
|
|
81
|
+
* @param projectRoot - 项目根目录绝对路径
|
|
82
|
+
* @param tsConfigContext - tsconfig 解析上下文(null/undefined 时仅走相对路径)
|
|
83
|
+
* @returns ResolveResult
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolveTsJsImport(moduleSpec: string, callerFile: string, projectRoot: string, tsConfigContext?: TsConfigResolutionContext | null): ResolveResult;
|
|
86
|
+
/**
|
|
87
|
+
* 从 filePath 向上查找最近的 tsconfig.json(plan §5.3 + C-5 修复)。
|
|
88
|
+
*
|
|
89
|
+
* 上溯范围:从 path.dirname(filePath) 向上,直到 projectRoot 边界(含 projectRoot 本身)。
|
|
90
|
+
* 越过 projectRoot 则停止,不抛异常。
|
|
91
|
+
*
|
|
92
|
+
* @param filePath - 起始文件的绝对路径
|
|
93
|
+
* @param projectRoot - 不超过此目录,超过则返回 null
|
|
94
|
+
* @returns { configDir: string, rawConfig: Record<string, unknown> } | null
|
|
95
|
+
*/
|
|
96
|
+
export declare function findNearestTsConfig(filePath: string, projectRoot: string): {
|
|
97
|
+
configDir: string;
|
|
98
|
+
rawConfig: Record<string, unknown>;
|
|
99
|
+
} | null;
|
|
100
|
+
/**
|
|
101
|
+
* 将 findNearestTsConfig 返回的 rawConfig 转换为 TsConfigResolutionContext。
|
|
102
|
+
*
|
|
103
|
+
* 处理规则(T-021a):
|
|
104
|
+
* 1. 读取 rawConfig.compilerOptions.baseUrl(缺省时为 null)
|
|
105
|
+
* 2. 读取 rawConfig.compilerOptions.paths → Map<string, string[]>(缺省时为空 Map)
|
|
106
|
+
* 3. 写入 configDir(由调用方传入,findNearestTsConfig 提供)
|
|
107
|
+
* 4. 不处理 extends 链(YAGNI,CL-04)
|
|
108
|
+
*
|
|
109
|
+
* @param rawConfig - tsconfig.json 的原始 JSON 对象
|
|
110
|
+
* @param configDir - tsconfig.json 所在目录的绝对路径
|
|
111
|
+
* @returns TsConfigResolutionContext
|
|
112
|
+
*/
|
|
113
|
+
export declare function buildTsConfigContext(rawConfig: Record<string, unknown>, configDir: string): TsConfigResolutionContext;
|
|
114
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../src/knowledge-graph/import-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EACA,QAAQ,GACR,cAAc,GACd,kBAAkB,GAClB,UAAU,GACV,aAAa,GACb,UAAU,GACV,UAAU,GACV,YAAY,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9B;AAgKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,aAAa,CA0Ef;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,yBAAyB,GAAG,IAAI,GACjD,aAAa,CAkKf;AA+BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB;IAAE,SAAS,EAAE,MAAM,CAAC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