Agent skill that turns natural language, code, Terraform/K8s, SQL, OpenAPI, AsyncAPI, Protobuf and GraphQL sources into editable, tested draw.io architecture diagrams: incremental sync, multi-view projection, drift diff, CI architecture tests, whiteboard derasterize, interactive HTML/PPTX/Mermaid exports.
Python agent-skillsarchitecturearchitecture-diagramasyncapibpmnc4-modelclaude-codediagramdiagrams-as-codedrawioflowchartgithub-actionsgraphqlimage-to-diagramkubernetesmcp-serverprotobufsysmlterraformuml
docs(readme): reorganize for readability, tighten highlights
Agents365-ai6440c1ec7f77
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3919ff4..6495568 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,19 @@ on [Keep a Changelog](https://keepachangelog.com/), and the project followssemantic-ish versioning (the `metadata.version` field in`skills/drawio-skill/SKILL.md`).+## [Unreleased]++### Changed++- **README / README_CN reorganized for readability**: the 26 flat Highlights+ bullets are grouped into four themes (from a prompt / from real sources /+ keep it true over time / share and restyle); Installation and Quick Start+ moved ahead of the examples; the 60-line CLI dump and its duplicate 16-row+ table are replaced by one short snippet plus a five-row stage table linking+ to `references/toolbox.md`. The microservices figure moved from the hero+ slot into Examples (its prompt callout intact). Section count and order,+ figures, and links stay mirrored between the two languages.+## [3.2.3] - 2026-09-11### Addeddiff --git a/README.md b/README.mdindex 335b552..00ab482 100644--- a/README.md+++ b/README.md@@ -18,96 +18,44 @@ A skill that turns natural language and real system sources into maintainable `.<img src="assets/hero-demo.gif" width="900" alt="Hero demo: Terraform source becomes an architecture diagram with official icons; the v2 change renders as an updated diagram"></p>-<p align="center">- <img src="assets/microservices-example.png" width="900" alt="Microservices Architecture: generated from a single natural-language prompt">-</p>-## ✨ Highlights-- **Whiteboard photo / screenshot → editable diagram** — snap a legacy PNG or a physical whiteboard, let vision extract the graph, and `raster2drawio.py` rebuilds it as a real, editable `.drawio` honouring the original layout-- **Architecture digital twin / Diagram IR** — separate meaning, provenance, and geometry; project executive, system, deployment, data-flow, and security views from one model-- **Incremental sync without losing manual layout** — `diagramctl sync` updates changed nodes/relations while preserving tuned coordinates, styles, and annotations; removals stay reviewable by default-- **Diagram-as-Test** — YAML/JSON rules for direct Internet-to-database access, cycles, orphans, ownership, production observability, external timeouts, trust-boundary protocols, and color contrast-- **Architecture query and review** — query components/owners/boundaries/paths, identify articulation points and high coupling, and emit Markdown/JSON review reports-- **What-if + Story Mode** — simulate failure propagation with an annotated diagram; publish an offline, keyboard-accessible HTML walkthrough with text alternative, provenance, and language switching-- **MCP server built in** — `scripts/diagramctl_mcp.py` exposes nine tools (`build/sync/views/architecture_test/review/query/whatif/story/doctor`) to Claude Desktop, Cursor, VS Code, Codex, and any MCP host; stdlib-only and offline, no `mcp` package-- **One CLI** — `doctor/build/sync/views/query/test/review/whatif/story/publish/transform` connects the toolbox; core semantic workflows need only Python and are offline by default-- **11 diagram type presets** — ERD, UML Class, Sequence, C4, Architecture, ML/Deep Learning, Flowchart, SysML (BDD / IBD / Requirement / Parametric), BPMN, Network Topology, Cross-Functional Swimlane-- **Mermaid → native .drawio** (draw.io ≥ 30) — author 28 standard types as Mermaid text (**mindmap, gantt, timeline, journey, pie, sankey, kanban**…) and the CLI converts them into a laid-out, editable `.drawio` — structure in, layout free-- **Visualize a codebase** — extract and auto-lay-out the structure of a Python / JS-TS / Go / Rust project (import graphs) or a Python class hierarchy — Graphviz placement, transitive reduction, nested module containers-- **IaC → architecture diagram** — turn **Terraform** configs, **Kubernetes** manifests, or **docker-compose** files into an architecture diagram where every resource renders as its **official AWS / Azure / GCP / K8s icon**, edges derived from actual references (role ARNs, selectors, volume mounts)-- **SQL DDL → ER diagram** — parse `CREATE TABLE` statements into per-table nodes with PK/FK markers and crow's-foot foreign-key edges-- **Deterministic sequence diagrams** — describe participants + messages as JSON; lifelines, auto-tracked activation bars, and arrows are computed, never hand-placed-- **C4 model with drill-down** — one command generates the multi-page System Context → Container → Component set with official C4 shapes; parent elements **click through** to their child page-- **Search 10,000+ official shapes** — resolve the exact AWS / Azure / GCP / Cisco / Kubernetes / UML / BPMN icon style instead of guessing (no more blank-box `shape=mxgraph.*` typos)-- **AI / LLM brand logos** — 321 logos (OpenAI, Claude, Gemini, Mistral, Llama, Ollama, LangChain…) that draw.io has none of, plus **18 data-store brands** (Redis, Postgres, Qdrant, Milvus…) for LLM/RAG architecture diagrams-- **Self-check + auto-fix** — reads its own PNG output and auto-fixes overlaps, clipped labels, stacked edges, and more (up to 2 rounds)-- **Iterative feedback loop** — up to 5 rounds of targeted refinement-- **Style presets** — capture your visual style from a `.drawio` file or image, reuse on demand-- **Clean layout** — grid-aligned, spacing scales with diagram size, connectors routed clear of nodes-- **CI-ready** — official `drawio-architecture-test` GitHub Action enforces architecture contracts on every PR with no draw.io/Xvfb/Graphviz install; visual PR diff action for rendered `.drawio`-- **Multi-agent, no daemon** — portable Agent Skills package plus an optional MCP server for host integrations (core semantic workflows need only Python; native export remains optional)--## 🗺️ Feature Map--<div align="center">- <img src="assets/mindmap.png" width="900" alt="drawio-skill feature map — one mind map covering every capability, itself drawn with the skill">-</div>--A bird's-eye view of everything the skill does — diagram types, import sources, layout engines, styling, export formats, and repurposing — in one map. Fittingly, this map was itself drawn with drawio-skill.--## 🖼️ Examples+**From a prompt**-The maintained [Architecture Studio showcase](examples/architecture-studio/)-covers code → IR → `.drawio`, conflict-aware synchronization that preserves a-manually tuned layout, and architecture → policy/views/what-if/accessible Story.-Every artifact is regenerated by one script and verified in the test suite.+- **Describe it, get an editable `.drawio`** — the skill plans the layout, writes the XML, exports, then self-checks its own PNG and auto-fixes overlaps, clipped labels, and stacked edges (up to 2 rounds), with up to 5 rounds of your feedback+- **Mermaid → native .drawio** (draw.io ≥ 30) — author 28 standard types as Mermaid text (**mindmap, gantt, timeline, journey, pie, sankey, kanban**…) and the CLI converts them into a laid-out, editable `.drawio`: structure in, layout free+- **Whiteboard photo / screenshot → editable diagram** — snap a legacy PNG or a physical whiteboard, let vision extract the graph, and `raster2drawio.py` rebuilds it as a real, editable `.drawio` honouring the original layout+- **11 diagram type presets** — ERD, UML Class, Sequence, C4, Architecture, ML/Deep Learning, Flowchart, SysML, BPMN, Network Topology, Cross-Functional Swimlane-> [!TIP]-> **The hero image above was generated from this single prompt:**+**From real sources**-```-Create a microservices e-commerce architecture with Mobile/Web/Admin clients,-API Gateway (auth + rate limiting + routing), Auth/User/Order/Product/Payment-services, Kafka message queue, Notification service, and User DB / Order DB /-Product DB / Redis Cache / Stripe API-```+- **Visualize a codebase** — import graphs for Python / JS-TS / Go / Rust and Python class hierarchies, with Graphviz placement, transitive reduction, and nested module containers+- **IaC and live infrastructure** — Terraform, Kubernetes, and docker-compose configs become diagrams with official AWS / Azure / GCP / K8s icons; snapshot what's *actually deployed* from `terraform show -json`, `docker inspect`, or `kubectl get -o json`+- **Schemas and pipelines** — SQL DDL → ER diagram, OpenAPI/Swagger → API diagram coloured by HTTP method, GitHub Actions / GitLab CI → pipeline DAG+- **Deterministic engines** — sequence diagrams with computed lifelines and activation bars; multi-page C4 models with click-to-drill-down-The skill is designed to route edges cleanly across different topologies, avoiding lines that cross through shapes:+**Keep it true over time**-<table>- <tr>- <td align="center" width="33%">- <img src="assets/demo-star.png" alt="Star topology" width="100%"><br>- <b>Star</b> · 7 nodes<br>- <sub>Central message broker with 6 microservices radiating outward, no edge crossings on this example.</sub>- </td>- <td align="center" width="33%">- <img src="assets/demo-layered.png" alt="Layered flow" width="100%"><br>- <b>Layered</b> · 10 nodes / 4 tiers<br>- <sub>E-commerce stack with horizontal and diagonal cross-connections routed via corridors.</sub>- </td>- <td align="center" width="33%">- <img src="assets/demo-ring.png" alt="Ring cycle" width="100%"><br>- <b>Ring</b> · 8 nodes<br>- <sub>CI/CD pipeline with a closed loop and 2 spur branches flowing along the perimeter.</sub>- </td>- </tr>-</table>+- **Architecture digital twin / Diagram IR** — separate meaning, provenance, and geometry; project executive, system, deployment, data-flow, and security views from one model+- **Incremental sync without losing manual layout** — `diagramctl sync` updates changed nodes/relations while preserving tuned coordinates, styles, and annotations; removals stay reviewable by default+- **Diagram-as-Test, in CI** — YAML/JSON architecture rules (Internet-to-database access, cycles, orphans, trust boundaries, contrast…) plus an official GitHub Action that enforces them on every PR, and a PR action that renders visual diffs+- **Query, review, what-if** — query components/owners/paths, spot articulation points and high coupling, simulate failure propagation, publish an accessible Story walkthrough+- **Drift and history** — colour-coded diffs between two diagrams or two live snapshots; a time-lapse player of how a codebase's architecture grew-It also speaks **Mermaid** — standard types (flowchart, mindmap, **kanban**, gitGraph, timeline…) convert straight to native, editable `.drawio`. Here's a Kanban board (this project's own roadmap) generated from a few lines of Mermaid:+**Share and restyle**-<div align="center">- <img src="assets/kanban.png" width="620" alt="Kanban board generated by drawio-skill from Mermaid — this project's roadmap across Backlog / Todo / In Progress / Done">-</div>+- **Repurpose with one command** — interactive HTML viewer (pan/zoom/search), PowerPoint deck, animated data-flow SVG, Mermaid or Markdown export, click-through runbook, exec-summary compression+- **Restyle and enrich** — style presets (yours or built-in `dark`/`corporate`/…), bilingual label variants with layout untouched, data-driven heat maps, white-to-metro tubemap mode+- **10,000+ official shapes + 321 AI/LLM logos** — resolve exact AWS / Cisco / K8s / UML icon styles instead of guessing, plus brand logos draw.io itself lacks+- **One CLI, optional MCP server** — `diagramctl doctor/build/sync/views/query/test/review/whatif/story/publish/transform`, core workflows stdlib-only and offline; the MCP server exposes them to Claude Desktop, Cursor, VS Code, Codex, and any MCP host. Portable to any Agent Skills-compatible agent, no daemon-**Tube-Map Mode** restyles a pipeline or journey as a London-Underground-style metro map — coloured lines, octilinear (H/V/45°) routing, and white interchange circles. Here's the skill's own flow (this map is `assets/tubemap.json`, ~20 lines):+## 🗺️ Feature Map<div align="center">- <img src="assets/tubemap.png" width="720" alt="drawio-skill's pipeline drawn as a metro map — Author / Import / Repurpose / Analyze lines meeting at the Auto-layout and .drawio interchange stations">+ <img src="assets/mindmap.png" width="900" alt="drawio-skill feature map — one mind map covering every capability, itself drawn with the skill"></div>-Full walkthrough in [docs/USAGE.md](docs/USAGE.md).+A bird's-eye view of everything the skill does — diagram types, import sources, layout engines, styling, export formats, and repurposing — in one map. Fittingly, this map was itself drawn with drawio-skill.## 🚀 Installation@@ -158,7 +106,7 @@ Also indexed on [SkillsMP](https://skillsmp.com/skills/agents365-ai-drawio-skillAfter installation, just describe what you want. For example, an ML model:-```+```textDraw a Transformer encoder-decoder for machine translation: 6-layer encoderwith self-attention, 6-layer decoder with cross-attention, input embeddings(batch × 512 × 768), positional encoding, and a final output projection.@@ -167,120 +115,98 @@ Annotate tensor shapes between layers and color-code by layer type.The skill plans the layout, generates the `.drawio` XML, exports to your chosen format, self-checks the result, and lets you iterate.-## 🗺️ Visualize Code & Infrastructure--Beyond hand-authored diagrams, the skill turns **existing code, infrastructure, and schemas into diagrams** — no manual coordinates. Just ask:--> *"Visualize the module structure of this Python project"* · *"Draw the class hierarchy of `mypackage`"*+## 🖼️ Examples<p align="center">- <img src="assets/code-structure-example.png" width="900" alt="Auto-generated class hierarchy of Python's logging package — modules boxed, inheritance arrows resolved">+ <img src="assets/microservices-example.png" width="900" alt="Microservices Architecture: generated from a single natural-language prompt"></p>-<sub>↑ Python's <code>logging</code> package as a class hierarchy — one command, modules auto-boxed, every inheritance edge resolved.</sub>--Under the hood it runs a bundled extractor → auto-layout → validate pipeline:--```bash-# Import graph — Python / JS-TS / Go / Rust-python3 scripts/pyimports.py myproject --group -o graph.json-python3 scripts/jsimports.py ./src --group -o graph.json-python3 scripts/goimports.py ./module --group -o graph.json-python3 scripts/rustimports.py ./crate --group -o graph.json--# Python class-inheritance hierarchy-python3 scripts/pyclasses.py mypackage --group -o graph.json--# Infrastructure as Code — official cloud icons resolved automatically-python3 scripts/tfimports.py ./infra -o graph.json # Terraform → AWS/Azure/GCP icons-python3 scripts/k8simports.py ./manifests -o graph.json # K8s YAML/JSON → kind icons-python3 scripts/composeimports.py compose.yml -o graph.json # services + named volumes--# Live infrastructure — draw what's ACTUALLY running / deployed-terraform show -json | python3 scripts/tfstate.py - -o graph.json # deployed cloud-docker inspect $(docker ps -q)| python3 scripts/dockerimports.py - -o graph.json # running containers-kubectl get all,ing,cm,secret,pvc -o json | python3 scripts/k8simports.py - -o graph.json # live cluster--# Data & interactions-python3 scripts/sqlerd.py schema.sql -o graph.json # SQL DDL → ER diagram-python3 scripts/ciimports.py . -o graph.json # GitHub Actions + GitLab CI -> pipeline DAG-python3 scripts/openapiimports.py openapi.yaml -o graph.json # OpenAPI/Swagger → API diagram (by method)-python3 scripts/seqlayout.py seq.json -o sequence.drawio # sequence diagram, direct to .drawio-python3 scripts/c4.py c4.json -o c4.drawio # C4 model, multi-page + drill-down+> [!TIP]+> **The diagram above was generated from this single prompt:**-# Diff two diagrams / snapshots → colour-coded "what changed"-python3 scripts/drawiodiff.py old.drawio new.drawio -o graph.json # +added -removed ~changed+```text+Create a microservices e-commerce architecture with Mobile/Web/Admin clients,+API Gateway (auth + rate limiting + routing), Auth/User/Order/Product/Payment+services, Kafka message queue, Notification service, and User DB / Order DB /+Product DB / Redis Cache / Stripe API+```-# Architecture time-lapse → self-contained HTML player of how a codebase grew-python3 scripts/timelapse.py src --importer pyimports # → architecture-evolution.html+The maintained [Architecture Studio showcase](examples/architecture-studio/)+covers code → IR → `.drawio`, conflict-aware synchronization that preserves a+manually tuned layout, and architecture → policy/views/what-if/accessible Story.+Every artifact is regenerated by one script and verified in the test suite.-# Reverse: describe an existing .drawio as structured Markdown (README / PR summary)-python3 scripts/explain.py architecture.drawio -o architecture.md+The skill is designed to route edges cleanly across different topologies, avoiding lines that cross through shapes:-# Diagram → PowerPoint deck (one page per slide; C4 model → presentation)-python3 scripts/drawio2pptx.py c4.drawio -o c4.pptx # needs: pip install python-pptx+<table>+ <tr>+ <td align="center" width="33%">+ <img src="assets/demo-star.png" alt="Star topology" width="100%"><br>+ <b>Star</b> · 7 nodes<br>+ <sub>Central message broker with 6 microservices radiating outward, no edge crossings on this example.</sub>+ </td>+ <td align="center" width="33%">+ <img src="assets/demo-layered.png" alt="Layered flow" width="100%"><br>+ <b>Layered</b> · 10 nodes / 4 tiers<br>+ <sub>E-commerce stack with horizontal and diagonal cross-connections routed via corridors.</sub>+ </td>+ <td align="center" width="33%">+ <img src="assets/demo-ring.png" alt="Ring cycle" width="100%"><br>+ <b>Ring</b> · 8 nodes<br>+ <sub>CI/CD pipeline with a closed loop and 2 spur branches flowing along the perimeter.</sub>+ </td>+ </tr>+</table>-# Interactive HTML viewer — pan/zoom/search/tabs + working drill-down links, one file-python3 scripts/drawiohtml.py c4.drawio -o c4.html+It also speaks **Mermaid** — standard types (flowchart, mindmap, **kanban**, gitGraph, timeline…) convert straight to native, editable `.drawio`. Here's a Kanban board (this project's own roadmap) generated from a few lines of Mermaid:-# Animated data-flow SVG — edges "flow" (marching ants); renders on GitHub-python3 scripts/svgflow.py architecture.drawio -o flow.svg+<div align="center">+ <img src="assets/kanban.png" width="620" alt="Kanban board generated by drawio-skill from Mermaid — this project's roadmap across Backlog / Todo / In Progress / Done">+</div>-# Reverse: .drawio → Mermaid flowchart (diagrams-as-code GitHub renders)-python3 scripts/drawio2mermaid.py architecture.drawio --fenced -o arch.md+**Tube-Map Mode** restyles a pipeline or journey as a London-Underground-style metro map — coloured lines, octilinear (H/V/45°) routing, and white interchange circles. Here's the skill's own flow (this map is `assets/tubemap.json`, ~20 lines):-# Language variant: extract labels → translate values → apply (layout untouched)-python3 scripts/relabel.py architecture.drawio --extract -o labels.json-python3 scripts/relabel.py architecture.drawio --map labels.json -o architecture_cn.drawio+<div align="center">+ <img src="assets/tubemap.png" width="720" alt="drawio-skill's pipeline drawn as a metro map — Author / Import / Repurpose / Analyze lines meeting at the Auto-layout and .drawio interchange stations">+</div>-# Re-theme an existing .drawio with a style preset (e.g. dark mode)-python3 scripts/restyle.py architecture.drawio --preset dark+Full walkthrough in [docs/USAGE.md](docs/USAGE.md).-# Colour an existing .drawio by data → cost / latency / traffic heat map-python3 scripts/heatmap.py architecture.drawio -m latency.csv --size -o hot.drawio+## 🗺️ From Real Sources to Diagrams-# any extractor → auto-layout → editable .drawio-python3 scripts/autolayout.py graph.json -o diagram.drawio+Beyond hand-authored diagrams, the skill turns **existing code, infrastructure, and schemas into diagrams** — no manual coordinates. Just ask:-# Image → editable .drawio — your vision extracts the graph JSON, this rebuilds it-python3 scripts/raster2drawio.py whiteboard-graph.json -o out.drawio+> *"Visualize the module structure of this Python project"* · *"Draw the class hierarchy of `mypackage`"*-# Watch a diagram build itself, node by node → HTML player (+ optional GIF)-python3 scripts/buildup.py architecture.drawio --gif build.gif # → buildup.html+<p align="center">+ <img src="assets/code-structure-example.png" width="900" alt="Auto-generated class hierarchy of Python's logging package — modules boxed, inheritance arrows resolved">+</p>-# Big diagram → boardroom exec summary (clustered) + click-to-drill-down to full-python3 scripts/compress.py big.drawio -o exec.drawio+<sub>↑ Python's <code>logging</code> package as a class hierarchy — one command, modules auto-boxed, every inheritance edge resolved.</sub>-# Decision-tree flowchart → click-through HTML triage runbook (no draw.io CLI needed)-python3 scripts/runbook.py triage.drawio -o triage.html+Under the hood it runs a bundled extractor → auto-layout → validate pipeline:-# CI: render base/head/diff PNGs + Markdown report for every .drawio a PR changed-python3 scripts/prdiff.py --base origin/main --head HEAD -o drawio-pr/report.md+```bash+# source -> graph JSON -> placed, editable .drawio+python3 scripts/tfimports.py ./infra -o graph.json # Terraform -> official AWS icons+python3 scripts/autolayout.py graph.json -o architecture.drawio-# Tube-Map Mode — restyle a pipeline / journey as a metro / subway map-python3 scripts/tubemap.py metro.json -o metro.drawio+# drift between two states, then share as one interactive file+python3 scripts/drawiodiff.py v1.drawio v2.drawio -o drift.json+python3 scripts/drawiohtml.py architecture.drawio -o architecture.html```-| Piece | What it does |+The full toolbox, grouped by stage:++| Stage | Tools || --- | --- |-| **13 extractors** | import graphs for **Python · JS/TS · Go · Rust**, **Python class inheritance**, **Terraform / Kubernetes / docker-compose** resource graphs (official cloud icons), **SQL DDL → ERD**, **OpenAPI / Swagger → API diagram** (operations coloured by HTTP method + schemas), **CI pipelines → DAG** (GitHub Actions `needs:` graphs + GitLab stages, with triggers, matrix sizes, reusable-workflow calls), and **live** infra from `terraform show -json` / `docker inspect` / `kubectl get -o json` (draw what's actually deployed) |-| **Diagram diff** | `drawiodiff.py` compares two `.drawio` (or two live snapshots) into one colour-coded graph — added=green, removed=red, changed=orange — so you can see architecture / infra **drift** at a glance |-| **Language variants** | `relabel.py` swaps every label via a JSON map with layout/styles/ids untouched — `--extract` dumps all labels, translate the values, `--map` applies them. One diagram → EN + CN twins for bilingual docs |-| **Re-theme** | `restyle.py` applies a style preset (built-in `dark`/`corporate`/… or your own) to an *existing* `.drawio` — palette remapped by hue so same-colored nodes stay grouped; layout and edge routing untouched |-| **Metric heat map** | `heatmap.py` recolours an existing `.drawio` from a CSV/JSON of per-node values — cost / latency / traffic / error-rate shaded low→high on a gradient (optional size-by-value + legend), matched by cell id or label |-| **Architecture time-lapse** | `timelapse.py` re-runs an importer across a repo's git history and assembles a self-contained HTML player — watch modules & edges appear over time (▶ play / ‹ › step) |-| **Diagram → Markdown** | `explain.py` reverses a `.drawio` into a structured description — components by tier, relations, per-page for C4 — for dropping an architecture summary into a README or PR |-| **Interactive viewer** | `drawiohtml.py` publishes a `.drawio` as one self-contained HTML — page tabs, drag-pan, wheel-zoom, node search, and a C4 model's drill-down links keep working. Share the file; no draw.io, no server |-| **Diagram → PowerPoint** | `drawio2pptx.py` turns a multi-page diagram into a 16:9 deck (one page per slide, page name as title) — a C4 model becomes a ready-to-present slideshow |-| **Animated data-flow** | `svgflow.py` makes a diagram's edges *flow* (marching-ants animation along each arrow) — a self-contained looping SVG that renders on GitHub, in docs, or as a slide background |-| **Diagram → Mermaid** | `drawio2mermaid.py` converts a `.drawio` into a Mermaid `flowchart` (containers → subgraphs, edge labels kept) — paste it into Markdown as diagrams-as-code that GitHub renders natively |-| **Sequence engine** | `seqlayout.py` computes lifeline / activation-bar / arrow geometry from a message list — no Graphviz, no hand placement |-| **Auto-layout** | Graphviz places nodes and routes orthogonal edges *around* them — removes the manual-coordinate ceiling for large graphs. `--tune` tries both directions and keeps the more readable one |-| **Transitive reduction** | drops edges implied by a longer path, turning a dense hairball into a traceable graph (asyncio: 149 → 46 edges) |-| **Nested containers** | `--group` boxes modules by sub-package, nested for deep package trees |-| **Deterministic validator** | `validate.py` lints the `.drawio` (dangling edges, duplicate ids, overlaps) before the visual self-check |--Layout needs Graphviz (`brew install graphviz` / `apt install graphviz`) — optional; everything else works without it. Full format + flag reference in [references/autolayout.md](skills/drawio-skill/references/autolayout.md). Regenerate, validate (`--strict` gate) and render headlessly in CI: [docs/CI.md](docs/CI.md).+| **Import** | 13 extractors: **Python · JS/TS · Go · Rust** import graphs, **Python class inheritance**, **Terraform / Kubernetes / docker-compose** with official cloud icons, **live** infra from `terraform show -json` / `docker inspect` / `kubectl get -o json`, **SQL DDL → ERD**, **OpenAPI → API diagram** (coloured by HTTP method), **GitHub Actions + GitLab CI → DAG** |+| **Compare & evolve** | `drawiodiff.py` colour-codes drift between two diagrams or two live snapshots (added=green, removed=red, changed=orange); `timelapse.py` replays git history as an HTML player; `prdiff.py` renders PR diffs in CI |+| **Repurpose** | `explain.py` → Markdown, `drawiohtml.py` → pan/zoom/search HTML viewer, `drawio2pptx.py` → deck, `svgflow.py` → animated SVG, `drawio2mermaid.py` → diagrams-as-code, `runbook.py` → clickable triage app, `compress.py` → exec summary with drill-down, `buildup.py` → self-drawing player, `tubemap.py` → metro map |+| **Restyle & enrich** | `restyle.py` applies presets by hue remap, `relabel.py` produces translated twins with layout untouched, `heatmap.py` shades nodes from a metrics CSV/JSON, `edgeports.py` un-stacks edges at shape boundaries |+| **Layout & lint** | `autolayout.py` (Graphviz placement, orthogonal routing, `--tune` direction picking, `--group` containers, transitive reduction: asyncio 149 → 46 edges), `seqlayout.py`, `c4.py`, and the deterministic `validate.py` linter (`--score` / `--strict`) |++Layout needs Graphviz (`brew install graphviz` / `apt install graphviz`) — optional; everything else works without it. Full format + flag reference in [references/autolayout.md](skills/drawio-skill/references/autolayout.md), every tool in [references/toolbox.md](skills/drawio-skill/references/toolbox.md). Regenerate, validate (`--strict` gate) and render headlessly in CI: [docs/CI.md](docs/CI.md).## 🧩 Supported Diagram Types@@ -338,11 +264,11 @@ python3 scripts/aiicons.py "openai" --embed # self-contained data URICapture a visual style once, reuse it everywhere. Five presets are built in — `default`, `corporate`, `handdrawn`, `colorblind-safe` (Okabe-Ito palette), `dark` — and you can teach the skill your own style from a `.drawio` file or a flat image:-```+```textDraw a microservices architecture using my "corporate" style```-```+```textLearn my style from ~/diagrams/brand.drawio as "mybrand"```diff --git a/README_CN.md b/README_CN.mdindex 78bf463..8f45615 100644--- a/README_CN.md+++ b/README_CN.md@@ -4,11 +4,11 @@[](https://github.com/Agents365-ai/drawio-skill/stargazers)[](https://github.com/Agents365-ai/drawio-skill/network/members)[](https://github.com/Agents365-ai/drawio-skill/releases/latest)-[](https://github.com/Agents365-ai/drawio-skill/commits/main)+[](https://github.com/Agents365-ai/drawio-skill/commits/main)[](https://skillsmp.com/skills/agents365-ai-drawio-skill-skills-drawio-skill-skill-md)[](https://github.com/Agents365-ai/365-skills)-[](https://agentskills.io)+[](https://agentskills.io)[English](README.md) · **中文** · [📖 在线文档](https://agents365-ai.github.io/drawio-skill/)@@ -18,94 +18,44 @@<img src="assets/hero-demo.gif" width="900" alt="演示:Terraform 源码生成带官方图标的架构图;v2 变更渲染为更新后的图"></p>-<p align="center">- <img src="assets/microservices-example.png" width="900" alt="微服务架构图:来自一条自然语言提示词">-</p>-## ✨ 核心亮点-- **白板照片 / 截图 → 可编辑图表** — 拍下旧 PNG 或实体白板,由视觉模型提取图结构,`raster2drawio.py` 按原布局重建为真正可编辑的 `.drawio`-- **架构数字孪生 / Diagram IR** —— 图的语义、来源与几何分离;同一模型可生成高管、系统、部署、数据流、安全五种可下钻视图-- **增量同步且不丢人工布局** —— `diagramctl sync` 只更新变化的节点和关系,保留手调坐标、样式与注释;删除项默认进入可审查状态-- **Diagram-as-Test** —— 用 YAML/JSON 规则检查直连数据库、循环依赖、孤立节点、owner、生产可观测性、外部超时、信任边界协议与颜色对比度-- **架构查询与体检** —— 查询任意组件/owner/边界/调用路径,发现单点连接、高耦合、缺失元数据,并生成 Markdown/JSON 审查报告-- **What-if + Story Mode** —— 模拟节点故障传播并生成高亮图;发布键盘可用、带文本替代/来源信息/多语言切换的离线 HTML 讲解页-- **内置 MCP 服务** —— `scripts/diagramctl_mcp.py` 把 9 个工具(`build/sync/views/architecture_test/review/query/whatif/story/doctor`)暴露给 Claude Desktop、Cursor、VS Code、Codex 等任何 MCP host;纯标准库、默认离线,无需 `mcp` 包-- **统一 CLI** —— `doctor/build/sync/views/query/test/review/whatif/story/publish/transform` 串起全部能力,核心语义工作流仅需 Python 且默认离线-- **11 种图表类型预设** —— ER 图、UML 类图、序列图、C4、架构图、ML/深度学习、流程图、SysML(BDD / IBD / 需求图 / 参数图)、BPMN、网络拓扑、跨职能泳道图-- **Mermaid → 原生 .drawio**(draw.io ≥ 30)—— 28 种标准类型直接用 Mermaid 文本作图(**mindmap、gantt、timeline、journey、pie、sankey、kanban**……),CLI 原生转成已布局、可编辑的 `.drawio` —— 只管结构,布局白送-- **可视化代码库** —— 提取并自动布局一个 Python / JS-TS / Go / Rust 项目的结构(导入关系图)或 Python 类继承层级 —— Graphviz 布点、传递约简、按子包嵌套的容器-- **IaC → 架构图** —— 把 **Terraform** 配置、**Kubernetes** manifest 或 **docker-compose** 文件直接变成架构图,每个资源渲染为**官方 AWS / Azure / GCP / K8s 图标**,连线来自真实引用(role ARN、selector、volume 挂载)-- **SQL DDL → ER 图** —— 解析 `CREATE TABLE` 语句,生成带 PK/FK 标记的表节点和鸦爪外键连线-- **确定性时序图** —— 用 JSON 描述参与者 + 消息序列,lifeline、自动追踪的激活条、箭头几何全部计算得出,无需手摆坐标-- **C4 模型 + 下钻** —— 一条命令生成多页 System Context → Container → Component 全套,官方 C4 形状配色,父元素**点击跳转**到子层页面-- **搜索 10,000+ 个官方形状** —— 直接拿到 AWS / Azure / GCP / Cisco / Kubernetes / UML / BPMN 图标的精确 style,不靠猜(杜绝 `shape=mxgraph.*` 拼错变空白框)-- **AI / LLM 品牌图标** —— 321 个 draw.io 自身没有的 logo(OpenAI、Claude、Gemini、Mistral、Llama、Ollama、LangChain……),外加 **18 个数据存储品牌**(Redis、Postgres、Qdrant、Milvus……),专为 LLM/RAG 应用架构图准备-- **自检 + 自动修复** —— 读取自己导出的 PNG,自动修复重叠、截断标签、连线堆叠等问题(最多 2 轮)-- **迭代反馈循环** —— 最多 5 轮定向优化-- **样式预设** —— 用 `.drawio` 文件或图片"教会"Skill 你的风格,命名保存后随时复用-- **整洁布局** —— 网格对齐,间距随图表规模缩放,连线避开节点-- **CI 就绪** —— 官方 `drawio-architecture-test` GitHub Action 在每个 PR 上强制执行架构契约,无需安装 draw.io/Xvfb/Graphviz;另有渲染 `.drawio` 的可视 PR diff action-- **多智能体、无后台服务** —— 可移植的 Agent Skills 包,外加可选的 MCP server 供宿主集成(核心语义工作流只需 Python,原生导出按需安装)--## 🗺️ 功能全景--<div align="center">- <img src="assets/mindmap-cn.png" width="900" alt="drawio-skill 功能全景图 —— 一张脑图看全所有能力,且由本 skill 自身绘制">-</div>--一张图看全 Skill 的全部能力 —— 图表类型、导入来源、布局引擎、样式、导出格式、二次利用,一目了然。本功能全景图即由 drawio-skill 自身绘制。--## 🖼️ 示例+**从一句话开始**-可维护的 [Architecture Studio 演示](examples/architecture-studio/) 覆盖代码 →-IR → `.drawio`、保留人工布局的冲突感知同步,以及架构模型 →-规则/多视图/What-if/无障碍 Story。所有产物都由一条脚本重建并纳入测试。+- **描述需求,得到可编辑的 `.drawio`** —— Skill 规划布局、写 XML、导出,然后读取自己的 PNG 自检并自动修复重叠、截断标签、连线堆叠(最多 2 轮),并支持最多 5 轮你的反馈迭代+- **Mermaid → 原生 .drawio**(draw.io ≥ 30)—— 28 种标准类型直接用 Mermaid 文本作图(**mindmap、gantt、timeline、journey、pie、sankey、kanban**……),CLI 原生转成已布局、可编辑的 `.drawio`:只管结构,布局白送+- **白板照片 / 截图 → 可编辑图表** —— 拍下旧 PNG 或实体白板,由视觉模型提取图结构,`raster2drawio.py` 按原布局重建为真正可编辑的 `.drawio`+- **11 种图表类型预设** —— ER 图、UML 类图、序列图、C4、架构图、ML/深度学习、流程图、SysML、BPMN、网络拓扑、跨职能泳道图-> [!TIP]-> **页首那张图就是用下面这条提示词生成的:**+**从真实来源生成**-```-画一个微服务电商架构图,包含 Mobile/Web/Admin 客户端,API Gateway(含认证+限流+路由),-Auth/User/Order/Product/Payment 微服务,Kafka 消息队列,Notification 服务,-以及 User DB / Order DB / Product DB / Redis Cache / Stripe API-```+- **可视化代码库** —— Python / JS-TS / Go / Rust 项目的导入关系图与 Python 类继承层级,Graphviz 布点、传递约简、按子包嵌套的容器+- **IaC 与实时基础设施** —— Terraform、Kubernetes、docker-compose 配置直接变成带**官方 AWS / Azure / GCP / K8s 图标**的架构图;也能从 `terraform show -json`、`docker inspect`、`kubectl get -o json` 画出**真正在运行**的东西+- **Schema 与流水线** —— SQL DDL → ER 图,OpenAPI/Swagger → 按 HTTP 方法着色的 API 图,GitHub Actions / GitLab CI → 流水线 DAG+- **确定性引擎** —— 序列图自动计算 lifeline 与激活条;多页 C4 模型支持点击下钻-Skill 在多种图表拓扑中尽量保持线条清晰路由,避免穿越无关形状:+**让图长期保持真实**-<table>- <tr>- <td align="center" width="33%">- <img src="assets/demo-star-cn.png" alt="星形拓扑" width="100%"><br>- <b>星形</b> · 7 个节点<br>- <sub>中央消息代理 + 6 个微服务辐射排列,本例中线条零交叉。</sub>- </td>- <td align="center" width="33%">- <img src="assets/demo-layered-cn.png" alt="分层流程" width="100%"><br>- <b>分层</b> · 10 节点 / 4 层<br>- <sub>电商架构,同层水平 + 对角线交叉连线均通过路由走廊绕行。</sub>- </td>- <td align="center" width="33%">- <img src="assets/demo-ring-cn.png" alt="环形拓扑" width="100%"><br>- <b>环形</b> · 8 个节点<br>- <sub>CI/CD 流水线,含闭合回路和 2 个分支,沿矩形外围流动。</sub>- </td>- </tr>-</table>+- **架构数字孪生 / Diagram IR** —— 图的语义、来源与几何分离;同一模型可生成高管、系统、部署、数据流、安全五种可下钻视图+- **增量同步且不丢人工布局** —— `diagramctl sync` 只更新变化的节点和关系,保留手调坐标、样式与注释;删除项默认进入可审查状态+- **Diagram-as-Test,进 CI** —— YAML/JSON 架构规则(直连数据库、循环依赖、孤立节点、信任边界、对比度……),配官方 GitHub Action 在每个 PR 上强制检查,另有渲染 `.drawio` 的可视 PR diff action+- **查询、体检、What-if** —— 查询组件/owner/调用路径,发现单点与高耦合,模拟节点故障传播,发布无障碍的 Story 讲解页+- **漂移与历史** —— 两张图或两个实时快照的彩色 diff;架构随 git 历史生长的时间轴播放器-它也懂 **Mermaid** —— 标准图类型(流程图、思维导图、**看板**、gitGraph、时间线…)可直接转成原生、可编辑的 `.drawio`。下面是一块看板(本项目自己的路线图),由几行 Mermaid 生成:+**分享与换肤**-<div align="center">- <img src="assets/kanban-cn.png" width="620" alt="drawio-skill 用 Mermaid 生成的看板 —— 本项目路线图,分为 需求池 / 待办 / 进行中 / 已完成">-</div>+- **一条命令二次利用** —— 交互式 HTML 查看器(平移/缩放/搜索)、PowerPoint 演示稿、数据流动画 SVG、Mermaid 或 Markdown 导出、点击式排查手册、高管摘要压缩+- **换肤与增强** —— 样式预设(自定义或内置 `dark`/`corporate`……)、布局不动的双语标签变体、数据驱动的热力图、地铁图模式+- **10,000+ 官方形状 + 321 个 AI/LLM logo** —— 精确解析 AWS / Cisco / K8s / UML 图标 style 而不靠猜,外加 draw.io 自身没有的品牌 logo+- **统一 CLI,可选 MCP 服务** —— `diagramctl doctor/build/sync/views/query/test/review/whatif/story/publish/transform`,核心工作流纯标准库且默认离线;MCP 服务把同样能力暴露给 Claude Desktop、Cursor、VS Code、Codex 等任何 MCP host。可移植到任何兼容 Agent Skills 的 agent,无需常驻服务-**Tube-Map 模式** 把流水线或旅程重绘成伦敦地铁风格的线路图 —— 彩色线路、八向(水平/垂直/45°)路由、白色换乘圈。下面是 skill 自己的处理流程(这张图就是 `assets/tubemap-cn.json`,约 20 行):+## 🗺️ 功能全景<div align="center">- <img src="assets/tubemap-cn.png" width="720" alt="drawio-skill 的处理流程画成地铁图 —— 作图 / 导入 / 二次利用 / 分析四条线在「自动布局」和「.drawio」两个换乘站汇合">+ <img src="assets/mindmap-cn.png" width="900" alt="drawio-skill 功能全景图 —— 一张脑图看全所有能力,且由本 skill 自身绘制"></div>-完整演练见 [docs/USAGE_CN.md](docs/USAGE_CN.md)。+一张图看全 Skill 的全部能力 —— 图表类型、导入来源、布局引擎、样式、导出格式、二次利用,一目了然。本功能全景图即由 drawio-skill 自身绘制。## 🚀 安装@@ -156,7 +106,7 @@ Autohand Code 也支持通过 `autohand --skill-install` 安装已收录在 Auto装好之后直接描述你想要的图表,比如画一个 ML 模型:-```+```text画一个用于机器翻译的 Transformer 编码器-解码器:6 层编码器(自注意力),6 层解码器(交叉注意力),输入嵌入(batch × 512 × 768),位置编码,最后一层输出投影。在层之间标注张量形状,按层类型配色。@@ -164,120 +114,96 @@ Autohand Code 也支持通过 `autohand --skill-install` 安装已收录在 AutoSkill 会自动规划布局、生成 `.drawio` XML、导出为你选择的格式、自检结果,并支持后续迭代。-## 🗺️ 可视化代码与基础设施--除了手写图表,Skill 还能把**现有代码、基础设施和 schema 变成图表** —— 无需手动摆坐标。直接说:--> *"可视化这个 Python 项目的模块结构"* · *"画出 `mypackage` 的类继承层级"*+## 🖼️ 示例<p align="center">- <img src="assets/code-structure-example.png" width="900" alt="Python logging 包的类继承层级 —— 模块自动分框,继承箭头自动解析">+ <img src="assets/microservices-example.png" width="900" alt="微服务架构图:来自一条自然语言提示词"></p>-<sub>↑ Python <code>logging</code> 包的类继承层级 —— 一条命令生成,模块自动分框,每条继承边都被解析。</sub>--幕后是一条 提取器 → 自动布局 → 校验 的流水线:--```bash-# 导入关系图 —— Python / JS-TS / Go / Rust-python3 scripts/pyimports.py myproject --group -o graph.json-python3 scripts/jsimports.py ./src --group -o graph.json-python3 scripts/goimports.py ./module --group -o graph.json-python3 scripts/rustimports.py ./crate --group -o graph.json--# Python 类继承层级-python3 scripts/pyclasses.py mypackage --group -o graph.json--# 基础设施即代码 —— 自动解析官方云图标-python3 scripts/tfimports.py ./infra -o graph.json # Terraform → AWS/Azure/GCP 图标-python3 scripts/k8simports.py ./manifests -o graph.json # K8s YAML/JSON → kind 图标-python3 scripts/composeimports.py compose.yml -o graph.json # 服务 + 命名卷--# 实时基础设施 —— 画「真正在运行 / 已部署」的东西-terraform show -json | python3 scripts/tfstate.py - -o graph.json # 已部署的云资源-docker inspect $(docker ps -q)| python3 scripts/dockerimports.py - -o graph.json # 正在运行的容器-kubectl get all,ing,cm,secret,pvc -o json | python3 scripts/k8simports.py - -o graph.json # 实时集群--# 数据与交互-python3 scripts/sqlerd.py schema.sql -o graph.json # SQL DDL → ER 图-python3 scripts/ciimports.py . -o graph.json # GitHub Actions + GitLab CI -> 流水线 DAG-python3 scripts/openapiimports.py openapi.yaml -o graph.json # OpenAPI/Swagger → API 图(按方法着色)-python3 scripts/seqlayout.py seq.json -o sequence.drawio # 时序图,直接生成 .drawio-python3 scripts/c4.py c4.json -o c4.drawio # C4 模型,多页 + 下钻+> [!TIP]+> **上面这张架构图就是用下面这条提示词生成的:**-# 对比两张图 / 两个快照 → 高亮「改了什么」-python3 scripts/drawiodiff.py old.drawio new.drawio -o graph.json # +新增 -删除 ~变更+```text+画一个微服务电商架构图,包含 Mobile/Web/Admin 客户端,API Gateway(含认证+限流+路由),+Auth/User/Order/Product/Payment 微服务,Kafka 消息队列,Notification 服务,+以及 User DB / Order DB / Product DB / Redis Cache / Stripe API+```-# 架构时间轴 → 从 git 历史生成「代码怎么长出来的」自包含 HTML 播放器-python3 scripts/timelapse.py src --importer pyimports # → architecture-evolution.html+可维护的 [Architecture Studio 演示](examples/architecture-studio/) 覆盖代码 →+IR → `.drawio`、保留人工布局的冲突感知同步,以及架构模型 →+规则/多视图/What-if/无障碍 Story。所有产物都由一条脚本重建并纳入测试。-# 反向:把已有的 .drawio 描述成结构化 Markdown(README / PR 摘要)-python3 scripts/explain.py architecture.drawio -o architecture.md+Skill 在多种图表拓扑中尽量保持线条清晰路由,避免穿越无关形状:-# 图 → PowerPoint 幻灯片(每页一张;C4 模型 → 演示稿)-python3 scripts/drawio2pptx.py c4.drawio -o c4.pptx # 需要: pip install python-pptx+<table>+ <tr>+ <td align="center" width="33%">+ <img src="assets/demo-star-cn.png" alt="星形拓扑" width="100%"><br>+ <b>星形</b> · 7 个节点<br>+ <sub>中央消息代理 + 6 个微服务辐射排列,本例中线条零交叉。</sub>+ </td>+ <td align="center" width="33%">+ <img src="assets/demo-layered-cn.png" alt="分层流程" width="100%"><br>+ <b>分层</b> · 10 节点 / 4 层<br>+ <sub>电商架构,同层水平 + 对角线交叉连线均通过路由走廊绕行。</sub>+ </td>+ <td align="center" width="33%">+ <img src="assets/demo-ring-cn.png" alt="环形拓扑" width="100%"><br>+ <b>环形</b> · 8 个节点<br>+ <sub>CI/CD 流水线,含闭合回路和 2 个分支,沿矩形外围流动。</sub>+ </td>+ </tr>+</table>-# 交互式 HTML 查看器 —— 平移/缩放/搜索/页签 + 可用的下钻链接,单文件-python3 scripts/drawiohtml.py c4.drawio -o c4.html+它也懂 **Mermaid** —— 标准图类型(流程图、思维导图、**看板**、gitGraph、时间线…)可直接转成原生、可编辑的 `.drawio`。下面是一块看板(本项目自己的路线图),由几行 Mermaid 生成:-# 数据流动画 SVG —— 让边「流动」起来(marching ants);GitHub 可直接渲染-python3 scripts/svgflow.py architecture.drawio -o flow.svg+<div align="center">+ <img src="assets/kanban-cn.png" width="620" alt="drawio-skill 用 Mermaid 生成的看板 —— 本项目路线图,分为 需求池 / 待办 / 进行中 / 已完成">+</div>-# 反向:.drawio → Mermaid 流程图(GitHub 原生渲染的 diagrams-as-code)-python3 scripts/drawio2mermaid.py architecture.drawio --fenced -o arch.md+**Tube-Map 模式** 把流水线或旅程重绘成伦敦地铁风格的线路图 —— 彩色线路、八向(水平/垂直/45°)路由、白色换乘圈。下面是 skill 自己的处理流程(这张图就是 `assets/tubemap-cn.json`,约 20 行):-# 语言变体:提取标签 → 翻译值 → 应用(布局不动)-python3 scripts/relabel.py architecture.drawio --extract -o labels.json-python3 scripts/relabel.py architecture.drawio --map labels.json -o architecture_cn.drawio+<div align="center">+ <img src="assets/tubemap-cn.png" width="720" alt="drawio-skill 的处理流程画成地铁图 —— 作图 / 导入 / 二次利用 / 分析四条线在「自动布局」和「.drawio」两个换乘站汇合">+</div>-# 给已有 .drawio 换主题(如暗色模式)-python3 scripts/restyle.py architecture.drawio --preset dark+完整演练见 [docs/USAGE_CN.md](docs/USAGE_CN.md)。-# 按数据给已有 .drawio 上色 → 成本 / 延迟 / 流量热力图-python3 scripts/heatmap.py architecture.drawio -m latency.csv --size -o hot.drawio+## 🗺️ 从真实来源到图表-# 任一提取器 → 自动布局 → 可编辑的 .drawio-python3 scripts/autolayout.py graph.json -o diagram.drawio+除了手写图表,Skill 还能把**现有代码、基础设施和 schema 变成图表** —— 无需手动摆坐标。直接说:-# 图片 → 可编辑 .drawio —— 由你的视觉提取出图结构 JSON,本脚本据此重建-python3 scripts/raster2drawio.py whiteboard-graph.json -o out.drawio+> *"可视化这个 Python 项目的模块结构"* · *"画出 `mypackage` 的类继承层级"*-# 看一张图按节点依赖顺序逐步"画出来" → HTML 播放器(可选 GIF)-python3 scripts/buildup.py architecture.drawio --gif build.gif # → buildup.html+<p align="center">+ <img src="assets/code-structure-example.png" width="900" alt="Python logging 包的类继承层级 —— 模块自动分框,继承箭头自动解析">+</p>-# 大图 → 高管摘要(聚类)+ 点击下钻回到完整图-python3 scripts/compress.py big.drawio -o exec.drawio+<sub>↑ Python <code>logging</code> 包的类继承层级 —— 一条命令生成,模块自动分框,每条继承边都被解析。</sub>-# 决策树流程图 → 点击式 HTML 排查手册(无需 draw.io CLI)-python3 scripts/runbook.py triage.drawio -o triage.html+幕后是一条 提取器 → 自动布局 → 校验 的流水线:-# CI:为 PR 改动的每个 .drawio 渲染 base/head/diff PNG + Markdown 报告-python3 scripts/prdiff.py --base origin/main --head HEAD -o drawio-pr/report.md+```bash+# 源码 -> graph JSON -> 已布局、可编辑的 .drawio+python3 scripts/tfimports.py ./infra -o graph.json # Terraform -> 官方 AWS 图标+python3 scripts/autolayout.py graph.json -o architecture.drawio-# Tube-Map 模式 —— 把流水线 / 旅程重绘成地铁风格线路图-python3 scripts/tubemap.py metro.json -o metro.drawio+# 两个状态之间的漂移,然后发布成一个交互式文件+python3 scripts/drawiodiff.py v1.drawio v2.drawio -o drift.json+python3 scripts/drawiohtml.py architecture.drawio -o architecture.html```-| 组件 | 作用 |+按阶段分组的完整工具箱:++| 阶段 | 工具 || --- | --- |-| **13 个提取器** | **Python · JS/TS · Go · Rust** 的导入关系图、**Python 类继承**、**Terraform / Kubernetes / docker-compose** 资源图(自动配官方云图标)、**SQL DDL → ER 图**、**OpenAPI / Swagger → API 图**(按 HTTP 方法着色的接口 + schema),**CI 流水线 → DAG**(GitHub Actions `needs:` 依赖图 + GitLab 阶段,含触发器、matrix 规模、可复用工作流调用)、以及从 `terraform show -json` / `docker inspect` / `kubectl get -o json` 提取的**实时**基础设施(画出真正已部署的样子) |-| **图对比 (diff)** | `drawiodiff.py` 把两张 `.drawio`(或两个实时快照)对比成一张彩色图 —— 新增=绿、删除=红、变更=橙 —— 一眼看出架构 / 基础设施**漂移** |-| **语言变体** | `relabel.py` 按 JSON 映射批量换标签,布局/样式/id 全不动 —— `--extract` 导出全部标签,翻译值后 `--map` 应用。一张图 → 中英双胞胎,双语文档必备 |-| **换主题** | `restyle.py` 给**已有** `.drawio` 应用风格预设(内置 `dark`/`corporate`/… 或自定义)—— 按色相重映射调色板,同色节点保持同组;布局与连线路由不动 |-| **指标热力图** | `heatmap.py` 按一份「节点→数值」的 CSV/JSON 给已有 `.drawio` 重新着色 —— 成本 / 延迟 / 流量 / 错误率沿渐变由低到高上色(可选按值缩放节点 + 自动图例),按 cell id 或标签匹配 |-| **架构时间轴** | `timelapse.py` 沿 git 历史逐个提交重跑提取器,拼成一个自包含 HTML 播放器 —— 看着模块和依赖边随时间长出来(▶ 播放 / ‹ › 单步) |-| **图 → Markdown** | `explain.py` 把一张 `.drawio` 反向描述成结构化文档 —— 按层级列出组件、关系、C4 多页分节 —— 方便把架构摘要塞进 README 或 PR |-| **交互式查看器** | `drawiohtml.py` 把 `.drawio` 发布成一个自包含 HTML —— 页签、拖拽平移、滚轮缩放、节点搜索,C4 模型的下钻链接照常可点。发一个文件即可分享;不需要 draw.io,也不需要服务器 |-| **图 → PowerPoint** | `drawio2pptx.py` 把多页图变成 16:9 幻灯片(每页一张、页名当标题)—— C4 模型一键变成可演示的 slideshow |-| **数据流动画** | `svgflow.py` 让图里的边「流动」起来(沿箭头方向的 marching-ants 动画)—— 自包含循环 SVG,可在 GitHub、文档或幻灯片背景里直接播放 |-| **图 → Mermaid** | `drawio2mermaid.py` 把 `.drawio` 转成 Mermaid `flowchart`(容器变 subgraph、保留边标签)—— 粘进 Markdown 就是 GitHub 原生渲染的 diagrams-as-code |-| **时序图引擎** | `seqlayout.py` 从消息列表直接算出 lifeline / 激活条 / 箭头几何 —— 不需要 Graphviz,不需要手摆 |-| **自动布局** | Graphviz 自动布点,正交连线**绕开**节点 —— 大图不再需要手动摆坐标。`--tune` 双向各排一次取更可读的 |-| **传递约简** | 删掉被更长路径蕴含的边,把密集的"毛线团"变成可读图(asyncio:149 → 46 条边) |-| **嵌套容器** | `--group` 按子包给模块分框,深层包树自动嵌套 |-| **确定性校验器** | `validate.py` 在视觉自检前先做结构 lint(悬空边、重复 id、重叠) |--布局需要 Graphviz(`brew install graphviz` / `apt install graphviz`)—— 可选,其余功能无需它。完整格式与参数见 [references/autolayout.md](skills/drawio-skill/references/autolayout.md)。在 CI 中重新生成、校验(`--strict` 门禁)并无头渲染:[docs/CI_CN.md](docs/CI_CN.md)。+| **导入** | 13 个提取器:**Python · JS/TS · Go / Rust** 导入关系图、**Python 类继承**、**Terraform / Kubernetes / docker-compose**(官方云图标)、从 `terraform show -json` / `docker inspect` / `kubectl get -o json` 提取的**实时**基础设施、**SQL DDL → ER 图**、**OpenAPI → API 图**(按 HTTP 方法着色)、**GitHub Actions + GitLab CI → DAG** |+| **对比与演进** | `drawiodiff.py` 用颜色标出两张图或两个实时快照的漂移(新增=绿、删除=红、变更=橙);`timelapse.py` 把 git 历史重放成 HTML 播放器;`prdiff.py` 在 CI 里渲染 PR diff |+| **二次利用** | `explain.py` → Markdown,`drawiohtml.py` → 平移缩放搜索的 HTML 查看器,`drawio2pptx.py` → 演示稿,`svgflow.py` → 动画 SVG,`drawio2mermaid.py` → diagrams-as-code,`runbook.py` → 点击式排查应用,`compress.py` → 可下钻的高管摘要,`buildup.py` → 自动绘制播放器,`tubemap.py` → 地铁图 |+| **换肤与增强** | `restyle.py` 按色相重映射应用预设,`relabel.py` 布局不动地生成翻译变体,`heatmap.py` 按指标 CSV/JSON 给节点上色,`edgeports.py` 解开形状边界上堆叠的连线 |+| **布局与校验** | `autolayout.py`(Graphviz 布点、正交路由、`--tune` 自动选方向、`--group` 容器、传递约简:asyncio 149 → 46 条边)、`seqlayout.py`、`c4.py`,以及确定性 `validate.py` linter(`--score` / `--strict`) |++布局需要 Graphviz(`brew install graphviz` / `apt install graphviz`)—— 可选,其余功能无需它。完整格式与参数见 [references/autolayout.md](skills/drawio-skill/references/autolayout.md),全部工具见 [references/toolbox.md](skills/drawio-skill/references/toolbox.md)。在 CI 中重新生成、校验(`--strict` 门禁)并无头渲染:[docs/CI_CN.md](docs/CI_CN.md)。## 🧩 支持的图表类型@@ -335,11 +261,11 @@ python3 scripts/aiicons.py "openai" --embed # 内联为自包含 data URI把视觉风格"教"给 Skill 一次,所有图表自动复用。内置五种预设:`default`、`corporate`、`handdrawn`、`colorblind-safe`(Okabe-Ito 色盲安全色板)、`dark`;也可以从 `.drawio` 文件或图片学习你的风格:-```+```text画一个微服务架构图,使用我的 "corporate" 样式```-```+```text从 ~/diagrams/brand.drawio 学习我的样式,保存为 "mybrand"```