@drafthq/draft 3.5.3 → 3.7.1

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 (143) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/hosts/cursor.js +3 -0
  7. package/cli/src/installer.js +8 -4
  8. package/cli/src/lib/cursor-registry.js +10 -0
  9. package/cli/src/lib/fsx.js +3 -0
  10. package/cli/src/lib/marker.js +8 -3
  11. package/core/agents/architect.md +21 -9
  12. package/core/agents/debugger.md +5 -0
  13. package/core/agents/ops.md +7 -2
  14. package/core/agents/planner.md +7 -0
  15. package/core/agents/rca.md +14 -3
  16. package/core/agents/reviewer.md +1 -0
  17. package/core/agents/writer.md +6 -0
  18. package/core/knowledge-base.md +22 -3
  19. package/core/methodology.md +30 -5
  20. package/core/shared/condensation.md +28 -18
  21. package/core/shared/context-verify.md +3 -1
  22. package/core/shared/cross-skill-dispatch.md +7 -3
  23. package/core/shared/draft-context-loading.md +3 -0
  24. package/core/shared/git-report-metadata.md +2 -1
  25. package/core/shared/graph-query.md +24 -26
  26. package/core/shared/graph-usage-report.md +1 -1
  27. package/core/shared/jira-sync.md +10 -6
  28. package/core/shared/okf-retrieval.md +1 -1
  29. package/core/shared/parallel-analysis.md +14 -7
  30. package/core/shared/pattern-learning.md +2 -0
  31. package/core/shared/template-contract.md +1 -1
  32. package/core/shared/tool-resolver.md +20 -15
  33. package/core/shared/vcs-commands.md +5 -2
  34. package/core/templates/ai-context.md +3 -2
  35. package/core/templates/ai-profile.md +7 -0
  36. package/core/templates/architecture.md +6 -2
  37. package/core/templates/discovery.md +1 -1
  38. package/core/templates/guardrails.md +9 -0
  39. package/core/templates/hld.md +5 -4
  40. package/core/templates/intake-questions.md +45 -0
  41. package/core/templates/jira.md +11 -2
  42. package/core/templates/lld.md +8 -5
  43. package/core/templates/okf/concept.md +0 -1
  44. package/core/templates/plan.md +1 -1
  45. package/core/templates/product.md +11 -2
  46. package/core/templates/rca.md +6 -0
  47. package/core/templates/service-index.md +1 -0
  48. package/core/templates/spec.md +15 -0
  49. package/core/templates/tech-stack.md +12 -0
  50. package/core/templates/workflow.md +20 -0
  51. package/integrations/agents/AGENTS.md +1449 -817
  52. package/integrations/copilot/.github/copilot-instructions.md +1449 -817
  53. package/package.json +1 -1
  54. package/scripts/fetch-memory-engine.sh +25 -7
  55. package/scripts/lib.sh +90 -6
  56. package/scripts/tools/_graph_queries.sh +22 -8
  57. package/scripts/tools/_lib.sh +81 -11
  58. package/scripts/tools/adr-index.sh +1 -1
  59. package/scripts/tools/check-repo-size.sh +125 -0
  60. package/scripts/tools/check-skill-line-caps.sh +3 -4
  61. package/scripts/tools/check-template-noop.sh +0 -1
  62. package/scripts/tools/check-track-hygiene.sh +41 -21
  63. package/scripts/tools/classify-files.sh +3 -3
  64. package/scripts/tools/cycle-detect.sh +18 -17
  65. package/scripts/tools/detect-test-framework.sh +1 -1
  66. package/scripts/tools/emit-skill-metrics.sh +7 -2
  67. package/scripts/tools/fix-whitespace.sh +3 -0
  68. package/scripts/tools/freshness-check.sh +2 -2
  69. package/scripts/tools/git-metadata.sh +12 -6
  70. package/scripts/tools/graph-arch.sh +5 -11
  71. package/scripts/tools/graph-callers.sh +10 -15
  72. package/scripts/tools/graph-deps.sh +3 -10
  73. package/scripts/tools/graph-errors.sh +4 -11
  74. package/scripts/tools/graph-hierarchy.sh +4 -11
  75. package/scripts/tools/graph-impact.sh +21 -19
  76. package/scripts/tools/graph-init.sh +13 -9
  77. package/scripts/tools/graph-preflight.sh +4 -1
  78. package/scripts/tools/graph-query.sh +74 -18
  79. package/scripts/tools/graph-risk.sh +3 -10
  80. package/scripts/tools/graph-search.sh +4 -11
  81. package/scripts/tools/graph-snapshot.sh +38 -9
  82. package/scripts/tools/graph-snippet.sh +3 -10
  83. package/scripts/tools/graph-tests.sh +3 -10
  84. package/scripts/tools/graph-traces.sh +3 -10
  85. package/scripts/tools/hotspot-rank.sh +6 -12
  86. package/scripts/tools/install-smoke-test.sh +223 -0
  87. package/scripts/tools/mermaid-from-graph.sh +5 -11
  88. package/scripts/tools/migrate-track-frontmatter.sh +11 -10
  89. package/scripts/tools/okf-coverage-check.sh +8 -7
  90. package/scripts/tools/okf-emit-catalog.sh +256 -0
  91. package/scripts/tools/okf-fix-links.sh +251 -0
  92. package/scripts/tools/okf-plan-concepts.sh +242 -14
  93. package/scripts/tools/okf-render-views.sh +63 -21
  94. package/scripts/tools/okf-validate-all.sh +20 -9
  95. package/scripts/tools/okf-validate-quality.sh +15 -10
  96. package/scripts/tools/okf-validate.sh +20 -6
  97. package/scripts/tools/parse-git-log.sh +23 -5
  98. package/scripts/tools/parse-reports.sh +1 -1
  99. package/scripts/tools/render-track.sh +1 -1
  100. package/scripts/tools/resolve-tools.sh +24 -8
  101. package/scripts/tools/run-coverage.sh +1 -1
  102. package/scripts/tools/scan-markers.sh +4 -4
  103. package/scripts/tools/validate-frontmatter.sh +2 -2
  104. package/scripts/tools/verify-citations.sh +3 -4
  105. package/scripts/tools/verify-doc-anchors.sh +14 -34
  106. package/scripts/tools/verify-graph-binary.sh +15 -5
  107. package/skills/GRAPH.md +21 -10
  108. package/skills/adr/SKILL.md +25 -7
  109. package/skills/assist-review/SKILL.md +2 -1
  110. package/skills/bughunt/SKILL.md +55 -12
  111. package/skills/bughunt/references/regression-tests.md +14 -4
  112. package/skills/change/SKILL.md +19 -9
  113. package/skills/coverage/SKILL.md +28 -12
  114. package/skills/debug/SKILL.md +13 -3
  115. package/skills/decompose/SKILL.md +42 -12
  116. package/skills/deep-review/SKILL.md +19 -6
  117. package/skills/deploy-checklist/SKILL.md +10 -3
  118. package/skills/documentation/SKILL.md +12 -1
  119. package/skills/draft/SKILL.md +40 -29
  120. package/skills/draft/context-files.md +8 -1
  121. package/skills/draft/quality-guide.md +10 -2
  122. package/skills/graph/SKILL.md +2 -2
  123. package/skills/impact/SKILL.md +4 -2
  124. package/skills/implement/SKILL.md +62 -20
  125. package/skills/incident-response/SKILL.md +5 -2
  126. package/skills/init/SKILL.md +112 -30
  127. package/skills/init/references/architecture-spec.md +32 -8
  128. package/skills/init/references/okf-emitter.md +42 -78
  129. package/skills/jira/SKILL.md +33 -13
  130. package/skills/jira/references/review.md +61 -19
  131. package/skills/learn/SKILL.md +30 -7
  132. package/skills/new-track/SKILL.md +73 -18
  133. package/skills/quick-review/SKILL.md +8 -3
  134. package/skills/revert/SKILL.md +11 -5
  135. package/skills/review/SKILL.md +126 -27
  136. package/skills/review/references/zero-setup-mode.md +117 -0
  137. package/skills/standup/SKILL.md +10 -2
  138. package/skills/status/SKILL.md +7 -7
  139. package/skills/tech-debt/SKILL.md +9 -3
  140. package/skills/testing-strategy/SKILL.md +10 -2
  141. package/skills/tour/SKILL.md +2 -1
  142. package/skills/upload/SKILL.md +4 -3
  143. package/core/templates/track-architecture.md +0 -311
