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
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Auto Mode Tool
3
+ * Configures Claude Code's auto mode by writing to ~/.claude/settings.json.
4
+ * Triggered by "merlin loop yolo" or "auto mode" intent.
5
+ */
6
+ import { z } from 'zod';
7
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
+ import { homedir } from 'os';
9
+ import { join, dirname } from 'path';
10
+ import { coachWrap } from '../session-coach.js';
11
+ const SETTINGS_PATH = join(homedir(), '.claude', 'settings.json');
12
+ // Permissions preset: full yolo — all reads/writes plus Merlin MCP tools
13
+ const YOLO_ALLOW = [
14
+ 'Read(*)',
15
+ 'Edit(*)',
16
+ 'Write(*)',
17
+ 'Glob(*)',
18
+ 'Grep(*)',
19
+ 'Bash(npm run *)',
20
+ 'Bash(npx *)',
21
+ 'Bash(git add *)',
22
+ 'Bash(git commit *)',
23
+ 'Bash(git status)',
24
+ 'Bash(git diff *)',
25
+ 'Bash(git log *)',
26
+ 'Bash(tsc *)',
27
+ 'Bash(node *)',
28
+ 'Bash(ls *)',
29
+ 'Bash(cat *)',
30
+ 'Bash(mkdir *)',
31
+ 'Bash(which *)',
32
+ 'mcp__merlin__*',
33
+ ];
34
+ const SHARED_DENY = [
35
+ 'Bash(rm -rf *)',
36
+ 'Bash(git push --force *)',
37
+ 'Bash(git reset --hard *)',
38
+ 'Bash(curl * | bash)',
39
+ 'Bash(pkill *)',
40
+ 'Bash(kill *)',
41
+ 'Bash(killall *)',
42
+ 'Bash(sudo *)',
43
+ ];
44
+ // Permissions preset: safe — read-only file access + MCP tools only
45
+ const SAFE_ALLOW = [
46
+ 'Read(*)',
47
+ 'Glob(*)',
48
+ 'Grep(*)',
49
+ 'Bash(git status)',
50
+ 'Bash(git log *)',
51
+ 'Bash(git diff *)',
52
+ 'Bash(ls *)',
53
+ 'Bash(which *)',
54
+ 'mcp__merlin__*',
55
+ ];
56
+ function readSettings() {
57
+ try {
58
+ if (!existsSync(SETTINGS_PATH))
59
+ return {};
60
+ const raw = readFileSync(SETTINGS_PATH, 'utf-8');
61
+ return JSON.parse(raw);
62
+ }
63
+ catch {
64
+ return {};
65
+ }
66
+ }
67
+ function writeSettings(settings) {
68
+ const dir = dirname(SETTINGS_PATH);
69
+ if (!existsSync(dir)) {
70
+ mkdirSync(dir, { recursive: true });
71
+ }
72
+ writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2), 'utf-8');
73
+ }
74
+ function buildPermissions(level) {
75
+ if (level === 'yolo') {
76
+ return {
77
+ mode: 'auto',
78
+ allow: YOLO_ALLOW,
79
+ deny: SHARED_DENY,
80
+ };
81
+ }
82
+ // safe (default)
83
+ return {
84
+ mode: 'auto',
85
+ allow: SAFE_ALLOW,
86
+ deny: SHARED_DENY,
87
+ };
88
+ }
89
+ function describeLevelRules(level) {
90
+ if (level === 'yolo') {
91
+ return `**Level: yolo** — Claude can read, edit, write files and run common dev commands without prompts.
92
+ Allowed: Read/Edit/Write files, Glob, Grep, npm/npx, git (non-destructive), tsc, node, ls, mcp__merlin__*
93
+ Blocked: rm -rf, git push --force, git reset --hard, curl|bash, kill/pkill/sudo`;
94
+ }
95
+ return `**Level: safe** — Read-only file access plus Merlin MCP tools only.
96
+ Allowed: Read files, Glob, Grep, git status/log/diff, ls, mcp__merlin__*
97
+ Blocked: All writes, most Bash, rm -rf, force operations, sudo`;
98
+ }
99
+ /** Register auto mode tool */
100
+ export function registerAutoModeTools(ctx) {
101
+ const { server } = ctx;
102
+ // ── DEFERRED tool: loaded on-demand for auto mode configuration ────────────
103
+ // Tool: merlin_auto_mode
104
+ server.tool('merlin_auto_mode', 'Configure Claude Code auto mode via ~/.claude/settings.json. Say "merlin loop yolo" to enable yolo mode (all dev tasks run without prompts) or "auto mode safe" for read-only. Use action="status" to check current state. action="disable" removes auto mode and resets permissions to default.', {
105
+ action: z.enum(['enable', 'disable', 'status']).describe('What to do: enable sets auto mode, disable removes it, status reports current state'),
106
+ level: z.enum(['safe', 'yolo', 'custom']).optional().describe('Preset: "yolo" allows all dev operations without prompts, "safe" (default) is read-only + MCP tools'),
107
+ }, async ({ action, level = 'safe' }) => {
108
+ try {
109
+ // ── STATUS ───────────────────────────────────────────────────────────
110
+ if (action === 'status') {
111
+ const settings = readSettings();
112
+ const permissions = settings.permissions;
113
+ if (!permissions || permissions.mode !== 'auto') {
114
+ return {
115
+ content: [{
116
+ type: 'text',
117
+ text: coachWrap('merlin_auto_mode', `
118
+ **Auto mode: disabled**
119
+
120
+ Claude Code is running in standard (prompted) mode.
121
+ Run \`merlin_auto_mode\` with action="enable" to configure auto mode.
122
+
123
+ - \`level="safe"\` — read-only + Merlin MCP tools
124
+ - \`level="yolo"\` — full dev workflow, no prompts (say "merlin loop yolo")
125
+ `),
126
+ }],
127
+ };
128
+ }
129
+ const allowList = permissions.allow ?? [];
130
+ const denyList = permissions.deny ?? [];
131
+ const detectedLevel = allowList.includes('Write(*)') ? 'yolo' : 'safe';
132
+ return {
133
+ content: [{
134
+ type: 'text',
135
+ text: coachWrap('merlin_auto_mode', `
136
+ **Auto mode: ENABLED** (level: ${detectedLevel})
137
+
138
+ Permissions in ~/.claude/settings.json:
139
+ - Allow rules: ${allowList.length}
140
+ - Deny rules: ${denyList.length}
141
+
142
+ ${describeLevelRules(detectedLevel)}
143
+
144
+ Run action="disable" to turn off auto mode.
145
+ `),
146
+ }],
147
+ };
148
+ }
149
+ // ── DISABLE ──────────────────────────────────────────────────────────
150
+ if (action === 'disable') {
151
+ const settings = readSettings();
152
+ const wasEnabled = settings.permissions?.mode === 'auto';
153
+ if (settings.permissions) {
154
+ // Remove mode and auto mode allow/deny but preserve any other permission keys
155
+ const { mode: _mode, allow: _allow, deny: _deny, ...rest } = settings.permissions;
156
+ if (Object.keys(rest).length === 0) {
157
+ delete settings.permissions;
158
+ }
159
+ else {
160
+ settings.permissions = rest;
161
+ }
162
+ }
163
+ writeSettings(settings);
164
+ return {
165
+ content: [{
166
+ type: 'text',
167
+ text: coachWrap('merlin_auto_mode', wasEnabled
168
+ ? `
169
+ **Auto mode disabled**
170
+
171
+ Removed auto mode permissions from ~/.claude/settings.json.
172
+ Claude Code will now prompt for approval on each action.
173
+ `
174
+ : `
175
+ **Auto mode was already off**
176
+
177
+ No changes made to ~/.claude/settings.json.
178
+ `),
179
+ }],
180
+ };
181
+ }
182
+ // ── ENABLE ───────────────────────────────────────────────────────────
183
+ if (level === 'custom') {
184
+ return {
185
+ content: [{
186
+ type: 'text',
187
+ text: coachWrap('merlin_auto_mode', `
188
+ **Custom level not yet supported via this tool**
189
+
190
+ Edit ~/.claude/settings.json directly to define custom allow/deny rules.
191
+ Or use level="safe" or level="yolo" for Merlin-optimized presets.
192
+ `),
193
+ }],
194
+ };
195
+ }
196
+ const settings = readSettings();
197
+ settings.permissions = {
198
+ ...settings.permissions,
199
+ ...buildPermissions(level),
200
+ };
201
+ writeSettings(settings);
202
+ return {
203
+ content: [{
204
+ type: 'text',
205
+ text: coachWrap('merlin_auto_mode', `
206
+ **Auto mode ENABLED** (level: ${level})
207
+
208
+ Written to ~/.claude/settings.json
209
+
210
+ ${describeLevelRules(level)}
211
+
212
+ Claude Code will now run autonomously within these boundaries.
213
+ ${level === 'yolo' ? '\nYou said "merlin loop yolo" — unleashed.' : '\nRunning in safe mode. Say "merlin loop yolo" to go full yolo.'}
214
+
215
+ Run action="status" to verify. Run action="disable" to reset.
216
+ `),
217
+ }],
218
+ };
219
+ }
220
+ catch (error) {
221
+ return {
222
+ content: [{
223
+ type: 'text',
224
+ text: `**Error configuring auto mode:** ${error instanceof Error ? error.message : 'Unknown error'}`,
225
+ }],
226
+ isError: true,
227
+ };
228
+ }
229
+ });
230
+ }
231
+ //# sourceMappingURL=auto-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-mode.js","sourceRoot":"","sources":["../../../src/server/tools/auto-mode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAElE,yEAAyE;AACzE,MAAM,UAAU,GAAG;IACjB,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;IACT,iBAAiB;IACjB,aAAa;IACb,iBAAiB;IACjB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,YAAY;IACZ,aAAa;IACb,eAAe;IACf,eAAe;IACf,gBAAgB;CACjB,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,gBAAgB;IAChB,0BAA0B;IAC1B,0BAA0B;IAC1B,qBAAqB;IACrB,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,cAAc;CACf,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,GAAG;IACjB,SAAS;IACT,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,gBAAgB;CACjB,CAAC;AAcF,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1C,MAAM,GAAG,GAA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AC,CAAC;YAExB,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,SAAS,CAAC,kBAAkB,EAAE;gCAChB,KAAK;;;;EAInC,kBAAkB,CAAC,KAAsB,CAAC;;;EAG1C,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,iEAAiE;;;CAGpI,CAAC;qBACS,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;qBACrG,CAAC;gBACF,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Computer Use Tools
3
+ * Enable and orchestrate Claude Code's desktop control capabilities on macOS.
4
+ */
5
+ import type { ToolContext } from './types.js';
6
+ /** Register computer use tools */
7
+ export declare function registerComputerUseTools(ctx: ToolContext): void;
8
+ //# sourceMappingURL=computer-use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computer-use.d.ts","sourceRoot":"","sources":["../../../src/server/tools/computer-use.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2D9C,kCAAkC;AAClC,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAmU/D"}
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Computer Use Tools
3
+ * Enable and orchestrate Claude Code's desktop control capabilities on macOS.
4
+ */
5
+ import { z } from 'zod';
6
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
7
+ import { homedir, platform } from 'os';
8
+ import { join, dirname } from 'path';
9
+ import { spawn } from 'child_process';
10
+ import { coachWrap } from '../session-coach.js';
11
+ const SETTINGS_PATH = join(homedir(), '.claude', 'settings.json');
12
+ /** Safe character set for app names — only allow letters, digits, spaces, dots, underscores, hyphens */
13
+ const SAFE_APP_NAME_RE = /^[a-zA-Z0-9 ._-]+$/;
14
+ /** Validate an app name is injection-safe */
15
+ function isSafeAppName(name) {
16
+ return SAFE_APP_NAME_RE.test(name) && name.length > 0 && name.length <= 64;
17
+ }
18
+ /** Read settings.json, returning parsed object or empty object on failure */
19
+ function readSettings() {
20
+ try {
21
+ if (!existsSync(SETTINGS_PATH))
22
+ return {};
23
+ return JSON.parse(readFileSync(SETTINGS_PATH, 'utf-8'));
24
+ }
25
+ catch {
26
+ return {};
27
+ }
28
+ }
29
+ /** Write settings.json, creating parent directory if needed */
30
+ function writeSettings(settings) {
31
+ try {
32
+ const dir = dirname(SETTINGS_PATH);
33
+ if (!existsSync(dir))
34
+ mkdirSync(dir, { recursive: true });
35
+ writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2), 'utf-8');
36
+ return true;
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /** Run a command with spawn (injection-safe). Returns stdout string or throws. */
43
+ function runCommand(cmd, args) {
44
+ return new Promise((resolve, reject) => {
45
+ const proc = spawn(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'] });
46
+ let out = '';
47
+ let err = '';
48
+ proc.stdout.on('data', (d) => { out += d.toString(); });
49
+ proc.stderr.on('data', (d) => { err += d.toString(); });
50
+ proc.on('close', (code) => {
51
+ if (code === 0)
52
+ resolve(out.trim());
53
+ else
54
+ reject(new Error(err.trim() || `exited with code ${code}`));
55
+ });
56
+ proc.on('error', reject);
57
+ });
58
+ }
59
+ /** Check if the process is running on macOS */
60
+ function assertMacOS() {
61
+ if (platform() !== 'darwin') {
62
+ return 'Computer use is only supported on macOS. Current platform: ' + platform();
63
+ }
64
+ return null;
65
+ }
66
+ /** Register computer use tools */
67
+ export function registerComputerUseTools(ctx) {
68
+ const { server } = ctx;
69
+ // ── Tool: merlin_computer_use ────────────────────────────────────────────
70
+ server.tool('merlin_computer_use', 'Enable, disable, check status of, or launch desktop apps using macOS computer use. Lets Merlin take control of any app on the user\'s desktop. Actions: enable (write permissions to ~/.claude/settings.json), disable (turn off), status (report current config and accessibility), launch (open a specific app and optionally give it a task). macOS only.', {
71
+ action: z.enum(['enable', 'disable', 'status', 'launch']).describe('What to do: enable computer use, disable it, check status, or launch an app'),
72
+ app: z.string().optional().describe('App name to launch or control, e.g. "Safari", "Xcode", "Figma". Required for launch.'),
73
+ task: z.string().optional().describe('What to do with the app after launching, e.g. "open google.com". Optional.'),
74
+ }, async ({ action, app, task }) => {
75
+ const platformErr = assertMacOS();
76
+ if (platformErr) {
77
+ return {
78
+ content: [{ type: 'text', text: coachWrap('merlin_computer_use', `ERROR: ${platformErr}`) }],
79
+ isError: true,
80
+ };
81
+ }
82
+ try {
83
+ // ── enable ──────────────────────────────────────────────────────────
84
+ if (action === 'enable') {
85
+ const settings = readSettings();
86
+ settings['computerUse'] = {
87
+ enabled: true,
88
+ allowedApps: ['*'],
89
+ requireConfirmation: true,
90
+ screenshotInterval: 2000,
91
+ safetyChecks: true,
92
+ };
93
+ // If autoMode already configured, add computer use to its allow list
94
+ const autoMode = settings['autoMode'];
95
+ if (autoMode && Array.isArray(autoMode['allow'])) {
96
+ const allow = autoMode['allow'];
97
+ if (!allow.includes('computer_use')) {
98
+ allow.push('computer_use');
99
+ }
100
+ }
101
+ const ok = writeSettings(settings);
102
+ if (!ok) {
103
+ return {
104
+ content: [{ type: 'text', text: coachWrap('merlin_computer_use', 'ERROR: Failed to write ~/.claude/settings.json') }],
105
+ isError: true,
106
+ };
107
+ }
108
+ return {
109
+ content: [{
110
+ type: 'text',
111
+ text: coachWrap('merlin_computer_use', [
112
+ 'COMPUTER USE ENABLED',
113
+ `Settings: ${SETTINGS_PATH}`,
114
+ 'Config: enabled=true, allowedApps=*, requireConfirmation=true, screenshotInterval=2000ms, safetyChecks=true',
115
+ 'NOTE: Grant Accessibility in System Settings > Privacy & Security > Accessibility if needed.',
116
+ 'Use merlin_computer_use(action: "launch", app: "AppName") to open an app.',
117
+ ].join('\n')),
118
+ }],
119
+ };
120
+ }
121
+ // ── disable ─────────────────────────────────────────────────────────
122
+ if (action === 'disable') {
123
+ const settings = readSettings();
124
+ const cu = settings['computerUse'];
125
+ if (cu) {
126
+ cu['enabled'] = false;
127
+ }
128
+ else {
129
+ settings['computerUse'] = { enabled: false };
130
+ }
131
+ const ok = writeSettings(settings);
132
+ if (!ok) {
133
+ return {
134
+ content: [{ type: 'text', text: coachWrap('merlin_computer_use', 'ERROR: Failed to write ~/.claude/settings.json') }],
135
+ isError: true,
136
+ };
137
+ }
138
+ return {
139
+ content: [{
140
+ type: 'text',
141
+ text: coachWrap('merlin_computer_use', [
142
+ 'COMPUTER USE DISABLED',
143
+ `Settings: ${SETTINGS_PATH}`,
144
+ 'Run merlin_computer_use(action: "enable") to re-enable.',
145
+ ].join('\n')),
146
+ }],
147
+ };
148
+ }
149
+ // ── status ───────────────────────────────────────────────────────────
150
+ if (action === 'status') {
151
+ const settings = readSettings();
152
+ const cu = settings['computerUse'];
153
+ const enabled = cu?.['enabled'] === true;
154
+ const allowedApps = Array.isArray(cu?.['allowedApps'])
155
+ ? cu['allowedApps'].join(', ')
156
+ : 'none';
157
+ const requireConfirmation = cu?.['requireConfirmation'] ?? 'not set';
158
+ const safetyChecks = cu?.['safetyChecks'] ?? 'not set';
159
+ // Check accessibility — runs AppleScript asking System Events for process list
160
+ let accessibilityOk = false;
161
+ let accessibilityNote = '';
162
+ try {
163
+ await runCommand('osascript', [
164
+ '-e',
165
+ 'tell application "System Events" to get name of first process',
166
+ ]);
167
+ accessibilityOk = true;
168
+ }
169
+ catch (e) {
170
+ accessibilityNote = `Accessibility check failed: ${e instanceof Error ? e.message : String(e)}`;
171
+ }
172
+ return {
173
+ content: [{
174
+ type: 'text',
175
+ text: coachWrap('merlin_computer_use', [
176
+ 'COMPUTER USE STATUS',
177
+ `Platform: macOS | Settings: ${existsSync(SETTINGS_PATH) ? SETTINGS_PATH : 'not found'}`,
178
+ `Config: enabled=${enabled}, allowedApps=${allowedApps || 'not configured'}, requireConfirmation=${requireConfirmation}, safetyChecks=${safetyChecks}`,
179
+ `Accessibility: ${accessibilityOk ? 'GRANTED' : `BLOCKED — ${accessibilityNote}`}`,
180
+ ...(accessibilityOk ? [] : ['To grant: System Settings > Privacy & Security > Accessibility']),
181
+ ].join('\n')),
182
+ }],
183
+ };
184
+ }
185
+ // ── launch ───────────────────────────────────────────────────────────
186
+ if (action === 'launch') {
187
+ if (!app) {
188
+ return {
189
+ content: [{ type: 'text', text: coachWrap('merlin_computer_use', 'ERROR: "app" parameter is required for the launch action.') }],
190
+ isError: true,
191
+ };
192
+ }
193
+ if (!isSafeAppName(app)) {
194
+ return {
195
+ content: [{
196
+ type: 'text',
197
+ text: coachWrap('merlin_computer_use', `ERROR: Invalid app name "${app}". App names must only contain letters, digits, spaces, dots, underscores, or hyphens (no quotes, semicolons, backticks, or shell metacharacters).`),
198
+ }],
199
+ isError: true,
200
+ };
201
+ }
202
+ // Check if app is installed
203
+ try {
204
+ await runCommand('osascript', [
205
+ '-e',
206
+ `tell application "Finder" to get application file id of application "${app}"`,
207
+ ]);
208
+ }
209
+ catch {
210
+ return {
211
+ content: [{
212
+ type: 'text',
213
+ text: coachWrap('merlin_computer_use', `ERROR: App "${app}" does not appear to be installed. Verify the name is correct (e.g. "Safari", not "safari").`),
214
+ }],
215
+ isError: true,
216
+ };
217
+ }
218
+ // Activate the app
219
+ try {
220
+ await runCommand('osascript', ['-e', `tell application "${app}" to activate`]);
221
+ }
222
+ catch (e) {
223
+ return {
224
+ content: [{
225
+ type: 'text',
226
+ text: coachWrap('merlin_computer_use', `ERROR: Failed to launch "${app}": ${e instanceof Error ? e.message : String(e)}`),
227
+ }],
228
+ isError: true,
229
+ };
230
+ }
231
+ // Brief pause so the app window can appear
232
+ await new Promise((r) => setTimeout(r, 1500));
233
+ // Take a screenshot
234
+ const screenshotPath = `/tmp/merlin-screenshot-${Date.now()}.png`;
235
+ let screenshotOk = false;
236
+ try {
237
+ await runCommand('screencapture', ['-x', screenshotPath]);
238
+ screenshotOk = true;
239
+ }
240
+ catch {
241
+ // Non-fatal — report it but continue
242
+ }
243
+ const taskNote = task
244
+ ? `\nRequested task: ${task}\n\nInstructions for Claude: Use your vision capabilities to read the screenshot at ${screenshotPath}, then proceed with the task described above.`
245
+ : '';
246
+ return {
247
+ content: [{
248
+ type: 'text',
249
+ text: coachWrap('merlin_computer_use', [
250
+ `APP LAUNCHED: ${app} (active)`,
251
+ screenshotOk ? `Screenshot: ${screenshotPath} — use Read tool or vision to inspect.` : 'Screenshot capture failed (screencapture unavailable).',
252
+ ...(task ? [`Task: ${task}`, `Instructions: Read screenshot at ${screenshotPath} then proceed with the task.`] : []),
253
+ ].join('\n')),
254
+ }],
255
+ };
256
+ }
257
+ // Unreachable — zod enum handles invalid values
258
+ return {
259
+ content: [{ type: 'text', text: coachWrap('merlin_computer_use', 'ERROR: Unknown action.') }],
260
+ isError: true,
261
+ };
262
+ }
263
+ catch (error) {
264
+ return {
265
+ content: [{
266
+ type: 'text',
267
+ text: coachWrap('merlin_computer_use', `ERROR: ${error instanceof Error ? error.message : String(error)}`),
268
+ }],
269
+ isError: true,
270
+ };
271
+ }
272
+ });
273
+ // ── Tool: merlin_screenshot ──────────────────────────────────────────────
274
+ server.tool('merlin_screenshot', 'Take a screenshot of the macOS desktop. Captures full screen, a named window, or allows manual selection. Returns the file path so Claude can read it with vision capabilities. macOS only.', {
275
+ region: z.enum(['full', 'window', 'selection']).optional().default('full').describe('What to capture: full screen (default), a specific window, or interactive selection'),
276
+ windowName: z.string().optional().describe('App name whose frontmost window to capture. Required when region is "window", e.g. "Safari".'),
277
+ }, async ({ region, windowName }) => {
278
+ const platformErr = assertMacOS();
279
+ if (platformErr) {
280
+ return {
281
+ content: [{ type: 'text', text: coachWrap('merlin_screenshot', `ERROR: ${platformErr}`) }],
282
+ isError: true,
283
+ };
284
+ }
285
+ const outPath = `/tmp/merlin-screenshot-${Date.now()}.png`;
286
+ try {
287
+ if (region === 'full' || region === undefined) {
288
+ await runCommand('screencapture', ['-x', outPath]);
289
+ }
290
+ else if (region === 'window') {
291
+ if (!windowName) {
292
+ return {
293
+ content: [{
294
+ type: 'text',
295
+ text: coachWrap('merlin_screenshot', 'ERROR: "windowName" is required when region is "window".'),
296
+ }],
297
+ isError: true,
298
+ };
299
+ }
300
+ if (!isSafeAppName(windowName)) {
301
+ return {
302
+ content: [{
303
+ type: 'text',
304
+ text: coachWrap('merlin_screenshot', `ERROR: Invalid window name "${windowName}". Only letters, digits, spaces, dots, underscores, and hyphens are allowed.`),
305
+ }],
306
+ isError: true,
307
+ };
308
+ }
309
+ // Get the window ID via osascript, then pass it to screencapture -l
310
+ let windowId;
311
+ try {
312
+ windowId = await runCommand('osascript', [
313
+ '-e',
314
+ `tell application "${windowName}" to id of window 1`,
315
+ ]);
316
+ }
317
+ catch (e) {
318
+ return {
319
+ content: [{
320
+ type: 'text',
321
+ text: coachWrap('merlin_screenshot', `ERROR: Could not get window ID for "${windowName}": ${e instanceof Error ? e.message : String(e)}`),
322
+ }],
323
+ isError: true,
324
+ };
325
+ }
326
+ await runCommand('screencapture', ['-l', windowId.trim(), outPath]);
327
+ }
328
+ else if (region === 'selection') {
329
+ // Interactive selection — screencapture will show crosshair to the user
330
+ await runCommand('screencapture', [outPath]);
331
+ }
332
+ return {
333
+ content: [{
334
+ type: 'text',
335
+ text: coachWrap('merlin_screenshot', [
336
+ 'SCREENSHOT CAPTURED',
337
+ `File: ${outPath}`,
338
+ `Region: ${region ?? 'full'}${windowName ? ` (window: ${windowName})` : ''} | ${new Date().toISOString()}`,
339
+ 'Use the Read tool or your vision capabilities to inspect this screenshot.',
340
+ ].join('\n')),
341
+ }],
342
+ };
343
+ }
344
+ catch (error) {
345
+ return {
346
+ content: [{
347
+ type: 'text',
348
+ text: coachWrap('merlin_screenshot', `ERROR: Screenshot failed — ${error instanceof Error ? error.message : String(error)}. Make sure screencapture is available and Accessibility permissions are granted.`),
349
+ }],
350
+ isError: true,
351
+ };
352
+ }
353
+ });
354
+ }
355
+ //# sourceMappingURL=computer-use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computer-use.js","sourceRoot":"","sources":["../../../src/server/tools/computer-use.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAElE,wGAAwG;AACxG,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAE9C,6CAA6C;AAC7C,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAC7E,CAAC;AAED,6EAA6E;AAC7E,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;IAAC,MA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E,QAAQ,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;YACtE,CAAC;iBAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,wEAAwE;gBACxE,MAAM,UAAU,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;YAC/C,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,SAAS,CAAC,mBAAmB,EAAE;4BACnC,qBAAqB;4BACrB,SAAS,OAAO,EAAE;4BAClB,WAAW,MAAM,IAAI,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,aAAa,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;4BAC1G,2EAA2E;yBAC5E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBACd,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,SAAS,CAAC,mBAAmB,EAAE,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,mFAAmF,CAAC;qBAC9M,CAAC;gBACF,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * AutoDream Memory Consolidation Tools
3
+ * Enables/configures Claude Code's AutoDream for Merlin's memory system.
4
+ * Project memory: ~/.claude/projects/<derived-path>/memory/
5
+ * Global memory: ~/.claude/memory/
6
+ */
7
+ import type { ToolContext } from './types.js';
8
+ export declare function registerDreamTools(ctx: ToolContext): void;
9
+ //# sourceMappingURL=dream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dream.d.ts","sourceRoot":"","sources":["../../../src/server/tools/dream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4K9C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA8EzD"}