stackai 0.1.2 → 0.1.3

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.js +85 -29
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -501,36 +501,86 @@ import { Box as Box2, Text as Text2, useApp } from "ink";
501
501
  import Spinner from "ink-spinner";
502
502
 
503
503
  // src/ui/format.ts
504
- function describe(step) {
505
- const p = step.args.path ?? step.args.dir ?? "";
504
+ var ACCENT = "#e8ff47";
505
+ var MAX_PREVIEW = 6;
506
+ function splitLines(s) {
507
+ return s.replace(/\n+$/, "").split("\n");
508
+ }
509
+ function clip(s, n = 76) {
510
+ return s.length > n ? `${s.slice(0, n)}\u2026` : s;
511
+ }
512
+ function preview(lines, prefix, color) {
513
+ const out = lines.slice(0, MAX_PREVIEW).map((l) => ({ kind: "sub", color, text: `${prefix} ${clip(l)}` }));
514
+ if (lines.length > MAX_PREVIEW) {
515
+ out.push({
516
+ kind: "sub",
517
+ color: "gray",
518
+ text: `\u2026 ${lines.length - MAX_PREVIEW} more lines`
519
+ });
520
+ }
521
+ return out;
522
+ }
523
+ function toolEntries(step) {
524
+ const args = step.args;
525
+ const path3 = String(args.path ?? args.dir ?? "");
506
526
  switch (step.name) {
527
+ case "write_file": {
528
+ const lines = splitLines(String(args.content ?? ""));
529
+ return [
530
+ { kind: "tool", color: ACCENT, label: `Write(${path3})` },
531
+ { kind: "sub", color: "green", text: `+${lines.length} lines` },
532
+ ...preview(lines, "+", "green")
533
+ ];
534
+ }
535
+ case "edit_file": {
536
+ const removed = splitLines(String(args.oldStr ?? ""));
537
+ const added = splitLines(String(args.newStr ?? ""));
538
+ return [
539
+ { kind: "tool", color: ACCENT, label: `Edit(${path3})` },
540
+ {
541
+ kind: "sub",
542
+ color: "gray",
543
+ text: `+${added.length} -${removed.length} lines`
544
+ },
545
+ ...preview(removed, "-", "red"),
546
+ ...preview(added, "+", "green")
547
+ ];
548
+ }
507
549
  case "read_file":
508
- return `Reading ${p}`;
509
- case "write_file":
510
- return `Writing ${p}`;
511
- case "edit_file":
512
- return `Editing ${p}`;
550
+ return [{ kind: "tool", color: ACCENT, label: `Read(${path3})` }];
513
551
  case "list_files":
514
- return `Listing ${p || "."}`;
552
+ return [{ kind: "tool", color: ACCENT, label: `List(${path3 || "."})` }];
515
553
  case "create_dir":
516
- return `Creating ${p}/`;
554
+ return [{ kind: "tool", color: ACCENT, label: `Create(${path3}/)` }];
517
555
  default:
518
- return step.name;
556
+ return [{ kind: "tool", color: ACCENT, label: step.name }];
519
557
  }
520
558
  }
521
559
  function applyStep(entries, step) {
522
560
  if (step.type === "token") {
523
561
  const last = entries[entries.length - 1];
524
562
  if (last && last.kind === "text") {
525
- return [...entries.slice(0, -1), { kind: "text", text: last.text + step.text }];
563
+ return [
564
+ ...entries.slice(0, -1),
565
+ { kind: "text", text: last.text + step.text }
566
+ ];
526
567
  }
527
568
  return [...entries, { kind: "text", text: step.text }];
528
569
  }
529
570
  if (step.type === "tool_call") {
530
- return [...entries, { kind: "tool", color: "gray", text: describe(step) }];
531
- }
532
- if (step.type === "tool_result" && !step.ok) {
533
- return [...entries, { kind: "tool", color: "red", text: step.detail }];
571
+ return [...entries, ...toolEntries(step)];
572
+ }
573
+ if (step.type === "tool_result") {
574
+ if (!step.ok) {
575
+ return [
576
+ ...entries,
577
+ { kind: "sub", color: "red", text: `\u2717 ${step.detail}` }
578
+ ];
579
+ }
580
+ if (step.name === "read_file") {
581
+ const n = step.detail ? splitLines(step.detail).length : 0;
582
+ return [...entries, { kind: "sub", color: "gray", text: `read ${n} lines` }];
583
+ }
534
584
  }
535
585
  return entries;
536
586
  }
@@ -539,12 +589,18 @@ function applyStep(entries, step) {
539
589
  import { Box, Text } from "ink";
540
590
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
541
591
  function EntryLines({ entries }) {
542
- return /* @__PURE__ */ jsx(Fragment, { children: entries.map(
543
- (e, i) => e.kind === "tool" ? /* @__PURE__ */ jsx(Box, { marginLeft: 2, children: /* @__PURE__ */ jsxs(Text, { color: e.color, children: [
544
- "\u2192 ",
545
- e.text
546
- ] }) }, i) : /* @__PURE__ */ jsx(Box, { marginTop: 1, marginLeft: 2, children: /* @__PURE__ */ jsx(Text, { children: e.text }) }, i)
547
- ) });
592
+ return /* @__PURE__ */ jsx(Fragment, { children: entries.map((e, i) => {
593
+ if (e.kind === "tool") {
594
+ return /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { color: e.color, bold: true, children: [
595
+ "\u25CF ",
596
+ e.label
597
+ ] }) }, i);
598
+ }
599
+ if (e.kind === "sub") {
600
+ return /* @__PURE__ */ jsx(Box, { marginLeft: 2, children: /* @__PURE__ */ jsx(Text, { color: e.color, children: e.text }) }, i);
601
+ }
602
+ return /* @__PURE__ */ jsx(Box, { marginTop: 1, marginLeft: 2, children: /* @__PURE__ */ jsx(Text, { children: e.text }) }, i);
603
+ }) });
548
604
  }
