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.
- package/.claude/settings.local.json +7 -5
- package/.claude/skills/agent-dbg/SKILL.md +116 -0
- package/.claude/skills/agent-dbg/references/commands.md +173 -0
- package/.vscode/launch.json +19 -0
- package/CLAUDE.md +2 -2
- package/PROGRESS.md +91 -91
- package/README.md +45 -17
- package/{ndbg-spec.md → SPEC.md} +152 -152
- package/dist/main.js +12500 -0
- package/package.json +3 -3
- package/src/cdp/client.ts +18 -4
- package/src/cdp/logger.ts +69 -0
- package/src/cli/parser.ts +54 -43
- package/src/commands/attach.ts +2 -2
- package/src/commands/blackbox-ls.ts +1 -1
- package/src/commands/blackbox-rm.ts +3 -3
- package/src/commands/blackbox.ts +2 -2
- package/src/commands/break-ls.ts +3 -2
- package/src/commands/break-rm.ts +2 -2
- package/src/commands/break-toggle.ts +2 -2
- package/src/commands/break.ts +46 -17
- package/src/commands/breakable.ts +2 -2
- package/src/commands/catch.ts +2 -2
- package/src/commands/console.ts +1 -1
- package/src/commands/continue.ts +5 -18
- package/src/commands/eval.ts +2 -2
- package/src/commands/exceptions.ts +1 -1
- package/src/commands/hotpatch.ts +2 -2
- package/src/commands/launch.ts +7 -11
- package/src/commands/logpoint.ts +7 -6
- package/src/commands/logs.ts +116 -0
- package/src/commands/pause.ts +5 -18
- package/src/commands/print-state.ts +85 -0
- package/src/commands/props.ts +2 -2
- package/src/commands/restart-frame.ts +1 -1
- package/src/commands/restart.ts +42 -0
- package/src/commands/run-to.ts +7 -20
- package/src/commands/scripts.ts +1 -1
- package/src/commands/search.ts +4 -3
- package/src/commands/set-return.ts +2 -2
- package/src/commands/set.ts +3 -3
- package/src/commands/source.ts +3 -2
- package/src/commands/sourcemap.ts +1 -1
- package/src/commands/stack.ts +1 -1
- package/src/commands/state.ts +3 -73
- package/src/commands/status.ts +3 -2
- package/src/commands/step.ts +5 -18
- package/src/commands/vars.ts +3 -1
- package/src/daemon/entry.ts +16 -6
- package/src/daemon/paths.ts +6 -2
- package/src/daemon/server.ts +1 -1
- package/src/daemon/session-breakpoints.ts +7 -2
- package/src/daemon/session-inspection.ts +6 -10
- package/src/daemon/session-state.ts +6 -5
- package/src/daemon/session.ts +23 -3
- package/src/formatter/logs.ts +110 -0
- package/src/formatter/path.ts +27 -0
- package/src/formatter/stack.ts +5 -2
- package/src/formatter/variables.ts +48 -1
- package/src/main.ts +2 -0
- package/src/protocol/messages.ts +3 -0
- package/tests/fixtures/async-app.js +1 -1
- package/tests/fixtures/error-app.js +1 -1
- package/tests/fixtures/simple-app.js +1 -1
- package/tests/fixtures/ts-app/src/app.ts +4 -0
- package/tests/integration/state.test.ts +7 -7
- package/tests/unit/daemon.test.ts +1 -1
- package/tests/unit/formatter.test.ts +8 -4
- package/.bin/ndbg +0 -0
- package/.claude/skills/ndbg-debugger/ndbg-debugger/SKILL.md +0 -116
- package/.claude/skills/ndbg-debugger/ndbg-debugger/references/commands.md +0 -173
|
@@ -2,9 +2,22 @@ export interface Variable {
|
|
|
2
2
|
ref: string;
|
|
3
3
|
name: string;
|
|
4
4
|
value: string;
|
|
5
|
+
scope?: string;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const SCOPE_LABELS: Record<string, string> = {
|
|
9
|
+
local: "Locals",
|
|
10
|
+
module: "Module",
|
|
11
|
+
closure: "Closure",
|
|
12
|
+
block: "Block",
|
|
13
|
+
catch: "Catch",
|
|
14
|
+
script: "Script",
|
|
15
|
+
eval: "Eval",
|
|
16
|
+
with: "With",
|
|
17
|
+
"wasm-expression-stack": "WASM Stack",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function formatGroup(vars: Variable[]): string {
|
|
8
21
|
if (vars.length === 0) return "";
|
|
9
22
|
|
|
10
23
|
const maxRefLen = Math.max(...vars.map((v) => v.ref.length));
|
|
@@ -18,3 +31,37 @@ export function formatVariables(vars: Variable[]): string {
|
|
|
18
31
|
})
|
|
19
32
|
.join("\n");
|
|
20
33
|
}
|
|
34
|
+
|
|
35
|
+
export function formatVariables(vars: Variable[]): string {
|
|
36
|
+
if (vars.length === 0) return "";
|
|
37
|
+
|
|
38
|
+
// Collect unique scopes in order of appearance
|
|
39
|
+
const scopeOrder: string[] = [];
|
|
40
|
+
const groups = new Map<string, Variable[]>();
|
|
41
|
+
for (const v of vars) {
|
|
42
|
+
const scope = v.scope ?? "local";
|
|
43
|
+
let group = groups.get(scope);
|
|
44
|
+
if (!group) {
|
|
45
|
+
group = [];
|
|
46
|
+
scopeOrder.push(scope);
|
|
47
|
+
groups.set(scope, group);
|
|
48
|
+
}
|
|
49
|
+
group.push(v);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Single scope: no header needed
|
|
53
|
+
if (scopeOrder.length === 1) {
|
|
54
|
+
return formatGroup(vars);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Multiple scopes: group with headers
|
|
58
|
+
const sections: string[] = [];
|
|
59
|
+
for (const scope of scopeOrder) {
|
|
60
|
+
const group = groups.get(scope);
|
|
61
|
+
if (!group || group.length === 0) continue;
|
|
62
|
+
const label = SCOPE_LABELS[scope] ?? scope;
|
|
63
|
+
sections.push(`${label}:\n${formatGroup(group)}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return sections.join("\n\n");
|
|
67
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -6,6 +6,7 @@ if (process.argv.includes("--daemon")) {
|
|
|
6
6
|
await import("./commands/launch.ts");
|
|
7
7
|
await import("./commands/attach.ts");
|
|
8
8
|
await import("./commands/stop.ts");
|
|
9
|
+
await import("./commands/restart.ts");
|
|
9
10
|
await import("./commands/sessions.ts");
|
|
10
11
|
await import("./commands/status.ts");
|
|
11
12
|
await import("./commands/state.ts");
|
|
@@ -37,6 +38,7 @@ if (process.argv.includes("--daemon")) {
|
|
|
37
38
|
await import("./commands/breakable.ts");
|
|
38
39
|
await import("./commands/restart-frame.ts");
|
|
39
40
|
await import("./commands/sourcemap.ts");
|
|
41
|
+
await import("./commands/logs.ts");
|
|
40
42
|
const { parseArgs, run } = await import("./cli/parser.ts");
|
|
41
43
|
|
|
42
44
|
const args = parseArgs(process.argv.slice(2));
|
package/src/protocol/messages.ts
CHANGED
|
@@ -254,6 +254,8 @@ const SourcemapRequest = z.object({
|
|
|
254
254
|
|
|
255
255
|
const SourcemapDisableRequest = z.object({ cmd: z.literal("sourcemap-disable") });
|
|
256
256
|
|
|
257
|
+
const RestartRequest = z.object({ cmd: z.literal("restart") });
|
|
258
|
+
|
|
257
259
|
const StopRequest = z.object({ cmd: z.literal("stop") });
|
|
258
260
|
|
|
259
261
|
// ── Union of all requests (discriminated on cmd) ───────────────────
|
|
@@ -291,6 +293,7 @@ export const DaemonRequestSchema = z.union([
|
|
|
291
293
|
BreakToggleRequest,
|
|
292
294
|
BreakableRequest,
|
|
293
295
|
RestartFrameRequest,
|
|
296
|
+
RestartRequest,
|
|
294
297
|
SourcemapRequest,
|
|
295
298
|
SourcemapDisableRequest,
|
|
296
299
|
StopRequest,
|
|
@@ -47,7 +47,7 @@ describe("buildState integration", () => {
|
|
|
47
47
|
expect(firstFrame?.line).toBeGreaterThan(0);
|
|
48
48
|
|
|
49
49
|
// Locals should be present (may be empty at entry point, but the array should exist)
|
|
50
|
-
expect(snapshot.
|
|
50
|
+
expect(snapshot.vars).toBeDefined();
|
|
51
51
|
|
|
52
52
|
// Breakpoint count should be present
|
|
53
53
|
expect(snapshot.breakpointCount).toBeDefined();
|
|
@@ -69,7 +69,7 @@ describe("buildState integration", () => {
|
|
|
69
69
|
expect(snapshot.status).toBe("running");
|
|
70
70
|
// When running, no source/locals/stack should be present
|
|
71
71
|
expect(snapshot.source).toBeUndefined();
|
|
72
|
-
expect(snapshot.
|
|
72
|
+
expect(snapshot.vars).toBeUndefined();
|
|
73
73
|
expect(snapshot.stack).toBeUndefined();
|
|
74
74
|
} finally {
|
|
75
75
|
await session.stop();
|
|
@@ -88,7 +88,7 @@ describe("buildState integration", () => {
|
|
|
88
88
|
|
|
89
89
|
expect(snapshot.status).toBe("paused");
|
|
90
90
|
// Locals should be present
|
|
91
|
-
expect(snapshot.
|
|
91
|
+
expect(snapshot.vars).toBeDefined();
|
|
92
92
|
// Source and stack should NOT be present (filtered out)
|
|
93
93
|
expect(snapshot.source).toBeUndefined();
|
|
94
94
|
expect(snapshot.stack).toBeUndefined();
|
|
@@ -114,7 +114,7 @@ describe("buildState integration", () => {
|
|
|
114
114
|
expect(snapshot.stack?.length).toBeGreaterThan(0);
|
|
115
115
|
// Source, locals, and breakpoints should NOT be present (filtered out)
|
|
116
116
|
expect(snapshot.source).toBeUndefined();
|
|
117
|
-
expect(snapshot.
|
|
117
|
+
expect(snapshot.vars).toBeUndefined();
|
|
118
118
|
expect(snapshot.breakpointCount).toBeUndefined();
|
|
119
119
|
} finally {
|
|
120
120
|
await session.stop();
|
|
@@ -136,7 +136,7 @@ describe("buildState integration", () => {
|
|
|
136
136
|
expect(snapshot.source).toBeDefined();
|
|
137
137
|
expect(snapshot.source?.lines.length).toBeGreaterThan(0);
|
|
138
138
|
// Locals, stack, and breakpoints should NOT be present (filtered out)
|
|
139
|
-
expect(snapshot.
|
|
139
|
+
expect(snapshot.vars).toBeUndefined();
|
|
140
140
|
expect(snapshot.stack).toBeUndefined();
|
|
141
141
|
expect(snapshot.breakpointCount).toBeUndefined();
|
|
142
142
|
} finally {
|
|
@@ -161,8 +161,8 @@ describe("buildState integration", () => {
|
|
|
161
161
|
const snapshot = await session.buildState();
|
|
162
162
|
|
|
163
163
|
// Check that variable refs are assigned
|
|
164
|
-
if (snapshot.
|
|
165
|
-
const firstLocal = snapshot.
|
|
164
|
+
if (snapshot.vars && snapshot.vars.length > 0) {
|
|
165
|
+
const firstLocal = snapshot.vars[0];
|
|
166
166
|
expect(firstLocal?.ref).toMatch(/^@v\d+$/);
|
|
167
167
|
expect(firstLocal?.name).toBeDefined();
|
|
168
168
|
expect(firstLocal?.value).toBeDefined();
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { DaemonServer } from "../../src/daemon/server.ts";
|
|
11
11
|
|
|
12
12
|
// Use a short test directory to stay within macOS 104-char Unix socket path limit
|
|
13
|
-
const TEST_SOCKET_DIR = `/tmp/
|
|
13
|
+
const TEST_SOCKET_DIR = `/tmp/agent-dbg-t${process.pid}`;
|
|
14
14
|
|
|
15
15
|
let originalEnv: string | undefined;
|
|
16
16
|
let testCounter = 0;
|
|
@@ -646,21 +646,25 @@ describe("formatError", () => {
|
|
|
646
646
|
const result = formatError(
|
|
647
647
|
"Cannot set breakpoint at src/queue/processor.ts:46 \u2014 no breakable location",
|
|
648
648
|
["Nearest valid lines: 45, 47"],
|
|
649
|
-
"
|
|
649
|
+
"agent-dbg break src/queue/processor.ts:47",
|
|
650
650
|
);
|
|
651
651
|
const lines = result.split("\n");
|
|
652
652
|
expect(lines).toHaveLength(3);
|
|
653
653
|
expect(lines[0]).toContain("\u2717");
|
|
654
654
|
expect(lines[1]).toBe(" Nearest valid lines: 45, 47");
|
|
655
|
-
expect(lines[2]).toBe(" \u2192 Try:
|
|
655
|
+
expect(lines[2]).toBe(" \u2192 Try: agent-dbg break src/queue/processor.ts:47");
|
|
656
656
|
});
|
|
657
657
|
|
|
658
658
|
test("formats error without details but with suggestion", () => {
|
|
659
|
-
const result = formatError(
|
|
659
|
+
const result = formatError(
|
|
660
|
+
"No active session",
|
|
661
|
+
undefined,
|
|
662
|
+
"agent-dbg launch --brk node app.js",
|
|
663
|
+
);
|
|
660
664
|
const lines = result.split("\n");
|
|
661
665
|
expect(lines).toHaveLength(2);
|
|
662
666
|
expect(lines[0]).toBe("\u2717 No active session");
|
|
663
|
-
expect(lines[1]).toBe(" \u2192 Try:
|
|
667
|
+
expect(lines[1]).toBe(" \u2192 Try: agent-dbg launch --brk node app.js");
|
|
664
668
|
});
|
|
665
669
|
});
|
|
666
670
|
|
package/.bin/ndbg
DELETED
|
Binary file
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ndbg-debugger
|
|
3
|
-
description: >
|
|
4
|
-
Debug Node.js/TypeScript/JavaScript applications using the ndbg CLI debugger.
|
|
5
|
-
Use when: (1) investigating runtime bugs by stepping through code, (2) inspecting
|
|
6
|
-
variable values at specific execution points, (3) setting breakpoints and conditional
|
|
7
|
-
breakpoints, (4) evaluating expressions in a paused context, (5) hot-patching code
|
|
8
|
-
without restarting, (6) debugging test failures by attaching to a running process,
|
|
9
|
-
(7) any task where understanding runtime behavior requires a debugger.
|
|
10
|
-
Triggers: "debug this", "set a breakpoint", "step through", "inspect variables",
|
|
11
|
-
"why is this value wrong", "trace execution", "attach debugger", "runtime error".
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# ndbg Debugger
|
|
15
|
-
|
|
16
|
-
`ndbg` is a CLI debugger for Node.js wrapping the V8 Inspector (CDP). It uses short `@refs` for all entities -- use them instead of long IDs.
|
|
17
|
-
|
|
18
|
-
## Core Debug Loop
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
# 1. Launch with breakpoint at first line
|
|
22
|
-
ndbg launch --brk node app.js
|
|
23
|
-
|
|
24
|
-
# 2. Set breakpoints at suspicious locations
|
|
25
|
-
ndbg break src/handler.ts:42
|
|
26
|
-
ndbg break src/utils.ts:15 --condition "count > 10"
|
|
27
|
-
|
|
28
|
-
# 3. Run to breakpoint
|
|
29
|
-
ndbg continue
|
|
30
|
-
|
|
31
|
-
# 4. Inspect state (shows location, source, locals, stack)
|
|
32
|
-
ndbg state
|
|
33
|
-
|
|
34
|
-
# 5. Drill into values
|
|
35
|
-
ndbg props @v1 # expand object
|
|
36
|
-
ndbg props @v1 --depth 3 # expand nested 3 levels
|
|
37
|
-
ndbg eval "items.filter(x => x.active)"
|
|
38
|
-
|
|
39
|
-
# 6. Fix and verify
|
|
40
|
-
ndbg set count 0 # change variable
|
|
41
|
-
ndbg hotpatch src/utils.js # live-edit (reads file from disk)
|
|
42
|
-
ndbg continue # verify fix
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Debugging Strategies
|
|
46
|
-
|
|
47
|
-
### Bug investigation -- narrow down with breakpoints
|
|
48
|
-
```bash
|
|
49
|
-
ndbg launch --brk node app.js
|
|
50
|
-
ndbg break src/api.ts:50 # suspect line
|
|
51
|
-
ndbg break src/api.ts:60 --condition "!user" # conditional
|
|
52
|
-
ndbg continue
|
|
53
|
-
ndbg vars # check locals
|
|
54
|
-
ndbg eval "JSON.stringify(req.body)" # inspect deeply
|
|
55
|
-
ndbg step over # advance one line
|
|
56
|
-
ndbg state # see new state
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Attach to running/test process
|
|
60
|
-
```bash
|
|
61
|
-
# Start node with inspector
|
|
62
|
-
node --inspect app.js
|
|
63
|
-
# Or attach by PID
|
|
64
|
-
ndbg attach 12345
|
|
65
|
-
ndbg state
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Trace execution flow with logpoints (no pause)
|
|
69
|
-
```bash
|
|
70
|
-
ndbg logpoint src/auth.ts:20 "login attempt: ${username}"
|
|
71
|
-
ndbg logpoint src/auth.ts:45 "auth result: ${result}"
|
|
72
|
-
ndbg continue
|
|
73
|
-
ndbg console # see logged output
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Exception debugging
|
|
77
|
-
```bash
|
|
78
|
-
ndbg catch uncaught # pause on uncaught exceptions
|
|
79
|
-
ndbg continue # runs until exception
|
|
80
|
-
ndbg state # see where it threw
|
|
81
|
-
ndbg eval "err.message" # inspect the error
|
|
82
|
-
ndbg stack # full call stack
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### TypeScript source map support
|
|
86
|
-
ndbg automatically resolves `.ts` paths via source maps. Set breakpoints using `.ts` paths, see `.ts` source in output. Use `--generated` to see compiled `.js` if needed.
|
|
87
|
-
|
|
88
|
-
## Ref System
|
|
89
|
-
|
|
90
|
-
Every output assigns short refs. Use them everywhere:
|
|
91
|
-
- `@v1..@vN` -- variables: `ndbg props @v1`, `ndbg set @v2 true`
|
|
92
|
-
- `@f0..@fN` -- stack frames: `ndbg eval --frame @f1 "this"`
|
|
93
|
-
- `BP#1..N` -- breakpoints: `ndbg break-rm BP#1`, `ndbg break-toggle BP#1`
|
|
94
|
-
- `LP#1..N` -- logpoints: `ndbg break-rm LP#1`
|
|
95
|
-
|
|
96
|
-
Refs `@v`/`@f` reset on each pause. `BP#`/`LP#` persist until removed.
|
|
97
|
-
|
|
98
|
-
## Key Flags
|
|
99
|
-
|
|
100
|
-
- `--json` -- machine-readable JSON output on any command
|
|
101
|
-
- `--session NAME` -- target a specific session (default: "default")
|
|
102
|
-
- `--generated` -- bypass source maps, show compiled JS (on state/source/stack)
|
|
103
|
-
|
|
104
|
-
## Command Reference
|
|
105
|
-
|
|
106
|
-
See [references/commands.md](references/commands.md) for full command details and options.
|
|
107
|
-
|
|
108
|
-
## Tips
|
|
109
|
-
|
|
110
|
-
- `ndbg state` after stepping always shows location + source + locals -- usually enough context
|
|
111
|
-
- `ndbg state -c` for source only, `-v` for vars only, `-s` for stack only -- save tokens
|
|
112
|
-
- `ndbg eval` supports `await` -- useful for async inspection
|
|
113
|
-
- `ndbg blackbox "node_modules/**"` -- skip stepping into dependencies
|
|
114
|
-
- `ndbg hotpatch file` reads the file from disk -- edit the file first, then hotpatch
|
|
115
|
-
- Execution commands (`continue`, `step`, `pause`, `run-to`) auto-return status
|
|
116
|
-
- `ndbg stop` kills the debugged process and daemon
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# ndbg Command Reference
|
|
2
|
-
|
|
3
|
-
## Table of Contents
|
|
4
|
-
- [Session](#session)
|
|
5
|
-
- [Execution](#execution)
|
|
6
|
-
- [Inspection](#inspection)
|
|
7
|
-
- [Breakpoints](#breakpoints)
|
|
8
|
-
- [Mutation](#mutation)
|
|
9
|
-
- [Blackboxing](#blackboxing)
|
|
10
|
-
- [Source Maps](#source-maps)
|
|
11
|
-
- [Global Flags](#global-flags)
|
|
12
|
-
|
|
13
|
-
## Session
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
ndbg launch [--brk] <command...> # Start + attach debugger (--brk pauses at first line)
|
|
17
|
-
ndbg attach <pid|ws-url|port> # Attach to running process
|
|
18
|
-
ndbg stop # Kill process + daemon
|
|
19
|
-
ndbg sessions [--cleanup] # List active sessions
|
|
20
|
-
ndbg status # Session info (pid, state, pause location)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Execution
|
|
24
|
-
|
|
25
|
-
All execution commands automatically return session status (state + pause info).
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
ndbg continue # Resume to next breakpoint or completion
|
|
29
|
-
ndbg step [over|into|out] # Step one statement (default: over)
|
|
30
|
-
ndbg run-to <file>:<line> # Continue to specific location
|
|
31
|
-
ndbg pause # Interrupt running process
|
|
32
|
-
ndbg restart-frame [@fN] # Re-execute frame from beginning
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Inspection
|
|
36
|
-
|
|
37
|
-
### state -- composite snapshot
|
|
38
|
-
```bash
|
|
39
|
-
ndbg state # Full snapshot: location, source, locals, stack, breakpoints
|
|
40
|
-
ndbg state -v # Locals only
|
|
41
|
-
ndbg state -s # Stack only
|
|
42
|
-
ndbg state -c # Source code only
|
|
43
|
-
ndbg state -b # Breakpoints only
|
|
44
|
-
ndbg state --depth 3 # Expand object values to depth 3
|
|
45
|
-
ndbg state --lines 10 # Show 10 lines of source context
|
|
46
|
-
ndbg state --frame @f1 # Inspect a different stack frame
|
|
47
|
-
ndbg state --all-scopes # Include closure scope variables
|
|
48
|
-
ndbg state --compact # Compact output
|
|
49
|
-
ndbg state --generated # Show compiled JS paths instead of TS
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### vars -- local variables
|
|
53
|
-
```bash
|
|
54
|
-
ndbg vars # All locals in current frame
|
|
55
|
-
ndbg vars name1 name2 # Filter specific variables
|
|
56
|
-
ndbg vars --frame @f1 # Variables from a different frame
|
|
57
|
-
ndbg vars --all-scopes # Include closure scope
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### stack -- call stack
|
|
61
|
-
```bash
|
|
62
|
-
ndbg stack # Full call stack
|
|
63
|
-
ndbg stack --async-depth 5 # Include async frames
|
|
64
|
-
ndbg stack --generated # Show compiled JS paths
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### eval -- evaluate expression
|
|
68
|
-
```bash
|
|
69
|
-
ndbg eval <expression> # Evaluate in current frame
|
|
70
|
-
ndbg eval "await fetchUser(id)" # Await supported
|
|
71
|
-
ndbg eval --frame @f1 "this" # Evaluate in different frame
|
|
72
|
-
ndbg eval --silent "setup()" # No output (side effects only)
|
|
73
|
-
ndbg eval --side-effect-free "x + 1" # Abort if side effects detected
|
|
74
|
-
ndbg eval --timeout 5000 "slowFn()" # Custom timeout in ms
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### props -- expand object
|
|
78
|
-
```bash
|
|
79
|
-
ndbg props @v1 # Expand object properties
|
|
80
|
-
ndbg props @v1 --depth 3 # Nested expansion
|
|
81
|
-
ndbg props @v1 --own # Own properties only
|
|
82
|
-
ndbg props @v1 --private # Include private fields
|
|
83
|
-
ndbg props @v1 --internal # Include internal slots
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### source -- view source code
|
|
87
|
-
```bash
|
|
88
|
-
ndbg source # Source around current line
|
|
89
|
-
ndbg source --lines 20 # 20 lines of context
|
|
90
|
-
ndbg source --file src/app.ts # Source of a specific file
|
|
91
|
-
ndbg source --all # Entire file
|
|
92
|
-
ndbg source --generated # Show compiled JS
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Other inspection
|
|
96
|
-
```bash
|
|
97
|
-
ndbg search "query" # Search loaded scripts
|
|
98
|
-
ndbg search "pattern" --regex # Regex search
|
|
99
|
-
ndbg search "text" --case-sensitive # Case-sensitive search
|
|
100
|
-
ndbg search "text" --file <id> # Search in specific script
|
|
101
|
-
ndbg scripts # List loaded scripts
|
|
102
|
-
ndbg scripts --filter "src/" # Filter by pattern
|
|
103
|
-
ndbg console # Show console output
|
|
104
|
-
ndbg console --since 5 # Last 5 messages
|
|
105
|
-
ndbg console --level error # Filter by level
|
|
106
|
-
ndbg console --clear # Clear console buffer
|
|
107
|
-
ndbg exceptions # Show captured exceptions
|
|
108
|
-
ndbg exceptions --since 3 # Last 3 exceptions
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Breakpoints
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
ndbg break <file>:<line> # Set breakpoint
|
|
115
|
-
ndbg break src/app.ts:42 --condition "x > 10" # Conditional
|
|
116
|
-
ndbg break src/app.ts:42 --hit-count 5 # Break on Nth hit
|
|
117
|
-
ndbg break src/app.ts:42 --continue # Log but don't pause
|
|
118
|
-
ndbg break --pattern "handler":15 # Regex URL match
|
|
119
|
-
ndbg break-rm BP#1 # Remove specific breakpoint
|
|
120
|
-
ndbg break-rm all # Remove all breakpoints
|
|
121
|
-
ndbg break-ls # List all breakpoints
|
|
122
|
-
ndbg break-toggle BP#1 # Disable/enable one breakpoint
|
|
123
|
-
ndbg break-toggle all # Disable/enable all
|
|
124
|
-
ndbg breakable src/app.ts:10-50 # List valid breakpoint locations
|
|
125
|
-
ndbg logpoint src/app.ts:20 "x=${x}" # Log without pausing
|
|
126
|
-
ndbg logpoint src/app.ts:20 "x=${x}" --condition "x > 0"
|
|
127
|
-
ndbg catch all # Pause on all exceptions
|
|
128
|
-
ndbg catch uncaught # Pause on uncaught only
|
|
129
|
-
ndbg catch none # Don't pause on exceptions
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Mutation
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
ndbg set <@ref|name> <value> # Change variable value
|
|
136
|
-
ndbg set count 0 # By name
|
|
137
|
-
ndbg set @v2 true # By ref
|
|
138
|
-
ndbg set-return "newValue" # Change return value (at return point)
|
|
139
|
-
ndbg hotpatch <file> # Live-edit script from disk
|
|
140
|
-
ndbg hotpatch <file> --dry-run # Preview without applying
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Blackboxing
|
|
144
|
-
|
|
145
|
-
Skip stepping into matching scripts (useful for node_modules).
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
ndbg blackbox "node_modules/**" # Add pattern
|
|
149
|
-
ndbg blackbox "lib/**" "vendor/**" # Multiple patterns
|
|
150
|
-
ndbg blackbox-ls # List patterns
|
|
151
|
-
ndbg blackbox-rm "node_modules/**" # Remove specific pattern
|
|
152
|
-
ndbg blackbox-rm all # Remove all patterns
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Source Maps
|
|
156
|
-
|
|
157
|
-
ndbg auto-detects source maps from `Debugger.scriptParsed` events. TypeScript `.ts` paths work transparently for breakpoints and display.
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
ndbg sourcemap # List all loaded source maps
|
|
161
|
-
ndbg sourcemap src/app.ts # Info for specific file
|
|
162
|
-
ndbg sourcemap --disable # Disable resolution globally
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Global Flags
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
--session NAME # Target session (default: "default")
|
|
169
|
-
--json # JSON output
|
|
170
|
-
--color # Enable ANSI colors
|
|
171
|
-
--help-agent # LLM-optimized reference card
|
|
172
|
-
--help # Human help
|
|
173
|
-
```
|