diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ad4c73b..ef598d1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,8 +18,10 @@ } }, "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/wcgomes/devcontainer-features/opencode:0": {}, + "ghcr.io/wcgomes/devcontainer-features/agency-agents:0": {} }, "remoteUser": "node", "updateContentCommand": "npm install -g @devcontainers/cli" -} +} \ No newline at end of file diff --git a/src/opencode/README.md b/src/opencode/README.md index b740922..fe3cccf 100644 --- a/src/opencode/README.md +++ b/src/opencode/README.md @@ -16,6 +16,7 @@ Installs the opencode AI coding agent CLI and ensures volume-mounted data direct | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| | username | Username to install opencode for. Defaults to _REMOTE_USER (the container's remote user). | string | - | +| installVscodePlugin | Install the opencode VS Code extension. | boolean | true | | version | Version to install (e.g. 1.3.17). Empty = latest. | string | - | diff --git a/src/opencode/devcontainer-feature.json b/src/opencode/devcontainer-feature.json index 46a0b23..286c4f2 100644 --- a/src/opencode/devcontainer-feature.json +++ b/src/opencode/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "opencode CLI", "id": "opencode", - "version": "0.2.3", + "version": "0.2.4", "description": "Installs the opencode AI coding agent CLI and ensures volume-mounted data directories are owned by the correct user.", "documentationURL": "https://opencode.ai", "options": { @@ -10,6 +10,11 @@ "default": "", "description": "Username to install opencode for. Defaults to _REMOTE_USER (the container's remote user)." }, + "installVscodePlugin": { + "type": "boolean", + "default": true, + "description": "Install the opencode VS Code extension." + }, "version": { "type": "string", "default": "", diff --git a/src/opencode/install.sh b/src/opencode/install.sh index f91c05c..3b4012d 100644 --- a/src/opencode/install.sh +++ b/src/opencode/install.sh @@ -73,6 +73,30 @@ ensure_prerequisites() { [ -f /etc/ssl/certs/ca-certificates.crt ] || fail "Falha na instalação de dependências: certificados CA ainda estão ausentes" } +install_vscode_extension() { + local user="$1" + local vscode_cmd="" + + if command -v code >/dev/null 2>&1; then + vscode_cmd="code" + elif [ -x "/usr/bin/code" ]; then + vscode_cmd="/usr/bin/code" + fi + + if [ -z "$vscode_cmd" ]; then + log "VS Code não encontrado. Pulando instalação da extensão." + return 0 + fi + + log "Instalando extensão VS Code opencode..." + + if su "$user" -c "$vscode_cmd --install-extension sst-dev.opencode --force" 2>/dev/null; then + log "Extensão VS Code instalada com sucesso." + else + log "Falha ao instalar extensão VS Code." + fi +} + USERNAME="${USERNAME:-"${_REMOTE_USER:-vscode}"}" USER_HOME="${_REMOTE_USER_HOME:-"/home/${USERNAME}"}" VERSION="${VERSION:-}" @@ -114,6 +138,10 @@ su "$USERNAME" -c "curl -fsSL https://opencode.ai/install | bash -s -- --no-modi ln -s "${USER_HOME}/.opencode/bin/opencode" /usr/local/bin/opencode +if [ "${INSTALLVSCODEPLUGIN:-true}" = "true" ]; then + install_vscode_extension "$USERNAME" +fi + log "Criando diretórios para volumes persistentes..." mkdir -p "${USER_HOME}/.config/opencode"