Skip to content

Commit 568933a

Browse files
mayurpiseclaude
andcommitted
feat(init)!: single scope-aware /draft:init, remove /draft:index (3.0.0)
/draft:init is now the single, scope-aware entry point. It builds the whole-repo code-graph knowledge memory first (the root spine), then scope-local context. New scripts/tools/graph-init.sh resolves the repo ROOT (ancestor-draft/ -> git toplevel -> cwd), ensures the engine (fetching as fallback), builds the committed root snapshot, and in a sub-module writes the module snapshot + draft/graph/root-link.json pointing up to the root graph. Adds --graph-only and --module-only flags; markdown is scope-asymmetric (sparse root / detailed module) while the graph stays symmetric. Rewires routers (discover, draft, intent-mapping), methodology, shared procedures, and 6 root-aggregation templates from index to init; the multi-directory bug sweep moves to /draft:bughunt. Also syncs pending OKF feature docs and bumps 2.8.3 -> 3.0.0 across package.json, plugin.json, marketplace.json, web, and docs. BREAKING CHANGE: /draft:index is removed. Run /draft:init at the repo root for whole-repo context (graph spine + sparse root map), or inside a sub-module for detailed context linked up to the root graph. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 64742c5 commit 568933a

44 files changed

Lines changed: 983 additions & 2854 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"name": "draft",
1313
"source": "./",
1414
"description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
15-
"version": "2.8.3",
15+
"version": "3.0.0",
1616
"author": {
1717
"name": "mayurpise"
1818
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "draft",
33
"description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
4-
"version": "2.8.3",
4+
"version": "3.0.0",
55
"author": {
66
"name": "mayurpise"
77
},

CHANGELOG.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,51 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [3.0.0] - 2026-06-14
9+
10+
### Added
11+
- **Open Knowledge Format (OKF) emission by default.** The knowledge-graph
12+
snapshot now also writes an [OKF v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)
13+
bundle to `draft/graph/okf/` (`index.md` + cross-linked `modules/<name>.md`
14+
concept pages) via the new `scripts/tools/okf-emit.sh`, on every `/draft:graph`
15+
and `/draft:init` run. A portable, vendor-neutral markdown
16+
mirror of the graph.
17+
- **The whole `draft/` directory is an OKF bundle.** `scripts/tools/okf-bundle.sh`
18+
writes `draft/index.md` (the bundle-root index) cross-linking every concept —
19+
context docs, tracks, and the graph sub-bundle. Project-doc templates
20+
(`architecture.md`, `.ai-context.md`, `.ai-profile.md`, `product.md`,
21+
`tech-stack.md`, `workflow.md`, `guardrails.md`) and track templates
22+
(`spec/plan/hld/lld/discovery/rca`, `tracks.md`) now carry an OKF `type:`
23+
frontmatter field.
24+
- **OKF v0.1 conformance checker.** `scripts/tools/okf-check.sh` validates §9 of
25+
the spec — parseable frontmatter with a non-empty `type` on every concept, and
26+
the reserved-file rules for `index.md`/`log.md`. Wired (advisory) into
27+
`/draft:init`.
28+
- **Scope-aware, root-first code-graph memory.** `/draft:init` is now the single,
29+
scope-aware entry point and builds the whole-repo "code-graph knowledge memory"
30+
first, wherever it is run. New `scripts/tools/graph-init.sh` resolves the repo
31+
ROOT (nearest ancestor with `draft/` → git toplevel → cwd), ensures the
32+
knowledge-graph engine is present (fetching it as a fallback), builds the
33+
committed root snapshot (`draft/graph/`), and — when run inside a sub-module —
34+
builds the module snapshot and writes `draft/graph/root-link.json` pointing up
35+
to the root graph, so any module has full cross-module understanding.
36+
- **`/draft:init --graph-only` and `--module-only` flags.** `--graph-only`
37+
(re)builds just the code-graph memory with no markdown; `--module-only` skips
38+
touching the root (the module→root link is marked `pending`).
39+
40+
### Changed
41+
- **`/draft:init` markdown is scope-asymmetric.** A root init now generates a
42+
sparse, high-level system map that links down to each module's context (no deep
43+
per-module prose); a module init generates the full detailed reference. The
44+
graph layer stays symmetric (root spine + per-module snapshots, linked).
45+
46+
### Removed
47+
- **`/draft:index` is removed — folded into the scope-aware `/draft:init`.**
48+
Monorepo context now comes from running `/draft:init` at the repo root (sparse
49+
root map + whole-repo graph spine) and in each sub-module (detailed context +
50+
`root-link.json`). The multi-directory bug-hunt sweep moved to
51+
`/draft:bughunt` (explicit dir list or auto-discovery). Total surface: 33 skills.
52+
(Web/book references to `/draft:index` will be updated in a follow-up docs pass.)
953

