@d5render/cli 0.1.12 → 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.
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  name: code-review
3
- description: code review suggestions
3
+ description: When the task is code-review, please follow this document to proceed the work.
4
4
  ---
5
5
 
6
6
  1. read file [review.instructions.md](./review.instructions.md).
7
7
  2. find all Markdown resumes within the project and their basic understanding of the project.
8
- 3. based on the understanding of review to supplemented.
9
- 4. run...
8
+ 3. integrate your understanding of code-review to process task.
9
+ 4. pay attention to the issue tracking description in the context, and try to use relevant tools to obtain more context.
10
+ 5. output your plan for the task,and when task run, output the intermediate process of the task.
11
+ 6. output all the context read, especially the introductory document.
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
package/bin/copilot.js CHANGED
@@ -18805,7 +18805,7 @@ var StdioServerTransport = class {
18805
18805
  //#region copilot/server/config.ts
18806
18806
  const name = "d5_mcp_review_builtin";
18807
18807
  const report = "report";
18808
- const getHash = "getHash";
18808
+ const getHash = "hash";
18809
18809
  const noMandatory = "dont't call under non-mandatory conditions";
18810
18810
  const file = "./copilot.js";
18811
18811
  const serveFile = join(dirname(fileURLToPath(import.meta.url)), file);
@@ -18836,6 +18836,7 @@ const tools = [
18836
18836
  args: [serveFile, `--customizenv=${JSON.stringify(envUsed)}`],
18837
18837
  tools: ["*"]
18838
18838
  } } }),
18839
+ "--allow-all-paths",
18839
18840
  "--allow-all-tools",
18840
18841
  "--deny-tool",
18841
18842
  "write",
@@ -19056,33 +19057,11 @@ const reportSchema = {
19056
19057
  }).describe("Related JIRA issues")).optional().describe("List of related JIRA issues"),
19057
19058
  risks: array(string().describe(one).describe("A short summary of the risk")).optional().describe("After summarizing all the bugs, identify the main risks that could potentially impact the business."),
19058
19059
  suggestions: array(object({
19059
- details: array(string().describe(one)).describe("Improvement suggestion"),
19060
+ details: string().describe("Suggestions with the same meaning should be stated in one sentence; please do not increase the array length."),
19060
19061
  example: object(code).optional().describe("Pass in when you feel it is necessary to provide code.")
19061
- })).optional().describe("After summarizing all the issues, other code snippets that deserve correction.")
19062
+ })).optional().describe("After gaining a comprehensive understanding of the files involved in the commits, propose suggestions for code corrections beyond the diff.")
19062
19063
  };
19063
19064
 
19064
- //#endregion
19065
- //#region packages/message/dingding.ts
19066
- function send(title, text) {
19067
- if (!envUsed.DINGTALK_WEBHOOK) return Promise.reject(/* @__PURE__ */ new Error("non DINGTALK_WEBHOOK"));
19068
- const urls = envUsed.DINGTALK_WEBHOOK.split(",");
19069
- return Promise.all(urls.map((url) => fetch(url, {
19070
- method: "POST",
19071
- headers: { "Content-Type": "application/json" },
19072
- body: JSON.stringify({
19073
- msgtype: "markdown",
19074
- markdown: {
19075
- title,
19076
- text
19077
- },
19078
- at: {
19079
- atMobiles: ["17856104313"],
19080
- isAtAll: false
19081
- }
19082
- })
19083
- })));
19084
- }
19085
-
19086
19065
  //#endregion
19087
19066
  //#region packages/message/report.ts
19088
19067
  const lastComment = { value: {} };
