@drafthq/draft 3.5.2 → 3.6.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 (86) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/cli/src/hosts/cursor.js +3 -0
  5. package/cli/src/installer.js +7 -3
  6. package/cli/src/lib/fsx.js +3 -0
  7. package/cli/src/lib/marker.js +8 -3
  8. package/core/shared/condensation.md +1 -1
  9. package/core/shared/git-report-metadata.md +1 -1
  10. package/core/shared/graph-query.md +24 -24
  11. package/core/shared/tool-resolver.md +20 -15
  12. package/core/templates/okf/index.md +6 -10
  13. package/core/templates/okf/section-index.md +2 -11
  14. package/core/templates/plan.md +1 -1
  15. package/integrations/agents/AGENTS.md +142 -492
  16. package/integrations/copilot/.github/copilot-instructions.md +142 -492
  17. package/package.json +1 -1
  18. package/scripts/fetch-memory-engine.sh +1 -1
  19. package/scripts/lib.sh +79 -2
  20. package/scripts/tools/_graph_queries.sh +12 -5
  21. package/scripts/tools/_lib.sh +56 -8
  22. package/scripts/tools/adr-index.sh +1 -1
  23. package/scripts/tools/check-skill-line-caps.sh +2 -2
  24. package/scripts/tools/check-track-hygiene.sh +41 -21
  25. package/scripts/tools/classify-files.sh +1 -1
  26. package/scripts/tools/cycle-detect.sh +2 -9
  27. package/scripts/tools/detect-test-framework.sh +1 -1
  28. package/scripts/tools/emit-skill-metrics.sh +7 -2
  29. package/scripts/tools/freshness-check.sh +2 -2
  30. package/scripts/tools/git-metadata.sh +6 -6
  31. package/scripts/tools/graph-arch.sh +4 -10
  32. package/scripts/tools/graph-callers.sh +4 -12
  33. package/scripts/tools/graph-deps.sh +3 -10
  34. package/scripts/tools/graph-errors.sh +4 -11
  35. package/scripts/tools/graph-hierarchy.sh +4 -11
  36. package/scripts/tools/graph-impact.sh +17 -17
  37. package/scripts/tools/graph-init.sh +1 -1
  38. package/scripts/tools/graph-preflight.sh +1 -1
  39. package/scripts/tools/graph-query.sh +5 -12
  40. package/scripts/tools/graph-risk.sh +3 -10
  41. package/scripts/tools/graph-search.sh +4 -11
  42. package/scripts/tools/graph-snapshot.sh +9 -4
  43. package/scripts/tools/graph-snippet.sh +3 -10
  44. package/scripts/tools/graph-tests.sh +3 -10
  45. package/scripts/tools/graph-traces.sh +3 -10
  46. package/scripts/tools/hotspot-rank.sh +4 -11
  47. package/scripts/tools/mermaid-from-graph.sh +3 -10
  48. package/scripts/tools/migrate-track-frontmatter.sh +3 -1
  49. package/scripts/tools/okf-coverage-check.sh +24 -6
  50. package/scripts/tools/okf-emit-catalog.sh +256 -0
  51. package/scripts/tools/okf-fix-links.sh +326 -0
  52. package/scripts/tools/okf-plan-concepts.sh +245 -14
  53. package/scripts/tools/okf-render-views.sh +65 -13
  54. package/scripts/tools/okf-validate-all.sh +20 -9
  55. package/scripts/tools/okf-validate-quality.sh +2 -8
  56. package/scripts/tools/okf-validate.sh +20 -10
  57. package/scripts/tools/parse-git-log.sh +4 -4
  58. package/scripts/tools/parse-reports.sh +1 -1
  59. package/scripts/tools/render-track.sh +1 -1
  60. package/scripts/tools/run-coverage.sh +1 -1
  61. package/scripts/tools/scan-markers.sh +4 -4
  62. package/scripts/tools/validate-frontmatter.sh +2 -2
  63. package/scripts/tools/verify-citations.sh +2 -2
  64. package/scripts/tools/verify-doc-anchors.sh +1 -1
  65. package/scripts/tools/verify-graph-binary.sh +2 -2
  66. package/skills/adr/SKILL.md +1 -1
  67. package/skills/bughunt/SKILL.md +1 -1
  68. package/skills/coverage/SKILL.md +2 -2
  69. package/skills/debug/SKILL.md +1 -1
  70. package/skills/decompose/SKILL.md +3 -3
  71. package/skills/deep-review/SKILL.md +2 -2
  72. package/skills/deploy-checklist/SKILL.md +1 -1
  73. package/skills/graph/SKILL.md +1 -1
  74. package/skills/impact/SKILL.md +1 -1
  75. package/skills/implement/SKILL.md +2 -2
  76. package/skills/init/SKILL.md +10 -7
  77. package/skills/init/references/architecture-spec.md +1 -1
  78. package/skills/init/references/okf-emitter.md +51 -76
  79. package/skills/learn/SKILL.md +1 -1
  80. package/skills/quick-review/SKILL.md +1 -1
  81. package/skills/review/SKILL.md +3 -3
  82. package/skills/standup/SKILL.md +1 -1
  83. package/skills/status/SKILL.md +1 -1
  84. package/skills/tech-debt/SKILL.md +2 -2
  85. package/skills/upload/SKILL.md +1 -1
  86. package/core/templates/track-architecture.md +0 -311
