@xevy/cli 0.1.22 → 0.1.24
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 +19 -5
- package/bin/dev-session.mjs +77 -11
- package/bin/xevy.mjs +97 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,11 +58,19 @@ OAuth.
|
|
|
58
58
|
xevy # open an interactive pi session with Xevy loaded
|
|
59
59
|
xevy "summarise this repo" # or send a one-off prompt
|
|
60
60
|
xevy dev task/VI22-07 # attach to a task's remote Dev Session
|
|
61
|
-
xevy dev xevy/xevyai #
|
|
61
|
+
xevy dev xevy/xevyai # select a running project workspace
|
|
62
|
+
xevy dev xevy/xevyai --new # create another workspace
|
|
63
|
+
xevy dev session/<uuid> # open one exact session
|
|
64
|
+
xevy dev session/<uuid> --rename "Checkout fix" # change its display name
|
|
62
65
|
```
|
|
63
66
|
|
|
64
67
|
That's it — you're set up. The sections below are reference for when you need more detail.
|
|
65
68
|
|
|
69
|
+
Every `xevy` launch checks the hosted package manifest. When an existing global
|
|
70
|
+
skills installation is older, Xevy updates those skills before opening pi. A
|
|
71
|
+
network or package-registry failure leaves the installed skills in place and
|
|
72
|
+
continues the launch with a warning.
|
|
73
|
+
|
|
66
74
|
## Upgrading
|
|
67
75
|
|
|
68
76
|
Keep the Xevy extensions and SDLC skills current (run after Xevy releases):
|
|
@@ -132,7 +140,9 @@ via `@xevy/skills`; your saved API key is left untouched. These commands accept
|
|
|
132
140
|
## `xevy`
|
|
133
141
|
|
|
134
142
|
Opens pi, loading `~/.xevy/extensions` via `pi -e …` (pi also auto-loads the
|
|
135
|
-
global dir, so core + model + MCP come along).
|
|
143
|
+
global dir, so core + model + MCP come along). Before pi starts, Xevy checks the
|
|
144
|
+
installed skills version and applies an available skills-only update. Extra
|
|
145
|
+
arguments are forwarded to pi:
|
|
136
146
|
|
|
137
147
|
```bash
|
|
138
148
|
xevy # interactive pi session with Xevy
|
|
@@ -141,12 +151,14 @@ xevy "summarise this repo" # forwards the prompt to pi
|
|
|
141
151
|
|
|
142
152
|
## `xevy dev`
|
|
143
153
|
|
|
144
|
-
Connect an interactive terminal to a task or
|
|
154
|
+
Connect an interactive terminal to a task-linked or task-free remote Dev Session:
|
|
145
155
|
|
|
146
156
|
```bash
|
|
147
157
|
xevy dev task/VI22-07
|
|
148
158
|
xevy dev task/cb49c02e-66d8-4475-95a8-6f3930643ec8
|
|
149
|
-
xevy dev xevy/xevyai
|
|
159
|
+
xevy dev xevy/xevyai --new
|
|
160
|
+
xevy dev xevy/xevyai --request-key <uuid>
|
|
161
|
+
xevy dev session/<uuid> --rename "Checkout fix"
|
|
150
162
|
xevy dev xevy/xevyai --base https://xevy.example.com
|
|
151
163
|
```
|
|
152
164
|
|
|
@@ -156,7 +168,7 @@ a `Ctrl+C` detach hint; press `Ctrl+]` while attached to leave the Dev Session
|
|
|
156
168
|
running immediately.
|
|
157
169
|
|
|
158
170
|
The CLI grammar is explicit: `task/<task-id-or-code>` selects a task session,
|
|
159
|
-
while `<workspace>/<project>` selects your default
|
|
171
|
+
while `<workspace>/<project>` selects your default task-free project workspace.
|
|
160
172
|
Bare task IDs, aliases, and scope-guessing are intentionally unsupported. After
|
|
161
173
|
the target is resolved, the CLI renders Pi's native TUI from the isolated remote
|
|
162
174
|
workspace: normal composer, thinking, tools, history, keyboard shortcuts, and
|
|
@@ -226,3 +238,5 @@ See the [`@xevy/skills` README](../xevy-skills/README.md) for the full command l
|
|
|
226
238
|
per-agent flags, and manual install steps.
|
|
227
239
|
|
|
228
240
|
Docs: <https://xevy.ai/docs/mcp>
|
|
241
|
+
|
|
242
|
+
New workspaces open the editor and terminal first. Start repository runtimes when you need a preview. Each new task-free session has a separate branch. The CLI prints a request UUID before creation; repeat it with `--request-key` if the response is lost.
|
package/bin/dev-session.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { spawn } from "node:child_process";
|
|
2
3
|
import readline from "node:readline";
|
|
3
4
|
import WebSocket from "ws";
|
|
@@ -21,13 +22,17 @@ const DEV_TARGET_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
|
21
22
|
function parseDevTarget(value) {
|
|
22
23
|
const reference = String(value || "").trim();
|
|
23
24
|
const segments = reference.split("/");
|
|
24
|
-
const usage = "Use `task/<task-id-or-code>` or `<workspace>/<project>`.";
|
|
25
|
+
const usage = "Use `session/<session-id>`, `task/<task-id-or-code>` or `<workspace>/<project>`.";
|
|
25
26
|
if (segments.length !== 2 || segments.some((segment) => !segment)) {
|
|
26
27
|
throw new Error(`Invalid Dev Session target '${reference}'. ${usage}`);
|
|
27
28
|
}
|
|
28
29
|
if (segments.some((segment) => !DEV_TARGET_SEGMENT_PATTERN.test(segment))) {
|
|
29
30
|
throw new Error(`Invalid Dev Session target '${reference}'. Identifiers may use letters, numbers, '.', '_', and '-'.`);
|
|
30
31
|
}
|
|
32
|
+
if (segments[0] === "session") {
|
|
33
|
+
if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(segments[1])) throw new Error("Use a session UUID after session/.");
|
|
34
|
+
return { kind: "session", sessionId: segments[1] };
|
|
35
|
+
}
|
|
31
36
|
if (segments[0] === "task") {
|
|
32
37
|
return { kind: "task", taskReference: segments[1] };
|
|
33
38
|
}
|
|
@@ -76,9 +81,25 @@ export function parseDevCommandArgs(argv) {
|
|
|
76
81
|
const args = [...argv];
|
|
77
82
|
let targetReference = "";
|
|
78
83
|
let base = null;
|
|
84
|
+
let newSession = false;
|
|
85
|
+
let requestKey;
|
|
86
|
+
let rename;
|
|
79
87
|
while (args.length > 0) {
|
|
80
88
|
const argument = args.shift();
|
|
81
89
|
if (argument === "-h" || argument === "--help") return { help: true, target: null, base: null };
|
|
90
|
+
if (argument === "--new") { newSession = true; continue; }
|
|
91
|
+
if (argument === "--request-key" || argument === "--rename") {
|
|
92
|
+
const value = args.shift();
|
|
93
|
+
if (!value) throw new Error(`Missing value for ${argument}`);
|
|
94
|
+
if (argument === "--request-key") {
|
|
95
|
+
if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value)) throw new Error("--request-key must be a UUID.");
|
|
96
|
+
requestKey = value; newSession = true;
|
|
97
|
+
} else {
|
|
98
|
+
rename = value.trim();
|
|
99
|
+
if (!rename || rename.length > 80 || /\p{Cc}/u.test(rename)) throw new Error("--rename needs a single-line name of 1–80 characters.");
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
82
103
|
if (argument === "--base") {
|
|
83
104
|
const value = args.shift();
|
|
84
105
|
if (!value) throw new Error("Missing value for --base");
|
|
@@ -92,7 +113,10 @@ export function parseDevCommandArgs(argv) {
|
|
|
92
113
|
if (!targetReference) {
|
|
93
114
|
throw new Error("Usage: xevy dev <task/<task-id-or-code>|workspace/project> [--base <url>]");
|
|
94
115
|
}
|
|
95
|
-
|
|
116
|
+
const target = parseDevTarget(targetReference);
|
|
117
|
+
if (newSession && target.kind !== "personal") throw new Error("--new and --request-key apply to workspace/project targets.");
|
|
118
|
+
if (rename && target.kind !== "session") throw new Error("--rename requires session/<session-id>.");
|
|
119
|
+
return { help: false, target, base, ...(newSession ? { newSession } : {}), ...(requestKey ? { requestKey } : {}), ...(rename ? { rename } : {}) };
|
|
96
120
|
}
|
|
97
121
|
|
|
98
122
|
export function resolveDevConnection({
|
|
@@ -626,13 +650,18 @@ function sessionSummary(context, session, base, writeLine) {
|
|
|
626
650
|
const url = task
|
|
627
651
|
? devSessionLaunchUrl(base, task)
|
|
628
652
|
: new URL(`/agent?session=${encodeURIComponent(session.id)}`, `${normalizeBaseUrl(base)}/`).toString();
|
|
629
|
-
writeLine(
|
|
653
|
+
writeLine(`\nDev Session${session.title ? ` · ${session.title}` : ""}`);
|
|
630
654
|
if (task) writeLine(` Task ${formatTask(task)}`);
|
|
631
|
-
else writeLine(` Project ${context.workspace.identifier}/${context.project.identifier}
|
|
655
|
+
else writeLine(` Project ${context.workspace.identifier}/${context.project.identifier}`);
|
|
632
656
|
writeLine(` Workbench ${url || "not available yet"}`);
|
|
633
|
-
|
|
657
|
+
const health = session.runtimeHealth || session.config?.runtimeHealth;
|
|
658
|
+
const preview = health?.status === "stopped" ? "stopped · start a runtime in the workbench"
|
|
659
|
+
: health && health.status !== "ready" ? health.status
|
|
660
|
+
: session.config?.runtimeMode === "none" || !session.hostname ? "none (workspace only)" : `https://${session.hostname}`;
|
|
661
|
+
writeLine(` Preview ${preview}`);
|
|
634
662
|
writeLine(` Branch ${session.branch || session.config?.branch || "unknown"}`);
|
|
635
663
|
writeLine(` Status ${session.status}`);
|
|
664
|
+
if (session.runtimeHealth) writeLine(` Runtime ${session.runtimeHealth.status}${session.runtimeHealth.error ? ` · ${session.runtimeHealth.error.message}` : ""}`);
|
|
636
665
|
writeLine(` Expires ${session.expiresAt || "server-managed"}`);
|
|
637
666
|
writeLine("\nXevy terminal · press Ctrl+] to detach and leave it running\n");
|
|
638
667
|
}
|
|
@@ -835,6 +864,8 @@ function commandHelp(writeLine, hasWebPreview = true) {
|
|
|
835
864
|
writeLine("Commands:");
|
|
836
865
|
writeLine(" /status Refresh session status");
|
|
837
866
|
writeLine(" /logs Show the latest Dev Session logs");
|
|
867
|
+
writeLine(" /merge-main Merge current main into the workspace");
|
|
868
|
+
if (hasWebPreview) writeLine(" /retry Retry preview setup in the current workspace");
|
|
838
869
|
if (hasWebPreview) writeLine(" /open Open a fresh one-use Dev Session URL");
|
|
839
870
|
writeLine(" /finish Save the task branch and stop");
|
|
840
871
|
writeLine(" /stop Stop the Dev Session without finishing");
|
|
@@ -882,7 +913,7 @@ export async function runDevSession(options) {
|
|
|
882
913
|
throw new Error("A Xevy API key is required. Run `xevy setup --credentials` first.");
|
|
883
914
|
}
|
|
884
915
|
const target = options.target;
|
|
885
|
-
if (!target || !["task", "personal"].includes(target.kind)) {
|
|
916
|
+
if (!target || !["task", "personal", "session"].includes(target.kind)) {
|
|
886
917
|
throw new Error("Usage: xevy dev <task/<task-id-or-code>|workspace/project> [--base <url>]");
|
|
887
918
|
}
|
|
888
919
|
|
|
@@ -959,7 +990,24 @@ export async function runDevSession(options) {
|
|
|
959
990
|
try {
|
|
960
991
|
// Validate both host and key before resolving any session context.
|
|
961
992
|
await api.request("/api/profile", { signal: detachController.signal });
|
|
962
|
-
if (target.kind === "
|
|
993
|
+
if (target.kind === "session") {
|
|
994
|
+
sessionPath = `/api/agent/dev-sessions/${encodeURIComponent(target.sessionId)}`;
|
|
995
|
+
const current = await api.request(sessionPath, { signal: detachController.signal });
|
|
996
|
+
session = current?.session;
|
|
997
|
+
if (!session) throw new Error("Dev Session not found.");
|
|
998
|
+
if (options.rename) {
|
|
999
|
+
const updated = await api.request(sessionPath, { method: "PATCH", body: { name: options.rename }, signal: detachController.signal });
|
|
1000
|
+
session = updated?.session || session;
|
|
1001
|
+
writeLine("Dev Session renamed.");
|
|
1002
|
+
}
|
|
1003
|
+
if (session.task) {
|
|
1004
|
+
task = { ...session.task, workspaceIdentifier: session.workspace.identifier, projectIdentifier: session.project.identifier };
|
|
1005
|
+
context = { kind: "task", task };
|
|
1006
|
+
} else {
|
|
1007
|
+
context = { kind: "personal", workspace: session.workspace, project: session.project };
|
|
1008
|
+
}
|
|
1009
|
+
writeLine(`Opening ${session.title || "Dev Session"}…`);
|
|
1010
|
+
} else if (target.kind === "task") {
|
|
963
1011
|
const search = await api.request("/api/tasks/search", {
|
|
964
1012
|
method: "POST",
|
|
965
1013
|
body: { taskIdentifier: target.taskReference },
|
|
@@ -1014,12 +1062,15 @@ export async function runDevSession(options) {
|
|
|
1014
1062
|
`/api/agent/dev-session-candidates?projectId=${encodeURIComponent(project.id)}`,
|
|
1015
1063
|
{ signal: detachController.signal },
|
|
1016
1064
|
);
|
|
1017
|
-
const
|
|
1065
|
+
const running = candidates?.personal?.existingSessions?.length ? candidates.personal.existingSessions
|
|
1066
|
+
: candidates?.personal?.existingSessionId ? [{ id: candidates.personal.existingSessionId, title: "Running workspace" }] : [];
|
|
1067
|
+
const choice = options.newSession ? null : await selectOne({ items: running, label: "sessions", describe: (item) => `${item.title} · ${item.id}`, interactive, ask, writeLine });
|
|
1068
|
+
const existingSessionId = choice?.id || null;
|
|
1018
1069
|
if (existingSessionId) {
|
|
1019
1070
|
sessionPath = `/api/agent/dev-sessions/${encodeURIComponent(existingSessionId)}`;
|
|
1020
1071
|
const current = await api.request(sessionPath, { signal: detachController.signal });
|
|
1021
1072
|
session = current?.session || null;
|
|
1022
|
-
if (session) writeLine("
|
|
1073
|
+
if (session) writeLine("Opening your running Dev Session…");
|
|
1023
1074
|
}
|
|
1024
1075
|
if (!session) {
|
|
1025
1076
|
const repositories = candidates?.repositories || [];
|
|
@@ -1034,12 +1085,15 @@ export async function runDevSession(options) {
|
|
|
1034
1085
|
ask,
|
|
1035
1086
|
writeLine,
|
|
1036
1087
|
});
|
|
1037
|
-
writeLine(`Starting
|
|
1088
|
+
writeLine(`Starting new Dev Session with ${repository.displayName || repository.role}…`);
|
|
1089
|
+
const requestKey = options.requestKey || randomUUID();
|
|
1090
|
+
writeLine(`New request ${requestKey} · retry safely with --request-key ${requestKey}`);
|
|
1038
1091
|
const started = await api.request("/api/agent/dev-sessions", {
|
|
1039
1092
|
method: "POST",
|
|
1040
1093
|
body: {
|
|
1041
1094
|
target: {
|
|
1042
1095
|
kind: "personal",
|
|
1096
|
+
requestKey,
|
|
1043
1097
|
projectId: project.id,
|
|
1044
1098
|
runtimeRepositoryId: repository.id,
|
|
1045
1099
|
},
|
|
@@ -1087,7 +1141,7 @@ export async function runDevSession(options) {
|
|
|
1087
1141
|
if (interactive && nativeTerminal) {
|
|
1088
1142
|
const reattachTarget = context.kind === "task"
|
|
1089
1143
|
? `task/${task.taskCode || task.id}`
|
|
1090
|
-
:
|
|
1144
|
+
: `session/${session.id}`;
|
|
1091
1145
|
await attachNativeTerminalOnce({
|
|
1092
1146
|
api,
|
|
1093
1147
|
base,
|
|
@@ -1165,6 +1219,18 @@ export async function runDevSession(options) {
|
|
|
1165
1219
|
if (!(logs?.lines || []).length) writeLine("No Dev Session logs yet.");
|
|
1166
1220
|
continue;
|
|
1167
1221
|
}
|
|
1222
|
+
if (prompt === "/merge-main") {
|
|
1223
|
+
const result = await api.request(`/api/agent/dev-sessions/${encodeURIComponent(session.id)}/merge-main`, { method: "POST", body: {}, timeoutMs: 220_000, signal: detachController.signal });
|
|
1224
|
+
for (const repo of result.repositories || []) writeLine(`${repo.dir}: ${repo.status} · ${repo.baseBranch}@${repo.baseSha}${repo.message ? ` · ${repo.message}` : ""}`);
|
|
1225
|
+
if (result.session) session = { ...session, status: result.session.state, runtimeHealth: result.session.runtimeHealth };
|
|
1226
|
+
continue;
|
|
1227
|
+
}
|
|
1228
|
+
if (prompt === "/retry") {
|
|
1229
|
+
const result = await api.request(`/api/agent/dev-sessions/${encodeURIComponent(session.id)}/retry-runtime`, { method: "POST", body: {}, signal: detachController.signal });
|
|
1230
|
+
session = result.session;
|
|
1231
|
+
writeLine("Preview retry started in the current workspace. Use /status or /logs to follow it.");
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1168
1234
|
if (prompt === "/open") {
|
|
1169
1235
|
if (session.config?.runtimeMode === "none" || !session.hostname) {
|
|
1170
1236
|
writeLine("This Dev Session has no web runtime or live preview.");
|
package/bin/xevy.mjs
CHANGED
|
@@ -40,6 +40,7 @@ const PI_BIN = isWindows ? "pi.cmd" : "pi";
|
|
|
40
40
|
const XEVY_EXTENSIONS_DIR = path.join(os.homedir(), ".xevy", "extensions");
|
|
41
41
|
const XEVY_EXTENSION_FILE = "xevy.ts";
|
|
42
42
|
const API_KEY_PREFIX = "xevy_pk_";
|
|
43
|
+
const SKILLS_UPDATE_CHECK_TIMEOUT_MS = 3_000;
|
|
43
44
|
|
|
44
45
|
// Credentials file the xevy.ts extension reads (baseUrl + token).
|
|
45
46
|
const CREDENTIALS_DIR = path.join(
|
|
@@ -47,6 +48,7 @@ const CREDENTIALS_DIR = path.join(
|
|
|
47
48
|
"xevy",
|
|
48
49
|
);
|
|
49
50
|
const CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, "credentials");
|
|
51
|
+
const SKILLS_INSTALL_STAMP_FILE = path.join(CREDENTIALS_DIR, "skills-package.json");
|
|
50
52
|
|
|
51
53
|
// pi's global extensions dir — core + model + MCP are installed here so they
|
|
52
54
|
// load in every pi session.
|
|
@@ -96,7 +98,7 @@ function usage() {
|
|
|
96
98
|
xevy setup [options] Choose credentials, pi, skills, and MCP setup
|
|
97
99
|
xevy update [--base u] Refresh the pi extensions + coding-agent skills/MCP
|
|
98
100
|
xevy check [--base u] Report skill updates or missing coding-agent targets
|
|
99
|
-
xevy dev <target> Attach to a remote task or
|
|
101
|
+
xevy dev <target> Attach to a remote task or task-free Dev Session
|
|
100
102
|
|
|
101
103
|
Options:
|
|
102
104
|
--base <url> Xevy host (default: XEVY_BASE or ${DEFAULT_BASE})
|
|
@@ -132,11 +134,13 @@ function devUsage() {
|
|
|
132
134
|
console.log(`Xevy Dev Session
|
|
133
135
|
|
|
134
136
|
xevy dev task/<task-id-or-code> [--base <url>]
|
|
135
|
-
xevy dev <workspace>/<project> [--base <url>]
|
|
137
|
+
xevy dev <workspace>/<project> [--new] [--request-key <uuid>] [--base <url>]
|
|
138
|
+
xevy dev session/<session-id> [--rename <name>] [--base <url>]
|
|
136
139
|
|
|
137
140
|
Connects this terminal to a remote Dev Session. The reserved task/ prefix
|
|
138
|
-
selects task work;
|
|
139
|
-
|
|
141
|
+
selects task work; workspace/project selects a running workspace. Use --new
|
|
142
|
+
for another session, and reuse --request-key after a failed create. A session/
|
|
143
|
+
target opens one exact workspace and --rename changes its display name. Xevy runs inside the isolated remote workspace.
|
|
140
144
|
|
|
141
145
|
Terminal control:
|
|
142
146
|
Ctrl+] Detach without stopping Xevy or the Dev Session
|
|
@@ -161,7 +165,7 @@ function parseArgv(argv) {
|
|
|
161
165
|
try {
|
|
162
166
|
const parsed = parseDevCommandArgs(args);
|
|
163
167
|
if (parsed.help) return { command: "dev-help" };
|
|
164
|
-
return { command: "dev",
|
|
168
|
+
return { command: "dev", ...parsed };
|
|
165
169
|
} catch (error) {
|
|
166
170
|
die(error instanceof Error ? error.message : String(error));
|
|
167
171
|
}
|
|
@@ -273,17 +277,24 @@ function ensurePi() {
|
|
|
273
277
|
// the MCP install here targets external coding agents and does not conflict
|
|
274
278
|
// with pi. Non-fatal: core pi setup has already succeeded, so an integration
|
|
275
279
|
// hiccup warns with the manual command instead of aborting.
|
|
276
|
-
function installAgentIntegration(base, agents, packageCommand) {
|
|
280
|
+
function installAgentIntegration(base, agents, packageCommand, options = {}) {
|
|
277
281
|
const args = ["--yes", "@xevy/skills", packageCommand, "-y"];
|
|
282
|
+
if (options.skillsOnly) args.push("--skills-only");
|
|
283
|
+
if (options.manifest) args.push("--manifest");
|
|
278
284
|
if (base !== DEFAULT_BASE) args.push("--base", base);
|
|
279
285
|
for (const agent of agents) args.push("-a", agent);
|
|
280
|
-
const
|
|
286
|
+
const integrationLabel = options.skillsOnly ? "coding-agent skills" : "coding-agent skills + MCP";
|
|
287
|
+
const label = `npx @xevy/skills ${packageCommand} (${integrationLabel})`;
|
|
281
288
|
console.log(`→ ${label}`);
|
|
282
289
|
const command = isWindows ? "npx.cmd" : "npx";
|
|
283
290
|
const r = spawnSync(command, args, { stdio: "inherit", shell: isWindows, env: process.env });
|
|
284
291
|
if (r.error || r.status !== 0) {
|
|
285
292
|
console.warn(`⚠ Could not configure coding agents (${r.error ? r.error.message : `exit ${r.status}`}).`);
|
|
286
|
-
console.warn(
|
|
293
|
+
console.warn(
|
|
294
|
+
options.skillsOnly
|
|
295
|
+
? " Retry later with: npx @xevy/skills update -y --skills-only"
|
|
296
|
+
: " Configure them later with: npx @xevy/skills -y",
|
|
297
|
+
);
|
|
287
298
|
return false;
|
|
288
299
|
}
|
|
289
300
|
return true;
|
|
@@ -359,6 +370,73 @@ function readStoredCredentials() {
|
|
|
359
370
|
return { baseUrl: null, token: null };
|
|
360
371
|
}
|
|
361
372
|
|
|
373
|
+
function readSkillsInstallStamp() {
|
|
374
|
+
try {
|
|
375
|
+
if (!fs.existsSync(SKILLS_INSTALL_STAMP_FILE)) return null;
|
|
376
|
+
const stamp = JSON.parse(fs.readFileSync(SKILLS_INSTALL_STAMP_FILE, "utf-8"));
|
|
377
|
+
const version = typeof stamp?.version === "string" ? stamp.version.trim() : "";
|
|
378
|
+
if (!/^\d+\.\d+\.\d+$/.test(version)) return null;
|
|
379
|
+
const agents = Array.isArray(stamp.agents)
|
|
380
|
+
? stamp.agents
|
|
381
|
+
.map((agent) => typeof agent === "string" ? agent.trim() : "")
|
|
382
|
+
.filter(Boolean)
|
|
383
|
+
: [];
|
|
384
|
+
return { version, agents: [...new Set(agents)] };
|
|
385
|
+
} catch {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function comparePackageVersions(left, right) {
|
|
391
|
+
const leftParts = left.split(".").map(Number);
|
|
392
|
+
const rightParts = right.split(".").map(Number);
|
|
393
|
+
for (let index = 0; index < 3; index += 1) {
|
|
394
|
+
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
395
|
+
if (difference !== 0) return difference > 0 ? 1 : -1;
|
|
396
|
+
}
|
|
397
|
+
return 0;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function updateOutdatedSkillsBeforeOpen(base) {
|
|
401
|
+
const stamp = readSkillsInstallStamp();
|
|
402
|
+
// Respect component-based setup: opening Xevy updates an existing skills
|
|
403
|
+
// installation and does not silently install skills a user omitted.
|
|
404
|
+
if (!stamp) return;
|
|
405
|
+
|
|
406
|
+
let latestVersion;
|
|
407
|
+
try {
|
|
408
|
+
const response = await fetch(`${base}/api/agent-packages`, {
|
|
409
|
+
headers: { accept: "application/json" },
|
|
410
|
+
signal: AbortSignal.timeout(SKILLS_UPDATE_CHECK_TIMEOUT_MS),
|
|
411
|
+
});
|
|
412
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
413
|
+
const manifest = await response.json();
|
|
414
|
+
latestVersion = String(manifest?.skills?.version || "").trim();
|
|
415
|
+
if (!/^\d+\.\d+\.\d+$/.test(latestVersion)) {
|
|
416
|
+
throw new Error("manifest returned an invalid skills version");
|
|
417
|
+
}
|
|
418
|
+
} catch (error) {
|
|
419
|
+
console.warn(
|
|
420
|
+
`⚠ Could not check Xevy skill updates (${error instanceof Error ? error.message : String(error)}). Opening with the installed skills.`,
|
|
421
|
+
);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (comparePackageVersions(latestVersion, stamp.version) <= 0) return;
|
|
426
|
+
|
|
427
|
+
console.log(`↻ Updating Xevy skills ${stamp.version} → ${latestVersion} before launch…`);
|
|
428
|
+
const agents = stamp.agents.length > 0 ? stamp.agents : DEFAULT_AGENTS;
|
|
429
|
+
const updated = installAgentIntegration(base, agents, "update", {
|
|
430
|
+
skillsOnly: true,
|
|
431
|
+
manifest: true,
|
|
432
|
+
});
|
|
433
|
+
if (updated) {
|
|
434
|
+
console.log(`✓ Xevy skills updated to ${latestVersion}.`);
|
|
435
|
+
} else {
|
|
436
|
+
console.warn(" Opening Xevy with the installed skills; run `xevy update` to retry.");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
362
440
|
/** Return the stored xevy_pk_ token from the credentials file, or null. */
|
|
363
441
|
function readStoredToken() {
|
|
364
442
|
return readStoredCredentials().token;
|
|
@@ -626,7 +704,7 @@ function check(opts) {
|
|
|
626
704
|
process.exit(r.status ?? (r.error ? 1 : 0));
|
|
627
705
|
}
|
|
628
706
|
|
|
629
|
-
function open(opts) {
|
|
707
|
+
async function open(opts) {
|
|
630
708
|
if (!hasPi()) {
|
|
631
709
|
die("pi is not installed. Run `xevy setup` first.");
|
|
632
710
|
}
|
|
@@ -641,13 +719,19 @@ function open(opts) {
|
|
|
641
719
|
die(`No Xevy extensions in ${XEVY_EXTENSIONS_DIR}. Run \`xevy setup\` first.`);
|
|
642
720
|
}
|
|
643
721
|
|
|
722
|
+
const storedBase = readStoredCredentials().baseUrl;
|
|
723
|
+
const updateBase = (
|
|
724
|
+
process.env.XEVY_BASE?.trim() || storedBase || opts.base
|
|
725
|
+
).replace(/\/+$/, "");
|
|
726
|
+
await updateOutdatedSkillsBeforeOpen(updateBase);
|
|
727
|
+
|
|
644
728
|
const piArgs = [];
|
|
645
729
|
for (const f of files) piArgs.push("-e", f);
|
|
646
730
|
piArgs.push(...opts.piArgs);
|
|
647
731
|
|
|
648
732
|
const r = spawnSync(PI_BIN, piArgs, { stdio: "inherit", shell: isWindows, env: process.env });
|
|
649
733
|
if (r.error) die(r.error.message);
|
|
650
|
-
process.
|
|
734
|
+
process.exitCode = r.status ?? 0;
|
|
651
735
|
}
|
|
652
736
|
|
|
653
737
|
async function dev(opts) {
|
|
@@ -666,6 +750,9 @@ async function dev(opts) {
|
|
|
666
750
|
base,
|
|
667
751
|
token,
|
|
668
752
|
target: opts.target,
|
|
753
|
+
newSession: opts.newSession,
|
|
754
|
+
requestKey: opts.requestKey,
|
|
755
|
+
rename: opts.rename,
|
|
669
756
|
});
|
|
670
757
|
}
|
|
671
758
|
|
package/package.json
CHANGED