|
| 1 | +# Local Build & AWS Bedrock Setup |
| 2 | + |
| 3 | +Instructions for cloning, building, and running the Flexion fork of opencode with AWS Bedrock. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- [Bun](https://bun.sh) v1.3+ |
| 8 | +- [AWS CLI](https://aws.amazon.com/cli/) v2 |
| 9 | +- Git + SSH key configured for GitHub (with access to the `flexion` org) |
| 10 | + |
| 11 | +## Clone & Build |
| 12 | + |
| 13 | +```bash |
| 14 | +git clone git@github.com:flexion/opencode.git |
| 15 | +cd opencode |
| 16 | + |
| 17 | +# Switch to the Flexion customizations branch |
| 18 | +git checkout flex |
| 19 | + |
| 20 | +# Install dependencies |
| 21 | +# Note: if your global ~/.npmrc redirects to a private registry (e.g. CMS Artifactory), |
| 22 | +# override it so public packages resolve correctly: |
| 23 | +BUN_CONFIG_REGISTRY=https://registry.npmjs.org bun install |
| 24 | + |
| 25 | +# Build for your current platform only |
| 26 | +BUN_CONFIG_REGISTRY=https://registry.npmjs.org bun run --cwd packages/opencode build --single --skip-embed-web-ui |
| 27 | +``` |
| 28 | + |
| 29 | +The binary will be at: |
| 30 | +- macOS ARM64: `packages/opencode/dist/opencode-darwin-arm64/bin/opencode` |
| 31 | +- macOS x64: `packages/opencode/dist/opencode-darwin-x64/bin/opencode` |
| 32 | +- Linux ARM64: `packages/opencode/dist/opencode-linux-arm64/bin/opencode` |
| 33 | +- Linux x64: `packages/opencode/dist/opencode-linux-x64/bin/opencode` |
| 34 | + |
| 35 | +Verify the build: |
| 36 | + |
| 37 | +```bash |
| 38 | +./packages/opencode/dist/opencode-darwin-arm64/bin/opencode --version |
| 39 | +``` |
| 40 | + |
| 41 | +## AWS Bedrock Setup |
| 42 | + |
| 43 | +### 1. Configure AWS SSO profile |
| 44 | + |
| 45 | +Add to `~/.aws/config`: |
| 46 | + |
| 47 | +```ini |
| 48 | +[profile AdministratorAccess] |
| 49 | +sso_start_url = <your-sso-start-url> |
| 50 | +sso_region = <your-sso-region> |
| 51 | +sso_account_id = <your-account-id> |
| 52 | +sso_role_name = AdministratorAccess |
| 53 | +region = <your-preferred-region> |
| 54 | +``` |
| 55 | + |
| 56 | +### 2. Configure opencode for Bedrock |
| 57 | + |
| 58 | +Create `~/.config/opencode/opencode.json`: |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "$schema": "https://opencode.ai/config.json", |
| 63 | + "model": "amazon-bedrock/us.anthropic.claude-sonnet-4-6", |
| 64 | + "enabled_providers": ["amazon-bedrock"], |
| 65 | + "plugin": [], |
| 66 | + "provider": { |
| 67 | + "amazon-bedrock": { |
| 68 | + "options": { |
| 69 | + "region": "<your-preferred-region>" |
| 70 | + }, |
| 71 | + "models": { |
| 72 | + "writer.palmyra-x4": { |
| 73 | + "id": "us.writer.palmyra-x4-v1:0", |
| 74 | + "name": "Writer Palmyra X4", |
| 75 | + "tool_call": false, |
| 76 | + "limit": { "context": 128000, "output": 8192 } |
| 77 | + }, |
| 78 | + "writer.palmyra-x5": { |
| 79 | + "id": "us.writer.palmyra-x5-v1:0", |
| 80 | + "name": "Writer Palmyra X5", |
| 81 | + "tool_call": false, |
| 82 | + "limit": { "context": 1000000, "output": 8192 } |
| 83 | + }, |
| 84 | + "deepseek.r1": { |
| 85 | + "id": "us.deepseek.r1-v1:0", |
| 86 | + "name": "DeepSeek R1", |
| 87 | + "tool_call": false, |
| 88 | + "limit": { "context": 64000, "output": 32768 } |
| 89 | + }, |
| 90 | + "mistral.pixtral-large-2502": { |
| 91 | + "id": "us.mistral.pixtral-large-2502-v1:0", |
| 92 | + "name": "Mistral Pixtral Large", |
| 93 | + "tool_call": false, |
| 94 | + "limit": { "context": 128000, "output": 8192 } |
| 95 | + }, |
| 96 | + "meta.llama4-maverick-17b-instruct": { |
| 97 | + "id": "us.meta.llama4-maverick-17b-instruct-v1:0", |
| 98 | + "name": "Meta Llama 4 Maverick 17B", |
| 99 | + "tool_call": false, |
| 100 | + "limit": { "context": 1000000, "output": 8192 } |
| 101 | + }, |
| 102 | + "meta.llama4-scout-17b-instruct": { |
| 103 | + "id": "us.meta.llama4-scout-17b-instruct-v1:0", |
| 104 | + "name": "Meta Llama 4 Scout 17B", |
| 105 | + "tool_call": false, |
| 106 | + "limit": { "context": 10000000, "output": 8192 } |
| 107 | + }, |
| 108 | + "amazon.nova-2-lite": { |
| 109 | + "id": "us.amazon.nova-2-lite-v1:0", |
| 110 | + "name": "Amazon Nova 2 Lite", |
| 111 | + "limit": { "context": 300000, "output": 5120 } |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +> **Note on `tool_call: false`:** Models marked with `tool_call: false` do not support |
| 120 | +> tool use in streaming mode on Bedrock. This config prevents opencode from sending |
| 121 | +> tool definitions to those models. The `flex` branch includes a fix that makes |
| 122 | +> `tool_call: false` actually respected at runtime — see the tracking PR |
| 123 | +> [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) for details. |
| 124 | +
|
| 125 | +### 3. Shell alias |
| 126 | + |
| 127 | +Add to `~/.zshrc` or `~/.bashrc`: |
| 128 | + |
| 129 | +```bash |
| 130 | +opencode-work() { |
| 131 | + local profile="AdministratorAccess" |
| 132 | + echo "Logging in to AWS SSO ($profile)..." |
| 133 | + aws sso login --profile "$profile" || return 1 |
| 134 | + eval "$(aws configure export-credentials --profile "$profile" --format env)" |
| 135 | + /path/to/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode "$@" |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +Replace `/path/to/opencode` with where you cloned the repo (e.g. `~/Code/personal/flexion-work-items/flexchat-stack/opencode`). |
| 140 | + |
| 141 | +### 4. Usage |
| 142 | + |
| 143 | +```bash |
| 144 | +# Login and launch |
| 145 | +opencode-work |
| 146 | + |
| 147 | +# Re-running after SSO session expires — just run again, it will re-authenticate |
| 148 | +opencode-work |
| 149 | +``` |
| 150 | + |
| 151 | +## Keeping the Fork Up to Date |
| 152 | + |
| 153 | +When upstream releases a new version, sync `dev` and rebase `flex`: |
| 154 | + |
| 155 | +```bash |
| 156 | +git fetch upstream # upstream = https://github.com/anomalyco/opencode.git |
| 157 | +git checkout dev |
| 158 | +git reset --hard upstream/dev |
| 159 | +git push origin dev --force |
| 160 | + |
| 161 | +git checkout flex |
| 162 | +git rebase dev |
| 163 | +# Resolve any conflicts, then: |
| 164 | +git push origin flex --force |
| 165 | +``` |
| 166 | + |
| 167 | +See [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) for the full list of Flexion customizations and conflict resolution notes. |
| 168 | + |
| 169 | +## What's Different in This Fork (`flex` branch) |
| 170 | + |
| 171 | +| Change | File(s) | Description | |
| 172 | +|--------|---------|-------------| |
| 173 | +| Hide skill prompt text from chat UI | `packages/opencode/src/session/prompt.ts` | Marks skill template as `synthetic` so the full prompt is sent to the model but hidden from the user | |
| 174 | +| Respect `tool_call: false` at runtime | `packages/opencode/src/session/llm.ts` | Gates tool resolution behind `capabilities.toolcall` — fixes failures on Bedrock models that don't support streaming + tool use | |
| 175 | +| Local build & AWS Bedrock setup docs | `LOCAL_AWS_SETUP.md` | This file | |
| 176 | + |
| 177 | +Full details and upstream tracking: [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) |
| 178 | + |
| 179 | +Upstream issue: [anomalyco/opencode#19966](https://github.com/anomalyco/opencode/issues/19966) |
0 commit comments