@drafthq/draft 3.6.0 → 3.7.2

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 (117) 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/installer.js +1 -1
  7. package/cli/src/lib/cursor-registry.js +10 -0
  8. package/core/agents/architect.md +21 -9
  9. package/core/agents/debugger.md +5 -0
  10. package/core/agents/ops.md +7 -2
  11. package/core/agents/planner.md +7 -0
  12. package/core/agents/rca.md +14 -3
  13. package/core/agents/reviewer.md +1 -0
  14. package/core/agents/writer.md +6 -0
  15. package/core/knowledge-base.md +22 -3
  16. package/core/methodology.md +30 -5
  17. package/core/shared/condensation.md +27 -17
  18. package/core/shared/context-verify.md +3 -1
  19. package/core/shared/cross-skill-dispatch.md +7 -3
  20. package/core/shared/draft-context-loading.md +3 -0
  21. package/core/shared/git-report-metadata.md +1 -0
  22. package/core/shared/graph-query.md +0 -2
  23. package/core/shared/graph-usage-report.md +1 -1
  24. package/core/shared/jira-sync.md +10 -6
  25. package/core/shared/okf-retrieval.md +1 -1
  26. package/core/shared/parallel-analysis.md +14 -7
  27. package/core/shared/pattern-learning.md +2 -0
  28. package/core/shared/template-contract.md +1 -1
  29. package/core/shared/vcs-commands.md +5 -2
  30. package/core/templates/ai-context.md +3 -2
  31. package/core/templates/ai-profile.md +7 -0
  32. package/core/templates/architecture.md +6 -2
  33. package/core/templates/discovery.md +1 -1
  34. package/core/templates/guardrails.md +9 -0
  35. package/core/templates/hld.md +5 -4
  36. package/core/templates/intake-questions.md +45 -0
  37. package/core/templates/jira.md +11 -2
  38. package/core/templates/lld.md +8 -5
  39. package/core/templates/okf/concept.md +0 -1
  40. package/core/templates/product.md +11 -2
  41. package/core/templates/rca.md +6 -0
  42. package/core/templates/service-index.md +1 -0
  43. package/core/templates/spec.md +15 -0
  44. package/core/templates/tech-stack.md +12 -0
  45. package/core/templates/workflow.md +20 -0
  46. package/integrations/agents/AGENTS.md +1272 -292
  47. package/integrations/copilot/.github/copilot-instructions.md +1272 -292
  48. package/package.json +1 -1
  49. package/scripts/fetch-memory-engine.sh +24 -6
  50. package/scripts/lib.sh +11 -4
  51. package/scripts/tools/_graph_queries.sh +10 -3
  52. package/scripts/tools/_lib.sh +33 -11
  53. package/scripts/tools/check-repo-size.sh +125 -0
  54. package/scripts/tools/check-skill-line-caps.sh +1 -2
  55. package/scripts/tools/check-template-noop.sh +0 -1
  56. package/scripts/tools/classify-files.sh +2 -2
  57. package/scripts/tools/cycle-detect.sh +16 -8
  58. package/scripts/tools/fix-whitespace.sh +3 -0
  59. package/scripts/tools/git-metadata.sh +6 -0
  60. package/scripts/tools/graph-arch.sh +1 -1
  61. package/scripts/tools/graph-callers.sh +6 -3
  62. package/scripts/tools/graph-impact.sh +4 -2
  63. package/scripts/tools/graph-init.sh +12 -8
  64. package/scripts/tools/graph-preflight.sh +3 -0
  65. package/scripts/tools/graph-query.sh +70 -7
  66. package/scripts/tools/graph-snapshot.sh +29 -5
  67. package/scripts/tools/hotspot-rank.sh +24 -9
  68. package/scripts/tools/install-smoke-test.sh +223 -0
  69. package/scripts/tools/mermaid-from-graph.sh +28 -11
  70. package/scripts/tools/migrate-track-frontmatter.sh +9 -10
  71. package/scripts/tools/okf-coverage-check.sh +4 -3
  72. package/scripts/tools/okf-fix-links.sh +18 -93
  73. package/scripts/tools/okf-plan-concepts.sh +5 -8
  74. package/scripts/tools/okf-render-views.sh +19 -14
  75. package/scripts/tools/okf-validate-quality.sh +13 -2
  76. package/scripts/tools/okf-validate.sh +13 -2
  77. package/scripts/tools/parse-git-log.sh +19 -1
  78. package/scripts/tools/resolve-tools.sh +24 -8
  79. package/scripts/tools/verify-citations.sh +1 -2
  80. package/scripts/tools/verify-doc-anchors.sh +13 -33
  81. package/scripts/tools/verify-graph-binary.sh +13 -3
  82. package/skills/GRAPH.md +21 -10
  83. package/skills/adr/SKILL.md +24 -6
  84. package/skills/assist-review/SKILL.md +2 -1
  85. package/skills/bughunt/SKILL.md +54 -11
  86. package/skills/bughunt/references/regression-tests.md +14 -4
  87. package/skills/change/SKILL.md +19 -9
  88. package/skills/coverage/SKILL.md +26 -10
  89. package/skills/debug/SKILL.md +12 -2
  90. package/skills/decompose/SKILL.md +39 -9
  91. package/skills/deep-review/SKILL.md +17 -4
  92. package/skills/deploy-checklist/SKILL.md +9 -2
  93. package/skills/documentation/SKILL.md +12 -1
  94. package/skills/draft/SKILL.md +40 -29
  95. package/skills/draft/context-files.md +8 -1
  96. package/skills/draft/quality-guide.md +10 -2
  97. package/skills/graph/SKILL.md +1 -1
  98. package/skills/impact/SKILL.md +3 -1
  99. package/skills/implement/SKILL.md +60 -18
  100. package/skills/incident-response/SKILL.md +5 -2
  101. package/skills/init/SKILL.md +102 -23
  102. package/skills/init/references/architecture-spec.md +31 -7
  103. package/skills/init/references/okf-emitter.md +3 -3
  104. package/skills/jira/SKILL.md +33 -13
  105. package/skills/jira/references/review.md +61 -19
  106. package/skills/learn/SKILL.md +29 -6
  107. package/skills/new-track/SKILL.md +73 -18
  108. package/skills/quick-review/SKILL.md +7 -2
  109. package/skills/revert/SKILL.md +11 -5
  110. package/skills/review/SKILL.md +123 -24
  111. package/skills/review/references/zero-setup-mode.md +117 -0
  112. package/skills/standup/SKILL.md +9 -1
  113. package/skills/status/SKILL.md +6 -6
  114. package/skills/tech-debt/SKILL.md +7 -1
  115. package/skills/testing-strategy/SKILL.md +10 -2
  116. package/skills/tour/SKILL.md +2 -1
  117. package/skills/upload/SKILL.md +3 -2
