Skip to content

Add Mermaid diagram rendering to kitty-image#1

Merged
whallil merged 1 commit into
mainfrom
worktree-mermaid-diagrams
May 29, 2026
Merged

Add Mermaid diagram rendering to kitty-image#1
whallil merged 1 commit into
mainfrom
worktree-mermaid-diagrams

Conversation

@whallil

@whallil whallil commented May 29, 2026

Copy link
Copy Markdown
Owner

Adds first-class Mermaid support to the kitty-image skill: turn a Mermaid definition (flowchart, sequence, state, workflow, …) into an inline terminal image.

What's new

  • mermaid.py — renders a Mermaid definition to PNG, then hands off to show.py for display. Reads a .mmd file or stdin (-).
  • Local-first for privacy — uses mmdc if on PATH, else npx -p @mermaid-js/mermaid-cli mmdc pointed at an already-installed Chrome (no Puppeteer Chromium download). The diagram text never leaves the machine unless --remote is passed (renders via mermaid.ink, pako envelope).
  • Defaults (--theme dark, --bg #10121a, --scale 2) match the existing Pillow chart aesthetic. Exit codes 10–13.
  • Docs: SKILL.md triggering + section + exit-code table, README.md section, plugin.json0.2.0, CHANGELOG [0.2.0], CI now compiles mermaid.py, and a design spec under docs/.

Verification

  • Every renderer assumption was verified empirically on a real box (which corrected two stale upstream doc claims: mermaid.ink still accepts plain base64; PUPPETEER_EXECUTABLE_PATH does work).
  • All paths tested: local/remote render, exit 10/11/12/13, stdin, empty input, bad syntax, unencoded background, unwritable output.
  • Passed an adversarial multi-lens review with per-finding verification; all confirmed findings fixed and re-tested.

Render a Mermaid definition to a PNG and display it inline, reusing show.py
for the display half. Local-first for privacy: uses `mmdc` if present, else
`npx -p @mermaid-js/mermaid-cli mmdc` pointed at an already-installed Chrome
(no Puppeteer Chromium download). The diagram text never leaves the machine
unless `--remote` is passed, which renders via the public mermaid.ink service
(pako-encoded envelope, dark theme).

- New skills/kitty-image/mermaid.py: .mmd or stdin input; --theme/--bg/--scale/
  --out/--no-show/--pts flags; dedicated exit codes 10-13. URL-encodes remote
  query params and guards output writes against uncaught errors.
- SKILL.md: mermaid triggering, a "Mermaid workflow diagrams" section, and an
  exit-code table (also documents the pre-existing show.py code 6).
- README: mermaid usage section and optional-dependency note.
- plugin.json -> 0.2.0 + keywords; CHANGELOG [0.2.0]; CI now compiles mermaid.py.
- Design spec under docs/superpowers/specs/.

Every renderer assumption was verified empirically (which corrected two stale
upstream doc claims), and the new script passed an adversarial multi-lens
review with per-finding verification.
@whallil
whallil merged commit 6815460 into main May 29, 2026
2 checks passed
@whallil
whallil deleted the worktree-mermaid-diagrams branch May 29, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant