create-openthrottle 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/index.mjs +32 -33
  2. package/package.json +2 -2
package/index.mjs CHANGED
@@ -5,10 +5,10 @@
5
5
  // Usage: npx create-openthrottle
6
6
  //
7
7
  // Detects the project, prompts for config, generates .openthrottle.yml +
8
- // wake-sandbox.yml, copies Daytona runtime files, and prints next steps.
8
+ // wake-sandbox.yml, creates a Daytona snapshot from GHCR, and prints next steps.
9
9
  // =============================================================================
10
10
 
11
- import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, readdirSync, statSync } from 'node:fs';
11
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync } from 'node:fs';
12
12
  import { join, dirname } from 'node:path';
13
13
  import { execFileSync } from 'node:child_process';
14
14
  import { fileURLToPath } from 'node:url';
@@ -165,31 +165,38 @@ function copyWorkflow() {
165
165
  }
166
166
 
167
167
  // ---------------------------------------------------------------------------
168
- // 5. Copy Daytona runtime files
168
+ // 5. Create Daytona snapshot from pre-built GHCR image
169
169
  // ---------------------------------------------------------------------------
170
170
 
171
171
  function setupDaytona(config) {
172
172
  const snapshotName = config.snapshotName || 'openthrottle';
173
+ const image = 'ghcr.io/knoxgraeme/openthrottle:latest';
173
174
 
174
- // Copy Dockerfile + runtime scripts into user's project
175
- const dockerDir = join(cwd, '.openthrottle', 'docker');
176
- mkdirSync(dockerDir, { recursive: true });
177
-
178
- const templateDir = join(__dirname, 'templates', 'docker');
179
- if (existsSync(templateDir)) {
180
- for (const file of readdirSync(templateDir, { recursive: true })) {
181
- const src = join(templateDir, file);
182
- const dest = join(dockerDir, file);
183
- const stat = statSync(src);
184
- if (stat.isDirectory()) {
185
- mkdirSync(dest, { recursive: true });
186
- } else {
187
- mkdirSync(dirname(dest), { recursive: true });
188
- copyFileSync(src, dest);
189
- }
175
+ // Check daytona CLI is available
176
+ try {
177
+ execFileSync('daytona', ['--version'], { stdio: 'pipe' });
178
+ } catch {
179
+ console.log(`\n daytona CLI not found. Install it, then run:`);
180
+ console.log(` daytona snapshot create ${snapshotName} --image ${image} --cpu 2 --memory 4 --disk 10\n`);
181
+ return { snapshotName, skipped: true };
182
+ }
183
+
184
+ // Create snapshot from pre-built image
185
+ try {
186
+ execFileSync('daytona', [
187
+ 'snapshot', 'create', snapshotName,
188
+ '--image', image,
189
+ '--cpu', '2', '--memory', '4', '--disk', '10',
190
+ ], { stdio: 'inherit' });
191
+ console.log(` ✓ Created Daytona snapshot: ${snapshotName}`);
192
+ } catch (err) {
193
+ if (err.stderr?.toString().includes('already exists')) {
194
+ console.log(` ✓ Snapshot already exists: ${snapshotName}`);
195
+ } else {
196
+ console.log(` ✗ Snapshot creation failed. You can create it manually:`);
197
+ console.log(` daytona snapshot create ${snapshotName} --image ${image} --cpu 2 --memory 4 --disk 10`);
190
198
  }
191
199
  }
192
- console.log(' ✓ Copied Dockerfile + runtime to .openthrottle/docker/');
193
200
 
194
201
  return { snapshotName };
195
202
  }
@@ -210,28 +217,20 @@ function printNextSteps(config) {
210
217
  agentSecret,
211
218
  ];
212
219
 
213
- const snapshotName = config.snapshotName || 'openthrottle';
214
-
215
220
  console.log(`
216
221
  Next steps:
217
222
 
218
- 1. Create your Daytona snapshot:
219
- cd .openthrottle/docker
220
- daytona snapshot create ${snapshotName} \\
221
- --dockerfile ./Dockerfile --context . \\
222
- --cpu 2 --memory 4 --disk 10
223
-
224
- 2. Set GitHub repo secrets:
223
+ 1. Set GitHub repo secrets:
225
224
  ${secrets.join('\n')}
226
225
  TELEGRAM_BOT_TOKEN ← optional (notifications)
227
226
  TELEGRAM_CHAT_ID ← optional (notifications)
228
227
 
229
- 3. Commit and push:
228
+ 2. Commit and push:
230
229
  git add .openthrottle.yml .github/workflows/wake-sandbox.yml
231
230
  git commit -m "feat: add openthrottle config"
232
231
  git push
233
232
 
234
- 4. Ship your first prompt:
233
+ 3. Ship your first prompt:
235
234
  gh issue create --title "My first feature" \\
236
235
  --body-file docs/prds/my-feature.md \\
237
236
  --label prd-queued
@@ -279,10 +278,10 @@ async function main() {
279
278
  console.log(' ✓ Copied .github/workflows/wake-sandbox.yml');
280
279
  }
281
280
 
282
- // Step 5: Copy Daytona runtime files
281
+ // Step 5: Create Daytona snapshot
283
282
  setupDaytona(config);
284
283
 
285
- // Step 7: Next steps
284
+ // Step 6: Next steps
286
285
  printNextSteps(config);
287
286
  }
288
287
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-openthrottle",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Set up openthrottle in any Node.js project — agent-agnostic, config-driven.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "https://github.com/knoxgraeme/sodaprompts"
23
+ "url": "https://github.com/knoxgraeme/openthrottle"
24
24
  },
25
25
  "keywords": [
26
26
  "openthrottle",