@untangle-code/cli 0.0.0-stage → 0.1.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/LICENSE +661 -0
- package/NOTICE +90 -0
- package/README.md +424 -2
- package/THIRD_PARTY_LICENSES.md +152 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +167 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/command.d.ts +69 -0
- package/dist/cli/command.d.ts.map +1 -0
- package/dist/cli/command.js +82 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/deadline.d.ts +33 -0
- package/dist/cli/deadline.d.ts.map +1 -0
- package/dist/cli/deadline.js +49 -0
- package/dist/cli/deadline.js.map +1 -0
- package/dist/cli/embedder-deadline.d.ts +72 -0
- package/dist/cli/embedder-deadline.d.ts.map +1 -0
- package/dist/cli/embedder-deadline.js +117 -0
- package/dist/cli/embedder-deadline.js.map +1 -0
- package/dist/cli/exit.d.ts +71 -0
- package/dist/cli/exit.d.ts.map +1 -0
- package/dist/cli/exit.js +81 -0
- package/dist/cli/exit.js.map +1 -0
- package/dist/cli/graphs.d.ts +65 -0
- package/dist/cli/graphs.d.ts.map +1 -0
- package/dist/cli/graphs.js +108 -0
- package/dist/cli/graphs.js.map +1 -0
- package/dist/cli/index-freshness.d.ts +13 -0
- package/dist/cli/index-freshness.d.ts.map +1 -0
- package/dist/cli/index-freshness.js +226 -0
- package/dist/cli/index-freshness.js.map +1 -0
- package/dist/cli/index-refresh.d.ts +10 -0
- package/dist/cli/index-refresh.d.ts.map +1 -0
- package/dist/cli/index-refresh.js +76 -0
- package/dist/cli/index-refresh.js.map +1 -0
- package/dist/cli/index-state.d.ts +184 -0
- package/dist/cli/index-state.d.ts.map +1 -0
- package/dist/cli/index-state.js +852 -0
- package/dist/cli/index-state.js.map +1 -0
- package/dist/cli/io.d.ts +29 -0
- package/dist/cli/io.d.ts.map +1 -0
- package/dist/cli/io.js +42 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/language-support.d.ts +77 -0
- package/dist/cli/language-support.d.ts.map +1 -0
- package/dist/cli/language-support.js +152 -0
- package/dist/cli/language-support.js.map +1 -0
- package/dist/cli/renewing-lease.d.ts +26 -0
- package/dist/cli/renewing-lease.d.ts.map +1 -0
- package/dist/cli/renewing-lease.js +102 -0
- package/dist/cli/renewing-lease.js.map +1 -0
- package/dist/cli/search-graph-enrichment.d.ts +16 -0
- package/dist/cli/search-graph-enrichment.d.ts.map +1 -0
- package/dist/cli/search-graph-enrichment.js +428 -0
- package/dist/cli/search-graph-enrichment.js.map +1 -0
- package/dist/cli/system.d.ts +34 -0
- package/dist/cli/system.d.ts.map +1 -0
- package/dist/cli/system.js +89 -0
- package/dist/cli/system.js.map +1 -0
- package/dist/cli/vector-store-policy.d.ts +116 -0
- package/dist/cli/vector-store-policy.d.ts.map +1 -0
- package/dist/cli/vector-store-policy.js +160 -0
- package/dist/cli/vector-store-policy.js.map +1 -0
- package/dist/cli/version.d.ts +3 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +3 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/workspace.d.ts +105 -0
- package/dist/cli/workspace.d.ts.map +1 -0
- package/dist/cli/workspace.js +215 -0
- package/dist/cli/workspace.js.map +1 -0
- package/dist/commands/complexity.d.ts +72 -0
- package/dist/commands/complexity.d.ts.map +1 -0
- package/dist/commands/complexity.js +580 -0
- package/dist/commands/complexity.js.map +1 -0
- package/dist/commands/doctor.d.ts +66 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +764 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/doctor.languages.d.ts +37 -0
- package/dist/commands/doctor.languages.d.ts.map +1 -0
- package/dist/commands/doctor.languages.js +143 -0
- package/dist/commands/doctor.languages.js.map +1 -0
- package/dist/commands/doctor.storage.d.ts +17 -0
- package/dist/commands/doctor.storage.d.ts.map +1 -0
- package/dist/commands/doctor.storage.js +91 -0
- package/dist/commands/doctor.storage.js.map +1 -0
- package/dist/commands/extensions/add.d.ts +10 -0
- package/dist/commands/extensions/add.d.ts.map +1 -0
- package/dist/commands/extensions/add.js +213 -0
- package/dist/commands/extensions/add.js.map +1 -0
- package/dist/commands/extensions/configure.d.ts +5 -0
- package/dist/commands/extensions/configure.d.ts.map +1 -0
- package/dist/commands/extensions/configure.js +58 -0
- package/dist/commands/extensions/configure.js.map +1 -0
- package/dist/commands/extensions/container.d.ts +15 -0
- package/dist/commands/extensions/container.d.ts.map +1 -0
- package/dist/commands/extensions/container.js +135 -0
- package/dist/commands/extensions/container.js.map +1 -0
- package/dist/commands/extensions/context.d.ts +37 -0
- package/dist/commands/extensions/context.d.ts.map +1 -0
- package/dist/commands/extensions/context.js +72 -0
- package/dist/commands/extensions/context.js.map +1 -0
- package/dist/commands/extensions/enable.d.ts +6 -0
- package/dist/commands/extensions/enable.d.ts.map +1 -0
- package/dist/commands/extensions/enable.js +180 -0
- package/dist/commands/extensions/enable.js.map +1 -0
- package/dist/commands/extensions/environment.d.ts +74 -0
- package/dist/commands/extensions/environment.d.ts.map +1 -0
- package/dist/commands/extensions/environment.js +168 -0
- package/dist/commands/extensions/environment.js.map +1 -0
- package/dist/commands/extensions/feature-scan.d.ts +48 -0
- package/dist/commands/extensions/feature-scan.d.ts.map +1 -0
- package/dist/commands/extensions/feature-scan.js +156 -0
- package/dist/commands/extensions/feature-scan.js.map +1 -0
- package/dist/commands/extensions/invoke.d.ts +60 -0
- package/dist/commands/extensions/invoke.d.ts.map +1 -0
- package/dist/commands/extensions/invoke.js +275 -0
- package/dist/commands/extensions/invoke.js.map +1 -0
- package/dist/commands/extensions/list.d.ts +5 -0
- package/dist/commands/extensions/list.d.ts.map +1 -0
- package/dist/commands/extensions/list.js +125 -0
- package/dist/commands/extensions/list.js.map +1 -0
- package/dist/commands/extensions/logs.d.ts +5 -0
- package/dist/commands/extensions/logs.d.ts.map +1 -0
- package/dist/commands/extensions/logs.js +74 -0
- package/dist/commands/extensions/logs.js.map +1 -0
- package/dist/commands/extensions/provision.d.ts +36 -0
- package/dist/commands/extensions/provision.d.ts.map +1 -0
- package/dist/commands/extensions/provision.js +137 -0
- package/dist/commands/extensions/provision.js.map +1 -0
- package/dist/commands/extensions/remove.d.ts +5 -0
- package/dist/commands/extensions/remove.d.ts.map +1 -0
- package/dist/commands/extensions/remove.js +77 -0
- package/dist/commands/extensions/remove.js.map +1 -0
- package/dist/commands/extensions/render.d.ts +16 -0
- package/dist/commands/extensions/render.d.ts.map +1 -0
- package/dist/commands/extensions/render.js +25 -0
- package/dist/commands/extensions/render.js.map +1 -0
- package/dist/commands/extensions/run.d.ts +30 -0
- package/dist/commands/extensions/run.d.ts.map +1 -0
- package/dist/commands/extensions/run.js +292 -0
- package/dist/commands/extensions/run.js.map +1 -0
- package/dist/commands/extensions/secret-store.d.ts +15 -0
- package/dist/commands/extensions/secret-store.d.ts.map +1 -0
- package/dist/commands/extensions/secret-store.js +164 -0
- package/dist/commands/extensions/secret-store.js.map +1 -0
- package/dist/commands/extensions/setup.d.ts +17 -0
- package/dist/commands/extensions/setup.d.ts.map +1 -0
- package/dist/commands/extensions/setup.js +94 -0
- package/dist/commands/extensions/setup.js.map +1 -0
- package/dist/commands/extensions/source.d.ts +47 -0
- package/dist/commands/extensions/source.d.ts.map +1 -0
- package/dist/commands/extensions/source.js +142 -0
- package/dist/commands/extensions/source.js.map +1 -0
- package/dist/commands/extensions/state.d.ts +62 -0
- package/dist/commands/extensions/state.d.ts.map +1 -0
- package/dist/commands/extensions/state.js +177 -0
- package/dist/commands/extensions/state.js.map +1 -0
- package/dist/commands/extensions/status.d.ts +9 -0
- package/dist/commands/extensions/status.d.ts.map +1 -0
- package/dist/commands/extensions/status.js +239 -0
- package/dist/commands/extensions/status.js.map +1 -0
- package/dist/commands/extensions.d.ts +3 -0
- package/dist/commands/extensions.d.ts.map +1 -0
- package/dist/commands/extensions.js +223 -0
- package/dist/commands/extensions.js.map +1 -0
- package/dist/commands/flow/index.d.ts +3 -0
- package/dist/commands/flow/index.d.ts.map +1 -0
- package/dist/commands/flow/index.js +295 -0
- package/dist/commands/flow/index.js.map +1 -0
- package/dist/commands/flow/limits.d.ts +12 -0
- package/dist/commands/flow/limits.d.ts.map +1 -0
- package/dist/commands/flow/limits.js +13 -0
- package/dist/commands/flow/limits.js.map +1 -0
- package/dist/commands/flow/output.d.ts +8 -0
- package/dist/commands/flow/output.d.ts.map +1 -0
- package/dist/commands/flow/output.js +11 -0
- package/dist/commands/flow/output.js.map +1 -0
- package/dist/commands/flow/render.d.ts +51 -0
- package/dist/commands/flow/render.d.ts.map +1 -0
- package/dist/commands/flow/render.js +220 -0
- package/dist/commands/flow/render.js.map +1 -0
- package/dist/commands/flow/select.d.ts +31 -0
- package/dist/commands/flow/select.d.ts.map +1 -0
- package/dist/commands/flow/select.js +62 -0
- package/dist/commands/flow/select.js.map +1 -0
- package/dist/commands/graph/boundaries-input.d.ts +26 -0
- package/dist/commands/graph/boundaries-input.d.ts.map +1 -0
- package/dist/commands/graph/boundaries-input.js +54 -0
- package/dist/commands/graph/boundaries-input.js.map +1 -0
- package/dist/commands/graph/boundaries.d.ts +4 -0
- package/dist/commands/graph/boundaries.d.ts.map +1 -0
- package/dist/commands/graph/boundaries.js +141 -0
- package/dist/commands/graph/boundaries.js.map +1 -0
- package/dist/commands/graph/bounds.d.ts +16 -0
- package/dist/commands/graph/bounds.d.ts.map +1 -0
- package/dist/commands/graph/bounds.js +22 -0
- package/dist/commands/graph/bounds.js.map +1 -0
- package/dist/commands/graph/category-clusters.d.ts +20 -0
- package/dist/commands/graph/category-clusters.d.ts.map +1 -0
- package/dist/commands/graph/category-clusters.js +158 -0
- package/dist/commands/graph/category-clusters.js.map +1 -0
- package/dist/commands/graph/feature-3d.d.ts +22 -0
- package/dist/commands/graph/feature-3d.d.ts.map +1 -0
- package/dist/commands/graph/feature-3d.js +114 -0
- package/dist/commands/graph/feature-3d.js.map +1 -0
- package/dist/commands/graph/feature-clusters.d.ts +17 -0
- package/dist/commands/graph/feature-clusters.d.ts.map +1 -0
- package/dist/commands/graph/feature-clusters.js +94 -0
- package/dist/commands/graph/feature-clusters.js.map +1 -0
- package/dist/commands/graph/feature-html.d.ts +26 -0
- package/dist/commands/graph/feature-html.d.ts.map +1 -0
- package/dist/commands/graph/feature-html.js +314 -0
- package/dist/commands/graph/feature-html.js.map +1 -0
- package/dist/commands/graph/feature-map.d.ts +31 -0
- package/dist/commands/graph/feature-map.d.ts.map +1 -0
- package/dist/commands/graph/feature-map.js +217 -0
- package/dist/commands/graph/feature-map.js.map +1 -0
- package/dist/commands/graph/feature-model.d.ts +55 -0
- package/dist/commands/graph/feature-model.d.ts.map +1 -0
- package/dist/commands/graph/feature-model.js +167 -0
- package/dist/commands/graph/feature-model.js.map +1 -0
- package/dist/commands/graph/feature-untangle-motion.d.ts +33 -0
- package/dist/commands/graph/feature-untangle-motion.d.ts.map +1 -0
- package/dist/commands/graph/feature-untangle-motion.js +155 -0
- package/dist/commands/graph/feature-untangle-motion.js.map +1 -0
- package/dist/commands/graph/index.d.ts +3 -0
- package/dist/commands/graph/index.d.ts.map +1 -0
- package/dist/commands/graph/index.js +414 -0
- package/dist/commands/graph/index.js.map +1 -0
- package/dist/commands/graph/render.d.ts +63 -0
- package/dist/commands/graph/render.d.ts.map +1 -0
- package/dist/commands/graph/render.js +352 -0
- package/dist/commands/graph/render.js.map +1 -0
- package/dist/commands/graph/select.d.ts +34 -0
- package/dist/commands/graph/select.d.ts.map +1 -0
- package/dist/commands/graph/select.js +55 -0
- package/dist/commands/graph/select.js.map +1 -0
- package/dist/commands/index/index.d.ts +6 -0
- package/dist/commands/index/index.d.ts.map +1 -0
- package/dist/commands/index/index.js +461 -0
- package/dist/commands/index/index.js.map +1 -0
- package/dist/commands/index/render.d.ts +53 -0
- package/dist/commands/index/render.d.ts.map +1 -0
- package/dist/commands/index/render.js +205 -0
- package/dist/commands/index/render.js.map +1 -0
- package/dist/commands/index/target.d.ts +34 -0
- package/dist/commands/index/target.d.ts.map +1 -0
- package/dist/commands/index/target.js +97 -0
- package/dist/commands/index/target.js.map +1 -0
- package/dist/commands/index-watch.d.ts +30 -0
- package/dist/commands/index-watch.d.ts.map +1 -0
- package/dist/commands/index-watch.js +138 -0
- package/dist/commands/index-watch.js.map +1 -0
- package/dist/commands/init/command.d.ts +25 -0
- package/dist/commands/init/command.d.ts.map +1 -0
- package/dist/commands/init/command.js +198 -0
- package/dist/commands/init/command.js.map +1 -0
- package/dist/commands/init/config-draft.d.ts +48 -0
- package/dist/commands/init/config-draft.d.ts.map +1 -0
- package/dist/commands/init/config-draft.js +201 -0
- package/dist/commands/init/config-draft.js.map +1 -0
- package/dist/commands/init/diff.d.ts +33 -0
- package/dist/commands/init/diff.d.ts.map +1 -0
- package/dist/commands/init/diff.js +109 -0
- package/dist/commands/init/diff.js.map +1 -0
- package/dist/commands/init/http-probe.d.ts +26 -0
- package/dist/commands/init/http-probe.d.ts.map +1 -0
- package/dist/commands/init/http-probe.js +144 -0
- package/dist/commands/init/http-probe.js.map +1 -0
- package/dist/commands/init/ignore-rules.d.ts +70 -0
- package/dist/commands/init/ignore-rules.d.ts.map +1 -0
- package/dist/commands/init/ignore-rules.js +146 -0
- package/dist/commands/init/ignore-rules.js.map +1 -0
- package/dist/commands/init/index.d.ts +33 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/init/index.js +32 -0
- package/dist/commands/init/index.js.map +1 -0
- package/dist/commands/init/integrations-apply.d.ts +50 -0
- package/dist/commands/init/integrations-apply.d.ts.map +1 -0
- package/dist/commands/init/integrations-apply.js +452 -0
- package/dist/commands/init/integrations-apply.js.map +1 -0
- package/dist/commands/init/integrations-plan.d.ts +68 -0
- package/dist/commands/init/integrations-plan.d.ts.map +1 -0
- package/dist/commands/init/integrations-plan.js +515 -0
- package/dist/commands/init/integrations-plan.js.map +1 -0
- package/dist/commands/init/integrations.d.ts +5 -0
- package/dist/commands/init/integrations.d.ts.map +1 -0
- package/dist/commands/init/integrations.js +4 -0
- package/dist/commands/init/integrations.js.map +1 -0
- package/dist/commands/init/languages.d.ts +55 -0
- package/dist/commands/init/languages.d.ts.map +1 -0
- package/dist/commands/init/languages.js +245 -0
- package/dist/commands/init/languages.js.map +1 -0
- package/dist/commands/init/product-context.d.ts +63 -0
- package/dist/commands/init/product-context.d.ts.map +1 -0
- package/dist/commands/init/product-context.js +390 -0
- package/dist/commands/init/product-context.js.map +1 -0
- package/dist/commands/init/render.d.ts +38 -0
- package/dist/commands/init/render.d.ts.map +1 -0
- package/dist/commands/init/render.js +501 -0
- package/dist/commands/init/render.js.map +1 -0
- package/dist/commands/init/report.d.ts +24 -0
- package/dist/commands/init/report.d.ts.map +1 -0
- package/dist/commands/init/report.js +163 -0
- package/dist/commands/init/report.js.map +1 -0
- package/dist/commands/init/run.d.ts +71 -0
- package/dist/commands/init/run.d.ts.map +1 -0
- package/dist/commands/init/run.js +253 -0
- package/dist/commands/init/run.js.map +1 -0
- package/dist/commands/init/services.d.ts +82 -0
- package/dist/commands/init/services.d.ts.map +1 -0
- package/dist/commands/init/services.js +209 -0
- package/dist/commands/init/services.js.map +1 -0
- package/dist/commands/init/storage.d.ts +8 -0
- package/dist/commands/init/storage.d.ts.map +1 -0
- package/dist/commands/init/storage.js +102 -0
- package/dist/commands/init/storage.js.map +1 -0
- package/dist/commands/init/toml.d.ts +65 -0
- package/dist/commands/init/toml.d.ts.map +1 -0
- package/dist/commands/init/toml.js +159 -0
- package/dist/commands/init/toml.js.map +1 -0
- package/dist/commands/init/topology.d.ts +54 -0
- package/dist/commands/init/topology.d.ts.map +1 -0
- package/dist/commands/init/topology.js +146 -0
- package/dist/commands/init/topology.js.map +1 -0
- package/dist/commands/init/types.d.ts +334 -0
- package/dist/commands/init/types.d.ts.map +1 -0
- package/dist/commands/init/types.js +31 -0
- package/dist/commands/init/types.js.map +1 -0
- package/dist/commands/init/wizard-terminal.d.ts +36 -0
- package/dist/commands/init/wizard-terminal.d.ts.map +1 -0
- package/dist/commands/init/wizard-terminal.js +163 -0
- package/dist/commands/init/wizard-terminal.js.map +1 -0
- package/dist/commands/init/wizard.d.ts +25 -0
- package/dist/commands/init/wizard.d.ts.map +1 -0
- package/dist/commands/init/wizard.js +358 -0
- package/dist/commands/init/wizard.js.map +1 -0
- package/dist/commands/mcp.d.ts +4 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +111 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/product-test-runner.d.ts +4 -0
- package/dist/commands/product-test-runner.d.ts.map +1 -0
- package/dist/commands/product-test-runner.js +85 -0
- package/dist/commands/product-test-runner.js.map +1 -0
- package/dist/commands/product.d.ts +16 -0
- package/dist/commands/product.d.ts.map +1 -0
- package/dist/commands/product.js +262 -0
- package/dist/commands/product.js.map +1 -0
- package/dist/commands/query.d.ts +114 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +783 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/scan.d.ts +10 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +302 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/sdd.d.ts +24 -0
- package/dist/commands/sdd.d.ts.map +1 -0
- package/dist/commands/sdd.js +195 -0
- package/dist/commands/sdd.js.map +1 -0
- package/dist/commands/unavailable.d.ts +40 -0
- package/dist/commands/unavailable.d.ts.map +1 -0
- package/dist/commands/unavailable.js +73 -0
- package/dist/commands/unavailable.js.map +1 -0
- package/dist/commands/watch/analyze.d.ts +69 -0
- package/dist/commands/watch/analyze.d.ts.map +1 -0
- package/dist/commands/watch/analyze.js +402 -0
- package/dist/commands/watch/analyze.js.map +1 -0
- package/dist/commands/watch/cli.d.ts +8 -0
- package/dist/commands/watch/cli.d.ts.map +1 -0
- package/dist/commands/watch/cli.js +97 -0
- package/dist/commands/watch/cli.js.map +1 -0
- package/dist/commands/watch/delta.d.ts +46 -0
- package/dist/commands/watch/delta.d.ts.map +1 -0
- package/dist/commands/watch/delta.js +170 -0
- package/dist/commands/watch/delta.js.map +1 -0
- package/dist/commands/watch/events.d.ts +214 -0
- package/dist/commands/watch/events.d.ts.map +1 -0
- package/dist/commands/watch/events.js +13 -0
- package/dist/commands/watch/events.js.map +1 -0
- package/dist/commands/watch/index.d.ts +19 -0
- package/dist/commands/watch/index.d.ts.map +1 -0
- package/dist/commands/watch/index.js +15 -0
- package/dist/commands/watch/index.js.map +1 -0
- package/dist/commands/watch/options.d.ts +43 -0
- package/dist/commands/watch/options.d.ts.map +1 -0
- package/dist/commands/watch/options.js +193 -0
- package/dist/commands/watch/options.js.map +1 -0
- package/dist/commands/watch/render.d.ts +26 -0
- package/dist/commands/watch/render.d.ts.map +1 -0
- package/dist/commands/watch/render.js +175 -0
- package/dist/commands/watch/render.js.map +1 -0
- package/dist/commands/watch/run.d.ts +14 -0
- package/dist/commands/watch/run.d.ts.map +1 -0
- package/dist/commands/watch/run.js +460 -0
- package/dist/commands/watch/run.js.map +1 -0
- package/dist/commands/watch/runtime.d.ts +67 -0
- package/dist/commands/watch/runtime.d.ts.map +1 -0
- package/dist/commands/watch/runtime.js +149 -0
- package/dist/commands/watch/runtime.js.map +1 -0
- package/dist/commands/watch-command.d.ts +3 -0
- package/dist/commands/watch-command.d.ts.map +1 -0
- package/dist/commands/watch-command.js +273 -0
- package/dist/commands/watch-command.js.map +1 -0
- package/dist/entry-point.d.ts +11 -0
- package/dist/entry-point.d.ts.map +1 -0
- package/dist/entry-point.js +65 -0
- package/dist/entry-point.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +245 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/boundaries-schema.d.ts +262 -0
- package/dist/mcp/boundaries-schema.d.ts.map +1 -0
- package/dist/mcp/boundaries-schema.js +183 -0
- package/dist/mcp/boundaries-schema.js.map +1 -0
- package/dist/mcp/default-runtime.d.ts +16 -0
- package/dist/mcp/default-runtime.d.ts.map +1 -0
- package/dist/mcp/default-runtime.js +718 -0
- package/dist/mcp/default-runtime.js.map +1 -0
- package/dist/mcp/envelope.d.ts +13 -0
- package/dist/mcp/envelope.d.ts.map +1 -0
- package/dist/mcp/envelope.js +29 -0
- package/dist/mcp/envelope.js.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/output-schemas.d.ts +5928 -0
- package/dist/mcp/output-schemas.d.ts.map +1 -0
- package/dist/mcp/output-schemas.js +2814 -0
- package/dist/mcp/output-schemas.js.map +1 -0
- package/dist/mcp/path-sandbox.d.ts +35 -0
- package/dist/mcp/path-sandbox.d.ts.map +1 -0
- package/dist/mcp/path-sandbox.js +128 -0
- package/dist/mcp/path-sandbox.js.map +1 -0
- package/dist/mcp/server.d.ts +155 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +257 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/stdio.d.ts +20 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +71 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/mcp/tools.d.ts +355 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +319 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/types.d.ts +15 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +45 -0
- package/dist/mcp/types.js.map +1 -0
- package/package.json +99 -3
- package/src/cli/args.ts +231 -0
- package/src/cli/command.ts +146 -0
- package/src/cli/deadline.ts +56 -0
- package/src/cli/embedder-deadline.ts +187 -0
- package/src/cli/exit.ts +94 -0
- package/src/cli/graphs.ts +191 -0
- package/src/cli/index-freshness.ts +303 -0
- package/src/cli/index-refresh.ts +125 -0
- package/src/cli/index-state.ts +1217 -0
- package/src/cli/io.ts +56 -0
- package/src/cli/language-support.ts +203 -0
- package/src/cli/renewing-lease.ts +121 -0
- package/src/cli/search-graph-enrichment.ts +639 -0
- package/src/cli/system.ts +94 -0
- package/src/cli/vector-store-policy.ts +213 -0
- package/src/cli/version.ts +2 -0
- package/src/cli/workspace.ts +324 -0
- package/src/commands/complexity.ts +776 -0
- package/src/commands/doctor.languages.ts +187 -0
- package/src/commands/doctor.storage.ts +124 -0
- package/src/commands/doctor.ts +946 -0
- package/src/commands/extensions/add.ts +312 -0
- package/src/commands/extensions/configure.ts +82 -0
- package/src/commands/extensions/container.ts +209 -0
- package/src/commands/extensions/context.ts +109 -0
- package/src/commands/extensions/enable.ts +237 -0
- package/src/commands/extensions/environment.ts +218 -0
- package/src/commands/extensions/feature-scan.ts +232 -0
- package/src/commands/extensions/invoke.ts +368 -0
- package/src/commands/extensions/list.ts +158 -0
- package/src/commands/extensions/logs.ts +104 -0
- package/src/commands/extensions/provision.ts +206 -0
- package/src/commands/extensions/remove.ts +110 -0
- package/src/commands/extensions/render.ts +32 -0
- package/src/commands/extensions/run.ts +386 -0
- package/src/commands/extensions/secret-store.ts +223 -0
- package/src/commands/extensions/setup.ts +140 -0
- package/src/commands/extensions/source.ts +189 -0
- package/src/commands/extensions/state.ts +252 -0
- package/src/commands/extensions/status.ts +320 -0
- package/src/commands/extensions.ts +280 -0
- package/src/commands/flow/index.ts +402 -0
- package/src/commands/flow/limits.ts +14 -0
- package/src/commands/flow/output.ts +16 -0
- package/src/commands/flow/render.ts +318 -0
- package/src/commands/flow/select.ts +101 -0
- package/src/commands/graph/boundaries-input.ts +63 -0
- package/src/commands/graph/boundaries.ts +182 -0
- package/src/commands/graph/bounds.ts +25 -0
- package/src/commands/graph/category-clusters.ts +194 -0
- package/src/commands/graph/feature-3d.ts +141 -0
- package/src/commands/graph/feature-clusters.ts +125 -0
- package/src/commands/graph/feature-html.ts +336 -0
- package/src/commands/graph/feature-map.ts +270 -0
- package/src/commands/graph/feature-model.ts +234 -0
- package/src/commands/graph/feature-untangle-motion.ts +192 -0
- package/src/commands/graph/index.ts +562 -0
- package/src/commands/graph/render.ts +503 -0
- package/src/commands/graph/select.ts +77 -0
- package/src/commands/index/index.ts +595 -0
- package/src/commands/index/render.ts +325 -0
- package/src/commands/index/target.ts +136 -0
- package/src/commands/index-watch.ts +206 -0
- package/src/commands/init/command.ts +238 -0
- package/src/commands/init/config-draft.ts +235 -0
- package/src/commands/init/diff.ts +117 -0
- package/src/commands/init/http-probe.ts +150 -0
- package/src/commands/init/ignore-rules.ts +170 -0
- package/src/commands/init/index.ts +63 -0
- package/src/commands/init/integrations-apply.ts +618 -0
- package/src/commands/init/integrations-plan.ts +634 -0
- package/src/commands/init/integrations.ts +8 -0
- package/src/commands/init/languages.ts +320 -0
- package/src/commands/init/product-context.ts +576 -0
- package/src/commands/init/render.ts +598 -0
- package/src/commands/init/report.ts +204 -0
- package/src/commands/init/run.ts +349 -0
- package/src/commands/init/services.ts +271 -0
- package/src/commands/init/storage.ts +136 -0
- package/src/commands/init/toml.ts +174 -0
- package/src/commands/init/topology.ts +192 -0
- package/src/commands/init/types.ts +366 -0
- package/src/commands/init/wizard-terminal.ts +206 -0
- package/src/commands/init/wizard.ts +450 -0
- package/src/commands/mcp.ts +123 -0
- package/src/commands/product-test-runner.ts +80 -0
- package/src/commands/product.ts +331 -0
- package/src/commands/query.ts +1032 -0
- package/src/commands/scan.ts +360 -0
- package/src/commands/sdd.ts +243 -0
- package/src/commands/unavailable.ts +92 -0
- package/src/commands/watch/README.md +160 -0
- package/src/commands/watch/analyze.ts +600 -0
- package/src/commands/watch/cli.ts +108 -0
- package/src/commands/watch/delta.ts +186 -0
- package/src/commands/watch/events.ts +235 -0
- package/src/commands/watch/index.ts +53 -0
- package/src/commands/watch/options.ts +234 -0
- package/src/commands/watch/render.ts +240 -0
- package/src/commands/watch/run.ts +553 -0
- package/src/commands/watch/runtime.ts +167 -0
- package/src/commands/watch-command.ts +294 -0
- package/src/entry-point.ts +67 -0
- package/src/index.ts +291 -0
- package/src/mcp/boundaries-schema.ts +193 -0
- package/src/mcp/default-runtime.ts +1034 -0
- package/src/mcp/envelope.ts +57 -0
- package/src/mcp/index.ts +28 -0
- package/src/mcp/output-schemas.ts +3071 -0
- package/src/mcp/path-sandbox.ts +156 -0
- package/src/mcp/server.ts +358 -0
- package/src/mcp/stdio.ts +92 -0
- package/src/mcp/tools.ts +563 -0
- package/src/mcp/types.ts +66 -0
|
@@ -0,0 +1,1034 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
compareCodepoints,
|
|
5
|
+
isUntangleError,
|
|
6
|
+
type SearchJourneyAbandonReasonCode,
|
|
7
|
+
type SearchJourneyExecutionContextInputV1,
|
|
8
|
+
type SearchJourneyTargetV1,
|
|
9
|
+
type SearchResultSetV1,
|
|
10
|
+
type ToolResponseEnvelopeV1,
|
|
11
|
+
type ToolWarningV1,
|
|
12
|
+
} from "@untangle-code/domain";
|
|
13
|
+
import { MAX_MAX_EDGES, MAX_MAX_NODES } from "@untangle-code/graph-explorer";
|
|
14
|
+
import { SearchJourneyService } from "@untangle-code/search";
|
|
15
|
+
import { openLocalStorage } from "@untangle-code/storage-local";
|
|
16
|
+
import { createSymbolGraphIndex } from "@untangle-code/symbol-graph";
|
|
17
|
+
|
|
18
|
+
import type { FlagValue, ParsedArgs } from "../cli/args.js";
|
|
19
|
+
import type { Command, CommandContext } from "../cli/command.js";
|
|
20
|
+
import { CliError, EXIT } from "../cli/exit.js";
|
|
21
|
+
import { loadGraphs } from "../cli/graphs.js";
|
|
22
|
+
import { stateRootOf } from "../cli/index-state.js";
|
|
23
|
+
import { BufferIo } from "../cli/io.js";
|
|
24
|
+
import { systemClock, systemRandom } from "../cli/system.js";
|
|
25
|
+
import { CLI_VERSION } from "../cli/version.js";
|
|
26
|
+
import { loadWorkspace } from "../cli/workspace.js";
|
|
27
|
+
import { complexityCommand } from "../commands/complexity.js";
|
|
28
|
+
import { doctorCommand } from "../commands/doctor.js";
|
|
29
|
+
import { flowCommand } from "../commands/flow/index.js";
|
|
30
|
+
import {
|
|
31
|
+
MAX_FLOW_DEPTH,
|
|
32
|
+
MAX_FLOW_EDGES,
|
|
33
|
+
MAX_FLOW_NODES,
|
|
34
|
+
MAX_FLOW_RESULT_LIMIT,
|
|
35
|
+
MAX_GRAPH_QUERY_DEPTH,
|
|
36
|
+
MAX_GRAPH_QUERY_EDGES,
|
|
37
|
+
MAX_GRAPH_QUERY_NODES,
|
|
38
|
+
} from "../commands/flow/limits.js";
|
|
39
|
+
import { selectSymbolNode } from "../commands/flow/select.js";
|
|
40
|
+
import { runBoundaries } from "../commands/graph/boundaries.js";
|
|
41
|
+
import { graphCommand } from "../commands/graph/index.js";
|
|
42
|
+
import { productCommand } from "../commands/product.js";
|
|
43
|
+
import { queryCommand } from "../commands/query.js";
|
|
44
|
+
|
|
45
|
+
import { mcpFailure, mcpSuccess, unavailableEnvelope } from "./envelope.js";
|
|
46
|
+
import { UNTANGLE_MCP_SUCCESS_DATA_SCHEMAS } from "./output-schemas.js";
|
|
47
|
+
import type { McpInvocationContext, UntangleMcpRuntime, UntangleMcpToolName } from "./types.js";
|
|
48
|
+
|
|
49
|
+
const SOURCE_URL = "https://github.com/lboel/untangle";
|
|
50
|
+
|
|
51
|
+
export const DEFAULT_MCP_AVAILABLE_TOOLS = Object.freeze([
|
|
52
|
+
"untangle_health",
|
|
53
|
+
"untangle_projects",
|
|
54
|
+
"untangle_search",
|
|
55
|
+
"untangle_search_session",
|
|
56
|
+
"untangle_context_list",
|
|
57
|
+
"untangle_graph_status",
|
|
58
|
+
"untangle_graph_query",
|
|
59
|
+
"untangle_graph_stats",
|
|
60
|
+
"untangle_graph_cycles",
|
|
61
|
+
"untangle_graph_visualize",
|
|
62
|
+
"untangle_symbols",
|
|
63
|
+
"untangle_symbol",
|
|
64
|
+
"untangle_flow",
|
|
65
|
+
"untangle_impact",
|
|
66
|
+
"untangle_complexity",
|
|
67
|
+
"untangle_hotspots",
|
|
68
|
+
"untangle_about",
|
|
69
|
+
"untangle_product",
|
|
70
|
+
"untangle_boundaries",
|
|
71
|
+
] as const satisfies readonly UntangleMcpToolName[]);
|
|
72
|
+
|
|
73
|
+
type DefaultMcpAvailableTool = (typeof DEFAULT_MCP_AVAILABLE_TOOLS)[number];
|
|
74
|
+
|
|
75
|
+
const DEFAULT_MCP_AVAILABLE_TOOL_SET: ReadonlySet<UntangleMcpToolName> = new Set(
|
|
76
|
+
DEFAULT_MCP_AVAILABLE_TOOLS,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
function isDefaultAvailableTool(
|
|
80
|
+
operation: UntangleMcpToolName,
|
|
81
|
+
): operation is DefaultMcpAvailableTool {
|
|
82
|
+
return DEFAULT_MCP_AVAILABLE_TOOL_SET.has(operation);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Default local runtime. It never spawns an external process. */
|
|
86
|
+
export class DefaultUntangleMcpRuntime implements UntangleMcpRuntime {
|
|
87
|
+
async invoke(
|
|
88
|
+
operation: UntangleMcpToolName,
|
|
89
|
+
input: Readonly<Record<string, unknown>>,
|
|
90
|
+
context: McpInvocationContext,
|
|
91
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
92
|
+
if (context.signal.aborted) {
|
|
93
|
+
return mcpFailure(operation, "CANCELLED", "The MCP operation was cancelled.", false);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const scopeFailure = validateRequestedWorkspace(operation, input, context);
|
|
98
|
+
if (scopeFailure !== null) return scopeFailure;
|
|
99
|
+
if (!isDefaultAvailableTool(operation)) {
|
|
100
|
+
if (operation === "untangle_blueprint" && input["apply"] === true) {
|
|
101
|
+
const targetDirectory = path.resolve(
|
|
102
|
+
stringInput(input, "root") ?? context.cwd,
|
|
103
|
+
String(input["targetDir"]),
|
|
104
|
+
);
|
|
105
|
+
return mcpFailure(
|
|
106
|
+
operation,
|
|
107
|
+
"FEATURE_UNAVAILABLE",
|
|
108
|
+
`Blueprint apply is unavailable for target directory "${targetDirectory}"; no filesystem changes were made.`,
|
|
109
|
+
false,
|
|
110
|
+
{
|
|
111
|
+
...(typeof input["workspaceId"] === "string"
|
|
112
|
+
? { workspaceId: input["workspaceId"] }
|
|
113
|
+
: {}),
|
|
114
|
+
details: {
|
|
115
|
+
missingCapability: unavailableReason(operation),
|
|
116
|
+
targetDirectory,
|
|
117
|
+
mutationPerformed: false,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return unavailableEnvelope(operation, unavailableReason(operation));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let result: ToolResponseEnvelopeV1<unknown>;
|
|
126
|
+
switch (operation) {
|
|
127
|
+
case "untangle_boundaries": {
|
|
128
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
129
|
+
copyString(input, "root", flags, "root");
|
|
130
|
+
copyString(input, "path", flags, "path");
|
|
131
|
+
copyString(input, "servicesFile", flags, "services");
|
|
132
|
+
copyNumber(input, "maxRelations", flags, "max-relations");
|
|
133
|
+
result = await invokeJsonCommand(
|
|
134
|
+
operation,
|
|
135
|
+
{ spec: graphCommand.spec, run: runBoundaries },
|
|
136
|
+
{ positionals: [], flags },
|
|
137
|
+
context,
|
|
138
|
+
);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case "untangle_about":
|
|
142
|
+
result = about(operation, context.env);
|
|
143
|
+
break;
|
|
144
|
+
case "untangle_projects":
|
|
145
|
+
result = projects(operation, input, context);
|
|
146
|
+
break;
|
|
147
|
+
case "untangle_context_list":
|
|
148
|
+
result = contextList(operation, input, context);
|
|
149
|
+
break;
|
|
150
|
+
case "untangle_health":
|
|
151
|
+
result = await this.health(operation, input, context);
|
|
152
|
+
break;
|
|
153
|
+
case "untangle_search":
|
|
154
|
+
result = await this.search(operation, input, context);
|
|
155
|
+
break;
|
|
156
|
+
case "untangle_search_session":
|
|
157
|
+
result = await this.searchSession(operation, input, context);
|
|
158
|
+
break;
|
|
159
|
+
case "untangle_complexity":
|
|
160
|
+
case "untangle_hotspots":
|
|
161
|
+
result = await this.complexity(operation, input, context);
|
|
162
|
+
break;
|
|
163
|
+
case "untangle_product":
|
|
164
|
+
result = await this.product(operation, input, context);
|
|
165
|
+
break;
|
|
166
|
+
case "untangle_graph_status":
|
|
167
|
+
case "untangle_graph_query":
|
|
168
|
+
case "untangle_graph_stats":
|
|
169
|
+
case "untangle_graph_cycles":
|
|
170
|
+
case "untangle_graph_visualize":
|
|
171
|
+
result = await this.graph(operation, input, context);
|
|
172
|
+
break;
|
|
173
|
+
case "untangle_symbols":
|
|
174
|
+
case "untangle_symbol":
|
|
175
|
+
result = await this.symbols(operation, input, context);
|
|
176
|
+
break;
|
|
177
|
+
case "untangle_flow":
|
|
178
|
+
case "untangle_impact":
|
|
179
|
+
result = await this.flow(operation, input, context);
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
return assertNever(operation);
|
|
183
|
+
}
|
|
184
|
+
if (context.signal.aborted) return cancelledEnvelope(operation);
|
|
185
|
+
return result;
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (context.signal.aborted) return cancelledEnvelope(operation);
|
|
188
|
+
return failureFromThrown(operation, error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private async health(
|
|
193
|
+
operation: UntangleMcpToolName,
|
|
194
|
+
input: Readonly<Record<string, unknown>>,
|
|
195
|
+
context: McpInvocationContext,
|
|
196
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
197
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
198
|
+
copyString(input, "root", flags, "root");
|
|
199
|
+
copyBoolean(input, "skipEmbeddings", flags, "skip-embeddings");
|
|
200
|
+
copyNumber(input, "timeoutMs", flags, "timeout");
|
|
201
|
+
return invokeJsonCommand(operation, doctorCommand, { positionals: [], flags }, context, [
|
|
202
|
+
EXIT.ok,
|
|
203
|
+
EXIT.environment,
|
|
204
|
+
]);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private async search(
|
|
208
|
+
operation: UntangleMcpToolName,
|
|
209
|
+
input: Readonly<Record<string, unknown>>,
|
|
210
|
+
context: McpInvocationContext,
|
|
211
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
212
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
213
|
+
copyString(input, "root", flags, "root");
|
|
214
|
+
copyString(input, "workspaceId", flags, "workspace");
|
|
215
|
+
copyNumber(input, "limit", flags, "limit");
|
|
216
|
+
copyString(input, "mode", flags, "mode");
|
|
217
|
+
copyString(input, "abstention", flags, "abstention");
|
|
218
|
+
copyBoolean(input, "requireFresh", flags, "require-fresh");
|
|
219
|
+
copyStrings(input, "repositories", flags, "repo");
|
|
220
|
+
copyStrings(input, "refs", flags, "ref");
|
|
221
|
+
copyStrings(input, "pathGlob", flags, "path");
|
|
222
|
+
copyStrings(input, "languages", flags, "lang");
|
|
223
|
+
copyStrings(input, "symbolNames", flags, "symbol");
|
|
224
|
+
copyBoolean(input, "includeContent", flags, "content");
|
|
225
|
+
copyBoolean(input, "includeContext", flags, "context");
|
|
226
|
+
copyBoolean(input, "includeLinked", flags, "linked");
|
|
227
|
+
copyBoolean(input, "explain", flags, "explain");
|
|
228
|
+
const result = await invokeJsonCommand(
|
|
229
|
+
operation,
|
|
230
|
+
queryCommand,
|
|
231
|
+
{ positionals: [String(input["query"])], flags },
|
|
232
|
+
context,
|
|
233
|
+
);
|
|
234
|
+
const link = searchSessionLink(input);
|
|
235
|
+
if (link === null) return result;
|
|
236
|
+
const searchData = result.ok ? result.data : result.error?.details?.["data"];
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
const service = await openSearchJourneyService(input, context);
|
|
240
|
+
const parsed = UNTANGLE_MCP_SUCCESS_DATA_SCHEMAS.untangle_search.safeParse(searchData);
|
|
241
|
+
if (parsed.success) {
|
|
242
|
+
const recorded = await service.recordSearch(
|
|
243
|
+
link.id,
|
|
244
|
+
parsed.data as unknown as SearchResultSetV1,
|
|
245
|
+
link.step === undefined ? {} : { step: link.step },
|
|
246
|
+
{ signal: context.signal },
|
|
247
|
+
);
|
|
248
|
+
return withSearchObservation(result, parsed.data, {
|
|
249
|
+
sessionId: link.id,
|
|
250
|
+
attemptId: recorded.attempt.attemptId,
|
|
251
|
+
status: "recorded",
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (result.ok) return result;
|
|
255
|
+
await service.recordFailedSearch(
|
|
256
|
+
link.id,
|
|
257
|
+
{
|
|
258
|
+
query: String(input["query"]),
|
|
259
|
+
failureCode: result.error?.code ?? "OPERATION_FAILED",
|
|
260
|
+
failureReason: result.error?.message ?? "The search did not produce a success result.",
|
|
261
|
+
},
|
|
262
|
+
link.step === undefined ? {} : { step: link.step },
|
|
263
|
+
{ signal: context.signal },
|
|
264
|
+
);
|
|
265
|
+
return result;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
const warning: ToolWarningV1 = {
|
|
268
|
+
code: "SEARCH_SESSION_RECORDING_FAILED",
|
|
269
|
+
message:
|
|
270
|
+
searchData !== undefined
|
|
271
|
+
? "The search result is valid, but its optional Dynamic Product Complexity observation could not be recorded."
|
|
272
|
+
: "The search failed, and its optional Dynamic Product Complexity failure observation could not be recorded.",
|
|
273
|
+
details: {
|
|
274
|
+
sessionId: link.id,
|
|
275
|
+
reasonCode: isUntangleError(error)
|
|
276
|
+
? error.code
|
|
277
|
+
: error instanceof Error
|
|
278
|
+
? error.name
|
|
279
|
+
: "UNKNOWN_ERROR",
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
if (!isRecord(searchData)) {
|
|
283
|
+
return { ...result, warnings: [...result.warnings, warning] };
|
|
284
|
+
}
|
|
285
|
+
return withSearchObservation(
|
|
286
|
+
{ ...result, warnings: [...result.warnings, warning] },
|
|
287
|
+
searchData,
|
|
288
|
+
{ sessionId: link.id, status: "not_recorded", warningCode: warning.code },
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private async searchSession(
|
|
294
|
+
operation: UntangleMcpToolName,
|
|
295
|
+
input: Readonly<Record<string, unknown>>,
|
|
296
|
+
context: McpInvocationContext,
|
|
297
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
298
|
+
const action = String(input["action"]);
|
|
299
|
+
const service = await openSearchJourneyService(input, context);
|
|
300
|
+
const callOptions = { signal: context.signal };
|
|
301
|
+
switch (action) {
|
|
302
|
+
case "start": {
|
|
303
|
+
const session = await service.start(
|
|
304
|
+
{
|
|
305
|
+
goal: String(input["goal"]),
|
|
306
|
+
...(typeof input["featureId"] === "string" ? { featureId: input["featureId"] } : {}),
|
|
307
|
+
...(typeof input["retainText"] === "boolean"
|
|
308
|
+
? { retainText: input["retainText"] }
|
|
309
|
+
: {}),
|
|
310
|
+
...(isRecord(input["executionContext"])
|
|
311
|
+
? {
|
|
312
|
+
executionContext: input[
|
|
313
|
+
"executionContext"
|
|
314
|
+
] as unknown as SearchJourneyExecutionContextInputV1,
|
|
315
|
+
}
|
|
316
|
+
: {}),
|
|
317
|
+
},
|
|
318
|
+
callOptions,
|
|
319
|
+
);
|
|
320
|
+
return mcpSuccess(operation, { action, session }, { workspaceId: session.workspaceId });
|
|
321
|
+
}
|
|
322
|
+
case "get": {
|
|
323
|
+
const session = await service.get(String(input["sessionId"]), callOptions);
|
|
324
|
+
return mcpSuccess(operation, { action, session }, { workspaceId: session.workspaceId });
|
|
325
|
+
}
|
|
326
|
+
case "observe": {
|
|
327
|
+
const session = await service.observeNavigation(
|
|
328
|
+
String(input["sessionId"]),
|
|
329
|
+
{
|
|
330
|
+
kind: input["kind"] as "open-file" | "open-symbol" | "graph-query" | "other-tool",
|
|
331
|
+
...(typeof input["toolName"] === "string" ? { toolName: input["toolName"] } : {}),
|
|
332
|
+
...(isRecord(input["target"]) ? { target: searchJourneyTarget(input["target"]) } : {}),
|
|
333
|
+
},
|
|
334
|
+
callOptions,
|
|
335
|
+
);
|
|
336
|
+
return mcpSuccess(operation, { action, session }, { workspaceId: session.workspaceId });
|
|
337
|
+
}
|
|
338
|
+
case "complete": {
|
|
339
|
+
const session = await service.complete(
|
|
340
|
+
String(input["sessionId"]),
|
|
341
|
+
{
|
|
342
|
+
target: searchJourneyTarget(input["target"] as Readonly<Record<string, unknown>>),
|
|
343
|
+
...(typeof input["acceptedAttemptId"] === "string"
|
|
344
|
+
? { acceptedAttemptId: input["acceptedAttemptId"] }
|
|
345
|
+
: {}),
|
|
346
|
+
},
|
|
347
|
+
callOptions,
|
|
348
|
+
);
|
|
349
|
+
return mcpSuccess(operation, { action, session }, { workspaceId: session.workspaceId });
|
|
350
|
+
}
|
|
351
|
+
case "abandon": {
|
|
352
|
+
const session = await service.abandon(
|
|
353
|
+
String(input["sessionId"]),
|
|
354
|
+
{
|
|
355
|
+
...(typeof input["reasonCode"] === "string"
|
|
356
|
+
? { reasonCode: input["reasonCode"] as SearchJourneyAbandonReasonCode }
|
|
357
|
+
: {}),
|
|
358
|
+
...(typeof input["reason"] === "string" ? { reason: input["reason"] } : {}),
|
|
359
|
+
},
|
|
360
|
+
callOptions,
|
|
361
|
+
);
|
|
362
|
+
return mcpSuccess(operation, { action, session }, { workspaceId: session.workspaceId });
|
|
363
|
+
}
|
|
364
|
+
case "report": {
|
|
365
|
+
const report = await service.report(callOptions);
|
|
366
|
+
return mcpSuccess(operation, { action, report }, { workspaceId: report.workspaceId });
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
return mcpFailure(
|
|
370
|
+
operation,
|
|
371
|
+
"INVALID_ARGUMENT",
|
|
372
|
+
`Unknown search-session action "${action}".`,
|
|
373
|
+
false,
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
private async product(
|
|
379
|
+
operation: UntangleMcpToolName,
|
|
380
|
+
input: Readonly<Record<string, unknown>>,
|
|
381
|
+
context: McpInvocationContext,
|
|
382
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
383
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
384
|
+
copyString(input, "root", flags, "root");
|
|
385
|
+
copyString(input, "manifest", flags, "manifest");
|
|
386
|
+
copyString(input, "testEvidence", flags, "test-evidence");
|
|
387
|
+
copyString(input, "featureId", flags, "feature");
|
|
388
|
+
copyString(input, "path", flags, "path");
|
|
389
|
+
copyNumber(input, "maxCognitive", flags, "max-cognitive");
|
|
390
|
+
copyBoolean(input, "requireComplete", flags, "require-complete");
|
|
391
|
+
return invokeJsonCommand(operation, productCommand, { positionals: [], flags }, context);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private async complexity(
|
|
395
|
+
operation: UntangleMcpToolName,
|
|
396
|
+
input: Readonly<Record<string, unknown>>,
|
|
397
|
+
context: McpInvocationContext,
|
|
398
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
399
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
400
|
+
copyString(input, "root", flags, "root");
|
|
401
|
+
copyBoolean(input, "prose", flags, "prose");
|
|
402
|
+
if (operation === "untangle_hotspots") {
|
|
403
|
+
copyNumber(input, "limit", flags, "top");
|
|
404
|
+
} else {
|
|
405
|
+
copyNumber(input, "top", flags, "top");
|
|
406
|
+
copyBoolean(input, "includeNested", flags, "include-nested");
|
|
407
|
+
}
|
|
408
|
+
return invokeJsonCommand(operation, complexityCommand, { positionals: [], flags }, context);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private async graph(
|
|
412
|
+
operation: UntangleMcpToolName,
|
|
413
|
+
input: Readonly<Record<string, unknown>>,
|
|
414
|
+
context: McpInvocationContext,
|
|
415
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
416
|
+
if (operation === "untangle_graph_query" && stringInput(input, "file") === undefined) {
|
|
417
|
+
return mcpFailure(
|
|
418
|
+
operation,
|
|
419
|
+
"INVALID_ARGUMENT",
|
|
420
|
+
"untangle_graph_query requires an explicit file; the unbounded workspace overview is not exposed over MCP.",
|
|
421
|
+
false,
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
425
|
+
copyString(input, "root", flags, "root");
|
|
426
|
+
copyString(input, "direction", flags, "direction");
|
|
427
|
+
copyCappedNumber(input, "depth", flags, "depth", MAX_GRAPH_QUERY_DEPTH);
|
|
428
|
+
copyCappedNumber(
|
|
429
|
+
input,
|
|
430
|
+
"maxNodes",
|
|
431
|
+
flags,
|
|
432
|
+
"max-nodes",
|
|
433
|
+
operation === "untangle_graph_visualize" ? MAX_MAX_NODES : MAX_GRAPH_QUERY_NODES,
|
|
434
|
+
);
|
|
435
|
+
copyCappedNumber(
|
|
436
|
+
input,
|
|
437
|
+
"maxEdges",
|
|
438
|
+
flags,
|
|
439
|
+
"max-edges",
|
|
440
|
+
operation === "untangle_graph_visualize" ? MAX_MAX_EDGES : MAX_GRAPH_QUERY_EDGES,
|
|
441
|
+
);
|
|
442
|
+
copyNumber(input, "limit", flags, "limit");
|
|
443
|
+
copyString(input, "out", flags, "out");
|
|
444
|
+
copyString(input, "layout", flags, "layout");
|
|
445
|
+
const file = typeof input["file"] === "string" ? input["file"] : undefined;
|
|
446
|
+
const positionals =
|
|
447
|
+
operation === "untangle_graph_visualize" ? ["visualize"] : file === undefined ? [] : [file];
|
|
448
|
+
const envelope = await invokeJsonCommand(
|
|
449
|
+
operation,
|
|
450
|
+
graphCommand,
|
|
451
|
+
{ positionals, flags },
|
|
452
|
+
context,
|
|
453
|
+
);
|
|
454
|
+
if (!envelope.ok || !isRecord(envelope.data)) return envelope;
|
|
455
|
+
if (operation === "untangle_graph_query" && file !== undefined) return envelope;
|
|
456
|
+
if (file !== undefined) return envelope;
|
|
457
|
+
if (operation === "untangle_graph_stats") {
|
|
458
|
+
return {
|
|
459
|
+
...envelope,
|
|
460
|
+
data: {
|
|
461
|
+
generationId: envelope.data["generationId"],
|
|
462
|
+
metrics: envelope.data["metrics"],
|
|
463
|
+
boundaries: envelope.data["boundaries"],
|
|
464
|
+
issues: envelope.data["issues"],
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
if (operation === "untangle_graph_cycles") {
|
|
469
|
+
const limit = typeof input["limit"] === "number" ? input["limit"] : 20;
|
|
470
|
+
const cycles = Array.isArray(envelope.data["cyclePaths"])
|
|
471
|
+
? envelope.data["cyclePaths"].slice(0, limit)
|
|
472
|
+
: [];
|
|
473
|
+
return {
|
|
474
|
+
...envelope,
|
|
475
|
+
data: {
|
|
476
|
+
generationId: envelope.data["generationId"],
|
|
477
|
+
cycles,
|
|
478
|
+
total: Array.isArray(envelope.data["cyclePaths"])
|
|
479
|
+
? envelope.data["cyclePaths"].length
|
|
480
|
+
: 0,
|
|
481
|
+
issues: envelope.data["issues"],
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
if (operation === "untangle_graph_status") {
|
|
486
|
+
return {
|
|
487
|
+
...envelope,
|
|
488
|
+
data: {
|
|
489
|
+
generationId: envelope.data["generationId"],
|
|
490
|
+
workspaceId: envelope.data["workspaceId"],
|
|
491
|
+
metrics: envelope.data["metrics"],
|
|
492
|
+
issues: envelope.data["issues"],
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return envelope;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
private async symbols(
|
|
500
|
+
operation: UntangleMcpToolName,
|
|
501
|
+
input: Readonly<Record<string, unknown>>,
|
|
502
|
+
context: McpInvocationContext,
|
|
503
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
504
|
+
const loaded = await loadGraphs({
|
|
505
|
+
cwd: stringInput(input, "root") ?? context.cwd,
|
|
506
|
+
env: context.env,
|
|
507
|
+
signal: context.signal,
|
|
508
|
+
});
|
|
509
|
+
const requestedWorkspace = stringInput(input, "workspaceId");
|
|
510
|
+
if (requestedWorkspace !== undefined && requestedWorkspace !== loaded.fileGraph.workspaceId) {
|
|
511
|
+
return mcpFailure(
|
|
512
|
+
operation,
|
|
513
|
+
"WORKSPACE_NOT_FOUND",
|
|
514
|
+
`Loaded graph belongs to workspace "${loaded.fileGraph.workspaceId}", not requested workspace "${requestedWorkspace}".`,
|
|
515
|
+
false,
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
if (loaded.symbolGraph === null) {
|
|
519
|
+
return mcpFailure(
|
|
520
|
+
operation,
|
|
521
|
+
"INDEX_INCOMPLETE",
|
|
522
|
+
loaded.symbolGraphMissingReason ?? "The symbol graph is unavailable.",
|
|
523
|
+
false,
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
const index = createSymbolGraphIndex(loaded.symbolGraph.graph);
|
|
527
|
+
if (operation === "untangle_symbols") {
|
|
528
|
+
const query = stringInput(input, "query")?.toLowerCase();
|
|
529
|
+
const limit = numberInput(input, "limit") ?? 100;
|
|
530
|
+
const matching = index
|
|
531
|
+
.nodes()
|
|
532
|
+
.filter(
|
|
533
|
+
(node) =>
|
|
534
|
+
query === undefined ||
|
|
535
|
+
node.name.toLowerCase().includes(query) ||
|
|
536
|
+
node.qualifiedName.toLowerCase().includes(query),
|
|
537
|
+
)
|
|
538
|
+
.sort(
|
|
539
|
+
(left, right) =>
|
|
540
|
+
compareCodepoints(left.repoId, right.repoId) ||
|
|
541
|
+
compareCodepoints(left.refId, right.refId) ||
|
|
542
|
+
compareCodepoints(left.filePath, right.filePath) ||
|
|
543
|
+
left.startLine - right.startLine ||
|
|
544
|
+
compareCodepoints(left.id, right.id),
|
|
545
|
+
);
|
|
546
|
+
return mcpSuccess(
|
|
547
|
+
operation,
|
|
548
|
+
{
|
|
549
|
+
generationId: loaded.generationId,
|
|
550
|
+
symbols: matching.slice(0, limit),
|
|
551
|
+
total: matching.length,
|
|
552
|
+
truncated: matching.length > limit,
|
|
553
|
+
},
|
|
554
|
+
{ workspaceId: loaded.fileGraph.workspaceId },
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
const selection = selectSymbolNode(index.nodes(), String(input["symbol"]));
|
|
558
|
+
if (selection.status === "ambiguous") {
|
|
559
|
+
return mcpFailure(
|
|
560
|
+
operation,
|
|
561
|
+
"SYMBOL_AMBIGUOUS",
|
|
562
|
+
`The symbol matched ${String(selection.candidates.length)} persisted nodes; none was selected.`,
|
|
563
|
+
false,
|
|
564
|
+
{ details: { candidates: selection.candidates } },
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
if (selection.status === "absent") {
|
|
568
|
+
return mcpFailure(
|
|
569
|
+
operation,
|
|
570
|
+
"SYMBOL_NOT_FOUND",
|
|
571
|
+
"The symbol is not present in the persisted graph.",
|
|
572
|
+
false,
|
|
573
|
+
{ details: { near: selection.near } },
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
return mcpSuccess(
|
|
577
|
+
operation,
|
|
578
|
+
{
|
|
579
|
+
generationId: loaded.generationId,
|
|
580
|
+
matchedBy: selection.matchedBy,
|
|
581
|
+
symbol: selection.node,
|
|
582
|
+
outgoing: index.outgoingEdges(selection.node.id),
|
|
583
|
+
callers: index.callers(selection.node.id),
|
|
584
|
+
},
|
|
585
|
+
{ workspaceId: loaded.fileGraph.workspaceId },
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
private async flow(
|
|
590
|
+
operation: UntangleMcpToolName,
|
|
591
|
+
input: Readonly<Record<string, unknown>>,
|
|
592
|
+
context: McpInvocationContext,
|
|
593
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
594
|
+
const flags: Record<string, FlagValue> = { format: "json" };
|
|
595
|
+
copyString(input, "root", flags, "root");
|
|
596
|
+
copyCappedNumber(input, "depth", flags, "depth", MAX_FLOW_DEPTH);
|
|
597
|
+
copyCappedNumber(input, "limit", flags, "limit", MAX_FLOW_RESULT_LIMIT);
|
|
598
|
+
copyCappedNumber(input, "maxNodes", flags, "max-nodes", MAX_FLOW_NODES);
|
|
599
|
+
copyCappedNumber(input, "maxEdges", flags, "max-edges", MAX_FLOW_EDGES);
|
|
600
|
+
copyNumber(input, "minConfidence", flags, "min-confidence");
|
|
601
|
+
const first = operation === "untangle_impact" ? String(input["symbol"]) : String(input["from"]);
|
|
602
|
+
const positionals = [first];
|
|
603
|
+
if (operation === "untangle_impact") {
|
|
604
|
+
flags["impact"] = true;
|
|
605
|
+
} else if (typeof input["to"] === "string") {
|
|
606
|
+
positionals.push(input["to"]);
|
|
607
|
+
}
|
|
608
|
+
return invokeJsonCommand(operation, flowCommand, { positionals, flags }, context);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
async function openSearchJourneyService(
|
|
613
|
+
input: Readonly<Record<string, unknown>>,
|
|
614
|
+
context: McpInvocationContext,
|
|
615
|
+
): Promise<SearchJourneyService> {
|
|
616
|
+
const view = loadWorkspace({
|
|
617
|
+
cwd: stringInput(input, "root") ?? context.cwd,
|
|
618
|
+
env: context.env,
|
|
619
|
+
strict: true,
|
|
620
|
+
});
|
|
621
|
+
const local = await openLocalStorage(
|
|
622
|
+
stateRootOf(view.root),
|
|
623
|
+
{
|
|
624
|
+
clock: systemClock,
|
|
625
|
+
random: systemRandom,
|
|
626
|
+
},
|
|
627
|
+
{ signal: context.signal },
|
|
628
|
+
);
|
|
629
|
+
return new SearchJourneyService({
|
|
630
|
+
workspaceId: view.workspaceId,
|
|
631
|
+
store: local.searchJourneys,
|
|
632
|
+
clock: systemClock,
|
|
633
|
+
random: systemRandom,
|
|
634
|
+
fingerprintKeyProvider: async (options) =>
|
|
635
|
+
await local.searchJourneys.getOrCreateFingerprintKey(options),
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function searchSessionLink(
|
|
640
|
+
input: Readonly<Record<string, unknown>>,
|
|
641
|
+
): { id: string; step?: number } | null {
|
|
642
|
+
const session = input["session"];
|
|
643
|
+
if (!isRecord(session) || typeof session["id"] !== "string") return null;
|
|
644
|
+
return {
|
|
645
|
+
id: session["id"],
|
|
646
|
+
...(typeof session["step"] === "number" ? { step: session["step"] } : {}),
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function searchJourneyTarget(input: Readonly<Record<string, unknown>>): SearchJourneyTargetV1 {
|
|
651
|
+
const output: SearchJourneyTargetV1 = {};
|
|
652
|
+
for (const key of [
|
|
653
|
+
"repoId",
|
|
654
|
+
"refId",
|
|
655
|
+
"filePath",
|
|
656
|
+
"chunkId",
|
|
657
|
+
"symbolId",
|
|
658
|
+
"embeddingProfileId",
|
|
659
|
+
"indexGeneration",
|
|
660
|
+
] as const) {
|
|
661
|
+
const value = input[key];
|
|
662
|
+
if (typeof value === "string") output[key] = value;
|
|
663
|
+
}
|
|
664
|
+
return output;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function validateRequestedWorkspace(
|
|
668
|
+
operation: UntangleMcpToolName,
|
|
669
|
+
input: Readonly<Record<string, unknown>>,
|
|
670
|
+
context: McpInvocationContext,
|
|
671
|
+
): ToolResponseEnvelopeV1<unknown> | null {
|
|
672
|
+
const requestedWorkspace = stringInput(input, "workspaceId");
|
|
673
|
+
if (requestedWorkspace === undefined) return null;
|
|
674
|
+
const view = loadWorkspace({
|
|
675
|
+
cwd: stringInput(input, "root") ?? context.cwd,
|
|
676
|
+
env: context.env,
|
|
677
|
+
strict: true,
|
|
678
|
+
});
|
|
679
|
+
if (requestedWorkspace === view.workspaceId) return null;
|
|
680
|
+
return mcpFailure(
|
|
681
|
+
operation,
|
|
682
|
+
"WORKSPACE_NOT_FOUND",
|
|
683
|
+
`The requested workspace "${requestedWorkspace}" is not the workspace served by this MCP scope.`,
|
|
684
|
+
false,
|
|
685
|
+
{ workspaceId: requestedWorkspace },
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function about(
|
|
690
|
+
operation: UntangleMcpToolName,
|
|
691
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
692
|
+
): ToolResponseEnvelopeV1<unknown> {
|
|
693
|
+
const commit = env["UNTANGLE_BUILD_COMMIT"]?.trim() || "unknown";
|
|
694
|
+
const warnings: ToolWarningV1[] =
|
|
695
|
+
commit === "unknown"
|
|
696
|
+
? [
|
|
697
|
+
{
|
|
698
|
+
code: "BUILD_COMMIT_UNKNOWN",
|
|
699
|
+
message: "This development build did not embed a source commit.",
|
|
700
|
+
},
|
|
701
|
+
]
|
|
702
|
+
: [];
|
|
703
|
+
return mcpSuccess(
|
|
704
|
+
operation,
|
|
705
|
+
{
|
|
706
|
+
name: "untangle",
|
|
707
|
+
version: CLI_VERSION,
|
|
708
|
+
license: "AGPL-3.0-only",
|
|
709
|
+
source: SOURCE_URL,
|
|
710
|
+
commit,
|
|
711
|
+
availableTools: [...DEFAULT_MCP_AVAILABLE_TOOLS].sort(compareCodepoints),
|
|
712
|
+
unavailableToolsReturn: "FEATURE_UNAVAILABLE",
|
|
713
|
+
},
|
|
714
|
+
{ warnings },
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function projects(
|
|
719
|
+
operation: UntangleMcpToolName,
|
|
720
|
+
input: Readonly<Record<string, unknown>>,
|
|
721
|
+
context: McpInvocationContext,
|
|
722
|
+
): ToolResponseEnvelopeV1<unknown> {
|
|
723
|
+
const view = loadWorkspace({
|
|
724
|
+
cwd: stringInput(input, "root") ?? context.cwd,
|
|
725
|
+
env: context.env,
|
|
726
|
+
strict: true,
|
|
727
|
+
});
|
|
728
|
+
return mcpSuccess(
|
|
729
|
+
operation,
|
|
730
|
+
{
|
|
731
|
+
root: view.root,
|
|
732
|
+
repositories: view.config.repositories ?? [],
|
|
733
|
+
projectId: view.config.projectId,
|
|
734
|
+
},
|
|
735
|
+
{ workspaceId: view.workspaceId },
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function contextList(
|
|
740
|
+
operation: UntangleMcpToolName,
|
|
741
|
+
input: Readonly<Record<string, unknown>>,
|
|
742
|
+
context: McpInvocationContext,
|
|
743
|
+
): ToolResponseEnvelopeV1<unknown> {
|
|
744
|
+
const view = loadWorkspace({
|
|
745
|
+
cwd: stringInput(input, "root") ?? context.cwd,
|
|
746
|
+
env: context.env,
|
|
747
|
+
strict: true,
|
|
748
|
+
});
|
|
749
|
+
const artifacts = [...(view.config.contextArtifacts ?? [])].sort((left, right) =>
|
|
750
|
+
compareCodepoints(left.name, right.name),
|
|
751
|
+
);
|
|
752
|
+
return mcpSuccess(
|
|
753
|
+
operation,
|
|
754
|
+
{ artifacts, configured: artifacts.length },
|
|
755
|
+
{ workspaceId: view.workspaceId },
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
async function invokeJsonCommand(
|
|
760
|
+
operation: UntangleMcpToolName,
|
|
761
|
+
command: Command,
|
|
762
|
+
args: ParsedArgs,
|
|
763
|
+
context: McpInvocationContext,
|
|
764
|
+
acceptedExitCodes: readonly number[] = [EXIT.ok],
|
|
765
|
+
): Promise<ToolResponseEnvelopeV1<unknown>> {
|
|
766
|
+
const io = new BufferIo();
|
|
767
|
+
const commandContext: CommandContext = {
|
|
768
|
+
io,
|
|
769
|
+
cwd: context.cwd,
|
|
770
|
+
env: context.env,
|
|
771
|
+
signal: context.signal,
|
|
772
|
+
};
|
|
773
|
+
let exitCode: number;
|
|
774
|
+
try {
|
|
775
|
+
exitCode = await command.run(commandContext, args);
|
|
776
|
+
} catch (error) {
|
|
777
|
+
if (context.signal.aborted) return cancelledEnvelope(operation);
|
|
778
|
+
const failure = failureFromThrown(operation, error);
|
|
779
|
+
return partialSearchFailure(operation, error, io, failure) ?? failure;
|
|
780
|
+
}
|
|
781
|
+
if (context.signal.aborted) return cancelledEnvelope(operation);
|
|
782
|
+
const warnings = diagnostics(io.errText);
|
|
783
|
+
let data: unknown;
|
|
784
|
+
try {
|
|
785
|
+
data = io.outText.trim() === "" ? null : JSON.parse(io.outText);
|
|
786
|
+
} catch {
|
|
787
|
+
return mcpFailure(
|
|
788
|
+
operation,
|
|
789
|
+
"INVALID_INTERNAL_OUTPUT",
|
|
790
|
+
`${command.spec.name} did not emit valid JSON.`,
|
|
791
|
+
false,
|
|
792
|
+
{ warnings },
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
if (!acceptedExitCodes.includes(exitCode)) {
|
|
796
|
+
return mcpFailure(
|
|
797
|
+
operation,
|
|
798
|
+
codeForExit(exitCode),
|
|
799
|
+
`The ${command.spec.name} operation ended with exit code ${String(exitCode)}.`,
|
|
800
|
+
exitCode === EXIT.environment,
|
|
801
|
+
{ warnings, details: { exitCode, data } },
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
return mcpSuccess(operation, data, { warnings });
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/** Preserve verified fallback hits without turning infrastructure failure into success. */
|
|
808
|
+
function partialSearchFailure(
|
|
809
|
+
operation: UntangleMcpToolName,
|
|
810
|
+
error: unknown,
|
|
811
|
+
io: BufferIo,
|
|
812
|
+
failure: ToolResponseEnvelopeV1<unknown>,
|
|
813
|
+
): ToolResponseEnvelopeV1<unknown> | undefined {
|
|
814
|
+
if (
|
|
815
|
+
operation !== "untangle_search" ||
|
|
816
|
+
!(error instanceof CliError) ||
|
|
817
|
+
error.exitCode !== EXIT.environment
|
|
818
|
+
) {
|
|
819
|
+
return undefined;
|
|
820
|
+
}
|
|
821
|
+
let output: unknown;
|
|
822
|
+
try {
|
|
823
|
+
output = JSON.parse(io.outText);
|
|
824
|
+
} catch {
|
|
825
|
+
return undefined;
|
|
826
|
+
}
|
|
827
|
+
const parsed = UNTANGLE_MCP_SUCCESS_DATA_SCHEMAS.untangle_search.safeParse(output);
|
|
828
|
+
if (
|
|
829
|
+
!parsed.success ||
|
|
830
|
+
!parsed.data.warnings.some((warning) => warning.code === "SEARCH_BRANCH_UNAVAILABLE") ||
|
|
831
|
+
!parsed.data.skipped.some(
|
|
832
|
+
(entry) =>
|
|
833
|
+
entry.subjectKind === "search_candidate" && entry.reason === "provider_unavailable",
|
|
834
|
+
)
|
|
835
|
+
) {
|
|
836
|
+
return undefined;
|
|
837
|
+
}
|
|
838
|
+
return {
|
|
839
|
+
...failure,
|
|
840
|
+
workspaceId: parsed.data.query.workspaceId,
|
|
841
|
+
warnings: [
|
|
842
|
+
...failure.warnings,
|
|
843
|
+
...parsed.data.warnings.map(({ code, message, details }) => ({
|
|
844
|
+
code,
|
|
845
|
+
message,
|
|
846
|
+
...(details === undefined ? {} : { details }),
|
|
847
|
+
})),
|
|
848
|
+
...diagnostics(io.errText),
|
|
849
|
+
],
|
|
850
|
+
error: {
|
|
851
|
+
code: failure.error?.code ?? "ENVIRONMENT_UNAVAILABLE",
|
|
852
|
+
message: failure.error?.message ?? "Search retrieval was incomplete.",
|
|
853
|
+
retryable: true,
|
|
854
|
+
details: { ...failure.error?.details, exitCode: error.exitCode, data: parsed.data },
|
|
855
|
+
},
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/** A partial search observation belongs inside its preserved failure payload. */
|
|
860
|
+
function withSearchObservation(
|
|
861
|
+
result: ToolResponseEnvelopeV1<unknown>,
|
|
862
|
+
searchData: Readonly<Record<string, unknown>>,
|
|
863
|
+
observation: Readonly<Record<string, string>>,
|
|
864
|
+
): ToolResponseEnvelopeV1<unknown> {
|
|
865
|
+
const data = { ...searchData, searchObservation: observation };
|
|
866
|
+
if (result.ok) return { ...result, data };
|
|
867
|
+
if (result.error === undefined) return result;
|
|
868
|
+
return { ...result, error: { ...result.error, details: { ...result.error.details, data } } };
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function failureFromThrown(
|
|
872
|
+
operation: UntangleMcpToolName,
|
|
873
|
+
error: unknown,
|
|
874
|
+
): ToolResponseEnvelopeV1<unknown> {
|
|
875
|
+
if (error instanceof CliError) {
|
|
876
|
+
return mcpFailure(
|
|
877
|
+
operation,
|
|
878
|
+
codeForExit(error.exitCode),
|
|
879
|
+
error.message,
|
|
880
|
+
error.exitCode === EXIT.environment,
|
|
881
|
+
error.nextStep === undefined ? {} : { details: { nextStep: error.nextStep } },
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
885
|
+
return mcpFailure(operation, "CANCELLED", "The MCP operation was cancelled.", false);
|
|
886
|
+
}
|
|
887
|
+
if (isUntangleError(error)) {
|
|
888
|
+
return mcpFailure(operation, error.code, error.message, error.retryable, {
|
|
889
|
+
...(Object.keys(error.context).length === 0 ? {} : { details: error.context }),
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
return mcpFailure(
|
|
893
|
+
operation,
|
|
894
|
+
"INTERNAL_ERROR",
|
|
895
|
+
error instanceof Error ? error.message : String(error),
|
|
896
|
+
false,
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function cancelledEnvelope(operation: UntangleMcpToolName): ToolResponseEnvelopeV1<unknown> {
|
|
901
|
+
return mcpFailure(operation, "CANCELLED", "The MCP operation was cancelled.", false);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function assertNever(value: never): never {
|
|
905
|
+
throw new Error(`Unhandled default MCP capability: ${String(value)}`);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function codeForExit(exitCode: number): string {
|
|
909
|
+
if (exitCode === EXIT.usage) return "INVALID_ARGUMENT";
|
|
910
|
+
if (exitCode === EXIT.unavailable) return "FEATURE_UNAVAILABLE";
|
|
911
|
+
if (exitCode === EXIT.environment) return "ENVIRONMENT_UNAVAILABLE";
|
|
912
|
+
if (exitCode === EXIT.gate) return "QUALITY_GATE_FAILED";
|
|
913
|
+
if (exitCode === EXIT.cancelled) return "CANCELLED";
|
|
914
|
+
return "OPERATION_FAILED";
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function diagnostics(text: string): ToolWarningV1[] {
|
|
918
|
+
return text
|
|
919
|
+
.split("\n")
|
|
920
|
+
.map((line) => line.trim())
|
|
921
|
+
.filter((line) => line !== "")
|
|
922
|
+
.map((message) => ({ code: "CLI_DIAGNOSTIC", message }));
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function unavailableReason(operation: UntangleMcpToolName): string {
|
|
926
|
+
if (
|
|
927
|
+
[
|
|
928
|
+
"untangle_index",
|
|
929
|
+
"untangle_update",
|
|
930
|
+
"untangle_stop",
|
|
931
|
+
"untangle_watch",
|
|
932
|
+
"untangle_status",
|
|
933
|
+
].includes(operation)
|
|
934
|
+
)
|
|
935
|
+
return "the job-capable MCP composition and persisted job registry are not wired";
|
|
936
|
+
if (
|
|
937
|
+
["untangle_context_index", "untangle_context_search", "untangle_context_remove"].includes(
|
|
938
|
+
operation,
|
|
939
|
+
)
|
|
940
|
+
)
|
|
941
|
+
return "context-artifact mutation/search use cases are not exposed by the current core facade";
|
|
942
|
+
if (["untangle_graph_build", "untangle_graph_remove"].includes(operation))
|
|
943
|
+
return "standalone graph mutation is not exposed by the current core facade";
|
|
944
|
+
if (operation === "untangle_cross_repo_impact")
|
|
945
|
+
return "a workspace-scoped multi-repository graph snapshot is required before cross-repository impact can be claimed";
|
|
946
|
+
if (
|
|
947
|
+
[
|
|
948
|
+
"untangle_complexity_explain",
|
|
949
|
+
"untangle_complexity_diff",
|
|
950
|
+
"untangle_changes",
|
|
951
|
+
"untangle_change_search",
|
|
952
|
+
"untangle_quality_gate",
|
|
953
|
+
].includes(operation)
|
|
954
|
+
)
|
|
955
|
+
return "the change-analysis and quality-gate engine is not implemented";
|
|
956
|
+
if (
|
|
957
|
+
operation.startsWith("untangle_portfolio") ||
|
|
958
|
+
[
|
|
959
|
+
"untangle_stack_matrix",
|
|
960
|
+
"untangle_who_uses",
|
|
961
|
+
"untangle_conventions",
|
|
962
|
+
"untangle_archetypes",
|
|
963
|
+
"untangle_tech_radar",
|
|
964
|
+
"untangle_blueprint",
|
|
965
|
+
].includes(operation)
|
|
966
|
+
)
|
|
967
|
+
return "the portfolio engine is not implemented";
|
|
968
|
+
return "the operation is not implemented by this runtime";
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
function stringInput(input: Readonly<Record<string, unknown>>, key: string): string | undefined {
|
|
972
|
+
const value = input[key];
|
|
973
|
+
return typeof value === "string" ? value : undefined;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
function numberInput(input: Readonly<Record<string, unknown>>, key: string): number | undefined {
|
|
977
|
+
const value = input[key];
|
|
978
|
+
return typeof value === "number" ? value : undefined;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function copyString(
|
|
982
|
+
input: Readonly<Record<string, unknown>>,
|
|
983
|
+
from: string,
|
|
984
|
+
flags: Record<string, FlagValue>,
|
|
985
|
+
to: string,
|
|
986
|
+
): void {
|
|
987
|
+
const value = stringInput(input, from);
|
|
988
|
+
if (value !== undefined) flags[to] = value;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function copyNumber(
|
|
992
|
+
input: Readonly<Record<string, unknown>>,
|
|
993
|
+
from: string,
|
|
994
|
+
flags: Record<string, FlagValue>,
|
|
995
|
+
to: string,
|
|
996
|
+
): void {
|
|
997
|
+
const value = numberInput(input, from);
|
|
998
|
+
if (value !== undefined) flags[to] = value;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function copyCappedNumber(
|
|
1002
|
+
input: Readonly<Record<string, unknown>>,
|
|
1003
|
+
from: string,
|
|
1004
|
+
flags: Record<string, FlagValue>,
|
|
1005
|
+
to: string,
|
|
1006
|
+
maximum: number,
|
|
1007
|
+
): void {
|
|
1008
|
+
const value = numberInput(input, from);
|
|
1009
|
+
if (value !== undefined) flags[to] = Math.min(value, maximum);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function copyBoolean(
|
|
1013
|
+
input: Readonly<Record<string, unknown>>,
|
|
1014
|
+
from: string,
|
|
1015
|
+
flags: Record<string, FlagValue>,
|
|
1016
|
+
to: string,
|
|
1017
|
+
): void {
|
|
1018
|
+
const value = input[from];
|
|
1019
|
+
if (typeof value === "boolean") flags[to] = value;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function copyStrings(
|
|
1023
|
+
input: Readonly<Record<string, unknown>>,
|
|
1024
|
+
from: string,
|
|
1025
|
+
flags: Record<string, FlagValue>,
|
|
1026
|
+
to: string,
|
|
1027
|
+
): void {
|
|
1028
|
+
const value = input[from];
|
|
1029
|
+
if (Array.isArray(value) && value.every((entry) => typeof entry === "string")) flags[to] = value;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
1033
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1034
|
+
}
|