@drunkcoding/agents-and-skills 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@
12
12
  "name": "tech-graph",
13
13
  "source": "./plugins/tech-graph",
14
14
  "description": "6-step wizard for technical diagrams (SVG/PNG) via fireworks-tech-graph",
15
- "version": "0.0.4",
15
+ "version": "0.0.6",
16
16
  "category": "diagram",
17
17
  "keywords": [
18
18
  "diagram",
@@ -26,7 +26,7 @@
26
26
  "name": "html-effectiveness",
27
27
  "source": "./plugins/html-effectiveness",
28
28
  "description": "Generate self-contained interactive HTML reports from 20 upstream templates via a conversational agent.",
29
- "version": "0.0.4",
29
+ "version": "0.0.6",
30
30
  "category": "reports",
31
31
  "keywords": [
32
32
  "html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drunkcoding/agents-and-skills",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Personal collection of Claude Code skills and agents, installable via `npx skills`.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "html-effectiveness",
3
3
  "displayName": "HTML Effectiveness Reports",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "description": "Generate self-contained interactive HTML reports from 20 upstream templates via a conversational agent.",
6
6
  "author": {
7
7
  "name": "Steven Hoang"
@@ -13,5 +13,11 @@
13
13
  "incident",
14
14
  "slide-deck",
15
15
  "decision-matrix"
16
+ ],
17
+ "skills": [
18
+ "skills/html-effectiveness"
19
+ ],
20
+ "agents": [
21
+ "agents/report-builder.md"
16
22
  ]
17
23
  }
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: report-builder
3
+ description: Conversational wizard that helps the user generate an HTML report from one of 20 templates (status, incident, PR writeup, decision matrix, slide deck, code review, research explainer, ...). Use when the user wants a polished interactive HTML output instead of markdown. Reads templates/manifest.json and CLAUDE.md html-effectiveness.reportDir for output path.
4
+ tools: Read, Write, Bash, Glob, Grep
5
+ ---
6
+
7
+ You are `report-builder`, a conversational wizard that turns the user's intent into a polished, self-contained interactive HTML report.
8
+
9
+ ## Role
10
+
11
+ Guide the user from intent → rendered HTML in a single file. Speak briefly. Ask one question at a time. Match the user's caveman setting if active.
12
+
13
+ ## Startup
14
+
15
+ On every run:
16
+
17
+ 1. Read `CLAUDE.md` from the repo root. Extract `html-effectiveness.reportDir` if present; fallback `docs/reports/`.
18
+ 2. Read `plugins/html-effectiveness/templates/manifest.json` (catalog + slot schemas).
19
+ 3. Greet briefly; confirm the user's intent.
20
+
21
+ ## Conversation loop
22
+
23
+ 1. **Classify** — infer the top 2-3 templates from the user's stated need by matching `use_cases` and `pattern` fields in the manifest.
24
+ 2. **Confirm** — present the top picks with one-line summaries; let the user pick or override.
25
+ 3. **Slot fill** — walk the required slots from `manifest[id].slots` in order. Batch obvious slots and infer from prior context to minimize questions. Cap at 6 user-facing questions; force render with best-guess defaults beyond that, with a one-line note of what was assumed.
26
+ 4. **Preview data** — show a JSON summary of slot values; ask "looks right?" before rendering.
27
+
28
+ ## Render
29
+
30
+ 1. Compute slug from title (kebab-case, ASCII-only, max 60 chars).
31
+ 2. Build path `<reportDir>/YYYY-MM-DD-<slug>.html`.
32
+ 3. Write `<path>.data.json` first (so the user can re-render later).
33
+ 4. Invoke render script via Bash:
34
+
35
+ ```bash
36
+ node plugins/html-effectiveness/scripts/render.js \
37
+ --template=<id> \
38
+ --data=<path>.data.json \
39
+ --out=<path>
40
+ ```
41
+
42
+ 5. On success: print the absolute path; offer `snip render --format html < <path>` to preview in the browser.
43
+ 6. On render error: surface stderr; locate the offending slot from the `template:slot` prefix; ask the user to fix; retry.
44
+
45
+ ## Regen path
46
+
47
+ If the user invokes the agent on an existing `<name>.data.json`:
48
+
49
+ - Skip slot fill.
50
+ - Edit only the slots the user wants changed.
51
+ - Re-render to the same path (or new path if requested).
52
+
53
+ ## Guardrails
54
+
55
+ - Never write to paths outside the repo root.
56
+ - Create `reportDir` if missing.
57
+ - If the output file already exists, ask the user before overwriting; suggest `-2`, `-3`, ... suffix.
58
+ - Refuse to render if the manifest is missing or the requested template id doesn't exist; surface the valid id list.
59
+
60
+ ## Tone
61
+
62
+ Terse, expert, no fluff. Caveman-mode-aware. Code blocks unchanged.
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: html-effectiveness
3
+ description: Use when the user wants dense information, status, comparison, plan, code review, or research output rendered as a self-contained interactive HTML report instead of plain markdown. Renders via plugin templates and scripts/render.js into a single HTML file under docs/reports/ (overridable via CLAUDE.md).
4
+ ---
5
+
6
+ # HTML Effectiveness — Interactive Output
7
+
8
+ Turn dense information into a self-contained, browser-based HTML document the user can explore interactively. Markdown is a wall of text; HTML is a spatial, interactive document. Zero dependencies, single file, opens anywhere.
9
+
10
+ ## When to invoke
11
+
12
+ Invoke this skill when the user asks for any of:
13
+
14
+ - "Make a report", "render as HTML", "interactive view"
15
+ - Status updates: weekly status, monthly recap, project digest
16
+ - Incident: post-mortem, outage writeup
17
+ - Code: PR review, code understanding, exploration of implementation approaches
18
+ - Design: design system, component variants, prototypes
19
+ - Research: feature explainer, concept explainer, tutorial
20
+ - Planning: implementation plan, rollout, roadmap
21
+ - Decisions: comparison board, decision matrix
22
+ - Visual: slide deck, flowchart, SVG illustration
23
+ - Editor tooling: triage board, feature flags, prompt tuner
24
+
25
+ If the request fits a report-style output and rendering as HTML would be clearer than markdown, invoke the skill and delegate to the `report-builder` agent.
26
+
27
+ ## Template catalog
28
+
29
+ 20 templates ship with this plugin. See `docs/template-gallery.md` for the full table (auto-generated from `templates/manifest.json`). Highlights:
30
+
31
+ - `01` / `02` — exploration comparisons (code approaches, visual designs)
32
+ - `03` — code review board
33
+ - `04` — code understanding / architecture walk-through
34
+ - `05` / `06` — design system, component variants
35
+ - `07` / `08` — prototype animation, prototype interaction
36
+ - `09` — slide deck (arrow-key nav)
37
+ - `10` — SVG illustrations
38
+ - `11` — status report
39
+ - `12` — incident report
40
+ - `13` — flowchart diagram
41
+ - `14` / `15` — research explainers (feature, concept)
42
+ - `16` — implementation plan (annotated timeline)
43
+ - `17` — PR writeup
44
+ - `18` / `19` / `20` — editor tools (triage board, feature flags, prompt tuner)
45
+
46
+ ## Render contract
47
+
48
+ Always uphold these invariants:
49
+
50
+ 1. **Inline-bundle** — the final HTML is single-file, self-contained. No `<link>` or `<script src>` references. The render script inlines `base.css`, `components.css`, `base.js`, plus any per-template extras.
51
+ 2. **Escape strings** — string slots are HTML-escaped. Raw-HTML slots are only allowed when the manifest flags the slot as `"html"`.
52
+ 3. **Output path** — read repo `CLAUDE.md` for `html-effectiveness.reportDir`; fallback to `docs/reports/`. Filename: `YYYY-MM-DD-<slug>.html`; slug derived from title (kebab-case, ASCII-only, max 60 chars).
53
+ 4. **Sidecar** — `<report>.html.data.json` is always written alongside the HTML so the report can be regenerated by re-running `render.js` on the sidecar.
54
+
55
+ ## Workflow
56
+
57
+ 1. Pick template via `manifest.json` (match user intent against `use_cases` and `pattern`).
58
+ 2. Fill slot data from the conversation; record it as JSON.
59
+ 3. Invoke render script:
60
+
61
+ ```bash
62
+ node plugins/html-effectiveness/scripts/render.js \
63
+ --template=<id> \
64
+ --data=<data.json> \
65
+ --out=<reportDir>/YYYY-MM-DD-<slug>.html
66
+ ```
67
+
68
+ 4. Confirm output path to the user; offer `snip render --format html < <path>` to preview in browser.
69
+
70
+ ## Design principles
71
+
72
+ Preserved from upstream `ThariqS/html-effectiveness`:
73
+
74
+ - Avoid purple/blue gradient backgrounds, generic feature grids, center-everything layouts, decorative patterns.
75
+ - Prioritize real data, scannable hierarchy, spatial grouping, progressive disclosure over decoration.
76
+
77
+ ## Technical requirements
78
+
79
+ - Single `.html` file, fully self-contained.
80
+ - CSS variables for light/dark theming via `prefers-color-scheme`.
81
+ - System font stack and 150ms smooth transitions.
82
+ - Responsive design 375px–1440px.
83
+ - Semantic HTML5 with ARIA labels.
84
+ - Print styles that expand all hidden content.
85
+
86
+ ## Failure modes
87
+
88
+ - **No template fits**: present the top 2 closest matches with one-line summaries; ask the user to confirm, or offer plain-markdown fallback. Never silently force a poor fit.
89
+ - **Missing slot data**: ask one question at a time; respect the cap of 6 questions before forcing render with best-guess defaults plus a note of what was assumed.
90
+ - **Render error**: surface `template:slot expected <type> got <type>` to the user; fix the slot value; retry.
91
+
92
+ ## Sync
93
+
94
+ Generated from upstream `ThariqS/html-effectiveness@<sha pinned in manifest>`. To refresh: `node plugins/html-effectiveness/scripts/sync-upstream.js check`. If drift is detected, re-fetch the affected template, re-run extraction, and review the diff before committing.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tech-graph",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Step-by-step wizard for generating technical diagrams as SVG+PNG.",
5
5
  "author": {
6
6
  "name": "steven"
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: fireworks-tech-graph
2
+ name: tech-graph
3
3
  description: >-
4
4
  Use when the user wants to create any technical diagram - architecture, data
5
5
  flow, flowchart, sequence, agent/memory, or concept map - and export as
@@ -8,32 +8,10 @@ description: >-
8
8
  system/flow description the user wants illustrated.
9
9
  ---
10
10
 
11
- # Fireworks Tech Graph
11
+ # Tech Graph
12
12
 
13
13
  Generate production-quality SVG technical diagrams exported as PNG via `cairosvg` (recommended), `rsvg-convert`, or `puppeteer`.
14
14
 
15
- ## Install Source
16
-
17
- Install this skill from GitHub:
18
-
19
- ```bash
20
- npx skills add yizhiyanhua-ai/fireworks-tech-graph
21
- ```
22
-
23
- Public package page:
24
-
25
- ```text
26
- https://www.npmjs.com/package/@yizhiyanhua-ai/fireworks-tech-graph
27
- ```
28
-
29
- Do not pass `@yizhiyanhua-ai/fireworks-tech-graph` directly to `skills add`, because the CLI expects a GitHub or local repository source.
30
-
31
- Update command:
32
-
33
- ```bash
34
- npx skills add yizhiyanhua-ai/fireworks-tech-graph --force -g -y
35
- ```
36
-
37
15
  ## Helper Scripts (Recommended)
38
16
 
39
17
  Four helper scripts in `scripts/` directory provide stable SVG generation and validation:
@@ -87,9 +65,9 @@ python3 ./scripts/generate-from-template.py architecture ./output/arch.svg '{"ti
87
65
  1. **Classify** the diagram type (see Diagram Types below)
88
66
  2. **Extract structure** — identify layers, nodes, edges, flows, and semantic groups from user description
89
67
  3. **Plan layout** — apply the layout rules for the diagram type
90
- 4. **Load style reference** — always load `references/style-1-flat-icon.md` unless user specifies another; load the matching `references/style-N.md` for exact color tokens and SVG patterns
68
+ 4. **Load style reference** — always load [style-1-flat-icon](references/style-1-flat-icon.md) unless user specifies another; load the matching style-N file (e.g. [style-2-dark-terminal](references/style-2-dark-terminal.md), [style-3-blueprint](references/style-3-blueprint.md), [style-4-notion-clean](references/style-4-notion-clean.md), [style-5-glassmorphism](references/style-5-glassmorphism.md), [style-6-claude-official](references/style-6-claude-official.md), [style-7-openai](references/style-7-openai.md)) for exact color tokens and SVG patterns
91
69
  5. **Map nodes to shapes** — use Shape Vocabulary below
92
- 6. **Check icon needs** — load `references/icons.md` for known products
70
+ 6. **Check icon needs** — load [icons](references/icons.md) for known products
93
71
  7. **Write SVG** with adaptive strategy (see SVG Generation Strategy below)
94
72
  8. **Validate**: Run `python3 -c "import xml.etree.ElementTree as ET; ET.parse('file.svg')"` to check XML syntax
95
73
  9. **Export PNG**: Use `cairosvg` (recommended). See **SVG → PNG Conversion** section below for full method comparison
@@ -105,175 +83,7 @@ python3 ./scripts/generate-from-template.py architecture ./output/arch.svg '{"ti
105
83
 
106
84
  ## Diagram Types & Layout Rules
107
85
 
108
- ### Architecture Diagram
109
- Nodes = services/components. Group into **horizontal layers** (top→bottom or left→right).
110
- - Typical layers: Client → Gateway/LB → Services → Data/Storage
111
- - Use `<rect>` dashed containers to group related services in the same layer
112
- - Arrow direction follows data/request flow
113
- - ViewBox: `0 0 960 600` standard, `0 0 960 800` for tall stacks
114
-
115
- ### Data Flow Diagram
116
- Emphasizes **what data moves where**. Focus on data transformation.
117
- - Label every arrow with the data type (e.g., "embeddings", "query", "context")
118
- - Use wider arrows (`stroke-width: 2.5`) for primary data paths
119
- - Dashed arrows for control/trigger flows
120
- - Color arrows by data category (not just Agent/RAG — use semantics)
121
-
122
- ### Flowchart / Process Flow
123
- Sequential decision/process steps.
124
- - Top-to-bottom preferred; left-to-right for wide flows
125
- - Diamond shapes for decisions, rounded rects for processes, parallelograms for I/O
126
- - Keep node labels short (≤3 words); put detail in sub-labels
127
- - Align nodes on a grid: x positions snap to 120px intervals, y to 80px
128
-
129
- ### Agent Architecture Diagram
130
- Shows how an AI agent reasons, uses tools, and manages memory.
131
- Key conceptual layers to always consider:
132
- - **Input layer**: User, query, trigger
133
- - **Agent core**: LLM, reasoning loop, planner
134
- - **Memory layer**: Short-term (context window), Long-term (vector/graph DB), Episodic
135
- - **Tool layer**: Tool calls, APIs, search, code execution
136
- - **Output layer**: Response, action, side-effects
137
- Use cyclic arrows (loop arcs) to show iterative reasoning. Separate memory types visually.
138
-
139
- ### Memory Architecture Diagram (Mem0, MemGPT-style)
140
- Specialized agent diagram focused on memory operations.
141
- - Show memory **write path** and **read path** separately (different arrow colors)
142
- - Memory tiers: Working Memory → Short-term → Long-term → External Store
143
- - Label memory operations: `store()`, `retrieve()`, `forget()`, `consolidate()`
144
- - Use stacked rects or layered cylinders for storage tiers
145
-
146
- ### Sequence Diagram
147
- Time-ordered message exchanges between participants.
148
- - Participants as vertical **lifelines** (top labels + vertical dashed lines)
149
- - Messages as horizontal arrows between lifelines, top-to-bottom time order
150
- - Activation boxes (thin filled rects on lifeline) show active processing
151
- - Group with `<rect>` loop/alt frames with label in top-left corner
152
- - ViewBox height = 80 + (num_messages × 50)
153
-
154
- ### Comparison / Feature Matrix
155
- Side-by-side comparison of approaches, systems, or components.
156
- - Column headers = systems, row headers = attributes
157
- - Row height: 40px; column width: min 120px; header row height: 50px
158
- - Checked cell: tinted background (e.g. `#dcfce7`) + `✓` checkmark; unsupported: `#f9fafb` fill
159
- - Alternating row fills (`#f9fafb` / `#ffffff`) for readability
160
- - Max readable columns: 5; beyond that, split into two diagrams
161
-
162
- ### Timeline / Gantt
163
- Horizontal time axis showing durations, phases, and milestones.
164
- - X-axis = time (weeks/months/quarters); Y-axis = items/tasks/phases
165
- - Bars: rounded rects, colored by category, labeled inside or beside
166
- - Milestone markers: diamond or filled circle at specific x position with label above
167
- - ViewBox: `0 0 960 400` typical; wider for many time periods: `0 0 1200 400`
168
-
169
- ### Mind Map / Concept Map
170
- Radial layout from central concept.
171
- - Central node at `cx=480, cy=280`
172
- - First-level branches: evenly distributed around center (360/N degrees)
173
- - Second-level branches: branch off first-level at 30-45° offset
174
- - Use curved `<path>` with cubic bezier for branches, not straight lines
175
-
176
- ### Class Diagram (UML)
177
- Static structure showing classes, attributes, methods, and relationships.
178
- - **Class box**: 3-compartment rect (name / attributes / methods), min width 160px
179
- - Top compartment: class name, bold, centered (abstract = *italic*)
180
- - Middle: attributes with visibility (`+` public, `-` private, `#` protected)
181
- - Bottom: method signatures, same visibility notation
182
- - **Relationships**:
183
- - Inheritance (extends): solid line + hollow triangle arrowhead, child → parent
184
- - Implementation (interface): dashed line + hollow triangle, class → interface
185
- - Association: solid line + open arrowhead, label with multiplicity (1, 0..*, 1..*)
186
- - Aggregation: solid line + hollow diamond on container side
187
- - Composition: solid line + filled diamond on container side
188
- - Dependency: dashed line + open arrowhead
189
- - **Interface**: `<<interface>>` stereotype above name, or circle/lollipop notation
190
- - **Enum**: compartment rect with `<<enumeration>>` stereotype, values in bottom
191
- - Layout: parent classes top, children below; interfaces to the left/right of implementors
192
- - ViewBox: `0 0 960 600` standard; `0 0 960 800` for deep hierarchies
193
-
194
- ### Use Case Diagram (UML)
195
- System functionality from user perspective.
196
- - **Actor**: stick figure (circle head + body line) placed outside system boundary
197
- - Label below figure, 13-14px
198
- - Primary actors on left, secondary/supporting on right
199
- - **Use case**: ellipse with label centered inside, min 140×60px
200
- - Keep names verb phrases: "Create Order", "Process Payment"
201
- - **System boundary**: large rect with dashed border + system name in top-left
202
- - **Relationships**:
203
- - Include: dashed arrow `<<include>>` from base to included use case
204
- - Extend: dashed arrow `<<extend>>` from extension to base use case
205
- - Generalization: solid line + hollow triangle (specialized → general)
206
- - Layout: system boundary centered, actors outside, use cases inside
207
- - ViewBox: `0 0 960 600` standard
208
-
209
- ### State Machine Diagram (UML)
210
- Lifecycle states and transitions of an entity.
211
- - **State**: rounded rect with state name, min 120×50px
212
- - Internal activities: small text `entry/ action`, `exit/ action`, `do/ activity`
213
- - **Initial state**: filled black circle (r=8), one outgoing arrow
214
- - **Final state**: filled circle (r=8) inside hollow circle (r=12)
215
- - **Choice**: small hollow diamond, guard labels on outgoing arrows `[condition]`
216
- - **Transition**: arrow with optional label `event [guard] / action`
217
- - Guard conditions in square brackets
218
- - Actions after `/`
219
- - **Composite/nested state**: larger rect containing sub-states, with name tab
220
- - **Fork/join**: thick horizontal or vertical black bar (synchronization)
221
- - Layout: initial state top-left, final state bottom-right, flow top-to-bottom
222
- - ViewBox: `0 0 960 600` standard
223
-
224
- ### ER Diagram (Entity-Relationship)
225
- Database schema and data relationships.
226
- - **Entity**: rect with entity name in header (bold), attributes below
227
- - Primary key attribute: underlined
228
- - Foreign key: italic or marked with (FK)
229
- - Min width: 160px; attribute font-size: 12px
230
- - **Relationship**: diamond shape on connecting line
231
- - Label inside diamond: "has", "belongs to", "enrolls in"
232
- - Cardinality labels near entity: `1`, `N`, `0..1`, `0..*`, `1..*`
233
- - **Weak entity**: double-bordered rect with double diamond relationship
234
- - **Associative entity**: diamond + rect hybrid (rect with diamond inside)
235
- - Line style: solid for identifying relationships, dashed for non-identifying
236
- - Layout: entities in 2-3 rows, relationships between related entities
237
- - ViewBox: `0 0 960 600` standard; wider `0 0 1200 600` for many entities
238
-
239
- ### Network Topology
240
- Physical or logical network infrastructure.
241
- - **Devices**: icon-like rects or rounded rects
242
- - Router: circle with cross arrows
243
- - Switch: rect with arrow grid
244
- - Server: stacked rect (rack icon)
245
- - Firewall: brick-pattern rect or shield shape
246
- - Load Balancer: horizontal split rect with arrows
247
- - Cloud: cloud path (overlapping arcs)
248
- - **Connections**: lines between device centers
249
- - Ethernet/wired: solid line, label bandwidth
250
- - Wireless: dashed line with WiFi symbol
251
- - VPN: dashed line with lock icon
252
- - **Subnets/Zones**: dashed rect containers with zone label (DMZ, Internal, External)
253
- - **Labels**: device hostname + IP below, 12-13px
254
- - Layout: tiered top-to-bottom (Internet → Edge → Core → Access → Endpoints)
255
- - ViewBox: `0 0 960 600` standard
256
-
257
- ## UML Coverage Map
258
-
259
- Full mapping of UML 14 diagram types to supported diagram types:
260
-
261
- | UML Diagram | Supported As | Notes |
262
- |-------------|-------------|-------|
263
- | Class | Class Diagram | Full UML notation |
264
- | Component | Architecture Diagram | Use colored fills per component type |
265
- | Deployment | Architecture Diagram | Add node/instance labels |
266
- | Package | Architecture Diagram | Use dashed grouping containers |
267
- | Composite Structure | Architecture Diagram | Nested rects within components |
268
- | Object | Class Diagram | Instance boxes with underlined name |
269
- | Use Case | Use Case Diagram | Full actor/ellipse/relationship |
270
- | Activity | Flowchart / Process Flow | Add fork/join bars |
271
- | State Machine | State Machine Diagram | Full UML notation |
272
- | Sequence | Sequence Diagram | Add alt/opt/loop frames |
273
- | Communication | — | Approximate with Sequence (swap axes) |
274
- | Timing | Timeline | Adapt time axis |
275
- | Interaction Overview | Flowchart | Combine activity + sequence fragments |
276
- | ER Diagram | ER Diagram | Chen/Crow's foot notation |
86
+ Per-type layout rules + UML coverage map: see [diagram-types](references/diagram-types.md). Covers Architecture, Data Flow, Flowchart, Agent, Memory, Sequence, Comparison, Timeline, Mind Map, Class (UML), Use Case (UML), State Machine (UML), ER, Network Topology, plus full UML-14 mapping.
277
87
 
278
88
  ## Shape Vocabulary
279
89
 
@@ -416,119 +226,13 @@ python3 -c "import cairosvg; cairosvg.svg2png(url='file.svg', write_to='/tmp/tes
416
226
 
417
227
  ## SVG → PNG Conversion
418
228
 
419
- ### Method Comparison
420
-
421
- | Tool | Install | Render Quality | Notes |
422
- |------|---------|----------------|-------|
423
- | `rsvg-convert` | System (often preinstalled) | ⚠️ Fair | Drops some CSS styles and `<foreignObject>` elements — missing borders/text on complex SVGs |
424
- | **`cairosvg` (recommended)** | `pip install cairosvg` | ✅ Good | Solid CSS support; clearly better than rsvg-convert |
425
- | `puppeteer` (headless Chrome) | `npm install puppeteer` | ✅✅ Best | Real browser engine; 100% fidelity but heavy (Node + Chromium) |
426
-
427
- ### Recommended: cairosvg (Python one-liner)
229
+ Default `cairosvg` one-liner:
428
230
 
429
231
  ```bash
430
- # Single file (2x resolution for retina/docs)
431
232
  python3 -c "import cairosvg; cairosvg.svg2png(url='input.svg', write_to='output.png', scale=2)"
432
-
433
- # Batch convert all SVGs in a directory
434
- python3 -c "
435
- import cairosvg, os, glob
436
- d = 'docs/00-core'
437
- for svg in sorted(glob.glob(os.path.join(d, '*.svg'))):
438
- png = svg.replace('.svg', '.png')
439
- cairosvg.svg2png(url=svg, write_to=png, scale=2)
440
- print(f'Done: {os.path.basename(svg)} -> {os.path.basename(png)}')
441
- "
442
233
  ```
443
234
 
444
- > `scale=2` produces 2x resolution PNG, ideal for high-DPI screens and embedded docs.
445
-
446
- ### Fallback: rsvg-convert (simple but may drop styles)
447
-
448
- ```bash
449
- # Single file
450
- rsvg-convert -w 1920 file.svg -o file.png
451
-
452
- # Batch (not recommended — complex SVGs may lose elements)
453
- for f in docs/00-core/*.svg; do rsvg-convert -o "${f%.svg}.png" "$f"; done
454
-
455
- # 2x resolution
456
- for f in docs/00-core/*.svg; do rsvg-convert -z 2 -o "${f%.svg}.png" "$f"; done
457
- ```
458
-
459
- ### Highest Fidelity: puppeteer (headless Chrome)
460
-
461
- ```bash
462
- npm install puppeteer # auto-downloads Chromium
463
- node svg2png.js [directory]
464
- ```
465
-
466
- <details>
467
- <summary>svg2png.js — full puppeteer script</summary>
468
-
469
- ```javascript
470
- const puppeteer = require('puppeteer');
471
- const fs = require('fs');
472
- const path = require('path');
473
-
474
- (async () => {
475
- const dir = process.argv[2] || '.';
476
- const svgFiles = fs.readdirSync(dir).filter(f => f.endsWith('.svg'));
477
-
478
- const browser = await puppeteer.launch({
479
- headless: 'new',
480
- args: ['--no-sandbox', '--disable-setuid-sandbox']
481
- });
482
-
483
- for (const file of svgFiles) {
484
- const svgPath = path.resolve(dir, file);
485
- const pngPath = svgPath.replace(/\.svg$/, '.png');
486
- const svgContent = fs.readFileSync(svgPath, 'utf-8');
487
-
488
- const wMatch = svgContent.match(/width="(\d+)/);
489
- const hMatch = svgContent.match(/height="(\d+)/);
490
- const vbMatch = svgContent.match(/viewBox="[^"]*\s(\d+)\s(\d+)"/);
491
-
492
- let width = wMatch ? parseInt(wMatch[1]) : (vbMatch ? parseInt(vbMatch[1]) : 1200);
493
- let height = hMatch ? parseInt(hMatch[1]) : (vbMatch ? parseInt(vbMatch[2]) : 800);
494
-
495
- const scale = 2;
496
- const page = await browser.newPage();
497
- await page.setViewport({ width, height, deviceScaleFactor: scale });
498
-
499
- const html = `<!DOCTYPE html>
500
- <html><head><style>
501
- body { margin: 0; padding: 0; background: transparent; }
502
- img { display: block; }
503
- </style></head>
504
- <body>
505
- <img src="data:image/svg+xml;base64,${Buffer.from(svgContent).toString('base64')}" width="${width}" height="${height}" />
506
- </body></html>`;
507
-
508
- await page.setContent(html, { waitUntil: 'networkidle0' });
509
- await page.screenshot({ path: pngPath, type: 'png', omitBackground: true });
510
- await page.close();
511
-
512
- console.log(`Done: ${file} -> ${path.basename(pngPath)} (${width}x${height} @${scale}x)`);
513
- }
514
-
515
- await browser.close();
516
- })();
517
- ```
518
-
519
- </details>
520
-
521
- ### Gotchas (lessons learned)
522
-
523
- - `rsvg-convert` renders SVGs containing `<foreignObject>`, CSS `filter`, or complex `<style>` blocks **incompletely** — missing borders / missing text are the typical symptoms
524
- - `cairosvg` (built on Cairo) has much better CSS support than rsvg and is sufficient for most cases
525
- - If the SVG was generated by a browser (D3.js, Mermaid, etc.), only headless Chrome (puppeteer) renders it 100% faithfully
526
-
527
- ### Picking a Method
528
-
529
- 1. **Default** → `cairosvg` (pip install once, one-line conversion, good fidelity)
530
- 2. **No Python available** → `rsvg-convert` (acceptable for simple flat-color diagrams)
531
- 3. **Browser-generated SVG or pixel-perfect required** → `puppeteer`
235
+ Full method comparison (cairosvg / rsvg-convert / puppeteer), batch scripts, puppeteer renderer, and gotchas: see [svg-to-png](references/svg-to-png.md).
532
236
 
533
237
  ## Styles
534
238
 
@@ -537,16 +241,16 @@ const path = require('path');
537
241
  | 1 | **Flat Icon** (default) | White | Blogs, docs, presentations |
538
242
  | 2 | **Dark Terminal** | `#0f0f1a` | GitHub, dev articles |
539
243
  | 3 | **Blueprint** | `#0a1628` | Architecture docs |
540
- | 4 | **Notion Clean** | White, minimal | Notionnce |
244
+ | 4 | **Notion Clean** | White, minimal | Notion |
541
245
  | 5 | **Glassmorphism** | Dark gradient | Product sites, keynotes |
542
246
  | 6 | **Claude Official** | Warm cream `#f8f6f3` | Anthropic-style diagrams |
543
247
  | 7 | **OpenAI Official** | Pure white `#ffffff` | OpenAI-style diagrams |
544
248
 
545
- Load `references/style-N.md` for exact color tokens and SVG patterns.
249
+ Load the matching style-N file in [references/](references/) for exact color tokens and SVG patterns.
546
250
 
547
251
  ## Style Selection
548
252
 
549
- **Default**: Style 1 (Flat Icon) for most diagrams. Load `references/style-diagram-matrix.md` for detailed style-to-diagram-type recommendations.
253
+ **Default**: Style 1 (Flat Icon) for most diagrams. Load [style-diagram-matrix](references/style-diagram-matrix.md) for detailed style-to-diagram-type recommendations.
550
254
 
551
255
  These patterns appear frequently — internalize them:
552
256
 
@@ -0,0 +1,171 @@
1
+ # Diagram Types & Layout Rules
2
+
3
+ ## Architecture Diagram
4
+ Nodes = services/components. Group into **horizontal layers** (top→bottom or left→right).
5
+ - Typical layers: Client → Gateway/LB → Services → Data/Storage
6
+ - Use `<rect>` dashed containers to group related services in the same layer
7
+ - Arrow direction follows data/request flow
8
+ - ViewBox: `0 0 960 600` standard, `0 0 960 800` for tall stacks
9
+
10
+ ## Data Flow Diagram
11
+ Emphasizes **what data moves where**. Focus on data transformation.
12
+ - Label every arrow with the data type (e.g., "embeddings", "query", "context")
13
+ - Use wider arrows (`stroke-width: 2.5`) for primary data paths
14
+ - Dashed arrows for control/trigger flows
15
+ - Color arrows by data category (not just Agent/RAG — use semantics)
16
+
17
+ ## Flowchart / Process Flow
18
+ Sequential decision/process steps.
19
+ - Top-to-bottom preferred; left-to-right for wide flows
20
+ - Diamond shapes for decisions, rounded rects for processes, parallelograms for I/O
21
+ - Keep node labels short (≤3 words); put detail in sub-labels
22
+ - Align nodes on a grid: x positions snap to 120px intervals, y to 80px
23
+
24
+ ## Agent Architecture Diagram
25
+ Shows how an AI agent reasons, uses tools, and manages memory.
26
+ Key conceptual layers to always consider:
27
+ - **Input layer**: User, query, trigger
28
+ - **Agent core**: LLM, reasoning loop, planner
29
+ - **Memory layer**: Short-term (context window), Long-term (vector/graph DB), Episodic
30
+ - **Tool layer**: Tool calls, APIs, search, code execution
31
+ - **Output layer**: Response, action, side-effects
32
+ Use cyclic arrows (loop arcs) to show iterative reasoning. Separate memory types visually.
33
+
34
+ ## Memory Architecture Diagram (Mem0, MemGPT-style)
35
+ Specialized agent diagram focused on memory operations.
36
+ - Show memory **write path** and **read path** separately (different arrow colors)
37
+ - Memory tiers: Working Memory → Short-term → Long-term → External Store
38
+ - Label memory operations: `store()`, `retrieve()`, `forget()`, `consolidate()`
39
+ - Use stacked rects or layered cylinders for storage tiers
40
+
41
+ ## Sequence Diagram
42
+ Time-ordered message exchanges between participants.
43
+ - Participants as vertical **lifelines** (top labels + vertical dashed lines)
44
+ - Messages as horizontal arrows between lifelines, top-to-bottom time order
45
+ - Activation boxes (thin filled rects on lifeline) show active processing
46
+ - Group with `<rect>` loop/alt frames with label in top-left corner
47
+ - ViewBox height = 80 + (num_messages × 50)
48
+
49
+ ## Comparison / Feature Matrix
50
+ Side-by-side comparison of approaches, systems, or components.
51
+ - Column headers = systems, row headers = attributes
52
+ - Row height: 40px; column width: min 120px; header row height: 50px
53
+ - Checked cell: tinted background (e.g. `#dcfce7`) + `✓` checkmark; unsupported: `#f9fafb` fill
54
+ - Alternating row fills (`#f9fafb` / `#ffffff`) for readability
55
+ - Max readable columns: 5; beyond that, split into two diagrams
56
+
57
+ ## Timeline / Gantt
58
+ Horizontal time axis showing durations, phases, and milestones.
59
+ - X-axis = time (weeks/months/quarters); Y-axis = items/tasks/phases
60
+ - Bars: rounded rects, colored by category, labeled inside or beside
61
+ - Milestone markers: diamond or filled circle at specific x position with label above
62
+ - ViewBox: `0 0 960 400` typical; wider for many time periods: `0 0 1200 400`
63
+
64
+ ## Mind Map / Concept Map
65
+ Radial layout from central concept.
66
+ - Central node at `cx=480, cy=280`
67
+ - First-level branches: evenly distributed around center (360/N degrees)
68
+ - Second-level branches: branch off first-level at 30-45° offset
69
+ - Use curved `<path>` with cubic bezier for branches, not straight lines
70
+
71
+ ## Class Diagram (UML)
72
+ Static structure showing classes, attributes, methods, and relationships.
73
+ - **Class box**: 3-compartment rect (name / attributes / methods), min width 160px
74
+ - Top compartment: class name, bold, centered (abstract = *italic*)
75
+ - Middle: attributes with visibility (`+` public, `-` private, `#` protected)
76
+ - Bottom: method signatures, same visibility notation
77
+ - **Relationships**:
78
+ - Inheritance (extends): solid line + hollow triangle arrowhead, child → parent
79
+ - Implementation (interface): dashed line + hollow triangle, class → interface
80
+ - Association: solid line + open arrowhead, label with multiplicity (1, 0..*, 1..*)
81
+ - Aggregation: solid line + hollow diamond on container side
82
+ - Composition: solid line + filled diamond on container side
83
+ - Dependency: dashed line + open arrowhead
84
+ - **Interface**: `<<interface>>` stereotype above name, or circle/lollipop notation
85
+ - **Enum**: compartment rect with `<<enumeration>>` stereotype, values in bottom
86
+ - Layout: parent classes top, children below; interfaces to the left/right of implementors
87
+ - ViewBox: `0 0 960 600` standard; `0 0 960 800` for deep hierarchies
88
+
89
+ ## Use Case Diagram (UML)
90
+ System functionality from user perspective.
91
+ - **Actor**: stick figure (circle head + body line) placed outside system boundary
92
+ - Label below figure, 13-14px
93
+ - Primary actors on left, secondary/supporting on right
94
+ - **Use case**: ellipse with label centered inside, min 140×60px
95
+ - Keep names verb phrases: "Create Order", "Process Payment"
96
+ - **System boundary**: large rect with dashed border + system name in top-left
97
+ - **Relationships**:
98
+ - Include: dashed arrow `<<include>>` from base to included use case
99
+ - Extend: dashed arrow `<<extend>>` from extension to base use case
100
+ - Generalization: solid line + hollow triangle (specialized → general)
101
+ - Layout: system boundary centered, actors outside, use cases inside
102
+ - ViewBox: `0 0 960 600` standard
103
+
104
+ ## State Machine Diagram (UML)
105
+ Lifecycle states and transitions of an entity.
106
+ - **State**: rounded rect with state name, min 120×50px
107
+ - Internal activities: small text `entry/ action`, `exit/ action`, `do/ activity`
108
+ - **Initial state**: filled black circle (r=8), one outgoing arrow
109
+ - **Final state**: filled circle (r=8) inside hollow circle (r=12)
110
+ - **Choice**: small hollow diamond, guard labels on outgoing arrows `[condition]`
111
+ - **Transition**: arrow with optional label `event [guard] / action`
112
+ - Guard conditions in square brackets
113
+ - Actions after `/`
114
+ - **Composite/nested state**: larger rect containing sub-states, with name tab
115
+ - **Fork/join**: thick horizontal or vertical black bar (synchronization)
116
+ - Layout: initial state top-left, final state bottom-right, flow top-to-bottom
117
+ - ViewBox: `0 0 960 600` standard
118
+
119
+ ## ER Diagram (Entity-Relationship)
120
+ Database schema and data relationships.
121
+ - **Entity**: rect with entity name in header (bold), attributes below
122
+ - Primary key attribute: underlined
123
+ - Foreign key: italic or marked with (FK)
124
+ - Min width: 160px; attribute font-size: 12px
125
+ - **Relationship**: diamond shape on connecting line
126
+ - Label inside diamond: "has", "belongs to", "enrolls in"
127
+ - Cardinality labels near entity: `1`, `N`, `0..1`, `0..*`, `1..*`
128
+ - **Weak entity**: double-bordered rect with double diamond relationship
129
+ - **Associative entity**: diamond + rect hybrid (rect with diamond inside)
130
+ - Line style: solid for identifying relationships, dashed for non-identifying
131
+ - Layout: entities in 2-3 rows, relationships between related entities
132
+ - ViewBox: `0 0 960 600` standard; wider `0 0 1200 600` for many entities
133
+
134
+ ## Network Topology
135
+ Physical or logical network infrastructure.
136
+ - **Devices**: icon-like rects or rounded rects
137
+ - Router: circle with cross arrows
138
+ - Switch: rect with arrow grid
139
+ - Server: stacked rect (rack icon)
140
+ - Firewall: brick-pattern rect or shield shape
141
+ - Load Balancer: horizontal split rect with arrows
142
+ - Cloud: cloud path (overlapping arcs)
143
+ - **Connections**: lines between device centers
144
+ - Ethernet/wired: solid line, label bandwidth
145
+ - Wireless: dashed line with WiFi symbol
146
+ - VPN: dashed line with lock icon
147
+ - **Subnets/Zones**: dashed rect containers with zone label (DMZ, Internal, External)
148
+ - **Labels**: device hostname + IP below, 12-13px
149
+ - Layout: tiered top-to-bottom (Internet → Edge → Core → Access → Endpoints)
150
+ - ViewBox: `0 0 960 600` standard
151
+
152
+ ## UML Coverage Map
153
+
154
+ Full mapping of UML 14 diagram types to supported diagram types:
155
+
156
+ | UML Diagram | Supported As | Notes |
157
+ |-------------|-------------|-------|
158
+ | Class | Class Diagram | Full UML notation |
159
+ | Component | Architecture Diagram | Use colored fills per component type |
160
+ | Deployment | Architecture Diagram | Add node/instance labels |
161
+ | Package | Architecture Diagram | Use dashed grouping containers |
162
+ | Composite Structure | Architecture Diagram | Nested rects within components |
163
+ | Object | Class Diagram | Instance boxes with underlined name |
164
+ | Use Case | Use Case Diagram | Full actor/ellipse/relationship |
165
+ | Activity | Flowchart / Process Flow | Add fork/join bars |
166
+ | State Machine | State Machine Diagram | Full UML notation |
167
+ | Sequence | Sequence Diagram | Add alt/opt/loop frames |
168
+ | Communication | — | Approximate with Sequence (swap axes) |
169
+ | Timing | Timeline | Adapt time axis |
170
+ | Interaction Overview | Flowchart | Combine activity + sequence fragments |
171
+ | ER Diagram | ER Diagram | Chen/Crow's foot notation |
@@ -0,0 +1,115 @@
1
+ # SVG → PNG Conversion
2
+
3
+ ## Method Comparison
4
+
5
+ | Tool | Install | Render Quality | Notes |
6
+ |------|---------|----------------|-------|
7
+ | `rsvg-convert` | System (often preinstalled) | ⚠️ Fair | Drops some CSS styles and `<foreignObject>` elements — missing borders/text on complex SVGs |
8
+ | **`cairosvg` (recommended)** | `pip install cairosvg` | ✅ Good | Solid CSS support; clearly better than rsvg-convert |
9
+ | `puppeteer` (headless Chrome) | `npm install puppeteer` | ✅✅ Best | Real browser engine; 100% fidelity but heavy (Node + Chromium) |
10
+
11
+ ## Recommended: cairosvg (Python one-liner)
12
+
13
+ ```bash
14
+ # Single file (2x resolution for retina/docs)
15
+ python3 -c "import cairosvg; cairosvg.svg2png(url='input.svg', write_to='output.png', scale=2)"
16
+
17
+ # Batch convert all SVGs in a directory
18
+ python3 -c "
19
+ import cairosvg, os, glob
20
+ d = 'docs/00-core'
21
+ for svg in sorted(glob.glob(os.path.join(d, '*.svg'))):
22
+ png = svg.replace('.svg', '.png')
23
+ cairosvg.svg2png(url=svg, write_to=png, scale=2)
24
+ print(f'Done: {os.path.basename(svg)} -> {os.path.basename(png)}')
25
+ "
26
+ ```
27
+
28
+ > `scale=2` produces 2x resolution PNG, ideal for high-DPI screens and embedded docs.
29
+
30
+ ## Fallback: rsvg-convert (simple but may drop styles)
31
+
32
+ ```bash
33
+ # Single file
34
+ rsvg-convert -w 1920 file.svg -o file.png
35
+
36
+ # Batch (not recommended — complex SVGs may lose elements)
37
+ for f in docs/00-core/*.svg; do rsvg-convert -o "${f%.svg}.png" "$f"; done
38
+
39
+ # 2x resolution
40
+ for f in docs/00-core/*.svg; do rsvg-convert -z 2 -o "${f%.svg}.png" "$f"; done
41
+ ```
42
+
43
+ ## Highest Fidelity: puppeteer (headless Chrome)
44
+
45
+ ```bash
46
+ npm install puppeteer # auto-downloads Chromium
47
+ node svg2png.js [directory]
48
+ ```
49
+
50
+ <details>
51
+ <summary>svg2png.js — full puppeteer script</summary>
52
+
53
+ ```javascript
54
+ const puppeteer = require('puppeteer');
55
+ const fs = require('fs');
56
+ const path = require('path');
57
+
58
+ (async () => {
59
+ const dir = process.argv[2] || '.';
60
+ const svgFiles = fs.readdirSync(dir).filter(f => f.endsWith('.svg'));
61
+
62
+ const browser = await puppeteer.launch({
63
+ headless: 'new',
64
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
65
+ });
66
+
67
+ for (const file of svgFiles) {
68
+ const svgPath = path.resolve(dir, file);
69
+ const pngPath = svgPath.replace(/\.svg$/, '.png');
70
+ const svgContent = fs.readFileSync(svgPath, 'utf-8');
71
+
72
+ const wMatch = svgContent.match(/width="(\d+)/);
73
+ const hMatch = svgContent.match(/height="(\d+)/);
74
+ const vbMatch = svgContent.match(/viewBox="[^"]*\s(\d+)\s(\d+)"/);
75
+
76
+ let width = wMatch ? parseInt(wMatch[1]) : (vbMatch ? parseInt(vbMatch[1]) : 1200);
77
+ let height = hMatch ? parseInt(hMatch[1]) : (vbMatch ? parseInt(vbMatch[2]) : 800);
78
+
79
+ const scale = 2;
80
+ const page = await browser.newPage();
81
+ await page.setViewport({ width, height, deviceScaleFactor: scale });
82
+
83
+ const html = `<!DOCTYPE html>
84
+ <html><head><style>
85
+ body { margin: 0; padding: 0; background: transparent; }
86
+ img { display: block; }
87
+ </style></head>
88
+ <body>
89
+ <img src="data:image/svg+xml;base64,${Buffer.from(svgContent).toString('base64')}" width="${width}" height="${height}" />
90
+ </body></html>`;
91
+
92
+ await page.setContent(html, { waitUntil: 'networkidle0' });
93
+ await page.screenshot({ path: pngPath, type: 'png', omitBackground: true });
94
+ await page.close();
95
+
96
+ console.log(`Done: ${file} -> ${path.basename(pngPath)} (${width}x${height} @${scale}x)`);
97
+ }
98
+
99
+ await browser.close();
100
+ })();
101
+ ```
102
+
103
+ </details>
104
+
105
+ ## Gotchas (lessons learned)
106
+
107
+ - `rsvg-convert` renders SVGs containing `<foreignObject>`, CSS `filter`, or complex `<style>` blocks **incompletely** — missing borders / missing text are the typical symptoms
108
+ - `cairosvg` (built on Cairo) has much better CSS support than rsvg and is sufficient for most cases
109
+ - If the SVG was generated by a browser (D3.js, Mermaid, etc.), only headless Chrome (puppeteer) renders it 100% faithfully
110
+
111
+ ## Picking a Method
112
+
113
+ 1. **Default** → `cairosvg` (pip install once, one-line conversion, good fidelity)
114
+ 2. **No Python available** → `rsvg-convert` (acceptable for simple flat-color diagrams)
115
+ 3. **Browser-generated SVG or pixel-perfect required** → `puppeteer`