@d5render/cli 0.0.88 → 0.0.90

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 (2) hide show
  1. package/bin/copilot.js +64 -62
  2. package/package.json +1 -1
package/bin/copilot.js CHANGED
@@ -14797,10 +14797,10 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
14797
14797
  Ajv$2.ValidationError = validation_error_1$1.default;
14798
14798
  Ajv$2.MissingRefError = ref_error_1$3.default;
14799
14799
  exports.default = Ajv$2;
14800
- function checkOptions(checkOpts, options, msg, log = "error") {
14800
+ function checkOptions(checkOpts, options, msg, log$1 = "error") {
14801
14801
  for (const key in checkOpts) {
14802
14802
  const opt = key;
14803
- if (opt in options) this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`);
14803
+ if (opt in options) this.logger[log$1](`${msg}: option ${key}. ${checkOpts[opt]}`);
14804
14804
  }
14805
14805
  }
14806
14806
  function getSchEnv(keyRef) {
@@ -18510,6 +18510,53 @@ const config = JSON.stringify({ mcpServers: { [name]: {
18510
18510
  tools: ["*"]
18511
18511
  } } });
18512
18512
 
18513
+ //#endregion
18514
+ //#region packages/builtin/config.ts
18515
+ function log(message) {
18516
+ process.stderr.write(`[LOG] ${message}\n`);
18517
+ }
18518
+ const reportSchema = {
18519
+ title: string().optional().describe("The title of the report"),
18520
+ summary: string().optional().describe("Overall summary of the changes"),
18521
+ relatedJIRAs: array(object({
18522
+ key: string().describe("JIRA issue key, e.g., 'FUS-123'"),
18523
+ summary: string().describe("Summary of the JIRA issue")
18524
+ }).describe("Related JIRA issues")).optional().describe("List of related JIRA issues"),
18525
+ severityIssues: array(object({
18526
+ severity: string().optional().describe("Bug severity levels, such as CRITICAL, HIGH, MEDIUM, LOW."),
18527
+ commitSha: string().optional().describe("The commit SHA associated with the issue"),
18528
+ commitTitle: string().optional().describe("The commit title associated with the issue"),
18529
+ file: string().optional().describe("The file path where the issue is found"),
18530
+ line: string().optional().describe("Line number, e.g., '1-345' pr '205' or '17,35', **must** provide the line of final file"),
18531
+ title: string().optional().describe("A short title for the issue"),
18532
+ details: array(string()).optional().describe("Details about the issue"),
18533
+ suggestions: array(string()).optional().describe("Improvement suggestion"),
18534
+ codeExample: string().optional().describe(`Code modification suggestions, recommended to use code in diff format, like: \`\`\`
18535
+ while (condition) {
18536
+ unchanged line;
18537
+ - remove this;
18538
+ + replace it with this;
18539
+ + and this;
18540
+ but keep this the same;
18541
+ }\`\`\`.`)
18542
+ })).optional().describe("List all bugs, Please order by 'severity' sort them from heaviest to lightest."),
18543
+ mainRisks: array(string().describe("Main risk item")).optional().describe("List of main risks"),
18544
+ nextActions: array(string().describe("Description of the action item")).optional().describe("List suggestions for improvement")
18545
+ };
18546
+ function commonURL() {
18547
+ const { CI_SERVER_URL, CI_PROJECT_PATH, CI_MERGE_REQUEST_IID, CI_COMMIT_SHA } = envUsed;
18548
+ if (!CI_SERVER_URL || !CI_PROJECT_PATH) return {};
18549
+ if (CI_MERGE_REQUEST_IID) return {
18550
+ url: `${CI_SERVER_URL}/${CI_PROJECT_PATH}/-/merge_requests/${CI_MERGE_REQUEST_IID}`,
18551
+ type: "merge_request"
18552
+ };
18553
+ if (CI_COMMIT_SHA) return {
18554
+ url: `${CI_SERVER_URL}/${CI_PROJECT_PATH}/-/commit/${CI_COMMIT_SHA}`,
18555
+ type: "commit"
18556
+ };
18557
+ return {};
18558
+ }
18559
+
18513
18560
  //#endregion
