@drafthq/draft 2.8.3 → 3.1.5

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 (68) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +5 -5
  4. package/bin/README.md +10 -0
  5. package/core/methodology.md +17 -18
  6. package/core/shared/condensation.md +9 -9
  7. package/core/shared/draft-context-loading.md +7 -9
  8. package/core/shared/graph-query.md +38 -31
  9. package/core/shared/graph-usage-report.md +1 -1
  10. package/core/shared/pattern-learning.md +2 -2
  11. package/core/shared/red-flags.md +3 -3
  12. package/core/templates/ai-context.md +2 -1
  13. package/core/templates/ai-profile.md +1 -0
  14. package/core/templates/architecture.md +4 -3
  15. package/core/templates/dependency-graph.md +2 -2
  16. package/core/templates/discovery.md +1 -0
  17. package/core/templates/guardrails.md +1 -0
  18. package/core/templates/hld.md +1 -0
  19. package/core/templates/lld.md +1 -0
  20. package/core/templates/plan.md +1 -0
  21. package/core/templates/product.md +1 -0
  22. package/core/templates/rca.md +1 -0
  23. package/core/templates/root-architecture.md +3 -3
  24. package/core/templates/root-product.md +2 -2
  25. package/core/templates/root-tech-stack.md +2 -2
  26. package/core/templates/service-index.md +3 -3
  27. package/core/templates/spec.md +1 -0
  28. package/core/templates/tech-matrix.md +2 -2
  29. package/core/templates/tech-stack.md +1 -0
  30. package/core/templates/workflow.md +1 -0
  31. package/integrations/agents/AGENTS.md +276 -1037
  32. package/integrations/copilot/.github/copilot-instructions.md +276 -1037
  33. package/package.json +1 -1
  34. package/scripts/lib.sh +2 -1
  35. package/scripts/tools/adr-index.sh +2 -2
  36. package/scripts/tools/check-scope-conflicts.sh +2 -2
  37. package/scripts/tools/check-skill-line-caps.sh +2 -2
  38. package/scripts/tools/cycle-detect.sh +5 -1
  39. package/scripts/tools/diff-templates-vs-tracks.sh +2 -2
  40. package/scripts/tools/fix-whitespace.sh +15 -9
  41. package/scripts/tools/graph-arch.sh +72 -0
  42. package/scripts/tools/graph-impact.sh +1 -0
  43. package/scripts/tools/graph-init.sh +187 -0
  44. package/scripts/tools/graph-snapshot.sh +52 -46
  45. package/scripts/tools/hotspot-rank.sh +2 -0
  46. package/scripts/tools/manage-symlinks.sh +1 -1
  47. package/scripts/tools/parse-reports.sh +1 -1
  48. package/scripts/tools/skill-caps.conf +0 -1
  49. package/scripts/tools/verify-doc-anchors.sh +2 -2
  50. package/scripts/tools/verify-graph-binary.sh +1 -1
  51. package/skills/GRAPH.md +9 -12
  52. package/skills/bughunt/SKILL.md +14 -1
  53. package/skills/debug/SKILL.md +3 -3
  54. package/skills/decompose/SKILL.md +5 -5
  55. package/skills/deep-review/SKILL.md +2 -2
  56. package/skills/deploy-checklist/SKILL.md +2 -2
  57. package/skills/discover/SKILL.md +2 -4
  58. package/skills/draft/SKILL.md +2 -2
  59. package/skills/draft/intent-mapping.md +3 -2
  60. package/skills/graph/SKILL.md +3 -3
  61. package/skills/implement/SKILL.md +1 -1
  62. package/skills/init/SKILL.md +102 -43
  63. package/skills/init/references/architecture-spec.md +17 -16
  64. package/skills/learn/SKILL.md +5 -5
  65. package/skills/quick-review/SKILL.md +3 -3
  66. package/skills/review/SKILL.md +7 -7
  67. package/skills/tech-debt/SKILL.md +2 -2
  68. package/skills/index/SKILL.md +0 -848
package/skills/GRAPH.md CHANGED
@@ -55,7 +55,6 @@ graph TD
55
55
  subgraph "Architecture"
56
56
  decompose["/draft:decompose"]
57
57
  adr["/draft:adr"]
58
- index["/draft:index"]
59
58
  tech-debt["/draft:tech-debt"]
60
59
  impact["/draft:impact"]
61
60
  end
@@ -96,7 +95,6 @@ graph TD
96
95
  init --> learn
97
96
  init --> adr
98
97
  init --> bughunt
