agent-dbg 0.1.0 → 0.1.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.
Files changed (71) hide show
  1. package/.claude/settings.local.json +7 -5
  2. package/.claude/skills/agent-dbg/SKILL.md +116 -0
  3. package/.claude/skills/agent-dbg/references/commands.md +173 -0
  4. package/.vscode/launch.json +19 -0
  5. package/CLAUDE.md +2 -2
  6. package/PROGRESS.md +91 -91
  7. package/README.md +45 -17
  8. package/{ndbg-spec.md → SPEC.md} +152 -152
  9. package/dist/main.js +12500 -0
  10. package/package.json +3 -3
  11. package/src/cdp/client.ts +18 -4
  12. package/src/cdp/logger.ts +69 -0
  13. package/src/cli/parser.ts +54 -43
  14. package/src/commands/attach.ts +2 -2
  15. package/src/commands/blackbox-ls.ts +1 -1
  16. package/src/commands/blackbox-rm.ts +3 -3
  17. package/src/commands/blackbox.ts +2 -2
  18. package/src/commands/break-ls.ts +3 -2
  19. package/src/commands/break-rm.ts +2 -2
  20. package/src/commands/break-toggle.ts +2 -2
  21. package/src/commands/break.ts +46 -17
  22. package/src/commands/breakable.ts +2 -2
  23. package/src/commands/catch.ts +2 -2
  24. package/src/commands/console.ts +1 -1
  25. package/src/commands/continue.ts +5 -18
  26. package/src/commands/eval.ts +2 -2
  27. package/src/commands/exceptions.ts +1 -1
  28. package/src/commands/hotpatch.ts +2 -2
  29. package/src/commands/launch.ts +7 -11
  30. package/src/commands/logpoint.ts +7 -6
  31. package/src/commands/logs.ts +116 -0
  32. package/src/commands/pause.ts +5 -18
  33. package/src/commands/print-state.ts +85 -0
  34. package/src/commands/props.ts +2 -2
  35. package/src/commands/restart-frame.ts +1 -1
  36. package/src/commands/restart.ts +42 -0
  37. package/src/commands/run-to.ts +7 -20
  38. package/src/commands/scripts.ts +1 -1
  39. package/src/commands/search.ts +4 -3
  40. package/src/commands/set-return.ts +2 -2
  41. package/src/commands/set.ts +3 -3
  42. package/src/commands/source.ts +3 -2
  43. package/src/commands/sourcemap.ts +1 -1
  44. package/src/commands/stack.ts +1 -1
  45. package/src/commands/state.ts +3 -73
  46. package/src/commands/status.ts +3 -2
  47. package/src/commands/step.ts +5 -18
  48. package/src/commands/vars.ts +3 -1
  49. package/src/daemon/entry.ts +16 -6
  50. package/src/daemon/paths.ts +6 -2
  51. package/src/daemon/server.ts +1 -1
  52. package/src/daemon/session-breakpoints.ts +7 -2
  53. package/src/daemon/session-inspection.ts +6 -10
  54. package/src/daemon/session-state.ts +6 -5
  55. package/src/daemon/session.ts +23 -3
  56. package/src/formatter/logs.ts +110 -0
  57. package/src/formatter/path.ts +27 -0
  58. package/src/formatter/stack.ts +5 -2
  59. package/src/formatter/variables.ts +48 -1
  60. package/src/main.ts +2 -0
  61. package/src/protocol/messages.ts +3 -0
  62. package/tests/fixtures/async-app.js +1 -1
  63. package/tests/fixtures/error-app.js +1 -1
  64. package/tests/fixtures/simple-app.js +1 -1
  65. package/tests/fixtures/ts-app/src/app.ts +4 -0
  66. package/tests/integration/state.test.ts +7 -7
  67. package/tests/unit/daemon.test.ts +1 -1
  68. package/tests/unit/formatter.test.ts +8 -4
  69. package/.bin/ndbg +0 -0
  70. package/.claude/skills/ndbg-debugger/ndbg-debugger/SKILL.md +0 -116
  71. package/.claude/skills/ndbg-debugger/ndbg-debugger/references/commands.md +0 -173
@@ -1,4 +1,4 @@
1
- # ndbg — Node.js Debugger CLI for AI Agents
1
+ # agent-dbg — Node.js Debugger CLI for AI Agents
2
2
 
3
3
  ## Specification v1.0
4
4
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 1. Vision
8
8
 
9
- `ndbg` is a command-line debugger for Node.js designed specifically for AI coding agents (Claude Code, Codex, Cursor, Gemini CLI, etc.). It wraps the V8 Inspector Protocol (Chrome DevTools Protocol) behind a token-efficient, stateless CLI interface that lets agents autonomously set breakpoints, step through code, inspect variables, profile memory, and even hot-patch code — all through bash.
9
+ `agent-dbg` is a command-line debugger for Node.js designed specifically for AI coding agents (Claude Code, Codex, Cursor, Gemini CLI, etc.). It wraps the V8 Inspector Protocol (Chrome DevTools Protocol) behind a token-efficient, stateless CLI interface that lets agents autonomously set breakpoints, step through code, inspect variables, profile memory, and even hot-patch code — all through bash.
10
10
 
11
11
  **Core principle:** every tool call should return maximum debugging insight for minimum token cost.
12
12
 
@@ -28,9 +28,9 @@ Humans can use it too. `--color` flag enables ANSI colors for terminal use.
28
28
 
29
29
  ### 2.2 CLI over MCP
30
30
 
31
- ndbg is a CLI tool, not an MCP server. Rationale:
31
+ agent-dbg is a CLI tool, not an MCP server. Rationale:
32
32
 
