新建会话
  • 网站
  • 文档
  • PPT
  • 表格
  • 深度研究
Kimi Code Kimi Claw
历史会话
  • 查看手机应用
  • 关于我们
    • 探索月之暗面
    • 开放平台
    • 社会招聘
    • 校园招聘
    • 用户协议
    • 隐私协议
  • Language
  • 用户反馈

Installing Oh My OpenCode Plugin

Developing Oh My OpenCode itself
Perfect! Since you're developing Oh My OpenCode itself and want to test it against your OpenCode dev branch, here's how to set up your local development environment:

Development Setup for Oh My OpenCode

1. Project Structure Setup

bash
复制
# Create your development workspace
mkdir -p ~/dev/opencode-ecosystem
cd ~/dev/opencode-ecosystem

# Clone both repositories (if you haven't already)
git clone https://github.com/opencode-ai/opencode.git
git clone https://github.com/code-yeongyu/oh-my-opencode.git

2. Build Your OpenCode Dev Branch

bash
复制
cd ~/dev/opencode-ecosystem/opencode
git checkout your-dev-branch  # Switch to your dev branch
bun install
bun run build

# Link your dev build globally (optional but recommended for testing)
bun link
# or use local path directly

3. Prepare Oh My OpenCode for Development

bash
复制
cd ~/dev/opencode-ecosystem/oh-my-opencode
bun install

# Build the plugin
bun run build

4. Link Oh My OpenCode to Your Dev OpenCode

Method A: File Path Reference (Recommended for active development)
Edit your OpenCode configuration to point directly to your local Oh My OpenCode source:
bash
复制
# Edit the global config
nano ~/.config/opencode/opencode.json
Add the absolute file path to your local Oh My OpenCode:
JSON
复制
{
  "plugin": [
    "file:///home/YOUR_USERNAME/dev/opencode-ecosystem/oh-my-opencode"
  ],
  "model": {
    "default": "claude-sonnet-4-20250514"
  }
}
⚠️ Important: Use file:// protocol with absolute path. Relative paths may not resolve correctly.
Method B: Bun Link (Alternative)
bash
复制
cd ~/dev/opencode-ecosystem/oh-my-opencode
bun link

cd ~/dev/opencode-ecosystem/opencode
bun link oh-my-opencode  # Link to your dev opencode

5. Hot Reload Development Workflow

Since you're actively developing, set up a watch mode:
bash
复制
# Terminal 1: Watch and rebuild Oh My OpenCode on changes
cd ~/dev/opencode-ecosystem/oh-my-opencode
bun run build --watch  # or use chokidar-cli, etc.

# Terminal 2: Run OpenCode with your dev plugin
cd ~/dev/opencode-ecosystem/opencode
bun run start  # or ./dist/cli.js

6. Debugging Tips

Check plugin loading:
bash
复制
# Run with verbose logging to see plugin initialization
DEBUG=opencode:* opencode
Verify config:
bash
复制
cat ~/.config/opencode/opencode.json | jq '.plugin'
Test plugin functionality:
bash
复制
# Start interactive session
opencode

# In the chat, test Oh My OpenCode features:
# - /commit command
# - Enhanced prompts
# - Custom agents

7. Project-Level Testing (Isolated)

If you want to test without affecting your global OpenCode config, create a project-level config:
bash
复制
cd ~/dev/opencode-ecosystem/oh-my-opencode
mkdir -p test-project
cd test-project

# Create local opencode.json
cat > opencode.json << 'EOF'
{
  "plugin": ["file:///home/YOUR_USERNAME/dev/opencode-ecosystem/oh-my-opencode"],
  "model": {
    "default": "claude-sonnet-4-20250514"
  }
}
EOF

# Run opencode from this directory - it will use local config
opencode

8. Publishing Workflow (When Ready)

When you're ready to test the npm package flow:
bash
复制
cd ~/dev/opencode-ecosystem/oh-my-opencode

# Bump version
npm version patch

# Pack locally to test
npm pack
# This creates oh-my-opencode-X.X.X.tgz

# Test install from tarball
cd ~/dev/test-project
opencode plugin install ./path/to/oh-my-opencode-X.X.X.tgz

Quick Reference: File Paths

表格
ComponentPath
OpenCode Dev Branch~/dev/opencode-ecosystem/opencode
Oh My OpenCode Source~/dev/opencode-ecosystem/oh-my-opencode
Global Config~/.config/opencode/opencode.json
Project Config./opencode.json (in any project dir)

Troubleshooting

Plugin not loading?
  • Ensure bun run build completed without errors in oh-my-opencode
  • Check that file:// path is absolute and correct
  • Verify OpenCode version supports plugins (≥1.0.150)
Changes not reflecting?
  • OpenCode may cache plugins - restart the CLI
  • Ensure you're running the dev build of OpenCode, not a globally installed stable version
Import errors?
  • Check that oh-my-opencode/dist/index.js exists and exports correctly
  • Verify package.json has correct main/exports fields
Would you like me to elaborate on any specific part of the setup, such as the build configuration or testing workflow?