Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .opencode/agent/translator.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ OPENCODE_DISABLE_CLAUDE_CODE
OPENCODE_DISABLE_CLAUDE_CODE_PROMPT
OPENCODE_DISABLE_CLAUDE_CODE_SKILLS
OPENCODE_DISABLE_DEFAULT_PLUGINS
OPENCODE_DISABLE_FILETIME_CHECK
OPENCODE_DISABLE_LSP_DOWNLOAD
OPENCODE_DISABLE_MODELS_FETCH
OPENCODE_DISABLE_PRUNE
Expand Down
6 changes: 1 addition & 5 deletions .opencode/opencode.jsonc
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"opencode": {
"options": {},
},
},
"provider": {},
"permission": {
"edit": {
"packages/opencode/migration/*": "deny",
Expand Down
2 changes: 1 addition & 1 deletion .opencode/tool/github-pr-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function githubFetch(endpoint: string, options: RequestInit = {}) {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
Accept: "application/vnd.github+json",
"Content-Type": "application/json",
...options.headers,
...(options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers),
},
})
if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion .opencode/tool/github-triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function githubFetch(endpoint: string, options: RequestInit = {}) {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
Accept: "application/vnd.github+json",
"Content-Type": "application/json",
...options.headers,
...(options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers),
},
})
if (!response.ok) {
Expand Down
51 changes: 51 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://raw.githubusercontent.com/nicolo-ribaudo/oxc-project.github.io/refs/heads/json-schema/src/public/.oxlintrc.schema.json",
"options": {
"typeAware": true
},
"categories": {
"suspicious": "warn"
},
"rules": {
"typescript/no-base-to-string": "warn",
// Effect uses `function*` with Effect.gen/Effect.fnUntraced that don't always yield
"require-yield": "off",
// SolidJS uses `let ref: T | undefined` for JSX ref bindings assigned at runtime
"no-unassigned-vars": "off",
// SolidJS tracks reactive deps by reading properties inside createEffect
"no-unused-expressions": "off",
// Intentional control char matching (ANSI escapes, null byte sanitization)
"no-control-regex": "off",
// SST and plugin tools require triple-slash references
"triple-slash-reference": "off",

// Suspicious category: suppress noisy rules
// Effect's nested function* closures inherently shadow outer scope
"no-shadow": "off",
// Namespace-heavy codebase makes this too noisy
"unicorn/consistent-function-scoping": "off",
// Opinionated — .sort()/.reverse() mutation is fine in this codebase
"unicorn/no-array-sort": "off",
"unicorn/no-array-reverse": "off",
// Not relevant — this isn't a DOM event handler codebase
"unicorn/prefer-add-event-listener": "off",
// Bundler handles module resolution
"unicorn/require-module-specifiers": "off",
// postMessage target origin not relevant for this codebase
"unicorn/require-post-message-target-origin": "off",
// Side-effectful constructors are intentional in some places
"no-new": "off",

// Type-aware: catch unhandled promises
"typescript/no-floating-promises": "warn",
// Warn when spreading non-plain objects (Headers, class instances, etc.)
"typescript/no-misused-spread": "warn"
},
"options": {
"typeAware": true
},
"options": {
"typeAware": true
},
"ignorePatterns": ["**/node_modules", "**/dist", "**/.build", "**/.sst", "**/*.d.ts", "**/sdk.gen.ts"]
}
27 changes: 1 addition & 26 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,10 @@
- Keep things in one function unless composable or reusable
- Avoid `try`/`catch` where possible
- Avoid using the `any` type
- Prefer single word variable names where possible
- Use Bun APIs when possible, like `Bun.file()`
- Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
- Prefer functional array methods (flatMap, filter, map) over for loops; use type guards on filter to maintain type inference downstream

### Naming

Prefer single word names for variables and functions. Only use multiple words if necessary.

### Naming Enforcement (Read This)

