create-merlin-brain 3.22.0 → 3.23.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 (76) hide show
  1. package/README.md +22 -4
  2. package/bin/merlin-ask.cjs +111 -0
  3. package/bin/merlin-cli.cjs +22 -0
  4. package/bin/runtime-adapters.cjs +678 -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 +45 -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/hud.d.ts +13 -0
  25. package/dist/server/tools/hud.d.ts.map +1 -0
  26. package/dist/server/tools/hud.js +295 -0
  27. package/dist/server/tools/hud.js.map +1 -0
  28. package/dist/server/tools/index.d.ts +4 -0
  29. package/dist/server/tools/index.d.ts.map +1 -1
  30. package/dist/server/tools/index.js +4 -0
  31. package/dist/server/tools/index.js.map +1 -1
  32. package/dist/server/tools/provider-ask.d.ts +10 -0
  33. package/dist/server/tools/provider-ask.d.ts.map +1 -0
  34. package/dist/server/tools/provider-ask.js +234 -0
  35. package/dist/server/tools/provider-ask.js.map +1 -0
  36. package/dist/server/tools/rate-limit.d.ts +8 -0
  37. package/dist/server/tools/rate-limit.d.ts.map +1 -0
  38. package/dist/server/tools/rate-limit.js +184 -0
  39. package/dist/server/tools/rate-limit.js.map +1 -0
  40. package/dist/server/tools/skills.d.ts +16 -0
  41. package/dist/server/tools/skills.d.ts.map +1 -0
  42. package/dist/server/tools/skills.js +326 -0
  43. package/dist/server/tools/skills.js.map +1 -0
  44. package/dist/server/tools/team-workers.d.ts +7 -0
  45. package/dist/server/tools/team-workers.d.ts.map +1 -0
  46. package/dist/server/tools/team-workers.js +271 -0
  47. package/dist/server/tools/team-workers.js.map +1 -0
  48. package/dist/server/utils/merlin-manifest.d.ts +6 -1
  49. package/dist/server/utils/merlin-manifest.d.ts.map +1 -1
  50. package/dist/server/utils/merlin-manifest.js +34 -1
  51. package/dist/server/utils/merlin-manifest.js.map +1 -1
  52. package/files/CLAUDE.md +22 -0
  53. package/files/hooks/rate-limit-watch.sh +120 -0
  54. package/files/hooks/statusline.sh +148 -0
  55. package/files/merlin/skills/SKILLS-INDEX.md +82 -0
  56. package/files/merlin/skills/automation/payments.md +14 -0
  57. package/files/merlin/skills/automation/webhooks.md +14 -0
  58. package/files/merlin/skills/coding/accessibility.md +14 -0
  59. package/files/merlin/skills/coding/api-design.md +14 -0
  60. package/files/merlin/skills/coding/debug-mode.md +14 -0
  61. package/files/merlin/skills/coding/focus-mode.md +14 -0
  62. package/files/merlin/skills/coding/loop.md +14 -0
  63. package/files/merlin/skills/coding/performance.md +14 -0
  64. package/files/merlin/skills/coding/react-patterns.md +51 -0
  65. package/files/merlin/skills/coding/security-hardening.md +56 -0
  66. package/files/merlin/skills/coding/verify.md +14 -0
  67. package/files/merlin/skills/communication/dispatcher.md +40 -0
  68. package/files/merlin/skills/communication/email-gmail.md +31 -0
  69. package/files/merlin/skills/communication/telegram.md +50 -0
  70. package/files/merlin/skills/communication/whatsapp.md +47 -0
  71. package/files/merlin/skills/data/google-sheets.md +14 -0
  72. package/files/merlin/skills/design/animation.md +14 -0
  73. package/files/merlin/skills/devops/docker-containers.md +14 -0
  74. package/files/merlin/skills/research/brainstorm.md +14 -0
  75. package/files/merlin/skills/testing/tdd-workflow.md +58 -0
  76. package/package.json +4 -2
