feat: Custom command aliases via [aliases] TOML config (F2.2) #25
Notifications
Due Date
No due date set.
Depends on
#4 feat: Wire ForgivingParser into REPL command dispatch
terraphim/agent-tasks
Reference: terraphim/agent-tasks#25
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Spec F2.2 (terraphim-agent-session-search-spec.md, lines 167-184) requires both built-in AND user-defined custom command aliases:
Built-in aliases ship today via
DEFAULT_ALIASESincrates/terraphim_agent/src/forgiving/aliases.rs:8, and #4 wiresForgivingParserinto REPL dispatch. But there is no path to load the[aliases]TOML section intoAliasRegistry.AliasRegistry::add()exists but no caller ever populates it from config, so users cannot definess = "sessions search"-- the headline F2.2 example.This blocks the "make CLI usable by AI agents and power users" goal (G2). Custom aliases also enable multi-token expansions (
ss->sessions search) that the currentexpand()only partially supports (it returns&strfor a single token; multi-word aliases need different handling).Acceptance Criteria
AliasConfiginterraphim_agent/src/forgiving/aliases.rs:AliasRegistry::load_from_toml(path: &Path) -> Result<Self, AliasError>that:[aliases]tableDEFAULT_ALIASES, merges user values (user wins on conflict)/); rejects withAliasError::InvalidKey { alias, reason }"sessions search", the parser must split into["sessions", "search", ...rest_of_args]; updateForgivingParser::expand_aliasaccordingly with a unit test for/ss "auth"->sessions search "auth"<terraphim_data_dir>/agent.tomlif present; absence is non-fatal (DEFAULT_ALIASES still load). Document the path in module-level rustdoc.log::info!("alias override: {} (default '{}' -> user '{}')", k, default_v, user_v)AliasErrorenum withthiserror:Io,TomlParse,InvalidKey,InvalidValueAliasRegistry::load_from_tomlinto REPL startup (ReplHandler::newor builder), behind atry_loadthat falls back toAliasRegistry::new()on any error with a warn-level logcapabilitiesoutput exposes the loaded alias count:"alias_count": 17cargo test -p terraphim_agent --lib forgiving::aliases::testspassescargo clippy -p terraphim_agent -- -D warningspassesProposed Approach
terraphim_agent(forgiving/aliases.rs,forgiving/parser.rs,repl/handler.rs,robot/docs.rs)tomlandserdedeps -- no new cratesexpand_aliasreturnsOption<Vec<String>>(tokens) instead ofOption<&str>to support multi-word; old single-word callers wrap with.first()Dependencies
None as a hard blocker. Lands cleanest after #4 (ForgivingParser into REPL dispatch); without #4 the multi-token expansion won't be observable from the REPL but the loader and unit tests still verify behaviour. Recommend implementation-swarm picks this after #4.
Verification
Scope
Single PR, ~250-320 lines (loader ~80, parser tweak ~40, error type ~20, REPL wiring ~30, robot capabilities ~10, tests ~100). Closes spec F2.2 fully alongside #4.