@drafthq/draft 2.7.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 (158) hide show
  1. package/.claude-plugin/marketplace.json +38 -0
  2. package/.claude-plugin/plugin.json +26 -0
  3. package/LICENSE +21 -0
  4. package/README.md +272 -0
  5. package/bin/README.md +49 -0
  6. package/cli/bin/draft.js +13 -0
  7. package/cli/src/cli.js +113 -0
  8. package/cli/src/hosts/claude-code.js +46 -0
  9. package/cli/src/hosts/codex.js +33 -0
  10. package/cli/src/hosts/cursor.js +50 -0
  11. package/cli/src/hosts/index.js +24 -0
  12. package/cli/src/hosts/opencode.js +39 -0
  13. package/cli/src/installer.js +61 -0
  14. package/cli/src/lib/fsx.js +34 -0
  15. package/cli/src/lib/graph.js +23 -0
  16. package/cli/src/lib/log.js +32 -0
  17. package/cli/src/lib/paths.js +14 -0
  18. package/core/agents/architect.md +338 -0
  19. package/core/agents/debugger.md +193 -0
  20. package/core/agents/ops.md +104 -0
  21. package/core/agents/planner.md +158 -0
  22. package/core/agents/rca.md +314 -0
  23. package/core/agents/reviewer.md +256 -0
  24. package/core/agents/writer.md +110 -0
  25. package/core/guardrails/README.md +4 -0
  26. package/core/guardrails/code-quality.md +4 -0
  27. package/core/guardrails/dependency-triage.md +4 -0
  28. package/core/guardrails/design-norms.md +4 -0
  29. package/core/guardrails/language-standards.md +4 -0
  30. package/core/guardrails/review-checks.md +4 -0
  31. package/core/guardrails/secure-patterns.md +4 -0
  32. package/core/guardrails/security.md +4 -0
  33. package/core/guardrails.md +22 -0
  34. package/core/knowledge-base.md +127 -0
  35. package/core/methodology.md +1221 -0
  36. package/core/shared/condensation.md +224 -0
  37. package/core/shared/context-verify.md +44 -0
  38. package/core/shared/cross-skill-dispatch.md +127 -0
  39. package/core/shared/discovery-schema.md +75 -0
  40. package/core/shared/draft-context-loading.md +282 -0
  41. package/core/shared/git-report-metadata.md +106 -0
  42. package/core/shared/graph-query.md +239 -0
  43. package/core/shared/graph-usage-report.md +22 -0
  44. package/core/shared/jira-sync.md +170 -0
  45. package/core/shared/parallel-analysis.md +386 -0
  46. package/core/shared/parallel-fanout.md +10 -0
  47. package/core/shared/pattern-learning.md +146 -0
  48. package/core/shared/red-flags.md +58 -0
  49. package/core/shared/template-contract.md +22 -0
  50. package/core/shared/template-hygiene.md +10 -0
  51. package/core/shared/tool-resolver.md +10 -0
  52. package/core/shared/vcs-commands.md +97 -0
  53. package/core/shared/verification-gates.md +47 -0
  54. package/core/templates/CHANGELOG.md +70 -0
  55. package/core/templates/ai-context-export.md +8 -0
  56. package/core/templates/ai-context.md +270 -0
  57. package/core/templates/ai-profile.md +41 -0
  58. package/core/templates/architecture.md +203 -0
  59. package/core/templates/dependency-graph.md +103 -0
  60. package/core/templates/discovery.md +79 -0
  61. package/core/templates/guardrails.md +143 -0
  62. package/core/templates/hld.md +327 -0
  63. package/core/templates/intake-questions.md +403 -0
  64. package/core/templates/jira.md +119 -0
  65. package/core/templates/lld.md +283 -0
  66. package/core/templates/metadata.json +66 -0
  67. package/core/templates/plan.md +130 -0
  68. package/core/templates/product.md +110 -0
  69. package/core/templates/rca.md +86 -0
  70. package/core/templates/root-architecture.md +127 -0
  71. package/core/templates/root-product.md +53 -0
  72. package/core/templates/root-tech-stack.md +117 -0
  73. package/core/templates/service-index.md +55 -0
  74. package/core/templates/session-summary.md +8 -0
  75. package/core/templates/spec.md +165 -0
  76. package/core/templates/tech-matrix.md +101 -0
  77. package/core/templates/tech-stack.md +169 -0
  78. package/core/templates/track-architecture.md +311 -0
  79. package/core/templates/workflow.md +187 -0
  80. package/integrations/agents/AGENTS.md +24384 -0
  81. package/integrations/copilot/.github/copilot-instructions.md +24384 -0
  82. package/integrations/gemini/.gemini.md +26 -0
  83. package/package.json +53 -0
  84. package/scripts/fetch-memory-engine.sh +116 -0
  85. package/scripts/lib.sh +256 -0
  86. package/scripts/tools/_lib.sh +220 -0
  87. package/scripts/tools/adr-index.sh +117 -0
  88. package/scripts/tools/check-graph-usage-report.sh +95 -0
  89. package/scripts/tools/check-scope-conflicts.sh +139 -0
  90. package/scripts/tools/check-skill-line-caps.sh +115 -0
  91. package/scripts/tools/check-template-noop.sh +87 -0
  92. package/scripts/tools/check-track-hygiene.sh +230 -0
  93. package/scripts/tools/classify-files.sh +231 -0
  94. package/scripts/tools/cycle-detect.sh +75 -0
  95. package/scripts/tools/detect-test-framework.sh +135 -0
  96. package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
  97. package/scripts/tools/emit-skill-metrics.sh +71 -0
  98. package/scripts/tools/fix-whitespace.sh +192 -0
  99. package/scripts/tools/freshness-check.sh +143 -0
  100. package/scripts/tools/git-metadata.sh +203 -0
  101. package/scripts/tools/graph-callers.sh +74 -0
  102. package/scripts/tools/graph-impact.sh +93 -0
  103. package/scripts/tools/graph-snapshot.sh +102 -0
  104. package/scripts/tools/hotspot-rank.sh +75 -0
  105. package/scripts/tools/manage-symlinks.sh +85 -0
  106. package/scripts/tools/mermaid-from-graph.sh +92 -0
  107. package/scripts/tools/migrate-track-frontmatter.sh +241 -0
  108. package/scripts/tools/parse-git-log.sh +135 -0
  109. package/scripts/tools/parse-reports.sh +114 -0
  110. package/scripts/tools/render-track.sh +145 -0
  111. package/scripts/tools/run-coverage.sh +153 -0
  112. package/scripts/tools/scan-markers.sh +144 -0
  113. package/scripts/tools/skill-caps.conf +24 -0
  114. package/scripts/tools/validate-frontmatter.sh +125 -0
  115. package/scripts/tools/verify-citations.sh +250 -0
  116. package/scripts/tools/verify-doc-anchors.sh +204 -0
  117. package/scripts/tools/verify-graph-binary.sh +154 -0
  118. package/skills/GRAPH.md +332 -0
  119. package/skills/adr/SKILL.md +374 -0
  120. package/skills/assist-review/SKILL.md +49 -0
  121. package/skills/bughunt/SKILL.md +668 -0
  122. package/skills/bughunt/references/regression-tests.md +399 -0
  123. package/skills/change/SKILL.md +267 -0
  124. package/skills/coverage/SKILL.md +336 -0
  125. package/skills/debug/SKILL.md +201 -0
  126. package/skills/decompose/SKILL.md +656 -0
  127. package/skills/deep-review/SKILL.md +326 -0
  128. package/skills/deploy-checklist/SKILL.md +254 -0
  129. package/skills/discover/SKILL.md +66 -0
  130. package/skills/docs/SKILL.md +42 -0
  131. package/skills/documentation/SKILL.md +197 -0
  132. package/skills/draft/SKILL.md +177 -0
  133. package/skills/draft/context-files.md +57 -0
  134. package/skills/draft/intent-mapping.md +37 -0
  135. package/skills/draft/quality-guide.md +51 -0
  136. package/skills/graph/SKILL.md +107 -0
  137. package/skills/impact/SKILL.md +86 -0
  138. package/skills/implement/SKILL.md +794 -0
  139. package/skills/incident-response/SKILL.md +245 -0
  140. package/skills/index/SKILL.md +848 -0
  141. package/skills/init/SKILL.md +1784 -0
  142. package/skills/init/references/architecture-spec.md +1259 -0
  143. package/skills/integrations/SKILL.md +53 -0
  144. package/skills/jira/SKILL.md +577 -0
  145. package/skills/jira/references/review.md +1322 -0
  146. package/skills/learn/SKILL.md +478 -0
  147. package/skills/new-track/SKILL.md +841 -0
  148. package/skills/ops/SKILL.md +57 -0
  149. package/skills/plan/SKILL.md +60 -0
  150. package/skills/quick-review/SKILL.md +216 -0
  151. package/skills/revert/SKILL.md +178 -0
  152. package/skills/review/SKILL.md +1114 -0
  153. package/skills/standup/SKILL.md +183 -0
  154. package/skills/status/SKILL.md +183 -0
  155. package/skills/tech-debt/SKILL.md +318 -0
  156. package/skills/testing-strategy/SKILL.md +195 -0
  157. package/skills/tour/SKILL.md +38 -0
  158. package/skills/upload/SKILL.md +117 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "draft-plugins",
