Skip to content
Open
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
20 changes: 14 additions & 6 deletions LOCAL_AWS_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@

Instructions for building and running the Flexion fork of opencode.

## AWS Credentials Setup
## AWS Credentials & End-User Install

AWS credentials and opencode configuration are managed by **flexcamp-ai**:
End-user installation and AWS credentials are managed by **[flexcamp-ai](https://github.com/flexion/flexcamp-ai)** — a macOS menubar app that walks you through a guided setup wizard.

```
https://github.com/flexion/flexcamp-ai
```
**Getting started:**

1. In Slack, type `/get-openwork` in any channel — the bot will DM you a Bedrock API key, expiration date, and region.
2. Download **OpenWork Setup** from the link in the DM (or the [latest release](https://github.com/flexion/flexcamp-ai/releases/latest)).
3. Open the app and run the setup wizard (~2 min). It installs and configures everything: Homebrew/Node.js if needed, OpenCode, the OpenWork desktop app, AWS Bedrock credentials, workspace folder, and pre-built skills.
4. After setup, click **"Open OpenWork"** or use the menu bar icon.

**Renewing your API key (expires every 7 days):**
Type `/bedrock-key` in Slack → click the menu bar icon → **"Replace API Key..."** → paste the Slack message.

---

Follow the setup instructions there before building or running this fork. flexcamp-ai handles AWS authentication, the `opencode-work` shell function, and `~/.config/opencode/opencode.json`.
_Developers building from source: continue to the sections below._

---

Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[install]
exact = true
registry = "https://registry.npmjs.org"

[test]
root = "./do-not-run-tests-from-root"
Expand Down
61 changes: 5 additions & 56 deletions install-flex
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# 2. Prompts: clone directory
# 3. Clones [email protected]:flexion/opencode.git (flex branch) — skipped if already present
# 4. Installs dependencies and builds the native binary
# 5. Appends opencode-work() launcher function to ~/.zshrc or ~/.bashrc
#
# AWS credentials and opencode configuration are managed by flexcamp-ai:
# https://github.com/flexion/flexcamp-ai
# Run flexcamp-ai setup before or after this installer.
# Use /get-openwork in Slack to get your API key, then run the OpenWork Setup
# app to complete configuration.
#
# Existing files are never overwritten; each step is skipped with a warning
# if the output already exists.
Expand Down Expand Up @@ -111,70 +111,19 @@ clone_and_build() {
success "Binary built"
}

# ── step 4: shell launcher function ──────────────────────────────────────────
write_shell_alias() {
local rc_file
case "$(basename "${SHELL:-bash}")" in
zsh) rc_file="$HOME/.zshrc" ;;
*) rc_file="$HOME/.bashrc" ;;
esac

# Sentinel comment is the idempotency guard — more reliable than matching the
# function signature, which a user might remove while leaving a stale comment.
if grep -qF "── Flexion opencode launcher ──" "$rc_file" 2>/dev/null; then
warn "opencode-work() already defined in $rc_file — skipping"
return
fi

info "Appending opencode-work() to $rc_file..."

# Use printf %q to shell-quote the clone path at install time.
# This eliminates the previous Perl s|...|..| substitution which was vulnerable
# to injection if CLONE_DIR contained a | character.
local clone_dir_q
clone_dir_q=$(printf '%q' "$CLONE_DIR")

# Double-quoted heredoc: $clone_dir_q expands now (install time);
# all other $ references are \-escaped so they expand at shell run time.
cat >>"$rc_file" <<SHELL_EOF

# ── Flexion opencode launcher ─────────────────────────────────────────────────
# AWS credentials are managed by flexcamp-ai (github.com/flexion/flexcamp-ai).
opencode-work() {
local clone_dir=$clone_dir_q
local arch os
case "\$(uname -m)" in arm64|aarch64) arch="arm64" ;; *) arch="x64" ;; esac
case "\$(uname -s)" in Darwin) os="darwin" ;; Linux) os="linux" ;; *)
echo "Unsupported OS: \$(uname -s)" && return 1 ;; esac
"\${clone_dir}/packages/opencode/dist/opencode-\${os}-\${arch}/bin/opencode" "\$@"
}
# ─────────────────────────────────────────────────────────────────────────────
SHELL_EOF

success "opencode-work() added to $rc_file"
}

# ── main ──────────────────────────────────────────────────────────────────────
main() {
check_prereqs
gather_inputs
clone_and_build
write_shell_alias

local rc_file
case "$(basename "${SHELL:-bash}")" in
zsh) rc_file="$HOME/.zshrc" ;;
*) rc_file="$HOME/.bashrc" ;;
esac

printf '\n%s%sInstallation complete!%s\n' "$GREEN" "$BOLD" "$NC"
printf '────────────────────────────────────────────\n'
printf ' Binary: %s/packages/opencode/dist/opencode-*/bin/opencode\n' "$CLONE_DIR"
printf '\n Next steps:\n'
printf ' 1. Set up AWS credentials via flexcamp-ai:\n'
printf ' https://github.com/flexion/flexcamp-ai\n'
printf ' 2. source %s\n' "$rc_file"
printf ' 3. opencode-work\n\n'
printf ' 1. Type /get-openwork in Slack to receive your Bedrock API key\n'
printf ' 2. Download and run OpenWork Setup to complete configuration:\n'
printf ' https://github.com/flexion/flexcamp-ai\n\n'
}

main
1 change: 1 addition & 0 deletions packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"minimatch": "10.0.3",
"npm-package-arg": "13.0.2",
"open": "10.1.2",
"opencode-darwin-arm64": "1.14.35",
"opencode-gitlab-auth": "2.0.1",
"opencode-poe-auth": "0.0.1",
"opentui-spinner": "catalog:",
Expand Down
6 changes: 2 additions & 4 deletions packages/opencode/test/provider/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,6 @@ describe("ProviderTransform.message - DeepSeek reasoning content", () => {
)

expect(result[0].content).toEqual([
{ type: "reasoning", text: "Should not be processed" },
{ type: "text", text: "Answer" },
])
expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
Expand Down Expand Up @@ -1369,9 +1368,8 @@ describe("ProviderTransform.message - anthropic empty content filtering", () =>
const result = ProviderTransform.message(msgs, anthropicModel, {})

expect(result).toHaveLength(1)
expect(result[0].content).toHaveLength(2)
expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
expect(result[0].content).toHaveLength(1)
expect(result[0].content[0]).toEqual({ type: "text", text: "Result" })
})

test("filters empty content for bedrock provider", () => {
Expand Down
Loading