@drafthq/draft 3.0.0 → 3.2.0

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 (62) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +3 -3
  4. package/bin/README.md +4 -7
  5. package/cli/src/hosts/claude-code.js +4 -1
  6. package/cli/src/installer.js +12 -5
  7. package/core/shared/condensation.md +8 -8
  8. package/core/shared/draft-context-loading.md +5 -9
  9. package/core/shared/graph-query.md +170 -33
  10. package/core/shared/graph-usage-report.md +1 -1
  11. package/core/shared/pattern-learning.md +2 -2
  12. package/core/shared/red-flags.md +3 -3
  13. package/core/templates/ai-context.md +1 -1
  14. package/core/templates/architecture.md +3 -3
  15. package/integrations/agents/AGENTS.md +299 -145
  16. package/integrations/copilot/.github/copilot-instructions.md +299 -145
  17. package/package.json +2 -1
  18. package/scripts/lib.sh +11 -3
  19. package/scripts/tools/_graph_queries.sh +102 -0
  20. package/scripts/tools/adr-index.sh +2 -2
  21. package/scripts/tools/check-scope-conflicts.sh +2 -2
  22. package/scripts/tools/check-skill-line-caps.sh +2 -2
  23. package/scripts/tools/cycle-detect.sh +22 -15
  24. package/scripts/tools/diff-templates-vs-tracks.sh +2 -2
  25. package/scripts/tools/fix-whitespace.sh +15 -9
  26. package/scripts/tools/graph-arch.sh +72 -0
  27. package/scripts/tools/graph-callers.sh +71 -20
  28. package/scripts/tools/graph-deps.sh +76 -0
  29. package/scripts/tools/graph-errors.sh +97 -0
  30. package/scripts/tools/graph-hierarchy.sh +89 -0
  31. package/scripts/tools/graph-impact.sh +1 -0
  32. package/scripts/tools/graph-init.sh +3 -3
  33. package/scripts/tools/graph-query.sh +124 -0
  34. package/scripts/tools/graph-risk.sh +81 -0
  35. package/scripts/tools/graph-search.sh +84 -0
  36. package/scripts/tools/graph-snapshot.sh +63 -50
  37. package/scripts/tools/graph-snippet.sh +92 -0
  38. package/scripts/tools/graph-tests.sh +112 -0
  39. package/scripts/tools/graph-traces.sh +83 -0
  40. package/scripts/tools/hotspot-rank.sh +44 -15
  41. package/scripts/tools/manage-symlinks.sh +1 -1
  42. package/scripts/tools/mermaid-from-graph.sh +31 -10
  43. package/scripts/tools/parse-reports.sh +1 -1
  44. package/scripts/tools/verify-doc-anchors.sh +2 -2
  45. package/scripts/tools/verify-graph-binary.sh +1 -1
  46. package/skills/GRAPH.md +2 -2
  47. package/skills/bughunt/SKILL.md +1 -1
  48. package/skills/debug/SKILL.md +3 -3
  49. package/skills/decompose/SKILL.md +5 -5
  50. package/skills/deep-review/SKILL.md +2 -2
  51. package/skills/deploy-checklist/SKILL.md +2 -2
  52. package/skills/graph/SKILL.md +1 -1
  53. package/skills/implement/SKILL.md +1 -1
  54. package/skills/init/SKILL.md +62 -42
  55. package/skills/init/references/architecture-spec.md +12 -11
  56. package/skills/learn/SKILL.md +5 -5
  57. package/skills/quick-review/SKILL.md +3 -3
  58. package/skills/review/SKILL.md +7 -7
  59. package/skills/tech-debt/SKILL.md +2 -2
  60. package/scripts/tools/okf-bundle.sh +0 -141
  61. package/scripts/tools/okf-check.sh +0 -137
  62. package/scripts/tools/okf-emit.sh +0 -161
