create-merlin-brain 3.23.0 → 4.2.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.
package/README.md CHANGED
@@ -115,9 +115,25 @@ On Codex, Merlin now installs beyond basic MCP connectivity:
115
115
  - Project `.codex/agents/` with Merlin specialist agents
116
116
  - Project `.agents/skills/` with Merlin workflow skills
117
117
  - Project `AGENTS.md` and `.codex/config.toml` for repo-local guidance
118
+ - Merlin capability discovery via `merlin_help`
119
+ - Automatic steering toward `merlin_smart_route`, `merlin_recommend_for_task`, and `merlin_find_skill` when Codex sees feature, bug, or resume-style prompts
118
120
 
119
121
  Codex does not currently expose a documented extension point for replacing app-shell chrome or adding a custom sidebar icon, so Merlin parity is implemented on the supported surfaces Codex actually provides.
120
122
 
123
+ Typical Codex prompts:
124
+
125
+ ```text
126
+ Use Merlin to map this codebase before changing anything.
127
+ ```
128
+
129
+ ```text
130
+ Use Merlin to find the best skill, agent, and workflow for this task: add OAuth login.
131
+ ```
132
+
133
+ ```text
134
+ Call merlin_help for this task: debug the failing Stripe webhook tests.
135
+ ```
136
+
121
137
  ## Documentation
122
138
 
123
139
  Visit [merlin.build/docs](https://merlin.build/docs) for full documentation.
package/bin/install.cjs CHANGED
@@ -136,6 +136,8 @@ const AGENTS_DIR = path.join(CLAUDE_DIR, 'agents');
136
136
  const COMMANDS_DIR = path.join(CLAUDE_DIR, 'commands', 'merlin');
137
137
  const LOOP_DIR = path.join(CLAUDE_DIR, 'loop');
138
138
  const RULES_DIR = path.join(CLAUDE_DIR, 'rules');
139
+ const SCRIPTS_DIR = path.join(CLAUDE_DIR, 'scripts');
140
+ const MERLIN_STATE_DIR = path.join(CLAUDE_DIR, 'merlin-state');
139
141
 
140
142
  const colors = {
141
143
  reset: '\x1b[0m',
@@ -1356,6 +1358,48 @@ async function install() {
1356
1358
  logWarn('Hooks not found in package');
1357
1359
  }
1358
1360
 
1361
+ // Step 11b: Install Codex integration scripts
1362
+ logStep('11b/13', 'Installing Codex integration scripts...');
1363
+ const scriptsSrc = path.join(filesDir, 'scripts');
1364
+ if (fs.existsSync(scriptsSrc)) {
1365
+ ensureDir(SCRIPTS_DIR);
1366
+ const count = copyDirRecursive(scriptsSrc, SCRIPTS_DIR);
1367
+ // Make all .sh files executable
1368
+ fs.readdirSync(SCRIPTS_DIR).forEach(file => {
1369
+ if (file.endsWith('.sh')) {
1370
+ fs.chmodSync(path.join(SCRIPTS_DIR, file), '755');
1371
+ }
1372
+ });
1373
+ logSuccess(`Installed ${count} script files (Codex integration)`);
1374
+ } else {
1375
+ logWarn('Scripts not found in package');
1376
+ }
1377
+
1378
+ // Step 11c: Install merlin-state defaults (without overwriting user state)
1379
+ logStep('11c/13', 'Installing merlin-state defaults...');
1380
+ const stateSrc = path.join(filesDir, 'merlin-state');
1381
+ if (fs.existsSync(stateSrc)) {
1382
+ ensureDir(MERLIN_STATE_DIR);
1383
+ const stateFiles = fs.readdirSync(stateSrc);
1384
+ let installedCount = 0;
1385
+ let skippedCount = 0;
1386
+ for (const stateFile of stateFiles) {
1387
+ if (stateFile === '.DS_Store') continue;
1388
+ const destPath = path.join(MERLIN_STATE_DIR, stateFile);
1389
+ // Never overwrite existing state files — preserve user state
1390
+ if (fs.existsSync(destPath)) {
1391
+ skippedCount++;
1392
+ } else {
1393
+ fs.copyFileSync(path.join(stateSrc, stateFile), destPath);
1394
+ installedCount++;
1395
+ }
1396
+ }
1397
+ if (installedCount > 0) logSuccess(`Installed ${installedCount} state file defaults`);
1398
+ if (skippedCount > 0) logSuccess(`Skipped ${skippedCount} existing state files (user state preserved)`);
1399
+ } else {
1400
+ logWarn('Merlin-state defaults not found in package');
1401
+ }
1402
+
1359
1403
  // Helper: create MCP config object based on available binary
1360
1404
  function mcpConfig(apiKey, includeType) {
1361
1405
  const cfg = useGlobalBinary
@@ -185,10 +185,19 @@ Before doing real work in a repository:
185
185
 
186
186
  Do not skip boot. Do not start editing code without Merlin context.
187
187
 
188
+ ## Discoverability
189
+
190
+ - If the user asks what Merlin can do, call \`merlin_help\`.
191
+ - If the best Merlin path is unclear, call \`merlin_help(task)\`.
192
+ - For new features or integrations, call \`merlin_recommend_for_task(task)\` before building from scratch.
193
+ - For agent selection, call \`merlin_smart_route(task)\`.
194
+ - For reusable prompt packs, call \`merlin_find_skill(query)\`.
195
+
188
196
  ## Codex + Merlin Workflow
189
197
 
190
198
  - For codebase questions, start with \`merlin_search("query")\` or \`merlin_get_context("task")\`.
191
199
  - Before every code edit, call \`merlin_get_context("your task")\`.
200
+ - Let Merlin choose the route first when helpful: tool vs skill vs custom agent vs direct execution.
192
201
  - When local file search is still needed, prefer fast repo-native tools such as \`rg\`.
193
202
  - Use Codex's normal execution style: inspect first, edit surgically, verify after changes.
194
203
  - Keep progress updates concise and factual while work is in flight.
@@ -211,9 +220,13 @@ Do not skip boot. Do not start editing code without Merlin context.
211
220
 
212
221
  - \`merlin_get_selected_repo\` — identify the active repository
213
222
  - \`merlin_get_project_status\` — load project state and active tasks
223
+ - \`merlin_help(task?)\` — explain Merlin capabilities and recommend the best route
214
224
  - \`merlin_get_context(task)\` — fetch targeted implementation context
215
225
  - \`merlin_find_files(query)\` — locate files by purpose
216
226
  - \`merlin_search(query)\` — semantic code search
227
+ - \`merlin_find_skill(query)\` — find reusable Merlin skills
228
+ - \`merlin_smart_route(task)\` — choose the best specialist agent
229
+ - \`merlin_recommend_for_task(task)\` — find agents and reference codebases before building
217
230
 
218
231
  ## Defaults
219
232
 
@@ -343,6 +356,8 @@ mkdir -p "\${MERLIN_HOME}/analytics" "\${MERLIN_HOME}/sessions" 2>/dev/null || t
343
356
 
344
357
  _context="MERLIN MODE ACTIVE. Before handling the user request, call merlin_get_selected_repo, then merlin_get_project_status, then merlin_get_rules and merlin_get_brief."
345
358
  _context="\${_context} Use Merlin context before edits: call merlin_get_context(task)."
359
+ _context="\${_context} If the best Merlin path is unclear, call merlin_help(task) before acting."
360
+ _context="\${_context} For task routing, prefer merlin_smart_route(task), merlin_find_skill(query), and merlin_recommend_for_task(task) over improvising."
346
361
  _context="\${_context} Prefer Merlin skills and custom agents installed in this repository when they match the task."
347
362
  _context="\${_context} Keep the Codex experience pragmatic: inspect first, patch surgically, verify before claiming completion."
348
363
  _context="\${_context} Prefix visible progress updates with the Merlin badge when practical: ⟡🔮 MERLIN ›"
@@ -375,18 +390,22 @@ fi
375
390
  clean=$(printf '%s' "$prompt" | sed -E -e 's/<[^>]+>//g' -e 's|https?://[^ ]*||g' -e 's|/[a-zA-Z0-9._/-]+||g' -e 's/\`[^\`]*\`//g')
376
391
 
377
392
  suggestion=""
378
- if echo "$clean" | grep -qiE "resume|pick up|continue|where were we"; then
379
- suggestion='Merlin routing: resume context and use the merlin-resume skill.'
393
+ if echo "$clean" | grep -qiE "what can merlin do|how do i use merlin|what is available|available skills|available agents|available tools|help me use merlin"; then
394
+ suggestion='Merlin routing: call merlin_help first, then pick the recommended tool, skill, or agent path.'
395
+ elif echo "$clean" | grep -qiE "resume|pick up|continue|where were we"; then
396
+ suggestion='Merlin routing: call merlin_get_project_status, then use the merlin-resume skill.'
380
397
  elif echo "$clean" | grep -qiE "progress|status|where are we|how far"; then
381
- suggestion='Merlin routing: use the merlin-progress skill.'
398
+ suggestion='Merlin routing: call merlin_get_project_status, then use the merlin-progress skill.'
382
399
  elif echo "$clean" | grep -qiE "map codebase|understand this repo|learn this codebase|explore the architecture"; then
383
- suggestion='Merlin routing: use the merlin-map-codebase skill before implementation.'
400
+ suggestion='Merlin routing: call merlin_search and merlin_get_context, then use the merlin-map-codebase skill before implementation.'
384
401
  elif echo "$clean" | grep -qiE "bug|crash|error|not working|fix|failing|exception"; then
385
- suggestion='Merlin routing: debug first, then route bounded work to implementation and verification agents.'
402
+ suggestion='Merlin routing: call merlin_get_context for the bug, then merlin_smart_route(task), then use merlin-verify after the fix.'
386
403
  elif echo "$clean" | grep -qiE "refactor|cleanup|clean up|dry|restructure"; then
387
- suggestion='Merlin routing: keep scope narrow, preserve behavior, and use implementation plus verification agents.'
404
+ suggestion='Merlin routing: call merlin_get_context first, keep scope narrow, and use merlin-workflow plus merlin-verify.'
405
+ elif echo "$clean" | grep -qiE "oauth|auth|stripe|prisma|sdk|integration|api|graphql|railway|deploy"; then
406
+ suggestion='Merlin routing: call merlin_recommend_for_task(task), merlin_find_skill(query), and merlin_smart_route(task) before building.'
388
407
  elif echo "$clean" | grep -qiE "build|add|create|implement|new feature|develop"; then
389
- suggestion='Merlin routing: gather Merlin context first, then execute with implementation-focused agents.'
408
+ suggestion='Merlin routing: call merlin_help(task) or merlin_smart_route(task), gather Merlin context, then execute with implementation-focused agents.'
390
409
  fi
391
410
 
392
411
  [ -z "$suggestion" ] && echo "{}" && exit 0
@@ -615,6 +634,18 @@ function installCodexAgents(projectDir) {
615
634
 
616
635
  function buildCodexSkillSpecs() {
617
636
  return [
637
+ {
638
+ dir: 'merlin-discover',
639
+ content: `---
640
+ name: merlin-discover
641
+ description: Use when the user asks what Merlin can do, which Merlin features are available, or which Merlin path should be used for a task in Codex.
642
+ ---
643
+
644
+ Start with \`merlin_help\`.
645
+ If the user also has a concrete task, call \`merlin_help(task)\`.
646
+ Then choose the recommended route: direct Merlin tools, a Merlin skill, a custom Codex agent, or local execution.
647
+ Do not assume the user already knows internal Merlin names.`,
648
+ },
618
649
  {
619
650
  dir: 'merlin-map-codebase',
620
651
  content: `---
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAuDpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CAigGxC;AAED,gDAAgD;AAChD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA+CjD"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAwDpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CA4gGxC;AAED,gDAAgD;AAChD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA+CjD"}
@@ -19,6 +19,7 @@ import { registerVerificationTools } from './tools/verification.js';
19
19
  import { registerAdaptiveTools } from './tools/adaptive.js';
20
20
  import { registerAgentTools } from './tools/agents.js';
21
21
  import { registerDiscoveryTools } from './tools/discoveries.js';
22
+ import { registerHelpTools } from './tools/help.js';
22
23
  import { registerRouteTools } from './tools/route.js';
23
24
  import { registerCostTools } from './tools/cost.js';
24
25
  import { registerLiteTools, getOrInitLiteClient, enhanceFromCloud } from './tools/lite.js';
@@ -2598,6 +2599,16 @@ export function createServer() {
2598
2599
  });
2599
2600
  } // end free: registerAutoTeachTools
2600
2601
  // ============================================================
2602
+ if (!coreOnly) {
2603
+ // HELP TOOLS - Discover Merlin capabilities and recommended routes
2604
+ // ============================================================
2605
+ registerHelpTools({
2606
+ server,
2607
+ client,
2608
+ resolveRepoId,
2609
+ });
2610
+ } // end free: registerHelpTools
2611
+ // ============================================================
2601
2612
  if (!coreOnly) {
2602
2613
  // AGENT ROUTE TOOLS - Fresh process spawning for specialists (local)
2603
2614
  // ============================================================