feat: surface macros as first-class custom commands in the REPL
Implements the invocation and management surfaces from plans/custom-commands-design.md §4 and §6: - Top-level dispatch: an enabled macro <name> now runs as ".<name> [args]" from the command catch-all; runtime-disabled macros point at ".macro enable <name>", locked macros name the owning config, and unknown commands keep the existing error verbatim - .macro enable|disable <name>: runtime toggles over the in-memory global-level enabled_macros list (disable with no list materializes all-active-minus-name); toggles error when a role/agent/session allowlist owns the field - .set enabled_macros <csv|null> with workspace-then-global existence validation; .set key completion gains enabled_macros and the previously missing enabled_skills - Dynamic completion: enabled macros (with descriptions) join built-ins on ".<TAB>" without touching the static command registry; ".macro <TAB>" lists invocable macros (incl. built-in-shadowed ones) plus the enable/disable subcommands; second-arg completion offers toggle-eligible names - .list macros: enriched table (name, source, isolated, state, description) covering every resolver state incl. missing and shadowed rows; .help gains a custom-commands section - Session info/render and sysinfo display enabled_macros; Macro::load resolves workspace-then-global; enable/disable rejected as macro names in the creator
This commit is contained in:
@@ -82,7 +82,12 @@ pub struct Macro {
|
||||
|
||||
impl Macro {
|
||||
pub fn load(name: &str) -> Result<Macro> {
|
||||
let path = paths::macro_file(name);
|
||||
let workspace_path = paths::workspace_macros_dir().join(format!("{name}.yaml"));
|
||||
let path = if workspace_path.exists() {
|
||||
workspace_path
|
||||
} else {
|
||||
paths::macro_file(name)
|
||||
};
|
||||
let err = || format!("Failed to load macro '{name}' at '{}'", path.display());
|
||||
let content = read_to_string(&path).with_context(err)?;
|
||||
let value: Macro = serde_yaml::from_str(&content).with_context(err)?;
|
||||
|
||||
Reference in New Issue
Block a user