create-merlin-brain 5.0.1 → 5.3.1

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 (104) hide show
  1. package/README.md +38 -4
  2. package/bin/install.cjs +20 -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/CLAUDE.md +2 -0
  16. package/files/agents/challenger-academic.md +8 -0
  17. package/files/agents/challenger-arbiter.md +8 -0
  18. package/files/agents/challenger-insider.md +8 -0
  19. package/files/agents/code-organization-supervisor.md +8 -0
  20. package/files/agents/codex-planner.md +36 -9
  21. package/files/agents/context-guardian.md +8 -0
  22. package/files/agents/docs-keeper.md +8 -0
  23. package/files/agents/dry-refactor.md +8 -0
  24. package/files/agents/elite-code-refactorer.md +8 -0
  25. package/files/agents/hardening-guard.md +8 -0
  26. package/files/agents/implementation-dev.md +8 -0
  27. package/files/agents/merlin-access-control-reviewer.md +8 -0
  28. package/files/agents/merlin-api-designer.md +8 -0
  29. package/files/agents/merlin-codebase-mapper.md +8 -0
  30. package/files/agents/merlin-debugger.md +8 -0
  31. package/files/agents/merlin-dependency-auditor.md +8 -0
  32. package/files/agents/merlin-edge-case-hunter.md +8 -0
  33. package/files/agents/merlin-executor.md +8 -0
  34. package/files/agents/merlin-frontend.md +8 -0
  35. package/files/agents/merlin-input-validator.md +8 -0
  36. package/files/agents/merlin-integration-checker.md +8 -0
  37. package/files/agents/merlin-migrator.md +8 -0
  38. package/files/agents/merlin-milestone-auditor.md +8 -0
  39. package/files/agents/merlin-party-review.md +8 -0
  40. package/files/agents/merlin-performance.md +8 -0
  41. package/files/agents/merlin-planner.md +9 -1
  42. package/files/agents/merlin-researcher.md +8 -0
  43. package/files/agents/merlin-reviewer.md +8 -0
  44. package/files/agents/merlin-sast-reviewer.md +8 -0
  45. package/files/agents/merlin-secret-scanner.md +8 -0
  46. package/files/agents/merlin-security.md +8 -0
  47. package/files/agents/merlin-verifier.md +8 -0
  48. package/files/agents/merlin-work-verifier.md +8 -0
  49. package/files/agents/merlin.md +8 -0
  50. package/files/agents/ops-railway.md +8 -0
  51. package/files/agents/orchestrator-retrofit.md +8 -0
  52. package/files/agents/product-spec.md +8 -0
  53. package/files/agents/remotion.md +8 -0
  54. package/files/agents/system-architect.md +8 -0
  55. package/files/agents/tests-qa.md +8 -0
  56. package/files/commands/merlin/course-correct.md +8 -0
  57. package/files/commands/merlin/design-audit.md +92 -0
  58. package/files/commands/merlin/health.md +8 -0
  59. package/files/commands/merlin/next.md +8 -0
  60. package/files/commands/merlin/optimize.md +89 -0
  61. package/files/commands/merlin/polish.md +99 -0
  62. package/files/commands/merlin/quick.md +8 -0
  63. package/files/commands/merlin/readiness-gate.md +8 -0
  64. package/files/commands/merlin/redesign.md +108 -0
  65. package/files/hooks/session-start.sh +88 -2
  66. package/files/hooks/statusline.sh +9 -1
  67. package/files/loop/README.md +11 -0
  68. package/files/merlin/skills/SKILLS-INDEX.md +16 -1
  69. package/files/merlin/skills/TASK-OPTIMIZER.json +310 -0
  70. package/files/merlin/skills/coding/focus-mode.md +8 -0
  71. package/files/merlin/skills/design/emil-design-eng.md +31 -0
  72. package/files/merlin/skills/design/impeccable.md +36 -0
  73. package/files/merlin/skills/duo/offer.md +20 -7
  74. package/files/merlin/skills/duo/on.md +26 -17
  75. package/files/merlin/skills/duo/status.md +10 -3
  76. package/files/merlin/templates/DEBUG.md +11 -0
  77. package/files/merlin/templates/UAT.md +11 -0
  78. package/files/merlin/templates/phase-prompt.md +11 -0
  79. package/files/merlin/templates/project.md +11 -0
  80. package/files/merlin/templates/requirements.md +11 -0
  81. package/files/merlin/templates/roadmap.md +11 -0
  82. package/files/merlin/templates/state.md +11 -0
  83. package/files/merlin/templates/verification-report.md +11 -0
  84. package/files/merlin/workflows/execute-phase.md +11 -0
  85. package/files/merlin/workflows/plan-phase.md +11 -0
  86. package/files/merlin/workflows/progress.md +11 -0
  87. package/files/merlin/workflows/resume-project.md +11 -0
  88. package/files/merlin/workflows/verify-phase.md +11 -0
  89. package/files/merlin/workflows/verify-work.md +11 -0
  90. package/files/merlin-system-prompt.txt +35 -1
  91. package/files/rules/codex-routing.md +19 -0
  92. package/files/rules/duo-routing.md +109 -10
  93. package/files/rules/merlin-routing.md +40 -0
  94. package/files/scripts/codex-as.sh +5 -2
  95. package/files/scripts/design-intent-detect.sh +8 -0
  96. package/files/scripts/duo-badge.sh +3 -5
  97. package/files/scripts/duo-installed.sh +3 -3
  98. package/files/scripts/duo-mode-read.sh +30 -10
  99. package/files/scripts/duo-mode-write.sh +28 -3
  100. package/files/scripts/duo-pre-route.sh +2 -8
  101. package/files/scripts/install-design-skills.sh +86 -0
  102. package/files/scripts/merlin-codex.sh +84 -0
  103. package/files/scripts/task-optimize.sh +335 -0
  104. 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
 
