@automaton-labs/aib 0.0.6 → 0.0.8
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 +36 -257
- package/config/agent-dx-policy.default.json +31 -0
- package/config/control-plane-client.default.json +3 -0
- package/dist/agent-dx/agent-dx.js +805 -0
- package/dist/agent-dx/presentation.js +32 -0
- package/dist/alias-advisor/analyze.js +982 -0
- package/dist/alias-advisor/exact-text-cost.js +74 -0
- package/dist/alias-advisor/lexical.js +240 -0
- package/dist/alias-advisor/model.js +2 -0
- package/dist/alias-advisor/path-identity.js +49 -0
- package/dist/alias-advisor/ranking.js +171 -0
- package/dist/alias-advisor/token-estimator.js +85 -0
- package/dist/bin/aib.js +5 -1
- package/dist/bin/cli.js +811 -2
- package/dist/commands/add-missing-imports-preview-cache.js +99 -2
- package/dist/commands/add-missing-imports.js +241 -2
- package/dist/commands/apply-module-plan.js +1319 -3
- package/dist/commands/background-command.js +378 -0
- package/dist/commands/captured-input.js +74 -2
- package/dist/commands/config-command.js +314 -2
- package/dist/commands/config-output.js +357 -10
- package/dist/commands/control-plane-command.js +183 -0
- package/dist/commands/declaration-command.js +1209 -0
- package/dist/commands/declaration-execution-cache.js +79 -0
- package/dist/commands/declaration-format.js +221 -0
- package/dist/commands/declaration-preview-cache.js +114 -0
- package/dist/commands/diagnostics-command.js +70 -3
- package/dist/commands/doctor.js +137 -2
- package/dist/commands/execution-command.js +117 -1
- package/dist/commands/exports-star-collapse-command.js +178 -0
- package/dist/commands/exports-star-command.js +252 -0
- package/dist/commands/exports-star-preview-cache.js +84 -0
- package/dist/commands/feedback-command.js +176 -3
- package/dist/commands/file-move-to-dir-execution-cache.js +92 -0
- package/dist/commands/file-move-to-dir-preview-cache.js +125 -0
- package/dist/commands/file-move-to-dir-worker.js +54 -0
- package/dist/commands/file-move-to-dir.js +1073 -0
- package/dist/commands/file-mutation-runtime.js +102 -0
- package/dist/commands/file-mutation-worker-apply.js +180 -0
- package/dist/commands/file-refactor-batch-execution-cache.js +90 -0
- package/dist/commands/file-refactor-batch-preview-cache.js +125 -0
- package/dist/commands/file-refactor-batch-worker.js +54 -0
- package/dist/commands/file-refactor-batch.js +1154 -0
- package/dist/commands/file-rename-execution-cache.js +92 -0
- package/dist/commands/file-rename-preview-cache.js +125 -0
- package/dist/commands/file-rename-worker.js +54 -0
- package/dist/commands/file-rename.js +1053 -0
- package/dist/commands/file-text-edit-executor.js +205 -0
- package/dist/commands/find-importers.js +52 -1
- package/dist/commands/find-unused-imports.js +55 -1
- package/dist/commands/generate-docs-command.js +244 -6
- package/dist/commands/help-command.js +460 -7
- package/dist/commands/import-specifier-policy.js +391 -0
- package/dist/commands/imports-command.js +68 -1
- package/dist/commands/imports-rebase.js +1138 -0
- package/dist/commands/init-skill-usage.js +92 -3
- package/dist/commands/init-workspace.js +30 -1
- package/dist/commands/inspect-alias-candidates.js +413 -0
- package/dist/commands/inspect-cycles.js +811 -5
- package/dist/commands/inspect-direct-usages.js +98 -0
- package/dist/commands/inspect-duplicates-format.js +229 -0
- package/dist/commands/inspect-format-primitives.js +127 -0
- package/dist/commands/inspect-format.js +1590 -18
- package/dist/commands/inspect-graph.js +1553 -9
- package/dist/commands/inspect-imports.js +339 -2
- package/dist/commands/inspect-mixed-format.js +524 -0
- package/dist/commands/inspect-module-plan-format.js +216 -0
- package/dist/commands/inspect-module-plan-serialization.js +402 -0
- package/dist/commands/inspect-reference-path-format.js +157 -0
- package/dist/commands/inspect-request-values.js +599 -0
- package/dist/commands/inspect-selector-kind.js +21 -0
- package/dist/commands/inspect-selector.js +50 -0
- package/dist/commands/inspect-symbol-format.js +90 -0
- package/dist/commands/inspect-topology.js +435 -0
- package/dist/commands/inspect-tree.js +827 -5
- package/dist/commands/inspect-usages-detail.js +793 -0
- package/dist/commands/inspect-usages-evidence.js +31 -0
- package/dist/commands/inspect-usages-format.js +367 -0
- package/dist/commands/inspect.js +1450 -16
- package/dist/commands/internal-command.js +64 -0
- package/dist/commands/json-file-input.js +60 -1
- package/dist/commands/module-plan-cache.js +156 -2
- package/dist/commands/module-plan-standalone.js +208 -0
- package/dist/commands/module-plan-timeout.js +77 -1
- package/dist/commands/move-preview-cache.js +101 -2
- package/dist/commands/mutate-aggregate-output.js +996 -0
- package/dist/commands/mutate-child-execution.js +374 -0
- package/dist/commands/mutate-command.js +1394 -0
- package/dist/commands/mutate-declaration-output.js +313 -0
- package/dist/commands/mutate-domain-adapters.js +638 -0
- package/dist/commands/mutate-execution-cache.js +114 -0
- package/dist/commands/mutate-execution-status.js +598 -0
- package/dist/commands/mutate-failure-output.js +531 -0
- package/dist/commands/mutate-file-view.js +151 -0
- package/dist/commands/mutate-object-output.js +91 -0
- package/dist/commands/mutate-output-values.js +97 -0
- package/dist/commands/mutate-preview-cache.js +86 -0
- package/dist/commands/mutate-response-replay.js +153 -0
- package/dist/commands/mutate-result-projection.js +818 -0
- package/dist/commands/mutation-eta.js +28 -0
- package/dist/commands/mutation-execution-cache.js +140 -3
- package/dist/commands/mutation-recovery-journal.js +195 -0
- package/dist/commands/normalize-imports.js +1120 -4
- package/dist/commands/object-pack-command.js +546 -0
- package/dist/commands/object-pack-preview-cache.js +88 -0
- package/dist/commands/observability-command.js +47 -3
- package/dist/commands/ota-command.js +403 -0
- package/dist/commands/print-config.js +10 -1
- package/dist/commands/quick-read.js +1113 -11
- package/dist/commands/refactor-batch-builder.js +265 -1
- package/dist/commands/refactor-batch-execution-cache.js +85 -1
- package/dist/commands/refactor-batch-preview-cache.js +96 -2
- package/dist/commands/refactor-batch.js +461 -4
- package/dist/commands/rename-entities.js +794 -4
- package/dist/commands/rename-execution-cache.js +49 -1
- package/dist/commands/rename-input.js +22 -1
- package/dist/commands/rename-polling-policy.js +68 -0
- package/dist/commands/rename-preview-cache.js +96 -2
- package/dist/commands/result-view.js +993 -6
- package/dist/commands/reveal-command.js +445 -5
- package/dist/commands/selector-suggestions.js +93 -0
- package/dist/commands/session-workspace.js +1836 -31
- package/dist/commands/shared.js +2 -1
- package/dist/commands/skills-command.js +315 -0
- package/dist/commands/sync-command.js +59 -2
- package/dist/commands/worker-command.js +173 -0
- package/dist/commands/workspace-cache.js +55 -1
- package/dist/config/defaults.js +26 -1
- package/dist/config/env-vars.js +77 -1
- package/dist/config/glob-match.js +44 -1
- package/dist/config/import-rules.js +165 -1
- package/dist/config/local-config.js +293 -3
- package/dist/config/mutation-comments.js +51 -1
- package/dist/config/path-aliases.js +165 -1
- package/dist/config/path-display.js +84 -1
- package/dist/config/product-storage.js +37 -1
- package/dist/config/request-env.js +21 -0
- package/dist/config/request-routing-context.js +23 -0
- package/dist/config/resolve-command-alias.js +74 -1
- package/dist/config/resolve.js +24 -1
- package/dist/config/tsconfig-discovery.js +113 -1
- package/dist/config/typescript-preferences.js +131 -0
- package/dist/config/workspace-root.js +310 -3
- package/dist/config/workspace-state.js +254 -1
- package/dist/content/content-bundle.js +88 -1
- package/dist/diagnostics/module-plan-timeline.js +75 -2
- package/dist/diagnostics/readiness-text.js +45 -8
- package/dist/dsl/aib-dsl.js +838 -1
- package/dist/dsl/declaration-dsl.js +264 -0
- package/dist/dsl/file-move-to-dir-dsl.js +123 -0
- package/dist/dsl/file-refactor-batch-dsl.js +203 -0
- package/dist/dsl/file-rename-dsl.js +135 -0
- package/dist/dsl/mutate-dsl.js +746 -0
- package/dist/help/bootstrap.bash.md +742 -0
- package/dist/help/bootstrap.md +236 -437
- package/dist/help/bootstrap.pwsh.md +742 -0
- package/dist/help/docs/basics.md +1 -1
- package/dist/help/docs/config-setup.import-normalize.md +65 -65
- package/dist/help/docs/config-setup.import-rules.md +6 -5
- package/dist/help/docs/dsl.md +4 -3
- package/dist/help/docs/first-setup.md +6 -5
- package/dist/help/docs/help-protocol.md +4 -3
- package/dist/help/docs/import.base.md +38 -0
- package/dist/help/docs/import.rebase.md +85 -0
- package/dist/help/docs/inspect.aliasCandidates.md +39 -0
- package/dist/help/docs/inspect.code.md +5 -11
- package/dist/help/docs/inspect.deps.md +7 -7
- package/dist/help/docs/inspect.file.md +10 -18
- package/dist/help/docs/inspect.graph.md +6 -20
- package/dist/help/docs/{inspect.md → inspect.shared.md} +18 -17
- package/dist/help/docs/modulePlan.md +24 -28
- package/dist/help/docs/move.md +19 -22
- package/dist/help/docs/moveToDir.md +46 -0
- package/dist/help/docs/mutate.mixed.md +34 -0
- package/dist/help/docs/mutation.shared.md +55 -0
- package/dist/help/docs/patterns.md +3 -16
- package/dist/help/docs/qr.md +13 -22
- package/dist/help/docs/quick-map.md +36 -23
- package/dist/help/docs/recipe.file-layout.md +15 -0
- package/dist/help/docs/recipe.import-boundary.md +92 -0
- package/dist/help/docs/recipe.safe-artifact-probing.md +68 -0
- package/dist/help/docs/recipe.unfamiliar-area.md +64 -0
- package/dist/help/docs/recipes.md +20 -0
- package/dist/help/docs/rename.md +19 -27
- package/dist/help/docs/renameFile.md +36 -0
- package/dist/help/docs/rg.md +22 -0
- package/dist/help/docs/rules.md +26 -0
- package/dist/help/docs/selectors.md +3 -2
- package/dist/help/docs/session.md +1 -1
- package/dist/help/dsl/bootstrap.bash.md +742 -0
- package/dist/help/dsl/bootstrap.md +236 -437
- package/dist/help/dsl/bootstrap.pwsh.md +742 -0
- package/dist/help/dsl/docs/basics.md +1 -1
- package/dist/help/dsl/docs/config-setup.import-normalize.md +65 -65
- package/dist/help/dsl/docs/config-setup.import-rules.md +6 -5
- package/dist/help/dsl/docs/dsl.md +4 -3
- package/dist/help/dsl/docs/first-setup.md +6 -5
- package/dist/help/dsl/docs/help-protocol.md +4 -3
- package/dist/help/dsl/docs/import.base.md +38 -0
- package/dist/help/dsl/docs/import.rebase.md +85 -0
- package/dist/help/dsl/docs/inspect.aliasCandidates.md +39 -0
- package/dist/help/dsl/docs/inspect.code.md +5 -11
- package/dist/help/dsl/docs/inspect.deps.md +7 -7
- package/dist/help/dsl/docs/inspect.file.md +10 -18
- package/dist/help/dsl/docs/inspect.graph.md +6 -20
- package/dist/help/dsl/docs/{inspect.md → inspect.shared.md} +18 -17
- package/dist/help/dsl/docs/modulePlan.md +24 -28
- package/dist/help/dsl/docs/move.md +19 -22
- package/dist/help/dsl/docs/moveToDir.md +46 -0
- package/dist/help/dsl/docs/mutate.mixed.md +34 -0
- package/dist/help/dsl/docs/mutation.shared.md +55 -0
- package/dist/help/dsl/docs/patterns.md +3 -16
- package/dist/help/dsl/docs/qr.md +13 -22
- package/dist/help/dsl/docs/quick-map.md +36 -23
- package/dist/help/dsl/docs/recipe.file-layout.md +15 -0
- package/dist/help/dsl/docs/recipe.import-boundary.md +92 -0
- package/dist/help/dsl/docs/recipe.safe-artifact-probing.md +68 -0
- package/dist/help/dsl/docs/recipe.unfamiliar-area.md +64 -0
- package/dist/help/dsl/docs/recipes.md +20 -0
- package/dist/help/dsl/docs/rename.md +19 -27
- package/dist/help/dsl/docs/renameFile.md +36 -0
- package/dist/help/dsl/docs/rg.md +22 -0
- package/dist/help/dsl/docs/rules.md +26 -0
- package/dist/help/dsl/docs/selectors.md +3 -2
- package/dist/help/dsl/docs/session.md +1 -1
- package/dist/help/dsl/full.md +236 -437
- package/dist/help/dsl/help-index.md +49 -0
- package/dist/help/dsl/snippets/agents.md +2 -2
- package/dist/help/dsl/tokens/qr.inline.examples.md +2 -0
- package/dist/help/dsl/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/dsl/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/dsl/topics/basics.md +1 -1
- package/dist/help/dsl/topics/config-setup.import-normalize.md +65 -65
- package/dist/help/dsl/topics/config-setup.import-rules.md +6 -5
- package/dist/help/dsl/topics/dsl.md +4 -3
- package/dist/help/dsl/topics/first-setup.md +6 -5
- package/dist/help/dsl/topics/help-protocol.md +4 -3
- package/dist/help/dsl/topics/import.base.md +36 -0
- package/dist/help/dsl/topics/import.rebase.md +83 -0
- package/dist/help/dsl/topics/inspect.aliasCandidates.md +37 -0
- package/dist/help/dsl/topics/inspect.code.md +5 -11
- package/dist/help/dsl/topics/inspect.deps.md +7 -7
- package/dist/help/dsl/topics/inspect.file.md +10 -18
- package/dist/help/dsl/topics/inspect.graph.md +6 -20
- package/dist/help/dsl/topics/{inspect.md → inspect.shared.md} +18 -17
- package/dist/help/dsl/topics/modulePlan.md +21 -26
- package/dist/help/dsl/topics/move.md +17 -18
- package/dist/help/dsl/topics/moveToDir.md +44 -0
- package/dist/help/dsl/topics/mutate.mixed.md +32 -0
- package/dist/help/dsl/topics/mutation.shared.md +53 -0
- package/dist/help/dsl/topics/patterns.md +3 -16
- package/dist/help/dsl/topics/qr.md +13 -22
- package/dist/help/dsl/topics/quick-map.md +36 -23
- package/dist/help/dsl/topics/recipe.file-layout.md +13 -0
- package/dist/help/dsl/topics/recipe.import-boundary.md +90 -0
- package/dist/help/dsl/topics/recipe.safe-artifact-probing.md +66 -0
- package/dist/help/dsl/topics/recipe.unfamiliar-area.md +62 -0
- package/dist/help/dsl/topics/recipes.md +18 -0
- package/dist/help/dsl/topics/rename.md +15 -15
- package/dist/help/dsl/topics/renameFile.md +34 -0
- package/dist/help/dsl/topics/rg.md +20 -0
- package/dist/help/dsl/topics/rules.md +24 -0
- package/dist/help/dsl/topics/selectors.md +3 -2
- package/dist/help/dsl/topics/session.md +1 -1
- package/dist/help/full.md +236 -437
- package/dist/help/help-index.md +49 -0
- package/dist/help/help-meta.json +114 -48
- package/dist/help/index.md +76 -87
- package/dist/help/snippets/agents.md +2 -2
- package/dist/help/tokens/qr.inline.examples.md +2 -0
- package/dist/help/tokens/stdin.examples.bash.md +8 -0
- package/dist/help/tokens/stdin.examples.pwsh.md +8 -0
- package/dist/help/tokens/stdin.examples.with-qr.bash.md +12 -0
- package/dist/help/tokens/stdin.examples.with-qr.pwsh.md +12 -0
- package/dist/help/topics/basics.md +1 -1
- package/dist/help/topics/config-setup.import-normalize.md +65 -65
- package/dist/help/topics/config-setup.import-rules.md +6 -5
- package/dist/help/topics/dsl.md +4 -3
- package/dist/help/topics/first-setup.md +6 -5
- package/dist/help/topics/help-protocol.md +4 -3
- package/dist/help/topics/import.base.md +36 -0
- package/dist/help/topics/import.rebase.md +83 -0
- package/dist/help/topics/inspect.aliasCandidates.md +37 -0
- package/dist/help/topics/inspect.code.md +5 -11
- package/dist/help/topics/inspect.deps.md +7 -7
- package/dist/help/topics/inspect.file.md +10 -18
- package/dist/help/topics/inspect.graph.md +6 -20
- package/dist/help/topics/{inspect.md → inspect.shared.md} +18 -17
- package/dist/help/topics/modulePlan.md +21 -26
- package/dist/help/topics/move.md +17 -18
- package/dist/help/topics/moveToDir.md +44 -0
- package/dist/help/topics/mutate.mixed.md +32 -0
- package/dist/help/topics/mutation.shared.md +53 -0
- package/dist/help/topics/patterns.md +3 -16
- package/dist/help/topics/qr.md +13 -22
- package/dist/help/topics/quick-map.md +36 -23
- package/dist/help/topics/recipe.file-layout.md +13 -0
- package/dist/help/topics/recipe.import-boundary.md +90 -0
- package/dist/help/topics/recipe.safe-artifact-probing.md +66 -0
- package/dist/help/topics/recipe.unfamiliar-area.md +62 -0
- package/dist/help/topics/recipes.md +18 -0
- package/dist/help/topics/rename.md +15 -15
- package/dist/help/topics/renameFile.md +34 -0
- package/dist/help/topics/rg.md +20 -0
- package/dist/help/topics/rules.md +24 -0
- package/dist/help/topics/selectors.md +3 -2
- package/dist/help/topics/session.md +1 -1
- package/dist/host/capabilities.js +56 -0
- package/dist/imports/standalone-import-analysis.js +602 -0
- package/dist/imports/standalone-import-model.js +2 -0
- package/dist/imports/standalone-import-process.js +66 -0
- package/dist/imports/standalone-import-worker.js +27 -0
- package/dist/imports/standalone-ts-project.js +147 -0
- package/dist/inspect/inspect-duplicates-service.js +526 -0
- package/dist/inspect/inspect-reverse-module-closure.js +338 -0
- package/dist/inspect/inspect-source-ranges.js +82 -0
- package/dist/inspect/inspect-source-shape.js +649 -0
- package/dist/inspect/standalone-inspect-analysis.js +319 -0
- package/dist/inspect/standalone-inspect-model.js +9 -0
- package/dist/inspect/standalone-inspect-process.js +55 -0
- package/dist/inspect/standalone-inspect-usages.js +274 -0
- package/dist/inspect/standalone-inspect-worker.js +13 -0
- package/dist/metrics/central-metrics.js +101 -2
- package/dist/mutation/concrete-edit-plan.js +157 -0
- package/dist/mutation/exports-star-collapse-preview.js +361 -0
- package/dist/mutation/exports-star-expand-apply.js +373 -0
- package/dist/mutation/exports-star-expand-preview.js +807 -0
- package/dist/mutation/file-impact-scan.js +182 -0
- package/dist/mutation/file-mutation-discovery.js +674 -0
- package/dist/mutation/file-mutation-eta.js +99 -0
- package/dist/mutation/file-mutation-standalone-apply.js +584 -0
- package/dist/mutation/file-mutation-standalone-planner.js +500 -0
- package/dist/mutation/file-mutation-tsserver-session.js +473 -0
- package/dist/mutation/mutation-estimate.js +45 -0
- package/dist/mutation/mutation-plan.js +467 -0
- package/dist/mutation/object-mutation-foundation.js +2 -0
- package/dist/mutation/object-mutation-partition.js +148 -0
- package/dist/mutation/object-pack-semantic-apply.js +507 -0
- package/dist/mutation/object-pack-semantic-preview.js +984 -0
- package/dist/mutation/object-unpack-semantic-preview.js +993 -0
- package/dist/mutation/package-manifest-impact.js +176 -0
- package/dist/mutation/rename-owner-worker-child.js +37 -0
- package/dist/mutation/rename-owner-worker.js +122 -0
- package/dist/mutation/runtime-cycle-query.js +66 -0
- package/dist/mutation/semantic-execution-progress.js +63 -0
- package/dist/mutation/semantic-export-index.js +474 -0
- package/dist/mutation/semantic-impact-scan.js +434 -0
- package/dist/mutation/semantic-model.js +2 -0
- package/dist/mutation/semantic-move-best-effort-planner.js +209 -0
- package/dist/mutation/semantic-move-config-worker-child.js +61 -0
- package/dist/mutation/semantic-move-config-worker.js +449 -0
- package/dist/mutation/semantic-move-declarations.js +94 -0
- package/dist/mutation/semantic-move-metrics.js +119 -0
- package/dist/mutation/semantic-move-model.js +2 -0
- package/dist/mutation/semantic-move-owner-authority.js +122 -0
- package/dist/mutation/semantic-move-owner-candidates.js +300 -0
- package/dist/mutation/semantic-move-owner-divergence-harness.js +474 -0
- package/dist/mutation/semantic-move-owner-divergence-runner.js +162 -0
- package/dist/mutation/semantic-move-plan-hash.js +56 -0
- package/dist/mutation/semantic-move-policy.js +360 -0
- package/dist/mutation/semantic-move-process.js +218 -0
- package/dist/mutation/semantic-move-provider-diagnostics.js +27 -0
- package/dist/mutation/semantic-move-standalone-engine.js +919 -0
- package/dist/mutation/semantic-move-standalone-planner.js +1553 -0
- package/dist/mutation/semantic-move-transaction.js +639 -0
- package/dist/mutation/semantic-mutation-engine.js +478 -0
- package/dist/mutation/semantic-mutation-runtime.js +521 -0
- package/dist/mutation/semantic-planner-retry.js +26 -0
- package/dist/mutation/semantic-program-roots.js +69 -0
- package/dist/mutation/semantic-rename-commonjs.js +229 -0
- package/dist/mutation/semantic-rename-config-worker-child.js +46 -0
- package/dist/mutation/semantic-rename-config-worker.js +498 -0
- package/dist/mutation/semantic-rename-locations.js +192 -0
- package/dist/mutation/semantic-rename-model.js +2 -0
- package/dist/mutation/semantic-rename-process.js +210 -0
- package/dist/mutation/semantic-rename-standalone-engine.js +302 -0
- package/dist/mutation/semantic-rename-standalone-planner.js +567 -0
- package/dist/mutation/semantic-rename-transaction.js +333 -0
- package/dist/mutation/semantic-unused-import-cleanup.js +248 -0
- package/dist/mutation/semantic-worker-retry.js +40 -0
- package/dist/mutation/semantic-workspace.js +804 -0
- package/dist/mutation/targeted-import-canonicalizer.js +359 -0
- package/dist/observability/config.js +206 -1
- package/dist/observability/context.js +59 -1
- package/dist/observability/failure-snapshot.js +124 -2
- package/dist/observability/recent.js +63 -2
- package/dist/payloads/read-stdin-json.js +212 -1
- package/dist/rg-wrapper/core.js +714 -0
- package/dist/rg-wrapper/options.js +125 -0
- package/dist/rtk-wrapper/core.js +144 -0
- package/dist/rtk-wrapper/git-safety.js +203 -0
- package/dist/rtk-wrapper/output-adapter.js +106 -0
- package/dist/runtime/buffered-process.js +114 -0
- package/dist/runtime/bundled-node.js +97 -1
- package/dist/runtime/command-lifecycle.js +2 -0
- package/dist/runtime/input-source.js +238 -1
- package/dist/runtime/node-cli-identity.js +37 -0
- package/dist/runtime/run-command.js +191 -1
- package/dist/selectors/parse-entities.js +84 -1
- package/dist/semantic/semantic-context-pool.js +830 -0
- package/dist/semantic/semantic-context-provider.js +416 -0
- package/dist/semantic/semantic-resident-admission.js +38 -0
- package/dist/semantic/semantic-worker-child.js +40 -0
- package/dist/semantic/semantic-worker-manager.js +460 -0
- package/dist/semantic/semantic-worker-protocol.js +2 -0
- package/dist/semantic/semantic-worker-runtime.js +38 -0
- package/dist/semantic/workspace-semantic-context-pools.js +136 -0
- package/dist/session/client.js +359 -1
- package/dist/session/daemon-state.js +185 -0
- package/dist/session/external-tool-coordinator.js +88 -0
- package/dist/session/external-tool-request.js +52 -0
- package/dist/session/lane-owner.js +116 -0
- package/dist/session/paths.js +71 -1
- package/dist/session/runtime-lifecycle.js +225 -0
- package/dist/session/runtime-shutdown.js +95 -0
- package/dist/session/server.js +1194 -8
- package/dist/session/session-health.js +27 -0
- package/dist/shared/agent-text.js +29 -1
- package/dist/shared/errors.js +496 -30
- package/dist/shared/event-loop.js +6 -1
- package/dist/shared/hints.js +37 -1
- package/dist/shared/metrics.js +43 -1
- package/dist/shared/presentation.js +69 -4
- package/dist/shared/stdin-examples.js +77 -3
- package/dist/shared/stdout.js +6 -2
- package/dist/shared/types.js +23 -1
- package/dist/tool-runtime/runtime-tools.js +120 -0
- package/dist/topology/availability.js +663 -0
- package/dist/topology/cache.js +130 -0
- package/dist/topology/candidates.js +372 -0
- package/dist/topology/core.js +903 -0
- package/dist/topology/dependency-snapshot.js +189 -0
- package/dist/topology/model.js +2 -0
- package/dist/topology/scope.js +100 -0
- package/dist/topology/ts-oracle-batch.js +529 -0
- package/dist/topology/ts-oracle-host.js +69 -0
- package/dist/topology/ts-oracle-model.js +2 -0
- package/dist/topology/ts-oracle.js +224 -0
- package/dist/topology/tsconfig-loader.js +105 -0
- package/dist/topology/workspace-project-index.js +542 -0
- package/dist/tracing/config.js +192 -2
- package/dist/tracing/failure-summary.js +100 -0
- package/dist/tracing/trace.js +318 -5
- package/dist/tsc-wrapper/core.js +697 -0
- package/dist/workers/control-plane/aib-control-plane-worker.cjs +80 -0
- package/dist/workers/control-plane/client-config.default.json +3 -0
- package/dist/workers/lexical-worker-child.js +27 -0
- package/dist/workers/lexical-worker-manager.js +394 -0
- package/dist/workers/lexical-worker-protocol.js +2 -0
- package/dist/workers/lexical-worker-runtime.js +25 -0
- package/dist/workers/owned-one-shot-process.js +115 -0
- package/dist/workers/product-storage.js +23 -0
- package/dist/workers/registry.js +241 -0
- package/package.json +8 -11
- package/runtimes/tools/rg/darwin-arm64/rg +0 -0
- package/runtimes/tools/rg/darwin-x64/rg +0 -0
- package/runtimes/tools/rg/linux-arm64/rg +0 -0
- package/runtimes/tools/rg/linux-x64/rg +0 -0
- package/runtimes/tools/rg/manifest.json +36 -0
- package/runtimes/tools/rg/win32-x64/rg.exe +0 -0
- package/runtimes/tools/rtk/darwin-arm64/rtk +0 -0
- package/runtimes/tools/rtk/darwin-x64/rtk +0 -0
- package/runtimes/tools/rtk/linux-arm64/rtk +0 -0
- package/runtimes/tools/rtk/linux-x64/rtk +0 -0
- package/runtimes/tools/rtk/manifest.json +36 -0
- package/runtimes/tools/rtk/win32-x64/rtk.exe +0 -0
- package/scripts/postinstall.cjs +29 -29
- package/scripts/provision-runtime.cjs +411 -459
- package/dist/client/http-client.js +0 -1
- package/dist/client/transport-options.js +0 -1
- package/dist/client/websocket-client.js +0 -1
- package/dist/commands/entity-resolution.js +0 -1
- package/dist/commands/inspect-symbol-query.js +0 -1
- package/dist/commands/list-instances.js +0 -1
- package/dist/commands/module-plan-command.js +0 -1
- package/dist/commands/move-command.js +0 -1
- package/dist/commands/move-to-file.js +0 -2
- package/dist/commands/ping.js +0 -1
- package/dist/commands/refactor-command.js +0 -1
- package/dist/commands/rename-command.js +0 -1
- package/dist/commands/runtime-command.js +0 -4
- package/dist/commands/runtime-info.js +0 -1
- package/dist/commands/validate-module-plan.js +0 -2
- package/dist/compatibility/policy.js +0 -1
- package/dist/config/auto-start-ide.js +0 -1
- package/dist/discovery/registry.js +0 -1
- package/dist/discovery/select-instance.js +0 -1
- package/dist/help/docs/mutation.md +0 -50
- package/dist/help/docs/refactor.batch.md +0 -44
- package/dist/help/dsl/docs/mutation.md +0 -50
- package/dist/help/dsl/docs/refactor.batch.md +0 -44
- package/dist/help/dsl/topics/mutation.md +0 -48
- package/dist/help/dsl/topics/refactor.batch.md +0 -33
- package/dist/help/json/bootstrap.md +0 -1085
- package/dist/help/json/docs/basics.md +0 -15
- package/dist/help/json/docs/config-setup.aliases.md +0 -56
- package/dist/help/json/docs/config-setup.excludes.md +0 -45
- package/dist/help/json/docs/config-setup.import-normalize.md +0 -86
- package/dist/help/json/docs/config-setup.import-rules.md +0 -96
- package/dist/help/json/docs/config-setup.tsconfigs.md +0 -33
- package/dist/help/json/docs/dsl.md +0 -25
- package/dist/help/json/docs/first-setup.md +0 -292
- package/dist/help/json/docs/help-format.md +0 -9
- package/dist/help/json/docs/help-protocol.md +0 -26
- package/dist/help/json/docs/imports.normalize.md +0 -47
- package/dist/help/json/docs/inspect.code.md +0 -41
- package/dist/help/json/docs/inspect.cycles.md +0 -38
- package/dist/help/json/docs/inspect.deps.md +0 -46
- package/dist/help/json/docs/inspect.duplicates.md +0 -65
- package/dist/help/json/docs/inspect.exports.md +0 -40
- package/dist/help/json/docs/inspect.file.md +0 -38
- package/dist/help/json/docs/inspect.graph.md +0 -139
- package/dist/help/json/docs/inspect.imports.md +0 -15
- package/dist/help/json/docs/inspect.md +0 -88
- package/dist/help/json/docs/inspect.members.md +0 -32
- package/dist/help/json/docs/inspect.tree.md +0 -32
- package/dist/help/json/docs/inspect.usages.md +0 -61
- package/dist/help/json/docs/modulePlan.md +0 -73
- package/dist/help/json/docs/move.md +0 -56
- package/dist/help/json/docs/mutation.md +0 -65
- package/dist/help/json/docs/patterns.md +0 -76
- package/dist/help/json/docs/prefs.md +0 -40
- package/dist/help/json/docs/qr.md +0 -37
- package/dist/help/json/docs/quick-map.md +0 -30
- package/dist/help/json/docs/refactor.batch.md +0 -72
- package/dist/help/json/docs/rename.md +0 -47
- package/dist/help/json/docs/reveal.md +0 -30
- package/dist/help/json/docs/selectors.md +0 -23
- package/dist/help/json/docs/session.md +0 -77
- package/dist/help/json/docs/view.md +0 -30
- package/dist/help/json/full.md +0 -1085
- package/dist/help/json/snippets/agents.md +0 -14
- package/dist/help/json/topics/basics.md +0 -13
- package/dist/help/json/topics/config-setup.aliases.md +0 -54
- package/dist/help/json/topics/config-setup.excludes.md +0 -43
- package/dist/help/json/topics/config-setup.import-normalize.md +0 -84
- package/dist/help/json/topics/config-setup.import-rules.md +0 -94
- package/dist/help/json/topics/config-setup.tsconfigs.md +0 -31
- package/dist/help/json/topics/dsl.md +0 -23
- package/dist/help/json/topics/first-setup.md +0 -290
- package/dist/help/json/topics/help-format.md +0 -7
- package/dist/help/json/topics/help-protocol.md +0 -24
- package/dist/help/json/topics/imports.normalize.md +0 -45
- package/dist/help/json/topics/inspect.code.md +0 -39
- package/dist/help/json/topics/inspect.cycles.md +0 -36
- package/dist/help/json/topics/inspect.deps.md +0 -44
- package/dist/help/json/topics/inspect.duplicates.md +0 -37
- package/dist/help/json/topics/inspect.exports.md +0 -38
- package/dist/help/json/topics/inspect.file.md +0 -36
- package/dist/help/json/topics/inspect.graph.md +0 -137
- package/dist/help/json/topics/inspect.imports.md +0 -13
- package/dist/help/json/topics/inspect.md +0 -86
- package/dist/help/json/topics/inspect.members.md +0 -30
- package/dist/help/json/topics/inspect.tree.md +0 -22
- package/dist/help/json/topics/inspect.usages.md +0 -59
- package/dist/help/json/topics/modulePlan.md +0 -60
- package/dist/help/json/topics/move.md +0 -46
- package/dist/help/json/topics/mutation.md +0 -63
- package/dist/help/json/topics/patterns.md +0 -74
- package/dist/help/json/topics/prefs.md +0 -38
- package/dist/help/json/topics/qr.md +0 -35
- package/dist/help/json/topics/quick-map.md +0 -28
- package/dist/help/json/topics/refactor.batch.md +0 -61
- package/dist/help/json/topics/rename.md +0 -42
- package/dist/help/json/topics/reveal.md +0 -28
- package/dist/help/json/topics/selectors.md +0 -21
- package/dist/help/json/topics/session.md +0 -59
- package/dist/help/json/topics/view.md +0 -28
- package/dist/help/topics/mutation.md +0 -48
- package/dist/help/topics/refactor.batch.md +0 -33
- package/dist/ide-launch/common.cjs +0 -162
- package/dist/managed-host/extension-vsix-resolver.js +0 -1
- package/dist/managed-host/manage-serve-web-host.cjs +0 -141
- package/dist/managed-host/serve-web-autostart.js +0 -1
- package/dist/managed-host/serve-web-host.cjs +0 -1904
- package/dist/runtime/managed-runtime-provisioning.js +0 -1
- package/dist/shared/diagnostic-catalog.js +0 -1
- package/dist/shared/diagnostics.js +0 -1
- package/dist/shared/operations.js +0 -1
- package/dist/shared/protocol.js +0 -1
- package/dist/shared/routes.js +0 -1
- package/extension/vscode-refactor-bridge-extension.vsix +0 -0
- package/runtimes/launcher/linux-x64/aib +0 -0
- package/runtimes/launcher/win-x64/aib.exe +0 -0
|
@@ -0,0 +1,982 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.analyzeAliasAdvisor = analyzeAliasAdvisor;
|
|
40
|
+
const node_crypto_1 = require("node:crypto");
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
43
|
+
const cache_1 = require("../topology/cache");
|
|
44
|
+
const core_1 = require("../topology/core");
|
|
45
|
+
const ts_oracle_host_1 = require("../topology/ts-oracle-host");
|
|
46
|
+
const tsconfig_loader_1 = require("../topology/tsconfig-loader");
|
|
47
|
+
const lexical_1 = require("./lexical");
|
|
48
|
+
const path_identity_1 = require("./path-identity");
|
|
49
|
+
const ranking_1 = require("./ranking");
|
|
50
|
+
const exact_text_cost_1 = require("./exact-text-cost");
|
|
51
|
+
const token_estimator_1 = require("./token-estimator");
|
|
52
|
+
const SOURCE_EXTENSION_RE = /\.(d\.)?[cm]?[tj]sx?$/i;
|
|
53
|
+
const GENERIC_ROOT_ALIASES = new Set(["@/*", "~/*", "#/*", "/*"]);
|
|
54
|
+
const TOKEN_ESTIMATOR = new token_estimator_1.PathLexicalV1Estimator();
|
|
55
|
+
function analyzeAliasAdvisor(input) {
|
|
56
|
+
const startedAt = Date.now();
|
|
57
|
+
const topologyStartedAt = Date.now();
|
|
58
|
+
const snapshot = input.snapshot === undefined ? (0, cache_1.getProjectTopologySnapshot)(input.cwd) : input.snapshot;
|
|
59
|
+
const topologyMs = Date.now() - topologyStartedAt;
|
|
60
|
+
const shortlistSize = Math.max(24, input.request.limit * 3);
|
|
61
|
+
const shortlisted = selectShortlist(input.lexicalEvidence, input.request.candidate, shortlistSize);
|
|
62
|
+
const resolutionStartedAt = Date.now();
|
|
63
|
+
const session = snapshot ? new ResolutionSession(snapshot) : null;
|
|
64
|
+
const resolutions = session ? resolveShortlist(shortlisted, session) : new Map();
|
|
65
|
+
const resolutionMs = Date.now() - resolutionStartedAt;
|
|
66
|
+
const analysisStartedAt = Date.now();
|
|
67
|
+
const builds = shortlisted.map((evidence) => buildCandidate(evidence, input.request, snapshot, session, resolutions));
|
|
68
|
+
applyGlobalAliasConflicts(builds);
|
|
69
|
+
const collapsed = collapseAdoptExistingBuilds(builds, input.request.candidate);
|
|
70
|
+
const ranked = (0, ranking_1.rankAliasCandidates)(collapsed);
|
|
71
|
+
const filtered = filterCandidates(ranked, input.request.candidate);
|
|
72
|
+
const visible = filtered.slice(0, input.request.limit);
|
|
73
|
+
const analysisMs = Date.now() - analysisStartedAt;
|
|
74
|
+
return {
|
|
75
|
+
ok: true,
|
|
76
|
+
op: "aliasCandidates",
|
|
77
|
+
mode: "topology-aware-advisor",
|
|
78
|
+
ranking: {
|
|
79
|
+
policyVersion: "alias-ranking-v2-text-primary",
|
|
80
|
+
estimatorProfile: TOKEN_ESTIMATOR.profile,
|
|
81
|
+
categoryCounts: countCategories(filtered)
|
|
82
|
+
},
|
|
83
|
+
decisionPolicy: {
|
|
84
|
+
version: "alias-decision-evidence-v1",
|
|
85
|
+
baseline: "keepCurrentAliases",
|
|
86
|
+
primaryMetric: "exact-text-characters",
|
|
87
|
+
minImports: ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.minImports,
|
|
88
|
+
minFiles: ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.minFiles,
|
|
89
|
+
materialNetCharacters: ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.materialNetCharacters
|
|
90
|
+
},
|
|
91
|
+
scope: input.request.displayScope,
|
|
92
|
+
scopePath: input.request.scope,
|
|
93
|
+
detail: input.request.detail,
|
|
94
|
+
...(input.request.candidate ? { candidate: input.request.candidate } : {}),
|
|
95
|
+
analyzedFiles: input.analyzedFiles,
|
|
96
|
+
analyzedSpecifiers: input.analyzedSpecifiers,
|
|
97
|
+
lexicalEvidenceCount: input.lexicalEvidence.length,
|
|
98
|
+
shortlistedEvidenceCount: shortlisted.length,
|
|
99
|
+
hiddenCandidates: Math.max(0, filtered.length - visible.length),
|
|
100
|
+
evidenceFilter: {
|
|
101
|
+
minImports: input.request.minImports,
|
|
102
|
+
minFiles: input.request.minFiles
|
|
103
|
+
},
|
|
104
|
+
resultLimit: {
|
|
105
|
+
limit: input.request.limit,
|
|
106
|
+
},
|
|
107
|
+
topology: snapshot ? {
|
|
108
|
+
available: true,
|
|
109
|
+
dependencyState: snapshot.dependencySnapshot.state,
|
|
110
|
+
tsconfigs: snapshot.tsconfigs.length,
|
|
111
|
+
packages: snapshot.packages.length,
|
|
112
|
+
diagnostics: snapshot.diagnostics.length
|
|
113
|
+
} : { available: false },
|
|
114
|
+
ownerConfigDiagnostics: session?.ownerConfigDiagnostics() ?? [],
|
|
115
|
+
candidates: visible,
|
|
116
|
+
timings: {
|
|
117
|
+
lexicalMs: input.lexicalMs,
|
|
118
|
+
topologyMs,
|
|
119
|
+
resolutionMs,
|
|
120
|
+
analysisMs,
|
|
121
|
+
totalMs: Date.now() - startedAt + input.lexicalMs
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function selectShortlist(evidence, requested, limit) {
|
|
126
|
+
const selected = evidence.slice(0, limit);
|
|
127
|
+
for (const item of evidence) {
|
|
128
|
+
if (requested && (item.prefix === requested || item.suggestedAliases.includes(requested)) && !selected.includes(item)) {
|
|
129
|
+
selected.push(item);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const selectedAliases = new Set(selected.flatMap((item) => item.suggestedAliases));
|
|
133
|
+
for (const item of evidence) {
|
|
134
|
+
if (!selected.includes(item) && item.suggestedAliases.some((alias) => selectedAliases.has(alias))) {
|
|
135
|
+
selected.push(item);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return selected;
|
|
139
|
+
}
|
|
140
|
+
function resolveShortlist(shortlist, session) {
|
|
141
|
+
const result = new Map();
|
|
142
|
+
for (const occurrence of uniqueOccurrences(shortlist.flatMap((item) => item.occurrences))) {
|
|
143
|
+
result.set(occurrenceKey(occurrence), session.resolve(occurrence));
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
function buildCandidate(evidence, request, snapshot, session, resolutionsByKey) {
|
|
148
|
+
const resolutions = evidence.occurrences.map((occurrence) => resolutionsByKey.get(occurrenceKey(occurrence)) ?? unresolvedWithoutTopology(occurrence));
|
|
149
|
+
const requestedAlias = request.candidate && evidence.suggestedAliases.includes(request.candidate) ? request.candidate : undefined;
|
|
150
|
+
const requestedExistingAlias = request.candidate === evidence.prefix ? undefined : request.candidate;
|
|
151
|
+
const targetRoots = uniqueCanonicalPaths(resolutions
|
|
152
|
+
.filter((item) => item.status === "resolvedInternal" && item.targetFile)
|
|
153
|
+
.map((item) => deriveTargetRoot(item, evidence.prefix))
|
|
154
|
+
.filter((item) => item !== null));
|
|
155
|
+
const specificExistingAlias = snapshot && session
|
|
156
|
+
? findSharedExistingAlias(snapshot, session, resolutions, requestedExistingAlias)
|
|
157
|
+
: null;
|
|
158
|
+
const alias = requestedAlias ?? specificExistingAlias?.pattern ?? evidence.suggestedAliases[0] ?? "<alias>";
|
|
159
|
+
const intent = !snapshot
|
|
160
|
+
? "rejectedEvidence"
|
|
161
|
+
: specificExistingAlias
|
|
162
|
+
? "adoptExistingAlias"
|
|
163
|
+
: "createAlias";
|
|
164
|
+
const conflicts = [];
|
|
165
|
+
const coverage = {
|
|
166
|
+
imports: evidence.importCount,
|
|
167
|
+
files: evidence.importingFileCount,
|
|
168
|
+
resolvedInternal: resolutions.filter((item) => item.status === "resolvedInternal").length,
|
|
169
|
+
resolvedExternal: resolutions.filter((item) => item.status === "resolvedExternal").length,
|
|
170
|
+
unresolved: resolutions.filter((item) => item.status === "unresolved").length,
|
|
171
|
+
noOwningTsconfig: resolutions.filter((item) => item.status === "noOwningTsconfig").length
|
|
172
|
+
};
|
|
173
|
+
if (!snapshot || coverage.resolvedInternal !== coverage.imports) {
|
|
174
|
+
conflicts.push({
|
|
175
|
+
code: "coverage_incomplete",
|
|
176
|
+
message: !snapshot
|
|
177
|
+
? "Topology is unavailable; covered occurrences were not resolved."
|
|
178
|
+
: `Only ${coverage.resolvedInternal}/${coverage.imports} covered occurrences resolved to internal targets.`,
|
|
179
|
+
files: unique(resolutions.filter((item) => item.status !== "resolvedInternal").map((item) => item.displayImporter)).slice(0, 8)
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const divergent = resolutions.filter(ownerResolutionsDiverge);
|
|
183
|
+
if (divergent.length > 0) {
|
|
184
|
+
conflicts.push({
|
|
185
|
+
code: "owning_tsconfig_resolution_divergence",
|
|
186
|
+
message: `${divergent.length} covered occurrence(s) resolve differently across owning tsconfigs.`,
|
|
187
|
+
files: unique(divergent.map((item) => item.displayImporter)).slice(0, 8)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (targetRoots.length === 0) {
|
|
191
|
+
conflicts.push({
|
|
192
|
+
code: "target_root_unproven",
|
|
193
|
+
message: "No single target root could be derived from resolved imports."
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (targetRoots.length > 1) {
|
|
197
|
+
conflicts.push({
|
|
198
|
+
code: "source_prefix_multiple_targets",
|
|
199
|
+
message: "The same lexical prefix resolves to multiple target roots.",
|
|
200
|
+
targets: targetRoots.map((item) => toDisplayPath(snapshot?.root ?? request.scope, item))
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (specificExistingAlias && !specificExistingAlias.compatible) {
|
|
204
|
+
conflicts.push({
|
|
205
|
+
code: "incompatible_mapping_across_tsconfigs",
|
|
206
|
+
message: `${specificExistingAlias.pattern} requires different import specifiers across owning tsconfigs.`
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const targetRoot = targetRoots.length === 1 ? targetRoots[0] : undefined;
|
|
210
|
+
const applicableTsconfigs = snapshot && session
|
|
211
|
+
? buildApplicableTsconfigs(snapshot, session, evidence, resolutions, alias, targetRoot, intent, specificExistingAlias?.specifiersByOccurrence, conflicts)
|
|
212
|
+
: [];
|
|
213
|
+
const owningTsconfigs = unique(resolutions.flatMap((resolution) => resolution.owningTsconfigs.map((owner) => owner.tsconfig)));
|
|
214
|
+
const simulatedTsconfigs = new Set(applicableTsconfigs.map((config) => config.tsconfig));
|
|
215
|
+
if (owningTsconfigs.some((tsconfig) => !simulatedTsconfigs.has(tsconfig))
|
|
216
|
+
|| applicableTsconfigs.some((config) => config.simulation === "failed" || config.simulation === "notRun")) {
|
|
217
|
+
conflicts.push({
|
|
218
|
+
code: "simulation_incomplete",
|
|
219
|
+
message: "Not every owning tsconfig proved a compatible alias mapping.",
|
|
220
|
+
targets: owningTsconfigs.filter((tsconfig) => !simulatedTsconfigs.has(tsconfig))
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (snapshot && targetRoot) {
|
|
224
|
+
addPackageAndRuntimeConflicts(snapshot, resolutions, alias, intent, conflicts);
|
|
225
|
+
}
|
|
226
|
+
const projectedSpecifiers = resolutions.map((resolution, index) => {
|
|
227
|
+
const occurrence = evidence.occurrences[index];
|
|
228
|
+
if (intent === "adoptExistingAlias" && snapshot && session && resolution.targetFile) {
|
|
229
|
+
return specificExistingAlias?.specifiersByOccurrence.get(occurrenceKey(occurrence)) ?? occurrence.specifier;
|
|
230
|
+
}
|
|
231
|
+
return (0, lexical_1.rewriteSpecifier)(occurrence.specifier, evidence.prefix, alias);
|
|
232
|
+
});
|
|
233
|
+
const boundaryReasons = boundaryRiskReasons(resolutions);
|
|
234
|
+
const runtimeReasons = runtimeRiskReasons(applicableTsconfigs, alias, intent);
|
|
235
|
+
const disposition = conflicts.length > 0 ? "rejected" : snapshot ? "eligibleForRanking" : "rawEvidence";
|
|
236
|
+
const confidence = confidenceFor(disposition, intent, runtimeReasons);
|
|
237
|
+
const occurrenceIds = evidence.occurrences.map(occurrenceKey);
|
|
238
|
+
const tokenEstimate = (0, token_estimator_1.estimateAliasTokenCost)({
|
|
239
|
+
estimator: TOKEN_ESTIMATOR,
|
|
240
|
+
intent,
|
|
241
|
+
alias,
|
|
242
|
+
occurrenceIds,
|
|
243
|
+
currentSpecifiers: evidence.occurrences.map((occurrence) => occurrence.specifier),
|
|
244
|
+
projectedSpecifiers,
|
|
245
|
+
applicableTsconfigs,
|
|
246
|
+
...deriveResolverMirrorEstimate(snapshot, resolutions, targetRoot, alias, conflicts)
|
|
247
|
+
});
|
|
248
|
+
const exactTextEstimate = (0, exact_text_cost_1.estimateAliasExactTextCost)({
|
|
249
|
+
intent,
|
|
250
|
+
alias,
|
|
251
|
+
occurrenceIds,
|
|
252
|
+
currentLiterals: evidence.occurrences.map((occurrence) => occurrence.literal),
|
|
253
|
+
currentSpecifiers: evidence.occurrences.map((occurrence) => occurrence.specifier),
|
|
254
|
+
projectedSpecifiers,
|
|
255
|
+
applicableTsconfigs,
|
|
256
|
+
...deriveResolverMirrorEstimate(snapshot, resolutions, targetRoot, alias, conflicts)
|
|
257
|
+
});
|
|
258
|
+
const targetPattern = intent === "adoptExistingAlias"
|
|
259
|
+
? specificExistingAlias?.targets.join(", ")
|
|
260
|
+
: targetRoot && snapshot
|
|
261
|
+
? `${toDisplayPath(snapshot.root, targetRoot)}/*`
|
|
262
|
+
: undefined;
|
|
263
|
+
const candidate = {
|
|
264
|
+
id: candidateId(evidence.prefix, alias, targetPattern ?? "unresolved"),
|
|
265
|
+
sourcePrefix: evidence.prefix,
|
|
266
|
+
alias,
|
|
267
|
+
...(targetPattern ? { targetPattern } : {}),
|
|
268
|
+
intent,
|
|
269
|
+
disposition,
|
|
270
|
+
coverage,
|
|
271
|
+
applicableTsconfigs,
|
|
272
|
+
sourceCost: {
|
|
273
|
+
metric: "characters",
|
|
274
|
+
current: exactTextEstimate.cost.sourceLiterals.current,
|
|
275
|
+
projected: exactTextEstimate.cost.sourceLiterals.projected,
|
|
276
|
+
delta: exactTextEstimate.cost.sourceLiterals.reduction
|
|
277
|
+
},
|
|
278
|
+
decisionEvidence: decisionEvidenceFor({
|
|
279
|
+
disposition,
|
|
280
|
+
coverage,
|
|
281
|
+
exactText: exactTextEstimate.cost,
|
|
282
|
+
conflicts
|
|
283
|
+
}),
|
|
284
|
+
tokenCost: tokenEstimate.cost,
|
|
285
|
+
ranking: {
|
|
286
|
+
policyVersion: "alias-ranking-v2-text-primary",
|
|
287
|
+
category: "rejected",
|
|
288
|
+
ordinal: 0,
|
|
289
|
+
score: 0,
|
|
290
|
+
scoreComponents: {
|
|
291
|
+
exactNetTextReduction: exactTextEstimate.cost.netReduction.absolute,
|
|
292
|
+
imports: coverage.imports,
|
|
293
|
+
files: coverage.files,
|
|
294
|
+
confidence: confidence.level,
|
|
295
|
+
estimatorConfidence: tokenEstimate.cost.profile.confidence
|
|
296
|
+
},
|
|
297
|
+
reasons: ["ranking pending candidate-set overlap analysis"]
|
|
298
|
+
},
|
|
299
|
+
conflicts,
|
|
300
|
+
boundaryRisk: {
|
|
301
|
+
level: boundaryReasons.length > 0 ? "high" : "low",
|
|
302
|
+
reasons: boundaryReasons
|
|
303
|
+
},
|
|
304
|
+
runtimeRisk: {
|
|
305
|
+
level: runtimeReasons.length > 0 ? (conflicts.some((item) => item.code === "runtime_resolver_mismatch") ? "high" : "unknown") : "low",
|
|
306
|
+
reasons: runtimeReasons
|
|
307
|
+
},
|
|
308
|
+
confidence,
|
|
309
|
+
examples: evidence.occurrences.slice(0, request.detail === "examples" ? 8 : 3).map((occurrence, index) => {
|
|
310
|
+
const resolution = resolutions[index];
|
|
311
|
+
return {
|
|
312
|
+
importer: occurrence.displayImporter,
|
|
313
|
+
from: occurrence.specifier,
|
|
314
|
+
...(projectedSpecifiers[index] && projectedSpecifiers[index] !== occurrence.specifier ? { to: projectedSpecifiers[index] } : {}),
|
|
315
|
+
...(resolution?.targetFile && snapshot ? { targetFile: toDisplayPath(snapshot.root, resolution.targetFile) } : {})
|
|
316
|
+
};
|
|
317
|
+
}),
|
|
318
|
+
overlap: {
|
|
319
|
+
parents: [],
|
|
320
|
+
children: [],
|
|
321
|
+
exclusiveImports: 0,
|
|
322
|
+
exclusiveTextReduction: 0,
|
|
323
|
+
marginalImports: 0,
|
|
324
|
+
marginalTextReduction: 0,
|
|
325
|
+
marginalNetTextReduction: 0,
|
|
326
|
+
marginalTokenSaving: 0
|
|
327
|
+
},
|
|
328
|
+
importNormalizeFollowUp: conflicts.length > 0 ? {
|
|
329
|
+
status: "blocked",
|
|
330
|
+
reason: conflicts[0]?.message ?? "Candidate is blocked."
|
|
331
|
+
} : intent === "adoptExistingAlias" ? {
|
|
332
|
+
status: "adoptExisting",
|
|
333
|
+
preferAlias: alias
|
|
334
|
+
} : {
|
|
335
|
+
status: "eligibleAfterConfig",
|
|
336
|
+
preferAlias: alias
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
return {
|
|
340
|
+
candidate,
|
|
341
|
+
occurrenceSavings: tokenEstimate.occurrenceSavings,
|
|
342
|
+
exactTextOccurrenceSavings: exactTextEstimate.occurrenceSavings,
|
|
343
|
+
...(targetRoot ? { targetRoot } : {})
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function decisionEvidenceFor(input) {
|
|
347
|
+
const meetsThreshold = input.coverage.imports >= ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.minImports
|
|
348
|
+
&& input.coverage.files >= ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.minFiles;
|
|
349
|
+
const eligible = input.disposition === "eligibleForRanking" && input.conflicts.length === 0;
|
|
350
|
+
const material = input.exactText.netReduction.absolute >= ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.materialNetCharacters;
|
|
351
|
+
const winsKeepCurrentAliases = eligible && meetsThreshold && material;
|
|
352
|
+
const outcome = !eligible ? "blocked" : winsKeepCurrentAliases ? "materialImprovement" : "noConfidentImprovement";
|
|
353
|
+
const reasons = !eligible
|
|
354
|
+
? ["M2 technical eligibility did not clear; keep current aliases."]
|
|
355
|
+
: !meetsThreshold
|
|
356
|
+
? ["Candidate is below provisional breadth thresholds; keep current aliases."]
|
|
357
|
+
: !material
|
|
358
|
+
? ["Exact net text reduction is below the provisional material threshold; keep current aliases."]
|
|
359
|
+
: ["Exact text reduction clears the provisional do-nothing baseline."];
|
|
360
|
+
return {
|
|
361
|
+
version: "alias-decision-evidence-v1",
|
|
362
|
+
baseline: "keepCurrentAliases",
|
|
363
|
+
primaryMetric: "exact-text-characters",
|
|
364
|
+
breadth: {
|
|
365
|
+
occurrences: input.coverage.imports,
|
|
366
|
+
files: input.coverage.files,
|
|
367
|
+
meetsThreshold
|
|
368
|
+
},
|
|
369
|
+
materialNetCharacters: ranking_1.PROVISIONAL_ALIAS_TEXT_DECISION_THRESHOLDS.materialNetCharacters,
|
|
370
|
+
exactText: input.exactText,
|
|
371
|
+
winsKeepCurrentAliases,
|
|
372
|
+
outcome,
|
|
373
|
+
reasons
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function buildApplicableTsconfigs(snapshot, session, evidence, resolutions, alias, targetRoot, intent, existingSpecifiersByOccurrence, conflicts) {
|
|
377
|
+
const byConfig = new Map();
|
|
378
|
+
resolutions.forEach((resolution, index) => {
|
|
379
|
+
for (const owner of resolution.owningTsconfigs) {
|
|
380
|
+
byConfig.set(owner.tsconfig, [...(byConfig.get(owner.tsconfig) ?? []), { index, owner }]);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
const result = [];
|
|
384
|
+
for (const [tsconfig, entries] of byConfig) {
|
|
385
|
+
const configSnapshot = snapshot.tsconfigs.find((item) => item.file === tsconfig);
|
|
386
|
+
const parsed = session.parsedConfig(tsconfig);
|
|
387
|
+
const files = unique(entries.map(({ index }) => evidence.occurrences[index].displayImporter));
|
|
388
|
+
if (!configSnapshot || !parsed || !targetRoot) {
|
|
389
|
+
result.push({ tsconfig, coveredImports: entries.length, coveredFiles: files.length, simulation: "notRun" });
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const mappingTarget = mappingTargetFor(snapshot.root, configSnapshot, targetRoot);
|
|
393
|
+
const exactMapping = configSnapshot.paths.find((mapping) => mapping.pattern === alias);
|
|
394
|
+
if (exactMapping && intent === "createAlias") {
|
|
395
|
+
const exactWorks = entries.every(({ index, owner }) => {
|
|
396
|
+
const occurrence = evidence.occurrences[index];
|
|
397
|
+
const rewritten = (0, lexical_1.rewriteSpecifier)(occurrence.specifier, evidence.prefix, alias);
|
|
398
|
+
const simulated = session.resolveSpecifier(parsed, occurrence.importer, rewritten);
|
|
399
|
+
return owner.targetFile && simulated && (0, path_identity_1.sameCanonicalPath)(simulated, owner.targetFile);
|
|
400
|
+
});
|
|
401
|
+
if (!exactWorks) {
|
|
402
|
+
conflicts.push({
|
|
403
|
+
code: "existing_paths_collision",
|
|
404
|
+
message: `${alias} already maps to a different target in ${tsconfig}.`,
|
|
405
|
+
tsconfig,
|
|
406
|
+
targets: exactMapping.targets
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
result.push({
|
|
410
|
+
tsconfig,
|
|
411
|
+
coveredImports: entries.length,
|
|
412
|
+
coveredFiles: files.length,
|
|
413
|
+
mappingTarget,
|
|
414
|
+
existingAlias: alias,
|
|
415
|
+
simulation: exactWorks ? "existing" : "failed"
|
|
416
|
+
});
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (intent === "adoptExistingAlias") {
|
|
420
|
+
const existingWorks = entries.every(({ index, owner }) => {
|
|
421
|
+
const occurrence = evidence.occurrences[index];
|
|
422
|
+
const rewritten = existingSpecifiersByOccurrence?.get(occurrenceKey(occurrence));
|
|
423
|
+
return owner.targetFile && rewritten
|
|
424
|
+
&& (0, path_identity_1.sameCanonicalPath)(session.resolveSpecifier(parsed, occurrence.importer, rewritten) ?? "", owner.targetFile);
|
|
425
|
+
});
|
|
426
|
+
if (!existingWorks) {
|
|
427
|
+
conflicts.push({
|
|
428
|
+
code: "proposed_mapping_target_mismatch",
|
|
429
|
+
message: `${alias} did not resolve to the original targets in ${tsconfig}.`,
|
|
430
|
+
tsconfig,
|
|
431
|
+
files: files.slice(0, 8)
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
result.push({
|
|
435
|
+
tsconfig,
|
|
436
|
+
coveredImports: entries.length,
|
|
437
|
+
coveredFiles: files.length,
|
|
438
|
+
mappingTarget,
|
|
439
|
+
existingAlias: alias,
|
|
440
|
+
simulation: existingWorks ? "existing" : "failed"
|
|
441
|
+
});
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const outcomes = entries.map(({ index, owner }) => {
|
|
445
|
+
const occurrence = evidence.occurrences[index];
|
|
446
|
+
const rewritten = (0, lexical_1.rewriteSpecifier)(occurrence.specifier, evidence.prefix, alias);
|
|
447
|
+
const simulated = session.resolveWithProposedMapping(parsed, configSnapshot, occurrence.importer, rewritten, alias, mappingTarget);
|
|
448
|
+
return { owner, simulated, occurrence };
|
|
449
|
+
});
|
|
450
|
+
const unresolved = outcomes.filter((item) => !item.simulated);
|
|
451
|
+
const mismatched = outcomes.filter((item) => item.simulated && (!item.owner.targetFile || !(0, path_identity_1.sameCanonicalPath)(item.owner.targetFile, item.simulated)));
|
|
452
|
+
if (unresolved.length > 0) {
|
|
453
|
+
conflicts.push({
|
|
454
|
+
code: "proposed_mapping_unresolved",
|
|
455
|
+
message: `${alias} did not resolve for ${unresolved.length} covered occurrence(s) in ${tsconfig}.`,
|
|
456
|
+
tsconfig,
|
|
457
|
+
files: unique(unresolved.map((item) => item.occurrence.displayImporter)).slice(0, 8)
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
if (mismatched.length > 0) {
|
|
461
|
+
conflicts.push({
|
|
462
|
+
code: "proposed_mapping_target_mismatch",
|
|
463
|
+
message: `${alias} resolved to a different target for ${mismatched.length} covered occurrence(s) in ${tsconfig}.`,
|
|
464
|
+
tsconfig,
|
|
465
|
+
targets: uniqueCanonicalPaths(mismatched.flatMap((item) => [item.owner.targetFile ?? "", item.simulated ?? ""]).filter(Boolean)).slice(0, 8)
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
result.push({
|
|
469
|
+
tsconfig,
|
|
470
|
+
coveredImports: entries.length,
|
|
471
|
+
coveredFiles: files.length,
|
|
472
|
+
mappingTarget,
|
|
473
|
+
simulation: unresolved.length === 0 && mismatched.length === 0 ? "resolved" : "failed"
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return result.sort((left, right) => left.tsconfig.localeCompare(right.tsconfig));
|
|
477
|
+
}
|
|
478
|
+
function addPackageAndRuntimeConflicts(snapshot, resolutions, alias, intent, conflicts) {
|
|
479
|
+
const aliasRoot = alias.replace(/\/\*$/, "");
|
|
480
|
+
const packageNames = new Set(snapshot.packages.flatMap((pkg) => [pkg.name, ...pkg.dependencies]).filter((item) => Boolean(item)));
|
|
481
|
+
if (intent === "createAlias" && packageNames.has(aliasRoot)) {
|
|
482
|
+
conflicts.push({
|
|
483
|
+
code: "package_name_collision",
|
|
484
|
+
message: `${aliasRoot} collides with a workspace or dependency package name.`
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
const consumerPackages = unique(resolutions.map((item) => item.packageRoot).filter((item) => Boolean(item)))
|
|
488
|
+
.map((root) => snapshot.packages.find((pkg) => toDisplayPath(snapshot.root, pkg.root) === root))
|
|
489
|
+
.filter((item) => Boolean(item));
|
|
490
|
+
if (intent === "createAlias" && consumerPackages.some((pkg) => packageImportsOverlap(pkg, alias))) {
|
|
491
|
+
conflicts.push({
|
|
492
|
+
code: "package_imports_collision",
|
|
493
|
+
message: `${alias} overlaps an existing package.json imports key.`
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
const crossPackage = resolutions.some((item) => item.status === "resolvedInternal" && Boolean(item.targetPackageRoot) && item.packageRoot !== item.targetPackageRoot);
|
|
497
|
+
if (crossPackage && intent === "createAlias") {
|
|
498
|
+
conflicts.push({
|
|
499
|
+
code: "private_cross_package_boundary",
|
|
500
|
+
message: "A new tsconfig alias would bypass a package dependency/exports boundary."
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
const nodeStyleConfigs = unique(resolutions.flatMap((item) => item.owningTsconfigs.map((owner) => owner.tsconfig)))
|
|
504
|
+
.map((file) => snapshot.tsconfigs.find((config) => config.file === file))
|
|
505
|
+
.filter((item) => Boolean(item))
|
|
506
|
+
.filter((config) => /node16|nodenext/i.test(`${config.module ?? ""} ${config.moduleResolution ?? ""}`));
|
|
507
|
+
if (intent === "createAlias" && alias.startsWith("#") && nodeStyleConfigs.length > 0 && !consumerPackages.every((pkg) => packageImportsOverlap(pkg, alias))) {
|
|
508
|
+
conflicts.push({
|
|
509
|
+
code: "runtime_resolver_mismatch",
|
|
510
|
+
message: `${alias} is not mirrored by package.json imports for Node-style resolution.`
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function deriveResolverMirrorEstimate(snapshot, resolutions, targetRoot, alias, conflicts) {
|
|
515
|
+
if (!snapshot || !targetRoot || !alias.startsWith("#") || !conflicts.some((item) => item.code === "runtime_resolver_mismatch")) {
|
|
516
|
+
return {};
|
|
517
|
+
}
|
|
518
|
+
const packageRoots = uniqueCanonicalPaths(resolutions
|
|
519
|
+
.map((resolution) => resolution.packageRoot)
|
|
520
|
+
.filter((item) => Boolean(item))
|
|
521
|
+
.map((item) => path.resolve(snapshot.root, item)));
|
|
522
|
+
if (packageRoots.length !== 1) {
|
|
523
|
+
return {};
|
|
524
|
+
}
|
|
525
|
+
const relative = path.relative(packageRoots[0], targetRoot).replace(/\\/g, "/");
|
|
526
|
+
if (relative.startsWith("../") || path.isAbsolute(relative)) {
|
|
527
|
+
return {};
|
|
528
|
+
}
|
|
529
|
+
return { resolverMirror: { target: `./${relative.replace(/^\.\//, "").replace(/\/$/, "")}/*` } };
|
|
530
|
+
}
|
|
531
|
+
function applyGlobalAliasConflicts(builds) {
|
|
532
|
+
const byAlias = new Map();
|
|
533
|
+
for (const build of builds.filter((item) => item.candidate.intent === "createAlias")) {
|
|
534
|
+
byAlias.set(build.candidate.alias, [...(byAlias.get(build.candidate.alias) ?? []), build]);
|
|
535
|
+
}
|
|
536
|
+
for (const [alias, group] of byAlias) {
|
|
537
|
+
const targets = unique(group.map((item) => item.targetRoot).filter((item) => Boolean(item)));
|
|
538
|
+
if (targets.length <= 1) {
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
for (const build of group) {
|
|
542
|
+
build.candidate.conflicts.push({
|
|
543
|
+
code: "alias_multiple_targets",
|
|
544
|
+
message: `${alias} is proposed for multiple target roots.`,
|
|
545
|
+
targets
|
|
546
|
+
});
|
|
547
|
+
build.candidate.disposition = "rejected";
|
|
548
|
+
build.candidate.confidence = { level: "low", reasons: ["hard conflict: alias maps to multiple targets"] };
|
|
549
|
+
build.candidate.importNormalizeFollowUp = { status: "blocked", reason: `${alias} maps to multiple targets.` };
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function collapseAdoptExistingBuilds(builds, requested) {
|
|
554
|
+
if (requested) {
|
|
555
|
+
return builds;
|
|
556
|
+
}
|
|
557
|
+
const bestByAliasAndTarget = new Map();
|
|
558
|
+
const result = [];
|
|
559
|
+
for (const build of builds) {
|
|
560
|
+
const candidate = build.candidate;
|
|
561
|
+
if (candidate.intent !== "adoptExistingAlias") {
|
|
562
|
+
result.push(build);
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
const key = `${candidate.alias}\0${candidate.targetPattern ?? ""}`;
|
|
566
|
+
const current = bestByAliasAndTarget.get(key);
|
|
567
|
+
if (!current || isBroaderEvidence(candidate, current.candidate)) {
|
|
568
|
+
bestByAliasAndTarget.set(key, build);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
result.push(...bestByAliasAndTarget.values());
|
|
572
|
+
return result;
|
|
573
|
+
}
|
|
574
|
+
function isBroaderEvidence(candidate, current) {
|
|
575
|
+
return candidate.coverage.imports > current.coverage.imports
|
|
576
|
+
|| (candidate.coverage.imports === current.coverage.imports && candidate.coverage.files > current.coverage.files)
|
|
577
|
+
|| (candidate.coverage.imports === current.coverage.imports
|
|
578
|
+
&& candidate.coverage.files === current.coverage.files
|
|
579
|
+
&& candidate.sourcePrefix.length < current.sourcePrefix.length);
|
|
580
|
+
}
|
|
581
|
+
function findSharedExistingAlias(snapshot, session, resolutions, requestedAlias) {
|
|
582
|
+
if (resolutions.length === 0 || resolutions.some((item) => item.status !== "resolvedInternal" || item.owningTsconfigs.length === 0)) {
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
const patternsPerConfig = new Map();
|
|
586
|
+
for (const resolution of resolutions) {
|
|
587
|
+
for (const owner of resolution.owningTsconfigs) {
|
|
588
|
+
const config = snapshot.tsconfigs.find((item) => item.file === owner.tsconfig);
|
|
589
|
+
const parsed = session.parsedConfig(owner.tsconfig);
|
|
590
|
+
if (!config || !parsed || owner.status !== "resolvedInternal" || !owner.targetFile) {
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
const valid = config.paths
|
|
594
|
+
.filter((mapping) => !GENERIC_ROOT_ALIASES.has(mapping.pattern) && mapping.pattern.includes("*"))
|
|
595
|
+
.filter((mapping) => !requestedAlias || mapping.pattern === requestedAlias)
|
|
596
|
+
.filter((mapping) => {
|
|
597
|
+
const specifier = specifierForMapping(snapshot.root, mapping, owner.targetFile);
|
|
598
|
+
const resolved = specifier ? session.resolveSpecifier(parsed, resolution.importer, specifier) : null;
|
|
599
|
+
return resolved !== null && (0, path_identity_1.sameCanonicalPath)(resolved, owner.targetFile);
|
|
600
|
+
})
|
|
601
|
+
.map((mapping) => mapping.pattern);
|
|
602
|
+
const current = patternsPerConfig.get(config.file);
|
|
603
|
+
patternsPerConfig.set(config.file, current ? intersect(current, new Set(valid)) : new Set(valid));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
const sets = [...patternsPerConfig.values()];
|
|
607
|
+
const shared = sets.length > 0 ? sets.slice(1).reduce((result, current) => intersect(result, current), new Set(sets[0])) : new Set();
|
|
608
|
+
const pattern = [...shared].sort((left, right) => right.replace("*", "").length - left.replace("*", "").length || left.localeCompare(right))[0];
|
|
609
|
+
if (!pattern) {
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
const targets = unique(snapshot.tsconfigs.flatMap((config) => config.paths.filter((mapping) => mapping.pattern === pattern).flatMap((mapping) => mapping.targets)));
|
|
613
|
+
const specifiersByOccurrence = new Map();
|
|
614
|
+
let compatible = true;
|
|
615
|
+
for (const resolution of resolutions) {
|
|
616
|
+
const specifiers = resolution.owningTsconfigs.map((owner) => {
|
|
617
|
+
const mapping = snapshot.tsconfigs.find((config) => config.file === owner.tsconfig)?.paths.find((item) => item.pattern === pattern);
|
|
618
|
+
return mapping && owner.targetFile ? specifierForMapping(snapshot.root, mapping, owner.targetFile) : null;
|
|
619
|
+
});
|
|
620
|
+
const exactSpecifiers = unique(specifiers.filter((item) => item !== null));
|
|
621
|
+
if (exactSpecifiers.length !== 1 || specifiers.some((item) => item === null)) {
|
|
622
|
+
compatible = false;
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
const exactSpecifier = exactSpecifiers[0];
|
|
626
|
+
const confirmedByAllOwners = resolution.owningTsconfigs.every((owner) => {
|
|
627
|
+
const parsed = session.parsedConfig(owner.tsconfig);
|
|
628
|
+
const resolved = parsed ? session.resolveSpecifier(parsed, resolution.importer, exactSpecifier) : null;
|
|
629
|
+
return owner.targetFile && resolved && (0, path_identity_1.sameCanonicalPath)(resolved, owner.targetFile);
|
|
630
|
+
});
|
|
631
|
+
if (!confirmedByAllOwners) {
|
|
632
|
+
compatible = false;
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
specifiersByOccurrence.set(occurrenceKey(resolution), exactSpecifier);
|
|
636
|
+
}
|
|
637
|
+
return { pattern, targets, compatible, specifiersByOccurrence };
|
|
638
|
+
}
|
|
639
|
+
function deriveTargetRoot(resolution, prefix) {
|
|
640
|
+
if (!resolution.targetFile || !resolution.specifier.startsWith(prefix)) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
const suffix = withoutSourceExtension(resolution.specifier.slice(prefix.length)).replace(/^\/+/, "");
|
|
644
|
+
const target = withoutSourceExtension(resolution.targetFile).replace(/\\/g, "/");
|
|
645
|
+
if (!suffix || !target.toLowerCase().endsWith(`/${suffix.toLowerCase()}`)) {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
return path.resolve(target.slice(0, -(suffix.length + 1)));
|
|
649
|
+
}
|
|
650
|
+
function mappingTargetFor(workspaceRoot, config, targetRoot) {
|
|
651
|
+
const relative = path.relative(path.resolve(workspaceRoot, config.baseUrl), targetRoot).replace(/\\/g, "/") || ".";
|
|
652
|
+
return `${relative.replace(/\/$/, "")}/*`;
|
|
653
|
+
}
|
|
654
|
+
function specifierForMapping(workspaceRoot, mapping, targetFile) {
|
|
655
|
+
if (!mapping.pattern.includes("*")) {
|
|
656
|
+
return null;
|
|
657
|
+
}
|
|
658
|
+
for (const rawTarget of mapping.targets) {
|
|
659
|
+
const star = rawTarget.indexOf("*");
|
|
660
|
+
if (star < 0) {
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
const prefix = path.resolve(workspaceRoot, mapping.baseUrl, rawTarget.slice(0, star));
|
|
664
|
+
const suffix = withoutSourceExtension(rawTarget.slice(star + 1)).replace(/^[/\\]/, "");
|
|
665
|
+
const target = withoutSourceExtension(path.resolve(targetFile));
|
|
666
|
+
const relative = path.relative(prefix, target).replace(/\\/g, "/");
|
|
667
|
+
if (relative.startsWith("..") || path.isAbsolute(relative) || (suffix && !relative.endsWith(suffix))) {
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
const wildcard = suffix ? relative.slice(0, -suffix.length).replace(/\/$/, "") : relative;
|
|
671
|
+
return mapping.pattern.replace("*", wildcard);
|
|
672
|
+
}
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
function boundaryRiskReasons(resolutions) {
|
|
676
|
+
return unique(resolutions
|
|
677
|
+
.filter((item) => item.status === "resolvedInternal" && Boolean(item.targetPackageRoot) && item.packageRoot !== item.targetPackageRoot)
|
|
678
|
+
.map((item) => `${item.packageRoot ?? "workspace"} -> ${item.targetPackageRoot ?? "workspace"}`));
|
|
679
|
+
}
|
|
680
|
+
function runtimeRiskReasons(configs, alias, intent) {
|
|
681
|
+
if (intent === "adoptExistingAlias") {
|
|
682
|
+
return [];
|
|
683
|
+
}
|
|
684
|
+
const reasons = ["non-TypeScript runtime/bundler resolver support is not proven in M2"];
|
|
685
|
+
if (alias.startsWith("#")) {
|
|
686
|
+
reasons.push("# alias may require matching package.json imports");
|
|
687
|
+
}
|
|
688
|
+
if (configs.length > 1) {
|
|
689
|
+
reasons.push("mapping must remain consistent across multiple tsconfigs");
|
|
690
|
+
}
|
|
691
|
+
return reasons;
|
|
692
|
+
}
|
|
693
|
+
function confidenceFor(disposition, intent, runtimeReasons) {
|
|
694
|
+
if (disposition === "rejected" || disposition === "rawEvidence") {
|
|
695
|
+
return { level: "low", reasons: [disposition === "rejected" ? "hard conflict or incomplete coverage" : "topology evidence unavailable"] };
|
|
696
|
+
}
|
|
697
|
+
if (intent === "adoptExistingAlias" && runtimeReasons.length === 0) {
|
|
698
|
+
return { level: "high", reasons: ["all covered occurrences resolve through an existing TS alias"] };
|
|
699
|
+
}
|
|
700
|
+
return { level: "medium", reasons: ["all covered occurrences resolve, but runtime resolver support is pending"] };
|
|
701
|
+
}
|
|
702
|
+
function filterCandidates(candidates, requested) {
|
|
703
|
+
if (!requested) {
|
|
704
|
+
return candidates;
|
|
705
|
+
}
|
|
706
|
+
return candidates.filter((candidate) => candidate.sourcePrefix === requested || candidate.alias === requested);
|
|
707
|
+
}
|
|
708
|
+
function countCategories(candidates) {
|
|
709
|
+
const counts = { recommended: 0, review: 0, optional: 0, rejected: 0 };
|
|
710
|
+
for (const candidate of candidates) {
|
|
711
|
+
counts[candidate.ranking.category] += 1;
|
|
712
|
+
}
|
|
713
|
+
return counts;
|
|
714
|
+
}
|
|
715
|
+
function packageImportsOverlap(pkg, alias) {
|
|
716
|
+
if (!pkg.imports) {
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
return Object.keys(pkg.imports).some((key) => pathPatternOverlaps(key, alias));
|
|
720
|
+
}
|
|
721
|
+
function pathPatternOverlaps(left, right) {
|
|
722
|
+
const leftPrefix = left.replace(/\*.*$/, "");
|
|
723
|
+
const rightPrefix = right.replace(/\*.*$/, "");
|
|
724
|
+
return left === right || leftPrefix.startsWith(rightPrefix) || rightPrefix.startsWith(leftPrefix);
|
|
725
|
+
}
|
|
726
|
+
function unresolvedWithoutTopology(occurrence) {
|
|
727
|
+
return {
|
|
728
|
+
importer: occurrence.importer,
|
|
729
|
+
displayImporter: occurrence.displayImporter,
|
|
730
|
+
specifier: occurrence.specifier,
|
|
731
|
+
position: occurrence.position,
|
|
732
|
+
status: "unresolved",
|
|
733
|
+
owningTsconfigs: [],
|
|
734
|
+
reason: "topology unavailable"
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
class ResolutionSession {
|
|
738
|
+
snapshot;
|
|
739
|
+
parsed = new Map();
|
|
740
|
+
resolutionCaches = new Map();
|
|
741
|
+
resolutions = new Map();
|
|
742
|
+
ownersByFile = null;
|
|
743
|
+
ownerDiagnostics = [];
|
|
744
|
+
host;
|
|
745
|
+
constructor(snapshot) {
|
|
746
|
+
this.snapshot = snapshot;
|
|
747
|
+
this.host = (0, ts_oracle_host_1.createWorkspaceModuleResolutionHost)(snapshot.root);
|
|
748
|
+
}
|
|
749
|
+
resolve(occurrence) {
|
|
750
|
+
const key = occurrenceKey(occurrence);
|
|
751
|
+
const cached = this.resolutions.get(key);
|
|
752
|
+
if (cached) {
|
|
753
|
+
return cached;
|
|
754
|
+
}
|
|
755
|
+
const ownership = (0, core_1.describeTopologyFile)(this.snapshot, occurrence.importer);
|
|
756
|
+
const owningTsconfigs = this.owningTsconfigs(occurrence.importer);
|
|
757
|
+
if (owningTsconfigs.length === 0) {
|
|
758
|
+
const result = {
|
|
759
|
+
importer: occurrence.importer,
|
|
760
|
+
displayImporter: occurrence.displayImporter,
|
|
761
|
+
specifier: occurrence.specifier,
|
|
762
|
+
position: occurrence.position,
|
|
763
|
+
status: "noOwningTsconfig",
|
|
764
|
+
owningTsconfigs: [],
|
|
765
|
+
...(ownership.packageRoot ? { packageRoot: ownership.packageRoot } : {}),
|
|
766
|
+
...(ownership.packageName ? { packageName: ownership.packageName } : {}),
|
|
767
|
+
reason: "no owning tsconfig"
|
|
768
|
+
};
|
|
769
|
+
this.resolutions.set(key, result);
|
|
770
|
+
return result;
|
|
771
|
+
}
|
|
772
|
+
const ownerResolutions = owningTsconfigs.map((tsconfig) => this.resolveForOwner(occurrence, tsconfig));
|
|
773
|
+
const internalTargets = uniqueCanonicalPaths(ownerResolutions
|
|
774
|
+
.filter((owner) => owner.status === "resolvedInternal" && owner.targetFile)
|
|
775
|
+
.map((owner) => owner.targetFile));
|
|
776
|
+
const allInternalSameTarget = ownerResolutions.every((owner) => owner.status === "resolvedInternal") && internalTargets.length === 1;
|
|
777
|
+
const allExternal = ownerResolutions.every((owner) => owner.status === "resolvedExternal");
|
|
778
|
+
const status = allInternalSameTarget
|
|
779
|
+
? "resolvedInternal"
|
|
780
|
+
: allExternal
|
|
781
|
+
? "resolvedExternal"
|
|
782
|
+
: "unresolved";
|
|
783
|
+
const targetFile = allInternalSameTarget ? internalTargets[0] : undefined;
|
|
784
|
+
const targetOwnership = targetFile ? (0, core_1.describeTopologyFile)(this.snapshot, targetFile) : null;
|
|
785
|
+
const result = {
|
|
786
|
+
importer: occurrence.importer,
|
|
787
|
+
displayImporter: occurrence.displayImporter,
|
|
788
|
+
specifier: occurrence.specifier,
|
|
789
|
+
position: occurrence.position,
|
|
790
|
+
status,
|
|
791
|
+
owningTsconfigs: ownerResolutions,
|
|
792
|
+
...(owningTsconfigs.length === 1 ? { tsconfig: owningTsconfigs[0] } : {}),
|
|
793
|
+
...(ownership.packageRoot ? { packageRoot: ownership.packageRoot } : {}),
|
|
794
|
+
...(ownership.packageName ? { packageName: ownership.packageName } : {}),
|
|
795
|
+
...(targetFile ? { targetFile } : {}),
|
|
796
|
+
...(targetOwnership?.packageRoot ? { targetPackageRoot: targetOwnership.packageRoot } : {}),
|
|
797
|
+
...(targetOwnership?.packageName ? { targetPackageName: targetOwnership.packageName } : {}),
|
|
798
|
+
...(!allInternalSameTarget && !allExternal ? { reason: "owning tsconfigs produced divergent resolution outcomes" } : {})
|
|
799
|
+
};
|
|
800
|
+
this.resolutions.set(key, result);
|
|
801
|
+
return result;
|
|
802
|
+
}
|
|
803
|
+
resolveForOwner(occurrence, tsconfig) {
|
|
804
|
+
const parsed = this.parsedConfig(tsconfig);
|
|
805
|
+
if (!parsed) {
|
|
806
|
+
return { tsconfig, status: "unresolved", reason: "owning tsconfig could not be parsed" };
|
|
807
|
+
}
|
|
808
|
+
const resolved = this.resolveSpecifier(parsed, occurrence.importer, occurrence.specifier);
|
|
809
|
+
if (!resolved) {
|
|
810
|
+
const packageName = packageNameFromSpecifier(occurrence.specifier);
|
|
811
|
+
const knownExternal = packageName && !this.matchesTsconfigPath(tsconfig, occurrence.specifier) && this.knownPackageName(packageName);
|
|
812
|
+
return {
|
|
813
|
+
tsconfig,
|
|
814
|
+
status: knownExternal ? "resolvedExternal" : "unresolved",
|
|
815
|
+
reason: knownExternal ? `external package ${packageName}` : "TypeScript module resolution failed"
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
return {
|
|
819
|
+
tsconfig,
|
|
820
|
+
status: isExternalTarget(this.snapshot.root, resolved) ? "resolvedExternal" : "resolvedInternal",
|
|
821
|
+
targetFile: resolved
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
owningTsconfigs(importer) {
|
|
825
|
+
this.ensureOwnerIndex();
|
|
826
|
+
return this.ownersByFile.get((0, path_identity_1.canonicalPathIdentity)(importer)) ?? [];
|
|
827
|
+
}
|
|
828
|
+
ownerConfigDiagnostics() {
|
|
829
|
+
this.ensureOwnerIndex();
|
|
830
|
+
return [...this.ownerDiagnostics];
|
|
831
|
+
}
|
|
832
|
+
ensureOwnerIndex() {
|
|
833
|
+
if (this.ownersByFile) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
this.ownersByFile = new Map();
|
|
837
|
+
const incomingExtends = new Map();
|
|
838
|
+
for (const config of this.snapshot.tsconfigs) {
|
|
839
|
+
if (!config.extends) {
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
const parent = (0, path_identity_1.canonicalPathIdentity)(path.resolve(this.snapshot.root, config.extends));
|
|
843
|
+
incomingExtends.set(parent, (incomingExtends.get(parent) ?? 0) + 1);
|
|
844
|
+
}
|
|
845
|
+
for (const config of this.snapshot.tsconfigs) {
|
|
846
|
+
const parsed = this.parsedConfig(config.file);
|
|
847
|
+
if (!parsed) {
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
const incoming = incomingExtends.get((0, path_identity_1.canonicalPathIdentity)(parsed.file)) ?? 0;
|
|
851
|
+
const explicitProjectRoots = hasExplicitProjectRoots(parsed.file);
|
|
852
|
+
if (incoming > 0 && !explicitProjectRoots) {
|
|
853
|
+
this.ownerDiagnostics.push({
|
|
854
|
+
code: "extends_template_excluded",
|
|
855
|
+
tsconfig: config.file,
|
|
856
|
+
incomingExtends: incoming,
|
|
857
|
+
explicitProjectRoots: false,
|
|
858
|
+
fileSetProvenance: "inheritedOrDefault",
|
|
859
|
+
message: "Config is extended by project configs and has no explicit files/include/references; its implicit file set is not owner evidence."
|
|
860
|
+
});
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
for (const file of parsed.parsed.fileNames) {
|
|
864
|
+
const identity = (0, path_identity_1.canonicalPathIdentity)(file);
|
|
865
|
+
this.ownersByFile.set(identity, [...(this.ownersByFile.get(identity) ?? []), config.file]);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
parsedConfig(tsconfig) {
|
|
870
|
+
if (this.parsed.has(tsconfig)) {
|
|
871
|
+
return this.parsed.get(tsconfig) ?? null;
|
|
872
|
+
}
|
|
873
|
+
const diagnostics = [];
|
|
874
|
+
const parsed = (0, tsconfig_loader_1.parseTsConfig)(path.resolve(this.snapshot.root, tsconfig), diagnostics);
|
|
875
|
+
this.parsed.set(tsconfig, parsed);
|
|
876
|
+
return parsed;
|
|
877
|
+
}
|
|
878
|
+
resolveSpecifier(parsed, importer, specifier) {
|
|
879
|
+
const cacheKey = parsed.file;
|
|
880
|
+
const cache = this.resolutionCaches.get(cacheKey) ?? typescript_1.default.createModuleResolutionCache(path.dirname(parsed.file), canonicalFileName, parsed.parsed.options);
|
|
881
|
+
this.resolutionCaches.set(cacheKey, cache);
|
|
882
|
+
return normalizeResolvedFile(typescript_1.default.resolveModuleName(specifier, importer, parsed.parsed.options, this.host, cache).resolvedModule?.resolvedFileName);
|
|
883
|
+
}
|
|
884
|
+
resolveWithProposedMapping(parsed, config, importer, specifier, alias, mappingTarget) {
|
|
885
|
+
const options = {
|
|
886
|
+
...parsed.parsed.options,
|
|
887
|
+
baseUrl: path.resolve(this.snapshot.root, config.baseUrl),
|
|
888
|
+
paths: {
|
|
889
|
+
...(parsed.parsed.options.paths ?? {}),
|
|
890
|
+
[alias]: [mappingTarget]
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
const cache = typescript_1.default.createModuleResolutionCache(path.dirname(parsed.file), canonicalFileName, options);
|
|
894
|
+
return normalizeResolvedFile(typescript_1.default.resolveModuleName(specifier, importer, options, this.host, cache).resolvedModule?.resolvedFileName);
|
|
895
|
+
}
|
|
896
|
+
matchesTsconfigPath(tsconfig, specifier) {
|
|
897
|
+
return this.snapshot.tsconfigs.find((item) => item.file === tsconfig)?.paths.some((mapping) => matchPathPattern(specifier, mapping.pattern)) ?? false;
|
|
898
|
+
}
|
|
899
|
+
knownPackageName(packageName) {
|
|
900
|
+
return this.snapshot.packages.some((pkg) => pkg.name === packageName || pkg.dependencies.includes(packageName));
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
function matchPathPattern(specifier, pattern) {
|
|
904
|
+
const star = pattern.indexOf("*");
|
|
905
|
+
if (star < 0) {
|
|
906
|
+
return specifier === pattern;
|
|
907
|
+
}
|
|
908
|
+
const prefix = pattern.slice(0, star);
|
|
909
|
+
const suffix = pattern.slice(star + 1);
|
|
910
|
+
return specifier.startsWith(prefix) && specifier.endsWith(suffix);
|
|
911
|
+
}
|
|
912
|
+
function hasExplicitProjectRoots(configFile) {
|
|
913
|
+
const read = typescript_1.default.readConfigFile(configFile, typescript_1.default.sys.readFile);
|
|
914
|
+
if (read.error || !read.config || typeof read.config !== "object") {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
return ["files", "include", "references"].some((key) => Object.prototype.hasOwnProperty.call(read.config, key));
|
|
918
|
+
}
|
|
919
|
+
function packageNameFromSpecifier(specifier) {
|
|
920
|
+
if (specifier.startsWith(".") || specifier.startsWith("#") || specifier.startsWith("@/")) {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
const parts = specifier.split("/");
|
|
924
|
+
return specifier.startsWith("@") ? parts.length >= 2 ? `${parts[0]}/${parts[1]}` : null : parts[0] || null;
|
|
925
|
+
}
|
|
926
|
+
function isExternalTarget(root, target) {
|
|
927
|
+
const relative = path.relative(root, target).replace(/\\/g, "/");
|
|
928
|
+
return relative.startsWith("../") || path.isAbsolute(relative) || relative.split("/").includes("node_modules");
|
|
929
|
+
}
|
|
930
|
+
function normalizeResolvedFile(file) {
|
|
931
|
+
if (!file) {
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
934
|
+
return path.resolve(file).replace(/\.d\.ts$/i, ".ts");
|
|
935
|
+
}
|
|
936
|
+
function canonicalFileName(file) {
|
|
937
|
+
return (0, path_identity_1.canonicalPathIdentity)(file);
|
|
938
|
+
}
|
|
939
|
+
function withoutSourceExtension(file) {
|
|
940
|
+
return file.replace(SOURCE_EXTENSION_RE, "");
|
|
941
|
+
}
|
|
942
|
+
function occurrenceKey(occurrence) {
|
|
943
|
+
return `${(0, path_identity_1.canonicalPathIdentity)(occurrence.importer)}\0${occurrence.position}\0${occurrence.specifier}`;
|
|
944
|
+
}
|
|
945
|
+
function uniqueOccurrences(items) {
|
|
946
|
+
const seen = new Set();
|
|
947
|
+
return items.filter((item) => {
|
|
948
|
+
const key = occurrenceKey(item);
|
|
949
|
+
if (seen.has(key)) {
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
seen.add(key);
|
|
953
|
+
return true;
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
function candidateId(prefix, alias, target) {
|
|
957
|
+
return `alias_${(0, node_crypto_1.createHash)("sha256").update(`${prefix}\0${alias}\0${target}`).digest("hex").slice(0, 10)}`;
|
|
958
|
+
}
|
|
959
|
+
function toDisplayPath(root, file) {
|
|
960
|
+
const relative = path.relative(path.resolve(root), path.resolve(file)).replace(/\\/g, "/");
|
|
961
|
+
return relative === "" ? "." : relative.startsWith("../") || path.isAbsolute(relative) ? path.resolve(file).replace(/\\/g, "/") : relative;
|
|
962
|
+
}
|
|
963
|
+
function unique(items) {
|
|
964
|
+
return [...new Set(items)];
|
|
965
|
+
}
|
|
966
|
+
function uniqueCanonicalPaths(items) {
|
|
967
|
+
const byIdentity = new Map();
|
|
968
|
+
for (const item of items) {
|
|
969
|
+
byIdentity.set((0, path_identity_1.canonicalPathIdentity)(item), item);
|
|
970
|
+
}
|
|
971
|
+
return [...byIdentity.values()];
|
|
972
|
+
}
|
|
973
|
+
function ownerResolutionsDiverge(resolution) {
|
|
974
|
+
if (resolution.owningTsconfigs.length <= 1) {
|
|
975
|
+
return false;
|
|
976
|
+
}
|
|
977
|
+
const outcomes = new Set(resolution.owningTsconfigs.map((owner) => `${owner.status}:${owner.targetFile ? (0, path_identity_1.canonicalPathIdentity)(owner.targetFile) : owner.reason ?? ""}`));
|
|
978
|
+
return outcomes.size > 1;
|
|
979
|
+
}
|
|
980
|
+
function intersect(left, right) {
|
|
981
|
+
return new Set([...left].filter((item) => right.has(item)));
|
|
982
|
+
}
|