AiCommand class

The :ai $prompt local command: drives a provider-agnostic AI agent that investigates the node, plans and executes commands to accomplish a natural-language goal, with command_shield gating every command.

Browser-safe: the provider, shield and config are injected, and all node interaction goes through LocalCommandContext / AgentCommandRunner. The native CLI wires it up via addAiCommand() (see ai_commands_native.dart).

Usage:

  • :ai <prompt> — run the agent in the current mode.
  • :ai mode <standard|plan|auto> — change the default mode for this session.
  • :ai --standard|--plan|--auto <prompt> — one-shot mode override.
  • :ai status — show provider, model and mode.
Inheritance

Constructors

AiCommand({required AiConfig config, required AiProvider provider, required CommandShield shield, AgentStyle style = const AgentStyle(), void onModeChanged(AgentMode mode)?, void onLanguageChanged(String? language)?})

Properties

aliases List<String>
Aliases that also invoke this command.
no setterinherited
description String
A one-line description shown by :help.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
name String
The command name (without the leading :).
no setteroverride
onLanguageChanged → void Function(String? language)?
Persists a reply-language change. null keeps it in-memory only.
final
onModeChanged → void Function(AgentMode mode)?
Persists a mode change (e.g. to ai.yaml). null keeps it in-memory only.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
usage String?
Optional multi-line usage/help text shown under the listing by :help.
no setteroverride

Methods

dispose() Future<void>
Releases any resources the command holds (e.g. an HTTP client / open sockets), so they do not keep the process alive after the session ends. Called by LocalCommandRegistry.dispose; the default is a no-op.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(LocalCommandContext context, List<String> args) Future<void>
Runs the command with parsed args.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited