@d5render/cli 0.1.15 → 0.1.16

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 (3) hide show
  1. package/bin/copilot.js +3165 -2832
  2. package/bin/d5cli +33 -14
  3. package/package.json +1 -1
package/bin/d5cli CHANGED
@@ -6,12 +6,12 @@ import { argv, env, exit, platform } from "node:process";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
8
8
  //#region package.json
9
- var name = "@d5render/cli";
10
- var version = "0.1.15";
9
+ var name$1 = "@d5render/cli";
10
+ var version = "0.1.16";
11
11
 
12
12
  //#endregion
13
13
  //#region copilot/server/config.ts
14
- const name$1 = "d5_mcp_review_builtin";
14
+ const name = "d5_mcp_review_builtin";
15
15
  const report = "report";
16
16
  const getHash = "hash";
17
17
  const file = "./copilot.js";
@@ -37,7 +37,7 @@ const envUsed = {
37
37
  };
38
38
  const tools = [
39
39
  "--additional-mcp-config",
40
- JSON.stringify({ mcpServers: { [name$1]: {
40
+ JSON.stringify({ mcpServers: { [name]: {
41
41
  type: "local",
42
42
  command: "node",
43
43
  args: [serveFile, `--customizenv=${JSON.stringify(envUsed)}`],
@@ -194,8 +194,8 @@ function need() {
194
194
 
195
195
  //#endregion
196
196
  //#region copilot/bin/index.ts
197
- 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.
198
- Otherwise, use chinese as default language to call the mcp tool '${name$1}-${report}'`;
197
+ const prompt = `Load skills, then call the mcp tool '${name}-${getHash}' to load code-review commits, if the task encounters an error, throw that.
198
+ Otherwise, use chinese as default language to call the mcp tool '${name}-${report}'`;
199
199
  deploy();
200
200
  if (need()) {
201
201
  install();
@@ -221,20 +221,21 @@ if (need()) {
221
221
  } else console.log("重复提交,进程跳过");
222
222
  function findCopilopt() {
223
223
  let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
224
- if (!copilot) try {
225
- const pathEnv = env.PATH || env.Path || "";
226
- const pathSeparator = platform === "win32" ? ";" : ":";
227
- const npm = pathEnv.split(pathSeparator).find((p) => p.includes("npm"));
228
- if (npm) copilot = join(npm, "node_modules", "@github", "copilot");
229
- } catch {}
224
+ if (!copilot) {
225
+ const first = platform === "win32" ? win : linux;
226
+ const second = platform === "win32" ? linux : win;
227
+ copilot = first();
228
+ if (!copilot) copilot = second();
229
+ if (!copilot) throw new Error("没找到安装的包");
230
+ }
230
231
  const pkg = join(copilot, "package.json");
231
- if (!existsSync(pkg)) throw new Error("non copilot package found");
232
+ if (!existsSync(pkg)) throw new Error("安装的包找不到正确版本 " + pkg);
232
233
  const copilotPackage = JSON.parse(readFileSync(pkg, "utf8"));
233
234
  const binPath = typeof copilotPackage.bin === "string" ? copilotPackage.bin : copilotPackage.bin?.copilot || copilotPackage.bin?.["@github/copilot"];
234
235
  if (!binPath) throw new Error("non copilot executable found");
235
236
  const copilotVersion = copilotPackage.version || "unknown";
236
237
  const copilotPath = join(copilot, binPath);
237
- console.log(`${name} server:
238
+ console.log(`${name$1} server:
238
239
  version: ${version}
239
240
  path: ${serveFile}
240
241
  copilot:
@@ -242,5 +243,23 @@ copilot:
242
243
  path: ${copilotPath}`);
243
244
  return copilotPath;
244
245
  }
246
+ function win() {
247
+ const pathEnv = env.PATH || env.Path || "";
248
+ const pathSeparator = platform === "win32" ? ";" : ":";
249
+ const npm = pathEnv.split(pathSeparator).find((p) => p.includes("npm"));
250
+ if (npm) return join(npm, "node_modules", "@github", "copilot");
251
+ return "";
252
+ }
253
+ function linux() {
254
+ let cached = env.NVM_BIN;
255
+ if (!cached) {
256
+ const pathEnv = env.PATH || env.Path || "";
257
+ const pathSeparator = platform === "win32" ? ";" : ":";
258
+ const npm = pathEnv.split(pathSeparator).find((p) => p.includes(".nvm"));
259
+ if (npm) cached = npm;
260
+ }
261
+ if (cached) return join(cached, "..", "lib", "node_modules", "@github", "copilot");
262
+ return "";
263
+ }
245
264
 
246
265
  //#endregion
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.15",
7
+ "version": "0.1.16",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",