@lichao0223/lobehub-cli 0.0.104 → 0.0.106

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 CHANGED
@@ -60397,7 +60397,7 @@ const buildAntigravityArgs = ({ extraArgs = [], resumeSessionId }) => {
60397
60397
 
60398
60398
  //#endregion
60399
60399
  //#region ../../packages/heterogeneous-agents/src/spawn/wsl.ts
60400
- 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, PROBE_SCRIPT, runWsl, decodeWslOutput, parseWslDistroList, parseWslProbeOutput, distrosPromise, distroProbes, settledPathEnv, listWslDistros, probeWslDistro, invalidateWslCache, findWslCommandCandidates, getWslPathEnv;
60400
+ 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;
60401
60401
  var init_wsl = __esmMin((() => {
60402
60402
  init_config();
60403
60403
  WSL_COMMAND_PREFIX = "wsl://";
@@ -60479,6 +60479,13 @@ var init_wsl = __esmMin((() => {
60479
60479
  for (const name of names) if (!present.has(name.toLowerCase())) entries.push(`${name}/u`);
60480
60480
  return entries.join(":");
60481
60481
  };
60482
+ WSL_DEFAULT_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
60483
+ withWslBinaryFolder = (linuxPath, pathEnv) => {
60484
+ const dir = linuxPath.slice(0, linuxPath.lastIndexOf("/"));
60485
+ const current = pathEnv || WSL_DEFAULT_PATH;
60486
+ if (!dir || current.split(":").includes(dir)) return current;
60487
+ return `${dir}:${current}`;
60488
+ };
60482
60489
  buildWslSpawnPlan = ({ distro, linuxPath }, args, env, pathEnv) => {
60483
60490
  const forwarded = env ? collectForwardedEnvNames(env) : [];
60484
60491
  return {
@@ -60486,7 +60493,8 @@ var init_wsl = __esmMin((() => {
60486
60493
  "--distribution",
60487
60494
  distro,
60488
60495
  "--exec",
60489
- ...pathEnv ? ["env", `PATH=${pathEnv}`] : [],
60496
+ "env",
60497
+ `PATH=${withWslBinaryFolder(linuxPath, pathEnv)}`,
60490
60498
  linuxPath,
60491
60499
  ...args.map(toWslArg)
60492
60500
  ],
@@ -60497,18 +60505,62 @@ var init_wsl = __esmMin((() => {
60497
60505
  } : env
60498
60506
  };
60499
60507
  };
60500
- WSL_PROBE_TIMEOUT_MS = 2e4;
60501
- WSL_LIST_TIMEOUT_MS = 5e3;
60508
+ WSL_PROBE_TIMEOUT_MS = 3e4;
60509
+ WSL_INTERACTIVE_SHELL_TIMEOUT_S = 10;
60510
+ WSL_LOGIN_SHELL_TIMEOUT_S = 5;
60511
+ WSL_LIST_TIMEOUT_MS = 15e3;
60502
60512
  PATH_MARKER = "__LOBEHUB_WSL_PATH__=";
60503
60513
  COMMAND_MARKER = "__LOBEHUB_WSL_CMD__=";
60514
+ SHELL_PATH_MARKER = "__LOBEHUB_WSL_SHELL_PATH__=";
60504
60515
  WSL_PROBED_COMMANDS = [...new Set([
60505
60516
  ...HETEROGENEOUS_AGENT_CONFIGS.map((config) => config.defaultCommand),
60506
60517
  "cursor-agent",
60507
60518
  "dsh"
60508
60519
  ])].filter((name) => /^[\w.-]+$/.test(name));
60509
- PROBE_SCRIPT = `lobehub_shell="\${SHELL:-/bin/sh}"
60510
- case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/sh ;; esac
60511
- "$lobehub_shell" -ilc 'printf "\\n${PATH_MARKER}%s\\n" "$PATH"; for c in "$@"; do p=$(command -v "$c" 2>/dev/null) || continue; case "$p" in /*) printf "${COMMAND_MARKER}%s=%s\\n" "$c" "$p" ;; esac; done' lobehub "$@" </dev/null
60520
+ WSL_PROBE_SCRIPT = `lh_c='${COMMAND_MARKER}'
60521
+ lh_to=; command -v timeout >/dev/null 2>&1 && lh_to=timeout
60522
+ lh_run() { lh_s=$1; shift; if [ -n "$lh_to" ]; then timeout "$lh_s" "$@"; else "$@"; fi; }
60523
+ lh_shell="\${SHELL:-/bin/sh}"
60524
+ case "\${lh_shell##*/}" in
60525
+ 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) ;;
60526
+ 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) ;;
60527
+ *) lh_ip= ;;
60528
+ esac
60529
+ lh_ip=$(printf '%s\\n' "$lh_ip" | sed -n 's/^${SHELL_PATH_MARKER}//p' | tail -n 1)
60530
+ 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)
60531
+ printf '\\n${PATH_MARKER}%s\\n' "\${lh_ip:-$lh_lp}"
60532
+ lh_wm=$(awk '$1 ~ /^[A-Za-z]:/ {print $2}' /proc/mounts 2>/dev/null)
60533
+ 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; }
60534
+ 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; }
60535
+ 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; }
60536
+ lh_dirs() {
60537
+ echo "$HOME/.local/bin"
60538
+ lh_np=$(sed -n 's/^[[:space:]]*prefix[[:space:]]*=[[:space:]]*//p' "$HOME/.npmrc" 2>/dev/null | head -n 1 | tr -d "\\"'\\r")
60539
+ case "$lh_np" in "~/"*) echo "$HOME/\${lh_np#??}/bin" ;; /*) echo "$lh_np/bin" ;; esac
60540
+ echo "$HOME/.npm-global/bin"; echo "$HOME/.bun/bin"; echo "$HOME/.local/share/pnpm"; echo "$HOME/.volta/bin"
60541
+ lh_nv="\${NVM_DIR:-$HOME/.nvm}"
60542
+ lh_nd=$(head -n 1 "$lh_nv/alias/default" 2>/dev/null); lh_nd=\${lh_nd#v}
60543
+ 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
60544
+ for lh_v in $(lh_vs "$lh_nv/versions/node"); do echo "$lh_nv/versions/node/$lh_v/bin"; done
60545
+ 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
60546
+ echo "$HOME/.local/share/mise/shims"
60547
+ for lh_v in $(lh_vs "$HOME/.local/share/mise/installs/node"); do echo "$HOME/.local/share/mise/installs/node/$lh_v/bin"; done
60548
+ echo "$HOME/.asdf/shims"; echo "$HOME/.cargo/bin"; echo "$HOME/.deno/bin"
60549
+ echo /home/linuxbrew/.linuxbrew/bin; echo "$HOME/.linuxbrew/bin"; echo /usr/local/bin; echo /snap/bin
60550
+ for lh_a in .opencode .amp .kimi-code .grok; do echo "$HOME/$lh_a/bin"; done
60551
+ }
60552
+ lh_ds=$(lh_dirs)
60553
+ for lh_name in "$@"; do
60554
+ for lh_p in "$lh_ip" "$lh_lp" "$PATH"; do
60555
+ lh_o=$IFS; IFS=:
60556
+ for lh_d in $lh_p; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
60557
+ IFS=$lh_o
60558
+ done
60559
+ lh_o=$IFS; IFS='
60560
+ '
60561
+ for lh_d in $lh_ds; do IFS=$lh_o; lh_emit "$lh_name" "$lh_d/$lh_name"; done
60562
+ IFS=$lh_o
60563
+ done
60512
60564
  `;
60513
60565
  runWsl = (args, { env, input, timeout }) => new Promise((resolve, reject) => {
60514
60566
  let settled = false;
@@ -60547,6 +60599,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
60547
60599
  });
60548
60600
  decodeWslOutput = (output) => (output.includes(0) ? output.toString("utf16le") : output.toString("utf8")).replace(/^\uFEFF/, "");
60549
60601
  parseWslDistroList = (output) => output.split(/\r?\n/).map((line) => line.replaceAll("\0", "").trim()).filter((name) => name && !/^docker-desktop/i.test(name));
60602
+ isOnWindowsDrive = (linuxPath) => /^\/mnt\/[a-z]\//i.test(linuxPath);
60550
60603
  parseWslProbeOutput = (output) => {
60551
60604
  const commands = /* @__PURE__ */ new Map();
60552
60605
  let pathEnv;
@@ -60558,7 +60611,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
60558
60611
  const separator = entry.indexOf("=");
60559
60612
  const name = entry.slice(0, separator);
60560
60613
  const linuxPath = entry.slice(separator + 1);
60561
- if (separator > 0 && linuxPath.startsWith("/")) commands.set(name, linuxPath);
60614
+ if (separator <= 0 || !linuxPath.startsWith("/") || isOnWindowsDrive(linuxPath)) continue;
60615
+ const found = commands.get(name) ?? [];
60616
+ if (!found.includes(linuxPath)) found.push(linuxPath);
60617
+ commands.set(name, found);
60562
60618
  }
60563
60619
  }
60564
60620
  return {
@@ -60570,7 +60626,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
60570
60626
  distroProbes = /* @__PURE__ */ new Map();
60571
60627
  settledPathEnv = /* @__PURE__ */ new Map();
60572
60628
  listWslDistros = () => {
60573
- distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() => []);
60629
+ distrosPromise ??= runWsl(["--list", "--quiet"], { timeout: WSL_LIST_TIMEOUT_MS }).then((output) => parseWslDistroList(decodeWslOutput(output))).catch(() => {
60630
+ distrosPromise = void 0;
60631
+ return [];
60632
+ });
60574
60633
  return distrosPromise;
60575
60634
  };
60576
60635
  probeWslDistro = (distro) => {
@@ -60585,7 +60644,7 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
60585
60644
  "--",
60586
60645
  ...WSL_PROBED_COMMANDS
60587
60646
  ], {
60588
- input: PROBE_SCRIPT,
60647
+ input: WSL_PROBE_SCRIPT,
60589
60648
  timeout: WSL_PROBE_TIMEOUT_MS
60590
60649
  }).then((output) => {
60591
60650
  const result = parseWslProbeOutput(decodeWslOutput(output));
@@ -60607,13 +60666,10 @@ case "\${lobehub_shell##*/}" in bash|zsh|ksh|sh|dash) ;; *) lobehub_shell=/bin/s
60607
60666
  if (platform() !== "win32") return [];
60608
60667
  const distros = await listWslDistros();
60609
60668
  const probes = await Promise.all(distros.map((distro) => probeWslDistro(distro)));
60610
- return distros.flatMap((distro, index) => {
60611
- const linuxPath = probes[index]?.commands.get(command);
60612
- return linuxPath ? [formatWslCommand({
60613
- distro,
60614
- linuxPath
60615
- })] : [];
60616
- });
60669
+ return distros.flatMap((distro, index) => (probes[index]?.commands.get(command) ?? []).map((linuxPath) => formatWslCommand({
60670
+ distro,
60671
+ linuxPath
60672
+ })));
60617
60673
  };
