@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/cli/src/hosts/claude-code.js +4 -1
- package/cli/src/installer.js +20 -5
- package/cli/src/lib/marker.js +93 -0
- package/core/shared/condensation.md +3 -2
- package/core/shared/git-report-metadata.md +3 -2
- package/core/shared/graph-query.md +140 -8
- package/core/shared/tool-resolver.md +71 -4
- package/core/templates/plan.md +3 -2
- package/integrations/agents/AGENTS.md +481 -106
- package/integrations/copilot/.github/copilot-instructions.md +481 -106
- package/package.json +2 -1
- package/scripts/lib.sh +11 -0
- package/scripts/tools/_graph_queries.sh +102 -0
- package/scripts/tools/cycle-detect.sh +18 -15
- package/scripts/tools/graph-callers.sh +71 -20
- package/scripts/tools/graph-deps.sh +76 -0
- package/scripts/tools/graph-errors.sh +97 -0
- package/scripts/tools/graph-hierarchy.sh +89 -0
- package/scripts/tools/graph-query.sh +124 -0
- package/scripts/tools/graph-risk.sh +81 -0
- package/scripts/tools/graph-search.sh +84 -0
- package/scripts/tools/graph-snapshot.sh +13 -1
- package/scripts/tools/graph-snippet.sh +92 -0
- package/scripts/tools/graph-tests.sh +112 -0
- package/scripts/tools/graph-traces.sh +83 -0
- package/scripts/tools/hotspot-rank.sh +43 -16
- package/scripts/tools/mermaid-from-graph.sh +31 -10
- package/scripts/tools/resolve-tools.sh +78 -0
- package/skills/adr/SKILL.md +3 -2
- package/skills/bughunt/SKILL.md +10 -1
- package/skills/coverage/SKILL.md +8 -3
- package/skills/debug/SKILL.md +16 -5
- package/skills/decompose/SKILL.md +29 -12
- package/skills/deep-review/SKILL.md +19 -6
- package/skills/deploy-checklist/SKILL.md +6 -5
- package/skills/graph/SKILL.md +15 -6
- package/skills/impact/SKILL.md +12 -1
- package/skills/implement/SKILL.md +20 -4
- package/skills/init/SKILL.md +17 -10
- package/skills/init/references/architecture-spec.md +17 -6
- package/skills/learn/SKILL.md +15 -4
- package/skills/quick-review/SKILL.md +13 -3
- package/skills/review/SKILL.md +32 -8
- package/skills/standup/SKILL.md +3 -2
- package/skills/status/SKILL.md +3 -2
- package/skills/tech-debt/SKILL.md +20 -6
- package/skills/upload/SKILL.md +3 -2
|
@@ -611,8 +611,15 @@ The knowledge-graph engine `codebase-memory-mcp` is Draft's **default** capabili
|
|
|
611
611
|
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:
|
|
612
612
|
|
|
613
613
|
```bash
|
|
614
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
615
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
616
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
617
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
618
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
619
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
620
|
+
|
|
614
621
|
# Add --module-only to skip touching the root (link marked "pending").
|
|
615
|
-
if
|
|
622
|
+
if "$DRAFT_TOOLS/graph-init.sh" --scope .; then
|
|
616
623
|
echo "Graph memory ready under draft/graph/ (the root spine is the structural source of truth)."
|
|
617
624
|
else
|
|
618
625
|
echo "Graph engine unavailable — proceeding with degraded manual discovery. Downstream skills degrade gracefully."
|
|
@@ -626,7 +633,7 @@ fi
|
|
|
626
633
|
Optionally record which engine was selected (usage-report contract):
|
|
627
634
|
|
|
628
635
|
```bash
|
|
629
|
-
|
|
636
|
+
"$DRAFT_TOOLS/verify-graph-binary.sh" --repo . --json 2>/dev/null || true
|
|
630
637
|
```
|
|
631
638
|
|
|
632
639
|
See `core/shared/graph-query.md` and `bin/README.md` for the query contract and engine resolution.
|
|
@@ -638,13 +645,13 @@ If indexing succeeds, `draft/graph/schema.yaml` is written and later steps query
|
|
|
638
645
|
Pull the architecture view once and reuse it across phases:
|
|
639
646
|
|
|
640
647
|
```bash
|
|
641
|
-
ARCH=$(
|
|
648
|
+
ARCH=$("$DRAFT_TOOLS/graph-arch.sh" --repo .)
|
|
642
649
|
```
|
|
643
650
|
|
|
644
651
|
- `$ARCH | jq '.packages'` — module list with fan-in/out
|
|
645
652
|
- `$ARCH | jq '.routes'` — detected service endpoints
|
|
646
653
|
- `$ARCH | jq '.languages, .node_labels, .layers, .boundaries'` — language mix, node shape, layering
|
|
647
|
-
- `
|
|
654
|
+
- `"$DRAFT_TOOLS/hotspot-rank.sh" --repo . --top 20` — complexity/fan-in hotspots (live)
|
|
648
655
|
|
|
649
656
|
### 3. Use graph data to accelerate Step 1.5
|
|
650
657
|
|
|
@@ -676,7 +683,7 @@ Apply tier table:
|
|
|
676
683
|
Hold tier in memory. This governs: architecture.md length minimum, .ai-context.md budget, and module deep-dive depth.
|
|
677
684
|
|
|
678
685
|
**Step 1.4.6 — Build Module Priority List:**
|
|
679
|
-
From `
|
|
686
|
+
From `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`: count hotspot symbols per module.
|
|
680
687
|
From `$ARCH | jq '.packages[]'`: read `fan_in` per module.
|
|
681
688
|
Rank modules by: `(hotspot_count × 2) + fan_in_count`.
|
|
682
689
|
Top-ranked modules drive Section 6 deep-dive ordering and depth. Modules ranked zero on both: summary treatment only.
|
|
@@ -687,7 +694,7 @@ Query for diagram content and write into architecture.md slots using the standar
|
|
|
687
694
|
|
|
688
695
|
For Section 4.4 (module-deps slot):
|
|
689
696
|
```bash
|
|
690
|
-
|
|
697
|
+
"$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram module-deps
|
|
691
698
|
```
|
|
692
699
|
The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on exit 2). Write between the markers:
|
|
693
700
|
```
|
|
@@ -697,7 +704,7 @@ The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on e
|
|
|
697
704
|
```
|
|
698
705
|
|
|
699
706
|
For Section 20 (hotspots slot):
|
|
700
|
-
Run `
|
|
707
|
+
Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo . --top 10`, take the top 10 by fanIn, build a markdown table:
|
|
701
708
|
```
|
|
702
709
|
<!-- GRAPH:hotspots:START -->
|
|
703
710
|
| Symbol | fanIn |
|
|
@@ -709,7 +716,7 @@ Run `scripts/tools/hotspot-rank.sh --repo . --top 10`, take the top 10 by fanIn,
|
|
|
709
716
|
|
|
710
717
|
For Appendix E (proto-map slot):
|
|
711
718
|
```bash
|
|
712
|
-
|
|
719
|
+
"$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram proto-map
|
|
713
720
|
```
|
|
714
721
|
The tool emits a ` ```mermaid ``` ` block from detected routes (empty stub if none). Write:
|
|
715
722
|
```
|
|
@@ -786,7 +793,7 @@ For tier 3+, readers run simultaneously; wall clock = slowest reader, not the su
|
|
|
786
793
|
The engine is already indexed. Query it live throughout this protocol (reuse `$ARCH` from Step 1.4.2):
|
|
787
794
|
- `$ARCH | jq '.packages'` — module list with `.fan_in`/`.fan_out` (for grouping)
|
|
788
795
|
- `$ARCH | jq '.languages, .node_labels'` — file/symbol counts, tier metrics
|
|
789
|
-
- `
|
|
796
|
+
- `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — top hotspot symbols per module (feed to readers)
|
|
790
797
|
|
|
791
798
|
#### Phase 1: Spawn Parallel Module Readers
|
|
792
799
|
|
|
@@ -913,7 +920,7 @@ If any reader agent fails to produce valid JSON after one retry:
|
|
|
913
920
|
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.
|
|
914
921
|
|
|
915
922
|
1. Use the ranked module list from Step 1.4.6 (graph-first — do not re-scan by directory if Phase 0 succeeded).
|
|
916
|
-
2. For each top module (up to 20 by fan-in), query the engine for its symbols/callers (`
|
|
923
|
+
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.
|
|
917
924
|
3. Always include §9 Graph Coverage Gaps and §10 Relationship when the Context Audit requires them.
|
|
918
925
|
4. Run Completion Verification (defined later in this skill) before condensation. Fidelity, provenance, and gap honesty block completion — not line counts.
|
|
919
926
|
|
|
@@ -2239,7 +2246,18 @@ Only when material: authentication/authorization checkpoints, distributed transa
|
|
|
2239
2246
|
|
|
2240
2247
|
**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.
|
|
2241
2248
|
|
|
2242
|
-
|
|
2249
|
+
First resolve the bundled helpers:
|
|
2250
|
+
|
|
2251
|
+
```bash
|
|
2252
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
2253
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
2254
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
2255
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
2256
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
2257
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
2258
|
+
```
|
|
2259
|
+
|
|
2260
|
+
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 .`.
|
|
2243
2261
|
|
|
2244
2262
|
#### 7.{N} {module-name}
|
|
2245
2263
|
|
|
@@ -2326,7 +2344,7 @@ Regardless of tier, any directory whose name contains `ops`, `handlers`, `execut
|
|
|
2326
2344
|
| ... | (enumerate ALL — no sampling, no "and others") | | | |
|
|
2327
2345
|
```
|
|
2328
2346
|
|
|
2329
|
-
Use `
|
|
2347
|
+
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.
|
|
2330
2348
|
|
|
2331
2349
|
#### Example: Full Sub-Module Treatment for `icebox/` (917 files)
|
|
2332
2350
|
|
|
@@ -2480,10 +2498,10 @@ Include architecturally significant implementations (high fan-in, core extension
|
|
|
2480
2498
|
| (enumerate ALL — use hotspot-rank.sh and graph-callers.sh / get_architecture for file list and line counts) |
|
|
2481
2499
|
```
|
|
2482
2500
|
|
|
2483
|
-
> **MANDATORY (graph data)**: Query `
|
|
2484
|
-
> `
|
|
2501
|
+
> **MANDATORY (graph data)**: Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` or
|
|
2502
|
+
> `"$DRAFT_TOOLS/graph-callers.sh" --symbol <module>` to get the complete file list with line counts.
|
|
2485
2503
|
> Filter for files in operation sub-directories (paths containing `/ops/`,
|
|
2486
|
-
> `/handlers/`, `/executors/`, `/workers/`). Use `
|
|
2504
|
+
> `/handlers/`, `/executors/`, `/workers/`). Use `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to flag
|
|
2487
2505
|
> high-complexity operations (high line count or fanIn). Do NOT skip this step — incomplete
|
|
2488
2506
|
> catalogs cause AI agents to reinvent existing functionality.
|
|
2489
2507
|
|
|
@@ -3178,7 +3196,7 @@ Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (
|
|
|
3178
3196
|
|
|
3179
3197
|
**FAILURE 4 — Missing Sub-Modules:**
|
|
3180
3198
|
Detection: A module with 100+ source files (check graph data) has no Sub-Module Structure table.
|
|
3181
|
-
Fix: Query `
|
|
3199
|
+
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.
|
|
3182
3200
|
|
|
3183
3201
|
**FAILURE 4b — Shallow Sub-Module Treatment:**
|
|
3184
3202
|
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.
|
|
@@ -3257,6 +3275,15 @@ if [ ! -d "$REPO" ]; then
|
|
|
3257
3275
|
fi
|
|
3258
3276
|
REPO_ABS="$(cd "$REPO" && pwd)"
|
|
3259
3277
|
echo "Target repo: $REPO_ABS"
|
|
3278
|
+
|
|
3279
|
+
# Locate Draft's bundled helpers. Skills run with cwd = the user's project and
|
|
3280
|
+
# ${CLAUDE_PLUGIN_ROOT} is not exported into skill Bash, so resolve DRAFT_TOOLS here
|
|
3281
|
+
# and call helpers as "$DRAFT_TOOLS/<tool>.sh". See core/shared/tool-resolver.md.
|
|
3282
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
3283
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
3284
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
3285
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
3286
|
+
DRAFT_SCRIPTS="${DRAFT_TOOLS%/tools}" # parent dir holds fetch-memory-engine.sh
|
|
3260
3287
|
```
|
|
3261
3288
|
|
|
3262
3289
|
## Step 2: Ensure the engine is present
|
|
@@ -3264,12 +3291,12 @@ echo "Target repo: $REPO_ABS"
|
|
|
3264
3291
|
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.
|
|
3265
3292
|
|
|
3266
3293
|
```bash
|
|
3267
|
-
if !
|
|
3294
|
+
if ! "$DRAFT_TOOLS/verify-graph-binary.sh" --repo "$REPO_ABS" --json 2>/dev/null | grep -q '"status":"ok"'; then
|
|
3268
3295
|
echo "Graph engine not found — attempting to fetch it..."
|
|
3269
|
-
|
|
3296
|
+
"$DRAFT_SCRIPTS/fetch-memory-engine.sh" || true
|
|
3270
3297
|
fi
|
|
3271
3298
|
|
|
3272
|
-
ENGINE="$(
|
|
3299
|
+
ENGINE="$("$DRAFT_TOOLS/verify-graph-binary.sh" --repo "$REPO_ABS" --json 2>/dev/null || true)"
|
|
3273
3300
|
if ! echo "$ENGINE" | grep -q '"status":"ok"'; then
|
|
3274
3301
|
echo "Graph engine unavailable — skipping. Install with scripts/fetch-memory-engine.sh, or unset DRAFT_MEMORY_DISABLE."
|
|
3275
3302
|
exit 0
|
|
@@ -3282,7 +3309,7 @@ echo "Engine: $ENGINE"
|
|
|
3282
3309
|
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`.
|
|
3283
3310
|
|
|
3284
3311
|
```bash
|
|
3285
|
-
|
|
3312
|
+
"$DRAFT_TOOLS/graph-snapshot.sh" --repo "$REPO_ABS"
|
|
3286
3313
|
```
|
|
3287
3314
|
|
|
3288
3315
|
If this exits non-zero, the engine became unavailable mid-run — report it and stop; do not fabricate results.
|
|
@@ -3296,10 +3323,10 @@ echo "--- Snapshot ---"
|
|
|
3296
3323
|
cat "$REPO_ABS/draft/graph/schema.yaml"
|
|
3297
3324
|
|
|
3298
3325
|
echo "--- Top hotspots ---"
|
|
3299
|
-
|
|
3326
|
+
"$DRAFT_TOOLS/hotspot-rank.sh" --repo "$REPO_ABS" --top 5
|
|
3300
3327
|
|
|
3301
3328
|
echo "--- Cycles ---"
|
|
3302
|
-
|
|
3329
|
+
"$DRAFT_TOOLS/cycle-detect.sh" --repo "$REPO_ABS"
|
|
3303
3330
|
|
|
3304
3331
|
echo "--- Snapshot state ---"
|
|
3305
3332
|
git -C "$REPO_ABS" rev-parse --short HEAD 2>/dev/null \
|
|
@@ -4181,12 +4208,23 @@ You are decomposing a project or track into modules with clear responsibilities,
|
|
|
4181
4208
|
|
|
4182
4209
|
## MANDATORY GRAPH LOOKUP (read before any analysis)
|
|
4183
4210
|
|
|
4211
|
+
First resolve the bundled helpers:
|
|
4212
|
+
|
|
4213
|
+
```bash
|
|
4214
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
4215
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
4216
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
4217
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
4218
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
4219
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
4220
|
+
```
|
|
4221
|
+
|
|
4184
4222
|
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**:
|
|
4185
4223
|
|
|
4186
|
-
1. Query `
|
|
4187
|
-
2. Run `
|
|
4188
|
-
3. Use `
|
|
4189
|
-
4. Run `
|
|
4224
|
+
1. Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` for the authoritative module list and fan-in/out.
|
|
4225
|
+
2. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to identify candidate modules to split.
|
|
4226
|
+
3. Use `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` on demand for symbols/callers inside a candidate module.
|
|
4227
|
+
4. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` to enumerate existing cycles before proposing new boundaries.
|
|
4190
4228
|
|
|
4191
4229
|
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.
|
|
4192
4230
|
|
|
@@ -4328,11 +4366,11 @@ ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
|
|
|
4328
4366
|
|
|
4329
4367
|
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:
|
|
4330
4368
|
|
|
4331
|
-
- **Module boundaries**: Query `
|
|
4369
|
+
- **Module boundaries**: Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` — module list with node counts and per-language file counts
|
|
4332
4370
|
- **Dependency edges**: Weighted inter-module dependencies with exact include counts — replaces manual import tracing
|
|
4333
4371
|
- **Cycle detection**: Circular dependency paths already computed — use for identifying tight coupling and decomposition candidates
|
|
4334
|
-
- **Hotspots**: Run `
|
|
4335
|
-
- **Per-module detail**: query `
|
|
4372
|
+
- **Hotspots**: Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — high-complexity files that may need further decomposition
|
|
4373
|
+
- **Per-module detail**: query `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` for symbol/call detail within modules of interest
|
|
4336
4374
|
|
|
4337
4375
|
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.
|
|
4338
4376
|
|
|
@@ -4576,8 +4614,11 @@ After writing all generated files, strip trailing whitespace and blank lines at
|
|
|
4576
4614
|
Resolve the script via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
|
|
4577
4615
|
|
|
4578
4616
|
```bash
|
|
4579
|
-
|
|
4580
|
-
|
|
4617
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
4618
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
4619
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
4620
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
4621
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
4581
4622
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
4582
4623
|
# Fix all generated markdown for this track:
|
|
4583
4624
|
[ -x "$DRAFT_TOOLS/fix-whitespace.sh" ] && bash "$DRAFT_TOOLS/fix-whitespace.sh" --track <id>
|
|
@@ -4624,7 +4665,7 @@ references, sunset criteria) survive every regenerate. After rewriting:
|
|
|
4624
4665
|
2. Update plan.md `generated_at:` to the current ISO-8601 timestamp.
|
|
4625
4666
|
3. Ensure plan.md `generated_at` ≥ sibling hld.md / lld.md `generated_at`
|
|
4626
4667
|
(the hygiene validator fails on stale plan).
|
|
4627
|
-
4. Run `
|
|
4668
|
+
4. Run `"$DRAFT_TOOLS/check-track-hygiene.sh" <track_dir>` and resolve any
|
|
4628
4669
|
findings before promoting status past `draft`.
|
|
4629
4670
|
|
|
4630
4671
|
If the plan does not yet have the bracket markers (pre-2.0 track), insert
|
|
@@ -4820,8 +4861,11 @@ As the last step after the completion announcement, emit a metrics record. Best-
|
|
|
4820
4861
|
|
|
4821
4862
|
**Emit call:**
|
|
4822
4863
|
```bash
|
|
4823
|
-
|
|
4824
|
-
|
|
4864
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
4865
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
4866
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
4867
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
4868
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
4825
4869
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
4826
4870
|
[ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
|
|
4827
4871
|
'{"skill":"decompose","scope":"<scope>","track_id":"<id_or_null>","modules_count":<N>,"lld_generated":<bool>,"high_complexity_modules":<N>}'
|
|
@@ -4961,9 +5005,21 @@ If one of these applies, route directly to the specialist workflow and stop this
|
|
|
4961
5005
|
- Keep matching invariants as **active constraints** for this task — these govern code generation, not just review
|
|
4962
5006
|
- If invariants reference lock ordering, fail-closed behavior, or data integrity rules: these are non-negotiable during implementation
|
|
4963
5007
|
9. **Load graph context** (if `draft/graph/schema.yaml` exists):
|
|
4964
|
-
|
|
5008
|
+
|
|
5009
|
+
First resolve the bundled helpers:
|
|
5010
|
+
|
|
5011
|
+
```bash
|
|
5012
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
5013
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
5014
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
5015
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
5016
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
5017
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
5018
|
+
```
|
|
5019
|
+
|
|
5020
|
+
- Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — check if any files this task will modify appear as hotspots
|
|
4965
5021
|
- 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."
|
|
4966
|
-
- Query `
|
|
5022
|
+
- Query `"$DRAFT_TOOLS/graph-impact.sh"`/`"$DRAFT_TOOLS/graph-callers.sh"` for the module(s) being modified — gives file-level dependency context
|
|
4967
5023
|
- See `core/shared/graph-query.md` for on-demand query subroutines (callers, impact)
|
|
4968
5024
|
10. Update the track's entry in `draft/tracks.md` from `[ ]` to `[~]` In Progress
|
|
4969
5025
|
|
|
@@ -5453,9 +5509,13 @@ After a phase passes review, refresh `metadata.json.impact` so future tracks can
|
|
|
5453
5509
|
```
|
|
5454
5510
|
That is the `files_touched` list. Derive `modules_touched` as the unique top-level path segments (e.g. `auth/login.go` → `auth`).
|
|
5455
5511
|
|
|
5456
|
-
2. **Compute downstream blast radius (graph-aware, optional):** If `draft/graph/schema.yaml` exists, for each file in `files_touched` query:
|
|
5512
|
+
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):
|
|
5457
5513
|
```bash
|
|
5458
|
-
|
|
5514
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
5515
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
5516
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
5517
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
5518
|
+
"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>
|
|
5459
5519
|
```
|
|
5460
5520
|
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.
|
|
5461
5521
|
|
|
@@ -5655,8 +5715,9 @@ If no active track and no argument provided:
|
|
|
5655
5715
|
**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)):
|
|
5656
5716
|
|
|
5657
5717
|
```bash
|
|
5658
|
-
DRAFT_TOOLS="$
|
|
5659
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
5718
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
5719
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
5720
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
5660
5721
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
5661
5722
|
[ -x "$DRAFT_TOOLS/detect-test-framework.sh" ] && \
|
|
5662
5723
|
bash "$DRAFT_TOOLS/detect-test-framework.sh" --root .
|
|
@@ -5695,7 +5756,11 @@ Build the coverage command with the appropriate scope/filter flags.
|
|
|
5695
5756
|
**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.
|
|
5696
5757
|
|
|
5697
5758
|
```bash
|
|
5698
|
-
#
|
|
5759
|
+
# Re-resolve helpers (this is a separate Bash session from Step 2).
|
|
5760
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
5761
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
5762
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
5763
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
5699
5764
|
[ -x "$DRAFT_TOOLS/run-coverage.sh" ] && \
|
|
5700
5765
|
bash "$DRAFT_TOOLS/run-coverage.sh" --root .
|
|
5701
5766
|
```
|
|
@@ -5969,9 +6034,9 @@ You are generating a pre-deployment verification checklist customized to this pr
|
|
|
5969
6034
|
|
|
5970
6035
|
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:
|
|
5971
6036
|
|
|
5972
|
-
1. For each file in the deploy diff, run `
|
|
5973
|
-
2. Run `
|
|
5974
|
-
3. Run `
|
|
6037
|
+
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.
|
|
6038
|
+
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.
|
|
6039
|
+
3. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — any hotspot in the diff escalates the Resiliency row of Phase 0.
|
|
5975
6040
|
|
|
5976
6041
|
Filesystem `grep` is reserved for source-text scans (migration file names, flag-key strings). Module/impact discovery goes through the graph.
|
|
5977
6042
|
|
|
@@ -6025,8 +6090,9 @@ by validator.
|
|
|
6025
6090
|
```bash
|
|
6026
6091
|
TRACK_DIR="$1" # absolute path to track-under-deploy, or .
|
|
6027
6092
|
|
|
6028
|
-
DRAFT_TOOLS="$
|
|
6029
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
6093
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
6094
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
6095
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
6030
6096
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
6031
6097
|
|
|
6032
6098
|
"$DRAFT_TOOLS/check-track-hygiene.sh" "$TRACK_DIR" || rc=$?
|
|
@@ -6280,7 +6346,16 @@ Read and follow the base procedure in `core/shared/draft-context-loading.md`.
|
|
|
6280
6346
|
- **Leverage Storage Topology** — Identify data loss risks at each tier (cache eviction without writeback, event log gaps, missing archive)
|
|
6281
6347
|
- **Leverage Consistency Boundaries** — Find bugs at eventual consistency seams (stale reads, lost events, missing reconciliation)
|
|
6282
6348
|
- **Leverage Failure Recovery Matrix** — Verify idempotency claims, check for partial failure states without recovery paths
|
|
6283
|
-
- **Leverage Graph Data** (if `draft/graph/` exists) —
|
|
6349
|
+
- **Leverage Graph Data** (if `draft/graph/` exists) — First resolve the bundled helpers:
|
|
6350
|
+
```bash
|
|
6351
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
6352
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
6353
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
6354
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
6355
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
6356
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
6357
|
+
```
|
|
6358
|
+
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`.
|
|
6284
6359
|
- **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.
|
|
6285
6360
|
|
|
6286
6361
|
### 2. Confirm Scope
|
|
@@ -7304,9 +7379,19 @@ You are conducting a code review using Draft's Context-Driven Development method
|
|
|
7304
7379
|
|
|
7305
7380
|
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**:
|
|
7306
7381
|
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7382
|
+
First resolve the bundled helpers:
|
|
7383
|
+
```bash
|
|
7384
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
7385
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
7386
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
7387
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
7388
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
7389
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
7390
|
+
```
|
|
7391
|
+
|
|
7392
|
+
1. Run blast-radius assessment via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` and `"$DRAFT_TOOLS/graph-impact.sh"` (see Stage 1).
|
|
7393
|
+
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.
|
|
7394
|
+
3. For each public symbol modified, run `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
|
|
7310
7395
|
|
|
7311
7396
|
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.
|
|
7312
7397
|
|
|
@@ -7662,10 +7747,21 @@ Load plugin guardrails before scanning: `core/guardrails/review-checks.md` (RC-#
|
|
|
7662
7747
|
For the files changed in the diff, perform static checks using `grep` or similar tools:
|
|
7663
7748
|
|
|
7664
7749
|
- **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
|
|
7750
|
+
|
|
7751
|
+
First resolve the bundled helpers:
|
|
7752
|
+
```bash
|
|
7753
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
7754
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
7755
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
7756
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
7757
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
7758
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
7759
|
+
```
|
|
7760
|
+
|
|
7665
7761
|
- List all changed files from the diff
|
|
7666
|
-
- For each changed file, check if it appears in `
|
|
7762
|
+
- For each changed file, check if it appears in `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` output — if yes, record its `fanIn` value
|
|
7667
7763
|
- 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**
|
|
7668
|
-
- For any file in a HIGH or MEDIUM module, query `
|
|
7764
|
+
- 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)
|
|
7669
7765
|
- 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]`
|
|
7670
7766
|
- If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
|
|
7671
7767
|
- **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
|
|
@@ -7674,7 +7770,7 @@ For the files changed in the diff, perform static checks using `grep` or similar
|
|
|
7674
7770
|
- **Graph Boundary Check** (if `draft/graph/schema.yaml` exists) `[RC-013]`:
|
|
7675
7771
|
- For each changed file, identify its module from the graph
|
|
7676
7772
|
- Check if any new cross-module includes were added in the diff
|
|
7677
|
-
- Verify they follow the established dependency direction from `
|
|
7773
|
+
- Verify they follow the established dependency direction from `"$DRAFT_TOOLS/graph-arch.sh" --repo .` package fan-in/out
|
|
7678
7774
|
- Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
|
|
7679
7775
|
- Check if changes introduce files in modules listed in graph cycles — flag as higher risk
|
|
7680
7776
|
- **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
|
|
@@ -8399,8 +8495,11 @@ As the last step after saving the review report, emit a metrics record. Best-eff
|
|
|
8399
8495
|
|
|
8400
8496
|
**Emit call:**
|
|
8401
8497
|
```bash
|
|
8402
|
-
|
|
8403
|
-
|
|
8498
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
8499
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
8500
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
8501
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
8502
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
8404
8503
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
8405
8504
|
[ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
|
|
8406
8505
|
'{"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>}'
|
|
@@ -8459,8 +8558,9 @@ Run the WS-9 chain from [verification-gates.md](../../core/shared/verification-g
|
|
|
8459
8558
|
|
|
8460
8559
|
```bash
|
|
8461
8560
|
TRACK_DIR="draft/tracks/<id>"
|
|
8462
|
-
DRAFT_TOOLS="$
|
|
8463
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
8561
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
8562
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
8563
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
8464
8564
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
8465
8565
|
|
|
8466
8566
|
"$DRAFT_TOOLS/check-track-hygiene.sh" "$TRACK_DIR"
|
|
@@ -10711,8 +10811,18 @@ You are performing a lightweight, ad-hoc code review. This is the fast alternati
|
|
|
10711
10811
|
|
|
10712
10812
|
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:
|
|
10713
10813
|
|
|
10714
|
-
|
|
10715
|
-
|
|
10814
|
+
First resolve the bundled helpers:
|
|
10815
|
+
```bash
|
|
10816
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
10817
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
10818
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
10819
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
10820
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
10821
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
10822
|
+
```
|
|
10823
|
+
|
|
10824
|
+
1. Always run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` for every changed file (Step 2 blast-radius pre-check below).
|
|
10825
|
+
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".
|
|
10716
10826
|
|
|
10717
10827
|
Filesystem `grep` is reserved for source-text scans (literal strings, regex patterns). Symbol and caller discovery go through the graph.
|
|
10718
10828
|
|
|
@@ -10770,7 +10880,7 @@ Determine the diff to review:
|
|
|
10770
10880
|
|
|
10771
10881
|
## Step 2: Blast Radius Pre-check (if `draft/graph/schema.yaml` exists)
|
|
10772
10882
|
|
|
10773
|
-
Before the four-dimension review, run `
|
|
10883
|
+
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:
|
|
10774
10884
|
|
|
10775
10885
|
```
|
|
10776
10886
|
⚠ HIGH IMPACT: {file} is a high-fanIn hotspot (fanIn={N}). Changes here propagate to many callers — review with extra care.
|
|
@@ -10927,10 +11037,20 @@ Perform an exhaustive end-to-end lifecycle review of a service, component, or mo
|
|
|
10927
11037
|
|
|
10928
11038
|
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:
|
|
10929
11039
|
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
11040
|
+
First resolve the bundled helpers:
|
|
11041
|
+
```bash
|
|
11042
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
11043
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
11044
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
11045
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
11046
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
11047
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
11048
|
+
```
|
|
11049
|
+
|
|
11050
|
+
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`.
|
|
11051
|
+
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.
|
|
11052
|
+
3. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` and flag any cycle that includes the audited module as Architecture Resilience finding.
|
|
11053
|
+
4. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to identify high-fanIn files inside the module — these get deeper inspection.
|
|
10934
11054
|
|
|
10935
11055
|
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.
|
|
10936
11056
|
|
|
@@ -11234,8 +11354,11 @@ As the last step after saving the deep-review report, emit a metrics record. Bes
|
|
|
11234
11354
|
|
|
11235
11355
|
**Emit call:**
|
|
11236
11356
|
```bash
|
|
11237
|
-
|
|
11238
|
-
|
|
11357
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
11358
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
11359
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
11360
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
11361
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
11239
11362
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
11240
11363
|
[ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
|
|
11241
11364
|
'{"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>}'
|
|
@@ -11446,10 +11569,21 @@ Scan the codebase to discover recurring coding patterns and update `draft/guardr
|
|
|
11446
11569
|
|
|
11447
11570
|
## MANDATORY GRAPH LOOKUP (read before pattern scanning)
|
|
11448
11571
|
|
|
11572
|
+
First resolve the bundled helpers:
|
|
11573
|
+
|
|
11574
|
+
```bash
|
|
11575
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
11576
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
11577
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
11578
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
11579
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
11580
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
11581
|
+
```
|
|
11582
|
+
|
|
11449
11583
|
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:
|
|
11450
11584
|
|
|
11451
|
-
1. Enumerate a module's symbols/files via `
|
|
11452
|
-
2. Prioritize hotspots via `
|
|
11585
|
+
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`).
|
|
11586
|
+
2. Prioritize hotspots via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — patterns in high-fanIn files are more impactful when learned.
|
|
11453
11587
|
3. For TS/Python/Go/C/C++, use `*-index.jsonl` to identify class/function definitions rather than re-discovering them via regex.
|
|
11454
11588
|
|
|
11455
11589
|
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.
|
|
@@ -11683,10 +11817,10 @@ git log --follow --oneline -1 -- {file_containing_pattern}
|
|
|
11683
11817
|
|
|
11684
11818
|
### 2.7: Graph-Aware Severity Enrichment
|
|
11685
11819
|
|
|
11686
|
-
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 `
|
|
11820
|
+
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 .`.
|
|
11687
11821
|
|
|
11688
11822
|
For each anti-pattern candidate from Step 2.2:
|
|
11689
|
-
1. Check if any evidence files appear in the hotspot output from `
|
|
11823
|
+
1. Check if any evidence files appear in the hotspot output from `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`
|
|
11690
11824
|
2. Take the highest fanIn value across all evidence files:
|
|
11691
11825
|
- fanIn ≥ 10 → `graph_severity: critical` (breakage propagates to many callers)
|
|
11692
11826
|
- fanIn 5–9 → `graph_severity: high`
|
|
@@ -11969,8 +12103,9 @@ Check for arguments:
|
|
|
11969
12103
|
If argument is `list`:
|
|
11970
12104
|
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)):
|
|
11971
12105
|
```bash
|
|
11972
|
-
DRAFT_TOOLS="$
|
|
11973
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
12106
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
12107
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
12108
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
11974
12109
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
11975
12110
|
if [ -x "$DRAFT_TOOLS/adr-index.sh" ]; then
|
|
11976
12111
|
bash "$DRAFT_TOOLS/adr-index.sh" --root draft/adrs
|
|
@@ -12298,12 +12433,23 @@ You are conducting a structured debugging session following systematic investiga
|
|
|
12298
12433
|
|
|
12299
12434
|
## MANDATORY GRAPH LOOKUP (read before Isolate/Diagnose)
|
|
12300
12435
|
|
|
12436
|
+
First resolve the bundled helpers:
|
|
12437
|
+
|
|
12438
|
+
```bash
|
|
12439
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
12440
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
12441
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
12442
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
12443
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
12444
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
12445
|
+
```
|
|
12446
|
+
|
|
12301
12447
|
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):
|
|
12302
12448
|
|
|
12303
|
-
1. Locate the suspect file's module via `
|
|
12304
|
-
2. Use `
|
|
12305
|
-
3. Use `
|
|
12306
|
-
4. Run `
|
|
12449
|
+
1. Locate the suspect file's module via `"$DRAFT_TOOLS/graph-arch.sh" --repo .` before tracing data flow.
|
|
12450
|
+
2. Use `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <fn>` to enumerate call sites of suspect functions — not `grep`.
|
|
12451
|
+
3. Use `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to size the blast radius before proposing a fix.
|
|
12452
|
+
4. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` to know whether the file is high-fanIn (any fix needs extra caution).
|
|
12307
12453
|
|
|
12308
12454
|
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.
|
|
12309
12455
|
|
|
@@ -12351,7 +12497,7 @@ Key context for debugging:
|
|
|
12351
12497
|
- `.ai-context.md` — Module boundaries, data flows, invariants (crucial for tracing)
|
|
12352
12498
|
- `tech-stack.md` — Language-specific debugging tools and techniques
|
|
12353
12499
|
- `guardrails.md` — Known anti-patterns that may be causing the issue
|
|
12354
|
-
- `draft/graph/` (MANDATORY when present) — Query `
|
|
12500
|
+
- `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).
|
|
12355
12501
|
|
|
12356
12502
|
## Step 1: Parse Arguments
|
|
12357
12503
|
|
|
@@ -12544,8 +12690,9 @@ Check for arguments:
|
|
|
12544
12690
|
**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)):
|
|
12545
12691
|
|
|
12546
12692
|
```bash
|
|
12547
|
-
DRAFT_TOOLS="$
|
|
12548
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
12693
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
12694
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
12695
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
12549
12696
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
12550
12697
|
if [ -x "$DRAFT_TOOLS/parse-git-log.sh" ]; then
|
|
12551
12698
|
bash "$DRAFT_TOOLS/parse-git-log.sh" --since "24 hours ago" --author "$(git config user.name)"
|
|
@@ -12682,12 +12829,23 @@ You are conducting a technical debt analysis to catalog, prioritize, and plan re
|
|
|
12682
12829
|
|
|
12683
12830
|
## MANDATORY GRAPH LOOKUP (read before debt scan)
|
|
12684
12831
|
|
|
12832
|
+
First resolve the bundled helpers:
|
|
12833
|
+
|
|
12834
|
+
```bash
|
|
12835
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
12836
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
12837
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
12838
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
12839
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
12840
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
12841
|
+
```
|
|
12842
|
+
|
|
12685
12843
|
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:
|
|
12686
12844
|
|
|
12687
|
-
1. Run `
|
|
12688
|
-
2. Query `
|
|
12689
|
-
3. Run `
|
|
12690
|
-
4. For each catalogued finding, run `
|
|
12845
|
+
1. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
|
|
12846
|
+
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.
|
|
12847
|
+
3. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
|
|
12848
|
+
4. For each catalogued finding, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` so the remediation plan includes blast-radius.
|
|
12691
12849
|
|
|
12692
12850
|
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**.
|
|
12693
12851
|
|
|
@@ -12755,8 +12913,11 @@ Scan the codebase systematically across all seven categories. For each finding,
|
|
|
12755
12913
|
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)):
|
|
12756
12914
|
|
|
12757
12915
|
```bash
|
|
12758
|
-
|
|
12759
|
-
|
|
12916
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
12917
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
12918
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
12919
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
12920
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
12760
12921
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
12761
12922
|
[ -x "$DRAFT_TOOLS/scan-markers.sh" ] && bash "$DRAFT_TOOLS/scan-markers.sh" --root .
|
|
12762
12923
|
# Fallback when script unavailable: grep -rn 'TODO\|FIXME\|HACK\|XXX\|DEPRECATED' .
|
|
@@ -13477,8 +13638,9 @@ Display a comprehensive overview of project progress.
|
|
|
13477
13638
|
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)):
|
|
13478
13639
|
|
|
13479
13640
|
```bash
|
|
13480
|
-
DRAFT_TOOLS="$
|
|
13481
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
13641
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
13642
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
13643
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
13482
13644
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
13483
13645
|
|
|
13484
13646
|
# Per-track report severity rollup (bughunt, review, tech-debt, etc.):
|
|
@@ -14115,11 +14277,22 @@ Generate a project-wide impact report measuring Context-Driven Development effec
|
|
|
14115
14277
|
|
|
14116
14278
|
## Execution Constraints
|
|
14117
14279
|
|
|
14280
|
+
First resolve the bundled helpers:
|
|
14281
|
+
|
|
14282
|
+
```bash
|
|
14283
|
+
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
|
|
14284
|
+
# is not exported into skill Bash). See core/shared/tool-resolver.md.
|
|
14285
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
14286
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
14287
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
14288
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
14289
|
+
```
|
|
14290
|
+
|
|
14118
14291
|
1. **Load Track State:**
|
|
14119
14292
|
- Read all `draft/tracks.md` entries.
|
|
14120
14293
|
- For each track, read `metadata.json` to extract: `created_at`, `updated`, `status`, phase counts, task counts, `scope_includes`, `scope_excludes`.
|
|
14121
14294
|
- If no tracks exist, report "No tracks found. Run `draft new-track` to create your first track."
|
|
14122
|
-
- Run `
|
|
14295
|
+
- Run `"$DRAFT_TOOLS/check-scope-conflicts.sh"` to surface adjacent
|
|
14123
14296
|
tracks sharing scope tags — duplicate effort signals in impact
|
|
14124
14297
|
reporting. Schema:
|
|
14125
14298
|
[core/shared/template-contract.md](../../core/shared/template-contract.md).
|
|
@@ -16042,8 +16215,9 @@ Referenced by: All skills that generate Draft reports — including `draft bughu
|
|
|
16042
16215
|
Use `git-metadata.sh` from the plugin install, resolved via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)):
|
|
16043
16216
|
|
|
16044
16217
|
```bash
|
|
16045
|
-
DRAFT_TOOLS="$
|
|
16046
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
16218
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
16219
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
16220
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
16047
16221
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
16048
16222
|
bash "$DRAFT_TOOLS/git-metadata.sh" --yaml \
|
|
16049
16223
|
--project "$PROJECT" --module "$MODULE" \
|
|
@@ -16476,8 +16650,9 @@ Write the completed content to `draft/.ai-context.md`.
|
|
|
16476
16650
|
After writing both output files, strip trailing whitespace and blank lines at EOF to prevent GitHub upload failures. Resolve the script via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)):
|
|
16477
16651
|
|
|
16478
16652
|
```bash
|
|
16479
|
-
DRAFT_TOOLS="$
|
|
16480
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
16653
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
16654
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
16655
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
16481
16656
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
16482
16657
|
[ -x "$DRAFT_TOOLS/fix-whitespace.sh" ] && bash "$DRAFT_TOOLS/fix-whitespace.sh" draft/architecture.md draft/.ai-context.md draft/.ai-profile.md 2>/dev/null || true
|
|
16483
16658
|
```
|
|
@@ -16899,7 +17074,7 @@ A single "no" / "list" answer is a halt — fix and re-check before output.
|
|
|
16899
17074
|
|
|
16900
17075
|
Use this recipe whenever the user names a concept, feature, or domain term ("in-memory shuffle", "auth flow", "ingest pipeline") and you need to locate the implementing files. **Run it before any filesystem search.**
|
|
16901
17076
|
|
|
16902
|
-
1. **Concept → modules** — query the engine for the package list (`scripts/tools/graph-arch.sh --repo . | jq -r '.packages[].name'`) and cross-reference `draft/.ai-context.md` (module headings). Record the candidate module list.
|
|
17077
|
+
1. **Concept → modules** — query the engine for the package list (`scripts/tools/graph-arch.sh --repo . | jq -r '.packages[].name'`) and cross-reference `draft/.ai-context.md` (module headings). Record the candidate module list. For an **intent/concept** name (not an exact symbol), start with semantic search: `scripts/tools/graph-search.sh --repo . --query "<concept>"` returns ranked candidate symbols directly.
|
|
16903
17078
|
2. **Concept → symbols/callers** — for a named function, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to find call sites, and `scripts/tools/graph-impact.sh --repo . --symbol <name>` for transitive dependents. These are the authoritative structural answers.
|
|
16904
17079
|
3. **Modules → risk ranking** — rank with `scripts/tools/hotspot-rank.sh --repo . [--top N]`. High-fanIn symbols are the most likely entry points for impact.
|
|
16905
17080
|
4. **Concept → public API** — for API-shaped concepts, read the engine's `.routes` (`get_architecture` output, detected HTTP/gRPC/GraphQL routes) for matching service surface.
|
|
@@ -16936,22 +17111,87 @@ These fields are appended to `~/.draft/metrics.jsonl` along with the existing sk
|
|
|
16936
17111
|
|
|
16937
17112
|
## Tooling Wrappers
|
|
16938
17113
|
|
|
16939
|
-
For common query modes, prefer the deterministic wrappers that ship with the plugin. Resolve their location via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)) before invoking:
|
|
17114
|
+
For common query modes, prefer the deterministic wrappers that ship with the plugin. Resolve their location via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)) before invoking. Skills run with cwd = the user's project and `${CLAUDE_PLUGIN_ROOT}` is **not** exported into skill Bash, so a bare `scripts/tools/foo.sh` fails — establish `DRAFT_TOOLS` once before the first helper call, in the same Bash session as your tool calls (re-establish it if you split helper calls into a separate, later Bash block):
|
|
16940
17115
|
|
|
16941
17116
|
```bash
|
|
16942
|
-
DRAFT_TOOLS="$
|
|
16943
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
17117
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
17118
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
17119
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
16944
17120
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
16945
17121
|
```
|
|
16946
17122
|
|
|
16947
17123
|
| Wrapper | Graph mode | Behavior on missing graph |
|
|
16948
17124
|
|---|---|---|
|
|
16949
|
-
| `bash "$DRAFT_TOOLS/hotspot-rank.sh" [--top N]
|
|
16950
|
-
| `bash "$DRAFT_TOOLS/cycle-detect.sh"` |
|
|
16951
|
-
| `bash "$DRAFT_TOOLS/mermaid-from-graph.sh" [--diagram module-deps\|proto-map]` |
|
|
17125
|
+
| `bash "$DRAFT_TOOLS/hotspot-rank.sh" [--top N]` | complexity-weighted hotspots | Emits `{hotspots:[],source:"unavailable"}` and exits 2 |
|
|
17126
|
+
| `bash "$DRAFT_TOOLS/cycle-detect.sh"` | call cycles | Emits `{cycles:[],source:"unavailable"}` and exits 2 |
|
|
17127
|
+
| `bash "$DRAFT_TOOLS/mermaid-from-graph.sh" [--diagram module-deps\|co-change\|proto-map]` | diagram text | Emits an empty mermaid block and exits 2 |
|
|
17128
|
+
| `bash "$DRAFT_TOOLS/graph-callers.sh" --symbol N [--transitive[=N]] [--prod-only] [--qualified]` | callers | `{callers:[],status:"unavailable",source:"unavailable"}`, exit 2 |
|
|
17129
|
+
| `bash "$DRAFT_TOOLS/graph-snippet.sh" --qualified N` | verified source + caller/callee counts | `{status:"unavailable",source:"unavailable"}`, exit 2 |
|
|
17130
|
+
| `bash "$DRAFT_TOOLS/graph-search.sh" --query "STR" [--limit N]` | semantic/ranked search | `{results:[],source:"unavailable"}`, exit 2 |
|
|
17131
|
+
| `bash "$DRAFT_TOOLS/graph-tests.sh" (--symbol N \| --untested)` | test→symbol coverage | `{tests:[]/untested:[],source:"unavailable"}`, exit 2 |
|
|
17132
|
+
| `bash "$DRAFT_TOOLS/graph-deps.sh" [--file PATH]` | real IMPORTS graph | `{imports:[],source:"unavailable"}`, exit 2 |
|
|
17133
|
+
| `bash "$DRAFT_TOOLS/graph-hierarchy.sh" [--symbol N \| --derived N]` | INHERITS tree | `{edges:[],source:"unavailable"}`, exit 2 |
|
|
17134
|
+
| `bash "$DRAFT_TOOLS/graph-errors.sh" (--symbol N \| --type N)` | RAISES/THROWS | `{raises:[]/raisers:[],source:"unavailable"}`, exit 2 |
|
|
17135
|
+
| `bash "$DRAFT_TOOLS/graph-risk.sh" [--min-complexity N]` | pre-computed risk flags | `{risky:[],source:"unavailable"}`, exit 2 |
|
|
17136
|
+
| `bash "$DRAFT_TOOLS/graph-query.sh" (--cypher STR \| --tool NAME --json '{...}')` | generic read-only passthrough | `{source:"unavailable"}`, exit 2 |
|
|
17137
|
+
| `bash "$DRAFT_TOOLS/graph-traces.sh" ingest --file F --experimental` | runtime traces (experimental write) | `{source:"unavailable"}`, exit 2 |
|
|
16952
17138
|
|
|
16953
17139
|
For lower-level modes, call the engine directly: `codebase-memory-mcp cli <tool> '<json>'` (see the tool list in [bin/README.md](../../bin/README.md)).
|
|
16954
17140
|
|
|
17141
|
+
### Capability wrappers & dialect limits (graph-tooling-v2)
|
|
17142
|
+
|
|
17143
|
+
All Cypher lives in `scripts/tools/_graph_queries.sh` (the single source of query
|
|
17144
|
+
truth). Wrappers are thin arg-parse → builder → fail-loud JSON. Three contracts
|
|
17145
|
+
matter when consuming them:
|
|
17146
|
+
|
|
17147
|
+
**Fail-loud status.** Symbol-scoped wrappers (`graph-callers`, `graph-snippet`,
|
|
17148
|
+
`graph-tests --symbol`, `graph-hierarchy --symbol/--derived`, `graph-errors`)
|
|
17149
|
+
emit a `status` field that distinguishes the three real outcomes — never read a
|
|
17150
|
+
bare `[]` as a confirmed true negative:
|
|
17151
|
+
|
|
17152
|
+
| `status` | Meaning |
|
|
17153
|
+
|---|---|
|
|
17154
|
+
| `ok` | node found, edges returned |
|
|
17155
|
+
| `no-edges` | node exists but has no matching edge (a *real* negative) |
|
|
17156
|
+
| `no-match` | the named symbol was not found at all (check the name / try `--qualified`) |
|
|
17157
|
+
| `unavailable` | engine could not be resolved (exit 2) |
|
|
17158
|
+
|
|
17159
|
+
**Verified engine param shapes** (engine v0.8.x — the runtime source of truth is
|
|
17160
|
+
`get_graph_schema`; do not hardcode a property set):
|
|
17161
|
+
|
|
17162
|
+
```bash
|
|
17163
|
+
get_code_snippet '{"project":P,"qualified_name":"pkg.Mod.Class.method"}' # → source + callers/callees counts + transitive_loop_depth
|
|
17164
|
+
search_graph '{"project":P,"query":"order submission to broker","limit":5}' # → {results:[{name,qualified_name,label,file_path,rank}]}
|
|
17165
|
+
trace_path '{"project":P,"function_name":"submit_order","depth":3,"direction":"both"}' # depth-bounded caller EXPANDER, not an A→B pathfinder
|
|
17166
|
+
detect_changes '{"project":P}' # → {changed_files, changed_count, impacted_symbols, depth}
|
|
17167
|
+
get_graph_schema '{"project":P}' # → {node_labels:[{label,count,properties}], edge_types:[{type,count}]}
|
|
17168
|
+
```
|
|
17169
|
+
|
|
17170
|
+
**Cypher dialect — keep queries inside the SAFE set:**
|
|
17171
|
+
|
|
17172
|
+
- ✅ SAFE: fixed-length patterns, single/multi-hop explicit patterns, `=`, `<`,
|
|
17173
|
+
`STARTS WITH`, `NOT x STARTS WITH`, `AND`, `OR`, relationship-type alternation
|
|
17174
|
+
`[:A|B]`, simple `count(x)`.
|
|
17175
|
+
- ❌ UNSAFE (rejected or silently empty): `coalesce()`, `<>` / `!=` / `<=` / `>=`,
|
|
17176
|
+
`NOT EXISTS(...)`, `NOT (pattern)`, `WITH`-grouping aggregation, multi-pattern
|
|
17177
|
+
joins. `graph-query.sh --cypher` returns the engine's raw error, not a silent
|
|
17178
|
+
empty — but the builders never emit these forms.
|
|
17179
|
+
|
|
17180
|
+
**Caveats consumers must respect:**
|
|
17181
|
+
|
|
17182
|
+
- **`--prod-only` is best-effort.** It filters `is_test=false AND NOT file_path
|
|
17183
|
+
STARTS WITH 'tests/'`. `is_test` is partially populated by the engine, so test
|
|
17184
|
+
helpers/mocks can leak through. Treat it as a heuristic, not a guarantee.
|
|
17185
|
+
- **`--transitive` uses the `trace_path` expander** (a depth-bounded caller
|
|
17186
|
+
expansion from one symbol), not a from→to pathfinder. "Path between A and B"
|
|
17187
|
+
still needs an explicit fixed-length `graph-query.sh --cypher` pattern.
|
|
17188
|
+
- **Honest caps.** `cycle-detect`, `graph-deps`, `graph-risk`, `graph-tests
|
|
17189
|
+
--untested` cap their output and report `"truncated": true` when the cap is
|
|
17190
|
+
hit — results are a sample, not exhaustive.
|
|
17191
|
+
- **`graph-tests --untested`** is a set difference (exported symbols minus TESTS
|
|
17192
|
+
targets) because the dialect has no anti-join; coverage depends on the engine
|
|
17193
|
+
resolving test→symbol links, which varies by language/framework.
|
|
17194
|
+
|
|
16955
17195
|
## Pre-Check
|
|
16956
17196
|
|
|
16957
17197
|
Verify graph data exists before any graph operation:
|
|
@@ -17040,13 +17280,80 @@ scripts/tools/mermaid-from-graph.sh --repo . --diagram proto-map # detected
|
|
|
17040
17280
|
|
|
17041
17281
|
Emits a ready-to-inject ` ```mermaid ``` ` block on the fly (computed live by the engine), or an empty stub (exit 2) when the engine is unavailable. Diagrams are generated at the moment of use — they are never committed.
|
|
17042
17282
|
|
|
17283
|
+
### Snippet — verified source + caller/callee counts
|
|
17284
|
+
|
|
17285
|
+
```bash
|
|
17286
|
+
scripts/tools/graph-snippet.sh --repo . --qualified <pkg.Mod.Class.method>
|
|
17287
|
+
```
|
|
17288
|
+
|
|
17289
|
+
Output: `{qualified_name, file, start_line, end_line, callers, callees, transitive_loop_depth, complexity, code, status, source}`. Prefer this over grep+Read when you have a qualified name — it returns the engine's attributed source plus pre-computed counts.
|
|
17290
|
+
|
|
17291
|
+
### Search — semantic / ranked symbol lookup
|
|
17292
|
+
|
|
17293
|
+
```bash
|
|
17294
|
+
scripts/tools/graph-search.sh --repo . --query "auth token refresh" [--limit N]
|
|
17295
|
+
```
|
|
17296
|
+
|
|
17297
|
+
Output: `{query, results[{name, qualified_name, label, file, rank}], total, source}`. Use when the user names an **intent/concept** rather than an exact symbol — this is the first move in the Concept-to-Files recipe.
|
|
17298
|
+
|
|
17299
|
+
### Tests — coverage edges and untested surface
|
|
17300
|
+
|
|
17301
|
+
```bash
|
|
17302
|
+
scripts/tools/graph-tests.sh --repo . --symbol <name> # tests covering a symbol
|
|
17303
|
+
scripts/tools/graph-tests.sh --repo . --untested # exported symbols with no TESTS edge
|
|
17304
|
+
```
|
|
17305
|
+
|
|
17306
|
+
Output: `{symbol, tests[{test,file}], status, source}` or `{untested[{symbol,file}], total, truncated, source}`. Feeds coverage gaps for `init`/`testing-strategy`/`coverage`.
|
|
17307
|
+
|
|
17308
|
+
### Deps — real module/file import graph
|
|
17309
|
+
|
|
17310
|
+
```bash
|
|
17311
|
+
scripts/tools/graph-deps.sh --repo . [--file PATH]
|
|
17312
|
+
```
|
|
17313
|
+
|
|
17314
|
+
Output: `{imports[{src,dst}], total, truncated, source}` from actual `IMPORTS` edges (self-imports filtered). This is the auto-derived dependency graph behind `mermaid-from-graph.sh --diagram module-deps` and `architecture.md §9`.
|
|
17315
|
+
|
|
17316
|
+
### Hierarchy — class inheritance
|
|
17317
|
+
|
|
17318
|
+
```bash
|
|
17319
|
+
scripts/tools/graph-hierarchy.sh --repo . [--symbol <Class> | --derived <Base>]
|
|
17320
|
+
```
|
|
17321
|
+
|
|
17322
|
+
Output: `{edges[{child,parent}], status, source}`. `--derived` gives the blast radius of changing a base class.
|
|
17323
|
+
|
|
17324
|
+
### Errors — error-propagation paths
|
|
17325
|
+
|
|
17326
|
+
```bash
|
|
17327
|
+
scripts/tools/graph-errors.sh --repo . --symbol <name> # what it raises/throws
|
|
17328
|
+
scripts/tools/graph-errors.sh --repo . --type <ErrType> # who raises/throws that type
|
|
17329
|
+
```
|
|
17330
|
+
|
|
17331
|
+
Output: `{symbol, raises[...], status, source}` or `{type, raisers[...], status, source}`. `--type` drives fail-closed audits.
|
|
17332
|
+
|
|
17333
|
+
### Risk — pre-computed risk hotspots
|
|
17334
|
+
|
|
17335
|
+
```bash
|
|
17336
|
+
scripts/tools/graph-risk.sh --repo . [--min-complexity N]
|
|
17337
|
+
```
|
|
17338
|
+
|
|
17339
|
+
Output: `{risky[{symbol, file, complexity, flags}], total, truncated, source}` from the engine's pre-computed flags (`unguarded_recursion`, `recursion_in_loop`, `alloc_in_loop`, `linear_scan_in_loop`). High-signal input for `bughunt`/`deep-review` — the engine already found these.
|
|
17340
|
+
|
|
17341
|
+
### Generic — read-only escape hatch (all 20 edges / ~30 properties)
|
|
17342
|
+
|
|
17343
|
+
```bash
|
|
17344
|
+
scripts/tools/graph-query.sh --repo . --cypher 'MATCH (f)-[:WRITES]->(v) RETURN f.name, v.name LIMIT 50'
|
|
17345
|
+
scripts/tools/graph-query.sh --repo . --tool get_graph_schema --json '{}'
|
|
17346
|
+
```
|
|
17347
|
+
|
|
17348
|
+
Unlocks any edge type or node property without a purpose-built wrapper. Write verbs are rejected; stay inside the SAFE dialect set (above). Emits raw engine JSON.
|
|
17349
|
+
|
|
17043
17350
|
### Indexing / refreshing the gate marker
|
|
17044
17351
|
|
|
17045
17352
|
```bash
|
|
17046
17353
|
scripts/tools/graph-snapshot.sh --repo .
|
|
17047
17354
|
```
|
|
17048
17355
|
|
|
17049
|
-
Indexes the repo into the engine and writes the `draft/graph/schema.yaml` gate marker. It writes **no** graph data. Run during `draft init` and `draft graph`, or whenever the index should be refreshed.
|
|
17356
|
+
Indexes the repo into the engine and writes the `draft/graph/schema.yaml` gate marker (now including the `detect_changes` delta: `changed_files`/`impacted_symbols`). It writes **no** graph data. Run during `draft init` and `draft graph`, or whenever the index should be refreshed.
|
|
17050
17357
|
|
|
17051
17358
|
## Finding the Engine (Resolution + Usage Report)
|
|
17052
17359
|
|
|
@@ -17796,14 +18103,81 @@ See verification-gates.md and template-hygiene.md for usage contracts.
|
|
|
17796
18103
|
|
|
17797
18104
|
---
|
|
17798
18105
|
shared: tool-resolver
|
|
17799
|
-
applies_to:
|
|
18106
|
+
applies_to: every skill that invokes scripts/tools/*
|
|
17800
18107
|
---
|
|
17801
18108
|
|
|
17802
|
-
# tool-resolver
|
|
18109
|
+
# tool-resolver
|
|
17803
18110
|
|
|
17804
|
-
|
|
18111
|
+
Canonical procedure for locating Draft's bundled shell helpers (`scripts/tools/*.sh`)
|
|
18112
|
+
from inside a skill.
|
|
17805
18113
|
|
|
17806
|
-
|
|
18114
|
+
## Why this exists
|
|
18115
|
+
|
|
18116
|
+
When Claude runs a draft skill, the shell's **working directory is the user's
|
|
18117
|
+
project**, not the plugin. The helpers live inside the plugin install directory,
|
|
18118
|
+
which on a marketplace/npm install is `~/.claude/plugins/cache/<marketplace>/draft/<version>/`
|
|
18119
|
+
— never the cwd. `${CLAUDE_PLUGIN_ROOT}` is **not** exported into skill-driven Bash
|
|
18120
|
+
(it is only set for hooks, MCP/LSP servers, and monitor commands), so a bare
|
|
18121
|
+
`scripts/tools/foo.sh` or `${CLAUDE_PLUGIN_ROOT}/...` invocation silently fails.
|
|
18122
|
+
|
|
18123
|
+
Every skill MUST resolve `DRAFT_TOOLS` and invoke helpers as `"$DRAFT_TOOLS/<tool>.sh"`.
|
|
18124
|
+
|
|
18125
|
+
## Resolution order
|
|
18126
|
+
|
|
18127
|
+
`DRAFT_TOOLS` resolves to the first directory that exists, in this order:
|
|
18128
|
+
|
|
18129
|
+
1. `${DRAFT_PLUGIN_ROOT}/scripts/tools` — explicit override (testing / pinned installs)
|
|
18130
|
+
2. `$(cat ~/.cache/draft/plugin-root)/scripts/tools` — install marker written by `draft install` (authoritative)
|
|
18131
|
+
3. `${CLAUDE_PLUGIN_ROOT}/scripts/tools` — set in hook/MCP contexts; harmless to probe
|
|
18132
|
+
4. `installed_plugins.json → installPath` for `draft@*` — Claude Code's own registry (needs `jq`)
|
|
18133
|
+
5. `~/.claude/plugins/cache/*/draft/*/scripts/tools` — newest cache install (glob, `sort -V`)
|
|
18134
|
+
6. `~/.claude/plugins/marketplaces/*draft*/scripts/tools` — marketplace clone
|
|
18135
|
+
7. `~/.cursor/plugins/local/draft/scripts/tools` — Cursor local install
|
|
18136
|
+
8. `$PWD/scripts/tools` — dev / dogfooding (running inside the draft repo itself)
|
|
18137
|
+
|
|
18138
|
+
The marker (step 2) is the fast, authoritative path; steps 5–6 are the glob fallback
|
|
18139
|
+
that keeps resolution working on installs predating the marker (no reinstall required).
|
|
18140
|
+
|
|
18141
|
+
## Skill preamble (copy verbatim)
|
|
18142
|
+
|
|
18143
|
+
Establish `DRAFT_TOOLS` once, before the first helper call, in the **same Bash
|
|
18144
|
+
session** that runs your tool calls — exactly as skills already define `REPO_ABS`
|
|
18145
|
+
once and reuse it. Env vars do not persist across **separate** Bash tool
|
|
18146
|
+
invocations (only the cwd does), so if you split helper calls into a later, separate
|
|
18147
|
+
Bash block, re-establish `DRAFT_TOOLS` there too:
|
|
18148
|
+
|
|
18149
|
+
```bash
|
|
18150
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
18151
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
18152
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
18153
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
18154
|
+
```
|
|
18155
|
+
|
|
18156
|
+
Then invoke helpers through the variable:
|
|
18157
|
+
|
|
18158
|
+
```bash
|
|
18159
|
+
"$DRAFT_TOOLS/hotspot-rank.sh" --repo . --top 5
|
|
18160
|
+
"$DRAFT_TOOLS/graph-arch.sh" --repo .
|
|
18161
|
+
```
|
|
18162
|
+
|
|
18163
|
+
The four-line inline preamble is self-contained and is the recommended form for
|
|
18164
|
+
skills — it needs no marker file and no prior `source`. The full 8-step resolver
|
|
18165
|
+
(adding the `${DRAFT_PLUGIN_ROOT}` override, `${CLAUDE_PLUGIN_ROOT}`, the jq-registry
|
|
18166
|
+
lookup, and the Cursor path) is shipped as `scripts/tools/resolve-tools.sh` for tests
|
|
18167
|
+
and for callers that prefer a single source of truth:
|
|
18168
|
+
|
|
18169
|
+
```bash
|
|
18170
|
+
DRAFT_TOOLS="$("$PWD/scripts/tools/resolve-tools.sh" 2>/dev/null)" # dev/dogfood
|
|
18171
|
+
# installed: "$(cat ~/.cache/draft/plugin-root)/scripts/tools/resolve-tools.sh"
|
|
18172
|
+
```
|
|
18173
|
+
|
|
18174
|
+
## The engine binary is separate
|
|
18175
|
+
|
|
18176
|
+
`DRAFT_TOOLS` locates the **wrapper scripts**. Each wrapper then resolves the
|
|
18177
|
+
`codebase-memory-mcp` **engine binary** itself via `_lib.sh:find_memory_bin`
|
|
18178
|
+
(`DRAFT_MEMORY_BIN` → `$PATH` → `~/.cache/draft/bin/` → vendored). Do not conflate
|
|
18179
|
+
the two: a wrapper that runs but reports `source: unavailable` means the engine
|
|
18180
|
+
binary is missing, not the wrapper.
|
|
17807
18181
|
|
|
17808
18182
|
</core-file>
|
|
17809
18183
|
|
|
@@ -20209,8 +20583,9 @@ validator chain via the canonical resolver pattern (see
|
|
|
20209
20583
|
[core/shared/verification-gates.md](../../core/shared/verification-gates.md)):
|
|
20210
20584
|
|
|
20211
20585
|
```bash
|
|
20212
|
-
DRAFT_TOOLS="$
|
|
20213
|
-
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$
|
|
20586
|
+
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
|
|
20587
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
|
|
20588
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
|
|
20214
20589
|
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
20215
20590
|
"$DRAFT_TOOLS/check-track-hygiene.sh" .; "$DRAFT_TOOLS/verify-citations.sh" .
|
|
20216
20591
|
"$DRAFT_TOOLS/verify-doc-anchors.sh" .; "$DRAFT_TOOLS/check-graph-usage-report.sh" .
|