@greenrenge/skills 0.0.0-stage → 0.2.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/bin/cli.mjs +525 -0
  4. package/bin/lib/onboard.mjs +1168 -0
  5. package/bin/lib/probe.mjs +631 -0
  6. package/catalog.json +590 -0
  7. package/package.json +50 -4
  8. package/skills/deck-story/SKILL.md +258 -0
  9. package/skills/deck-story/check-svg-text.mjs +94 -0
  10. package/skills/deck-story/check.mjs +348 -0
  11. package/skills/diagram-router/LICENSE +21 -0
  12. package/skills/diagram-router/SKILL.md +193 -0
  13. package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
  14. package/skills/diagram-router/references/channels.md +213 -0
  15. package/skills/diagram-router/references/evals.md +85 -0
  16. package/skills/diagram-router/references/gathering.md +101 -0
  17. package/skills/diagram-router/references/prior-art.md +65 -0
  18. package/skills/diagram-router/references/routing.md +166 -0
  19. package/skills/diagram-router/skill-release.json +17 -0
  20. package/skills/frontend-design/SKILL.md +443 -0
  21. package/skills/frontend-design/references/rtl.md +72 -0
  22. package/skills/frontend-design/scripts/.upstream-sha +1 -0
  23. package/skills/frontend-design/scripts/LICENSE +21 -0
  24. package/skills/frontend-design/scripts/README.md +24 -0
  25. package/skills/frontend-design/scripts/gates.md +243 -0
  26. package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
  27. package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
  28. package/skills/open-code-review-rules/SKILL.md +59 -0
  29. package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
  30. package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
  31. package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
  32. package/skills/plain-english-mode/SKILL.md +41 -0
  33. package/skills/pr-diagram-portfolio/SKILL.md +75 -0
  34. package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
  35. package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
  36. package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
  37. package/skills/pr-lens/LICENSE-upstream +21 -0
  38. package/skills/pr-lens/SKILL.md +99 -0
  39. package/skills/pr-lens/VENDOR.md +47 -0
  40. package/skills/pr-lens/package-lock.json +91 -0
  41. package/skills/pr-lens/package.json +9 -0
  42. package/skills/pr-lens/references/config.md +90 -0
  43. package/skills/pr-lens/references/example.graph.json +580 -0
  44. package/skills/pr-lens/references/graph-document.md +233 -0
  45. package/skills/pr-lens/skill-release.json +16 -0
  46. package/skills/security-remediation-epic/SKILL.md +316 -0
  47. package/skills/security-remediation-epic/prompt-template.md +33 -0
  48. package/skills/skill-maintainer/SKILL.md +99 -0
  49. package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
  50. package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
  51. package/skills/t3-successor-handoff/SKILL.md +141 -0
  52. package/skills/t3-thread-bridge/SKILL.md +175 -0
  53. package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
  54. package/skills/t3-thread-bridge/references/ping-back.md +108 -0
  55. package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
  56. package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
  57. package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
  58. package/skills/ticket-scheme/SKILL.md +144 -0
  59. package/skills/ulw-plan/SKILL.md +98 -0
  60. package/skills/ulw-plan/references/full-workflow.md +255 -0
  61. package/skills/ulw-plan/references/intent-clear.md +44 -0
  62. package/skills/ulw-plan/references/intent-unclear.md +44 -0
  63. package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
  64. package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: plain-english-mode