@@ -7,7 +7,7 @@ description: Create and manage Architecture Decision Records. Documents signific
7
7
 
8
8
  You are creating or managing Architecture Decision Records (ADRs) for this project.
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
11
 
12
12
  - Creating an ADR without understanding the decision context
13
13
  - Documenting trivial decisions that don't warrant an ADR (e.g., variable naming)
@@ -23,20 +23,24 @@ You are creating or managing Architecture Decision Records (ADRs) for this proje
23
23
  ## Pre-Check
24
24
 
25
25
  1. Verify Draft is initialized:
26
+
26
27
  ```bash
27
28
  ls draft/ 2>/dev/null
28
29
  ```
29
30
 
30
31
  If `draft/` doesn't exist:
32
+
31
33
  - Tell user: "Project not initialized. Run `/draft:init` first."
32
34
  - Stop here.
33
35
 
34
36
  2. Check for existing ADR directory:
37
+
35
38
  ```bash
36
39
  ls draft/adrs/ 2>/dev/null
37
40
  ```
38
41
 
39
42
  If `draft/adrs/` doesn't exist, create it:
43
+
40
44
  ```bash
41
45
  mkdir -p draft/adrs
42
46
  ```
@@ -44,6 +48,7 @@ mkdir -p draft/adrs
44
48
  ## Step 1: Parse Arguments
