From 575d02a6f5963f2e2e635a4d512829616b319d9b Mon Sep 17 00:00:00 2001 From: Sam Valladares Date: Mon, 8 Jun 2026 13:12:06 -0500 Subject: [PATCH] Add OpenCode integration and adoption plan --- README.md | 6 +- crates/vestige-core/Cargo.toml | 6 +- crates/vestige-mcp/src/main.rs | 51 ++-- docs/AGENT-MEMORY-PROTOCOL.md | 2 +- docs/CONFIGURATION.md | 34 +++ docs/ROADMAP.md | 2 +- docs/VESTIGE_STATE_AND_PLAN.md | 4 +- docs/integrations/codex.md | 1 + docs/integrations/cursor.md | 1 + docs/integrations/jetbrains.md | 1 + docs/integrations/opencode.md | 217 ++++++++++++++++++ docs/integrations/vscode.md | 1 + docs/integrations/windsurf.md | 1 + docs/integrations/xcode.md | 1 + docs/launch/opencode-adoption.md | 114 +++++++++ packages/vestige-init/bin/init.js | 54 ++++- packages/vestige-init/package.json | 1 + packages/vestige-mcp-npm/README.md | 34 +++ packages/vestige-mcp-npm/package.json | 1 + .../vestige-mcp-npm/scripts/postinstall.js | 1 + 20 files changed, 508 insertions(+), 25 deletions(-) create mode 100644 docs/integrations/opencode.md create mode 100644 docs/launch/opencode-adoption.md diff --git a/README.md b/README.md index 885588a..cec3daf 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ claude mcp add vestige vestige-mcp -s user # Codex codex mcp add vestige -- vestige-mcp +# OpenCode +npx @vestige/init + # 3. Test it # "Remember that I prefer TypeScript over JavaScript" # ...new session... @@ -142,6 +145,7 @@ Vestige speaks MCP, so any client that can register a stdio MCP server can use i | **Xcode 26.3** | [Integration guide](docs/integrations/xcode.md) | | **Cursor** | [Integration guide](docs/integrations/cursor.md) | | **VS Code (Copilot)** | [Integration guide](docs/integrations/vscode.md) | +| **OpenCode** | [Integration guide](docs/integrations/opencode.md) | | **JetBrains** | [Integration guide](docs/integrations/jetbrains.md) | | **Windsurf** | [Integration guide](docs/integrations/windsurf.md) | @@ -421,7 +425,7 @@ vestige dashboard # Open 3D dashboard in browser | [Storage Modes](docs/STORAGE.md) | Global, per-project, multi-instance | | [CLAUDE.md Setup](docs/CLAUDE-SETUP.md) | Templates for proactive memory | | [Configuration](docs/CONFIGURATION.md) | CLI commands, environment variables | -| [Integrations](docs/integrations/) | Codex, Xcode, Cursor, VS Code, JetBrains, Windsurf | +| [Integrations](docs/integrations/) | Codex, Xcode, Cursor, VS Code, OpenCode, JetBrains, Windsurf | | [Changelog](CHANGELOG.md) | Version history | --- diff --git a/crates/vestige-core/Cargo.toml b/crates/vestige-core/Cargo.toml index fe89443..ac1d5fa 100644 --- a/crates/vestige-core/Cargo.toml +++ b/crates/vestige-core/Cargo.toml @@ -121,7 +121,11 @@ candle-core = { version = "0.10.2", optional = true } # its memory_mapping_allocator_gt template references the POSIX MAP_FAILED # macro from , which doesn't exist on MSVC. Tracked upstream in # unum-cloud/usearch#746. Unpin when the upstream fix lands. -usearch = { version = "=2.23.0", optional = true } +# +# Disable default features so release binaries do not include SimSIMD's +# Haswell+/AVX2/FMA dispatch targets. Those kernels can trigger illegal +# instructions on older x86_64 CPUs that Vestige otherwise supports. +usearch = { version = "=2.23.0", default-features = false, optional = true } # LRU cache for query embeddings lru = "0.16" diff --git a/crates/vestige-mcp/src/main.rs b/crates/vestige-mcp/src/main.rs index 52524ba..a372fa3 100644 --- a/crates/vestige-mcp/src/main.rs +++ b/crates/vestige-mcp/src/main.rs @@ -300,21 +300,6 @@ async fn main() { let storage = match Storage::new(storage_path) { Ok(s) => { info!("Storage initialized successfully"); - - // Try to initialize embeddings early and log any issues - #[cfg(feature = "embeddings")] - { - if let Err(e) = s.init_embeddings() { - error!("Failed to initialize embedding service: {}", e); - error!("Smart ingest will fall back to regular ingest without deduplication"); - error!( - "Hint: Check FASTEMBED_CACHE_PATH or ensure ~/.cache/vestige/fastembed is writable" - ); - } else { - info!("Embedding service initialized successfully"); - } - } - Arc::new(s) } Err(e) => { @@ -323,6 +308,40 @@ async fn main() { } }; + // Initialize embeddings in the background so MCP clients can complete the + // stdio handshake quickly. First-run model downloads can otherwise exceed + // short client startup timeouts. + #[cfg(feature = "embeddings")] + { + let storage_clone = Arc::clone(&storage); + tokio::task::spawn_blocking(move || { + if let Err(e) = storage_clone.init_embeddings() { + error!("Failed to initialize embedding service: {}", e); + error!("Smart ingest will fall back to regular ingest without deduplication"); + error!( + "Hint: Check FASTEMBED_CACHE_PATH or ensure ~/.cache/vestige/fastembed is writable" + ); + } else { + info!("Embedding service initialized successfully"); + + #[cfg(feature = "vector-search")] + match storage_clone.generate_embeddings(None, false) { + Ok(result) => { + if result.successful > 0 || result.failed > 0 { + info!( + embeddings_generated = result.successful, + embeddings_failed = result.failed, + embeddings_skipped = result.skipped, + "Background embedding backfill complete" + ); + } + } + Err(e) => warn!("Background embedding backfill failed: {}", e), + } + } + }); + } + // Spawn periodic auto-consolidation so FSRS-6 decay scores stay fresh. // Runs on startup (if needed) and then every N hours (default: 6). // Configurable via VESTIGE_CONSOLIDATION_INTERVAL_HOURS env var. @@ -505,7 +524,7 @@ async fn main() { } // Load cross-encoder reranker in the background (downloads ~150MB on first run) - #[cfg(feature = "vector-search")] + #[cfg(all(feature = "vector-search", feature = "embeddings"))] { let cog_clone = Arc::clone(&cognitive); tokio::spawn(async move { diff --git a/docs/AGENT-MEMORY-PROTOCOL.md b/docs/AGENT-MEMORY-PROTOCOL.md index 367ca4b..6096982 100644 --- a/docs/AGENT-MEMORY-PROTOCOL.md +++ b/docs/AGENT-MEMORY-PROTOCOL.md @@ -76,6 +76,6 @@ call `memory` with `action="purge"` and `confirm=true`. ## Portability Notes The same protocol applies to Claude Code, Codex, Cursor, VS Code, Xcode, -JetBrains, Windsurf, and any other client that can run a stdio MCP server. Claude +OpenCode, JetBrains, Windsurf, and any other client that can run a stdio MCP server. Claude Code's Cognitive Sandwich hooks are optional companion files; they are not required for normal Vestige memory. diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 1205f70..2092663 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -141,6 +141,40 @@ Add to `%APPDATA%\Claude\claude_desktop_config.json`: } ``` +### OpenCode + +OpenCode supports global and project-local config. For a project-local setup, add to `opencode.json`: +```json +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "vestige": { + "type": "local", + "command": ["vestige-mcp"], + "enabled": true, + "timeout": 10000 + } + } +} +``` + +For isolated per-project memory, pass the data directory in the command array: +```json +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "vestige": { + "type": "local", + "command": ["vestige-mcp", "--data-dir", "./.vestige"], + "enabled": true, + "timeout": 10000 + } + } +} +``` + +See the [OpenCode integration guide](integrations/opencode.md) for global config, verification, and troubleshooting. + --- ## Custom Data Directory diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 91870bc..6578cef 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -45,7 +45,7 @@ Target: make the first 30 minutes with Vestige hard to mess up. | Atomic memory guide | Clear examples for one fact, one preference, one decision, one bug fix, one source note, and one code pattern per memory. | | Default tag vocabulary | Recommended tags for source quality, confidence, project, type, urgency, and lifecycle without overloading words like `verified`. | | Smart vs force-create guide | Agents know when to use `forceCreate`, `batchMergePolicy="force_create"`, or normal PE gating. | -| Updated agent templates | Claude, Codex, Cursor, VS Code, Xcode, JetBrains, and Windsurf templates start with `session_context` and use the same memory vocabulary. | +| Updated agent templates | Claude, Codex, Cursor, VS Code, Xcode, OpenCode, JetBrains, and Windsurf templates start with `session_context` and use the same memory vocabulary. | Planned docs: diff --git a/docs/VESTIGE_STATE_AND_PLAN.md b/docs/VESTIGE_STATE_AND_PLAN.md index 3e3a001..5f22469 100644 --- a/docs/VESTIGE_STATE_AND_PLAN.md +++ b/docs/VESTIGE_STATE_AND_PLAN.md @@ -73,8 +73,8 @@ Vestige is organized as: HTTP MCP is disabled unless the user passes `--http`, passes `--http-port`, or sets `VESTIGE_HTTP_ENABLED=1`. The stdio MCP server remains the portable default -for Claude Code, Codex, Cursor, VS Code, Xcode, JetBrains, Windsurf, and other -clients. +for Claude Code, Codex, Cursor, VS Code, Xcode, OpenCode, JetBrains, Windsurf, +and other clients. Purge is implemented transactionally in storage and surfaced through the MCP `memory` tool. `memory(action="purge", confirm=true)` is the explicit hard diff --git a/docs/integrations/codex.md b/docs/integrations/codex.md index 7d9b17b..9413175 100644 --- a/docs/integrations/codex.md +++ b/docs/integrations/codex.md @@ -145,6 +145,7 @@ codex mcp add vestige -- /usr/local/bin/vestige-mcp | Xcode 26.3 | [Setup](./xcode.md) | | Cursor | [Setup](./cursor.md) | | VS Code (Copilot) | [Setup](./vscode.md) | +| OpenCode | [Setup](./opencode.md) | | JetBrains | [Setup](./jetbrains.md) | | Windsurf | [Setup](./windsurf.md) | | Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | diff --git a/docs/integrations/cursor.md b/docs/integrations/cursor.md index 1e22943..4b7467b 100644 --- a/docs/integrations/cursor.md +++ b/docs/integrations/cursor.md @@ -135,6 +135,7 @@ Cursor does not surface MCP server errors in the UI. Test by running the command | Xcode 26.3 | [Setup](./xcode.md) | | Codex | [Setup](./codex.md) | | VS Code (Copilot) | [Setup](./vscode.md) | +| OpenCode | [Setup](./opencode.md) | | JetBrains | [Setup](./jetbrains.md) | | Windsurf | [Setup](./windsurf.md) | | Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | diff --git a/docs/integrations/jetbrains.md b/docs/integrations/jetbrains.md index 3424539..1582a34 100644 --- a/docs/integrations/jetbrains.md +++ b/docs/integrations/jetbrains.md @@ -123,6 +123,7 @@ In **Settings > Tools > MCP Server**, click the expansion arrow next to your cli | Cursor | [Setup](./cursor.md) | | VS Code (Copilot) | [Setup](./vscode.md) | | Codex | [Setup](./codex.md) | +| OpenCode | [Setup](./opencode.md) | | Windsurf | [Setup](./windsurf.md) | | Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | | Claude Desktop | [Setup](../CONFIGURATION.md#claude-desktop-macos) | diff --git a/docs/integrations/opencode.md b/docs/integrations/opencode.md new file mode 100644 index 0000000..c025225 --- /dev/null +++ b/docs/integrations/opencode.md @@ -0,0 +1,217 @@ +# OpenCode + +> Give OpenCode persistent local memory across TUI, CLI, and desktop sessions. + +OpenCode supports local MCP servers through its `mcp` config. Add Vestige once and your OpenCode agents can remember project decisions, architecture context, preferences, and previous fixes between sessions. + +Verified with OpenCode `1.16.2` on June 8, 2026. + +--- + +## Setup + +### 1. Install Vestige + +```bash +npm install -g vestige-mcp-server@latest +``` + +Verify the binary: + +```bash +vestige-mcp --version +``` + +If you prefer not to install globally, use `npx` directly in the OpenCode command array: + +```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 + } + } +} +``` + +The higher timeout is for the first cold `npx` run, which may need to download the npm package before OpenCode can connect. If you install `vestige-mcp-server` globally, `10000` is enough for normal startup. + +If `npx` times out against an older published Vestige build, install globally once and use `command: ["vestige-mcp"]`. The current integration keeps the MCP handshake fast by moving embedding startup work into the background. + +### 2. Add Vestige To OpenCode + +For global use across projects, create or edit: + +```bash +mkdir -p ~/.config/opencode +${EDITOR:-vi} ~/.config/opencode/opencode.json +``` + +Add: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "vestige": { + "type": "local", + "command": ["vestige-mcp"], + "enabled": true, + "timeout": 10000 + } + } +} +``` + +OpenCode also supports project-local config. Put the same block in `opencode.json` at the repo root when you want the setting checked in with a project. + +For a custom config file, set `OPENCODE_CONFIG=/path/to/opencode.json` before launching OpenCode. + +### 3. Verify + +Restart OpenCode, then validate the resolved config and MCP server list: + +```bash +opencode debug config +opencode mcp list +``` + +You should see `vestige` listed. In a session, ask: + +> "What MCP tools can you use?" + +Vestige tools should be available with the `vestige_` prefix, such as `vestige_search`, `vestige_smart_ingest`, `vestige_session_context`, and `vestige_deep_reference`. + +--- + +## First Use + +In OpenCode: + +> "Remember that this project uses Rust with Axum and SQLite." + +Start a new OpenCode session, then ask: + +> "What stack does this project use?" + +It remembers. + +--- + +## Project-Specific Memory + +To isolate memory per repo, add `--data-dir` to OpenCode's command array: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "vestige": { + "type": "local", + "command": ["vestige-mcp", "--data-dir", "./.vestige"], + "enabled": true, + "timeout": 10000 + } + } +} +``` + +For an absolute path: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "vestige": { + "type": "local", + "command": ["/usr/local/bin/vestige-mcp", "--data-dir", "/Users/you/projects/my-app/.vestige"], + "enabled": true, + "timeout": 10000 + } + } +} +``` + +--- + +## Automatic Setup + +If `opencode` is installed or `~/.config/opencode` exists, Vestige's installer can add the global config automatically: + +```bash +npx @vestige/init +``` + +The installer writes a backup before modifying an existing config file. It also migrates Vestige entries copied from older `mcpServers` examples into OpenCode's current `mcp.vestige` shape. + +--- + +## Troubleshooting + +
+Vestige tools do not appear + +1. Verify OpenCode can see configured MCP servers: + ```bash + opencode debug config + opencode mcp list + ``` +2. Verify the binary is on your path: + ```bash + which vestige-mcp + ``` +3. Use an absolute binary path if OpenCode cannot resolve `vestige-mcp`. +4. Restart OpenCode after changing `opencode.json`. +5. Keep `timeout` at `10000` or higher for installed binaries. If you use the direct `npx` command, use `60000` so the first cold npm download does not fail OpenCode startup. +
+ +
+Config does not validate + +OpenCode uses the top-level `mcp` key. Do not use the `mcpServers` shape from Claude Desktop, Cursor, or Windsurf. + +If you copied an older Vestige example that used `mcpServers`, rerun: + +```bash +npx @vestige/init +``` + +Correct: + +```json +{ + "mcp": { + "vestige": { + "type": "local", + "command": ["vestige-mcp"], + "timeout": 10000 + } + } +} +``` +
+ +
+Too many MCP tools in context + +OpenCode loads MCP tools alongside built-in tools. If you have many MCP servers enabled, disable unused servers or restrict MCP tools per agent in your OpenCode config. +
+ +--- + +## Also Works With + +| IDE | Guide | +|-----|-------| +| Codex | [Setup](./codex.md) | +| Cursor | [Setup](./cursor.md) | +| VS Code (Copilot) | [Setup](./vscode.md) | +| JetBrains | [Setup](./jetbrains.md) | +| Windsurf | [Setup](./windsurf.md) | +| Xcode 26.3 | [Setup](./xcode.md) | +| Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | +| Claude Desktop | [Setup](../CONFIGURATION.md#claude-desktop-macos) | diff --git a/docs/integrations/vscode.md b/docs/integrations/vscode.md index 556e784..0211f87 100644 --- a/docs/integrations/vscode.md +++ b/docs/integrations/vscode.md @@ -153,6 +153,7 @@ Every team member with Vestige installed will automatically get memory-enabled C | Xcode 26.3 | [Setup](./xcode.md) | | Cursor | [Setup](./cursor.md) | | Codex | [Setup](./codex.md) | +| OpenCode | [Setup](./opencode.md) | | JetBrains | [Setup](./jetbrains.md) | | Windsurf | [Setup](./windsurf.md) | | Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | diff --git a/docs/integrations/windsurf.md b/docs/integrations/windsurf.md index 3a0aca1..ec00dea 100644 --- a/docs/integrations/windsurf.md +++ b/docs/integrations/windsurf.md @@ -149,6 +149,7 @@ If you have many MCP servers and exceed 100 total tools, Cascade will ignore exc | Cursor | [Setup](./cursor.md) | | VS Code (Copilot) | [Setup](./vscode.md) | | Codex | [Setup](./codex.md) | +| OpenCode | [Setup](./opencode.md) | | JetBrains | [Setup](./jetbrains.md) | | Claude Code | [Setup](../CONFIGURATION.md#claude-code-one-liner) | | Claude Desktop | [Setup](../CONFIGURATION.md#claude-desktop-macos) | diff --git a/docs/integrations/xcode.md b/docs/integrations/xcode.md index 3856a5e..5164ec1 100644 --- a/docs/integrations/xcode.md +++ b/docs/integrations/xcode.md @@ -252,6 +252,7 @@ Vestige uses the MCP standard — the same memory works across all your tools: | Claude Desktop | [Setup](../CONFIGURATION.md#claude-desktop-macos) | | Cursor | [Setup](./cursor.md) | | VS Code (Copilot) | [Setup](./vscode.md) | +| OpenCode | [Setup](./opencode.md) | | JetBrains | [Setup](./jetbrains.md) | | Windsurf | [Setup](./windsurf.md) | diff --git a/docs/launch/opencode-adoption.md b/docs/launch/opencode-adoption.md new file mode 100644 index 0000000..808c36e --- /dev/null +++ b/docs/launch/opencode-adoption.md @@ -0,0 +1,114 @@ +# OpenCode Adoption Plan + +Status: Vestige was tested with OpenCode `1.16.2` on June 8, 2026. The working config uses OpenCode's top-level `mcp.vestige` schema, not `mcpServers`. + +## Release Gate + +- PR #67 is merged upstream and should be treated as the contributor-driven starting point. +- Ship the corrected OpenCode config docs and `@vestige/init` migration from stale `mcpServers.vestige` to `mcp.vestige`. +- Ship the background embedding initialization fix before making direct `npx` the main OpenCode install path. A cold published `2.1.23` package can still time out while OpenCode waits for tools. +- After release, verify all three OpenCode paths again: + - installed binary: `command: ["vestige-mcp"]` + - project memory: `command: ["vestige-mcp", "--data-dir", "./.vestige"]` + - direct npm: `command: ["npx", "-y", "-p", "vestige-mcp-server@latest", "vestige-mcp"]` with `timeout: 60000` + +## Official OpenCode PR + +Target repo: `https://github.com/anomalyco/opencode` + +Files: + +- `packages/web/src/content/docs/mcp-servers.mdx` +- `packages/web/src/content/docs/ecosystem.mdx` + +MCP docs snippet: + +```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 + } + } +} +``` + +Ecosystem row: + +```md +| [Vestige](https://github.com/samvallad33/vestige) | Local MCP memory server for OpenCode that remembers project decisions, preferences, and previous fixes across sessions | +``` + +Positioning: local, inspectable MCP memory for OpenCode. Avoid claiming Vestige fixes OpenCode's process memory or session resume behavior. + +## Awesome OpenCode + +Target repo: `https://github.com/awesome-opencode/awesome-opencode` + +Suggested entry, with category to confirm against maintainer preference (`data/projects/vestige.yaml` or `data/resources/vestige.yaml`): + +```yaml +name: Vestige +repo: https://github.com/samvallad33/vestige +tagline: Local persistent memory for OpenCode +description: Local MCP server that lets OpenCode remember project decisions, preferences, architecture context, and previous fixes across sessions. +scope: + - global + - project +tags: + - mcp + - memory + - local-first + - sqlite + - opencode +min_version: 1.16.2 +homepage: https://github.com/samvallad33/vestige/blob/main/docs/integrations/opencode.md +installation: | + npm install -g vestige-mcp-server@latest + npx @vestige/init +``` + +## MCP Directories + +Current state: + +- Official MCP Registry already lists `io.github.samvallad33/vestige` at `https://registry.modelcontextprotocol.io/v0/servers?search=vestige`. +- Smithery already lists Vestige and indexes 25 tools: `https://smithery.ai/server/@samvallad33/vestige`. +- Glama already lists Vestige, but the listing needs a refresh/fix if it shows no tools: `https://glama.ai/mcp/servers/samvallad33/vestige`. +- `mcp.so` does not show Vestige under the expected slugs yet; submit manually at `https://mcp.so/submit`. + +Priority order: + +1. Official MCP Registry: `https://github.com/modelcontextprotocol/registry` +2. Awesome MCP Servers: `https://github.com/punkpeye/awesome-mcp-servers` +3. Glama MCP directory: `https://glama.ai/mcp/servers` +4. Smithery: `https://smithery.ai` +5. PulseMCP: `https://www.pulsemcp.com` + +Registry metadata is mostly ready: `server.json` exists and `packages/vestige-mcp-npm/package.json` has `mcpName: "io.github.samvallad33/vestige"`. Publish only when the package version and `server.json` version match the released npm package. + +## Community Launch + +Use tested technical copy, not hype: + +> Vestige now works with OpenCode as a local MCP memory server. It gives OpenCode persistent memory for project decisions, preferences, architecture context, and previous fixes across sessions. Install with `npm install -g vestige-mcp-server@latest`, run `npx @vestige/init`, then verify with `opencode mcp list`. + +High-signal channels after release: + +- OpenCode Discord: `https://opencode.ai/discord` +- opencode.cafe MCP Server listing: `https://opencode.cafe` +- OpenCode memory-related GitHub issues, only where directly relevant +- Hacker News and Lobsters with a technical post about the tested OpenCode integration and failure modes +- npm keyword/discovery after the next package release includes `opencode` + +## Proof Checklist + +- `opencode debug config` accepts `mcp.vestige`. +- `opencode mcp list` shows `vestige connected`. +- Stale `mcpServers.vestige` examples fail in OpenCode and are migrated by `@vestige/init`. +- OpenCode tools are prefixed as `vestige_search`, `vestige_smart_ingest`, `vestige_session_context`, and `vestige_deep_reference`. +- The OpenCode guide says `timeout: 60000` for direct `npx` and `timeout: 10000` for installed binaries. diff --git a/packages/vestige-init/bin/init.js b/packages/vestige-init/bin/init.js index d7c5da2..cb62f81 100755 --- a/packages/vestige-init/bin/init.js +++ b/packages/vestige-init/bin/init.js @@ -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); } diff --git a/packages/vestige-init/package.json b/packages/vestige-init/package.json index dce6675..1a70a91 100644 --- a/packages/vestige-init/package.json +++ b/packages/vestige-init/package.json @@ -13,6 +13,7 @@ "claude", "copilot", "cursor", + "opencode", "xcode", "jetbrains", "windsurf", diff --git a/packages/vestige-mcp-npm/README.md b/packages/vestige-mcp-npm/README.md index 98e6575..7bc9e2c 100644 --- a/packages/vestige-mcp-npm/README.md +++ b/packages/vestige-mcp-npm/README.md @@ -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: diff --git a/packages/vestige-mcp-npm/package.json b/packages/vestige-mcp-npm/package.json index 1ff860f..119093a 100644 --- a/packages/vestige-mcp-npm/package.json +++ b/packages/vestige-mcp-npm/package.json @@ -14,6 +14,7 @@ "keywords": [ "mcp", "claude", + "opencode", "ai", "memory", "vestige", diff --git a/packages/vestige-mcp-npm/scripts/postinstall.js b/packages/vestige-mcp-npm/scripts/postinstall.js index 65fe54b..76e678b 100644 --- a/packages/vestige-mcp-npm/scripts/postinstall.js +++ b/packages/vestige-mcp-npm/scripts/postinstall.js @@ -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('');