Skip to content

Commit 7b84d91

Browse files
feat: add opencode module (#515)
## Description This PR adds the opencode module to the registry. ## Type of Change - [x] New module - [ ] New template - [ ] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder-labs/modules/opencode` **New version:** `v0.1.0` **Breaking change:** [ ] Yes [x] No ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun fmt`) - [x] Changes tested locally ## Related Issues <!-- Link related issues or write "None" if not applicable --> --------- Co-authored-by: DevCats <christofer@coder.com>
1 parent dd412fb commit 7b84d91

File tree

8 files changed

+1275
-0
lines changed

8 files changed

+1275
-0
lines changed

.icons/opencode.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
display_name: OpenCode
3+
icon: ../../../../.icons/opencode.svg
4+
description: Run OpenCode AI coding assistant for AI-powered terminal assistance
5+
verified: false
6+
tags: [agent, opencode, ai, tasks]
7+
---
8+
9+
# OpenCode
10+
11+
Run [OpenCode](https://opencode.ai) AI coding assistant in your workspace for intelligent code generation, analysis, and development assistance. This module integrates with [AgentAPI](https://github.com/coder/agentapi) for seamless task reporting in the Coder UI.
12+
13+
```tf
14+
module "opencode" {
15+
source = "registry.coder.com/coder-labs/opencode/coder"
16+
version = "0.1.0"
17+
agent_id = coder_agent.example.id
18+
workdir = "/home/coder/project"
19+
}
20+
```
21+
22+
## Prerequisites
23+
24+
- **Authentication credentials** - OpenCode auth.json file is required for non-interactive authentication, you can find this file on your system: `$HOME/.local/share/opencode/auth.json`
25+
26+
## Examples
27+
28+
### Basic Usage with Tasks
29+
30+
```tf
31+
resource "coder_ai_task" "task" {
32+
app_id = module.opencode.task_app_id
33+
}
34+
35+
module "opencode" {
36+
source = "registry.coder.com/coder-labs/opencode/coder"
37+
version = "0.1.0"
38+
agent_id = coder_agent.example.id
39+
workdir = "/home/coder/project"
40+
41+
ai_prompt = coder_ai_task.task.prompt
42+
43+
auth_json = <<-EOT
44+
{
45+
"google": {
46+
"type": "api",
47+
"key": "gem-xxx-xxxx"
48+
},
49+
"anthropic": {
50+
"type": "api",
51+
"key": "sk-ant-api03-xxx-xxxxxxx"
52+
}
53+
}
54+
EOT
55+
56+
config_json = jsonencode({
57+
"$schema" = "https://opencode.ai/config.json"
58+
mcp = {
59+
filesystem = {
60+
command = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/home/coder/projects"]
61+
enabled = true
62+
type = "local"
63+
environment = {
64+
SOME_VARIABLE_X = "value"
65+
}
66+
}
67+
playwright = {
68+
command = ["npx", "-y", "@playwright/mcp@latest", "--headless", "--isolated"]
69+
enabled = true
70+
type = "local"
71+
}
72+
}
73+
model = "anthropic/claude-sonnet-4-20250514"
74+
})
75+
76+
pre_install_script = <<-EOT
77+
#!/bin/bash
78+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
79+
sudo apt-get install -y nodejs
80+
EOT
81+
}
82+
```
83+
84+
### Standalone CLI Mode
85+
86+
Run OpenCode as a command-line tool without web interface or task reporting:
87+
88+
```tf
89+
module "opencode" {
90+
source = "registry.coder.com/coder-labs/opencode/coder"
91+
version = "0.1.0"
92+
agent_id = coder_agent.example.id
93+
workdir = "/home/coder"
94+
report_tasks = false
95+
cli_app = true
96+
}
97+
```
98+
99+
## Troubleshooting
100+
101+
If you encounter any issues, check the log files in the `~/.opencode-module` directory within your workspace for detailed information.
102+
103+
## References
104+
105+
- [Opencode JSON Config](https://opencode.ai/docs/config/)
106+
- [OpenCode Documentation](https://opencode.ai/docs)
107+
- [AgentAPI Documentation](https://github.com/coder/agentapi)
108+
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents)

0 commit comments

Comments
 (0)