create-merlin-brain 3.5.7 → 3.5.8

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.
@@ -20,7 +20,32 @@ const fs = require('fs');
20
20
  const path = require('path');
21
21
 
22
22
  const API_URL = process.env.MERLIN_API_URL || 'https://auth.merlin.build';
23
- const API_KEY = process.env.MERLIN_API_KEY || '';
23
+
24
+ /**
25
+ * Resolve API key: env var first, then ~/.claude/config.json (where the MCP server stores it).
26
+ * This lets the CLI work even when MERLIN_API_KEY isn't exported in the shell.
27
+ */
28
+ function resolveApiKey() {
29
+ if (process.env.MERLIN_API_KEY) return process.env.MERLIN_API_KEY;
30
+
31
+ // Fallback: read from Claude Code MCP config
32
+ const configPaths = [
33
+ path.join(require('os').homedir(), '.claude', 'config.json'),
34
+ path.join(require('os').homedir(), '.claude', 'claude_desktop_config.json'),
35
+ ];
36
+ for (const configPath of configPaths) {
37
+ try {
38
+ if (fs.existsSync(configPath)) {
39
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
40
+ const key = config?.mcpServers?.merlin?.env?.MERLIN_API_KEY;
41
+ if (key) return key;
42
+ }
43
+ } catch { /* ignore parse errors */ }
44
+ }
45
+
46
+ return '';
47
+ }
48
+ const API_KEY = resolveApiKey();
24
49
 
25
50
  // ============================================================
26
51
  // Helpers
@@ -76,11 +101,12 @@ async function apiRequest(path, method = 'GET', body = null) {
76
101
 
77
102
  async function findRepoId(repoUrl) {
78
103
  try {
79
- const repos = await apiRequest('/api/repos');
104
+ const data = await apiRequest('/api/repos/my/list');
105
+ const repos = data.repositories || data || [];
80
106
  const normalizedUrl = repoUrl.replace(/^https?:\/\//, '').replace(/\.git$/, '').toLowerCase();
81
107
 
82
108
  const repo = repos.find(r => {
83
- const rUrl = r.url.replace(/^https?:\/\//, '').replace(/\.git$/, '').toLowerCase();
109
+ const rUrl = (r.url || '').replace(/^https?:\/\//, '').replace(/\.git$/, '').toLowerCase();
84
110
  return rUrl.includes(normalizedUrl) || normalizedUrl.includes(rUrl);
85
111
  });
86
112
 
@@ -1 +1 @@
1
- 3.5.7
1
+ 3.5.8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-merlin-brain",
3
- "version": "3.5.7",
3
+ "version": "3.5.8",
4
4
  "description": "Merlin - The Ultimate AI Brain for Claude Code. One install: workflows, agents, loop, and Sights MCP server.",
5
5
  "type": "module",
6
6
  "main": "./dist/server/index.js",