@@ -177,7 +177,7 @@ emit() {
177
177
  if ((EMIT_JSON)); then
178
178
  printf '{"violation_count": %d, "violations": [\n' "$violation_count"
179
179
  local first=1 v track kind file line detail
180
- for v in "${violations[@]}"; do
180
+ for v in ${violations[@]+"${violations[@]}"}; do
181
181
  IFS='|' read -r track kind file line detail <<< "$v"
182
182
  if ((first)); then first=0; else printf ',\n'; fi
183
183
  printf ' {"track":"%s","kind":"%s","file":"%s","line":%s,"detail":"%s"}' \
@@ -192,7 +192,7 @@ emit() {
192
192
  printf 'ANCHORS: %d violation(s) across %d track(s).\n' \
193
193
  "$violation_count" "${#TRACK_PATHS[@]}" >&2
194
194
  local v track kind file line detail
195
- for v in "${violations[@]}"; do
195
+ for v in ${violations[@]+"${violations[@]}"}; do
196
196
  IFS='|' read -r track kind file line detail <<< "$v"
197
197
  printf ' [%s] %s/%s:%s — %s\n' "$kind" "$track" "$file" "$line" "$detail" >&2
198
198
  done
@@ -141,7 +141,7 @@ if [[ -d "$REPO/draft" ]]; then
141
141
  mkdir -p "$REPO/draft"
142
142
  cat > "$REPO/draft/.graph-binary-report.json" <<EOF
143
143
  {
144
- "detected_at": "$(date -Iseconds 2>/dev/null || date)",
144
+ "detected_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
145
145
  "engine_bin": "$(json_escape "$MEMORY_BIN")",
146
146
  "source": "$(json_escape "$SOURCE")",
147
147
  "arch": "$(json_escape "$ARCH")",
package/skills/GRAPH.md CHANGED
@@ -301,8 +301,8 @@ init → learn → (updates guardrails.md)
301
301
  init ──────────► │ architecture.md ──► .ai-context.md │
302
302
  │ product.md tech-stack.md guardrails.md │
303
303
  │ workflow.md tracks.md tech-debt.md │
304
- │ graph/ (module-graph, hotspots, proto,
305
- module-deps.mermaid, proto-map..)
304
+ │ graph/ (schema.yaml gate; all data queried
305
+ live via codebase-memory-mcp engine)
306
306
  └──────────────────┬──────────────────────────┘
307
307
  │ read by all skills
308
308
  ┌───────────────────────────┼───────────────────────┐
@@ -68,7 +68,7 @@ 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) — Read `architecture.json` (`.packages`) for dependency awareness. Flag dependencies on unexpected modules. Flag code in modules involved in dependency cycles as higher risk. Use `hotspots.jsonl` to prioritize analysis of high-complexity, high-fanIn files. See `core/shared/graph-query.md`.
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`.
72
72
  - **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
73
 
74
74
  ### 2. Confirm Scope
@@ -11,10 +11,10 @@ You are conducting a structured debugging session following systematic investiga
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. During Steps 3–4 (Isolate, Diagnose):
13
13
 
14
- 1. Locate the suspect file's module via `draft/graph/architecture.json` (`.packages`) before tracing data flow.
14
+ 1. Locate the suspect file's module via `scripts/tools/graph-arch.sh --repo .` before tracing data flow.
15
15
  2. Use `scripts/tools/graph-callers.sh --repo . --symbol <fn>` to enumerate call sites of suspect functions — not `grep`.
16
16
  3. Use `scripts/tools/graph-impact.sh --repo . --file <path>` to size the blast radius before proposing a fix.
17
- 4. Cross-check `draft/graph/hotspots.jsonl` to know whether the file is high-fanIn (any fix needs extra caution).
17
+ 4. Run `scripts/tools/hotspot-rank.sh --repo .` to know whether the file is high-fanIn (any fix needs extra caution).
18
18
 
19
19
  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
20
 
@@ -62,7 +62,7 @@ Key context for debugging:
62
62
  - `.ai-context.md` — Module boundaries, data flows, invariants (crucial for tracing)
63
63
  - `tech-stack.md` — Language-specific debugging tools and techniques
64
64
  - `guardrails.md` — Known anti-patterns that may be causing the issue
65
- - `draft/graph/` (MANDATORY when present) — Load `architecture.json` for dependency/module context and `hotspots.jsonl` 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).
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).
66
66
 
67
67
  ## Step 1: Parse Arguments
68
68
 
@@ -11,8 +11,8 @@ You are decomposing a project or track into modules with clear responsibilities,
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. Module identification (Step 3) and dependency mapping (Step 4) **start from the graph**:
13
13
 
14
- 1. Load `draft/graph/architecture.json` (`.packages`) for the authoritative module list and fan-in/out.
15
- 2. Load `draft/graph/hotspots.jsonl` to identify candidate modules to split.
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
16
  3. Use `scripts/tools/graph-callers.sh`/`graph-impact.sh` on demand for symbols/callers inside a candidate module.
17
17
  4. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate existing cycles before proposing new boundaries.
18
18
 
@@ -156,10 +156,10 @@ ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
156
156
 
157
157
  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
158
 
159
- - **Module boundaries**: Read `draft/graph/architecture.json` (`.packages`, `.languages`) — module list with node counts and per-language file counts
159
+ - **Module boundaries**: Query `scripts/tools/graph-arch.sh --repo .` — module list with node counts and per-language file counts
160
160
  - **Dependency edges**: Weighted inter-module dependencies with exact include counts — replaces manual import tracing
161
161
  - **Cycle detection**: Circular dependency paths already computed — use for identifying tight coupling and decomposition candidates
162
- - **Hotspots**: Load `draft/graph/hotspots.jsonl` — high-complexity files that may need further decomposition
162
+ - **Hotspots**: Run `scripts/tools/hotspot-rank.sh --repo .` — high-complexity files that may need further decomposition
163
163
  - **Per-module detail**: query `scripts/tools/graph-callers.sh`/`graph-impact.sh` for symbol/call detail within modules of interest
164
164
 
165
165
  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.
@@ -615,7 +615,7 @@ When decomposition involves breaking a monolith, choosing module boundaries, or
615
615
 
616
616
  Before printing the completion announcement, internally verify and report:
617
617
 
618
- 1. **Graph files queried** — which JSONL files were loaded (e.g. `architecture.json, hotspots.jsonl` and tools like `cycle-detect.sh`).
618
+ 1. **Graph data queried** — which live-engine tools were invoked (e.g. `get_architecture`, `hotspot-rank.sh`, `cycle-detect.sh`).
619
619
  2. **Layer 1 files deliberately skipped** — list any `.ai-context.md` sections, `tech-stack.md`, `product.md`, `workflow.md` you skipped as irrelevant to this decomposition. Be explicit; do not silently skip.
620
620
  3. **Filesystem grep fallback justification** — for every `grep`/`find` run, state the concept it searched for and quote the graph-miss sentence.
621
621
  4. **Citation Gate audit** — scan every Citation column in the generated component table, dependencies table, and LLD class table. Report:
@@ -11,10 +11,10 @@ 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 `architecture.json` for the audited module's structure — do not enumerate via `find`.
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
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
16
  3. Run `scripts/tools/cycle-detect.sh --repo .` and flag any cycle that includes the audited module as Architecture Resilience finding.
17
- 4. Cross-check `draft/graph/hotspots.jsonl` to identify high-fanIn files inside the module — these get deeper inspection.
17
+ 4. Run `scripts/tools/hotspot-rank.sh --repo .` to identify high-fanIn files inside the module — these get deeper inspection.
18
18
 
19
19
  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
20
 
@@ -12,8 +12,8 @@ You are generating a pre-deployment verification checklist customized to this pr
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
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 read `draft/graph/architecture.json` for the module overview) to ensure no fresh cycles were introduced after HLD sign-off.
16
- 3. Load `draft/graph/hotspots.jsonl` — any hotspot in the diff escalates the Resiliency row of Phase 0.
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.
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
 
@@ -55,7 +55,7 @@ echo "Engine: $ENGINE"
55
55
 
56
56
  ## Step 3: Build / refresh the snapshot
57
57
 
58
- One call resolves the engine, indexes the repo (incrementally on refresh), and writes the committed snapshot under `<repo>/draft/graph/` — `schema.yaml`, `architecture.json`, `hotspots.jsonl`, `module-deps.mermaid`, `proto-map.mermaid`, and an Open Knowledge Format bundle under `okf/` (a portable, vendor-neutral markdown mirror of the graph`index.md` + one cross-linked `modules/<name>.md` concept per module).
58
+ 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 engineno snapshot files are committed beyond `schema.yaml`.
59
59
 
60
60
  ```bash
61
61
  scripts/tools/graph-snapshot.sh --repo "$REPO_ABS"
@@ -133,7 +133,7 @@ If one of these applies, route directly to the specialist workflow and stop this
133
133
  - Keep matching invariants as **active constraints** for this task — these govern code generation, not just review
134
134
  - If invariants reference lock ordering, fail-closed behavior, or data integrity rules: these are non-negotiable during implementation
135
135
  9. **Load graph context** (if `draft/graph/schema.yaml` exists):
136
- - Read `draft/graph/hotspots.jsonl` — check if any files this task will modify appear as hotspots
136
+ - Run `scripts/tools/hotspot-rank.sh --repo .` — check if any files this task will modify appear as hotspots
137
137
  - If modifying a hotspot file (high fanIn), warn: "This task modifies {file} (fanIn={N}). Changes here affect many downstream files. Consider running a graph impact query."
138
138
  - Query `scripts/tools/graph-impact.sh`/`graph-callers.sh` for the module(s) being modified — gives file-level dependency context
139
139
  - See `core/shared/graph-query.md` for on-demand query subroutines (callers, impact)
@@ -52,7 +52,7 @@ Initialize a Draft project for Context-Driven Development.
52
52
 
53
53
  ## Graph Fidelity & Diagram-First Priority (MANDATORY)
54
54
 
55
- The knowledge graph in `draft/graph/` (architecture.json with packages, languages, routes, and fan-in/out; hotspots.jsonl) is the **deterministic structural ground truth** for the system's actual architecture.
55
+ The knowledge graph served live by the local `codebase-memory-mcp` engine (packages, languages, routes, fan-in/out, hotspots) and queried via the `graph-*.sh` wrappers — is the **deterministic structural ground truth** for the system's actual architecture. Draft is engine-only: `draft/graph/` holds only the `schema.yaml` gate marker; all graph data comes from live queries.
56
56
 
57
57
  **You are running inside a powerful agentic coding environment** (Cursor, Claude Code, Copilot, Windsurf, etc.) that maintains its own rich, continuously updated index of the entire codebase. **Use that indexed knowledge aggressively** in addition to the explicit graph data and direct source reads. Your environment's index often captures higher-level intent, naming patterns, cross-file workflows, and architectural signals that the static graph may not fully express yet. Combine both sources:
58
58
  - Graph = authoritative modules, edges, public surfaces, hotspots, call relationships.
@@ -499,9 +499,9 @@ else
499
499
  fi
500
500
  ```
501
501
 
502
- - **Root init** writes `<root>/draft/graph/` — the committed, git-tracked whole-repo memory.
502
+ - **Root init** writes `<root>/draft/graph/schema.yaml` — the committed gate marker. Draft is engine-only: graph data is served live by the engine, never committed.
503
503
  - **Module init** also writes `draft/graph/root-link.json` (module→root); follow `root_graph` for cross-module understanding. The root spine is rebuilt first so the link is live.
504
- - Only `draft/graph/` is committed. The engine's `~/.cache` index is a disposable accelerator — never commit it; it rebuilds deterministically from source.
504
+ - Only `schema.yaml` (and `root-link.json` in a module) is committed. The engine's `~/.cache` index is the live structural store — never commit it; it rebuilds deterministically from source.
505
505
 
506
506
  Optionally record which engine was selected (usage-report contract):
507
507
 
@@ -511,15 +511,20 @@ scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null || true
511
511
 
512
512
  See `core/shared/graph-query.md` and `bin/README.md` for the query contract and engine resolution.
513
513
 
514
- If the build succeeds, `draft/graph/` is populated and later steps consume the always-load artifacts + injection slots.
514
+ If indexing succeeds, `draft/graph/schema.yaml` is written and later steps query the engine live for structure + populate the injection slots.
515
515
 
516
- ### 2. If graph build succeeds, load the always-load artifacts
516
+ ### 2. If indexing succeeds, query the engine for structural context
517
517
 
518
- Read these files to get structural context for all subsequent phases:
519
- - `draft/graph/schema.yaml` — module count, file count, edge count, language stats per module
520
- - `draft/graph/architecture.json` — module list (`.packages`) with fan-in/out
521
- - `draft/graph/architecture.json` `.routes` — detected service endpoints
522
- - `draft/graph/hotspots.jsonl` — all complexity hotspots (files ranked by lines + fanIn * 50)
518
+ Pull the architecture view once and reuse it across phases:
519
+
520
+ ```bash
521
+ ARCH=$(scripts/tools/graph-arch.sh --repo .)
522
+ ```
523
+
524
+ - `$ARCH | jq '.packages'` — module list with fan-in/out
525
+ - `$ARCH | jq '.routes'` — detected service endpoints
526
+ - `$ARCH | jq '.languages, .node_labels, .layers, .boundaries'` — language mix, node shape, layering
527
+ - `scripts/tools/hotspot-rank.sh --repo . --top 20` — complexity/fan-in hotspots (live)
523
528
 
524
529
  ### 3. Use graph data to accelerate Step 1.5
525
530
 
@@ -533,10 +538,10 @@ Read these files to get structural context for all subsequent phases:
533
538
  ### 4. Compute codebase tier and module priority
534
539
 
535
540
  **Step 1.4.5 — Compute Codebase Tier:**
536
- Read `draft/graph/schema.yaml`. Extract:
537
- - `M = stats.modules`
538
- - `F = stats.go_functions + stats.py_functions`
539
- - `P = stats.proto_rpcs`
541
+ From the live `$ARCH` (above), extract:
542
+ - `M = $ARCH | jq '.packages | length'` (modules)
543
+ - `F = $ARCH | jq '[.node_labels[] | select(.label=="Function" or .label=="Method") | .count] | add // 0'` (functions+methods)
544
+ - `P = $ARCH | jq '.routes | length'` (routes / RPCs)
540
545
 
541
546
  Apply tier table:
542
547
 
@@ -551,8 +556,8 @@ Apply tier table:
551
556
  Hold tier in memory. This governs: architecture.md length minimum, .ai-context.md budget, and module deep-dive depth.
552
557
 
553
558
  **Step 1.4.6 — Build Module Priority List:**
554
- From `draft/graph/hotspots.jsonl`: count hotspot files per module (group by `module` field).
555
- From `draft/graph/architecture.json` `.packages[]`: read `fan_in` per module.
559
+ From `scripts/tools/hotspot-rank.sh --repo .`: count hotspot symbols per module.
560
+ From `$ARCH | jq '.packages[]'`: read `fan_in` per module.
556
561
  Rank modules by: `(hotspot_count × 2) + fan_in_count`.
557
562
  Top-ranked modules drive Section 6 deep-dive ordering and depth. Modules ranked zero on both: summary treatment only.
558
563
  Hold ranked list in memory — it replaces directory scanning for module discovery.
@@ -572,7 +577,7 @@ The tool emits a ready-to-inject ` ```mermaid ``` ` block (or an empty stub on e
572
577
  ```
573
578
 
574
579
  For Section 20 (hotspots slot):
575
- Read `draft/graph/hotspots.jsonl` (or run `scripts/tools/hotspot-rank.sh --repo . --top 10`), take the top 10 by fanIn, build a markdown table:
580
+ Run `scripts/tools/hotspot-rank.sh --repo . --top 10`, take the top 10 by fanIn, build a markdown table:
576
581
  ```
577
582
  <!-- GRAPH:hotspots:START -->
578
583
  | Symbol | fanIn |
@@ -631,7 +636,7 @@ Perform a **one-time, exhaustive analysis** of the existing codebase. This is NO
631
636
 
632
637
  If the codebase is large (200+ files), focus on the module boundaries but still enumerate exhaustively within each module.
633
638
 
634
- > **Large codebase guardrail:** If the codebase exceeds 500 source files, limit Section 7 deep dives to the top 20 most-imported modules and summarize others in a table. Rank modules by the number of unique files that import/reference them (descending) — use `draft/graph/architecture.json` `.packages[].fan_in` if graph data is available. For dynamic languages where static import counting is impractical, rank by file count within each module directory (larger modules first). **Even for summarized modules, enumerate immediate sub-directories with file counts** (one-line per sub-dir) — this is cheap with graph data and provides essential navigation context.
639
+ > **Large codebase guardrail:** If the codebase exceeds 500 source files, limit Section 7 deep dives to the top 20 most-imported modules and summarize others in a table. Rank modules by the number of unique files that import/reference them (descending) — use the engine's `.packages[].fan_in` (`get_architecture`, captured as `$ARCH` in Step 1.4.2) if the engine is available. For dynamic languages where static import counting is impractical, rank by file count within each module directory (larger modules first). **Even for summarized modules, enumerate immediate sub-directories with file counts** (one-line per sub-dir) — this is cheap with graph data and provides essential navigation context.
635
640
 
636
641
  ### Parallel Analysis Protocol (Tiers 3–5)
637
642
 
@@ -658,16 +663,16 @@ For tier 3+, readers run simultaneously; wall clock = slowest reader, not the su
658
663
 
659
664
  #### Phase 0: Graph Data (already done in Step 1.4)
660
665
 
661
- The graph binary has already run. Use its output throughout this protocol:
662
- - `draft.tmp/graph/schema.yaml` — module list, file counts, tier metrics
663
- - `draft.tmp/graph/architecture.json` — `.packages[].fan_in` per module (for grouping)
664
- - `draft.tmp/graph/hotspots.jsonl` — top hotspot files per module (feed to readers)
666
+ The engine is already indexed. Query it live throughout this protocol (reuse `$ARCH` from Step 1.4.2):
667
+ - `$ARCH | jq '.packages'` — module list with `.fan_in`/`.fan_out` (for grouping)
668
+ - `$ARCH | jq '.languages, .node_labels'` — file/symbol counts, tier metrics
669
+ - `scripts/tools/hotspot-rank.sh --repo .` — top hotspot symbols per module (feed to readers)
665
670
 
666
671
  #### Phase 1: Spawn Parallel Module Readers
667
672
 
668
673
  **Step 1: Group modules.**
669
674
 
670
- From `draft.tmp/graph/architecture.json` `.packages[]`, extract all module names and their `fan_in` counts.
675
+ From `$ARCH | jq '.packages[]'`, extract all module names and their `fan_in` counts.
671
676
  Apply dependency-aware grouping (see `core/shared/parallel-analysis.md`).
672
677
  Use the modules-per-agent count from the tier table above (4 for tier 4/5; all modules in one agent for tier 1):
673
678
  - Assign highest fan-in modules to separate readers (tier 3+)
@@ -683,7 +688,7 @@ Hotspot files:
683
688
  execution/engine.go (847 lines, fanIn=12)
684
689
  execution/router.go (412 lines, fanIn=8)
685
690
  fill_processor/handler.go (623 lines, fanIn=5)
686
- Module edges (from architecture.json .packages fan-in/out):
691
+ Module edges (from $ARCH .packages fan-in/out):
687
692
  execution → [risk, data, services]
688
693
  fill_processor → [execution, persistence]
689
694
  ```
@@ -788,7 +793,7 @@ If any reader agent fails to produce valid JSON after one retry:
788
793
  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.
789
794
 
790
795
  1. Use the ranked module list from Step 1.4.6 (graph-first — do not re-scan by directory if Phase 0 succeeded).
791
- 2. For each top module (up to 20 by fan-in), read `draft/graph/modules/{name}.jsonl`, 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.
796
+ 2. For each top module (up to 20 by fan-in), query the engine for its symbols/callers (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, or `$ARCH | jq '.packages[] | select(.name=="<m>")'`), read the hotspot files and 3–5 key sources; embed graph blocks and at least one workflow/state diagram per significant module inside §4–§8 as appropriate.
792
797
  3. Always include §9 Graph Coverage Gaps and §10 Relationship when the Context Audit requires them.
793
798
  4. Run Completion Verification (defined later in this skill) before condensation. Fidelity, provenance, and gap honesty block completion — not line counts.
794
799
 
@@ -911,11 +916,11 @@ Follow these steps in order. The specific files to look for depend on the langua
911
916
 
912
917
  #### Phase 1: Discovery (Broad Scan)
913
918
 
914
- 1. **Map the directory tree**: Recursively list the project to understand the file layout. Note subdirectory groupings. (If Step 1.4 graph analysis succeeded, use `draft.tmp/graph/schema.yaml` module list instead — it is exhaustive and includes file counts.)
919
+ 1. **Map the directory tree**: Recursively list the project to understand the file layout. Note subdirectory groupings. (If Step 1.4 graph analysis succeeded, use the engine's `$ARCH | jq '.packages, .file_tree'` instead — it is exhaustive and includes file counts.)
915
920
 
916
921
  2. **Read build / dependency files**: These reveal the module structure, dependencies, and targets. (See language guide above for which files.)
917
922
 
918
- 3. **Read API definition files**: These define the module's data model and service interfaces. (See language guide above for which files. If Step 1.4 succeeded, `draft.tmp/graph/architecture.json` `.routes` already has all detected service endpoints.)
923
+ 3. **Read API definition files**: These define the module's data model and service interfaces. (See language guide above for which files. If Step 1.4 succeeded, the engine's `$ARCH | jq '.routes'` already has all detected service endpoints.)
919
924
 
920
925
  4. **Read interface / type definition files**: Class declarations, interface definitions, and type annotations reveal the public API and design intent.
921
926
 
@@ -1653,22 +1658,37 @@ For **brownfield** projects, run `/draft:learn` (no arguments — full codebase
1653
1658
 
1654
1659
  ## Completion
1655
1660
 
1656
- **Finalize OKF bundle:** After all `draft/` files are written, run the bundle tool
1657
- to (re)generate the Open Knowledge Format root index so the whole `draft/` tree is
1658
- a portable, vendor-neutral OKF bundle. This is the default no flag required.
1661
+ **Finalize the context index:** After all `draft/` files are written, author (or refresh)
1662
+ `draft/index.md` a plain, navigable index over the context bundle. No OKF framing, no
1663
+ special frontmatter; it is a human- and agent-readable table of contents.
1659
1664
 
1660
- ```bash
1661
- scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
1662
- scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
1665
+ Write `draft/index.md` with this structure (omit rows whose files were not generated):
1666
+
1667
+ ```md
1668
+ # <project> — Draft Context
1669
+
1670
+ Start here. This indexes the Draft context for this repo.
1671
+
1672
+ ## Context
1673
+ - [Architecture](architecture.md) — module map, dependencies, hotspots (graph-grounded)
1674
+ - [Product](product.md) — what this system does and for whom
1675
+ - [Tech Stack](tech-stack.md) — languages, frameworks, infra
1676
+ - [Workflow](workflow.md) — how work flows through the repo
1677
+ - [Guardrails](guardrails.md) — learned conventions and anti-patterns
1678
+ - [AI Context Map](.ai-context.md) — condensed orientation for agents
1679
+ - [AI Profile](.ai-profile.md) — repo profile + tiering
1680
+
1681
+ ## Tracks
1682
+ - [Track Index](tracks.md) — active, completed, and archived tracks
1683
+
1684
+ ## Knowledge graph
1685
+ - Engine-only (`codebase-memory-mcp`). Structural data is queried live via the
1686
+ `graph-*.sh` wrappers; `draft/graph/schema.yaml` is the gate marker. There is no
1687
+ committed graph mirror to browse.
1663
1688
  ```
1664
1689
 
1665
- `okf-bundle.sh` links every concept file present (`.ai-profile.md`, `.ai-context.md`,
1666
- `architecture.md`, `product.md`, `tech-stack.md`, `workflow.md`, `guardrails.md`), the
1667
- tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes from
1668
- the templates; `okf-check.sh` validates §9 conformance (frontmatter + `type` on every
1669
- concept; reserved `index.md`/`log.md` structure). It is advisory — report the result,
1670
- do not fail init. Note: operational reports later written into `draft/` (e.g.
1671
- `deep-review-report.md`) are not OKF concepts and will be flagged.
1690
+ Keep one-line descriptions accurate to what each file actually contains. This index is
1691
+ the single committed entry point to the `draft/` bundle.
1672
1692
 
1673
1693
  **Finalize run memory:** Update `draft/.state/run-memory.json`:
1674
1694
  - `status`: `"completed"`
@@ -1679,7 +1699,7 @@ For **Brownfield** projects, announce:
1679
1699
  "Draft initialized successfully with comprehensive analysis!
1680
1700
 
1681
1701
  Created:
1682
- - draft/index.md (Open Knowledge Format bundle root cross-links every concept)
1702
+ - draft/index.md (plain docs index navigable table of contents for the draft/ bundle)
1683
1703
  - draft/.ai-profile.md (20-50 lines — ultra-compact always-injected profile, Tier 0)
1684
1704
  - draft/.ai-context.md (200-400 lines — token-optimized AI context, self-contained, Tier 1)
1685
1705
  - draft/architecture.md (comprehensive human-readable engineering reference, Tier 2)
@@ -1714,7 +1734,7 @@ For **Greenfield** projects, announce:
1714
1734
  "Draft initialized successfully!
1715
1735
 
1716
1736
  Created:
1717
- - draft/index.md (Open Knowledge Format bundle root cross-links every concept)
1737
+ - draft/index.md (plain docs index navigable table of contents for the draft/ bundle)
1718
1738
  - draft/product.md
1719
1739
  - draft/tech-stack.md
1720
1740
  - draft/workflow.md
@@ -275,13 +275,13 @@ Only when material: authentication/authorization checkpoints, distributed transa
275
275
 
276
276
  **Core rule:** The graph is the source of truth for structure. LLM synthesis exists only to interpret the graph into actionable design understanding — primarily via one accurate workflow or state diagram per module — plus tiny supporting notes. The previous volume-oriented deep-dive expectations are superseded.
277
277
 
278
- For each module in `draft/graph/architecture.json` (`.packages[]`), produce a subsection whose **primary content** is the deterministic graph block followed by one synthesized behavioral diagram. Every module gets a slot; do not sample. The block's fan-in/out and node counts come from `.packages[]`; public API and key call edges come from live per-package queries (`scripts/tools/graph-callers.sh`, `graph-impact.sh`) and `hotspots.jsonl`.
278
+ For each module returned by `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'`, produce a subsection whose **primary content** is the deterministic graph block followed by one synthesized behavioral diagram. Every module gets a slot; do not sample. The block's fan-in/out and node counts come from `.packages[]`; public API and key call edges come from live per-package queries (`scripts/tools/graph-callers.sh`, `graph-impact.sh`) and `scripts/tools/hotspot-rank.sh --repo .`.
279
279
 
280
280
  #### 7.{N} {module-name}
281
281
 
282
282
  <!-- GRAPH:module-deep/{module-name}:START -->
283
283
  <!-- Rendered deterministic block: package name, node count, public API list, fan-in/fan-out (from
284
- architecture.json .packages), hotspot fan-in (from hotspots.jsonl), key call edges (from
284
+ get_architecture .packages), hotspot fan-in (from hotspot-rank.sh), key call edges (from
285
285
  graph-callers.sh/graph-impact.sh), entry points if known. No LLM prose inside fence. -->
286
286
  <!-- GRAPH:module-deep/{module-name}:END -->
287
287
 
@@ -300,7 +300,7 @@ Synthesize a single, accurate Mermaid diagram (`stateDiagram-v2`, `sequenceDiagr
300
300
 
301
301
  #### Sub-Module Guidance (when graph justifies recursion)
302
302
 
303
- When a module has clear internal structure visible in `draft/graph/architecture.json` (`.packages` fan-in/out) or live per-package queries:
303
+ When a module has clear internal structure visible in live engine query `get_architecture .packages` (fan-in/out) or live per-package queries:
304
304
  - Create `##### 7.X.Y {Parent}/{Child}` subsections only for children that have their own meaningful public surface or high internal fan-in.
305
305
  - Each sub-module subsection follows the same compact pattern: graph facts + **one mandatory workflow/state diagram** + ≤60 words Design Notes.
306
306
  - Do not descend further unless the child itself shows additional clear boundaries in the graph data.
@@ -362,7 +362,7 @@ Regardless of tier, any directory whose name contains `ops`, `handlers`, `execut
362
362
  | ... | (enumerate ALL — no sampling, no "and others") | | | |
363
363
  ```
364
364
 
365
- Use `draft/graph/modules/{module}.jsonl` to get the complete file list with line counts. Use `draft/graph/hotspots.jsonl` to flag high-complexity operations.
365
+ Use `scripts/tools/graph-callers.sh --symbol <module>` or `scripts/tools/graph-arch.sh --repo .` to get the complete file list. Use `scripts/tools/hotspot-rank.sh --repo .` to flag high-complexity operations.
366
366
 
367
367
  #### Example: Full Sub-Module Treatment for `icebox/` (917 files)
368
368
 
@@ -409,7 +409,7 @@ stateDiagram-v2
409
409
  After writing Section 7, run these checks before proceeding. **If any check fails, STOP and fix.**
410
410
 
411
411
  **Check 1 — Graph block present and faithful for every module:**
412
- Every top-level module from `draft/graph/architecture.json` (`.packages`) has its `<!-- GRAPH:module-deep/...:START --> ... <!-- GRAPH:module-deep/...:END -->` fence rendered verbatim. No LLM prose inside the fence. No modules missing.
412
+ Every top-level module from the live engine (`get_architecture .packages`) has its `<!-- GRAPH:module-deep/...:START --> ... <!-- GRAPH:module-deep/...:END -->` fence rendered verbatim. No LLM prose inside the fence. No modules missing.
413
413
 
414
414
  **Check 2 — One mandatory workflow/state diagram per module:**
415
415
  Every `#### 7.X` (and every `##### 7.X.Y` that the graph justified) contains exactly one high-signal `Primary Workflow / State` Mermaid diagram (`stateDiagram-v2`, `sequenceDiagram`, or clear `flowchart`). The diagram must reflect facts from the module's graph record (entry points, public symbols, call targets). Generic placeholder diagrams fail this check.
@@ -513,12 +513,13 @@ Include architecturally significant implementations (high fan-in, core extension
513
513
  |---|-----------|-------------|-------|-------------|
514
514
  | 1 | ArchiveFilesOp | `icebox/master/ops/archive_files_op.cc` | 2100 | Archives files to cloud vault |
515
515
  | 2 | CancelJobOp | `icebox/master/ops/cancel_job_op.cc` | 450 | Cancels running archive job |
516
- | (enumerate ALL — use graph hotspots.jsonl and per-module JSONL for file list and line counts) |
516
+ | (enumerate ALL — use hotspot-rank.sh and graph-callers.sh / get_architecture for file list and line counts) |
517
517
  ```
518
518
 
519
- > **MANDATORY (graph data)**: Read `draft/graph/modules/{module}.jsonl` to get the complete file
520
- > list with line counts. Filter for files in operation sub-directories (paths containing `/ops/`,
521
- > `/handlers/`, `/executors/`, `/workers/`). Use `draft/graph/hotspots.jsonl` to flag
519
+ > **MANDATORY (graph data)**: Query `scripts/tools/graph-arch.sh --repo .` or
520
+ > `scripts/tools/graph-callers.sh --symbol <module>` to get the complete file list with line counts.
521
+ > Filter for files in operation sub-directories (paths containing `/ops/`,
522
+ > `/handlers/`, `/executors/`, `/workers/`). Use `scripts/tools/hotspot-rank.sh --repo .` to flag
522
523
  > high-complexity operations (high line count or fanIn). Do NOT skip this step — incomplete
523
524
  > catalogs cause AI agents to reinvent existing functionality.
524
525
 
@@ -1209,11 +1210,11 @@ Fix: Add actual payload descriptions on arrows, `alt`/`opt` blocks for condition
1209
1210
 
1210
1211
  **FAILURE 3 — Empty Appendices:**
1211
1212
  Detection: Appendix B, C, or D tables have fewer than 10 data rows.
1212
- Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (Appendix C), and add 2-3 detailed sequence diagrams to Appendix D. Use graph data (`architecture.json` `.packages`/`.routes`) to enumerate exhaustively.
1213
+ Fix: Cross-reference ALL data sources (Appendix B), ALL implementation outputs (Appendix C), and add 2-3 detailed sequence diagrams to Appendix D. Use live engine queries (`get_architecture .packages`/`.routes`) to enumerate exhaustively.
1213
1214
 
1214
1215
  **FAILURE 4 — Missing Sub-Modules:**
1215
1216
  Detection: A module with 100+ source files (check graph data) has no Sub-Module Structure table.
1216
- Fix: Read `draft/graph/modules/{name}.jsonl`, group files by immediate sub-directory, and generate the table with file counts and one-line role descriptions per sub-directory.
1217
+ Fix: Query `scripts/tools/graph-arch.sh --repo .` or `scripts/tools/graph-callers.sh --symbol <name>`, group results by immediate sub-directory, and generate the table with file counts and one-line role descriptions per sub-directory.
1217
1218
 
1218
1219
  **FAILURE 4b — Shallow Sub-Module Treatment:**
1219
1220
  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.
@@ -11,8 +11,8 @@ Scan the codebase to discover recurring coding patterns and update `draft/guardr
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:
13
13
 
14
- 1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `architecture.json` (preferred over `find`).
15
- 2. Prioritize hotspots from `draft/graph/hotspots.jsonl` — patterns in high-fanIn files are more impactful when learned.
14
+ 1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `scripts/tools/graph-arch.sh --repo .` (preferred over `find`).
15
+ 2. Prioritize hotspots via `scripts/tools/hotspot-rank.sh --repo .` — patterns in high-fanIn files are more impactful when learned.
16
16
  3. For TS/Python/Go/C/C++, use `*-index.jsonl` to identify class/function definitions rather than re-discovering them via regex.
17
17
 
18
18
  Filesystem `find` for source discovery (Step 2.1) is permitted **as a complement** to the graph for languages not covered by indexes (e.g. Ruby, Java without ctags). Record the rationale in the Graph Usage Report.
@@ -246,15 +246,15 @@ git log --follow --oneline -1 -- {file_containing_pattern}
246
246
 
247
247
  ### 2.7: Graph-Aware Severity Enrichment
248
248
 
249
- If `draft/graph/hotspots.jsonl` exists, derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found.
249
+ If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `scripts/tools/hotspot-rank.sh --repo .`.
250
250
 
251
251
  For each anti-pattern candidate from Step 2.2:
252
- 1. Check if any evidence files appear in `draft/graph/hotspots.jsonl`
252
+ 1. Check if any evidence files appear in the hotspot output from `scripts/tools/hotspot-rank.sh --repo .`
253
253
  2. Take the highest fanIn value across all evidence files:
254
254
  - fanIn ≥ 10 → `graph_severity: critical` (breakage propagates to many callers)
255
255
  - fanIn 5–9 → `graph_severity: high`
256
256
  - fanIn 1–4 → `graph_severity: medium`
257
- - fanIn 0 or file not in hotspots.jsonl → `graph_severity: low`
257
+ - fanIn 0 or file not in hotspot output → `graph_severity: low`
258
258
  3. If no graph data exists → `graph_severity: unresolved`
259
259
 
260
260
  Collect all evidence files with fanIn ≥ 5 for the `high_fanin_files` field.
@@ -11,7 +11,7 @@ You are performing a lightweight, ad-hoc code review. This is the fast alternati
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Quick-review keeps the graph load light:
13
13
 
14
- 1. Always check `draft/graph/hotspots.jsonl` for every changed file (Step 2 blast-radius pre-check below).
14
+ 1. Always run `scripts/tools/hotspot-rank.sh --repo .` for every changed file (Step 2 blast-radius pre-check below).
15
15
  2. If a finding spans more than one file, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
16
16
 
17
17
  Filesystem `grep` is reserved for source-text scans (literal strings, regex patterns). Symbol and caller discovery go through the graph.
@@ -68,9 +68,9 @@ Determine the diff to review:
68
68
  3. If commit range: `git diff <range>`
69
69
  4. Default: `git diff HEAD~1..HEAD` (last commit)
70
70
 
71
- ## Step 2: Blast Radius Pre-check (if `draft/graph/hotspots.jsonl` exists)
71
+ ## Step 2: Blast Radius Pre-check (if `draft/graph/schema.yaml` exists)
72
72
 
73
- Before the four-dimension review, check if any files in scope appear in `draft/graph/hotspots.jsonl`. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
73
+ Before the four-dimension review, run `scripts/tools/hotspot-rank.sh --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
74
74
 
75
75
  ```
76
76
  ⚠ HIGH IMPACT: {file} is a high-fanIn hotspot (fanIn={N}). Changes here propagate to many callers — review with extra care.
@@ -11,7 +11,7 @@ You are conducting a code review using Draft's Context-Driven Development method
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Stage 1 (Automated Validation) **starts from the graph**:
13
13
 
14
- 1. Run blast-radius assessment from `draft/graph/hotspots.jsonl` and `scripts/tools/graph-impact.sh` (see Stage 1).
14
+ 1. Run blast-radius assessment via `scripts/tools/hotspot-rank.sh --repo .` and `scripts/tools/graph-impact.sh` (see Stage 1).
15
15
  2. For each changed file with non-trivial diff size, run `scripts/tools/graph-impact.sh --repo . --file <path>` to obtain the affected module set deterministically.
16
16
  3. For each public symbol modified, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
17
17
 
@@ -370,18 +370,18 @@ For the files changed in the diff, perform static checks using `grep` or similar
370
370
 
371
371
  - **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
372
372
  - List all changed files from the diff
373
- - For each changed file, check if it appears in `hotspots.jsonl` — if yes, record its `fanIn` value
374
- - Classify: files with fanIn in the top 20% of the hotspots list = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in list = **STANDARD**
375
- - For any file in a HIGH or MEDIUM module, check `architecture.json` `.packages[].fan_in` (how many modules depend on this module)
373
+ - For each changed file, check if it appears in `scripts/tools/hotspot-rank.sh --repo .` output — if yes, record its `fanIn` value
374
+ - Classify: files with fanIn in the top 20% of the hotspot output = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in output = **STANDARD**
375
+ - For any file in a HIGH or MEDIUM module, query `scripts/tools/graph-arch.sh --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
376
376
  - Include a `Blast Radius` line in the Stage 1 report summary: `Blast Radius: HIGH | MEDIUM | STANDARD — <N> changed files affect high-fanIn modules: [file list]`
377
377
  - If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
378
378
  - **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
379
379
  - **Dead Code:** Check for newly exported functions/classes in the diff that have 0 references across the codebase.
380
380
  - **Dependency Cycles:** Trace the import chains for new imports to ensure no circular dependencies (e.g., A → B → C → A) are introduced.
381
- - **Graph Boundary Check** (if `draft/graph/architecture.json` exists) `[RC-013]`:
381
+ - **Graph Boundary Check** (if `draft/graph/schema.yaml` exists) `[RC-013]`:
382
382
  - For each changed file, identify its module from the graph
383
383
  - Check if any new cross-module includes were added in the diff
384
- - Verify they follow the established dependency direction from `architecture.json` package fan-in/out
384
+ - Verify they follow the established dependency direction from `scripts/tools/graph-arch.sh --repo .` package fan-in/out
385
385
  - Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
386
386
  - Check if changes introduce files in modules listed in graph cycles — flag as higher risk
387
387
  - **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
@@ -1075,7 +1075,7 @@ If Jira ticket linked, sync via `core/shared/jira-sync.md`:
1075
1075
 
1076
1076
  Before printing the final verdict, internally verify and report:
1077
1077
 
1078
- 1. **Graph files queried** — which JSONL files were loaded (e.g. `architecture.json, hotspots.jsonl`) plus any live graph query-tool invocations (impact, callers, cycles).
1078
+ 1. **Graph data queried** — which live-engine tools were invoked (e.g. `get_architecture`, `hotspot-rank.sh`, `graph-impact.sh`, `graph-callers.sh`, `cycle-detect.sh`).
1079
1079
  2. **Layer 1 files deliberately skipped** — list any context sections skipped as irrelevant to the diff under review.
1080
1080
  3. **Filesystem grep fallback justification** — for every `grep`/`find` run, state the concept it searched for. Source-text scans (string literals, regex matches in code) are exempt — they are not symbol/file discovery.
1081
1081
 
@@ -11,8 +11,8 @@ You are conducting a technical debt analysis to catalog, prioritize, and plan re
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. Tech-debt prioritization is fundamentally driven by graph data:
13
13
 
14
- 1. Load `draft/graph/hotspots.jsonl` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
15
- 2. Read `draft/graph/architecture.json` (`.packages`) and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
14
+ 1. Run `scripts/tools/hotspot-rank.sh --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
15
+ 2. Query `scripts/tools/graph-arch.sh --repo .` and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
16
16
  3. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
17
17
  4. For each catalogued finding, run `scripts/tools/graph-impact.sh --repo . --file <path>` so the remediation plan includes blast-radius.
18
18