45
49
 
46
50
  Check for arguments:
51
+
47
52
  - `/draft:adr` — Interactive mode: ask about the decision
48
53
  - `/draft:adr "decision title"` — Create ADR with given title
49
54
  - `/draft:adr list` — List all existing ADRs
@@ -52,9 +57,11 @@ Check for arguments:
52
57
  ### List Mode
53
58
 
54
59
  If argument is `list`:
60
+
55
61
  1. Prefer the deterministic `adr-index.sh` wrapper for the listing — it returns a structured JSON `{adrs:[{id,title,date,status,path,related_tracks}]}` derived from each ADR's frontmatter. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
62
+
56
63
  ```bash
57
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
64
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
58
65
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
59
66
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
60
67
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -64,9 +71,10 @@ If argument is `list`:
64
71
  ls draft/adrs/ # fallback: enumerate files manually
65
72
  fi
66
73
  ```
74
+
67
75
  2. Display summary table:
68
76
 
69
- ```
77
+ ```text
70
78
  Architecture Decision Records
71
79
 
72
80
  | # | Title | Status | Date |
@@ -81,6 +89,7 @@ Stop here after listing.
81
89
  ### Supersede Mode
82
90
 
83
91
  If argument is `supersede <number>`:
92
+
84
93
  1. Read the ADR file `draft/adrs/<number>-*.md`
85
94
  2. Change status from `Accepted` to `Superseded by ADR-<new_number>`
86
95
  3. In the OLD ADR's References section, add: "Superseded by ADR-<new_number>"
@@ -91,6 +100,7 @@ If argument is `supersede <number>`:
91
100
  ### Evaluate Mode
92
101
 
93
102
  If argument starts with `evaluate`:
103
+
94
104
  - `/draft:adr evaluate <proposal or description>` — Evaluate a design proposal
95
105
 
96
106
  1. Read the proposal (from arguments, pasted text, file path, or ask user to describe)
@@ -106,7 +116,7 @@ If argument starts with `evaluate`:
106
116
 
107
117
  5. Output evaluation report (do not save to file — display directly):
108
118
 
109
- ```
119
+ ```text
110
120
  # Design Evaluation: <Title>
111
121
 
112
122
  ## Summary
@@ -138,6 +148,7 @@ Stop here after evaluation.
138
148
  ### Design Mode
139
149
 
140
150
  If argument starts with `design`:
151
+
141
152
  - `/draft:adr design <system or component>` — Full system/component design
142
153
 
143
154
  1. Gather requirements:
@@ -201,11 +212,13 @@ If an active track exists and `draft/tracks/<id>/hld.md` is present:
201
212
 
202
213
  1. Read HLD §Alternatives Considered table.
203
214
  2. If any row is marked `Promote to ADR? yes` and has not been promoted yet (no matching ADR exists), offer:
204
- ```
215
+
216
+ ```text
205
217
  Found 1 unpromoted alternative in <track>/hld.md:
206
218
  - {alternative} — rejected because: {reason}
207
219
  Promote to ADR? [Y/n]
208
220
  ```
221
+
209
222
  3. When promoting:
210
223
  - Pre-fill ADR §Context from HLD §Background and the §High-Level Design / Key Design Decisions row that drove this rejection.
211
224
  - Pre-fill ADR §Decision from the HLD §Key Design Decision that was selected over this alternative.
@@ -220,11 +233,13 @@ If invoked outside a track context, skip 2.1 and proceed with normal interactive
220
233
  Follow the base procedure in `core/shared/draft-context-loading.md`.
221
234
 
222
235
  Read relevant Draft context:
236
+
223
237
  - `draft/.ai-context.md` — Current architecture patterns, invariants, data paths, and constraints. Falls back to `draft/architecture.md` for legacy projects.
224
238
  - `draft/tech-stack.md` — Current technology choices
225
239
  - `draft/product.md` — Product requirements that influence the decision
226
240
 
227
241
  Cross-reference the decision against existing context:
242
+
228
243
  - Does it align with documented architecture patterns?
229
244
  - Does it introduce a new technology not in tech-stack.md?
230
245
  - Does it affect product requirements?
@@ -335,7 +350,7 @@ originating_track: "{<track_id> or null}"
335
350
 
336
351
  Present the ADR to the user for review:
337
352
 
338
- ```
353
+ ```text
339
354
  ADR-<number> created: <title>
340
355
  File: draft/adrs/<number>-<kebab-case-title>.md
341
356
  Status: Proposed
@@ -353,7 +368,7 @@ If the decision affects existing Draft context:
353
368
 
354
369
  ## ADR Status Lifecycle
355
370
 
356
- ```
371
+ ```text
357
372
  Proposed → Accepted → [Deprecated | Superseded by ADR-xxx]
358
373
  ```
