@codexstar/bug-hunter 3.0.0 → 3.0.6

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 (78) hide show
  1. package/CHANGELOG.md +149 -83
  2. package/README.md +150 -15
  3. package/SKILL.md +94 -27
  4. package/agents/openai.yaml +4 -0
  5. package/bin/bug-hunter +9 -3
  6. package/docs/images/2026-03-12-fix-plan-rollout.png +0 -0
  7. package/docs/images/2026-03-12-hero-bug-hunter-overview.png +0 -0
  8. package/docs/images/2026-03-12-machine-readable-artifacts.png +0 -0
  9. package/docs/images/2026-03-12-pr-review-flow.png +0 -0
  10. package/docs/images/2026-03-12-security-pack.png +0 -0
  11. package/docs/images/adversarial-debate.png +0 -0
  12. package/docs/images/doc-verify-fix-plan.png +0 -0
  13. package/docs/images/hero.png +0 -0
  14. package/docs/images/pipeline-overview.png +0 -0
  15. package/docs/images/security-finding-card.png +0 -0
  16. package/docs/plans/2026-03-11-structured-output-migration-plan.md +288 -0
  17. package/docs/plans/2026-03-12-audit-bug-fixes-surgical-plan.md +193 -0
  18. package/docs/plans/2026-03-12-enterprise-security-pack-e2e-plan.md +59 -0
  19. package/docs/plans/2026-03-12-local-security-skills-integration-plan.md +39 -0
  20. package/docs/plans/2026-03-12-pr-review-strategic-fix-flow.md +78 -0
  21. package/evals/evals.json +366 -102
  22. package/modes/extended.md +2 -2
  23. package/modes/fix-loop.md +30 -30
  24. package/modes/fix-pipeline.md +32 -6
  25. package/modes/large-codebase.md +14 -15
  26. package/modes/local-sequential.md +44 -20
  27. package/modes/loop.md +56 -56
  28. package/modes/parallel.md +3 -3
  29. package/modes/scaled.md +2 -2
  30. package/modes/single-file.md +3 -3
  31. package/modes/small.md +11 -11
  32. package/package.json +11 -1
  33. package/prompts/fixer.md +37 -23
  34. package/prompts/hunter.md +39 -20
  35. package/prompts/referee.md +34 -20
  36. package/prompts/skeptic.md +25 -22
  37. package/schemas/coverage.schema.json +67 -0
  38. package/schemas/examples/findings.invalid.json +13 -0
  39. package/schemas/examples/findings.valid.json +17 -0
  40. package/schemas/findings.schema.json +76 -0
  41. package/schemas/fix-plan.schema.json +94 -0
  42. package/schemas/fix-report.schema.json +105 -0
  43. package/schemas/fix-strategy.schema.json +99 -0
  44. package/schemas/recon.schema.json +31 -0
  45. package/schemas/referee.schema.json +46 -0
  46. package/schemas/shared.schema.json +51 -0
  47. package/schemas/skeptic.schema.json +21 -0
  48. package/scripts/bug-hunter-state.cjs +35 -12
  49. package/scripts/code-index.cjs +11 -4
  50. package/scripts/fix-lock.cjs +95 -25
  51. package/scripts/payload-guard.cjs +24 -10
  52. package/scripts/pr-scope.cjs +181 -0
  53. package/scripts/prepublish-guard.cjs +82 -0
  54. package/scripts/render-report.cjs +346 -0
  55. package/scripts/run-bug-hunter.cjs +669 -33
  56. package/scripts/schema-runtime.cjs +273 -0
  57. package/scripts/schema-validate.cjs +40 -0
  58. package/scripts/tests/bug-hunter-state.test.cjs +68 -3
  59. package/scripts/tests/code-index.test.cjs +15 -0
  60. package/scripts/tests/fix-lock.test.cjs +60 -2
  61. package/scripts/tests/fixtures/flaky-worker.cjs +6 -1
  62. package/scripts/tests/fixtures/low-confidence-worker.cjs +8 -2
  63. package/scripts/tests/fixtures/success-worker.cjs +6 -1
  64. package/scripts/tests/payload-guard.test.cjs +154 -2
  65. package/scripts/tests/pr-scope.test.cjs +212 -0
  66. package/scripts/tests/render-report.test.cjs +180 -0
  67. package/scripts/tests/run-bug-hunter.test.cjs +686 -2
  68. package/scripts/tests/security-skills-integration.test.cjs +29 -0
  69. package/scripts/tests/skills-packaging.test.cjs +30 -0
  70. package/scripts/tests/worktree-harvest.test.cjs +67 -1
  71. package/scripts/worktree-harvest.cjs +62 -9
  72. package/skills/README.md +19 -0
  73. package/skills/commit-security-scan/SKILL.md +63 -0
  74. package/skills/security-review/SKILL.md +57 -0
  75. package/skills/threat-model-generation/SKILL.md +47 -0
  76. package/skills/vulnerability-validation/SKILL.md +59 -0
  77. package/templates/subagent-wrapper.md +12 -3
  78. package/modes/_dispatch.md +0 -121
