context-mode 1.0.111 → 1.0.112

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.
Files changed (150) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.openclaw-plugin/index.ts +3 -2
  4. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  5. package/.openclaw-plugin/package.json +1 -1
  6. package/README.md +152 -34
  7. package/bin/statusline.mjs +144 -127
  8. package/build/adapters/base.d.ts +8 -5
  9. package/build/adapters/base.js +8 -18
  10. package/build/adapters/claude-code/index.d.ts +24 -3
  11. package/build/adapters/claude-code/index.js +44 -11
  12. package/build/adapters/codex/hooks.d.ts +10 -5
  13. package/build/adapters/codex/hooks.js +10 -5
  14. package/build/adapters/codex/index.d.ts +17 -5
  15. package/build/adapters/codex/index.js +337 -37
  16. package/build/adapters/codex/paths.d.ts +1 -0
  17. package/build/adapters/codex/paths.js +12 -0
  18. package/build/adapters/cursor/index.d.ts +6 -0
  19. package/build/adapters/cursor/index.js +83 -2
  20. package/build/adapters/detect.d.ts +1 -1
  21. package/build/adapters/detect.js +29 -6
  22. package/build/adapters/omp/index.d.ts +65 -0
  23. package/build/adapters/omp/index.js +182 -0
  24. package/build/adapters/omp/plugin.d.ts +75 -0
  25. package/build/adapters/omp/plugin.js +220 -0
  26. package/build/adapters/openclaw/mcp-tools.d.ts +54 -0
  27. package/build/adapters/openclaw/mcp-tools.js +198 -0
  28. package/build/adapters/openclaw/plugin.d.ts +130 -0
  29. package/build/adapters/openclaw/plugin.js +629 -0
  30. package/build/adapters/openclaw/workspace-router.d.ts +29 -0
  31. package/build/adapters/openclaw/workspace-router.js +64 -0
  32. package/build/adapters/opencode/plugin.d.ts +145 -0
  33. package/build/adapters/opencode/plugin.js +457 -0
  34. package/build/adapters/pi/extension.d.ts +26 -0
  35. package/build/adapters/pi/extension.js +552 -0
  36. package/build/adapters/pi/index.d.ts +57 -0
  37. package/build/adapters/pi/index.js +173 -0
  38. package/build/adapters/pi/mcp-bridge.d.ts +113 -0
  39. package/build/adapters/pi/mcp-bridge.js +251 -0
  40. package/build/adapters/types.d.ts +11 -6
  41. package/build/cli.js +186 -170
  42. package/build/db-base.d.ts +15 -2
  43. package/build/db-base.js +50 -5
  44. package/build/executor.d.ts +2 -0
  45. package/build/executor.js +15 -2
  46. package/build/runPool.d.ts +36 -0
  47. package/build/runPool.js +51 -0
  48. package/build/runtime.js +64 -5
  49. package/build/search/auto-memory.js +6 -4
  50. package/build/security.js +30 -10
  51. package/build/server.d.ts +23 -1
  52. package/build/server.js +652 -174
  53. package/build/session/analytics.d.ts +404 -1
  54. package/build/session/analytics.js +1347 -42
  55. package/build/session/db.d.ts +114 -5
  56. package/build/session/db.js +275 -27
  57. package/build/session/event-emit.d.ts +48 -0
  58. package/build/session/event-emit.js +101 -0
  59. package/build/session/extract.d.ts +1 -0
  60. package/build/session/extract.js +79 -12
  61. package/build/session/purge.d.ts +111 -0
  62. package/build/session/purge.js +138 -0
  63. package/build/store.d.ts +7 -0
  64. package/build/store.js +69 -6
  65. package/build/util/claude-config.d.ts +26 -0
  66. package/build/util/claude-config.js +91 -0
  67. package/build/util/hook-config.d.ts +4 -0
  68. package/build/util/hook-config.js +39 -0
  69. package/cli.bundle.mjs +411 -208
  70. package/configs/antigravity/GEMINI.md +0 -3
  71. package/configs/claude-code/CLAUDE.md +1 -4
  72. package/configs/codex/AGENTS.md +1 -4
  73. package/configs/codex/config.toml +3 -0
  74. package/configs/codex/hooks.json +8 -0
  75. package/configs/cursor/context-mode.mdc +0 -3
  76. package/configs/gemini-cli/GEMINI.md +0 -3
  77. package/configs/jetbrains-copilot/copilot-instructions.md +0 -3
  78. package/configs/kilo/AGENTS.md +0 -3
  79. package/configs/kiro/KIRO.md +0 -3
  80. package/configs/omp/SYSTEM.md +85 -0
  81. package/configs/omp/mcp.json +7 -0
  82. package/configs/openclaw/AGENTS.md +0 -3
  83. package/configs/opencode/AGENTS.md +0 -3
  84. package/configs/pi/AGENTS.md +0 -3
  85. package/configs/qwen-code/QWEN.md +1 -4
  86. package/configs/vscode-copilot/copilot-instructions.md +0 -3
  87. package/configs/zed/AGENTS.md +0 -3
  88. package/hooks/codex/posttooluse.mjs +9 -2
  89. package/hooks/codex/precompact.mjs +69 -0
  90. package/hooks/codex/sessionstart.mjs +13 -9
  91. package/hooks/codex/stop.mjs +1 -2
  92. package/hooks/codex/userpromptsubmit.mjs +1 -2
  93. package/hooks/core/routing.mjs +237 -18
  94. package/hooks/cursor/afteragentresponse.mjs +1 -1
  95. package/hooks/cursor/hooks.json +31 -0
  96. package/hooks/cursor/posttooluse.mjs +1 -1
  97. package/hooks/cursor/sessionstart.mjs +5 -5
  98. package/hooks/cursor/stop.mjs +1 -1
  99. package/hooks/ensure-deps.mjs +12 -13
  100. package/hooks/gemini-cli/aftertool.mjs +1 -1
  101. package/hooks/gemini-cli/beforeagent.mjs +1 -1
  102. package/hooks/gemini-cli/precompress.mjs +3 -2
  103. package/hooks/gemini-cli/sessionstart.mjs +9 -9
  104. package/hooks/jetbrains-copilot/posttooluse.mjs +1 -1
  105. package/hooks/jetbrains-copilot/precompact.mjs +3 -2
  106. package/hooks/jetbrains-copilot/sessionstart.mjs +9 -9
  107. package/hooks/kiro/agentspawn.mjs +5 -5
  108. package/hooks/kiro/posttooluse.mjs +2 -2
  109. package/hooks/kiro/userpromptsubmit.mjs +1 -1
  110. package/hooks/posttooluse.mjs +45 -0
  111. package/hooks/precompact.mjs +17 -0
  112. package/hooks/pretooluse.mjs +23 -0
  113. package/hooks/routing-block.mjs +0 -12
  114. package/hooks/run-hook.mjs +16 -3
  115. package/hooks/session-db.bundle.mjs +27 -18
  116. package/hooks/session-extract.bundle.mjs +2 -2
  117. package/hooks/session-helpers.mjs +101 -64
  118. package/hooks/sessionstart.mjs +51 -2
  119. package/hooks/vscode-copilot/posttooluse.mjs +1 -1
  120. package/hooks/vscode-copilot/precompact.mjs +3 -2
  121. package/hooks/vscode-copilot/sessionstart.mjs +9 -9
  122. package/openclaw.plugin.json +1 -1
  123. package/package.json +14 -8
  124. package/server.bundle.mjs +349 -147
  125. package/skills/UPSTREAM-CREDITS.md +0 -51
  126. package/skills/context-mode-ops/SKILL.md +0 -299
  127. package/skills/context-mode-ops/agent-teams.md +0 -198
  128. package/skills/context-mode-ops/communication.md +0 -224
  129. package/skills/context-mode-ops/marketing.md +0 -124
  130. package/skills/context-mode-ops/release.md +0 -214
  131. package/skills/context-mode-ops/review-pr.md +0 -269
  132. package/skills/context-mode-ops/tdd.md +0 -329
  133. package/skills/context-mode-ops/triage-issue.md +0 -266
  134. package/skills/context-mode-ops/validation.md +0 -307
  135. package/skills/diagnose/SKILL.md +0 -122
  136. package/skills/diagnose/scripts/hitl-loop.template.sh +0 -41
  137. package/skills/grill-me/SKILL.md +0 -15
  138. package/skills/grill-with-docs/ADR-FORMAT.md +0 -47
  139. package/skills/grill-with-docs/CONTEXT-FORMAT.md +0 -77
  140. package/skills/grill-with-docs/SKILL.md +0 -93
  141. package/skills/improve-codebase-architecture/DEEPENING.md +0 -37
  142. package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +0 -44
  143. package/skills/improve-codebase-architecture/LANGUAGE.md +0 -53
  144. package/skills/improve-codebase-architecture/SKILL.md +0 -76
  145. package/skills/tdd/SKILL.md +0 -114
  146. package/skills/tdd/deep-modules.md +0 -33
  147. package/skills/tdd/interface-design.md +0 -31
  148. package/skills/tdd/mocking.md +0 -59
  149. package/skills/tdd/refactoring.md +0 -10
  150. package/skills/tdd/tests.md +0 -61
