@d5render/cli 0.1.6 → 0.1.15

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/README.md CHANGED
@@ -16,10 +16,6 @@ CI MCP 的入口是 [server.ts](.\copilot\server\index.ts) 会经历一轮打包
16
16
  4. 返回 Promise 之后会丢失开发过程中的类型支持,registerTool 调用时可先不写 Promise 看 MCP Server 支持的返回参数
17
17
  5. 其他用例参考 https://github.com/modelcontextprotocol/typescript-sdk/tree/main/src/examples
18
18
 
19
- copilot\CHANGELOG.md:有功能变更的时候写这里,将会
20
- 1. 跟随发包时写进 根CHANGELOG.md
21
- 2. 包第一次安装后会进行通知
22
-
23
19
  # debug
24
20
 
25
21
  项目初始化会多出来 Standalone 的调试配置。
package/bin/copilot.js CHANGED
@@ -18472,7 +18472,7 @@ var StdioServerTransport = class {
18472
18472
  //#region copilot/server/config.ts
18473
18473
  const name = "d5_mcp_review_builtin";
18474
18474
  const report = "report";
18475
- const getHash = "getHash";
18475
+ const getHash = "hash";
18476
18476
  const noMandatory = "dont't call under non-mandatory conditions";
18477
18477
  const file = "./copilot.js";
18478
18478
  const serveFile = join(dirname(fileURLToPath(import.meta.url)), file);
@@ -18503,6 +18503,7 @@ const tools = [
18503
18503
  args: [serveFile, `--customizenv=${JSON.stringify(envUsed)}`],
18504
18504
  tools: ["*"]
18505
18505
  } } }),
18506
+ "--allow-all-paths",
18506
18507
  "--allow-all-tools",
18507
18508
  "--deny-tool",
18508
18509
  "write",
@@ -18723,33 +18724,11 @@ const reportSchema = {
18723
18724
  }).describe("Related JIRA issues")).optional().describe("List of related JIRA issues"),
18724
18725
  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."),
18725
18726
  suggestions: array(object({
18726
- details: array(string().describe(one)).describe("Improvement suggestion"),
18727
+ details: string().describe("Suggestions with the same meaning should be stated in one sentence; please do not increase the array length."),
18727
18728
  example: object(code).optional().describe("Pass in when you feel it is necessary to provide code.")
18728
- })).optional().describe("After summarizing all the issues, other code snippets that deserve correction.")
18729
+ })).optional().describe("After gaining a comprehensive understanding of the files involved in the commits, propose suggestions for code corrections beyond the diff.")
18729
18730
  };
18730
18731
 
18731
- //#endregion
18732
- //#region packages/message/dingding.ts
18733
- function send(title, text) {
18734
- if (!envUsed.DINGTALK_WEBHOOK) return Promise.reject(/* @__PURE__ */ new Error("non DINGTALK_WEBHOOK"));
18735
- const urls = envUsed.DINGTALK_WEBHOOK.split(",");
18736
- return Promise.all(urls.map((url) => fetch(url, {
18737
- method: "POST",
18738
- headers: { "Content-Type": "application/json" },
18739
- body: JSON.stringify({
18740
- msgtype: "markdown",
18741
- markdown: {
18742
- title,
18743
- text
18744
- },
18745
- at: {
18746
- atMobiles: ["17856104313"],
18747
- isAtAll: false
18748
- }
18749
- })
18750
- })));
18751
- }
18752
-
18753
18732
  //#endregion
18754
18733
  //#region packages/message/report.ts
18755
18734
  const lastComment = { value: {} };
@@ -18836,14 +18815,14 @@ function distReports(input) {
18836
18815
  gitlabReportMessage += "\n\n### 📈 其他建议\n\n-----\n";
18837
18816
  let withNoFile = "", withFile = "";
18838
18817
  for (const suggestion of suggestions) {
18839
- const { details = [], example } = suggestion;
18818
+ const { details = "", example } = suggestion;
18840
18819
  const { file: file$1 = "", line: line$1 = "", codeExample = "" } = example || {};
18841
18820
  if (file$1) {
18842
18821
  withFile += `\n-----\n\n#### 文件: ${file$1}`;
18843
18822
  if (line$1) withFile += `\n- 行数:${line$1}`;
18844
- withFile += `\n- 详情:\n - ${details.join("\n - ")}`;
18823
+ withFile += `\n- 详情:\n - ${details}`;
18845
18824
  if (codeExample) withFile += `\n${toCode(codeExample)}\n`;
18846
- } else withNoFile += `\n - ${details.join("\n - ")}`;
18825
+ } else withNoFile += `\n - ${details}`;
18847
18826
  }