@@ -12,7 +12,7 @@
12
12
  "name": "draft",
13
13
  "source": "./",
14
14
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
15
- "version": "3.5.2",
15
+ "version": "3.6.0",
16
16
  "author": {
17
17
  "name": "mayurpise"
18
18
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "draft",
3
3
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
4
- "version": "3.5.2",
4
+ "version": "3.6.0",
5
5
  "author": {
6
6
  "name": "mayurpise"
7
7
  },
@@ -2,7 +2,7 @@
2
2
  "name": "draft",
3
3
  "displayName": "Draft",
4
4
  "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
5
- "version": "3.5.2",
5
+ "version": "3.6.0",
6
6
  "skills": "./skills/",
7
7
  "agents": "./core/agents/",
8
8
  "author": {
@@ -48,6 +48,9 @@ module.exports = {
48
48
  targetSummary: `${base} (${ctx.scope})`,
49
49
  actions,
50
50
  graph: true,
51
+ // The actual install root (scope/CURSOR_HOME aware) — used for the
52
+ // plugin-root marker instead of re-deriving a default path.
53
+ pluginRoot: base,
51
54
  // Runs after the file copies: register + enable the plugin in the shared
52
55
  // Claude registry. On a dry run it computes the merges and writes nothing.
53
56
  postInstall(c) {
@@ -10,9 +10,13 @@ const { writePluginRootMarker } = require('./lib/marker');
10
10
  // before we even reach the real (separately-timed) install steps.
11
11
  const CHECK_TIMEOUT_MS = 10000;
12
12
 
13
+ // On Windows, npm global CLIs are .cmd shims that CreateProcess can't resolve
14
+ // without a shell; elsewhere a shell is unnecessary overhead.
15
+ const USE_SHELL = process.platform === 'win32';
16
+
13
17
  function hasBinary(name) {
14
18
  // ENOENT on the error means the binary is not on PATH.
15
- const r = spawnSync(name, ['--version'], { stdio: 'ignore', timeout: CHECK_TIMEOUT_MS });
19
+ const r = spawnSync(name, ['--version'], { stdio: 'ignore', timeout: CHECK_TIMEOUT_MS, shell: USE_SHELL });
16
20
  return !(r.error && r.error.code === 'ENOENT');
17
21
  }
18
22
 
@@ -25,7 +29,7 @@ function execAction(act, ctx) {
25
29
  const printable = `${act.cmd} ${act.args.join(' ')}`;
26
30
  log.plan(`${ctx.dryRun ? 'would run' : 'running'}: ${printable}`);
27
31
  if (ctx.dryRun) return 0;
28
- const r = spawnSync(act.cmd, act.args, { stdio: 'inherit', timeout: STEP_TIMEOUT_MS });
32
+ const r = spawnSync(act.cmd, act.args, { stdio: 'inherit', timeout: STEP_TIMEOUT_MS, shell: USE_SHELL });
29
33
  if (r.error) {
30
34
  if (r.error.code === 'ETIMEDOUT') {
31
35
  log.error(`timed out after ${Math.round(STEP_TIMEOUT_MS / 1000)}s: ${printable}`);
@@ -123,7 +127,7 @@ function install(host, ctx) {
123
127
  // Record the install path so skills can locate scripts/tools/ from the user's
124
128
  // project cwd (best-effort; graph skills glob-fallback if the marker is absent).
125
129
  if (!ctx.dryRun) {
126
- const root = writePluginRootMarker(host.id);
130
+ const root = writePluginRootMarker(host.id, plan.pluginRoot);
127
131
  if (root) log.note(`Recorded plugin path for graph tooling: ${root}`);
128
132
  }
129
133
 
@@ -18,6 +18,9 @@ function ensureDir(dir) {
18
18
 
19
19
  function copyTree(src, dest) {
20
20
  ensureDir(path.dirname(dest));
21
+ // Mirror, don't merge: dests are fully draft-owned bundled dirs, and a
22
+ // merge-copy would keep files deleted by newer releases around forever.
23
+ fs.rmSync(dest, { recursive: true, force: true });
21
24
  fs.cpSync(src, dest, { recursive: true });
22
25
  }
23
26
 
@@ -14,9 +14,14 @@ const os = require('os');
14
14
  const path = require('path');
15
15
 
16
16
  // Resolve the installed draft plugin root for a given host, or null if unknown.
17
- function resolvePluginRoot(hostId) {
17
+ // hintRoot: the root the just-executed install plan actually wrote to — it
18
+ // already accounts for scope (--project) and env overrides (CURSOR_HOME) that
19
+ // the per-host defaults below cannot see.
20
+ function resolvePluginRoot(hostId, hintRoot) {
18
21
  const home = os.homedir();
19
22
 
23
+ if (hintRoot && fs.existsSync(path.join(hintRoot, 'scripts', 'tools'))) return hintRoot;
24
+
20
25
  if (hostId === 'claude-code') {
21
26
  // 1. Claude Code's own registry holds the authoritative installPath.
22
27
  const reg = path.join(home, '.claude', 'plugins', 'installed_plugins.json');
@@ -77,9 +82,9 @@ function compareVersions(a, b) {
77
82
  }
78
83
 
79
84
  // Write ~/.cache/draft/plugin-root for the host. Returns the path written, or null.
80
- function writePluginRootMarker(hostId) {
85
+ function writePluginRootMarker(hostId, hintRoot) {
81
86
  try {
82
- const root = resolvePluginRoot(hostId);
87
+ const root = resolvePluginRoot(hostId, hintRoot);
83
88
  if (!root) return null;
84
89
  const dest = path.join(os.homedir(), '.cache', 'draft', 'plugin-root');
85
90
  fs.mkdirSync(path.dirname(dest), { recursive: true });
@@ -180,7 +180,7 @@ Write the completed content to `draft/.ai-context.md`.
180
180
  After writing both output files, strip trailing whitespace and blank lines at EOF to prevent GitHub upload failures. Resolve the script via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)):
181
181
 
182
182
  ```bash
183
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
183
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
184
184
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
185
185
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
186
186
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -16,7 +16,7 @@ Referenced by: All skills that generate Draft reports — including `/draft:bugh
16
16
  Use `git-metadata.sh` from the plugin install, resolved via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)):
17
17
 
18
18
  ```bash
19
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
20
20
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
21
21
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
22
22
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -92,10 +92,10 @@ These fields are appended to `~/.draft/metrics.jsonl` along with the existing sk
92
92
 
93
93
  ## Tooling Wrappers
94
94
 
95
- For common query modes, prefer the deterministic wrappers that ship with the plugin. Resolve their location via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)) before invoking. Skills run with cwd = the user's project and `${CLAUDE_PLUGIN_ROOT}` is **not** exported into skill Bash, so a bare `scripts/tools/foo.sh` fails — establish `DRAFT_TOOLS` once before the first helper call, in the same Bash session as your tool calls (re-establish it if you split helper calls into a separate, later Bash block):
95
+ For common query modes, prefer the deterministic wrappers that ship with the plugin. Resolve their location via the canonical tool resolver (see [tool-resolver.md](tool-resolver.md)) before invoking. Skills run with cwd = the user's project and `${CLAUDE_PLUGIN_ROOT}` is **not** exported into skill Bash, so a bare `scripts/tools/git-metadata.sh` fails — establish `DRAFT_TOOLS` once before the first helper call, in the same Bash session as your tool calls (re-establish it if you split helper calls into a separate, later Bash block):
96
96
 
97
97
  ```bash
98
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
98
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
99
99
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
100
100
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
101
101
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -211,7 +211,7 @@ Live queries go through the shell tools under `scripts/tools/`, which drive the
211
211
  ### Callers — who calls this function?
212
212
 
213
213
  ```bash
214
- scripts/tools/graph-callers.sh --repo . --symbol <name>
214
+ "$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <name>
215
215
  ```
216
216
 
217
217
  Output: `{symbol, callers[{name, file}], source}`. Use when enumerating call sites before claiming "no other usages" or judging breaking-change severity.
@@ -219,8 +219,8 @@ Output: `{symbol, callers[{name, file}], source}`. Use when enumerating call sit
219
219
  ### Impact — blast radius of a file or symbol
220
220
 
221
221
  ```bash
222
- scripts/tools/graph-impact.sh --repo . --file <path> # changed-file impact (working-tree diff)
223
- scripts/tools/graph-impact.sh --repo . --symbol <name> # transitive callers of a function
222
+ "$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path> # changed-file impact (working-tree diff)
223
+ "$DRAFT_TOOLS/graph-impact.sh" --repo . --symbol <name> # transitive callers of a function
224
224
  ```
225
225
 
226
226
  Output: `{target, kind, impacted[{name, file, hop}], source}`. Use when sizing risk before modifying a file or symbol, especially high-fan-in hotspots.
@@ -228,7 +228,7 @@ Output: `{target, kind, impacted[{name, file, hop}], source}`. Use when sizing r
228
228
  ### Hotspots — fan-in ranking
229
229
 
230
230
  ```bash
231
- scripts/tools/hotspot-rank.sh --repo . [--top N]
231
+ "$DRAFT_TOOLS/hotspot-rank.sh" --repo . [--top N]
232
232
  ```
233
233
 
234
234
  Output: `{hotspots[{id, name, fanIn}], source}` (server-computed by the engine).
@@ -236,7 +236,7 @@ Output: `{hotspots[{id, name, fanIn}], source}` (server-computed by the engine).
236
236
  ### Cycles — call-cycle detection
237
237
 
238
238
  ```bash
239
- scripts/tools/cycle-detect.sh --repo .
239
+ "$DRAFT_TOOLS/cycle-detect.sh" --repo .
240
240
  ```
241
241
 
242
242
  Output: `{cycles[[a,b],[a,b,c]], source}` — fixed-length 2- and 3-node `CALLS` cycles (mutual recursion / tight coupling).
@@ -246,7 +246,7 @@ Output: `{cycles[[a,b],[a,b,c]], source}` — fixed-length 2- and 3-node `CALLS`
246
246
  Query the engine's architecture view live with the `graph-arch.sh` wrapper (it resolves the engine, indexes on demand, and auto-resolves the project):
247
247
 
248
248
  ```bash
249
- scripts/tools/graph-arch.sh --repo . \
249
+ "$DRAFT_TOOLS/graph-arch.sh" --repo . \
250
250
  | jq '{packages, node_labels, edge_types, routes, layers, boundaries}'
251
251
  ```
252
252
 
@@ -255,8 +255,8 @@ scripts/tools/graph-arch.sh --repo . \
255
255
  ### Mermaid — diagram text
256
256
 
257
257
  ```bash
258
- scripts/tools/mermaid-from-graph.sh --repo . --diagram module-deps # co-change coupling
259
- scripts/tools/mermaid-from-graph.sh --repo . --diagram proto-map # detected routes
258
+ "$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram module-deps # co-change coupling
259
+ "$DRAFT_TOOLS/mermaid-from-graph.sh" --repo . --diagram proto-map # detected routes
260
260
  ```
261
261
 
262
262
  Emits a ready-to-inject ` ```mermaid ``` ` block on the fly (computed live by the engine), or an empty stub (exit 2) when the engine is unavailable. Diagrams are generated at the moment of use — they are never committed.
@@ -264,7 +264,7 @@ Emits a ready-to-inject ` ```mermaid ``` ` block on the fly (computed live by th
264
264
  ### Snippet — verified source + caller/callee counts
265
265
 
266
266
  ```bash
267
- scripts/tools/graph-snippet.sh --repo . --qualified <pkg.Mod.Class.method>
267
+ "$DRAFT_TOOLS/graph-snippet.sh" --repo . --qualified <pkg.Mod.Class.method>
268
268
  ```
269
269
 
270
270
  Output: `{qualified_name, file, start_line, end_line, callers, callees, transitive_loop_depth, complexity, code, status, source}`. Prefer this over grep+Read when you have a qualified name — it returns the engine's attributed source plus pre-computed counts.
@@ -272,7 +272,7 @@ Output: `{qualified_name, file, start_line, end_line, callers, callees, transiti
272
272
  ### Search — semantic / ranked symbol lookup
273
273
 
274
274
  ```bash
275
- scripts/tools/graph-search.sh --repo . --query "auth token refresh" [--limit N]
275
+ "$DRAFT_TOOLS/graph-search.sh" --repo . --query "auth token refresh" [--limit N]
276
276
  ```
277
277
 
278
278
  Output: `{query, results[{name, qualified_name, label, file, rank}], total, source}`. Use when the user names an **intent/concept** rather than an exact symbol — this is the first move in the Concept-to-Files recipe.
@@ -280,8 +280,8 @@ Output: `{query, results[{name, qualified_name, label, file, rank}], total, sour
280
280
  ### Tests — coverage edges and untested surface
281
281
 
282
282
  ```bash
283
- scripts/tools/graph-tests.sh --repo . --symbol <name> # tests covering a symbol
284
- scripts/tools/graph-tests.sh --repo . --untested # exported symbols with no TESTS edge
283
+ "$DRAFT_TOOLS/graph-tests.sh" --repo . --symbol <name> # tests covering a symbol
284
+ "$DRAFT_TOOLS/graph-tests.sh" --repo . --untested # exported symbols with no TESTS edge
285
285
  ```
286
286
 
287
287
  Output: `{symbol, tests[{test,file}], status, source}` or `{untested[{symbol,file}], total, truncated, source}`. Feeds coverage gaps for `init`/`testing-strategy`/`coverage`.
@@ -289,7 +289,7 @@ Output: `{symbol, tests[{test,file}], status, source}` or `{untested[{symbol,fil
289
289
  ### Deps — real module/file import graph
290
290
 
291
291
  ```bash
292
- scripts/tools/graph-deps.sh --repo . [--file PATH]
292
+ "$DRAFT_TOOLS/graph-deps.sh" --repo . [--file PATH]
293
293
  ```
294
294
 
295
295
  Output: `{imports[{src,dst}], total, truncated, source}` from actual `IMPORTS` edges (self-imports filtered). This is the auto-derived dependency graph behind `mermaid-from-graph.sh --diagram module-deps` and `architecture.md §9`.
@@ -297,7 +297,7 @@ Output: `{imports[{src,dst}], total, truncated, source}` from actual `IMPORTS` e
297
297
  ### Hierarchy — class inheritance
298
298
 
299
299
  ```bash
300
- scripts/tools/graph-hierarchy.sh --repo . [--symbol <Class> | --derived <Base>]
300
+ "$DRAFT_TOOLS/graph-hierarchy.sh" --repo . [--symbol <Class> | --derived <Base>]
301
301
  ```
302
302
 
303
303
  Output: `{edges[{child,parent}], status, source}`. `--derived` gives the blast radius of changing a base class.
@@ -305,8 +305,8 @@ Output: `{edges[{child,parent}], status, source}`. `--derived` gives the blast r
305
305
  ### Errors — error-propagation paths
306
306
 
307
307
  ```bash
308
- scripts/tools/graph-errors.sh --repo . --symbol <name> # what it raises/throws
309
- scripts/tools/graph-errors.sh --repo . --type <ErrType> # who raises/throws that type
308
+ "$DRAFT_TOOLS/graph-errors.sh" --repo . --symbol <name> # what it raises/throws
309
+ "$DRAFT_TOOLS/graph-errors.sh" --repo . --type <ErrType> # who raises/throws that type
310
310
  ```
311
311
 
312
312
  Output: `{symbol, raises[...], status, source}` or `{type, raisers[...], status, source}`. `--type` drives fail-closed audits.
@@ -314,7 +314,7 @@ Output: `{symbol, raises[...], status, source}` or `{type, raisers[...], status,
314
314
  ### Risk — pre-computed risk hotspots
315
315
 
316
316
  ```bash
317
- scripts/tools/graph-risk.sh --repo . [--min-complexity N]
317
+ "$DRAFT_TOOLS/graph-risk.sh" --repo . [--min-complexity N]
318
318
  ```
319
319
 
320
320
  Output: `{risky[{symbol, file, complexity, flags}], total, truncated, source}` from the engine's pre-computed flags (`unguarded_recursion`, `recursion_in_loop`, `alloc_in_loop`, `linear_scan_in_loop`). High-signal input for `bughunt`/`deep-review` — the engine already found these.
@@ -322,8 +322,8 @@ Output: `{risky[{symbol, file, complexity, flags}], total, truncated, source}` f
322
322
  ### Generic — read-only escape hatch (all 20 edges / ~30 properties)
323
323
 
324
324
  ```bash
325
- scripts/tools/graph-query.sh --repo . --cypher 'MATCH (f)-[:WRITES]->(v) RETURN f.name, v.name LIMIT 50'
326
- scripts/tools/graph-query.sh --repo . --tool get_graph_schema --json '{}'
325
+ "$DRAFT_TOOLS/graph-query.sh" --repo . --cypher 'MATCH (f)-[:WRITES]->(v) RETURN f.name, v.name LIMIT 50'
326
+ "$DRAFT_TOOLS/graph-query.sh" --repo . --tool get_graph_schema --json '{}'
327
327
  ```
328
328
 
329
329
  Unlocks any edge type or node property without a purpose-built wrapper. Write verbs are rejected; stay inside the SAFE dialect set (above). Emits raw engine JSON.
@@ -331,7 +331,7 @@ Unlocks any edge type or node property without a purpose-built wrapper. Write ve
331
331
  ### Indexing / refreshing the gate marker
332
332
 
333
333
  ```bash
334
- scripts/tools/graph-snapshot.sh --repo .
334
+ "$DRAFT_TOOLS/graph-snapshot.sh" --repo .
335
335
  ```
336
336
 
337
337
  Indexes the repo into the engine and writes the `draft/graph/schema.yaml` gate marker (now including the `detect_changes` delta: `changed_files`/`impacted_symbols`). It writes **no** graph data. Run during `/draft:init` and `/draft:graph`, or whenever the index should be refreshed.
@@ -350,7 +350,7 @@ The engine is the `codebase-memory-mcp` binary. Resolution order (implemented by
350
350
  The canonical verifier is `scripts/tools/verify-graph-binary.sh` (`--json --verbose --strict`). It resolves and liveness-checks the engine and, in a `draft/` context, writes the usage-report side-effect:
351
351
 
352
352
  ```bash
353
- ENGINE_INFO="$(scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null || true)"
353
+ ENGINE_INFO="$("$DRAFT_TOOLS/verify-graph-binary.sh" --repo . --json 2>/dev/null || true)"
354
354
  # {"status":"ok","engine_bin":"...","source":"managed|path|bundled:<arch>|override","arch":"..."}
355
355
  ```
356
356
 
@@ -363,7 +363,7 @@ After successful detection, `draft/.graph-binary-report.json` contains: `detecte
363
363
  Run during `draft:init` / `draft:graph`, or manually:
364
364
 
365
365
  ```bash
366
- scripts/tools/graph-snapshot.sh --repo .
366
+ "$DRAFT_TOOLS/graph-snapshot.sh" --repo .
367
367
  ```
368
368
 
369
369
  The engine indexes C/C++, Go, Python, TypeScript/JS, and more (tree-sitter, 159 languages) plus LSP-assisted resolution for the major ones, and detects HTTP/gRPC/GraphQL routes. Indexing is incremental in the engine (content-based, git-aware). This refreshes the engine index and rewrites the `schema.yaml` gate marker; it produces no committed graph data.
@@ -15,7 +15,7 @@ project**, not the plugin. The helpers live inside the plugin install directory,
15
15
  which on a marketplace/npm install is `~/.claude/plugins/cache/<marketplace>/draft/<version>/`
16
16
  — never the cwd. `${CLAUDE_PLUGIN_ROOT}` is **not** exported into skill-driven Bash
17
17
  (it is only set for hooks, MCP/LSP servers, and monitor commands), so a bare
18
- `scripts/tools/foo.sh` or `${CLAUDE_PLUGIN_ROOT}/...` invocation silently fails.
18
+ `scripts/tools/git-metadata.sh` or `${CLAUDE_PLUGIN_ROOT}/...` invocation silently fails.
19
19
 
20
20
  Every skill MUST resolve `DRAFT_TOOLS` and invoke helpers as `"$DRAFT_TOOLS/<tool>.sh"`.
21
21
 
@@ -24,16 +24,20 @@ Every skill MUST resolve `DRAFT_TOOLS` and invoke helpers as `"$DRAFT_TOOLS/<too
24
24
  `DRAFT_TOOLS` resolves to the first directory that exists, in this order:
25
25
 
26
26
  1. `${DRAFT_PLUGIN_ROOT}/scripts/tools` — explicit override (testing / pinned installs)
27
- 2. `$(cat ~/.cache/draft/plugin-root)/scripts/tools` — install marker written by `draft install` (authoritative)
28
- 3. `${CLAUDE_PLUGIN_ROOT}/scripts/tools` set in hook/MCP contexts; harmless to probe
29
- 4. `installed_plugins.json installPath` for `draft@*` Claude Code's own registry (needs `jq`)
30
- 5. `~/.claude/plugins/cache/*/draft/*/scripts/tools` — newest cache install (glob, `sort -V`)
31
- 6. `~/.claude/plugins/marketplaces/*draft*/scripts/tools` — marketplace clone
32
- 7. `~/.cursor/plugins/local/draft/scripts/tools` — Cursor local install
33
- 8. `$PWD/scripts/tools` — dev / dogfooding (running inside the draft repo itself)
34
-
35
- The marker (step 2) is the fast, authoritative path; steps 5–6 are the glob fallback
36
- that keeps resolution working on installs predating the marker (no reinstall required).
27
+ 2. `$PWD/scripts/tools` — dev / dogfooding when cwd IS the draft repo (guarded by
28
+ `resolve-tools.sh`'s own presence, so it can never misfire in a user project;
29
+ deliberately beats the install marker so a repo checkout always wins)
30
+ 3. `$(cat ~/.cache/draft/plugin-root)/scripts/tools` — install marker written by `draft install` (authoritative for installs)
31
+ 4. `${CLAUDE_PLUGIN_ROOT}/scripts/tools` — set in hook/MCP contexts; harmless to probe
32
+ 5. `installed_plugins.json → installPath` for `draft@*` Claude Code's own registry (needs `jq`)
33
+ 6. `~/.claude/plugins/cache/*/draft/*/scripts/tools` — newest cache install (glob, `sort -V`)
34
+ 7. `~/.claude/plugins/marketplaces/*draft*/scripts/tools` — marketplace clone
35
+ 8. `~/.cursor/plugins/local/draft/scripts/tools` Cursor local install
36
+ 9. `$PWD/scripts/tools` last-resort cwd fallback (unguarded)
37
+
38
+ The marker (step 3) is the fast, authoritative path for installs; steps 6–7 are the
39
+ glob fallback that keeps resolution working on installs predating the marker (no
40
+ reinstall required).
37
41
 
38
42
  ## Skill preamble (copy verbatim)
39
43
 
@@ -44,7 +48,7 @@ invocations (only the cwd does), so if you split helper calls into a later, sepa
44
48
  Bash block, re-establish `DRAFT_TOOLS` there too:
45
49
 
46
50
  ```bash
47
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
51
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
48
52
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
49
53
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
50
54
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -58,9 +62,10 @@ Then invoke helpers through the variable:
58
62
  ```
59
63
 
60
64
  The four-line inline preamble is self-contained and is the recommended form for
61
- skills — it needs no marker file and no prior `source`. The full 8-step resolver
62
- (adding the `${DRAFT_PLUGIN_ROOT}` override, `${CLAUDE_PLUGIN_ROOT}`, the jq-registry
63
- lookup, and the Cursor path) is shipped as `scripts/tools/resolve-tools.sh` for tests
65
+ skills — it needs no marker file and no prior `source`. The full resolver
66
+ (adding the `${DRAFT_PLUGIN_ROOT}` override, the guarded dogfood short-circuit,
67
+ `${CLAUDE_PLUGIN_ROOT}`, the jq-registry lookup, and the Cursor path) is shipped
68
+ as `scripts/tools/resolve-tools.sh` for tests
64
69
  and for callers that prefer a single source of truth:
65
70
 
66
71
  ```bash
@@ -1,17 +1,13 @@
1
1
  ---
2
- type: Subsystem
3
- title: "{PROJECT_NAME} — Wiki"
4
- description: >
5
- Root index of the project wiki. Start here, then route into
6
- overview/, systems/, features/, reference/, or entrypoints/ via the
7
- Concept Map. Open a concept only when its description matches the task.
8
- resource: .
9
- tags: [index]
10
- timestamp: "{ISO_TIMESTAMP}"
11
2
  okf_version: "0.1"
12
- okf_types_version: "0.1"
13
3
  ---
14
4
 
5
+ <!-- OKF §6/§11: an index file carries NO concept frontmatter; the root index.md
6
+ may declare ONLY `okf_version`. The frozen concept-`type` vocabulary version
7
+ is tracked here in the body (not in frontmatter) so bumping it stays visible
8
+ without violating the index-frontmatter rule.
9
+ okf-types-version: 0.1 -->
10
+
15
11
  # {PROJECT_NAME} — Wiki
16
12
 
17
13
  > Project wiki. One concept per file; cross-links form the graph. The
@@ -1,14 +1,5 @@
1
- ---
2
- type: Subsystem
3
- title: "{SECTION_TITLE}"
4
- description: >
5
- Section index. Lists every concept in this section with its one-line
6
- routing description so an agent can pick the right page without opening
7
- each one. {SECTION_PURPOSE}
8
- resource: .
9
- tags: [index]
10
- timestamp: "{ISO_TIMESTAMP}"
11
- ---
1
+ <!-- OKF §6: an index file contains NO frontmatter. This page is a reserved
2
+ navigation index, not a concept — its Concepts table is tool-generated. -->
12
3
 
13
4
  # {SECTION_TITLE}
14
5
 
@@ -111,7 +111,7 @@ validator chain via the canonical resolver pattern (see
111
111
  [core/shared/verification-gates.md](../../core/shared/verification-gates.md)):
112
112
 
113
113
  ```bash
114
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
114
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
115
115
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
116
116
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
117
117
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"