diagram-generator
Generate conceptual diagrams from article content. Trigger when the operator says 'genera diagramma', 'diagram', 'visual spec', 'conceptual map', or when a page is created/updated and needs a structural visualization.
Diagram Generator — From Content to Structure
When an article is created or updated, this skill generates a conceptual diagram that captures the logical structure: key concepts, directional relations, and contextual copy for each node.
When to use
- A new article is published and needs a visual structure
- An existing article is updated and the diagram is stale
- The operator asks for a conceptual map of any content
- The admin panel "Generate Diagram AI" button is clicked
How it works
- Read the article content (title + body)
- Extract 3-7 key concepts as nodes
- Identify relations: cause→effect, sequence, dependency, tension
- Generate contextual copy for each node (observer positioning: when → content → result)
- Produce a DiagramSpec JSON compatible with the renderer
Two modes
LLM mode (default): sends content to LLM API. Best results — understands narrative.
Requires: GODEL_API_KEY + GODEL_API_URL (or DIAGRAM_API_KEY + DIAGRAM_API_URL)
Structural mode: rule-based extraction from headers and text patterns. No API needed. Use when: offline, quick generation, or API unavailable.
CLI
# LLM mode
python diagram_generator.py --content article.md --json
# Structural mode
python diagram_generator.py --content article.md --structural --json
# From stdin
cat article.md | python diagram_generator.py --stdin --title "Article Title"
As library
from diagram_generator import generate_diagram, generate_diagram_structural
spec = generate_diagram('Title', 'Content...', lang='it')
# spec = {type, entities: [{id, label, color, context, link}], interactions: [{from, to, type}]}
Copy rules for nodes
Every node's context field positions the observer:
- When/where this matters (situation)
- What happens (content)
- What comes out (result)
Inclusive language: "we/our" not "you/tu". The visitor is on the same boat.
Iteration
The first generation is a draft. Review, edit labels and relations, test with a fresh eye. 4 clear nodes > 7 cluttered nodes.
Complete guide
See DIAGRAM_GENERATOR_GUIDE.md in plugins/d-nd-core/scripts/.
$ARGUMENTS