Skip to main content

Command

Struct Command 

Source
pub struct Command { /* private fields */ }
Expand description

One slash-command palette entry completed by SlashCommands.

Implementations§

Source§

impl Command

Source

pub fn new(name: &str, description: &str, aliases: &[&str]) -> Self

Builds a palette entry from its name, blurb, and alias spellings.

Examples found in repository?
examples/chat/demo.rs (lines 136-140)
134pub fn demo_commands() -> Vec<Command> {
135	vec![
136		Command::new(
137			"security",
138			"Plan, run, inspect, import, and compare OMP-native security scans",
139			&[],
140		)
141		.with_args(&[
142			("plan", "Draft a scan plan for this workspace", "[focus]"),
143			("run", "Execute the current scan plan", ""),
144			("inspect", "Browse findings from the last scan", "[finding-id]"),
145			("import", "Import an external scan report", "<path>"),
146			("compare", "Diff two scan runs", "<run-a> <run-b>"),
147		])
148		.with_hint("plan|run|inspect|import|compare"),
149		Command::new("attach", "Stage an image attachment on the composer", &[]).with_hint("<path>"),
150		Command::new("settings", "Open settings menu", &[]),
151		Command::new("setup", "Open provider setup", &["providers"]).with_hint("[provider]"),
152		Command::new("plan", "Toggle plan mode (agent plans before executing)", &[]),
153		Command::new("plan-review", "Re-open the plan review for the latest plan", &[]),
154		Command::new("vibe", "Toggle persistent fast worker sessions", &[]),
155		Command::new("goal", "Toggle an autonomous objective for this session", &[])
156			.with_hint("<objective>"),
157		Command::new("guided-goal", "Interview you in chat, then set up goal mode", &[]),
158		Command::new("queue", "Queue a message for after the agent yields", &[]),
159		Command::new("switch", "Switch model for this session (same as alt+p)", &[]),
160		Command::new("fast", "Toggle priority service tier", &[]),
161		Command::new("computer", "Toggle the native computer-use tool", &[]),
162		Command::new("vision", "Control inspect_image vision delegation", &[]),
163		Command::new("prewalk", "Switch to a fast model at the next action", &[]),
164		Command::new("advisor", "Toggle the second-model advisor", &[]),
165		Command::new("export", "Export session to an HTML file", &[]),
166		Command::new("dump", "Copy the session transcript to clipboard", &[]),
167		Command::new("share", "Share session via an encrypted link", &[]),
168		Command::new("collab", "Share this session live via a relay", &[]),
169		Command::new("join", "Join a shared collab session", &[]),
170		Command::new("leave", "Leave the collab session", &[]),
171		Command::new("browser", "Toggle browser headless vs visible mode", &[]),
172		Command::new("copy", "Pick conversation text or code to copy", &[]),
173		Command::new("todo", "View or modify the agent's todo list", &[]),
174		Command::new("session", "Session management commands", &[]),
175		Command::new("jobs", "Show async background jobs status", &[]),
176		Command::new("usage", "Show provider usage and limits", &[]),
177		Command::new("stats", "Launch the local stats dashboard", &[]),
178		Command::new("changelog", "Show changelog entries", &[]),
179		Command::new("hotkeys", "Show all keyboard shortcuts", &[]),
180		Command::new("tools", "Show tools currently visible to the agent", &[]),
181		Command::new("context", "Show estimated context usage breakdown", &[]),
182		Command::new("agents", "Open Agent Control Center dashboard", &[]),
183		Command::new("branch", "Create a new branch from a previous message", &[]),
184		Command::new("fork", "Create a new fork from a previous message", &[]),
185		Command::new("tree", "Navigate the session tree", &[]),
186		Command::new("login", "Login with an OAuth provider", &[]),
187		Command::new("logout", "Logout from an OAuth provider", &[]),
188		Command::new("mcp", "Manage MCP servers", &[]),
189		Command::new("ssh", "Manage SSH hosts", &[]),
190		Command::new("new", "Start a new session", &[]),
191		Command::new("fresh", "Reset provider state without changing the transcript", &[]),
192		Command::new("clear", "Clear conversation context, keeping the session", &[]),
193		Command::new("drop", "Delete the current session and start a new one", &[]),
194		Command::new("compact", "Manually compact the session context", &[]),
195		Command::new("shake", "Drop heavy content from context", &[]),
196		Command::new("handoff", "Hand off context to a new session", &[]),
197		Command::new("resume", "Resume a different session", &[]),
198		Command::new("btw", "Ask an ephemeral side question", &[]),
199		Command::new("tan", "Run a background agent on tangential work", &[]),
200		Command::new("omfg", "Forge a rule from a recurring complaint", &[]),
201		Command::new("retry", "Retry the last failed agent turn", &[]),
202		Command::new("debug", "Open the debug tools selector", &[]),
203		Command::new("memory", "Inspect and operate memory maintenance", &[]),
204		Command::new("rename", "Rename the current session", &[]),
205		Command::new("move", "Move the session to a different directory", &[]),
206		Command::new("add-dir", "Add a workspace directory", &[]),
207		Command::new("remove-dir", "Remove a workspace directory", &[]),
208		Command::new("dirs", "List this session's workspace directories", &[]),
209		Command::new("marketplace", "Manage marketplace plugins", &[]),
210		Command::new("plugins", "View and manage installed plugins", &[]),
211		Command::new("reload-plugins", "Reload skills, commands, hooks, tools, and agents", &[]),
212		Command::new("force", "Force the next turn to use a specific tool", &["force:"]),
213		Command::new("live", "Start Codex-backed realtime voice mode", &[]),
214		Command::new("pause", "Freeze all agents until resumed", &[]),
215		Command::new("quit", "Quit the application", &["q"]),
216	]
217}
Source

