@d5render/cli 0.1.36 → 0.1.38
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/d5cli +42 -5
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name$1 = "@d5render/cli";
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.38";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region copilot/server/config.ts
|
|
@@ -288,6 +288,8 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
|
|
|
288
288
|
},
|
|
289
289
|
...platform === "win32" && { windowsHide: true }
|
|
290
290
|
});
|
|
291
|
+
console.log("执行命令:");
|
|
292
|
+
console.log(`node ${findCopilopt()} ${tools.join(" ")} --stream off -p ${prompt}`);
|
|
291
293
|
copilot.stdout.setEncoding("utf8");
|
|
292
294
|
copilot.stderr.setEncoding("utf8");
|
|
293
295
|
copilot.stdout.on("data", (chunk) => {
|
|
@@ -307,31 +309,66 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
|
|
|
307
309
|
*/
|
|
308
310
|
function getCopilotPackageNames() {
|
|
309
311
|
const packages = [];
|
|
312
|
+
console.log("platform:", platform);
|
|
313
|
+
console.log("arch:", arch);
|
|
310
314
|
if (platform === "win32" && arch === "x64") packages.push("@github/copilot-win32-x64");
|
|
311
315
|
else if (platform === "linux" && arch === "x64") packages.push("@github/copilot-linux-x64");
|
|
312
316
|
else if (platform === "linux" && arch === "arm64") packages.push("@github/copilot-linux-arm64");
|
|
313
317
|
else if (platform === "darwin" && arch === "arm64") packages.push("@github/copilot-darwin-arm64");
|
|
314
318
|
packages.push("@github/copilot");
|
|
319
|
+
console.log("packages:", packages);
|
|
315
320
|
return packages;
|
|
316
321
|
}
|
|
317
322
|
function findCopilopt() {
|
|
318
323
|
const packageNames = getCopilotPackageNames();
|
|
319
324
|
let copilot = "";
|
|
325
|
+
let foundPackageName = "";
|
|
320
326
|
for (const packageName of packageNames) try {
|
|
321
327
|
copilot = execSync(`npm list ${packageName} -g -p`).toString().trim();
|
|
322
|
-
if (copilot)
|
|
328
|
+
if (copilot) {
|
|
329
|
+
foundPackageName = packageName;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
323
332
|
} catch {}
|
|
324
333
|
if (!copilot) {
|
|
325
334
|
const first = platform === "win32" ? win : linux;
|
|
326
335
|
const second = platform === "win32" ? linux : win;
|
|
327
|
-
|
|
328
|
-
if (
|
|
336
|
+
const result = first();
|
|
337
|
+
if (result) {
|
|
338
|
+
copilot = result;
|
|
339
|
+
const pathParts = copilot.split(/[/\\]/);
|
|
340
|
+
const nodeModulesIndex = pathParts.indexOf("node_modules");
|
|
341
|
+
if (nodeModulesIndex !== -1 && pathParts[nodeModulesIndex + 1]) foundPackageName = pathParts[nodeModulesIndex + 1] === "@github" ? `${pathParts[nodeModulesIndex + 1]}/${pathParts[nodeModulesIndex + 2]}` : pathParts[nodeModulesIndex + 1];
|
|
342
|
+
} else {
|
|
343
|
+
copilot = second();
|
|
344
|
+
if (copilot) {
|
|
345
|
+
const pathParts = copilot.split(/[/\\]/);
|
|
346
|
+
const nodeModulesIndex = pathParts.indexOf("node_modules");
|
|
347
|
+
if (nodeModulesIndex !== -1 && pathParts[nodeModulesIndex + 1]) foundPackageName = pathParts[nodeModulesIndex + 1] === "@github" ? `${pathParts[nodeModulesIndex + 1]}/${pathParts[nodeModulesIndex + 2]}` : pathParts[nodeModulesIndex + 1];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
329
350
|
if (!copilot) throw new Error("没找到安装的包");
|
|
330
351
|
}
|
|
331
352
|
const pkg = join(copilot, "package.json");
|
|
332
353
|
if (!existsSync(pkg)) throw new Error("安装的包找不到正确版本 " + pkg);
|
|
333
354
|
const copilotPackage = JSON.parse(readFileSync(pkg, "utf8"));
|
|
334
|
-
|
|
355
|
+
let binPath;
|
|
356
|
+
if (typeof copilotPackage.bin === "string") binPath = copilotPackage.bin;
|
|
357
|
+
else if (copilotPackage.bin) {
|
|
358
|
+
const possibleKeys = foundPackageName ? [
|
|
359
|
+
foundPackageName,
|
|
360
|
+
"copilot",
|
|
361
|
+
"@github/copilot"
|
|
362
|
+
] : [
|
|
363
|
+
"copilot",
|
|
364
|
+
"@github/copilot",
|
|
365
|
+
...packageNames
|
|
366
|
+
];
|
|
367
|
+
for (const key of possibleKeys) if (copilotPackage.bin[key]) {
|
|
368
|
+
binPath = copilotPackage.bin[key];
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
335
372
|
if (!binPath) throw new Error("non copilot executable found");
|
|
336
373
|
const copilotVersion = copilotPackage.version || "unknown";
|
|
337
374
|
const copilotPath = join(copilot, binPath);
|