galaxy-opc 0.5.2 → 0.5.3

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 +49 -3
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -115,6 +115,14 @@ function checkTool(cmd) {
115
115
  try { execSync(`${cmd} --version`, { stdio: "ignore" }); return true; } catch { return false; }
116
116
  }
117
117
 
118
+ function findPackedTarball(dir, pkgPrefix) {
119
+ if (!fs.existsSync(dir)) return null;
120
+ const files = fs.readdirSync(dir).filter((f) => f.startsWith(pkgPrefix) && f.endsWith(".tgz"));
121
+ if (files.length === 0) return null;
122
+ files.sort();
123
+ return path.join(dir, files[files.length - 1]);
124
+ }
125
+
118
126
  function getOpenclawVersion() {
119
127
  try {
120
128
  const out = execSync("openclaw --version 2>&1", { encoding: "utf8" }).trim();
@@ -184,6 +192,28 @@ ${bold(cyan(" ╚════════════════════
184
192
  process.exit(1);
185
193
  }
186
194
  console.log(green(" ✓ git 已就绪"));
195
+ } else if (process.platform === "win32") {
196
+ console.log(yellow("\n ! git 未安装,正在尝试通过 winget 自动安装...\n"));
197
+ if (!checkTool("winget")) {
198
+ console.error(red(" ✗ 未检测到 winget,无法自动安装 git"));
199
+ console.error(gray(" 请先安装 Git: https://git-scm.com/downloads\n"));
200
+ process.exit(1);
201
+ }
202
+ try {
203
+ await runCommand("winget", [
204
+ "install", "--id", "Git.Git", "-e",
205
+ "--accept-package-agreements", "--accept-source-agreements",
206
+ ]);
207
+ } catch {
208
+ console.error(red(" ✗ git 自动安装失败"));
209
+ console.error(gray(" 请手动安装 Git 后重试: https://git-scm.com/downloads\n"));
210
+ process.exit(1);
211
+ }
212
+ if (!checkTool("git")) {
213
+ console.error(red(" ✗ git 安装后仍不可用,请重开终端再试"));
214
+ process.exit(1);
215
+ }
216
+ console.log(green(" ✓ git 已安装"));
187
217
  } else {
188
218
  console.error(red("\n ✗ git 未安装,请先安装 git:"));
189
219
  console.error(gray(" https://git-scm.com/downloads\n"));
@@ -286,9 +316,25 @@ async function installPlugin() {
286
316
  await runCommand("openclaw", ["plugins", "install", "galaxy-opc-plugin"]);
287
317
  console.log(green("\n ✓ 插件安装完成"));
288
318
  } catch (e) {
289
- console.error(red(`\n 插件安装失败: ${e.message}`));
290
- console.error(gray(" 请手动运行: openclaw plugins install galaxy-opc-plugin\n"));
291
- process.exit(1);
319
+ console.log(yellow(`\n ! npm spec 安装失败: ${e.message}`));
320
+ console.log(dim(" 正在尝试 fallback:先 npm pack,再安装本地 tgz...\n"));
321
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "galaxy-opc-plugin-"));
322
+ try {
323
+ await runCommand("npm", ["pack", "galaxy-opc-plugin@latest", "--silent"], { cwd: tmpDir });
324
+ const archive = findPackedTarball(tmpDir, "galaxy-opc-plugin-");
325
+ if (!archive) throw new Error("未找到打包产物 *.tgz");
326
+ await runCommand("openclaw", ["plugins", "install", archive]);
327
+ console.log(green("\n ✓ 插件安装完成(fallback)"));
328
+ } catch (fallbackErr) {
329
+ console.error(red(`\n ✗ fallback 安装也失败: ${fallbackErr.message}`));
330
+ console.error(gray(" 请依次手动执行:"));
331
+ console.error(gray(" 1) openclaw doctor --fix"));
332
+ console.error(gray(" 2) npm pack galaxy-opc-plugin@latest --silent"));
333
+ console.error(gray(" 3) openclaw plugins install .\\galaxy-opc-plugin-<version>.tgz\n"));
334
+ process.exit(1);
335
+ } finally {
336
+ try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* ignore */ }
337
+ }
292
338
  }
293
339
 
294
340
  // better-sqlite3 是 native 模块,需要针对当前 Node.js 版本编译
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galaxy-opc",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "星环 Galaxy OPC — 一人公司孵化与赋能平台 AI 员工系统",
5
5
  "keywords": [
6
6
  "ai",