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.
fix(export): restore the svg-only/png-only exclusion rule in commands (#449)
Twot4f4489a294a7
diff --git a/commands/export-diagram.md b/commands/export-diagram.mdindex 0a25630..2fe7404 100644--- a/commands/export-diagram.md+++ b/commands/export-diagram.md@@ -17,7 +17,7 @@ Full argument string: `$ARGUMENTS`- **With no format flags, or with `--svg-only`/`--png-only`/`--scale`/`--output` but no `--registry`:** produce **both** `.svg` and `.png` next to the source (e.g. `diagram.html` → `diagram.svg` + `diagram.png`).- PNG renders at `device_scale_factor=2`.-- **`--registry` given by itself, with neither `--svg-only` nor `--png-only` also present, produces *only* the registry JSON.** The SVG/PNG defaults above do not also apply, and Playwright is never required for a registry-only call. To get an image alongside the registry, add `--svg-only` and/or `--png-only` explicitly.+- **`--registry` given by itself, with neither `--svg-only` nor `--png-only` also present, produces *only* the registry JSON.** The SVG/PNG defaults above do not also apply, and Playwright is never required for a registry-only call. To get an image alongside the registry, add `--svg-only` or `--png-only` explicitly.## Flags@@ -25,7 +25,7 @@ Full argument string: `$ARGUMENTS`- `--png-only` — emit only the PNG.- `--scale=N` — override the PNG device scale factor with a finite number from `1` to `4`, including fractional values such as `1.25`. Default `2`.- `--output=<path>` — override the output base path; the format extension is appended. Applies to both formats when both are produced.-- `--registry` — emit `<basename>.registry.json`, a metadata sidecar of every block's `data-block-*` attributes. Follows [`skills/diagram-design/references/export-registry.md`](../skills/diagram-design/references/export-registry.md), a procedure independent of the SVG/PNG rasterization above — it never needs Playwright. Used alone (see Defaults), it is the *only* output produced. Combine with `--svg-only` and/or `--png-only` to also produce an image in the same call.+- `--registry` — emit `<basename>.registry.json`, a metadata sidecar of every block's `data-block-*` attributes. Follows [`skills/diagram-design/references/export-registry.md`](../skills/diagram-design/references/export-registry.md), a procedure independent of the SVG/PNG rasterization above — it never needs Playwright. Used alone (see Defaults), it is the *only* output produced. Combine with `--svg-only` or `--png-only` to also produce an image in the same call.## Required behaviour@@ -34,7 +34,8 @@ Full argument string: `$ARGUMENTS`3. **Source has no `<svg>` block** → refuse and tell the user; don't write anything.4. **PNG requested but Playwright not installed** → surface the install instruction from the reference verbatim and stop. Do **not** auto-install.5. **PNG requested with a non-numeric or non-finite `--scale`, or a value outside the inclusive 1–4 range** → reject. Fractional values within that range are valid.-6. **`--registry` requested but source has no `data-block-id` attributes** → refuse and tell the user; don't emit an empty or partial registry file. Per the export-registry reference's edge-case section.-7. **`--registry` is the only flag given** (no `--svg-only`/`--png-only`) → emit only the registry JSON. Do not also produce SVG/PNG, and do not check for Playwright — a registry-only call must succeed on a host that doesn't have it installed at all.+6. **Both `--svg-only` and `--png-only` supplied** → reject them as mutually exclusive.+7. **`--registry` requested but source has no `data-block-id` attributes** → refuse and tell the user; don't emit an empty or partial registry file. Per the export-registry reference's edge-case section.+8. **`--registry` is the only flag given** (no `--svg-only`/`--png-only`) → emit only the registry JSON. Do not also produce SVG/PNG, and do not check for Playwright — a registry-only call must succeed on a host that doesn't have it installed at all.After producing the outputs, report the file paths and sizes back to the user.diff --git a/prompts/export-diagram.md b/prompts/export-diagram.mdindex e5d497c..51fa9c6 100644--- a/prompts/export-diagram.md+++ b/prompts/export-diagram.md@@ -11,7 +11,7 @@ Full argument string: `$ARGUMENTS`- With no format flags, or with `--svg-only`/`--png-only`/`--scale`/`--output` but no `--registry`: produce both `.svg` and `.png` next to source (for example, `diagram.html` → `diagram.svg` + `diagram.png`).- Render PNG at `device_scale_factor=2`.-- `--registry` given alone, with neither `--svg-only` nor `--png-only` also present, produces only the registry JSON — the SVG/PNG defaults above do not apply, and Playwright is never required. Add `--svg-only` and/or `--png-only` explicitly to also get an image.+- `--registry` given alone, with neither `--svg-only` nor `--png-only` also present, produces only the registry JSON — the SVG/PNG defaults above do not apply, and Playwright is never required. Add `--svg-only` or `--png-only` explicitly to also get an image.## Flags@@ -19,7 +19,7 @@ Full argument string: `$ARGUMENTS`- `--png-only` — emit PNG only.- `--scale=N` — override PNG device scale factor with a finite number from `1` to `4`, including fractional values such as `1.25`. Default `2`.- `--output=<path>` — override output base path; append format extension.-- `--registry` — emit `<basename>.registry.json`, a metadata sidecar of every block's `data-block-*` attributes. Never needs Playwright. Used alone (see Defaults) it is the only output; combine with `--svg-only` and/or `--png-only` to also produce an image.+- `--registry` — emit `<basename>.registry.json`, a metadata sidecar of every block's `data-block-*` attributes. Never needs Playwright. Used alone (see Defaults) it is the only output; combine with `--svg-only` or `--png-only` to also produce an image.## Required behaviordiff --git a/scripts/test-verify-docs-sync.py b/scripts/test-verify-docs-sync.pyindex 81da257..e2c5fcc 100644--- a/scripts/test-verify-docs-sync.py+++ b/scripts/test-verify-docs-sync.py@@ -552,6 +552,77 @@ def split_route_error(heading: str, target: str) -> str:)+def check_export_surface_parity(verify) -> None:+ with tempfile.TemporaryDirectory(prefix="verify-docs-sync-export-") as temp_dir:+ fake_root = Path(temp_dir)+ fake_cmd = fake_root / "commands/export-diagram.md"+ fake_prompt = fake_root / "prompts/export-diagram.md"+ fake_cmd.parent.mkdir(parents=True)+ fake_prompt.parent.mkdir(parents=True)++ fake_cmd.write_text(+ (ROOT / "commands/export-diagram.md").read_text(encoding="utf-8"),+ encoding="utf-8",+ )+ fake_prompt.write_text(+ (ROOT / "prompts/export-diagram.md").read_text(encoding="utf-8"),+ encoding="utf-8",+ )++ errors: list[str] = []+ verify.check_export_surface_parity(errors, fake_root)+ if errors:+ raise AssertionError(f"shipped export surfaces failed: {errors}")++ broken_cmd = fake_cmd.read_text(encoding="utf-8").replace(+ "Both `--svg-only` and `--png-only` supplied",+ "Both format flags supplied",+ )+ fake_cmd.write_text(broken_cmd, encoding="utf-8")+ errors = []+ verify.check_export_surface_parity(errors, fake_root)+ if not any("commands/export-diagram.md" in err for err in errors):+ raise AssertionError(f"missing commands/export-diagram.md parity error: {errors}")+ print("OK export surface parity: missing command rule caught")++ fake_cmd.write_text(+ (ROOT / "commands/export-diagram.md").read_text(encoding="utf-8"),+ encoding="utf-8",+ )+ broken_prompt = fake_prompt.read_text(encoding="utf-8").replace(+ "Both `--svg-only` and `--png-only` supplied",+ "Both format flags supplied",+ )+ fake_prompt.write_text(broken_prompt, encoding="utf-8")+ errors = []+ verify.check_export_surface_parity(errors, fake_root)+ if not any("prompts/export-diagram.md" in err for err in errors):+ raise AssertionError(f"missing prompts/export-diagram.md parity error: {errors}")+ print("OK export surface parity: missing prompt rule caught")++ fake_prompt.write_text(+ (ROOT / "prompts/export-diagram.md").read_text(encoding="utf-8"),+ encoding="utf-8",+ )+ fake_cmd.unlink()+ errors = []+ verify.check_export_surface_parity(errors, fake_root)+ if errors != ["export surface is missing: commands/export-diagram.md"]:+ raise AssertionError(f"missing commands/export-diagram.md was not caught: {errors}")+ print("OK export surface parity: missing commands file caught")++ fake_cmd.write_text(+ (ROOT / "commands/export-diagram.md").read_text(encoding="utf-8"),+ encoding="utf-8",+ )+ fake_prompt.unlink()+ errors = []+ verify.check_export_surface_parity(errors, fake_root)+ if errors != ["export surface is missing: prompts/export-diagram.md"]:+ raise AssertionError(f"missing prompts/export-diagram.md was not caught: {errors}")+ print("OK export surface parity: missing prompts file caught")++def check_split_routes(verify) -> None:"""Each SKILL.md section the ADR 0004 split thinned still routes to its content."""skill = verify.SKILL.read_text(encoding="utf-8")@@ -2101,6 +2172,7 @@ diagram-design/check_size_preset_surfaces(verify)check_split_type_ramp(verify)check_split_routes(verify)+ check_export_surface_parity(verify)print("PASS: docs sync checks references, style-guide anchors, asset citations, "diff --git a/scripts/verify-docs-sync.py b/scripts/verify-docs-sync.pyindex 8241864..a746f41 100644--- a/scripts/verify-docs-sync.py+++ b/scripts/verify-docs-sync.py@@ -1752,6 +1752,29 @@ def check_title_fallback_order(errors: list[str], root: Path) -> None:)+def check_export_surface_parity(errors: list[str], root: Path) -> None:+ """commands/export-diagram.md and prompts/export-diagram.md must both carry the mutual-exclusion rule."""+ command_path = root / "commands/export-diagram.md"+ prompt_path = root / "prompts/export-diagram.md"+ if not command_path.is_file():+ errors.append("export surface is missing: commands/export-diagram.md")+ return+ if not prompt_path.is_file():+ errors.append("export surface is missing: prompts/export-diagram.md")+ return+ command_text = command_path.read_text(encoding="utf-8")+ prompt_text = prompt_path.read_text(encoding="utf-8")+ rule_re = re.compile(r"--svg-only.*--png-only.*mutually exclusive", re.IGNORECASE)+ if not rule_re.search(command_text):+ errors.append(+ "commands/export-diagram.md missing `--svg-only` and `--png-only` mutual-exclusion rule"+ )+ if not rule_re.search(prompt_text):+ errors.append(+ "prompts/export-diagram.md missing `--svg-only` and `--png-only` mutual-exclusion rule"+ )++def main() -> int:errors: list[str] = []check_description(errors)@@ -1797,6 +1820,7 @@ def main() -> int:check_size_preset_surfaces(errors, ROOT)check_export_font_parity(errors, ROOT)check_title_fallback_order(errors, ROOT)+ check_export_surface_parity(errors, ROOT)if errors:print("FAIL docs sync")for error in errors:@@ -1810,7 +1834,7 @@ def main() -> int:"High-Level invariants, onboarding trust boundary, Line dark-skin contract, ""Loop station origin, ""font-link parity, title fallback order, type-ramp contract, registered legacy "- "type sizes, split routing"+ "type sizes, split routing, export surface parity")return 0