create-merlin-brain 5.0.2 → 5.3.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.
Files changed (101) hide show
  1. package/README.md +25 -4
  2. package/bin/install.cjs +95 -0
  3. package/dist/server/server.d.ts.map +1 -1
  4. package/dist/server/server.js +75 -0
  5. package/dist/server/server.js.map +1 -1
  6. package/dist/server/tools/context.d.ts.map +1 -1
  7. package/dist/server/tools/context.js +60 -0
  8. package/dist/server/tools/context.js.map +1 -1
  9. package/dist/server/tools/project-picture.d.ts +17 -0
  10. package/dist/server/tools/project-picture.d.ts.map +1 -0
  11. package/dist/server/tools/project-picture.js +204 -0
  12. package/dist/server/tools/project-picture.js.map +1 -0
  13. package/dist/server/tools/types.d.ts +24 -0
  14. package/dist/server/tools/types.d.ts.map +1 -1
  15. package/files/agents/challenger-academic.md +8 -0
  16. package/files/agents/challenger-arbiter.md +8 -0
  17. package/files/agents/challenger-insider.md +8 -0
  18. package/files/agents/code-organization-supervisor.md +8 -0
  19. package/files/agents/codex-planner.md +36 -9
  20. package/files/agents/context-guardian.md +8 -0
  21. package/files/agents/docs-keeper.md +8 -0
  22. package/files/agents/dry-refactor.md +8 -0
  23. package/files/agents/elite-code-refactorer.md +8 -0
  24. package/files/agents/hardening-guard.md +8 -0
  25. package/files/agents/implementation-dev.md +8 -0
  26. package/files/agents/merlin-access-control-reviewer.md +8 -0
  27. package/files/agents/merlin-api-designer.md +8 -0
  28. package/files/agents/merlin-codebase-mapper.md +8 -0
  29. package/files/agents/merlin-debugger.md +8 -0
  30. package/files/agents/merlin-dependency-auditor.md +8 -0
  31. package/files/agents/merlin-edge-case-hunter.md +8 -0
  32. package/files/agents/merlin-executor.md +8 -0
  33. package/files/agents/merlin-frontend.md +8 -0
  34. package/files/agents/merlin-input-validator.md +8 -0
  35. package/files/agents/merlin-integration-checker.md +8 -0
  36. package/files/agents/merlin-migrator.md +8 -0
  37. package/files/agents/merlin-milestone-auditor.md +8 -0
  38. package/files/agents/merlin-party-review.md +8 -0
  39. package/files/agents/merlin-performance.md +8 -0
  40. package/files/agents/merlin-planner.md +9 -1
  41. package/files/agents/merlin-researcher.md +8 -0
  42. package/files/agents/merlin-reviewer.md +8 -0
  43. package/files/agents/merlin-sast-reviewer.md +8 -0
  44. package/files/agents/merlin-secret-scanner.md +8 -0
  45. package/files/agents/merlin-security.md +8 -0
  46. package/files/agents/merlin-verifier.md +8 -0
  47. package/files/agents/merlin-work-verifier.md +8 -0
  48. package/files/agents/merlin.md +8 -0
  49. package/files/agents/ops-railway.md +8 -0
  50. package/files/agents/orchestrator-retrofit.md +8 -0
  51. package/files/agents/product-spec.md +8 -0
  52. package/files/agents/remotion.md +8 -0
  53. package/files/agents/system-architect.md +8 -0
  54. package/files/agents/tests-qa.md +8 -0
  55. package/files/commands/merlin/course-correct.md +8 -0
  56. package/files/commands/merlin/design-audit.md +92 -0
  57. package/files/commands/merlin/health.md +8 -0
  58. package/files/commands/merlin/next.md +8 -0
  59. package/files/commands/merlin/optimize.md +89 -0
  60. package/files/commands/merlin/polish.md +99 -0
  61. package/files/commands/merlin/quick.md +8 -0
  62. package/files/commands/merlin/readiness-gate.md +8 -0
  63. package/files/commands/merlin/redesign.md +108 -0
  64. package/files/loop/README.md +11 -0
  65. package/files/merlin/skills/SKILLS-INDEX.md +16 -1
  66. package/files/merlin/skills/TASK-OPTIMIZER.json +310 -0
  67. package/files/merlin/skills/coding/focus-mode.md +8 -0
  68. package/files/merlin/skills/design/emil-design-eng.md +31 -0
  69. package/files/merlin/skills/design/impeccable.md +36 -0
  70. package/files/merlin/skills/duo/offer.md +20 -7
  71. package/files/merlin/skills/duo/on.md +26 -17
  72. package/files/merlin/skills/duo/status.md +10 -3
  73. package/files/merlin/templates/DEBUG.md +11 -0
  74. package/files/merlin/templates/UAT.md +11 -0
  75. package/files/merlin/templates/phase-prompt.md +11 -0
  76. package/files/merlin/templates/project.md +11 -0
  77. package/files/merlin/templates/requirements.md +11 -0
  78. package/files/merlin/templates/roadmap.md +11 -0
  79. package/files/merlin/templates/state.md +11 -0
  80. package/files/merlin/templates/verification-report.md +11 -0
  81. package/files/merlin/workflows/execute-phase.md +11 -0
  82. package/files/merlin/workflows/plan-phase.md +11 -0
  83. package/files/merlin/workflows/progress.md +11 -0
  84. package/files/merlin/workflows/resume-project.md +11 -0
  85. package/files/merlin/workflows/verify-phase.md +11 -0
  86. package/files/merlin/workflows/verify-work.md +11 -0
  87. package/files/merlin-system-prompt.txt +35 -1
  88. package/files/rules/codex-routing.md +19 -0
  89. package/files/rules/duo-routing.md +109 -10
  90. package/files/rules/merlin-routing.md +40 -0
  91. package/files/scripts/codex-as.sh +5 -2
  92. package/files/scripts/design-intent-detect.sh +8 -0
  93. package/files/scripts/duo-badge.sh +3 -5
  94. package/files/scripts/duo-installed.sh +3 -3
  95. package/files/scripts/duo-mode-read.sh +30 -10
  96. package/files/scripts/duo-mode-write.sh +28 -3
  97. package/files/scripts/duo-pre-route.sh +2 -8
  98. package/files/scripts/install-design-skills.sh +86 -0
  99. package/files/scripts/merlin-codex.sh +9 -4
  100. package/files/scripts/task-optimize.sh +335 -0
  101. package/package.json +1 -1
