opencodekit 0.10.0 → 0.11.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/.opencode/agent/planner.md +3 -2
- package/dist/template/.opencode/command/accessibility-check.md +293 -30
- package/dist/template/.opencode/command/analyze-mockup.md +406 -20
- package/dist/template/.opencode/command/analyze-project.md +439 -30
- package/dist/template/.opencode/command/brainstorm.md +288 -5
- package/dist/template/.opencode/command/commit.md +226 -17
- package/dist/template/.opencode/command/create.md +138 -35
- package/dist/template/.opencode/command/design-audit.md +477 -29
- package/dist/template/.opencode/command/design.md +609 -6
- package/dist/template/.opencode/command/edit-image.md +223 -20
- package/dist/template/.opencode/command/finish.md +162 -71
- package/dist/template/.opencode/command/fix-ci.md +296 -24
- package/dist/template/.opencode/command/fix-types.md +345 -13
- package/dist/template/.opencode/command/fix-ui.md +293 -13
- package/dist/template/.opencode/command/fix.md +256 -9
- package/dist/template/.opencode/command/generate-diagram.md +327 -26
- package/dist/template/.opencode/command/generate-icon.md +266 -22
- package/dist/template/.opencode/command/generate-image.md +232 -12
- package/dist/template/.opencode/command/generate-pattern.md +234 -20
- package/dist/template/.opencode/command/generate-storyboard.md +231 -21
- package/dist/template/.opencode/command/handoff.md +202 -30
- package/dist/template/.opencode/command/implement.md +162 -50
- package/dist/template/.opencode/command/import-plan.md +247 -51
- package/dist/template/.opencode/command/init.md +154 -35
- package/dist/template/.opencode/command/integration-test.md +405 -24
- package/dist/template/.opencode/command/issue.md +171 -21
- package/dist/template/.opencode/command/new-feature.md +382 -54
- package/dist/template/.opencode/command/plan.md +144 -118
- package/dist/template/.opencode/command/pr.md +229 -28
- package/dist/template/.opencode/command/quick-build.md +234 -5
- package/dist/template/.opencode/command/research-and-implement.md +436 -12
- package/dist/template/.opencode/command/research-ui.md +444 -34
- package/dist/template/.opencode/command/research.md +173 -45
- package/dist/template/.opencode/command/restore-image.md +416 -22
- package/dist/template/.opencode/command/resume.md +439 -63
- package/dist/template/.opencode/command/revert-feature.md +341 -64
- package/dist/template/.opencode/command/review-codebase.md +193 -4
- package/dist/template/.opencode/command/skill-create.md +506 -14
- package/dist/template/.opencode/command/skill-optimize.md +487 -16
- package/dist/template/.opencode/command/status.md +320 -60
- package/dist/template/.opencode/command/summarize.md +374 -33
- package/dist/template/.opencode/command/triage.md +355 -0
- package/dist/template/.opencode/command/ui-review.md +292 -25
- package/dist/template/.opencode/skill/playwriter/SKILL.md +148 -0
- package/package.json +1 -1
|
@@ -1,52 +1,324 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Analyze
|
|
3
|
-
argument-hint: "
|
|
2
|
+
description: Analyze GitHub Actions logs and fix issues with bead tracking
|
|
3
|
+
argument-hint: "<github-actions-url or run-id>"
|
|
4
|
+
agent: build
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
# Fix CI: $ARGUMENTS
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Phase 1: Load Skills & Create Bead
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
**Load skills:**
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
skill({ name: "systematic-debugging" });
|
|
15
|
+
skill({ name: "root-cause-tracing" });
|
|
16
|
+
```
|
|
15
17
|
|
|
16
|
-
CI failures are P0 bugs
|
|
18
|
+
**CI failures are P0 bugs.** Create bead immediately:
|
|
17
19
|
|
|
18
20
|
```typescript
|
|
19
21
|
bd_add({
|
|
20
|
-
title: "Fix CI:
|
|
21
|
-
type: "
|
|
22
|
+
title: "Fix CI: [failure summary]",
|
|
23
|
+
type: "bug",
|
|
22
24
|
pri: 0,
|
|
23
|
-
tags: ["bug"],
|
|
25
|
+
tags: ["ci", "bug"],
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Reserve workflow files:**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
bd_reserve({
|
|
33
|
+
paths: [".github/workflows/**", "package.json", "tsconfig.json"],
|
|
34
|
+
reason: "Fixing CI: $ARGUMENTS",
|
|
35
|
+
ttl: 600,
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Phase 2: Fetch CI Logs
|
|
40
|
+
|
|
41
|
+
**From URL:**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Extract run ID from URL
|
|
45
|
+
# https://github.com/owner/repo/actions/runs/12345678
|
|
46
|
+
gh run view 12345678 --log-failed
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**From run ID:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
gh run view $ARGUMENTS --log-failed
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**List recent failed runs:**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
gh run list --status=failure --limit=5
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Get full logs:**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gh run view $ARGUMENTS --log > /tmp/ci-log.txt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Phase 3: Extract Errors
|
|
68
|
+
|
|
69
|
+
Parse the CI log for errors:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Find error lines
|
|
73
|
+
grep -i "error\|failed\|exception" /tmp/ci-log.txt | head -30
|
|
74
|
+
|
|
75
|
+
# Find the failing step
|
|
76
|
+
gh run view $ARGUMENTS --json jobs --jq '.jobs[] | select(.conclusion=="failure") | {name, steps: [.steps[] | select(.conclusion=="failure")]}'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Extract key information:**
|
|
80
|
+
|
|
81
|
+
| Field | Extract |
|
|
82
|
+
| ----------------- | ------------------------------ |
|
|
83
|
+
| **Failing job** | Which job failed |
|
|
84
|
+
| **Failing step** | Which step in the job |
|
|
85
|
+
| **Error message** | Exact error text |
|
|
86
|
+
| **Exit code** | Process exit code if available |
|
|
87
|
+
| **Context** | Lines before/after error |
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
CI Failure Analysis:
|
|
91
|
+
━━━━━━━━━━━━━━━━━━━━
|
|
92
|
+
|
|
93
|
+
Job: [job name]
|
|
94
|
+
Step: [step name]
|
|
95
|
+
Error: [error message]
|
|
96
|
+
|
|
97
|
+
Context:
|
|
98
|
+
[relevant log lines]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Phase 4: Identify Failure Pattern
|
|
102
|
+
|
|
103
|
+
Common CI failure patterns:
|
|
104
|
+
|
|
105
|
+
| Pattern | Symptoms | Typical Fix |
|
|
106
|
+
| ------------------------ | ---------------------------------- | ----------------------------------- |
|
|
107
|
+
| **Dependency issue** | "module not found", npm/yarn error | Update lockfile, check versions |
|
|
108
|
+
| **Environment mismatch** | Works locally, fails in CI | Check Node/Python version, env vars |
|
|
109
|
+
| **Test flakiness** | Intermittent failures | Add retries, fix race conditions |
|
|
110
|
+
| **Build timeout** | Job cancelled after N minutes | Optimize build, increase timeout |
|
|
111
|
+
| **Type error** | TypeScript compilation failed | Fix type errors locally first |
|
|
112
|
+
| **Lint error** | ESLint/Prettier failures | Run lint locally, fix issues |
|
|
113
|
+
| **Secret missing** | "secret not found" | Check repository secrets config |
|
|
114
|
+
| **Permission denied** | GITHUB_TOKEN issues | Check workflow permissions |
|
|
115
|
+
| **Cache issue** | Stale cache causing failures | Clear cache, update cache key |
|
|
116
|
+
| **Docker issue** | Image pull/build failures | Check Dockerfile, registry auth |
|
|
117
|
+
|
|
118
|
+
## Phase 5: Estimate Complexity
|
|
119
|
+
|
|
120
|
+
| Signals | Estimate | Approach |
|
|
121
|
+
| ----------------------------------- | -------- | ------------------ |
|
|
122
|
+
| Single config change, obvious fix | S (~10) | Quick fix |
|
|
123
|
+
| Dependency update, env var fix | M (~30) | Systematic |
|
|
124
|
+
| Flaky tests, race conditions | L (~100) | Deep investigation |
|
|
125
|
+
| Workflow restructure, cross-cutting | XL | Plan first |
|
|
126
|
+
|
|
127
|
+
## Phase 6: Reproduce Locally (if possible)
|
|
128
|
+
|
|
129
|
+
Try to reproduce the failure locally:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Run the same commands as CI
|
|
133
|
+
npm ci
|
|
134
|
+
npm run build
|
|
135
|
+
npm test
|
|
136
|
+
npm run lint
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
If it passes locally but fails in CI:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Check for environment differences
|
|
143
|
+
node --version # Compare to CI
|
|
144
|
+
npm --version # Compare to CI
|
|
145
|
+
cat .nvmrc # If exists
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Phase 7: Fix
|
|
149
|
+
|
|
150
|
+
**For complex fixes (≥3 phases):**
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
task({
|
|
154
|
+
subagent_type: "planner",
|
|
155
|
+
description: "Plan CI fix",
|
|
156
|
+
prompt: "Create implementation plan for fixing CI: [failure description]",
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Save plan to `.beads/artifacts/<bead-id>/spec.md`
|
|
161
|
+
|
|
162
|
+
**Common fixes:**
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Dependency issues
|
|
166
|
+
rm -rf node_modules package-lock.json
|
|
167
|
+
npm install
|
|
168
|
+
|
|
169
|
+
# Type errors
|
|
170
|
+
npm run type-check # Fix locally first
|
|
171
|
+
|
|
172
|
+
# Lint errors
|
|
173
|
+
npm run lint -- --fix
|
|
174
|
+
|
|
175
|
+
# Cache issues (add to workflow)
|
|
176
|
+
# - uses: actions/cache@v3
|
|
177
|
+
# with:
|
|
178
|
+
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Phase 8: Verify Locally
|
|
182
|
+
|
|
183
|
+
Before pushing:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm run build
|
|
187
|
+
npm test
|
|
188
|
+
npm run lint
|
|
189
|
+
npm run type-check
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
All must pass locally.
|
|
193
|
+
|
|
194
|
+
## Phase 9: Push & Re-trigger CI
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
git add <files>
|
|
198
|
+
git commit -m "fix(ci): <description>
|
|
199
|
+
|
|
200
|
+
Root cause: [what was wrong]
|
|
201
|
+
<bead-id>"
|
|
202
|
+
|
|
203
|
+
git push
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Re-trigger CI:**
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
gh workflow run <workflow-name>
|
|
210
|
+
# or
|
|
211
|
+
gh run rerun $ARGUMENTS --failed
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Watch CI status:**
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
gh run watch
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
CI Verification:
|
|
222
|
+
━━━━━━━━━━━━━━━━
|
|
223
|
+
|
|
224
|
+
Run ID: [new run id]
|
|
225
|
+
Status: [pending/success/failure]
|
|
226
|
+
URL: [run url]
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Phase 10: Handle Results
|
|
230
|
+
|
|
231
|
+
**If CI passes:**
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
observation({
|
|
235
|
+
type: "bugfix",
|
|
236
|
+
title: "CI fix: [summary]",
|
|
237
|
+
content: `
|
|
238
|
+
## Root Cause
|
|
239
|
+
[What was actually wrong]
|
|
240
|
+
|
|
241
|
+
## Fix
|
|
242
|
+
[What we changed]
|
|
243
|
+
|
|
244
|
+
## Prevention
|
|
245
|
+
[How to avoid in future]
|
|
246
|
+
`,
|
|
247
|
+
concepts: "ci, github-actions, [specific issue]",
|
|
248
|
+
bead_id: "<bead-id>",
|
|
24
249
|
});
|
|
250
|
+
|
|
251
|
+
bd_done({ id: "<bead-id>", msg: "CI fixed: [summary]" });
|
|
25
252
|
```
|
|
26
253
|
|
|
27
|
-
|
|
254
|
+
**If CI still fails:**
|
|
28
255
|
|
|
29
|
-
|
|
256
|
+
Iterate:
|
|
30
257
|
|
|
31
|
-
1.
|
|
258
|
+
1. Fetch new logs
|
|
259
|
+
2. Identify new/remaining error
|
|
260
|
+
3. Fix and push again
|
|
261
|
+
4. Maximum 3 iterations before escalating
|
|
32
262
|
|
|
33
|
-
|
|
263
|
+
**If fix makes things worse:**
|
|
34
264
|
|
|
35
|
-
|
|
265
|
+
```bash
|
|
266
|
+
git revert HEAD
|
|
267
|
+
git push
|
|
268
|
+
```
|
|
36
269
|
|
|
37
|
-
|
|
270
|
+
Then reassess approach.
|
|
38
271
|
|
|
39
|
-
|
|
272
|
+
## Phase 11: Update Memory
|
|
40
273
|
|
|
41
|
-
|
|
274
|
+
If this was a recurring CI issue:
|
|
42
275
|
|
|
43
|
-
|
|
276
|
+
```typescript
|
|
277
|
+
memory -
|
|
278
|
+
update({
|
|
279
|
+
file: "project/gotchas",
|
|
280
|
+
content: `
|
|
281
|
+
## CI: [Issue Title]
|
|
282
|
+
|
|
283
|
+
**Symptom:** [What you see in CI logs]
|
|
284
|
+
**Cause:** [Root cause]
|
|
285
|
+
**Fix:** [How to resolve]
|
|
286
|
+
**Prevention:** [Config to prevent recurrence]
|
|
287
|
+
`,
|
|
288
|
+
mode: "append",
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Phase 12: Sync & Report
|
|
44
293
|
|
|
45
294
|
```typescript
|
|
46
|
-
|
|
295
|
+
bd_release({ _: true });
|
|
296
|
+
bd_sync({ reason: "Fixed CI: $ARGUMENTS" });
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
CI Fixed: $ARGUMENTS
|
|
301
|
+
━━━━━━━━━━━━━━━━━━━━
|
|
302
|
+
|
|
303
|
+
Estimate: [S/M/L]
|
|
304
|
+
Root cause: [brief description]
|
|
305
|
+
Pattern: [which common pattern]
|
|
306
|
+
|
|
307
|
+
Changes:
|
|
308
|
+
- [file] - [change]
|
|
309
|
+
|
|
310
|
+
CI Run: [new run URL]
|
|
311
|
+
Status: Passed ✓
|
|
312
|
+
|
|
313
|
+
Observation: Created ✓
|
|
314
|
+
Gotcha: [Added/Not needed]
|
|
315
|
+
|
|
316
|
+
Commit: [hash]
|
|
47
317
|
```
|
|
48
318
|
|
|
49
319
|
## Notes
|
|
50
320
|
|
|
51
|
-
- If `gh`
|
|
52
|
-
- If
|
|
321
|
+
- If `gh` CLI is not available: `brew install gh && gh auth login`
|
|
322
|
+
- If fix reveals systemic issues, create follow-up beads
|
|
323
|
+
- For flaky tests, consider adding retry logic or fixing race conditions
|
|
324
|
+
- Check if same failure happened before: `gh run list --status=failure --limit=20`
|
|
@@ -1,30 +1,362 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Fix type errors with optional bead tracking
|
|
3
|
-
argument-hint: "[bead-id]"
|
|
3
|
+
argument-hint: "[bead-id] [--strict]"
|
|
4
|
+
agent: build
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Fix Type Errors
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Options
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
- `--strict`: Also fix warnings and enable stricter checks
|
|
11
12
|
|
|
12
|
-
##
|
|
13
|
+
## Phase 1: Load Context
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
- Do not use `any` just to pass the type check.
|
|
16
|
-
- Prefer proper typing over type assertions where possible.
|
|
15
|
+
**Load skill:**
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
skill({ name: "systematic-debugging" });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Check for bead context:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
bd_show({ id: "$ARGUMENTS" });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Reserve files:**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
bd_reserve({
|
|
31
|
+
paths: ["src/**/*.ts", "src/**/*.tsx"],
|
|
32
|
+
reason: "Fixing type errors",
|
|
33
|
+
ttl: 600,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Phase 2: Detect Project & Run Type Check
|
|
38
|
+
|
|
39
|
+
**Detect type check command:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Check package.json for type-check script
|
|
43
|
+
grep -q "type-check\|typecheck" package.json && echo "npm run type-check"
|
|
44
|
+
|
|
45
|
+
# Or use tsc directly
|
|
46
|
+
npx tsc --noEmit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
| Project Type | Type Check Command |
|
|
50
|
+
| ------------ | ------------------------------------------ |
|
|
51
|
+
| npm | `npm run type-check` or `npx tsc --noEmit` |
|
|
52
|
+
| bun | `bun run typecheck` |
|
|
53
|
+
| yarn | `yarn type-check` |
|
|
54
|
+
| pnpm | `pnpm type-check` |
|
|
55
|
+
|
|
56
|
+
**Capture initial error count:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx tsc --noEmit 2>&1 | grep -c "error TS"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Type Check Status:
|
|
64
|
+
━━━━━━━━━━━━━━━━━━
|
|
65
|
+
|
|
66
|
+
Initial errors: [N]
|
|
67
|
+
Files affected: [N]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Phase 3: Use LSP for Semantic Analysis
|
|
71
|
+
|
|
72
|
+
Get errors with full context:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
lsp_diagnostics({ filePath: "<file>", severity: "error" });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For each file with errors:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
lsp_hover({ filePath: "<file>", line: N, character: N }); // Understand types
|
|
82
|
+
lsp_goto_definition({ filePath: "<file>", line: N, character: N }); // Find source
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Phase 4: Categorize Errors
|
|
19
86
|
|
|
20
|
-
|
|
87
|
+
Group errors by pattern:
|
|
21
88
|
|
|
22
|
-
|
|
89
|
+
| Category | Error Pattern | Typical Fix |
|
|
90
|
+
| ---------------------- | ----------------------------------- | -------------------------------- |
|
|
91
|
+
| **Missing type** | `implicitly has 'any' type` | Add explicit type annotation |
|
|
92
|
+
| **Incorrect type** | `Type 'X' is not assignable to 'Y'` | Fix type or add conversion |
|
|
93
|
+
| **Null/undefined** | `possibly 'null' or 'undefined'` | Add null check or optional chain |
|
|
94
|
+
| **Property missing** | `Property 'x' does not exist` | Add to interface or fix typo |
|
|
95
|
+
| **Generic constraint** | `does not satisfy constraint` | Fix generic or add constraint |
|
|
96
|
+
| **Import error** | `Cannot find module` | Fix import path or install dep |
|
|
97
|
+
| **Overload mismatch** | `No overload matches this call` | Check function signature |
|
|
98
|
+
| **Readonly violation** | `Cannot assign to 'x' (read-only)` | Remove mutation or cast |
|
|
23
99
|
|
|
24
|
-
|
|
100
|
+
```
|
|
101
|
+
Error Categories:
|
|
102
|
+
━━━━━━━━━━━━━━━━
|
|
103
|
+
|
|
104
|
+
- Missing types: [N]
|
|
105
|
+
- Incorrect types: [N]
|
|
106
|
+
- Null handling: [N]
|
|
107
|
+
- Property errors: [N]
|
|
108
|
+
- Other: [N]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Phase 5: Estimate Complexity
|
|
112
|
+
|
|
113
|
+
| Signals | Estimate | Approach |
|
|
114
|
+
| ---------------------------------------- | -------- | ---------------- |
|
|
115
|
+
| <10 errors, single category | S (~10) | Quick fix |
|
|
116
|
+
| 10-30 errors, few categories | M (~30) | Systematic |
|
|
117
|
+
| 30-100 errors, multiple categories | L (~100) | Batch by pattern |
|
|
118
|
+
| >100 errors or architectural type issues | XL | Plan first |
|
|
119
|
+
|
|
120
|
+
## Phase 6: Fix Errors
|
|
121
|
+
|
|
122
|
+
### Rules (MUST follow)
|
|
123
|
+
|
|
124
|
+
- ❌ **Never** use `any` just to pass type check
|
|
125
|
+
- ❌ **Never** use `// @ts-ignore` without justification
|
|
126
|
+
- ❌ **Never** use `as unknown as T` pattern
|
|
127
|
+
- ✅ **Prefer** proper typing over type assertions
|
|
128
|
+
- ✅ **Prefer** narrowing with type guards
|
|
129
|
+
- ✅ **Prefer** `unknown` over `any` when type is truly unknown
|
|
130
|
+
|
|
131
|
+
### Common Fixes
|
|
25
132
|
|
|
26
|
-
|
|
133
|
+
**Missing type on parameter:**
|
|
27
134
|
|
|
28
135
|
```typescript
|
|
29
|
-
|
|
136
|
+
// Before
|
|
137
|
+
function process(data) { ... }
|
|
138
|
+
|
|
139
|
+
// After
|
|
140
|
+
function process(data: ProcessInput): ProcessOutput { ... }
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Null/undefined handling:**
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// Before
|
|
147
|
+
const name = user.name.toUpperCase();
|
|
148
|
+
|
|
149
|
+
// After (optional chaining)
|
|
150
|
+
const name = user?.name?.toUpperCase() ?? "Unknown";
|
|
151
|
+
|
|
152
|
+
// After (type guard)
|
|
153
|
+
if (user?.name) {
|
|
154
|
+
const name = user.name.toUpperCase();
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Property doesn't exist:**
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Before
|
|
162
|
+
interface User {
|
|
163
|
+
name: string;
|
|
164
|
+
}
|
|
165
|
+
user.email; // Error
|
|
166
|
+
|
|
167
|
+
// After - extend interface
|
|
168
|
+
interface User {
|
|
169
|
+
name: string;
|
|
170
|
+
email?: string;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Generic constraint:**
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// Before
|
|
178
|
+
function getValue<T>(obj: T, key: string) {
|
|
179
|
+
return obj[key]; // Error
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// After
|
|
183
|
+
function getValue<T extends Record<string, unknown>>(obj: T, key: keyof T) {
|
|
184
|
+
return obj[key];
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Batch Fixing Strategy
|
|
189
|
+
|
|
190
|
+
For many errors of same type:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
// Use AST grep to find patterns
|
|
194
|
+
ast - grep({ pattern: "function $NAME($PARAMS) {" }); // Find untyped functions
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Fix one, then apply pattern to similar cases.
|
|
198
|
+
|
|
199
|
+
## Phase 7: Iterate Until Clean
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npx tsc --noEmit 2>&1
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Repeat until:
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
Type Check: 0 errors ✓
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Maximum iterations:** 5 passes. If still errors after 5, reassess approach.
|
|
212
|
+
|
|
213
|
+
## Phase 8: Verification
|
|
214
|
+
|
|
215
|
+
**Type check passes:**
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
npx tsc --noEmit
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Tests still pass:**
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm test
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Lint still passes:**
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npm run lint
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
Verification:
|
|
235
|
+
━━━━━━━━━━━━━
|
|
236
|
+
|
|
237
|
+
Types: 0 errors ✓
|
|
238
|
+
Tests: Passing ✓
|
|
239
|
+
Lint: Passing ✓
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Phase 9: Track Improvement
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
Type Error Resolution:
|
|
246
|
+
━━━━━━━━━━━━━━━━━━━━━━
|
|
247
|
+
|
|
248
|
+
Before: [N] errors
|
|
249
|
+
After: 0 errors
|
|
250
|
+
Reduction: 100%
|
|
251
|
+
|
|
252
|
+
By category:
|
|
253
|
+
- Missing types: [N] → 0
|
|
254
|
+
- Null handling: [N] → 0
|
|
255
|
+
- Property errors: [N] → 0
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Phase 10: Document Patterns
|
|
259
|
+
|
|
260
|
+
If you discovered useful type patterns:
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
observation({
|
|
264
|
+
type: "pattern",
|
|
265
|
+
title: "Type pattern: [name]",
|
|
266
|
+
content: `
|
|
267
|
+
## Pattern
|
|
268
|
+
[Description of the type pattern]
|
|
269
|
+
|
|
270
|
+
## Example
|
|
271
|
+
\`\`\`typescript
|
|
272
|
+
[Code showing the pattern]
|
|
273
|
+
\`\`\`
|
|
274
|
+
|
|
275
|
+
## When to Use
|
|
276
|
+
[When this pattern applies]
|
|
277
|
+
`,
|
|
278
|
+
concepts: "typescript, types, [specific pattern]",
|
|
279
|
+
bead_id: "<bead-id>",
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Update conventions if this should be standard:
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
memory -
|
|
287
|
+
update({
|
|
288
|
+
file: "project/conventions",
|
|
289
|
+
content: `
|
|
290
|
+
## Type Pattern: [Name]
|
|
291
|
+
|
|
292
|
+
[Pattern description and example]
|
|
293
|
+
`,
|
|
294
|
+
mode: "append",
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Phase 11: Handle Deep Issues
|
|
299
|
+
|
|
300
|
+
If type errors reveal architectural problems:
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
bd_add({
|
|
304
|
+
title: "Refactor: [type issue summary]",
|
|
305
|
+
type: "task",
|
|
306
|
+
pri: 2,
|
|
307
|
+
desc: "Type errors revealed need for: [description]",
|
|
308
|
+
});
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Phase 12: Commit & Sync
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
git add <files>
|
|
315
|
+
git commit -m "fix(types): resolve type errors
|
|
316
|
+
|
|
317
|
+
- Fixed [N] type errors
|
|
318
|
+
- Categories: [list main categories]
|
|
319
|
+
- No 'any' types added
|
|
320
|
+
[bead-id if applicable]"
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
bd_release({ _: true });
|
|
325
|
+
bd_sync({ reason: "Fixed type errors" });
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Output
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
Type Errors Fixed
|
|
332
|
+
━━━━━━━━━━━━━━━━━
|
|
333
|
+
|
|
334
|
+
Estimate: [S/M/L]
|
|
335
|
+
Before: [N] errors
|
|
336
|
+
After: 0 errors
|
|
337
|
+
|
|
338
|
+
Categories fixed:
|
|
339
|
+
- Missing types: [N]
|
|
340
|
+
- Null handling: [N]
|
|
341
|
+
- Property errors: [N]
|
|
342
|
+
|
|
343
|
+
Verification:
|
|
344
|
+
- Type check: ✓
|
|
345
|
+
- Tests: ✓
|
|
346
|
+
- Lint: ✓
|
|
347
|
+
|
|
348
|
+
'any' types added: 0 ✓
|
|
349
|
+
Patterns documented: [N]
|
|
350
|
+
|
|
351
|
+
Commit: [hash]
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Next steps:**
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
If part of larger task:
|
|
358
|
+
/implement <bead-id>
|
|
359
|
+
|
|
360
|
+
If standalone:
|
|
361
|
+
/finish <bead-id>
|
|
30
362
|
```
|