Skip to content

Commit 28a4921

Browse files
committed
init
0 parents  commit 28a4921

15 files changed

Lines changed: 2302 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: 24
15+
- run: npm run check
16+
- run: npm test

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log*
4+
5+
.runtime-debug/
6+
*.ndjson

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 wangnan0916
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.

‎README.md‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Debug Mode Skill
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+
7+
Agents add temporary structured probes, collect NDJSON evidence through a
8+
local loopback collector, wait for you to reproduce manually, fix from log proof,
9+
verify once, then clean up.
10+
11+
```text
12+
hypothesize -> instrument -> reproduce -> inspect evidence -> fix -> verify -> clean up
13+
```
14+
15+
## When to Use
16+
17+
Use this skill only when you explicitly ask for it, for example:
18+
19+
- `$debug-mode` or `debug mode`
20+
- instrumented debugging
21+
- local runtime log collection with temporary probes
22+
23+
For ordinary bug reports, failing tests, build errors, or issues already
24+
explained by existing logs, agents should debug normally without this workflow.
25+
26+
Full opt-in rules and the agent workflow live in
27+
[`skills/debug-mode/SKILL.md`](skills/debug-mode/SKILL.md).
28+
29+
## How It Works
30+
31+
1. The agent states ranked hypotheses and adds 3–8 targeted probes.
32+
2. A small loopback collector receives structured events at `POST /log` and
33+
writes one NDJSON line per event.
34+
3. The agent stops and asks you to reproduce the bug manually.
35+
4. After you reply, it summarizes the log, confirms or rejects hypotheses,
36+
states the fix acceptance criteria, makes a minimal fix, verifies once with
37+
probes still active, then removes all instrumentation.
38+
39+
Probe templates for browser/frontend JavaScript and Node/server-side JavaScript
40+
live under `skills/debug-mode/assets/`. Agents start collection with
41+
`skills/debug-mode/scripts/start-collector.mjs`; the lower-level collector is
42+
`skills/debug-mode/scripts/log-server.mjs`; the NDJSON summary script is
43+
`skills/debug-mode/scripts/summarize-log.mjs`.
44+
45+
Agents run `node <skill-dir>/scripts/start-collector.mjs --session <id>`. The
46+
wrapper fixes host to `127.0.0.1` and port to `0`, then delegates to
47+
`log-server.mjs --ensure`. It reuses a healthy collector when available; if it
48+
starts one, the child binds only to loopback and writes state/log files under
49+
the OS temp directory. If command authorization is denied, agents stop and wait
50+
for you to run the same command locally before adding probes.
51+
52+
## Usage
53+
54+
Ask your agent explicitly:
55+
56+
```text
57+
Use $debug-mode to investigate this reproducible runtime bug with temporary probes, manual reproduction, log evidence, a minimal fix, and cleanup.
58+
```
59+
60+
When the agent pauses for manual verification, reply with the leading letter:
61+
62+
```text
63+
A - Reproduced
64+
B - Fixed
65+
C - Other; describe what happened
66+
```
67+
68+
Checkpoint wording, evidence format, troubleshooting, and cleanup steps are in
69+
`SKILL.md`.
70+
71+
## Install
72+
73+
Install or inspect with the open Agent Skills CLI:
74+
75+
```bash
76+
npx skills add wangnan0916/debug-mode-skill
77+
npx skills add wangnan0916/debug-mode-skill -g
78+
npx skills add wangnan0916/debug-mode-skill -a codex
79+
npx skills add wangnan0916/debug-mode-skill --list
80+
npx skills update debug-mode
81+
```
82+
83+
Use `-g` for global install, `-a codex` for a specific agent, `--list` to list
84+
without installing, and `npx skills update debug-mode` to update later.
85+
86+
## Layout
87+
88+
```text
89+
skills/debug-mode/
90+
SKILL.md # full agent workflow and protocol
91+
agents/openai.yaml # Codex / OpenAI skill UI metadata
92+
assets/
93+
browser-log-helper.js # copy into frontend code
94+
node-log-helper.js # copy into Node/server code
95+
scripts/
96+
start-collector.mjs # safe fixed-host collector entrypoint
97+
log-server.mjs # loopback NDJSON collector
98+
summarize-log.mjs # local NDJSON evidence summarizer
99+
100+
tests/ # Node built-in tests for collector, helpers, and summarizer
101+
```
102+
103+
## Safety
104+
105+
- Collector binds to loopback only (`127.0.0.1`, `localhost`, or `::1`).
106+
- `start-collector.mjs` fixes host to `127.0.0.1` and port to `0`, then delegates
107+
to the reusable `--ensure` collector path.
108+
- Approval denial is terminal for that collector command; agents stop until they
109+
have user-provided collector details or a safe file-based fallback.
110+
- Probes must not log secrets, tokens, cookies, auth headers, or raw private
111+
payloads.
112+
- Temporary instrumentation uses `DEBUG_MODE_PROBE <session_id>` region markers
113+
so agents can remove it mechanically.
114+
- Debug logs are local temp evidence and should not be committed.
115+
116+
## Development
117+
118+
```bash
119+
npm run check
120+
npm test
121+
```
122+
123+
Requires Node.js 24+. Tests use only Node.js built-ins.
124+
125+
## License
126+
127+
MIT. See [LICENSE](LICENSE).

‎package.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "debug-mode-skill",
3+
"version": "0.1.0",
4+
"private": true,
5+
"type": "module",
6+
"description": "Agent-agnostic debug-mode skill with local NDJSON log collection.",
7+
"scripts": {
8+
"check": "node --check skills/debug-mode/scripts/log-server.mjs && node --check skills/debug-mode/scripts/start-collector.mjs && node --check skills/debug-mode/scripts/summarize-log.mjs && node --check skills/debug-mode/assets/browser-log-helper.js && node --check skills/debug-mode/assets/node-log-helper.js && node --check tests/log-server.test.mjs && node --check tests/helper-assets.test.mjs && node --check tests/summarize-log.test.mjs",
9+
"test": "node tests/log-server.test.mjs && node tests/helper-assets.test.mjs && node tests/summarize-log.test.mjs"
10+
},
11+
"engines": {
12+
"node": ">=24"
13+
}
14+
}

0 commit comments

Comments
 (0)