@decantr/cli 1.0.0-beta.5 → 1.0.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decantr/cli",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "Decantr CLI — search the registry, validate essence files, and access design intelligence from the terminal",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,7 +15,8 @@
15
15
  },
16
16
  "main": "dist/index.js",
17
17
  "files": [
18
- "dist"
18
+ "dist",
19
+ "src/templates"
19
20
  ],
20
21
  "publishConfig": {
21
22
  "access": "public"
@@ -0,0 +1,394 @@
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
+ ### Pages
102
+
103
+ {{PAGES_TABLE}}
104
+
105
+ ### Patterns in Use
106
+
107
+ {{PATTERNS_LIST}}
108
+
109
+ ---
110
+
111
+ ## Before Writing Code
112
+
113
+ **Always check these before generating UI code:**
114
+
115
+ ### With MCP Tools (Recommended)
116
+
117
+ If you have access to Decantr MCP tools:
118
+
119
+ 1. `decantr_read_essence` — Load the current essence
120
+ 2. `decantr_check_drift` — Verify your planned changes won't violate rules
121
+ 3. `decantr_resolve_pattern` — Get pattern details before implementing
122
+ 4. `decantr_suggest_patterns` — Find appropriate patterns for new sections
123
+
124
+ ### Without MCP Tools
125
+
126
+ 1. Read `decantr.essence.json` in the project root
127
+ 2. Verify the page you're editing exists in `structure[]`
128
+ 3. Check the page's `layout[]` for required pattern order
129
+ 4. Follow the `theme.style` and `theme.recipe` specifications
130
+ 5. Use spacing tokens from `density.content_gap`
131
+
132
+ ### Checklist
133
+
134
+ Before writing any UI code:
135
+
136
+ - [ ] Is this page in the essence structure?
137
+ - [ ] Am I using the correct theme ({{THEME_STYLE}})?
138
+ - [ ] Am I following the correct mode ({{THEME_MODE}})?
139
+ - [ ] Does my pattern order match the layout spec?
140
+ - [ ] Am I using the correct spacing tokens?
141
+
142
+ If any answer is "no" — **STOP and ask the user to update the essence.**
143
+
144
+ ---
145
+
146
+ ## After Writing Code
147
+
148
+ ### Self-Check
149
+
150
+ After generating code, verify:
151
+
152
+ 1. **Theme consistency** — All colors, typography, and effects match the theme
153
+ 2. **Pattern structure** — Components follow the pattern's layout spec
154
+ 3. **Spacing consistency** — Gap values use tokens, not arbitrary pixels
155
+ 4. **Page declaration** — The page exists in the essence structure
156
+
157
+ ### Drift Validation
158
+
159
+ Run validation to check for violations:
160
+
161
+ ```bash
162
+ decantr validate
163
+ ```
164
+
165
+ Or use the MCP tool:
166
+
167
+ ```
168
+ decantr_check_drift(page_id="{{page}}", theme_used="{{theme}}")
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Pattern Quality Rules
174
+
175
+ When implementing patterns, follow these rules:
176
+
177
+ ### 1. One Elevation
178
+
179
+ Each pattern section should have a single visual elevation level. Don't nest cards within cards or create competing visual hierarchies.
180
+
181
+ ```
182
+ // Good: Single elevation
183
+ <section class="pattern-section">
184
+ <h2>Title</h2>
185
+ <div class="content">...</div>
186
+ </section>
187
+
188
+ // Bad: Nested elevations
189
+ <Card>
190
+ <Card>...</Card>
191
+ </Card>
192
+ ```
193
+
194
+ ### 2. Containment Decision
195
+
196
+ Decide upfront whether a pattern is:
197
+ - **Contained** — Has visible boundaries (card, panel)
198
+ - **Inline** — Flows with content, no boundaries
199
+
200
+ Don't mix containment within a pattern.
201
+
202
+ ### 3. Component Consistency
203
+
204
+ Use the same component variants throughout a pattern. If buttons are `primary` style in one place, they should be `primary` everywhere in that pattern.
205
+
206
+ ---
207
+
208
+ ## Spatial Guidelines
209
+
210
+ ### Personality to Density Mapping
211
+
212
+ | Personality | Suggested Density | Content Gap |
213
+ |-------------|-------------------|-------------|
214
+ | professional | comfortable | `_gap4` |
215
+ | playful | spacious | `_gap6` |
216
+ | premium | spacious | `_gap8` |
217
+ | minimal | compact | `_gap2` |
218
+ | bold | comfortable | `_gap4` |
219
+
220
+ This project uses: **{{PERSONALITY}}** personality with **{{DENSITY}}** density.
221
+
222
+ ### The 50% Rule
223
+
224
+ Pattern content should occupy roughly 50% of its container width on desktop. This creates breathing room and prevents wall-of-text layouts.
225
+
226
+ ### Spacing Tokens
227
+
228
+ Use these tokens instead of arbitrary pixel values:
229
+
230
+ | Token | Value | Use Case |
231
+ |-------|-------|----------|
232
+ | `_gap1` | 4px | Tight spacing within components |
233
+ | `_gap2` | 8px | Compact layouts |
234
+ | `_gap3` | 12px | Default inline spacing |
235
+ | `_gap4` | 16px | Comfortable content gap |
236
+ | `_gap6` | 24px | Section spacing |
237
+ | `_gap8` | 32px | Major section breaks |
238
+ | `_gap12` | 48px | Page section spacing |
239
+
240
+ ---
241
+
242
+ ## Shells (Page Layouts)
243
+
244
+ A shell is the page-level layout container. This project uses **{{DEFAULT_SHELL}}** as the default shell.
245
+
246
+ ### Available Shells
247
+
248
+ | Shell | Description | Use Case |
249
+ |-------|-------------|----------|
250
+ | `sidebar-main` | Collapsible sidebar + main content | Dashboards, admin panels |
251
+ | `top-nav-main` | Horizontal nav + full-width content | Marketing, content sites |
252
+ | `centered` | Centered card on background | Auth flows, focused tasks |
253
+ | `full-bleed` | No persistent nav, scroll-driven | Landing pages, portfolios |
254
+ | `minimal-header` | Slim header + centered content | Checkout, wizards |
255
+ | `sidebar-aside` | Three columns (nav + main + aside) | IDE-style, email clients |
256
+
257
+ ### Shell Structure
258
+
259
+ ```
260
+ {{SHELL_STRUCTURE}}
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Task-Specific Context
266
+
267
+ For detailed instructions based on what you're doing, see:
268
+
269
+ | Task | Context File |
270
+ |------|--------------|
271
+ | Scaffolding new pages | `.decantr/context/task-scaffold.md` |
272
+ | Adding pages/features | `.decantr/context/task-add-page.md` |
273
+ | Modifying existing code | `.decantr/context/task-modify.md` |
274
+
275
+ These files contain tier-specific rules and checklists.
276
+
277
+ ---
278
+
279
+ ## Quick Reference
280
+
281
+ ### Essence Schema (Simplified)
282
+
283
+ ```json
284
+ {
285
+ "version": "2.0.0",
286
+ "theme": {
287
+ "style": "theme-id",
288
+ "mode": "dark | light | auto",
289
+ "recipe": "recipe-id",
290
+ "shape": "pill | rounded | sharp"
291
+ },
292
+ "personality": ["trait1", "trait2"],
293
+ "structure": [
294
+ {
295
+ "id": "page-id",
296
+ "shell": "shell-id",
297
+ "layout": ["pattern-1", "pattern-2"]
298
+ }
299
+ ],
300
+ "features": ["auth", "search"],
301
+ "guard": {
302
+ "enforce_style": true,
303
+ "enforce_recipe": true,
304
+ "mode": "strict | guided | creative"
305
+ },
306
+ "density": {
307
+ "level": "compact | comfortable | spacious",
308
+ "content_gap": "_gap4"
309
+ },
310
+ "target": "react | vue | svelte | html"
311
+ }
312
+ ```
313
+
314
+ ### Common Violations
315
+
316
+ | Violation | Fix |
317
+ |-----------|-----|
318
+ | "Page not in structure" | Add page to `structure[]` in essence |
319
+ | "Theme mismatch" | Use the theme from `theme.style` |
320
+ | "Pattern order wrong" | Reorder to match `layout[]` |
321
+ | "Unknown recipe" | Use recipe from `theme.recipe` |
322
+ | "Spacing inconsistent" | Use tokens from `density.content_gap` |
323
+
324
+ ### Troubleshooting
325
+
326
+ **"I need to add a new page"**
327
+ 1. Update `structure[]` in essence with the new page
328
+ 2. Specify the shell and layout patterns
329
+ 3. Then generate the code
330
+
331
+ **"I want to change the theme"**
332
+ 1. Update `theme.style` in essence
333
+ 2. Update `theme.recipe` if needed
334
+ 3. Regenerate affected components
335
+
336
+ **"The guard is blocking me"**
337
+ 1. Check which rule is being violated
338
+ 2. Update the essence to reflect the desired change
339
+ 3. Then proceed with code generation
340
+
341
+ **"I don't know which pattern to use"**
342
+ 1. Use `decantr_suggest_patterns` with a description
343
+ 2. Or check the patterns in `.decantr/cache/patterns/`
344
+ 3. Or search the registry with `decantr search <query>`
345
+
346
+ ---
347
+
348
+ ## Registry Content
349
+
350
+ This project has access to the following content:
351
+
352
+ ### Patterns
353
+ {{AVAILABLE_PATTERNS}}
354
+
355
+ ### Themes
356
+ {{AVAILABLE_THEMES}}
357
+
358
+ ### Shells
359
+ {{AVAILABLE_SHELLS}}
360
+
361
+ ---
362
+
363
+ ## Updating the Essence
364
+
365
+ When the user wants to change the design spec:
366
+
367
+ 1. Read the current `decantr.essence.json`
368
+ 2. Make the requested changes
369
+ 3. Validate with `decantr validate`
370
+ 4. Write the updated file
371
+ 5. Regenerate `DECANTR.md` if structure changed significantly
372
+
373
+ Or use the MCP tool:
374
+
375
+ ```
376
+ decantr_update_essence(operation="add_page", payload={...})
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Summary
382
+
383
+ 1. **Read the essence** before generating code
384
+ 2. **Check guard rules** before proceeding
385
+ 3. **Never violate** — update the essence instead
386
+ 4. **Use patterns** from the layout spec
387
+ 5. **Follow the theme** exactly
388
+ 6. **Validate after** generating code
389
+
390
+ The essence is the source of truth. When in doubt, consult it.
391
+
392
+ ---
393
+
394
+ *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
+ }
@@ -0,0 +1,111 @@
1
+ # Task Context: Adding Pages
2
+
3
+ **Enforcement Tier: Guided**
4
+
5
+ You are adding new pages or features to an existing Decantr project. Guard rules 1, 2, and 4 are enforced.
6
+
7
+ ---
8
+
9
+ ## Enforced Rules
10
+
11
+ | # | Rule | Enforcement | What It Means |
12
+ |---|------|-------------|---------------|
13
+ | 1 | **Style** | ENFORCED | You MUST use theme `{{THEME_STYLE}}` |
14
+ | 2 | **Structure** | ENFORCED | Page MUST exist in essence before generating code |
15
+ | 3 | Layout | advisory | Pattern order is flexible |
16
+ | 4 | **Recipe** | ENFORCED | You MUST use recipe `{{THEME_RECIPE}}` |
17
+ | 5 | Density | advisory | Spacing can vary slightly |
18
+
19
+ ## Before You Start
20
+
21
+ ### 1. Update the Essence
22
+
23
+ Before generating code for a new page, add it to the essence:
24
+
25
+ ```json
26
+ {
27
+ "structure": [
28
+ // ... existing pages ...
29
+ {
30
+ "id": "new-page-id",
31
+ "shell": "{{DEFAULT_SHELL}}",
32
+ "layout": ["pattern-1", "pattern-2"]
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ ### 2. Validate
39
+
40
+ Run validation to ensure the essence is valid:
41
+
42
+ ```bash
43
+ decantr validate
44
+ ```
45
+
46
+ ### 3. Then Generate
47
+
48
+ Only after the page exists in the essence should you generate code for it.
49
+
50
+ ## Checklist
51
+
52
+ Before adding a page:
53
+
54
+ - [ ] The page ID is added to `structure[]` in essence
55
+ - [ ] The page has a `shell` defined
56
+ - [ ] The page has a `layout[]` with pattern IDs
57
+ - [ ] Validation passes (`decantr validate`)
58
+
59
+ During code generation:
60
+
61
+ - [ ] Use theme `{{THEME_STYLE}}` for all styling
62
+ - [ ] Use recipe `{{THEME_RECIPE}}` for decorations
63
+ - [ ] Follow the shell structure ({{DEFAULT_SHELL}})
64
+ - [ ] Include patterns from the layout array
65
+
66
+ After generation:
67
+
68
+ - [ ] Run `decantr validate`
69
+ - [ ] Verify the page matches the theme
70
+ - [ ] Check that the recipe styles are applied
71
+
72
+ ## Violation Response
73
+
74
+ If the user asks you to generate a page that doesn't exist in the essence:
75
+
76
+ ```
77
+ STOP: I cannot generate code for page "{{page}}" because it's not
78
+ in the essence structure. This would violate the Structure guard rule.
79
+
80
+ Would you like me to:
81
+ 1. Add "{{page}}" to the essence first, then generate the code?
82
+ 2. Skip this page for now?
83
+
84
+ Please confirm how you'd like to proceed.
85
+ ```
86
+
87
+ **Never generate code for undefined pages.** Always update the essence first.
88
+
89
+ ## Adding Features
90
+
91
+ When adding features (auth, search, payments, etc.):
92
+
93
+ 1. Add the feature to `features[]` in the essence
94
+ 2. Update relevant pages in `structure[]`
95
+ 3. Then implement the feature
96
+
97
+ ## Pattern Selection
98
+
99
+ For new pages, suggest patterns based on page purpose:
100
+
101
+ | Page Type | Suggested Patterns |
102
+ |-----------|-------------------|
103
+ | Dashboard | `kpi-grid`, `chart-grid`, `data-table` |
104
+ | Settings | `form-sections`, `filter-bar` |
105
+ | Detail | `detail-header`, `activity-feed` |
106
+ | List | `data-table`, `filter-bar`, `card-grid` |
107
+ | Landing | `hero`, `cta-section`, `card-grid` |
108
+
109
+ ---
110
+
111
+ *Task context generated by Decantr CLI*