blun-king-cli 2.1.1 → 2.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.
Files changed (2) hide show
  1. package/bin/blun.js +53 -10
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -1375,19 +1375,62 @@ function cmdPermissions(args) {
1375
1375
 
1376
1376
  // ── Agent Loop (CLI wrapper) ──
1377
1377
  async function cmdAgent(args) {
1378
- if (!args) { printError("Usage: /agent <goal>"); return; }
1378
+ if (!args) { printError("Usage: /agent <goal> — runs autonomously until done"); return; }
1379
1379
  try {
1380
1380
  printUserMessage(args);
1381
- process.stdout.write(C.dim + " " + BOX.bot + " working autonomously..." + C.reset);
1382
- var resp = await apiCall("POST", "/agent", { goal: args, verbose: true });
1383
- process.stdout.write("\r" + " ".repeat(50) + "\r");
1384
- if (resp.status !== 200) { printError(resp.data.error || "Error"); return; }
1385
- var d = resp.data;
1386
- var meta = d.steps_executed + " steps" + (d.files.length > 0 ? " " + BOX.dot + " " + d.files.length + " files" : "");
1387
- printAnswer(d.answer, meta);
1388
- if (d.files.length > 0) {
1381
+ var maxLoops = 20;
1382
+ var loop = 0;
1383
+ var totalFiles = [];
1384
+ var lastAnswer = "";
1385
+ var goal = args;
1386
+ var context = [];
1387
+
1388
+ while (loop < maxLoops) {
1389
+ loop++;
1390
+ // Phase indicator
1391
+ var phase = loop === 1 ? "planning" : "step " + loop;
1392
+ process.stdout.write("\r\x1b[K" + C.dim + " " + BOX.bot + " [" + phase + "/" + maxLoops + "] working..." + C.reset);
1393
+
1394
+ var resp = await apiCall("POST", "/agent", {
1395
+ goal: goal,
1396
+ context: context.slice(-5),
1397
+ verbose: false
1398
+ });
1399
+ process.stdout.write("\r\x1b[K");
1400
+
1401
+ if (resp.status !== 200) {
1402
+ printError("Step " + loop + " failed: " + (resp.data.error || "Error"));
1403
+ break;
1404
+ }
1405
+
1406
+ var d = resp.data;
1407
+ lastAnswer = d.answer || "";
1408
+ if (d.files && d.files.length > 0) totalFiles = totalFiles.concat(d.files);
1409
+ context.push({ step: loop, answer: lastAnswer.slice(0, 500), files: (d.files || []).length });
1410
+
1411
+ // Check if the agent says it's done
1412
+ var doneSignals = ["done", "complete", "finished", "fertig", "erledigt", "all steps", "nothing left"];
1413
+ var isDone = doneSignals.some(function(s) { return lastAnswer.toLowerCase().includes(s); });
1414
+
1415
+ // Show brief step result
1416
+ console.log(C.dim + " [" + loop + "] " + C.reset + C.green + (d.steps_executed || 1) + " steps" +
1417
+ (d.files && d.files.length > 0 ? ", " + d.files.length + " files" : "") + C.reset +
1418
+ (isDone ? C.yellow + " ✓ done" + C.reset : ""));
1419
+
1420
+ if (isDone) break;
1421
+
1422
+ // Feed result back as next goal
1423
+ goal = "Continue with the original goal: " + args + "\n\nLast step result: " + lastAnswer.slice(0, 1000) +
1424
+ "\n\nWhat is the next step? If everything is done, say 'done'.";
1425
+ }
1426
+
1427
+ // Final summary
1428
+ console.log("");
1429
+ var meta = loop + " loops" + (totalFiles.length > 0 ? " " + BOX.dot + " " + totalFiles.length + " files total" : "");
1430
+ printAnswer(lastAnswer, meta);
1431
+ if (totalFiles.length > 0) {
1389
1432
  console.log(C.green + " Files:" + C.reset);
1390
- d.files.forEach(function(f) { console.log(" " + C.brightCyan + f.name + C.reset + " " + config.api.base_url + f.download); });
1433
+ totalFiles.forEach(function(f) { console.log(" " + C.brightCyan + f.name + C.reset + " \u2192 " + config.api.base_url + f.download); });
1391
1434
  console.log("");
1392
1435
  }
1393
1436
  } catch(e) { printError(e.message); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"