create-merlin-brain 3.5.7 → 3.5.9

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/install.cjs CHANGED
@@ -1077,7 +1077,15 @@ async function install() {
1077
1077
  }
1078
1078
  const inputKey = await promptApiKey(!!existingApiKey);
1079
1079
  if (inputKey) {
1080
- apiKey = inputKey;
1080
+ // If user has an existing key and typed a confirmation like "y" or "yes",
1081
+ // they meant "keep existing" — don't store the literal string as the key.
1082
+ const isConfirmation = /^(y|yes|yeah|yep|sure|ok|keep)$/i.test(inputKey);
1083
+ if (isConfirmation && existingApiKey) {
1084
+ // Keep the existing key — user confirmed they want to keep it
1085
+ logSuccess('Keeping existing API key');
1086
+ } else {
1087
+ apiKey = inputKey;
1088
+ }
1081
1089
  }
1082
1090
 
1083
1091
  if (apiKey) {
@@ -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.9
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.9",
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",