CommandBuilder
Configures metadata and behavior for a mapped command.
- Kind:
Class - Namespace: Repl
- Assembly:
Repl.Core - Source: src/Repl.Core/CommandBuilder.cs
Signature
Section titled “Signature”public sealed class CommandBuilderInheritance
Section titled “Inheritance”Methods
Section titled “Methods”AsPrompt()
Section titled “AsPrompt()”Marks this command as a prompt source. The handler return value becomes the prompt message template. Handler parameters become prompt arguments.
public CommandBuilder AsPrompt()Returns
Section titled “Returns”CommandBuilder - The same builder instance.
AsProtocolPassthrough()
Section titled “AsProtocolPassthrough()”Marks this command as protocol passthrough. In this mode, repl diagnostics are routed to stderr and interactive stdin reads are skipped. When handlers request IReplIoContext, Output remains the protocol stream (stdout in local CLI passthrough), while framework output stays on stderr. For hosted sessions, handlers should request IReplIoContext to access transport streams explicitly.
public CommandBuilder AsProtocolPassthrough()Returns
Section titled “Returns”CommandBuilder - The same builder instance.
AsResource()
Section titled “AsResource()”Marks this command as a resource (data to consult, not an operation to perform). Resources appear in a separate help section and are auto-exposed as MCP resources.
public CommandBuilder AsResource()Returns
Section titled “Returns”CommandBuilder - The same builder instance.
AutomationHidden(bool)
Section titled “AutomationHidden(bool)”Hides the command from programmatic/automation surfaces only.
public CommandBuilder AutomationHidden(bool value = true)Parameters
Section titled “Parameters”value(bool): True to hide from automation.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
Destructive(bool)
Section titled “Destructive(bool)”Marks the command as destructive (deletes, modifies state).
public CommandBuilder Destructive(bool value = true)Parameters
Section titled “Parameters”value(bool): True to mark as destructive.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
Hidden(bool)
Section titled “Hidden(bool)”Marks a command as hidden or visible.
public CommandBuilder Hidden(bool isHidden = true)Parameters
Section titled “Parameters”isHidden(bool): True to hide the command.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
Idempotent(bool)
Section titled “Idempotent(bool)”Marks the command as safely retriable.
public CommandBuilder Idempotent(bool value = true)Parameters
Section titled “Parameters”value(bool): True to mark as idempotent.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
LongRunning(bool)
Section titled “LongRunning(bool)”Marks the command as long-running (enables task-based execution).
public CommandBuilder LongRunning(bool value = true)Parameters
Section titled “Parameters”value(bool): True to mark as long-running.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
OpenWorld(bool)
Section titled “OpenWorld(bool)”Marks the command as interacting with external systems.
public CommandBuilder OpenWorld(bool value = true)Parameters
Section titled “Parameters”value(bool): True to mark as open-world.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
ReadOnly(bool)
Section titled “ReadOnly(bool)”Marks the command as read-only (no side effects).
public CommandBuilder ReadOnly(bool value = true)Parameters
Section titled “Parameters”value(bool): True to mark as read-only.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithAlias(params string[])
Section titled “WithAlias(params string[])”Sets aliases for the command.
public CommandBuilder WithAlias(params string[] aliases)Parameters
Section titled “Parameters”aliases(string[]): Alias list.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithAnnotations(Action<CommandAnnotationsBuilder>)
Section titled “WithAnnotations(Action<CommandAnnotationsBuilder>)”Configures annotations via builder — escape hatch for complex scenarios. Overwrites any annotations set by individual shortcuts.
public CommandBuilder WithAnnotations(Action<CommandAnnotationsBuilder> configure)Parameters
Section titled “Parameters”configure(Action<CommandAnnotationsBuilder>): Builder configuration callback.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithAnswer(string, string, string?)
Section titled “WithAnswer(string, string, string?)”Declares an interactive answer slot that can be pre-filled via --answer:{name}=value
on the CLI or answer:{name} in MCP tool calls.
public CommandBuilder WithAnswer(string name, string type = "string", string? description = null)Parameters
Section titled “Parameters”name(string): Answer name (matches thenameparameter inAskConfirmationAsync,AskChoiceAsync, etc.).type(string): Value type using route constraint names:string,bool,int,guid,email, etc.description(string): Optional description for help text and agent tool schemas.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithBanner(Delegate)
Section titled “WithBanner(Delegate)”Registers a banner delegate displayed before command execution. Unlike WithDescription(string), which is structural metadata visible in help and documentation, banners are display-only messages that appear at runtime.
public CommandBuilder WithBanner(Delegate bannerProvider)Parameters
Section titled “Parameters”bannerProvider(Delegate): Banner delegate with injectable parameters.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithBanner(string)
Section titled “WithBanner(string)”Registers a static banner string displayed before command execution. Unlike WithDescription(string), which is structural metadata visible in help and documentation, banners are display-only messages that appear at runtime.
public CommandBuilder WithBanner(string text)Parameters
Section titled “Parameters”text(string): Banner text.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithCompletion(string, CompletionDelegate)
Section titled “WithCompletion(string, CompletionDelegate)”Adds a completion provider for a target parameter.
public CommandBuilder WithCompletion(string targetName, CompletionDelegate provider)Parameters
Section titled “Parameters”targetName(string): Route or option target name.provider(CompletionDelegate): Completion delegate.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithDescription(string)
Section titled “WithDescription(string)”Sets a command description.
public CommandBuilder WithDescription(string text)Parameters
Section titled “Parameters”text(string): Description text.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithDetails(string)
Section titled “WithDetails(string)”Sets a rich markdown description body for agent tool descriptions and documentation export.
public CommandBuilder WithDetails(string markdown)Parameters
Section titled “Parameters”markdown(string): Markdown content.
Returns
Section titled “Returns”CommandBuilder - The same builder instance.
WithMetadata(string, object)
Section titled “WithMetadata(string, object)”Adds a generic metadata entry.
public CommandBuilder WithMetadata(string key, object value)Parameters
Section titled “Parameters”Returns
Section titled “Returns”CommandBuilder - The same builder instance.
Properties
Section titled “Properties”Aliases
Section titled “Aliases”Gets the configured aliases.
public IReadOnlyList<string> Aliases { get; }Returns
Section titled “Returns”IReadOnlyList<string>
Annotations
Section titled “Annotations”Gets the structured behavioral annotations for this command.
public CommandAnnotations? Annotations { get; }Returns
Section titled “Returns”Answers
Section titled “Answers”Gets declared answer slots for interactive prompts.
public IReadOnlyList<AnswerDeclaration> Answers { get; }Returns
Section titled “Returns”IReadOnlyList<AnswerDeclaration>
Banner
Section titled “Banner”Gets the banner delegate rendered before command execution.
public Delegate? Banner { get; }Returns
Section titled “Returns”Completions
Section titled “Completions”Gets parameter completion providers keyed by target name.
public IReadOnlyDictionary<string, CompletionDelegate> Completions { get; }Returns
Section titled “Returns”IReadOnlyDictionary<string, CompletionDelegate>
Description
Section titled “Description”Gets the command description.
public string? Description { get; }Returns
Section titled “Returns”Details
Section titled “Details”Gets the rich markdown description body. Used for agent tool descriptions and documentation export.
public string? Details { get; }Returns
Section titled “Returns”Handler
Section titled “Handler”Gets the command handler.
public Delegate Handler { get; }Returns
Section titled “Returns”IsHidden
Section titled “IsHidden”Gets a value indicating whether this command is hidden from discovery surfaces.
public bool IsHidden { get; }Returns
Section titled “Returns”IsPrompt
Section titled “IsPrompt”Gets a value indicating whether this command is a prompt source.
public bool IsPrompt { get; }Returns
Section titled “Returns”IsProtocolPassthrough
Section titled “IsProtocolPassthrough”Gets a value indicating whether this command reserves stdin/stdout for a protocol handler.
public bool IsProtocolPassthrough { get; }Returns
Section titled “Returns”IsResource
Section titled “IsResource”Gets a value indicating whether this command is a resource (data to consult).
public bool IsResource { get; }Returns
Section titled “Returns”Metadata
Section titled “Metadata”Gets generic metadata entries for extensibility.
public IReadOnlyDictionary<string, object> Metadata { get; }Returns
Section titled “Returns”IReadOnlyDictionary<string, object>
Gets the command route.
public string Route { get; }