package/SKILL.md CHANGED
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  name: bug-hunter
3
3
  description: "Adversarial bug hunting with a sequential-first pipeline (Recon, Hunter, Skeptic, Referee) that can optionally use safe read-only parallel triage. Finds, verifies, and auto-fixes real bugs by default (with --scan-only opt-out) using checkpointed verification and resume state for large codebases. Use this skill whenever the user wants bug finding, security audits, regression checks, or code review focused on runtime behavior."
4
- argument-hint: "[path | -b <branch> [--base <base-branch>] | --staged | --scan-only | --fix | --autonomous | --no-loop | --approve | --deps | --threat-model | --dry-run]"
5
- disable-model-invocation: true
6
4
  ---
7
5
 
8
6
  # Bug Hunt - Adversarial Bug Finding
@@ -44,17 +42,31 @@ For large scans: process chunks sequentially with persistent state to avoid comp
44
42
  /bug-hunter lib/auth.ts # Scan specific file
45
43
  /bug-hunter -b feature-xyz # Scan files changed in feature-xyz vs main
46
44
  /bug-hunter -b feature-xyz --base dev # Scan files changed in feature-xyz vs dev
45
+ /bug-hunter --pr # Easy alias for --pr current
46
+ /bug-hunter --pr current # Review the current PR end to end
47
+ /bug-hunter --pr recent --scan-only # Review the most recent PR without editing code
48
+ /bug-hunter --pr 123 # Review a specific PR number
49
+ /bug-hunter --pr-security # PR security review: PR scope + threat model + dependency scan
50
+ /bug-hunter --last-pr --review # Easy mnemonic for “review the last PR”
51
+ /bug-hunter --review-pr # Alias for --pr current
47
52
  /bug-hunter --staged # Scan staged files (pre-commit check)
48
53
  /bug-hunter --scan-only src/ # Scan only, no code changes
54
+ /bug-hunter --review src/ # Easy alias for --scan-only
49
55
  /bug-hunter --fix src/ # Find bugs AND auto-fix them
56
+ /bug-hunter --plan-only src/ # Build fix strategy + plan, but do not edit files
57
+ /bug-hunter --plan src/ # Easy alias for --plan-only
58
+ /bug-hunter --safe src/ # Easy alias for --fix --approve
59
+ /bug-hunter --preview src/ # Easy alias for --fix --dry-run
50
60
  /bug-hunter --autonomous src/ # Alias for no-intervention auto-fix run
51
61
  /bug-hunter --fix -b feature-xyz # Find + fix on branch diff
52
62
  /bug-hunter --fix --approve src/ # Find + fix, but ask before each fix
53
- /bug-hunter src/ # Loops by default: audit until 100% coverage
63
+ /bug-hunter src/ # Loops by default: audit + fix until all queued source files are covered
54
64
  /bug-hunter --no-loop src/ # Single-pass only, no iterating
