Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,4 @@ gha-creds-*.json

# IDEs
.idea
LICENSE.txt
1 change: 1 addition & 0 deletions bun.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
"configVersion": 0,
"workspaces": {
"": {
"name": "registry",
Expand Down
28 changes: 15 additions & 13 deletions registry/rothnic/modules/opencode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Integrate [OpenCode.ai](https://opencode.ai/) - an AI coding agent that runs in

```tf
module "opencode" {
source = "git::https://github.com/rothnic/coder-registry.git//registry/rothnic/modules/opencode"
source = "git::https://github.com/rothnic/coder-registry.git//registry/rothnic/modules/opencode"

agent_id = coder_agent.main.id
workdir = "/workspaces"
Expand All @@ -31,18 +31,20 @@ OpenCode requires GitHub Copilot's special session token format. Three options:
**Option 1: Pre-configured auth (Recommended)**

Run locally:

```bash
npm install -g opencode-ai
opencode auth login # Complete device flow
cat ~/.local/share/opencode/auth.json # Copy this
opencode auth login # Complete device flow
cat ~/.local/share/opencode/auth.json # Copy this
```

In your template:

```tf
module "opencode" {
source = "..."

opencode_auth_config = file("${path.module}/opencode-auth.json") # Store as file
opencode_auth_config = file("${path.module}/opencode-auth.json") # Store as file
# Or use variable: opencode_auth_config = var.opencode_auth_json
}
```
Expand All @@ -61,15 +63,15 @@ For Anthropic, OpenAI, etc., users authenticate via `opencode auth login` in the

## Configuration

| Variable | Description | Default |
|----------|-------------|---------|
| `agent_id` | Coder agent ID | Required |
| `workdir` | Working directory | Required |
| `opencode_auth_config` | Pre-configured auth.json content | `""` (optional) |
| `opencode_version` | OpenCode version | `"latest"` |
| `install_method` | Installation method: `npm` or `curl` | `"npm"` |
| `report_tasks` | Enable Coder task reporting | `true` |
| `subdomain` | Use subdomain for app access | `false` |
| Variable | Description | Default |
| ---------------------- | ------------------------------------ | --------------- |
| `agent_id` | Coder agent ID | Required |
| `workdir` | Working directory | Required |
| `opencode_auth_config` | Pre-configured auth.json content | `""` (optional) |
| `opencode_version` | OpenCode version | `"latest"` |
| `install_method` | Installation method: `npm` or `curl` | `"npm"` |
| `report_tasks` | Enable Coder task reporting | `true` |
| `subdomain` | Use subdomain for app access | `false` |

See [variables](./main.tf) for complete list.

Expand Down
6 changes: 3 additions & 3 deletions registry/rothnic/modules/opencode/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ install_nodejs() {
fi

# Reload shell environment
source "$HOME"/.bashrc 2>/dev/null || true
source "$HOME"/.bashrc 2> /dev/null || true

if ! command_exists node; then
echo "ERROR: Failed to install Node.js"
Expand Down Expand Up @@ -82,7 +82,7 @@ install_opencode() {
export PATH="$HOME/.local/bin:$PATH"

# Persist PATH to shell profile
if ! grep -q 'PATH="$HOME/.local/bin:$PATH"' "$HOME/.bashrc" 2>/dev/null; then
if ! grep -q 'PATH="$HOME/.local/bin:$PATH"' "$HOME/.bashrc" 2> /dev/null; then
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"
fi

Expand Down Expand Up @@ -180,7 +180,7 @@ configure_github_copilot_provider() {
echo "✓ GitHub token available - configuring Copilot provider in auth.json"

# Create auth.json with GitHub Copilot credentials
cat > "$auth_file" <<EOF
cat > "$auth_file" << EOF
{
"credentials": [
{
Expand Down
4 changes: 2 additions & 2 deletions registry/rothnic/modules/opencode/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail

source "$HOME"/.bashrc 2>/dev/null || true
source "$HOME"/.bashrc 2> /dev/null || true
export PATH="$HOME/.local/bin:$PATH"

command_exists() {
Expand Down Expand Up @@ -78,7 +78,7 @@ setup_github_authentication() {
# Note: This creates a simplified auth.json that may not work with GitHub Copilot
# For full GitHub Copilot support, use the opencode_auth_config variable
echo "⚠ Warning: Using simplified auth format - GitHub Copilot may require device flow auth"
cat > "$auth_file" <<EOF
cat > "$auth_file" << EOF
{
"credentials": [
{
Expand Down