-
Notifications
You must be signed in to change notification settings - Fork 76
feat: add opencode module #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
35C4n0r
wants to merge
20
commits into
coder:main
Choose a base branch
from
35C4n0r:feat-opencode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fa07a63
feat: opencode module
35C4n0r e29cdb9
chore: update version
35C4n0r e7de712
chore: add output
35C4n0r d89abc0
Merge branch 'main' into feat-opencode
35C4n0r a28c050
chore: format
35C4n0r 248a5cf
chore: format
35C4n0r 8691b91
feat: update README.md
35C4n0r 875bdda
feat: update README.md
35C4n0r 8efdd37
feat: migrate to opencode config
35C4n0r 5493134
feat: make config global
35C4n0r 6a5f539
chore
35C4n0r c157295
chore
35C4n0r 8b560e0
chore
35C4n0r c4018ec
revert
35C4n0r fbb9647
feat: install only
35C4n0r c29a494
Merge branch 'main' into feat-opencode
DevelopmentCats 3c99534
chore: fix json
35C4n0r 9a5f7a6
Merge remote-tracking branch 'origin/feat-opencode' into feat-opencode
35C4n0r 24120e4
chore: use -I flag
35C4n0r e92f268
wip
35C4n0r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| display_name: OpenCode | ||
| icon: ../../../../.icons/opencode.svg | ||
| description: Run OpenCode AI coding assistant for AI-powered terminal assistance | ||
| verified: false | ||
| tags: [agent, opencode, ai, tasks] | ||
| --- | ||
|
|
||
| # OpenCode | ||
|
|
||
| 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. | ||
|
|
||
| ```tf | ||
| module "opencode" { | ||
| source = "registry.coder.com/coder-labs/opencode/coder" | ||
| version = "0.1.0" | ||
| agent_id = coder_agent.example.id | ||
| workdir = "/home/coder/project" | ||
| } | ||
| ``` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - **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` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Basic Usage with Tasks | ||
|
|
||
| ```tf | ||
| resource "coder_ai_task" "task" { | ||
| app_id = module.opencode.task_app_id | ||
| } | ||
|
|
||
| module "opencode" { | ||
| source = "registry.coder.com/coder-labs/opencode/coder" | ||
| version = "0.1.0" | ||
| agent_id = coder_agent.example.id | ||
| workdir = "/home/coder/project" | ||
|
|
||
| ai_prompt = coder_ai_task.task.prompt | ||
|
|
||
| auth_json = <<-EOT | ||
| { | ||
| "google": { | ||
| "type": "api", | ||
| "key": "gem-xxx-xxxx" | ||
| }, | ||
| "anthropic": { | ||
| "type": "api", | ||
| "key": "sk-ant-api03-xxx-xxxxxxx" | ||
| } | ||
| } | ||
| EOT | ||
|
|
||
| config_json = jsonencode({ | ||
| "$schema" = "https://opencode.ai/config.json" | ||
| mcp = { | ||
| filesystem = { | ||
| command = ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/home/coder/projects"] | ||
| enabled = true | ||
| type = "local" | ||
| environment = { | ||
| SOME_VARIABLE_X = "value" | ||
| } | ||
| } | ||
| playwright = { | ||
| command = ["npx", "-y", "@playwright/mcp@latest", "--headless", "--isolated"] | ||
| enabled = true | ||
| type = "local" | ||
| } | ||
| } | ||
| model = "anthropic/claude-sonnet-4-20250514" | ||
| }) | ||
|
|
||
| pre_install_script = <<-EOT | ||
| #!/bin/bash | ||
| curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - | ||
| sudo apt-get install -y nodejs | ||
| EOT | ||
| } | ||
| ``` | ||
|
|
||
| ### Standalone CLI Mode | ||
|
|
||
| Run OpenCode as a command-line tool without web interface or task reporting: | ||
|
|
||
| ```tf | ||
| module "opencode" { | ||
| source = "registry.coder.com/coder-labs/opencode/coder" | ||
| version = "0.1.0" | ||
| agent_id = coder_agent.example.id | ||
| workdir = "/home/coder" | ||
| report_tasks = false | ||
| cli_app = true | ||
| } | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| If you encounter any issues, check the log files in the `~/.opencode-module` directory within your workspace for detailed information. | ||
|
|
||
| ## References | ||
|
|
||
| - [Opencode JSON Config](https://opencode.ai/docs/config/) | ||
| - [OpenCode Documentation](https://opencode.ai/docs) | ||
| - [AgentAPI Documentation](https://github.com/coder/agentapi) | ||
| - [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an example to be used with Bedrock. Or link to the docs with what to change in the module.