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
feat(autolayout): colour groups from the skill palette, not monochrome (#25)
Agents365.ai0d8eb418151f
diff --git a/assets/code-structure-example.png b/assets/code-structure-example.pngindex 9724559..919cbd6 100644Binary files a/assets/code-structure-example.png and b/assets/code-structure-example.png differdiff --git a/skills/drawio-skill/SKILL.md b/skills/drawio-skill/SKILL.mdindex bf57d9a..030fbeb 100644--- a/skills/drawio-skill/SKILL.md+++ b/skills/drawio-skill/SKILL.md@@ -1,12 +1,12 @@---name: drawio-skill-version: 1.12.0+version: 1.13.0description: Use when the user requests diagrams, flowcharts, architecture diagrams, ER diagrams, UML / sequence / class diagrams, network topology, ML/DL model figures (Transformer/CNN/LSTM), mind maps, or any visualization. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Best suited when the diagram needs custom styling, rich shape vocabulary, swimlanes, or exportable images (PNG/SVG/PDF/JPG). Generates .drawio XML and exports locally via the native draw.io desktop CLI.license: MIThomepage: https://github.com/Agents365-ai/drawio-skillcompatibility: Requires draw.io desktop app CLI on PATH (macOS/Linux/Windows). Self-check step requires a vision-enabled model (e.g., Claude Sonnet/Opus); gracefully skipped if unavailable. Optional auto-layout (scripts/autolayout.py) needs Graphviz (dot).platforms: [macos, linux, windows]-metadata: {"openclaw":{"requires":{"anyBins":["draw.io","drawio"]},"emoji":"📐","os":["darwin","linux","win32"],"install":[{"id":"brew-drawio","kind":"brew","formula":"drawio","bins":["drawio"],"label":"Install draw.io via Homebrew","os":["darwin"]},{"id":"brew-graphviz","kind":"brew","formula":"graphviz","bins":["dot"],"label":"Install Graphviz for optional autolayout.py","os":["darwin"],"optional":true}]},"hermes":{"tags":["drawio","diagram","flowchart","architecture","visualization","uml"],"category":"design","requires_tools":["drawio","draw.io"],"related_skills":["mermaid","excalidraw","plantuml"]},"author":"Agents365-ai","version":"1.12.0"}+metadata: {"openclaw":{"requires":{"anyBins":["draw.io","drawio"]},"emoji":"📐","os":["darwin","linux","win32"],"install":[{"id":"brew-drawio","kind":"brew","formula":"drawio","bins":["drawio"],"label":"Install draw.io via Homebrew","os":["darwin"]},{"id":"brew-graphviz","kind":"brew","formula":"graphviz","bins":["dot"],"label":"Install Graphviz for optional autolayout.py","os":["darwin"],"optional":true}]},"hermes":{"tags":["drawio","diagram","flowchart","architecture","visualization","uml"],"category":"design","requires_tools":["drawio","draw.io"],"related_skills":["mermaid","excalidraw","plantuml"]},"author":"Agents365-ai","version":"1.13.0"}---# Draw.io Diagramsdiff --git a/skills/drawio-skill/references/autolayout.md b/skills/drawio-skill/references/autolayout.mdindex 1a170e3..5cbed0f 100644--- a/skills/drawio-skill/references/autolayout.md+++ b/skills/drawio-skill/references/autolayout.md@@ -51,7 +51,7 @@ It prints `wrote diagram.drawio (N nodes, M edges)` to stderr and writes a norma| `direction` | no | `TB` | `TB` (top→bottom) or `LR` (left→right) — the layout rank direction || `nodes[].id` | **yes** | — | Unique; must not be `0` or `1` (reserved for draw.io root cells) || `nodes[].label` | no | the `id` | Display text; auto XML-escaped |-| `nodes[].style` | no | blue rounded box | Any draw.io style string — reuse the role/shape styles from `diagram-types.md` and the active preset |+| `nodes[].style` | no | group colour, else blue | Any draw.io style string — reuse the role/shape styles from `diagram-types.md` and the active preset. A styleless node is tinted by its group (see **Containers / grouping**); an explicit style always wins || `nodes[].width` / `height` | no | `120` / `60` | Pixels; dot lays out at this real size || `nodes[].group` | no | none | Group key, or a `/`-delimited path (`"core/db"`) for **nested** containers — nodes sharing a path are boxed together (see **Containers / grouping**) || `nodes[].groupLabel` | no | last path segment | Title shown on the node's deepest container (first node with the path wins) |@@ -70,6 +70,7 @@ Give nodes a `group` key and the script wraps each group in a labeled container**Nesting.** A `group` value with `/` separators builds nested containers: `"core/db"` puts the node inside a `db` box that itself sits inside a `core` box. Every path prefix becomes a container, so an arbitrarily deep package tree maps to nested boxes. A node can also sit *directly* in a parent box (`group: "core"`) alongside a sibling sub-box (`group: "core/db"`).+- **Colour by group.** Each top-level group is assigned a colour from the skill's own palette (`styles/built-in/default.json`, cycled in role order: blue → green → orange → purple → yellow → red → grey). A node with no `style` of its own is tinted with its group's colour, and the container's border + title match — so related modules read as a coloured cluster instead of monochrome boxes. A node that carries its own `style` (e.g. from an applied preset) is left untouched. Pass `--mono` to turn colouring off (dashed grey boxes, default-blue nodes — the previous look). Ungrouped graphs are unaffected.- Each container box is the bounding box of its members and child boxes plus a uniform padding. The dot cluster margin is set to that same padding, so each box equals dot's cluster box — which dot keeps non-overlapping at **any nesting depth**.- The title sits in the top padding (`verticalAlign=top`); the box title is the path's last segment, or a member's `groupLabel`.- Containers are visual only (no edges of their own). Edges still connect node→node and route across containers normally.diff --git a/skills/drawio-skill/scripts/autolayout.py b/skills/drawio-skill/scripts/autolayout.pyindex 8220f68..51e2858 100644--- a/skills/drawio-skill/scripts/autolayout.py+++ b/skills/drawio-skill/scripts/autolayout.py@@ -25,6 +25,7 @@ Usage: python3 autolayout.py graph.json [-o diagram.drawio]"""import argparseimport json+import osimport shleximport subprocessimport sys@@ -35,6 +36,32 @@ NODE_STYLE = "rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6cEDGE_STYLE = "html=1;rounded=0;"GROUP_STYLE = ("rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeColor=#999999;""verticalAlign=top;fontStyle=2;dashed=1;")+# Group colours come from the skill's own palette (styles/built-in/default.json)+# so there is a single source of truth, not a second list baked in here. When a+# grouped graph is laid out, each top-level group takes the next colour (cycled+# in a fixed, harmonious role order) so related modules read as a coloured+# cluster. Nodes that carry their own `style` keep it; only styleless grouped+# nodes are tinted. Disable with --mono.+_PALETTE_ORDER = ["primary", "success", "accent", "secondary", "warning", "danger", "neutral"]+_PALETTE_FILE = os.path.join(os.path.dirname(__file__), "..", "styles", "built-in", "default.json")+_FALLBACK_PALETTE = [("#dae8fc", "#6c8ebf"), ("#d5e8d4", "#82b366"), ("#ffe6cc", "#d79b00"),+ ("#e1d5e7", "#9673a6"), ("#fff2cc", "#d6b656"), ("#f8cecc", "#b85450")]+++def load_palette():+ """Ordered (fill, stroke) list from the default preset's palette; fall back+ to the same colours inline if the preset file can't be read."""+ try:+ pal = json.load(open(_PALETTE_FILE, encoding="utf-8"))["palette"]+ colors = [(pal[r]["fillColor"], pal[r]["strokeColor"]) for r in _PALETTE_ORDER if r in pal]+ if colors:+ return colors+ except (OSError, KeyError, ValueError):+ pass+ return _FALLBACK_PALETTE+++PALETTE = load_palette()# Uniform container padding; the title sits in the top pad (verticalAlign=top).# dot's cluster margin is set to this same value so each container box equals# dot's cluster box — which dot guarantees never overlaps, at any nesting depth.@@ -142,7 +169,13 @@ def layout(dot_src):return height, pos, edges-def to_drawio(graph, height, pos, edge_pts):+def group_style(stroke):+ """Container box styled with a group's colour (coloured border + title)."""+ return (f"rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeColor={stroke};"+ f"fontColor={stroke};verticalAlign=top;fontStyle=2;dashed=1;")+++def to_drawio(graph, height, pos, edge_pts, color=True):nodes = graph["nodes"]# Absolute snapped rect for every placed node.rects = {}@@ -158,6 +191,16 @@ def to_drawio(graph, height, pos, edge_pts):# Parse the (possibly nested) group tree and assign each container a# collision-free id and a title (the path's last segment, or a member's groupLabel).gpath, direct, children, ordered = group_tree(nodes)+ # Assign each top-level group a palette colour, in order of first appearance.+ top_order = []+ for node in nodes:+ t = gpath.get(node["id"])+ if t and t[0] not in top_order:+ top_order.append(t[0])++ def gcolor(seg):+ return PALETTE[top_order.index(seg) % len(PALETTE)]+used = {n["id"] for n in nodes}label_override = {}for node in nodes:@@ -208,9 +251,10 @@ def to_drawio(graph, height, pos, edge_pts):continuegx, gy, gw, gh = gbox[p]x, y, parent = rebase(gx, gy, p[:-1] if len(p) > 1 else None)+ gstyle = group_style(gcolor(p[0])[1]) if color else GROUP_STYLEcells.append(f' <mxCell id="{attr(gid[p])}" value="{attr(glabel[p])}" '- f'style="{GROUP_STYLE}" vertex="1" parent="{attr(parent)}">\n'+ f'style="{gstyle}" vertex="1" parent="{attr(parent)}">\n'f' <mxGeometry x="{x}" y="{y}" width="{gw}" height="{gh}" as="geometry"/>\n'f" </mxCell>")@@ -220,7 +264,13 @@ def to_drawio(graph, height, pos, edge_pts):continuerx, ry, w, h = rects[nid]x, y, parent = rebase(rx, ry, gpath.get(nid) if gpath.get(nid) in gbox else None)- style = node.get("style", NODE_STYLE)+ if node.get("style"):+ style = node["style"] # explicit style always wins+ elif color and nid in gpath:+ fill, stroke = gcolor(gpath[nid][0]) # tint styleless nodes by group+ style = f"rounded=1;whiteSpace=wrap;html=1;fillColor={fill};strokeColor={stroke};"+ else:+ style = NODE_STYLEcells.append(f' <mxCell id="{attr(nid)}" value="{attr(node.get("label", nid))}" 'f'style="{style}" vertex="1" parent="{attr(parent)}">\n'@@ -264,11 +314,13 @@ def main():ap = argparse.ArgumentParser(description="Auto-layout a graph JSON into draw.io XML.")ap.add_argument("input", help="graph JSON file")ap.add_argument("-o", "--output", help="output .drawio path (default: stdout)")+ ap.add_argument("--mono", action="store_true",+ help="don't colour groups by palette (monochrome boxes)")args = ap.parse_args()with open(args.input, encoding="utf-8") as f:graph = json.load(f)height, pos, edge_pts = layout(build_dot(graph))- xml = to_drawio(graph, height, pos, edge_pts)+ xml = to_drawio(graph, height, pos, edge_pts, color=not args.mono)if args.output:with open(args.output, "w", encoding="utf-8") as f:f.write(xml)diff --git a/skills/drawio-skill/scripts/pyclasses.py b/skills/drawio-skill/scripts/pyclasses.pyindex e4ced44..570acb4 100644--- a/skills/drawio-skill/scripts/pyclasses.py+++ b/skills/drawio-skill/scripts/pyclasses.py@@ -26,8 +26,6 @@ import reimport subprocessimport sys-CLASS_STYLE = "rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;"-def discover(root):"""Map dotted module name -> file path; qualify with the package name when@@ -129,7 +127,9 @@ def main():short = lambda m: m[len(strip):] if strip and m.startswith(strip) else mdef node(cid):- d = {"id": cid, "label": cid.rsplit(".", 1)[1], "style": CLASS_STYLE}+ # No hard-coded colour: autolayout tints nodes by their group (module),+ # so a grouped class hierarchy reads as coloured-by-module.+ d = {"id": cid, "label": cid.rsplit(".", 1)[1]}if args.group:mod = classes[cid][0]path = short(mod).replace(".", "/") # module path -> nested boxes