33
- - **Zero setup** — `npm i -g ndbg` or `npx ndbg`, no MCP config files
33
+ - **Zero setup** — `npm i -g agent-dbg` or `npx agent-dbg`, no MCP config files
34
34
  - **Context efficient** — no JSON-RPC overhead, no schema in every call
35
35
  - **Composable** — can pipe to grep/jq, chain with other bash commands
36
36
  - **Universal** — works with any agent that has shell access, not just MCP clients
@@ -38,9 +38,9 @@ ndbg is a CLI tool, not an MCP server. Rationale:
38
38
 
39
39
  ### 2.3 Daemon architecture
40
40
 
41
- Debugging is inherently stateful (a process paused at a breakpoint). ndbg uses a background daemon model:
41
+ Debugging is inherently stateful (a process paused at a breakpoint). agent-dbg uses a background daemon model:
42
42
 
43
- - `ndbg launch` starts a daemon that holds the WebSocket connection to the V8 inspector
43
+ - `agent-dbg launch` starts a daemon that holds the WebSocket connection to the V8 inspector
44
44
  - All subsequent CLI calls communicate with the daemon via a local Unix socket
45
45
  - Each CLI invocation is fast and stateless from the agent's perspective
46
46
  - The daemon manages the debug session lifecycle
@@ -57,7 +57,7 @@ Debugging is inherently stateful (a process paused at a breakpoint). ndbg uses a
57
57
 
58
58
  ## 3. The @ref System
59
59
 
60
- Inspired by agent-browser's `@e1` element refs, ndbg assigns short stable references to every inspectable entity in its output. Agents use these refs instead of long object IDs, file paths, or frame indices.
60
+ Inspired by agent-browser's `@e1` element refs, agent-dbg assigns short stable references to every inspectable entity in its output. Agents use these refs instead of long object IDs, file paths, or frame indices.
61
61
 
62
62
  ### 3.1 Ref types
63
63
 
@@ -65,7 +65,7 @@ Inspired by agent-browser's `@e1` element refs, ndbg assigns short stable refere
65
65
  |--------|--------|---------|----------|
66
66
  | `@v` | Variable / value | `@v1`, `@v2` | Until next pause (step/continue) |
67
67
  | `@f` | Stack frame | `@f0`, `@f1` | Until next pause |
68
- | `@o` | Expanded object | `@o1`, `@o2` | Until session ends or `ndbg gc-refs` |
68
+ | `@o` | Expanded object | `@o1`, `@o2` | Until session ends or `agent-dbg gc-refs` |
69
69
  | `BP#` | Breakpoint | `BP#1`, `BP#2` | Until removed |
70
70
  | `LP#` | Logpoint | `LP#1`, `LP#2` | Until removed |
71
71
  | `HS#` | Heap snapshot | `HS#1`, `HS#2` | Until session ends |
@@ -75,13 +75,13 @@ Inspired by agent-browser's `@e1` element refs, ndbg assigns short stable refere
75
75
  Refs can be used anywhere an identifier is expected:
76
76
 
77
77
  ```bash
78
- ndbg props @v1 # expand variable @v1
79
- ndbg eval "@v1.retryCount" # use ref in expressions
80
- ndbg set @v2 true # mutate variable @v2
81
- ndbg frame @f1 # switch to stack frame @f1
82
- ndbg restart-frame @f0 # restart frame @f0
83
- ndbg break-rm BP#1 # remove breakpoint BP#1
84
- ndbg heap diff HS#1 HS#2 # diff two heap snapshots
78
+ agent-dbg props @v1 # expand variable @v1
79
+ agent-dbg eval "@v1.retryCount" # use ref in expressions
80
+ agent-dbg set @v2 true # mutate variable @v2
81
+ agent-dbg frame @f1 # switch to stack frame @f1
82
+ agent-dbg restart-frame @f0 # restart frame @f0
83
+ agent-dbg break-rm BP#1 # remove breakpoint BP#1
84
+ agent-dbg heap diff HS#1 HS#2 # diff two heap snapshots
85
85
  ```
86
86
 
87
87
  ### 3.3 Ref resolution
@@ -149,7 +149,7 @@ Breakpoints:
149
149
 
150
150
  Commands that return state: `continue`, `step`, `step over`, `step into`, `step out`, `run-to`, `restart-frame`, `pause`.
151
151
 
152
- The auto-returned state uses the same format as `ndbg state` and respects a configurable default verbosity (see `ndbg config`).
152
+ The auto-returned state uses the same format as `agent-dbg state` and respects a configurable default verbosity (see `agent-dbg config`).
153
153
 
154
154
  ---
155
155
 
@@ -158,7 +158,7 @@ The auto-returned state uses the same format as `ndbg state` and respects a conf
158
158
  ### 5.1 Session Management
159
159
 
160
160
  ```
161
- ndbg launch [--brk] [--session NAME] <command...>
161
+ agent-dbg launch [--brk] [--session NAME] <command...>
162
162
  ```
163
163
  Start a Node.js process with `--inspect` (or `--inspect-brk` if `--brk` is passed) and attach the debugger daemon. Returns initial state if `--brk`.
164
164
 
