create-merlin-brain 3.22.0 → 4.0.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 (80) hide show
  1. package/README.md +38 -4
  2. package/bin/merlin-ask.cjs +111 -0
  3. package/bin/merlin-cli.cjs +22 -0
  4. package/bin/runtime-adapters.cjs +709 -28
  5. package/dist/server/api/client.d.ts +2 -0
  6. package/dist/server/api/client.d.ts.map +1 -1
  7. package/dist/server/api/client.js +4 -0
  8. package/dist/server/api/client.js.map +1 -1
  9. package/dist/server/server.d.ts.map +1 -1
  10. package/dist/server/server.js +56 -4
  11. package/dist/server/server.js.map +1 -1
  12. package/dist/server/tools/auto-mode.d.ts +9 -0
  13. package/dist/server/tools/auto-mode.d.ts.map +1 -0
  14. package/dist/server/tools/auto-mode.js +231 -0
  15. package/dist/server/tools/auto-mode.js.map +1 -0
  16. package/dist/server/tools/computer-use.d.ts +8 -0
  17. package/dist/server/tools/computer-use.d.ts.map +1 -0
  18. package/dist/server/tools/computer-use.js +355 -0
  19. package/dist/server/tools/computer-use.js.map +1 -0
  20. package/dist/server/tools/dream.d.ts +9 -0
  21. package/dist/server/tools/dream.d.ts.map +1 -0
  22. package/dist/server/tools/dream.js +246 -0
  23. package/dist/server/tools/dream.js.map +1 -0
  24. package/dist/server/tools/help.d.ts +3 -0
  25. package/dist/server/tools/help.d.ts.map +1 -0
  26. package/dist/server/tools/help.js +110 -0
  27. package/dist/server/tools/help.js.map +1 -0
  28. package/dist/server/tools/hud.d.ts +13 -0
  29. package/dist/server/tools/hud.d.ts.map +1 -0
  30. package/dist/server/tools/hud.js +295 -0
  31. package/dist/server/tools/hud.js.map +1 -0
  32. package/dist/server/tools/index.d.ts +5 -0
  33. package/dist/server/tools/index.d.ts.map +1 -1
  34. package/dist/server/tools/index.js +5 -0
  35. package/dist/server/tools/index.js.map +1 -1
  36. package/dist/server/tools/provider-ask.d.ts +10 -0
  37. package/dist/server/tools/provider-ask.d.ts.map +1 -0
  38. package/dist/server/tools/provider-ask.js +234 -0
  39. package/dist/server/tools/provider-ask.js.map +1 -0
  40. package/dist/server/tools/rate-limit.d.ts +8 -0
  41. package/dist/server/tools/rate-limit.d.ts.map +1 -0
  42. package/dist/server/tools/rate-limit.js +184 -0
  43. package/dist/server/tools/rate-limit.js.map +1 -0
  44. package/dist/server/tools/skills.d.ts +16 -0
  45. package/dist/server/tools/skills.d.ts.map +1 -0
  46. package/dist/server/tools/skills.js +326 -0
  47. package/dist/server/tools/skills.js.map +1 -0
  48. package/dist/server/tools/team-workers.d.ts +7 -0
  49. package/dist/server/tools/team-workers.d.ts.map +1 -0
  50. package/dist/server/tools/team-workers.js +271 -0
  51. package/dist/server/tools/team-workers.js.map +1 -0
  52. package/dist/server/utils/merlin-manifest.d.ts +6 -1
  53. package/dist/server/utils/merlin-manifest.d.ts.map +1 -1
  54. package/dist/server/utils/merlin-manifest.js +34 -1
  55. package/dist/server/utils/merlin-manifest.js.map +1 -1
  56. package/files/CLAUDE.md +22 -0
  57. package/files/hooks/rate-limit-watch.sh +120 -0
  58. package/files/hooks/statusline.sh +148 -0
  59. package/files/merlin/skills/SKILLS-INDEX.md +82 -0
  60. package/files/merlin/skills/automation/payments.md +14 -0
  61. package/files/merlin/skills/automation/webhooks.md +14 -0
  62. package/files/merlin/skills/coding/accessibility.md +14 -0
  63. package/files/merlin/skills/coding/api-design.md +14 -0
  64. package/files/merlin/skills/coding/debug-mode.md +14 -0
  65. package/files/merlin/skills/coding/focus-mode.md +14 -0
  66. package/files/merlin/skills/coding/loop.md +14 -0
  67. package/files/merlin/skills/coding/performance.md +14 -0
  68. package/files/merlin/skills/coding/react-patterns.md +51 -0
  69. package/files/merlin/skills/coding/security-hardening.md +56 -0
  70. package/files/merlin/skills/coding/verify.md +14 -0
  71. package/files/merlin/skills/communication/dispatcher.md +40 -0
  72. package/files/merlin/skills/communication/email-gmail.md +31 -0
  73. package/files/merlin/skills/communication/telegram.md +50 -0
  74. package/files/merlin/skills/communication/whatsapp.md +47 -0
  75. package/files/merlin/skills/data/google-sheets.md +14 -0
  76. package/files/merlin/skills/design/animation.md +14 -0
  77. package/files/merlin/skills/devops/docker-containers.md +14 -0
  78. package/files/merlin/skills/research/brainstorm.md +14 -0
  79. package/files/merlin/skills/testing/tdd-workflow.md +58 -0
  80. package/package.json +4 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Merlin - The Ultimate AI Brain for Claude Code
