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,652 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component view builder
|
|
3
|
+
*
|
|
4
|
+
* 基于 ArchitectureIR + stored module specs 生成关键组件视图。
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { dedupeComponentEvidence, summarizeComponentView, } from './component-view-model.js';
|
|
8
|
+
import { loadTemplate } from './utils/template-loader.js';
|
|
9
|
+
import { sanitizeMermaidId } from './utils/mermaid-helpers.js';
|
|
10
|
+
const CLASSLIKE_KINDS = new Set(['class', 'interface', 'type', 'data_class', 'struct', 'protocol']);
|
|
11
|
+
const CORE_METHOD_RE = /(query|connect|request|stream|send|receive|parse|publish|subscribe|load|save|persist|session|interrupt|control|run|execute|process)/i;
|
|
12
|
+
const HIGH_SIGNAL_NAME_RE = /(query|client|transport|parser|session|store|adapter|service|runtime|protocol|message|gateway|manager)/i;
|
|
13
|
+
export function buildComponentView(options) {
|
|
14
|
+
const maxComponents = options.maxComponents ?? 12;
|
|
15
|
+
const warnings = new Set();
|
|
16
|
+
const narrativeNames = collectNarrativeNames(options.architectureNarrative);
|
|
17
|
+
const packageElements = options.architectureIR.elements.filter((element) => element.id.startsWith('package:'));
|
|
18
|
+
const groupElements = options.architectureIR.elements.filter((element) => element.id.startsWith('group:'));
|
|
19
|
+
if (options.storedModules.length === 0) {
|
|
20
|
+
warnings.add('未找到可用的 stored module specs,无法生成细粒度组件视图。');
|
|
21
|
+
}
|
|
22
|
+
const rankedComponents = options.storedModules
|
|
23
|
+
.flatMap((module) => buildRankedComponents(module, packageElements, groupElements, narrativeNames))
|
|
24
|
+
.filter((component, index, components) => components.findIndex((candidate) => candidate.id === component.id) === index)
|
|
25
|
+
.sort((left, right) => {
|
|
26
|
+
const scoreDiff = right.score - left.score;
|
|
27
|
+
return scoreDiff !== 0 ? scoreDiff : left.id.localeCompare(right.id);
|
|
28
|
+
})
|
|
29
|
+
.slice(0, maxComponents);
|
|
30
|
+
if (rankedComponents.length === 0 && options.storedModules.length > 0) {
|
|
31
|
+
warnings.add('未识别到高信号组件,组件视图将以 warnings 形式降级。');
|
|
32
|
+
}
|
|
33
|
+
const components = rankedComponents.map((component) => finalizeComponent(component));
|
|
34
|
+
const relationships = buildComponentRelationships(rankedComponents, options.storedModules, options.architectureIR, options.eventSurface);
|
|
35
|
+
const groups = buildComponentGroups(rankedComponents);
|
|
36
|
+
const mermaidDiagram = buildComponentMermaid(groups, components, relationships);
|
|
37
|
+
const relevantIrWarnings = options.architectureIR.views
|
|
38
|
+
.filter((view) => view.kind === 'component' || view.kind === 'system-context')
|
|
39
|
+
.flatMap((view) => view.warnings);
|
|
40
|
+
for (const warning of relevantIrWarnings) {
|
|
41
|
+
warnings.add(warning);
|
|
42
|
+
}
|
|
43
|
+
for (const relationship of relationships) {
|
|
44
|
+
if (relationship.confidence === 'low') {
|
|
45
|
+
warnings.add(`低置信组件关系: ${relationship.label}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const summary = buildSummaryLines(components, relationships);
|
|
49
|
+
const model = {
|
|
50
|
+
projectName: options.architectureIR.projectName,
|
|
51
|
+
generatedAt: new Date().toISOString(),
|
|
52
|
+
summary,
|
|
53
|
+
groups,
|
|
54
|
+
components,
|
|
55
|
+
relationships,
|
|
56
|
+
mermaidDiagram,
|
|
57
|
+
warnings: [...warnings].sort((a, b) => a.localeCompare(b)),
|
|
58
|
+
stats: summarizeComponentView({ components, relationships }),
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
title: `组件视图: ${options.architectureIR.projectName}`,
|
|
62
|
+
generatedAt: model.generatedAt,
|
|
63
|
+
model,
|
|
64
|
+
warnings: model.warnings,
|
|
65
|
+
mermaidDiagram,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function renderComponentView(output) {
|
|
69
|
+
const template = loadTemplate('component-view.hbs', import.meta.url);
|
|
70
|
+
return template(output);
|
|
71
|
+
}
|
|
72
|
+
function buildRankedComponents(module, packageElements, groupElements, narrativeNames) {
|
|
73
|
+
const exports = module.baselineSkeleton?.exports ?? [];
|
|
74
|
+
const rankedCandidates = [];
|
|
75
|
+
const moduleRole = classifyModuleRole(module.sourceTarget);
|
|
76
|
+
const packageMatch = findMatchingPackage(module, packageElements);
|
|
77
|
+
const groupMatch = findMatchingGroup(packageMatch, groupElements);
|
|
78
|
+
const subsystem = inferSubsystem(module, packageMatch, groupMatch);
|
|
79
|
+
for (const symbol of exports) {
|
|
80
|
+
const category = classifyComponentCategory(symbol.name, module.sourceTarget);
|
|
81
|
+
const score = scoreExportSymbol(symbol, category, moduleRole, narrativeNames);
|
|
82
|
+
const shouldKeep = CLASSLIKE_KINDS.has(symbol.kind) || score >= 7;
|
|
83
|
+
if (!shouldKeep || isLowSignalSymbol(symbol.name, moduleRole)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
rankedCandidates.push({
|
|
87
|
+
id: sanitizeComponentId(module.sourceTarget, symbol.name),
|
|
88
|
+
name: symbol.name,
|
|
89
|
+
category,
|
|
90
|
+
subsystem,
|
|
91
|
+
summary: summarizeComponentSummary(module, symbol),
|
|
92
|
+
responsibilities: dedupeStrings([
|
|
93
|
+
module.intentSummary,
|
|
94
|
+
module.businessSummary,
|
|
95
|
+
symbol.jsDoc ?? undefined,
|
|
96
|
+
]),
|
|
97
|
+
relatedFiles: module.relatedFiles,
|
|
98
|
+
keyMethods: collectKeyMethods(symbol, module),
|
|
99
|
+
upstreamIds: [],
|
|
100
|
+
downstreamIds: [],
|
|
101
|
+
confidence: deriveConfidence(score, module.confidence),
|
|
102
|
+
inferred: module.confidence === 'low',
|
|
103
|
+
evidence: dedupeComponentEvidence([
|
|
104
|
+
createModuleEvidence(module),
|
|
105
|
+
createSkeletonEvidence(module, symbol.name, symbol.signature, module.confidence === 'low'),
|
|
106
|
+
]),
|
|
107
|
+
score,
|
|
108
|
+
sourceTarget: module.sourceTarget,
|
|
109
|
+
packageId: packageMatch?.id,
|
|
110
|
+
groupId: groupMatch?.id,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (rankedCandidates.length === 0 && moduleRole !== 'validation') {
|
|
114
|
+
rankedCandidates.push(createFallbackModuleComponent(module, subsystem, packageMatch?.id, groupMatch?.id));
|
|
115
|
+
}
|
|
116
|
+
const primaryCandidate = rankedCandidates[0];
|
|
117
|
+
if (primaryCandidate) {
|
|
118
|
+
attachTopLevelFunctionMethods(primaryCandidate, exports, module);
|
|
119
|
+
}
|
|
120
|
+
return rankedCandidates
|
|
121
|
+
.sort((left, right) => {
|
|
122
|
+
const scoreDiff = right.score - left.score;
|
|
123
|
+
return scoreDiff !== 0 ? scoreDiff : left.name.localeCompare(right.name);
|
|
124
|
+
})
|
|
125
|
+
.slice(0, moduleRole === 'core' ? 2 : 1);
|
|
126
|
+
}
|
|
127
|
+
function finalizeComponent(component) {
|
|
128
|
+
return {
|
|
129
|
+
id: component.id,
|
|
130
|
+
name: component.name,
|
|
131
|
+
category: component.category,
|
|
132
|
+
subsystem: component.subsystem,
|
|
133
|
+
summary: component.summary,
|
|
134
|
+
responsibilities: component.responsibilities,
|
|
135
|
+
relatedFiles: component.relatedFiles,
|
|
136
|
+
keyMethods: component.keyMethods,
|
|
137
|
+
upstreamIds: component.upstreamIds,
|
|
138
|
+
downstreamIds: component.downstreamIds,
|
|
139
|
+
confidence: component.confidence,
|
|
140
|
+
inferred: component.inferred,
|
|
141
|
+
evidence: component.evidence,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function buildComponentRelationships(rankedComponents, storedModules, architectureIR, eventSurface) {
|
|
145
|
+
const relationships = new Map();
|
|
146
|
+
const primaryByModule = new Map();
|
|
147
|
+
for (const component of rankedComponents) {
|
|
148
|
+
if (!primaryByModule.has(component.sourceTarget)) {
|
|
149
|
+
primaryByModule.set(component.sourceTarget, component);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const componentById = new Map(rankedComponents.map((component) => [component.id, component]));
|
|
153
|
+
for (const module of storedModules) {
|
|
154
|
+
const sourceComponent = primaryByModule.get(module.sourceTarget);
|
|
155
|
+
if (!sourceComponent) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
for (const targetModule of resolveImportedModules(module, storedModules)) {
|
|
159
|
+
const targetComponent = primaryByModule.get(targetModule.sourceTarget);
|
|
160
|
+
if (!targetComponent || targetComponent.id === sourceComponent.id) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
upsertRelationship(relationships, {
|
|
164
|
+
fromId: sourceComponent.id,
|
|
165
|
+
toId: targetComponent.id,
|
|
166
|
+
kind: 'calls',
|
|
167
|
+
label: `${sourceComponent.name} imports ${targetComponent.name}`,
|
|
168
|
+
confidence: 'medium',
|
|
169
|
+
evidence: [createModuleEvidence(module)],
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const relationship of architectureIR.relationships) {
|
|
174
|
+
if (relationship.kind !== 'depends-on') {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const mapped = mapIrRelationshipToComponents(relationship, rankedComponents);
|
|
178
|
+
if (!mapped) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
upsertRelationship(relationships, mapped);
|
|
182
|
+
}
|
|
183
|
+
const queryComponent = findTopComponent(rankedComponents, ['query', 'client', 'service', 'module']);
|
|
184
|
+
const transportComponent = findTopComponent(rankedComponents, ['transport']);
|
|
185
|
+
const parserComponent = findTopComponent(rankedComponents, ['parser']);
|
|
186
|
+
const sessionComponent = findTopComponent(rankedComponents, ['session', 'store']);
|
|
187
|
+
if (queryComponent && transportComponent && queryComponent.id !== transportComponent.id) {
|
|
188
|
+
upsertRelationship(relationships, {
|
|
189
|
+
fromId: queryComponent.id,
|
|
190
|
+
toId: transportComponent.id,
|
|
191
|
+
kind: 'uses-transport',
|
|
192
|
+
label: `${queryComponent.name} delegates to ${transportComponent.name}`,
|
|
193
|
+
confidence: 'high',
|
|
194
|
+
evidence: mergeEvidence(queryComponent.evidence, transportComponent.evidence),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (transportComponent && parserComponent && transportComponent.id !== parserComponent.id) {
|
|
198
|
+
upsertRelationship(relationships, {
|
|
199
|
+
fromId: transportComponent.id,
|
|
200
|
+
toId: parserComponent.id,
|
|
201
|
+
kind: 'parses',
|
|
202
|
+
label: `${transportComponent.name} hands off to ${parserComponent.name}`,
|
|
203
|
+
confidence: 'high',
|
|
204
|
+
evidence: mergeEvidence(transportComponent.evidence, parserComponent.evidence),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
else if (queryComponent && parserComponent && queryComponent.id !== parserComponent.id) {
|
|
208
|
+
upsertRelationship(relationships, {
|
|
209
|
+
fromId: queryComponent.id,
|
|
210
|
+
toId: parserComponent.id,
|
|
211
|
+
kind: 'parses',
|
|
212
|
+
label: `${queryComponent.name} relies on ${parserComponent.name}`,
|
|
213
|
+
confidence: 'medium',
|
|
214
|
+
evidence: mergeEvidence(queryComponent.evidence, parserComponent.evidence),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (queryComponent && sessionComponent && queryComponent.id !== sessionComponent.id) {
|
|
218
|
+
upsertRelationship(relationships, {
|
|
219
|
+
fromId: queryComponent.id,
|
|
220
|
+
toId: sessionComponent.id,
|
|
221
|
+
kind: 'manages-session',
|
|
222
|
+
label: `${queryComponent.name} updates ${sessionComponent.name}`,
|
|
223
|
+
confidence: 'medium',
|
|
224
|
+
evidence: mergeEvidence(queryComponent.evidence, sessionComponent.evidence),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (eventSurface) {
|
|
228
|
+
for (const channel of eventSurface.channels) {
|
|
229
|
+
const publisher = channel.publishers[0];
|
|
230
|
+
const subscriber = channel.subscribers[0];
|
|
231
|
+
if (!publisher || !subscriber) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const publisherComponent = findComponentByEvidence(rankedComponents, publisher.symbolName, publisher.sourceFile);
|
|
235
|
+
const subscriberComponent = findComponentByEvidence(rankedComponents, subscriber.symbolName, subscriber.sourceFile);
|
|
236
|
+
if (!publisherComponent || !subscriberComponent || publisherComponent.id === subscriberComponent.id) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
upsertRelationship(relationships, {
|
|
240
|
+
fromId: publisherComponent.id,
|
|
241
|
+
toId: subscriberComponent.id,
|
|
242
|
+
kind: 'publishes',
|
|
243
|
+
label: `${publisherComponent.name} emits ${channel.channelName}`,
|
|
244
|
+
confidence: 'medium',
|
|
245
|
+
evidence: [{
|
|
246
|
+
sourceType: 'event-surface',
|
|
247
|
+
ref: channel.channelName,
|
|
248
|
+
note: channel.kind,
|
|
249
|
+
}],
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const finalized = [...relationships.values()]
|
|
254
|
+
.filter((relationship) => relationship.fromId !== relationship.toId)
|
|
255
|
+
.sort((left, right) => `${left.fromId}|${left.kind}|${left.toId}`.localeCompare(`${right.fromId}|${right.kind}|${right.toId}`));
|
|
256
|
+
for (const relationship of finalized) {
|
|
257
|
+
componentById.get(relationship.fromId)?.downstreamIds.push(relationship.toId);
|
|
258
|
+
componentById.get(relationship.toId)?.upstreamIds.push(relationship.fromId);
|
|
259
|
+
}
|
|
260
|
+
for (const component of componentById.values()) {
|
|
261
|
+
component.upstreamIds = dedupeStrings(component.upstreamIds);
|
|
262
|
+
component.downstreamIds = dedupeStrings(component.downstreamIds);
|
|
263
|
+
}
|
|
264
|
+
return finalized;
|
|
265
|
+
}
|
|
266
|
+
function buildComponentGroups(components) {
|
|
267
|
+
const groups = new Map();
|
|
268
|
+
for (const component of components) {
|
|
269
|
+
const id = sanitizeMermaidId(`group_${component.subsystem}`);
|
|
270
|
+
if (!groups.has(id)) {
|
|
271
|
+
groups.set(id, {
|
|
272
|
+
id,
|
|
273
|
+
name: component.subsystem,
|
|
274
|
+
componentIds: [],
|
|
275
|
+
summary: `${component.subsystem} 子系统`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
groups.get(id).componentIds.push(component.id);
|
|
279
|
+
}
|
|
280
|
+
return [...groups.values()]
|
|
281
|
+
.map((group) => ({
|
|
282
|
+
...group,
|
|
283
|
+
componentIds: dedupeStrings(group.componentIds),
|
|
284
|
+
}))
|
|
285
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
286
|
+
}
|
|
287
|
+
function buildComponentMermaid(groups, components, relationships) {
|
|
288
|
+
if (components.length === 0) {
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
const lines = ['flowchart LR'];
|
|
292
|
+
const componentById = new Map(components.map((component) => [component.id, component]));
|
|
293
|
+
for (const group of groups) {
|
|
294
|
+
lines.push(` subgraph ${sanitizeMermaidId(group.id)}["${escapeMermaidLabel(group.name)}"]`);
|
|
295
|
+
for (const componentId of group.componentIds) {
|
|
296
|
+
const component = componentById.get(componentId);
|
|
297
|
+
if (!component) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const nodeId = sanitizeMermaidId(component.id);
|
|
301
|
+
lines.push(` ${nodeId}["${escapeMermaidLabel(`${component.name}\\n${component.category}`)}"]`);
|
|
302
|
+
}
|
|
303
|
+
lines.push(' end');
|
|
304
|
+
}
|
|
305
|
+
for (const relationship of relationships) {
|
|
306
|
+
const fromId = sanitizeMermaidId(relationship.fromId);
|
|
307
|
+
const toId = sanitizeMermaidId(relationship.toId);
|
|
308
|
+
lines.push(` ${fromId} -->|${escapeMermaidLabel(relationship.kind)}| ${toId}`);
|
|
309
|
+
}
|
|
310
|
+
return lines.join('\n');
|
|
311
|
+
}
|
|
312
|
+
function buildSummaryLines(components, relationships) {
|
|
313
|
+
const lines = [];
|
|
314
|
+
if (components.length > 0) {
|
|
315
|
+
lines.push(`识别到 ${components.length} 个关键组件,优先聚焦 ${components.slice(0, 4).map((component) => `\`${component.name}\``).join('、')}。`);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
lines.push('当前批次未识别到可稳定命名的关键组件。');
|
|
319
|
+
}
|
|
320
|
+
const transports = components.filter((component) => component.category === 'transport');
|
|
321
|
+
const parsers = components.filter((component) => component.category === 'parser');
|
|
322
|
+
const sessions = components.filter((component) => component.category === 'session' || component.category === 'store');
|
|
323
|
+
if (transports.length > 0 || parsers.length > 0 || sessions.length > 0) {
|
|
324
|
+
lines.push(`检测到 transport/parser/session 边界:transport=${transports.length},parser=${parsers.length},session/store=${sessions.length}。`);
|
|
325
|
+
}
|
|
326
|
+
if (relationships.length > 0) {
|
|
327
|
+
lines.push(`组件关系共 ${relationships.length} 条,包含 imports、transport hand-off 或 session 管理等关键连接。`);
|
|
328
|
+
}
|
|
329
|
+
return lines;
|
|
330
|
+
}
|
|
331
|
+
function collectNarrativeNames(narrative) {
|
|
332
|
+
const names = new Set();
|
|
333
|
+
if (!narrative) {
|
|
334
|
+
return names;
|
|
335
|
+
}
|
|
336
|
+
for (const symbol of narrative.keySymbols) {
|
|
337
|
+
names.add(symbol.name);
|
|
338
|
+
}
|
|
339
|
+
for (const method of narrative.keyMethods) {
|
|
340
|
+
names.add(method.name);
|
|
341
|
+
}
|
|
342
|
+
for (const module of narrative.keyModules) {
|
|
343
|
+
names.add(module.displayName);
|
|
344
|
+
}
|
|
345
|
+
return names;
|
|
346
|
+
}
|
|
347
|
+
function scoreExportSymbol(symbol, category, moduleRole, narrativeNames) {
|
|
348
|
+
let score = 0;
|
|
349
|
+
if (CLASSLIKE_KINDS.has(symbol.kind))
|
|
350
|
+
score += 6;
|
|
351
|
+
if (HIGH_SIGNAL_NAME_RE.test(symbol.name))
|
|
352
|
+
score += 6;
|
|
353
|
+
if (category !== 'module')
|
|
354
|
+
score += 4;
|
|
355
|
+
if ((symbol.members ?? []).some((member) => CORE_METHOD_RE.test(member.name)))
|
|
356
|
+
score += 3;
|
|
357
|
+
if (CORE_METHOD_RE.test(symbol.name))
|
|
358
|
+
score += 3;
|
|
359
|
+
if (narrativeNames.has(symbol.name))
|
|
360
|
+
score += 3;
|
|
361
|
+
if (moduleRole === 'core')
|
|
362
|
+
score += 3;
|
|
363
|
+
if (moduleRole === 'support')
|
|
364
|
+
score -= 1;
|
|
365
|
+
if (moduleRole === 'validation')
|
|
366
|
+
score -= 6;
|
|
367
|
+
return score;
|
|
368
|
+
}
|
|
369
|
+
function deriveConfidence(score, moduleConfidence) {
|
|
370
|
+
if (moduleConfidence === 'low') {
|
|
371
|
+
return score >= 12 ? 'medium' : 'low';
|
|
372
|
+
}
|
|
373
|
+
if (score >= 14) {
|
|
374
|
+
return 'high';
|
|
375
|
+
}
|
|
376
|
+
if (score >= 8) {
|
|
377
|
+
return 'medium';
|
|
378
|
+
}
|
|
379
|
+
return 'low';
|
|
380
|
+
}
|
|
381
|
+
function collectKeyMethods(symbol, module) {
|
|
382
|
+
const methods = [];
|
|
383
|
+
for (const member of symbol.members ?? []) {
|
|
384
|
+
if (isLowSignalMethod(member.name, module.sourceTarget)) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
methods.push({
|
|
388
|
+
ownerName: symbol.name,
|
|
389
|
+
name: member.name,
|
|
390
|
+
kind: classifyMethodKind(member.name),
|
|
391
|
+
signature: member.signature,
|
|
392
|
+
evidence: [createSkeletonEvidence(module, `${symbol.name}.${member.name}`, member.signature, module.confidence === 'low')],
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
return methods
|
|
396
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
397
|
+
.slice(0, 6);
|
|
398
|
+
}
|
|
399
|
+
function attachTopLevelFunctionMethods(component, exports, module) {
|
|
400
|
+
const methods = exports
|
|
401
|
+
.filter((symbol) => symbol.kind === 'function' && CORE_METHOD_RE.test(symbol.name))
|
|
402
|
+
.map((symbol) => ({
|
|
403
|
+
ownerName: undefined,
|
|
404
|
+
name: symbol.name,
|
|
405
|
+
kind: classifyMethodKind(symbol.name),
|
|
406
|
+
signature: symbol.signature,
|
|
407
|
+
evidence: [createSkeletonEvidence(module, symbol.name, symbol.signature, module.confidence === 'low')],
|
|
408
|
+
}));
|
|
409
|
+
component.keyMethods = dedupeMethods([...component.keyMethods, ...methods]);
|
|
410
|
+
}
|
|
411
|
+
function createFallbackModuleComponent(module, subsystem, packageId, groupId) {
|
|
412
|
+
const fallbackName = path.posix.basename(module.sourceTarget).replace(/\.[^/.]+$/, '');
|
|
413
|
+
return {
|
|
414
|
+
id: sanitizeComponentId(module.sourceTarget, fallbackName),
|
|
415
|
+
name: fallbackName,
|
|
416
|
+
category: classifyComponentCategory(fallbackName, module.sourceTarget),
|
|
417
|
+
subsystem,
|
|
418
|
+
summary: module.intentSummary,
|
|
419
|
+
responsibilities: dedupeStrings([module.intentSummary, module.businessSummary]),
|
|
420
|
+
relatedFiles: module.relatedFiles,
|
|
421
|
+
keyMethods: [],
|
|
422
|
+
upstreamIds: [],
|
|
423
|
+
downstreamIds: [],
|
|
424
|
+
confidence: module.confidence === 'low' ? 'low' : 'medium',
|
|
425
|
+
inferred: module.confidence === 'low',
|
|
426
|
+
evidence: [createModuleEvidence(module)],
|
|
427
|
+
score: module.confidence === 'low' ? 2 : 6,
|
|
428
|
+
sourceTarget: module.sourceTarget,
|
|
429
|
+
packageId,
|
|
430
|
+
groupId,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function createModuleEvidence(module) {
|
|
434
|
+
return {
|
|
435
|
+
sourceType: 'module-spec',
|
|
436
|
+
ref: module.sourceTarget,
|
|
437
|
+
note: module.intentSummary,
|
|
438
|
+
inferred: module.confidence === 'low',
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function createSkeletonEvidence(module, refName, signature, inferred) {
|
|
442
|
+
return {
|
|
443
|
+
sourceType: 'baseline-skeleton',
|
|
444
|
+
ref: `${module.sourceTarget}:${refName}`,
|
|
445
|
+
note: signature,
|
|
446
|
+
inferred,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function classifyComponentCategory(name, sourceTarget) {
|
|
450
|
+
const lower = `${name} ${sourceTarget}`.toLowerCase();
|
|
451
|
+
if (/(transport|stdin|stdout)/.test(lower))
|
|
452
|
+
return 'transport';
|
|
453
|
+
if (/(parser|parse|codec|serializer|message)/.test(lower))
|
|
454
|
+
return 'parser';
|
|
455
|
+
if (/(session|conversation|transcript)/.test(lower))
|
|
456
|
+
return 'session';
|
|
457
|
+
if (/(store|cache|repository)/.test(lower))
|
|
458
|
+
return 'store';
|
|
459
|
+
if (/(adapter)/.test(lower))
|
|
460
|
+
return 'adapter';
|
|
461
|
+
if (/(client|sdk)/.test(lower))
|
|
462
|
+
return 'client';
|
|
463
|
+
if (/(query|request)/.test(lower))
|
|
464
|
+
return 'query';
|
|
465
|
+
if (/(service|runtime|manager|controller|gateway)/.test(lower))
|
|
466
|
+
return 'service';
|
|
467
|
+
return 'module';
|
|
468
|
+
}
|
|
469
|
+
function classifyMethodKind(name) {
|
|
470
|
+
const lower = name.toLowerCase();
|
|
471
|
+
if (/(query|request|connect|send|stream|run|execute|process|interrupt|control)/.test(lower))
|
|
472
|
+
return 'entrypoint';
|
|
473
|
+
if (/(transport|dispatch|emit|publish|subscribe|listen)/.test(lower))
|
|
474
|
+
return 'transport';
|
|
475
|
+
if (/(parse|decode|encode|serialize)/.test(lower))
|
|
476
|
+
return 'parser';
|
|
477
|
+
if (/(session|persist|store|load|save|resume)/.test(lower))
|
|
478
|
+
return 'session';
|
|
479
|
+
if (/(event|handle|on[A-Z_])/.test(name) || /(event|handle)/.test(lower))
|
|
480
|
+
return 'event-handler';
|
|
481
|
+
return 'supporting';
|
|
482
|
+
}
|
|
483
|
+
function summarizeComponentSummary(module, symbol) {
|
|
484
|
+
const doc = symbol.jsDoc?.trim();
|
|
485
|
+
if (doc) {
|
|
486
|
+
return summarizeLine(doc, module.intentSummary);
|
|
487
|
+
}
|
|
488
|
+
return summarizeLine(module.intentSummary, symbol.signature);
|
|
489
|
+
}
|
|
490
|
+
function summarizeLine(content, fallback) {
|
|
491
|
+
const value = content
|
|
492
|
+
.split(/\r?\n/)
|
|
493
|
+
.map((line) => line.replace(/^[-*]\s+/, '').trim())
|
|
494
|
+
.find((line) => line.length > 0);
|
|
495
|
+
return value ?? fallback;
|
|
496
|
+
}
|
|
497
|
+
function classifyModuleRole(sourceTarget) {
|
|
498
|
+
if (sourceTarget === 'tests' || sourceTarget.startsWith('tests/') || sourceTarget.includes('/tests/')) {
|
|
499
|
+
return 'validation';
|
|
500
|
+
}
|
|
501
|
+
if (sourceTarget.startsWith('examples/') || sourceTarget.startsWith('scripts/')) {
|
|
502
|
+
return 'support';
|
|
503
|
+
}
|
|
504
|
+
return 'core';
|
|
505
|
+
}
|
|
506
|
+
function isLowSignalSymbol(name, moduleRole) {
|
|
507
|
+
return moduleRole === 'validation' && /^test/i.test(name);
|
|
508
|
+
}
|
|
509
|
+
function isLowSignalMethod(name, sourceTarget) {
|
|
510
|
+
return classifyModuleRole(sourceTarget) === 'validation' && /^test/i.test(name);
|
|
511
|
+
}
|
|
512
|
+
function sanitizeComponentId(sourceTarget, name) {
|
|
513
|
+
return sanitizeMermaidId(`component_${sourceTarget}_${name}`);
|
|
514
|
+
}
|
|
515
|
+
function findMatchingPackage(module, packageElements) {
|
|
516
|
+
return packageElements.find((element) => {
|
|
517
|
+
const elementPath = getMetadataString(element, 'path');
|
|
518
|
+
return typeof elementPath === 'string' && module.relatedFiles.some((filePath) => filePath.startsWith(`${elementPath}/`) || filePath === elementPath);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function findMatchingGroup(packageElement, groupElements) {
|
|
522
|
+
if (!packageElement) {
|
|
523
|
+
return undefined;
|
|
524
|
+
}
|
|
525
|
+
const groupName = getMetadataString(packageElement, 'group');
|
|
526
|
+
if (!groupName) {
|
|
527
|
+
return undefined;
|
|
528
|
+
}
|
|
529
|
+
return groupElements.find((element) => element.id === `group:${groupName}`);
|
|
530
|
+
}
|
|
531
|
+
function inferSubsystem(module, packageElement, groupElement) {
|
|
532
|
+
const packagePath = getMetadataString(packageElement, 'path');
|
|
533
|
+
if (packagePath) {
|
|
534
|
+
return packagePath;
|
|
535
|
+
}
|
|
536
|
+
if (groupElement?.name) {
|
|
537
|
+
return groupElement.name;
|
|
538
|
+
}
|
|
539
|
+
const parts = module.sourceTarget.split('/').filter(Boolean);
|
|
540
|
+
if (parts.length >= 3 && (parts[0] === 'src' || parts[0] === 'tests')) {
|
|
541
|
+
return parts.slice(1, parts.length - 1).join('/') || parts[1];
|
|
542
|
+
}
|
|
543
|
+
if (parts.length >= 2) {
|
|
544
|
+
return parts.slice(0, parts.length - 1).join('/');
|
|
545
|
+
}
|
|
546
|
+
return module.sourceTarget;
|
|
547
|
+
}
|
|
548
|
+
function resolveImportedModules(module, storedModules) {
|
|
549
|
+
const imports = module.baselineSkeleton?.imports ?? [];
|
|
550
|
+
const matches = new Set();
|
|
551
|
+
for (const item of imports) {
|
|
552
|
+
const resolved = item.resolvedPath?.split(path.sep).join('/');
|
|
553
|
+
for (const candidate of storedModules) {
|
|
554
|
+
if (candidate.sourceTarget === module.sourceTarget) {
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
if (resolved && candidate.relatedFiles.some((filePath) => resolved.endsWith(filePath) || filePath.endsWith(resolved))) {
|
|
558
|
+
matches.add(candidate);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
const specifier = item.moduleSpecifier.replace(/^\.\//, '');
|
|
562
|
+
if (specifier.length > 0 && candidate.sourceTarget.endsWith(specifier)) {
|
|
563
|
+
matches.add(candidate);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return [...matches];
|
|
568
|
+
}
|
|
569
|
+
function mapIrRelationshipToComponents(relationship, rankedComponents) {
|
|
570
|
+
const fromCandidates = rankedComponents.filter((component) => component.packageId === relationship.sourceId || component.groupId === relationship.sourceId);
|
|
571
|
+
const toCandidates = rankedComponents.filter((component) => component.packageId === relationship.destinationId || component.groupId === relationship.destinationId);
|
|
572
|
+
const fromComponent = fromCandidates[0];
|
|
573
|
+
const toComponent = toCandidates[0];
|
|
574
|
+
if (!fromComponent || !toComponent || fromComponent.id === toComponent.id) {
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
fromId: fromComponent.id,
|
|
579
|
+
toId: toComponent.id,
|
|
580
|
+
kind: relationship.kind === 'depends-on' ? 'depends-on' : 'calls',
|
|
581
|
+
label: `${fromComponent.name} ${relationship.kind} ${toComponent.name}`,
|
|
582
|
+
confidence: 'medium',
|
|
583
|
+
evidence: relationship.evidence.map(mapIrEvidence),
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function mapIrEvidence(evidence) {
|
|
587
|
+
return {
|
|
588
|
+
sourceType: 'architecture-ir',
|
|
589
|
+
ref: evidence.ref,
|
|
590
|
+
note: evidence.note,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function findTopComponent(components, categories) {
|
|
594
|
+
return components.find((component) => categories.includes(component.category));
|
|
595
|
+
}
|
|
596
|
+
function findComponentByEvidence(components, symbolName, sourceFile) {
|
|
597
|
+
const normalizedFile = sourceFile.split(path.sep).join('/');
|
|
598
|
+
return components.find((component) => component.name === symbolName
|
|
599
|
+
|| component.keyMethods.some((method) => method.ownerName === symbolName || method.name === symbolName)
|
|
600
|
+
|| component.relatedFiles.some((filePath) => filePath === normalizedFile || filePath.endsWith(normalizedFile)));
|
|
601
|
+
}
|
|
602
|
+
function upsertRelationship(relationships, relationship) {
|
|
603
|
+
const key = `${relationship.fromId}|${relationship.kind}|${relationship.toId}`;
|
|
604
|
+
const existing = relationships.get(key);
|
|
605
|
+
if (!existing) {
|
|
606
|
+
relationships.set(key, {
|
|
607
|
+
...relationship,
|
|
608
|
+
evidence: dedupeComponentEvidence(relationship.evidence),
|
|
609
|
+
});
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
existing.label = existing.label || relationship.label;
|
|
613
|
+
existing.confidence = maxConfidence(existing.confidence, relationship.confidence);
|
|
614
|
+
existing.evidence = dedupeComponentEvidence([...existing.evidence, ...relationship.evidence]);
|
|
615
|
+
}
|
|
616
|
+
function maxConfidence(left, right) {
|
|
617
|
+
const order = ['low', 'medium', 'high'];
|
|
618
|
+
return order[Math.max(order.indexOf(left), order.indexOf(right))] ?? 'low';
|
|
619
|
+
}
|
|
620
|
+
function mergeEvidence(left, right) {
|
|
621
|
+
return dedupeComponentEvidence([...left, ...right]);
|
|
622
|
+
}
|
|
623
|
+
function dedupeMethods(methods) {
|
|
624
|
+
const seen = new Set();
|
|
625
|
+
const result = [];
|
|
626
|
+
for (const method of methods) {
|
|
627
|
+
const key = `${method.ownerName ?? ''}|${method.name}|${method.signature ?? ''}`;
|
|
628
|
+
if (seen.has(key)) {
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
seen.add(key);
|
|
632
|
+
result.push(method);
|
|
633
|
+
}
|
|
634
|
+
return result
|
|
635
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
636
|
+
.slice(0, 8);
|
|
637
|
+
}
|
|
638
|
+
function dedupeStrings(values) {
|
|
639
|
+
return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]
|
|
640
|
+
.sort((a, b) => a.localeCompare(b));
|
|
641
|
+
}
|
|
642
|
+
function getMetadataString(element, key) {
|
|
643
|
+
if (!element) {
|
|
644
|
+
return undefined;
|
|
645
|
+
}
|
|
646
|
+
const value = element.metadata[key];
|
|
647
|
+
return typeof value === 'string' ? value : undefined;
|
|
648
|
+
}
|
|
649
|
+
function escapeMermaidLabel(value) {
|
|
650
|
+
return value.replace(/"/g, '\\"');
|
|
651
|
+
}
|
|
652
|
+
//# sourceMappingURL=component-view-builder.js.map
|