oh-my-opencode 5.0.0-beta.21 → 5.0.0-beta.23
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/dist/cli/index.js +290 -288
- package/dist/cli-node/index.js +290 -288
- package/dist/index.js +1675 -1657
- package/dist/skills/debugging/SKILL.md +2 -0
- package/dist/skills/debugging/references/methodology/00-setup.md +12 -0
- package/dist/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/dist/skills/debugging/references/runtimes/go.md +15 -1
- package/dist/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/dist/skills/debugging/references/runtimes/node.md +25 -0
- package/dist/skills/debugging/references/runtimes/python.md +13 -0
- package/dist/skills/debugging/references/runtimes/rust.md +41 -0
- package/dist/skills/debugging/references/scripts/dap.mjs +267 -0
- package/dist/skills/debugging/references/scripts/dap.test.ts +86 -0
- package/dist/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/dist/skills/debugging/references/tools/dap.md +103 -0
- package/dist/skills/debugging/references/tools/frida.md +193 -0
- package/dist/tools/delegate-task/types.d.ts +3 -0
- package/dist/tui.js +131 -147
- package/package.json +18 -15
- package/packages/lsp-core/src/index.ts +1 -0
- package/packages/lsp-core/src/lsp/client-wrapper.ts +25 -5
- package/packages/lsp-core/src/lsp/client.ts +26 -0
- package/packages/lsp-core/src/lsp/connection.ts +16 -0
- package/packages/lsp-core/src/lsp/constants.ts +1 -0
- package/packages/lsp-core/src/lsp/format-document.test.ts +143 -0
- package/packages/lsp-core/src/lsp/format-document.ts +90 -0
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +151 -0
- package/packages/lsp-core/src/lsp/manager.ts +34 -1
- package/packages/lsp-core/src/lsp/server-definitions.ts +29 -0
- package/packages/lsp-core/src/lsp/server-installation.test.ts +376 -0
- package/packages/lsp-core/src/lsp/server-installation.ts +200 -27
- package/packages/lsp-core/src/lsp/server-resolution-local-binary.test.ts +170 -0
- package/packages/lsp-core/src/lsp/server-resolution.ts +18 -5
- package/packages/lsp-core/src/lsp/transport.ts +9 -0
- package/packages/lsp-core/src/lsp/types.ts +8 -0
- package/packages/lsp-core/src/tool-surface.test.ts +13 -1
- package/packages/lsp-core/src/tools/definitions.ts +14 -0
- package/packages/lsp-core/src/tools/format.test.ts +56 -0
- package/packages/lsp-core/src/tools/format.ts +56 -0
- package/packages/lsp-core/src/tools/index.ts +1 -0
- package/packages/lsp-core/src/tools/types.ts +10 -0
- package/packages/lsp-daemon/dist/cli.js +432 -144
- package/packages/lsp-daemon/dist/client.d.ts +10 -0
- package/packages/lsp-daemon/dist/client.js +401 -107
- package/packages/lsp-daemon/dist/daemon-client.d.ts +1 -0
- package/packages/lsp-daemon/dist/daemon-client.js +3 -0
- package/packages/lsp-daemon/dist/index.js +395 -107
- package/packages/lsp-daemon/package.json +1 -1
- package/packages/lsp-tools-mcp/dist/cli.js +384 -99
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +53 -0
- package/packages/lsp-tools-mcp/dist/mcp.js +384 -99
- package/packages/lsp-tools-mcp/dist/tools.js +385 -99
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2 -2
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +69 -35
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +21 -2
- package/packages/omo-codex/plugin/components/codegraph/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +404 -121
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +3 -3
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +3 -3
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +4 -4
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +30 -15
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +30 -15
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +5 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +2 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +11 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +22 -10
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +5 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +13 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +3 -5
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +26 -2
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/model-catalog.json +3 -3
- package/packages/omo-codex/plugin/package-lock.json +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +3 -3
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +2 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +12 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +15 -1
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +25 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +13 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +41 -0
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/dap.mjs +267 -0
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/dap.md +103 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/frida.md +193 -0
- package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +2 -2
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +8 -8
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +2 -2
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +38 -23
- package/packages/shared-skills/skills/debugging/SKILL.md +2 -0
- package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +12 -0
- package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/go.md +15 -1
- package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/node.md +25 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/python.md +13 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +41 -0
- package/packages/shared-skills/skills/debugging/references/scripts/dap.mjs +267 -0
- package/packages/shared-skills/skills/debugging/references/scripts/dap.test.ts +86 -0
- package/packages/shared-skills/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/packages/shared-skills/skills/debugging/references/tools/dap.md +103 -0
- package/packages/shared-skills/skills/debugging/references/tools/frida.md +193 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Frida — Hook a Live Process and See Real Values at Runtime
|
|
2
|
+
|
|
3
|
+
**https://frida.re**
|
|
4
|
+
|
|
5
|
+
Frida injects a JavaScript engine into a running process and lets you intercept function calls, read arguments, patch return values, and trace execution without touching the binary on disk. **When static analysis in Ghidra shows you *what* a function does, Frida shows you what it does *right now*, with real inputs.** The two compose naturally: use Ghidra to find the target function and its offset, then use Frida to hook it and watch live traffic.
|
|
6
|
+
|
|
7
|
+
Choose Frida over Ghidra when you need runtime values (actual arguments, return codes, heap contents) or when the binary's control flow is too obfuscated for static analysis to resolve.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install frida-tools # Python 3 required
|
|
15
|
+
frida --version # verify
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
On macOS, attaching to another user's process needs root (`sudo frida ...`). SIP-protected system binaries (`/usr/bin/*`, `/usr/sbin/*`) are off-limits entirely. On Linux, you may need `ptrace` permissions: run as root or set `kernel.yama.ptrace_scope=0`.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Target discovery with `frida-ps`
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
frida-ps # list local processes
|
|
26
|
+
frida-ps -U # USB-connected device (iOS/Android)
|
|
27
|
+
frida-ps | grep -i target # find your target by name
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## `frida-trace` — zero-code entry point
|
|
33
|
+
|
|
34
|
+
`frida-trace` auto-generates JavaScript handler stubs for every matched function. You don't write any code to start.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
frida-trace -p <pid> -i "recv*" # trace exported functions by glob
|
|
38
|
+
frida-trace -p <pid> -m "-[NSURLSession dataTaskWithRequest:*]" # Objective-C method
|
|
39
|
+
frida-trace -U -p <pid> -j "com.example.App!login*" # Java method (Android)
|
|
40
|
+
frida-trace -f ./target -i "open" # spawn + trace from start
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Generated handler files land in `__handlers__/`. Each looks like:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// __handlers__/libSystem.B.dylib/open.js
|
|
47
|
+
{
|
|
48
|
+
onEnter(log, args, state) {
|
|
49
|
+
// args[0] is the first argument (a pointer)
|
|
50
|
+
log(`open("${args[0].readUtf8String()}")`);
|
|
51
|
+
},
|
|
52
|
+
onLeave(log, retval, state) {
|
|
53
|
+
log(` => ${retval}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Edit that file, save, and `frida-trace` hot-reloads it. This is the fastest path from "I wonder what this function receives" to a concrete answer.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## The JS agent API
|
|
63
|
+
|
|
64
|
+
When `frida-trace` isn't enough, you write a JS agent and load it with `frida` or from a Python host script. These are the building blocks.
|
|
65
|
+
|
|
66
|
+
### Find a function
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
// By exported symbol name
|
|
70
|
+
const openPtr = Module.getExportByName(null, "open"); // null = any module
|
|
71
|
+
const sslWritePtr = Module.getExportByName("libssl.so", "SSL_write");
|
|
72
|
+
|
|
73
|
+
// By offset in a stripped binary (get the offset from Ghidra)
|
|
74
|
+
const base = Module.getBaseAddress("target");
|
|
75
|
+
const funcPtr = base.add(0x1a3c);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Intercept calls
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
Interceptor.attach(openPtr, {
|
|
82
|
+
onEnter(args) {
|
|
83
|
+
// args[0], args[1], ... are NativePointer objects
|
|
84
|
+
const path = args[0].readUtf8String();
|
|
85
|
+
const flags = args[1].toInt32();
|
|
86
|
+
send({ event: "open", path: path, flags: flags });
|
|
87
|
+
},
|
|
88
|
+
onLeave(retval) {
|
|
89
|
+
// retval is the return value as a NativePointer
|
|
90
|
+
send({ event: "open_ret", fd: retval.toInt32() });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Read memory
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
args[0].readUtf8String() // read a UTF-8 C string from a pointer
|
|
99
|
+
args[0].readCString() // read a raw C string (stops at null)
|
|
100
|
+
args[1].readByteArray(len) // read len raw bytes (returns ArrayBuffer)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Replace / stub a function
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
// Force a function to always return 0 (e.g. bypass a license check)
|
|
107
|
+
Interceptor.replace(checkLicensePtr, new NativeCallback(function () {
|
|
108
|
+
return 0;
|
|
109
|
+
}, 'int', []));
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Use `Interceptor.replace` sparingly. It changes program behavior, so always note in your journal that you patched something and why.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Python host script
|
|
117
|
+
|
|
118
|
+
A host script lets you load a JS agent, receive `send()` messages, and post-process results from the Python side.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import frida, sys
|
|
122
|
+
|
|
123
|
+
with open("agent.js") as f:
|
|
124
|
+
agent_source = f.read()
|
|
125
|
+
|
|
126
|
+
def on_message(message, data):
|
|
127
|
+
if message["type"] == "send":
|
|
128
|
+
print(f"[*] {message['payload']}")
|
|
129
|
+
else:
|
|
130
|
+
print(f"[!] {message}")
|
|
131
|
+
|
|
132
|
+
session = frida.attach(int(sys.argv[1]))
|
|
133
|
+
script = session.create_script(agent_source)
|
|
134
|
+
script.on("message", on_message)
|
|
135
|
+
script.load()
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
sys.stdin.read() # block until Ctrl+C
|
|
139
|
+
except KeyboardInterrupt:
|
|
140
|
+
session.detach()
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The agent runs inside the target; the host script stays in your terminal and prints structured output.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Output-budget discipline
|
|
148
|
+
|
|
149
|
+
**Hooking a hot function (e.g. `malloc`, `read`) will flood your context with thousands of lines.** Don't print every call. Aggregate in the agent and report a summary.
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// Count calls, report every 1000
|
|
153
|
+
let callCount = 0;
|
|
154
|
+
Interceptor.attach(mallocPtr, {
|
|
155
|
+
onEnter(args) {
|
|
156
|
+
callCount++;
|
|
157
|
+
if (callCount % 1000 === 0) {
|
|
158
|
+
send({ event: "malloc_summary", total_calls: callCount });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Alternatives: filter by argument value, only log calls from a specific caller module, or batch into an array and `send()` on a timer.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## ⚠️ Gotchas
|
|
169
|
+
|
|
170
|
+
**Attach vs. spawn.** `frida -p <pid>` attaches to an already-running process. If you need to catch early initialization (constructors, `main` entry), spawn the process with `frida -f ./target`. Frida pauses it at startup. Resume with `%resume` in the REPL or by calling `device.resume(pid)` from Python.
|
|
171
|
+
|
|
172
|
+
**Stripped binaries have no symbol names.** `Module.getExportByName` returns null for internal functions. You must find the function offset in Ghidra, then compute the address at runtime:
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
const addr = Module.getBaseAddress("target").add(0x4a20);
|
|
176
|
+
Interceptor.attach(addr, { /* ... */ });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**A crashing target kills your session.** If the target segfaults or aborts, Frida's agent dies with it. Script a respawn loop on the Python side if you expect crashes.
|
|
180
|
+
|
|
181
|
+
**Thread safety.** `onEnter`/`onLeave` fire on multiple threads. Keep shared state to simple counters.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Cleanup
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
kill <pid> # kill any process you spawned with -f
|
|
189
|
+
rm -rf __handlers__/ # remove generated handler stubs
|
|
190
|
+
rm -f agent.js host.py # remove session-specific scripts
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Always note in your journal which processes you attached to and whether you replaced any functions. A forgotten `Interceptor.replace` in a long-running target will cause confusing behavior later.
|
|
@@ -9,7 +9,7 @@ test("#given bundled model catalog #when inspected #then default verifier and wo
|
|
|
9
9
|
const catalog = JSON.parse(await readFile(join(root, "model-catalog.json"), "utf8"));
|
|
10
10
|
|
|
11
11
|
assert.equal(catalog.current.model, "gpt-5.6-sol");
|
|
12
|
-
assert.equal(catalog.current.model_context_window,
|
|
12
|
+
assert.equal(catalog.current.model_context_window, 650000);
|
|
13
13
|
assert.equal(catalog.current.model_reasoning_effort, "high");
|
|
14
14
|
assert.equal(catalog.current.plan_mode_reasoning_effort, "xhigh");
|
|
15
15
|
assert.deepEqual(catalog.roles.default, catalog.current);
|
|
@@ -279,7 +279,7 @@ test("#given active lock #when running check #then skips concurrent update", asy
|
|
|
279
279
|
|
|
280
280
|
assert.equal(result.started, false);
|
|
281
281
|
assert.equal(result.reason, "locked");
|
|
282
|
-
assert.match(await readFile(join(root, "codex-home", "config.toml"), "utf8"), /model_context_window =
|
|
282
|
+
assert.match(await readFile(join(root, "codex-home", "config.toml"), "utf8"), /model_context_window = 650000/);
|
|
283
283
|
});
|
|
284
284
|
|
|
285
285
|
test("#given stale lock #when running check #then removes lock and runs update", async () => {
|
|
@@ -646,7 +646,7 @@ test("#given throttled updater and stale Codex config #when running check #then
|
|
|
646
646
|
assert.equal(result.started, false);
|
|
647
647
|
assert.equal(result.reason, "throttled");
|
|
648
648
|
assert.match(content, /model = "gpt-5\.6-sol"/);
|
|
649
|
-
assert.match(content, /model_context_window =
|
|
649
|
+
assert.match(content, /model_context_window = 650000/);
|
|
650
650
|
assert.match(content, /model_reasoning_effort = "high"/);
|
|
651
651
|
assert.match(content, /plan_mode_reasoning_effort = "xhigh"/);
|
|
652
652
|
assert.doesNotMatch(content, /gpt-5\.2/);
|
|
@@ -55,7 +55,7 @@ test("#given stale root reasoning config #when ensuring config #then replaces st
|
|
|
55
55
|
assert.equal(result.match(/^model_reasoning_effort\s*=/gm)?.length, 1);
|
|
56
56
|
assert.equal(result.match(/^plan_mode_reasoning_effort\s*=/gm)?.length, 1);
|
|
57
57
|
assert.match(result, /model = "gpt-5\.6-sol"/);
|
|
58
|
-
assert.match(result, /model_context_window =
|
|
58
|
+
assert.match(result, /model_context_window = 650000/);
|
|
59
59
|
assert.match(result, /model_reasoning_effort = "high"/);
|
|
60
60
|
assert.match(result, /plan_mode_reasoning_effort = "xhigh"/);
|
|
61
61
|
assert.doesNotMatch(result, /gpt-5\.2/);
|
|
@@ -80,7 +80,7 @@ test("#given section settings reuse managed root keys #when ensuring config #the
|
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
assert.match(result, /^model = "gpt-5\.6-sol"$/m);
|
|
83
|
-
assert.match(result, /^model_context_window =
|
|
83
|
+
assert.match(result, /^model_context_window = 650000$/m);
|
|
84
84
|
assert.match(result, /\[model_providers\.openai\]\nmodel = "provider-scoped-value"\nmodel_context_window = 123456/);
|
|
85
85
|
assert.match(result, /\[profiles\.review\]\nmodel_reasoning_effort = "medium"\nplan_mode_reasoning_effort = "medium"/);
|
|
86
86
|
});
|
|
@@ -162,7 +162,7 @@ test("#given global and project-local stale Codex configs #when migrating #then
|
|
|
162
162
|
|
|
163
163
|
assert.deepEqual(result.changed.sort(), [join(codexHome, "config.toml"), projectConfig].sort());
|
|
164
164
|
assert.match(await readFile(join(codexHome, "config.toml"), "utf8"), /model = "gpt-5\.6-sol"/);
|
|
165
|
-
assert.match(await readFile(projectConfig, "utf8"), /model_context_window =
|
|
165
|
+
assert.match(await readFile(projectConfig, "utf8"), /model_context_window = 650000/);
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
test("#given model catalog is unavailable and stale 272k config #when migrating #then fallback catalog still upgrades it", async () => {
|
|
@@ -184,7 +184,7 @@ test("#given model catalog is unavailable and stale 272k config #when migrating
|
|
|
184
184
|
const content = await readFile(join(codexHome, "config.toml"), "utf8");
|
|
185
185
|
assert.deepEqual(result.changed, [join(codexHome, "config.toml")]);
|
|
186
186
|
assert.match(content, /model = "gpt-5\.6-sol"/);
|
|
187
|
-
assert.match(content, /model_context_window =
|
|
187
|
+
assert.match(content, /model_context_window = 650000/);
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
test("#given model catalog is malformed and stale config #when migrating #then fallback catalog still upgrades it", async () => {
|
|
@@ -207,7 +207,7 @@ test("#given model catalog is malformed and stale config #when migrating #then f
|
|
|
207
207
|
const content = await readFile(join(codexHome, "config.toml"), "utf8");
|
|
208
208
|
assert.deepEqual(result.changed, [join(codexHome, "config.toml")]);
|
|
209
209
|
assert.match(content, /model = "gpt-5\.6-sol"/);
|
|
210
|
-
assert.match(content, /model_context_window =
|
|
210
|
+
assert.match(content, /model_context_window = 650000/);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
test("#given user-customized Codex model config #when migrating #then user values are preserved without root multi-agent mode", async () => {
|
|
@@ -262,7 +262,7 @@ test("#given managed config state is malformed #when migrating #then migration i
|
|
|
262
262
|
const content = await readFile(join(codexHome, "config.toml"), "utf8");
|
|
263
263
|
const state = JSON.parse(await readFile(statePath, "utf8"));
|
|
264
264
|
assert.deepEqual(result.changed, [join(codexHome, "config.toml")]);
|
|
265
|
-
assert.match(content, /model_context_window =
|
|
265
|
+
assert.match(content, /model_context_window = 650000/);
|
|
266
266
|
assert.equal(state.files[join(codexHome, "config.toml")].managed, true);
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -671,14 +671,14 @@ test("#given global config starts with inline-comment features table #when full
|
|
|
671
671
|
const parsed = parseTomlWithPython(content);
|
|
672
672
|
assert.equal("multi_agent_mode" in parsed, false);
|
|
673
673
|
assert.equal(parsed.model, "gpt-5.6-sol");
|
|
674
|
-
assert.equal(parsed.model_context_window,
|
|
674
|
+
assert.equal(parsed.model_context_window, 650000);
|
|
675
675
|
assert.equal(parsed.model_reasoning_effort, "high");
|
|
676
676
|
assert.equal(parsed.plan_mode_reasoning_effort, "xhigh");
|
|
677
677
|
assert.equal(parsed.features.plugins, true);
|
|
678
678
|
assert.equal("multi_agent_mode" in parsed.features, false);
|
|
679
679
|
assert.equal("model" in parsed.features, false);
|
|
680
680
|
assert.equal("model_context_window" in parsed.features, false);
|
|
681
|
-
assert.match(content, /^model = "gpt-5\.6-sol"\nmodel_context_window =
|
|
681
|
+
assert.match(content, /^model = "gpt-5\.6-sol"\nmodel_context_window = 650000/m);
|
|
682
682
|
assert.doesNotMatch(content, /^\s*multi_agent_mode\s*=/m);
|
|
683
683
|
assert.match(content, /\[features\] # keep comment\nplugins = true/);
|
|
684
684
|
});
|
|
@@ -23,7 +23,7 @@ test("#given empty Codex config #when script installer updates config #then sets
|
|
|
23
23
|
// then
|
|
24
24
|
const content = await readFile(configPath, "utf8");
|
|
25
25
|
assert.match(content, /model = "gpt-5\.6-sol"/);
|
|
26
|
-
assert.match(content, /model_context_window =
|
|
26
|
+
assert.match(content, /model_context_window = 650000/);
|
|
27
27
|
assert.match(content, /model_reasoning_effort = "high"/);
|
|
28
28
|
assert.match(content, /plan_mode_reasoning_effort = "xhigh"/);
|
|
29
29
|
});
|
|
@@ -62,7 +62,7 @@ test("#given existing model and reasoning config #when script installer updates
|
|
|
62
62
|
assert.equal(content.match(/^model_reasoning_effort\s*=/gm)?.length, 1);
|
|
63
63
|
assert.equal(content.match(/^plan_mode_reasoning_effort\s*=/gm)?.length, 1);
|
|
64
64
|
assert.match(content, /model = "gpt-5\.6-sol"/);
|
|
65
|
-
assert.match(content, /model_context_window =
|
|
65
|
+
assert.match(content, /model_context_window = 650000/);
|
|
66
66
|
assert.match(content, /model_reasoning_effort = "high"/);
|
|
67
67
|
assert.match(content, /plan_mode_reasoning_effort = "xhigh"/);
|
|
68
68
|
assert.doesNotMatch(content, /model = "gpt-5\.2"/);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// omo-codex-install:
|
|
2
|
+
// omo-codex-install:819e258f7485f9ccdcbb64a54ac0097bf81cd8e2980d7f907017f224b1f99b98:0211b93be64998d1b34d67c74053ea385a23fa560370b8d02016f46f492cfbe3
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __returnValue = (v) => v;
|
|
5
5
|
function __exportSetter(name, newValue) {
|
|
@@ -47,9 +47,12 @@ import {
|
|
|
47
47
|
fsyncSync,
|
|
48
48
|
openSync,
|
|
49
49
|
renameSync,
|
|
50
|
+
rmSync,
|
|
50
51
|
unlinkSync,
|
|
51
52
|
writeFileSync
|
|
52
53
|
} from "node:fs";
|
|
54
|
+
import { randomUUID } from "node:crypto";
|
|
55
|
+
import { dirname as dirname10 } from "node:path";
|
|
53
56
|
function isToleratedFsyncError(error) {
|
|
54
57
|
if (!(error instanceof Error))
|
|
55
58
|
return false;
|
|
@@ -65,24 +68,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
function writeFileAtomically(filePath, content, options = {}) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
try {
|
|
72
|
-
tolerantFsyncSync(tempFileDescriptor, options.fsyncSync ?? fsyncSync);
|
|
73
|
-
} finally {
|
|
74
|
-
closeSync(tempFileDescriptor);
|
|
75
|
-
}
|
|
71
|
+
const platform = options.platform ?? process.platform;
|
|
72
|
+
const fsyncImpl = options.fsyncSync ?? fsyncSync;
|
|
73
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
76
74
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
writeFileSync(tempPath, content, "utf-8");
|
|
76
|
+
const tempFileDescriptor = openSync(tempPath, "r+");
|
|
77
|
+
try {
|
|
78
|
+
tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
|
|
79
|
+
} finally {
|
|
80
|
+
closeSync(tempFileDescriptor);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
renameSync(tempPath, filePath);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
|
|
86
|
+
if (platform !== "win32" || !isPermissionError)
|
|
87
|
+
throw error;
|
|
81
88
|
unlinkSync(filePath);
|
|
82
89
|
renameSync(tempPath, filePath);
|
|
90
|
+
}
|
|
91
|
+
if (platform === "win32")
|
|
83
92
|
return;
|
|
93
|
+
const directoryFileDescriptor = openSync(dirname10(filePath), "r");
|
|
94
|
+
try {
|
|
95
|
+
tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
|
|
96
|
+
} finally {
|
|
97
|
+
closeSync(directoryFileDescriptor);
|
|
84
98
|
}
|
|
85
|
-
|
|
99
|
+
} finally {
|
|
100
|
+
rmSync(tempPath, { force: true });
|
|
86
101
|
}
|
|
87
102
|
}
|
|
88
103
|
var TOLERATED_FSYNC_CODES;
|
|
@@ -348,7 +363,7 @@ var init_env = __esm(() => {
|
|
|
348
363
|
});
|
|
349
364
|
|
|
350
365
|
// node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
351
|
-
import { dirname as
|
|
366
|
+
import { dirname as dirname11, posix as posix2, sep as sep7 } from "node:path";
|
|
352
367
|
function createModulerModifier() {
|
|
353
368
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
354
369
|
return async (frames) => {
|
|
@@ -357,7 +372,7 @@ function createModulerModifier() {
|
|
|
357
372
|
return frames;
|
|
358
373
|
};
|
|
359
374
|
}
|
|
360
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
375
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows = sep7 === "\\") {
|
|
361
376
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
362
377
|
return (filename) => {
|
|
363
378
|
if (!filename)
|
|
@@ -7962,7 +7977,7 @@ var package_default;
|
|
|
7962
7977
|
var init_package = __esm(() => {
|
|
7963
7978
|
package_default = {
|
|
7964
7979
|
name: "@oh-my-opencode/omo-codex",
|
|
7965
|
-
version: "5.0.0-beta.
|
|
7980
|
+
version: "5.0.0-beta.23",
|
|
7966
7981
|
type: "module",
|
|
7967
7982
|
private: true,
|
|
7968
7983
|
description: "Codex harness adapter for oh-my-openagent. Vendored Codex plugin namespace (omo) + TypeScript installer + telemetry.",
|
|
@@ -8182,7 +8197,7 @@ var init_telemetry = __esm(() => {
|
|
|
8182
8197
|
|
|
8183
8198
|
// packages/omo-codex/src/install/install-local-cli.ts
|
|
8184
8199
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
8185
|
-
import { dirname as
|
|
8200
|
+
import { dirname as dirname13, join as join40, resolve as resolve10 } from "node:path";
|
|
8186
8201
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8187
8202
|
|
|
8188
8203
|
// packages/utils/src/runtime/spawn.ts
|
|
@@ -11029,14 +11044,14 @@ import { join as join17 } from "node:path";
|
|
|
11029
11044
|
var FALLBACK_CODEX_MODEL_CATALOG = {
|
|
11030
11045
|
current: {
|
|
11031
11046
|
model: "gpt-5.6-sol",
|
|
11032
|
-
modelContextWindow:
|
|
11047
|
+
modelContextWindow: 650000,
|
|
11033
11048
|
modelReasoningEffort: "high",
|
|
11034
11049
|
planModeReasoningEffort: "xhigh"
|
|
11035
11050
|
},
|
|
11036
11051
|
managedProfiles: [
|
|
11037
11052
|
{
|
|
11038
11053
|
model: "gpt-5.5",
|
|
11039
|
-
modelContextWindow:
|
|
11054
|
+
modelContextWindow: 650000,
|
|
11040
11055
|
modelReasoningEffort: "high",
|
|
11041
11056
|
planModeReasoningEffort: "xhigh"
|
|
11042
11057
|
},
|
|
@@ -13540,7 +13555,7 @@ function shellQuote(value) {
|
|
|
13540
13555
|
// packages/omo-codex/src/install/lazycodex-manual-update.ts
|
|
13541
13556
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
13542
13557
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
13543
|
-
import { dirname as
|
|
13558
|
+
import { dirname as dirname12, join as join38 } from "node:path";
|
|
13544
13559
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
13545
13560
|
import { fileURLToPath } from "node:url";
|
|
13546
13561
|
|
|
@@ -13649,7 +13664,7 @@ function resolveArgs(env2) {
|
|
|
13649
13664
|
function resolveCurrentVersion(env2) {
|
|
13650
13665
|
if (env2.LAZYCODEX_CURRENT_VERSION?.trim())
|
|
13651
13666
|
return env2.LAZYCODEX_CURRENT_VERSION.trim();
|
|
13652
|
-
const pluginRoot =
|
|
13667
|
+
const pluginRoot = dirname12(dirname12(fileURLToPath(import.meta.url)));
|
|
13653
13668
|
return readVersionManifest(resolveInstalledVersionPath(env2, pluginRoot)) ?? readVersionManifest(join38(pluginRoot, "..", "..", "..", "package.json")) ?? readVersionManifest(join38(pluginRoot, ".codex-plugin", "plugin.json"));
|
|
13654
13669
|
}
|
|
13655
13670
|
function resolveLatestVersion(env2) {
|
|
@@ -13829,7 +13844,7 @@ async function installMarketplaceLocally(options = {}) {
|
|
|
13829
13844
|
return runCodexInstaller(options);
|
|
13830
13845
|
}
|
|
13831
13846
|
function resolveDefaultRepoRootForEntrypoint(entrypointPath) {
|
|
13832
|
-
return resolve10(
|
|
13847
|
+
return resolve10(dirname13(entrypointPath), "..", "..", "..");
|
|
13833
13848
|
}
|
|
13834
13849
|
function resolveDefaultRepoRoot() {
|
|
13835
13850
|
return resolveDefaultRepoRootForEntrypoint(fileURLToPath2(import.meta.url));
|
|
@@ -53,6 +53,8 @@ These are not "optional extras". They are the correct tool in their domain, and
|
|
|
53
53
|
| **Ghidra** | Any binary without trustworthy source — third-party closed libs, malware, vendored binaries whose behavior contradicts docs, CTF, firmware. **Use Ghidra's decompiler before `strings`/`objdump` guessing. It turns machine code into readable C.** | 📖 **[references/tools/ghidra.md](references/tools/ghidra.md)** |
|
|
54
54
|
| **pwndbg** | Any native binary debugging session. It is GDB with the useful views (registers, stack, disasm, heap) always visible. **If you'd reach for plain `gdb`, reach for `pwndbg` instead — it is strictly a superset.** | 📖 **[references/tools/pwndbg.md](references/tools/pwndbg.md)** |
|
|
55
55
|
| **pwntools** | Any time you need a reproducible interaction with a binary or network service — crafted payloads, exploit automation, fuzz harness, CTF scripting. | 📖 **[references/tools/pwntools.md](references/tools/pwntools.md)** |
|
|
56
|
+
| **Frida** | Any running process you must instrument live without source or symbols — hook a function and print real argument values, trace calls, stub a return. Complements Ghidra: Ghidra reads the bytes, Frida watches them execute. **If Ghidra's static decompile has hit its limit, reach for Frida.** | 📖 **[references/tools/frida.md](references/tools/frida.md)** |
|
|
57
|
+
| **DAP client (`dap.mjs`)** | Any time you would drive a debugger through a PTY and screen-scrape its text. Debuggers already speak the machine-readable Debug Adapter Protocol (debugpy, `dlv dap`, lldb-dap, js-debug); this bundled script drives it with bounded, monitorable output. **Prefer it over scraping `gdb`/`pdb` whenever the debugger speaks DAP.** Design modeled on oh-my-pi's `debug` tool (github.com/can1357/oh-my-pi). | 📖 **[references/tools/dap.md](references/tools/dap.md)** |
|
|
56
58
|
|
|
57
59
|
**Failing to use these tools in their domain is a process failure, not a stylistic choice.** If the bug is in a browser and you did Phase 8 without Playwright, you are doing it wrong. If the bug is in a stripped binary and you read hex with `xxd`, you are doing it wrong. The references tell you how. Read them.
|
|
58
60
|
|
|
@@ -35,6 +35,18 @@ The shape of the answers you need (commands in the runtime reference):
|
|
|
35
35
|
| Is there an existing failing test or known repro? | Prefer amplifying an existing repro over inventing one. |
|
|
36
36
|
| Are watchers (file watchers, hot reloaders, supervisors) going to restart the process mid-session? | If yes, turn them off before attaching. Restarts drop inspector connections and invalidate breakpoints. |
|
|
37
37
|
|
|
38
|
+
### Output budget
|
|
39
|
+
|
|
40
|
+
**Bound every inspection before you run it; unbounded output destroys the investigation's working context.**
|
|
41
|
+
- Set a frame count, element count, or byte range for every query.
|
|
42
|
+
- Prefer one targeted query over one broad dump: ask for the value that distinguishes hypotheses.
|
|
43
|
+
- Page through more data only when the first bounded result says it is necessary; do not re-dump the whole object.
|
|
44
|
+
- Treat any command whose output size you cannot predict as a command that needs a limit.
|
|
45
|
+
- Before: GDB `bt` — After: GDB `bt 10` to inspect only the top ten frames.
|
|
46
|
+
- Before: LLDB `memory read 0x1000` — After: `memory read 0x1000 -c 32` for a bounded byte range.
|
|
47
|
+
- Before: LLDB `frame variable` — After: `frame variable --children-count 10 user` for one variable's children.
|
|
48
|
+
- This is not presentation etiquette: a flooded context hides the decisive observation and can end the investigation.
|
|
49
|
+
|
|
38
50
|
### 4. Gate check
|
|
39
51
|
|
|
40
52
|
If any answer is "I'm not sure", you are not ready for Phase 1. Investigate until certain. Guessing here cascades into false-positive hypotheses in Phase 2.
|
|
@@ -39,6 +39,27 @@ If two hypotheses have identical distinguishing evidence, they aren't actually d
|
|
|
39
39
|
|
|
40
40
|
## Phase 3 — Parallel Investigation
|
|
41
41
|
|
|
42
|
+
### State freshness invariant
|
|
43
|
+
|
|
44
|
+
**A debug session's state is a snapshot with a lifetime, not a fact you can carry forward indefinitely.**
|
|
45
|
+
- Before any action that mutates the debuggee, re-observe the session's current state.
|
|
46
|
+
- This includes continue, step, side-effecting evaluation, setting or removing breakpoints, and termination.
|
|
47
|
+
- Record the current thread state and stop reason; those are the concrete tells for whether the old plan still applies.
|
|
48
|
+
- An observation from an earlier turn may already be stale when the next action is issued.
|
|
49
|
+
- Turns can be minutes apart while the debuggee runs at full speed, so this failure mode is normal, not exceptional.
|
|
50
|
+
- If the thread state or stop reason has moved, re-observe the new state and do not replay the old plan.
|
|
51
|
+
- Treat every mutation as conditional on the state you just observed, not on a remembered stop.
|
|
52
|
+
|
|
53
|
+
### Failure-to-recovery taxonomy
|
|
54
|
+
|
|
55
|
+
| Failure signature | Most likely cause | Next move |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Adapter or debugger process failed to start | Wrong binary or missing installation | Verify the tool exists, then re-launch; do not retry blindly. |
|
|
58
|
+
| Breakpoint accepted but never bound or verified | Source path mismatch, optimized-out code, or missing debug symbols | Check the binary was built with symbols and that the debugger-resolved path matches your file. |
|
|
59
|
+
| Attach refused | Permissions, ptrace scope, SIP, or wrong PID | Fix the environment or target identity; a retry will not change it. |
|
|
60
|
+
| No stop event within the expected window | Process is running, the breakpoint is unreachable, or the wait was too short | Pause and inspect threads rather than waiting longer. |
|
|
61
|
+
| Session terminated unexpectedly | The debuggee crashed or exited | Capture the exit and crash evidence before restarting. |
|
|
62
|
+
|
|
42
63
|
Branch depending on what's available.
|
|
43
64
|
|
|
44
65
|
### Path A: Team mode ENABLED
|
|
@@ -42,10 +42,24 @@ dlv exec ./bin/myserver
|
|
|
42
42
|
# Attach to a running process
|
|
43
43
|
dlv attach $(pgrep myserver)
|
|
44
44
|
|
|
45
|
-
#
|
|
45
|
+
# Delve's JSON-RPC API (IDE / remote attach) — default port 2345
|
|
46
46
|
dlv debug --headless --listen=:2345 --api-version=2 ./cmd/server
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Delve exposes two distinct machine-readable interfaces:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Debug Adapter Protocol: use this for editors and DAP-aware automation
|
|
53
|
+
dlv dap --listen=127.0.0.1:2345
|
|
54
|
+
|
|
55
|
+
# Delve's JSON-RPC API: use this for clients built directly against Delve's API
|
|
56
|
+
dlv debug --headless --listen=127.0.0.1:2345 --api-version=2 ./cmd/server
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Pick `dlv dap` when the client speaks DAP; pick headless JSON-RPC when you need Delve's
|
|
60
|
+
native API or an existing JSON-RPC client. Both expose structured state, unlike scraping
|
|
61
|
+
an interactive `(dlv)` session.
|
|
62
|
+
|
|
49
63
|
### Building a debuggable binary
|
|
50
64
|
|
|
51
65
|
The compiler inlines and optimizes aggressively in normal builds, which makes stepping confusing. For serious debugging:
|
|
@@ -107,6 +107,24 @@ print(repr(data[max(0,pos-100):pos+200]))
|
|
|
107
107
|
|
|
108
108
|
If you must keep using `strings`, lower the threshold: `strings -n 1 -t x ./target | rg ...`. The signal-to-noise drops sharply but short content is preserved.
|
|
109
109
|
|
|
110
|
+
### Sanitizer build for a crashing C/C++ binary
|
|
111
|
+
|
|
112
|
+
If the binary can be rebuilt from C/C++ sources, reproduce the crash with sanitizers before
|
|
113
|
+
trying to infer the fault from stripped machine code. AddressSanitizer catches out-of-bounds
|
|
114
|
+
accesses and use-after-free; UndefinedBehaviorSanitizer reports undefined operations.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Rebuild with source locations and runtime checks enabled
|
|
118
|
+
CFLAGS='-g -O1 -fsanitize=address,undefined' \
|
|
119
|
+
CXXFLAGS='-g -O1 -fsanitize=address,undefined' \
|
|
120
|
+
make clean all
|
|
121
|
+
./target
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The sanitizer report identifies the invalid access and its allocation/free or undefined
|
|
125
|
+
operation stack, often making the root cause clear before dynamic analysis. For a binary
|
|
126
|
+
that cannot be rebuilt, continue with the native tracing and debugger workflow below.
|
|
127
|
+
|
|
110
128
|
Write the triage summary to the journal:
|
|
111
129
|
|
|
112
130
|
```markdown
|
|
@@ -229,6 +247,26 @@ lldb ./target
|
|
|
229
247
|
(lldb) image dump symtab ./target
|
|
230
248
|
```
|
|
231
249
|
|
|
250
|
+
### Data watchpoints — catch the corruption, not just the crash
|
|
251
|
+
|
|
252
|
+
When a value is already wrong by the time execution reaches the crash, watch the memory
|
|
253
|
+
address for writes and stop at the instruction that corrupts it. Use the address of the
|
|
254
|
+
field or buffer identified from the static/dynamic hypothesis; see [tools/pwndbg.md](../tools/pwndbg.md)
|
|
255
|
+
for the richer pwndbg watchpoint workflow rather than duplicating it here.
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
# lldb: watch writes to an address (replace with a valid expression/address)
|
|
259
|
+
(lldb) watchpoint set expression -- <addr>
|
|
260
|
+
|
|
261
|
+
# gdb: stop on writes, or on reads when a read is the first observable symptom
|
|
262
|
+
(gdb) watch *(<type> *)<addr>
|
|
263
|
+
(gdb) rwatch *(<type> *)<addr>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
A watchpoint is most useful after narrowing the suspect object: continue from its
|
|
267
|
+
allocation or initialization, and inspect the backtrace and writer when it triggers.
|
|
268
|
+
Hardware watchpoint slots are limited, so remove broad watchpoints before adding more.
|
|
269
|
+
|
|
232
270
|
**Function interception via `DYLD_INSERT_LIBRARIES`** (macOS equivalent of `LD_PRELOAD`):
|
|
233
271
|
|
|
234
272
|
```bash
|
|
@@ -98,6 +98,31 @@ bun test --inspect-brk # debug test runner
|
|
|
98
98
|
|
|
99
99
|
**Critical**: Bun uses WebKit Inspector Protocol, not V8. `chrome://inspect` cannot connect directly. Use `debug.bun.sh` or the (currently buggy, per Bun docs) VS Code extension.
|
|
100
100
|
|
|
101
|
+
### Scripted V8 inspector / CDP attach
|
|
102
|
+
|
|
103
|
+
The inspector port also serves machine-readable HTTP discovery endpoints. `/json` lists
|
|
104
|
+
inspectable targets; `/json/version` includes the WebSocket debugger URL. Connect that
|
|
105
|
+
URL with the Chrome DevTools Protocol (CDP), rather than scraping `node inspect` text.
|
|
106
|
+
`chrome-remote-interface` is the canonical scriptable npm client. When browser automation
|
|
107
|
+
is already in play, use Playwright's `CDPSession` instead.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
curl -s http://127.0.0.1:9229/json/version
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
const CDP = require('chrome-remote-interface');
|
|
115
|
+
const version = await fetch('http://127.0.0.1:9229/json/version').then(r => r.json());
|
|
116
|
+
const client = await CDP({ target: version.webSocketDebuggerUrl });
|
|
117
|
+
await client.Runtime.enable();
|
|
118
|
+
await client.Debugger.pause();
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The same CDP commands can be sent through `chrome-remote-interface`; with Playwright,
|
|
122
|
+
create a session with `await context.newCDPSession(page)` and call
|
|
123
|
+
`await session.send('Runtime.enable')`. These V8/CDP examples do not apply to Bun's
|
|
124
|
+
WebKit inspector protocol.
|
|
125
|
+
|
|
101
126
|
### Deno (native V8, Chrome DevTools / VS Code compatible)
|
|
102
127
|
|
|
103
128
|
```bash
|
|
@@ -41,6 +41,19 @@ python -c 'import asyncio; print(asyncio.__version__)'
|
|
|
41
41
|
| **post-mortem `pdb.pm()`** | Exception already happened, you want to inspect state | In an exception-caught REPL: `import pdb; pdb.pm()` after the exception propagates |
|
|
42
42
|
| **debugpy (remote / IDE)** | IDE attach, remote host, containerized process | `python -m debugpy --listen 5678 --wait-for-client script.py` then attach from VS Code / PyCharm |
|
|
43
43
|
|
|
44
|
+
`debugpy` is a Debug Adapter Protocol (DAP) adapter, not merely an IDE convenience.
|
|
45
|
+
Its listener exposes a machine-readable protocol that an agent or other client can drive
|
|
46
|
+
programmatically; it is a better boundary for automation than the human-oriented pdb REPL.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Listen on the requested interface and wait before executing the script
|
|
50
|
+
python -m debugpy --listen <host:port> --wait-for-client <script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use a DAP client to send structured requests and receive structured stopped/continued
|
|
54
|
+
and stack/variable events. By contrast, `pdb` exposes prompt-oriented text: an agent
|
|
55
|
+
using it must screen-scrape output and parse a human-facing REPL.
|
|
56
|
+
|
|
44
57
|
### Prefer `ipdb` or `pudb` over plain `pdb` when available
|
|
45
58
|
|
|
46
59
|
- **ipdb** — drop-in replacement with tab completion, syntax highlighting. `pip install ipdb`, then `PYTHONBREAKPOINT=ipdb.set_trace` or use `import ipdb; ipdb.set_trace()`.
|