@robinpath/cli 3.4.1 → 3.5.0
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.mjs +135 -160
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -18598,7 +18598,7 @@ function getNativeModules() {
|
|
|
18598
18598
|
import { join as join3, basename as basename2 } from "node:path";
|
|
18599
18599
|
import { homedir as homedir2, platform as platform2 } from "node:os";
|
|
18600
18600
|
import { existsSync as existsSync2 } from "node:fs";
|
|
18601
|
-
var CLI_VERSION = true ? "3.
|
|
18601
|
+
var CLI_VERSION = true ? "3.5.0" : "3.5.0";
|
|
18602
18602
|
var FLAG_QUIET = false;
|
|
18603
18603
|
var FLAG_VERBOSE = false;
|
|
18604
18604
|
var FLAG_AUTO_ACCEPT = false;
|
|
@@ -28495,6 +28495,64 @@ async function handleSaveRun(content, prompt, { save, run, outFile }) {
|
|
|
28495
28495
|
console.log(content);
|
|
28496
28496
|
}
|
|
28497
28497
|
}
|
|
28498
|
+
function arrowSelect(options) {
|
|
28499
|
+
return new Promise((resolve13) => {
|
|
28500
|
+
if (!process.stdin.isTTY) {
|
|
28501
|
+
resolve13(0);
|
|
28502
|
+
return;
|
|
28503
|
+
}
|
|
28504
|
+
let selected = 0;
|
|
28505
|
+
function render2() {
|
|
28506
|
+
process.stdout.write("\x1B[2K\r");
|
|
28507
|
+
for (let i = 0; i < options.length; i++) {
|
|
28508
|
+
if (i > 0) process.stdout.write("\n\x1B[2K");
|
|
28509
|
+
const marker = i === selected ? color.cyan(" \u276F ") : " ";
|
|
28510
|
+
const text = i === selected ? color.bold(options[i]) : options[i];
|
|
28511
|
+
process.stdout.write(`${marker}${text}`);
|
|
28512
|
+
}
|
|
28513
|
+
if (options.length > 1) process.stdout.write(`\x1B[${options.length - 1}A\r`);
|
|
28514
|
+
}
|
|
28515
|
+
render2();
|
|
28516
|
+
process.stdin.setRawMode(true);
|
|
28517
|
+
process.stdin.resume();
|
|
28518
|
+
const onKey = (buf) => {
|
|
28519
|
+
const key = buf.toString();
|
|
28520
|
+
if (key === "\x1B[A") {
|
|
28521
|
+
selected = Math.max(0, selected - 1);
|
|
28522
|
+
render2();
|
|
28523
|
+
return;
|
|
28524
|
+
}
|
|
28525
|
+
if (key === "\x1B[B") {
|
|
28526
|
+
selected = Math.min(options.length - 1, selected + 1);
|
|
28527
|
+
render2();
|
|
28528
|
+
return;
|
|
28529
|
+
}
|
|
28530
|
+
if (key === "\r" || key === "\n") {
|
|
28531
|
+
process.stdin.removeListener("data", onKey);
|
|
28532
|
+
try {
|
|
28533
|
+
process.stdin.setRawMode(false);
|
|
28534
|
+
} catch {
|
|
28535
|
+
}
|
|
28536
|
+
process.stdin.pause();
|
|
28537
|
+
process.stdout.write("\n".repeat(options.length));
|
|
28538
|
+
resolve13(selected);
|
|
28539
|
+
return;
|
|
28540
|
+
}
|
|
28541
|
+
if (key === "\x1B" || key === "") {
|
|
28542
|
+
process.stdin.removeListener("data", onKey);
|
|
28543
|
+
try {
|
|
28544
|
+
process.stdin.setRawMode(false);
|
|
28545
|
+
} catch {
|
|
28546
|
+
}
|
|
28547
|
+
process.stdin.pause();
|
|
28548
|
+
process.stdout.write("\n".repeat(options.length));
|
|
28549
|
+
resolve13(options.length - 1);
|
|
28550
|
+
return;
|
|
28551
|
+
}
|
|
28552
|
+
};
|
|
28553
|
+
process.stdin.on("data", onKey);
|
|
28554
|
+
});
|
|
28555
|
+
}
|
|
28498
28556
|
async function main() {
|
|
28499
28557
|
const args = process.argv.slice(2);
|
|
28500
28558
|
setFlags({
|
|
@@ -28721,171 +28779,88 @@ async function main() {
|
|
|
28721
28779
|
return;
|
|
28722
28780
|
}
|
|
28723
28781
|
checkForUpdates();
|
|
28724
|
-
|
|
28725
|
-
|
|
28726
|
-
|
|
28727
|
-
console.log(color.bold(" Welcome to RobinPath!"));
|
|
28728
|
-
console.log("");
|
|
28729
|
-
console.log(" To unlock AI assistant, deploy, snippets, and sync \u2014");
|
|
28730
|
-
console.log(" please login to your RobinPath account.");
|
|
28731
|
-
console.log("");
|
|
28732
|
-
console.log(" Without login you can still:");
|
|
28733
|
-
console.log(` ${color.dim("\u2022")} Run scripts: ${color.cyan("robinpath script.rp")}`);
|
|
28734
|
-
console.log(` ${color.dim("\u2022")} Format code: ${color.cyan("robinpath fmt file.rp")}`);
|
|
28735
|
-
console.log(` ${color.dim("\u2022")} Run tests: ${color.cyan("robinpath test")}`);
|
|
28736
|
-
console.log(` ${color.dim("\u2022")} Install modules: ${color.cyan("robinpath add @robinpath/csv")}`);
|
|
28737
|
-
console.log("");
|
|
28738
|
-
const choice = await new Promise((resolve13) => {
|
|
28739
|
-
if (!process.stdin.isTTY) {
|
|
28740
|
-
resolve13("skip");
|
|
28741
|
-
return;
|
|
28742
|
-
}
|
|
28743
|
-
let selected = 0;
|
|
28744
|
-
const options = ["Login", "Skip for now"];
|
|
28745
|
-
function render2() {
|
|
28746
|
-
process.stdout.write("\x1B[2K\r");
|
|
28747
|
-
for (let i = 0; i < options.length; i++) {
|
|
28748
|
-
if (i > 0) process.stdout.write("\n\x1B[2K");
|
|
28749
|
-
const marker = i === selected ? color.cyan(" \u276F ") : " ";
|
|
28750
|
-
const text = i === selected ? color.bold(options[i]) : options[i];
|
|
28751
|
-
process.stdout.write(`${marker}${text}`);
|
|
28752
|
-
}
|
|
28753
|
-
if (options.length > 1) process.stdout.write(`\x1B[${options.length - 1}A`);
|
|
28754
|
-
process.stdout.write("\r");
|
|
28755
|
-
}
|
|
28756
|
-
render2();
|
|
28757
|
-
process.stdin.setRawMode(true);
|
|
28758
|
-
process.stdin.resume();
|
|
28759
|
-
const onKey = (buf) => {
|
|
28760
|
-
const key = buf.toString();
|
|
28761
|
-
if (key === "\x1B[A") {
|
|
28762
|
-
selected = 0;
|
|
28763
|
-
render2();
|
|
28764
|
-
return;
|
|
28765
|
-
}
|
|
28766
|
-
if (key === "\x1B[B") {
|
|
28767
|
-
selected = 1;
|
|
28768
|
-
render2();
|
|
28769
|
-
return;
|
|
28770
|
-
}
|
|
28771
|
-
if (key === "\r" || key === "\n") {
|
|
28772
|
-
process.stdin.removeListener("data", onKey);
|
|
28773
|
-
try {
|
|
28774
|
-
process.stdin.setRawMode(false);
|
|
28775
|
-
} catch {
|
|
28776
|
-
}
|
|
28777
|
-
process.stdin.pause();
|
|
28778
|
-
process.stdout.write("\n".repeat(options.length));
|
|
28779
|
-
resolve13(selected === 0 ? "login" : "skip");
|
|
28780
|
-
return;
|
|
28781
|
-
}
|
|
28782
|
-
if (key === "\x1B" || key === "") {
|
|
28783
|
-
process.stdin.removeListener("data", onKey);
|
|
28784
|
-
try {
|
|
28785
|
-
process.stdin.setRawMode(false);
|
|
28786
|
-
} catch {
|
|
28787
|
-
}
|
|
28788
|
-
process.stdin.pause();
|
|
28789
|
-
process.stdout.write("\n".repeat(options.length));
|
|
28790
|
-
resolve13("skip");
|
|
28791
|
-
return;
|
|
28792
|
-
}
|
|
28793
|
-
};
|
|
28794
|
-
process.stdin.on("data", onKey);
|
|
28795
|
-
});
|
|
28796
|
-
if (choice === "login") {
|
|
28797
|
-
await handleLogin();
|
|
28798
|
-
} else {
|
|
28799
|
-
console.log(color.dim(" Skipped. Run ") + color.cyan("robinpath login") + color.dim(" anytime to unlock AI features."));
|
|
28782
|
+
if (process.stdin.isTTY) {
|
|
28783
|
+
const auth = readAuth();
|
|
28784
|
+
if (!auth) {
|
|
28800
28785
|
console.log("");
|
|
28801
|
-
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28806
|
-
|
|
28807
|
-
|
|
28808
|
-
|
|
28809
|
-
|
|
28810
|
-
|
|
28811
|
-
|
|
28812
|
-
console.log(color.bold(" Step 1:") + " Go to " + color.cyan("https://openrouter.ai/keys"));
|
|
28813
|
-
console.log(color.bold(" Step 2:") + ' Click "Create Key" and copy it');
|
|
28814
|
-
console.log(color.bold(" Step 3:") + " Run this command:");
|
|
28815
|
-
console.log("");
|
|
28816
|
-
console.log(" " + color.cyan(color.bold("robinpath ai config set-key ...")));
|
|
28817
|
-
console.log("");
|
|
28818
|
-
const ready = await new Promise((resolve13) => {
|
|
28819
|
-
if (!process.stdin.isTTY) {
|
|
28820
|
-
resolve13("later");
|
|
28786
|
+
console.log(color.bold(" Welcome to RobinPath!"));
|
|
28787
|
+
console.log("");
|
|
28788
|
+
console.log(" Login to unlock AI assistant, deploy, snippets, and sync.");
|
|
28789
|
+
console.log(color.dim(" Without login: run scripts, fmt, test, and install modules."));
|
|
28790
|
+
console.log("");
|
|
28791
|
+
const choice = await arrowSelect(["Login", "Skip for now"]);
|
|
28792
|
+
if (choice === 0) {
|
|
28793
|
+
await handleLogin();
|
|
28794
|
+
} else {
|
|
28795
|
+
console.log(color.dim(" Run ") + color.cyan("robinpath login") + color.dim(" anytime."));
|
|
28796
|
+
console.log("");
|
|
28821
28797
|
return;
|
|
28822
28798
|
}
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
process.stdout.write("\x1B[2K\r");
|
|
28827
|
-
for (let i = 0; i < options.length; i++) {
|
|
28828
|
-
if (i > 0) process.stdout.write("\n\x1B[2K");
|
|
28829
|
-
const marker = i === selected ? color.cyan(" \u276F ") : " ";
|
|
28830
|
-
const text = i === selected ? color.bold(options[i]) : options[i];
|
|
28831
|
-
process.stdout.write(`${marker}${text}`);
|
|
28832
|
-
}
|
|
28833
|
-
if (options.length > 1) process.stdout.write(`\x1B[${options.length - 1}A`);
|
|
28834
|
-
process.stdout.write("\r");
|
|
28835
|
-
}
|
|
28836
|
-
render2();
|
|
28837
|
-
process.stdin.setRawMode(true);
|
|
28838
|
-
process.stdin.resume();
|
|
28839
|
-
const onKey = (buf) => {
|
|
28840
|
-
const key = buf.toString();
|
|
28841
|
-
if (key === "\x1B[A") {
|
|
28842
|
-
selected = 0;
|
|
28843
|
-
render2();
|
|
28844
|
-
return;
|
|
28845
|
-
}
|
|
28846
|
-
if (key === "\x1B[B") {
|
|
28847
|
-
selected = 1;
|
|
28848
|
-
render2();
|
|
28849
|
-
return;
|
|
28850
|
-
}
|
|
28851
|
-
if (key === "\r" || key === "\n") {
|
|
28852
|
-
process.stdin.removeListener("data", onKey);
|
|
28853
|
-
try {
|
|
28854
|
-
process.stdin.setRawMode(false);
|
|
28855
|
-
} catch {
|
|
28856
|
-
}
|
|
28857
|
-
process.stdin.pause();
|
|
28858
|
-
process.stdout.write("\n".repeat(options.length));
|
|
28859
|
-
resolve13(selected === 0 ? "ready" : "later");
|
|
28860
|
-
return;
|
|
28861
|
-
}
|
|
28862
|
-
if (key === "\x1B" || key === "") {
|
|
28863
|
-
process.stdin.removeListener("data", onKey);
|
|
28864
|
-
try {
|
|
28865
|
-
process.stdin.setRawMode(false);
|
|
28866
|
-
} catch {
|
|
28867
|
-
}
|
|
28868
|
-
process.stdin.pause();
|
|
28869
|
-
process.stdout.write("\n".repeat(options.length));
|
|
28870
|
-
resolve13("later");
|
|
28871
|
-
return;
|
|
28872
|
-
}
|
|
28873
|
-
};
|
|
28874
|
-
process.stdin.on("data", onKey);
|
|
28875
|
-
});
|
|
28876
|
-
console.log("");
|
|
28877
|
-
if (ready === "ready") {
|
|
28878
|
-
console.log(" Copy and paste this command in your terminal:");
|
|
28799
|
+
}
|
|
28800
|
+
const config = readAiConfig();
|
|
28801
|
+
if (!config.apiKey) {
|
|
28879
28802
|
console.log("");
|
|
28880
|
-
console.log(
|
|
28803
|
+
console.log(color.green(" \u2713") + " Logged in!");
|
|
28881
28804
|
console.log("");
|
|
28882
|
-
console.log(
|
|
28883
|
-
|
|
28884
|
-
console.log(color.
|
|
28885
|
-
console.log("
|
|
28805
|
+
console.log(" Connect your OpenRouter API key to use the AI:");
|
|
28806
|
+
console.log("");
|
|
28807
|
+
console.log(color.bold(" 1.") + " Go to " + color.cyan("https://openrouter.ai/keys"));
|
|
28808
|
+
console.log(color.bold(" 2.") + " Create a key and copy it");
|
|
28809
|
+
console.log(color.bold(" 3.") + " Paste it below:");
|
|
28810
|
+
console.log("");
|
|
28811
|
+
const apiKey = await new Promise((resolve13) => {
|
|
28812
|
+
process.stdout.write(color.cyan(" API key: "));
|
|
28813
|
+
process.stdin.setRawMode(true);
|
|
28814
|
+
process.stdin.resume();
|
|
28815
|
+
let input = "";
|
|
28816
|
+
const onData = (ch) => {
|
|
28817
|
+
const c = ch.toString();
|
|
28818
|
+
if (c === "\r" || c === "\n") {
|
|
28819
|
+
process.stdin.removeListener("data", onData);
|
|
28820
|
+
try {
|
|
28821
|
+
process.stdin.setRawMode(false);
|
|
28822
|
+
} catch {
|
|
28823
|
+
}
|
|
28824
|
+
process.stdin.pause();
|
|
28825
|
+
process.stdout.write("\n");
|
|
28826
|
+
resolve13(input);
|
|
28827
|
+
} else if (c === "" || c === "\x1B") {
|
|
28828
|
+
process.stdin.removeListener("data", onData);
|
|
28829
|
+
try {
|
|
28830
|
+
process.stdin.setRawMode(false);
|
|
28831
|
+
} catch {
|
|
28832
|
+
}
|
|
28833
|
+
process.stdin.pause();
|
|
28834
|
+
process.stdout.write("\n");
|
|
28835
|
+
resolve13("");
|
|
28836
|
+
} else if (c === "\x7F" || c === "\b") {
|
|
28837
|
+
if (input.length > 0) {
|
|
28838
|
+
input = input.slice(0, -1);
|
|
28839
|
+
process.stdout.write("\b \b");
|
|
28840
|
+
}
|
|
28841
|
+
} else if (c.charCodeAt(0) >= 32) {
|
|
28842
|
+
input += c;
|
|
28843
|
+
process.stdout.write("*");
|
|
28844
|
+
}
|
|
28845
|
+
};
|
|
28846
|
+
process.stdin.on("data", onData);
|
|
28847
|
+
});
|
|
28848
|
+
if (apiKey && apiKey.trim()) {
|
|
28849
|
+
const k2 = apiKey.trim();
|
|
28850
|
+
const newConfig = { apiKey: k2, model: "anthropic/claude-sonnet-4.6" };
|
|
28851
|
+
if (k2.startsWith("sk-or-")) newConfig.provider = "openrouter";
|
|
28852
|
+
else if (k2.startsWith("sk-ant-")) newConfig.provider = "anthropic";
|
|
28853
|
+
else if (k2.startsWith("sk-")) newConfig.provider = "openai";
|
|
28854
|
+
else newConfig.provider = "openrouter";
|
|
28855
|
+
writeAiConfig(newConfig);
|
|
28856
|
+
console.log(color.green(" \u2713") + " API key saved! Provider: " + color.cyan(newConfig.provider));
|
|
28857
|
+
console.log("");
|
|
28858
|
+
} else {
|
|
28859
|
+
console.log(color.dim(" Skipped. Set it later: ") + color.cyan("robinpath ai config set-key ..."));
|
|
28860
|
+
console.log("");
|
|
28861
|
+
return;
|
|
28862
|
+
}
|
|
28886
28863
|
}
|
|
28887
|
-
console.log("");
|
|
28888
|
-
return;
|
|
28889
28864
|
}
|
|
28890
28865
|
await startInkOrFallback(null, null, { autoAccept: FLAG_AUTO_ACCEPT, devMode: FLAG_DEV_MODE });
|
|
28891
28866
|
}
|