package/README.md CHANGED
@@ -9,11 +9,26 @@
9
9
  ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═══╝
10
10
  ```
11
11
 
12
- Merlin is a complete AI-powered development system for Claude Code, Codex, and other CLI runtimes with three integrated layers:
12
+ Merlin curates the best of the Claude Code and Codex CLI ecosystem and wires it together — automated, opinionated, and kept in sync. We didn't invent context engineering, spec-driven workflows, or adversarial code review. We integrated them. One install, you get the patterns the community converged on, made discoverable through slash commands, specialist agents, lifecycle hooks, and an MCP-backed knowledge layer. This is the AI development system connecting Claude Code, Codex CLI, MCP, and the broader ecosystem into a coherent whole.
13
13
 
14
- - **Merlin Sights** - Knowledge layer (instant codebase context)
15
- - **Merlin Workflows** - Planning & execution (`/merlin:*` commands)
16
- - **Merlin Agents** - Specialist agents for every task
14
+ ---
15
+
16
+ ## Standing on the shoulders of
17
+
18
+ Merlin would not exist without these projects. We adapted patterns, code, and ideas from each — and we credit them in [`NOTICE.md`](./NOTICE.md). The full machine-readable ledger is in [`upstreams.yaml`](./upstreams.yaml).
19
+
20
+ | Upstream | What we credit | Link |
21
+ |---|---|---|
22
+ | **GSD (Get Shit Done)** | `.planning/` schema, `/merlin:quick`, `/merlin:health --repair`, fresh-context execution model, multi-runtime adapter pattern | [gsd-build/get-shit-done](https://github.com/gsd-build/get-shit-done) |
23
+ | **BMAD-METHOD** | `<critical_actions>` agent hardening, adversarial reviewer, edge-case-hunter, party-review, `/merlin:next`, `/merlin:readiness-gate`, `/merlin:course-correct`, dialectic challenge | [bmad-code-org/BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD) |
24
+ | **Ralph Wiggum technique** | Merlin Loop (autonomous iterate-on-failure pattern) | [snwfdhmp/awesome-ralph](https://github.com/snwfdhmp/awesome-ralph) |
25
+ | **Claude Code Best Practice** (shanraisshan) | Curated index of Claude Code patterns we draw from | [shanraisshan/claude-code-best-practice](https://github.com/shanraisshan/claude-code-best-practice) |
26
+
27
+ Full attribution and per-file provenance in [`NOTICE.md`](./NOTICE.md).
28
+
29
+ > Note: The historical internal `get-shit-done/` directory in this repo (deleted in commit `bfe5d2c` v3.0.0) was an unrelated Merlin sub-package, not lifted from external GSD.
30
+
31
+ ---
17
32
 
18
33
  ## Quick Install
19
34
 
@@ -166,6 +181,12 @@ merlin-codex login # pass-through — no prompt injection
166
181
 
167
182
  The wrapper prints the Merlin banner to stderr, loads `~/.claude/merlin-system-prompt.txt` (falls back to a one-liner if missing), and forwards all management subcommands (`login`, `logout`, `mcp`, etc.) unchanged.
168
183
 
184
+ ## Recommended reading
185
+
186
+ The single best curated index of Claude Code patterns we draw from:
187
+
188
+ - **[shanraisshan/claude-code-best-practice](https://github.com/shanraisshan/claude-code-best-practice)** — 49k★ — community-curated catalog of 82 tips, 10+ workflow taxonomies, and expert distillations from Boris Cherny, Anthropic staff, and the broader community. Endorsed by the Claude Code creator. If you want to understand the patterns Merlin automates, start here.
189
+
169
190
  ## Documentation
170
191
 
171
192
  Visit [merlin.build/docs](https://merlin.build/docs) for full documentation.
package/bin/install.cjs CHANGED
@@ -1609,6 +1609,91 @@ async function install() {
1609
1609
  quiet: true, // step 2 already printed the detection summary
1610
1610
  });
1611
1611
 
1612
+ // Step 13.4: Allowlist codex Bash patterns (when Codex is installed)
1613
+ if (!process.env.MERLIN_SKIP_PERMISSIONS_PATCH) {
1614
+ try {
1615
+ const { execSync } = require('child_process');
1616
+ const codexInstalledScript = path.join(SCRIPTS_DIR, 'codex-installed.sh');
1617
+
1618
+ // Check if Codex is installed
1619
+ let isCodexInstalled = false;
1620
+ try {
1621
+ if (fs.existsSync(codexInstalledScript)) {
1622
+ execSync(`bash ${codexInstalledScript}`, { stdio: 'pipe' });
1623
+ isCodexInstalled = true;
1624
+ }
1625
+ } catch (err) {
1626
+ // Codex not installed, skip this step
1627
+ }
1628
+
1629
+ if (isCodexInstalled) {
1630
+ const settingsPath = path.join(CLAUDE_DIR, 'settings.json');
1631
+
1632
+ if (fs.existsSync(settingsPath)) {
1633
+ try {
1634
+ const settingsContent = fs.readFileSync(settingsPath, 'utf8');
1635
+ const settings = JSON.parse(settingsContent);
1636
+
1637
+ if (settings.permissions && Array.isArray(settings.permissions.allow)) {
1638
+ const codexRules = [
1639
+ 'Bash(which *)',
1640
+ 'Bash(codex *)',
1641
+ 'Bash(codex exec *)',
1642
+ 'Bash(merlin-codex *)',
1643
+ 'Bash(~/.claude/scripts/codex-as.sh *)',
1644
+ 'Bash(bash ~/.claude/scripts/codex-as.sh *)',
1645
+ 'Bash(~/.claude/scripts/duo-codex-call.sh *)',
1646
+ 'Bash(bash ~/.claude/scripts/duo-codex-call.sh *)',
1647
+ 'Bash(~/.claude/scripts/codex-installed.sh)',
1648
+ 'Bash(~/.claude/scripts/duo-*)',
1649
+ 'Bash(bash ~/.claude/scripts/duo-*)',
1650
+ 'mcp__merlin__*'
1651
+ ];
1652
+
1653
+ let addedCount = 0;
1654
+ for (const rule of codexRules) {
1655
+ if (!settings.permissions.allow.includes(rule)) {
1656
+ settings.permissions.allow.push(rule);
1657
+ addedCount++;
1658
+ }
1659
+ }
1660
+
1661
+ if (addedCount > 0) {
1662
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
1663
+ logSuccess(`Allowlisted codex/duo commands in ~/.claude/settings.json (${addedCount} new rules)`);
1664
+ } else if (process.env.MERLIN_INSTALL_VERBOSE) {
1665
+ log(` codex/duo Bash rules already allowlisted`);
1666
+ }
1667
+ } else {
1668
+ logWarn('permissions.allow not found in ~/.claude/settings.json — skipping codex allowlist');
1669
+ }
1670
+ } catch (parseErr) {
1671
+ logWarn(`Could not parse ~/.claude/settings.json — skipping codex allowlist: ${parseErr.message}`);
1672
+ }
1673
+ }
1674
+ // If settings.json doesn't exist, skip silently (don't create it from scratch)
1675
+ }
1676
+ } catch (err) {
1677
+ // Non-fatal: permissions patch failure does not block the installer
1678
+ if (process.env.MERLIN_INSTALL_VERBOSE) {
1679
+ logWarn(`Codex permissions patch skipped: ${err.message}`);
1680
+ }
1681
+ }
1682
+ }
1683
+
1684
+ // Step 13.5: Install priority design skills (async, non-blocking)
1685
+ if (!process.env.MERLIN_SKIP_DESIGN_SKILLS) {
1686
+ try {
1687
+ const { spawn } = require('child_process');
1688
+ const designSkillsScript = path.join(SCRIPTS_DIR, 'install-design-skills.sh');
1689
+ if (fs.existsSync(designSkillsScript)) {
1690
+ spawn('bash', [designSkillsScript], { stdio: 'inherit', detached: false });
1691
+ }
1692
+ } catch (err) {
1693
+ // Non-fatal: design skills install failure does not block the main installer
1694
+ }
1695
+ }
1696
+
1612
1697
  // Shell integration (runs after runtime adapters)
1613
1698
  log(`\n${colors.cyan}[shell]${colors.reset} Setting up shell integration...`);
1614
1699
  const shellConfigured = setupShellIntegration();
@@ -1641,6 +1726,16 @@ ${colors.cyan}Autonomous Mode (Merlin Loop):${colors.reset}
1641
1726
  ${colors.bright}merlin-loop build${colors.reset} - Execute tasks autonomously
1642
1727
  ${colors.bright}merlin-loop --afk auto${colors.reset} - Run unattended with safety limits
1643
1728
 
1729
+ ${colors.cyan}Universal Task Optimization (NEW in 5.3.0):${colors.reset}
1730
+ • Every task gets the right skill + agent automatically
1731
+ • ${colors.bright}/merlin:optimize "<task>"${colors.reset} - Preview the recommendation
1732
+ • ${colors.bright}/merlin:design-audit${colors.reset} - Design review with impeccable + emil
1733
+ • ${colors.bright}/merlin:polish${colors.reset} - Animation polish via animation-expert
1734
+ • ${colors.bright}/merlin:redesign${colors.reset} - Full redesign via ui-builder
1735
+
1736
+ ${colors.cyan}Duo permissions (NEW in 5.3.2):${colors.reset}
1737
+ • Auto-allowlist codex/duo Bash commands when Codex is installed
1738
+
1644
1739
  ${colors.cyan}Merlin works with or without Sights:${colors.reset}
1645
1740
  • ${colors.green}With Sights${colors.reset}: Instant context, cross-session memory
1646
1741
  • ${colors.green}Without${colors.reset}: Full workflows, uses file exploration
@@ -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;AAwDpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CA4gGxC;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;AAyDpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CA4lGxC;AAED,gDAAgD;AAChD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA+CjD"}
@@ -37,6 +37,7 @@ import { registerAutoModeTools } from './tools/auto-mode.js';
37
37
  import { registerDreamTools } from './tools/dream.js';
38
38
  import { registerComputerUseTools } from './tools/computer-use.js';
39
39
  import { registerSkillsTools } from './tools/skills.js';
40
+ import { registerProjectPictureTools } from './tools/project-picture.js';
40
41
  import { wrapResponse, getStats, getCompactStats, formatSaveNotification, markSessionStatusShown } from './stats.js';
41
42
  import { coachWrap, recordToolCall } from './session-coach.js';
42
43
  /** Load saved config from ~/.merlin/config.json */
@@ -608,6 +609,69 @@ export function createServer() {
608
609
  if (teachBackPrompt) {
609
610
  context += teachBackPrompt;
610
611
  }
612
+ // ── Phase 9 Wave 4: Project Picture augmentation ─────────────────────
613
+ // Always-populated on tracked repos (any non-default repository_branches rows).
614
+ // Feature-flagged; when flag off or API unavailable this is a silent no-op.
615
+ if (process.env.MERLIN_CROSS_BRANCH_ENABLED === 'true') {
616
+ try {
617
+ // Infer current branch from git HEAD
618
+ let currentBranch = null;
619
+ try {
620
+ const { execFile } = await import('child_process');
621
+ const { promisify } = await import('util');
622
+ const execFileAsync = promisify(execFile);
623
+ const { stdout } = await execFileAsync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { timeout: 3000 });
624
+ const b = stdout.trim();
625
+ if (b && b !== 'HEAD')
626
+ currentBranch = b;
627
+ }
628
+ catch { /* non-fatal */ }
629
+ const apiBase = process.env.MERLIN_API_URL ?? 'https://auth.merlin.build';
630
+ const ppUrl = new URL(`/api/repos/${repoId}/project-picture`, apiBase);
631
+ if (currentBranch)
632
+ ppUrl.searchParams.set('branch', currentBranch);
633
+ if (task)
634
+ ppUrl.searchParams.set('task', task.slice(0, 200));
635
+ const ppHeaders = { 'Content-Type': 'application/json' };
636
+ const ppKey = process.env.MERLIN_API_KEY;
637
+ if (ppKey)
638
+ ppHeaders['Authorization'] = `Bearer ${ppKey}`;
639
+ const ppResp = await fetch(ppUrl.toString(), {
640
+ headers: ppHeaders,
641
+ signal: AbortSignal.timeout(5000),
642
+ });
643
+ if (ppResp.ok) {
644
+ const pp = await ppResp.json();
645
+ // Always include even with zero signals so agent knows other branches exist
646
+ context += `\n## 🌿 Project Picture (cross-branch)\n`;
647
+ context += `_${pp.disclaimer}_\n\n`;
648
+ context += `**Current Branch:** \`${pp.currentBranch}\`\n`;
649
+ if (pp.liveBranches && pp.liveBranches.length > 0) {
650
+ context += `**Live Branches (${pp.liveBranches.length}):** ${pp.liveBranches.slice(0, 8).map(b => `\`${b.name}\``).join(', ')}\n`;
651
+ }
652
+ else {
653
+ context += `**Live Branches:** _(none — single-branch workspace)_\n`;
654
+ }
655
+ if (pp.signals && pp.signals.length > 0) {
656
+ const topSignals = pp.signals.slice(0, 5);
657
+ context += `\n**Signals (top ${topSignals.length}):**\n`;
658
+ for (const s of topSignals) {
659
+ const emoji = s.kind === 'drift' ? '⚠️' : '💡';
660
+ context += `${emoji} **${s.kind}** \`${s.filePath}\` severity=${s.severity.toFixed(2)} — ${s.summary}\n`;
661
+ context += ` _(${s.sourceBranch} → ${s.targetBranch})_\n`;
662
+ }
663
+ }
664
+ else {
665
+ context += `**Signals:** _(none — no cross-branch conflicts detected)_\n`;
666
+ }
667
+ context += '\n';
668
+ }
669
+ }
670
+ catch {
671
+ // Strictly best-effort — never break context delivery
672
+ }
673
+ }
674
+ // ── End Project Picture augmentation ─────────────────────────────────
611
675
  // Wrap with visual header and stats
612
676
  const wrappedContext = wrapResponse('merlin_get_context', context, {
613
677
  task,
@@ -2772,6 +2836,17 @@ export function createServer() {
2772
2836
  client,
2773
2837
  resolveRepoId,
2774
2838
  });
2839
+ // ============================================================
2840
+ // PROJECT PICTURE TOOLS - Cross-branch drift + opportunity signals
2841
+ // Phase 9 Wave 4 — works locally (no cloud API key needed)
2842
+ // Feature-flagged: MERLIN_CROSS_BRANCH_ENABLED=true activates signals
2843
+ // ============================================================
2844
+ registerProjectPictureTools({
2845
+ server,
2846
+ client,
2847
+ resolveRepoId,
2848
+ getRepoRootPath,
2849
+ });
2775
2850
  return server;
2776
2851
  }
2777
2852
  /** Start the MCP server with stdio transport */