@@ -19169,14 +19148,14 @@ function distReports(input) {
19169
19148
  gitlabReportMessage += "\n\n### 📈 其他建议\n\n-----\n";
19170
19149
  let withNoFile = "", withFile = "";
19171
19150
  for (const suggestion of suggestions) {
19172
- const { details = [], example } = suggestion;
19151
+ const { details = "", example } = suggestion;
19173
19152
  const { file: file$1 = "", line = "", codeExample = "" } = example || {};
19174
19153
  if (file$1) {
19175
19154
  withFile += `\n-----\n\n#### 文件: ${file$1}`;
19176
19155
  if (line) withFile += `\n- 行数:${line}`;
19177
- withFile += `\n- 详情:\n - ${details.join("\n - ")}`;
19156
+ withFile += `\n- 详情:\n - ${details}`;
19178
19157
  if (codeExample) withFile += `\n${toCode(codeExample)}\n`;
19179
- } else withNoFile += `\n - ${details.join("\n - ")}`;
19158
+ } else withNoFile += `\n - ${details}`;
19180
19159
  }
19181
19160
  gitlabReportMessage += withNoFile + withFile;
19182
19161
  }
@@ -19240,8 +19219,8 @@ function distReports(input) {
19240
19219
  })
19241
19220
  }).then((res) => res.json()).then((res) => {
19242
19221
  lastComment.value = res;
19243
- })] : [() => Promise.reject(/* @__PURE__ */ new Error("⚠️ 当前为 push 事件,无合并请求,无法在 GitLab 中发布报告。报告内容已生成但未发布。"))];
19244
- dingdingReport.report = DINGTALK_WEBHOOK ? [() => send(title, dingdingReportMessage).then((response) => {
19222
+ })] : [() => Promise.reject(/* @__PURE__ */ new Error("⚠️ 报告内容已生成但未发布。"))];
19223
+ dingdingReport.report = DINGTALK_WEBHOOK ? [() => sendding(title, dingdingReportMessage).then((response) => {
19245
19224
  if (!response.ok) throw new Error(response.statusText);
19246
19225
  return response.json();
19247
19226
  }).then((res) => {
@@ -19258,12 +19237,32 @@ async function runReport(input) {
19258
19237
  error: error$1.message || "未知错误"
19259
19238
  })));
19260
19239
  const error = results.find((v) => v.error);
19261
- return error ? error.error : "✅ GitLab MCP Report 执行完成,无问题";
19240
+ return error ? `error: ${error.title}\n${error.error}` : "✅ GitLab MCP Report 执行完成,无问题";
19262
19241
  }
19263
19242
  function toCode(code$1) {
19264
19243
  const ct = code$1.trim();
19265
19244
  return ct.startsWith("```") && ct.endsWith("```") ? code$1 : `\`\`\`\n${code$1}\n\`\`\``;
19266
19245
  }
19246
+ async function sendding(title, text) {
19247
+ if (!envUsed.DINGTALK_WEBHOOK) throw new Error("non DINGTALK_WEBHOOK");
19248
+ let res = new Response();
19249
+ for (const url of envUsed.DINGTALK_WEBHOOK.split(",")) res = await fetch(url, {
19250
+ method: "POST",
19251
+ headers: { "Content-Type": "application/json" },
19252
+ body: JSON.stringify({
19253
+ msgtype: "markdown",
19254
+ markdown: {
19255
+ title,
19256
+ text
19257
+ },
19258
+ at: {
19259
+ atMobiles: ["17856104313"],
19260
+ isAtAll: false
19261
+ }
19262
+ })
19263
+ });
19264
+ return res;
19265
+ }
19267
19266
 
19268
19267
  //#endregion
19269
19268
  //#region packages/message/index.ts
@@ -19271,12 +19270,10 @@ function install(server$1) {
19271
19270
  server$1.registerTool(report, {
19272
19271
  description: noMandatory,
19273
19272
  inputSchema: reportSchema
19274
- }, async (input) => {
19275
- return { content: [{
19276
- type: "text",
19277
- text: await runReport(distReports(input))
19278
- }] };
19279
- });
19273
+ }, async (input) => ({ content: [{
19274
+ type: "text",
19275
+ text: await runReport(distReports(input))
19276
+ }] }));
19280
19277
  }