55
65
  /bug-hunter --no-loop --scan-only src/ # Single-pass scan, no fixes, no loop
56
66
  /bug-hunter --deps src/ # Include dependency CVE scan
57
67
  /bug-hunter --threat-model src/ # Generate/use STRIDE threat model
68
+ /bug-hunter --security-review src/ # Enterprise security workflow: threat model + CVEs + validation
69
+ /bug-hunter --validate-security src/ # Force vulnerability-validation for security findings
58
70
  /bug-hunter --deps --threat-model src/ # Full security audit
59
71
  /bug-hunter --fix --dry-run src/ # Preview fixes without editing files
60
72
  ```
@@ -75,14 +87,36 @@ The raw arguments are: $ARGUMENTS
75
87
  0g. If arguments contain `--deps`: strip it and set `DEP_SCAN=true`. Dependency scanning runs package manager audit tools and checks if vulnerable APIs are actually called in the codebase.
76
88
  0h. If arguments contain `--threat-model`: strip it and set `THREAT_MODEL_MODE=true`. Generates a STRIDE threat model at `.bug-hunter/threat-model.md` if one doesn't exist, then feeds it to Recon + Hunter for targeted security analysis.
77
89
  0i. If arguments contain `--dry-run`: strip it and set `DRY_RUN_MODE=true`. Forces `FIX_MODE=true`. In dry-run mode, Phase 2 builds the fix plan and the Fixer reads code and outputs planned changes as unified diff previews, but no file edits, git commits, or lock acquisition occur. Produces `fix-report.json` with `"dry_run": true`.
90
+ 0j. If arguments contain `--preview`: strip it, set `DRY_RUN_MODE=true`, and force `FIX_MODE=true`. Treat it as a memorable alias for `--fix --dry-run`.
91
+ 0k. If arguments contain `--plan-only`: strip it and set `PLAN_ONLY_MODE=true`. The pipeline still scans, verifies, and builds `fix-strategy.json` + `fix-plan.json`, but it stops before the Fixer edits code.
92
+ 0l. If arguments contain `--plan`: strip it and set `PLAN_ONLY_MODE=true`. Treat it as a memorable alias for `--plan-only`.
93
+ 0m. If arguments contain `--review-pr`: strip it and treat it as `--pr current`.
94
+ 0n. If arguments contain `--pr` with no selector after it, treat it as `--pr current`.
95
+ 0o. If arguments contain `--last-pr`: strip it and treat it as `--pr recent`.
96
+ 0p. If arguments contain `--review`: strip it and set `FIX_MODE=false`. Treat it as a memorable alias for `--scan-only`.
97
+ 0q. If arguments contain `--safe`: strip it, set `FIX_MODE=true`, and set `APPROVE_MODE=true`. Treat it as a memorable alias for `--fix --approve`.
98
+ 0r. If arguments contain `--pr-security`: strip it, set `PR_SECURITY_MODE=true`, force `DEP_SCAN=true`, force `THREAT_MODEL_MODE=true`, force `FIX_MODE=false`, and if no explicit `--pr` selector was provided treat it as `--pr current`.
99
+ 0s. If arguments contain `--security-review`: strip it, set `SECURITY_REVIEW_MODE=true`, force `DEP_SCAN=true`, force `THREAT_MODEL_MODE=true`, and force `FIX_MODE=false`.
100
+ 0t. If arguments contain `--validate-security`: strip it and set `VALIDATE_SECURITY_MODE=true`.
101
+
102
+ 1. If arguments contain `--pr <selector>`: this is **PR review mode**.
103
+ - Valid selectors: `current`, `recent`, or a PR number like `123`.
104
+ - If `--base <base-branch>` is present, pass it through for current-branch git fallback.
105
+ - Run:
106
+ ```bash
107
+ node "$SKILL_DIR/scripts/pr-scope.cjs" resolve "<selector>" --repo-root "$PWD" [--base <base-branch>]
108
+ ```
109
+ - If it fails, report the error to the user and stop.
110
+ - Save the JSON result to `.bug-hunter/pr-scope.json` for later reporting.
111
+ - Use `changedFiles` from the JSON output as the scan target (scan full file contents, not just the diff).
78
112
 
79
- 1. If arguments contain `--staged`: this is **staged file mode**.
113
+ 2. If arguments contain `--staged`: this is **staged file mode**.
80
114
  - Run `git diff --cached --name-only` using the Bash tool to get the list of staged files.
81
115
  - If the command fails, report the error to the user and stop.
82
116
  - If no files are staged, tell the user there are no staged changes to scan and stop.
83
117
  - The scan target is the list of staged files (scan their full contents, not just the diff).
84
118
 
85
- 2. If arguments contain `-b <branch>`: this is **branch diff mode**.
119
+ 3. If arguments contain `-b <branch>`: this is **branch diff mode**.
86
120
  - Extract the branch name after `-b`.
87
121
  - If `--base <base-branch>` is also present, use that as the base branch. Otherwise default to `main`.
88
122
  - Run `git diff --name-only <base>...<branch>` using the Bash tool to get the list of changed files.
@@ -90,9 +124,9 @@ The raw arguments are: $ARGUMENTS
90
124
  - If no files changed, tell the user there are no changes to scan and stop.
91
125
  - The scan target is the list of changed files (scan their full contents, not just the diff).
92
126
 
93
- 3. If arguments do NOT contain `-b` or `--staged`: treat the entire argument string as a **path target** (file or directory). If empty, scan the current working directory.
127
+ 4. If arguments do NOT contain `--pr`, `-b`, or `--staged`: treat the entire argument string as a **path target** (file or directory). If empty, scan the current working directory.
94
128
 
95
- **After resolving the file list (for modes 1 and 2), filter out non-source files:**
129
+ **After resolving the file list (for modes 1, 2, and 3), filter out non-source files:**
96
130
 
97
131
  Remove any files matching these patterns — they are not scannable source code:
98
132
  - Docs/text: `*.md`, `*.txt`, `*.rst`, `*.adoc`
@@ -130,7 +164,7 @@ If triage was not run (e.g., Recon was called directly without the orchestrator)
130
164
 
131
165
  **File partitioning rules (Extended/Scaled modes):**
132
166
  - **Service-aware partitioning (preferred)**: If Recon detected multiple service boundaries (monorepo), partition by service.
133
- - **Risk-tier partitioning (fallback)**: process CRITICAL then HIGH then MEDIUM.
167
+ - **Risk-tier partitioning (fallback)**: process CRITICAL then HIGH then MEDIUM then LOW.
134
168
  - Keep chunk size small (recommended 20-40 files) to avoid context compaction issues.
135
169
  - Persist chunk progress in `.bug-hunter/state.json` so restarts do not re-scan done chunks.
136
170
  - Test files (CONTEXT-ONLY) are included only when needed for intent.
@@ -169,7 +203,7 @@ Before doing anything else, verify the environment:
169
203
 
170
204
  5. **Verify helper scripts exist**:
171
205
  ```
