@d5render/cli 0.1.53 → 0.1.55
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 +55 -3
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawn } from "node:child_process";
|
|
3
|
+
import { createConnection } from "node:net";
|
|
3
4
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
5
|
import { dirname, join } from "node:path";
|
|
5
6
|
import { argv, env, platform } from "node:process";
|
|
@@ -107,7 +108,7 @@ function installCopilot() {
|
|
|
107
108
|
//#endregion
|
|
108
109
|
//#region package.json
|
|
109
110
|
var name = "@d5render/cli";
|
|
110
|
-
var version = "0.1.
|
|
111
|
+
var version = "0.1.55";
|
|
111
112
|
|
|
112
113
|
//#endregion
|
|
113
114
|
//#region packages/gitlab/url.ts
|
|
@@ -270,6 +271,9 @@ async function codereview() {
|
|
|
270
271
|
install();
|
|
271
272
|
const prompt = `Load skills, then call the mcp tool '${name$1}-${getHash}' to load code-review commits, if the task encounters an error, throw that.
|
|
272
273
|
Otherwise, use chinese as default language to call the mcp tool '${name$1}-${report}'`;
|
|
274
|
+
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy || "";
|
|
275
|
+
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy || "";
|
|
276
|
+
await logProxyStatus(httpProxy, httpsProxy);
|
|
273
277
|
const copilot = spawn("node", [
|
|
274
278
|
findCopilopt(),
|
|
275
279
|
...tools,
|
|
@@ -286,8 +290,9 @@ Otherwise, use chinese as default language to call the mcp tool '${name$1}-${rep
|
|
|
286
290
|
],
|
|
287
291
|
...platform === "win32" && { windowsHide: true },
|
|
288
292
|
env: {
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
...process.env,
|
|
294
|
+
HTTP_PROXY: httpProxy,
|
|
295
|
+
HTTPS_PROXY: httpsProxy
|
|
291
296
|
}
|
|
292
297
|
});
|
|
293
298
|
copilot.stdout.on("data", (chunk) => console.log(String(chunk)));
|
|
@@ -296,6 +301,53 @@ Otherwise, use chinese as default language to call the mcp tool '${name$1}-${rep
|
|
|
296
301
|
copilot.on("close", (code) => res());
|
|
297
302
|
});
|
|
298
303
|
}
|
|
304
|
+
/** 代理排查:环境变量 + 检测代理是否在运行、子进程是否会走代理 */
|
|
305
|
+
async function logProxyStatus(httpProxy, httpsProxy) {
|
|
306
|
+
const tag = "[proxy]";
|
|
307
|
+
console.log(`${tag} -------- 代理排查 --------`);
|
|
308
|
+
console.log(`${tag} 当前进程 env: HTTP_PROXY = ${process.env.HTTP_PROXY ?? "(未设置)"}, http_proxy = ${process.env.http_proxy ?? "(未设置)"}`);
|
|
309
|
+
console.log(`${tag} 当前进程 env: HTTPS_PROXY = ${process.env.HTTPS_PROXY ?? "(未设置)"}, https_proxy = ${process.env.https_proxy ?? "(未设置)"}`);
|
|
310
|
+
console.log(`${tag} 传给子进程: HTTP_PROXY = ${httpProxy || "(空)"}, HTTPS_PROXY = ${httpsProxy || "(空)"}`);
|
|
311
|
+
const proxyUrl = httpsProxy || httpProxy;
|
|
312
|
+
if (!proxyUrl) {
|
|
313
|
+
console.log(`${tag} 结论: 未设置代理,子进程将直连外网,不会经代理`);
|
|
314
|
+
console.log(`${tag} ------------------------`);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
let host;
|
|
318
|
+
let port;
|
|
319
|
+
try {
|
|
320
|
+
const u = new URL(proxyUrl);
|
|
321
|
+
host = u.hostname || "127.0.0.1";
|
|
322
|
+
port = u.port ? parseInt(u.port, 10) : 7890;
|
|
323
|
+
} catch {
|
|
324
|
+
console.log(`${tag} 结论: 代理 URL 解析失败,子进程可能无法正确使用代理: ${proxyUrl}`);
|
|
325
|
+
console.log(`${tag} ------------------------`);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (await checkPortReachable(host, port)) {
|
|
329
|
+
console.log(`${tag} 代理检测: ${host}:${port} 可连接,代理服务应在运行`);
|
|
330
|
+
console.log(`${tag} 结论: 子进程已继承代理环境变量,请求应能通过代理发出`);
|
|
331
|
+
} else {
|
|
332
|
+
console.log(`${tag} 代理检测: ${host}:${port} 无法连接,可能代理未启动或地址/端口错误`);
|
|
333
|
+
console.log(`${tag} 结论: 子进程虽有代理变量,但代理不可达,请求可能失败或直连`);
|
|
334
|
+
}
|
|
335
|
+
console.log(`${tag} ------------------------`);
|
|
336
|
+
}
|
|
337
|
+
function checkPortReachable(host, port, timeoutMs = 3e3) {
|
|
338
|
+
return new Promise((resolve) => {
|
|
339
|
+
const socket = createConnection(port, host, () => {
|
|
340
|
+
socket.destroy();
|
|
341
|
+
resolve(true);
|
|
342
|
+
});
|
|
343
|
+
socket.setTimeout(timeoutMs);
|
|
344
|
+
socket.on("timeout", () => {
|
|
345
|
+
socket.destroy();
|
|
346
|
+
resolve(false);
|
|
347
|
+
});
|
|
348
|
+
socket.on("error", () => resolve(false));
|
|
349
|
+
});
|
|
350
|
+
}
|
|
299
351
|
function findCopilopt() {
|
|
300
352
|
let copilot = "";
|
|
301
353
|
try {
|