@greenrenge/skills 0.0.0-stage → 0.1.0

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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -2
  3. package/bin/cli.mjs +349 -0
  4. package/catalog.json +201 -0
  5. package/package.json +49 -4
  6. package/skills/deck-story/SKILL.md +258 -0
  7. package/skills/deck-story/check-svg-text.mjs +94 -0
  8. package/skills/deck-story/check.mjs +348 -0
  9. package/skills/diagram-router/LICENSE +21 -0
  10. package/skills/diagram-router/SKILL.md +193 -0
  11. package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
  12. package/skills/diagram-router/references/channels.md +213 -0
  13. package/skills/diagram-router/references/evals.md +85 -0
  14. package/skills/diagram-router/references/gathering.md +101 -0
  15. package/skills/diagram-router/references/prior-art.md +65 -0
  16. package/skills/diagram-router/references/routing.md +166 -0
  17. package/skills/diagram-router/skill-release.json +17 -0
  18. package/skills/frontend-design/SKILL.md +443 -0
  19. package/skills/frontend-design/references/rtl.md +72 -0
  20. package/skills/frontend-design/scripts/.upstream-sha +1 -0
  21. package/skills/frontend-design/scripts/LICENSE +21 -0
  22. package/skills/frontend-design/scripts/README.md +24 -0
  23. package/skills/frontend-design/scripts/gates.md +243 -0
  24. package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
  25. package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
  26. package/skills/open-code-review-rules/SKILL.md +59 -0
  27. package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
  28. package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
  29. package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
  30. package/skills/plain-english-mode/SKILL.md +41 -0
  31. package/skills/pr-diagram-portfolio/SKILL.md +75 -0
  32. package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
  33. package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
  34. package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
  35. package/skills/pr-lens/LICENSE-upstream +21 -0
  36. package/skills/pr-lens/SKILL.md +99 -0
  37. package/skills/pr-lens/VENDOR.md +47 -0
  38. package/skills/pr-lens/package-lock.json +91 -0
  39. package/skills/pr-lens/package.json +9 -0
  40. package/skills/pr-lens/references/config.md +90 -0
  41. package/skills/pr-lens/references/example.graph.json +580 -0
  42. package/skills/pr-lens/references/graph-document.md +233 -0
  43. package/skills/pr-lens/skill-release.json +16 -0
  44. package/skills/security-remediation-epic/SKILL.md +316 -0
  45. package/skills/security-remediation-epic/prompt-template.md +33 -0
  46. package/skills/skill-maintainer/SKILL.md +99 -0
  47. package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
  48. package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
  49. package/skills/t3-successor-handoff/SKILL.md +141 -0
  50. package/skills/t3-thread-bridge/SKILL.md +175 -0
  51. package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
  52. package/skills/t3-thread-bridge/references/ping-back.md +108 -0
  53. package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
  54. package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
  55. package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
  56. package/skills/ulw-plan/SKILL.md +98 -0
  57. package/skills/ulw-plan/references/full-workflow.md +255 -0
  58. package/skills/ulw-plan/references/intent-clear.md +44 -0
  59. package/skills/ulw-plan/references/intent-unclear.md +44 -0
  60. package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
  61. package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
