Commands

The developer-facing entry point for triggering edits.

Input — produces intents for the pipeline

A command is an intent factory. A command's handler runs against a CommandContext and returns an Intent (or null to no-op).

Contract

interface Command {
  readonly id: CommandId;
  readonly handlerId?: CommandHandlerId;
  readonly meta?: CommandMeta;
  run(context: CommandContext, args?: JsonValue): CommandResult;
}

type CommandResult = Intent | null;

Commands are registered via createCommandRegistry() and extendCommandRegistry(...) from packages/core/src/command.ts. Core ships createEditingCommands() for the built-in editing surface and createHistoryCommands() for undo/redo.

Invoking

Invoke a command through the registry or through engine.dispatchCommand(...). Most commands return an intent, and the engine dispatches that intent through the normal pipeline. History commands are the exception: they use the undo / redo callbacks on CommandContext, then return null because the history operation is already engine-owned.

Custom commands

Plugins may contribute commands through the plugin capability graph (PluginCommand). resolvePlugins resolves declared commands once at initialization.