@d5render/cli 0.1.32 → 0.1.33

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/d5cli +33 -5
  2. package/package.json +1 -1
package/bin/d5cli CHANGED
@@ -2,12 +2,12 @@
2
2
  import { execSync, spawn } from "node:child_process";
3
3
  import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
- import { argv, env, exit, platform, stdout } from "node:process";
5
+ import { arch, argv, env, exit, platform, stdout } from "node:process";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
8
8
  //#region package.json
9
9
  var name$1 = "@d5render/cli";
10
- var version = "0.1.32";
10
+ var version = "0.1.33";
11
11
 
12
12
  //#endregion
13
13
  //#region copilot/server/config.ts
@@ -300,8 +300,26 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
300
300
  exit(code);
301
301
  });
302
302
  }
303
+ /**
304
+ * 根据操作系统和架构获取对应的 copilot 包名
305
+ * @returns 平台特定的包名数组,按优先级排序
306
+ */
307
+ function getCopilotPackageNames() {
308
+ const packages = [];
309
+ if (platform === "win32" && arch === "x64") packages.push("@github/copilot-win32-x64");
310
+ else if (platform === "linux" && arch === "x64") packages.push("@github/copilot-linux-x64");
311
+ else if (platform === "linux" && arch === "arm64") packages.push("@github/copilot-linux-arm64");
312
+ else if (platform === "darwin" && arch === "arm64") packages.push("@github/copilot-darwin-arm64");
313
+ packages.push("@github/copilot");
314
+ return packages;
315
+ }
303
316
  function findCopilopt() {
304
- let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
317
+ const packageNames = getCopilotPackageNames();
318
+ let copilot = "";
319
+ for (const packageName of packageNames) try {
320
+ copilot = execSync(`npm list ${packageName} -g -p`).toString().trim();
321
+ if (copilot) break;
322
+ } catch {}
305
323
  if (!copilot) {
306
324
  const first = platform === "win32" ? win : linux;
307
325
  const second = platform === "win32" ? linux : win;
@@ -328,7 +346,12 @@ function win() {
328
346
  const pathEnv = env.PATH || env.Path || "";
329
347
  const pathSeparator = platform === "win32" ? ";" : ":";
330
348
  const npm = pathEnv.split(pathSeparator).find((p) => p.includes("npm"));
331
- if (npm) return join(npm, "node_modules", "@github", "copilot");
349
+ if (!npm) return "";
350
+ const packageNames = getCopilotPackageNames();
351
+ for (const packageName of packageNames) {
352
+ const packagePath = join(npm, "node_modules", ...packageName.split("/"));
353
+ if (existsSync(join(packagePath, "package.json"))) return packagePath;
354
+ }
332
355
  return "";
333
356
  }
334
357
  function linux() {
@@ -339,7 +362,12 @@ function linux() {
339
362
  const npm = pathEnv.split(pathSeparator).find((p) => p.includes(".nvm"));
340
363
  if (npm) cached = npm;
341
364
  }
342
- if (cached) return join(cached, "..", "lib", "node_modules", "@github", "copilot");
365
+ if (!cached) return "";
366
+ const packageNames = getCopilotPackageNames();
367
+ for (const packageName of packageNames) {
368
+ const packagePath = join(cached, "..", "lib", "node_modules", ...packageName.split("/"));
369
+ if (existsSync(join(packagePath, "package.json"))) return packagePath;
370
+ }
343
371
  return "";
344
372
  }
345
373
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "license": "MIT",
5
5
  "author": "jasirou",
6
6
  "main": "./bin/d5cli",
7
- "version": "0.1.32",
7
+ "version": "0.1.33",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",