@hivehub/rulebook 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/.claude/commands/analysis.md +35 -0
  2. package/.claude/commands/rulebook-task-apply.md +7 -25
  3. package/.claude/commands/rulebook-task-archive.md +10 -19
  4. package/.claude/commands/rulebook-task-create.md +1 -1
  5. package/README.md +354 -965
  6. package/dist/cli/commands/analysis.d.ts +8 -0
  7. package/dist/cli/commands/analysis.d.ts.map +1 -0
  8. package/dist/cli/commands/analysis.js +78 -0
  9. package/dist/cli/commands/analysis.js.map +1 -0
  10. package/dist/cli/commands/context-intelligence.d.ts +33 -0
  11. package/dist/cli/commands/context-intelligence.d.ts.map +1 -0
  12. package/dist/cli/commands/context-intelligence.js +181 -0
  13. package/dist/cli/commands/context-intelligence.js.map +1 -0
  14. package/dist/cli/commands/index.d.ts +19 -0
  15. package/dist/cli/commands/index.d.ts.map +1 -0
  16. package/dist/cli/commands/index.js +19 -0
  17. package/dist/cli/commands/index.js.map +1 -0
  18. package/dist/cli/commands/init.d.ts +15 -0
  19. package/dist/cli/commands/init.d.ts.map +1 -0
  20. package/dist/cli/commands/init.js +608 -0
  21. package/dist/cli/commands/init.js.map +1 -0
  22. package/dist/cli/commands/mcp.d.ts +10 -0
  23. package/dist/cli/commands/mcp.d.ts.map +1 -0
  24. package/dist/cli/commands/mcp.js +128 -0
  25. package/dist/cli/commands/mcp.js.map +1 -0
  26. package/dist/cli/commands/memory.d.ts +24 -0
  27. package/dist/cli/commands/memory.d.ts.map +1 -0
  28. package/dist/cli/commands/memory.js +265 -0
  29. package/dist/cli/commands/memory.js.map +1 -0
  30. package/dist/cli/commands/misc.d.ts +33 -0
  31. package/dist/cli/commands/misc.d.ts.map +1 -0
  32. package/dist/cli/commands/misc.js +576 -0
  33. package/dist/cli/commands/misc.js.map +1 -0
  34. package/dist/cli/commands/plans.d.ts +15 -0
  35. package/dist/cli/commands/plans.d.ts.map +1 -0
  36. package/dist/cli/commands/plans.js +266 -0
  37. package/dist/cli/commands/plans.js.map +1 -0
  38. package/dist/cli/commands/ralph.d.ts +45 -0
  39. package/dist/cli/commands/ralph.d.ts.map +1 -0
  40. package/dist/cli/commands/ralph.js +694 -0
  41. package/dist/cli/commands/ralph.js.map +1 -0
  42. package/dist/cli/commands/skills.d.ts +9 -0
  43. package/dist/cli/commands/skills.d.ts.map +1 -0
  44. package/dist/cli/commands/skills.js +249 -0
  45. package/dist/cli/commands/skills.js.map +1 -0
  46. package/dist/cli/commands/task.d.ts +16 -0
  47. package/dist/cli/commands/task.d.ts.map +1 -0
  48. package/dist/cli/commands/task.js +256 -0
  49. package/dist/cli/commands/task.js.map +1 -0
  50. package/dist/cli/commands/update.d.ts +14 -0
  51. package/dist/cli/commands/update.d.ts.map +1 -0
  52. package/dist/cli/commands/update.js +636 -0
  53. package/dist/cli/commands/update.js.map +1 -0
  54. package/dist/cli/commands/workspace.d.ts +6 -0
  55. package/dist/cli/commands/workspace.d.ts.map +1 -0
  56. package/dist/cli/commands/workspace.js +141 -0
  57. package/dist/cli/commands/workspace.js.map +1 -0
  58. package/dist/core/agent-template-engine.js +28 -28
  59. package/dist/core/analysis-manager.d.ts +56 -0
  60. package/dist/core/analysis-manager.d.ts.map +1 -0
  61. package/dist/core/analysis-manager.js +218 -0
  62. package/dist/core/analysis-manager.js.map +1 -0
  63. package/dist/core/claude-md-generator.d.ts +52 -0
  64. package/dist/core/claude-md-generator.d.ts.map +1 -0
  65. package/dist/core/claude-md-generator.js +104 -0
  66. package/dist/core/claude-md-generator.js.map +1 -0
  67. package/dist/core/claude-settings-manager.d.ts +37 -0
  68. package/dist/core/claude-settings-manager.d.ts.map +1 -0
  69. package/dist/core/claude-settings-manager.js +168 -0
  70. package/dist/core/claude-settings-manager.js.map +1 -0
  71. package/dist/core/compact-context-manager.d.ts +34 -0
  72. package/dist/core/compact-context-manager.d.ts.map +1 -0
  73. package/dist/core/compact-context-manager.js +60 -0
  74. package/dist/core/compact-context-manager.js.map +1 -0
  75. package/dist/core/doctor.d.ts +19 -0
  76. package/dist/core/doctor.d.ts.map +1 -0
  77. package/dist/core/doctor.js +163 -0
  78. package/dist/core/doctor.js.map +1 -0
  79. package/dist/core/generator.js +28 -28
  80. package/dist/core/mcp-reference-generator.d.ts +13 -0
  81. package/dist/core/mcp-reference-generator.d.ts.map +1 -0
  82. package/dist/core/mcp-reference-generator.js +66 -0
  83. package/dist/core/mcp-reference-generator.js.map +1 -0
  84. package/dist/core/merger.d.ts +35 -0
  85. package/dist/core/merger.d.ts.map +1 -1
  86. package/dist/core/merger.js +120 -0
  87. package/dist/core/merger.js.map +1 -1
  88. package/dist/core/prd-generator.d.ts.map +1 -1
  89. package/dist/core/prd-generator.js +7 -1
  90. package/dist/core/prd-generator.js.map +1 -1
  91. package/dist/core/ralph-manager.d.ts.map +1 -1
  92. package/dist/core/ralph-manager.js +17 -0
  93. package/dist/core/ralph-manager.js.map +1 -1
  94. package/dist/core/rules-generator.d.ts +73 -0
  95. package/dist/core/rules-generator.d.ts.map +1 -0
  96. package/dist/core/rules-generator.js +201 -0
  97. package/dist/core/rules-generator.js.map +1 -0
  98. package/dist/core/state-writer.d.ts +35 -0
  99. package/dist/core/state-writer.d.ts.map +1 -0
  100. package/dist/core/state-writer.js +81 -0
  101. package/dist/core/state-writer.js.map +1 -0
  102. package/dist/core/task-manager.d.ts +35 -0
  103. package/dist/core/task-manager.d.ts.map +1 -1
  104. package/dist/core/task-manager.js +135 -38
  105. package/dist/core/task-manager.js.map +1 -1
  106. package/dist/core/telemetry.d.ts +29 -0
  107. package/dist/core/telemetry.d.ts.map +1 -0
  108. package/dist/core/telemetry.js +57 -0
  109. package/dist/core/telemetry.js.map +1 -0
  110. package/dist/core/workflow-generator.d.ts.map +1 -1
  111. package/dist/core/workflow-generator.js +2 -177
  112. package/dist/core/workflow-generator.js.map +1 -1
  113. package/dist/index.js +28 -1
  114. package/dist/index.js.map +1 -1
  115. package/dist/mcp/rulebook-server.d.ts.map +1 -1
  116. package/dist/mcp/rulebook-server.js +190 -7
  117. package/dist/mcp/rulebook-server.js.map +1 -1
  118. package/dist/memory/memory-store.js +91 -91
  119. package/dist/types.d.ts +11 -0
  120. package/dist/types.d.ts.map +1 -1
  121. package/dist/utils/gitignore.d.ts +10 -0
  122. package/dist/utils/gitignore.d.ts.map +1 -0
  123. package/dist/utils/gitignore.js +38 -0
  124. package/dist/utils/gitignore.js.map +1 -0
  125. package/package.json +1 -1
  126. package/templates/compact-context/_default.md +23 -0
  127. package/templates/compact-context/cpp.md +26 -0
  128. package/templates/compact-context/go.md +26 -0
  129. package/templates/compact-context/python.md +26 -0
  130. package/templates/compact-context/rust.md +28 -0
  131. package/templates/compact-context/typescript.md +29 -0
  132. package/templates/core/CLAUDE_MD_v2.md +71 -0
  133. package/templates/hooks/check-context-and-handoff.ps1 +50 -0
  134. package/templates/hooks/check-context-and-handoff.sh +69 -0
  135. package/templates/hooks/enforce-mcp-for-tasks.sh +31 -0
  136. package/templates/hooks/enforce-no-deferred.sh +21 -0
  137. package/templates/hooks/enforce-no-shortcuts.sh +31 -0
  138. package/templates/hooks/enforce-team-for-background-agents.ps1 +63 -0
  139. package/templates/hooks/enforce-team-for-background-agents.sh +55 -0
  140. package/templates/hooks/on-compact-reinject.sh +34 -0
  141. package/templates/hooks/resume-from-handoff.ps1 +33 -0
  142. package/templates/hooks/resume-from-handoff.sh +55 -0
  143. package/templates/rules/consult-analysis-before-implementing.md +23 -0
  144. package/templates/rules/cpp.md +46 -0
  145. package/templates/rules/csharp.md +44 -0
  146. package/templates/rules/diagnostic-first.md +39 -0
  147. package/templates/rules/fail-twice-escalate.md +46 -0
  148. package/templates/rules/go.md +40 -0
  149. package/templates/rules/java.md +43 -0
  150. package/templates/rules/javascript.md +39 -0
  151. package/templates/rules/multi-agent-teams.md +75 -0
  152. package/templates/rules/python.md +43 -0
  153. package/templates/rules/respect-handoff-trigger.md +41 -0
  154. package/templates/rules/rust.md +40 -0
  155. package/templates/rules/typescript.md +40 -0
  156. package/templates/skills/dev/analysis/SKILL.md +19 -0
  157. package/templates/skills/dev/handoff/SKILL.md +27 -0
