Skip to content

Feat/opencode install scripts#8

Open
Bonislolz wants to merge 6 commits intobacktrue:mainfrom
Bonislolz:feat/opencode-install-scripts
Open

Feat/opencode install scripts#8
Bonislolz wants to merge 6 commits intobacktrue:mainfrom
Bonislolz:feat/opencode-install-scripts

Conversation

@Bonislolz
Copy link
Copy Markdown

This pull request introduces a cross-platform automated installation system for integrating the SBIR MCP Server into OpenCode, with dedicated scripts for Mac and Windows. The new installation flow ensures user settings are preserved, dependencies are managed via either uv or Python virtual environments, and the OpenCode configuration is safely updated to include the SBIR MCP Server. The update also includes a robust Python utility for merging the MCP server configuration into opencode.json without overwriting existing settings.

Key changes:

1. Cross-platform Installation Scripts

  • Added install-opencode-mac.sh, a comprehensive Bash script for Mac users to automate environment checking, dependency installation (via uv or Python venv), safe OpenCode configuration merging, and installation verification. The script preserves user settings and provides clear instructions and error handling.
  • Added install-opencode-windows.bat and install-opencode-windows.ps1, providing a Windows batch launcher and a PowerShell script that mirrors the Mac installation logic, including environment checks, dependency setup, safe configuration merging, and user guidance. [1] [2]

2. Safe OpenCode Configuration Update Utility

  • Introduced mcp-server/update_opencode_config.py, a Python script that safely merges the SBIR MCP Server configuration into opencode.json, supporting both uv and venv modes. The script ensures only the relevant MCP entry is updated/added, preserving all other user settings. It handles both JSON decode errors and file I/O gracefully.

3. Robust Dependency Management and Verification

  • Both Mac and Windows scripts intelligently detect and prefer uv for dependency management (for isolation and speed), falling back to Python venv if uv is unavailable. They verify installation success by checking for the presence of required Python modules and confirm the MCP server entry in the OpenCode config. [1] [2]

4. User Experience and Safety Enhancements

  • All scripts back up the existing opencode.json before making changes, provide clear error messages and next-step instructions, and ensure that installation failures do not leave the user with a broken configuration. [1] [2]

5. Documentation and Maintainability

  • The scripts and utility include detailed comments and user-facing messages in Traditional Chinese, making the process transparent and maintainable for both users and future developers. [1] [2] [3]

Bonislolz and others added 6 commits March 25, 2026 17:55
Add Mac/Windows install scripts for OpenCode (as opposed to Claude Desktop).
Key differences from existing install scripts:
- Config target: ~/.config/opencode/opencode.json (not Claude Desktop)
- MCP format: OpenCode's {mcp: {name: {type, command}}} structure
- uv path skips pre-install; relies on uv run auto-resolution for dependency isolation
- Safe merge: preserves existing OpenCode settings (plugins, providers, other MCPs)
- Includes update_opencode_config.py for JSON config merging with backup

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- Add setlocal EnableDelayedExpansion, use !VAR! inside parenthesized blocks
- Escape parentheses in echo with ^( ^) to prevent cmd parse errors
- Fix echo indentation that caused Chinese text to be parsed as commands
- Add endlocal at script end
- Prefix Chinese-only echo lines with [i] tag so cmd sees ASCII first
- Replace [!] warning icons with [*] to avoid delayed expansion conflicts
- Fixes 3 lines that cmd.exe parsed Chinese chars as command names
Replace fragile .bat with native PowerShell (.ps1) to eliminate all
cmd.exe encoding issues with Chinese text. The .bat file is now a
minimal 6-line launcher that calls the .ps1 with -ExecutionPolicy Bypass.

Benefits:
- Native UTF-8 support (no chcp hacks)
- Write-Host instead of echo (no parsing issues)
- Proper try/catch error handling
- No delayed expansion / variable escaping headaches
Windows PowerShell 5.1 reads .ps1 files as ANSI by default.
Without BOM, Chinese characters corrupt the parser's brace matching,
causing 'Missing closing }' errors across the entire file.
ErrorActionPreference=Stop causes PowerShell to treat uv stderr
output (dependency install progress) as a terminating error.
Switch to Continue for verification, use 2>&1 pipe filtering,
and wrap in try/catch since verification is non-critical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant