spectra-cli 4.1.1 → 4.3.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 +12 -5
- package/dist/.spectra-build-meta.json +9 -0
- 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 +42 -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 +168 -61
- 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 +74 -5
- package/dist/batch/batch-orchestrator.d.ts.map +1 -1
- package/dist/batch/batch-orchestrator.js +583 -70
- 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 +21 -28
- package/dist/batch/delta-regenerator.js.map +1 -1
- package/dist/batch/module-grouper.d.ts +9 -2
- package/dist/batch/module-grouper.d.ts.map +1 -1
- package/dist/batch/module-grouper.js +3 -1
- package/dist/batch/module-grouper.js.map +1 -1
- package/dist/batch/regen-plan.d.ts +78 -0
- package/dist/batch/regen-plan.d.ts.map +1 -0
- package/dist/batch/regen-plan.js +93 -0
- package/dist/batch/regen-plan.js.map +1 -0
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +36 -8
- package/dist/cli/commands/batch.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/commands/scaffold-kb.d.ts +9 -0
- package/dist/cli/commands/scaffold-kb.d.ts.map +1 -0
- package/dist/cli/commands/scaffold-kb.js +179 -0
- package/dist/cli/commands/scaffold-kb.js.map +1 -0
- package/dist/cli/index.js +33 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/error-handler.d.ts +0 -6
- package/dist/cli/utils/error-handler.d.ts.map +1 -1
- package/dist/cli/utils/error-handler.js +0 -13
- package/dist/cli/utils/error-handler.js.map +1 -1
- package/dist/cli/utils/parse-args.d.ts +55 -3
- package/dist/cli/utils/parse-args.d.ts.map +1 -1
- package/dist/cli/utils/parse-args.js +176 -13
- package/dist/cli/utils/parse-args.js.map +1 -1
- package/dist/cli/version-meta.d.ts +16 -0
- package/dist/cli/version-meta.d.ts.map +1 -0
- package/dist/cli/version-meta.js +28 -0
- package/dist/cli/version-meta.js.map +1 -0
- package/dist/core/ast-analyzer.d.ts.map +1 -1
- package/dist/core/ast-analyzer.js +75 -5
- package/dist/core/ast-analyzer.js.map +1 -1
- package/dist/core/import-resolver.d.ts +93 -0
- package/dist/core/import-resolver.d.ts.map +1 -0
- package/dist/core/import-resolver.js +414 -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 +21 -0
- package/dist/core/single-spec-orchestrator.d.ts.map +1 -1
- package/dist/core/single-spec-orchestrator.js +187 -23
- package/dist/core/single-spec-orchestrator.js.map +1 -1
- package/dist/core/skeleton-hash.d.ts +33 -0
- package/dist/core/skeleton-hash.d.ts.map +1 -0
- package/dist/core/skeleton-hash.js +76 -0
- package/dist/core/skeleton-hash.js.map +1 -0
- package/dist/core/tree-sitter-analyzer.d.ts +7 -0
- package/dist/core/tree-sitter-analyzer.d.ts.map +1 -1
- package/dist/core/tree-sitter-analyzer.js +32 -1
- package/dist/core/tree-sitter-analyzer.js.map +1 -1
- package/dist/core/tree-sitter-fallback.d.ts +12 -4
- package/dist/core/tree-sitter-fallback.d.ts.map +1 -1
- package/dist/core/tree-sitter-fallback.js +160 -12
- package/dist/core/tree-sitter-fallback.js.map +1 -1
- package/dist/extraction/extraction-types.d.ts +25 -25
- package/dist/extraction/image-extractor.d.ts.map +1 -1
- package/dist/extraction/image-extractor.js +3 -1
- package/dist/extraction/image-extractor.js.map +1 -1
- package/dist/extraction/markdown-extractor.d.ts.map +1 -1
- package/dist/extraction/markdown-extractor.js +3 -1
- package/dist/extraction/markdown-extractor.js.map +1 -1
- package/dist/generator/frontmatter.d.ts +5 -0
- package/dist/generator/frontmatter.d.ts.map +1 -1
- package/dist/generator/frontmatter.js +4 -0
- package/dist/generator/frontmatter.js.map +1 -1
- 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/kb-mcp/index.d.ts +14 -0
- package/dist/kb-mcp/index.d.ts.map +1 -0
- package/dist/kb-mcp/index.js +24 -0
- package/dist/kb-mcp/index.js.map +1 -0
- package/dist/kb-mcp/lib/kb-error.d.ts +21 -0
- package/dist/kb-mcp/lib/kb-error.d.ts.map +1 -0
- package/dist/kb-mcp/lib/kb-error.js +28 -0
- package/dist/kb-mcp/lib/kb-error.js.map +1 -0
- package/dist/kb-mcp/lib/kb-locator.d.ts +58 -0
- package/dist/kb-mcp/lib/kb-locator.d.ts.map +1 -0
- package/dist/kb-mcp/lib/kb-locator.js +85 -0
- package/dist/kb-mcp/lib/kb-locator.js.map +1 -0
- package/dist/kb-mcp/lib/result-merger.d.ts +35 -0
- package/dist/kb-mcp/lib/result-merger.d.ts.map +1 -0
- package/dist/kb-mcp/lib/result-merger.js +64 -0
- package/dist/kb-mcp/lib/result-merger.js.map +1 -0
- package/dist/kb-mcp/server.d.ts +12 -0
- package/dist/kb-mcp/server.d.ts.map +1 -0
- package/dist/kb-mcp/server.js +29 -0
- package/dist/kb-mcp/server.js.map +1 -0
- package/dist/kb-mcp/tools/kb-api-lookup.d.ts +28 -0
- package/dist/kb-mcp/tools/kb-api-lookup.d.ts.map +1 -0
- package/dist/kb-mcp/tools/kb-api-lookup.js +237 -0
- package/dist/kb-mcp/tools/kb-api-lookup.js.map +1 -0
- package/dist/kb-mcp/tools/kb-doc-lookup.d.ts +20 -0
- package/dist/kb-mcp/tools/kb-doc-lookup.d.ts.map +1 -0
- package/dist/kb-mcp/tools/kb-doc-lookup.js +92 -0
- package/dist/kb-mcp/tools/kb-doc-lookup.js.map +1 -0
- package/dist/kb-mcp/tools/kb-search.d.ts +23 -0
- package/dist/kb-mcp/tools/kb-search.d.ts.map +1 -0
- package/dist/kb-mcp/tools/kb-search.js +126 -0
- package/dist/kb-mcp/tools/kb-search.js.map +1 -0
- 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 +39 -0
- package/dist/knowledge-graph/import-resolver.d.ts.map +1 -0
- package/dist/knowledge-graph/import-resolver.js +214 -0
- package/dist/knowledge-graph/import-resolver.js.map +1 -0
- package/dist/knowledge-graph/incremental.d.ts +131 -0
- package/dist/knowledge-graph/incremental.d.ts.map +1 -0
- package/dist/knowledge-graph/incremental.js +432 -0
- package/dist/knowledge-graph/incremental.js.map +1 -0
- package/dist/knowledge-graph/index.d.ts +85 -0
- package/dist/knowledge-graph/index.d.ts.map +1 -0
- package/dist/knowledge-graph/index.js +198 -0
- package/dist/knowledge-graph/index.js.map +1 -0
- package/dist/knowledge-graph/module-derivation.d.ts +252 -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 +310 -0
- package/dist/knowledge-graph/persistence.d.ts.map +1 -0
- package/dist/knowledge-graph/persistence.js +280 -0
- package/dist/knowledge-graph/persistence.js.map +1 -0
- package/dist/knowledge-graph/query-helpers.d.ts +191 -0
- package/dist/knowledge-graph/query-helpers.d.ts.map +1 -0
- package/dist/knowledge-graph/query-helpers.js +559 -0
- package/dist/knowledge-graph/query-helpers.js.map +1 -0
- package/dist/knowledge-graph/relativize.d.ts +51 -0
- package/dist/knowledge-graph/relativize.d.ts.map +1 -0
- package/dist/knowledge-graph/relativize.js +104 -0
- package/dist/knowledge-graph/relativize.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 +53 -0
- package/dist/mcp/agent-context-tools.d.ts.map +1 -0
- package/dist/mcp/agent-context-tools.js +806 -0
- package/dist/mcp/agent-context-tools.js.map +1 -0
- package/dist/mcp/file-nav-tools.d.ts +42 -0
- package/dist/mcp/file-nav-tools.d.ts.map +1 -0
- package/dist/mcp/file-nav-tools.js +318 -0
- package/dist/mcp/file-nav-tools.js.map +1 -0
- package/dist/mcp/graph-tools.d.ts +22 -0
- package/dist/mcp/graph-tools.d.ts.map +1 -1
- package/dist/mcp/graph-tools.js +204 -133
- package/dist/mcp/graph-tools.js.map +1 -1
- package/dist/mcp/lib/file-nav-helpers.d.ts +128 -0
- package/dist/mcp/lib/file-nav-helpers.d.ts.map +1 -0
- package/dist/mcp/lib/file-nav-helpers.js +305 -0
- package/dist/mcp/lib/file-nav-helpers.js.map +1 -0
- 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/lib/telemetry.d.ts +69 -0
- package/dist/mcp/lib/telemetry.d.ts.map +1 -0
- package/dist/mcp/lib/telemetry.js +113 -0
- package/dist/mcp/lib/telemetry.js.map +1 -0
- package/dist/mcp/lib/tool-response.d.ts +46 -0
- package/dist/mcp/lib/tool-response.d.ts.map +1 -0
- package/dist/mcp/lib/tool-response.js +83 -0
- package/dist/mcp/lib/tool-response.js.map +1 -0
- package/dist/mcp/server.d.ts +14 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +216 -158
- 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 +80 -6
- package/dist/models/code-skeleton.d.ts.map +1 -1
- package/dist/models/code-skeleton.js +30 -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 +173 -94
- package/dist/models/module-spec.d.ts.map +1 -1
- package/dist/models/module-spec.js +6 -0
- package/dist/models/module-spec.js.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 +15 -2
- package/dist/panoramic/builders/doc-graph-builder.d.ts.map +1 -1
- package/dist/panoramic/builders/doc-graph-builder.js +20 -0
- 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 +72 -2
- package/dist/panoramic/graph/graph-builder.d.ts.map +1 -1
- package/dist/panoramic/graph/graph-builder.js +330 -46
- 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 +49 -2
- package/dist/panoramic/graph/graph-query.d.ts.map +1 -1
- package/dist/panoramic/graph/graph-query.js +117 -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/graph/index.d.ts +2 -1
- package/dist/panoramic/graph/index.d.ts.map +1 -1
- package/dist/panoramic/graph/index.js +1 -1
- package/dist/panoramic/graph/index.js.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/adr-evidence-verifier.d.ts.map +1 -1
- package/dist/panoramic/pipelines/adr-evidence-verifier.js +1 -29
- package/dist/panoramic/pipelines/adr-evidence-verifier.js.map +1 -1
- 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/query.d.ts +1 -0
- package/dist/panoramic/query.d.ts.map +1 -1
- package/dist/panoramic/query.js +5 -0
- package/dist/panoramic/query.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/scaffold-kb/api-entities-serializer.d.ts +12 -0
- package/dist/scaffold-kb/api-entities-serializer.d.ts.map +1 -0
- package/dist/scaffold-kb/api-entities-serializer.js +144 -0
- package/dist/scaffold-kb/api-entities-serializer.js.map +1 -0
- package/dist/scaffold-kb/arbitration.d.ts +44 -0
- package/dist/scaffold-kb/arbitration.d.ts.map +1 -0
- package/dist/scaffold-kb/arbitration.js +144 -0
- package/dist/scaffold-kb/arbitration.js.map +1 -0
- package/dist/scaffold-kb/chunk-splitter.d.ts +20 -0
- package/dist/scaffold-kb/chunk-splitter.d.ts.map +1 -0
- package/dist/scaffold-kb/chunk-splitter.js +309 -0
- package/dist/scaffold-kb/chunk-splitter.js.map +1 -0
- package/dist/scaffold-kb/doc-graph-builder.d.ts +26 -0
- package/dist/scaffold-kb/doc-graph-builder.d.ts.map +1 -0
- package/dist/scaffold-kb/doc-graph-builder.js +72 -0
- package/dist/scaffold-kb/doc-graph-builder.js.map +1 -0
- package/dist/scaffold-kb/entity-extractor.d.ts +40 -0
- package/dist/scaffold-kb/entity-extractor.d.ts.map +1 -0
- package/dist/scaffold-kb/entity-extractor.js +0 -0
- package/dist/scaffold-kb/entity-extractor.js.map +1 -0
- package/dist/scaffold-kb/entity-heuristic.d.ts +14 -0
- package/dist/scaffold-kb/entity-heuristic.d.ts.map +1 -0
- package/dist/scaffold-kb/entity-heuristic.js +107 -0
- package/dist/scaffold-kb/entity-heuristic.js.map +1 -0
- package/dist/scaffold-kb/entity-matcher.d.ts +20 -0
- package/dist/scaffold-kb/entity-matcher.d.ts.map +1 -0
- package/dist/scaffold-kb/entity-matcher.js +53 -0
- package/dist/scaffold-kb/entity-matcher.js.map +1 -0
- package/dist/scaffold-kb/entity-util.d.ts +11 -0
- package/dist/scaffold-kb/entity-util.d.ts.map +1 -0
- package/dist/scaffold-kb/entity-util.js +23 -0
- package/dist/scaffold-kb/entity-util.js.map +1 -0
- package/dist/scaffold-kb/evidence-envelope.d.ts +17 -0
- package/dist/scaffold-kb/evidence-envelope.d.ts.map +1 -0
- package/dist/scaffold-kb/evidence-envelope.js +32 -0
- package/dist/scaffold-kb/evidence-envelope.js.map +1 -0
- package/dist/scaffold-kb/index.d.ts +20 -0
- package/dist/scaffold-kb/index.d.ts.map +1 -0
- package/dist/scaffold-kb/index.js +102 -0
- package/dist/scaffold-kb/index.js.map +1 -0
- package/dist/scaffold-kb/ingest/ingest-core.d.ts +47 -0
- package/dist/scaffold-kb/ingest/ingest-core.d.ts.map +1 -0
- package/dist/scaffold-kb/ingest/ingest-core.js +231 -0
- package/dist/scaffold-kb/ingest/ingest-core.js.map +1 -0
- package/dist/scaffold-kb/ingest/office-parser.d.ts +33 -0
- package/dist/scaffold-kb/ingest/office-parser.d.ts.map +1 -0
- package/dist/scaffold-kb/ingest/office-parser.js +187 -0
- package/dist/scaffold-kb/ingest/office-parser.js.map +1 -0
- package/dist/scaffold-kb/ingest/url-fetcher.d.ts +43 -0
- package/dist/scaffold-kb/ingest/url-fetcher.d.ts.map +1 -0
- package/dist/scaffold-kb/ingest/url-fetcher.js +245 -0
- package/dist/scaffold-kb/ingest/url-fetcher.js.map +1 -0
- package/dist/scaffold-kb/ingester.d.ts +38 -0
- package/dist/scaffold-kb/ingester.d.ts.map +1 -0
- package/dist/scaffold-kb/ingester.js +261 -0
- package/dist/scaffold-kb/ingester.js.map +1 -0
- package/dist/scaffold-kb/injection-format.d.ts +25 -0
- package/dist/scaffold-kb/injection-format.d.ts.map +1 -0
- package/dist/scaffold-kb/injection-format.js +55 -0
- package/dist/scaffold-kb/injection-format.js.map +1 -0
- package/dist/scaffold-kb/kb-writer.d.ts +13 -0
- package/dist/scaffold-kb/kb-writer.d.ts.map +1 -0
- package/dist/scaffold-kb/kb-writer.js +69 -0
- package/dist/scaffold-kb/kb-writer.js.map +1 -0
- package/dist/scaffold-kb/keyword-extract.d.ts +16 -0
- package/dist/scaffold-kb/keyword-extract.d.ts.map +1 -0
- package/dist/scaffold-kb/keyword-extract.js +49 -0
- package/dist/scaffold-kb/keyword-extract.js.map +1 -0
- package/dist/scaffold-kb/query-sanitizer.d.ts +28 -0
- package/dist/scaffold-kb/query-sanitizer.d.ts.map +1 -0
- package/dist/scaffold-kb/query-sanitizer.js +38 -0
- package/dist/scaffold-kb/query-sanitizer.js.map +1 -0
- package/dist/scaffold-kb/recall-eval.d.ts +48 -0
- package/dist/scaffold-kb/recall-eval.d.ts.map +1 -0
- package/dist/scaffold-kb/recall-eval.js +55 -0
- package/dist/scaffold-kb/recall-eval.js.map +1 -0
- package/dist/scaffold-kb/schema-compat.d.ts +22 -0
- package/dist/scaffold-kb/schema-compat.d.ts.map +1 -0
- package/dist/scaffold-kb/schema-compat.js +32 -0
- package/dist/scaffold-kb/schema-compat.js.map +1 -0
- package/dist/scaffold-kb/search-core.d.ts +42 -0
- package/dist/scaffold-kb/search-core.d.ts.map +1 -0
- package/dist/scaffold-kb/search-core.js +89 -0
- package/dist/scaffold-kb/search-core.js.map +1 -0
- package/dist/scaffold-kb/sqlite-engine.d.ts +58 -0
- package/dist/scaffold-kb/sqlite-engine.d.ts.map +1 -0
- package/dist/scaffold-kb/sqlite-engine.js +61 -0
- package/dist/scaffold-kb/sqlite-engine.js.map +1 -0
- package/dist/scaffold-kb/sqlite-writer.d.ts +18 -0
- package/dist/scaffold-kb/sqlite-writer.d.ts.map +1 -0
- package/dist/scaffold-kb/sqlite-writer.js +76 -0
- package/dist/scaffold-kb/sqlite-writer.js.map +1 -0
- package/dist/scaffold-kb/tokenizer.d.ts +26 -0
- package/dist/scaffold-kb/tokenizer.d.ts.map +1 -0
- package/dist/scaffold-kb/tokenizer.js +97 -0
- package/dist/scaffold-kb/tokenizer.js.map +1 -0
- package/dist/scaffold-kb/types.d.ts +157 -0
- package/dist/scaffold-kb/types.d.ts.map +1 -0
- package/dist/scaffold-kb/types.js +5 -0
- package/dist/scaffold-kb/types.js.map +1 -0
- package/dist/utils/file-scanner.d.ts +15 -0
- package/dist/utils/file-scanner.d.ts.map +1 -1
- package/dist/utils/file-scanner.js +18 -1
- package/dist/utils/file-scanner.js.map +1 -1
- package/dist/utils/string-distance.d.ts +20 -0
- package/dist/utils/string-distance.d.ts.map +1 -0
- package/dist/utils/string-distance.js +38 -0
- package/dist/utils/string-distance.js.map +1 -0
- package/package.json +22 -3
- package/plugins/demo-kb-en/.claude-plugin/plugin.json +11 -0
- package/plugins/demo-kb-en/.mcp.json +8 -0
- package/plugins/demo-kb-en/FIXTURE.json +23 -0
- package/plugins/demo-kb-en/FIXTURE.md +53 -0
- package/plugins/demo-kb-en/ingest-samples/meeting-notes.md +13 -0
- package/plugins/demo-kb-en/kb/api-entities.json +3445 -0
- package/plugins/demo-kb-en/kb/chunks.sqlite +0 -0
- package/plugins/demo-kb-en/kb/doc-graph.json +113 -0
- package/plugins/demo-kb-zh/.claude-plugin/plugin.json +11 -0
- package/plugins/demo-kb-zh/.mcp.json +8 -0
- package/plugins/demo-kb-zh/FIXTURE.json +23 -0
- package/plugins/demo-kb-zh/FIXTURE.md +63 -0
- package/plugins/demo-kb-zh/ingest-samples/meeting-notes.md +13 -0
- package/plugins/demo-kb-zh/kb/api-entities.json +990 -0
- package/plugins/demo-kb-zh/kb/chunks.sqlite +0 -0
- package/plugins/demo-kb-zh/kb/doc-graph.json +113 -0
- package/plugins/spec-driver/.claude-plugin/plugin.json +1 -1
- package/plugins/spec-driver/README.md +50 -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 +108 -1
- package/plugins/spec-driver/config/orchestration.yaml +39 -31
- package/plugins/spec-driver/contracts/orchestration-overrides-contract.yaml +27 -0
- package/plugins/spec-driver/contracts/orchestration-schema.mjs +272 -227
- package/plugins/spec-driver/contracts/wrapper-source-of-truth.yaml +3 -0
- package/plugins/spec-driver/docs/customization.md +134 -0
- package/plugins/spec-driver/docs/spectra-mcp-integration.md +165 -0
- package/plugins/spec-driver/hooks/hooks.json +9 -0
- package/plugins/spec-driver/hooks/stop-fix-compliance-check.sh +36 -0
- package/plugins/spec-driver/lib/delegation-contract.mjs +84 -0
- package/plugins/spec-driver/lib/orchestration-resolver.mjs +49 -0
- package/plugins/spec-driver/lib/orchestrator.mjs +29 -1
- package/plugins/spec-driver/lib/preference-rules.mjs +96 -0
- package/plugins/spec-driver/scripts/codex-skills.sh +28 -28
- package/plugins/spec-driver/scripts/dev/spike-fix-compliance-e2e.mjs +130 -0
- package/plugins/spec-driver/scripts/fix-compliance-judge.mjs +415 -0
- package/plugins/spec-driver/scripts/generate-adoption-insights.mjs +48 -1
- package/plugins/spec-driver/scripts/goal-loop-cli.mjs +307 -0
- package/plugins/spec-driver/scripts/init-project.sh +56 -0
- package/plugins/spec-driver/scripts/kb-prequery.mjs +125 -0
- package/plugins/spec-driver/scripts/lib/config-schema.mjs +200 -94
- package/plugins/spec-driver/scripts/lib/ensure-gitignore.sh +277 -0
- package/plugins/spec-driver/scripts/lib/extract-wrapper-body.mjs +136 -0
- package/plugins/spec-driver/scripts/lib/fix-compliance-core.mjs +434 -0
- package/plugins/spec-driver/scripts/lib/fix-compliance-io.mjs +335 -0
- package/plugins/spec-driver/scripts/lib/goal-loop-core.mjs +783 -0
- package/plugins/spec-driver/scripts/lib/init-project-output.sh +28 -0
- package/plugins/spec-driver/scripts/lib/load-zod.mjs +62 -0
- package/plugins/spec-driver/scripts/lib/project-profile-resolver.mjs +141 -49
- package/plugins/spec-driver/scripts/lib/project-profile-schema.mjs +88 -54
- package/plugins/spec-driver/scripts/postinstall.sh +13 -1
- package/plugins/spec-driver/scripts/record-workflow-run.mjs +75 -0
- package/plugins/spec-driver/scripts/sync-delegation-contract.mjs +187 -0
- package/plugins/spec-driver/scripts/sync-preference-rules.mjs +148 -0
- package/plugins/spec-driver/scripts/validate-orchestrator-models.mjs +156 -0
- package/plugins/spec-driver/scripts/validate-wrapper-sources.mjs +46 -1
- package/plugins/spec-driver/skills/spec-driver-feature/SKILL.md +302 -0
- package/plugins/spec-driver/skills/spec-driver-fix/SKILL.md +97 -8
- package/plugins/spec-driver/skills/spec-driver-implement/SKILL.md +18 -0
- package/plugins/spec-driver/skills/spec-driver-refactor/SKILL.md +10 -0
- package/plugins/spec-driver/skills/spec-driver-resume/SKILL.md +12 -1
- package/plugins/spec-driver/skills/spec-driver-story/SKILL.md +30 -0
- package/plugins/spec-driver/templates/delegation-contract.md +27 -0
- package/plugins/spec-driver/templates/goal-loop-override-template.yaml +284 -0
- package/plugins/spec-driver/templates/preference-rules.md +39 -0
- package/plugins/spec-driver/templates/specify-base/project-context-template.yaml +10 -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/module-spec.hbs +1 -0
- package/templates/product-overview.hbs +1 -1
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature 155 — Agent-Context MCP Tools (impact / context / detect_changes)
|
|
3
|
+
*
|
|
4
|
+
* 3 个 tool handler,建在 Feature 151 已 ship 的 UnifiedGraph + call-resolver 之上:
|
|
5
|
+
* - impact: blast radius — 反向 BFS 找受影响 symbols
|
|
6
|
+
* - context: 360° symbol 视图 — definition + callers + callees + imports + relatedSpec
|
|
7
|
+
* - detect_changes: git diff → changedSymbols → impact 链
|
|
8
|
+
*
|
|
9
|
+
* 数据流:
|
|
10
|
+
* getCachedGraphData(projectRoot) // 来自 graph-tools.ts,含 mtime/size stale 检测
|
|
11
|
+
* ↓
|
|
12
|
+
* query-helpers.ts (bfsTraverse / canonicalizeSymbolId / resolveSymbolFuzzy / ...)
|
|
13
|
+
* ↓
|
|
14
|
+
* tool handler 输出 JSON envelope
|
|
15
|
+
*
|
|
16
|
+
* 错误处理(FR-050):统一 envelope `{ isError: true, content: [{type:'text', text: JSON({code, message, hint?, context?})}]}`
|
|
17
|
+
* 错误 code: graph-not-built / symbol-not-found / invalid-symbol-id / invalid-input /
|
|
18
|
+
* invalid-diff / payload-too-large / git-spawn-failed / git-timeout / internal-error
|
|
19
|
+
*/
|
|
20
|
+
import { spawnSync } from 'node:child_process';
|
|
21
|
+
import { existsSync } from 'node:fs';
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
import { getCachedGraphData, isGraphFormatStaleError } from './graph-tools.js';
|
|
25
|
+
import { bfsTraverse, canonicalizeSymbolId, computeRiskTier, resolveSymbolFuzzy, findNode, moduleFileFromId, resolveEdgeConfidence, } from '../knowledge-graph/query-helpers.js';
|
|
26
|
+
import { buildTopImpactedRanking, buildTopRelevantCallers, generateNextStepHint, safeStderrLog, } from './lib/response-helpers.js';
|
|
27
|
+
// ============================================================
|
|
28
|
+
// 共享响应原语 + Telemetry(Feature 171 抽到 lib/ 复用,解 C-4 / TELEMETRY-COUPLING)
|
|
29
|
+
// ============================================================
|
|
30
|
+
import { buildErrorResponse, buildSuccessResponse, } from './lib/tool-response.js';
|
|
31
|
+
import { recordAndReturn } from './lib/telemetry.js';
|
|
32
|
+
// 向后兼容 re-export:既有 tests/unit/mcp/telemetry.test.ts 从本模块 import 这些符号
|
|
33
|
+
export { recordAndReturn, writeTelemetry } from './lib/telemetry.js';
|
|
34
|
+
/**
|
|
35
|
+
* 统一 impact / context / detect_changes 三工具的 telemetry 采样 + 顶层 internal-error catch +
|
|
36
|
+
* recordAndReturn 透传,消除三处复制的 _telStart / _telReqSize / 散落 recordAndReturn 样板。
|
|
37
|
+
*
|
|
38
|
+
* 不变量(spec AD-1):agent-context 属"自采样组"——telemetry 在本骨架内(handler 内部)发射,
|
|
39
|
+
* 注册层**不**再包 withTelemetry,故每次调用恰 1 行。
|
|
40
|
+
*
|
|
41
|
+
* 顶层 catch 行为保持与重构前**逐字一致**(behavior-preserve):internal-error 携带 err.message
|
|
42
|
+
* 与截断 stack。该 message/stack 形态属 agent-context 既有行为,不在 F177 C-4 重新脱敏范围
|
|
43
|
+
* (spec 遗留-2)。
|
|
44
|
+
*/
|
|
45
|
+
async function runAgentContextTool(toolName, args, body) {
|
|
46
|
+
const _telStart = Date.now();
|
|
47
|
+
let _telReqSize = 0;
|
|
48
|
+
try {
|
|
49
|
+
_telReqSize = JSON.stringify(args).length;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
_telReqSize = 0;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const out = await body();
|
|
56
|
+
return recordAndReturn(toolName, _telStart, _telReqSize, out.result, out.summary, out.samples);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// F186 T4:脱敏回传给 MCP 客户端的错误响应——不外漏 err.message / stack(可能含绝对路径)。
|
|
60
|
+
// 保留 internal-error code(客户端只消费 code);telemetry 经 recordAndReturn 仍记录该 code。
|
|
61
|
+
return recordAndReturn(toolName, _telStart, _telReqSize, buildErrorResponse('internal-error', '内部错误,请稍后重试'));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Feature 193 FR-006 — 加载 graph,区分三态:
|
|
66
|
+
* - 成功 → { data }
|
|
67
|
+
* - graph-format-stale(旧绝对格式,copy 自其他 worktree)→ { error: stale 响应 }
|
|
68
|
+
* - 缺图 / 其他加载失败 → { error: graph-not-built 响应 }
|
|
69
|
+
*
|
|
70
|
+
* 让 impact/context/detect_changes 对旧格式图给明确重建指引,不静默退化为 graph-not-built。
|
|
71
|
+
*/
|
|
72
|
+
function loadGraphOrError(projectRoot) {
|
|
73
|
+
try {
|
|
74
|
+
const cached = getCachedGraphData(projectRoot);
|
|
75
|
+
if (cached === null) {
|
|
76
|
+
return {
|
|
77
|
+
// F186 T4:去掉 projectRoot 内插(避免回传绝对路径),固定文案 + 可执行 hint
|
|
78
|
+
error: buildErrorResponse('graph-not-built', 'graph 未构建', '请先运行 `spectra batch` 生成图谱'),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { data: cached };
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (isGraphFormatStaleError(err)) {
|
|
85
|
+
return {
|
|
86
|
+
error: buildErrorResponse('graph-format-stale', err.message, '当前 worktree 的图为旧绝对路径格式(可能 copy 自主仓/其他 worktree)。运行 `spectra index` 或 `spectra batch` 在当前 worktree 重建图。'),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
// F186 T4:其他加载失败同样脱敏——不回传 projectRoot 绝对路径
|
|
91
|
+
error: buildErrorResponse('graph-not-built', 'graph 未构建', '请先运行 `spectra batch` 生成图谱'),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ============================================================
|
|
96
|
+
// impact tool
|
|
97
|
+
// ============================================================
|
|
98
|
+
const ImpactInputSchema = {
|
|
99
|
+
target: z.string().describe('symbol id (e.g. "micrograd/engine.py::Value.__add__")'),
|
|
100
|
+
depth: z.number().int().min(0).max(20).optional().describe('BFS depth (default 2, max 5; 超出 clamp)'),
|
|
101
|
+
minConfidence: z.number().min(0).max(1).optional().describe('confidence 阈值 (default 0.65)'),
|
|
102
|
+
direction: z.enum(['upstream', 'downstream', 'both']).optional().describe('BFS 方向 (default upstream)'),
|
|
103
|
+
budget: z.number().int().min(0).max(10000).optional().describe('节点上限 (default 200, max 1000; 超出 clamp)'),
|
|
104
|
+
projectRoot: z.string().optional().describe('default cwd'),
|
|
105
|
+
};
|
|
106
|
+
export async function handleImpact(args) {
|
|
107
|
+
return runAgentContextTool('impact', args, () => {
|
|
108
|
+
if (typeof args.target !== 'string' || args.target.length === 0) {
|
|
109
|
+
return { result: buildErrorResponse('invalid-input', 'target 必填且为非空字符串') };
|
|
110
|
+
}
|
|
111
|
+
const projectRoot = args.projectRoot ?? process.cwd();
|
|
112
|
+
const loaded = loadGraphOrError(projectRoot);
|
|
113
|
+
if (loaded.error) {
|
|
114
|
+
return { result: loaded.error };
|
|
115
|
+
}
|
|
116
|
+
const { graphData, graphPath, mtimeMs, sizeBytes } = loaded.data;
|
|
117
|
+
// 入参 clamp(FR-015)— handler 层负责 clamp 并附 warning,不依赖 zod max
|
|
118
|
+
const warnings = [];
|
|
119
|
+
const reqDepth = args.depth ?? 2;
|
|
120
|
+
const effectiveDepth = Math.min(Math.max(reqDepth, 0), 5);
|
|
121
|
+
if (effectiveDepth !== reqDepth)
|
|
122
|
+
warnings.push('depth-clamped');
|
|
123
|
+
const reqBudget = args.budget ?? 200;
|
|
124
|
+
const effectiveBudget = Math.min(Math.max(reqBudget, 0), 1000);
|
|
125
|
+
if (effectiveBudget !== reqBudget)
|
|
126
|
+
warnings.push('budget-clamped');
|
|
127
|
+
const reqMinConf = args.minConfidence ?? 0.65;
|
|
128
|
+
const minConfidence = Math.min(Math.max(reqMinConf, 0), 1);
|
|
129
|
+
if (minConfidence !== reqMinConf)
|
|
130
|
+
warnings.push('minConfidence-clamped');
|
|
131
|
+
const direction = args.direction ?? 'upstream';
|
|
132
|
+
// canonicalize symbol id
|
|
133
|
+
const canon = canonicalizeSymbolId(args.target, graphData, { projectRoot });
|
|
134
|
+
if (canon.reason === 'invalid') {
|
|
135
|
+
return { result: buildErrorResponse('invalid-symbol-id', `target 含非法字符或格式: ${args.target}`) };
|
|
136
|
+
}
|
|
137
|
+
// F174:canonicalize not-found 时走分层 fuzzy(autoResolved → 用 resolvedTo 继续;否则结构化 top-3)
|
|
138
|
+
let startId;
|
|
139
|
+
let fuzzyResolved = null;
|
|
140
|
+
if (canon.reason === 'not-found' || canon.canonicalId === null) {
|
|
141
|
+
const fuzzy = resolveSymbolFuzzy(graphData, args.target, { projectRoot });
|
|
142
|
+
if (fuzzy.autoResolved && fuzzy.candidates[0] !== undefined) {
|
|
143
|
+
startId = fuzzy.candidates[0].id;
|
|
144
|
+
fuzzyResolved = { from: args.target, to: fuzzy.candidates[0].id, confidence: fuzzy.candidates[0].confidence };
|
|
145
|
+
warnings.push('fuzzy-resolved');
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return { result: buildErrorResponse('symbol-not-found', `target 在 graph 中未找到: ${args.target}`, '请检查 symbol id 格式或参考 fuzzyMatches 候选', { fuzzyMatches: fuzzy.candidates.slice(0, 3) }) };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
startId = canon.canonicalId;
|
|
153
|
+
}
|
|
154
|
+
// BFS
|
|
155
|
+
const r = bfsTraverse(graphData, startId, {
|
|
156
|
+
depth: effectiveDepth,
|
|
157
|
+
minConfidence,
|
|
158
|
+
direction,
|
|
159
|
+
budget: effectiveBudget,
|
|
160
|
+
graphPath,
|
|
161
|
+
graphMtimeMs: mtimeMs,
|
|
162
|
+
graphSizeBytes: sizeBytes,
|
|
163
|
+
relations: ['calls'],
|
|
164
|
+
});
|
|
165
|
+
// 合并 warnings
|
|
166
|
+
for (const w of r.warnings) {
|
|
167
|
+
if (!warnings.includes(w))
|
|
168
|
+
warnings.push(w);
|
|
169
|
+
}
|
|
170
|
+
// summary
|
|
171
|
+
const directCallers = r.affected.filter((a) => a.depth === 1).length;
|
|
172
|
+
const transitive = r.affected.length;
|
|
173
|
+
const riskTier = computeRiskTier(directCallers, transitive);
|
|
174
|
+
const data = {
|
|
175
|
+
affected: r.affected,
|
|
176
|
+
summary: { directCallers, transitive, riskTier },
|
|
177
|
+
effectiveDepth,
|
|
178
|
+
effectiveMinConfidence: minConfidence,
|
|
179
|
+
effectiveBudget,
|
|
180
|
+
effectiveDirection: direction,
|
|
181
|
+
};
|
|
182
|
+
if (warnings.length > 0)
|
|
183
|
+
data['warnings'] = warnings;
|
|
184
|
+
// F174:autoResolved 时附加 resolve 溯源字段
|
|
185
|
+
if (fuzzyResolved !== null) {
|
|
186
|
+
data['resolvedFrom'] = fuzzyResolved.from;
|
|
187
|
+
data['resolvedTo'] = fuzzyResolved.to;
|
|
188
|
+
data['resolvedConfidence'] = fuzzyResolved.confidence;
|
|
189
|
+
}
|
|
190
|
+
// F170c enrichment 三路径(plan G 节):临时变量 + 显式 catch reset 避免 partial fill
|
|
191
|
+
let topImpacted;
|
|
192
|
+
let nextStepHint;
|
|
193
|
+
let enrichmentDegraded;
|
|
194
|
+
try {
|
|
195
|
+
const _topImpacted = buildTopImpactedRanking(r.affected, 5);
|
|
196
|
+
const _nextStepHint = generateNextStepHint('impact', { topImpacted: _topImpacted, affected: r.affected }, 'success');
|
|
197
|
+
topImpacted = _topImpacted;
|
|
198
|
+
nextStepHint = _nextStepHint;
|
|
199
|
+
enrichmentDegraded = false;
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
topImpacted = [];
|
|
203
|
+
nextStepHint = '';
|
|
204
|
+
enrichmentDegraded = true;
|
|
205
|
+
safeStderrLog(`[F170c] impact enrichment degraded: ${String(e)}\n`);
|
|
206
|
+
}
|
|
207
|
+
data['topImpacted'] = topImpacted;
|
|
208
|
+
data['nextStepHint'] = nextStepHint;
|
|
209
|
+
if (enrichmentDegraded)
|
|
210
|
+
data['_enrichmentDegraded'] = true;
|
|
211
|
+
return { result: buildSuccessResponse(data, ['affected']) };
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
// ============================================================
|
|
215
|
+
// context tool
|
|
216
|
+
// ============================================================
|
|
217
|
+
const ContextInputSchema = {
|
|
218
|
+
symbolId: z.string().describe('symbol id'),
|
|
219
|
+
include: z
|
|
220
|
+
.array(z.enum(['callers', 'callees', 'imports', 'related-spec']))
|
|
221
|
+
.optional()
|
|
222
|
+
.describe('字段子集 (default ["callers","callees","imports"])'),
|
|
223
|
+
projectRoot: z.string().optional(),
|
|
224
|
+
};
|
|
225
|
+
export async function handleContext(args) {
|
|
226
|
+
return runAgentContextTool('context', args, () => {
|
|
227
|
+
if (typeof args.symbolId !== 'string' || args.symbolId.length === 0) {
|
|
228
|
+
return { result: buildErrorResponse('invalid-input', 'symbolId 必填且为非空字符串') };
|
|
229
|
+
}
|
|
230
|
+
const projectRoot = args.projectRoot ?? process.cwd();
|
|
231
|
+
// Codex implement-C2:复用 loadGraphOrError,使 graph-format-stale 明确上抛
|
|
232
|
+
// (旧绝对格式图给重建指引),不被外层 catch-all 吞成 internal-error。
|
|
233
|
+
const loaded = loadGraphOrError(projectRoot);
|
|
234
|
+
if (loaded.error) {
|
|
235
|
+
return { result: loaded.error };
|
|
236
|
+
}
|
|
237
|
+
const { graphData } = loaded.data;
|
|
238
|
+
const include = args.include ?? ['callers', 'callees', 'imports'];
|
|
239
|
+
// F174:context handler 引入 warnings 数组(原本无此字段),承载 'fuzzy-resolved' 等
|
|
240
|
+
const warnings = [];
|
|
241
|
+
const canon = canonicalizeSymbolId(args.symbolId, graphData, { projectRoot });
|
|
242
|
+
if (canon.reason === 'invalid') {
|
|
243
|
+
return { result: buildErrorResponse('invalid-symbol-id', `symbolId 含非法字符: ${args.symbolId}`) };
|
|
244
|
+
}
|
|
245
|
+
// F174:canonicalize not-found 时走分层 fuzzy(autoResolved → 用 resolvedTo 继续;否则结构化 top-3)
|
|
246
|
+
let resolvedId;
|
|
247
|
+
let fuzzyResolved = null;
|
|
248
|
+
if (canon.reason === 'not-found' || canon.canonicalId === null) {
|
|
249
|
+
const fuzzy = resolveSymbolFuzzy(graphData, args.symbolId, { projectRoot });
|
|
250
|
+
if (fuzzy.autoResolved && fuzzy.candidates[0] !== undefined) {
|
|
251
|
+
resolvedId = fuzzy.candidates[0].id;
|
|
252
|
+
fuzzyResolved = { from: args.symbolId, to: fuzzy.candidates[0].id, confidence: fuzzy.candidates[0].confidence };
|
|
253
|
+
warnings.push('fuzzy-resolved');
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
return { result: buildErrorResponse('symbol-not-found', `symbolId 在 graph 中未找到: ${args.symbolId}`, '请检查 id 格式或参考 fuzzyMatches 候选', { fuzzyMatches: fuzzy.candidates.slice(0, 3) }) };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
resolvedId = canon.canonicalId;
|
|
261
|
+
}
|
|
262
|
+
const node = findNode(graphData, resolvedId);
|
|
263
|
+
if (node === null) {
|
|
264
|
+
return { result: buildErrorResponse('symbol-not-found', `节点对象未找到: ${resolvedId}`) };
|
|
265
|
+
}
|
|
266
|
+
const definition = buildDefinition(node);
|
|
267
|
+
const data = { definition };
|
|
268
|
+
if (include.includes('callers')) {
|
|
269
|
+
data['callers'] = collectNeighbors(graphData, resolvedId, 'inbound', 'calls');
|
|
270
|
+
}
|
|
271
|
+
if (include.includes('callees')) {
|
|
272
|
+
data['callees'] = collectNeighbors(graphData, resolvedId, 'outbound', 'calls');
|
|
273
|
+
}
|
|
274
|
+
if (include.includes('imports')) {
|
|
275
|
+
// imports 来自 module 节点的 outbound depends-on / cross-module
|
|
276
|
+
const moduleId = moduleFileFromId(resolvedId);
|
|
277
|
+
const importEntries = collectNeighbors(graphData, moduleId, 'outbound', 'depends-on').concat(collectNeighbors(graphData, moduleId, 'outbound', 'cross-module'));
|
|
278
|
+
// 转换为 import schema
|
|
279
|
+
data['imports'] = importEntries.map((x) => ({
|
|
280
|
+
moduleId: x.id,
|
|
281
|
+
file: moduleFileFromId(x.id),
|
|
282
|
+
confidence: x.confidence,
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
if (include.includes('related-spec')) {
|
|
286
|
+
data['relatedSpec'] = deriveRelatedSpec(resolvedId, projectRoot);
|
|
287
|
+
}
|
|
288
|
+
// F174:autoResolved 时附加 resolve 溯源字段 + warnings
|
|
289
|
+
if (fuzzyResolved !== null) {
|
|
290
|
+
data['resolvedFrom'] = fuzzyResolved.from;
|
|
291
|
+
data['resolvedTo'] = fuzzyResolved.to;
|
|
292
|
+
data['resolvedConfidence'] = fuzzyResolved.confidence;
|
|
293
|
+
}
|
|
294
|
+
if (warnings.length > 0)
|
|
295
|
+
data['warnings'] = warnings;
|
|
296
|
+
// F170c enrichment 三路径(plan G 节)
|
|
297
|
+
const callersRaw = data['callers'] ?? [];
|
|
298
|
+
let topRelevantCallers;
|
|
299
|
+
let nextStepHint;
|
|
300
|
+
let enrichmentDegraded;
|
|
301
|
+
try {
|
|
302
|
+
const _top = buildTopRelevantCallers(callersRaw, 3);
|
|
303
|
+
const _hint = generateNextStepHint('context', { definition, callers: callersRaw }, 'success');
|
|
304
|
+
topRelevantCallers = _top;
|
|
305
|
+
nextStepHint = _hint;
|
|
306
|
+
enrichmentDegraded = false;
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
topRelevantCallers = [];
|
|
310
|
+
nextStepHint = '';
|
|
311
|
+
enrichmentDegraded = true;
|
|
312
|
+
safeStderrLog(`[F170c] context enrichment degraded: ${String(e)}\n`);
|
|
313
|
+
}
|
|
314
|
+
data['topRelevantCallers'] = topRelevantCallers;
|
|
315
|
+
data['nextStepHint'] = nextStepHint;
|
|
316
|
+
if (enrichmentDegraded)
|
|
317
|
+
data['_enrichmentDegraded'] = true;
|
|
318
|
+
return { result: buildSuccessResponse(data, ['callers', 'callees', 'imports']) };
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function buildDefinition(node) {
|
|
322
|
+
const md = node.metadata;
|
|
323
|
+
const def = {
|
|
324
|
+
id: node.id,
|
|
325
|
+
file: md['sourceFile'] ?? md['sourcePath'] ?? moduleFileFromId(node.id),
|
|
326
|
+
kind: node.kind,
|
|
327
|
+
label: node.label,
|
|
328
|
+
};
|
|
329
|
+
const lineRange = md['lineRange'];
|
|
330
|
+
if (lineRange) {
|
|
331
|
+
if (typeof lineRange.start === 'number')
|
|
332
|
+
def['lineStart'] = lineRange.start;
|
|
333
|
+
if (typeof lineRange.end === 'number')
|
|
334
|
+
def['lineEnd'] = lineRange.end;
|
|
335
|
+
}
|
|
336
|
+
const conf = md['confidence'];
|
|
337
|
+
if (typeof conf === 'string')
|
|
338
|
+
def['confidence'] = conf;
|
|
339
|
+
return def;
|
|
340
|
+
}
|
|
341
|
+
function collectNeighbors(graphData, nodeId, direction, relation) {
|
|
342
|
+
const out = [];
|
|
343
|
+
for (const link of graphData.links) {
|
|
344
|
+
if (link.relation !== relation)
|
|
345
|
+
continue;
|
|
346
|
+
const conf = resolveEdgeConfidence(link);
|
|
347
|
+
if (conf === null)
|
|
348
|
+
continue;
|
|
349
|
+
if (direction === 'inbound' && link.target === nodeId) {
|
|
350
|
+
out.push({ id: link.source, confidence: conf, relation: link.relation });
|
|
351
|
+
}
|
|
352
|
+
else if (direction === 'outbound' && link.source === nodeId) {
|
|
353
|
+
out.push({ id: link.target, confidence: conf, relation: link.relation });
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return out;
|
|
357
|
+
}
|
|
358
|
+
function deriveRelatedSpec(symbolId, projectRoot) {
|
|
359
|
+
const moduleFile = moduleFileFromId(symbolId);
|
|
360
|
+
const slug = path.basename(moduleFile, path.extname(moduleFile));
|
|
361
|
+
const candidates = [
|
|
362
|
+
path.join(projectRoot, 'panoramic', 'modules', `${slug}.spec.md`),
|
|
363
|
+
path.join(projectRoot, 'specs', 'products', 'spectra', '_generated', 'modules', `${slug}.spec.md`),
|
|
364
|
+
path.join(projectRoot, '_meta', 'modules', `${slug}.spec.md`),
|
|
365
|
+
];
|
|
366
|
+
for (const c of candidates) {
|
|
367
|
+
if (existsSync(c)) {
|
|
368
|
+
return { kind: 'module-coarse', path: path.relative(projectRoot, c) };
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return { kind: 'unknown' };
|
|
372
|
+
}
|
|
373
|
+
// ============================================================
|
|
374
|
+
// detect_changes tool
|
|
375
|
+
// ============================================================
|
|
376
|
+
const DetectChangesInputSchema = {
|
|
377
|
+
diff: z.string().optional().describe('unified diff 文本'),
|
|
378
|
+
baseRef: z.string().optional().describe('git ref (e.g. HEAD~1)'),
|
|
379
|
+
projectRoot: z.string().optional(),
|
|
380
|
+
depth: z.number().int().min(0).max(10).optional().describe('default 2, max 5'),
|
|
381
|
+
budget: z.number().int().min(0).max(10000).optional().describe('default 200, max 1000'),
|
|
382
|
+
minConfidence: z.number().min(0).max(1).optional().describe('default 0.65'),
|
|
383
|
+
};
|
|
384
|
+
const MAX_DIFF_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
385
|
+
const BASEREF_WHITELIST = /^[A-Za-z0-9_./~^@{}-]+$/;
|
|
386
|
+
const GIT_TIMEOUT_MS = 30_000;
|
|
387
|
+
const REVPARSE_TIMEOUT_MS = 5_000;
|
|
388
|
+
export async function handleDetectChanges(args) {
|
|
389
|
+
return runAgentContextTool('detect_changes', args, () => {
|
|
390
|
+
const hasDiff = typeof args.diff === 'string' && args.diff.length > 0;
|
|
391
|
+
const hasBaseRef = typeof args.baseRef === 'string' && args.baseRef.length > 0;
|
|
392
|
+
if (!hasDiff && !hasBaseRef) {
|
|
393
|
+
return { result: buildErrorResponse('invalid-input', '必须提供 diff 或 baseRef 之一', undefined, { reason: 'diff-or-baseref-required' }) };
|
|
394
|
+
}
|
|
395
|
+
const warnings = [];
|
|
396
|
+
if (hasDiff && hasBaseRef) {
|
|
397
|
+
warnings.push('baseRef-ignored');
|
|
398
|
+
}
|
|
399
|
+
const projectRoot = args.projectRoot ?? process.cwd();
|
|
400
|
+
// Codex implement-C2:复用 loadGraphOrError,使 graph-format-stale 明确上抛
|
|
401
|
+
// (旧绝对格式图给重建指引),不被外层 catch-all 吞成 internal-error。
|
|
402
|
+
const loaded = loadGraphOrError(projectRoot);
|
|
403
|
+
if (loaded.error) {
|
|
404
|
+
return { result: loaded.error };
|
|
405
|
+
}
|
|
406
|
+
const { graphData, graphPath, mtimeMs, sizeBytes } = loaded.data;
|
|
407
|
+
// 1) 拿改动文件列表
|
|
408
|
+
let changedFiles;
|
|
409
|
+
let unmappedFromInput = [];
|
|
410
|
+
if (hasDiff) {
|
|
411
|
+
// 5MB 上限校验前置(CRITICAL fix:返回 payload-too-large 而非 invalid-diff)
|
|
412
|
+
if (Buffer.byteLength(args.diff, 'utf-8') > MAX_DIFF_BYTES) {
|
|
413
|
+
return { result: buildErrorResponse('payload-too-large', `diff 超过上限 ${MAX_DIFF_BYTES} 字节`, undefined, { limitBytes: MAX_DIFF_BYTES }) };
|
|
414
|
+
}
|
|
415
|
+
const parsed = parseUnifiedDiff(args.diff);
|
|
416
|
+
if (parsed.error !== undefined) {
|
|
417
|
+
return { result: buildErrorResponse('invalid-diff', parsed.error) };
|
|
418
|
+
}
|
|
419
|
+
changedFiles = parsed.changed;
|
|
420
|
+
unmappedFromInput = parsed.unmapped;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
const r = runGitDiffNameStatus(args.baseRef, projectRoot);
|
|
424
|
+
if (!r.ok) {
|
|
425
|
+
return { result: buildErrorResponse(r.code, r.message, undefined, r.context) };
|
|
426
|
+
}
|
|
427
|
+
changedFiles = r.changed;
|
|
428
|
+
unmappedFromInput = r.unmapped;
|
|
429
|
+
}
|
|
430
|
+
// 没有改动文件 → success warning(FR-050 'no-changed-files' 是 warning 不是 error)
|
|
431
|
+
if (changedFiles.length === 0 && unmappedFromInput.length === 0) {
|
|
432
|
+
warnings.push('no-changed-files');
|
|
433
|
+
}
|
|
434
|
+
// 2) file → graph symbols 映射
|
|
435
|
+
const fileToSymbols = buildFileSymbolIndex(graphData);
|
|
436
|
+
const changedSymbolsOut = [];
|
|
437
|
+
const unmappedFiles = [...unmappedFromInput];
|
|
438
|
+
const allChangedSymbolIds = [];
|
|
439
|
+
for (const cf of changedFiles) {
|
|
440
|
+
const symbols = fileToSymbols.get(cf.file);
|
|
441
|
+
if (symbols === undefined || symbols.length === 0) {
|
|
442
|
+
unmappedFiles.push({ file: cf.file, reason: 'not-in-graph' });
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
changedSymbolsOut.push({ file: cf.file, changeKind: cf.changeKind, symbols });
|
|
446
|
+
for (const s of symbols)
|
|
447
|
+
allChangedSymbolIds.push(s);
|
|
448
|
+
}
|
|
449
|
+
// 3) 跨 changedSymbol 共享 budget BFS
|
|
450
|
+
const reqDepth = args.depth ?? 2;
|
|
451
|
+
const effectiveDepth = Math.min(Math.max(reqDepth, 0), 5);
|
|
452
|
+
if (effectiveDepth !== reqDepth)
|
|
453
|
+
warnings.push('depth-clamped');
|
|
454
|
+
const reqBudget = args.budget ?? 200;
|
|
455
|
+
const effectiveBudget = Math.min(Math.max(reqBudget, 0), 1000);
|
|
456
|
+
if (effectiveBudget !== reqBudget)
|
|
457
|
+
warnings.push('budget-clamped');
|
|
458
|
+
const minConfidence = args.minConfidence ?? 0.65;
|
|
459
|
+
const sharedVisited = new Set();
|
|
460
|
+
for (const s of allChangedSymbolIds)
|
|
461
|
+
sharedVisited.add(s);
|
|
462
|
+
const affectedAcc = [];
|
|
463
|
+
let remaining = effectiveBudget;
|
|
464
|
+
for (const startId of allChangedSymbolIds) {
|
|
465
|
+
if (remaining <= 0) {
|
|
466
|
+
warnings.push('budget-truncated');
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
const r = bfsTraverse(graphData, startId, {
|
|
470
|
+
depth: effectiveDepth,
|
|
471
|
+
minConfidence,
|
|
472
|
+
direction: 'upstream',
|
|
473
|
+
budget: remaining,
|
|
474
|
+
sharedVisited,
|
|
475
|
+
graphPath,
|
|
476
|
+
graphMtimeMs: mtimeMs,
|
|
477
|
+
graphSizeBytes: sizeBytes,
|
|
478
|
+
relations: ['calls'],
|
|
479
|
+
});
|
|
480
|
+
affectedAcc.push(...r.affected);
|
|
481
|
+
remaining = effectiveBudget - affectedAcc.length;
|
|
482
|
+
for (const w of r.warnings) {
|
|
483
|
+
if (!warnings.includes(w))
|
|
484
|
+
warnings.push(w);
|
|
485
|
+
}
|
|
486
|
+
if (r.warnings.includes('budget-truncated'))
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
// de-warning(去重)
|
|
490
|
+
const uniqWarnings = [...new Set(warnings)];
|
|
491
|
+
const totalChanged = allChangedSymbolIds.length;
|
|
492
|
+
const totalAffected = affectedAcc.length;
|
|
493
|
+
const riskTier = computeRiskTier(0, totalAffected);
|
|
494
|
+
const data = {
|
|
495
|
+
changedSymbols: changedSymbolsOut,
|
|
496
|
+
affectedSymbols: affectedAcc,
|
|
497
|
+
riskSummary: { totalChanged, totalAffected, riskTier },
|
|
498
|
+
unmappedFiles,
|
|
499
|
+
effectiveBudget,
|
|
500
|
+
effectiveDepth,
|
|
501
|
+
effectiveMinConfidence: minConfidence,
|
|
502
|
+
};
|
|
503
|
+
if (uniqWarnings.length > 0)
|
|
504
|
+
data['warnings'] = uniqWarnings;
|
|
505
|
+
// F170c enrichment(plan G + D 节)
|
|
506
|
+
const enrichment = _computeDetectChangesEnrichment(affectedAcc, riskTier, totalChanged);
|
|
507
|
+
data['riskTier'] = riskTier;
|
|
508
|
+
data['topImpacted'] = enrichment.topImpacted;
|
|
509
|
+
data['nextStepHint'] = enrichment.nextStepHint;
|
|
510
|
+
if (enrichment.degraded)
|
|
511
|
+
data['_enrichmentDegraded'] = true;
|
|
512
|
+
// telemetry sample(Feature 165)
|
|
513
|
+
const { symbolSample, fileSample } = _buildTelemetrySamples(changedSymbolsOut);
|
|
514
|
+
return {
|
|
515
|
+
result: buildSuccessResponse(data, ['affectedSymbols']),
|
|
516
|
+
summary: { changedSymbolsCount: totalChanged },
|
|
517
|
+
samples: { symbols: symbolSample, files: fileSample },
|
|
518
|
+
};
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
// ─── detect_changes 私有辅助函数(F170c T-GREEN-2 cleanup) ───
|
|
522
|
+
function _computeDetectChangesEnrichment(affectedAcc, riskTier, totalChanged) {
|
|
523
|
+
try {
|
|
524
|
+
const topImpacted = buildTopImpactedRanking(affectedAcc, 5);
|
|
525
|
+
const nextStepHint = generateNextStepHint('detect_changes', { topImpacted, riskTier, totalChanged }, 'success');
|
|
526
|
+
return { topImpacted, nextStepHint, degraded: false };
|
|
527
|
+
}
|
|
528
|
+
catch (e) {
|
|
529
|
+
safeStderrLog(`[F170c] detect_changes enrichment degraded: ${String(e)}\n`);
|
|
530
|
+
return { topImpacted: [], nextStepHint: '', degraded: true };
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function _buildTelemetrySamples(changedSymbolsOut) {
|
|
534
|
+
const sampleMaxN = 10;
|
|
535
|
+
const symbolSample = [];
|
|
536
|
+
for (const cf of changedSymbolsOut) {
|
|
537
|
+
for (const sym of cf.symbols) {
|
|
538
|
+
if (symbolSample.length >= sampleMaxN)
|
|
539
|
+
break;
|
|
540
|
+
symbolSample.push(sym);
|
|
541
|
+
}
|
|
542
|
+
if (symbolSample.length >= sampleMaxN)
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
const fileSample = [];
|
|
546
|
+
for (const cf of changedSymbolsOut) {
|
|
547
|
+
if (fileSample.length >= sampleMaxN)
|
|
548
|
+
break;
|
|
549
|
+
fileSample.push(cf.file);
|
|
550
|
+
}
|
|
551
|
+
return { symbolSample, fileSample };
|
|
552
|
+
}
|
|
553
|
+
// ─── unified diff 解析 ─────────────────────────────────────
|
|
554
|
+
function parseUnifiedDiff(diff) {
|
|
555
|
+
const lines = diff.split('\n');
|
|
556
|
+
const changed = [];
|
|
557
|
+
const unmapped = [];
|
|
558
|
+
let pendingHeader = null;
|
|
559
|
+
let sawAnyHeader = false;
|
|
560
|
+
const flushPending = (binary) => {
|
|
561
|
+
if (pendingHeader === null)
|
|
562
|
+
return;
|
|
563
|
+
const aPath = pendingHeader.aPath;
|
|
564
|
+
const bPath = pendingHeader.bPath;
|
|
565
|
+
// mode-only diff(仅 diff --git 头,没有 --- / +++ / rename / binary)→ 跳过
|
|
566
|
+
if (!binary && !pendingHeader.sawContent) {
|
|
567
|
+
pendingHeader = null;
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
if (binary) {
|
|
571
|
+
const file = bPath ?? aPath;
|
|
572
|
+
if (file !== undefined && file !== '/dev/null') {
|
|
573
|
+
unmapped.push({ file: stripDiffPrefix(file), reason: 'binary' });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
// 删除:bPath 为 /dev/null
|
|
578
|
+
if (bPath === '/dev/null' && aPath !== undefined && aPath !== '/dev/null') {
|
|
579
|
+
unmapped.push({ file: stripDiffPrefix(aPath), reason: 'deleted-file' });
|
|
580
|
+
}
|
|
581
|
+
else if (aPath === '/dev/null' && bPath !== undefined && bPath !== '/dev/null') {
|
|
582
|
+
// 新增文件
|
|
583
|
+
unmapped.push({ file: stripDiffPrefix(bPath), reason: 'new-file-not-in-graph-yet' });
|
|
584
|
+
}
|
|
585
|
+
else if (bPath !== undefined && bPath !== '/dev/null') {
|
|
586
|
+
const cleanB = stripDiffPrefix(bPath);
|
|
587
|
+
const cleanA = aPath !== undefined ? stripDiffPrefix(aPath) : cleanB;
|
|
588
|
+
const isRename = cleanA !== cleanB;
|
|
589
|
+
changed.push({ file: cleanB, changeKind: isRename ? 'rename' : 'modified' });
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
pendingHeader = null;
|
|
593
|
+
};
|
|
594
|
+
for (const rawLine of lines) {
|
|
595
|
+
const line = rawLine.replace(/\r$/, '');
|
|
596
|
+
if (line.startsWith('diff --git ')) {
|
|
597
|
+
// 上一组结束
|
|
598
|
+
flushPending(false);
|
|
599
|
+
sawAnyHeader = true;
|
|
600
|
+
// 解析 a/<path> b/<path>,可能含引号 + 路径含空格
|
|
601
|
+
// 优先匹配 quoted: diff --git "a/foo bar" "b/foo bar"
|
|
602
|
+
const quotedM = line.match(/^diff --git "(a\/.+?)" "(b\/.+?)"$/);
|
|
603
|
+
const unquotedM = line.match(/^diff --git (a\/[^\s]+) (b\/[^\s]+)$/);
|
|
604
|
+
if (quotedM) {
|
|
605
|
+
pendingHeader = { aPath: quotedM[1], bPath: quotedM[2], sawContent: false };
|
|
606
|
+
}
|
|
607
|
+
else if (unquotedM) {
|
|
608
|
+
pendingHeader = { aPath: unquotedM[1], bPath: unquotedM[2], sawContent: false };
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
// 兜底(rename 等场景 diff --git 头可能没 a/ b/ 前缀)
|
|
612
|
+
pendingHeader = { sawContent: false };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
else if (line.startsWith('--- ')) {
|
|
616
|
+
if (pendingHeader === null)
|
|
617
|
+
pendingHeader = { sawContent: false };
|
|
618
|
+
pendingHeader.aPath = line.slice(4).trim().replace(/^"|"$/g, '');
|
|
619
|
+
pendingHeader.sawContent = true;
|
|
620
|
+
}
|
|
621
|
+
else if (line.startsWith('+++ ')) {
|
|
622
|
+
if (pendingHeader === null)
|
|
623
|
+
pendingHeader = { sawContent: false };
|
|
624
|
+
pendingHeader.bPath = line.slice(4).trim().replace(/^"|"$/g, '');
|
|
625
|
+
pendingHeader.sawContent = true;
|
|
626
|
+
}
|
|
627
|
+
else if (line.startsWith('Binary files') || line.startsWith('GIT binary patch')) {
|
|
628
|
+
flushPending(true);
|
|
629
|
+
}
|
|
630
|
+
else if (line.startsWith('rename to ')) {
|
|
631
|
+
if (pendingHeader === null)
|
|
632
|
+
pendingHeader = { sawContent: false };
|
|
633
|
+
pendingHeader.bPath = 'b/' + line.slice('rename to '.length).trim().replace(/^"|"$/g, '');
|
|
634
|
+
pendingHeader.sawContent = true;
|
|
635
|
+
}
|
|
636
|
+
else if (line.startsWith('rename from ')) {
|
|
637
|
+
if (pendingHeader === null)
|
|
638
|
+
pendingHeader = { sawContent: false };
|
|
639
|
+
pendingHeader.aPath = 'a/' + line.slice('rename from '.length).trim().replace(/^"|"$/g, '');
|
|
640
|
+
pendingHeader.sawContent = true;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
flushPending(false);
|
|
644
|
+
if (!sawAnyHeader && diff.trim().length > 0) {
|
|
645
|
+
return {
|
|
646
|
+
changed: [],
|
|
647
|
+
unmapped: [],
|
|
648
|
+
error: 'unified diff 格式不合法:未找到 `diff --git` 头',
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
return { changed, unmapped };
|
|
652
|
+
}
|
|
653
|
+
function stripDiffPrefix(p) {
|
|
654
|
+
if (p.startsWith('a/'))
|
|
655
|
+
return p.slice(2);
|
|
656
|
+
if (p.startsWith('b/'))
|
|
657
|
+
return p.slice(2);
|
|
658
|
+
return p;
|
|
659
|
+
}
|
|
660
|
+
// ─── git diff baseRef 路径 ──────────────────────────────────
|
|
661
|
+
function runGitDiffNameStatus(baseRef, projectRoot) {
|
|
662
|
+
if (!BASEREF_WHITELIST.test(baseRef) || baseRef.startsWith('-')) {
|
|
663
|
+
return {
|
|
664
|
+
ok: false,
|
|
665
|
+
code: 'invalid-input',
|
|
666
|
+
message: `baseRef 含非法字符或以 - 开头: ${baseRef}`,
|
|
667
|
+
context: { reason: 'baseref-format' },
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
// 1) rev-parse 验证
|
|
671
|
+
const rev = spawnSync('git', ['rev-parse', '--verify', `${baseRef}^{commit}`], {
|
|
672
|
+
cwd: projectRoot,
|
|
673
|
+
shell: false,
|
|
674
|
+
timeout: REVPARSE_TIMEOUT_MS,
|
|
675
|
+
encoding: 'utf-8',
|
|
676
|
+
});
|
|
677
|
+
if (rev.error !== undefined && rev.error.code === 'ETIMEDOUT') {
|
|
678
|
+
return { ok: false, code: 'git-timeout', message: `rev-parse 超时 (${REVPARSE_TIMEOUT_MS} ms)` };
|
|
679
|
+
}
|
|
680
|
+
if (rev.status !== 0) {
|
|
681
|
+
const stderr = (rev.stderr ?? '').toString().slice(0, 200);
|
|
682
|
+
return {
|
|
683
|
+
ok: false,
|
|
684
|
+
code: 'git-spawn-failed',
|
|
685
|
+
message: `rev-parse 失败: ${stderr || 'unknown'}`,
|
|
686
|
+
context: { reason: 'baseref-invalid', stderr },
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
const sha = rev.stdout.trim();
|
|
690
|
+
if (sha.length === 0) {
|
|
691
|
+
return { ok: false, code: 'git-spawn-failed', message: 'rev-parse 返回空 sha' };
|
|
692
|
+
}
|
|
693
|
+
// 2) git diff --name-status
|
|
694
|
+
const diff = spawnSync('git', ['diff', '--name-status', `${sha}...HEAD`], {
|
|
695
|
+
cwd: projectRoot,
|
|
696
|
+
shell: false,
|
|
697
|
+
timeout: GIT_TIMEOUT_MS,
|
|
698
|
+
encoding: 'utf-8',
|
|
699
|
+
});
|
|
700
|
+
if (diff.error !== undefined && diff.error.code === 'ETIMEDOUT') {
|
|
701
|
+
return { ok: false, code: 'git-timeout', message: `git diff 超时 (${GIT_TIMEOUT_MS} ms)` };
|
|
702
|
+
}
|
|
703
|
+
if (diff.status !== 0) {
|
|
704
|
+
const stderr = (diff.stderr ?? '').toString().slice(0, 200);
|
|
705
|
+
return { ok: false, code: 'git-spawn-failed', message: `git diff 失败: ${stderr}` };
|
|
706
|
+
}
|
|
707
|
+
const changed = [];
|
|
708
|
+
const unmapped = [];
|
|
709
|
+
const out = diff.stdout.toString();
|
|
710
|
+
for (const rawLine of out.split('\n')) {
|
|
711
|
+
const line = rawLine.trim();
|
|
712
|
+
if (line.length === 0)
|
|
713
|
+
continue;
|
|
714
|
+
const parts = line.split('\t');
|
|
715
|
+
const status = parts[0] ?? '';
|
|
716
|
+
if (status.startsWith('R')) {
|
|
717
|
+
// R<score>\told\tnew
|
|
718
|
+
const newPath = parts[2];
|
|
719
|
+
if (typeof newPath === 'string' && newPath.length > 0) {
|
|
720
|
+
changed.push({ file: newPath, changeKind: 'rename' });
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
else if (status === 'M') {
|
|
724
|
+
const file = parts[1];
|
|
725
|
+
if (typeof file === 'string')
|
|
726
|
+
changed.push({ file, changeKind: 'modified' });
|
|
727
|
+
}
|
|
728
|
+
else if (status === 'A') {
|
|
729
|
+
const file = parts[1];
|
|
730
|
+
if (typeof file === 'string')
|
|
731
|
+
unmapped.push({ file, reason: 'new-file-not-in-graph-yet' });
|
|
732
|
+
}
|
|
733
|
+
else if (status === 'D') {
|
|
734
|
+
const file = parts[1];
|
|
735
|
+
if (typeof file === 'string')
|
|
736
|
+
unmapped.push({ file, reason: 'deleted-file' });
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
// 其他状态(C / T / U 等)按 modified 处理
|
|
740
|
+
const file = parts[parts.length - 1];
|
|
741
|
+
if (typeof file === 'string')
|
|
742
|
+
changed.push({ file, changeKind: 'modified' });
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return { ok: true, changed, unmapped };
|
|
746
|
+
}
|
|
747
|
+
// ─── file → symbols 索引 ───────────────────────────────────
|
|
748
|
+
function buildFileSymbolIndex(graphData) {
|
|
749
|
+
const index = new Map();
|
|
750
|
+
for (const node of graphData.nodes) {
|
|
751
|
+
const file = moduleFileFromId(node.id);
|
|
752
|
+
const list = index.get(file) ?? [];
|
|
753
|
+
list.push(node.id);
|
|
754
|
+
index.set(file, list);
|
|
755
|
+
}
|
|
756
|
+
return index;
|
|
757
|
+
}
|
|
758
|
+
// ============================================================
|
|
759
|
+
// 注册入口
|
|
760
|
+
// ============================================================
|
|
761
|
+
/**
|
|
762
|
+
* 把 3 个 Agent-Context tool 注册到 MCP server。
|
|
763
|
+
* 在 server.ts 里 registerGraphTools(server) 之后调用。
|
|
764
|
+
*/
|
|
765
|
+
export function registerAgentContextTools(server) {
|
|
766
|
+
server.tool('impact', `查询 symbol 改动的 blast radius — 反向/正向 BFS 遍历调用链,返回受影响 symbols + risk summary。
|
|
767
|
+
|
|
768
|
+
Use this tool when:
|
|
769
|
+
- 改动前评估 caller 影响面
|
|
770
|
+
- 重构前看 transitive 影响(depth=3-5)
|
|
771
|
+
- 决定 PR review 范围
|
|
772
|
+
|
|
773
|
+
Example:
|
|
774
|
+
- Input: { target: "engine.py::Value.add", depth: 2 }
|
|
775
|
+
- Output: { affected, summary, topImpacted: [{ id, score }], nextStepHint }
|
|
776
|
+
|
|
777
|
+
Typical chained usage:
|
|
778
|
+
- 修代码前: detect_changes → impact → context`, ImpactInputSchema, async (args) => handleImpact(args));
|
|
779
|
+
server.tool('context', `查询 symbol 360° 上下文 — definition + callers + callees + imports + topRelevantCallers。
|
|
780
|
+
|
|
781
|
+
Use this tool when:
|
|
782
|
+
- 第一次接触某 symbol,理解位置/调用方/依赖
|
|
783
|
+
- 修改前查 caller 风格保持一致
|
|
784
|
+
- 调试时定位上游引用源头
|
|
785
|
+
|
|
786
|
+
Example:
|
|
787
|
+
- Input: { symbolId: "engine.py::Value" }
|
|
788
|
+
- Output: { definition, callers, callees, imports, topRelevantCallers, nextStepHint }
|
|
789
|
+
|
|
790
|
+
Typical chained usage:
|
|
791
|
+
- impact → context(查 top 受影响节点的上下文)`, ContextInputSchema, async (args) => handleContext(args));
|
|
792
|
+
server.tool('detect_changes', `从 git diff(unified diff 或 baseRef)派生 changedSymbols + BFS 影响链 + risk 总结。
|
|
793
|
+
|
|
794
|
+
Use this tool when:
|
|
795
|
+
- 收到 patch/PR diff 找实际改动 symbol
|
|
796
|
+
- 提交前自检本次改动的上游影响
|
|
797
|
+
- review 大型 PR 按 risk tier 分级
|
|
798
|
+
|
|
799
|
+
Example:
|
|
800
|
+
- Input: { diff: "diff --git a/engine.py..." } 或 { baseRef: "HEAD~3" }
|
|
801
|
+
- Output: { changedSymbols, affectedSymbols, riskSummary, riskTier, topImpacted, nextStepHint }
|
|
802
|
+
|
|
803
|
+
Typical chained usage:
|
|
804
|
+
- detect_changes → impact → context`, DetectChangesInputSchema, async (args) => handleDetectChanges(args));
|
|
805
|
+
}
|
|
806
|
+
//# sourceMappingURL=agent-context-tools.js.map
|