pub fn with_args(self, args: &[(&str, &str, &str)]) -> Self

Argument candidates offered once the command name is complete: (name, description, usage), with "" usage meaning none. Usage text ghosts after the argument pi-style (<path>, <a> <b>).

Examples found in repository?
examples/chat/demo.rs (lines 141-147)
134pub fn demo_commands() -> Vec<Command> {
135	vec![
136		Command::new(
137			"security",
138			"Plan, run, inspect, import, and compare OMP-native security scans",
139			&[],
140		)
141		.with_args(&[
142			("plan", "Draft a scan plan for this workspace", "[focus]"),
143			("run", "Execute the current scan plan", ""),
144			("inspect", "Browse findings from the last scan", "[finding-id]"),
145			("import", "Import an external scan report", "<path>"),
146			("compare", "Diff two scan runs", "<run-a> <run-b>"),
147		])
148		.with_hint("plan|run|inspect|import|compare"),
149		Command::new("attach", "Stage an image attachment on the composer", &[]).with_hint("<path>"),
150		Command::new("settings", "Open settings menu", &[]),
151		Command::new("setup", "Open provider setup", &["providers"]).with_hint("[provider]"),
152		Command::new("plan", "Toggle plan mode (agent plans before executing)", &[]),
153		Command::new("plan-review", "Re-open the plan review for the latest plan", &[]),
154		Command::new("vibe", "Toggle persistent fast worker sessions", &[]),
155		Command::new("goal", "Toggle an autonomous objective for this session", &[])
156			.with_hint("<objective>"),
157		Command::new("guided-goal", "Interview you in chat, then set up goal mode", &[]),
158		Command::new("queue", "Queue a message for after the agent yields", &[]),
159		Command::new("switch", "Switch model for this session (same as alt+p)", &[]),
160		Command::new("fast", "Toggle priority service tier", &[]),
161		Command::new("computer", "Toggle the native computer-use tool", &[]),
162		Command::new("vision", "Control inspect_image vision delegation", &[]),
163		Command::new("prewalk", "Switch to a fast model at the next action", &[]),
164		Command::new("advisor", "Toggle the second-model advisor", &[]),
165		Command::new("export", "Export session to an HTML file", &[]),
166		Command::new("dump", "Copy the session transcript to clipboard", &[]),
167		Command::new("share", "Share session via an encrypted link", &[]),
168		Command::new("collab", "Share this session live via a relay", &[]),
169		Command::new("join", "Join a shared collab session", &[]),
170		Command::new("leave", "Leave the collab session", &[]),
171		Command::new("browser", "Toggle browser headless vs visible mode", &[]),
172		Command::new("copy", "Pick conversation text or code to copy", &[]),
173		Command::new("todo", "View or modify the agent's todo list", &[]),
174		Command::new("session", "Session management commands", &[]),
175		Command::new("jobs", "Show async background jobs status", &[]),
176		Command::new("usage", "Show provider usage and limits", &[]),
177		Command::new("stats", "Launch the local stats dashboard", &[]),
178		Command::new("changelog", "Show changelog entries", &[]),
179		Command::new("hotkeys", "Show all keyboard shortcuts", &[]),
180		Command::new("tools", "Show tools currently visible to the agent", &[]),
181		Command::new("context", "Show estimated context usage breakdown", &[]),
182		Command::new("agents", "Open Agent Control Center dashboard", &[]),
183		Command::new("branch", "Create a new branch from a previous message", &[]),
184		Command::new("fork", "Create a new fork from a previous message", &[]),
185		Command::new("tree", "Navigate the session tree", &[]),
186		Command::new("login", "Login with an OAuth provider", &[]),
187		Command::new("logout", "Logout from an OAuth provider", &[]),
188		Command::new("mcp", "Manage MCP servers", &[]),
189		Command::new("ssh", "Manage SSH hosts", &[]),
190		Command::new("new", "Start a new session", &[]),
191		Command::new("fresh", "Reset provider state without changing the transcript", &[]),
192		Command::new("clear", "Clear conversation context, keeping the session", &[]),
193		Command::new("drop", "Delete the current session and start a new one", &[]),
194		Command::new("compact", "Manually compact the session context", &[]),
195		Command::new("shake", "Drop heavy content from context", &[]),
196		Command::new("handoff", "Hand off context to a new session", &[]),
197		Command::new("resume", "Resume a different session", &[]),
198		Command::new("btw", "Ask an ephemeral side question", &[]),
199		Command::new("tan", "Run a background agent on tangential work", &[]),
200		Command::new("omfg", "Forge a rule from a recurring complaint", &[]),
201		Command::new("retry", "Retry the last failed agent turn", &[]),
202		Command::new("debug", "Open the debug tools selector", &[]),
203		Command::new("memory", "Inspect and operate memory maintenance", &[]),
204		Command::new("rename", "Rename the current session", &[]),
205		Command::new("move", "Move the session to a different directory", &[]),
206		Command::new("add-dir", "Add a workspace directory", &[]),
207		Command::new("remove-dir", "Remove a workspace directory", &[]),
208		Command::new("dirs", "List this session's workspace directories", &[]),
209		Command::new("marketplace", "Manage marketplace plugins", &[]),
210		Command::new("plugins", "View and manage installed plugins", &[]),
211		Command::new("reload-plugins", "Reload skills, commands, hooks, tools, and agents", &[]),
212		Command::new("force", "Force the next turn to use a specific tool", &["force:"]),
213		Command::new("live", "Start Codex-backed realtime voice mode", &[]),
214		Command::new("pause", "Freeze all agents until resumed", &[]),
215		Command::new("quit", "Quit the application", &["q"]),
216	]
217}
Source

