From a6698cbb126d61f0e37ed61aefd8c13f2853fc1c Mon Sep 17 00:00:00 2001 From: LangerSword Date: Sun, 22 Nov 2026 00:33:32 +0530 Subject: [PATCH] Stamp bare semver into the plugin manifest (fixes #5) --- internal/setup/user_skills.go | 8 +++++++- internal/setup/user_skills_test.go | 31 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/internal/setup/user_skills.go b/internal/setup/user_skills.go index 61e0ff9..85b8064 100644 --- a/internal/setup/user_skills.go +++ b/internal/setup/user_skills.go @@ -438,7 +438,13 @@ func buildUserCandidates(opts UserInstallOptions) []userCandidate { for _, client := range normalizeUserClients(opts.Clients) { root := userClientRoot(client) for _, asset := range skills.Native(nativeAssetClient(client)) { - content := strings.ReplaceAll(asset.Content, userVersionToken, opts.Version) + // The Agent Plugins 1.0 schema requires bare semver: a + // v-prefixed version invalidates the whole manifest. The + // build stamps Version from a v-prefixed git tag, so the + // v is dropped here. Status, plan, and update surfaces + // keep the v-prefixed form and are unchanged. + assetVersion := strings.TrimPrefix(opts.Version, "v") + content := strings.ReplaceAll(asset.Content, userVersionToken, assetVersion) out = append(out, userCandidate{ client: client, assetID: client + ":" + asset.Path, diff --git a/internal/setup/user_skills_test.go b/internal/setup/user_skills_test.go index 7457579..d9b685e 100644 --- a/internal/setup/user_skills_test.go +++ b/internal/setup/user_skills_test.go @@ -271,6 +271,8 @@ func TestUserSkillPlanPreviewOrderingIsStable(t *testing.T) { // TestUserSkillPlanFirstInstallChecksums proves a first install produces install // actions whose checksums equal the exact bytes that would be written. +// TestUserSkillPlanFirstInstallChecksums proves a fresh install reports every +// asset with the expected checksum. func TestUserSkillPlanFirstInstallChecksums(t *testing.T) { opts := newUserOpts(t) plan := mustPlan(t, opts) @@ -291,6 +293,35 @@ func TestUserSkillPlanFirstInstallChecksums(t *testing.T) { } } +// TestUserSkillManifestVersionIsBareSemver pins the agent-plugins schema +// requirement: a v-prefixed build version must not reach the plugin manifest. +// The schema validator rejects the whole plugin on a non-semver version +// string, which takes every skill and command down with it. +func TestUserSkillManifestVersionIsBareSemver(t *testing.T) { + opts := newUserOpts(t) + opts.Version = "v9.9.9" + mustApply(t, opts) + for _, client := range opts.Clients { + manifest := filepath.Join(opts.Home, userClientRoot(client), ".claude-plugin", "plugin.json") + if client != "claude" { + continue + } + raw, err := os.ReadFile(manifest) + if err != nil { + t.Fatalf("read %s: %v", manifest, err) + } + var decoded struct { + Version string `json:"version"` + } + if err := json.Unmarshal(raw, &decoded); err != nil { + t.Fatalf("decode %s: %v", manifest, err) + } + if decoded.Version != "9.9.9" { + t.Errorf("manifest version %q, want bare semver \"9.9.9\" (Agent Plugins 1.0 schema rejects a v prefix)", decoded.Version) + } + } +} + // TestUserSkillPlanAllCurrentIsNoOp proves a re-plan after a successful install // reports every asset as unchanged. func TestUserSkillPlanAllCurrentIsNoOp(t *testing.T) {