@@ -1,266 +0,0 @@
1
- # Triage Issue Workflow
2
-
3
- ## Trigger
4
-
5
- User says: "triage issue #N", "fix issue #N", "analyze issue #N"
6
-
7
- ## Step-by-Step
8
-
9
- ### 1. Gather Intelligence (ONE batch call)
10
-
11
- Use `ctx_batch_execute` to gather everything in ONE call:
12
-
13
- ```javascript
14
- commands: [
15
- { label: "issue-body", command: "gh issue view {N} --json title,body,labels,state,comments,author,createdAt" },
16
- { label: "issue-comments", command: "gh issue view {N} --comments" },
17
- { label: "recent-related-prs", command: "gh pr list --state all --limit 10 --json number,title,state,headRefName" },
18
- { label: "source-tree", command: "find src -type f -name '*.ts' | sort" },
19
- { label: "test-tree", command: "find tests -type f -name '*.test.ts' | sort" },
20
- { label: "open-issues", command: "gh issue list --state open --limit 20 --json number,title,labels" }
21
- ],
22
- queries: [
23
- "issue title description problem",
24
- "affected adapter platform",
25
- "error message stack trace",
26
- "environment variables mentioned",
27
- "OS platform specific",
28
- "related PRs and issues"
29
- ]
30
- ```
31
-
32
- ### 2. Classify Domains
33
-
34
- From the gathered intelligence, identify:
35
-
36
- - [ ] **Affected adapters** — which of the 12 platforms?
37
- - [ ] **Affected OS** — macOS, Linux, Windows, or all?
38
- - [ ] **Core modules** — server, store, executor, session, hooks?
39
- - [ ] **Issue type** — bug, feature request, question, discussion?
40
- - [ ] **Severity** — breaking (can't use tool), degraded (works but wrong), cosmetic
41
-
42
- ### 3. Spawn Agent Army
43
-
44
- Based on classification, spawn from [agent-teams.md](agent-teams.md):
45
-
46
- ```
47
- ALWAYS spawn:
48
- ├── Context Mode Architect (reviews everything)
49
- ├── QA Engineer (runs all tests)
50
- ├── DX Engineer (checks user-facing quality)
51
-
52
- IF adapter X is affected:
53
- ├── {X} Architect
54
- ├── {X} Staff Engineer
55
-
56
- IF OS-specific:
57
- ├── OS Compatibility Architect
58
- ├── {macOS|Linux|Windows} Staff Engineer
59
-
60
- IF domain-specific:
61
- ├── {Domain} Architect
62
- └── (Staff Engineer if code changes needed)
63
- ```
64
-
65
- **Example: Issue #208 "CLI upgrade full support for Opencode/Kilocode"**
66
- ```
67
- Agents to spawn:
68
- 1. Context Mode Architect
69
- 2. QA Engineer
70
- 3. DX Engineer
71
- 4. OpenCode Architect
72
- 5. OpenCode Staff Engineer
73
- 6. Kilo Architect
74
- 7. Kilo Staff Engineer
75
- 8. Hooks Architect (CLI upgrade touches hooks)
76
- 9. OS Compatibility Architect (CLI runs on all OS)
77
- ```
78
-
79
- ### 4. Claim Verification — BLOCKING GATE
80
-
81
- <claim_verification_enforcement>
82
- STOP. Before ANY agent writes implementation code, the claim in the issue MUST be verified
83
- with hard evidence. We shipped inheritEnvKeys because an LLM said Claude Code strips env vars
84
- — it doesn't. We got burned shipping a fix for an unverified claim. Never again.
85
- </claim_verification_enforcement>
86
-
87
- **Every issue makes a claim. Verify it BEFORE coding.**
88
-
89
- | Issue Type | Required Evidence | How to Get It |
90
- |------------|-------------------|---------------|
91
- | **Bug report** | Reproduce locally with a failing test or command | Run the exact steps from the report. If it doesn't fail, the bug may not exist. |
92
- | **Feature request claiming behavior X** | Prove behavior X actually happens | Check official docs, source code, or web search. NOT LLM knowledge — LLMs hallucinate platform behavior. |
93
- | **Feature request claiming perf issue** | Benchmark the actual impact | Measure before/after. No "it should be faster" — show numbers. |
94
- | **"Tool X sets env var Y"** | Find it in official source | `ctx_fetch_and_index` the platform's docs/source. Grep their repo. If you can't find it, it probably doesn't exist. |
95
-
96
- **Verification Steps:**
97
-
98
- 1. **Architect agents** must produce a `CLAIM_VERDICT` before any Staff Engineer writes code:
99
- ```
100
- CLAIM: "{exact claim from the issue}"
101
- EVIDENCE: {link to official doc, source file, or reproduction output}
102
- VERDICT: CONFIRMED | UNCONFIRMED | HALLUCINATED
103
- ```
104
-
105
- 2. If `VERDICT: UNCONFIRMED` — do NOT implement. Instead, comment on the issue:
106
- ```
107
- We couldn't reproduce/verify this claim. Could you provide:
108
- - Debug output from: npx context-mode doctor (or ctx-debug.sh)
109
- - Exact steps to reproduce
110
- - Platform version and OS
111
-
112
- We want to fix this but need to confirm the problem exists first.
113
- ```
114
-
115
- 3. If `VERDICT: HALLUCINATED` — the reporter (or their LLM) made up a behavior that doesn't exist. Comment kindly explaining the misunderstanding. Close with "working as intended" if appropriate.
116
-
117
- 4. Only `VERDICT: CONFIRMED` proceeds to the Investigation Phase below.
118
-
119
- **The `ctx-debug.sh` script exists for exactly this purpose.** When in doubt, ask the reporter to run it and paste the output.
120
-
121
- ### 5. Investigation Phase (Parallel)
122
-
123
- All agents investigate simultaneously:
124
-
125
- **Architects** research:
126
- - Read relevant source files
127
- - Check if claimed behavior actually exists
128
- - Validate ENV vars against real platform docs (use WebSearch + Context7)
129
- - Review related closed issues for prior art
130
- - Report: FINDINGS with specific file:line references
131
-
132
- **Staff Engineers** prepare (TDD-first per [tdd.md](tdd.md)):
133
- - Read the code that needs changing
134
- - **RED**: Write a failing test that reproduces the bug / specifies new behavior
135
- - Run test — verify it **FAILS** (if it passes, the test is useless)
136
- - **GREEN**: Write minimal code to make the test pass
137
- - Run test — verify it **PASSES**
138
- - **REFACTOR**: Clean up while keeping tests green
139
- - Repeat for each behavior (vertical slices, never horizontal)
140
- - Run full affected adapter tests
141
- - Report: DRAFT_FIX with RED→GREEN evidence for each behavior
142
-
143
- ### 6. Ping-Pong Review
144
-
145
- Route Staff Engineer outputs to their paired Architects:
146
-
147
- ```
148
- EM reads Staff Engineer result
149
- → Sends to Architect via Agent(SendMessage)
150
- → Architect reviews: APPROVED or CHANGES_NEEDED
151
- → If CHANGES_NEEDED: route back to Staff Engineer
152
- → Max 2 rounds, then EM decides
153
- ```
154
-
155
- ### 7. Validate (QA Engineer)
156
-
157
- QA Engineer runs the full validation matrix:
158
-
159
- ```shell
160
- # All adapter tests
161
- npx vitest run tests/adapters/
162
-
163
- # Core tests
164
- npx vitest run tests/core/
165
-
166
- # Full suite
167
- npm test
168
-
169
- # TypeScript
170
- npm run typecheck
171
- ```
172
-
173
- Report as a matrix:
174
-
175
- ```
176
- Adapter Tests:
177
- ✓ claude-code ✓ gemini-cli ✓ opencode
178
- ✓ openclaw ✓ kilo ✓ codex
179
- ✓ vscode-copilot ✓ cursor ✓ antigravity
180
- ✓ kiro ✓ pi ✓ zed
181
-
182
- Core Tests: ✓ routing ✓ search ✓ server ✓ cli
183
- TypeScript: ✓ no errors
184
- Full Suite: ✓ 47/47 passed
185
- ```
186
-
187
- ### 8. Push Directly to `next`
188
-
189
- **Do NOT open a PR.** Push fixes directly to the `next` branch:
190
-
191
- ```bash
192
- # Ensure we're on next
193
- git checkout next
194
- git pull origin next
195
-
196
- # Apply changes from worktree agents
197
- # ... (merge worktree changes)
198
-
199
- # Commit with issue reference
200
- git commit -m "fix: {concise description} (closes #{N})
201
-
202
- - {what was broken}
203
- - {what was fixed}
204
- - {which adapters/modules affected}
205
-
206
- Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>"
207
-
208
- # Push to next
209
- git push origin next
210
- ```
211
-
212
- ### 9. Comment on Issue & Close
213
-
214
- After pushing to `next`, comment and **close the issue immediately**:
215
-
216
- ```bash
217
- gh issue comment {N} --body "$(cat <<'EOF'
218
- Hey @{author}! 👋
219
-
220
- We investigated this and pushed a fix to the `next` branch ({commit_sha}).
221
-
222
- **What was happening:** {technical explanation of the root cause}
223
-
224
- **What we fixed:** {technical explanation of the fix}
225
-
226
- **Affected area:** {adapter/module names}
227
-
228
- This will ship in the next release. Once it's out, could you please test it in your setup and let us know if it resolves the issue? 🙏
229
-
230
- If the fix doesn't work for you, feel free to reopen this issue.
231
-
232
- Thanks for reporting this!
233
- EOF
234
- )"
235
-
236
- # Close the issue — fix is pushed, job done
237
- gh issue close {N}
238
- ```
239
-
240
- ## Decision Tree: Fix vs. Wontfix vs. Needs Info
241
-
242
- ```
243
- Issue makes a claim about platform behavior?
244
- ├── YES → Run Claim Verification (Step 4) FIRST
245
- │ ├── CONFIRMED → Fix it (steps 5-9 above)
246
- │ ├── UNCONFIRMED → Request evidence (ctx-debug.sh output, repro steps)
247
- │ └── HALLUCINATED → Explain kindly, close if appropriate
248
-
249
- Issue is clear and reproducible (no behavioral claim)?
250
- ├── YES → Fix it (steps 5-9 above)
251
- ├── UNCLEAR → Comment asking for reproduction steps
252
- │ └── Template: "Could you share the exact command/config that triggers this?"
253
- └── BY DESIGN → Explain why, close with "working as intended" label
254
- └── Be kind — explain the design decision
255
- ```
256
-
257
- ## Edge Cases
258
-
259
- ### Issue references a feature that doesn't exist
260
- The issue author may have been told by an LLM that a feature exists when it doesn't. Use [validation.md](validation.md) ENV verification to catch this. Comment explaining the misunderstanding kindly.
261
-
262
- ### Issue is a duplicate
263
- Link to the original issue, close as duplicate, thank the reporter.
264
-
265
- ### Issue is actually a feature request
266
- Re-label, add to backlog discussion, don't close — let the community weigh in.
@@ -1,307 +0,0 @@
1
- # Validation Patterns
2
-
3
- Cross-cutting validation rules used by ALL workflows (triage, review, release).
4
-
5
- ## Problem Verification — FIRST GATE
6
-
7
- <problem_verification_enforcement>
8
- This is the FIRST validation step, before anything else. We shipped inheritEnvKeys because
9
- we trusted an LLM claim that Claude Code strips environment variables — it does not.
10
- We got burned shipping a fix for an unverified claim. Never again.
11
- Every bug report, feature request, and behavioral claim MUST be proven true before code is written.
12
- </problem_verification_enforcement>
13
-
14
- ### For Bug Reports
15
-
16
- **Reproduce it or reject it.** Run the exact reproduction steps from the issue. If it doesn't fail, the bug may not exist.
17
-
18
- ```
19
- Step 1: Extract the claimed reproduction steps from the issue
20
- Step 2: Run them locally (use ctx_execute or a test)
21
- Step 3: Record the ACTUAL output
22
- Step 4: Compare actual vs. claimed behavior
23
- Step 5: VERDICT:
24
- → REPRODUCED: Bug is real, proceed to fix
25
- → NOT_REPRODUCED: Ask reporter for ctx-debug.sh output and exact repro steps
26
- → INVALID: Reporter's environment is misconfigured, help them fix it
27
- ```
28
-
29
- ### For Feature Requests
30
-
31
- **Verify the underlying claim.** Feature requests always contain an implicit claim ("X behaves this way", "Y is slow", "Z doesn't support W"). Prove the claim first.
32
-
33
- ```
34
- Step 1: Identify the claim (e.g., "Claude Code strips env vars from child processes")
35
- Step 2: Find HARD EVIDENCE — official docs, source code, or measured benchmarks
36
- → Use ctx_fetch_and_index on official docs/repos
37
- → Use ctx_execute to run actual tests
38
- → NEVER trust LLM knowledge about platform behavior — LLMs hallucinate this constantly
39
- Step 3: VERDICT:
40
- → CONFIRMED: Claim is true, proceed to design
41
- → UNCONFIRMED: Cannot verify — ask reporter for evidence before implementing
42
- → DEBUNKED: Claim is false — comment on issue explaining the misunderstanding
43
- ```
44
-
45
- ### Requesting Evidence from Reporters
46
-
47
- When a claim cannot be verified, comment on the issue BEFORE implementing:
48
-
49
- ```markdown
50
- We want to address this but need to verify the underlying behavior first.
51
- Could you provide:
52
- 1. Output from: `npx context-mode doctor` (or run `ctx-debug.sh`)
53
- 2. Exact reproduction steps
54
- 3. Platform version, adapter, and OS
55
-
56
- We'll investigate as soon as we can confirm the issue. Thanks for reporting!
57
- ```
58
-
59
- ### Evidence Log
60
-
61
- Every triage MUST produce a verification entry:
62
-
63
- ```
64
- CLAIM: "{exact claim}"
65
- SOURCE: {issue number or PR}
66
- EVIDENCE: {link to doc, test output, or benchmark result}
67
- VERDICT: CONFIRMED | UNCONFIRMED | DEBUNKED
68
- ACTION: {proceed | request-info | close-as-invalid}
69
- ```
70
-
71
- ---
72
-
73
- ## ENV Variable Verification
74
-
75
- LLMs frequently hallucinate environment variables. Every ENV var in an issue or PR must be verified.
76
-
77
- ### Verification Protocol
78
-
79
- For EACH environment variable mentioned:
80
-
81
- ```
82
- Step 1: GREP — Does it exist in context-mode source?
83
- → rg "{ENV_VAR}" src/
84
- → If found: VERIFIED (we already use it)
85
- → If not found: continue to Step 2
86
-
87
- Step 2: GREP ADAPTERS — Is it in the adapter detect logic?
88
- → Read src/adapters/detect.ts
89
- → Check the verified env vars comment block at the top
90
- → If listed: VERIFIED (we know about it)
91
-
92
- Step 3: WEBSEARCH — Does the platform document it?
93
- → WebSearch: "{PLATFORM} {ENV_VAR} environment variable"
94
- → Check official docs, GitHub repos, release notes
95
- → If found in official source: REAL but we don't use it yet
96
-
97
- Step 4: CONTEXT7 — Library documentation check
98
- → resolve-library-id for the platform
99
- → query-docs for the ENV var
100
- → Cross-reference with Step 3
101
-
102
- Step 5: VERDICT
103
- → VERIFIED: We use it and it's real
104
- → REAL_NEW: Platform has it but we don't use it yet
105
- → HALLUCINATED: No evidence it exists — flag it
106
- → DEPRECATED: Used to exist but was removed
107
- ```
108
-
109
- ### Known Verified ENV Vars (Reference)
110
-
111
- | Platform | Verified ENV Vars | Source |
112
- |----------|------------------|--------|
113
- | Claude Code | `CLAUDE_PROJECT_DIR`, `CLAUDE_SESSION_ID` | src/adapters/detect.ts |
114
- | Gemini CLI | `GEMINI_PROJECT_DIR`, `GEMINI_CLI` | src/adapters/detect.ts |
115
- | OpenCode | `OPENCODE`, `OPENCODE_PID` | src/adapters/detect.ts |
116
- | OpenClaw | `OPENCLAW_HOME`, `OPENCLAW_CLI` | src/adapters/detect.ts |
117
- | Kilo | `KILO`, `KILO_PID` | src/adapters/detect.ts |
118
- | Codex | `CODEX_CI`, `CODEX_THREAD_ID` | src/adapters/detect.ts |
119
- | VS Code Copilot | `VSCODE_PID`, `VSCODE_CWD` | src/adapters/detect.ts |
120
- | Cursor | `CURSOR_TRACE_ID`, `CURSOR_CLI` | src/adapters/detect.ts |
121
- | Override | `CONTEXT_MODE_PLATFORM` | src/adapters/detect.ts |
122
-
123
- Any ENV var NOT in this table must go through the full verification protocol.
124
-
125
- ## Adapter Test Matrix
126
-
127
- ### Full Matrix Run
128
-
129
- ```shell
130
- # Run ALL adapter tests
131
- npx vitest run tests/adapters/
132
-
133
- # Individual adapter (for targeted testing)
134
- npx vitest run tests/adapters/claude-code.test.ts
135
- npx vitest run tests/adapters/gemini-cli.test.ts
136
- npx vitest run tests/adapters/opencode.test.ts
137
- npx vitest run tests/adapters/openclaw.test.ts
138
- npx vitest run tests/adapters/kilo.test.ts
139
- npx vitest run tests/adapters/codex.test.ts
140
- npx vitest run tests/adapters/vscode-copilot.test.ts
141
- npx vitest run tests/adapters/cursor.test.ts
142
- npx vitest run tests/adapters/antigravity.test.ts
143
- npx vitest run tests/adapters/kiro.test.ts
144
- npx vitest run tests/adapters/zed.test.ts
145
-
146
- # Detection logic
147
- npx vitest run tests/adapters/detect.test.ts
148
- npx vitest run tests/adapters/client-map.test.ts
149
- ```
150
-
151
- ### Report Format
152
-
153
- ```
154
- ADAPTER TEST MATRIX
155
- ═══════════════════
156
- claude-code ✓ 5/5 gemini-cli ✓ 4/4
157
- opencode ✓ 6/6 openclaw ✓ 3/3
158
- kilo ✓ 4/4 codex ✓ 3/3
159
- vscode-copilot ✓ 4/4 cursor ✓ 3/3
160
- antigravity ✓ 2/2 kiro ✓ 3/3
161
- pi ✓ 2/2 zed ✓ 2/2
162
- detect ✓ 8/8 client-map ✓ 6/6
163
- ───────────────────────────────────────────
164
- TOTAL: {N}/{N} passed | 0 failed
165
- ```
166
-
167
- ## Core Module Tests
168
-
169
- ```shell
170
- # Core tests
171
- npx vitest run tests/core/routing.test.ts
172
- npx vitest run tests/core/search.test.ts
173
- npx vitest run tests/core/server.test.ts
174
- npx vitest run tests/core/cli.test.ts
175
-
176
- # Module tests
177
- npx vitest run tests/store.test.ts
178
- npx vitest run tests/executor.test.ts
179
- npx vitest run tests/security.test.ts
180
- npx vitest run tests/formatters.test.ts
181
-
182
- # Hook tests
183
- npx vitest run tests/hooks/
184
-
185
- # Full suite
186
- npm test
187
- ```
188
-
189
- ## OS Compatibility Checks
190
-
191
- ### Path Handling
192
-
193
- ```javascript
194
- // WRONG — breaks on Windows
195
- const configPath = homedir + "/.config/opencode/config.json";
196
-
197
- // CORRECT — works everywhere
198
- const configPath = path.join(homedir(), ".config", "opencode", "config.json");
199
- ```
200
-
201
- Grep for potential issues:
202
- ```shell
203
- # String concatenation with path separators
204
- rg "homedir\(\)\s*\+" src/
205
- rg '"/\.' src/
206
- rg "'\\./" src/
207
-
208
- # Direct slash usage in paths (should use path.join)
209
- rg 'path\s*=.*"/' src/ --type ts
210
- ```
211
-
212
- ### Temp Directory
213
-
214
- ```javascript
215
- // WRONG — hardcoded /tmp
216
- const tmpFile = "/tmp/context-mode-output.txt";
217
-
218
- // CORRECT — uses OS temp dir
219
- const tmpFile = path.join(os.tmpdir(), "context-mode-output.txt");
220
- ```
221
-
222
- Grep for hardcoded temp:
223
- ```shell
224
- rg '"/tmp/' src/
225
- rg "'/tmp/" src/
226
- ```
227
-
228
- ### Native Bindings (better-sqlite3)
229
-
230
- Check that `better-sqlite3` is in `optionalDependencies` (not `dependencies`) and the code handles the case where it's not available:
231
-
232
- ```shell
233
- rg "better-sqlite3" src/ --type ts
234
- rg "optionalDependencies" package.json
235
- ```
236
-
237
- ### Process Spawn
238
-
239
- ```javascript
240
- // WRONG — shell: true behaves differently on Windows
241
- spawn("command", { shell: true });
242
-
243
- // CORRECT — explicit shell selection
244
- spawn("command", { shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh" });
245
- ```
246
-
247
- ## Hook Format Validation
248
-
249
- Each platform has different hook formats. Verify changes match:
250
-
251
- | Platform | Hook Format | Key Differences |
252
- |----------|------------|-----------------|
253
- | Claude Code | `hooks.json` in plugin dir | `PreToolUse`, `PostToolUse`, `PreCompact`, `SessionStart` |
254
- | Gemini CLI | `~/.gemini/settings.json` | `BeforeTool`, `AfterTool`, `PreCompress`, `SessionStart` + `matcher` |
255
- | VS Code Copilot | `.github/hooks/*.json` | Same as Claude Code but separate file |
256
- | Cursor | `.cursor/hooks.json` | No `SessionStart` (injects via file instead) |
257
- | OpenCode | `opencode.json` | Uses `agents` section, not traditional hooks |
258
- | OpenClaw | `openclaw.plugin.json` | Extension model, not hook-based |
259
-
260
- ## Security Checks
261
-
262
- ### Sandbox Escape
263
-
264
- ```shell
265
- # File writing attempts through ctx_execute
266
- rg "writeFile\|appendFile\|createWriteStream" src/executor.ts
267
-
268
- # Path traversal
269
- rg "\.\.\/" src/ --type ts
270
-
271
- # Command injection vectors
272
- rg "exec\(.*\$\{" src/ --type ts
273
- rg "spawn\(.*\$\{" src/ --type ts
274
- ```
275
-
276
- ### Information Disclosure
277
-
278
- ```shell
279
- # Sensitive paths
280
- rg "process\.env\b" src/ --type ts | grep -v "test"
281
-
282
- # Home directory exposure
283
- rg "homedir\(\)" src/ --type ts
284
- ```
285
-
286
- ## TypeScript Validation
287
-
288
- ```bash
289
- # Full type check
290
- npm run typecheck
291
-
292
- # Should report 0 errors
293
- # If errors exist, they MUST be fixed before shipping
294
- ```
295
-
296
- ## Pre-Ship Checklist
297
-
298
- Every change, regardless of workflow, must pass:
299
-
300
- - [ ] **Problem verified** — CLAIM_VERDICT is CONFIRMED with hard evidence (this is gate zero)
301
- - [ ] `npm run typecheck` — 0 errors
302
- - [ ] `npm test` — all pass
303
- - [ ] Adapter tests — all 12 pass (or N/A if untouched)
304
- - [ ] ENV vars — all verified against real platform source
305
- - [ ] Path handling — no hardcoded separators
306
- - [ ] Hook format — matches target platform's schema
307
- - [ ] No security regressions
@@ -1,122 +0,0 @@
1
- ---
2
- name: diagnose
3
- description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
4
- ---
5
-
6
- # Diagnose
7
-
8
- A discipline for hard bugs. Skip phases only when explicitly justified.
9
-
10
- When exploring the codebase, use the project's domain glossary to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
11
-
12
- ## Phase 1 — Build a feedback loop
13
-
14
- **This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
15
-
16
- Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
17
-
18
- ### Ways to construct one — try them in roughly this order
19
-
20
- 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
21
- 2. **Curl / HTTP script** against a running dev server.
22
- 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
23
- 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
24
- 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
25
- 6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
26
- 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
27
- 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
28
- 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
29
- 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
30
-
31
- Build the right feedback loop, and the bug is 90% fixed.
32
-
33
- ### Iterate on the loop itself
34
-
35
- Treat the loop as a product. Once you have _a_ loop, ask:
36
-
37
- - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
38
- - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
39
- - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
40
-
41
- A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
42
-
43
- ### Non-deterministic bugs
44
-
45
- The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
46
-
47
- ### When you genuinely cannot build a loop
48
-
49
- Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
50
-
51
- Do not proceed to Phase 2 until you have a loop you believe in.
52
-
53
- ## Phase 2 — Reproduce
54
-
55
- Run the loop. Watch the bug appear.
56
-
57
- Confirm:
58
-
59
- - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
60
- - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
61
- - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
62
-
63
- Do not proceed until you reproduce the bug.
64
-
65
- ## Phase 3 — Hypothesise
66
-
67
- Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
68
-
69
- Each hypothesis must be **falsifiable**: state the prediction it makes.
70
-
71
- > Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
72
-
73
- If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
74
-
75
- **Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
76
-
77
- ## Phase 4 — Instrument
78
-
79
- Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
80
-
81
- Tool preference:
82
-
83
- 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
84
- 2. **Targeted logs** at the boundaries that distinguish hypotheses.
85
- 3. Never "log everything and grep".
86
-
87
- **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
88
-
89
- **Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
90
-
91
- ## Phase 5 — Fix + regression test
92
-
93
- Write the regression test **before the fix** — but only if there is a **correct seam** for it.
94
-
95
- A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
96
-
97
- **If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
98
-
99
- If a correct seam exists:
100
-
101
- 1. Turn the minimised repro into a failing test at that seam.
102
- 2. Watch it fail.
103
- 3. Apply the fix.
104
- 4. Watch it pass.
105
- 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
106
-
107
- ## Phase 6 — Cleanup + post-mortem
108
-
109
- Required before declaring done:
110
-
111
- - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
112
- - [ ] Regression test passes (or absence of seam is documented)
113
- - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
114
- - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
115
- - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
116
-
117
- **Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
118
-
119
-
120
- ---
121
-
122
- _Vendored from [mattpocock/skills](https://github.com/mattpocock/skills) @ `b843cb5` — MIT License. See [skills/UPSTREAM-CREDITS.md](../UPSTREAM-CREDITS.md) for refresh instructions._