stoops 0.3.2 → 0.3.4

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/dist/cli/index.js CHANGED
@@ -20,6 +20,9 @@ import {
20
20
  formatTimestamp
21
21
  } from "../chunk-TGA24MC3.js";
22
22
 
23
+ // src/cli/index.ts
24
+ import { createRequire as createRequire2 } from "module";
25
+
23
26
  // src/cli/serve.ts
24
27
  import { createServer } from "http";
25
28
  import { spawn, execFileSync } from "child_process";
@@ -585,7 +588,7 @@ Port ${port} is already in use. Another stoops instance may be running.`);
585
588
  };
586
589
  process.on("SIGINT", shutdown);
587
590
  process.on("SIGTERM", shutdown);
588
- return { serverUrl, publicUrl, roomName, adminToken, memberToken };
591
+ return { serverUrl, publicUrl, roomName, adminToken, memberToken, savePath };
589
592
  }
590
593
  function logServer(message) {
591
594
  console.log(` [${formatTimestamp(/* @__PURE__ */ new Date())}] ${message}`);
@@ -718,10 +721,34 @@ function makeIdentityAssigner() {
718
721
  return map.get(name);
719
722
  };
720
723
  }
724
+ function wordWrap(text, width) {
725
+ if (width <= 0) return [text];
726
+ const result = [];
727
+ for (const paragraph of text.split("\n")) {
728
+ if (paragraph.length === 0) {
729
+ result.push("");
730
+ continue;
731
+ }
732
+ let line = "";
733
+ for (const word of paragraph.split(/(\s+)/)) {
734
+ if (line.length + word.length > width && line.length > 0) {
735
+ result.push(line);
736
+ line = word.replace(/^\s+/, "");
737
+ } else {
738
+ line += word;
739
+ }
740
+ }
741
+ if (line.length > 0) result.push(line);
742
+ }
743
+ if (result.length === 0) result.push("");
744
+ return result;
745
+ }
721
746
  var NAME_COL = 12;
747
+ var PREFIX_WIDTH = 27;
722
748
  function EventLine({
723
749
  event,
724
- identify
750
+ identify,
751
+ cols
725
752
  }) {
726
753
  const ts = /* @__PURE__ */ jsxs(Text, { color: C.muted, children: [
727
754
  event.ts,
@@ -734,8 +761,11 @@ function EventLine({
734
761
  const sigilColor = isSelf ? C.dim : event.senderType === "agent" ? color : C.dim;
735
762
  const sigilChar = isSelf ? "\u203A" : event.senderType === "agent" ? sigil : "\xB7";
736
763
  const contentColor = isSelf ? C.text : C.secondary;
737
- return /* @__PURE__ */ jsxs(Box, { paddingX: 1, children: [
738
- /* @__PURE__ */ jsxs(Box, { flexShrink: 0, children: [
764
+ const replyPrefix = event.replyToName ? `\u2192 ${event.replyToName} ` : "";
765
+ const contentWidth = Math.max(20, cols - PREFIX_WIDTH - 1);
766
+ const wrapped = wordWrap(replyPrefix + event.content, contentWidth);
767
+ return /* @__PURE__ */ jsx(Box, { paddingX: 1, flexDirection: "column", children: wrapped.map((line, i) => /* @__PURE__ */ jsxs(Box, { children: [
768
+ i === 0 ? /* @__PURE__ */ jsxs(Box, { flexShrink: 0, children: [
739
769
  ts,
740
770
  /* @__PURE__ */ jsxs(Text, { color: sigilColor, children: [
741
771
  sigilChar,
@@ -743,16 +773,12 @@ function EventLine({
743
773
  ] }),
744
774
  /* @__PURE__ */ jsx(Text, { color: nameColor, bold: isSelf, children: event.senderName.slice(0, NAME_COL).padEnd(NAME_COL) }),
745
775
  /* @__PURE__ */ jsx(Text, { children: " " })
746
- ] }),
747
- /* @__PURE__ */ jsx(Box, { flexGrow: 1, flexShrink: 1, children: /* @__PURE__ */ jsxs(Text, { wrap: "wrap", children: [
748
- event.replyToName && /* @__PURE__ */ jsxs(Text, { color: C.dim, children: [
749
- "\u2192 ",
750
- event.replyToName,
751
- " "
752
- ] }),
753
- /* @__PURE__ */ jsx(Text, { color: contentColor, children: event.content })
754
- ] }) })
755
- ] });
776
+ ] }) : /* @__PURE__ */ jsx(Text, { children: " ".repeat(PREFIX_WIDTH - 1) }),
777
+ /* @__PURE__ */ jsx(Text, { wrap: "truncate", children: i === 0 && replyPrefix ? /* @__PURE__ */ jsxs(Fragment, { children: [
778
+ /* @__PURE__ */ jsx(Text, { color: C.dim, children: replyPrefix }),
779
+ /* @__PURE__ */ jsx(Text, { color: contentColor, children: line.slice(replyPrefix.length) })
780
+ ] }) : /* @__PURE__ */ jsx(Text, { color: contentColor, children: line }) })
781
+ ] }, i)) });
756
782
  }
757
783
  if (event.kind === "join") {
758
784
  const isAgent = event.participantType === "agent";
@@ -799,7 +825,9 @@ function App({
799
825
  onCtrlC,
800
826
  onReady,
801
827
  readOnly,
802
- isAdmin
828
+ isAdmin,
829
+ version,
830
+ savePath
803
831
  }) {
804
832
  const [events, setEvents] = useState([]);
805
833
  const [agentNames, setAgentNames] = useState([]);
@@ -935,14 +963,22 @@ function App({
935
963
  if (!entry.event) {
936
964
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 2, paddingTop: 1, paddingBottom: 1, children: [
937
965
  BANNER_LINES.map((line, i) => /* @__PURE__ */ jsx(Text, { color: GRADIENT[i], children: line }, i)),
966
+ version && /* @__PURE__ */ jsxs(Text, { color: C.dim, children: [
967
+ " v",
968
+ version
969
+ ] }),
938
970
  /* @__PURE__ */ jsx(Text, { children: " " }),
939
971
  /* @__PURE__ */ jsxs(Text, { children: [
940
972
  /* @__PURE__ */ jsx(Text, { color: C.dim, children: " room " }),
941
973
  /* @__PURE__ */ jsx(Text, { color: C.cyan, bold: true, children: roomName })
974
+ ] }),
975
+ savePath && /* @__PURE__ */ jsxs(Text, { children: [
976
+ /* @__PURE__ */ jsx(Text, { color: C.dim, children: " saved " }),
977
+ /* @__PURE__ */ jsx(Text, { color: C.secondary, children: savePath })
942
978
  ] })
943
979
  ] }, entry.id);
944
980
  }
945
- return /* @__PURE__ */ jsx(EventLine, { event: entry.event, identify }, entry.id);
981
+ return /* @__PURE__ */ jsx(EventLine, { event: entry.event, identify, cols }, entry.id);
946
982
  } }),
947
983
  /* @__PURE__ */ jsxs(Box, { paddingX: 1, children: [
948
984
  /* @__PURE__ */ jsx(Text, { color: C.purple, children: "\u2500" }),
@@ -1006,7 +1042,9 @@ function startTUI(opts) {
1006
1042
  onCtrlC: opts.onCtrlC,
1007
1043
  onReady,
1008
1044
  readOnly: opts.readOnly,
1009
- isAdmin: opts.isAdmin
1045
+ isAdmin: opts.isAdmin,
1046
+ version: opts.version,
1047
+ savePath: opts.savePath
1010
1048
  }
1011
1049
  ),
1012
1050
  { exitOnCtrlC: false }
@@ -1399,6 +1437,8 @@ ${lines.join("\n")}`);
1399
1437
  roomName,
