rlm-cli 0.2.2 → 0.2.4
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/interactive.js +36 -6
- package/package.json +1 -1
package/dist/interactive.js
CHANGED
|
@@ -615,11 +615,40 @@ async function interactive() {
|
|
|
615
615
|
if (!hasApiKey) {
|
|
616
616
|
printBanner();
|
|
617
617
|
console.log(` ${c.red}No API key found.${c.reset}\n`);
|
|
618
|
-
console.log(`
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
618
|
+
console.log(` ${c.bold}Paste your API key to get started:${c.reset}\n`);
|
|
619
|
+
const setupRl = readline.createInterface({ input: stdin, output: stdout, terminal: true });
|
|
620
|
+
const key = await new Promise((resolve) => {
|
|
621
|
+
setupRl.question(` ${c.cyan}API key:${c.reset} `, (answer) => {
|
|
622
|
+
setupRl.close();
|
|
623
|
+
resolve(answer.trim());
|
|
624
|
+
});
|
|
625
|
+
});
|
|
626
|
+
if (!key) {
|
|
627
|
+
console.log(`\n ${c.dim}No key provided. Exiting.${c.reset}\n`);
|
|
628
|
+
process.exit(0);
|
|
629
|
+
}
|
|
630
|
+
// Detect provider from key format
|
|
631
|
+
let envVar;
|
|
632
|
+
if (key.startsWith("sk-ant-")) {
|
|
633
|
+
envVar = "ANTHROPIC_API_KEY";
|
|
634
|
+
process.env.ANTHROPIC_API_KEY = key;
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
envVar = "OPENAI_API_KEY";
|
|
638
|
+
process.env.OPENAI_API_KEY = key;
|
|
639
|
+
}
|
|
640
|
+
// Save to shell profile
|
|
641
|
+
const shellRc = process.env.SHELL?.includes("zsh") ? "~/.zshrc" : "~/.bashrc";
|
|
642
|
+
const rcPath = shellRc.replace("~", process.env.HOME || "~");
|
|
643
|
+
try {
|
|
644
|
+
fs.appendFileSync(rcPath, `\nexport ${envVar}=${key}\n`);
|
|
645
|
+
console.log(`\n ${c.green}✓${c.reset} Key saved to ${c.dim}${shellRc}${c.reset}`);
|
|
646
|
+
}
|
|
647
|
+
catch {
|
|
648
|
+
console.log(`\n ${c.yellow}!${c.reset} Could not write to ${shellRc}. Add manually:`);
|
|
649
|
+
console.log(` ${c.yellow}export ${envVar}=${key}${c.reset}`);
|
|
650
|
+
}
|
|
651
|
+
console.log();
|
|
623
652
|
}
|
|
624
653
|
// Resolve model
|
|
625
654
|
currentModel = resolveModel(currentModelId);
|
|
@@ -742,7 +771,8 @@ async function interactive() {
|
|
|
742
771
|
: `${c.dim}${m.id}${c.reset}`;
|
|
743
772
|
console.log(` ${c.dim}${num}${c.reset} ${dot} ${label}`);
|
|
744
773
|
}
|
|
745
|
-
console.log(`\n ${c.dim}
|
|
774
|
+
console.log(`\n ${c.dim}${available.length} models · scroll up to see full list.${c.reset}`);
|
|
775
|
+
console.log(` ${c.dim}Type${c.reset} ${c.cyan}/model <number>${c.reset} ${c.dim}or${c.reset} ${c.cyan}/model <id>${c.reset} ${c.dim}to switch.${c.reset}`);
|
|
746
776
|
}
|
|
747
777
|
break;
|
|
748
778
|
}
|