359
374
 
@@ -365,11 +380,14 @@ Proposed → Accepted → [Deprecated | Superseded by ADR-xxx]
365
380
  ## Error Handling
366
381
 
367
382
  **If no draft/ directory:**
383
+
368
384
  - Tell user to run `/draft:init` first
369
385
 
370
386
  **If ADR number conflict:**
387
+
371
388
  - Increment to next available number
372
389
  - Warn: "ADR-<number> already exists. Using ADR-<next>."
373
390
 
374
391
  **If superseding non-existent ADR:**
392
+
375
393
  - Warn: "ADR-<number> not found. Check `draft/adrs/` for valid ADR numbers."
@@ -7,7 +7,8 @@ description: Reviewing someone else's PR for handoff/sign-off. Isolates structur
7
7
 
8
8
  Help human reviewers effectively review an executed track without shifting the entire cognitive burden onto them.
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
+
11
12
  - Conducting standard unit tests; use `/draft:review` for that.
12
13
  - Fixing code rather than explaining logic and risk profiles to the human.
13
14
  - Reviewing output without first summarizing the source `spec.md` intent.
@@ -24,7 +24,7 @@ Some AI tools (e.g., Claude Code) provide a built-in `bughunt` agent that auto-d
24
24
 
25
25
  **When to use which:** Use `/draft:bughunt` when you need context-aware analysis with structured evidence and false-positive elimination. Use the built-in agent when you want fast parallel sweeps with auto-fix capability. For maximum coverage, run both — `/draft:bughunt` catches context-specific bugs the built-in misses, and vice versa.
26
26
 
27
- ## Red Flags - STOP if you're:
27
+ ## Red Flags - STOP if you're
28
28
 
29
29
  - Hunting for bugs without reading Draft context first (architecture.md, tech-stack.md, product.md)
30
30
  - Reporting a finding without reproducing or tracing the code path
@@ -57,6 +57,7 @@ Store this for the report header. All bugs found are relative to this specific b
57
57
  Read and follow the base procedure in `core/shared/draft-context-loading.md`.
58
58
 
59
59
  **Bug-hunt-specific context application:**
60
+
60
61
  - Flag violations of intended architecture as bugs (coupling, boundary violations)
61
62
  - Apply framework-specific checks from tech-stack (React anti-patterns, Node gotchas, etc.)
62
63
  - Catch bugs that violate product requirements or user flows
@@ -69,14 +70,16 @@ Read and follow the base procedure in `core/shared/draft-context-loading.md`.
69
70
  - **Leverage Consistency Boundaries** — Find bugs at eventual consistency seams (stale reads, lost events, missing reconciliation)
70
71
  - **Leverage Failure Recovery Matrix** — Verify idempotency claims, check for partial failure states without recovery paths
71
72
  - **Leverage Graph Data** (if `draft/graph/` exists) — First resolve the bundled helpers:
73
+
72
74
  ```bash
73
75
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
74
76
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
75
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
77
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
76
78
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
77
79
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
78
80
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
79
81
  ```
82
+
80
83
  Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for dependency awareness. Flag dependencies on unexpected modules. Flag code in modules involved in dependency cycles as higher risk. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to prioritize analysis of high-complexity, high-fanIn files. See `core/shared/graph-query.md`.
81
84
  - **Leverage Learned Anti-Patterns** — If `draft/guardrails.md` exists, read the `## Learned Anti-Patterns` section. During the bug sweep, when a bug matches a learned anti-pattern, prefix the report entry with `[KNOWN-ANTI-PATTERN: {pattern name}]`. This distinguishes recurring documented patterns from newly discovered bugs, and signals that a systemic fix may be needed rather than a one-off patch.
82
85
 
@@ -85,6 +88,7 @@ Read and follow the base procedure in `core/shared/draft-context-loading.md`.
85
88
  When invoked programmatically by `/draft:review` with `with-bughunt`, skip scope confirmation and inherit the scope from the calling command.
86
89
 
87
90
  Otherwise, ask user to confirm scope:
91
+
88
92
  - **Entire repo** - Full codebase analysis
89
93
  - **Specific paths** - Target directories or files
90
94
  - **Track-level** (specify `<track-id>`) - Focus on files relevant to a specific track
@@ -92,10 +96,12 @@ Otherwise, ask user to confirm scope:
92
96
  ### 3. Load Track Context (if track-level)
93
97
 
94
98
  If running for a specific track, also load:
