@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
@@ -1,27 +1,33 @@
1
1
  #!/usr/bin/env bash
2
- # hotspot-rank.sh — emit complexity/fan-in-ranked symbols from the knowledge graph.
2
+ # hotspot-rank.sh — complexity-weighted hotspot ranking from the knowledge graph.
3
3
  #
4
- # Backed by the codebase-memory-mcp engine (get_architecture, server-computed
5
- # hotspot ranking by fan-in). Indexes the repo on demand if needed.
4
+ # Backed by the codebase-memory-mcp engine. Fan-in alone is skewed by
5
+ # name-collision generics (e.g. a logger `info` with fan_in 1022 but complexity 0),
6
+ # so graph-tooling-v2 Phase 4 blends the engine's pre-computed complexity and
7
+ # cognitive scores into the rank: score = fanIn + complexity + cognitive. Entry
8
+ # points are annotated. fan_in still comes from the engine's server-computed
9
+ # hotspot ranking; the per-symbol complexity/cognitive/is_entry_point come from a
10
+ # node-property query and are merged in.
6
11
  #
7
12
  # Usage:
8
13
  # scripts/tools/hotspot-rank.sh [--repo DIR] [--top N]
9
14
  #
10
- # Output: JSON {hotspots:[{id, name, fanIn}], source}.
15
+ # Output: JSON {hotspots:[{id, name, fanIn, complexity, cognitive, score,
16
+ # isEntryPoint}], source}.
11
17
  # source = "memory-graph" | "unavailable"
12
18
  #
13
19
  # Exit codes: 0 OK, 1 invocation error, 2 graph engine/data unavailable.
14
20
  set -euo pipefail
15
21
 
16
- # shellcheck source=_lib.sh
17
- source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
22
+ # shellcheck source=_graph_queries.sh
23
+ source "$(dirname "${BASH_SOURCE[0]}")/_graph_queries.sh"
18
24
 
19
25
  REPO="."
20
26
  TOP=0
21
27
 
