@drafthq/draft 3.1.5 → 3.2.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 (49) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/cli/src/hosts/claude-code.js +4 -1
  4. package/cli/src/installer.js +20 -5
  5. package/cli/src/lib/marker.js +93 -0
  6. package/core/shared/condensation.md +3 -2
  7. package/core/shared/git-report-metadata.md +3 -2
  8. package/core/shared/graph-query.md +140 -8
  9. package/core/shared/tool-resolver.md +71 -4
  10. package/core/templates/plan.md +3 -2
  11. package/integrations/agents/AGENTS.md +481 -106
  12. package/integrations/copilot/.github/copilot-instructions.md +481 -106
  13. package/package.json +2 -1
  14. package/scripts/lib.sh +11 -0
  15. package/scripts/tools/_graph_queries.sh +102 -0
  16. package/scripts/tools/cycle-detect.sh +18 -15
  17. package/scripts/tools/graph-callers.sh +71 -20
  18. package/scripts/tools/graph-deps.sh +76 -0
  19. package/scripts/tools/graph-errors.sh +97 -0
  20. package/scripts/tools/graph-hierarchy.sh +89 -0
  21. package/scripts/tools/graph-query.sh +124 -0
  22. package/scripts/tools/graph-risk.sh +81 -0
  23. package/scripts/tools/graph-search.sh +84 -0
  24. package/scripts/tools/graph-snapshot.sh +13 -1
  25. package/scripts/tools/graph-snippet.sh +92 -0
  26. package/scripts/tools/graph-tests.sh +112 -0
  27. package/scripts/tools/graph-traces.sh +83 -0
  28. package/scripts/tools/hotspot-rank.sh +43 -16
  29. package/scripts/tools/mermaid-from-graph.sh +31 -10
  30. package/scripts/tools/resolve-tools.sh +78 -0
  31. package/skills/adr/SKILL.md +3 -2
  32. package/skills/bughunt/SKILL.md +10 -1
  33. package/skills/coverage/SKILL.md +8 -3
  34. package/skills/debug/SKILL.md +16 -5
  35. package/skills/decompose/SKILL.md +29 -12
  36. package/skills/deep-review/SKILL.md +19 -6
  37. package/skills/deploy-checklist/SKILL.md +6 -5
  38. package/skills/graph/SKILL.md +15 -6
  39. package/skills/impact/SKILL.md +12 -1
  40. package/skills/implement/SKILL.md +20 -4
  41. package/skills/init/SKILL.md +17 -10
  42. package/skills/init/references/architecture-spec.md +17 -6
  43. package/skills/learn/SKILL.md +15 -4
  44. package/skills/quick-review/SKILL.md +13 -3
  45. package/skills/review/SKILL.md +32 -8
  46. package/skills/standup/SKILL.md +3 -2
  47. package/skills/status/SKILL.md +3 -2
  48. package/skills/tech-debt/SKILL.md +20 -6
  49. package/skills/upload/SKILL.md +3 -2
@@ -133,9 +133,21 @@ If one of these applies, route directly to the specialist workflow and stop this
133
133
  - Keep matching invariants as **active constraints** for this task — these govern code generation, not just review
134
134
  - If invariants reference lock ordering, fail-closed behavior, or data integrity rules: these are non-negotiable during implementation
135
135
  9. **Load graph context** (if `draft/graph/schema.yaml` exists):
136
- - Run `scripts/tools/hotspot-rank.sh --repo .` — check if any files this task will modify appear as hotspots
136
+
137
+ First resolve the bundled helpers:
138
+
139
+ ```bash
140
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
141
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
142
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
143
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
144
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
145
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
146
+ ```
147
+
148
+ - Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — check if any files this task will modify appear as hotspots
137
149
  - If modifying a hotspot file (high fanIn), warn: "This task modifies {file} (fanIn={N}). Changes here affect many downstream files. Consider running a graph impact query."
