Figure spec

From pdl-openair/OpenAIR · View interactive version

Figure spec is an AI agent skill from the GitHub repository pdl-openair/OpenAIR. Generate deterministic publication-quality architecture, workflow, and pipeline diagrams from structured JSON (FigureSpec) into editable SVG. Use when user says \"架构图\", \"workflow 图\", \"pipeline 图\", \"确定性矢量图\", \"figure spec\", \"draw architecture\", or needs precise, editable, publication-ready

How to use this skill

Skill file

FigureSpec: Deterministic JSON → SVG Figure Generation

Generate publication-quality architecture diagrams, workflow pipelines, audit cascades, and system topology figures as editable SVG vector graphics using a deterministic JSON → SVG renderer.

When to Use This Skill

Use figure-spec for:

Do NOT use for:

Core Properties

Tool Location

scripts/figure_renderer.py is bundled with this skill (Python standard library only for SVG).

Resolve SKILL_DIR to the directory containing this SKILL.md; never resolve the renderer

relative to the research CWD or an ARIS checkout. Invoke via:

python -I "$SKILL_DIR/scripts/figure_renderer.py" render <spec.json> --output <out.svg>
python -I "$SKILL_DIR/scripts/figure_renderer.py" validate <spec.json>
python -I "$SKILL_DIR/scripts/figure_renderer.py" schema

Workflow

Step 1: Understand the Diagram Goal

From $ARGUMENTS (description or path to PAPER_PLAN.md / NARRATIVE_REPORT.md), identify:

Step 2: Draft the FigureSpec JSON

Canvas sizing guide:

Start from a template based on the diagram type:

Architecture (stacked rows):

{
  "canvas": {"width": 900, "height": 520},
  "nodes": [
    {"id": "layer1_label", "label": "Layer 1", "x": 450, "y": 60, ...},
    {"id": "node_a", "label": "A", "x": 180, "y": 120, ...},
    {"id": "node_b", "label": "B", "x": 350, "y": 120, ...}
  ],
  "edges": [...],
  "groups": [
    {"label": "Layer 1", "node_ids": ["node_a", "node_b"], "fill": "#F0F9FF", "stroke": "#BAE6FD"}
  ]
}

Workflow (left-to-right chain):

{
  "canvas": {"width": 900, "height": 300},
  "nodes": [
    {"id": "step1", "label": "Step 1", "x": 100, "y": 150, "shape": "rounded"},
    {"id": "step2", "label": "Step 2", "x": 280, "y": 150, "shape": "rounded"}
  ],
  "edges": [
    {"from": "step1", "to": "step2", "label": "produces"}
  ]
}

Decision diamond:

{"id": "check", "label": "Passes?", "shape": "diamond", "x": 450, "y": 200}

Step 3: Render and Validate

# Validate first
python -I "$SKILL_DIR/scripts/figure_renderer.py" validate /tmp/spec.json

# Render to SVG
python -I "$SKILL_DIR/scripts/figure_renderer.py" render /tmp/spec.json --output figures/fig_arch.svg

# Convert to PDF for LaTeX inclusion
rsvg-convert -f pdf figures/fig_arch.svg -o figures/fig_arch.pdf

If validation fails, inspect the error (missing field, duplicate ID, overlap warning, invalid hex color) and fix the JSON.

Step 4: Visual Review

Open the SVG/PDF and check:

If issues found, edit the JSON spec (never the generated SVG) and re-render.

Step 4b: Markdown 内联渲染尺寸(面向 .md 报告)

当下游是 Markdown 报告(如 experiment-report 的 experiment_report.md,SVG 以

<img src="..."> 内联而非 LaTeX \includegraphics)时,SVG 的内嵌 font-size

(通常 10–14px)直接决定渲染字号。SVG 是矢量、放大不失真,所以策略是**放大到标注

清晰**,而非缩小。

<style>/节点 font-size 最小值)。

字号放大到正文(~16px)量级、略小或持平(标注仍清晰)。绝不用默认 ![alt](path)

(渲染器按 viewBox 原始尺寸 1:1 显示,1180×430 的管线图会缩到过小或铺满爆宽)。

```html

<img src="figures/pipeline.svg" width="900" alt="管线图:四阶段管线与降级链路" />

```

只设 width、不设 height(保纵横比)。alt 描述图内容、非文件名。

\textwidth 决定。本节只针对 Markdown 内联。

Step 5: Iterate with Codex Review (Optional, for High-Stakes Figures)

For paper architecture figures, invoke cross-model review:

mcp__codex__codex:
  model: gpt-5.4
  config: {"model_reasoning_effort": "xhigh"}
  prompt: |
    Review this SVG figure for a technical paper (architecture / workflow diagram).

    Spec file: /path/to/spec.json
    Rendered: /path/to/fig.svg

    Evaluate:
    1. Clarity (C): can a reader understand the system from this figure alone?
    2. Readability (R): font sizes, label placement, visual hierarchy
    3. Semantic accuracy (S): do relationships match the described system?

    Score each axis 1-10 and list specific issues to fix.

Iterate until all three axes ≥ 7/10. The ARIS tech report figures went through 5 rounds of this loop to reach C:7/R:7/S:8.

Schema Quick Reference

Run python -I "$SKILL_DIR/scripts/figure_renderer.py" schema for the authoritative schema.

Nodes

| Field | Required | Default | Notes |

|-------|----------|---------|-------|

| id | ✓ | — | Unique |

| label | ✓ | — | \n for multi-line |

| x, y | ✓ | — | Center coordinates |

| width, height | | 120, 50 | |

| shape | | rounded | rect / rounded / circle / ellipse / diamond |

| fill, stroke | | auto from palette | #RRGGBB |

| text_color | | #333333 | |

| font_size | | 14 | Override style default |

Edges

| Field | Default | Notes |

|-------|---------|-------|

| from, to | required | Same = self-loop |

| label | — | Short edge label |

| style | solid | solid / dashed / dotted |

| color | #555555 | |

| curve | false | Curved path |

Groups

Rectangular background regions framing a set of nodes:

{"label": "Layer Name", "node_ids": ["a", "b", "c"], "fill": "#EFF6FF", "stroke": "#BFDBFE"}

Design Patterns

Pattern 1: Layered Architecture

Stack rows of related nodes, each row is a group, add inter-layer arrows with semantic labels (uses↓, produces↑, checks↓).

Pattern 2: Hub-and-Spoke

Central node (e.g., Executor), peripheral nodes (skills, tools), solid arrows for primary relations, dashed for feedback.

Pattern 3: Pipeline with Feedback

Left-to-right main flow, feedback arrows curve below with curve: true.

Pattern 4: Audit Cascade

Three-stage horizontal cascade with inputs feeding in from top, outputs exiting right, each stage in its own group.

Anti-Patterns

Output Contract

Integration with Other Skills

Review Tracing

Optional review does not require an ARIS checkout or helper scripts. If review tracing is requested, save the prompt and actual response beside the figure source in the project artifact directory. Never invent a review result.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.