99
+
95
100
  - [ ] `draft/tracks/<id>/spec.md` - Requirements, acceptance criteria, edge cases
96
101
  - [ ] `draft/tracks/<id>/plan.md` - Implementation tasks, phases, dependencies
97
102
 
98
103
  Use track context to:
104
+
99
105
  - Verify implemented features match spec requirements
100
106
  - Check edge cases listed in spec are handled
101
107
  - Identify bugs in areas touched by the track's plan
@@ -124,6 +130,7 @@ Before analyzing all 14 dimensions, determine which apply to this codebase:
124
130
  - **Mark skipped dimensions** with reason in report summary
125
131
 
126
132
  **Examples of skipping:**
133
+
127
134
  - "N/A - no backend code" (skip dimensions 2, 8, 10 for frontend-only repo)
128
135
  - "N/A - no UI components" (skip dimensions 5, 9, 14 for CLI tool)
129
136
  - "N/A - no database" (skip dimension 2 for in-memory app)
@@ -136,18 +143,21 @@ Before analyzing all 14 dimensions, determine which apply to this codebase:
136
143
  Analyze systematically across all applicable dimensions. Skip N/A dimensions explicitly (see Dimension Applicability Check above).
137
144
 
138
145
  ### 1. Correctness
146
+
139
147
  - Logical errors, invalid assumptions, edge cases
140
148
  - Incorrect state transitions, stale or inconsistent UI state
141
149
  - Error handling gaps, silent failures
142
150
  - Off-by-one errors, boundary conditions
143
151
 
144
152
  ### 2. Reliability & Resilience
153
+
145
154
  - Crash paths, unhandled exceptions
146
155
  - Reload/refresh behavior, retry logic
147
156
  - UI behavior on partial backend failure
148
157
  - Broken recovery after errors, navigation
149
158
 
150
159
  ### 3. Security
160
+
151
161
  - XSS, injection vectors, unsafe rendering
152
162
  - Client-side trust assumptions
153
163
  - Secrets, tokens, auth data exposure
@@ -161,12 +171,14 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
161
171
  - Reference: OWASP Top 10, Meta Infer taint analysis methodology
162
172
 
163
173
  ### 4. Performance (Backend + UI)
174
+
164
175
  - Inefficient algorithms and data fetching
165
176
  - Blocking work on main/UI thread
166
177
  - Excessive re-renders, unnecessary state updates
167
178
  - Unbounded memory growth (listeners, caches, stores)
168
179
 
169
180
  ### 5. UI Responsiveness & Perceived Performance
181
+
170
182
  - Long tasks blocking input
171
183
  - Jank during scrolling, typing, resizing
172
184
  - Layout thrashing, forced reflows
@@ -174,6 +186,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
174
186
  - Poor loading states, flicker, content shifts
175
187
 
176
188
  ### 6. Concurrency & Ordering
189
+
177
190
  - Race conditions between async calls
178
191
  - Stale responses overwriting newer state
179
192
  - Incorrect cancellation or debouncing
@@ -181,6 +194,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
181
194
  - Deadlocks, livelocks
182
195
 
183
196
  ### 7. State Management
197
+
184
198
  - Source-of-truth violations
185
199
  - Derived state bugs (computed from stale data)
186
200
  - Global state misuse
@@ -188,12 +202,14 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
188
202
  - Inconsistent state across components
189
203
 
190
204
  ### 8. API & Contracts
205
+
191
206
  - UI assumptions not guaranteed by backend
192
207
  - Schema drift, weak typing, missing validation
193
208
  - Backward compatibility risks
194
209
  - Undocumented API behavior dependencies
195
210
 
196
211
  ### 9. Accessibility & UX Correctness
212
+
197
213
  - Keyboard navigation gaps
198
214
  - Focus management bugs
199
215
  - ARIA misuse or absence
@@ -202,6 +218,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
202
218
  - Color contrast, screen reader compatibility
203
219
 
204
220
  ### 10. Configuration & Build
221
+
205
222
  - Fragile environment assumptions
206
223
  - Build-time vs runtime config leaks
207
224
  - Dev-only code shipping to prod
@@ -209,6 +226,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
209
226
  - CI gaps affecting builds or tests
210
227
 
211
228
  ### 11. Tests
229
+
212
230
  - Missing coverage for critical flows
213
231
  - Snapshot misuse (testing implementation, not behavior)
214
232
  - Tests that assert implementation instead of behavior
@@ -221,6 +239,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
221
239
  - **Flaky test patterns:** time-dependent assertions (sleep, Date.now, timestamps), port/file system assumptions, test ordering dependencies, non-deterministic data (random seeds, UUIDs without control)
222
240
 
223
241
  ### 12. Dependency & Supply Chain Security