138
- - Query `scripts/tools/graph-impact.sh`/`graph-callers.sh` for the module(s) being modified — gives file-level dependency context
150
+ - Query `"$DRAFT_TOOLS/graph-impact.sh"`/`"$DRAFT_TOOLS/graph-callers.sh"` for the module(s) being modified — gives file-level dependency context
139
151
  - See `core/shared/graph-query.md` for on-demand query subroutines (callers, impact)
140
152
  10. Update the track's entry in `draft/tracks.md` from `[ ]` to `[~]` In Progress
141
153
 
@@ -625,9 +637,13 @@ After a phase passes review, refresh `metadata.json.impact` so future tracks can
625
637
  ```
626
638
  That is the `files_touched` list. Derive `modules_touched` as the unique top-level path segments (e.g. `auth/login.go` → `auth`).
627
639
 
628
- 2. **Compute downstream blast radius (graph-aware, optional):** If `draft/graph/schema.yaml` exists, for each file in `files_touched` query:
640
+ 2. **Compute downstream blast radius (graph-aware, optional):** If `draft/graph/schema.yaml` exists, for each file in `files_touched` query (this runs in its own Bash session — re-resolve the helpers):
629
641
  ```bash
630
- scripts/tools/graph-impact.sh --repo . --file <path>
642
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
643
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
644
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
645
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
646
+ "$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>
631
647
  ```
632
648
  Aggregate across all files: `downstream_files` = total unique downstream files (deduped), `downstream_modules` = union of `affected_modules`, `max_depth` = max across queries, `by_category` = sum of each query's `by_category`. If the graph is absent, leave these fields as zeros / empty arrays — the snapshot still records the directly-touched files.
633
649
 
@@ -491,8 +491,15 @@ The knowledge-graph engine `codebase-memory-mcp` is Draft's **default** capabili
491
491
  One command resolves ROOT, ensures the engine, builds the whole-repo spine, and — in a sub-module — builds the module snapshot and writes the `root-link.json` pointer:
492
492
 
493
493
  ```bash
494
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
495
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
496
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
497
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
498
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
499
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
500
+
494
501
  # Add --module-only to skip touching the root (link marked "pending").
495
- if scripts/tools/graph-init.sh --scope .; then
502
+ if "$DRAFT_TOOLS/graph-init.sh" --scope .; then
496
503
  echo "Graph memory ready under draft/graph/ (the root spine is the structural source of truth)."
497
504
  else
498
505
  echo "Graph engine unavailable — proceeding with degraded manual discovery. Downstream skills degrade gracefully."
@@ -506,7 +513,7 @@ fi
506
513
  Optionally record which engine was selected (usage-report contract):
507
514
 
508
515
  ```bash
509
- scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null || true
516
+ "$DRAFT_TOOLS/verify-graph-binary.sh" --repo . --json 2>/dev/null || true
510
517
  ```
511
518
 
512
519
  See `core/shared/graph-query.md` and `bin/README.md` for the query contract and engine resolution.
@@ -518,13 +525,13 @@ If indexing succeeds, `draft/graph/schema.yaml` is written and later steps query
518
525
  Pull the architecture view once and reuse it across phases:
519
526
 
520
527
  ```bash
521
- ARCH=$(scripts/tools/graph-arch.sh --repo .)
528
+ ARCH=$("$DRAFT_TOOLS/graph-arch.sh" --repo .)
522
529
  ```
523
530
 
524
531
  - `$ARCH | jq '.packages'` — module list with fan-in/out
525
532
  - `$ARCH | jq '.routes'` — detected service endpoints
526
533
  - `$ARCH | jq '.languages, .node_labels, .layers, .boundaries'` — language mix, node shape, layering
527
- - `scripts/tools/hotspot-rank.sh --repo . --top 20` — complexity/fan-in hotspots (live)
534
+ - `"$DRAFT_TOOLS/hotspot-rank.sh" --repo . --top 20` — complexity/fan-in hotspots (live)
528
535
 
