continuous-improvement 3.9.2 → 3.12.3

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 (160) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +95 -0
  3. package/LICENSE +21 -21
  4. package/QUICKSTART.md +13 -8
  5. package/README.md +94 -162
  6. package/SKILL.md +1 -1
  7. package/bin/analyze.sh +161 -161
  8. package/bin/backfill.mjs +19 -19
  9. package/bin/check-docs-substrings.mjs +73 -0
  10. package/bin/check-scripts-citation-drift.mjs +210 -0
  11. package/bin/check-skill-count.mjs +110 -0
  12. package/bin/check-test-imports-only.mjs +126 -0
  13. package/bin/check-tool-count.mjs +129 -0
  14. package/bin/companion-preference-status.mjs +231 -0
  15. package/bin/gateguard-clear.mjs +53 -0
  16. package/bin/generate-plugin-manifests.mjs +8 -1
  17. package/bin/harvest-friction.mjs +1 -1
  18. package/bin/hook-stats.mjs +21 -21
  19. package/bin/install.mjs +185 -28
  20. package/bin/mcp-server.mjs +216 -3
  21. package/bin/refresh-third-party.mjs +315 -313
  22. package/commands/audit.md +34 -0
  23. package/commands/companion-preference.md +58 -0
  24. package/commands/continuous-improvement.md +115 -115
  25. package/commands/dashboard.md +56 -56
  26. package/commands/discipline.md +14 -0
  27. package/commands/distill.md +39 -0
  28. package/commands/goal-check.md +53 -0
  29. package/commands/grill-me.md +40 -0
  30. package/commands/grill-with-docs.md +38 -0
  31. package/commands/handoff.md +42 -0
  32. package/commands/harvest.md +1 -1
  33. package/commands/proceed-with-the-recommendation.md +20 -0
  34. package/commands/recall.md +49 -0
  35. package/commands/reconcile.md +47 -0
  36. package/commands/seven-laws.md +16 -16
  37. package/commands/superpowers.md +3 -3
  38. package/commands/verify-install.md +55 -0
  39. package/commands/workspace-surface-audit.md +77 -77
  40. package/hooks/companion-preference.mjs +190 -0
  41. package/hooks/gateguard.mjs +72 -25
  42. package/hooks/goal-drift-stop.mjs +183 -0
  43. package/hooks/observe.sh +15 -1
  44. package/hooks/recall-briefing.mjs +167 -0
  45. package/hooks/route-prompt.mjs +180 -0
  46. package/hooks/route-table.json +35 -0
  47. package/hooks/session.sh +106 -106
  48. package/hooks/three-section-close.mjs +134 -132
  49. package/instinct-packs/go.json +58 -58
  50. package/instinct-packs/meta.json +16 -16
  51. package/instinct-packs/python.json +58 -58
  52. package/instinct-packs/react.json +58 -58
  53. package/lib/gateguard-state.mjs +54 -2
  54. package/lib/goal-drift-gate.mjs +50 -0
  55. package/lib/goal-state.mjs +285 -0
  56. package/lib/plugin-metadata.mjs +134 -15
  57. package/lib/recall-briefing.mjs +57 -0
  58. package/lib/recall-index.mjs +175 -0
  59. package/lib/skill-distill.mjs +222 -0
  60. package/llms.txt +2 -2
  61. package/package.json +12 -7
  62. package/plugins/beginner.json +9 -4
  63. package/plugins/continuous-improvement/.claude-plugin/marketplace.json +2 -2
  64. package/plugins/continuous-improvement/.claude-plugin/plugin.json +2 -2
  65. package/plugins/continuous-improvement/LICENSE +21 -21
  66. package/plugins/continuous-improvement/agents/README.md +3 -3
  67. package/plugins/continuous-improvement/bin/backfill.mjs +19 -19
  68. package/plugins/continuous-improvement/bin/gateguard-clear.mjs +53 -0
  69. package/plugins/continuous-improvement/bin/mcp-server.mjs +216 -3
  70. package/plugins/continuous-improvement/commands/audit.md +34 -0
  71. package/plugins/continuous-improvement/commands/companion-preference.md +58 -0
  72. package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -115
  73. package/plugins/continuous-improvement/commands/dashboard.md +56 -56
  74. package/plugins/continuous-improvement/commands/discipline.md +14 -0
  75. package/plugins/continuous-improvement/commands/distill.md +39 -0
  76. package/plugins/continuous-improvement/commands/goal-check.md +53 -0
  77. package/plugins/continuous-improvement/commands/grill-me.md +40 -0
  78. package/plugins/continuous-improvement/commands/grill-with-docs.md +38 -0
  79. package/plugins/continuous-improvement/commands/handoff.md +42 -0
  80. package/plugins/continuous-improvement/commands/harvest.md +1 -1
  81. package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +20 -0
  82. package/plugins/continuous-improvement/commands/recall.md +49 -0
  83. package/plugins/continuous-improvement/commands/reconcile.md +47 -0
  84. package/plugins/continuous-improvement/commands/seven-laws.md +16 -16
  85. package/plugins/continuous-improvement/commands/superpowers.md +3 -3
  86. package/plugins/continuous-improvement/commands/verify-install.md +55 -0
  87. package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -77
  88. package/plugins/continuous-improvement/hooks/companion-preference.mjs +190 -0
  89. package/plugins/continuous-improvement/hooks/gateguard.mjs +72 -25
  90. package/plugins/continuous-improvement/hooks/goal-drift-stop.mjs +183 -0
  91. package/plugins/continuous-improvement/hooks/hooks.json +23 -2
  92. package/plugins/continuous-improvement/hooks/observe.sh +15 -1
  93. package/plugins/continuous-improvement/hooks/recall-briefing.mjs +167 -0
  94. package/plugins/continuous-improvement/hooks/route-prompt.mjs +180 -0
  95. package/plugins/continuous-improvement/hooks/route-table.json +35 -0
  96. package/plugins/continuous-improvement/hooks/session.sh +106 -106
  97. package/plugins/continuous-improvement/hooks/three-section-close.mjs +134 -132
  98. package/plugins/continuous-improvement/instinct-packs/go.json +58 -58
  99. package/plugins/continuous-improvement/instinct-packs/meta.json +16 -16
  100. package/plugins/continuous-improvement/instinct-packs/python.json +58 -58
  101. package/plugins/continuous-improvement/instinct-packs/react.json +58 -58
  102. package/plugins/continuous-improvement/lib/gateguard-state.mjs +137 -0
  103. package/plugins/continuous-improvement/lib/goal-drift-gate.mjs +50 -0
  104. package/plugins/continuous-improvement/lib/goal-state.mjs +285 -0
  105. package/plugins/continuous-improvement/lib/plugin-metadata.mjs +134 -15
  106. package/plugins/continuous-improvement/lib/recall-briefing.mjs +57 -0
  107. package/plugins/continuous-improvement/lib/recall-index.mjs +175 -0
  108. package/plugins/continuous-improvement/lib/skill-distill.mjs +222 -0
  109. package/plugins/continuous-improvement/skills/README.md +8 -0
  110. package/plugins/continuous-improvement/skills/audit/SKILL.md +73 -0
  111. package/plugins/continuous-improvement/skills/continuous-improvement/SKILL.md +1 -1
  112. package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +13 -17
  113. package/plugins/continuous-improvement/skills/gateguard/SKILL.md +36 -17
  114. package/plugins/continuous-improvement/skills/goal-monitor/SKILL.md +81 -0
  115. package/plugins/continuous-improvement/skills/grill-me/SKILL.md +66 -0
  116. package/plugins/continuous-improvement/skills/grill-with-docs/SKILL.md +252 -0
  117. package/plugins/continuous-improvement/skills/handoff/SKILL.md +59 -0
  118. package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +1 -1
  119. package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +82 -6
  120. package/plugins/continuous-improvement/skills/ralph/SKILL.md +1 -0
  121. package/plugins/continuous-improvement/skills/recall/SKILL.md +50 -0
  122. package/plugins/continuous-improvement/skills/reconcile/SKILL.md +80 -0
  123. package/plugins/continuous-improvement/skills/recovery-classification/SKILL.md +1 -0
  124. package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +1 -0
  125. package/plugins/continuous-improvement/skills/skill-distillation/SKILL.md +57 -0
  126. package/plugins/continuous-improvement/skills/state-reconciliation/SKILL.md +1 -0
  127. package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +1 -0
  128. package/plugins/continuous-improvement/skills/superpowers/SKILL.md +77 -3
  129. package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -411
  130. package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +1 -1
  131. package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +28 -20
  132. package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +1 -0
  133. package/plugins/continuous-improvement/skills/workspace-surface-audit/SKILL.md +1 -1
  134. package/plugins/continuous-improvement/skills/worktree-safety/SKILL.md +3 -2
  135. package/plugins/expert.json +28 -3
  136. package/skills/README.md +3 -0
  137. package/skills/audit.md +73 -0
  138. package/skills/deploy-receipt.md +13 -17
  139. package/skills/gateguard.md +36 -17
  140. package/skills/goal-monitor.md +81 -0
  141. package/skills/grill-me.md +66 -0
  142. package/skills/grill-with-docs.md +252 -0
  143. package/skills/handoff.md +59 -0
  144. package/skills/para-memory-files.md +1 -1
  145. package/skills/proceed-with-the-recommendation.md +82 -6
  146. package/skills/ralph.md +1 -0
  147. package/skills/recall.md +50 -0
  148. package/skills/reconcile.md +80 -0
  149. package/skills/recovery-classification.md +1 -0
  150. package/skills/safety-guard.md +1 -0
  151. package/skills/skill-distillation.md +57 -0
  152. package/skills/state-reconciliation.md +1 -0
  153. package/skills/strategic-compact.md +1 -0
  154. package/skills/superpowers.md +77 -3
  155. package/skills/tdd-workflow.md +411 -411
  156. package/skills/token-budget-advisor.md +1 -1
  157. package/skills/verification-loop.md +28 -20
  158. package/skills/wild-risa-balance.md +1 -0
  159. package/skills/workspace-surface-audit.md +1 -1
  160. package/skills/worktree-safety.md +3 -2