172
- ls "$SKILL_DIR/scripts/run-bug-hunter.cjs" "$SKILL_DIR/scripts/bug-hunter-state.cjs" "$SKILL_DIR/scripts/delta-mode.cjs" "$SKILL_DIR/scripts/payload-guard.cjs" "$SKILL_DIR/scripts/fix-lock.cjs" "$SKILL_DIR/scripts/triage.cjs" "$SKILL_DIR/scripts/doc-lookup.cjs"
206
+ ls "$SKILL_DIR/scripts/run-bug-hunter.cjs" "$SKILL_DIR/scripts/bug-hunter-state.cjs" "$SKILL_DIR/scripts/delta-mode.cjs" "$SKILL_DIR/scripts/payload-guard.cjs" "$SKILL_DIR/scripts/fix-lock.cjs" "$SKILL_DIR/scripts/triage.cjs" "$SKILL_DIR/scripts/doc-lookup.cjs" "$SKILL_DIR/scripts/pr-scope.cjs"
173
207
  ```
174
208
  If any are missing, stop and tell the user to update/reinstall the skill.
175
209
  Note: `code-index.cjs` is optional — enables cross-domain dependency analysis for boundary audits in large-codebase mode, but the pipeline works fully without it.
@@ -249,10 +283,10 @@ Before doing anything else, verify the environment:
249
283
 
250
284
  ### Step 1: Parse arguments, resolve target, and run triage
251
285
 
252
- Follow the rules in the **Target** section above. If in branch diff or staged mode, run the appropriate git command now, collect the file list, and apply the filter.
286
+ Follow the rules in the **Target** section above. If in PR review, branch diff, or staged mode, run the appropriate resolver command now, collect the file list, and apply the filter.
253
287
 
254
288
  Report to the user:
255
- - Mode (full project / directory / file / branch diff / staged)
289
+ - Mode (full project / directory / file / PR review / branch diff / staged)
256
290
  - Number of source files to scan (after filtering)
257
291
  - Number of files filtered out
258
292
 
@@ -296,7 +330,7 @@ Token estimate: ~[N] tokens for full pipeline
296
330
  ```