@@ -0,0 +1,35 @@
1
+ # /analysis — Structured analysis workflow
2
+
3
+ Create a structured analysis for a topic. Scaffolds `docs/analysis/<slug>/` with skeleton files (README.md, findings.md, execution-plan.md, manifest.json).
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /analysis <topic>
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ 1. Slugifies the topic (e.g. "Auth Refactor v2" → `auth-refactor-v2`)
14
+ 2. Creates `docs/analysis/<slug>/` with:
15
+ - **README.md** — executive summary, methodology, conclusion
16
+ - **findings.md** — numbered findings F-001..F-NNN (title, evidence, impact, confidence)
17
+ - **execution-plan.md** — phased implementation plan
18
+ - **manifest.json** — metadata (agents, timestamps, version)
19
+ 3. Idempotent: re-running updates manifest but preserves user-edited content files
20
+
21
+ ## After scaffolding
22
+
23
+ 1. Fill `findings.md` with investigation results
24
+ 2. Design the phases in `execution-plan.md`
25
+ 3. Create implementation tasks from the plan: `rulebook task create phase1_<slug>-<name>`
26
+ 4. Each task should reference the analysis: `Source: docs/analysis/<slug>/README.md#F-NNN`
27
+ 5. Before implementing, consult the knowledge base: `rulebook_knowledge_list` filtered by `analysis:<slug>`
28
+
29
+ ## MCP equivalent
30
+
31
+ ```
32
+ rulebook_analysis_create({ topic: "<topic>" })
33
+ rulebook_analysis_list()
34
+ rulebook_analysis_show({ slug: "<slug>" })
35
+ ```
@@ -14,35 +14,24 @@ description: Implement an approved Rulebook task and keep tasks checklist in syn
14
14
  **Steps**