package/bin/analyze.sh CHANGED
@@ -1,161 +1,161 @@
1
- #!/usr/bin/env bash
2
- # analyze.sh — Read observations.jsonl, detect patterns, create instinct YAML files
3
- # Runs via /continuous-improvement command. Uses claude CLI with Haiku for cost-efficient analysis.
4
-
5
- set -euo pipefail
6
-
7
- INSTINCTS_DIR="${HOME}/.claude/instincts"
8
-
9
- # ---------------------------------------------------------------------------
10
- # Detect project
11
- # ---------------------------------------------------------------------------
12
- PROJECT_ROOT=""
13
- if [[ -n "${CLAUDE_PROJECT_DIR:-}" && -d "${CLAUDE_PROJECT_DIR}" ]]; then
14
- PROJECT_ROOT="${CLAUDE_PROJECT_DIR}"
15
- fi
16
- if [[ -z "$PROJECT_ROOT" ]]; then
17
- PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
18
- fi
19
- if [[ -z "$PROJECT_ROOT" ]]; then
20
- PROJECT_ROOT="global"
21
- fi
22
-
23
- # Use shasum on macOS, sha256sum on Linux
24
- if command -v sha256sum &>/dev/null; then
25
- PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | sha256sum | cut -c1-12)"
26
- elif command -v shasum &>/dev/null; then
27
- PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | shasum -a 256 | cut -c1-12)"
28
- else
29
- # Fallback: use project root basename if no hashing available
30
- PROJECT_HASH="$(basename "$PROJECT_ROOT" | tr -cd 'a-zA-Z0-9' | cut -c1-12)"
31
- fi
32
- PROJECT_NAME="$(basename "${PROJECT_ROOT%.git}")"
33
- PROJECT_DIR="${INSTINCTS_DIR}/${PROJECT_HASH}"
34
- OBS_FILE="${PROJECT_DIR}/observations.jsonl"
35
-
36
- # ---------------------------------------------------------------------------
37
- # Check observations exist
38
- # ---------------------------------------------------------------------------
39
- if [[ ! -f "$OBS_FILE" ]] || [[ ! -s "$OBS_FILE" ]]; then
40
- echo "No observations found at ${OBS_FILE}"
41
- echo "Use Claude Code with hooks installed to generate observations."
42
- exit 0
43
- fi
44
-
45
- OBS_COUNT=$(wc -l < "$OBS_FILE")
46
- echo "Found ${OBS_COUNT} observations in ${OBS_FILE}"
47
-
48
- if (( OBS_COUNT < 20 )); then
49
- echo "Need at least 20 observations for meaningful analysis. Keep using Claude Code (${OBS_COUNT}/20)."
50
- exit 0
51
- fi
52
-
53
- # ---------------------------------------------------------------------------
54
- # Read existing instincts to avoid duplicates
55
- # ---------------------------------------------------------------------------
56
- EXISTING_INSTINCTS=""
57
- for f in "${PROJECT_DIR}"/*.yaml "${INSTINCTS_DIR}/global"/*.yaml; do
58
- [[ -f "$f" ]] && EXISTING_INSTINCTS="${EXISTING_INSTINCTS}$(cat "$f")"$'\n'
59
- done
60
-
61
- # ---------------------------------------------------------------------------
62
- # Take last 500 observations
63
- # ---------------------------------------------------------------------------
64
- RECENT_OBS=$(tail -500 "$OBS_FILE")
65
-
66
- # ---------------------------------------------------------------------------
67
- # Build analysis prompt
68
- # ---------------------------------------------------------------------------
69
- ANALYSIS_PROMPT="Analyze these Claude Code session observations and extract behavioral patterns as instinct YAML files.
70
-
71
- OBSERVATIONS (JSONL — each line is a tool call):
72
- ${RECENT_OBS}
73
-
74
- EXISTING INSTINCTS (already learned — do NOT duplicate these):
75
- ${EXISTING_INSTINCTS}
76
-
77
- YOUR TASK:
78
- 1. Look for REPEATED PATTERNS — same tool sequence used 3+ times
79
- 2. Look for ERROR-THEN-FIX sequences — tool fails, next tools fix it
80
- 3. Look for TOOL PREFERENCES — one tool consistently chosen over alternatives
81
- 4. Look for WORKFLOW PATTERNS — consistent ordering of operations
82
- 5. Look for USER CORRECTIONS — user says no/stop/don't after an action
83
-
84
- OUTPUT FORMAT — output ONLY new instincts as YAML blocks, separated by ---:
85
-
86
- id: descriptive-kebab-case-id
87
- trigger: \"when [specific situation]\"
88
- confidence: 0.5
89
- domain: workflow|tooling|testing|patterns
90
- source: observation
91
- scope: project
92
- project_id: ${PROJECT_HASH}
93
- created: \"$(date -u +%Y-%m-%d)\"
94
- last_seen: \"$(date -u +%Y-%m-%d)\"
95
- observation_count: [number of times pattern was seen]
96
- ---
97
- [One sentence describing the specific actionable behavior]
98
-
99
- Rules:
100
- - Only create instincts for patterns seen 3+ times
101
- - Start confidence at 0.5 (suggest level)
102
- - Be specific and actionable (not vague advice)
103
- - Different from existing instincts listed above
104
-
105
- If no new patterns are found, output exactly: NO_NEW_PATTERNS
106
-
107
- Output ONLY the YAML blocks or NO_NEW_PATTERNS. No explanation, no preamble."
108
-
109
- # ---------------------------------------------------------------------------
110
- # Run analysis with Haiku
111
- # ---------------------------------------------------------------------------
112
- echo "Analyzing patterns with Haiku..."
113
- RESULT=$(echo "$ANALYSIS_PROMPT" | claude --model haiku --print -p - 2>/dev/null) || {
114
- echo "Analysis failed — claude CLI error. Try running manually."
115
- exit 1
116
- }
117
-
118
- if [[ "$RESULT" == "NO_NEW_PATTERNS" ]] || [[ -z "$RESULT" ]]; then
119
- echo "No new patterns detected yet. Keep using Claude Code — patterns emerge over time."
120
- exit 0
121
- fi
122
-
123
- # ---------------------------------------------------------------------------
124
- # Write instinct YAML files
125
- # ---------------------------------------------------------------------------
126
- mkdir -p "$PROJECT_DIR"
127
-
128
- NEW_COUNT=0
129
- INSTINCT_ID=""
130
- BLOCK=""
131
-
132
- while IFS= read -r line; do
133
- if [[ "$line" == "---" ]] && [[ -n "$BLOCK" ]]; then
134
- if [[ -n "$INSTINCT_ID" ]]; then
135
- DEST="${PROJECT_DIR}/${INSTINCT_ID}.yaml"
136
- printf '%s\n' "$BLOCK" > "$DEST"
137
- echo " + ${INSTINCT_ID} -> ${DEST}"
138
- NEW_COUNT=$((NEW_COUNT + 1))
139
- fi
140
- INSTINCT_ID=""
141
- BLOCK=""
142
- else
143
- BLOCK="${BLOCK}${line}"$'\n'
144
- if [[ "$line" =~ ^id:\ (.+) ]]; then
145
- INSTINCT_ID="${BASH_REMATCH[1]}"
146
- INSTINCT_ID="${INSTINCT_ID//\"/}"
147
- INSTINCT_ID="${INSTINCT_ID//\'/}"
148
- fi
149
- fi
150
- done <<< "$RESULT"
151
-
152
- # Handle last block
153
- if [[ -n "$INSTINCT_ID" ]] && [[ -n "$BLOCK" ]]; then
154
- DEST="${PROJECT_DIR}/${INSTINCT_ID}.yaml"
155
- printf '%s\n' "$BLOCK" > "$DEST"
156
- echo " + ${INSTINCT_ID} -> ${DEST}"
157
- NEW_COUNT=$((NEW_COUNT + 1))
158
- fi
159
-
160
- echo ""
161
- echo "Created ${NEW_COUNT} new instinct(s) in ${PROJECT_DIR}/"
1
+ #!/usr/bin/env bash
2
+ # analyze.sh — Read observations.jsonl, detect patterns, create instinct YAML files
3
+ # Runs via /continuous-improvement command. Uses claude CLI with Haiku for cost-efficient analysis.
4
+
5
+ set -euo pipefail
6
+
7
+ INSTINCTS_DIR="${HOME}/.claude/instincts"
8
+
9
+ # ---------------------------------------------------------------------------
10
+ # Detect project
11
+ # ---------------------------------------------------------------------------
12
+ PROJECT_ROOT=""
13
+ if [[ -n "${CLAUDE_PROJECT_DIR:-}" && -d "${CLAUDE_PROJECT_DIR}" ]]; then
14
+ PROJECT_ROOT="${CLAUDE_PROJECT_DIR}"
15
+ fi
16
+ if [[ -z "$PROJECT_ROOT" ]]; then
17
+ PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
18
+ fi
19
+ if [[ -z "$PROJECT_ROOT" ]]; then
20
+ PROJECT_ROOT="global"
21
+ fi
22
+
23
+ # Use shasum on macOS, sha256sum on Linux
24
+ if command -v sha256sum &>/dev/null; then
25
+ PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | sha256sum | cut -c1-12)"
26
+ elif command -v shasum &>/dev/null; then
27
+ PROJECT_HASH="$(printf '%s' "$PROJECT_ROOT" | shasum -a 256 | cut -c1-12)"
28
+ else
29
+ # Fallback: use project root basename if no hashing available
30
+ PROJECT_HASH="$(basename "$PROJECT_ROOT" | tr -cd 'a-zA-Z0-9' | cut -c1-12)"
31
+ fi
32
+ PROJECT_NAME="$(basename "${PROJECT_ROOT%.git}")"
33
+ PROJECT_DIR="${INSTINCTS_DIR}/${PROJECT_HASH}"
34
+ OBS_FILE="${PROJECT_DIR}/observations.jsonl"
35
+
36
+ # ---------------------------------------------------------------------------
37
+ # Check observations exist
38
+ # ---------------------------------------------------------------------------
39
+ if [[ ! -f "$OBS_FILE" ]] || [[ ! -s "$OBS_FILE" ]]; then
40
+ echo "No observations found at ${OBS_FILE}"
41
+ echo "Use Claude Code with hooks installed to generate observations."
42
+ exit 0
43
+ fi
44
+
45
+ OBS_COUNT=$(wc -l < "$OBS_FILE")
46
+ echo "Found ${OBS_COUNT} observations in ${OBS_FILE}"
47
+
48
+ if (( OBS_COUNT < 20 )); then
49
+ echo "Need at least 20 observations for meaningful analysis. Keep using Claude Code (${OBS_COUNT}/20)."
50
+ exit 0
51
+ fi
52
+
53
+ # ---------------------------------------------------------------------------
54
+ # Read existing instincts to avoid duplicates
55
+ # ---------------------------------------------------------------------------
56
+ EXISTING_INSTINCTS=""
57
+ for f in "${PROJECT_DIR}"/*.yaml "${INSTINCTS_DIR}/global"/*.yaml; do
58
+ [[ -f "$f" ]] && EXISTING_INSTINCTS="${EXISTING_INSTINCTS}$(cat "$f")"$'\n'
59
+ done
60
+
61
+ # ---------------------------------------------------------------------------
62
+ # Take last 500 observations
63
+ # ---------------------------------------------------------------------------
64
+ RECENT_OBS=$(tail -500 "$OBS_FILE")
65
+
66
+ # ---------------------------------------------------------------------------
67
+ # Build analysis prompt
68
+ # ---------------------------------------------------------------------------
69
+ ANALYSIS_PROMPT="Analyze these Claude Code session observations and extract behavioral patterns as instinct YAML files.
70
+
71
+ OBSERVATIONS (JSONL — each line is a tool call):
72
+ ${RECENT_OBS}
73
+
74
+ EXISTING INSTINCTS (already learned — do NOT duplicate these):
75
+ ${EXISTING_INSTINCTS}
76
+
77
+ YOUR TASK:
78
+ 1. Look for REPEATED PATTERNS — same tool sequence used 3+ times
79
+ 2. Look for ERROR-THEN-FIX sequences — tool fails, next tools fix it
80
+ 3. Look for TOOL PREFERENCES — one tool consistently chosen over alternatives
81
+ 4. Look for WORKFLOW PATTERNS — consistent ordering of operations
82
+ 5. Look for USER CORRECTIONS — user says no/stop/don't after an action
83
+
84
+ OUTPUT FORMAT — output ONLY new instincts as YAML blocks, separated by ---:
85
+
86
+ id: descriptive-kebab-case-id
87
+ trigger: \"when [specific situation]\"
88
+ confidence: 0.5
89
+ domain: workflow|tooling|testing|patterns
90
+ source: observation
91
+ scope: project
92
+ project_id: ${PROJECT_HASH}
93
+ created: \"$(date -u +%Y-%m-%d)\"
94
+ last_seen: \"$(date -u +%Y-%m-%d)\"
95
+ observation_count: [number of times pattern was seen]
96
+ ---
97
+ [One sentence describing the specific actionable behavior]
98
+
99
+ Rules:
100
+ - Only create instincts for patterns seen 3+ times
101
+ - Start confidence at 0.5 (suggest level)
102
+ - Be specific and actionable (not vague advice)
103
+ - Different from existing instincts listed above
104
+
105
+ If no new patterns are found, output exactly: NO_NEW_PATTERNS
106
+
107
+ Output ONLY the YAML blocks or NO_NEW_PATTERNS. No explanation, no preamble."
108
+
109
+ # ---------------------------------------------------------------------------
110
+ # Run analysis with Haiku
111
+ # ---------------------------------------------------------------------------
112
+ echo "Analyzing patterns with Haiku..."
113
+ RESULT=$(echo "$ANALYSIS_PROMPT" | claude --model haiku --print -p - 2>/dev/null) || {
114
+ echo "Analysis failed — claude CLI error. Try running manually."
115
+ exit 1
116
+ }
117
+
118
+ if [[ "$RESULT" == "NO_NEW_PATTERNS" ]] || [[ -z "$RESULT" ]]; then
119
+ echo "No new patterns detected yet. Keep using Claude Code — patterns emerge over time."
120
+ exit 0
121
+ fi
122
+
123
+ # ---------------------------------------------------------------------------
124
+ # Write instinct YAML files
125
+ # ---------------------------------------------------------------------------
126
+ mkdir -p "$PROJECT_DIR"
127
+
128
+ NEW_COUNT=0
129
+ INSTINCT_ID=""
130
+ BLOCK=""
131
+
132
+ while IFS= read -r line; do
133
+ if [[ "$line" == "---" ]] && [[ -n "$BLOCK" ]]; then
134
+ if [[ -n "$INSTINCT_ID" ]]; then
135
+ DEST="${PROJECT_DIR}/${INSTINCT_ID}.yaml"
136
+ printf '%s\n' "$BLOCK" > "$DEST"
137
+ echo " + ${INSTINCT_ID} -> ${DEST}"
138
+ NEW_COUNT=$((NEW_COUNT + 1))
139
+ fi
140
+ INSTINCT_ID=""
141
+ BLOCK=""
142
+ else
143
+ BLOCK="${BLOCK}${line}"$'\n'
144
+ if [[ "$line" =~ ^id:\ (.+) ]]; then
145
+ INSTINCT_ID="${BASH_REMATCH[1]}"
146
+ INSTINCT_ID="${INSTINCT_ID//\"/}"
147
+ INSTINCT_ID="${INSTINCT_ID//\'/}"
148
+ fi
149
+ fi
150
+ done <<< "$RESULT"
151
+
152
+ # Handle last block
153
+ if [[ -n "$INSTINCT_ID" ]] && [[ -n "$BLOCK" ]]; then
154
+ DEST="${PROJECT_DIR}/${INSTINCT_ID}.yaml"
155
+ printf '%s\n' "$BLOCK" > "$DEST"
156
+ echo " + ${INSTINCT_ID} -> ${DEST}"
157
+ NEW_COUNT=$((NEW_COUNT + 1))
158
+ fi
159
+
160
+ echo ""
161
+ echo "Created ${NEW_COUNT} new instinct(s) in ${PROJECT_DIR}/"
package/bin/backfill.mjs CHANGED
@@ -27,25 +27,25 @@ const args = process.argv.slice(2);
27
27
  const DRY_RUN = args.includes("--dry-run");
28
28
  const HELP = args.includes("--help") || args.includes("-h");
29
29
  if (HELP) {
30
- console.log(`
31
- backfill — Tag legacy thin-schema observation rows.
32
-
33
- Usage:
34
- npx continuous-improvement backfill Tag rows in place
35
- npx continuous-improvement backfill --dry-run Report counts, write nothing
36
-
37
- What it does:
38
- Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
39
- schema field ("thin" or "rich") to every row that lacks one. Thin rows
40
- came from the legacy bash fallback (jq missing) and have no input_summary;
41
- rich rows came from the Node observer and have full tool_input.command /
42
- Edit.file_path / etc.
43
-
44
- Output:
45
- - observations.jsonl rewritten in place (original kept as .bak)
46
- - backfill-summary.json with per-project counts
47
-
48
- Idempotent. Always exits 0 — failures go to stderr only.
30
+ console.log(`
31
+ backfill — Tag legacy thin-schema observation rows.
32
+
33
+ Usage:
34
+ npx continuous-improvement backfill Tag rows in place
35
+ npx continuous-improvement backfill --dry-run Report counts, write nothing
36
+
37
+ What it does:
38
+ Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
39
+ schema field ("thin" or "rich") to every row that lacks one. Thin rows
40
+ came from the legacy bash fallback (jq missing) and have no input_summary;
41
+ rich rows came from the Node observer and have full tool_input.command /
42
+ Edit.file_path / etc.
43
+
44
+ Output:
45
+ - observations.jsonl rewritten in place (original kept as .bak)
46
+ - backfill-summary.json with per-project counts
47
+
48
+ Idempotent. Always exits 0 — failures go to stderr only.
49
49
  `);
50
50
  process.exit(0);
51
51
  }
@@ -177,6 +177,48 @@ export const DOCS_ASSERTIONS = [
177
177
  { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "## Stacked-PR Plan Precondition (≥3 files)", source: "docs-substrings-manifest:superpowers-stacked-pr-precondition" },
178
178
  { file: "skills/superpowers.md", pattern: "Per-PR table", source: "docs-substrings-manifest:superpowers-stacked-pr-precondition" },
179
179
  { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "Per-PR table", source: "docs-substrings-manifest:superpowers-stacked-pr-precondition" },
180
+ // superpowers Companion-Preference Override — locked 2026-05-13 (PR 1 of dispatcher-bias train).
181
+ // The dispatcher gained an opt-in settings key (~/.claude/settings.json →
182
+ // continuous_improvement.companion_preference: "ci-first" | "companions-first" | "strict-companions")
183
+ // that lets an operator who installed a companion plugin promote it over the CI-bundled default.
184
+ // Each assertion below catches a specific class of regression:
185
+ // - "## Companion-Preference Override" → removing the whole override section
186
+ // - "companion_preference" → renaming or moving the settings key
187
+ // - "strict-companions" → losing the hard-halt variant
188
+ { file: "skills/superpowers.md", pattern: "## Companion-Preference Override", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
189
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "## Companion-Preference Override", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
190
+ { file: "skills/superpowers.md", pattern: "companion_preference", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
191
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "companion_preference", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
192
+ { file: "skills/superpowers.md", pattern: "strict-companions", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
193
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "strict-companions", source: "docs-substrings-manifest:superpowers-companion-preference-override" },
194
+ // superpowers Runtime Enforcement subsection — locked 2026-05-13 (PR 3 of dispatcher-bias train).
195
+ // The Companion-Preference Override moved from documented-only to runtime-enforced via
196
+ // hooks/companion-preference.mjs (PreToolUse). The "### Runtime enforcement" subsection
197
+ // names the hook file as the verify:doc-runtime-claims anchor and describes the per-mode
198
+ // decision contract. Each assertion catches a specific class of regression:
199
+ // - "### Runtime enforcement" → removing the whole subsection
200
+ // - "hooks/companion-preference.mjs" → losing the hook anchor (also satisfies doc-runtime-claims)
201
+ // - "fails open" → losing the no-block-on-bug invariant
202
+ { file: "skills/superpowers.md", pattern: "### Runtime enforcement", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
203
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "### Runtime enforcement", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
204
+ { file: "skills/superpowers.md", pattern: "hooks/companion-preference.mjs", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
205
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "hooks/companion-preference.mjs", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
206
+ { file: "skills/superpowers.md", pattern: "fails open", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
207
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "fails open", source: "docs-substrings-manifest:superpowers-runtime-enforcement" },
208
+ // superpowers Telemetry subsection — locked 2026-05-14 (PR 4 of dispatcher-bias train).
209
+ // The hook gained a JSONL telemetry writer at ~/.claude/instincts/<hash>/companion-preference.jsonl
210
+ // that fires under every mode including ci-first (which writes `observation` shadow rows). The
211
+ // "### Telemetry" subsection documents the JSONL path and the four-value action enum. Each
212
+ // assertion catches a specific class of regression:
213
+ // - "### Telemetry" → removing the whole subsection
214
+ // - "companion-preference.jsonl" → renaming the JSONL file
215
+ // - "observation" → losing the ci-first shadow row that makes default-flip decisions evidence-driven
216
+ { file: "skills/superpowers.md", pattern: "### Telemetry", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
217
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "### Telemetry", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
218
+ { file: "skills/superpowers.md", pattern: "companion-preference.jsonl", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
219
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "companion-preference.jsonl", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
220
+ { file: "skills/superpowers.md", pattern: "`observation`", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
221
+ { file: "plugins/continuous-improvement/skills/superpowers/SKILL.md", pattern: "`observation`", source: "docs-substrings-manifest:superpowers-telemetry-jsonl" },
180
222
  // verification-loop per-project ladder — locked 2026-05-07 (PR C of second-release train).
181
223
  // Phase 0 (Ladder Resolution) was added so Phases 1–6 read the project's actual build/typecheck/
182
224
  // lint/test/security/deploy_receipt invocations from .claude/verify-ladder.json (or sniff /
@@ -253,6 +295,37 @@ export const DOCS_ASSERTIONS = [
253
295
  { file: "plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md", pattern: `The "no" escape valve (both tiers)`, source: "wild-risa-tiers.test.mts" },
254
296
  { file: "skills/proceed-with-the-recommendation.md", pattern: "explicit handoff signal", source: "wild-risa-tiers.test.mts" },
255
297
  { file: "plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md", pattern: "explicit handoff signal", source: "wild-risa-tiers.test.mts" },
298
+ // proceed-with-the-recommendation --once fast-path mode — locked 2026-05-13 (PR 2 of dispatcher-bias train).
299
+ // The orchestrator gained an opt-in mode that runs Phase 1 + Phase 3 + Phase 4 only on single-item
300
+ // safe-tagged confirmations, skipping P-MAG, Plan, Reflect, and the three-section close. Hard
301
+ // preconditions refuse --once and fall back to the full flow if list size != 1, item is not safe,
302
+ // it touches > 3 files / > 150 LOC, hits restricted dirs, or is destructive. Each assertion below
303
+ // catches a specific class of regression:
304
+ // - "## Fast-Path: `--once` Mode" → removing the whole section
305
+ // - "Refuse --once if any fail"-shaped → losing the precondition gate (matched via "--once refused:")
306
+ // - "Phase 0 — P-MAG" + "**Skipped.**" → losing the explicit phase-status table (matched via "Skipped.** Reason: single-item")
307
+ { file: "skills/proceed-with-the-recommendation.md", pattern: "## Fast-Path: `--once` Mode", source: "docs-substrings-manifest:proceed-once-mode" },
308
+ { file: "plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md", pattern: "## Fast-Path: `--once` Mode", source: "docs-substrings-manifest:proceed-once-mode" },
309
+ { file: "skills/proceed-with-the-recommendation.md", pattern: "--once refused:", source: "docs-substrings-manifest:proceed-once-mode" },
310
+ { file: "plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md", pattern: "--once refused:", source: "docs-substrings-manifest:proceed-once-mode" },
311
+ { file: "skills/proceed-with-the-recommendation.md", pattern: "Skipped.** Reason: single-item", source: "docs-substrings-manifest:proceed-once-mode" },
312
+ { file: "plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md", pattern: "Skipped.** Reason: single-item", source: "docs-substrings-manifest:proceed-once-mode" },
313
+ { file: "commands/proceed-with-the-recommendation.md", pattern: "Fast-path: `--once` mode", source: "docs-substrings-manifest:proceed-once-mode" },
314
+ { file: "plugins/continuous-improvement/commands/proceed-with-the-recommendation.md", pattern: "Fast-path: `--once` mode", source: "docs-substrings-manifest:proceed-once-mode" },
315
+ // /companion-preference status reader — locked 2026-05-14 (PR 5 of dispatcher-bias train).
316
+ // The reader CLI (bin/companion-preference-status.mjs) and slash command (commands/companion-preference.md)
317
+ // turn the JSONL telemetry from PR #138 into a per-skill aggregation report. The slash command must
318
+ // expose the frontmatter name, the canonical CLI invocation, and the documented --json subcommand.
319
+ // Each assertion catches a specific class of regression:
320
+ // - "name: companion-preference" → renaming the slash command
321
+ // - "companion-preference-status.mjs" → renaming the CLI entry point
322
+ // - "## Subcommands" → losing the documented surface (--json, --days, --all)
323
+ { file: "commands/companion-preference.md", pattern: "name: companion-preference", source: "docs-substrings-manifest:companion-preference-status-reader" },
324
+ { file: "plugins/continuous-improvement/commands/companion-preference.md", pattern: "name: companion-preference", source: "docs-substrings-manifest:companion-preference-status-reader" },
325
+ { file: "commands/companion-preference.md", pattern: "companion-preference-status.mjs", source: "docs-substrings-manifest:companion-preference-status-reader" },
326
+ { file: "plugins/continuous-improvement/commands/companion-preference.md", pattern: "companion-preference-status.mjs", source: "docs-substrings-manifest:companion-preference-status-reader" },
327
+ { file: "commands/companion-preference.md", pattern: "## Subcommands", source: "docs-substrings-manifest:companion-preference-status-reader" },
328
+ { file: "plugins/continuous-improvement/commands/companion-preference.md", pattern: "## Subcommands", source: "docs-substrings-manifest:companion-preference-status-reader" },
256
329
  ];
257
330
  export function checkAssertions(repoRoot, assertions = DOCS_ASSERTIONS) {
258
331
  const fileCache = new Map();