You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,38 @@ Want to take on an issue? Leave a comment and a maintainer may assign it to you
42
42
> [!NOTE]
43
43
> After touching `packages/opencode/src/server/server.ts`, run "./packages/sdk/js/script/build.ts" to regenerate the JS sdk.
44
44
45
+
### Setting up a Debugger
46
+
47
+
Bun debugging is currently rough around the edges. We hope this guide helps you get set up and avoid some pain points.
48
+
49
+
The most reliable way to debug OpenCode is to run it manually in a terminal via `bun run --inspect=<url> dev ...` and attach
50
+
your debugger via that URL. Other methods can result in breakpoints being mapped incorrectly, at least in VSCode (YMMV).
51
+
52
+
Caveats:
53
+
54
+
-`*.tsx` files won't have their breakpoints correctly mapped. This seems due to Bun currently not supporting source maps on code transformed
55
+
via `BunPlugin`s (currently necessary due to our dependency on `@opentui/solid`). Currently, the best you can do in terms of debugging `*.tsx`
56
+
files is writing a `debugger;` statement. Debugging facilities like stepping won't work, but at least you will be informed if a specific code
57
+
is triggered.
58
+
- If you want to run the OpenCode TUI and have breakpoints triggered in the server code, you might need to run `bun dev spawn` instead of
59
+
the usual `bun dev`. This is because `bun dev` runs the server in a worker thread and breakpoints might not work there.
60
+
61
+
Other tips and tricks:
62
+
63
+
- You might want to use `--inspect-wait` or `--inspect-brk` instead of `--inspect`, depending on your workflow
64
+
- Specifying `--inspect=ws://localhost:6499/` on every invocation can be tiresome, you may want to `export BUN_OPTIONS=--inspect=ws://localhost:6499/` instead
65
+
66
+
#### VSCode Setup
67
+
68
+
If you use VSCode, you can use our example configurations [.vscode/settings.example.json](.vscode/settings.example.json) and [.vscode/launch.example.json](.vscode/launch.example.json).
69
+
70
+
Some debug methods that can be problematic:
71
+
72
+
- Debug configurations with `"request": "launch"` can have breakpoints incorrectly mapped and thus unusable
73
+
- The same problem arises when running OpenCode in the VSCode `JavaScript Debug Terminal`
74
+
75
+
With that said, you may want to try these methods, as they might work for you.
0 commit comments