@@ -0,0 +1,51 @@
1
+ ---
2
+ id: react-patterns
3
+ name: React Patterns
4
+ domain: coding
5
+ category: frontend
6
+ tags: [react, nextjs, remix, vite, hooks, components, server-components]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+
14
+ # React Patterns
15
+
16
+ You are an expert in modern React patterns. Apply these when building or reviewing React code.
17
+
18
+ ## Component Architecture
19
+ - Prefer function components with hooks over class components
20
+ - Co-locate related code: component + hook + types + styles in the same directory
21
+ - Extract custom hooks when logic is reused across 2+ components
22
+ - Use `React.memo()` only when profiling shows re-render cost (not preemptively)
23
+
24
+ ## Hooks
25
+ - `useState` for simple local state; `useReducer` when state transitions are complex
26
+ - `useCallback` and `useMemo` only when passing to memoized children or expensive computations
27
+ - Custom hooks should start with `use` and return a typed object (not a tuple for >2 values)
28
+ - `useEffect` cleanup: always return cleanup functions for subscriptions, timers, event listeners
29
+
30
+ ## Server Components (Next.js 13+)
31
+ - Default to Server Components — only add `'use client'` when you need interactivity, hooks, or browser APIs
32
+ - Data fetching belongs in Server Components (no useEffect for initial data)
33
+ - Pass serializable props from Server → Client components (no functions, no classes)
34
+
35
+ ## Performance
36
+ - Lazy load heavy components: `const Heavy = dynamic(() => import('./Heavy'), { ssr: false })`
37
+ - Use `Suspense` boundaries around async components
38
+ - Virtualize long lists (react-window, @tanstack/virtual)
39
+ - Image optimization: next/image with explicit width/height, priority for above-fold
40
+
41
+ ## Error Handling
42
+ - Wrap route segments with Error Boundaries
43
+ - Use `error.tsx` convention in Next.js App Router
44
+ - Show meaningful fallback UI, not blank screens
45
+ - Log errors to a service (Sentry, LogRocket) in production
46
+
47
+ ## State Management
48
+ - Local state first (useState/useReducer) — don't reach for global state prematurely
49
+ - URL state for shareable UI state (search params, filters)
50
+ - Server state via TanStack Query or SWR (not Redux for API data)
51
+ - Global client state only for truly app-wide concerns (auth, theme, locale)
@@ -0,0 +1,56 @@
1
+ ---
2
+ id: security-hardening
3
+ name: Security Hardening
4
+ domain: coding
5
+ category: security
6
+ tags: [security, owasp, auth, validation, xss, csrf, injection]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+
14
+ # Security Hardening
15
+
16
+ Apply security best practices to every piece of code you write or review.
17
+
18
+ ## Input Validation
19
+ - Validate ALL user input at the boundary (API route handler, form submission)
20
+ - Use Zod, Joi, or equivalent schema validation — never trust `typeof` alone
21
+ - Whitelist allowed values rather than blacklisting dangerous ones
22
+ - Validate types, lengths, ranges, formats before processing
23
+
24
+ ## Injection Prevention
25
+ - SQL: Use parameterized queries / prepared statements. NEVER string-concatenate user input into SQL
26
+ - NoSQL: Validate query operators. Reject `$gt`, `$regex` etc. from user input
27
+ - Command injection: Use `execFile` (not `exec`). Never pass user input to shell commands
28
+ - Template injection: Sanitize before rendering in templates
29
+
30
+ ## Authentication
31
+ - Hash passwords with bcrypt/argon2 (cost factor >= 12)
32
+ - Use constant-time comparison for secrets (`crypto.timingSafeEqual`)
33
+ - JWTs: short expiry (15min access, 7d refresh), validate `iss`, `aud`, `exp`
34
+ - Session IDs: cryptographically random, >= 128 bits entropy
35
+
36
+ ## Authorization
37
+ - Check permissions on EVERY protected endpoint (not just the frontend)
38
+ - Verify resource ownership: `WHERE user_id = $authenticatedUser AND id = $resourceId`
39
+ - Use middleware for role checks, not inline if-statements
40
+ - Principle of least privilege: default deny, explicitly grant
41
+
42
+ ## XSS Prevention
43
+ - React/Vue auto-escape by default — but `dangerouslySetInnerHTML` / `v-html` bypasses it
44
+ - Sanitize HTML with DOMPurify before rendering user content
45
+ - Set `Content-Security-Policy` headers (no inline scripts)
46
+ - HttpOnly + Secure + SameSite cookies for session tokens
47
+
48
+ ## CSRF Protection
49
+ - SameSite=Lax cookies (minimum) or SameSite=Strict
50
+ - CSRF tokens for state-changing operations if using cookies
51
+ - Verify `Origin` / `Referer` headers on sensitive endpoints
52
+
53
+ ## Error Handling
54
+ - Never expose stack traces, SQL errors, or internal paths to the client
55
+ - Use generic error messages: "Something went wrong" (log the real error server-side)
56
+ - Return consistent error shapes: `{ error: string, code: string }`
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: verify
3
+ name: Verify Results
4
+ domain: coding
5
+ category: execution
6
+ tags: [verify, validation, qa, check]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+ # Verify Results
14
+ After completing the task, verify the result. Run the code, check the output, and confirm it meets the requirements. Report any issues found. Never claim "done" without actually testing.
@@ -0,0 +1,40 @@
1
+ ---
2
+ id: dispatcher
3
+ name: Communications Dispatcher
4
+ domain: non-coding
5
+ category: communication
6
+ tags: [dispatcher, hub, routing, whatsapp, telegram, email, always-on]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+
14
+ # Communications Dispatcher
15
+
16
+ You are the central communications hub. You receive messages from multiple channels (WhatsApp, Telegram, email) and either respond directly or dispatch tasks to specialist agents.
17
+
18
+ ## Your Role
19
+ - You are ALWAYS listening. You run on a heartbeat — checking channels continuously.
20
+ - When a message arrives, you decide: can you handle it, or does it need a specialist?
21
+ - You respond in the same channel the message came from.
22
+ - You maintain context across channels — if someone emails you, then WhatsApps about the same topic, you connect the dots.
23
+
24
+ ## Channels
25
+ - **WhatsApp**: Two-way messaging via OpenClaw. You receive and send messages.
26
+ - **Telegram**: Bot integration. Respond to commands and conversations.
27
+ - **Email**: Read from connected Gmail mailboxes. Draft and send replies.
28
+
29
+ ## Dispatch Rules
30
+ - Simple questions, scheduling, reminders → handle yourself
31
+ - Code tasks → dispatch to implementation-dev or bug-doctor
32
+ - Content/writing → dispatch to docs-keeper
33
+ - Research → dispatch to researcher
34
+ - Security concerns → dispatch to hardening-guard
35
+
36
+ ## Response Style
37
+ - Be concise in WhatsApp/Telegram (people expect short messages)
38
+ - Be more detailed in email (people expect structured responses)
39
+ - Always confirm when dispatching: "I'm sending this to [Agent] — I'll update you when it's done"
40
+ - Proactively update the user on dispatched task progress
@@ -0,0 +1,31 @@
1
+ ---
2
+ id: email-gmail
3
+ name: Gmail Integration
4
+ domain: non-coding
5
+ category: communication
6
+ tags: [email, gmail, mailbox, inbox, send, read, draft]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+
14
+ # Gmail Integration
15
+
16
+ You can read from and send emails through connected Gmail mailboxes.
17
+
18
+ ## Capabilities
19
+ - Read new emails from connected inboxes
20
+ - Search emails by sender, subject, date, or content
21
+ - Draft and send replies
22
+ - Create new emails with rich formatting
23
+ - Manage labels and organize inbox
24
+ - Handle multiple mailboxes (personal + work)
25
+
26
+ ## Rules
27
+ - Never auto-send without user confirmation (draft first, send on approval)
28
+ - Summarize long email threads before responding
29
+ - Detect urgency: flag emails that need immediate attention
30
+ - Respect "do not reply" and unsubscribe patterns
31
+ - Keep sent email tone professional unless user specifies otherwise
@@ -0,0 +1,50 @@
1
+ ---
2
+ id: telegram
3
+ name: Telegram Direct
4
+ domain: non-coding
5
+ category: communication
6
+ tags: [telegram, bot, direct, bot-api, two-way]
7
+ version: 2
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution:
12
+ - "v2: Direct Telegram Bot API — no external dependencies"
13
+ ---
14
+
15
+ # Telegram Direct Integration
16
+
17
+ Send and receive Telegram messages directly via the Bot API. No middleware — direct HTTP calls.
18
+
19
+ ## Receiving Messages
20
+ Telegram sends updates to our webhook. Each update has: chat_id, sender info, message text, message_id, date.
21
+
22
+ ## Sending Messages
23
+ ```
24
+ POST https://api.telegram.org/bot{BOT_TOKEN}/sendMessage
25
+ Content-Type: application/json
26
+
27
+ {
28
+ "chat_id": 123456789,
29
+ "text": "Your message here",
30
+ "parse_mode": "Markdown"
31
+ }
32
+ ```
33
+
34
+ ## Key API Methods
35
+ - `sendMessage` — send text (supports Markdown and HTML)
36
+ - `sendPhoto` / `sendDocument` — send media files
37
+ - `editMessageText` — update a sent message (good for progress updates)
38
+ - `deleteMessage` — remove a message
39
+ - `sendChatAction` — show "typing..." indicator
40
+ - `getUpdates` — poll for messages (fallback if webhook fails)
41
+
42
+ ## Setup
43
+ - Create a bot via @BotFather on Telegram → get BOT_TOKEN
44
+ - Set webhook: `POST https://api.telegram.org/bot{TOKEN}/setWebhook?url=https://merlin.build/api/hooks/telegram/{userId}`
45
+
46
+ ## Response Rules
47
+ - Markdown formatting supported (bold, italic, code blocks)
48
+ - Messages can be longer than WhatsApp — up to 4096 chars
49
+ - Use "typing..." action before long responses: `sendChatAction({ chat_id, action: "typing" })`
50
+ - Reply to specific messages with `reply_to_message_id`
@@ -0,0 +1,47 @@
1
+ ---
2
+ id: whatsapp
3
+ name: WhatsApp Direct
4
+ domain: non-coding
5
+ category: communication
6
+ tags: [whatsapp, messaging, business-api, direct, two-way]
7
+ version: 2
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution:
12
+ - "v2: Direct WhatsApp Business API — no external dependencies"
13
+ ---
14
+
15
+ # WhatsApp Direct Integration
16
+
17
+ Send and receive WhatsApp messages directly via the WhatsApp Business API. No middleware, no OpenClaw — direct API calls.
18
+
19
+ ## Receiving Messages
20
+ Messages arrive via webhook → Merlin API → your Claude session. Each message has: sender phone, text, timestamp, message type (text/image/document).
21
+
22
+ ## Sending Messages
23
+ ```
24
+ POST https://graph.facebook.com/v21.0/{PHONE_NUMBER_ID}/messages
25
+ Authorization: Bearer {WHATSAPP_ACCESS_TOKEN}
26
+ Content-Type: application/json
27
+
28
+ {
29
+ "messaging_product": "whatsapp",
30
+ "to": "1234567890",
31
+ "type": "text",
32
+ "text": { "body": "Your message here" }
33
+ }
34
+ ```
35
+
36
+ ## Message Types
37
+ - Text: simple messages
38
+ - Template: pre-approved messages (required for initiating conversations)
39
+ - Media: images, documents, audio (send URL or upload)
40
+ - Interactive: buttons, lists (for structured choices)
41
+
42
+ ## Response Rules
43
+ - Keep under 300 chars — mobile reading
44
+ - Use line breaks, not bullets
45
+ - Respond within seconds
46
+ - Break long content into 2-3 sequential messages
47
+ - Mark messages as read: POST `/{PHONE_NUMBER_ID}/messages` with `{ status: "read", message_id: "..." }`
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: google-sheets
3
+ name: Google Sheets
4
+ domain: non-coding
5
+ category: data
6
+ tags: [sheets, google, spreadsheet, data]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+ # Google Sheets
14
+ Read from and write to Google Sheets. Pull data for analysis, update cells, create new sheets, and use Sheets as a simple database. Support for batch operations (batchUpdate for multiple writes) and formula generation. Use the Google Sheets API v4 with service account credentials for server-side access.
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: animation
3
+ name: Motion Design
4
+ domain: coding
5
+ category: design
6
+ tags: [animation, framer-motion, gsap, motion, transitions]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+ # Motion Design
14
+ Create smooth, performant animations. Use Framer Motion for React component enter/exit/layout animations. Use CSS transitions for simple hover/focus states (cheaper than JS). Use GSAP for complex timelines and scroll-triggered animations. Always target 60fps — prefer `transform` and `opacity` (GPU-composited) over `width`, `height`, `top`, `left` (trigger layout). Use `will-change` sparingly. Respect `prefers-reduced-motion` media query.
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: docker-containers
3
+ name: Docker & Containers
4
+ domain: coding
5
+ category: devops
6
+ tags: [docker, containers, dockerfile, docker-compose, devops]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+ # Docker & Containers
14
+ Use Docker best practices: multi-stage builds (build stage + runtime stage), minimal base images (alpine/distroless), non-root users (USER node), health checks (HEALTHCHECK CMD), proper layer caching (COPY package.json first, then npm install, then COPY source), .dockerignore for node_modules/dist/.git. Docker Compose for multi-service local dev. Pin image versions (node:20-alpine, not node:latest).
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: brainstorm
3
+ name: Brainstorm
4
+ domain: research
5
+ category: ideation
6
+ tags: [brainstorm, ideation, exploration, approaches]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+ # Brainstorm
14
+ Before implementing, brainstorm 3-5 different approaches. Present them to the user with pros/cons for each. Wait for selection before proceeding. Consider: simplicity, maintainability, performance, time-to-implement, and alignment with existing architecture.
@@ -0,0 +1,58 @@
1
+ ---
2
+ id: tdd-workflow
3
+ name: Test-Driven Development
4
+ domain: coding
5
+ category: testing
6
+ tags: [tdd, testing, jest, vitest, pytest, red-green-refactor]
7
+ version: 1
8
+ source: builtin
9
+ successRate: 0
10
+ usageCount: 0
11
+ evolution: []
12
+ ---
13
+
14
+ # Test-Driven Development
15
+
16
+ Follow the RED-GREEN-REFACTOR cycle for every feature.
17
+
18
+ ## The Cycle
19
+ 1. **RED** — Write a failing test that describes the desired behavior
20
+ 2. **GREEN** — Write the minimum code to make the test pass
21
+ 3. **REFACTOR** — Clean up without changing behavior, tests still pass
22
+
23
+ ## Rules
24
+ - Never write production code without a failing test first
25
+ - Each test should test ONE behavior (not one function — one behavior)
26
+ - Test names describe the behavior: `should return 404 when user not found`
27
+ - Run tests after every change — the cycle takes minutes, not hours
28
+
29
+ ## What to Test
30
+ - Happy path (expected input → expected output)
31
+ - Edge cases (empty input, null, boundary values, max length)
32
+ - Error cases (invalid input, network failure, permission denied)
33
+ - Integration points (API contracts, database queries, external services)
34
+
35
+ ## What NOT to Test
36
+ - Implementation details (private methods, internal state)
37
+ - Framework code (React rendering, Express routing)
38
+ - Third-party libraries (they have their own tests)
39
+ - Trivial code (getters, setters, simple pass-through)
40
+
41
+ ## Test Structure
42
+ ```
43
+ describe('[Unit Under Test]', () => {
44
+ describe('[Scenario]', () => {
45
+ it('should [expected behavior] when [condition]', () => {
46
+ // Arrange — set up test data and dependencies
47
+ // Act — call the function / trigger the behavior
48
+ // Assert — verify the result
49
+ });
50
+ });
51
+ });
52
+ ```
53
+
54
+ ## Mocking
55
+ - Mock at boundaries: external APIs, databases, file system, time
56
+ - Don't mock the thing you're testing
57
+ - Prefer dependency injection over module mocking
58
+ - Reset mocks between tests (`afterEach(() => jest.restoreAllMocks())`)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-merlin-brain",
3
- "version": "3.22.0",
4
- "description": "Merlin - The Ultimate AI Brain for Claude Code. One install: workflows, agents, loop, and Sights MCP server.",
3
+ "version": "3.23.0",
4
+ "description": "Merlin - The Ultimate AI Brain for Claude Code, Codex, and other AI CLIs. One install: workflows, agents, loop, and Sights MCP server.",
5
5
  "type": "module",
6
6
  "main": "./dist/server/index.js",
7
7
  "bin": {
@@ -23,6 +23,8 @@
23
23
  "keywords": [
24
24
  "claude",
25
25
  "claude-code",
26
+ "codex",
27
+ "codex-cli",
26
28
  "merlin",
27
29
  "mcp",
28
30
  "model-context-protocol",