18848
18827
  gitlabReportMessage += withNoFile + withFile;
18849
18828
  }
@@ -18907,8 +18886,8 @@ function distReports(input) {
18907
18886
  })
18908
18887
  }).then((res) => res.json()).then((res) => {
18909
18888
  lastComment.value = res;
18910
- })] : [() => Promise.reject(/* @__PURE__ */ new Error("⚠️ 当前为 push 事件,无合并请求,无法在 GitLab 中发布报告。报告内容已生成但未发布。"))];
18911
- dingdingReport.report = DINGTALK_WEBHOOK ? [() => send(title, dingdingReportMessage).then((response) => {
18889
+ })] : [() => Promise.reject(/* @__PURE__ */ new Error("⚠️ 报告内容已生成但未发布。"))];
18890
+ dingdingReport.report = DINGTALK_WEBHOOK ? [() => sendding(title, dingdingReportMessage).then((response) => {
18912
18891
  if (!response.ok) throw new Error(response.statusText);
18913
18892
  return response.json();
18914
18893
  }).then((res) => {
@@ -18925,12 +18904,32 @@ async function runReport(input) {
18925
18904
  error: error$2.message || "未知错误"
18926
18905
  })));
18927
18906
  const error$1 = results.find((v) => v.error);
18928
- return error$1 ? error$1.error : "✅ GitLab MCP Report 执行完成,无问题";
18907
+ return error$1 ? `error: ${error$1.title}\n${error$1.error}` : "✅ GitLab MCP Report 执行完成,无问题";
18929
18908
  }
18930
18909
  function toCode(code$1) {
18931
18910
  const ct = code$1.trim();
18932
18911
  return ct.startsWith("```") && ct.endsWith("```") ? code$1 : `\`\`\`\n${code$1}\n\`\`\``;
18933
18912
  }
18913
+ async function sendding(title, text) {
18914
+ if (!envUsed.DINGTALK_WEBHOOK) throw new Error("non DINGTALK_WEBHOOK");
18915
+ let res = new Response();
18916
+ for (const url of envUsed.DINGTALK_WEBHOOK.split(",")) res = await fetch(url, {
18917
+ method: "POST",
18918
+ headers: { "Content-Type": "application/json" },
18919
+ body: JSON.stringify({
18920
+ msgtype: "markdown",
18921
+ markdown: {
18922
+ title,
18923
+ text
18924
+ },
18925
+ at: {
18926
+ atMobiles: ["17856104313"],
18927
+ isAtAll: false
18928
+ }
18929
+ })
18930
+ });
18931
+ return res;
18932
+ }
18934
18933
 
18935
18934
  //#endregion
18936
18935
  //#region packages/message/index.ts
@@ -18938,12 +18937,10 @@ function install$2(server$1) {
18938
18937
  server$1.registerTool(report, {
18939
18938
  description: noMandatory,
18940
18939
  inputSchema: reportSchema
18941
- }, async (input) => {
18942
- return { content: [{
18943
- type: "text",
18944
- text: await runReport(distReports(input))
18945
- }] };
18946
- });
18940
+ }, async (input) => ({ content: [{
18941
+ type: "text",
18942
+ text: await runReport(distReports(input))
18943
+ }] }));
18947
18944
  }
18948
18945
 
18949
18946
  //#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 = "@d5render/cli";
10
- var version = "0.1.6";
10
+ var version = "0.1.15";
11
11
 
12
12
  //#endregion
13
13
  //#region copilot/server/config.ts
14
14
  const name$1 = "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",
@@ -59,6 +60,54 @@ function buildEnv() {
59
60
  return envJson$1;
60
61
  }
61
62
 
