feat(vendor): add rename command for deployed item names
- Add `vendor rename <source> [upstream-id=name ...] [--reset ids]` to change deployed names after `vendor add`, without moving the pinned rev or selection - Persist renames in the lockfile so they survive `vendor update` and `vendor select` - Rewrite SKILL.md frontmatter `name:` to the folder name so OpenCode loads renamed skills - Validate rename targets: single path segment, no leading dot, and OpenCode skill naming rules for skills - Re-run collision checks before writing; failed renames leave lockfile and external area untouched - Add unit tests for frontmatter rewrite and name validation, plus e2e rename coverage - Document renames in README; sync beads issue export
This commit is contained in:
1 parent
f37c3dce5e
commit
d6821c6d7c
11 files changed
+472
-2
No files matched your search
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
package vendor
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSetFrontmatterName(t *testing.T) {
|
||||
cases := []struct{ name, in, want string }{
|
||||
{"replace", "---\nname: Good Skill\ndescription: d\n---\nbody\n", "---\nname: ideen\ndescription: d\n---\nbody\n"},
|
||||
{"crlf", "---\r\nname: x\r\n---\r\nb", "---\r\nname: ideen\r\n---\r\nb"},
|
||||
{"insert", "---\ndescription: d\n---\n", "---\nname: ideen\ndescription: d\n---\n"},
|
||||
{"no frontmatter", "# Title\n", "---\nname: ideen\n---\n# Title\n"},
|
||||
{"nested name untouched", "---\nmeta:\n name: inner\n---\n", "---\nname: ideen\nmeta:\n name: inner\n---\n"},
|
||||
{"name in body untouched", "---\ndescription: d\n---\nname: body\n", "---\nname: ideen\ndescription: d\n---\nname: body\n"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := setFrontmatterName(c.in, "ideen"); got != c.want {
|
||||
t.Errorf("%s:\n got %q\nwant %q", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRenameTarget(t *testing.T) {
|
||||
ok := []struct{ typ, dep string }{
|
||||
{"skills", "code-review"}, {"skills", "a1"}, {"commands", "Review_Things"},
|
||||
}
|
||||
for _, c := range ok {
|
||||
if err := validateRenameTarget(c.typ, "up", c.dep); err != nil {
|
||||
t.Errorf("%s %q should be valid: %v", c.typ, c.dep, err)
|
||||
}
|
||||
}
|
||||
bad := []struct{ typ, dep string }{
|
||||
{"skills", "Code Review"}, {"skills", "code--review"}, {"skills", "-x"}, {"skills", "Gross"},
|
||||
{"commands", "../x"}, {"agents", "a/b"}, {"commands", ".hidden"}, {"skills", ""},
|
||||
}
|
||||
for _, c := range bad {
|
||||
if err := validateRenameTarget(c.typ, "up", c.dep); err == nil {
|
||||
t.Errorf("%s %q should be rejected", c.typ, c.dep)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user