wispy-cli 2.7.27 → 2.7.28
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/bin/wispy.mjs +70 -1
- package/package.json +1 -1
package/bin/wispy.mjs
CHANGED
|
@@ -1447,12 +1447,13 @@ if (command === "update" || command === "upgrade") {
|
|
|
1447
1447
|
// ── Guard: known commands that fall through to REPL ───────────────────────────
|
|
1448
1448
|
|
|
1449
1449
|
const REPL_COMMANDS = new Set(["server", "overview", undefined]);
|
|
1450
|
+
const LATE_COMMANDS = new Set(["stop", "status"]); // handled after the guard
|
|
1450
1451
|
// If command looks like a flag (starts with -), it's a REPL arg (e.g., wispy -w project)
|
|
1451
1452
|
// If command is undefined (no args), start REPL
|
|
1452
1453
|
// If command is a known REPL command, fall through
|
|
1453
1454
|
// Otherwise, if it looks like an unknown command (not a chat message), warn
|
|
1454
1455
|
|
|
1455
|
-
if (command && !REPL_COMMANDS.has(command) && !command.startsWith("-")) {
|
|
1456
|
+
if (command && !REPL_COMMANDS.has(command) && !LATE_COMMANDS.has(command) && !command.startsWith("-")) {
|
|
1456
1457
|
// Check if it could be a chat message (contains spaces, is long, etc.)
|
|
1457
1458
|
const fullPrompt = args.join(" ");
|
|
1458
1459
|
if (fullPrompt.length < 30 && !fullPrompt.includes(" ") && /^[a-z][a-z0-9-]*$/i.test(command)) {
|
|
@@ -1464,6 +1465,74 @@ if (command && !REPL_COMMANDS.has(command) && !command.startsWith("-")) {
|
|
|
1464
1465
|
}
|
|
1465
1466
|
}
|
|
1466
1467
|
|
|
1468
|
+
// ── Stop / Status ─────────────────────────────────────────────────────────────
|
|
1469
|
+
|
|
1470
|
+
if (command === "stop") {
|
|
1471
|
+
// Kill any running wispy processes (server, TUI) except this one
|
|
1472
|
+
const { execSync } = await import("node:child_process");
|
|
1473
|
+
const myPid = process.pid;
|
|
1474
|
+
try {
|
|
1475
|
+
const pids = execSync("pgrep -f 'wispy-tui\\|wispy.mjs\\|wispy-cli' 2>/dev/null || true", { encoding: "utf8" })
|
|
1476
|
+
.trim().split("\n").filter(p => p && Number(p) !== myPid);
|
|
1477
|
+
if (pids.length === 0) {
|
|
1478
|
+
console.log(" No running wispy processes found.");
|
|
1479
|
+
} else {
|
|
1480
|
+
for (const pid of pids) {
|
|
1481
|
+
try { process.kill(Number(pid), "SIGTERM"); } catch {}
|
|
1482
|
+
}
|
|
1483
|
+
console.log(` Stopped ${pids.length} wispy process(es).`);
|
|
1484
|
+
}
|
|
1485
|
+
} catch {
|
|
1486
|
+
console.log(" No running wispy processes found.");
|
|
1487
|
+
}
|
|
1488
|
+
// Also try stopping server via PID file
|
|
1489
|
+
try {
|
|
1490
|
+
const pidFile = join(rootDir, "..", "..", ".wispy", "server.pid");
|
|
1491
|
+
const { readFile: rf } = await import("node:fs/promises");
|
|
1492
|
+
const serverPid = (await rf(pidFile, "utf8")).trim();
|
|
1493
|
+
if (serverPid) {
|
|
1494
|
+
try { process.kill(Number(serverPid), "SIGTERM"); } catch {}
|
|
1495
|
+
console.log(` Server (PID ${serverPid}) stopped.`);
|
|
1496
|
+
}
|
|
1497
|
+
} catch {}
|
|
1498
|
+
process.exit(0);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
if (command === "status") {
|
|
1502
|
+
const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf8"));
|
|
1503
|
+
console.log(`\n wispy-cli v${pkg.version}`);
|
|
1504
|
+
|
|
1505
|
+
// Check server
|
|
1506
|
+
try {
|
|
1507
|
+
const port = process.env.AWOS_PORT ?? "8090";
|
|
1508
|
+
const resp = await fetch(`http://127.0.0.1:${port}/api/health`, { signal: AbortSignal.timeout(2000) });
|
|
1509
|
+
if (resp.ok) console.log(` Server: running (port ${port})`);
|
|
1510
|
+
else console.log(" Server: not running");
|
|
1511
|
+
} catch {
|
|
1512
|
+
console.log(" Server: not running");
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// Check browser bridge
|
|
1516
|
+
try {
|
|
1517
|
+
const resp = await fetch("http://127.0.0.1:3000/health", { signal: AbortSignal.timeout(2000) });
|
|
1518
|
+
if (resp.ok) console.log(" Browser: connected");
|
|
1519
|
+
else console.log(" Browser: not running");
|
|
1520
|
+
} catch {
|
|
1521
|
+
console.log(" Browser: not running");
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// Check running processes
|
|
1525
|
+
const { execSync } = await import("node:child_process");
|
|
1526
|
+
try {
|
|
1527
|
+
const count = execSync("pgrep -fc 'wispy-tui\\|wispy.mjs' 2>/dev/null || echo 0", { encoding: "utf8" }).trim();
|
|
1528
|
+
console.log(` Processes: ${count} wispy instance(s)`);
|
|
1529
|
+
} catch {
|
|
1530
|
+
console.log(" Processes: unknown");
|
|
1531
|
+
}
|
|
1532
|
+
console.log("");
|
|
1533
|
+
process.exit(0);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1467
1536
|
if (command === "server" || command === "overview") {
|
|
1468
1537
|
// Already set up env flags above, fall through to REPL
|
|
1469
1538
|
}
|
package/package.json
CHANGED