rlm-cli 0.2.18 → 0.2.20
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/config.js +6 -5
- package/dist/env.js +5 -1
- package/dist/interactive.js +29 -12
- package/dist/viewer.js +8 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -56,12 +56,13 @@ export function loadConfig() {
|
|
|
56
56
|
try {
|
|
57
57
|
const raw = fs.readFileSync(configPath, "utf-8");
|
|
58
58
|
const parsed = parseYaml(raw);
|
|
59
|
+
const clamp = (v, min, max, def) => typeof v === "number" && isFinite(v) ? Math.max(min, Math.min(max, Math.round(v))) : def;
|
|
59
60
|
return {
|
|
60
|
-
max_iterations:
|
|
61
|
-
max_depth:
|
|
62
|
-
max_sub_queries:
|
|
63
|
-
truncate_len:
|
|
64
|
-
metadata_preview_lines:
|
|
61
|
+
max_iterations: clamp(parsed.max_iterations, 1, 100, DEFAULTS.max_iterations),
|
|
62
|
+
max_depth: clamp(parsed.max_depth, 1, 10, DEFAULTS.max_depth),
|
|
63
|
+
max_sub_queries: clamp(parsed.max_sub_queries, 1, 500, DEFAULTS.max_sub_queries),
|
|
64
|
+
truncate_len: clamp(parsed.truncate_len, 500, 50000, DEFAULTS.truncate_len),
|
|
65
|
+
metadata_preview_lines: clamp(parsed.metadata_preview_lines, 5, 100, DEFAULTS.metadata_preview_lines),
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
catch {
|
package/dist/env.js
CHANGED
|
@@ -22,7 +22,11 @@ function loadEnvFile(filePath) {
|
|
|
22
22
|
if (eqIndex === -1)
|
|
23
23
|
continue;
|
|
24
24
|
const key = trimmed.slice(0, eqIndex).trim();
|
|
25
|
-
|
|
25
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
26
|
+
// Strip matching surrounding quotes ("..." or '...')
|
|
27
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
28
|
+
value = value.slice(1, -1);
|
|
29
|
+
}
|
|
26
30
|
if (key && !process.env[key]) {
|
|
27
31
|
process.env[key] = value;
|
|
28
32
|
}
|
package/dist/interactive.js
CHANGED
|
@@ -687,6 +687,8 @@ function walkDir(dir, depth = 0) {
|
|
|
687
687
|
return results;
|
|
688
688
|
}
|
|
689
689
|
for (const entry of entries) {
|
|
690
|
+
if (results.length >= MAX_FILES)
|
|
691
|
+
break;
|
|
690
692
|
if (entry.name.startsWith(".") && entry.name !== ".env")
|
|
691
693
|
continue;
|
|
692
694
|
if (entry.isSymbolicLink())
|
|
@@ -695,18 +697,25 @@ function walkDir(dir, depth = 0) {
|
|
|
695
697
|
if (entry.isDirectory()) {
|
|
696
698
|
if (SKIP_DIRS.has(entry.name))
|
|
697
699
|
continue;
|
|
698
|
-
|
|
700
|
+
const sub = walkDir(full, depth + 1);
|
|
701
|
+
const remaining = MAX_FILES - results.length;
|
|
702
|
+
results.push(...sub.slice(0, remaining));
|
|
699
703
|
}
|
|
700
704
|
else if (entry.isFile()) {
|
|
701
705
|
if (!isBinaryFile(full))
|
|
702
706
|
results.push(full);
|
|
703
707
|
}
|
|
704
|
-
if (results.length > MAX_FILES)
|
|
705
|
-
break;
|
|
706
708
|
}
|
|
707
709
|
return results;
|
|
708
710
|
}
|
|
711
|
+
/** Normalize path separators to forward slash for consistent matching. */
|
|
712
|
+
function toForwardSlash(p) {
|
|
713
|
+
return p.replace(/\\/g, "/");
|
|
714
|
+
}
|
|
709
715
|
function simpleGlobMatch(pattern, filePath, _braceDepth = 0) {
|
|
716
|
+
// Normalize both to forward slashes for cross-platform matching
|
|
717
|
+
pattern = toForwardSlash(pattern);
|
|
718
|
+
filePath = toForwardSlash(filePath);
|
|
710
719
|
// Expand {a,b,c} braces into alternatives (with depth limit)
|
|
711
720
|
const braceMatch = pattern.match(/\{([^}]+)\}/);
|
|
712
721
|
if (braceMatch && _braceDepth < 5) {
|
|
@@ -752,8 +761,9 @@ function resolveFileArgs(args) {
|
|
|
752
761
|
// Glob pattern (contains * or ?)
|
|
753
762
|
if (arg.includes("*") || arg.includes("?")) {
|
|
754
763
|
// Find the base directory (portion before the first glob char)
|
|
755
|
-
const
|
|
756
|
-
const
|
|
764
|
+
const normalized = toForwardSlash(arg);
|
|
765
|
+
const firstGlob = normalized.search(/[*?{]/);
|
|
766
|
+
const baseDir = firstGlob > 0 ? path.resolve(normalized.slice(0, normalized.lastIndexOf("/", firstGlob) + 1) || ".") : process.cwd();
|
|
757
767
|
const allFiles = walkDir(baseDir);
|
|
758
768
|
for (const f of allFiles) {
|
|
759
769
|
const rel = path.relative(process.cwd(), f);
|
|
@@ -983,7 +993,8 @@ function extractFilePath(input) {
|
|
|
983
993
|
return { filePath, query };
|
|
984
994
|
}
|
|
985
995
|
}
|
|
986
|
-
|
|
996
|
+
// Unix absolute path (/...) or Windows absolute path (C:\...)
|
|
997
|
+
const absPathMatch = input.match(/((?:\/|[A-Za-z]:[\\\/])[^\s]+)/);
|
|
987
998
|
if (absPathMatch) {
|
|
988
999
|
const filePath = absPathMatch[1];
|
|
989
1000
|
if (fs.existsSync(filePath)) {
|
|
@@ -991,7 +1002,8 @@ function extractFilePath(input) {
|
|
|
991
1002
|
return { filePath, query };
|
|
992
1003
|
}
|
|
993
1004
|
}
|
|
994
|
-
|
|
1005
|
+
// Relative path with forward or back slashes
|
|
1006
|
+
const relPathMatch = input.match(/([\w\-\.]+[\/\\][\w\-\.\/\\]+\.\w{2,6})/);
|
|
995
1007
|
if (relPathMatch) {
|
|
996
1008
|
const filePath = path.resolve(relPathMatch[1]);
|
|
997
1009
|
if (fs.existsSync(filePath)) {
|
|
@@ -1387,11 +1399,16 @@ async function interactive() {
|
|
|
1387
1399
|
if (!contextText) {
|
|
1388
1400
|
const { filePath, query: extractedQuery } = extractFilePath(query);
|
|
1389
1401
|
if (filePath) {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1402
|
+
try {
|
|
1403
|
+
contextText = fs.readFileSync(filePath, "utf-8");
|
|
1404
|
+
contextSource = path.basename(filePath);
|
|
1405
|
+
const lines = contextText.split("\n").length;
|
|
1406
|
+
console.log(` ${c.green}✓${c.reset} Loaded ${c.bold}${contextText.length.toLocaleString()}${c.reset} chars (${lines} lines) from ${c.underline}${filePath}${c.reset}`);
|
|
1407
|
+
query = extractedQuery || query;
|
|
1408
|
+
}
|
|
1409
|
+
catch (err) {
|
|
1410
|
+
console.log(` ${c.red}Could not read file: ${err.message}${c.reset}`);
|
|
1411
|
+
}
|
|
1395
1412
|
}
|
|
1396
1413
|
}
|
|
1397
1414
|
// Run query
|
package/dist/viewer.js
CHANGED
|
@@ -639,7 +639,14 @@ async function main() {
|
|
|
639
639
|
console.error(`${c.red}File not found: ${filePath}${c.reset}`);
|
|
640
640
|
process.exit(1);
|
|
641
641
|
}
|
|
642
|
-
|
|
642
|
+
let traj;
|
|
643
|
+
try {
|
|
644
|
+
traj = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
645
|
+
}
|
|
646
|
+
catch (err) {
|
|
647
|
+
console.error(`${c.red}Could not parse trajectory file: ${err.message}${c.reset}`);
|
|
648
|
+
process.exit(1);
|
|
649
|
+
}
|
|
643
650
|
if (!traj.iterations || traj.iterations.length === 0) {
|
|
644
651
|
console.error(`${c.red}Trajectory has no iterations (empty run).${c.reset}`);
|
|
645
652
|
process.exit(1);
|