529
536
  ### 3. Use graph data to accelerate Step 1.5
530
537
 
@@ -556,7 +563,7 @@ Apply tier table:
556
563
  Hold tier in memory. This governs: architecture.md length minimum, .ai-context.md budget, and module deep-dive depth.
557
564
 
558
565
  **Step 1.4.6 — Build Module Priority List:**
559
- From `scripts/tools/hotspot-rank.sh --repo .`: count hotspot symbols per module.
566
+ From `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`: count hotspot symbols per module.
560
567
  From `$ARCH | jq '.packages[]'`: read `fan_in` per module.
561
568
  Rank modules by: `(hotspot_count × 2) + fan_in_count`.
562
569
  Top-ranked modules drive Section 6 deep-dive ordering and depth. Modules ranked zero on both: summary treatment only.
@@ -567,7 +574,7 @@ Query for diagram content and write into architecture.md slots using the standar
567
574
 
568
575
  For Section 4.4 (module-deps slot):
569
576
  ```bash
570
- scripts/tools/mermaid-from-graph.sh --repo . --diagram module-deps
577
+ "$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram module-deps
571
578
  ```
572
579
  The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on exit 2). Write between the markers:
573
580
  ```
@@ -577,7 +584,7 @@ The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on e
577
584
  ```
578
585
 
579
586
  For Section 20 (hotspots slot):
580
- Run `scripts/tools/hotspot-rank.sh --repo . --top 10`, take the top 10 by fanIn, build a markdown table:
587
+ Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo . --top 10`, take the top 10 by fanIn, build a markdown table:
581
588
  ```
582
589
  <!-- GRAPH:hotspots:START -->
583
590
  | Symbol | fanIn |
@@ -589,7 +596,7 @@ Run `scripts/tools/hotspot-rank.sh --repo . --top 10`, take the top 10 by fanIn,
589
596
 
590
597
  For Appendix E (proto-map slot):
591
598
  ```bash
592
- scripts/tools/mermaid-from-graph.sh --repo . --diagram proto-map
599
+ "$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram proto-map
593
600
  ```
594
601
  The tool emits a ` ```mermaid ``` ` block from detected routes (empty stub if none). Write:
595
602
  ```
@@ -666,7 +673,7 @@ For tier 3+, readers run simultaneously; wall clock = slowest reader, not the su
666
673
  The engine is already indexed. Query it live throughout this protocol (reuse `$ARCH` from Step 1.4.2):
667
674
  - `$ARCH | jq '.packages'` — module list with `.fan_in`/`.fan_out` (for grouping)
668
675
  - `$ARCH | jq '.languages, .node_labels'` — file/symbol counts, tier metrics
669
- - `scripts/tools/hotspot-rank.sh --repo .` — top hotspot symbols per module (feed to readers)
676
+ - `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — top hotspot symbols per module (feed to readers)
670
677
 
671
678
  #### Phase 1: Spawn Parallel Module Readers
672
679
 
@@ -793,7 +800,7 @@ If any reader agent fails to produce valid JSON after one retry:
793
800
  When the Agent tool is unavailable or reader agents fail after retry, write `draft/architecture.md` using the **10-section graph-primary structure** (checklist above + `core/templates/architecture.md`). Do not use legacy 28-section or Pass 1/2/3 volume protocols.
794
801
 
795
802
  1. Use the ranked module list from Step 1.4.6 (graph-first — do not re-scan by directory if Phase 0 succeeded).
