create-merlin-brain 2.1.6 → 2.1.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/install.cjs +96 -0
- package/dist/server/version.d.ts +1 -1
- package/dist/server/version.js +1 -1
- package/package.json +1 -1
package/bin/install.cjs
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// CRITICAL: Detect if this is being run as MCP server (with 'serve' argument)
|
|
5
|
+
// If so, hand off to the actual MCP server instead of running the installer.
|
|
6
|
+
// This prevents the installer from reading MCP protocol messages as user input!
|
|
7
|
+
// =============================================================================
|
|
8
|
+
const isServeMode = process.argv.includes('serve');
|
|
9
|
+
|
|
10
|
+
if (isServeMode) {
|
|
11
|
+
// Hand off to the MCP server using dynamic import (works in CommonJS with Node 14+)
|
|
12
|
+
import('../dist/server/index.js').catch((err) => {
|
|
13
|
+
console.error('Failed to start Merlin MCP server:', err.message);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
// The import runs the server module which keeps the process alive.
|
|
17
|
+
// We don't need to do anything else here - the code below won't
|
|
18
|
+
// execute until the server exits (which it won't during normal operation).
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// INSTALLER CODE BELOW - Only runs when NOT in serve mode
|
|
23
|
+
// =============================================================================
|
|
24
|
+
|
|
25
|
+
if (!isServeMode) {
|
|
26
|
+
|
|
3
27
|
const fs = require('fs');
|
|
4
28
|
const path = require('path');
|
|
5
29
|
const os = require('os');
|
|
@@ -475,6 +499,39 @@ function cleanupLegacy() {
|
|
|
475
499
|
} catch (e) { /* ignore */ }
|
|
476
500
|
}
|
|
477
501
|
|
|
502
|
+
// ═══════════════════════════════════════════════════════════════
|
|
503
|
+
// FIX ~/.claude.json MCP REGISTRY (update old merlin-mcp to create-merlin-brain)
|
|
504
|
+
// ═══════════════════════════════════════════════════════════════
|
|
505
|
+
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
506
|
+
if (fs.existsSync(claudeJsonPath)) {
|
|
507
|
+
try {
|
|
508
|
+
let claudeJson = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf8'));
|
|
509
|
+
let modified = false;
|
|
510
|
+
|
|
511
|
+
// Check if merlin MCP server uses old package name
|
|
512
|
+
if (claudeJson.mcpServers?.merlin) {
|
|
513
|
+
const args = claudeJson.mcpServers.merlin.args;
|
|
514
|
+
if (args && (args[0] === 'merlin-mcp' || args[0] === 'merlin-mcp@latest' || args[0] === 'ccwiki-mcp')) {
|
|
515
|
+
// Update to new package name
|
|
516
|
+
claudeJson.mcpServers.merlin.args = ['create-merlin-brain@latest', 'serve'];
|
|
517
|
+
modified = true;
|
|
518
|
+
cleaned.push('~/.claude.json (updated merlin-mcp → create-merlin-brain)');
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Remove old 'briefed' server if exists
|
|
523
|
+
if (claudeJson.mcpServers?.briefed) {
|
|
524
|
+
delete claudeJson.mcpServers.briefed;
|
|
525
|
+
modified = true;
|
|
526
|
+
cleaned.push('~/.claude.json (removed deprecated briefed server)');
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (modified) {
|
|
530
|
+
fs.writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2));
|
|
531
|
+
}
|
|
532
|
+
} catch (e) { /* ignore */ }
|
|
533
|
+
}
|
|
534
|
+
|
|
478
535
|
// ═══════════════════════════════════════════════════════════════
|
|
479
536
|
// PATTERN-BASED CLEANUP IN AGENTS DIR
|
|
480
537
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -745,6 +802,43 @@ async function install() {
|
|
|
745
802
|
};
|
|
746
803
|
fs.writeFileSync(claudeDirDesktopConfig, JSON.stringify(claudeDirConfig, null, 2));
|
|
747
804
|
logSuccess('Merlin Sights configured for ~/.claude/claude_desktop_config.json');
|
|
805
|
+
|
|
806
|
+
// CRITICAL: Also update ~/.claude.json (Claude MCP registry - this is what Claude Code actually uses!)
|
|
807
|
+
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
808
|
+
if (fs.existsSync(claudeJsonPath)) {
|
|
809
|
+
try {
|
|
810
|
+
let claudeJson = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf8'));
|
|
811
|
+
claudeJson.mcpServers = claudeJson.mcpServers || {};
|
|
812
|
+
claudeJson.mcpServers.merlin = {
|
|
813
|
+
type: 'stdio',
|
|
814
|
+
command: 'npx',
|
|
815
|
+
args: ['create-merlin-brain@latest', 'serve'],
|
|
816
|
+
env: { MERLIN_API_KEY: apiKey }
|
|
817
|
+
};
|
|
818
|
+
fs.writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2));
|
|
819
|
+
logSuccess('Merlin Sights configured for ~/.claude.json (Claude MCP registry)');
|
|
820
|
+
} catch (e) {
|
|
821
|
+
logWarn('Could not update ~/.claude.json - you may need to run: claude mcp remove merlin && claude mcp add merlin ...');
|
|
822
|
+
}
|
|
823
|
+
} else {
|
|
824
|
+
// Create ~/.claude.json with MCP config if it doesn't exist
|
|
825
|
+
try {
|
|
826
|
+
const claudeJson = {
|
|
827
|
+
mcpServers: {
|
|
828
|
+
merlin: {
|
|
829
|
+
type: 'stdio',
|
|
830
|
+
command: 'npx',
|
|
831
|
+
args: ['create-merlin-brain@latest', 'serve'],
|
|
832
|
+
env: { MERLIN_API_KEY: apiKey }
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
fs.writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2));
|
|
837
|
+
logSuccess('Merlin Sights configured for ~/.claude.json (Claude MCP registry - created)');
|
|
838
|
+
} catch (e) {
|
|
839
|
+
logWarn('Could not create ~/.claude.json');
|
|
840
|
+
}
|
|
841
|
+
}
|
|
748
842
|
} else {
|
|
749
843
|
logWarn('Skipped Merlin Sights (you can configure it later)');
|
|
750
844
|
}
|
|
@@ -794,3 +888,5 @@ install().catch((err) => {
|
|
|
794
888
|
console.error('Installation failed:', err);
|
|
795
889
|
process.exit(1);
|
|
796
890
|
});
|
|
891
|
+
|
|
892
|
+
} // End of if (!isServeMode)
|
package/dist/server/version.d.ts
CHANGED
package/dist/server/version.js
CHANGED
package/package.json
CHANGED