@xevy/cli 0.1.19 → 0.1.22

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.
@@ -13,10 +13,8 @@ const HEARTBEAT_INTERVAL_MS = 60_000;
13
13
  const SESSION_POLL_INTERVAL_MS = 2_000;
14
14
  const SESSION_START_TIMEOUT_MS = 10 * 60_000;
15
15
  const EXECUTION_RECONNECT_LIMIT = 8;
16
- const TERMINAL_RECONNECT_LIMIT = 8;
17
- const TERMINAL_RECONNECT_MAX_DELAY_MS = 5_000;
18
- const TERMINAL_RESTART_GRACE_MS = 3_000;
19
- const TERMINAL_STABLE_RUNTIME_MS = 10_000;
16
+ const TERMINAL_START_ATTEMPT_LIMIT = 8;
17
+ const TERMINAL_START_MAX_DELAY_MS = 5_000;
20
18
  const TERMINAL_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
21
19
  const DEV_TARGET_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
22
20
 
@@ -636,7 +634,7 @@ function sessionSummary(context, session, base, writeLine) {
636
634
  writeLine(` Branch ${session.branch || session.config?.branch || "unknown"}`);
637
635
  writeLine(` Status ${session.status}`);
638
636
  writeLine(` Expires ${session.expiresAt || "server-managed"}`);
639
- writeLine("\nNative Pi terminal · press Ctrl+] to detach and leave it running\n");
637
+ writeLine("\nXevy terminal · press Ctrl+] to detach and leave it running\n");
640
638
  }
641
639
 