@@ -15,7 +15,7 @@ It owns the common execution loop and absorbs three adjacent commands when appro
15
15
  - `/draft:coverage`
16
16
  - `/draft:revert`
17
17
 
18
- ## Red Flags - STOP if you're:
18
+ ## Red Flags - STOP if you're
19
19
 
20
20
  - Implementing without an approved spec and plan
21
21
  - Skipping TDD cycle when workflow.md has TDD enabled
@@ -152,9 +152,11 @@ If one of these applies, route directly to the specialist workflow and stop this
152
152
  10. Update the track's entry in `draft/tracks.md` from `[ ]` to `[~]` In Progress
153
153
 
154
154
  If no active track found:
155
+
155
156
  - Tell user: "No active track found. Run `/draft:plan` to create or resume planned work."
156
157
 
157
158
  **Architecture / Design Mode Activation:**
159
+
158
160
  - Automatically enabled when `.ai-context.md`, graph-primary `architecture.md`, or track `hld.md`/`lld.md` exists.
159
161
  - Project-level context from `/draft:init`.
160
162
  - Track-level design docs from `/draft:decompose`.
@@ -168,21 +170,25 @@ Run once, before the first task of a new track:
168
170
  ### AC Coverage Check
169
171
 
170
172
  For each acceptance criterion in `spec.md`:
