Skip to content

feat: add OpenCode compatibility support - #121

Open
ricky-theseus wants to merge 2 commits into
lingfengQAQ:masterfrom
ricky-theseus:feat/opencode-compatibility
Open

feat: add OpenCode compatibility support#121
ricky-theseus wants to merge 2 commits into
lingfengQAQ:masterfrom
ricky-theseus:feat/opencode-compatibility

Conversation

@ricky-theseus

Copy link
Copy Markdown

Summary

Add compatibility with OpenCode, an alternative to Claude Code. Makes the plugin work under OpenCode with zero breaking changes for existing Claude Code users.

Changes

Environment Variable Fallback Pattern

OpenCode does not set CLAUDE_* env vars. Instead it uses OPENCODE_PLUGIN_ROOT and OPENCODE_PROJECT_DIR. A fallback chain was added:

  • scripts/project_locator.py: Detect OPENCODE_PROJECT_DIR, fall back to ~/.opencode/
  • scripts/runtime_compat.py: Document OpenCode compat strategy
  • hooks/session_start.py: Read OPENCODE_PLUGIN_ROOT, export as CLAUDE_PLUGIN_ROOT
  • 8 SKILL.md files: Pre-set CLAUDE_* from OPENCODE_* before any existing reference

Documentation

  • Root README: OpenCode compat badge
  • webnovel-writer/README: OpenCode installation guide with env var reference

Testing

  • All existing pytest tests pass
  • Python scripts verifiable via preflight command with OPENCODE_PLUGIN_ROOT set

- env var fallback: OPENCODE_PLUGIN_ROOT -> CLAUDE_PLUGIN_ROOT, OPENCODE_PROJECT_DIR -> CLAUDE_PROJECT_DIR
- project_locator.py: detect OpenCode env vars, fall back to ~/.opencode/
- runtime_compat.py: document OpenCode compat strategy
- session_start.py: read OPENCODE_PLUGIN_ROOT, export CLAUDE_PLUGIN_ROOT
- 8 SKILL.md: pre-set CLAUDE_* from OPENCODE_* before any reference
- README: add OpenCode compatibility badge + installation guide

All changes are non-breaking for existing Claude Code users.
@ricky-theseus
ricky-theseus marked this pull request as ready for review June 20, 2026 01:59
@lingfengQAQ

Copy link
Copy Markdown
Owner

感谢你的pr,关于opencode的适配在新的v7版本会使用另外一种方式来适配

@ricky-theseus

ricky-theseus commented Jun 22, 2026 via email

Copy link
Copy Markdown
Author

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.

2 participants