create-merlin-brain 3.17.0 → 3.18.2

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.
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Challenge Tracking Tools
3
+ * MCP tools for recording and analyzing dialectic challenge outcomes
4
+ * (Insider vs Academic vs Synthesis approach comparisons)
5
+ */
6
+ import { z } from 'zod';
7
+ // ── In-memory store + file persistence ──────────────────────────────
8
+ // Challenges are stored locally in ~/.claude/merlin/challenges.jsonl
9
+ // and optionally synced to cloud via agent state API
10
+ import { existsSync, mkdirSync, appendFileSync, readFileSync, writeFileSync } from 'fs';
11
+ import { join } from 'path';
12
+ import { homedir } from 'os';
13
+ function getChallengesPath() {
14
+ const dir = join(homedir(), '.claude', 'merlin');
15
+ if (!existsSync(dir)) {
16
+ mkdirSync(dir, { recursive: true });
17
+ }
18
+ return join(dir, 'challenges.jsonl');
19
+ }
20
+ function loadChallenges() {
21
+ const path = getChallengesPath();
22
+ if (!existsSync(path))
23
+ return [];
24
+ try {
25
+ const lines = readFileSync(path, 'utf-8').split('\n').filter(Boolean);
26
+ return lines.map(line => JSON.parse(line));
27
+ }
28
+ catch {
29
+ return [];
30
+ }
31
+ }
32
+ function appendChallenge(record) {
33
+ const path = getChallengesPath();
34
+ appendFileSync(path, JSON.stringify(record) + '\n');
35
+ }
36
+ function updateChallenge(id, updates) {
37
+ const path = getChallengesPath();
38
+ const challenges = loadChallenges();
39
+ const idx = challenges.findIndex(c => c.id === id);
40
+ if (idx === -1)
41
+ return false;
42
+ challenges[idx] = { ...challenges[idx], ...updates };
43
+ // Rewrite file
44
+ const content = challenges.map(c => JSON.stringify(c)).join('\n') + '\n';
45
+ writeFileSync(path, content);
46
+ return true;
47
+ }
48
+ export function registerChallengeTools(ctx) {
49
+ const { server } = ctx;
50
+ // ── DEFERRED tool: Record a challenge outcome ─────────────────────
51
+ server.tool('merlin_record_challenge', 'Record the outcome of a dialectic challenge (Insider vs Academic approach comparison). Called automatically by /merlin:challenge after the Arbiter produces a verdict. Stores results locally for long-term trend analysis.', {
52
+ task: z.string().describe('Task that was challenged'),
53
+ insiderScore: z.number().describe('Insider weighted score (0-110)'),
54
+ academicScore: z.number().describe('Academic weighted score (0-110)'),
55
+ verdict: z.enum(['insider', 'academic', 'synthesis']).describe('Arbiter recommendation'),
56
+ synthesisRatio: z.number().describe('How much came from Academic (0=all insider, 1=all academic, 0.5=equal)'),
57
+ confidence: z.enum(['high', 'medium', 'low']).describe('Arbiter confidence level'),
58
+ keyInsight: z.string().describe('One-sentence insight from the challenge'),
59
+ phase: z.string().optional().describe('Phase number if part of planning pipeline'),
60
+ repoUrl: z.string().optional().describe('GitHub URL of the repository'),
61
+ }, async ({ task, insiderScore, academicScore, verdict, synthesisRatio, confidence, keyInsight, phase, repoUrl }) => {
62
+ try {
63
+ const record = {
64
+ id: `ch_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
65
+ timestamp: new Date().toISOString(),
66
+ repoUrl: repoUrl || undefined,
67
+ task,
68
+ phase: phase || undefined,
69
+ insiderScore,
70
+ academicScore,
71
+ verdict,
72
+ synthesisRatio,
73
+ confidence,
74
+ keyInsight,
75
+ };
76
+ appendChallenge(record);
77
+ const delta = insiderScore - academicScore;
78
+ const winner = delta > 0 ? 'Insider' : delta < 0 ? 'Academic' : 'Tie';
79
+ let response = `# Challenge Recorded\n\n`;
80
+ response += `**ID:** ${record.id}\n`;
81
+ response += `**Task:** ${task}\n`;
82
+ if (phase)
83
+ response += `**Phase:** ${phase}\n`;
84
+ response += `**Scores:** Insider ${insiderScore} vs Academic ${academicScore} (${winner} by ${Math.abs(delta)})\n`;
85
+ response += `**Verdict:** ${verdict}${verdict === 'synthesis' ? ` (ratio: ${synthesisRatio})` : ''}\n`;
86
+ response += `**Confidence:** ${confidence}\n`;
87
+ response += `**Insight:** ${keyInsight}\n\n`;
88
+ response += `_Use \`merlin_rate_challenge("${record.id}", rating, notes)\` after implementation to track outcome quality._`;
89
+ return { content: [{ type: 'text', text: response }] };
90
+ }
91
+ catch (error) {
92
+ return {
93
+ content: [{ type: 'text', text: `Error recording challenge: ${error instanceof Error ? error.message : 'Unknown'}` }],
94
+ isError: true,
95
+ };
96
+ }
97
+ });
98
+ // ── DEFERRED tool: Rate a past challenge outcome ──────────────────
99
+ server.tool('merlin_rate_challenge', 'Rate the outcome of a previously recorded challenge after implementation is complete. This closes the feedback loop — did the chosen approach actually work well? Enables long-term performance tracking of the challenge system itself.', {
100
+ challengeId: z.string().describe('Challenge ID (ch_...) to rate'),
101
+ rating: z.number().min(1).max(10).describe('How well did the chosen approach work? (1=terrible, 10=perfect)'),
102
+ notes: z.string().optional().describe('What went well or poorly with the chosen approach'),
103
+ implementedApproach: z.enum(['insider', 'academic', 'synthesis']).optional().describe('Which approach was actually implemented (may differ from verdict)'),
104
+ }, async ({ challengeId, rating, notes, implementedApproach }) => {
105
+ try {
106
+ const updated = updateChallenge(challengeId, {
107
+ outcomeRating: rating,
108
+ outcomeNotes: notes,
109
+ implementedApproach,
110
+ });
111
+ if (!updated) {
112
+ return {
113
+ content: [{ type: 'text', text: `Challenge ${challengeId} not found.` }],
114
+ isError: true,
115
+ };
116
+ }
117
+ let response = `# Challenge Rated\n\n`;
118
+ response += `**ID:** ${challengeId}\n`;
119
+ response += `**Rating:** ${rating}/10\n`;
120
+ if (implementedApproach)
121
+ response += `**Implemented:** ${implementedApproach}\n`;
122
+ if (notes)
123
+ response += `**Notes:** ${notes}\n`;
124
+ response += `\n_This data improves challenge accuracy over time._`;
125
+ return { content: [{ type: 'text', text: response }] };
126
+ }
127
+ catch (error) {
128
+ return {
129
+ content: [{ type: 'text', text: `Error rating challenge: ${error instanceof Error ? error.message : 'Unknown'}` }],
130
+ isError: true,
131
+ };
132
+ }
133
+ });
134
+ // ── DEFERRED tool: Get challenge statistics ───────────────────────
135
+ server.tool('merlin_get_challenge_stats', 'Analyze challenge history to measure the impact of the dialectic challenge system. Shows: win rates (insider vs academic vs synthesis), average scores, confidence calibration, outcome ratings, trend analysis, and insights surfaced. Use to evaluate whether challenges are improving decisions.', {
136
+ window: z.enum(['7d', '30d', '90d', 'all']).optional().describe('Time window for analysis (default: all)'),
137
+ repoUrl: z.string().optional().describe('Filter by repository'),
138
+ }, async ({ window, repoUrl }) => {
139
+ try {
140
+ let challenges = loadChallenges();
141
+ // Filter by repo if specified
142
+ if (repoUrl) {
143
+ challenges = challenges.filter(c => c.repoUrl === repoUrl);
144
+ }
145
+ // Filter by time window
146
+ if (window && window !== 'all') {
147
+ const days = window === '7d' ? 7 : window === '30d' ? 30 : 90;
148
+ const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
149
+ challenges = challenges.filter(c => c.timestamp >= cutoff);
150
+ }
151
+ if (challenges.length === 0) {
152
+ return {
153
+ content: [{ type: 'text', text: `No challenges recorded${window ? ` in the last ${window}` : ''}.` }],
154
+ };
155
+ }
156
+ // ── Compute statistics ──────────────────────────────────────
157
+ const total = challenges.length;
158
+ const verdicts = { insider: 0, academic: 0, synthesis: 0 };
159
+ const confidences = { high: 0, medium: 0, low: 0 };
160
+ let totalInsiderScore = 0;
161
+ let totalAcademicScore = 0;
162
+ let totalSynthesisRatio = 0;
163
+ let ratedChallenges = 0;
164
+ let totalRating = 0;
165
+ const insights = [];
166
+ for (const c of challenges) {
167
+ verdicts[c.verdict]++;
168
+ confidences[c.confidence]++;
169
+ totalInsiderScore += c.insiderScore;
170
+ totalAcademicScore += c.academicScore;
171
+ totalSynthesisRatio += c.synthesisRatio;
172
+ if (c.keyInsight)
173
+ insights.push(c.keyInsight);
174
+ if (c.outcomeRating !== undefined) {
175
+ ratedChallenges++;
176
+ totalRating += c.outcomeRating;
177
+ }
178
+ }
179
+ const avgInsider = (totalInsiderScore / total).toFixed(1);
180
+ const avgAcademic = (totalAcademicScore / total).toFixed(1);
181
+ const avgSynthesisRatio = (totalSynthesisRatio / total).toFixed(2);
182
+ const avgRating = ratedChallenges > 0 ? (totalRating / ratedChallenges).toFixed(1) : 'N/A';
183
+ // ── Compute value metrics ──────────────────────────────────
184
+ // How often did the challenge change the approach?
185
+ const academicWins = verdicts.academic;
186
+ const synthesisWithAcademic = challenges.filter(c => c.verdict === 'synthesis' && c.synthesisRatio > 0.3).length;
187
+ const approachChanged = academicWins + synthesisWithAcademic;
188
+ const changeRate = ((approachChanged / total) * 100).toFixed(0);
189
+ // Confidence calibration: do high-confidence verdicts get better ratings?
190
+ const highConfRated = challenges.filter(c => c.confidence === 'high' && c.outcomeRating !== undefined);
191
+ const lowConfRated = challenges.filter(c => c.confidence === 'low' && c.outcomeRating !== undefined);
192
+ const avgHighConfRating = highConfRated.length > 0
193
+ ? (highConfRated.reduce((s, c) => s + c.outcomeRating, 0) / highConfRated.length).toFixed(1)
194
+ : 'N/A';
195
+ const avgLowConfRating = lowConfRated.length > 0
196
+ ? (lowConfRated.reduce((s, c) => s + c.outcomeRating, 0) / lowConfRated.length).toFixed(1)
197
+ : 'N/A';
198
+ // ── Build report ────────────────────────────────────────────
199
+ let report = `# Challenge System Analytics\n\n`;
200
+ report += `**Period:** ${window || 'all time'} · **Challenges:** ${total}\n\n`;
201
+ report += `## Verdict Distribution\n`;
202
+ report += `| Verdict | Count | Rate |\n|---------|-------|------|\n`;
203
+ report += `| Insider wins | ${verdicts.insider} | ${((verdicts.insider / total) * 100).toFixed(0)}% |\n`;
204
+ report += `| Academic wins | ${verdicts.academic} | ${((verdicts.academic / total) * 100).toFixed(0)}% |\n`;
205
+ report += `| Synthesis | ${verdicts.synthesis} | ${((verdicts.synthesis / total) * 100).toFixed(0)}% |\n\n`;
206
+ report += `## Scores\n`;
207
+ report += `- Avg Insider score: **${avgInsider}**/110\n`;
208
+ report += `- Avg Academic score: **${avgAcademic}**/110\n`;
209
+ report += `- Avg synthesis ratio: **${avgSynthesisRatio}** (0=all insider, 1=all academic)\n\n`;
210
+ report += `## Impact\n`;
211
+ report += `- **${changeRate}%** of challenges changed the approach (academic win or significant synthesis)\n`;
212
+ report += `- This means ${changeRate}% of the time, the system caught a better path that single-track planning would have missed.\n\n`;
213
+ report += `## Confidence Distribution\n`;
214
+ report += `- High: ${confidences.high} · Medium: ${confidences.medium} · Low: ${confidences.low}\n\n`;
215
+ if (ratedChallenges > 0) {
216
+ report += `## Outcome Quality (${ratedChallenges} rated)\n`;
217
+ report += `- Average outcome rating: **${avgRating}**/10\n`;
218
+ report += `- High-confidence outcomes: **${avgHighConfRating}**/10\n`;
219
+ report += `- Low-confidence outcomes: **${avgLowConfRating}**/10\n`;
220
+ if (avgHighConfRating !== 'N/A' && avgLowConfRating !== 'N/A') {
221
+ const calibrated = parseFloat(avgHighConfRating) > parseFloat(avgLowConfRating);
222
+ report += `- Confidence calibration: ${calibrated ? '✅ Well-calibrated (high confidence → better outcomes)' : '⚠️ Miscalibrated (low confidence outcomes not worse — arbiter may be too cautious)'}\n`;
223
+ }
224
+ report += `\n`;
225
+ }
226
+ // Recent insights (last 5)
227
+ const recentInsights = insights.slice(-5);
228
+ if (recentInsights.length > 0) {
229
+ report += `## Recent Insights\n`;
230
+ for (const insight of recentInsights) {
231
+ report += `- ${insight}\n`;
232
+ }
233
+ report += `\n`;
234
+ }
235
+ // Unrated challenges reminder
236
+ const unrated = challenges.filter(c => c.outcomeRating === undefined);
237
+ if (unrated.length > 0) {
238
+ report += `---\n_${unrated.length} challenges awaiting outcome rating. Rate them with \`merlin_rate_challenge\` after implementation._\n`;
239
+ }
240
+ return { content: [{ type: 'text', text: report }] };
241
+ }
242
+ catch (error) {
243
+ return {
244
+ content: [{ type: 'text', text: `Error computing stats: ${error instanceof Error ? error.message : 'Unknown'}` }],
245
+ isError: true,
246
+ };
247
+ }
248
+ });
249
+ }
250
+ //# sourceMappingURL=challenge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"challenge.js","sourceRoot":"","sources":["../../../src/server/tools/challenge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KA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,MAAM,IAAI,sBAAsB,CAAC;gBACjC,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;oBACrC,MAAM,IAAI,KAAK,OAAO,IAAI,CAAC;gBAC7B,CAAC;gBACD,MAAM,IAAI,IAAI,CAAC;YACjB,CAAC;YAED,8BAA8B;YAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;YACtE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,SAAS,OAAO,CAAC,MAAM,wGAAwG,CAAC;YAC5I,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAChE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC1H,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -18,4 +18,5 @@ export { registerSessionRestoreTools } from './session-restore.js';
18
18
  export { registerSessionSearchTools } from './session-search.js';
19
19
  export { registerPromoteTools } from './promote.js';
20
20
  export { registerLearningTools } from './learning.js';
21
+ export { registerChallengeTools } from './challenge.js';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,oBAAoB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EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -17,4 +17,5 @@ export { registerSessionRestoreTools } from './session-restore.js';
17
17
  export { registerSessionSearchTools } from './session-search.js';
18
18
  export { registerPromoteTools } from './promote.js';
19
19
  export { registerLearningTools } from './learning.js';
20
+ export { registerChallengeTools } from './challenge.js';
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
package/files/CLAUDE.md CHANGED
@@ -1,79 +1,48 @@
1
1
  <!-- ⟡🔮 MERLIN BRAIN — MANDATORY PROTOCOL -->
2
2
 
3
- # ⟡🔮 MERLIN STOPBoot Sequence BEFORE Every Response
3
+ # ⟡🔮 YOU ARE MERLINAN ORCHESTRATOR, NOT A CODER
4
4
 
5
- **Step 1**Call `merlin_get_selected_repo` to connect Merlin Sights.
6
- **Step 2** — Call `merlin_get_project_status` to load project state.
7
- **Step 3** — Call `merlin_get_rules` and `merlin_get_brief` in parallel to load rules and project context.
8
- **Step 4** — Auto-detect intent from the user's message. Apply the current operating mode (see below). Take action.
5
+ **You do NOT write code yourself.** You detect what needs to happen, then delegate to specialist agents who do the actual work. You are the brain that routes, coordinates, and quality-checks. When you catch yourself about to Read a source file, write code, or grep through a codebase STOP. That is a specialist's job. Your job is to figure out WHICH specialist and give them the right context.
9
6
 
10
- Do NOT skip these steps. Do NOT start working without Merlin context.
11
-
12
- ---
13
-
14
- ## ⟡🔮 Operating Modes Two Ways to Work
15
-
16
- Merlin has two operating modes. **AI Automation is the default.** The user can switch at any time.
17
-
18
- ### 🤖 AI Automation (default)
7
+ The only exceptions where you work directly:
8
+ - Answering questions about the project (use Sights, not raw file reads)
9
+ - Editing planning files (.planning/, ROADMAP.md, STATE.md)
10
+ - Running Merlin MCP tools
11
+ - Small config changes the user explicitly asks YOU to make
19
12
 
20
- Merlin detects intent, picks the best execution path, and runs the full pipeline autonomously. The user sees results, not menus.
13
+ **For everything else: ROUTE TO A SPECIALIST AGENT.**
21
14
 
22
- - Auto-invoke workflows, agents, and commands based on intent
23
- - Run multi-step pipelines without pausing for permission
24
- - Pause only at genuine decision points (architecture choices, scope ambiguity, irreversible actions)
25
- - Show what is happening, not what could happen
26
-
27
- **Activate:** Default. Also: "autopilot", "auto mode", "AI mode", "Merlin mode", "just do it", "go"
28
-
29
- ### 🎮 In Control
30
-
31
- Merlin detects intent identically, but presents options before executing. The user picks.
15
+ ---
32
16
 
33
- - Same smart detection — Merlin still identifies the best workflow/agent/command
34
- - Present 3-5 numbered options with the recommended path marked as [1]
35
- - Wait for user selection before executing
36
- - Still auto-run Sights checks, verification, and learning (these never need permission)
17
+ # ⟡🔮 THREE NON-NEGOTIABLE RULES
37
18
 
38
- **Activate:** "in control", "manual mode", "let me decide", "show me options", "I want to pick"
19
+ **RULE 1: ALWAYS route implementation work to specialist agents.**
20
+ Never write, edit, or debug application code yourself. Use `Skill("merlin:workflow")`, `Skill("merlin:debug")`, `Skill("merlin:route")`, or the intent table below. If no workflow fits, call `merlin_smart_route(task="...")` then `merlin_route()`.
39
21
 
40
- ### Showing the Mode
22
+ **RULE 2: ALWAYS call `merlin_get_context()` before ANY code-related action.**
23
+ Before routing an agent, before reading source files, before answering questions about code — check Sights first. It knows where things are. Don't `find` or `grep` blindly.
41
24
 
42
- At session start, after boot, show the active mode:
43
- ```
44
- ⟡🔮 MERLIN · connected · [project name]
45
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
46
- 📊 Status: [phase/milestone info]
47
- 🎯 Mode: 🤖 AI Automation (say "in control" to switch)
48
- ```
25
+ **RULE 3: ALWAYS verify after implementation.**
26
+ After any agent completes work, run `merlin_run_verification()`. After code changes, actually build/compile/test. Never claim "done" without proof.
49
27
 
50
- When user switches modes:
51
- ```
52
- ⟡🔮 MERLIN › Mode: 🎮 In Control — I'll show you options before executing.
53
- ```
54
- ```
55
- ⟡🔮 MERLIN › Mode: 🤖 AI Automation — I'll detect, decide, and execute.
56
- ```
28
+ **Violating these rules wastes the user's money and time. The user has explicitly demanded these rules be followed.**
57
29
 
58
30
  ---
59
31
 
60
- ## ⟡🔮 Visual IdentityTHE MERLIN BADGE
32
+ # ⟡🔮 Boot SequenceBEFORE Every Response
61
33
 
62
- **Every Merlin action MUST be prefixed with `⟡🔮 MERLIN ›`** routing, sights calls, saves, decisions, warnings, completions. No exceptions.
34
+ **Step 1**Call `merlin_get_selected_repo` to connect Merlin Sights.
35
+ **Step 2** — Call `merlin_get_project_status` to load project state.
36
+ **Step 3** — Call `merlin_get_rules` and `merlin_get_brief` in parallel to load rules and project context.
37
+ **Step 4** — Detect intent → Route to action (see intent table below). Do NOT start working yourself.
63
38
 
64
- ```
65
- ⟡🔮 MERLIN › Routing → implementation-dev
66
- ⟡🔮 MERLIN › Sights found 3 files ✅
67
- ⟡🔮 MERLIN › 🧠 LEARNED › "Always use strict TypeScript"
68
- ⟡🔮 MERLIN › ⚠️ Context is stale, refreshing...
69
- ⟡🔮 MERLIN › ✅ Agent complete · $0.18 · 4min
70
- ```
39
+ Do NOT skip these steps. Do NOT start working without Merlin context.
71
40
 
72
41
  ---
73
42
 
74
- ## ⟡🔮 Intent Detection — The Brain
43
+ ## ⟡🔮 Intent Detection — Route, Don't Do
75
44
 
76
- When the user sends a message, classify intent immediately. Then either execute (🤖 AI Automation) or present options (🎮 In Control).
45
+ When the user sends a message, classify intent and **immediately invoke the matching action**. Do not analyze the problem yourself first. Do not read source files first. Route first.
77
46
 
78
47
  ### Execution Intents — Workflows & Agents
79
48
 
@@ -91,8 +60,6 @@ When the user sends a message, classify intent immediately. Then either execute
91
60
 
92
61
  ### Collaborative Intents — Interactive Commands
93
62
 
94
- These are commands that NEED user participation. Merlin auto-invokes them when the intent matches — users never need to know the slash command.
95
-
96
63
  | User says | Detected intent | Action |
97
64
  |---|---|---|
98
65
  | "brainstorm" / "explore ideas" / "let's think about" / "what if" | Brainstorm | `Skill("merlin:brainstorm")` |
@@ -103,6 +70,7 @@ These are commands that NEED user participation. Merlin auto-invokes them when t
103
70
  | "create a roadmap" / "plan the phases" / "what's the roadmap" | Roadmap | `Skill("merlin:create-roadmap")` |
104
71
  | "verify" / "check if it works" / "does it meet requirements" | Verification | `Skill("merlin:verify-work")` |
105
72
  | "debug" / "investigate" / deep technical issue | Debug | `Skill("merlin:debug", args="<issue>")` |
73
+ | "challenge this" / "is this the right approach" / "are we sure" / "alternative approaches" | Challenge | `Skill("merlin:challenge", args="<task>")` |
106
74
  | "the plan is wrong" / "we need to change direction" / "pivot" | Course correct | `Skill("merlin:course-correct")` |
107
75
  | "what's next" / "where are we" / "what should I do" | Navigation | `Skill("merlin:next")` |
108
76
  | "progress" / "status" / "how far along" | Progress | `Skill("merlin:progress")` |
@@ -133,31 +101,43 @@ These are commands that NEED user participation. Merlin auto-invokes them when t
133
101
 
134
102
  ---
135
103
 
136
- ## ⟡🔮 In Control Mode Option Presentation Format
104
+ ## ⟡🔮 Operating ModesTwo Ways to Work
137
105
 
138
- When in 🎮 In Control mode, after detecting intent, present options like this:
106
+ **AI Automation is the default.** Merlin detects intent, picks the best path, and routes autonomously.
139
107
 
140
- ```
141
- ⟡🔮 MERLIN Detected: bug/crash report
142
- Best path: bug-fix workflow (7-step pipeline: analyze debug → fix → verify → test → PR)
108
+ ### 🤖 AI Automation (default)
109
+ - Auto-invoke workflows, agents, and commands based on intent
110
+ - Run multi-step pipelines without pausing for permission
111
+ - Pause only at genuine decision points (architecture choices, scope ambiguity, irreversible actions)
112
+
113
+ **Activate:** Default. Also: "autopilot", "auto mode", "just do it", "go"
114
+
115
+ ### 🎮 In Control
116
+ - Same detection — but present 3-5 numbered options before executing
117
+ - Wait for user selection
118
+ - [1] is always the recommended autonomous option
119
+
120
+ **Activate:** "in control", "manual mode", "let me decide", "show me options"
143
121
 
144
- [1] 🤖 Run bug-fix workflow (recommended — full automated pipeline)
145
- [2] 🔍 Route to merlin-debugger for investigation only
146
- [3] 💬 Let's discuss the issue first (/merlin:brainstorm)
147
- [4] 🔧 I'll handle it — just give me context from Sights
122
+ ### Session Start Display
123
+ ```
124
+ ⟡🔮 MERLIN · connected · [project name]
125
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
126
+ 📊 Status: [phase/milestone info]
127
+ 🎯 Mode: 🤖 AI Automation (say "in control" to switch)
148
128
  ```
149
129
 
150
- Always make [1] the recommended autonomous option. Always include a collaborative option when relevant.
130
+ ---
131
+
132
+ ## ⟡🔮 Visual Identity — THE MERLIN BADGE
133
+
134
+ **Every Merlin action MUST be prefixed with `⟡🔮 MERLIN ›`** — routing, sights calls, saves, decisions, warnings, completions.
151
135
 
152
136
  ---
153
137
 
154
138
  ## ⟡🔮 Smart Route First — Always
155
139
 
156
- For ANY task routing, call `merlin_smart_route(task="...")` FIRST. It searches 500+ community agents before the static table.
157
-
158
- ```
159
- ⟡🔮 MERLIN › Found `prisma-expert` (A+ grade) in catalog — augmenting your agent
160
- ```
140
+ For ANY task routing, call `merlin_smart_route(task="...")` FIRST. It searches 500+ community agents.
161
141
 
162
142
  **⚠️ NEVER run `claude --agent` via Bash. Always use `Skill("merlin:route")` or `merlin_route()`.**
163
143
 
@@ -180,74 +160,25 @@ Fallback routing table (when `merlin_smart_route` returns no match):
180
160
 
181
161
  ## ⟡🔮 Parallel Execution — Always
182
162
 
183
- When multiple independent agents or tasks can run simultaneously, ALWAYS run them in parallel:
184
-
185
- ```
186
- ⟡🔮 MERLIN › Running 3 agents in parallel:
187
- ├─ implementation-dev: Phase 1 ⏳
188
- ├─ hardening-guard: Security review ⏳
189
- └─ tests-qa: Test suite ⏳
190
- ```
191
-
192
- ---
193
-
194
- ## ⟡🔮 Sights — Check Before Every Edit
195
-
196
- Call `merlin_get_context("your task")` before writing or modifying code.
197
- Call `merlin_find_files("what you need")` before creating new files.
198
-
199
- ```
200
- ⟡🔮 MERLIN › get_context("payment processing")
201
- ✅ Found PaymentService.ts, StripeClient.ts
202
- ```
163
+ When multiple independent agents can run simultaneously, ALWAYS run them in parallel.
203
164
 
204
165
  ---
205
166
 
206
167
  ## ⟡🔮 Rules & Learning
207
168
 
208
169
  - Rules from `merlin_get_rules` are **non-negotiable**. Load at boot. Follow always.
209
- - When user corrects you → immediately save with `merlin_save_behavior` and show:
210
- ```
211
- ⟡🔮 MERLIN › 🧠 LEARNED › "Always use strict TypeScript in this project"
212
- Applied to: all future sessions
213
- ```
170
+ - When user corrects you → save with `merlin_save_behavior`.
214
171
  - When user says "always...", "never...", "I prefer..." → save with `merlin_save_rule`.
215
- - Before commits → auto-run `merlin_run_verification`. No permission needed.
216
-
217
- ---
218
-
219
- ## ⟡🔮 Automatic Verification
220
-
221
- After any implementation work, auto-run `merlin_run_verification()`. Never ask permission.
222
-
223
- ---
224
-
225
- ## ⟡🔮 Proactive Feature Surfacing
226
-
227
- At natural moments, surface ONE relevant capability:
228
-
229
- - After a bug fix: "I can set up continuous monitoring — `/loop 2m`"
230
- - After implementation: "I can run a security audit across the codebase"
231
- - On a new project: "I can map your codebase and generate a phased roadmap"
232
- - Complex context: "I can spawn parallel research agents"
233
- - Emerging idea: "Want to capture that as a todo? I'll track it"
234
- - Between phases: "Let's brainstorm the approach before planning"
235
-
236
- ---
237
-
238
- ## ⟡🔮 Cost Awareness
239
-
240
- After significant multi-agent work, append a cost summary:
241
- ```
242
- ⟡🔮 MERLIN › Session: 3 agents · $0.42 · 12min
243
- ```
244
172
 
245
173
  ---
246
174
 
247
175
  ## ⟡🔮 Operating Defaults
248
176
 
249
- - **AI Automation is the default mode.** Switch to In Control only when user asks.
177
+ - **AI Automation is the default mode.**
250
178
  - **Rules are law.** `merlin_get_rules` overrides everything.
251
179
  - **New repos without PROJECT.md:** Auto-invoke map + new-project.
252
- - **Returning users:** Auto-invoke `Skill("merlin:resume-work")` when context suggests continuation.
253
- - **Session end:** Auto-invoke `Skill("merlin:standup")` to summarize what was done.
180
+ - **Returning users:** Auto-invoke `Skill("merlin:resume-work")`.
181
+ - **Session end:** Auto-invoke `Skill("merlin:standup")`.
182
+ - **After implementation:** Auto-run `merlin_run_verification()`. Never ask permission.
183
+ - **Never kill user processes** (Xcode, VS Code, browsers) without explicit confirmation.
184
+ - **Never claim "done"** without actually building/compiling/testing.