Skip to content

Commit 2a1c59c

Browse files
committed
init
0 parents  commit 2a1c59c

33 files changed

Lines changed: 3612 additions & 0 deletions

‎.agents/plugins/marketplace.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "runtime-debug-toolkit",
3+
"interface": {
4+
"displayName": "Runtime Debug Toolkit"
5+
},
6+
"plugins": [
7+
{
8+
"name": "runtime-debug-toolkit",
9+
"source": {
10+
"source": "local",
11+
"path": "."
12+
},
13+
"policy": {
14+
"installation": "AVAILABLE",
15+
"authentication": "ON_INSTALL"
16+
},
17+
"category": "Developer Tools"
18+
}
19+
]
20+
}

‎.codex-plugin/plugin.json‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "runtime-debug-toolkit",
3+
"version": "0.1.0",
4+
"description": "Log-driven code tracing and evidence-based runtime debugging on one local server.",
5+
"author": {
6+
"name": "wangnan0916",
7+
"url": "https://github.com/wangnan0916"
8+
},
9+
"homepage": "https://github.com/wangnan0916/runtime-debug-toolkit#readme",
10+
"repository": "https://github.com/wangnan0916/runtime-debug-toolkit",
11+
"license": "MIT",
12+
"keywords": [
13+
"debugging",
14+
"runtime",
15+
"logging",
16+
"tracing",
17+
"instrumentation",
18+
"agent-skill",
19+
"codex-plugin"
20+
],
21+
"skills": "./skills/",
22+
"interface": {
23+
"displayName": "Runtime Debug Toolkit",
24+
"shortDescription": "Trace runtime code paths and fix bugs with log evidence.",
25+
"longDescription": "Locate runtime code with temporary structured logs, or continue the same evidence loop through bug repair, verification, and cleanup.",
26+
"developerName": "wangnan0916",
27+
"category": "Developer Tools",
28+
"capabilities": [
29+
"Interactive",
30+
"Read",
31+
"Write"
32+
],
33+
"defaultPrompt": [
34+
"Use $trace-mode to locate the code handling this runtime behavior.",
35+
"Use $debug-mode to diagnose this reproducible runtime bug with temporary probes."
36+
]
37+
}
38+
}