22
28
  usage() {
23
29
  cat <<'EOF'
24
- hotspot-rank.sh — fan-in-ranked symbols from the knowledge graph.
30
+ hotspot-rank.sh — complexity-weighted hotspot ranking from the knowledge graph.
25
31
 
26
32
  Usage:
27
33
  scripts/tools/hotspot-rank.sh [--repo DIR] [--top N]
@@ -31,8 +37,8 @@ Flags:
31
37
  --top N Keep only top N hotspots (default: 0 = all).
32
38
  --help Show this help.
33
39
 
34
- Output: JSON {hotspots:[{id, name, fanIn}], source}.
35
- source = "memory-graph" | "unavailable"
40
+ Output: JSON {hotspots:[{id, name, fanIn, complexity, cognitive, score,
41
+ isEntryPoint}], source}. Ranked by score = fanIn + complexity + cognitive.
36
42
 
37
43
  Exit 0 with results, exit 2 with {"hotspots":[],"source":"unavailable"} when the
38
44
  graph engine is unavailable.
@@ -68,10 +74,31 @@ PROJECT="$(memory_ensure_index "$REPO_ABS" || true)"
68
74
 
69
75
  ARCH_JSON="$(memory_cli get_architecture "{\"project\":\"$PROJECT\",\"aspects\":[\"hotspots\"]}" || true)"
70
76
  [[ -n "$ARCH_JSON" ]] || unavailable
71
-
72
- echo "$ARCH_JSON" | jq --argjson top "$TOP" '
73
- {
74
- hotspots: ([ (.hotspots // [])[] | {id: .qualified_name, name: .name, fanIn: .fan_in} ]
75
- | if $top > 0 then .[0:$top] else . end),
76
- source: "memory-graph"
77
- }'
77
+ echo "$ARCH_JSON" | jq -e . >/dev/null 2>&1 || unavailable
78
+
79
+ # Pre-computed complexity/cognitive/is_entry_point per symbol (merged onto fan-in).
80
+ PROPS_JSON="$(gq_run "$PROJECT" "$(gq_q_node_props)" || echo '{"rows":[]}')"
81
+ echo "$PROPS_JSON" | jq -e . >/dev/null 2>&1 || PROPS_JSON='{"rows":[]}'
82
+
83
+ # Merge via temp files (the props row set can exceed argv limits on large repos).
84
+ TMP_ARCH="$(mktemp)"; TMP_PROPS="$(mktemp)"
85
+ trap 'rm -f "$TMP_ARCH" "$TMP_PROPS"' EXIT
86
+ printf '%s' "$ARCH_JSON" > "$TMP_ARCH"
87
+ printf '%s' "$PROPS_JSON" > "$TMP_PROPS"
88
+
89
+ jq -n --slurpfile arch "$TMP_ARCH" --slurpfile props "$TMP_PROPS" --argjson top "$TOP" '
90
+ (($props[0].rows) // []) as $prows
91
+ | (reduce $prows[] as $r ({};
92
+ .[$r[0]] = {c:((($r[1]) // "0") | tonumber? // 0),
93
+ cog:((($r[2]) // "0") | tonumber? // 0),
94
+ ep:((($r[3]) | tostring) == "true")})) as $pmap
95
+ | [ (($arch[0].hotspots) // [])[]
96
+ | (.qualified_name) as $q
97
+ | ($pmap[$q] // {c:0, cog:0, ep:false}) as $p
98
+ | {id:$q, name:.name, fanIn:(.fan_in // 0),
99
+ complexity:$p.c, cognitive:$p.cog,
100
+ score:((.fan_in // 0) + $p.c + $p.cog),
101
+ isEntryPoint:$p.ep} ]
102
+ | sort_by(-.score)
103
+ | (if $top > 0 then .[0:$top] else . end) as $h
104
+ | {hotspots:$h, source:"memory-graph"}'
@@ -1,21 +1,27 @@
1
1
  #!/usr/bin/env bash
2
2
  # mermaid-from-graph.sh — emit Mermaid diagrams from the knowledge graph.
3
3
  #
4
- # Backed by the codebase-memory-mcp engine. Two diagrams:
5
- # module-deps : file co-change coupling (FILE_CHANGES_WITH edges) as a flowchart.
4
+ # Backed by the codebase-memory-mcp engine. Diagrams:
5
+ # module-deps : real file/module dependency graph (IMPORTS edges) as a flowchart.
6
+ # This is the auto-derived dependency diagram for architecture.md
7
+ # §9 (graph-tooling-v2 Phase 4) — it replaces the prior co-change
8
+ # proxy with actual import edges.
9
+ # co-change : file co-change coupling (FILE_CHANGES_WITH edges) — the hidden,
10
+ # git-history dependency proxy (the prior module-deps behavior,
11
+ # still available explicitly).
6
12
  # proto-map : detected service routes (Route nodes) as a flowchart.
7
13
  #
8
14
  # When the engine is unavailable, emits an empty diagram stub and exits 2 so
9
15
  # consuming skills can degrade gracefully.
10
16
  #
11
17
  # Usage:
12
- # scripts/tools/mermaid-from-graph.sh [--repo DIR] [--diagram module-deps|proto-map]
18
+ # scripts/tools/mermaid-from-graph.sh [--repo DIR] [--diagram module-deps|co-change|proto-map]
13
19
  #
14
20
  # Exit codes: 0 OK, 1 invocation error, 2 graph engine/data unavailable.
15
21
  set -euo pipefail
16
22
 
17
- # shellcheck source=_lib.sh
18
- source "$(dirname "${BASH_SOURCE[0]}")/_lib.sh"
23
+ # shellcheck source=_graph_queries.sh
24
+ source "$(dirname "${BASH_SOURCE[0]}")/_graph_queries.sh"
19
25
 
20
26
  REPO="."
21
27
  DIAGRAM="module-deps"
@@ -25,11 +31,12 @@ usage() {
25
31
  mermaid-from-graph.sh — emit Mermaid diagrams from the knowledge graph.
26
32
 
27
33
  Usage:
28
- scripts/tools/mermaid-from-graph.sh [--repo DIR] [--diagram module-deps|proto-map]
34
+ scripts/tools/mermaid-from-graph.sh [--repo DIR] [--diagram module-deps|co-change|proto-map]
29
35
 
30
36
  Flags:
31
37
  --repo DIR Repository root (default: cwd).
32
- --diagram NAME module-deps (default) or proto-map.
38
+ --diagram NAME module-deps (default, IMPORTS edges), co-change
39
+ (FILE_CHANGES_WITH coupling), or proto-map (routes).
33
40
  --help Show this help.
34
41
 
35
42
  Exit 0 with diagram output, exit 2 with an empty stub when the engine is unavailable.
@@ -70,9 +77,22 @@ command -v jq >/dev/null 2>&1 || stub
70
77
  PROJECT="$(memory_ensure_index "$REPO_ABS" || true)"
71
78
  [[ -n "$PROJECT" ]] || stub
72
79
 
80
+ # module-deps: real IMPORTS edges (the auto-derived dependency graph). Self-imports
81
+ # (src == dst) are dropped so the diagram is a true cross-file graph. Capped at 40
82
+ # edges for readability.
73
83
  render_module_deps() {
74
- local q="MATCH (a:File)-[r:FILE_CHANGES_WITH]->(b:File) RETURN a.name AS src, b.name AS dst, r.coupling_score AS score ORDER BY r.coupling_score DESC LIMIT 40"
75
- local res; res="$(memory_cli query_graph "{\"project\":\"$PROJECT\",\"query\":\"$q\"}" || echo '{}')"
84
+ local res; res="$(gq_run "$PROJECT" "$(gq_q_imports)" || echo '{}')"
85
+ local edges; edges="$(echo "${res:-{\}}" | jq -r '
86
+ [ (.rows // [])[] | {s:(.[0]|tostring), d:(.[1]|tostring)}
87
+ | select(.s != "" and .d != "" and .s != .d) ]
88
+ | unique | .[0:40][] | " \"" + .s + "\" --> \"" + .d + "\""' 2>/dev/null || true)"
89
+ if [[ -z "$edges" ]]; then return 1; fi
90
+ printf '```mermaid\nflowchart LR\n%s\n```\n' "$edges"
91
+ }
92
+
93
+ # co-change: FILE_CHANGES_WITH coupling (the prior module-deps proxy).
94
+ render_co_change() {
95
+ local res; res="$(gq_run "$PROJECT" "$(gq_q_co_change)" || echo '{}')"
76
96
  local edges; edges="$(echo "${res:-{\}}" | jq -r '(.rows // [])[] | " \"" + (.[0]|tostring) + "\" --> \"" + (.[1]|tostring) + "\""' 2>/dev/null || true)"
77
97
  if [[ -z "$edges" ]]; then return 1; fi
78
98
  printf '```mermaid\nflowchart LR\n%s\n```\n' "$edges"
@@ -87,6 +107,7 @@ render_proto_map() {
87
107
 
88
108
  case "$DIAGRAM" in
89
109
  module-deps) render_module_deps || stub ;;
110
+ co-change) render_co_change || stub ;;
90
111
  proto-map) render_proto_map || stub ;;
91
- *) echo "Unknown --diagram '$DIAGRAM' (expected module-deps|proto-map)" >&2; exit 1 ;;
112
+ *) echo "Unknown --diagram '$DIAGRAM' (expected module-deps|co-change|proto-map)" >&2; exit 1 ;;
92
113
  esac
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+ # resolve-tools.sh — print the absolute path to Draft's bundled scripts/tools dir.
3
+ #
4
+ # Skills run with cwd = the user's project, and ${CLAUDE_PLUGIN_ROOT} is NOT exported
5
+ # into skill-driven Bash, so a bare `scripts/tools/foo.sh` invocation fails. This
6
+ # resolver finds the plugin's helper directory regardless of how Draft was installed.
7
+ # See core/shared/tool-resolver.md for the canonical procedure and the inline preamble
8
+ # skills embed (this script is the single source of truth for the resolution order).
9
+ #
10
+ # Usage:
11
+ # DRAFT_TOOLS="$(scripts/tools/resolve-tools.sh)" # prints the dir, exit 0 if found
12
+ # scripts/tools/resolve-tools.sh || echo "tools not found" # exit 1 if none exist
13
+ set -euo pipefail
14
+
15
+ case "${1:-}" in
16
+ -h|--help)
17
+ sed -n '2,13p' "$0" | sed 's/^# \{0,1\}//'
18
+ exit 0
19
+ ;;
20
+ esac
21
+
22
+ newest() {
23
+ # Echo the lexically-newest existing match of a glob (by version sort), or nothing.
24
+ # shellcheck disable=SC2086
25
+ ls -d $1 2>/dev/null | sort -V | tail -1
26
+ }
27
+
28
+ resolve() {
29
+ local d
30
+
31
+ # 1. Explicit override (testing / pinned installs).
32
+ d="${DRAFT_PLUGIN_ROOT:-}/scripts/tools"
33
+ [ -n "${DRAFT_PLUGIN_ROOT:-}" ] && [ -d "$d" ] && { printf '%s' "$d"; return 0; }
34
+
35
+ # 1b. Dev / dogfooding: cwd IS the draft repo. Guarded by this script's own
36
+ # presence so it can never misfire in a user project (which has no resolve-tools.sh).
37
+ [ -f "$PWD/scripts/tools/resolve-tools.sh" ] && { printf '%s' "$PWD/scripts/tools"; return 0; }
38
+
39
+ # 2. Install marker written by `draft install` (authoritative).
40
+ local marker="$HOME/.cache/draft/plugin-root"
41
+ if [ -f "$marker" ]; then
42
+ d="$(cat "$marker" 2>/dev/null)/scripts/tools"
43
+ [ -d "$d" ] && { printf '%s' "$d"; return 0; }
44
+ fi
45
+
46
+ # 3. ${CLAUDE_PLUGIN_ROOT} — set in hook/MCP contexts; harmless to probe.
47
+ d="${CLAUDE_PLUGIN_ROOT:-}/scripts/tools"
48
+ [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -d "$d" ] && { printf '%s' "$d"; return 0; }
49
+
50
+ # 4. Claude Code's own registry (authoritative installPath; needs jq).
51
+ local reg="$HOME/.claude/plugins/installed_plugins.json"
52
+ if command -v jq >/dev/null 2>&1 && [ -f "$reg" ]; then
53
+ local ip
54
+ ip="$(jq -r '.plugins | to_entries[] | select(.key|startswith("draft@")) | .value[0].installPath' \
55
+ "$reg" 2>/dev/null | head -1)"
56
+ [ -n "$ip" ] && [ -d "$ip/scripts/tools" ] && { printf '%s' "$ip/scripts/tools"; return 0; }
57
+ fi
58
+
59
+ # 5. Newest cache install (glob).
60
+ d="$(newest "$HOME/.claude/plugins/cache/*/draft/*/scripts/tools")"
61
+ [ -n "$d" ] && [ -d "$d" ] && { printf '%s' "$d"; return 0; }
62
+
63
+ # 6. Marketplace clone.
64
+ d="$(newest "$HOME/.claude/plugins/marketplaces/*draft*/scripts/tools")"
65
+ [ -n "$d" ] && [ -d "$d" ] && { printf '%s' "$d"; return 0; }
66
+
67
+ # 7. Cursor local install.
68
+ d="$HOME/.cursor/plugins/local/draft/scripts/tools"
69
+ [ -d "$d" ] && { printf '%s' "$d"; return 0; }
70
+
71
+ # 8. Dev / dogfooding (running inside the draft repo itself).
72
+ d="$PWD/scripts/tools"
73
+ [ -d "$d" ] && { printf '%s' "$d"; return 0; }
74
+
75
+ return 1
76
+ }
77
+
78
+ resolve
@@ -54,8 +54,9 @@ Check for arguments:
54
54
  If argument is `list`:
55
55
  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)):
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/adr-index.sh" ]; then
61
62
  bash "$DRAFT_TOOLS/adr-index.sh" --root draft/adrs
@@ -68,7 +68,16 @@ Read and follow the base procedure in `core/shared/draft-context-loading.md`.
68
68
  - **Leverage Storage Topology** — Identify data loss risks at each tier (cache eviction without writeback, event log gaps, missing archive)
69
69
  - **Leverage Consistency Boundaries** — Find bugs at eventual consistency seams (stale reads, lost events, missing reconciliation)
70
70
  - **Leverage Failure Recovery Matrix** — Verify idempotency claims, check for partial failure states without recovery paths
71
- - **Leverage Graph Data** (if `draft/graph/` exists) — Query `scripts/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 `scripts/tools/hotspot-rank.sh --repo .` to prioritize analysis of high-complexity, high-fanIn files. See `core/shared/graph-query.md`.
71
+ - **Leverage Graph Data** (if `draft/graph/` exists) — First resolve the bundled helpers:
72
+ ```bash
73
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
74
+ # 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"
76
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
77
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
78
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
79
+ ```
80
+ 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`.
72
81
  - **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.
73
82
 
74
83
  ### 2. Confirm Scope
@@ -33,8 +33,9 @@ If no active track and no argument provided:
33
33
  **Preferred:** use the deterministic `detect-test-framework.sh` wrapper — it emits JSON `{languages:[{language,framework,runner_command,test_globs,config_file}]}`. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
34
34
 
35
35
  ```bash
36
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
37
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
36
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
37
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
38
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
38
39
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
39
40
  [ -x "$DRAFT_TOOLS/detect-test-framework.sh" ] && \
40
41
  bash "$DRAFT_TOOLS/detect-test-framework.sh" --root .
@@ -73,7 +74,11 @@ Build the coverage command with the appropriate scope/filter flags.
73
74
  **Preferred:** invoke the normalized `run-coverage.sh` dispatcher — it dispatches to the language-specific runner and emits a normalized JSON `{language,tool,total:{lines,branches},per_file:[{path,lines,branches,uncovered_lines}]}`. This avoids per-language ad-hoc parsing in Step 5.
74
75
 
75
76
  ```bash
76
- # DRAFT_TOOLS resolved in Step 2 above
77
+ # Re-resolve helpers (this is a separate Bash session from Step 2).
78
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
79
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
80
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
81
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
77
82
  [ -x "$DRAFT_TOOLS/run-coverage.sh" ] && \
78
83
  bash "$DRAFT_TOOLS/run-coverage.sh" --root .
79
84
  ```
@@ -9,12 +9,23 @@ You are conducting a structured debugging session following systematic investiga
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before Isolate/Diagnose)
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. During Steps 3–4 (Isolate, Diagnose):
13
24
 
14
- 1. Locate the suspect file's module via `scripts/tools/graph-arch.sh --repo .` before tracing data flow.
15
- 2. Use `scripts/tools/graph-callers.sh --repo . --symbol <fn>` to enumerate call sites of suspect functions — not `grep`.
16
- 3. Use `scripts/tools/graph-impact.sh --repo . --file <path>` to size the blast radius before proposing a fix.
17
- 4. Run `scripts/tools/hotspot-rank.sh --repo .` to know whether the file is high-fanIn (any fix needs extra caution).
25
+ 1. Locate the suspect file's module via `"$DRAFT_TOOLS/graph-arch.sh" --repo .` before tracing data flow.
26
+ 2. Use `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <fn>` to enumerate call sites of suspect functions — not `grep`.
27
+ 3. Use `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to size the blast radius before proposing a fix.
28
+ 4. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to know whether the file is high-fanIn (any fix needs extra caution).
18
29
 
19
30
  Filesystem `grep` is reserved for source-text scans (literal error strings, stack-trace symbols when the graph misses). Use the fallback sentence on graph miss.
20
31
 
@@ -62,7 +73,7 @@ Key context for debugging:
62
73
  - `.ai-context.md` — Module boundaries, data flows, invariants (crucial for tracing)
63
74
  - `tech-stack.md` — Language-specific debugging tools and techniques
64
75
  - `guardrails.md` — Known anti-patterns that may be causing the issue
65
- - `draft/graph/` (MANDATORY when present) — Query `scripts/tools/graph-arch.sh --repo .` for dependency/module context and `scripts/tools/hotspot-rank.sh --repo .` for complexity awareness. Use `scripts/tools/graph-callers.sh --repo . --symbol <fn>` to find all callers, and `scripts/tools/graph-impact.sh --repo . --file <path>` to size blast radius before any fix. See [core/shared/graph-query.md](../../core/shared/graph-query.md).
76
+ - `draft/graph/` (MANDATORY when present) — Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for dependency/module context and `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` for complexity awareness. Use `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <fn>` to find all callers, and `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to size blast radius before any fix. See [core/shared/graph-query.md](../../core/shared/graph-query.md).
66
77
 
67
78
  ## Step 1: Parse Arguments
68
79
 
@@ -9,12 +9,23 @@ You are decomposing a project or track into modules with clear responsibilities,
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before any analysis)
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. Module identification (Step 3) and dependency mapping (Step 4) **start from the graph**:
13
24
 
14
- 1. Query `scripts/tools/graph-arch.sh --repo .` for the authoritative module list and fan-in/out.
15
- 2. Run `scripts/tools/hotspot-rank.sh --repo .` to identify candidate modules to split.
16
- 3. Use `scripts/tools/graph-callers.sh`/`graph-impact.sh` on demand for symbols/callers inside a candidate module.
17
- 4. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate existing cycles before proposing new boundaries.
25
+ 1. Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for the authoritative module list and fan-in/out.
26
+ 2. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to identify candidate modules to split.
27
+ 3. Use `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` on demand for symbols/callers inside a candidate module.
28
+ 4. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` to enumerate existing cycles before proposing new boundaries.
18
29
 
19
30
  Filesystem `grep`/`find` for module discovery is only permitted **after** a documented graph miss, using the fallback sentence `Graph returned no match for <X>; falling back to grep.` and recorded in the Graph Usage Report.
20
31
 
@@ -156,11 +167,11 @@ ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
156
167
 
157
168
  When graph data is available, the graph is the **primary** (not optional) source for module discovery — manual scanning above is reserved for the graph-miss fallback path:
158
169
 
159
- - **Module boundaries**: Query `scripts/tools/graph-arch.sh --repo .` — module list with node counts and per-language file counts
170
+ - **Module boundaries**: Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` — module list with node counts and per-language file counts
160
171
  - **Dependency edges**: Weighted inter-module dependencies with exact include counts — replaces manual import tracing
161
172
  - **Cycle detection**: Circular dependency paths already computed — use for identifying tight coupling and decomposition candidates
162
- - **Hotspots**: Run `scripts/tools/hotspot-rank.sh --repo .` — high-complexity files that may need further decomposition
163
- - **Per-module detail**: query `scripts/tools/graph-callers.sh`/`graph-impact.sh` for symbol/call detail within modules of interest
173
+ - **Hotspots**: Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — high-complexity files that may need further decomposition
174
+ - **Per-module detail**: query `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` for symbol/call detail within modules of interest
164
175
 
165
176
  This data is deterministic and exhaustive. The manual scanning recipes above only run **after** the graph misses on the concept the user named — and the miss must be reported in the Graph Usage Report footer. See [core/shared/graph-query.md](../../core/shared/graph-query.md) §Concept-to-Files Recipe.
166
177
 
@@ -404,8 +415,11 @@ After writing all generated files, strip trailing whitespace and blank lines at
404
415
  Resolve the script via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
405
416
 
406
417
  ```bash
407
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
408
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
418
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
419
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
420
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
421
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
422
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
409
423
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
410
424
  # Fix all generated markdown for this track:
411
425
  [ -x "$DRAFT_TOOLS/fix-whitespace.sh" ] && bash "$DRAFT_TOOLS/fix-whitespace.sh" --track <id>
@@ -452,7 +466,7 @@ references, sunset criteria) survive every regenerate. After rewriting:
452
466
  2. Update plan.md `generated_at:` to the current ISO-8601 timestamp.
453
467
  3. Ensure plan.md `generated_at` ≥ sibling hld.md / lld.md `generated_at`
454
468
  (the hygiene validator fails on stale plan).
455
- 4. Run `scripts/tools/check-track-hygiene.sh <track_dir>` and resolve any
469
+ 4. Run `"$DRAFT_TOOLS/check-track-hygiene.sh" <track_dir>` and resolve any
456
470
  findings before promoting status past `draft`.
457
471
 
458
472
  If the plan does not yet have the bracket markers (pre-2.0 track), insert
@@ -648,8 +662,11 @@ As the last step after the completion announcement, emit a metrics record. Best-
648
662
 
649
663
  **Emit call:**
650
664
  ```bash
651
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
652
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
665
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
666
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
667
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
668
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
669
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
653
670
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
654
671
  [ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
655
672
  '{"skill":"decompose","scope":"<scope>","track_id":"<id_or_null>","modules_count":<N>,"lld_generated":<bool>,"high_complexity_modules":<N>}'
@@ -11,10 +11,20 @@ Perform an exhaustive end-to-end lifecycle review of a service, component, or mo
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. Deep-review uses the graph to **narrow review scope** — a key 30–50% scope reduction:
13
13
 
14
- 1. Use `scripts/tools/graph-impact.sh`/`graph-callers.sh` and `scripts/tools/graph-arch.sh --repo .` for the audited module's structure — do not enumerate via `find`.
15
- 2. Run `scripts/tools/graph-impact.sh --repo . --file <each-changed-file>` per file in the diff (or per file in the module if no diff) to obtain the affected module set deterministically.
16
- 3. Run `scripts/tools/cycle-detect.sh --repo .` and flag any cycle that includes the audited module as Architecture Resilience finding.
17
- 4. Run `scripts/tools/hotspot-rank.sh --repo .` to identify high-fanIn files inside the module — these get deeper inspection.
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. Use `"$DRAFT_TOOLS/graph-impact.sh"`/`graph-callers.sh` and `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for the audited module's structure — do not enumerate via `find`.
25
+ 2. Run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <each-changed-file>` per file in the diff (or per file in the module if no diff) to obtain the affected module set deterministically.
26
+ 3. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` and flag any cycle that includes the audited module as Architecture Resilience finding.
27
+ 4. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to identify high-fanIn files inside the module — these get deeper inspection.
18
28
 
19
29
  Filesystem `grep` is reserved for source-text scans (API contract strings, secret patterns, log message audits). Module enumeration and caller tracing go through the graph.
20
30
 
@@ -318,8 +328,11 @@ As the last step after saving the deep-review report, emit a metrics record. Bes
318
328
 
319
329
  **Emit call:**
320
330
  ```bash
321
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
322
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
331
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
332
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
333
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
334
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
335
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
323
336
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
324
337
  [ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
325
338
  '{"skill":"deep-review","module":"<module>","phases_completed":<N>,"critical_count":<N>,"important_count":<N>,"sec_violations":<N>,"acid_violations":<N>,"graph_queries":<N>,"fallback_grep_count":<N>}'
@@ -11,9 +11,9 @@ You are generating a pre-deployment verification checklist customized to this pr
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. Use the graph to validate module boundaries before the deploy:
13
13
 
14
- 1. For each file in the deploy diff, run `scripts/tools/graph-impact.sh --repo . --file <path>` to enumerate the modules affected — flag any module **not** declared in `hld.md` §Detailed Design as a deployment-scope miss.
15
- 2. Run `scripts/tools/cycle-detect.sh --repo .` (and query `scripts/tools/graph-arch.sh --repo .` for the module overview) to ensure no fresh cycles were introduced after HLD sign-off.
16
- 3. Run `scripts/tools/hotspot-rank.sh --repo .` — any hotspot in the diff escalates the Resiliency row of Phase 0.
14
+ 1. For each file in the deploy diff, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to enumerate the modules affected — flag any module **not** declared in `hld.md` §Detailed Design as a deployment-scope miss.
15
+ 2. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` (and query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for the module overview) to ensure no fresh cycles were introduced after HLD sign-off.
16
+ 3. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — any hotspot in the diff escalates the Resiliency row of Phase 0.
17
17
 
18
18
  Filesystem `grep` is reserved for source-text scans (migration file names, flag-key strings). Module/impact discovery goes through the graph.
19
19
 
@@ -67,8 +67,9 @@ by validator.
67
67
  ```bash
68
68
  TRACK_DIR="$1" # absolute path to track-under-deploy, or .
69
69
 
70
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
71
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
70
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
71
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
72
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
72
73
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
73
74
 
74
75
  "$DRAFT_TOOLS/check-track-hygiene.sh" "$TRACK_DIR" || rc=$?
@@ -33,6 +33,15 @@ if [ ! -d "$REPO" ]; then
33
33
  fi
34
34
  REPO_ABS="$(cd "$REPO" && pwd)"
35
35
  echo "Target repo: $REPO_ABS"
36
+
37
+ # Locate Draft's bundled helpers. Skills run with cwd = the user's project and
38
+ # ${CLAUDE_PLUGIN_ROOT} is not exported into skill Bash, so resolve DRAFT_TOOLS here
39
+ # and call helpers as "$DRAFT_TOOLS/<tool>.sh". See core/shared/tool-resolver.md.
40
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
41
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
42
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
43
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
44
+ DRAFT_SCRIPTS="${DRAFT_TOOLS%/tools}" # parent dir holds fetch-memory-engine.sh
36
45
  ```
37
46
 
38
47
  ## Step 2: Ensure the engine is present
@@ -40,12 +49,12 @@ echo "Target repo: $REPO_ABS"
40
49
  Resolve the engine; if it is missing, fetch it once, then re-check. If it is still unavailable (e.g. offline, opted out via `DRAFT_MEMORY_DISABLE`), report and stop gracefully — graph features are optional everywhere in Draft.
41
50
 
42
51
  ```bash
43
- if ! scripts/tools/verify-graph-binary.sh --repo "$REPO_ABS" --json 2>/dev/null | grep -q '"status":"ok"'; then
52
+ if ! "$DRAFT_TOOLS/verify-graph-binary.sh" --repo "$REPO_ABS" --json 2>/dev/null | grep -q '"status":"ok"'; then
44
53
  echo "Graph engine not found — attempting to fetch it..."
45
- scripts/fetch-memory-engine.sh || true
54
+ "$DRAFT_SCRIPTS/fetch-memory-engine.sh" || true
46
55
  fi
47
56
 
48
- ENGINE="$(scripts/tools/verify-graph-binary.sh --repo "$REPO_ABS" --json 2>/dev/null || true)"
57
+ ENGINE="$("$DRAFT_TOOLS/verify-graph-binary.sh" --repo "$REPO_ABS" --json 2>/dev/null || true)"
49
58
  if ! echo "$ENGINE" | grep -q '"status":"ok"'; then
50
59
  echo "Graph engine unavailable — skipping. Install with scripts/fetch-memory-engine.sh, or unset DRAFT_MEMORY_DISABLE."
51
60
  exit 0
@@ -58,7 +67,7 @@ echo "Engine: $ENGINE"
58
67
  One call resolves the engine, indexes the repo (incrementally on refresh), and updates the gate marker `<repo>/draft/graph/schema.yaml` (engine metadata + point-of-index counts; `access: engine-live`). All structural graph data is queried live from the engine — no snapshot files are committed beyond `schema.yaml`.
59
68
 
60
69
  ```bash
61
- scripts/tools/graph-snapshot.sh --repo "$REPO_ABS"
70
+ "$DRAFT_TOOLS/graph-snapshot.sh" --repo "$REPO_ABS"
62
71
  ```
63
72
 
64
73
  If this exits non-zero, the engine became unavailable mid-run — report it and stop; do not fabricate results.
@@ -72,10 +81,10 @@ echo "--- Snapshot ---"
72
81
  cat "$REPO_ABS/draft/graph/schema.yaml"
73
82
 
74
83
  echo "--- Top hotspots ---"
75
- scripts/tools/hotspot-rank.sh --repo "$REPO_ABS" --top 5
84
+ "$DRAFT_TOOLS/hotspot-rank.sh" --repo "$REPO_ABS" --top 5
76
85
 
77
86
  echo "--- Cycles ---"
78
- scripts/tools/cycle-detect.sh --repo "$REPO_ABS"
87
+ "$DRAFT_TOOLS/cycle-detect.sh" --repo "$REPO_ABS"
79
88
 
80
89
  echo "--- Snapshot state ---"
81
90
  git -C "$REPO_ABS" rev-parse --short HEAD 2>/dev/null \
@@ -16,11 +16,22 @@ Generate a project-wide impact report measuring Context-Driven Development effec
16
16
 
17
17
  ## Execution Constraints
18
18
 
19
+ First resolve the bundled helpers:
20
+
21
+ ```bash
22
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
23
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
24
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
25
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
26
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
27
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
28
+ ```
29
+
19
30
  1. **Load Track State:**
20
31
  - Read all `draft/tracks.md` entries.
21
32
  - For each track, read `metadata.json` to extract: `created_at`, `updated`, `status`, phase counts, task counts, `scope_includes`, `scope_excludes`.
22
33
  - If no tracks exist, report "No tracks found. Run `/draft:new-track` to create your first track."
23
- - Run `scripts/tools/check-scope-conflicts.sh` to surface adjacent
34
+ - Run `"$DRAFT_TOOLS/check-scope-conflicts.sh"` to surface adjacent
24
35
  tracks sharing scope tags — duplicate effort signals in impact
25
36
  reporting. Schema:
26
37
  [core/shared/template-contract.md](../../core/shared/template-contract.md).