@drafthq/draft 3.0.0 → 3.1.5

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 (47) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +3 -3
  3. package/bin/README.md +4 -7
  4. package/core/shared/condensation.md +8 -8
  5. package/core/shared/draft-context-loading.md +5 -9
  6. package/core/shared/graph-query.md +36 -30
  7. package/core/shared/graph-usage-report.md +1 -1
  8. package/core/shared/pattern-learning.md +2 -2
  9. package/core/shared/red-flags.md +3 -3
  10. package/core/templates/ai-context.md +1 -1
  11. package/core/templates/architecture.md +3 -3
  12. package/integrations/agents/AGENTS.md +165 -142
  13. package/integrations/copilot/.github/copilot-instructions.md +165 -142
  14. package/package.json +1 -1
  15. package/scripts/lib.sh +1 -3
  16. package/scripts/tools/adr-index.sh +2 -2
  17. package/scripts/tools/check-scope-conflicts.sh +2 -2
  18. package/scripts/tools/check-skill-line-caps.sh +2 -2
  19. package/scripts/tools/cycle-detect.sh +5 -1
  20. package/scripts/tools/diff-templates-vs-tracks.sh +2 -2
  21. package/scripts/tools/fix-whitespace.sh +15 -9
  22. package/scripts/tools/graph-arch.sh +72 -0
  23. package/scripts/tools/graph-impact.sh +1 -0
  24. package/scripts/tools/graph-init.sh +3 -3
  25. package/scripts/tools/graph-snapshot.sh +52 -51
  26. package/scripts/tools/hotspot-rank.sh +2 -0
  27. package/scripts/tools/manage-symlinks.sh +1 -1
  28. package/scripts/tools/parse-reports.sh +1 -1
  29. package/scripts/tools/verify-doc-anchors.sh +2 -2
  30. package/scripts/tools/verify-graph-binary.sh +1 -1
  31. package/skills/GRAPH.md +2 -2
  32. package/skills/bughunt/SKILL.md +1 -1
  33. package/skills/debug/SKILL.md +3 -3
  34. package/skills/decompose/SKILL.md +5 -5
  35. package/skills/deep-review/SKILL.md +2 -2
  36. package/skills/deploy-checklist/SKILL.md +2 -2
  37. package/skills/graph/SKILL.md +1 -1
  38. package/skills/implement/SKILL.md +1 -1
  39. package/skills/init/SKILL.md +62 -42
  40. package/skills/init/references/architecture-spec.md +12 -11
  41. package/skills/learn/SKILL.md +5 -5
  42. package/skills/quick-review/SKILL.md +3 -3
  43. package/skills/review/SKILL.md +7 -7
  44. package/skills/tech-debt/SKILL.md +2 -2
  45. package/scripts/tools/okf-bundle.sh +0 -141
  46. package/scripts/tools/okf-check.sh +0 -137
  47. package/scripts/tools/okf-emit.sh +0 -161
@@ -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.0.0",
4
+ "version": "3.1.5",
5
5
  "author": {
6
6
  "name": "mayurpise"
7
7
  },
package/README.md CHANGED
@@ -129,7 +129,7 @@ curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrat
129
129
  | **`/draft:docs`** | Router for authoring and documentation workflows |
130
130
  | **`/draft:discover`** | Router for discovery, debugging, investigation, and quality |
131
131
  | **`/draft:init`** | Analyze codebase, create context files + state tracking |
132
- | **`/draft:index`** | Aggregate monorepo service contexts |
132
+ | **`/draft:graph`** | Build / refresh the knowledge-graph snapshot |
133
133
  | **`/draft:new-track`** | Collaborative spec + plan with AI |
134
134
  | **`/draft:decompose`** | Module decomposition with dependency mapping |
135
135
  | **`/draft:implement`** | TDD workflow with checkpoints |
@@ -187,7 +187,7 @@ The graph powers `/draft:graph` and `/draft:impact`, enriches `/draft:bughunt` a
187
187
 
188
188
  ### Deterministic helper tools
189
189
 
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.
190
+ Skills also call into **shell helpers** under `scripts/tools/` for mechanical work — git metadata, file classification, test-framework detection, hotspot ranking, freshness checks, ADR indexing, and live graph queries (`graph-callers.sh`, `graph-impact.sh`, `hotspot-rank.sh`, `cycle-detect.sh`, `mermaid-from-graph.sh`). All emit JSON or markdown, follow a uniform exit-code contract, and degrade gracefully when their input source is unavailable.
191
191
 
192
192
  ---
193
193
 