549
605
 
550
606
  // src/ui/run-view.tsx
@@ -597,7 +653,7 @@ import { Box as Box3, Text as Text3, useApp as useApp2 } from "ink";
597
653
  import Spinner2 from "ink-spinner";
598
654
  import TextInput from "ink-text-input";
599
655
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
600
- var ACCENT = "#e8ff47";
656
+ var ACCENT2 = "#e8ff47";
601
657
  var LOGO = [
602
658
  "\u2588\u2580\u2580 \u2580\u2588\u2580 \u2588\u2580\u2588 \u2588\u2580\u2580 \u2588\u2584\u2580 \u2588\u2580\u2588 \u2588",
603
659
  "\u2584\u2584\u2588 \u2588 \u2588\u2580\u2588 \u2588\u2584\u2584 \u2588\u2580\u2584 \u2588\u2580\u2588 \u2588"
@@ -647,11 +703,11 @@ function Interactive({ session, cwd, version }) {
647
703
  {
648
704
  flexDirection: "column",
649
705
  borderStyle: "round",
650
- borderColor: ACCENT,
706
+ borderColor: ACCENT2,
651
707
  paddingX: 2,
652
708
  paddingY: 1,
653
709
  children: [
654
- LOGO.map((line, i) => /* @__PURE__ */ jsx3(Text3, { color: ACCENT, bold: true, children: line }, i)),
710
+ LOGO.map((line, i) => /* @__PURE__ */ jsx3(Text3, { color: ACCENT2, bold: true, children: line }, i)),
655
711
  /* @__PURE__ */ jsx3(Box3, { marginTop: 1, children: /* @__PURE__ */ jsxs3(Text3, { color: "gray", children: [
656
712
  "v",
657
713
  version,
@@ -664,12 +720,12 @@ function Interactive({ session, cwd, version }) {
664
720
  /* @__PURE__ */ jsx3(Box3, { marginTop: 1, marginBottom: 1, children: /* @__PURE__ */ jsxs3(Text3, { color: "gray", children: [
665
721
  "Describe what you want to build \xB7 type",
666
722
  " ",
667
- /* @__PURE__ */ jsx3(Text3, { color: ACCENT, children: "/exit" }),
723
+ /* @__PURE__ */ jsx3(Text3, { color: ACCENT2, children: "/exit" }),
668
724
  " to quit"
669
725
  ] }) }),
670
726
  history.map(
671
727
  (block, i) => block.kind === "user" ? /* @__PURE__ */ jsxs3(Box3, { marginTop: 1, children: [
672
- /* @__PURE__ */ jsxs3(Text3, { color: ACCENT, bold: true, children: [
728
+ /* @__PURE__ */ jsxs3(Text3, { color: ACCENT2, bold: true, children: [
673
729
  "\u203A",
674
730
  " "
675
731
  ] }),
@@ -685,13 +741,13 @@ function Interactive({ session, cwd, version }) {
685
741
  {
686
742
  marginTop: 1,
687
743
  borderStyle: "round",
688
- borderColor: busy ? "gray" : ACCENT,
744
+ borderColor: busy ? "gray" : ACCENT2,
689
745
  paddingX: 1,
690
746
  children: busy ? /* @__PURE__ */ jsxs3(Text3, { color: "gray", children: [
691
747
  /* @__PURE__ */ jsx3(Spinner2, { type: "dots" }),
692
748
  " working\u2026"
693
749
  ] }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
694
- /* @__PURE__ */ jsx3(Text3, { color: ACCENT, children: "\u203A " }),
750
+ /* @__PURE__ */ jsx3(Text3, { color: ACCENT2, children: "\u203A " }),
695
751
  /* @__PURE__ */ jsx3(
696
752
  TextInput,
697
753
  {
@@ -776,7 +832,7 @@ function LoginView() {
776
832
 
777
833
  // src/cli.tsx
778
834
  import { jsx as jsx5 } from "react/jsx-runtime";
779
- var VERSION = "0.1.2";
835
+ var VERSION = "0.1.3";
780
836
  var HELP = `
781
837
  StackAI \u2014 AI coding agent in your terminal
782
838
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackai",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "StackAI — AI coding agent in your terminal. Read, write, and edit code with AI.",
5
5
  "type": "module",
6
6
  "bin": {