15
15
  Track these steps as TODOs and complete them one by one.
16
16
 
17
- 1. **Check Knowledge Base FIRST (MANDATORY)**:
18
- Before writing any code, search for relevant patterns and anti-patterns:
19
- ```bash
20
- rulebook knowledge list
21
- ```
22
- Also search learnings related to this area:
23
- ```bash
24
- rulebook learn list
25
- ```
26
- Apply any relevant patterns. Avoid any documented anti-patterns.
27
-
28
- 2. **Read Task Details**:
17
+ 1. **Read Task Details**:
29
18
  ```bash
30
19
  rulebook task show <task-id>
31
20
  ```
32
21
  Read `proposal.md`, `design.md` (if present), and `tasks.md` to confirm scope and acceptance criteria.
33
22
 
34
- 3. **Follow Priority Order (MANDATORY)**:
23
+ 2. **Follow Priority Order (MANDATORY)**:
35
24
  - **Tests** (HIGHEST PRIORITY) - Write tests first
36
25
  - **Coverage Verification** (CRITICAL) - Verify coverage ≥95%
37
26
  - **Update Task Status** (MANDATORY) - Mark completed items as `[x]` in `tasks.md`
38
27
  - **Next Task** (Only after above steps)
39
28
 
40
- 4. **Work Through Tasks Sequentially**:
29
+ 3. **Work Through Tasks Sequentially**:
41
30
  - Work through `tasks.md` checklist item by item
