@d5render/cli 0.1.30 → 0.1.31

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/copilot.js CHANGED
@@ -18916,7 +18916,6 @@ const tools = [
18916
18916
  "--deny-tool",
18917
18917
  "github-mcp-server"
18918
18918
  ];
18919
- console.log("production");
18920
18919
  tools.push("--model", "claude-sonnet-4.5");
18921
18920
  function toEnv(key, defaultValue) {
18922
18921
  return envJson[key] || process.env[key] || defaultValue;
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.30";
10
+ var version = "0.1.31";
11
11
 
12
12
  //#endregion
13
13
  //#region packages/gitlab/url.ts
@@ -178,7 +178,6 @@ const tools = [
178
178
  "--deny-tool",
179
179
  "github-mcp-server"
180
180
  ];
181
- console.log("production");
182
181
  tools.push("--model", "claude-sonnet-4.5");
183
182
  function toEnv(key, defaultValue) {
184
183
  return envJson[key] || process.env[key] || defaultValue;
@@ -281,6 +280,7 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
281
280
  },
282
281
  ...platform === "win32" && { windowsHide: true }
283
282
  });
283
+ console.log(`node ${findCopilopt()} ${tools.join(" ")} --stream off -p ${prompt}`);
284
284
  copilot.stdout.setEncoding("utf8");
285
285
  copilot.stderr.setEncoding("utf8");
286
286
  copilot.stdout.on("data", (chunk) => {
@@ -294,19 +294,57 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
294
294
  exit(code);
295
295
  });
296
296
  }
297
+ /**
298
+ * 根据平台和架构获取对应的 @github/copilot 包名
299
+ * @returns 包名,如 @github/copilot-win32-x64 或 @github/copilot
300
+ */
301
+ function getCopilotPackageName() {
302
+ const platformMap = {
303
+ win32: "win32",
304
+ linux: "linux",
305
+ darwin: "darwin"
306
+ };
307
+ const archMap = {
308
+ x64: "x64",
309
+ arm64: "arm64"
310
+ };
311
+ const platformName = platformMap[platform];
312
+ const archName = archMap[arch];
313
+ if (platformName && archName) {
314
+ const specificPackage = `@github/copilot-${platformName}-${archName}`;
315
+ try {
316
+ if (execSync(`npm list ${specificPackage} -g -p`, {
317
+ encoding: "utf8",
318
+ stdio: "pipe"
319
+ }).trim()) {
320
+ logImmediate(`[调试] 使用平台特定包: ${specificPackage}`);
321
+ return specificPackage;
322
+ }
323
+ } catch {}
324
+ }
325
+ logImmediate(`[调试] 使用通用包: @github/copilot`);
326
+ return "@github/copilot";
327
+ }
297
328
  function findCopilopt() {
298
- let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
329
+ const packageName = getCopilotPackageName();
330
+ let copilot = "";
331
+ try {
332
+ copilot = execSync(`npm list ${packageName} -g -p`, {
333
+ encoding: "utf8",
334
+ stdio: "pipe"
335
+ }).trim();
336
+ } catch {}
299
337
  if (!copilot) {
300
338
  const first = platform === "win32" ? win : linux;
301
339
  const second = platform === "win32" ? linux : win;
302
- copilot = first();
303
- if (!copilot) copilot = second();
304
- if (!copilot) throw new Error("没找到安装的包");
340
+ copilot = first(packageName);
341
+ if (!copilot) copilot = second(packageName);
342
+ if (!copilot) throw new Error(`没找到安装的包: ${packageName},请运行: npm install -g ${packageName}`);
305
343
  }
306
344
  const pkg = join(copilot, "package.json");
307
345
  if (!existsSync(pkg)) throw new Error("安装的包找不到正确版本 " + pkg);
308
346
  const copilotPackage = JSON.parse(readFileSync(pkg, "utf8"));
309
- const binPath = typeof copilotPackage.bin === "string" ? copilotPackage.bin : copilotPackage.bin?.copilot || copilotPackage.bin?.["@github/copilot"];
347
+ const binPath = typeof copilotPackage.bin === "string" ? copilotPackage.bin : copilotPackage.bin?.copilot || copilotPackage.bin?.["@github/copilot"] || copilotPackage.bin?.[packageName];
310
348
  if (!binPath) throw new Error("non copilot executable found");
311
349
  const copilotVersion = copilotPackage.version || "unknown";
312
350
  const copilotPath = join(copilot, binPath);
@@ -314,18 +352,19 @@ function findCopilopt() {
314
352
  version: ${VERSION}
315
353
  path: ${serveFile}
316
354
  copilot:
355
+ package: ${packageName}
317
356
  version: ${copilotVersion}
318
357
  path: ${copilotPath}`);
319
358
  return copilotPath;
320
359
  }
321
- function win() {
360
+ function win(packageName = "@github/copilot") {
322
361
  const pathEnv = env.PATH || env.Path || "";
323
362
  const pathSeparator = platform === "win32" ? ";" : ":";
324
363
  const npm = pathEnv.split(pathSeparator).find((p) => p.includes("npm"));
325
- if (npm) return join(npm, "node_modules", "@github", "copilot");
364
+ if (npm) return join(npm, "node_modules", packageName.replace("/", pathSeparator === ";" ? "\\" : "/"));
326
365
  return "";
327
366
  }
328
- function linux() {
367
+ function linux(packageName = "@github/copilot") {
329
368
  let cached = env.NVM_BIN;
330
369
  if (!cached) {
331
370
  const pathEnv = env.PATH || env.Path || "";
@@ -333,7 +372,10 @@ function linux() {
333
372
  const npm = pathEnv.split(pathSeparator).find((p) => p.includes(".nvm"));
334
373
  if (npm) cached = npm;
335
374
  }
336
- if (cached) return join(cached, "..", "lib", "node_modules", "@github", "copilot");
375
+ if (cached) {
376
+ const packageDir = packageName.replace("/", "/");
377
+ return join(cached, "..", "lib", "node_modules", packageDir);
378
+ }
337
379
  return "";
338
380
  }
339
381
 
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.30",
7
+ "version": "0.1.31",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",