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,85 @@
1
+ /**
2
+ * Gateguard per-session state.
3
+ *
4
+ * State file: <sessionDir>/gateguard-session.json. sessionDir resolves to
5
+ * GATEGUARD_SESSION_DIR (env override, used by tests) or
6
+ * ~/.claude/instincts/<projectHash>/ in production.
7
+ *
8
+ * V1 limitations (documented for honesty, not mitigated in code):
9
+ * - Honor system: clearance is granted whenever the agent sets
10
+ * `_gateguard_facts_presented: true` in tool_input or has a prior per-file
11
+ * marker. The hook cannot verify that real investigation occurred.
12
+ * - State-file deletion: rm'ing the state file resets every gate in the
13
+ * session. Defensible because the session itself is the trust boundary;
14
+ * the cap below limits cumulative damage.
15
+ * - Concurrency: two parallel hook invocations can race the read+write.
16
+ * Acceptable trade-off vs OS-specific atomic-rename complexity on Windows.
17
+ * - Cap: MAX_CLEARED_FILES caps the number of distinct files a single
18
+ * session can clear, bounding stuck-loop / rogue-agent damage.
19
+ */
20
+ import { createHash } from "node:crypto";
21
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
22
+ import { execFileSync } from "node:child_process";
23
+ import { homedir } from "node:os";
24
+ import { join } from "node:path";
25
+ export const MAX_CLEARED_FILES = 50;
26
+ export function resolveSessionDir() {
27
+ const fromEnv = process.env.GATEGUARD_SESSION_DIR;
28
+ if (fromEnv)
29
+ return fromEnv;
30
+ const home = process.env.HOME || process.env.USERPROFILE || homedir();
31
+ const projectRoot = resolveProjectRoot();
32
+ const projectHash = createHash("sha256").update(projectRoot).digest("hex").slice(0, 12);
33
+ return join(home, ".claude", "instincts", projectHash);
34
+ }
35
+ function resolveProjectRoot() {
36
+ const fromEnv = process.env.CLAUDE_PROJECT_DIR;
37
+ if (fromEnv)
38
+ return fromEnv;
39
+ try {
40
+ const root = execFileSync("git", ["rev-parse", "--show-toplevel"], {
41
+ encoding: "utf8",
42
+ stdio: ["ignore", "pipe", "ignore"],
43
+ }).trim();
44
+ if (root)
45
+ return root;
46
+ }
47
+ catch {
48
+ // not in a git repo
49
+ }
50
+ return "global";
51
+ }
52
+ export function loadState(sessionDir) {
53
+ const path = join(sessionDir, "gateguard-session.json");
54
+ if (!existsSync(path)) {
55
+ return { created_at: new Date().toISOString(), cleared_files: {} };
56
+ }
57
+ try {
58
+ const raw = readFileSync(path, "utf8");
59
+ const parsed = JSON.parse(raw);
60
+ return {
61
+ created_at: parsed.created_at ?? new Date().toISOString(),
62
+ cleared_files: parsed.cleared_files ?? {},
63
+ };
64
+ }
65
+ catch {
66
+ return { created_at: new Date().toISOString(), cleared_files: {} };
67
+ }
68
+ }
69
+ export function saveState(sessionDir, state) {
70
+ if (!existsSync(sessionDir))
71
+ mkdirSync(sessionDir, { recursive: true });
72
+ writeFileSync(join(sessionDir, "gateguard-session.json"), `${JSON.stringify(state, null, 2)}\n`);
73
+ }
74
+ export function isCapReached(state) {
75
+ return Object.keys(state.cleared_files).length >= MAX_CLEARED_FILES;
76
+ }
77
+ export function markFileCleared(state, filePath) {
78
+ return {
79
+ ...state,
80
+ cleared_files: {
81
+ ...state.cleared_files,
82
+ [filePath]: { cleared_at: new Date().toISOString() },
83
+ },
84
+ };
85
+ }
@@ -0,0 +1,128 @@
1
+ // observe-event.mts — Pure parsers for the Mulahazah observation hook.
2
+ //
3
+ // These functions have NO I/O. They turn raw stdin text and tool input/output
4
+ // payloads into shaped data the entrypoint (src/bin/observe.mts) writes to
5
+ // observations.jsonl. Pure separation lets the unit tests cover schema edge
6
+ // cases (malformed JSON, missing fields, oversized payloads) without ever
7
+ // touching the filesystem or computing project hashes.
8
+ //
9
+ // Truncation budgets match the prior bash/jq behavior to preserve the existing
10
+ // privacy contract: input head ≤500 chars, output head ≤200 chars.
11
+ const INPUT_TRUNCATE = 500;
12
+ const OUTPUT_TRUNCATE = 200;
13
+ /**
14
+ * Parse the raw JSON stdin payload from a Claude Code PreToolUse/PostToolUse
15
+ * hook event. Returns null for any unparseable or schema-invalid input —
16
+ * never throws. Empty/null/array payloads are rejected (the harness only
17
+ * sends objects).
18
+ *
19
+ * Field-name normalisation: Claude Code's PostToolUse payload uses
20
+ * `tool_response`. Older mocks and some third-party harnesses emit
21
+ * `tool_output` or `toolOutput`. We accept all three at the boundary and
22
+ * expose a single `tool_response` field downstream so the discriminator and
23
+ * `summariseOutput` only have to know one name.
24
+ */
25
+ export function parseHookPayload(raw) {
26
+ if (!raw)
27
+ return null;
28
+ let parsed;
29
+ try {
30
+ parsed = JSON.parse(raw);
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
36
+ return null;
37
+ }
38
+ const obj = parsed;
39
+ if (typeof obj.tool_name !== "string" || obj.tool_name.length === 0) {
40
+ return null;
41
+ }
42
+ const toolResponse = obj.tool_response !== undefined
43
+ ? obj.tool_response
44
+ : obj.tool_output !== undefined
45
+ ? obj.tool_output
46
+ : obj.toolOutput;
47
+ return {
48
+ tool_name: obj.tool_name,
49
+ session_id: typeof obj.session_id === "string" ? obj.session_id : "",
50
+ tool_input: obj.tool_input,
51
+ tool_response: toolResponse,
52
+ };
53
+ }
54
+ /**
55
+ * Extract a tool-aware short summary from `tool_input`. Tool-specific cases
56
+ * cover the high-frequency surfaces the linter/analyser reads (Bash command
57
+ * head, Edit/Write/Read file_path, Grep/Glob pattern). Unknown tools fall
58
+ * back to JSON.stringify(input) capped at INPUT_TRUNCATE.
59
+ *
60
+ * Returns an empty string when the expected field is missing on a known tool
61
+ * or when input is null/undefined — never returns "undefined" or "null"
62
+ * literals to the caller.
63
+ */
64
+ export function summariseInput(toolName, input) {
65
+ if (input === null || input === undefined)
66
+ return "";
67
+ switch (toolName) {
68
+ case "Bash": {
69
+ const cmd = readStringField(input, "command");
70
+ return cmd === null ? "" : truncate(cmd, INPUT_TRUNCATE);
71
+ }
72
+ case "Edit":
73
+ case "Write":
74
+ case "Read":
75
+ case "NotebookEdit": {
76
+ const path = readStringField(input, "file_path");
77
+ return path === null ? "" : truncate(path, INPUT_TRUNCATE);
78
+ }
79
+ case "Grep":
80
+ case "Glob": {
81
+ const pattern = readStringField(input, "pattern");
82
+ return pattern === null ? "" : truncate(pattern, INPUT_TRUNCATE);
83
+ }
84
+ default: {
85
+ // Unknown tool: stringify input so we record *something* useful for
86
+ // future analysis. Truncate to keep observations.jsonl row size bounded.
87
+ let serialised;
88
+ try {
89
+ serialised = JSON.stringify(input);
90
+ }
91
+ catch {
92
+ serialised = "";
93
+ }
94
+ return truncate(serialised ?? "", INPUT_TRUNCATE);
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * Extract a short summary from `tool_response`. Strings pass through (capped
100
+ * at OUTPUT_TRUNCATE); numbers/booleans coerce to string; objects
101
+ * JSON-stringify. Null/undefined collapse to "".
102
+ */
103
+ export function summariseOutput(output) {
104
+ if (output === null || output === undefined)
105
+ return "";
106
+ if (typeof output === "string")
107
+ return truncate(output, OUTPUT_TRUNCATE);
108
+ if (typeof output === "number" || typeof output === "boolean") {
109
+ return String(output);
110
+ }
111
+ let serialised;
112
+ try {
113
+ serialised = JSON.stringify(output);
114
+ }
115
+ catch {
116
+ serialised = "";
117
+ }
118
+ return truncate(serialised ?? "", OUTPUT_TRUNCATE);
119
+ }
120
+ function readStringField(input, field) {
121
+ if (input === null || typeof input !== "object")
122
+ return null;
123
+ const value = input[field];
124
+ return typeof value === "string" ? value : null;
125
+ }
126
+ function truncate(value, max) {
127
+ return value.length > max ? value.slice(0, max) : value;
128
+ }
@@ -0,0 +1,435 @@
1
+ export const PACKAGE_NAME = "continuous-improvement";
2
+ export const VERSION = "3.9.0";
3
+ export const PLUGIN_MODES = ["beginner", "expert"];
4
+ const REPOSITORY_URL = "https://github.com/naimkatiman/continuous-improvement";
5
+ const HOMEPAGE_URL = `${REPOSITORY_URL}#readme`;
6
+ const AUTHOR = {
7
+ name: "naimkatiman",
8
+ url: "https://github.com/naimkatiman",
9
+ };
10
+ const KEYWORDS = [
11
+ "claude-code",
12
+ "claude-code-skill",
13
+ "ai-agent",
14
+ "agent-skill",
15
+ "ai-discipline",
16
+ "mulahazah",
17
+ "instinct",
18
+ "hooks",
19
+ "mcp",
20
+ "mcp-server",
21
+ "github-action",
22
+ "transcript-linter",
23
+ ];
24
+ const CLAUDE_PLUGIN_CATEGORY = "productivity";
25
+ const SHARED_PLUGIN_DESCRIPTION = "Stops Claude Code from skipping research, claiming 'done' without verifying, and repeating yesterday's mistakes. The 7 Laws of AI Agent Discipline — 13 enforcement skills, gating hooks, and the Mulahazah auto-leveling instinct engine.";
26
+ // Four vendored upstream companions registered alongside the CI plugin.
27
+ // Each entry points at a pinned-SHA snapshot under third-party/<name>/.
28
+ // See third-party/MANIFEST.md for refresh recipes and per-snapshot
29
+ // OUR_NOTES.md for integration scope and overlap matrices. The unified
30
+ // /superpowers dispatcher (skills/superpowers.md) routes across all four.
31
+ // Product-management coverage is supplied by phuryn/pm-skills as an
32
+ // out-of-band marketplace install — see docs/THIRD_PARTY.md for the
33
+ // `claude plugin marketplace add phuryn/pm-skills` recipe and the eight
34
+ // installable plugins (pm-toolkit, pm-product-strategy, pm-product-discovery,
35
+ // pm-market-research, pm-data-analytics, pm-marketing-growth,
36
+ // pm-go-to-market, pm-execution).
37
+ const THIRD_PARTY_COMPANIONS = [
38
+ {
39
+ name: "superpowers",
40
+ description: "Obra's core skills library: TDD, debugging, brainstorming, writing-plans, executing-plans, dispatching-parallel-agents, using-git-worktrees, finishing-a-development-branch, subagent-driven-development, requesting-code-review, receiving-code-review, systematic-debugging, verification-before-completion, writing-skills, using-superpowers. Vendored snapshot at third-party/superpowers/ pinned to upstream SHA f2cbfbe (v5.1.0). Companion to the /superpowers dispatcher in continuous-improvement plugin.",
41
+ version: "5.1.0",
42
+ source: "./third-party/superpowers",
43
+ author: {
44
+ name: "Jesse Vincent",
45
+ email: "jesse@fsck.com",
46
+ },
47
+ category: "workflow",
48
+ homepage: "https://github.com/obra/superpowers",
49
+ },
50
+ {
51
+ name: "agent-skills",
52
+ description: "Addy Osmani's production-grade engineering skills for AI coding agents — 21 skills covering the full software development lifecycle: spec-driven-development, source-driven-development, context-engineering, idea-refine, incremental-implementation, test-driven-development, code-review-and-quality, code-simplification, security-and-hardening, debugging-and-error-recovery, performance-optimization, api-and-interface-design, frontend-ui-engineering, browser-testing-with-devtools, ci-cd-and-automation, deprecation-and-migration, documentation-and-adrs, git-workflow-and-versioning, planning-and-task-breakdown, shipping-and-launch, using-agent-skills. Vendored snapshot at third-party/addy-agent-skills/ pinned to upstream SHA 742dca5 (v1.0.0).",
53
+ version: "1.0.0",
54
+ source: "./third-party/addy-agent-skills",
55
+ author: {
56
+ name: "Addy Osmani",
57
+ },
58
+ category: "workflow",
59
+ homepage: "https://github.com/addyosmani/agent-skills",
60
+ },
61
+ {
62
+ name: "ruflo-swarm",
63
+ description: "Agent teams, swarm coordination, Monitor streams, and worktree isolation. Wraps 4 swarm_* + 8 agent_* MCP tools (12 total) plus 6 topologies (hierarchical, mesh, hierarchical-mesh, ring, star, adaptive). Slash commands /swarm and /watch. Skills swarm-init and monitor-stream. Cherry-picked from ruvnet/ruflo monorepo (the other 31 plugins are explicitly out of scope). Vendored snapshot at third-party/ruflo-swarm/ pinned to upstream SHA addb5cd (v0.2.0). Activation note: assets reference unpinned npx @claude-flow/cli@latest — supply-chain risk inert until installed.",
64
+ version: "0.2.0",
65
+ source: "./third-party/ruflo-swarm",
66
+ author: {
67
+ name: "ruvnet",
68
+ url: "https://github.com/ruvnet",
69
+ },
70
+ category: "orchestration",
71
+ homepage: "https://github.com/ruvnet/ruflo",
72
+ },
73
+ {
74
+ name: "oh-my-claudecode",
75
+ description: "Multi-agent orchestration system for Claude Code — 39 skills + 19 agents covering audit, plan, build, verify, ship, release, retrospective, and ops. Includes ralph (autonomous PRD loop), release, ultrawork, ultraqa, team, trace, visual-verdict, debug, deep-dive, deep-interview, autopilot, autoresearch. Vendored snapshot at third-party/oh-my-claudecode/ pinned to upstream SHA aacde3e (v4.13.6). Heavy overlap with continuous-improvement /ralph and /superpowers — pick per task.",
76
+ version: "4.13.6",
77
+ source: "./third-party/oh-my-claudecode",
78
+ author: {
79
+ name: "Yeachan-Heo",
80
+ },
81
+ category: "orchestration",
82
+ homepage: "https://github.com/Yeachan-Heo/oh-my-claudecode",
83
+ },
84
+ ];
85
+ export function isPluginMode(value) {
86
+ return value === "beginner" || value === "expert";
87
+ }
88
+ const BEGINNER_TOOL_ENTRIES = [
89
+ {
90
+ name: "ci_status",
91
+ description: "Show current level, instinct count, and observation count for this project. Good starting point to see what the system has learned.",
92
+ manifestWhat: "See what the system has learned about your project",
93
+ inputSchema: { type: "object", properties: {}, required: [] },
94
+ },
95
+ {
96
+ name: "ci_instincts",
97
+ description: "List all learned instincts for this project with their confidence levels and behaviors.",
98
+ manifestWhat: "List all learned behaviors with confidence levels",
99
+ inputSchema: {
100
+ type: "object",
101
+ properties: {
102
+ min_confidence: {
103
+ type: "number",
104
+ description: "Minimum confidence to show (default: 0)",
105
+ default: 0,
106
+ },
107
+ },
108
+ required: [],
109
+ },
110
+ },
111
+ {
112
+ name: "ci_reflect",
113
+ description: "Generate a structured reflection for the current session. Provide a summary of what you worked on.",
114
+ manifestWhat: "Reflect on what you did this session",
115
+ inputSchema: {
116
+ type: "object",
117
+ properties: {
118
+ summary: {
119
+ type: "string",
120
+ description: "Brief summary of what was done this session",
121
+ },
122
+ },
123
+ required: ["summary"],
124
+ },
125
+ },
126
+ ];
127
+ const EXPERT_TOOL_ENTRIES = [
128
+ {
129
+ name: "ci_reinforce",
130
+ description: "Accept or reject an instinct suggestion. Adjusts confidence: +0.15 for accept, -0.1 for reject.",
131
+ manifestWhat: "Accept or reject instinct suggestions to tune confidence",
132
+ inputSchema: {
133
+ type: "object",
134
+ properties: {
135
+ instinct_id: { type: "string", description: "The instinct ID to reinforce" },
136
+ accepted: {
137
+ type: "boolean",
138
+ description: "true = accept (+0.15), false = reject (-0.1)",
139
+ },
140
+ },
141
+ required: ["instinct_id", "accepted"],
142
+ },
143
+ },
144
+ {
145
+ name: "ci_create_instinct",
146
+ description: "Manually create a new instinct with a trigger, body, and starting confidence.",
147
+ manifestWhat: "Manually create instincts with custom triggers and confidence",
148
+ inputSchema: {
149
+ type: "object",
150
+ properties: {
151
+ id: { type: "string", description: "Unique instinct ID (kebab-case)" },
152
+ trigger: { type: "string", description: "When this instinct applies" },
153
+ body: { type: "string", description: "The behavior to follow" },
154
+ confidence: {
155
+ type: "number",
156
+ description: "Starting confidence 0.0-0.9 (default: 0.6)",
157
+ default: 0.6,
158
+ },
159
+ domain: {
160
+ type: "string",
161
+ description: "Domain: workflow|tooling|testing|patterns|code-style",
162
+ default: "workflow",
163
+ },
164
+ scope: {
165
+ type: "string",
166
+ description: "Scope: project|global",
167
+ default: "project",
168
+ },
169
+ },
170
+ required: ["id", "trigger", "body"],
171
+ },
172
+ },
173
+ {
174
+ name: "ci_observations",
175
+ description: "View recent tool call observations captured by hooks.",
176
+ manifestWhat: "View raw tool call observations captured by hooks",
177
+ inputSchema: {
178
+ type: "object",
179
+ properties: {
180
+ limit: {
181
+ type: "number",
182
+ description: "Number of recent observations to return (default: 20)",
183
+ default: 20,
184
+ },
185
+ },
186
+ required: [],
187
+ },
188
+ },
189
+ {
190
+ name: "ci_export",
191
+ description: "Export all instincts as a JSON array for sharing or backup.",
192
+ manifestWhat: "Export instincts as JSON for sharing or backup",
193
+ inputSchema: {
194
+ type: "object",
195
+ properties: {
196
+ scope: {
197
+ type: "string",
198
+ description: "Which instincts: project|global|all (default: all)",
199
+ default: "all",
200
+ },
201
+ },
202
+ required: [],
203
+ },
204
+ },
205
+ {
206
+ name: "ci_import",
207
+ description: "Import instincts from a JSON array. Skips duplicates by ID.",
208
+ manifestWhat: "Import instincts from JSON (skip duplicates)",
209
+ inputSchema: {
210
+ type: "object",
211
+ properties: {
212
+ instincts_json: {
213
+ type: "string",
214
+ description: "JSON array of instinct objects to import",
215
+ },
216
+ scope: {
217
+ type: "string",
218
+ description: "Import to: project|global (default: project)",
219
+ default: "project",
220
+ },
221
+ },
222
+ required: ["instincts_json"],
223
+ },
224
+ },
225
+ {
226
+ name: "ci_plan_init",
227
+ description: "Create task_plan.md, findings.md, and progress.md in the project root for persistent file-based planning.",
228
+ manifestWhat: "Create project-root planning files for persistent task memory",
229
+ inputSchema: {
230
+ type: "object",
231
+ properties: {
232
+ goal: { type: "string", description: "Goal for the planning workflow" },
233
+ phases: {
234
+ type: "array",
235
+ description: "Optional ordered phase names. Defaults to Research, Plan, Execute, Verify, Reflect.",
236
+ items: { type: "string" },
237
+ },
238
+ force: {
239
+ type: "boolean",
240
+ description: "Overwrite existing planning files",
241
+ default: false,
242
+ },
243
+ },
244
+ required: ["goal"],
245
+ },
246
+ },
247
+ {
248
+ name: "ci_plan_status",
249
+ description: "Summarize the status of task_plan.md, findings.md, and progress.md in the project root.",
250
+ manifestWhat: "Summarize task_plan.md, findings.md, and progress.md status",
251
+ inputSchema: {
252
+ type: "object",
253
+ properties: {
254
+ include_contents: {
255
+ type: "boolean",
256
+ description: "Include raw file contents in the response",
257
+ default: false,
258
+ },
259
+ },
260
+ required: [],
261
+ },
262
+ },
263
+ {
264
+ name: "ci_dashboard",
265
+ description: "Visual dashboard showing instinct health, observation stats, confidence distribution, and learning progress.",
266
+ manifestWhat: "Visual dashboard showing instinct health, confidence distribution, and learning progress",
267
+ inputSchema: { type: "object", properties: {}, required: [] },
268
+ },
269
+ {
270
+ name: "ci_load_pack",
271
+ description: "Load a starter instinct pack (react, python, go) into the current project.",
272
+ manifestWhat: "Load starter instinct packs (react, python, go) into the current project",
273
+ inputSchema: {
274
+ type: "object",
275
+ properties: {
276
+ pack: { type: "string", description: "Pack name: react, python, or go" },
277
+ },
278
+ required: ["pack"],
279
+ },
280
+ },
281
+ ];
282
+ const MODE_METADATA = {
283
+ beginner: {
284
+ description: "Beginner mode: see what your agent learned, list its instincts, and request a session reflection. Bundles four discipline skills (gateguard, para-memory-files, tdd-workflow, verification-loop) so research, memory, tests, and verification happen by default.",
285
+ hooks: ["PreToolUse", "PostToolUse"],
286
+ hookDescription: "Silently captures every tool call as observations. Lightweight and non-blocking.",
287
+ },
288
+ expert: {
289
+ description: "Expert mode: tune confidence, manage instincts, and persist plans on disk. Adds safety, token-budget, and strategic-compact skills plus the /learn-eval command so long sessions stay disciplined and learnings survive context resets.",
290
+ hooks: ["PreToolUse", "PostToolUse", "SessionStart", "SessionEnd"],
291
+ hookDescription: "Full hook suite: observation capture + session-level instinct loading and auto-reflection.",
292
+ },
293
+ };
294
+ function getToolCatalog(mode) {
295
+ return mode === "expert"
296
+ ? [...BEGINNER_TOOL_ENTRIES, ...EXPERT_TOOL_ENTRIES]
297
+ : [...BEGINNER_TOOL_ENTRIES];
298
+ }
299
+ export function getToolDefinitions(mode) {
300
+ return getToolCatalog(mode).map(({ name, description, inputSchema }) => ({
301
+ name,
302
+ description,
303
+ inputSchema,
304
+ }));
305
+ }
306
+ export function getToolNames(mode) {
307
+ return getToolCatalog(mode).map((tool) => tool.name);
308
+ }
309
+ export function getPluginManifest(mode) {
310
+ const modeMetadata = MODE_METADATA[mode];
311
+ const mcpServerConfig = {
312
+ command: "node",
313
+ args: ["<install-path>/bin/mcp-server.mjs", "--mode", mode],
314
+ };
315
+ return {
316
+ name: PACKAGE_NAME,
317
+ version: VERSION,
318
+ mode,
319
+ description: modeMetadata.description,
320
+ tools: getToolCatalog(mode).map((tool) => ({
321
+ name: tool.name,
322
+ what: tool.manifestWhat,
323
+ })),
324
+ setup: {
325
+ claude_desktop: {
326
+ mcpServers: {
327
+ [PACKAGE_NAME]: mcpServerConfig,
328
+ },
329
+ },
330
+ claude_code: {
331
+ mcpServers: {
332
+ [PACKAGE_NAME]: mcpServerConfig,
333
+ },
334
+ },
335
+ },
336
+ hooks: {
337
+ included: [...modeMetadata.hooks],
338
+ description: modeMetadata.hookDescription,
339
+ },
340
+ };
341
+ }
342
+ export function getClaudePluginManifest() {
343
+ return {
344
+ name: PACKAGE_NAME,
345
+ version: VERSION,
346
+ description: SHARED_PLUGIN_DESCRIPTION,
347
+ author: AUTHOR,
348
+ homepage: HOMEPAGE_URL,
349
+ repository: REPOSITORY_URL,
350
+ license: "MIT",
351
+ keywords: [...KEYWORDS],
352
+ };
353
+ }
354
+ export function getPluginHooksConfig() {
355
+ const gateguardCommand = {
356
+ type: "command",
357
+ command: "node \"${CLAUDE_PLUGIN_ROOT}/hooks/gateguard.mjs\"",
358
+ timeout: 5,
359
+ };
360
+ const observeCommand = {
361
+ type: "command",
362
+ command: "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/observe.sh\"",
363
+ timeout: 5,
364
+ };
365
+ const sessionCommand = {
366
+ type: "command",
367
+ command: "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session.sh\"",
368
+ timeout: 5,
369
+ };
370
+ const threeSectionCloseCommand = {
371
+ type: "command",
372
+ command: "node \"${CLAUDE_PLUGIN_ROOT}/hooks/three-section-close.mjs\"",
373
+ timeout: 5,
374
+ };
375
+ return {
376
+ description: "Gateguard fact-forcing PreToolUse, observation, session lifecycle, and 3-section-close discipline hooks for continuous-improvement.",
377
+ hooks: {
378
+ // gateguard runs FIRST so its block decision short-circuits before
379
+ // observe.sh records the tool call. observe.sh stays in PreToolUse for
380
+ // the observation feed; the Claude Code host runs both regardless of
381
+ // gateguard's decision.
382
+ PreToolUse: [{ hooks: [gateguardCommand, observeCommand] }],
383
+ PostToolUse: [{ hooks: [observeCommand] }],
384
+ SessionStart: [{ hooks: [sessionCommand] }],
385
+ SessionEnd: [{ hooks: [sessionCommand] }],
386
+ Stop: [{ hooks: [threeSectionCloseCommand] }],
387
+ },
388
+ };
389
+ }
390
+ export function getClaudePluginMarketplaceManifest() {
391
+ return {
392
+ name: `${PACKAGE_NAME}-dev`,
393
+ description: "Development marketplace for the Continuous Improvement Claude Code plugin.",
394
+ owner: {
395
+ name: AUTHOR.name,
396
+ },
397
+ plugins: [
398
+ {
399
+ name: PACKAGE_NAME,
400
+ description: SHARED_PLUGIN_DESCRIPTION,
401
+ version: VERSION,
402
+ source: "./",
403
+ author: {
404
+ name: AUTHOR.name,
405
+ },
406
+ category: CLAUDE_PLUGIN_CATEGORY,
407
+ homepage: REPOSITORY_URL,
408
+ },
409
+ ],
410
+ };
411
+ }
412
+ export function getClaudeRepoMarketplaceManifest(extraPlugins = []) {
413
+ return {
414
+ name: PACKAGE_NAME,
415
+ description: "Marketplace for the Continuous Improvement Claude Code plugin and four vendored upstream companions (Obra superpowers, addyosmani/agent-skills, ruflo-swarm, oh-my-claudecode). All four companions are pinned-SHA snapshots in third-party/ — see third-party/MANIFEST.md for refresh recipes and per-snapshot OUR_NOTES.md for integration scope. Product-management coverage is provided out-of-band by phuryn/pm-skills via Claude Code's plugin marketplace — see docs/THIRD_PARTY.md.",
416
+ owner: {
417
+ name: AUTHOR.name,
418
+ },
419
+ plugins: [
420
+ {
421
+ name: PACKAGE_NAME,
422
+ description: SHARED_PLUGIN_DESCRIPTION,
423
+ version: VERSION,
424
+ source: `./plugins/${PACKAGE_NAME}`,
425
+ author: {
426
+ name: AUTHOR.name,
427
+ },
428
+ category: CLAUDE_PLUGIN_CATEGORY,
429
+ homepage: REPOSITORY_URL,
430
+ },
431
+ ...THIRD_PARTY_COMPANIONS,
432
+ ...extraPlugins,
433
+ ],
434
+ };
435
+ }