clikit-plugin 0.2.35 → 0.2.37

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 (53) hide show
  1. package/README.md +13 -14
  2. package/command/init.md +70 -152
  3. package/command/issue.md +1 -1
  4. package/command/plan.md +9 -4
  5. package/command/research.md +5 -5
  6. package/command/ship.md +51 -59
  7. package/command/verify.md +74 -50
  8. package/dist/.tsbuildinfo +1 -1
  9. package/dist/agents/index.d.ts.map +1 -1
  10. package/dist/cli.d.ts +1 -1
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +45 -107
  13. package/dist/cli.test.d.ts +2 -0
  14. package/dist/cli.test.d.ts.map +1 -0
  15. package/dist/clikit.schema.json +154 -136
  16. package/dist/commands/index.d.ts.map +1 -1
  17. package/dist/config.d.ts +13 -0
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.test.d.ts +2 -0
  20. package/dist/config.test.d.ts.map +1 -0
  21. package/dist/hooks/error-logger.d.ts +10 -0
  22. package/dist/hooks/error-logger.d.ts.map +1 -0
  23. package/dist/hooks/index.d.ts +1 -1
  24. package/dist/hooks/index.d.ts.map +1 -1
  25. package/dist/hooks/memory-digest.d.ts +2 -0
  26. package/dist/hooks/memory-digest.d.ts.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +770 -154
  29. package/dist/skills/index.d.ts +10 -0
  30. package/dist/skills/index.d.ts.map +1 -1
  31. package/dist/tools/cass-memory.d.ts +61 -0
  32. package/dist/tools/cass-memory.d.ts.map +1 -0
  33. package/dist/tools/index.d.ts +1 -0
  34. package/dist/tools/index.d.ts.map +1 -1
  35. package/package.json +2 -2
  36. package/skill/cass-village/SKILL.md +217 -0
  37. package/src/agents/AGENTS.md +2 -1
  38. package/src/agents/build.md +17 -16
  39. package/src/agents/index.ts +33 -4
  40. package/src/agents/oracle.md +49 -68
  41. package/src/agents/plan.md +14 -15
  42. package/src/agents/research.md +76 -0
  43. package/src/agents/review.md +1 -1
  44. package/src/agents/vision.md +1 -1
  45. package/dist/hooks/git-guard.test.d.ts +0 -2
  46. package/dist/hooks/git-guard.test.d.ts.map +0 -1
  47. package/dist/hooks/security-check.test.d.ts +0 -2
  48. package/dist/hooks/security-check.test.d.ts.map +0 -1
  49. package/src/agents/general.md +0 -92
  50. package/src/agents/librarian.md +0 -116
  51. package/src/agents/looker.md +0 -112
  52. package/src/agents/scout.md +0 -84
  53. /package/command/{status.md → status-beads.md} +0 -0
@@ -1,8 +1,18 @@
1
+ export declare function resolveSkillsDir(): string;
1
2
  export interface SkillConfig {
2
3
  name: string;
3
4
  description: string;
4
5
  content: string;
5
6
  location: string;
7
+ from?: string;
8
+ model?: string;
9
+ agent?: string;
10
+ subtask?: boolean;
11
+ "argument-hint"?: string;
12
+ license?: string;
13
+ compatibility?: string;
14
+ metadata?: Record<string, unknown>;
15
+ "allowed-tools"?: string[];
6
16
  }
7
17
  export declare function getBuiltinSkills(): Record<string, SkillConfig>;
8
18
  export declare function findSkill(skills: Record<string, SkillConfig>, query: string): SkillConfig | null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAuC9D;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAgChG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAUA,wBAAgB,gBAAgB,IAAI,MAAM,CAOzC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAuC9D;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAgChG"}
