@drafthq/draft 2.8.1 → 3.0.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/README.md +9 -3
  4. package/bin/README.md +13 -0
  5. package/cli/src/installer.js +11 -2
  6. package/core/methodology.md +17 -18
  7. package/core/shared/condensation.md +1 -1
  8. package/core/shared/draft-context-loading.md +4 -2
  9. package/core/shared/graph-query.md +4 -3
  10. package/core/templates/ai-context.md +1 -0
  11. package/core/templates/ai-profile.md +1 -0
  12. package/core/templates/architecture.md +1 -0
  13. package/core/templates/dependency-graph.md +2 -2
  14. package/core/templates/discovery.md +1 -0
  15. package/core/templates/guardrails.md +1 -0
  16. package/core/templates/hld.md +1 -0
  17. package/core/templates/lld.md +1 -0
  18. package/core/templates/plan.md +1 -0
  19. package/core/templates/product.md +1 -0
  20. package/core/templates/rca.md +1 -0
  21. package/core/templates/root-architecture.md +3 -3
  22. package/core/templates/root-product.md +2 -2
  23. package/core/templates/root-tech-stack.md +2 -2
  24. package/core/templates/service-index.md +3 -3
  25. package/core/templates/spec.md +1 -0
  26. package/core/templates/tech-matrix.md +2 -2
  27. package/core/templates/tech-stack.md +1 -0
  28. package/core/templates/workflow.md +1 -0
  29. package/integrations/agents/AGENTS.md +134 -918
  30. package/integrations/copilot/.github/copilot-instructions.md +134 -918
  31. package/integrations/copilot/.github/copilot-instructions.md.7iDz8X +91 -0
  32. package/integrations/copilot/.github/copilot-instructions.md.DoBdtd +91 -0
  33. package/integrations/copilot/.github/copilot-instructions.md.McGoBW +122 -0
  34. package/integrations/copilot/.github/copilot-instructions.md.VsPyLB +91 -0
  35. package/integrations/copilot/.github/copilot-instructions.md.XAVr7D +91 -0
  36. package/integrations/copilot/.github/copilot-instructions.md.YoFVFa +91 -0
  37. package/integrations/copilot/.github/copilot-instructions.md.a9DeW0 +91 -0
  38. package/integrations/copilot/.github/copilot-instructions.md.oxQs3B +91 -0
  39. package/integrations/copilot/.github/copilot-instructions.md.ww33Ly +91 -0
  40. package/package.json +1 -1
  41. package/scripts/lib.sh +4 -1
  42. package/scripts/tools/graph-init.sh +187 -0
  43. package/scripts/tools/graph-snapshot.sh +6 -1
  44. package/scripts/tools/okf-bundle.sh +141 -0
  45. package/scripts/tools/okf-check.sh +137 -0
  46. package/scripts/tools/okf-emit.sh +161 -0
  47. package/scripts/tools/skill-caps.conf +0 -1
  48. package/skills/GRAPH.md +7 -10
  49. package/skills/bughunt/SKILL.md +13 -0
  50. package/skills/discover/SKILL.md +2 -4
  51. package/skills/draft/SKILL.md +2 -2
  52. package/skills/draft/intent-mapping.md +3 -2
  53. package/skills/graph/SKILL.md +3 -3
  54. package/skills/init/SKILL.md +58 -19
  55. package/skills/init/references/architecture-spec.md +5 -5
  56. package/skills/index/SKILL.md +0 -848
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: init
3
- description: "Initialize Draft project context for Context-Driven Development. Run once per project to create product.md, tech-stack.md, workflow.md, tracks.md, architecture.md (brownfield), .ai-context.md (derived), and .ai-profile.md (ultra-compact profile). Always performs deep analysis. Use when the user asks to 'init draft', 'set up Draft for this project', 'bootstrap context', or says 'start using Draft', 'I want to use Draft here'."
3
+ description: "Initialize Draft project context for Context-Driven Development — the single, scope-aware entry point (works at the repo root or inside any sub-module; no separate index command). Builds the root-first code-graph knowledge memory (draft/graph/, with a module→root link) and creates product.md, tech-stack.md, workflow.md, tracks.md, architecture.md (brownfield), .ai-context.md (derived), and .ai-profile.md. Supports --graph-only (graph memory only, no markdown) and --module-only. Use when the user asks to 'init draft', 'set up Draft for this project', 'bootstrap context', 'build the code graph', or says 'start using Draft', 'I want to use Draft here'."
4
4
  ---
5
5
 
6
6
  # Draft Init
@@ -193,18 +193,24 @@ synced_to_commit: "a1b2c3d4e5f6789012345678901234567890abcd"
193
193
 
194
194
  Check for arguments:
195
195
  - `refresh`: Update existing context without full re-init
