diff --git a/roles/vhosts/acp_server_opencode/tasks/config.yml b/roles/vhosts/acp_server_opencode/tasks/config.yml index 368f031..d4b992e 100644 --- a/roles/vhosts/acp_server_opencode/tasks/config.yml +++ b/roles/vhosts/acp_server_opencode/tasks/config.yml @@ -79,6 +79,29 @@ - "{{ acp_opencode_home }}/.local" - "{{ acp_opencode_workdir }}" +# Resolve the OpenCode CLI at deploy time instead of assuming a fixed path. +# npm installs it wherever the active node prefix points (NodeSource -> /usr/bin +# on Debian/Ubuntu, ~/.local/bin or Homebrew on macOS), so probe the real path +# with the role PATH and fall back to the OS-aware default when not yet present. +- name: Resolve OpenCode CLI binary path + ansible.builtin.shell: | + set -eu + export PATH="{{ acp_opencode_path }}:${PATH}" + command -v opencode || true + args: + executable: /bin/bash + register: acp_opencode_resolved_bin + changed_when: false + +- name: Use resolved OpenCode CLI binary path when present + ansible.builtin.set_fact: + acp_opencode_binary_path: "{{ acp_opencode_resolved_bin.stdout_lines[0] | trim }}" + when: acp_opencode_resolved_bin.stdout | default('') | trim | length > 0 + +- name: Report effective OpenCode CLI binary path + ansible.builtin.debug: + msg: "OpenCode CLI binary resolved to: {{ acp_opencode_binary_path }}" + - name: Deploy Caddy main file ansible.builtin.template: src: Caddyfile.j2 diff --git a/roles/vhosts/acp_server_opencode/templates/acp-bridge.service.j2 b/roles/vhosts/acp_server_opencode/templates/acp-bridge.service.j2 deleted file mode 100644 index 293a963..0000000 --- a/roles/vhosts/acp_server_opencode/templates/acp-bridge.service.j2 +++ /dev/null @@ -1,27 +0,0 @@ -[Unit] -Description=XWorkmate OpenCode ACP bridge server -After=network-online.target {{ acp_opencode_service_name }}.service -Wants=network-online.target - -[Service] -Type=simple -User={{ acp_opencode_service_user }} -Group={{ acp_opencode_service_group }} -WorkingDirectory={{ acp_opencode_workdir }} -Environment=HOME={{ acp_opencode_home }} -Environment=TERM=xterm-256color -Environment=ACP_LISTEN_ADDR={{ acp_opencode_bridge_listen_host }}:{{ acp_opencode_bridge_listen_port }} -Environment=ACP_ALLOWED_ORIGINS={{ acp_opencode_bridge_allowed_origins | join(',') }} -{% if acp_opencode_auth_token | trim | length > 0 %} -Environment=ACP_AUTH_TOKEN={{ acp_opencode_auth_token }} -{% endif %} -Environment=ACP_CODEX_BIN={{ acp_opencode_bridge_disabled_binary_path }} -Environment=ACP_CLAUDE_BIN={{ acp_opencode_bridge_disabled_binary_path }} -Environment=ACP_GEMINI_BIN={{ acp_opencode_bridge_disabled_binary_path }} -Environment=ACP_OPENCODE_BIN={{ acp_opencode_bridge_opencode_binary_path }} -ExecStart={{ acp_opencode_bridge_binary_path }} serve --listen {{ acp_opencode_bridge_listen_host }}:{{ acp_opencode_bridge_listen_port }} -Restart=always -RestartSec=2 - -[Install] -WantedBy=multi-user.target diff --git a/roles/vhosts/acp_server_opencode/templates/opencode.plist.j2 b/roles/vhosts/acp_server_opencode/templates/opencode.plist.j2 index 716ead6..3a4997f 100644 --- a/roles/vhosts/acp_server_opencode/templates/opencode.plist.j2 +++ b/roles/vhosts/acp_server_opencode/templates/opencode.plist.j2 @@ -17,6 +17,7 @@ exec "{{ acp_opencode_bridge_binary_path }}" adapter opencode \ -listen {{ acp_opencode_listen_host }}:{{ acp_opencode_listen_port }} \ + -opencode-bin "{{ acp_opencode_binary_path }}" \ -cwd "{{ acp_opencode_workdir }}"