@drafthq/draft 3.2.0 → 3.3.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 (56) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +28 -0
  4. package/README.md +2 -2
  5. package/cli/src/hosts/cursor.js +35 -5
  6. package/cli/src/installer.js +20 -0
  7. package/cli/src/lib/cursor-registry.js +122 -0
  8. package/cli/src/lib/marker.js +93 -0
  9. package/cli/src/lib/plugin-manifest.js +20 -0
  10. package/core/methodology.md +1 -1
  11. package/core/shared/condensation.md +3 -2
  12. package/core/shared/git-report-metadata.md +3 -2
  13. package/core/shared/graph-query.md +4 -3
  14. package/core/shared/tool-resolver.md +71 -4
  15. package/core/templates/okf/ai-context-index.md +48 -0
  16. package/core/templates/okf/concept.md +54 -0
  17. package/core/templates/okf/index.md +40 -0
  18. package/core/templates/okf/section-index.md +25 -0
  19. package/core/templates/plan.md +3 -2
  20. package/integrations/agents/AGENTS.md +792 -102
  21. package/integrations/copilot/.github/copilot-instructions.md +792 -102
  22. package/package.json +3 -2
  23. package/scripts/lib.sh +10 -0
  24. package/scripts/tools/graph-preflight.sh +259 -0
  25. package/scripts/tools/okf-render-views.sh +373 -0
  26. package/scripts/tools/okf-validate.sh +204 -0
  27. package/scripts/tools/resolve-tools.sh +78 -0
  28. package/skills/adr/SKILL.md +3 -2
  29. package/skills/bughunt/SKILL.md +10 -1
  30. package/skills/coverage/SKILL.md +8 -3
  31. package/skills/debug/SKILL.md +16 -5
  32. package/skills/decompose/SKILL.md +29 -12
  33. package/skills/deep-review/SKILL.md +19 -6
  34. package/skills/deploy-checklist/SKILL.md +6 -5
  35. package/skills/graph/SKILL.md +15 -6
  36. package/skills/impact/SKILL.md +12 -1
  37. package/skills/implement/SKILL.md +20 -4
  38. package/skills/init/SKILL.md +36 -10
  39. package/skills/init/references/architecture-spec.md +17 -6
  40. package/skills/init/references/okf-emitter.md +223 -0
  41. package/skills/learn/SKILL.md +15 -4
  42. package/skills/quick-review/SKILL.md +13 -3
  43. package/skills/review/SKILL.md +32 -8
  44. package/skills/standup/SKILL.md +3 -2
  45. package/skills/status/SKILL.md +3 -2
  46. package/skills/tech-debt/SKILL.md +20 -6
  47. package/skills/upload/SKILL.md +3 -2
  48. package/integrations/copilot/.github/copilot-instructions.md.7iDz8X +0 -91
  49. package/integrations/copilot/.github/copilot-instructions.md.DoBdtd +0 -91
  50. package/integrations/copilot/.github/copilot-instructions.md.McGoBW +0 -122
  51. package/integrations/copilot/.github/copilot-instructions.md.VsPyLB +0 -91
  52. package/integrations/copilot/.github/copilot-instructions.md.XAVr7D +0 -91
  53. package/integrations/copilot/.github/copilot-instructions.md.YoFVFa +0 -91
  54. package/integrations/copilot/.github/copilot-instructions.md.a9DeW0 +0 -91
  55. package/integrations/copilot/.github/copilot-instructions.md.oxQs3B +0 -91
  56. package/integrations/copilot/.github/copilot-instructions.md.ww33Ly +0 -91