60618
60674
  getWslPathEnv = async (distro) => (await probeWslDistro(distro))?.pathEnv;
60619
60675
  }));
@@ -60807,6 +60863,192 @@ var init_cliSpawn = __esmMin((() => {
60807
60863
  };
60808
60864
  }));
60809
60865
 
60866
+ //#endregion
60867
+ //#region ../../packages/heterogeneous-agents/src/spawn/userBinDirs.ts
60868
+ var getEnv$1, pathFor, readDirNames, VERSION_DIR, sortVersionDirsDesc, defaultFirst, readFirstLine, readNpmrcPrefix, nodeVersionBins, getWindowsUserBinDirs, getPosixUserBinDirs, getUserBinDirs, WINDOWS_EXTS, isRunnableFile, findCommandInUserBinDirs;
60869
+ var init_userBinDirs = __esmMin((() => {
60870
+ getEnv$1 = (env, name, os) => {
60871
+ const exact = env[name]?.trim();
60872
+ if (exact || os !== "win32") return exact || void 0;
60873
+ const lower = name.toLowerCase();
60874
+ const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === lower && !!env[candidate]?.trim());
60875
+ return key ? env[key].trim() : void 0;
60876
+ };
60877
+ pathFor = (os) => os === "win32" ? path.win32 : path.posix;
60878
+ readDirNames = async (dir) => {
60879
+ try {
60880
+ const entries = await readdir(dir);
60881
+ return Array.isArray(entries) ? entries.map(String) : [];
60882
+ } catch {
60883
+ return [];
60884
+ }
60885
+ };
60886
+ VERSION_DIR = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
60887
+ sortVersionDirsDesc = (names) => names.map((name) => ({
60888
+ match: name.match(VERSION_DIR),
60889
+ name
60890
+ })).filter((entry) => !!entry.match).sort((a, b) => {
60891
+ for (let index = 1; index <= 3; index += 1) {
60892
+ const diff = Number(b.match[index] ?? 0) - Number(a.match[index] ?? 0);
60893
+ if (diff !== 0) return diff;
60894
+ }
60895
+ return 0;
60896
+ }).map(({ name }) => name);
60897
+ defaultFirst = (versions, alias) => {
60898
+ const wanted = alias?.trim().replace(/^v/, "");
60899
+ if (!wanted || !/^\d/.test(wanted)) return versions;
60900
+ const matches = (version) => {
60901
+ const bare = version.replace(/^v/, "");
60902
+ return bare === wanted || bare.startsWith(`${wanted}.`);
60903
+ };
60904
+ return [...versions.filter(matches), ...versions.filter((version) => !matches(version))];
60905
+ };
60906
+ readFirstLine = async (file) => {
60907
+ try {
60908
+ const content = await readFile(file, "utf8");
60909
+ return typeof content === "string" ? content.split(/\r?\n/)[0]?.trim() || void 0 : void 0;
60910
+ } catch {
60911
+ return;
60912
+ }
60913
+ };
60914
+ readNpmrcPrefix = async (home, os, env) => {
60915
+ const fromEnv = getEnv$1(env, "NPM_CONFIG_PREFIX", os) ?? getEnv$1(env, "npm_config_prefix", os);
60916
+ if (fromEnv) return fromEnv;
60917
+ let content;
60918
+ try {
60919
+ content = await readFile(pathFor(os).join(home, ".npmrc"), "utf8");
60920
+ } catch {
60921
+ return;
60922
+ }
60923
+ if (typeof content !== "string") return void 0;
60924
+ const value = content.match(/^\s*prefix\s*=\s*(.+?)\s*$/m)?.[1]?.replaceAll(/^["']|["']$/g, "").trim();
60925
+ if (!value) return void 0;
60926
+ if (value.startsWith("~/") || value.startsWith("~\\")) return pathFor(os).join(home, value.slice(2));
60927
+ return pathFor(os).isAbsolute(value) ? value : void 0;
60928
+ };
60929
+ nodeVersionBins = async (versionsDir, alias, toBin, os) => defaultFirst(sortVersionDirsDesc(await readDirNames(versionsDir)), alias).map((version) => toBin(pathFor(os).join(versionsDir, version)));
60930
+ getWindowsUserBinDirs = async (env, home) => {
60931
+ const os = "win32";
60932
+ const { join } = path.win32;
60933
+ const get = (name) => getEnv$1(env, name, os);
60934
+ const appData = get("APPDATA") ?? join(home, "AppData", "Roaming");
60935
+ const localAppData = get("LOCALAPPDATA") ?? join(home, "AppData", "Local");
60936
+ const programData = get("ProgramData") ?? "C:\\ProgramData";
60937
+ const programFiles = get("ProgramFiles") ?? "C:\\Program Files";
60938
+ const npmPrefix = await readNpmrcPrefix(home, os, env);
60939
+ const nvmHome = get("NVM_HOME");
60940
+ const nvmVersions = nvmHome ? await nodeVersionBins(nvmHome, void 0, (dir) => dir, os) : [];
60941
+ const fnmRoots = [
60942
+ get("FNM_DIR"),
60943
+ join(appData, "fnm"),
60944
+ join(localAppData, "fnm")
60945
+ ].filter((dir) => !!dir);
60946
+ const fnmDirs = [];
60947
+ 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));
60948
+ const miseData = get("MISE_DATA_DIR") ?? (get("XDG_DATA_HOME") ? join(get("XDG_DATA_HOME"), "mise") : join(localAppData, "mise"));
60949
+ const scoop = get("SCOOP") ?? join(home, "scoop");
60950
+ const scoopGlobal = get("SCOOP_GLOBAL") ?? join(programData, "scoop");
60951
+ return [
60952
+ join(home, ".local", "bin"),
60953
+ ...npmPrefix ? [npmPrefix] : [],
60954
+ join(appData, "npm"),
60955
+ ...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
60956
+ join(localAppData, "pnpm"),
60957
+ ...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
60958
+ join(home, ".bun", "bin"),
60959
+ ...get("VOLTA_HOME") ? [join(get("VOLTA_HOME"), "bin")] : [],
60960
+ join(localAppData, "Volta", "bin"),
60961
+ ...get("NVM_SYMLINK") ? [get("NVM_SYMLINK")] : [],
60962
+ "C:\\nvm4w\\nodejs",
60963
+ ...nvmVersions,
60964
+ ...fnmDirs,
60965
+ join(miseData, "shims"),
60966
+ join(scoop, "shims"),
60967
+ join(scoopGlobal, "shims"),
60968
+ join(localAppData, "Microsoft", "WinGet", "Links"),
60969
+ join(programFiles, "WinGet", "Links"),
60970
+ join(get("ChocolateyInstall") ?? join(programData, "chocolatey"), "bin"),
60971
+ join(programFiles, "nodejs"),
60972
+ join(home, ".cargo", "bin"),
60973
+ join(home, ".deno", "bin")
60974
+ ];
60975
+ };
60976
+ getPosixUserBinDirs = async (env, home) => {
60977
+ const os = "linux";
60978
+ const { join } = path.posix;
60979
+ const get = (name) => getEnv$1(env, name, os);
60980
+ const xdgData = get("XDG_DATA_HOME") ?? join(home, ".local", "share");
60981
+ const npmPrefix = await readNpmrcPrefix(home, os, env);
60982
+ const nvmDir = get("NVM_DIR") ?? join(home, ".nvm");
60983
+ const nvmBins = await nodeVersionBins(join(nvmDir, "versions", "node"), await readFirstLine(join(nvmDir, "alias", "default")), (dir) => join(dir, "bin"), os);
60984
+ const fnmRoots = [
60985
+ get("FNM_DIR"),
60986
+ join(xdgData, "fnm"),
60987
+ join(home, "Library", "Application Support", "fnm"),
60988
+ join(home, ".fnm")
60989
+ ].filter((dir) => !!dir);
60990
+ const fnmDirs = [];
60991
+ 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));
60992
+ const miseData = get("MISE_DATA_DIR") ?? join(xdgData, "mise");
60993
+ const miseNodes = await nodeVersionBins(join(miseData, "installs", "node"), void 0, (dir) => join(dir, "bin"), os);
60994
+ return [
60995
+ join(home, ".local", "bin"),
60996
+ ...npmPrefix ? [join(npmPrefix, "bin")] : [],
60997
+ join(home, ".npm-global", "bin"),
60998
+ join(home, ".npm", "bin"),
60999
+ ...get("BUN_INSTALL") ? [join(get("BUN_INSTALL"), "bin")] : [],
61000
+ join(home, ".bun", "bin"),
61001
+ ...get("PNPM_HOME") ? [get("PNPM_HOME")] : [],
61002
+ join(home, "Library", "pnpm"),
61003
+ join(xdgData, "pnpm"),
61004
+ join(get("VOLTA_HOME") ?? join(home, ".volta"), "bin"),
61005
+ ...nvmBins,
61006
+ ...fnmDirs,
61007
+ join(miseData, "shims"),
61008
+ ...miseNodes,
61009
+ join(get("ASDF_DATA_DIR") ?? join(home, ".asdf"), "shims"),
61010
+ join(home, ".cargo", "bin"),
61011
+ join(home, ".deno", "bin"),
61012
+ "/opt/homebrew/bin",
61013
+ "/usr/local/bin",
61014
+ "/home/linuxbrew/.linuxbrew/bin",
61015
+ join(home, ".linuxbrew", "bin")
61016
+ ];
61017
+ };
61018
+ getUserBinDirs = async ({ env = process.env, home = homedir(), os = platform() } = {}) => {
61019
+ const dirs = os === "win32" ? await getWindowsUserBinDirs(env, home) : await getPosixUserBinDirs(env, home);
61020
+ const seen = /* @__PURE__ */ new Set();
61021
+ return dirs.filter((dir) => {
61022
+ const key = os === "win32" ? dir.toLowerCase() : dir;
61023
+ if (!dir || seen.has(key)) return false;
61024
+ seen.add(key);
61025
+ return true;
61026
+ });
61027
+ };
61028
+ WINDOWS_EXTS = [
61029
+ ".exe",
61030
+ ".cmd",
61031
+ ".bat"
61032
+ ];
61033
+ isRunnableFile = async (file, os) => {
61034
+ try {
61035
+ await access(file, os === "win32" ? constants.F_OK : constants.X_OK);
61036
+ return true;
61037
+ } catch {
61038
+ return false;
61039
+ }
61040
+ };
61041
+ findCommandInUserBinDirs = async (names, options = {}) => {
61042
+ const os = options.os ?? platform();
61043
+ const files = (await getUserBinDirs({
61044
+ ...options,
61045
+ os
61046
+ })).flatMap((dir) => names.flatMap((name) => os === "win32" ? WINDOWS_EXTS.map((ext) => path.win32.join(dir, `${name}${ext}`)) : [path.posix.join(dir, name)]));
61047
+ const runnable = await Promise.all(files.map((file) => isRunnableFile(file, os)));
61048
+ return files.filter((_, index) => runnable[index]);
61049
+ };
61050
+ }));
61051
+
60810
61052
  //#endregion
