@lobehub/cli 0.0.187 → 0.0.189
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/index.js +296 -33
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -60392,7 +60392,7 @@ const buildAntigravityArgs = ({ extraArgs = [], resumeSessionId }) => {
|
|
|
60392
60392
|
|
|
60393
60393
|
//#endregion
|
|
60394
60394
|
//#region ../../packages/heterogeneous-agents/src/spawn/wsl.ts
|
|
60395
|
-
var WSL_COMMAND_PREFIX, isWslCommand, parseWslCommand, formatWslCommand, getWslExecutable, toWslPath, toWslArg, NEVER_FORWARDED, FORWARDED_PREFIXES, FORWARDED_PROXY, ENV_NAME, collectForwardedEnvNames, mergeWslEnv, buildWslSpawnPlan, WSL_PROBE_TIMEOUT_MS, WSL_LIST_TIMEOUT_MS, PATH_MARKER, COMMAND_MARKER, WSL_PROBED_COMMANDS,
|
|
60395
|
+
var WSL_COMMAND_PREFIX, isWslCommand, parseWslCommand, formatWslCommand, getWslExecutable, toWslPath, toWslArg, NEVER_FORWARDED, FORWARDED_PREFIXES, FORWARDED_PROXY, ENV_NAME, collectForwardedEnvNames, mergeWslEnv, WSL_DEFAULT_PATH, withWslBinaryFolder, buildWslSpawnPlan, WSL_PROBE_TIMEOUT_MS, WSL_INTERACTIVE_SHELL_TIMEOUT_S, WSL_LOGIN_SHELL_TIMEOUT_S, WSL_LIST_TIMEOUT_MS, PATH_MARKER, COMMAND_MARKER, SHELL_PATH_MARKER, WSL_PROBED_COMMANDS, WSL_PROBE_SCRIPT, runWsl, decodeWslOutput, parseWslDistroList, isOnWindowsDrive, parseWslProbeOutput, distrosPromise, distroProbes, settledPathEnv, listWslDistros, probeWslDistro, invalidateWslCache, findWslCommandCandidates, getWslPathEnv;
|
|
60396
60396
|
var init_wsl = __esmMin((() => {
|
|
60397
60397
|
init_config();
|
|
60398
60398
|
WSL_COMMAND_PREFIX = "wsl://";
|
|
@@ -60474,6 +60474,13 @@ var init_wsl = __esmMin((() => {
|
|
|
60474
60474
|
for (const name of names) if (!present.has(name.toLowerCase())) entries.push(`${name}/u`);
|
|
60475
60475
|
return entries.join(":");
|
|
60476
60476
|
};
|
|
60477
|
+
WSL_DEFAULT_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
60478
|
+
withWslBinaryFolder = (linuxPath, pathEnv) => {
|
|
60479
|
+
const dir = linuxPath.slice(0, linuxPath.lastIndexOf("/"));
|
|
60480
|
+
const current = pathEnv || WSL_DEFAULT_PATH;
|
|
60481
|
+
if (!dir || current.split(":").includes(dir)) return current;
|
|
60482
|
+
return `${dir}:${current}`;
|
|
60483
|
+
};
|
|
60477
60484
|
buildWslSpawnPlan = ({ distro, linuxPath }, args, env, pathEnv) => {
|
|
60478
60485
|
const forwarded = env ? collectForwardedEnvNames(env) : [];
|
|
60479
60486
|
return {
|
|
@@ -60481,7 +60488,8 @@ var init_wsl = __esmMin((() => {
|
|
|
60481
60488
|
"--distribution",
|
|
60482
60489
|
distro,
|
|
60483
60490
|
"--exec",
|
|
60484
|
-
|
|
60491
|
+
"env",
|
|
60492
|
+
`PATH=${withWslBinaryFolder(linuxPath, pathEnv)}`,
|
|
60485
60493
|
linuxPath,
|
|
60486
60494
|
...args.map(toWslArg)
|
|
60487
60495
|
],
|
|
@@ -60492,18 +60500,62 @@ var init_wsl = __esmMin((() => {
|
|
|
60492
60500
|
} : env
|
|
60493
60501
|
};
|
|
60494
60502
|
};
|
|
60495
|
-
WSL_PROBE_TIMEOUT_MS =
|
|
60496
|
-
|
|
60503
|
+
WSL_PROBE_TIMEOUT_MS = 3e4;
|
|
60504
|
+
WSL_INTERACTIVE_SHELL_TIMEOUT_S = 10;
|
|
60505
|
+
WSL_LOGIN_SHELL_TIMEOUT_S = 5;
|
|
60506
|
+
WSL_LIST_TIMEOUT_MS = 15e3;
|
|
60497
60507
|
PATH_MARKER = "__LOBEHUB_WSL_PATH__=";
|
|
60498
60508
|
COMMAND_MARKER = "__LOBEHUB_WSL_CMD__=";
|
|
60509
|
+
SHELL_PATH_MARKER = "__LOBEHUB_WSL_SHELL_PATH__=";
|
|
60499
60510
|
WSL_PROBED_COMMANDS = [...new Set([
|
|
60500
60511
|
...HETEROGENEOUS_AGENT_CONFIGS.map((config) => config.defaultCommand),
|
|
60501
60512
|
"cursor-agent",
|
|
60502
60513
|
"dsh"
|
|
60503
60514
|
])].filter((name) => /^[\w.-]+$/.test(name));
|
|
60504
|
-
|
|
60505
|
-
|
|
60506
|
-
|
|
60515
|
+
WSL_PROBE_SCRIPT = `lh_c='${COMMAND_MARKER}'
|
|
60516
|
+
lh_to=; command -v timeout >/dev/null 2>&1 && lh_to=timeout
|
|
60517
|
+
lh_run() { lh_s=$1; shift; if [ -n "$lh_to" ]; then timeout "$lh_s" "$@"; else "$@"; fi; }
|
|
60518
|
+
lh_shell="\${SHELL:-/bin/sh}"
|
|
60519
|
+
case "\${lh_shell##*/}" in
|
|
60520
|
+
bash|zsh|ksh|sh|dash) lh_ip=$(lh_run ${WSL_INTERACTIVE_SHELL_TIMEOUT_S} "$lh_shell" -ilc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" "$PATH"' </dev/null 2>/dev/null) ;;
|
|
60521
|
+
fish) lh_ip=$(lh_run ${WSL_INTERACTIVE_SHELL_TIMEOUT_S} "$lh_shell" -ilc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" (string join : $PATH)' </dev/null 2>/dev/null) ;;
|
|
60522
|
+
*) lh_ip= ;;
|
|
60523
|
+
esac
|
|
60524
|
+
lh_ip=$(printf '%s\\n' "$lh_ip" | sed -n 's/^${SHELL_PATH_MARKER}//p' | tail -n 1)
|
|
60525
|
+
lh_lp=$(lh_run ${WSL_LOGIN_SHELL_TIMEOUT_S} sh -lc 'printf "\\n${SHELL_PATH_MARKER}%s\\n" "$PATH"' </dev/null 2>/dev/null | sed -n 's/^${SHELL_PATH_MARKER}//p' | tail -n 1)
|
|
60526
|
+
printf '\\n${PATH_MARKER}%s\\n' "\${lh_ip:-$lh_lp}"
|
|
60527
|
+
lh_wm=$(awk '$1 ~ /^[A-Za-z]:/ {print $2}' /proc/mounts 2>/dev/null)
|
|
60528
|
+
lh_win() { case "$1" in /mnt/[A-Za-z]/*) return 0 ;; esac; for lh_m in $lh_wm; do case "$1" in "$lh_m"/*) return 0 ;; esac; done; return 1; }
|
|
60529
|
+
lh_emit() { case "$2" in /*) ;; *) return 0 ;; esac; lh_win "$2" && return 0; [ -f "$2" ] && [ -x "$2" ] && printf '%s%s=%s\\n' "$lh_c" "$1" "$2"; return 0; }
|
|
60530
|
+
lh_vs() { ls "$1" 2>/dev/null | sed 's/^v*\\([0-9][0-9.]*\\).*$/\\1 &/;t;d' | sort -t. -k1,1nr -k2,2nr -k3,3nr | cut -d' ' -f2; }
|
|
60531
|
+
lh_dirs() {
|
|
60532
|
+
echo "$HOME/.local/bin"
|
|
60533
|
+
lh_np=$(sed -n 's/^[[:space:]]*prefix[[:space:]]*=[[:space:]]*//p' "$HOME/.npmrc" 2>/dev/null | head -n 1 | tr -d "\\"'\\r")
|
|
60534
|
+
case "$lh_np" in "~/"*) echo "$HOME/\${lh_np#??}/bin" ;; /*) echo "$lh_np/bin" ;; esac
|
|
60535
|
+
echo "$HOME/.npm-global/bin"; echo "$HOME/.bun/bin"; echo "$HOME/.local/share/pnpm"; echo "$HOME/.volta/bin"
|
|
60536
|
+
lh_nv="\${NVM_DIR:-$HOME/.nvm}"
|
|
60537
|
+
lh_nd=$(head -n 1 "$lh_nv/alias/default" 2>/dev/null); lh_nd=\${lh_nd#v}
|
|
60538
|
+
case "$lh_nd" in [0-9]*) for lh_v in $(lh_vs "$lh_nv/versions/node"); do case "\${lh_v#v}" in "$lh_nd"|"$lh_nd".*) echo "$lh_nv/versions/node/$lh_v/bin" ;; esac; done ;; esac
|
|
60539
|
+
for lh_v in $(lh_vs "$lh_nv/versions/node"); do echo "$lh_nv/versions/node/$lh_v/bin"; done
|
|
60540
|
+
for lh_r in "$HOME/.local/share/fnm" "$HOME/.fnm"; do [ -d "$lh_r/node-versions" ] || continue; echo "$lh_r/aliases/default/bin"; for lh_v in $(lh_vs "$lh_r/node-versions"); do echo "$lh_r/node-versions/$lh_v/installation/bin"; done; done
|
|
60541
|
+
echo "$HOME/.local/share/mise/shims"
|
|
60542
|
+
for lh_v in $(lh_vs "$HOME/.local/share/mise/installs/node"); do echo "$HOME/.local/share/mise/installs/node/$lh_v/bin"; done
|
|
60543
|
+
echo "$HOME/.asdf/shims"; echo "$HOME/.cargo/bin"; echo "$HOME/.deno/bin"
|
|
60544
|
+
echo /home/linuxbrew/.linuxbrew/bin; echo "$HOME/.linuxbrew/bin"; echo /usr/local/bin; echo /snap/bin
|
|
60545
|
+
for lh_a in .opencode .amp .kimi-code .grok; do echo "$HOME/$lh_a/bin"; done
|
|
60546
|
+
}
|
|
60547
|
+
lh_ds=$(lh_dirs)
|
|
60548
|
+
for lh_name in "$@"; do
|
|
60549
|
+
for lh_p in "$lh_ip" "$lh_lp" "$PATH"; do
|
|
60550
|
+
lh_o=$IFS; IFS=:
|
|
60551
|
+
for lh_d in $lh_p; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
|
|
60552
|
+
IFS=$lh_o
|
|
60553
|
+
done
|
|
60554
|
+
lh_o=$IFS; IFS='
|
|
60555
|
+
'
|
|
60556
|
+
for lh_d in $lh_ds; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
|
|
60557
|
+
IFS=$lh_o
|
|
60558
|
+
done
|
|
60507
60559
|
`;
|
|
60508
60560
|
runWsl = (args, { env, input, timeout }) => new Promise((resolve, reject) => {
|
|
60509
60561
|
let settled = false;
|
|
@@ -60542,6 +60594,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60542
60594
|
});
|
|
60543
60595
|
decodeWslOutput = (output) => (output.includes(0) ? output.toString("utf16le") : output.toString("utf8")).replace(/^\uFEFF/, "");
|
|
60544
60596
|
parseWslDistroList = (output) => output.split(/\r?\n/).map((line) => line.replaceAll("\0", "").trim()).filter((name) => name && !/^docker-desktop/i.test(name));
|
|
60597
|
+
isOnWindowsDrive = (linuxPath) => /^\/mnt\/[a-z]\//i.test(linuxPath);
|
|
60545
60598
|
parseWslProbeOutput = (output) => {
|
|
60546
60599
|
const commands = /* @__PURE__ */ new Map();
|
|
60547
60600
|
let pathEnv;
|
|
@@ -60553,7 +60606,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60553
60606
|
const separator = entry.indexOf("=");
|
|
60554
60607
|
const name = entry.slice(0, separator);
|
|
60555
60608
|
const linuxPath = entry.slice(separator + 1);
|
|
60556
|
-
if (separator
|
|
60609
|
+
if (separator <= 0 || !linuxPath.startsWith("/") || isOnWindowsDrive(linuxPath)) continue;
|
|
60610
|
+
const found = commands.get(name) ?? [];
|
|
60611
|
+
if (!found.includes(linuxPath)) found.push(linuxPath);
|
|
60612
|
+
commands.set(name, found);
|
|
60557
60613
|
}
|
|
60558
60614
|
}
|
|
60559
60615
|
return {
|
|
@@ -60565,7 +60621,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60565
60621
|
distroProbes = /* @__PURE__ */ new Map();
|
|
60566
60622
|
settledPathEnv = /* @__PURE__ */ new Map();
|
|
60567
60623
|
listWslDistros = () => {
|
|
60568
|
-
distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() =>
|
|
60624
|
+
distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() => {
|
|
60625
|
+
distrosPromise = void 0;
|
|
60626
|
+
return [];
|
|
60627
|
+
});
|
|
60569
60628
|
return distrosPromise;
|
|
60570
60629
|
};
|
|
60571
60630
|
probeWslDistro = (distro) => {
|
|
@@ -60580,7 +60639,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60580
60639
|
"--",
|
|
60581
60640
|
...WSL_PROBED_COMMANDS
|
|
60582
60641
|
], {
|
|
60583
|
-
input:
|
|
60642
|
+
input: WSL_PROBE_SCRIPT,
|
|
60584
60643
|
timeout: WSL_PROBE_TIMEOUT_MS
|
|
60585
60644
|
}).then((output) => {
|
|
60586
60645
|
const result = parseWslProbeOutput(decodeWslOutput(output));
|
|
@@ -60602,13 +60661,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
|
|
|
60602
60661
|
if (platform() !== "win32") return [];
|
|
60603
60662
|
const distros = await listWslDistros();
|
|
60604
60663
|
const probes = await Promise.all(distros.map((distro) => probeWslDistro(distro)));
|
|
60605
|
-
return distros.flatMap((distro, index) => {
|
|
60606
|
-
|
|
60607
|
-
|
|
60608
|
-
|
|
60609
|
-
linuxPath
|
|
60610
|
-
})] : [];
|
|
60611
|
-
});
|
|
60664
|
+
return distros.flatMap((distro, index) => (probes[index]?.commands.get(command) ?? []).map((linuxPath) => formatWslCommand({
|
|
60665
|
+
distro,
|
|
60666
|
+
linuxPath
|
|
60667
|
+
})));
|
|
60612
60668
|
};
|
|
60613
60669
|
getWslPathEnv = async (distro) => (await probeWslDistro(distro))?.pathEnv;
|
|
60614
60670
|
}));
|
|
@@ -60802,6 +60858,192 @@ var init_cliSpawn = __esmMin((() => {
|
|
|
60802
60858
|
};
|
|
60803
60859
|
}));
|
|
60804
60860
|
|
|
60861
|
+
//#endregion
|
|
60862
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/userBinDirs.ts
|
|
60863
|
+
var getEnv$1, pathFor, readDirNames, VERSION_DIR, sortVersionDirsDesc, defaultFirst, readFirstLine, readNpmrcPrefix, nodeVersionBins, getWindowsUserBinDirs, getPosixUserBinDirs, getUserBinDirs, WINDOWS_EXTS, isRunnableFile, findCommandInUserBinDirs;
|
|
60864
|
+
var init_userBinDirs = __esmMin((() => {
|
|
60865
|
+
getEnv$1 = (env, name, os) => {
|
|
60866
|
+
const exact = env[name]?.trim();
|
|
60867
|
+
if (exact || os !== "win32") return exact || void 0;
|
|
60868
|
+
const lower = name.toLowerCase();
|
|
60869
|
+
const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === lower && !!env[candidate]?.trim());
|
|
60870
|
+
return key ? env[key].trim() : void 0;
|
|
60871
|
+
};
|
|
60872
|
+
pathFor = (os) => os === "win32" ? path.win32 : path.posix;
|
|
60873
|
+
readDirNames = async (dir) => {
|
|
60874
|
+
try {
|
|
60875
|
+
const entries = await readdir(dir);
|
|
60876
|
+
return Array.isArray(entries) ? entries.map(String) : [];
|
|
60877
|
+
} catch {
|
|
60878
|
+
return [];
|
|
60879
|
+
}
|
|
60880
|
+
};
|
|
60881
|
+
VERSION_DIR = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
60882
|
+
sortVersionDirsDesc = (names) => names.map((name) => ({
|
|
60883
|
+
match: name.match(VERSION_DIR),
|
|
60884
|
+
name
|
|
60885
|
+
})).filter((entry) => !!entry.match).sort((a, b) => {
|
|
60886
|
+
for (let index = 1; index <= 3; index += 1) {
|
|
60887
|
+
const diff = Number(b.match[index] ?? 0) - Number(a.match[index] ?? 0);
|
|
60888
|
+
if (diff !== 0) return diff;
|
|
60889
|
+
}
|
|
60890
|
+
return 0;
|
|
60891
|
+
}).map(({ name }) => name);
|
|
60892
|
+
defaultFirst = (versions, alias) => {
|
|
60893
|
+
const wanted = alias?.trim().replace(/^v/, "");
|
|
60894
|
+
if (!wanted || !/^\d/.test(wanted)) return versions;
|
|
60895
|
+
const matches = (version) => {
|
|
60896
|
+
const bare = version.replace(/^v/, "");
|
|
60897
|
+
return bare === wanted || bare.startsWith(`${wanted}.`);
|
|
60898
|
+
};
|
|
60899
|
+
return [...versions.filter(matches), ...versions.filter((version) => !matches(version))];
|
|
60900
|
+
};
|
|
60901
|
+
readFirstLine = async (file) => {
|
|
60902
|
+
try {
|
|
60903
|
+
const content = await readFile(file, "utf8");
|
|
60904
|
+
return typeof content === "string" ? content.split(/\r?\n/)[0]?.trim() || void 0 : void 0;
|
|
60905
|
+
} catch {
|
|
60906
|
+
return;
|
|
60907
|
+
}
|
|
60908
|
+
};
|
|
60909
|
+
readNpmrcPrefix = async (home, os, env) => {
|
|
60910
|
+
const fromEnv = getEnv$1(env, "NPM_CONFIG_PREFIX", os) ?? getEnv$1(env, "npm_config_prefix", os);
|
|
60911
|
+
if (fromEnv) return fromEnv;
|
|
60912
|
+
let content;
|
|
60913
|
+
try {
|
|
60914
|
+
content = await readFile(pathFor(os).join(home, ".npmrc"), "utf8");
|
|
60915
|
+
} catch {
|
|
60916
|
+
return;
|
|
60917
|
+
}
|
|
60918
|
+
if (typeof content !== "string") return void 0;
|
|
60919
|
+
const value = content.match(/^\s*prefix\s*=\s*(.+?)\s*$/m)?.[1]?.replaceAll(/^["']|["']$/g, "").trim();
|
|
60920
|
+
if (!value) return void 0;
|
|
60921
|
+
if (value.startsWith("~/") || value.startsWith("~\\")) return pathFor(os).join(home, value.slice(2));
|
|
60922
|
+
return pathFor(os).isAbsolute(value) ? value : void 0;
|
|
60923
|
+
};
|
|
60924
|
+
nodeVersionBins = async (versionsDir, alias, toBin, os) => defaultFirst(sortVersionDirsDesc(await readDirNames(versionsDir)), alias).map((version) => toBin(pathFor(os).join(versionsDir, version)));
|
|
60925
|
+
getWindowsUserBinDirs = async (env, home) => {
|
|
60926
|
+
const os = "win32";
|
|
60927
|
+
const { join } = path.win32;
|
|
60928
|
+
const get = (name) => getEnv$1(env, name, os);
|
|
60929
|
+
const appData = get("APPDATA") ?? join(home, "AppData", "Roaming");
|
|
60930
|
+
const localAppData = get("LOCALAPPDATA") ?? join(home, "AppData", "Local");
|
|
60931
|
+
const programData = get("ProgramData") ?? "C:\\ProgramData";
|
|
60932
|
+
const programFiles = get("ProgramFiles") ?? "C:\\Program Files";
|
|
60933
|
+
const npmPrefix = await readNpmrcPrefix(home, os, env);
|
|
60934
|
+
const nvmHome = get("NVM_HOME");
|
|
60935
|
+
const nvmVersions = nvmHome ? await nodeVersionBins(nvmHome, void 0, (dir) => dir, os) : [];
|
|
60936
|
+
const fnmRoots = [
|
|
60937
|
+
get("FNM_DIR"),
|
|
60938
|
+
join(appData, "fnm"),
|
|
60939
|
+
join(localAppData, "fnm")
|
|
60940
|
+
].filter((dir) => !!dir);
|
|
60941
|
+
const fnmDirs = [];
|
|
60942
|
+
for (const root of new Set(fnmRoots)) fnmDirs.push(join(root, "aliases", "default"), ...await nodeVersionBins(join(root, "node-versions"), void 0, (dir) => join(dir, "installation"), os));
|
|
60943
|
+
const miseData = get("MISE_DATA_DIR") ?? (get("XDG_DATA_HOME") ? join(get("XDG_DATA_HOME"), "mise") : join(localAppData, "mise"));
|
|
60944
|
+
const scoop = get("SCOOP") ?? join(home, "scoop");
|
|
60945
|
+
const scoopGlobal = get("SCOOP_GLOBAL") ?? join(programData, "scoop");
|
|
60946
|
+
return [
|
|
60947
|
+
join(home, ".local", "bin"),
|
|
60948
|
+
...npmPrefix ? [npmPrefix] : [],
|
|
60949
|
+
join(appData, "npm"),
|
|
60950
|
+
...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
|
|
60951
|
+
join(localAppData, "pnpm"),
|
|
60952
|
+
...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
|
|
60953
|
+
join(home, ".bun", "bin"),
|
|
60954
|
+
...get("VOLTA_HOME") ? [join(get("VOLTA_HOME"), "bin")] : [],
|
|
60955
|
+
join(localAppData, "Volta", "bin"),
|
|
60956
|
+
...get("NVM_SYMLINK") ? [get("NVM_SYMLINK")] : [],
|
|
60957
|
+
"C:\\nvm4w\\nodejs",
|
|
60958
|
+
...nvmVersions,
|
|
60959
|
+
...fnmDirs,
|
|
60960
|
+
join(miseData, "shims"),
|
|
60961
|
+
join(scoop, "shims"),
|
|
60962
|
+
join(scoopGlobal, "shims"),
|
|
60963
|
+
join(localAppData, "Microsoft", "WinGet", "Links"),
|
|
60964
|
+
join(programFiles, "WinGet", "Links"),
|
|
60965
|
+
join(get("ChocolateyInstall") ?? join(programData, "chocolatey"), "bin"),
|
|
60966
|
+
join(programFiles, "nodejs"),
|
|
60967
|
+
join(home, ".cargo", "bin"),
|
|
60968
|
+
join(home, ".deno", "bin")
|
|
60969
|
+
];
|
|
60970
|
+
};
|
|
60971
|
+
getPosixUserBinDirs = async (env, home) => {
|
|
60972
|
+
const os = "linux";
|
|
60973
|
+
const { join } = path.posix;
|
|
60974
|
+
const get = (name) => getEnv$1(env, name, os);
|
|
60975
|
+
const xdgData = get("XDG_DATA_HOME") ?? join(home, ".local", "share");
|
|
60976
|
+
const npmPrefix = await readNpmrcPrefix(home, os, env);
|
|
60977
|
+
const nvmDir = get("NVM_DIR") ?? join(home, ".nvm");
|
|
60978
|
+
const nvmBins = await nodeVersionBins(join(nvmDir, "versions", "node"), await readFirstLine(join(nvmDir, "alias", "default")), (dir) => join(dir, "bin"), os);
|
|
60979
|
+
const fnmRoots = [
|
|
60980
|
+
get("FNM_DIR"),
|
|
60981
|
+
join(xdgData, "fnm"),
|
|
60982
|
+
join(home, "Library", "Application Support", "fnm"),
|
|
60983
|
+
join(home, ".fnm")
|
|
60984
|
+
].filter((dir) => !!dir);
|
|
60985
|
+
const fnmDirs = [];
|
|
60986
|
+
for (const root of new Set(fnmRoots)) fnmDirs.push(join(root, "aliases", "default", "bin"), ...await nodeVersionBins(join(root, "node-versions"), void 0, (dir) => join(dir, "installation", "bin"), os));
|
|
60987
|
+
const miseData = get("MISE_DATA_DIR") ?? join(xdgData, "mise");
|
|
60988
|
+
const miseNodes = await nodeVersionBins(join(miseData, "installs", "node"), void 0, (dir) => join(dir, "bin"), os);
|
|
60989
|
+
return [
|
|
60990
|
+
join(home, ".local", "bin"),
|
|
60991
|
+
...npmPrefix ? [join(npmPrefix, "bin")] : [],
|
|
60992
|
+
join(home, ".npm-global", "bin"),
|
|
60993
|
+
join(home, ".npm", "bin"),
|
|
60994
|
+
...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
|
|
60995
|
+
join(home, ".bun", "bin"),
|
|
60996
|
+
...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
|
|
60997
|
+
join(home, "Library", "pnpm"),
|
|
60998
|
+
join(xdgData, "pnpm"),
|
|
60999
|
+
join(get("VOLTA_HOME") ?? join(home, ".volta"), "bin"),
|
|
61000
|
+
...nvmBins,
|
|
61001
|
+
...fnmDirs,
|
|
61002
|
+
join(miseData, "shims"),
|
|
61003
|
+
...miseNodes,
|
|
61004
|
+
join(get("ASDF_DATA_DIR") ?? join(home, ".asdf"), "shims"),
|
|
61005
|
+
join(home, ".cargo", "bin"),
|
|
61006
|
+
join(home, ".deno", "bin"),
|
|
61007
|
+
"/opt/homebrew/bin",
|
|
61008
|
+
"/usr/local/bin",
|
|
61009
|
+
"/home/linuxbrew/.linuxbrew/bin",
|
|
61010
|
+
join(home, ".linuxbrew", "bin")
|
|
61011
|
+
];
|
|
61012
|
+
};
|
|
61013
|
+
getUserBinDirs = async ({ env = process.env, home = homedir(), os = platform() } = {}) => {
|
|
61014
|
+
const dirs = os === "win32" ? await getWindowsUserBinDirs(env, home) : await getPosixUserBinDirs(env, home);
|
|
61015
|
+
const seen = /* @__PURE__ */ new Set();
|
|
61016
|
+
return dirs.filter((dir) => {
|
|
61017
|
+
const key = os === "win32" ? dir.toLowerCase() : dir;
|
|
61018
|
+
if (!dir || seen.has(key)) return false;
|
|
61019
|
+
seen.add(key);
|
|
61020
|
+
return true;
|
|
61021
|
+
});
|
|
61022
|
+
};
|
|
61023
|
+
WINDOWS_EXTS = [
|
|
61024
|
+
".exe",
|
|
61025
|
+
".cmd",
|
|
61026
|
+
".bat"
|
|
61027
|
+
];
|
|
61028
|
+
isRunnableFile = async (file, os) => {
|
|
61029
|
+
try {
|
|
61030
|
+
await access(file, os === "win32" ? constants.F_OK : constants.X_OK);
|
|
61031
|
+
return true;
|
|
61032
|
+
} catch {
|
|
61033
|
+
return false;
|
|
61034
|
+
}
|
|
61035
|
+
};
|
|
61036
|
+
findCommandInUserBinDirs = async (names, options = {}) => {
|
|
61037
|
+
const os = options.os ?? platform();
|
|
61038
|
+
const files = (await getUserBinDirs({
|
|
61039
|
+
...options,
|
|
61040
|
+
os
|
|
61041
|
+
})).flatMap((dir) => names.flatMap((name) => os === "win32" ? WINDOWS_EXTS.map((ext) => path.win32.join(dir, `${name}${ext}`)) : [path.posix.join(dir, name)]));
|
|
61042
|
+
const runnable = await Promise.all(files.map((file) => isRunnableFile(file, os)));
|
|
61043
|
+
return files.filter((_, index) => runnable[index]);
|
|
61044
|
+
};
|
|
61045
|
+
}));
|
|
61046
|
+
|
|
60805
61047
|
//#endregion
|
|
60806
61048
|
//#region ../../packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts
|
|
60807
61049
|
var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
@@ -60809,6 +61051,7 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60809
61051
|
LOGIN_SHELL_TIMEOUT_STATUS_ERROR: () => LOGIN_SHELL_TIMEOUT_STATUS_ERROR,
|
|
60810
61052
|
LoginShellPathTimeoutError: () => LoginShellPathTimeoutError,
|
|
60811
61053
|
detectHeterogeneousCliCommand: () => detectHeterogeneousCliCommand,
|
|
61054
|
+
detectInUserBinDirs: () => detectInUserBinDirs,
|
|
60812
61055
|
detectInWslWhenMissing: () => detectInWslWhenMissing,
|
|
60813
61056
|
detectValidatedCommand: () => detectValidatedCommand,
|
|
60814
61057
|
detectValidatedCommandCandidates: () => detectValidatedCommandCandidates,
|
|
@@ -60817,10 +61060,11 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
60817
61060
|
resolveHeteroSpawnCommand: () => resolveHeteroSpawnCommand,
|
|
60818
61061
|
resolveUserSpawnPath: () => resolveUserSpawnPath
|
|
60819
61062
|
});
|
|
60820
|
-
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand,
|
|
61063
|
+
var execFilePromise$2, VERSION_PATTERN, extractVersion, isWindows, shellPathPromise, registryPathPromise, WINDOWS_SHELL_METAS, WINDOWS_RUNNABLE_EXTS, WINDOWS_SHIM_EXTS, WINDOWS_SHELL_MAX_COMMAND_LINE_LENGTH, isWindowsRunnablePath, isWindowsShimPath, pickWindowsRunnables, isPathLikeCommand, LOGIN_SHELL_PATH_TIMEOUT_MS, LOGIN_SHELL_TIMEOUT_STATUS_ERROR, isLoginShellTimeoutStatus, LoginShellPathTimeoutError, getLoginShellPath, cachedShellPath, shellPathGeneration, getCurrentLoginShellPath, invalidateLoginShellPathCache, WINDOWS_REGISTRY_PATH_KEYS, WINDOWS_REGISTRY_PATH_VALUE, expandWindowsEnvRefs$1, readWindowsRegistryPathValue, readMergedWindowsRegistryPath, getWindowsRegistryPath, mergePathValues, resolveUserSpawnPath, recoverProbeEnvironment, getCommandPathLines, resolveCommandCandidates, quoteWindowsShellToken, buildWindowsShellProbe, UNRESOLVED_SHIM, execProbe, detectValidatedCommandInEnvironment, isProbeableCommand, detectValidatedCommandCandidates, detectValidatedCommand, HETEROGENEOUS_CLI_AGENT_OPTIONS, DEFAULT_HETERO_COMMAND, getWellKnownCommandPaths, detectHeterogeneousCliCommand, DEFAULT_COMMAND_ALIASES, withFolderOnPath, detectInUserBinDirs, detectInWslWhenMissing, resolveHeteroSpawnCommand;
|
|
60821
61064
|
var init_resolveCliCommand = __esmMin((() => {
|
|
60822
61065
|
init_config();
|
|
60823
61066
|
init_cliSpawn();
|
|
61067
|
+
init_userBinDirs();
|
|
60824
61068
|
init_wsl();
|
|
60825
61069
|
execFilePromise$2 = promisify(execFile);
|
|
60826
61070
|
VERSION_PATTERN = /v?(\d+\.\d+\.\d+(?:-[\dA-Za-z.-]+)?(?:\+[\dA-Za-z.-]+)?)/;
|
|
@@ -61150,7 +61394,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61150
61394
|
},
|
|
61151
61395
|
"cursor": {
|
|
61152
61396
|
validateFlag: "--help",
|
|
61153
|
-
validatePattern: /^Usage: agent[\s\S]*Cursor Agent/im
|
|
61397
|
+
validatePattern: /^Usage: (?:cursor-)?agent[\s\S]*Cursor Agent/im
|
|
61154
61398
|
},
|
|
61155
61399
|
"droid": {
|
|
61156
61400
|
validateHelpArgs: ["exec", "--help"],
|
|
@@ -61243,7 +61487,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61243
61487
|
if (platform() === "win32") {
|
|
61244
61488
|
const localAppData = process.env.LOCALAPPDATA;
|
|
61245
61489
|
if (!localAppData) return [];
|
|
61246
|
-
return [path.win32.join(localAppData, "cursor-agent", "agent.cmd")];
|
|
61490
|
+
return [path.win32.join(localAppData, "cursor-agent", "agent.cmd"), path.win32.join(localAppData, "cursor-agent", "cursor-agent.cmd")];
|
|
61247
61491
|
}
|
|
61248
61492
|
if (platform() !== "darwin" && platform() !== "linux") return [];
|
|
61249
61493
|
return [path.join(homedir(), ".local", "bin", "agent"), path.join(homedir(), ".local", "bin", "cursor-agent")];
|
|
@@ -61316,12 +61560,32 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
61316
61560
|
detectHeterogeneousCliCommand = async (agentType, command, probeEnv) => {
|
|
61317
61561
|
const validator = HETEROGENEOUS_CLI_AGENT_OPTIONS[agentType];
|
|
61318
61562
|
if (!validator) return { available: false };
|
|
61319
|
-
|
|
61320
|
-
const
|
|
61321
|
-
|
|
61322
|
-
|
|
61563
|
+
if (!(command.trim() === DEFAULT_HETERO_COMMAND[agentType])) return detectValidatedCommandCandidates([command], validator, probeEnv);
|
|
61564
|
+
const names = [command, ...DEFAULT_COMMAND_ALIASES[agentType] ?? []];
|
|
61565
|
+
return detectInWslWhenMissing(await detectInUserBinDirs(await detectValidatedCommandCandidates([...names, ...getWellKnownCommandPaths(agentType)], validator, probeEnv), names, validator, probeEnv), names, validator);
|
|
61566
|
+
};
|
|
61567
|
+
DEFAULT_COMMAND_ALIASES = { cursor: ["cursor-agent"] };
|
|
61568
|
+
withFolderOnPath = (file, env) => {
|
|
61569
|
+
const base = env ?? process.env;
|
|
61570
|
+
const windows = isWindows();
|
|
61571
|
+
const dir = windows ? path.win32.dirname(file) : path.posix.dirname(file);
|
|
61572
|
+
const delimiter = windows ? ";" : ":";
|
|
61573
|
+
const key = base.PATH === void 0 && windows ? Object.keys(base).find((name) => name.toLowerCase() === "path") : "PATH";
|
|
61574
|
+
const current = key && base[key] || "";
|
|
61575
|
+
return current.split(delimiter).some((entry) => windows ? entry.toLowerCase() === dir.toLowerCase() : entry === dir) ? base : {
|
|
61576
|
+
...base,
|
|
61577
|
+
PATH: current ? `${dir}${delimiter}${current}` : dir
|
|
61578
|
+
};
|
|
61579
|
+
};
|
|
61580
|
+
detectInUserBinDirs = async (status, commandNames, options, probeEnv) => {
|
|
61581
|
+
if (status.available) return status;
|
|
61582
|
+
const candidates = await findCommandInUserBinDirs(commandNames, { env: probeEnv ?? process.env }).catch(() => []);
|
|
61583
|
+
for (const candidate of candidates) {
|
|
61584
|
+
const found = await detectValidatedCommandInEnvironment(candidate, options, withFolderOnPath(candidate, probeEnv));
|
|
61585
|
+
if (found.available) return found;
|
|
61586
|
+
}
|
|
61587
|
+
return status;
|
|
61323
61588
|
};
|
|
61324
|
-
WSL_COMMAND_NAMES = { cursor: ["agent", "cursor-agent"] };
|
|
61325
61589
|
detectInWslWhenMissing = async (status, commandNames, options) => {
|
|
61326
61590
|
if (status.available || !isWindows()) return status;
|
|
61327
61591
|
const candidates = [];
|
|
@@ -75336,18 +75600,17 @@ const isSupportedDshVersion = (version) => {
|
|
|
75336
75600
|
* Find a `dsh` that can run LobeHub turns. An older CLI still answers
|
|
75337
75601
|
* `--version` but has no `acp` profile, so it is reported unavailable here
|
|
75338
75602
|
* rather than failing every turn after the agent was created.
|
|
75603
|
+
*
|
|
75604
|
+
* `dsh` is installed with `npm i -g`, which puts it in whichever global folder
|
|
75605
|
+
* the user's Node setup has: `%APPDATA%\npm`, an nvm-windows or fnm Node's own
|
|
75606
|
+
* folder, a pnpm / bun / Volta global, often off the PATH this app started
|
|
75607
|
+
* with. Those folders are swept before WSL is asked.
|
|
75339
75608
|
*/
|
|
75340
|
-
/**
|
|
75341
|
-
* `dsh` is installed with `npm i -g`. On Windows that drops `dsh.cmd` in npm's
|
|
75342
|
-
* global prefix (`%APPDATA%\npm`), a directory npm's installer only adds to the
|
|
75343
|
-
* registry User PATH, so an app started before it never sees it.
|
|
75344
|
-
*/
|
|
75345
|
-
const getDshWellKnownPaths = () => platform() === "win32" ? [path.win32.join(process.env.APPDATA || path.win32.join(homedir(), "AppData", "Roaming"), "npm", "dsh.cmd")] : [];
|
|
75346
75609
|
const detectDshCommand = async (command = "dsh", env) => {
|
|
75347
75610
|
const isDefaultCommand = command.trim() === "dsh";
|
|
75348
75611
|
const validation = { validatePattern: DSH_VERSION_PATTERN };
|
|
75349
|
-
const nativeStatus = await detectValidatedCommandCandidates(
|
|
75350
|
-
const status = isDefaultCommand ? await detectInWslWhenMissing(nativeStatus, ["dsh"], validation) : nativeStatus;
|
|
75612
|
+
const nativeStatus = await detectValidatedCommandCandidates([command], validation, env);
|
|
75613
|
+
const status = isDefaultCommand ? await detectInWslWhenMissing(await detectInUserBinDirs(nativeStatus, ["dsh"], validation, env), ["dsh"], validation) : nativeStatus;
|
|
75351
75614
|
if (!status.available || isSupportedDshVersion(status.version)) return status;
|
|
75352
75615
|
return {
|
|
75353
75616
|
...status,
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lobehub/cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lobehub/cli 0.0.189" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.189",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/lobehub/lobehub",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "16618b1554ebf8303a41f1556e7e3fa803597744"
|
|
87
87
|
}
|