1054
## [2.8.3] - 2026-06-14
1155

CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Repository Overview
66

7-
Draft is a Claude Code plugin that implements Context-Driven Development methodology. It provides a two-tier command surface: 4 primary workflow commands (`/draft:init`, `/draft:new-track`, `/draft:implement`, `/draft:review`) plus 5 routers (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) as the recommended public interface. 25 specialist commands are dispatched underneath the routers. The unified `/draft:jira` router supports `preview`, `create`, and the advanced `review <JIRA-ID>` qualification pipeline (deep-review + bughunt + coverage + test-gap analysis). Run `/draft` for the full intent map. Total surface: 34 skills.
7+
Draft is a Claude Code plugin that implements Context-Driven Development methodology. It provides a two-tier command surface: 4 primary workflow commands (`/draft:init`, `/draft:new-track`, `/draft:implement`, `/draft:review`) plus 5 routers (`/draft:plan`, `/draft:ops`, `/draft:docs`, `/draft:discover`, `/draft:jira`) as the recommended public interface. 24 specialist commands are dispatched underneath the routers. The unified `/draft:jira` router supports `preview`, `create`, and the advanced `review <JIRA-ID>` qualification pipeline (deep-review + bughunt + coverage + test-gap analysis). Run `/draft` for the full intent map. Total surface: 33 skills.
88

9-
Draft also ships a **knowledge graph engine** under `bin/<arch>/` (native Aether binaries) + `scripts/tools/` (14 deterministic shell helpers). Skills are markdown (source of truth, processed by a bash build script into platform-specific integration files for Copilot and Gemini); the graph engine and shell helpers handle mechanical work that markdown can't.
9+
Draft also ships a **knowledge graph engine** under `bin/<arch>/` (native Aether binaries) + `scripts/tools/` (34 deterministic shell helpers). Skills are markdown (source of truth, processed by a bash build script into platform-specific integration files for Copilot and Gemini); the graph engine and shell helpers handle mechanical work that markdown can't.
1010

1111
## Build & Test Commands
1212

1313
```bash
1414
make build # Generate integration files from skills
1515
make build-integrations # Same as above (explicit target)
16-
make test # Run all 25 test suites (skills, build, tools)
16+
make test # Run all 44 test suites (skills, build, tools)
1717
make lint # Run shellcheck + markdownlint
1818
make clean # Remove generated integrations
1919

@@ -47,7 +47,7 @@ core/agents/*.md ──┘
4747
```
4848