60811
61053
  //#region ../../packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts
60812
61054
  var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
@@ -60814,6 +61056,7 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
60814
61056
  LOGIN_SHELL_TIMEOUT_STATUS_ERROR: () => LOGIN_SHELL_TIMEOUT_STATUS_ERROR,
60815
61057
  LoginShellPathTimeoutError: () => LoginShellPathTimeoutError,
60816
61058
  detectHeterogeneousCliCommand: () => detectHeterogeneousCliCommand,
61059
+ detectInUserBinDirs: () => detectInUserBinDirs,
60817
61060
  detectInWslWhenMissing: () => detectInWslWhenMissing,
60818
61061
  detectValidatedCommand: () => detectValidatedCommand,
60819
61062
  detectValidatedCommandCandidates: () => detectValidatedCommandCandidates,
@@ -60822,10 +61065,11 @@ var resolveCliCommand_exports = /* @__PURE__ */ __exportAll$2({
60822
61065
  resolveHeteroSpawnCommand: () => resolveHeteroSpawnCommand,
60823
61066
  resolveUserSpawnPath: () => resolveUserSpawnPath
60824
61067
  });
60825
- 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, WSL_COMMAND_NAMES, detectInWslWhenMissing, resolveHeteroSpawnCommand;
61068
+ 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;
60826
61069
  var init_resolveCliCommand = __esmMin((() => {
60827
61070
  init_config();
60828
61071
  init_cliSpawn();
61072
+ init_userBinDirs();
60829
61073
  init_wsl();
60830
61074
  execFilePromise$2 = promisify(execFile);
60831
61075
  VERSION_PATTERN = /v?(\d+\.\d+\.\d+(?:-[\dA-Za-z.-]+)?(?:\+[\dA-Za-z.-]+)?)/;
@@ -61155,7 +61399,7 @@ var init_resolveCliCommand = __esmMin((() => {
61155
61399
  },
61156
61400
  "cursor": {
61157
61401
  validateFlag: "--help",
61158
- validatePattern: /^Usage: agent[\s\S]*Cursor Agent/im
61402
+ validatePattern: /^Usage: (?:cursor-)?agent[\s\S]*Cursor Agent/im
61159
61403
  },
61160
61404
  "droid": {
61161
61405
  validateHelpArgs: ["exec", "--help"],
@@ -61248,7 +61492,7 @@ var init_resolveCliCommand = __esmMin((() => {
61248
61492
  if (platform() === "win32") {
61249
61493
  const localAppData = process.env.LOCALAPPDATA;
61250
61494
  if (!localAppData) return [];
61251
- return [path.win32.join(localAppData, "cursor-agent", "agent.cmd")];
61495
+ return [path.win32.join(localAppData, "cursor-agent", "agent.cmd"), path.win32.join(localAppData, "cursor-agent", "cursor-agent.cmd")];
61252
61496
  }
61253
61497
  if (platform() !== "darwin" && platform() !== "linux") return [];
61254
61498
  return [path.join(homedir(), ".local", "bin", "agent"), path.join(homedir(), ".local", "bin", "cursor-agent")];
@@ -61321,12 +61565,32 @@ var init_resolveCliCommand = __esmMin((() => {
61321
61565
  detectHeterogeneousCliCommand = async (agentType, command, probeEnv) => {
61322
61566
  const validator = HETEROGENEOUS_CLI_AGENT_OPTIONS[agentType];
61323
61567
  if (!validator) return { available: false };
61324
- const isDefaultCommand = command.trim() === DEFAULT_HETERO_COMMAND[agentType];
61325
- const status = await detectValidatedCommandCandidates(isDefaultCommand ? [command, ...getWellKnownCommandPaths(agentType)] : [command], validator, probeEnv);
61326
- if (!isDefaultCommand) return status;
61327
- return detectInWslWhenMissing(status, WSL_COMMAND_NAMES[agentType] ?? [command], validator);
61568
+ if (!(command.trim() === DEFAULT_HETERO_COMMAND[agentType])) return detectValidatedCommandCandidates([command], validator, probeEnv);
61569
+ const names = [command, ...DEFAULT_COMMAND_ALIASES[agentType] ?? []];
61570
+ return detectInWslWhenMissing(await detectInUserBinDirs(await detectValidatedCommandCandidates([...names, ...getWellKnownCommandPaths(agentType)], validator, probeEnv), names, validator, probeEnv), names, validator);
61571
+ };
61572
+ DEFAULT_COMMAND_ALIASES = { cursor: ["cursor-agent"] };
61573
+ withFolderOnPath = (file, env) => {
61574
+ const base = env ?? process.env;
61575
+ const windows = isWindows();
61576
+ const dir = windows ? path.win32.dirname(file) : path.posix.dirname(file);
61577
+ const delimiter = windows ? ";" : ":";
61578
+ const key = base.PATH === void 0 && windows ? Object.keys(base).find((name) => name.toLowerCase() === "path") : "PATH";
61579
+ const current = key && base[key] || "";
61580
+ return current.split(delimiter).some((entry) => windows ? entry.toLowerCase() === dir.toLowerCase() : entry === dir) ? base : {
61581
+ ...base,
61582
+ PATH: current ? `${dir}${delimiter}${current}` : dir
61583
+ };
61584
+ };
61585
+ detectInUserBinDirs = async (status, commandNames, options, probeEnv) => {
61586
+ if (status.available) return status;
61587
+ const candidates = await findCommandInUserBinDirs(commandNames, { env: probeEnv ?? process.env }).catch(() => []);
61588
+ for (const candidate of candidates) {
61589
+ const found = await detectValidatedCommandInEnvironment(candidate, options, withFolderOnPath(candidate, probeEnv));
61590
+ if (found.available) return found;
61591
+ }
61592
+ return status;
61328
61593
  };
61329
- WSL_COMMAND_NAMES = { cursor: ["agent", "cursor-agent"] };
61330
61594
  detectInWslWhenMissing = async (status, commandNames, options) => {
61331
61595
  if (status.available || !isWindows()) return status;
61332
61596
  const candidates = [];
@@ -75341,18 +75605,17 @@ const isSupportedDshVersion = (version) => {
75341
75605
  * Find a `dsh` that can run LobeHub turns. An older CLI still answers
75342
75606
  * `--version` but has no `acp` profile, so it is reported unavailable here
75343
75607
  * rather than failing every turn after the agent was created.
75608
+ *
75609
+ * `dsh` is installed with `npm i -g`, which puts it in whichever global folder
75610
+ * the user's Node setup has: `%APPDATA%\npm`, an nvm-windows or fnm Node's own
75611
+ * folder, a pnpm / bun / Volta global, often off the PATH this app started
75612
+ * with. Those folders are swept before WSL is asked.
75344
75613
  */
75345
- /**
75346
- * `dsh` is installed with `npm i -g`. On Windows that drops `dsh.cmd` in npm's
75347
- * global prefix (`%APPDATA%\npm`), a directory npm's installer only adds to the
75348
- * registry User PATH, so an app started before it never sees it.
75349
- */
75350
- const getDshWellKnownPaths = () => platform() === "win32" ? [path.win32.join(process.env.APPDATA || path.win32.join(homedir(), "AppData", "Roaming"), "npm", "dsh.cmd")] : [];
75351
75614
  const detectDshCommand = async (command = "dsh", env) => {
75352
75615
  const isDefaultCommand = command.trim() === "dsh";
75353
75616
  const validation = { validatePattern: DSH_VERSION_PATTERN };
75354
- const nativeStatus = await detectValidatedCommandCandidates(isDefaultCommand ? [command, ...getDshWellKnownPaths()] : [command], validation, env);
75355
- const status = isDefaultCommand ? await detectInWslWhenMissing(nativeStatus, ["dsh"], validation) : nativeStatus;
75617
+ const nativeStatus = await detectValidatedCommandCandidates([command], validation, env);
75618
+ const status = isDefaultCommand ? await detectInWslWhenMissing(await detectInUserBinDirs(nativeStatus, ["dsh"], validation, env), ["dsh"], validation) : nativeStatus;
75356
75619
  if (!status.available || isSupportedDshVersion(status.version)) return status;
75357
75620
  return {
75358
75621
  ...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 "" "@lichao0223/lobehub\-cli 0.0.104" "User Commands"
3
+ .TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.106" "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": "@lichao0223/lobehub-cli",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/lichao0223/lobehub",
@@ -83,5 +83,5 @@
83
83
  "access": "public",
84
84
  "registry": "https://registry.npmjs.org"
85
85
  },
86
- "gitHead": "510c0af3a05c8ab6519c9366b07bf2e782bc7af6"
86
+ "gitHead": "4357e5f1f596e9ceefc8625578e6b7a36ca3fa6d"
87
87
  }