@drafthq/draft 3.5.3 → 3.7.1

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 (143) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/hosts/cursor.js +3 -0
  7. package/cli/src/installer.js +8 -4
  8. package/cli/src/lib/cursor-registry.js +10 -0
  9. package/cli/src/lib/fsx.js +3 -0
  10. package/cli/src/lib/marker.js +8 -3
  11. package/core/agents/architect.md +21 -9
  12. package/core/agents/debugger.md +5 -0
  13. package/core/agents/ops.md +7 -2
  14. package/core/agents/planner.md +7 -0
  15. package/core/agents/rca.md +14 -3
  16. package/core/agents/reviewer.md +1 -0
  17. package/core/agents/writer.md +6 -0
  18. package/core/knowledge-base.md +22 -3
  19. package/core/methodology.md +30 -5
  20. package/core/shared/condensation.md +28 -18
  21. package/core/shared/context-verify.md +3 -1
  22. package/core/shared/cross-skill-dispatch.md +7 -3
  23. package/core/shared/draft-context-loading.md +3 -0
  24. package/core/shared/git-report-metadata.md +2 -1
  25. package/core/shared/graph-query.md +24 -26
  26. package/core/shared/graph-usage-report.md +1 -1
  27. package/core/shared/jira-sync.md +10 -6
  28. package/core/shared/okf-retrieval.md +1 -1
  29. package/core/shared/parallel-analysis.md +14 -7
  30. package/core/shared/pattern-learning.md +2 -0
  31. package/core/shared/template-contract.md +1 -1
  32. package/core/shared/tool-resolver.md +20 -15
  33. package/core/shared/vcs-commands.md +5 -2
  34. package/core/templates/ai-context.md +3 -2
  35. package/core/templates/ai-profile.md +7 -0
  36. package/core/templates/architecture.md +6 -2
  37. package/core/templates/discovery.md +1 -1
  38. package/core/templates/guardrails.md +9 -0
  39. package/core/templates/hld.md +5 -4
  40. package/core/templates/intake-questions.md +45 -0
  41. package/core/templates/jira.md +11 -2
  42. package/core/templates/lld.md +8 -5
  43. package/core/templates/okf/concept.md +0 -1
  44. package/core/templates/plan.md +1 -1
  45. package/core/templates/product.md +11 -2
  46. package/core/templates/rca.md +6 -0
  47. package/core/templates/service-index.md +1 -0
  48. package/core/templates/spec.md +15 -0
  49. package/core/templates/tech-stack.md +12 -0
  50. package/core/templates/workflow.md +20 -0
  51. package/integrations/agents/AGENTS.md +1449 -817
  52. package/integrations/copilot/.github/copilot-instructions.md +1449 -817
  53. package/package.json +1 -1
  54. package/scripts/fetch-memory-engine.sh +25 -7
  55. package/scripts/lib.sh +90 -6
  56. package/scripts/tools/_graph_queries.sh +22 -8
  57. package/scripts/tools/_lib.sh +81 -11
  58. package/scripts/tools/adr-index.sh +1 -1
  59. package/scripts/tools/check-repo-size.sh +125 -0
  60. package/scripts/tools/check-skill-line-caps.sh +3 -4
  61. package/scripts/tools/check-template-noop.sh +0 -1
  62. package/scripts/tools/check-track-hygiene.sh +41 -21
  63. package/scripts/tools/classify-files.sh +3 -3
  64. package/scripts/tools/cycle-detect.sh +18 -17
  65. package/scripts/tools/detect-test-framework.sh +1 -1
  66. package/scripts/tools/emit-skill-metrics.sh +7 -2
  67. package/scripts/tools/fix-whitespace.sh +3 -0
  68. package/scripts/tools/freshness-check.sh +2 -2
  69. package/scripts/tools/git-metadata.sh +12 -6
  70. package/scripts/tools/graph-arch.sh +5 -11
  71. package/scripts/tools/graph-callers.sh +10 -15
  72. package/scripts/tools/graph-deps.sh +3 -10
  73. package/scripts/tools/graph-errors.sh +4 -11
  74. package/scripts/tools/graph-hierarchy.sh +4 -11
  75. package/scripts/tools/graph-impact.sh +21 -19
  76. package/scripts/tools/graph-init.sh +13 -9
  77. package/scripts/tools/graph-preflight.sh +4 -1
  78. package/scripts/tools/graph-query.sh +74 -18
  79. package/scripts/tools/graph-risk.sh +3 -10
  80. package/scripts/tools/graph-search.sh +4 -11
  81. package/scripts/tools/graph-snapshot.sh +38 -9
  82. package/scripts/tools/graph-snippet.sh +3 -10
  83. package/scripts/tools/graph-tests.sh +3 -10
  84. package/scripts/tools/graph-traces.sh +3 -10
  85. package/scripts/tools/hotspot-rank.sh +6 -12
  86. package/scripts/tools/install-smoke-test.sh +223 -0
  87. package/scripts/tools/mermaid-from-graph.sh +5 -11
  88. package/scripts/tools/migrate-track-frontmatter.sh +11 -10
  89. package/scripts/tools/okf-coverage-check.sh +8 -7
  90. package/scripts/tools/okf-emit-catalog.sh +256 -0
  91. package/scripts/tools/okf-fix-links.sh +251 -0
  92. package/scripts/tools/okf-plan-concepts.sh +242 -14
  93. package/scripts/tools/okf-render-views.sh +63 -21
  94. package/scripts/tools/okf-validate-all.sh +20 -9
  95. package/scripts/tools/okf-validate-quality.sh +15 -10
  96. package/scripts/tools/okf-validate.sh +20 -6
  97. package/scripts/tools/parse-git-log.sh +23 -5
  98. package/scripts/tools/parse-reports.sh +1 -1
  99. package/scripts/tools/render-track.sh +1 -1
  100. package/scripts/tools/resolve-tools.sh +24 -8
  101. package/scripts/tools/run-coverage.sh +1 -1
  102. package/scripts/tools/scan-markers.sh +4 -4
  103. package/scripts/tools/validate-frontmatter.sh +2 -2
  104. package/scripts/tools/verify-citations.sh +3 -4
  105. package/scripts/tools/verify-doc-anchors.sh +14 -34
  106. package/scripts/tools/verify-graph-binary.sh +15 -5
  107. package/skills/GRAPH.md +21 -10
  108. package/skills/adr/SKILL.md +25 -7
  109. package/skills/assist-review/SKILL.md +2 -1
  110. package/skills/bughunt/SKILL.md +55 -12
  111. package/skills/bughunt/references/regression-tests.md +14 -4
  112. package/skills/change/SKILL.md +19 -9
  113. package/skills/coverage/SKILL.md +28 -12
  114. package/skills/debug/SKILL.md +13 -3
  115. package/skills/decompose/SKILL.md +42 -12
  116. package/skills/deep-review/SKILL.md +19 -6
  117. package/skills/deploy-checklist/SKILL.md +10 -3
  118. package/skills/documentation/SKILL.md +12 -1
  119. package/skills/draft/SKILL.md +40 -29
  120. package/skills/draft/context-files.md +8 -1
  121. package/skills/draft/quality-guide.md +10 -2
  122. package/skills/graph/SKILL.md +2 -2
  123. package/skills/impact/SKILL.md +4 -2
  124. package/skills/implement/SKILL.md +62 -20
  125. package/skills/incident-response/SKILL.md +5 -2
  126. package/skills/init/SKILL.md +112 -30
  127. package/skills/init/references/architecture-spec.md +32 -8
  128. package/skills/init/references/okf-emitter.md +42 -78
  129. package/skills/jira/SKILL.md +33 -13
  130. package/skills/jira/references/review.md +61 -19
  131. package/skills/learn/SKILL.md +30 -7
  132. package/skills/new-track/SKILL.md +73 -18
  133. package/skills/quick-review/SKILL.md +8 -3
  134. package/skills/revert/SKILL.md +11 -5
  135. package/skills/review/SKILL.md +126 -27
  136. package/skills/review/references/zero-setup-mode.md +117 -0
  137. package/skills/standup/SKILL.md +10 -2
  138. package/skills/status/SKILL.md +7 -7
  139. package/skills/tech-debt/SKILL.md +9 -3
  140. package/skills/testing-strategy/SKILL.md +10 -2
  141. package/skills/tour/SKILL.md +2 -1
  142. package/skills/upload/SKILL.md +4 -3
  143. package/core/templates/track-architecture.md +0 -311