63
+ //#endregion
64
+ //#region copilot/bin/install.ts
65
+ function install() {
66
+ if (!env.CI) return;
67
+ console.log("install copilot...");
68
+ let success = false;
69
+ let local = "";
70
+ try {
71
+ local = execSync("npm list @github/copilot -g --depth=0 --json").toString();
72
+ } catch {
73
+ local = "{}";
74
+ }
75
+ try {
76
+ const localInfo = JSON.parse(local);
77
+ const localVersion = localInfo.dependencies ? localInfo.dependencies?.["@github/copilot"]?.version : void 0;
78
+ if (!localVersion) {
79
+ installCopilot();
80
+ success = true;
81
+ console.log("install copilot success");
82
+ return;
83
+ }
84
+ if (localVersion !== execSync("npm view @github/copilot version --registry=https://registry.npmmirror.com").toString().trim()) {
85
+ execSync("npm uninstall -g @github/copilot --force");
86
+ installCopilot();
87
+ success = true;
88
+ console.log("update copilot success");
89
+ } else {
90
+ success = true;
91
+ console.log("copilot exists and is up-to-date");
92
+ }
93
+ } catch (error) {
94
+ console.error(error);
95
+ }
96
+ if (!success) try {
97
+ console.warn("try to reinstall copilot...");
98
+ installCopilot();
99
+ success = true;
100
+ } catch (error) {
101
+ console.error(error);
102
+ }
103
+ if (success) return;
104
+ console.warn("try to reinstall copilot...");
105
+ installCopilot();
106
+ }
107
+ function installCopilot() {
108
+ execSync("npm install -g @github/copilot --registry=https://registry.npmmirror.com", { stdio: "inherit" });
109
+ }
110
+
62
111
  //#endregion
63
112
  //#region packages/gitlab/url.ts