196
- - `index`: Route to `/draft:index`
196
+ - `--graph-only`: Build/refresh only the code-graph knowledge memory (no markdown) — see the fast path below
197
+ - `--module-only`: When run in a sub-module, do not touch the root graph (the module→root link is marked `pending`)
197
198
  - `discover`: Route to `/draft:discover`
198
199
 
200
+ > `/draft:init` is the **single entry point** for building context — there is no separate `index` command. Init is scope-aware (root vs sub-module); see **Scope Detection** below.
201
+
199
202
  ### Route Explicit Modes Before Initialization
200
203
 
201
204
  If the user explicitly invoked a specialist mode, route directly:
202
205
 
203
- - `/draft:init index` → follow `/draft:index`
204
206
  - `/draft:init discover` → follow `/draft:discover`
205
207
 
206
208
  Explicit mode always wins. Do not perform standard initialization if an explicit mode is requested.
207
209
 
210
+ ### `--graph-only` Fast Path
211
+
212
+ If `--graph-only` is present, run **Step 1.4** (scope-aware, root-first graph build via `graph-init.sh`) and **STOP** — generate no `architecture.md` or other markdown. This is the fast path to (re)build the whole-repo code-graph knowledge memory; in a sub-module it also ensures the root spine exists and writes the module→root link. This path is allowed even when `draft/` already exists (it refreshes the graph in place — no `draft.tmp/` staging, no overwrite prompt).
213
+
208
214
  ### Standard Init Check
209
215
 
210
216
  ```bash
@@ -236,16 +242,16 @@ mv draft.tmp/ draft/
236
242
 
237
243
  > **Forced re-init:** If `draft/` exists and the user explicitly requests a fresh init (not refresh), confirm with user before removing the existing `draft/` directory.
238
244
 
239
- ### Monorepo Detection
245
+ ### Scope Detection (root vs sub-module)
246
+
247
+ `/draft:init` is the single entry point and is **scope-aware** — it works the same whether run at the repository root or inside a sub-module. The root-first graph behavior is handled mechanically by `graph-init.sh` in Step 1.4; you do not detect the monorepo shape by hand.
240
248
 
241
- Check for monorepo indicators:
242
- - Multiple `package.json` / `go.mod` / `Cargo.toml` in child directories
243
- - `lerna.json`, `pnpm-workspace.yaml`, `nx.json`, or `turbo.json` at root
244
- - `packages/`, `apps/`, `services/` directories with independent manifests
249
+ Resolve **ROOT** = nearest ancestor (above the current dir) containing `draft/` → else the git toplevel → else the current dir. Then:
245
250
 
246
- If monorepo detected:
247
- - Announce: "Detected monorepo structure. Consider using `/draft:init index` at root level to aggregate service context, or run `/draft:init` within individual service directories."
248
- - Ask user to confirm: initialize here (single service) or abort (use /draft:init index instead)
251
+ - **Root init** (current dir IS root): the graph step builds the whole-repo spine. The generated markdown is a **sparse, high-level system map** that links *down* to each module's context — a large root must not carry deep per-module prose. (See "Root vs Module Markdown" below.)
252
+ - **Module init** (current dir is BELOW root): the graph step ensures the root spine exists first (building it if missing), builds the module snapshot, and writes `draft/graph/root-link.json` (module→root). The generated markdown is the **detailed** module reference produced by the standard deep analysis in this skill.
253
+
254
+ Use `--module-only` to skip touching the root (the link is marked `pending` and resolves when root init later runs). With no git and no ancestor `draft/`, init treats the current dir as root (module-local, no traversal).
249
255
 
250
256
  ### Migration Detection
251
257
 
@@ -478,20 +484,25 @@ If **Greenfield**: skip to Step 2 (Product Definition).
478
484
 
479
485
  **CRITICAL ORDERING**: Phase 0 (this step) MUST complete before writing any section of architecture.md. The graph provides: (a) exhaustive module list, (b) hotspot-ranked module priority, (c) authoritative proto API surface, (d) mermaid diagrams ready for slot injection, (e) codebase tier for .ai-context.md budget.
480
486
 
481
- ### 1. Build the graph snapshot
487
+ ### 1. Build the graph (scope-aware, root-first)
482
488
 
483
- The knowledge-graph engine is `codebase-memory-mcp`, resolved by `scripts/tools/_lib.sh:find_memory_bin` (`DRAFT_MEMORY_BIN` > PATH > `~/.cache/draft/bin` > vendored `bin/<arch>/`). `draft install` fetches it (skip with `--no-graph`); install manually with `scripts/fetch-memory-engine.sh`. Set `DRAFT_MEMORY_DISABLE=1` to opt out.
489
+ The knowledge-graph engine `codebase-memory-mcp` is Draft's **default** capability tier — deterministic call/dependency traversal beats grep/glob. It is normally already installed by `draft install`; `graph-init.sh` fetches it as a fallback when missing (blocking — download/index time is accepted, never gated on cost). Resolution: `scripts/tools/_lib.sh:find_memory_bin` (`DRAFT_MEMORY_BIN` > PATH > `~/.cache/draft/bin` > vendored `bin/<arch>/`). Set `DRAFT_MEMORY_DISABLE=1` to opt out.
484
490
 
485
- One command resolves the engine, indexes the repo, and writes the committed snapshot under `draft/graph/`:
491
+ One command resolves ROOT, ensures the engine, builds the whole-repo spine, and in a sub-module — builds the module snapshot and writes the `root-link.json` pointer:
486
492
 
487
493
  ```bash