1
+ # Merlin - The Ultimate AI Brain for Claude Code and Codex
2
2
 
3
3
  ```
4
4
  ███╗ ███╗███████╗██████╗ ██╗ ██╗███╗ ██╗
@@ -9,7 +9,7 @@
9
9
  ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═══╝
10
10
  ```
11
11
 
12
- Merlin is a complete AI-powered development system for Claude Code with three integrated layers:
12
+ Merlin is a complete AI-powered development system for Claude Code, Codex, and other CLI runtimes with three integrated layers:
13
13
 
14
14
  - **Merlin Sights** - Knowledge layer (instant codebase context)
15
15
  - **Merlin Workflows** - Planning & execution (`/merlin:*` commands)
@@ -21,6 +21,12 @@ Merlin is a complete AI-powered development system for Claude Code with three in
21
21
  npx create-merlin-brain
22
22
  ```
23
23
 
24
+ ### Runtime Support
25
+
26
+ - Claude Code: full Merlin install with workflows, agents, hooks, statusline, and shell integration
27
+ - Codex: Merlin MCP, `AGENTS.md`, Codex hooks, custom Codex agents, repo skills, and project `.codex` config
28
+ - OpenCode / Gemini CLI: Merlin MCP plus instruction-file integration
29
+
24
30
  ## What You Get
25
31
 
26
32
  ### Workflows (`/merlin:*` commands)
@@ -88,10 +94,10 @@ Merlin Sights provides instant codebase context across sessions. Get your API ke
88
94
  npx create-merlin-brain
89
95
  ```
90
96
 
91
- 2. Open Claude Code in any project
97
+ 2. Open Claude Code or Codex in any project
92
98
 
93
99
  3. Run your first command:
94
- ```
100
+ ```text
95
101
  /merlin:map-codebase
96
102
  ```
97
103
 
@@ -100,6 +106,34 @@ Merlin Sights provides instant codebase context across sessions. Get your API ke
100
106
  /merlin:new-project
101
107
  ```
102
108
 
109
+ ## Codex Experience
110
+
111
+ On Codex, Merlin now installs beyond basic MCP connectivity:
112
+
113
+ - Global `~/.codex/config.toml` MCP wiring for Merlin
114
+ - Global `~/.codex/hooks.json` for startup, prompt routing, command guardrails, and session wrap-up
115
+ - Project `.codex/agents/` with Merlin specialist agents
116
+ - Project `.agents/skills/` with Merlin workflow skills
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
120
+
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.
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
+
103
137
  ## Documentation
104
138
 
