-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Description
Summary
The installer fails to register the plugin when opencode.json contains URLs (e.g., MCP configurations with http:// or https://).
Root Cause
The JSONC comment stripping regex in cli.ts (line 204) and config.ts (line 38-40) incorrectly strips content after // inside string values:
const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");This regex is intended to strip single-line comments like // comment, but it naively matches ANY // on a line, including those inside quoted strings (URLs).
Example
Input (opencode.json):
{
"plugin": ["oh-my-opencode"],
"mcp": {
"Figma Desktop": {
"url": "http://127.0.0.1:3845/mcp"
}
},
"$schema": "https://opencode.ai/config.json"
}After comment stripping:
{
"plugin": ["oh-my-opencode"],
"mcp": {
"Figma Desktop": {
"url": "http:
}
},
"$schema": "https:
}The URLs are truncated, producing invalid JSON.
Symptoms
- Installer outputs:
✗ Failed to parse config file - Plugin is never added to
opencode.json - After restart, OpenCode shows "MCP not found" for supermemory
- The
/supermemory-initcommand exists but cannot use the supermemory tool
Affected Files
src/cli.tsline 204src/config.tslines 38-40
Proposed Fix
Replace the naive regex with a JSONC-aware parser that respects string boundaries. Options:
- Use a library like
jsonc-parser(from VSCode) - Implement a state-machine based comment stripper
- Use a more conservative regex that only matches
//at the start of a line (with optional leading whitespace)
Environment
- opencode-supermemory version: 0.1.3
- Config file:
opencode.json(not.jsonc) - Config contains MCP definitions with URLs
Metadata
Metadata
Assignees
Labels
No labels