@@ -234,7 +234,7 @@ AI tools are fast but unstructured. Draft applies Context-Driven Development to
234
234
  ```
235
235
  product.md → "Build a task manager"
236
236
  tech-stack.md → "React, TypeScript, Tailwind"
237
- 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).
237
+ architecture.md → Comprehensive: 10-section graph-primary engineering reference, 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).
238
238
  .ai-context.md → 200-400 lines: condensed from architecture.md (token-optimized AI context)
239
239
  .state/ → freshness hashes, signal classification, run memory (incremental refresh)
240
240
  spec.md → "Add drag-and-drop reordering"
package/bin/README.md CHANGED
@@ -46,16 +46,13 @@ and `verify-graph-binary.sh`. The shared wrappers (`memory_cli`,
46
46
 
47
47
  ## Snapshot artifacts
48
48
 
49
- `scripts/tools/graph-snapshot.sh` writes a small, committed, PR-reviewable snapshot under `<repo>/draft/graph/`:
49
+ `draft/graph/` holds a single committed file:
50
50
 
51
51
  | Artifact | Content |
52
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`. |
53
+ | `schema.yaml` | Engine + project metadata, node/edge counts, point-of-index counts (gates graph use). |
54
+
55
+ Structural graph data (architecture, hotspots, module deps, service routes) is queried **live** from the `codebase-memory-mcp` engine — either via the wrapper scripts under `scripts/tools/` (`graph-callers.sh`, `graph-impact.sh`, `hotspot-rank.sh`, `cycle-detect.sh`, `mermaid-from-graph.sh`) or directly with `codebase-memory-mcp cli <tool> '<json>'`.
59
56
 
60
57
  ## Offline / air-gapped distributions
61
58
 
@@ -88,16 +88,16 @@ Transform each `architecture.md` section into machine-optimized format using thi
88
88
 
89
89
  #### Step 3.5: Generate Graph Summary Sections
90
90
 
91
- If `draft/graph/schema.yaml` exists, generate these sections from the snapshot (`draft/graph/architecture.json`, `draft/graph/hotspots.jsonl`) and the live query tools:
91
+ If `draft/graph/schema.yaml` exists, generate these sections via live engine queries.
92
92
 
93
93
  **GRAPH:MODULES** (tier ≥ 2 only):
94
- - Read `draft/graph/architecture.json` `.packages[]` (each has `name`, `node_count`, `fan_in`, `fan_out`)
94
+ - Query: `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'` (each has `name`, `node_count`, `fan_in`, `fan_out`)
95
95
  - Format: `{name}|{node_count} nodes|fan_in:{fan_in} fan_out:{fan_out}`
96
96
  - Order by `node_count` descending
97
97
  - Omit this section entirely for tier-1 codebases (≤5 modules) where Component Graph is sufficient
98
98
 
99
99
  **GRAPH:HOTSPOTS** (all tiers):
100
- - Read `draft/graph/hotspots.jsonl` (already fan-in-ranked), take top 10
100
+ - Query: `scripts/tools/hotspot-rank.sh --repo . --top 10`; take top 10 results
101
101
  - Format: `{name}|fanIn:{fanIn}` (use `id` for disambiguation when names collide)
102
102
  - Always include regardless of tier
103
103
 
