@lifeonlars/prime-yggdrasil 0.2.6 → 0.3.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.
@@ -0,0 +1,308 @@
1
+ # Yggdrasil AI Agents
2
+
3
+ **Quick Start for AI-Assisted Development**
4
+
5
+ This folder contains 4 specialized AI agents that guide design system usage and prevent drift.
6
+
7
+ ---
8
+
9
+ ## The 4 Agents
10
+
11
+ ### 1. Block Composer (`block-composer.md`)
12
+ **When to use:** Before implementing ANY UI feature
13
+
14
+ **Job:** Turn "I need X UI" into a composition plan using PrimeReact components and existing Blocks.
15
+
16
+ **Example prompt:**
17
+ ```
18
+ Read .ai/yggdrasil/block-composer.md
19
+
20
+ I need to implement a user profile form with:
21
+ - Avatar upload
22
+ - Name and email inputs
23
+ - Save and cancel buttons
24
+
25
+ What PrimeReact components should I use? What's the composition structure?
26
+ ```
27
+
28
+ ---
29
+
30
+ ### 2. PrimeFlex Guard (`primeflex-guard.md`)
31
+ **When to use:** When using PrimeFlex utility classes for layout
32
+
33
+ **Job:** Ensure PrimeFlex is used correctly (layout/spacing only, not design).
34
+
35
+ **Critical Rule:** Never use PrimeFlex classes on PrimeReact components (except `w-full` on inputs).
36
+
37
+ **Example prompt:**
38
+ ```
39
+ Read .ai/yggdrasil/primeflex-guard.md
40
+
41
+ Review this layout code and check for PrimeFlex violations:
42
+
43
+ <div className="flex justify-content-between bg-blue-500 p-4">
44
+ <Button className="mr-2" label="Save" />
45
+ </div>
46
+
47
+ What's wrong and how should I fix it?
48
+ ```
49
+
50
+ ---
51
+
52
+ ### 3. Semantic Token Intent (`semantic-token-intent.md`)
53
+ **When to use:** When styling any UI element (colors, borders, shadows)
54
+
55
+ **Job:** Select the right semantic tokens for ALL states (default, hover, focus, disabled, error).
56
+
57
+ **Example prompt:**
58
+ ```
59
+ Read .ai/yggdrasil/semantic-token-intent.md
60
+
61
+ I need to style a success message banner. What semantic tokens should I use for:
62
+ - Background color
63
+ - Text color
64
+ - Border color
65
+ - Icon color
66
+
67
+ Include all states (default, hover, focus).
68
+ ```
69
+
70
+ ---
71
+
72
+ ### 4. Drift Validator (`drift-validator.md`)
73
+ **When to use:** Before committing code or during code review
74
+
75
+ **Job:** Validate code against 7 design system policy rules.
76
+
77
+ **Example prompt:**
78
+ ```
79
+ Read .ai/yggdrasil/drift-validator.md
80
+
81
+ Review this component for design system violations:
82
+
83
+ function UserCard() {
84
+ return (
85
+ <div style={{ background: '#f0f0f0', padding: '20px' }}>
86
+ <button style={{ background: '#3B82F6', color: 'white' }}>
87
+ Edit
88
+ </button>
89
+ </div>
90
+ )
91
+ }
92
+
93
+ What violations exist and how should I fix them?
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Quick Reference
99
+
100
+ ### Agent Selection Guide
101
+
102
+ | **I need to...** | **Use this agent** |
103
+ |------------------|-------------------|
104
+ | Plan a new UI feature | Block Composer |
105
+ | Layout components with PrimeFlex | PrimeFlex Guard |
106
+ | Choose colors/styling | Semantic Token Intent |
107
+ | Review code for violations | Drift Validator |
108
+
109
+ ---
110
+
111
+ ## Workflow Example
112
+
113
+ ### Implementing a User List Page
114
+
115
+ **Step 1: Plan Composition (Block Composer)**
116
+ ```
117
+ Read .ai/yggdrasil/block-composer.md
118
+
119
+ I need a user list page with:
120
+ - Search bar
121
+ - Filter dropdown (by role)
122
+ - User table (name, email, role, actions)
123
+ - Pagination
124
+
125
+ What PrimeReact components and layout structure should I use?
126
+ ```
127
+
128
+ **Step 2: Layout with PrimeFlex (PrimeFlex Guard)**
129
+ ```
130
+ Read .ai/yggdrasil/primeflex-guard.md
131
+
132
+ I'm creating a filter bar with search input and dropdown.
133
+ What PrimeFlex classes can I use for layout?
134
+ ```
135
+
136
+ **Step 3: Style with Tokens (Semantic Token Intent)**
137
+ ```
138
+ Read .ai/yggdrasil/semantic-token-intent.md
139
+
140
+ What semantic tokens should I use for:
141
+ - Table header background
142
+ - Row hover state
143
+ - Delete button (danger action)
144
+ ```
145
+
146
+ **Step 4: Validate (Drift Validator)**
147
+ ```
148
+ Read .ai/yggdrasil/drift-validator.md
149
+
150
+ Review my UserList component for design system violations.
151
+ [paste code]
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Key Rules to Remember
157
+
158
+ ### ✅ DO
159
+
160
+ - **Use PrimeReact components** - Don't create custom components
161
+ - **Use PrimeFlex for layout only** - `flex`, `grid`, `p-*`, `m-*`, `gap-*`
162
+ - **Use semantic tokens for design** - `var(--text-neutral-default)`, etc.
163
+ - **Handle all 5 states** - default, loading, empty, error, disabled
164
+ - **Check for existing Blocks** - Reuse before creating new
165
+
166
+ ### ❌ DON'T
167
+
168
+ - **Don't use PrimeFlex on PrimeReact components** (except `w-full` on inputs)
169
+ - **Don't use PrimeFlex for colors/borders/shadows** - Use semantic tokens
170
+ - **Don't use Tailwind classes** - This project uses PrimeFlex
171
+ - **Don't hardcode colors** - `#333`, `rgb()`, etc. are forbidden
172
+ - **Don't create custom buttons/inputs** - Use PrimeReact components
173
+
174
+ ---
175
+
176
+ ## PrimeFlex Allowlist (Quick Reference)
177
+
178
+ **✅ Allowed (Layout & Spacing):**
179
+ - `flex`, `flex-column`, `justify-*`, `align-*`
180
+ - `grid`, `col-*`, `gap-*`
181
+ - `p-*`, `m-*` (4px grid: 0, 1, 2, 3, 4, 5, 6, 7, 8)
182
+ - `block`, `inline-block`, `hidden`
183
+ - `relative`, `absolute`, `fixed`, `sticky`
184
+ - `w-full`, `h-full`, `w-screen`, `h-screen`
185
+
186
+ **❌ Forbidden (Design):**
187
+ - `bg-*`, `text-[color]-*`, `border-[color]-*`
188
+ - `rounded-*`, `shadow-*`, `font-*`
189
+ - Any Tailwind-specific classes (`space-*`, `ring-*`, etc.)
190
+
191
+ Full policy: See `PRIMEFLEX-POLICY.md`
192
+
193
+ ---
194
+
195
+ ## Semantic Token Categories
196
+
197
+ **Surface (Backgrounds):**
198
+ - `--surface-neutral-primary` - Main background
199
+ - `--surface-brand-primary` - Brand color (buttons)
200
+ - `--surface-context-success/warning/danger/info` - Semantic states
201
+
202
+ **Text:**
203
+ - `--text-neutral-default` - Body text
204
+ - `--text-neutral-subdued` - Secondary text
205
+ - `--text-state-interactive` - Links, interactive elements
206
+ - `--text-onsurface-onbrand` - Text on brand backgrounds
207
+
208
+ **Borders:**
209
+ - `--border-neutral-default` - Standard borders
210
+ - `--border-state-focus` - Focus rings
211
+ - `--border-context-danger/success` - Semantic borders
212
+
213
+ **Spacing (4px grid):**
214
+ - `0.5rem` (8px), `1rem` (16px), `1.5rem` (24px), `2rem` (32px)
215
+
216
+ Full token catalog: See `semantic-token-intent.md`
217
+
218
+ ---
219
+
220
+ ## Common Violations
221
+
222
+ ### Violation 1: PrimeFlex on Components
223
+ ```tsx
224
+ ❌ <Button className="bg-blue-500 p-4" label="Save" />
225
+ ✅ <Button label="Save" /> {/* Theme handles styling */}
226
+ ```
227
+
228
+ ### Violation 2: Hardcoded Colors
229
+ ```tsx
230
+ ❌ <div style={{ color: '#333', background: '#f0f0f0' }}>
231
+ ✅ <div style={{
232
+ color: 'var(--text-neutral-default)',
233
+ background: 'var(--surface-neutral-secondary)'
234
+ }}>
235
+ ```
236
+
237
+ ### Violation 3: Custom Components
238
+ ```tsx
239
+ ❌ const CustomButton = ({ label }) => (
240
+ <button style={{ background: 'blue', color: 'white' }}>
241
+ {label}
242
+ </button>
243
+ )
244
+
245
+ ✅ import { Button } from 'primereact/button'
246
+ <Button label="Click me" />
247
+ ```
248
+
249
+ ### Violation 4: Tailwind Classes
250
+ ```tsx
251
+ ❌ <div className="space-x-4 ring-2 rounded-lg">
252
+ ✅ <div className="flex gap-3" style={{
253
+ borderRadius: 'var(--radius-md)',
254
+ outline: `2px solid var(--border-state-focus)`
255
+ }}>
256
+ ```
257
+
258
+ ---
259
+
260
+ ## Integration with AI Tools
261
+
262
+ ### Claude Code
263
+ Add to your prompts:
264
+ ```
265
+ Read the Yggdrasil agents in .ai/yggdrasil/ before implementing UI.
266
+ Use Block Composer for planning, PrimeFlex Guard for layout,
267
+ Semantic Token Intent for styling, and Drift Validator for review.
268
+ ```
269
+
270
+ ### Cursor
271
+ Add `.ai/yggdrasil/` to composer context, then:
272
+ ```
273
+ @Workspace Help me implement a product card following the Yggdrasil
274
+ Block Composer agent guidelines.
275
+ ```
276
+
277
+ ### GitHub Copilot
278
+ Reference in comments:
279
+ ```tsx
280
+ // Following .ai/yggdrasil/block-composer.md
281
+ // Using PrimeReact DataTable for user list
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Enforcement
287
+
288
+ This design system is enforced through:
289
+
290
+ 1. **Agents (Phase 1)** - Preventive guidance during development
291
+ 2. **ESLint Plugin (Phase 3)** - Code-time detection in IDE
292
+ 3. **CLI Validation (Phase 4)** - Pre-commit and CI/CD checks
293
+
294
+ **Current Status:** Phase 1 complete (agents available)
295
+ **Next:** Phase 3 (ESLint plugin) and Phase 4 (CLI validation)
296
+
297
+ ---
298
+
299
+ ## Support
300
+
301
+ - **Documentation:** [Prime Yggdrasil README](https://github.com/lifeonlars/prime-yggdrasil)
302
+ - **PrimeReact Docs:** https://primereact.org/
303
+ - **PrimeFlex Docs:** https://primeflex.org/
304
+ - **Issues:** https://github.com/lifeonlars/prime-yggdrasil/issues
305
+
306
+ ---
307
+
308
+ **Remember:** The agents are here to guide, not restrict. They help you build consistent, accessible UIs faster by preventing common mistakes before they happen.
@@ -0,0 +1,168 @@
1
+ # Prime Yggdrasil — UI Aesthetics & Principles
2
+
3
+ This document defines the aesthetic and interaction principles that all UI built with **Prime Yggdrasil** must follow.
4
+ It is intentionally token-agnostic: **use design tokens, not raw values**.
5
+
6
+ ## Non-negotiables
7
+
8
+ - **Typography:** Use the system font configuration provided by Prime Yggdrasil (Roboto). Do not introduce additional fonts.
9
+ - **Tokens over values:** Do not hardcode colours, spacing, radii, shadows, or typography values. Use semantic tokens.
10
+ - **No Tailwind:** Do not use Tailwind or Tailwind-like utility classes. Use **PrimeFlex** utilities and Prime Yggdrasil patterns.
11
+ - **Restraint:** Prefer neutral surfaces, clear hierarchy, and functional layout. Avoid decorative styling.
12
+
13
+ ## Visual tone
14
+
15
+ Prime Yggdrasil UIs should feel:
16
+
17
+ - clean, calm, and pragmatic
18
+ - high-clarity with low ornamentation
19
+ - confident, not flashy
20
+
21
+ Avoid:
22
+
23
+ - trendy “AI” aesthetics (generic gradients, glossy cards, noisy textures)
24
+ - excessive colour accents
25
+ - “card soup” (too many bordered containers competing for attention)
26
+
27
+ ## Typography & hierarchy
28
+
29
+ - Express hierarchy through **size, weight, spacing, and layout** — not decoration.
30
+ - Use a small number of purposeful scale steps (e.g., body → section heading → page heading).
31
+ - Keep line lengths readable. Use whitespace and grouping to reduce cognitive load.
32
+
33
+ ## Layout & spacing
34
+
35
+ - Follow a **4px grid** (spacing rhythm must be consistent and token-based).
36
+ - Prefer clear grouping: headings + sections + consistent internal spacing.
37
+ - Default to simple layouts (Stack/Inline/Grid). Avoid over-nesting containers.
38
+
39
+ ### Default spacing rhythm (guideline)
40
+
41
+ - Major section separation: “regular” to “relaxed”
42
+ - Inside groups: “tight” to “regular”
43
+ (Exact steps are defined by tokens.)
44
+
45
+ ## Surfaces, borders, and elevation
46
+
47
+ - Prefer neutral surfaces by default.
48
+ - Use borders to delineate structure; avoid heavy elevation unless it improves clarity.
49
+ - Keep radii restrained and modern; use tokenised radii only.
50
+
51
+ ## Colour & emphasis
52
+
53
+ - Colour is for **meaning and hierarchy**, not decoration.
54
+ - Use **context/semantic colours** only for status (success/warning/danger/info) and feedback.
55
+ - Limit brand/accent colour to primary actions or key emphasis.
56
+
57
+ ## Motion & interaction
58
+
59
+ - Motion should be subtle and purposeful: feedback, state change, continuity.
60
+ - Prefer simple opacity/transform transitions.
61
+ - Avoid bouncy or attention-grabbing animations.
62
+
63
+ ## Principle checklist (use before shipping)
64
+
65
+ 1. **Purposeful simplicity** — remove anything that doesn’t improve understanding.
66
+ 2. **Clear progression** — users should know what they can do next.
67
+ 3. **Consistent patterns** — reuse Prime Yggdrasil components and Blocks.
68
+ 4. **Visible states** — hover/focus/pressed/loading/disabled are all intentional.
69
+ 5. **System thinking** — design choices must scale across screens and themes.
70
+
71
+ ## If you're unsure, use the default recipe
72
+
73
+ - Neutral surface + clear section headers
74
+ - One primary action per view
75
+ - Tokenised spacing with consistent rhythm
76
+ - Tokenised borders for separation, minimal elevation
77
+ - Complete state coverage (hover/focus/disabled/loading/empty/error)
78
+
79
+ ---
80
+
81
+ ## Agent integration
82
+
83
+ **This document is a mandatory reference for all Yggdrasil AI agents.**
84
+
85
+ Agents must ensure all guidance, validation, and generated code consistently follows these aesthetics.
86
+
87
+ ### Agent responsibilities
88
+
89
+ **Block Composer** — Suggest compositions that embody purposeful simplicity. Don't over-engineer. Ensure all 5 states specified (default, hover, focus, active, disabled).
90
+
91
+ **PrimeFlex Guard** — Enforce layout-only PrimeFlex usage. Block design utilities (colors, borders, shadows). Maintain 4px grid discipline.
92
+
93
+ **Semantic Token Intent** — Ensure state completeness. Validate token pairings work in light/dark modes. Prevent hardcoded values.
94
+
95
+ **Drift Validator** — Detect violations of architectural rules. Flag custom components that duplicate PrimeReact. Validate token-first approach.
96
+
97
+ **Interaction Patterns** *(future)* — Enforce state visibility. Standardize empty/loading/error patterns. Specify keyboard + focus behavior. Ensure copy is clear and pragmatic.
98
+
99
+ **Accessibility** *(future)* — Validate WCAG 2.1 AA compliance. Check contrast ratios. Ensure color is not the only cue. Verify keyboard navigation.
100
+
101
+ ### Quick reference for agents
102
+
103
+ **Before suggesting UI:**
104
+ - Can this use existing PrimeReact components?
105
+ - Can this reuse an existing Block?
106
+ - Does layout use PrimeFlex (layout/spacing only)?
107
+ - Does design use semantic tokens only?
108
+ - Are all states defined (5+ minimum)?
109
+ - Does it work in both light and dark modes?
110
+ - Is keyboard navigation considered?
111
+ - Is focus visibility specified?
112
+
113
+ **Before validating code:**
114
+ - Check for hardcoded colors (hex, rgb, named)
115
+ - Check for PrimeFlex on PrimeReact components
116
+ - Check for PrimeFlex design utilities (bg-*, text-*, rounded-*, shadow-*)
117
+ - Check for off-grid spacing (not 4px increments)
118
+ - Check for foundation tokens in app code (var(--blue-500))
119
+ - Check for custom components duplicating PrimeReact
120
+ - Check for missing states (no hover, no focus, no disabled)
121
+ - Check for Tailwind classes
122
+
123
+ **PrimeFlex allowlist (layout & spacing only):**
124
+ - Flexbox: `flex`, `flex-column`, `justify-*`, `align-*`
125
+ - Grid: `grid`, `col-*`, `gap-*`
126
+ - Spacing: `p-*`, `m-*` (4px grid: 0-8)
127
+ - Display: `block`, `inline-block`, `hidden`
128
+ - Positioning: `relative`, `absolute`, `fixed`, `sticky`
129
+
130
+ **PrimeFlex forbidden (design):**
131
+ - Colors: `bg-*`, `text-[color]-*`, `border-[color]-*`
132
+ - Borders: `rounded-*`, `border-*`
133
+ - Shadows: `shadow-*` (use semantic tokens instead)
134
+ - Typography: `font-*`, `text-[size]-*`
135
+
136
+ **Critical rule:** NO PrimeFlex on PrimeReact components (exception: `w-full` on form inputs)
137
+
138
+ ### Copy & content tone
139
+
140
+ Voice: Clear, pragmatic, non-fluffy
141
+ - Concise — fewest words possible
142
+ - Functional — describe what it does
143
+ - Neutral — avoid marketing speak
144
+ - Action-oriented — use verbs, be direct
145
+
146
+ Examples:
147
+ - ❌ "Oops! Something went wrong 😅" → ✅ "Unable to save. Try again."
148
+ - ❌ "Let's get started!" → ✅ "Create your first project"
149
+ - ❌ "You're all set! 🎉" → ✅ "Settings saved"
150
+
151
+ Button labels: Specific actions ("Save Changes", "Delete Item"), not generic ("OK", "Submit")
152
+
153
+ ### Accessibility requirements
154
+
155
+ **Minimum: WCAG 2.1 AA**
156
+ - Text contrast: 4.5:1 (normal), 3:1 (large ≥18pt)
157
+ - Keyboard navigation for all interactive elements
158
+ - Visible focus indicators on ALL interactive elements
159
+ - Never use color as only cue (add icons, text, patterns)
160
+ - Meaningful labels for all form inputs
161
+ - ARIA labels for icon-only buttons
162
+
163
+ **PrimeReact components handle most accessibility patterns — always verify keyboard navigation works.**
164
+
165
+ ---
166
+
167
+ **Status:** Mandatory reference for all agents
168
+ **Last updated:** 2026-01-10