Skip to content

feat: replace Claude Code with OpenCode + Vercel AI Gateway#23

Merged
sweetmantech merged 3 commits intomainfrom
sweetmantech/myc-4161-task-opencode-coding-assistant-add-opencode
Feb 6, 2026
Merged

feat: replace Claude Code with OpenCode + Vercel AI Gateway#23
sweetmantech merged 3 commits intomainfrom
sweetmantech/myc-4161-task-opencode-coding-assistant-add-opencode

Conversation

@sweetmantech
Copy link
Contributor

@sweetmantech sweetmantech commented Feb 6, 2026

Summary

  • Replaces Claude Code with OpenCode as the AI coding assistant in Vercel Sandboxes
  • Configures OpenCode to use the Vercel AI Gateway provider for model access
  • New installOpenCode.ts installs opencode-ai CLI globally in the sandbox
  • New writeOpenCodeConfig.ts writes opencode.json with Vercel AI Gateway provider and anthropic/claude-sonnet-4 model
  • Updated runSandboxCommandTask.ts to call new install + config functions

Environment Variables

  • New: VERCEL_AI_GATEWAY_API_KEY — must be set in Trigger.dev env vars (get from Vercel dashboard > AI Gateway > API keys)

Test plan

  • Set VERCEL_AI_GATEWAY_API_KEY in Trigger.dev environment
  • Create a sandbox with a command via POST /api/sandboxes
  • Verify OpenCode is installed and opencode.json is written in the sandbox
  • Verify the run-sandbox-command task completes successfully
  • Verify command output is captured in stdout/stderr

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Integrated OpenCode CLI installation and configuration into sandbox initialization
    • OpenCode configured to connect with Vercel AI Gateway using Claude Sonnet 4 model
    • Added VERCEL_AI_GATEWAY_API_KEY environment variable requirement for sandbox operations

- Add installOpenCode.ts to install opencode-ai CLI globally
- Add writeOpenCodeConfig.ts to write opencode.json with Vercel AI Gateway provider config
- Update runSandboxCommandTask to use OpenCode instead of Claude Code
- Requires VERCEL_AI_GATEWAY_API_KEY env var in Trigger.dev

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

This pull request introduces two new modules (installOpenCode and writeOpenCodeConfig) that handle installing and configuring the OpenCode CLI within a Vercel sandbox environment, replacing the prior Claude Code integration in the runSandboxCommandTask workflow.

Changes

Cohort / File(s) Summary
OpenCode Sandbox Installation
src/sandboxes/installOpenCode.ts
New module that installs OpenCode CLI globally via privileged npm command with progress logging and error handling.
OpenCode Configuration
src/sandboxes/writeOpenCodeConfig.ts
New module that writes OpenCode configuration to sandbox, including API Gateway setup and model mapping using the VERCEL_AI_GATEWAY_API_KEY environment variable.
Sandbox Task Integration
src/tasks/runSandboxCommandTask.ts
Updated to import and invoke the new OpenCode modules, replacing Claude Code installation; adds VERCEL_AI_GATEWAY_API_KEY to required environment variables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 OpenCode hops into the sandbox pen,
Config written again and again!
With API keys held ever so tight,
Our furry deployment flows just right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing Claude Code with OpenCode and Vercel AI Gateway integration, which aligns with all three modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sweetmantech/myc-4161-task-opencode-coding-assistant-add-opencode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tasks/runSandboxCommandTask.ts (1)

36-40: ⚠️ Potential issue | 🟠 Major

VERCEL_AI_GATEWAY_API_KEY is not validated despite being documented as required.

The docstring at Lines 19-20 lists VERCEL_AI_GATEWAY_API_KEY as a required env var, but the guard at Lines 36-40 only checks the other three. This is the natural place to add the check (see Option B in the writeOpenCodeConfig.ts comment).

Proposed fix
     const token = process.env.VERCEL_TOKEN;
     const teamId = process.env.VERCEL_TEAM_ID;
     const projectId = process.env.VERCEL_PROJECT_ID;
+    const aiGatewayKey = process.env.VERCEL_AI_GATEWAY_API_KEY;

-    if (!token || !teamId || !projectId) {
+    if (!token || !teamId || !projectId || !aiGatewayKey) {
       throw new Error(
-        "Missing Vercel credentials. Set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID."
+        "Missing Vercel credentials. Set VERCEL_TOKEN, VERCEL_TEAM_ID, VERCEL_PROJECT_ID, and VERCEL_AI_GATEWAY_API_KEY."
       );
     }
🤖 Fix all issues with AI agents
In `@src/sandboxes/writeOpenCodeConfig.ts`:
- Around line 10-24: The writeOpenCodeConfig function currently sets apiKey:
process.env.VERCEL_AI_GATEWAY_API_KEY which may be undefined and will be dropped
by JSON.stringify; add a fail-fast validation in writeOpenCodeConfig that checks
process.env.VERCEL_AI_GATEWAY_API_KEY (the VERCEL_AI_GATEWAY_API_KEY env var)
and throw a clear Error (or reject) with a descriptive message if missing, so
the missing credential is caught close to usage; alternatively, if you prefer
centralized checks, add the same validation in runSandboxCommandTask alongside
other env var validations.
🧹 Nitpick comments (1)
src/sandboxes/installOpenCode.ts (1)

15-15: Pin opencode-ai to a specific version range instead of @latest.

Using @latest in an automated pipeline means any breaking release will silently break all new sandbox runs. Since the package is currently at 0.6.4, pinning to a caret range (e.g., opencode-ai@^0.6) would allow security patches and minor updates without risking breaking changes.

sweetmantech and others added 2 commits February 5, 2026 21:52
installClaudeCode.ts and runClaudeCode.ts are no longer imported
after switching to OpenCode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sweetmantech sweetmantech merged commit b16577d into main Feb 6, 2026
1 check passed
Sign up for free to 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.

1 participant

Comments