THIS RULE IS MANDATORY FOR AGENT WRITTEN CODE.

- Use single word names by default for new locals, params, and helper functions.
- Multi-word names are allowed only when a single word would be unclear or ambiguous.
- Do not introduce new camelCase compounds when a short single-word alternative is clear.
- Before finishing edits, review touched lines and shorten newly introduced identifiers where possible.
- Good short names to prefer: `pid`, `cfg`, `err`, `opts`, `dir`, `root`, `child`, `state`, `timeout`.
- Examples to avoid unless truly required: `inputPID`, `existingClient`, `connectTimeout`, `workerPath`.

```ts
// Good
const foo = 1
function journal(dir: string) {}

// Bad
const fooBar = 1
function prepareJournal(dir: string) {}
```
- In `src/config`, follow the existing self-export pattern at the top of the file (for example `export * as ConfigAgent from "./agent"`) when adding a new config module.

Reduce total variable count by inlining when a value is only used once.

Expand Down
180 changes: 180 additions & 0 deletions LOCAL_AWS_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Local Build & AWS Bedrock Setup

Instructions for cloning, building, and running the Flexion fork of opencode with AWS Bedrock.

## Prerequisites

- [Bun](https://bun.sh) v1.3+
- [AWS CLI](https://aws.amazon.com/cli/) v2
- Git + SSH key configured for GitHub (with access to the `flexion` org)

## Clone & Build

```bash
git clone git@github.com:flexion/opencode.git
cd opencode

# Switch to the Flexion customizations branch
git checkout flex

# Install dependencies
# Note: if your global ~/.npmrc redirects to a private registry (e.g. CMS Artifactory),
# override it so public packages resolve correctly:
BUN_CONFIG_REGISTRY=https://registry.npmjs.org bun install

# Build for your current platform only
BUN_CONFIG_REGISTRY=https://registry.npmjs.org bun run --cwd packages/opencode build --single --skip-embed-web-ui
```

The binary will be at:
- macOS ARM64: `packages/opencode/dist/opencode-darwin-arm64/bin/opencode`
- macOS x64: `packages/opencode/dist/opencode-darwin-x64/bin/opencode`
- Linux ARM64: `packages/opencode/dist/opencode-linux-arm64/bin/opencode`
- Linux x64: `packages/opencode/dist/opencode-linux-x64/bin/opencode`

Verify the build:

```bash
./packages/opencode/dist/opencode-darwin-arm64/bin/opencode --version
```

## AWS Bedrock Setup

### 1. Configure AWS SSO profile

Add to `~/.aws/config`:

```ini
[profile ClaudeCodeAccess]
sso_start_url = <your-sso-start-url>
sso_region = <your-sso-region>
sso_account_id = <your-account-id>
sso_role_name = AdministratorAccess
region = <your-preferred-region>
```

### 2. Configure opencode for Bedrock

Create `~/.config/opencode/opencode.json`:

```json
{
"$schema": "https://opencode.ai/config.json",
"model": "amazon-bedrock/us.anthropic.claude-sonnet-4-6",
"enabled_providers": ["amazon-bedrock"],
"plugin": [],
"provider": {
"amazon-bedrock": {
"options": {
"region": "<your-preferred-region>"
},
"models": {
"writer.palmyra-x4-v1:0": {
"name": "Writer Palmyra X4",
"tool_call": false,
"limit": { "context": 128000, "output": 8192 }
},
"writer.palmyra-x5-v1:0": {
"name": "Writer Palmyra X5",
"tool_call": false,
"limit": { "context": 1000000, "output": 8192 }
},
"deepseek.r1-v1:0": {
"name": "DeepSeek R1 (A)",
"tool_call": false,
"reasoning": false,
"limit": { "context": 64000, "output": 32768 }
},
"mistral.pixtral-large-2502-v1:0": {
"name": "Mistral Pixtral Large",
"tool_call": false,
"limit": { "context": 128000, "output": 8192 }
},
"meta.llama4-maverick-17b-instruct-v1:0": {
"name": "Meta Llama 4 Maverick 17B",
"tool_call": false,
"limit": { "context": 1000000, "output": 8192 }
},
"meta.llama4-scout-17b-instruct-v1:0": {
"name": "Meta Llama 4 Scout 17B",
"tool_call": false,
"limit": { "context": 10000000, "output": 8192 }
},
"amazon.nova-2-lite-v1:0": {
"name": "Amazon Nova 2 Lite",
"limit": { "context": 300000, "output": 5120 }
}
}
}
}
}
```

> **Notes on model config keys:** Config keys must match the snapshot model ID exactly (e.g. `writer.palmyra-x5-v1:0`) — the `us.` cross-region inference profile prefix is added automatically at runtime for supported models and regions. The `id` field is only needed if you want the key to differ from the API model ID.
>
> **`tool_call: false`:** Models marked with `tool_call: false` do not support tool use in streaming mode on Bedrock. This prevents opencode from sending tool definitions to those models.
>
> **`reasoning: false`:** Models marked with `reasoning: false` will have reasoning content stripped from message history before being sent to the model. Required for models like DeepSeek R1 on Bedrock that generate reasoning output but reject it as input in subsequent turns.

### 3. Shell alias

Add to `~/.zshrc` or `~/.bashrc`:

```bash
opencode-work() {
local profile="ClaudeCodeAccess"
echo "Logging in to AWS SSO ($profile)..."
aws sso login --profile "$profile" || return 1
eval "$(aws configure export-credentials --profile "$profile" --format env)"
/path/to/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode "${opencode_args[@]}"
}
```

Replace `/path/to/opencode` with where you cloned the repo (e.g. `~/Code/personal/flexion-work-items/flexchat-stack/opencode`).

### 4. Usage

```bash
# Login and launch
opencode-work

# Resume a previous session
opencode-work ses_2541da06dffeSyfI3ed4qvC7Tv

# Re-running after SSO session expires — just run again, it will re-authenticate
opencode-work
```

## Keeping the Fork Up to Date

When upstream releases a new version, sync `dev` and rebase `flex`:

```bash
git fetch upstream # upstream = https://github.com/anomalyco/opencode.git
git checkout dev
git reset --hard upstream/dev
git push origin dev --force

git checkout flex
git rebase dev
# Resolve any conflicts, then:
git push origin flex --force
```

See [flexion/opencode#2](https://github.com/flexion/opencode/pull/2) for the full list of Flexion customizations and conflict resolution notes.

## What's Different in This Fork (`flex` branch)

| Change | File(s) | Description |
|--------|---------|-------------|
| 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 |
| 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 |
| Re-sign macOS binaries after build | `packages/opencode/script/build.ts` | Strips Bun's embedded signature and applies a fresh ad-hoc one — fixes SIGKILL (exit 137) on Darwin 25+ where Bun's signature format is rejected |
| Add inference profile prefixes for palmyra and pixtral | `packages/opencode/src/provider/provider.ts` | Adds `us.` cross-region inference profile prefix for Writer Palmyra and Mistral Pixtral models in US regions |
| Strip reasoning from history for non-reasoning models | `packages/opencode/src/provider/transform.ts` | Removes reasoning content parts from assistant message history before sending to models with `reasoning: false` — fixes Bedrock rejections when switching from a reasoning model |
| Exclude palmyra from reasoning variant generation | `packages/opencode/src/provider/transform.ts` | Prevents unsupported `reasoningConfig` parameters from being sent to Writer Palmyra models |
| Local build & AWS Bedrock setup docs | `LOCAL_AWS_SETUP.md` | This file |

Full details and upstream tracking: [flexion/opencode#2](https://github.com/flexion/opencode/pull/2)

Upstream issue: [anomalyco/opencode#19966](https://github.com/anomalyco/opencode/issues/19966)
Loading
Loading