@hivehub/rulebook 4.3.0 → 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.
- package/.claude/commands/rulebook-decision-create.md +55 -0
- package/.claude/commands/rulebook-decision-list.md +15 -0
- package/.claude/commands/rulebook-knowledge-add.md +41 -0
- package/.claude/commands/rulebook-knowledge-list.md +15 -0
- package/.claude/commands/rulebook-learn-capture.md +48 -0
- package/.claude/commands/rulebook-learn-list.md +13 -0
- package/.claude/commands/rulebook-task-archive.md +24 -0
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +10 -1
- package/dist/cli/commands.d.ts +32 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +210 -14
- package/dist/cli/commands.js.map +1 -1
- package/dist/core/claude-mcp.d.ts +2 -1
- package/dist/core/claude-mcp.d.ts.map +1 -1
- package/dist/core/claude-mcp.js +16 -8
- package/dist/core/claude-mcp.js.map +1 -1
- package/dist/core/config-manager.d.ts.map +1 -1
- package/dist/core/config-manager.js +1 -2
- package/dist/core/config-manager.js.map +1 -1
- package/dist/core/decision-manager.d.ts +25 -0
- package/dist/core/decision-manager.d.ts.map +1 -0
- package/dist/core/decision-manager.js +188 -0
- package/dist/core/decision-manager.js.map +1 -0
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +26 -0
- package/dist/core/generator.js.map +1 -1
- package/dist/core/indexer/background-indexer.d.ts +7 -0
- package/dist/core/indexer/background-indexer.d.ts.map +1 -1
- package/dist/core/indexer/background-indexer.js +54 -25
- package/dist/core/indexer/background-indexer.js.map +1 -1
- package/dist/core/knowledge-manager.d.ts +24 -0
- package/dist/core/knowledge-manager.d.ts.map +1 -0
- package/dist/core/knowledge-manager.js +173 -0
- package/dist/core/knowledge-manager.js.map +1 -0
- package/dist/core/learn-manager.d.ts +29 -0
- package/dist/core/learn-manager.d.ts.map +1 -0
- package/dist/core/learn-manager.js +159 -0
- package/dist/core/learn-manager.js.map +1 -0
- package/dist/core/workspace/project-worker.d.ts +9 -0
- package/dist/core/workspace/project-worker.d.ts.map +1 -1
- package/dist/core/workspace/project-worker.js +27 -0
- package/dist/core/workspace/project-worker.js.map +1 -1
- package/dist/index.js +68 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/rulebook-server.d.ts.map +1 -1
- package/dist/mcp/rulebook-server.js +515 -19
- package/dist/mcp/rulebook-server.js.map +1 -1
- package/dist/memory/memory-manager.d.ts +3 -0
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +18 -1
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/memory-store.d.ts.map +1 -1
- package/dist/memory/memory-store.js +3 -1
- package/dist/memory/memory-store.js.map +1 -1
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/templates/agents/context-intelligence.md +52 -0
- package/templates/commands/rulebook-decision-create.md +55 -0
- package/templates/commands/rulebook-decision-list.md +15 -0
- package/templates/commands/rulebook-knowledge-add.md +41 -0
- package/templates/commands/rulebook-knowledge-list.md +15 -0
- package/templates/commands/rulebook-learn-capture.md +48 -0
- package/templates/commands/rulebook-learn-list.md +13 -0
- package/templates/core/DECISIONS.md +38 -0
- package/templates/core/KNOWLEDGE.md +49 -0
|
@@ -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 -->
|
|
@@ -62,6 +62,30 @@ description: Archive a completed Rulebook task and apply spec deltas to main spe
|
|
|
62
62
|
- Create migration guides (if needed)
|
|
63
63
|
- Unblock related tasks (if any)
|
|
64
64
|
|
|
65
|
+
8. **🚨 MANDATORY: Deferred Items → Tasks Rule**:
|
|
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**.
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
❌ WRONG — defer without creating task:
|
|
70
|
+
1. Archive task with "- [ ] D1. feature X — deferred Phase 4"
|
|
71
|
+
→ Feature X is now forgotten forever
|
|
72
|
+
|
|
73
|
+
✅ CORRECT — defer with tracking:
|
|
74
|
+
1. Add "- [ ] D1. feature X — deferred Phase 4" to tasks.md
|
|
75
|
+
2. Call rulebook_task_create("phase4-feature-x")
|
|
76
|
+
3. Write tasks.md for the new task with full context
|
|
77
|
+
4. THEN call rulebook_task_archive
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Archive Checklist (ALL must be done before archiving):**
|
|
81
|
+
```
|
|
82
|
+
□ 1. tasks.md uses - [x] for implemented, - [ ] for deferred
|
|
83
|
+
□ 2. Each deferred item has a "Phase N" target
|
|
84
|
+
□ 3. A rulebook task exists for EVERY deferred item or group
|
|
85
|
+
□ 4. The new deferred tasks have tasks.md with full context
|
|
86
|
+
□ 5. THEN call rulebook_task_archive
|
|
87
|
+
```
|
|
88
|
+
|
|
65
89
|
**Reference**
|
|
66
90
|
- Use `rulebook task list --archived` to see archived tasks
|
|
67
91
|
- Use `rulebook task show <task-id>` to view task details
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rulebook",
|
|
3
3
|
"description": "Standardize AI-generated projects with Ralph autonomous loop, persistent memory, and quality gates. Supports 28 languages, 17 frameworks, 13 MCP modules, and 20 services.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "HiveLLM"
|
|
7
7
|
}
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Large Language Models (LLMs) for software development need **clear directives**
|
|
|
27
27
|
- 🎯 **Normalized Deliverables**: Ensures consistent code quality across all AI-generated outputs
|
|
28
28
|
- 🛡️ **Error Reduction**: Catches issues early through automated quality gates and pre-commit/pre-push hooks
|
|
29
29
|
- ⚙️ **Process Automation**: Automates repetitive tasks like formatting, testing, and deployment
|
|
30
|
-
- 🔌 **MCP Integration**:
|
|
30
|
+
- 🔌 **MCP Integration**: 40 MCP tools for task management, skills, memory, decisions, knowledge, and learnings
|
|
31
31
|
- 📊 **Task Management**: Built-in task management system (OpenSpec-compatible format) for structured development
|
|
32
32
|
|
|
33
33
|
By giving LLMs a clear "rulebook" to follow, you ensure that every piece of generated code meets your project's standards—**automatically**.
|
|
@@ -52,6 +52,15 @@ npx @hivehub/rulebook@latest update
|
|
|
52
52
|
|
|
53
53
|
See the full [CHANGELOG](CHANGELOG.md) for details.
|
|
54
54
|
|
|
55
|
+
### v4.4.0 — Context Intelligence Layer
|
|
56
|
+
|
|
57
|
+
- 🧠 **Decision Records**: `rulebook decision create|list|show|supersede` — Architecture Decision Records with auto-numbering and status lifecycle
|
|
58
|
+
- 📚 **Knowledge Base**: `rulebook knowledge add|list|show|remove` — Explicit patterns and anti-patterns auto-injected into AGENTS.md
|
|
59
|
+
- 💡 **Learn Phase**: `rulebook learn capture|from-ralph|list|promote` — Capture learnings, extract from Ralph, promote to patterns or decisions
|
|
60
|
+
- 🔌 **10 New MCP Tools**: Decision, knowledge, and learning management — **40 MCP tools total**
|
|
61
|
+
- 🤖 **Context Intelligence Agent**: New `context-intelligence` (haiku) agent for managing project knowledge
|
|
62
|
+
- 📋 **6 New Skills**: `/rulebook-decision-create`, `/rulebook-decision-list`, `/rulebook-knowledge-add`, `/rulebook-knowledge-list`, `/rulebook-learn-capture`, `/rulebook-learn-list`
|
|
63
|
+
|
|
55
64
|
### v4.3.0 — Agent Delegation & Cost Optimization
|
|
56
65
|
|
|
57
66
|
- 🤖 **18 Specialist Agents**: Cost-appropriate model assignments (opus for architecture, sonnet for code, haiku for read-only) with full Claude Code fields (`tools`, `maxTurns`, `disallowedTools`)
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -189,5 +189,37 @@ export declare function workspaceAddCommand(projectPath: string): Promise<void>;
|
|
|
189
189
|
export declare function workspaceRemoveCommand(projectName: string): Promise<void>;
|
|
190
190
|
export declare function workspaceListCommand(): Promise<void>;
|
|
191
191
|
export declare function workspaceStatusCommand(): Promise<void>;
|
|
192
|
+
export declare function decisionCreateCommand(title: string, options: {
|
|
193
|
+
context?: string;
|
|
194
|
+
relatedTask?: string;
|
|
195
|
+
}): Promise<void>;
|
|
196
|
+
export declare function decisionListCommand(options: {
|
|
197
|
+
status?: string;
|
|
198
|
+
}): Promise<void>;
|
|
199
|
+
export declare function decisionShowCommand(id: string): Promise<void>;
|
|
200
|
+
export declare function decisionSupersedeCommand(oldId: string, newId: string): Promise<void>;
|
|
201
|
+
export declare function knowledgeAddCommand(type: string, title: string, options: {
|
|
202
|
+
category?: string;
|
|
203
|
+
description?: string;
|
|
204
|
+
}): Promise<void>;
|
|
205
|
+
export declare function knowledgeListCommand(options: {
|
|
206
|
+
type?: string;
|
|
207
|
+
category?: string;
|
|
208
|
+
}): Promise<void>;
|
|
209
|
+
export declare function knowledgeShowCommand(id: string): Promise<void>;
|
|
210
|
+
export declare function knowledgeRemoveCommand(id: string): Promise<void>;
|
|
211
|
+
export declare function learnCaptureCommand(options: {
|
|
212
|
+
title?: string;
|
|
213
|
+
content?: string;
|
|
214
|
+
relatedTask?: string;
|
|
215
|
+
tags?: string;
|
|
216
|
+
}): Promise<void>;
|
|
217
|
+
export declare function learnFromRalphCommand(): Promise<void>;
|
|
218
|
+
export declare function learnListCommand(options: {
|
|
219
|
+
limit?: string;
|
|
220
|
+
}): Promise<void>;
|
|
221
|
+
export declare function learnPromoteCommand(id: string, target: string, options: {
|
|
222
|
+
title?: string;
|
|
223
|
+
}): Promise<void>;
|
|
192
224
|
export {};
|
|
193
225
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAgEA,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAgEA,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CA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AE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASpE;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAStE;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB3I;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3D;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcjF;AAED,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhH"}
|
package/dist/cli/commands.js
CHANGED
|
@@ -417,6 +417,25 @@ export async function initCommand(options) {
|
|
|
417
417
|
console.log(chalk.gray(` - ${path.relative(cwd, artifact)}`));
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
// Clean up any accidental nested .rulebook/.rulebook directory
|
|
421
|
+
try {
|
|
422
|
+
const fsPromises = await import('fs/promises');
|
|
423
|
+
const accidentalDir = path.join(cwd, '.rulebook', '.rulebook');
|
|
424
|
+
if (existsSync(accidentalDir)) {
|
|
425
|
+
await fsPromises.rm(accidentalDir, { recursive: true, force: true });
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
// Ignore cleanup errors
|
|
430
|
+
}
|
|
431
|
+
// Detect if this looks like a workspace root and hint the user
|
|
432
|
+
const wsConfig = WorkspaceManager.findWorkspaceConfig(cwd);
|
|
433
|
+
if (wsConfig && wsConfig.projects.length > 1) {
|
|
434
|
+
console.log(chalk.yellow(`\n⚠ Workspace detected: "${wsConfig.name}" with ${wsConfig.projects.length} projects.`));
|
|
435
|
+
console.log(chalk.yellow(' The MCP server will auto-detect workspace mode. For explicit setup, run:'));
|
|
436
|
+
console.log(chalk.yellow(' rulebook workspace init'));
|
|
437
|
+
console.log(chalk.yellow(' Then run `rulebook init` inside each sub-project individually for best results.\n'));
|
|
438
|
+
}
|
|
420
439
|
console.log(chalk.bold.green('\n✨ Rulebook initialization complete!\n'));
|
|
421
440
|
console.log(chalk.gray('Next steps:'));
|
|
422
441
|
console.log(chalk.gray(' 1. Review AGENTS.md'));
|
|
@@ -2981,7 +3000,6 @@ export async function setupClaudeCodePlugin() {
|
|
|
2981
3000
|
// Get Claude Code plugins directory
|
|
2982
3001
|
const homeDir = os.homedir();
|
|
2983
3002
|
const pluginsDir = path.join(homeDir, '.claude', 'plugins');
|
|
2984
|
-
const installCountsPath = path.join(pluginsDir, 'install-counts-cache.json');
|
|
2985
3003
|
const installedPluginsPath = path.join(pluginsDir, 'installed_plugins.json');
|
|
2986
3004
|
// Create plugins directory if it doesn't exist
|
|
2987
3005
|
await fs.mkdir(pluginsDir, { recursive: true });
|
|
@@ -2994,17 +3012,32 @@ export async function setupClaudeCodePlugin() {
|
|
|
2994
3012
|
const content = await readFile(installedPluginsPath);
|
|
2995
3013
|
installedPlugins = JSON.parse(content);
|
|
2996
3014
|
}
|
|
2997
|
-
// Add rulebook plugin
|
|
3015
|
+
// Add rulebook plugin — keep exactly ONE entry per plugin key
|
|
2998
3016
|
const pluginKey = `rulebook@hivehub`;
|
|
2999
3017
|
const version = pluginJson.version || '3.2.1';
|
|
3000
3018
|
const installPath = path.join(pluginsDir, 'cache', 'hivehub', 'rulebook', version);
|
|
3001
3019
|
if (!installedPlugins.plugins[pluginKey]) {
|
|
3002
3020
|
installedPlugins.plugins[pluginKey] = [];
|
|
3003
3021
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
if (
|
|
3007
|
-
|
|
3022
|
+
const entries = installedPlugins.plugins[pluginKey];
|
|
3023
|
+
// Deduplicate: keep only the single latest entry, update it in-place
|
|
3024
|
+
if (entries.length > 0) {
|
|
3025
|
+
// Preserve original installedAt from the first entry
|
|
3026
|
+
const originalInstalledAt = entries[0].installedAt;
|
|
3027
|
+
// Replace all entries with a single updated one
|
|
3028
|
+
installedPlugins.plugins[pluginKey] = [
|
|
3029
|
+
{
|
|
3030
|
+
scope: 'user',
|
|
3031
|
+
installPath: installPath,
|
|
3032
|
+
version: version,
|
|
3033
|
+
installedAt: originalInstalledAt || new Date().toISOString(),
|
|
3034
|
+
lastUpdated: new Date().toISOString(),
|
|
3035
|
+
},
|
|
3036
|
+
];
|
|
3037
|
+
}
|
|
3038
|
+
else {
|
|
3039
|
+
// First install
|
|
3040
|
+
entries.push({
|
|
3008
3041
|
scope: 'user',
|
|
3009
3042
|
installPath: installPath,
|
|
3010
3043
|
version: version,
|
|
@@ -3014,14 +3047,6 @@ export async function setupClaudeCodePlugin() {
|
|
|
3014
3047
|
}
|
|
3015
3048
|
// Save installed_plugins.json
|
|
3016
3049
|
await fs.writeFile(installedPluginsPath, JSON.stringify(installedPlugins, null, 2));
|
|
3017
|
-
// Update install-counts-cache.json
|
|
3018
|
-
let installCounts = {};
|
|
3019
|
-
if (existsSync(installCountsPath)) {
|
|
3020
|
-
const content = await readFile(installCountsPath);
|
|
3021
|
-
installCounts = JSON.parse(content);
|
|
3022
|
-
}
|
|
3023
|
-
installCounts[pluginKey] = (installCounts[pluginKey] || 0) + 1;
|
|
3024
|
-
await fs.writeFile(installCountsPath, JSON.stringify(installCounts, null, 2));
|
|
3025
3050
|
spinner.succeed('Claude Code plugin installed');
|
|
3026
3051
|
console.log(`\n ${chalk.green('✓')} Plugin: ${pluginKey} v${version}`);
|
|
3027
3052
|
console.log(` ${chalk.gray('Installed to:')} ${installPath}`);
|
|
@@ -3657,4 +3682,175 @@ export async function workspaceStatusCommand() {
|
|
|
3657
3682
|
await manager.shutdownAll();
|
|
3658
3683
|
}
|
|
3659
3684
|
}
|
|
3685
|
+
// Context Intelligence Layer commands (v4.4)
|
|
3686
|
+
export async function decisionCreateCommand(title, options) {
|
|
3687
|
+
const { DecisionManager } = await import('../core/decision-manager.js');
|
|
3688
|
+
const mgr = new DecisionManager(process.cwd());
|
|
3689
|
+
const spinner = ora('Creating decision...').start();
|
|
3690
|
+
try {
|
|
3691
|
+
const d = await mgr.create(title, {
|
|
3692
|
+
context: options.context,
|
|
3693
|
+
relatedTasks: options.relatedTask ? [options.relatedTask] : undefined,
|
|
3694
|
+
});
|
|
3695
|
+
spinner.succeed(`Decision ADR-${String(d.id).padStart(3, '0')}: ${d.title} (${d.status})`);
|
|
3696
|
+
}
|
|
3697
|
+
catch (error) {
|
|
3698
|
+
spinner.fail(`Failed: ${String(error)}`);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
export async function decisionListCommand(options) {
|
|
3702
|
+
const { DecisionManager } = await import('../core/decision-manager.js');
|
|
3703
|
+
const mgr = new DecisionManager(process.cwd());
|
|
3704
|
+
const decisions = await mgr.list(options.status);
|
|
3705
|
+
if (decisions.length === 0) {
|
|
3706
|
+
console.log(chalk.dim('No decisions found.'));
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
for (const d of decisions) {
|
|
3710
|
+
const badge = d.status === 'accepted' ? chalk.green(d.status) : d.status === 'superseded' ? chalk.dim(d.status) : chalk.yellow(d.status);
|
|
3711
|
+
console.log(` ADR-${String(d.id).padStart(3, '0')} ${d.title} ${badge}`);
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
export async function decisionShowCommand(id) {
|
|
3715
|
+
const { DecisionManager } = await import('../core/decision-manager.js');
|
|
3716
|
+
const mgr = new DecisionManager(process.cwd());
|
|
3717
|
+
const result = await mgr.show(parseInt(id));
|
|
3718
|
+
if (!result) {
|
|
3719
|
+
console.log(chalk.red(`Decision ${id} not found.`));
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
console.log(result.content);
|
|
3723
|
+
}
|
|
3724
|
+
export async function decisionSupersedeCommand(oldId, newId) {
|
|
3725
|
+
const { DecisionManager } = await import('../core/decision-manager.js');
|
|
3726
|
+
const mgr = new DecisionManager(process.cwd());
|
|
3727
|
+
const ok = await mgr.supersede(parseInt(oldId), parseInt(newId));
|
|
3728
|
+
if (ok) {
|
|
3729
|
+
console.log(chalk.green(`Decision ${oldId} superseded by ${newId}.`));
|
|
3730
|
+
}
|
|
3731
|
+
else {
|
|
3732
|
+
console.log(chalk.red(`Decision ${oldId} not found.`));
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
export async function knowledgeAddCommand(type, title, options) {
|
|
3736
|
+
const { KnowledgeManager } = await import('../core/knowledge-manager.js');
|
|
3737
|
+
const mgr = new KnowledgeManager(process.cwd());
|
|
3738
|
+
const spinner = ora('Adding knowledge entry...').start();
|
|
3739
|
+
try {
|
|
3740
|
+
const entry = await mgr.add(type, title, {
|
|
3741
|
+
category: (options.category ?? 'code'),
|
|
3742
|
+
description: options.description ?? '',
|
|
3743
|
+
});
|
|
3744
|
+
spinner.succeed(`${entry.type}: ${entry.title} (${entry.category})`);
|
|
3745
|
+
}
|
|
3746
|
+
catch (error) {
|
|
3747
|
+
spinner.fail(`Failed: ${String(error)}`);
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
export async function knowledgeListCommand(options) {
|
|
3751
|
+
const { KnowledgeManager } = await import('../core/knowledge-manager.js');
|
|
3752
|
+
const mgr = new KnowledgeManager(process.cwd());
|
|
3753
|
+
const entries = await mgr.list(options.type, options.category);
|
|
3754
|
+
if (entries.length === 0) {
|
|
3755
|
+
console.log(chalk.dim('No knowledge entries found.'));
|
|
3756
|
+
return;
|
|
3757
|
+
}
|
|
3758
|
+
for (const e of entries) {
|
|
3759
|
+
const badge = e.type === 'pattern' ? chalk.green('pattern') : chalk.red('anti-pattern');
|
|
3760
|
+
console.log(` ${badge} ${e.title} ${chalk.dim(e.category)}`);
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
export async function knowledgeShowCommand(id) {
|
|
3764
|
+
const { KnowledgeManager } = await import('../core/knowledge-manager.js');
|
|
3765
|
+
const mgr = new KnowledgeManager(process.cwd());
|
|
3766
|
+
const result = await mgr.show(id);
|
|
3767
|
+
if (!result) {
|
|
3768
|
+
console.log(chalk.red(`Knowledge entry "${id}" not found.`));
|
|
3769
|
+
return;
|
|
3770
|
+
}
|
|
3771
|
+
console.log(result.content);
|
|
3772
|
+
}
|
|
3773
|
+
export async function knowledgeRemoveCommand(id) {
|
|
3774
|
+
const { KnowledgeManager } = await import('../core/knowledge-manager.js');
|
|
3775
|
+
const mgr = new KnowledgeManager(process.cwd());
|
|
3776
|
+
const ok = await mgr.remove(id);
|
|
3777
|
+
if (ok) {
|
|
3778
|
+
console.log(chalk.green(`Knowledge entry "${id}" removed.`));
|
|
3779
|
+
}
|
|
3780
|
+
else {
|
|
3781
|
+
console.log(chalk.red(`Knowledge entry "${id}" not found.`));
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
export async function learnCaptureCommand(options) {
|
|
3785
|
+
const { LearnManager } = await import('../core/learn-manager.js');
|
|
3786
|
+
const mgr = new LearnManager(process.cwd());
|
|
3787
|
+
// If no title/content provided, this would be interactive (placeholder for prompts)
|
|
3788
|
+
const title = options.title ?? 'Untitled learning';
|
|
3789
|
+
const content = options.content ?? '';
|
|
3790
|
+
const tags = options.tags ? options.tags.split(',').map(t => t.trim()) : [];
|
|
3791
|
+
const spinner = ora('Capturing learning...').start();
|
|
3792
|
+
try {
|
|
3793
|
+
const learning = await mgr.capture(title, content, {
|
|
3794
|
+
source: 'manual',
|
|
3795
|
+
relatedTask: options.relatedTask,
|
|
3796
|
+
tags,
|
|
3797
|
+
});
|
|
3798
|
+
spinner.succeed(`Learning captured: ${learning.title}`);
|
|
3799
|
+
}
|
|
3800
|
+
catch (error) {
|
|
3801
|
+
spinner.fail(`Failed: ${String(error)}`);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
export async function learnFromRalphCommand() {
|
|
3805
|
+
const { LearnManager } = await import('../core/learn-manager.js');
|
|
3806
|
+
const mgr = new LearnManager(process.cwd());
|
|
3807
|
+
const spinner = ora('Extracting learnings from Ralph history...').start();
|
|
3808
|
+
try {
|
|
3809
|
+
const learnings = await mgr.fromRalph();
|
|
3810
|
+
if (learnings.length === 0) {
|
|
3811
|
+
spinner.info('No new learnings found in Ralph history.');
|
|
3812
|
+
}
|
|
3813
|
+
else {
|
|
3814
|
+
spinner.succeed(`Extracted ${learnings.length} learning(s) from Ralph history.`);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
catch (error) {
|
|
3818
|
+
spinner.fail(`Failed: ${String(error)}`);
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
export async function learnListCommand(options) {
|
|
3822
|
+
const { LearnManager } = await import('../core/learn-manager.js');
|
|
3823
|
+
const mgr = new LearnManager(process.cwd());
|
|
3824
|
+
const limit = options.limit ? parseInt(options.limit) : undefined;
|
|
3825
|
+
const learnings = await mgr.list(limit);
|
|
3826
|
+
if (learnings.length === 0) {
|
|
3827
|
+
console.log(chalk.dim('No learnings found.'));
|
|
3828
|
+
return;
|
|
3829
|
+
}
|
|
3830
|
+
for (const l of learnings) {
|
|
3831
|
+
const badge = l.source === 'ralph' ? chalk.blue('ralph') : l.source === 'task-archive' ? chalk.yellow('archive') : chalk.dim('manual');
|
|
3832
|
+
const promoted = l.promotedTo ? chalk.green(` → ${l.promotedTo.type}`) : '';
|
|
3833
|
+
console.log(` ${badge} ${l.title}${promoted}`);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
export async function learnPromoteCommand(id, target, options) {
|
|
3837
|
+
const { LearnManager } = await import('../core/learn-manager.js');
|
|
3838
|
+
const mgr = new LearnManager(process.cwd());
|
|
3839
|
+
if (target !== 'knowledge' && target !== 'decision') {
|
|
3840
|
+
console.log(chalk.red('Target must be "knowledge" or "decision".'));
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
const spinner = ora(`Promoting learning to ${target}...`).start();
|
|
3844
|
+
try {
|
|
3845
|
+
const result = await mgr.promote(id, target, { title: options.title });
|
|
3846
|
+
if (!result) {
|
|
3847
|
+
spinner.fail(`Learning "${id}" not found.`);
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
spinner.succeed(`Learning promoted to ${result.type} (id: ${result.id}).`);
|
|
3851
|
+
}
|
|
3852
|
+
catch (error) {
|
|
3853
|
+
spinner.fail(`Failed: ${String(error)}`);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3660
3856
|
//# sourceMappingURL=commands.js.map
|