242
+
224
243
  - **Known CVEs:** Check dependencies against known vulnerability databases (reference tools: Snyk, Trivy, OWASP Dependency-Check, `npm audit`, `pip-audit`, `cargo audit`, `go vuln`)
225
244
  - **Unpinned dependency versions:** Lockfile freshness, use of version ranges (`^`, `~`, `*`, `>=`) without lockfile enforcement, missing lockfile entirely
226
245
  - **Deprecated packages:** Dependencies with known deprecation notices, archived repositories, or no maintenance activity
@@ -230,6 +249,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
230
249
  - Reference: Google OSS-Fuzz, Microsoft SDL, OpenSSF Scorecard
231
250
 
232
251
  ### 13. Algorithmic Complexity
252
+
233
253
  - **Quadratic or worse loops:** O(n^2) or worse nested loops over collections (nested `.filter()` inside `.map()`, repeated linear scans, cartesian joins in application code)
234
254
  - **Regex catastrophic backtracking:** Nested quantifiers (`(a+)+`, `(a|a)*`), unbounded repetition with overlapping alternatives — flag any regex applied to user-controlled input
235
255
  - **Unbounded recursion:** Recursive functions without depth limits, missing base cases, or base cases that depend on external/mutable state
@@ -237,6 +257,7 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
237
257
  - **Hot path inefficiency:** Sorting/searching in hot paths without appropriate data structures (linear scan where hash map suffices, repeated sorting of same collection, string concatenation in loops)
238
258
 
239
259
  ### 14. Internationalization & Localization
260
+
240
261
  - **Hardcoded user-facing strings:** Strings displayed to users embedded directly in source code rather than externalized to resource files/i18n frameworks
241
262
  - **Locale-sensitive operations without locale parameter:** String comparison (`<`, `>`, `localeCompare` without locale), date formatting (`toLocaleDateString` without explicit locale), number formatting, sorting (alphabetical sort that assumes ASCII ordering)
242
263
  - **RTL layout issues:** Hardcoded LTR assumptions in UI code (absolute `left`/`right` positioning, directional margin/padding, text alignment assumptions)
@@ -291,7 +312,8 @@ Analyze systematically across all applicable dimensions. Skip N/A dimensions exp
291
312
  - [ ] If all instances have the bug: Report with pattern count in "Impact"
292
313
 
293
314
  **Example Pattern Prevalence Check:**
294
- ```
315
+
316
+ ```text
295
317
  1. Grep: `rg 'dangerouslySetInnerHTML' src/` → found 12 occurrences
296
318
  2. Sampled 3: src/Blog.tsx:45, src/About.tsx:12, src/FAQ.tsx:30
297
319
  3. All 3 sanitize input via `DOMPurify.sanitize()` before rendering
@@ -316,6 +338,7 @@ Only report bugs with HIGH or CONFIRMED confidence:
316
338
  ### Evidence Requirements
317
339
 
318
340
  Each reported bug MUST include:
341
+
319
342
  - **Code Evidence:** The actual problematic code snippet
320
343
  - **Trace:** How data reaches this point (caller chain or data flow)
321
344
  - **Verification Done:** Which checks from the checklist were completed
@@ -341,6 +364,7 @@ For suspected bugs that can be tested, write a minimal failing test to confirm:
341
364
  4. **Only report if**: Test fails OR CONFIRMED confidence from code trace
342
365
 
343
366
  **Example:**
367
+
344
368
  ```javascript
345
369
  // Suspected bug: off-by-one in pagination
346
370
  test('should handle last page boundary', () => {
@@ -359,12 +383,12 @@ For each verified bug, generate a regression test in the project's native test f
359
383
  If no test framework is detected, mark all bugs `Regression Test Status: N/A` and continue — the bug report is the primary deliverable.
360
384
 
361
385
  **Detailed procedure** — see `references/regression-tests.md` for:
386
+
362
387
  - Language and test-framework detection signals (C/C++, Go, Python, JS/TS, Rust, Java)
363
388
  - Existing-test discovery patterns and coverage classification
364
389
  - Test case requirements and language-specific templates
365
390
  - Build/syntax validation commands per toolchain
366
391
 
367
-
368
392
  ## Fix Suggestion Generation
369
393
 
370
394
  For each bug with CONFIRMED or HIGH confidence, generate a minimal suggested fix alongside the bug report. Fix suggestions are advisory — they are never auto-applied.
@@ -404,6 +428,7 @@ For each verified bug:
404
428
  **Impact:** [User-visible effect or system failure mode]
405
429
 
406
430
  **Verification Done:**
431
+
407
432
  - [x] Traced code path from [entry point]
408
433
  - [x] Checked architecture.md — not intentional
409
434
  - [x] Verified framework doesn't handle this
@@ -415,6 +440,7 @@ For each verified bug:
415
440
  **Fix:** [Minimal code change or mitigation]
416
441
 
417
442
  **Suggested Fix (REVIEW REQUIRED):**
443
+
418
444
  ```[language]