@@ -108,20 +108,20 @@ If `draft/graph/schema.yaml` exists, generate these sections from the snapshot (
108
108
  - Always include — absence is positive signal that the call graph is acyclic
109
109
 
110
110
  **GRAPH:MODULE-HOTSPOTS** (tier ≥ 3 only):
111
- - Read `draft/graph/hotspots.jsonl`; group by the package segment of each `id` (the qualified name minus the leaf symbol)
111
+ - Query: `scripts/tools/hotspot-rank.sh --repo .`; group results by the package segment of each `id` (the qualified name minus the leaf symbol)
112
112
  - For each module: take its top 3 symbols by `fanIn`, format as indented lines under the module name
113
113
  - Format: `{module}: {name}|fanIn:{N}` with subsequent symbols indented to align
114
114
  - Order modules by their highest-fanIn symbol, descending
115
115
  - Omit modules with no hotspot entries; omit entire section for tier 1–2 (covered by global GRAPH:HOTSPOTS)
116
116
 
117
117
  **GRAPH:FAN-IN** (tier ≥ 3 only):
118
- - Read `architecture.json` `.packages[]`, use the `fan_in` field per module
118
+ - Query: `scripts/tools/graph-arch.sh --repo . | jq '.packages[]'`, use the `fan_in` field per module
119
119
  - Format: `{name}|fanIn:{fan_in}|fanOut:{fan_out}`
120
120
  - Order by `fan_in` descending; include only modules with `fan_in ≥ 2`; cap at 15 rows
121
121
  - Omit entire section for tier 1–2 (trivially small graph)
122
122
 
123
- **GRAPH:PROTO-MAP** (only when `architecture.json` `.routes` is non-empty):
124
- - Read `architecture.json` `.routes[]` (each has `method`, `path`, `handler`)
123
+ **GRAPH:PROTO-MAP** (only when routes are non-empty):
124
+ - Query: `scripts/tools/graph-arch.sh --repo . | jq '.routes[]'` (each has `method`, `path`, `handler`)
125
125
  - Format: `{method} {path} → {handler}`
126
126
  - One line per route
127
127
  - Omit entire section if `.routes` is empty — do not write an empty section
@@ -168,7 +168,7 @@ Before writing `draft/.ai-context.md`, verify:
168
168
  - [ ] GRAPH:CYCLES present ("None ✓" or cycle list; or note if graph absent)
169
169
  - [ ] GRAPH:MODULE-HOTSPOTS present for tier ≥ 3 (or note if no hotspot data)
170
170
  - [ ] GRAPH:FAN-IN present for tier ≥ 3
171
- - [ ] GRAPH:PROTO-MAP present when `stats.proto_rpcs > 0` (omit entirely if no protos)
171
+ - [ ] GRAPH:PROTO-MAP present when engine reports non-empty routes (omit entirely if no protos)
172
172
  - [ ] YAML frontmatter metadata is present at the top
173
173
 
174
174
  #### Step 7: Write Output
@@ -71,13 +71,9 @@ If `draft/graph/schema.yaml` exists, the project has automated graph analysis da
71
71
 
72
72
  | File | Purpose | Content |
73
73
  |------|---------|---------|
74
- | `draft/graph/schema.yaml` | Snapshot metadata (engine, project, node/edge counts) | YAML, ~15 lines |
75
- | `draft/graph/architecture.json` | Node labels, edge types, languages, packages (fan-in/out), entry points, routes, hotspots | JSON |
76
- | `draft/graph/hotspots.jsonl` | Fan-in-ranked symbols, one object per line: `{id, name, fanIn}` | JSONL |
74
+ | `draft/graph/schema.yaml` | Gate marker (engine + project metadata + point-of-index counts); presence gates graph use | YAML, ~15 lines |
77
75
 
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
-
80
- 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.
76
+ Note: `.ai-context.md` embeds a condensed graph summary (`GRAPH:MODULES`, `GRAPH:HOTSPOTS`, `GRAPH:CYCLES`) for first-pass structural ground truth. Deep structural data is queried live from the engine (see Live structural queries below).
81
77
 
82
78
  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`.
83
79
 
@@ -151,12 +147,12 @@ Do NOT apply relevance scoring for commands that need full context (`/draft:init
151
147
  | `## FILES` | Always (need file locations) |
152
148
  | `## VOCAB` | Domain-specific tasks |
153
149
 
154
- 3. **Score graph files** (if `draft/graph/` exists) against the task concepts:
150
+ 3. **Score graph queries** (if `draft/graph/schema.yaml` exists) against the task concepts:
155
151
 
156
152
  | Graph source | Use When Task Involves... |
157
153
  |------------|--------------------------|
158
- | `architecture.json` | Module boundary changes, cross-module work, architecture analysis, API/route surface |
159
- | `hotspots.jsonl` | Performance work, refactoring, changes to high-fanIn symbols |
154
+ | `scripts/tools/graph-arch.sh --repo .` | Module boundary changes, cross-module work, architecture analysis, API/route surface |
155
+ | `scripts/tools/hotspot-rank.sh --repo .` | Performance work, refactoring, changes to high-fanIn symbols |
160
156
  | `scripts/tools/graph-callers.sh --symbol <name>` | Enumerating callers before a change |
161
157
  | `scripts/tools/graph-impact.sh --file <path>` / `--symbol <name>` | Tracing call paths, root cause analysis, function-level impact |
162
158
  | `scripts/tools/cycle-detect.sh` | Checking for call cycles |
@@ -10,7 +10,7 @@ Referenced by: `/draft:init`, `/draft:implement`, `/draft:bughunt`, `/draft:revi
10
10
 
11
11
  Any code-touching skill that needs to discover files, modules, symbols, callers, or blast-radius **MUST** follow this lookup order whenever `draft/graph/schema.yaml` exists:
12
12
 
13
- 1. **Graph first** — the committed snapshot (`architecture.json`, `hotspots.jsonl`) and the live query tools (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, `cycle-detect.sh`, `hotspot-rank.sh`).
13
+ 1. **Graph first** — live engine queries via the query tools (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, `cycle-detect.sh`, `hotspot-rank.sh`, `mermaid-from-graph.sh`), which drive the local `codebase-memory-mcp` engine on demand. Draft is **engine-only**: there is no committed machine-readable graph to read — `draft/graph/` holds only `schema.yaml` (the gate marker).
14
14
  2. **Generated context second** — `draft/.ai-context.md`, relevant `draft/architecture.md` slices, track-level `hld.md`/`lld.md`.
15
15
  3. **Source file reads third** — narrow via tiers 1–2, then **Read** the candidate files. Reading is **not optional**: see §Ground-Truth Discipline below.
16
16
  4. **Filesystem `grep`/`find`/`rg` last** — only after an explicit graph miss.
@@ -55,10 +55,10 @@ A single "no" / "list" answer is a halt — fix and re-check before output.
55
55
 
56
56
  Use this recipe whenever the user names a concept, feature, or domain term ("in-memory shuffle", "auth flow", "ingest pipeline") and you need to locate the implementing files. **Run it before any filesystem search.**
57
57
 
58
- 1. **Concept → modules** — `grep` the concept token against `draft/graph/architecture.json` (`.packages[].name`) and `draft/.ai-context.md` (module headings). Record the candidate module list.
58
+ 1. **Concept → modules** — query the engine for the package list (`scripts/tools/graph-arch.sh --repo . | jq -r '.packages[].name'`) and cross-reference `draft/.ai-context.md` (module headings). Record the candidate module list.
59
59
  2. **Concept → symbols/callers** — for a named function, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to find call sites, and `scripts/tools/graph-impact.sh --repo . --symbol <name>` for transitive dependents. These are the authoritative structural answers.
60
- 3. **Modules → risk ranking** — cross-reference `draft/graph/hotspots.jsonl` (or `scripts/tools/hotspot-rank.sh`). High-fanIn symbols are the most likely entry points for impact.
61
- 4. **Concept → public API** — for API-shaped concepts, consult `architecture.json` `.routes` (detected HTTP/gRPC/GraphQL routes) for matching service surface.
60
+ 3. **Modules → risk ranking** — rank with `scripts/tools/hotspot-rank.sh --repo . [--top N]`. High-fanIn symbols are the most likely entry points for impact.
61
+ 4. **Concept → public API** — for API-shaped concepts, read the engine's `.routes` (`get_architecture` output, detected HTTP/gRPC/GraphQL routes) for matching service surface.
62
62
  5. **Graph miss → grep fallback** — only if steps 1–4 return nothing relevant, emit the fallback sentence and use `grep`/`find`. Narrow the search by file extension and exclude `node_modules`, `vendor`, `dist`, `build`, `.git`.
63
63
 
64
64
  ## Graph Usage Report (Mandatory Footer)
@@ -68,7 +68,7 @@ Every code-touching skill output MUST end with this footer block. The lint check
68
68
  ```md
69
69
  ## Graph Usage Report
70
70
 
71
- - Graph files queried: <comma-separated list, e.g. `architecture.json, hotspots.jsonl` and/or query tools like `graph-callers.sh` — or `NONE` with justification below>
71
+ - Graph files queried: <comma-separated list of query tools invoked, e.g. `graph-callers.sh, hotspot-rank.sh` — or `NONE` with justification below>
72
72
  - Modules identified via graph: <comma-separated module names, or `none`>
73
73
  - Files identified via graph: <integer count>
74
74
  - Filesystem grep fallbacks: <list of `<pattern>` searches with one-line justification each, or `none`>
@@ -106,7 +106,7 @@ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
106
106
  | `bash "$DRAFT_TOOLS/cycle-detect.sh"` | `--mode cycles` | Emits `{cycles:[],source:"unavailable"}` and exits 2 |
107
107
  | `bash "$DRAFT_TOOLS/mermaid-from-graph.sh" [--diagram module-deps\|proto-map]` | `--mode mermaid` | Emits an empty mermaid block and exits 2 |
108
108
 
109
- Use the raw `graph` CLI directly for the lower-level modes documented below.
109
+ For lower-level modes, call the engine directly: `codebase-memory-mcp cli <tool> '<json>'` (see the tool list in [bin/README.md](../../bin/README.md)).
110
110
 
111
111
  ## Pre-Check
112
112
 
@@ -118,27 +118,26 @@ ls draft/graph/schema.yaml 2>/dev/null
118
118
 
119
119
  If absent, **skip all graph operations silently**. Graph enriches analysis — it never gates it. All skills must work identically without graph data.
120
120
 
121
- ## Engine + snapshot model
121
+ ## Engine model (engine-only)
122
122
 
123
- The graph is produced by the **codebase-memory-mcp** engine (a single binary; see [bin/README.md](../../bin/README.md)). There are two ways skills consume it:
123
+ The graph is produced by the **codebase-memory-mcp** engine (a single binary; see [bin/README.md](../../bin/README.md)). Draft is **engine-only and opinionated**: the engine is the one structural source of truth, queried live. There is **no committed machine-readable mirror** of the graph — no `architecture.json`, `hotspots.jsonl`, `*.mermaid`, or `okf/`. Those were lossy, went stale on the next commit, and duplicated what the engine serves precisely on demand.
124
124
 
125
- 1. **Live queries** (preferred when the engine is resolvable) — the shell tools under `scripts/tools/` drive the engine on demand (it auto-indexes into its own cache). No committed files required.
126
- 2. **Committed snapshot** (`draft/graph/`) — a small, derived, PR-reviewable snapshot written by `scripts/tools/graph-snapshot.sh`. It exists for reviewability and for the Copilot/Gemini integrations, which cannot run the engine but can read committed files. Git remains the source of truth.
125
+ The only committed file is the gate marker:
127
126
 
128
- When `draft/graph/` exists, the snapshot contains:
127
+ | File | Role |
128
+ |------|------|
129
+ | `draft/graph/schema.yaml` | Engine + project metadata and point-of-index counts (provenance, not authoritative). Carries **no graph data**. Its presence is the **gate** (see Pre-Check) — it signals the engine is wired for this repo. Written by `scripts/tools/graph-snapshot.sh`. |
129
130
 
130
- | File | Load | Content |
131
- |------|------|---------|
132
- | `schema.yaml` | Always | Engine + project metadata, node/edge counts, artifact list. Its presence **gates** graph use (see Pre-Check). |
133
- | `architecture.json` | Always | `get_architecture(all)` output: node labels, edge types, languages, packages (with fan-in/out), entry points, routes, hotspots. |
134
- | `hotspots.jsonl` | Always | Fan-in-ranked symbols, one JSON object per line: `{id, name, fanIn}`. |
135
- | `module-deps.mermaid` | Diagram injection | File co-change coupling diagram (`FILE_CHANGES_WITH`). |
136
- | `proto-map.mermaid` | Diagram injection | Detected service-route diagram (`Route` nodes). |
137
- | `okf/` | On demand | Open Knowledge Format v0.1 bundle (emitted by default): `index.md` (reserved bundle root, no frontmatter) + cross-linked `modules/<name>.md` concept pages. Portable, vendor-neutral mirror of the graph; validate with `okf-check.sh`. |
131
+ All structural data is obtained live by shelling out to the engine — either through the query-tool wrappers under `scripts/tools/` or directly via `codebase-memory-mcp cli <tool> '<json>'`. The shell tools auto-index the repo into the engine's own cache on demand, so no committed files are required.
138
132
 
139
- The engine uses a **unified, language-agnostic** node model — `Function`, `Method`, `Class`, `Module`, `File`, `Folder`, `Route`, `Section`, `Variable` (language is inferred from file extension) — and edges `CALLS`, `DEFINES`, `CONTAINS_FILE`, `IMPORTS`, `HTTP_CALLS`, `FILE_CHANGES_WITH`, `SEMANTICALLY_RELATED`, `SIMILAR_TO`. There are **no** per-language index files and no `ctags-sym` fallback; that detail is served by live queries against the unified model.
133
+ ### How skills query (engine is the interface; jq is optional)
140
134
 
141
- **Always-load files** are compact and should be read during context loading for any task that touches code structure.
135
+ - **The engine is the query.** `codebase-memory-mcp cli <tool> '<json>'` (and the wrappers that call it) is how you ask it takes JSON args and returns JSON. There is no other query surface.
136
+ - **Prefer the wrappers — they resolve the engine for you.** `graph-arch.sh` (architecture view: packages/routes/layers/hotspots), `graph-callers.sh`, `hotspot-rank.sh`, `graph-impact.sh`, `cycle-detect.sh`, `mermaid-from-graph.sh` return already-shaped JSON. The engine binary is usually **not on `$PATH`** (it lives under `~/.cache/draft/bin/`); the wrappers locate it via `_lib.sh:find_memory_bin`, so a skill using a wrapper needs no resolution step.
137
+ - **Raw `codebase-memory-mcp cli` requires resolving the binary first** (it is not on `$PATH`): `CM="${DRAFT_MEMORY_BIN:-$HOME/.cache/draft/bin/codebase-memory-mcp}"; "$CM" cli <tool> '<json>'`. Reach for this only for tools without a wrapper (`search_graph`, `search_code`, `trace_path`).
138
+ - **`jq` is not a query tool — it only trims output.** Reach for it solely to slice a *large* response (chiefly the `get_architecture` blob) down to the field you need, for token economy. The agent can read raw JSON directly; jq is an optimization, not a requirement. Don't pipe wrapper output through jq unless you genuinely need a sub-field.
139
+
140
+ The engine uses a **unified, language-agnostic** node model — `Function`, `Method`, `Class`, `Module`, `File`, `Folder`, `Route`, `Section`, `Variable` (language is inferred from file extension) — and edges `CALLS`, `DEFINES`, `CONTAINS_FILE`, `IMPORTS`, `HTTP_CALLS`, `FILE_CHANGES_WITH`, `SEMANTICALLY_RELATED`, `SIMILAR_TO`. Each node carries `file_path` + `start_line`/`end_line` and rich `properties` (complexity, signature, parent_class), and the engine exposes full-text (`search_code`) and semantic search — none of which a committed snapshot reproduced.
142
141
 
143
142
  ## Query Tools
144
143
 
@@ -179,7 +178,14 @@ Output: `{cycles[[a,b],[a,b,c]], source}` — fixed-length 2- and 3-node `CALLS`
179
178
 
180
179
  ### Modules — dependency overview
181
180
 
182
- Read `draft/graph/architecture.json` (`.packages` for module fan-in/out, `.node_labels`/`.edge_types` for shape, `.routes` for service surface), or regenerate it with `scripts/tools/graph-snapshot.sh --repo .`.
181
+ 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):
182
+
183
+ ```bash
184
+ scripts/tools/graph-arch.sh --repo . \
185
+ | jq '{packages, node_labels, edge_types, routes, layers, boundaries}'
186
+ ```
187
+
188
+ `.packages` gives module fan-in/out, `.node_labels`/`.edge_types` the shape, `.routes` the service surface, `.layers`/`.boundaries` the dependency direction.
183
189
 
