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.
Files changed (2) hide show
  1. package/bin/cli.mjs +36 -61
  2. 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
- // 优先使用官方安装脚本(预编译二进制,绕开 npm git 依赖超时)
164
- try {
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: "国内镜像(fallback)",
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:卸载插件(可选保留数据 / 卸载 openclaw)────────────────────
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
- console.log(red("\n 警告:此操作将移除 OPC Platform 插件及其配置。\n"));
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. 询问是否保留业务数据(SQLite 数据库)──────────────────────────────
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
- // ── 3. openclaw.json 中清除插件注册信息 ───────────────────────────────
549
- const cfg = readJson(CONFIG_PATH);
550
- let cfgChanged = false;
551
- if (cfg.plugins?.["galaxy-opc-plugin"]) {
552
- delete cfg.plugins["galaxy-opc-plugin"];
553
- cfgChanged = true;
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
- if (cfg.plugins?.load) {
556
- delete cfg.plugins.load;
557
- cfgChanged = true;
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 (cfgChanged) {
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"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galaxy-opc",
3
- "version": "0.5.18",
3
+ "version": "0.5.20",
4
4
  "description": "星环 Galaxy OPC — 一人公司孵化与赋能平台 AI 员工系统",
5
5
  "keywords": [
6
6
  "ai",