18514
18561
  //#region packages/gitlab/config.ts
18515
18562
  const canireview = "can-i-review";
@@ -18545,7 +18592,7 @@ const postComments = (report$1) => {
18545
18592
  const url = commonMergeURL();
18546
18593
  const { title = "代码审查报告", summary, severityIssues = [], mainRisks = [], nextActions = [] } = report$1;
18547
18594
  if (severityIssues.length === 0) {
18548
- console.log(`[GitLab] 无问题,跳过提交`);
18595
+ log("GitLab: 无问题,跳过提交");
18549
18596
  return Promise.resolve({ content: [{
18550
18597
  type: "text",
18551
18598
  text: "✅ GitLab MCP Report 执行完成,无问题"
@@ -18603,17 +18650,17 @@ const postComments = (report$1) => {
18603
18650
  }
18604
18651
  if (nextActions.length > 0) message += "\n\n### 📈 其他建议\n\n-----\n - " + nextActions.join("\n - ");
18605
18652
  if (!url) {
18606
- console.log(`[GitLab] 跳过提交 - push 事件,无合并请求`);
18653
+ log("GitLab: 跳过提交 - push 事件,无合并请求");
18607
18654
  return Promise.resolve({ content: [{
18608
18655
  type: "text",
18609
18656
  text: "⚠️ 当前为 push 事件,无合并请求,无法在 GitLab 中发布报告。报告内容已生成但未发布。"
18610
18657
  }] });
18611
18658
  }
18612
- console.log(`[GitLab] 开始提交 - 行内评论: ${commitTasks.length} 条, 总结报告: 1 条`);
18659
+ log(`GitLab: 开始提交 - 行内评论: ${commitTasks.length} 条, 总结报告: 1 条`);
18613
18660
  return Promise.allSettled(commitTasks.map((task) => task())).then((results) => {
18614
18661
  const successCount = results.filter((r) => r.status === "fulfilled").length;
18615
18662
  const failCount = results.filter((r) => r.status === "rejected").length;
18616
- if (commitTasks.length > 0) console.log(`[GitLab] 行内评论提交完成 - 成功: ${successCount}, 失败: ${failCount}`);
18663
+ if (commitTasks.length > 0) log(`GitLab: 行内评论完成 - 成功: ${successCount}, 失败: ${failCount}`);
18617
18664
  return fetch(url + `/notes`, {
18618
18665
  method: "POST",
18619
18666
  headers: commonHeaders$1(),
@@ -18621,13 +18668,13 @@ const postComments = (report$1) => {
18621
18668
  });
18622
18669
  }).then((res) => res.json()).then((res) => {
18623
18670
  lastComment.value = res;
18624
- console.log(`[GitLab] 总结报告已发布 - MR: ${url}`);
18671
+ log(`GitLab: 总结报告已发布`);
18625
18672
  return { content: [{
18626
18673
  type: "text",
18627
18674
  text: "✅ GitLab 代码审查报告已发布。"
18628
18675
  }] };
18629
18676
  }).catch((error$1) => {
18630
- console.error(`[GitLab] 提交失败 - ${error$1.message || error$1.reason || "未知错误"}`);
18677
+ log(`GitLab: 提交失败 - ${error$1.message || error$1.reason || "未知错误"}`);
18631
18678
  return {
18632
18679
  content: [{
18633
18680
  type: "text",
@@ -18704,56 +18751,12 @@ function installGitlab(server$1) {
18704
18751
  }, getMergeInfomation);
18705
18752
  }
18706
18753
 
18707
- //#endregion
18708
- //#region packages/builtin/config.ts
18709
- const reportSchema = {
18710
- title: string().optional().describe("The title of the report"),
18711
- summary: string().optional().describe("Overall summary of the changes"),
18712
- relatedJIRAs: array(object({
18713
- key: string().describe("JIRA issue key, e.g., 'FUS-123'"),
18714
- summary: string().describe("Summary of the JIRA issue")
18715
- }).describe("Related JIRA issues")).optional().describe("List of related JIRA issues"),
18716
- severityIssues: array(object({
18717
- severity: string().optional().describe("Bug severity levels, such as CRITICAL, HIGH, MEDIUM, LOW."),
18718
- commitSha: string().optional().describe("The commit SHA associated with the issue"),
18719
- commitTitle: string().optional().describe("The commit title associated with the issue"),
18720
- file: string().optional().describe("The file path where the issue is found"),
18721
- line: string().optional().describe("Line number, e.g., '1-345' pr '205' or '17,35', **must** provide the line of final file"),
18722
- title: string().optional().describe("A short title for the issue"),
18723
- details: array(string()).optional().describe("Details about the issue"),
18724
- suggestions: array(string()).optional().describe("Improvement suggestion"),
18725
- codeExample: string().optional().describe(`Code modification suggestions, recommended to use code in diff format, like: \`\`\`
18726
- while (condition) {
18727
- unchanged line;
18728
- - remove this;
18729
- + replace it with this;
18730
- + and this;
18731
- but keep this the same;
18732
- }\`\`\`.`)
18733
- })).optional().describe("List all bugs, Please order by 'severity' sort them from heaviest to lightest."),
18734
- mainRisks: array(string().describe("Main risk item")).optional().describe("List of main risks"),
18735
- nextActions: array(string().describe("Description of the action item")).optional().describe("List suggestions for improvement")
18736
- };
18737
- function commonURL() {
18738
- const { CI_SERVER_URL, CI_PROJECT_PATH, CI_MERGE_REQUEST_IID, CI_COMMIT_SHA } = envUsed;
18739
- if (!CI_SERVER_URL || !CI_PROJECT_PATH) return {};
18740
- if (CI_MERGE_REQUEST_IID) return {
18741
- url: `${CI_SERVER_URL}/${CI_PROJECT_PATH}/-/merge_requests/${CI_MERGE_REQUEST_IID}`,
18742
- type: "merge_request"
18743
- };
18744
- if (CI_COMMIT_SHA) return {
18745
- url: `${CI_SERVER_URL}/${CI_PROJECT_PATH}/-/commit/${CI_COMMIT_SHA}`,
18746
- type: "commit"
18747
- };
18748
- return {};
18749
- }
18750
-
18751
18754
  //#endregion
18752
18755
  //#region packages/builtin/dingding.ts
18753
18756
  const postComments$1 = (report$1) => {
18754
18757
  const { CI_PROJECT_NAME = "", CI_COMMIT_SHA = "", CI_COMMIT_AUTHOR = "", CI_COMMIT_AUTHOR_EMAIL = "", JIRA_BASE_URL, CI_MERGE_REQUEST_IID, DINGTALK_WEBHOOK } = envUsed;
18755
18758
  if (!DINGTALK_WEBHOOK) {
18756
- console.log(`[钉钉] 跳过推送 - 无 Webhook 配置`);
18759
+ log("钉钉: 跳过推送 - 无 Webhook 配置");
18757
18760
  return { content: [{
18758
18761
  type: "text",
18759
18762
  text: "✅ 无 DingDing Webhook 配置,跳过推送。"
@@ -18761,7 +18764,7 @@ const postComments$1 = (report$1) => {
18761
18764
  }
18762
18765
  const { title = "代码审查报告", mainRisks = [], relatedJIRAs = [], severityIssues = [] } = report$1;
18763
18766
  if (severityIssues.length === 0) {
18764
- console.log(`[钉钉] 跳过推送 - 无问题`);
18767
+ log("钉钉: 跳过推送 - 无问题");
18765
18768
  return { content: [{
18766
18769
  type: "text",
18767
18770
  text: "✅ 无问题,跳过DingDing推送。"
@@ -18820,7 +18823,7 @@ const postComments$1 = (report$1) => {
18820
18823
  hashLength++;
18821
18824
  }
18822
18825
  if (relatedJIRAs.length > 0) message += `\n\n\n\n#### 🔗 关联 JIRA\n ${relatedJIRAs.map((v) => `[${v.key}](${JIRA_BASE_URL}/browse/${v.key}): ${v.summary}`).join("\n\n")}`;
18823
- console.log(`[钉钉] 开始推送 - 问题数: ${severityIssues.length}, 项目: ${CI_PROJECT_NAME}`);
18826
+ log(`钉钉: 开始推送 - 问题数: ${severityIssues.length}, 项目: ${CI_PROJECT_NAME}`);
18824
18827
  return fetch(DINGTALK_WEBHOOK, {
18825
18828
  method: "POST",
18826
18829
  headers: { "Content-Type": "application/json" },
@@ -18840,14 +18843,14 @@ const postComments$1 = (report$1) => {
18840
18843
  return response.json();
18841
18844
  }).then((res) => {
18842
18845
  if (res.errcode === 0) {
18843
- console.log(`[钉钉] 推送成功`);
18846
+ log("钉钉: 推送成功");
18844
18847
  return { content: [{
18845
18848
  type: "text",
18846
18849
  text: "✅ DingDing 代码审查报告已推送。"
18847
18850
  }] };
18848
18851
  }
18849
18852
  if (res.errcode === 31e4) {
18850
- console.log(`[钉钉] 推送成功,但被关键词拦截`);
18853
+ log("钉钉: 推送成功,但被关键词拦截");
18851
18854
  return { content: [{
18852
18855
  type: "text",
18853
18856
  text: "✅ DingDing 代码审查报告已推送,但被屏蔽关键词拦截。"
@@ -18855,7 +18858,7 @@ const postComments$1 = (report$1) => {
18855
18858
  }
18856
18859
  throw new Error("Post comments to DingTalk with error code:" + res.errcode + ", message: " + res.errmsg);
18857
18860
  }).catch((error$1) => {
18858
- console.error(`[钉钉] 推送失败 - ${error$1.message || "Post comments to DingTalk failed"}`);
18861
+ log(`钉钉: 推送失败 - ${error$1.message || "Post comments to DingTalk failed"}`);
18859
18862
  return {
18860
18863
  content: [{
18861
18864
  type: "text",
@@ -18918,12 +18921,11 @@ function install(server$1) {
18918
18921
  description: noMandatory,
18919
18922
  inputSchema: reportSchema
18920
18923
  }, async (...args) => {
18921
- const issueCount = args[0]?.severityIssues?.length || 0;
18922
- console.log(`[报告提交] 开始提交代码审查报告,共 ${issueCount} 个问题`);
18924
+ log(`报告提交开始 - 问题数: ${args[0]?.severityIssues?.length || 0}`);
18923
18925
  const git = await postComments(...args);
18924
18926
  const ding = await postComments$1(...args);
18925
18927
  if (git.isError || ding.isError) {
18926
- console.error(`[报告提交] 提交失败 - GitLab: ${git.isError ? "失败" : "成功"}, 钉钉: ${ding.isError ? "失败" : "成功"}`);
18928
+ log(`报告提交失败 - GitLab: ${git.isError ? "失败" : "成功"}, 钉钉: ${ding.isError ? "失败" : "成功"}`);
18927
18929
  return {
18928
18930
  content: [{
18929
18931
  type: "text",
@@ -18932,7 +18934,7 @@ function install(server$1) {
18932
18934
  isError: true
18933
18935
  };
18934
18936
  }
18935
- console.log(`[报告提交] 提交成功 - GitLab: 已发布, 钉钉: 已推送`);
18937
+ log(`报告提交成功 - GitLab: 已发布, 钉钉: 已推送`);
18936
18938
  return { content: [{
18937
18939
  type: "text",
18938
18940
  text: args[0]?.summary || ""
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "license": "MIT",
5
5
  "author": "jasirou",
6
6
  "main": "./bin/d5cli",
7
- "version": "0.0.88",
7
+ "version": "0.0.90",
8
8
  "devDependencies": {
9
9
  "@modelcontextprotocol/sdk": "^1.24.3",
10
10
  "@types/node": "22.18.1",