ctx-cc 3.3.1 → 3.3.2

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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  **AI that learns your preferences. Predictive planning. Self-healing deployments. Voice control.**
17
17
 
18
- [Installation](#installation) · [Quick Start](#quick-start) · [New in 3.3](#new-in-33) · [Commands](#commands) · [Why CTX](#why-ctx)
18
+ [Installation](#installation) · [Quick Start](#quick-start) · [New in 3.3](#new-in-33) · [Commands](#commands) · [Why CTX](#why-ctx) · [**Getting Started Guide**](./GETTING_STARTED.md)
19
19
 
20
20
  </div>
21
21
 
@@ -403,12 +403,31 @@ Configure in `.ctx/config.json`:
403
403
  }
404
404
  ```
405
405
 
406
- ### Persistent Debug State
407
- Debug sessions survive context resets:
406
+ ### Persistent Debug Mode
407
+ Scientific debugging with persistent state across sessions:
408
+
408
409
  ```bash
409
- /ctx debug --resume # Continue previous session
410
+ /ctx debug "login fails" # Start debugging
411
+ /ctx debug --resume # Resume after context reset
412
+ /ctx debug --list # See all sessions
413
+ ```
414
+
415
+ **How it works:**
416
+ ```
417
+ 1. OBSERVE → Capture exact error, context, state
418
+ 2. RESEARCH → Search codebase and web for similar issues
419
+ 3. HYPOTHESIZE → Form testable theory with confidence level
420
+ 4. TEST → Apply minimal fix
421
+ 5. VERIFY → Build + Tests + Lint + Browser
422
+ 6. ITERATE → Refine hypothesis, max 10 attempts
410
423
  ```
411
424
 
425
+ **Key features:**
426
+ - Sessions survive context resets and days between attempts
427
+ - Browser verification with stored credentials
428
+ - Screenshots saved for each attempt
429
+ - Escalation report if max attempts reached
430
+
412
431
  State stored in `.ctx/debug/sessions/`:
413
432
  - `STATE.json` - Machine-readable progress
414
433
  - `TRACE.md` - Human-readable log
@@ -486,6 +505,15 @@ Results synthesized into `SUMMARY.md`.
486
505
  | `/ctx verify` | Force three-level verification |
487
506
  | `/ctx quick "task"` | Quick task bypass |
488
507
 
508
+ ### Debug
509
+ | Command | Purpose |
510
+ |---------|---------|
511
+ | `/ctx debug` | Start debugging current issue |
512
+ | `/ctx debug "issue"` | Debug specific problem |
513
+ | `/ctx debug --resume` | Resume last debug session |
514
+ | `/ctx debug --list` | List all debug sessions |
515
+ | `/ctx debug --status` | Show current session status |
516
+
489
517
  ### Session
490
518
  | Command | Purpose |
491
519
  |---------|---------|
@@ -0,0 +1,461 @@
1
+ ---
2
+ name: ctx:debug
3
+ description: Systematic debugging with persistent state across sessions. Scientific method. Max 10 attempts. Browser verification.
4
+ ---
5
+
6
+ <objective>
7
+ Enter debug mode to systematically fix an issue using scientific method.
8
+
9
+ Debug sessions are **persistent** - they survive context resets, session restarts, and days between attempts. No context is ever lost.
10
+ </objective>
11
+
12
+ <usage>
13
+ ```bash
14
+ /ctx:debug # Start debug on current issue (from STATE.md)
15
+ /ctx:debug "description" # Start debug with specific issue
16
+ /ctx:debug --resume # Resume most recent debug session
17
+ /ctx:debug --resume {id} # Resume specific session
18
+ /ctx:debug --list # List all debug sessions
19
+ /ctx:debug --status # Show current debug session status
20
+ /ctx:debug --abort # Abort current session (mark failed)
21
+ ```
22
+ </usage>
23
+
24
+ <process>
25
+
26
+ ## Step 1: Parse Command
27
+
28
+ Check arguments:
29
+ - No args → Check STATE.md for debug_issue, or ask user
30
+ - `"description"` → Start fresh session with description
31
+ - `--resume` → Resume active session
32
+ - `--resume {id}` → Resume specific session
33
+ - `--list` → Show sessions and exit
34
+ - `--status` → Show current session and exit
35
+ - `--abort` → Mark session failed and exit
36
+
37
+ ## Step 2: Handle List/Status/Abort (if requested)
38
+
39
+ ### --list
40
+ ```bash
41
+ echo "## Debug Sessions"
42
+ echo ""
43
+ for session in .ctx/debug/sessions/*/; do
44
+ id=$(basename "$session")
45
+ state=$(cat "$session/STATE.json" | jq -r '.status')
46
+ issue=$(cat "$session/STATE.json" | jq -r '.issue.description' | head -c 50)
47
+ attempts=$(cat "$session/STATE.json" | jq -r '.currentAttempt')
48
+ echo "- $id [$state] $attempts attempts"
49
+ echo " $issue..."
50
+ done
51
+ ```
52
+
53
+ Output example:
54
+ ```
55
+ ## Debug Sessions
56
+
57
+ - debug-20240120-143022 [resolved] 2 attempts
58
+ Login form shows blank error...
59
+
60
+ - debug-20240119-091500 [escalated] 10 attempts
61
+ API returns 500 on checkout...
62
+
63
+ - debug-20240118-160045 [in_progress] 3 attempts ← ACTIVE
64
+ File upload fails silently...
65
+ ```
66
+
67
+ ### --status
68
+ Read `.ctx/debug/active-session.json` and show:
69
+ - Session ID
70
+ - Issue description
71
+ - Current attempt number
72
+ - Last hypothesis
73
+ - Last result
74
+ - Time spent
75
+
76
+ ### --abort
77
+ ```json
78
+ // Update STATE.json
79
+ {
80
+ "status": "aborted",
81
+ "abortedAt": "{timestamp}",
82
+ "reason": "User requested abort"
83
+ }
84
+ ```
85
+ Clear active-session.json and return to main router.
86
+
87
+ ## Step 3: Initialize or Resume Session
88
+
89
+ ### Resume Existing
90
+ ```javascript
91
+ // Check for active session
92
+ const active = JSON.parse(fs.readFileSync('.ctx/debug/active-session.json'));
93
+ if (active.sessionId) {
94
+ const state = JSON.parse(fs.readFileSync(`.ctx/debug/sessions/${active.sessionId}/STATE.json`));
95
+ // Continue from state.currentAttempt
96
+ }
97
+ ```
98
+
99
+ ### Start Fresh
100
+ ```javascript
101
+ const sessionId = `debug-${date}-${time}`;
102
+ const sessionDir = `.ctx/debug/sessions/${sessionId}`;
103
+
104
+ // Create session directory
105
+ fs.mkdirSync(sessionDir, { recursive: true });
106
+ fs.mkdirSync(`${sessionDir}/screenshots`, { recursive: true });
107
+
108
+ // Initialize STATE.json
109
+ const state = {
110
+ sessionId,
111
+ created: new Date().toISOString(),
112
+ updated: new Date().toISOString(),
113
+ status: "in_progress",
114
+ issue: {
115
+ description: userDescription,
116
+ type: null, // Will classify
117
+ severity: null,
118
+ errorMessage: null,
119
+ stackTrace: null,
120
+ stepsToReproduce: []
121
+ },
122
+ attempts: [],
123
+ currentAttempt: 0,
124
+ maxAttempts: 10 // From config.json
125
+ };
126
+
127
+ // Set as active
128
+ fs.writeFileSync('.ctx/debug/active-session.json', JSON.stringify({ sessionId }));
129
+ ```
130
+
131
+ ## Step 4: Gather Issue Context
132
+
133
+ ### Automatic Detection
134
+ 1. Check build output for errors
135
+ 2. Check test output for failures
136
+ 3. Check STATE.md for debug_issue
137
+ 4. Check git diff for recent changes
138
+
139
+ ### Classify Issue Type
140
+ ```
141
+ build → Compilation/bundling errors
142
+ test → Test failures
143
+ runtime → Crashes, exceptions
144
+ ui → Visual/interaction bugs
145
+ api → Backend/network errors
146
+ perf → Performance issues
147
+ ```
148
+
149
+ ### Document in STATE.json
150
+ ```json
151
+ {
152
+ "issue": {
153
+ "description": "Login form submits but shows blank error",
154
+ "type": "ui",
155
+ "severity": "high",
156
+ "errorMessage": "TypeError: Cannot read property 'message' of undefined",
157
+ "stackTrace": "at handleSubmit (login.tsx:45)...",
158
+ "stepsToReproduce": [
159
+ "Go to /login",
160
+ "Enter invalid credentials",
161
+ "Click submit",
162
+ "Observe blank error message"
163
+ ],
164
+ "affectedFiles": ["src/auth/login.tsx"],
165
+ "relatedCommits": ["abc1234"]
166
+ }
167
+ }
168
+ ```
169
+
170
+ ## Step 5: Spawn ctx-debugger Agent
171
+
172
+ ```
173
+ Task tool:
174
+ subagent_type: ctx-debugger
175
+ prompt: |
176
+ Resume debug session: {sessionId}
177
+
178
+ Issue: {issue.description}
179
+ Type: {issue.type}
180
+ Error: {issue.errorMessage}
181
+
182
+ Previous attempts: {attempts.length}
183
+ Last result: {lastAttempt.result}
184
+ Last learning: {lastAttempt.learnings}
185
+
186
+ Continue debugging. Max {remainingAttempts} more attempts.
187
+
188
+ Credentials available in .ctx/.env for browser testing.
189
+ ```
190
+
191
+ ## Step 6: Monitor Progress
192
+
193
+ The debugger agent will:
194
+
195
+ 1. **Form Hypothesis** based on:
196
+ - Error analysis
197
+ - Previous attempts (if any)
198
+ - Codebase patterns
199
+ - Web research
200
+
201
+ 2. **Apply Minimal Fix**
202
+ - Single focused change
203
+ - No collateral modifications
204
+
205
+ 3. **Verify All Layers**
206
+ - Build passes
207
+ - Tests pass
208
+ - Lint passes
209
+ - Browser works (if UI)
210
+
211
+ 4. **Record Result**
212
+ - Update STATE.json
213
+ - Append to TRACE.md
214
+ - Save screenshots
215
+
216
+ 5. **Loop or Exit**
217
+ - If fixed → Mark resolved
218
+ - If max attempts → Escalate
219
+ - Otherwise → Next hypothesis
220
+
221
+ ## Step 7: Handle Outcomes
222
+
223
+ ### Success (resolved)
224
+ ```
225
+ [DEBUG] ✅ Issue resolved!
226
+
227
+ Session: debug-20240120-143022
228
+ Issue: Login form shows blank error
229
+ Attempts: 2
230
+ Duration: 15 minutes
231
+
232
+ Root Cause:
233
+ Error state was logged but not set in React state
234
+
235
+ Fix Applied:
236
+ src/auth/login.tsx:45 - Added setError() call
237
+
238
+ Files Changed:
239
+ - src/auth/login.tsx
240
+
241
+ Commit: abc1234
242
+
243
+ Full trace: .ctx/debug/sessions/debug-20240120-143022/TRACE.md
244
+ ```
245
+
246
+ Update STATE.md:
247
+ - Set status = "executing"
248
+ - Clear debug_issue
249
+ - Log resolution
250
+
251
+ ### Escalation (max attempts)
252
+ ```
253
+ [DEBUG] ⚠️ Max attempts reached (10)
254
+
255
+ Session: debug-20240119-091500
256
+ Issue: API returns 500 on checkout
257
+ Duration: 2 hours
258
+
259
+ What We Tried:
260
+ 1. [FAIL] Null check on request body
261
+ 2. [FAIL] Validate payment data format
262
+ 3. [PARTIAL] Fix database connection pool
263
+ ...
264
+
265
+ What We Know:
266
+ - Error occurs only with specific product combinations
267
+ - Database connection is stable
268
+ - Payment API returns valid response
269
+
270
+ Possible Root Causes:
271
+ 1. [60%] Race condition in inventory check
272
+ 2. [30%] Stale cache invalidation
273
+
274
+ Recommended:
275
+ - Add logging to checkInventory()
276
+ - Review concurrent order tests
277
+
278
+ Full report: .ctx/debug/sessions/debug-20240119-091500/ESCALATION.md
279
+ ```
280
+
281
+ Ask user:
282
+ - Provide more context?
283
+ - Try different approach?
284
+ - Manual investigation?
285
+
286
+ </process>
287
+
288
+ <debug_philosophy>
289
+
290
+ ## Scientific Method
291
+
292
+ ```
293
+ OBSERVE → Exact error, context, state
294
+ RESEARCH → Similar issues, web search
295
+ HYPOTHESIZE → Testable theory with confidence
296
+ PREDICT → Expected outcome if correct
297
+ TEST → Apply minimal fix
298
+ ANALYZE → Did prediction match?
299
+ ITERATE → Refine and repeat
300
+ ```
301
+
302
+ ## Hypothesis Confidence Levels
303
+
304
+ | Confidence | Meaning | Action |
305
+ |------------|---------|--------|
306
+ | 90%+ | Strong evidence, likely root cause | Test first |
307
+ | 70-90% | Good evidence, probable cause | Test early |
308
+ | 50-70% | Some evidence, possible cause | Test if higher fails |
309
+ | <50% | Weak evidence, unlikely | Last resort |
310
+
311
+ ## Fix Principles
312
+
313
+ 1. **Minimal** - Change only what's necessary
314
+ 2. **Focused** - One hypothesis per attempt
315
+ 3. **Reversible** - Easy to undo if wrong
316
+ 4. **Documented** - Clear diff and rationale
317
+
318
+ ## Verification Layers
319
+
320
+ | Layer | What | How |
321
+ |-------|------|-----|
322
+ | 1 | Build | `npm run build` or equivalent |
323
+ | 2 | Tests | Run affected test files |
324
+ | 3 | Lint | `npm run lint` |
325
+ | 4 | Browser | Playwright/Chrome DevTools |
326
+
327
+ All layers must pass for "resolved" status.
328
+
329
+ </debug_philosophy>
330
+
331
+ <persistence>
332
+
333
+ ## Why Persistence Matters
334
+
335
+ Regular debugging:
336
+ ```
337
+ Session 1: Try 3 fixes, context resets
338
+ Session 2: Forget what was tried, repeat same fixes
339
+ Session 3: Still stuck, no progress
340
+ ```
341
+
342
+ CTX debugging:
343
+ ```
344
+ Session 1: Try 3 fixes, save state
345
+ Session 2: Load state, know what failed, try fix 4
346
+ Session 3: Load state, try fix 5, success!
347
+ ```
348
+
349
+ ## State Files
350
+
351
+ ```
352
+ .ctx/debug/
353
+ ├── active-session.json # Current session pointer
354
+ └── sessions/
355
+ └── debug-20240120-143022/
356
+ ├── STATE.json # Machine-readable state
357
+ ├── TRACE.md # Human-readable log
358
+ ├── hypotheses.json # All hypotheses
359
+ └── screenshots/ # Visual evidence
360
+ ```
361
+
362
+ ## Resume After Days
363
+
364
+ ```bash
365
+ # Monday - start debugging
366
+ /ctx:debug "checkout fails"
367
+ # Try 3 fixes, no luck, go home
368
+
369
+ # Wednesday - resume
370
+ /ctx:debug --resume
371
+ # CTX knows: 3 attempts failed, here's what we learned
372
+ # Continues from attempt 4
373
+ ```
374
+
375
+ </persistence>
376
+
377
+ <browser_verification>
378
+
379
+ ## Autonomous Browser Testing
380
+
381
+ CTX uses stored credentials from `.ctx/.env`:
382
+
383
+ ```bash
384
+ APP_URL=http://localhost:3000
385
+ TEST_USER_EMAIL=test@example.com
386
+ TEST_USER_PASSWORD=testpass123
387
+ ```
388
+
389
+ ### Verification Flow
390
+
391
+ ```javascript
392
+ // 1. Navigate to app
393
+ browser_navigate({ url: process.env.APP_URL });
394
+
395
+ // 2. Login if needed
396
+ browser_snapshot();
397
+ if (page.includes('login')) {
398
+ browser_type({ ref: 'email-input', text: process.env.TEST_USER_EMAIL });
399
+ browser_type({ ref: 'password-input', text: process.env.TEST_USER_PASSWORD });
400
+ browser_click({ ref: 'submit-button' });
401
+ }
402
+
403
+ // 3. Navigate to affected page
404
+ browser_navigate({ url: `${process.env.APP_URL}/affected-page` });
405
+
406
+ // 4. Reproduce issue
407
+ browser_snapshot();
408
+ // ... interaction steps
409
+
410
+ // 5. Verify fix
411
+ browser_snapshot();
412
+ browser_take_screenshot({ filename: `attempt-${n}.png` });
413
+ ```
414
+
415
+ ### Screenshot Evidence
416
+
417
+ Every attempt saves screenshots:
418
+ ```
419
+ screenshots/
420
+ ├── issue-initial.png # Before any fixes
421
+ ├── attempt-1.png # After fix 1
422
+ ├── attempt-2.png # After fix 2
423
+ ├── attempt-3-success.png # Fixed!
424
+ ```
425
+
426
+ </browser_verification>
427
+
428
+ <config>
429
+
430
+ ## Debug Settings
431
+
432
+ In `.ctx/config.json`:
433
+
434
+ ```json
435
+ {
436
+ "debug": {
437
+ "maxAttempts": 10,
438
+ "persistSessions": true,
439
+ "screenshotOnFailure": true,
440
+ "autoResume": true
441
+ }
442
+ }
443
+ ```
444
+
445
+ | Setting | Default | Description |
446
+ |---------|---------|-------------|
447
+ | maxAttempts | 10 | Max tries before escalation |
448
+ | persistSessions | true | Save state across sessions |
449
+ | screenshotOnFailure | true | Capture on each failed attempt |
450
+ | autoResume | true | Auto-resume if active session exists |
451
+
452
+ </config>
453
+
454
+ <output>
455
+ After spawning ctx-debugger, report:
456
+ - Session status (in_progress / resolved / escalated)
457
+ - Attempts made
458
+ - If resolved: root cause, fix, commit
459
+ - If escalated: report path, recommendations
460
+ - Next action for main router
461
+ </output>
package/commands/help.md CHANGED
@@ -93,6 +93,16 @@ Output ONLY the reference content below. Do NOT add project-specific analysis.
93
93
  | `/ctx verify` | Force three-level verification |
94
94
  | `/ctx quick "task"` | Quick task bypass |
95
95
 
96
+ ### Debug
97
+ | Command | Purpose |
98
+ |---------|---------|
99
+ | `/ctx debug` | Start debugging current issue |
100
+ | `/ctx debug "issue"` | Debug specific problem |
101
+ | `/ctx debug --resume` | Resume last debug session |
102
+ | `/ctx debug --list` | List all debug sessions |
103
+ | `/ctx debug --status` | Show current session status |
104
+ | `/ctx debug --abort` | Abort current session |
105
+
96
106
  ### Session
97
107
  | Command | Purpose |
98
108
  |---------|---------|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-cc",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "CTX 3.3 (Continuous Task eXecution) - AI that learns your preferences. Learning system, predictive planning, self-healing deployments (Sentry/LogRocket), voice control for hands-free development.",
5
5
  "keywords": [
6
6
  "claude",