@punks/cli 1.0.1 → 1.0.2

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.
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: dp-cli
3
+ description: Operates the DevPunks `dp` CLI and follows its scaffold, stage, update, and post-command handoff artifacts through to completion. Use when a repo contains `.devpunks/` output, when the user mentions `dp scaffold`, `dp update`, DevPunks CLI setup, or asks what to do after running a `dp` command.
4
+ metadata: {"devpunks":{"entrypoint":true}}
5
+ ---
6
+
7
+ # DP CLI
8
+
9
+ The `dp` CLI scaffolds DevPunks agent assets and writes follow-up instructions for the next agent.
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ dp scaffold setup
15
+ dp scaffold stage init
16
+ dp scaffold stage backlog
17
+ dp update --check
18
+ dp update --write
19
+ ```
20
+
21
+ After any command, read the command output and generated artifacts before acting.
22
+
23
+ ## Core Rule
24
+
25
+ `.devpunks/` is an active work queue.
26
+
27
+ Do not summarize the generated files and stop. Read the handoff, execute the specs, reconcile generated assets, and report only remaining unresolved items.
28
+
29
+ ## Command Workflows
30
+
31
+ See [references/commands.md](references/commands.md) for command intent and when to use each command.
32
+
33
+ See [references/post-command-flow.md](references/post-command-flow.md) for the required agent flow after `dp scaffold` or `dp update`.
34
+
35
+ ## Scaffold Setup
36
+
37
+ After `dp scaffold setup`, expect artifacts such as:
38
+
39
+ - `.devpunks/AGENT-SYSTEM-PROMPT.md`
40
+ - `.devpunks/AGENT-HANDOFF.md`
41
+ - `.devpunks/scaffold-manifest.json`
42
+ - `.devpunks/required-tools.json`
43
+ - `.devpunks/specs/prompts/**/*.md`
44
+ - `.devpunks/specs/lint/*`
45
+ - `.devpunks/specs/subagents/manifest-spec.json`
46
+
47
+ Read `.devpunks/AGENT-SYSTEM-PROMPT.md` first when present.
48
+
49
+ Then author or reconcile the final repo files requested by the specs, including prompt files, harness mirrors, lint configuration, and subagent manifests.
50
+
51
+ ## Update
52
+
53
+ After `dp update`, inspect `.devpunks/scaffold-manifest.json` and the update summary.
54
+
55
+ - `--check` reports managed-file drift without writing.
56
+ - `--write` refreshes scaffold-managed assets.
57
+ - pack drift is a setup decision point, not a silent auto-fix.
58
+
59
+ ## Completion Checklist
60
+
61
+ - `.devpunks/AGENT-SYSTEM-PROMPT.md` was followed or consciously superseded.
62
+ - `.devpunks/specs/**` items were implemented or listed as unresolved.
63
+ - required tools were checked when `.devpunks/required-tools.json` exists.
64
+ - final prompt files and harness mirrors match the handoff contract.
65
+ - subagent manifests were reconciled when specs exist.
@@ -0,0 +1,33 @@
1
+ # DP CLI Commands
2
+
3
+ ## `dp scaffold setup`
4
+
5
+ Use for repo-aware full scaffold setup.
6
+
7
+ It detects package manifests, resolves packs, writes `.agents/`, harness files, selected skills, prompt specs, lint specs, subagent specs, required tools metadata, and `.devpunks/scaffold-manifest.json`.
8
+
9
+ It does not finish all repo-specific authoring. The next agent must use `.devpunks/AGENT-SYSTEM-PROMPT.md` and `.devpunks/specs/**` to generate final scoped guidance and reconcile assets.
10
+
11
+ ## `dp scaffold stage init`
12
+
13
+ Use before boilerplate exists.
14
+
15
+ It scaffolds requirements-stage assets and prints an operator prompt. Follow that prompt before moving to another stage.
16
+
17
+ ## `dp scaffold stage backlog`
18
+
19
+ Use to inspect or enter the backlog stage.
20
+
21
+ When no backlog-stage packs are available, the command still prints the operator prompt so the stage boundary is explicit.
22
+
23
+ ## `dp update --check`
24
+
25
+ Use to preview managed scaffold drift from `.devpunks/scaffold-manifest.json`.
26
+
27
+ Report missing, changed, or pack-drift findings. Do not write files.
28
+
29
+ ## `dp update --write`
30
+
31
+ Use to refresh scaffold-managed files recorded in `.devpunks/scaffold-manifest.json`.
32
+
33
+ After writing, verify the refreshed files still fit the repo shape and any pack drift is handled intentionally.
@@ -0,0 +1,45 @@
1
+ # Post-Command Flow
2
+
3
+ ## Read Order
4
+
5
+ When `.devpunks/` exists, read in this order:
6
+
7
+ 1. `.devpunks/AGENT-SYSTEM-PROMPT.md`
8
+ 2. `.devpunks/AGENT-HANDOFF.md`
9
+ 3. `.devpunks/scaffold-manifest.json`
10
+ 4. `.devpunks/required-tools.json`
11
+ 5. `.devpunks/specs/**`
12
+
13
+ If a file is missing, continue with the next available artifact and say what was missing.
14
+
15
+ ## Artifact Meaning
16
+
17
+ - `.devpunks/AGENT-SYSTEM-PROMPT.md`: paste-ready instructions for the next agent.
18
+ - `.devpunks/AGENT-HANDOFF.md`: human-readable scaffold summary and required follow-up.
19
+ - `.devpunks/scaffold-manifest.json`: source of truth for managed files and update behavior.
20
+ - `.devpunks/required-tools.json`: tools implied by selected skills.
21
+ - `.devpunks/specs/prompts/**`: instructions for final prompt files, not final prompt bodies.
22
+ - `.devpunks/specs/lint/**`: lint asset selection and starter config guidance.
23
+ - `.devpunks/specs/subagents/**`: desired subagent manifest shape.
24
+
25
+ ## Required Follow-Through
26
+
27
+ After `dp scaffold setup`:
28
+
29
+ - Generate final root/docs/workspace `AGENTS.md` files from prompt specs.
30
+ - Create sibling `CLAUDE.md` symlink mirrors for those neutral prompt files.
31
+ - Keep `.agents/AGENTS.md` as the shared global prompt source.
32
+ - Keep `.agents/skills/` as the main skill directory; only `.claude/skills` mirrors it.
33
+ - Reconcile `.agents/subagents/manifest.mjs` with both `.agents/subagents/manifest.prompt.md` and `.devpunks/specs/subagents/manifest-spec.json`.
34
+ - Use lint specs to produce or update the repo's real lint config when requested.
35
+
36
+ Do not stop after saying the files exist.
37
+
38
+ ## Reporting
39
+
40
+ Final reports should say:
41
+
42
+ - what artifacts were consumed
43
+ - what final files were authored or reconciled
44
+ - what validation ran
45
+ - what remains unresolved, if anything
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: debug-agent
3
+ description: >-
4
+ Systematic evidence-based debugging using runtime logs. Generates hypotheses,
5
+ instruments code with NDJSON logs, guides reproduction, analyzes log evidence,
6
+ and iterates until root cause is proven with cited log lines. Use when the
7
+ user reports a bug, unexpected behavior, or asks to debug an issue.
8
+ ---
9
+
10
+ # Debug Mode
11
+
12
+ You are now in **DEBUG MODE**. You must debug with **runtime evidence**.
13
+
14
+ **Why this approach:** Traditional AI agents jump to fixes claiming 100% confidence, but fail due to lacking runtime information.
15
+ They guess based on code alone. You **cannot** and **must NOT** fix bugs this way — you need actual runtime data.
16
+
17
+ **Your systematic workflow:**
18
+
19
+ 1. **Generate 3-5 precise hypotheses** about WHY the bug occurs (be detailed, aim for MORE not fewer)
20
+ 2. **Instrument code** with logs (see Logging section) to test all hypotheses in parallel
21
+ 3. **Reproduce the bug.**
22
+ - **If a failing test already exists**: run it directly.
23
+ - **If reproduction is straightforward** (e.g., a single CLI command, a curl request, a simple script): write and run an ad hoc reproduction script yourself. Tailor it to the runtime — Playwright/Puppeteer for browser bugs, a Node/Python/shell script for backend bugs, etc.
24
+ - **Otherwise**: ask the user to reproduce it. Provide clear, numbered steps. Remind them to restart apps/services if instrumented files are cached or bundled. Offer: "If you'd like me to write a reproduction script instead, let me know."
25
+ - Once the user confirms a reproduction pathway (manual or automated), reuse it for all subsequent iterations without re-asking.
26
+ 4. **Analyze logs**: evaluate each hypothesis (CONFIRMED/REJECTED/INCONCLUSIVE) with cited log line evidence
27
+ 5. **Fix only with 100% confidence** and log proof; do NOT remove instrumentation yet
28
+ 6. **Verify with logs**: ask user to run again, compare before/after logs with cited entries
29
+ 7. **If logs prove success** and user confirms: remove all instrumentation by searching for `#region debug log` / `#endregion` markers and deleting those blocks (see Cleanup section). **If failed**: FIRST remove any code changes from rejected hypotheses (keep only instrumentation and proven fixes), THEN generate NEW hypotheses from different subsystems and add more instrumentation
30
+ 8. **After confirmed success**: explain the problem and provide a concise summary of the fix (1-2 lines)
31
+
32
+ **Critical constraints:**
33
+
34
+ - NEVER fix without runtime evidence first
35
+ - ALWAYS rely on runtime information + code (never code alone)
36
+ - Do NOT remove instrumentation before post-fix verification logs prove success and user confirms that there are no more issues
37
+ - Fixes often fail; iteration is expected and preferred. Taking longer with more data yields better, more precise fixes
38
+
39
+ ---
40
+
41
+ ## Logging
42
+
43
+ ### STEP 0: Start the logging server (MANDATORY BEFORE ANY INSTRUMENTATION)
44
+
45
+ Run the debug server in **daemon mode** before any instrumentation. The `--daemon` flag starts the server in the background and exits immediately with the server info — no backgrounding or `&` required.
46
+
47
+ ```bash
48
+ npx debug-agent --daemon
49
+ ```
50
+
51
+ The command prints a single JSON line to stdout and exits:
52
+
53
+ ```json
54
+ {
55
+ "sessionId": "a1b2c3",
56
+ "port": 54321,
57
+ "endpoint": "http://127.0.0.1:54321/ingest/a1b2c3",
58
+ "logPath": "/tmp/debug-agent/debug-a1b2c3.log"
59
+ }
60
+ ```
61
+
62
+ Capture and remember these values:
63
+
64
+ - **Server endpoint**: The `endpoint` value (the HTTP endpoint URL where logs will be sent via POST requests)
65
+ - **Log path**: The `logPath` value (NDJSON logs are written here)
66
+ - **Session ID**: The `sessionId` value (unique identifier for this debug session)
67
+
68
+ If the server fails to start, STOP IMMEDIATELY and inform the user.
69
+
70
+ - DO NOT PROCEED with instrumentation without valid logging configuration.
71
+ - The server is idempotent — if one is already running, it returns the existing server's info instead of starting a duplicate.
72
+ - You do not need to pre-create the log file; it will be created automatically when your instrumentation first writes to it.
73
+
74
+ ### STEP 1: Understand the log format
75
+
76
+ - Logs are written in **NDJSON format** (one JSON object per line) to the file specified by the **log path**.
77
+ - For JavaScript/TypeScript, logs are sent via a POST request to the **server endpoint** during runtime, and the logging server writes these as NDJSON lines to the **log path** file.
78
+ - For other languages (Python, Go, Rust, Java, C/C++, Ruby, etc.), you should prefer writing logs directly by appending NDJSON lines to the **log path** using the language's standard library file I/O.
79
+
80
+ Example log entry:
81
+
82
+ ```json
83
+ {
84
+ "sessionId": "a1b2c3",
85
+ "id": "log_1733456789_abc",
86
+ "timestamp": 1733456789000,
87
+ "location": "test.js:42",
88
+ "message": "User score",
89
+ "data": { "userId": 5, "score": 85 },
90
+ "runId": "run1",
91
+ "hypothesisId": "A"
92
+ }
93
+ ```
94
+
95
+ ### STEP 2: Insert instrumentation logs
96
+
97
+ - In **JavaScript/TypeScript files**, use this one-line fetch template (replace `ENDPOINT` and `SESSION_ID` with values from Step 0), even if filesystem access is available:
98
+
99
+ ```
100
+ fetch('ENDPOINT',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'SESSION_ID',location:'file.js:LINE',message:'desc',data:{k:v},timestamp:Date.now()})}).catch(()=>{});
101
+ ```
102
+
103
+ - In **non-JavaScript languages** (Python, Go, Rust, Java, C, C++, Ruby), instrument by opening the **log path** in append mode using standard library file I/O, writing a single NDJSON line with your payload, and then closing the file. Keep these snippets as tiny and compact as possible (ideally one line, or just a few).
104
+
105
+ - Decide how many instrumentation logs to insert based on the complexity of the code under investigation and the hypotheses you are testing. A single well-placed log may be enough when the issue is highly localized; complex multi-step flows may need more. Aim for the minimum number that can confirm or reject ALL your hypotheses. Guidelines:
106
+ - At least 1 log is required; never skip instrumentation entirely
107
+ - Do not exceed 10 logs — if you think you need more, narrow your hypotheses first
108
+ - Typical range is 2-6 logs, but use your judgment
109
+
110
+ - Choose log placements from these categories as relevant to your hypotheses:
111
+ - Function entry with parameters
112
+ - Function exit with return values
113
+ - Values BEFORE critical operations
114
+ - Values AFTER critical operations
115
+ - Branch execution paths (which if/else executed)
116
+ - Suspected error/edge case values
117
+ - State mutations and intermediate values
118
+
119
+ - Each log must map to at least one hypothesis (include `hypothesisId` in payload).
120
+ - Use this payload structure: `{sessionId, runId, hypothesisId, location, message, data, timestamp}`
121
+ - **REQUIRED:** Wrap EACH debug log in a collapsible code region:
122
+ - Use language-appropriate region syntax (e.g., `// #region debug log`, `// #endregion` for JS/TS)
123
+ - This keeps the editor clean by auto-folding debug instrumentation
124
+ - **FORBIDDEN:** Logging secrets (tokens, passwords, API keys, PII)
125
+
126
+ ### STEP 3: Clear previous log file before each run (MANDATORY)
127
+
128
+ - Send a `DELETE` request to the **server endpoint** to clear the log file before each run. For example: `curl -X DELETE ENDPOINT` (replace `ENDPOINT` with the endpoint value from Step 0).
129
+ - This ensures clean logs for the new run without mixing old and new data.
130
+ - Clearing the log file is NOT the same as removing instrumentation; do not remove any debug logs from code here.
131
+ - **CRITICAL:** Only clear YOUR session's logs (via your endpoint from Step 0). NEVER delete, modify, or overwrite log files belonging to other debug sessions.
132
+
133
+ ### STEP 4: Read logs after user runs the program
134
+
135
+ - After the user runs the program and confirms completion in their interface, do NOT ask them to type "done"; then use the file-read tool to read the file at the **log path**.
136
+ - The log file will contain NDJSON entries (one JSON object per line) from your instrumentation.
137
+ - Analyze these logs to evaluate your hypotheses and identify the root cause.
138
+ - If log file is empty or missing: tell user the reproduction may have failed and ask them to try again.
139
+
140
+ ### STEP 5: Keep logs during fixes
141
+
142
+ - When implementing a fix, DO NOT remove debug logs yet.
143
+ - Logs MUST remain active for verification runs.
144
+ - You may tag logs with `runId="post-fix"` to distinguish verification runs from initial debugging runs.
145
+ - FORBIDDEN: Removing or modifying any previously added logs in any files before post-fix verification logs are analyzed or the user explicitly confirms success.
146
+ - Only remove logs after a successful post-fix verification run (log-based proof) or explicit user request to remove.
147
+
148
+ ---
149
+
150
+ ## Critical Reminders (must follow)
151
+
152
+ - Keep instrumentation active during fixes; do not remove or modify logs until verification succeeds or the user explicitly confirms.
153
+ - FORBIDDEN: Using `setTimeout`, `sleep`, or artificial delays as a "fix"; use proper reactivity/events/lifecycles.
154
+ - FORBIDDEN: Removing instrumentation before analyzing post-fix verification logs or receiving explicit user confirmation.
155
+ - Verification requires before/after log comparison with cited log lines; do not claim success without log proof.
156
+ - Clear logs by sending a DELETE request to the server endpoint.
157
+ - Do not create the log file manually; it's created automatically.
158
+ - Clearing the log file is not removing instrumentation.
159
+ - NEVER delete or modify log files that do not belong to this session. Only touch the log file at the exact path from Step 0.
160
+ - Always try to rely on generating new hypotheses and using evidence from the logs to provide fixes.
161
+ - If all hypotheses are rejected, you MUST generate more and add more instrumentation accordingly.
162
+ - **Remove code changes from rejected hypotheses:** When logs prove a hypothesis wrong, revert the code changes made for that hypothesis. Do not let defensive guards, speculative fixes, or unproven changes accumulate. Only keep modifications that are supported by runtime evidence.
163
+ - Prefer reusing existing architecture, patterns, and utilities; avoid overengineering. Make fixes precise, targeted, and as small as possible while maximizing impact.
164
+
165
+ ## Cleanup
166
+
167
+ When it is time to remove instrumentation (after verified fix or user request):
168
+
169
+ 1. Search all files for `#region debug log` markers (e.g., grep/ripgrep for `#region debug log`)
170
+ 2. For each match, delete everything from the `#region debug log` line through its corresponding `#endregion` line (inclusive)
171
+ 3. Grep again to verify zero markers remain
172
+ 4. Run `git diff` to review all changes — confirm only your intentional fix remains and no stray debug code was missed
173
+
174
+ This is why wrapping every debug log in `#region debug log` / `#endregion` is mandatory — it enables deterministic cleanup.
175
+
176
+ ---
177
+
178
+ ## Server API reference
179
+
180
+ | Method | Effect |
181
+ | --------------------------- | ------------------------------------------- |
182
+ | `POST /ingest/:sessionId` | Append JSON body as NDJSON line to log file |
183
+ | `GET /ingest/:sessionId` | Read full log file contents |
184
+ | `DELETE /ingest/:sessionId` | Clear the log file |