tlc-claude-code 0.6.4 → 0.7.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/autofix.md ADDED
@@ -0,0 +1,327 @@
1
+ # /tlc:autofix - Automatic Test Failure Recovery
2
+
3
+ Automatically fix failing tests with AI-powered debugging.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /tlc:autofix [test-file]
9
+ ```
10
+
11
+ If no file specified, fixes all failing tests.
12
+
13
+ ## What This Does
14
+
15
+ 1. Runs tests to identify failures
16
+ 2. Analyzes failure reasons
17
+ 3. Attempts fixes with reasoning
18
+ 4. Retries up to max attempts
19
+ 5. Reports results with explanations
20
+
21
+ ## Process
22
+
23
+ ### Step 1: Identify Failing Tests
24
+
25
+ Run test suite and capture failures:
26
+
27
+ ```bash
28
+ npm test 2>&1
29
+ ```
30
+
31
+ Parse output:
32
+ ```
33
+ Failing Tests:
34
+
35
+ 1. login.test.js
36
+ ✗ throws ValidationError for null email
37
+ Expected: ValidationError
38
+ Actual: TypeError: Cannot read property 'toLowerCase' of null
39
+
40
+ 2. users.test.js
41
+ ✗ returns empty array when no users
42
+ Expected: []
43
+ Actual: null
44
+ ```
45
+
46
+ ### Step 2: Analyze Each Failure
47
+
48
+ For each failing test:
49
+
50
+ ```
51
+ Analyzing: "throws ValidationError for null email"
52
+
53
+ Test Code:
54
+ it('throws ValidationError for null email', async () => {
55
+ await expect(login(null, 'password'))
56
+ .to.be.rejectedWith(ValidationError);
57
+ });
58
+
59
+ Error:
60
+ TypeError: Cannot read property 'toLowerCase' of null
61
+ at login (src/auth/login.ts:15)
62
+
63
+ Source Code (line 15):
64
+ const normalizedEmail = email.toLowerCase();
65
+
66
+ Analysis:
67
+ - Test expects ValidationError for null input
68
+ - Code tries to call .toLowerCase() on email before validation
69
+ - Null check should happen BEFORE string operations
70
+
71
+ Proposed Fix:
72
+ Add null check at start of function, before any string operations.
73
+ ```
74
+
75
+ ### Step 3: Generate Fix
76
+
77
+ ```typescript
78
+ // BEFORE (line 12-20 of src/auth/login.ts)
79
+ async function login(email: string, password: string): Promise<User> {
80
+ const normalizedEmail = email.toLowerCase();
81
+
82
+ if (!normalizedEmail || !password) {
83
+ throw new ValidationError('Email and password required');
84
+ }
85
+ // ...
86
+ }
87
+
88
+ // AFTER
89
+ async function login(email: string, password: string): Promise<User> {
90
+ if (!email || !password) {
91
+ throw new ValidationError('Email and password required');
92
+ }
93
+
94
+ const normalizedEmail = email.toLowerCase();
95
+ // ...
96
+ }
97
+ ```
98
+
99
+ ### Step 4: Apply Fix and Retry
100
+
101
+ ```
102
+ Applying fix to src/auth/login.ts...
103
+
104
+ Running test: "throws ValidationError for null email"
105
+ ✓ PASSED
106
+
107
+ Fix successful!
108
+
109
+ Commit this fix? (Y/n)
110
+ ```
111
+
112
+ ### Step 5: Handle Complex Failures
113
+
114
+ If simple fix doesn't work, try alternative approaches:
115
+
116
+ ```
117
+ Attempt 1: Move null check before toLowerCase()
118
+ Result: ✗ Still failing
119
+
120
+ Analyzing deeper...
121
+ The test expects ValidationError but we throw generic Error
122
+
123
+ Attempt 2: Change throw to ValidationError
124
+ Result: ✗ Still failing - ValidationError not imported
125
+
126
+ Attempt 3: Import ValidationError and use it
127
+ Result: ✓ PASSED
128
+
129
+ Fix required 3 attempts:
130
+ 1. Moved null check (insufficient)
131
+ 2. Changed error type (missing import)
132
+ 3. Added import (success)
133
+ ```
134
+
135
+ ### Step 6: Report Results
136
+
137
+ ```
138
+ ╭─────────────────────────────────────────────────────────────╮
139
+ │ AutoFix Results │
140
+ ├─────────────────────────────────────────────────────────────┤
141
+ │ │
142
+ │ Failing tests found: 6 │
143
+ │ Successfully fixed: 5 │
144
+ │ Could not fix: 1 │
145
+ │ │
146
+ │ Fixed: │
147
+ │ ✓ login.test.js - null email handling │
148
+ │ ✓ login.test.js - empty password handling │
149
+ │ ✓ users.test.js - empty array return │
150
+ │ ✓ users.test.js - pagination bounds │
151
+ │ ✓ api.test.js - timeout handling │
152
+ │ │
153
+ │ Could not fix: │
154
+ │ ✗ integration.test.js - database connection │
155
+ │ Reason: Requires external service configuration │
156
+ │ Suggestion: Check DATABASE_URL environment variable │
157
+ │ │
158
+ │ Files modified: │
159
+ │ - src/auth/login.ts (2 changes) │
160
+ │ - src/api/users.ts (1 change) │
161
+ │ - src/api/index.ts (1 change) │
162
+ │ │
163
+ ╰─────────────────────────────────────────────────────────────╯
164
+
165
+ Commit all fixes? (Y/n)
166
+ ```
167
+
168
+ ## Fix Strategies
169
+
170
+ ### Strategy 1: Direct Fix
171
+ Simple issues with obvious solutions:
172
+ - Missing null checks
173
+ - Wrong return types
174
+ - Missing imports
175
+ - Typos
176
+
177
+ ### Strategy 2: Pattern Matching
178
+ Recognize common error patterns:
179
+ ```
180
+ TypeError: Cannot read property 'X' of null/undefined
181
+ → Add null check before accessing property
182
+
183
+ Expected X but got undefined
184
+ → Add return statement or default value
185
+
186
+ Timeout exceeded
187
+ → Increase timeout or add async handling
188
+ ```
189
+
190
+ ### Strategy 3: Test-Driven Fix
191
+ Use the test assertion to guide the fix:
192
+ ```
193
+ Test expects: throws ValidationError
194
+ Code does: throws Error
195
+ Fix: Change Error to ValidationError
196
+ ```
197
+
198
+ ### Strategy 4: Contextual Analysis
199
+ Read surrounding code for patterns:
200
+ ```
201
+ Similar function handles null this way...
202
+ Following project's error handling pattern...
203
+ Using existing validation utility...
204
+ ```
205
+
206
+ ## Configuration
207
+
208
+ In `.tlc.json`:
209
+
210
+ ```json
211
+ {
212
+ "autofix": {
213
+ "maxAttempts": 5,
214
+ "strategies": ["direct", "pattern", "test-driven", "contextual"],
215
+ "autoCommit": false,
216
+ "excludePatterns": ["integration.test.*", "e2e.*"],
217
+ "timeout": 30000
218
+ }
219
+ }
220
+ ```
221
+
222
+ ## Limitations
223
+
224
+ AutoFix works best for:
225
+ - ✓ Simple logic errors
226
+ - ✓ Missing null/undefined checks
227
+ - ✓ Type mismatches
228
+ - ✓ Missing imports
229
+ - ✓ Wrong return values
230
+
231
+ AutoFix struggles with:
232
+ - ✗ Complex business logic bugs
233
+ - ✗ Architecture issues
234
+ - ✗ External service problems
235
+ - ✗ Race conditions
236
+ - ✗ Performance issues
237
+
238
+ When AutoFix can't solve it:
239
+ ```
240
+ Could not fix: "handles concurrent requests"
241
+
242
+ Analysis:
243
+ This appears to be a race condition in the request handler.
244
+ Multiple requests modify shared state without synchronization.
245
+
246
+ This requires manual investigation:
247
+ 1. Review shared state in src/api/handler.ts
248
+ 2. Consider adding mutex/lock
249
+ 3. Or redesign to avoid shared state
250
+
251
+ Would you like to:
252
+ 1) Log this as a bug (/tlc:bug)
253
+ 2) Create a task for manual fix
254
+ 3) Skip for now
255
+ ```
256
+
257
+ ## Example Session
258
+
259
+ ```
260
+ > /tlc:autofix
261
+
262
+ Running tests...
263
+ 12 passing
264
+ 4 failing
265
+
266
+ Analyzing failures...
267
+
268
+ [1/4] login.test.js - "throws for null email"
269
+ Error: TypeError: Cannot read property 'toLowerCase' of null
270
+ Fix: Add null check before string operation
271
+ Applying... ✓ Fixed
272
+
273
+ [2/4] login.test.js - "rejects empty password"
274
+ Error: Expected ValidationError, got nothing
275
+ Fix: Add validation for empty string
276
+ Applying... ✓ Fixed
277
+
278
+ [3/4] users.test.js - "returns empty array"
279
+ Error: Expected [], got null
280
+ Fix: Return [] instead of null when no results
281
+ Applying... ✓ Fixed
282
+
283
+ [4/4] integration.test.js - "connects to database"
284
+ Error: ECONNREFUSED 127.0.0.1:5432
285
+ Cannot fix: External service issue
286
+ Suggestion: Start PostgreSQL or set DATABASE_URL
287
+
288
+ Results: 3/4 fixed
289
+
290
+ Modified files:
291
+ - src/auth/login.ts
292
+ - src/api/users.ts
293
+
294
+ Commit fixes? (Y/n) y
295
+
296
+ Committed: fix: resolve 3 failing tests (null checks, empty returns)
297
+
298
+ 1 test still failing - requires manual attention.
299
+ ```
300
+
301
+ ## Integration with Build
302
+
303
+ AutoFix runs automatically during `/tlc:build` when tests fail:
304
+
305
+ ```
306
+ /tlc:build
307
+
308
+ Writing tests... ✓
309
+ Running tests...
310
+ ✗ 2 tests failing
311
+
312
+ AutoFix enabled. Attempting repairs...
313
+ ✓ Fixed 2/2 failures
314
+
315
+ Re-running tests...
316
+ ✓ All tests passing
317
+
318
+ Continuing with implementation...
319
+ ```
320
+
321
+ ## Notes
322
+
323
+ - AutoFix modifies source code - review changes before committing
324
+ - Use `--dry-run` to preview fixes without applying
325
+ - Fixes are atomic - each fix is a separate change
326
+ - If fix breaks other tests, it's rolled back
327
+ - Works best with good test descriptions
package/bin/install.js CHANGED
@@ -28,20 +28,41 @@ ${c.cyan} ████████╗██╗ ██████╗
28
28
  const VERSION = require('../package.json').version;
29
29
 
30
30
  const COMMANDS = [
31
+ // Core workflow
31
32
  'tlc.md',
32
33
  'new-project.md',
33
34
  'init.md',
34
35
  'import-project.md',
35
- 'coverage.md',
36
36
  'discuss.md',
37
37
  'plan.md',
38
38
  'build.md',
39
39
  'verify.md',
40
- 'status.md',
41
40
  'progress.md',
42
41
  'complete.md',
43
42
  'new-milestone.md',
44
43
  'quick.md',
44
+ // Quality & Testing
45
+ 'status.md',
46
+ 'coverage.md',
47
+ 'quality.md',
48
+ 'edge-cases.md',
49
+ 'autofix.md',
50
+ 'config.md',
51
+ // Team Collaboration
52
+ 'claim.md',
53
+ 'release.md',
54
+ 'who.md',
55
+ 'bug.md',
56
+ 'server.md',
57
+ // CI/CD & Integration
58
+ 'ci.md',
59
+ 'issues.md',
60
+ // Documentation
61
+ 'docs.md',
62
+ // Multi-Tool & Deployment
63
+ 'export.md',
64
+ 'deploy.md',
65
+ // Help
45
66
  'help.md'
46
67
  ];
47
68
 
package/bug.md ADDED
@@ -0,0 +1,255 @@
1
+ # /tlc:bug - Log a Bug or Feedback
2
+
3
+ Report issues discovered during development or QA verification.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /tlc:bug [description]
9
+ ```
10
+
11
+ Or interactive:
12
+ ```
13
+ /tlc:bug
14
+ ```
15
+
16
+ ## Process
17
+
18
+ ### Step 1: Gather Bug Information
19
+
20
+ If description provided as argument, use it. Otherwise prompt:
21
+
22
+ ```
23
+ What's the issue?
24
+ > Login fails when email contains a + symbol
25
+
26
+ Where did you find this?
27
+ 1) During development
28
+ 2) During /tlc:verify (QA)
29
+ 3) From automated tests
30
+ 4) User reported
31
+ > 2
32
+
33
+ Severity?
34
+ 1) Critical - blocks release
35
+ 2) High - major feature broken
36
+ 3) Medium - workaround exists
37
+ 4) Low - cosmetic/minor
38
+ > 2
39
+ ```
40
+
41
+ ### Step 2: Identify Context
42
+
43
+ Automatically detect:
44
+ - Current user: `git config user.name` or `$TLC_USER`
45
+ - Current phase: from `.planning/ROADMAP.md`
46
+ - Current task: from any `[>@user]` marker in PLAN.md
47
+ - Git branch: `git branch --show-current`
48
+ - Last commit: `git log -1 --oneline`
49
+
50
+ ### Step 3: Generate Bug ID
51
+
52
+ Format: `BUG-{NNN}` where NNN is sequential.
53
+
54
+ Read `.planning/BUGS.md` to find highest existing ID, increment.
55
+
56
+ ### Step 4: Create Bug Entry
57
+
58
+ Append to `.planning/BUGS.md`:
59
+
60
+ ```markdown
61
+ ---
62
+
63
+ ### BUG-007: Login fails with + symbol in email
64
+
65
+ **Status:** Open
66
+ **Severity:** High
67
+ **Reporter:** @alice
68
+ **Date:** 2024-01-26
69
+ **Phase:** 2 - Authentication
70
+ **Task:** Task 3 - Email validation
71
+ **Branch:** feature/auth
72
+ **Commit:** a1b2c3d
73
+
74
+ **Description:**
75
+ Login fails when email contains a + symbol (e.g., user+test@example.com)
76
+
77
+ **Steps to Reproduce:**
78
+ 1. Go to login page
79
+ 2. Enter email: user+test@example.com
80
+ 3. Enter valid password
81
+ 4. Click Login
82
+
83
+ **Expected:** Should accept valid email and log in
84
+ **Actual:** Shows "Invalid email format" error
85
+
86
+ **Notes:**
87
+ Plus addressing is valid per RFC 5321. Regex validation is too strict.
88
+ ```
89
+
90
+ ### Step 5: Commit Bug Report
91
+
92
+ ```bash
93
+ git add .planning/BUGS.md
94
+ git commit -m "bug: BUG-007 - Login fails with + symbol (@alice)"
95
+ ```
96
+
97
+ ### Step 6: Link to Task (Optional)
98
+
99
+ If bug relates to a specific task, offer to add reference:
100
+
101
+ ```
102
+ Link this bug to Task 3 in the current phase? (Y/n)
103
+ ```
104
+
105
+ If yes, add to task in PLAN.md:
106
+ ```markdown
107
+ ### Task 3: Email validation [>@bob]
108
+
109
+ **Bugs:** BUG-007
110
+ ```
111
+
112
+ ### Step 7: Notify
113
+
114
+ ```
115
+ Bug logged: BUG-007
116
+ File: .planning/BUGS.md
117
+ Committed: bug: BUG-007 - Login fails with + symbol (@alice)
118
+
119
+ Push to share with team? (Y/n)
120
+ ```
121
+
122
+ ## Bug Status Workflow
123
+
124
+ | Status | Meaning |
125
+ |--------|---------|
126
+ | Open | New, not yet addressed |
127
+ | In Progress | Someone is fixing |
128
+ | Fixed | Code fixed, needs verification |
129
+ | Verified | Fix confirmed working |
130
+ | Closed | Resolved |
131
+ | Won't Fix | Declined with reason |
132
+
133
+ ## Updating Bug Status
134
+
135
+ To update an existing bug:
136
+
137
+ ```
138
+ /tlc:bug --update BUG-007 --status "Fixed"
139
+ ```
140
+
141
+ Or interactive:
142
+ ```
143
+ /tlc:bug --update
144
+
145
+ Which bug?
146
+ BUG-005: Session timeout too short (Open)
147
+ BUG-006: Missing loading spinner (Open)
148
+ BUG-007: Login fails with + symbol (Open)
149
+ > BUG-007
150
+
151
+ New status?
152
+ 1) In Progress
153
+ 2) Fixed
154
+ 3) Verified
155
+ 4) Closed
156
+ 5) Won't Fix
157
+ > 2
158
+
159
+ Add resolution notes?
160
+ > Fixed regex in src/auth/validate.ts to allow + in local part
161
+
162
+ Updated BUG-007: Open → Fixed
163
+ ```
164
+
165
+ ## Viewing Bugs
166
+
167
+ To see all open bugs:
168
+
169
+ ```
170
+ /tlc:bug --list
171
+
172
+ Open Bugs (3):
173
+
174
+ | ID | Severity | Description | Reporter | Phase |
175
+ |----|----------|-------------|----------|-------|
176
+ | BUG-005 | Medium | Session timeout too short | @alice | 2 |
177
+ | BUG-006 | Low | Missing loading spinner | @bob | 2 |
178
+ | BUG-007 | High | Login fails with + symbol | @alice | 2 |
179
+
180
+ Critical: 0 | High: 1 | Medium: 1 | Low: 1
181
+ ```
182
+
183
+ ## Integration with /tlc:verify
184
+
185
+ During `/tlc:verify`, QA is prompted to log bugs:
186
+
187
+ ```
188
+ Testing Task 3: Email validation
189
+
190
+ Did you find any issues? (Y/n) y
191
+
192
+ /tlc:bug (interactive mode)
193
+ ...
194
+ ```
195
+
196
+ ## Example Session
197
+
198
+ ```
199
+ > /tlc:bug "Button color doesn't match design spec"
200
+
201
+ Gathering context...
202
+ User: @alice
203
+ Phase: 3 - Dashboard
204
+ Branch: feature/dashboard
205
+
206
+ Severity?
207
+ 1) Critical
208
+ 2) High
209
+ 3) Medium
210
+ 4) Low
211
+ > 4
212
+
213
+ BUG-008 created:
214
+ "Button color doesn't match design spec"
215
+ Severity: Low
216
+ Phase: 3 - Dashboard
217
+
218
+ Committed: bug: BUG-008 - Button color doesn't match design spec (@alice)
219
+
220
+ Push? (Y/n) y
221
+ Pushed to origin/feature/dashboard
222
+ ```
223
+
224
+ ## BUGS.md Format
225
+
226
+ The bugs file has a header and entries:
227
+
228
+ ```markdown
229
+ # Bug Tracker
230
+
231
+ ## Summary
232
+
233
+ | Status | Count |
234
+ |--------|-------|
235
+ | Open | 3 |
236
+ | In Progress | 1 |
237
+ | Fixed | 2 |
238
+ | Closed | 5 |
239
+
240
+ ## Open Bugs
241
+
242
+ ### BUG-007: Login fails with + symbol in email
243
+ ...
244
+
245
+ ### BUG-006: Missing loading spinner
246
+ ...
247
+
248
+ ## Closed Bugs
249
+
250
+ ### BUG-001: App crashes on startup
251
+ **Status:** Closed
252
+ **Resolution:** Fixed null check in main.ts
253
+ **Closed:** 2024-01-25 by @bob
254
+ ...
255
+ ```