19281
19278
 
19282
19279
  //#endregion
package/bin/d5cli CHANGED
@@ -7,13 +7,13 @@ import { fileURLToPath } from "node:url";
7
7
 
8
8
  //#region package.json
9
9
  var name$1 = "@d5render/cli";
10
- var version = "0.1.12";
10
+ var version = "0.1.16";
11
11
 
12
12
  //#endregion
13
13
  //#region copilot/server/config.ts
14
14
  const name = "d5_mcp_review_builtin";
15
15
  const report = "report";
16
- const getHash = "getHash";
16
+ const getHash = "hash";
17
17
  const file = "./copilot.js";
18
18
  const serveFile = join(dirname(fileURLToPath(import.meta.url)), file);
19
19
  const envJson = buildEnv();
@@ -43,6 +43,7 @@ const tools = [
43
43
  args: [serveFile, `--customizenv=${JSON.stringify(envUsed)}`],
44
44
  tools: ["*"]
45
45
  } } }),
46
+ "--allow-all-paths",
46
47
  "--allow-all-tools",
47
48
  "--deny-tool",
48
49
  "write",
@@ -193,8 +194,8 @@ function need() {
193
194
 
194
195
  //#endregion
195
196
  //#region copilot/bin/index.ts
196
- const prompt = `call the mcp tool '${name}-${getHash}' to load review commits, if the task encounters an error, throw that, otherwise, you can decide for yourself which tools to use to enrich context and determine whether a specific commit needs to be reviewed.
197
- Then, use chinese as default language to organize the report into JSON format and call the mcp tool '${name}-${report}', please ignore error encountered when calling this and report title should not contain words such as MCP or "中文".`;
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}'`;
198
199
  deploy();
199
200
  if (need()) {
200
201
  install();
@@ -207,22 +208,28 @@ if (need()) {
207
208
  prompt
208
209
  ], {
209
210
  cwd: env.CI_PROJECT_DIR,
211
+ stdio: [
212
+ "inherit",
213
+ "pipe",
214
+ "pipe"
215
+ ],
210
216
  ...platform === "win32" && { windowsHide: true }
211
217
  });
212
- copilot.stdout.on("data", (data) => console.log(data.toString()));
213
- copilot.stderr.on("data", (data) => console.error(data.toString()));
218
+ copilot.stdout.on("data", (chunk) => console.log(String(chunk)));
219
+ copilot.stderr.on("data", (chunk) => console.error(String(chunk)));
214
220
  copilot.on("close", (code) => exit(code));
215
221
  } else console.log("重复提交,进程跳过");
216
222
  function findCopilopt() {
217
223
  let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
218
- if (!copilot) try {
219
- const pathEnv = env.PATH || env.Path || "";
220
- const pathSeparator = platform === "win32" ? ";" : ":";
221
- const npm = pathEnv.split(pathSeparator).find((p) => p.includes("npm"));
222
- if (npm) copilot = join(npm, "node_modules", "@github", "copilot");
223
- } 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
+ }
224
231
  const pkg = join(copilot, "package.json");
225
- if (!existsSync(pkg)) throw new Error("non copilot package found");
232
+ if (!existsSync(pkg)) throw new Error("安装的包找不到正确版本 " + pkg);
226
233
  const copilotPackage = JSON.parse(readFileSync(pkg, "utf8"));
227
234
  const binPath = typeof copilotPackage.bin === "string" ? copilotPackage.bin : copilotPackage.bin?.copilot || copilotPackage.bin?.["@github/copilot"];
228
235
  if (!binPath) throw new Error("non copilot executable found");
@@ -236,5 +243,23 @@ copilot:
236
243
  path: ${copilotPath}`);
237
244
  return copilotPath;
238
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
+ }
239
264
 
240
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.12",
7
+ "version": "0.1.16",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",