@piut/cli 3.5.0 → 3.5.1
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/cli.js +40 -33
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -614,18 +614,35 @@ var Spinner = class {
|
|
|
614
614
|
startTime = Date.now();
|
|
615
615
|
message = "";
|
|
616
616
|
sections = [];
|
|
617
|
+
currentSection = null;
|
|
617
618
|
start(message) {
|
|
618
619
|
this.message = message;
|
|
619
620
|
this.startTime = Date.now();
|
|
620
621
|
this.sections = [];
|
|
622
|
+
this.currentSection = null;
|
|
621
623
|
this.render();
|
|
622
624
|
this.interval = setInterval(() => this.render(), 80);
|
|
623
625
|
}
|
|
624
626
|
addSection(name) {
|
|
625
|
-
this.
|
|
626
|
-
|
|
627
|
-
|
|
627
|
+
if (this.currentSection) {
|
|
628
|
+
this.clearLine();
|
|
629
|
+
const elapsed = this.elapsed();
|
|
630
|
+
const label = this.capitalize(this.currentSection);
|
|
631
|
+
console.log(` ${success("\u2713")} ${label.padEnd(14)} ${dim(elapsed)}`);
|
|
632
|
+
}
|
|
633
|
+
this.currentSection = name;
|
|
628
634
|
this.sections.push(name);
|
|
635
|
+
this.message = `Building ${this.capitalize(name)}...`;
|
|
636
|
+
}
|
|
637
|
+
completeAll() {
|
|
638
|
+
if (this.currentSection) {
|
|
639
|
+
this.clearLine();
|
|
640
|
+
const elapsed = this.elapsed();
|
|
641
|
+
const label = this.capitalize(this.currentSection);
|
|
642
|
+
console.log(` ${success("\u2713")} ${label.padEnd(14)} ${dim(elapsed)}`);
|
|
643
|
+
this.currentSection = null;
|
|
644
|
+
}
|
|
645
|
+
this.message = "Finalizing...";
|
|
629
646
|
}
|
|
630
647
|
updateMessage(message) {
|
|
631
648
|
this.message = message;
|
|
@@ -655,6 +672,9 @@ var Spinner = class {
|
|
|
655
672
|
clearLine() {
|
|
656
673
|
process.stdout.write("\r\x1B[K");
|
|
657
674
|
}
|
|
675
|
+
capitalize(s) {
|
|
676
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
677
|
+
}
|
|
658
678
|
};
|
|
659
679
|
|
|
660
680
|
// src/types.ts
|
|
@@ -1441,30 +1461,6 @@ import os6 from "os";
|
|
|
1441
1461
|
// src/lib/auth.ts
|
|
1442
1462
|
import { password as password2 } from "@inquirer/prompts";
|
|
1443
1463
|
import chalk4 from "chalk";
|
|
1444
|
-
async function resolveApiKey(keyOption) {
|
|
1445
|
-
const config = readStore();
|
|
1446
|
-
let apiKey = keyOption || config.apiKey;
|
|
1447
|
-
if (!apiKey) {
|
|
1448
|
-
apiKey = await password2({
|
|
1449
|
-
message: "Enter your p\u0131ut API key:",
|
|
1450
|
-
mask: "*",
|
|
1451
|
-
validate: (v) => v.startsWith("pb_") || "Key must start with pb_"
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
console.log(dim(" Validating key..."));
|
|
1455
|
-
let result;
|
|
1456
|
-
try {
|
|
1457
|
-
result = await validateKey(apiKey);
|
|
1458
|
-
} catch (err) {
|
|
1459
|
-
console.log(chalk4.red(` \u2717 ${err.message}`));
|
|
1460
|
-
console.log(dim(" Get a key at https://piut.com/dashboard/keys"));
|
|
1461
|
-
throw new CliError(err.message);
|
|
1462
|
-
}
|
|
1463
|
-
const label = result.slug ? `${result.displayName} (${result.slug})` : result.displayName;
|
|
1464
|
-
console.log(success(` \u2713 Connected as ${label}`));
|
|
1465
|
-
updateStore({ apiKey });
|
|
1466
|
-
return apiKey;
|
|
1467
|
-
}
|
|
1468
1464
|
async function resolveApiKeyWithResult(keyOption) {
|
|
1469
1465
|
const config = readStore();
|
|
1470
1466
|
let apiKey = keyOption || config.apiKey;
|
|
@@ -1493,7 +1489,7 @@ async function resolveApiKeyWithResult(keyOption) {
|
|
|
1493
1489
|
// src/commands/build.ts
|
|
1494
1490
|
async function buildCommand(options) {
|
|
1495
1491
|
banner();
|
|
1496
|
-
const apiKey = await
|
|
1492
|
+
const { apiKey, serverUrl } = await resolveApiKeyWithResult(options.key);
|
|
1497
1493
|
let scanFolders;
|
|
1498
1494
|
if (options.folders) {
|
|
1499
1495
|
scanFolders = options.folders.split(",").map((f) => expandPath(f.trim()));
|
|
@@ -1587,6 +1583,7 @@ async function buildCommand(options) {
|
|
|
1587
1583
|
spinner.addSection(String(event.data.name));
|
|
1588
1584
|
break;
|
|
1589
1585
|
case "complete":
|
|
1586
|
+
spinner.completeAll();
|
|
1590
1587
|
sections = event.data.sections || {};
|
|
1591
1588
|
break;
|
|
1592
1589
|
case "error":
|
|
@@ -1629,15 +1626,25 @@ async function buildCommand(options) {
|
|
|
1629
1626
|
}
|
|
1630
1627
|
console.log(dim(` Review and edit at ${brand("piut.com/dashboard")}`));
|
|
1631
1628
|
console.log();
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
})
|
|
1629
|
+
let wantPublish;
|
|
1630
|
+
if (options.publish === false) {
|
|
1631
|
+
wantPublish = false;
|
|
1632
|
+
} else if (options.yes) {
|
|
1633
|
+
wantPublish = true;
|
|
1634
|
+
} else {
|
|
1635
|
+
console.log(dim(" You can always make changes later."));
|
|
1636
|
+
wantPublish = await confirm3({
|
|
1637
|
+
message: "Publish your brain now?",
|
|
1638
|
+
default: true
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1636
1641
|
if (wantPublish) {
|
|
1637
1642
|
try {
|
|
1638
1643
|
await publishServer(apiKey);
|
|
1639
1644
|
console.log();
|
|
1640
1645
|
console.log(success(" \u2713 Brain published. MCP server is live."));
|
|
1646
|
+
console.log(` ${brand(serverUrl)}`);
|
|
1647
|
+
console.log(dim(" (accessible only with secure authentication)"));
|
|
1641
1648
|
console.log();
|
|
1642
1649
|
} catch (err) {
|
|
1643
1650
|
console.log();
|
|
@@ -2808,7 +2815,7 @@ async function handleViewBrain(apiKey) {
|
|
|
2808
2815
|
}
|
|
2809
2816
|
|
|
2810
2817
|
// src/cli.ts
|
|
2811
|
-
var VERSION = "3.5.
|
|
2818
|
+
var VERSION = "3.5.1";
|
|
2812
2819
|
function withExit(fn) {
|
|
2813
2820
|
return async (...args2) => {
|
|
2814
2821
|
try {
|