@hivehub/rulebook 4.3.1 → 4.4.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 (60) hide show
  1. package/.claude/commands/rulebook-decision-create.md +55 -0
  2. package/.claude/commands/rulebook-decision-list.md +15 -0
  3. package/.claude/commands/rulebook-knowledge-add.md +41 -0
  4. package/.claude/commands/rulebook-knowledge-list.md +15 -0
  5. package/.claude/commands/rulebook-learn-capture.md +48 -0
  6. package/.claude/commands/rulebook-learn-list.md +13 -0
  7. package/.claude/commands/rulebook-task-archive.md +24 -0
  8. package/.claude-plugin/plugin.json +1 -1
  9. package/README.md +8 -6
  10. package/dist/cli/commands.d.ts +32 -0
  11. package/dist/cli/commands.d.ts.map +1 -1
  12. package/dist/cli/commands.js +171 -0
  13. package/dist/cli/commands.js.map +1 -1
  14. package/dist/core/decision-manager.d.ts +25 -0
  15. package/dist/core/decision-manager.d.ts.map +1 -0
  16. package/dist/core/decision-manager.js +188 -0
  17. package/dist/core/decision-manager.js.map +1 -0
  18. package/dist/core/generator.d.ts.map +1 -1
  19. package/dist/core/generator.js +26 -0
  20. package/dist/core/generator.js.map +1 -1
  21. package/dist/core/indexer/background-indexer.d.ts +7 -0
  22. package/dist/core/indexer/background-indexer.d.ts.map +1 -1
  23. package/dist/core/indexer/background-indexer.js +45 -23
  24. package/dist/core/indexer/background-indexer.js.map +1 -1
  25. package/dist/core/knowledge-manager.d.ts +24 -0
  26. package/dist/core/knowledge-manager.d.ts.map +1 -0
  27. package/dist/core/knowledge-manager.js +173 -0
  28. package/dist/core/knowledge-manager.js.map +1 -0
  29. package/dist/core/learn-manager.d.ts +29 -0
  30. package/dist/core/learn-manager.d.ts.map +1 -0
  31. package/dist/core/learn-manager.js +159 -0
  32. package/dist/core/learn-manager.js.map +1 -0
  33. package/dist/core/workspace/project-worker.d.ts +9 -0
  34. package/dist/core/workspace/project-worker.d.ts.map +1 -1
  35. package/dist/core/workspace/project-worker.js +27 -0
  36. package/dist/core/workspace/project-worker.js.map +1 -1
  37. package/dist/index.js +68 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/mcp/rulebook-server.d.ts.map +1 -1
  40. package/dist/mcp/rulebook-server.js +498 -14
  41. package/dist/mcp/rulebook-server.js.map +1 -1
  42. package/dist/memory/memory-manager.d.ts +3 -0
  43. package/dist/memory/memory-manager.d.ts.map +1 -1
  44. package/dist/memory/memory-manager.js +18 -1
  45. package/dist/memory/memory-manager.js.map +1 -1
  46. package/dist/memory/memory-store.d.ts.map +1 -1
  47. package/dist/memory/memory-store.js +3 -1
  48. package/dist/memory/memory-store.js.map +1 -1
  49. package/dist/types.d.ts +43 -0
  50. package/dist/types.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/templates/agents/context-intelligence.md +52 -0
  53. package/templates/commands/rulebook-decision-create.md +55 -0
  54. package/templates/commands/rulebook-decision-list.md +15 -0
  55. package/templates/commands/rulebook-knowledge-add.md +41 -0
  56. package/templates/commands/rulebook-knowledge-list.md +15 -0
  57. package/templates/commands/rulebook-learn-capture.md +48 -0
  58. package/templates/commands/rulebook-learn-list.md +13 -0
  59. package/templates/core/DECISIONS.md +38 -0
  60. package/templates/core/KNOWLEDGE.md +49 -0
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: context-intelligence
3
+ model: haiku
4
+ description: Manages project decisions, knowledge base, and learnings. Use for capturing ADRs, patterns/anti-patterns, and post-implementation learnings.
5
+ tools: Read, Glob, Grep, Bash, Write, Edit
6
+ maxTurns: 15
7
+ ---
8
+
9
+ You are a context-intelligence agent. Your primary responsibility is managing the project's institutional knowledge: decisions, patterns, and learnings.
10
+
11
+ ## Responsibilities
12
+
13
+ - Create and manage Architecture Decision Records (ADRs) via `rulebook decision`
14
+ - Add patterns and anti-patterns to the knowledge base via `rulebook knowledge`
15
+ - Capture and promote learnings via `rulebook learn`
16
+ - Extract learnings from Ralph iteration history
17
+ - Ensure decisions have proper context, alternatives, and consequences
18
+
19
+ ## Workflow
20
+
21
+ ### When creating a decision:
22
+ 1. Check existing decisions: `rulebook decision list`
23
+ 2. Create: `rulebook decision create "<title>" --context "<context>"`
24
+ 3. Enrich the `.rulebook/decisions/NNN-<slug>.md` file with full details
25
+ 4. Verify: `rulebook decision show <id>`
26
+
27
+ ### When adding knowledge:
28
+ 1. Check existing entries: `rulebook knowledge list`
29
+ 2. Create: `rulebook knowledge add <pattern|anti-pattern> "<title>" --category <cat>`
30
+ 3. Enrich `.rulebook/knowledge/<type>s/<slug>.md` with examples and guidelines
31
+ 4. Verify: `rulebook knowledge show <slug>`
32
+
33
+ ### When capturing learnings:
34
+ 1. Capture: `rulebook learn capture --title "<title>" --content "<content>" --tags "tag1,tag2"`
35
+ 2. For Ralph learnings: `rulebook learn from-ralph`
36
+ 3. Promote significant learnings: `rulebook learn promote <id> knowledge|decision`
37
+
38
+ ## Standards
39
+
40
+ 1. Every decision MUST include context, the decision, alternatives, and consequences
41
+ 2. Patterns MUST include concrete code examples (not abstract descriptions)
42
+ 3. Anti-patterns MUST explain what to do instead
43
+ 4. Learnings should be captured immediately after discovery, not batched
44
+ 5. Use descriptive titles — they appear in AGENTS.md for AI context
45
+
46
+ ## Rules
47
+
48
+ - Do NOT modify production source code — only `.rulebook/` files
49
+ - Do NOT delete decisions — supersede or deprecate them
50
+ - Knowledge entries auto-appear in AGENTS.md after `rulebook update`
51
+ - Tag all entries for searchability
52
+ - When promoting a learning, verify the promoted entry is complete
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: /rulebook-decision-create
3
+ id: rulebook-decision-create
4
+ category: Rulebook
5
+ description: Create a new Architecture Decision Record (ADR) with auto-numbering and memory integration.
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Guardrails**
9
+ - Favor straightforward, minimal implementations first and add complexity only when it is requested or clearly required.
10
+ - Keep changes tightly scoped to the requested outcome.
11
+ - Decisions are stored in `.rulebook/decisions/` as numbered Markdown files with metadata sidecars.
12
+
13
+ **Steps**
14
+ 1. **Understand the Decision**: Ask the user what architectural/technical decision needs to be recorded. Gather:
15
+ - **Title**: Short, descriptive name (e.g., "Use PostgreSQL for Primary Database")
16
+ - **Context**: Why this decision is needed — constraints, requirements, trade-offs
17
+ - **Decision**: What was decided
18
+ - **Alternatives**: What other options were considered and why they were rejected
19
+ - **Consequences**: What follows from this decision (positive and negative)
20
+ - **Related Tasks**: Any task IDs this decision relates to
21
+
22
+ 2. **Check Existing Decisions**:
23
+ ```bash
24
+ rulebook decision list
25
+ ```
26
+ Verify no duplicate or conflicting decision exists.
27
+
28
+ 3. **Create the Decision**:
29
+ ```bash
30
+ rulebook decision create "<title>" --context "<context>" --related-task <task-id>
31
+ ```
32
+ The system auto-numbers the decision (e.g., ADR-001, ADR-002).
33
+
34
+ 4. **Enrich the Decision File**: Open the generated `.rulebook/decisions/NNN-<slug>.md` and fill in:
35
+ - Context section with full background
36
+ - Decision section with the chosen approach
37
+ - Alternatives Considered with reasoning for each rejected option
38
+ - Consequences with both positive and negative outcomes
39
+
40
+ 5. **Update Status** (if immediately accepted):
41
+ ```bash
42
+ # Via MCP tool or direct metadata edit
43
+ ```
44
+
45
+ 6. **Verify**:
46
+ ```bash
47
+ rulebook decision show <id>
48
+ ```
49
+
50
+ **Reference**
51
+ - Decisions use 4 statuses: `proposed` → `accepted` → `superseded` | `deprecated`
52
+ - Use `rulebook decision supersede <oldId> <newId>` to replace a decision
53
+ - Decisions are auto-injected into AGENTS.md on `rulebook update`
54
+ - See `/.rulebook/specs/DECISIONS.md` for format documentation
55
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: /rulebook-decision-list
3
+ id: rulebook-decision-list
4
+ category: Rulebook
5
+ description: List all Architecture Decision Records with optional status filter.
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Steps**
9
+ 1. Run `rulebook decision list` to see all decisions.
10
+ 2. Optionally filter: `rulebook decision list --status accepted`
11
+ 3. Present results to the user with ID, title, and status.
12
+ 4. If the user wants details on a specific decision, run `rulebook decision show <id>`.
13
+
14
+ **Status Values**: proposed, accepted, superseded, deprecated
15
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: /rulebook-knowledge-add
3
+ id: rulebook-knowledge-add
4
+ category: Rulebook
5
+ description: Add a pattern or anti-pattern to the project knowledge base.
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Guardrails**
9
+ - Knowledge entries are auto-injected into AGENTS.md on `rulebook update`, making them visible to all AI assistants.
10
+ - Patterns go to `.rulebook/knowledge/patterns/`, anti-patterns to `.rulebook/knowledge/anti-patterns/`.
11
+
12
+ **Steps**
13
+ 1. **Determine Type**: Ask if this is a `pattern` (good practice to follow) or `anti-pattern` (bad practice to avoid).
14
+
15
+ 2. **Gather Details**:
16
+ - **Title**: Short, descriptive name (e.g., "Repository Pattern", "God Object")
17
+ - **Category**: `architecture` | `code` | `testing` | `security` | `performance` | `devops`
18
+ - **Description**: What the pattern/anti-pattern is
19
+ - **Example**: Code showing correct (or incorrect) usage
20
+ - **When to Use**: Situations where this applies
21
+ - **When NOT to Use**: Exceptions and edge cases
22
+ - **Tags**: For searchability
23
+
24
+ 3. **Create Entry**:
25
+ ```bash
26
+ rulebook knowledge add <type> "<title>" --category <category> --description "<desc>"
27
+ ```
28
+
29
+ 4. **Enrich the Entry**: Open `.rulebook/knowledge/<type>s/<slug>.md` and fill in Example, When to Use, and When NOT to Use sections with concrete code examples.
30
+
31
+ 5. **Verify**:
32
+ ```bash
33
+ rulebook knowledge show <slug>
34
+ ```
35
+
36
+ **Reference**
37
+ - Use `rulebook knowledge list` to see all entries
38
+ - Use `rulebook knowledge list --type pattern --category architecture` to filter
39
+ - Use `rulebook knowledge remove <slug>` to delete an entry
40
+ - Entries appear in AGENTS.md "Project Knowledge" section after `rulebook update`
41
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: /rulebook-knowledge-list
3
+ id: rulebook-knowledge-list
4
+ category: Rulebook
5
+ description: List project knowledge entries (patterns and anti-patterns).
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Steps**
9
+ 1. Run `rulebook knowledge list` to see all entries.
10
+ 2. Optionally filter:
11
+ - By type: `rulebook knowledge list --type pattern`
12
+ - By category: `rulebook knowledge list --category architecture`
13
+ 3. Present results with type badge, title, and category.
14
+ 4. If the user wants details, run `rulebook knowledge show <slug>`.
15
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: /rulebook-learn-capture
3
+ id: rulebook-learn-capture
4
+ category: Rulebook
5
+ description: Capture a learning from implementation work for future reference.
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Guardrails**
9
+ - Learnings are saved to both the memory system and `.rulebook/learnings/` for offline backup.
10
+ - Learnings can be promoted to patterns/decisions later via `rulebook learn promote`.
11
+
12
+ **Steps**
13
+ 1. **Gather the Learning**:
14
+ - **Title**: Short description of what was learned
15
+ - **Content**: Full explanation — what happened, what was discovered, why it matters
16
+ - **Tags**: Keywords for searchability
17
+ - **Related Task**: Task ID if this learning came from a specific task
18
+ - **Source**: `manual` (default), `ralph`, or `task-archive`
19
+
20
+ 2. **Capture**:
21
+ ```bash
22
+ rulebook learn capture --title "<title>" --content "<content>" --tags "tag1,tag2" --related-task <task-id>
23
+ ```
24
+
25
+ 3. **Verify**:
26
+ ```bash
27
+ rulebook learn list --limit 5
28
+ ```
29
+
30
+ **Promotion Flow**
31
+ If a learning is significant enough to become a team pattern or decision:
32
+ ```bash
33
+ rulebook learn promote <id> knowledge # → creates a pattern
34
+ rulebook learn promote <id> decision # → creates an ADR
35
+ ```
36
+
37
+ **Ralph Integration**
38
+ Extract learnings from Ralph autonomous loop history:
39
+ ```bash
40
+ rulebook learn from-ralph
41
+ ```
42
+ This reads `.rulebook/ralph/history/iteration-*.json` and captures entries with non-empty learnings.
43
+
44
+ **Reference**
45
+ - Learnings are searchable via `rulebook memory search`
46
+ - Use `rulebook learn list` to see all learnings
47
+ - Learnings captured during `rulebook task archive` have source `task-archive`
48
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: /rulebook-learn-list
3
+ id: rulebook-learn-list
4
+ category: Rulebook
5
+ description: List captured learnings with source and promotion status.
6
+ ---
7
+ <!-- RULEBOOK:START -->
8
+ **Steps**
9
+ 1. Run `rulebook learn list` to see all learnings (newest first).
10
+ 2. Optionally limit: `rulebook learn list --limit 10`
11
+ 3. Present results with source badge (manual/ralph/archive) and promotion status.
12
+ 4. Suggest promotion for significant learnings: `rulebook learn promote <id> knowledge|decision`
13
+ <!-- RULEBOOK:END -->
@@ -0,0 +1,38 @@
1
+ # Decision Records
2
+
3
+ This project uses Architecture Decision Records (ADRs) to track important technical decisions.
4
+
5
+ ## Format
6
+
7
+ Decisions are stored in `.rulebook/decisions/` as numbered Markdown files:
8
+
9
+ ```
10
+ .rulebook/decisions/
11
+ ├── 001-use-postgres.md
12
+ ├── 001-use-postgres.metadata.json
13
+ ├── 002-api-rest-over-graphql.md
14
+ └── 002-api-rest-over-graphql.metadata.json
15
+ ```
16
+
17
+ ## Status Lifecycle
18
+
19
+ - **proposed** → Initial state when a decision is recorded
20
+ - **accepted** → Team has agreed on this decision
21
+ - **superseded** → Replaced by a newer decision (links to replacement)
22
+ - **deprecated** → No longer applicable
23
+
24
+ ## Commands
25
+
26
+ ```bash
27
+ rulebook decision create "Use PostgreSQL" # Create a new ADR
28
+ rulebook decision list # List all decisions
29
+ rulebook decision show 1 # Show full decision details
30
+ rulebook decision supersede 1 5 # Mark decision 1 as superseded by 5
31
+ ```
32
+
33
+ ## Rules
34
+
35
+ 1. Every significant architectural choice SHOULD have a decision record
36
+ 2. Decisions MUST include context, the decision itself, alternatives considered, and consequences
37
+ 3. Never delete a decision — supersede or deprecate it instead
38
+ 4. Reference related tasks when applicable
@@ -0,0 +1,49 @@
1
+ # Project Knowledge Base
2
+
3
+ This project maintains an explicit knowledge base of patterns and anti-patterns.
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ .rulebook/knowledge/
9
+ ├── patterns/ # Approved patterns to follow
10
+ │ ├── <slug>.md
11
+ │ └── <slug>.metadata.json
12
+ └── anti-patterns/ # Known anti-patterns to avoid
13
+ ├── <slug>.md
14
+ └── <slug>.metadata.json
15
+ ```
16
+
17
+ ## Entry Format
18
+
19
+ Each knowledge entry includes:
20
+ - **Description**: What the pattern/anti-pattern is
21
+ - **Example**: Code showing correct (or incorrect) usage
22
+ - **When to Use**: Situations where this pattern applies
23
+ - **When NOT to Use**: Exceptions and edge cases
24
+
25
+ ## Categories
26
+
27
+ - `architecture` — System-level design patterns
28
+ - `code` — Code-level patterns and idioms
29
+ - `testing` — Testing strategies and patterns
30
+ - `security` — Security patterns and practices
31
+ - `performance` — Performance optimization patterns
32
+ - `devops` — Infrastructure and deployment patterns
33
+
34
+ ## Commands
35
+
36
+ ```bash
37
+ rulebook knowledge add pattern "Repository Pattern" --category architecture
38
+ rulebook knowledge add anti-pattern "God Object" --category code
39
+ rulebook knowledge list --type pattern
40
+ rulebook knowledge show repository-pattern
41
+ rulebook knowledge remove god-object
42
+ ```
43
+
44
+ ## Rules
45
+
46
+ 1. Patterns added here are auto-injected into AGENTS.md on `rulebook update`
47
+ 2. AI assistants should follow patterns and avoid anti-patterns
48
+ 3. Include concrete examples — abstract descriptions are less useful
49
+ 4. Tag entries for searchability