Skip to content

Commit 8ce36e9

Browse files
committed
feat(opencode): add session state persistence and documentation
- Added volume mount for ~/.local/state/opencode to persist prompt history and model configuration - Updated install.sh to ensure ~/.local/state/opencode exists with correct user permissions - Bumped feature version to 1.0.4 - Created README.md with usage instructions and note on custom user support
1 parent 214285b commit 8ce36e9

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/opencode/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# OpenCode Dev Container Feature
2+
3+
Installs [OpenCode](https://opencode.ai) with persistent configuration and session history.
4+
5+
## Features
6+
- Installs the `opencode` CLI.
7+
- Automatically persists:
8+
- Authentication (`~/.local/share/opencode/auth.json`)
9+
- Session history and storage (`~/.local/share/opencode/storage`)
10+
- Global configuration (`~/.config/opencode`)
11+
- Prompt history and state (`~/.local/state/opencode`)
12+
- Cache (`~/.cache/opencode`)
13+
14+
## Usage
15+
Add this feature to your `devcontainer.json`:
16+
17+
```json
18+
{
19+
"features": {
20+
"ghcr.io/zendril/features/opencode:1": {}
21+
}
22+
}
23+
```
24+
25+
## Options
26+
- `version`: Specify the version of OpenCode to install (default: `latest`).
27+
28+
## Note on Custom Users
29+
Currently, the persistence mounts are hardcoded to `/home/vscode`. If you are using a custom user (e.g., `ubuntu` or a custom username) and need persistence for that user, please open a GitHub issue. We have a planned implementation for dynamic symlinking to support non-standard home directories but have not enabled it yet.

src/opencode/devcontainer-feature.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "opencode",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"name": "OpenCode",
55
"documentationURL": "https://opencode.ai/docs/",
66
"description": "Installs OpenCode (opencode.ai) with persistent configuration",
@@ -29,6 +29,11 @@
2929
"source": "opencode-cache",
3030
"target": "/home/vscode/.cache/opencode",
3131
"type": "volume"
32+
},
33+
{
34+
"source": "opencode-state",
35+
"target": "/home/vscode/.local/state/opencode",
36+
"type": "volume"
3237
}
3338
],
3439
"containerEnv": {

src/opencode/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ su - "$USERNAME" -c "curl -fsSL https://opencode.ai/install | bash -s -- ${VERSI
3030
mkdir -p "$USER_HOME/.local/share/opencode"
3131
mkdir -p "$USER_HOME/.config/opencode"
3232
mkdir -p "$USER_HOME/.cache/opencode"
33-
mkdir -p "$USER_HOME/.local/state"
33+
mkdir -p "$USER_HOME/.local/state/opencode"
3434

3535
chown -R "$USERNAME:$USERNAME" "$USER_HOME/.local/share/opencode"
3636
chown -R "$USERNAME:$USERNAME" "$USER_HOME/.config/opencode"

0 commit comments

Comments
 (0)