42
31
  - Keep edits minimal and focused on the requested change
43
32
  - Follow priority order (most critical first)
44
33
 
45
- 5. **After Each Implementation Step**:
34
+ 4. **After Each Implementation Step**:
46
35
  - ✅ Implement the feature
47
36
  - ✅ Test the implementation
48
37
  - ✅ Verify test coverage (run `npm test -- --coverage`)
@@ -50,7 +39,7 @@ Track these steps as TODOs and complete them one by one.
50
39
  - ✅ Commit locally (backup)
51
40
  - ✅ Only then proceed to next task
52
41
 
53
- 6. **Update Tasks Checklist**:
42
+ 5. **Update Tasks Checklist**:
54
43
  After completing and testing each item:
55
44
  ```markdown
56
45
  ## 1. Implementation Phase
@@ -59,24 +48,17 @@ Track these steps as TODOs and complete them one by one.
59
48
  - [ ] 1.3 Add archive functionality <!-- next: will start after status update -->
60
49
  ```
61
50
 
62
- 7. **Confirm Completion**:
51
+ 6. **Confirm Completion**:
63
52
  - Make sure every item in `tasks.md` is finished
64
53
  - All tests pass
65
54
  - Coverage meets thresholds
66
55
  - Documentation updated
67
56
 
68
- 8. **Update Checklist After All Work**:
57
+ 7. **Update Checklist After All Work**:
69
58
  - Mark each completed task as `[x]`
70
59
  - Add comments with test status and coverage
71
60
  - Reflect reality in the checklist
72
61
 
73
- 9. **Capture Learnings (MANDATORY)**:
74
- After completing the task, record what you learned:
75
- - **Patterns that worked** → `rulebook knowledge add pattern "<title>" --category <cat>`
76
- - **Anti-patterns discovered** → `rulebook knowledge add anti-pattern "<title>" --category <cat>`
77
- - **Debugging insights** → `rulebook learn capture --title "<title>" --content "<what you learned>"`
78
- - If nothing significant was learned, record at minimum: `rulebook learn capture --title "Completed <task-id>" --content "Implemented <summary>. No unexpected issues."`
79
-
80
62
  **Reference**
81
63
  - Use `rulebook task show <task-id>` when additional context is required
82
64
  - Use `rulebook task validate <task-id>` to check format before archiving
@@ -11,22 +11,13 @@ description: Archive a completed Rulebook task and apply spec deltas to main spe
11
11
  - Refer to `/.rulebook/specs/RULEBOOK.md` for complete task management guidelines.
12
12
 
13
13
  **Steps**
14
- 1. **Capture Learnings BEFORE Archiving (MANDATORY)**:
15
- Before archiving, record what was learned during this task:
16
- - **Patterns discovered** → `rulebook knowledge add pattern "<title>" --category <cat> --description "<desc>"`
17
- - **Anti-patterns found** → `rulebook knowledge add anti-pattern "<title>" --category <cat> --description "<desc>"`
18
- - **Implementation learnings** → `rulebook learn capture --title "<title>" --content "<what you learned>"`
19
- - **Architectural decisions** → record via `rulebook decision create` if a significant design choice was made
20
-
21
- Minimum: at least ONE learning must be captured per task archive. If the task was trivial, record: `rulebook learn capture --title "Completed <task-id>" --content "<1-line summary of what was done>"`
22
-
23
- 2. **Verify Task Completion**:
14
+ 1. **Verify Task Completion**:
24
15
  - All items in `tasks.md` must be marked as `[x]`