@@ -5,11 +5,13 @@
5
5
  Generate `draft/architecture.md` — a graph-primary human-readable engineering reference.
6
6
 
7
7
  **Output format**:
8
+
8
9
  - Markdown report with Mermaid diagrams, tables, and code blocks
9
10
  - **Target length: fidelity-first** — cover all 10 mandatory sections with graph-grounded accuracy and diagram correctness
10
11
  - End the document with: `"End of analysis. Queries should reference the .ai-context.md file for token efficiency."`
11
12
 
12
13
  **CRITICAL — Template Structure Compliance:**
14
+
13
15
  - The output MUST use the EXACT 10-section structure from `core/templates/architecture.md` (§1–§10)
14
16
  - Do NOT create freeform/custom section names or resurrect 28-section numbering
15
17
  - Do NOT skip mandatory sections — if a section does not apply, include the heading with "N/A — {reason}"
@@ -68,11 +70,13 @@ _(Skip or adapt sections per the Adaptive Sections table above.)_
68
70
  ### 1. Executive Summary
69
71
 
70
72
  Write **one paragraph** that states:
73
+
71
74
  - What the module IS (identity)
72
75
  - What it DOES (responsibilities)
73
76
  - Its role in the larger system
74
77
 
75
78
  Follow with a **Key Facts** bullet list:
79
+
76
80
  - Primary language(s) and version
77
81
  - Binary / entry-point / package name
78
82
  - Architecture style (e.g., distributed master/worker, client-server, daemon, library, microservice, monolith, serverless, CLI tool)
@@ -87,7 +91,7 @@ Follow with a **Key Facts** bullet list:
87
91
 
88
92
  A compact block optimized for fast AI-agent context loading. Fill in every field that applies; mark others as "N/A":
89
93
 
90
- ```
94
+ ```text
91
95
  **Module** : {PROJECT_NAME}
92
96
  **Root Path** : ./
93
97
  **Language** : (e.g., C++17, Go 1.21, Python 3.12, TypeScript 5.3, Rust 1.75, Java 21)
@@ -136,11 +140,13 @@ A compact block optimized for fast AI-agent context loading. Fill in every field
136
140
  #### 4.1 High-Level Topology