3
+ "owner": {
4
+ "name": "mayurpise",
5
+ "url": "https://github.com/mayurpise"
6
+ },
7
+ "metadata": {
8
+ "description": "Context-Driven Development plugins for Claude Code"
9
+ },
10
+ "plugins": [
11
+ {
12
+ "name": "draft",
13
+ "source": "./",
14
+ "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
15
+ "version": "2.7.0",
16
+ "author": {
17
+ "name": "mayurpise"
18
+ },
19
+ "homepage": "https://github.com/drafthq/draft",
20
+ "license": "MIT",
21
+ "keywords": [
22
+ "context-driven-development",
23
+ "ai-assisted",
24
+ "planning",
25
+ "specifications",
26
+ "architecture",
27
+ "code-review",
28
+ "monorepo",
29
+ "tdd",
30
+ "validation",
31
+ "enterprise",
32
+ "incremental-refresh",
33
+ "signal-detection",
34
+ "state-management"
35
+ ]
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "draft",
3
+ "description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
4
+ "version": "2.7.0",
5
+ "author": {
6
+ "name": "mayurpise"
7
+ },
8
+ "homepage": "https://github.com/drafthq/draft",
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "context-driven-development",
12
+ "ai-assisted",
13
+ "planning",
14
+ "specifications",
15
+ "architecture",
16
+ "code-review",
17
+ "monorepo",
18
+ "tdd",
19
+ "validation",
20
+ "enterprise",
21
+ "incremental-refresh",
22
+ "signal-detection",
23
+ "state-management"
24
+ ],
25
+ "skills": "./skills/"
26
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mayur Pise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,272 @@
1
+ <h1 align="center">Draft</h1>
2
+
3
+ <p align="center">
4
+ <strong>Stop shipping AI-generated bugs.</strong><br>
5
+ One command runs a three-stage review on your branch — validation, spec compliance, code quality — and writes the missing tests. Free. Open-source. MIT.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/drafthq/draft/releases"><img src="https://img.shields.io/github/v/release/drafthq/draft?include_prereleases&style=for-the-badge" alt="GitHub release"></a>
10
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
11
+ <a href="https://github.com/drafthq/draft/stargazers"><img src="https://img.shields.io/github/stars/drafthq/draft?style=for-the-badge" alt="Stars"></a>
12
+ <a href="https://github.com/DeusData/codebase-memory-mcp" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/graph_engine-codebase--memory--mcp-8A2BE2?style=for-the-badge" alt="Graph engine: codebase-memory-mcp"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ Powered by <a href="https://github.com/DeusData/codebase-memory-mcp" target="_blank" rel="noopener noreferrer">codebase-memory-mcp</a> by <a href="https://github.com/DeusData" target="_blank" rel="noopener noreferrer">DeusData</a> — a 159-language, 100% local knowledge-graph engine.
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="https://getdraft.dev">Website</a> ·
21
+ <a href="https://getdraft.dev#commands">Docs</a> ·
22
+ <a href="core/methodology.md">Methodology</a> ·
23
+ <a href="https://www.youtube.com/watch?v=gBSwFEFVd7Y">Watch (8 min)</a> ·
24
+ <a href="https://www.youtube.com/playlist?list=PLoN73NRJ_HQPdnR5Su4WkWK-O_7IOrOg_">All Videos</a>
25
+ </p>
26
+
27
+ ---
28
+
29
+ ## The 60-second pitch
30
+
31
+ Your AI assistant just wrote 200 lines. Some of them are bugs. Some don't match your patterns. Some skip tests.
32
+
33
+ ```bash
34
+ /draft:review
35
+ ```
36
+
37
+ Three stages, one command:
38
+
39
+ 1. **Validation** — runs your tests, lints, type-checks, and surfaces real failures
40
+ 2. **Spec compliance** — checks the diff against the agreed spec, not vibes
41
+ 3. **Code quality** — flags hotspots, blast radius, and missing test coverage using a tree-sitter knowledge graph of your repo
42
+
43
+ Free. No API keys. No paid tier. No vendor lock-in. Catches the 3 bugs you missed before they hit your reviewer.
44
+
45
+ > *Demo coming soon — for now, [watch the 8-minute walkthrough](https://www.youtube.com/watch?v=gBSwFEFVd7Y).*
46
+
47
+ ---
48
+
49
+ ## Install (30 seconds)
50
+
51
+ One command installs Draft into your agent. No clone, no config.
52
+
53
+ ```bash
54
+ npx @drafthq/draft install <host> # claude-code | cursor | codex | opencode
55
+ ```
56
+
57
+ …or install the CLI once and reuse it:
58
+
59
+ ```bash
60
+ npm install -g @drafthq/draft
61
+ draft install <host>
62
+ draft list # show every host + where it installs
63
+ ```
64
+
65
+ | Host | `draft install …` | Lands in |
66
+ |------|-------------------|----------|
67
+ | **Claude Code** | `claude-code` | `./.claude-plugin/` + `skills/` `core/` (project) |
68
+ | **Cursor** | `cursor` | `~/.cursor/plugins/local/draft/` (global) |
69
+ | **Codex** | `codex` | `./AGENTS.md` (project) |
70
+ | **opencode** | `opencode` | `./AGENTS.md` + `~/.agents/skills/draft/` |
71
+
72
+ Flags: `--global` / `--project` to pick scope, `--dry-run` to preview writes, `--force` to overwrite, `--no-graph` to skip the graph-engine fetch.
73
+
74
+ Then, in Claude Code:
75
+
76
+ ```bash
77
+ /draft:init # 5-phase codebase analysis (one-time)
78
+ /draft:review # ← run this on every branch before you push
79
+ ```
80
+
81
+ Run `/draft` for the full command map.
82
+
83
+ <details>
84
+ <summary><strong>Other ways to install →</strong></summary>
85
+
86
+ ### Claude Code — native marketplace
87
+ ```bash
88
+ /plugin marketplace add drafthq/draft
89
+ /plugin install draft
90
+ ```
91
+
92
+ ### Cursor — from GitHub
93
+ Cursor natively supports the `.claude-plugin/` structure. Add via *Settings > Rules, Skills, Subagents > Rules > New > Add from Github*:
94
+ ```
95
+ https://github.com/drafthq/draft.git
96
+ ```
97
+
98
+ ### GitHub Copilot
99
+ Copilot reads a committed instructions file — copy it directly (not a `draft install` host):
100
+ ```bash
101
+ mkdir -p .github && curl -o .github/copilot-instructions.md \
102
+ https://raw.githubusercontent.com/drafthq/draft/main/integrations/copilot/.github/copilot-instructions.md
103
+ ```
104
+
105
+ ### Gemini
106
+ ```bash
107
+ curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrations/gemini/.gemini.md
108
+ ```
109
+
110
+ </details>
111
+
112
+ ---
113
+
114
+ ## Beyond `/draft:review` — 27 more commands
115
+
116
+ `/draft:review` is the wedge. Once Draft has indexed your repo, you also get spec-driven planning, TDD-enforced implementation, exhaustive bug hunting, deep architectural audits, and 23 more commands covering the full development lifecycle.
117
+
118
+ ---
119
+
120
+ ## What You Get
121
+
122
+ | Command | What It Does |
123
+ |---------|--------------|
124
+ | **`/draft`** | Overview, intent mapping, and command reference |
125
+ | **`/draft:init`** | Analyze codebase, create context files + state tracking |
126
+ | **`/draft:index`** | Aggregate monorepo service contexts |
127
+ | **`/draft:new-track`** | Collaborative spec + plan with AI |
128
+ | **`/draft:decompose`** | Module decomposition with dependency mapping |
129
+ | **`/draft:implement`** | TDD workflow with checkpoints |
130
+ | **`/draft:coverage`** | Code coverage report (target 95%+) |
131
+ | **`/draft:review`** | 3-stage review (validation + spec compliance + code quality) |
132
+ | **`/draft:deep-review`** | Enterprise-grade module lifecycle and ACID audit |
133
+ | **`/draft:bughunt`** | Exhaustive 14-dimension defect discovery with taint tracking |
134
+ | **`/draft:learn`** | Discover coding patterns, update guardrails |
135
+ | **`/draft:adr`** | Architecture Decision Records |
136
+ | **`/draft:status`** | Show progress overview |
137
+ | **`/draft:revert`** | Git-aware rollback |
138
+ | **`/draft:change`** | Handle mid-track requirement changes |
139
+ | **`/draft:debug`** | Structured debugging: reproduce, isolate, diagnose, fix |
140
+ | **`/draft:quick-review`** | Lightweight 4-dimension code review |
141
+ | **`/draft:deploy-checklist`** | Pre-deployment verification with rollback triggers |
142
+ | **`/draft:testing-strategy`** | Test plan design with coverage targets |
143
+ | **`/draft:tech-debt`** | Technical debt analysis across 6 dimensions |
144
+ | **`/draft:standup`** | Git activity standup summary (read-only) |
145
+ | **`/draft:incident-response`** | Incident lifecycle: triage, communicate, mitigate, postmortem |
146
+ | **`/draft:documentation`** | Technical docs: readme, runbook, api, onboarding |
147
+ | **`/draft:jira`** | Unified Jira workflows (preview / create / review) |
148
+ | **`/draft:tour`** | Interactive architecture mentorship and codebase walk-through |
149
+ | **`/draft:impact`** | ROI analytics tracking friction and timeline metrics |
150
+ | **`/draft:assist-review`** | Summarize intent and highlight structural PR risks for reviewers |
151
+
152
+ [See full command reference →](core/methodology.md#command-workflows)
153
+
154
+ > **Recommended next step after install:** run `/draft:init` to index your repo, then `/draft:review` on any branch with AI-generated changes. Once you've seen what it catches, explore the rest.
155
+
156
+ ---
157
+
158
+ ## Built-in Code Intelligence
159
+
160
+ Draft is powered by a **local knowledge graph engine** ([codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)) that gives every command precise structural context — module boundaries, call graphs, dependencies, hotspots. It's 100% local (no API key, no SaaS), installed on first use.
161
+
162
+ ```bash
163
+ /draft:graph # build / refresh the snapshot
164
+ scripts/tools/graph-impact.sh --file src/auth/login.go
165
+ # → blast radius: which files, which symbols, which tests/docs/configs
166
+ ```
167
+
168
+ | Capability | What it provides |
169
+ |---|---|
170
+ | **Multi-language extraction** | Tree-sitter + LSP-grade resolution across 159 languages, 100% local |
171
+ | **Call graph** | Callers/callees with confidence signals so review/bughunt can weight findings |
172
+ | **Impact analysis** | Blast-radius with file-class dimension (code/test/doc/config) — answers *"what breaks if I change this?"* |
173
+ | **Cycle detection** | Flags circular call dependencies before they bite |
174
+ | **Hotspot ranking** | Fan-in score so high-risk symbols get extra scrutiny |
175
+ | **Incremental indexing** | git-aware, content-based; only changed code re-indexes |
176
+ | **Track impact memory** | `metadata.json.impact` snapshots each completed track's blast radius — `/draft:new-track` flags overlap with recent work |
177
+
178
+ The graph powers `/draft:graph` and `/draft:impact`, enriches `/draft:bughunt` and `/draft:review`, and is consumed by skills via `core/shared/graph-query.md`. The engine is installed via [`scripts/fetch-memory-engine.sh`](scripts/fetch-memory-engine.sh); the deterministic shell helpers live under [`scripts/tools/`](scripts/tools/).
179
+
180
+ ### Deterministic helper tools
181
+
182
+ Skills also call into **14 shell helpers** under `scripts/tools/` for mechanical work — git metadata, file classification, test-framework detection, hotspot ranking, freshness checks, ADR indexing. All emit JSON, follow a uniform exit-code contract, and degrade gracefully when their input source is unavailable.
183
+
184
+ ---
185
+
186
+ ## How It Works
187
+
188
+ ```
189
+ ┌─────────────────────────────────────────────────────────────┐
190
+ │ /draft:init │
191
+ │ 5-phase codebase analysis + signal detection + state │
192
+ │ architecture.md + .ai-context.md + .state/ (freshness, │
193
+ │ signals, run memory) │
194
+ └────────────────────────────┬────────────────────────────────┘
195
+
196
+
197
+ ┌─────────────────────────────────────────────────────────────┐
198
+ │ /draft:new-track │
199
+ │ AI-guided spec.md + phased plan.md │
200
+ └────────────────────────────┬────────────────────────────────┘
201
+
202
+
203
+ ┌─────────────────────────────────────────────────────────────┐
204
+ │ /draft:implement │
205
+ │ RED → GREEN → REFACTOR (repeat) │
206
+ └────────────────────────────┬────────────────────────────────┘
207
+
208
+
209
+ ┌─────────────────────────────────────────────────────────────┐
210
+ │ /draft:review │
211
+ │ Three-stage review (validation + spec + quality) │
212
+ └─────────────────────────────────────────────────────────────┘
213
+
214
+ /draft:init refresh ←── incremental: only re-analyze
215
+ files with changed hashes
216
+ ```
217
+
218
+ [Full workflow →](core/methodology.md#core-workflow)
219
+
220
+ ---
221
+
222
+ ## Why Draft?
223
+
224
+ AI tools are fast but unstructured. Draft applies Context-Driven Development to impose clear boundaries: explicit context, phased execution, and built-in verification, ensuring outputs remain aligned, predictable, and production-ready.
225
+
226
+ ```
227
+ product.md → "Build a task manager"
228
+ tech-stack.md → "React, TypeScript, Tailwind"
229
+ architecture.md → Comprehensive: 28 sections + 5 appendices, Mermaid diagrams (source of truth). Mature brownfield projects with strong existing agent docs (CLAUDE.md, INVARIANTS.md, etc.) receive early Context Quality Audit, graph fidelity dashboard, and explicit Relationship + Gaps sections (no blind duplication).
230
+ .ai-context.md → 200-400 lines: condensed from architecture.md (token-optimized AI context)
231
+ .state/ → freshness hashes, signal classification, run memory (incremental refresh)
232
+ spec.md → "Add drag-and-drop reordering"
233
+ plan.md → "Phase 1: sortable, Phase 2: persist"
234
+ ```
235
+
236
+ Each layer narrows the solution space. By the time AI writes code, decisions are made.
237
+
238
+ **Incremental refresh**: After initial setup, `/draft:init refresh` uses stored file hashes and signal classification to only re-analyze what changed — no full re-scan needed.
239
+
240
+ [Read methodology →](core/methodology.md#philosophy)
241
+
242
+ ---
243
+
244
+ ## Contributing
245
+
246
+ ### Source of Truth
247
+ 1. `core/methodology.md` — Master methodology
248
+ 2. `skills/<name>/SKILL.md` — Command implementations
249
+ 3. `integrations/` — Auto-generated (don't edit)
250
+
251
+ ### Update Workflow
252
+ ```bash
253
+ # 1. Edit core/methodology.md or skills/*/SKILL.md
254
+ # 2. Rebuild integrations
255
+ ./scripts/build-integrations.sh
256
+ ```
257
+
258
+ [Full architecture →](CLAUDE.md)
259
+
260
+ ---
261
+
262
+ ## Star History
263
+
264
+ [![Star History Chart](https://api.star-history.com/svg?repos=drafthq/draft&type=Date)](https://star-history.com/#drafthq/draft&Date)
265
+
266
+ ---
267
+
268
+ <p align="center">MIT License &middot; Graph engine: <a href="https://github.com/DeusData/codebase-memory-mcp" target="_blank" rel="noopener noreferrer">codebase-memory-mcp</a> by <a href="https://github.com/DeusData" target="_blank" rel="noopener noreferrer">DeusData</a></p>
269
+
270
+ <p align="center">
271
+ <strong>Credits:</strong> Inspired by <a href="https://github.com/gemini-cli-extensions/conductor">gemini-cli-extensions/conductor</a>
272
+ </p>
package/bin/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Knowledge-Graph Engine
2
+
3
+ Draft's knowledge graph is powered by **[codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)** — a single static binary that indexes a repository into a SQLite knowledge graph (functions, classes, modules, files, routes, and their CALLS/DEFINES/IMPORTS edges) and answers structural queries.
4
+
5
+ ## Not vendored — fetched on install
6
+
7
+ Unlike the previous Aether `graph` binary, the engine is **not committed to this repo** (it is ~250 MB per platform). Instead it is downloaded on install:
8
+
9
+ ```bash
10
+ scripts/fetch-memory-engine.sh # fetch pinned version for this host
11
+ CMM_VERSION=latest scripts/fetch-memory-engine.sh # or a specific tag / latest
12
+ ```
13
+
14
+ This installs the binary to the **Draft-managed location**:
15
+
16
+ ```
17
+ ~/.cache/draft/bin/codebase-memory-mcp
18
+ ```
19
+
20
+ The fetch script picks the right release archive for the host OS/arch, verifies its SHA-256 against the published `checksums.txt`, extracts it, and installs it there. `draft install claude-code` / `draft install cursor` run this automatically (best-effort, network-gated); skip it with `--no-graph`.
21
+
22
+ ## Resolution order
23
+
24
+ `scripts/tools/_lib.sh:find_memory_bin()` resolves the engine in this order:
25
+
26
+ 1. `DRAFT_MEMORY_BIN` — explicit override (pinned installs, testing)
27
+ 2. `codebase-memory-mcp` on `$PATH` — global/dev installs
28
+ 3. `~/.cache/draft/bin/codebase-memory-mcp` — the managed install location
29
+ 4. `bin/<os>-<arch>/codebase-memory-mcp` under the plugin/repo root — optional vendored fallback (offline/air-gapped distributions only)
30
+
31
+ Architecture strings are normalized to `linux-amd64`, `linux-arm64`, `darwin-amd64`, `darwin-arm64`.
32
+
33
+ There is **no legacy fallback** to the retired Aether `graph` / `graph-clang` binaries.
34
+
35
+ ## Opting out
36
+
37
+ Set `DRAFT_MEMORY_DISABLE=1` to force the engine off. All graph-backed skills and tools degrade gracefully (they report `source: unavailable` / emit empty stubs) when the engine cannot be resolved.
38
+
39
+ ## How tools use it
40
+
41
+ Shell helpers under `scripts/tools/` drive the engine via its CLI
42
+ (`codebase-memory-mcp cli <tool> '<json>'`) and shape results into Draft's
43
+ contracts — see `hotspot-rank.sh`, `cycle-detect.sh`, `mermaid-from-graph.sh`,
44
+ and `verify-graph-binary.sh`. The shared wrappers (`memory_cli`,
45
+ `memory_ensure_index`, `memory_project_for_repo`) live in `_lib.sh`.
46
+
47
+ ## Offline / air-gapped distributions
48
+
49
+ To ship the engine in-tree, place the binary at `bin/<os>-<arch>/codebase-memory-mcp` (resolution step 4). This is optional and not the default; the managed fetch is preferred.
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Entry point for the `draft` CLI. Keeps argv parsing and dispatch in src/cli.js
5
+ // so this stays a thin, dependency-free launcher.
6
+ const { run } = require('../src/cli');
7
+
8
+ run(process.argv.slice(2))
9
+ .then((code) => process.exit(code))
10
+ .catch((err) => {
11
+ console.error(err && err.message ? err.message : String(err));
12
+ process.exit(1);
13
+ });
package/cli/src/cli.js ADDED
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ const os = require('os');
4
+ const { hosts, getHost } = require('./hosts');
5
+ const { install } = require('./installer');
6
+ const log = require('./lib/log');
7
+ const pkg = require('../../package.json');
8
+
9
+ function parseFlags(args) {
10
+ const flags = { scope: null, dryRun: false, graph: true, force: false };
11
+ const positionals = [];
12
+ for (const a of args) {
13
+ switch (a) {
14
+ case '--global': flags.scope = 'global'; break;
15
+ case '--project':
16
+ case '--local': flags.scope = 'project'; break;
17
+ case '--dry-run': flags.dryRun = true; break;
18
+ case '--no-graph': flags.graph = false; break;
19
+ case '--force': flags.force = true; break;
20
+ default:
21
+ if (a.startsWith('-')) {
22
+ throw new Error(`Unknown flag: ${a}`);
23
+ }
24
+ positionals.push(a);
25
+ }
26
+ }
27
+ return { flags, positionals };
28
+ }
29
+
30
+ function printHosts() {
31
+ log.info('\nSupported hosts:');
32
+ for (const h of hosts) {
33
+ log.info(` ${h.id.padEnd(12)} ${h.label} (${h.defaultScope} install)`);
34
+ }
35
+ log.info('\nUsage: draft install <host> [--global|--project] [--dry-run] [--no-graph] [--force]');
36
+ }
37
+
38
+ function printHelp() {
39
+ log.info(`draft — install the Draft Context-Driven Development methodology into your AI coding agent
40
+
41
+ Usage:
42
+ draft install <host> [flags] Install Draft for a host
43
+ draft list List supported hosts
44
+ draft --version Print version
45
+ draft --help Show this help
46
+
47
+ Hosts: ${hosts.map((h) => h.id).join(', ')}
48
+
49
+ Flags:
50
+ --global Install to the user-level location (default for cursor)
51
+ --project Install into the current project (default for claude-code, codex, opencode)
52
+ --dry-run Print planned writes without touching disk
53
+ --no-graph Skip the knowledge-graph engine fetch
54
+ --force Overwrite an existing target
55
+
56
+ GitHub Copilot / Gemini are not hosts — copy the committed instructions file directly:
57
+ .github/copilot-instructions.md or .gemini.md from github.com/drafthq/draft`);
58
+ }
59
+
60
+ function cmdInstall(args) {
61
+ const { flags, positionals } = parseFlags(args);
62
+ const hostId = positionals[0];
63
+ if (!hostId) {
64
+ log.error('Missing host. Usage: draft install <host>');
65
+ printHosts();
66
+ return 1;
67
+ }
68
+ const host = getHost(hostId);
69
+ if (!host) {
70
+ log.error(`Unknown host: ${hostId}`);
71
+ printHosts();
72
+ return 1;
73
+ }
74
+ const ctx = {
75
+ cwd: process.cwd(),
76
+ home: os.homedir(),
77
+ env: process.env,
78
+ scope: flags.scope || host.defaultScope,
79
+ dryRun: flags.dryRun,
80
+ force: flags.force,
81
+ graph: flags.graph,
82
+ };
83
+ return install(host, ctx);
84
+ }
85
+
86
+ async function run(argv) {
87
+ const [cmd, ...rest] = argv;
88
+ switch (cmd) {
89
+ case undefined:
90
+ case 'help':
91
+ case '--help':
92
+ case '-h':
93
+ printHelp();
94
+ return 0;
95
+ case 'version':
96
+ case '--version':
97
+ case '-v':
98
+ log.info(pkg.version);
99
+ return 0;
100
+ case 'list':
101
+ case 'hosts':
102
+ printHosts();
103
+ return 0;
104
+ case 'install':
105
+ return cmdInstall(rest);
106
+ default:
107
+ log.error(`Unknown command: ${cmd}`);
108
+ printHelp();
109
+ return 1;
110
+ }
111
+ }
112
+
113
+ module.exports = { run, parseFlags };
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { asset } = require('../lib/paths');
5
+
6
+ // Draft's native plugin shape: the .claude-plugin manifest + skills/core/bin and
7
+ // the deterministic shell helpers the skills invoke. Copied into the project root
8
+ // so Claude Code (and Cursor, which shares the format) discovers it locally.
9
+ const ITEMS = [
10
+ { p: '.claude-plugin', kind: 'copyTree' },
11
+ { p: 'skills', kind: 'copyTree' },
12
+ { p: 'core', kind: 'copyTree' },
13
+ { p: 'bin', kind: 'copyTree' },
14
+ { p: 'scripts/tools', kind: 'copyTree' },
15
+ { p: 'scripts/fetch-memory-engine.sh', kind: 'copyFile' },
16
+ { p: 'scripts/lib.sh', kind: 'copyFile' },
17
+ ];
18
+
19
+ module.exports = {
20
+ id: 'claude-code',
21
+ label: 'Claude Code',
22
+ aliases: ['claude', 'claudecode'],
23
+ defaultScope: 'project',
24
+
25
+ plan(ctx) {
26
+ const root = ctx.cwd;
27
+ const actions = ITEMS.map((it) => ({
28
+ kind: it.kind,
29
+ src: asset(it.p),
30
+ dest: path.join(root, it.p),
31
+ label: it.p,
32
+ // Guard on the manifest dir: its presence marks a prior Draft install.
33
+ guard: it.p === '.claude-plugin',
34
+ }));
35
+
36
+ return {
37
+ targetSummary: `${root} (project)`,
38
+ actions,
39
+ graph: true,
40
+ done: 'Draft plugin copied into the project. Run /draft in Claude Code to see the commands.',
41
+ notes: [
42
+ 'Alternative (no npm): /plugin marketplace add drafthq/draft then /plugin install draft',
43
+ ],
44
+ };
45
+ },
46
+ };
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { asset } = require('../lib/paths');
5
+
6
+ // Codex reads an AGENTS.md from the repo root. Draft ships a generated AGENTS.md
7
+ // (the full inlined methodology) — drop it in place. Guarded so we never clobber
8
+ // an existing AGENTS.md without --force.
9
+ module.exports = {
10
+ id: 'codex',
11
+ label: 'OpenAI Codex',
12
+ aliases: ['codex-cli'],
13
+ defaultScope: 'project',
14
+
15
+ plan(ctx) {
16
+ const dest = path.join(ctx.cwd, 'AGENTS.md');
17
+ return {
18
+ targetSummary: `${dest} (project)`,
19
+ actions: [
20
+ {
21
+ kind: 'copyFile',
22
+ src: asset('integrations', 'agents', 'AGENTS.md'),
23
+ dest,
24
+ label: 'AGENTS.md',
25
+ guard: true,
26
+ },
27
+ ],
28
+ graph: false,
29
+ done: 'Wrote AGENTS.md — Codex reads it automatically from the repo root.',
30
+ notes: ['Commit AGENTS.md so your whole team shares the Draft methodology.'],
31
+ };
32
+ },
33
+ };
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { asset } = require('../lib/paths');
5
+
6
+ // Cursor natively understands the .claude-plugin structure. Install the same
7
+ // native plugin tree, by default to the user-level plugin directory so it is
8
+ // available across all projects.
9
+ const ITEMS = [
10
+ { p: '.claude-plugin', kind: 'copyTree' },
11
+ { p: 'skills', kind: 'copyTree' },
12
+ { p: 'core', kind: 'copyTree' },
13
+ { p: 'bin', kind: 'copyTree' },
14
+ { p: 'scripts/tools', kind: 'copyTree' },
15
+ { p: 'scripts/fetch-memory-engine.sh', kind: 'copyFile' },
16
+ { p: 'scripts/lib.sh', kind: 'copyFile' },
17
+ ];
18
+
19
+ function cursorHome(ctx) {
20
+ return ctx.env.CURSOR_HOME || path.join(ctx.home, '.cursor');
21
+ }
22
+
23
+ module.exports = {
24
+ id: 'cursor',
25
+ label: 'Cursor',
26
+ aliases: [],
27
+ defaultScope: 'global',
28
+
29
+ plan(ctx) {
30
+ const base = ctx.scope === 'project'
31
+ ? path.join(ctx.cwd, '.cursor', 'plugins', 'local', 'draft')
32
+ : path.join(cursorHome(ctx), 'plugins', 'local', 'draft');
33
+
34
+ const actions = ITEMS.map((it) => ({
35
+ kind: it.kind,
36
+ src: asset(it.p),
37
+ dest: path.join(base, it.p),
38
+ label: it.p,
39
+ }));
40
+ // Guard the whole install dir on the manifest's presence.
41
+ actions[0].guard = true;
42
+
43
+ return {
44
+ targetSummary: `${base} (${ctx.scope})`,
45
+ actions,
46
+ graph: true,
47
+ done: `Draft installed to ${base}. Restart Cursor to detect the plugin.`,
48
+ };
49
+ },
50
+ };