the-frame-ai 0.1.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/LICENSE +21 -0
- package/README.md +335 -0
- package/README.ru.md +333 -0
- package/bin/the-frame +5 -0
- package/bin/the-frame-ai +5 -0
- package/package.json +29 -0
- package/src/cli.js +84 -0
- package/src/doctor.js +164 -0
- package/src/init.js +178 -0
- package/src/languages.js +141 -0
- package/src/manifest.js +55 -0
- package/src/update.js +87 -0
- package/src/utils.js +55 -0
- package/templates/agents/builder.md +240 -0
- package/templates/agents/devils-advocate.md +136 -0
- package/templates/agents/planner.md +277 -0
- package/templates/agents/researcher.md +195 -0
- package/templates/agents/reviewer.md +300 -0
- package/templates/commands/frame:add-task.md +57 -0
- package/templates/commands/frame:build.md +170 -0
- package/templates/commands/frame:check-deps.md +118 -0
- package/templates/commands/frame:checkpoint.md +158 -0
- package/templates/commands/frame:cleanup-memory.md +80 -0
- package/templates/commands/frame:context.md +64 -0
- package/templates/commands/frame:daily.md +77 -0
- package/templates/commands/frame:debug.md +146 -0
- package/templates/commands/frame:doctor.md +170 -0
- package/templates/commands/frame:estimate.md +105 -0
- package/templates/commands/frame:explain.md +84 -0
- package/templates/commands/frame:fast.md +89 -0
- package/templates/commands/frame:forensics.md +139 -0
- package/templates/commands/frame:headless.md +118 -0
- package/templates/commands/frame:health.md +86 -0
- package/templates/commands/frame:init.md +231 -0
- package/templates/commands/frame:migrate.md +107 -0
- package/templates/commands/frame:note.md +32 -0
- package/templates/commands/frame:pause.md +145 -0
- package/templates/commands/frame:performance.md +228 -0
- package/templates/commands/frame:plan.md +198 -0
- package/templates/commands/frame:refactor.md +161 -0
- package/templates/commands/frame:research.md +131 -0
- package/templates/commands/frame:resume.md +137 -0
- package/templates/commands/frame:retrospective.md +196 -0
- package/templates/commands/frame:review.md +174 -0
- package/templates/commands/frame:rollback.md +207 -0
- package/templates/commands/frame:ship.md +148 -0
- package/templates/commands/frame:sprint-check.md +111 -0
- package/templates/commands/frame:status.md +103 -0
- package/templates/commands/frame:unstuck.md +102 -0
- package/templates/commands/frame:wave.md +312 -0
- package/templates/commands/frame:where.md +5 -0
- package/templates/commands/frame:why.md +57 -0
- package/templates/commands/frame:worktree.md +219 -0
- package/templates/hooks/git-safety.sh +33 -0
- package/templates/hooks/quality-gate.sh +52 -0
- package/templates/hooks/safety-net.sh +13 -0
- package/templates/hooks/session-init.sh +81 -0
- package/templates/planning/pause-state.json +1 -0
- package/templates/project/CLAUDE.md +63 -0
- package/templates/project/CONTEXT.md +16 -0
- package/templates/project/MAP.md +35 -0
- package/templates/project/ROADMAP.md +12 -0
- package/templates/project/STATE.md +13 -0
- package/templates/project/config.json +74 -0
- package/templates/project/memory/anti-patterns.md +14 -0
- package/templates/project/memory/context.md +23 -0
- package/templates/project/memory/conventions.md +19 -0
- package/templates/project/memory/decisions.md +20 -0
- package/templates/project/memory/dependencies.md +23 -0
- package/templates/project/memory/metrics.md +22 -0
- package/templates/project/memory/patterns.md +30 -0
- package/templates/project/memory/wins.md +11 -0
- package/templates/project/settings.local.json +50 -0
- package/templates/project/specs/_template/PRD.md +24 -0
- package/templates/project/specs/_template/plan.md +25 -0
- package/templates/project/specs/_template/spec.md +27 -0
- package/templates/project/specs/_template/subagent-prompt.md +43 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# /frame:performance -- Performance Budget
|
|
2
|
+
|
|
3
|
+
Performance monitoring and bundle analysis.
|
|
4
|
+
|
|
5
|
+
## Subcommands
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### `/frame:performance bundle` -- Bundle Analysis
|
|
10
|
+
|
|
11
|
+
### Step 0: Validate prerequisites
|
|
12
|
+
|
|
13
|
+
Check `.frame/config.json` exists:
|
|
14
|
+
```bash
|
|
15
|
+
test -f .frame/config.json || echo "MISSING"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If missing → **STOP**:
|
|
19
|
+
```
|
|
20
|
+
❌ .frame/config.json not found. Run /frame:init first.
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Update STATE.md:
|
|
24
|
+
```markdown
|
|
25
|
+
## Current Position
|
|
26
|
+
- Phase: REVIEW
|
|
27
|
+
- Status: Bundle analysis IN_PROGRESS
|
|
28
|
+
- Started: {timestamp}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Step 1: Build
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
{quality.commands.build} 2>&1 | tail -20
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Step 2: Bundle size
|
|
38
|
+
|
|
39
|
+
Detect tool from `package.json`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Next.js
|
|
43
|
+
ls -la .next/static/chunks/ 2>/dev/null | sort -k5 -rn | head -10
|
|
44
|
+
|
|
45
|
+
# Vite
|
|
46
|
+
ls -la dist/assets/ 2>/dev/null | sort -k5 -rn | head -10
|
|
47
|
+
|
|
48
|
+
# Universal
|
|
49
|
+
find dist .next build -name "*.js" 2>/dev/null | xargs ls -la | sort -k5 -rn | head -10
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Step 3: Compare against limits
|
|
53
|
+
|
|
54
|
+
Read `.frame/config.json` → `performance` section:
|
|
55
|
+
- `maxBundleSize` (default: 200KB)
|
|
56
|
+
- `maxFirstLoadJS` (default: 85KB)
|
|
57
|
+
|
|
58
|
+
If `{quality.commands.bundle}` is set in config — use it instead of step 2.
|
|
59
|
+
|
|
60
|
+
Calculate percentage of limit and determine level:
|
|
61
|
+
- < 90% of limit → PASS
|
|
62
|
+
- 90–120% of limit → WARNING
|
|
63
|
+
- > 120% of limit → FAIL
|
|
64
|
+
|
|
65
|
+
### Step 4: Update STATE.md
|
|
66
|
+
|
|
67
|
+
```markdown
|
|
68
|
+
## Current Position
|
|
69
|
+
- Phase: REVIEW
|
|
70
|
+
- Status: Bundle analysis complete — {PASS|WARNING|FAIL}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### `/frame:performance audit` -- Full Performance Audit
|
|
76
|
+
|
|
77
|
+
### Step 0: Validate prerequisites
|
|
78
|
+
|
|
79
|
+
Check `.frame/config.json` exists:
|
|
80
|
+
```bash
|
|
81
|
+
test -f .frame/config.json || echo "MISSING"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If missing → **STOP**:
|
|
85
|
+
```
|
|
86
|
+
❌ .frame/config.json not found. Run /frame:init first.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Step 1: Update STATE.md
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
## Current Position
|
|
93
|
+
- Phase: REVIEW
|
|
94
|
+
- Status: Performance audit IN_PROGRESS
|
|
95
|
+
- Started: {timestamp}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Step 2: Bundle analysis
|
|
99
|
+
|
|
100
|
+
Run all steps from `/frame:performance bundle`.
|
|
101
|
+
|
|
102
|
+
**Heartbeat**: Output after each sub-step completes — build, size scan, comparison.
|
|
103
|
+
|
|
104
|
+
### Step 3: Runtime metrics
|
|
105
|
+
|
|
106
|
+
Check for available tools:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Lighthouse CLI (if installed)
|
|
110
|
+
npx lighthouse {url} --output=json --quiet 2>/dev/null | grep -E '"score"|"numericValue"' | head -20
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Heartbeat**: If Lighthouse takes > 30s — output: `Lighthouse running... ({url})`
|
|
114
|
+
|
|
115
|
+
If Lighthouse is unavailable — note in report: "Check manually in Chrome DevTools → Lighthouse".
|
|
116
|
+
|
|
117
|
+
Target values:
|
|
118
|
+
- CLS < 0.1
|
|
119
|
+
- INP < 200ms
|
|
120
|
+
- LCP < 2.5s
|
|
121
|
+
- Lighthouse Performance > 90
|
|
122
|
+
|
|
123
|
+
### Step 4: Code review for performance anti-patterns
|
|
124
|
+
|
|
125
|
+
- No N+1 queries in critical paths
|
|
126
|
+
- No memory leaks (unclosed subscriptions, timers)
|
|
127
|
+
- Correct caching (HTTP headers, memoization)
|
|
128
|
+
- No blocking operations on the main thread
|
|
129
|
+
|
|
130
|
+
### Step 5: Create report
|
|
131
|
+
|
|
132
|
+
Create `.planning/reports/performance/performance-{date}.md`:
|
|
133
|
+
|
|
134
|
+
```markdown
|
|
135
|
+
# Performance Report -- {date}
|
|
136
|
+
|
|
137
|
+
## Status: PASS | WARNING | FAIL
|
|
138
|
+
|
|
139
|
+
## Bundle
|
|
140
|
+
- Size: {size} / {maxBundleSize}
|
|
141
|
+
- First Load JS: {size} / {maxFirstLoadJS}
|
|
142
|
+
- Level: PASS | WARNING | FAIL
|
|
143
|
+
|
|
144
|
+
## Runtime Metrics
|
|
145
|
+
- CLS: {score} / 0.1 — {PASS|FAIL|not checked}
|
|
146
|
+
- INP: {ms} / 200ms — {PASS|FAIL|not checked}
|
|
147
|
+
- LCP: {ms} / 2500ms — {PASS|FAIL|not checked}
|
|
148
|
+
- Lighthouse: {score} / 90 — {PASS|FAIL|not checked}
|
|
149
|
+
|
|
150
|
+
## Anti-patterns
|
|
151
|
+
- {issues found or "none detected"}
|
|
152
|
+
|
|
153
|
+
## Enforce Level: {strict|warning|advisory}
|
|
154
|
+
|
|
155
|
+
## Recommendations
|
|
156
|
+
- {specific optimization suggestions}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Step 6: Update memory files
|
|
160
|
+
|
|
161
|
+
If anti-patterns were found in Step 4:
|
|
162
|
+
- Add to `.planning/memory/anti-patterns.md`: each issue with context
|
|
163
|
+
|
|
164
|
+
If new optimization patterns were confirmed:
|
|
165
|
+
- Add to `.planning/memory/patterns.md`: the pattern and why it worked
|
|
166
|
+
|
|
167
|
+
### Step 7: Update STATE.md
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
## Current Position
|
|
171
|
+
- Phase: REVIEW
|
|
172
|
+
- Status: Performance audit complete — {PASS|WARNING|FAIL}
|
|
173
|
+
- Report: .planning/reports/performance/performance-{date}.md
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### `/frame:performance check` -- Quick Check
|
|
179
|
+
|
|
180
|
+
Quick bundle size check without full audit.
|
|
181
|
+
|
|
182
|
+
### Step 0: Validate prerequisites
|
|
183
|
+
|
|
184
|
+
Check `.frame/config.json` exists:
|
|
185
|
+
```bash
|
|
186
|
+
test -f .frame/config.json || echo "MISSING"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
If missing → **STOP**:
|
|
190
|
+
```
|
|
191
|
+
❌ .frame/config.json not found. Run /frame:init first.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Update STATE.md:
|
|
195
|
+
```markdown
|
|
196
|
+
## Current Position
|
|
197
|
+
- Phase: REVIEW
|
|
198
|
+
- Status: Quick performance check IN_PROGRESS
|
|
199
|
+
- Started: {timestamp}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Step 1: Check
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
{quality.commands.build} 2>&1 | grep -E "(Bundle|First Load|chunk|dist|kB|KB)"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Compare output against limits from `.frame/config.json` → `performance` and output: PASS / WARNING / FAIL.
|
|
209
|
+
|
|
210
|
+
### Step 2: Update STATE.md
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
## Current Position
|
|
214
|
+
- Phase: REVIEW
|
|
215
|
+
- Status: Quick performance check complete — {PASS|WARNING|FAIL}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Enforce Levels
|
|
221
|
+
|
|
222
|
+
| Level | Behavior |
|
|
223
|
+
|-------|----------|
|
|
224
|
+
| strict | > limit = BLOCKED, cannot Ship |
|
|
225
|
+
| warning | > limit = WARNING, can Ship |
|
|
226
|
+
| advisory | > limit = INFO, does not block |
|
|
227
|
+
|
|
228
|
+
Default: `warning`
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# /frame:plan -- Feature Planning
|
|
2
|
+
|
|
3
|
+
Takes research.md, validates it, reads memory, breaks into atomic tasks with complexity, risk, dependencies and waves.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
Plan the feature: **$ARGUMENTS**
|
|
8
|
+
|
|
9
|
+
### Step 0: Checkpoint
|
|
10
|
+
|
|
11
|
+
Create git tag before the phase:
|
|
12
|
+
```bash
|
|
13
|
+
git tag "frame/checkpoint/plan-$(date +%Y%m%dT%H%M%S)" -m "Auto checkpoint before plan phase"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Update `.planning/STATE.md` — phase started:
|
|
17
|
+
```markdown
|
|
18
|
+
- Phase: PLAN
|
|
19
|
+
- Feature: {feature}
|
|
20
|
+
- Status: IN_PROGRESS
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Step 1: Find and read research.md
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
find docs/specs -name "research.md" | head -5
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Read `docs/specs/{feature}/research.md`.
|
|
30
|
+
|
|
31
|
+
### Step 1.1: Validate research.md (fail-fast)
|
|
32
|
+
|
|
33
|
+
Check for required sections:
|
|
34
|
+
- `## Requirements`
|
|
35
|
+
- `## Architecture`
|
|
36
|
+
- `## API Design`
|
|
37
|
+
|
|
38
|
+
**If any section is missing — STOP.** Do not begin decomposition. Report:
|
|
39
|
+
|
|
40
|
+
> "research.md is incomplete, missing: {sections}. Run /frame:research again or add sections manually."
|
|
41
|
+
|
|
42
|
+
### Step 1.2: Read Memory Impact from research.md
|
|
43
|
+
|
|
44
|
+
Find the **Memory Impact** section in research.md and extract:
|
|
45
|
+
- Which patterns will be affected/created
|
|
46
|
+
- Which dependencies will appear
|
|
47
|
+
- Which focus will shift
|
|
48
|
+
- Which conventions are affected
|
|
49
|
+
|
|
50
|
+
This is the Researcher's decision context — why this approach was chosen, which alternatives were rejected.
|
|
51
|
+
|
|
52
|
+
### Step 2: Read MAP.md
|
|
53
|
+
|
|
54
|
+
Read `.planning/MAP.md` to understand:
|
|
55
|
+
- Current project architecture
|
|
56
|
+
- File structure
|
|
57
|
+
- Key patterns and constraints
|
|
58
|
+
|
|
59
|
+
### Step 3: Read memory files
|
|
60
|
+
|
|
61
|
+
Read in the following order with restrictions:
|
|
62
|
+
|
|
63
|
+
| File | What to read | Why |
|
|
64
|
+
|------|-------------|-----|
|
|
65
|
+
| `.planning/memory/context.md` | Entire file (**first**) | Current focus and blockers |
|
|
66
|
+
| `.planning/memory/patterns.md` | **Core section only** | Established patterns (confidence: high or medium with 3+ confirmations) |
|
|
67
|
+
| `.planning/memory/conventions.md` | Entire file | Code conventions for tasks |
|
|
68
|
+
| `.planning/memory/dependencies.md` | Entire file + **Avoid list** | Don't propose rejected tools |
|
|
69
|
+
|
|
70
|
+
**Important**: Core patterns only — experimental ones (confidence: low/medium without confirmations) are not reliable enough for planning.
|
|
71
|
+
|
|
72
|
+
### Step 4: Decompose into atomic tasks
|
|
73
|
+
|
|
74
|
+
**Heartbeat**: after every 5 tasks report: "Decomposition: {N} tasks created, continuing..."
|
|
75
|
+
|
|
76
|
+
Break the specification into tasks. Each task must be **atomic**: Files Changed ≤ 3, Complexity ≤ medium.
|
|
77
|
+
|
|
78
|
+
If a task is too large (Files Changed > 3 or Complexity: high) — split it.
|
|
79
|
+
|
|
80
|
+
**Risk definition:**
|
|
81
|
+
|
|
82
|
+
| Risk | Criteria |
|
|
83
|
+
|------|----------|
|
|
84
|
+
| `low` | 1-2 files, no cross-module dependencies |
|
|
85
|
+
| `medium` | 3-5 files or touches public APIs |
|
|
86
|
+
| `high` | 5+ files, touches core logic or routing |
|
|
87
|
+
|
|
88
|
+
### Step 5: Define dependencies
|
|
89
|
+
|
|
90
|
+
For each task: if task B uses the result of task A (file, type, function) — B depends on A.
|
|
91
|
+
|
|
92
|
+
### Step 6: Group into waves
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Wave 1: Tasks with no dependencies (parallel)
|
|
96
|
+
Wave 2: Tasks depending on Wave 1
|
|
97
|
+
Wave 3: Tasks depending on Wave 2
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Rules:
|
|
101
|
+
- Maximum 5 tasks per wave
|
|
102
|
+
- Two tasks in the same wave cannot modify the same file
|
|
103
|
+
- Each task knows its wave
|
|
104
|
+
|
|
105
|
+
### Step 7: Check file conflicts
|
|
106
|
+
|
|
107
|
+
Final check: no two tasks in the same wave modify the same file. On conflict — merge tasks or move to different waves.
|
|
108
|
+
|
|
109
|
+
### Step 8: Create spec.md and plan.md
|
|
110
|
+
|
|
111
|
+
Create `docs/specs/{feature}/spec.md` (transform research.md into a concrete specification).
|
|
112
|
+
|
|
113
|
+
Create `docs/specs/{feature}/plan.md`:
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
# Plan: {Feature}
|
|
117
|
+
|
|
118
|
+
## Overview
|
|
119
|
+
{Brief description of the plan}
|
|
120
|
+
|
|
121
|
+
## Waves
|
|
122
|
+
|
|
123
|
+
### Wave 1: {name}
|
|
124
|
+
Tasks with no dependencies (parallel):
|
|
125
|
+
- Task 1
|
|
126
|
+
- Task 2
|
|
127
|
+
|
|
128
|
+
### Wave 2: {name}
|
|
129
|
+
Tasks depending on Wave 1:
|
|
130
|
+
- Task 3
|
|
131
|
+
|
|
132
|
+
## Tasks
|
|
133
|
+
|
|
134
|
+
### Task 1: {name}
|
|
135
|
+
- Files: `path/to/file.ts`
|
|
136
|
+
- Files Changed: 2
|
|
137
|
+
- Complexity: low
|
|
138
|
+
- Risk: low
|
|
139
|
+
- Estimate: {time estimate, e.g. 30min / 1h / 2h}
|
|
140
|
+
- Wave: 1
|
|
141
|
+
- Test: `path/to/file.test.ts`
|
|
142
|
+
- Dependencies: NONE
|
|
143
|
+
- Verification: `{quality.commands.test} path/to/file.test.ts`
|
|
144
|
+
- Status: [ ]
|
|
145
|
+
|
|
146
|
+
### Task 2: {name}
|
|
147
|
+
- Files: `path/to/other.ts`, `path/to/another.ts`
|
|
148
|
+
- Files Changed: 2
|
|
149
|
+
- Complexity: medium
|
|
150
|
+
- Risk: medium
|
|
151
|
+
- Estimate: {time estimate, e.g. 30min / 1h / 2h}
|
|
152
|
+
- Wave: 2
|
|
153
|
+
- Test: `path/to/other.test.ts`
|
|
154
|
+
- Dependencies: Task 1
|
|
155
|
+
- Verification: `{quality.commands.test} path/to/other.test.ts`
|
|
156
|
+
- Status: [ ]
|
|
157
|
+
|
|
158
|
+
## Exit Criteria
|
|
159
|
+
- [ ] `{quality.commands.typecheck}` passes with 0 errors
|
|
160
|
+
- [ ] `{quality.commands.test}` — all tests pass
|
|
161
|
+
- [ ] All tasks marked [DONE] in plan.md
|
|
162
|
+
- [ ] STATE.md: Phase: BUILD, Status: complete
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 9: Update STATE.md
|
|
166
|
+
|
|
167
|
+
Update `.planning/STATE.md`:
|
|
168
|
+
```markdown
|
|
169
|
+
## Current Position
|
|
170
|
+
- Phase: PLAN
|
|
171
|
+
- Feature: {feature}
|
|
172
|
+
- Task: 0/{total}
|
|
173
|
+
- Status: COMPLETE — plan created, {total} tasks in {waves} waves
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Step 10: Report result
|
|
177
|
+
|
|
178
|
+
Show the user:
|
|
179
|
+
- Number of tasks and waves
|
|
180
|
+
- Tasks with Risk: high (if any)
|
|
181
|
+
- Next step: `/frame:build` (sequential) or `/frame:wave` (parallel)
|
|
182
|
+
|
|
183
|
+
## Rules
|
|
184
|
+
|
|
185
|
+
- **Fail-fast on research.md** — don't plan on incomplete data
|
|
186
|
+
- **Core patterns only** — don't trust experimental ones
|
|
187
|
+
- **Avoid list** — don't propose rejected tools
|
|
188
|
+
- **Atomic tasks** — Files Changed ≤ 3, Complexity ≤ medium
|
|
189
|
+
- **Risk on every task** — Builder must see risks upfront
|
|
190
|
+
- **Test on every task** — every task is verified
|
|
191
|
+
- **No file conflicts** within one wave
|
|
192
|
+
- **Never edit code** — only create spec.md and plan.md
|
|
193
|
+
|
|
194
|
+
## Result
|
|
195
|
+
|
|
196
|
+
- `docs/specs/{feature}/spec.md` — specification
|
|
197
|
+
- `docs/specs/{feature}/plan.md` — plan with tasks
|
|
198
|
+
- `.planning/STATE.md` updated
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# /frame:refactor -- Refactoring with Test Coverage
|
|
2
|
+
|
|
3
|
+
Analyzes an area, plans the refactor, executes with TDD, checks quality gates.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
Refactor: **$ARGUMENTS**
|
|
8
|
+
|
|
9
|
+
### Step 0: Checkpoint + Update STATE.md (IN_PROGRESS)
|
|
10
|
+
|
|
11
|
+
Create checkpoint before starting:
|
|
12
|
+
```bash
|
|
13
|
+
git tag "frame/checkpoint/refactor-$(date +%s)" -m "Auto checkpoint before refactor"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Update `.planning/STATE.md` before any work:
|
|
17
|
+
```markdown
|
|
18
|
+
## Current Position
|
|
19
|
+
- Phase: REFACTOR
|
|
20
|
+
- Feature: {area}
|
|
21
|
+
- Status: IN_PROGRESS
|
|
22
|
+
- Started: {timestamp}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Step 1: Read Context
|
|
26
|
+
|
|
27
|
+
Read before refactoring:
|
|
28
|
+
- `.planning/memory/patterns.md` — Core + Active patterns (what to follow)
|
|
29
|
+
- `.planning/memory/anti-patterns.md` — what to avoid
|
|
30
|
+
- `docs/specs/{feature}/research.md` — **Memory Impact** section (if exists)
|
|
31
|
+
|
|
32
|
+
### Step 2: Baseline Metrics
|
|
33
|
+
|
|
34
|
+
Before any changes, record:
|
|
35
|
+
- Number of files in the area
|
|
36
|
+
- Current test coverage (if available)
|
|
37
|
+
- LOC of key files
|
|
38
|
+
- List of public exports (to detect breaking changes)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
grep -r "export " {area} | wc -l
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Step 3: Analyze the area
|
|
45
|
+
|
|
46
|
+
1. **Find related files**:
|
|
47
|
+
- `grep -r "{area}" | head -20`
|
|
48
|
+
- Map the dependency graph
|
|
49
|
+
|
|
50
|
+
2. **Assess current state**:
|
|
51
|
+
- How many files?
|
|
52
|
+
- Are there tests?
|
|
53
|
+
- What is the coverage?
|
|
54
|
+
|
|
55
|
+
3. **Identify problems**:
|
|
56
|
+
- Code smells
|
|
57
|
+
- Duplication
|
|
58
|
+
- Tight coupling
|
|
59
|
+
- Missing tests
|
|
60
|
+
|
|
61
|
+
### Step 4: Plan the refactor
|
|
62
|
+
|
|
63
|
+
Create a plan as a table:
|
|
64
|
+
|
|
65
|
+
| File | What changes | Test | Risk |
|
|
66
|
+
|------|-------------|------|------|
|
|
67
|
+
| ... | ... | ... | low/medium/high |
|
|
68
|
+
|
|
69
|
+
Order: least risky changes first.
|
|
70
|
+
|
|
71
|
+
### Step 5: TDD Refactor
|
|
72
|
+
|
|
73
|
+
For each change:
|
|
74
|
+
|
|
75
|
+
1. **Write a test** (if none exists):
|
|
76
|
+
- Define expected behavior
|
|
77
|
+
- **D-step**: Test should FAIL (RED)
|
|
78
|
+
|
|
79
|
+
2. **Refactor the code**:
|
|
80
|
+
- Minimal changes
|
|
81
|
+
- Do not change behavior
|
|
82
|
+
- **D-step**: Test should PASS (GREEN)
|
|
83
|
+
|
|
84
|
+
3. **Repeat** until refactor is complete
|
|
85
|
+
|
|
86
|
+
#### Stuck Detection
|
|
87
|
+
|
|
88
|
+
If after **3 attempts** the test does not reach GREEN:
|
|
89
|
+
1. Stop
|
|
90
|
+
2. Update STATE.md: `Status: STUCK, Task: {change}`
|
|
91
|
+
3. Report to user: what was tried, where stuck, suggest:
|
|
92
|
+
- Simplify the change
|
|
93
|
+
- Rewrite the test
|
|
94
|
+
- Skip with `[BLOCKED]` flag
|
|
95
|
+
|
|
96
|
+
### Step 6: Check for Breaking Changes
|
|
97
|
+
|
|
98
|
+
Compare public API before and after:
|
|
99
|
+
```bash
|
|
100
|
+
grep -r "export " {area} | sort > after-exports.txt
|
|
101
|
+
# compare with baseline from Step 2
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If signatures changed — that is a breaking change and requires an explicit decision.
|
|
105
|
+
|
|
106
|
+
### Step 7: Quality Gates
|
|
107
|
+
|
|
108
|
+
Determine commands from the project config:
|
|
109
|
+
- If `package.json` exists → use `npm test`, `npm run lint`, `npm run typecheck`
|
|
110
|
+
- If TypeScript → `npx tsc --noEmit`
|
|
111
|
+
- If vitest → `npx vitest run`
|
|
112
|
+
- If jest → `npx jest`
|
|
113
|
+
- If eslint → `npx eslint .`
|
|
114
|
+
|
|
115
|
+
Run all applicable checks. **D-step**: All checks must pass.
|
|
116
|
+
|
|
117
|
+
If checks fail — **do not commit**. Roll back changes:
|
|
118
|
+
```bash
|
|
119
|
+
git stash
|
|
120
|
+
# or for specific files:
|
|
121
|
+
git checkout -- {file}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Step 8: Git Commit
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git add {specific files from the plan}
|
|
128
|
+
git commit -m "refactor({scope}): {description}"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Step 9: Update Memory + STATE.md
|
|
132
|
+
|
|
133
|
+
Update `.planning/memory/patterns.md` if a new good pattern was confirmed.
|
|
134
|
+
Update `.planning/memory/anti-patterns.md` if a problem was found and fixed.
|
|
135
|
+
|
|
136
|
+
Update `.planning/STATE.md`:
|
|
137
|
+
```markdown
|
|
138
|
+
## Current Position
|
|
139
|
+
- Phase: REFACTOR
|
|
140
|
+
- Feature: {area}
|
|
141
|
+
- Status: COMPLETE
|
|
142
|
+
- Finished: {timestamp}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Rules
|
|
146
|
+
|
|
147
|
+
- **Behavior preservation** -- do not change behavior
|
|
148
|
+
- **Test coverage** -- increase coverage
|
|
149
|
+
- **Incremental** -- small steps
|
|
150
|
+
- **Quality gates** -- read from project config, do not hardcode
|
|
151
|
+
- **Rollback** -- if gates fail, roll back, do not commit broken code
|
|
152
|
+
- **Never skip D-steps** -- every step is verified
|
|
153
|
+
|
|
154
|
+
## Result
|
|
155
|
+
|
|
156
|
+
- Baseline recorded, improvement is measurable
|
|
157
|
+
- Code refactored without breaking changes
|
|
158
|
+
- Test coverage increased
|
|
159
|
+
- Quality gates passed
|
|
160
|
+
- Memory files updated
|
|
161
|
+
- Git commit created
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# /frame:research -- Domain Research
|
|
2
|
+
|
|
3
|
+
Analyzes the request, searches for alternatives, explores the codebase, creates research.md with Memory Impact.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
Research the following topic: **$ARGUMENTS**
|
|
8
|
+
|
|
9
|
+
> Use the `researcher` agent for this task. It runs with a fresh context window (200K) to avoid contamination from previous phases.
|
|
10
|
+
|
|
11
|
+
### Step 0: Fail-fast validation
|
|
12
|
+
|
|
13
|
+
**Before doing anything**, check:
|
|
14
|
+
- `$ARGUMENTS` is not empty — if empty, STOP and ask: "What topic should I research? Usage: /frame:research <topic>"
|
|
15
|
+
- `.planning/MAP.md` exists — if missing, STOP: "Run /frame:init first — MAP.md not found."
|
|
16
|
+
|
|
17
|
+
Then immediately write to `.planning/STATE.md`:
|
|
18
|
+
```markdown
|
|
19
|
+
## Current Position
|
|
20
|
+
- Phase: RESEARCH
|
|
21
|
+
- Feature: {topic from $ARGUMENTS}
|
|
22
|
+
- Status: IN_PROGRESS
|
|
23
|
+
- Started: {timestamp}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Step 1: Analyze the Request
|
|
27
|
+
|
|
28
|
+
Determine:
|
|
29
|
+
- What exactly needs to be researched
|
|
30
|
+
- What alternatives may exist
|
|
31
|
+
- Constraints: tech, time, budget
|
|
32
|
+
|
|
33
|
+
### Step 2: Codebase Exploration
|
|
34
|
+
|
|
35
|
+
Read in this order:
|
|
36
|
+
|
|
37
|
+
1. `.planning/MAP.md` — project architecture (stack, patterns, key directories). **Must be first.**
|
|
38
|
+
2. `.planning/memory/context.md` — current focus and blockers
|
|
39
|
+
3. Grep the codebase: `grep -r "{keywords}" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.py" | head -20`
|
|
40
|
+
4. Memory files (with staleness check):
|
|
41
|
+
- `.planning/memory/patterns.md` — **ignore entries flagged [stale]**
|
|
42
|
+
- `.planning/memory/decisions.md` — **decisions older than 6 months are context, not constraints**
|
|
43
|
+
- `.planning/memory/dependencies.md` — current stack and Avoid list
|
|
44
|
+
|
|
45
|
+
**Heartbeat**: after reading memory files, report: "Context loaded, starting web research..."
|
|
46
|
+
|
|
47
|
+
### Step 3: Web Research
|
|
48
|
+
|
|
49
|
+
WebSearch is **required** if at least one condition is met:
|
|
50
|
+
- Topic involves external APIs/libraries (versions, limits, pricing)
|
|
51
|
+
- No entry for the topic in `dependencies.md`
|
|
52
|
+
- No relevant pattern in `patterns.md`
|
|
53
|
+
|
|
54
|
+
WebSearch is **not needed** only if:
|
|
55
|
+
- Topic is about internal architecture (own code, own patterns)
|
|
56
|
+
- Pattern already exists in memory with `confidence: high`
|
|
57
|
+
|
|
58
|
+
Check: alternative libraries, latest versions, limits, best practices.
|
|
59
|
+
|
|
60
|
+
**Heartbeat**: after web research, report: "Research complete, writing research.md..."
|
|
61
|
+
|
|
62
|
+
### Step 4: Create research.md
|
|
63
|
+
|
|
64
|
+
Create `docs/specs/{topic}/research.md`:
|
|
65
|
+
|
|
66
|
+
```markdown
|
|
67
|
+
# Research: {Topic}
|
|
68
|
+
|
|
69
|
+
## Overview
|
|
70
|
+
{Brief description of what is being researched}
|
|
71
|
+
|
|
72
|
+
## Current State
|
|
73
|
+
{What already exists in the project}
|
|
74
|
+
|
|
75
|
+
## Alternatives
|
|
76
|
+
|
|
77
|
+
### Option 1: {name}
|
|
78
|
+
- **Pros**: {advantages}
|
|
79
|
+
- **Cons**: {disadvantages}
|
|
80
|
+
- **Effort**: {estimate}
|
|
81
|
+
- **Risk**: {risks}
|
|
82
|
+
|
|
83
|
+
### Option 2: {name}
|
|
84
|
+
- **Pros**: {advantages}
|
|
85
|
+
- **Cons**: {disadvantages}
|
|
86
|
+
- **Effort**: {estimate}
|
|
87
|
+
- **Risk**: {risks}
|
|
88
|
+
|
|
89
|
+
## Recommendation
|
|
90
|
+
{Recommendation with justification}
|
|
91
|
+
|
|
92
|
+
## Requirements
|
|
93
|
+
- {functional requirement 1}
|
|
94
|
+
- {functional requirement 2}
|
|
95
|
+
|
|
96
|
+
## Architecture
|
|
97
|
+
{High-level description of the chosen approach}
|
|
98
|
+
|
|
99
|
+
## API Design
|
|
100
|
+
{Key interfaces, endpoints, or data structures}
|
|
101
|
+
|
|
102
|
+
## References
|
|
103
|
+
- {links to documentation}
|
|
104
|
+
|
|
105
|
+
## Memory Impact
|
|
106
|
+
<!-- Retrospective reads this section to decide what to persist. Fill it now while context is fresh. -->
|
|
107
|
+
- patterns.md: {proposed pattern if found, otherwise "none"}
|
|
108
|
+
- decisions.md: {proposed decision if made, otherwise "none"}
|
|
109
|
+
- dependencies.md: {new dependencies if any, otherwise "none"}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Rule**: minimum 2 alternatives. Research without alternatives is incomplete.
|
|
113
|
+
|
|
114
|
+
**Do not create spec.md** — that is the responsibility of `/frame:plan`.
|
|
115
|
+
|
|
116
|
+
### Step 5: Update STATE.md (phase complete)
|
|
117
|
+
|
|
118
|
+
```markdown
|
|
119
|
+
## Current Position
|
|
120
|
+
- Phase: RESEARCH
|
|
121
|
+
- Feature: {topic}
|
|
122
|
+
- Status: COMPLETE
|
|
123
|
+
- Started: {timestamp from step 0}
|
|
124
|
+
- Completed: {timestamp}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Result
|
|
128
|
+
|
|
129
|
+
- `docs/specs/{topic}/research.md` — research findings with Memory Impact
|
|
130
|
+
- `.planning/STATE.md` updated (COMPLETE)
|
|
131
|
+
- Next phase: `/frame:plan` (takes research.md as input, creates spec.md and plan.md)
|