@xevy/cli 0.1.14 → 0.1.15
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/README.md +18 -24
- package/bin/dev-session.mjs +110 -1
- package/bin/xevy.mjs +4 -4
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -150,34 +150,28 @@ xevy dev VI22-07 --base https://xevy.example.com
|
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
The CLI resolves an exact task ID or task code, attaches to its existing Dev
|
|
153
|
-
Session, or starts one from a linked repository.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
and
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
Available commands while attached:
|
|
153
|
+
Session, or starts one from a linked repository. It then renders Pi's native TUI
|
|
154
|
+
from the isolated remote workspace: normal composer, thinking, tools, history,
|
|
155
|
+
keyboard shortcuts, and session resume all behave like Pi on a local machine.
|
|
156
|
+
When several accessible tasks share a code, or a project has several linked
|
|
157
|
+
repositories, the CLI presents a numbered selector first.
|
|
158
|
+
|
|
159
|
+
`xevy dev` is only a terminal transport. Pi, Git credentials, the repository,
|
|
160
|
+
and Docker remain on the server. Press `Ctrl+]` to detach without stopping Pi;
|
|
161
|
+
run the same command again to reattach. Pi conversation history is stored in the
|
|
162
|
+
bounded Dev Session volume. The controller periodically commits work and pushes
|
|
163
|
+
the resumable Dev Session branch; exiting Pi also commits and pushes any final
|
|
164
|
+
edits. You do not need to ask the agent to commit after every prompt.
|
|
165
|
+
|
|
166
|
+
Terminal control:
|
|
168
167
|
|
|
169
168
|
```text
|
|
170
|
-
|
|
171
|
-
/logs Show the latest session logs
|
|
172
|
-
/open Request a fresh one-use browser link and open it when supported
|
|
173
|
-
/finish Merge into the task branch and stop
|
|
174
|
-
/stop Stop without merging (the pushed session branch remains preserved)
|
|
175
|
-
/detach Disconnect this terminal without stopping anything
|
|
176
|
-
/help Show the command list
|
|
169
|
+
Ctrl+] Disconnect this terminal without stopping Pi or the Dev Session
|
|
177
170
|
```
|
|
178
171
|
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
Use the task's Dev Session panel in Xevy to open the live site, stop the session,
|
|
173
|
+
or finish and redeploy after exiting Pi. A heartbeat keeps the session active
|
|
174
|
+
while the CLI is attached, within the server's hard expiry limit.
|
|
181
175
|
|
|
182
176
|
Host precedence is `--base`, `XEVY_BASE`, the saved credentials `baseUrl`, then
|
|
183
177
|
`https://xevy.ai`. API-key precedence is `XEVY_API_KEY`, then the saved key in
|
package/bin/dev-session.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import readline from "node:readline";
|
|
3
|
+
import WebSocket from "ws";
|
|
3
4
|
|
|
4
5
|
const DEFAULT_BASE = "https://xevy.ai";
|
|
5
6
|
const TERMINAL_EXECUTION_STATUSES = new Set(["succeeded", "failed", "cancelled"]);
|
|
@@ -545,7 +546,99 @@ function sessionSummary(task, session, writeLine) {
|
|
|
545
546
|
writeLine(` Branch ${session.config?.branch || "unknown"}`);
|
|
546
547
|
writeLine(` Status ${session.status}`);
|
|
547
548
|
writeLine(` Expires ${session.expiresAt || "server-managed"}`);
|
|
548
|
-
writeLine("\
|
|
549
|
+
writeLine("\nNative Pi terminal · press Ctrl+] to detach and leave it running\n");
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async function attachNativeTerminal({ api, base, sessionPath, input, output, signal, WebSocketImpl = WebSocket }) {
|
|
553
|
+
const ticket = await api.request(`${sessionPath}/terminal-ticket`, { method: "POST", body: {}, signal });
|
|
554
|
+
if (!ticket?.ticket || !ticket?.terminalPath) throw new Error("Xevy did not return a terminal ticket.");
|
|
555
|
+
const url = new URL(ticket.terminalPath, `${base}/`);
|
|
556
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
557
|
+
|
|
558
|
+
await new Promise((resolve, reject) => {
|
|
559
|
+
const socket = new WebSocketImpl(url, {
|
|
560
|
+
headers: { "X-Xevy-Terminal-Ticket": ticket.ticket },
|
|
561
|
+
maxPayload: 2 * 1024 * 1024,
|
|
562
|
+
});
|
|
563
|
+
let ready = false;
|
|
564
|
+
let settled = false;
|
|
565
|
+
let rawEnabled = false;
|
|
566
|
+
const onAbort = () => {
|
|
567
|
+
if (socket.readyState === WebSocketImpl.OPEN) socket.close(1000, "client_detach");
|
|
568
|
+
else socket.terminate?.();
|
|
569
|
+
finish(new Error("Detached."));
|
|
570
|
+
};
|
|
571
|
+
const finish = (error) => {
|
|
572
|
+
if (settled) return;
|
|
573
|
+
settled = true;
|
|
574
|
+
input.off("data", onInput);
|
|
575
|
+
process.off("SIGWINCH", onResize);
|
|
576
|
+
signal?.removeEventListener("abort", onAbort);
|
|
577
|
+
if (rawEnabled && typeof input.setRawMode === "function") input.setRawMode(false);
|
|
578
|
+
if (error) reject(error);
|
|
579
|
+
else resolve();
|
|
580
|
+
};
|
|
581
|
+
const sendResize = () => {
|
|
582
|
+
if (socket.readyState !== WebSocketImpl.OPEN) return;
|
|
583
|
+
socket.send(JSON.stringify({
|
|
584
|
+
type: "resize",
|
|
585
|
+
cols: Number(output.columns) || 80,
|
|
586
|
+
rows: Number(output.rows) || 24,
|
|
587
|
+
}));
|
|
588
|
+
};
|
|
589
|
+
const onResize = () => sendResize();
|
|
590
|
+
const onInput = (chunk) => {
|
|
591
|
+
const value = Buffer.from(chunk);
|
|
592
|
+
const detachAt = value.indexOf(0x1d);
|
|
593
|
+
if (detachAt >= 0) {
|
|
594
|
+
if (detachAt > 0 && socket.readyState === WebSocketImpl.OPEN) {
|
|
595
|
+
socket.send(value.subarray(0, detachAt), { binary: true });
|
|
596
|
+
}
|
|
597
|
+
output.write("\r\nDetached. Pi and the Dev Session are still running.\r\n");
|
|
598
|
+
socket.close(1000, "client_detach");
|
|
599
|
+
finish();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (socket.readyState === WebSocketImpl.OPEN) socket.send(value, { binary: true });
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
if (signal?.aborted) {
|
|
606
|
+
onAbort();
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
610
|
+
|
|
611
|
+
socket.on("message", (data, isBinary) => {
|
|
612
|
+
if (isBinary) {
|
|
613
|
+
output.write(Buffer.from(data));
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
let control;
|
|
617
|
+
try { control = JSON.parse(data.toString()); } catch { return; }
|
|
618
|
+
if (control.type === "ready" && !ready) {
|
|
619
|
+
ready = true;
|
|
620
|
+
if (typeof input.setRawMode === "function") {
|
|
621
|
+
input.setRawMode(true);
|
|
622
|
+
rawEnabled = true;
|
|
623
|
+
}
|
|
624
|
+
input.resume?.();
|
|
625
|
+
input.on("data", onInput);
|
|
626
|
+
process.on("SIGWINCH", onResize);
|
|
627
|
+
sendResize();
|
|
628
|
+
} else if (control.type === "error") {
|
|
629
|
+
finish(new Error(control.message || "Dev Session terminal failed."));
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
socket.once("unexpected-response", (_request, response) => {
|
|
633
|
+
finish(new Error(`Dev Session terminal refused the connection (HTTP ${response.statusCode || 500}).`));
|
|
634
|
+
});
|
|
635
|
+
socket.once("error", (error) => finish(new Error(`Dev Session terminal connection failed: ${error.message}`)));
|
|
636
|
+
socket.once("close", (code) => {
|
|
637
|
+
if (!ready && !settled) finish(new Error(`Dev Session terminal closed before it was ready (code ${code}).`));
|
|
638
|
+
else if (ready && code !== 1000 && !settled) finish(new Error("Dev Session terminal connection was lost. Rerun `xevy dev` to reattach."));
|
|
639
|
+
else finish();
|
|
640
|
+
});
|
|
641
|
+
});
|
|
549
642
|
}
|
|
550
643
|
|
|
551
644
|
function commandHelp(writeLine) {
|
|
@@ -747,6 +840,22 @@ export async function runDevSession(options) {
|
|
|
747
840
|
});
|
|
748
841
|
sessionSummary(task, session, writeLine);
|
|
749
842
|
|
|
843
|
+
const nativeTerminal = options.nativeTerminal
|
|
844
|
+
?? (input === process.stdin && output === process.stdout);
|
|
845
|
+
if (interactive && nativeTerminal) {
|
|
846
|
+
await attachNativeTerminal({
|
|
847
|
+
api,
|
|
848
|
+
base,
|
|
849
|
+
sessionPath,
|
|
850
|
+
input,
|
|
851
|
+
output,
|
|
852
|
+
signal: detachController.signal,
|
|
853
|
+
WebSocketImpl: options.webSocketImpl || WebSocket,
|
|
854
|
+
});
|
|
855
|
+
detached = true;
|
|
856
|
+
return { task, session, detached: true };
|
|
857
|
+
}
|
|
858
|
+
|
|
750
859
|
const renderState = {
|
|
751
860
|
messageIds: new Set(),
|
|
752
861
|
lastExecutionStatus: null,
|
package/bin/xevy.mjs
CHANGED
|
@@ -133,11 +133,11 @@ function devUsage() {
|
|
|
133
133
|
xevy dev <task-id-or-code> [--base <url>]
|
|
134
134
|
|
|
135
135
|
Connects this terminal to the task's remote Dev Session. The command attaches
|
|
136
|
-
to an existing session or starts one from a linked repository
|
|
137
|
-
|
|
136
|
+
to an existing session or starts one from a linked repository, then opens Pi's
|
|
137
|
+
native interactive terminal inside the isolated remote workspace.
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
Terminal control:
|
|
140
|
+
Ctrl+] Detach without stopping Pi or the Dev Session
|
|
141
141
|
|
|
142
142
|
Credentials:
|
|
143
143
|
XEVY_API_KEY takes precedence over ~/.config/xevy/credentials.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xevy/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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": [
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=18"
|
|
25
25
|
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"ws": "^8.18.3"
|
|
28
|
+
},
|
|
26
29
|
"publishConfig": {
|
|
27
30
|
"access": "public"
|
|
28
31
|
}
|