Skip to content

Conversation

@KevinWu098
Copy link
Contributor

@KevinWu098KevinWu098 commented Nov 17, 2025

Summary

Adds support for OpenCode to gtr.

Testing

Tested locally on MacOS.

  • Create worktree with branch name
  • Create worktree with branch containing slashes (e.g., feature/auth)
  • Create from remote branch
  • Create from local branch
  • Create new branch
  • Open in editor (if testing adapters)
  • Run AI tool (if testing adapters)
  • Remove worktree by branch name
  • List worktrees
  • Test configuration commands
  • Test completions (tab completion works)
  • Test gtr go 1 for main repo
  • Test gtr go <branch> for worktrees

Summary by CodeRabbit

  • New Features

    • Added OpenCode as a selectable AI tool adapter (can be chosen as the default).
  • User Experience

    • Adapter will check for OpenCode availability and provide informative guidance if the tool is not installed or cannot be run.
  • Documentation

    • Updated help text and documentation to list OpenCode among available AI tool choices and in built-in adapter listings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitaibot commented Nov 17, 2025

📝 Walkthrough

Walkthrough

Adds an OpenCode AI adapter: a new Bash wrapper script that checks for the OpenCode CLI and runs it in a target directory; updates README.md and bin/gtr help/config to list opencode as a built-in AI tool option.

Changes

Cohort / File(s)Summary
New OpenCode adapter
adapters/ai/opencode.sh
Adds ai_can_start() to verify opencode CLI availability and ai_start() to validate the target directory and execute opencode in a subshell; includes error logging and guidance when CLI is missing.
Documentation and CLI help
README.md, bin/gtr
Adds opencode to the AI tools list and updates gtr.ai.default/options and adapter listing text to include opencode.

Sequence Diagram(s)

sequenceDiagram participant User as Caller (script/CLI) participant Adapter as adapters/ai/opencode.sh participant CLI as opencode (system) User->>Adapter: ai_start(path, args...) Adapter->>Adapter: ai_can_start()? (command -v opencode) alt opencode missing Adapter-->>User: log info/error (missing opencode) else opencode available Adapter->>Adapter: validate path exists alt path missing Adapter-->>User: log error (missing dir) else path ok Adapter->>CLI: (subshell) cd path && opencode args... CLI-->>Adapter: exit status / output Adapter-->>User: return status end end 
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Focus points:
    • adapters/ai/opencode.sh: consistent error messages, subshell usage, and correct argument forwarding.
    • bin/gtr: verify help text formatting and inclusion of opencode.
    • README.md: ensure the new table entry matches existing formatting.

Poem

🐰 A hop and a tap, a new tool in sight,
I found OpenCode and made it take flight,
A script that will check, then run through the night,
Docs now say "opencode" — simple and bright,
Small changes, big hops, everything's right!

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'feat: add opencode adapter' is concise, articulate, and directly describes the main change: adding support for the OpenCode AI adapter to the gtr tool.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 678bcd2 and 884008d.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • adapters/ai/opencode.sh (1 hunks)
  • bin/gtr (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
🧰 Additional context used
🧬 Code graph analysis (1)
adapters/ai/opencode.sh (1)
lib/ui.sh (2)
  • log_error (12-14)
  • log_info (4-6)
🔇 Additional comments (5)
adapters/ai/opencode.sh (3)

1-3: LGTM!

The shebang and header comments follow the standard pattern for adapter scripts.


5-7: LGTM!

The availability check is implemented correctly using command -v, which is portable and follows the pattern used by other adapters.


11-28: Implementation correctly handles OpenCode CLI availability and execution.

The ai_can_start() function properly validates the opencode CLI is available, and opencode is a documented CLI tool with official documentation and GitHub repository. The three-layer defensive approach is sound:

  1. Lines 15-19: Validates CLI existence via ai_can_start with clear error messaging
  2. Lines 21-24: Verifies directory exists before execution
  3. Line 27: Safe subshell invocation without eval, properly passes arguments via "$@"

The implementation follows the established pattern across all adapters (cursor, claude, continue, codex, aider) and handles the case where opencode is unavailable with appropriate exit code.

bin/gtr (2)

947-947: LGTM!

The addition of "opencode" to the built-in adapters list is correct and maintains the alphabetical ordering of the adapter names.


1101-1101: LGTM!

The configuration help text correctly includes "opencode" as an option for gtr.ai.default, maintaining consistency with the built-in adapters list at line 947.


Comment @coderabbitai help to get the list of available commands and usage tips.

@KevinWu098KevinWu098force-pushed the kwu/add-opencode-adapter branch from 8592e38 to 678bcd2CompareNovember 17, 2025 14:14
@helizagahelizagaforce-pushed the kwu/add-opencode-adapter branch from 678bcd2 to 884008dCompareNovember 22, 2025 03:13
@helizagahelizaga merged commit 0d5363e into coderabbitai:mainNov 22, 2025
1 check passed
Sign up for freeto 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

@KevinWu098@helizaga