@silicaclaw/cli 1.0.0-beta.17 → 1.0.0-beta.18
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/package.json +1 -1
- package/scripts/silicaclaw-cli.mjs +70 -0
package/package.json
CHANGED
|
@@ -37,6 +37,19 @@ function runCapture(cmd, args, extra = {}) {
|
|
|
37
37
|
return result;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function runInherit(cmd, args, extra = {}) {
|
|
41
|
+
const result = spawnSync(cmd, args, {
|
|
42
|
+
cwd: ROOT_DIR,
|
|
43
|
+
stdio: "inherit",
|
|
44
|
+
env: process.env,
|
|
45
|
+
...extra,
|
|
46
|
+
});
|
|
47
|
+
if (result.error) {
|
|
48
|
+
throw result.error;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
function readVersion() {
|
|
41
54
|
const versionFile = resolve(ROOT_DIR, "VERSION");
|
|
42
55
|
if (!existsSync(versionFile)) return "unknown";
|
|
@@ -112,6 +125,49 @@ function showUpdateGuide(current, latest, beta) {
|
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|
|
128
|
+
function getGatewayStatus() {
|
|
129
|
+
try {
|
|
130
|
+
const result = runCapture("node", [resolve(ROOT_DIR, "scripts", "silicaclaw-gateway.mjs"), "status"], {
|
|
131
|
+
cwd: process.cwd(),
|
|
132
|
+
});
|
|
133
|
+
if ((result.status ?? 1) !== 0) return null;
|
|
134
|
+
const text = String(result.stdout || "").trim();
|
|
135
|
+
return text ? JSON.parse(text) : null;
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function restartGatewayIfRunning() {
|
|
142
|
+
const status = getGatewayStatus();
|
|
143
|
+
const localRunning = Boolean(status?.local_console?.running);
|
|
144
|
+
const signalingRunning = Boolean(status?.signaling?.running);
|
|
145
|
+
if (!localRunning && !signalingRunning) {
|
|
146
|
+
console.log("Gateway not running: no restart needed.");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const mode = String(status?.mode || "local");
|
|
151
|
+
const args = [resolve(ROOT_DIR, "scripts", "silicaclaw-gateway.mjs"), "restart", `--mode=${mode}`];
|
|
152
|
+
if (mode === "global-preview" && status?.signaling?.url) {
|
|
153
|
+
args.push(`--signaling-url=${status.signaling.url}`);
|
|
154
|
+
}
|
|
155
|
+
if (mode === "global-preview" && status?.signaling?.room) {
|
|
156
|
+
args.push(`--room=${status.signaling.room}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log("Refreshing gateway services...");
|
|
160
|
+
runInherit("node", args, { cwd: process.cwd() });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function tryGlobalUpgrade(beta) {
|
|
164
|
+
const writableGlobal = canWriteGlobalPrefix();
|
|
165
|
+
if (!writableGlobal) return false;
|
|
166
|
+
console.log(`Installing @silicaclaw/cli@${beta} globally...`);
|
|
167
|
+
const result = runInherit("npm", ["i", "-g", `@silicaclaw/cli@${beta}`]);
|
|
168
|
+
return (result.status ?? 1) === 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
115
171
|
function update() {
|
|
116
172
|
const current = readPackageVersion();
|
|
117
173
|
try {
|
|
@@ -126,6 +182,20 @@ function update() {
|
|
|
126
182
|
const latest = tags.latest ? String(tags.latest) : "";
|
|
127
183
|
const beta = tags.beta ? String(tags.beta) : "";
|
|
128
184
|
showUpdateGuide(current, latest, beta);
|
|
185
|
+
const hasNewBeta = Boolean(beta) && beta !== current;
|
|
186
|
+
const npxRuntime = isNpxRun();
|
|
187
|
+
|
|
188
|
+
if (hasNewBeta) {
|
|
189
|
+
if (npxRuntime) {
|
|
190
|
+
console.log(`New beta detected (${beta}). npx will use latest on next run.`);
|
|
191
|
+
} else if (tryGlobalUpgrade(beta)) {
|
|
192
|
+
console.log(`Global upgrade completed: ${beta}`);
|
|
193
|
+
} else {
|
|
194
|
+
console.log("Skipped global upgrade (no write permission or upgrade failed).");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
restartGatewayIfRunning();
|
|
129
199
|
process.exit(0);
|
|
130
200
|
} catch (error) {
|
|
131
201
|
console.error(`Update check failed: ${error.message}`);
|