@minhduydev/mdpi 0.4.0 → 0.5.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.
- package/dist/index.js +1 -1
- package/dist/template/.pi/VERSION +1 -1
- package/dist/template/.pi/extensions/templates-injector.ts +34 -6
- package/dist/template/.pi/prompts/INDEX.md +3 -9
- package/dist/template/.pi/skills/INDEX.md +81 -19
- package/dist/template/.pi/skills/accessibility-audit/SKILL.md +8 -2
- package/dist/template/.pi/skills/baseline-ui/SKILL.md +211 -0
- package/dist/template/.pi/skills/dcp-hygiene/SKILL.md +1 -1
- package/dist/template/.pi/skills/design-taste-frontend/SKILL.md +53 -42
- package/dist/template/.pi/skills/fixing-accessibility/SKILL.md +509 -0
- package/dist/template/.pi/skills/frontend-design/SKILL.md +60 -47
- package/dist/template/.pi/skills/frontend-design/references/animation/motion-advanced.md +88 -15
- package/dist/template/.pi/skills/frontend-design/references/animation/motion-core.md +148 -13
- package/dist/template/.pi/skills/frontend-design/references/shadcn/setup.md +127 -20
- package/dist/template/.pi/skills/frontend-ui-engineering/SKILL.md +21 -27
- package/dist/template/.pi/skills/nextjs-app-router/SKILL.md +334 -0
- package/dist/template/.pi/skills/nextjs-cache/SKILL.md +262 -0
- package/dist/template/.pi/skills/oklch-color-workflow/SKILL.md +426 -0
- package/dist/template/.pi/skills/production-hardening/SKILL.md +652 -0
- package/dist/template/.pi/skills/react-best-practices/SKILL.md +79 -1
- package/dist/template/.pi/skills/react-compiler/SKILL.md +237 -0
- package/dist/template/.pi/skills/react-hook-form/SKILL.md +374 -0
- package/dist/template/.pi/skills/react-server-actions/SKILL.md +299 -0
- package/dist/template/.pi/skills/shadcn-ui/SKILL.md +404 -0
- package/dist/template/.pi/skills/tanstack-query/SKILL.md +330 -0
- package/dist/template/.pi/skills/ui-craft-principles/SKILL.md +564 -0
- package/dist/template/.pi/skills/ui-quality-audit/SKILL.md +329 -0
- package/dist/template/.pi/skills/v0/SKILL.md +264 -0
- package/dist/template/.pi/skills/zustand/SKILL.md +333 -0
- package/dist/template/.pi/templates/DESIGN.md +76 -0
- package/dist/template/.pi/workflows/INDEX.md +2 -1
- package/dist/template/.pi/workflows/frontend-feature-workflow.md +343 -0
- package/dist/template/.pi/workflows/quality-loop.md +1 -1
- package/package.json +1 -1
- package/dist/template/.pi/prompts/loop-check.md +0 -87
- package/dist/template/.pi/prompts/loop-init.md +0 -157
- package/dist/template/.pi/prompts/loop-review.md +0 -90
- package/dist/template/.pi/skills/loop-audit/SKILL.md +0 -141
- package/dist/template/.pi/skills/loop-cost/SKILL.md +0 -130
- package/dist/template/.pi/skills/loop-engineering/SKILL.md +0 -175
- package/dist/template/.pi/templates/loop-github-action.yml +0 -162
- package/dist/template/.pi/templates/loop-orchestrator.sh +0 -514
- package/dist/template/.pi/templates/loop-orchestrator.test.ts +0 -332
- package/dist/template/.pi/templates/loop-orchestrator.ts +0 -936
- package/dist/template/.pi/templates/loop-state.json +0 -24
- package/dist/template/.pi/templates/loop-state.md +0 -98
- package/dist/template/.pi/templates/loop-vision.md +0 -110
- /package/dist/template/.pi/templates/{design.md → feature-design.md} +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Full frontend feature workflow — design analysis → deslop → architecture → craft polish → parallel implementation → hardening → quality audit (7 phases)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# frontend-feature-workflow
|
|
6
|
+
|
|
7
|
+
Multi-agent workflow for building production-quality frontend features. Chains 7 phases: design analysis, baseline cleanup, component architecture, craft polish, parallel implementation, hardening, and quality audit.
|
|
8
|
+
|
|
9
|
+
## Args
|
|
10
|
+
|
|
11
|
+
- `feature` (required) — The frontend feature or component to build
|
|
12
|
+
- `mockup` (optional) — URL or path to Figma mockup, screenshot, or design reference
|
|
13
|
+
|
|
14
|
+
## Phases
|
|
15
|
+
|
|
16
|
+
### Phase 1: Design Analysis
|
|
17
|
+
|
|
18
|
+
- **Agent:** vision
|
|
19
|
+
- **Concurrency:** 1
|
|
20
|
+
- **Depends on:** —
|
|
21
|
+
- **Tool:** `subagent` (single mode)
|
|
22
|
+
- **Skill:** `figma` (if mockup provided), `mockup-to-code` (if screenshot provided)
|
|
23
|
+
|
|
24
|
+
**Pre-Flight: Load DESIGN.md + aesthetic skills.** Before analyzing any mockup or design file: (1) read `.pi/DESIGN.md` (fallback: `.pi/templates/DESIGN.md`) to load project mood, color palette, typography scale, and design constraints; (2) load `frontend-design` and `design-taste-frontend` skills via `/skill:frontend-design` and `/skill:design-taste-frontend`. Use DESIGN.md prose as the aesthetic anchor — the Overview section's specific reference sets the tone for all subsequent design decisions.
|
|
25
|
+
|
|
26
|
+
Also load `design-taste-frontend` and `frontend-design` skills — they enforce the aesthetic rules that translate DESIGN.md's prose into concrete component styling decisions.
|
|
27
|
+
|
|
28
|
+
**Prompt:**
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Analyze the design for: {feature}.
|
|
32
|
+
|
|
33
|
+
If a mockup is provided ({mockup}):
|
|
34
|
+
- Extract layout structure (grid, sections, spacing patterns)
|
|
35
|
+
- Identify all visual components (buttons, cards, inputs, navigation)
|
|
36
|
+
- Extract color palette (primary, accent, neutrals, semantic tokens)
|
|
37
|
+
- Identify typography (font families, sizes, weights, hierarchy)
|
|
38
|
+
- Note responsive breakpoint behavior
|
|
39
|
+
- Identify animation/motion patterns
|
|
40
|
+
- Flag any accessibility concerns in the design
|
|
41
|
+
|
|
42
|
+
If no mockup is provided:
|
|
43
|
+
- Based on the feature description, recommend a layout structure
|
|
44
|
+
- Suggest component decomposition
|
|
45
|
+
- Propose a color palette (OKLCH tokens preferred)
|
|
46
|
+
- Recommend typography pairings
|
|
47
|
+
|
|
48
|
+
Return findings in this format:
|
|
49
|
+
|
|
50
|
+
## Layout Structure
|
|
51
|
+
- [Grid/stack/split-screen description]
|
|
52
|
+
|
|
53
|
+
## Components Identified
|
|
54
|
+
| Component | Type | States | Priority |
|
|
55
|
+
|-----------|------|--------|----------|
|
|
56
|
+
| [name] | [button/card/form/...] | [default, hover, active, disabled, loading, error] | [P0/P1/P2] |
|
|
57
|
+
|
|
58
|
+
## Design Tokens
|
|
59
|
+
- Colors: [primitive + semantic tokens]
|
|
60
|
+
- Typography: [font stack, scale, weights]
|
|
61
|
+
- Spacing: [scale reference]
|
|
62
|
+
- Motion: [animation patterns]
|
|
63
|
+
|
|
64
|
+
## Accessibility Notes
|
|
65
|
+
- [Potential issues or considerations]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Phase 2: Baseline Cleanup
|
|
69
|
+
|
|
70
|
+
- **Agent:** general
|
|
71
|
+
- **Concurrency:** 1
|
|
72
|
+
- **Depends on:** Phase 1
|
|
73
|
+
- **Tool:** `subagent` (single mode)
|
|
74
|
+
- **Skill:** `baseline-ui`
|
|
75
|
+
|
|
76
|
+
**Prompt:**
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Apply the baseline-ui deslop pass to the feature: {feature}.
|
|
80
|
+
|
|
81
|
+
Using the design analysis from Phase 1 ({phase_1_output}):
|
|
82
|
+
|
|
83
|
+
1. Scan existing code (if any) or scaffold for:
|
|
84
|
+
- MUST violations: purple gradients, banned fonts (Inter/Roboto/Arial), emojis, h-screen, div onClick
|
|
85
|
+
- SHOULD violations: inconsistent spacing, raw color values, missing semantic tokens
|
|
86
|
+
- NEVER violations: pure black (#000), centered hero with high variance, 3-column identical cards
|
|
87
|
+
|
|
88
|
+
2. Apply fixes for each violation found. Use the before/after patterns from baseline-ui.
|
|
89
|
+
|
|
90
|
+
3. Verify all MUST rules pass after fixes.
|
|
91
|
+
|
|
92
|
+
Return the list of fixes applied and verification results.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Phase 3: Component Architecture
|
|
96
|
+
|
|
97
|
+
- **Agent:** plan
|
|
98
|
+
- **Concurrency:** 1
|
|
99
|
+
- **Depends on:** Phase 2
|
|
100
|
+
- **Tool:** `subagent` (single mode)
|
|
101
|
+
- **Skill:** `frontend-design`
|
|
102
|
+
|
|
103
|
+
**Prompt:**
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Plan the component architecture for: {feature}.
|
|
107
|
+
|
|
108
|
+
Based on the design analysis ({phase_1_output}) and baseline cleanup ({phase_2_output}):
|
|
109
|
+
|
|
110
|
+
1. Decompose the feature into components:
|
|
111
|
+
- Page-level components (layout containers)
|
|
112
|
+
- Section components (feature areas)
|
|
113
|
+
- Shared/primitive components (reusable across sections)
|
|
114
|
+
- Leaf components (specific interactive elements)
|
|
115
|
+
|
|
116
|
+
2. For each component, specify:
|
|
117
|
+
- Props interface (TypeScript)
|
|
118
|
+
- State requirements (local, lifted, context, server)
|
|
119
|
+
- Loading/empty/error state design
|
|
120
|
+
- Accessibility requirements (ARIA roles, keyboard handling)
|
|
121
|
+
- Data dependencies
|
|
122
|
+
|
|
123
|
+
3. Define the component tree with parent-child relationships.
|
|
124
|
+
|
|
125
|
+
4. Identify which components can be built in parallel (no shared state, no parent-child dependency).
|
|
126
|
+
|
|
127
|
+
Return the architecture plan in this format:
|
|
128
|
+
|
|
129
|
+
## Component Tree
|
|
130
|
+
```
|
|
131
|
+
PageLayout
|
|
132
|
+
├── Header
|
|
133
|
+
│ ├── Navigation
|
|
134
|
+
│ └── UserMenu
|
|
135
|
+
├── MainContent
|
|
136
|
+
│ ├── SectionA
|
|
137
|
+
│ │ ├── ComponentA1
|
|
138
|
+
│ │ └── ComponentA2
|
|
139
|
+
│ └── SectionB
|
|
140
|
+
│ └── ComponentB1
|
|
141
|
+
└── Footer
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Component Specs
|
|
145
|
+
### [ComponentName]
|
|
146
|
+
- **Type:** [page/section/shared/leaf]
|
|
147
|
+
- **Props:** [TypeScript interface]
|
|
148
|
+
- **State:** [local/lifted/context/server]
|
|
149
|
+
- **States:** [loading, empty, error, default]
|
|
150
|
+
- **Accessibility:** [ARIA, keyboard, focus]
|
|
151
|
+
- **Data:** [dependencies]
|
|
152
|
+
|
|
153
|
+
## Parallel Build Groups
|
|
154
|
+
- Group 1: [components that can be built simultaneously]
|
|
155
|
+
- Group 2: [components that can be built simultaneously]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Phase 4: Craft Polish
|
|
159
|
+
|
|
160
|
+
- **Agent:** general
|
|
161
|
+
- **Concurrency:** 1
|
|
162
|
+
- **Depends on:** Phase 3
|
|
163
|
+
- **Tool:** `subagent` (single mode)
|
|
164
|
+
- **Skill:** `ui-craft-principles`, `oklch-color-workflow`
|
|
165
|
+
|
|
166
|
+
**Prompt:**
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
Apply craft polish to the component architecture for: {feature}.
|
|
170
|
+
|
|
171
|
+
Using the architecture plan ({phase_3_output}) and design tokens ({phase_1_output}):
|
|
172
|
+
|
|
173
|
+
1. Verify and enhance color tokens using OKLCH:
|
|
174
|
+
- Convert any HEX/RGB tokens to OKLCH
|
|
175
|
+
- Check gamut for all colors
|
|
176
|
+
- Generate 50-950 scale for primary and accent
|
|
177
|
+
- Define semantic tokens from primitives
|
|
178
|
+
- Verify contrast ratios (4.5:1 min for text)
|
|
179
|
+
|
|
180
|
+
2. Apply craft principles to each component:
|
|
181
|
+
- Concentric border-radius (outer = inner + padding)
|
|
182
|
+
- Optical text alignment (-0.05em margin for visual centering)
|
|
183
|
+
- Multi-shadow layering (not single box-shadow)
|
|
184
|
+
- Interruptible animations (spring-based, not duration-based)
|
|
185
|
+
- Tabular numbers for data displays
|
|
186
|
+
- Hit areas ≥ 44px for interactive elements
|
|
187
|
+
- Focus ring offset (outline-offset: 2px)
|
|
188
|
+
|
|
189
|
+
3. Define motion specs:
|
|
190
|
+
- Animation duration hierarchy (100ms/200ms/300ms/500ms)
|
|
191
|
+
- Easing: exponential only (cubic-bezier(0.16, 1, 0.3, 1))
|
|
192
|
+
- prefers-reduced-motion handling
|
|
193
|
+
|
|
194
|
+
Return the enhanced design specs with before/after for each craft improvement.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Phase 5: Parallel Implementation
|
|
198
|
+
|
|
199
|
+
- **Agent:** general
|
|
200
|
+
- **Concurrency:** Dynamic: 1..5
|
|
201
|
+
- **Notes:** One subagent per build group from Phase 3.
|
|
202
|
+
- **Depends on:** Phase 4
|
|
203
|
+
- **Tool:** `subagent` (parallel mode)
|
|
204
|
+
- **Skill:** `frontend-ui-engineering`, `react-best-practices`
|
|
205
|
+
|
|
206
|
+
**Prompt:**
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Implement the components for build group: [assigned group] in feature: {feature}.
|
|
210
|
+
|
|
211
|
+
Using the architecture plan ({phase_3_output}) and craft polish specs ({phase_4_output}):
|
|
212
|
+
|
|
213
|
+
1. For each component in your assigned group:
|
|
214
|
+
- Implement the component with full TypeScript types
|
|
215
|
+
- Handle all states: loading, empty, error, default, active, disabled
|
|
216
|
+
- Apply all craft principles from the polish phase
|
|
217
|
+
- Use semantic HTML and ARIA attributes
|
|
218
|
+
- Add keyboard navigation support
|
|
219
|
+
- Use the exact design tokens (colors, spacing, typography)
|
|
220
|
+
|
|
221
|
+
2. Follow frontend-ui-engineering patterns:
|
|
222
|
+
- Composition over configuration
|
|
223
|
+
- Colocate component files (component + test + types)
|
|
224
|
+
- Separate data fetching from presentation
|
|
225
|
+
- Components < 200 lines; split if larger
|
|
226
|
+
|
|
227
|
+
3. Apply react-best-practices:
|
|
228
|
+
- Server Components by default, Client Components only for interactivity
|
|
229
|
+
- Memoize expensive computations
|
|
230
|
+
- Optimize re-renders
|
|
231
|
+
|
|
232
|
+
Return each component implementation with its test file.
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Phase 6: Hardening
|
|
236
|
+
|
|
237
|
+
- **Agent:** general
|
|
238
|
+
- **Concurrency:** 1
|
|
239
|
+
- **Depends on:** Phase 5
|
|
240
|
+
- **Tool:** `subagent` (single mode)
|
|
241
|
+
- **Skill:** `production-hardening`, `fixing-accessibility`
|
|
242
|
+
|
|
243
|
+
**Prompt:**
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
Apply production hardening to the implemented feature: {feature}.
|
|
247
|
+
|
|
248
|
+
Using the implemented components ({phase_5_output}):
|
|
249
|
+
|
|
250
|
+
1. Production hardening checklist:
|
|
251
|
+
- Text overflow: add truncation, word-break for long content
|
|
252
|
+
- i18n readiness: 30% text expansion allowance, RTL support
|
|
253
|
+
- Error states: what happened + why + how to fix
|
|
254
|
+
- Empty states: don't show blank screens, provide guidance
|
|
255
|
+
- Loading states: skeleton loaders matching exact layout
|
|
256
|
+
- Input validation: HTML5 + JS, sanitization, max lengths
|
|
257
|
+
- Edge cases: 0 items, 1 item, many items, very long names, missing images
|
|
258
|
+
- Cross-browser: -webkit-appearance, scrollbar styling, safe area insets
|
|
259
|
+
|
|
260
|
+
2. Accessibility fixes (WCAG 2.1 AA):
|
|
261
|
+
- Keyboard navigation: all interactive elements reachable via Tab
|
|
262
|
+
- Focus management: visible focus indicators, trap in modals
|
|
263
|
+
- ARIA labels: all icon buttons, form inputs labeled
|
|
264
|
+
- Color contrast: verify 4.5:1 for text, 3:1 for UI elements
|
|
265
|
+
- Heading hierarchy: logical H1-H6, no skipped levels
|
|
266
|
+
- Touch targets: minimum 44x44px
|
|
267
|
+
- Screen reader: meaningful content and structure
|
|
268
|
+
|
|
269
|
+
Return hardening report with each issue found and fix applied.
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Phase 7: Quality Audit
|
|
273
|
+
|
|
274
|
+
- **Agent:** review
|
|
275
|
+
- **Concurrency:** 1
|
|
276
|
+
- **Depends on:** Phase 6
|
|
277
|
+
- **Tool:** `subagent` (single mode)
|
|
278
|
+
- **Skill:** `ui-quality-audit`
|
|
279
|
+
|
|
280
|
+
**Prompt:**
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
Run a 5-dimension quality audit on the completed feature: {feature}.
|
|
284
|
+
|
|
285
|
+
Using all previous phase outputs:
|
|
286
|
+
|
|
287
|
+
Score each dimension 0-4:
|
|
288
|
+
|
|
289
|
+
1. **Accessibility** (0-4): keyboard, ARIA, contrast, focus, semantic HTML
|
|
290
|
+
2. **Performance** (0-4): bundle size, render performance, animation perf, image optimization
|
|
291
|
+
3. **Theming** (0-4): token consistency, dark mode, color contrast, typography scale
|
|
292
|
+
4. **Responsive** (0-4): breakpoints, touch targets, content reflow, viewport meta
|
|
293
|
+
5. **Anti-patterns** (0-4): AI fingerprints, dead code, over-engineering, inconsistent patterns
|
|
294
|
+
|
|
295
|
+
For each finding, tag severity:
|
|
296
|
+
- **P0**: Ship blocker — must fix before release
|
|
297
|
+
- **P1**: Must fix this release
|
|
298
|
+
- **P2**: Should fix
|
|
299
|
+
- **P3**: Nice to have
|
|
300
|
+
|
|
301
|
+
Return the complete audit report with total score /20 and per-dimension breakdown.
|
|
302
|
+
|
|
303
|
+
## Overall Score: X/20
|
|
304
|
+
|
|
305
|
+
## Dimension Breakdown
|
|
306
|
+
| Dimension | Score | P0 | P1 | P2 | P3 |
|
|
307
|
+
|-----------|-------|----|----|----|-----|
|
|
308
|
+
| Accessibility | X/4 | N | N | N | N |
|
|
309
|
+
| Performance | X/4 | N | N | N | N |
|
|
310
|
+
| Theming | X/4 | N | N | N | N |
|
|
311
|
+
| Responsive | X/4 | N | N | N | N |
|
|
312
|
+
| Anti-patterns | X/4 | N | N | N | N |
|
|
313
|
+
|
|
314
|
+
## Findings
|
|
315
|
+
### [P0/P1/P2/P3] [Title]
|
|
316
|
+
- **Dimension:** [name]
|
|
317
|
+
- **Location:** [file:line]
|
|
318
|
+
- **Issue:** [description]
|
|
319
|
+
- **Fix:** [recommendation]
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Final Synthesis (Main Agent)
|
|
325
|
+
|
|
326
|
+
After all 7 phases complete, the main agent:
|
|
327
|
+
|
|
328
|
+
1. **Aggregates** the quality audit ({phase_7_output}) and all phase outputs
|
|
329
|
+
2. **Verifies** P0 issues are resolved (re-run Phase 7 if needed)
|
|
330
|
+
3. **Compiles** the final summary:
|
|
331
|
+
- Feature delivered vs spec
|
|
332
|
+
- Quality score /20
|
|
333
|
+
- Open issues (P1-P3)
|
|
334
|
+
- Files created/modified
|
|
335
|
+
4. **Reports** to the user with the complete results
|
|
336
|
+
|
|
337
|
+
## Notes
|
|
338
|
+
|
|
339
|
+
- **Empty mockup guard:** If no mockup provided, Phase 1 focuses on recommendation rather than extraction
|
|
340
|
+
- **Skip guard:** If Phase 2 finds no violations, report clean and proceed to Phase 3
|
|
341
|
+
- **Parallel safety:** Phase 5 groups must have no shared files; if conflicts detected, fall back to sequential
|
|
342
|
+
- **Score gate:** Quality score < 12/20 triggers re-hardening (Phase 6) before final synthesis
|
|
343
|
+
- All phases use project's design tokens and conventions as established in Phase 1
|
|
@@ -69,7 +69,7 @@ Score-gated, review-driven feedback loop for high-risk features. Runs iterative
|
|
|
69
69
|
"findings": [
|
|
70
70
|
{ "severity": "critical", "file": "src/auth.ts:42", "finding": "...", "suggestion": "..." }
|
|
71
71
|
],
|
|
72
|
-
"suggested_action": "fix" | "
|
|
72
|
+
"suggested_action": "fix" | "ask_user_question" | "proceed"
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
package/package.json
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: NO-GO qualification gate — decide whether a task is safe to run as an unattended loop
|
|
3
|
-
argument-hint: "<task description> [--help]"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Loop-Check: $ARGUMENTS
|
|
7
|
-
|
|
8
|
-
Qualify a task before it is ever scheduled as an unattended loop. Emit a single GO/NO-GO verdict with the cited condition that produced it. This prompt is the gate *before* the gate — it refuses work a loop cannot honestly judge.
|
|
9
|
-
|
|
10
|
-
> Refuse first, test second, checklist last. Never let "looks automatable" override the refuse-list.
|
|
11
|
-
|
|
12
|
-
## Parse Arguments
|
|
13
|
-
|
|
14
|
-
| Argument | Default | Description |
|
|
15
|
-
| ------------- | -------- | ------------------------------------------------ |
|
|
16
|
-
| `<task>` | required | The task proposed for unattended looping |
|
|
17
|
-
| `--help` | false | Show this usage |
|
|
18
|
-
|
|
19
|
-
## Step 1 — Refuse-List (Immediate NO-GO)
|
|
20
|
-
|
|
21
|
-
If the task touches any of these, **stop here** and emit NO-GO. Do not proceed to the 2-condition test.
|
|
22
|
-
|
|
23
|
-
- **auth** — login, sessions, tokens, permissions, auth flows, auth module rewrites
|
|
24
|
-
- **payments** — billing, checkout, refunds, subscriptions, payment provider integration
|
|
25
|
-
- **architecture** — framework/library switches, schema migrations, new DB tables, new services, breaking API changes
|
|
26
|
-
|
|
27
|
-
> Rationale: these need human judgement a loop cannot provide. The refuse-list is the honest ceiling, not a configurable preference.
|
|
28
|
-
|
|
29
|
-
If a refuse-list category is hit → `CONDITION: <refused category> refused` (e.g. `CONDITION: architecture refused`).
|
|
30
|
-
|
|
31
|
-
## Step 2 — The 2-Condition Test
|
|
32
|
-
|
|
33
|
-
Both conditions must hold. If either fails, emit NO-GO citing the failed condition.
|
|
34
|
-
|
|
35
|
-
1. **Verification is automated.** There exists an objective command whose **exit code** decides pass/fail — `npm test`, `tsc --noEmit`, `eslint`, a custom gate script. The stop condition is computational (exit code), never an LLM's opinion. If the only "check" is "the agent says it looks good" → FAIL.
|
|
36
|
-
2. **The token budget absorbs the waste.** The cost of one wasted run (gate fails, no-op, early-exit) is small enough that running on the scheduled cadence does not blow the budget. If a single failed run is expensive (large model, long context, many turns) and there is no per-run cap → FAIL.
|
|
37
|
-
|
|
38
|
-
If condition 1 fails → `CONDITION: verification not automated (no exit-code gate)`.
|
|
39
|
-
If condition 2 fails → `CONDITION: budget does not absorb waste (uncapped/expensive failed run)`.
|
|
40
|
-
|
|
41
|
-
## Step 3 — 30-Second Checklist
|
|
42
|
-
|
|
43
|
-
Confirm every item. Any miss → NO-GO citing the missing item.
|
|
44
|
-
|
|
45
|
-
- [ ] **Objective gate exists** — a named command with a pass = exit 0 contract (write it down; "tests" without a command is not a gate).
|
|
46
|
-
- [ ] **Hard stop exists** — a non-negotiable exit condition: repeated gate failure, budget cap hit, or forbidden path touched. The loop exits; it does not improvise.
|
|
47
|
-
- [ ] **Human approves merge/deploy/dependency changes** — the loop may open PRs and stage work; a human merges, deploys, and changes deps. No auto-merge.
|
|
48
|
-
|
|
49
|
-
Missing gate → `CONDITION: no objective gate`.
|
|
50
|
-
Missing hard stop → `CONDITION: no hard stop`.
|
|
51
|
-
No human-approval boundary → `CONDITION: no human-approval boundary on merge/deploy/deps`.
|
|
52
|
-
|
|
53
|
-
## Step 4 — Emit Verdict
|
|
54
|
-
|
|
55
|
-
Output **exactly** these two lines and nothing else as the decision:
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
VERDICT: GO
|
|
59
|
-
CONDITION: verification automated + budget absorbs waste
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
or
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
VERDICT: NO-GO
|
|
66
|
-
CONDITION: <cited condition from Step 1, 2, or 3>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
- `VERDICT` is `GO` or `NO-GO` — no other values.
|
|
70
|
-
- `CONDITION` cites the specific condition that produced the verdict. For GO, cite both passing conditions. For NO-GO, cite the first failing condition (Step 1 overrides Step 2 overrides Step 3).
|
|
71
|
-
- Do not add rationale, recommendations, or next steps after the verdict lines. The verdict is the contract.
|
|
72
|
-
|
|
73
|
-
## Worked Examples
|
|
74
|
-
|
|
75
|
-
- **"triage failing CI nightly"** with `npm test` gate, no-op early-exit <5k tokens → `VERDICT: GO` / `CONDITION: verification automated + budget absorbs waste`
|
|
76
|
-
- **"rewrite auth module"** → `VERDICT: NO-GO` / `CONDITION: auth refused`
|
|
77
|
-
- **"migrate from REST to GraphQL"** → `VERDICT: NO-GO` / `CONDITION: architecture refused`
|
|
78
|
-
- **"keep docs in sync with code weekly"** with no gate command → `VERDICT: NO-GO` / `CONDITION: verification not automated (no exit-code gate)`
|
|
79
|
-
|
|
80
|
-
## Related
|
|
81
|
-
|
|
82
|
-
| Companion | Role |
|
|
83
|
-
|---|---|
|
|
84
|
-
| `loop-engineering` skill | The 2-condition test, refuse-list, and 5 building blocks this gate codifies |
|
|
85
|
-
| `/loop-init` | Scaffold `.pi/loops/<name>/` once a task is GO |
|
|
86
|
-
| `/loop-review` | Maker/checker verification — the gate *during* a run |
|
|
87
|
-
| `loop-audit` | Readiness scoring (L0-L3) for an already-GO loop |
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Scaffold a new unattended loop at .pi/loops/<name>/ with VISION, STATE, and a per-loop SKILL stub
|
|
3
|
-
argument-hint: "<name> [--help]"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Loop Init: $ARGUMENTS
|
|
7
|
-
|
|
8
|
-
Scaffold a new loop-engineering harness at `.pi/loops/<name>/` from the templates shipped in `.pi/templates/`. Run once per loop. The scaffold is the contract + ledger + procedure the orchestrator (T9/T10) drives unattended.
|
|
9
|
-
|
|
10
|
-
> **Prerequisite:** `/loop-check <task>` returned GO. If not, refuse and tell the user to qualify the task first.
|
|
11
|
-
|
|
12
|
-
## Parse Arguments
|
|
13
|
-
|
|
14
|
-
| Argument | Default | Description |
|
|
15
|
-
| -------- | --------- | -------------------------------------------- |
|
|
16
|
-
| `<name>` | required | Loop slug; used as directory name `loop/<name>/<ts>` branch prefix |
|
|
17
|
-
| `--help` | false | Show this usage |
|
|
18
|
-
|
|
19
|
-
**Validation:** `<name>` must be a filesystem-safe slug (`^[a-z0-9][a-z0-9-]*$`, lowercase). Reject names containing `/`, spaces, or upper-case. Trim surrounding whitespace before use.
|
|
20
|
-
|
|
21
|
-
## When to Use
|
|
22
|
-
|
|
23
|
-
- You want to start a new unattended loop (nightly CI triage, dependency bumps, doc sync, PR babysitting).
|
|
24
|
-
- `/loop-check <task>` already returned GO (verification automated + token budget absorbs waste + human approves merge/deploy/deps).
|
|
25
|
-
- You need the contract (VISION.md), dedup ledger (STATE.json + STATE.md), and per-loop procedure (SKILL.md) that the orchestrator will drive.
|
|
26
|
-
|
|
27
|
-
Do NOT use for:
|
|
28
|
-
- One-off tasks (use `/create` or `/fix`).
|
|
29
|
-
- Tasks `/loop-check` refused (auth, payments, architecture) — refuse here too.
|
|
30
|
-
|
|
31
|
-
## The Scaffold Steps
|
|
32
|
-
|
|
33
|
-
### 1. Create the loop directory
|
|
34
|
-
|
|
35
|
-
Create `.pi/loops/<name>/` (parent `.pi/loops/` may not exist yet — create it).
|
|
36
|
-
|
|
37
|
-
### 2. Copy the four artifacts
|
|
38
|
-
|
|
39
|
-
Copy map (exact source → destination):
|
|
40
|
-
|
|
41
|
-
| Source (template) | Destination | Purpose |
|
|
42
|
-
| ----------------------------------------- | ------------------------------------ | ----------------------------------------- |
|
|
43
|
-
| `.pi/templates/loop-vision.md` | `.pi/loops/<name>/VISION.md` | Anti goal-drift contract (FR2) |
|
|
44
|
-
| `.pi/templates/loop-state.md` | `.pi/loops/<name>/STATE.md` | Human-readable state mirror (FR3) |
|
|
45
|
-
| `.pi/templates/loop-state.json` | `.pi/loops/<name>/STATE.json` | Machine dedup ledger (FR3, authoritative) |
|
|
46
|
-
| (new stub) | `.pi/loops/<name>/SKILL.md` | Per-loop procedure (classification + fix patterns) |
|
|
47
|
-
|
|
48
|
-
Copy the three templates byte-for-byte first (placeholders intact), then fill placeholders in the copied files. The `SKILL.md` stub is not a template — write a minimal seed:
|
|
49
|
-
|
|
50
|
-
```markdown
|
|
51
|
-
---
|
|
52
|
-
name: <name>
|
|
53
|
-
description: Per-loop procedure for <name> — classify, fix, escalate
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
# Loop Procedure: <name>
|
|
57
|
-
|
|
58
|
-
Reread `VISION.md` at the start of every run. Do not act outside it.
|
|
59
|
-
|
|
60
|
-
## Procedure
|
|
61
|
-
|
|
62
|
-
1. Reread `VISION.md` (boundaries authoritative).
|
|
63
|
-
2. Read `STATE.json` — build the dedup set from `processed[]`.
|
|
64
|
-
3. Fetch candidate items (per the loop's source: CI runs, PRs, packages, commits).
|
|
65
|
-
4. For each item: skip if in `processed[]`; else classify → fix / escalate / reject.
|
|
66
|
-
5. Run the Gate command (the ```bash block directly under `## Gate` in VISION.md); ship only on exit 0.
|
|
67
|
-
6. Append to `STATE.json.processed[]`, `completed[]`, `escalated[]`, or `failures[]`.
|
|
68
|
-
7. Enforce hard stops (see VISION.md "Hard stops").
|
|
69
|
-
|
|
70
|
-
## Classification rubric
|
|
71
|
-
|
|
72
|
-
<!-- Fill by hand after supervising the first manual runs. -->
|
|
73
|
-
|
|
74
|
-
## Fix patterns
|
|
75
|
-
|
|
76
|
-
<!-- Fill by hand as repeatable fixes are discovered. -->
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 3. Fill `<name>` placeholders
|
|
80
|
-
|
|
81
|
-
In the copied `VISION.md`, `STATE.md`, and `STATE.json`, replace every placeholder occurrence with the actual loop name:
|
|
82
|
-
|
|
83
|
-
- `<loop-name>` → `<name>`
|
|
84
|
-
- Leave human-fill placeholders (`[Owner]`, `[Date]`, `[cron expression or "manual"]`, `[Allowed action 1]`, `<GATE_COMMAND>`, etc.) as bracketed prompts for the user to edit by hand — do NOT invent values.
|
|
85
|
-
|
|
86
|
-
Tell the user explicitly which placeholders still need their input.
|
|
87
|
-
|
|
88
|
-
### 4. Print the rollout order
|
|
89
|
-
|
|
90
|
-
After scaffolding, print this rollout order so the user knows the path from scaffold to unattended run:
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
Rollout order:
|
|
94
|
-
1. check — /loop-check <task> (already GO; re-run if scope changes)
|
|
95
|
-
2. init — /loop-init <name> (this step — scaffold created)
|
|
96
|
-
3. supervise — run the loop's SKILL.md manually in a session; refine classification/fix patterns
|
|
97
|
-
4. wire — copy loop-orchestrator.ts/.sh + loop-github-action.yml; set cadence + gate + scope
|
|
98
|
-
5. run — schedule cron/launchd (local) or GitHub Actions `on: schedule` (CI); loop runs unattended
|
|
99
|
-
6. review — /loop-review <name> for interactive maker/checker verify
|
|
100
|
-
7. audit/cost — loop-audit scores readiness (L0-L3); track cost-per-accepted-change; kill if acceptance < 50%
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Idempotency Guard
|
|
104
|
-
|
|
105
|
-
Before writing anything:
|
|
106
|
-
|
|
107
|
-
1. Check whether `.pi/loops/<name>/` already exists.
|
|
108
|
-
2. **If it exists:** STOP. Do not overwrite. Ask the user:
|
|
109
|
-
> `.pi/loops/<name>/` already exists. Overwrite all files (VISION.md, STATE.md, STATE.json, SKILL.md)? This destroys any hand-edited contract/state. (y/N)
|
|
110
|
-
3. **Refuse overwrite without explicit confirmation.** On `N` or no answer, abort and report the existing tree without modifying it.
|
|
111
|
-
4. **If it does not exist:** proceed with the scaffold.
|
|
112
|
-
|
|
113
|
-
This guard protects hand-edited VISION.md contracts and STATE.json dedup ledgers from being clobbered by a re-run.
|
|
114
|
-
|
|
115
|
-
## Output
|
|
116
|
-
|
|
117
|
-
Print:
|
|
118
|
-
|
|
119
|
-
1. **Created tree** (e.g.):
|
|
120
|
-
```
|
|
121
|
-
.pi/loops/<name>/
|
|
122
|
-
├── VISION.md (contract — fill [Owner], [Date], cadence, Scope, Gate)
|
|
123
|
-
├── STATE.md (human-readable state mirror)
|
|
124
|
-
├── STATE.json (machine dedup ledger — authoritative)
|
|
125
|
-
└── SKILL.md (per-loop procedure — fill classification + fix patterns by hand)
|
|
126
|
-
```
|
|
127
|
-
2. **Rollout order** (the 7-step block above).
|
|
128
|
-
3. **Placeholders still needing input** (list each `[...]` / `<GATE_COMMAND>` the user must fill by hand, with file:line where useful).
|
|
129
|
-
4. **Next step:** `supervise` — run the loop's `SKILL.md` manually in a session and refine classification/fix patterns before wiring the orchestrator.
|
|
130
|
-
|
|
131
|
-
## Failure Handling
|
|
132
|
-
|
|
133
|
-
| Scenario | Action |
|
|
134
|
-
| ------------------------------------- | ------------------------------------------------------------ |
|
|
135
|
-
| `<name>` missing or invalid slug | Abort with the validation regex and an example |
|
|
136
|
-
| `.pi/loops/<name>/` exists, no confirm| Abort, print existing tree, do not modify |
|
|
137
|
-
| Template missing from `.pi/templates/`| Abort, list which template is missing (T2 must be shipped first) |
|
|
138
|
-
| `<name>` would collide with a reserved path | Abort, suggest an alternate slug |
|
|
139
|
-
|
|
140
|
-
## Stop Conditions
|
|
141
|
-
|
|
142
|
-
- `<name>` invalid → stop, report the regex.
|
|
143
|
-
- Directory exists and user declines overwrite → stop, report existing tree.
|
|
144
|
-
- Any of the three templates missing → stop, report (T2 prerequisite unmet).
|
|
145
|
-
|
|
146
|
-
## Related Commands
|
|
147
|
-
|
|
148
|
-
| Need | Command |
|
|
149
|
-
| ------------------------ | ----------------- |
|
|
150
|
-
| Qualify a task first | `/loop-check` |
|
|
151
|
-
| Review a running loop | `/loop-review` |
|
|
152
|
-
| Audit loop readiness | `loop-audit` |
|
|
153
|
-
|
|
154
|
-
## Related Skills
|
|
155
|
-
|
|
156
|
-
- `loop-engineering` — 2-condition test, 5 building blocks, VISION/state contract, failure modes
|
|
157
|
-
- `planning-and-task-breakdown` — decompose the loop's procedure into verifiable steps
|