99
- init --> index
100
98
  init --> status
101
99
  init --> deep-review
102
100
  init --> debug
@@ -124,7 +122,6 @@ graph TD
124
122
  discover --> coverage
125
123
  discover --> testing-strategy
126
124
  discover --> learn
127
- discover --> index
128
125
  discover --> tour
129
126
  discover --> impact
130
127
  discover --> assist-review
@@ -178,8 +175,7 @@ graph TD
178
175
  impact -.->|reads graph| new-track
179
176
  impact -.->|reads graph| implement
180
177
 
181
- %% Monorepo chain
182
- init -.->|per-service| index
178
+ %% Monorepo: init is scope-aware — root build + module→root graph link (no separate index command)
183
179
  ```
184
180
 
185
181
  ## Dependency Matrix
@@ -193,7 +189,7 @@ graph TD
193
189
  | `implement` | init, new-track | review (triggers at phase boundaries) | Modifies source code; regenerates .ai-context.md |
194
190
  | `review` | init, new-track | implement (called at phase boundaries) | review-report-latest.md |
195
191
  | `quick-review` | init | review (fast alternative) | quick-review-report.md |
196
- | `bughunt` | init | review (optional), index (optional), jira (optional) | bughunt-report-latest.md |
192
+ | `bughunt` | init | review (optional), jira (optional) | bughunt-report-latest.md |
197
193
  | `deep-review` | init | -- | deep-review audit report |
198
194
  | `coverage` | init, new-track | -- | Regenerates .ai-context.md |
199
195
  | `testing-strategy` | init | coverage (informs), bughunt (informs) | testing-strategy.md |
@@ -248,7 +244,8 @@ deep-review ──→ tech-debt ──→ new-track (prioritized items)
248
244
 
249
245
  ### Monorepo Flow
250
246
  ```