297
331
  ⚠️ This codebase has [N] source files (FILE_BUDGET: [B]).
298
332
  Single-pass mode will only cover a subset. Remove `--no-loop` to enable iterative coverage.
299
- Proceeding with partial scan — CRITICAL and HIGH domains only.
333
+ Proceeding with partial scan — highest-priority queued files only.
300
334
  ```
301
335
 
302
336
  **Triage replaces Recon's FILE_BUDGET computation.** Recon still runs for tech stack identification and pattern-based analysis, but it no longer needs to count files or compute the context budget — triage already did that, for free.
@@ -304,7 +338,10 @@ Proceeding with partial scan — CRITICAL and HIGH domains only.
304
338
  ### Step 1b: Generate threat model (if --threat-model)
305
339
 
306
340
  If `THREAT_MODEL_MODE=true`:
307
- 1. Check if `.bug-hunter/threat-model.md` already exists.
341
+ 1. Read the bundled local skill `SKILL_DIR/skills/threat-model-generation/SKILL.md` before generating the threat model. This keeps the enterprise security pack end-to-end connected to the main Bug Hunter flow.
342
+ 2. Use the bundled skill's Bug Hunter-native artifact conventions (`.bug-hunter/threat-model.md`, `.bug-hunter/security-config.json`).
343
+
344
+ 3. Check if `.bug-hunter/threat-model.md` already exists.
308
345
  - If it exists and was modified within the last 90 days: use it as-is. Set `THREAT_MODEL_AVAILABLE=true`.
309
346
  - If it exists but is >90 days old: warn user ("Threat model is N days old — regenerating"), regenerate.
310
347
  - If it doesn't exist: generate it.
@@ -321,7 +358,10 @@ If `THREAT_MODEL_MODE=false` but `.bug-hunter/threat-model.md` exists:
321
358
 
322
359
  ### Step 1c: Dependency scan (if --deps)
323
360
 
324
- If `DEP_SCAN=true`:
361
+ If `DEP_SCAN=true` or `SECURITY_REVIEW_MODE=true` or `PR_SECURITY_MODE=true`:
362
+ - Read the bundled local skill `SKILL_DIR/skills/security-review/SKILL.md` when running the broader enterprise security workflow.
363
+
364
+ If `DEP_SCAN=true`:
325
365
  ```bash
326
366
  node "$SKILL_DIR/scripts/dep-scan.cjs" --target "<TARGET_PATH>" --output .bug-hunter/dep-findings.json
