Skip to content

Commit 16cf90f

Browse files
committed
feat: add debugger_set_logpoint and debugger_remove_logpoint tools with documentation and tests.
1 parent a7f6d4e commit 16cf90f

5 files changed

Lines changed: 459 additions & 273 deletions

File tree

scripts/post-build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const DEFAULT_LOCALE = 'en-US';
4141
export const REMOTE_FETCH_PATTERN = '@HOST@/remote/serve_file/@VERSION@/core/i18n/locales/@LOCALE@.json';
4242
4343
export const LOCAL_FETCH_PATTERN = './locales/@LOCALE@.json';`;
44-
fs.mkdirSync(i18nDir, { recursive: true });
44+
fs.mkdirSync(i18nDir, {recursive: true});
4545
writeFile(localesFile, localesContent);
4646

4747
// Create codemirror.next mock.

skills/breakpoint-debugging/SKILL.md

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,92 @@ This skill allows you to perform in-depth Root Cause Analysis (RCA) by controlli
99

1010
## Tools
1111

12-
- `debugger_enable`: Enable the debugger for the page. **Must be called first.**
13-
- `debugger_set_breakpoint`: Set a breakpoint at a specific URL and line number.
14-
- `debugger_get_paused_state`: Check if the debugger is paused and get the call stack.
15-
- `debugger_get_scope_variables`: Inspect variables in a specific scope when paused.
16-
- `debugger_step_over` / `debugger_step_into` / `debugger_step_out`: Control execution.
17-
- `debugger_resume`: Resume execution.
18-
- `debugger_evaluate_on_call_frame`: Evaluate expressions in the current context.
19-
- `debugger_get_code_lines`: Read code around a specific line.
12+
- `debugger_enable`: Enable the debugger for the page. **Must be called first.**
13+
- `debugger_set_breakpoint`: Set a breakpoint at a specific URL and line number.
14+
- `debugger_set_logpoint`: Set a logpoint that logs a message to the console without pausing.
15+
- `debugger_remove_breakpoint` / `debugger_remove_logpoint`: Remove a breakpoint or logpoint.
16+
- `debugger_get_paused_state`: Check if the debugger is paused and get the call stack.
17+
- `debugger_get_scope_variables`: Inspect variables in a specific scope when paused.
18+
- `debugger_step_over` / `debugger_step_into` / `debugger_step_out`: Control execution.
19+
- `debugger_resume`: Resume execution.
20+
- `debugger_evaluate_on_call_frame`: Evaluate expressions in the current context.
21+
- `debugger_get_code_lines`: Read code around a specific line.
22+
- `list_console_messages`: View console output (useful for logpoints).
2023

2124
## Root Cause Analysis Workflow
2225

2326
Your objective is to find the **root cause** of an error or bug. Do not stop at the surface level.
2427

2528
1. **Enable Debugger**: Always start by ensuring the debugger is enabled.
29+
2630
```javascript
2731
// Example
28-
debugger_enable({})
32+
debugger_enable({});
2933
```
3034

3135
2. **Hypothesize & Set Trap**:
32-
- Read the code using `debugger_get_code_lines` (or `read_file` if local) to understand the logic.
33-
- Identify the critical line where state corruption likely occurred.
34-
- Set a breakpoint on that line.
36+
- Read the code using `debugger_get_code_lines` (or `read_file` if local) to understand the logic.
37+
- Identify the critical line where state corruption likely occurred.
38+
- Set a breakpoint on that line.
39+
3540
```javascript
36-
debugger_set_breakpoint({ url: 'http://localhost:8080/app.js', lineNumber: 42 })
41+
debugger_set_breakpoint({
42+
url: 'http://localhost:8080/app.js',
43+
lineNumber: 42,
44+
});
3745
```
3846

3947
3. **Trigger & Wait**:
40-
- Perform the action that triggers the bug (e.g., clicking a button using `click`).
41-
- Check if the debugger is paused using `debugger_get_paused_state`.
42-
- **Note**: If `debugger_get_paused_state` returns "Debugger is not paused", wait a moment and try again, or ask the user to trigger the action if you cannot.
48+
- Perform the action that triggers the bug (e.g., clicking a button using `click`).
49+
- Check if the debugger is paused using `debugger_get_paused_state`.
50+
- **Note**: If `debugger_get_paused_state` returns "Debugger is not paused", wait a moment and try again, or ask the user to trigger the action if you cannot.
4351

4452
4. **Inspect State (Runtime Mode)**:
45-
- Once paused, examine the `callStack` returned by `debugger_get_paused_state`.
46-
- Use `debugger_get_scope_variables` to see values of local variables.
47-
- Use `debugger_evaluate_on_call_frame` to check specific expressions or deep objects.
53+
- Once paused, examine the `callStack` returned by `debugger_get_paused_state`.
54+
- Use `debugger_get_scope_variables` to see values of local variables.
55+
- Use `debugger_evaluate_on_call_frame` to check specific expressions or deep objects.
56+
4857
```javascript
4958
// Check local variables (scopeIndex 0 is usually Local)
50-
debugger_get_scope_variables({ callFrameId: '...', scopeIndex: 0 })
59+
debugger_get_scope_variables({callFrameId: '...', scopeIndex: 0});
5160
```
5261

5362
5. **Step & Trace**:
54-
- Use `debugger_step_into` to enter function calls.
55-
- Use `debugger_step_over` to advance line-by-line.
56-
- Use `debugger_step_out` to return to the caller.
57-
- **Always** check `debugger_get_paused_state` and variable values after stepping to see how state changed.
63+
- Use `debugger_step_into` to enter function calls.
64+
- Use `debugger_step_over` to advance line-by-line.
65+
- Use `debugger_step_out` to return to the caller.
66+
- **Always** check `debugger_get_paused_state` and variable values after stepping to see how state changed.
5867

5968
6. **Verify Root Cause**:
60-
- Explain exactly how the runtime state contradicts the expected logic.
61-
- Point to the specific line of code that is the root cause.
69+
- Explain exactly how the runtime state contradicts the expected logic.
70+
- Point to the specific line of code that is the root cause.
6271

6372
7. **Apply Fix & Verify**:
64-
- Once the issue is found, you can try to fix it (e.g., by editing the file).
65-
- Remove breakpoints using `debugger_remove_breakpoint` or `debugger_remove_all_breakpoints`.
66-
- Resume execution with `debugger_resume`.
67-
- Verify the fix by reproducing the steps.
73+
- Once the issue is found, you can try to fix it (e.g., by editing the file).
74+
- Remove breakpoints using `debugger_remove_breakpoint` or `debugger_remove_all_breakpoints`.
75+
- Resume execution with `debugger_resume`.
76+
- Verify the fix by reproducing the steps.
77+
78+
## Logpoints (Non-breaking Breakpoints)
79+
80+
Use logpoints to trace execution without pausing. This is useful for debugging loops or high-frequency events.
81+
82+
1. **Set Logpoint**:
83+
```javascript
84+
// Logs "Value of x is 42" to the console
85+
debugger_set_logpoint({
86+
url: '...',
87+
lineNumber: 10,
88+
message: 'Value of x is {x}',
89+
});
90+
```
91+
2. **View Output**:
92+
- Use `list_console_messages` to see the logs.
93+
- Logpoints do NOT pause execution.
6894

6995
## Tips
7096

71-
- **STATIC MODE** (Reading code) vs **RUNTIME MODE** (Paused): Switch between them. If you need to see a variable, switch to Runtime Mode by setting a breakpoint.
72-
- **Already Paused?**: If you are already paused, start inspecting immediately.
73-
- **Step Into**: Essential for investigating function calls on the current line.
74-
- **Check Location**: Always confirm where you are with `debugger_get_paused_state` after stepping.
97+
- **STATIC MODE** (Reading code) vs **RUNTIME MODE** (Paused): Switch between them. If you need to see a variable, switch to Runtime Mode by setting a breakpoint.
98+
- **Already Paused?**: If you are already paused, start inspecting immediately.
99+
- **Step Into**: Essential for investigating function calls on the current line.
100+
- **Check Location**: Always confirm where you are with `debugger_get_paused_state` after stepping.

0 commit comments

Comments
 (0)