rlm-cli 0.2.9 → 0.2.10
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/env.d.ts +4 -4
- package/dist/env.js +16 -11
- package/dist/interactive.js +8 -6
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Load
|
|
2
|
+
* Load env vars into process.env.
|
|
3
3
|
* Must be imported BEFORE any module that reads env vars (e.g. pi-ai).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
5
|
+
* Load order (later wins):
|
|
6
|
+
* 1. ~/.rlm/credentials — persistent keys saved by first-run setup
|
|
7
|
+
* 2. .env in package root — local overrides
|
|
8
8
|
*/
|
|
9
9
|
export {};
|
package/dist/env.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Load
|
|
2
|
+
* Load env vars into process.env.
|
|
3
3
|
* Must be imported BEFORE any module that reads env vars (e.g. pi-ai).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
5
|
+
* Load order (later wins):
|
|
6
|
+
* 1. ~/.rlm/credentials — persistent keys saved by first-run setup
|
|
7
|
+
* 2. .env in package root — local overrides
|
|
8
8
|
*/
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "node:path";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const content = fs.readFileSync(
|
|
11
|
+
import * as os from "node:os";
|
|
12
|
+
function loadEnvFile(filePath) {
|
|
13
|
+
if (!fs.existsSync(filePath))
|
|
14
|
+
return;
|
|
15
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
16
16
|
for (const line of content.split("\n")) {
|
|
17
17
|
const trimmed = line.trim();
|
|
18
18
|
if (!trimmed || trimmed.startsWith("#"))
|
|
@@ -22,13 +22,18 @@ if (fs.existsSync(envPath)) {
|
|
|
22
22
|
continue;
|
|
23
23
|
const key = trimmed.slice(0, eqIndex).trim();
|
|
24
24
|
const value = trimmed.slice(eqIndex + 1).trim();
|
|
25
|
-
if (key) {
|
|
25
|
+
if (key && !process.env[key]) {
|
|
26
26
|
process.env[key] = value;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
// 1. Load persistent credentials (~/.rlm/credentials)
|
|
31
|
+
loadEnvFile(path.join(os.homedir(), ".rlm", "credentials"));
|
|
32
|
+
// 2. Load .env from package root (local overrides)
|
|
33
|
+
const __dir = path.dirname(new URL(import.meta.url).pathname);
|
|
34
|
+
loadEnvFile(path.resolve(__dir, "..", ".env"));
|
|
30
35
|
// Default model
|
|
31
36
|
if (!process.env.RLM_MODEL) {
|
|
32
|
-
process.env.RLM_MODEL = "claude-sonnet-4-
|
|
37
|
+
process.env.RLM_MODEL = "claude-sonnet-4-6";
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=env.js.map
|
package/dist/interactive.js
CHANGED
|
@@ -206,15 +206,17 @@ async function promptForProviderKey(rlInstance, providerInfo) {
|
|
|
206
206
|
if (!key)
|
|
207
207
|
return false; // empty
|
|
208
208
|
process.env[providerInfo.env] = key;
|
|
209
|
-
// Save to
|
|
210
|
-
const
|
|
211
|
-
const
|
|
209
|
+
// Save to ~/.rlm/credentials (persistent across sessions)
|
|
210
|
+
const credDir = path.join(process.env.HOME || "~", ".rlm");
|
|
211
|
+
const credPath = path.join(credDir, "credentials");
|
|
212
212
|
try {
|
|
213
|
-
fs.
|
|
214
|
-
|
|
213
|
+
if (!fs.existsSync(credDir))
|
|
214
|
+
fs.mkdirSync(credDir, { recursive: true });
|
|
215
|
+
fs.appendFileSync(credPath, `${providerInfo.env}=${key}\n`);
|
|
216
|
+
console.log(`\n ${c.green}✓${c.reset} ${providerInfo.name} key saved to ${c.dim}~/.rlm/credentials${c.reset}`);
|
|
215
217
|
}
|
|
216
218
|
catch {
|
|
217
|
-
console.log(`\n ${c.yellow}!${c.reset} Could not
|
|
219
|
+
console.log(`\n ${c.yellow}!${c.reset} Could not save key. Add manually:`);
|
|
218
220
|
console.log(` ${c.yellow}export ${providerInfo.env}=${key}${c.reset}`);
|
|
219
221
|
}
|
|
220
222
|
return true;
|