4949
The build script (`scripts/build-integrations.sh`) reads `SKILL_ORDER`, `CORE_FILES`, and `TOOLS` from `scripts/lib.sh` (sourced) and:
50-
1. Iterates `SKILL_ORDER` (34 skills in current two-tier model, order matters)
50+
1. Iterates `SKILL_ORDER` (33 skills in current two-tier model, order matters)
5151
2. Validates YAML frontmatter (`name:` and `description:` required)
5252
3. Validates body format: blank, `# Title`, blank, then content
5353
4. Extracts body via `extract_body()`, skipping frontmatter
@@ -68,7 +68,7 @@ The build script (`scripts/build-integrations.sh`) reads `SKILL_ORDER`, `CORE_FI
6868
- **`core/agents/`** — Behavioral protocols for specialized agents (architect, debugger, planner, rca, reviewer, ops, writer)
6969
- **`core/templates/`** — 20 templates for files that `/draft:init` generates in user projects
7070
- **`bin/<arch>/`** — Knowledge graph engine native binaries (from Aether). `bin/<arch>/graph` (+ optional `graph-clang`). Output artifacts under `draft/graph/`. CLI and schema documented in `bin/README.md`. Legacy `graph/bin/` layout supported for transition.
71-
- **`scripts/tools/`**14 deterministic shell helpers (git-metadata, classify-files, hotspot-rank, cycle-detect, etc.). Skills call these for mechanical work.
71+
- **`scripts/tools/`**34 deterministic shell helpers (git-metadata, classify-files, hotspot-rank, cycle-detect, etc.). Skills call these for mechanical work.
7272
- **`scripts/lib.sh`** — Shared definitions sourced by build script: `SKILL_ORDER`, `CORE_FILES`, `TOOLS`.
7373
- **`web/`** — Static website deployed to GitHub Pages (`getdraft.dev`), deployed via `.github/workflows/pages.yml`. Includes the Draft Book (22 chapters + 2 appendices) under `web/book/`.
7474
- **`draft/`** — Dogfooding: Draft's own context files, generated by running `/draft:init` on this repo

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ TEST_SCRIPTS = \
3030
./tests/test-tools-manage-symlinks.sh \
3131
./tests/test-tools-mermaid-from-graph.sh \
3232
./tests/test-tools-graph-snapshot.sh \
33+
./tests/test-tools-graph-init.sh \
3334
./tests/test-tools-okf-emit.sh \
3435
./tests/test-tools-okf-bundle.sh \
3536
./tests/test-tools-okf-check.sh \

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrat
113113

114114
---
115115

116-
## Beyond `/draft:review`33 more commands
116+
## Beyond `/draft:review`32 more commands
117117

118-
`/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 29 more commands covering the full development lifecycle.
118+
`/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 32 more commands covering the full development lifecycle.
119119

120120
---
121121

@@ -187,7 +187,7 @@ The graph powers `/draft:graph` and `/draft:impact`, enriches `/draft:bughunt` a
187187

188188
### Deterministic helper tools
189189

190-
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.
190+
Skills also call into **34 shell helpers** under `scripts/tools/` for mechanical work — git metadata, file classification, test-framework detection, hotspot ranking, freshness checks, ADR indexing, and Open Knowledge Format emission/validation (`okf-emit.sh`, `okf-bundle.sh`, `okf-check.sh`). All emit JSON or markdown, follow a uniform exit-code contract, and degrade gracefully when their input source is unavailable.
191191

192192
---
193193

bin/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ contracts — see `hotspot-rank.sh`, `cycle-detect.sh`, `mermaid-from-graph.sh`,
4444
and `verify-graph-binary.sh`. The shared wrappers (`memory_cli`,
4545
`memory_ensure_index`, `memory_project_for_repo`) live in `_lib.sh`.
4646

47+
## Snapshot artifacts
48+
49+
`scripts/tools/graph-snapshot.sh` writes a small, committed, PR-reviewable snapshot under `<repo>/draft/graph/`:
50+
51+
| Artifact | Content |
52+
|----------|---------|
53+
| `schema.yaml` | Engine + project metadata, node/edge counts, artifact list (gates graph use). |
54+
| `architecture.json` | `get_architecture(all)`: node labels, edge types, languages, packages (fan-in/out), entry points, routes, hotspots. |
55+
| `hotspots.jsonl` | Fan-in-ranked symbols, one JSON object per line. |
56+
| `module-deps.mermaid` | File co-change coupling diagram. |
57+
| `proto-map.mermaid` | Detected service-route diagram. |
58+
| `okf/` | Open Knowledge Format v0.1 bundle (`index.md` + cross-linked `modules/<name>.md`), emitted by default — a portable markdown mirror of the graph. Validate with `okf-check.sh`. |
59+
4760
## Offline / air-gapped distributions
4861

4962
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.

core/methodology.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Draft solves this through **Context-Driven Development**: structured documents t
3030
- [Command Workflows](#command-workflows)
3131
- [/draft:init](#draftinit--initialize-project)
3232
- [/draft:plan](#draftplan--planning-orchestrator)
33-
- [/draft:index](#draftindex--monorepo-service-index)
33+
- [Monorepo Support (via /draft:init)](#monorepo-support-via-draftinit)
3434
- [/draft:new-track](#draftnew-track--create-feature-track)
3535
- [/draft:implement](#draftimplement--execute-tasks)
3636
- [/draft:status](#draftstatus--show-progress)
@@ -405,7 +405,7 @@ Draft auto-classifies the project:
405405
- **Brownfield (existing codebase):** Detected by the presence of `package.json`, `requirements.txt`, `go.mod`, `Cargo.toml`, `src/`, or git history with commits. Draft scans the existing stack and pre-fills `tech-stack.md`.
406406
- **Greenfield (new project):** Empty or near-empty directory. Developer provides all context through dialogue.
407407
- **Mature high-context brownfield:** Projects with strong existing agent-optimized docs (CLAUDE.md, INVARIANTS.md, ADRs, etc.) now receive an early Context Quality Audit, graph fidelity declaration, and explicit Relationship/Gaps sections so the generated architecture.md acts as graph-primary overlay rather than duplicative prose.
408-
- **Monorepo:** Detected by `lerna.json`, `pnpm-workspace.yaml`, `nx.json`, `turbo.json`, or multiple package manifests in child directories. Suggests `/draft:index` instead.
408+
- **Monorepo:** Detected by `lerna.json`, `pnpm-workspace.yaml`, `nx.json`, `turbo.json`, or multiple package manifests in child directories. `/draft:init` is scope-aware — run it at the root for whole-repo context (sparse root map + the code-graph spine), or inside a sub-module to generate detailed module context that links up to the root graph. See **Monorepo Support (via /draft:init)** below.
409409

410410
#### Initialization Sequence
411411

@@ -499,32 +499,31 @@ The parent command should move planning forward rather than listing options.
499499

500500
---
501501

502-
### `/draft:index` — Monorepo Service Index
502+
### Monorepo Support (via `/draft:init`)
503503

504-
Aggregates Draft context from multiple services in a monorepo into unified root-level documents. Designed for organizations with multiple services, each with their own `draft/` context.
504+
There is no separate index command — `/draft:init` is the single, scope-aware entry point. The same command behaves differently by where it is run, so a monorepo needs no special tooling.
505505

506-
#### What It Does
506+
#### Root init (run at the repo root)
507507

508-
1. **Scans** immediate child directories for services (detects `package.json`, `go.mod`, `Cargo.toml`, etc.)
509-
2. **Reads** each service's `draft/product.md`, `draft/.ai-context.md` (or legacy `draft/architecture.md`), `draft/tech-stack.md`
510-
3. **Synthesizes** root-level documents:
508+
1. **Builds the whole-repo code-graph spine**`graph-init.sh` indexes every file at every depth into one unified graph and writes the committed `draft/graph/` snapshot (the structural source of truth).
509+
2. **Generates a sparse root map** (not deep per-module prose), aggregating the children into root-level documents:
511510
- `draft/service-index.md` — Service registry with status, tech, and links
512-
- `draft/dependency-graph.md` — Inter-service dependency topology
511+
- `draft/dependency-graph.md` — Inter-service dependency topology (from the graph)
513512
- `draft/tech-matrix.md` — Technology distribution across services
514-
- `draft/product.md` — Synthesized product vision (if not exists)
515-
- `draft/.ai-context.md` — System-of-systems architecture view
516-
- `draft/tech-stack.md` — Org-wide technology standards
513+
- `draft/architecture.md` — High-level system map linking *down* to each module's `draft/.ai-context.md`
514+
- `draft/.ai-context.md` / `draft/.ai-profile.md` — Condensed system-of-systems views
517515

518-
#### Arguments
516+
#### Module init (run inside a sub-module)
519517

520-
- `init-missing` — Run `/draft:init` on services that lack a `draft/` directory
521-
- `bughunt [dir1 dir2 ...]` — Run `/draft:bughunt` across subdirectories with `draft/` folders. If no directories specified, auto-discovers all subdirectories with `draft/`. Generates summary report at `draft-index-bughunt-summary.md`.
518+
1. **Ensures the root spine exists first** (builds it if missing), then builds the module's own `draft/graph/` snapshot.
519+
2. **Writes `draft/graph/root-link.json`** — a pointer up to the root graph so the module has full cross-module understanding regardless of where init ran.
520+
3. **Generates the detailed module reference** (full 10-section `architecture.md` for the subtree). Use `--module-only` to skip touching the root (link marked `pending`).
522521

523522
#### When to Use
524523

525-
- After running `/draft:init` on individual services
526-
- After adding or removing services from the monorepo
527-
- Periodically to refresh cross-service context
524+
- After cloning or adding a service — run `/draft:init` in it (auto-links to the root spine)
525+
- At the root after services change — refresh the whole-repo graph + sparse root map
526+
- `/draft:init --graph-only` to (re)build just the code-graph knowledge memory, no markdown
528527

529528
---
530529

core/shared/condensation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This is a self-contained, callable procedure for generating `draft/.ai-context.m
1616