@@ -168,27 +168,27 @@ Start a Node.js process with `--inspect` (or `--inspect-brk` if `--brk` is passe
168
168
  - `--timeout SECS` — daemon idle timeout (default: 300)
169
169
 
170
170
  ```
171
- ndbg attach <pid | ws-url | port>
171
+ agent-dbg attach <pid | ws-url | port>
172
172
  ```
173
173
  Attach to an already-running Node.js process (started with `--inspect`).
174
174
 
175
175
  ```
176
- ndbg stop [--session NAME]
176
+ agent-dbg stop [--session NAME]
177
177
  ```
178
178
  Kill the debugged process and shut down the daemon.
179
179
 
180
180
  ```
181
- ndbg sessions
181
+ agent-dbg sessions
182
182
  ```
183
183
  List active debug sessions with PID, status (paused/running), and session name.
184
184
 
185
185
  ```
186
- ndbg sessions --cleanup
186
+ agent-dbg sessions --cleanup
187
187
  ```
188
188
  Kill all orphaned daemon processes.
189
189
 
190
190
  ```
191
- ndbg status
191
+ agent-dbg status
192
192
  ```
193
193
  Current session info: PID, pause state, attached breakpoints, memory usage, uptime.
194
194
 
@@ -197,7 +197,7 @@ Current session info: PID, pause state, attached breakpoints, memory usage, upti
197
197
  ### 5.2 Breakpoints
198
198
 
199
199
  ```
200
- ndbg break <file>:<line> [OPTIONS]
200
+ agent-dbg break <file>:<line> [OPTIONS]
201
201
  ```
202
202
  Set a breakpoint. Returns the breakpoint ID and resolved location (with source map).
203
203
 
@@ -205,45 +205,45 @@ Options:
205
205
  - `--condition <expr>` — only pause when expression is truthy
206
206
  - `--hit-count <n>` — only pause on the Nth hit
207
207
  - `--continue` — immediately continue after setting (composite command)
208
- - `--log <template>` — convert to logpoint (shortcut for `ndbg logpoint`)
208
+ - `--log <template>` — convert to logpoint (shortcut for `agent-dbg logpoint`)
209
209
 
210
210
  ```
211
- ndbg break --pattern <urlRegex>:<line>
211
+ agent-dbg break --pattern <urlRegex>:<line>
212
212
  ```
213
213
  Set breakpoint on all files matching a URL regex pattern. Useful for breaking in `node_modules` or dynamically loaded scripts.
214
214
 
215
215
  ```
216
- ndbg break-fn <expr>
216
+ agent-dbg break-fn <expr>
217
217
  ```
218
- Set a breakpoint on every call to the function returned by evaluating `<expr>`. Example: `ndbg break-fn "require('express').Router"`.
218
+ Set a breakpoint on every call to the function returned by evaluating `<expr>`. Example: `agent-dbg break-fn "require('express').Router"`.
219
219
 
220
220
  ```
221
- ndbg break-on-load [--sourcemap]
221
+ agent-dbg break-on-load [--sourcemap]
222
222
  ```
223
223
  Break whenever a new script is parsed. With `--sourcemap`, only break on scripts with source maps (i.e., your code, not node internals).
224
224
 
225
225
  ```
226
- ndbg break-rm <BP#id | LP#id | all>
226
+ agent-dbg break-rm <BP#id | LP#id | all>
227
227
  ```
228
228
  Remove a breakpoint or logpoint by ref. `all` removes everything.
229
229
 
230
230
  ```
231
- ndbg break-ls
231
+ agent-dbg break-ls
232
232
  ```
233
233
  List all breakpoints and logpoints with their locations, conditions, and hit counts.
234
234
 
235
235
  ```
236
- ndbg break-toggle [BP#id | all]
236
+ agent-dbg break-toggle [BP#id | all]
237
237
  ```
238
238
  Enable/disable breakpoint(s) without removing them.
239
239
 
240
240
  ```
241
- ndbg breakable <file>:<start>-<end>
241
+ agent-dbg breakable <file>:<start>-<end>
242
242
  ```
243
243
  List valid breakpoint locations in a line range. Useful when the agent picks a non-breakable line.
244
244
 
245
245
  ```
246
- ndbg logpoint <file>:<line> <template>
246
+ agent-dbg logpoint <file>:<line> <template>
247
247
  ```
248
248
  Set a logpoint — logs the interpolated template string each time the line is hit, without pausing. Template uses `${expr}` syntax.
249
249
 
@@ -251,7 +251,7 @@ Set a logpoint — logs the interpolated template string each time the line is h
251
251
  - `--condition <expr>` — only log when condition is true
252
252
 
253
253
  ```
254
- ndbg catch [all | uncaught | caught | none]
254
+ agent-dbg catch [all | uncaught | caught | none]
255
255
  ```
256
256
  Configure pause-on-exception behavior. `all` catches even exceptions inside try/catch. `uncaught` is the most useful default.
257
257
 
@@ -262,12 +262,12 @@ Configure pause-on-exception behavior. `all` catches even exceptions inside try/
262
262
  All execution commands **return a state snapshot** when the process next pauses.
263
263
 
264
264
  ```
265
- ndbg continue
265
+ agent-dbg continue
266
266
  ```
267
267
  Resume execution until next breakpoint, exception, or manual pause.
268
268
 
269
269
  ```
270
- ndbg step [over | into | out]
270
+ agent-dbg step [over | into | out]
271
271
  ```
272
272
  Step one statement. Default is `over`.
273
273
 
@@ -275,22 +275,22 @@ Step one statement. Default is `over`.
275
275
  - `step over` / `step into` — accept `--skip <pattern>` to skip over matching files (inline blackboxing)
276
276
 
277
277
  ```
278
- ndbg run-to <file>:<line>
278
+ agent-dbg run-to <file>:<line>
279
279
  ```
280
280
  Continue execution until a specific location. Does not create a persistent breakpoint.
281
281
 
282
282
  ```
283
- ndbg restart-frame [@fN]
283
+ agent-dbg restart-frame [@fN]
284
284
  ```
285
285
  Re-execute the specified frame (or current frame) from the beginning. The process continues immediately and pauses at the beginning of the restarted function.
286
286
 
287
287
  ```
288
- ndbg pause
288
+ agent-dbg pause
289
289
  ```
290
290
  Interrupt a running process. Returns state at the interrupt point.
291
291
 
292
292
  ```
293
- ndbg kill-execution
293
+ agent-dbg kill-execution
294
294
  ```
295
295
  Terminate the current JavaScript execution without killing the Node.js process. Useful for stopping infinite loops while keeping the debug session alive.
296
296
 
@@ -299,34 +299,34 @@ Terminate the current JavaScript execution without killing the Node.js process.
299
299
  ### 5.4 Inspection
300
300
 
301
301
  ```
302
- ndbg state [FLAGS]
302
+ agent-dbg state [FLAGS]
303
303
  ```
304
304
  Return the current debug state snapshot. See Section 4 for flags.
305
305
 
306
306
  ```
307
- ndbg vars [name1, name2, ...]
307
+ agent-dbg vars [name1, name2, ...]
308
308
  ```
309
309
  Show local variables in the current frame. Optionally filter to specific names. Output assigns `@v` refs.
310
310
 
311
311
  ```
312
- ndbg stack [--async-depth N]
312
+ agent-dbg stack [--async-depth N]
313
313
  ```
314
314
  Show the call stack. `--async-depth` controls how many async frames to resolve (default: 8, 0 to disable).
315
315
 
316
316
  ```
317
- ndbg eval <expression>
317
+ agent-dbg eval <expression>
318
318
  ```
319
319
  Evaluate an expression in the context of the current call frame.
320
320
 
321
321
  - Supports `await` (uses CDP's `awaitPromise`)
322
- - Supports `@ref` interpolation: `ndbg eval "@v1.retryCount"`
322
+ - Supports `@ref` interpolation: `agent-dbg eval "@v1.retryCount"`
323
323
  - `--frame @fN` — evaluate in a specific frame
324
324
  - `--silent` — suppress exception reporting
325
325
  - `--timeout MS` — kill evaluation after N milliseconds (default: 5000)
326
326
  - `--side-effect-free` — throw if expression has side effects (safe inspection)
327
327
 
328
328
  ```
329
- ndbg props <@ref> [OPTIONS]
329
+ agent-dbg props <@ref> [OPTIONS]
330
330
  ```
331
331
  Expand the properties of an object ref. Returns `@o` refs for nested values.
332
332
 
@@ -336,17 +336,17 @@ Expand the properties of an object ref. Returns `@o` refs for nested values.
336
336
  - `--internal` — include V8 internal properties (e.g., `[[PromiseState]]`)
337
337
 
338
338
  ```
339
- ndbg instances <expression>
339
+ agent-dbg instances <expression>
340
340
  ```
341
- Find all live instances of a prototype/constructor. Evaluates the expression to get a prototype, then queries all objects sharing it. Example: `ndbg instances "EventEmitter.prototype"`.
341
+ Find all live instances of a prototype/constructor. Evaluates the expression to get a prototype, then queries all objects sharing it. Example: `agent-dbg instances "EventEmitter.prototype"`.
342
342
 
343
343
  ```
344
- ndbg globals
344
+ agent-dbg globals
345
345
  ```
346
346
  List all global `let`, `const`, and `class` declarations in the current execution context.
347
347
 
348
348
  ```
349
- ndbg source [OPTIONS]
349
+ agent-dbg source [OPTIONS]
350
350
  ```
351
351
  Show source code around the current pause location.
352
352
 
@@ -355,7 +355,7 @@ Show source code around the current pause location.
355
355
  - `--all` — show full file
356
356
 
357
357
  ```
358
- ndbg search <query> [OPTIONS]
358
+ agent-dbg search <query> [OPTIONS]
359
359
  ```
360
360
  Search across all loaded scripts.
361
361
 
@@ -364,12 +364,12 @@ Search across all loaded scripts.
364
364
  - `--file <scriptId>` — search within a specific script
365
365
 
366
366
  ```
367
- ndbg scripts [--filter <pattern>]
367
+ agent-dbg scripts [--filter <pattern>]
368
368
  ```
369
369
  List all loaded scripts (files). Useful to find the right `scriptId` for breakpoints in dynamically loaded code.
370
370
 
371
371
  ```
372
- ndbg console [OPTIONS]
372
+ agent-dbg console [OPTIONS]
373
373
  ```
374
374
  Show captured console output (log, warn, error, etc.) with timestamps and stack traces.
375
375
 
@@ -379,7 +379,7 @@ Show captured console output (log, warn, error, etc.) with timestamps and stack
379
379
  - `--clear` — clear captured console buffer
380
380
 
381
381
  ```
382
- ndbg exceptions [OPTIONS]
382
+ agent-dbg exceptions [OPTIONS]
383
383
  ```
384
384
  Show captured uncaught exceptions.
385
385
 
@@ -393,28 +393,28 @@ Show captured uncaught exceptions.
393
393
  These commands let an agent **test hypotheses and fixes without restarting**.
394
394
 
395
395
  ```
396
- ndbg set <@vRef | varName> <value>
396
+ agent-dbg set <@vRef | varName> <value>
397
397
  ```
398
398
  Change the value of a local, closure, or catch-scope variable in the current frame.
399
399
 
400
400
  - Value is parsed as JSON or as a JavaScript primitive
401
401
  - Only works on `local`, `closure`, and `catch` scope types (V8 limitation)
402
- - Example: `ndbg set @v2 true`, `ndbg set retryCount 0`
402
+ - Example: `agent-dbg set @v2 true`, `agent-dbg set retryCount 0`
403
403
 
404
404
  ```
405
- ndbg set-return <value>
405
+ agent-dbg set-return <value>
406
406
  ```
407
407
  Change the return value of the current function. Only available when paused at a return point.
408
408
 
409
409
  ```
410
- ndbg hotpatch <file>
410
+ agent-dbg hotpatch <file>
411
411
  ```
412
412
  Live-edit the source of a loaded script. Reads the file from disk and pushes it to V8 via `Debugger.setScriptSource`.
413
413
 
414
414
  - If the edited function is the top-most stack frame (and only activation), it auto-restarts
415
415
  - `--dry-run` — check if the edit would succeed without applying
416
416
  - Returns status: `Ok`, `CompileError`, `BlockedByActiveFunction`, etc.
417
- - **This is ndbg's killer feature for agents** — fix code and immediately verify, no restart
417
+ - **This is agent-dbg's killer feature for agents** — fix code and immediately verify, no restart
418
418
 
419
419
  ---
420
420
 
@@ -423,20 +423,20 @@ Live-edit the source of a loaded script. Reads the file from disk and pushes it
423
423
  Control which code the debugger steps into, preventing agents from getting lost in framework internals.
424
424
 
425
425
  ```
426
- ndbg blackbox <pattern...>
426
+ agent-dbg blackbox <pattern...>
427
427
  ```
428
428
  Skip stepping into scripts matching the given patterns (regex). Stepping into a blackboxed function will step over it instead.
429
429
 
430
- - Example: `ndbg blackbox "node_modules" "internal/"`
430
+ - Example: `agent-dbg blackbox "node_modules" "internal/"`
431
431
  - Stacks with previous patterns
432
432
 
433
433
  ```
434
- ndbg blackbox-ls
434
+ agent-dbg blackbox-ls
435
435
  ```
436
436
  List current blackbox patterns.
437
437
 
438
438
  ```
439
- ndbg blackbox-rm <pattern | all>
439
+ agent-dbg blackbox-rm <pattern | all>
440
440
  ```
441
441
  Remove blackbox patterns.
442
442
 
@@ -445,12 +445,12 @@ Remove blackbox patterns.
445
445
  ### 5.7 CPU Profiling
446
446
 
447
447
  ```
448
- ndbg cpu start [--interval <μs>]
448
+ agent-dbg cpu start [--interval <μs>]
449
449
  ```
450
450
  Start the V8 CPU profiler. Default sampling interval is 1000μs.
451
451
 
452
452
  ```
453
- ndbg cpu stop [--top N]
453
+ agent-dbg cpu stop [--top N]
454
454
  ```
455
455
  Stop profiling and return results.
456
456
 
@@ -459,12 +459,12 @@ Stop profiling and return results.
459
459
  - Full profile saved to a file for external tools
460
460
 
461
461
  ```
462
- ndbg coverage start [--detailed]
462
+ agent-dbg coverage start [--detailed]
463
463
  ```
464
464
  Start precise code coverage collection. `--detailed` enables block-level granularity (not just function-level).
465
465
 
466
466
  ```
467
- ndbg coverage stop [OPTIONS]
467
+ agent-dbg coverage stop [OPTIONS]
468
468
  ```
469
469
  Stop coverage and report.
470
470
 
@@ -477,22 +477,22 @@ Stop coverage and report.
477
477
  ### 5.8 Memory / Heap
478
478
 
479
479
  ```
480
- ndbg heap usage
480
+ agent-dbg heap usage
481
481
  ```
482
482
  Quick heap statistics: used, total, embedder heap, backing store. No snapshot needed.
483
483
 
484
484
  ```
485
- ndbg heap snapshot [--tag <name>]
485
+ agent-dbg heap snapshot [--tag <name>]
486
486
  ```
487
487
  Take a full V8 heap snapshot. Assigns an `HS#` ref.
488
488
 
489
489
  ```
490
- ndbg heap diff <HS#a> <HS#b> [--top N]
490
+ agent-dbg heap diff <HS#a> <HS#b> [--top N]
491
491
  ```
492
492
  Compare two heap snapshots. Output: table of constructors with delta count and delta size, sorted by size impact.
493
493
 
494
494
  ```
495
- ndbg heap sample start [--interval <bytes>] [--include-gc]
495
+ agent-dbg heap sample start [--interval <bytes>] [--include-gc]
496
496
  ```
497
497
  Start sampling heap profiler. Lightweight alternative to full snapshots.
498
498
 
@@ -500,27 +500,27 @@ Start sampling heap profiler. Lightweight alternative to full snapshots.
500
500
  - `--include-gc` — include objects already garbage-collected (shows temporary allocations)
501
501
 
502
502
  ```
503
- ndbg heap sample stop [--top N]
503
+ agent-dbg heap sample stop [--top N]
504
504
  ```
505
505
  Stop sampling and report top allocation sites.
506
506
 
507
507
  ```
508
- ndbg heap track start
508
+ agent-dbg heap track start
509
509
  ```
510
510
  Start allocation tracking over time (timeline mode).
511
511
 
512
512
  ```
513
- ndbg heap track stop
513
+ agent-dbg heap track stop
514
514
  ```
515
515
  Stop tracking and report allocation rate by callsite.
516
516
 
517
517
  ```
518
- ndbg heap inspect <heapObjectId>
518
+ agent-dbg heap inspect <heapObjectId>
519
519
  ```
520
520
  Get a remote object reference from a heap snapshot node, bridging heap analysis with runtime inspection. Returns an `@o` ref.
521
521
 
522
522
  ```
523
- ndbg gc
523
+ agent-dbg gc
524
524
  ```
525
525
  Force a garbage collection cycle. Useful before taking a snapshot to see what truly leaks.
526
526
 
@@ -529,26 +529,26 @@ Force a garbage collection cycle. Useful before taking a snapshot to see what tr
529
529
  ### 5.9 Advanced / Utility
530
530
 
531
531
  ```
532
- ndbg inject-hook <name>
532
+ agent-dbg inject-hook <name>
533
533
  ```
534
534
  Create a runtime binding that, when called from application code, sends a notification to the daemon. Use for custom instrumentation.
535
535
 
536
- - Adds a global function `__ndbg_<name>()` that the app can call
536
+ - Adds a global function `__agent-dbg_<name>()` that the app can call
537
537
  - When called, the daemon captures the call's arguments and stack
538
- - View with: `ndbg hooks [--follow]`
538
+ - View with: `agent-dbg hooks [--follow]`
539
539
 
540
540
  ```
541
- ndbg contexts
541
+ agent-dbg contexts
542
542
  ```
543
543
  List all V8 execution contexts (useful for debugging Jest VM sandboxes, workers, or vm.runInContext scenarios). Each context gets an ID.
544
544
 
545
545
  ```
546
- ndbg async-depth <N>
546
+ agent-dbg async-depth <N>
547
547
  ```
548
548
  Set the async call stack trace depth. Default: 16. Set to 0 to disable async stacks. Higher values cost more memory but show the full async chain.
549
549
 
550
550
  ```
551
- ndbg config [key] [value]
551
+ agent-dbg config [key] [value]
552
552
  ```
553
553
  Get/set daemon configuration:
554
554
 
@@ -560,12 +560,12 @@ Get/set daemon configuration:
560
560
  - `timeout` — daemon idle timeout in seconds
561
561
 
562
562
  ```
563
- ndbg gc-refs
563
+ agent-dbg gc-refs
564
564
  ```
565
565
  Clear accumulated `@o` refs to free memory. `@v` and `@f` refs are cleared automatically on each pause.
566
566
 
567
567
  ```
568
- ndbg --help-agent
568
+ agent-dbg --help-agent
569
569
  ```
570
570
  Output a compact LLM-optimized reference card with core workflow, quick reference, and common debugging patterns. Designed to be injected into an agent's context window.
571
571
 
@@ -580,7 +580,7 @@ Output a compact LLM-optimized reference card with core workflow, quick referenc
580
580
  3. **@refs inline** — every inspectable value is prefixed with its ref
581
581
  4. **Timing annotations** — execution commands report elapsed time since last pause
582
582
  5. **No JSON by default** — JSON wastes tokens on syntax. Available with `--json` flag
583
- 6. **Truncation with hints** — large outputs are truncated with a `... (ndbg props @oN for more)` hint
583
+ 6. **Truncation with hints** — large outputs are truncated with a `... (agent-dbg props @oN for more)` hint
584
584
 
585
585
  ### 6.2 Variable formatting
586
586
 
@@ -641,17 +641,17 @@ Errors always suggest the next action:
641
641
  ```
642
642
  ✗ Cannot set breakpoint at src/queue/processor.ts:46 — no breakable location
643
643
  Nearest valid lines: 45, 47
644
- → Try: ndbg break src/queue/processor.ts:47
644
+ → Try: agent-dbg break src/queue/processor.ts:47
645
645
 
646
646
  ✗ Variable 'foo' not found in current scope
647
647
  Available locals: job, lock, this
648
- → Try: ndbg vars
648
+ → Try: agent-dbg vars
649
649
 
650
650
  ✗ Cannot step — process is running (not paused)
651
- → Try: ndbg pause
651
+ → Try: agent-dbg pause
652
652
 
653
653
  ✗ Session "default" not found — no active debug session
654
- → Try: ndbg launch --brk "node app.js"
654
+ → Try: agent-dbg launch --brk "node app.js"
655
655
  ```
656
656
 
657
657
  ---
@@ -664,16 +664,16 @@ Source maps are a first-class concern, not an afterthought.
664
664
 
665
665
  - All user-facing locations display **source-mapped paths and line numbers** (TypeScript, etc.)
666
666
  - The `Debugger.scriptParsed` event provides `sourceMapURL`; the daemon fetches and caches it
667
- - `ndbg break src/foo.ts:42` resolves to the generated `.js` location automatically
667
+ - `agent-dbg break src/foo.ts:42` resolves to the generated `.js` location automatically
668
668
  - Stack traces always show source-mapped locations
669
- - `ndbg source` shows the original source (TypeScript), not compiled JS
669
+ - `agent-dbg source` shows the original source (TypeScript), not compiled JS
670
670
  - If no source map exists, the generated JS is shown (no error)
671
671
 
672
672
  ### 7.2 Source map commands
673
673
 
674
674
  ```
675
- ndbg sourcemap <file> # Show source map info for a file
676
- ndbg sourcemap --disable # Disable source map resolution globally
675
+ agent-dbg sourcemap <file> # Show source map info for a file
676
+ agent-dbg sourcemap --disable # Disable source map resolution globally
677
677
  ```
678
678
 
679
679
  ---
@@ -682,11 +682,11 @@ ndbg sourcemap --disable # Disable source map resolution globally
682
682
 
683
683
  ### 8.1 Daemon lifecycle
684
684
 
685
- 1. `ndbg launch` starts a background daemon process
685
+ 1. `agent-dbg launch` starts a background daemon process
686
686
  2. Daemon opens a WebSocket to the Node.js inspector (`ws://127.0.0.1:<port>`)
687
- 3. Daemon listens on a Unix socket at `$XDG_RUNTIME_DIR/ndbg/<session-name>.sock` (or `$TMPDIR` fallback)
687
+ 3. Daemon listens on a Unix socket at `$XDG_RUNTIME_DIR/agent-dbg/<session-name>.sock` (or `$TMPDIR` fallback)
688
688
  4. CLI commands connect to the Unix socket, send a request, receive a response, disconnect
689
- 5. Daemon shuts down when: process exits, `ndbg stop` is called, or idle timeout is reached
689
+ 5. Daemon shuts down when: process exits, `agent-dbg stop` is called, or idle timeout is reached
690
690
 
691
691
  ### 8.2 Internal protocol
692
692
 
@@ -705,20 +705,20 @@ CLI-to-daemon communication uses newline-delimited JSON over Unix socket. Each r
705
705
  - Each debug session has a unique name (default: `"default"`)
706
706
  - Multiple sessions can run simultaneously (e.g., debugging a client and server)
707
707
  - `--session NAME` on any command targets a specific session
708
- - `ndbg sessions` lists all active sessions
708
+ - `agent-dbg sessions` lists all active sessions
709
709
 
710
710
  ### 8.4 Crash recovery
711
711
 
712
712
  - If the daemon crashes, the CLI detects the dead socket and reports:
713
713
  `✗ Session "default" daemon is not running. The debugged process (PID 42871) is still alive.`
714
- `→ Try: ndbg attach 42871`
714
+ `→ Try: agent-dbg attach 42871`
715
715
  - Lock files prevent duplicate daemons for the same session
716
716
 
717
717
  ---
718
718
 
719
719
  ## 9. SKILL.md for Agent Integration
720
720
 
721
- ndbg ships with a SKILL.md for Claude Code's skill system and compatible agents.
721
+ agent-dbg ships with a SKILL.md for Claude Code's skill system and compatible agents.
722
722
 
723
723
  ```yaml
724
724
  ---
@@ -735,73 +735,73 @@ description: >
735
735
 
736
736
  ### 9.1 `--help-agent` output
737
737
 
738
- The `ndbg --help-agent` command outputs a compact reference designed for agent context windows:
738
+ The `agent-dbg --help-agent` command outputs a compact reference designed for agent context windows:
739
739
 
740
740
  ```
741
- ndbg — Node.js debugger CLI for AI agents
741
+ agent-dbg — Node.js debugger CLI for AI agents
742
742
 
743
743
  CORE LOOP:
744
- 1. ndbg launch --brk "node app.js" → pauses at first line, returns state
745
- 2. ndbg break src/file.ts:42 → set breakpoint
746
- 3. ndbg continue → run to breakpoint, returns state
747
- 4. Inspect: ndbg vars, ndbg eval, ndbg props @v1
748
- 5. Mutate/fix: ndbg set @v1 value, ndbg hotpatch src/file.ts
744
+ 1. agent-dbg launch --brk "node app.js" → pauses at first line, returns state
745
+ 2. agent-dbg break src/file.ts:42 → set breakpoint
746
+ 3. agent-dbg continue → run to breakpoint, returns state
747
+ 4. Inspect: agent-dbg vars, agent-dbg eval, agent-dbg props @v1
748
+ 5. Mutate/fix: agent-dbg set @v1 value, agent-dbg hotpatch src/file.ts
749
749
  6. Repeat from 3
750
750
 
751
751
  REFS: Every output assigns @refs. Use them everywhere:
752
- @v1..@vN variables │ ndbg props @v1, ndbg set @v2 true
753
- @f0..@fN stack frames │ ndbg frame @f1, ndbg restart-frame @f0
754
- BP#1..N breakpoints │ ndbg break-rm BP#1
755
- HS#1..N heap snaps │ ndbg heap diff HS#1 HS#2
752
+ @v1..@vN variables │ agent-dbg props @v1, agent-dbg set @v2 true
753
+ @f0..@fN stack frames │ agent-dbg frame @f1, agent-dbg restart-frame @f0
754
+ BP#1..N breakpoints │ agent-dbg break-rm BP#1
755
+ HS#1..N heap snaps │ agent-dbg heap diff HS#1 HS#2
756
756
 
757
757
  EXECUTION (all return state automatically):
758
- ndbg continue Resume to next breakpoint
759
- ndbg step [over|into|out] Step one statement
760
- ndbg run-to file:line Continue to location
761
- ndbg pause Interrupt running process
762
- ndbg restart-frame @f0 Re-run current function
758
+ agent-dbg continue Resume to next breakpoint
759
+ agent-dbg step [over|into|out] Step one statement
760
+ agent-dbg run-to file:line Continue to location
761
+ agent-dbg pause Interrupt running process
762
+ agent-dbg restart-frame @f0 Re-run current function
763
763
 
764
764
  BREAKPOINTS:
765
- ndbg break file:line [--condition expr]
766
- ndbg logpoint file:line "template ${var}"
767
- ndbg catch [all|uncaught|none]
768
- ndbg blackbox "node_modules/**"
765
+ agent-dbg break file:line [--condition expr]
766
+ agent-dbg logpoint file:line "template ${var}"
767
+ agent-dbg catch [all|uncaught|none]
768
+ agent-dbg blackbox "node_modules/**"
769
769
 
770
770
  INSPECTION:
771
- ndbg state [-v|-s|-b|-c] [--depth N]
772
- ndbg vars [name...]
773
- ndbg eval <expr> (await supported)
774
- ndbg props @ref [--depth N]
775
- ndbg instances "Class.prototype"
776
- ndbg search "query" [--regex]
771
+ agent-dbg state [-v|-s|-b|-c] [--depth N]
772
+ agent-dbg vars [name...]
773
+ agent-dbg eval <expr> (await supported)
774
+ agent-dbg props @ref [--depth N]
775
+ agent-dbg instances "Class.prototype"
776
+ agent-dbg search "query" [--regex]
777
777
 
778
778
  MUTATION:
779
- ndbg set @v1 <value> Change variable
780
- ndbg set-return <value> Change return value
781
- ndbg hotpatch <file> Live-edit code (no restart!)
779
+ agent-dbg set @v1 <value> Change variable
780
+ agent-dbg set-return <value> Change return value
781
+ agent-dbg hotpatch <file> Live-edit code (no restart!)
782
782
 
783
783
  PROFILING:
784
- ndbg cpu start / stop [--top N]
785
- ndbg coverage start [--detailed] / stop [--uncovered]
786
- ndbg heap usage | snapshot | diff | sample | gc
784
+ agent-dbg cpu start / stop [--top N]
785
+ agent-dbg coverage start [--detailed] / stop [--uncovered]
786
+ agent-dbg heap usage | snapshot | diff | sample | gc
787
787
 
788
788
  PATTERNS:
789
789
  # Race condition → trace with logpoints
790
- ndbg logpoint src/lock.ts:31 "acquire: ${jobId} by ${workerId}"
791
- ndbg continue
790
+ agent-dbg logpoint src/lock.ts:31 "acquire: ${jobId} by ${workerId}"
791
+ agent-dbg continue
792
792
 
793
793
  # Circular dependency → trace require chain
794
- ndbg break-on-load --sourcemap
795
- ndbg logpoint node_modules/jest-runtime/build/index.js:348 "${from} → ${moduleName}"
794
+ agent-dbg break-on-load --sourcemap
795
+ agent-dbg logpoint node_modules/jest-runtime/build/index.js:348 "${from} → ${moduleName}"
796
796
 
797
797
  # Memory leak → snapshot before/after
798
- ndbg heap snapshot --tag before
798
+ agent-dbg heap snapshot --tag before
799
799
  # ... trigger load ...
800
- ndbg heap snapshot --tag after
801
- ndbg heap diff HS#1 HS#2 --top 5
800
+ agent-dbg heap snapshot --tag after
801
+ agent-dbg heap diff HS#1 HS#2 --top 5
802
802
 
803
803
  # Skip framework noise
804
- ndbg blackbox "node_modules" "internal/"
804
+ agent-dbg blackbox "node_modules" "internal/"
805
805
  ```
806
806
 
807
807
  ---
@@ -812,32 +812,32 @@ PATTERNS:
812
812
 
813
813
  ```bash
814
814
  # npx (zero install — recommended for first use)
815
- npx ndbg launch --brk "node app.js"
815
+ npx agent-dbg launch --brk "node app.js"
816
816
 
817
817
  # Global install
818
- npm install -g ndbg
818
+ npm install -g agent-dbg
819
819
 
820
820
  # Compiled binary (no runtime needed)
821
- # Download from GitHub releases: ndbg-linux-x64, ndbg-darwin-arm64, etc.
822
- curl -fsSL https://github.com/<org>/ndbg/releases/latest/download/ndbg-$(uname -s)-$(uname -m) -o /usr/local/bin/ndbg
823
- chmod +x /usr/local/bin/ndbg
821
+ # Download from GitHub releases: agent-dbg-linux-x64, agent-dbg-darwin-arm64, etc.
822
+ curl -fsSL https://github.com/<org>/agent-dbg/releases/latest/download/agent-dbg-$(uname -s)-$(uname -m) -o /usr/local/bin/agent-dbg
823
+ chmod +x /usr/local/bin/agent-dbg
824
824
  ```
825
825
 
826
826
  ### 10.2 Skill installation (for Claude Code and compatible agents)
827
827
 
828
828
  ```bash
829
829
  # Via vercel skills CLI
830
- npx skills add <org>/ndbg
830
+ npx skills add <org>/agent-dbg
831
831
 
832
832
  # Manual: copy SKILL.md to Claude Code skills directory
833
- cp node_modules/ndbg/skills/node-debugger/SKILL.md ~/.claude/skills/node-debugger/SKILL.md
833
+ cp node_modules/agent-dbg/skills/node-debugger/SKILL.md ~/.claude/skills/node-debugger/SKILL.md
834
834
  ```
835
835
 
836
836
  ### 10.3 Requirements
837
837
 
838
838
  - **Debugged process**: Node.js 16+ (for V8 inspector support)
839
- - **ndbg binary**: no runtime dependency (standalone compiled binary)
840
- - **ndbg via npm/npx**: Bun or Node.js 18+ on the host
839
+ - **agent-dbg binary**: no runtime dependency (standalone compiled binary)
840
+ - **agent-dbg via npm/npx**: Bun or Node.js 18+ on the host
841
841
 
842
842
  ---
843
843
 
@@ -854,21 +854,21 @@ cp node_modules/ndbg/skills/node-debugger/SKILL.md ~/.claude/skills/node-debugge
854
854
 
855
855
  ### 11.2 Out of scope (v1)
856
856
 
857
- - **Browser debugging** — ndbg targets Node.js processes only (no DOM, no CSS)
857
+ - **Browser debugging** — agent-dbg targets Node.js processes only (no DOM, no CSS)
858
858
  - **Other languages** — no Python, Rust, Go, etc. (use dedicated tools)
859
859
  - **GUI** — no TUI, no web UI (output is text for terminal/agent consumption)
860
860
  - **MCP server mode** — may be added later as an optional adapter, but CLI is primary
861
861
  - **Remote debugging** — v1 targets localhost only (SSH tunneling is the recommended approach for remote)
862
862
  - **Recording/replay** — time-travel debugging (may be a v2 feature)
863
- - **Test framework integration** — ndbg debugs any Node.js process; it doesn't know about Jest/Vitest internals (but can debug them)
863
+ - **Test framework integration** — agent-dbg debugs any Node.js process; it doesn't know about Jest/Vitest internals (but can debug them)
864
864
 
865
865
  ---
866
866
 
867
867
  ## 12. V8 Inspector Protocol Mapping
868
868
 
869
- Reference for implementors. Maps ndbg commands to CDP methods.
869
+ Reference for implementors. Maps agent-dbg commands to CDP methods.
870
870
 
871
- | ndbg command | CDP domain | CDP method(s) |
871
+ | agent-dbg command | CDP domain | CDP method(s) |
872
872
  |---|---|---|
873
873
  | `launch --brk` | — | Spawns `node --inspect-brk` + `Runtime.runIfWaitingForDebugger` |
874
874
  | `break file:line` | Debugger | `setBreakpointByUrl` |