327
367
  ```
@@ -335,15 +375,23 @@ If `.bug-hunter/dep-findings.json` exists with REACHABLE findings, include them
335
375
 
336
376
  ### Step 2: Read prompt files on demand (context efficiency)
337
377
 
378
+ **Security-pack routing:**
379
+ - If `PR_SECURITY_MODE=true`, read `SKILL_DIR/skills/commit-security-scan/SKILL.md` before the normal PR-review scan.
380
+ - If `SECURITY_REVIEW_MODE=true`, read `SKILL_DIR/skills/security-review/SKILL.md` before the broader security audit flow.
381
+ - If `VALIDATE_SECURITY_MODE=true`, read `SKILL_DIR/skills/vulnerability-validation/SKILL.md` before finalizing confirmed security findings.
382
+
338
383
  **MANDATORY**: You MUST read prompt files using the Read tool before passing them to subagents or executing them yourself. Do NOT skip this or act from memory. Use the absolute SKILL_DIR path resolved in Step 0.
339
384
 
340
385
  **Load only what you need for each phase — do NOT read all files upfront:**
341
386
 
342
387
  | Phase | Read These Files |
343
388
  |-------|-----------------|
344
- | Threat Model (Step 1b) | `prompts/threat-model.md` (only if THREAT_MODEL_MODE=true) |
389
+ | PR security review | `skills/commit-security-scan/SKILL.md` (if `PR_SECURITY_MODE=true` or the user asks for PR-focused security review) |
390
+ | Security review | `skills/security-review/SKILL.md` (if `SECURITY_REVIEW_MODE=true` or the user asks for an enterprise/full security audit) |
391
+ | Threat Model (Step 1b) | `skills/threat-model-generation/SKILL.md` + `prompts/threat-model.md` (only if THREAT_MODEL_MODE=true) |
345
392
  | Recon (Step 4) | `prompts/recon.md` (skip for single-file mode) |
346
393
  | Hunters (Step 5) | `prompts/hunter.md` + `prompts/doc-lookup.md` + `prompts/examples/hunter-examples.md` |
394
+ | Security validation | `skills/vulnerability-validation/SKILL.md` (if `VALIDATE_SECURITY_MODE=true` or confirmed security findings need exploitability validation) |
347
395
  | Skeptics (Step 6) | `prompts/skeptic.md` + `prompts/doc-lookup.md` + `prompts/examples/skeptic-examples.md` |
348
396
  | Referee (Step 7) | `prompts/referee.md` |
349
397
  | Fixers (Phase 2) | `prompts/fixer.md` + `prompts/doc-lookup.md` (only if FIX_MODE=true) |
@@ -362,8 +410,8 @@ read({ path: "$SKILL_DIR/prompts/hunter.md" })
362
410
  # - Apply the security checklist sweep
363
411
  # - Write each finding in BUG-N format
364
412
 
365
- # 3. Write your findings to disk:
366
- write({ path: ".bug-hunter/findings.md", content: "<your findings>" })
413
+ # 3. Write your canonical findings artifact to disk:
414
+ write({ path: ".bug-hunter/findings.json", content: "<your findings json>" })
367
415
  ```
368
416
 
369
417
  #### Example B: subagent dispatch
@@ -383,16 +431,16 @@ read({ path: "$SKILL_DIR/templates/subagent-wrapper.md" })
383
431
  # - {RISK_MAP} = <risk map from .bug-hunter/recon.md>
384
432
  # - {TECH_STACK} = <framework, auth, DB from Recon>
385
433
  # - {PHASE_SPECIFIC_CONTEXT} = <doc-lookup instructions from doc-lookup.md>
386
- # - {OUTPUT_FILE_PATH} = ".bug-hunter/findings.md"
434
+ # - {OUTPUT_FILE_PATH} = ".bug-hunter/findings.json"
387
435
  # - {SKILL_DIR} = <absolute path>
388
436
  # 4. Dispatch:
389
437
  subagent({
390
438
  agent: "hunter-agent",
391
439
  task: "<the filled template>",
392
- output: ".bug-hunter/findings.md"
440
+ output: ".bug-hunter/findings.json"
393
441
  })
