Skip to content

Comments

feat: add OpenCode support and fix hook basename detection#262

Open
itai-delphos wants to merge 2 commits intortk-ai:masterfrom
Delphos-Labs:master
Open

feat: add OpenCode support and fix hook basename detection#262
itai-delphos wants to merge 2 commits intortk-ai:masterfrom
Delphos-Labs:master

Conversation

@itai-delphos
Copy link

Summary

  • OpenCode integration: Adds full support for OpenCode as a second AI agent platform alongside Claude Code, including a TypeScript plugin (hooks/rtk-rewrite.ts), platform abstraction layer (src/platform.rs), and OpenCode session provider for discover/learn commands.
  • Hook basename fix: Fixes shell hook basename detection so rtk-rewrite.sh works correctly across different shell environments.
  • Multi-platform documentation: Updates README, INSTALL, ARCHITECTURE, and TROUBLESHOOTING docs to reflect support for both Claude Code and OpenCode.

Changes

New Files

  • src/platform.rs — Platform abstraction layer for detecting and managing Claude Code vs OpenCode environments
  • hooks/rtk-rewrite.ts — OpenCode TypeScript plugin with full command rewrite logic (equivalent to rtk-rewrite.sh for Claude Code)

Modified Files

  • src/init.rs — Auto-detect platform (Claude Code or OpenCode), install appropriate hook/plugin
  • src/discover/provider.rs — Add OpenCode session provider to scan OpenCode session history
  • src/discover/mod.rs — Multi-platform support: discover scans both platforms by default
  • src/learn/mod.rs — Multi-platform support: learn scans both platforms by default
  • src/main.rs — Register platform module and new CLI options
  • hooks/rtk-rewrite.sh — Fix basename detection for broader shell compatibility
  • hooks/rtk-awareness.md — Updated for multi-platform context

Documentation

  • README.md — Updated terminology from "Claude Code" to "AI agent" where applicable, added OpenCode references
  • INSTALL.md — Updated installation instructions for both platforms
  • ARCHITECTURE.md — Updated hook architecture section for multi-platform support
  • docs/TROUBLESHOOTING.md — Added OpenCode-specific troubleshooting guidance

Stats

  • 13 files changed, 1743 insertions, 408 deletions

**OpenCode Integration:**
- Add platform abstraction layer (src/platform.rs) for Claude Code and OpenCode
- New OpenCode plugin (hooks/rtk-rewrite.ts) with full command rewrite logic
- OpenCode session provider for discover/learn commands (scans ~/.local/share/opencode/opencode.db)
- Multi-platform support: discover/learn scan both platforms by default
- Updated documentation (README, INSTALL, ARCHITECTURE, TROUBLESHOOTING) for dual-platform usage

**Hook Fixes:**
- Fix critical basename detection bug: pattern `*/rtk\ *` incorrectly matched `git -C /path/to/rtk status`
- Changed to basename checking: only skip if first command word is literally 'rtk'
- Add workaround for git -C/-c flags (not yet supported by RTK core)
  - Hooks now skip rewriting git commands with global options
  - Prevents "unexpected argument '-C' found" errors
  - Documented as known limitation in TROUBLESHOOTING.md

**Testing:**
- All 435 tests pass
- Manual testing confirms hooks work in both platforms
- Hook correctly rewrites: `git status` → `rtk git status`
- Hook correctly skips: `git -C /path status` (no rewrite)
- Hook correctly skips: `rtk git status` (already using rtk)

**Files Changed:**
- NEW: hooks/rtk-rewrite.ts (OpenCode plugin)
- NEW: src/platform.rs (platform abstraction)
- FIXED: hooks/rtk-rewrite.sh (basename detection + git -C skip)
- UPDATED: src/discover/, src/init.rs, src/learn/ (multi-platform)
- DOCS: README, INSTALL, ARCHITECTURE, TROUBLESHOOTING
…-fixes

feat: add OpenCode support and fix hook basename detection
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