Skip to content
13 changes: 12 additions & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ GH_TOKEN='<gh-token>' A2A_BEARER_TOKEN='<a2a-token>' \
./scripts/deploy.sh project=alpha a2a_port=8010 a2a_host=127.0.0.1 a2a_public_url=https://a2a.example.com
```

Supported CLI keys (case-insensitive): `project`/`project_name`, `data_root`, `a2a_port`, `a2a_host`, `a2a_public_url`, `a2a_streaming`, `a2a_log_level`, `a2a_log_payloads`, `a2a_log_body_limit`, `opencode_provider_id`, `opencode_model_id`, `repo_url`, `repo_branch`, `opencode_timeout`, `opencode_timeout_stream`, `git_identity_name`, `git_identity_email`, `update_a2a`, `force_restart`.
Supported CLI keys (case-insensitive): `project`/`project_name`, `data_root`, `a2a_port`, `a2a_host`, `a2a_public_url`, `a2a_streaming`, `a2a_log_level`, `a2a_log_payloads`, `a2a_log_body_limit`, `opencode_provider_id`, `opencode_model_id`, `opencode_lsp`, `repo_url`, `repo_branch`, `opencode_timeout`, `opencode_timeout_stream`, `git_identity_name`, `git_identity_email`, `update_a2a`, `force_restart`.

Required secret env vars: `GH_TOKEN`, `A2A_BEARER_TOKEN`

Expand All @@ -106,6 +106,16 @@ GH_TOKEN='<gh-token>' A2A_BEARER_TOKEN='<a2a-token>' \
./scripts/deploy.sh project=alpha a2a_port=8010
```

LSP behavior:

- Deployment default is `OPENCODE_LSP=false` (LSP disabled).
- To enable LSP for one instance, pass `opencode_lsp=true`:

```bash
GH_TOKEN='<gh-token>' A2A_BEARER_TOKEN='<a2a-token>' \
./scripts/deploy.sh project=alpha opencode_lsp=true
```

Upgrade an existing instance after shared-code update:

