|
| 1 | +# Plan for opencode Dev Container Feature |
| 2 | + |
| 3 | +We will create a new devcontainer feature for `opencode` in `src/opencode`, modeling it after the `gemini-cli` feature but adapting it for the `opencode` installation method (`curl | bash`) and its specific persistence requirements. |
| 4 | + |
| 5 | +## 1. Structure |
| 6 | +We will create the following file structure: |
| 7 | +``` |
| 8 | +src/ |
| 9 | + opencode/ |
| 10 | + devcontainer-feature.json |
| 11 | + install.sh |
| 12 | +``` |
| 13 | + |
| 14 | +## 2. Configuration & Persistence (`devcontainer-feature.json`) |
| 15 | + |
| 16 | +**Note on Environment Variables:** |
| 17 | +The `opencode` install script (`https://opencode.ai/install`) hardcodes the binary installation path to `$HOME/.opencode/bin` and uses standard XDG logic for finding shell configuration files. It **does not** appear to expose environment variables (like `OPENCODE_HOME`) to override the locations of data, config, or cache directories at install time. |
| 18 | +Therefore, to ensure persistence for the user's specific paths, we will use **Docker Volumes** mounted to the standard XDG locations used by `opencode`. |
| 19 | + |
| 20 | +**Mounts:** |
| 21 | +We will define the following mounts to persist data across container rebuilds: |
| 22 | + |
| 23 | +1. **Credentials, History, Logs (`~/.local/share/opencode`):** |
| 24 | + - Source: `opencode-data` |
| 25 | + - Target: `/home/vscode/.local/share/opencode` (We will use `$_REMOTE_USER_HOME` in `install.sh` context, but `devcontainer-feature.json` targets are usually absolute or relative to user. We'll stick to standard user home or allow it to be dynamic if the feature supports it, but standard features often assume `/home/vscode` or use `${containerEnv:HOME}` if available, though `devcontainer-feature.json` mounts usually map to a fixed target or rely on the user being `vscode`. Actually, `devcontainer-feature.json` mounts are applied at container creation. We will target the standard paths). |
| 26 | + *Correction:* `devcontainer-feature.json` mount targets are absolute paths inside the container. We typically assume the standard user is `vscode` or `node`, but `opencode` installs to `$HOME`. We will map to `/home/vscode/...` for now as the most common default, but we should be aware of `remoteUser`. |
| 27 | + |
| 28 | + *Refinement:* The `gemini-cli` example uses `target: "/home/vscode/.gemini"`. We will follow that pattern for now. |
| 29 | + |
| 30 | + - **Mount 1:** `opencode-share` -> `/home/vscode/.local/share/opencode` |
| 31 | + - **Mount 2:** `opencode-config` -> `/home/vscode/.config/opencode` |
| 32 | + - **Mount 3:** `opencode-cache` -> `/home/vscode/.cache/opencode` |
| 33 | + |
| 34 | +## 3. Installation Logic (`install.sh`) |
| 35 | + |
| 36 | +The script will: |
| 37 | +1. Install necessary system dependencies (e.g., `curl`, `ca-certificates`, `tar` or `unzip` as required by the install script). |
| 38 | +2. Execute the installation command: `curl -fsSL https://opencode.ai/install | bash`. |
| 39 | + - We can pass `--version` if the user specifies a version in `devcontainer-feature.json` options. |
| 40 | +3. Ensure the `bin` directory (`$HOME/.opencode/bin`) is in the `PATH` (The install script tries to update rc files, but for devcontainers we often want to ensure it's in the global environment or `containerEnv`). |
| 41 | + - We will likely add `export PATH=$HOME/.opencode/bin:$PATH` to a profile script or rely on `containerEnv` in `devcontainer-feature.json`. |
| 42 | + - Actually, `devcontainer-feature.json` has `containerEnv`. We should add `PATH` modification there if possible, or just rely on the script. `gemini-cli` example sets `GEMINI_CONFIG_DIR` but relies on the install script/nanolayer for PATH? Nanolayer handles it. Here we might need to manually ensure it. |
| 43 | + - We will add `PATH: "/home/vscode/.opencode/bin:${PATH}"` to `containerEnv`. |
| 44 | + |
| 45 | +## 4. Execution Plan |
| 46 | +1. Create `src/opencode` directory. |
| 47 | +2. Write `src/opencode/install.sh`. |
| 48 | +3. Write `src/opencode/devcontainer-feature.json`. |
| 49 | +4. Add GitHub Action for automated publication (`.github/workflows/publish-features.yml`). |
| 50 | +5. Test the feature (if possible, or just verify file content). |
| 51 | + |
0 commit comments