1400
1438
  readOnly: isReadOnly,
1401
1439
  isAdmin: authority === "admin",
1440
+ version: options.version,
1441
+ savePath: options.savePath,
1402
1442
  onSend: isReadOnly ? void 0 : async (content) => {
1403
1443
  if (content.startsWith("/")) {
1404
1444
  await handleSlashCommand(content);
@@ -1766,7 +1806,7 @@ var TmuxBridge = class {
1766
1806
  injectIdle(text) {
1767
1807
  tmuxInjectText(this.session, text);
1768
1808
  tmuxSendEnter(this.session);
1769
- this.sleep(80);
1809
+ this.sleep(200);
1770
1810
  tmuxSendEnter(this.session);
1771
1811
  }
1772
1812
  /**
@@ -1780,7 +1820,7 @@ var TmuxBridge = class {
1780
1820
  this.sleep(this.keystrokeDelayMs);
1781
1821
  tmuxInjectText(this.session, text);
1782
1822
  tmuxSendEnter(this.session);
1783
- this.sleep(80);
1823
+ this.sleep(200);
1784
1824
  tmuxSendEnter(this.session);
1785
1825
  this.sleep(this.keystrokeDelayMs);
1786
1826
  tmuxSendKey(this.session, "C-y");
@@ -2661,6 +2701,15 @@ async function runCodex(options) {
2661
2701
  }
2662
2702
 
2663
2703
  // src/cli/index.ts
2704
+ function getVersion() {
2705
+ try {
2706
+ const require2 = createRequire2(import.meta.url);
2707
+ const pkg = require2("../../package.json");
2708
+ return pkg.version ?? "unknown";
2709
+ } catch {
2710
+ return "unknown";
2711
+ }
2712
+ }
2664
2713
  var args = process.argv.slice(2);
2665
2714
  function getFlag(name, arr = args) {
2666
2715
  const idx = arr.indexOf(`--${name}`);
@@ -2770,7 +2819,9 @@ async function main() {
2770
2819
  await join({
2771
2820
  server: adminJoinUrl,
2772
2821
  name: getFlag("name"),
2773
- shareUrl: participantShareUrl
2822
+ shareUrl: participantShareUrl,
2823
+ version: getVersion(),
2824
+ savePath: result.savePath
2774
2825
  });
2775
2826
  return;
2776
2827
  }