419
445
  // BEFORE (current buggy code):
420
446
  [exact code snippet from the codebase]
@@ -422,16 +448,19 @@ For each verified bug:
422
448
  // AFTER (suggested fix):
423
449
  [minimal change that addresses root cause]
424
450
  ```
451
+
425
452
  _This fix is SUGGESTED only — human review required before applying. Reference: Meta SapFix methodology._
426
453
 
427
454
  **Regression Test:**
428
455
  **Status:** [COVERED | PARTIAL | WRONG_ASSERTION | NO_COVERAGE | N/A]
429
456
  **Existing Test:** [`path/to/test_file:line` — test name | None found]
430
457
  [Action: existing test reference, proposed modification, or new test case]
458
+
431
459
  ```[language]
432
460
  // New or modified test case (omit if COVERED or N/A)
433
461
  ```
434
- ```
462
+
463
+ ```text
435
464
 
436
465
  **Example — COVERED (no new test needed):**
437
466
  ```markdown
@@ -442,6 +471,7 @@ No new test needed. Existing test fails when XSS sanitization is removed.
442
471
  ```
443
472
 
444
473
  **Example — PARTIAL (C++ / GTest):**
474
+
445
475
  ```markdown
446
476
  **Regression Test:**
447
477
  **Status:** PARTIAL — tests exist for processInput() but miss unsanitized HTML path
@@ -455,7 +485,8 @@ TEST(InputSanitization, RejectsMaliciousScript) {
455
485
  << "Input should be sanitized to remove script tags";
456
486
  }
457
487
  ```
458
- ```
488
+
489
+ ```text
459
490
 
460
491
  **Example — NO_COVERAGE (Python / pytest):**
461
492
  ```markdown
@@ -473,7 +504,8 @@ def test_rejects_malicious_script():
473
504
  assert "<script>" not in result, "XSS script tag should be stripped"
474
505
  # Expected: FAILS against current code (passes XSS through), PASSES after fix
475
506
  ```
476
- ```
507
+
508
+ ```text
477
509
 
478
510
  **Example — NO_COVERAGE (Go / testing):**
479
511
  ```markdown
@@ -497,7 +529,8 @@ func TestProcessInputRejectsMaliciousScript(t *testing.T) {
497
529
  }
498
530
  // Expected: FAILS against current code (passes XSS through), PASSES after fix
499
531
  ```
500
- ```
532
+
533
+ ```text
501
534
 
502
535
  **Example — N/A (not testable, but still report the bug):**
503
536
  ```markdown
