Expand description
CommandExecutor provider: runs shell commands in a managed subprocess.
§CommandProvider
Implements CommandExecutor for MountainEnvironment - the central
registry and dispatcher for all commands in Mountain. Commands are
identified by string IDs and handled either by native Rust functions
or proxied to extension sidecar processes via IPC.
§Execution flow
- Caller invokes
ExecuteCommand(id, args). - Provider looks up
idinApplicationState::CommandRegistry. - Native handler: calls the Rust function pointer directly with
AppHandle, the mainWebviewWindow,ApplicationRunTime, andargs. - Proxied handler: sends an RPC request to the owning extension sidecar via the Vine IPC client.
- Returns a serialized
serde_json::Valueresult or aCommonError.
§Special-case no-ops
Three categories of unknown commands are silently returned as
Value::Null rather than an error, to match VS Code’s behaviour:
- View-action auto-commands (
.focus,.resetViewLocation,.removeView) - Workbench-internal commands with no Land backing service
(
getTelemetrySenderObject,testing.clearTestResults) - Bootstrap-phase activation-race commands (
_typescript.*, etc.)
§Lazy activation
If a command is not yet in the registry but a scanned extension declares
onCommand:<id> as an activation event, ExecuteCommand fires
$activateByEvent to Cocoon, yields 50 ms for the fire-and-forget
registerCommand notification to arrive, then retries the lookup.
§Backlog
- Contribution points from extensions; enablement/disable state
- Categories, grouping, aliases, deprecation
- History and undo/redo stack; keyboard shortcut resolution
- Permission validation; batching for related operations; telemetry
VS Code reference: vs/platform/commands/common/commands.ts,
vs/workbench/services/commands/common/commandService.ts.
Enums§
- Command
Handler - An enum representing the different ways a command can be handled.
Functions§
- Lookup
Command 🔒Contributing Extension - Return
truewhen some scanned extension declaresonCommand:<CommandIdentifier>as one of its activation events. Used by the lazy-activation fallback inExecuteCommand- without this check we’d fire an$activateByEvent("onCommand:X")for every unknown command, which would cause Cocoon to log “no extension matching event” for every typo. Scans the cached registry; no IPC.