opencodekit 0.12.2 → 0.12.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/dist/index.js +1 -1
- package/dist/template/.opencode/AGENTS.md +40 -417
- package/dist/template/.opencode/agent/build.md +119 -9
- package/dist/template/.opencode/agent/planner.md +0 -1
- package/dist/template/.opencode/agent/rush.md +81 -19
- package/dist/template/.opencode/command/accessibility-check.md +1 -1
- package/dist/template/.opencode/command/commit.md +1 -1
- package/dist/template/.opencode/command/create.md +68 -441
- package/dist/template/.opencode/command/finish.md +82 -252
- package/dist/template/.opencode/command/fix-ci.md +52 -247
- package/dist/template/.opencode/command/fix-types.md +32 -292
- package/dist/template/.opencode/command/fix-ui.md +49 -234
- package/dist/template/.opencode/command/fix.md +57 -194
- package/dist/template/.opencode/command/handoff.md +66 -243
- package/dist/template/.opencode/command/implement.md +67 -231
- package/dist/template/.opencode/command/issue.md +42 -190
- package/dist/template/.opencode/command/plan.md +86 -442
- package/dist/template/.opencode/command/pr.md +3 -1
- package/dist/template/.opencode/command/research-and-implement.md +69 -370
- package/dist/template/.opencode/command/research.md +72 -197
- package/dist/template/.opencode/command/resume.md +70 -438
- package/dist/template/.opencode/command/status.md +11 -11
- package/dist/template/.opencode/command/triage.md +23 -18
- package/dist/template/.opencode/memory/project/commands.md +139 -7
- package/dist/template/.opencode/memory/project/gotchas.md +85 -0
- package/dist/template/.opencode/opencode.json +556 -510
- package/dist/template/.opencode/plugin/beads.ts +181 -16
- package/dist/template/.opencode/skill/beads/SKILL.md +15 -0
- package/dist/template/.opencode/skill/context-engineering/SKILL.md +94 -0
- package/dist/template/.opencode/skill/memory-system/SKILL.md +107 -0
- package/dist/template/.opencode/skill/session-management/SKILL.md +111 -0
- package/dist/template/.opencode/skill/tool-priority/SKILL.md +115 -0
- package/package.json +1 -1
|
@@ -1,368 +1,108 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Fix type errors
|
|
2
|
+
description: Fix TypeScript type errors
|
|
3
3
|
argument-hint: "[bead-id] [--strict]"
|
|
4
4
|
agent: build
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Fix Type Errors
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Resolve TypeScript errors without adding `any` everywhere.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
skill({ name: "beads" });
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Options
|
|
16
|
-
|
|
17
|
-
- `--strict`: Also fix warnings and enable stricter checks
|
|
18
|
-
|
|
19
|
-
## Phase 1: Load Context
|
|
20
|
-
|
|
21
|
-
**Load skill:**
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
skill({ name: "systematic-debugging" });
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Check for bead context:**
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
bd_show({ id: "$ARGUMENTS" });
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Reserve files:**
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
bd_reserve({
|
|
37
|
-
paths: ["src/**/*.ts", "src/**/*.tsx"],
|
|
38
|
-
reason: "Fixing type errors",
|
|
39
|
-
ttl: 600,
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Phase 2: Detect Project & Run Type Check
|
|
44
|
-
|
|
45
|
-
**Detect type check command:**
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# Check package.json for type-check script
|
|
49
|
-
grep -q "type-check\|typecheck" package.json && echo "npm run type-check"
|
|
50
|
-
|
|
51
|
-
# Or use tsc directly
|
|
52
|
-
npx tsc --noEmit
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
| Project Type | Type Check Command |
|
|
56
|
-
| ------------ | ------------------------------------------ |
|
|
57
|
-
| npm | `npm run type-check` or `npx tsc --noEmit` |
|
|
58
|
-
| bun | `bun run typecheck` |
|
|
59
|
-
| yarn | `yarn type-check` |
|
|
60
|
-
| pnpm | `pnpm type-check` |
|
|
61
|
-
|
|
62
|
-
**Capture initial error count:**
|
|
11
|
+
## Get Current State
|
|
63
12
|
|
|
64
13
|
```bash
|
|
14
|
+
npx tsc --noEmit 2>&1 | head -50
|
|
65
15
|
npx tsc --noEmit 2>&1 | grep -c "error TS"
|
|
66
16
|
```
|
|
67
17
|
|
|
68
|
-
|
|
69
|
-
Type Check Status:
|
|
70
|
-
━━━━━━━━━━━━━━━━━━
|
|
71
|
-
|
|
72
|
-
Initial errors: [N]
|
|
73
|
-
Files affected: [N]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Phase 3: Use LSP for Semantic Analysis
|
|
77
|
-
|
|
78
|
-
Get errors with full context:
|
|
18
|
+
## Use LSP For Context
|
|
79
19
|
|
|
80
20
|
```typescript
|
|
81
21
|
lsp_lsp_diagnostics({ filePath: "<file>", severity: "error" });
|
|
22
|
+
lsp_lsp_hover({ filePath: "<file>", line: N, character: N });
|
|
82
23
|
```
|
|
83
24
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
lsp_lsp_hover({ filePath: "<file>", line: N, character: N }); // Understand types
|
|
88
|
-
lsp_lsp_goto_definition({ filePath: "<file>", line: N, character: N }); // Find source
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Phase 4: Categorize Errors
|
|
92
|
-
|
|
93
|
-
Group errors by pattern:
|
|
94
|
-
|
|
95
|
-
| Category | Error Pattern | Typical Fix |
|
|
96
|
-
| ---------------------- | ----------------------------------- | -------------------------------- |
|
|
97
|
-
| **Missing type** | `implicitly has 'any' type` | Add explicit type annotation |
|
|
98
|
-
| **Incorrect type** | `Type 'X' is not assignable to 'Y'` | Fix type or add conversion |
|
|
99
|
-
| **Null/undefined** | `possibly 'null' or 'undefined'` | Add null check or optional chain |
|
|
100
|
-
| **Property missing** | `Property 'x' does not exist` | Add to interface or fix typo |
|
|
101
|
-
| **Generic constraint** | `does not satisfy constraint` | Fix generic or add constraint |
|
|
102
|
-
| **Import error** | `Cannot find module` | Fix import path or install dep |
|
|
103
|
-
| **Overload mismatch** | `No overload matches this call` | Check function signature |
|
|
104
|
-
| **Readonly violation** | `Cannot assign to 'x' (read-only)` | Remove mutation or cast |
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
Error Categories:
|
|
108
|
-
━━━━━━━━━━━━━━━━
|
|
109
|
-
|
|
110
|
-
- Missing types: [N]
|
|
111
|
-
- Incorrect types: [N]
|
|
112
|
-
- Null handling: [N]
|
|
113
|
-
- Property errors: [N]
|
|
114
|
-
- Other: [N]
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Phase 5: Estimate Complexity
|
|
118
|
-
|
|
119
|
-
| Signals | Estimate | Approach |
|
|
120
|
-
| ---------------------------------------- | -------- | ---------------- |
|
|
121
|
-
| <10 errors, single category | S (~10) | Quick fix |
|
|
122
|
-
| 10-30 errors, few categories | M (~30) | Systematic |
|
|
123
|
-
| 30-100 errors, multiple categories | L (~100) | Batch by pattern |
|
|
124
|
-
| >100 errors or architectural type issues | XL | Plan first |
|
|
125
|
-
|
|
126
|
-
## Phase 6: Fix Errors
|
|
127
|
-
|
|
128
|
-
### Rules (MUST follow)
|
|
25
|
+
## Common Fixes
|
|
129
26
|
|
|
130
|
-
|
|
131
|
-
- ❌ **Never** use `// @ts-ignore` without justification
|
|
132
|
-
- ❌ **Never** use `as unknown as T` pattern
|
|
133
|
-
- ✅ **Prefer** proper typing over type assertions
|
|
134
|
-
- ✅ **Prefer** narrowing with type guards
|
|
135
|
-
- ✅ **Prefer** `unknown` over `any` when type is truly unknown
|
|
136
|
-
|
|
137
|
-
### Common Fixes
|
|
138
|
-
|
|
139
|
-
**Missing type on parameter:**
|
|
27
|
+
**Missing type:**
|
|
140
28
|
|
|
141
29
|
```typescript
|
|
142
30
|
// Before
|
|
143
31
|
function process(data) { ... }
|
|
144
|
-
|
|
145
32
|
// After
|
|
146
|
-
function process(data:
|
|
33
|
+
function process(data: InputType): OutputType { ... }
|
|
147
34
|
```
|
|
148
35
|
|
|
149
|
-
**Null
|
|
36
|
+
**Null handling:**
|
|
150
37
|
|
|
151
38
|
```typescript
|
|
152
39
|
// Before
|
|
153
40
|
const name = user.name.toUpperCase();
|
|
154
|
-
|
|
155
|
-
// After (optional chaining)
|
|
41
|
+
// After
|
|
156
42
|
const name = user?.name?.toUpperCase() ?? "Unknown";
|
|
157
|
-
|
|
158
|
-
// After (type guard)
|
|
159
|
-
if (user?.name) {
|
|
160
|
-
const name = user.name.toUpperCase();
|
|
161
|
-
}
|
|
162
43
|
```
|
|
163
44
|
|
|
164
45
|
**Property doesn't exist:**
|
|
165
46
|
|
|
166
47
|
```typescript
|
|
167
|
-
//
|
|
48
|
+
// Add to interface
|
|
168
49
|
interface User {
|
|
169
50
|
name: string;
|
|
51
|
+
email?: string; // Add missing property
|
|
170
52
|
}
|
|
171
|
-
user.email; // Error
|
|
172
|
-
|
|
173
|
-
// After - extend interface
|
|
174
|
-
interface User {
|
|
175
|
-
name: string;
|
|
176
|
-
email?: string;
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
**Generic constraint:**
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
// Before
|
|
184
|
-
function getValue<T>(obj: T, key: string) {
|
|
185
|
-
return obj[key]; // Error
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// After
|
|
189
|
-
function getValue<T extends Record<string, unknown>>(obj: T, key: keyof T) {
|
|
190
|
-
return obj[key];
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Batch Fixing Strategy
|
|
195
|
-
|
|
196
|
-
For many errors of same type:
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
// Use AST grep to find patterns
|
|
200
|
-
ast - grep({ pattern: "function $NAME($PARAMS) {" }); // Find untyped functions
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Fix one, then apply pattern to similar cases.
|
|
204
|
-
|
|
205
|
-
## Phase 7: Iterate Until Clean
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
npx tsc --noEmit 2>&1
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Repeat until:
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
Type Check: 0 errors ✓
|
|
215
53
|
```
|
|
216
54
|
|
|
217
|
-
|
|
55
|
+
## Rules
|
|
218
56
|
|
|
219
|
-
|
|
57
|
+
- ❌ Never use `any` just to pass type check
|
|
58
|
+
- ❌ Never use `// @ts-ignore` without justification
|
|
59
|
+
- ❌ Never use `as unknown as T`
|
|
60
|
+
- ✅ Prefer proper typing over assertions
|
|
61
|
+
- ✅ Prefer narrowing with type guards
|
|
62
|
+
- ✅ Prefer `unknown` over `any` when truly unknown
|
|
220
63
|
|
|
221
|
-
|
|
64
|
+
## Iterate Until Clean
|
|
222
65
|
|
|
223
66
|
```bash
|
|
224
67
|
npx tsc --noEmit
|
|
225
68
|
```
|
|
226
69
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
npm test
|
|
231
|
-
```
|
|
70
|
+
Repeat until 0 errors. Max 5 passes.
|
|
232
71
|
|
|
233
|
-
|
|
72
|
+
## Verify
|
|
234
73
|
|
|
235
74
|
```bash
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
Verification:
|
|
241
|
-
━━━━━━━━━━━━━
|
|
242
|
-
|
|
243
|
-
Types: 0 errors ✓
|
|
244
|
-
Tests: Passing ✓
|
|
245
|
-
Lint: Passing ✓
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Phase 9: Track Improvement
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
Type Error Resolution:
|
|
252
|
-
━━━━━━━━━━━━━━━━━━━━━━
|
|
253
|
-
|
|
254
|
-
Before: [N] errors
|
|
255
|
-
After: 0 errors
|
|
256
|
-
Reduction: 100%
|
|
257
|
-
|
|
258
|
-
By category:
|
|
259
|
-
- Missing types: [N] → 0
|
|
260
|
-
- Null handling: [N] → 0
|
|
261
|
-
- Property errors: [N] → 0
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Phase 10: Document Patterns
|
|
265
|
-
|
|
266
|
-
If you discovered useful type patterns:
|
|
267
|
-
|
|
268
|
-
```typescript
|
|
269
|
-
observation({
|
|
270
|
-
type: "pattern",
|
|
271
|
-
title: "Type pattern: [name]",
|
|
272
|
-
content: `
|
|
273
|
-
## Pattern
|
|
274
|
-
[Description of the type pattern]
|
|
275
|
-
|
|
276
|
-
## Example
|
|
277
|
-
\`\`\`typescript
|
|
278
|
-
[Code showing the pattern]
|
|
279
|
-
\`\`\`
|
|
280
|
-
|
|
281
|
-
## When to Use
|
|
282
|
-
[When this pattern applies]
|
|
283
|
-
`,
|
|
284
|
-
concepts: "typescript, types, [specific pattern]",
|
|
285
|
-
bead_id: "<bead-id>",
|
|
286
|
-
});
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Update conventions if this should be standard:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
memory -
|
|
293
|
-
update({
|
|
294
|
-
file: "project/conventions",
|
|
295
|
-
content: `
|
|
296
|
-
## Type Pattern: [Name]
|
|
297
|
-
|
|
298
|
-
[Pattern description and example]
|
|
299
|
-
`,
|
|
300
|
-
mode: "append",
|
|
301
|
-
});
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Phase 11: Handle Deep Issues
|
|
305
|
-
|
|
306
|
-
If type errors reveal architectural problems:
|
|
307
|
-
|
|
308
|
-
```typescript
|
|
309
|
-
bd_add({
|
|
310
|
-
title: "Refactor: [type issue summary]",
|
|
311
|
-
type: "task",
|
|
312
|
-
pri: 2,
|
|
313
|
-
desc: "Type errors revealed need for: [description]",
|
|
314
|
-
});
|
|
75
|
+
npx tsc --noEmit # Types
|
|
76
|
+
npm test # Tests still pass
|
|
77
|
+
npm run lint # Lint still passes
|
|
315
78
|
```
|
|
316
79
|
|
|
317
|
-
##
|
|
80
|
+
## Commit
|
|
318
81
|
|
|
319
82
|
```bash
|
|
320
83
|
git add <files>
|
|
321
84
|
git commit -m "fix(types): resolve type errors
|
|
322
85
|
|
|
323
|
-
- Fixed [N]
|
|
324
|
-
-
|
|
325
|
-
- No 'any' types added
|
|
326
|
-
[bead-id if applicable]"
|
|
86
|
+
- Fixed [N] errors
|
|
87
|
+
- No 'any' types added"
|
|
327
88
|
```
|
|
328
89
|
|
|
329
90
|
```typescript
|
|
330
|
-
|
|
331
|
-
bd_sync({ reason: "Fixed type errors" });
|
|
91
|
+
bd_sync({ reason: "Sync type fixes" });
|
|
332
92
|
```
|
|
333
93
|
|
|
334
94
|
## Output
|
|
335
95
|
|
|
336
96
|
```
|
|
337
97
|
Type Errors Fixed
|
|
338
|
-
━━━━━━━━━━━━━━━━━
|
|
339
98
|
|
|
340
|
-
Estimate: [S/M/L]
|
|
341
99
|
Before: [N] errors
|
|
342
100
|
After: 0 errors
|
|
343
101
|
|
|
344
|
-
Categories fixed:
|
|
345
|
-
- Missing types: [N]
|
|
346
|
-
- Null handling: [N]
|
|
347
|
-
- Property errors: [N]
|
|
348
|
-
|
|
349
102
|
Verification:
|
|
350
|
-
-
|
|
103
|
+
- Types: ✓
|
|
351
104
|
- Tests: ✓
|
|
352
105
|
- Lint: ✓
|
|
353
106
|
|
|
354
|
-
'any'
|
|
355
|
-
Patterns documented: [N]
|
|
356
|
-
|
|
357
|
-
Commit: [hash]
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
**Next steps:**
|
|
361
|
-
|
|
362
|
-
```
|
|
363
|
-
If part of larger task:
|
|
364
|
-
/implement <bead-id>
|
|
365
|
-
|
|
366
|
-
If standalone:
|
|
367
|
-
/finish <bead-id>
|
|
107
|
+
'any' added: 0 ✓
|
|
368
108
|
```
|