394
442
  # 5. Read the output:
395
- read({ path: ".bug-hunter/findings.md" })
443
+ read({ path: ".bug-hunter/findings.json" })
396
444
  ```
397
445
 
398
446
  When launching subagents, always pass `SKILL_DIR` explicitly in the task context so prompt commands like `node "$SKILL_DIR/scripts/doc-lookup.cjs"` resolve correctly. The `context7-api.cjs` script is kept as a fallback if `doc-lookup.cjs` fails.
@@ -491,35 +539,49 @@ In a collapsed `<details>` section (for transparency).
491
539
  - Skeptic accuracy: X/Y correct challenges (Z%)
492
540
 
493
541
  ### 7. Coverage assessment
494
- - If ALL CRITICAL/HIGH files scanned: "Full coverage achieved."
542
+ - If ALL queued scannable source files scanned: "Full queued coverage achieved."
495
543
  - If any missed: list them with note about `--loop` mode.
496
544
 
497
545
  ### 7b. Coverage enforcement (mandatory)
498
546
 
499
- If the coverage assessment shows ANY CRITICAL or HIGH files were not scanned, the pipeline is NOT complete:
547
+ If the coverage assessment shows ANY queued scannable source files were not scanned, the pipeline is NOT complete:
500
548
 
501
- 1. If `LOOP_MODE=true` (default): the ralph-loop will automatically continue to the next iteration covering missed files. Call `ralph_done` to proceed to the next iteration. Do NOT output `<promise>COMPLETE</promise>` until all CRITICAL/HIGH files show DONE.
549
+ 1. If `LOOP_MODE=true` (default): the ralph-loop will automatically continue to the next iteration covering missed files. Call `ralph_done` to proceed to the next iteration. Do NOT output `<promise>COMPLETE</promise>` until all queued scannable source files show DONE.
502
550
 
503
551
  2. If `LOOP_MODE=false` (`--no-loop` was specified) AND missed files exist:
504
552
  - If total files ≤ FILE_BUDGET × 3: Output the report with a WARNING:
505
553
  ```
506
- ⚠️ PARTIAL COVERAGE: [N] CRITICAL/HIGH files were not scanned.
554
+ ⚠️ PARTIAL COVERAGE: [N] queued source files were not scanned.
507
555
  Run `/bug-hunter [path]` for complete coverage (loop is on by default).
508
556
  Unscanned files: [list them]
509
557
  ```
510
558
  - If total files > FILE_BUDGET × 3: The report MUST include:
511
559
  ```
512
560
  🚨 LARGE CODEBASE: [N] source files (FILE_BUDGET: [B]).
513
- Single-pass audit covered [X]% of CRITICAL/HIGH files.
561
+ Single-pass audit covered [X]% of queued source files.
514
562
  Use `/bug-hunter [path]` for full coverage (loop is on by default).