488
- if scripts/tools/graph-snapshot.sh --repo .; then
489
- echo "Graph snapshot written to draft/graph/ (schema.yaml, architecture.json, hotspots.jsonl, *.mermaid)."
494
+ # Add --module-only to skip touching the root (link marked "pending").
495
+ if scripts/tools/graph-init.sh --scope .; then
496
+ echo "Graph memory ready under draft/graph/ (the root spine is the structural source of truth)."
490
497
  else
491
- echo "Graph engine unavailable — skipping automated graph analysis. Downstream skills degrade gracefully."
498
+ echo "Graph engine unavailable — proceeding with degraded manual discovery. Downstream skills degrade gracefully."
492
499
  fi
493
500
  ```
494
501
 
502
+ - **Root init** writes `<root>/draft/graph/` — the committed, git-tracked whole-repo memory.
503
+ - **Module init** also writes `draft/graph/root-link.json` (module→root); follow `root_graph` for cross-module understanding. The root spine is rebuilt first so the link is live.
504
+ - Only `draft/graph/` is committed. The engine's `~/.cache` index is a disposable accelerator — never commit it; it rebuilds deterministically from source.
505
+
495
506
  Optionally record which engine was selected (usage-report contract):
496
507
 
497
508
  ```bash
@@ -500,7 +511,7 @@ scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null || true
500
511
 
501
512
  See `core/shared/graph-query.md` and `bin/README.md` for the query contract and engine resolution.
502
513
 
503
- If the snapshot succeeds, `draft/graph/` is populated and later steps consume the always-load artifacts + injection slots.
514
+ If the build succeeds, `draft/graph/` is populated and later steps consume the always-load artifacts + injection slots.
504
515
 
505
516
  ### 2. If graph build succeeds, load the always-load artifacts
506
517
 
@@ -1008,11 +1019,19 @@ The document is:
1008
1019
 
1009
1020
  **Full details, per-section guidance, provenance rules, and examples** live in:
1010
1021
  - `core/templates/architecture.md` (the source of truth for the 10 sections + Generation Contract)
1011
- - `docs/research/proposed-graph-backed-architecture-template.md` (design rationale and fidelity rules)
1012
1022
  - `references/architecture-spec.md` (deprecated legacy notes — **10-section template wins on any conflict**)
1013
1023
 
1014
1024
  There is no legacy 28-section structure and no volume targets. The template itself is the contract.
1015
1025
 
1026
+ ### Root vs Module Markdown (scope asymmetry)
1027
+
1028
+ The depth of generated markdown depends on the scope resolved in **Scope Detection**:
1029
+
1030
+ - **Module init** (current dir below root): generate the **full, detailed** 10-section `architecture.md` for the module subtree — the standard deep analysis described in this skill. This is where engineering depth lives.
1031
+ - **Root init** (current dir IS root, monorepo): generate a **sparse, high-level system map**, not deep per-module prose. The root `architecture.md` covers: system overview + Graph Health Dashboard (from the whole-repo spine), the module catalog with one-line responsibilities and links *down* to each module's `draft/.ai-context.md`, cross-module dependency topology (from `draft/graph/`), shared infrastructure, and system-wide invariants. Defer module internals to the module docs — a large root must not duplicate them. If a module has not been initialized, link it as "not yet initialized — run `/draft:init` there."
1032
+
1033
+ The graph is symmetric (root spine + per-module snapshots, linked); only the **prose** is asymmetric. Both consume `draft/graph/`.
1034
+
1016
1035
  **After completing analysis AND passing verification**, write to `draft/architecture.md`. This is the PRIMARY output. Then run the Condensation Subroutine.
1017
1036
 
1018
1037
  ## .ai-context.md Specification
@@ -1588,6 +1607,7 @@ Create `draft/tracks.md` with metadata header:
1588
1607
 
