From 0947fdb6e569a705fa38ce3a5fe9391c60d836d2 Mon Sep 17 00:00:00 2001 From: Cathryn Lavery <50469282+cathrynlavery@users.noreply.github.com> Date: Tue, 18 Aug 2026 10:38:57 -0700 Subject: [PATCH] fix(drawio): keep import command reference in sync (#109) --- .claude-plugin/plugin.json | 2 +- .codex-plugin/plugin.json | 2 +- .github/workflows/ci.yml | 4 +- CONTRIBUTING.md | 3 +- scripts/test-verify-drawio-import.py | 65 +++++++++++++++++++ scripts/verify-drawio-import.py | 10 +++ .../references/import-drawio.md | 2 +- 7 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 scripts/test-verify-drawio-import.py diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 97b1518..95c91ac 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "diagram-design", "description": "Create branded architecture, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, loop/flywheel, nested, tree, org chart, layer stack, Venn, pyramid/funnel, treemap, bar, line, Gantt and scatter charts, high-level, process, medallion, data flow, DP integration, or DP security matrix diagrams as standalone HTML/SVG/PNG. Redraw .drawio/.drawio.png/.drawio.svg or Mermaid .mmd sources at a chosen size/detail; onboard brand tokens from a website; add semantic patterns, callouts, accessible motion, or sketchy/hand-drawn styling.", - "version": "2.5.2", + "version": "2.5.4", "author": { "name": "Cathryn Lavery", "url": "https://github.com/cathrynlavery" diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 98a69cb..dc4bc40 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "diagram-design", "description": "Create branded architecture, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, loop/flywheel, nested, tree, org chart, layer stack, Venn, pyramid/funnel, treemap, bar, line, Gantt and scatter charts, high-level, process, medallion, data flow, DP integration, or DP security matrix diagrams as standalone HTML/SVG/PNG. Redraw .drawio/.drawio.png/.drawio.svg or Mermaid .mmd sources at a chosen size/detail; onboard brand tokens from a website; add semantic patterns, callouts, accessible motion, or sketchy/hand-drawn styling.", - "version": "2.5.2", + "version": "2.5.4", "author": { "name": "Cathryn Lavery", "url": "https://github.com/cathrynlavery" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88cfd9f..ad23dae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,9 @@ jobs: - name: Verify draw.io import script if: always() id: drawio - run: python scripts/verify-drawio-import.py + run: | + python scripts/verify-drawio-import.py + python scripts/test-verify-drawio-import.py - name: Verify Mermaid import script if: always() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d23cf23..d4e4ccc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,7 @@ The helper refuses to run if the Claude and Codex versions already differ. If an | Skin conformance of every example and template (colors, fonts, a11y, assets, scripts) | `python3 scripts/lint-skin.py --all --baseline` | | A single file, e.g. a new example | `python3 scripts/lint-skin.py skills/diagram-design/assets/example-my-type.html` | | Sequence-doc consistency (ATL fragments, budgets) | `python3 scripts/verify-sequence-oauth.py` | -| draw.io import path (real extractor vs fixtures + docs sync) | `python3 scripts/verify-drawio-import.py` | +| draw.io import path (real extractor vs fixtures + docs sync) | `python3 scripts/verify-drawio-import.py && python3 scripts/test-verify-drawio-import.py` | | Mermaid import path (grammars, adversarial input, caps, docs sync) | `python3 scripts/verify-mermaid-import.py` | | Optional motion contract (fallbacks, controls, budgets, determinism) | `python3 scripts/test-verify-motion.py` | | Every shipped motion template/example | `python3 scripts/verify-motion.py --shipped` | @@ -75,6 +75,7 @@ python3 scripts/test-plugin-package.py \ && python3 scripts/lint-skin.py --all --baseline \ && python3 scripts/verify-sequence-oauth.py \ && python3 scripts/verify-drawio-import.py \ + && python3 scripts/test-verify-drawio-import.py \ && python3 scripts/verify-mermaid-import.py \ && python3 scripts/test-verify-motion.py \ && python3 scripts/verify-docs-sync.py \ diff --git a/scripts/test-verify-drawio-import.py b/scripts/test-verify-drawio-import.py new file mode 100644 index 0000000..3560e02 --- /dev/null +++ b/scripts/test-verify-drawio-import.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +"""Regression tests for the draw.io import verifier.""" + +from __future__ import annotations + +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + + +ROOT = Path(__file__).resolve().parent.parent +REFERENCE = Path("skills/diagram-design/references/import-drawio.md") +VERIFIER = Path("scripts/verify-drawio-import.py") + + +def run_verifier(root: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + [sys.executable, str(root / VERIFIER)], + cwd=root, + capture_output=True, + text=True, + encoding="utf-8", + errors="replace", + ) + + +def main() -> int: + with tempfile.TemporaryDirectory(prefix="diagram-design-drawio-test-") as tmp_dir: + clone = Path(tmp_dir) / "repo" + shutil.copytree( + ROOT, + clone, + ignore=shutil.ignore_patterns(".git", "__pycache__"), + ) + + reference = clone / REFERENCE + stale_name = "/diagram-design:import" + valid_name = "/diagram-design:import-drawio" + text = reference.read_text(encoding="utf-8") + if valid_name not in text: + raise AssertionError("test fixture lacks the valid slash name") + + valid = run_verifier(clone) + if valid.returncode != 0: + raise AssertionError( + f"valid slash command failed verification:\n{valid.stdout}\n{valid.stderr}" + ) + + reference.write_text(text.replace(valid_name, stale_name), encoding="utf-8") + stale = run_verifier(clone) + if stale.returncode == 0: + raise AssertionError("stale slash command unexpectedly passed verification") + if "slash command" not in stale.stderr: + raise AssertionError( + f"stale slash command lacked a focused diagnostic:\n{stale.stderr}" + ) + + print("OK: draw.io verifier rejects a stale slash command name") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/verify-drawio-import.py b/scripts/verify-drawio-import.py index 3ae9ce0..56b4e4e 100644 --- a/scripts/verify-drawio-import.py +++ b/scripts/verify-drawio-import.py @@ -341,6 +341,16 @@ def check_security_and_limits(tmp: Path) -> None: def check_docs() -> None: import_text = IMPORT_REF.read_text(encoding="utf-8") + expected_slash_command = f"/diagram-design:{COMMAND.stem}" + documented_slash_commands = set( + re.findall(r"`(/diagram-design:[a-z0-9-]+)`", import_text) + ) + if documented_slash_commands != {expected_slash_command}: + rendered = ", ".join(sorted(documented_slash_commands)) or "none" + fail( + "import-drawio.md slash command does not match " + f"{COMMAND.name}: expected {expected_slash_command}, found {rendered}" + ) for needle in ( "drawio_extract.py", "output-spec.md", diff --git a/skills/diagram-design/references/import-drawio.md b/skills/diagram-design/references/import-drawio.md index 9a716f7..262af0d 100644 --- a/skills/diagram-design/references/import-drawio.md +++ b/skills/diagram-design/references/import-drawio.md @@ -6,7 +6,7 @@ Turn a `.drawio` file into an editorial-quality diagram at the format, size, and ## Trigger -Load this file when the user points at a `.drawio`, `.drawio.xml`, `.drawio.png`, or `.drawio.svg` file and wants a diagram out of it — "convert this drawio", "redraw this diagram", "make this presentable", "この drawio をきれいにして", or the `/diagram-design:import` slash command. +Load this file when the user points at a `.drawio`, `.drawio.xml`, `.drawio.png`, or `.drawio.svg` file and wants a diagram out of it — "convert this drawio", "redraw this diagram", "make this presentable", "この drawio をきれいにして", or the `/diagram-design:import-drawio` slash command. ---