@jamesmurdza/opencode-daytona 0.1.14 → 0.1.15
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/package.json +1 -1
- package/README.md +0 -192
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# Daytona Sandbox Plugin for OpenCode
|
|
2
|
-
|
|
3
|
-
This is an OpenCode plugin that automatically runs all your OpenCode sessions in Daytona sandboxes. This provides isolated, reproducible development environments for your AI coding sessions.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Securely isolate each OpenCode session in a sandbox environment
|
|
8
|
-
- Automatically generates live preview links to applications or servers running in the sandbox
|
|
9
|
-
- Synchronizes changes made within the sandbox to the current git repository
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
14
|
-
|
|
15
|
-
You can install this extension globally or within a specific project.
|
|
16
|
-
|
|
17
|
-
To install it globally, edit `~/.config/opencode/opencode.json`. To install for a specific project, add it to `opencode.json` in the project's root directory.
|
|
18
|
-
|
|
19
|
-
Adding this extension to the plugins field will install it automatically when OpenCode starts:
|
|
20
|
-
|
|
21
|
-
```json
|
|
22
|
-
{
|
|
23
|
-
"$schema": "https://opencode.ai/config.json",
|
|
24
|
-
"plugins": ["@jamesmurdza/opencode-daytona"]
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Environment Configuration
|
|
29
|
-
|
|
30
|
-
This extension requires a [Daytona account](https://www.daytona.io/) and [Daytona API key](https://app.daytona.io/dashboard/keys) to create sandboxes.
|
|
31
|
-
|
|
32
|
-
Set your Daytona API key and URL as environment variables:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
export DAYTONA_API_KEY="your-api-key"
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Or create a `.env` file in your project root:
|
|
39
|
-
|
|
40
|
-
```env
|
|
41
|
-
DAYTONA_API_KEY=your-api-key
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Running OpenCode
|
|
45
|
-
|
|
46
|
-
Start OpenCode in your project using the OpenCode command:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
opencode
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
OpenCode sessions running in Daytona sandboxes are not immediately distinguishable from local sessions. To ensure that the plugin is working, type `pwd` in the chat. If the response is `/home/daytona`, then the plugin is working correctly.
|
|
53
|
-
|
|
54
|
-
See branches created by OpenCode:
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
git branch
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Continue working with OpenCode's latest changes on your local system:
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
git checkout opencode/1
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
To see live logs for debugging, run this command in a separate terminal:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
tail -f ~/.local/share/.daytona-plugin.log
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## How It Works
|
|
73
|
-
|
|
74
|
-
### File Synchronization
|
|
75
|
-
|
|
76
|
-
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.
|
|
77
|
-
|
|
78
|
-
#### Sandbox Setup
|
|
79
|
-
|
|
80
|
-
When a new Daytona sandbox is created:
|
|
81
|
-
1. The plugin looks for a git repository in the local directory If none is found, it creates a new one.
|
|
82
|
-
2. In the sandbox, a parallel repository to the local repository is created in the sandbox. An `opencode` branch is created in the sandbox repository.
|
|
83
|
-
3. A new `sandbox` remote is added to the local repository using an SSH connection to the sandbox.
|
|
84
|
-
4. The `HEAD` of the local repository is pushed to `opencode`, and the sandbox repository is reset to match this initial state.
|
|
85
|
-
5. Each sandbox is assigned a unique incrementing branch number (1, 2, 3, etc.) that persists across sessions.
|
|
86
|
-
|
|
87
|
-
#### Synchronization
|
|
88
|
-
|
|
89
|
-
Each time the agent makes changes:
|
|
90
|
-
1. A new commit is created in the sandbox repository on the `opencode` branch.
|
|
91
|
-
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.
|
|
92
|
-
|
|
93
|
-
The above workflow only synchronizes changes from the sandbox to your local system. To apply changes made locally, it is recommend to start with a new OpenCode session (and sandbox).
|
|
94
|
-
|
|
95
|
-
### Session-sandbox data storage
|
|
96
|
-
|
|
97
|
-
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:
|
|
98
|
-
|
|
99
|
-
* On macOS: `~/.local/share/opencode/storage/daytona/[projectid].json`.
|
|
100
|
-
* On Windows: `%LOCALAPPDATA%\opencode\storage\daytona\[projectid].json`.
|
|
101
|
-
|
|
102
|
-
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.
|
|
103
|
-
|
|
104
|
-
The plugin uses [XDG Base Directory](https://specifications.freedesktop.org/basedir/latest/) specifical 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#L4).
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## Development
|
|
108
|
-
|
|
109
|
-
This plugin is part of the Daytona monorepo.
|
|
110
|
-
|
|
111
|
-
### Setup
|
|
112
|
-
|
|
113
|
-
First, clone the Daytona monorepo:
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
git clone -b feat/opencode-plugin https://github.com/jamesmurdza/daytona.git
|
|
117
|
-
git checkout feat/opencode-plugin
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Install dependencies:
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
yarn install
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Development and Testing
|
|
127
|
-
|
|
128
|
-
To modify the extension, edit the source code files in `libs/opencode-plugin/.opencode`.
|
|
129
|
-
|
|
130
|
-
To test the OpenCode extension, create a new directory to run OpenCode in:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
mkdir ~/myproject
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Use a symbolic link to install a development version of the plugin:
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
ln -s libs/opencode-plugin/.opencode ~/myproject
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Open OpenCode in the new directory:
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
cd ~/myproject && opencode
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Use the instructions from [Running OpenCode](#running-opencode) above to check that the plugin is running and view live logs for debugging.
|
|
149
|
-
|
|
150
|
-
> [!NOTE]
|
|
151
|
-
> Because OpenCode uses Bun, the TypeScript plugin is loaded directly without a build step.
|
|
152
|
-
|
|
153
|
-
### Publishing
|
|
154
|
-
|
|
155
|
-
Check for TypeScript errors before publishing:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npx nx run opencode-plugin:type-check
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
Log into npm:
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
npm login
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Publish the TypeScript package to npm:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npx nx publish opencode-plugin:
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
This will publish to npm with public access and use the version number from `package.json`.
|
|
174
|
-
|
|
175
|
-
## Project Structure
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
libs/opencode-plugin/
|
|
179
|
-
├── .opencode/
|
|
180
|
-
│ ├── plugin/
|
|
181
|
-
│ │ ├── daytona/ # Main Daytona integration
|
|
182
|
-
│ │ │ └── ...
|
|
183
|
-
│ │ └── index.ts # Plugin entry point
|
|
184
|
-
├── package.json # Package metadata
|
|
185
|
-
├── project.json # Nx build configuration
|
|
186
|
-
├── tsconfig.json # TypeScript config
|
|
187
|
-
└── README.md
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## License
|
|
191
|
-
|
|
192
|
-
Apache-2.0
|