64
113
  function buildHeaders() {
@@ -92,47 +141,12 @@ const commits = () => {
92
141
  };
93
142
 
94
143
  //#endregion
95
- //#region packages/message/dingding.ts
96
- function send(title, text) {
97
- if (!envUsed.DINGTALK_WEBHOOK) return Promise.reject(/* @__PURE__ */ new Error("non DINGTALK_WEBHOOK"));
98
- const urls = envUsed.DINGTALK_WEBHOOK.split(",");
99
- return Promise.all(urls.map((url) => fetch(url, {
100
- method: "POST",
101
- headers: { "Content-Type": "application/json" },
102
- body: JSON.stringify({
103
- msgtype: "markdown",
104
- markdown: {
105
- title,
106
- text
107
- },
108
- at: {
109
- atMobiles: ["17856104313"],
110
- isAtAll: false
111
- }
112
- })
113
- })));
114
- }
115
-
116
- //#endregion
117
- //#region copilot/bin/deploy.ts
118
- const root = () => {
119
- const dir = env.HOME ?? env.HOMEPATH;
120
- if (!dir) throw new Error("cannot find home directory");
121
- return dir;
122
- };
144
+ //#region copilot/bin/utils.ts
145
+ const root = env.HOME ?? env.HOMEPATH ?? env.LOCALAPPDATA;
146
+ if (!root) throw new Error("cannot find home directory");
123
147
  const cwd = join(dirname(fileURLToPath(import.meta.url)), "../");
124
148
  function deploy() {
125
- if (env.CI) {
126
- const cl = join(cwd, "bin/CHANGELOG.md");
127
- const clt = existsSync(cl) ? readFileSync(cl, "utf8") : "";
128
- const clr = join(cwd, name.split("/").map(() => "..").join("/"), `${name.replaceAll("/", "-")}-notice`);
129
- let need = !!clt;
130
- if (existsSync(clr)) {
131
- if (readFileSync(clr, "utf8") === version) need = false;
132
- }
133
- if (need && env.DINGTALK_WEBHOOK) send("NOTICE", `#### cli upgrade\n\n${clt}\n\n##### [HISTORY CHANGELOG](https://www.npmjs.com/package/${name}/v/${version}?activeTab=code)`).then(() => writeFileSync(clr, version)).catch(() => {});
134
- }
135
- const dir = join(root(), ".copilot/skills/codereview");
149
+ const dir = join(root, ".copilot/skills/codereview");
136
150
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
137
151
  const skillRoot = join(cwd, ".skills/review");
138
152
  const versiono = readFileSync(join(cwd, ".skills/review/version"), "utf8");
@@ -142,12 +156,9 @@ function deploy() {
142
156
  const instructionsRoot = join(cwd, ".github/instructions");
143
157
  readdirSync(instructionsRoot).forEach((instruction) => copyFileSync(join(instructionsRoot, instruction), join(dir, instruction)));
144
158
  }
145
-
146
- //#endregion
147
- //#region copilot/bin/canireview.ts
148
- function canireview() {
149
- const { CI_MERGE_REQUEST_IID, CI_COMMIT_SHA, CI_PROJECT_PATH } = envUsed;
150
- const file$1 = join(root(), ".ci-ai-review", CI_PROJECT_PATH || "defaults");
159
+ function need() {
160
+ const { CI_MERGE_REQUEST_IID, CI_COMMIT_SHA, CI_PROJECT_PATH } = env;
161
+ const file$1 = join(root, ".ci-ai-review", CI_PROJECT_PATH || "defaults");
151
162
  const dir = dirname(file$1);
152
163
  if (CI_MERGE_REQUEST_IID) {
153
164
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
@@ -181,60 +192,12 @@ function canireview() {
181
192
  return !yes;
182
193
  }
183
194
 
184
- //#endregion
185
- //#region copilot/bin/install.ts
186
- function install() {
187
- if (!env.CI) return;
188
- console.log("install copilot...");
189
- let success = false;
190
- let local = "";
191
- try {
192
- local = execSync("npm list @github/copilot -g --depth=0 --json").toString();
193
- } catch {
194
- local = "{}";
195
- }
196
- try {
197
- const localInfo = JSON.parse(local);
198
- const localVersion = localInfo.dependencies ? localInfo.dependencies?.["@github/copilot"]?.version : void 0;
199
- if (!localVersion) {
200
- installCopilot();
201
- success = true;
202
- console.log("install copilot success");
203
- return;
204
- }
205
- if (localVersion !== execSync("npm view @github/copilot version --registry=https://registry.npmmirror.com").toString().trim()) {
206
- execSync("npm uninstall -g @github/copilot --force");
207
- installCopilot();
208
- success = true;
209
- console.log("update copilot success");
210
- } else {
211
- success = true;
212
- console.log("copilot exists and is up-to-date");
213
- }
214
- } catch (error) {
215
- console.error(error);
216
- }
217
- if (!success) try {
218
- console.warn("try to reinstall copilot...");
219
- installCopilot();
220
- success = true;
221
- } catch (error) {
222
- console.error(error);
223
- }
224
- if (success) return;
225
- console.warn("try to reinstall copilot...");
226
- installCopilot();
227
- }
228
- function installCopilot() {
229
- execSync("npm install -g @github/copilot --registry=https://registry.npmmirror.com", { stdio: "inherit" });
230
- }
231
-
232
195
  //#endregion
233
196
  //#region copilot/bin/index.ts
234
- const prompt = `call the mcp tool '${name$1}-${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.
235
- Then, use chinese as default language to organize the report into JSON format and call the mcp tool '${name$1}-${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$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}'`;
236
199
  deploy();
237
- if (canireview()) {
200
+ if (need()) {
238
201
  install();
239
202
  const copilot = spawn("node", [
240
203
  findCopilopt(),
@@ -245,12 +208,17 @@ if (canireview()) {
245
208
  prompt
246
209
  ], {
247
210
  cwd: env.CI_PROJECT_DIR,
211
+ stdio: [
212
+ "inherit",
213
+ "pipe",
214
+ "pipe"
215
+ ],
248
216
  ...platform === "win32" && { windowsHide: true }
249
217
  });
250
- copilot.stdout.on("data", (data) => console.log(data.toString()));
251
- 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)));
252
220
  copilot.on("close", (code) => exit(code));
253
- }
221
+ } else console.log("重复提交,进程跳过");
254
222
  function findCopilopt() {
255
223
  let copilot = execSync("npm list @github/copilot -g -p").toString().trim();
256
224
  if (!copilot) try {
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.6",
7
+ "version": "0.1.15",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.25.1",
10
10
  "@types/node": "^25.0.3",
@@ -19,8 +19,8 @@
19
19
  ".github/instructions/review.instructions.md",
20
20
  ".github/instructions/severity.instructions.md",
21
21
  ".skills/review",
22
- "bin",
23
- "CHANGELOG.md"
22
+ "bin/copilot.js",
23
+ "bin/d5cli"
24
24
  ],
25
25
  "bin": {
26
26
  "d5cli": "bin/d5cli"
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- ## 0.1.4 (2026-01-08)
2
- 评审流程转移至skills内 codereview 0.0.1
3
- 增加去重功能
4
-
5
-
6
- ## 0.1.0 (2026-01-07)
7
- 基础评审能力
package/bin/CHANGELOG.md DELETED
@@ -1,2 +0,0 @@
1
- 评审流程转移至skills内 codereview 0.0.1
2
- 增加去重功能