‎.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: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Runtime Debug Toolkit
2+
3+
Two agent workflows backed by one local loopback log server.
4+
5+
| Skill | Workflow outcome |
6+
| --- | --- |
7+
| `$trace-mode` | Add temporary structured logs, analyze one runtime trace, and locate the responsible code boundary. |
8+
| `$debug-mode` | Use the same trace evidence to confirm a cause, fix the bug, verify it, and clean up. |
9+
10+
`debug-mode` depends on the sibling `trace-mode` skill. The server, runtime
11+
helpers, event protocol, and NDJSON summarizer have one implementation under
12+
`skills/trace-mode/`.
13+
14+
## Workflows
15+
16+
Trace Mode stops after evidence-backed code location:
17+
18+
```text
19+
analyze code -> plan events -> arm server -> instrument -> trigger -> analyze logs -> locate code -> clean
20+
```
21+
22+
Cursor-like Debug Mode continues from the same trace into a verified fix:
23+
24+
```text
25+
analyze code -> hypothesize -> trace with trace-mode -> prove -> fix -> verify -> clean
26+
```
27+
28+
Use `$trace-mode` when the goal is understanding runtime behavior or locating
29+
the code that handles an event. It changes only temporary instrumentation.
30+
31+
Use `$debug-mode` when the goal includes modifying product code. Starting it is
32+
explicit. An active session resumes automatically across later turns until
33+
cleanup or explicit abandonment.
34+
35+
## Shared Log Server
36+
37+
The loopback server accepts one JSON object at `POST /log` and appends one
38+
NDJSON record. `GET /health` reports service state. Each session writes to a
39+
separate file and queue.
40+
41+
Agents start or reuse it with:
42+
43+
```bash
44+
node <trace-mode-skill-dir>/scripts/start-collector.mjs --session <id>
45+
```
46+
47+
The command prints:
48+
49+
```text
50+
LOG_SERVER_URL=<loopback origin>
51+
SESSION_ID=<id>
52+
LOG_DIR=<temporary log directory>
53+
LOG_FILE=<session NDJSON path>
54+
HEALTH_URL=<loopback health URL>
55+
```
56+
57+
The wrapper fixes host to `127.0.0.1` and port to `0`. It reuses one healthy
58+
server across concurrent sessions. State and evidence stay in the operating
59+
system temporary directory.
60+
61+
## Usage
62+
63+
### Agent Skills clients
64+
65+
Locate a runtime path without fixing product code:
66+
67+
```text
68+
$trace-mode trace which handler persists this setting after Save
69+
```
70+
71+
Diagnose and fix a reproducible runtime bug:
72+
73+
```text
74+
$debug-mode the setting resets after Save and reload
75+
```
76+
77+
At debug checkpoints, Codex uses native phase-specific choices when available.
78+
Pi uses the bundled A/B/C chooser. Other clients use the text fallback.
79+
80+
### Pi package command
81+
82+
The short command starts Cursor-like Debug Mode:
83+
84+
```text
85+
/cursor-like-debug-mode <problem description>
86+
```
87+
88+
Pi also exposes both native skill commands:
89+
90+
```text
91+
/skill:trace-mode <runtime question>
92+
/skill:debug-mode <problem description>
93+
```
94+
95+
## Install
96+
97+
### Codex plugin
98+
99+
Add this repository as a marketplace and install the plugin:
100+
101+
```bash
102+
codex plugin marketplace add https://github.com/wangnan0916/runtime-debug-toolkit.git --ref main
103+
codex plugin add runtime-debug-toolkit@runtime-debug-toolkit
104+
```
105+
106+
The plugin packages both skills. It does not load the Pi extension, an MCP
107+
server, or an external service.
108+
109+
### Pi
110+
111+
Install the package to load both skills, the short command, and the chooser:
112+
113+
```bash
114+
pi install git:github.com/wangnan0916/runtime-debug-toolkit
115+
```
116+
117+
### Other agents
118+
119+
Use the open Agent Skills CLI and select both skills when installing
120+
`debug-mode`:
121+
122+
```bash
123+
npx skills add wangnan0916/runtime-debug-toolkit
124+
npx skills add wangnan0916/runtime-debug-toolkit -g
125+
npx skills add wangnan0916/runtime-debug-toolkit -a codex
126+
npx skills add wangnan0916/runtime-debug-toolkit --list
127+
```
128+
129+
`trace-mode` can be installed independently. `debug-mode` requires both sibling
130+
skill directories because its workflow reuses the shared resources.
131+
132+
## Layout
133+
134+
```text
135+
.codex-plugin/
136+
plugin.json
137+
138+
.agents/plugins/
139+
marketplace.json
140+
141+
extensions/
142+
cursor-like-debug-mode.ts
143+
cursor-like-debug-mode-choice.mjs
144+
145+
skills/trace-mode/
146+
SKILL.md # trace and code-location workflow
147+
agents/openai.yaml
148+
assets/
149+
browser-log-helper.js # generic browser event sender
150+
node-log-helper.js # generic Node.js event sender
151+
references/
152+
checkpoint.md # manual trace capture gate
153+
collector.md # lifecycle and authorization contract
154+
probes.md # event design, privacy, and markers
155+
protocol.md # HTTP and NDJSON contract
156+
troubleshooting.md
157+
scripts/
158+
log-server.mjs # shared loopback server
159+
start-collector.mjs # safe reusable entrypoint
160+
summarize-log.mjs # shared evidence summarizer
161+
162+
skills/debug-mode/
163+
SKILL.md # hypothesis, fix, verify, clean workflow
164+
agents/openai.yaml
165+
references/
166+
checkpoints.md # pre-fix and post-fix gates
167+
probes.md # debug fields layered on generic events
168+
troubleshooting.md
169+
170+
tests/
171+
```
172+
173+
## Safety
174+
175+
- The server binds only to `127.0.0.1`, `localhost`, or `::1`.
176+
- The safe wrapper always uses `127.0.0.1` with an available port.
177+
- The server makes no external network calls.
178+
- Event payloads exclude secrets, credentials, and unrelated personal data.
179+
- Temporary instrumentation uses `LOG_SERVER_PROBE <session_id>` markers.
180+
- Runtime logs stay outside the repository and should not be committed.
181+
182+
## Development
183+
184+
Requires Node.js 24 or later. Tests use only Node.js built-ins.
185+
186+
```bash
187+
npm run check
188+
npm test
189+
```
190+
191+
## License
192+
193+
MIT. See [LICENSE](LICENSE).
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/** @typedef {"A" | "B" | "C"} CheckpointSelection */
2+
/** @typedef {{ selection: CheckpointSelection, meaning: "Reproduced" | "Fixed" | "Other", text?: string }} CheckpointAnswer */
3+
4+
export const CURSOR_LIKE_DEBUG_MODE_CHOICES = Object.freeze({
5+
A: "A - Reproduced",
6+
B: "B - Fixed",
7+
C: "C - Other: enter details",
8+
});
9+
10+
export const CURSOR_LIKE_DEBUG_MODE_CHOICE_LIST = Object.freeze(
11+
Object.values(CURSOR_LIKE_DEBUG_MODE_CHOICES),
12+
);
13+
14+
/**
15+
* @param {string | undefined} choice
16+
* @returns {CheckpointSelection | undefined}
17+
*/
18+
export function checkpointCodeFromChoice(choice) {
19+
for (const [code, label] of Object.entries(CURSOR_LIKE_DEBUG_MODE_CHOICES)) {
20+
if (choice === label) return /** @type {CheckpointSelection} */ (code);
21+
}
22+
return undefined;
23+
}
24+
25+
/**
26+
* @param {CheckpointSelection} selection
27+
* @param {string | undefined} [text]
28+
* @returns {CheckpointAnswer}
29+
*/
30+
export function buildCheckpointAnswer(selection, text) {
31+
let meaning;
32+
if (selection === "A") meaning = "Reproduced";
33+
else if (selection === "B") meaning = "Fixed";
34+
else meaning = "Other";
35+
36+
const answer = { selection, meaning };
37+
38+
if (selection === "C") answer.text = text;
39+
return answer;
40+
}
41+
42+
/**
43+
* @param {CheckpointSelection} selection
44+
* @param {string | undefined} [text]
45+
*/
46+
export function formatCheckpointAnswer(selection, text) {
47+
return JSON.stringify(buildCheckpointAnswer(selection, text), null, 2);
48+
}

0 commit comments

Comments
 (0)