Add OpenCode integration and safer startup

This commit is contained in:
Sam Valladares 2026-06-15 17:06:01 -05:00
parent 16903f3ab4
commit 6c7d56b4cf
21 changed files with 676 additions and 44 deletions

View file

@ -105,6 +105,21 @@ const IDE_CONFIGS = {
note: 'Tip: For project-level config, create .vscode/mcp.json with {"servers": {"vestige": ...}}',
},
'OpenCode': {
detect: () => {
try {
execSync(PLATFORM === 'win32' ? 'where opencode' : 'which opencode', { stdio: 'ignore' });
return true;
} catch {
return fs.existsSync(path.join(HOME, '.config', 'opencode'));
}
},
configPath: () => path.join(HOME, '.config', 'opencode', 'opencode.json'),
format: 'opencode',
key: 'mcp',
note: 'Tip: For project-level memory, add the same mcp.vestige block to an opencode.json in your repo root.',
},
'Xcode 26.3': {
detect: () => {
if (PLATFORM !== 'darwin') return false;
@ -152,7 +167,10 @@ function findBinary() {
// npm global install location
(() => {
try {
const npmPrefix = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
const npmPrefix = execSync('npm prefix -g', {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
}).trim();
return path.join(npmPrefix, 'bin', 'vestige-mcp');
} catch { return null; }
})(),
@ -164,7 +182,11 @@ function findBinary() {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'ignore'],
}).trim();
if (result) candidates.unshift(result);
const firstMatch = result
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)[0];
if (firstMatch) candidates.unshift(firstMatch);
} catch {}
for (const candidate of candidates) {
@ -272,6 +294,16 @@ function buildVestigeConfig(binaryPath) {
};
}
function buildOpenCodeConfig(binaryPath) {
return {
type: 'local',
command: [binaryPath],
enabled: true,
timeout: 10000,
environment: {},
};
}
function buildXcodeConfig(binaryPath) {
return {
projects: {
@ -324,6 +356,22 @@ function injectConfig(ide, ideName, binaryPath) {
return false;
}
config.mcp.servers.vestige = buildVestigeConfig(binaryPath);
} else if (ide.format === 'opencode') {
// OpenCode uses top-level "mcp" entries with command arrays.
if (!config.$schema) config.$schema = 'https://opencode.ai/config.json';
if (!config.mcp) config.mcp = {};
if (config.mcp.vestige) {
console.log(` [skip] ${ideName} — already configured`);
return false;
}
if (config.mcpServers && config.mcpServers.vestige) {
delete config.mcpServers.vestige;
if (Object.keys(config.mcpServers).length === 0) {
delete config.mcpServers;
}
console.log(` [migrate] ${ideName} — moved vestige from mcpServers to mcp`);
}
config.mcp.vestige = buildOpenCodeConfig(binaryPath);
} else {
// Standard mcpServers format (Cursor, Claude Desktop, JetBrains, Windsurf)
const key = ide.key || 'mcpServers';
@ -383,7 +431,7 @@ function main() {
if (detected.length === 0) {
console.log(' No supported IDEs found.');
console.log('');
console.log('Supported: Claude Code, Claude Desktop, Cursor, VS Code, Xcode, JetBrains, Windsurf');
console.log('Supported: Claude Code, Claude Desktop, Cursor, VS Code, OpenCode, Xcode, JetBrains, Windsurf');
process.exit(1);
}

View file

@ -13,6 +13,7 @@
"claude",
"copilot",
"cursor",
"opencode",
"xcode",
"jetbrains",
"windsurf",

View file

@ -54,6 +54,40 @@ codex mcp add vestige -- vestige-mcp
Then restart your MCP client.
**OpenCode**
Add to `~/.config/opencode/opencode.json` or a project-local `opencode.json`:
```json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"vestige": {
"type": "local",
"command": ["vestige-mcp"],
"enabled": true,
"timeout": 10000
}
}
}
```
Prefer the installed `vestige-mcp` command for OpenCode. If you run Vestige directly through `npx`, use a longer first-run timeout because npm may need to download the package before OpenCode can connect:
```json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"vestige": {
"type": "local",
"command": ["npx", "-y", "-p", "vestige-mcp-server@latest", "vestige-mcp"],
"enabled": true,
"timeout": 60000
}
}
}
```
## Usage with Claude Desktop
Add to your Claude Desktop configuration:

View file

@ -14,6 +14,7 @@
"keywords": [
"mcp",
"claude",
"opencode",
"ai",
"memory",
"vestige",

View file

@ -258,6 +258,7 @@ async function main() {
console.log(' 1. Add vestige-mcp to any MCP-compatible agent.');
console.log(' Claude Code: claude mcp add vestige vestige-mcp -s user');
console.log(' Codex: codex mcp add vestige -- vestige-mcp');
console.log(' OpenCode: npx @vestige/init, or add mcp.vestige to ~/.config/opencode/opencode.json');
console.log(' 2. Restart your MCP client.');
console.log(' 3. Test with: "remember that my preferred editor is VS Code"');
console.log('');