@d5render/cli 0.1.24 → 0.1.26

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
@@ -18872,7 +18872,7 @@ const NAME = name$1.replaceAll("/", "_");
18872
18872
  const RUNTIME_CWD = join(dirname(fileURLToPath(import.meta.url)), "../");
18873
18873
  const HOME = env.USERPROFILE ?? env.HOME ?? env.HOMEPATH;
18874
18874
  if (!HOME) throw new Error("cannot find `USERPROFILE` directory");
18875
- const TEMP = env.CI_PROJECT_DIR + NAME;
18875
+ const TEMP = env.CI_PROJECT_DIR + "." + NAME;
18876
18876
 
18877
18877
  //#endregion
18878
18878
  //#region copilot/server/config.ts
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.24";
10
+ var version = "0.1.26";
11
11
 
12
12
  //#endregion
13
13
  //#region packages/gitlab/url.ts
@@ -71,8 +71,16 @@ const VERSION = version;
71
71
  const RUNTIME_CWD = join(dirname(fileURLToPath(import.meta.url)), "../");
72
72
  const HOME = env.USERPROFILE ?? env.HOME ?? env.HOMEPATH;
73
73
  if (!HOME) throw new Error("cannot find `USERPROFILE` directory");
74
- const TEMP = env.CI_PROJECT_DIR + NAME;
75
- function deploy() {
74
+ const TEMP = env.CI_PROJECT_DIR + "." + NAME;
75
+ const dingding = async (...args) => {
76
+ try {
77
+ const msg = await (await sendding(...args)).text();
78
+ console.log(msg);
79
+ } catch (error) {
80
+ console.error(error);
81
+ }
82
+ };
83
+ async function deploy() {
76
84
  if (!env.CI) return;
77
85
  const config = join(HOME, ".copilot/config.json"), dir = join(HOME, ".copilot/skills/codereview");
78
86
  console.log("deploy...");
@@ -82,6 +90,14 @@ function deploy() {
82
90
  }
83
91
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
84
92
  const versiono = readFileSync(join(RUNTIME_CWD, ".skills/review/version"), "utf8");
93
+ const changelog = readFileSync(join(RUNTIME_CWD, "CHANGELOG.md"), "utf8");
94
+ const cachepath = join(TEMP, "CHANGELOG");
95
+ if (changelog !== (existsSync(cachepath) ? readFileSync(cachepath, "utf8") : "")) {
96
+ if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
97
+ writeFileSync(cachepath, changelog, "utf8");
98
+ console.log("updated CHANGELOG cache.");
99
+ await dingding("NOTICE", `codereview skills has been updated to version ${versiono}\n\nfor more details, please refer to [ONLINE](https://www.npmjs.com/package/@d5render/cli?activeTab=readme)`);
100
+ }
85
101
  const versionnPath = join(dir, "version");
86
102
  if ((existsSync(versionnPath) ? readFileSync(versionnPath, "utf8") : "") === versiono) return;
87
103
  const skillRoot = join(RUNTIME_CWD, ".skills/review");
@@ -89,25 +105,16 @@ function deploy() {
89
105
  const instructionsRoot = join(RUNTIME_CWD, ".github/instructions");
90
106
  readdirSync(instructionsRoot).forEach((instruction) => copyFileSync(join(instructionsRoot, instruction), join(dir, instruction)));
91
107
  console.log("to new skill.");
92
- const changelog = readFileSync(join(RUNTIME_CWD, "CHANGELOG.md"), "utf8");
93
- const cachepath = join(TEMP, "CHANGELOG");
94
- if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
95
- if (changelog !== (existsSync(cachepath) ? readFileSync(cachepath, "utf8") : "")) {
96
- if (!existsSync(cachepath)) mkdirSync(cachepath, { recursive: true });
97
- writeFileSync(cachepath, changelog, "utf8");
98
- console.log("updated CHANGELOG cache.");
99
- sendding("NOTICE", `NOTICE: codereview skills has been updated to version ${versiono}\n\nfor more details, please refer to [ONLINE](https://www.npmjs.com/package/@d5render/cli?activeTab=readme)`);
100
- }
101
108
  }
102
- function need() {
109
+ async function need() {
103
110
  if (!env.CI) return;
104
- if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
105
111
  const { CI_MERGE_REQUEST_IID, CI_COMMIT_SHA } = env;
106
112
  const file$1 = join(TEMP, "CODEREVIEW");
107
113
  if (CI_MERGE_REQUEST_IID) {
108
114
  let appended = `${existsSync(file$1) ? readFileSync(file$1, "utf8") : ""}\n${CI_MERGE_REQUEST_IID}`.split("\n");
109
115
  const max = 1e4;
110
116
  if (appended.length > max) appended = appended.slice(-max);
117
+ if (!existsSync(TEMP)) mkdirSync(TEMP, { recursive: true });
111
118
  writeFileSync(file$1, appended.join("\n"), "utf8");
112
119
  console.log("merge pipeline, recorded IID:", CI_MERGE_REQUEST_IID, "to:", file$1);
113
120
  return true;
@@ -125,14 +132,14 @@ function need() {
125
132
  console.warn(`Merge Request !${iid} has been AI reviewed before.`);
126
133
  const mergeURL = visitPipeline(iid).url;
127
134
  const url = `${commits()}/${CI_COMMIT_SHA}/comments`;
128
- fetch(url, {
135
+ await fetch(url, {
129
136
  method: "POST",
130
137
  headers: buildHeaders(),
131
138
  body: JSON.stringify({
132
139
  note: `请查看管道评论:${mergeURL}#note`,
133
140
  line_type: "new"
134
141
  })
135
- }).then((res) => res.text());
142
+ }).then((res) => res.text()).then((v) => console.log(v)).catch((e) => console.error(e));
136
143
  }
137
144
  return !yes;
138
145
  }
@@ -241,12 +248,12 @@ function installCopilot() {
241
248
  try {
242
249
  codereview();
243
250
  } catch (error) {
244
- sendding("CRITICAL", "CRITICAL CI ERROR: 未知错误,请自行检查日志");
251
+ dingding("CRITICAL", "CI ERROR: 未知错误,请自行检查日志");
245
252
  throw error;
246
253
  }
247
- function codereview() {
248
- deploy();
249
- if (!need()) {
254
+ async function codereview() {
255
+ await deploy();
256
+ if (!await need()) {
250
257
  console.log("重复提交,进程跳过");
251
258
  return;
252
259
  }
@@ -272,7 +279,7 @@ Otherwise, use chinese as default language to call the mcp tool '${name}-${repor
272
279
  copilot.stdout.on("data", (chunk) => console.log(String(chunk)));
273
280
  copilot.stderr.on("data", (chunk) => console.error(String(chunk)));
274
281
  copilot.on("close", (code) => {
275
- sendding("CRITICAL", "CRITICAL CI ERROR: 代码审查任务失败,请自行检查日志");
282
+ if (!code) dingding("CRITICAL", "CI ERROR: 代码审查任务失败,请自行检查日志");
276
283
  exit(code);
277
284
  });
278
285
  }
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.24",
7
+ "version": "0.1.26",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",