pub fn with_hint(self, hint: &str) -> Self

Usage hint shown as dim ghost text after the cursor, pi-style (e.g. <name> [--scope project|user]).

Examples found in repository?
examples/chat/demo.rs (line 148)
134pub fn demo_commands() -> Vec<Command> {
135	vec![
136		Command::new(
137			"security",
138			"Plan, run, inspect, import, and compare OMP-native security scans",
139			&[],
140		)
141		.with_args(&[
142			("plan", "Draft a scan plan for this workspace", "[focus]"),
143			("run", "Execute the current scan plan", ""),
144			("inspect", "Browse findings from the last scan", "[finding-id]"),
145			("import", "Import an external scan report", "<path>"),
146			("compare", "Diff two scan runs", "<run-a> <run-b>"),
147		])
148		.with_hint("plan|run|inspect|import|compare"),
149		Command::new("attach", "Stage an image attachment on the composer", &[]).with_hint("<path>"),
150		Command::new("settings", "Open settings menu", &[]),
151		Command::new("setup", "Open provider setup", &["providers"]).with_hint("[provider]"),
152		Command::new("plan", "Toggle plan mode (agent plans before executing)", &[]),
153		Command::new("plan-review", "Re-open the plan review for the latest plan", &[]),
154		Command::new("vibe", "Toggle persistent fast worker sessions", &[]),
155		Command::new("goal", "Toggle an autonomous objective for this session", &[])
156			.with_hint("<objective>"),
157		Command::new("guided-goal", "Interview you in chat, then set up goal mode", &[]),
158		Command::new("queue", "Queue a message for after the agent yields", &[]),
159		Command::new("switch", "Switch model for this session (same as alt+p)", &[]),
160		Command::new("fast", "Toggle priority service tier", &[]),
161		Command::new("computer", "Toggle the native computer-use tool", &[]),
162		Command::new("vision", "Control inspect_image vision delegation", &[]),
163		Command::new("prewalk", "Switch to a fast model at the next action", &[]),
164		Command::new("advisor", "Toggle the second-model advisor", &[]),
165		Command::new("export", "Export session to an HTML file", &[]),
166		Command::new("dump", "Copy the session transcript to clipboard", &[]),
167		Command::new("share", "Share session via an encrypted link", &[]),
168		Command::new("collab", "Share this session live via a relay", &[]),
169		Command::new("join", "Join a shared collab session", &[]),
170		Command::new("leave", "Leave the collab session", &[]),
171		Command::new("browser", "Toggle browser headless vs visible mode", &[]),
172		Command::new("copy", "Pick conversation text or code to copy", &[]),
173		Command::new("todo", "View or modify the agent's todo list", &[]),
174		Command::new("session", "Session management commands", &[]),
175		Command::new("jobs", "Show async background jobs status", &[]),
176		Command::new("usage", "Show provider usage and limits", &[]),
177		Command::new("stats", "Launch the local stats dashboard", &[]),
178		Command::new("changelog", "Show changelog entries", &[]),
179		Command::new("hotkeys", "Show all keyboard shortcuts", &[]),
180		Command::new("tools", "Show tools currently visible to the agent", &[]),
181		Command::new("context", "Show estimated context usage breakdown", &[]),
182		Command::new("agents", "Open Agent Control Center dashboard", &[]),
183		Command::new("branch", "Create a new branch from a previous message", &[]),
184		Command::new("fork", "Create a new fork from a previous message", &[]),
185		Command::new("tree", "Navigate the session tree", &[]),
186		Command::new("login", "Login with an OAuth provider", &[]),
187		Command::new("logout", "Logout from an OAuth provider", &[]),
188		Command::new("mcp", "Manage MCP servers", &[]),
189		Command::new("ssh", "Manage SSH hosts", &[]),
190		Command::new("new", "Start a new session", &[]),
191		Command::new("fresh", "Reset provider state without changing the transcript", &[]),
192		Command::new("clear", "Clear conversation context, keeping the session", &[]),
193		Command::new("drop", "Delete the current session and start a new one", &[]),
194		Command::new("compact", "Manually compact the session context", &[]),
195		Command::new("shake", "Drop heavy content from context", &[]),
196		Command::new("handoff", "Hand off context to a new session", &[]),
197		Command::new("resume", "Resume a different session", &[]),
198		Command::new("btw", "Ask an ephemeral side question", &[]),
199		Command::new("tan", "Run a background agent on tangential work", &[]),
200		Command::new("omfg", "Forge a rule from a recurring complaint", &[]),
201		Command::new("retry", "Retry the last failed agent turn", &[]),
202		Command::new("debug", "Open the debug tools selector", &[]),
203		Command::new("memory", "Inspect and operate memory maintenance", &[]),
204		Command::new("rename", "Rename the current session", &[]),
205		Command::new("move", "Move the session to a different directory", &[]),
206		Command::new("add-dir", "Add a workspace directory", &[]),
207		Command::new("remove-dir", "Remove a workspace directory", &[]),
208		Command::new("dirs", "List this session's workspace directories", &[]),
209		Command::new("marketplace", "Manage marketplace plugins", &[]),
210		Command::new("plugins", "View and manage installed plugins", &[]),
211		Command::new("reload-plugins", "Reload skills, commands, hooks, tools, and agents", &[]),
212		Command::new("force", "Force the next turn to use a specific tool", &["force:"]),
213		Command::new("live", "Start Codex-backed realtime voice mode", &[]),
214		Command::new("pause", "Freeze all agents until resumed", &[]),
215		Command::new("quit", "Quit the application", &["q"]),
216	]
217}
Source