3
+ description: Talk with the user in plain English — terms defined at first use, a small glossary before term-heavy topics, concrete examples over jargon. Use when the user says "plain english", "talk plainly", "assume I'm new", "explain like I'm new", "I can't understand you", or names plain-english-mode.
4
+ ---
5
+
6
+ # Plain-English mode
7
+
8
+ The user wants ideas in everyday words, not the project's working vocabulary.
9
+ Loaded once — by request, by name, or by a confusion signal (below) — the mode
10
+ holds for the rest of the conversation. It shapes replies to the user; code,
11
+ commits, and file contents keep their own conventions.
12
+
13
+ ## The rules
14
+
15
+ **Define a term the moment it first appears.** One short sentence in everyday
16
+ words — "the API, the set of buttons other programs can press" — then the term
17
+ is established and free to use. A new term rides only on words the user
18
+ already has: a term stacked on another undefined term gets rewritten until it
19
+ isn't.
20
+
21
+ **Glossary first when terms arrive in a bunch.** A topic introducing more than
22
+ three new terms opens with a small glossary — `term — plain definition`, one
23
+ line each — before the substance. Three or fewer: define inline as they
24
+ appear.
25
+
26
+ **Show, don't name.** A concrete, user-visible example ("when you click Save,
27
+ the file goes to…") beats architecture vocabulary. Expand every acronym on
28
+ first use, or pick a plain word instead.
29
+
30
+ **Short sentences, no filler.** One idea each; no throat-clearing, no
31
+ restating the question back.
32
+
33
+ **Ask decisions in plain words.** The question restated simply, options in
34
+ plain labels (a code name or ticket id alone is not a label), and one
35
+ recommended answer with its reason.
36
+
37
+ ## Staying in the mode
38
+
39
+ "I can't understand", "too much jargon", "assume I am new" — any of these
40
+ turns the mode on, unasked, and it stays on for the rest of the conversation.
41
+ The user never has to ask twice.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: pr-diagram-portfolio
3
+ description: Explain a pull request or code change as a portfolio of diagrams, one per reader question, delivered as one self-contained HTML page. Use when asked to explain, review or walk through a PR, branch or diff visually ("diagram this PR", "many diagrams", "explain this change as a page", "which diagrams does this PR need"), when building such a portfolio page, or when SVGs lifted out of a styled page (archify, diagram-design) render as black shapes or stripe fields — the still-lift rule, the CSS-restore script and the verify-against-owner gate live here.
4
+ ---
5
+
6
+ # PR Diagram Portfolio
7
+
8
+ One change, several diagrams: each answers **one reader question**, carries **one
9
+ load-bearing fact**, has **one owning skill** (routed by `diagram-router`), and the set is
10
+ delivered as one self-contained HTML page, verified against the owning skill's own render.
11
+
12
+ Built and debugged on kpc PR #562 (95 files): 7 diagrams, 5 angles refused by the stop
13
+ rule, and a styling defect the first build shipped because its QA probe could not see it.
14
+ That history is the reason steps 6–8 exist.
15
+
16
+ ## Workflow
17
+
18
+ 1. **Classify** the change from its diff fingerprint — new packages vs edits, adds:dels,
19
+ config/code/tests/docs share, tickets closed (the signals table is in
20
+ `references/angle-framework.md`). *Done when one archetype is named.*
21
+ 2. **Select the angle set** from the archetype defaults. Baseline: one delta diagram
22
+ (pr-lens) for every code change. Each further angle passes the entry rule — the change
23
+ **alters the answer** to its question, and you can name the one load-bearing fact the
24
+ diagram must carry. Refuse angles out loud, each with its reason; hard cap 8.
25
+ 3. **Route** each angle through `diagram-router`; one owning skill per artefact; never mix
26
+ visual languages inside one picture.
27
+ 4. **Gather facts with sources.** Every fact carries a file path or command output. A
28
+ brief written earlier is re-verified against the repo at the change's head — corrections
29
+ go into that diagram's fidelity ledger, not silently into the drawing.
30
+ 5. **Draw** under each owning skill's own gate (archify `finalize`, diagram-design
31
+ `self_check`, pr-lens `validate` + render).
32
+ 6. **Build the portfolio** to the contract in `references/portfolio-delivery.md`: inline
33
+ SVG stills, per-diagram ID namespaces, a header per diagram (number, angle, reader
34
+ question, load-bearing fact, fidelity ledger) **and a glossary of every
35
+ bounded-context term the diagram uses**, written for a reader from outside the project.
36
+ Producer metadata — owning skill, form, fidelity counts, gate status — lives in the
37
+ manifest, never on the page. Self-contained, ≤ 512,000 characters.
38
+ 7. **Verify against the owner's render** — the gate, in this order:
39
+ - *Coverage*: every class a still uses is consumed by a rule in the carried CSS —
40
+ `scripts/restore_still_css.py` names uncovered classes and exits 1 (a class the
41
+ source pages never style on purpose — a semantic marker — earns `--no-strict`).
42
+ - *Pixels*: the rendered still matches the owning artefact — light-pixel fraction of
43
+ the same crop, before vs after, and a vision read on the diff. A painted-pixel probe
44
+ ("did anything get drawn") does **not** count: a canvas full of black triangles is
45
+ painted.
46
+ 8. **Deliver inline**: when the harness exposes `html_preview` → `html_render`, render inline (otherwise write the standalone `.html` file and return its path). Never shuttle a large page through
47
+ context — serve the folder on loopback and fetch it where the render tools live
48
+ (`references/portfolio-delivery.md`). For an image to post elsewhere: a `.png` file and
49
+ its path, never `html_render`.
50
+
51
+ ## The still-lift rule
52
+
53
+ An SVG lifted out of a styled page keeps its elements and loses the page's CSS. The
54
+ symptom is quiet and total: palette **variables** travel (they sit in a scoped block) but
55
+ the **rules that read them** (`.c-grid { stroke: var(--grid); fill: none }`) do not, so
56
+ every classed element falls back to SVG's default `fill: black` — a stripe field of solid
57
+ black pattern tiles, black slabs where panels belong, default text metrics.
58
+
59
+ So: **the CSS travels with the still, all of it** — the union of every source page's CSS
60
+ (each diagram type carries its own rules; the class diagram's `svg[data-class-ui]` rules
61
+ live only in the class diagram's page), every class of every multi-class attribute
62
+ (`class="c-frontend cl-type"` is two classes, and a "first class only" extraction silently
63
+ drops the second), re-scoped to the still. `scripts/restore_still_css.py` does this and
64
+ refuses uncovered classes. Keep the broken stills beside the fixed ones, and record the
65
+ correction in the page footer and the manifest — a reader who saw the broken build
66
+ deserves the diff.
67
+
68
+ ## References
69
+
70
+ - `references/angle-framework.md` — the angle taxonomy, archetype detection and defaults,
71
+ the C4 and use-case rulings, overlap resolutions, the worked #562 example, sources.
72
+ - `references/portfolio-delivery.md` — the page contract, the verify gate with real
73
+ measurements, and the inline-render mechanics for pages too big to shuttle.
74
+ - `scripts/restore_still_css.py` — extract, re-scope and check the CSS that lifted stills
75
+ need; `--help` for the full contract.
@@ -0,0 +1,124 @@
1
+ # The angle framework
2
+
3
+ The reasoning layer above `diagram-router`: which diagrams a change needs, and when to
4
+ stop adding them. Grounded in the primary sources listed at the end; every contested
5
+ ruling has a citable anchor.
6
+
7
+ ## The angles — each is ONE reader question
8
+
9
+ | # | Angle | The reader's question |
10
+ |---|---|---|
11
+ | A1 | Delta / blast radius | What exactly was touched, added, removed — and what was left alone? |
12
+ | A2 | Structure (logical) | What parts exist now, and what are their boundaries and dependencies? |
13
+ | A2′ | Structure (infra) | Where does it all run, and what talks to what across deployables? |
14
+ | A3 | Interaction — order | In what order do the parties interact at runtime? |
15
+ | A4 | Interaction — ownership | Which party owns which step and which decision? |
16
+ | A5 | State / lifecycle | What states does the changed thing pass through; which transitions are new or forbidden? |
17
+ | A6 | Data shape | What is the schema/contract of what crosses the new boundary? |
18
+ | A7 | Data movement | Where does data originate, flow, transform, and leave? |
19
+ | A8 | Purpose / audience | Who is this for, and what can they now do? |
20
+ | A9 | Rationale | Why this design and not the alternative? |
21
+
22
+ **Zoom vs axis.** C4 levels are zoom on A2, not separate angles. Sequence, swimlane and
23
+ workflow are three projections of one interaction axis — draw at most one per flow.
24
+
25
+ ## The three rules
26
+
27
+ - **Entry rule.** An angle enters the set iff (1) this change **changes the answer** to
28
+ its question — not merely "is relevant to it" — and (2) you can name the **one
29
+ load-bearing fact** the diagram must carry: a sentence a reviewer would act on. No
30
+ fact nameable → drop the angle.
31
+ - **Baseline.** Exactly one mandatory diagram for any code-touching change: the delta
32
+ (pr-lens — deterministic, near-free, anchors scope). Everything above the baseline is
33
+ conditional on the archetype.
34
+ - **Stop rule.** Stop when every remaining candidate fails the entry rule or the
35
+ decoration test — *if this diagram were wrong, would the reviewer catch a real defect?*
36
+ If the fact fits one sentence the reviewer will read anyway, don't draw it. Hard cap 8;
37
+ beyond it, each extra diagram must name a distinct ticket.
38
+
39
+ ## Archetype detection and defaults
40
+
41
+ Signals (all from `git diff --stat`, file paths, PR metadata): new-package signal (≥1 new
42
+ dir under a src root, or ≥5 files in new dirs) · net-shape (adds:dels ratio, rename/move
43
+ %) · file-type share (yaml/tf/helm/Dockerfile vs code vs md) · tests added vs untouched ·
44
+ ticket verbs · old+new coexisting paths (migration).
45
+
46
+ | Archetype | Fingerprint | Default angle set |
47
+ |---|---|---|
48
+ | Feature — new subsystem | ≥1 new package, adds ≫ dels (>5:1), several tickets | A1 + A2 + A3 + A4 if ≥3 parties + A6 if new contracts + A8 if new actors (usually text) |
49
+ | Feature — in existing path | few new files + edits, adds > dels, tests added | A1 + one of A3 + A5 if lifecycle changed |
50
+ | Refactor | dels ≈ adds, moves detected, tests ~flat | A1 + diagram-design architecture-delta (before/after **is** the story) |
51
+ | Bugfix | ≤10 files, test added, "fix" | A1 alone; + one sequence iff the fix is an ordering/handshake fix |
52
+ | Infra / config | yaml/tf/helm dominate | A1 + stack-diagram; + deployment if rollout order matters |
53
+ | Docs | .md dominates | none (archify tree only for doc-set navigation) |
54
+ | Perf | hot-path edits + benchmarks | A1 + a quantitative chart (router precedence); sequence/dataflow only if the mechanism needs it |
55
+ | API / contract change | exported types/schemas changed + consumer edits | A1 + A6 + A3 + arch-delta if old and new coexist |
56
+ | Migration / rollout | old+new coexist, flags, dual-write | A1 + A5 + arch-delta |
57
+
58
+ ## Rulings
59
+
60
+ **C4 mapping.** L1 context: draw only if the boundary changed (archify architecture, or
61
+ stack-diagram when the neighbours are cloud services). L2 container: only if a deployable
62
+ was added or rewired. L3 component: the default for large feature/refactor changes
63
+ (archify architecture, nested scopes). L4 code: default **no** — the diff reads better —
64
+ except when the type graph **is** the contribution (a contracts package, a polymorphism
65
+ rework): archify class / diagram-design UML class. Where C4 does not map: delta
66
+ (pr-lens), data movement (archify dataflow), goals (A8), rationale (A9); no skill draws
67
+ C4 *notation* — levels map onto owned forms only.
68
+
69
+ **Use cases.** No skill owns UML use-case notation, and the published position is that
70
+ the ellipse diagram adds little (Fowler: "the diagram is of rather limited value"; Petre
71
+ finds practitioners never use it). The honest default is a text actor/goal list; draw a
72
+ journey or story map only when ≥3 actors share overlapping capabilities and the matrix
73
+ structure itself is the fact. If the underlying question is "which callers are affected",
74
+ that is A1 → pr-lens, not a use-case picture.
75
+
76
+ **Overlap resolutions.**
77
+ 1. pr-lens vs architecture-delta vs archify architecture — three different questions:
78
+ what was touched vs left alone (pr-lens, always wins A1); how the shape changes,
79
+ before→after, as the story under review (diagram-design delta — refactors, removals,
80
+ re-routings); what the new structure is (archify architecture — only when structure is
81
+ substantially new, i.e. before ≈ empty). Never all three; at most two, each naming a
82
+ different fact.
83
+ 2. archify sequence vs diagram-design sequence — call order between software parties →
84
+ archify; diagram-design only when the time axis carries quantities (latencies).
85
+ 3. Sequence vs swimlane vs workflow — one form per flow: order between parties →
86
+ sequence; one flow with decision branches/guards → workflow; ownership of steps or
87
+ decisions across ≥3 parties → swimlane (diagram-design).
88
+
89
+ **Zoom budget.** At most two A2 drawings per change, adjacent levels only.
90
+
91
+ ## Worked example — kpc PR #562 (feature, new subsystem ×3)
92
+
93
+ 95 files, +4598/−533, three new subsystems (a fitting contracts package, a pipeline-config
94
+ system, an image-Regions path), 8 tickets. Seven diagrams:
95
+
96
+ | # | Angle | Skill · form | The load-bearing fact (abridged) |
97
+ |---|---|---|---|
98
+ | 1 | A1 | pr-lens blast radius | apps/* untouched; the Regions path reachable only through new config routing |
99
+ | 2 | A2 (L3) | archify architecture | `core/fitting` is contracts-only; the request path never imports pydantic (importlinter) |
100
+ | 3 | A3 | archify workflow | a refused member aborts before any MLflow run exists |
101
+ | 4 | A3 | archify sequence | with `whole_gated`, the whole-photo L2 distance alone gates recognition |
102
+ | 5 | A4 | diagram-design swimlane | the use-case Fitting never touches the tracker — the step logs on its behalf |
103
+ | 6 | A6 | archify class | serving imports only the pydantic-free `InferencePipeline` contract |
104
+ | 7 | A7 | archify dataflow | both run kinds emit one prediction-row schema, so evaluation is path-agnostic |
105
+
106
+ Refused by the stop rule, each with its reason: **A5** (states already carried by the
107
+ workflow's guard branches) · **A8** (≤3 internal actors, a text paragraph carries it) ·
108
+ **A9** (ADR links) · **stack-diagram** (no new deployable) · **architecture-delta**
109
+ (before ≈ empty for new subsystems).
110
+
111
+ ## Sources
112
+
113
+ - C4: c4model.com/diagrams and /diagrams/faq (levels, change rates, "code: not
114
+ recommended"); docs.structurizr.com/as-code (diagrams in PRs).
115
+ - UML & 4+1: OMG UML 2.5.1 Annex A (omg.org/spec/UML/2.5.1); Kruchten, *4+1 View
116
+ Model*, IEEE Software 12(6) 1995 — views may be pruned per need.
117
+ - arc42: docs.arc42.org §6 ("document only a few runtime scenarios"; swimlanes per
118
+ actor), §3, §7.
119
+ - Sequence vs swimlane: agilemodeling.com/style/sequenceDiagram.htm and
120
+ /style/activityDiagram.htm.
121
+ - Use cases: Fowler, *UML Distilled* ch. 9; Petre, *UML in Practice* (oro.open.ac.uk);
122
+ Jacobson et al., *Use-Case 2.0*, CACM 59(5) 2016.
123
+ - PR-diagram tooling convergence (changed-vs-impacted topology + interaction + compact
124
+ flow + rationale-as-text): CodeSee docs (review-map legend), PR-Agent/Qodo `/describe`.
@@ -0,0 +1,79 @@
1
+ # Portfolio delivery and verification
2
+
3
+ The build contract, the verify gate, and the mechanics of showing a large page inline.
4
+ Everything here was measured on a real build (kpc PR #562); the numbers are examples of
5
+ the *checks*, not constants to reproduce.
6
+
7
+ ## The page contract
8
+
9
+ - One self-contained HTML file, no external assets: every diagram an inline SVG still;
10
+ fonts and the restored CSS inlined in `<head>`.
11
+ - **≤ 512,000 characters** — the inline render's hard limit. Budget: stills ≈ 60% of it,
12
+ restored CSS ≈ 12% (one shared block: the union of every source page's rules, deduped —
13
+ per-diagram blocks duplicate the same runtime CSS fivefold), fonts ≈ 20%, page chrome
14
+ the rest.
15
+ - Per-diagram ID namespaces (`#arrowhead` → `#d2-arrowhead`): five lifted SVGs in one
16
+ document collide on ids otherwise. Keep `data-portfolio="<key>"` on each `<svg>` — the
17
+ restored CSS scopes to it, and the palette variables each still carries stay per-diagram.
18
+ - A header per diagram: number, angle, the reader question, the one-sentence load-bearing
19
+ fact, and the **fidelity ledger** (what was merged, collapsed or dropped, and why). The
20
+ ledger is not decoration: a reader who cannot see what is missing cannot trust the
21
+ picture.
22
+ - **No producer metadata on the page.** Owning skill, form, fidelity counts, gate status —
23
+ these answer the maker's questions and live in `manifest.md`. On the page they cost the
24
+ reader's eye without telling them anything about the change. The page speaks to the
25
+ reader; the manifest speaks to the pipeline.
26
+ - **A glossary beside every diagram**, written for a reader who is not a project member:
27
+ each bounded-context term the picture or its fact uses gets a one-line plain-language
28
+ definition. Source the wording from the project's own glossary (the `CONTEXT.md` /
29
+ `CONTEXT-MAP.md` pattern) or the change's ADR — do not invent parallel definitions —
30
+ and mark the terms the change itself introduces or amends. Assumed-pipeline terms the
31
+ diagram leans on (ONNX, MLflow) still earn one line each.
32
+ - Footer: verification per diagram, the render paths used, and — if a correction was
33
+ ever needed — what was wrong and how it was caught. Keep the corrected build's
34
+ measurements there.
35
+
36
+ ## The verify gate
37
+
38
+ Run all three, in order. The order matters: coverage failures explain pixel failures.
39
+
40
+ 1. **Coverage** — `scripts/restore_still_css.py --html … --still …`: every class any
41
+ still uses is consumed by some rule in the carried CSS; uncovered classes are named
42
+ and the script exits 1 (a class no source page styles on purpose — a semantic marker
43
+ such as `cl-vis-public` — earns `--no-strict`). The two real escapes both fail here
44
+ loudly: variables carried without their rules (every `c-*`/`t-*` uncovered → the
45
+ stripe field), and rules taken from one source page while a diagram type carries its
46
+ own (`cl-type` uncovered → D6's black interface panels).
47
+ 2. **Pixels** — render the still and the owning artefact, crop the same region, compare:
48
+ light-pixel fraction (magick `-colorspace gray -threshold 40% -format '%[fx:mean]'`),
49
+ and per-panel sampling where a defect lived. The measured case: the broken still
50
+ scored 0.37 light, the fixed one 0.996, per-panel `rgb(222,248,252)` where black was.
51
+ 3. **Vision** — a vision-capable read of the rendered page against the owner's render,
52
+ asking for legibility per diagram (card titles, edge labels, legend), stripe/checker
53
+ patterns, black slabs, and any difference from the reference. "Clean" means readable
54
+ without obstruction, not merely painted.
55
+
56
+ **Why a painted-pixel probe cannot substitute:** the first build's QA measured
57
+ colored-pixel share per strip (11–26% = "painted") and passed a page whose background was
58
+ a field of black triangles. A defect whose symptom is *wrong colour* is invisible to a
59
+ probe that asks *whether anything was drawn*. The reference comparison is the gate; the
60
+ probe is at most a smoke test.
61
+
62
+ ## Showing a large page inline
63
+
64
+ `html_preview({html})` → `html_render({html, title, height})` both want the HTML string,
65
+ capped at 512,000 characters. A portfolio is 300–500 KB — far too much to read into
66
+ context and re-emit. Do not shuttle it:
67
+
68
+ 1. Serve the folder on loopback, in the background:
69
+ `cd <folder> && python3 -m http.server 8765 --bind 127.0.0.1`
70
+ 2. In the Code Mode runtime (where the render tools live): fetch it and render, so the
71
+ bytes go server-to-tool, never through the model:
72
+ `const html = await (await fetch("http://127.0.0.1:8765/portfolio.html")).text();`
73
+ then `html_preview({html, width, appearance})`, take its content height, then
74
+ `html_render({html, title, height})` (height ≤ 2000; a tall page scrolls in the frame).
75
+ 3. Kill the server the moment the render returns — a loopback door left open is still a
76
+ door. One GET in the log is the expected shape.
77
+
78
+ For an image to post or send elsewhere: export a `.png` and give its path — never
79
+ `html_render`. For a file the user should open themselves: `browser.preview({path})`.
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env python3
2
+ """The CSS that stills lifted out of a styled page need — extracted, re-scoped, and checked.
3
+
4
+ An SVG lifted out of a page that styles it (an archify diagram taken out of its HTML)
5
+ keeps its elements and class attributes but loses the page's CSS. Palette variables
6
+ usually travel (they sit in a scoped block); the rules that read them do not, so every
7
+ classed element falls back to SVG's default fill — black. This script carries the rules:
8
+
9
+ * reads the CSS of every --html source page and keeps the rules that can apply inside
10
+ a lifted diagram (any selector mentioning `svg`, or any class a still uses);
11
+ * takes the UNION of all source pages — each diagram type carries its own rules (the
12
+ class diagram's `svg[data-class-ui]` rules live only in the class diagram's page);
13
+ * reads every class of every multi-class attribute (`class="c-frontend cl-type"` is two
14
+ classes; a first-class-only extraction silently drops the second);
15
+ * re-scopes each selector to --scope (default `svg[data-portfolio]`): page prefixes
16
+ (`html[...]`, `.diagram-container >`) are stripped, and the stills must carry the
17
+ scoping attribute (`data-portfolio="<key>"`) for the result to apply;
18
+ * writes the rules to --out-css and the @font-face declarations to --out-fonts;
19
+ * CHECKS coverage: every class any still uses must be consumed by some kept rule.
20
+ Uncovered classes are named; --no-strict downgrades the failure to a warning when a
21
+ class is known to be unstyled on purpose.
22
+
23
+ Exit codes: 0 clean; 1 uncovered classes (strict mode); 2 usage/input errors.
24
+ """
25
+
26
+ import argparse
27
+ import os
28
+ import re
29
+ import sys
30
+
31
+ DEFAULT_SCOPE = "svg[data-portfolio]"
32
+ PAGE_PREFIXES = ("html", ".diagram-container")
33
+
34
+
35
+ def split_parts(selector: str) -> list[str]:
36
+ """A selector list split on top-level commas only (:is(a, b) stays one part)."""
37
+ parts, depth, buf = [], 0, ""
38
+ for ch in selector:
39
+ if ch == "(":
40
+ depth += 1
41
+ elif ch == ")":
42
+ depth -= 1
43
+ if ch == "," and depth == 0:
44
+ parts.append(buf.strip())
45
+ buf = ""
46
+ else:
47
+ buf += ch
48
+ if buf.strip():
49
+ parts.append(buf.strip())
50
+ return parts
51
+
52
+
53
+ def split_rules(css: str) -> list[tuple[str, str]]:
54
+ """Top-level (selector, declarations) pairs; @media bodies are skipped."""
55
+ rules, depth, buf = [], 0, ""
56
+ for ch in css:
57
+ if ch == "{":
58
+ depth += 1
59
+ buf += ch
60
+ elif ch == "}":
61
+ depth -= 1
62
+ buf += ch
63
+ if depth == 0:
64
+ selector, _, body = buf.partition("{")
65
+ rules.append((selector.strip(), body[:-1].strip()))
66
+ buf = ""
67
+ else:
68
+ buf += ch
69
+ return rules
70
+
71
+
72
+ def strip_page_prefixes(selector: str) -> str:
73
+ """Drop the page chrome a rule may depend on, keeping the diagram part."""
74
+ changed = True
75
+ while changed:
76
+ changed = False
77
+ for prefix in PAGE_PREFIXES:
78
+ if selector.startswith(prefix):
79
+ selector = selector[len(prefix):].lstrip()
80
+ changed = True
81
+ if selector.startswith(">"):
82
+ selector = selector[1:].lstrip()
83
+ changed = True
84
+ match = re.match(r"^html\[[^\]]*\]", selector)
85
+ if match:
86
+ selector = selector[match.end():].lstrip()
87
+ changed = True
88
+ return selector
89
+
90
+
91
+ def scope_part(part: str, scope: str) -> str | None:
92
+ """The part re-scoped to the stills, or None when it cannot apply inside a diagram."""
93
+ part = strip_page_prefixes(part)
94
+ if not part or "body" in part:
95
+ return None
96
+ if re.match(r"^svg\b", part): # keep the compound; add the scoping attribute to it
97
+ return part[:3] + f"[{scope[len('svg') + 1:-1]}]" + part[3:]
98
+ return f"{scope} {part}"
99
+
100
+
101
+ def classes_of(svg: str) -> set[str]:
102
+ """Every class in the still — one attribute may hold several."""
103
+ found: set[str] = set()
104
+ for attribute in re.findall(r'class="([^"]*)"', svg):
105
+ found.update(attribute.split())
106
+ return found
107
+
108
+
109
+ def read_css_of(html_path: str) -> str:
110
+ html = open(html_path, encoding="utf-8").read()
111
+ return "\n".join(re.findall(r"<style[^>]*>(.*?)</style>", html, re.S))
112
+
113
+
114
+ def main(argv: list[str] | None = None) -> int:
115
+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
116
+ parser.add_argument("--html", nargs="+", required=True,
117
+ help="the styled pages the stills were lifted from (ALL of them)")
118
+ parser.add_argument("--still", nargs="+", required=True,
119
+ help="the lifted SVG stills, with the scoping attribute set")
120
+ parser.add_argument("--out-css", required=True, help="where the scoped rules go")
121
+ parser.add_argument("--out-fonts", help="where the @font-face declarations go")
122
+ parser.add_argument("--scope", default=DEFAULT_SCOPE,
123
+ help=f"scoping selector (default {DEFAULT_SCOPE})")
124
+ parser.add_argument("--no-strict", action="store_true",
125
+ help="uncovered classes warn instead of failing")
126
+ args = parser.parse_args(argv)
127
+
128
+ for path in [*args.html, *args.still]:
129
+ if not os.path.isfile(path):
130
+ print(f"no such file: {path}", file=sys.stderr)
131
+ return 2
132
+
133
+ used: set[str] = set()
134
+ for path in args.still:
135
+ used |= classes_of(open(path, encoding="utf-8").read())
136
+
137
+ rules: dict[str, str] = {}
138
+ for html_path in args.html:
139
+ for selector, body in split_rules(read_css_of(html_path)):
140
+ if selector.startswith("@") or "@" in selector.split("{")[0]:
141
+ continue # @media / @supports: not needed for a still
142
+ kept = []
143
+ for part in split_parts(selector):
144
+ if "svg" in part or any(f".{name}" in part for name in used):
145
+ scoped = scope_part(part, args.scope)
146
+ if scoped:
147
+ kept.append(scoped)
148
+ if kept:
149
+ rules[f"{', '.join(kept)} {{ {body} }}"] = selector
150
+
151
+ carried = "\n".join(rules)
152
+ open(args.out_css, "w", encoding="utf-8").write(carried + "\n")
153
+ if args.out_fonts:
154
+ fonts = "\n".join(
155
+ sorted({face
156
+ for html_path in args.html
157
+ for face in re.findall(r"@font-face\s*\{[^}]*\}", read_css_of(html_path))})
158
+ )
159
+ open(args.out_fonts, "w", encoding="utf-8").write(fonts + "\n")
160
+
161
+ covered = {name for name in used if f".{name}" in carried}
162
+ uncovered = sorted(used - covered)
163
+ print(f"{len(rules)} rules, {len(carried)} bytes -> {args.out_css}")
164
+ print(f"{len(used)} classes used by the stills, {len(covered)} covered")
165
+ if uncovered:
166
+ print("uncovered classes (no carried rule consumes them):")
167
+ for name in uncovered:
168
+ print(f" .{name}")
169
+ if args.no_strict:
170
+ print("--no-strict: continuing despite uncovered classes")
171
+ return 0
172
+ print("these elements will fall back to SVG defaults (fill: black) — "
173
+ "add their source page to --html, or pass --no-strict if they are "
174
+ "unstyled on purpose")
175
+ return 1
176
+ return 0
177
+
178
+
179
+ if __name__ == "__main__":
180
+ sys.exit(main())
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Coldtea AI
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,99 @@
1
+ ---
2
+ name: pr-lens
3
+ description: "Deterministic PR diagrams: turn a pull request's diff into a validated graph document, then render mechanically consistent architecture and data-flow SVGs with GitHub's own delta semantics — green added, amber changed, red removed, dimmed unchanged neighbours. Use when a PR's blast radius and mechanics should look identical every run (CI-grade consistency), when the diagram-router routes a 'diagram the PR' request here, or when PR Lens is named explicitly. Not for editorial or branded diagrams, charts, journeys, or narrative before/after stories — those belong to archify, stack-diagram and diagram-design."
4
+ license: MIT
5
+ metadata:
6
+ version: "1.0"
7
+ upstream: "@coldtea/pr-lens-agent-skill@0.1.5 + @coldtea/pr-lens-cli@0.2.0"
8
+ ---
9
+
10
+ # PR Lens (host wrapper)
11
+
12
+ A **deterministic renderer wrapped around a flat data model.** You author a
13
+ strict graph document describing only what the diff changes; the CLI validates
14
+ it against the schema and renders SVGs that look the same every single run.
15
+
16
+ This is a renderer, not a storyteller. Its vocabulary is blast radius, delta
17
+ semantics, and call structure — not the PR's argument. Route accordingly (the
18
+ `diagram-router` skill owns that decision; its `references/routing.md` names
19
+ when this skill wins).
20
+
21
+ ## When this is the right tool
22
+
23
+ | The story is… | Use |
24
+ |---|---|
25
+ | What the PR touched, what it added/changed/removed, what it left alone (blast radius) | **this skill** |
26
+ | The same diagram, identically, on every PR, from CI | **this skill** |
27
+ | A call/data-flow trace of the change with delta colours | **this skill** |
28
+ | The PR's narrative — before/after of a contract, outcome taxonomies, gate structures | `diagram-design` (architecture delta) |
29
+ | Infra topology with logos | `stack-diagram` |
30
+ | An explorable page or a sequence with annotations | `archify` |
31
+
32
+ ## Setup (once per machine)
33
+
34
+ The npm toolchain is **not** installed into this skill directory (it is symlinked
35
+ into every consumer). It installs to a cache dir from the committed lockfile —
36
+ reproducible, no version drift:
37
+
38
+ ```bash
39
+ mkdir -p ~/.cache/pr-lens
40
+ cp ~/.agents/skills/pr-lens/package.json ~/.agents/skills/pr-lens/package-lock.json ~/.cache/pr-lens/
41
+ cd ~/.cache/pr-lens && npm ci
42
+ # binary: ~/.cache/pr-lens/node_modules/.bin/pr-lens
43
+ ```
44
+
45
+ Verify: `~/.cache/pr-lens/node_modules/.bin/pr-lens --help`
46
+
47
+ ## Workflow
48
+
49
+ 1. **Read the contract first** — `references/graph-document.md` (233 lines) and
50
+ `references/example.graph.json`. The schema is strict: an unknown key is a
51
+ rejection, not a warning. Every node carries `files` with line ranges; every
52
+ delta is one vocabulary (`added | modified | removed | unchanged`).
53
+ 2. **Read the PR the way the document demands** — diff shape first
54
+ (`gh pr diff <n> --name-only`… note: `gh pr diff` takes no pathspecs; use
55
+ targeted `git diff <base>..<head> -- <path>` against a checkout, or full-diff
56
+ dumps filtered yourself), then the owning project's AGENTS.md and module
57
+ docstrings, then targeted hunks. Bound the graph to **only what the diff
58
+ changes**, including honest `unchanged` neighbours for blast radius.
59
+ 3. **Author `.pr-lens/graph.json`** in the working directory.
60
+ 4. **Validate until exit 0**:
61
+ ```bash
62
+ ~/.cache/pr-lens/node_modules/.bin/pr-lens validate .pr-lens/graph.json
63
+ ```
64
+ 5. **Render both themes**:
65
+ ```bash
66
+ ~/.cache/pr-lens/node_modules/.bin/pr-lens render .pr-lens/graph.json --theme dark
67
+ ~/.cache/pr-lens/node_modules/.bin/pr-lens render .pr-lens/graph.json --theme light
68
+ ```
69
+ 6. **Inspect the render** — the renderer cannot notice its own mistakes.
70
+ Screenshot the SVGs (`~/.local/bin/chromium --headless --screenshot …`) and
71
+ look for edge labels sitting on node cards; if a label collides, shorten the
72
+ label (the layout is not negotiable). Check `manifest.json` lists what you
73
+ expect — but know its limits below.
74
+
75
+ ## Known limits (measured in multi-module PR A/B benchmarks)
76
+
77
+ - **No field for before/after pairing** — a removed edge and an added edge are
78
+ the closest it gets; there is no "this replaced that."
79
+ - **Node summaries do not render** — the richest prose lives only in
80
+ `graph.json`/canvas. If a fact must be *seen*, it must be a label, chip, or
81
+ badge — or it belongs in a different skill's diagram.
82
+ - **The manifest lists only the most recent render's theme** — after
83
+ dark-then-light, trust the directory listing.
84
+ - **Re-rendering orphans stale content-hashed SVGs** — nothing sweeps them;
85
+ delete `.pr-lens/*.svg` before a re-render if the directory is shared.
86
+ - **Label placement is the renderer's weak spot** — always inspect (step 6).
87
+ - Runtime cost: ~12 MB of node_modules (pinned by lockfile) and Node ≥ 20.11.
88
+
89
+ ## Delivering
90
+
91
+ The output is SVG files plus `manifest.json`/`drawn.graph.json`. This skill is
92
+ a standalone renderer — it produces the SVG artefacts and leaves delivery channel
93
+ selection to the caller (if `diagram-router` is installed, its
94
+ `references/channels.md` documents PR-comment upload and cleanup mechanics).
95
+
96
+ ## Provenance
97
+
98
+ See `VENDOR.md` for upstream versions, licence, and the update path. The
99
+ vendored `references/` are upstream's own documents (MIT, © 2026 Coldtea AI).