173
+
171
174
  - Verify at least one task in `plan.md` references or addresses it
172
175
  - If an AC has no corresponding task, flag it: "⚠️ AC: '[criterion]' has no task in plan.md"
173
176
 
174
177
  ### Sync Check (if `.ai-context.md` exists)
175
178
 
176
179
  Compare the `synced_to_commit` values in the YAML frontmatter of `spec.md` and `plan.md`.
180
+
177
181
  - **Skip if** either file has no YAML frontmatter or no `synced_to_commit` field (quick-mode tracks omit it).
178
182
  - If they differ: "⚠️ Spec and plan were synced to different commits — verify they are still aligned."
179
183
 
180
184
  ### Result
181
185
 
182
186
  **Issues found:** List them, then ask:
183
- ```
187
+
188
+ ```text
184
189
  Readiness issues found (see above). Proceed anyway or update first? [proceed/update]
185
190
  ```
191
+
186
192
  - `proceed` → add a `## Notes` entry in `plan.md` listing the issues, then continue to Step 2
187
193
  - `update` → stop here and let the user refine spec or plan before re-running
188
194
 
@@ -201,7 +207,8 @@ Before starting TDD cycle for the first task:
201
207
  ### Bug Track Test Guardrail
202
208
 
203
209
  If track type is `bugfix` (from metadata.json):
204
- ```
210
+
211
+ ```text
205
212
  BEFORE writing any test file:
206
213
  ASK: "This is a bug fix track. Want me to write tests as part of the fix? [Y/n]"
207
214
  If declined: skip TDD cycle, note in plan.md: "Tests: developer-handled"
@@ -210,12 +217,14 @@ BEFORE writing any test file:
210
217
  ## Step 2: Find Next Task
211
218
 
212
219
  Scan `plan.md` for the first uncompleted task:
220
+
213
221
  - `[ ]` = Pending (pick this one)
214
222
  - `[~]` = In Progress (resume this one)
215
223
  - `[x]` = Completed (skip)
216
224
  - `[!]` = Blocked (skip - requires manual intervention)
217
225
 
218
226
  **IMPORTANT:** If blocked task found, notify user:
227
+
219
228
  - "Task [task description] is marked `[!]` Blocked"
220
229
  - Show the blocked task details and recovery message
221
230
  - "Resolve the blockage manually before continuing implementation"
@@ -274,7 +283,7 @@ When the next task involves creating or substantially modifying a code file:
274
283
 
275
284
  ### Story Format
276
285
 
277
- ```
286
+ ```text
278
287
  // Story: [Module/File Name]
279
288
  //
280
289
  // Input: [what this module/function receives]
@@ -320,7 +329,8 @@ Study the control flow for the task and propose intermediate state variables:
320
329
  5. Propose execution state: input state, intermediate state, output state, error state
321
330
 
322
331
  Present in this format:
323
- ```
332
+
333
+ ```text
324
334
  EXECUTION STATE: [Task/Module Name]
325
335
  ─────────────────────────────────────────────────────────
326
336
  Input State:
@@ -435,12 +445,13 @@ For each task, follow this workflow based on `workflow.md`. If skeletons were ge
435
445
 
436
446
  When refactoring code that lacks tests, write characterization tests first to capture current behavior as a baseline. Identify seams (interfaces for test doubles, swappable imports), record actual outputs for representative inputs, then proceed with the TDD cycle for new behavior.
437
447
 
438
- ### If TDD Enabled:
448
+ ### If TDD Enabled
439
449
 
440
450
  **Iron Law:** No production code without a failing test first.
441
451
 
442
452
  **3a. RED - Write Failing Test**
443
- ```
453
+
454
+ ```text
444
455
  1. Create/update test file as specified in task
445
456
  2. Write test that captures the requirement
446
457
  3. RUN test - VERIFY it FAILS (not syntax error, actual assertion failure)
