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/demo/DEMO.md DELETED
@@ -1,71 +0,0 @@
1
- # Demo: AI Agent Debugging with agent-dbg
2
-
3
- ## Overview
4
-
5
- This demo shows Claude Code autonomously debugging a buggy Node.js app using `agent-dbg` — finding root causes, inspecting variables, and hot-patching fixes **without restarting the process**.
6
-
7
- **Total demo time: ~3 minutes**
8
-
9
- ## The Buggy App
10
-
11
- `order-processor.js` processes customer orders, applies discount codes, and calculates totals. It has **two bugs**:
12
-
13
- | Bug | Type | Symptom |
14
- |-----|------|---------|
15
- | **Bug 1** — `calculateSubtotal` loop uses `<=` instead of `<` | Off-by-one | Crashes with `TypeError: Cannot read properties of undefined` |
16
- | **Bug 2** — `applyDiscount` returns `subtotal * rate` instead of `subtotal * (1 - rate)` | Logic error | Returns the discount amount ($20) instead of the discounted price ($80) |
17
-
18
- ### Expected correct output
19
- ```
20
- ORD-001: subtotal $125, total $100 (125 * 0.80)
21
- ORD-002: subtotal $75, total $75 (no discount)
22
- ORD-003: subtotal $225, total $180 (225 * 0.80)
23
- ```
24
-
25
- ## Running the Demo
26
-
27
- ### Prompt to give Claude Code
28
-
29
- ```
30
- This order processor is crashing and the totals look wrong. Debug it with agent-dbg and fix both bugs without restarting the process.
31
-
32
- The app is at demo/order-processor.js
33
- ```
34
-
35
- ### What the agent will do (key moments to narrate)
36
-
37
- 1. **Launch with `--brk`** — Agent starts the app paused at the first line using `agent-dbg launch --brk demo/order-processor.js`
38
-
39
- 2. **Set breakpoints** — Agent sets a breakpoint inside `calculateSubtotal` and continues execution
40
-
41
- 3. **Hit the crash** — The off-by-one `<=` causes a `TypeError` on `items[2]` when `items.length` is 2. Agent inspects the error, sees `i` equals `items.length`, identifies the off-by-one
42
-
43
- 4. **Hot-patch Bug 1** — Agent uses `agent-dbg hotpatch` to fix `i <= items.length` to `i < items.length` **in the running process** (no restart!)
44
-
45
- 5. **Continue and inspect** — Agent restarts the frame or continues. Orders process without crashing, but the discount amounts look wrong
46
-
47
- 6. **Investigate Bug 2** — Agent sets a breakpoint in `applyDiscount`, inspects `subtotal`, `rate`, and the return value. Evals `subtotal * rate` vs `subtotal * (1 - rate)` to confirm the formula is wrong
48
-
49
- 7. **Hot-patch Bug 2** — Agent patches `return subtotal * rate` to `return subtotal * (1 - rate)`
50
-
51
- 8. **Verify** — Agent continues execution, sees the correct totals in the output
52
-
53
- ### Talking Points
54
-
55
- - **No restart needed**: Both fixes were applied to the live process via hot-patching
56
- - **Agent reasoning**: The agent didn't just fix a crash — it reasoned about the discount math to catch the subtle logic bug
57
- - **Token-efficient output**: agent-dbg's compact output format keeps the agent's context window lean
58
- - **@ref system**: Variables use short references (@v1, @v2...) that the agent can use in subsequent commands without copying long object IDs
59
-
60
- ## Manual Verification
61
-
62
- ```bash
63
- # Should crash (Bug 1)
64
- node demo/order-processor.js
65
-
66
- # After fixing Bug 1 (change <= to <), should show wrong discounts (Bug 2)
67
- # ORD-001 total will be 25 instead of 100
68
-
69
- # After fixing both bugs, correct output
70
- node demo/order-processor.js
71
- ```
@@ -1,35 +0,0 @@
1
- // Order Processor — calculates totals and applies discount codes
2
- const orders = [
3
- { id: "ORD-001", items: [{ name: "Widget", price: 25, qty: 3 }, { name: "Gadget", price: 50, qty: 1 }], discount: "SAVE20" },
4
- { id: "ORD-002", items: [{ name: "Gizmo", price: 15, qty: 5 }], discount: null },
5
- { id: "ORD-003", items: [{ name: "Doohickey", price: 100, qty: 2 }, { name: "Widget", price: 25, qty: 1 }], discount: "SAVE20" },
6
- ];
7
-
8
- const discountCodes = { SAVE20: 0.20, HALF: 0.50, VIP: 0.30 };
9
-
10
- function calculateSubtotal(items) {
11
- let subtotal = 0;
12
- for (let i = 0; i < items.length; i++) {
13
- subtotal += items[i].price * items[i].qty;
14
- }
15
- return subtotal;
16
- }
17
-
18
- function applyDiscount(subtotal, code) {
19
- if (!code) return subtotal;
20
- const rate = discountCodes[code];
21
- return subtotal * (1 - rate);
22
- }
23
-
24
- function processOrders(orders) {
25
- const results = [];
26
- for (const order of orders) {
27
- const subtotal = calculateSubtotal(order.items);
28
- const total = applyDiscount(subtotal, order.discount);
29
- results.push({ id: order.id, subtotal, total });
30
- }
31
- return results;
32
- }
33
-
34
- const results = processOrders(orders);
35
- console.log("Order Results:", JSON.stringify(results, null, 2));
Binary file
@@ -1,20 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>English</string>
7
- <key>CFBundleIdentifier</key>
8
- <string>com.apple.xcode.dsym.hello</string>
9
- <key>CFBundleInfoDictionaryVersion</key>
10
- <string>6.0</string>
11
- <key>CFBundlePackageType</key>
12
- <string>dSYM</string>
13
- <key>CFBundleSignature</key>
14
- <string>????</string>
15
- <key>CFBundleShortVersionString</key>
16
- <string>1.0</string>
17
- <key>CFBundleVersion</key>
18
- <string>1</string>
19
- </dict>
20
- </plist>
@@ -1,5 +0,0 @@
1
- ---
2
- triple: 'arm64-apple-darwin'
3
- binary-path: '/Users/waltoss/Code/Theodo/OpenSource/agent-dbg/tests/fixtures/dap/hello'
4
- relocations: []
5
- ...