AI Agent Skill to generate and render beautiful Mermaid diagrams as SVG or terminal ASCII — 15 themes, 6 diagram types, batch CLI, no browser.
JavaScript agent-skillsai-agentsascii-artclaude-codecodexcursordiagram-generatordocumentationflowchartmermaidmermaid-diagramskillssvg
Initial commit: Beautiful-Mermaid Skill v1.0.0
Beautiful-Mermaid Devf4d57ca739d7
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..6442ebf--- /dev/null+++ b/.gitignore@@ -0,0 +1,62 @@+# macOS+.DS_Store+.AppleDouble+.LSOverride+*.swp+.DS_Store?++# Python+__pycache__/+*.py[cod]+*$py.class+*.so+.Python+build/+develop-eggs/+dist/+downloads/+eggs/+.eggs/+lib/+lib64/+parts/+sdist/+var/+wheels/+pip-wheel-metadata/+share/python-wheels/+*.egg-info/+.installed.cfg+*.egg+MANIFEST++# IDEs+.vscode/+.idea/+*.swp+*.swo+*~+.project+.pydevproject+.settings/++# Test outputs+/test-output/+/output/+*.svg+*.txt+!requirements.txt++# Node.js+node_modules/+npm-debug.log*+yarn-debug.log*+yarn-error.log*++# Environment files+.env+.env.local+.env.*.local++# OS+Thumbs.dbdiff --git a/LICENSE b/LICENSEnew file mode 100644index 0000000..bcd4d77--- /dev/null+++ b/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2026 Beautiful-Mermaid Contributors++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/README.md b/README.mdnew file mode 100644index 0000000..81a9114--- /dev/null+++ b/README.md@@ -0,0 +1,85 @@+# Beautiful-Mermaid Skill for Claude++## 简介+为 Claude AI 提供的 Mermaid 图表渲染 Skill,支持 SVG 和 ASCII 双格式输出。++## 功能特性+- 📊 SVG 和 ASCII 渲染+- 🎨 14 个精美主题(tokyo-night, dracula, github-dark...)+- 📈 5 种图表类型(Flowchart, Sequence, State, Class, ER)+- ⚡ 批量并行渲染+- 📚 完整的模板和文档++## 安装步骤++### 1. 安装到 Claude Skills 目录+```bash+cd ~/.claude/skills+git clone https://github.com/[用户名]/beautiful-mermaid.git+```++### 2. 安装依赖+```bash+# 安装 Node.js(如果未安装)+# macOS: brew install node+# Ubuntu: sudo apt install nodejs npm++# 安装 beautiful-mermaid+npm install -g beautiful-mermaid+```++### 3. 验证安装+```bash+cd beautiful-mermaid+python3 scripts/list_themes.py+```++## 快速开始++### 列出可用主题+```bash+python3 scripts/list_themes.py+```++### 渲染单个图表+```bash+python3 scripts/render_mermaid.py \+ --input diagram.mmd \+ --output output.svg \+ --theme tokyo-night+```++### 批量渲染+```bash+python3 scripts/batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./output \+ --theme dracula+```++## 使用示例++查看 `assets/example_diagrams/` 目录下的 5 个模板文件:+- `flowchart.mmd` - 流程图+- `sequence.mmd` - 时序图+- `state.mmd` - 状态图+- `class.mmd` - 类图+- `er.mmd` - ER 图++## 完整文档++详细使用指南请参阅 [SKILL.md](SKILL.md)++## 系统要求++- Python 3.7++- Node.js 14++- npm 或 yarn++## 许可证++MIT License++## 致谢++基于 [beautiful-mermaid](https://github.com/lukilabs/beautiful-mermaid) 项目diff --git a/SKILL.md b/SKILL.mdnew file mode 100644index 0000000..17a7b4a--- /dev/null+++ b/SKILL.md@@ -0,0 +1,520 @@+---+name: beautiful-mermaid+description: |+ Render beautiful Mermaid diagrams as SVG or ASCII art using the beautiful-mermaid library.+ Supports 15+ themes, 5 diagram types (flowchart, sequence, state, class, ER), and ultra-fast rendering.++ Use this skill when:+ 1. User asks to "render a mermaid diagram" or provides .mmd files+ 2. User requests "create a flowchart/sequence diagram/state diagram"+ 3. User wants to "apply a theme" or "beautify a diagram"+ 4. User needs to "batch process multiple diagrams"+ 5. User mentions "ASCII diagram" or "terminal-friendly diagram"+ 6. User wants to visualize architecture, workflows, or data models+---++# Beautiful Mermaid++Render stunning, professionally-styled Mermaid diagrams with one command. Supports SVG for web/docs and ASCII for terminals.++## Quick Start++### Render a Single Diagram++**From a file:**+```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --output diagram.svg \+ --format svg \+ --theme tokyo-night+```++**From user-provided Mermaid code:**+1. Save the code to a `.mmd` file+2. Run the render script with desired theme++### Batch Render Multiple Diagrams++```bash+python scripts/batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./output \+ --format svg \+ --theme dracula \+ --workers 4+```++### ASCII Output (Terminal-Friendly)++```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --format ascii \+ --use-ascii+```++---++## Workflow Decision Tree++**Step 1: What does the user want?**+- **Render existing Mermaid code** → Go to [Rendering](#rendering-diagrams)+- **Create new diagram** → Go to [Creating](#creating-diagrams)+- **Apply/change theme** → Go to [Theming](#theming)+- **Batch process** → Go to [Batch Rendering](#batch-rendering)++**Step 2: Choose output format**+- **SVG** (web, docs, presentations) → `--format svg`+- **ASCII** (terminal, logs, plain text) → `--format ascii`++**Step 3: Select theme**+- **Dark mode docs** → `tokyo-night` (recommended)+- **Light mode docs** → `github-light`+- **Vibrant colors** → `dracula`+- **See all themes** → Run `python scripts/list_themes.py`++---++## Rendering Diagrams++### From File++When user provides a `.mmd` file or Mermaid code block:++1. **Save to file** (if code block):+ ```bash+ cat > diagram.mmd << 'EOF'+ flowchart LR+ A[Start] --> B[End]+ EOF+ ```++2. **Render with theme**:+ ```bash+ python scripts/render_mermaid.py \+ --input diagram.mmd \+ --output diagram.svg \+ --theme tokyo-night+ ```++3. **Verify output**:+ - SVG: Open in browser or embed in docs+ - ASCII: Display in terminal++### Output Formats++**SVG (Scalable Vector Graphics)**+- Best for: Web pages, documentation, presentations+- Features: Full color support, transparency, scalable+- Usage: `--format svg --output diagram.svg`++**ASCII (Terminal Art)**+- Best for: Terminal output, plain text logs, README files+- Features: Pure text, works anywhere, no dependencies+- Usage: `--format ascii` (prints to stdout)+- Options:+ - `--use-ascii` - Use pure ASCII (no Unicode)+ - `--padding-x 5` - Horizontal spacing+ - `--padding-y 5` - Vertical spacing++### Advanced Options++**Custom Colors** (overrides theme):+```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --bg "#1a1b26" \+ --fg "#a9b1d6" \+ --accent "#7aa2f7" \+ --output custom.svg+```++**Transparent Background**:+```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --transparent \+ --output transparent.svg+```++**Custom Font**:+```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --font "JetBrains Mono" \+ --output custom-font.svg+```++---++## Creating Diagrams++### Using Templates++**Step 1: List available templates**+```bash+ls assets/example_diagrams/+# flowchart.mmd sequence.mmd state.mmd class.mmd er.mmd+```++**Step 2: Copy and modify**+```bash+cp assets/example_diagrams/flowchart.mmd my-workflow.mmd+# Edit my-workflow.mmd with user requirements+```++**Step 3: Render**+```bash+python scripts/render_mermaid.py \+ --input my-workflow.mmd \+ --output my-workflow.svg \+ --theme github-dark+```++### Diagram Type Reference++For detailed syntax and best practices, see [DIAGRAM_TYPES.md](references/DIAGRAM_TYPES.md).++**Quick reference:**++**Flowchart** - Processes, workflows, decision trees+```mermaid+flowchart LR+ A[Start] --> B{Decision}+ B -->|Yes| C[Action]+ B -->|No| D[End]+```++**Sequence** - API calls, interactions, message flows+```mermaid+sequenceDiagram+ User->>Server: Request+ Server-->>User: Response+```++**State** - Application states, lifecycle, FSM+```mermaid+stateDiagram-v2+ [*] --> Idle+ Idle --> Loading+ Loading --> [*]+```++**Class** - Object models, architecture, relationships+```mermaid+classDiagram+ User --> Post: creates+ Post --> Comment: has+```++**ER** - Database schema, data models+```mermaid+erDiagram+ USER ||--o{ ORDER : places+ ORDER ||--|{ ORDER_ITEM : contains+```++### From User Requirements++**Step 1: Identify diagram type**+- **Process/workflow** → Flowchart+- **API/interaction** → Sequence+- **States/lifecycle** → State+- **Object model** → Class+- **Database** → ER++**Step 2: Create diagram file**+```bash+cat > user-diagram.mmd << 'EOF'+# [Insert generated Mermaid code]+EOF+```++**Step 3: Render and iterate**+```bash+python scripts/render_mermaid.py \+ --input user-diagram.mmd \+ --output preview.svg \+ --theme tokyo-night++# Review with user, edit diagram.mmd if needed, re-render+```++---++## Theming++### List Available Themes++```bash+python scripts/list_themes.py+```++**Output:**+```+Available Beautiful-Mermaid Themes:++ 1. zinc-light+ 2. zinc-dark+ 3. tokyo-night+ 4. tokyo-night-storm+ 5. tokyo-night-light+ 6. catppuccin-mocha+ 7. catppuccin-latte+ 8. nord+ 9. nord-light+10. dracula+11. github-dark+12. github-light+13. solarized-dark+14. solarized-light+15. one-dark++Total: 15 themes+```++### Theme Selection Guide++**For dark mode documentation:**+- `tokyo-night` ⭐ - Modern, developer-friendly+- `github-dark` - Familiar GitHub style+- `dracula` - Vibrant, high contrast+- `nord` - Cool, minimalist++**For light mode documentation:**+- `github-light` - Clean, professional+- `zinc-light` - High contrast, printable+- `catppuccin-latte` - Warm, friendly++**Detailed theme information:** See [THEMES.md](references/THEMES.md)++### Apply Theme to Diagram++```bash+python scripts/render_mermaid.py \+ --input diagram.mmd \+ --output themed.svg \+ --theme tokyo-night+```++### Compare Themes++Render the same diagram with multiple themes:+```bash+for theme in tokyo-night dracula github-dark; do+ python scripts/render_mermaid.py \+ --input diagram.mmd \+ --output "diagram-${theme}.svg" \+ --theme "$theme"+done+```++---++## Batch Rendering++### Batch Render Directory++**Step 1: Organize diagrams**+```bash+diagrams/+├── architecture.mmd+├── workflow.mmd+└── database.mmd+```++**Step 2: Batch render**+```bash+python scripts/batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./rendered \+ --format svg \+ --theme tokyo-night \+ --workers 4+```++**Output:**+```+Found 3 diagram(s) to render...+✓ architecture.mmd+✓ workflow.mmd+✓ database.mmd++3/3 diagrams rendered successfully+```++### Batch with Multiple Formats++Render both SVG and ASCII:+```bash+# SVG for docs+python scripts/batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./svg \+ --format svg \+ --theme github-dark++# ASCII for README+python scripts/batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./ascii \+ --format ascii \+ --use-ascii+```++### Performance Options++- `--workers N` - Parallel rendering (default: 4)+- Recommended: `--workers 8` for 10+ diagrams++---++## Common Use Cases++### 1. Architecture Diagram for Documentation++```bash+# User provides architecture description+# → Create flowchart.mmd+# → Render with professional theme++python scripts/render_mermaid.py \+ --input architecture.mmd \+ --output docs/architecture.svg \+ --theme github-dark \+ --transparent+```++### 2. API Sequence Diagram++```bash+# User describes API flow+# → Create sequence.mmd+# → Render with clear theme++python scripts/render_mermaid.py \+ --input api-flow.mmd \+ --output api-sequence.svg \+ --theme tokyo-night+```++### 3. Database Schema Visualization++```bash+# User provides table definitions+# → Create er.mmd+# → Render for database docs++python scripts/render_mermaid.py \+ --input schema.mmd \+ --output database-schema.svg \+ --theme dracula+```++### 4. Terminal-Friendly Workflow++```bash+# For README or terminal display+python scripts/render_mermaid.py \+ --input workflow.mmd \+ --format ascii \+ --use-ascii > workflow.txt+```++### 5. Presentation Slides++```bash+# High-contrast for projectors+python scripts/render_mermaid.py \+ --input slides-diagram.mmd \+ --output presentation.svg \+ --theme zinc-light+```++---++## Troubleshooting++### Node.js Not Found+```+Error: Node.js not found. Please install Node.js to use this tool.+```+**Solution:** Install Node.js from https://nodejs.org/++### beautiful-mermaid Not Installed+```+Error: Cannot find module 'beautiful-mermaid'+```+**Solution:**+```bash+npm install -g beautiful-mermaid+```++### Invalid Mermaid Syntax+```+Error: Parse error on line 3+```+**Solution:**+1. Validate syntax against [DIAGRAM_TYPES.md](references/DIAGRAM_TYPES.md)+2. Test on https://mermaid.live/+3. Check for common errors:+ - Missing spaces in `A --> B`+ - Incorrect node shape syntax+ - Unclosed brackets++### File Not Found+```+Error: Input file not found: diagram.mmd+```+**Solution:** Verify file path is correct, use absolute path if needed++---++## Resources++### scripts/+Executable Python and Node.js scripts for rendering operations:+- `render_mermaid.py` - Main rendering script+- `batch_render.py` - Batch processing script+- `list_themes.py` - Theme listing utility+- `render_helper.mjs` - Node.js bridge to beautiful-mermaid++### references/+Documentation to inform diagram creation:+- `THEMES.md` - Detailed theme reference with examples+- `DIAGRAM_TYPES.md` - Comprehensive syntax guide for all diagram types+- `api_reference.md` - beautiful-mermaid API documentation++### assets/+Template files for quick diagram creation:+- `example_diagrams/flowchart.mmd` - Flowchart template+- `example_diagrams/sequence.mmd` - Sequence diagram template+- `example_diagrams/state.mmd` - State diagram template+- `example_diagrams/class.mmd` - Class diagram template+- `example_diagrams/er.mmd` - ER diagram template++---++## Tips & Best Practices++### Performance+- Batch render for 3+ diagrams (parallel processing)+- Keep diagrams under 50 nodes for fast rendering+- Use ASCII for quick previews++### Quality+- Use `tokyo-night` or `github-dark` for technical docs+- Add transparency for dark/light mode compatibility: `--transparent`+- Test theme in target environment before batch rendering++### Workflow+1. Start with templates from `assets/example_diagrams/`+2. Iterate with user feedback+3. Apply theme last+4. Render both SVG (docs) and ASCII (README) if needed++### Accessibility+- Use high-contrast themes for presentations+- Add text labels to all connections+- Avoid color-only information encodingdiff --git a/assets/example_diagrams/class.mmd b/assets/example_diagrams/class.mmdnew file mode 100644index 0000000..7ae62ad--- /dev/null+++ b/assets/example_diagrams/class.mmd@@ -0,0 +1,29 @@+classDiagram+ class User {+ +String id+ +String name+ +String email+ +login()+ +logout()+ }++ class Post {+ +String id+ +String title+ +String content+ +Date createdAt+ +publish()+ +delete()+ }++ class Comment {+ +String id+ +String text+ +Date createdAt+ +edit()+ +delete()+ }++ User "1" --> "*" Post: creates+ Post "1" --> "*" Comment: has+ User "1" --> "*" Comment: writesdiff --git a/assets/example_diagrams/er.mmd b/assets/example_diagrams/er.mmdnew file mode 100644index 0000000..779a0a8--- /dev/null+++ b/assets/example_diagrams/er.mmd@@ -0,0 +1,32 @@+erDiagram+ USER ||--o{ ORDER : places+ USER {+ string id PK+ string name+ string email+ date created_at+ }++ ORDER ||--|{ ORDER_ITEM : contains+ ORDER {+ string id PK+ string user_id FK+ decimal total+ date created_at+ }++ ORDER_ITEM }o--|| PRODUCT : references+ ORDER_ITEM {+ string id PK+ string order_id FK+ string product_id FK+ int quantity+ decimal price+ }++ PRODUCT {+ string id PK+ string name+ decimal price+ int stock+ }diff --git a/assets/example_diagrams/flowchart.mmd b/assets/example_diagrams/flowchart.mmdnew file mode 100644index 0000000..8a78d0a--- /dev/null+++ b/assets/example_diagrams/flowchart.mmd@@ -0,0 +1,8 @@+flowchart LR+ Start([Start]) --> Input[/Input Data/]+ Input --> Process[Process Data]+ Process --> Decision{Valid?}+ Decision -->|Yes| Success[Success]+ Decision -->|No| Error[Error Handler]+ Error --> Input+ Success --> End([End])diff --git a/assets/example_diagrams/sequence.mmd b/assets/example_diagrams/sequence.mmdnew file mode 100644index 0000000..e6d73e1--- /dev/null+++ b/assets/example_diagrams/sequence.mmd@@ -0,0 +1,12 @@+sequenceDiagram+ participant User+ participant Client+ participant Server+ participant Database++ User->>Client: Request Data+ Client->>Server: API Call+ Server->>Database: Query+ Database-->>Server: Result+ Server-->>Client: Response+ Client-->>User: Display Datadiff --git a/assets/example_diagrams/state.mmd b/assets/example_diagrams/state.mmdnew file mode 100644index 0000000..38800cb--- /dev/null+++ b/assets/example_diagrams/state.mmd@@ -0,0 +1,8 @@+stateDiagram-v2+ [*] --> Idle+ Idle --> Loading: Start Request+ Loading --> Success: Data Received+ Loading --> Error: Request Failed+ Success --> Idle: Reset+ Error --> Idle: Retry+ Error --> [*]: Abortdiff --git a/references/DIAGRAM_TYPES.md b/references/DIAGRAM_TYPES.mdnew file mode 100644index 0000000..a0883ad--- /dev/null+++ b/references/DIAGRAM_TYPES.md@@ -0,0 +1,328 @@+# Mermaid Diagram Types Reference++## Flowchart / Graph++### Basic Syntax+```mermaid+flowchart LR+ A[Node] --> B[Another Node]+ B --> C{Decision}+ C -->|Yes| D[Result 1]+ C -->|No| E[Result 2]+```++### Node Shapes+- `[Text]` - Rectangle+- `([Text])` - Stadium (rounded)+- `[[Text]]` - Subroutine (double border)+- `[(Text)]` - Cylindrical (database)+- `((Text))` - Circle+- `>Text]` - Asymmetric shape+- `{Text}` - Rhombus (decision)+- `{{Text}}` - Hexagon+- `[/Text/]` - Parallelogram+- `[\Text\]` - Trapezoid (alt)++### Connections+- `-->` - Arrow+- `---` - Line+- `-.->` - Dotted arrow+- `==>` - Thick arrow+- `--text-->` - Arrow with text+- `-->|text|` - Arrow with text (alt syntax)++### Direction+- `LR` - Left to Right+- `RL` - Right to Left+- `TB` / `TD` - Top to Bottom / Top Down+- `BT` - Bottom to Top++### Best Practices+- Use `LR` direction for wide screens+- Keep decision nodes distinct with `{}` shape+- Use stadium shapes `([])` for start/end+- Limit nesting depth to 3 levels+- Group related nodes visually++---++## Sequence Diagram++### Basic Syntax+```mermaid+sequenceDiagram+ participant A as Alice+ participant B as Bob++ A->>B: Hello Bob+ B-->>A: Hi Alice+ Note right of B: Bob is thinking+ A->>B: Another message+```++### Participants+```mermaid+sequenceDiagram+ participant A+ actor B+ participant C+```++### Message Types+- `->>` - Solid line arrow+- `-->>` - Dotted line arrow+- `-x` - Solid line with cross+- `--x` - Dotted line with cross+- `-)` - Solid line with open arrow+- `--)` - Dotted line with open arrow++### Activations+```mermaid+sequenceDiagram+ A->>+B: Request+ B-->>-A: Response+```++### Notes+```mermaid+sequenceDiagram+ Note left of A: Note on left+ Note right of B: Note on right+ Note over A,B: Note spanning both+```++### Loops & Alt+```mermaid+sequenceDiagram+ loop Every minute+ A->>B: Ping+ end++ alt Success+ B-->>A: OK+ else Failure+ B-->>A: Error+ end+```++### Best Practices+- Use meaningful participant names+- Add notes for complex logic+- Keep sequence linear (avoid too many branches)+- Use activations to show processing time+- Limit to 5-7 participants for clarity++---++## State Diagram++### Basic Syntax+```mermaid+stateDiagram-v2+ [*] --> State1+ State1 --> State2: Transition+ State2 --> [*]+```++### Composite States+```mermaid+stateDiagram-v2+ [*] --> Active++ state Active {+ [*] --> Running+ Running --> Paused+ Paused --> Running+ Running --> [*]+ }++ Active --> [*]+```++### Choice+```mermaid+stateDiagram-v2+ state if_state <<choice>>+ [*] --> if_state+ if_state --> State1: condition 1+ if_state --> State2: condition 2+```++### Concurrency+```mermaid+stateDiagram-v2+ [*] --> Active++ state Active {+ [*] --> Process1+ --+ [*] --> Process2+ }+```++### Notes+```mermaid+stateDiagram-v2+ State1 --> State2+ note right of State1+ Important note here+ end note+```++### Best Practices+- Start with `[*]` for initial state+- Use clear transition labels+- Limit composite state depth to 2 levels+- Group related states together+- Use choice nodes for complex branching++---++## Class Diagram++### Basic Syntax+```mermaid+classDiagram+ class ClassName {+ +String publicField+ -int privateField+ #bool protectedField+ ~String packageField++ +publicMethod()+ -privateMethod()+ #protectedMethod()+ ~packageMethod()+ }+```++### Visibility+- `+` Public+- `-` Private+- `#` Protected+- `~` Package/Internal++### Relationships+```mermaid+classDiagram+ ClassA --|> ClassB : Inheritance+ ClassC --* ClassD : Composition+ ClassE --o ClassF : Aggregation+ ClassG --> ClassH : Association+ ClassI -- ClassJ : Link (solid)+ ClassK ..> ClassL : Dependency+ ClassM ..|> ClassN : Realization+```++### Cardinality+```mermaid+classDiagram+ Customer "1" --> "*" Order+ Order "1" --> "1..*" OrderItem+```++### Abstract & Interface+```mermaid+classDiagram+ class AbstractClass {+ <<abstract>>+ +abstractMethod()*+ }++ class Interface {+ <<interface>>+ +method()+ }+```++### Best Practices+- Show only relevant attributes/methods+- Use inheritance sparingly+- Indicate cardinality on associations+- Group related classes visually+- Use interfaces for contracts++---++## ER Diagram++### Basic Syntax+```mermaid+erDiagram+ CUSTOMER ||--o{ ORDER : places+ ORDER ||--|{ ORDER_ITEM : contains+ PRODUCT ||--o{ ORDER_ITEM : "ordered in"+```++### Cardinality+- `||--||` - One to one+- `}o--o{` - Zero or more to zero or more+- `||--o{` - One to zero or more+- `}o--||` - Zero or more to one+- `||--|{` - One to one or more+- `}|--|{` - One or more to one or more++### Attributes+```mermaid+erDiagram+ CUSTOMER {+ string id PK+ string name+ string email UK+ date created_at+ }++ ORDER {+ string id PK+ string customer_id FK+ decimal total+ date order_date+ }+```++### Attribute Types+- Use standard SQL types: `string`, `int`, `decimal`, `date`, `bool`+- Add constraints: `PK` (Primary Key), `FK` (Foreign Key), `UK` (Unique Key)++### Best Practices+- Use UPPERCASE for entity names+- Use snake_case for attribute names+- Always mark PK and FK+- Show only essential attributes+- Keep relationship labels clear+- Limit to 6-8 entities per diagram++---++## General Best Practices++### Theming+- Use `tokyo-night` for dark mode documentation+- Use `github-light` for light mode documentation+- Use `dracula` for vibrant, colorful diagrams+- Use `monokai` for code-centric diagrams++### Performance+- Keep diagrams under 50 nodes for fast rendering+- Split complex diagrams into multiple files+- Use batch rendering for multiple diagrams++### Accessibility+- Add meaningful labels to all connections+- Use high-contrast themes+- Avoid relying solely on color to convey information+- Provide text descriptions for complex diagrams++### File Organization+```+diagrams/+├── architecture/+│ ├── system-overview.mmd+│ └── data-flow.mmd+├── workflows/+│ ├── user-registration.mmd+│ └── checkout-process.mmd+└── database/+ ├── schema-users.mmd+ └── schema-orders.mmd+```diff --git a/references/THEMES.md b/references/THEMES.mdnew file mode 100644index 0000000..52394af--- /dev/null+++ b/references/THEMES.md@@ -0,0 +1,477 @@+# Beautiful-Mermaid 主题参考++Beautiful-Mermaid 提供 15 个精心设计的内置主题,涵盖亮色和暗色方案。每个主题都基于两种核心颜色(背景 `bg` 和前景 `fg`),并可通过可选的丰富色彩进行增强。++## 快速选择指南++### 亮色主题+| 主题 | 背景 | 前景 | 用途 |+|------|------|------|------|+| `zinc-light` | #FFFFFF | 自动推导 | 通用亮色主题 |+| `tokyo-night-light` | #d5d6db | #34548a | 柔和亮色 |+| `catppuccin-latte` | #eff1f5 | #8839ef | 清爽亮色 |+| `nord-light` | #eceff4 | #5e81ac | 冰蓝亮色 |+| `github-light` | #ffffff | #0969da | GitHub 亮色风格 |+| `solarized-light` | #fdf6e3 | #268bd2 | Solarized 亮色 |++### 暗色主题+| 主题 | 背景 | 前景 | 用途 |+|------|------|------|------|+| `zinc-dark` | #18181B | 自动推导 | 通用暗色主题 |+| `tokyo-night` | #1a1b26 | #a9b1d6 | 现代日本风格 |+| `tokyo-night-storm` | #24283b | #a9b1d6 | Tokyo Night 变体 |+| `catppuccin-mocha` | #1e1e2e | #cba6f7 | 温暖暗色 |+| `nord` | #2e3440 | 自动推导 | 北欧冰蓝风格 |+| `dracula` | #282a36 | #f8f8f2 | 经典暗色主题 |+| `github-dark` | #0d1117 | #4493f8 | GitHub 暗色风格 |+| `solarized-dark` | #002b36 | #268bd2 | Solarized 暗色 |+| `one-dark` | #282c34 | 自动推导 | Atom One Dark 风格 |++---++## 主题详细说明++### `zinc-light` (亮色)+**特性:** 清洁、通用的浅色主题,适合打印和高对比度场景。++**配置:**+```javascript+{+ bg: '#FFFFFF',+ fg: '#27272A'+}+```++**最佳用途:**+- 正式文档和报告+- 打印输出+- 演示幻灯片++**示例:**+```mermaid+graph TD+ A[Start] --> B{Decision}+ B -->|Yes| C[Action]+ B -->|No| D[End]+```++---++### `zinc-dark` (暗色)+**特性:** 纯暗色主题,前景色由系统推导。极简主义风格。++**配置:**+```javascript+{+ bg: '#18181B',+ fg: '自动推导'+}+```++**最佳用途:**+- 终端应用+- 暗色 UI 集成+- 代码编辑器++---++### `tokyo-night` (暗色) ⭐ 推荐+**特性:** 现代日本风格,柔和的蓝色调,专为开发者设计。++**配置:**+```javascript+{+ bg: '#1a1b26',+ fg: '#a9b1d6',+ accent: '#7aa2f7'+}+```++**最佳用途:**+- 现代开发文档+- AI 辅助编程+- 代码示例和教程++**视觉特性:**+- 深蓝色背景(#1a1b26)+- 柔和紫色文字(#a9b1d6)+- 亮蓝色强调(#7aa2f7)++---++### `tokyo-night-storm` (暗色)+**特性:** Tokyo Night 的深色变体,更深的背景色。++**配置:**+```javascript+{+ bg: '#24283b',+ fg: '#a9b1d6',+ accent: '#7aa2f7'+}+```++**最佳用途:**+- 极低光环境+- OLED 屏幕优化+- 长时间阅读++---++### `tokyo-night-light` (亮色)+**特性:** Tokyo Night 的亮色版本,保持同样的配色哲学。++**配置:**+```javascript+{+ bg: '#d5d6db',+ fg: '#34548a'+}+```++**最佳用途:**+- 日间使用+- 高对比度需求+- 打印友好++---++### `catppuccin-mocha` (暗色)+**特性:** 温暖、舒适的暗色主题,带有红紫色强调。++**配置:**+```javascript+{+ bg: '#1e1e2e',+ fg: '#cba6f7'+}+```++**最佳用途:**+- 长时间阅读(眼睛友好)+- 创意项目+- 设计文档++---++### `catppuccin-latte` (亮色)+**特性:** Catppuccin 的亮色变体,温暖而柔和。++**配置:**+```javascript+{+ bg: '#eff1f5',+ fg: '#8839ef'+}+```++**最佳用途:**+- 日间亮色环境+- 紫色爱好者+- 设计导向的文档++---++### `nord` (暗色)+**特性:** 北欧启发的冰蓝色调,专业且冷静。++**配置:**+```javascript+{+ bg: '#2e3440',+ fg: '自动推导'+}+```++**最佳用途:**+- 企业文档+- 技术规范+- 系统架构图++**视觉特性:**+- 深灰蓝色背景+- 高对比度文字+- 冷色调整体++---++### `nord-light` (亮色)+**特性:** Nord 的亮色版本。++**配置:**+```javascript+{+ bg: '#eceff4',+ fg: '#5e81ac'+}+```++**最佳用途:**+- 日间亮色使用+- 印刷品+- 北欧风格项目++---++### `dracula` (暗色) ⭐ 推荐+**特性:** 经典的深暗色主题,高对比度。++**配置:**+```javascript+{+ bg: '#282a36',+ fg: '#f8f8f2'+}+```++**最佳用途:**+- 代码编辑器集成+- 开发者文档+- 命令行工具++**视觉特性:**+- 极深的背景色+- 明亮的文字+- 紫色和粉色强调++---++### `github-light` (亮色)+**特性:** GitHub 亮色主题,Web 友好。++**配置:**+```javascript+{+ bg: '#ffffff',+ fg: '#0969da'+}+```++**最佳用途:**+- GitHub README+- Web 文档+- 在线教程++---++### `github-dark` (暗色)+**特性:** GitHub 暗色主题,GitHub 用户熟悉。++**配置:**+```javascript+{+ bg: '#0d1117',+ fg: '#4493f8'+}+```++**最佳用途:**+- GitHub 文档+- GitHub Issues 和 Discussions+- 开源项目++---++### `solarized-light` (亮色)+**特性:** Ethan Schoonover 设计的经典亮色主题。++**配置:**+```javascript+{+ bg: '#fdf6e3',+ fg: '#268bd2'+}+```++**最佳用途:**+- 研究论文+- 学术文档+- 精确色彩工作++---++### `solarized-dark` (暗色)+**特性:** Solarized 的暗色版本,精心调校的对比度。++**配置:**+```javascript+{+ bg: '#002b36',+ fg: '#268bd2'+}+```++**最佳用途:**+- 长篇文档阅读+- 科学论文+- 编程教材++---++### `one-dark` (暗色)+**特性:** Atom 编辑器的经典 One Dark 主题。++**配置:**+```javascript+{+ bg: '#282c34',+ fg: '自动推导'+}+```++**最佳用途:**+- Atom 用户+- JavaScript 项目+- Web 开发文档++---++## 自定义主题++### 基础自定义(Mono Mode)++只需要两种颜色就能创建美观的主题:++```python+python render_mermaid.py \+ --input diagram.mmd \+ --output output.svg \+ --bg '#0f0f0f' \+ --fg '#e0e0e0'+```++系统会自动推导所有其他颜色。++### 高级自定义(Enriched Mode)++对于更丰富的颜色方案,提供可选的强调色:++```python+python render_mermaid.py \+ --input diagram.mmd \+ --output output.svg \+ --bg '#0f0f0f' \+ --fg '#e0e0e0' \+ --accent '#ff6b6b' \+ --muted '#666666' \+ --line '#4a90e2' \+ --surface '#1a1a1a' \+ --border '#2a2a2a'+```++### 颜色选择指南++| 参数 | 作用 | 示例 |+|------|------|------|+| `--bg` | 背景色(必需) | `#1a1a1a` |+| `--fg` | 文字色(必需) | `#e0e0e0` |+| `--accent` | 箭头头和强调 | `#7aa2f7` |+| `--muted` | 次级文字和标签 | `#666666` |+| `--line` | 边/连接线 | `#3d59a1` |+| `--surface` | 节点填充 | `#292e42` |+| `--border` | 节点边框 | `#3d59a1` |++---++## 主题选择决策树++```+你想要的主题风格是什么?+├── 亮色 (Light)+│ ├── 极简/清洁? → zinc-light+│ ├── GitHub 风格? → github-light+│ ├── Solarized? → solarized-light+│ ├── 冰蓝色? → nord-light+│ ├── 紫色? → catppuccin-latte+│ └── 柔和日式? → tokyo-night-light+│+└── 暗色 (Dark)+ ├── 推荐通用? → tokyo-night ⭐+ ├── 经典暗色? → dracula ⭐+ ├── 极简/纯粹? → zinc-dark+ ├── 北欧风格? → nord+ ├── 温暖舒适? → catppuccin-mocha+ ├── GitHub 风格? → github-dark+ ├── 极深背景? → tokyo-night-storm+ ├── 学术/精确? → solarized-dark+ └── Atom 风格? → one-dark+```++---++## 实用示例++### 示例 1:在中文文档中使用 Tokyo Night++```bash+python render_mermaid.py \+ --input 架构图.mmd \+ --output 架构图.svg \+ --theme tokyo-night+```++### 示例 2:创建打印友好的图表++```bash+python render_mermaid.py \+ --input diagram.mmd \+ --output diagram.svg \+ --theme zinc-light+```++### 示例 3:批量应用主题++```bash+python batch_render.py \+ --input-dir ./diagrams \+ --output-dir ./output \+ --format svg \+ --theme dracula+```++### 示例 4:自定义企业主题++```bash+python render_mermaid.py \+ --input diagram.mmd \+ --output output.svg \+ --bg '#1a1a1a' \+ --fg '#ffffff' \+ --accent '#0066cc' \+ --border '#333333'+```++---++## 颜色值速查表++### 常用十六进制颜色+| 颜色名 | 十六进制 | 用途 |+|--------|---------|------|+| 纯白 | #FFFFFF | 亮色背景 |+| 纯黑 | #000000 | 深色背景 |+| 深灰 | #1a1a1a | 友好暗色 |+| 浅灰 | #f0f0f0 | 友好亮色 |+| 蓝色 | #0066cc | 强调色 |+| 绿色 | #00cc00 | 成功色 |+| 红色 | #cc0000 | 警告/错误 |+| 紫色 | #9966cc | 创意项目 |++---++## 常见问题++**Q: 我应该使用哪个主题?**+A: 如果不确定,推荐使用 `tokyo-night`(暗色)或 `zinc-light`(亮色)。++**Q: 如何为 GitHub README 选择主题?**+A: 使用 `github-light` 或 `github-dark`,与 GitHub 的主题相匹配。++**Q: 我能混合多个主题的颜色吗?**+A: 可以,使用 Enriched Mode 自定义任意颜色组合。++**Q: 主题是否支持透明背景?**+A: 支持,添加 `--transparent` 标志。++**Q: 如何在 AI 聊天中推荐主题给用户?**+A: 根据项目类型:开发项目→Tokyo Night,企业→Nord,打印→Zinc Light。diff --git a/references/api_reference.md b/references/api_reference.mdnew file mode 100644index 0000000..85392c8--- /dev/null+++ b/references/api_reference.md@@ -0,0 +1,34 @@+# Reference Documentation for Beautiful Mermaid++This is a placeholder for detailed reference documentation.+Replace with actual reference content or delete if not needed.++Example real reference docs from other skills:+- product-management/references/communication.md - Comprehensive guide for status updates+- product-management/references/context_building.md - Deep-dive on gathering context+- bigquery/references/ - API references and query examples++## When Reference Docs Are Useful++Reference docs are ideal for:+- Comprehensive API documentation+- Detailed workflow guides+- Complex multi-step processes+- Information too lengthy for main SKILL.md+- Content that's only needed for specific use cases++## Structure Suggestions++### API Reference Example+- Overview+- Authentication+- Endpoints with examples+- Error codes+- Rate limits++### Workflow Guide Example+- Prerequisites+- Step-by-step instructions+- Common patterns+- Troubleshooting+- Best practicesdiff --git a/requirements.txt b/requirements.txtnew file mode 100644index 0000000..f9ec85c--- /dev/null+++ b/requirements.txt@@ -0,0 +1,13 @@+# Beautiful-Mermaid Skill - Python Dependencies+# This skill requires no additional Python packages (uses only standard library)++# System Dependencies:+# - Node.js >= 14.0.0+# - npm or yarn++# Installation:+# 1. npm install -g beautiful-mermaid@^0.1.3+# 2. Ensure Node.js and npm are installed on your system++# No Python packages are required for this skill to function.+# All rendering is handled by the Node.js beautiful-mermaid library via subprocess calls.diff --git a/scripts/batch_render.py b/scripts/batch_render.pynew file mode 100644index 0000000..4883188--- /dev/null+++ b/scripts/batch_render.py@@ -0,0 +1,170 @@+#!/usr/bin/env python3+"""+Batch render multiple Mermaid diagrams.++Usage:+ python batch_render.py --input-dir ./diagrams --output-dir ./output --format svg --theme tokyo-night+"""++import argparse+import shutil+import subprocess+import sys+from pathlib import Path+from concurrent.futures import ThreadPoolExecutor, as_completed+++def render_file(input_file, output_dir, args):+ """Render a single Mermaid file."""+ output_ext = '.svg' if args.format == 'svg' else '.txt'+ output_file = output_dir / (input_file.stem + output_ext)++ # Build command+ helper_script = Path(__file__).parent / 'render_helper.mjs'+ cmd = [+ 'node', str(helper_script), 'render',+ '--input', str(input_file),+ '--output', str(output_file),+ '--format', args.format+ ]++ if args.theme:+ cmd.extend(['--theme', args.theme])++ if args.bg:+ cmd.extend(['--bg', args.bg])++ if args.fg:+ cmd.extend(['--fg', args.fg])++ if args.transparent:+ cmd.extend(['--transparent', 'true'])++ if args.use_ascii:+ cmd.extend(['--use-ascii', 'true'])++ try:+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)+ if result.returncode == 0:+ return (input_file.name, True, None)+ else:+ return (input_file.name, False, result.stderr)+ except Exception as e:+ return (input_file.name, False, str(e))+++def main():+ parser = argparse.ArgumentParser(+ description='Batch render Mermaid diagrams'+ )++ parser.add_argument(+ '--input-dir', '-i',+ required=True,+ help='Input directory containing .mmd files'+ )++ parser.add_argument(+ '--output-dir', '-o',+ required=True,+ help='Output directory for rendered files'+ )++ parser.add_argument(+ '--format', '-f',+ choices=['svg', 'ascii'],+ default='svg',+ help='Output format (default: svg)'+ )++ parser.add_argument(+ '--theme', '-t',+ help='Built-in theme name'+ )++ parser.add_argument(+ '--bg',+ help='Background color (hex)'+ )++ parser.add_argument(+ '--fg',+ help='Foreground color (hex)'+ )++ parser.add_argument(+ '--transparent',+ action='store_true',+ help='Render with transparent background (SVG only)'+ )++ parser.add_argument(+ '--use-ascii',+ action='store_true',+ help='Use pure ASCII instead of Unicode (ASCII format only)'+ )++ parser.add_argument(+ '--workers', '-w',+ type=int,+ default=4,+ help='Number of parallel workers (default: 4)'+ )++ args = parser.parse_args()++ # Validate input directory+ input_dir = Path(args.input_dir)+ if not input_dir.exists():+ print(f"Error: Input directory not found: {args.input_dir}", file=sys.stderr)+ sys.exit(1)++ # Check for Node.js dependency+ if not shutil.which('node'):+ print("Error: Node.js is required but not found in PATH.", file=sys.stderr)+ sys.exit(1)++ # Create output directory+ output_dir = Path(args.output_dir)+ output_dir.mkdir(parents=True, exist_ok=True)++ # Find all .mmd files+ mmd_files = list(input_dir.glob('*.mmd'))++ if not mmd_files:+ print(f"No .mmd files found in {args.input_dir}", file=sys.stderr)+ sys.exit(1)++ print(f"Found {len(mmd_files)} diagram(s) to render...")++ # Render in parallel+ success_count = 0+ failed = []++ with ThreadPoolExecutor(max_workers=args.workers) as executor:+ futures = {+ executor.submit(render_file, mmd_file, output_dir, args): mmd_file+ for mmd_file in mmd_files+ }++ for future in as_completed(futures):+ filename, success, error = future.result()+ if success:+ print(f"✓ {filename}")+ success_count += 1+ else:+ print(f"✗ {filename}: {error}", file=sys.stderr)+ failed.append((filename, error))++ # Summary+ print(f"\n{success_count}/{len(mmd_files)} diagrams rendered successfully")++ if failed:+ print(f"\n{len(failed)} failed:")+ for filename, error in failed:+ print(f" - {filename}: {error}")+ sys.exit(1)+++if __name__ == '__main__':+ main()diff --git a/scripts/list_themes.py b/scripts/list_themes.pynew file mode 100644index 0000000..6f98232--- /dev/null+++ b/scripts/list_themes.py@@ -0,0 +1,48 @@+#!/usr/bin/env python3+"""+List all available beautiful-mermaid themes.++Usage:+ python list_themes.py+"""++import subprocess+import json+import sys+from pathlib import Path+++def main():+ helper_script = Path(__file__).parent / 'render_helper.mjs'+ cmd = ['node', str(helper_script), 'list-themes']++ try:+ result = subprocess.run(cmd, capture_output=True, text=True)++ if result.returncode != 0:+ print(f"Error: {result.stderr}", file=sys.stderr)+ sys.exit(1)++ themes = json.loads(result.stdout)++ print("Available Beautiful-Mermaid Themes:\n")+ for i, theme in enumerate(themes, 1):+ print(f"{i:2d}. {theme}")++ print(f"\nTotal: {len(themes)} themes")+ print("\nUsage:")+ print(" python render_mermaid.py --input diagram.mmd --theme <theme-name> --output output.svg")++ except FileNotFoundError:+ print("Error: Node.js not found. Please install Node.js to use this tool.", file=sys.stderr)+ sys.exit(1)+ except json.JSONDecodeError:+ print("Error: Could not parse theme list", file=sys.stderr)+ sys.exit(1)+ except Exception as e:+ print(f"Error: {e}", file=sys.stderr)+ sys.exit(1)+++if __name__ == '__main__':+ main()diff --git a/scripts/render_helper.mjs b/scripts/render_helper.mjsnew file mode 100644index 0000000..66eb500--- /dev/null+++ b/scripts/render_helper.mjs@@ -0,0 +1,165 @@+#!/usr/bin/env node++/**+ * Node.js helper for beautiful-mermaid rendering+ * Called by Python wrapper scripts+ */++import { renderMermaid, renderMermaidAscii, THEMES } from 'beautiful-mermaid';+import { readFileSync, writeFileSync } from 'fs';++const args = process.argv.slice(2);+const command = args[0];++async function main() {+ try {+ switch (command) {+ case 'render':+ await handleRender();+ break;+ case 'list-themes':+ handleListThemes();+ break;+ default:+ console.error(`Unknown command: ${command}`);+ process.exit(1);+ }+ } catch (error) {+ console.error('Error:', error.message);+ process.exit(1);+ }+}++async function handleRender() {+ const options = parseRenderArgs();+ const input = readFileSync(options.input, 'utf8');++ if (options.format === 'ascii') {+ const ascii = renderMermaidAscii(input, {+ useAscii: options.useAscii,+ paddingX: options.paddingX,+ paddingY: options.paddingY,+ boxBorderPadding: options.boxBorderPadding,+ });++ if (options.output) {+ writeFileSync(options.output, ascii);+ console.log(`ASCII diagram saved to ${options.output}`);+ } else {+ console.log(ascii);+ }+ } else {+ // SVG rendering+ const theme = options.theme ? THEMES[options.theme] : undefined;+ const colors = theme || {+ bg: options.bg,+ fg: options.fg,+ ...(options.line && { line: options.line }),+ ...(options.accent && { accent: options.accent }),+ ...(options.muted && { muted: options.muted }),+ ...(options.surface && { surface: options.surface }),+ ...(options.border && { border: options.border }),+ };++ const svg = await renderMermaid(input, {+ ...colors,+ font: options.font,+ transparent: options.transparent,+ });++ if (options.output) {+ writeFileSync(options.output, svg);+ console.log(`SVG diagram saved to ${options.output}`);+ } else {+ console.log(svg);+ }+ }+}++function handleListThemes() {+ console.log(JSON.stringify(Object.keys(THEMES), null, 2));+}++function parseRenderArgs() {+ const options = {+ input: null,+ output: null,+ format: 'svg',+ theme: null,+ bg: '#FFFFFF',+ fg: '#27272A',+ font: 'Inter',+ transparent: false,+ useAscii: false,+ paddingX: 5,+ paddingY: 5,+ boxBorderPadding: 1,+ };++ for (let i = 1; i < args.length; i += 2) {+ const key = args[i];+ const value = args[i + 1];++ switch (key) {+ case '--input':+ options.input = value;+ break;+ case '--output':+ options.output = value;+ break;+ case '--format':+ options.format = value;+ break;+ case '--theme':+ options.theme = value;+ break;+ case '--bg':+ options.bg = value;+ break;+ case '--fg':+ options.fg = value;+ break;+ case '--line':+ options.line = value;+ break;+ case '--accent':+ options.accent = value;+ break;+ case '--muted':+ options.muted = value;+ break;+ case '--surface':+ options.surface = value;+ break;+ case '--border':+ options.border = value;+ break;+ case '--font':+ options.font = value;+ break;+ case '--transparent':+ options.transparent = value === 'true';+ break;+ case '--use-ascii':+ options.useAscii = value === 'true';+ break;+ case '--padding-x':+ options.paddingX = parseInt(value);+ break;+ case '--padding-y':+ options.paddingY = parseInt(value);+ break;+ case '--box-border-padding':+ options.boxBorderPadding = parseInt(value);+ break;+ }+ }++ if (!options.input) {+ throw new Error('--input is required');+ }++ return options;+}++main();diff --git a/scripts/render_mermaid.py b/scripts/render_mermaid.pynew file mode 100644index 0000000..d307b7a--- /dev/null+++ b/scripts/render_mermaid.py@@ -0,0 +1,191 @@+#!/usr/bin/env python3+"""+Render a Mermaid diagram as SVG or ASCII using beautiful-mermaid.++Usage:+ python render_mermaid.py --input diagram.mmd --output diagram.svg --format svg --theme tokyo-night+ python render_mermaid.py --input diagram.mmd --format ascii+"""++import argparse+import subprocess+import sys+from pathlib import Path+++def main():+ parser = argparse.ArgumentParser(+ description='Render Mermaid diagrams as beautiful SVGs or ASCII art'+ )++ parser.add_argument(+ '--input', '-i',+ required=True,+ help='Input Mermaid file (.mmd)'+ )++ parser.add_argument(+ '--output', '-o',+ help='Output file (SVG or text). If omitted, prints to stdout'+ )++ parser.add_argument(+ '--format', '-f',+ choices=['svg', 'ascii'],+ default='svg',+ help='Output format (default: svg)'+ )++ parser.add_argument(+ '--theme', '-t',+ help='Built-in theme name (e.g., tokyo-night, dracula, github-dark)'+ )++ parser.add_argument(+ '--bg',+ help='Background color (hex)'+ )++ parser.add_argument(+ '--fg',+ help='Foreground color (hex)'+ )++ parser.add_argument(+ '--line',+ help='Edge/connector color (hex)'+ )++ parser.add_argument(+ '--accent',+ help='Arrow heads and highlights color (hex)'+ )++ parser.add_argument(+ '--muted',+ help='Secondary text and labels color (hex)'+ )++ parser.add_argument(+ '--surface',+ help='Node fill tint color (hex)'+ )++ parser.add_argument(+ '--border',+ help='Node stroke color (hex)'+ )++ parser.add_argument(+ '--font',+ default='Inter',+ help='Font family (default: Inter)'+ )++ parser.add_argument(+ '--transparent',+ action='store_true',+ help='Render with transparent background (SVG only)'+ )++ parser.add_argument(+ '--use-ascii',+ action='store_true',+ help='Use pure ASCII instead of Unicode (ASCII format only)'+ )++ parser.add_argument(+ '--padding-x',+ type=int,+ default=5,+ help='Horizontal spacing between nodes (ASCII only, default: 5)'+ )++ parser.add_argument(+ '--padding-y',+ type=int,+ default=5,+ help='Vertical spacing between nodes (ASCII only, default: 5)'+ )++ parser.add_argument(+ '--box-border-padding',+ type=int,+ default=1,+ help='Padding inside node boxes (ASCII only, default: 1)'+ )++ args = parser.parse_args()++ # Validate input file+ input_path = Path(args.input)+ if not input_path.exists():+ print(f"Error: Input file not found: {args.input}", file=sys.stderr)+ sys.exit(1)++ # Build command+ helper_script = Path(__file__).parent / 'render_helper.mjs'+ cmd = ['node', str(helper_script), 'render', '--input', args.input]++ if args.output:+ cmd.extend(['--output', args.output])++ cmd.extend(['--format', args.format])++ if args.theme:+ cmd.extend(['--theme', args.theme])++ if args.bg:+ cmd.extend(['--bg', args.bg])++ if args.fg:+ cmd.extend(['--fg', args.fg])++ if args.line:+ cmd.extend(['--line', args.line])++ if args.accent:+ cmd.extend(['--accent', args.accent])++ if args.muted:+ cmd.extend(['--muted', args.muted])++ if args.surface:+ cmd.extend(['--surface', args.surface])++ if args.border:+ cmd.extend(['--border', args.border])++ if args.font:+ cmd.extend(['--font', args.font])++ if args.transparent:+ cmd.extend(['--transparent', 'true'])++ if args.use_ascii:+ cmd.extend(['--use-ascii', 'true'])++ cmd.extend(['--padding-x', str(args.padding_x)])+ cmd.extend(['--padding-y', str(args.padding_y)])+ cmd.extend(['--box-border-padding', str(args.box_border_padding)])++ # Execute+ try:+ result = subprocess.run(cmd, capture_output=True, text=True)++ if result.returncode != 0:+ print(f"Error: {result.stderr}", file=sys.stderr)+ sys.exit(result.returncode)++ print(result.stdout)++ except FileNotFoundError:+ print("Error: Node.js not found. Please install Node.js to use this tool.", file=sys.stderr)+ sys.exit(1)+ except Exception as e:+ print(f"Error: {e}", file=sys.stderr)+ sys.exit(1)+++if __name__ == '__main__':+ main()