@@ -449,6 +460,7 @@ When refactoring code that lacks tests, write characterization tests first to ca
449
460
  ```
450
461
 
451
462
  **Test Quality Checklist (REQUIRED for every test):**
463
+
452
464
  - No shared mutable state between test cases — each test sets up its own state
453
465
  - Assertion density: every test must have at least one meaningful assertion (not just `assertTrue(true)`)
454
466
  - No logic in tests: no conditionals, loops, or try/catch in test code — tests should be trivially readable
@@ -461,7 +473,8 @@ When refactoring code that lacks tests, write characterization tests first to ca
461
473
  After writing example-based tests, consider property-based tests for pure functions (algebraic properties, round-trip serialization, sort invariants). Not mandatory — skip if properties are not obvious.
462
474
 
463
475
  **3b. GREEN - Implement Minimum Code**
464
- ```
476
+
477
+ ```text
465
478
  1. Write MINIMUM code to make test pass (no extras)
466
479
  2. RUN test - VERIFY it PASSES
467
480
  3. Show test output with pass
@@ -475,7 +488,8 @@ Structured logging at decision points, metrics for latency-sensitive ops, tracin
475
488
  For new API endpoints or service-to-service interfaces, suggest consumer-driven contract tests. Skip for purely internal modules.
476
489
 
477
490
  **3c. REFACTOR - Clean with Tests Green**
478
- ```
491
+
492
+ ```text
479
493
  1. Review code for improvements
480
494
  2. Refactor while keeping tests green
481
495
  3. RUN all related tests after each change
@@ -484,15 +498,17 @@ For new API endpoints or service-to-service interfaces, suggest consumer-driven
484
498
  ```
485
499
 
486
500
  **Red Flags - STOP and restart the cycle if:**
501
+
487
502
  - About to write code before test exists
488
503
  - Test passes immediately (testing wrong thing)
489
504
  - Thinking "just this once" or "too simple to test"
490
505
  - Running tests mentally instead of actually executing
491
506
 
492
- ### If TDD Not Enabled:
507
+ ### If TDD Not Enabled
493
508
 
494
509
  **3a. Implement**
495
- ```
510
+
511
+ ```text
496
512
  1. Implement the task as specified
497
513
  2. Test manually or run existing tests
498
514
  3. Announce: "Implementation complete"
@@ -571,6 +587,7 @@ Before marking ANY task/phase/track complete:
571
587
  - If **YES**: Show evidence, then mark `[x]`
572
588
 
573
589
  **Red Flags - STOP if you're thinking:**
590
+
574
591
  - "Should pass", "probably works"
575
592
  - Satisfaction before running verification
576
593
  - About to mark `[x]` without fresh evidence from this session
@@ -588,16 +605,19 @@ When all tasks in a phase are `[x]`:
588
605
  ### Three-Stage Review (REQUIRED)
589
606
 
590
607
  **Stage 1: Automated Validation**
608
+
591
609
  - Fast static checks: architecture conformance, dead code, circular dependencies, performance anti-patterns. Review for common security anti-patterns (OWASP top 10). For automated checks, use language-specific tools (e.g., `npm audit` for JS, `bandit` for Python, `cargo audit` for Rust).
592
610
  - **If critical issues found:** List them, return to implementation
593
611
 
594
612
  **Stage 2: Spec Compliance** (only if Stage 1 passes)
613
+
595
614
  - Load track's `spec.md`
596
615
  - Verify all requirements for this phase are implemented
597
616
  - Check acceptance criteria coverage
598
617
  - **If gaps found:** List them, return to implementation
599
618
 
600
619
  **Stage 3: Code Quality** (only if Stage 2 passes)
620
+
601
621
  - Verify code follows project patterns (tech-stack.md)
602
622
  - Check error handling is appropriate
603
623
  - Verify tests cover real logic
@@ -608,12 +628,14 @@ See `core/agents/reviewer.md` for detailed review process.
608
628
  ### Quick Review Alternative
609
629
 
610
630
  At phase boundaries, offer the lightweight alternative:
611
- ```
631
+
632
+ ```text
612
633
  "Phase {N} complete. Review options:
613
634
  1. Full three-stage review (recommended) — spec compliance + security + quality
614
635
  2. /draft:quick-review — lightweight 4-dimension check (faster)
615
636
  Choose [1/2, default: 1]:"