137
141
 
138
142
  **MANDATORY: Generate a Mermaid `flowchart TD` diagram** showing:
143
+
139
144
  - The main process / service and its internal components (as nested subgraphs)
140
145
  - External services and dependencies (as a separate subgraph)
141
146
  - Directional arrows showing primary data / control flow
142
147
 
143
148
  Example structure (adapt to actual codebase):
149
+
144
150
  ```mermaid
145
151
  flowchart TD
146
152
  subgraph Service["MyService"]
@@ -162,7 +168,8 @@ Write the `GRAPH:module-deps` injection slot into architecture.md:
162
168
  If graph build succeeded (Step 1.4.7 completed), write the populated slot content using the diagram from Step 1.4.7. If filtered (>30 modules), include the filter note. Dashed edges indicate circular dependencies.
163
169
 
164
170
  If graph binary was not found: write the slot with placeholder body so draft:init --graph-only can populate it later:
165
- ```
171
+
172
+ ```text
166
173
  <!-- GRAPH:module-deps:START -->
167
174
  [Graph data unavailable — run draft:init --graph-only to populate after graph binary is installed]
168
175
  <!-- GRAPH:module-deps:END -->
@@ -187,6 +194,7 @@ For CLI tools: parse args → validate → execute → output → exit.
187
194
  #### 5.1 Top-Level Orchestrator
188
195
 
189
196
  For the main controller / manager / app class:
197
+
190
198
  - Describe its role in one sentence.
191
199
  - **Owned Components** — table:
192
200
 
@@ -198,6 +206,7 @@ For the main controller / manager / app class:
198
206
  #### 5.2 Dependency Injection / Wiring Pattern
199
207
 
200
208
  Describe how components reference each other. Common patterns to look for:
209
+
201
210
  - Constructor injection (Spring, Guice, etc.)
202
211
  - Service locator / context struct (C++ pattern)
203
212
  - Module system (Python, Node.js imports)
@@ -230,6 +239,7 @@ Use ✓ for direct calls, ✓(RPC) for remote procedure calls, ✓(HTTP) for RES
230
239
  **Purpose**: This section captures the **real behavioral architecture** — the primary ways the system moves through time, state, and control flow. It is more valuable for correct code generation and modification than static component descriptions.
231
240
 
232
241
  The LLM **must** combine:
242
+
233
243
  - The deterministic knowledge graph (modules, edges, entry points, public surfaces, hotspots, call targets)
234
244
  - Its full indexed project understanding from the host Cursor / Claude Code / Copilot environment
235
245
  - Targeted source reads only for confirmation and detail
@@ -247,6 +257,7 @@ Synthesize the 2–5 most important operational views for the system. Typical ca
247
257
  - For plugin / meta-tooling / agent platforms: the core execution or dispatch model (skill/command/agent lifecycle, frontmatter contract enforcement, generation/condensation pipeline, parallel analysis protocol, track/decompose/implement lifecycle, etc.)
248
258
 
249
259
  Each diagram must be a **stateDiagram-v2**, **sequenceDiagram**, or detailed **flowchart** containing:
260
+
250
261
  - Real actor / state / stage names from the actual codebase
251
262
  - Labeled transitions using actual function, message, or event names where possible
252
263
  - `alt` / `opt` / `loop` / `critical` where branching, repetition, or error handling exists
@@ -280,7 +291,7 @@ First resolve the bundled helpers:
280
291
  ```bash
