@daytonaio/opencode 0.143.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/plugin/daytona/core/logger.d.ts +15 -0
- package/.opencode/plugin/daytona/core/logger.js +64 -0
- package/.opencode/plugin/daytona/core/logger.js.map +1 -0
- package/.opencode/plugin/daytona/core/project-data-storage.d.ts +42 -0
- package/.opencode/plugin/daytona/core/project-data-storage.js +171 -0
- package/.opencode/plugin/daytona/core/project-data-storage.js.map +1 -0
- package/.opencode/plugin/daytona/core/session-manager.d.ts +46 -0
- package/.opencode/plugin/daytona/core/session-manager.js +239 -0
- package/.opencode/plugin/daytona/core/session-manager.js.map +1 -0
- package/.opencode/plugin/daytona/core/toast.d.ts +47 -0
- package/.opencode/plugin/daytona/core/toast.js +73 -0
- package/.opencode/plugin/daytona/core/toast.js.map +1 -0
- package/.opencode/plugin/daytona/core/types.d.ts +53 -0
- package/.opencode/plugin/daytona/core/types.js +15 -0
- package/.opencode/plugin/daytona/core/types.js.map +1 -0
- package/.opencode/plugin/daytona/git/host-git-manager.d.ts +40 -0
- package/.opencode/plugin/daytona/git/host-git-manager.js +283 -0
- package/.opencode/plugin/daytona/git/host-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/git/index.d.ts +5 -0
- package/.opencode/plugin/daytona/git/index.js +10 -0
- package/.opencode/plugin/daytona/git/index.js.map +1 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.d.ts +14 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js +68 -0
- package/.opencode/plugin/daytona/git/sandbox-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/git/session-git-manager.d.ts +43 -0
- package/.opencode/plugin/daytona/git/session-git-manager.js +132 -0
- package/.opencode/plugin/daytona/git/session-git-manager.js.map +1 -0
- package/.opencode/plugin/daytona/index.d.ts +10 -0
- package/.opencode/plugin/daytona/index.js +44 -0
- package/.opencode/plugin/daytona/index.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js +26 -0
- package/.opencode/plugin/daytona/plugins/custom-tools.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/index.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/index.js +19 -0
- package/.opencode/plugin/daytona/plugins/index.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.d.ts +11 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.js +43 -0
- package/.opencode/plugin/daytona/plugins/session-cleanup.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js +54 -0
- package/.opencode/plugin/daytona/plugins/session-idle-auto-commit.js.map +1 -0
- package/.opencode/plugin/daytona/plugins/system-transform.d.ts +10 -0
- package/.opencode/plugin/daytona/plugins/system-transform.js +29 -0
- package/.opencode/plugin/daytona/plugins/system-transform.js.map +1 -0
- package/.opencode/plugin/daytona/tools/bash.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/bash.js +42 -0
- package/.opencode/plugin/daytona/tools/bash.js.map +1 -0
- package/.opencode/plugin/daytona/tools/edit.d.ts +21 -0
- package/.opencode/plugin/daytona/tools/edit.js +27 -0
- package/.opencode/plugin/daytona/tools/edit.js.map +1 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.js +21 -0
- package/.opencode/plugin/daytona/tools/get-preview-url.js.map +1 -0
- package/.opencode/plugin/daytona/tools/glob.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/glob.js +25 -0
- package/.opencode/plugin/daytona/tools/glob.js.map +1 -0
- package/.opencode/plugin/daytona/tools/grep.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/grep.js +25 -0
- package/.opencode/plugin/daytona/tools/grep.js.map +1 -0
- package/.opencode/plugin/daytona/tools/ls.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/ls.js +26 -0
- package/.opencode/plugin/daytona/tools/ls.js.map +1 -0
- package/.opencode/plugin/daytona/tools/lsp.d.ts +21 -0
- package/.opencode/plugin/daytona/tools/lsp.js +21 -0
- package/.opencode/plugin/daytona/tools/lsp.js.map +1 -0
- package/.opencode/plugin/daytona/tools/multiedit.d.ts +25 -0
- package/.opencode/plugin/daytona/tools/multiedit.js +31 -0
- package/.opencode/plugin/daytona/tools/multiedit.js.map +1 -0
- package/.opencode/plugin/daytona/tools/patch.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/patch.js +19 -0
- package/.opencode/plugin/daytona/tools/patch.js.map +1 -0
- package/.opencode/plugin/daytona/tools/read.d.ts +17 -0
- package/.opencode/plugin/daytona/tools/read.js +22 -0
- package/.opencode/plugin/daytona/tools/read.js.map +1 -0
- package/.opencode/plugin/daytona/tools/write.d.ts +19 -0
- package/.opencode/plugin/daytona/tools/write.js +22 -0
- package/.opencode/plugin/daytona/tools/write.js.map +1 -0
- package/.opencode/plugin/daytona/tools.d.ts +129 -0
- package/.opencode/plugin/daytona/tools.js +38 -0
- package/.opencode/plugin/daytona/tools.js.map +1 -0
- package/.opencode/plugin/index.d.ts +9 -0
- package/.opencode/plugin/index.js +13 -0
- package/.opencode/plugin/index.js.map +1 -0
- package/README.md +219 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Daytona Sandbox Plugin for OpenCode
|
|
2
|
+
|
|
3
|
+
This is an OpenCode plugin that automatically runs OpenCode sessions in Daytona sandboxes. Each session has its own remote sandbox which is automatically synced to a local git branch.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Securely isolate each OpenCode session in a sandbox environment
|
|
8
|
+
- Preserves sandbox environments indefinitely until the OpenCode session is deleted
|
|
9
|
+
- Generates live preview links when a server starts in the sandbox
|
|
10
|
+
- Synchronizes each OpenCode session to a local git branch
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
To add the plugin to a project, edit `opencode.json` in the project directory:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"$schema": "https://opencode.ai/config.json",
|
|
21
|
+
"plugin": ["@daytonaio/opencode"]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Now that the Daytona plugin is in the plugins list, it will automatically be downloaded when OpenCode starts.
|
|
26
|
+
|
|
27
|
+
To install the plugin globally, edit `~/.config/opencode/opencode.json`.
|
|
28
|
+
|
|
29
|
+
### Environment Configuration
|
|
30
|
+
|
|
31
|
+
This plugin requires a [Daytona account](https://www.daytona.io/) and [Daytona API key](https://app.daytona.io/dashboard/keys) to create sandboxes.
|
|
32
|
+
|
|
33
|
+
Set your Daytona API key and URL as environment variables:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export DAYTONA_API_KEY="your-api-key"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or create a `.env` file in your project root:
|
|
40
|
+
|
|
41
|
+
```env
|
|
42
|
+
DAYTONA_API_KEY=your-api-key
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Running OpenCode
|
|
46
|
+
|
|
47
|
+
Before starting OpenCode, ensure that your project is a git repository:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Now start OpenCode in your project using the OpenCode command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
opencode
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
To check that the plugin is working, type `pwd` in the chat. You should see a response like `/home/daytona/project`, and a toast notification that a new sandbox was created.
|
|
60
|
+
|
|
61
|
+
OpenCode will create new branches using the format `opencode/1`, `opencode/2`, etc. To work with these changes, use normal git commands in a separate terminal window. List branches:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
git branch
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Check out OpenCode's latest changes on your local system:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
git checkout [branch]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To view live logs from the plugin for debugging, run this command in a separate terminal:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
tail -f ~/.local/share/opencode/log/daytona.log
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## How It Works
|
|
80
|
+
|
|
81
|
+
### File Synchronization
|
|
82
|
+
|
|
83
|
+
The plugin uses git to synchronize files between the sandbox and your local system. This happens automatically and in the background, keeping your copy of the code up-to-date without exposing your system to the agent.
|
|
84
|
+
|
|
85
|
+
#### Sandbox Setup
|
|
86
|
+
|
|
87
|
+
When a new Daytona sandbox is created:
|
|
88
|
+
|
|
89
|
+
1. The plugin looks for a git repository in the local directory. If none is found, file synchronization will be disabled.
|
|
90
|
+
2. A parallel repository is created in the sandbox with a single `opencode` branch, mirroring the checked out local branch.
|
|
91
|
+
3. A new `sandbox` remote is added to the local repository using an SSH connection to the sandbox.
|
|
92
|
+
4. The `HEAD` of the local repository is pushed to `opencode`, and the sandbox repository is reset to match this initial state.
|
|
93
|
+
5. Each sandbox is assigned a unique incrementing branch number (1, 2, 3, etc.) that persists across sessions.
|
|
94
|
+
|
|
95
|
+
#### Synchronization
|
|
96
|
+
|
|
97
|
+
Each time the agent makes changes:
|
|
98
|
+
|
|
99
|
+
1. A new commit is created in the sandbox repository on the `opencode` branch.
|
|
100
|
+
2. The plugin pulls the latest commits from the sandbox remote into a unique local branch named `opencode/1`, `opencode/2`, etc. This keeps both environments in sync while isolating changes from different sandboxes in separate local branches.
|
|
101
|
+
|
|
102
|
+
The plugin only synchronizes changes from the sandbox to your system. To pass local changes to the agent, commit them to a local branch, and start a new OpenCode session with that branch checked out.
|
|
103
|
+
|
|
104
|
+
> [!CAUTION]
|
|
105
|
+
> When changes are synchronized to local `opencode` branches, any locally made changes will be overwritten.
|
|
106
|
+
|
|
107
|
+
### Session to sandbox mapping
|
|
108
|
+
|
|
109
|
+
The plugin keeps track of which sandbox belongs to each OpenCode project using local state files. This data is stored in a separate JSON file for each project:
|
|
110
|
+
|
|
111
|
+
- On macOS: `~/.local/share/opencode/storage/daytona/[projectid].json`.
|
|
112
|
+
- On Windows: `%LOCALAPPDATA%\opencode\storage\daytona\[projectid].json`.
|
|
113
|
+
|
|
114
|
+
Each JSON file contains the sandbox metadata for each session in the project, including when the sandbox was created, and when it was last used.
|
|
115
|
+
|
|
116
|
+
The plugin uses [XDG Base Directory](https://specifications.freedesktop.org/basedir/latest/) specifically to resolve the path to this directory, using the convention [set by OpenCode](https://github.com/anomalyco/opencode/blob/052f887a9a7aaf79d9f1a560f9b686d59faa8348/packages/opencode/src/global/index.ts#L8).
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
This plugin is part of the Daytona monorepo.
|
|
121
|
+
|
|
122
|
+
### Setup
|
|
123
|
+
|
|
124
|
+
First, clone the Daytona monorepo:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/daytonaio/daytona
|
|
128
|
+
cd daytona
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Install dependencies:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
yarn install
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Development and Testing
|
|
138
|
+
|
|
139
|
+
To modify the plugin, edit the source code files in `libs/opencode-plugin/.opencode`.
|
|
140
|
+
|
|
141
|
+
To test the OpenCode plugin, create a test project to run OpenCode in:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
mkdir ~/myproject
|
|
145
|
+
cd myproject
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Add a symlink from the project directory to the plugin source code:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
ln -s [ABSOLUTE_PATH_TO_DAYTONA]/libs/opencode-plugin/.opencode .opencode
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Initialize git to enable file syncing:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
git init
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Start OpenCode in the test project:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
opencode
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Use the instructions from [Running OpenCode](#running-opencode) above to check that the plugin is running and view live logs for debugging.
|
|
167
|
+
|
|
168
|
+
> [!NOTE]
|
|
169
|
+
> When developing locally with a symlink, OpenCode loads the TypeScript source directly, so no build step is required.
|
|
170
|
+
|
|
171
|
+
### Building
|
|
172
|
+
|
|
173
|
+
Build the plugin:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npx nx run opencode-plugin:build
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This compiles the TypeScript source files in `.opencode/` to JavaScript in `dist/.opencode/`.
|
|
180
|
+
|
|
181
|
+
### Publishing
|
|
182
|
+
|
|
183
|
+
Log into npm:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm login
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Publish the compiled JavaScript package to npm:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npx nx run opencode-plugin:publish
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This will publish to npm with public access and use the version number from `package.json`.
|
|
196
|
+
|
|
197
|
+
## Project Structure
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
libs/opencode-plugin/
|
|
201
|
+
├── .opencode/ # Source TypeScript files
|
|
202
|
+
│ ├── plugin/
|
|
203
|
+
│ │ ├── daytona/ # Main Daytona integration
|
|
204
|
+
│ │ │ └── ...
|
|
205
|
+
│ │ └── index.ts # Plugin entry point
|
|
206
|
+
├── dist/ # Build output
|
|
207
|
+
│ └── .opencode/ # Compiled JavaScript files
|
|
208
|
+
├── .gitignore
|
|
209
|
+
├── .npmignore
|
|
210
|
+
├── package.json # Package metadata (includes main/types)
|
|
211
|
+
├── project.json # Nx build configuration
|
|
212
|
+
├── tsconfig.json # TypeScript config
|
|
213
|
+
├── tsconfig.lib.json # TypeScript config for library build
|
|
214
|
+
└── README.md
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
Apache-2.0
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daytonaio/opencode",
|
|
3
|
+
"version": "0.143.0",
|
|
4
|
+
"description": "OpenCode plugin that automatically runs all sessions in Daytona sandboxes for isolated, reproducible development environments",
|
|
5
|
+
"main": "./.opencode/plugin/index.js",
|
|
6
|
+
"types": "./.opencode/plugin/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
".opencode"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/daytonaio/daytona.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Daytona Platforms Inc.",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@aws-sdk/client-s3": "^3.787.0",
|
|
18
|
+
"@aws-sdk/lib-storage": "^3.798.0",
|
|
19
|
+
"@daytonaio/sdk": "^0.125.0",
|
|
20
|
+
"@iarna/toml": "^2.2.5",
|
|
21
|
+
"@opencode-ai/plugin": "1.1.59",
|
|
22
|
+
"@opentelemetry/api": "^1.9.0",
|
|
23
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.207.0",
|
|
24
|
+
"@opentelemetry/instrumentation-http": "^0.207.0",
|
|
25
|
+
"@opentelemetry/otlp-exporter-base": "0.207.0",
|
|
26
|
+
"@opentelemetry/resources": "2.2.0",
|
|
27
|
+
"@opentelemetry/sdk-node": "^0.207.0",
|
|
28
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
29
|
+
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
30
|
+
"axios": "^1.13.5",
|
|
31
|
+
"busboy": "^1.0.0",
|
|
32
|
+
"dotenv": "^17.0.1",
|
|
33
|
+
"expand-tilde": "^2.0.2",
|
|
34
|
+
"fast-glob": "^3.3.0",
|
|
35
|
+
"form-data": "^4.0.4",
|
|
36
|
+
"isomorphic-ws": "^5.0.0",
|
|
37
|
+
"pathe": "^2.0.3",
|
|
38
|
+
"shell-quote": "^1.8.2",
|
|
39
|
+
"tar": "^7.5.7",
|
|
40
|
+
"xdg-basedir": "^5.1.0",
|
|
41
|
+
"zod": "^4.2.1",
|
|
42
|
+
"@daytonaio/api-client": "0.143.0",
|
|
43
|
+
"@daytonaio/toolbox-api-client": "0.143.0"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/daytonaio/daytona/issues"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"daytona",
|
|
50
|
+
"opencode",
|
|
51
|
+
"plugin"
|
|
52
|
+
],
|
|
53
|
+
"packageManager": "yarn@4.6.0",
|
|
54
|
+
"type": "commonjs"
|
|
55
|
+
}
|