25
16
  - All tests must pass
26
17
  - Code review complete (if applicable)
27
18
  - Documentation updated (README, CHANGELOG, specs)
28
19
 
29
- 3. **Run Quality Checks**:
20
+ 2. **Run Quality Checks**:
30
21
  ```bash
31
22
  npm test
32
23
  npm run lint
@@ -35,13 +26,13 @@ description: Archive a completed Rulebook task and apply spec deltas to main spe
35
26
  ```
36
27
  Ensure all checks pass before archiving.
37
28
 
38
- 4. **Validate Task Format**:
29
+ 3. **Validate Task Format**:
39
30
  ```bash
40
31
  rulebook task validate <task-id>
41
32
  ```
42
33
  Must pass all format checks.
43
34
 
44
- 5. **Archive Task**:
35
+ 4. **Archive Task**:
45
36
  ```bash
46
37
  rulebook task archive <task-id>
47
38
  ```
@@ -51,27 +42,27 @@ description: Archive a completed Rulebook task and apply spec deltas to main spe
51
42
  ```
52
43
  (Only use `--skip-validation` if you're certain the task is valid)
53
44
 
54
- 6. **Archive Process**:
45
+ 5. **Archive Process**:
55
46
  - Validates task format (unless skipped)
56
47
  - Checks task completion status
57
48
  - Applies spec deltas to main specifications
58
- - Moves task to `/.rulebook/archive/YYYY-MM-DD-<task-id>/`
49
+ - Moves task to `/.rulebook/tasks/archive/YYYY-MM-DD-<task-id>/`
59
50
  - Updates related specifications
60
51
 
61
- 7. **Verify Archive**:
52
+ 6. **Verify Archive**:
62
53
  ```bash
63
54
  rulebook task list --archived
64
55
  ```
65
56
  Task should appear in archived list.
66
57
 
67
- 8. **Post-Archive Actions**:
58
+ 7. **Post-Archive Actions**:
68
59
  - Ensure spec deltas are applied to main specifications
69
60
  - Update CHANGELOG.md with the change
70
61
  - Document any breaking changes
71
62
  - Create migration guides (if needed)
72
63
  - Unblock related tasks (if any)
73
64
 
74
- 9. **🚨 MANDATORY: Deferred Items → Tasks Rule**:
65
+ 8. **🚨 MANDATORY: Deferred Items → Tasks Rule**:
75
66
  **ABSOLUTE RULE — NO EXCEPTIONS**: Whenever a task is archived with items marked as "Deferred" or "Phase X+", you MUST immediately create Rulebook tasks for those deferred items **before archiving**.
76
67
 
77
68
  ```
@@ -81,7 +72,7 @@ description: Archive a completed Rulebook task and apply spec deltas to main spe
81
72
 
82
73
  ✅ CORRECT — defer with tracking:
83
74
  1. Add "- [ ] D1. feature X — deferred Phase 4" to tasks.md
84
- 2. Call rulebook_task_create("phase4_feature-x")
75
+ 2. Call rulebook_task_create("phase4-feature-x")
85
76
  3. Write tasks.md for the new task with full context
86
77
  4. THEN call rulebook_task_archive
87
78
  ```
@@ -24,7 +24,7 @@ description: Create a new Rulebook task following OpenSpec-compatible format wit
24
24
  - Review related code or docs (e.g., via `rg`/`ls`) to understand current behavior
25
25
  - Note any gaps that require clarification
26
26
 
27
- 3. **Choose Task ID**: MUST use phase prefix: `phase<N>[subletter]_<description>` in kebab-case (e.g., `phase1_add-feature`, `phase2a_fix-login`). Must be unique. Tasks must be sized to fit a single implementation cycle — if a task is too large, split it into multiple smaller tasks within the same phase or across phases.
27
+ 3. **Choose Task ID**: Use verb-led kebab-case (e.g., `add-feature`, `update-api`, `refactor-module`). Must be unique.
28
28
 
29
29
  4. **Create Task Structure**:
30
30
  ```bash