@@ -153,6 +168,25 @@ When enabled, the badge swaps to `⟡🔮↔🔮 MERLIN·DUO ›` so you always
153
168
 
154
169
  Full rules: `~/.claude/rules/duo-routing.md`.
155
170
 
171
+ ## Standalone Codex Users
172
+
173
+ If you run Codex directly (without Claude Code), use `merlin-codex` as a drop-in wrapper to get the Merlin orchestrator persona on every invocation:
174
+
175
+ ```bash
176
+ merlin-codex # opens interactive Codex shell with Merlin banner
177
+ merlin-codex exec "add auth login" # exec with Merlin system prompt prepended
178
+ merlin-codex "fix the failing test" # prompt mode with Merlin prompt prepended
179
+ merlin-codex login # pass-through — no prompt injection
180
+ ```
181
+
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.
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
+
156
190
  ## Documentation
157
191
 
158
192
  Visit [merlin.build/docs](https://merlin.build/docs) for full documentation.
package/bin/install.cjs CHANGED
@@ -1609,6 +1609,19 @@ async function install() {
1609
1609
  quiet: true, // step 2 already printed the detection summary
1610
1610
  });
1611
1611
 
1612
+ // Step 13.5: Install priority design skills (async, non-blocking)
1613
+ if (!process.env.MERLIN_SKIP_DESIGN_SKILLS) {
1614
+ try {
1615
+ const { spawn } = require('child_process');
1616
+ const designSkillsScript = path.join(SCRIPTS_DIR, 'install-design-skills.sh');
1617
+ if (fs.existsSync(designSkillsScript)) {
1618
+ spawn('bash', [designSkillsScript], { stdio: 'inherit', detached: false });
1619
+ }
1620
+ } catch (err) {
1621
+ // Non-fatal: design skills install failure does not block the main installer
1622
+ }
1623
+ }
1624
+
1612
1625
  // Shell integration (runs after runtime adapters)
1613
1626
  log(`\n${colors.cyan}[shell]${colors.reset} Setting up shell integration...`);
1614
1627
  const shellConfigured = setupShellIntegration();
@@ -1641,6 +1654,13 @@ ${colors.cyan}Autonomous Mode (Merlin Loop):${colors.reset}
1641
1654
  ${colors.bright}merlin-loop build${colors.reset} - Execute tasks autonomously
1642
1655
  ${colors.bright}merlin-loop --afk auto${colors.reset} - Run unattended with safety limits
1643
1656
 
1657
+ ${colors.cyan}Universal Task Optimization (NEW in 5.3.0):${colors.reset}
1658
+ • Every task gets the right skill + agent automatically
1659
+ • ${colors.bright}/merlin:optimize "<task>"${colors.reset} - Preview the recommendation
1660
+ • ${colors.bright}/merlin:design-audit${colors.reset} - Design review with impeccable + emil
1661
+ • ${colors.bright}/merlin:polish${colors.reset} - Animation polish via animation-expert
1662
+ • ${colors.bright}/merlin:redesign${colors.reset} - Full redesign via ui-builder
1663
+
1644
1664
  ${colors.cyan}Merlin works with or without Sights:${colors.reset}
1645
1665
  • ${colors.green}With Sights${colors.reset}: Instant context, cross-session memory
1646
1666
  • ${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 */