opencode-debug-agent 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 zenobi.us
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # opencode-debug-agent
2
+
3
+ OpenCode plugin for runtime debugging - capture and analyze execution data via HTTP instrumentation.
4
+
5
+ ## Features
6
+
7
+ - **Debug Agent** - Primary agent specialized for debugging workflows
8
+ - **Debug Skill** - Use debugging tools from any agent via `skill({ name: "debug" })`
9
+ - **HTTP Server** - Hono-based server with CORS support for browser/Node instrumentation
10
+ - **Port Persistence** - Server remembers its port across sessions
11
+ - **5 Tools** - `debug_start`, `debug_stop`, `debug_read`, `debug_clear`, `debug_status`
12
+
13
+ ## Installation
14
+
15
+ Add to your `opencode.json`:
16
+
17
+ ```json
18
+ {
19
+ "plugin": ["opencode-debug-agent"]
20
+ }
21
+ ```
22
+
23
+ Or for local development, copy to `.opencode/plugin/`.
24
+
25
+ ## Usage
26
+
27
+ ### Using the Debug Agent
28
+
29
+ Switch to the debug agent (Tab key) and describe your issue. The agent will:
30
+
31
+ 1. Start the debug server
32
+ 2. Instrument your code with fetch() calls
33
+ 3. Ask you to reproduce the issue
34
+ 4. Analyze captured logs
35
+ 5. Help identify the problem
36
+ 6. Clean up instrumentation
37
+
38
+ ### Using the Debug Skill (from any agent)
39
+
40
+ ```
41
+ Load the debug skill and help me debug this API timeout issue.
42
+ ```
43
+
44
+ The build agent can then use all debug tools.
45
+
46
+ ### Manual Tool Usage
47
+
48
+ ```
49
+ debug_start # Start server, get instrumentation snippet
50
+ debug_status # Check if server running, get port
51
+ debug_read # Read captured logs
52
+ debug_read(tail: 10) # Read last 10 entries
53
+ debug_clear # Clear log file
54
+ debug_stop # Stop server
55
+ ```
56
+
57
+ ## How It Works
58
+
59
+ 1. **Start server**: `debug_start` launches an HTTP server and returns a ready-to-use fetch() snippet
60
+ 2. **Instrument code**: Insert the snippet at strategic locations to capture runtime data
61
+ 3. **Reproduce issue**: User runs their code normally
62
+ 4. **Analyze logs**: `debug_read` returns captured data as structured JSON
63
+ 5. **Clean up**: `debug_stop` and remove instrumentation
64
+
65
+ ### Instrumentation Example
66
+
67
+ ```javascript
68
+ // Snippet returned by debug_start:
69
+ fetch("http://localhost:54321/log", {
70
+ method: "POST",
71
+ headers: {"Content-Type": "application/json"},
72
+ body: JSON.stringify({label: "LABEL_HERE", data: {YOUR_DATA}})
73
+ })
74
+
75
+ // Used in code:
76
+ fetch("http://localhost:54321/log", {
77
+ method: "POST",
78
+ headers: {"Content-Type": "application/json"},
79
+ body: JSON.stringify({label: "before-api", data: {userId, params}})
80
+ })
81
+ ```
82
+
83
+ ## Files
84
+
85
+ - `.opencode/debug.log` - NDJSON log file
86
+ - `.opencode/debug.port` - Persisted port number
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ bun install
92
+ mise run build
93
+ mise run test
94
+ mise run lint
95
+ ```
96
+
97
+ ## License
98
+
99
+ MIT