@atlashub/smartstack-cli 2.7.3 → 2.7.4
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/.documentation/agents.html +0 -4
- package/.documentation/business-analyse.html +0 -4
- package/.documentation/cli-commands.html +0 -4
- package/.documentation/commands.html +0 -77
- package/.documentation/css/styles.css +0 -8
- package/.documentation/efcore.html +0 -4
- package/.documentation/gitflow.html +0 -4
- package/.documentation/hooks.html +0 -4
- package/.documentation/index.html +2 -28
- package/.documentation/init.html +8 -14
- package/.documentation/installation.html +0 -11
- package/.documentation/js/app.js +2 -16
- package/.documentation/ralph-loop.html +0 -4
- package/.documentation/test-web.html +0 -4
- package/README.md +0 -1
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/templates/agents/docs-sync-checker.md +2 -2
- package/templates/hooks/docs-drift-check.md +4 -5
- package/templates/skills/_resources/context-digest-template.md +2 -2
- package/templates/skills/_resources/doc-context-cache.md +0 -2
- package/templates/skills/_resources/docs-manifest-schema.md +1 -3
- package/templates/skills/_resources/mcp-validate-documentation-spec.md +1 -3
- package/templates/skills/_shared.md +24 -25
- package/templates/skills/application/steps/step-04-backend.md +185 -11
- package/templates/skills/application/steps/step-06-migration.md +41 -2
- package/templates/skills/application/templates-seed.md +151 -0
- package/templates/skills/business-analyse/steps/step-05-handoff.md +59 -17
- package/templates/skills/controller/steps/step-01-analyze.md +1 -1
- package/templates/skills/ralph-loop/steps/step-01-task.md +21 -1
- package/templates/skills/ralph-loop/steps/step-02-execute.md +75 -3
- package/.documentation/apex.html +0 -1027
- package/templates/skills/apex/SKILL.md +0 -297
- package/templates/skills/apex/steps/step-00-init.md +0 -212
- package/templates/skills/apex/steps/step-01-analyze.md +0 -263
- package/templates/skills/apex/steps/step-02-plan.md +0 -255
- package/templates/skills/apex/steps/step-03-execute.md +0 -217
- package/templates/skills/apex/steps/step-04-validate.md +0 -273
- package/templates/skills/apex/steps/step-04b-doc-sync.md +0 -162
- package/templates/skills/apex/steps/step-05-examine.md +0 -214
- package/templates/skills/apex/steps/step-06-resolve.md +0 -181
- package/templates/skills/apex/steps/step-07-tests.md +0 -206
- package/templates/skills/apex/steps/step-08-run-tests.md +0 -207
- package/templates/skills/apex/templates/00-context.md +0 -46
- package/templates/skills/apex/templates/01-analyze.md +0 -63
- package/templates/skills/apex/templates/02-plan.md +0 -63
- package/templates/skills/apex/templates/03-execute.md +0 -34
- package/templates/skills/apex/templates/04-validate.md +0 -61
- package/templates/skills/apex/templates/04b-doc-sync.md +0 -31
- package/templates/skills/apex/templates/05-examine.md +0 -58
- package/templates/skills/apex/templates/06-resolve.md +0 -39
- package/templates/skills/apex/templates/07-tests.md +0 -56
- package/templates/skills/apex/templates/08-run-tests.md +0 -41
- package/templates/skills/apex/templates/README.md +0 -69
- package/templates/skills/apex/templates/context-digest.md +0 -35
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-05-examine
|
|
3
|
-
description: Adversarial code review - security, logic, and quality analysis
|
|
4
|
-
prev_step: steps/step-04-validate.md
|
|
5
|
-
next_step: steps/step-06-resolve.md
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Step 5: Examine (Adversarial Review)
|
|
9
|
-
|
|
10
|
-
## MANDATORY EXECUTION RULES:
|
|
11
|
-
|
|
12
|
-
- NEVER skip security review
|
|
13
|
-
- NEVER dismiss findings without justification
|
|
14
|
-
- NEVER auto-approve without thorough review
|
|
15
|
-
- ALWAYS check OWASP top 10 vulnerabilities
|
|
16
|
-
- ALWAYS classify findings by severity and validity
|
|
17
|
-
- ALWAYS present findings table to user
|
|
18
|
-
- YOU ARE A SKEPTICAL REVIEWER, not a defender
|
|
19
|
-
- FORBIDDEN to approve without thorough analysis
|
|
20
|
-
|
|
21
|
-
## YOUR TASK:
|
|
22
|
-
|
|
23
|
-
Conduct an adversarial code review to identify security vulnerabilities, logic flaws, and quality issues.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
<available_state>
|
|
28
|
-
From previous steps:
|
|
29
|
-
|
|
30
|
-
| Variable | Description |
|
|
31
|
-
|----------|-------------|
|
|
32
|
-
| `{task_description}` | What was implemented |
|
|
33
|
-
| `{task_id}` | Kebab-case identifier |
|
|
34
|
-
| `{auto_mode}` | Auto-fix Real findings |
|
|
35
|
-
| `{save_mode}` | Save outputs to files |
|
|
36
|
-
| `{economy_mode}` | No subagents, direct review |
|
|
37
|
-
| `{output_dir}` | Path to output (if save_mode) |
|
|
38
|
-
| Files modified | From step-03 |
|
|
39
|
-
</available_state>
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## EXECUTION SEQUENCE:
|
|
44
|
-
|
|
45
|
-
### 1. Gather Changes
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
git diff --name-only HEAD~1
|
|
49
|
-
git status --porcelain
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Group files: source, tests, config, other.
|
|
53
|
-
|
|
54
|
-
### 2. Conduct Review
|
|
55
|
-
|
|
56
|
-
**If `{economy_mode}` = true:**
|
|
57
|
-
|
|
58
|
-
Self-review with checklist:
|
|
59
|
-
|
|
60
|
-
```markdown
|
|
61
|
-
## Security Checklist
|
|
62
|
-
- [ ] No SQL injection (parameterized queries)
|
|
63
|
-
- [ ] No XSS (output encoding)
|
|
64
|
-
- [ ] No secrets in code
|
|
65
|
-
- [ ] Input validation present
|
|
66
|
-
- [ ] Auth checks on protected routes
|
|
67
|
-
|
|
68
|
-
## Logic Checklist
|
|
69
|
-
- [ ] Error handling for all failure modes
|
|
70
|
-
- [ ] Edge cases handled
|
|
71
|
-
- [ ] Null/undefined checks
|
|
72
|
-
- [ ] Race conditions considered
|
|
73
|
-
|
|
74
|
-
## Quality Checklist
|
|
75
|
-
- [ ] Follows existing patterns
|
|
76
|
-
- [ ] No code duplication
|
|
77
|
-
- [ ] Clear naming
|
|
78
|
-
|
|
79
|
-
## Documentation Checklist
|
|
80
|
-
- [ ] Documented modules updated (doc-data.ts reflects code changes)
|
|
81
|
-
- [ ] API endpoints reflected in documentation
|
|
82
|
-
- [ ] Documented permissions match code
|
|
83
|
-
- [ ] i18n keys added for new labels
|
|
84
|
-
- [ ] docs-manifest.json timestamps current
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**If `{economy_mode}` = false:**
|
|
88
|
-
|
|
89
|
-
Launch parallel review agents in a SINGLE message:
|
|
90
|
-
|
|
91
|
-
**Agent 1: Security** (`code-reviewer`)
|
|
92
|
-
```
|
|
93
|
-
Review for OWASP Top 10:
|
|
94
|
-
- Injection flaws
|
|
95
|
-
- Auth/authz issues
|
|
96
|
-
- Data exposure
|
|
97
|
-
- Security misconfiguration
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Agent 2: Logic** (`code-reviewer`)
|
|
101
|
-
```
|
|
102
|
-
Review for:
|
|
103
|
-
- Edge cases not handled
|
|
104
|
-
- Race conditions
|
|
105
|
-
- Null handling
|
|
106
|
-
- Incorrect logic
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
**Agent 3: Clean Code** (`code-reviewer`)
|
|
110
|
-
```
|
|
111
|
-
Review for:
|
|
112
|
-
- SOLID violations
|
|
113
|
-
- Code smells
|
|
114
|
-
- Complexity issues
|
|
115
|
-
- Duplication >20 lines
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 3. Classify Findings
|
|
119
|
-
|
|
120
|
-
For each finding:
|
|
121
|
-
|
|
122
|
-
**Severity:**
|
|
123
|
-
- CRITICAL: Security vulnerability, data loss risk
|
|
124
|
-
- HIGH: Significant bug, will cause issues
|
|
125
|
-
- MEDIUM: Should fix, not urgent
|
|
126
|
-
- LOW: Minor improvement
|
|
127
|
-
|
|
128
|
-
**Validity:**
|
|
129
|
-
- Real: Definitely needs fixing
|
|
130
|
-
- Noise: Not actually a problem
|
|
131
|
-
- Uncertain: Needs discussion
|
|
132
|
-
|
|
133
|
-
### 4. Present Findings Table
|
|
134
|
-
|
|
135
|
-
```markdown
|
|
136
|
-
## Findings
|
|
137
|
-
|
|
138
|
-
| ID | Severity | Category | Location | Issue | Validity |
|
|
139
|
-
|----|----------|----------|----------|-------|----------|
|
|
140
|
-
| F1 | CRITICAL | Security | auth.ts:42 | SQL injection | Real |
|
|
141
|
-
| F2 | HIGH | Logic | handler.ts:78 | Missing null check | Real |
|
|
142
|
-
| F3 | MEDIUM | Quality | utils.ts:15 | Complex function | Uncertain |
|
|
143
|
-
|
|
144
|
-
**Summary:** {count} findings ({blocking} blocking)
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### 5. Create Finding Todos
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
- [ ] F1 [CRITICAL] Fix SQL injection in auth.ts:42
|
|
151
|
-
- [ ] F2 [HIGH] Add null check in handler.ts:78
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 6. Save Output (if save_mode)
|
|
155
|
-
|
|
156
|
-
**If `{save_mode}` = true:**
|
|
157
|
-
|
|
158
|
-
Write to `{output_dir}/05-examine.md`:
|
|
159
|
-
- Findings table
|
|
160
|
-
- Checklist results
|
|
161
|
-
- Timestamp
|
|
162
|
-
- Update 00-context.md Progress table: 05-examine -> Complete
|
|
163
|
-
|
|
164
|
-
### 7. Get User Approval
|
|
165
|
-
|
|
166
|
-
**If `{auto_mode}` = true:**
|
|
167
|
-
Proceed automatically based on findings.
|
|
168
|
-
|
|
169
|
-
**If `{auto_mode}` = false:**
|
|
170
|
-
|
|
171
|
-
```yaml
|
|
172
|
-
questions:
|
|
173
|
-
- header: "Review"
|
|
174
|
-
question: "Review complete. How would you like to proceed?"
|
|
175
|
-
options:
|
|
176
|
-
- label: "Resolve findings (Recommended)"
|
|
177
|
-
description: "Address the identified issues"
|
|
178
|
-
- label: "Skip to tests"
|
|
179
|
-
description: "Skip resolution, proceed to test creation"
|
|
180
|
-
- label: "Skip resolution"
|
|
181
|
-
description: "Accept findings, don't make changes"
|
|
182
|
-
- label: "Discuss findings"
|
|
183
|
-
description: "I want to discuss specific findings"
|
|
184
|
-
multiSelect: false
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## SUCCESS METRICS:
|
|
190
|
-
|
|
191
|
-
- All modified files reviewed
|
|
192
|
-
- Security checklist completed
|
|
193
|
-
- Findings classified by severity
|
|
194
|
-
- Validity assessed for each finding
|
|
195
|
-
- Findings table presented
|
|
196
|
-
- Todos created for tracking
|
|
197
|
-
|
|
198
|
-
## FAILURE MODES:
|
|
199
|
-
|
|
200
|
-
- Skipping security review
|
|
201
|
-
- Not classifying by severity
|
|
202
|
-
- Auto-dismissing findings
|
|
203
|
-
- Launching agents sequentially
|
|
204
|
-
- Using subagents when economy_mode
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## NEXT STEP:
|
|
209
|
-
|
|
210
|
-
After user confirms (or auto-proceed):
|
|
211
|
-
|
|
212
|
-
- **If user chooses "Resolve findings":** Load `./step-06-resolve.md`
|
|
213
|
-
- **If user chooses "Skip to tests" (and test_mode):** Load `./step-07-tests.md`
|
|
214
|
-
- **If user chooses "Skip resolution":** Workflow complete - show summary
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-06-resolve
|
|
3
|
-
description: Resolve findings - interactively address review issues
|
|
4
|
-
prev_step: steps/step-05-examine.md
|
|
5
|
-
next_step: COMPLETE
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Step 6: Resolve Findings
|
|
9
|
-
|
|
10
|
-
## MANDATORY EXECUTION RULES:
|
|
11
|
-
|
|
12
|
-
- NEVER auto-fix Noise or Uncertain findings
|
|
13
|
-
- NEVER skip validation after fixes
|
|
14
|
-
- ALWAYS present resolution options to user (unless auto_mode)
|
|
15
|
-
- ALWAYS validate after applying fixes
|
|
16
|
-
- ALWAYS provide clear completion summary
|
|
17
|
-
- YOU ARE A RESOLVER, addressing identified issues
|
|
18
|
-
- FORBIDDEN to proceed with failing validation
|
|
19
|
-
|
|
20
|
-
## YOUR TASK:
|
|
21
|
-
|
|
22
|
-
Address adversarial review findings interactively - fix real issues, dismiss noise, discuss uncertain items.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
<available_state>
|
|
27
|
-
From previous steps:
|
|
28
|
-
|
|
29
|
-
| Variable | Description |
|
|
30
|
-
|----------|-------------|
|
|
31
|
-
| `{task_description}` | What was implemented |
|
|
32
|
-
| `{task_id}` | Kebab-case identifier |
|
|
33
|
-
| `{auto_mode}` | Auto-fix Real findings |
|
|
34
|
-
| `{save_mode}` | Save outputs to files |
|
|
35
|
-
| `{output_dir}` | Path to output (if save_mode) |
|
|
36
|
-
| Findings table | IDs, severity, validity |
|
|
37
|
-
| Finding todos | For tracking |
|
|
38
|
-
</available_state>
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## EXECUTION SEQUENCE:
|
|
43
|
-
|
|
44
|
-
### 1. Present Resolution Options
|
|
45
|
-
|
|
46
|
-
**If `{auto_mode}` = true:**
|
|
47
|
-
Auto-fix all "Real" findings, skip Noise/Uncertain.
|
|
48
|
-
|
|
49
|
-
**If `{auto_mode}` = false:**
|
|
50
|
-
|
|
51
|
-
```yaml
|
|
52
|
-
questions:
|
|
53
|
-
- header: "Resolution"
|
|
54
|
-
question: "How would you like to handle these findings?"
|
|
55
|
-
options:
|
|
56
|
-
- label: "Auto-fix Real issues (Recommended)"
|
|
57
|
-
description: "Fix 'Real' findings, skip noise/uncertain"
|
|
58
|
-
- label: "Walk through each finding"
|
|
59
|
-
description: "Decide on each finding individually"
|
|
60
|
-
- label: "Fix only critical"
|
|
61
|
-
description: "Only fix CRITICAL/BLOCKING issues"
|
|
62
|
-
- label: "Skip all"
|
|
63
|
-
description: "Acknowledge but don't change"
|
|
64
|
-
multiSelect: false
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 2. Apply Fixes Based on Choice
|
|
68
|
-
|
|
69
|
-
**Auto-fix Real:**
|
|
70
|
-
1. Filter to Real findings only
|
|
71
|
-
2. For each: Read file -> Apply fix -> Verify
|
|
72
|
-
3. Log each fix
|
|
73
|
-
|
|
74
|
-
**Walk through each:**
|
|
75
|
-
For each finding in severity order:
|
|
76
|
-
|
|
77
|
-
```yaml
|
|
78
|
-
questions:
|
|
79
|
-
- header: "F1"
|
|
80
|
-
question: "How should we handle this finding?"
|
|
81
|
-
options:
|
|
82
|
-
- label: "Fix now (Recommended)"
|
|
83
|
-
description: "Apply the suggested fix"
|
|
84
|
-
- label: "Skip"
|
|
85
|
-
description: "Acknowledge but don't fix"
|
|
86
|
-
- label: "Discuss"
|
|
87
|
-
description: "Need more context"
|
|
88
|
-
- label: "Mark as noise"
|
|
89
|
-
description: "Not a real issue"
|
|
90
|
-
multiSelect: false
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Fix only critical:**
|
|
94
|
-
1. Filter to CRITICAL/BLOCKING only
|
|
95
|
-
2. Auto-fix those, skip others
|
|
96
|
-
|
|
97
|
-
**Skip all:**
|
|
98
|
-
1. Acknowledge findings
|
|
99
|
-
2. If Critical/High exist, confirm user wants to proceed anyway
|
|
100
|
-
|
|
101
|
-
### 3. Post-Resolution Validation
|
|
102
|
-
|
|
103
|
-
After any fixes:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pnpm run typecheck && pnpm run lint
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Both MUST pass.
|
|
110
|
-
|
|
111
|
-
### 4. Resolution Summary
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
**Resolution Complete**
|
|
115
|
-
|
|
116
|
-
**Fixed:** {count}
|
|
117
|
-
- F1: Parameterized SQL query in auth.ts:42
|
|
118
|
-
- F2: Added null check in handler.ts:78
|
|
119
|
-
|
|
120
|
-
**Skipped:** {count}
|
|
121
|
-
- F3: Complex function (uncertain)
|
|
122
|
-
|
|
123
|
-
**Validation:** Pass
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### 5. Save Output (if save_mode)
|
|
127
|
-
|
|
128
|
-
**If `{save_mode}` = true:**
|
|
129
|
-
|
|
130
|
-
Write to `{output_dir}/06-resolve.md`:
|
|
131
|
-
- Resolution summary
|
|
132
|
-
- Fixes applied
|
|
133
|
-
- Timestamp
|
|
134
|
-
- Update 00-context.md Progress table: 06-resolve -> Complete
|
|
135
|
-
|
|
136
|
-
### 6. Completion Summary
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
**APEX Workflow Complete**
|
|
140
|
-
|
|
141
|
-
**Task:** {task_description}
|
|
142
|
-
|
|
143
|
-
**Implementation:**
|
|
144
|
-
- Files modified: {count}
|
|
145
|
-
- All checks passing: Yes
|
|
146
|
-
|
|
147
|
-
**Review:**
|
|
148
|
-
- Findings identified: {total}
|
|
149
|
-
- Findings resolved: {fixed}
|
|
150
|
-
- Findings skipped: {skipped}
|
|
151
|
-
|
|
152
|
-
**Next Steps:**
|
|
153
|
-
- [ ] Commit changes
|
|
154
|
-
- [ ] Run full test suite
|
|
155
|
-
- [ ] Deploy when ready
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## SUCCESS METRICS:
|
|
161
|
-
|
|
162
|
-
- User chose resolution approach
|
|
163
|
-
- All chosen fixes applied correctly
|
|
164
|
-
- Validation passes after fixes
|
|
165
|
-
- Clear summary of resolved/skipped
|
|
166
|
-
- User understands next steps
|
|
167
|
-
|
|
168
|
-
## FAILURE MODES:
|
|
169
|
-
|
|
170
|
-
- Auto-fixing Noise or Uncertain findings
|
|
171
|
-
- Not validating after fixes
|
|
172
|
-
- No clear completion summary
|
|
173
|
-
- Proceeding with failing validation
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## NEXT STEP:
|
|
178
|
-
|
|
179
|
-
Based on flags:
|
|
180
|
-
- **If test_mode:** Load `./step-07-tests.md`
|
|
181
|
-
- **Otherwise:** Workflow complete - show summary
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: step-07-tests
|
|
3
|
-
description: Test analysis and creation - identify gaps and write tests
|
|
4
|
-
prev_step: steps/step-04-validate.md
|
|
5
|
-
next_step: steps/step-08-run-tests.md
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Step 7: Tests (Analysis & Creation)
|
|
9
|
-
|
|
10
|
-
## MANDATORY EXECUTION RULES:
|
|
11
|
-
|
|
12
|
-
- NEVER skip test coverage analysis
|
|
13
|
-
- NEVER write tests without reading existing patterns
|
|
14
|
-
- ALWAYS identify untested code paths
|
|
15
|
-
- ALWAYS follow existing test patterns
|
|
16
|
-
- ALWAYS create meaningful assertions
|
|
17
|
-
- YOU ARE A TEST ENGINEER, ensuring quality
|
|
18
|
-
- FORBIDDEN to write redundant tests
|
|
19
|
-
|
|
20
|
-
## YOUR TASK:
|
|
21
|
-
|
|
22
|
-
Analyze test coverage for the implementation, identify gaps, and create comprehensive tests.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
<available_state>
|
|
27
|
-
From previous steps:
|
|
28
|
-
|
|
29
|
-
| Variable | Description |
|
|
30
|
-
|----------|-------------|
|
|
31
|
-
| `{task_description}` | What was implemented |
|
|
32
|
-
| `{task_id}` | Kebab-case identifier |
|
|
33
|
-
| `{auto_mode}` | Skip confirmations |
|
|
34
|
-
| `{save_mode}` | Save outputs to files |
|
|
35
|
-
| `{economy_mode}` | No subagents, direct tools |
|
|
36
|
-
| `{output_dir}` | Path to output (if save_mode) |
|
|
37
|
-
| Files modified | From step-03 |
|
|
38
|
-
</available_state>
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## EXECUTION SEQUENCE:
|
|
43
|
-
|
|
44
|
-
### 1. Analyze Existing Tests
|
|
45
|
-
|
|
46
|
-
**If `{economy_mode}` = true:**
|
|
47
|
-
|
|
48
|
-
Use direct tools:
|
|
49
|
-
1. Glob for test files: `**/*.test.ts`, `**/*.spec.ts`
|
|
50
|
-
2. Read 1-2 similar test files for patterns
|
|
51
|
-
3. Identify test framework (jest, vitest, etc.)
|
|
52
|
-
|
|
53
|
-
**If `{economy_mode}` = false:**
|
|
54
|
-
|
|
55
|
-
Launch exploration agent:
|
|
56
|
-
```
|
|
57
|
-
Analyze test structure for: {task_description}
|
|
58
|
-
|
|
59
|
-
Find:
|
|
60
|
-
1. Test file naming conventions
|
|
61
|
-
2. Test patterns used (describe/it, test())
|
|
62
|
-
3. Mocking patterns
|
|
63
|
-
4. Assertion style (expect, assert)
|
|
64
|
-
5. Coverage of similar features
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 2. Identify Test Gaps
|
|
68
|
-
|
|
69
|
-
For each modified file, determine:
|
|
70
|
-
|
|
71
|
-
```markdown
|
|
72
|
-
## Test Coverage Analysis
|
|
73
|
-
|
|
74
|
-
### `src/auth/handler.ts`
|
|
75
|
-
**Existing coverage:** 60%
|
|
76
|
-
**New code coverage:** 0%
|
|
77
|
-
|
|
78
|
-
**Untested paths:**
|
|
79
|
-
- [ ] `validateToken` happy path
|
|
80
|
-
- [ ] `validateToken` expired token error
|
|
81
|
-
- [ ] `validateToken` invalid signature error
|
|
82
|
-
|
|
83
|
-
### `src/api/auth/route.ts`
|
|
84
|
-
**Existing coverage:** 80%
|
|
85
|
-
**New code coverage:** 0%
|
|
86
|
-
|
|
87
|
-
**Untested paths:**
|
|
88
|
-
- [ ] POST endpoint with valid credentials
|
|
89
|
-
- [ ] POST endpoint with invalid credentials
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### 3. Plan Test Creation
|
|
93
|
-
|
|
94
|
-
```markdown
|
|
95
|
-
## Test Plan
|
|
96
|
-
|
|
97
|
-
### New Test Files
|
|
98
|
-
- `src/auth/__tests__/handler.test.ts`
|
|
99
|
-
- Test validateToken function
|
|
100
|
-
- 3 test cases planned
|
|
101
|
-
|
|
102
|
-
### Update Existing Tests
|
|
103
|
-
- `src/api/auth/__tests__/route.test.ts`
|
|
104
|
-
- Add integration tests for new endpoint
|
|
105
|
-
- 2 test cases planned
|
|
106
|
-
|
|
107
|
-
### Test Cases Summary
|
|
108
|
-
| File | Function | Test Case | Priority |
|
|
109
|
-
|------|----------|-----------|----------|
|
|
110
|
-
| handler.test.ts | validateToken | Valid token returns payload | High |
|
|
111
|
-
| handler.test.ts | validateToken | Expired token throws error | High |
|
|
112
|
-
| handler.test.ts | validateToken | Invalid signature throws | Medium |
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 4. Write Tests
|
|
116
|
-
|
|
117
|
-
Follow existing patterns:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
// Example pattern (adapt to project style)
|
|
121
|
-
describe('validateToken', () => {
|
|
122
|
-
it('should return payload for valid token', async () => {
|
|
123
|
-
// Arrange
|
|
124
|
-
const validToken = createTestToken({ userId: '123' });
|
|
125
|
-
|
|
126
|
-
// Act
|
|
127
|
-
const result = await validateToken(validToken);
|
|
128
|
-
|
|
129
|
-
// Assert
|
|
130
|
-
expect(result.userId).toBe('123');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should throw for expired token', async () => {
|
|
134
|
-
// Arrange
|
|
135
|
-
const expiredToken = createTestToken({ exp: Date.now() - 1000 });
|
|
136
|
-
|
|
137
|
-
// Act & Assert
|
|
138
|
-
await expect(validateToken(expiredToken)).rejects.toThrow('Token expired');
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
**Economy mode:** Create essential tests only:
|
|
144
|
-
- 1 happy path test
|
|
145
|
-
- 1 error case test
|
|
146
|
-
- Skip edge cases unless critical
|
|
147
|
-
|
|
148
|
-
### 5. Verify Tests Compile
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
pnpm run typecheck
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Fix any type errors in tests.
|
|
155
|
-
|
|
156
|
-
### 6. Save Output (if save_mode)
|
|
157
|
-
|
|
158
|
-
**If `{save_mode}` = true:**
|
|
159
|
-
|
|
160
|
-
Write to `{output_dir}/07-tests.md`:
|
|
161
|
-
- Coverage analysis
|
|
162
|
-
- Test plan
|
|
163
|
-
- Tests created
|
|
164
|
-
- Timestamp
|
|
165
|
-
- Update 00-context.md Progress table: 07-tests -> Complete
|
|
166
|
-
|
|
167
|
-
### 7. Present Test Summary
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
**Test Creation Complete**
|
|
171
|
-
|
|
172
|
-
**New test files:** {count}
|
|
173
|
-
**Test cases added:** {count}
|
|
174
|
-
|
|
175
|
-
**Coverage improvement:**
|
|
176
|
-
- Before: {X}%
|
|
177
|
-
- After: {Y}% (estimated)
|
|
178
|
-
|
|
179
|
-
**Tests ready to run.**
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
**Proceed directly to step-08-run-tests.md**
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## SUCCESS METRICS:
|
|
187
|
-
|
|
188
|
-
- Existing test patterns identified
|
|
189
|
-
- Coverage gaps documented
|
|
190
|
-
- Tests follow project conventions
|
|
191
|
-
- Tests compile without errors
|
|
192
|
-
- Meaningful assertions present
|
|
193
|
-
|
|
194
|
-
## FAILURE MODES:
|
|
195
|
-
|
|
196
|
-
- Writing tests without reading existing patterns
|
|
197
|
-
- Creating redundant test coverage
|
|
198
|
-
- Tests that don't compile
|
|
199
|
-
- Meaningless assertions (just checking truthy)
|
|
200
|
-
- Using subagents in economy_mode
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## NEXT STEP:
|
|
205
|
-
|
|
206
|
-
Always proceed to `./step-08-run-tests.md` to run the tests.
|