251
- init (per-service) index (at root) aggregated context
247
+ init (root) whole-repo code-graph spine + sparse root map
248
+ init (sub-module) → module snapshot + root-link.json → cross-module context via the root spine
252
249
  ```
253
250
 
254
251
  ### Quality Audit Flow
@@ -280,15 +277,15 @@ init → learn → (updates guardrails.md)
280
277
 
281
278
  | Subroutine | Defined In | Called By |
282
279
  |------------|-----------|----------|
283
- | Condensation Subroutine (.ai-context.md regeneration) | `core/shared/condensation.md` | implement, decompose, coverage, index |
280
+ | Condensation Subroutine (.ai-context.md regeneration) | `core/shared/condensation.md` | implement, decompose, coverage |
284
281
  | Standard File Metadata (YAML frontmatter) | `init` | All skills that generate draft/ files |
285
282
  | Three-Stage Review | `review` | implement (at phase boundaries) |
286
- | Signal Classification | `init` | init refresh, index (future) |
283
+ | Signal Classification | `init` | init refresh |
287
284
  | Pattern Learning | `core/shared/pattern-learning.md` | learn, bughunt, review, deep-review (updates guardrails.md) |
288
285
  | Context Loading | `core/shared/draft-context-loading.md` | All skills requiring draft/ context |
289
286
  | Cross-Skill Dispatch | `core/shared/cross-skill-dispatch.md` | bughunt, deep-review, implement, review |
290
287
  | Jira Sync | `core/shared/jira-sync.md` | bughunt, review, implement (when ticket linked) |
291
- | Graph Query | `core/shared/graph-query.md` | init, implement, bughunt, review, debug, decompose, index, impact |
288
+ | Graph Query | `core/shared/graph-query.md` | init, implement, bughunt, review, debug, decompose, impact |
292
289
  | Graph Mermaid | `scripts/tools/mermaid-from-graph.sh` | init (injects module-deps + proto-map into architecture.md) |
293
290
 
294
291
  ## Artifact Flow
@@ -304,8 +301,8 @@ init → learn → (updates guardrails.md)
304
301
  init ──────────► │ architecture.md ──► .ai-context.md │
305
302
  │ product.md tech-stack.md guardrails.md │
306
303
  │ workflow.md tracks.md tech-debt.md │
307
- │ graph/ (module-graph, hotspots, proto,
308
- module-deps.mermaid, proto-map..)
304
+ │ graph/ (schema.yaml gate; all data queried
305
+ live via codebase-memory-mcp engine)
309
306
  └──────────────────┬──────────────────────────┘
310
307
  │ read by all skills
311
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
@@ -94,6 +94,19 @@ Use track context to:
94
94
 
95
95
  If no Draft context exists, proceed with code-only analysis.
96
96
 
97
+ ## Multi-Directory Mode (monorepo)
98
+
99
+ `/draft:bughunt` can sweep multiple sub-projects in one run — useful at a monorepo root. Trigger it with an explicit directory list (`bughunt <dir1> <dir2> ...`) or no list (auto-discover).
100
+
101
+ 1. **Resolve targets:**
102
+ - **Explicit list** → use the given directories; verify each exists; skip (with a warning) any that lack a `draft/` directory.
103
+ - **Auto-discover** → immediate child directories containing a `draft/` folder, excluding `node_modules/`, `vendor/`, `.git/`, `draft/`, and dotfiles.
104
+ 2. **Run sequentially** (not in parallel — avoids context conflicts): for each target, run the full single-target bug hunt below scoped to that directory. Each writes its own `<dir>/draft/bughunt-report-latest.md`.
105
+ 3. **Aggregate** into `draft/bughunt-summary.md` at the invocation root: a table of `dir | Critical | High | Medium | Low | Total | report link`, a grand total, and a "directories with Critical issues" callout.
106
+ 4. Report skipped directories (no `draft/`) and suggest running `/draft:init` in them first.
107
+
108
+ For a single target (the common case), skip this section and proceed.
109
+
97
110
  ## Dimension Applicability Check
98
111
 
99
112
  Before analyzing all 14 dimensions, determine which apply to this codebase:
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: discover
3
- description: "Primary router for discovery, debugging, investigation, quality, and exploration workflows. Analyzes user intent and dispatches to debug, bughunt, quick-review, deep-review, coverage, testing-strategy, learn, index, tour, impact, assist-review. The recommended entry point for any 'find out', 'check', 'review', or 'investigate' request."
3
+ description: "Primary router for discovery, debugging, investigation, quality, and exploration workflows. Analyzes user intent and dispatches to debug, bughunt, quick-review, deep-review, coverage, testing-strategy, learn, tour, impact, assist-review. The recommended entry point for any 'find out', 'check', 'review', or 'investigate' request."
4
4
  ---
5
5
 
6
6
  # Discover - Investigation & Quality Router
@@ -13,7 +13,6 @@ description: "Primary router for discovery, debugging, investigation, quality, a
13
13
  - Code quality reviews (lightweight to exhaustive to architectural)
14
14
  - Coverage analysis and test strategy design
15
15
  - Discovering and codifying project conventions
16
- - Monorepo indexing and context aggregation
17
16
  - Project tours, impact analysis, or reviewer assistance
18
17
 
19
18
  ## Routing Logic
@@ -29,7 +28,6 @@ Strong keyword and phrase matching with fallback to a menu when intent is broad
29
28
  | coverage, code coverage, test coverage report | `/draft:coverage` | Coverage measurement and gap report |
30
29
  | test strategy, testing plan, coverage targets, pyramid | `/draft:testing-strategy` | Test approach design |
31
30
  | learn patterns, discover conventions, update guardrails, anti-patterns | `/draft:learn` | Pattern mining + guardrail evolution |
32
- | index services, aggregate context, monorepo index | `/draft:index` | Monorepo service context aggregation |
33
31
  | tour, walkthrough, onboard me, getting started tour | `/draft:tour` | Guided interactive project tour |
34
32
  | blast radius, code impact, affected modules, downstream callers | `/draft:review` or `scripts/tools/graph-impact.sh` | Graph-derived blast-radius before merge |
35
33
  | impact, delivery telemetry, track analytics, CDD effectiveness | `/draft:impact` | Project-wide track delivery telemetry |
@@ -55,7 +53,7 @@ User: "learn the coding patterns in this repo and tighten guardrails"
55
53
 
56
54
  User: "index the monorepo so agents see all services"
57
55
 
58
- dispatches to `/draft:index --init-missing`
56
+ Monorepo context is a foundation task, not a discover route: run `/draft:init` at the repo root (it builds the whole-repo code graph + a sparse root map linking each module). Running `/draft:init` inside a sub-module links that module up to the same root graph.
59
57
 
60
58
  ## Auto-Chains & Recommendations
61
59
 
@@ -39,7 +39,7 @@ The 5 router commands provide intent-based dispatch into the 20+ specialist comm
39
39
  | `/draft:plan` | Planning & architecture | new-track, decompose, adr, tech-debt, change |
40
40
  | `/draft:ops` | Operations & lifecycle | deploy-checklist, incident-response, standup, status, revert |
41
41
  | `/draft:docs` | Authoring | documentation |
42
- | `/draft:discover` | Investigation & quality | debug, bughunt, quick/deep-review, coverage, testing-strategy, learn, index, tour, impact, assist-review |
42
+ | `/draft:discover` | Investigation & quality | debug, bughunt, quick/deep-review, coverage, testing-strategy, learn, tour, impact, assist-review |
43
43
  | `/draft:jira` | Jira integration (preview, create, review) | - |
44
44
 
45
45
  ### Specialist Commands (leaf skills, invoked via routers or directly)
@@ -74,7 +74,7 @@ These commands remain available for targeted, specialist execution outside paren
74
74
 
75
75
  #### 4. Setup & Documentation
76
76
  * `/draft` - Display this command overview and help reference
77
- * `/draft:index` - Aggregate multi-service context in monorepo structures
77
+ * `/draft:init` - Single scope-aware entry point: builds the root-first code graph (`draft/graph/`) and project context; run at the repo root or inside any sub-module (monorepo context comes from running it at root)
78
78
  * `/draft:discover` - Phase 0 code-spike report (hotspots, mode flags, open questions) before spec freeze
79
79
  * `/draft:documentation` - Generate structured codebase documentation (API, Onboarding, Runbooks)
80
80
  * `/draft:tech-debt` - Audit technical debt across 6 key dimensions
@@ -33,5 +33,6 @@ Draft commands can be invoked using natural language. If you describe your goal
33
33
  | "write docs", "create readme", "api documentation" | `/draft:documentation` | Generate professional, structured docs |
34
34
  | "preview jira", "export jira issues", "jira draft" | `/draft:jira-preview` | Generate Jira markdown export from plan |
35
35
  | "create jira", "push to jira board" | `/draft:jira-create` | Create actual Jira issues via MCP integrations |
36
- | "index services", "aggregate context", "monorepo setup" | `/draft:index` | Aggregate multi-service context at the root |
37
- | "build graph", "refresh graph", "rebuild the knowledge graph", "index this repo's structure" | `/draft:graph` | Initialize/refresh the `draft/graph/` snapshot (optionally `draft graph <path>`) |
36
+ | "index services", "aggregate context", "monorepo setup" | `/draft:init` | Single entry point — run at the repo root to build the whole-repo code graph + sparse root map; run in a sub-module to link up to it |
37
+ | "build the code graph", "index this repo's structure", "graph memory only" | `/draft:init --graph-only` | Scope-aware, root-first code-graph build with no markdown |
38
+ | "build graph", "refresh graph", "rebuild the knowledge graph" | `/draft:graph` | Narrow refresh of the `draft/graph/` snapshot for one repo (optionally `draft graph <path>`) |
@@ -5,7 +5,7 @@ description: Initialize or refresh the knowledge-graph snapshot for a repository
5
5
 
6
6
  # Draft Graph
7
7
 
8
- Initialize or refresh the `draft/graph/` knowledge-graph snapshot for a repository. This is the narrow "give me a fresh structural graph" command — it does **not** generate `architecture.md`/`.ai-context.md` (that is `/draft:init`) and does **not** re-inject doc diagram slots (that is `/draft:index`).
8
+ Initialize or refresh the `draft/graph/` knowledge-graph snapshot for a single repository. This is the narrow "give me a fresh structural graph" command — it does **not** generate `architecture.md`/`.ai-context.md` and does **not** re-inject doc diagram slots (both are `/draft:init`). For scope-aware, root-first graph memory across a monorepo (root spine + module→root links), use `/draft:init --graph-only`.
9
9
 
10
10
  ## Red Flags - STOP if you're:
11
11
 
@@ -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`.
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 engine — no snapshot files are committed beyond `schema.yaml`.
59
59
 
60
60
  ```bash
61
61
  scripts/tools/graph-snapshot.sh --repo "$REPO_ABS"
@@ -92,7 +92,7 @@ Present a concise summary:
92
92
 
93
93
  Then point the user at the natural next steps:
94
94
 
95
- - To re-inject the refreshed diagrams/hotspot tables into `architecture.md` / `.ai-context.md`: run `/draft:index`.
95
+ - To re-inject the refreshed diagrams/hotspot tables into `architecture.md` / `.ai-context.md`: run `/draft:init refresh` (or `/draft:init --graph-only` to rebuild just the graph memory).
96
96
  - For a first-time full context bootstrap (architecture + profiles): run `/draft:init`.
97
97
 
98
98
  ## Graceful Degradation
@@ -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)