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.
- package/bin/merlin-cli.cjs +29 -3
- package/files/merlin/VERSION +1 -1
- package/package.json +1 -1
package/bin/merlin-cli.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
package/files/merlin/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.5.
|
|
1
|
+
3.5.8
|
package/package.json
CHANGED