@@ -507,6 +540,7 @@ func TestProcessInputRejectsMaliciousScript(t *testing.T) {
507
540
  ```
508
541
 
509
542
  Severity levels:
543
+
510
544
  - **Critical** — Blocks release, breaks functionality, security issue
511
545
  - **Important** — Degrades quality, creates tech debt
512
546
  - **Minor** — Style, optimization, edge cases
@@ -514,10 +548,12 @@ Severity levels:
514
548
  ## Report Generation
515
549
 
516
550
  Generate report at:
551
+
517
552
  - **Project-level:** `draft/bughunt-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`)
518
553
  - **Track-level:** `draft/tracks/<track-id>/bughunt-report-<timestamp>.md` (if analyzing specific track)
519
554
 
520
555
  After writing the timestamped report, create a symlink pointing to it:
556
+
521
557
  ```bash
522
558
  # Project-level
523
559
  ln -sf bughunt-report-<timestamp>.md draft/bughunt-report-latest.md
@@ -597,9 +633,11 @@ Report structure:
597
633
  | 5 | [Brief title] | — | SKIPPED (N/A) |
598
634
 
599
635
  ```
636
+
600
637
  Validation Summary: 3 BUILD_OK, 0 BUILD_FAILED, 1 SKIPPED
601
638
  Validation Command: python -m py_compile <file>
602
- ```
639
+
640
+ ```text
603
641
 
604
642
  ### New Tests Written (NO_COVERAGE)
605
643
 
@@ -637,7 +675,8 @@ Bugs that cannot have automated regression tests (config issues, documentation,
637
675
  | Bug # | Bug Title | Reason |
638
676
  |-------|-----------|--------|
639
677
  | 6 | [Brief title] | Config file — no executable code |
640
- ```
678
+
679
+ ```text
641
680
 
642
681
  ## Final Instructions
643
682
 
@@ -670,17 +709,21 @@ After bughunt report generation:
670
709
 
671
710
  **If critical bugs found:**
672
711
  ```
712
+
673
713
  "Critical bugs found. Consider:
674
714
  → /draft:debug — Run structured debug session on critical finding #{n}
675
715
  → git bisect — Find the exact commit that introduced the bug"
676
- ```
716
+
717
+ ```text
677
718
 
678
719
  ### Test Writing Guardrail
679
720
 
680
721
  When offering to write regression tests for found bugs:
681
722
  ```
723
+
682
724
  ASK: "Want me to write regression tests for the {n} bugs found? [Y/n]"
683
- ```
725
+
726
+ ```text
684
727
  Never auto-write tests — always ask first.
685
728
 
686
729
  ### Jira Sync
@@ -21,6 +21,7 @@ Identify the project's language(s) and test framework by examining the codebase:
21
21
  | `build.gradle`/`build.gradle.kts` | Java/Kotlin | JUnit | `gradle test` |
22
22
 
23
23
  **Resolution order:**
24
+
24
25
  1. Check `draft/tech-stack.md` first — it may explicitly state the test framework
25
26
  2. Look for existing test files and match their import/framework patterns
26
27
  3. Fall back to build system signals above
@@ -30,7 +31,8 @@ If the project is **polyglot** (multiple languages), detect per-component and ge
30
31
  **If no test framework is detected:** Mark all bugs with `Regression Test Status: N/A — no test framework detected` and proceed with bug reporting. **Do not skip bugs because tests cannot be written.** The regression test section is supplementary — the primary deliverable is the bug report.
31
32
 
32
33
  Record the detected configuration:
33
- ```
34
+
35
+ ```yaml
34
36
  Language: [detected | none]
35
37
  Test Framework: [detected | none]
36
38
  Build System: [detected | none]
@@ -71,7 +73,8 @@ For each verified bug, search the codebase for existing tests before generating
71
73
  4. **Document discovery results** in the bug report's Regression Test field
72
74
 
73
75
  **Example Existing Test Discovery:**
74
- ```
76
+
77
+ ```text
75
78
  1. Bug location: src/parser.cpp:145 — off-by-one in tokenize()
76
79
  2. Grep: `rg 'tokenize' tests/` → found tests/parser_test.cpp
77
80
  3. Read tests/parser_test.cpp:
@@ -87,7 +90,8 @@ For each verified bug, search the codebase for existing tests before generating
87
90
  Based on discovery results, generate tests in the project's native framework:
88
91
 
89
92
  #### When status is COVERED
90
- ```
93
+
94
+ ```text
91
95
  **Regression Test:**
92
96
  **Status:** COVERED — existing test already catches this bug
93
97
  **Existing Test:** `tests/parser_test.cpp:45` — `TEST(Parser, TokenizeBoundary)`
@@ -95,7 +99,9 @@ No new test needed.
95
99
  ```
96
100
 
97
101
  #### When status is PARTIAL — add to existing test file
102
+
98
103
  #### When status is WRONG_ASSERTION — fix assertion in existing test
104
+
99
105
  #### When status is NO_COVERAGE — generate new test
100
106
 
101
107
  ### Test Case Requirements (all languages)
@@ -297,6 +303,7 @@ For bugs with status NO_COVERAGE, PARTIAL, or WRONG_ASSERTION, write the actual
297
303
  #### NO_COVERAGE — Create new test file
298
304
 
299
305
  1. **Create directory** if it doesn't exist:
306
+
300
307
  ```bash
301
308
  mkdir -p <test_directory>/
302
309
  ```
@@ -315,6 +322,7 @@ For bugs with status NO_COVERAGE, PARTIAL, or WRONG_ASSERTION, write the actual
315
322
  3. **Create or update build config** (if required by the build system):
316
323
 
317
324
  **C/C++ (Bazel)** — add `cc_test` to BUILD:
325
+
318
326
  ```python
319
327
  cc_test(
320
328
  name = "<source_filename>_test",
@@ -355,6 +363,7 @@ For bugs with status NO_COVERAGE, PARTIAL, or WRONG_ASSERTION, write the actual
355
363
  4. No build config changes needed
356
364
 
357
365
  **Constraints:**
366
+
358
367
  - **Never modify production source code** — only test files and their build configs
359
368
  - Each test file must be valid for the project's test runner
360
369
  - Use the project's actual import paths, module names, and namespace conventions
@@ -392,7 +401,8 @@ After writing all test files, validate them using the project's native toolchain
392
401
  **Exception for Go:** `go vet` is preferred over `go build` for test files because Go compiles tests as part of `go test` only. `go vet` catches type errors and common issues without executing.
393
402
 
394
403
  4. **Validation summary** — Record results for the report:
395
- ```
404
+
405
+ ```yaml
396
406
  BUILD_OK: 3 targets
397
407
  BUILD_FAILED: 1 target (tests/config/test_loader.py — ImportError: no module named 'config.loader')
398
408
  SKIPPED: 1 target (N/A — race condition not reliably testable)