OpenCode substitutes {env:VAR} and {file:path} in config text at load
time, but OMP's OpenCode discovery ran the generic ${VAR}-only
expandEnvVarsDeep, leaving those tokens literal. An MCP header like
`Bearer {env:MCP_KEY}` reached the server verbatim and returned 401.
The OpenCode loader now applies OpenCode's own substitution to raw
config text before parsing: {env:VAR} -> env value or empty string,
{file:path} -> trimmed, JSON-escaped file contents resolved relative to
the config dir / ~ / absolute, skipping tokens on // comment lines.
Fixes#8778
Deep-merged each MCP server across config layers in ascending precedence, matching OpenCode config merge, so a partial higher-precedence override inherits command/url and env from lower layers instead of shadowing and invalidating the complete definition.
Added a regression test asserting a project override of a single field keeps the user command, transport, and merged env.
Emitted OpenCode MCP servers highest precedence first so the name-keyed first-wins dedupe keeps the project/opencode.jsonc entry OpenCode would use instead of a shadowing user or opencode.json definition.
Added a regression test asserting same-named servers resolve to the highest-precedence source, including a project enabled:false override.
Discovered opencode.jsonc at user and project scopes and parsed both supported extensions with Bun JSONC semantics.
Added coverage for JSONC settings, MCP servers, and comments in opencode.json.
Fixes#8104
Migrate 203 test files (356 call sites) from fs.rm/fs.rmSync to
removeWithRetries/removeSyncWithRetries to reduce EBUSY test failures
on Windows. removeWithRetries is now exported from @oh-my-pi/pi-utils.
The migration uses a regex-based approach that:
- Replaces fs.rm(path, { recursive, force }) → removeWithRetries(path)
- Replaces fs.rmSync(path, { recursive, force }) → removeSyncWithRetries(path)
- Replaces fs.rm(path) → removeWithRetries(path) (no options)
- Skips fs.rm/fs.rmSync inside template literals (bun --eval scripts)
- Adds imports to existing @oh-my-pi/pi-utils import or creates new one
- Removes unused fs imports where fs.rm was the only fs usage (4 files)
Mapped OpenCode MCP array commands to stdio command plus args and accepted environment as the provider-native env key.\n\nAdded regression coverage for array command normalization, environment mapping, env fallback, and empty args omission.\n\nFixes #3180