continuous-improvement 3.1.0 β†’ 3.9.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 (136) hide show
  1. package/.claude-plugin/marketplace.json +66 -0
  2. package/CHANGELOG.md +216 -0
  3. package/QUICKSTART.md +79 -12
  4. package/README.md +229 -349
  5. package/SKILL.md +87 -9
  6. package/action.yml +1 -1
  7. package/bin/analyze.sh +9 -1
  8. package/bin/backfill.mjs +172 -0
  9. package/bin/check-doc-runtime-claims.mjs +120 -0
  10. package/bin/check-docs-substrings.mjs +333 -0
  11. package/bin/check-everything-mirror.mjs +145 -0
  12. package/bin/check-routing-targets.mjs +151 -0
  13. package/bin/check-skill-law-tag.mjs +128 -0
  14. package/bin/check-skill-mirror.mjs +119 -0
  15. package/bin/check-skill-tiers.mjs +116 -0
  16. package/bin/check-third-party-shape.mjs +202 -0
  17. package/bin/generate-plugin-manifests.mjs +171 -0
  18. package/bin/harvest-friction.mjs +279 -0
  19. package/bin/hook-stats.mjs +258 -0
  20. package/bin/install.mjs +407 -499
  21. package/bin/lint-transcript.mjs +182 -210
  22. package/bin/mcp-server.mjs +834 -608
  23. package/bin/observe.mjs +148 -0
  24. package/bin/pre-commit-block-strays.sh +49 -0
  25. package/bin/refresh-third-party.mjs +416 -0
  26. package/bin/unified-cli.mjs +533 -0
  27. package/commands/continuous-improvement.md +43 -2
  28. package/commands/discipline.md +14 -0
  29. package/commands/harvest.md +76 -0
  30. package/commands/learn-eval.md +117 -0
  31. package/commands/planning-with-files.md +66 -0
  32. package/commands/proceed-with-the-recommendation.md +62 -0
  33. package/commands/ralph.md +103 -0
  34. package/commands/release-train.md +81 -0
  35. package/commands/seven-laws.md +16 -0
  36. package/commands/superpowers.md +180 -0
  37. package/commands/swarm.md +101 -0
  38. package/commands/workspace-surface-audit.md +77 -0
  39. package/hooks/gateguard.mjs +172 -0
  40. package/hooks/observe.sh +42 -4
  41. package/hooks/session.sh +3 -3
  42. package/hooks/three-section-close.mjs +181 -0
  43. package/instinct-packs/meta.json +16 -0
  44. package/lib/cli-anything.mjs +401 -0
  45. package/lib/compound-engineering.mjs +831 -0
  46. package/lib/gateguard-state.mjs +85 -0
  47. package/lib/observe-event.mjs +128 -0
  48. package/lib/plugin-metadata.mjs +435 -0
  49. package/lib/pm-marketplace.mjs +61 -0
  50. package/lib/pm-skills.mjs +1274 -0
  51. package/lib/resolve-home-dir.mjs +43 -0
  52. package/lib/skill-tiers.mjs +137 -0
  53. package/lib/unified-plugin.mjs +924 -0
  54. package/llms.txt +32 -7
  55. package/package.json +29 -19
  56. package/plugins/beginner.json +17 -6
  57. package/plugins/continuous-improvement/.claude-plugin/marketplace.json +20 -0
  58. package/plugins/continuous-improvement/.claude-plugin/plugin.json +26 -0
  59. package/plugins/continuous-improvement/LICENSE +21 -0
  60. package/plugins/continuous-improvement/README.md +57 -0
  61. package/plugins/continuous-improvement/agents/README.md +120 -0
  62. package/plugins/continuous-improvement/agents/code-reviewer.md +97 -0
  63. package/plugins/continuous-improvement/agents/security-auditor.md +101 -0
  64. package/plugins/continuous-improvement/agents/test-engineer.md +95 -0
  65. package/plugins/continuous-improvement/bin/backfill.mjs +172 -0
  66. package/plugins/continuous-improvement/bin/mcp-server.mjs +889 -0
  67. package/plugins/continuous-improvement/bin/observe.mjs +148 -0
  68. package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -0
  69. package/plugins/continuous-improvement/commands/dashboard.md +56 -0
  70. package/plugins/continuous-improvement/commands/discipline.md +51 -0
  71. package/plugins/continuous-improvement/commands/harvest.md +76 -0
  72. package/plugins/continuous-improvement/commands/learn-eval.md +117 -0
  73. package/plugins/continuous-improvement/commands/planning-with-files.md +66 -0
  74. package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +62 -0
  75. package/plugins/continuous-improvement/commands/ralph.md +103 -0
  76. package/plugins/continuous-improvement/commands/release-train.md +81 -0
  77. package/plugins/continuous-improvement/commands/seven-laws.md +16 -0
  78. package/plugins/continuous-improvement/commands/superpowers.md +180 -0
  79. package/plugins/continuous-improvement/commands/swarm.md +101 -0
  80. package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -0
  81. package/plugins/continuous-improvement/hooks/gateguard.mjs +172 -0
  82. package/plugins/continuous-improvement/hooks/hooks.json +65 -0
  83. package/plugins/continuous-improvement/hooks/observe.sh +172 -0
  84. package/plugins/continuous-improvement/hooks/session.sh +106 -0
  85. package/plugins/continuous-improvement/hooks/three-section-close.mjs +181 -0
  86. package/plugins/continuous-improvement/instinct-packs/go.json +58 -0
  87. package/plugins/continuous-improvement/instinct-packs/meta.json +16 -0
  88. package/plugins/continuous-improvement/instinct-packs/python.json +58 -0
  89. package/plugins/continuous-improvement/instinct-packs/react.json +58 -0
  90. package/plugins/continuous-improvement/lib/observe-event.mjs +128 -0
  91. package/plugins/continuous-improvement/lib/plugin-metadata.mjs +435 -0
  92. package/plugins/continuous-improvement/lib/resolve-home-dir.mjs +43 -0
  93. package/plugins/continuous-improvement/skills/README.md +37 -0
  94. package/plugins/continuous-improvement/skills/continuous-improvement/SKILL.md +249 -0
  95. package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +178 -0
  96. package/plugins/continuous-improvement/skills/gateguard/SKILL.md +163 -0
  97. package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +108 -0
  98. package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +447 -0
  99. package/plugins/continuous-improvement/skills/ralph/SKILL.md +221 -0
  100. package/plugins/continuous-improvement/skills/recovery-classification/SKILL.md +73 -0
  101. package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +76 -0
  102. package/plugins/continuous-improvement/skills/state-reconciliation/SKILL.md +63 -0
  103. package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +104 -0
  104. package/plugins/continuous-improvement/skills/superpowers/SKILL.md +219 -0
  105. package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -0
  106. package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +136 -0
  107. package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +224 -0
  108. package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +191 -0
  109. package/plugins/continuous-improvement/skills/workspace-surface-audit/SKILL.md +147 -0
  110. package/plugins/continuous-improvement/skills/worktree-safety/SKILL.md +66 -0
  111. package/plugins/continuous-improvement/templates/planning-with-files/findings.md +8 -0
  112. package/plugins/continuous-improvement/templates/planning-with-files/progress.md +7 -0
  113. package/plugins/continuous-improvement/templates/planning-with-files/task_plan.md +23 -0
  114. package/plugins/expert.json +26 -5
  115. package/skills/README.md +79 -0
  116. package/skills/deploy-receipt.md +178 -0
  117. package/skills/gateguard.md +163 -0
  118. package/skills/para-memory-files.md +108 -0
  119. package/skills/proceed-with-the-recommendation.md +447 -0
  120. package/skills/ralph.md +221 -0
  121. package/skills/recovery-classification.md +73 -0
  122. package/skills/safety-guard.md +76 -0
  123. package/skills/state-reconciliation.md +63 -0
  124. package/skills/strategic-compact.md +104 -0
  125. package/skills/superpowers.md +219 -0
  126. package/skills/tdd-workflow.md +411 -0
  127. package/skills/token-budget-advisor.md +136 -0
  128. package/skills/verification-loop.md +224 -0
  129. package/skills/wild-risa-balance.md +191 -0
  130. package/skills/workspace-surface-audit.md +147 -0
  131. package/skills/worktree-safety.md +66 -0
  132. package/templates/insights-claude-md.md +91 -0
  133. package/templates/planning-with-files/findings.md +8 -0
  134. package/templates/planning-with-files/progress.md +7 -0
  135. package/templates/planning-with-files/task_plan.md +23 -0
  136. package/templates/verify-ladder.example.json +60 -0
