|
| 1 | +# Cursor-like Debug Mode |
| 2 | + |
| 3 | +Agent-agnostic, opt-in debug mode for reproducible runtime bugs. It includes |
| 4 | +first-class probe helpers for browser/frontend JavaScript and Node.js, while |
| 5 | +the local collector accepts the same structured events from other runtimes. |
| 6 | +Pi installations can also load the bundled interactive checkpoint chooser. |
| 7 | +The `debug-mode` skill ID remains unchanged for compatibility. |
| 8 | + |
| 9 | +Agents add temporary structured probes, collect NDJSON evidence through a |
| 10 | +local loopback collector, wait for you to reproduce manually, fix from log proof, |
| 11 | +verify once, then clean up. |
| 12 | + |
| 13 | +```text |
| 14 | +hypothesize -> instrument -> reproduce -> inspect evidence -> fix -> verify -> clean up |
| 15 | +``` |
| 16 | + |
| 17 | +## When to Use |
| 18 | + |
| 19 | +Use this skill only when you explicitly ask for it, for example: |
| 20 | + |
| 21 | +- `$debug-mode` or `debug mode` |
| 22 | +- instrumented debugging |
| 23 | +- collection of local runtime logs with temporary probes |
| 24 | + |
| 25 | +For ordinary bug reports, test failures, build errors, or explained issues, |
| 26 | +agents should use the normal debug process. |
| 27 | + |
| 28 | +The evidence loop lives in [`skills/debug-mode/SKILL.md`](skills/debug-mode/SKILL.md). |
| 29 | +Detailed contracts load progressively from `skills/debug-mode/references/`. |
| 30 | + |
| 31 | +## How It Works |
| 32 | + |
| 33 | +1. The agent states ranked hypotheses and adds 3–8 targeted probes. |
| 34 | +2. A small loopback collector receives structured events at `POST /log` and |
| 35 | + writes one NDJSON line per event. |
| 36 | +3. The agent stops and asks you to reproduce the bug manually. In Pi, the |
| 37 | + bundled chooser presents exactly `A - Reproduced`, `B - Fixed`, and |
| 38 | + `C - Other: enter details`. If the user selects C, the chooser opens a |
| 39 | + free-form editor. |
| 40 | +4. After you choose or type a reply, it summarizes the log, confirms or rejects |
| 41 | + hypotheses, states the fix acceptance criteria, makes a minimal fix, verifies |
| 42 | + once with probes still active, then removes all instrumentation. |
| 43 | + |
| 44 | +Probe templates for browser or front-end JavaScript and Node.js are in |
| 45 | +`skills/debug-mode/assets/`. Agents start collection with |
| 46 | +`skills/debug-mode/scripts/start-collector.mjs`. The lower-level collector is |
| 47 | +`skills/debug-mode/scripts/log-server.mjs`. The NDJSON summary script is |
| 48 | +`skills/debug-mode/scripts/summarize-log.mjs`. |
| 49 | + |
| 50 | +Agents run `node <skill-dir>/scripts/start-collector.mjs --session <id>`. The |
| 51 | +wrapper fixes host to `127.0.0.1` and port to `0`, then delegates to |
| 52 | +`log-server.mjs --ensure`. It reuses a healthy collector when available. A new |
| 53 | +child binds only to loopback. It writes state and log files in the temporary |
| 54 | +directory. If command authorization denies the request, the agent stops. The |
| 55 | +agent waits for you to run the same command before it adds probes. |
| 56 | + |
| 57 | +## Usage |
| 58 | + |
| 59 | +### Pi package command |
| 60 | + |
| 61 | +If you installed the Pi package, use the short command: |
| 62 | + |
| 63 | +```text |
| 64 | +/cursor-like-debug-mode <problem description> |
| 65 | +``` |
| 66 | + |
| 67 | +This command loads the bundled `debug-mode` skill and starts the same workflow. |
| 68 | +Pi also keeps its native skill command as a compatible alternative: |
| 69 | + |
| 70 | +```text |
| 71 | +/skill:debug-mode <problem description> |
| 72 | +``` |
| 73 | + |
| 74 | +### Agent Skills clients |
| 75 | + |
| 76 | +For Codex and similar clients, invoke the stable Skill ID: |
| 77 | + |
| 78 | +```text |
| 79 | +$debug-mode <problem description> |
| 80 | +``` |
| 81 | + |
| 82 | +When the agent pauses for manual verification, Pi users can select A, B, or C |
| 83 | +from the interactive chooser. If you select C, the chooser opens a text editor. |
| 84 | +If the chooser is not available, reply with the first letter: |
| 85 | + |
| 86 | +```text |
| 87 | +A - Reproduced |
| 88 | +B - Fixed |
| 89 | +C - Other: describe what happened |
| 90 | +``` |
| 91 | + |
| 92 | +Checkpoint wording and fallback behavior live in |
| 93 | +[`references/checkpoints.md`](skills/debug-mode/references/checkpoints.md). |
| 94 | +The main skill owns the evidence format and cleanup criteria. |
| 95 | + |
| 96 | +## Naming and Compatibility |
| 97 | + |
| 98 | +- **Project and display name:** `Cursor-like Debug Mode`. |
| 99 | +- **Stable Agent Skills ID:** `debug-mode`. The directory remains |
| 100 | + `skills/debug-mode/` so existing `$debug-mode`, update, and direct-install |
| 101 | + workflows keep working. |
| 102 | +- **Pi command:** `/cursor-like-debug-mode`. It loads the bundled `debug-mode` |
| 103 | + skill. |
| 104 | +- **Pi tool ID:** `cursor_like_debug_mode_checkpoint`. It is optional and is |
| 105 | + loaded only when the repository is installed as a Pi package. |
| 106 | +- **Other Agent Skills clients:** receive only `skills/debug-mode/`, including |
| 107 | + its scripts and assets. They do not receive or execute the Pi extension and |
| 108 | + use the plain-text checkpoint with A, B, and C. |
| 109 | +- **Runtime:** Node.js 24+ is required only when the bundled collector or summary |
| 110 | + scripts run. |
| 111 | + |
| 112 | +The repository name is `cursor-like-debug-mode`. The stable Skill ID remains |
| 113 | +`debug-mode`. |
| 114 | + |
| 115 | +## Install |
| 116 | + |
| 117 | +### Pi: skill and interactive chooser |
| 118 | + |
| 119 | +Install this repository as a Pi package to load the command, skill, and |
| 120 | +Cursor-like Debug Mode chooser: |
| 121 | + |
| 122 | +```bash |
| 123 | +pi install git:github.com/wangnan0916/cursor-like-debug-mode |
| 124 | +``` |
| 125 | + |
| 126 | +The chooser is a Pi extension and therefore runs only in Pi. In non-interactive |
| 127 | +Pi modes, the workflow automatically uses the plain-text checkpoint with A, B, |
| 128 | +and C. |
| 129 | + |
| 130 | +### Other agents: skill only |
| 131 | + |
| 132 | +Install or inspect the agent-agnostic skill with the open Agent Skills CLI: |
| 133 | + |
| 134 | +```bash |
| 135 | +npx skills add wangnan0916/cursor-like-debug-mode |
| 136 | +npx skills add wangnan0916/cursor-like-debug-mode -g |
| 137 | +npx skills add wangnan0916/cursor-like-debug-mode -a codex |
| 138 | +npx skills add wangnan0916/cursor-like-debug-mode --list |
| 139 | +npx skills update debug-mode |
| 140 | +``` |
| 141 | + |
| 142 | +Use `-g` for global install, `-a codex` for a specific agent, `--list` to list |
| 143 | +without installing, and `npx skills update debug-mode` to update later. This |
| 144 | +installation path does not load the Pi extension. |
| 145 | + |
| 146 | +## Layout |
| 147 | + |
| 148 | +```text |
| 149 | +extensions/ |
| 150 | + cursor-like-debug-mode.ts # Pi checkpoint tool with A, B, and C |
| 151 | + cursor-like-debug-mode-choice.mjs # shared option/result helpers |
| 152 | +
|
| 153 | +skills/debug-mode/ |
| 154 | + SKILL.md # evidence loop and completion criteria |
| 155 | + agents/openai.yaml # Codex / OpenAI skill UI metadata |
| 156 | + assets/ |
| 157 | + browser-log-helper.js # copy into frontend code |
| 158 | + node-log-helper.js # copy into Node/server code |
| 159 | + references/ |
| 160 | + checkpoints.md # interactive and plain-text checkpoint protocol |
| 161 | + collector.md # collector contract and authorization branch |
| 162 | + probes.md # event shape, privacy, markers, and helpers |
| 163 | + troubleshooting.md # failure-only branches |
| 164 | + scripts/ |
| 165 | + start-collector.mjs # safe fixed-host collector entrypoint |
| 166 | + log-server.mjs # loopback NDJSON collector |
| 167 | + summarize-log.mjs # local NDJSON evidence summarizer |
| 168 | +
|
| 169 | +tests/ # Node built-in tests for chooser, collector, helpers, and summarizer |
| 170 | +``` |
| 171 | + |
| 172 | +## Safety |
| 173 | + |
| 174 | +- Collector binds to loopback only (`127.0.0.1`, `localhost`, or `::1`). |
| 175 | +- `start-collector.mjs` fixes host to `127.0.0.1` and port to `0`, then delegates |
| 176 | + to the reusable `--ensure` collector path. |
| 177 | +- Approval denial stops that collector command. Agents wait for collector |
| 178 | + details from the user or a safe fallback through a file. |
| 179 | +- Probes must not log secrets, tokens, cookies, auth headers, or raw private |
| 180 | + payloads. |
| 181 | +- Temporary instrumentation uses `DEBUG_MODE_PROBE <session_id>` region markers |
| 182 | + so agents can remove it mechanically. |
| 183 | +- Debug logs are local temp evidence and should not be committed. |
| 184 | + |
| 185 | +## Development |
| 186 | + |
| 187 | +```bash |
| 188 | +npm run check |
| 189 | +npm test |
| 190 | +``` |
| 191 | + |
| 192 | +Requires Node.js 24+. Tests use only Node.js built-ins. |
| 193 | + |
| 194 | +## License |
| 195 | + |
| 196 | +MIT. See [LICENSE](LICENSE). |
0 commit comments