796
- 2. For each top module (up to 20 by fan-in), query the engine for its symbols/callers (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, or `$ARCH | jq '.packages[] | select(.name=="<m>")'`), read the hotspot files and 3–5 key sources; embed graph blocks and at least one workflow/state diagram per significant module inside §4–§8 as appropriate.
803
+ 2. For each top module (up to 20 by fan-in), query the engine for its symbols/callers (`"$DRAFT_TOOLS/graph-callers.sh"`, `"$DRAFT_TOOLS/graph-impact.sh"`, or `$ARCH | jq '.packages[] | select(.name=="<m>")'`), read the hotspot files and 3–5 key sources; embed graph blocks and at least one workflow/state diagram per significant module inside §4–§8 as appropriate.
797
804
  3. Always include §9 Graph Coverage Gaps and §10 Relationship when the Context Audit requires them.
798
805
  4. Run Completion Verification (defined later in this skill) before condensation. Fidelity, provenance, and gap honesty block completion — not line counts.
799
806
 
@@ -275,7 +275,18 @@ Only when material: authentication/authorization checkpoints, distributed transa
275
275
 
276
276
  **Core rule:** The graph is the source of truth for structure. LLM synthesis exists only to interpret the graph into actionable design understanding — primarily via one accurate workflow or state diagram per module — plus tiny supporting notes. The previous volume-oriented deep-dive expectations are superseded.
277
277
 
278
- For each module returned by `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'`, produce a subsection whose **primary content** is the deterministic graph block followed by one synthesized behavioral diagram. Every module gets a slot; do not sample. The block's fan-in/out and node counts come from `.packages[]`; public API and key call edges come from live per-package queries (`scripts/tools/graph-callers.sh`, `graph-impact.sh`) and `scripts/tools/hotspot-rank.sh --repo .`.
278
+ First resolve the bundled helpers:
279
+
280
+ ```bash
281
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
282
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
283
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
284
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
285
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
286
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
287
+ ```
288
+
289
+ For each module returned by `"$DRAFT_TOOLS/graph-arch.sh" --repo . | jq '.packages[]'`, produce a subsection whose **primary content** is the deterministic graph block followed by one synthesized behavioral diagram. Every module gets a slot; do not sample. The block's fan-in/out and node counts come from `.packages[]`; public API and key call edges come from live per-package queries (`"$DRAFT_TOOLS/graph-callers.sh"`, `"$DRAFT_TOOLS/graph-impact.sh"`) and `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`.
279
290
 
280
291
  #### 7.{N} {module-name}
281
292
 
@@ -362,7 +373,7 @@ Regardless of tier, any directory whose name contains `ops`, `handlers`, `execut
362
373
  | ... | (enumerate ALL — no sampling, no "and others") | | | |
363
374
  ```
364
375
 
365
- Use `scripts/tools/graph-callers.sh --symbol <module>` or `scripts/tools/graph-arch.sh --repo .` to get the complete file list. Use `scripts/tools/hotspot-rank.sh --repo .` to flag high-complexity operations.
376
+ Use `"$DRAFT_TOOLS/graph-callers.sh" --symbol <module>` or `"$DRAFT_TOOLS/graph-arch.sh" --repo .` to get the complete file list. Use `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to flag high-complexity operations.
366
377
 
367
378
  #### Example: Full Sub-Module Treatment for `icebox/` (917 files)
368
379
 
@@ -516,10 +527,10 @@ Include architecturally significant implementations (high fan-in, core extension
516
527
  | (enumerate ALL — use hotspot-rank.sh and graph-callers.sh / get_architecture for file list and line counts) |
517
528
  ```
518
529
 
519
- > **MANDATORY (graph data)**: Query `scripts/tools/graph-arch.sh --repo .` or
520
- > `scripts/tools/graph-callers.sh --symbol <module>` to get the complete file list with line counts.
530
+ > **MANDATORY (graph data)**: Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` or
531
+ > `"$DRAFT_TOOLS/graph-callers.sh" --symbol <module>` to get the complete file list with line counts.
521
532
  > Filter for files in operation sub-directories (paths containing `/ops/`,
522
- > `/handlers/`, `/executors/`, `/workers/`). Use `scripts/tools/hotspot-rank.sh --repo .` to flag
533
+ > `/handlers/`, `/executors/`, `/workers/`). Use `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to flag
523
534
  > high-complexity operations (high line count or fanIn). Do NOT skip this step — incomplete
