@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
package/dist/dsl/aib-dsl.js
CHANGED
|
@@ -1 +1,838 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileAibDsl=V;const L=new Set(["file","exports","members","code","deps","usages","duplicates","graph","tree","cycles","imports"]),R=new Set(["rename","move","plan","module"]),$=new Set(["imports.normalize"]),K=new Set(["view"]),w="__aibDslDefaultFile",g="__aibDslDefaultScope",A="__aibDslDefaultTarget";function V(e,r={}){if(r.tolerantInspect===!0)return j(e);const t={},n=[],i=[],o=[],s=[],a=[];let c=null;for(const u of N(e)){const[f,...p]=u.tokens;if(f){if(f.startsWith("@")){M(t,f,p,u.lineNumber);continue}if(L.has(f)){c=y(c,"inspect",u.lineNumber),n.push(U(f,p,t,u.lineNumber));continue}if(R.has(f)){c=y(c,"mutation",u.lineNumber),f==="plan"||f==="module"?o.push(oe(p,u.lineNumber)):i.push(ie(f,p,u.lineNumber));continue}if($.has(f)){c=y(c,"imports",u.lineNumber),s.push(re(p,t,u.lineNumber));continue}if(K.has(f)){c=y(c,"view",u.lineNumber),a.push(se(p,u.lineNumber));continue}throw l(u.lineNumber,`Unknown DSL operation: ${f}`)}}if(c==="inspect")return{command:"inspect",payload:C(t,n)};if(o.length>0&&i.length>0)throw l(0,"Cannot mix modulePlan rows with rename/move mutation rows.");if(o.length>0)return E(t.sourceFile,"@source",0),{command:"modulePlan",payload:D({sourceFile:t.sourceFile,modules:o,expectEmpty:t.expectEmpty===!0?!0:void 0,save:t.save})};if(i.length===1){E(t.sourceFile,"@source",0);const u=i[0];return u.op==="rename"?{command:"rename",payload:D({sourceFile:t.sourceFile,renames:u.renames,save:t.save})}:{command:"move.toFile",payload:D({sourceFile:t.sourceFile,targetFile:u.targetFile,entities:u.entities,save:t.save})}}if(i.length>1)return E(t.sourceFile,"@source",0),{command:"refactor.batch",payload:D({sourceFile:t.sourceFile,requests:i,save:t.save})};if(s.length>0)return{command:"imports.normalize",payload:s.length===1?s[0]:{requests:s}};if(a.length>0)return{command:"view",payload:a.length===1?a[0]:{views:a}};throw l(0,"DSL document has no operations.")}function j(e){const r={},t=[],n=[];let i=null;const o=e.split(/\r?\n/);for(let a=0;a<o.length;a+=1){const c=a+1,u=o[a]??"",f=_(u).trim();if(!f)continue;let p;try{p=O(f,c)}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))});continue}const[m,...T]=p;if(m){if(m.startsWith("@")){M(r,m,T,c);continue}if(L.has(m)){i=y(i,"inspect",c);try{t.push(U(m,T,r,c))}catch(d){n.push({line:c,message:I(d instanceof Error?d.message:String(d))})}continue}if(R.has(m)||$.has(m))throw l(c,"Cannot mix inspect, mutation, and imports operations in one DSL document.");n.push({line:c,message:`Unknown DSL operation: ${m}`})}}if(t.length===0)throw n.length>0?l(n[0].line,n[0].message):l(0,"DSL document has no operations.");const s=C(r,t);return n.length>0&&(s.dslDiagnostics=n.map(a=>({line:a.line,message:a.message}))),{command:"inspect",payload:s,...n.length>0?{diagnostics:n}:{}}}function I(e){return e.replace(/^DSL(?: line \d+)?:\s*/,"")}function N(e){return e.split(/\r?\n/).flatMap((r,t)=>{const n=_(r).trim();return n?[{lineNumber:t+1,tokens:O(n,t+1)}]:[]})}function _(e){let r=null;for(let t=0;t<e.length;t+=1){const n=e[t];if((n==='"'||n==="'")&&e[t-1]!=="\\"&&(r=r===n?null:r??n),n==="#"&&r===null)return e.slice(0,t)}return e}function O(e,r){const t=[];let n="",i=null;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&e[o-1]!=="\\"?i=null:n+=s;continue}if(s==='"'||s==="'"){i=s;continue}if(/\s/.test(s)){n&&(t.push(n),n="");continue}n+=s}if(i)throw l(r,"Unclosed quote.");return n&&t.push(n),t}function M(e,r,t,n){const i=t.join(" ").trim();if(!i)throw l(n,`${r} requires a value.`);switch(r){case"@file":e.file=i;return;case"@source":{const{value:o,flags:s}=B(t,n,r);e.sourceFile=o,s.has("expectEmpty")&&(e.expectEmpty=!0);return}case"@scope":e.scope=i;return;case"@target":e.target=i;return;case"@save":e.save=i;return;default:throw l(n,`Unknown DSL default: ${r}`)}}function B(e,r,t){const n=new Set,i=[];for(const s of e){if(s.startsWith("+")&&s.length>1){n.add(s.slice(1));continue}i.push(s)}const o=i.join(" ").trim();if(!o)throw l(r,`${t} requires a value.`);return{value:o,flags:n}}function y(e,r,t){if(e&&e!==r)throw l(t,"Cannot mix inspect, mutation, and imports operations in one DSL document.");return r}function U(e,r,t,n){const{positional:i,fields:o}=S(r,n),s={op:e};if(Object.assign(s,o),e==="file"||e==="exports"||e==="imports"){const a=i[0]??o.file,c=a??t.file;return c&&(s.file=c,a||h(s,w)),s}if(e==="members"){const c=W(s,i,t).map(v);return c.length===1&&!o.entity&&!o.entities?s.entity=c[0]:c.length>0&&!o.entities&&(s.entities=c),s}if(e==="code"||e==="deps"){const c=W(s,i,t).map(v);return e==="deps"&&c.length===1&&!o.entities&&!o.entity?s.entity=c[0]:c.length>0&&!o.entities&&!o.entity&&(s.entities=c),s}if(e==="usages"){const a=o.target??i[0],c=a??t.target??t.file;c&&(s.target=c,a||h(s,A));const u=o.entity??o.entities,p=(c===i[0]?i.slice(1):i).map(v);return!u&&p.length===1?s.entity=p[0]:!u&&p.length>1&&(s.entities=p),s}if(e==="duplicates"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="tree"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="cycles"){const a=o.scope??i[0],c=a??t.scope;return c&&(s.scope=c,a||h(s,g)),s}if(e==="graph"){const a=o.scope??i[0],c=a??t.scope;return c&&!s.fromFile&&(s.scope=c,a||h(s,g)),s}return s}function G(e,r){!e.file&&!e.fromFile&&r.file&&(e.file=r.file,h(e,w))}function W(e,r,t){return!e.file&&!e.fromFile&&r.length>0&&H(r[0])?(e.file=r[0],r.slice(1)):(G(e,t),r)}function H(e){return e.includes("/")||e.includes("\\")||/^@[^/\\]+[/\\]/.test(e)||/\.(?:[cm]?[jt]sx?|d\.ts)$/i.test(e)}function h(e,r){Object.defineProperty(e,r,{value:!0,enumerable:!1})}function S(e,r){const t=[],n={};for(const i of e){if(i.startsWith("+")&&i.length>1){x(n,i.slice(1),!0);continue}if(i.startsWith("-")&&i.length>1){x(n,i.slice(1),!1);continue}if(i.startsWith(">")&&i.length>1){x(n,"save",i.slice(1));continue}const o=i.indexOf("=");if(o>0){const s=i.slice(0,o),a=i.slice(o+1);x(n,q(s),J(s,a));continue}if(i==="->")throw l(r,"Unexpected move separator in inspect request.");t.push(i)}return{positional:t,fields:n}}function x(e,r,t){const n=e[r];if(n===void 0){e[r]=t;return}if(b(r)){e[r]=[...z(n),...z(t)];return}e[r]=t}function b(e){return e==="focus"||e==="scope"||e==="scopes"||e==="file"||e==="files"||e==="exclude"||e==="excludes"||e==="pathExclude"||e==="pathExcludes"||e==="excludePath"||e==="excludePaths"||e==="entities"||e==="only"||e==="except"||e==="kinds"}function z(e){return Array.isArray(e)?e:[e]}function q(e){return e==="from"?"fromFile":e==="no-default-exclude"?"noDefaultExclude":e==="no-config-exclude"?"noConfigExclude":e}function J(e,r){const t=X(r),n=Q(t);if(/^-?\d+$/.test(t))return Number(t);if(t==="true")return!0;if(t==="false")return!1;if(e==="entity"||e==="entities"){const i=(n??F(t)).map(v);return e==="entity"&&i.length===1?i[0]:i}return e==="only"||e==="except"?(n??F(t)).flatMap(Y):n&&b(q(e))?n:b(q(e))&&t.includes(",")?F(t):t}function Q(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;const r=e.slice(1,-1).trim();return r?F(r):[]}function F(e){const r=[];let t="",n=0,i=0;for(const o of e){if(o==="{"?n+=1:o==="}"&&n>0?n-=1:o==="["?i+=1:o==="]"&&i>0&&(i-=1),o===","&&n===0&&i===0){t.trim()&&r.push(t.trim()),t="";continue}t+=o}return t.trim()&&r.push(t.trim()),r}function X(e){return e==="sum"?"summary":e==="loc"?"locations":e}function v(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const n=r[1],i=r[2];return!n||!i?e:{parent:n,entities:i.split(",").map(o=>o.trim()).filter(Boolean)}}const t=e.match(/^(.+)\.([^./{}]+)$/);if(t){const n=t[1],i=t[2];return!n||!i?e:{parent:n,entities:[i]}}return e}function Y(e){const r=e.match(/^(.+)\.\{(.+)\}$/);if(r){const t=r[1],n=r[2];if(t&&n)return n.split(",").map(i=>i.trim()).filter(Boolean).map(i=>`${t}.${i}`)}return[e]}function C(e,r){const t=r.map(Z),n={requests:t};return P(n,t,{payloadKey:"file",defaultValue:e.file,predicate:ee,marker:w}),P(n,t,{payloadKey:"scope",defaultValue:e.scope,predicate:te,marker:g}),P(n,t,{payloadKey:"target",defaultValue:e.target,predicate:ne,marker:A}),e.save&&(n.save=e.save),k(n,t),n}function Z(e){const r={...e};for(const t of[w,g,A])e[t]===!0&&h(r,t);return r}function P(e,r,t){if(t.defaultValue===void 0)return;const n=r.filter(t.predicate);if(n.some(i=>i[t.payloadKey]!==void 0)){e[t.payloadKey]=t.defaultValue;for(const i of n)i[t.marker]===!0&&i[t.payloadKey]===t.defaultValue&&delete i[t.payloadKey]}}function k(e,r){for(const t of r){const n=String(t.op??"");if((n==="file"||n==="exports"||n==="imports")&&typeof t.file!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=... or @file.`);if((n==="members"||n==="code"||n==="deps")&&typeof t.file!="string"&&typeof t.fromFile!="string"&&typeof e.file!="string")throw l(0,`${n} requires file=..., from=..., or @file.`);if(n==="usages"&&typeof t.target!="string"&&typeof e.target!="string")throw l(0,"usages requires target=..., positional target, @target, or @file.");if(n==="duplicates"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"duplicates requires scope=..., positional scope, or @scope.");if(n==="graph"&&typeof t.fromFile!="string"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"graph requires scope=..., positional scope, @scope, or from=...");if(n==="tree"&&typeof t.scope!="string"&&typeof e.scope!="string")throw l(0,"tree requires scope=..., positional scope, or @scope.");if(n==="cycles"&&typeof t.scope!="string"&&!Array.isArray(t.scope)&&typeof t.file!="string"&&!Array.isArray(t.files)&&typeof e.scope!="string"&&!Array.isArray(e.scope))throw l(0,"cycles requires scope=..., files=[...], positional scope, or @scope.")}}function ee(e){return(e.op==="file"||e.op==="exports"||e.op==="imports"||e.op==="members"||e.op==="code"||e.op==="deps")&&!e.fromFile}function te(e){return(e.op==="duplicates"||e.op==="graph"||e.op==="tree"||e.op==="cycles")&&!e.fromFile}function ne(e){return e.op==="usages"}function ie(e,r,t){if(e==="rename"){const i={};for(const o of r){if(o.startsWith(">")&&o.length>1)throw l(t,"Use @save <name> for mutation payload saves.");const s=o.indexOf("->");if(s<=0||s===o.length-2)throw l(t,`Invalid rename pair: ${o}`);i[o.slice(0,s)]=o.slice(s+2)}return{op:"rename",renames:i}}if(r.some(i=>i.startsWith(">")&&i.length>1))throw l(t,"Use @save <name> for mutation payload saves.");const n=r[0];if(typeof n=="string"&&n.endsWith(":")&&n.length>1){const i=r.slice(1);if(i.length===0)throw l(t,"Move entities are required.");return{op:"move",entities:i,targetFile:n.slice(0,-1)}}throw l(t,"Invalid move syntax. Expected: move target.ts: entity entity")}function re(e,r,t){const{positional:n,fields:i}=S(e,t),o={...i},s=o.scope??n[0]??r.scope;if(s!==void 0&&(o.scope=s),Array.isArray(o.scope))throw l(t,"imports.normalize scope expects one file/dir; use multiple imports.normalize lines for multiple scopes.");if(typeof o.scope!="string"||o.scope.length===0)throw l(t,"imports.normalize requires scope=..., positional scope, or @scope.");if(n.length>1)throw l(t,"imports.normalize accepts one positional scope; use key=value fields for options.");return o}function se(e,r){const{positional:t,fields:n}=S(e,r),i=n.handle??n.from??t[0];if(typeof i!="string"||i.length===0)throw l(r,"view requires a result handle.");if(t.length>1)throw l(r,"view accepts one positional handle; use key=value fields for options.");const o={handle:i};for(const[s,a]of Object.entries(n))s==="handle"||s==="from"||(o[s]=a);return o}function oe(e,r){if(e.findIndex(o=>o.endsWith(":"))!==0)throw l(r,"Plan syntax is: plan target.ts: entity entity");const n=e[0].slice(0,-1),i=e.slice(1);if(!n||i.length===0)throw l(r,"Plan row requires target and at least one entity.");return{target:n,entities:i}}function E(e,r,t){if(!e)throw l(t,`${r} is required.`)}function l(e,r){const t=e>0?`DSL line ${e}: `:"DSL: ";return new Error(`${t}${r}`)}function D(e){return Object.fromEntries(Object.entries(e).filter(r=>r[1]!==void 0))}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileAibDsl = compileAibDsl;
|
|
4
|
+
const INSPECT_OPS = new Set(["file", "exports", "members", "code", "deps", "usages", "duplicates", "graph", "tree", "cycles", "imports", "aliasCandidates", "alias-candidates"]);
|
|
5
|
+
const MUTATION_OPS = new Set(["rename", "move", "plan", "module"]);
|
|
6
|
+
const IMPORT_OPS = new Set(["imports.normalize"]);
|
|
7
|
+
const VIEW_OPS = new Set(["view"]);
|
|
8
|
+
const INSPECT_OPTION_TOKENS_FIELD = "__aibDslOptionTokens";
|
|
9
|
+
const DEFAULT_FILE_MARK = "__aibDslDefaultFile";
|
|
10
|
+
const DEFAULT_SCOPE_MARK = "__aibDslDefaultScope";
|
|
11
|
+
const DEFAULT_TARGET_MARK = "__aibDslDefaultTarget";
|
|
12
|
+
function compileAibDsl(source, options = {}) {
|
|
13
|
+
if (options.tolerantInspect === true) {
|
|
14
|
+
return compileAibDslTolerantInspect(source);
|
|
15
|
+
}
|
|
16
|
+
const defaults = {};
|
|
17
|
+
const inspectRequests = [];
|
|
18
|
+
const mutationRequests = [];
|
|
19
|
+
const modulePlanRows = [];
|
|
20
|
+
const importNormalizeRequests = [];
|
|
21
|
+
const viewRequests = [];
|
|
22
|
+
let commandFamily = null;
|
|
23
|
+
for (const line of parseLines(source)) {
|
|
24
|
+
const [head, ...rest] = line.tokens;
|
|
25
|
+
if (!head) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (head.startsWith("@")) {
|
|
29
|
+
applyDefault(defaults, head, rest, line.lineNumber);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (INSPECT_OPS.has(head)) {
|
|
33
|
+
commandFamily = claimFamily(commandFamily, "inspect", line.lineNumber);
|
|
34
|
+
inspectRequests.push(compileInspectRequest(head, rest, defaults, line.lineNumber));
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (MUTATION_OPS.has(head)) {
|
|
38
|
+
commandFamily = claimFamily(commandFamily, "mutation", line.lineNumber);
|
|
39
|
+
if (head === "plan" || head === "module") {
|
|
40
|
+
modulePlanRows.push(compilePlanRow(rest, line.lineNumber));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
mutationRequests.push(compileMutationRequest(head, rest, line.lineNumber));
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (IMPORT_OPS.has(head)) {
|
|
48
|
+
commandFamily = claimFamily(commandFamily, "imports", line.lineNumber);
|
|
49
|
+
importNormalizeRequests.push(compileImportNormalizeRequest(rest, defaults, line.lineNumber));
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (VIEW_OPS.has(head)) {
|
|
53
|
+
commandFamily = claimFamily(commandFamily, "view", line.lineNumber);
|
|
54
|
+
viewRequests.push(compileViewRequest(rest, line.lineNumber));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
throw dslError(line.lineNumber, `Unknown DSL operation: ${head}`);
|
|
58
|
+
}
|
|
59
|
+
if (commandFamily === "inspect") {
|
|
60
|
+
return {
|
|
61
|
+
command: "inspect",
|
|
62
|
+
payload: buildInspectPayload(defaults, inspectRequests)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (modulePlanRows.length > 0 && mutationRequests.length > 0) {
|
|
66
|
+
throw dslError(0, "Cannot mix modulePlan rows with rename/move mutation rows.");
|
|
67
|
+
}
|
|
68
|
+
if (modulePlanRows.length > 0) {
|
|
69
|
+
requireDefault(defaults.sourceFile, "@source", 0);
|
|
70
|
+
return {
|
|
71
|
+
command: "modulePlan",
|
|
72
|
+
payload: compactObject({
|
|
73
|
+
sourceFile: defaults.sourceFile,
|
|
74
|
+
modules: modulePlanRows,
|
|
75
|
+
expectEmpty: defaults.expectEmpty === true ? true : undefined,
|
|
76
|
+
save: defaults.save
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (mutationRequests.length === 1) {
|
|
81
|
+
requireDefault(defaults.sourceFile, "@source", 0);
|
|
82
|
+
const request = mutationRequests[0];
|
|
83
|
+
if (request.op === "rename") {
|
|
84
|
+
return {
|
|
85
|
+
command: "rename",
|
|
86
|
+
payload: compactObject({
|
|
87
|
+
sourceFile: defaults.sourceFile,
|
|
88
|
+
renames: request.renames,
|
|
89
|
+
save: defaults.save
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
command: "move.toFile",
|
|
95
|
+
payload: compactObject({
|
|
96
|
+
sourceFile: defaults.sourceFile,
|
|
97
|
+
targetFile: request.targetFile,
|
|
98
|
+
entities: request.entities,
|
|
99
|
+
save: defaults.save
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (mutationRequests.length > 1) {
|
|
104
|
+
requireDefault(defaults.sourceFile, "@source", 0);
|
|
105
|
+
return {
|
|
106
|
+
command: "refactor.batch",
|
|
107
|
+
payload: compactObject({
|
|
108
|
+
sourceFile: defaults.sourceFile,
|
|
109
|
+
requests: mutationRequests,
|
|
110
|
+
save: defaults.save
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (importNormalizeRequests.length > 0) {
|
|
115
|
+
return {
|
|
116
|
+
command: "imports.normalize",
|
|
117
|
+
payload: importNormalizeRequests.length === 1
|
|
118
|
+
? importNormalizeRequests[0]
|
|
119
|
+
: { requests: importNormalizeRequests }
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (viewRequests.length > 0) {
|
|
123
|
+
return {
|
|
124
|
+
command: "view",
|
|
125
|
+
payload: viewRequests.length === 1
|
|
126
|
+
? viewRequests[0]
|
|
127
|
+
: { views: viewRequests }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
throw dslError(0, "DSL document has no operations.");
|
|
131
|
+
}
|
|
132
|
+
function compileAibDslTolerantInspect(source) {
|
|
133
|
+
const defaults = {};
|
|
134
|
+
const inspectRequests = [];
|
|
135
|
+
const diagnostics = [];
|
|
136
|
+
let commandFamily = null;
|
|
137
|
+
const sourceLines = source.split(/\r?\n/);
|
|
138
|
+
for (let index = 0; index < sourceLines.length; index += 1) {
|
|
139
|
+
const lineNumber = index + 1;
|
|
140
|
+
const rawLine = sourceLines[index] ?? "";
|
|
141
|
+
const withoutComment = stripComment(rawLine).trim();
|
|
142
|
+
if (!withoutComment) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
let tokens;
|
|
146
|
+
try {
|
|
147
|
+
tokens = tokenize(withoutComment, lineNumber);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
diagnostics.push({
|
|
151
|
+
line: lineNumber,
|
|
152
|
+
message: stripDslErrorPrefix(error instanceof Error ? error.message : String(error))
|
|
153
|
+
});
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const [head, ...rest] = tokens;
|
|
157
|
+
if (!head) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (head.startsWith("@")) {
|
|
161
|
+
applyDefault(defaults, head, rest, lineNumber);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (INSPECT_OPS.has(head)) {
|
|
165
|
+
commandFamily = claimFamily(commandFamily, "inspect", lineNumber);
|
|
166
|
+
try {
|
|
167
|
+
inspectRequests.push(compileInspectRequest(head, rest, defaults, lineNumber));
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
diagnostics.push({
|
|
171
|
+
line: lineNumber,
|
|
172
|
+
message: stripDslErrorPrefix(error instanceof Error ? error.message : String(error))
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (MUTATION_OPS.has(head) || IMPORT_OPS.has(head)) {
|
|
178
|
+
throw dslError(lineNumber, "Cannot mix inspect, mutation, and imports operations in one DSL document.");
|
|
179
|
+
}
|
|
180
|
+
diagnostics.push({
|
|
181
|
+
line: lineNumber,
|
|
182
|
+
message: `Unknown DSL operation: ${head}`
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (inspectRequests.length === 0) {
|
|
186
|
+
throw diagnostics.length > 0
|
|
187
|
+
? dslError(diagnostics[0].line, diagnostics[0].message)
|
|
188
|
+
: dslError(0, "DSL document has no operations.");
|
|
189
|
+
}
|
|
190
|
+
const payload = buildInspectPayload(defaults, inspectRequests);
|
|
191
|
+
if (diagnostics.length > 0) {
|
|
192
|
+
payload.dslDiagnostics = diagnostics.map((diagnostic) => ({
|
|
193
|
+
line: diagnostic.line,
|
|
194
|
+
message: diagnostic.message
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
command: "inspect",
|
|
199
|
+
payload,
|
|
200
|
+
...(diagnostics.length > 0 ? { diagnostics } : {})
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function stripDslErrorPrefix(message) {
|
|
204
|
+
return message.replace(/^DSL(?: line \d+)?:\s*/, "");
|
|
205
|
+
}
|
|
206
|
+
function parseLines(source) {
|
|
207
|
+
return source.split(/\r?\n/).flatMap((rawLine, index) => {
|
|
208
|
+
const withoutComment = stripComment(rawLine).trim();
|
|
209
|
+
if (!withoutComment) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
return [{
|
|
213
|
+
lineNumber: index + 1,
|
|
214
|
+
tokens: tokenize(withoutComment, index + 1)
|
|
215
|
+
}];
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function stripComment(line) {
|
|
219
|
+
let quote = null;
|
|
220
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
221
|
+
const char = line[index];
|
|
222
|
+
if ((char === `"` || char === "'") && line[index - 1] !== "\\") {
|
|
223
|
+
quote = quote === char ? null : quote ?? char;
|
|
224
|
+
}
|
|
225
|
+
if (char === "#" && quote === null && (index === 0 || /\s/.test(line[index - 1] ?? ""))) {
|
|
226
|
+
return line.slice(0, index);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return line;
|
|
230
|
+
}
|
|
231
|
+
function tokenize(line, lineNumber) {
|
|
232
|
+
const tokens = [];
|
|
233
|
+
let current = "";
|
|
234
|
+
let quote = null;
|
|
235
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
236
|
+
const char = line[index];
|
|
237
|
+
if (quote) {
|
|
238
|
+
if (char === quote && line[index - 1] !== "\\") {
|
|
239
|
+
quote = null;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
current += char;
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (char === `"` || char === "'") {
|
|
247
|
+
quote = char;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (/\s/.test(char)) {
|
|
251
|
+
if (current) {
|
|
252
|
+
tokens.push(current);
|
|
253
|
+
current = "";
|
|
254
|
+
}
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
current += char;
|
|
258
|
+
}
|
|
259
|
+
if (quote) {
|
|
260
|
+
throw dslError(lineNumber, "Unclosed quote.");
|
|
261
|
+
}
|
|
262
|
+
if (current) {
|
|
263
|
+
tokens.push(current);
|
|
264
|
+
}
|
|
265
|
+
return tokens;
|
|
266
|
+
}
|
|
267
|
+
function applyDefault(defaults, directive, args, lineNumber) {
|
|
268
|
+
const value = args.join(" ").trim();
|
|
269
|
+
if (!value) {
|
|
270
|
+
throw dslError(lineNumber, `${directive} requires a value.`);
|
|
271
|
+
}
|
|
272
|
+
switch (directive) {
|
|
273
|
+
case "@file":
|
|
274
|
+
defaults.file = value;
|
|
275
|
+
return;
|
|
276
|
+
case "@source": {
|
|
277
|
+
const { value: sourceFile, flags } = parseDefaultDirectiveValue(args, lineNumber, directive);
|
|
278
|
+
defaults.sourceFile = sourceFile;
|
|
279
|
+
if (flags.has("expectEmpty")) {
|
|
280
|
+
defaults.expectEmpty = true;
|
|
281
|
+
}
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
case "@scope":
|
|
285
|
+
defaults.scope = value;
|
|
286
|
+
return;
|
|
287
|
+
case "@target":
|
|
288
|
+
defaults.target = value;
|
|
289
|
+
return;
|
|
290
|
+
case "@save":
|
|
291
|
+
defaults.save = value;
|
|
292
|
+
return;
|
|
293
|
+
default:
|
|
294
|
+
throw dslError(lineNumber, `Unknown DSL default: ${directive}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function parseDefaultDirectiveValue(args, lineNumber, directive) {
|
|
298
|
+
const flags = new Set();
|
|
299
|
+
const valueParts = [];
|
|
300
|
+
for (const arg of args) {
|
|
301
|
+
if (arg.startsWith("+") && arg.length > 1) {
|
|
302
|
+
flags.add(arg.slice(1));
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
valueParts.push(arg);
|
|
306
|
+
}
|
|
307
|
+
const value = valueParts.join(" ").trim();
|
|
308
|
+
if (!value) {
|
|
309
|
+
throw dslError(lineNumber, `${directive} requires a value.`);
|
|
310
|
+
}
|
|
311
|
+
return { value, flags };
|
|
312
|
+
}
|
|
313
|
+
function claimFamily(current, next, lineNumber) {
|
|
314
|
+
if (current && current !== next) {
|
|
315
|
+
throw dslError(lineNumber, "Cannot mix inspect, mutation, and imports operations in one DSL document.");
|
|
316
|
+
}
|
|
317
|
+
return next;
|
|
318
|
+
}
|
|
319
|
+
function compileInspectRequest(op, tokens, defaults, lineNumber) {
|
|
320
|
+
const { positional, fields, optionTokens } = parseRequestTokens(tokens, lineNumber);
|
|
321
|
+
const request = { op };
|
|
322
|
+
Object.assign(request, fields);
|
|
323
|
+
if (optionTokens.length > 0) {
|
|
324
|
+
request[INSPECT_OPTION_TOKENS_FIELD] = optionTokens;
|
|
325
|
+
}
|
|
326
|
+
if (op === "file" || op === "exports" || op === "imports") {
|
|
327
|
+
const explicitFile = positional[0] ?? fields.file;
|
|
328
|
+
const file = explicitFile ?? defaults.file;
|
|
329
|
+
if (file) {
|
|
330
|
+
request.file = file;
|
|
331
|
+
if (!explicitFile) {
|
|
332
|
+
markDefault(request, DEFAULT_FILE_MARK);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return request;
|
|
336
|
+
}
|
|
337
|
+
if (op === "members") {
|
|
338
|
+
const entityTokens = applyPositionalFileOrDefault(request, positional, defaults);
|
|
339
|
+
const entities = entityTokens.map(parseEntityToken);
|
|
340
|
+
if (entities.length === 1 && !fields.entity && !fields.entities) {
|
|
341
|
+
request.entity = entities[0];
|
|
342
|
+
}
|
|
343
|
+
else if (entities.length > 0 && !fields.entities) {
|
|
344
|
+
request.entities = entities;
|
|
345
|
+
}
|
|
346
|
+
return request;
|
|
347
|
+
}
|
|
348
|
+
if (op === "code" || op === "deps") {
|
|
349
|
+
const entityTokens = applyPositionalFileOrDefault(request, positional, defaults);
|
|
350
|
+
const entities = entityTokens.map(parseEntityToken);
|
|
351
|
+
if (op === "deps" && entities.length === 1 && typeof entities[0] === "string" && !fields.entities && !fields.entity) {
|
|
352
|
+
request.entity = entities[0];
|
|
353
|
+
}
|
|
354
|
+
else if (entities.length > 0 && !fields.entities && !fields.entity) {
|
|
355
|
+
request.entities = entities;
|
|
356
|
+
}
|
|
357
|
+
return request;
|
|
358
|
+
}
|
|
359
|
+
if (op === "usages") {
|
|
360
|
+
const explicitTarget = fields.target ?? positional[0];
|
|
361
|
+
const target = explicitTarget ?? defaults.target ?? defaults.file;
|
|
362
|
+
if (target) {
|
|
363
|
+
request.target = target;
|
|
364
|
+
if (!explicitTarget) {
|
|
365
|
+
markDefault(request, DEFAULT_TARGET_MARK);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const explicitEntity = fields.entity ?? fields.entities;
|
|
369
|
+
const entityTokens = target === positional[0] ? positional.slice(1) : positional;
|
|
370
|
+
const entities = entityTokens.map(parseEntityToken);
|
|
371
|
+
if (!explicitEntity && entities.length === 1) {
|
|
372
|
+
request.entity = entities[0];
|
|
373
|
+
}
|
|
374
|
+
else if (!explicitEntity && entities.length > 1) {
|
|
375
|
+
request.entities = entities;
|
|
376
|
+
}
|
|
377
|
+
return request;
|
|
378
|
+
}
|
|
379
|
+
if (op === "duplicates") {
|
|
380
|
+
const explicitScope = fields.scope ?? positional[0];
|
|
381
|
+
const scope = explicitScope ?? defaults.scope;
|
|
382
|
+
if (scope) {
|
|
383
|
+
request.scope = scope;
|
|
384
|
+
if (!explicitScope) {
|
|
385
|
+
markDefault(request, DEFAULT_SCOPE_MARK);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return request;
|
|
389
|
+
}
|
|
390
|
+
if (op === "tree") {
|
|
391
|
+
const explicitScope = fields.scope ?? positional[0];
|
|
392
|
+
const scope = explicitScope ?? defaults.scope;
|
|
393
|
+
if (scope) {
|
|
394
|
+
request.scope = scope;
|
|
395
|
+
if (!explicitScope) {
|
|
396
|
+
markDefault(request, DEFAULT_SCOPE_MARK);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return request;
|
|
400
|
+
}
|
|
401
|
+
if (op === "cycles" || op === "aliasCandidates" || op === "alias-candidates") {
|
|
402
|
+
const explicitScope = fields.scope ?? positional[0];
|
|
403
|
+
const scope = explicitScope ?? defaults.scope;
|
|
404
|
+
if (scope) {
|
|
405
|
+
request.scope = scope;
|
|
406
|
+
if (!explicitScope) {
|
|
407
|
+
markDefault(request, DEFAULT_SCOPE_MARK);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return request;
|
|
411
|
+
}
|
|
412
|
+
if (op === "graph") {
|
|
413
|
+
const explicitScope = fields.scope ?? positional[0];
|
|
414
|
+
const scope = explicitScope ?? defaults.scope;
|
|
415
|
+
if (scope && !request.fromFile) {
|
|
416
|
+
request.scope = scope;
|
|
417
|
+
if (!explicitScope) {
|
|
418
|
+
markDefault(request, DEFAULT_SCOPE_MARK);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return request;
|
|
422
|
+
}
|
|
423
|
+
return request;
|
|
424
|
+
}
|
|
425
|
+
function applyFileDefault(request, defaults) {
|
|
426
|
+
if (!request.file && !request.fromFile && defaults.file) {
|
|
427
|
+
request.file = defaults.file;
|
|
428
|
+
markDefault(request, DEFAULT_FILE_MARK);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function applyPositionalFileOrDefault(request, positional, defaults) {
|
|
432
|
+
if (!request.file && !request.fromFile && positional.length > 0 && isPathLikeToken(positional[0])) {
|
|
433
|
+
request.file = positional[0];
|
|
434
|
+
return positional.slice(1);
|
|
435
|
+
}
|
|
436
|
+
applyFileDefault(request, defaults);
|
|
437
|
+
return positional;
|
|
438
|
+
}
|
|
439
|
+
function isPathLikeToken(token) {
|
|
440
|
+
return token.includes("/") ||
|
|
441
|
+
token.includes("\\") ||
|
|
442
|
+
/^@[^/\\]+[/\\]/.test(token) ||
|
|
443
|
+
/\.(?:[cm]?[jt]sx?|d\.ts)$/i.test(token);
|
|
444
|
+
}
|
|
445
|
+
function markDefault(request, key) {
|
|
446
|
+
Object.defineProperty(request, key, {
|
|
447
|
+
value: true,
|
|
448
|
+
enumerable: false
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function parseRequestTokens(tokens, lineNumber) {
|
|
452
|
+
const positional = [];
|
|
453
|
+
const fields = {};
|
|
454
|
+
const optionTokens = [];
|
|
455
|
+
for (const token of tokens) {
|
|
456
|
+
if (token.startsWith("+") && token.length > 1) {
|
|
457
|
+
optionTokens.push(token);
|
|
458
|
+
assignField(fields, token.slice(1), true);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
if (token.startsWith("-") && token.length > 1) {
|
|
462
|
+
optionTokens.push(token);
|
|
463
|
+
assignField(fields, token.slice(1), false);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (token.startsWith(">") && token.length > 1) {
|
|
467
|
+
optionTokens.push(token);
|
|
468
|
+
assignField(fields, "save", token.slice(1));
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
const equalIndex = token.indexOf("=");
|
|
472
|
+
if (equalIndex > 0) {
|
|
473
|
+
const rawKey = token.slice(0, equalIndex);
|
|
474
|
+
const rawValue = token.slice(equalIndex + 1);
|
|
475
|
+
optionTokens.push(token);
|
|
476
|
+
assignField(fields, normalizeKey(rawKey), parseValue(rawKey, rawValue));
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (token === "->") {
|
|
480
|
+
throw dslError(lineNumber, "Unexpected move separator in inspect request.");
|
|
481
|
+
}
|
|
482
|
+
positional.push(token);
|
|
483
|
+
}
|
|
484
|
+
return { positional, fields, optionTokens };
|
|
485
|
+
}
|
|
486
|
+
function assignField(fields, key, value) {
|
|
487
|
+
const existing = fields[key];
|
|
488
|
+
if (existing === undefined) {
|
|
489
|
+
fields[key] = value;
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (isRepeatableField(key)) {
|
|
493
|
+
fields[key] = [...asArray(existing), ...asArray(value)];
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
fields[key] = value;
|
|
497
|
+
}
|
|
498
|
+
function isRepeatableField(key) {
|
|
499
|
+
return key === "focus" ||
|
|
500
|
+
key === "scope" ||
|
|
501
|
+
key === "scopes" ||
|
|
502
|
+
key === "file" ||
|
|
503
|
+
key === "files" ||
|
|
504
|
+
key === "exclude" ||
|
|
505
|
+
key === "excludes" ||
|
|
506
|
+
key === "pathExclude" ||
|
|
507
|
+
key === "pathExcludes" ||
|
|
508
|
+
key === "excludePath" ||
|
|
509
|
+
key === "excludePaths" ||
|
|
510
|
+
key === "entities" ||
|
|
511
|
+
key === "only" ||
|
|
512
|
+
key === "except" ||
|
|
513
|
+
key === "kinds";
|
|
514
|
+
}
|
|
515
|
+
function asArray(value) {
|
|
516
|
+
return Array.isArray(value) ? value : [value];
|
|
517
|
+
}
|
|
518
|
+
function normalizeKey(key) {
|
|
519
|
+
if (key === "from") {
|
|
520
|
+
return "fromFile";
|
|
521
|
+
}
|
|
522
|
+
if (key === "no-default-exclude") {
|
|
523
|
+
return "noDefaultExclude";
|
|
524
|
+
}
|
|
525
|
+
if (key === "no-config-exclude") {
|
|
526
|
+
return "noConfigExclude";
|
|
527
|
+
}
|
|
528
|
+
return key;
|
|
529
|
+
}
|
|
530
|
+
function parseValue(key, value) {
|
|
531
|
+
const normalized = normalizeDetailAlias(value);
|
|
532
|
+
const bracketItems = parseBracketList(normalized);
|
|
533
|
+
if (/^-?\d+$/.test(normalized)) {
|
|
534
|
+
return Number(normalized);
|
|
535
|
+
}
|
|
536
|
+
if (normalized === "true") {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
if (normalized === "false") {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
if (key === "entity" || key === "entities") {
|
|
543
|
+
const entities = (bracketItems ?? splitCommaList(normalized)).map(parseEntityToken);
|
|
544
|
+
return key === "entity" && entities.length === 1 ? entities[0] : entities;
|
|
545
|
+
}
|
|
546
|
+
if (key === "only" || key === "except") {
|
|
547
|
+
return (bracketItems ?? splitCommaList(normalized)).flatMap(expandSelectorToken);
|
|
548
|
+
}
|
|
549
|
+
if (bracketItems && isRepeatableField(normalizeKey(key))) {
|
|
550
|
+
return bracketItems;
|
|
551
|
+
}
|
|
552
|
+
if (isRepeatableField(normalizeKey(key)) && normalized.includes(",")) {
|
|
553
|
+
return splitCommaList(normalized);
|
|
554
|
+
}
|
|
555
|
+
return normalized;
|
|
556
|
+
}
|
|
557
|
+
function parseBracketList(value) {
|
|
558
|
+
if (!value.startsWith("[") || !value.endsWith("]")) {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
const inner = value.slice(1, -1).trim();
|
|
562
|
+
if (!inner) {
|
|
563
|
+
return [];
|
|
564
|
+
}
|
|
565
|
+
return splitCommaList(inner);
|
|
566
|
+
}
|
|
567
|
+
function splitCommaList(value) {
|
|
568
|
+
const items = [];
|
|
569
|
+
let current = "";
|
|
570
|
+
let braceDepth = 0;
|
|
571
|
+
let bracketDepth = 0;
|
|
572
|
+
for (const char of value) {
|
|
573
|
+
if (char === "{") {
|
|
574
|
+
braceDepth += 1;
|
|
575
|
+
}
|
|
576
|
+
else if (char === "}" && braceDepth > 0) {
|
|
577
|
+
braceDepth -= 1;
|
|
578
|
+
}
|
|
579
|
+
else if (char === "[") {
|
|
580
|
+
bracketDepth += 1;
|
|
581
|
+
}
|
|
582
|
+
else if (char === "]" && bracketDepth > 0) {
|
|
583
|
+
bracketDepth -= 1;
|
|
584
|
+
}
|
|
585
|
+
if (char === "," && braceDepth === 0 && bracketDepth === 0) {
|
|
586
|
+
if (current.trim()) {
|
|
587
|
+
items.push(current.trim());
|
|
588
|
+
}
|
|
589
|
+
current = "";
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
current += char;
|
|
593
|
+
}
|
|
594
|
+
if (current.trim()) {
|
|
595
|
+
items.push(current.trim());
|
|
596
|
+
}
|
|
597
|
+
return items;
|
|
598
|
+
}
|
|
599
|
+
function normalizeDetailAlias(value) {
|
|
600
|
+
if (value === "sum") {
|
|
601
|
+
return "summary";
|
|
602
|
+
}
|
|
603
|
+
if (value === "loc") {
|
|
604
|
+
return "locations";
|
|
605
|
+
}
|
|
606
|
+
return value;
|
|
607
|
+
}
|
|
608
|
+
function parseEntityToken(token) {
|
|
609
|
+
const groupMatch = token.match(/^(.+)\.\{(.+)\}$/);
|
|
610
|
+
if (groupMatch) {
|
|
611
|
+
const parent = groupMatch[1];
|
|
612
|
+
const members = groupMatch[2];
|
|
613
|
+
if (!parent || !members) {
|
|
614
|
+
return token;
|
|
615
|
+
}
|
|
616
|
+
return {
|
|
617
|
+
parent,
|
|
618
|
+
entities: members.split(",").map((item) => item.trim()).filter(Boolean)
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
const memberMatch = token.match(/^(.+)\.([^./{}]+)$/);
|
|
622
|
+
if (memberMatch) {
|
|
623
|
+
const parent = memberMatch[1];
|
|
624
|
+
const member = memberMatch[2];
|
|
625
|
+
if (!parent || !member) {
|
|
626
|
+
return token;
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
parent,
|
|
630
|
+
entities: [member]
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
return token;
|
|
634
|
+
}
|
|
635
|
+
function expandSelectorToken(token) {
|
|
636
|
+
const groupMatch = token.match(/^(.+)\.\{(.+)\}$/);
|
|
637
|
+
if (groupMatch) {
|
|
638
|
+
const parent = groupMatch[1];
|
|
639
|
+
const members = groupMatch[2];
|
|
640
|
+
if (parent && members) {
|
|
641
|
+
return members.split(",").map((item) => item.trim()).filter(Boolean).map((member) => `${parent}.${member}`);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return [token];
|
|
645
|
+
}
|
|
646
|
+
function buildInspectPayload(defaults, requests) {
|
|
647
|
+
const normalizedRequests = requests.map(cloneRequestWithMarkers);
|
|
648
|
+
const payload = { requests: normalizedRequests };
|
|
649
|
+
hoistDefaultField(payload, normalizedRequests, {
|
|
650
|
+
payloadKey: "file",
|
|
651
|
+
defaultValue: defaults.file,
|
|
652
|
+
predicate: requestCanUsePayloadFile,
|
|
653
|
+
marker: DEFAULT_FILE_MARK
|
|
654
|
+
});
|
|
655
|
+
hoistDefaultField(payload, normalizedRequests, {
|
|
656
|
+
payloadKey: "scope",
|
|
657
|
+
defaultValue: defaults.scope,
|
|
658
|
+
predicate: requestCanUsePayloadScope,
|
|
659
|
+
marker: DEFAULT_SCOPE_MARK
|
|
660
|
+
});
|
|
661
|
+
hoistDefaultField(payload, normalizedRequests, {
|
|
662
|
+
payloadKey: "target",
|
|
663
|
+
defaultValue: defaults.target,
|
|
664
|
+
predicate: requestCanUsePayloadTarget,
|
|
665
|
+
marker: DEFAULT_TARGET_MARK
|
|
666
|
+
});
|
|
667
|
+
if (defaults.save) {
|
|
668
|
+
payload.save = defaults.save;
|
|
669
|
+
}
|
|
670
|
+
assertInspectPayload(payload, normalizedRequests);
|
|
671
|
+
return payload;
|
|
672
|
+
}
|
|
673
|
+
function cloneRequestWithMarkers(request) {
|
|
674
|
+
const clone = { ...request };
|
|
675
|
+
for (const key of [DEFAULT_FILE_MARK, DEFAULT_SCOPE_MARK, DEFAULT_TARGET_MARK]) {
|
|
676
|
+
if (request[key] === true) {
|
|
677
|
+
markDefault(clone, key);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return clone;
|
|
681
|
+
}
|
|
682
|
+
function hoistDefaultField(payload, requests, options) {
|
|
683
|
+
if (options.defaultValue === undefined) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const relevant = requests.filter(options.predicate);
|
|
687
|
+
if (!relevant.some((request) => request[options.payloadKey] !== undefined)) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
payload[options.payloadKey] = options.defaultValue;
|
|
691
|
+
for (const request of relevant) {
|
|
692
|
+
if (request[options.marker] === true && request[options.payloadKey] === options.defaultValue) {
|
|
693
|
+
delete request[options.payloadKey];
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function assertInspectPayload(payload, requests) {
|
|
698
|
+
for (const request of requests) {
|
|
699
|
+
const op = String(request.op ?? "");
|
|
700
|
+
if ((op === "file" || op === "exports" || op === "imports") && typeof request.file !== "string" && typeof payload.file !== "string") {
|
|
701
|
+
throw dslError(0, `${op} requires file=... or @file.`);
|
|
702
|
+
}
|
|
703
|
+
if ((op === "members" || op === "code" || op === "deps") && typeof request.file !== "string" && typeof request.fromFile !== "string" && typeof payload.file !== "string") {
|
|
704
|
+
throw dslError(0, `${op} requires file=..., from=..., or @file.`);
|
|
705
|
+
}
|
|
706
|
+
if (op === "usages" && typeof request.target !== "string" && typeof payload.target !== "string") {
|
|
707
|
+
throw dslError(0, "usages requires target=..., positional target, @target, or @file.");
|
|
708
|
+
}
|
|
709
|
+
if (op === "duplicates" && typeof request.scope !== "string" && !Array.isArray(request.scope) && typeof payload.scope !== "string" && !Array.isArray(payload.scope)) {
|
|
710
|
+
throw dslError(0, "duplicates requires scope=..., positional scope, or @scope.");
|
|
711
|
+
}
|
|
712
|
+
if (op === "graph" && typeof request.fromFile !== "string" && typeof request.scope !== "string" && !Array.isArray(request.scope) && typeof payload.scope !== "string" && !Array.isArray(payload.scope)) {
|
|
713
|
+
throw dslError(0, "graph requires scope=..., positional scope, @scope, or from=...");
|
|
714
|
+
}
|
|
715
|
+
if (op === "tree" && typeof request.scope !== "string" && typeof payload.scope !== "string") {
|
|
716
|
+
throw dslError(0, "tree requires scope=..., positional scope, or @scope.");
|
|
717
|
+
}
|
|
718
|
+
if (op === "cycles" && typeof request.scope !== "string" && !Array.isArray(request.scope) && typeof request.file !== "string" && !Array.isArray(request.files) && typeof payload.scope !== "string" && !Array.isArray(payload.scope)) {
|
|
719
|
+
throw dslError(0, "cycles requires scope=..., files=[...], positional scope, or @scope.");
|
|
720
|
+
}
|
|
721
|
+
if ((op === "aliasCandidates" || op === "alias-candidates") && typeof request.scope !== "string" && typeof payload.scope !== "string") {
|
|
722
|
+
throw dslError(0, "aliasCandidates requires scope=..., positional scope, or @scope.");
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function requestCanUsePayloadFile(request) {
|
|
727
|
+
return (request.op === "file" ||
|
|
728
|
+
request.op === "exports" ||
|
|
729
|
+
request.op === "imports" ||
|
|
730
|
+
request.op === "members" ||
|
|
731
|
+
request.op === "code" ||
|
|
732
|
+
request.op === "deps") && !request.fromFile;
|
|
733
|
+
}
|
|
734
|
+
function requestCanUsePayloadScope(request) {
|
|
735
|
+
return (request.op === "duplicates" ||
|
|
736
|
+
request.op === "graph" ||
|
|
737
|
+
request.op === "tree" ||
|
|
738
|
+
request.op === "cycles" ||
|
|
739
|
+
request.op === "aliasCandidates" ||
|
|
740
|
+
request.op === "alias-candidates") && !request.fromFile;
|
|
741
|
+
}
|
|
742
|
+
function requestCanUsePayloadTarget(request) {
|
|
743
|
+
return request.op === "usages";
|
|
744
|
+
}
|
|
745
|
+
function compileMutationRequest(op, tokens, lineNumber) {
|
|
746
|
+
if (op === "rename") {
|
|
747
|
+
const renames = {};
|
|
748
|
+
for (const token of tokens) {
|
|
749
|
+
if (token.startsWith(">") && token.length > 1) {
|
|
750
|
+
throw dslError(lineNumber, "Use @save <name> for mutation payload saves.");
|
|
751
|
+
}
|
|
752
|
+
const index = token.indexOf("->");
|
|
753
|
+
if (index <= 0 || index === token.length - 2) {
|
|
754
|
+
throw dslError(lineNumber, `Invalid rename pair: ${token}`);
|
|
755
|
+
}
|
|
756
|
+
renames[token.slice(0, index)] = token.slice(index + 2);
|
|
757
|
+
}
|
|
758
|
+
return { op: "rename", renames };
|
|
759
|
+
}
|
|
760
|
+
if (tokens.some((token) => token.startsWith(">") && token.length > 1)) {
|
|
761
|
+
throw dslError(lineNumber, "Use @save <name> for mutation payload saves.");
|
|
762
|
+
}
|
|
763
|
+
const targetFirst = tokens[0];
|
|
764
|
+
if (typeof targetFirst === "string" && targetFirst.endsWith(":") && targetFirst.length > 1) {
|
|
765
|
+
const entities = tokens.slice(1);
|
|
766
|
+
if (entities.length === 0) {
|
|
767
|
+
throw dslError(lineNumber, "Move entities are required.");
|
|
768
|
+
}
|
|
769
|
+
return {
|
|
770
|
+
op: "move",
|
|
771
|
+
entities,
|
|
772
|
+
targetFile: targetFirst.slice(0, -1)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
throw dslError(lineNumber, "Invalid move syntax. Expected: move target.ts: entity entity");
|
|
776
|
+
}
|
|
777
|
+
function compileImportNormalizeRequest(tokens, defaults, lineNumber) {
|
|
778
|
+
const { positional, fields } = parseRequestTokens(tokens, lineNumber);
|
|
779
|
+
const request = { ...fields };
|
|
780
|
+
const scope = request.scope ?? positional[0] ?? defaults.scope;
|
|
781
|
+
if (scope !== undefined) {
|
|
782
|
+
request.scope = scope;
|
|
783
|
+
}
|
|
784
|
+
if (Array.isArray(request.scope)) {
|
|
785
|
+
throw dslError(lineNumber, "imports.normalize scope expects one file/dir; use multiple imports.normalize lines for multiple scopes.");
|
|
786
|
+
}
|
|
787
|
+
if (typeof request.scope !== "string" || request.scope.length === 0) {
|
|
788
|
+
throw dslError(lineNumber, "imports.normalize requires scope=..., positional scope, or @scope.");
|
|
789
|
+
}
|
|
790
|
+
if (positional.length > 1) {
|
|
791
|
+
throw dslError(lineNumber, "imports.normalize accepts one positional scope; use key=value fields for options.");
|
|
792
|
+
}
|
|
793
|
+
return request;
|
|
794
|
+
}
|
|
795
|
+
function compileViewRequest(tokens, lineNumber) {
|
|
796
|
+
const { positional, fields } = parseRequestTokens(tokens, lineNumber);
|
|
797
|
+
const handle = fields.handle ?? fields.from ?? positional[0];
|
|
798
|
+
if (typeof handle !== "string" || handle.length === 0) {
|
|
799
|
+
throw dslError(lineNumber, "view requires a result handle.");
|
|
800
|
+
}
|
|
801
|
+
if (positional.length > 1) {
|
|
802
|
+
throw dslError(lineNumber, "view accepts one positional handle; use key=value fields for options.");
|
|
803
|
+
}
|
|
804
|
+
const request = {
|
|
805
|
+
handle
|
|
806
|
+
};
|
|
807
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
808
|
+
if (key === "handle" || key === "from") {
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
request[key] = value;
|
|
812
|
+
}
|
|
813
|
+
return request;
|
|
814
|
+
}
|
|
815
|
+
function compilePlanRow(tokens, lineNumber) {
|
|
816
|
+
const colonIndex = tokens.findIndex((token) => token.endsWith(":"));
|
|
817
|
+
if (colonIndex !== 0) {
|
|
818
|
+
throw dslError(lineNumber, "Plan syntax is: plan target.ts: entity entity");
|
|
819
|
+
}
|
|
820
|
+
const target = tokens[0].slice(0, -1);
|
|
821
|
+
const entities = tokens.slice(1);
|
|
822
|
+
if (!target || entities.length === 0) {
|
|
823
|
+
throw dslError(lineNumber, "Plan row requires target and at least one entity.");
|
|
824
|
+
}
|
|
825
|
+
return { target, entities };
|
|
826
|
+
}
|
|
827
|
+
function requireDefault(value, name, lineNumber) {
|
|
828
|
+
if (!value) {
|
|
829
|
+
throw dslError(lineNumber, `${name} is required.`);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
function dslError(lineNumber, message) {
|
|
833
|
+
const prefix = lineNumber > 0 ? `DSL line ${lineNumber}: ` : "DSL: ";
|
|
834
|
+
return new Error(`${prefix}${message}`);
|
|
835
|
+
}
|
|
836
|
+
function compactObject(input) {
|
|
837
|
+
return Object.fromEntries(Object.entries(input).filter((entry) => entry[1] !== undefined));
|
|
838
|
+
}
|