galaxy-opc 0.3.0 → 0.3.2
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 +26 -3
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -128,8 +128,8 @@ const HOME = os.homedir();
|
|
|
128
128
|
const STATE_DIR = path.join(HOME, ".openclaw");
|
|
129
129
|
const CONFIG_PATH = path.join(STATE_DIR, "openclaw.json");
|
|
130
130
|
const ENV_PATH = path.join(STATE_DIR, ".env");
|
|
131
|
-
// 插件由 openclaw plugins install 写入 ~/.openclaw/extensions/opc-
|
|
132
|
-
const PLUGIN_INSTALL_DIR = path.join(STATE_DIR, "extensions", "opc-
|
|
131
|
+
// 插件由 openclaw plugins install 写入 ~/.openclaw/extensions/galaxy-opc-plugin
|
|
132
|
+
const PLUGIN_INSTALL_DIR = path.join(STATE_DIR, "extensions", "galaxy-opc-plugin");
|
|
133
133
|
|
|
134
134
|
// ─── 命令路由 ───────────────────────────────────────────────────────────────
|
|
135
135
|
const args = process.argv.slice(2);
|
|
@@ -177,13 +177,29 @@ ${bold(cyan(" ╚════════════════════
|
|
|
177
177
|
console.log(green(` ✓ OpenClaw 已安装 (${ocVersion})`));
|
|
178
178
|
} else {
|
|
179
179
|
console.log(dim(" 正在安装 OpenClaw(首次安装约 80MB+,使用国内镜像加速)...\n"));
|
|
180
|
+
// 临时覆盖 git url rewrite(有些机器把 https://github.com 重写到 ssh)
|
|
181
|
+
let gitRewriteSet = false;
|
|
180
182
|
try {
|
|
181
|
-
|
|
183
|
+
execSync("git config --global url.https://github.com/.insteadOf git@github.com:", { stdio: "ignore" });
|
|
184
|
+
gitRewriteSet = true;
|
|
185
|
+
} catch { /* ignore */ }
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
await runCommand("npm", [
|
|
189
|
+
"install", "-g", "openclaw@latest",
|
|
190
|
+
"--registry", "https://registry.npmmirror.com",
|
|
191
|
+
"--git-protocol", "https",
|
|
192
|
+
]);
|
|
182
193
|
console.log(green("\n ✓ OpenClaw 安装完成"));
|
|
183
194
|
} catch {
|
|
184
195
|
console.error(red("\n ✗ OpenClaw 安装失败,请手动运行:"));
|
|
185
196
|
console.error(gray(" npm install -g openclaw@latest --registry https://registry.npmmirror.com\n"));
|
|
186
197
|
process.exit(1);
|
|
198
|
+
} finally {
|
|
199
|
+
// 还原 git 配置
|
|
200
|
+
if (gitRewriteSet) {
|
|
201
|
+
try { execSync("git config --global --unset url.https://github.com/.insteadOf", { stdio: "ignore" }); } catch { /* ignore */ }
|
|
202
|
+
}
|
|
187
203
|
}
|
|
188
204
|
}
|
|
189
205
|
|
|
@@ -234,9 +250,16 @@ async function cmdSetup() {
|
|
|
234
250
|
const existingPaths = newConfig.plugins?.load?.paths ?? [];
|
|
235
251
|
const mergedPaths = Array.from(new Set([...existingPaths, PLUGIN_INSTALL_DIR]));
|
|
236
252
|
newConfig = deepMerge(newConfig, {
|
|
253
|
+
gateway: { mode: "local" },
|
|
237
254
|
plugins: { load: { paths: mergedPaths } },
|
|
238
255
|
});
|
|
239
256
|
|
|
257
|
+
// 清理可能残留的错误 entries key(openclaw plugins install 会写入 galaxy-opc-plugin,
|
|
258
|
+
// 但旧版本或手动配置可能留下 opc-platform key 导致 id mismatch 警告)
|
|
259
|
+
if (newConfig.plugins?.entries?.["opc-platform"]) {
|
|
260
|
+
delete newConfig.plugins.entries["opc-platform"];
|
|
261
|
+
}
|
|
262
|
+
|
|
240
263
|
const regionIdx = await askChoice("选择 AI 模型地区", [
|
|
241
264
|
{ label: "国产模型", desc: "通义千问 / MiniMax / 豆包 / Kimi / DeepSeek", recommended: true },
|
|
242
265
|
{ label: "海外模型", desc: "OpenAI / Anthropic / OpenRouter" },
|