Expand description
CLI extension registry, match, preexec, and expand (ADR-0022). CLI extension registry: load, merge, match, expand, and dispatch.
Extensions are an argv preprocessor inside the wyvern crate (ADR-0022).
They produce existing wyvern_schema::Command JSON only — no new host
dialog types. Phase E --interactive reuses this module; MCP tools consume
pre-expanded Command JSON.
§Examples
use std::path::Path;
use wyvern::extensions::{build_match_context, expand_and_validate, ExtensionRegistry};
let registry = ExtensionRegistry::load(Path::new("share/wyvern/extensions.json"), None)?;
let argv = vec!["doc.md".to_string()];
if let Some(matched) = registry.match_argv(&argv) {
let ctx = build_match_context(&matched, matched.extension());
let expanded = expand_and_validate(matched.extension(), &ctx)?;
assert_eq!(expanded.command["type"], "markdown");
}Structs§
- ArgName
- Declared
{arg:name}flag name (no leading dashes). - Binary
Name - Bare PATH binary name (non-empty, no path separators).
- Expand
Spec - Expand templates for command JSON and host overrides.
- Expanded
Invocation - Validated expansion ready for the existing host pipeline.
- Extension
Def - One registry entry after merge and
extendsresolution. - Extension
Id - Validated, non-empty extension identifier.
- Extension
IdError - Failure from
ExtensionId::try_from. - Extension
Registry - Merged,
extends-resolved extension registry. - Host
Expand Spec - Host template object (
ui_rootonly). - Host
Overrides - Host overrides produced by phase-2 expand (
ui_rootonly in Phase F). - Match
Context - Context collected from an
ExtensionMatchplus optional preexec outputs. - Match
Outcome - Result of walking the registry with skip diagnostics.
- Match
Spec - Match fields from the registry schema.
- Match
Token - Non-empty match token (suffix, filename, or argv prefix element).
- Path
Requires Probe - Default probe that searches
PATH(and WindowsPATHEXT). - Preexec
Spec - Preexec subprocess declaration.
- Script
Assets - Embedded
scripts/ext/**preexec helpers. - Script
Output - Successful wait outcome for
run_script. - Script
Request - Subprocess request shared by extension preexec and workflow hooks.
- Share
Assets - Embedded
share/wyvern/**assets (extensions.json, packaged UI extras). - Skill
Arg - One declared
{arg:name}/{arg:name:repeat}flag. - Skill
Record - One catalog / help record for a resolved extension (REQ-0132).
- Skill
Require - One
preexec.requiresbinary and its current PATH availability. - Skipped
Extension - Extension that would have matched argv but was skipped for
requires.
Enums§
- Extension
Error - Structured extension-engine failure.
- Extension
Match - Successful argv match against one extension.
- Extensions
CmdError - Failure from the
extensionsbuilt-in. - Near
Miss Kind - Why remainder argv did not match an extension (REQ-0136).
- Preexec
Failure Kind - Why a preexec subprocess failed.
- Script
Error - Failure from
run_script(spawn, timeout, wait, or stdout capture). - Skill
Source - Whether a catalog entry came from shipped defaults or a project file.
- Stdout
Capture - Stdout capture mode for
PreexecSpec. - Template
Error Kind - Why
ExtensionError::Templatefailed (RBP-F006).
Constants§
- SHIPPED_
EXTENSIONS_ JSON - Shipped defaults compiled into the binary (dev +
cargo install).
Traits§
- Requires
Probe - Probe used at match time for
preexec.requires.
Functions§
- binary_
on_ path - Return whether
nameresolves onPATH. - build_
match_ context - Build the initial match context (no preexec outputs yet).
- build_
skill_ record - Build a help-oriented
SkillRecordfrom a resolved extension. - build_
skill_ records - Build a
SkillRecordfor every merged extension, in registry order. - classify_
near_ miss - Classify a no-match remainder using the Phase G near-miss table.
- create_
tmpdir - Create a secure temp directory for
{tmpdir}. - emit_
near_ miss - Serialize a near-miss as the existing
StderrErrorenvelope. - expand_
and_ validate - Create tmpdir if needed, run preexec, expand, and validate.
- expand_
command_ host - Phase 2: expand
command/command_from_fileandhost. - expand_
preexec_ args - Phase 1: expand
preexec.cmdandpreexec.argsonly. - extensions_
usage_ message - Usage text for
wyvern extensions --help/-h. - find_
workspace_ root - Walk
startand parents looking forshare/wyvern/extensions.json. - format_
extensions_ list - Format each extension as a
format_skill_cardblock. - format_
skill_ card - Format one skill as the single help / list / show text card.
- infer_
wizard_ root - Walk from the file’s directory until
wizard.jsonorpages/is found. - is_
help_ only_ tokens - Returns whether every token is
--helpor-h(and at least one is present). - last_
created_ tmpdir - Path of the temp dir created by the last
expand_and_validateon this thread. - match_
extension_ help - Match an extension whose remaining tokens are only
--help/-h. - match_
kind_ summary - relpath_
from_ ui_ root {path}relative to{wizard_root}using/separators.- resolve_
wyvern_ share - Resolve
{wyvern_share}to a unified directory (dev workspace or embed). - resolve_
wyvern_ share_ with - Resolve
{wyvern_share}from injectable inputs (no process-global mutation). - run_
extensions_ command - Run
wyvern extensions …; returns stdout text on success. - run_
preexec - Runs the extension preexec command. On timeout the child is killed so a
piped stdout reader cannot keep buffering after the CLI has moved on.
See
WYVERN_PREEXEC_TIMEOUT_SECS. - run_
script - Spawn a subprocess with timeout, optional stdin, and stderr tail.
- skill_
help_ command - Recovery
--helpusing the invocation prefix, not the extension id.