|
1
|
--- |
|
2
|
name: diagnostics |
|
3
|
description: Access LSP diagnostics and suggest project rollback. Use for debugging static errors and helping users revert changes. |
|
4
|
--- |
|
5
|
|
|
6
|
# Diagnostics Skill |
|
7
|
|
|
8
|
Tools for debugging code issues and managing project state. |
|
9
|
|
|
10
|
## When to Use |
|
11
|
|
|
12
|
Use this skill when: |
|
13
|
|
|
14
|
- Checking for syntax errors, type errors, or import issues after code changes |
|
15
|
- User wants to undo changes or revert to a previous state |
|
16
|
- Debugging static errors detected by the language server |
|
17
|
|
|
18
|
## When NOT to Use |
|
19
|
|
|
20
|
- Runtime errors or logic bugs (use logs and debugging) |
|
21
|
- Small changes that don't need LSP validation |
|
22
|
- Code search (use grep/glob tools) |
|
23
|
|
|
24
|
## Available Functions |
|
25
|
|
|
26
|
### getLatestLspDiagnostics(filePath=None) |
|
27
|
|
|
28
|
Retrieve LSP diagnostics - syntax errors, type errors, and code issues. |
|
29
|
|
|
30
|
**Parameters:** |
|
31
|
|
|
32
|
- `filePath` (str, optional): File path to check. If omitted, checks all files with errors. |
|
33
|
|
|
34
|
**Returns:** Dict with `diagnostics` (file paths to error lists) and `filePath` (filter used) |
|
35
|
|
|
36
|
**Example:** |
|
37
|
|
|
38
|
```javascript |
|
39
|
// Check specific file after editing |
|
40
|
const result = await getLatestLspDiagnostics({ filePath: "src/auth.ts" }); |
|
41
|
for (const [path, errors] of Object.entries(result.diagnostics)) { |
|
42
|
for (const error of errors) { |
|
43
|
console.log(`Line ${error.startLine}: ${error.message}`); |
|
44
|
} |
|
45
|
} |
|
46
|
|
|
47
|
// Check all files for errors |
|
48
|
const allErrors = await getLatestLspDiagnostics(); |
|
49
|
console.log(`Files with errors: ${Object.keys(allErrors.diagnostics)}`); |
|
50
|
``` |
|
51
|
|
|
52
|
**When to check LSP:** |
|
53
|
|
|
54
|
- After refactoring >100 lines of code |
|
55
|
- User reports "errors" or "something's not working" |
|
56
|
- After adding imports or dependencies |
|
57
|
- Before completing a task with >100 lines of changes |
|
58
|
|
|
59
|
**Skip LSP when:** |
|
60
|
|
|
61
|
- Making small changes (<10 lines) |
|
62
|
- Adding comments or documentation |
|
63
|
- Debugging runtime errors (LSP won't show these) |
|
64
|
|
|
65
|
### suggestRollback(reason) |
|
66
|
|
|
67
|
Suggest rolling back to a previous checkpoint. |
|
68
|
|
|
69
|
**Parameters:** |
|
70
|
|
|
71
|
- `reason` (str, required): Short, non-technical explanation for why rollback is suggested |
|
72
|
|
|
73
|
**Returns:** Dict with `success`, `message`, and `reason` |
|
74
|
|
|
75
|
**Example:** |
|
76
|
|
|
77
|
```javascript |
|
78
|
await suggestRollback({ reason: "The changes caused unexpected errors across multiple files" }); |
|
79
|
``` |
|
80
|
|
|
81
|
**Use when user expresses intent to:** |
|
82
|
|
|
83
|
- Undo changes: "can you undo what you just did?", "revert the last changes" |
|
84
|
- Restore previous version: "roll back", "go back to how it was yesterday" |
|
85
|
- Fix major error: "you deleted my database!", "everything is broken" |
|
86
|
- Try different approach: "take a completely different approach", "start over" |
|
87
|
|
|
88
|
**Important:** |
|
89
|
|
|
90
|
- This does NOT perform the rollback - it shows a "View Checkpoints" button |
|
91
|
- After calling, direct the user to click the button that appears |
|
92
|
- This pauses the agent to wait for user response |
|
93
|
|
|
94
|
## Best Practices |
|
95
|
|
|
96
|
1. **Check LSP after significant changes**: Large refactors, new features, or when user reports errors |
|
97
|
2. **Use filePath parameter**: When checking a specific file you just edited |
|
98
|
3. **Suggest rollback carefully**: Only when user clearly wants to undo or revert |
|
99
|
|
|
100
|
## Example Workflows |
|
101
|
|
|
102
|
### Debugging after refactoring |
|
103
|
|
|
104
|
```javascript |
|
105
|
// After making code changes |
|
106
|
const errors = await getLatestLspDiagnostics({ filePath: "src/services/user.ts" }); |
|
107
|
if (Object.keys(errors.diagnostics).length > 0) { |
|
108
|
// Fix each error |
|
109
|
for (const [path, diags] of Object.entries(errors.diagnostics)) { |
|
110
|
for (const diag of diags) { |
|
111
|
console.log(`Fix: ${diag.rendered}`); |
|
112
|
} |
|
113
|
} |
|
114
|
} |
|
115
|
``` |
|
116
|
|
|
117
|
### Helping user undo changes |
|
118
|
|
|
119
|
```javascript |
|
120
|
// User: "Everything broke, can you undo this?" |
|
121
|
await suggestRollback({ reason: "Recent changes caused errors. Click View Checkpoints to restore a working version." }); |
|
122
|
``` |