@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +33 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tritard/waterbrother",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Waterbrother: Grok-powered coding CLI with local tools, sessions, operator modes, and approval controls",
5
5
  "type": "module",
6
6
  "bin": {
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
- const goalArg = line.replace("/experiment", "").trim();
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("Usage: /experiment <goal> (e.g. /experiment speed up the test suite)");
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
- // Ask for metric command
6220
- if (!charter.metric.command) {
6221
- try {
6222
- const metricCmd = await promptLine("metric command (e.g. npm test, python bench.py): ", { input: process.stdin, output: process.stdout });
6223
- charter.metric.command = metricCmd.trim();
6224
- } catch {
6225
- console.log("experiment canceled");
6226
- continue;
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
- // Ask for attempt budget (0 = infinite, runs until Ctrl+C or time limit)
6235
- try {
6236
- const attemptsStr = await promptLine("max attempts (0 = run until interrupted) [0]: ", { input: process.stdin, output: process.stdout });
6237
- const parsed = parseInt(attemptsStr.trim(), 10);
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(`────────────────────────────────────────────────────────────`);