soulhubcli 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +177 -114
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13284,6 +13284,7 @@ var import_node_fs8 = __toESM(require("fs"), 1);
|
|
|
13284
13284
|
var import_node_path11 = __toESM(require("path"), 1);
|
|
13285
13285
|
var import_node_os2 = __toESM(require("os"), 1);
|
|
13286
13286
|
var import_node_child_process = require("child_process");
|
|
13287
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
13287
13288
|
|
|
13288
13289
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
13289
13290
|
function isNothing(subject) {
|
|
@@ -19038,7 +19039,7 @@ function findOpenClawDir(customDir) {
|
|
|
19038
19039
|
}
|
|
19039
19040
|
return resolved;
|
|
19040
19041
|
}
|
|
19041
|
-
const envHome = process.env.OPENCLAW_HOME;
|
|
19042
|
+
const envHome = process.env.OPENCLAW_HOME || process.env.LIGHTCLAW_HOME;
|
|
19042
19043
|
if (envHome) {
|
|
19043
19044
|
const resolved = import_node_path11.default.resolve(envHome);
|
|
19044
19045
|
if (import_node_fs8.default.existsSync(resolved)) {
|
|
@@ -19046,9 +19047,12 @@ function findOpenClawDir(customDir) {
|
|
|
19046
19047
|
}
|
|
19047
19048
|
return resolved;
|
|
19048
19049
|
}
|
|
19050
|
+
const home = process.env.HOME || "~";
|
|
19049
19051
|
const candidates = [
|
|
19050
|
-
import_node_path11.default.join(
|
|
19051
|
-
import_node_path11.default.join(
|
|
19052
|
+
import_node_path11.default.join(home, ".openclaw"),
|
|
19053
|
+
import_node_path11.default.join(home, ".lightclaw"),
|
|
19054
|
+
import_node_path11.default.join(process.cwd(), ".openclaw"),
|
|
19055
|
+
import_node_path11.default.join(process.cwd(), ".lightclaw")
|
|
19052
19056
|
];
|
|
19053
19057
|
for (const candidate of candidates) {
|
|
19054
19058
|
if (import_node_fs8.default.existsSync(candidate)) {
|
|
@@ -19057,6 +19061,58 @@ function findOpenClawDir(customDir) {
|
|
|
19057
19061
|
}
|
|
19058
19062
|
return null;
|
|
19059
19063
|
}
|
|
19064
|
+
function findAllClawDirs(customDir) {
|
|
19065
|
+
if (customDir) {
|
|
19066
|
+
const resolved = import_node_path11.default.resolve(customDir);
|
|
19067
|
+
return import_node_fs8.default.existsSync(resolved) ? [resolved] : [resolved];
|
|
19068
|
+
}
|
|
19069
|
+
const envHome = process.env.OPENCLAW_HOME || process.env.LIGHTCLAW_HOME;
|
|
19070
|
+
if (envHome) {
|
|
19071
|
+
const resolved = import_node_path11.default.resolve(envHome);
|
|
19072
|
+
return [resolved];
|
|
19073
|
+
}
|
|
19074
|
+
const home = process.env.HOME || "~";
|
|
19075
|
+
const candidates = [
|
|
19076
|
+
import_node_path11.default.join(home, ".openclaw"),
|
|
19077
|
+
import_node_path11.default.join(home, ".lightclaw"),
|
|
19078
|
+
import_node_path11.default.join(process.cwd(), ".openclaw"),
|
|
19079
|
+
import_node_path11.default.join(process.cwd(), ".lightclaw")
|
|
19080
|
+
];
|
|
19081
|
+
return candidates.filter((c) => import_node_fs8.default.existsSync(c));
|
|
19082
|
+
}
|
|
19083
|
+
async function promptSelectClawDir(customDir) {
|
|
19084
|
+
const dirs = findAllClawDirs(customDir);
|
|
19085
|
+
if (dirs.length === 0) {
|
|
19086
|
+
return null;
|
|
19087
|
+
}
|
|
19088
|
+
if (dirs.length === 1) {
|
|
19089
|
+
return dirs[0];
|
|
19090
|
+
}
|
|
19091
|
+
console.log();
|
|
19092
|
+
console.log(" Detected multiple Claw installations:");
|
|
19093
|
+
console.log();
|
|
19094
|
+
dirs.forEach((dir, index) => {
|
|
19095
|
+
const brand = detectClawBrand(dir);
|
|
19096
|
+
console.log(` ${index + 1}) ${brand} ${dir}`);
|
|
19097
|
+
});
|
|
19098
|
+
console.log();
|
|
19099
|
+
const rl = import_node_readline.default.createInterface({
|
|
19100
|
+
input: process.stdin,
|
|
19101
|
+
output: process.stdout
|
|
19102
|
+
});
|
|
19103
|
+
return new Promise((resolve) => {
|
|
19104
|
+
rl.question(` Please select target (1-${dirs.length}): `, (answer) => {
|
|
19105
|
+
rl.close();
|
|
19106
|
+
const idx = parseInt(answer.trim(), 10);
|
|
19107
|
+
if (idx >= 1 && idx <= dirs.length) {
|
|
19108
|
+
resolve(dirs[idx - 1]);
|
|
19109
|
+
} else {
|
|
19110
|
+
console.log(" Invalid selection, operation cancelled.");
|
|
19111
|
+
resolve(null);
|
|
19112
|
+
}
|
|
19113
|
+
});
|
|
19114
|
+
});
|
|
19115
|
+
}
|
|
19060
19116
|
function getConfigPath() {
|
|
19061
19117
|
const home = process.env.HOME || "~";
|
|
19062
19118
|
return import_node_path11.default.join(home, ".soulhub", "config.json");
|
|
@@ -19111,8 +19167,22 @@ function checkMainAgentExists(clawDir) {
|
|
|
19111
19167
|
workspaceDir
|
|
19112
19168
|
};
|
|
19113
19169
|
}
|
|
19170
|
+
function detectClawBrand(clawDir) {
|
|
19171
|
+
const dirName = import_node_path11.default.basename(clawDir).toLowerCase();
|
|
19172
|
+
if (dirName.includes("lightclaw")) {
|
|
19173
|
+
return "LightClaw";
|
|
19174
|
+
}
|
|
19175
|
+
if (import_node_fs8.default.existsSync(import_node_path11.default.join(clawDir, "lightclaw.json"))) {
|
|
19176
|
+
return "LightClaw";
|
|
19177
|
+
}
|
|
19178
|
+
return "OpenClaw";
|
|
19179
|
+
}
|
|
19180
|
+
function getClawConfigFileName(clawDir) {
|
|
19181
|
+
const brand = detectClawBrand(clawDir);
|
|
19182
|
+
return brand === "LightClaw" ? "lightclaw.json" : "openclaw.json";
|
|
19183
|
+
}
|
|
19114
19184
|
function getOpenClawConfigPath(clawDir) {
|
|
19115
|
-
return import_node_path11.default.join(clawDir,
|
|
19185
|
+
return import_node_path11.default.join(clawDir, getClawConfigFileName(clawDir));
|
|
19116
19186
|
}
|
|
19117
19187
|
function readOpenClawConfig(clawDir) {
|
|
19118
19188
|
const configPath = getOpenClawConfigPath(clawDir);
|
|
@@ -19208,32 +19278,6 @@ function detectPackageKind(dir) {
|
|
|
19208
19278
|
}
|
|
19209
19279
|
return "unknown";
|
|
19210
19280
|
}
|
|
19211
|
-
function checkOpenClawInstalled(customDir) {
|
|
19212
|
-
const clawDir = findOpenClawDir(customDir);
|
|
19213
|
-
if (clawDir) {
|
|
19214
|
-
return {
|
|
19215
|
-
installed: true,
|
|
19216
|
-
clawDir,
|
|
19217
|
-
message: `OpenClaw detected at: ${clawDir}`
|
|
19218
|
-
};
|
|
19219
|
-
}
|
|
19220
|
-
try {
|
|
19221
|
-
(0, import_node_child_process.execSync)("which openclaw 2>/dev/null || where openclaw 2>nul", {
|
|
19222
|
-
stdio: "pipe"
|
|
19223
|
-
});
|
|
19224
|
-
return {
|
|
19225
|
-
installed: true,
|
|
19226
|
-
clawDir: null,
|
|
19227
|
-
message: "OpenClaw command found in PATH, but workspace directory not detected."
|
|
19228
|
-
};
|
|
19229
|
-
} catch {
|
|
19230
|
-
}
|
|
19231
|
-
return {
|
|
19232
|
-
installed: false,
|
|
19233
|
-
clawDir: null,
|
|
19234
|
-
message: "OpenClaw is not installed. Please install OpenClaw first, use --claw-dir to specify OpenClaw directory, or set OPENCLAW_HOME environment variable."
|
|
19235
|
-
};
|
|
19236
|
-
}
|
|
19237
19281
|
function backupAgentWorkspace(workspaceDir) {
|
|
19238
19282
|
if (!import_node_fs8.default.existsSync(workspaceDir)) {
|
|
19239
19283
|
return null;
|
|
@@ -19333,7 +19377,7 @@ function generateBackupId() {
|
|
|
19333
19377
|
}
|
|
19334
19378
|
function createBackupRecord(installType, packageName, clawDir) {
|
|
19335
19379
|
let openclawJsonSnapshot = null;
|
|
19336
|
-
const configPath =
|
|
19380
|
+
const configPath = getOpenClawConfigPath(clawDir);
|
|
19337
19381
|
if (import_node_fs8.default.existsSync(configPath)) {
|
|
19338
19382
|
try {
|
|
19339
19383
|
openclawJsonSnapshot = import_node_fs8.default.readFileSync(configPath, "utf-8");
|
|
@@ -19375,30 +19419,31 @@ var CATEGORY_LABELS = {
|
|
|
19375
19419
|
};
|
|
19376
19420
|
function registerAgentToOpenClaw(agentName, workspaceDir, _clawDir) {
|
|
19377
19421
|
const agentId = agentName.toLowerCase().replace(/[\s_]+/g, "-");
|
|
19378
|
-
logger.debug(`Registering agent to OpenClaw`, { agentId, workspaceDir });
|
|
19422
|
+
logger.debug(`Registering agent to OpenClaw/LightClaw`, { agentId, workspaceDir });
|
|
19379
19423
|
try {
|
|
19424
|
+
const clawCmd = detectClawCommand();
|
|
19380
19425
|
(0, import_node_child_process.execSync)(
|
|
19381
|
-
|
|
19426
|
+
`${clawCmd} agents add "${agentId}" --workspace "${workspaceDir}" --non-interactive --json`,
|
|
19382
19427
|
{ stdio: "pipe", timeout: 15e3 }
|
|
19383
19428
|
);
|
|
19384
19429
|
return {
|
|
19385
19430
|
success: true,
|
|
19386
|
-
message: `Agent "${agentId}" registered via
|
|
19431
|
+
message: `Agent "${agentId}" registered via CLI.`
|
|
19387
19432
|
};
|
|
19388
19433
|
} catch (cliError) {
|
|
19389
19434
|
const stderr = cliError && typeof cliError === "object" && "stderr" in cliError ? String(cliError.stderr) : "";
|
|
19390
19435
|
if (stderr.includes("already exists")) {
|
|
19391
19436
|
return {
|
|
19392
19437
|
success: true,
|
|
19393
|
-
message: `Agent "${agentId}" already registered
|
|
19438
|
+
message: `Agent "${agentId}" already registered.`
|
|
19394
19439
|
};
|
|
19395
19440
|
}
|
|
19396
19441
|
const isCommandNotFound = cliError && typeof cliError === "object" && "code" in cliError && cliError.code === "ENOENT" || stderr.includes("not found") || stderr.includes("not recognized");
|
|
19397
19442
|
if (isCommandNotFound) {
|
|
19398
|
-
logger.error(`OpenClaw CLI not found`);
|
|
19443
|
+
logger.error(`OpenClaw/LightClaw CLI not found`);
|
|
19399
19444
|
return {
|
|
19400
19445
|
success: false,
|
|
19401
|
-
message: "OpenClaw CLI not found. Please install
|
|
19446
|
+
message: "OpenClaw/LightClaw CLI not found. Please install first."
|
|
19402
19447
|
};
|
|
19403
19448
|
}
|
|
19404
19449
|
const errMsg = cliError instanceof Error ? cliError.message : String(cliError);
|
|
@@ -19409,17 +19454,31 @@ function registerAgentToOpenClaw(agentName, workspaceDir, _clawDir) {
|
|
|
19409
19454
|
};
|
|
19410
19455
|
}
|
|
19411
19456
|
}
|
|
19457
|
+
function detectClawCommand() {
|
|
19458
|
+
try {
|
|
19459
|
+
(0, import_node_child_process.execSync)("which lightclaw 2>/dev/null || where lightclaw 2>nul", { stdio: "pipe" });
|
|
19460
|
+
return "lightclaw";
|
|
19461
|
+
} catch {
|
|
19462
|
+
}
|
|
19463
|
+
try {
|
|
19464
|
+
(0, import_node_child_process.execSync)("which openclaw 2>/dev/null || where openclaw 2>nul", { stdio: "pipe" });
|
|
19465
|
+
return "openclaw";
|
|
19466
|
+
} catch {
|
|
19467
|
+
}
|
|
19468
|
+
return "openclaw";
|
|
19469
|
+
}
|
|
19412
19470
|
function restartOpenClawGateway() {
|
|
19413
|
-
|
|
19471
|
+
const clawCmd = detectClawCommand();
|
|
19472
|
+
logger.debug(`Restarting ${clawCmd} Gateway`);
|
|
19414
19473
|
try {
|
|
19415
|
-
(0, import_node_child_process.execSync)(
|
|
19474
|
+
(0, import_node_child_process.execSync)(`${clawCmd} gateway restart`, {
|
|
19416
19475
|
stdio: "pipe",
|
|
19417
19476
|
timeout: 3e4
|
|
19418
19477
|
// 30 秒超时
|
|
19419
19478
|
});
|
|
19420
19479
|
return {
|
|
19421
19480
|
success: true,
|
|
19422
|
-
message:
|
|
19481
|
+
message: `${clawCmd} Gateway restarted successfully.`
|
|
19423
19482
|
};
|
|
19424
19483
|
} catch (error) {
|
|
19425
19484
|
const stderr = error && typeof error === "object" && "stderr" in error ? String(error.stderr).trim() : "";
|
|
@@ -19659,12 +19718,18 @@ function createSpinner(initialText = "") {
|
|
|
19659
19718
|
// src/commands/install.ts
|
|
19660
19719
|
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
19661
19720
|
var import_node_path12 = __toESM(require("path"), 1);
|
|
19721
|
+
async function resolveClawDir(clawDir) {
|
|
19722
|
+
if (clawDir) {
|
|
19723
|
+
return findOpenClawDir(clawDir);
|
|
19724
|
+
}
|
|
19725
|
+
return promptSelectClawDir();
|
|
19726
|
+
}
|
|
19662
19727
|
var installCommand = new Command("install").description("Install an agent or team from the SoulHub registry").argument("[name]", "Agent or team name to install").option("--from <source>", "Install from a local directory, ZIP file, or URL").option(
|
|
19663
19728
|
"--dir <path>",
|
|
19664
|
-
"Target directory (defaults to OpenClaw workspace)"
|
|
19729
|
+
"Target directory (defaults to OpenClaw/LightClaw workspace)"
|
|
19665
19730
|
).option(
|
|
19666
19731
|
"--claw-dir <path>",
|
|
19667
|
-
"OpenClaw installation directory (overrides OPENCLAW_HOME env var, defaults to ~/.openclaw)"
|
|
19732
|
+
"OpenClaw/LightClaw installation directory (overrides OPENCLAW_HOME/LIGHTCLAW_HOME env var, defaults to ~/.openclaw or ~/.lightclaw)"
|
|
19668
19733
|
).action(async (name, options) => {
|
|
19669
19734
|
try {
|
|
19670
19735
|
if (options.from) {
|
|
@@ -19709,14 +19774,18 @@ async function installFromRegistry(name, targetDir, clawDir) {
|
|
|
19709
19774
|
}
|
|
19710
19775
|
async function installSingleAgent(name, targetDir, clawDir) {
|
|
19711
19776
|
const spinner = createSpinner(`Checking environment...`).start();
|
|
19777
|
+
let selectedClawDir = null;
|
|
19712
19778
|
if (!targetDir) {
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19779
|
+
spinner.stop();
|
|
19780
|
+
selectedClawDir = await resolveClawDir(clawDir);
|
|
19781
|
+
if (!selectedClawDir) {
|
|
19782
|
+
console.log(source_default.red("OpenClaw/LightClaw workspace directory not found."));
|
|
19716
19783
|
printOpenClawInstallHelp();
|
|
19717
19784
|
return;
|
|
19718
19785
|
}
|
|
19719
|
-
spinner.
|
|
19786
|
+
spinner.start();
|
|
19787
|
+
const brand = detectClawBrand(selectedClawDir);
|
|
19788
|
+
spinner.text = source_default.dim(`${brand} detected: ${selectedClawDir}`);
|
|
19720
19789
|
}
|
|
19721
19790
|
spinner.text = `Fetching agent ${source_default.cyan(name)}...`;
|
|
19722
19791
|
const index = await fetchIndex();
|
|
@@ -19730,18 +19799,11 @@ async function installSingleAgent(name, targetDir, clawDir) {
|
|
|
19730
19799
|
if (targetDir) {
|
|
19731
19800
|
workspaceDir = import_node_path12.default.resolve(targetDir);
|
|
19732
19801
|
} else {
|
|
19733
|
-
|
|
19734
|
-
if (!resolvedClawDir) {
|
|
19735
|
-
spinner.fail("OpenClaw workspace directory not found.");
|
|
19736
|
-
printOpenClawInstallHelp();
|
|
19737
|
-
return;
|
|
19738
|
-
}
|
|
19739
|
-
workspaceDir = getMainWorkspaceDir(resolvedClawDir);
|
|
19802
|
+
workspaceDir = getMainWorkspaceDir(selectedClawDir);
|
|
19740
19803
|
}
|
|
19741
|
-
const
|
|
19742
|
-
const backupRecord = !targetDir ? createBackupRecord("single-agent", name, resolvedClawDirForBackup) : null;
|
|
19804
|
+
const backupRecord = !targetDir ? createBackupRecord("single-agent", name, selectedClawDir) : null;
|
|
19743
19805
|
if (!targetDir) {
|
|
19744
|
-
const mainCheck = checkMainAgentExists(
|
|
19806
|
+
const mainCheck = checkMainAgentExists(selectedClawDir);
|
|
19745
19807
|
if (mainCheck.hasContent) {
|
|
19746
19808
|
spinner.warn(
|
|
19747
19809
|
`Existing main agent detected. Backing up workspace...`
|
|
@@ -19769,9 +19831,8 @@ async function installSingleAgent(name, targetDir, clawDir) {
|
|
|
19769
19831
|
}
|
|
19770
19832
|
if (!targetDir) {
|
|
19771
19833
|
spinner.text = `Registering ${source_default.cyan(agent.displayName)} as main agent...`;
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
spinner.text = source_default.dim(`Main agent registered in openclaw.json`);
|
|
19834
|
+
addAgentToOpenClawConfig(selectedClawDir, "main", name, true);
|
|
19835
|
+
spinner.text = source_default.dim(`Main agent registered in config`);
|
|
19775
19836
|
}
|
|
19776
19837
|
spinner.text = `Downloading ${source_default.cyan(agent.displayName)} package...`;
|
|
19777
19838
|
const pkgDir = await downloadAgentPackage(name, agent.version);
|
|
@@ -19797,19 +19858,19 @@ async function installSingleAgent(name, targetDir, clawDir) {
|
|
|
19797
19858
|
}
|
|
19798
19859
|
async function installRecipeFromRegistry(name, recipe, targetDir, clawDir) {
|
|
19799
19860
|
const spinner = createSpinner(`Installing team ${source_default.cyan(recipe.displayName)}...`).start();
|
|
19800
|
-
|
|
19801
|
-
|
|
19802
|
-
|
|
19803
|
-
|
|
19861
|
+
let resolvedClawDir;
|
|
19862
|
+
if (targetDir) {
|
|
19863
|
+
resolvedClawDir = import_node_path12.default.resolve(targetDir);
|
|
19864
|
+
} else {
|
|
19865
|
+
spinner.stop();
|
|
19866
|
+
const selected = await resolveClawDir(clawDir);
|
|
19867
|
+
if (!selected) {
|
|
19868
|
+
console.log(source_default.red("OpenClaw/LightClaw workspace directory not found."));
|
|
19804
19869
|
printOpenClawInstallHelp();
|
|
19805
19870
|
return;
|
|
19806
19871
|
}
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
if (!resolvedClawDir) {
|
|
19810
|
-
spinner.fail("OpenClaw workspace directory not found.");
|
|
19811
|
-
printOpenClawInstallHelp();
|
|
19812
|
-
return;
|
|
19872
|
+
resolvedClawDir = selected;
|
|
19873
|
+
spinner.start();
|
|
19813
19874
|
}
|
|
19814
19875
|
spinner.text = `Fetching team configuration...`;
|
|
19815
19876
|
let pkg;
|
|
@@ -19957,29 +20018,26 @@ async function installSingleAgentFromDir(packageDir, targetDir, clawDir) {
|
|
|
19957
20018
|
const spinner = createSpinner("Installing single agent...").start();
|
|
19958
20019
|
const pkg = readSoulHubPackage(packageDir);
|
|
19959
20020
|
const agentName = pkg?.name || import_node_path12.default.basename(packageDir);
|
|
20021
|
+
let selectedClawDir = null;
|
|
19960
20022
|
if (!targetDir) {
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
20023
|
+
spinner.stop();
|
|
20024
|
+
selectedClawDir = await resolveClawDir(clawDir);
|
|
20025
|
+
if (!selectedClawDir) {
|
|
20026
|
+
console.log(source_default.red("OpenClaw/LightClaw workspace directory not found."));
|
|
19964
20027
|
printOpenClawInstallHelp();
|
|
19965
20028
|
return;
|
|
19966
20029
|
}
|
|
20030
|
+
spinner.start();
|
|
19967
20031
|
}
|
|
19968
20032
|
let workspaceDir;
|
|
19969
20033
|
if (targetDir) {
|
|
19970
20034
|
workspaceDir = import_node_path12.default.resolve(targetDir);
|
|
19971
20035
|
} else {
|
|
19972
|
-
|
|
19973
|
-
if (!resolvedClawDir) {
|
|
19974
|
-
spinner.fail("OpenClaw workspace directory not found.");
|
|
19975
|
-
return;
|
|
19976
|
-
}
|
|
19977
|
-
workspaceDir = getMainWorkspaceDir(resolvedClawDir);
|
|
20036
|
+
workspaceDir = getMainWorkspaceDir(selectedClawDir);
|
|
19978
20037
|
}
|
|
19979
|
-
const localBackupRecord = !targetDir ? createBackupRecord("single-agent-local", agentName,
|
|
20038
|
+
const localBackupRecord = !targetDir ? createBackupRecord("single-agent-local", agentName, selectedClawDir) : null;
|
|
19980
20039
|
if (!targetDir) {
|
|
19981
|
-
const
|
|
19982
|
-
const mainCheck = checkMainAgentExists(resolvedClawDir);
|
|
20040
|
+
const mainCheck = checkMainAgentExists(selectedClawDir);
|
|
19983
20041
|
if (mainCheck.hasContent) {
|
|
19984
20042
|
spinner.warn("Existing main agent detected. Backing up...");
|
|
19985
20043
|
const backupDir = backupAgentWorkspace(workspaceDir);
|
|
@@ -20000,8 +20058,7 @@ async function installSingleAgentFromDir(packageDir, targetDir, clawDir) {
|
|
|
20000
20058
|
}
|
|
20001
20059
|
if (!targetDir) {
|
|
20002
20060
|
spinner.text = `Registering ${source_default.cyan(agentName)} as main agent...`;
|
|
20003
|
-
|
|
20004
|
-
addAgentToOpenClawConfig(resolvedClawDir, "main", agentName, true);
|
|
20061
|
+
addAgentToOpenClawConfig(selectedClawDir, "main", agentName, true);
|
|
20005
20062
|
}
|
|
20006
20063
|
spinner.text = `Copying soul files...`;
|
|
20007
20064
|
copyAgentFilesFromDir(packageDir, workspaceDir);
|
|
@@ -20028,18 +20085,19 @@ async function installTeamFromDir(packageDir, targetDir, clawDir) {
|
|
|
20028
20085
|
spinner.fail("Invalid team package. Missing soulhub.yaml.");
|
|
20029
20086
|
return;
|
|
20030
20087
|
}
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20088
|
+
let resolvedClawDir;
|
|
20089
|
+
if (targetDir) {
|
|
20090
|
+
resolvedClawDir = import_node_path12.default.resolve(targetDir);
|
|
20091
|
+
} else {
|
|
20092
|
+
spinner.stop();
|
|
20093
|
+
const selected = await resolveClawDir(clawDir);
|
|
20094
|
+
if (!selected) {
|
|
20095
|
+
console.log(source_default.red("OpenClaw/LightClaw workspace directory not found."));
|
|
20035
20096
|
printOpenClawInstallHelp();
|
|
20036
20097
|
return;
|
|
20037
20098
|
}
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
if (!resolvedClawDir) {
|
|
20041
|
-
spinner.fail("OpenClaw workspace directory not found.");
|
|
20042
|
-
return;
|
|
20099
|
+
resolvedClawDir = selected;
|
|
20100
|
+
spinner.start();
|
|
20043
20101
|
}
|
|
20044
20102
|
const teamBackupRecord = !targetDir ? createBackupRecord("team-local", pkg.name, resolvedClawDir) : null;
|
|
20045
20103
|
if (!targetDir) {
|
|
@@ -20199,11 +20257,11 @@ async function extractZipToDir(zip, targetDir) {
|
|
|
20199
20257
|
}
|
|
20200
20258
|
}
|
|
20201
20259
|
function printOpenClawInstallHelp() {
|
|
20202
|
-
console.log(source_default.dim(" Please install OpenClaw first, or use one of the following options:"));
|
|
20203
|
-
console.log(source_default.dim(" --claw-dir <path>
|
|
20204
|
-
console.log(source_default.dim(" --dir <path>
|
|
20205
|
-
console.log(source_default.dim(" OPENCLAW_HOME=<path>
|
|
20206
|
-
console.log(source_default.dim("
|
|
20260
|
+
console.log(source_default.dim(" Please install OpenClaw or LightClaw first, or use one of the following options:"));
|
|
20261
|
+
console.log(source_default.dim(" --claw-dir <path> Specify OpenClaw/LightClaw installation directory"));
|
|
20262
|
+
console.log(source_default.dim(" --dir <path> Specify agent target directory directly"));
|
|
20263
|
+
console.log(source_default.dim(" OPENCLAW_HOME=<path> Set environment variable (for OpenClaw)"));
|
|
20264
|
+
console.log(source_default.dim(" LIGHTCLAW_HOME=<path> Set environment variable (for LightClaw)"));
|
|
20207
20265
|
}
|
|
20208
20266
|
function printTeamSummary(pkg, workerIds) {
|
|
20209
20267
|
console.log();
|
|
@@ -20221,15 +20279,17 @@ function printTeamSummary(pkg, workerIds) {
|
|
|
20221
20279
|
console.log();
|
|
20222
20280
|
}
|
|
20223
20281
|
async function tryRestartGateway() {
|
|
20224
|
-
const
|
|
20282
|
+
const clawCmd = detectClawCommand();
|
|
20283
|
+
const brandName = clawCmd === "lightclaw" ? "LightClaw" : "OpenClaw";
|
|
20284
|
+
const restartSpinner = createSpinner(`Restarting ${brandName} Gateway...`).start();
|
|
20225
20285
|
const result = restartOpenClawGateway();
|
|
20226
20286
|
if (result.success) {
|
|
20227
|
-
restartSpinner.succeed(
|
|
20287
|
+
restartSpinner.succeed(`${brandName} Gateway restarted successfully.`);
|
|
20228
20288
|
} else {
|
|
20229
|
-
restartSpinner.warn(
|
|
20289
|
+
restartSpinner.warn(`Failed to restart ${brandName} Gateway.`);
|
|
20230
20290
|
console.log(source_default.yellow(` Reason: ${result.message}`));
|
|
20231
20291
|
console.log(source_default.dim(" Please restart manually:"));
|
|
20232
|
-
console.log(source_default.dim(
|
|
20292
|
+
console.log(source_default.dim(` ${clawCmd} gateway restart`));
|
|
20233
20293
|
}
|
|
20234
20294
|
}
|
|
20235
20295
|
|
|
@@ -20335,7 +20395,7 @@ var import_node_fs11 = __toESM(require("fs"), 1);
|
|
|
20335
20395
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
20336
20396
|
var rollbackCommand = new Command("rollback").description("Rollback to a previous agent installation state").option("--list", "List available rollback records").option("--id <id>", "Rollback to a specific backup record by ID").option(
|
|
20337
20397
|
"--claw-dir <path>",
|
|
20338
|
-
"OpenClaw installation directory (overrides OPENCLAW_HOME env var)"
|
|
20398
|
+
"OpenClaw/LightClaw installation directory (overrides OPENCLAW_HOME/LIGHTCLAW_HOME env var)"
|
|
20339
20399
|
).action(async (options) => {
|
|
20340
20400
|
try {
|
|
20341
20401
|
if (options.list) {
|
|
@@ -20407,20 +20467,21 @@ async function performRollback(recordId, clawDir) {
|
|
|
20407
20467
|
const spinner = createSpinner(
|
|
20408
20468
|
`Rolling back ${source_default.cyan(record.packageName)}...`
|
|
20409
20469
|
).start();
|
|
20410
|
-
const resolvedClawDir = findOpenClawDir(clawDir) || record.clawDir;
|
|
20470
|
+
const resolvedClawDir = clawDir ? findOpenClawDir(clawDir) || record.clawDir : await promptSelectClawDir() || record.clawDir;
|
|
20411
20471
|
if (!resolvedClawDir || !import_node_fs11.default.existsSync(resolvedClawDir)) {
|
|
20412
|
-
spinner.fail(`OpenClaw directory not found: ${record.clawDir}`);
|
|
20472
|
+
spinner.fail(`OpenClaw/LightClaw directory not found: ${record.clawDir}`);
|
|
20413
20473
|
return;
|
|
20414
20474
|
}
|
|
20475
|
+
const brand = detectClawBrand(resolvedClawDir);
|
|
20415
20476
|
if (record.openclawJsonSnapshot) {
|
|
20416
|
-
spinner.text =
|
|
20477
|
+
spinner.text = `Restoring ${brand.toLowerCase()}.json...`;
|
|
20417
20478
|
try {
|
|
20418
20479
|
const configObj = JSON.parse(record.openclawJsonSnapshot);
|
|
20419
20480
|
writeOpenClawConfig(resolvedClawDir, configObj);
|
|
20420
|
-
logger.info(
|
|
20481
|
+
logger.info(`${brand.toLowerCase()}.json restored from snapshot`, { recordId: record.id });
|
|
20421
20482
|
} catch (err) {
|
|
20422
|
-
logger.error(
|
|
20423
|
-
console.log(source_default.yellow(
|
|
20483
|
+
logger.error(`Failed to restore ${brand.toLowerCase()}.json`, { error: err });
|
|
20484
|
+
console.log(source_default.yellow(` \u26A0 Failed to restore ${brand.toLowerCase()}.json, skipping...`));
|
|
20424
20485
|
}
|
|
20425
20486
|
}
|
|
20426
20487
|
if (record.installedWorkerIds.length > 0) {
|
|
@@ -20483,15 +20544,17 @@ async function performRollback(recordId, clawDir) {
|
|
|
20483
20544
|
spinner.succeed(
|
|
20484
20545
|
`Rolled back ${source_default.cyan.bold(record.packageName)} successfully! (${restoredCount} item(s) restored)`
|
|
20485
20546
|
);
|
|
20486
|
-
const
|
|
20547
|
+
const clawCmd = detectClawCommand();
|
|
20548
|
+
const brandName = clawCmd === "lightclaw" ? "LightClaw" : "OpenClaw";
|
|
20549
|
+
const restartSpinner = createSpinner(`Restarting ${brandName} Gateway...`).start();
|
|
20487
20550
|
const result = restartOpenClawGateway();
|
|
20488
20551
|
if (result.success) {
|
|
20489
|
-
restartSpinner.succeed(
|
|
20552
|
+
restartSpinner.succeed(`${brandName} Gateway restarted successfully.`);
|
|
20490
20553
|
} else {
|
|
20491
|
-
restartSpinner.warn(
|
|
20554
|
+
restartSpinner.warn(`Failed to restart ${brandName} Gateway.`);
|
|
20492
20555
|
console.log(source_default.yellow(` Reason: ${result.message}`));
|
|
20493
20556
|
console.log(source_default.dim(" Please restart manually:"));
|
|
20494
|
-
console.log(source_default.dim(
|
|
20557
|
+
console.log(source_default.dim(` ${clawCmd} gateway restart`));
|
|
20495
20558
|
}
|
|
20496
20559
|
console.log();
|
|
20497
20560
|
}
|
|
@@ -20512,13 +20575,13 @@ function formatInstallType(type2) {
|
|
|
20512
20575
|
|
|
20513
20576
|
// src/index.ts
|
|
20514
20577
|
var program2 = new Command();
|
|
20515
|
-
program2.name("soulhub").description("SoulHub CLI - Install and manage AI agent persona templates").version("1.0.
|
|
20578
|
+
program2.name("soulhub").description("SoulHub CLI - Install and manage AI agent persona templates").version("1.0.13").option("--verbose", "Enable verbose debug logging").hook("preAction", () => {
|
|
20516
20579
|
const opts = program2.opts();
|
|
20517
20580
|
const verbose = opts.verbose || process.env.SOULHUB_DEBUG === "1";
|
|
20518
20581
|
logger.init(verbose);
|
|
20519
20582
|
logger.info("CLI started", {
|
|
20520
20583
|
args: process.argv.slice(2),
|
|
20521
|
-
version: "1.0.
|
|
20584
|
+
version: "1.0.13",
|
|
20522
20585
|
node: process.version
|
|
20523
20586
|
});
|
|
20524
20587
|
});
|