create-openthrottle 1.0.0 → 1.2.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/index.mjs +36 -79
- package/package.json +1 -2
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Usage: npx create-openthrottle
|
|
6
6
|
//
|
|
7
7
|
// Detects the project, prompts for config, generates .openthrottle.yml +
|
|
8
|
-
// wake-sandbox.yml,
|
|
8
|
+
// wake-sandbox.yml, copies Daytona runtime files, and prints next steps.
|
|
9
9
|
// =============================================================================
|
|
10
10
|
|
|
11
11
|
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, readdirSync, statSync } from 'node:fs';
|
|
@@ -14,7 +14,6 @@ import { execFileSync } from 'node:child_process';
|
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
import prompts from 'prompts';
|
|
16
16
|
import { stringify } from 'yaml';
|
|
17
|
-
import { Daytona } from '@daytonaio/sdk';
|
|
18
17
|
|
|
19
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
19
|
const cwd = process.cwd();
|
|
@@ -108,14 +107,7 @@ async function promptConfig(detected) {
|
|
|
108
107
|
type: (prev) => prev ? 'number' : null,
|
|
109
108
|
name: 'maxRounds', message: 'Max review rounds', initial: 3, min: 1, max: 10,
|
|
110
109
|
},
|
|
111
|
-
{
|
|
112
|
-
type: 'select', name: 'snapshotMode', message: 'Snapshot source',
|
|
113
|
-
choices: [
|
|
114
|
-
{ title: 'Pre-built image (faster, recommended)', value: 'image' },
|
|
115
|
-
{ title: 'Build from Dockerfile (customizable)', value: 'dockerfile' },
|
|
116
|
-
],
|
|
117
|
-
initial: 0,
|
|
118
|
-
},
|
|
110
|
+
{ type: 'text', name: 'snapshotName', message: 'Daytona snapshot name', initial: 'openthrottle' },
|
|
119
111
|
], { onCancel: () => { console.log('\nCancelled.'); process.exit(0); } });
|
|
120
112
|
|
|
121
113
|
return { ...detected, ...response };
|
|
@@ -135,7 +127,7 @@ function generateConfig(config) {
|
|
|
135
127
|
build: config.build || undefined,
|
|
136
128
|
notifications: config.notifications === 'none' ? undefined : config.notifications,
|
|
137
129
|
agent: config.agent,
|
|
138
|
-
snapshot:
|
|
130
|
+
snapshot: config.snapshotName || 'openthrottle',
|
|
139
131
|
post_bootstrap: [config.postBootstrap],
|
|
140
132
|
mcp_servers: {},
|
|
141
133
|
review: {
|
|
@@ -173,76 +165,33 @@ function copyWorkflow() {
|
|
|
173
165
|
}
|
|
174
166
|
|
|
175
167
|
// ---------------------------------------------------------------------------
|
|
176
|
-
// 5
|
|
168
|
+
// 5. Copy Daytona runtime files
|
|
177
169
|
// ---------------------------------------------------------------------------
|
|
178
170
|
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
mkdirSync(dockerDir, { recursive: true });
|
|
195
|
-
|
|
196
|
-
const templateDir = join(__dirname, 'templates', 'docker');
|
|
197
|
-
if (existsSync(templateDir)) {
|
|
198
|
-
for (const file of readdirSync(templateDir, { recursive: true })) {
|
|
199
|
-
const src = join(templateDir, file);
|
|
200
|
-
const dest = join(dockerDir, file);
|
|
201
|
-
const stat = statSync(src);
|
|
202
|
-
if (stat.isDirectory()) {
|
|
203
|
-
mkdirSync(dest, { recursive: true });
|
|
204
|
-
} else {
|
|
205
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
206
|
-
copyFileSync(src, dest);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
console.log(' ✓ Copied Dockerfile + runtime to .openthrottle/docker/');
|
|
211
|
-
console.log(' Customize the Dockerfile, then create snapshot:');
|
|
212
|
-
console.log(` daytona snapshot create ${snapshotName} --dockerfile .openthrottle/docker/Dockerfile --build-arg AGENT=${config.agent}`);
|
|
213
|
-
} else {
|
|
214
|
-
const image = `ghcr.io/openthrottle/doer-${config.agent}:node-1.0.0`;
|
|
215
|
-
try {
|
|
216
|
-
await daytona.snapshot.create({
|
|
217
|
-
name: snapshotName,
|
|
218
|
-
image,
|
|
219
|
-
resources: { cpu: 2, memory: 4, disk: 10 },
|
|
220
|
-
});
|
|
221
|
-
console.log(` ✓ Created Daytona snapshot: ${snapshotName}`);
|
|
222
|
-
} catch (err) {
|
|
223
|
-
if (err.status === 409 || err.message?.includes('already exists')) {
|
|
224
|
-
console.log(` ✓ Snapshot already exists: ${snapshotName}`);
|
|
171
|
+
function setupDaytona(config) {
|
|
172
|
+
const snapshotName = config.snapshotName || 'openthrottle';
|
|
173
|
+
|
|
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 });
|
|
225
186
|
} else {
|
|
226
|
-
|
|
227
|
-
|
|
187
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
188
|
+
copyFileSync(src, dest);
|
|
228
189
|
}
|
|
229
190
|
}
|
|
230
191
|
}
|
|
192
|
+
console.log(' ✓ Copied Dockerfile + runtime to .openthrottle/docker/');
|
|
231
193
|
|
|
232
|
-
|
|
233
|
-
try {
|
|
234
|
-
await daytona.volume.create({ name: volumeName });
|
|
235
|
-
console.log(` ✓ Created Daytona volume: ${volumeName}`);
|
|
236
|
-
} catch (err) {
|
|
237
|
-
if (err.status === 409 || err.message?.includes('already exists')) {
|
|
238
|
-
console.log(` ✓ Volume already exists: ${volumeName}`);
|
|
239
|
-
} else {
|
|
240
|
-
console.error(` ✗ Failed to create volume: ${err.message}`);
|
|
241
|
-
process.exit(1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return { snapshotName, volumeName };
|
|
194
|
+
return { snapshotName };
|
|
246
195
|
}
|
|
247
196
|
|
|
248
197
|
// ---------------------------------------------------------------------------
|
|
@@ -261,20 +210,28 @@ function printNextSteps(config) {
|
|
|
261
210
|
agentSecret,
|
|
262
211
|
];
|
|
263
212
|
|
|
213
|
+
const snapshotName = config.snapshotName || 'openthrottle';
|
|
214
|
+
|
|
264
215
|
console.log(`
|
|
265
216
|
Next steps:
|
|
266
217
|
|
|
267
|
-
1.
|
|
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:
|
|
268
225
|
${secrets.join('\n')}
|
|
269
226
|
TELEGRAM_BOT_TOKEN ← optional (notifications)
|
|
270
227
|
TELEGRAM_CHAT_ID ← optional (notifications)
|
|
271
228
|
|
|
272
|
-
|
|
229
|
+
3. Commit and push:
|
|
273
230
|
git add .openthrottle.yml .github/workflows/wake-sandbox.yml
|
|
274
231
|
git commit -m "feat: add openthrottle config"
|
|
275
232
|
git push
|
|
276
233
|
|
|
277
|
-
|
|
234
|
+
4. Ship your first prompt:
|
|
278
235
|
gh issue create --title "My first feature" \\
|
|
279
236
|
--body-file docs/prds/my-feature.md \\
|
|
280
237
|
--label prd-queued
|
|
@@ -322,8 +279,8 @@ async function main() {
|
|
|
322
279
|
console.log(' ✓ Copied .github/workflows/wake-sandbox.yml');
|
|
323
280
|
}
|
|
324
281
|
|
|
325
|
-
//
|
|
326
|
-
|
|
282
|
+
// Step 5: Copy Daytona runtime files
|
|
283
|
+
setupDaytona(config);
|
|
327
284
|
|
|
328
285
|
// Step 7: Next steps
|
|
329
286
|
printNextSteps(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-openthrottle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Set up openthrottle in any Node.js project — agent-agnostic, config-driven.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"templates/"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@daytonaio/sdk": "^0.153.0",
|
|
15
14
|
"prompts": "^2.4.2",
|
|
16
15
|
"yaml": "^2.4.0"
|
|
17
16
|
},
|