@decantr/cli 1.0.0-beta.7 → 1.0.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,533 @@
1
+ # DECANTR.md
2
+
3
+ This project uses **Decantr** for design intelligence. Read this file before generating any UI code.
4
+
5
+ ---
6
+
7
+ ## What is Decantr?
8
+
9
+ Decantr is a design intelligence layer that sits between you (the AI code generator) and the code you produce. It provides:
10
+
11
+ - **Structured schemas** — The `decantr.essence.json` file is the source of truth for this project's design
12
+ - **Reusable building blocks** — Patterns, archetypes, blueprints, and themes from the registry
13
+ - **Drift prevention** — Guard rules that validate your code against the spec
14
+ - **Design methodology** — The 7-stage Design Pipeline
15
+
16
+ **Decantr does NOT generate code.** You generate the code. Decantr ensures it remains coherent and consistent.
17
+
18
+ ### Why Drift Matters
19
+
20
+ Design drift is the gradual divergence between intended design and actual implementation. It happens when:
21
+
22
+ - Themes are switched "just this once" without updating the spec
23
+ - New pages are added without declaring them in the structure
24
+ - Layout order is changed because "it looks better this way"
25
+ - Spacing values are tweaked ad-hoc instead of following the density profile
26
+
27
+ Drift compounds. Small violations accumulate into a codebase where every page looks different, spacing is inconsistent, and the original design intent is lost. Decantr prevents this by making the design spec explicit and enforced.
28
+
29
+ ---
30
+
31
+ ## The Design Pipeline
32
+
33
+ Every design decision follows these seven stages:
34
+
35
+ | Stage | Name | What Happens |
36
+ |-------|------|--------------|
37
+ | 1 | **Intent** | User describes what they want to build |
38
+ | 2 | **Interpret** | Parse intent into structured form |
39
+ | 3 | **Decompose** | Split into theme, structure, features |
40
+ | 4 | **Specify** | Write `decantr.essence.json` |
41
+ | 5 | **Compose** | Resolve layouts from patterns and recipes |
42
+ | 6 | **Generate** | You generate code from the composition |
43
+ | 7 | **Guard** | Validate every change against the spec |
44
+
45
+ The essence file captures stages 1-5. Your code generation is stage 6. The guard rules enforce stage 7.
46
+
47
+ ---
48
+
49
+ ## Guard Rules
50
+
51
+ The guard system enforces five rules. **These are non-negotiable.**
52
+
53
+ | # | Rule | What It Checks | Severity |
54
+ |---|------|----------------|----------|
55
+ | 1 | **Style** | Code uses theme specified in essence | Error |
56
+ | 2 | **Structure** | Page exists in essence structure | Error |
57
+ | 3 | **Layout** | Pattern order matches essence layout | Error (strict only) |
58
+ | 4 | **Recipe** | Decorations match essence recipe | Error |
59
+ | 5 | **Density** | Spacing follows density profile | Warning (strict only) |
60
+
61
+ ### Enforcement Tiers
62
+
63
+ | Tier | When Used | Rules Enforced |
64
+ |------|-----------|----------------|
65
+ | **Creative** | New project scaffolding | Advisory only |
66
+ | **Guided** | Adding pages or features | Rules 1, 2, 4 |
67
+ | **Strict** | Modifying existing code | All 5 rules |
68
+
69
+ This project uses **{{GUARD_MODE}}** mode.
70
+
71
+ ### Violation Response Protocol
72
+
73
+ When a user request would violate guard rules:
74
+
75
+ ```
76
+ 1. STOP — Do not proceed with code that violates guard rules
77
+ 2. EXPLAIN — Tell the user which rule would be violated and why
78
+ 3. OFFER — Ask if they want to update the essence
79
+ 4. WAIT — Only proceed after the essence is updated
80
+ ```
81
+
82
+ **Never make "just this once" exceptions.** If the user insists, update the essence first.
83
+
84
+ ---
85
+
86
+ ## This Project
87
+
88
+ {{PROJECT_SUMMARY}}
89
+
90
+ ### Essence Overview
91
+
92
+ ```json
93
+ {
94
+ "theme": "{{THEME_STYLE}}",
95
+ "mode": "{{THEME_MODE}}",
96
+ "guard": "{{GUARD_MODE}}",
97
+ "target": "{{TARGET}}"
98
+ }
99
+ ```
100
+
101
+ ### Theme Quick Reference
102
+
103
+ {{THEME_QUICK_REFERENCE}}
104
+
105
+ **To fetch complete theme and recipe specs:**
106
+ ```bash
107
+ npx @decantr/cli get theme {{THEME_STYLE}}
108
+ npx @decantr/cli get recipe {{THEME_RECIPE}}
109
+ ```
110
+
111
+ {{ACCESSIBILITY_SECTION}}
112
+
113
+ {{SEO_SECTION}}
114
+
115
+ ### Pages
116
+
117
+ {{PAGES_TABLE}}
118
+
119
+ ### Patterns in Use
120
+
121
+ {{PATTERNS_LIST}}
122
+
123
+ ---
124
+
125
+ ## Before Writing Code
126
+
127
+ **Always check these before generating UI code:**
128
+
129
+ ### Quick Commands
130
+
131
+ ```bash
132
+ # Get full theme spec (colors, palette, modes)
133
+ npx @decantr/cli get theme {{THEME_STYLE}}
134
+
135
+ # Get recipe decorators and effects
136
+ npx @decantr/cli get recipe {{THEME_RECIPE}}
137
+
138
+ # Get pattern structure and presets
139
+ npx @decantr/cli get pattern <pattern-name>
140
+
141
+ # Search for patterns
142
+ npx @decantr/cli search <query>
143
+ ```
144
+
145
+ ### With MCP Tools (If Available)
146
+
147
+ > Note: MCP tools require the `@decantr/mcp-server` to be configured. If these tools are not available, use the CLI commands above.
148
+
149
+ 1. `decantr_read_essence` — Load the current essence
150
+ 2. `decantr_check_drift` — Verify your planned changes won't violate rules
151
+ 3. `decantr_resolve_pattern` — Get pattern details before implementing
152
+ 4. `decantr_suggest_patterns` — Find appropriate patterns for new sections
153
+
154
+ ### Without MCP Tools or CLI
155
+
156
+ 1. Read `decantr.essence.json` in the project root
157
+ 2. Verify the page you're editing exists in `structure[]`
158
+ 3. Check the page's `layout[]` for required pattern order
159
+ 4. Follow the `theme.style` and `theme.recipe` specifications
160
+ 5. Use spacing tokens from `density.content_gap`
161
+
162
+ ### Checklist
163
+
164
+ Before writing any UI code:
165
+
166
+ - [ ] Is this page in the essence structure?
167
+ - [ ] Am I using the correct theme ({{THEME_STYLE}})?
168
+ - [ ] Am I following the correct mode ({{THEME_MODE}})?
169
+ - [ ] Does my pattern order match the layout spec?
170
+ - [ ] Am I using the correct spacing tokens?
171
+
172
+ If any answer is "no" — **STOP and ask the user to update the essence.**
173
+
174
+ ---
175
+
176
+ ## After Writing Code
177
+
178
+ ### Self-Check
179
+
180
+ After generating code, verify:
181
+
182
+ 1. **Theme consistency** — All colors, typography, and effects match the theme
183
+ 2. **Pattern structure** — Components follow the pattern's layout spec
184
+ 3. **Spacing consistency** — Gap values use tokens, not arbitrary pixels
185
+ 4. **Page declaration** — The page exists in the essence structure
186
+
187
+ ### Drift Validation
188
+
189
+ Run validation to check for violations:
190
+
191
+ ```bash
192
+ npx @decantr/cli validate
193
+ ```
194
+
195
+ Or use the MCP tool:
196
+
197
+ ```
198
+ decantr_check_drift(page_id="{{page}}", theme_used="{{theme}}")
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Pattern Quality Rules
204
+
205
+ When implementing patterns, follow these rules:
206
+
207
+ ### 1. One Elevation
208
+
209
+ Each pattern section should have a single visual elevation level. Don't nest cards within cards or create competing visual hierarchies.
210
+
211
+ ```
212
+ // Good: Single elevation
213
+ <section class="pattern-section">
214
+ <h2>Title</h2>
215
+ <div class="content">...</div>
216
+ </section>
217
+
218
+ // Bad: Nested elevations
219
+ <Card>
220
+ <Card>...</Card>
221
+ </Card>
222
+ ```
223
+
224
+ ### 2. Containment Decision
225
+
226
+ Decide upfront whether a pattern is:
227
+ - **Contained** — Has visible boundaries (card, panel)
228
+ - **Inline** — Flows with content, no boundaries
229
+
230
+ Don't mix containment within a pattern.
231
+
232
+ ### 3. Component Consistency
233
+
234
+ Use the same component variants throughout a pattern. If buttons are `primary` style in one place, they should be `primary` everywhere in that pattern.
235
+
236
+ ---
237
+
238
+ ## CSS Implementation
239
+
240
+ ### HTML Setup
241
+
242
+ Your `index.html` MUST have theme and mode attributes:
243
+
244
+ ```html
245
+ <!DOCTYPE html>
246
+ <html lang="en" data-theme="{{THEME_STYLE}}" data-mode="{{THEME_MODE}}">
247
+ <head>
248
+ <meta name="color-scheme" content="{{THEME_MODE}}">
249
+ ...
250
+ </head>
251
+ </html>
252
+ ```
253
+
254
+ **Why this matters:**
255
+ - `data-theme` enables theme switching via JS without reloading CSS
256
+ - `data-mode` enables light/dark toggle
257
+ - `color-scheme` tells the browser to style native controls (scrollbars, inputs) correctly
258
+
259
+ ### CSS Layer Structure
260
+
261
+ Use `@layer` for proper cascade control:
262
+
263
+ ```css
264
+ @layer decantr.reset, decantr.tokens, decantr.decorators, decantr.patterns, decantr.utilities, app;
265
+
266
+ @layer decantr.reset {
267
+ *, *::before, *::after { box-sizing: border-box; }
268
+ body { margin: 0; }
269
+ }
270
+
271
+ @layer decantr.tokens {
272
+ /* Base spacing (theme-agnostic) */
273
+ :root {
274
+ --gap1: 4px;
275
+ --gap2: 8px;
276
+ --gap3: 12px;
277
+ --gap4: 16px;
278
+ --gap6: 24px;
279
+ --gap8: 32px;
280
+ --gap12: 48px;
281
+ }
282
+
283
+ /* Theme-specific tokens */
284
+ html[data-theme="{{THEME_STYLE}}"] {
285
+ color-scheme: {{THEME_MODE}};
286
+
287
+ /* Seed colors from theme */
288
+ --d-primary: /* from theme.seed.primary */;
289
+ --d-secondary: /* from theme.seed.secondary */;
290
+ --d-accent: /* from theme.seed.accent */;
291
+ --d-bg: /* from theme.seed.background */;
292
+
293
+ /* Surface stack */
294
+ --d-surface: rgba(255, 255, 255, 0.03);
295
+ --d-surface-raised: rgba(255, 255, 255, 0.06);
296
+ --d-border: rgba(255, 255, 255, 0.1);
297
+
298
+ /* Text hierarchy */
299
+ --d-text: #FFFFFF;
300
+ --d-text-secondary: rgba(255, 255, 255, 0.7);
301
+ --d-text-muted: rgba(255, 255, 255, 0.4);
302
+ }
303
+ }
304
+
305
+ @layer decantr.decorators {
306
+ /* Recipe-specific classes from {{THEME_RECIPE}} */
307
+ }
308
+
309
+ @layer decantr.patterns {
310
+ .pattern-hero { }
311
+ .pattern-kpi-grid { }
312
+ }
313
+
314
+ @layer app {
315
+ /* Your application overrides */
316
+ }
317
+ ```
318
+
319
+ ### Variable Naming Convention
320
+
321
+ | Prefix | Purpose | Example |
322
+ |--------|---------|---------|
323
+ | `--d-` | Core Decantr tokens | `--d-primary`, `--d-bg` |
324
+ | `--{recipe}-` | Recipe-specific | `--lum-orb-opacity` |
325
+ | `--gap{N}` | Spacing tokens | `--gap4`, `--gap8` |
326
+
327
+ ### Theme Switching (JavaScript)
328
+
329
+ ```javascript
330
+ // Switch theme
331
+ document.documentElement.dataset.theme = 'newTheme';
332
+
333
+ // Switch mode
334
+ document.documentElement.dataset.mode = 'light';
335
+ document.querySelector('meta[name="color-scheme"]').content = 'light';
336
+ ```
337
+
338
+ ### Get Full Theme/Recipe Specs
339
+
340
+ ```bash
341
+ npx @decantr/cli get theme {{THEME_STYLE}} # See seed colors, palette
342
+ npx @decantr/cli get recipe {{THEME_RECIPE}} # See decorators, effects
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Spatial Guidelines
348
+
349
+ ### Personality to Density Mapping
350
+
351
+ | Personality | Suggested Density | Content Gap |
352
+ |-------------|-------------------|-------------|
353
+ | professional | comfortable | `_gap4` |
354
+ | playful | spacious | `_gap6` |
355
+ | premium | spacious | `_gap8` |
356
+ | minimal | compact | `_gap2` |
357
+ | bold | comfortable | `_gap4` |
358
+
359
+ This project uses: **{{PERSONALITY}}** personality with **{{DENSITY}}** density.
360
+
361
+ ### The 50% Rule
362
+
363
+ Pattern content should occupy roughly 50% of its container width on desktop. This creates breathing room and prevents wall-of-text layouts.
364
+
365
+ ### Spacing Tokens
366
+
367
+ Use these tokens instead of arbitrary pixel values:
368
+
369
+ | Token | Value | Use Case |
370
+ |-------|-------|----------|
371
+ | `_gap1` | 4px | Tight spacing within components |
372
+ | `_gap2` | 8px | Compact layouts |
373
+ | `_gap3` | 12px | Default inline spacing |
374
+ | `_gap4` | 16px | Comfortable content gap |
375
+ | `_gap6` | 24px | Section spacing |
376
+ | `_gap8` | 32px | Major section breaks |
377
+ | `_gap12` | 48px | Page section spacing |
378
+
379
+ ---
380
+
381
+ ## Shells (Page Layouts)
382
+
383
+ A shell is the page-level layout container. This project uses **{{DEFAULT_SHELL}}** as the default shell.
384
+
385
+ ### Available Shells
386
+
387
+ | Shell | Description | Use Case |
388
+ |-------|-------------|----------|
389
+ | `sidebar-main` | Collapsible sidebar + main content | Dashboards, admin panels |
390
+ | `top-nav-main` | Horizontal nav + full-width content | Marketing, content sites |
391
+ | `centered` | Centered card on background | Auth flows, focused tasks |
392
+ | `full-bleed` | No persistent nav, scroll-driven | Landing pages, portfolios |
393
+ | `minimal-header` | Slim header + centered content | Checkout, wizards |
394
+ | `sidebar-aside` | Three columns (nav + main + aside) | IDE-style, email clients |
395
+
396
+ ### Shell Structure
397
+
398
+ ```
399
+ {{SHELL_STRUCTURE}}
400
+ ```
401
+
402
+ ---
403
+
404
+ ## Task-Specific Context
405
+
406
+ For detailed instructions based on what you're doing, see:
407
+
408
+ | Task | Context File |
409
+ |------|--------------|
410
+ | Scaffolding new pages | `.decantr/context/task-scaffold.md` |
411
+ | Adding pages/features | `.decantr/context/task-add-page.md` |
412
+ | Modifying existing code | `.decantr/context/task-modify.md` |
413
+
414
+ These files contain tier-specific rules and checklists.
415
+
416
+ ---
417
+
418
+ ## Quick Reference
419
+
420
+ ### Essence Schema (Simplified)
421
+
422
+ ```json
423
+ {
424
+ "version": "2.0.0",
425
+ "theme": {
426
+ "style": "theme-id",
427
+ "mode": "dark | light | auto",
428
+ "recipe": "recipe-id",
429
+ "shape": "pill | rounded | sharp"
430
+ },
431
+ "personality": ["trait1", "trait2"],
432
+ "structure": [
433
+ {
434
+ "id": "page-id",
435
+ "shell": "shell-id",
436
+ "layout": ["pattern-1", "pattern-2"]
437
+ }
438
+ ],
439
+ "features": ["auth", "search"],
440
+ "guard": {
441
+ "enforce_style": true,
442
+ "enforce_recipe": true,
443
+ "mode": "strict | guided | creative"
444
+ },
445
+ "density": {
446
+ "level": "compact | comfortable | spacious",
447
+ "content_gap": "_gap4"
448
+ },
449
+ "target": "react | vue | svelte | html"
450
+ }
451
+ ```
452
+
453
+ ### Common Violations
454
+
455
+ | Violation | Fix |
456
+ |-----------|-----|
457
+ | "Page not in structure" | Add page to `structure[]` in essence |
458
+ | "Theme mismatch" | Use the theme from `theme.style` |
459
+ | "Pattern order wrong" | Reorder to match `layout[]` |
460
+ | "Unknown recipe" | Use recipe from `theme.recipe` |
461
+ | "Spacing inconsistent" | Use tokens from `density.content_gap` |
462
+
463
+ ### Troubleshooting
464
+
465
+ **"I need to add a new page"**
466
+ 1. Update `structure[]` in essence with the new page
467
+ 2. Specify the shell and layout patterns
468
+ 3. Then generate the code
469
+
470
+ **"I want to change the theme"**
471
+ 1. Update `theme.style` in essence
472
+ 2. Update `theme.recipe` if needed
473
+ 3. Regenerate affected components
474
+
475
+ **"The guard is blocking me"**
476
+ 1. Check which rule is being violated
477
+ 2. Update the essence to reflect the desired change
478
+ 3. Then proceed with code generation
479
+
480
+ **"I don't know which pattern to use"**
481
+ 1. Use `decantr_suggest_patterns` with a description
482
+ 2. Or check the patterns in `.decantr/cache/patterns/`
483
+ 3. Or search the registry with `npx @decantr/cli search <query>`
484
+
485
+ ---
486
+
487
+ ## Registry Content
488
+
489
+ This project has access to the following content:
490
+
491
+ ### Patterns
492
+ {{AVAILABLE_PATTERNS}}
493
+
494
+ ### Themes
495
+ {{AVAILABLE_THEMES}}
496
+
497
+ ### Shells
498
+ {{AVAILABLE_SHELLS}}
499
+
500
+ ---
501
+
502
+ ## Updating the Essence
503
+
504
+ When the user wants to change the design spec:
505
+
506
+ 1. Read the current `decantr.essence.json`
507
+ 2. Make the requested changes
508
+ 3. Validate with `npx @decantr/cli validate`
509
+ 4. Write the updated file
510
+ 5. Regenerate `DECANTR.md` if structure changed significantly
511
+
512
+ Or use the MCP tool:
513
+
514
+ ```
515
+ decantr_update_essence(operation="add_page", payload={...})
516
+ ```
517
+
518
+ ---
519
+
520
+ ## Summary
521
+
522
+ 1. **Read the essence** before generating code
523
+ 2. **Check guard rules** before proceeding
524
+ 3. **Never violate** — update the essence instead
525
+ 4. **Use patterns** from the layout spec
526
+ 5. **Follow the theme** exactly
527
+ 6. **Validate after** generating code
528
+
529
+ The essence is the source of truth. When in doubt, consult it.
530
+
531
+ ---
532
+
533
+ *Generated by Decantr CLI v{{VERSION}}*
@@ -0,0 +1,50 @@
1
+ # Essence Summary
2
+
3
+ Auto-generated summary of `decantr.essence.json`.
4
+
5
+ ---
6
+
7
+ ## Project Identity
8
+
9
+ | Property | Value |
10
+ |----------|-------|
11
+ | Archetype | {{ARCHETYPE}} |
12
+ | Blueprint | {{BLUEPRINT}} |
13
+ | Personality | {{PERSONALITY}} |
14
+ | Target | {{TARGET}} |
15
+
16
+ ## Visual Identity
17
+
18
+ | Property | Value |
19
+ |----------|-------|
20
+ | Theme | {{THEME_STYLE}} |
21
+ | Mode | {{THEME_MODE}} |
22
+ | Recipe | {{THEME_RECIPE}} |
23
+ | Shape | {{SHAPE}} |
24
+
25
+ ## Structure
26
+
27
+ {{PAGES_TABLE}}
28
+
29
+ ## Features
30
+
31
+ {{FEATURES_LIST}}
32
+
33
+ ## Guard Configuration
34
+
35
+ | Property | Value |
36
+ |----------|-------|
37
+ | Mode | {{GUARD_MODE}} |
38
+ | Enforce Style | {{ENFORCE_STYLE}} |
39
+ | Enforce Recipe | {{ENFORCE_RECIPE}} |
40
+
41
+ ## Density
42
+
43
+ | Property | Value |
44
+ |----------|-------|
45
+ | Level | {{DENSITY}} |
46
+ | Content Gap | {{CONTENT_GAP}} |
47
+
48
+ ---
49
+
50
+ *Last updated: {{LAST_UPDATED}}*
@@ -0,0 +1,30 @@
1
+ {
2
+ "detected": {
3
+ "framework": "{{FRAMEWORK}}",
4
+ "version": "{{FRAMEWORK_VERSION}}",
5
+ "packageManager": "{{PACKAGE_MANAGER}}",
6
+ "hasTypeScript": {{HAS_TYPESCRIPT}},
7
+ "hasTailwind": {{HAS_TAILWIND}},
8
+ "existingRuleFiles": {{EXISTING_RULE_FILES}}
9
+ },
10
+ "overrides": {
11
+ "framework": {{FRAMEWORK_OVERRIDE}}
12
+ },
13
+ "sync": {
14
+ "status": "{{SYNC_STATUS}}",
15
+ "lastSync": "{{LAST_SYNC}}",
16
+ "registrySource": "{{REGISTRY_SOURCE}}",
17
+ "cachedContent": {
18
+ "archetypes": {{CACHED_ARCHETYPES}},
19
+ "patterns": {{CACHED_PATTERNS}},
20
+ "themes": {{CACHED_THEMES}},
21
+ "recipes": {{CACHED_RECIPES}}
22
+ }
23
+ },
24
+ "initialized": {
25
+ "at": "{{INIT_AT}}",
26
+ "via": "{{INIT_VIA}}",
27
+ "version": "{{CLI_VERSION}}",
28
+ "flags": "{{INIT_FLAGS}}"
29
+ }
30
+ }