feat(alias): user-level shorthand names for module sources#37
Open
rickliujh wants to merge 1 commit into
Open
Conversation
An alias maps a short name to a module source plus default parameters, so `loom run git@github.com:foo/bar.git -p foo=bar` becomes `loom :bar`. A leading ":" marks an alias reference. Because the sigil makes the alias namespace disjoint from the subcommand namespace, `loom :bar` can dispatch to run without any bare name shadowing a subcommand — an unknown subcommand still gets cobra's usual "unknown command" error and suggestions. Top-level dispatch is an argv rewrite (`loom :bar` -> `loom run :bar`) rather than a root-level handler, so the alias form inherits the whole `loom run` flag set instead of having to redeclare it. Aliases are user-level only: one file at $LOOM_CONFIG_DIR/aliases.yaml (else <user config dir>/loom/aliases.yaml), with no repo-local file and no upward search, so changing branch or directory can never change what an alias resolves to. Resolution happens at the CLI boundary only — module.ResolveSource stays alias-blind so spec.modules[].source cannot depend on the operator's local aliases, keeping modules portable. Alias params are the lowest-precedence source, beneath --params-file and -p. Adds `loom alias add|list|remove` and specs/alias.md (AL1-AL13) with covering tests. `loom validate` and `loom bulk` deliberately do not accept references: neither consumes alias params, and bulk embeds its source into generated modules where a reference would violate AL8. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shortens long invocations. Instead of:
you get:
An alias maps a short name to a module source plus a set of default parameters.
Design notes
A leading
:marks a reference. The sigil makes the alias namespace disjoint from the subcommand namespace, which is what letsloom :bardispatch at top level: no bare name can shadow a subcommand, so a typo likeloom rnustill gets cobra's usualunknown commanderror and "Did you mean: run" suggestion.Top-level dispatch is an argv rewrite (
loom :bar …→loom run :bar …), not a root-level handler. A root handler was tried first and fails withunknown shorthand flag: 'p'— the run flags live onrunCmd, so root dispatch would have to redeclare every one of them. The rewrite inherits the whole flag set for free.Aliases are user-level only. One file at
$LOOM_CONFIG_DIR/aliases.yaml, else<user config dir>/loom/aliases.yaml. No repo-local file and no upward search, so changing branch or directory can never change what an alias resolves to.Aliases are never module configuration. Resolution happens at the CLI boundary;
module.ResolveSourcestays alias-blind, sospec.modules[].sourcecannot depend on whichever aliases an operator happens to have defined. Modules stay portable.Alias params are the lowest-precedence source, beneath
--params-fileand-p. Modulespec.paramsdefaults still apply beneath all three.Unknown aliases don't fall through to the git-URL path, so a mistyped alias reports a mistyped alias rather than a failed clone.
Scope
loom runandloom diffaccept:<name>.loom validateandloom bulkdeliberately do not: neither consumes alias params,validateresolves no remote sources at all today, andbulkembeds the source it is given into the module it generates — where a reference would resolve for nobody else. Extending them is additive.Single-segment names only. The alias file is a flat
map[name]Def, so multi-segment names (loom :svc onboard) remain a lookup-loop change rather than a schema change.Testing
specs/alias.mddefines AL1–AL13; spectrace passes, so every rule has a covering test.go build,go vet,go test ./...).loom :barrenders the templated output;-poverrides the alias param;loom :typoreportsunknown alias "typo" (looked in …)with no clone attempt;loom :errors on the empty name;loom rnustill reports an unknown command;loom diff :barpreviews.gofmtflags only files that were already unformatted on main (pkg/generate,pkg/action,pkg/llm); none touched here.🤖 Generated with Claude Code