Skip to content

Commit 0d5363e

Browse files
authored
feat: add opencode adapter (#16)
1 parent 213a467 commit 0d5363e

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ gtr.editor.default = cursor
315315
### AI Tool Settings
316316

317317
```bash
318-
# Default AI tool: none (or aider, claude, codex, cursor, continue)
318+
# Default AI tool: none (or aider, claude, codex, cursor, continue, opencode)
319319
gtr.ai.default = none
320320
```
321321

@@ -328,6 +328,7 @@ gtr.ai.default = none
328328
|**[Codex CLI](https://github.com/openai/codex)**|`npm install -g @openai/codex`| OpenAI coding assistant |`git gtr config set gtr.ai.default codex`|
329329
|**[Cursor](https://cursor.com)**| Install from cursor.com | AI-powered editor with CLI agent |`git gtr config set gtr.ai.default cursor`|
330330
|**[Continue](https://continue.dev)**| See [docs](https://docs.continue.dev/cli/install)| Open-source coding agent |`git gtr config set gtr.ai.default continue`|
331+
|**[OpenCode](https://opencode.ai)**| Install from opencode.ai | AI coding assistant |`git gtr config set gtr.ai.default opencode`|
331332

332333
**Examples:**
333334

‎adapters/ai/opencode.sh‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# OpenCode adapter
3+
4+
# Check if OpenCode is available
5+
ai_can_start(){
6+
command -v opencode >/dev/null 2>&1
7+
}
8+
9+
# Start OpenCode in a directory
10+
# Usage: ai_start path [args...]
11+
ai_start(){
12+
local path="$1"
13+
shift
14+
15+
if! ai_can_start;then
16+
log_error "OpenCode not found. Install from https://opencode.ai"
17+
log_info "Make sure the 'opencode' CLI is available in your PATH"
18+
return 1
19+
fi
20+
21+
if [ !-d"$path" ];then
22+
log_error "Directory not found: $path"
23+
return 1
24+
fi
25+
26+
# Change to the directory and run opencode with any additional arguments
27+
(cd "$path"&& opencode "$@")
28+
}
29+

‎bin/gtr‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ load_ai_adapter(){
944944

945945
if!command -v "$cmd_name">/dev/null 2>&1;then
946946
log_error "AI tool '$ai_tool' not found"
947-
log_info "Built-in adapters: aider, claude, codex, cursor, continue"
947+
log_info "Built-in adapters: aider, claude, codex, cursor, continue, opencode"
948948
log_info "Or use any AI tool command available in your PATH (e.g., bunx, gpt)"
949949
exit 1
950950
fi
@@ -1098,7 +1098,7 @@ CONFIGURATION OPTIONS:
10981098
atom, none
10991099
gtr.ai.default Default AI tool
11001100
Options: aider, claude, codex, cursor,
1101-
continue, none
1101+
continue, opencode, none
11021102
gtr.copy.include Files to copy (multi-valued)
11031103
gtr.copy.exclude Files to exclude (multi-valued)
11041104
gtr.copy.includeDirs Directories to copy (multi-valued)

0 commit comments

Comments
(0)