616
637
  ```
638
+
617
639
  If quick-review chosen, invoke `/draft:quick-review` with the phase's changed files.
618
640
 
619
641
  2. Run verification steps from plan (tests, builds)
@@ -632,12 +654,15 @@ If quick-review chosen, invoke `/draft:quick-review` with the phase's changed fi
632
654
  After a phase passes review, refresh `metadata.json.impact` so future tracks can detect overlap with this work.
633
655
 
634
656
  1. **Compute touched files:** From `plan.md`, find the first commit SHA recorded for this track (earliest `[x]` line with `(<sha>)`). Run:
657
+
635
658
  ```bash
636
659
  git diff --name-only <first_sha>^..HEAD
637
660
  ```
661
+
638
662
  That is the `files_touched` list. Derive `modules_touched` as the unique top-level path segments (e.g. `auth/login.go` → `auth`).
639
663
 
640
664
  2. **Compute downstream blast radius (graph-aware, optional):** If `draft/graph/schema.yaml` exists, for each file in `files_touched` query (this runs in its own Bash session — re-resolve the helpers):
665
+
641
666
  ```bash
642
667
  DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
643
668
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
@@ -645,6 +670,7 @@ After a phase passes review, refresh `metadata.json.impact` so future tracks can
645
670
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
646
671
  "$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path>
647
672
  ```
673
+
648
674
  Aggregate across all files: `downstream_files` = total unique downstream files (deduped), `downstream_modules` = union of `affected_modules`, `max_depth` = max across queries, `by_category` = sum of each query's `by_category`. If the graph is absent, leave these fields as zeros / empty arrays — the snapshot still records the directly-touched files.
649
675
 
650
676
  3. **Write metadata.json** with the populated `impact` block and `computed_at` set to the current timestamp.
@@ -658,10 +684,12 @@ When all phases complete:
658
684
  1. **Run review (if enabled):**
659
685
  - Read `draft/workflow.md` review configuration
660
686
  - Check if auto-review enabled:
687
+
661
688
  ```markdown
662
689
  ## Review Settings
663
690
  - [x] Auto-review at track completion
664
691
  ```
692
+
665
693
  - If enabled, run `/draft:review track <track_id>`
666
694
  - Check review results:
667
695
  - If block-on-failure enabled AND critical issues found → HALT, require fixes
@@ -687,6 +715,7 @@ When all phases complete:
687
715
  "Track <track_id> completed!
688
716
 
689
717
  Summary:
718
+
690
719
  - Phases: N/N
691
720
  - Tasks: M/M
692
721
  - Duration: [if tracked]
@@ -702,6 +731,7 @@ Next: Run `/draft:status` to see project overview."
702
731
  ## Error Handling
703
732
 
704
733
  **If blocked:**
734
+
705
735
  - Mark task as `[!]` Blocked
706
736
  - Add reason in plan.md
707
737
  - **REQUIRED:** Follow systematic debugging process (see `core/agents/debugger.md`)
@@ -713,18 +743,22 @@ Next: Run `/draft:status` to see project overview."
713
743
  - Document root cause when found
714
744
 
715
745
  **Recommended:** Instead of inline debugging, invoke `/draft:debug` skill for a structured session:
716
- ```
746
+
747
+ ```text
717
748
  "Task blocked: {description}. Run /draft:debug for structured investigation? [Y/n]"
718
749
  ```
750
+
719
751
  The debug skill provides: Reproduce → Isolate → Diagnose → Fix methodology with debug report output.
720
752
 
721
753
  **If test fails unexpectedly:**
754
+
722
755
  - Don't mark complete
723
756
  - Follow systematic debugging process above
724
757
  - Announce failure details with root cause analysis
725
758
  - Show evidence when resolved
726
759
 
727
760
  **If unsure about implementation:**
761
+
728
762
  - Ask clarifying questions
729
763
  - Reference spec.md for requirements
730
764
  - Don't proceed with assumptions