pub fn name(&self) -> &str

The command’s primary spelling, without the leading /.

Examples found in repository?
examples/chat/commands.rs (line 194)
177fn entries() -> Vec<EntrySpec> {
178	let commands = demo_commands();
179	let mut list = Vec::with_capacity(commands.len() + 3);
180	list.push(EntrySpec::action(
181		SWITCH_MODEL,
182		"Switch Model",
183		"Pick the model for this session",
184		"ctrl+p",
185	));
186	list.push(EntrySpec::action(
187		TOGGLE_SIDEBAR,
188		"Toggle Sidebar",
189		"Show or hide the session rail",
190		"ctrl+b",
191	));
192	list.push(EntrySpec::action(QUIT, "Quit", "Exit the demo", "ctrl+c"));
193	list.extend(commands.iter().map(|command| {
194		let name = fmts!("/{}", command.name());
195		EntrySpec {
196			value: name.clone(),
197			label: name.clone(),
198			name,
199			name_fg: CYAN,
200			detail: Str::from(command.description()),
201			key: Str::default(),
202		}
203	}));
204	list
205}
Source

pub fn description(&self) -> &str

The one-line blurb shown beside the command name.

Examples found in repository?
examples/chat/commands.rs (line 200)
177fn entries() -> Vec<EntrySpec> {
178	let commands = demo_commands();
179	let mut list = Vec::with_capacity(commands.len() + 3);
180	list.push(EntrySpec::action(
181		SWITCH_MODEL,
182		"Switch Model",
183		"Pick the model for this session",
184		"ctrl+p",
185	));
186	list.push(EntrySpec::action(
187		TOGGLE_SIDEBAR,
188		"Toggle Sidebar",
189		"Show or hide the session rail",
190		"ctrl+b",
191	));
192	list.push(EntrySpec::action(QUIT, "Quit", "Exit the demo", "ctrl+c"));
193	list.extend(commands.iter().map(|command| {
194		let name = fmts!("/{}", command.name());
195		EntrySpec {
196			value: name.clone(),
197			label: name.clone(),
198			name,
199			name_fg: CYAN,
200			detail: Str::from(command.description()),
201			key: Str::default(),
202		}
203	}));
204	list
205}

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.