524
535
  > catalogs cause AI agents to reinvent existing functionality.
525
536
 
@@ -1214,7 +1225,7 @@ Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (
1214
1225
 
1215
1226
  **FAILURE 4 — Missing Sub-Modules:**
1216
1227
  Detection: A module with 100+ source files (check graph data) has no Sub-Module Structure table.
1217
- Fix: Query `scripts/tools/graph-arch.sh --repo .` or `scripts/tools/graph-callers.sh --symbol <name>`, group results by immediate sub-directory, and generate the table with file counts and one-line role descriptions per sub-directory.
1228
+ Fix: Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` or `"$DRAFT_TOOLS/graph-callers.sh" --symbol <name>`, group results by immediate sub-directory, and generate the table with file counts and one-line role descriptions per sub-directory.
1218
1229
 
1219
1230
  **FAILURE 4b — Shallow Sub-Module Treatment:**
1220
1231
  Detection: Large sub-modules (50+ files) listed only as table rows with no dedicated deep-dive subsection. Or ops/handler directories have no operation catalog.
@@ -9,10 +9,21 @@ Scan the codebase to discover recurring coding patterns and update `draft/guardr
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before pattern scanning)
11
11
 
12
+ First resolve the bundled helpers:
13
+
14
+ ```bash
15
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
16
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
17
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
18
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
21
+ ```
22
+
12
23
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Use the graph to:
13
24
 
14
- 1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `scripts/tools/graph-arch.sh --repo .` (preferred over `find`).
15
- 2. Prioritize hotspots via `scripts/tools/hotspot-rank.sh --repo .` — patterns in high-fanIn files are more impactful when learned.
25
+ 1. Enumerate a module's symbols/files via `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` and `"$DRAFT_TOOLS/graph-arch.sh" --repo .` (preferred over `find`).
26
+ 2. Prioritize hotspots via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — patterns in high-fanIn files are more impactful when learned.
16
27
  3. For TS/Python/Go/C/C++, use `*-index.jsonl` to identify class/function definitions rather than re-discovering them via regex.
17
28
 
18
29
  Filesystem `find` for source discovery (Step 2.1) is permitted **as a complement** to the graph for languages not covered by indexes (e.g. Ruby, Java without ctags). Record the rationale in the Graph Usage Report.
@@ -246,10 +257,10 @@ git log --follow --oneline -1 -- {file_containing_pattern}
246
257
 
247
258
  ### 2.7: Graph-Aware Severity Enrichment
248
259
 
249
- If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `scripts/tools/hotspot-rank.sh --repo .`.
260
+ If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`.
250
261
 
251
262
  For each anti-pattern candidate from Step 2.2:
252
- 1. Check if any evidence files appear in the hotspot output from `scripts/tools/hotspot-rank.sh --repo .`
263
+ 1. Check if any evidence files appear in the hotspot output from `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`
253
264
  2. Take the highest fanIn value across all evidence files:
254
265
  - fanIn ≥ 10 → `graph_severity: critical` (breakage propagates to many callers)
255
266
  - fanIn 5–9 → `graph_severity: high`
@@ -11,8 +11,18 @@ You are performing a lightweight, ad-hoc code review. This is the fast alternati
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Quick-review keeps the graph load light:
13
13
 
14
- 1. Always run `scripts/tools/hotspot-rank.sh --repo .` for every changed file (Step 2 blast-radius pre-check below).
15
- 2. If a finding spans more than one file, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
14
+ First resolve the bundled helpers:
15
+ ```bash
16
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
17
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
18
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
21
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
22
+ ```
23
+
24
+ 1. Always run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` for every changed file (Step 2 blast-radius pre-check below).
25
+ 2. If a finding spans more than one file, run `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
16
26
 
17
27
  Filesystem `grep` is reserved for source-text scans (literal strings, regex patterns). Symbol and caller discovery go through the graph.
18
28
 
@@ -70,7 +80,7 @@ Determine the diff to review:
70
80
 
71
81
  ## Step 2: Blast Radius Pre-check (if `draft/graph/schema.yaml` exists)
72
82
 
73
- Before the four-dimension review, run `scripts/tools/hotspot-rank.sh --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
83
+ Before the four-dimension review, run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
74
84
 
