@cleocode/core 2026.10.1 → 2026.10.3
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/dist/build-provenance.json +2 -2
- package/dist/cloud/http.d.ts +2 -0
- package/dist/cloud/http.d.ts.map +1 -1
- package/dist/cloud/http.js +3 -0
- package/dist/cloud/http.js.map +1 -1
- package/dist/cloud/journal.d.ts +9 -5
- package/dist/cloud/journal.d.ts.map +1 -1
- package/dist/cloud/journal.js +29 -8
- package/dist/cloud/journal.js.map +1 -1
- package/dist/cloud/manifest-check.d.ts +140 -4
- package/dist/cloud/manifest-check.d.ts.map +1 -1
- package/dist/cloud/manifest-check.js +322 -10
- package/dist/cloud/manifest-check.js.map +1 -1
- package/dist/cloud/nexus-attach.d.ts +25 -0
- package/dist/cloud/nexus-attach.d.ts.map +1 -1
- package/dist/cloud/nexus-attach.js +81 -6
- package/dist/cloud/nexus-attach.js.map +1 -1
- package/dist/cloud/nexus-cloud-activity.d.ts +37 -0
- package/dist/cloud/nexus-cloud-activity.d.ts.map +1 -0
- package/dist/cloud/nexus-cloud-activity.js +79 -0
- package/dist/cloud/nexus-cloud-activity.js.map +1 -0
- package/dist/cloud/nexus-cloud-status.d.ts.map +1 -1
- package/dist/cloud/nexus-cloud-status.js +36 -0
- package/dist/cloud/nexus-cloud-status.js.map +1 -1
- package/dist/cloud/nexus-device.d.ts +1 -1
- package/dist/cloud/nexus-enrol.d.ts.map +1 -1
- package/dist/cloud/nexus-enrol.js +5 -0
- package/dist/cloud/nexus-enrol.js.map +1 -1
- package/dist/cloud/nexus-home.d.ts +74 -0
- package/dist/cloud/nexus-home.d.ts.map +1 -0
- package/dist/cloud/nexus-home.js +97 -0
- package/dist/cloud/nexus-home.js.map +1 -0
- package/dist/cloud/nexus-vault-keys.d.ts +130 -0
- package/dist/cloud/nexus-vault-keys.d.ts.map +1 -0
- package/dist/cloud/nexus-vault-keys.js +347 -0
- package/dist/cloud/nexus-vault-keys.js.map +1 -0
- package/dist/cloud/nexus-vault-state.d.ts +121 -0
- package/dist/cloud/nexus-vault-state.d.ts.map +1 -0
- package/dist/cloud/nexus-vault-state.js +274 -0
- package/dist/cloud/nexus-vault-state.js.map +1 -0
- package/dist/cloud/nexus-vault.d.ts +160 -0
- package/dist/cloud/nexus-vault.d.ts.map +1 -0
- package/dist/cloud/nexus-vault.js +1745 -0
- package/dist/cloud/nexus-vault.js.map +1 -0
- package/dist/cloud/signing.d.ts +24 -8
- package/dist/cloud/signing.d.ts.map +1 -1
- package/dist/cloud/signing.js +61 -15
- package/dist/cloud/signing.js.map +1 -1
- package/dist/docs/export-document.js +8137 -3318
- package/dist/docs/export-document.js.map +3 -3
- package/dist/doctor/migrations.d.ts +75 -0
- package/dist/doctor/migrations.d.ts.map +1 -0
- package/dist/doctor/migrations.js +136 -0
- package/dist/doctor/migrations.js.map +1 -0
- package/dist/doctor/sync-sealer.d.ts +48 -0
- package/dist/doctor/sync-sealer.d.ts.map +1 -0
- package/dist/doctor/sync-sealer.js +109 -0
- package/dist/doctor/sync-sealer.js.map +1 -0
- package/dist/doctor/sync-triggers.d.ts +53 -0
- package/dist/doctor/sync-triggers.d.ts.map +1 -0
- package/dist/doctor/sync-triggers.js +157 -0
- package/dist/doctor/sync-triggers.js.map +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +5 -1
- package/dist/init.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/llm/plugin-facade.js +8442 -3623
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/nexus/projects-clean.d.ts +3 -0
- package/dist/nexus/projects-clean.d.ts.map +1 -1
- package/dist/nexus/projects-clean.js +9 -3
- package/dist/nexus/projects-clean.js.map +1 -1
- package/dist/nexus/registry-roots.d.ts +3 -1
- package/dist/nexus/registry-roots.d.ts.map +1 -1
- package/dist/nexus/registry-roots.js +5 -2
- package/dist/nexus/registry-roots.js.map +1 -1
- package/dist/nexus/registry.d.ts +8 -1
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +24 -10
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/workspace.d.ts +4 -1
- package/dist/nexus/workspace.d.ts.map +1 -1
- package/dist/nexus/workspace.js +10 -4
- package/dist/nexus/workspace.js.map +1 -1
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +7 -2
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestrate/worker-verify.d.ts +121 -12
- package/dist/orchestrate/worker-verify.d.ts.map +1 -1
- package/dist/orchestrate/worker-verify.js +172 -21
- package/dist/orchestrate/worker-verify.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +15 -9
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +9 -0
- package/dist/release/ci-evidence.d.ts.map +1 -1
- package/dist/release/ci-evidence.js +9 -2
- package/dist/release/ci-evidence.js.map +1 -1
- package/dist/resources/backend.d.ts +15 -3
- package/dist/resources/backend.d.ts.map +1 -1
- package/dist/resources/backend.js +7 -3
- package/dist/resources/backend.js.map +1 -1
- package/dist/resources/darwin-backend.d.ts +142 -0
- package/dist/resources/darwin-backend.d.ts.map +1 -0
- package/dist/resources/darwin-backend.js +288 -0
- package/dist/resources/darwin-backend.js.map +1 -0
- package/dist/resources/governor.d.ts +44 -1
- package/dist/resources/governor.d.ts.map +1 -1
- package/dist/resources/governor.js +100 -36
- package/dist/resources/governor.js.map +1 -1
- package/dist/resources/heavy-command.d.ts +132 -0
- package/dist/resources/heavy-command.d.ts.map +1 -0
- package/dist/resources/heavy-command.js +768 -0
- package/dist/resources/heavy-command.js.map +1 -0
- package/dist/resources/monitor.d.ts +50 -1
- package/dist/resources/monitor.d.ts.map +1 -1
- package/dist/resources/monitor.js +83 -1
- package/dist/resources/monitor.js.map +1 -1
- package/dist/resources/run-admission.d.ts +303 -0
- package/dist/resources/run-admission.d.ts.map +1 -0
- package/dist/resources/run-admission.js +648 -0
- package/dist/resources/run-admission.js.map +1 -0
- package/dist/resources/run-class.d.ts +111 -0
- package/dist/resources/run-class.d.ts.map +1 -0
- package/dist/resources/run-class.js +658 -0
- package/dist/resources/run-class.js.map +1 -0
- package/dist/resources/run-governed.d.ts +158 -0
- package/dist/resources/run-governed.d.ts.map +1 -0
- package/dist/resources/run-governed.js +406 -0
- package/dist/resources/run-governed.js.map +1 -0
- package/dist/resources/slot-holder.d.ts +267 -0
- package/dist/resources/slot-holder.d.ts.map +1 -0
- package/dist/resources/slot-holder.js +505 -0
- package/dist/resources/slot-holder.js.map +1 -0
- package/dist/resources/tool-groups.d.ts +74 -0
- package/dist/resources/tool-groups.d.ts.map +1 -0
- package/dist/resources/tool-groups.js +118 -0
- package/dist/resources/tool-groups.js.map +1 -0
- package/dist/routing/build-command-groups.d.ts.map +1 -1
- package/dist/routing/build-command-groups.js +1 -0
- package/dist/routing/build-command-groups.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +8446 -3627
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sentient/cross-project-hygiene.d.ts +3 -2
- package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
- package/dist/sentient/cross-project-hygiene.js +5 -2
- package/dist/sentient/cross-project-hygiene.js.map +1 -1
- package/dist/sentient/state.d.ts +7 -0
- package/dist/sentient/state.d.ts.map +1 -1
- package/dist/sentient/state.js.map +1 -1
- package/dist/sentient/tick.d.ts +14 -2
- package/dist/sentient/tick.d.ts.map +1 -1
- package/dist/sentient/tick.js +63 -4
- package/dist/sentient/tick.js.map +1 -1
- package/dist/store/backup-recover.d.ts.map +1 -1
- package/dist/store/backup-recover.js +5 -0
- package/dist/store/backup-recover.js.map +1 -1
- package/dist/store/data-accessor.d.ts +1 -0
- package/dist/store/data-accessor.d.ts.map +1 -1
- package/dist/store/data-accessor.js +7 -0
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +23 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +126 -36
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/recovery.d.ts.map +1 -1
- package/dist/store/exodus/recovery.js +15 -0
- package/dist/store/exodus/recovery.js.map +1 -1
- package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
- package/dist/store/legacy-tasks-lineage.js +5 -0
- package/dist/store/legacy-tasks-lineage.js.map +1 -1
- package/dist/store/lock.d.ts +8 -1
- package/dist/store/lock.d.ts.map +1 -1
- package/dist/store/lock.js +10 -2
- package/dist/store/lock.js.map +1 -1
- package/dist/store/migration-manager.d.ts +5 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +11 -0
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/migration-runner.d.ts +158 -0
- package/dist/store/migration-runner.d.ts.map +1 -0
- package/dist/store/migration-runner.js +493 -0
- package/dist/store/migration-runner.js.map +1 -0
- package/dist/store/portable-bundle-import.d.ts +15 -1
- package/dist/store/portable-bundle-import.d.ts.map +1 -1
- package/dist/store/portable-bundle-import.js +24 -4
- package/dist/store/portable-bundle-import.js.map +1 -1
- package/dist/store/portable-bundle-relocate.d.ts +43 -0
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
- package/dist/store/portable-bundle-relocate.js +79 -5
- package/dist/store/portable-bundle-relocate.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts +42 -0
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +132 -25
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/portable-bundle.d.ts +40 -0
- package/dist/store/portable-bundle.d.ts.map +1 -1
- package/dist/store/portable-bundle.js +43 -7
- package/dist/store/portable-bundle.js.map +1 -1
- package/dist/store/row-identity-registry.d.ts +137 -7
- package/dist/store/row-identity-registry.d.ts.map +1 -1
- package/dist/store/row-identity-registry.js +364 -9
- package/dist/store/row-identity-registry.js.map +1 -1
- package/dist/store/row-identity.d.ts.map +1 -1
- package/dist/store/row-identity.js +9 -10
- package/dist/store/row-identity.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +10 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.d.ts +31 -0
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +5 -1
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/sync/capture.d.ts +203 -0
- package/dist/store/sync/capture.d.ts.map +1 -0
- package/dist/store/sync/capture.js +562 -0
- package/dist/store/sync/capture.js.map +1 -0
- package/dist/store/sync/clock-store.d.ts.map +1 -1
- package/dist/store/sync/clock-store.js +2 -0
- package/dist/store/sync/clock-store.js.map +1 -1
- package/dist/store/sync/fk-orphans.d.ts +133 -0
- package/dist/store/sync/fk-orphans.d.ts.map +1 -0
- package/dist/store/sync/fk-orphans.js +265 -0
- package/dist/store/sync/fk-orphans.js.map +1 -0
- package/dist/store/sync/flags.d.ts +7 -0
- package/dist/store/sync/flags.d.ts.map +1 -1
- package/dist/store/sync/flags.js +16 -0
- package/dist/store/sync/flags.js.map +1 -1
- package/dist/store/sync/hlc.d.ts.map +1 -1
- package/dist/store/sync/hlc.js +4 -0
- package/dist/store/sync/hlc.js.map +1 -1
- package/dist/store/sync/identity-fill.d.ts +45 -0
- package/dist/store/sync/identity-fill.d.ts.map +1 -0
- package/dist/store/sync/identity-fill.js +85 -0
- package/dist/store/sync/identity-fill.js.map +1 -0
- package/dist/store/sync/machinery.d.ts +27 -0
- package/dist/store/sync/machinery.d.ts.map +1 -0
- package/dist/store/sync/machinery.js +44 -0
- package/dist/store/sync/machinery.js.map +1 -0
- package/dist/store/sync/netting.d.ts +120 -0
- package/dist/store/sync/netting.d.ts.map +1 -0
- package/dist/store/sync/netting.js +336 -0
- package/dist/store/sync/netting.js.map +1 -0
- package/dist/store/sync/replica.d.ts +27 -2
- package/dist/store/sync/replica.d.ts.map +1 -1
- package/dist/store/sync/replica.js +47 -3
- package/dist/store/sync/replica.js.map +1 -1
- package/dist/store/sync/schema.d.ts +12 -0
- package/dist/store/sync/schema.d.ts.map +1 -1
- package/dist/store/sync/schema.js +21 -0
- package/dist/store/sync/schema.js.map +1 -1
- package/dist/store/sync/seal-backlog.d.ts +21 -0
- package/dist/store/sync/seal-backlog.d.ts.map +1 -0
- package/dist/store/sync/seal-backlog.js +24 -0
- package/dist/store/sync/seal-backlog.js.map +1 -0
- package/dist/store/sync/sealer-values.d.ts +34 -0
- package/dist/store/sync/sealer-values.d.ts.map +1 -0
- package/dist/store/sync/sealer-values.js +53 -0
- package/dist/store/sync/sealer-values.js.map +1 -0
- package/dist/store/sync/sealer.d.ts +145 -0
- package/dist/store/sync/sealer.d.ts.map +1 -0
- package/dist/store/sync/sealer.js +906 -0
- package/dist/store/sync/sealer.js.map +1 -0
- package/dist/store/sync/structural.d.ts +63 -0
- package/dist/store/sync/structural.d.ts.map +1 -0
- package/dist/store/sync/structural.js +180 -0
- package/dist/store/sync/structural.js.map +1 -0
- package/dist/store/sync/timestamps.d.ts +92 -0
- package/dist/store/sync/timestamps.d.ts.map +1 -0
- package/dist/store/sync/timestamps.js +228 -0
- package/dist/store/sync/timestamps.js.map +1 -0
- package/dist/store/sync/tombstones.d.ts +75 -0
- package/dist/store/sync/tombstones.d.ts.map +1 -0
- package/dist/store/sync/tombstones.js +103 -0
- package/dist/store/sync/tombstones.js.map +1 -0
- package/dist/store/sync/trigger-classes.d.ts +221 -0
- package/dist/store/sync/trigger-classes.d.ts.map +1 -0
- package/dist/store/sync/trigger-classes.js +441 -0
- package/dist/store/sync/trigger-classes.js.map +1 -0
- package/dist/store/sync/trigger-suspend-at-path.d.ts +23 -0
- package/dist/store/sync/trigger-suspend-at-path.d.ts.map +1 -0
- package/dist/store/sync/trigger-suspend-at-path.js +44 -0
- package/dist/store/sync/trigger-suspend-at-path.js.map +1 -0
- package/dist/store/sync/writer-version.d.ts +43 -0
- package/dist/store/sync/writer-version.d.ts.map +1 -0
- package/dist/store/sync/writer-version.js +90 -0
- package/dist/store/sync/writer-version.js.map +1 -0
- package/dist/store/table-classification.d.ts.map +1 -1
- package/dist/store/table-classification.js +102 -0
- package/dist/store/table-classification.js.map +1 -1
- package/dist/store/trigger-suspend-schema.d.ts +44 -0
- package/dist/store/trigger-suspend-schema.d.ts.map +1 -0
- package/dist/store/trigger-suspend-schema.js +25 -0
- package/dist/store/trigger-suspend-schema.js.map +1 -0
- package/dist/store/vault-manifest.d.ts +365 -0
- package/dist/store/vault-manifest.d.ts.map +1 -0
- package/dist/store/vault-manifest.js +812 -0
- package/dist/store/vault-manifest.js.map +1 -0
- package/dist/store/writer-lease.d.ts +31 -0
- package/dist/store/writer-lease.d.ts.map +1 -1
- package/dist/store/writer-lease.js +65 -2
- package/dist/store/writer-lease.js.map +1 -1
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +21 -0
- package/dist/system/health.js.map +1 -1
- package/dist/system/project-health.d.ts.map +1 -1
- package/dist/system/project-health.js +3 -1
- package/dist/system/project-health.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +58 -0
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +75 -6
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/affected-scope.d.ts +150 -23
- package/dist/tasks/affected-scope.d.ts.map +1 -1
- package/dist/tasks/affected-scope.js +320 -32
- package/dist/tasks/affected-scope.js.map +1 -1
- package/dist/tasks/change-set.d.ts +96 -0
- package/dist/tasks/change-set.d.ts.map +1 -1
- package/dist/tasks/change-set.js +169 -4
- package/dist/tasks/change-set.js.map +1 -1
- package/dist/tasks/complete-ci.d.ts +115 -0
- package/dist/tasks/complete-ci.d.ts.map +1 -0
- package/dist/tasks/complete-ci.js +171 -0
- package/dist/tasks/complete-ci.js.map +1 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +50 -17
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/compute-task-view.d.ts.map +1 -1
- package/dist/tasks/compute-task-view.js +7 -0
- package/dist/tasks/compute-task-view.js.map +1 -1
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +51 -30
- package/dist/tasks/done-plan.js.map +1 -1
- package/dist/tasks/done-record.d.ts +6 -0
- package/dist/tasks/done-record.d.ts.map +1 -1
- package/dist/tasks/done-record.js +9 -3
- package/dist/tasks/done-record.js.map +1 -1
- package/dist/tasks/evidence.d.ts +3 -2
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +143 -12
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-notes.d.ts +22 -0
- package/dist/tasks/gate-notes.d.ts.map +1 -0
- package/dist/tasks/gate-notes.js +33 -0
- package/dist/tasks/gate-notes.js.map +1 -0
- package/dist/tasks/index.d.ts +2 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +2 -1
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/test-run-binding.d.ts +117 -0
- package/dist/tasks/test-run-binding.d.ts.map +1 -0
- package/dist/tasks/test-run-binding.js +365 -0
- package/dist/tasks/test-run-binding.js.map +1 -0
- package/dist/tasks/tool-cache-env.d.ts +123 -0
- package/dist/tasks/tool-cache-env.d.ts.map +1 -0
- package/dist/tasks/tool-cache-env.js +287 -0
- package/dist/tasks/tool-cache-env.js.map +1 -0
- package/dist/tasks/tool-cache-failed-first.d.ts +155 -0
- package/dist/tasks/tool-cache-failed-first.d.ts.map +1 -0
- package/dist/tasks/tool-cache-failed-first.js +285 -0
- package/dist/tasks/tool-cache-failed-first.js.map +1 -0
- package/dist/tasks/tool-cache.d.ts +375 -55
- package/dist/tasks/tool-cache.d.ts.map +1 -1
- package/dist/tasks/tool-cache.js +912 -303
- package/dist/tasks/tool-cache.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +4 -3
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +15 -4
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/tool-semaphore.d.ts +67 -7
- package/dist/tasks/tool-semaphore.d.ts.map +1 -1
- package/dist/tasks/tool-semaphore.js +134 -56
- package/dist/tasks/tool-semaphore.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +4 -0
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +6 -0
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +8 -0
- package/dist/validation/engine-ops.js.map +1 -1
- package/migrations/drizzle-cleo-project/20260930170000_t12819-trigger-suspend-clause/migration.sql +367 -0
- package/migrations/sync-journal/20260930120000_t12343-capture/migration.sql +47 -0
- package/migrations/sync-journal/20261001170000_t12984-sealer/migration.sql +101 -0
- package/package.json +13 -13
- package/templates/CLEO-INJECTION.md +5 -5
- package/templates/CLEO-REFERENCE.md +8 -4
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a command is, for `cleo run` and the provider hook (T12983): the
|
|
3
|
+
* governor class it needs, whether it is heavy at all, and whether it may be
|
|
4
|
+
* paused. Pure and dependency-free (type-only imports, plus `node:fs` for the
|
|
5
|
+
* workspace-root check), so a hook that runs on every Bash call can import it
|
|
6
|
+
* cheaply.
|
|
7
|
+
*
|
|
8
|
+
* Only the COMMAND WORD counts: the tool (`argv[0]` after `env`/`nice`/
|
|
9
|
+
* `time` and `NAME=value` prefixes), or for a package manager its script
|
|
10
|
+
* (`pnpm build`, `npm run test:unit`) or exec'd tool (`npx vitest`,
|
|
11
|
+
* `pnpm exec tsc`, `pnpm dlx`). A tool name inside an argument never counts
|
|
12
|
+
* (`git commit -m "fix vitest"`, `grep -rn tsc .`, `cd packages/next`).
|
|
13
|
+
* `--version`/`--help` and watch/dev/serve modes are never heavy: a watcher
|
|
14
|
+
* would hold a slot forever.
|
|
15
|
+
*
|
|
16
|
+
* @module resources/run-class
|
|
17
|
+
* @task T12979
|
|
18
|
+
* @epic T12978
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync } from 'node:fs';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
/** Short class names accepted by `cleo run --class`. */
|
|
23
|
+
export const RUN_CLASS_ALIASES = Object.freeze({
|
|
24
|
+
test: 'test-run',
|
|
25
|
+
'test-run': 'test-run',
|
|
26
|
+
build: 'scoped-build',
|
|
27
|
+
'scoped-build': 'scoped-build',
|
|
28
|
+
typecheck: 'scoped-build',
|
|
29
|
+
install: 'scoped-build',
|
|
30
|
+
scan: 'scoped-build',
|
|
31
|
+
'full-build': 'full-build',
|
|
32
|
+
db: 'db-heavy',
|
|
33
|
+
'db-heavy': 'db-heavy',
|
|
34
|
+
});
|
|
35
|
+
const TEST_RUNNERS = /^(vitest|jest|mocha|ava|tap|playwright|pytest|rspec|phpunit)$/;
|
|
36
|
+
const BUILD_TOOLS = /^(tsc|tsup|turbo|vite|esbuild|webpack|rollup|next|nx|biome|eslint|svelte-check)$/;
|
|
37
|
+
const PACKAGE_MANAGERS = /^(npm|pnpm|yarn|bun)$/;
|
|
38
|
+
const EXEC_RUNNERS = /^(npx|pnpx|bunx)$/;
|
|
39
|
+
const PREFIX_COMMANDS = /^(env|nice|time|nohup)$/;
|
|
40
|
+
const INSTALL_VERBS = /^(install|i|ci|add|update|up|upgrade)$/;
|
|
41
|
+
const HEAVY_SCRIPTS = /^(test|t|build|typecheck|lint|check|install|i|ci)(:|$)/;
|
|
42
|
+
/** Serve/dev words that count only as a name's FIRST segment (`dev:web`, not `build:dev`). */
|
|
43
|
+
const LEADING_WATCH_WORD = /^(dev|start|preview)$/;
|
|
44
|
+
/** Watch/serve words that count in any segment (`test:watch`, `docs:serve`). */
|
|
45
|
+
const ANY_WATCH_WORD = /^(watch|serve)$/;
|
|
46
|
+
/** Watch-mode flags (`-w` is per tool: maxWorkers for jest; `--ui` per tool: a value for turbo). */
|
|
47
|
+
const WATCH_FLAGS = new Set(['--watch', '--watchAll', '--serve']);
|
|
48
|
+
/** Tools whose `-w` is `--watch` (for jest it is --maxWorkers, for prettier and gofmt --write). */
|
|
49
|
+
const SHORT_WATCH_TOOLS = /^(tsc|rollup|webpack|vite|vitest|mocha|ava|sass|babel|tailwindcss|swc|tsx)$/;
|
|
50
|
+
/** Tools whose `--ui` opens a long-lived UI server. */
|
|
51
|
+
const UI_SERVES = /^(vitest|playwright)$/;
|
|
52
|
+
/** Subcommands that serve or watch (only as the first positional word). */
|
|
53
|
+
const WATCH_SUBCOMMANDS = new Set(['watch', 'dev', 'serve', 'start', 'preview']);
|
|
54
|
+
/**
|
|
55
|
+
* Known tools with no serve/watch subcommand: their first positional word is a
|
|
56
|
+
* path or a flag value, never a mode (`pytest -k dev`, `jest -t start`,
|
|
57
|
+
* `mocha -g watch`, `tsc -p dev`). Any other tool keeps the subcommand rule.
|
|
58
|
+
*/
|
|
59
|
+
const NO_WATCH_SUBCOMMAND = /^(jest|mocha|ava|tap|playwright|pytest|rspec|phpunit|tsc|tsup|esbuild|rollup|eslint|biome|svelte-check|go|prettier|gofmt)$/;
|
|
60
|
+
/** Short flags that take a value, for tools that do have serve/watch subcommands (`vitest -t serve`). */
|
|
61
|
+
const SHORT_VALUE_FLAGS = {
|
|
62
|
+
vitest: ['-t', '-c', '-r'],
|
|
63
|
+
vite: ['-c', '-m', '-l', '-f'],
|
|
64
|
+
webpack: ['-c', '-o', '-t', '-d', '-e'],
|
|
65
|
+
next: ['-p', '-H'],
|
|
66
|
+
};
|
|
67
|
+
/** `next` subcommands that run once (`next lint`); with no subcommand, `dev` or `start` it serves. */
|
|
68
|
+
const NEXT_ONESHOT = /^(build|lint|info|export|telemetry|typegen|experimental-[\w-]+)$/;
|
|
69
|
+
/** `next` subcommands that build nothing either: never heavy. */
|
|
70
|
+
const NEXT_ADMIN = /^(info|telemetry)$/;
|
|
71
|
+
/** `vite` subcommands that run once; anything else serves (`vite`, `vite dev`, `vite preview`). */
|
|
72
|
+
const VITE_ONESHOT = /^(build|optimize)$/;
|
|
73
|
+
/**
|
|
74
|
+
* CLEO's own CLI as a command word: `cleo`, `ct`, a versioned package
|
|
75
|
+
* (`@cleocode/cleo@latest`), or a script path (`…/bin/cleo.js`,
|
|
76
|
+
* `packages/cleo/dist/cli/index.js`).
|
|
77
|
+
*/
|
|
78
|
+
const CLEO_BIN = /^(cleo|ct)(@[\w.-]+|\.[cm]?js)?$/;
|
|
79
|
+
const CLEO_SCRIPT = /(^|\/)(cleo|ct)(\.[cm]?js)?$|(^|\/)cleo\/dist\/cli\/index\.js$/;
|
|
80
|
+
/** node flags that take a value, so the value is never read as the script. */
|
|
81
|
+
const NODE_VALUE_FLAGS = new Set([
|
|
82
|
+
'-r',
|
|
83
|
+
'--require',
|
|
84
|
+
'--import',
|
|
85
|
+
'--loader',
|
|
86
|
+
'--experimental-loader',
|
|
87
|
+
'-C',
|
|
88
|
+
'--conditions',
|
|
89
|
+
]);
|
|
90
|
+
const INFO_FLAGS = new Set(['--version', '--help', '-h']);
|
|
91
|
+
/**
|
|
92
|
+
* Short flags that mean `--version`, per tool; any other tool: both. `-v` is
|
|
93
|
+
* verbose for go, pytest and cargo; jest and vitest have no `-V`.
|
|
94
|
+
*/
|
|
95
|
+
const SHORT_VERSION_FLAGS = {
|
|
96
|
+
jest: ['-v'],
|
|
97
|
+
vitest: ['-v'],
|
|
98
|
+
pytest: ['-V'],
|
|
99
|
+
mocha: ['-V'],
|
|
100
|
+
cargo: ['-V'],
|
|
101
|
+
go: [],
|
|
102
|
+
};
|
|
103
|
+
/** turbo flags that take a value (so the value is never read as a task). */
|
|
104
|
+
const TURBO_VALUE_FLAGS = new Set([
|
|
105
|
+
'--filter',
|
|
106
|
+
'-F',
|
|
107
|
+
'--concurrency',
|
|
108
|
+
'--cache',
|
|
109
|
+
'--cache-dir',
|
|
110
|
+
'--cache-workers',
|
|
111
|
+
'--output-logs',
|
|
112
|
+
'--log-order',
|
|
113
|
+
'--log-prefix',
|
|
114
|
+
'--env-mode',
|
|
115
|
+
'--global-deps',
|
|
116
|
+
'--ui',
|
|
117
|
+
'--cwd',
|
|
118
|
+
'--team',
|
|
119
|
+
'--token',
|
|
120
|
+
'--api',
|
|
121
|
+
'--login',
|
|
122
|
+
'--heap',
|
|
123
|
+
'--trace',
|
|
124
|
+
'--cpuprofile',
|
|
125
|
+
'--profile',
|
|
126
|
+
'--anon-profile',
|
|
127
|
+
'--remote-cache-timeout',
|
|
128
|
+
'--pkg-inference-root',
|
|
129
|
+
'--root-turbo-json',
|
|
130
|
+
]);
|
|
131
|
+
/** turbo subcommands that run no task (`turbo login`, `turbo prune`). `turbo watch` watches. */
|
|
132
|
+
const TURBO_ADMIN = new Set([
|
|
133
|
+
'login',
|
|
134
|
+
'logout',
|
|
135
|
+
'link',
|
|
136
|
+
'unlink',
|
|
137
|
+
'prune',
|
|
138
|
+
'gen',
|
|
139
|
+
'generate',
|
|
140
|
+
'daemon',
|
|
141
|
+
'info',
|
|
142
|
+
'ls',
|
|
143
|
+
'query',
|
|
144
|
+
'scan',
|
|
145
|
+
'telemetry',
|
|
146
|
+
'bin',
|
|
147
|
+
'completion',
|
|
148
|
+
'boundaries',
|
|
149
|
+
]);
|
|
150
|
+
/** nx subcommands that run no target (`nx graph`, `nx show`). `nx watch` watches. */
|
|
151
|
+
const NX_ADMIN = new Set([
|
|
152
|
+
'graph',
|
|
153
|
+
'show',
|
|
154
|
+
'report',
|
|
155
|
+
'list',
|
|
156
|
+
'migrate',
|
|
157
|
+
'g',
|
|
158
|
+
'generate',
|
|
159
|
+
'reset',
|
|
160
|
+
'daemon',
|
|
161
|
+
'init',
|
|
162
|
+
'add',
|
|
163
|
+
'release',
|
|
164
|
+
'connect',
|
|
165
|
+
'connect-to-nx-cloud',
|
|
166
|
+
'login',
|
|
167
|
+
'logout',
|
|
168
|
+
'repair',
|
|
169
|
+
'sync',
|
|
170
|
+
'view-logs',
|
|
171
|
+
'import',
|
|
172
|
+
]);
|
|
173
|
+
/** nx flags that take a value. `-t`/`--target(s)` are read as tasks. */
|
|
174
|
+
const NX_VALUE_FLAGS = new Set([
|
|
175
|
+
'--configuration',
|
|
176
|
+
'-c',
|
|
177
|
+
'--projects',
|
|
178
|
+
'-p',
|
|
179
|
+
'--exclude',
|
|
180
|
+
'--parallel',
|
|
181
|
+
'--base',
|
|
182
|
+
'--head',
|
|
183
|
+
'--output-style',
|
|
184
|
+
'--files',
|
|
185
|
+
]);
|
|
186
|
+
/** nx flags that name the tasks of `run-many` / `affected`. */
|
|
187
|
+
const NX_TARGET_FLAGS = new Set(['-t', '--target', '--targets']);
|
|
188
|
+
/** Package-manager flags that take a value. */
|
|
189
|
+
const PM_VALUE_FLAGS = new Set([
|
|
190
|
+
'--workspace-concurrency',
|
|
191
|
+
'--reporter',
|
|
192
|
+
'--loglevel',
|
|
193
|
+
'--filter',
|
|
194
|
+
'-F',
|
|
195
|
+
'-C',
|
|
196
|
+
'--dir',
|
|
197
|
+
'--prefix',
|
|
198
|
+
'--workspace',
|
|
199
|
+
'-w',
|
|
200
|
+
'--cwd',
|
|
201
|
+
]);
|
|
202
|
+
/** Flags that scope a package-manager command to some packages. */
|
|
203
|
+
const SCOPING_FLAGS = new Set([
|
|
204
|
+
'--filter',
|
|
205
|
+
'-F',
|
|
206
|
+
'-C',
|
|
207
|
+
'--dir',
|
|
208
|
+
'--prefix',
|
|
209
|
+
'--workspace',
|
|
210
|
+
'-w',
|
|
211
|
+
'--cwd',
|
|
212
|
+
]);
|
|
213
|
+
/** Flags that run a script across every workspace package. */
|
|
214
|
+
const RECURSIVE_FLAGS = new Set(['-r', '--recursive', '--workspaces', '-ws']);
|
|
215
|
+
function base(token) {
|
|
216
|
+
return token.split('/').pop() ?? token;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Resolve the command word of `argv`.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* commandTarget(['pnpm', '--filter', 'x', 'run', 'test:unit']).script; // 'test:unit'
|
|
224
|
+
* commandTarget(['npx', '-y', 'vitest', 'run']).tool; // 'vitest'
|
|
225
|
+
* commandTarget(['env', 'CI=1', 'tsc', '-b']).tool; // 'tsc'
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export function commandTarget(argv) {
|
|
229
|
+
let i = 0;
|
|
230
|
+
while (i < argv.length) {
|
|
231
|
+
const w = argv[i];
|
|
232
|
+
const b = base(w);
|
|
233
|
+
if (PREFIX_COMMANDS.test(b)) {
|
|
234
|
+
i++;
|
|
235
|
+
// The prefix's own flags: `nice -n 10`, `env -i`, `time -p`.
|
|
236
|
+
while (i < argv.length && argv[i].startsWith('-')) {
|
|
237
|
+
const f = argv[i];
|
|
238
|
+
i +=
|
|
239
|
+
(b === 'nice' && f === '-n') || (b === 'env' && (f === '-u' || f === '--unset')) ? 2 : 1;
|
|
240
|
+
}
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w)) {
|
|
244
|
+
i++;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
const first = base(argv[i] ?? '');
|
|
250
|
+
const after = argv.slice(i + 1);
|
|
251
|
+
if (EXEC_RUNNERS.test(first)) {
|
|
252
|
+
// `npx -p pkg cmd`, `npx --package=pkg cmd`: skip value-taking flags.
|
|
253
|
+
let at = -1;
|
|
254
|
+
for (let x = 0; x < after.length; x++) {
|
|
255
|
+
const w = after[x];
|
|
256
|
+
if (w === '-p' || w === '--package') {
|
|
257
|
+
x++;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (!w.startsWith('-')) {
|
|
261
|
+
at = x;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
tool: at < 0 ? first : base(after[at]),
|
|
267
|
+
script: null,
|
|
268
|
+
pm: null,
|
|
269
|
+
rest: at < 0 ? [] : after.slice(at + 1),
|
|
270
|
+
scoped: false,
|
|
271
|
+
recursive: false,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (PACKAGE_MANAGERS.test(first)) {
|
|
275
|
+
let scoped = false;
|
|
276
|
+
let recursive = false;
|
|
277
|
+
let j = 0;
|
|
278
|
+
while (j < after.length && after[j].startsWith('-')) {
|
|
279
|
+
const f = after[j];
|
|
280
|
+
if (SCOPING_FLAGS.has(f) || f.startsWith('--filter=') || f.startsWith('--dir='))
|
|
281
|
+
scoped = true;
|
|
282
|
+
if (RECURSIVE_FLAGS.has(f))
|
|
283
|
+
recursive = true;
|
|
284
|
+
// pnpm's `-w` is the boolean --workspace-root; npm's `-w <name>` takes a value.
|
|
285
|
+
const takesValue = PM_VALUE_FLAGS.has(f) && !(first === 'pnpm' && f === '-w');
|
|
286
|
+
j += takesValue ? 2 : 1;
|
|
287
|
+
}
|
|
288
|
+
let verb = after[j] ?? null;
|
|
289
|
+
let k = j + 1;
|
|
290
|
+
// yarn workspaces foreach [-A …] run <script>
|
|
291
|
+
if (verb === 'workspaces' && after[k] === 'foreach') {
|
|
292
|
+
recursive = true;
|
|
293
|
+
k += 1;
|
|
294
|
+
while (k < after.length && after[k].startsWith('-'))
|
|
295
|
+
k++;
|
|
296
|
+
verb = after[k] ?? null;
|
|
297
|
+
k += 1;
|
|
298
|
+
}
|
|
299
|
+
if (verb === 'exec' || verb === 'dlx' || verb === 'x') {
|
|
300
|
+
// `pnpm dlx -p typescript tsc`: `-p`/`--package` take a value.
|
|
301
|
+
while (k < after.length && after[k].startsWith('-')) {
|
|
302
|
+
const f = after[k];
|
|
303
|
+
k += f === '-p' || f === '--package' ? 2 : 1;
|
|
304
|
+
}
|
|
305
|
+
const tool = after[k];
|
|
306
|
+
return {
|
|
307
|
+
tool: tool ? base(tool) : first,
|
|
308
|
+
script: null,
|
|
309
|
+
pm: first,
|
|
310
|
+
rest: after.slice(k + 1),
|
|
311
|
+
scoped,
|
|
312
|
+
recursive,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (verb === 'run' || verb === 'run-script') {
|
|
316
|
+
// `pnpm run --filter x build`: flags (and their values) before the script.
|
|
317
|
+
while (k < after.length && after[k].startsWith('-')) {
|
|
318
|
+
const f = after[k];
|
|
319
|
+
if (RECURSIVE_FLAGS.has(f))
|
|
320
|
+
recursive = true;
|
|
321
|
+
if (SCOPING_FLAGS.has(f) || f.startsWith('--filter=') || f.startsWith('--dir='))
|
|
322
|
+
scoped = true;
|
|
323
|
+
k += PM_VALUE_FLAGS.has(f) && !(first === 'pnpm' && f === '-w') ? 2 : 1;
|
|
324
|
+
}
|
|
325
|
+
verb = after[k] ?? null;
|
|
326
|
+
k += 1;
|
|
327
|
+
}
|
|
328
|
+
for (const f of after.slice(k))
|
|
329
|
+
if (RECURSIVE_FLAGS.has(f))
|
|
330
|
+
recursive = true;
|
|
331
|
+
// `pnpm vitest run`, `yarn tsc -b`: the package manager runs a bin directly.
|
|
332
|
+
if (verb !== null && (TEST_RUNNERS.test(verb) || BUILD_TOOLS.test(verb))) {
|
|
333
|
+
return { tool: verb, script: null, pm: first, rest: after.slice(k), scoped, recursive };
|
|
334
|
+
}
|
|
335
|
+
return { tool: first, script: verb, pm: first, rest: after.slice(k), scoped, recursive };
|
|
336
|
+
}
|
|
337
|
+
return { tool: first, script: null, pm: null, rest: after, scoped: false, recursive: false };
|
|
338
|
+
}
|
|
339
|
+
function infoOnly(t) {
|
|
340
|
+
const short = Object.hasOwn(SHORT_VERSION_FLAGS, t.tool)
|
|
341
|
+
? SHORT_VERSION_FLAGS[t.tool]
|
|
342
|
+
: ['-v', '-V'];
|
|
343
|
+
return t.rest.some((w) => INFO_FLAGS.has(w) || short.includes(w));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Positional words of `rest`: not flags, and not the value right after a
|
|
347
|
+
* long `--flag` given without `=` (so `--mode dev`, `--project dev`,
|
|
348
|
+
* `--profile dev` never read as a `dev` subcommand), nor after one of the
|
|
349
|
+
* tool's value-taking short flags (`vitest -t serve`).
|
|
350
|
+
*/
|
|
351
|
+
function positionals(rest, shortTakesValue = () => false) {
|
|
352
|
+
const out = [];
|
|
353
|
+
rest.forEach((w, x) => {
|
|
354
|
+
if (w.startsWith('-'))
|
|
355
|
+
return;
|
|
356
|
+
const prev = rest[x - 1];
|
|
357
|
+
if (prev?.startsWith('--') && !prev.includes('='))
|
|
358
|
+
return;
|
|
359
|
+
if (prev !== undefined && shortTakesValue(prev))
|
|
360
|
+
return;
|
|
361
|
+
out.push(w);
|
|
362
|
+
});
|
|
363
|
+
return out;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The first positional word after the tool or script. A package-manager
|
|
367
|
+
* script hands its arguments to a command we cannot see, so the word after
|
|
368
|
+
* any single-letter flag is read as that flag's value (`pnpm test -t serve`).
|
|
369
|
+
*/
|
|
370
|
+
function subcommand(t) {
|
|
371
|
+
if (t.script !== null)
|
|
372
|
+
return positionals(t.rest, (f) => /^-[A-Za-z]$/.test(f))[0];
|
|
373
|
+
const short = Object.hasOwn(SHORT_VALUE_FLAGS, t.tool)
|
|
374
|
+
? SHORT_VALUE_FLAGS[t.tool]
|
|
375
|
+
: [];
|
|
376
|
+
return positionals(t.rest, (f) => short.includes(f))[0];
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Whether a script or task name serves or watches: `dev`, `start` or
|
|
380
|
+
* `preview` as its first segment (`dev`, `dev:web`), or `watch`/`serve` in
|
|
381
|
+
* any segment (`test:watch`, `docs:serve`). `build:dev`, `build:preview` and
|
|
382
|
+
* `test:dev` are one-shot runs.
|
|
383
|
+
*/
|
|
384
|
+
export function isWatchName(name) {
|
|
385
|
+
const segs = name.split(':');
|
|
386
|
+
return LEADING_WATCH_WORD.test(segs[0] ?? '') || segs.some((seg) => ANY_WATCH_WORD.test(seg));
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* The tasks of a turbo or nx command, or null for any other tool.
|
|
390
|
+
*
|
|
391
|
+
* - turbo: `turbo run a b`, `turbo a b` (`web#dev` → `dev`); `--filter` scopes.
|
|
392
|
+
* - nx: `nx run-many|affected -t a b` / `--targets=a,b`; `nx run proj:target[:config]`;
|
|
393
|
+
* `nx <target> <project>` (`nx serve app`, `nx --verbose test app`).
|
|
394
|
+
*/
|
|
395
|
+
function orchestratorTasks(t) {
|
|
396
|
+
if (t.tool === 'turbo') {
|
|
397
|
+
const words = [];
|
|
398
|
+
let scoped = false;
|
|
399
|
+
for (let x = 0; x < t.rest.length; x++) {
|
|
400
|
+
const w = t.rest[x];
|
|
401
|
+
if (w.startsWith('-')) {
|
|
402
|
+
if (w === '--filter' || w === '-F' || w.startsWith('--filter='))
|
|
403
|
+
scoped = true;
|
|
404
|
+
if (TURBO_VALUE_FLAGS.has(w))
|
|
405
|
+
x++;
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
words.push(w);
|
|
409
|
+
}
|
|
410
|
+
const sub = words[0];
|
|
411
|
+
if (sub !== undefined && TURBO_ADMIN.has(sub)) {
|
|
412
|
+
return { tasks: [], admin: true, watch: false, many: false, scoped };
|
|
413
|
+
}
|
|
414
|
+
const watch = sub === 'watch';
|
|
415
|
+
if (sub === 'run' || watch)
|
|
416
|
+
words.shift();
|
|
417
|
+
return {
|
|
418
|
+
tasks: words.map((w) => w.split('#').pop() ?? w),
|
|
419
|
+
admin: false,
|
|
420
|
+
watch,
|
|
421
|
+
many: true,
|
|
422
|
+
scoped,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
if (t.tool === 'nx') {
|
|
426
|
+
const tasks = [];
|
|
427
|
+
const pos = [];
|
|
428
|
+
let scoped = false;
|
|
429
|
+
for (let x = 0; x < t.rest.length; x++) {
|
|
430
|
+
const w = t.rest[x];
|
|
431
|
+
const [flag, value] = w.split('=', 2);
|
|
432
|
+
if (NX_TARGET_FLAGS.has(flag)) {
|
|
433
|
+
if (value !== undefined)
|
|
434
|
+
tasks.push(...value.split(','));
|
|
435
|
+
else
|
|
436
|
+
while (x + 1 < t.rest.length && !t.rest[x + 1].startsWith('-')) {
|
|
437
|
+
tasks.push(...t.rest[++x].split(','));
|
|
438
|
+
}
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (w.startsWith('-')) {
|
|
442
|
+
if (flag === '--projects' || flag === '-p')
|
|
443
|
+
scoped = true;
|
|
444
|
+
if (value === undefined && NX_VALUE_FLAGS.has(flag))
|
|
445
|
+
x++;
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
pos.push(w);
|
|
449
|
+
}
|
|
450
|
+
const sub = pos[0];
|
|
451
|
+
const none = { admin: false, watch: false };
|
|
452
|
+
if (sub !== undefined && NX_ADMIN.has(sub)) {
|
|
453
|
+
return { tasks: [], admin: true, watch: false, many: false, scoped: true };
|
|
454
|
+
}
|
|
455
|
+
if (sub === 'watch')
|
|
456
|
+
return { tasks, admin: false, watch: true, many: false, scoped: true };
|
|
457
|
+
if (sub === 'run-many' || sub === 'affected')
|
|
458
|
+
return { tasks, ...none, many: true, scoped };
|
|
459
|
+
// `nx run web:test:ci`: the target is the second segment.
|
|
460
|
+
if (sub === 'run') {
|
|
461
|
+
const target = (pos[1] ?? '').split(':')[1];
|
|
462
|
+
return { tasks: target ? [target] : [], ...none, many: false, scoped: true };
|
|
463
|
+
}
|
|
464
|
+
return { tasks: sub ? [sub] : [], ...none, many: false, scoped: true };
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
/** A watcher or server: never heavy, never admitted (it would hold a slot forever). */
|
|
469
|
+
function watching(t) {
|
|
470
|
+
// `next --help`, `vite --version` print and exit. Not for a package-manager
|
|
471
|
+
// script, which passes the flag on to whatever the script runs.
|
|
472
|
+
if (t.script === null && infoOnly(t))
|
|
473
|
+
return false;
|
|
474
|
+
// `pnpm dev`, `npm run test:watch`, `pnpm build:watch`, `pnpm run serve:docs`.
|
|
475
|
+
if (t.script !== null && isWatchName(t.script))
|
|
476
|
+
return true;
|
|
477
|
+
if (t.rest.some((w) => WATCH_FLAGS.has(w) || w.startsWith('--serve=')))
|
|
478
|
+
return true;
|
|
479
|
+
// `vitest --ui`, `playwright test --ui`; for turbo `--ui` takes a value (`--ui stream`).
|
|
480
|
+
if (UI_SERVES.test(t.tool) && t.rest.includes('--ui'))
|
|
481
|
+
return true;
|
|
482
|
+
// `tsc -w`, `rollup -c -w`; never `jest -w 2`, `prettier -w .` or `gofmt -w .`.
|
|
483
|
+
if (SHORT_WATCH_TOOLS.test(t.tool) && t.rest.includes('-w'))
|
|
484
|
+
return true;
|
|
485
|
+
// `turbo run dev`, `nx run-many -t serve`, `nx affected -t dev`, `nx run app:serve`.
|
|
486
|
+
const orch = orchestratorTasks(t);
|
|
487
|
+
if (orch)
|
|
488
|
+
return orch.watch || orch.tasks.some(isWatchName);
|
|
489
|
+
if (NO_WATCH_SUBCOMMAND.test(t.tool))
|
|
490
|
+
return false;
|
|
491
|
+
const sub = subcommand(t);
|
|
492
|
+
// `vitest watch`, `next dev`, `webpack serve`.
|
|
493
|
+
if (sub !== undefined && WATCH_SUBCOMMANDS.has(sub))
|
|
494
|
+
return true;
|
|
495
|
+
// `next` and `vite` serve unless told to do a one-shot job (`vite preview` serves).
|
|
496
|
+
if (t.tool === 'next')
|
|
497
|
+
return sub === undefined || !NEXT_ONESHOT.test(sub);
|
|
498
|
+
if (t.tool === 'vite')
|
|
499
|
+
return sub === undefined || !VITE_ONESHOT.test(sub);
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Whether `argv` is a heavy command: a test runner, compiler, bundler or
|
|
504
|
+
* linter as the command word, or a package-manager test/build/typecheck/lint/
|
|
505
|
+
* install script, or `cargo`/`go` build or test. Never `--version`/`--help`,
|
|
506
|
+
* never a watch/dev/serve mode.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```ts
|
|
510
|
+
* looksHeavy(['npx', 'vitest', 'run']); // true
|
|
511
|
+
* looksHeavy(['git', 'commit', '-m', 'fix vitest']); // false
|
|
512
|
+
* looksHeavy(['pnpm', 'dev']); // false
|
|
513
|
+
* looksHeavy(['tsc', '--version']); // false
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
export function looksHeavy(argv) {
|
|
517
|
+
const t = commandTarget(argv);
|
|
518
|
+
if (infoOnly(t) || watching(t))
|
|
519
|
+
return false;
|
|
520
|
+
if (orchestratorTasks(t)?.admin === true)
|
|
521
|
+
return false;
|
|
522
|
+
if (t.tool === 'next' && NEXT_ADMIN.test(subcommand(t) ?? ''))
|
|
523
|
+
return false;
|
|
524
|
+
if (TEST_RUNNERS.test(t.tool) || BUILD_TOOLS.test(t.tool))
|
|
525
|
+
return true;
|
|
526
|
+
if (t.pm !== null) {
|
|
527
|
+
if (t.script === null)
|
|
528
|
+
return false;
|
|
529
|
+
if (t.pm === 'bun' && t.script === 'test')
|
|
530
|
+
return true;
|
|
531
|
+
return HEAVY_SCRIPTS.test(t.script) || INSTALL_VERBS.test(t.script);
|
|
532
|
+
}
|
|
533
|
+
return (t.tool === 'cargo' || t.tool === 'go') && /^(build|test)$/.test(t.rest[0] ?? '');
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Whether `argv` is a watcher or server (`pnpm dev`, `turbo run dev`,
|
|
537
|
+
* `vitest --ui`, `vite preview`): it never exits, so `cleo run` refuses it
|
|
538
|
+
* rather than let it hold a slot forever (an explicit `--class` overrides).
|
|
539
|
+
* Never `--version`/`--help`, a flag value (`pytest -k dev`, `vitest -t serve`)
|
|
540
|
+
* or a `-w` that means something else (`jest -w 2`, `prettier -w .`).
|
|
541
|
+
*/
|
|
542
|
+
export function isWatchCommand(argv) {
|
|
543
|
+
return watching(commandTarget(argv));
|
|
544
|
+
}
|
|
545
|
+
function isWorkspaceRoot(cwd) {
|
|
546
|
+
return (existsSync(join(cwd, 'pnpm-workspace.yaml')) ||
|
|
547
|
+
existsSync(join(cwd, 'turbo.json')) ||
|
|
548
|
+
existsSync(join(cwd, 'nx.json')));
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* The governor class for a command.
|
|
552
|
+
*
|
|
553
|
+
* An explicit `--class` wins (aliases above). Otherwise: a test runner, a
|
|
554
|
+
* `test` script, `npm t`, `bun test`, `cargo|go test`, or turbo/nx running
|
|
555
|
+
* only test tasks is `test-run`; a build that spans the workspace (`-r`,
|
|
556
|
+
* `--workspaces`, `yarn workspaces foreach`, an unscoped build at a workspace
|
|
557
|
+
* root, or any non-test turbo / `nx run-many|affected` run, `build test`
|
|
558
|
+
* included) is `full-build`; anything else is `scoped-build`.
|
|
559
|
+
*
|
|
560
|
+
* @param explicit - the `--class` value, if given.
|
|
561
|
+
* @param argv - the command.
|
|
562
|
+
* @param cwd - where it runs (for the workspace-root check).
|
|
563
|
+
* @throws {Error} when `explicit` is not a known class or alias.
|
|
564
|
+
*/
|
|
565
|
+
export function resolveRunClass(explicit, argv, cwd) {
|
|
566
|
+
if (explicit !== undefined) {
|
|
567
|
+
const cls = RUN_CLASS_ALIASES[explicit];
|
|
568
|
+
if (!cls) {
|
|
569
|
+
throw new Error(`unknown --class '${explicit}' (expected one of: ${Object.keys(RUN_CLASS_ALIASES).join(', ')})`);
|
|
570
|
+
}
|
|
571
|
+
return cls;
|
|
572
|
+
}
|
|
573
|
+
const t = commandTarget(argv);
|
|
574
|
+
if (TEST_RUNNERS.test(t.tool))
|
|
575
|
+
return 'test-run';
|
|
576
|
+
if (t.pm !== null && t.script !== null && (/^test(:|$)/.test(t.script) || t.script === 't')) {
|
|
577
|
+
return 'test-run';
|
|
578
|
+
}
|
|
579
|
+
if ((t.tool === 'cargo' || t.tool === 'go') && t.rest[0] === 'test')
|
|
580
|
+
return 'test-run';
|
|
581
|
+
// turbo / nx: a build (or any non-test task) across the workspace is a full
|
|
582
|
+
// build, checked BEFORE the test rule so `turbo run build test` keeps the
|
|
583
|
+
// single full-build slot; tests only are a test run (`nx run web:test`).
|
|
584
|
+
const orch = orchestratorTasks(t);
|
|
585
|
+
if (orch) {
|
|
586
|
+
const isTest = (x) => /^test(:|$)/.test(x);
|
|
587
|
+
if (orch.tasks.length > 0 && orch.tasks.every(isTest))
|
|
588
|
+
return 'test-run';
|
|
589
|
+
return orch.many && !orch.scoped && !t.scoped ? 'full-build' : 'scoped-build';
|
|
590
|
+
}
|
|
591
|
+
if (t.script !== null && /^build(:|$)/.test(t.script)) {
|
|
592
|
+
if (t.scoped)
|
|
593
|
+
return 'scoped-build';
|
|
594
|
+
if (t.recursive)
|
|
595
|
+
return 'full-build';
|
|
596
|
+
if (t.pm !== null && isWorkspaceRoot(cwd))
|
|
597
|
+
return 'full-build';
|
|
598
|
+
}
|
|
599
|
+
return 'scoped-build';
|
|
600
|
+
}
|
|
601
|
+
/** The `heavyToolEnv` canonical tool a run class sizes its env from. */
|
|
602
|
+
export function canonicalForClass(cls) {
|
|
603
|
+
return cls === 'test-run' ? 'test' : 'build';
|
|
604
|
+
}
|
|
605
|
+
/** The script a `node` command runs (`node --max-old-space-size=4096 bin/cleo.js`), else null. */
|
|
606
|
+
function nodeScript(rest) {
|
|
607
|
+
for (let x = 0; x < rest.length; x++) {
|
|
608
|
+
const w = rest[x];
|
|
609
|
+
if (w === '-e' || w === '--eval' || w === '-p' || w === '--print')
|
|
610
|
+
return null;
|
|
611
|
+
if (NODE_VALUE_FLAGS.has(w)) {
|
|
612
|
+
x++;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
if (!w.startsWith('-'))
|
|
616
|
+
return w;
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Whether the command word is CLEO's own CLI: `cleo …`, `ct …`, `npx cleo`,
|
|
622
|
+
* `pnpm exec cleo`, `pnpm cleo`, `node …/bin/cleo.js`.
|
|
623
|
+
*/
|
|
624
|
+
function isCleoCommand(t) {
|
|
625
|
+
if (CLEO_BIN.test(t.tool))
|
|
626
|
+
return true;
|
|
627
|
+
if (t.script !== null && CLEO_SCRIPT.test(t.script))
|
|
628
|
+
return true;
|
|
629
|
+
if (t.tool !== 'node')
|
|
630
|
+
return false;
|
|
631
|
+
const script = nodeScript(t.rest);
|
|
632
|
+
return script !== null && CLEO_SCRIPT.test(script);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Whether a job may be SIGSTOPped under pressure. Installs, db-heavy work and
|
|
636
|
+
* cargo (which holds the registry cache and target-dir locks) hold shared
|
|
637
|
+
* locks the oldest job may need, so pausing them can stall the one job that
|
|
638
|
+
* is meant to keep the machine moving.
|
|
639
|
+
*
|
|
640
|
+
* CLEO's own commands are never paused either (#1777 R7-1): `cleo verify
|
|
641
|
+
* --evidence tool:test` holds the tool-semaphore and tool-cache locks and
|
|
642
|
+
* spawns its heavy tool DETACHED, out of the paused group. A pause would
|
|
643
|
+
* freeze only the lock holder while the test keeps running; its locks stop
|
|
644
|
+
* refreshing, go stale and are taken, and it crashes on resume.
|
|
645
|
+
*/
|
|
646
|
+
export function isPausable(cls, argv) {
|
|
647
|
+
if (cls === 'db-heavy')
|
|
648
|
+
return false;
|
|
649
|
+
const t = commandTarget(argv);
|
|
650
|
+
if (t.pm !== null && t.script !== null && INSTALL_VERBS.test(t.script))
|
|
651
|
+
return false;
|
|
652
|
+
if (t.tool === 'cargo')
|
|
653
|
+
return false;
|
|
654
|
+
if (isCleoCommand(t))
|
|
655
|
+
return false;
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
//# sourceMappingURL=run-class.js.map
|