feat(cli): codemap rename alias for homonym-safe renames#166
Conversation
`define_in` on rename-preview shipped in #165; this adds the thin `codemap rename` → `apply rename-preview` alias with positional ergonomics and plan doc for the scoped-rename slice.
🦋 Changeset detectedLatest commit: 7b0ce69 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis PR implements ChangesCodemap rename CLI alias
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/rename-alias.ts`:
- Around line 32-36: When handling the case where a === "--params" inside the
loop over tail (using variables tail and i and constant RENAME_RECIPE_ID), do
not inject an empty string as a fabricated operand; instead preserve the flag as
missing so the downstream apply parsing hits the real missing-argument error
path. Concretely, change the branch that currently returns ["apply",
RENAME_RECIPE_ID, "--params", ""] to return the flag without a value (e.g.
["apply", RENAME_RECIPE_ID, "--params"]) so the parser sees a true missing
operand for "--params".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 39d6a414-2e23-44a4-b6d3-b08bd89fc60d
📒 Files selected for processing (10)
README.mddocs/architecture.mddocs/plans/scoped-rename-define-in.mddocs/roadmap.mddocs/testing-coverage.mdsrc/cli/bootstrap.tssrc/cli/cmd-apply.test.tssrc/cli/main.tssrc/cli/rename-alias.test.tssrc/cli/rename-alias.ts
Align with --define-in/--in-file/--kind: pass bare --params through so
apply reports the real missing-argument error instead of accepting {}.
Return rename-local errors for missing scoped-flag operands, extract old/new regardless of apply-flag order, reject stray positionals, and align README/roadmap/architecture/skill with the shipped alias.
Support equals-form scoped flags, reject partial old/new at the alias layer, add changeset and glossary/rule coverage, delete shipped plan.
Report unexpected positionals when old/new are already bound via --params; align glossary shorthand with full rename flag surface.
Only early-return bare --params when it is the sole rename arg; otherwise keep merged params, positionals, and apply flags. Delegate incomplete old/new to apply when applyTail still carries --params.
Mirror query/apply parser guard: when --params is not followed by a value token, treat it as bare trailing --params instead of parsing the next flag as k=v input.
When old/new are already serialized, drop no-op trailing --params tokens so apply argv stays parseable (e.g. before --dry-run).
Align --define-in, --in-file, and --kind with --params: a following flag is not a valid operand value.
Treat --params followed by apply flags as bare passthrough, whitelist apply flags in splitPassthrough so symbol names like --help stay positional, and only show rename help when it is the sole argument.
Rename alias and apply parser no longer pair value-taking apply flags with a following flag, so `rename a b --commit --dry-run` preserves dry-run semantics end-to-end.
Replace dogfood bench fixture paths in README and rename --help with consumer-facing placeholder paths.
Summary
codemap rename— thin CLI alias →apply rename-preview(Moat A: no new write semantics; same policy gates asapply).codemap rename <old> <new> [--define-in <file_path>] [--in-file <prefix>] [--kind <k>] [apply flags…]--define-in/--in-file/--kind(space or=form) → recipeparams; apply flags pass through unchanged..changeset/rename-alias-cli.md(patch).Closes the roadmap gap left after homonym
define_inshipped in #165.Implementation
src/cli/rename-alias.ts—resolveRenameAlias,formatParamsCli,printRenameAliasHelpsrc/cli/main.ts— rewrite beforeapply; rename-local errors exit 1src/cli/rename-alias.test.ts(29 unit),src/cli/cmd-apply.test.ts(homonym e2e + parse-error e2e)Not in scope (by design): no MCP
renametool — agents useapply+define_ininparams.Review hardening (cycles 1–12)
Multi-agent review loop addressed parser edge cases:
--params/ scoped-flag operands → rename-local or apply-delegated errors<old> <new>; equals-form scoped flags (--params=,--commit=)--params(preserve state, strip when redundant, reject flag-as-operand)old/new; scoped flags followed by flagsrename --help); symbol names like--helpstay positional--commit/--max-passesno longer pair with a following apply flag (rename +parseApplyRest)Cycle 12 verdict: CLEAN (61 tests pass; docs/consumer + Moat A + cross-refs).
Usage
Test plan
bun test src/cli/rename-alias.test.ts(29 cases)bun test src/cli/cmd-apply.test.ts— homonym scoped apply +codemap renamee2e + parse-error e2ece8ddd4