75
85
  ```
76
86
  ⚠ HIGH IMPACT: {file} is a high-fanIn hotspot (fanIn={N}). Changes here propagate to many callers — review with extra care.
@@ -11,9 +11,19 @@ You are conducting a code review using Draft's Context-Driven Development method
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Stage 1 (Automated Validation) **starts from the graph**:
13
13
 
14
- 1. Run blast-radius assessment via `scripts/tools/hotspot-rank.sh --repo .` and `scripts/tools/graph-impact.sh` (see Stage 1).
15
- 2. For each changed file with non-trivial diff size, run `scripts/tools/graph-impact.sh --repo . --file <path>` to obtain the affected module set deterministically.
16
- 3. For each public symbol modified, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
14
+ First resolve the bundled helpers:
15
+ ```bash
16
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
17
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
18
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
21
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
22
+ ```
23
+
24
+ 1. Run blast-radius assessment via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` and `"$DRAFT_TOOLS/graph-impact.sh"` (see Stage 1).
25
+ 2. For each changed file with non-trivial diff size, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to obtain the affected module set deterministically.
26
+ 3. For each public symbol modified, run `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
17
27
 
18
28
  Filesystem `grep` is reserved for source-text scans (string literals, log messages, regex matches in code) — not for discovering modules, files, or callers when the graph can answer.
19
29
 
@@ -369,10 +379,21 @@ Load plugin guardrails before scanning: `core/guardrails/review-checks.md` (RC-#
369
379
  For the files changed in the diff, perform static checks using `grep` or similar tools:
370
380
 
371
381
  - **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
382
+
383
+ First resolve the bundled helpers:
384
+ ```bash
385
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
386
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
387
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
388
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
389
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
390
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
391
+ ```
392
+
372
393
  - List all changed files from the diff
373
- - For each changed file, check if it appears in `scripts/tools/hotspot-rank.sh --repo .` output — if yes, record its `fanIn` value
394
+ - For each changed file, check if it appears in `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` output — if yes, record its `fanIn` value
374
395
  - Classify: files with fanIn in the top 20% of the hotspot output = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in output = **STANDARD**
375
- - For any file in a HIGH or MEDIUM module, query `scripts/tools/graph-arch.sh --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
396
+ - For any file in a HIGH or MEDIUM module, query `"$DRAFT_TOOLS/graph-arch.sh" --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
376
397
  - Include a `Blast Radius` line in the Stage 1 report summary: `Blast Radius: HIGH | MEDIUM | STANDARD — <N> changed files affect high-fanIn modules: [file list]`
377
398
  - If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
378
399
  - **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
@@ -381,7 +402,7 @@ For the files changed in the diff, perform static checks using `grep` or similar
381
402
  - **Graph Boundary Check** (if `draft/graph/schema.yaml` exists) `[RC-013]`:
382
403
  - For each changed file, identify its module from the graph
383
404
  - Check if any new cross-module includes were added in the diff
384
- - Verify they follow the established dependency direction from `scripts/tools/graph-arch.sh --repo .` package fan-in/out
405
+ - Verify they follow the established dependency direction from `"$DRAFT_TOOLS/graph-arch.sh" --repo .` package fan-in/out
385
406
  - Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
386
407
  - Check if changes introduce files in modules listed in graph cycles — flag as higher risk
387
408
  - **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
@@ -1106,8 +1127,11 @@ As the last step after saving the review report, emit a metrics record. Best-eff
1106
1127
 
1107
1128
  **Emit call:**
1108
1129
  ```bash
