Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.
ci(release): bump plugin versions on main after merge, not in PRs (#172)
Cathryn Lavery8d55bd42ad9b
diff --git a/.github/workflows/auto-bump.yml b/.github/workflows/auto-bump.ymlnew file mode 100644index 0000000..a5affff--- /dev/null+++ b/.github/workflows/auto-bump.yml@@ -0,0 +1,356 @@+name: Auto Version Bump++# Post-merge release automation (ADR 0009): pull requests never touch the+# plugin manifest versions; this workflow bumps them on main after each merge.+# Rapid consecutive merges may coalesce into a single bump.++on:+ push:+ branches: [ main ]++permissions: {}++# Serialize bump runs. A pending run superseded by a newer push simply lets+# that newer run bump once for all changes since the previous bump.+concurrency:+ group: auto-bump-main+ cancel-in-progress: false++env:+ PYTHONIOENCODING: utf-8+ PYTHONUTF8: "1"++jobs:+ prepare:+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ pull-requests: read+ outputs:+ should_bump: ${{ steps.guard.outputs.should_bump }}+ source_sha: ${{ steps.guard.outputs.source_sha }}+ part: ${{ steps.part.outputs.part }}++ steps:+ # This job runs newly merged repository code, so it receives only the+ # read-only GITHUB_TOKEN and never sees the protected-main PAT.+ - name: Checkout latest main without persisted credentials+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7+ with:+ ref: main+ fetch-depth: 0+ persist-credentials: false++ - name: Set up Python+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7+ with:+ python-version: "3.12"++ # Skip when the tip of main already carries a version change (a manual+ # bump, or this workflow's own commit triggering another run).+ - name: Check whether main already bumped+ id: guard+ shell: bash+ run: |+ source_sha=$(git rev-parse HEAD)+ echo "source_sha=${source_sha}" >> "$GITHUB_OUTPUT"+ if git rev-parse --verify --quiet HEAD^ >/dev/null \+ && ! git diff --quiet HEAD^ HEAD -- \+ .claude-plugin/plugin.json \+ .codex-plugin/plugin.json \+ .factory-plugin/plugin.json; then+ echo "should_bump=false" >> "$GITHUB_OUTPUT"+ else+ echo "should_bump=true" >> "$GITHUB_OUTPUT"+ fi++ # Inspect every commit since the previous manifest bump. This preserves+ # the strongest release label when multiple merges coalesce into one run.+ - name: Determine bump size across all unversioned merges+ if: steps.guard.outputs.should_bump == 'true'+ id: part+ env:+ GH_TOKEN: ${{ github.token }}+ SOURCE_SHA: ${{ steps.guard.outputs.source_sha }}+ shell: bash+ run: |+ set -euo pipefail+ last_bump=$(git log -1 --format=%H "$SOURCE_SHA" -- \+ .claude-plugin/plugin.json \+ .codex-plugin/plugin.json \+ .factory-plugin/plugin.json)+ if [ -z "$last_bump" ]; then+ echo "No previous manifest bump found" >&2+ exit 1+ fi++ part=patch+ while IFS= read -r commit; do+ labels=$(gh api \+ "repos/${{ github.repository }}/commits/${commit}/pulls" \+ --jq '[.[].labels[].name] | join(" ")')+ case " $labels " in+ *" release:major "*)+ part=major+ break+ ;;+ *" release:minor "*)+ part=minor+ ;;+ esac+ done < <(git rev-list --reverse "${last_bump}..${SOURCE_SHA}")+ echo "part=${part}" >> "$GITHUB_OUTPUT"++ - name: Bump plugin manifests+ if: steps.guard.outputs.should_bump == 'true'+ env:+ BUMP_PART: ${{ steps.part.outputs.part }}+ shell: bash+ run: |+ case "$BUMP_PART" in+ major) flag=--major ;;+ minor) flag=--minor ;;+ patch) flag= ;;+ *) echo "Invalid bump part: $BUMP_PART" >&2; exit 1 ;;+ esac+ python3 scripts/bump-plugin-version.py $flag++ - name: Verify and package the exact bump+ if: steps.guard.outputs.should_bump == 'true'+ env:+ SOURCE_SHA: ${{ steps.guard.outputs.source_sha }}+ shell: bash+ run: |+ set -euo pipefail+ python3 scripts/verify-plugin-package.py "$SOURCE_SHA"++ expected=$(printf '%s\n' \+ .claude-plugin/plugin.json \+ .codex-plugin/plugin.json \+ .factory-plugin/plugin.json \+ skills/diagram-design/SKILL.md | LC_ALL=C sort)+ actual=$(git diff --name-only | LC_ALL=C sort)+ if [ "$actual" != "$expected" ]; then+ echo "Bump changed files outside the release allowlist:" >&2+ git diff --name-only >&2+ exit 1+ fi++ git diff --binary -- \+ .claude-plugin/plugin.json \+ .codex-plugin/plugin.json \+ .factory-plugin/plugin.json \+ skills/diagram-design/SKILL.md > version-bump.patch+ test -s version-bump.patch++ - name: Upload version bump+ if: steps.guard.outputs.should_bump == 'true'+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: version-bump-${{ github.run_id }}-${{ github.run_attempt }}+ path: version-bump.patch+ if-no-files-found: error+ retention-days: 1++ publish:+ needs: prepare+ if: needs.prepare.outputs.should_bump == 'true'+ runs-on: ubuntu-latest+ timeout-minutes: 5+ permissions:+ contents: read++ steps:+ - name: Checkout latest main without persisted credentials+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7+ with:+ ref: main+ fetch-depth: 0+ persist-credentials: false++ - name: Confirm prepared tree is still current+ id: current+ env:+ SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }}+ shell: bash+ run: |+ if [ "$(git rev-parse HEAD)" = "$SOURCE_SHA" ]; then+ echo "matches=true" >> "$GITHUB_OUTPUT"+ else+ echo "matches=false" >> "$GITHUB_OUTPUT"+ echo "main advanced after preparation; a newer queued run will recompute the bump"+ fi++ - name: Download prepared version bump+ if: steps.current.outputs.matches == 'true'+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ name: version-bump-${{ github.run_id }}-${{ github.run_attempt }}+ path: _version-bump++ # Do not trust the artifact merely because the unprivileged job produced+ # it. Revalidate its paths and exact semantic changes before committing.+ - name: Apply and independently validate prepared bump+ if: steps.current.outputs.matches == 'true'+ env:+ BUMP_PART: ${{ needs.prepare.outputs.part }}+ shell: bash+ run: |+ set -euo pipefail+ patch=_version-bump/version-bump.patch+ expected=$(printf '%s\n' \+ .claude-plugin/plugin.json \+ .codex-plugin/plugin.json \+ .factory-plugin/plugin.json \+ skills/diagram-design/SKILL.md | LC_ALL=C sort)+ patch_paths=$(git apply --numstat "$patch" | cut -f3- | LC_ALL=C sort)+ if [ "$patch_paths" != "$expected" ]; then+ echo "Artifact contains paths outside the release allowlist" >&2+ exit 1+ fi++ git apply --check --whitespace=error "$patch"+ git apply --index --whitespace=error "$patch"+ staged_paths=$(git diff --cached --name-only | LC_ALL=C sort)+ if [ "$staged_paths" != "$expected" ] \+ || [ -n "$(git diff --cached --summary)" ]; then+ echo "Artifact changed unexpected paths or file modes" >&2+ exit 1+ fi++ python3 - <<'PY'+ import json+ import os+ import re+ import subprocess+ from pathlib import Path++ manifests = (+ Path(".claude-plugin/plugin.json"),+ Path(".codex-plugin/plugin.json"),+ Path(".factory-plugin/plugin.json"),+ )+ semver = re.compile(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$")++ def from_head(path: Path) -> str:+ return subprocess.check_output(+ ["git", "show", f"HEAD:{path.as_posix()}"], text=True+ )++ base_payloads = [json.loads(from_head(path)) for path in manifests]+ base_versions = {payload.get("version") for payload in base_payloads}+ if len(base_versions) != 1:+ raise SystemExit("base manifest versions are not synchronized")+ base_version = base_versions.pop()+ match = semver.fullmatch(base_version) if isinstance(base_version, str) else None+ if match is None:+ raise SystemExit(f"invalid base version: {base_version!r}")++ major, minor, patch = (int(value) for value in match.groups())+ part = os.environ["BUMP_PART"]+ if part == "major":+ expected_version = f"{major + 1}.0.0"+ elif part == "minor":+ expected_version = f"{major}.{minor + 1}.0"+ elif part == "patch":+ expected_version = f"{major}.{minor}.{patch + 1}"+ else:+ raise SystemExit(f"invalid bump part: {part!r}")++ for path, base in zip(manifests, base_payloads):+ expected_payload = dict(base)+ expected_payload["version"] = expected_version+ expected_text = json.dumps(+ expected_payload, indent=2, ensure_ascii=False+ ) + "\n"+ if path.read_text(encoding="utf-8") != expected_text:+ raise SystemExit(+ f"{path} changed beyond the exact {expected_version} version update"+ )++ skill_path = Path("skills/diagram-design/SKILL.md")+ base_skill = from_head(skill_path)+ lines = base_skill.splitlines(keepends=True)+ if not lines or lines[0].strip() != "---":+ raise SystemExit("SKILL.md has no YAML frontmatter")+ closing = next(+ (index for index in range(1, len(lines)) if lines[index].strip() == "---"),+ None,+ )+ if closing is None:+ raise SystemExit("SKILL.md frontmatter is unterminated")++ expected_minor = ".".join(expected_version.split(".")[:2])+ in_metadata = False+ replaced = 0+ for index in range(1, closing):+ line = lines[index]+ body = line.rstrip("\r\n")+ ending = line[len(body):]+ if re.fullmatch(r"metadata:\s*(?:#.*)?", body):+ in_metadata = True+ continue+ if in_metadata and body.strip() and not body[0].isspace():+ in_metadata = False+ if not in_metadata:+ continue+ version_match = re.fullmatch(+ r'(?P<head>\s+version:\s*)"[0-9][0-9.]*"(?P<tail>\s*(?:#.*)?)',+ body,+ )+ if version_match is not None:+ lines[index] = (+ f'{version_match.group("head")}"{expected_minor}"'+ f'{version_match.group("tail")}{ending}'+ )+ replaced += 1+ if replaced != 1:+ raise SystemExit(+ "SKILL.md must contain exactly one quoted metadata.version"+ )+ current_skill = skill_path.read_text(encoding="utf-8")+ if current_skill != "".join(lines):+ raise SystemExit("SKILL.md changed beyond the expected metadata.version")++ PY++ version=$(python3 -c \+ "import json; print(json.load(open('.claude-plugin/plugin.json'))['version'])")+ git config user.name "github-actions[bot]"+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"+ git commit -m "chore(release): bump plugin manifests to ${version}"++ - name: Recheck main before publishing+ if: steps.current.outputs.matches == 'true'+ id: fresh+ env:+ SOURCE_SHA: ${{ needs.prepare.outputs.source_sha }}+ shell: bash+ run: |+ git fetch --no-tags origin main+ if [ "$(git rev-parse FETCH_HEAD)" = "$SOURCE_SHA" ]; then+ echo "matches=true" >> "$GITHUB_OUTPUT"+ else+ echo "matches=false" >> "$GITHUB_OUTPUT"+ echo "main advanced before publish; a newer queued run will recompute the bump"+ fi++ # AUTO_BUMP_TOKEN is introduced only for this final command. No merged+ # repository script or third-party action runs with the token available.+ - name: Push the validated bump to protected main+ if: steps.fresh.outputs.matches == 'true'+ env:+ AUTO_BUMP_TOKEN: ${{ secrets.AUTO_BUMP_TOKEN }}+ shell: bash+ run: |+ set -euo pipefail+ if [ -z "$AUTO_BUMP_TOKEN" ]; then+ echo "AUTO_BUMP_TOKEN is not configured" >&2+ exit 1+ fi+ clean_remote="https://github.com/${GITHUB_REPOSITORY}.git"+ trap 'git remote set-url origin "$clean_remote"' EXIT+ git remote set-url origin \+ "https://x-access-token:${AUTO_BUMP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"+ git push origin HEAD:refs/heads/maindiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 5dd8acd..0ea4e22 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -46,10 +46,18 @@ jobs:- name: Verify maintainer policy tracks package and CI truthrun: python3 scripts/test-maintainer-policy.py- - name: Require a synchronized plugin version bump+ # Versions are bumped on main by the Auto Version Bump workflow after+ # each merge (ADR 0009); pull requests must leave them untouched.+ - name: Forbid manifest version changes in pull requestsenv:- BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}- run: python3 scripts/verify-plugin-package.py "$BASE_REF"+ BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }}+ shell: bash+ run: |+ if [ "${{ github.event_name }}" = "pull_request" ]; then+ python3 scripts/verify-plugin-package.py --require-no-bump "$BASE_REF"+ else+ python3 scripts/verify-plugin-package.py --current-only+ fi- name: Validate Claude marketplace package without warningsrun: npx --yes @anthropic-ai/[email protected] plugin validate . --strictdiff --git a/.maintainer-policy.json b/.maintainer-policy.jsonindex aaf1517..4a925b3 100644--- a/.maintainer-policy.json+++ b/.maintainer-policy.json@@ -22,14 +22,20 @@}],"require_synchronized": true,- "require_unique_across_open_prs": true,- "bump_command": "python3 scripts/bump-plugin-version.py"+ "require_unique_across_open_prs": false,+ "bump_command": "python3 scripts/bump-plugin-version.py",+ "bumped_by": "auto-bump workflow on push to main (ADR 0009)",+ "pr_manifest_version_changes": "forbidden",+ "bump_size_labels": {+ "minor": "release:minor",+ "major": "release:major"+ }},"gates": {"local_commands": ["python3 scripts/test-plugin-package.py","python3 scripts/test-maintainer-policy.py",- "python3 scripts/verify-plugin-package.py origin/main",+ "python3 scripts/verify-plugin-package.py --require-no-bump origin/main","npx --yes @anthropic-ai/[email protected] plugin validate . --strict","python3 scripts/test-lint-a11y.py","python3 scripts/verify-semantic-motion.py --markdown-only",@@ -90,6 +96,7 @@"require_no_requested_changes": true,"post_merge_workflows": ["CI",+ "Auto Version Bump","Deploy gallery to GitHub Pages"]},diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex e802b0c..6cd7b5b 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -27,21 +27,13 @@ See [README.md](README.md) for the full picture, including the design system andEvery validation gate below must pass before a PR is ready. They also run automatically as GitHub Actions CI (`.github/workflows/ci.yml`).-Every PR changes the distributed plugin package, including documentation- and CI-only PRs. Increment both native manifests together before opening or updating a PR:--```bash-python3 scripts/bump-plugin-version.py # patch (default)-python3 scripts/bump-plugin-version.py --minor # minor release-python3 scripts/bump-plugin-version.py --major # major release-```--The helper refuses to run if the Claude, Codex, and Factory versions already differ. If another release lands on `main` first, rebase and bump again so your version remains greater than the new base.+**Do not bump the plugin version in your PR.** The Claude, Codex, and Factory manifest versions are bumped automatically on `main` after each merge by the Auto Version Bump workflow (`.github/workflows/auto-bump.yml`, ADR 0009), so pull requests must leave all three `plugin.json` versions untouched — CI rejects any change to them. This keeps open PRs from conflicting with each other on every merge. If your change warrants more than a patch release, say so in the PR description and the maintainer will apply the `release:minor` or `release:major` label before merging; the label selects the bump size. (`scripts/bump-plugin-version.py` still exists for the workflow and the maintainer — contributors never need to run it.)| What it checks | Command ||---|---|| Plugin bump helper and adversarial package cases | `python3 scripts/test-plugin-package.py` || Maintainer policy matches native manifests and current CI gates | `python3 scripts/test-maintainer-policy.py` |-| Synchronized, increasing versions; valid marketplace paths; packaged skill | `python3 scripts/verify-plugin-package.py origin/main` |+| Manifest versions untouched and synchronized; valid marketplace paths; packaged skill | `python3 scripts/verify-plugin-package.py --require-no-bump origin/main` || Claude marketplace and plugin schema, with warnings treated as errors | `claude plugin validate . --strict` || Accessible SVG contract (unit tests for the a11y linter) | `python3 scripts/test-lint-a11y.py` || Semantic-pattern routing | `python3 scripts/verify-semantic-motion.py --markdown-only` |@@ -91,7 +83,7 @@ Run them all at once before pushing:```bashpython3 scripts/test-plugin-package.py \&& python3 scripts/test-maintainer-policy.py \- && python3 scripts/verify-plugin-package.py origin/main \+ && python3 scripts/verify-plugin-package.py --require-no-bump origin/main \&& claude plugin validate . --strict \&& python3 scripts/test-lint-a11y.py \&& python3 scripts/verify-semantic-motion.py --markdown-only \@@ -139,7 +131,7 @@ python3 scripts/test-plugin-package.py \### If a gate fails-- **`verify-plugin-package.py`:** run the bump helper if the versions did not increase. If packaging validation fails, keep both marketplaces pointed at the repository root and keep the shared skill at `skills/diagram-design/SKILL.md`.+- **`verify-plugin-package.py`:** if it reports a version change, drop the manifest edits from your branch — versions are bumped on `main` after merge, never in a PR. If packaging validation fails, keep both marketplaces pointed at the repository root and keep the shared skill at `skills/diagram-design/SKILL.md`.- **`lint-skin.py`:** the failure message names the file, line, and category (`color`, `font-family`, `a11y`, `external-asset`, `pure-black`, `script`). Colors must come from the palette in `skills/diagram-design/references/style-guide.md`; fonts from the allowed list; diagrams must satisfy the accessible SVG contract (see below). The linter also requires the SHA-pinned controller from `template-motion.html` verbatim and rejects remote resources, CSS `@import`, non-fragment CSS `url()`, event handlers, `srcdoc`, executable URLs, and extra scripts.- **`verify-*.py`:** the extractor's real behavior no longer matches its fixture or the documentation, or the reference/command/prompt wiring drifted. Fix the source of truth — do not widen a test to avoid a failure.- **`verify-screenshot-freshness.py`:** a canonical minimal-light example or its committed PNG changed without a synchronized catalog refresh. Before the first regeneration, install the renderer with `python3 -m pip install playwright && python3 -m playwright install chromium`. Then run `python3 scripts/render-canonical-screenshots.py`, inspect all 39 renders, and commit the updated PNGs plus `docs/screenshots/manifest.json`.@@ -189,7 +181,7 @@ Motion is opt-in. Start from `skills/diagram-design/assets/template-motion.html`## Design decisions (ADRs)-Settled policies live as short records in `docs/adr/` — one pinned motion controller, semantic patterns never expanding the visual-type taxonomy, the reveal-only autoplay rule, the SKILL.md byte cap with its trigger-rich description requirement, and geometric label placement being verified rather than reviewed. Read the relevant ADR before proposing a change that touches one; when a PR settles a new policy, add an ADR in the same PR.+Settled policies live as short records in `docs/adr/` — one pinned motion controller, semantic patterns never expanding the visual-type taxonomy, the reveal-only autoplay rule, the SKILL.md byte cap with its trigger-rich description requirement, geometric label placement being verified rather than reviewed, and plugin versions being bumped on `main` after merge rather than in PRs. Read the relevant ADR before proposing a change that touches one; when a PR settles a new policy, add an ADR in the same PR.## Adding a new diagram typediff --git a/docs/adr/0009-versions-are-bumped-on-main-after-merge.md b/docs/adr/0009-versions-are-bumped-on-main-after-merge.mdnew file mode 100644index 0000000..c586011--- /dev/null+++ b/docs/adr/0009-versions-are-bumped-on-main-after-merge.md@@ -0,0 +1,17 @@+# ADR 0009 — Versions are bumped on main after merge, never in a pull request++**Status:** accepted (v2.6.12)++## Context++Every pull request used to be required to increment the synchronized Claude, Codex, and Factory manifest versions before merge. Because all open branches edited the same three version lines, every merge to `main` instantly put every other open PR into merge conflict; with ~17 community PRs open, a single squash-merge forced seventeen rebase-and-rebump rounds, and the next merge invalidated them all again. The bump requirement served release integrity — installs resolve from `main`, so each new tip needs a version greater than the last — but serialized all contribution on three shared lines.++## Decision++Pull requests must leave the three manifest versions untouched; `verify-plugin-package.py --require-no-bump` enforces this in CI on every PR. After each push to `main`, the Auto Version Bump workflow (`.github/workflows/auto-bump.yml`) runs `scripts/bump-plugin-version.py`, verifies the result with the classic increase gate against the pre-bump commit, and prepares an allowlisted patch. A separate publisher independently verifies that patch before pushing the bump commit directly to `main`. A `release:minor` or `release:major` label on any merged PR since the previous bump selects the strongest required bump size; the default is a patch. The bump tool also rewrites SKILL.md's `metadata.version` to the new MAJOR.MINOR in the same step, so the two never drift.++Rapid consecutive merges may coalesce into a single bump: a queued workflow run superseded by a newer push bumps once for every merge since the previous bump and preserves the strongest release label in that range. If `main` advances after a bump is prepared, the publisher declines to push so the newer queued run can recompute from the new tip. Versions still strictly increase at every bump commit, which is the only property installs and the marketplaces depend on. The workflow skips itself when the tip of `main` already carries a manifest version change, so manual maintainer bumps and the workflow's own commits never trigger a second bump.++## Consequences++Open PRs no longer conflict with each other through the manifests; they conflict only when they genuinely touch the same content. Contributors never run the bump helper, and a PR that edits a manifest version fails CI with instructions to drop the change. Release numbering moves from one-version-per-PR to one-version-per-bump-commit, and a version may cover more than one merged PR. The workflow pushes past branch protection's required status checks, so its final push needs a token from an actor the protection exempts. Newly merged repository code runs in an unprivileged job that never receives that token; the publisher introduces it only for the final `git push`, after independently constraining the patch to the synchronized version fields and SKILL.md metadata. All third-party actions are pinned to immutable commits. The bump commit is also validated by CI's current-tree check on push.diff --git a/scripts/bump-plugin-version.py b/scripts/bump-plugin-version.pyindex ef66d60..fd00261 100755--- a/scripts/bump-plugin-version.py+++ b/scripts/bump-plugin-version.py@@ -16,6 +16,7 @@ MANIFEST_PATHS = (Path(".codex-plugin/plugin.json"),Path(".factory-plugin/plugin.json"),)+SKILL_PATH = Path("skills/diagram-design/SKILL.md")SEMVER = re.compile(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$")@@ -68,11 +69,60 @@ def bump(root: Path, part: str = "patch") -> str:rendered_manifests.append((root / relative, json.dumps(payload, indent=2, ensure_ascii=False) + "\n"))+ skill_path, skill_contents = render_skill_metadata_version(root, version)for path, contents in rendered_manifests:path.write_text(contents, encoding="utf-8")+ skill_path.write_text(skill_contents, encoding="utf-8")return version+def render_skill_metadata_version(root: Path, version: str) -> tuple[Path, str]:+ """Keep SKILL.md's hand-maintained metadata.version on the manifest MAJOR.MINOR.++ The package verifier fails when the two drift, so the bump must update both+ sides in one step. Returns the pending write (rendered before any manifest+ is written, so a malformed SKILL.md aborts the whole bump); raises when the+ frontmatter does not carry exactly one metadata.version to rewrite.+ """+ path = root / SKILL_PATH+ if not path.is_file():+ raise PackageVersionError(f"missing {SKILL_PATH}")+ lines = path.read_text(encoding="utf-8").splitlines(keepends=True)+ if not lines or lines[0].strip() != "---":+ raise PackageVersionError(f"{SKILL_PATH} has no YAML frontmatter")+ closing = next(+ (index for index in range(1, len(lines)) if lines[index].strip() == "---"), None+ )+ if closing is None:+ raise PackageVersionError(f"{SKILL_PATH} frontmatter is unterminated")++ major_minor = ".".join(version.split(".")[:2])+ in_metadata = False+ replaced = 0+ for index in range(1, closing):+ line = lines[index]+ if re.fullmatch(r"metadata:\s*(?:#.*)?", line.rstrip("\n")):+ in_metadata = True+ continue+ if in_metadata and line.strip() and not line[0].isspace():+ in_metadata = False+ if not in_metadata:+ continue+ match = re.fullmatch(+ r'(?P<head>\s+version:\s*)"[0-9][0-9.]*"(?P<tail>\s*(?:#.*)?)',+ line.rstrip("\n"),+ )+ if match is not None:+ lines[index] = f'{match.group("head")}"{major_minor}"{match.group("tail")}\n'+ replaced += 1+ if replaced != 1:+ raise PackageVersionError(+ f"{SKILL_PATH} frontmatter must contain exactly one quoted "+ f"metadata.version; found {replaced}"+ )+ return path, "".join(lines)++def parse_args() -> argparse.Namespace:parser = argparse.ArgumentParser(description="Increment all plugin manifests (patch by default)."diff --git a/scripts/test-plugin-package.py b/scripts/test-plugin-package.pyindex 9dc7e1a..ffaa42b 100755--- a/scripts/test-plugin-package.py+++ b/scripts/test-plugin-package.py@@ -181,6 +181,50 @@ def test_verifier() -> None:"must increase",)+ with package_repo() as root:+ errors = VERIFY.verify_package(root, "HEAD", mode="no-bump")+ if errors:+ raise AssertionError(f"unchanged versions failed no-bump mode: {errors}")+ print("OK: no-bump mode accepts unchanged versions")++ with package_repo() as root:+ set_versions(root, "1.2.4", "1.2.4")+ expect_failure(+ "version bump inside a pull request",+ VERIFY.verify_package(root, "HEAD", mode="no-bump"),+ "must not change in a pull request",+ )++ with package_repo() as root:+ set_versions(root, "1.2.2", "1.2.2")+ expect_failure(+ "version rollback inside a pull request",+ VERIFY.verify_package(root, "HEAD", mode="no-bump"),+ "must not change in a pull request",+ )++ with package_repo() as root:+ errors = VERIFY.verify_package(root, None, mode="current-only")+ if errors:+ raise AssertionError(f"current-only mode failed a valid tree: {errors}")+ print("OK: current-only mode accepts a valid tree")++ with package_repo() as root:+ set_versions(root, "1.2.4", "1.2.5")+ expect_failure(+ "current-only mode with desynchronized manifests",+ VERIFY.verify_package(root, None, mode="current-only"),+ "versions must match",+ )++ with package_repo() as root:+ set_versions(root, "1.2", "1.2")+ expect_failure(+ "current-only mode with malformed versions",+ VERIFY.verify_package(root, None, mode="current-only"),+ "strict MAJOR.MINOR.PATCH",+ )+with package_repo() as root:set_versions(root, "1.2.4", "1.2.5")expect_failure(@@ -444,7 +488,14 @@ def test_bumper() -> None:raise AssertionError(f"{part} bump: expected {expected}, got {actual} and {versions}")- print(f"OK: {part} bump produced {expected}")+ skill_text = (root / BUMP.SKILL_PATH).read_text(encoding="utf-8")+ expected_minor = ".".join(expected.split(".")[:2])+ if f'version: "{expected_minor}"' not in skill_text:+ raise AssertionError(+ f"{part} bump left SKILL.md metadata.version off "+ f"{expected_minor!r}: {skill_text!r}"+ )+ print(f"OK: {part} bump produced {expected} and synced SKILL.md")with tempfile.TemporaryDirectory() as scratch:root = Path(scratch)@@ -459,6 +510,30 @@ def test_bumper() -> None:raise AssertionError("version bumper accepted mismatched manifests")print("OK: version bumper rejects mismatched manifests")+ with tempfile.TemporaryDirectory() as scratch:+ root = Path(scratch)+ seed_package(root)+ skill = root / BUMP.SKILL_PATH+ skill.write_text(f"---\nname: {PLUGIN_NAME}\n---\n", encoding="utf-8")+ before = {+ relative: (root / relative).read_text(encoding="utf-8")+ for relative in BUMP.MANIFEST_PATHS+ }+ try:+ BUMP.bump(root)+ except BUMP.PackageVersionError as exc:+ if "metadata.version" not in str(exc):+ raise AssertionError(f"unexpected SKILL.md error: {exc}") from exc+ else:+ raise AssertionError("version bumper accepted SKILL.md without metadata.version")+ after = {+ relative: (root / relative).read_text(encoding="utf-8")+ for relative in BUMP.MANIFEST_PATHS+ }+ if before != after:+ raise AssertionError("failed bump must leave every manifest untouched")+ print("OK: version bumper fails closed on SKILL.md drift, manifests untouched")+def main() -> int:test_verifier()diff --git a/scripts/verify-plugin-package.py b/scripts/verify-plugin-package.pyindex 50e48d9..a6c1732 100755--- a/scripts/verify-plugin-package.py+++ b/scripts/verify-plugin-package.py@@ -1,12 +1,25 @@#!/usr/bin/env python3-"""Verify synchronized version bumps and native marketplace packaging."""+"""Verify synchronized plugin versions and native marketplace packaging.++Three modes cover the release flow (ADR 0009):++- ``verify-plugin-package.py <base-ref>`` requires the synchronized version to+ increase relative to the base. The post-merge auto-bump workflow runs this+ before pushing its bump commit.+- ``verify-plugin-package.py --require-no-bump <base-ref>`` requires the+ versions to be unchanged relative to the base. CI runs this on pull+ requests: contributors never touch the manifest versions.+- ``verify-plugin-package.py --current-only`` skips the base comparison and+ validates only the current tree (synchronization, identity, marketplace+ paths, packaged skill). CI runs this on pushes to main.+"""from __future__ import annotations+import argparseimport jsonimport reimport subprocess-import sysfrom pathlib import Pathfrom typing import Any@@ -142,9 +155,10 @@ def find_plugin_entry(def verify_versions(root: Path,- base_ref: str,+ base_ref: str | None,manifests: dict[str, dict[str, Any]],errors: list[str],+ mode: str = "increase",) -> None:current_versions = {label: payload.get("version") for label, payload in manifests.items()}version_values = list(current_versions.values())@@ -152,6 +166,11 @@ def verify_versions(rendered = ", ".join(f"{label}={value!r}" for label, value in current_versions.items())errors.append(f"plugin manifest versions must match: {rendered}")+ if mode == "current-only":+ for label in MANIFEST_PATHS:+ parse_semver(current_versions.get(label), f"current {label}", errors)+ return+base_check = subprocess.run(["git", "rev-parse", "--verify", f"{base_ref}^{{commit}}"],cwd=root,@@ -174,15 +193,23 @@ def verify_versions(if base_manifest is None:continuebase = parse_semver(base_manifest.get("version"), f"{label} at {base_ref}", errors)- if current is not None and base is not None and current <= base:+ if current is None or base is None:+ continue+ if mode == "increase" and current <= base:errors.append(f"{label} manifest version must increase relative to {base_ref}: "f"{base_manifest.get('version')} -> {current_versions.get(label)}")+ if mode == "no-bump" and current != base:+ errors.append(+ f"{label} manifest version must not change in a pull request "+ f"(ADR 0009: versions are bumped on main after merge): "+ f"{base_manifest.get('version')} -> {current_versions.get(label)}"+ )if base_manifest_count == 0:errors.append(f"no synchronized plugin manifest exists at {base_ref}; "- "cannot establish that the package version advanced"+ "cannot compare the package version against the base")@@ -432,7 +459,7 @@ def verify_skill_metadata_version(root: Path, manifests: dict[str, dict[str, Any)-def verify_package(root: Path, base_ref: str) -> list[str]:+def verify_package(root: Path, base_ref: str | None, mode: str = "increase") -> list[str]:errors: list[str] = []manifests: dict[str, dict[str, Any]] = {}for label, relative in MANIFEST_PATHS.items():@@ -441,7 +468,7 @@ def verify_package(root: Path, base_ref: str) -> list[str]:manifests[label] = payloadif len(manifests) == len(MANIFEST_PATHS):- verify_versions(root, base_ref, manifests, errors)+ verify_versions(root, base_ref, manifests, errors, mode)verify_manifest_identity(manifests, errors)verify_skill_metadata_version(root, manifests, errors)verify_codex_skill_path(root, manifests["Codex"], errors)@@ -449,20 +476,52 @@ def verify_package(root: Path, base_ref: str) -> list[str]:return errors+def parse_args() -> argparse.Namespace:+ parser = argparse.ArgumentParser(+ description="Verify synchronized plugin versions and marketplace packaging."+ )+ parser.add_argument("base_ref", nargs="?", help="base ref to compare versions against")+ group = parser.add_mutually_exclusive_group()+ group.add_argument(+ "--require-no-bump",+ action="store_true",+ help="require manifest versions to be unchanged relative to the base (PR gate)",+ )+ group.add_argument(+ "--current-only",+ action="store_true",+ help="validate the current tree without comparing versions to a base",+ )+ args = parser.parse_args()+ if args.current_only:+ if args.base_ref is not None:+ parser.error("--current-only does not take a base ref")+ elif args.base_ref is None:+ parser.error("a base ref is required unless --current-only is given")+ return args++def main() -> int:- if len(sys.argv) != 2:- print(f"Usage: {Path(sys.argv[0]).name} <base-ref>", file=sys.stderr)- return 2- base_ref = sys.argv[1]- errors = verify_package(ROOT, base_ref)+ args = parse_args()+ mode = (+ "current-only"+ if args.current_only+ else "no-bump" if args.require_no_bump else "increase"+ )+ errors = verify_package(ROOT, args.base_ref, mode)if errors:print("FAIL plugin package")for error in errors:print(f" - {error}")return 1versions = load_json(ROOT / MANIFEST_PATHS["Claude"], [])["version"]+ detail = {+ "increase": "version advanced",+ "no-bump": "version unchanged",+ "current-only": "current tree",+ }[mode]print(- f"OK plugin package: Claude, Codex, and Factory {versions}, "+ f"OK plugin package ({detail}): Claude, Codex, and Factory {versions}, "f"marketplace paths, and packaged skill")return 0