```bash
Expand Down Expand Up @@ -220,6 +230,7 @@ Naming rule in the tables below:
| `OPENCODE_EXTRA_ARGS` | - | Optional | empty | Extra OpenCode startup args. |
| `OPENCODE_PROVIDER_ID` | `opencode_provider_id` | Optional | None | Written to `a2a.env`. |
| `OPENCODE_MODEL_ID` | `opencode_model_id` | Optional | None | Written to `a2a.env`. |
| `OPENCODE_LSP` | `opencode_lsp` | Optional | `false` | Global OpenCode LSP switch for deployed instance. Wrapper injects default `OPENCODE_CONFIG_CONTENT` with this value when `OPENCODE_CONFIG_CONTENT` is unset. |
| `OPENCODE_TIMEOUT` | `opencode_timeout` | Optional | `300` | OpenCode request timeout (seconds). |
| `OPENCODE_TIMEOUT_STREAM` | `opencode_timeout_stream` | Optional | None | OpenCode streaming timeout (seconds). |
| `GIT_IDENTITY_NAME` | `git_identity_name` | Optional | `OpenCode-<project>` | Git author/committer name. |
Expand Down
10 changes: 8 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Deploy an isolated OpenCode + A2A instance (systemd services).
# Usage: ./deploy.sh project=<name> [data_root=<path>] [a2a_port=<port>] [a2a_host=<host>] [a2a_public_url=<url>] [a2a_streaming=<bool>] [a2a_log_level=<level>] [a2a_log_payloads=<bool>] [a2a_log_body_limit=<int>] [opencode_provider_id=<id>] [opencode_model_id=<id>] [repo_url=<url>] [repo_branch=<branch>] [opencode_timeout=<seconds>] [opencode_timeout_stream=<seconds>] [git_identity_name=<name>] [git_identity_email=<email>] [update_a2a=true] [force_restart=true]
# Usage: ./deploy.sh project=<name> [data_root=<path>] [a2a_port=<port>] [a2a_host=<host>] [a2a_public_url=<url>] [a2a_streaming=<bool>] [a2a_log_level=<level>] [a2a_log_payloads=<bool>] [a2a_log_body_limit=<int>] [opencode_provider_id=<id>] [opencode_model_id=<id>] [opencode_lsp=<bool>] [repo_url=<url>] [repo_branch=<branch>] [opencode_timeout=<seconds>] [opencode_timeout_stream=<seconds>] [git_identity_name=<name>] [git_identity_email=<email>] [update_a2a=true] [force_restart=true]
# Required env: GH_TOKEN, A2A_BEARER_TOKEN
# Optional provider secret env: see scripts/deploy/provider_secret_env_keys.sh
# Requires: sudo access to write systemd units and create users/directories.
Expand Down Expand Up @@ -29,6 +29,7 @@ A2A_LOG_BODY_LIMIT_INPUT=""
DATA_ROOT_INPUT=""
OPENCODE_PROVIDER_ID_INPUT=""
OPENCODE_MODEL_ID_INPUT=""
OPENCODE_LSP_INPUT=""
REPO_URL_INPUT=""
REPO_BRANCH_INPUT=""
OPENCODE_TIMEOUT_INPUT=""
Expand Down Expand Up @@ -89,6 +90,9 @@ for arg in "$@"; do
opencode_model_id)
OPENCODE_MODEL_ID_INPUT="$value"
;;
opencode_lsp)
OPENCODE_LSP_INPUT="$value"
;;
repo_url)
REPO_URL_INPUT="$value"
;;
Expand Down Expand Up @@ -130,7 +134,7 @@ Usage:
GH_TOKEN=<token> A2A_BEARER_TOKEN=<token> [<PROVIDER_SECRET_ENV>=<key>] \
./scripts/deploy.sh project=<name> [data_root=<path>] [a2a_port=<port>] [a2a_host=<host>] [a2a_public_url=<url>] \
[a2a_streaming=<bool>] [a2a_log_level=<level>] [a2a_log_payloads=<bool>] [a2a_log_body_limit=<int>] \
[opencode_provider_id=<id>] [opencode_model_id=<id>] [repo_url=<url>] [repo_branch=<branch>] \
[opencode_provider_id=<id>] [opencode_model_id=<id>] [opencode_lsp=<bool>] [repo_url=<url>] [repo_branch=<branch>] \
[opencode_timeout=<seconds>] [opencode_timeout_stream=<seconds>] [git_identity_name=<name>] \
[git_identity_email=<email>] [update_a2a=true] [force_restart=true]

Expand All @@ -155,6 +159,7 @@ export_if_present() {

export_if_present "OPENCODE_PROVIDER_ID" "$OPENCODE_PROVIDER_ID_INPUT"
export_if_present "OPENCODE_MODEL_ID" "$OPENCODE_MODEL_ID_INPUT"
export_if_present "OPENCODE_LSP" "$OPENCODE_LSP_INPUT"
export_if_present "REPO_URL" "$REPO_URL_INPUT"
export_if_present "REPO_BRANCH" "$REPO_BRANCH_INPUT"
export_if_present "OPENCODE_TIMEOUT" "$OPENCODE_TIMEOUT_INPUT"
Expand All @@ -166,6 +171,7 @@ export_if_present "DATA_ROOT" "$DATA_ROOT_INPUT"
export OPENCODE_BIND_HOST="${OPENCODE_BIND_HOST:-127.0.0.1}"
export OPENCODE_LOG_LEVEL="${OPENCODE_LOG_LEVEL:-DEBUG}"
export OPENCODE_EXTRA_ARGS="${OPENCODE_EXTRA_ARGS:-}"
export OPENCODE_LSP="${OPENCODE_LSP:-false}"

if [[ -n "$A2A_HOST_INPUT" ]]; then
export A2A_HOST="$A2A_HOST_INPUT"
Expand Down
20 changes: 20 additions & 0 deletions scripts/deploy/run_opencode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ OPENCODE_BIND_PORT="${OPENCODE_BIND_PORT:-4096}"
OPENCODE_EXTRA_ARGS="${OPENCODE_EXTRA_ARGS:-}"
OPENCODE_PROVIDER_ID="${OPENCODE_PROVIDER_ID:-}"
OPENCODE_MODEL_ID="${OPENCODE_MODEL_ID:-}"
OPENCODE_LSP="${OPENCODE_LSP:-false}"
GOOGLE_GENERATIVE_AI_API_KEY="${GOOGLE_GENERATIVE_AI_API_KEY:-}"

if [[ ! -x "$OPENCODE_BIN" ]]; then
Expand All @@ -26,6 +27,25 @@ if [[ "$provider_lc" == "google" || "$model_lc" == *"gemini"* ]]; then
fi
fi

if [[ -z "${OPENCODE_CONFIG_CONTENT:-}" ]]; then
case "${OPENCODE_LSP,,}" in
1|true|yes|on)
lsp_json=true
;;
0|false|no|off|"")
lsp_json=false
;;
*)
echo "Invalid OPENCODE_LSP value: ${OPENCODE_LSP} (expected true/false)" >&2
exit 1
;;
esac
printf -v OPENCODE_CONFIG_CONTENT \
'{"$schema":"https://opencode.ai/config.json","lsp":%s}' \
"$lsp_json"
export OPENCODE_CONFIG_CONTENT
fi

cmd=("$OPENCODE_BIN" serve --log-level "$OPENCODE_LOG_LEVEL" --print-logs)

if [[ -n "$OPENCODE_BIND_HOST" ]]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/deploy/setup_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ opencode_env_tmp="$(mktemp)"
echo "OPENCODE_BIND_HOST=${OPENCODE_BIND_HOST}"
echo "OPENCODE_BIND_PORT=${OPENCODE_BIND_PORT}"
echo "OPENCODE_EXTRA_ARGS=${OPENCODE_EXTRA_ARGS:-}"
echo "OPENCODE_LSP=${OPENCODE_LSP:-false}"
echo "GH_TOKEN=${GH_TOKEN}"
echo "GIT_ASKPASS=${ASKPASS_SCRIPT}"
echo "GIT_ASKPASS_REQUIRE=force"
Expand Down
Loading
Loading