1109
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
1110
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
1130
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
1131
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
1132
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
1133
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
1134
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
1111
1135
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
1112
1136
  [ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
1113
1137
  '{"skill":"review","track_id":"<id_or_null>","stage_reached":"<stage>","verdict":"<v>","critical_count":<N>,"important_count":<N>,"blast_radius":"<br>","graph_queries":<N>,"fallback_grep_count":<N>}'
@@ -54,8 +54,9 @@ Check for arguments:
54
54
  **Preferred:** invoke `parse-git-log.sh` — it parses conventional commits into structured JSONL `{sha,type,scope,track_id,subject,author,timestamp,files_changed}`, eliminating ambiguity in `type(track-id): subject` parsing. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
55
55
 
56
56
  ```bash
57
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
58
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
57
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
58
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
59
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
59
60
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
60
61
  if [ -x "$DRAFT_TOOLS/parse-git-log.sh" ]; then
61
62
  bash "$DRAFT_TOOLS/parse-git-log.sh" --since "24 hours ago" --author "$(git config user.name)"
@@ -44,8 +44,9 @@ Display a comprehensive overview of project progress.
44
44
  If `parse-reports.sh` and `freshness-check.sh` are available, gather structured signals to enrich the status output (severity counts per track, stale `draft/` docs). Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
45
45
 
46
46
  ```bash
47
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
48
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
47
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
48
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
49
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
49
50
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
50
51
 
51
52
  # Per-track report severity rollup (bughunt, review, tech-debt, etc.):
@@ -9,12 +9,23 @@ You are conducting a technical debt analysis to catalog, prioritize, and plan re
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before debt scan)
11
11
 
12
+ First resolve the bundled helpers:
13
+
14
+ ```bash
15
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
16
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
17
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
18
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
21
+ ```
22
+
12
23
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Tech-debt prioritization is fundamentally driven by graph data:
13
24
 
14
- 1. Run `scripts/tools/hotspot-rank.sh --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
15
- 2. Query `scripts/tools/graph-arch.sh --repo .` and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
16
- 3. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
17
- 4. For each catalogued finding, run `scripts/tools/graph-impact.sh --repo . --file <path>` so the remediation plan includes blast-radius.
25
+ 1. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
26
+ 2. Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` and run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` — flag debt in modules involved in cycles as higher priority.
27
+ 3. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
28
+ 4. For each catalogued finding, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` so the remediation plan includes blast-radius.
18
29
 
19
30
  Filesystem `grep` (e.g. `scan-markers.sh`) is still primary for TODO/FIXME marker discovery — markers are source-text, not graph-derived. The graph governs **prioritization**, the marker scan governs **discovery**.
20
31
 
@@ -82,8 +93,11 @@ Scan the codebase systematically across all seven categories. For each finding,
82
93
  For TODO/FIXME/HACK/XXX/DEPRECATED markers, prefer the deterministic `scan-markers.sh` wrapper — it emits JSON `[{path,line,marker,text,sha,author,introduced,age_days}]` with blame ages already computed. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
83
94
 
84
95
  ```bash
85
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
86
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
96
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
97
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
98
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
99
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
100
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
87
101
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
88
102
  [ -x "$DRAFT_TOOLS/scan-markers.sh" ] && bash "$DRAFT_TOOLS/scan-markers.sh" --root .
89
103
  # Fallback when script unavailable: grep -rn 'TODO\|FIXME\|HACK\|XXX\|DEPRECATED' .
@@ -52,8 +52,9 @@ Run the WS-9 chain from [verification-gates.md](../../core/shared/verification-g
52
52
 
53
53
  ```bash
54
54
  TRACK_DIR="draft/tracks/<id>"
55
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
56
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
55
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
56
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
57
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
57
58
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
58
59
 
59
60
  "$DRAFT_TOOLS/check-track-hygiene.sh" "$TRACK_DIR"