281
292
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
282
293
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
283
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
294
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
284
295
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
285
296
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
286
297
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -312,6 +323,7 @@ Synthesize a single, accurate Mermaid diagram (`stateDiagram-v2`, `sequenceDiagr
312
323
  #### Sub-Module Guidance (when graph justifies recursion)
313
324
 
314
325
  When a module has clear internal structure visible in live engine query `get_architecture .packages` (fan-in/out) or live per-package queries:
326
+
315
327
  - Create `##### 7.X.Y {Parent}/{Child}` subsections only for children that have their own meaningful public surface or high internal fan-in.
316
328
  - Each sub-module subsection follows the same compact pattern: graph facts + **one mandatory workflow/state diagram** + ≤60 words Design Notes.
317
329
  - Do not descend further unless the child itself shows additional clear boundaries in the graph data.
@@ -326,6 +338,7 @@ When a module has clear internal structure visible in live engine query `get_arc
326
338
  | (enumerate ALL public methods — at least 5 entries) | | |
327
339
 
328
340
  **Interaction with Sibling Sub-Modules**:
341
+
329
342
  - Calls `{sibling}/` for {purpose}
330
343
  - Called by `{sibling}/` when {trigger}
331
344
  - Shares `{base|common}/` types: {list key shared types}
@@ -336,7 +349,8 @@ When a module has clear internal structure visible in live engine query `get_arc
336
349
  **Notable Mechanisms**: {caching, retry, batching, scheduling, etc.}
337
350
 
338
351
  **Error Handling**: How errors propagate within this sub-module and to the parent.
339
- ```
352
+
353
+ ```text
340
354
 
341
355
  #### Per-Sub-Module Template (Medium — 10–49 files)
342
356
 
@@ -357,7 +371,8 @@ When a module has clear internal structure visible in live engine query `get_arc
357
371
  ```{language}
358
372
  // actual code from the interface header, 10-20 lines
359
373
  ```
360
- ```
374
+
375
+ ```text
361
376
 
362
377
  #### Operation Catalog Template (for ops/handler directories)
363
378
 
@@ -379,7 +394,7 @@ Use `"$DRAFT_TOOLS/graph-callers.sh" --symbol <module>` or `"$DRAFT_TOOLS/graph-
379
394
 
380
395
  For a module like `icebox/` with sub-directories `master/` (200+ files), `slave/` (150+ files), `client/` (20 files), `base/` (40 files):
381
396
 
382
- ```
397
+ ```text
383
398
  #### 7.3 icebox
384
399
  [Top-level module deep-dive: role, overall architecture diagram, cross-sub-module interaction]
385
400
 
@@ -405,6 +420,7 @@ For a module like `icebox/` with sub-directories `master/` (200+ files), `slave/
405
420
  This produces 300–500+ lines for `icebox/` alone, which is proportional to its 917-file complexity.
406
421
 
407
422
  **MANDATORY for stateful modules and sub-modules**: Include a `stateDiagram-v2` showing state transitions:
423
+
408
424
  ```mermaid
409
425
  stateDiagram-v2
410
426
  [*] --> Idle
@@ -470,6 +486,7 @@ Table:
470
486
  #### 9.2 Registry / Registration Mechanism
471
487
 
472
488
  Describe how plugins are registered. Common patterns:
489
+
473
490
  - Explicit registry calls in an init file
474
491
  - Decorator / annotation-based auto-registration
475
492
  - Convention-based discovery (file naming, directory scanning)
@@ -574,6 +591,7 @@ Table:
574
591
  #### 12.3 External-Facing API (if distinct from internal)
575
592
 
576
593
  List endpoints grouped by function. Reference the actual definition files:
594
+
577
595
  - `.proto` files for gRPC / protobuf
578
596
  - OpenAPI / Swagger specs for REST
579
597
  - GraphQL schema files
@@ -643,6 +661,7 @@ sequenceDiagram
643
661
  ```
644
662
 
645
663
  Each sequence diagram MUST show:
664
+
646
665
  - All participant lifelines (components / services)
647
666
  - Request → response arrows with payload descriptions
648
667
  - Conditional branches (alt/opt blocks) where logic diverges
@@ -834,13 +853,15 @@ For each significant pattern (typically 4–8), provide a COMPLETE writeup:
834
853
  ```
835
854
 
836
855
  **Anti-Pattern to Avoid**:
856
+
837
857
  ```{language}
838
858
  // Show what NOT to do
839
859
  // This helps AI agents avoid common mistakes
840
860
  ```
841
861
 
842
862
  **When to Apply**: Guidance on when new code should use this pattern.
843
- ```
863
+
864
+ ```text
844
865
 
845
866
  **MANDATORY**: Code snippets must be ACTUAL CODE from the codebase, not pseudocode or simplified examples. Include enough context (10-30 lines) to understand the pattern.
846
867
 
@@ -1088,7 +1109,8 @@ Write the `GRAPH:proto-map` injection slot into architecture.md.
1088
1109
  If graph build succeeded and proto files exist (Step 1.4.7 completed), write the populated slot content using the diagram from Step 1.4.7.
1089
1110
 
1090
1111
  If graph binary was not found or no proto files exist, write the slot with placeholder:
1091
- ```
1112
+
1113
+ ```text
1092
1114
  <!-- GRAPH:proto-map:START -->
1093
1115
  [Graph data unavailable — run draft:init --graph-only to populate after graph binary is installed]
1094
1116
  <!-- GRAPH:proto-map:END -->
@@ -1130,6 +1152,7 @@ Before finalizing architecture.md, verify your output meets these quality gates.
1130
1152
  **If any depth gate fails: re-read source for the failing sections and expand. Do NOT proceed to .ai-context.md generation until all depth gates pass.**
1131
1153
 
1132
1154
  **Checklist additions:**
1155
+
1133
1156
  - [ ] Graph injection slots populated (GRAPH:module-deps, GRAPH:hotspots, GRAPH:proto-map) if schema.yaml exists
1134
1157
  - [ ] At least 28 + 5 appendices present (including new Appendix E)
1135
1158
 
@@ -1234,6 +1257,7 @@ Fix: Apply the tiered sub-module analysis. For each Large sub-module, create a `
1234
1257
 
1235
1258
  **FAILURE 5 — Missing Operational Diagrams:**
1236
1259
  Detection: Any of these three diagrams is absent from the document:
1260
+
1237
1261
  - §3.3 initialization sequence diagram
1238
1262
  - §7.4 execution topology diagram
1239
1263
  - §16.2 failure decision tree
@@ -38,7 +38,7 @@ and adds `wiki/`. **Every other standard `/draft:init` file is still produced**
38
38
  `.ai-profile.md`, `tracks/` + `tracks.md`, `.state/`, `graph/` — exactly as in
39
39
  `monolith` mode. Do **not** skip them: emitting only the bundle is a regression.
40
40
 
41
- ```
41
+ ```text
42
42
  draft/
43
43
  ├── .ai-context.md # INDEX ROOT: synopsis (150–250 lines) + Concept Map
44
44
  ├── architecture.md # RENDERED VIEW (generated from bundle; not source of truth)
@@ -130,78 +130,43 @@ Derive concepts from the graph, not by hand:
130
130
 
131
131
  ## Generation pipeline (M3)
132
132
 
133
- ```
133
+ ```text
134
134
  1. Survey → existing /draft:init 5-phase + graph snapshot (graph-snapshot.sh)
135
135
  2. Plan → DETERMINISTIC. okf-plan-concepts.sh derives the expected-concept
136
- set from the graph. EVERY package the graph knows about is
137
- required (fan_in floor Subsystem; below floor Module — the
138
- floor only types/orders, it never exempts); entrypoints required;
139
- only --allow-defer matches are deferred (with a reason). Writes
140
- draft.tmp/.state/concept-plan.json.
136
+ set. Discovery order (exclusive of --manifest):
137
+ a) Cargo workspace members / npm workspaces / Go modules
138
+ b) graph packages (noise-filtered when a language inventory exists)
139
+ c) heuristic top-level source dirs
140
+ Coarse graph parents (e.g. crates/codegen) become Subsystems;
141
+ crate/package names become Modules. Tokenizer noise (str, int, …)
142
+ is dropped when unmapped. Writes draft.tmp/.state/concept-plan.json.
141
143
  okf-plan-concepts.sh --repo . [--scope PATH] \
142
144
  [--manifest FILE] [--min-fan-in 2] [--allow-defer GLOB]... \
143
145
  --out draft.tmp/.state/concept-plan.json
144
- This replaces the old in-context concept enumeration — the boundary
145
- of the work is now a tool output, not an LLM judgment, so modules
146
- and sub-modules cannot be silently dropped. (Legacy fan-in
147
- exemption is opt-in via --defer-below-floor.) LOG the counts
148
- (expected/required/deferred) BEFORE writing any page.
149
- `generated_order` is topo-ish (required + high-fan-in first) so
150
- forward cross-links resolve.
151
- 3. Generate → iterate concept-plan.generated_order; write ONE page per REQUIRED
152
- entry, grounding each from the graph:
153
- x-callers ← graph-callers.sh --symbol <c>
154
- x-grounded-paths ← graph-impact.sh --symbol <c> (blast radius)
155
- x-hotspot-score ← hotspot-rank.sh
156
- overview diagrams mermaid-from-graph.sh
157
- Record each source path → page in .state/path-to-concept.json.
158
- Loop post-condition: every required concept_id has an output file.
159
- Writing pages via shell heredoc without reading x-grounded-paths
160
- sources, or finishing while any required entry is unwritten, is a
161
- completeness failure not a stylistic one.
162
- 4. Render views → ai-context.md (synopsis + Concept Map), architecture.md
163
- (concatenated view + coverage banner), wiki/log.md (see M4).
164
- 5. Validate → the promotion gate. Run all layers via the orchestrator:
165
- 5a. okf-validate-all.sh draft.tmp/wiki \
166
- --repo . \
167
- --plan draft.tmp/.state/concept-plan.json \
168
- --path-index draft.tmp/.state/path-to-concept.json \
169
- --strict --report draft.tmp/.state/validation-report.json
170
- It runs, in order: okf-validate.sh (structure + reverse index +
171
- empty/untyped-page + leftover-template-token + dangling-link checks),
172
- okf-validate-quality.sh (per-type anti-stub / depth / per-section
173
- content / mermaid lint), okf-coverage-check.sh (every required plan
174
- entry → real page).
175
- ANY layer failing ⇒ exit non-zero ⇒ DO NOT atomic-rename.
176
- coverage.md (systems/coverage.md) is regenerated by the coverage
177
- layer; it is tool-owned (marker <!-- okf:coverage-generated -->) —
178
- never hand-author it except deferral reasons in the manifest.
179
- 6. Emit → mv draft.tmp/ draft/ ONLY IF step 5 exit 0 ; update .state/.
180
- On failure keep draft.tmp/ and surface validation-report.json.
181
- ```
182
-
183
- ### Validation report schema (`.state/validation-report.json`)
184
-
185
- ```json
186
- { "valid": false, "bundle": "draft.tmp/wiki",
187
- "layers": { "structure": "pass", "quality": "pass", "coverage": "fail" } }
146
+ LOG counts (expected/required/deferred + discovery[]) BEFORE pages.
147
+ 3. Catalog floor okf-emit-catalog.sh writes a quality-passing MINIMUM page for
148
+ every REQUIRED plan entry that is still missing (so XL monorepos
149
+ do not depend on the LLM for completeness):
150
+ okf-emit-catalog.sh --plan draft.tmp/.state/concept-plan.json \
151
+ --bundle draft.tmp/wiki --repo .
152
+ 4. Generate/enrich → iterate concept-plan.generated_order; enrich top hotspots
153
+ (LLM) beyond the catalog floor. Record path-to-concept.json.
154
+ Post-condition: every required concept_id has a non-stub page.
155
+ 5. Render views → okf-render-views.sh (architecture.md + Concept Map + section
156
+ indexes). Uses GFM slugs for TOC; rewrites sibling links to
157
+ wiki/<section>/…. Then okf-fix-links.sh --draft draft.tmp --fix.
158
+ 6. Validate → promotion gate (order is intentional):
159
+ okf-validate-all.sh draft.tmp/wiki \
160
+ --plan draft.tmp/.state/concept-plan.json \
161
+ --path-index draft.tmp/.state/path-to-concept.json \
162
+ --strict --report draft.tmp/.state/validation-report.json
163
+ Runs: quality coverage (rewrites coverage.md) → structure LAST
164
+ so coverage relative links are checked. Also run:
165
+ okf-fix-links.sh --draft draft.tmp --check
166
+ ANY failure DO NOT atomic-rename.
167
+ 7. Emit → mv draft.tmp/ draft/ ONLY IF step 6 exit 0 ; update .state/.
188
168
  ```
189
169
 
190
- ### Component manifest (optional — `--manifest FILE`)
191
-
192
- When the graph engine is unavailable (or a repo wants an authoritative list), pass
193
- a plain-text manifest: one component name per line, `#` comments and blanks ignored.
194
- Every listed component becomes a REQUIRED concept; `--allow-defer GLOB` still moves
195
- matches to deferred. Without a manifest the plan comes from the graph, and only if
196
- both are unavailable does it fall back to a heuristic top-level-dir scan (which it
197
- marks `degraded: true`).
198
-
199
- Page bodies are LLM-narrated for readability **but** the graph-derived
200
- frontmatter and the `Blast radius`/`Used by` sections are deterministic. To keep
201
- incremental carry-forward byte-identical (open decision 2), cache the narrated
202
- prose keyed by the source hash of `x-grounded-paths` — unchanged sources reuse
203
- the cached narration verbatim.
204
-
205
170
  ## Render views (M4)
206
171
 
207
172
  Both are produced by the deterministic helper `okf-render-views.sh` (no LLM) —
@@ -254,18 +219,17 @@ section `index.md` tables are the injection slots for the routing tables.
254
219
 
255
220
  `/draft:init refresh` under `okf` mode:
256
221
 
257
- ```
258
- 1. Re-derive the plan: okf-plan-concepts.sh (modules added since last run become
259
- REQUIRED — a new package can't slip through a refresh either)
260
- 2. Diff hashes.json vs working tree changed source paths
261
- 3. path-to-concept.json affected concept pages
262
- 4. Regenerate ONLY affected concepts; carry the rest verbatim (cached narration)
263
- 5. Re-render ai-context.md / architecture.md / log.md (cheap; always regenerated)
264
- 6. Re-validate (full gate): okf-validate-all.sh on the bundle with --plan and
265
- --path-index. Refresh re-runs structure + quality + coverage — a changed
266
- concept must still clear the quality bar, and a newly-required module must
267
- still be present.
268
- 7. Append log.md; update hashes.json + path-to-concept.json
222
+ ```text
223
+ 1. Re-derive the plan: okf-plan-concepts.sh (cargo/npm/go + graph). Modules added
224
+ since last run become REQUIRED — a new crate cannot slip through a refresh.
225
+ 2. Diff plan vs previous concept-plan.json NEW required concept_ids
226
+ 3. Diff hashes.json vs working tree changed source paths
227
+ 4. path-to-concept.json → affected concept pages
228
+ 5. okf-emit-catalog.sh for any NEW missing required pages (completeness floor)
229
+ 6. Regenerate/enrich changed + new concepts; carry the rest verbatim
230
+ 7. Re-render ai-context.md / architecture.md / log.md + okf-fix-links --fix
231
+ 8. Re-validate: okf-validate-all + okf-fix-links --check
232
+ 9. Append log.md; update hashes.json + path-to-concept.json + concept-plan.json
269
233
  ```
270
234
 
271
235
  A 1-file change regenerates only the concept(s) that file grounds. Unchanged
@@ -7,7 +7,6 @@ description: Unified Jira entry point. Routes to preview (default), create, or r
7
7
 
8
8
  Single entry point for all Jira workflows: preview Draft tracks as Jira issues, create them via MCP (default = 1 Story per track; --epic = 1 Epic + 1-3 Stories), and review any Jira ticket (epic, story, bug, sub-task) end-to-end.
9
9
 
10
-
11
10
  ## Subcommand Routing
12
11
 
13
12
  Parse `$ARGUMENTS` and dispatch:
@@ -44,6 +43,7 @@ Assignee Display Name: <assignee-name>
44
43
  - **Team / Component / Swimlane / Assignee Display Name** — applied as defaults to every issue created by `create`. Empty values are skipped (Jira ignores blank fields).
45
44
 
46
45
  If a value is missing when needed:
46
+
47
47
  1. Prompt the user for it.
48
48
  2. Append to (or create) the `## Jira` section in `draft/workflow.md` so subsequent runs reuse it.
49
49
 
@@ -69,7 +69,7 @@ Generate a timestamped `jira-export-<timestamp>.md` (with `jira-export-latest.md
69
69
 
70
70
  **Flag handling:** Check `$ARGUMENTS` for `--epic` at the very start of this section. If present, set `EPIC_MODE=true` and remove the flag from the working arguments. This flag changes the entire output structure (see Step 2).
71
71
 
72
- ## Red Flags — STOP if you're:
72
+ ## Red Flags — STOP if you're
73
73
 
74
74
  - Generating a preview without an approved plan.md
75
75
  - Assigning story points inconsistent with task count
@@ -123,7 +123,6 @@ synced_to_commit: "{FULL_SHA}"
123
123
 
124
124
  ## Mapping Structure
125
125
 
126
-
127
126
  ### Default behavior (recommended)
128
127
 
129
128
  - Every track becomes **exactly 1 Story**.
@@ -137,6 +136,7 @@ This keeps Jira clean and keeps the export focused on root issues by default.
137
136
  Use `/draft:jira preview --epic` or `/draft:jira create --epic` when you want an Epic.
138
137
 
139
138
  **Splitting rule (simple):**
139
+
140
140
  - 5 or fewer phases → **1 Story** under the Epic
141
141
  - More than 5 phases → split across **2 or 3 Stories** (maximum)
142
142
 
@@ -166,13 +166,16 @@ If no track found: tell the user "No track found. Run `/draft:new-track` to crea
166
166
  ## Step 2: Determine Export Mode, Count Phases, and Group Content
167
167
 
168
168
  ### 2.1 Detect Mode
169
+
169
170
  - If `EPIC_MODE=true` (from `--epic` flag), use Epic + Stories mode.
170
171
  - Otherwise, use **default single-Story mode**.
171
172
 
172
173
  ### 2.2 Count Phases and Decide Story Count (Epic Mode Only)
174
+
173
175
  Count the number of `## Phase` sections in `plan.md`.
174
176
 
175
177
  **Splitting guideline (when using --epic):**
178
+
176
179
  - Phases ≤ 5 → 1 Story under the Epic
177
180
  - Phases 6–12 → 2 Stories under the Epic
178
181
  - Phases > 12 → 3 Stories under the Epic (hard cap)
@@ -180,9 +183,11 @@ Count the number of `## Phase` sections in `plan.md`.
180
183
  Store the target number of stories: `TARGET_STORIES`.
181
184
 
182
185
  ### 2.3 Group Phases (for Epic Mode)
186
+
183
187
  Divide the phases as evenly as possible across `TARGET_STORIES`.
184
188
 
185
189
  Example grouping (store this in memory):
190
+
186
191
  - Story 1 gets phases 1..K
187
192
  - Story 2 gets phases K+1..M
188
193
  - Story 3 gets remaining phases
@@ -190,13 +195,16 @@ Example grouping (store this in memory):
190
195
  In **default mode**, ignore grouping — everything goes under one Story.
191
196
 
192
197
  ### 2.4 Build Data Structures
198
+
193
199
  For every phase:
200
+
194
201
  - Capture Phase name, Goal, Verification
195
202
  - Collect all its tasks (with status)
196
203
 
197
204
  Calculate total story points using the existing simple table (1-2 tasks = 1pt, 3-4=2pt, 5-6=3pt, 7+=5pt). This total goes on the root issue (or split across stories in epic mode if desired — default is to put total on the first Story).
198
205
 
199
206
  ### 2.5 Root Issue Data
207
+
200
208
  - Summary = Track title
201
209
  - Description base = content from `spec.md` (first 2-3 paragraphs) + later the full structured plan
202
210
  - Issue Type = "Story" (default) or "Epic" (--epic)
@@ -230,6 +238,7 @@ SYMLINK="draft/tracks/<track_id>/jira-export-latest.md"
230
238
  Create the file and the `latest` symlink.
231
239
 
232
240
  ### 4.1 Write Frontmatter + Header
241
+
233
242
  Use the standard YAML frontmatter.
234
243
  Add a `mode: default` or `mode: epic` field.
235
244
 
@@ -266,6 +275,7 @@ Include the Draft signature at the bottom of the description.
266
275
  **Jira Content Rule:** Keep every Story description **short and scannable**. Use compact headings and minimal text.
267
276
 
268
277
  If `mode: epic`:
278
+
269
279
  - Emit 1 to 3 `## Story N: [Short Title]` blocks (using the grouping decided in Step 2).
270
280
  - Under each Story, put the phases assigned to it as `### Phase ...` + **compact** task checklists.
271
281
  - Each Story gets its share of the total story points (or put the total on the first one — simple is fine).
@@ -276,6 +286,7 @@ Use the existing high-quality bug export format from `bughunt-report-latest.md`.
276
286
  These will become real Bug issues linked to the root (Epic or the main Story).
277
287
 
278
288
  ### 4.5 Final Notes in the Export
289
+
279
290
  Add at the top:
280
291
 
281
292
  > Default = 1 Story. Use `--epic` for 1 Epic + 1-3 Stories.
@@ -284,7 +295,7 @@ Update the symlink.
284
295
 
285
296
  ## Step 5: Report
286
297
 
287
- ```
298
+ ```text
288
299
  Jira Preview Generated
289
300
 
290
301
  Track: [track_id] - [title]
@@ -317,18 +328,22 @@ Next steps:
317
328
  ## Error Handling (preview)
318
329
 
319
330
  **plan.md has no phases:**
331
+
320
332
  - Tell user: "No phases found in plan.md. Run `/draft:new-track` to generate a proper plan."
321
333
 
322
334
  **spec.md missing:**
335
+
323
336
  - Use `plan.md` overview for root-issue description.
324
337
  - Warn: "spec.md not found, using plan overview for root-issue description."
325
338
 
326
339
  **jira-export-latest.md already exists:**
340
+
327
341
  - Check if the target file has been manually modified (user-added content not matching generated patterns — edited descriptions, added rows, changed story points from generated values).
328
342
  - If modifications detected, prompt: "Existing jira-export appears to have manual edits. Overwrite? [y/N]"
329
343
  - If unmodified, proceed with regeneration (new timestamped file + updated symlink).
330
344
 
331
345
  **Phase has no tasks:**
346
+
332
347
  - Create mid-level issue with 1 story point.
333
348
  - Add note: "No leaf issues defined for this phase."
334
349
 
@@ -338,7 +353,7 @@ Next steps:
338
353
 
339
354
  Create Jira issues from `jira-export-latest.md` using MCP-Jira. If no export file exists, auto-generates one first by running the `preview` subcommand.
340
355
 
341
- ## Red Flags — STOP if you're:
356
+ ## Red Flags — STOP if you're
342
357
 
343
358
  - Creating Jira issues without reviewing `jira-export-latest.md` first (run `/draft:jira preview`)
344
359
  - Proceeding when MCP-Jira is not configured
@@ -372,7 +387,7 @@ Detect MCP-Jira tools. Known tool name variants: `mcp_jira_create_issue`, `jira_
372
387
 
373
388
  If unavailable:
374
389
 
375
- ```
390
+ ```text
376
391
  MCP-Jira not configured.
377
392
 
378
393
  To create issues:
@@ -388,14 +403,17 @@ Stop execution.
388
403
  ## Step 4: Parse Export File (Export Format)
389
404
 
390
405
  Read the `mode` field from frontmatter:
406
+
391
407
  - `default` → expect 1 root Story
392
408
  - `epic` → expect 1 Epic + 1–3 Stories
393
409
 
394
410
  ### Root Issue(s)
411
+
395
412
  - Parse the `## Root Issue` (and any `## Story N:` sections if mode=epic).
396
413
  - For each Story section: Summary, Description (which now contains the phases and task checklists), story points if present.
397
414
 
398
415
  ### Bug Issues
416
+
399
417
  Parse the `## Bug Issues` section completely (same as before). These are always created as separate Bug issues.
400
418
 
401
419
  **Important:** There are no longer "Mid-Level" or "Leaf Issues" tables that become separate Jira Tasks/Sub-tasks. All work items live inside the Story description(s).
@@ -430,7 +448,7 @@ Assignee Display Name: <assignee-name>
430
448
 
431
449
  Before creating issues, attempt to fetch project metadata via MCP to verify the project key exists:
432
450
 
433
- ```
451
+ ```text
434
452
  MCP call: get_project (or equivalent)
435
453
  - project: [project key]
436
454
  ```
@@ -453,7 +471,7 @@ If `Assignee Display Name` is provided, resolve to an account ID via MCP user se
453
471
 
454
472
  Apply these to every `create_issue` call (omit any that resolved to empty in Step 4b):
455
473
 
456
- ```
474
+ ```text
457
475
  - project: [Project Key]
458
476
  - labels: ["draft"]
459
477
  - component: [Component if set]
@@ -472,20 +490,21 @@ Apply these to every `create_issue` call (omit any that resolved to empty in Ste
472
490
  For each Story/Epic:
473
491
  **Jira Content Rule (strict):** The description sent to Jira must be concise. Use short summaries and compact structured sections only. Do not include long reasoning or exhaustive lists.
474
492
 
475
- ```
493
+ ```text
476
494
  MCP call: create_issue
477
495
  - issue_type: Story or Epic
478
496
  - summary: ...
479
497
  - description: [concise content — phases as compact sections, tasks as short checklists]
480
498
  + shared field defaults
481
499
  ```
500
+
482
501
  Capture the keys.
483
502
 
484
503
  ### 5b. Create Bug Issues (from Bug Hunt Report)
485
504
 
486
505
  For every bug parsed in Step 4, create a real **Bug** issue:
487
506
 
488
- ```
507
+ ```text
489
508
  MCP call: create_issue
490
509
  - issue_type: Bug
491
510
  - summary: ...
@@ -517,7 +536,7 @@ Set export file status to Created (via `jira-export-latest.md`):
517
536
 
518
537
  ## Step 7: Report (new simplified format)
519
538
 
520
- ```
539
+ ```text
521
540
  Jira Issues Created
522
541
 
523
542
  Track: [track_id] - [title]
@@ -543,7 +562,8 @@ Updated:
543
562
  ## Error Handling (create)
544
563
 
545
564
  **MCP call fails:**
546
- ```
565
+
566
+ ```text
547
567
  Failed to create [issue type]: [error message]
548
568
 
549
569
  Partial creation:
@@ -563,7 +583,6 @@ Already-created issues will be detected by keys in jira-export-latest.md.
563
583
 
564
584
  **plan.md phases don't match export:** warn "Export has N mid-level issues but plan has M phases. Proceeding with export structure." Create based on export.
565
585
 
566
-
567
586
  ---
568
587
 
569
588
  # Subcommand: review
@@ -571,6 +590,7 @@ Already-created issues will be detected by keys in jira-export-latest.md.
571
590
  See [review.md](review.md) for the full epic/story/bug/sub-task qualification pipeline. The router delegates to that file when the user invokes `/draft:jira review <JIRA_ID>`.
572
591
 
573
592
  The review subcommand:
593
+
574
594
  - Accepts any Jira issue ID (epic, story, bug, sub-task) and adapts its depth to the issue type.
575
595
  - Runs a 7-phase pipeline: prerequisites → epic/story collection → document/test-plan synthesis → code change collection (Gerrit/GitHub/GitLab) → context synthesis → quality analysis (deep-review + bughunt + coverage) → test gap analysis → report.
576
596
  - Produces `draft/jira-review/<JIRA_ID>/qualification-report.md` and (if gaps exist) `remediation-plan.md`.