rlm-cli 0.2.12 → 0.2.13
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/bin/rlm.mjs +5 -5
- package/dist/config.js +2 -1
- package/dist/env.js +2 -1
- package/dist/repl.js +6 -3
- package/package.json +1 -1
package/bin/rlm.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* then falls back to tsx for development.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
|
|
@@ -15,8 +15,8 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
15
15
|
const distEntry = join(__dirname, "..", "dist", "main.js");
|
|
16
16
|
|
|
17
17
|
if (existsSync(distEntry)) {
|
|
18
|
-
// Production: use compiled JS
|
|
19
|
-
await import(distEntry);
|
|
18
|
+
// Production: use compiled JS (pathToFileURL needed for Windows)
|
|
19
|
+
await import(pathToFileURL(distEntry).href);
|
|
20
20
|
} else {
|
|
21
21
|
// Development: use tsx to run TypeScript directly
|
|
22
22
|
const srcEntry = join(__dirname, "..", "src", "main.ts");
|
|
@@ -26,9 +26,9 @@ if (existsSync(distEntry)) {
|
|
|
26
26
|
try {
|
|
27
27
|
const tsxPath = join(__dirname, "..", "node_modules", "tsx", "dist", "esm", "index.mjs");
|
|
28
28
|
if (existsSync(tsxPath)) {
|
|
29
|
-
register(tsxPath);
|
|
29
|
+
register(pathToFileURL(tsxPath).href);
|
|
30
30
|
}
|
|
31
|
-
await import(srcEntry);
|
|
31
|
+
await import(pathToFileURL(srcEntry).href);
|
|
32
32
|
} catch {
|
|
33
33
|
// Fallback: spawn tsx as a child process
|
|
34
34
|
const { spawn } = await import("node:child_process");
|
package/dist/config.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
8
9
|
const DEFAULTS = {
|
|
9
10
|
max_iterations: 20,
|
|
10
11
|
max_depth: 3,
|
|
@@ -48,7 +49,7 @@ export function loadConfig() {
|
|
|
48
49
|
// Search order: cwd, then package root
|
|
49
50
|
const candidates = [
|
|
50
51
|
path.resolve(process.cwd(), "rlm_config.yaml"),
|
|
51
|
-
path.resolve(
|
|
52
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "rlm_config.yaml"),
|
|
52
53
|
];
|
|
53
54
|
for (const configPath of candidates) {
|
|
54
55
|
if (fs.existsSync(configPath)) {
|
package/dist/env.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import * as os from "node:os";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
12
13
|
function loadEnvFile(filePath) {
|
|
13
14
|
if (!fs.existsSync(filePath))
|
|
14
15
|
return;
|
|
@@ -30,7 +31,7 @@ function loadEnvFile(filePath) {
|
|
|
30
31
|
// 1. Load persistent credentials (~/.rlm/credentials)
|
|
31
32
|
loadEnvFile(path.join(os.homedir(), ".rlm", "credentials"));
|
|
32
33
|
// 2. Load .env from package root (local overrides)
|
|
33
|
-
const __dir = path.dirname(
|
|
34
|
+
const __dir = path.dirname(fileURLToPath(import.meta.url));
|
|
34
35
|
loadEnvFile(path.resolve(__dir, "..", ".env"));
|
|
35
36
|
// Default model
|
|
36
37
|
if (!process.env.RLM_MODEL) {
|
package/dist/repl.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import * as path from "node:path";
|
|
10
|
+
import * as os from "node:os";
|
|
10
11
|
import * as readline from "node:readline";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
11
13
|
// ── REPL class ──────────────────────────────────────────────────────────────
|
|
12
14
|
export class PythonRepl {
|
|
13
15
|
proc = null;
|
|
@@ -28,13 +30,14 @@ export class PythonRepl {
|
|
|
28
30
|
async start(signal) {
|
|
29
31
|
if (this.isAlive)
|
|
30
32
|
return;
|
|
31
|
-
const runtimePath = path.join(path.dirname(
|
|
32
|
-
|
|
33
|
+
const runtimePath = path.join(path.dirname(fileURLToPath(import.meta.url)), "runtime.py");
|
|
34
|
+
const pythonCmd = process.platform === "win32" ? "python" : "python3";
|
|
35
|
+
this.proc = spawn(pythonCmd, [runtimePath], {
|
|
33
36
|
stdio: ["pipe", "pipe", "pipe"],
|
|
34
37
|
env: {
|
|
35
38
|
// Only pass what Python actually needs — not API keys or secrets
|
|
36
39
|
PATH: process.env.PATH,
|
|
37
|
-
HOME:
|
|
40
|
+
HOME: os.homedir(),
|
|
38
41
|
PYTHONUNBUFFERED: "1",
|
|
39
42
|
},
|
|
40
43
|
});
|