1589
1608
  ```markdown
1590
1609
  ---
1610
+ type: TrackIndex
1591
1611
  project: "{PROJECT_NAME}"
1592
1612
  module: "root"
1593
1613
  generated_by: "draft:init"
@@ -1633,6 +1653,23 @@ For **brownfield** projects, run `/draft:learn` (no arguments — full codebase
1633
1653
 
1634
1654
  ## Completion
1635
1655
 
1656
+ **Finalize OKF bundle:** After all `draft/` files are written, run the bundle tool
1657
+ to (re)generate the Open Knowledge Format root index so the whole `draft/` tree is
1658
+ a portable, vendor-neutral OKF bundle. This is the default — no flag required.
1659
+
1660
+ ```bash
1661
+ scripts/tools/okf-bundle.sh --dir draft # writes the bundle-root draft/index.md
1662
+ scripts/tools/okf-check.sh --dir draft # OKF v0.1 conformance (advisory, non-fatal)
1663
+ ```
1664
+
1665
+ `okf-bundle.sh` links every concept file present (`.ai-profile.md`, `.ai-context.md`,
1666
+ `architecture.md`, `product.md`, `tech-stack.md`, `workflow.md`, `guardrails.md`), the
1667
+ tracks, and the graph sub-bundle (`graph/okf/`). Concept `type:` frontmatter comes from
1668
+ the templates; `okf-check.sh` validates §9 conformance (frontmatter + `type` on every
1669
+ concept; reserved `index.md`/`log.md` structure). It is advisory — report the result,
1670
+ do not fail init. Note: operational reports later written into `draft/` (e.g.
1671
+ `deep-review-report.md`) are not OKF concepts and will be flagged.
1672
+
1636
1673
  **Finalize run memory:** Update `draft/.state/run-memory.json`:
1637
1674
  - `status`: `"completed"`
1638
1675
  - `completed_at`: current ISO timestamp
@@ -1642,6 +1679,7 @@ For **Brownfield** projects, announce:
1642
1679
  "Draft initialized successfully with comprehensive analysis!
1643
1680
 
1644
1681
  Created:
1682
+ - draft/index.md (Open Knowledge Format bundle root — cross-links every concept)
1645
1683
  - draft/.ai-profile.md (20-50 lines — ultra-compact always-injected profile, Tier 0)
1646
1684
  - draft/.ai-context.md (200-400 lines — token-optimized AI context, self-contained, Tier 1)
1647
1685
  - draft/architecture.md (comprehensive human-readable engineering reference, Tier 2)
@@ -1676,6 +1714,7 @@ For **Greenfield** projects, announce:
1676
1714
  "Draft initialized successfully!
1677
1715
 
1678
1716
  Created:
1717
+ - draft/index.md (Open Knowledge Format bundle root — cross-links every concept)
1679
1718
  - draft/product.md
1680
1719
  - draft/tech-stack.md
1681
1720
  - draft/workflow.md
@@ -161,14 +161,14 @@ Write the `GRAPH:module-deps` injection slot into architecture.md:
161
161
 
162
162
  If graph build succeeded (Step 1.4.7 completed), write the populated slot content using the diagram from Step 1.4.7. If filtered (>30 modules), include the filter note. Dashed edges indicate circular dependencies.
163
163
 
164
- If graph binary was not found: write the slot with placeholder body so draft:index can populate it later:
164
+ If graph binary was not found: write the slot with placeholder body so draft:init --graph-only can populate it later:
165
165
  ```
166
166
  <!-- GRAPH:module-deps:START -->
167
- [Graph data unavailable — run draft:index to populate after graph binary is installed]
167
+ [Graph data unavailable — run draft:init --graph-only to populate after graph binary is installed]
168
168
  <!-- GRAPH:module-deps:END -->
169
169
  ```
170
170
 
171
- The slot markers MUST always be written — they are required for draft:index refresh to function.
171
+ The slot markers MUST always be written — they are required for draft:init --graph-only refresh to function.
172
172
 
173
173
  #### 4.2 Process Lifecycle (or Usage Lifecycle for libraries)
174
174
 
@@ -1078,11 +1078,11 @@ If graph build succeeded and proto files exist (Step 1.4.7 completed), write the
1078
1078
  If graph binary was not found or no proto files exist, write the slot with placeholder:
1079
1079
  ```
1080
1080
  <!-- GRAPH:proto-map:START -->
1081
- [Graph data unavailable — run draft:index to populate after graph binary is installed]
1081
+ [Graph data unavailable — run draft:init --graph-only to populate after graph binary is installed]
1082
1082
  <!-- GRAPH:proto-map:END -->
1083
1083
  ```
1084
1084
 
1085
- The slot markers MUST always be written — they are required for draft:index refresh to function.
1085
+ The slot markers MUST always be written — they are required for draft:init --graph-only refresh to function.
1086
1086
 
1087
1087
  ---
1088
1088