642
640
  async function attachNativeTerminal({
@@ -647,6 +645,7 @@ async function attachNativeTerminal({
647
645
  output,
648
646
  signal,
649
647
  onReady,
648
+ reattachHint,
650
649
  WebSocketImpl = WebSocket,
651
650
  }) {
652
651
  const ticket = await api.request(`${sessionPath}/terminal-ticket`, { method: "POST", body: {}, signal });
@@ -662,6 +661,7 @@ async function attachNativeTerminal({
662
661
  let ready = false;
663
662
  let settled = false;
664
663
  let rawEnabled = false;
664
+ let resumedInput = false;
665
665
  let detachedByUser = false;
666
666
  const connectedAt = Date.now();
667
667
  const pendingOutput = [];
@@ -678,6 +678,13 @@ async function attachNativeTerminal({
678
678
  process.off("SIGWINCH", onResize);
679
679
  signal?.removeEventListener("abort", onAbort);
680
680
  if (rawEnabled && typeof input.setRawMode === "function") input.setRawMode(false);
681
+ // A resumed stdin keeps its libuv handle referenced, so without this the
682
+ // process sits there after detaching and never gives the shell back.
683
+ if (resumedInput) {
684
+ input.pause?.();
685
+ input.unref?.();
686
+ resumedInput = false;
687
+ }
681
688
  if (error) reject(error);
682
689
  else resolve(result);
683
690
  };
@@ -698,7 +705,8 @@ async function attachNativeTerminal({
698
705
  if (detachAt > 0 && socket.readyState === WebSocketImpl.OPEN) {
699
706
  socket.send(value.subarray(0, detachAt), { binary: true });
700
707
  }
701
- output.write("\r\nDetached. Pi and the Dev Session are still running.\r\n");
708
+ output.write("\r\nDetached. Xevy and the Dev Session are still running.\r\n");
709
+ if (reattachHint) output.write(`${reattachHint}\r\n`);
702
710
  socket.close(1000, "client_detach");
703
711
  finish(null, { reason: "detached", code: 1000, durationMs: Date.now() - connectedAt });
704
712
  return;
@@ -730,6 +738,7 @@ async function attachNativeTerminal({
730
738
  rawEnabled = true;
731
739
  }
732
740
  input.resume?.();
741
+ resumedInput = true;
733
742
  input.on("data", onInput);
734
743
  process.on("SIGWINCH", onResize);
735
744
  sendResize();
@@ -752,10 +761,18 @@ async function attachNativeTerminal({
752
761
  });
753
762
  }
754
763
 
755
- async function attachNativeTerminalPersistently({
764
+ /**
765
+ * Attaches once and returns when the attachment ends — by Ctrl+], because Pi
766
+ * exited, or because the connection dropped. It does NOT reconnect: silently
767
+ * restarting the remote terminal fought whoever was trying to leave and hid
768
+ * why Pi stopped. Retries before the first attach are a different thing and
769
+ * stay, since a session that is still provisioning has nothing to attach to.
770
+ */
771
+ async function attachNativeTerminalOnce({
756
772
  api,
757
773
  base,
758
774
  sessionPath,
775
+ reattachHint,
759
776
  input,
760
777
  output,
761
778
  signal,
@@ -765,12 +782,10 @@ async function attachNativeTerminalPersistently({
765
782
  animateStatus,
766
783
  }) {
767
784
  const status = createTerminalStatus({ output, writeLine, animate: animateStatus });
768
- let reconnecting = false;
769
- let consecutiveFailures = 0;
785
+ let attempts = 0;
770
786
  try {
771
787
  while (!signal?.aborted) {
772
- let reconnectDelayMs = null;
773
- status.update(reconnecting ? "Restarting remote Pi terminal…" : "Starting remote Pi terminal…");
788
+ status.update(attempts === 0 ? "Starting remote Xevy terminal…" : "Terminal is not ready yet · retrying…");
774
789
  try {
775
790
  const result = await attachNativeTerminal({
776
791
  api,
@@ -779,47 +794,36 @@ async function attachNativeTerminalPersistently({
779
794
  input,
780
795
  output,
781
796
  signal,
782
- onReady: () => status.succeed(reconnecting ? "Pi terminal restarted" : "Pi terminal ready"),
797
+ reattachHint,
798
+ onReady: () => status.succeed("Xevy terminal ready"),
783
799
  WebSocketImpl,
784
800
  });
785
801
  if (result?.reason === "detached") return;
786
- reconnecting = true;
787
- consecutiveFailures = result?.durationMs >= TERMINAL_STABLE_RUNTIME_MS
788
- ? 0
789
- : consecutiveFailures + 1;
790
- if (result?.reason === "transport-lost") {
791
- status.update("Terminal connection lost · reconnecting…");
792
- } else {
793
- reconnectDelayMs = TERMINAL_RESTART_GRACE_MS;
794
- status.update("Pi exited · restarting in 3 seconds · Ctrl+C to detach");
795
- }
802
+ status.stop();
803
+ // The attachment ended on its own; say why and leave the session up.
804
+ writeLine(result?.reason === "transport-lost"
805
+ ? "\nConnection to the Dev Session terminal was lost. The Dev Session is still running."
806
+ : "\nXevy exited. The Dev Session is still running.");
807
+ if (reattachHint) writeLine(reattachHint);
808
+ return;
796
809
  } catch (error) {
797
810
  if (signal?.aborted) throw error;
798
811
  if (error instanceof DevSessionApiError && ![409, 502, 503, 504].includes(error.status)) throw error;
799
- reconnecting = true;
800
- consecutiveFailures += 1;
812
+ attempts += 1;
813
+ if (attempts >= TERMINAL_START_ATTEMPT_LIMIT) {
814
+ throw new Error("The remote Xevy terminal never became ready. The Dev Session remains active; check its logs and rerun `xevy dev` after correcting the startup error.");
815
+ }
801
816
  status.update("Terminal is not ready yet · retrying…");
802
- }
803
-
804
- if (consecutiveFailures >= TERMINAL_RECONNECT_LIMIT) {
805
- throw new Error("The remote Pi terminal repeatedly exited before stabilizing. The Dev Session remains active; check its logs and rerun `xevy dev` after correcting the startup error.");
806
- }
807
- await sleep(
808
- reconnectDelayMs
809
- ?? Math.min(500 * 2 ** Math.max(0, consecutiveFailures - 1), TERMINAL_RECONNECT_MAX_DELAY_MS),
810
- signal,
811
- );
812
- let current = null;
813
- try {
814
- current = await api.request(`${sessionPath}/`, { signal });
815
- } catch (error) {
816
- if (signal?.aborted) throw error;
817
- if (error instanceof DevSessionApiError && [401, 403, 404].includes(error.status)) throw error;
818
- status.update("Session status unavailable · retrying terminal…");
819
- }
820
- if (current && !current.session) throw new Error("The Dev Session disappeared while reconnecting the terminal.");
821
- if (current?.session && SESSION_TERMINAL_STATUSES.has(current.session.status)) {
822
- throw new Error(current.session.error || `Dev Session ${current.session.status}.`);
817
+ await sleep(Math.min(500 * 2 ** (attempts - 1), TERMINAL_START_MAX_DELAY_MS), signal);
818
+ const current = await api.request(`${sessionPath}/`, { signal }).catch((cause) => {
819
+ if (signal?.aborted || (cause instanceof DevSessionApiError && [401, 403, 404].includes(cause.status))) throw cause;
820
+ status.update("Session status unavailable · retrying terminal…");
821
+ return null;
822
+ });
823
+ if (current && !current.session) throw new Error("The Dev Session disappeared while starting the terminal.");
824
+ if (current?.session && SESSION_TERMINAL_STATUSES.has(current.session.status)) {
825
+ throw new Error(current.session.error || `Dev Session ${current.session.status}.`);
826
+ }
823
827
  }
824
828
  }
825
829
  } finally {
@@ -1081,10 +1085,14 @@ export async function runDevSession(options) {
1081
1085
  const nativeTerminal = options.nativeTerminal
1082
1086
  ?? (input === process.stdin && output === process.stdout);
1083
1087
  if (interactive && nativeTerminal) {
1084
- await attachNativeTerminalPersistently({
1088
+ const reattachTarget = context.kind === "task"
1089
+ ? `task/${task.taskCode || task.id}`
1090
+ : `${context.workspace.identifier}/${context.project.identifier}`;
1091
+ await attachNativeTerminalOnce({
1085
1092
  api,
1086
1093
  base,
1087
1094
  sessionPath,
1095
+ reattachHint: `Reattach with: xevy dev ${reattachTarget}`,
1088
1096
  input,
1089
1097
  output,
1090
1098
  signal: detachController.signal,
@@ -1098,7 +1106,7 @@ export async function runDevSession(options) {
1098
1106
  }
1099
1107
 
1100
1108
  if (context.kind === "personal") {
1101
- writeLine("Attached successfully. Rerun in an interactive terminal to open Pi.");
1109
+ writeLine("Attached successfully. Rerun in an interactive terminal to open Xevy.");
1102
1110
  return { task: null, project: context.project, session, detached: true };
1103
1111
  }
1104
1112
 
package/bin/xevy.mjs CHANGED
@@ -136,10 +136,10 @@ function devUsage() {
136
136
 
137
137
  Connects this terminal to a remote Dev Session. The reserved task/ prefix
138
138
  selects task work; a workspace/project target starts or resumes your personal
139
- project session. Pi runs inside the isolated remote workspace.
139
+ project session. Xevy runs inside the isolated remote workspace.
140
140
 
141
141
  Terminal control:
142
- Ctrl+] Detach without stopping Pi or the Dev Session
142
+ Ctrl+] Detach without stopping Xevy or the Dev Session
143
143
 
144
144
  Credentials:
145
145
  XEVY_API_KEY takes precedence over ~/.config/xevy/credentials.
@@ -437,7 +437,7 @@ async function resolveSetupComponents(opts) {
437
437
 
438
438
  console.log("What would you like to set up?");
439
439
  console.log(" 1. Credentials Store or replace your Xevy API key");
440
- console.log(" 2. Pi Install pi and the Xevy pi extensions");
440
+ console.log(" 2. Agent Install the Xevy coding agent and its extensions");
441
441
  console.log(" 3. Skills Install Xevy skills for coding agents");
442
442
  console.log(" 4. MCP Configure Xevy MCP for coding agents");
443
443
  const answer = await promptLine(
@@ -508,7 +508,7 @@ async function setup(opts) {
508
508
  ) {
509
509
  components.unshift("credentials");
510
510
  console.log(
511
- "→ Added credentials because Pi and the Codex MCP bridge require a Xevy API key.",
511
+ "→ Added credentials because the Xevy agent and the Codex MCP bridge require a Xevy API key.",
512
512
  );
513
513
  }
514
514
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xevy/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.22",
4
4
  "description": "Xevy CLI — connect to remote Dev Sessions, configure credentials, pi, coding-agent skills, and MCP, and keep integrations current.",
5
5
  "type": "module",
6
6
  "keywords": [