create-merlin-brain 3.12.0 → 3.14.0

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 (45) hide show
  1. package/bin/install.cjs +10 -10
  2. package/dist/server/api/types.d.ts +7 -0
  3. package/dist/server/api/types.d.ts.map +1 -1
  4. package/dist/server/server.js +8 -8
  5. package/dist/server/server.js.map +1 -1
  6. package/dist/server/session-coach.js +9 -9
  7. package/dist/server/session-coach.js.map +1 -1
  8. package/dist/server/stats.js +7 -7
  9. package/dist/server/stats.js.map +1 -1
  10. package/dist/server/tools/__tests__/augmentation.test.d.ts +8 -0
  11. package/dist/server/tools/__tests__/augmentation.test.d.ts.map +1 -0
  12. package/dist/server/tools/__tests__/augmentation.test.js +76 -0
  13. package/dist/server/tools/__tests__/augmentation.test.js.map +1 -0
  14. package/dist/server/tools/__tests__/route-helpers.test.d.ts +5 -0
  15. package/dist/server/tools/__tests__/route-helpers.test.d.ts.map +1 -0
  16. package/dist/server/tools/__tests__/route-helpers.test.js +49 -0
  17. package/dist/server/tools/__tests__/route-helpers.test.js.map +1 -0
  18. package/dist/server/tools/agent-spawn.d.ts +25 -0
  19. package/dist/server/tools/agent-spawn.d.ts.map +1 -0
  20. package/dist/server/tools/agent-spawn.js +95 -0
  21. package/dist/server/tools/agent-spawn.js.map +1 -0
  22. package/dist/server/tools/augmentation.d.ts +45 -0
  23. package/dist/server/tools/augmentation.d.ts.map +1 -0
  24. package/dist/server/tools/augmentation.js +167 -0
  25. package/dist/server/tools/augmentation.js.map +1 -0
  26. package/dist/server/tools/project.js +1 -1
  27. package/dist/server/tools/project.js.map +1 -1
  28. package/dist/server/tools/route-helpers.d.ts +45 -0
  29. package/dist/server/tools/route-helpers.d.ts.map +1 -0
  30. package/dist/server/tools/route-helpers.js +93 -0
  31. package/dist/server/tools/route-helpers.js.map +1 -0
  32. package/dist/server/tools/route.d.ts +4 -3
  33. package/dist/server/tools/route.d.ts.map +1 -1
  34. package/dist/server/tools/route.js +63 -308
  35. package/dist/server/tools/route.js.map +1 -1
  36. package/files/CLAUDE.md +66 -5
  37. package/files/agents/merlin.md +21 -13
  38. package/files/hooks/config-change.sh +2 -2
  39. package/files/hooks/notify-desktop.sh +2 -2
  40. package/files/hooks/notify-webhook.sh +1 -1
  41. package/files/hooks/session-start-context.sh +1 -1
  42. package/files/hooks/task-completed-verify.sh +2 -2
  43. package/files/hooks/worktree-create.sh +1 -1
  44. package/files/hooks/worktree-remove.sh +1 -1
  45. package/package.json +5 -2
@@ -7,229 +7,26 @@
7
7
  *
8
8
  * 1. Verifies agent exists
9
9
  * 2. Fetches Sights context for the task
10
- * 3. Builds structured handoff
11
- * 4. Spawns a fresh `claude --agent <name> -p` process
12
- * 5. Captures and returns the result
10
+ * 3. Discovers cloud agent augmentation
11
+ * 4. Builds structured handoff with domain expertise
12
+ * 5. Spawns a fresh `claude --agent <name> -p` process
13
+ * 6. Captures and returns the result
13
14
  *
14
15
  * Claude just calls `merlin_route(agent, task)` — no bash generation needed.
15
16
  */
16
17
  import { z } from 'zod';
17
18
  import { spawn } from 'child_process';
18
- import { existsSync, readdirSync, readFileSync } from 'fs';
19
+ import { existsSync } from 'fs';
19
20
  import { join } from 'path';
