@lobehub/cli 0.0.153 → 0.0.154
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/acceptance-report.html +284 -284
- package/dist/index.js +343 -48
- package/man/man1/lh.1 +4 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import crypto$1, { X509Certificate, createHash, randomBytes, randomUUID, sign } from "node:crypto";
|
|
4
4
|
import * as fs$5 from "node:fs";
|
|
5
|
-
import fs, { appendFileSync, closeSync, constants, createReadStream, createWriteStream, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, unlink, writeFileSync } from "node:fs";
|
|
5
|
+
import fs, { appendFileSync, chmodSync, closeSync, constants, createReadStream, createWriteStream, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, unlink, writeFileSync } from "node:fs";
|
|
6
6
|
import * as os$4 from "node:os";
|
|
7
7
|
import os, { EOL, constants as constants$1, homedir, platform, tmpdir } from "node:os";
|
|
8
8
|
import * as path$4 from "node:path";
|
|
@@ -15,7 +15,7 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
15
15
|
import * as net$1 from "node:net";
|
|
16
16
|
import net, { BlockList, connect, createServer, isIP } from "node:net";
|
|
17
17
|
import { scheduler, setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
18
|
-
import
|
|
18
|
+
import process$1, { cwd, execArgv, execPath, hrtime, platform as platform$1 } from "node:process";
|
|
19
19
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
import { finished, pipeline } from "node:stream/promises";
|
|
21
21
|
import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark, pipeline as pipeline$1 } from "node:stream";
|
|
@@ -22215,7 +22215,7 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22215
22215
|
const childProcess$2 = __require("node:child_process");
|
|
22216
22216
|
const path$16 = __require("node:path");
|
|
22217
22217
|
const fs$17 = __require("node:fs");
|
|
22218
|
-
const process$
|
|
22218
|
+
const process$3 = __require("node:process");
|
|
22219
22219
|
const { Argument, humanReadableArgName } = require_argument();
|
|
22220
22220
|
const { CommanderError } = require_error$1();
|
|
22221
22221
|
const { Help, stripColor } = require_help();
|
|
@@ -22267,13 +22267,13 @@ var require_command = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
22267
22267
|
this._showSuggestionAfterError = true;
|
|
22268
22268
|
this._savedState = null;
|
|
22269
22269
|
this._outputConfiguration = {
|
|
22270
|
-
writeOut: (str) => process$
|
|
22271
|
-
writeErr: (str) => process$
|
|
22270
|
+
writeOut: (str) => process$3.stdout.write(str),
|
|
22271
|
+
writeErr: (str) => process$3.stderr.write(str),
|
|
22272
22272
|
outputError: (str, write) => write(str),
|
|
22273
|
-
getOutHelpWidth: () => process$
|
|
22274
|
-
getErrHelpWidth: () => process$
|
|
22275
|
-
getOutHasColors: () => useColor() ?? (process$
|
|
22276
|
-
getErrHasColors: () => useColor() ?? (process$
|
|
22273
|
+
getOutHelpWidth: () => process$3.stdout.isTTY ? process$3.stdout.columns : void 0,
|
|
22274
|
+
getErrHelpWidth: () => process$3.stderr.isTTY ? process$3.stderr.columns : void 0,
|
|
22275
|
+
getOutHasColors: () => useColor() ?? (process$3.stdout.isTTY && process$3.stdout.hasColors?.()),
|
|
22276
|
+
getErrHasColors: () => useColor() ?? (process$3.stderr.isTTY && process$3.stderr.hasColors?.()),
|
|
22277
22277
|
stripColor: (str) => stripColor(str)
|
|
22278
22278
|
};
|
|
22279
22279
|
this._hidden = false;
|
|
@@ -22631,7 +22631,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22631
22631
|
*/
|
|
22632
22632
|
_exit(exitCode, code, message) {
|
|
22633
22633
|
if (this._exitCallback) this._exitCallback(new CommanderError(exitCode, code, message));
|
|
22634
|
-
process$
|
|
22634
|
+
process$3.exit(exitCode);
|
|
22635
22635
|
}
|
|
22636
22636
|
/**
|
|
22637
22637
|
* Register callback `fn` for the command.
|
|
@@ -22970,11 +22970,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22970
22970
|
if (argv !== void 0 && !Array.isArray(argv)) throw new Error("first parameter to parse must be array or undefined");
|
|
22971
22971
|
parseOptions = parseOptions || {};
|
|
22972
22972
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
22973
|
-
if (process$
|
|
22974
|
-
const execArgv = process$
|
|
22973
|
+
if (process$3.versions?.electron) parseOptions.from = "electron";
|
|
22974
|
+
const execArgv = process$3.execArgv ?? [];
|
|
22975
22975
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) parseOptions.from = "eval";
|
|
22976
22976
|
}
|
|
22977
|
-
if (argv === void 0) argv = process$
|
|
22977
|
+
if (argv === void 0) argv = process$3.argv;
|
|
22978
22978
|
this.rawArgs = argv.slice();
|
|
22979
22979
|
let userArgs;
|
|
22980
22980
|
switch (parseOptions.from) {
|
|
@@ -22984,7 +22984,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22984
22984
|
userArgs = argv.slice(2);
|
|
22985
22985
|
break;
|
|
22986
22986
|
case "electron":
|
|
22987
|
-
if (process$
|
|
22987
|
+
if (process$3.defaultApp) {
|
|
22988
22988
|
this._scriptPath = argv[1];
|
|
22989
22989
|
userArgs = argv.slice(2);
|
|
22990
22990
|
} else userArgs = argv.slice(1);
|
|
@@ -23149,16 +23149,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23149
23149
|
}
|
|
23150
23150
|
launchWithNode = sourceExt.includes(path$16.extname(executableFile));
|
|
23151
23151
|
let proc;
|
|
23152
|
-
if (process$
|
|
23152
|
+
if (process$3.platform !== "win32") if (launchWithNode) {
|
|
23153
23153
|
args.unshift(executableFile);
|
|
23154
|
-
args = incrementNodeInspectorPort(process$
|
|
23155
|
-
proc = childProcess$2.spawn(process$
|
|
23154
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23155
|
+
proc = childProcess$2.spawn(process$3.argv[0], args, { stdio: "inherit" });
|
|
23156
23156
|
} else proc = childProcess$2.spawn(executableFile, args, { stdio: "inherit" });
|
|
23157
23157
|
else {
|
|
23158
23158
|
this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23159
23159
|
args.unshift(executableFile);
|
|
23160
|
-
args = incrementNodeInspectorPort(process$
|
|
23161
|
-
proc = childProcess$2.spawn(process$
|
|
23160
|
+
args = incrementNodeInspectorPort(process$3.execArgv).concat(args);
|
|
23161
|
+
proc = childProcess$2.spawn(process$3.execPath, args, { stdio: "inherit" });
|
|
23162
23162
|
}
|
|
23163
23163
|
if (!proc.killed) [
|
|
23164
23164
|
"SIGUSR1",
|
|
@@ -23167,20 +23167,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23167
23167
|
"SIGINT",
|
|
23168
23168
|
"SIGHUP"
|
|
23169
23169
|
].forEach((signal) => {
|
|
23170
|
-
process$
|
|
23170
|
+
process$3.on(signal, () => {
|
|
23171
23171
|
if (proc.killed === false && proc.exitCode === null) proc.kill(signal);
|
|
23172
23172
|
});
|
|
23173
23173
|
});
|
|
23174
23174
|
const exitCallback = this._exitCallback;
|
|
23175
23175
|
proc.on("close", (code) => {
|
|
23176
23176
|
code = code ?? 1;
|
|
23177
|
-
if (!exitCallback) process$
|
|
23177
|
+
if (!exitCallback) process$3.exit(code);
|
|
23178
23178
|
else exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)"));
|
|
23179
23179
|
});
|
|
23180
23180
|
proc.on("error", (err) => {
|
|
23181
23181
|
if (err.code === "ENOENT") this._checkForMissingExecutable(executableFile, executableDir, subcommand._name);
|
|
23182
23182
|
else if (err.code === "EACCES") throw new Error(`'${executableFile}' not executable`);
|
|
23183
|
-
if (!exitCallback) process$
|
|
23183
|
+
if (!exitCallback) process$3.exit(1);
|
|
23184
23184
|
else {
|
|
23185
23185
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
23186
23186
|
wrappedError.nestedError = err;
|
|
@@ -23589,13 +23589,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23589
23589
|
*/
|
|
23590
23590
|
_parseOptionsEnv() {
|
|
23591
23591
|
this.options.forEach((option) => {
|
|
23592
|
-
if (option.envVar && option.envVar in process$
|
|
23592
|
+
if (option.envVar && option.envVar in process$3.env) {
|
|
23593
23593
|
const optionKey = option.attributeName();
|
|
23594
23594
|
if (this.getOptionValue(optionKey) === void 0 || [
|
|
23595
23595
|
"default",
|
|
23596
23596
|
"config",
|
|
23597
23597
|
"env"
|
|
23598
|
-
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$
|
|
23598
|
+
].includes(this.getOptionValueSource(optionKey))) if (option.required || option.optional) this.emit(`optionEnv:${option.name()}`, process$3.env[option.envVar]);
|
|
23599
23599
|
else this.emit(`optionEnv:${option.name()}`);
|
|
23600
23600
|
}
|
|
23601
23601
|
});
|
|
@@ -24012,7 +24012,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
24012
24012
|
*/
|
|
24013
24013
|
help(contextOptions) {
|
|
24014
24014
|
this.outputHelp(contextOptions);
|
|
24015
|
-
let exitCode = Number(process$
|
|
24015
|
+
let exitCode = Number(process$3.exitCode ?? 0);
|
|
24016
24016
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) exitCode = 1;
|
|
24017
24017
|
this._exit(exitCode, "commander.help", "(outputHelp)");
|
|
24018
24018
|
}
|
|
@@ -24102,8 +24102,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
24102
24102
|
* @package
|
|
24103
24103
|
*/
|
|
24104
24104
|
function useColor() {
|
|
24105
|
-
if (process$
|
|
24106
|
-
if (process$
|
|
24105
|
+
if (process$3.env.NO_COLOR || process$3.env.FORCE_COLOR === "0" || process$3.env.FORCE_COLOR === "false") return false;
|
|
24106
|
+
if (process$3.env.FORCE_COLOR || process$3.env.CLICOLOR_FORCE !== void 0) return true;
|
|
24107
24107
|
}
|
|
24108
24108
|
exports.Command = Command;
|
|
24109
24109
|
exports.useColor = useColor;
|
|
@@ -51039,6 +51039,300 @@ function registerAgentSignalCommand(program) {
|
|
|
51039
51039
|
});
|
|
51040
51040
|
}
|
|
51041
51041
|
|
|
51042
|
+
//#endregion
|
|
51043
|
+
//#region src/utils/desktopApp.ts
|
|
51044
|
+
const CHANNELS$1 = [
|
|
51045
|
+
"stable",
|
|
51046
|
+
"beta",
|
|
51047
|
+
"nightly"
|
|
51048
|
+
];
|
|
51049
|
+
/** Matches `productName` in scripts/electronWorkflow/setDesktopVersion.ts. */
|
|
51050
|
+
const BUNDLE_NAMES = {
|
|
51051
|
+
beta: "LobeHub-Beta",
|
|
51052
|
+
nightly: "LobeHub-Nightly",
|
|
51053
|
+
stable: "LobeHub"
|
|
51054
|
+
};
|
|
51055
|
+
/** The shell command `lh app --install-cli` writes. */
|
|
51056
|
+
const CLI_SHIM_NAME = "lobehub";
|
|
51057
|
+
const SHIM_MARKER = "# installed by `lh app --install-cli`";
|
|
51058
|
+
const isDesktopChannel = (value) => CHANNELS$1.includes(value);
|
|
51059
|
+
const macBundleCandidates = (channel) => ["/Applications", path.join(os.homedir(), "Applications")].map((dir) => path.join(dir, `${BUNDLE_NAMES[channel]}.app`));
|
|
51060
|
+
/**
|
|
51061
|
+
* The executable inside a `.app`. `CFBundleExecutable` is not always the
|
|
51062
|
+
* product name (a downstream build may rename it), so fall back to reading the
|
|
51063
|
+
* single binary out of `Contents/MacOS` instead of guessing again.
|
|
51064
|
+
*/
|
|
51065
|
+
const macExecutablePath = (bundlePath) => {
|
|
51066
|
+
const macosDir = path.join(bundlePath, "Contents", "MacOS");
|
|
51067
|
+
const named = path.join(macosDir, BUNDLE_NAMES.stable);
|
|
51068
|
+
if (existsSync(named)) return named;
|
|
51069
|
+
try {
|
|
51070
|
+
const binary = readdirSync(macosDir).find((entry) => {
|
|
51071
|
+
try {
|
|
51072
|
+
return statSync(path.join(macosDir, entry)).isFile();
|
|
51073
|
+
} catch {
|
|
51074
|
+
return false;
|
|
51075
|
+
}
|
|
51076
|
+
});
|
|
51077
|
+
return binary ? path.join(macosDir, binary) : null;
|
|
51078
|
+
} catch {
|
|
51079
|
+
return null;
|
|
51080
|
+
}
|
|
51081
|
+
};
|
|
51082
|
+
/**
|
|
51083
|
+
* Windows and Linux binary names are NOT derived from the channel's product
|
|
51084
|
+
* name. `electron-builder.mjs` pins `win.executableName` to a single constant
|
|
51085
|
+
* for every channel, while only the product (and therefore the install
|
|
51086
|
+
* directory) carries the suffix — so beta and nightly both ship
|
|
51087
|
+
* `LobeHub.exe` inside their own folder. Looking for `LobeHub-Beta.exe` finds
|
|
51088
|
+
* nothing and reports a missing installation.
|
|
51089
|
+
*
|
|
51090
|
+
* Linux leaves `executableName` unset, so the binary follows the product name;
|
|
51091
|
+
* the lowercase form covers a build that lowercased it.
|
|
51092
|
+
*/
|
|
51093
|
+
const platformExecutableNames = (channel, platform = process.platform) => {
|
|
51094
|
+
if (platform === "win32") return ["LobeHub.exe"];
|
|
51095
|
+
if (platform === "linux") return [BUNDLE_NAMES[channel], BUNDLE_NAMES[channel].toLowerCase()];
|
|
51096
|
+
return [];
|
|
51097
|
+
};
|
|
51098
|
+
const toLocation = (channel, installPath, platform = process.platform) => {
|
|
51099
|
+
if (platform === "darwin") {
|
|
51100
|
+
const executablePath = macExecutablePath(installPath);
|
|
51101
|
+
return executablePath ? {
|
|
51102
|
+
channel,
|
|
51103
|
+
executablePath,
|
|
51104
|
+
installPath
|
|
51105
|
+
} : null;
|
|
51106
|
+
}
|
|
51107
|
+
for (const name of platformExecutableNames(channel, platform)) {
|
|
51108
|
+
const executablePath = path.join(installPath, name);
|
|
51109
|
+
if (existsSync(executablePath)) return {
|
|
51110
|
+
channel,
|
|
51111
|
+
executablePath,
|
|
51112
|
+
installPath
|
|
51113
|
+
};
|
|
51114
|
+
}
|
|
51115
|
+
return null;
|
|
51116
|
+
};
|
|
51117
|
+
const candidateInstallPaths = (channel) => {
|
|
51118
|
+
if (process.platform === "darwin") return macBundleCandidates(channel);
|
|
51119
|
+
const name = BUNDLE_NAMES[channel];
|
|
51120
|
+
if (process.platform === "win32") {
|
|
51121
|
+
const localAppData = process.env.LOCALAPPDATA ?? path.join(os.homedir(), "AppData", "Local");
|
|
51122
|
+
return [path.join(localAppData, "Programs", name), path.join(localAppData, name)];
|
|
51123
|
+
}
|
|
51124
|
+
return [
|
|
51125
|
+
`/opt/${name}`,
|
|
51126
|
+
path.join(os.homedir(), ".local", "opt", name),
|
|
51127
|
+
`/usr/lib/${name}`
|
|
51128
|
+
];
|
|
51129
|
+
};
|
|
51130
|
+
/**
|
|
51131
|
+
* Find an installed desktop build.
|
|
51132
|
+
*
|
|
51133
|
+
* `LOBEHUB_DESKTOP_PATH` short-circuits the search so a dev build, a
|
|
51134
|
+
* white-label bundle, or a copy in `~/Downloads` can be used without teaching
|
|
51135
|
+
* the CLI every layout. It accepts either the bundle and the executable.
|
|
51136
|
+
*/
|
|
51137
|
+
const resolveDesktopApp = (channel, env = process.env) => {
|
|
51138
|
+
const override = env.LOBEHUB_DESKTOP_PATH;
|
|
51139
|
+
if (override) {
|
|
51140
|
+
const located = locateFromOverride(override, channel ?? "stable");
|
|
51141
|
+
if (located) return located;
|
|
51142
|
+
}
|
|
51143
|
+
for (const candidateChannel of channel ? [channel] : CHANNELS$1) for (const installPath of candidateInstallPaths(candidateChannel)) {
|
|
51144
|
+
if (!existsSync(installPath)) continue;
|
|
51145
|
+
const located = toLocation(candidateChannel, installPath);
|
|
51146
|
+
if (located) return located;
|
|
51147
|
+
}
|
|
51148
|
+
return null;
|
|
51149
|
+
};
|
|
51150
|
+
const locateFromOverride = (override, channel) => {
|
|
51151
|
+
const absolute = path.resolve(override);
|
|
51152
|
+
if (!existsSync(absolute)) return null;
|
|
51153
|
+
if (statSync(absolute).isDirectory() && absolute.endsWith(".app")) return toLocation(channel, absolute);
|
|
51154
|
+
return {
|
|
51155
|
+
channel,
|
|
51156
|
+
executablePath: absolute,
|
|
51157
|
+
installPath: path.dirname(absolute)
|
|
51158
|
+
};
|
|
51159
|
+
};
|
|
51160
|
+
/**
|
|
51161
|
+
* Scheme the installed build answers to — a nightly and a stable install
|
|
51162
|
+
* coexist on one machine, and each handoff has to address its own.
|
|
51163
|
+
*/
|
|
51164
|
+
const schemeFor = (location) => location.channel === "stable" ? "lobehub" : `lobehub-${location.channel}`;
|
|
51165
|
+
/**
|
|
51166
|
+
* Start the app detached and return as soon as it is running.
|
|
51167
|
+
*
|
|
51168
|
+
* NOT `--wait`: unlike an editor, the app is the session — blocking the shell
|
|
51169
|
+
* until the user quits would leave every terminal that ran `lh app` hanging.
|
|
51170
|
+
*/
|
|
51171
|
+
const launchDesktopApp = (location, args) => new Promise((resolve, reject) => {
|
|
51172
|
+
const child = spawn(location.executablePath, args, {
|
|
51173
|
+
detached: true,
|
|
51174
|
+
stdio: "ignore"
|
|
51175
|
+
});
|
|
51176
|
+
child.once("error", reject);
|
|
51177
|
+
child.once("spawn", () => {
|
|
51178
|
+
child.unref();
|
|
51179
|
+
resolve();
|
|
51180
|
+
});
|
|
51181
|
+
});
|
|
51182
|
+
/** Where the shim goes: next to the running `lh`, else `~/.local/bin`. */
|
|
51183
|
+
const resolveShimDirectory = (env = process.env) => {
|
|
51184
|
+
const cliDir = env.LOBE_CLI_SHIM_DIR;
|
|
51185
|
+
if (cliDir) return path.resolve(cliDir);
|
|
51186
|
+
return path.join(os.homedir(), ".local", "bin");
|
|
51187
|
+
};
|
|
51188
|
+
const resolveShimPath = (env = process.env) => path.join(resolveShimDirectory(env), CLI_SHIM_NAME);
|
|
51189
|
+
/**
|
|
51190
|
+
* Write a one-line `lobehub` launcher.
|
|
51191
|
+
*
|
|
51192
|
+
* It execs the bundle's executable instead of symlinking to it: a symlink
|
|
51193
|
+
* pins whatever channel happened to be installed at the time, so switching
|
|
51194
|
+
* from nightly to stable would silently keep launching the old build.
|
|
51195
|
+
*/
|
|
51196
|
+
const installShim = (location, env = process.env) => {
|
|
51197
|
+
const shimPath = resolveShimPath(env);
|
|
51198
|
+
mkdirSync(path.dirname(shimPath), { recursive: true });
|
|
51199
|
+
if (existsSync(shimPath)) {
|
|
51200
|
+
const existing = readFileSafe(shimPath);
|
|
51201
|
+
if (existing !== null && !existing.includes(SHIM_MARKER)) return {
|
|
51202
|
+
path: shimPath,
|
|
51203
|
+
written: false
|
|
51204
|
+
};
|
|
51205
|
+
}
|
|
51206
|
+
writeFileSync(shimPath, [
|
|
51207
|
+
"#!/bin/sh",
|
|
51208
|
+
SHIM_MARKER,
|
|
51209
|
+
`exec "${location.executablePath}" "$@"`,
|
|
51210
|
+
""
|
|
51211
|
+
].join("\n"), "utf8");
|
|
51212
|
+
chmodSync(shimPath, 493);
|
|
51213
|
+
return {
|
|
51214
|
+
path: shimPath,
|
|
51215
|
+
written: true
|
|
51216
|
+
};
|
|
51217
|
+
};
|
|
51218
|
+
const uninstallShim = (env = process.env) => {
|
|
51219
|
+
const shimPath = resolveShimPath(env);
|
|
51220
|
+
if (!existsSync(shimPath)) return false;
|
|
51221
|
+
const existing = readFileSafe(shimPath);
|
|
51222
|
+
if (existing === null || !existing.includes(SHIM_MARKER)) return false;
|
|
51223
|
+
rmSync(shimPath);
|
|
51224
|
+
return true;
|
|
51225
|
+
};
|
|
51226
|
+
const readFileSafe = (filePath) => {
|
|
51227
|
+
try {
|
|
51228
|
+
return readFileSync(filePath, "utf8");
|
|
51229
|
+
} catch {
|
|
51230
|
+
return null;
|
|
51231
|
+
}
|
|
51232
|
+
};
|
|
51233
|
+
|
|
51234
|
+
//#endregion
|
|
51235
|
+
//#region src/commands/app.ts
|
|
51236
|
+
/**
|
|
51237
|
+
* Canonicalize the directory a launch should open.
|
|
51238
|
+
*
|
|
51239
|
+
* Resolving here, in the invoking shell's process, is what makes the feature
|
|
51240
|
+
* work at all: the app itself may be started by launchd with `/` as its
|
|
51241
|
+
* working directory, so a relative `.` would mean nothing by the time it is
|
|
51242
|
+
* read on the other side.
|
|
51243
|
+
*/
|
|
51244
|
+
const resolveLaunchDirectory = (input = ".") => {
|
|
51245
|
+
const absolute = path.resolve(input);
|
|
51246
|
+
if (!existsSync(absolute)) return null;
|
|
51247
|
+
if (!statSync(absolute).isDirectory()) return null;
|
|
51248
|
+
try {
|
|
51249
|
+
return realpathSync(absolute);
|
|
51250
|
+
} catch {
|
|
51251
|
+
return null;
|
|
51252
|
+
}
|
|
51253
|
+
};
|
|
51254
|
+
const describeMissingApp = (channel) => {
|
|
51255
|
+
return [
|
|
51256
|
+
`No ${channel ? `${channel} channel of ` : ""}LobeHub Desktop installation was found.`,
|
|
51257
|
+
"",
|
|
51258
|
+
" Install the desktop app, or point at a build explicitly:",
|
|
51259
|
+
` ${import_picocolors.default.bold("LOBEHUB_DESKTOP_PATH=/path/to/LobeHub.app")} lh app .`,
|
|
51260
|
+
"",
|
|
51261
|
+
` Check what is installed: ${import_picocolors.default.bold("lh app --scheme")}`
|
|
51262
|
+
].join("\n");
|
|
51263
|
+
};
|
|
51264
|
+
const runInstallCli = (location, options) => {
|
|
51265
|
+
const result = installShim(location);
|
|
51266
|
+
if (options.json !== void 0) return outputJson({
|
|
51267
|
+
...result,
|
|
51268
|
+
executablePath: location.executablePath
|
|
51269
|
+
}, options.json);
|
|
51270
|
+
if (!result.written) {
|
|
51271
|
+
log$15.error(`Refusing to overwrite ${result.path} — it was not written by LobeHub.`);
|
|
51272
|
+
process.exitCode = 1;
|
|
51273
|
+
return;
|
|
51274
|
+
}
|
|
51275
|
+
console.log(`Installed ${import_picocolors.default.bold(result.path)} → ${import_picocolors.default.dim(location.executablePath)}`);
|
|
51276
|
+
console.log(`\nNow run ${import_picocolors.default.bold("lobehub .")} to open a directory.`);
|
|
51277
|
+
if (!(process.env.PATH ?? "").split(path.delimiter).includes(path.dirname(result.path))) console.log(import_picocolors.default.yellow(`\n Note: ${path.dirname(result.path)} is not on your PATH.`), `\n Add it in your shell profile to use the command from anywhere.`);
|
|
51278
|
+
};
|
|
51279
|
+
function registerAppCommand(program) {
|
|
51280
|
+
program.command("app [path]").description("Open a directory in LobeHub Desktop (like `code .`)").option("-n, --new-window", "Start a new conversation instead of revealing the existing one").option("--channel <channel>", "Which installed build to use (stable, beta, nightly)").option("--scheme", "Print the deep-link scheme of the installed build").option("--install-cli", "Install the `lobehub` shell command").option("--uninstall-cli", "Remove the `lobehub` shell command").option("--dry-run", "Print what would be launched without starting it").option("--json [fields]", "Output JSON").action(async (pathArg, options) => {
|
|
51281
|
+
const channel = options.channel && isDesktopChannel(options.channel) ? options.channel : void 0;
|
|
51282
|
+
if (options.channel && !channel) {
|
|
51283
|
+
log$15.error(`Unknown channel "${options.channel}". Use stable, beta, or nightly.`);
|
|
51284
|
+
process.exitCode = 1;
|
|
51285
|
+
return;
|
|
51286
|
+
}
|
|
51287
|
+
if (options.uninstallCli) {
|
|
51288
|
+
const removed = uninstallShim();
|
|
51289
|
+
if (options.json !== void 0) return outputJson({ removed }, options.json);
|
|
51290
|
+
console.log(removed ? "Removed the `lobehub` command." : "No `lobehub` command to remove.");
|
|
51291
|
+
return;
|
|
51292
|
+
}
|
|
51293
|
+
const location = resolveDesktopApp(channel);
|
|
51294
|
+
if (!location) {
|
|
51295
|
+
log$15.error(describeMissingApp(channel));
|
|
51296
|
+
process.exitCode = 1;
|
|
51297
|
+
return;
|
|
51298
|
+
}
|
|
51299
|
+
if (options.installCli) return runInstallCli(location, options);
|
|
51300
|
+
if (options.scheme) {
|
|
51301
|
+
if (options.json !== void 0) return outputJson({
|
|
51302
|
+
channel: location.channel,
|
|
51303
|
+
executablePath: location.executablePath,
|
|
51304
|
+
scheme: schemeFor(location)
|
|
51305
|
+
}, options.json);
|
|
51306
|
+
console.log(schemeFor(location));
|
|
51307
|
+
return;
|
|
51308
|
+
}
|
|
51309
|
+
const target = pathArg ?? ".";
|
|
51310
|
+
const directory = resolveLaunchDirectory(target);
|
|
51311
|
+
if (!directory) {
|
|
51312
|
+
log$15.error(`Not a directory: ${target}`);
|
|
51313
|
+
process.exitCode = 1;
|
|
51314
|
+
return;
|
|
51315
|
+
}
|
|
51316
|
+
const args = [directory];
|
|
51317
|
+
if (options.newWindow) args.push("--new-window");
|
|
51318
|
+
if (options.dryRun) {
|
|
51319
|
+
if (options.json !== void 0) return outputJson({
|
|
51320
|
+
args,
|
|
51321
|
+
channel: location.channel,
|
|
51322
|
+
executablePath: location.executablePath
|
|
51323
|
+
}, options.json);
|
|
51324
|
+
console.log(`${location.executablePath} ${args.join(" ")}`);
|
|
51325
|
+
return;
|
|
51326
|
+
}
|
|
51327
|
+
await launchDesktopApp(location, args);
|
|
51328
|
+
if (options.json !== void 0) return outputJson({
|
|
51329
|
+
channel: location.channel,
|
|
51330
|
+
opened: directory
|
|
51331
|
+
}, options.json);
|
|
51332
|
+
log$15.info(`Opened ${import_picocolors.default.bold(directory)} in LobeHub Desktop`);
|
|
51333
|
+
});
|
|
51334
|
+
}
|
|
51335
|
+
|
|
51042
51336
|
//#endregion
|
|
51043
51337
|
//#region src/commands/artboardComments.ts
|
|
51044
51338
|
const runAgentId = () => {
|
|
@@ -333910,7 +334204,7 @@ var stdio_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
333910
334204
|
function getDefaultEnvironment() {
|
|
333911
334205
|
const env = {};
|
|
333912
334206
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
333913
|
-
const value =
|
|
334207
|
+
const value = process$1.env[key];
|
|
333914
334208
|
if (value === void 0) continue;
|
|
333915
334209
|
if (value.startsWith("()")) continue;
|
|
333916
334210
|
env[key] = value;
|
|
@@ -333921,7 +334215,7 @@ var import_cross_spawn$1, DEFAULT_INHERITED_ENV_VARS, StdioClientTransport;
|
|
|
333921
334215
|
var init_stdio = __esmMin((() => {
|
|
333922
334216
|
init_src_CeKsbNLO();
|
|
333923
334217
|
import_cross_spawn$1 = /* @__PURE__ */ __toESM$2(require_cross_spawn(), 1);
|
|
333924
|
-
DEFAULT_INHERITED_ENV_VARS =
|
|
334218
|
+
DEFAULT_INHERITED_ENV_VARS = process$1.platform === "win32" ? [
|
|
333925
334219
|
"APPDATA",
|
|
333926
334220
|
"COMSPEC",
|
|
333927
334221
|
"HOMEDRIVE",
|
|
@@ -333978,7 +334272,7 @@ var init_stdio = __esmMin((() => {
|
|
|
333978
334272
|
this._serverParams.stderr ?? "inherit"
|
|
333979
334273
|
],
|
|
333980
334274
|
shell: false,
|
|
333981
|
-
windowsHide:
|
|
334275
|
+
windowsHide: process$1.platform === "win32",
|
|
333982
334276
|
cwd: this._serverParams.cwd
|
|
333983
334277
|
});
|
|
333984
334278
|
this._process.on("error", (error) => {
|
|
@@ -337012,9 +337306,9 @@ const getSubprocessResult = ({ stdout }) => {
|
|
|
337012
337306
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/standard-stream.js
|
|
337013
337307
|
const isStandardStream = (stream) => STANDARD_STREAMS.includes(stream);
|
|
337014
337308
|
const STANDARD_STREAMS = [
|
|
337015
|
-
|
|
337016
|
-
|
|
337017
|
-
|
|
337309
|
+
process$1.stdin,
|
|
337310
|
+
process$1.stdout,
|
|
337311
|
+
process$1.stderr
|
|
337018
337312
|
];
|
|
337019
337313
|
const STANDARD_STREAMS_ALIASES = [
|
|
337020
337314
|
"stdin",
|
|
@@ -337139,9 +337433,9 @@ const NO_ESCAPE_REGEXP = /^[\w./-]+$/;
|
|
|
337139
337433
|
//#endregion
|
|
337140
337434
|
//#region node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
|
|
337141
337435
|
function isUnicodeSupported() {
|
|
337142
|
-
const { env } =
|
|
337436
|
+
const { env } = process$1;
|
|
337143
337437
|
const { TERM, TERM_PROGRAM } = env;
|
|
337144
|
-
if (
|
|
337438
|
+
if (process$1.platform !== "win32") return TERM !== "linux";
|
|
337145
337439
|
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
337146
337440
|
}
|
|
337147
337441
|
|
|
@@ -337676,7 +337970,7 @@ function traversePathUp(startPath) {
|
|
|
337676
337970
|
|
|
337677
337971
|
//#endregion
|
|
337678
337972
|
//#region node_modules/.pnpm/npm-run-path@6.0.0/node_modules/npm-run-path/index.js
|
|
337679
|
-
const npmRunPath = ({ cwd =
|
|
337973
|
+
const npmRunPath = ({ cwd = process$1.cwd(), path: pathOption = process$1.env[pathKey()], preferLocal = true, execPath = process$1.execPath, addExecPath = true } = {}) => {
|
|
337680
337974
|
const cwdPath = path.resolve(toPath(cwd));
|
|
337681
337975
|
const result = [];
|
|
337682
337976
|
const pathParts = pathOption.split(path.delimiter);
|
|
@@ -337694,7 +337988,7 @@ const applyExecPath = (result, pathParts, execPath, cwdPath) => {
|
|
|
337694
337988
|
const pathPart = path.resolve(cwdPath, toPath(execPath), "..");
|
|
337695
337989
|
if (!pathParts.includes(pathPart)) result.push(pathPart);
|
|
337696
337990
|
};
|
|
337697
|
-
const npmRunPathEnv = ({ env =
|
|
337991
|
+
const npmRunPathEnv = ({ env = process$1.env, ...options } = {}) => {
|
|
337698
337992
|
env = { ...env };
|
|
337699
337993
|
const pathName = pathKey({ env });
|
|
337700
337994
|
options.path = env[pathName];
|
|
@@ -338829,7 +339123,7 @@ const normalizeCwd = (cwd = getDefaultCwd()) => {
|
|
|
338829
339123
|
};
|
|
338830
339124
|
const getDefaultCwd = () => {
|
|
338831
339125
|
try {
|
|
338832
|
-
return
|
|
339126
|
+
return process$1.cwd();
|
|
338833
339127
|
} catch (error) {
|
|
338834
339128
|
error.message = `The current directory does not exist.\n${error.message}`;
|
|
338835
339129
|
throw error;
|
|
@@ -338865,7 +339159,7 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
338865
339159
|
options.killSignal = normalizeKillSignal(options.killSignal);
|
|
338866
339160
|
options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);
|
|
338867
339161
|
options.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);
|
|
338868
|
-
if (
|
|
339162
|
+
if (process$1.platform === "win32" && path.basename(file, ".exe") === "cmd") commandArguments.unshift("/q");
|
|
338869
339163
|
return {
|
|
338870
339164
|
file,
|
|
338871
339165
|
commandArguments,
|
|
@@ -338892,7 +339186,7 @@ const addDefaultOptions = ({ extendEnv = true, preferLocal = false, cwd, localDi
|
|
|
338892
339186
|
});
|
|
338893
339187
|
const getEnv = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath }) => {
|
|
338894
339188
|
const env = extendEnv ? {
|
|
338895
|
-
...
|
|
339189
|
+
...process$1.env,
|
|
338896
339190
|
...envOption
|
|
338897
339191
|
} : envOption;
|
|
338898
339192
|
if (preferLocal || node) return npmRunPathEnv({
|
|
@@ -339894,12 +340188,12 @@ const guessStreamDirection = {
|
|
|
339894
340188
|
}
|
|
339895
340189
|
};
|
|
339896
340190
|
const getStandardStreamDirection = (value) => {
|
|
339897
|
-
if ([0,
|
|
340191
|
+
if ([0, process$1.stdin].includes(value)) return "input";
|
|
339898
340192
|
if ([
|
|
339899
340193
|
1,
|
|
339900
340194
|
2,
|
|
339901
|
-
|
|
339902
|
-
|
|
340195
|
+
process$1.stdout,
|
|
340196
|
+
process$1.stderr
|
|
339903
340197
|
].includes(value)) return "output";
|
|
339904
340198
|
};
|
|
339905
340199
|
const DEFAULT_DIRECTION = "output";
|
|
@@ -340963,9 +341257,9 @@ const addIpcMethods = (subprocess, { ipc }) => {
|
|
|
340963
341257
|
Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
|
|
340964
341258
|
};
|
|
340965
341259
|
const getIpcExport = () => {
|
|
340966
|
-
const anyProcess =
|
|
341260
|
+
const anyProcess = process$1;
|
|
340967
341261
|
const isSubprocess = true;
|
|
340968
|
-
const ipc =
|
|
341262
|
+
const ipc = process$1.channel !== void 0;
|
|
340969
341263
|
return {
|
|
340970
341264
|
...getIpcMethods(anyProcess, isSubprocess, ipc),
|
|
340971
341265
|
getCancelSignal: getCancelSignal$1.bind(void 0, {
|
|
@@ -341442,7 +341736,7 @@ var SignalExitFallback = class extends SignalExitBase {
|
|
|
341442
341736
|
};
|
|
341443
341737
|
var SignalExit = class extends SignalExitBase {
|
|
341444
341738
|
/* c8 ignore start */
|
|
341445
|
-
#hupSig = process$
|
|
341739
|
+
#hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
341446
341740
|
/* c8 ignore stop */
|
|
341447
341741
|
#emitter = new Emitter();
|
|
341448
341742
|
#process;
|
|
@@ -341537,8 +341831,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
341537
341831
|
} else return og.call(this.#process, ev, ...args);
|
|
341538
341832
|
}
|
|
341539
341833
|
};
|
|
341540
|
-
const process$
|
|
341541
|
-
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$
|
|
341834
|
+
const process$2 = globalThis.process;
|
|
341835
|
+
const { onExit, load: load$1, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
|
|
341542
341836
|
|
|
341543
341837
|
//#endregion
|
|
341544
341838
|
//#region node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/terminate/cleanup.js
|
|
@@ -593774,6 +594068,7 @@ function createProgram() {
|
|
|
593774
594068
|
registerAgentCommand(program);
|
|
593775
594069
|
registerAgentGroupCommand(program);
|
|
593776
594070
|
registerAgentSignalCommand(program);
|
|
594071
|
+
registerAppCommand(program);
|
|
593777
594072
|
registerBotCommand(program);
|
|
593778
594073
|
registerArtboardCommand(program);
|
|
593779
594074
|
registerChannelCommand(program);
|
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.154" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
|
@@ -89,6 +89,9 @@ Manage agent groups
|
|
|
89
89
|
.B agent\-signal
|
|
90
90
|
Inspect and trigger Agent Signal source events
|
|
91
91
|
.TP
|
|
92
|
+
.B app
|
|
93
|
+
Open a directory in LobeHub Desktop (like `code .`)
|
|
94
|
+
.TP
|
|
92
95
|
.B bot
|
|
93
96
|
Manage bot integrations
|
|
94
97
|
.TP
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.154",
|
|
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": "861773018cf365ba16d0e179b2d944eb01d0f430"
|
|
87
87
|
}
|