@tritard/waterbrother 0.9.5 → 0.9.6
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/src/cli.js +33 -29
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -6207,43 +6207,47 @@ async function promptLoop(agent, session, context) {
|
|
|
6207
6207
|
}
|
|
6208
6208
|
|
|
6209
6209
|
if (line === "/experiment" || line.startsWith("/experiment ")) {
|
|
6210
|
-
|
|
6210
|
+
// Parse: /experiment <goal> --metric "command" --attempts N --time M
|
|
6211
|
+
const rawArgs = line.replace("/experiment", "").trim();
|
|
6212
|
+
if (!rawArgs) {
|
|
6213
|
+
console.log('Usage: /experiment <goal> --metric "npm test" --attempts 5 --time 30');
|
|
6214
|
+
console.log(' --metric command to measure (required)');
|
|
6215
|
+
console.log(' --attempts max attempts, 0=infinite (default: 0)');
|
|
6216
|
+
console.log(' --time time limit in minutes (default: 60)');
|
|
6217
|
+
continue;
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
// Extract flags
|
|
6221
|
+
const metricMatch = rawArgs.match(/--metric\s+"([^"]+)"|--metric\s+(\S+)/);
|
|
6222
|
+
const attemptsMatch = rawArgs.match(/--attempts\s+(\d+)/);
|
|
6223
|
+
const timeMatch = rawArgs.match(/--time\s+(\d+)/);
|
|
6224
|
+
const goalArg = rawArgs
|
|
6225
|
+
.replace(/--metric\s+"[^"]+"|--metric\s+\S+/g, "")
|
|
6226
|
+
.replace(/--attempts\s+\d+/g, "")
|
|
6227
|
+
.replace(/--time\s+\d+/g, "")
|
|
6228
|
+
.trim();
|
|
6229
|
+
|
|
6211
6230
|
if (!goalArg) {
|
|
6212
|
-
console.log("
|
|
6231
|
+
console.log("experiment needs a goal");
|
|
6213
6232
|
continue;
|
|
6214
6233
|
}
|
|
6215
6234
|
|
|
6216
|
-
// Build charter
|
|
6217
6235
|
const charter = parseCharterFromGoal(goalArg);
|
|
6218
6236
|
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
}
|
|
6228
|
-
if (!charter.metric.command) {
|
|
6229
|
-
console.log("no metric command — experiment canceled");
|
|
6230
|
-
continue;
|
|
6231
|
-
}
|
|
6237
|
+
if (metricMatch) {
|
|
6238
|
+
charter.metric.command = (metricMatch[1] || metricMatch[2]).trim();
|
|
6239
|
+
}
|
|
6240
|
+
if (attemptsMatch) {
|
|
6241
|
+
charter.budget.maxAttempts = parseInt(attemptsMatch[1], 10);
|
|
6242
|
+
}
|
|
6243
|
+
if (timeMatch) {
|
|
6244
|
+
charter.budget.maxMinutes = parseInt(timeMatch[1], 10);
|
|
6232
6245
|
}
|
|
6233
6246
|
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
if (parsed > 0) charter.budget.maxAttempts = parsed;
|
|
6239
|
-
} catch {}
|
|
6240
|
-
|
|
6241
|
-
// Ask for time budget
|
|
6242
|
-
try {
|
|
6243
|
-
const timeStr = await promptLine(`time limit in minutes [${charter.budget.maxMinutes}]: `, { input: process.stdin, output: process.stdout });
|
|
6244
|
-
const parsed = parseInt(timeStr.trim(), 10);
|
|
6245
|
-
if (parsed > 0) charter.budget.maxMinutes = parsed;
|
|
6246
|
-
} catch {}
|
|
6247
|
+
if (!charter.metric.command) {
|
|
6248
|
+
console.log('experiment needs a metric: /experiment <goal> --metric "npm test"');
|
|
6249
|
+
continue;
|
|
6250
|
+
}
|
|
6247
6251
|
|
|
6248
6252
|
const isInfinite = !charter.budget.maxAttempts || charter.budget.maxAttempts <= 0;
|
|
6249
6253
|
console.log(`────────────────────────────────────────────────────────────`);
|