20
21
  import { homedir } from 'os';
21
22
  import { classifyTask } from '../cost/classifier.js';
22
23
  import { recordRouting } from '../cost/tracker.js';
23
- /**
24
- * Parse the YAML frontmatter block from an agent .md file.
25
- * Returns the raw frontmatter string or null if not present.
26
- */
27
- function parseFrontmatter(agentPath) {
28
- try {
29
- const content = readFileSync(agentPath, 'utf-8');
30
- const match = content.match(/^---\n([\s\S]*?)\n---/);
31
- return match ? match[1] : null;
32
- }
33
- catch {
34
- return null;
35
- }
36
- }
37
- /**
38
- * Read the effort field from an agent's .md frontmatter.
39
- * Returns 'medium' as the safe default if not found or unreadable.
40
- */
41
- function readAgentEffort(agentPath) {
42
- const frontmatter = parseFrontmatter(agentPath);
43
- if (!frontmatter)
44
- return 'medium';
45
- const match = frontmatter.match(/^effort:\s*(high|medium|low)\s*$/m);
46
- if (!match)
47
- return 'medium';
48
- return match[1];
49
- }
50
- /**
51
- * Read the isolation field from an agent's .md frontmatter.
52
- * Returns 'worktree' if isolation: worktree is set, otherwise null.
53
- */
54
- function readAgentIsolation(agentPath) {
55
- const frontmatter = parseFrontmatter(agentPath);
56
- if (!frontmatter)
57
- return null;
58
- const match = frontmatter.match(/^isolation:\s*(worktree)\s*$/m);
59
- return match ? match[1] : null;
60
- }
61
- /**
62
- * Read the background field from an agent's .md frontmatter.
63
- * Returns true if background: true is set.
64
- */
65
- function readAgentBackground(agentPath) {
66
- const frontmatter = parseFrontmatter(agentPath);
67
- if (!frontmatter)
68
- return false;
69
- return /^background:\s*true\s*$/m.test(frontmatter);
70
- }
71
- /**
72
- * Build the task prompt prefix based on effort level.
73
- * - high: prepend ultrathink for deep reasoning
74
- * - low: append concise note to avoid unnecessary exploration
75
- * - medium: no prefix (default behavior)
76
- */
77
- function buildEffortPrefix(effort) {
78
- if (effort === 'high') {
79
- return { prefix: 'ultrathink\n\n', suffix: '' };
80
- }
81
- if (effort === 'low') {
82
- return {
83
- prefix: '',
84
- suffix: '\n\n> **Note:** Be concise and efficient. Focus on output over exploration.',
85
- };
86
- }
87
- return { prefix: '', suffix: '' };
88
- }
89
- /** Known specialist agents and their roles */
90
- const AGENT_ROLES = {
91
- 'product-spec': 'Feature specification and product definition',
92
- 'system-architect': 'Architecture decisions and system design',
93
- 'implementation-dev': 'Code implementation and feature building',
94
- 'dry-refactor': 'Code cleanup, DRY refactoring, file organization',
95
- 'hardening-guard': 'Security hardening, input validation, error handling',
96
- 'tests-qa': 'Testing and quality assurance',
97
- 'ops-railway': 'Deployment, ops, Railway, Google Cloud',
98
- 'docs-keeper': 'Documentation updates',
99
- };
100
- /** Merlin internal workflow agents */
101
- const WORKFLOW_AGENTS = [
102
- 'merlin-planner', 'merlin-executor', 'merlin-codebase-mapper',
103
- 'merlin-debugger', 'merlin-researcher', 'merlin-reviewer',
104
- 'merlin-work-verifier', 'merlin-milestone-auditor',
105
- 'merlin-frontend', 'merlin-api-designer', 'merlin-security',
106
- 'merlin-performance', 'merlin-migrator', 'merlin-integration-checker',
107
- ];
108
- /** Max output size to prevent context explosion (100KB) */
109
- const MAX_OUTPUT_SIZE = 100 * 1024;
110
- /**
111
- * Spawn a fresh Claude process and capture its output
112
- */
113
- function spawnAgent(agent, input, timeoutMs, model, isolation) {
114
- return new Promise((resolve, reject) => {
115
- let settled = false;
116
- const settle = (fn, value) => {
117
- if (settled)
118
- return;
119
- settled = true;
120
- clearTimeout(timer);
121
- fn(value);
122
- };
123
- // Remove CLAUDECODE env var so the child process doesn't think it's nested.
124
- // Claude Code sets CLAUDECODE to detect nested sessions, but merlin_route
125
- // intentionally spawns isolated fresh processes — not accidental nesting.
126
- const childEnv = { ...process.env };
127
- delete childEnv.CLAUDECODE;
128
- const spawnArgs = [
129
- '--agent', agent,
130
- '-p',
131
- '--permission-mode', 'acceptEdits',
132
- '--output-format', 'text',
133
- ];
134
- // Add worktree isolation flag for risky agents (hardening, refactoring, implementation)
135
- if (isolation === 'worktree') {
136
- spawnArgs.push('--worktree');
137
- }
138
- // Add model flag if specified
139
- if (model) {
140
- spawnArgs.push('--model', model);
141
- }
142
- const proc = spawn('claude', spawnArgs, {
143
- stdio: ['pipe', 'pipe', 'pipe'],
144
- env: childEnv,
145
- });
146
- let stdout = '';
147
- let stderr = '';
148
- proc.stdout.on('data', (data) => {
149
- stdout += data.toString();
150
- // Prevent memory explosion — kill and reject (only if not already settled)
151
- if (stdout.length > MAX_OUTPUT_SIZE) {
152
- proc.kill('SIGTERM');
153
- settle(reject, new Error('Agent output exceeded 100KB limit'));
154
- }
155
- });
156
- proc.stderr.on('data', (data) => {
157
- stderr += data.toString();
158
- });
159
- proc.stdin.write(input);
160
- proc.stdin.end();
161
- const timer = setTimeout(() => {
162
- proc.kill('SIGTERM');
163
- settle(reject, new Error(`Agent timed out after ${Math.round(timeoutMs / 60000)} minutes`));
164
- }, timeoutMs);
165
- proc.on('close', (code) => {
166
- settle(resolve, { stdout, stderr, exitCode: code });
167
- });
168
- proc.on('error', (err) => {
169
- settle(reject, err);
170
- });
171
- });
172
- }
173
- /**
174
- * Get list of available agent names from ~/.claude/agents/
175
- */
176
- function getAvailableAgents() {
177
- const agents = new Set();
178
- // Check global agents
179
- const globalDir = join(homedir(), '.claude', 'agents');
180
- if (existsSync(globalDir)) {
181
- readdirSync(globalDir).filter(f => f.endsWith('.md')).forEach(f => agents.add(f.replace('.md', '')));
182
- }
183
- // Check project-local agents
184
- const localDir = join(process.cwd(), '.claude', 'agents');
185
- if (existsSync(localDir)) {
186
- readdirSync(localDir).filter(f => f.endsWith('.md')).forEach(f => agents.add(f.replace('.md', '')));
187
- }
188
- return [...agents].sort();
189
- }
190
- /**
191
- * Truncate output to prevent context window explosion
192
- */
193
- function truncateOutput(output, maxLength = 50000) {
194
- if (output.length <= maxLength)
195
- return output;
196
- const truncated = output.slice(0, maxLength);
197
- return truncated + `\n\n... [Output truncated at ${maxLength} chars. Full output was ${output.length} chars]`;
198
- }
199
- /**
200
- * Discovery-first routing: before routing to a built-in agent, check the
201
- * catalog for a better-fit community/specialist agent. Returns recommendation
202
- * if a high-scoring match exists, otherwise null.
203
- */
204
- async function discoverBetterAgent(client, task, chosenAgent) {
205
- try {
206
- const results = await client.searchAgentsIndex(task, { limit: 3 });
207
- if (!results || results.length === 0)
208
- return null;
209
- // Only suggest if grade is A+ or A++ and it's NOT the same agent already chosen
210
- const topMatch = results[0];
211
- const grade = (topMatch.grade || '').toUpperCase();
212
- if ((grade === 'A++' || grade === 'A+') && topMatch.slug !== chosenAgent && topMatch.name !== chosenAgent) {
213
- return {
214
- name: topMatch.name,
215
- grade: topMatch.grade || '',
216
- description: topMatch.description || '',
217
- slug: topMatch.slug,
218
- };
219
- }
220
- return null;
221
- }
222
- catch {
223
- // Discovery is best-effort — never block routing
224
- return null;
225
- }
226
- }
24
+ import { readAgentEffort, readAgentIsolation, readAgentBackground, buildEffortPrefix, AGENT_ROLES, WORKFLOW_AGENTS, } from './route-helpers.js';
25
+ import { spawnAgent, getAvailableAgents, truncateOutput } from './agent-spawn.js';
26
+ import { discoverBetterAgent, shouldAugment, fetchAugmentation, buildAugmentationSection, } from './augmentation.js';
227
27
  export function registerRouteTools(ctx) {
228
28
  const { server, client, resolveRepoId } = ctx;
229
- // ── CORE tool: always loaded, primary way to delegate specialist work ───
230
- // ===================================================================
231
- // merlin_route — Spawn a fresh Claude process for a specialist agent
232
- // ===================================================================
29
+ // ── merlin_route Spawn a fresh Claude process for a specialist agent ──
233
30
  server.tool('merlin_route', 'Delegate a task to a specialist agent in a FRESH Claude process with full 200K context. ' +
234
31
  'Pre-fetches Sights codebase context, builds a structured handoff, applies effort-level routing (ultrathink for high-effort agents), and captures the result. ' +
235
32
  'Use when you need a specialist: code implementation, architecture design, test writing, security hardening, DRY refactoring, documentation, deployment/ops. ' +
@@ -247,29 +44,7 @@ export function registerRouteTools(ctx) {
247
44
  // 1. Verify agent exists
248
45
  const agentPath = join(homedir(), '.claude', 'agents', `${agent}.md`);
249
46
  if (!existsSync(agentPath)) {
250
- const available = getAvailableAgents();
251
- const specialists = available.filter(a => AGENT_ROLES[a]);
252
- const workflows = available.filter(a => WORKFLOW_AGENTS.includes(a));
253
- const other = available.filter(a => !AGENT_ROLES[a] && !WORKFLOW_AGENTS.includes(a));
254
- let msg = `Agent "${agent}" not found.\n\n`;
255
- if (specialists.length > 0) {
256
- msg += `**Specialist Agents:**\n`;
257
- specialists.forEach(a => {
258
- msg += `- \`${a}\` — ${AGENT_ROLES[a] || ''}\n`;
259
- });
260
- }
261
- if (workflows.length > 0) {
262
- msg += `\n**Workflow Agents:**\n`;
263
- workflows.forEach(a => { msg += `- \`${a}\`\n`; });
264
- }
265
- if (other.length > 0) {
266
- msg += `\n**Other Agents:**\n`;
267
- other.forEach(a => { msg += `- \`${a}\`\n`; });
268
- }
269
- return {
270
- content: [{ type: 'text', text: msg }],
271
- isError: true,
272
- };
47
+ return { content: [{ type: 'text', text: formatAgentNotFound(agent) }], isError: true };
273
48
  }
274
49
  // 2. Check if `claude` CLI is available
275
50
  try {
@@ -281,20 +56,14 @@ export function registerRouteTools(ctx) {
281
56
  }
282
57
  catch {
283
58
  return {
284
- content: [{
285
- type: 'text',
286
- text: 'The `claude` CLI is not available in PATH. ' +
287
- 'Agent routing requires Claude Code CLI to spawn fresh processes.',
288
- }],
59
+ content: [{ type: 'text', text: 'The `claude` CLI is not available in PATH. Agent routing requires Claude Code CLI to spawn fresh processes.' }],
289
60
  isError: true,
290
61
  };
291
62
  }
292
63
  // 3. Fetch Sights context + discovery check in parallel
293
64
  let sightsContext = '';
294
65
  let repoRoot = '';
295
- // Run Sights fetch, discovery check, and repo root in parallel
296
66
  const [, discoveryResult] = await Promise.all([
297
- // Sights context fetch
298
67
  (async () => {
299
68
  try {
300
69
  const repoId = await resolveRepoId();
@@ -306,79 +75,62 @@ export function registerRouteTools(ctx) {
306
75
  sightsContext = '';
307
76
  }
308
77
  })(),
309
- // Discovery-first: check catalog for a better-fit agent (non-blocking)
310
78
  discoverBetterAgent(client, task, agent).catch(() => null),
311
- // Repo root path
312
79
  (async () => {
313
80
  try {
314
81
  if (ctx.getRepoRootPath) {
315
82
  repoRoot = await ctx.getRepoRootPath() || '';
316
83
  }
317
84
  }
318
- catch {
319
- // Non-fatal
320
- }
85
+ catch { /* Non-fatal */ }
321
86
  })(),
322
87
  ]);
323
88
  const discoveryHint = discoveryResult;
324
89
  if (discoveryHint) {
325
- console.error(`[merlin_route] Discovery hint: "${discoveryHint.name}" (${discoveryHint.grade}) may be a better fit — slug: ${discoveryHint.slug}`);
90
+ console.error(`[merlin_route] Discovery hint: "${discoveryHint.name}" (${discoveryHint.grade}) — slug: ${discoveryHint.slug}`);
326
91
  }
327
- // 4. Read effort level, isolation mode, and background flag from agent frontmatter
92
+ // 4. Fetch augmentation if cloud agent matched and agent is eligible
93
+ const augmentation = (discoveryHint && shouldAugment(agent))
94
+ ? await fetchAugmentation(client, discoveryHint)
95
+ : null;
96
+ // 5. Read agent frontmatter config
328
97
  const effort = readAgentEffort(agentPath);
329
98
  const isolation = readAgentIsolation(agentPath);
330
99
  const isBackground = readAgentBackground(agentPath);
331
100
  const { prefix: effortPrefix, suffix: effortSuffix } = buildEffortPrefix(effort);
332
- console.error(`[merlin_route] Effort level: ${effort}${effort === 'high' ? ' (ultrathink enabled)' : effort === 'low' ? ' (concise mode)' : ''}`);
101
+ console.error(`[merlin_route] Effort: ${effort}${effort === 'high' ? ' (ultrathink)' : effort === 'low' ? ' (concise)' : ''}`);
333
102
  if (isolation)
334
103
  console.error(`[merlin_route] Isolation: ${isolation}`);
335
- if (isBackground)
336
- console.error(`[merlin_route] Mode: background (non-blocking)`);
337
- // 5. Build the handoff
104
+ // 6. Build the handoff
338
105
  const handoffParts = [
339
- `# Agent Task: ${agent}`,
340
- '',
341
- `## Your Task`,
342
- task,
343
- '',
106
+ `# Agent Task: ${agent}`, '',
107
+ `## Your Task`, task, '',
344
108
  ];
345
- if (extraContext) {
109
+ if (extraContext)
346
110
  handoffParts.push(`## Additional Context`, extraContext, '');
347
- }
348
- if (repoRoot) {
111
+ if (repoRoot)
349
112
  handoffParts.push(`## Repository Root`, `\`${repoRoot}\``, '');
350
- }
351
- if (sightsContext) {
113
+ if (sightsContext)
352
114
  handoffParts.push(`## Merlin Sights Context (pre-fetched)`, sightsContext, '');
353
- }
115
+ if (augmentation)
116
+ handoffParts.push(...buildAugmentationSection(augmentation));
354
117
  handoffParts.push(`## Instructions`, `- Complete the task described above`, `- Use Merlin Sights tools (merlin_get_context, merlin_find_files) for additional context`, `- Follow all coding rules and conventions from Sights`, `- Output a clear, concise summary of what you did and any files changed`);
355
- if (effortSuffix) {
118
+ if (effortSuffix)
356
119
  handoffParts.push('', effortSuffix);
357
- }
358
120
  const handoff = effortPrefix + handoffParts.join('\n');
359
- // 7. Classify task complexity and select model
121
+ // 7. Classify task and select model
360
122
  const classification = classifyTask(task, agent);
361
- console.error(`[merlin_route] Model selected: ${classification.model} (${classification.complexity}) — ${classification.reason}`);
362
- // Record cost tracking before spawning (agent name tracked for per-agent breakdown)
123
+ console.error(`[merlin_route] Model: ${classification.model} (${classification.complexity}) — ${classification.reason}`);
363
124
  recordRouting(classification.model, classification.complexity, { agent });
364
125
  // 8. Spawn fresh Claude process
365
- console.error(`[merlin_route] Spawning agent "${agent}" for task: ${task.slice(0, 100)}...`);
126
+ console.error(`[merlin_route] Spawning "${agent}" for: ${task.slice(0, 100)}...`);
366
127
  try {
367
128
  const result = await spawnAgent(agent, handoff, timeout, classification.model, isolation);
368
129
  const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
369
130
  const output = truncateOutput(result.stdout || '');
370
131
  if (result.exitCode !== 0 && !output) {
371
- // Process failed with no output
372
- const errMsg = result.stderr
373
- ? truncateOutput(result.stderr, 5000)
374
- : 'No output or error from agent process';
375
- return {
376
- content: [{
377
- type: 'text',
378
- text: `Agent "${agent}" exited with code ${result.exitCode} (${elapsed}s)\n\n**Error:**\n${errMsg}`,
379
- }],
380
- isError: true,
381
- };
132
+ const errMsg = result.stderr ? truncateOutput(result.stderr, 5000) : 'No output or error from agent process';
133
+ return { content: [{ type: 'text', text: `Agent "${agent}" exited with code ${result.exitCode} (${elapsed}s)\n\n**Error:**\n${errMsg}` }], isError: true };
382
134
  }
383
135
  // Build response header
384
136
  let response = `## Agent: ${agent} (${elapsed}s)\n`;
@@ -388,56 +140,40 @@ export function registerRouteTools(ctx) {
388
140
  response += `> Isolation: \`${isolation}\` — running in fresh worktree\n`;
389
141
  if (isBackground)
390
142
  response += `> Mode: background — non-blocking execution\n`;
391
- // Discovery hint: suggest a better-fit agent from the catalog
143
+ if (augmentation)
144
+ response += `> Augmented with: \`${augmentation.slug}\` (${augmentation.grade}) — ${augmentation.description.slice(0, 80)}\n`;
392
145
  if (discoveryHint) {
393
- response += `\n> 💡 **Catalog match:** \`${discoveryHint.name}\` (${discoveryHint.grade}) — ${discoveryHint.description}\n`;
146
+ response += `\n> Catalog match: \`${discoveryHint.name}\` (${discoveryHint.grade}) — ${discoveryHint.description}\n`;
394
147
  response += `> View: \`merlin_get_agent_detail("${discoveryHint.slug}")\` | Install: \`merlin_discover_agents("${discoveryHint.slug}")\`\n`;
395
148
  }
396
149
  response += '\n';
397
- if (result.exitCode !== 0) {
150
+ if (result.exitCode !== 0)
398
151
  response += `> Note: Agent exited with code ${result.exitCode}\n\n`;
399
- }
400
152
  response += output;
401
- return {
402
- content: [{ type: 'text', text: response }],
403
- };
153
+ return { content: [{ type: 'text', text: response }] };
404
154
  }
405
155
  catch (e) {
406
156
  const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
407
- return {
408
- content: [{
409
- type: 'text',
410
- text: `Agent "${agent}" failed after ${elapsed}s: ${e.message}`,
411
- }],
412
- isError: true,
413
- };
157
+ return { content: [{ type: 'text', text: `Agent "${agent}" failed after ${elapsed}s: ${e.message}` }], isError: true };
414
158
  }
415
159
  });
416
- // ── CORE tool: always loaded, needed to know what routing options exist ─
417
- // ===================================================================
418
- // merlin_list_agents — List available specialist agents
419
- // ===================================================================
160
+ // ── merlin_list_agents List available specialist agents ──
420
161
  server.tool('merlin_list_agents', 'List all installed specialist agents available for routing via merlin_route. Returns agent names, roles, effort levels, and descriptions for all built-in agents (product-spec, system-architect, implementation-dev, dry-refactor, hardening-guard, tests-qa, ops-railway, docs-keeper) plus any custom agents in ~/.claude/agents/. Use before delegating to confirm which agents are available.', {}, async () => {
421
162
  const available = getAvailableAgents();
422
163
  let response = `# Available Agents\n\n`;
423
- // Specialists
424
164
  const specialists = available.filter(a => AGENT_ROLES[a]);
425
165
  if (specialists.length > 0) {
426
166
  response += `## Specialist Agents (use with merlin_route)\n\n`;
427
167
  response += `| Agent | Role |\n|-------|------|\n`;
428
- specialists.forEach(a => {
429
- response += `| \`${a}\` | ${AGENT_ROLES[a]} |\n`;
430
- });
168
+ specialists.forEach(a => { response += `| \`${a}\` | ${AGENT_ROLES[a]} |\n`; });
431
169
  response += '\n';
432
170
  }
433
- // Workflow agents
434
171
  const workflows = available.filter(a => WORKFLOW_AGENTS.includes(a));
435
172
  if (workflows.length > 0) {
436
173
  response += `## Workflow Agents (used by /merlin:* commands)\n\n`;
437
174
  workflows.forEach(a => { response += `- \`${a}\`\n`; });
438
175
  response += '\n';
439
176
  }
440
- // Other
441
177
  const other = available.filter(a => !AGENT_ROLES[a] && !WORKFLOW_AGENTS.includes(a));
442
178
  if (other.length > 0) {
443
179
  response += `## Other Agents\n\n`;
@@ -445,9 +181,28 @@ export function registerRouteTools(ctx) {
445
181
  }
446
182
  response += `\n**Total:** ${available.length} agents installed\n`;
447
183
  response += `\n**Usage:** \`merlin_route(agent="implementation-dev", task="add login endpoint")\``;
448
- return {
449
- content: [{ type: 'text', text: response }],
450
- };
184
+ return { content: [{ type: 'text', text: response }] };
451
185
  });
452
186
  }
187
+ /** Format "agent not found" error with available agents list */
188
+ function formatAgentNotFound(agent) {
189
+ const available = getAvailableAgents();
190
+ const specialists = available.filter(a => AGENT_ROLES[a]);
191
+ const workflows = available.filter(a => WORKFLOW_AGENTS.includes(a));
192
+ const other = available.filter(a => !AGENT_ROLES[a] && !WORKFLOW_AGENTS.includes(a));
193
+ let msg = `Agent "${agent}" not found.\n\n`;
194
+ if (specialists.length > 0) {
195
+ msg += `**Specialist Agents:**\n`;
196
+ specialists.forEach(a => { msg += `- \`${a}\` — ${AGENT_ROLES[a] || ''}\n`; });
197
+ }
198
+ if (workflows.length > 0) {
199
+ msg += `\n**Workflow Agents:**\n`;
200
+ workflows.forEach(a => { msg += `- \`${a}\`\n`; });
201
+ }
202
+ if (other.length > 0) {
203
+ msg += `\n**Other Agents:**\n`;
204
+ other.forEach(a => { msg += `- \`${a}\`\n`; });
205
+ }
206
+ return msg;
207
+ }
453
208
  //# sourceMappingURL=route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/server/tools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Execute These Steps BEFORE Responding
2
4
 
3
5
  **Step 1** — Call `merlin_get_selected_repo` to connect Merlin Sights.
4
6
  **Step 2** — Call `merlin_get_project_status` to load project state.
5
- **Step 3** — Show the user a status summary with numbered options, THEN handle their request.
7
+ **Step 3** — Show the user a `⟡🔮 MERLIN` status summary with numbered options, THEN handle their request.
6
8
 
7
9
  Do NOT skip these steps. Do NOT start working without Merlin context.
8
10
 
9
- ## Routing
11
+ ## ⟡🔮 Visual Identity — THE MERLIN BADGE
12
+
13
+ **Every single Merlin action MUST be prefixed with `⟡🔮 MERLIN ›`** — routing, sights calls, saves, decisions, warnings, completions. No exceptions. This is how the user knows Merlin is engaged.
14
+
15
+ Examples:
16
+ ```
17
+ ⟡🔮 MERLIN › Routing → implementation-dev
18
+ ⟡🔮 MERLIN › Sights found 3 files ✅
19
+ ⟡🔮 MERLIN › SAVED › Rule: "strict TypeScript"
20
+ ⟡🔮 MERLIN › ⚠️ Context is stale, refreshing...
21
+ ⟡🔮 MERLIN › ✅ Agent complete
22
+ ```
23
+
24
+ ---
25
+
26
+ ## ⟡🔮 Routing — Use Skill(), Never Raw claude Commands
10
27
 
11
28
  Route specialist work via: `Skill("merlin:route", args='<agent> "<task>"')`
12
29
 
13
- NEVER run `claude --agent` via Bash — it crashes inside Claude Code. Always use the Skill tool.
30
+ **⚠️ NEVER run `claude --agent` via Bash — it crashes inside Claude Code. Always use the Skill tool.**
31
+
32
+ | User intent | Route to |
33
+ |---|---|
34
+ | Idea, product flow | `product-spec` |
35
+ | Architecture, data models | `system-architect` |
36
+ | New/changed code | `implementation-dev` |
37
+ | Cleanup, DRY | `dry-refactor` |
38
+ | Security, validation | `hardening-guard` |
39
+ | Tests | `tests-qa` |
40
+ | Deploy, infra | `ops-railway` |
41
+ | Docs | `docs-keeper` |
42
+ | Video, Remotion | `remotion` |
43
+ | React/Vue UI | `merlin-frontend` |
14
44
 
15
- ## Before every file edit
45
+ ## ⟡🔮 Sights — Check Before Every Edit
16
46
 
17
47
  Call `merlin_get_context("your task")` before writing or modifying code.
48
+ Call `merlin_find_files("what you need")` before creating new files.
49
+
50
+ **Show the badge after every Sights call:**
51
+ ```
52
+ ⟡🔮 MERLIN › get_context("payment processing")
53
+ ✅ Found PaymentService.ts, StripeClient.ts
54
+ ```
55
+ Use ✅ (helped), ⚠️ (partial), ❌ (no match).
56
+
57
+ ## ⟡🔮 Rules & Behaviors
58
+
59
+ - Rules from `merlin_get_rules` are **non-negotiable**. Follow them.
60
+ - When user corrects you → save with `merlin_save_behavior`.
61
+ - When user says "always...", "never...", "I prefer..." → save with `merlin_save_rule`.
62
+ - Before commits → run `merlin_run_verification`.
63
+
64
+ ## ⟡🔮 Decision Points — Always Show Options
65
+
66
+ At session start, task completion, unclear requests, or errors — show numbered options:
67
+ ```
68
+ ⟡🔮 MERLIN › What's next?
69
+ [1] ▶️ Continue implementation
70
+ [2] 🧪 Test what we built
71
+ [3] 📋 Plan next steps (/merlin:plan-phase)
72
+ [4] 💬 Something else
73
+ ```
74
+
75
+ ## Operating Mode
76
+
77
+ - **Default: Fast execution.** Move fast, state assumptions at end.
78
+ - **New repos without PROJECT.md:** Suggest `/merlin:map-codebase` then `/merlin:new-project`.