@canonical/design-system 0.2.0 → 0.2.2
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.
- package/bun.lock +1 -0
- package/package.json +2 -1
- package/skills/adoption-a1-styles/SKILL.md +44 -0
- package/skills/adoption-a2-components/SKILL.md +17 -1
- package/skills/adoption-a3-forms/SKILL.md +21 -0
- package/skills/anatomy-author/SKILL.md +32 -0
- package/skills/design-auditor/SKILL.md +197 -274
- package/skills/implement-component/SKILL.md +21 -0
- package/skills/specify-component/SKILL.md +37 -0
- package/skills/specify-pattern/SKILL.md +35 -0
- package/src/collect/generateTurtle.tests.ts +148 -0
- package/src/collect/generateTurtle.ts +71 -22
- package/src/collect/types.ts +20 -0
package/bun.lock
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"types": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "LGPL-3.0",
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.2",
|
|
8
8
|
"bin": {
|
|
9
9
|
"collect-implementations": "./src/collect-implementations.ts"
|
|
10
10
|
},
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ajv": "^8.17.1",
|
|
42
|
+
"tinyglobby": "^0.2.14",
|
|
42
43
|
"jsonld": "^9.0.0",
|
|
43
44
|
"n3": "^2.0.1"
|
|
44
45
|
}
|
|
@@ -50,6 +50,33 @@ Fonts are opt-in and must be imported FIRST. The canonical form, in the root sty
|
|
|
50
50
|
fonts entry loads Ubuntu Sans as variable fonts, self-hosted from
|
|
51
51
|
`@canonical/ds-assets` via its `@font-face` rules — no external font host.
|
|
52
52
|
|
|
53
|
+
## Declare the surface: context and density classes
|
|
54
|
+
|
|
55
|
+
The density system is class-driven, and it starts at the root. The app's root element
|
|
56
|
+
(`<body>`, or the app's root container) must carry TWO classes:
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<body class="app comfortable">
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **Context** — `app`, `site`, or `docs`: which surface this is. Applications take
|
|
63
|
+
`app`; marketing/brochure surfaces take `site`; documentation surfaces take `docs`
|
|
64
|
+
(`docs` shares `site`'s values).
|
|
65
|
+
- **Density** — `comfortable` or `dense`: picks within the context's pair.
|
|
66
|
+
`comfortable` is the default choice unless the product's design calls for `dense`.
|
|
67
|
+
|
|
68
|
+
Components never read these classes directly — they read the `--density-*` custom
|
|
69
|
+
properties the classes emit (control heights, inline padding, vertical spacing rungs,
|
|
70
|
+
baseline seating). A section can locally tighten by carrying its own `dense` class on
|
|
71
|
+
an ancestor of just that region.
|
|
72
|
+
|
|
73
|
+
**Failure mode: missing root classes fail SILENTLY.** The primitives fall back to
|
|
74
|
+
app-comfortable values, so an application looks right by accident — while a site or
|
|
75
|
+
docs surface, or any intended `dense` region, quietly renders with the wrong control
|
|
76
|
+
heights and spacing. This step has historically been forgotten precisely because
|
|
77
|
+
nothing errors. If control heights or spacing look subtly off, check the root classes
|
|
78
|
+
before debugging component CSS.
|
|
79
|
+
|
|
53
80
|
## The /icons serving contract (and its silent failure)
|
|
54
81
|
|
|
55
82
|
Icons are per-file SVGs in `@canonical/ds-assets` (`icons/<name>.svg`, 16x16 viewBox,
|
|
@@ -103,6 +130,12 @@ imported preview.
|
|
|
103
130
|
## Verify
|
|
104
131
|
|
|
105
132
|
- [ ] Computed `font-family` on body text shows Ubuntu Sans.
|
|
133
|
+
- [ ] The root element carries one context class (`app`/`site`/`docs`) and one
|
|
134
|
+
density class (`comfortable`/`dense`).
|
|
135
|
+
- [ ] Computed `--density-line-height` on a control matches the intended cell
|
|
136
|
+
(e.g. `32px` for app-comfortable, `36px` for site-comfortable) — a fallback
|
|
137
|
+
value on a class-less root passes visual inspection and still fails this check
|
|
138
|
+
on non-app surfaces.
|
|
106
139
|
- [ ] `/icons/<name>.svg` returns 200 with SVG content, and an icon visibly renders.
|
|
107
140
|
- [ ] The `@layer normalize, ds.reset, ds.modifiers, ds.components` rule is present in
|
|
108
141
|
the served CSS.
|
|
@@ -113,3 +146,14 @@ imported preview.
|
|
|
113
146
|
## Next
|
|
114
147
|
|
|
115
148
|
Foundation in place — continue with `adoption-a2-components`.
|
|
149
|
+
|
|
150
|
+
## Support
|
|
151
|
+
|
|
152
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
153
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
154
|
+
stuck:
|
|
155
|
+
|
|
156
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
157
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
158
|
+
- Or contact the design-system team owners directly through your organization's
|
|
159
|
+
professional messaging channels for assistance.
|
|
@@ -7,7 +7,10 @@ description: Swap an application's UI to Canonical design-system components one
|
|
|
7
7
|
|
|
8
8
|
The second adoption track: replace the app's existing UI elements with design-system
|
|
9
9
|
components. Prerequisite: track A1 is done — styles, fonts, and icons are live, so
|
|
10
|
-
swapped components land on the right foundation.
|
|
10
|
+
swapped components land on the right foundation. That includes the root context and
|
|
11
|
+
density classes (`class="app comfortable"` — A1's "Declare the surface" section):
|
|
12
|
+
component geometry reads the `--density-*` channel those classes emit, and a swap onto
|
|
13
|
+
a class-less root looks subtly wrong rather than broken.
|
|
11
14
|
|
|
12
15
|
## When to Use
|
|
13
16
|
|
|
@@ -161,6 +164,8 @@ yet — check the component's types before writing it.
|
|
|
161
164
|
|
|
162
165
|
## Verify per PR
|
|
163
166
|
|
|
167
|
+
- [ ] Root context and density classes present (track A1) — swapped components size
|
|
168
|
+
from the `--density-*` channel, not from luck.
|
|
164
169
|
- [ ] Zero dev-console warnings from the swapped components.
|
|
165
170
|
- [ ] Keyboard pass on each swapped instance (focus, activation, escape where relevant).
|
|
166
171
|
- [ ] Visual pass against the component's Storybook stories.
|
|
@@ -168,3 +173,14 @@ yet — check the component's types before writing it.
|
|
|
168
173
|
## Next
|
|
169
174
|
|
|
170
175
|
Forms are their own programming model — continue with `adoption-a3-forms`.
|
|
176
|
+
|
|
177
|
+
## Support
|
|
178
|
+
|
|
179
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
180
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
181
|
+
stuck:
|
|
182
|
+
|
|
183
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
184
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
185
|
+
- Or contact the design-system team owners directly through your organization's
|
|
186
|
+
professional messaging channels for assistance.
|
|
@@ -39,6 +39,14 @@ Then BOTH stylesheets in the root stylesheet:
|
|
|
39
39
|
The first brings the global reset and tokens; the second the input chrome and field
|
|
40
40
|
layout. The package builds on top of `@canonical/react-ds-global`.
|
|
41
41
|
|
|
42
|
+
Forms are the heaviest consumer of the density system: control heights, field spacing,
|
|
43
|
+
and baseline seating all read the `--density-*` channel, which only emits real values
|
|
44
|
+
when the app root carries its context and density classes
|
|
45
|
+
(`class="app comfortable"` — track A1's "Declare the surface" section). Confirm those
|
|
46
|
+
classes before judging any form layout: without them the primitives silently fall back
|
|
47
|
+
to app-comfortable values, and a `dense` or site-surface form renders with the wrong
|
|
48
|
+
geometry.
|
|
49
|
+
|
|
42
50
|
## The react-hook-form switch
|
|
43
51
|
|
|
44
52
|
Form state moves INTO the form system:
|
|
@@ -129,6 +137,19 @@ live react-hook-form state while you exercise a story.
|
|
|
129
137
|
|
|
130
138
|
## Verify
|
|
131
139
|
|
|
140
|
+
- [ ] Root context and density classes present (track A1) — field spacing and control
|
|
141
|
+
seating read the `--density-*` channel.
|
|
132
142
|
- [ ] Submit round-trip works, with validation errors surfaced per field.
|
|
133
143
|
- [ ] The whole form is completable keyboard-only.
|
|
134
144
|
- [ ] Zero dev-console warnings from the form components.
|
|
145
|
+
|
|
146
|
+
## Support
|
|
147
|
+
|
|
148
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
149
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
150
|
+
stuck:
|
|
151
|
+
|
|
152
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
153
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
154
|
+
- Or contact the design-system team owners directly through your organization's
|
|
155
|
+
professional messaging channels for assistance.
|
|
@@ -26,6 +26,27 @@ The Anatomy DSL represents design system components as YAML trees with:
|
|
|
26
26
|
|
|
27
27
|
This skill helps you author these specifications correctly and consistently.
|
|
28
28
|
|
|
29
|
+
## Working mode: assistant to a design authority
|
|
30
|
+
|
|
31
|
+
Most of the time this skill runs in collaboration with a senior designer or engineer —
|
|
32
|
+
they are the design authority, you are the assistant whose job is to make them
|
|
33
|
+
successful. Default to that mode: lay out where the flow stands, do the legwork
|
|
34
|
+
(discovery queries, template drafting, validation) and return digestible findings, and
|
|
35
|
+
bring structural decisions to the person as a recommendation plus a question rather
|
|
36
|
+
than a fait accompli. An anatomy encodes opinions the graph cannot settle alone —
|
|
37
|
+
draw the person's knowledge out and use it.
|
|
38
|
+
|
|
39
|
+
Full autonomy is the exception, not the default: run the whole flow alone only when
|
|
40
|
+
explicitly asked to. Even then, list every judgment call made unilaterally in the
|
|
41
|
+
final report so a human can revisit them.
|
|
42
|
+
|
|
43
|
+
Decision gates — in collaboration, pause at each and resolve it WITH the person:
|
|
44
|
+
|
|
45
|
+
1. Node boundaries: what is a named subcomponent vs. an anonymous structural role.
|
|
46
|
+
2. Slot names — they become API surface.
|
|
47
|
+
3. Cardinality choices, especially optional vs. required parts.
|
|
48
|
+
4. What the anatomy fixes vs. what is deliberately left free.
|
|
49
|
+
|
|
29
50
|
The full specification ships beside this file as `ANATOMY_DSL_SPEC.md` in the
|
|
30
51
|
installed skill folder — `pragma skill lookup anatomy-author` renders only this
|
|
31
52
|
SKILL.md, so open the sibling file directly when you need the complete spec (the
|
|
@@ -1091,3 +1112,14 @@ The following features would require additional work:
|
|
|
1091
1112
|
- Representation of related nodes displayed in portals
|
|
1092
1113
|
- Representation of conditional display
|
|
1093
1114
|
- Inheritance reference for styles (e.g., "NetworkCard inherits from Card")
|
|
1115
|
+
|
|
1116
|
+
## Support
|
|
1117
|
+
|
|
1118
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
1119
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
1120
|
+
stuck:
|
|
1121
|
+
|
|
1122
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
1123
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
1124
|
+
- Or contact the design-system team owners directly through your organization's
|
|
1125
|
+
professional messaging channels for assistance.
|
|
@@ -5,7 +5,36 @@ description: Audit design system coverage, consistency, and quality
|
|
|
5
5
|
|
|
6
6
|
# Design Auditor
|
|
7
7
|
|
|
8
|
-
Audit design system coverage, consistency, and quality. This semantic skill analyzes
|
|
8
|
+
Audit design system coverage, consistency, and quality. This semantic skill analyzes
|
|
9
|
+
the knowledge graph to find gaps, inconsistencies, and opportunities for improvement
|
|
10
|
+
across components, patterns, layouts, and documentation.
|
|
11
|
+
|
|
12
|
+
In a fresh session, orient first:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pragma capabilities
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Working mode: assistant to a design authority
|
|
19
|
+
|
|
20
|
+
An audit produces judgments, and most of the time those judgments belong to a senior
|
|
21
|
+
designer or engineer — you are the assistant whose job is to make them successful.
|
|
22
|
+
Default to that mode: lay out the audit direction, run the queries and return
|
|
23
|
+
digestible findings, and bring each judgment to the person as a recommendation plus a
|
|
24
|
+
question rather than a verdict. They know which gaps are deliberate, which components
|
|
25
|
+
are on the way out, and which numbers actually worry the team — the graph does not.
|
|
26
|
+
|
|
27
|
+
Full autonomy is the exception, not the default: run a whole audit alone only when
|
|
28
|
+
explicitly asked to. Even then, list every judgment call made unilaterally in the
|
|
29
|
+
final report so a human can revisit them.
|
|
30
|
+
|
|
31
|
+
Decision gates — in collaboration, pause at each and resolve it WITH the person:
|
|
32
|
+
|
|
33
|
+
1. Scope: which audit dimensions matter right now, and which tiers are in scope.
|
|
34
|
+
2. What counts as concerning: agree the thresholds with the team instead of importing
|
|
35
|
+
folklore numbers — a "low" pattern count may be a young catalog, not a problem.
|
|
36
|
+
3. Prioritization of the recommendations.
|
|
37
|
+
4. Any promote/demote/deprecate suggestion — these are roadmap calls, not data calls.
|
|
9
38
|
|
|
10
39
|
## When to Use
|
|
11
40
|
|
|
@@ -16,20 +45,45 @@ Audit design system coverage, consistency, and quality. This semantic skill anal
|
|
|
16
45
|
- Preparing for design system roadmap planning
|
|
17
46
|
- Auditing before a major release
|
|
18
47
|
|
|
48
|
+
## When NOT to Use
|
|
49
|
+
|
|
50
|
+
- Auditing an APP's adoption of the design system — that is the
|
|
51
|
+
`adoption-a1-styles`/`a2`/`a3` tracks
|
|
52
|
+
- Fixing what the audit finds — route gaps to `specify-component`/`specify-pattern`,
|
|
53
|
+
missing anatomies to `anatomy-author`
|
|
54
|
+
|
|
19
55
|
## Discovery Flow
|
|
20
56
|
|
|
21
57
|
Start with a broad inventory, then drill into specific concerns:
|
|
22
58
|
|
|
59
|
+
```bash
|
|
60
|
+
pragma block list # every component, pattern, layout and subcomponent, with type and tier
|
|
61
|
+
pragma modifier list # every modifier family with its values
|
|
62
|
+
pragma tier list # the tiers blocks can live in
|
|
63
|
+
pragma graph query "…" # the audit queries below
|
|
64
|
+
pragma graph inspect <IRI-or-ds:name> # every triple on one entity
|
|
23
65
|
```
|
|
24
|
-
sem_readme(package: "design-system")
|
|
25
|
-
→ Get overview of classes and counts
|
|
26
66
|
|
|
27
|
-
|
|
28
|
-
→ Get full inventory across types
|
|
67
|
+
Two graph-query mechanics to know (shared with the sibling skills):
|
|
29
68
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
69
|
+
- Common prefixes (`ds:`, `cs:`) are applied automatically — no PREFIX preamble.
|
|
70
|
+
- Inside a SPARQL body, a local name with more than one dot
|
|
71
|
+
(`ds:global.component.button`) does not parse — use the full IRI there
|
|
72
|
+
(`<https://ds.canonical.com/global.component.button>`). Single-dot and dot-free
|
|
73
|
+
prefixed names (`ds:global`, `ds:Component`) work as-is.
|
|
74
|
+
|
|
75
|
+
Note that `block list` deliberately omits the `ds:Group` class — an audit that counts
|
|
76
|
+
only the list under-counts. The queries below go to the graph directly, so they see
|
|
77
|
+
groups too.
|
|
78
|
+
|
|
79
|
+
> The covered set is whatever the graph answers today. Query it live — never copy its
|
|
80
|
+
> output (counts, names, ratios) into documentation, PRs, or this skill.
|
|
81
|
+
|
|
82
|
+
One more live-data rule: before trusting any query, confirm its predicates against the
|
|
83
|
+
current ontology (`pragma ontology lookup ds`). The vocabulary evolves — for example,
|
|
84
|
+
`ds:usage` subsumed the former `whenToUse`/`whenNotToUse` predicates, and queries
|
|
85
|
+
against retired names return empty tables, not errors. An empty result must be
|
|
86
|
+
distinguished from a wrong query before it becomes a finding.
|
|
33
87
|
|
|
34
88
|
## Audit Dimensions
|
|
35
89
|
|
|
@@ -47,81 +101,94 @@ What's connected vs. orphaned?
|
|
|
47
101
|
|
|
48
102
|
## Key Queries
|
|
49
103
|
|
|
50
|
-
|
|
104
|
+
Documentation-completeness queries must catch BOTH the absent predicate and the empty
|
|
105
|
+
string — many entries carry a field that is present but blank, and a
|
|
106
|
+
`FILTER NOT EXISTS` alone misses them.
|
|
51
107
|
|
|
52
|
-
|
|
53
|
-
PREFIX ds: <https://ds.canonical.com/>
|
|
108
|
+
### Coverage: Components by Tier
|
|
54
109
|
|
|
55
|
-
|
|
110
|
+
```bash
|
|
111
|
+
pragma graph query "SELECT ?tierName (COUNT(?c) as ?componentCount) WHERE {
|
|
56
112
|
?c a ds:Component ;
|
|
57
113
|
ds:tier ?tier .
|
|
58
114
|
?tier ds:name ?tierName .
|
|
59
115
|
} GROUP BY ?tierName
|
|
60
|
-
ORDER BY DESC(?componentCount)
|
|
116
|
+
ORDER BY DESC(?componentCount)"
|
|
61
117
|
```
|
|
62
118
|
|
|
63
|
-
**
|
|
119
|
+
**What it asks**: where the catalog's weight sits. A tier with few components can be a
|
|
120
|
+
gap, a young tier, or a deliberate scope — which one is a question for the team.
|
|
64
121
|
|
|
65
122
|
### Coverage: UIBlock Types Distribution
|
|
66
123
|
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
SELECT ?type (COUNT(?block) as ?count) WHERE {
|
|
71
|
-
VALUES ?type { ds:Component ds:Pattern ds:Layout ds:Subcomponent }
|
|
124
|
+
```bash
|
|
125
|
+
pragma graph query "SELECT ?type (COUNT(?block) as ?count) WHERE {
|
|
126
|
+
VALUES ?type { ds:Component ds:Pattern ds:Layout ds:Subcomponent ds:Group }
|
|
72
127
|
?block a ?type .
|
|
73
|
-
} GROUP BY ?type
|
|
128
|
+
} GROUP BY ?type"
|
|
74
129
|
```
|
|
75
130
|
|
|
76
|
-
**
|
|
131
|
+
**What it asks**: the shape of the catalog. There is no universally healthy ratio —
|
|
132
|
+
compare against the previous audit's numbers and let the team judge the trend.
|
|
133
|
+
|
|
134
|
+
### Quality: Blocks Missing or Blank Summary
|
|
77
135
|
|
|
78
|
-
|
|
136
|
+
```bash
|
|
137
|
+
pragma graph query "SELECT ?block ?name WHERE {
|
|
138
|
+
?block a ?type ;
|
|
139
|
+
ds:name ?name .
|
|
140
|
+
VALUES ?type { ds:Component ds:Pattern ds:Layout ds:Subcomponent ds:Group }
|
|
141
|
+
FILTER NOT EXISTS { ?block ds:summary ?s . FILTER(STR(?s) != '') }
|
|
142
|
+
}"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**What it asks**: which blocks have no base definition at all. These rows are also
|
|
146
|
+
what `implement-component` treats as "no spec here to implement".
|
|
79
147
|
|
|
80
|
-
|
|
81
|
-
PREFIX ds: <https://ds.canonical.com/>
|
|
148
|
+
### Quality: Components Missing or Blank Usage
|
|
82
149
|
|
|
83
|
-
|
|
150
|
+
```bash
|
|
151
|
+
pragma graph query "SELECT ?component ?name WHERE {
|
|
84
152
|
?component a ds:Component ;
|
|
85
153
|
ds:name ?name .
|
|
86
|
-
FILTER(
|
|
87
|
-
|
|
88
|
-
}
|
|
154
|
+
FILTER NOT EXISTS { ?component ds:usage ?u . FILTER(STR(?u) != '') }
|
|
155
|
+
}"
|
|
89
156
|
```
|
|
90
157
|
|
|
91
|
-
**
|
|
92
|
-
|
|
93
|
-
|
|
158
|
+
**What it asks**: where When-to-use / When-not-to-use guidance is missing (`ds:usage`
|
|
159
|
+
subsumes both). Without it, adopters cannot tell what replaces what — these gaps
|
|
160
|
+
directly hurt the adoption tracks.
|
|
94
161
|
|
|
95
|
-
|
|
96
|
-
PREFIX ds: <https://ds.canonical.com/>
|
|
162
|
+
### Quality: Components Missing or Blank Guidelines
|
|
97
163
|
|
|
98
|
-
|
|
164
|
+
```bash
|
|
165
|
+
pragma graph query "SELECT ?component ?name WHERE {
|
|
99
166
|
?component a ds:Component ;
|
|
100
167
|
ds:name ?name .
|
|
101
|
-
FILTER NOT EXISTS { ?component ds:
|
|
102
|
-
}
|
|
168
|
+
FILTER NOT EXISTS { ?component ds:guidelines ?g . FILTER(STR(?g) != '') }
|
|
169
|
+
}"
|
|
103
170
|
```
|
|
104
171
|
|
|
105
|
-
**
|
|
172
|
+
**What it asks**: where accessibility and best-practice material is missing —
|
|
173
|
+
`ds:guidelines` is its conventional home.
|
|
106
174
|
|
|
107
|
-
### Quality:
|
|
175
|
+
### Quality: Blocks Missing or Blank Anatomy
|
|
108
176
|
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
?
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
177
|
+
```bash
|
|
178
|
+
pragma graph query "SELECT ?block ?name WHERE {
|
|
179
|
+
?block a ?type ;
|
|
180
|
+
ds:name ?name .
|
|
181
|
+
VALUES ?type { ds:Component ds:Pattern }
|
|
182
|
+
FILTER NOT EXISTS { ?block ds:anatomyDsl ?a . FILTER(STR(?a) != '') }
|
|
183
|
+
}"
|
|
117
184
|
```
|
|
118
185
|
|
|
119
|
-
|
|
186
|
+
**What it asks**: `anatomy-author` candidates.
|
|
120
187
|
|
|
121
|
-
|
|
122
|
-
PREFIX ds: <https://ds.canonical.com/>
|
|
188
|
+
### Consistency: Modifier Family Usage
|
|
123
189
|
|
|
124
|
-
|
|
190
|
+
```bash
|
|
191
|
+
pragma graph query "SELECT ?family ?familyName (COUNT(?component) as ?usage) WHERE {
|
|
125
192
|
?family a ds:ModifierFamily ;
|
|
126
193
|
ds:name ?familyName .
|
|
127
194
|
OPTIONAL {
|
|
@@ -129,250 +196,126 @@ SELECT ?family ?familyName (COUNT(?component) as ?usage) WHERE {
|
|
|
129
196
|
ds:hasModifierFamily ?family .
|
|
130
197
|
}
|
|
131
198
|
} GROUP BY ?family ?familyName
|
|
132
|
-
ORDER BY DESC(?usage)
|
|
199
|
+
ORDER BY DESC(?usage)"
|
|
133
200
|
```
|
|
134
201
|
|
|
135
|
-
**
|
|
202
|
+
**What it asks**: which families are core and which are unused. A zero-usage family is
|
|
203
|
+
a question — premature abstraction, or adoption that has not landed yet?
|
|
136
204
|
|
|
137
205
|
### Consistency: Components Without Modifier Families
|
|
138
206
|
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
SELECT ?component ?name WHERE {
|
|
207
|
+
```bash
|
|
208
|
+
pragma graph query "SELECT ?component ?name WHERE {
|
|
143
209
|
?component a ds:Component ;
|
|
144
210
|
ds:name ?name .
|
|
145
211
|
FILTER NOT EXISTS { ?component ds:hasModifierFamily ?mf }
|
|
146
|
-
}
|
|
212
|
+
}"
|
|
147
213
|
```
|
|
148
214
|
|
|
149
|
-
**
|
|
215
|
+
**What it asks**: candidates to review — not every component needs modifiers, but
|
|
216
|
+
many do.
|
|
150
217
|
|
|
151
218
|
### Usage: Orphaned Subcomponents
|
|
152
219
|
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
SELECT ?sub ?name WHERE {
|
|
220
|
+
```bash
|
|
221
|
+
pragma graph query "SELECT ?sub ?name WHERE {
|
|
157
222
|
?sub a ds:Subcomponent ;
|
|
158
223
|
ds:name ?name .
|
|
159
224
|
FILTER NOT EXISTS { ?sub ds:parentComponent ?parent }
|
|
160
|
-
}
|
|
225
|
+
}"
|
|
161
226
|
```
|
|
162
227
|
|
|
163
|
-
**
|
|
228
|
+
**What it asks**: subcomponents without parents — either the relationship is missing,
|
|
229
|
+
or the block should be promoted to Component. Which one is a team call.
|
|
164
230
|
|
|
165
231
|
### Usage: Components With Subcomponents
|
|
166
232
|
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
SELECT ?component ?componentName (COUNT(?sub) as ?subCount) WHERE {
|
|
233
|
+
```bash
|
|
234
|
+
pragma graph query "SELECT ?component ?componentName (COUNT(?sub) as ?subCount) WHERE {
|
|
171
235
|
?component a ds:Component ;
|
|
172
236
|
ds:name ?componentName .
|
|
173
237
|
?sub ds:parentComponent ?component .
|
|
174
238
|
} GROUP BY ?component ?componentName
|
|
175
|
-
ORDER BY DESC(?subCount)
|
|
239
|
+
ORDER BY DESC(?subCount)"
|
|
176
240
|
```
|
|
177
241
|
|
|
178
|
-
**
|
|
242
|
+
**What it asks**: where composition complexity concentrates. A very high count is a
|
|
243
|
+
prompt to ask whether the decomposition still serves its users.
|
|
179
244
|
|
|
180
245
|
### Cross-Tier: Potential Promotion Candidates
|
|
181
246
|
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
SELECT ?component ?name ?tierName WHERE {
|
|
247
|
+
```bash
|
|
248
|
+
pragma graph query "SELECT ?component ?name ?tierName WHERE {
|
|
186
249
|
?component a ds:Component ;
|
|
187
250
|
ds:name ?name ;
|
|
188
251
|
ds:tier ?tier .
|
|
189
252
|
?tier ds:name ?tierName .
|
|
190
|
-
|
|
191
|
-
# Find non-global components that might be universal
|
|
192
|
-
FILTER(?tier != <https://ds.canonical.com/data/global>)
|
|
193
|
-
|
|
194
|
-
# Heuristic: has modifier families (suggests maturity)
|
|
253
|
+
FILTER(?tier != ds:global)
|
|
195
254
|
FILTER EXISTS { ?component ds:hasModifierFamily ?mf }
|
|
196
|
-
FILTER EXISTS { ?component ds:summary ?d }
|
|
197
|
-
FILTER EXISTS { ?component ds:
|
|
198
|
-
}
|
|
255
|
+
FILTER EXISTS { ?component ds:summary ?d . FILTER(STR(?d) != '') }
|
|
256
|
+
FILTER EXISTS { ?component ds:usage ?u . FILTER(STR(?u) != '') }
|
|
257
|
+
}"
|
|
199
258
|
```
|
|
200
259
|
|
|
201
|
-
**
|
|
260
|
+
**What it asks**: well-documented tier-specific components that MIGHT be universal.
|
|
261
|
+
Promotion is a roadmap decision — present these as candidates, never as conclusions.
|
|
262
|
+
|
|
263
|
+
## Audit Report
|
|
202
264
|
|
|
203
|
-
|
|
265
|
+
Build the report from the live query results, structured as:
|
|
204
266
|
|
|
205
267
|
```markdown
|
|
206
268
|
## Design System Audit Report
|
|
207
269
|
|
|
208
|
-
**Generated:** {date}
|
|
209
|
-
**Package:** design-system
|
|
210
|
-
**Version:** {version}
|
|
211
|
-
|
|
212
|
-
---
|
|
270
|
+
**Generated:** {date} **Scope:** {tiers/dimensions agreed at the scope gate}
|
|
213
271
|
|
|
214
272
|
### Executive Summary
|
|
273
|
+
Counts per UIBlock type and per tier, documentation coverage percentages, and the
|
|
274
|
+
headline findings — with each "concern" label traced to a threshold the team agreed,
|
|
275
|
+
not an imported one.
|
|
215
276
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
| Subcomponents | {n} | {status} |
|
|
222
|
-
| Modifier Families | {n} | {status} |
|
|
223
|
-
| Documentation Coverage | {%} | {status} |
|
|
224
|
-
|
|
225
|
-
**Overall Health:** {Good/Needs Attention/Critical}
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
### Coverage Analysis
|
|
230
|
-
|
|
231
|
-
#### By Tier
|
|
232
|
-
|
|
233
|
-
| Tier | Components | Patterns | Layouts |
|
|
234
|
-
|------|------------|----------|---------|
|
|
235
|
-
| global | {n} | {n} | {n} |
|
|
236
|
-
| apps | {n} | {n} | {n} |
|
|
237
|
-
| site | {n} | {n} | {n} |
|
|
238
|
-
| ... | ... | ... | ... |
|
|
239
|
-
|
|
240
|
-
**Observations:**
|
|
241
|
-
- {observation 1}
|
|
242
|
-
- {observation 2}
|
|
243
|
-
|
|
244
|
-
**Recommendations:**
|
|
245
|
-
- {recommendation 1}
|
|
246
|
-
- {recommendation 2}
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
### Quality Analysis
|
|
251
|
-
|
|
252
|
-
#### Documentation Completeness
|
|
253
|
-
|
|
254
|
-
| Property | Present | Missing | Coverage |
|
|
255
|
-
|----------|---------|---------|----------|
|
|
256
|
-
| description | {n} | {n} | {%} |
|
|
257
|
-
| whenToUse | {n} | {n} | {%} |
|
|
258
|
-
| whenNotToUse | {n} | {n} | {%} |
|
|
259
|
-
| guidelines | {n} | {n} | {%} |
|
|
260
|
-
| figmaLink | {n} | {n} | {%} |
|
|
261
|
-
|
|
262
|
-
**Components Needing Attention:**
|
|
263
|
-
1. {component}: missing {properties}
|
|
264
|
-
2. {component}: missing {properties}
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
### Consistency Analysis
|
|
269
|
-
|
|
270
|
-
#### Modifier Family Usage
|
|
271
|
-
|
|
272
|
-
| Family | Components Using | Coverage |
|
|
273
|
-
|--------|-----------------|----------|
|
|
274
|
-
| importance | {n} | {assessment} |
|
|
275
|
-
| criticality | {n} | {assessment} |
|
|
276
|
-
| density | {n} | {assessment} |
|
|
277
|
-
| ... | ... | ... |
|
|
278
|
-
|
|
279
|
-
**Inconsistencies Found:**
|
|
280
|
-
- {inconsistency 1}
|
|
281
|
-
- {inconsistency 2}
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
### Structural Analysis
|
|
286
|
-
|
|
287
|
-
#### Component Composition
|
|
288
|
-
|
|
289
|
-
| Component | Subcomponents | Assessment |
|
|
290
|
-
|-----------|---------------|------------|
|
|
291
|
-
| {name} | {n} | {assessment} |
|
|
292
|
-
|
|
293
|
-
**Orphaned Elements:**
|
|
294
|
-
- {list of orphaned subcomponents}
|
|
295
|
-
|
|
296
|
-
---
|
|
277
|
+
### Findings per dimension
|
|
278
|
+
Coverage / Quality / Consistency / Usage — for each: the numbers, the specific blocks
|
|
279
|
+
affected, and the open question or recommendation. Route each actionable gap to its
|
|
280
|
+
skill: missing spec → specify-component / specify-pattern; missing anatomy →
|
|
281
|
+
anatomy-author.
|
|
297
282
|
|
|
298
283
|
### Recommendations
|
|
284
|
+
Prioritized WITH the person (decision gate 3). Mark which items are data-driven
|
|
285
|
+
(e.g. "12 components have a blank summary") and which are judgment
|
|
286
|
+
(e.g. "consider promoting X to global").
|
|
299
287
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
2. {action item}
|
|
303
|
-
|
|
304
|
-
#### Medium Priority
|
|
305
|
-
1. {action item}
|
|
306
|
-
2. {action item}
|
|
307
|
-
|
|
308
|
-
#### Low Priority / Nice to Have
|
|
309
|
-
1. {action item}
|
|
310
|
-
2. {action item}
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
### Appendix: Raw Data
|
|
315
|
-
|
|
316
|
-
<details>
|
|
317
|
-
<summary>Components Missing Documentation</summary>
|
|
318
|
-
|
|
319
|
-
{list}
|
|
320
|
-
|
|
321
|
-
</details>
|
|
322
|
-
|
|
323
|
-
<details>
|
|
324
|
-
<summary>Unused Modifier Families</summary>
|
|
325
|
-
|
|
326
|
-
{list}
|
|
327
|
-
|
|
328
|
-
</details>
|
|
288
|
+
### Appendix
|
|
289
|
+
The raw query results the findings rest on, in collapsible sections.
|
|
329
290
|
```
|
|
330
291
|
|
|
331
292
|
## Workflow
|
|
332
293
|
|
|
333
294
|
### Quick Health Check
|
|
334
295
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
2. Run "Components Missing Descriptions" query
|
|
342
|
-
→ If > 20% missing, flag as concern
|
|
343
|
-
|
|
344
|
-
3. Run "Modifier Family Usage" query
|
|
345
|
-
→ If any family has 0 usage, investigate
|
|
296
|
+
```text
|
|
297
|
+
1. pragma block list + pragma modifier list — the big picture
|
|
298
|
+
2. Run the three Quality queries (summary, usage, guidelines)
|
|
299
|
+
3. Run Modifier Family Usage
|
|
300
|
+
4. Report the counts and the specific blocks; agree with the person what, if
|
|
301
|
+
anything, is alarming
|
|
346
302
|
```
|
|
347
303
|
|
|
348
304
|
### Full Audit
|
|
349
305
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
2. Coverage queries (all)
|
|
357
|
-
|
|
358
|
-
3. Quality queries (all)
|
|
359
|
-
|
|
360
|
-
4. Consistency queries (all)
|
|
361
|
-
|
|
362
|
-
5. Usage queries (all)
|
|
363
|
-
|
|
364
|
-
6. Generate report using template
|
|
365
|
-
|
|
366
|
-
7. Prioritize recommendations
|
|
306
|
+
```text
|
|
307
|
+
1. Scope gate: agree dimensions and tiers with the person
|
|
308
|
+
2. Inventory: block list, tier list, modifier list, types-distribution query
|
|
309
|
+
3. Coverage queries, Quality queries, Consistency queries, Usage queries
|
|
310
|
+
4. Compare against the previous audit's report where one exists
|
|
311
|
+
5. Draft the report; resolve interpretation and priorities with the person
|
|
367
312
|
```
|
|
368
313
|
|
|
369
314
|
### Targeted Audit
|
|
370
315
|
|
|
371
|
-
For specific concerns:
|
|
372
|
-
|
|
373
316
|
| Concern | Queries to Run |
|
|
374
317
|
|---------|----------------|
|
|
375
|
-
| "Are we missing patterns?" | Coverage by tier,
|
|
318
|
+
| "Are we missing patterns?" | Coverage by tier, types distribution |
|
|
376
319
|
| "Is documentation complete?" | All Quality queries |
|
|
377
320
|
| "Are modifiers consistent?" | Modifier Family Usage, Components Without Modifiers |
|
|
378
321
|
| "Any orphaned elements?" | Orphaned Subcomponents |
|
|
@@ -380,54 +323,34 @@ For specific concerns:
|
|
|
380
323
|
|
|
381
324
|
## Interpreting Results
|
|
382
325
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
| Metric | Good | Warning | Critical |
|
|
386
|
-
|--------|------|---------|----------|
|
|
387
|
-
| Description coverage | >90% | 70-90% | <70% |
|
|
388
|
-
| whenToUse coverage | >80% | 60-80% | <60% |
|
|
389
|
-
| Orphaned elements | 0 | 1-3 | >3 |
|
|
390
|
-
| Unused modifier families | 0-1 | 2-3 | >3 |
|
|
391
|
-
| Component:Pattern ratio | 2:1 to 4:1 | 5:1 to 7:1 | >7:1 |
|
|
392
|
-
|
|
393
|
-
### Common Issues and Fixes
|
|
394
|
-
|
|
395
|
-
| Issue | Likely Cause | Recommended Action |
|
|
396
|
-
|-------|--------------|-------------------|
|
|
397
|
-
| Many components missing descriptions | Rapid growth without documentation | Documentation sprint |
|
|
398
|
-
| Low pattern count | Focus on components over UX | Pattern extraction workshop |
|
|
399
|
-
| Unused modifier families | Premature abstraction | Remove or document intended use |
|
|
400
|
-
| Orphaned subcomponents | Refactoring without cleanup | Link to parents or promote |
|
|
401
|
-
| Tier imbalance | Organic growth | Review tier definitions |
|
|
402
|
-
|
|
403
|
-
## Following next_steps
|
|
404
|
-
|
|
405
|
-
After running queries, sem tools provide contextual guidance:
|
|
406
|
-
|
|
407
|
-
```json
|
|
408
|
-
{
|
|
409
|
-
"results": [...],
|
|
410
|
-
"next_steps": [
|
|
411
|
-
"Use sem_context on specific components to understand relationships",
|
|
412
|
-
"Use sem_describe to see full property definitions"
|
|
413
|
-
]
|
|
414
|
-
}
|
|
415
|
-
```
|
|
326
|
+
Interpretation is where the working mode matters most. The queries return facts; what
|
|
327
|
+
they MEAN is judged against the team's intent:
|
|
416
328
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
5. **Share reports with stakeholders**: Visibility drives improvement
|
|
426
|
-
6. **Automate recurring audits**: Consider scheduling monthly checks
|
|
329
|
+
- Prefer trends over absolutes: compare with the previous audit rather than against a
|
|
330
|
+
fixed "healthy" number.
|
|
331
|
+
- A gap can be deliberate (out-of-scope tier, deprecation in progress) — ask before
|
|
332
|
+
flagging.
|
|
333
|
+
- Distinguish data findings (a blank field IS blank) from judgment findings (a ratio
|
|
334
|
+
"looks" off) and label them differently in the report.
|
|
335
|
+
- Follow up drill-downs with `pragma graph inspect <IRI>` on the specific blocks a
|
|
336
|
+
query surfaced, and `pragma block lookup <Name>` for the human-readable view.
|
|
427
337
|
|
|
428
338
|
## Limitations
|
|
429
339
|
|
|
430
340
|
- Cannot assess visual design quality (only metadata)
|
|
431
341
|
- Cannot verify Figma link validity (only presence)
|
|
432
342
|
- Pattern quality is subjective (coverage is objective)
|
|
433
|
-
- Does not analyze implementation
|
|
343
|
+
- Does not analyze implementation packages — the graph records what is DOCUMENTED,
|
|
344
|
+
and packages ship what is BUILT; the two run ahead of each other in both directions
|
|
345
|
+
(see `adoption-a2-components` for the export check)
|
|
346
|
+
|
|
347
|
+
## Support
|
|
348
|
+
|
|
349
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
350
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
351
|
+
stuck:
|
|
352
|
+
|
|
353
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
354
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
355
|
+
- Or contact the design-system team owners directly through your organization's
|
|
356
|
+
professional messaging channels for assistance.
|
|
@@ -9,6 +9,16 @@ Take an APPROVED spec — from `specify-component`, or an existing documented bl
|
|
|
9
9
|
working code. The defining discipline: the applicable code standards are pulled and held
|
|
10
10
|
open DURING implementation, so they shape the code as it is written, not only in review.
|
|
11
11
|
|
|
12
|
+
## Working mode
|
|
13
|
+
|
|
14
|
+
This skill often runs alongside a senior engineer or designer. When it does, work as
|
|
15
|
+
their assistant: lay out where the flow stands, do the legwork (spec reads, standard
|
|
16
|
+
pulls, scaffolding), and surface decisions rather than absorbing them silently. The
|
|
17
|
+
points to raise with the person rather than decide alone: a thin or ambiguous spec
|
|
18
|
+
field, any deviation from a pulled standard, the target package for a tier outside the
|
|
19
|
+
naming convention, and API naming the spec does not fix. When running fully
|
|
20
|
+
autonomously (only on explicit request), list those judgment calls in the PR.
|
|
21
|
+
|
|
12
22
|
## When to Use
|
|
13
23
|
|
|
14
24
|
- An approved spec — from `specify-component`, or an existing documented block — needs
|
|
@@ -221,3 +231,14 @@ unavailable.
|
|
|
221
231
|
|
|
222
232
|
- `specify-component` — upstream: produces the spec this skill implements
|
|
223
233
|
- `anatomy-author` — the structure contract the implementation must honor
|
|
234
|
+
|
|
235
|
+
## Support
|
|
236
|
+
|
|
237
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
238
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
239
|
+
stuck:
|
|
240
|
+
|
|
241
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
242
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
243
|
+
- Or contact the design-system team owners directly through your organization's
|
|
244
|
+
professional messaging channels for assistance.
|
|
@@ -17,6 +17,32 @@ In a fresh session, orient first:
|
|
|
17
17
|
pragma capabilities
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## Working mode: assistant to a design authority
|
|
21
|
+
|
|
22
|
+
Most of the time this skill runs in collaboration with a senior designer or engineer —
|
|
23
|
+
they are the design authority, you are the assistant whose job is to make them
|
|
24
|
+
successful. Default to that mode:
|
|
25
|
+
|
|
26
|
+
- Lay out the workflow direction: say which step comes next and why, so the person
|
|
27
|
+
always knows where the flow stands.
|
|
28
|
+
- Do the legwork yourself — graph searches, ontology reads, benchmark research — and
|
|
29
|
+
bring back digestible findings, not raw dumps.
|
|
30
|
+
- Bring each decision to the person as a recommendation plus a question, never as a
|
|
31
|
+
fait accompli. They hold context the graph does not — history, intent, naming
|
|
32
|
+
precedent, roadmap — so ask the questions that draw that knowledge out, and use it.
|
|
33
|
+
|
|
34
|
+
Full autonomy is the exception, not the default: run the whole flow alone only when
|
|
35
|
+
explicitly asked to. Even then, list every judgment call made unilaterally in the
|
|
36
|
+
final report so a human can revisit them.
|
|
37
|
+
|
|
38
|
+
Decision gates — in collaboration, pause at each and resolve it WITH the person:
|
|
39
|
+
|
|
40
|
+
1. The step-1 verdict: exists/extend vs. a named gap.
|
|
41
|
+
2. The step-2 category choice (which `ds:UIBlock` subclass the entry is).
|
|
42
|
+
3. The step-3 boundary: how the definition disambiguates from its neighbors.
|
|
43
|
+
4. The step-4 adopt/reject decisions from the benchmark.
|
|
44
|
+
5. Whether the step-5 state gate fires, and the state model when it does.
|
|
45
|
+
|
|
20
46
|
## When to Use
|
|
21
47
|
|
|
22
48
|
- A component is proposed that the design system may not cover yet
|
|
@@ -193,3 +219,14 @@ Spec: specs/<tier>.<type>.<snake_name>.md
|
|
|
193
219
|
- `anatomy-author` — the step-7 engine
|
|
194
220
|
- `specify-pattern` — the same skeleton, context-first, for recurring arrangements
|
|
195
221
|
- `implement-component` — what happens after the spec is approved
|
|
222
|
+
|
|
223
|
+
## Support
|
|
224
|
+
|
|
225
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
226
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
227
|
+
stuck:
|
|
228
|
+
|
|
229
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
230
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
231
|
+
- Or contact the design-system team owners directly through your organization's
|
|
232
|
+
professional messaging channels for assistance.
|
|
@@ -21,6 +21,30 @@ In a fresh session, orient first:
|
|
|
21
21
|
pragma capabilities
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## Working mode: assistant to a design authority
|
|
25
|
+
|
|
26
|
+
Most of the time this skill runs in collaboration with a senior designer or engineer —
|
|
27
|
+
they are the design authority, you are the assistant whose job is to make them
|
|
28
|
+
successful. Default to that mode: lay out the workflow direction step by step, do the
|
|
29
|
+
legwork (graph searches, ontology reads, benchmark research) and return digestible
|
|
30
|
+
findings, and bring each decision to the person as a recommendation plus a question
|
|
31
|
+
rather than a fait accompli. They hold context the graph does not — which situations
|
|
32
|
+
actually recur across products, history, naming precedent — so ask the questions that
|
|
33
|
+
draw that knowledge out; for patterns especially, the recurring CONTEXT often lives in
|
|
34
|
+
the person's experience before it lives in any data.
|
|
35
|
+
|
|
36
|
+
Full autonomy is the exception, not the default: run the whole flow alone only when
|
|
37
|
+
explicitly asked to. Even then, list every judgment call made unilaterally in the
|
|
38
|
+
final report so a human can revisit them.
|
|
39
|
+
|
|
40
|
+
Decision gates — in collaboration, pause at each and resolve it WITH the person:
|
|
41
|
+
|
|
42
|
+
1. The step-1 verdicts: for the pattern AND for each composed component.
|
|
43
|
+
2. Whether the entry IS a pattern (a recurring arrangement, not a component or layout).
|
|
44
|
+
3. The step-3 context definition and composition rule — what is fixed, what varies.
|
|
45
|
+
4. The step-4 adopt/reject decisions from the benchmark.
|
|
46
|
+
5. The step-5 state model spanning the composed components.
|
|
47
|
+
|
|
24
48
|
## When to Use
|
|
25
49
|
|
|
26
50
|
- A recurring arrangement of components (a flow, a page region, a repeated pairing)
|
|
@@ -155,3 +179,14 @@ composed components named in step 1; the composition rule stated in step 3).
|
|
|
155
179
|
step 1 uncovers)
|
|
156
180
|
- `anatomy-author` — the step-7 engine
|
|
157
181
|
- `implement-component` — after the spec is approved
|
|
182
|
+
|
|
183
|
+
## Support
|
|
184
|
+
|
|
185
|
+
If this skill leads somewhere broken — a command that errors, guidance that
|
|
186
|
+
contradicts what the live system answers, a gap the flow cannot cover — you are not
|
|
187
|
+
stuck:
|
|
188
|
+
|
|
189
|
+
- Raise an issue in the pragma repo: https://github.com/canonical/pragma/issues —
|
|
190
|
+
include the skill name, what was run, and expected vs. actual outcome.
|
|
191
|
+
- Or contact the design-system team owners directly through your organization's
|
|
192
|
+
professional messaging channels for assistance.
|
|
@@ -43,6 +43,18 @@ describe("generateLibraryTurtle", () => {
|
|
|
43
43
|
expect(ttl).toContain("ds:libraryTier ds:global");
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
it("should strip the npm scope when slugifying package names", async () => {
|
|
47
|
+
const config: CollectConfig = {
|
|
48
|
+
...minimalConfig,
|
|
49
|
+
name: "@canonical/react-ds-global",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const ttl = await generateLibraryTurtle(config);
|
|
53
|
+
|
|
54
|
+
expect(ttl).toContain("ds:implementation.library.react-ds-global");
|
|
55
|
+
expect(ttl).not.toContain("canonical-react-ds-global");
|
|
56
|
+
});
|
|
57
|
+
|
|
46
58
|
it("should slugify library name for URI", async () => {
|
|
47
59
|
const config: CollectConfig = {
|
|
48
60
|
...minimalConfig,
|
|
@@ -186,3 +198,139 @@ describe("generateObjectsTurtle", () => {
|
|
|
186
198
|
expect(ttl).toContain('ds:headLink "src/deep/nested/Component.tsx"');
|
|
187
199
|
});
|
|
188
200
|
});
|
|
201
|
+
|
|
202
|
+
describe("generateLibraryTurtle with release version", () => {
|
|
203
|
+
const config: CollectConfig = {
|
|
204
|
+
name: "Test Library",
|
|
205
|
+
platform: "react",
|
|
206
|
+
link: "https://github.com/example/test",
|
|
207
|
+
prefix: {
|
|
208
|
+
short: "ds",
|
|
209
|
+
namespace: "https://ds.canonical.com/",
|
|
210
|
+
},
|
|
211
|
+
pattern: "src/**/*.tsx",
|
|
212
|
+
version: "0.35.0",
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
it("should emit ds:version when a release version is configured", async () => {
|
|
216
|
+
const ttl = await generateLibraryTurtle(config);
|
|
217
|
+
|
|
218
|
+
expect(ttl).toContain('ds:version "0.35.0"');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should not emit ds:version without a release version", async () => {
|
|
222
|
+
const ttl = await generateLibraryTurtle({ ...config, version: undefined });
|
|
223
|
+
|
|
224
|
+
expect(ttl).not.toContain("ds:version");
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("generateObjectsTurtle named IRIs and links", () => {
|
|
229
|
+
const config: CollectConfig = {
|
|
230
|
+
name: "React DS Global",
|
|
231
|
+
platform: "react",
|
|
232
|
+
link: "https://github.com/canonical/pragma/tree/main/packages/react/ds-global",
|
|
233
|
+
prefix: {
|
|
234
|
+
short: "ds",
|
|
235
|
+
namespace: "https://ds.canonical.com/",
|
|
236
|
+
},
|
|
237
|
+
pattern: "src/**/*.tsx",
|
|
238
|
+
repository: "https://github.com/canonical/pragma",
|
|
239
|
+
sourcePath: "packages/react/ds-global",
|
|
240
|
+
version: "0.35.0",
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const annotations: ImplementsAnnotation[] = [
|
|
244
|
+
{
|
|
245
|
+
filePath: "/base/src/lib/component/Chip/Chip.tsx",
|
|
246
|
+
blockUri: "ds:global.component.chip",
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
it("should emit named IRIs instead of blank nodes", async () => {
|
|
251
|
+
const ttl = await generateObjectsTurtle(config, annotations, "/base");
|
|
252
|
+
|
|
253
|
+
expect(ttl).toContain(
|
|
254
|
+
"ds:implementation.react-ds-global.global.component.chip",
|
|
255
|
+
);
|
|
256
|
+
expect(ttl).not.toContain("_:");
|
|
257
|
+
expect(ttl).not.toContain("[");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should link the library to the named implementation", async () => {
|
|
261
|
+
const ttl = await generateObjectsTurtle(config, annotations, "/base");
|
|
262
|
+
|
|
263
|
+
expect(ttl).toContain("ds:implementation.library.react-ds-global");
|
|
264
|
+
expect(ttl).toContain("ds:hasImplementation");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("should emit full blob URLs for headLink when repository is set", async () => {
|
|
268
|
+
const ttl = await generateObjectsTurtle(config, annotations, "/base");
|
|
269
|
+
|
|
270
|
+
expect(ttl).toContain(
|
|
271
|
+
'ds:headLink "https://github.com/canonical/pragma/blob/main/packages/react/ds-global/src/lib/component/Chip/Chip.tsx"',
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("should emit versionedLink pinned to the release tag", async () => {
|
|
276
|
+
const ttl = await generateObjectsTurtle(config, annotations, "/base");
|
|
277
|
+
|
|
278
|
+
expect(ttl).toContain(
|
|
279
|
+
'ds:versionedLink "https://github.com/canonical/pragma/blob/v0.35.0/packages/react/ds-global/src/lib/component/Chip/Chip.tsx"',
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("should not emit versionedLink without a release version", async () => {
|
|
284
|
+
const ttl = await generateObjectsTurtle(
|
|
285
|
+
{ ...config, version: undefined },
|
|
286
|
+
annotations,
|
|
287
|
+
"/base",
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
expect(ttl).not.toContain("ds:versionedLink");
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("should disambiguate duplicate block implementations with a file slug", async () => {
|
|
294
|
+
const duplicated: ImplementsAnnotation[] = [
|
|
295
|
+
{
|
|
296
|
+
filePath: "/base/src/lib/component/Chip/Chip.tsx",
|
|
297
|
+
blockUri: "ds:global.component.chip",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
filePath: "/base/src/lib/component/Chip/variants/Dense.tsx",
|
|
301
|
+
blockUri: "ds:global.component.chip",
|
|
302
|
+
},
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
const ttl = await generateObjectsTurtle(config, duplicated, "/base");
|
|
306
|
+
|
|
307
|
+
expect(ttl).toContain(
|
|
308
|
+
"ds:implementation.react-ds-global.global.component.chip a ds:ImplementationObject",
|
|
309
|
+
);
|
|
310
|
+
expect(ttl).toContain(
|
|
311
|
+
"ds:implementation.react-ds-global.global.component.chip.component-dense a ds:ImplementationObject",
|
|
312
|
+
);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("should produce deterministic output regardless of annotation order", async () => {
|
|
316
|
+
const shuffled: ImplementsAnnotation[] = [
|
|
317
|
+
{
|
|
318
|
+
filePath: "/base/src/lib/Modal.tsx",
|
|
319
|
+
blockUri: "ds:global.pattern.modal",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
filePath: "/base/src/lib/component/Chip/Chip.tsx",
|
|
323
|
+
blockUri: "ds:global.component.chip",
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
const forward = await generateObjectsTurtle(config, shuffled, "/base");
|
|
328
|
+
const reversed = await generateObjectsTurtle(
|
|
329
|
+
config,
|
|
330
|
+
[...shuffled].reverse(),
|
|
331
|
+
"/base",
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
expect(forward).toBe(reversed);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
@@ -21,6 +21,7 @@ const RESERVED_PREFIXES = new Set(["rdf", "rdfs", "xsd", "owl"]);
|
|
|
21
21
|
function slugify(name: string): string {
|
|
22
22
|
return name
|
|
23
23
|
.toLowerCase()
|
|
24
|
+
.replace(/^@[^/]+\//, "") // Remove npm scope
|
|
24
25
|
.replace(/[^a-z0-9]+/g, "-")
|
|
25
26
|
.replace(/^-|-$/g, "");
|
|
26
27
|
}
|
|
@@ -32,7 +33,7 @@ function slugify(name: string): string {
|
|
|
32
33
|
* e.g., "src/lib/Tile/common/Header/Header.tsx" -> "tile-header"
|
|
33
34
|
* e.g., "src/lib/Accordion/common/Item/Item.tsx" -> "accordion-item"
|
|
34
35
|
*/
|
|
35
|
-
function
|
|
36
|
+
function filePathSlug(filePath: string): string {
|
|
36
37
|
// Remove extension and get path parts
|
|
37
38
|
const withoutExt = filePath.replace(/\.[^.]+$/, "");
|
|
38
39
|
const parts = withoutExt.split("/").filter(Boolean);
|
|
@@ -158,12 +159,40 @@ export function generateLibraryTurtle(config: CollectConfig): Promise<string> {
|
|
|
158
159
|
);
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
if (config.version) {
|
|
163
|
+
store.addLiteral(
|
|
164
|
+
libraryUri,
|
|
165
|
+
prefixes.expand(`${p}:version`),
|
|
166
|
+
config.version,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
161
170
|
return serializeToTurtle(store, { prefixes });
|
|
162
171
|
}
|
|
163
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Build the source link for an implementation file.
|
|
175
|
+
* With a repository configured, returns a full blob URL pinned to the given
|
|
176
|
+
* ref; otherwise falls back to the repo-relative path.
|
|
177
|
+
*/
|
|
178
|
+
function buildSourceLink(
|
|
179
|
+
config: CollectConfig,
|
|
180
|
+
ref: string,
|
|
181
|
+
relativePath: string,
|
|
182
|
+
): string {
|
|
183
|
+
if (!config.repository) {
|
|
184
|
+
return relativePath;
|
|
185
|
+
}
|
|
186
|
+
const repo = config.repository.replace(/\/$/, "");
|
|
187
|
+
const prefix = config.sourcePath ? `${config.sourcePath}/` : "";
|
|
188
|
+
return `${repo}/blob/${ref}/${prefix}${relativePath}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
164
191
|
/**
|
|
165
192
|
* Generate the ImplementationObject .ttl content from annotations
|
|
166
|
-
* ImplementationObjects are
|
|
193
|
+
* ImplementationObjects are named IRIs (ds:implementation.{librarySlug}.{blockLocalName})
|
|
194
|
+
* attached to the library, so they keep a stable identity across releases
|
|
195
|
+
* when ingested into a knowledge graph.
|
|
167
196
|
*/
|
|
168
197
|
export function generateObjectsTurtle(
|
|
169
198
|
config: CollectConfig,
|
|
@@ -181,44 +210,68 @@ export function generateObjectsTurtle(
|
|
|
181
210
|
const librarySlug = slugify(config.name);
|
|
182
211
|
const libraryUri = `${config.prefix.namespace}implementation.library.${librarySlug}`;
|
|
183
212
|
|
|
184
|
-
for
|
|
213
|
+
// Sort for deterministic output so regenerated files diff cleanly
|
|
214
|
+
const sorted = [...annotations].sort((a, b) => {
|
|
215
|
+
const byBlock = a.blockUri.localeCompare(b.blockUri);
|
|
216
|
+
return byBlock !== 0 ? byBlock : a.filePath.localeCompare(b.filePath);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Track emitted IRIs so a second implementation of the same block in the
|
|
220
|
+
// same library gets a file-path discriminator instead of merging silently
|
|
221
|
+
const seen = new Set<string>();
|
|
222
|
+
|
|
223
|
+
for (const annotation of sorted) {
|
|
185
224
|
const relativePath = relative(basePath, annotation.filePath);
|
|
186
225
|
|
|
187
|
-
//
|
|
188
|
-
const
|
|
226
|
+
// Named IRI: ds:implementation.{librarySlug}.{blockLocalName}
|
|
227
|
+
const blockLocalName = annotation.blockUri.replace(/^[^:]+:/, "");
|
|
228
|
+
let implUri = `${config.prefix.namespace}implementation.${librarySlug}.${blockLocalName}`;
|
|
229
|
+
if (seen.has(implUri)) {
|
|
230
|
+
implUri = `${implUri}.${filePathSlug(relativePath)}`;
|
|
231
|
+
}
|
|
232
|
+
seen.add(implUri);
|
|
189
233
|
|
|
190
234
|
// Link library to implementation object
|
|
191
|
-
store.
|
|
235
|
+
store.addQuad(
|
|
192
236
|
libraryUri,
|
|
193
237
|
prefixes.expand(`${p}:hasImplementation`),
|
|
194
|
-
|
|
238
|
+
implUri,
|
|
195
239
|
);
|
|
196
240
|
|
|
197
241
|
// Add type
|
|
198
|
-
store.
|
|
199
|
-
|
|
242
|
+
store.addQuad(
|
|
243
|
+
implUri,
|
|
200
244
|
prefixes.expand("rdf:type"),
|
|
201
245
|
prefixes.expand(`${p}:ImplementationObject`),
|
|
202
246
|
);
|
|
203
247
|
|
|
204
248
|
// Add implements block reference
|
|
205
|
-
store.
|
|
206
|
-
|
|
249
|
+
store.addQuad(
|
|
250
|
+
implUri,
|
|
207
251
|
prefixes.expand(`${p}:implementsBlock`),
|
|
208
252
|
prefixes.expand(annotation.blockUri),
|
|
209
253
|
);
|
|
210
254
|
|
|
211
|
-
// Add head link (
|
|
212
|
-
store.
|
|
213
|
-
|
|
255
|
+
// Add head link (source file at the repository head)
|
|
256
|
+
store.addLiteral(
|
|
257
|
+
implUri,
|
|
214
258
|
prefixes.expand(`${p}:headLink`),
|
|
215
|
-
relativePath,
|
|
259
|
+
buildSourceLink(config, "main", relativePath),
|
|
216
260
|
);
|
|
217
261
|
|
|
262
|
+
// Add versioned link (source file pinned to the release tag)
|
|
263
|
+
if (config.repository && config.version) {
|
|
264
|
+
store.addLiteral(
|
|
265
|
+
implUri,
|
|
266
|
+
prefixes.expand(`${p}:versionedLink`),
|
|
267
|
+
buildSourceLink(config, `v${config.version}`, relativePath),
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
218
271
|
// Add version if specified
|
|
219
272
|
if (annotation.version) {
|
|
220
|
-
store.
|
|
221
|
-
|
|
273
|
+
store.addLiteral(
|
|
274
|
+
implUri,
|
|
222
275
|
prefixes.expand(`${p}:implementationVersion`),
|
|
223
276
|
annotation.version,
|
|
224
277
|
);
|
|
@@ -226,11 +279,7 @@ export function generateObjectsTurtle(
|
|
|
226
279
|
|
|
227
280
|
// Add draft status if true
|
|
228
281
|
if (annotation.isDraft) {
|
|
229
|
-
store.
|
|
230
|
-
implNode,
|
|
231
|
-
prefixes.expand(`${p}:isDraft`),
|
|
232
|
-
"true",
|
|
233
|
-
);
|
|
282
|
+
store.addLiteral(implUri, prefixes.expand(`${p}:isDraft`), "true");
|
|
234
283
|
}
|
|
235
284
|
}
|
|
236
285
|
|
package/src/collect/types.ts
CHANGED
|
@@ -35,6 +35,26 @@ export interface CollectConfig {
|
|
|
35
35
|
|
|
36
36
|
/** Output directory for generated .ttl files (default: "data") */
|
|
37
37
|
outputDir?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Release version of the library (e.g., "0.35.0").
|
|
41
|
+
* When set, emits ds:version on the library and enables versionedLink
|
|
42
|
+
* generation for implementation objects.
|
|
43
|
+
*/
|
|
44
|
+
version?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Base URL of the source repository (e.g., "https://github.com/canonical/pragma").
|
|
48
|
+
* When set, headLink/versionedLink are emitted as full blob URLs instead of
|
|
49
|
+
* repo-relative paths.
|
|
50
|
+
*/
|
|
51
|
+
repository?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Path of the library within the repository (e.g., "packages/react/ds-global").
|
|
55
|
+
* Prepended to file paths when building full blob URLs.
|
|
56
|
+
*/
|
|
57
|
+
sourcePath?: string;
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
/**
|