184
190
  ### Mermaid — diagram text
185
191
 
@@ -188,15 +194,15 @@ scripts/tools/mermaid-from-graph.sh --repo . --diagram module-deps # co-change
188
194
  scripts/tools/mermaid-from-graph.sh --repo . --diagram proto-map # detected routes
189
195
  ```
190
196
 
191
- Emits a ready-to-inject ` ```mermaid ``` ` block, or an empty stub (exit 2) when the engine is unavailable. The committed `draft/graph/*.mermaid` snapshots are written by `graph-snapshot.sh`.
197
+ 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.
192
198
 
193
- ### Building / refreshing the snapshot
199
+ ### Indexing / refreshing the gate marker
194
200
 
195
201
  ```bash
196
202
  scripts/tools/graph-snapshot.sh --repo .
197
203
  ```
198
204
 
199
- Writes the committed `draft/graph/` snapshot (`schema.yaml`, `architecture.json`, `hotspots.jsonl`, `*.mermaid`, plus the Open Knowledge Format bundle under `okf/`). Run during `/draft:init` and `/draft:graph`, or whenever the reviewable graph state should be refreshed.
205
+ Indexes the repo into the engine and writes the `draft/graph/schema.yaml` gate marker. It writes **no** graph data. Run during `/draft:init` and `/draft:graph`, or whenever the index should be refreshed.
200
206
 
201
207
  ## Finding the Engine (Resolution + Usage Report)
202
208
 
@@ -220,7 +226,7 @@ ENGINE_INFO="$(scripts/tools/verify-graph-binary.sh --repo . --json 2>/dev/null
220
226
 
221
227
  After successful detection, `draft/.graph-binary-report.json` contains: `detected_at`, `engine_bin`, `source` (`path` | `managed` | `bundled:<arch>` | `override`), `arch`, `status`. It is a derived artifact (safe to prune), regenerated by each graph-using command that calls the verifier.
222
228
 
223
- ## Building the Snapshot
229
+ ## Indexing the Repo
224
230
 
225
231
  Run during `draft:init` / `draft:graph`, or manually:
226
232
 
@@ -228,13 +234,13 @@ Run during `draft:init` / `draft:graph`, or manually:
228
234
  scripts/tools/graph-snapshot.sh --repo .
229
235
  ```
230
236
 
231
- 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); the snapshot is re-derived on each run.
237
+ 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.
232
238
 
233
239
  ## Graceful Degradation
234
240
 
235
241
  | Scenario | Behavior |
236
242
  |----------|----------|
237
- | No engine resolvable (or `DRAFT_MEMORY_DISABLE=1`) | Skip graph build in init; all skills proceed without graph data; tools emit `source: unavailable` |
243
+ | No engine resolvable (or `DRAFT_MEMORY_DISABLE=1`) | Skip graph indexing in init; all skills proceed without graph data; tools emit `source: unavailable` |
238
244
  | Engine present but a query fails | Warn and proceed; skills work without graph data |
239
- | `draft/graph/` snapshot exists | Load always-load files during context loading; use live query tools as needed |
240
- | Stale snapshot | Still useful structural changes are infrequent. Re-run `graph-snapshot.sh` (or init) to refresh. |
245
+ | `draft/graph/schema.yaml` exists | Engine is wired use live query tools as needed during the run |
246
+ | Engine index out of date | The engine indexes incrementally (content-based, git-aware) on each query, so it self-freshens. Re-run `graph-snapshot.sh` (or init) to force a reindex and refresh the marker. |
@@ -12,7 +12,7 @@ See [graph-query.md](graph-query.md) §Graph Usage Report (Mandatory Footer) for
12
12
  ```md
13
13
  ## Graph Usage Report
14
14
 
15
- - Graph files queried: <comma-separated list, e.g. `architecture.json, hotspots.jsonl` and/or query tools like `graph-callers.sh` — or `NONE` with justification below>
15
+ - Graph files queried: <comma-separated list, e.g. `get_architecture, hotspot-rank.sh` and/or query tools like `graph-callers.sh` — or `NONE` with justification below>
16
16
  - Modules identified via graph: <comma-separated module names, or `none`>
17
17
  - Files identified via graph: <integer count>
18
18
  - Filesystem grep fallbacks: <list of `<pattern>` searches with one-line justification each, or `none`>
@@ -109,11 +109,11 @@ Append under `## Learned Anti-Patterns`:
109
109
  - **Suggested fix:** [Brief description of the correct approach]
110
110
  ```
111
111
 
112
- `graph_severity` derivation rules (from `draft/graph/hotspots.jsonl` fanIn values):
112
+ `graph_severity` derivation rules (from live hotspot query `scripts/tools/hotspot-rank.sh --repo .` fanIn values):
113
113
  - fanIn ≥ 10 in any evidence file → `critical`
114
114
  - fanIn 5–9 → `high`
115
115
  - fanIn 1–4 → `medium`
116
- - fanIn 0 or file not in hotspots.jsonl → `low`
116
+ - fanIn 0 or file not returned by hotspot query → `low`
117
117
  - Graph data absent → `unresolved`
118
118
 
119
119
  When `graph_severity` differs from `severity`, use `graph_severity` as the enforcement priority — it is objective and graph-derived.
@@ -12,7 +12,7 @@ Referenced by: `/draft:decompose`, `/draft:implement`, `/draft:review`, `/draft:
12
12
  ## Universal Red Flags (STOP if any apply)
13
13
 
14
14
  - **Ran `grep`/`find`/`rg` for symbol or file discovery before consulting the graph** (when `draft/graph/schema.yaml` exists).
15
- - **Read more than 50 lines of source before consulting `draft/graph/hotspots.jsonl`** to know whether the file is a hotspot.
15
+ - **Read more than 50 lines of source before querying hotspot rank** (`scripts/tools/hotspot-rank.sh --repo .`) to know whether the file is a hotspot.
16
16
  - **Omitted the Graph Usage Report footer** from the final output (see [graph-query.md](graph-query.md) §Mandatory Lookup Contract).
17
17
  - **Used a `grep` fallback without an explicit graph-miss statement** in the form: `Graph returned no match for <X>; falling back to grep.`
18
18
  - **Loaded full Layer 0.5 guardrails when the command type does not require them** (see selective-loading matrix in [draft-context-loading.md](draft-context-loading.md) §Layer 0.5).
@@ -24,7 +24,7 @@ Referenced by: `/draft:decompose`, `/draft:implement`, `/draft:review`, `/draft:
24
24
  These enforce [graph-query.md](graph-query.md) §Ground-Truth Discipline. Graph identifies candidates; Read confirms them. Shipping unread claims is the dominant correctness failure mode observed in Draft output.
25
25
 
26
26
  - **Wrote a `path:line` / `func()` / `symbol` reference into a deliverable without opening the file in this run.** Graph hit ≠ Read. (G1)
27
- - **Declared something in-scope or out-of-scope without Reading at least one file in that path.** Module names from `architecture.json` are a candidate set, not proof that the candidate contains the named cost. (G2)
27
+ - **Declared something in-scope or out-of-scope without Reading at least one file in that path.** Module names from the live engine (`get_architecture`) are a candidate set, not proof that the candidate contains the named cost. (G2)
28
28
  - **Shipped `Citation: TBD` / `Path: TBD` / `Symbol: TBD` on a row whose Status is `Modified` or `Existing`.** TBD is reserved for `Status: New` rows with a planned path filled in. (G3)
29
29
  - **Claimed code behavior (writes / blocks / loops / fails / is the only path) from graph metadata alone.** Fan-in / fan-out / complexity scores are necessary signal, not sufficient evidence. (G4)
30
30
  - **Promoted a spec / generated an HLD or LLD / closed a review without checking that the in-scope file set covers every cost term in the problem statement.** Silent scope narrowing that excludes the named cost is the highest-impact failure class. (G5)
@@ -34,7 +34,7 @@ When in doubt, prefer "not yet validated against source" over an unbacked assert
34
34
 
35
35
  ## Graph-First Lookup Order (non-negotiable)
36
36
 
37
- 1. **Graph first** — the committed snapshot (`draft/graph/architecture.json`, `draft/graph/hotspots.jsonl`) and the live query tools (`scripts/tools/graph-callers.sh`, `graph-impact.sh`, `cycle-detect.sh`, `hotspot-rank.sh`).
37
+ 1. **Graph first** — wrapper scripts (`scripts/tools/graph-arch.sh`, `graph-callers.sh`, `graph-impact.sh`, `cycle-detect.sh`, `hotspot-rank.sh`) and direct engine queries (`search_graph`, `search_code`). The gate marker `draft/graph/schema.yaml` (present = engine available) is the only committed graph file.
38
38
  2. **Generated context second** — `draft/.ai-context.md`, relevant `draft/architecture.md` slices, track-level `hld.md`/`lld.md`.
39
39
  3. **Source file reads third** — only narrowed targets identified via graph or generated context.
40
40
  4. **Filesystem `grep`/`find` last** — only after a graph miss, with the explicit fallback sentence above.
@@ -49,7 +49,7 @@ generated_at: "{ISO_TIMESTAMP}"
49
49
  ```
50
50
 
51
51
  > Include immediate sub-directories for all major modules (not just top-level).
52
- > Use graph data (`draft/graph/modules/*.jsonl`) for exhaustive sub-module enumeration.
52
+ > Use live engine queries (`get_architecture .packages[]` or `graph-callers.sh`) for exhaustive sub-module enumeration.
53
53
  > Show file counts per sub-module to indicate relative size/importance.
54
54
 
55
55
  ## GRAPH:MODULES
@@ -30,9 +30,9 @@ graph:
30
30
  go: "{approximate | high}"
31
31
  stats:
32
32
  modules: "{N from schema.yaml}"
33
- edges: "{total_edges from architecture.json}"
33
+ edges: "{total_edges from engine: get_architecture .edges}"
34
34
  hotspots: "{N}"
35
- notes: "{explicit fidelity summary from architecture.json languages/packages}"
35
+ notes: "{explicit fidelity summary from engine: get_architecture .languages/.packages}"
36
36
  generation_notes: "{High existing context detected via audit — see §10 Relationship for deference | Standard graph-primary generation}"
37
37
  ---
38
38
 
@@ -114,7 +114,7 @@ Each backed by:
114
114
 
115
115
  ## 4. Module & Dependency Map (Primarily Graph-Derived)
116
116
 
117
- - Module dependency graph rendered from `draft/graph/architecture.json` (`.packages`) + `module-deps.mermaid`
117
+ - Module dependency graph rendered from live engine query `scripts/tools/graph-arch.sh --repo . | jq '.packages'` + `scripts/tools/mermaid-from-graph.sh --repo . --diagram module-deps` (generated live, never committed)
118
118
  - High fan-in / fan-out modules highlighted
119
119
  - Cyclic dependencies called out
120
120
  - Cross-language boundaries (FFI, RPC, shared memory) explicitly surfaced with coverage notes