1717
Any skill that mutates `architecture.md` should execute this subroutine afterward to keep the derived context files in sync.
1818

19-
**Called by:** `/draft:init`, `/draft:init refresh`, `/draft:implement`, `/draft:decompose`, `/draft:coverage`, `/draft:index`
19+
**Called by:** `/draft:init`, `/draft:init refresh`, `/draft:implement`, `/draft:decompose`, `/draft:coverage`
2020

2121
### Inputs
2222

core/shared/draft-context-loading.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This matrix is the **single source of truth** for which Layer 0.5 files load per
3838

3939
| Command type | Commands | Guardrails loaded |
4040
|---|---|---|
41-
| **Read-only** | `/draft:status`, `/draft:standup`, `/draft:tour`, `/draft:index`, `/draft:coverage` | **none** |
41+
| **Read-only** | `/draft:status`, `/draft:standup`, `/draft:tour`, `/draft:coverage` | **none** |
4242
| **Spec / Plan** | `/draft:new-track`, `/draft:decompose`, `/draft:adr`, `/draft:testing-strategy`, `/draft:documentation` | `design-norms.md` only (architecture-shaped rules) |
4343
| **Code-touching (generation)** | `/draft:implement`, `/draft:debug`, `/draft:change`, `/draft:revert` | `code-quality.md` + `security.md` + `secure-patterns.md` + `language-standards.md` (detected stack) |
4444
| **Review** | `/draft:review`, `/draft:quick-review`, `/draft:deep-review`, `/draft:assist-review`, `/draft:bughunt`, `/draft:tech-debt` | `review-checks.md` + `security.md` + `language-standards.md` (detected stack); deep-review also loads `code-quality.md` + `design-norms.md` |
@@ -75,9 +75,11 @@ If `draft/graph/schema.yaml` exists, the project has automated graph analysis da
7575
| `draft/graph/architecture.json` | Node labels, edge types, languages, packages (fan-in/out), entry points, routes, hotspots | JSON |
7676
| `draft/graph/hotspots.jsonl` | Fan-in-ranked symbols, one object per line: `{id, name, fanIn}` | JSONL |
7777

78+
The snapshot also includes `draft/graph/okf/` — an Open Knowledge Format v0.1 bundle (`index.md` + `modules/*.md`) emitted by default. It is a portable mirror of the graph, not an always-load target.
79+
7880
Note: `.ai-context.md` embeds a condensed graph summary (`GRAPH:MODULES`, `GRAPH:HOTSPOTS`, `GRAPH:CYCLES`) for first-pass structural ground truth. `architecture.json` is authoritative for deep structure.
7981

80-
Note: The canonical embedded mermaid diagrams are in architecture.md injection slots (`<!-- GRAPH:module-deps:START/END -->`, `<!-- GRAPH:proto-map:START/END -->`), refreshed by `draft:index`. For current data, regenerate via `scripts/tools/mermaid-from-graph.sh`.
82+
Note: The canonical embedded mermaid diagrams are in architecture.md injection slots (`<!-- GRAPH:module-deps:START/END -->`, `<!-- GRAPH:proto-map:START/END -->`), refreshed by `draft:init`. For current data, regenerate via `scripts/tools/mermaid-from-graph.sh`.
8183

8284
**Live structural queries** (run on demand — no per-language index files; the engine's model is unified):
8385

0 commit comments

Comments
 (0)