sharkcode 0.3.7 → 0.3.8

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/dist/cli.mjs +25 -9
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -413,7 +413,22 @@ async function runAgent(messages, config) {
413
413
  let currentStep = 0;
414
414
  const thinkingSpinner = createSpinner("thinking...");
415
415
  let thinkingDone = false;
416
- let lastWasNewline = true;
416
+ let trailingNL = 0;
417
+ function writeOut(text) {
418
+ if (!text) return;
419
+ process.stdout.write(text);
420
+ for (const ch of text) {
421
+ if (ch === "\n") trailingNL++;
422
+ else trailingNL = 0;
423
+ }
424
+ }
425
+ function collapseNL(keep = 1) {
426
+ if (trailingNL > keep) {
427
+ const remove = trailingNL - keep;
428
+ process.stdout.write(`\x1B[${remove}A\x1B[J`);
429
+ trailingNL = keep;
430
+ }
431
+ }
417
432
  let toolSpinner = null;
418
433
  let currentToolName = "";
419
434
  thinkingSpinner.start();
@@ -424,14 +439,15 @@ async function runAgent(messages, config) {
424
439
  }
425
440
  switch (event.type) {
426
441
  case "text-delta":
427
- process.stdout.write(event.text);
428
- lastWasNewline = event.text.endsWith("\n");
442
+ if (trailingNL > 1 && event.text.trim() !== "") collapseNL(1);
443
+ writeOut(event.text);
429
444
  break;
430
445
  case "tool-call": {
431
446
  const meta = TOOL_LABELS[event.toolName] ?? { icon: "\u{1F527}", verb: "running" };
432
447
  currentToolName = event.toolName;
433
448
  const argHint = getArgHint(event.toolName, event.input);
434
- if (!lastWasNewline) process.stdout.write("\n");
449
+ if (trailingNL === 0) writeOut("\n");
450
+ collapseNL(1);
435
451
  await playScanLine();
436
452
  process.stdout.write(
437
453
  ` ${meta.icon} ${PURPLE2(meta.verb)}${argHint ? chalk2.dim(" \u203A ") + chalk2.white(argHint) : ""}
@@ -440,7 +456,7 @@ async function runAgent(messages, config) {
440
456
  toolSpinner = createSpinner(`${meta.verb}...`);
441
457
  registerToolSpinner(() => toolSpinner?.stop());
442
458
  toolSpinner.start();
443
- lastWasNewline = false;
459
+ trailingNL = 0;
444
460
  break;
445
461
  }
446
462
  case "tool-result": {
@@ -454,7 +470,7 @@ async function runAgent(messages, config) {
454
470
  ` ${chalk2.green("\u2713")} ${chalk2.dim(summary)}
455
471
  `
456
472
  );
457
- lastWasNewline = true;
473
+ trailingNL = 1;
458
474
  break;
459
475
  }
460
476
  case "tool-error":
@@ -467,7 +483,7 @@ async function runAgent(messages, config) {
467
483
  chalk2.red(` \u2717 [${event.toolName}] ${String(event.error)}
468
484
  `)
469
485
  );
470
- lastWasNewline = true;
486
+ trailingNL = 1;
471
487
  break;
472
488
  case "finish-step":
473
489
  currentStep++;
@@ -482,7 +498,7 @@ async function runAgent(messages, config) {
482
498
  process.stderr.write(chalk2.red(`
483
499
  \u274C ${String(event.error)}
484
500
  `));
485
- lastWasNewline = true;
501
+ trailingNL = 1;
486
502
  break;
487
503
  }
488
504
  }
@@ -491,7 +507,7 @@ async function runAgent(messages, config) {
491
507
  toolSpinner.stop();
492
508
  unregisterToolSpinner();
493
509
  }
494
- if (!lastWasNewline) process.stdout.write("\n");
510
+ if (trailingNL === 0) process.stdout.write("\n");
495
511
  const usage = await result.totalUsage;
496
512
  if (usage) {
497
513
  process.stderr.write(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sharkcode",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Local First, open-source AI Coding Agent",
5
5
  "type": "module",
6
6
  "bin": {