@@ -748,6 +782,7 @@ When you encounter a shortcut, workaround, or known-imperfect solution during im
748
782
  ```
749
783
 
750
784
  **Severity levels:**
785
+
751
786
  - **Low** — Cosmetic or minor maintainability issue
752
787
  - **Medium** — Will cause problems at scale or in specific scenarios
753
788
  - **High** — Actively impeding development or risking production issues
@@ -761,7 +796,8 @@ Only log genuine debt — intentional shortcuts with known consequences. Not eve
761
796
  ## Progress Reporting
762
797
 
763
798
  After each task, report:
764
- ```
799
+
800
+ ```yaml
765
801
  Task: [description]
766
802
  Status: Complete
767
803
  Phase Progress: N/M tasks
@@ -777,34 +813,40 @@ Overall: X% complete
777
813
  After announcing track completion, suggest relevant follow-ups based on context:
778
814
 
779
815
  **If track modifies production code:**
780
- ```
816
+
817
+ ```text
781
818
  "Track complete! Consider:
782
819
  → /draft:deploy-checklist — Pre-deployment verification"
783
820
  ```
784
821
 
785
822
  **If track added new APIs/services/components:**
786
- ```
823
+
824
+ ```text
787
825
  → /draft:documentation — Update documentation for new components"
788
826
  ```
789
827
 
790
828
  **If implementation contains TODO/FIXME/HACK comments:**
791
- ```
829
+
830
+ ```text
792
831
  → /draft:tech-debt — Catalog any new technical debt introduced"
793
832
  ```
794
833
 
795
834
  **If new patterns or dependencies not in tech-stack.md:**
796
- ```
835
+
836
+ ```text
797
837
  → /draft:adr — Document this design decision"
798
838
  ```
799
839
 
800
840
  ### Jira Sync at Completion
801
841
 
802
842
  If Jira ticket linked, sync via `core/shared/jira-sync.md`:
843
+
803
844
  - Post comment: "[draft] implementation-complete: All {n} tasks done. Ready for review."
804
845
 
805
846
  ### Bug Track with rca.md
806
847
 
807
848
  If implementing a bug track and `draft/tracks/<id>/rca.md` exists:
849
+
808
850
  - Load rca.md as context for the implementation
809
851
  - Reference root cause, blast radius, and prevention items during fix
810
852
  - After fix: update rca.md "Proposed Fix" section with actual fix details
@@ -7,7 +7,7 @@ description: Incident management lifecycle — triage, communicate, mitigate, po
7
7
 
8
8
  You are managing an incident through its full lifecycle using structured incident management practices.
9
9
 
10
- ## Red Flags — STOP if you're:
10
+ ## Red Flags — STOP if you're
11
11
 
12
12
  - Fixing before communicating (stakeholders must know first)
13
13
  - Skipping severity classification
@@ -22,6 +22,7 @@ You are managing an incident through its full lifecycle using structured inciden
22
22
  ## Pre-Check
23
23
 
24
24
  1. Check for Draft context:
25
+
25
26
  ```bash
26
27
  ls draft/ 2>/dev/null
27
28
  ```
@@ -53,6 +54,7 @@ Classify severity:
53
54
  | **SEV4** | Next business day | Assigned engineer | Cosmetic issue, minor inconvenience |
54
55
 
55
56
  Assess:
57
+
56
58
  1. **What is broken?** (from description or Jira ticket)
57
59
  2. **Who is affected?** (from `draft/product.md` user types if available)
58
60
  3. **What is the blast radius?** (from `draft/.ai-context.md` service topology if available)
@@ -62,7 +64,7 @@ Assess:
62
64
 
63
65
  Generate initial status update:
64
66
 
65
- ```
67
+ ```yaml
66
68
  INCIDENT: {description}
67
69
  Severity: SEV{1-4}
68
70
  Impact: {who/what is affected}
@@ -228,6 +230,7 @@ Or track-scoped: `draft/tracks/<id>/postmortem.md`
228
230
  ### Step 5: Jira Sync
229
231
 
230
232
  Follow `core/shared/jira-sync.md`:
233
+
231
234
  - Attach postmortem to Jira ticket
232
235
  - Post comment: "[draft] Postmortem complete. Root cause: {1-line summary}. {N} action items."
233
236