515
563
  ```
516
564
 
517
- 3. Do NOT claim "audit complete" or "full coverage achieved" unless ALL CRITICAL and HIGH files have status DONE. A partial audit is still valuable — report what you found honestly.
565
+ 3. Do NOT claim "audit complete" or "full coverage achieved" unless ALL queued scannable source files have status DONE. A partial audit is still valuable — report what you found honestly.
566
+
567
+ 4. Autonomous runs must keep descending through the remaining priority queue after the current prioritized chunk is done:
568
+ - Finish current CRITICAL/HIGH work first.
569
+ - Immediately continue with remaining MEDIUM files.
570
+ - Then continue with remaining LOW files.
571
+ - Only stop when the queue is exhausted, the user interrupts, or a hard blocker prevents safe progress.
518
572
 
519
573
  If zero bugs were confirmed, say so clearly — a clean report is a good result.
520
574
 
521
575
  **Routing after report:**
576
+ - If there are confirmed security findings AND (`VALIDATE_SECURITY_MODE=true` OR `PR_SECURITY_MODE=true` OR `SECURITY_REVIEW_MODE=true`):
577
+ - Read `SKILL_DIR/skills/vulnerability-validation/SKILL.md`.
578
+ - Re-check reachability, exploitability, PoC quality, and CVSS details for the confirmed security findings before finalizing the security summary.
579
+ - If confirmed bugs > 0 AND `PLAN_ONLY_MODE=true`:
580
+ - Build `fix-strategy.json` and `fix-plan.json`.
581
+ - Present the strategy clusters (safe autofix vs manual review vs larger refactor vs architectural remediation).
582
+ - Stop before the Fixer edits code.
522
583
  - If confirmed bugs > 0 AND `FIX_MODE=true`:
584
+ - Build and present `fix-strategy.json` first.
523
585
  - Auto-fix only `ELIGIBLE` bugs.
524
586
  - Apply canary-first rollout: fix top critical eligible subset first, verify, then continue remaining eligible fixes.
525
587
  - Keep `MANUAL_REVIEW` bugs in report only (do not auto-edit).
@@ -577,7 +639,12 @@ Rules for JSON output:
577
639
  - `dependencies` array: populated only if `--deps` was used and `.bug-hunter/dep-findings.json` exists.
578
640
  - This JSON enables CI/CD gating, dashboard ingestion, and downstream patch generation.
579
641
 
580
- Also write the final markdown report to `.bug-hunter/report.md` as the canonical human-readable output (in addition to displaying it to the user).
642
+ Also write the final markdown report to `.bug-hunter/report.md` as the
643
+ canonical human-readable output. Generate it from the JSON artifacts with:
644
+
645
+ ```bash
646
+ node "$SKILL_DIR/scripts/render-report.cjs" report ".bug-hunter/findings.json" ".bug-hunter/referee.json" > ".bug-hunter/report.md"
647
+ ```
581
648
 
582
649
  ---
583
650
 
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Bug Hunter"
3
+ short_description: "Find, verify, and auto-fix real code bugs"
4
+ default_prompt: "Use $bug-hunter to scan this codebase for confirmed runtime, logic, and security bugs."
package/bin/bug-hunter CHANGED
@@ -129,7 +129,7 @@ function doctor() {
129
129
  const nodeVersion = execFileSync('node', ['--version'], { encoding: 'utf8' }).trim();
130
130
  console.log(` [ok] Node.js ${nodeVersion}`);
131
131
  } catch {
132
- console.log(' [!!] Node.js not found — required for doc verification');
132
+ console.error(' [!!] Node.js not found — required for doc verification');
133
133
  issues++;
134
134
  }
135
135
 
@@ -160,7 +160,7 @@ function doctor() {
160
160
  const gitVersion = execFileSync('git', ['--version'], { encoding: 'utf8' }).trim();
161
161
  console.log(` [ok] ${gitVersion}`);
162
162
  } catch {
163
- console.log(' [!!] Git not found — required for fix pipeline');
163
+ console.error(' [!!] Git not found — required for fix pipeline');
164
164
  issues++;
165
165
  }
166
166
 
@@ -169,6 +169,7 @@ function doctor() {
169
169
  console.log(' Ready to hunt bugs.\n');
170
170
  } else {
171
171
  console.log(` ${issues} issue(s) found. Fix them for full functionality.\n`);
172
+ process.exit(1);
172
173
  }
173
174
  }
174
175
 
@@ -210,6 +211,12 @@ switch (command) {
210
211
  case 'info':
211
212
  info();
212
213
  break;
214
+ case '--version':
215
+ case '-v': {
216
+ const version = require('../package.json').version;
217
+ console.log(`bug-hunter ${version}`);
218
+ break;
219
+ }
213
220
  case '--help':
214
221
  case '-h':
215
222
  case undefined:
@@ -217,6 +224,5 @@ switch (command) {
217
224
  break;
218
225
  default:
219
226
  console.error(`Unknown command: ${command}`);
220
- usage();
221
227
  process.exit(1);
222
228
  }
Binary file