galaxy-opc 0.5.18 → 0.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +36 -61
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -158,35 +158,16 @@ function cleanupAgentModelOverrides() {
|
|
|
158
158
|
|
|
159
159
|
async function installOpenclawWithFallback() {
|
|
160
160
|
const env = buildOpenclawInstallEnv();
|
|
161
|
-
const isWindows = process.platform === "win32";
|
|
162
161
|
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
console.log(dim(" 尝试 官方安装脚本(预编译二进制)安装 OpenClaw...\n"));
|
|
166
|
-
if (isWindows) {
|
|
167
|
-
// shell: false 避免 cmd.exe 拦截管道符(否则 iex 会被 cmd 执行而非 PowerShell)
|
|
168
|
-
await runCommand("powershell", [
|
|
169
|
-
"-NoProfile", "-NonInteractive", "-Command",
|
|
170
|
-
"iwr -useb https://openclaw.ai/install.ps1 | iex",
|
|
171
|
-
], { env, shell: false });
|
|
172
|
-
} else {
|
|
173
|
-
await runCommand("bash", [
|
|
174
|
-
"-c", "curl -fsSL https://openclaw.ai/install.sh | bash",
|
|
175
|
-
], { env });
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
} catch (e) {
|
|
179
|
-
console.log(yellow(` ! 官方安装脚本失败: ${e.message}\n`));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// 降级到 npm install
|
|
162
|
+
// 官方安装脚本(install.sh / install.ps1)会在安装后自动启动 openclaw onboarding 向导,
|
|
163
|
+
// 与本向导流程冲突,因此统一使用 npm install,China 网络自动降级到 npmmirror。
|
|
183
164
|
const attempts = [
|
|
184
165
|
{
|
|
185
|
-
label: "
|
|
166
|
+
label: "官方源",
|
|
186
167
|
args: ["install", "-g", "openclaw@latest"],
|
|
187
168
|
},
|
|
188
169
|
{
|
|
189
|
-
label: "国内镜像(
|
|
170
|
+
label: "国内镜像(npmmirror)",
|
|
190
171
|
args: ["install", "-g", "openclaw@latest", "--registry", "https://registry.npmmirror.com"],
|
|
191
172
|
},
|
|
192
173
|
];
|
|
@@ -511,13 +492,19 @@ async function cmdUpdate() {
|
|
|
511
492
|
console.log(cyan(" npx galaxy-opc start\n"));
|
|
512
493
|
}
|
|
513
494
|
|
|
514
|
-
// ─── uninstall
|
|
495
|
+
// ─── uninstall:卸载插件 + 清除全部用户数据 ─────────────────────────────────
|
|
515
496
|
async function cmdUninstall() {
|
|
516
497
|
separator();
|
|
517
498
|
console.log(bold(" galaxy-opc uninstall — 卸载 OPC Platform 插件"));
|
|
518
499
|
separator();
|
|
519
500
|
|
|
520
|
-
|
|
501
|
+
const pluginDir = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
502
|
+
const dataDir = path.join(STATE_DIR, "opc-platform");
|
|
503
|
+
|
|
504
|
+
console.log(red("\n 警告:此操作将删除以下内容,且不可恢复:"));
|
|
505
|
+
console.log(gray(` · 插件目录 ${pluginDir}`));
|
|
506
|
+
console.log(gray(` · 业务数据 ${dataDir} (公司/财务/合同/员工等数据库)`));
|
|
507
|
+
console.log(gray(` · openclaw.json 中的全部 OPC 插件配置\n`));
|
|
521
508
|
|
|
522
509
|
const confirm = await askYesNo(" 确认继续卸载?", false);
|
|
523
510
|
if (!confirm) {
|
|
@@ -525,14 +512,7 @@ async function cmdUninstall() {
|
|
|
525
512
|
return;
|
|
526
513
|
}
|
|
527
514
|
|
|
528
|
-
// ── 1.
|
|
529
|
-
const keepData = await askYesNo(
|
|
530
|
-
` 保留业务数据(公司/财务/合同等数据库 ${path.join(STATE_DIR, "opc-platform")})?`,
|
|
531
|
-
true,
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
// ── 2. 移除插件目录 ───────────────────────────────────────────────────────
|
|
535
|
-
const pluginDir = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
515
|
+
// ── 1. 移除插件目录 ───────────────────────────────────────────────────────
|
|
536
516
|
if (fs.existsSync(pluginDir)) {
|
|
537
517
|
console.log(dim(`\n 移除插件目录: ${pluginDir}`));
|
|
538
518
|
try {
|
|
@@ -541,42 +521,37 @@ async function cmdUninstall() {
|
|
|
541
521
|
} catch (e) {
|
|
542
522
|
console.log(yellow(` ! 无法移除插件目录: ${e.message}`));
|
|
543
523
|
}
|
|
544
|
-
} else {
|
|
545
|
-
console.log(gray(" 插件目录不存在,跳过"));
|
|
546
524
|
}
|
|
547
525
|
|
|
548
|
-
// ──
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
526
|
+
// ── 2. 删除业务数据 ───────────────────────────────────────────────────────
|
|
527
|
+
if (fs.existsSync(dataDir)) {
|
|
528
|
+
console.log(dim(` 移除业务数据: ${dataDir}`));
|
|
529
|
+
try {
|
|
530
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
531
|
+
console.log(green(" ✓ 业务数据已删除"));
|
|
532
|
+
} catch (e) {
|
|
533
|
+
console.log(yellow(` ! 无法删除数据目录: ${e.message}`));
|
|
534
|
+
}
|
|
554
535
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
536
|
+
|
|
537
|
+
// ── 3. 清除 openclaw.json 中全部 OPC 插件配置 ────────────────────────────
|
|
538
|
+
const cfg = readJson(CONFIG_PATH);
|
|
539
|
+
let cfgDirty = false;
|
|
540
|
+
if (cfg.plugins) {
|
|
541
|
+
if (cfg.plugins.load !== undefined) { delete cfg.plugins.load; cfgDirty = true; }
|
|
542
|
+
if (cfg.plugins.entries?.["galaxy-opc-plugin"] !== undefined){ delete cfg.plugins.entries["galaxy-opc-plugin"]; cfgDirty = true; }
|
|
543
|
+
if (Array.isArray(cfg.plugins.allow)) {
|
|
544
|
+
const before = cfg.plugins.allow.length;
|
|
545
|
+
cfg.plugins.allow = cfg.plugins.allow.filter((p) => p !== "galaxy-opc-plugin");
|
|
546
|
+
if (cfg.plugins.allow.length !== before) cfgDirty = true;
|
|
547
|
+
}
|
|
558
548
|
}
|
|
559
|
-
if (
|
|
549
|
+
if (cfgDirty) {
|
|
560
550
|
writeJson(CONFIG_PATH, cfg);
|
|
561
551
|
console.log(green(" ✓ 已从 openclaw.json 清除插件配置"));
|
|
562
552
|
}
|
|
563
553
|
|
|
564
|
-
// ── 4.
|
|
565
|
-
if (!keepData) {
|
|
566
|
-
const dataDir = path.join(STATE_DIR, "opc-platform");
|
|
567
|
-
if (fs.existsSync(dataDir)) {
|
|
568
|
-
try {
|
|
569
|
-
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
570
|
-
console.log(green(" ✓ 业务数据已删除"));
|
|
571
|
-
} catch (e) {
|
|
572
|
-
console.log(yellow(` ! 无法删除数据目录: ${e.message}`));
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
} else {
|
|
576
|
-
console.log(dim(` 数据已保留: ${path.join(STATE_DIR, "opc-platform")}`));
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// ── 5. 询问是否同时卸载 openclaw ────────────────────────────────────────
|
|
554
|
+
// ── 4. 询问是否同时卸载 openclaw ────────────────────────────────────────
|
|
580
555
|
const removeOc = await askYesNo("\n 同时卸载 OpenClaw(npm uninstall -g openclaw)?", false);
|
|
581
556
|
if (removeOc) {
|
|
582
557
|
console.log(dim("\n 卸载 openclaw...\n"));
|