claudemesh-cli 1.0.0-alpha.7 → 1.0.0-alpha.9
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/dist/entrypoints/cli.js +110 -23
- package/dist/entrypoints/cli.js.map +3 -3
- package/package.json +2 -2
package/dist/entrypoints/cli.js
CHANGED
|
@@ -1407,17 +1407,103 @@ var exports_login = {};
|
|
|
1407
1407
|
__export(exports_login, {
|
|
1408
1408
|
login: () => login
|
|
1409
1409
|
});
|
|
1410
|
+
import { createInterface } from "node:readline";
|
|
1411
|
+
function prompt(question) {
|
|
1412
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1413
|
+
return new Promise((resolve) => {
|
|
1414
|
+
rl.question(question, (answer) => {
|
|
1415
|
+
rl.close();
|
|
1416
|
+
resolve(answer.trim());
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
async function loginWithToken() {
|
|
1421
|
+
console.log(`
|
|
1422
|
+
Paste a token from ${dim(URLS.API_BASE + "/token")}`);
|
|
1423
|
+
console.log(` ${dim("Generate one in your browser, then paste it here.")}
|
|
1424
|
+
`);
|
|
1425
|
+
const token = await prompt(" Token: ");
|
|
1426
|
+
if (!token) {
|
|
1427
|
+
console.error(` ${icons.cross} No token provided.`);
|
|
1428
|
+
return EXIT.AUTH_FAILED;
|
|
1429
|
+
}
|
|
1430
|
+
let user = { id: "", display_name: "", email: "" };
|
|
1431
|
+
try {
|
|
1432
|
+
const parts = token.split(".");
|
|
1433
|
+
if (parts[1]) {
|
|
1434
|
+
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString());
|
|
1435
|
+
if (payload.exp && payload.exp < Date.now() / 1000) {
|
|
1436
|
+
console.error(` ${icons.cross} Token expired. Generate a new one.`);
|
|
1437
|
+
return EXIT.AUTH_FAILED;
|
|
1438
|
+
}
|
|
1439
|
+
user = {
|
|
1440
|
+
id: payload.sub ?? "",
|
|
1441
|
+
display_name: payload.name ?? payload.email ?? "",
|
|
1442
|
+
email: payload.email ?? ""
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
} catch {
|
|
1446
|
+
console.error(` ${icons.cross} Invalid token format.`);
|
|
1447
|
+
return EXIT.AUTH_FAILED;
|
|
1448
|
+
}
|
|
1449
|
+
storeToken({ session_token: token, user, token_source: "manual" });
|
|
1450
|
+
console.log(` ${green(icons.check)} Signed in as ${user.display_name || user.email || "user"}.`);
|
|
1451
|
+
return EXIT.SUCCESS;
|
|
1452
|
+
}
|
|
1453
|
+
async function syncMeshes(token) {
|
|
1454
|
+
try {
|
|
1455
|
+
const meshes = await exports_my.getMeshes(token);
|
|
1456
|
+
if (meshes.length > 0) {
|
|
1457
|
+
const names = meshes.map((m) => m.slug).join(", ");
|
|
1458
|
+
console.log(` ${green(icons.check)} Synced ${meshes.length} mesh${meshes.length === 1 ? "" : "es"}: ${names}`);
|
|
1459
|
+
}
|
|
1460
|
+
} catch {}
|
|
1461
|
+
}
|
|
1410
1462
|
async function login() {
|
|
1463
|
+
const existing = getStoredToken();
|
|
1464
|
+
if (existing) {
|
|
1465
|
+
const name = existing.user.display_name || existing.user.email || "unknown";
|
|
1466
|
+
console.log(`
|
|
1467
|
+
Already signed in as ${bold(name)}.`);
|
|
1468
|
+
console.log("");
|
|
1469
|
+
console.log(` ${bold("1)")} Continue as ${name}`);
|
|
1470
|
+
console.log(` ${bold("2)")} Sign in via browser`);
|
|
1471
|
+
console.log(` ${bold("3)")} Paste a token from ${dim("claudemesh.com/token")}`);
|
|
1472
|
+
console.log(` ${bold("4)")} Sign out`);
|
|
1473
|
+
console.log("");
|
|
1474
|
+
const choice = await prompt(" Choice [1]: ") || "1";
|
|
1475
|
+
if (choice === "1") {
|
|
1476
|
+
console.log(`
|
|
1477
|
+
${green(icons.check)} Continuing as ${name}.`);
|
|
1478
|
+
return EXIT.SUCCESS;
|
|
1479
|
+
}
|
|
1480
|
+
if (choice === "4") {
|
|
1481
|
+
clearToken();
|
|
1482
|
+
console.log(` ${green(icons.check)} Signed out.`);
|
|
1483
|
+
return EXIT.SUCCESS;
|
|
1484
|
+
}
|
|
1485
|
+
if (choice === "3") {
|
|
1486
|
+
clearToken();
|
|
1487
|
+
return loginWithToken();
|
|
1488
|
+
}
|
|
1489
|
+
clearToken();
|
|
1490
|
+
console.log(` ${dim("Signing in…")}`);
|
|
1491
|
+
} else {
|
|
1492
|
+
console.log(`
|
|
1493
|
+
${bold("claudemesh")} — sign in to connect your terminal`);
|
|
1494
|
+
console.log("");
|
|
1495
|
+
console.log(` ${bold("1)")} Sign in via browser ${dim("(opens automatically)")}`);
|
|
1496
|
+
console.log(` ${bold("2)")} Paste a token from ${dim("claudemesh.com/token")}`);
|
|
1497
|
+
console.log("");
|
|
1498
|
+
const choice = await prompt(" Choice [1]: ") || "1";
|
|
1499
|
+
if (choice === "2") {
|
|
1500
|
+
return loginWithToken();
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1411
1503
|
try {
|
|
1412
1504
|
const result = await loginWithDeviceCode();
|
|
1413
1505
|
console.log(` ${green(icons.check)} Signed in as ${result.user.display_name}.`);
|
|
1414
|
-
|
|
1415
|
-
const meshes = await exports_my.getMeshes(result.session_token);
|
|
1416
|
-
if (meshes.length > 0) {
|
|
1417
|
-
const names = meshes.map((m) => m.slug).join(", ");
|
|
1418
|
-
console.log(` ${green(icons.check)} Synced ${meshes.length} mesh${meshes.length === 1 ? "" : "es"}: ${names}`);
|
|
1419
|
-
}
|
|
1420
|
-
} catch {}
|
|
1506
|
+
await syncMeshes(result.session_token);
|
|
1421
1507
|
return EXIT.SUCCESS;
|
|
1422
1508
|
} catch (err) {
|
|
1423
1509
|
console.error(` ${icons.cross} Login failed: ${err instanceof Error ? err.message : err}`);
|
|
@@ -1429,6 +1515,7 @@ var init_login = __esm(() => {
|
|
|
1429
1515
|
init_facade2();
|
|
1430
1516
|
init_styles();
|
|
1431
1517
|
init_exit_codes();
|
|
1518
|
+
init_urls();
|
|
1432
1519
|
});
|
|
1433
1520
|
|
|
1434
1521
|
// src/commands/register.ts
|
|
@@ -1449,13 +1536,13 @@ __export(exports_welcome, {
|
|
|
1449
1536
|
runWelcome: () => runWelcome,
|
|
1450
1537
|
_stub: () => runWelcome
|
|
1451
1538
|
});
|
|
1452
|
-
import { createInterface } from "node:readline";
|
|
1539
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
1453
1540
|
async function runWelcome() {
|
|
1454
1541
|
const config = readConfig();
|
|
1455
1542
|
if (config.meshes.length > 0)
|
|
1456
1543
|
return EXIT.SUCCESS;
|
|
1457
1544
|
renderWelcome();
|
|
1458
|
-
const rl =
|
|
1545
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
1459
1546
|
return new Promise((resolve) => {
|
|
1460
1547
|
rl.question(" Choice [1]: ", async (answer) => {
|
|
1461
1548
|
rl.close();
|
|
@@ -3517,7 +3604,7 @@ var init_facade9 = __esm(() => {
|
|
|
3517
3604
|
});
|
|
3518
3605
|
|
|
3519
3606
|
// src/ui/screen.ts
|
|
3520
|
-
import { createInterface as
|
|
3607
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
3521
3608
|
function termSize() {
|
|
3522
3609
|
return { cols: process.stdout.columns || 80, rows: process.stdout.rows || 24 };
|
|
3523
3610
|
}
|
|
@@ -3545,7 +3632,7 @@ function enterFullScreen() {
|
|
|
3545
3632
|
function exitFullScreen() {
|
|
3546
3633
|
process.stdout.write(SHOW_CURSOR + CLEAR_SCREEN);
|
|
3547
3634
|
}
|
|
3548
|
-
async function menuSelect(itemsOrOpts,
|
|
3635
|
+
async function menuSelect(itemsOrOpts, prompt2 = "Choice") {
|
|
3549
3636
|
const items = Array.isArray(itemsOrOpts) ? itemsOrOpts : itemsOrOpts.items;
|
|
3550
3637
|
const title = !Array.isArray(itemsOrOpts) ? itemsOrOpts.title : undefined;
|
|
3551
3638
|
if (title)
|
|
@@ -3553,9 +3640,9 @@ async function menuSelect(itemsOrOpts, prompt = "Choice") {
|
|
|
3553
3640
|
${title}`);
|
|
3554
3641
|
items.forEach((item, i) => console.log(` ${bold(String(i + 1) + ")")} ${item}`));
|
|
3555
3642
|
console.log("");
|
|
3556
|
-
const rl =
|
|
3643
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
3557
3644
|
return new Promise((resolve) => {
|
|
3558
|
-
rl.question(` ${
|
|
3645
|
+
rl.question(` ${prompt2} [1]: `, (answer) => {
|
|
3559
3646
|
rl.close();
|
|
3560
3647
|
const idx = parseInt(answer || "1", 10) - 1;
|
|
3561
3648
|
resolve(idx >= 0 && idx < items.length ? idx : 0);
|
|
@@ -3565,7 +3652,7 @@ async function menuSelect(itemsOrOpts, prompt = "Choice") {
|
|
|
3565
3652
|
async function textInput(promptOrOpts, defaultVal = "") {
|
|
3566
3653
|
const label = typeof promptOrOpts === "string" ? promptOrOpts : promptOrOpts.label;
|
|
3567
3654
|
const placeholder = typeof promptOrOpts === "object" ? promptOrOpts.placeholder : undefined;
|
|
3568
|
-
const rl =
|
|
3655
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
3569
3656
|
return new Promise((resolve) => {
|
|
3570
3657
|
const hint = placeholder ? ` (${placeholder})` : defaultVal ? ` [${defaultVal}]` : "";
|
|
3571
3658
|
rl.question(` ${label}${hint}: `, (answer) => {
|
|
@@ -3577,7 +3664,7 @@ async function textInput(promptOrOpts, defaultVal = "") {
|
|
|
3577
3664
|
async function confirmPrompt(promptOrOpts, defaultYes = true) {
|
|
3578
3665
|
const message = typeof promptOrOpts === "string" ? promptOrOpts : promptOrOpts.message;
|
|
3579
3666
|
const defYes = typeof promptOrOpts === "object" && promptOrOpts.defaultYes !== undefined ? promptOrOpts.defaultYes : defaultYes;
|
|
3580
|
-
const rl =
|
|
3667
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
3581
3668
|
const hint = defYes ? "[Y/n]" : "[y/N]";
|
|
3582
3669
|
return new Promise((resolve) => {
|
|
3583
3670
|
rl.question(` ${message} ${hint}: `, (answer) => {
|
|
@@ -3692,7 +3779,7 @@ import { randomUUID } from "node:crypto";
|
|
|
3692
3779
|
import { mkdtempSync, writeFileSync as writeFileSync4, rmSync, readdirSync, statSync, existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
3693
3780
|
import { tmpdir, hostname as hostname3, homedir as homedir3 } from "node:os";
|
|
3694
3781
|
import { join as join3 } from "node:path";
|
|
3695
|
-
import { createInterface as
|
|
3782
|
+
import { createInterface as createInterface4 } from "node:readline";
|
|
3696
3783
|
async function pickMesh(meshes) {
|
|
3697
3784
|
if (meshes.length === 1)
|
|
3698
3785
|
return meshes[0];
|
|
@@ -3702,7 +3789,7 @@ async function pickMesh(meshes) {
|
|
|
3702
3789
|
console.log(` ${i + 1}) ${m.slug}`);
|
|
3703
3790
|
});
|
|
3704
3791
|
console.log("");
|
|
3705
|
-
const rl =
|
|
3792
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
3706
3793
|
return new Promise((resolve) => {
|
|
3707
3794
|
rl.question(" Choice [1]: ", (answer) => {
|
|
3708
3795
|
rl.close();
|
|
@@ -3944,7 +4031,7 @@ async function runLaunch(flags, rawArgs) {
|
|
|
3944
4031
|
console.log(` ${dim2(`Or join with invite: claudemesh launch --join <url>`)}
|
|
3945
4032
|
`);
|
|
3946
4033
|
const manualPromise = new Promise((resolve) => {
|
|
3947
|
-
const rl =
|
|
4034
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
3948
4035
|
rl.question(" Paste sync token (or wait for browser): ", (answer) => {
|
|
3949
4036
|
rl.close();
|
|
3950
4037
|
if (answer.trim())
|
|
@@ -7662,7 +7749,7 @@ var init_rename2 = __esm(() => {
|
|
|
7662
7749
|
|
|
7663
7750
|
// src/commands/connect.ts
|
|
7664
7751
|
import { hostname as hostname4 } from "node:os";
|
|
7665
|
-
import { createInterface as
|
|
7752
|
+
import { createInterface as createInterface5 } from "node:readline";
|
|
7666
7753
|
async function pickMesh2(meshes) {
|
|
7667
7754
|
console.log(`
|
|
7668
7755
|
Select mesh:`);
|
|
@@ -7670,7 +7757,7 @@ async function pickMesh2(meshes) {
|
|
|
7670
7757
|
console.log(` ${i + 1}) ${m.slug}`);
|
|
7671
7758
|
});
|
|
7672
7759
|
console.log("");
|
|
7673
|
-
const rl =
|
|
7760
|
+
const rl = createInterface5({ input: process.stdin, output: process.stdout });
|
|
7674
7761
|
return new Promise((resolve) => {
|
|
7675
7762
|
rl.question(" Choice [1]: ", (answer) => {
|
|
7676
7763
|
rl.close();
|
|
@@ -8965,7 +9052,7 @@ var exports_sync = {};
|
|
|
8965
9052
|
__export(exports_sync, {
|
|
8966
9053
|
runSync: () => runSync
|
|
8967
9054
|
});
|
|
8968
|
-
import { createInterface as
|
|
9055
|
+
import { createInterface as createInterface6 } from "node:readline";
|
|
8969
9056
|
import { hostname as hostname5 } from "node:os";
|
|
8970
9057
|
async function runSync(args) {
|
|
8971
9058
|
const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
|
|
@@ -8979,7 +9066,7 @@ async function runSync(args) {
|
|
|
8979
9066
|
console.log(dim2(`Visit: ${url}`));
|
|
8980
9067
|
await openBrowser(url);
|
|
8981
9068
|
const manualPromise = new Promise((resolve2) => {
|
|
8982
|
-
const rl =
|
|
9069
|
+
const rl = createInterface6({ input: process.stdin, output: process.stdout });
|
|
8983
9070
|
rl.question("Paste sync token (or wait for browser): ", (answer) => {
|
|
8984
9071
|
rl.close();
|
|
8985
9072
|
if (answer.trim())
|
|
@@ -10614,4 +10701,4 @@ main().catch((err) => {
|
|
|
10614
10701
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
10615
10702
|
});
|
|
10616
10703
|
|
|
10617
|
-
//# debugId=
|
|
10704
|
+
//# debugId=B1D91566048A7A1864756E2164756E21
|