@@ -0,0 +1,533 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Unified Continuous Improvement CLI.
4
+ *
5
+ * Comprehensive command-line interface for the unified plugin that combines
6
+ * CLI-Anything, Compound Engineering, and PM-Skills.
7
+ */
8
+ import { existsSync, readFileSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ import UnifiedContinuousImprovement from "../lib/unified-plugin.mjs";
11
+ const DEFAULT_CONFIG = {
12
+ workspace: "./ci-workspace",
13
+ verbose: false,
14
+ defaultMode: "expert",
15
+ };
16
+ function getErrorMessage(error) {
17
+ return error instanceof Error ? error.message : String(error);
18
+ }
19
+ function parseJsonOption(raw) {
20
+ if (!raw)
21
+ return undefined;
22
+ try {
23
+ return JSON.parse(raw);
24
+ }
25
+ catch (error) {
26
+ throw new Error(`Invalid JSON option: ${getErrorMessage(error)}`);
27
+ }
28
+ }
29
+ class UnifiedCLI {
30
+ plugin = null;
31
+ config;
32
+ constructor() {
33
+ this.config = this.loadConfig();
34
+ }
35
+ loadConfig() {
36
+ const configPath = join(process.cwd(), ".ci-config.json");
37
+ if (existsSync(configPath)) {
38
+ try {
39
+ const parsed = JSON.parse(readFileSync(configPath, "utf8"));
40
+ return { ...DEFAULT_CONFIG, ...parsed };
41
+ }
42
+ catch {
43
+ console.warn("Warning: Invalid config file, using defaults");
44
+ }
45
+ }
46
+ return { ...DEFAULT_CONFIG };
47
+ }
48
+ initializePlugin(options) {
49
+ this.plugin = new UnifiedContinuousImprovement({
50
+ workspace: options.workspace ?? this.config.workspace,
51
+ verbose: options.verbose ?? this.config.verbose,
52
+ });
53
+ return this.plugin;
54
+ }
55
+ requirePlugin() {
56
+ if (!this.plugin) {
57
+ throw new Error("CLI plugin not initialized");
58
+ }
59
+ return this.plugin;
60
+ }
61
+ async runCommand(command, args, options = {}) {
62
+ this.initializePlugin(options);
63
+ switch (command) {
64
+ case "init":
65
+ return this.handleInit(args, options);
66
+ case "workflow":
67
+ return this.handleWorkflow(args, options);
68
+ case "research":
69
+ return this.handleResearch(options);
70
+ case "planning":
71
+ return this.handlePlanning(options);
72
+ case "execution":
73
+ return this.handleExecution();
74
+ case "review":
75
+ return this.handleReview(options);
76
+ case "status":
77
+ return this.handleStatus();
78
+ case "cli":
79
+ return this.handleCLI(args);
80
+ case "pm":
81
+ return this.handlePM(args, options);
82
+ case "compound":
83
+ return this.handleCompound(args);
84
+ case "learnings":
85
+ return this.handleLearnings(args);
86
+ case "config":
87
+ return this.handleConfig(args);
88
+ default:
89
+ throw new Error(`Unknown command: ${command}`);
90
+ }
91
+ }
92
+ async handleInit(args, options) {
93
+ if (args.length < 2) {
94
+ throw new Error("Usage: ci init <project-name> <objective> [options]");
95
+ }
96
+ const [name, ...objectiveParts] = args;
97
+ const objective = objectiveParts.join(" ");
98
+ console.log(`πŸš€ Initializing project: ${name}`);
99
+ console.log(`πŸ“‹ Objective: ${objective}`);
100
+ const plugin = this.requirePlugin();
101
+ const result = await plugin.initializeProject({
102
+ name: name,
103
+ objective,
104
+ product: parseJsonOption(options.product) ?? {},
105
+ industry: options.industry ?? "",
106
+ targetMarket: parseJsonOption(options.targetMarket) ?? {},
107
+ });
108
+ console.log(`βœ… Project initialized successfully!`);
109
+ console.log(`πŸ†” Project ID: ${result.projectId}`);
110
+ console.log(`πŸ”— Session ID: ${result.sessionId}`);
111
+ console.log(`πŸ“Š PM Analysis: ${result.pmAnalysis.totalSkills} skills completed`);
112
+ console.log(`\n🎯 Next steps:`);
113
+ result.nextSteps.forEach((step, i) => {
114
+ console.log(` ${i + 1}. ${step}`);
115
+ });
116
+ return result;
117
+ }
118
+ async handleWorkflow(args, options) {
119
+ if (args.length < 2) {
120
+ throw new Error("Usage: ci workflow <project-name> <objective> [options]");
121
+ }
122
+ const [name, ...objectiveParts] = args;
123
+ const objective = objectiveParts.join(" ");
124
+ console.log(`πŸš€ Starting complete workflow for: ${name}`);
125
+ console.log(`πŸ“‹ Objective: ${objective}`);
126
+ const progressCallback = (message) => {
127
+ console.log(` ⏳ ${message}`);
128
+ };
129
+ const plugin = this.requirePlugin();
130
+ const result = await plugin.executeCompleteWorkflow({
131
+ name: name,
132
+ objective,
133
+ product: parseJsonOption(options.product) ?? {},
134
+ industry: options.industry ?? "",
135
+ targetMarket: parseJsonOption(options.targetMarket) ?? {},
136
+ }, {
137
+ researchContext: options.repo ? { repositoryPath: options.repo } : {},
138
+ progressCallback,
139
+ });
140
+ console.log(`πŸŽ‰ Complete workflow finished!`);
141
+ console.log(`πŸ†” Project: ${result.project}`);
142
+ console.log(`πŸ”— Session: ${result.sessionId}`);
143
+ for (const [phase] of Object.entries(result.phases)) {
144
+ console.log(`\nπŸ“Š ${phase.charAt(0).toUpperCase() + phase.slice(1)} Phase:`);
145
+ }
146
+ return result;
147
+ }
148
+ async handleResearch(options) {
149
+ console.log(`πŸ” Starting research phase...`);
150
+ const context = {};
151
+ if (options.repo)
152
+ context.repositoryPath = options.repo;
153
+ if (options.context)
154
+ context.additionalContext = parseJsonOption(options.context);
155
+ const plugin = this.requirePlugin();
156
+ const result = await plugin.executeResearchPhase(context);
157
+ console.log(`βœ… Research phase completed!`);
158
+ console.log(`πŸ’‘ Generated ${result.brainstorm.ideas.length} ideas`);
159
+ console.log(`πŸ” Identified ${result.brainstorm.risks.length} risks`);
160
+ if (result.cliTools) {
161
+ console.log(`πŸ› οΈ Generated CLI with ${result.cliTools.commands.length} commands`);
162
+ }
163
+ return result;
164
+ }
165
+ async handlePlanning(options) {
166
+ console.log(`πŸ“‹ Starting planning phase...`);
167
+ const preferences = parseJsonOption(options.preferences) ?? {};
168
+ const plugin = this.requirePlugin();
169
+ const result = await plugin.executePlanningPhase(preferences);
170
+ console.log(`βœ… Planning phase completed!`);
171
+ console.log(`πŸ“ˆ Created plan with ${result.corePlan.steps.length} steps`);
172
+ const estimated = result.corePlan.timeline?.estimated;
173
+ if (estimated)
174
+ console.log(`⏱️ Timeline: ${estimated}`);
175
+ console.log(`⚠️ Identified ${result.risks.length} risks`);
176
+ return result;
177
+ }
178
+ async handleExecution() {
179
+ console.log(`πŸ”§ Starting execution phase...`);
180
+ const progressCallback = (message) => {
181
+ console.log(` ⚑ ${message}`);
182
+ };
183
+ const plugin = this.requirePlugin();
184
+ const result = await plugin.executeWorkingPhase(progressCallback);
185
+ console.log(`βœ… Execution phase completed!`);
186
+ console.log(`πŸ“‹ Completed ${result.coreWork.steps.length} steps`);
187
+ console.log(`πŸ”§ Resolved ${result.issues.length} issues`);
188
+ console.log(`πŸ’‘ Applied ${result.solutions.length} solutions`);
189
+ return result;
190
+ }
191
+ async handleReview(options) {
192
+ console.log(`πŸ” Starting review phase...`);
193
+ const criteria = parseJsonOption(options.criteria);
194
+ const plugin = this.requirePlugin();
195
+ const result = await plugin.executeReviewPhase(criteria);
196
+ console.log(`βœ… Review phase completed!`);
197
+ console.log(`πŸ“Š Overall score: ${result.coreReview.review.overallScore}/100`);
198
+ console.log(`πŸ’‘ Generated ${result.learnings.length} learnings`);
199
+ console.log(`πŸ“‹ Created ${result.recommendations.length} recommendations`);
200
+ return result;
201
+ }
202
+ async handleStatus() {
203
+ const plugin = this.requirePlugin();
204
+ const status = await plugin.getProjectStatus();
205
+ console.log(`πŸ“Š Project Status:`);
206
+ console.log(` Project: ${status.project ?? "No active project"}`);
207
+ console.log(` Session: ${status.sessionId ?? "N/A"}`);
208
+ console.log(` Current Phase: ${status.currentPhase ?? "N/A"}`);
209
+ if (status.progress) {
210
+ console.log(` Progress: ${status.progress.completed}/${status.progress.total} (${status.progress.percentage}%)`);
211
+ }
212
+ if (status.nextSteps && status.nextSteps.length > 0) {
213
+ console.log(`\n🎯 Next Steps:`);
214
+ status.nextSteps.forEach((step, i) => {
215
+ console.log(` ${i + 1}. ${step}`);
216
+ });
217
+ }
218
+ return status;
219
+ }
220
+ async handleCLI(args) {
221
+ const [subcommand, ...subArgs] = args;
222
+ switch (subcommand) {
223
+ case "generate":
224
+ if (subArgs.length === 0) {
225
+ throw new Error("Usage: ci cli generate <repository-path>");
226
+ }
227
+ return this.handleCLIGenerate(subArgs[0]);
228
+ case "list":
229
+ return this.handleCLIList();
230
+ default:
231
+ throw new Error("Usage: ci cli <generate|list> [args]");
232
+ }
233
+ }
234
+ async handleCLIGenerate(repoPath) {
235
+ console.log(`πŸ› οΈ Generating CLI for: ${repoPath}`);
236
+ const plugin = this.requirePlugin();
237
+ const result = await plugin.cliAnything.generateCLI(repoPath);
238
+ console.log(`βœ… CLI generated successfully!`);
239
+ console.log(`πŸ“ Output: ${result.outputPath}`);
240
+ console.log(`πŸ”§ Commands: ${result.commands.length}`);
241
+ console.log(`\nπŸ“‹ Available Commands:`);
242
+ for (const cmd of result.commands) {
243
+ console.log(` ${cmd.name.padEnd(15)} - ${cmd.description}`);
244
+ }
245
+ return result;
246
+ }
247
+ handleCLIList() {
248
+ console.log(`πŸ› οΈ CLI Generation Tool Status: Ready`);
249
+ console.log(` Repository Analysis: Supported`);
250
+ console.log(` Project Types: Node.js, React, Python, Docker, and more`);
251
+ console.log(` Output Format: Executable JavaScript`);
252
+ }
253
+ async handlePM(args, options) {
254
+ const [subcommand, ...subArgs] = args;
255
+ switch (subcommand) {
256
+ case "analyze":
257
+ return this.handlePMAnalyze(options);
258
+ case "skill":
259
+ return this.handlePMSkill(subArgs);
260
+ case "list":
261
+ return this.handlePMList();
262
+ default:
263
+ throw new Error("Usage: ci pm <analyze|skill|list> [args]");
264
+ }
265
+ }
266
+ async handlePMAnalyze(options) {
267
+ console.log(`πŸ“Š Running comprehensive PM analysis...`);
268
+ const productInfo = {
269
+ product: parseJsonOption(options.product) ?? {},
270
+ industry: options.industry ?? "Technology",
271
+ targetMarket: parseJsonOption(options.targetMarket) ?? {},
272
+ };
273
+ const plugin = this.requirePlugin();
274
+ const result = await plugin.pmSkills.runProductAnalysis(productInfo);
275
+ console.log(`βœ… PM analysis completed!`);
276
+ console.log(`πŸ“Š Summary: ${result.summary.completedSkills}/${result.summary.totalSkills} skills completed`);
277
+ console.log(`πŸ’‘ Key insights: ${result.summary.keyInsights.length}`);
278
+ console.log(`πŸ“‹ Recommendations: ${result.summary.recommendations.length}`);
279
+ console.log(`πŸ“ Results saved to: ${result.savedTo}`);
280
+ return result;
281
+ }
282
+ async handlePMSkill(args) {
283
+ if (args.length === 0) {
284
+ throw new Error("Usage: ci pm skill <skill-name>");
285
+ }
286
+ const [skillName] = args;
287
+ console.log(`πŸ“Š Executing PM skill: ${skillName}`);
288
+ const input = {
289
+ product: { name: "Sample Product" },
290
+ market: { size: "Medium" },
291
+ };
292
+ const plugin = this.requirePlugin();
293
+ const result = await plugin.pmSkills.executeSkill(skillName, input);
294
+ console.log(`βœ… PM skill ${skillName} completed!`);
295
+ console.log(`πŸ“ Results saved to: ${result.savedTo}`);
296
+ return result;
297
+ }
298
+ handlePMList() {
299
+ const plugin = this.requirePlugin();
300
+ const skills = plugin.pmSkills.getAvailableSkills();
301
+ console.log(`πŸ“Š Available PM Skills:`);
302
+ for (const skill of skills) {
303
+ console.log(` ${skill.name.padEnd(20)} - ${skill.description} [${skill.category}]`);
304
+ }
305
+ }
306
+ async handleCompound(args) {
307
+ const [subcommand, ...subArgs] = args;
308
+ switch (subcommand) {
309
+ case "session":
310
+ return this.handleCompoundSession(subArgs);
311
+ case "learnings":
312
+ return this.handleCompoundLearnings();
313
+ default:
314
+ throw new Error("Usage: ci compound <session|learnings> [args]");
315
+ }
316
+ }
317
+ async handleCompoundSession(args) {
318
+ if (args.length < 2) {
319
+ throw new Error("Usage: ci compound session <project-name> <objective>");
320
+ }
321
+ const [name, ...objectiveParts] = args;
322
+ const objective = objectiveParts.join(" ");
323
+ console.log(`πŸ”§ Starting compound engineering session...`);
324
+ const plugin = this.requirePlugin();
325
+ const session = await plugin.compoundEngineering.startSession(name, objective);
326
+ console.log(`βœ… Session started!`);
327
+ console.log(`πŸ†” Session ID: ${session.id}`);
328
+ console.log(`πŸ“‹ Objective: ${session.objective}`);
329
+ console.log(`πŸ”„ Current Phase: ${session.phase}`);
330
+ return session;
331
+ }
332
+ async handleCompoundLearnings() {
333
+ console.log(`πŸ“š Loading compound engineering learnings...`);
334
+ const plugin = this.requirePlugin();
335
+ await plugin.compoundEngineering.loadLearnings();
336
+ const learnings = plugin.compoundEngineering.getAllLearnings();
337
+ console.log(`πŸ“š Found ${learnings.length} learnings:`);
338
+ for (const learning of learnings) {
339
+ console.log(` [${learning.confidence.toFixed(2)}] ${learning.summary}`);
340
+ }
341
+ return learnings;
342
+ }
343
+ async handleLearnings(args) {
344
+ const [subcommand, ...subArgs] = args;
345
+ switch (subcommand) {
346
+ case "search":
347
+ return this.handleLearningsSearch(subArgs.join(" "));
348
+ case "all":
349
+ return this.handleLearningsAll();
350
+ default:
351
+ throw new Error("Usage: ci learnings <search|all> [query]");
352
+ }
353
+ }
354
+ async handleLearningsSearch(query) {
355
+ console.log(`πŸ” Searching learnings for: "${query}"`);
356
+ const plugin = this.requirePlugin();
357
+ await plugin.compoundEngineering.loadLearnings();
358
+ const results = plugin.compoundEngineering.searchLearnings(query);
359
+ console.log(`πŸ” Found ${results.length} matching learnings:`);
360
+ for (const learning of results) {
361
+ console.log(` [${learning.confidence.toFixed(2)}] ${learning.summary}`);
362
+ }
363
+ return results;
364
+ }
365
+ async handleLearningsAll() {
366
+ console.log(`πŸ“š Loading all learnings...`);
367
+ const plugin = this.requirePlugin();
368
+ await plugin.compoundEngineering.loadLearnings();
369
+ const learnings = plugin.compoundEngineering.getAllLearnings();
370
+ console.log(`πŸ“š Total learnings: ${learnings.length}`);
371
+ const grouped = learnings.reduce((groups, learning) => {
372
+ const type = learning.type || "general";
373
+ if (!groups[type])
374
+ groups[type] = [];
375
+ groups[type].push(learning);
376
+ return groups;
377
+ }, {});
378
+ for (const [type, items] of Object.entries(grouped)) {
379
+ console.log(`\n ${type.charAt(0).toUpperCase() + type.slice(1)} (${items.length}):`);
380
+ for (const learning of items) {
381
+ console.log(` [${learning.confidence.toFixed(2)}] ${learning.summary}`);
382
+ }
383
+ }
384
+ return learnings;
385
+ }
386
+ async handleConfig(args) {
387
+ const [subcommand, ...subArgs] = args;
388
+ switch (subcommand) {
389
+ case "show":
390
+ return this.handleConfigShow();
391
+ case "set":
392
+ return this.handleConfigSet(subArgs);
393
+ default:
394
+ throw new Error("Usage: ci config <show|set> [key] [value]");
395
+ }
396
+ }
397
+ handleConfigShow() {
398
+ console.log(`βš™οΈ Current Configuration:`);
399
+ console.log(` Workspace: ${this.config.workspace}`);
400
+ console.log(` Verbose: ${this.config.verbose}`);
401
+ console.log(` Default Mode: ${this.config.defaultMode}`);
402
+ }
403
+ handleConfigSet(args) {
404
+ if (args.length < 2) {
405
+ throw new Error("Usage: ci config set <key> <value>");
406
+ }
407
+ const [key, value] = args;
408
+ if (!key || value === undefined) {
409
+ throw new Error("Usage: ci config set <key> <value>");
410
+ }
411
+ if (key === "workspace") {
412
+ this.config.workspace = value;
413
+ }
414
+ else if (key === "verbose") {
415
+ this.config.verbose = value === "true";
416
+ }
417
+ else if (key === "defaultMode") {
418
+ this.config.defaultMode = value;
419
+ }
420
+ else {
421
+ throw new Error(`Unknown config key: ${key}`);
422
+ }
423
+ console.log(`βœ… Configuration updated: ${key} = ${value}`);
424
+ }
425
+ }
426
+ function parseGlobalOptions(args) {
427
+ const options = {};
428
+ for (let i = 0; i < args.length; i++) {
429
+ const flag = args[i];
430
+ const next = args[i + 1];
431
+ const consumeValue = (key) => {
432
+ if (next === undefined)
433
+ return;
434
+ options[key] = next;
435
+ args.splice(i, 2);
436
+ i--;
437
+ };
438
+ switch (flag) {
439
+ case "--workspace":
440
+ consumeValue("workspace");
441
+ break;
442
+ case "--verbose":
443
+ options.verbose = true;
444
+ args.splice(i, 1);
445
+ i--;
446
+ break;
447
+ case "--repo":
448
+ consumeValue("repo");
449
+ break;
450
+ case "--product":
451
+ consumeValue("product");
452
+ break;
453
+ case "--industry":
454
+ consumeValue("industry");
455
+ break;
456
+ case "--target-market":
457
+ consumeValue("targetMarket");
458
+ break;
459
+ default:
460
+ break;
461
+ }
462
+ }
463
+ return options;
464
+ }
465
+ async function main() {
466
+ const [, , command, ...args] = process.argv;
467
+ if (!command || command === "--help" || command === "-h") {
468
+ console.log(`
469
+ Unified Continuous Improvement CLI
470
+
471
+ Usage: ci <command> [args] [options]
472
+
473
+ Main Commands:
474
+ init <name> <objective> Initialize new project with comprehensive analysis
475
+ workflow <name> <objective> Run complete end-to-end workflow
476
+ research Execute research phase
477
+ planning Execute planning phase
478
+ execution Execute execution phase
479
+ review Execute review phase
480
+ status Show project status
481
+
482
+ Tool Commands:
483
+ cli generate <repo-path> Generate CLI for repository
484
+ pm analyze Run comprehensive PM analysis
485
+ pm skill <name> Execute specific PM skill
486
+ pm list List available PM skills
487
+ compound session <name> <obj> Start compound engineering session
488
+ compound learnings Show compound engineering learnings
489
+ learnings search <query> Search through all learnings
490
+ learnings all Show all learnings
491
+
492
+ Configuration:
493
+ config show Show current configuration
494
+ config set <key> <value> Set configuration value
495
+
496
+ Global Options:
497
+ --workspace <dir> Workspace directory
498
+ --verbose Enable verbose logging
499
+ --repo <path> Repository path for CLI generation
500
+ --product <json> Product information as JSON
501
+ --industry <name> Industry name
502
+ --target-market <json> Target market as JSON
503
+
504
+ Examples:
505
+ ci init "MyApp" "Build a task management app"
506
+ ci workflow "MyApp" "Build task management" --repo ./my-app
507
+ ci cli generate ./my-repo
508
+ ci pm analyze --industry "SaaS" --target-market '{"segment":"SMB"}'
509
+ ci learnings search "performance"
510
+ `);
511
+ process.exit(0);
512
+ }
513
+ const cli = new UnifiedCLI();
514
+ const options = parseGlobalOptions(args);
515
+ try {
516
+ const result = await cli.runCommand(command, args, options);
517
+ if (options.verbose && result) {
518
+ console.log(`\nπŸ” Detailed result:`);
519
+ console.log(JSON.stringify(result, null, 2));
520
+ }
521
+ }
522
+ catch (error) {
523
+ console.error(`❌ Error: ${getErrorMessage(error)}`);
524
+ process.exit(1);
525
+ }
526
+ }
527
+ if (import.meta.url === `file://${process.argv[1]}`) {
528
+ main().catch((error) => {
529
+ console.error(`❌ Fatal error: ${getErrorMessage(error)}`);
530
+ process.exit(1);
531
+ });
532
+ }
533
+ export default UnifiedCLI;
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: continuous-improvement
3
- description: "Reflect on the current session, analyze observations for patterns, and show instinct status. Run after finishing significant work."
3
+ description: "Reflect on the current session, analyze observations for patterns, and show instinct status. Runs on-demand to save tokens."
4
4
  ---
5
5
 
6
6
  # /continuous-improvement
7
7
 
8
- Run this after completing significant work. It does three things in order.
8
+ Run this when you want to reflect and learn β€” not every session. Three steps in order.
9
9
 
10
10
  ## Step 1: Reflect
11
11
 
@@ -17,10 +17,20 @@ Generate a reflection for this session based on what happened:
17
17
  - What failed:
18
18
  - What I'd do differently:
19
19
  - Rule to add:
20
+ - Iteration β€” Next best recommendations (ranked, top 3):
21
+ 1. <primary β€” strongest next move>
22
+ 2. <alternative β€” different angle>
23
+ 3. <alternative β€” smaller/larger scope>
20
24
  ```
21
25
 
22
26
  If there's a "Rule to add", create an instinct YAML file with 0.6 starting confidence in the project's instinct directory.
23
27
 
28
+ The "Iteration β€” Next best recommendations" field is the Law 6 handoff. List the **top 3 ranked** core-development moves β€” what to build, fix, refactor, or investigate next so the feature/system advances. Item #1 is the strongest; #2 and #3 are alternatives the user can pivot to. NOT git steps (commit, push, PR), NOT verification re-runs, NOT deploy actions β€” those belong in the end-of-run summary.
29
+
30
+ Format per item: `<verb> <object at path:line> (<why, one clause grounded in current context>)`.
31
+
32
+ Rules: always exactly 3 distinct directions, not padding. If fewer real moves exist, fill remaining slots with `None β€” goal met from this angle.` If the goal is fully met across all angles, write `1. None β€” goal met, stop.` and omit #2 and #3.
33
+
24
34
  ## Step 2: Analyze Observations
25
35
 
26
36
  Check `~/.claude/instincts/` for the current project (detect via git root β†’ SHA-256 first 12 chars).
@@ -39,6 +49,15 @@ Look at `~/.claude/instincts/<hash>/observations.jsonl`. If 20+ lines exist:
39
49
 
40
50
  If fewer than 20 observations, skip analysis and note the count.
41
51
 
52
+ ### Multi-Agent Analysis (500+ observations)
53
+
54
+ When observation backlog is large, parallelize:
55
+ - **Agent 1:** User corrections + error→fix patterns
56
+ - **Agent 2:** Repeated workflows + tool preferences
57
+ - **Agent 3:** Cross-reference existing instincts for updates
58
+
59
+ Merge results and deduplicate before writing YAML files.
60
+
42
61
  ## Step 3: Show Status
43
62
 
44
63
  Display all instincts for the current project + global:
@@ -53,6 +72,10 @@ Display all instincts for the current project + global:
53
72
  - What failed: [from this session]
54
73
  - What I'd do differently: [from this session]
55
74
  - Rule to add: [captured as instinct]
75
+ - Iteration β€” Next best recommendations (ranked, top 3):
76
+ 1. [primary core-development move]
77
+ 2. [alternative angle]
78
+ 3. [alternative scope]
56
79
 
57
80
  ## Learning
58
81
  NEW [instinct-id] [domain] [confidence] (from reflection)
@@ -72,3 +95,21 @@ Display all instincts for the current project + global:
72
95
  ```
73
96
 
74
97
  If no instincts or observations exist yet, explain this is expected β€” the system is in CAPTURE level and will create instincts after 20+ observations accumulate.
98
+
99
+ ## Subcommands
100
+
101
+ ### `/continuous-improvement weekly`
102
+
103
+ Set up a weekly analysis schedule:
104
+ 1. Create a cron/loop schedule that runs `/continuous-improvement analyze` every 7 days
105
+ 2. Confirm the schedule to the user
106
+ 3. Show next scheduled run date
107
+
108
+ ### `/continuous-improvement always-on`
109
+
110
+ Toggle always-on mode for the current project:
111
+ 1. Find project hash
112
+ 2. Create/update `~/.claude/instincts/<hash>/config.yaml` with `always_on: true|false`
113
+ 3. Confirm the change
114
+
115
+ **Default is off** β€” observations accumulate silently, analysis only runs when you ask.
@@ -19,6 +19,20 @@ Print this card and check yourself against each law.
19
19
  | 6 | **Iterate One Change** | Am I changing one thing at a time? | "And also..." |
20
20
  | 7 | **Learn From Every Session** | Did I capture this as an instinct? | "Next time I'll..." |
21
21
 
22
+ ## Operator Stakes
23
+
24
+ The Laws above are the *how*. These five principles are the *why*: code ships from your account, the incident lands on your pager, the bill hits your budget. Each one pairs with the Law that prevents it from going wrong.
25
+
26
+ | # | Principle | Vibe coder | Engineer | Law |
27
+ |---|-----------|------------|----------|-----|
28
+ | 1 | **Ownership** | Ships auth, moves on | Adds rate limits, audit logs, password-reset flow, incident runbook before shipping | 4 |
29
+ | 2 | **Reliability over cleverness** | Accepts a clever regex + heavy lib that breaks on ISO 8601 with millis | Picks the boring tested API, writes tests for leap years and DST | 1 |
30
+ | 3 | **Systems thinking** | Builds in-memory CSV export, works for 100 dev users, OOMs in prod | Asks row count first, picks paginated background job + S3 link | 2 |
31
+ | 4 | **Problem framing** | Builds the websocket chat the ticket asked for | Finds out users wanted faster support replies, not chat | 1 |
32
+ | 5 | **Constraints management** | Calls the $0.02/image model on every upload | Does the math, adds client-side validation + caching + cheaper triage model | 2 |
33
+
34
+ Code is a liability, not an asset. Speed without these five turns into someone else's incident at 3am β€” except the someone is you.
35
+
22
36
  ## The Loop
23
37
 
24
38
  ```