@@ -0,0 +1,348 @@
1
+ #!/usr/bin/env node
2
+ // The deck-story QA pass, mechanical half: the budgets and the layout invariants
3
+ // that a slide either passes or fails, so a deck's defects are arithmetic rather
4
+ // than taste.
5
+ //
6
+ // node check.mjs <deck.html> [--svg-dir <dir>] [--strict]
7
+ //
8
+ // A deck is one self-contained HTML file. This reads the source; it never opens a
9
+ // browser and never fetches anything, so it runs in CI and in an editor's hook.
10
+ //
11
+ // The rules come from SKILL.md §2 and §5. Each one names the skill rule it
12
+ // enforces. A pass is not a good deck; a pass is a deck whose remaining defects
13
+ // are in the copy, not in the arithmetic.
14
+ //
15
+ // Exit 0 when every rule holds, 1 when one does not.
16
+
17
+ import { readFile, readdir } from 'node:fs/promises'
18
+ import { basename, dirname, join, resolve } from 'node:path'
19
+
20
+ const argv = process.argv.slice(2)
21
+ const positional = argv.filter((a) => !a.startsWith('--'))
22
+ const flag = (name) => argv.includes(`--${name}`)
23
+ const opt = (name, fallback) => {
24
+ const i = argv.indexOf(`--${name}`)
25
+ return i !== -1 && argv[i + 1] ? argv[i + 1] : fallback
26
+ }
27
+
28
+ if (!positional.length) {
29
+ console.error('usage: node check.mjs <deck.html> [--svg-dir <dir>] [--strict]')
30
+ process.exit(2)
31
+ }
32
+
33
+ const deckPath = resolve(positional[0])
34
+ const svgDir = opt('svg-dir', null)
35
+ const strict = flag('strict')
36
+
37
+ // ── the skill's numbers ──────────────────────────────────────────────────────
38
+ const WORD_BUDGET = 50 // §2 "Fifty words of prose at most"
39
+ const ELEMENT_BUDGET = 6 // §2 "Six elements at most on a slide"
40
+ const BODY_PT = 24 // §2 body type, on a 13.33 by 7.5 inch slide
41
+ const LABEL_PT = 18 // §2 "18 to 22 for supporting labels"
42
+ const SLIDE_W = 1280 // the canvas the deck is authored against
43
+ const SLIDE_H = 720
44
+ const PX_PER_IN = 96 // §2's slide is 13.33 by 7.5 inch, so 96px per inch
45
+ const PT_PER_PX = 72 / PX_PER_IN
46
+ const CONTRAST_BODY = 4.5 // §2 "4.5:1 for body text"
47
+ const CONTRAST_LARGE = 3 // §2 "3:1 for text at 24pt or larger"
48
+ const MONOTONY_RUN = 4 // §2 "a run of identical layouts is a list pretending to be a story"
49
+ const MONOTONY_MIN = 0.25 // §2's margin band, in inches
50
+
51
+ // ── colour maths ─────────────────────────────────────────────────────────────
52
+ const hexToRgb = (h) => {
53
+ const s = h.replace('#', '')
54
+ const full = s.length === 3 ? [...s].map((c) => c + c).join('') : s
55
+ return [0, 2, 4].map((i) => parseInt(full.slice(i, i + 2), 16) / 255)
56
+ }
57
+ const luminance = (rgb) => {
58
+ const [r, g, b] = rgb.map((v) =>
59
+ v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4,
60
+ )
61
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b
62
+ }
63
+ const contrast = (a, b) => {
64
+ const l1 = luminance(hexToRgb(a))
65
+ const l2 = luminance(hexToRgb(b))
66
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05)
67
+ }
68
+
69
+ // ── read the deck ────────────────────────────────────────────────────────────
70
+ const html = await readFile(deckPath, 'utf8')
71
+ const styleBlock = (html.match(/<style>([\s\S]*?)<\/style>/) || [, ''])[1]
72
+ const css = styleBlock
73
+
74
+ const deckStart = html.indexOf('<div id="deck">')
75
+ const deckEnd = html.indexOf('<div id="bar"')
76
+ const deckHtml = deckStart !== -1 ? html.slice(deckStart, deckEnd === -1 ? html.length : deckEnd) : html
77
+ const slides = [...deckHtml.matchAll(/<section class="slide[^"]*">([\s\S]*?)<\/section>/g)].map((m) => m[1])
78
+
79
+ const failures = []
80
+ const notes = []
81
+ const fail = (rule, msg) => failures.push(`${rule}: ${msg}`)
82
+ const note = (rule, msg) => notes.push(`${rule}: ${msg}`)
83
+
84
+ const strip = (s) =>
85
+ s
86
+ .replace(/<aside class="notes">[\s\S]*?<\/aside>/g, ' ') // notes are for the speaker, not the room
87
+ .replace(/<svg[\s\S]*?<\/svg>/g, ' ')
88
+ .replace(/<img[^>]+>/g, ' ')
89
+ .replace(/<pre[\s\S]*?<\/pre>/g, ' ')
90
+ .replace(/<!--[\s\S]*?-->/g, ' ')
91
+ .replace(/<[^>]+>/g, ' ')
92
+ .replace(/&[a-z]+;/gi, ' ')
93
+
94
+ console.log(`${basename(deckPath)} — ${slides.length} slides`)
95
+
96
+ // ── per slide ────────────────────────────────────────────────────────────────
97
+ slides.forEach((slide, i) => {
98
+ const n = i + 1
99
+ const prose = strip(slide)
100
+ const words = prose.split(/\s+/).filter(Boolean).length
101
+ if (words > WORD_BUDGET)
102
+ fail('budget/words', `slide ${n}: ${words} words, over the ${WORD_BUDGET}-word budget`)
103
+
104
+ // A card is one element on screen, not two; so is a numbered list.
105
+ const bare = slide
106
+ .replace(/<aside class="notes">[\s\S]*?<\/aside>/g, '')
107
+ .replace(/<svg[\s\S]*?<\/svg>/g, '')
108
+ .replace(/<img[^>]+>/g, '')
109
+ .replace(/<pre[\s\S]*?<\/pre>/g, 'PRE')
110
+ .replace(/<div class="card[^"]*">[\s\S]*?<\/div>/g, 'CARD')
111
+ const els = (bare.match(/<h1\b|<h2\b|CARD|PRE|<ol\b|p class="note"|class="quote"/g) || []).length
112
+ if (els > ELEMENT_BUDGET)
113
+ fail('budget/elements', `slide ${n}: ${els} elements, over the ${ELEMENT_BUDGET}-element budget`)
114
+
115
+ if (!prose.trim()) fail('content/empty-slide', `slide ${n}: no content at all`)
116
+
117
+ for (const m of slide.matchAll(/\[([^\]]{1,40})\]/g)) {
118
+ const v = m[1].trim()
119
+ if (
120
+ /^(name|date|tbd|tbc|todo|insert|add|your|enter|company|placeholder|figure)\b/i.test(v) ||
121
+ /^(TBD|TBC|TODO|FIXME|XXX)$/.test(v)
122
+ )
123
+ fail('content/placeholder-text', `slide ${n}: leftover placeholder "[${v}]"`)
124
+ }
125
+
126
+ const titles = [...slide.matchAll(/<h[12][^>]*>([\s\S]*?)<\/h[12]>/g)].map((m) =>
127
+ strip(m[1]).trim().toLowerCase(),
128
+ )
129
+ if (!titles.length) fail('content/no-title', `slide ${n}: a slide with no headline`)
130
+ })
131
+
132
+ // ── duplicate titles ─────────────────────────────────────────────────────────
133
+ const titleOf = (s) => {
134
+ const m = s.match(/<h[12][^>]*>([\s\S]*?)<\/h[12]>/)
135
+ return m ? strip(m[1]).trim().toLowerCase() : ''
136
+ }
137
+ const titles = slides.map(titleOf)
138
+ titles.forEach((t, i) => {
139
+ if (!t) return
140
+ const j = titles.indexOf(t)
141
+ if (j !== i) fail('content/duplicate-title', `slides ${j + 1} and ${i + 1} share the title "${t}"`)
142
+ })
143
+
144
+ // ── layout monotony ──────────────────────────────────────────────────────────
145
+ const signature = (s) => {
146
+ const kinds = []
147
+ if (/class="[^"]*\bfig\b/.test(s)) kinds.push('figure')
148
+ if (/class="[^"]*\bcards\b/.test(s)) kinds.push('cards')
149
+ if (/<table\b/.test(s)) kinds.push('table')
150
+ if (/<pre\b/.test(s)) kinds.push('code')
151
+ if (/<ol\b|<ul\b/.test(s)) kinds.push('list')
152
+ if (/class="[^"]*\bsteps\b/.test(s)) kinds.push('steps')
153
+ if (kinds.length) return kinds.sort().join('+')
154
+ return 'plain'
155
+ }
156
+ const sigs = slides.map(signature)
157
+ let run = 1
158
+ for (let i = 1; i <= sigs.length; i++) {
159
+ if (i < sigs.length && sigs[i] === sigs[i - 1]) {
160
+ run++
161
+ continue
162
+ }
163
+ if (run >= MONOTONY_RUN) {
164
+ // Whether a run of identical layouts is a list pretending to be a story depends
165
+ // on the story, so this is advisory by default and a failure under --strict.
166
+ const msg = `slides ${i - run + 1}-${i} (${run} in a row) use the same layout "${sigs[i - 1]}"`
167
+ if (strict) fail('layout/monotony', msg)
168
+ else note('layout/monotony', msg)
169
+ }
170
+ run = 1
171
+ }
172
+
173
+ // ── margins ──────────────────────────────────────────────────────────────────
174
+ const pad = css.match(/\.slide\s*\{[\s\S]*?padding:\s*([^;]+);/)
175
+ if (pad) {
176
+ const v = pad[1].trim().split(/\s+/)
177
+ const top = v[0]
178
+ const bottom = v.length === 1 ? v[0] : v.length === 2 ? v[0] : v[2]
179
+ const left = v.length === 1 ? v[0] : v.length === 2 ? v[1] : v.length === 3 ? v[1] : v[3]
180
+ if (top !== bottom) fail('layout/margins', `top margin ${top} != bottom margin ${bottom}`)
181
+ const hPct = (parseFloat(top) / SLIDE_H) * 100
182
+ const wPct = (parseFloat(left) / SLIDE_W) * 100
183
+ if (hPct < 5 || hPct > 9)
184
+ fail('layout/margins', `vertical margin ${hPct.toFixed(1)}% outside the 5-9% band`)
185
+ if (wPct < 4 || wPct > 7)
186
+ fail('layout/margins', `side margin ${wPct.toFixed(1)}% outside the 4-7% band`)
187
+ } else {
188
+ note('layout/margins', 'no .slide padding rule found; margins not checked')
189
+ }
190
+
191
+ // ── centring ─────────────────────────────────────────────────────────────────
192
+ // §2 "never centre a paragraph". A centred graphic is fine; a centred paragraph
193
+ // is not. So the rule is about the text, not the word "center".
194
+ const centredSelectors = [...css.matchAll(/([^{}]*)\{([^{}]*text-align:\s*center[^}]*)\}/g)].map(
195
+ (m) => ({ selector: m[1].trim(), body: m[2] }),
196
+ )
197
+ {
198
+ const centredClasses = new Set()
199
+ for (const { selector } of centredSelectors) {
200
+ for (const c of selector.matchAll(/\.([a-z0-9-]+)/g)) centredClasses.add(c[1])
201
+ }
202
+ slides.forEach((slide, i) => {
203
+ for (const m of slide.matchAll(/<(p|li|ul|ol)\b([^>]*)>([\s\S]*?)<\/\1>/g)) {
204
+ const attrs = m[2]
205
+ const cls = (attrs.match(/class="([^"]*)"/) || [, ''])[1]
206
+ const names = cls.split(/\s+/).filter(Boolean)
207
+ const centredByClass = names.some((c) => centredClasses.has(c))
208
+ const centredInline = /text-align:\s*center/.test(attrs)
209
+ if (!centredByClass && !centredInline) continue
210
+ const text = strip(m[3]).trim()
211
+ const words = text.split(/\s+/).filter(Boolean)
212
+ if (words.length > 2 || text.length > 120)
213
+ fail(
214
+ 'layout/centred-body',
215
+ `slide ${i + 1}: a centred ${m[1]} of ${words.length} words / ${text.length} characters`,
216
+ )
217
+ }
218
+ })
219
+ }
220
+
221
+ // ── contrast, measured from the CSS ──────────────────────────────────────────
222
+ const vars = {}
223
+ for (const m of css.matchAll(/(--[\w-]+):\s*([^;]+);/g)) vars[m[1]] = m[2].trim()
224
+ const paper = vars['--paper'] || '#ffffff'
225
+
226
+ // A rule's colour, and the font-size in force there.
227
+ const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({
228
+ selector: m[1].trim(),
229
+ body: m[2],
230
+ }))
231
+ // A rule's foreground is measured against the ground it actually sits on: its own
232
+ // opaque background, the nearest ancestor's, or the slide's paper.
233
+ const parseColour = (value) => {
234
+ const v = value.trim()
235
+ if (v.startsWith('#')) return { hex: v.length === 4 ? v : v.slice(0, 7), alpha: 1 }
236
+ const rgba = v.match(/rgba?\(([^)]+)\)/)
237
+ if (rgba) {
238
+ const [r, g, b, a = '1'] = rgba[1].split(',').map((x) => parseFloat(x))
239
+ return { hex: '#' + [r, g, b].map((x) => Math.round(x).toString(16).padStart(2, '0')).join(''), alpha: a }
240
+ }
241
+ return null
242
+ }
243
+ const composite = (fg, bgHex) => {
244
+ if (fg.alpha >= 1) return fg.hex
245
+ const [fr, fg2, fb] = hexToRgb(fg.hex).map((v) => v * 255)
246
+ const [br, bg2, bb] = hexToRgb(bgHex).map((v) => v * 255)
247
+ const mix = (f, b) => Math.round(f * fg.alpha + b * (1 - fg.alpha))
248
+ return '#' + [mix(fr, br), mix(fg2, bg2), mix(fb, bb)].map((x) => x.toString(16).padStart(2, '0')).join('')
249
+ }
250
+ const resolveColour = (value) => {
251
+ const v = value.trim()
252
+ if (v.startsWith('#')) return v.length === 4 ? v : v.slice(0, 7)
253
+ const m = v.match(/var\((--[\w-]+)\)/)
254
+ if (m) return resolveColour(vars[m[1]] || '')
255
+ return null
256
+ }
257
+ // Which selectors sit on the deck's chrome rather than on a slide? The chrome is
258
+ // furniture — a running footer and a slide counter — and its type scale is
259
+ // deliberately smaller than the content scale.
260
+ const chromeSelectors = new Set(
261
+ [...css.matchAll(/#(bar|count|brand|notes)\b|\.hint\b/g)].map((m) => m[0]),
262
+ )
263
+
264
+ // Every rule that paints an opaque ground, so a label on a dark panel is measured
265
+ // against that panel rather than against the slide's paper.
266
+ const grounds = rules
267
+ .map(({ selector, body }) => {
268
+ const bg = (body.match(/(?:^|;)\s*background:\s*([^;]+)/) || [, ''])[1]
269
+ const parsed = bg ? parseColour(resolveColour(bg) || bg) : null
270
+ return parsed ? { selector, ...parsed } : null
271
+ })
272
+ .filter(Boolean)
273
+
274
+ const groundFor = (selector) => {
275
+ let best = null
276
+ for (const g of grounds) {
277
+ if (!selector.includes(g.selector)) continue
278
+ if (!best || g.selector.length > best.selector.length) best = g
279
+ }
280
+ return best
281
+ }
282
+
283
+ for (const { selector, body } of rules) {
284
+ const raw = (body.match(/(?:^|;)\s*color:\s*([^;]+)/) || [, ''])[1]
285
+ const parsed = raw ? parseColour(resolveColour(raw) || raw) : null
286
+ if (!parsed) continue
287
+ const g = groundFor(selector)
288
+ const ground = g ? composite(g, paper) : paper
289
+ const colour = composite(parsed, ground)
290
+ const px = (body.match(/font-size:\s*([\d.]+)px/) || [, null])[1]
291
+ const sizePx = px ? parseFloat(px) : null
292
+ const pt = sizePx === null ? null : sizePx * PT_PER_PX
293
+ const bold = /font-weight:\s*(6|7|8|9)00/.test(body)
294
+ const isChrome = [...chromeSelectors].some((c) => selector.includes(c))
295
+ const large = pt !== null && (pt >= 18 || (bold && pt >= 14))
296
+ const floor = large ? CONTRAST_LARGE : CONTRAST_BODY
297
+ const ratio = contrast(colour, ground)
298
+ if (ratio < floor) {
299
+ const where = isChrome ? 'chrome' : 'content'
300
+ fail(
301
+ 'contrast',
302
+ `${where} ${selector.split(',')[0].trim()} uses ${colour} on ${ground}: ${ratio.toFixed(2)}:1, floor ${floor}:1`,
303
+ )
304
+ }
305
+ if (!isChrome && pt !== null && pt < LABEL_PT) {
306
+ note(
307
+ 'type/min-size',
308
+ `${selector.split(',')[0].trim()} sets ${sizePx}px (${pt.toFixed(1)}pt), under the ${LABEL_PT}pt supporting-label floor`,
309
+ )
310
+ }
311
+ }
312
+
313
+ // ── print path ───────────────────────────────────────────────────────────────
314
+ // §5 "Check the print path." A deck handed out on paper is a different artefact.
315
+ if (!/@media\s+print/.test(css)) fail('print/path', 'no @media print rule: the deck has no print path')
316
+
317
+ // ── speaker notes ────────────────────────────────────────────────────────────
318
+ // §4 "Write speaker notes with the exact transition sentence that bridges each
319
+ // slide to the next." The format has nowhere to put them unless it carries them.
320
+ const withNotes = slides.filter((s) => /<aside class="notes"|\bnotes="[^"]+"/.test(s)).length
321
+ if (withNotes < slides.length)
322
+ fail(
323
+ 'notes/missing',
324
+ `${slides.length - withNotes} of ${slides.length} slides carry no speaker notes`,
325
+ )
326
+
327
+ // ── SVG labels ───────────────────────────────────────────────────────────────
328
+ // §5 "Check the text does not overflow its box and the labels do not collide."
329
+ // SVG text is not clipped, so an overlong label paints over whatever is drawn
330
+ // next. That check needs a layout engine, so it lives in check-svg-text.mjs.
331
+ if (svgDir) {
332
+ const files = (await readdir(svgDir)).filter((f) => f.endsWith('.svg'))
333
+ if (!files.length) fail('svg/labels', `no SVG files in ${svgDir}`)
334
+ } else {
335
+ note('svg/labels', 'no --svg-dir given; the SVG label check was not run')
336
+ }
337
+
338
+ // ── report ───────────────────────────────────────────────────────────────────
339
+ if (notes.length) {
340
+ console.log(`\n${notes.length} note(s):`)
341
+ for (const n of notes) console.log(` - ${n}`)
342
+ }
343
+ if (failures.length) {
344
+ console.log(`\n${failures.length} failure(s):`)
345
+ for (const f of failures) console.log(` - ${f}`)
346
+ process.exit(1)
347
+ }
348
+ console.log('\nall rules hold')
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Greenrenge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,193 @@
1
+ ---
2
+ name: diagram-router
3
+ description: "Chooses the right picture for a request, then hands the drawing to the skill that owns that visual language. Routes between the archify, stack-diagram and diagram-design skills and decides the visual form, the fidelity, and the delivery channel (self-contained HTML, SVG, PNG, a PR comment, a terminal text block, or a committed repository asset), gathering the facts it needs from the codebase, the web or the conversation first. Use when something should become a picture and the right picture is not yet decided: 'diagram this', 'make this visual', 'picture this', 'diagram the PR', 'explain this simply', 'which picture fits'. Do NOT use when a specific diagram type or format is already named and one of archify, stack-diagram or diagram-design owns it, and not for dashboards, live-data charts, or plain-text answers."
4
+ license: MIT
5
+ metadata:
6
+ version: "1.0"
7
+ ---
8
+
9
+ # Diagram Router
10
+
11
+ You route; you do not draw. Your job is to decide **what picture** the request needs,
12
+ **which skill owns that visual language**, **how faithful** it must be, and **where
13
+ it lands** — then hand off to that skill and check the result.
14
+
15
+ Three diagram skills live on this host and they overlap. This skill exists because
16
+ choosing between them is a decision, not an accident.
17
+
18
+ | Skill | Owns | Output |
19
+ |---|---|---|
20
+ | `archify` | Software structure and behaviour: components, sequences, flows, lifecycles, schemas, one-page explainers. Interactive, explorable, motion. | standalone HTML (+ image/SVG/WebM export) |
21
+ | `stack-diagram` | Cloud and infra topology with real brand logos: zones, clusters, services, registries, storage. | HTML, PNG, React/TSX |
22
+ | `diagram-design` | Editorial and analytical pictures: quantitative charts, process and strategy maps, journeys, matrices, plus a before/after "architecture delta". Imports Mermaid/.drawio/.excalidraw. | self-contained HTML, PNG, SVG |
23
+ | `pr-lens` | Deterministic PR diagrams: a validated graph document rendered to mechanically identical SVGs with GitHub's delta semantics (added/changed/removed/unchanged) — blast radius and call structure, CI-grade consistency. | SVG (light + dark), PR comment |
24
+
25
+ ## 0. Gate — is a picture even right?
26
+
27
+ *Would the reader learn more from this than from a well-written paragraph?*
28
+
29
+ If no — answer in text and stop. A list of things is a list; a one-shape "diagram" is
30
+ a sentence. **Criterion: either a written answer exists, or you state that you are
31
+ drawing and why.**
32
+
33
+ ## 1. Route card — four slots, before any tool runs
34
+
35
+ Fill all four, in your head or in one line, before touching anything.
36
+
37
+ | Slot | Values |
38
+ |---|---|
39
+ | **SKILL** | `archify` · `stack-diagram` · `diagram-design` |
40
+ | **FORM** | the visual type the chosen skill owns (see `references/routing.md`) |
41
+ | **FIDELITY** | `faithful` (≤24 nodes) · `balanced` (≤12) · `simplified` (≤7) |
42
+ | **CHANNEL** | `inline-html` · `file` · `svg` · `png` · `pr-comment` · `repo-asset` · `terminal-text` · `mermaid-block` |
43
+
44
+ **Audience** rides along: `engineer` · `mixed` · `executive` — it changes wording and
45
+ density, never the count.
46
+
47
+ ### Precedence — first match wins
48
+
49
+ 1. **Brand logos, cloud vendors, "where does it run"** → `stack-diagram`.
50
+ 2. **Quantitative data** — values, series, comparisons, distributions, part-to-whole → `diagram-design` (its chart types). Never `archify`.
51
+ 3. **A PR's mechanics** — what it touched, added, removed, left alone, identical every run → `pr-lens`. **A structural change as a story** ("what did this PR change", "before → after") → `diagram-design` (architecture delta).
52
+ 4. **Software behaviour, call order, lifecycle, data model, a system as a whole** → `archify`.
53
+ 5. **Strategy, journey, narrative, process, editorial charts** → `diagram-design`.
54
+ 6. **"Explain this as a page"** — one scrollable page carrying the answer → `archify` (explainer mode).
55
+
56
+ **Tie-breaker:** `archify guide "<your scenario>" --json` is a *signal*, not the
57
+ authority. A `low` confidence or a `system-overview` fallback means the request is
58
+ outside archify's vocabulary — which is itself the answer: go to `diagram-design`.
59
+
60
+ **Criterion: the route card names a SKILL and a FORM, and you can state the
61
+ discriminator that decided it.** If you cannot name the discriminator, you have not
62
+ decided yet — go read `references/routing.md`.
63
+
64
+ ## 2. Gather — only if the facts are missing
65
+
66
+ A picture is only as good as its claims. If you already hold the facts (they are in
67
+ the conversation, in the file you just read), skip to step 3.
68
+
69
+ Otherwise fire **1–3 read-only children in a single response**, each with a
70
+ self-contained prompt:
71
+
72
+ ```
73
+ TASK: <one objective, measurable>
74
+ DELIVERABLE: <exact output format> — write to <absolute path>
75
+ SCOPE: <in scope> / OUT OF SCOPE: <explicitly not>
76
+ SOURCES: <which tools and which sources are authoritative>
77
+ EVIDENCE: <each fact must carry its source path or command output; "all checks pass" is not evidence>
78
+ UNKNOWNS: <mark every gap; do not infer>
79
+ VERIFY: <how you will confirm the deliverable>
80
+ FALLBACK: <if you have no tools, return what you can and say what is missing>
81
+ ```
82
+
83
+ Rules: fire them **in parallel, in one response** · never let a child edit product
84
+ code · never re-search a child's topic yourself · children return claims, you
85
+ verify before drawing · every fact in the merged brief carries a source · every
86
+ unknown is marked, not filled in.
87
+
88
+ **Inline fallback:** if spawning is unavailable or the task is one file, gather
89
+ sequentially yourself with the same evidence standard.
90
+
91
+ **Criterion: one brief exists; every fact in it has a source; every unknown is
92
+ marked.**
93
+
94
+ **When you skipped the gather step, the conversation *is* the brief.** Write the
95
+ route card, state which facts you are relying on, and proceed — a brief *file* is
96
+ only required when you actually gathered.
97
+
98
+ ## 3. Draw — hand off, one owner
99
+
100
+ Load the chosen skill with the `skill` tool — `~/.agents/skills/<name>/` is the
101
+ sibling's base directory — and follow **its** instructions; the brief is the input.
102
+ One agent owns the artefact. If several artefacts are produced, one owner holds the
103
+ shared style.
104
+
105
+ Never mix two skills' visual languages in one picture. Reference a sibling's
106
+ files by its absolute path (`~/.agents/skills/<name>/references/<file>.md`), never by a
107
+ path relative to this skill — every sibling has its own `references/`.
108
+
109
+ **Fidelity is a target, not a ceiling.** If the story genuinely needs more nodes
110
+ than the channel's budget allows, do not silently drop claims: either raise the
111
+ fidelity, or split into two pictures (overview + detail) and post both. A PR
112
+ comment can carry two images; a wrong picture cannot be fixed later.
113
+
114
+ **Criterion: the artefact exists and its style constants match the brief.**
115
+
116
+ ## 4. Verify — render it and look at it
117
+
118
+ Use the owning skill's own gate, then **actually look at the rendered result**:
119
+
120
+ - `archify` → `finalize` (validate, deliver, check, browser-check all pass).
121
+ - `diagram-design` → `python3 scripts/self_check.py <file>` (exit 0).
122
+ - `stack-diagram` → `build.py` clean, then render the PNG.
123
+
124
+ **PNG rendering fallback (check host profile rule if present, e.g. `~/.agents/rules/host-*.md`):**
125
+ When the system `python3` lacks the `playwright` module and `render_png.py` /
126
+ `export_png.py` fail on import, use either fallback:
127
+
128
+ ```bash
129
+ magick in.svg out.png
130
+ chromium --headless --no-sandbox --disable-gpu --hide-scrollbars \
131
+ --window-size=W,H --screenshot=out.png "file://$PWD/page.html"
132
+ ```
133
+ (On hosts with a wrapper binary like `~/.local/bin/chromium`, invoke that wrapper.)
134
+
135
+ Say which path you used. If you did not look at the rendered image, say
136
+ **"automated checks passed; not visually reviewed"** — never imply you saw it.
137
+
138
+ **Criterion: the render was inspected, and your reply says which path you used.**
139
+
140
+ ## 5. Deliver — the channel decides the mechanics
141
+
142
+ Full matrix with exact commands: `references/channels.md`. The short version:
143
+
144
+ | CHANNEL | What lands |
145
+ |---|---|
146
+ | `inline-html` | When harness exposes `html_preview`/`html_render`: preview then render (≤512,000 chars; no outer card/padding); otherwise write standalone `.html` and return its path |
147
+ | `file` / `svg` / `png` | write the file, `browser.preview({path})`, reply with the absolute path |
148
+ | `pr-comment` | upload the PNG as a user-attachment, or commit it and link the root-relative `![](/OWNER/REPO/blob/<ref>/<path>?raw=true)` (SHA-pinned), then post with `gh pr comment <n> --body-file <file>` — **never inline `<svg>`**, never a fenced ` ```svg ` block, never `../blob/...` |
149
+ | `repo-asset` | `docs/diagrams/`, SVG canonical with a "do not edit" header, PNG for embedding, relative link from the README |
150
+ | `terminal-text` | fenced code block, box-drawing or ASCII, ≤100 cols, no emoji |
151
+ | `mermaid-block` | a fenced ```mermaid block — GitHub renders it natively, no asset |
152
+
153
+ **Fidelity ledger — always, for every diagram.** The reader of the diagram cannot
154
+ see what is missing; the person who asked for it must. One short list: what you
155
+ merged, collapsed, or dropped, and why. Also: **do not produce extra exports
156
+ unprompted.**
157
+
158
+ ## Boundaries
159
+
160
+ - You do not draw. If the chosen skill cannot express the request, say so and offer
161
+ the nearest thing it *can* express.
162
+ - You do not post to GitHub without the user's go-ahead; prepare the markdown and
163
+ the file, then let them press the button.
164
+ - You do not silently substitute a different skill. If the sibling you wanted is
165
+ unavailable, say so.
166
+ - You do not invent facts to fill a layout. A picture with fewer claims is better
167
+ than a picture with invented ones.
168
+ - You do not use this skill for dashboards, live-data charts, or plain-text answers.
169
+
170
+ ## Common failure modes
171
+
172
+ | Symptom | Cause | Fix |
173
+ |---|---|---|
174
+ | Router and sibling both fire | sibling description lacks a handoff clause | the siblings carry a clause pointing here; if you are editing them, keep it |
175
+ | Diagram says nothing specific | facts were never gathered | step 2 was skipped; gather before drawing |
176
+ | PR comment shows code, not a picture | fenced ```` ```svg ```` was used | commit a PNG and link it with `?raw=true` |
177
+ | Everything is one dense canvas | fidelity was not set | pick `simplified` or `balanced`; split into overview + detail |
178
+ | The picture is right but unreadable in the thread | channel was `inline-html` for a 1600px canvas | export a PNG for the reply, keep the HTML as source |
179
+ | A still lifted out of a styled page renders as black shapes, stripe fields | the source page's CSS (the rules its classes read) did not travel with the extracted SVG — variables alone are not styling | carry the rules, re-scoped to the still, and check every class is consumed: `pr-diagram-portfolio`'s still-lift rule and `scripts/restore_still_css.py`; then verify against the owning skill's own render — a painted-pixel probe passes a black canvas |
180
+
181
+ ## References
182
+
183
+ - `references/routing.md` — the full skill → form routing matrix, sibling capabilities, and tie-breakers.
184
+ - `references/channels.md` — output channels with exact commands, GitHub rendering rules, host render fallbacks.
185
+ - `references/gathering.md` — the delegation contract, brief template, and evidence standards.
186
+ - `references/evals.md` — the trigger evaluation set (20 queries) and how to score a change to this skill.
187
+ - `references/prior-art.md` — PR Lens and the superseded `render-pr-diagram`: what other PR-diagram skills do, what we adopted, what we declined, and the evidence that a fenced ` ```svg ` block renders as code on GitHub.
188
+
189
+ *Design provenance (for maintainers, not for the drawing agent): `DESIGN-NOTE.md`
190
+ in this directory is the cited research this skill was built from — the Agent
191
+ Skills spec constraints, a survey of existing diagram-router skills, published
192
+ chart-selection taxonomies, the GitHub and terminal output-channel mechanics, and
193
+ the recommendation that produced the sibling handoff clauses.*
@@ -0,0 +1,15 @@
1
+ # Third-party notices
2
+
3
+ `diagram-router` is MIT-licensed (see `LICENSE`) and **vendors no third-party
4
+ text**. It references three sibling skills that live on this host and are
5
+ licensed separately:
6
+
7
+ | Skill | License | Where |
8
+ |---|---|---|
9
+ | `archify` | Apache-2.0 | `~/.agents/skills/archify/` (see its `NOTICE` and `THIRD_PARTY_NOTICES.md`) |
10
+ | `stack-diagram` | MIT (c) 2026 caru-ini | `~/.agents/skills/stack-diagram/LICENSE` |
11
+ | `diagram-design` | MIT (c) 2025 Cathryn Lavery | `~/.agents/skills/diagram-design/LICENSE` |
12
+
13
+ Its routing tables were written from this host's own skills and from public
14
+ documentation; see the research note referenced in `skill-release.json` for the
15
+ source list. No upstream skill text is reproduced here.