@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/dist/index.js +1111 -157
- package/package.json +3 -2
- package/src/templates/DECANTR.md.template +394 -0
- package/src/templates/essence-summary.md.template +50 -0
- package/src/templates/project.json.template +30 -0
- package/src/templates/task-add-page.md.template +111 -0
- package/src/templates/task-modify.md.template +171 -0
- package/src/templates/task-scaffold.md.template +65 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Task Context: Modifying Code
|
|
2
|
+
|
|
3
|
+
**Enforcement Tier: Strict**
|
|
4
|
+
|
|
5
|
+
You are modifying existing code in a Decantr project. ALL 5 guard rules are enforced exactly.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Enforced Rules
|
|
10
|
+
|
|
11
|
+
| # | Rule | Enforcement | Consequence of Violation |
|
|
12
|
+
|---|------|-------------|--------------------------|
|
|
13
|
+
| 1 | **Style** | STRICT | ERROR — Code rejected |
|
|
14
|
+
| 2 | **Structure** | STRICT | ERROR — Code rejected |
|
|
15
|
+
| 3 | **Layout** | STRICT | ERROR — Pattern order must match exactly |
|
|
16
|
+
| 4 | **Recipe** | STRICT | ERROR — Code rejected |
|
|
17
|
+
| 5 | **Density** | STRICT | WARNING — Flagged for review |
|
|
18
|
+
|
|
19
|
+
## Violation Response Protocol
|
|
20
|
+
|
|
21
|
+
When ANY rule would be violated:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
1. STOP — Do not generate code that violates rules
|
|
25
|
+
2. EXPLAIN — State which rule and why
|
|
26
|
+
3. OFFER — Propose updating the essence
|
|
27
|
+
4. WAIT — Only proceed after essence is updated
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Example Responses
|
|
31
|
+
|
|
32
|
+
**Theme violation:**
|
|
33
|
+
```
|
|
34
|
+
STOP: I cannot use theme "glassmorphism" because the essence specifies
|
|
35
|
+
"{{THEME_STYLE}}". This would violate the Style guard rule.
|
|
36
|
+
|
|
37
|
+
Would you like me to:
|
|
38
|
+
1. Update the essence to use "glassmorphism" instead?
|
|
39
|
+
2. Keep the current theme "{{THEME_STYLE}}"?
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Layout violation:**
|
|
43
|
+
```
|
|
44
|
+
STOP: I cannot reorder the patterns to [chart-grid, kpi-grid] because
|
|
45
|
+
the essence specifies [kpi-grid, chart-grid] for this page.
|
|
46
|
+
This would violate the Layout guard rule.
|
|
47
|
+
|
|
48
|
+
Would you like me to:
|
|
49
|
+
1. Update the essence with the new pattern order?
|
|
50
|
+
2. Keep the original order [kpi-grid, chart-grid]?
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Never say "just this once."** The essence is the source of truth.
|
|
54
|
+
|
|
55
|
+
## Before Modifying
|
|
56
|
+
|
|
57
|
+
### 1. Read Current State
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Read the essence
|
|
61
|
+
cat decantr.essence.json
|
|
62
|
+
|
|
63
|
+
# Or use MCP
|
|
64
|
+
decantr_read_essence()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Check Constraints
|
|
68
|
+
|
|
69
|
+
For the page you're modifying, verify:
|
|
70
|
+
|
|
71
|
+
- Page ID exists in `structure[]`
|
|
72
|
+
- Shell matches the page's `shell` property
|
|
73
|
+
- Patterns match the page's `layout[]` in order
|
|
74
|
+
- Theme matches `theme.style`
|
|
75
|
+
- Recipe matches `theme.recipe`
|
|
76
|
+
|
|
77
|
+
### 3. Plan Changes
|
|
78
|
+
|
|
79
|
+
Before writing code:
|
|
80
|
+
|
|
81
|
+
1. List what changes are needed
|
|
82
|
+
2. Check each change against guard rules
|
|
83
|
+
3. If any would violate, STOP and propose essence updates
|
|
84
|
+
4. Only proceed when all changes are compliant
|
|
85
|
+
|
|
86
|
+
## Checklist
|
|
87
|
+
|
|
88
|
+
Before modifying:
|
|
89
|
+
|
|
90
|
+
- [ ] Page exists in essence structure
|
|
91
|
+
- [ ] I know the exact layout order: `{{LAYOUT}}`
|
|
92
|
+
- [ ] I will use theme: `{{THEME_STYLE}}`
|
|
93
|
+
- [ ] I will use recipe: `{{THEME_RECIPE}}`
|
|
94
|
+
- [ ] I will follow density: `{{DENSITY}}`
|
|
95
|
+
|
|
96
|
+
During modification:
|
|
97
|
+
|
|
98
|
+
- [ ] Every color/typography change uses the theme
|
|
99
|
+
- [ ] Pattern order matches essence exactly
|
|
100
|
+
- [ ] Spacing uses tokens, not arbitrary values
|
|
101
|
+
- [ ] No new pages without essence declaration
|
|
102
|
+
|
|
103
|
+
After modification:
|
|
104
|
+
|
|
105
|
+
- [ ] Run `decantr validate`
|
|
106
|
+
- [ ] Run `decantr audit` to check drift
|
|
107
|
+
- [ ] Verify no warnings or errors
|
|
108
|
+
|
|
109
|
+
## Spacing Enforcement
|
|
110
|
+
|
|
111
|
+
In strict mode, spacing must match the density profile:
|
|
112
|
+
|
|
113
|
+
| Density | Content Gap | Use These Tokens |
|
|
114
|
+
|---------|-------------|------------------|
|
|
115
|
+
| compact | `_gap2` | `_gap1`, `_gap2`, `_gap3` |
|
|
116
|
+
| comfortable | `_gap4` | `_gap3`, `_gap4`, `_gap6` |
|
|
117
|
+
| spacious | `_gap6` | `_gap4`, `_gap6`, `_gap8` |
|
|
118
|
+
|
|
119
|
+
This project uses **{{DENSITY}}** density with `{{CONTENT_GAP}}` content gap.
|
|
120
|
+
|
|
121
|
+
## Pattern Order Matters
|
|
122
|
+
|
|
123
|
+
In strict mode, patterns MUST appear in the order specified in `layout[]`.
|
|
124
|
+
|
|
125
|
+
If the essence says:
|
|
126
|
+
```json
|
|
127
|
+
"layout": ["kpi-grid", "chart-grid", "data-table"]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Then your code MUST render in that order:
|
|
131
|
+
1. KPI Grid section
|
|
132
|
+
2. Chart Grid section
|
|
133
|
+
3. Data Table section
|
|
134
|
+
|
|
135
|
+
Swapping `chart-grid` and `data-table` is a Layout guard violation.
|
|
136
|
+
|
|
137
|
+
## Common Strict Mode Violations
|
|
138
|
+
|
|
139
|
+
| Violation | What Happened | Fix |
|
|
140
|
+
|-----------|---------------|-----|
|
|
141
|
+
| "Theme mismatch" | Used different theme | Revert to `{{THEME_STYLE}}` |
|
|
142
|
+
| "Page undefined" | Edited undeclared page | Add page to essence first |
|
|
143
|
+
| "Layout order wrong" | Patterns out of order | Match `layout[]` exactly |
|
|
144
|
+
| "Recipe mismatch" | Wrong decoration style | Use `{{THEME_RECIPE}}` |
|
|
145
|
+
| "Density drift" | Wrong spacing values | Use `{{CONTENT_GAP}}` tokens |
|
|
146
|
+
|
|
147
|
+
## Proposing Essence Changes
|
|
148
|
+
|
|
149
|
+
If a change requires updating the essence:
|
|
150
|
+
|
|
151
|
+
1. Explain what needs to change and why
|
|
152
|
+
2. Show the before/after for the essence
|
|
153
|
+
3. Wait for user approval
|
|
154
|
+
4. Update the essence file
|
|
155
|
+
5. Then proceed with code changes
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
To implement your request, I need to update the essence:
|
|
159
|
+
|
|
160
|
+
Before:
|
|
161
|
+
"layout": ["kpi-grid", "chart-grid"]
|
|
162
|
+
|
|
163
|
+
After:
|
|
164
|
+
"layout": ["hero", "kpi-grid", "chart-grid"]
|
|
165
|
+
|
|
166
|
+
Shall I make this change?
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
*Task context generated by Decantr CLI*
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Task Context: Scaffolding
|
|
2
|
+
|
|
3
|
+
**Enforcement Tier: Creative**
|
|
4
|
+
|
|
5
|
+
You are scaffolding a new Decantr project. Guard rules are advisory only during initial scaffolding.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Your Task
|
|
10
|
+
|
|
11
|
+
Generate the initial project structure based on the essence specification.
|
|
12
|
+
|
|
13
|
+
## Rules (Advisory)
|
|
14
|
+
|
|
15
|
+
During scaffolding, the following rules are recommendations, not requirements:
|
|
16
|
+
|
|
17
|
+
| Rule | Status | Guidance |
|
|
18
|
+
|------|--------|----------|
|
|
19
|
+
| Style | Advisory | Use the theme from essence, but creative variations are acceptable |
|
|
20
|
+
| Structure | Advisory | Follow the page structure, add placeholder content |
|
|
21
|
+
| Layout | Advisory | Use suggested patterns, order can be adjusted |
|
|
22
|
+
| Recipe | Advisory | Apply recipe styles where possible |
|
|
23
|
+
| Density | Advisory | Follow spacing guidelines loosely |
|
|
24
|
+
|
|
25
|
+
## Checklist
|
|
26
|
+
|
|
27
|
+
Before scaffolding:
|
|
28
|
+
|
|
29
|
+
- [ ] Read `decantr.essence.json`
|
|
30
|
+
- [ ] Understand the target framework ({{TARGET}})
|
|
31
|
+
- [ ] Know the theme ({{THEME_STYLE}}) and mode ({{THEME_MODE}})
|
|
32
|
+
- [ ] Review the page structure
|
|
33
|
+
|
|
34
|
+
During scaffolding:
|
|
35
|
+
|
|
36
|
+
- [ ] Create the shell layout ({{DEFAULT_SHELL}})
|
|
37
|
+
- [ ] Generate pages from `structure[]`
|
|
38
|
+
- [ ] Add pattern placeholders for each page's `layout[]`
|
|
39
|
+
- [ ] Apply theme colors and typography
|
|
40
|
+
- [ ] Set up routing based on page IDs
|
|
41
|
+
|
|
42
|
+
After scaffolding:
|
|
43
|
+
|
|
44
|
+
- [ ] Run `decantr validate` to check the essence
|
|
45
|
+
- [ ] Verify each page renders correctly
|
|
46
|
+
- [ ] Check theme consistency across pages
|
|
47
|
+
|
|
48
|
+
## What to Generate
|
|
49
|
+
|
|
50
|
+
{{SCAFFOLD_STRUCTURE}}
|
|
51
|
+
|
|
52
|
+
## Next Steps
|
|
53
|
+
|
|
54
|
+
After scaffolding is complete:
|
|
55
|
+
|
|
56
|
+
1. Run the development server
|
|
57
|
+
2. Verify all pages load
|
|
58
|
+
3. Check theme consistency
|
|
59
|
+
4. Run `decantr validate`
|
|
60
|
+
|
|
61
|
+
Once verified, subsequent changes will use **{{GUARD_MODE}}** enforcement mode.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
*Task context generated by Decantr CLI*
|