105
139
  Visit [merlin.build/docs](https://merlin.build/docs) for full documentation.
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * merlin-ask — Delegate a prompt to an external AI CLI provider
5
+ *
6
+ * Usage:
7
+ * merlin-ask claude "review this code for bugs"
8
+ * merlin-ask codex "add error handling to the payment module"
9
+ * merlin-ask gemini "suggest performance improvements"
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ const { spawn, execFileSync } = require('child_process');
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const os = require('os');
18
+
19
+ const ARTIFACTS_DIR = path.join(os.homedir(), '.merlin', 'artifacts', 'ask');
20
+
21
+ const COMMANDS = {
22
+ claude: (p) => ['claude', ['-p', p, '--output-format', 'text']],
23
+ codex: (p) => ['codex', ['exec', p]],
24
+ gemini: (p) => ['gemini', ['-p', p]],
25
+ };
26
+
27
+ // ── Args + validation ─────────────────────────────────────────────────────────
28
+
29
+ const provider = process.argv[2];
30
+ const prompt = process.argv[3];
31
+
32
+ if (!provider || !prompt) {
33
+ console.error('Usage: merlin-ask <claude|codex|gemini> "<prompt>"');
34
+ process.exit(1);
35
+ }
36
+
37
+ if (!COMMANDS[provider]) {
38
+ console.error(`Unknown provider: "${provider}". Valid: ${Object.keys(COMMANDS).join(', ')}`);
39
+ process.exit(1);
40
+ }
41
+
42
+ try {
43
+ execFileSync('which', [provider], { stdio: 'ignore' });
44
+ } catch {
45
+ console.error(`Error: '${provider}' CLI is not installed or not on PATH.`);
46
+ console.error(`Install it first, then retry: merlin-ask ${provider} "${prompt}"`);
47
+ process.exit(1);
48
+ }
49
+
50
+ // ── Helpers ───────────────────────────────────────────────────────────────────
51
+
52
+ function slugify(text) {
53
+ return text.toLowerCase().replace(/[^a-z0-9\s-]/g, '').trim().replace(/\s+/g, '-').slice(0, 40);
54
+ }
55
+
56
+ function saveArtifact(prov, text, output, exitCode, timestamp) {
57
+ if (!fs.existsSync(ARTIFACTS_DIR)) fs.mkdirSync(ARTIFACTS_DIR, { recursive: true });
58
+ const filePath = path.join(ARTIFACTS_DIR, `${prov}-${slugify(text)}-${timestamp}.md`);
59
+ fs.writeFileSync(filePath, [
60
+ `# Provider Ask — ${prov}`,
61
+ '',
62
+ `**Timestamp:** ${timestamp}`,
63
+ `**Exit Code:** ${exitCode}`,
64
+ '',
65
+ '## Prompt',
66
+ '',
67
+ text,
68
+ '',
69
+ '## Output',
70
+ '',
71
+ output || '_(no output)_',
72
+ ].join('\n'), 'utf-8');
73
+ return filePath;
74
+ }
75
+
76
+ // ── Spawn ─────────────────────────────────────────────────────────────────────
77
+
78
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
79
+ const [cmd, args] = COMMANDS[provider](prompt);
80
+
81
+ const env = { ...process.env };
82
+ if (provider === 'codex') {
83
+ delete env['RUST_LOG'];
84
+ delete env['RUST_BACKTRACE'];
85
+ }
86
+
87
+ const stdoutChunks = [];
88
+ const stderrChunks = [];
89
+ const proc = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'], env });
90
+
91
+ proc.stdout.on('data', (chunk) => stdoutChunks.push(chunk));
92
+ proc.stderr.on('data', (chunk) => stderrChunks.push(chunk));
93
+
94
+ proc.on('error', (err) => {
95
+ console.error(`Failed to start ${provider}: ${err.message}`);
96
+ process.exit(1);
97
+ });
98
+
99
+ proc.on('close', (code) => {
100
+ const output = Buffer.concat(stdoutChunks).toString('utf-8').trim();
101
+ const stderr = Buffer.concat(stderrChunks).toString('utf-8').trim();
102
+ const exitCode = code ?? -1;
103
+ const text = output || stderr;
104
+
105
+ const artifactPath = saveArtifact(provider, prompt, text, exitCode, timestamp);
106
+
107
+ if (text) process.stdout.write(text + '\n');
108
+ if (exitCode !== 0) process.stderr.write(`[merlin-ask] ${provider} exited with code ${exitCode}\n`);
109
+ process.stderr.write(`[merlin-ask] Artifact saved: ${artifactPath}\n`);
110
+ process.exit(exitCode);
111
+ });
@@ -353,6 +353,17 @@ async function inject() {
353
353
  }
354
354
  }
355
355
 
356
+ const agentsMd = path.join(repoRoot, 'AGENTS.md');
357
+ if (fs.existsSync(agentsMd)) {
358
+ const content = fs.readFileSync(agentsMd, 'utf-8');
359
+ if (!content.includes('MERLIN_SIGHT')) {
360
+ fs.writeFileSync(agentsMd, `# MERLIN_SIGHT: ${sightUrl}\n` + content);
361
+ console.log('✅ Injected Sight URL into AGENTS.md');
362
+ } else {
363
+ console.log('⏭️ AGENTS.md already has MERLIN_SIGHT marker');
364
+ }
365
+ }
366
+
356
367
  const cursorRules = path.join(repoRoot, '.cursor', 'rules');
357
368
  if (fs.existsSync(cursorRules)) {
358
369
  const content = fs.readFileSync(cursorRules, 'utf-8');
@@ -371,6 +382,17 @@ async function inject() {
371
382
  }
372
383
  }
373
384
 
385
+ const geminiMd = path.join(repoRoot, 'GEMINI.md');
386
+ if (fs.existsSync(geminiMd)) {
387
+ const content = fs.readFileSync(geminiMd, 'utf-8');
388
+ if (!content.includes('MERLIN_SIGHT')) {
389
+ fs.writeFileSync(geminiMd, `# MERLIN_SIGHT: ${sightUrl}\n` + content);
390
+ console.log('✅ Injected Sight URL into GEMINI.md');
391
+ } else {
392
+ console.log('⏭️ GEMINI.md already has MERLIN_SIGHT marker');
393
+ }
394
+ }
395
+
374
396
  console.log(`\n📄 Sight: ${sightUrl}`);
375
397
  console.log(`🔗 API: ${apiUrl}`);
376
398
  console.log('\nCommit .merlin.json to make it available to all collaborators.');