agent-dbg 0.1.8 → 0.2.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/.claude/skills/agent-dbg/SKILL.md +44 -14
- package/.claude/skills/agent-dbg/references/commands.md +4 -0
- package/README.md +65 -29
- package/dist/main.js +362 -98
- package/package.json +3 -3
- package/src/cdp/client.ts +67 -6
- package/src/cdp/jsc-client.ts +58 -0
- package/src/cdp/jsc-protocol.d.ts +2807 -0
- package/src/daemon/adapters/bun-adapter.ts +190 -0
- package/src/daemon/adapters/index.ts +13 -0
- package/src/daemon/adapters/node-adapter.ts +121 -0
- package/src/daemon/runtime-adapter.ts +50 -0
- package/src/daemon/session-blackbox.ts +2 -6
- package/src/daemon/session-breakpoints.ts +64 -53
- package/src/daemon/session-inspection.ts +2 -2
- package/src/daemon/session-state.ts +1 -1
- package/src/daemon/session.ts +46 -44
- package/src/formatter/source.ts +6 -2
- package/tests/fixtures/bun-simple.js +12 -0
- package/tests/integration/bun-launch.test.ts +135 -0
- package/tests/unit/cdp-client.test.ts +134 -10
- package/tests/unit/jsc-client.test.ts +165 -0
- package/demo/DEMO.md +0 -71
- package/demo/order-processor.js +0 -35
- package/tests/fixtures/dap/hello +0 -0
- package/tests/fixtures/dap/hello.dSYM/Contents/Info.plist +0 -20
- package/tests/fixtures/dap/hello.dSYM/Contents/Resources/DWARF/hello +0 -0
- package/tests/fixtures/dap/hello.dSYM/Contents/Resources/Relocations/aarch64/hello.yml +0 -5
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-dbg
|
|
3
3
|
description: >
|
|
4
|
-
Debug
|
|
4
|
+
Debug applications using the agent-dbg CLI debugger.
|
|
5
|
+
Supports Node.js (V8/CDP), Bun (WebKit/JSC), and native code via LLDB (DAP).
|
|
5
6
|
Use when: (1) investigating runtime bugs by stepping through code, (2) inspecting
|
|
6
7
|
variable values at specific execution points, (3) setting breakpoints and conditional
|
|
7
8
|
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
|
|
9
|
+
without restarting (JS/TS), (6) debugging test failures by attaching to a running process,
|
|
10
|
+
(7) debugging C/C++/Rust/Swift with LLDB, (8) any task where understanding runtime
|
|
11
|
+
behavior requires a debugger.
|
|
10
12
|
Triggers: "debug this", "set a breakpoint", "step through", "inspect variables",
|
|
11
|
-
"why is this value wrong", "trace execution", "attach debugger", "runtime error"
|
|
13
|
+
"why is this value wrong", "trace execution", "attach debugger", "runtime error",
|
|
14
|
+
"segfault", "core dump".
|
|
12
15
|
---
|
|
13
16
|
|
|
14
17
|
# agent-dbg Debugger
|
|
15
18
|
|
|
16
|
-
`agent-dbg` is a CLI debugger
|
|
19
|
+
`agent-dbg` is a CLI debugger that supports **Node.js** (V8/CDP), **Bun** (WebKit/JSC), and **native code** (C/C++/Rust/Swift via LLDB/DAP). It uses short `@refs` for all entities -- use them instead of long IDs.
|
|
20
|
+
|
|
21
|
+
## Supported Runtimes
|
|
22
|
+
|
|
23
|
+
| Runtime | Language | Launch example |
|
|
24
|
+
|---------|----------|----------------|
|
|
25
|
+
| Node.js | JavaScript | `agent-dbg launch --brk node app.js` |
|
|
26
|
+
| tsx / ts-node | TypeScript | `agent-dbg launch --brk tsx src/app.ts` |
|
|
27
|
+
| Bun | JavaScript / TypeScript | `agent-dbg launch --brk bun app.ts` |
|
|
28
|
+
| LLDB | C / C++ / Rust / Swift | `agent-dbg launch --brk --runtime lldb ./program` |
|
|
29
|
+
|
|
30
|
+
The runtime is auto-detected from the launch command for JS runtimes. For native code, use `--runtime lldb`.
|
|
17
31
|
|
|
18
32
|
## Core Debug Loop
|
|
19
33
|
|
|
20
34
|
```bash
|
|
21
35
|
# 1. Launch with breakpoint at first line
|
|
22
36
|
agent-dbg launch --brk node app.js
|
|
23
|
-
# Or
|
|
37
|
+
# Or: agent-dbg launch --brk bun app.ts
|
|
38
|
+
# Or: agent-dbg launch --brk --runtime lldb ./my_program
|
|
39
|
+
# Or attach to a running process with the --inspect flag
|
|
24
40
|
agent-dbg attach 9229
|
|
25
41
|
|
|
26
42
|
# 2. Set breakpoints at suspicious locations
|
|
@@ -35,10 +51,10 @@ agent-dbg state
|
|
|
35
51
|
|
|
36
52
|
# 5. Drill into values
|
|
37
53
|
agent-dbg props @v1 # expand object
|
|
38
|
-
agent-dbg props @v1 --depth 3
|
|
39
|
-
agent-dbg eval "
|
|
54
|
+
agent-dbg props @v1 --depth 3 # expand nested 3 levels
|
|
55
|
+
agent-dbg eval "x + 1"
|
|
40
56
|
|
|
41
|
-
# 6. Fix and verify
|
|
57
|
+
# 6. Fix and verify (JS/TS only)
|
|
42
58
|
agent-dbg set count 0 # change variable
|
|
43
59
|
agent-dbg hotpatch src/utils.js # live-edit (reads file from disk)
|
|
44
60
|
agent-dbg continue # verify fix
|
|
@@ -58,12 +74,24 @@ agent-dbg step over # advance one line
|
|
|
58
74
|
agent-dbg state # see new state
|
|
59
75
|
```
|
|
60
76
|
|
|
77
|
+
### Native code debugging (C/C++/Rust)
|
|
78
|
+
```bash
|
|
79
|
+
agent-dbg launch --brk --runtime lldb ./my_program
|
|
80
|
+
agent-dbg break main.c:42
|
|
81
|
+
agent-dbg break-fn main # function breakpoint (DAP only)
|
|
82
|
+
agent-dbg continue
|
|
83
|
+
agent-dbg vars # inspect locals
|
|
84
|
+
agent-dbg eval "array[i]" # evaluate expression
|
|
85
|
+
agent-dbg step into # step into function
|
|
86
|
+
```
|
|
87
|
+
|
|
61
88
|
### Attach to running/test process
|
|
62
89
|
```bash
|
|
63
|
-
# Start
|
|
90
|
+
# Start with inspector enabled
|
|
64
91
|
node --inspect app.js
|
|
65
|
-
# Or
|
|
66
|
-
|
|
92
|
+
# Or: bun --inspect app.ts
|
|
93
|
+
# Then attach
|
|
94
|
+
agent-dbg attach 9229
|
|
67
95
|
agent-dbg state
|
|
68
96
|
```
|
|
69
97
|
|
|
@@ -101,6 +129,7 @@ Refs `@v`/`@f` reset on each pause. `BP#`/`LP#` persist until removed.
|
|
|
101
129
|
|
|
102
130
|
- `--json` -- machine-readable JSON output on any command
|
|
103
131
|
- `--session NAME` -- target a specific session (default: "default")
|
|
132
|
+
- `--runtime NAME` -- select debug adapter (e.g. `lldb` for native code)
|
|
104
133
|
- `--generated` -- bypass source maps, show compiled JS (on state/source/stack)
|
|
105
134
|
|
|
106
135
|
## Command Reference
|
|
@@ -111,8 +140,9 @@ See [references/commands.md](references/commands.md) for full command details an
|
|
|
111
140
|
|
|
112
141
|
- `agent-dbg state` after stepping always shows location + source + locals -- usually enough context
|
|
113
142
|
- `agent-dbg state -c` for source only, `-v` for vars only, `-s` for stack only -- save tokens
|
|
114
|
-
- `agent-dbg eval` supports `await` -- useful for async inspection
|
|
143
|
+
- `agent-dbg eval` supports `await` -- useful for async inspection (JS/TS)
|
|
115
144
|
- `agent-dbg blackbox "node_modules/**"` -- skip stepping into dependencies
|
|
116
|
-
- `agent-dbg hotpatch file` reads the file from disk -- edit the file first, then hotpatch
|
|
145
|
+
- `agent-dbg hotpatch file` reads the file from disk -- edit the file first, then hotpatch (JS/TS only)
|
|
146
|
+
- `agent-dbg break-fn funcName` -- function breakpoints work with DAP runtimes (LLDB)
|
|
117
147
|
- Execution commands (`continue`, `step`, `pause`, `run-to`) auto-return status
|
|
118
148
|
- `agent-dbg stop` kills the debugged process and daemon
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
agent-dbg launch [--brk] <command...> # Start + attach debugger (--brk pauses at first line)
|
|
17
|
+
agent-dbg launch --brk --runtime lldb ./program # Native debugging via LLDB (DAP)
|
|
17
18
|
agent-dbg attach <pid|ws-url|port> # Attach to running process
|
|
18
19
|
agent-dbg stop # Kill process + daemon
|
|
19
20
|
agent-dbg sessions [--cleanup] # List active sessions
|
|
@@ -125,6 +126,8 @@ agent-dbg break-toggle all # Disable/enable all
|
|
|
125
126
|
agent-dbg breakable src/app.ts:10-50 # List valid breakpoint locations
|
|
126
127
|
agent-dbg logpoint src/app.ts:20 "x=${x}" # Log without pausing
|
|
127
128
|
agent-dbg logpoint src/app.ts:20 "x=${x}" --condition "x > 0"
|
|
129
|
+
agent-dbg break-fn <name> # Function breakpoint (DAP runtimes only)
|
|
130
|
+
agent-dbg break-fn main --condition "argc > 1"
|
|
128
131
|
agent-dbg catch all # Pause on all exceptions
|
|
129
132
|
agent-dbg catch uncaught # Pause on uncaught only
|
|
130
133
|
agent-dbg catch none # Don't pause on exceptions
|
|
@@ -167,6 +170,7 @@ agent-dbg sourcemap --disable # Disable resolution globally
|
|
|
167
170
|
|
|
168
171
|
```bash
|
|
169
172
|
--session NAME # Target session (default: "default")
|
|
173
|
+
--runtime NAME # Debug adapter: lldb, codelldb, etc. (for native debugging)
|
|
170
174
|
--json # JSON output
|
|
171
175
|
--color # Enable ANSI colors
|
|
172
176
|
--help-agent # LLM-optimized reference card
|
package/README.md
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
# agent-dbg
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Debugger CLI built for AI agents. Fast, token-efficient, no fluff.
|
|
4
4
|
|
|
5
5
|
**Why?** Agents waste tokens on print-debugging. A real debugger gives precise state inspection in minimal output — variables, stack, breakpoints — all via short `@ref` handles.
|
|
6
6
|
|
|
7
|
+
Inspired by Vercel's [agent-browser](https://github.com/vercel-labs/agent-browser) CLI — the same `@ref` concept, applied to debugging instead of browsing.
|
|
8
|
+
|
|
9
|
+
## Supported Runtimes & Languages
|
|
10
|
+
|
|
11
|
+
| Runtime | Language | Status | Protocol |
|
|
12
|
+
|---------|----------|--------|----------|
|
|
13
|
+
| Node.js | JavaScript | Supported | V8 Inspector (CDP) |
|
|
14
|
+
| Node.js + tsx/ts-node | TypeScript | Supported | V8 Inspector (CDP) + Source Maps |
|
|
15
|
+
| Bun | JavaScript / TypeScript | Supported | WebKit Inspector (JSC) |
|
|
16
|
+
| LLDB | C / C++ / Rust / Swift | Supported | DAP (Debug Adapter Protocol) |
|
|
17
|
+
| Deno | JavaScript / TypeScript | Planned | V8 Inspector (CDP) |
|
|
18
|
+
| Python (debugpy) | Python | Planned | DAP |
|
|
19
|
+
| Go (delve) | Go | Planned | DAP |
|
|
20
|
+
|
|
21
|
+
agent-dbg auto-detects the runtime from the launch command and uses the appropriate protocol adapter. For native languages, use `--runtime lldb` to select the DAP adapter.
|
|
22
|
+
|
|
7
23
|
## Install
|
|
8
24
|
|
|
9
25
|
Requires [Bun](https://bun.sh).
|
|
10
26
|
|
|
11
27
|
```bash
|
|
12
28
|
bun install --global agent-dbg
|
|
13
|
-
npx skills add theodo-group/agent-dbg # Install
|
|
29
|
+
npx skills add theodo-group/agent-dbg # Install Claude Code skill
|
|
14
30
|
```
|
|
15
31
|
|
|
16
32
|
## Example
|
|
@@ -23,17 +39,17 @@ Paused at ./src/app.ts:0:1
|
|
|
23
39
|
BP#1 set at src/app.ts:19
|
|
24
40
|
|
|
25
41
|
> agent-dbg continue
|
|
26
|
-
|
|
42
|
+
Paused at ./src/app.ts:19:21 (other)
|
|
27
43
|
|
|
28
44
|
Source:
|
|
29
|
-
16
|
|
30
|
-
17
|
|
31
|
-
18
|
|
32
|
-
|
|
45
|
+
16|
|
|
46
|
+
17|const alice: Person = { name: "Alice", age: 30 };
|
|
47
|
+
18|const greeting: string = greet(alice);
|
|
48
|
+
> 19|const sum: number = add(2, 3);
|
|
33
49
|
^
|
|
34
|
-
20
|
|
35
|
-
21
|
|
36
|
-
22
|
|
50
|
+
20|console.log(greeting);
|
|
51
|
+
21|console.log("Sum:", sum);
|
|
52
|
+
22|
|
|
37
53
|
|
|
38
54
|
Locals:
|
|
39
55
|
@v1 greet Function greet(person)
|
|
@@ -51,33 +67,30 @@ Breakpoints: 1 active
|
|
|
51
67
|
## Usage
|
|
52
68
|
|
|
53
69
|
```bash
|
|
70
|
+
# Node.js
|
|
54
71
|
agent-dbg launch --brk node app.js
|
|
55
|
-
# Session "default" started (pid 12345)
|
|
56
|
-
# Paused at app.js:1:1
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
# TypeScript (via tsx)
|
|
74
|
+
agent-dbg launch --brk tsx src/app.ts
|
|
60
75
|
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
# Bun
|
|
77
|
+
agent-dbg launch --brk bun app.ts
|
|
63
78
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# @v2 name "alice"
|
|
67
|
-
# @v3 opts {timeout: 3000}
|
|
79
|
+
# C/C++ (via LLDB)
|
|
80
|
+
agent-dbg launch --brk --runtime lldb ./my_program
|
|
68
81
|
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
# Attach to a running process (any runtime with --inspect)
|
|
83
|
+
agent-dbg attach 9229
|
|
71
84
|
|
|
85
|
+
# Debug loop
|
|
86
|
+
agent-dbg break src/handler.ts:42
|
|
87
|
+
agent-dbg continue
|
|
88
|
+
agent-dbg vars
|
|
89
|
+
agent-dbg props @v3
|
|
72
90
|
agent-dbg eval "x + 1"
|
|
73
|
-
# 43
|
|
74
|
-
|
|
75
91
|
agent-dbg step over
|
|
76
|
-
# Paused at src/handler.ts:43:5 (step)
|
|
77
|
-
|
|
78
92
|
agent-dbg set @v1 100
|
|
79
|
-
#
|
|
80
|
-
|
|
93
|
+
agent-dbg hotpatch src/handler.ts # live-edit from disk (JS/TS only)
|
|
81
94
|
agent-dbg stop
|
|
82
95
|
```
|
|
83
96
|
|
|
@@ -88,8 +101,31 @@ agent-dbg stop
|
|
|
88
101
|
| Session | `launch`, `attach`, `stop`, `status`, `sessions` |
|
|
89
102
|
| Execution | `continue`, `step [over\|into\|out]`, `pause`, `run-to`, `restart-frame` |
|
|
90
103
|
| Inspection | `state`, `vars`, `stack`, `eval`, `props`, `source`, `scripts`, `search`, `console`, `exceptions` |
|
|
91
|
-
| Breakpoints | `break`, `break-rm`, `break-ls`, `break-toggle`, `breakable`, `logpoint`, `catch` |
|
|
104
|
+
| Breakpoints | `break`, `break-rm`, `break-ls`, `break-toggle`, `breakable`, `logpoint`, `catch`, `break-fn` (DAP only) |
|
|
92
105
|
| Mutation | `set`, `set-return`, `hotpatch` |
|
|
93
106
|
| Blackbox | `blackbox`, `blackbox-ls`, `blackbox-rm` |
|
|
94
107
|
|
|
95
108
|
Run `agent-dbg --help` or `agent-dbg --help-agent` for the full reference.
|
|
109
|
+
|
|
110
|
+
## Architecture
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
CLI (stateless) --> Unix socket IPC --> Daemon (per session)
|
|
114
|
+
|
|
|
115
|
+
DebugSession / DapSession
|
|
116
|
+
/ \
|
|
117
|
+
CDP path (JS) DAP path (native)
|
|
118
|
+
| |
|
|
119
|
+
RuntimeAdapter DapClient
|
|
120
|
+
/ \ (stdin/stdout)
|
|
121
|
+
NodeAdapter BunAdapter |
|
|
122
|
+
(CDP/V8) (WebKit/JSC) lldb-dap / etc.
|
|
123
|
+
\ /
|
|
124
|
+
CdpClient (WebSocket)
|
|
125
|
+
|
|
|
126
|
+
V8/JSC Inspector
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The daemon manages two session types:
|
|
130
|
+
- **DebugSession** (CDP) — for JavaScript runtimes (Node.js, Bun). Uses `RuntimeAdapter` to handle protocol differences between V8 and JSC.
|
|
131
|
+
- **DapSession** (DAP) — for native debuggers (LLDB, etc.). Communicates with a debug adapter over stdin/stdout using the Debug Adapter Protocol.
|