ctx-cc 3.0.0 → 3.3.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/README.md +360 -6
- package/agents/ctx-auditor.md +495 -0
- package/agents/ctx-criteria-suggester.md +358 -0
- package/agents/ctx-handoff.md +379 -0
- package/agents/ctx-learner.md +533 -0
- package/agents/ctx-parallelizer.md +351 -0
- package/agents/ctx-predictor.md +438 -0
- package/agents/ctx-reviewer.md +366 -0
- package/agents/ctx-team-coordinator.md +407 -0
- package/commands/integrate.md +422 -0
- package/commands/metrics.md +465 -0
- package/commands/milestone.md +264 -0
- package/commands/monitor.md +474 -0
- package/commands/voice.md +513 -0
- package/package.json +2 -2
- package/templates/config.json +253 -16
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: monitor
|
|
3
|
+
description: Self-healing deployments - connect to error tracking (Sentry/LogRocket), auto-create fix stories, and optionally auto-fix with PR creation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<objective>
|
|
7
|
+
CTX 3.3 Self-Healing Deployments - Monitor production errors and automatically create fix stories or even auto-fix with PR creation.
|
|
8
|
+
</objective>
|
|
9
|
+
|
|
10
|
+
<usage>
|
|
11
|
+
```
|
|
12
|
+
/ctx monitor # Show monitoring status
|
|
13
|
+
/ctx monitor connect sentry # Connect Sentry integration
|
|
14
|
+
/ctx monitor connect logrocket # Connect LogRocket integration
|
|
15
|
+
/ctx monitor errors # List recent errors
|
|
16
|
+
/ctx monitor auto-fix [id] # Auto-fix specific error
|
|
17
|
+
/ctx monitor --watch # Continuous monitoring mode
|
|
18
|
+
```
|
|
19
|
+
</usage>
|
|
20
|
+
|
|
21
|
+
<workflow>
|
|
22
|
+
|
|
23
|
+
## Step 1: Connect Error Tracking
|
|
24
|
+
|
|
25
|
+
### Sentry Integration
|
|
26
|
+
```bash
|
|
27
|
+
/ctx monitor connect sentry
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Prompts for:
|
|
31
|
+
- Sentry DSN or API token
|
|
32
|
+
- Organization slug
|
|
33
|
+
- Project slug
|
|
34
|
+
- Environment filter (production, staging, etc.)
|
|
35
|
+
|
|
36
|
+
Stores in `.ctx/config.json`:
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"monitor": {
|
|
40
|
+
"sentry": {
|
|
41
|
+
"enabled": true,
|
|
42
|
+
"token": "env:SENTRY_AUTH_TOKEN",
|
|
43
|
+
"organization": "my-org",
|
|
44
|
+
"project": "my-app",
|
|
45
|
+
"environment": "production"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### LogRocket Integration
|
|
52
|
+
```bash
|
|
53
|
+
/ctx monitor connect logrocket
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Stores in `.ctx/config.json`:
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"monitor": {
|
|
60
|
+
"logrocket": {
|
|
61
|
+
"enabled": true,
|
|
62
|
+
"appId": "my-org/my-app",
|
|
63
|
+
"apiKey": "env:LOGROCKET_API_KEY"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Step 2: Fetch Errors
|
|
70
|
+
|
|
71
|
+
Poll error tracking service:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
[MONITOR] Fetching errors from Sentry...
|
|
75
|
+
|
|
76
|
+
Recent Errors (last 24h):
|
|
77
|
+
|
|
78
|
+
ID | Error | Count | Users | First Seen
|
|
79
|
+
----------|--------------------------------|-------|-------|------------
|
|
80
|
+
ERR-001 | TypeError: Cannot read 'id' | 45 | 12 | 2h ago
|
|
81
|
+
ERR-002 | NetworkError: Failed to fetch | 23 | 8 | 4h ago
|
|
82
|
+
ERR-003 | ValidationError: Invalid email | 15 | 15 | 6h ago
|
|
83
|
+
ERR-004 | 500: Internal Server Error | 8 | 5 | 12h ago
|
|
84
|
+
|
|
85
|
+
Actions:
|
|
86
|
+
[1] View ERR-001 details
|
|
87
|
+
[2] Create fix story for ERR-001
|
|
88
|
+
[A] Auto-fix ERR-001 (creates PR)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Step 3: Error Analysis
|
|
92
|
+
|
|
93
|
+
When viewing error details:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
[MONITOR] Error Details: ERR-001
|
|
97
|
+
|
|
98
|
+
Type: TypeError
|
|
99
|
+
Message: Cannot read properties of undefined (reading 'id')
|
|
100
|
+
File: src/components/UserProfile.tsx:45
|
|
101
|
+
Function: UserProfile
|
|
102
|
+
|
|
103
|
+
Stack Trace:
|
|
104
|
+
at UserProfile (src/components/UserProfile.tsx:45:23)
|
|
105
|
+
at renderWithHooks (node_modules/react-dom/...)
|
|
106
|
+
at mountIndeterminateComponent (...)
|
|
107
|
+
|
|
108
|
+
Context:
|
|
109
|
+
- URL: /users/123/profile
|
|
110
|
+
- Browser: Chrome 120
|
|
111
|
+
- User: authenticated
|
|
112
|
+
- Session: 5 minutes
|
|
113
|
+
|
|
114
|
+
Similar Errors:
|
|
115
|
+
- 3 occurrences in UserSettings.tsx (same pattern)
|
|
116
|
+
- Last occurred: 15 minutes ago
|
|
117
|
+
|
|
118
|
+
Suggested Fix:
|
|
119
|
+
Add null check: user?.id instead of user.id
|
|
120
|
+
Or add loading state guard
|
|
121
|
+
|
|
122
|
+
Actions:
|
|
123
|
+
[F] Create fix story
|
|
124
|
+
[A] Auto-fix and create PR
|
|
125
|
+
[I] Ignore (mark as expected)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Step 4: Create Fix Story
|
|
129
|
+
|
|
130
|
+
Automatically generate story from error:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"id": "S-FIX-001",
|
|
135
|
+
"title": "Fix TypeError in UserProfile component",
|
|
136
|
+
"type": "fix",
|
|
137
|
+
"priority": "high",
|
|
138
|
+
"source": "sentry",
|
|
139
|
+
"errorId": "ERR-001",
|
|
140
|
+
"description": "TypeError: Cannot read properties of undefined (reading 'id') in UserProfile.tsx:45",
|
|
141
|
+
"acceptance": [
|
|
142
|
+
"Error no longer occurs on /users/*/profile pages",
|
|
143
|
+
"Proper loading state shown while user data loads",
|
|
144
|
+
"Null check added for user object",
|
|
145
|
+
"Similar pattern fixed in UserSettings.tsx",
|
|
146
|
+
"Error rate drops to 0 for this issue"
|
|
147
|
+
],
|
|
148
|
+
"context": {
|
|
149
|
+
"file": "src/components/UserProfile.tsx",
|
|
150
|
+
"line": 45,
|
|
151
|
+
"errorCount": 45,
|
|
152
|
+
"affectedUsers": 12,
|
|
153
|
+
"stackTrace": "..."
|
|
154
|
+
},
|
|
155
|
+
"suggestedFix": "Add optional chaining: user?.id"
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Step 5: Auto-Fix Mode
|
|
160
|
+
|
|
161
|
+
For simple errors, auto-fix with PR:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
[MONITOR] Auto-Fix: ERR-001
|
|
165
|
+
|
|
166
|
+
Analyzing error...
|
|
167
|
+
✓ Pattern identified: Missing null check
|
|
168
|
+
✓ Fix available: Add optional chaining
|
|
169
|
+
✓ Similar locations found: 2 files
|
|
170
|
+
|
|
171
|
+
Generating fix...
|
|
172
|
+
✓ Modified: src/components/UserProfile.tsx
|
|
173
|
+
✓ Modified: src/components/UserSettings.tsx
|
|
174
|
+
✓ Added loading state guard
|
|
175
|
+
|
|
176
|
+
Verification:
|
|
177
|
+
✓ TypeScript compiles
|
|
178
|
+
✓ Tests pass
|
|
179
|
+
✓ No new errors introduced
|
|
180
|
+
|
|
181
|
+
Creating PR...
|
|
182
|
+
✓ Branch: fix/err-001-userprofile-null-check
|
|
183
|
+
✓ PR: #123 - Fix TypeError in UserProfile
|
|
184
|
+
|
|
185
|
+
[MONITOR] Auto-fix complete!
|
|
186
|
+
|
|
187
|
+
PR: https://github.com/org/repo/pull/123
|
|
188
|
+
Review required before merge.
|
|
189
|
+
|
|
190
|
+
Slack notification sent to #dev-alerts.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
</workflow>
|
|
194
|
+
|
|
195
|
+
<auto_fix_rules>
|
|
196
|
+
|
|
197
|
+
## Safe Auto-Fix Patterns
|
|
198
|
+
|
|
199
|
+
CTX can auto-fix these patterns:
|
|
200
|
+
|
|
201
|
+
| Pattern | Fix | Risk |
|
|
202
|
+
|---------|-----|------|
|
|
203
|
+
| Missing null check | Add optional chaining | Low |
|
|
204
|
+
| Undefined property | Add default value | Low |
|
|
205
|
+
| Missing import | Add import statement | Low |
|
|
206
|
+
| Type mismatch | Add type assertion | Medium |
|
|
207
|
+
| Missing error handling | Add try/catch | Medium |
|
|
208
|
+
| Race condition | Add async guard | Medium |
|
|
209
|
+
|
|
210
|
+
## Requires Human Review
|
|
211
|
+
|
|
212
|
+
These need human approval:
|
|
213
|
+
|
|
214
|
+
| Pattern | Reason |
|
|
215
|
+
|---------|--------|
|
|
216
|
+
| Logic errors | Business logic understanding needed |
|
|
217
|
+
| Security issues | Careful review required |
|
|
218
|
+
| Database changes | Migration risk |
|
|
219
|
+
| API changes | Breaking change risk |
|
|
220
|
+
| Performance issues | Optimization choices |
|
|
221
|
+
|
|
222
|
+
## Auto-Fix Process
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
1. Identify error pattern
|
|
226
|
+
2. Check if pattern is in safe list
|
|
227
|
+
3. If safe:
|
|
228
|
+
a. Generate fix
|
|
229
|
+
b. Run tests
|
|
230
|
+
c. Create PR
|
|
231
|
+
d. Notify team
|
|
232
|
+
4. If not safe:
|
|
233
|
+
a. Create fix story
|
|
234
|
+
b. Assign to on-call
|
|
235
|
+
c. Provide context
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
</auto_fix_rules>
|
|
239
|
+
|
|
240
|
+
<continuous_monitoring>
|
|
241
|
+
|
|
242
|
+
## Watch Mode
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
/ctx monitor --watch
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Continuous monitoring with alerts:
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
[MONITOR] Watching production errors...
|
|
252
|
+
|
|
253
|
+
Press Ctrl+C to stop.
|
|
254
|
+
|
|
255
|
+
[10:30:15] New error: TypeError in checkout.ts
|
|
256
|
+
→ Creating fix story S-FIX-002
|
|
257
|
+
→ Slack alert sent
|
|
258
|
+
|
|
259
|
+
[10:45:00] Error spike detected: NetworkError (50 in 5min)
|
|
260
|
+
→ Possible API outage
|
|
261
|
+
→ Escalating to #incidents
|
|
262
|
+
|
|
263
|
+
[11:00:00] Error resolved: ERR-001 (no occurrences in 30min)
|
|
264
|
+
→ Closing related story
|
|
265
|
+
|
|
266
|
+
[11:15:00] Auto-fixed: Simple null check in profile.ts
|
|
267
|
+
→ PR #124 created
|
|
268
|
+
→ Awaiting review
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Alert Rules
|
|
272
|
+
|
|
273
|
+
`.ctx/config.json`:
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"monitor": {
|
|
277
|
+
"alerts": {
|
|
278
|
+
"errorSpike": {
|
|
279
|
+
"threshold": 50,
|
|
280
|
+
"window": "5m",
|
|
281
|
+
"action": "escalate"
|
|
282
|
+
},
|
|
283
|
+
"newError": {
|
|
284
|
+
"action": "create-story"
|
|
285
|
+
},
|
|
286
|
+
"criticalError": {
|
|
287
|
+
"keywords": ["payment", "auth", "security"],
|
|
288
|
+
"action": "page-oncall"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
</continuous_monitoring>
|
|
296
|
+
|
|
297
|
+
<integrations>
|
|
298
|
+
|
|
299
|
+
## Error Tracking Services
|
|
300
|
+
|
|
301
|
+
### Sentry
|
|
302
|
+
```json
|
|
303
|
+
{
|
|
304
|
+
"sentry": {
|
|
305
|
+
"enabled": true,
|
|
306
|
+
"token": "env:SENTRY_AUTH_TOKEN",
|
|
307
|
+
"organization": "org-slug",
|
|
308
|
+
"project": "project-slug",
|
|
309
|
+
"environment": "production",
|
|
310
|
+
"issueUrl": "https://sentry.io/organizations/{org}/issues/{id}/"
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
API Usage:
|
|
316
|
+
- List issues: `GET /api/0/projects/{org}/{project}/issues/`
|
|
317
|
+
- Get issue: `GET /api/0/issues/{id}/`
|
|
318
|
+
- Get events: `GET /api/0/issues/{id}/events/`
|
|
319
|
+
|
|
320
|
+
### LogRocket
|
|
321
|
+
```json
|
|
322
|
+
{
|
|
323
|
+
"logrocket": {
|
|
324
|
+
"enabled": true,
|
|
325
|
+
"appId": "org/app",
|
|
326
|
+
"apiKey": "env:LOGROCKET_API_KEY",
|
|
327
|
+
"sessionUrl": "https://app.logrocket.com/{appId}/sessions/{id}"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Bugsnag
|
|
333
|
+
```json
|
|
334
|
+
{
|
|
335
|
+
"bugsnag": {
|
|
336
|
+
"enabled": true,
|
|
337
|
+
"apiKey": "env:BUGSNAG_API_KEY",
|
|
338
|
+
"projectId": "project-id"
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Datadog
|
|
344
|
+
```json
|
|
345
|
+
{
|
|
346
|
+
"datadog": {
|
|
347
|
+
"enabled": true,
|
|
348
|
+
"apiKey": "env:DD_API_KEY",
|
|
349
|
+
"appKey": "env:DD_APP_KEY",
|
|
350
|
+
"site": "datadoghq.com"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Notification Services
|
|
356
|
+
|
|
357
|
+
### Slack
|
|
358
|
+
```json
|
|
359
|
+
{
|
|
360
|
+
"notifications": {
|
|
361
|
+
"slack": {
|
|
362
|
+
"webhook": "env:SLACK_WEBHOOK_URL",
|
|
363
|
+
"channels": {
|
|
364
|
+
"errors": "#dev-errors",
|
|
365
|
+
"incidents": "#incidents",
|
|
366
|
+
"fixes": "#auto-fixes"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### PagerDuty
|
|
374
|
+
```json
|
|
375
|
+
{
|
|
376
|
+
"notifications": {
|
|
377
|
+
"pagerduty": {
|
|
378
|
+
"routingKey": "env:PAGERDUTY_ROUTING_KEY",
|
|
379
|
+
"severityMapping": {
|
|
380
|
+
"critical": "critical",
|
|
381
|
+
"high": "error",
|
|
382
|
+
"medium": "warning"
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
</integrations>
|
|
390
|
+
|
|
391
|
+
<output_format>
|
|
392
|
+
|
|
393
|
+
## Status Output
|
|
394
|
+
```
|
|
395
|
+
[MONITOR] Production Monitoring Status
|
|
396
|
+
|
|
397
|
+
Services Connected:
|
|
398
|
+
✓ Sentry (my-org/my-app)
|
|
399
|
+
○ LogRocket (not configured)
|
|
400
|
+
○ Bugsnag (not configured)
|
|
401
|
+
|
|
402
|
+
Last 24 Hours:
|
|
403
|
+
Errors: 91 (↓15% from yesterday)
|
|
404
|
+
Unique: 4 error types
|
|
405
|
+
Users affected: 40
|
|
406
|
+
Auto-fixed: 2
|
|
407
|
+
|
|
408
|
+
Active Issues:
|
|
409
|
+
ERR-001: TypeError in UserProfile (45 occurrences)
|
|
410
|
+
ERR-002: NetworkError (23 occurrences)
|
|
411
|
+
|
|
412
|
+
Recent Auto-Fixes:
|
|
413
|
+
PR #123: Null check in profile.ts (merged)
|
|
414
|
+
PR #124: Loading state in dashboard.tsx (pending)
|
|
415
|
+
|
|
416
|
+
Monitoring: Active
|
|
417
|
+
Watch mode: /ctx monitor --watch
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Error Alert
|
|
421
|
+
```
|
|
422
|
+
[MONITOR] 🚨 New Production Error
|
|
423
|
+
|
|
424
|
+
Type: TypeError
|
|
425
|
+
Message: Cannot read 'id' of undefined
|
|
426
|
+
File: src/checkout.ts:78
|
|
427
|
+
Users: 5 affected
|
|
428
|
+
First seen: 2 minutes ago
|
|
429
|
+
|
|
430
|
+
Quick actions:
|
|
431
|
+
[V] View details
|
|
432
|
+
[F] Create fix story
|
|
433
|
+
[A] Auto-fix
|
|
434
|
+
[I] Ignore
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
</output_format>
|
|
438
|
+
|
|
439
|
+
<configuration>
|
|
440
|
+
|
|
441
|
+
## Full Monitor Config
|
|
442
|
+
|
|
443
|
+
`.ctx/config.json`:
|
|
444
|
+
```json
|
|
445
|
+
{
|
|
446
|
+
"monitor": {
|
|
447
|
+
"enabled": true,
|
|
448
|
+
"pollInterval": "5m",
|
|
449
|
+
"autoFix": {
|
|
450
|
+
"enabled": true,
|
|
451
|
+
"safePatterns": ["null-check", "import-missing", "type-mismatch"],
|
|
452
|
+
"requireReview": true,
|
|
453
|
+
"createPR": true
|
|
454
|
+
},
|
|
455
|
+
"alerts": {
|
|
456
|
+
"slack": true,
|
|
457
|
+
"pagerduty": false,
|
|
458
|
+
"email": false
|
|
459
|
+
},
|
|
460
|
+
"ignore": {
|
|
461
|
+
"patterns": ["ResizeObserver", "Script error"],
|
|
462
|
+
"environments": ["development", "staging"]
|
|
463
|
+
},
|
|
464
|
+
"sentry": {
|
|
465
|
+
"enabled": true,
|
|
466
|
+
"token": "env:SENTRY_AUTH_TOKEN",
|
|
467
|
+
"organization": "my-org",
|
|
468
|
+
"project": "my-app"
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
</configuration>
|