@cotal-ai/cli 0.100.2 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/chat-view.d.ts.map +1 -1
- package/dist/chat/chat-view.js +5 -1
- package/dist/chat/chat-view.js.map +1 -1
- package/dist/chat/engine.d.ts +2 -1
- package/dist/chat/engine.d.ts.map +1 -1
- package/dist/chat/engine.js +2 -1
- package/dist/chat/engine.js.map +1 -1
- package/dist/chat/frontend.d.ts.map +1 -1
- package/dist/chat/frontend.js +13 -7
- package/dist/chat/frontend.js.map +1 -1
- package/dist/chat/native-session.d.ts +22 -3
- package/dist/chat/native-session.d.ts.map +1 -1
- package/dist/chat/native-session.js +91 -19
- package/dist/chat/native-session.js.map +1 -1
- package/dist/chat/open-session.d.ts +1 -0
- package/dist/chat/open-session.d.ts.map +1 -1
- package/dist/chat/open-session.js +1 -1
- package/dist/chat/open-session.js.map +1 -1
- package/dist/chat/picker.d.ts +5 -0
- package/dist/chat/picker.d.ts.map +1 -1
- package/dist/chat/picker.js +23 -10
- package/dist/chat/picker.js.map +1 -1
- package/dist/chat/plain.d.ts.map +1 -1
- package/dist/chat/plain.js +36 -10
- package/dist/chat/plain.js.map +1 -1
- package/dist/chat/session.d.ts +5 -0
- package/dist/chat/session.d.ts.map +1 -1
- package/dist/chat/static-session.d.ts +1 -0
- package/dist/chat/static-session.d.ts.map +1 -1
- package/dist/chat/static-session.js +24 -8
- package/dist/chat/static-session.js.map +1 -1
- package/dist/chat/stdio-io.d.ts +2 -0
- package/dist/chat/stdio-io.d.ts.map +1 -1
- package/dist/chat/stdio-io.js +6 -6
- package/dist/chat/stdio-io.js.map +1 -1
- package/dist/chat/stdio.d.ts +3 -2
- package/dist/chat/stdio.d.ts.map +1 -1
- package/dist/chat/stdio.js +26 -25
- package/dist/chat/stdio.js.map +1 -1
- package/dist/chat/user-session.d.ts +1 -0
- package/dist/chat/user-session.d.ts.map +1 -1
- package/dist/chat/user-session.js +1 -1
- package/dist/chat/user-session.js.map +1 -1
- package/dist/chat/view.d.ts +5 -4
- package/dist/chat/view.d.ts.map +1 -1
- package/dist/chat/view.js +10 -8
- package/dist/chat/view.js.map +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +295 -82
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +29 -5
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +100 -35
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/backup-maintenance.d.ts.map +1 -1
- package/dist/commands/backup-maintenance.js +54 -21
- package/dist/commands/backup-maintenance.js.map +1 -1
- package/dist/commands/backup-read.d.ts.map +1 -1
- package/dist/commands/backup-read.js +12 -15
- package/dist/commands/backup-read.js.map +1 -1
- package/dist/commands/backup-restore.d.ts.map +1 -1
- package/dist/commands/backup-restore.js +20 -4
- package/dist/commands/backup-restore.js.map +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +156 -28
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channel-members.d.ts +1 -1
- package/dist/commands/channel-members.d.ts.map +1 -1
- package/dist/commands/channel-members.js +115 -29
- package/dist/commands/channel-members.js.map +1 -1
- package/dist/commands/channels.d.ts +11 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +109 -20
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +11 -3
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +50 -22
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/clean.d.ts +10 -5
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +245 -42
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/completion.d.ts +15 -2
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +91 -26
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/config.d.ts +24 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +65 -13
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +5 -4
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/describe.d.ts +4 -2
- package/dist/commands/describe.d.ts.map +1 -1
- package/dist/commands/describe.js +4 -4
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +261 -34
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-manifest.d.ts.map +1 -1
- package/dist/commands/down-manifest.js +9 -6
- package/dist/commands/down-manifest.js.map +1 -1
- package/dist/commands/down-services.d.ts +17 -16
- package/dist/commands/down-services.d.ts.map +1 -1
- package/dist/commands/down-services.js +29 -53
- package/dist/commands/down-services.js.map +1 -1
- package/dist/commands/down.d.ts +2 -2
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +96 -67
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-deregister.d.ts.map +1 -1
- package/dist/commands/endpoint-deregister.js +2 -2
- package/dist/commands/endpoint-deregister.js.map +1 -1
- package/dist/commands/endpoint.d.ts +2 -1
- package/dist/commands/endpoint.d.ts.map +1 -1
- package/dist/commands/endpoint.js +2 -2
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/endpoints.d.ts +1 -0
- package/dist/commands/endpoints.d.ts.map +1 -1
- package/dist/commands/endpoints.js +20 -5
- package/dist/commands/endpoints.js.map +1 -1
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +40 -2
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +2 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/history-clear.d.ts.map +1 -1
- package/dist/commands/history-clear.js +67 -51
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history.d.ts +17 -2
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +221 -34
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts +2 -0
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +132 -80
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes-add.d.ts +19 -4
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +114 -15
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes-wizard.d.ts +1 -0
- package/dist/commands/meshes-wizard.d.ts.map +1 -1
- package/dist/commands/meshes-wizard.js +45 -13
- package/dist/commands/meshes-wizard.js.map +1 -1
- package/dist/commands/meshes.d.ts +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +76 -47
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +212 -19
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/models.d.ts +5 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +21 -13
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona-remote.d.ts.map +1 -1
- package/dist/commands/persona-remote.js +24 -13
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/persona.d.ts +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +92 -23
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +59 -40
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.d.ts.map +1 -1
- package/dist/commands/reset-space-apply.js +69 -17
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.d.ts +16 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -1
- package/dist/commands/reset-store-apply.js +122 -23
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +8 -7
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/revoke-credential.d.ts +5 -0
- package/dist/commands/revoke-credential.d.ts.map +1 -0
- package/dist/commands/revoke-credential.js +128 -0
- package/dist/commands/revoke-credential.js.map +1 -0
- package/dist/commands/send.d.ts +11 -3
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +284 -47
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts +2 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +117 -21
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-log-follow.js +1 -1
- package/dist/commands/service-log-follow.js.map +1 -1
- package/dist/commands/service-registry.d.ts +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +74 -30
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/service-set-stop.d.ts.map +1 -1
- package/dist/commands/service-set-stop.js +3 -2
- package/dist/commands/service-set-stop.js.map +1 -1
- package/dist/commands/setup-start.d.ts.map +1 -1
- package/dist/commands/setup-start.js +46 -5
- package/dist/commands/setup-start.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +28 -13
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-delete.d.ts.map +1 -1
- package/dist/commands/space-delete.js +130 -41
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/space-registration.d.ts +13 -6
- package/dist/commands/space-registration.d.ts.map +1 -1
- package/dist/commands/space-registration.js +167 -46
- package/dist/commands/space-registration.js.map +1 -1
- package/dist/commands/space.d.ts +15 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +66 -24
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn-preview.d.ts.map +1 -1
- package/dist/commands/spawn-preview.js +48 -10
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts +36 -13
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +263 -129
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +9 -3
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +344 -64
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-gone.d.ts +17 -0
- package/dist/commands/stack-gone.d.ts.map +1 -0
- package/dist/commands/stack-gone.js +218 -0
- package/dist/commands/stack-gone.js.map +1 -0
- package/dist/commands/stack-up.d.ts +64 -4
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +482 -55
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status.d.ts +76 -2
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +550 -112
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-apply.d.ts.map +1 -1
- package/dist/commands/team-agent-apply.js +4 -3
- package/dist/commands/team-agent-apply.js.map +1 -1
- package/dist/commands/team-agent-remove.d.ts.map +1 -1
- package/dist/commands/team-agent-remove.js +4 -4
- package/dist/commands/team-agent-remove.js.map +1 -1
- package/dist/commands/team-boot-controller.d.ts.map +1 -1
- package/dist/commands/team-boot-controller.js +8 -2
- package/dist/commands/team-boot-controller.js.map +1 -1
- package/dist/commands/team-channel-remove.d.ts.map +1 -1
- package/dist/commands/team-channel-remove.js +26 -10
- package/dist/commands/team-channel-remove.js.map +1 -1
- package/dist/commands/team-deploy-apply.d.ts.map +1 -1
- package/dist/commands/team-deploy-apply.js +4 -3
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/team-mixed-remove.js +5 -5
- package/dist/commands/team-mixed-remove.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +94 -32
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +3 -1
- package/dist/commands/telemetry.js.map +1 -1
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +11 -7
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/up.d.ts +6 -6
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +963 -240
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +9 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts +5 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +55 -12
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/watch.d.ts +4 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +15 -3
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/who.d.ts +2 -0
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +18 -5
- package/dist/commands/who.js.map +1 -1
- package/dist/commands/whoami.d.ts +44 -5
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +168 -16
- package/dist/commands/whoami.js.map +1 -1
- package/dist/console/app.d.ts +1 -1
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +15 -9
- package/dist/console/app.js.map +1 -1
- package/dist/console/launch.d.ts +25 -0
- package/dist/console/launch.d.ts.map +1 -0
- package/dist/console/launch.js +56 -0
- package/dist/console/launch.js.map +1 -0
- package/dist/console/ui/CommandPalette.d.ts +5 -4
- package/dist/console/ui/CommandPalette.d.ts.map +1 -1
- package/dist/console/ui/CommandPalette.js +136 -45
- package/dist/console/ui/CommandPalette.js.map +1 -1
- package/dist/console/ui/Help.js +1 -1
- package/dist/console/ui/Help.js.map +1 -1
- package/dist/console/ui/Modal.d.ts +10 -0
- package/dist/console/ui/Modal.d.ts.map +1 -0
- package/dist/console/ui/Modal.js +8 -0
- package/dist/console/ui/Modal.js.map +1 -0
- package/dist/console/ui/NewAgent.d.ts +14 -0
- package/dist/console/ui/NewAgent.d.ts.map +1 -0
- package/dist/console/ui/NewAgent.js +114 -0
- package/dist/console/ui/NewAgent.js.map +1 -0
- package/dist/console/ui/StatusBar.d.ts +1 -2
- package/dist/console/ui/StatusBar.d.ts.map +1 -1
- package/dist/console/ui/StatusBar.js +6 -8
- package/dist/console/ui/StatusBar.js.map +1 -1
- package/dist/console/ui/topo/Map.d.ts.map +1 -1
- package/dist/console/ui/topo/Map.js +1 -2
- package/dist/console/ui/topo/Map.js.map +1 -1
- package/dist/console/ui/topo/Matrix.js +2 -2
- package/dist/console/ui/topo/Matrix.js.map +1 -1
- package/dist/console/ui/topo/Sequence.d.ts.map +1 -1
- package/dist/console/ui/topo/Sequence.js +5 -4
- package/dist/console/ui/topo/Sequence.js.map +1 -1
- package/dist/console/ui/topo/model.d.ts +2 -1
- package/dist/console/ui/topo/model.d.ts.map +1 -1
- package/dist/console/ui/topo/model.js +4 -3
- package/dist/console/ui/topo/model.js.map +1 -1
- package/dist/exec-endpoint/service-adapter.d.ts.map +1 -1
- package/dist/exec-endpoint/service-adapter.js +13 -3
- package/dist/exec-endpoint/service-adapter.js.map +1 -1
- package/dist/ext-loader.d.ts +4 -0
- package/dist/ext-loader.d.ts.map +1 -1
- package/dist/ext-loader.js +6 -0
- package/dist/ext-loader.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +44 -23
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -54
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-skills.d.ts.map +1 -1
- package/dist/lib/agent-skills.js +2 -1
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/attach-client.js +2 -2
- package/dist/lib/attach-client.js.map +1 -1
- package/dist/lib/backup-artifact.d.ts +29 -8
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +147 -26
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +27 -3
- package/dist/lib/broker-service.d.ts.map +1 -1
- package/dist/lib/broker-service.js +135 -27
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/broker-store-health.d.ts +89 -0
- package/dist/lib/broker-store-health.d.ts.map +1 -0
- package/dist/lib/broker-store-health.js +171 -0
- package/dist/lib/broker-store-health.js.map +1 -0
- package/dist/lib/cancel.d.ts +4 -4
- package/dist/lib/cancel.d.ts.map +1 -1
- package/dist/lib/cancel.js +5 -5
- package/dist/lib/cancel.js.map +1 -1
- package/dist/lib/completion-install.d.ts +11 -2
- package/dist/lib/completion-install.d.ts.map +1 -1
- package/dist/lib/completion-install.js +79 -21
- package/dist/lib/completion-install.js.map +1 -1
- package/dist/lib/completion-scripts.d.ts.map +1 -1
- package/dist/lib/completion-scripts.js +2 -2
- package/dist/lib/completion-scripts.js.map +1 -1
- package/dist/lib/completion.d.ts +5 -1
- package/dist/lib/completion.d.ts.map +1 -1
- package/dist/lib/completion.js +10 -0
- package/dist/lib/completion.js.map +1 -1
- package/dist/lib/concrete-channel.d.ts +6 -0
- package/dist/lib/concrete-channel.d.ts.map +1 -0
- package/dist/lib/concrete-channel.js +17 -0
- package/dist/lib/concrete-channel.js.map +1 -0
- package/dist/lib/confirmation-required.d.ts +3 -12
- package/dist/lib/confirmation-required.d.ts.map +1 -1
- package/dist/lib/confirmation-required.js +9 -8
- package/dist/lib/confirmation-required.js.map +1 -1
- package/dist/lib/connect.d.ts +9 -0
- package/dist/lib/connect.d.ts.map +1 -1
- package/dist/lib/connect.js +27 -0
- package/dist/lib/connect.js.map +1 -1
- package/dist/lib/control.d.ts +42 -12
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +130 -31
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-restore.d.ts.map +1 -1
- package/dist/lib/controller-restore.js +12 -7
- package/dist/lib/controller-restore.js.map +1 -1
- package/dist/lib/credential-authority.d.ts.map +1 -1
- package/dist/lib/credential-authority.js +3 -0
- package/dist/lib/credential-authority.js.map +1 -1
- package/dist/lib/credential-exports.d.ts +17 -0
- package/dist/lib/credential-exports.d.ts.map +1 -0
- package/dist/lib/credential-exports.js +21 -0
- package/dist/lib/credential-exports.js.map +1 -0
- package/dist/lib/debug-flag.d.ts +4 -0
- package/dist/lib/debug-flag.d.ts.map +1 -0
- package/dist/lib/debug-flag.js +7 -0
- package/dist/lib/debug-flag.js.map +1 -0
- package/dist/lib/default-persona.d.ts +2 -0
- package/dist/lib/default-persona.d.ts.map +1 -1
- package/dist/lib/default-persona.js +2 -0
- package/dist/lib/default-persona.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts +1 -1
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +5 -4
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/delivery-responder.d.ts +7 -3
- package/dist/lib/delivery-responder.d.ts.map +1 -1
- package/dist/lib/delivery-responder.js +8 -4
- package/dist/lib/delivery-responder.js.map +1 -1
- package/dist/lib/denied-write.d.ts +8 -0
- package/dist/lib/denied-write.d.ts.map +1 -0
- package/dist/lib/denied-write.js +24 -0
- package/dist/lib/denied-write.js.map +1 -0
- package/dist/lib/endpoint-capability-gates.js +2 -2
- package/dist/lib/endpoint-capability-gates.js.map +1 -1
- package/dist/lib/flag-value-refusal.d.ts +8 -0
- package/dist/lib/flag-value-refusal.d.ts.map +1 -0
- package/dist/lib/flag-value-refusal.js +10 -0
- package/dist/lib/flag-value-refusal.js.map +1 -0
- package/dist/lib/install-umask.d.ts +5 -0
- package/dist/lib/install-umask.d.ts.map +1 -1
- package/dist/lib/install-umask.js +25 -0
- package/dist/lib/install-umask.js.map +1 -1
- package/dist/lib/interrupt-notice.d.ts +23 -1
- package/dist/lib/interrupt-notice.d.ts.map +1 -1
- package/dist/lib/interrupt-notice.js +27 -6
- package/dist/lib/interrupt-notice.js.map +1 -1
- package/dist/lib/interrupt-report.d.ts +7 -0
- package/dist/lib/interrupt-report.d.ts.map +1 -0
- package/dist/lib/interrupt-report.js +24 -0
- package/dist/lib/interrupt-report.js.map +1 -0
- package/dist/lib/isolated-broker.d.ts +1 -1
- package/dist/lib/isolated-broker.d.ts.map +1 -1
- package/dist/lib/isolated-broker.js +17 -8
- package/dist/lib/isolated-broker.js.map +1 -1
- package/dist/lib/legacy-start.d.ts +8 -6
- package/dist/lib/legacy-start.d.ts.map +1 -1
- package/dist/lib/legacy-start.js +36 -36
- package/dist/lib/legacy-start.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +45 -4
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +214 -24
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +7 -6
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/index.d.ts +5 -1
- package/dist/lib/manifest/index.d.ts.map +1 -1
- package/dist/lib/manifest/index.js +50 -5
- package/dist/lib/manifest/index.js.map +1 -1
- package/dist/lib/manifest/preflight.d.ts +4 -0
- package/dist/lib/manifest/preflight.d.ts.map +1 -1
- package/dist/lib/manifest/preflight.js +18 -1
- package/dist/lib/manifest/preflight.js.map +1 -1
- package/dist/lib/manifest/resolve.d.ts +8 -0
- package/dist/lib/manifest/resolve.d.ts.map +1 -1
- package/dist/lib/manifest/resolve.js +104 -11
- package/dist/lib/manifest/resolve.js.map +1 -1
- package/dist/lib/missing-flags.js +1 -1
- package/dist/lib/missing-flags.js.map +1 -1
- package/dist/lib/nats-bin.d.ts +28 -5
- package/dist/lib/nats-bin.d.ts.map +1 -1
- package/dist/lib/nats-bin.js +85 -7
- package/dist/lib/nats-bin.js.map +1 -1
- package/dist/lib/nearest-word.d.ts +14 -0
- package/dist/lib/nearest-word.d.ts.map +1 -0
- package/dist/lib/nearest-word.js +76 -0
- package/dist/lib/nearest-word.js.map +1 -0
- package/dist/lib/no-expiry-record.d.ts +8 -0
- package/dist/lib/no-expiry-record.d.ts.map +1 -0
- package/dist/lib/no-expiry-record.js +27 -0
- package/dist/lib/no-expiry-record.js.map +1 -0
- package/dist/lib/paths.d.ts +31 -0
- package/dist/lib/paths.d.ts.map +1 -1
- package/dist/lib/paths.js +92 -2
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/persona-files.d.ts +29 -6
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +179 -36
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/personas.d.ts +18 -1
- package/dist/lib/personas.d.ts.map +1 -1
- package/dist/lib/personas.js +65 -6
- package/dist/lib/personas.js.map +1 -1
- package/dist/lib/prompts.d.ts +7 -1
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +43 -3
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/registry-errors.d.ts +2 -1
- package/dist/lib/registry-errors.d.ts.map +1 -1
- package/dist/lib/registry-errors.js +6 -2
- package/dist/lib/registry-errors.js.map +1 -1
- package/dist/lib/reset-space-plan.d.ts +2 -0
- package/dist/lib/reset-space-plan.d.ts.map +1 -1
- package/dist/lib/reset-space-plan.js +1 -1
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/restore.d.ts +45 -3
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +233 -39
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/rolled-back-runs.d.ts +36 -0
- package/dist/lib/rolled-back-runs.d.ts.map +1 -0
- package/dist/lib/rolled-back-runs.js +96 -0
- package/dist/lib/rolled-back-runs.js.map +1 -0
- package/dist/lib/service-definitions.d.ts +16 -3
- package/dist/lib/service-definitions.d.ts.map +1 -1
- package/dist/lib/service-definitions.js +99 -27
- package/dist/lib/service-definitions.js.map +1 -1
- package/dist/lib/service-instances.d.ts +13 -1
- package/dist/lib/service-instances.d.ts.map +1 -1
- package/dist/lib/service-instances.js +56 -12
- package/dist/lib/service-instances.js.map +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +16 -0
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-process.d.ts +51 -8
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +385 -48
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/space-streams.d.ts +18 -0
- package/dist/lib/space-streams.d.ts.map +1 -0
- package/dist/lib/space-streams.js +35 -0
- package/dist/lib/space-streams.js.map +1 -0
- package/dist/lib/spawn-defaults.d.ts +25 -1
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +37 -1
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +157 -14
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +406 -49
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/stack-listeners.d.ts +17 -0
- package/dist/lib/stack-listeners.d.ts.map +1 -0
- package/dist/lib/stack-listeners.js +54 -0
- package/dist/lib/stack-listeners.js.map +1 -0
- package/dist/lib/stack-members.d.ts +13 -0
- package/dist/lib/stack-members.d.ts.map +1 -0
- package/dist/lib/stack-members.js +24 -0
- package/dist/lib/stack-members.js.map +1 -0
- package/dist/lib/stack-resume.d.ts.map +1 -1
- package/dist/lib/stack-resume.js +5 -2
- package/dist/lib/stack-resume.js.map +1 -1
- package/dist/lib/stack-runs.d.ts +34 -0
- package/dist/lib/stack-runs.d.ts.map +1 -0
- package/dist/lib/stack-runs.js +75 -0
- package/dist/lib/stack-runs.js.map +1 -0
- package/dist/lib/status.d.ts +11 -0
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +4 -5
- package/dist/lib/status.js.map +1 -1
- package/dist/lib/stdout-owner.d.ts +12 -3
- package/dist/lib/stdout-owner.d.ts.map +1 -1
- package/dist/lib/stdout-owner.js +33 -5
- package/dist/lib/stdout-owner.js.map +1 -1
- package/dist/lib/store-dir.d.ts +68 -4
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +253 -17
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/team-additive-attempt.d.ts +1 -1
- package/dist/lib/team-channel-removal.d.ts.map +1 -1
- package/dist/lib/team-channel-removal.js +4 -0
- package/dist/lib/team-channel-removal.js.map +1 -1
- package/dist/lib/team-deploy-inspection.d.ts +13 -0
- package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
- package/dist/lib/team-deploy-inspection.js +12 -0
- package/dist/lib/team-deploy-inspection.js.map +1 -1
- package/dist/lib/team-text.d.ts +6 -0
- package/dist/lib/team-text.d.ts.map +1 -0
- package/dist/lib/team-text.js +36 -0
- package/dist/lib/team-text.js.map +1 -0
- package/dist/lib/transient.d.ts +14 -8
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +72 -11
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/unusable-file.d.ts +13 -0
- package/dist/lib/unusable-file.d.ts.map +1 -0
- package/dist/lib/unusable-file.js +12 -0
- package/dist/lib/unusable-file.js.map +1 -0
- package/dist/lib/up-report.d.ts +6 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +13 -0
- package/dist/lib/up-report.js.map +1 -1
- package/dist/lib/verdict.d.ts +14 -0
- package/dist/lib/verdict.d.ts.map +1 -0
- package/dist/lib/verdict.js +15 -0
- package/dist/lib/verdict.js.map +1 -0
- package/dist/managed-handoff.d.ts +11 -6
- package/dist/managed-handoff.d.ts.map +1 -1
- package/dist/managed-handoff.js +27 -18
- package/dist/managed-handoff.js.map +1 -1
- package/dist/render.d.ts +5 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +44 -10
- package/dist/render.js.map +1 -1
- package/dist/telemetry.d.ts +4 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +14 -6
- package/dist/telemetry.js.map +1 -1
- package/dist/ui.d.ts +3 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +6 -4
- package/dist/ui.js.map +1 -1
- package/dist/view/mesh-view.d.ts.map +1 -1
- package/dist/view/mesh-view.js +4 -1
- package/dist/view/mesh-view.js.map +1 -1
- package/dist/watch-data.d.ts +9 -1
- package/dist/watch-data.d.ts.map +1 -1
- package/dist/watch-data.js +17 -3
- package/dist/watch-data.js.map +1 -1
- package/dist/watch-json.js +4 -3
- package/dist/watch-json.js.map +1 -1
- package/package.json +5 -5
package/dist/command.js
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { writeSync } from "node:fs";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
2
5
|
import { commandDeclarationProblems, findCommand, findSubcommand, parseCommandArgs } from "@cotal-ai/core";
|
|
3
|
-
import { CommandFailure, commandFailureReport, cachedPreferences, disableColor, disableInput, envelopeLine, exitCode, failureEnvelope, globalFlagDeclarationProblems, hasMeshTargetFlags, inOperationSpace, isCommandFailure, isConnectRefusal, isSeededCommand, isWorkspaceTargetError, operationWarnings, outputDeclarationProblems, renderReport, renderWorkspaceError, runOperation, workspaceErrorParts, spaceRootTarget, targetErrorCode, terminalWidth, } from "@cotal-ai/workspace";
|
|
6
|
+
import { CommandFailure, commandFailureReport, cachedPreferences, cotalDirProblem, cotalHomeProblem, findCotalRoot, disableColor, disableInput, envelopeLine, exitCode, failureEnvelope, GLOBAL_FLAGS, globalConfigDirProblem, globalFlagDeclarationProblems, hasMeshTargetFlags, inOperationSpace, isCommandFailure, brokerUrlCredentialRefusal, brokerUrlHasUserinfo, isConnectRefusal, isMeshRegistryError, isSeededCommand, isWorkspaceTargetError, localeIsUtf8, operationWarnings, outputDeclarationProblems, oneLine, preferencesFolderWarning, recordOperationWarning, renderReport, renderWorkspaceError, runOperation, workspaceErrorParts, spaceRootTarget, targetErrorCode, terminalWidth, userCotalDir, } from "@cotal-ai/workspace";
|
|
4
7
|
import { c, staleStoreHint, stderrLine } from "./ui.js";
|
|
8
|
+
import { debugFlag } from "./lib/debug-flag.js";
|
|
5
9
|
import { isExtensionStub, materializeExtension, materializeExtensionCommand, overlayExtensions, setCommandSurface, setInstalledExtensionsEnabled, } from "./ext-loader.js";
|
|
6
10
|
import { reconcileSeededConnectors } from "./seed/reconcile.js";
|
|
7
11
|
import { isAuthenticSeedChild } from "./seed/lock.js";
|
|
8
12
|
import { printCommandHelp, printHelpPath, printEntry } from "./help.js";
|
|
9
13
|
import { CatalogPreparationError, prepareCatalogCommand } from "./commands/sync.js";
|
|
10
14
|
import { servicePresetCommand } from "./lib/service-presets.js";
|
|
15
|
+
import { keepStartupNotice } from "./lib/interrupt-notice.js";
|
|
11
16
|
import { metadataPositionals } from "./lib/command-path.js";
|
|
12
17
|
import { chooseMeshTarget } from "./lib/choose-target.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
18
|
+
import { registryFailure } from "./lib/registry-errors.js";
|
|
19
|
+
import { FlagValueRefusal } from "./lib/flag-value-refusal.js";
|
|
20
|
+
import { workingFolderRemoved } from "./lib/paths.js";
|
|
15
21
|
import { reportLostOutput } from "./lib/stdout-owner.js";
|
|
16
|
-
import {
|
|
22
|
+
import { shellWord } from "./lib/endpoint-errors.js";
|
|
23
|
+
import { managerChoiceFailure, pickManager, rosterOf } from "./lib/manager-choice.js";
|
|
24
|
+
import { goneStackRefusal } from "./commands/stack-gone.js";
|
|
25
|
+
import { canPrompt } from "./commands/meshes-wizard.js";
|
|
17
26
|
import { takeManagedHandoffCustody } from "./managed-handoff.js";
|
|
27
|
+
import { didYouMean, unknownCommandMessage, unknownSubcommandMessage } from "./lib/nearest-word.js";
|
|
28
|
+
import { UnusableFile } from "./lib/unusable-file.js";
|
|
18
29
|
import { armTelemetry, recordTelemetryError, recordTelemetryFailure } from "./telemetry.js";
|
|
19
30
|
/** Whether `args` ask for help: `--help` or `-h` before any `--`, after which every word is text. */
|
|
20
31
|
function asksForHelp(args) {
|
|
@@ -32,10 +43,27 @@ function takeGlobalFlag(word) {
|
|
|
32
43
|
return false;
|
|
33
44
|
return true;
|
|
34
45
|
}
|
|
35
|
-
/**
|
|
36
|
-
function
|
|
46
|
+
/** Node's unknown-option error, trimmed to its first sentence, with the nearest of `cmd`'s flags. */
|
|
47
|
+
function parseErrorMessage(cmd, e) {
|
|
48
|
+
const message = e.message.split(".")[0];
|
|
49
|
+
const option = e.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" ? /^Unknown option '(--[^']+)'/.exec(message)?.[1] : undefined;
|
|
50
|
+
const hint = option ? didYouMean(option, [...(cmd.flags ?? []).map((flag) => `--${flag.name}`), "--no-color", "--no-input", "--help"]) : "";
|
|
51
|
+
return hint ? `${message} - ${hint}` : message;
|
|
52
|
+
}
|
|
53
|
+
/** `words` without the global flags before any `--`, each applied. A global flag is given once, as
|
|
54
|
+
* any flag is: one already in `words` or in `leading`, those taken before the command word, is the
|
|
55
|
+
* usage error a repeated flag of `cmd` is. */
|
|
56
|
+
function stripGlobalFlags(words, leading = new Set(), cmd) {
|
|
37
57
|
const end = words.indexOf("--");
|
|
38
|
-
const
|
|
58
|
+
const taken = new Set(leading);
|
|
59
|
+
const head = (end === -1 ? words : words.slice(0, end)).filter((word) => {
|
|
60
|
+
if (taken.has(word))
|
|
61
|
+
usageExit(`Option '${word}' cannot be repeated`, cmd, cmd !== undefined && asksForJson(cmd, words), words.includes("--plain"));
|
|
62
|
+
if (!takeGlobalFlag(word))
|
|
63
|
+
return true;
|
|
64
|
+
taken.add(word);
|
|
65
|
+
return false;
|
|
66
|
+
});
|
|
39
67
|
return end === -1 ? head : [...head, ...words.slice(end)];
|
|
40
68
|
}
|
|
41
69
|
/** Whether `cmd` takes its words raw: it declares so, or it is an internal command, whose words are
|
|
@@ -45,8 +73,8 @@ function takesWordsRaw(cmd) {
|
|
|
45
73
|
}
|
|
46
74
|
/** The words `cmd` parses: the global flags are the kernel's, except for a command that takes its
|
|
47
75
|
* words raw. */
|
|
48
|
-
function ownWords(cmd, words) {
|
|
49
|
-
return takesWordsRaw(cmd) ? [...words] : stripGlobalFlags(words);
|
|
76
|
+
function ownWords(cmd, words, leading) {
|
|
77
|
+
return takesWordsRaw(cmd) ? [...words] : stripGlobalFlags(words, leading, cmd);
|
|
50
78
|
}
|
|
51
79
|
/** Whether the invoked mode declares a structured output, so it reports every outcome by the 0 to 5
|
|
52
80
|
* table: the subcommand `first` selects, else the command's bare form. */
|
|
@@ -66,7 +94,7 @@ function asksForJson(cmd, args) {
|
|
|
66
94
|
}
|
|
67
95
|
/** Under COTAL_DEBUG, print the failure's stack and the stack of each error that caused it. */
|
|
68
96
|
function debugStacks(failure) {
|
|
69
|
-
if (!
|
|
97
|
+
if (!debugFlag("COTAL_DEBUG"))
|
|
70
98
|
return;
|
|
71
99
|
let error = failure;
|
|
72
100
|
for (let depth = 0; error instanceof Error && depth < 8; error = error.cause, depth++)
|
|
@@ -76,40 +104,51 @@ function debugStacks(failure) {
|
|
|
76
104
|
/** A classified failure: its line and remedy on stderr, its envelope on stdout when one was asked
|
|
77
105
|
* for, and the exit code its outcome sets. The envelope is written synchronously, because stdout
|
|
78
106
|
* to a pipe is asynchronous on some platforms and `exit` would cut it short. */
|
|
79
|
-
function failureExit(cmd, failure, json, plain = false,
|
|
107
|
+
function failureExit(cmd, failure, json, plain = false, scope) {
|
|
108
|
+
const warnings = scope ? scope.warnings ?? [] : operationWarnings();
|
|
80
109
|
recordTelemetryFailure(failure.outcome, failure.code, failure);
|
|
81
110
|
// A command's own usage refusal reads as the parser's: the error, its remedy, then the help. A
|
|
82
|
-
// missing --yes
|
|
83
|
-
// whole fix.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
stderrLine(" ", failure.remedy, c.dim);
|
|
88
|
-
if (!(failure instanceof ConfirmationRequired) && !(failure instanceof MissingFlags))
|
|
89
|
-
printCommandHelp(cmd, undefined, (line) => console.error(line), terminalWidth(process.stderr));
|
|
111
|
+
// missing --yes, a missing scripted input or a removed working folder is not a grammar mistake,
|
|
112
|
+
// and its remedy says the whole fix. A file the command cannot use is reported like one that does
|
|
113
|
+
// not exist, and a refused flag value names its corrected value, so it gets the classified report.
|
|
114
|
+
if (failure.code === "USAGE_INVALID" && !json && !(failure instanceof UnusableFile) && !(failure instanceof FlagValueRefusal)) {
|
|
115
|
+
usageRefusal(failure, plain, failure.selfContained ? undefined : cmd);
|
|
90
116
|
debugStacks(failure);
|
|
91
117
|
process.exit(1);
|
|
92
118
|
}
|
|
93
|
-
|
|
119
|
+
// Rendered in the run's scope, so the `Mesh:` heading keeps the note on how the run chose its space.
|
|
120
|
+
const report = () => renderReport(commandFailureReport(failure), plain ? "plain" : "rich", terminalWidth(process.stderr));
|
|
121
|
+
const writeReport = () => writeSync(2, `${scope ? runOperation(scope, report) : report()}
|
|
94
122
|
`);
|
|
95
|
-
//
|
|
96
|
-
|
|
123
|
+
// Under --json the envelope alone reports the failure. Its text report goes to stderr only when the
|
|
124
|
+
// envelope cannot be written, and the exit status below stands either way.
|
|
125
|
+
if (!json)
|
|
126
|
+
writeReport();
|
|
127
|
+
else
|
|
97
128
|
try {
|
|
98
129
|
writeSync(1, envelopeLine(failureEnvelope(cmd.name, failure, warnings)));
|
|
99
130
|
}
|
|
100
131
|
catch (error) {
|
|
101
132
|
reportLostOutput(error);
|
|
133
|
+
try {
|
|
134
|
+
writeReport();
|
|
135
|
+
}
|
|
136
|
+
catch { /* stderr failed too; the exit status still says so */ }
|
|
102
137
|
}
|
|
103
138
|
debugStacks(failure);
|
|
104
139
|
process.exit(exitCode(failure.outcome, failure.code));
|
|
105
140
|
}
|
|
141
|
+
/** The refusal of a command that would read or write a config folder that is a file. */
|
|
142
|
+
function configFolderRefusal(problem) {
|
|
143
|
+
return new CommandFailure("refused", "SCHEMA_INVALID", `${problem.message}; Cotal keeps your preferences, config and extensions there, so the command did not run`, { remedy: problem.remedy });
|
|
144
|
+
}
|
|
106
145
|
/**
|
|
107
146
|
* `ext seed [--repair|--reset|--force]`, dispatched before the manifest overlay so repair survives a
|
|
108
147
|
* corrupt manifest. Returns `true` iff `argv` was that command (or its help), so the caller returns.
|
|
109
148
|
* The overlay cannot list the command yet, so the built-in `ext` is found through the registry,
|
|
110
149
|
* which resolves its alias too.
|
|
111
150
|
*/
|
|
112
|
-
async function extSeedGate(registry, argv) {
|
|
151
|
+
async function extSeedGate(registry, argv, configFolder, leading) {
|
|
113
152
|
const [word, sub] = argv;
|
|
114
153
|
const extCmd = word === undefined || !registry.has("command", word) ? undefined : registry.resolve("command", word);
|
|
115
154
|
if (extCmd?.name !== "ext" || sub !== "seed")
|
|
@@ -120,7 +159,9 @@ async function extSeedGate(registry, argv) {
|
|
|
120
159
|
printCommandHelp(extCmd);
|
|
121
160
|
return true;
|
|
122
161
|
}
|
|
123
|
-
|
|
162
|
+
if (configFolder)
|
|
163
|
+
failureExit(extCmd, configFolderRefusal(configFolder), false);
|
|
164
|
+
await extCmd.run(parseCommandArgs(extCmd, stripGlobalFlags(argv.slice(1), leading, extCmd)));
|
|
124
165
|
return true;
|
|
125
166
|
}
|
|
126
167
|
/**
|
|
@@ -199,6 +240,28 @@ function isArgError(e) {
|
|
|
199
240
|
const code = e?.code;
|
|
200
241
|
return typeof code === "string" && code.startsWith("ERR_PARSE_ARGS");
|
|
201
242
|
}
|
|
243
|
+
/** The managed verbs whose unpinned manager selection is asked on a terminal: each is refused
|
|
244
|
+
* before any effect when several of your managers are live. */
|
|
245
|
+
const PICKS_MANAGER = new Set(["spawn", "ps", "stop", "attach", "input", "models", "persona", "status"]);
|
|
246
|
+
/** Whether `e` refused the unpinned manager selection of a command in {@link PICKS_MANAGER} and
|
|
247
|
+
* this terminal then picked a manager, which `parsed` now pins with `--on`. A script, `--json`,
|
|
248
|
+
* `--no-input` or `COTAL_NO_PROMPT=1` is not asked and keeps the refusal. A cancelled question exits 0, having
|
|
249
|
+
* done nothing. */
|
|
250
|
+
async function pinPickedManager(e, cmd, parsed, argv) {
|
|
251
|
+
if (!PICKS_MANAGER.has(cmd.name) || parsed.values.on !== undefined || !canPrompt())
|
|
252
|
+
return false;
|
|
253
|
+
const failure = isCommandFailure(e) ? e : isConnectRefusal(e) ? e.failure() : undefined;
|
|
254
|
+
if (!failure)
|
|
255
|
+
return false;
|
|
256
|
+
const target = { space: typeof parsed.values.space === "string" ? parsed.values.space : undefined, server: typeof parsed.values.server === "string" ? parsed.values.server : undefined };
|
|
257
|
+
const picked = await pickManager(failure, () => rosterOf(target), argv);
|
|
258
|
+
if (picked === null)
|
|
259
|
+
process.exit(0);
|
|
260
|
+
if (picked === undefined)
|
|
261
|
+
return false;
|
|
262
|
+
parsed.values.on = picked.instanceId;
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
202
265
|
/** One dispatcher-owned catalog gate for every command that uses the shared mesh target grammar,
|
|
203
266
|
* including commands self-registered by other packages. Registry-local `meshes add/rm` stay
|
|
204
267
|
* offline. `use` takes its target positionally, and status keeps stale bytes diagnostic-only.
|
|
@@ -234,42 +297,121 @@ async function prepareCatalogForCommand(cmd, args) {
|
|
|
234
297
|
await chooseMeshTarget(args);
|
|
235
298
|
}
|
|
236
299
|
}
|
|
237
|
-
/** A usage
|
|
238
|
-
|
|
300
|
+
/** A usage refusal on stderr, then `cmd`'s help when one is given. Plain output and a locale without
|
|
301
|
+
* UTF-8 have no refusal mark, so there the refusal is the classified report, which names its outcome
|
|
302
|
+
* in words. Either way the words it quotes are escaped, as the report escapes every text. */
|
|
303
|
+
function usageRefusal(failure, plain, cmd) {
|
|
304
|
+
const report = plain || !localeIsUtf8();
|
|
305
|
+
if (report)
|
|
306
|
+
writeSync(2, `${renderReport(commandFailureReport(failure), plain ? "plain" : "rich", terminalWidth(process.stderr))}\n`);
|
|
307
|
+
else {
|
|
308
|
+
stderrLine("✗ ", oneLine(failure.message), c.red);
|
|
309
|
+
if (failure.remedy)
|
|
310
|
+
stderrLine(" ", oneLine(failure.remedy), c.dim);
|
|
311
|
+
}
|
|
312
|
+
if (!cmd)
|
|
313
|
+
return;
|
|
314
|
+
if (report)
|
|
315
|
+
console.error("");
|
|
316
|
+
printCommandHelp(cmd, undefined, (line) => console.error(line), terminalWidth(process.stderr));
|
|
317
|
+
}
|
|
318
|
+
/** A usage error, written by {@link usageRefusal} with the command's help when there is one, and
|
|
319
|
+
* with `remedy` under the message when the parser can name one. Exit 1. */
|
|
320
|
+
function usageExit(message, cmd, json = false, plain = false, remedy) {
|
|
239
321
|
// A JSON caller gets the refusal as an envelope, so stdout stays one document and the help text
|
|
240
322
|
// the remedy names stays out of it.
|
|
241
323
|
if (cmd && json)
|
|
242
|
-
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", message, { remedy: `run \`cotal help ${cmd.name}\`` }), true);
|
|
324
|
+
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", message, { remedy: remedy ?? `run \`cotal help ${cmd.name}\`` }), true);
|
|
243
325
|
recordTelemetryFailure("refused", "USAGE_INVALID", message);
|
|
244
326
|
// The help goes to stderr with the reason, so a refused run leaves stdout empty and a script that
|
|
245
327
|
// sources or parses it gets nothing.
|
|
246
|
-
|
|
247
|
-
if (cmd)
|
|
248
|
-
printCommandHelp(cmd, undefined, (line) => console.error(line), terminalWidth(process.stderr));
|
|
328
|
+
usageRefusal(new CommandFailure("refused", "USAGE_INVALID", message, remedy === undefined ? undefined : { remedy }), plain, cmd);
|
|
249
329
|
process.exit(1);
|
|
250
330
|
}
|
|
251
|
-
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
331
|
+
/** An option the parser would misread without an error: a short option written `-c=value`, which
|
|
332
|
+
* takes `=value` as its value, or a declared option typed with a typographic dash pasted from typeset
|
|
333
|
+
* text, which is read as a positional. */
|
|
334
|
+
function misspelledOption(cmd, rest) {
|
|
335
|
+
const names = new Set([...(cmd.flags ?? []).map((flag) => flag.name), ...GLOBAL_FLAGS]);
|
|
336
|
+
const shorts = new Set((cmd.flags ?? []).flatMap((flag) => (flag.short ? [flag.short] : [])));
|
|
337
|
+
for (const [index, word] of rest.entries()) {
|
|
338
|
+
if (word === "--")
|
|
339
|
+
return undefined;
|
|
340
|
+
const previous = rest[index - 1];
|
|
341
|
+
if (previous !== undefined && cmd.flags?.some((flag) => flag.type === "string" && (previous === `--${flag.name}` || previous === `-${flag.short}`)))
|
|
342
|
+
continue;
|
|
343
|
+
const short = /^-([^-=])=(.*)$/su.exec(word);
|
|
344
|
+
const flag = short && cmd.flags?.find((item) => item.short === short[1] && item.type === "string");
|
|
345
|
+
if (short && flag)
|
|
346
|
+
return { message: `${word} gives -${short[1]} the value "=${short[2]}"`, remedy: `write -${short[1]} ${short[2]} or --${flag.name}=${short[2]}` };
|
|
347
|
+
const typed = /^[\u2010-\u2015\u2212][-\u2010-\u2015\u2212]*([^=]+)/u.exec(word);
|
|
348
|
+
if (typed && (names.has(typed[1]) || shorts.has(typed[1])))
|
|
349
|
+
return { message: `${word} starts with a typographic dash, so it is not an option`, remedy: `type the option with hyphens: ${names.has(typed[1]) ? "--" : "-"}${typed[1]}` };
|
|
350
|
+
}
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
/** A parse error as a refusal. Node's message is trimmed to its first sentence, and the hint its tail
|
|
354
|
+
* carries is given as the remedy in this CLI's words: a word that starts with `-` goes after `--`,
|
|
355
|
+
* an option value that starts with `-` is written `--name=value`, and an option given with no value,
|
|
356
|
+
* last or before another of the command's options, is named with its placeholder. */
|
|
357
|
+
function parseRefusal(error, cmd, rest) {
|
|
358
|
+
const message = parseErrorMessage(cmd, error);
|
|
359
|
+
if (error.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && cmd.positionals !== undefined)
|
|
360
|
+
return { message, remedy: "to pass a word that starts with \"-\", put -- before it" };
|
|
361
|
+
const missingValue = (flag) => ({ message: `--${flag.name} needs a value`, remedy: `write --${flag.name} ${flag.value ?? "<value>"}` });
|
|
362
|
+
const bare = /^Option '(?:-[^,']+, )?--([^ ']+) <value>' argument missing/.exec(error.message)?.[1];
|
|
363
|
+
const last = bare === undefined ? undefined : cmd.flags?.find((item) => item.name === bare);
|
|
364
|
+
if (error.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && last)
|
|
365
|
+
return missingValue(last);
|
|
366
|
+
const long = /use '--([^=']+)=-XYZ'/.exec(error.message)?.[1];
|
|
367
|
+
const flag = long === undefined ? undefined : cmd.flags?.find((item) => item.name === long);
|
|
368
|
+
if (error.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE" && flag) {
|
|
369
|
+
const at = rest.findIndex((word) => word === `--${flag.name}` || (flag.short !== undefined && word === `-${flag.short}`));
|
|
370
|
+
const value = at < 0 ? undefined : rest[at + 1];
|
|
371
|
+
if (value !== undefined && cmd.flags?.some((item) => value === `--${item.name}` || value.startsWith(`--${item.name}=`) || (item.short !== undefined && value === `-${item.short}`)))
|
|
372
|
+
return missingValue(flag);
|
|
373
|
+
if (value?.startsWith("-"))
|
|
374
|
+
return { message: `the value of --${flag.name} starts with "-", so it reads as an option`, remedy: `write it as --${flag.name}=${value}` };
|
|
375
|
+
}
|
|
376
|
+
return { message };
|
|
377
|
+
}
|
|
378
|
+
/** `rest` parsed against `cmd`'s declared flags, positionals and subcommands, or a usage exit. */
|
|
254
379
|
function parseOrExit(cmd, rest) {
|
|
255
380
|
const json = asksForJson(cmd, rest);
|
|
381
|
+
const plain = rest.includes("--plain");
|
|
382
|
+
const misspelled = cmd.rawArgs ? undefined : misspelledOption(cmd, rest);
|
|
383
|
+
if (misspelled)
|
|
384
|
+
usageExit(misspelled.message, cmd, json, plain, misspelled.remedy);
|
|
256
385
|
let parsed;
|
|
257
386
|
try {
|
|
258
387
|
parsed = parseCommandArgs(cmd, rest);
|
|
259
388
|
}
|
|
260
389
|
catch (e) {
|
|
261
|
-
if (isArgError(e))
|
|
262
|
-
|
|
390
|
+
if (isArgError(e)) {
|
|
391
|
+
const refusal = parseRefusal(e, cmd, rest);
|
|
392
|
+
usageExit(refusal.message, cmd, json, plain, refusal.remedy);
|
|
393
|
+
}
|
|
263
394
|
throw e;
|
|
264
395
|
}
|
|
265
396
|
const first = parsed.positionals[0];
|
|
266
397
|
// History also accepts a root channel positional; only its reserved clear token is a mode.
|
|
267
398
|
if (cmd.subcommands?.length && first !== undefined && cmd.name !== "history" && !findSubcommand(cmd, first))
|
|
268
|
-
usageExit(
|
|
399
|
+
usageExit(unknownSubcommandMessage(cmd.name, cmd, first), cmd, json, plain);
|
|
400
|
+
// Target resolution reads an empty space as no space and falls back to the selected one, so a script
|
|
401
|
+
// whose variable is unset would act on whichever space is selected.
|
|
402
|
+
const spaceFlag = cmd.flags?.find((flag) => flag.name === "space");
|
|
403
|
+
if (spaceFlag && typeof parsed.values.space === "string" && !parsed.values.space.trim())
|
|
404
|
+
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", `--space${spaceFlag.short ? `/-${spaceFlag.short}` : ""} is empty; name one space`, { remedy: "name the space; `cotal space` lists the spaces this machine knows" }), json, parsed.values.plain === true);
|
|
405
|
+
// An empty --store-dir reads as no value and opens the default store, and a ~ no shell expanded
|
|
406
|
+
// names a folder called ~ in the working folder.
|
|
407
|
+
const storeDir = parsed.values["store-dir"];
|
|
408
|
+
if (typeof storeDir === "string" && (!storeDir.trim() || storeDir.startsWith("~")))
|
|
409
|
+
failureExit(cmd, storeDirRefusal(storeDir), json, parsed.values.plain === true);
|
|
269
410
|
// `--json` implies `--no-input`: a script reading one document cannot answer a prompt.
|
|
270
411
|
if (structured(cmd, first) && parsed.values.json === true)
|
|
271
412
|
disableInput();
|
|
272
413
|
const canonical = canonicalSubcommand(cmd, parsed);
|
|
414
|
+
refuseRemovedFolder(cmd, canonical);
|
|
273
415
|
try {
|
|
274
416
|
cmd.validate?.(canonical);
|
|
275
417
|
}
|
|
@@ -277,11 +419,33 @@ function parseOrExit(cmd, rest) {
|
|
|
277
419
|
if (isCommandFailure(error))
|
|
278
420
|
failureExit(cmd, error, json, canonical.values.plain === true);
|
|
279
421
|
if (isArgError(error))
|
|
280
|
-
usageExit(error.message.split(".")[0], cmd, json);
|
|
422
|
+
usageExit(error.message.split(".")[0], cmd, json, plain);
|
|
281
423
|
throw error;
|
|
282
424
|
}
|
|
425
|
+
// The NATS client keeps only the host and port of a broker URL, so a user and password in it were
|
|
426
|
+
// dropped in silence and the command connected with whatever credential it resolved instead. A
|
|
427
|
+
// command whose own check names this, such as `up`'s, has refused above. The value is never repeated.
|
|
428
|
+
if (cmd.flags?.some((flag) => flag.name === "server") && typeof canonical.values.server === "string" && brokerUrlHasUserinfo(canonical.values.server))
|
|
429
|
+
failureExit(cmd, brokerUrlCredentialRefusal("--server"), json, canonical.values.plain === true);
|
|
283
430
|
return canonical;
|
|
284
431
|
}
|
|
432
|
+
/** The refusal of a `--store-dir` that is empty, or that starts with a `~` no shell expanded. */
|
|
433
|
+
function storeDirRefusal(value) {
|
|
434
|
+
if (!value.trim())
|
|
435
|
+
return new CommandFailure("refused", "USAGE_INVALID", "--store-dir is empty; the command did not run", { remedy: "name the store directory, or omit --store-dir to use the default store", selfContained: true });
|
|
436
|
+
const home = value === "~" || value.startsWith("~/") ? join(homedir(), value.slice(2)) : undefined;
|
|
437
|
+
return new CommandFailure("refused", "USAGE_INVALID", `--store-dir ${JSON.stringify(value)} starts with ~, which no shell expanded, so it names a folder called ${value.split("/")[0]} in ${process.cwd()}; the command did not run`, { target: { storeDir: value }, remedy: home ? `name the absolute path: --store-dir ${shellWord(home)}` : "name the store directory by its absolute path", selfContained: true });
|
|
438
|
+
}
|
|
439
|
+
/** The commands that never read the working folder, so they run from one that was removed. */
|
|
440
|
+
const FOLDERLESS = new Set(["help", "version", "completion", "docs", "telemetry"]);
|
|
441
|
+
/** A working folder removed before this process read it fails every cwd read the command makes, and
|
|
442
|
+
* Node caches the first read that succeeds. One read refuses that case before the command's own
|
|
443
|
+
* checks, such as `up`'s, or any effect, unless the command never reads the folder. */
|
|
444
|
+
function refuseRemovedFolder(cmd, parsed) {
|
|
445
|
+
if (cmd.name.startsWith("__") || FOLDERLESS.has(cmd.name) || !workingFolderRemoved())
|
|
446
|
+
return;
|
|
447
|
+
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", "this folder no longer exists", { remedy: "cd to an existing folder and run the command again", selfContained: true }), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
448
|
+
}
|
|
285
449
|
/** The parsed args with a subcommand alias in the first positional replaced by its name, so `run`
|
|
286
450
|
* only ever sees canonical subcommands. */
|
|
287
451
|
function canonicalSubcommand(cmd, parsed) {
|
|
@@ -308,6 +472,10 @@ function printHelpFor(cmd, rest) {
|
|
|
308
472
|
const path = [];
|
|
309
473
|
for (const word of words) {
|
|
310
474
|
const sub = findSubcommand(surface, word);
|
|
475
|
+
// A word where a subcommand belongs that names none refuses as `cotal help` does, so a mistyped
|
|
476
|
+
// subcommand never gets its group's help. History's own first word may be a channel.
|
|
477
|
+
if (!sub && surface.subcommands?.length && !(surface === cmd && cmd.name === "history"))
|
|
478
|
+
return printHelpPath(cmd, [...path, word]);
|
|
311
479
|
if (!sub || sub.hidden)
|
|
312
480
|
break;
|
|
313
481
|
path.push(sub.name);
|
|
@@ -335,12 +503,17 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
335
503
|
// the leading flags. A command that takes its words raw has no flags to read them as, so it
|
|
336
504
|
// refuses them there. The built-in surface decides that before any extension overlay is read.
|
|
337
505
|
const output = [];
|
|
506
|
+
const leadingGlobals = new Set();
|
|
338
507
|
let lead = 0;
|
|
339
508
|
for (; lead < argv.length; lead++) {
|
|
340
509
|
const word = argv[lead];
|
|
341
510
|
if (word === "--json" || word === "-j" || word === "--plain")
|
|
342
511
|
output.push(word);
|
|
343
|
-
else if (
|
|
512
|
+
else if (leadingGlobals.has(word))
|
|
513
|
+
usageExit(`Option '${word}' cannot be repeated`);
|
|
514
|
+
else if (takeGlobalFlag(word))
|
|
515
|
+
leadingGlobals.add(word);
|
|
516
|
+
else
|
|
344
517
|
break;
|
|
345
518
|
}
|
|
346
519
|
if (argv[lead] === "--")
|
|
@@ -367,9 +540,9 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
367
540
|
}
|
|
368
541
|
return;
|
|
369
542
|
}
|
|
370
|
-
// Before any ordinary dispatch outcome can exit,
|
|
371
|
-
//
|
|
372
|
-
takeManagedHandoffCustody(process.env);
|
|
543
|
+
// Before any ordinary dispatch outcome can exit, a spawn takes its handoff, and no command lets a
|
|
544
|
+
// child inherit the variable. The unit entry refuses such a handoff without consuming its file.
|
|
545
|
+
takeManagedHandoffCustody(process.env, findCommand(registry.all("command"), argv[0])?.name === "spawn");
|
|
373
546
|
setInstalledExtensionsEnabled(Boolean(opts.extensions));
|
|
374
547
|
// The global spellings of help and version are the `help` and `version` commands.
|
|
375
548
|
if (argv[0] === "-v")
|
|
@@ -378,9 +551,10 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
378
551
|
argv = ["version", ...argv.slice(1)];
|
|
379
552
|
else if (argv[0] === "--help" || argv[0] === "-h")
|
|
380
553
|
argv = ["help", ...argv.slice(1)];
|
|
554
|
+
const configFolder = globalConfigDirProblem();
|
|
381
555
|
if (opts.extensions) {
|
|
382
556
|
try {
|
|
383
|
-
if (await extSeedGate(registry, argv))
|
|
557
|
+
if (await extSeedGate(registry, argv, configFolder, leadingGlobals))
|
|
384
558
|
return;
|
|
385
559
|
}
|
|
386
560
|
catch (e) {
|
|
@@ -417,7 +591,7 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
417
591
|
if (word === undefined)
|
|
418
592
|
return printEntry(commands);
|
|
419
593
|
let cmd = findCommand(commands, word);
|
|
420
|
-
let rest = ownWords(cmd, words);
|
|
594
|
+
let rest = ownWords(cmd, words, leadingGlobals);
|
|
421
595
|
const wantsHelp = asksForHelp(rest);
|
|
422
596
|
if (cmd?.name === "service") {
|
|
423
597
|
try {
|
|
@@ -448,7 +622,7 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
448
622
|
// unknown word is a usage error.
|
|
449
623
|
const awaitingSeed = !cmd && opts.extensions === true && isSeededCommand(word) && !wantsHelp && !skipsSeed(word, rest[0], rest);
|
|
450
624
|
if (!cmd && !awaitingSeed)
|
|
451
|
-
usageExit(
|
|
625
|
+
usageExit(unknownCommandMessage(commands, word));
|
|
452
626
|
// `cotal <cmd> --help` / `-h` → that command's help, never run it. This intercept also covers
|
|
453
627
|
// rawArgs commands and extension STUBS (cached specs are exactly the display surface) — only
|
|
454
628
|
// `__`-internal ones are exempt, because __complete's argv is ANOTHER command's half-typed
|
|
@@ -457,6 +631,11 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
457
631
|
return printHelpFor(cmd, rest);
|
|
458
632
|
let parsed = cmd && !isExtensionStub(cmd) ? parseOrExit(cmd, rest) : undefined;
|
|
459
633
|
// ---- Effects: only a validated invocation reaches this line. ----
|
|
634
|
+
// A config folder that is a file fails every read and write of the preferences, the config file and
|
|
635
|
+
// the extensions, so a command that could use them stops here, before the seed would write there.
|
|
636
|
+
// Help, shell completion, version and docs use none of them.
|
|
637
|
+
if (configFolder && cmd && parsed && !cmd.name.startsWith("__") && !["help", "completion", "version", "docs"].includes(cmd.name))
|
|
638
|
+
failureExit(cmd, configFolderRefusal(configFolder), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
460
639
|
// The seed can install or upgrade an extension package, so the surface is read again after it and
|
|
461
640
|
// an extension stub resolves against the manifest the seed left.
|
|
462
641
|
const controlOnlyManager = parsed?.values.execution === "none" && (cmd?.name === "supervise" || cmd?.name === "__daemon-manager");
|
|
@@ -471,8 +650,8 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
471
650
|
commands = surface();
|
|
472
651
|
cmd = findCommand(commands, word);
|
|
473
652
|
if (!cmd)
|
|
474
|
-
usageExit(
|
|
475
|
-
rest = ownWords(cmd, words);
|
|
653
|
+
usageExit(unknownCommandMessage(commands, word));
|
|
654
|
+
rest = ownWords(cmd, words, leadingGlobals);
|
|
476
655
|
arm();
|
|
477
656
|
}
|
|
478
657
|
// An extension stub materializes before parsing: verify the version pin, import the package
|
|
@@ -489,73 +668,107 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
489
668
|
}
|
|
490
669
|
if (!cmd || !parsed)
|
|
491
670
|
throw new Error("internal error: dispatch reached its effects without a parsed command");
|
|
492
|
-
// A
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
|
|
496
|
-
try {
|
|
497
|
-
process.cwd();
|
|
498
|
-
}
|
|
499
|
-
catch (e) {
|
|
500
|
-
if (e.code !== "ENOENT")
|
|
501
|
-
throw e;
|
|
502
|
-
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", "this folder no longer exists", { remedy: "cd to an existing folder and run the command again" }), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
// A preferences file that does not validate stops every command except help and shell completion,
|
|
506
|
-
// as a broken config file does, so nothing runs on a default the person did not mean. `--help` on a
|
|
507
|
-
// command has already returned above.
|
|
671
|
+
// A preferences file that does not validate stops every command that could act on a default, as a
|
|
672
|
+
// broken config file does, so nothing runs on a default the person did not mean. Help, shell
|
|
673
|
+
// completion, version and docs use no preference, and status reports the file as a warning, so they
|
|
674
|
+
// still run. `--help` on a command has already returned above.
|
|
508
675
|
if (!cmd.name.startsWith("__") && cmd.name !== "help" && cmd.name !== "completion") {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
676
|
+
// A relative COTAL_HOME would name another home in each folder a command runs in, and a
|
|
677
|
+
// COTAL_HOME that cannot be a directory can hold no record: both stop them before any command
|
|
678
|
+
// reads it.
|
|
679
|
+
const home = process.env.COTAL_HOME;
|
|
680
|
+
if (home && !isAbsolute(home))
|
|
681
|
+
failureExit(cmd, new CommandFailure("refused", "USAGE_INVALID", `COTAL_HOME ${JSON.stringify(home)} is a relative path, so each folder a command runs in would have its own Cotal home; the command did not run`, { remedy: `set COTAL_HOME to an absolute path, or unset it to use ${userCotalDir()}` }), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
682
|
+
const homeProblem = cotalHomeProblem();
|
|
683
|
+
if (homeProblem)
|
|
684
|
+
failureExit(cmd, new CommandFailure("refused", "SCHEMA_INVALID", `${homeProblem}; the command did not run`, { remedy: `point COTAL_HOME at a directory, or unset it to use ${userCotalDir()}` }), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
685
|
+
// A `.cotal` that is a file in the folder the command uses, such as someone's notes, holds no
|
|
686
|
+
// records, and every reader would otherwise report a different wrong cause.
|
|
687
|
+
const dirProblem = cmd.name === "version" || workingFolderRemoved() ? undefined : cotalDirProblem(typeof parsed.values.root === "string" ? resolve(parsed.values.root) : findCotalRoot());
|
|
688
|
+
if (dirProblem)
|
|
689
|
+
failureExit(cmd, new CommandFailure("refused", "CONFLICT", `${dirProblem}; the command did not run`, { remedy: "rename or move that file, then run the command again" }), structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
690
|
+
if (!["version", "docs", "status"].includes(cmd.name)) {
|
|
691
|
+
try {
|
|
692
|
+
cachedPreferences();
|
|
693
|
+
}
|
|
694
|
+
catch (e) {
|
|
695
|
+
if (!isCommandFailure(e))
|
|
696
|
+
throw e;
|
|
697
|
+
failureExit(cmd, e, structured(cmd, parsed.positionals[0]) && parsed.values.json === true, parsed.values.plain === true);
|
|
698
|
+
}
|
|
516
699
|
}
|
|
517
700
|
}
|
|
518
|
-
// A failure raised after the command recorded the space it resolved is reported in that space.
|
|
519
|
-
|
|
520
|
-
|
|
701
|
+
// A failure raised after the command recorded the space it resolved is reported in that space. A
|
|
702
|
+
// completion writes its warnings, as its errors, only under COTAL_COMPLETE_DEBUG.
|
|
703
|
+
const scope = cmd.name === "__complete" && !debugFlag("COTAL_COMPLETE_DEBUG") ? { quiet: true } : {};
|
|
704
|
+
const execute = async () => {
|
|
521
705
|
if (opts.extensions && cmd.requiredExtensions) {
|
|
522
706
|
for (const ref of cmd.requiredExtensions(parsed))
|
|
523
707
|
await materializeExtension(ref);
|
|
524
708
|
}
|
|
525
709
|
await prepareCatalogForCommand(cmd, parsed);
|
|
526
710
|
await runOperation(scope, async () => {
|
|
711
|
+
// Preferences that another local account could change still apply, so each command that uses
|
|
712
|
+
// them says so, with the change that protects their folder.
|
|
713
|
+
if (!cmd.name.startsWith("__") && !["help", "completion", "version", "docs"].includes(cmd.name)) {
|
|
714
|
+
const folder = preferencesFolderWarning();
|
|
715
|
+
if (folder)
|
|
716
|
+
recordOperationWarning(folder.warning);
|
|
717
|
+
}
|
|
527
718
|
if (cmd.prepare)
|
|
528
719
|
await cmd.prepare(parsed);
|
|
529
720
|
await cmd.run(parsed);
|
|
530
721
|
});
|
|
722
|
+
};
|
|
723
|
+
if (opts.startupNotice && cmd.keepsStartupNotice)
|
|
724
|
+
keepStartupNotice(opts.startupNotice);
|
|
725
|
+
else
|
|
726
|
+
await opts.startupNotice?.release();
|
|
727
|
+
try {
|
|
728
|
+
await execute();
|
|
531
729
|
}
|
|
532
730
|
catch (e) {
|
|
731
|
+
// On a terminal, a refused unpinned manager selection among several live managers is asked
|
|
732
|
+
// once, and the command runs again on the manager picked, as the refusal's Next would rerun it.
|
|
733
|
+
if (await pinPickedManager(e, cmd, parsed, argv)) {
|
|
734
|
+
try {
|
|
735
|
+
await execute();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
catch (again) {
|
|
739
|
+
e = again;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
533
742
|
recordTelemetryError(e);
|
|
534
743
|
const mode = parsed.positionals[0];
|
|
535
744
|
const json = structured(cmd, mode) && parsed.values.json === true;
|
|
536
745
|
// A usage error a command raises from its own checks prints the command's help, not a stack trace.
|
|
537
746
|
if (isArgError(e))
|
|
538
|
-
usageExit(e.message.split(".")[0], cmd, json);
|
|
747
|
+
usageExit(e.message.split(".")[0], cmd, json, parsed.values.plain === true);
|
|
539
748
|
// A refused manager selection among several live managers becomes the choice: each manager
|
|
540
|
-
// and the command again with `--on` for it.
|
|
749
|
+
// and the command again with `--on` for it. A space whose stack folder is gone names its stop.
|
|
541
750
|
const target = { space: typeof parsed.values.space === "string" ? parsed.values.space : undefined, server: typeof parsed.values.server === "string" ? parsed.values.server : undefined };
|
|
542
|
-
const choice = async (failure) => (await managerChoiceFailure(failure, () => rosterOf(target), argv)) ?? failure;
|
|
751
|
+
const choice = async (failure) => (await managerChoiceFailure(failure, () => rosterOf(target), argv)) ?? goneStackRefusal(failure);
|
|
543
752
|
if (isCommandFailure(e))
|
|
544
|
-
failureExit(cmd, inOperationSpace(await choice(e), scope.space), json, parsed.values.plain === true, scope
|
|
753
|
+
failureExit(cmd, inOperationSpace(await choice(e), scope.space), json, parsed.values.plain === true, scope);
|
|
545
754
|
// A command that declares a structured output reports by the outcome table. A target it could
|
|
546
755
|
// not resolve or connect to is refused before any request, under the refusal's own code; a
|
|
547
756
|
// failure it did not classify is unknown: it may have had effects that cannot be attributed.
|
|
548
757
|
if (structured(cmd, mode)) {
|
|
549
758
|
if (isConnectRefusal(e))
|
|
550
|
-
failureExit(cmd, inOperationSpace(await choice(e.failure()), scope.space), json, parsed.values.plain === true, scope
|
|
759
|
+
failureExit(cmd, inOperationSpace(await choice(e.failure()), scope.space), json, parsed.values.plain === true, scope);
|
|
551
760
|
if (isWorkspaceTargetError(e)) {
|
|
552
761
|
const { message, remedy } = workspaceErrorParts({ kind: "target", error: e });
|
|
553
762
|
const target = spaceRootTarget(e.details);
|
|
554
|
-
failureExit(cmd, inOperationSpace(new CommandFailure("refused", targetErrorCode(e.code), message, { ...(remedy ? { remedy } : {}), ...(target ? { target } : {}) }), scope.space), json, parsed.values.plain === true, scope
|
|
763
|
+
failureExit(cmd, inOperationSpace(new CommandFailure("refused", targetErrorCode(e.code), message, { ...(remedy ? { remedy } : {}), ...(target ? { target } : {}) }), scope.space), json, parsed.values.plain === true, scope);
|
|
555
764
|
}
|
|
765
|
+
// A registry record or directory it could not read is refused by its file, as `space` reports
|
|
766
|
+
// it, and as a target it could not resolve is refused above.
|
|
767
|
+
if (isMeshRegistryError(e))
|
|
768
|
+
failureExit(cmd, inOperationSpace(registryFailure(e), scope.space), json, parsed.values.plain === true, scope);
|
|
556
769
|
if (e instanceof CatalogPreparationError)
|
|
557
|
-
failureExit(cmd, new CommandFailure("refused", e.code, e.message), json, parsed.values.plain === true, scope
|
|
558
|
-
failureExit(cmd, inOperationSpace(new CommandFailure("unknown", "OPERATION_UNKNOWN", e instanceof Error ? e.message : String(e), { cause: e }), scope.space), json, parsed.values.plain === true, scope
|
|
770
|
+
failureExit(cmd, new CommandFailure("refused", e.code, e.message), json, parsed.values.plain === true, scope);
|
|
771
|
+
failureExit(cmd, inOperationSpace(new CommandFailure("unknown", "OPERATION_UNKNOWN", e instanceof Error ? e.message : String(e), { cause: e }), scope.space), json, parsed.values.plain === true, scope);
|
|
559
772
|
}
|
|
560
773
|
// A workspace TARGET error carries structured recovery — which entry, whether it was removed,
|
|
561
774
|
// what to run next — and has its own renderer. Its raw `.message` is deliberately dev-safe
|
|
@@ -565,7 +778,7 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
565
778
|
// `…OrExit` helper.
|
|
566
779
|
if (isWorkspaceTargetError(e)) {
|
|
567
780
|
console.error(c.red(renderWorkspaceError({ kind: "target", error: e })));
|
|
568
|
-
if (
|
|
781
|
+
if (debugFlag("COTAL_DEBUG") && e instanceof Error && e.stack)
|
|
569
782
|
console.error(c.dim(e.stack));
|
|
570
783
|
process.exit(1);
|
|
571
784
|
}
|
|
@@ -586,7 +799,7 @@ export async function runCli(registry, argv, opts = {}) {
|
|
|
586
799
|
const hint = staleStoreHint(msg);
|
|
587
800
|
if (hint)
|
|
588
801
|
stderrLine(" ↳ ", hint, c.dim);
|
|
589
|
-
if (
|
|
802
|
+
if (debugFlag("COTAL_DEBUG") && e instanceof Error && e.stack)
|
|
590
803
|
console.error(c.dim(e.stack));
|
|
591
804
|
process.exit(1);
|
|
592
805
|
}
|