@@ -0,0 +1,61 @@
1
+ export interface CassMemoryExecOptions {
2
+ cmPath?: string;
3
+ cwd?: string;
4
+ timeoutMs?: number;
5
+ }
6
+ export interface CassMemoryResult<T = unknown> {
7
+ ok: boolean;
8
+ command: string[];
9
+ data?: T;
10
+ raw?: string;
11
+ error?: string;
12
+ source?: "cm" | "embedded";
13
+ }
14
+ export interface CassMemoryContextParams extends CassMemoryExecOptions {
15
+ task: string;
16
+ limit?: number;
17
+ history?: number;
18
+ days?: number;
19
+ noHistory?: boolean;
20
+ }
21
+ export interface CassMemoryMarkParams extends CassMemoryExecOptions {
22
+ bulletId: string;
23
+ helpful?: boolean;
24
+ harmful?: boolean;
25
+ reason?: string;
26
+ }
27
+ export interface CassMemoryReflectParams extends CassMemoryExecOptions {
28
+ days?: number;
29
+ maxSessions?: number;
30
+ dryRun?: boolean;
31
+ workspace?: string;
32
+ }
33
+ export interface CassMemoryOutcomeParams extends CassMemoryExecOptions {
34
+ status: "success" | "failure" | "mixed" | "partial";
35
+ rules: string;
36
+ summary?: string;
37
+ duration?: number;
38
+ errors?: number;
39
+ }
40
+ export interface CassMemoryDoctorParams extends CassMemoryExecOptions {
41
+ fix?: boolean;
42
+ }
43
+ export declare function cassMemoryContext(params: unknown): Promise<CassMemoryResult>;
44
+ export declare function cassMemoryMark(params: unknown): Promise<CassMemoryResult>;
45
+ export declare function cassMemoryReflect(params?: unknown): Promise<CassMemoryResult>;
46
+ export declare function cassMemoryOutcome(params: unknown): Promise<CassMemoryResult>;
47
+ export declare function cassMemoryDoctor(params?: CassMemoryExecOptions): Promise<CassMemoryResult>;
48
+ /**
49
+ * Check whether the real cm binary is available.
50
+ * Useful for conditional logic in hooks/skills.
51
+ */
52
+ export declare function cassIsAvailable(cmPath?: string): Promise<{
53
+ available: boolean;
54
+ version?: string;
55
+ path?: string;
56
+ }>;
57
+ /**
58
+ * Reset the cached cm binary path. Useful after installation.
59
+ */
60
+ export declare function cassResetCache(): void;
61
+ //# sourceMappingURL=cass-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cass-memory.d.ts","sourceRoot":"","sources":["../../src/tools/cass-memory.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAuVD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0BlF;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwB/E;AAED,wBAAsB,iBAAiB,CAAC,MAAM,GAAE,OAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkBvF;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2BlF;AAED,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWpG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAYvH;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
@@ -4,4 +4,5 @@ export { swarm, type SwarmParams, type SwarmTask, type SwarmResult, type SwarmPl
4
4
  export { beadsMemorySync, type BeadsMemorySyncParams, type BeadsMemorySyncResult, } from "./beads-memory-sync";
5
5
  export { quickResearch, type QuickResearchParams, type QuickResearchResult, } from "./quick-research";
6
6
  export { contextSummary, type ContextSummaryParams, type ContextSummaryResult, } from "./context-summary";
7
+ export { cassMemoryContext, cassMemoryMark, cassMemoryReflect, cassMemoryDoctor, cassMemoryOutcome, cassIsAvailable, cassResetCache, type CassMemoryContextParams, type CassMemoryMarkParams, type CassMemoryReflectParams, type CassMemoryOutcomeParams, type CassMemoryDoctorParams, type CassMemoryExecOptions, type CassMemoryResult, } from "./cass-memory";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clikit-plugin",
3
- "version": "0.2.35",
4
- "description": "OpenCode plugin with 10 agents, 19 commands, 48 skills, 10 hooks",
3
+ "version": "0.2.37",
4
+ "description": "OpenCode plugin with 7 agents, 19 commands, 48 skills, 10 hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: cass-village
3
+ description: Use when delegating multi-agent tasks with persistent memory. Combines CASS procedural memory with beads-village coordination so agents learn from every delegation cycle.
4
+ ---
5
+
6
+ # CASS Village Skill
7
+
8
+ You are running the **cass-village** skill. Memory-informed multi-agent delegation with learning feedback loops.
9
+
10
+ ## How It Works
11
+
12
+ CliKit integrates with the real [CASS Memory System](https://github.com/Dicklesworthstone/cass_memory_system) (`cm` CLI) when available. If `cm` is not installed, it falls back to an embedded SQLite-based implementation with reduced capabilities.
13
+
14
+ **With `cm` installed** (recommended): Full playbook management, Bayesian rule scoring, real reflection that distills sessions into rules, outcome tracking, and cross-agent memory sharing.
15
+
16
+ **Without `cm`** (embedded fallback): Basic context retrieval via FTS5 search, feedback recording, and anti-pattern promotion. Reflection is a stub.
17
+
18
+ ## The Problem
19
+
20
+ Without shared memory, subagents repeat the same mistakes across sessions. Knowledge dies when a session ends. Tasks get assigned without context about what worked or failed before. This skill closes the loop: memory informs delegation, outcomes feed back into memory.
21
+
22
+ ## Core Loop
23
+
24
+ ```
25
+ PLAN cm context per task Hydrate tasks with relevant rules
26
+ | |
27
+ v v
28
+ ENRICH beads-village_add Tasks carry CASS context in description
29
+ | |
30
+ v v
31
+ EXECUTE subagents claim Follow rules, leave inline feedback
32
+ | |
33
+ v v
34
+ LEARN cm outcome + reflect Session knowledge becomes persistent rules
35
+ ```
36
+
37
+ ## Phase 1: Plan with Memory
38
+
39
+ Before creating tasks, query CASS for relevant knowledge.
40
+
41
+ ```bash
42
+ # For each task you're about to delegate:
43
+ cm context "<task description>" --json
44
+ ```
45
+
46
+ This returns:
47
+ - **Playbook rules** scored against the task (with rule IDs like `b-8f3a2c`)
48
+ - **History snippets** from past sessions where similar work was done
49
+ - **Anti-patterns** to avoid (rules previously marked harmful)
50
+
51
+ Extract the top 3-5 rules. These go into the task description.
52
+
53
+ ## Phase 2: Enrich and Delegate
54
+
55
+ When creating beads-village tasks, embed CASS context directly in the task description.
56
+
57
+ **Task description template:**
58
+
59
+ ```
60
+ ## Task
61
+ <what needs to be done>
62
+
63
+ ## Memory Context
64
+ Following rules from CASS playbook:
65
+ - b-8f3a2c: <rule content> (score: 8.2, proven)
66
+ - b-def456: <rule content> (score: 6.1, established)
67
+
68
+ Avoid anti-patterns:
69
+ - b-xyz789: PITFALL: <what not to do>
70
+
71
+ ## Prior History
72
+ <relevant snippet from cm context output, if any>
73
+
74
+ ## Feedback Protocol
75
+ When following a rule, comment: // [cass: helpful b-XXXX] - reason
76
+ When a rule causes problems, comment: // [cass: harmful b-XXXX] - reason
77
+ ```
78
+
79
+ **Delegation commands:**
80
+
81
+ ```
82
+ beads-village_add title, desc (with CASS context), tags, deps
83
+ beads-village_assign id, role
84
+ ```
85
+
86
+ Tag tasks with roles (`fe`, `be`, `qa`, `devops`, `mobile`) so the right subagent picks them up.
87
+
88
+ ## Phase 3: Subagent Execution
89
+
90
+ Subagents follow the standard beads cycle with one addition -- inline CASS feedback:
91
+
92
+ ```
93
+ 1. beads-village_claim Pick up the task
94
+ 2. Read the Memory Context Note which rules apply
95
+ 3. beads-village_reserve Lock files
96
+ 4. Work Follow the rules, write code
97
+ 5. Leave inline feedback // [cass: helpful b-XXX] or // [cass: harmful b-XXX]
98
+ 6. beads-village_done Complete the task
99
+ ```
100
+
101
+ ### Inline Feedback Rules
102
+
103
+ - Reference rule IDs when following them: `"Following b-8f3a2c, using retry with backoff"`
104
+ - Mark rules helpful when they prevent a mistake or speed up work
105
+ - Mark rules harmful when they cause a regression, waste time, or are wrong
106
+ - Be specific in the reason -- vague feedback is discarded during reflection
107
+
108
+ ## Phase 4: Learn from Outcomes
109
+
110
+ After a batch of tasks completes, the leader records outcomes and triggers reflection.
111
+
112
+ ### Record Task Outcomes
113
+
114
+ For each completed task, record whether it succeeded or failed and which rules were used:
115
+
116
+ ```bash
117
+ # Successful task that followed specific rules
118
+ cm outcome success b-8f3a2c,b-def456 --json
119
+
120
+ # Failed task where a rule caused problems
121
+ cm outcome failure b-xyz789 --text "Rate limiter approach caused deadlock" --json
122
+
123
+ # Mixed results
124
+ cm outcome mixed b-8f3a2c,b-def456 --json
125
+ ```
126
+
127
+ ### End-of-Session Reflection
128
+
129
+ At session end, trigger reflection to distill new rules from the work done:
130
+
131
+ ```bash
132
+ cm reflect --days 1 --json
133
+ ```
134
+
135
+ This processes all session activity (including inline feedback) into:
136
+ - New candidate rules from patterns detected
137
+ - Score updates for existing rules (helpful/harmful counts)
138
+ - Anti-pattern inversions for consistently harmful rules
139
+ - Maturity promotions for consistently helpful rules
140
+
141
+ ### Review Playbook Health
142
+
143
+ ```bash
144
+ # Top performing rules
145
+ cm top 10
146
+
147
+ # Find stale rules without recent feedback
148
+ cm stale --days 60
149
+
150
+ # Understand why a rule exists
151
+ cm why b-8f3a2c
152
+
153
+ # Overall playbook health metrics
154
+ cm stats --json
155
+ ```
156
+
157
+ ## Decision Matrix
158
+
159
+ | Situation | Action |
160
+ |-----------|--------|
161
+ | Creating a new task | Run `cm context` first, embed top rules |
162
+ | Task similar to past failure | Include anti-patterns prominently in description |
163
+ | Subagent following a rule successfully | Leave `// [cass: helpful b-XXX]` inline |
164
+ | Rule caused a problem during execution | Leave `// [cass: harmful b-XXX]` inline |
165
+ | Batch of tasks completed | Run `cm outcome` for each, then `cm reflect` |
166
+ | Starting a new session | `cm context` for the overall goal to prime memory |
167
+
168
+ ## Configuration
169
+
170
+ In `clikit.config.json`:
171
+
172
+ ```json
173
+ {
174
+ "hooks": {
175
+ "cass_memory": {
176
+ "enabled": true,
177
+ "cm_path": "/path/to/cm",
178
+ "context_on_session_created": true,
179
+ "reflect_on_session_idle": true,
180
+ "context_limit": 5,
181
+ "reflect_days": 7,
182
+ "log": true
183
+ }
184
+ }
185
+ }
186
+ ```
187
+
188
+ The `cm_path` option lets you specify a custom path to the `cm` binary. If omitted, it looks for `cm` on your PATH.
189
+
190
+ ## Graceful Degradation
191
+
192
+ | Component Missing | Behavior |
193
+ |-------------------|----------|
194
+ | `cm` not installed | Falls back to embedded SQLite mode (basic context, no real reflection) |
195
+ | No playbook rules match | Delegate without memory context |
196
+ | `cm context` returns empty | Proceed -- the task is novel, learning starts now |
197
+ | `cm reflect` fails | Outcomes are still recorded, retry later |
198
+ | `cm outcome` without `cm` | Skipped (requires real cm CLI) |
199
+
200
+ ## Leader Checklist
201
+
202
+ ```
203
+ [ ] Run cm context before creating tasks
204
+ [ ] Embed top rules + anti-patterns in task descriptions
205
+ [ ] Include feedback protocol instructions in each task
206
+ [ ] After batch completion, run cm outcome for each task
207
+ [ ] At session end, run cm reflect --days 1
208
+ [ ] Review new/updated rules: cm top 10
209
+ ```
210
+
211
+ ## Anti-Patterns
212
+
213
+ - Dumping the entire playbook into a task description (token waste, noise)
214
+ - Skipping inline feedback (the learning loop breaks)
215
+ - Never running reflection (knowledge stays ephemeral)
216
+ - Assigning tasks without checking CASS first (repeating past mistakes)
217
+ - Ignoring anti-patterns in task descriptions (same failures recur)
@@ -9,7 +9,8 @@ Each `.md` file in this directory defines an agent. The frontmatter sets model,
9
9
  - @vision — prompt-to-UI, image-to-code, variant exploration. Loads skills like `frontend-aesthetics` and `mockup-to-code`.
10
10
  - @explore — fast read-only codebase navigation. Has restricted bash (grep, find, git read-only).
11
11
  - @review — code review and security audit. Use before merging.
12
- - @oracle, @scout, @librarian, @looker, @general see individual agent files for details.
12
+ - @oracle merged deep analysis + architecture advisor (from previous oracle + looker).
13
+ - @research — merged external research + GitHub evidence specialist (from previous scout + librarian).
13
14
 
14
15
  ## Rules
15
16
 
@@ -46,14 +46,14 @@ Before ANY action, silently classify the user's intent:
46
46
  |---|---|---|
47
47
  | **Trivial** | Single file, obvious fix, typo | Do it yourself immediately |
48
48
  | **Explicit** | Clear task, defined scope | Create todos → implement → verify |
49
- | **Exploratory** | "How does X work?", "Find Y" | Fire Explore/Looker in background, report findings |
50
- | **Research** | "What's the best way to...", external APIs | Fire Scout + Librarian in background |
49
+ | **Exploratory** | "How does X work?", "Find Y" | Fire Explore in background, report findings |
50
+ | **Research** | "What's the best way to...", external APIs | Fire Research in background, synthesize results |
51
51
  | **Open-ended** | Vague goal, multiple approaches | Assess codebase first (Phase 1), then plan |
52
52
  | **Ambiguous** | Can't determine intent | Ask ONE clarifying question, then act |
53
53
 
54
54
  **Key triggers (check every message):**
55
55
  - 2+ modules involved → fire `Explore` in background immediately
56
- - External library/API mentioned → fire `Scout` in background immediately
56
+ - External library/API mentioned → fire `Research` in background immediately
57
57
  - Architecture question → fire `Oracle` (wait for result before answering)
58
58
  - UI/design work → delegate to `Vision`
59
59
  - Security-sensitive → delegate to `Review`
@@ -72,7 +72,7 @@ Skip this for explicit/trivial tasks. For open-ended work:
72
72
 
73
73
  ## Phase 2A: Exploration & Research (parallel, background-first)
74
74
 
75
- **CRITICAL: Explore and Scout are CHEAP. Fire them liberally and in PARALLEL.**
75
+ **CRITICAL: Explore and Research are CHEAP. Fire them liberally and in PARALLEL.**
76
76
 
77
77
  For codebase questions, fire multiple Explore tasks simultaneously:
78
78
  ```
@@ -81,12 +81,13 @@ Task 2: "Find how <pattern> is used across the codebase"
81
81
  Task 3: "Find test patterns for <module>"
82
82
  ```
83
83
 
84
- For external knowledge, fire Scout + Librarian simultaneously:
84
+ For external knowledge, fire Research:
85
85
  ```
86
- Scout: "Find docs for <library> <specific API>"
87
- Librarian: "Find real-world usage of <pattern> on GitHub"
86
+ Research: "Find docs for <library> <specific API> + real-world usage + migration notes"
88
87
  ```
89
88
 
89
+ Require Research to include a re-check section (confirmed/contradicted/unknown) before consuming results.
90
+
90
91
  Collect results only when needed for implementation. Never wait synchronously for background research.
91
92
 
92
93
  ## Phase 2B: Implementation
@@ -115,22 +116,21 @@ Execute directly:
115
116
  | Tier | Tool/Agent | When |
116
117
  |---|---|---|
117
118
  | **FREE** | read, glob, grep, lsp_* | Always prefer first |
118
- | **CHEAP** | Explore, Scout, Librarian | Fire liberally in background for any uncertainty |
119
- | **MODERATE** | General, Vision | Delegate bounded subtasks |
120
- | **EXPENSIVE** | Oracle, Looker | Hard problems, after 2+ failed attempts, architecture |
119
+ | **CHEAP** | Explore, Research | Fire liberally in background for uncertainty |
120
+ | **MODERATE** | Vision, Review | Delegate bounded subtasks |
121
+ | **EXPENSIVE** | Oracle | Hard problems, after 2+ failed attempts or architecture decisions |
121
122
 
122
123
  #### Delegation Table
123
124
 
124
125
  | Domain | Delegate To | Mode |
125
126
  |---|---|---|
126
127
  | Codebase navigation, find files/usages | **Explore** | background, parallel |
127
- | Deep code analysis, architecture review | **Looker** | foreground |
128
- | External docs, library APIs | **Scout** | background, parallel |
129
- | Open-source internals, GitHub evidence | **Librarian** | background, parallel |
130
- | Architecture decisions, stuck 3+ failures | **Oracle** | foreground, MUST collect result |
128
+ | Deep local analysis, architecture review | **Oracle** | foreground |
129
+ | External docs, library APIs | **Research** | background, parallel |
130
+ | Open-source internals, GitHub evidence | **Research** | background, parallel |
131
131
  | UI/UX design + implementation | **Vision** | foreground |
132
132
  | Code review, security audit, quality gate | **Review** | foreground |
133
- | Multi-step utility tasks | **General** | foreground |
133
+ | Multi-step utility tasks | **Self** | foreground |
134
134
 
135
135
  #### 7-Section Prompt (MANDATORY for every Task() delegation)
136
136
 
@@ -149,6 +149,7 @@ CONTEXT: File paths, constraints, related decisions, code snippets
149
149
  - If Oracle is running in background, **MUST collect its result** before delivering any final answer
150
150
  - Never cancel Oracle prematurely
151
151
  - Oracle is for HARD problems only — don't waste it on simple lookups
152
+ - Require Oracle to re-check incoming Research findings before final recommendations
152
153
 
153
154
  ## Phase 2C: Failure Recovery
154
155
 
@@ -217,7 +218,7 @@ AST-grep: `$VAR` = single node, `$$$` = multiple nodes, pattern must be valid co
217
218
  - Silently ignore failing acceptance criteria
218
219
  - Add unnecessary comments, logging, or "improvements" beyond scope
219
220
  - Over-engineer: build the simplest thing that works
220
- - Wait synchronously for Explore/Scout when you could fire them in background
221
+ - Wait synchronously for Explore/Research when you could fire them in background
221
222
 
222
223
  ## Inputs
223
224
 
@@ -4,11 +4,25 @@ import * as path from "path";
4
4
  import matter from "gray-matter";
5
5
 
6
6
  const AGENTS_DIR_CANDIDATES = [
7
+ // Dev: running from src/agents
7
8
  import.meta.dir,
9
+ // Packaged plugin: running from dist/, agents live in src/agents/
10
+ path.join(import.meta.dir, "../src/agents"),
11
+ // Additional fallbacks for non-standard layouts
8
12
  path.join(import.meta.dir, "../../src/agents"),
13
+ path.join(import.meta.dir, "../agents"),
9
14
  ];
10
15
 
11
16
  function resolveAgentsDir(): string {
17
+ for (const dir of AGENTS_DIR_CANDIDATES) {
18
+ if (!fs.existsSync(dir)) continue;
19
+ try {
20
+ const hasAgentFiles = fs.readdirSync(dir).some((f) => f.endsWith(".md") && f !== "AGENTS.md");
21
+ if (hasAgentFiles) return dir;
22
+ } catch {
23
+ // Ignore unreadable candidate and continue.
24
+ }
25
+ }
12
26
  for (const dir of AGENTS_DIR_CANDIDATES) {
13
27
  if (fs.existsSync(dir)) {
14
28
  return dir;
@@ -75,14 +89,29 @@ export function loadAgents(): Record<string, AgentConfig> {
75
89
  }
76
90
 
77
91
  let _cachedAgents: Record<string, AgentConfig> | null = null;
78
- let _cachedAgentsMtime = 0;
92
+ let _cachedAgentsFingerprint = "";
93
+
94
+ function getAgentsFingerprint(agentsDir: string): string {
95
+ const files = fs.readdirSync(agentsDir)
96
+ .filter((f) => f.endsWith(".md") && f !== "AGENTS.md")
97
+ .sort();
98
+
99
+ const parts = files.map((file) => {
100
+ const fullPath = path.join(agentsDir, file);
101
+ const stat = fs.statSync(fullPath);
102
+ return `${file}:${stat.mtimeMs}`;
103
+ });
104
+
105
+ return parts.join("|");
106
+ }
79
107
 
80
108
  export function getBuiltinAgents(): Record<string, AgentConfig> {
81
109
  try {
82
- const mtime = fs.statSync(resolveAgentsDir()).mtimeMs;
83
- if (_cachedAgents && _cachedAgentsMtime === mtime) return _cachedAgents;
110
+ const agentsDir = resolveAgentsDir();
111
+ const fingerprint = getAgentsFingerprint(agentsDir);
112
+ if (_cachedAgents && _cachedAgentsFingerprint === fingerprint) return _cachedAgents;
84
113
  _cachedAgents = loadAgents();
85
- _cachedAgentsMtime = mtime;
114
+ _cachedAgentsFingerprint = fingerprint;
86
115
  return _cachedAgents;
87
116
  } catch {
88
117
  return _cachedAgents ?? loadAgents();