@@ -0,0 +1,223 @@
1
+ ## Init — OKF Taxonomy Emitter (DRAFT_INIT_MODE=okf)
2
+
3
+ > Progressive-disclosure reference for `/draft:init`. Covers the OKF emitter:
4
+ > type vocabulary, frontmatter contract, generation pipeline, render views,
5
+ > incremental refresh, and the `okf-validate.sh` gate. Authoritative HLD:
6
+ > `hld-draft-init-okf-taxonomy.md` at the repo root.
7
+
8
+ This is the `/draft:init` output mode for **tier 3+ repos**, where it is the
9
+ **tier-gated default** (`DRAFT_INIT_MODE` unset → tier 1–2 `monolith`, tier 3–5
10
+ `okf`; an explicit `DRAFT_INIT_MODE=monolith|okf` overrides). `monolith` is
11
+ retained — the tier-1/2 default, the A/B baseline, and the over-fetch fallback.
12
+ The default rests on maintainability/readability, not the benchmark (parity).
13
+
14
+ ```bash
15
+ # Mode gate — default is tier-gated 'auto', finalized after Step 1.4.5 (tier):
16
+ DRAFT_INIT_MODE="${DRAFT_INIT_MODE:-auto}"
17
+ case "$DRAFT_INIT_MODE" in
18
+ monolith|okf) : ;; # explicit override — honored as-is
19
+ auto) : ;; # resolve from tier: 1–2 → monolith, 3–5 → okf
20
+ *) echo "Unknown DRAFT_INIT_MODE='$DRAFT_INIT_MODE' (monolith|okf|auto); using auto" >&2
21
+ DRAFT_INIT_MODE=auto ;;
22
+ esac
23
+ ```
24
+
25
+ Everything else in `/draft:init` (5-phase analysis, graph snapshot, `.state/`
26
+ hashing, scope detection, atomic staging) is **reused unchanged**. This mode adds
27
+ a decomposition + serialization stage. It introduces **no new LLM analysis
28
+ engine** and exactly **one** new deterministic helper, `okf-validate.sh`.
29
+
30
+ ## Target layout
31
+
32
+ `okf` mode changes **only** the `architecture.md` / `.ai-context.md` packaging
33
+ and adds `wiki/`. **Every other standard `/draft:init` file is still produced**
34
+ — `product.md`, `tech-stack.md`, `workflow.md`, `guardrails.md`, `index.md`,
35
+ `.ai-profile.md`, `tracks/` + `tracks.md`, `.state/`, `graph/` — exactly as in
36
+ `monolith` mode. Do **not** skip them: emitting only the bundle is a regression.
37
+
38
+ ```
39
+ draft/
40
+ ├── .ai-context.md # INDEX ROOT: synopsis (150–250 lines) + Concept Map
41
+ ├── architecture.md # RENDERED VIEW (generated from bundle; not source of truth)
42
+ ├── .ai-profile.md # always-injected profile (derived from .ai-context.md) [SAME AS MONOLITH]
43
+ ├── product.md # [SAME AS MONOLITH]
44
+ ├── tech-stack.md # [SAME AS MONOLITH]
45
+ ├── workflow.md # [SAME AS MONOLITH]
46
+ ├── guardrails.md # [SAME AS MONOLITH]
47
+ ├── index.md # docs index — lists prose files + wiki/ [SAME AS MONOLITH, +wiki link]
48
+ ├── tracks.md + tracks/ # [SAME AS MONOLITH]
49
+ ├── wiki/ # OKF bundle (source of truth) — okf-mode ONLY
50
+ │ ├── index.md # bundle root + Concept Map
51
+ │ ├── overview/{index,architecture,getting-started,glossary}.md
52
+ │ ├── systems/{index,<subsystem>}.md
53
+ │ ├── features/{index,<feature>}.md
54
+ │ ├── reference/{index,<ref>}.md # config, deps, data models, ADRs, runbooks
55
+ │ ├── entrypoints/<app>.md
56
+ │ ├── web/index.html # optional offline viewer (okf-render-views.sh --web)
57
+ │ └── log.md # chronological change history (from .state run memory)
58
+ ├── graph/schema.yaml # [SAME AS MONOLITH] engine gate marker
59
+ └── .state/
60
+ ├── hashes.json # file → content hash [SAME AS MONOLITH]
61
+ ├── path-to-concept.json # NEW: source path → concept page(s) it grounds
62
+ └── signals.json # [SAME AS MONOLITH]
63
+ ```
64
+
65
+ The standard project files come from the same generators as `monolith` mode
66
+ (intake questions → `product.md`; tech detection → `tech-stack.md`; `/draft:learn`
67
+ → `guardrails.md`; templates → `workflow.md`, `index.md`, `tracks.md`,
68
+ `.ai-profile.md`). The OKF emitter only *replaces the architecture packaging*; it
69
+ never owns or removes the rest of the context directory.
70
+
71
+ Templates for each bundle page live in `core/templates/okf/` (`index.md`,
72
+ `concept.md`, `section-index.md`, `ai-context-index.md`).
73
+
74
+ ## Frozen `type` vocabulary
75
+
76
+ Every concept carries a `type` from this frozen set (changing it churns every
77
+ file; versioned via `index.md` frontmatter `okf_types_version`):
78
+
79
+ | type | Maps to | Home |
80
+ |------|---------|------|
81
+ | `Subsystem` | major graph cluster / package boundary | `systems/` |
82
+ | `Module` | single package/dir, cohesive responsibility | `systems/` |
83
+ | `Feature` | user-facing capability spanning modules | `features/` |
84
+ | `Entrypoint` | binary / main / CLI / handler root | `entrypoints/` |
85
+ | `API` | public interface, route group, RPC surface | `reference/` |
86
+ | `DataModel` | schema, table, core struct/type | `reference/` |
87
+ | `Dependency` | notable external dep + how it's used | `reference/` |
88
+ | `ADR` | architecture decision record | `reference/` |
89
+ | `Runbook` | operational procedure | `reference/` |
90
+
91
+ `okf-validate.sh` enforces this set as ground truth — an out-of-vocab `type`
92
+ fails the build.
93
+
94
+ ## Frontmatter contract
95
+
96
+ Per concept page (see `core/templates/okf/concept.md`). Required OKF keys:
97
+ `type`, `title`, `description`, `resource`. **`description` is the load-bearing
98
+ routing key** — write it as a routing decision ("should the agent open this for
99
+ the task at hand?"), never a summary. Draft extensions are namespaced `x-` and
100
+ ignored by generic OKF consumers: `x-grounded-paths`, `x-hotspot-score`,
101
+ `x-callers`.
102
+
103
+ ## Concept granularity (resolves open decision 1)
104
+
105
+ Derive concepts from the graph, not by hand:
106
+
107
+ - A **Subsystem** = a graph cluster (package/dir boundary) with `fan_in ≥ 2` from
108
+ other clusters, OR a top-ranked module from `hotspot-rank.sh`.
109
+ - A **Module** = a cohesive package/dir below a subsystem that is *not* itself a
110
+ cluster boundary but has its own hotspot or public surface.
111
+ - A **Feature** = a capability the graph shows spanning ≥2 modules (shared
112
+ callers / a route group touching multiple packages).
113
+ - Default cap: one page per package boundary; do not split a package into
114
+ multiple concept pages unless it has >1 distinct public surface. This keeps
115
+ page count ≈ module count and navigation depth shallow.
116
+
117
+ ## Generation pipeline (M3)
118
+
119
+ ```
120
+ 1. Survey → existing /draft:init 5-phase + graph snapshot (graph-snapshot.sh)
121
+ 2. Plan → derive the concept list (above) from graph clusters +
122
+ entrypoints + features. Topo-sort by dependency so pages that
123
+ others link to (overview, core subsystems) generate FIRST —
124
+ forward cross-links resolve.
125
+ 3. Generate → per concept, pull grounding from the graph and write the page:
126
+ x-callers ← graph-callers.sh --symbol <c>
127
+ x-grounded-paths ← graph-impact.sh --symbol <c> (blast radius)
128
+ x-hotspot-score ← hotspot-rank.sh
129
+ overview diagrams ← mermaid-from-graph.sh
130
+ Record each source path → page in .state/path-to-concept.json.
131
+ 4. Render views → ai-context.md (synopsis + Concept Map), architecture.md
132
+ (concatenated view), wiki/log.md (see M4).
133
+ 5. Validate → okf-validate.sh draft/wiki \
134
+ --path-index draft/.state/path-to-concept.json
135
+ FAIL the build (do not atomic-rename) on any dangle, missing
136
+ field, bad type, or path-index gap.
137
+ 6. Emit → mv draft.tmp/ draft/ ; update .state/.
138
+ ```
139
+
140
+ Page bodies are LLM-narrated for readability **but** the graph-derived
141
+ frontmatter and the `Blast radius`/`Used by` sections are deterministic. To keep
142
+ incremental carry-forward byte-identical (open decision 2), cache the narrated
143
+ prose keyed by the source hash of `x-grounded-paths` — unchanged sources reuse
144
+ the cached narration verbatim.
145
+
146
+ ## Render views (M4)
147
+
148
+ Both are produced by the deterministic helper `okf-render-views.sh` (no LLM) —
149
+ regenerated on every init/refresh so they never drift from the bundle:
150
+
151
+ ```bash
152
+ okf-render-views.sh draft/wiki \
153
+ --arch-out draft/architecture.md \
154
+ --concept-map-into draft/wiki/index.md \
155
+ --concept-map-into draft/.ai-context.md \
156
+ --web draft/wiki/web/index.html
157
+ ```
158
+
159
+ - `--arch-out` renders the linear `architecture.md` (banner + TOC + every concept
160
+ page in canonical section order, frontmatter stripped, Mermaid preserved).
161
+ - `--concept-map-into` rebuilds the routing table between the
162
+ `<!-- CONCEPT-MAP:START -->` / `:END` markers from each concept's `title` +
163
+ `type` + `description` (section `index.md` pages excluded).
164
+ - `--web` writes a **self-contained offline HTML viewer** (single file: all pages
165
+ inlined as JSON + a built-in markdown renderer + sidebar nav + search). Works by
166
+ double-click — no server, no internet, no CDN. Optional, human-facing; regenerate
167
+ on refresh like the other views. (Mermaid blocks render as labeled source since a
168
+ graphical engine can't be inlined offline.)
169
+
170
+ All views write into `draft/` (the OKF emitter never creates a separate output
171
+ dir): `draft/wiki/` is the bundle, `draft/architecture.md` + `draft/.ai-context.md`
172
+ are the rendered views, `draft/wiki/web/index.html` is the optional viewer.
173
+
174
+ The two views:
175
+
176
+ - **`ai-context.md`** (index root) — from `core/templates/okf/ai-context-index.md`:
177
+ the Synopsis preserves the prior `.ai-context.md` content shape (so existing
178
+ downstream consumers keep working); the Concept Map is built from each
179
+ concept's `description`. Broad tasks terminate here.
180
+ - **`architecture.md`** (rendered view) — TOC + per-concept section concat +
181
+ Mermaid, in topo order. Demoted, not deleted: the brownfield Context Quality
182
+ Audit and any command grepping `architecture.md` keep working (§9 of the HLD).
183
+ - **`wiki/log.md`** — appended from `.state/` run memory.
184
+
185
+ The `<!-- CONCEPT-MAP:START -->` / `:END` markers in `wiki/index.md` and the
186
+ section `index.md` tables are the injection slots for the routing tables.
187
+
188
+ ## Incremental refresh at concept granularity (M5)
189
+
190
+ `/draft:init refresh` under `okf` mode:
191
+
192
+ ```
193
+ 1. Diff hashes.json vs working tree → changed source paths
194
+ 2. path-to-concept.json → affected concept pages
195
+ 3. Regenerate ONLY affected concepts; carry the rest verbatim (cached narration)
196
+ 4. Re-render ai-context.md / architecture.md / log.md (cheap; always regenerated)
197
+ 5. Re-validate: okf-validate.sh on the bundle + path-index (cross-links touching
198
+ changed concepts must still resolve)
199
+ 6. Append log.md; update hashes.json + path-to-concept.json
200
+ ```
201
+
202
+ A 1-file change regenerates only the concept(s) that file grounds. Unchanged
203
+ concepts are byte-identical across runs.
204
+
205
+ ## Backward compatibility (§9)
206
+
207
+ - `architecture.md` is retained as a rendered view (brownfield audit + grep keep
208
+ working).
209
+ - `ai-context.md`'s Synopsis preserves the prior content shape; the Concept Map
210
+ is additive.
211
+ - `/draft:review` and downstream command contracts are unchanged — they consume
212
+ `architecture.md` / `ai-context.md`, both of which still exist.
213
+
214
+ ## Default policy & retirement of `monolith`
215
+
216
+ `okf` is the **tier-gated default** (tier 3+); `monolith` is the tier-1/2 default
217
+ and remains in place as the A/B baseline + over-fetch fallback. Full retirement of
218
+ `monolith` is deferred until **both**: (1) the large-monolith A/B run shows `okf` ≥
219
+ baseline on tokens at parity accuracy (the regime the §12 benchmark flagged), and
220
+ (2) a human-onboarding eval confirms the wiki + generated `architecture.md` covers
221
+ linear onboarding. Note: retiring `monolith` would not remove `architecture.md` —
222
+ it is generated from the bundle regardless — so there is no readability gain from
223
+ deletion, only lost optionality.
@@ -9,10 +9,21 @@ Scan the codebase to discover recurring coding patterns and update `draft/guardr
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before pattern scanning)
11
11
 
12
+ First resolve the bundled helpers:
13
+
14
+ ```bash
15
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
16
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
17
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
18
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
21
+ ```
22
+
12
23
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Use the graph to:
13
24
 
14
- 1. Enumerate a module's symbols/files via `scripts/tools/graph-callers.sh`/`graph-impact.sh` and `scripts/tools/graph-arch.sh --repo .` (preferred over `find`).
15
- 2. Prioritize hotspots via `scripts/tools/hotspot-rank.sh --repo .` — patterns in high-fanIn files are more impactful when learned.
25
+ 1. Enumerate a module's symbols/files via `"$DRAFT_TOOLS/graph-callers.sh"`/`"$DRAFT_TOOLS/graph-impact.sh"` and `"$DRAFT_TOOLS/graph-arch.sh" --repo .` (preferred over `find`).
26
+ 2. Prioritize hotspots via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — patterns in high-fanIn files are more impactful when learned.
16
27
  3. For TS/Python/Go/C/C++, use `*-index.jsonl` to identify class/function definitions rather than re-discovering them via regex.
17
28
 
18
29
  Filesystem `find` for source discovery (Step 2.1) is permitted **as a complement** to the graph for languages not covered by indexes (e.g. Ruby, Java without ctags). Record the rationale in the Graph Usage Report.
@@ -246,10 +257,10 @@ git log --follow --oneline -1 -- {file_containing_pattern}
246
257
 
247
258
  ### 2.7: Graph-Aware Severity Enrichment
248
259
 
249
- If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `scripts/tools/hotspot-rank.sh --repo .`.
260
+ If `draft/graph/schema.yaml` exists (engine live), derive objective severity for all anti-pattern candidates based on the fanIn of files where the pattern was found via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`.
250
261
 
251
262
  For each anti-pattern candidate from Step 2.2:
252
- 1. Check if any evidence files appear in the hotspot output from `scripts/tools/hotspot-rank.sh --repo .`
263
+ 1. Check if any evidence files appear in the hotspot output from `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .`
253
264
  2. Take the highest fanIn value across all evidence files:
254
265
  - fanIn ≥ 10 → `graph_severity: critical` (breakage propagates to many callers)
255
266
  - fanIn 5–9 → `graph_severity: high`
@@ -11,8 +11,18 @@ You are performing a lightweight, ad-hoc code review. This is the fast alternati
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Quick-review keeps the graph load light:
13
13
 
14
- 1. Always run `scripts/tools/hotspot-rank.sh --repo .` for every changed file (Step 2 blast-radius pre-check below).
15
- 2. If a finding spans more than one file, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
14
+ First resolve the bundled helpers:
15
+ ```bash
16
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
17
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
18
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
21
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
22
+ ```
23
+
24
+ 1. Always run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` for every changed file (Step 2 blast-radius pre-check below).
25
+ 2. If a finding spans more than one file, run `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>` to enumerate the call sites before claiming "no other usages".
16
26
 
17
27
  Filesystem `grep` is reserved for source-text scans (literal strings, regex patterns). Symbol and caller discovery go through the graph.
18
28
 
@@ -70,7 +80,7 @@ Determine the diff to review:
70
80
 
71
81
  ## Step 2: Blast Radius Pre-check (if `draft/graph/schema.yaml` exists)
72
82
 
73
- Before the four-dimension review, run `scripts/tools/hotspot-rank.sh --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
83
+ Before the four-dimension review, run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` and check if any files in scope appear in the output. If any file has a `fanIn` in the top 20% of the list, add this warning at the top of the review report:
74
84
 
75
85
  ```
76
86
  ⚠ HIGH IMPACT: {file} is a high-fanIn hotspot (fanIn={N}). Changes here propagate to many callers — review with extra care.
@@ -11,9 +11,19 @@ You are conducting a code review using Draft's Context-Driven Development method
11
11
 
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Stage 1 (Automated Validation) **starts from the graph**:
13
13
 
14
- 1. Run blast-radius assessment via `scripts/tools/hotspot-rank.sh --repo .` and `scripts/tools/graph-impact.sh` (see Stage 1).
15
- 2. For each changed file with non-trivial diff size, run `scripts/tools/graph-impact.sh --repo . --file <path>` to obtain the affected module set deterministically.
16
- 3. For each public symbol modified, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
14
+ First resolve the bundled helpers:
15
+ ```bash
16
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
17
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
18
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
21
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
22
+ ```
23
+
24
+ 1. Run blast-radius assessment via `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` and `"$DRAFT_TOOLS/graph-impact.sh"` (see Stage 1).
25
+ 2. For each changed file with non-trivial diff size, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` to obtain the affected module set deterministically.
26
+ 3. For each public symbol modified, run `"$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
17
27
 
18
28
  Filesystem `grep` is reserved for source-text scans (string literals, log messages, regex matches in code) — not for discovering modules, files, or callers when the graph can answer.
19
29
 
@@ -369,10 +379,21 @@ Load plugin guardrails before scanning: `core/guardrails/review-checks.md` (RC-#
369
379
  For the files changed in the diff, perform static checks using `grep` or similar tools:
370
380
 
371
381
  - **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
382
+
383
+ First resolve the bundled helpers:
384
+ ```bash
385
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
386
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
387
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
388
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
389
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
390
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
391
+ ```
392
+
372
393
  - List all changed files from the diff
373
- - For each changed file, check if it appears in `scripts/tools/hotspot-rank.sh --repo .` output — if yes, record its `fanIn` value
394
+ - For each changed file, check if it appears in `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` output — if yes, record its `fanIn` value
374
395
  - Classify: files with fanIn in the top 20% of the hotspot output = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in output = **STANDARD**
375
- - For any file in a HIGH or MEDIUM module, query `scripts/tools/graph-arch.sh --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
396
+ - For any file in a HIGH or MEDIUM module, query `"$DRAFT_TOOLS/graph-arch.sh" --repo . | jq '.packages[].fan_in'` (how many modules depend on this module)
376
397
  - Include a `Blast Radius` line in the Stage 1 report summary: `Blast Radius: HIGH | MEDIUM | STANDARD — <N> changed files affect high-fanIn modules: [file list]`
377
398
  - If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
378
399
  - **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
@@ -381,7 +402,7 @@ For the files changed in the diff, perform static checks using `grep` or similar
381
402
  - **Graph Boundary Check** (if `draft/graph/schema.yaml` exists) `[RC-013]`:
382
403
  - For each changed file, identify its module from the graph
383
404
  - Check if any new cross-module includes were added in the diff
384
- - Verify they follow the established dependency direction from `scripts/tools/graph-arch.sh --repo .` package fan-in/out
405
+ - Verify they follow the established dependency direction from `"$DRAFT_TOOLS/graph-arch.sh" --repo .` package fan-in/out
385
406
  - Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
386
407
  - Check if changes introduce files in modules listed in graph cycles — flag as higher risk
387
408
  - **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
@@ -1106,8 +1127,11 @@ As the last step after saving the review report, emit a metrics record. Best-eff
1106
1127
 
1107
1128
  **Emit call:**
1108
1129
  ```bash
1109
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
1110
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
1130
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
1131
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
1132
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
1133
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
1134
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
1111
1135
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
1112
1136
  [ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
1113
1137
  '{"skill":"review","track_id":"<id_or_null>","stage_reached":"<stage>","verdict":"<v>","critical_count":<N>,"important_count":<N>,"blast_radius":"<br>","graph_queries":<N>,"fallback_grep_count":<N>}'
@@ -54,8 +54,9 @@ Check for arguments:
54
54
  **Preferred:** invoke `parse-git-log.sh` — it parses conventional commits into structured JSONL `{sha,type,scope,track_id,subject,author,timestamp,files_changed}`, eliminating ambiguity in `type(track-id): subject` parsing. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
55
55
 
56
56
  ```bash
57
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
58
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
57
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
58
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
59
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
59
60
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
60
61
  if [ -x "$DRAFT_TOOLS/parse-git-log.sh" ]; then
61
62
  bash "$DRAFT_TOOLS/parse-git-log.sh" --since "24 hours ago" --author "$(git config user.name)"
@@ -44,8 +44,9 @@ Display a comprehensive overview of project progress.
44
44
  If `parse-reports.sh` and `freshness-check.sh` are available, gather structured signals to enrich the status output (severity counts per track, stale `draft/` docs). Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
45
45
 
46
46
  ```bash
47
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
48
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
47
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
48
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
49
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
49
50
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
50
51
 
51
52
  # Per-track report severity rollup (bughunt, review, tech-debt, etc.):
@@ -9,12 +9,23 @@ You are conducting a technical debt analysis to catalog, prioritize, and plan re
9
9
 
10
10
  ## MANDATORY GRAPH LOOKUP (read before debt scan)
11
11
 
12
+ First resolve the bundled helpers:
13
+
14
+ ```bash
15
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
16
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
17
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
18
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
19
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
20
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
21
+ ```
22
+
12
23
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Tech-debt prioritization is fundamentally driven by graph data:
13
24
 
14
- 1. Run `scripts/tools/hotspot-rank.sh --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
15
- 2. Query `scripts/tools/graph-arch.sh --repo .` and run `scripts/tools/cycle-detect.sh --repo .` — flag debt in modules involved in cycles as higher priority.
16
- 3. Run `scripts/tools/cycle-detect.sh --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
17
- 4. For each catalogued finding, run `scripts/tools/graph-impact.sh --repo . --file <path>` so the remediation plan includes blast-radius.
25
+ 1. Run `"$DRAFT_TOOLS/hotspot-rank.sh" --repo .` — **rank candidates by `fanIn × complexity`** to surface high-leverage debt first.
26
+ 2. Query `"$DRAFT_TOOLS/graph-arch.sh" --repo .` and run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` — flag debt in modules involved in cycles as higher priority.
27
+ 3. Run `"$DRAFT_TOOLS/cycle-detect.sh" --repo .` to enumerate dependency cycles — every cycle is a candidate architecture-debt entry.
28
+ 4. For each catalogued finding, run `"$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>` so the remediation plan includes blast-radius.
18
29
 
19
30
  Filesystem `grep` (e.g. `scan-markers.sh`) is still primary for TODO/FIXME marker discovery — markers are source-text, not graph-derived. The graph governs **prioritization**, the marker scan governs **discovery**.
20
31
 
@@ -82,8 +93,11 @@ Scan the codebase systematically across all seven categories. For each finding,
82
93
  For TODO/FIXME/HACK/XXX/DEPRECATED markers, prefer the deterministic `scan-markers.sh` wrapper — it emits JSON `[{path,line,marker,text,sha,author,introduced,age_days}]` with blame ages already computed. Resolve via the canonical tool resolver (see [core/shared/tool-resolver.md](../../core/shared/tool-resolver.md)):
83
94
 
84
95
  ```bash
85
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
86
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
96
+ # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
97
+ # is not exported into skill Bash). See core/shared/tool-resolver.md.
98
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
99
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
100
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
87
101
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
88
102
  [ -x "$DRAFT_TOOLS/scan-markers.sh" ] && bash "$DRAFT_TOOLS/scan-markers.sh" --root .
89
103
  # Fallback when script unavailable: grep -rn 'TODO\|FIXME\|HACK\|XXX\|DEPRECATED' .
@@ -52,8 +52,9 @@ Run the WS-9 chain from [verification-gates.md](../../core/shared/verification-g
52
52
 
53
53
  ```bash
54
54
  TRACK_DIR="draft/tracks/<id>"
55
- DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
56
- [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
55
+ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
56
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
57
+ [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
57
58
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
58
59
 
59
60
  "$DRAFT_TOOLS/check-track-hygiene.sh" "$TRACK_DIR"
@@ -1,91 +0,0 @@
1
- # Draft - Context-Driven Development
2
-
3
- You are operating with the Draft methodology for Context-Driven Development.
4
-
5
- **Measure twice, code once.**
6
-
7
- ## Core Workflow
8
-
9
- **Context -> Spec & Plan -> Implement**
10
-
11
- Every feature follows this lifecycle:
12
- 1. **Setup** - Initialize project context (once per project)
13
- 2. **New Track** - Create specification and plan
14
- 3. **Implement** - Execute tasks with TDD workflow
15
- 4. **Verify** - Confirm acceptance criteria met
16
-
17
- ## Project Context Files
18
-
19
- When `draft/` exists in the project, always consider:
20
- - `draft/.ai-context.md` - Source of truth for AI agents (dense codebase understanding)
21
- - `draft/architecture.md` - Human-readable engineering guide (derived from .ai-context.md)
22
- - `draft/product.md` - Product vision and goals
23
- - `draft/tech-stack.md` - Technical constraints
24
- - `draft/workflow.md` - TDD and commit preferences
25
- - `draft/tracks.md` - Active work items
26
-
27
- ## Available Commands
28
-
29
- | Command | Purpose |
30
- |---------|---------|
31
- | `draft` | Show overview and available commands |
32
- | `draft init` | Initialize project (run once) |
33
- | `draft index [--init-missing]` | Aggregate monorepo service contexts |
34
- | `draft new-track <description>` | Create feature/bug track |
35
- | `draft decompose` | Module decomposition with dependency mapping |
36
- | `draft implement` | Execute tasks from plan |
37
- | `draft coverage` | Code coverage report (target 95%+) |
38
- | `draft bughunt [--track <id>]` | Systematic bug discovery |
39
- | `draft review [--track <id>]` | Three-stage code review |
40
- | `draft deep-review [module]` | Exhaustive production-grade module audit |
41
- | `draft learn [promote\|migrate]` | Discover coding patterns, update guardrails |
42
- | `draft adr [title]` | Architecture Decision Records |
43
- | `draft status` | Show progress overview |
44
- | `draft revert` | Git-aware rollback |
45
- | `draft change <description>` | Handle mid-track requirement changes |
46
- | `draft jira-preview [track-id]` | Generate jira-export.md for review |
47
- | `draft jira-create [track-id]` | Create Jira issues from export via MCP |
48
-
49
- ## Intent Mapping
50
-
51
- Recognize these natural language patterns:
52
-
53
- | User Says | Action |
54
- |-----------|--------|
55
- | "set up the project" | Run init |
56
- | "index services", "aggregate context" | Run index |
57
- | "new feature", "add X" | Create new track |
58
- | "break into modules", "decompose" | Run decompose |
59
- | "start implementing" | Execute implement |
60
- | "check coverage", "test coverage" | Run coverage |
61
- | "hunt bugs", "find bugs" | Run bug hunt |
62
- | "review code", "review track", "check quality" | Run review |
63
- | "deep review", "production audit", "module audit" | Run deep-review |
64
- | "learn patterns", "update guardrails", "discover conventions" | Run learn |
65
- | "what's the status" | Show status |
66
- | "undo", "revert" | Run revert |
67
- | "requirements changed", "scope changed", "update the spec" | Run change |
68
- | "preview jira", "export to jira" | Run jira-preview |
69
- | "create jira", "push to jira" | Run jira-create |
70
- | "document decision", "create ADR" | Create architecture decision record |
71
- | "help", "what commands" | Show draft overview |
72
- | "the plan" | Read active track's plan.md |
73
- | "the spec" | Read active track's spec.md |
74
-
75
- ## Tracks
76
-
77
- A **track** is a high-level unit of work (feature, bug fix, refactor). Each track contains:
78
- - `spec.md` - Requirements and acceptance criteria
79
- - `plan.md` - Phased task breakdown
80
- - `metadata.json` - Status and timestamps
81
-
82
- Located at: `draft/tracks/<track-id>/`
83
-
84
- ## Status Markers
85
-
86
- Recognize and use these throughout plan.md:
87
- - `[ ]` - Pending
88
- - `[~]` - In Progress
89
- - `[x]` - Completed
90
- - `[!]` - Blocked
91
-
@@ -1,91 +0,0 @@
1
- # Draft - Context-Driven Development
2
-
3
- You are operating with the Draft methodology for Context-Driven Development.
4
-
5
- **Measure twice, code once.**
6
-
7
- ## Core Workflow
8
-
9
- **Context -> Spec & Plan -> Implement**
10
-
11
- Every feature follows this lifecycle:
12
- 1. **Setup** - Initialize project context (once per project)
13
- 2. **New Track** - Create specification and plan
14
- 3. **Implement** - Execute tasks with TDD workflow
15
- 4. **Verify** - Confirm acceptance criteria met
16
-
17
- ## Project Context Files
18
-
19
- When `draft/` exists in the project, always consider:
20
- - `draft/.ai-context.md` - Source of truth for AI agents (dense codebase understanding)
21
- - `draft/architecture.md` - Human-readable engineering guide (derived from .ai-context.md)
22
- - `draft/product.md` - Product vision and goals
23
- - `draft/tech-stack.md` - Technical constraints
24
- - `draft/workflow.md` - TDD and commit preferences
25
- - `draft/tracks.md` - Active work items
26
-
27
- ## Available Commands
28
-
29
- | Command | Purpose |
30
- |---------|---------|
31
- | `draft` | Show overview and available commands |
32
- | `draft init` | Initialize project (run once) |
33
- | `draft index [--init-missing]` | Aggregate monorepo service contexts |
34
- | `draft new-track <description>` | Create feature/bug track |
35
- | `draft decompose` | Module decomposition with dependency mapping |
36
- | `draft implement` | Execute tasks from plan |
37
- | `draft coverage` | Code coverage report (target 95%+) |
38
- | `draft bughunt [--track <id>]` | Systematic bug discovery |
39
- | `draft review [--track <id>]` | Three-stage code review |
40
- | `draft deep-review [module]` | Exhaustive production-grade module audit |
41
- | `draft learn [promote\|migrate]` | Discover coding patterns, update guardrails |
42
- | `draft adr [title]` | Architecture Decision Records |
43
- | `draft status` | Show progress overview |
44
- | `draft revert` | Git-aware rollback |
45
- | `draft change <description>` | Handle mid-track requirement changes |
46
- | `draft jira-preview [track-id]` | Generate jira-export.md for review |
47
- | `draft jira-create [track-id]` | Create Jira issues from export via MCP |
48
-
49
- ## Intent Mapping
50
-
51
- Recognize these natural language patterns:
52
-
53
- | User Says | Action |
54
- |-----------|--------|
55
- | "set up the project" | Run init |
56
- | "index services", "aggregate context" | Run index |
57
- | "new feature", "add X" | Create new track |
58
- | "break into modules", "decompose" | Run decompose |
59
- | "start implementing" | Execute implement |
60
- | "check coverage", "test coverage" | Run coverage |
61
- | "hunt bugs", "find bugs" | Run bug hunt |
62
- | "review code", "review track", "check quality" | Run review |
63
- | "deep review", "production audit", "module audit" | Run deep-review |
64
- | "learn patterns", "update guardrails", "discover conventions" | Run learn |
65
- | "what's the status" | Show status |
66
- | "undo", "revert" | Run revert |
67
- | "requirements changed", "scope changed", "update the spec" | Run change |
68
- | "preview jira", "export to jira" | Run jira-preview |
69
- | "create jira", "push to jira" | Run jira-create |
70
- | "document decision", "create ADR" | Create architecture decision record |
71
- | "help", "what commands" | Show draft overview |
72
- | "the plan" | Read active track's plan.md |
73
- | "the spec" | Read active track's spec.md |
74
-
75
- ## Tracks
76
-
77
- A **track** is a high-level unit of work (feature, bug fix, refactor). Each track contains:
78
- - `spec.md` - Requirements and acceptance criteria
79
- - `plan.md` - Phased task breakdown
80
- - `metadata.json` - Status and timestamps
81
-
82
- Located at: `draft/tracks/<track-id>/`
83
-
84
- ## Status Markers
85
-
86
- Recognize and use these throughout plan.md:
87
- - `[ ]` - Pending
88
- - `[~]` - In Progress
89
- - `[x]` - Completed
90
- - `[!]` - Blocked
91
-