@d5render/cli 0.1.16 → 0.1.18
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/.skills/review/SKILL.md +2 -3
- package/.skills/review/version +1 -1
- package/bin/copilot.js +29 -43
- package/bin/d5cli +6 -3
- package/package.json +1 -1
package/.skills/review/SKILL.md
CHANGED
|
@@ -6,6 +6,5 @@ description: When the task is code-review, please follow this document to procee
|
|
|
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
8
|
3. integrate your understanding of code-review to process task.
|
|
9
|
-
4.
|
|
10
|
-
5.
|
|
11
|
-
6. output all the context read, especially the introductory document.
|
|
9
|
+
4. the merge request is only for change reference and is not the main objective of the review; therefore, it does not require in-depth analysis.
|
|
10
|
+
5. pay attention to the issue tracking description in the context, and try to use relevant tools to obtain more context.
|
package/.skills/review/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.2
|
package/bin/copilot.js
CHANGED
|
@@ -18918,10 +18918,6 @@ const getCommits = () => {
|
|
|
18918
18918
|
text: `latest commit`
|
|
18919
18919
|
}] };
|
|
18920
18920
|
};
|
|
18921
|
-
const canIReview = ({ B }) => ({ content: [{
|
|
18922
|
-
type: "text",
|
|
18923
|
-
text: B.startsWith("Merge") ? "no" : "yes"
|
|
18924
|
-
}] });
|
|
18925
18921
|
const getMergeInfomation = () => {
|
|
18926
18922
|
const { CI_MERGE_REQUEST_DESCRIPTION, CI_MERGE_REQUEST_TITLE } = envUsed;
|
|
18927
18923
|
if (CI_MERGE_REQUEST_DESCRIPTION || CI_MERGE_REQUEST_TITLE) return { content: [{
|
|
@@ -18937,22 +18933,10 @@ const getMergeInfomation = () => {
|
|
|
18937
18933
|
};
|
|
18938
18934
|
};
|
|
18939
18935
|
|
|
18940
|
-
//#endregion
|
|
18941
|
-
//#region packages/gitlab/schema.ts
|
|
18942
|
-
const canireview = "can-i-review";
|
|
18943
|
-
const canireviewSchema = {
|
|
18944
|
-
hash: string().describe("commit hash"),
|
|
18945
|
-
B: string().describe("the commit directions logged by `git log --format=%B -n 1 <hash>`")
|
|
18946
|
-
};
|
|
18947
|
-
|
|
18948
18936
|
//#endregion
|
|
18949
18937
|
//#region packages/gitlab/index.ts
|
|
18950
18938
|
function install$2(server$1) {
|
|
18951
18939
|
server$1.registerTool(getHash, { description: noMandatory }, getCommits);
|
|
18952
|
-
server$1.registerTool(canireview, {
|
|
18953
|
-
inputSchema: canireviewSchema,
|
|
18954
|
-
description: "Determine whether the commit with the given hash needs to be reviewed based on its commit message."
|
|
18955
|
-
}, canIReview);
|
|
18956
18940
|
server$1.registerTool("getMergeDescription", {
|
|
18957
18941
|
title: "merge pipeline description",
|
|
18958
18942
|
description: "When review task from `merge pipeline`, get the merge request description."
|
|
@@ -19043,9 +19027,9 @@ const reportSchema = {
|
|
|
19043
19027
|
summary: array(string().describe(one)).optional().describe("Regarding the description of the current review, please summarize the main logic of the submission as concisely as possible."),
|
|
19044
19028
|
issues: array(object({
|
|
19045
19029
|
severity: string().optional().describe("Bug severity levels, such as CRITICAL, HIGH, MEDIUM, LOW."),
|
|
19046
|
-
|
|
19030
|
+
commitTitle: string().describe("The commit title associated with the issue"),
|
|
19031
|
+
commitAuthor: string().describe("The commit latest author associated with the issue"),
|
|
19047
19032
|
commitSha: string().optional().describe("The commit SHA associated with the issue"),
|
|
19048
|
-
commitTitle: string().optional().describe("The commit title associated with the issue"),
|
|
19049
19033
|
title: string().optional().describe("A short title for the issue"),
|
|
19050
19034
|
details: array(string()).optional().describe("Details about the issue"),
|
|
19051
19035
|
suggestions: array(string()).optional().describe("Improvement suggestion"),
|
|
@@ -19102,23 +19086,6 @@ function distReports(input) {
|
|
|
19102
19086
|
const mergeURL = pipelineMerge();
|
|
19103
19087
|
const linkBase = visitCommit();
|
|
19104
19088
|
const commitsURL = commits();
|
|
19105
|
-
for (const issue$1 of issues) {
|
|
19106
|
-
const { file: file$1 = "NON", commitSha = "", severity = "NON", commitSha: NCommitSha = "NON" } = issue$1;
|
|
19107
|
-
const fileList = fileMap.get(file$1) || [], issueList = severityMap.get(severity) || [];
|
|
19108
|
-
fileList.push(issue$1);
|
|
19109
|
-
fileMap.set(file$1, fileList);
|
|
19110
|
-
issueList.push(issue$1);
|
|
19111
|
-
severityMap.set(severity, issueList);
|
|
19112
|
-
if (commitSha) commitsSet.add(commitSha);
|
|
19113
|
-
commitsMap.set(NCommitSha, issue$1);
|
|
19114
|
-
distCommitComments(issue$1);
|
|
19115
|
-
}
|
|
19116
|
-
let gitlabReportMessage = `## 📖 ${title}\n`;
|
|
19117
|
-
if (summary && summary.length > 0) gitlabReportMessage += `> ${summary.join(" \n> ")}\n\n`;
|
|
19118
|
-
if (risks.length > 0) gitlabReportMessage += "\n**📋 主要风险**\n - " + risks.join("\n - ");
|
|
19119
|
-
gitlabReportMessage += `\n### 🐛 问题列表`;
|
|
19120
|
-
const cms = [...commitsSet].map((v) => `[${v.slice(0, 8)}](${linkBase}/${v})`);
|
|
19121
|
-
if (cms.length > 0) gitlabReportMessage += `\n-----\n> 含问题的commits:${cms.join(",")}\n\n`;
|
|
19122
19089
|
function distCommitComments({ file: file$1, commitSha, severity = "NON", line = "", details = [], suggestions: suggestions$1 = [], codeExample = "" }) {
|
|
19123
19090
|
if (commitSha && file$1) {
|
|
19124
19091
|
const lines = line.split(",").map((line$1) => {
|
|
@@ -19134,14 +19101,33 @@ function distReports(input) {
|
|
|
19134
19101
|
});
|
|
19135
19102
|
}
|
|
19136
19103
|
}
|
|
19137
|
-
for (const
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19104
|
+
for (const issue$1 of issues) {
|
|
19105
|
+
const { file: file$1 = "NON", commitSha = "", severity = "NON", commitSha: NCommitSha = "NON" } = issue$1;
|
|
19106
|
+
const fileList = fileMap.get(file$1) || [], issueList = severityMap.get(severity) || [];
|
|
19107
|
+
fileList.push(issue$1);
|
|
19108
|
+
fileMap.set(file$1, fileList);
|
|
19109
|
+
issueList.push(issue$1);
|
|
19110
|
+
severityMap.set(severity, issueList);
|
|
19111
|
+
if (commitSha) commitsSet.add(commitSha);
|
|
19112
|
+
commitsMap.set(NCommitSha, issue$1);
|
|
19113
|
+
distCommitComments(issue$1);
|
|
19114
|
+
}
|
|
19115
|
+
let gitlabReportMessage = `## 📖 ${title}\n`;
|
|
19116
|
+
if (summary && summary.length > 0) gitlabReportMessage += `> ${summary.join(" \n> ")}\n\n`;
|
|
19117
|
+
if (risks.length > 0) gitlabReportMessage += "\n**📋 主要风险**\n - " + risks.join("\n - ");
|
|
19118
|
+
if (fileMap.size > 0 || commitsSet.size > 0) {
|
|
19119
|
+
gitlabReportMessage += `\n### 🐛 问题列表`;
|
|
19120
|
+
const cms = [...commitsSet].map((v) => `[${v.slice(0, 8)}](${linkBase}/${v})`);
|
|
19121
|
+
if (cms.length > 0) gitlabReportMessage += `\n-----\n> 含问题的commits:${cms.join(",")}\n\n`;
|
|
19122
|
+
for (const [file$1, fileIssues] of fileMap) {
|
|
19123
|
+
gitlabReportMessage += `\n-----\n\n#### 文件: ${file$1}`;
|
|
19124
|
+
for (const issue$1 of fileIssues) {
|
|
19125
|
+
const { severity = "NON", line = "NON", title: issueTitle = "NON", details = [], suggestions: issueSuggestions = [], codeExample = "" } = issue$1;
|
|
19126
|
+
gitlabReportMessage += `\n\n**${severity}** | ${line} | ${issueTitle}`;
|
|
19127
|
+
gitlabReportMessage += `\n- 详情:\n - ${details.join("\n - ")}`;
|
|
19128
|
+
gitlabReportMessage += `\n- 建议:\n - ${issueSuggestions.join("\n - ")}`;
|
|
19129
|
+
if (codeExample) gitlabReportMessage += `\n${toCode(codeExample)}\n`;
|
|
19130
|
+
}
|
|
19145
19131
|
}
|
|
19146
19132
|
}
|
|
19147
19133
|
if (suggestions.length > 0) {
|
package/bin/d5cli
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawn } from "node:child_process";
|
|
3
|
-
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { argv, env, exit, platform } from "node:process";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
//#region package.json
|
|
9
9
|
var name$1 = "@d5render/cli";
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.18";
|
|
11
11
|
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region copilot/server/config.ts
|
|
@@ -142,10 +142,13 @@ const commits = () => {
|
|
|
142
142
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region copilot/bin/utils.ts
|
|
145
|
-
const
|
|
145
|
+
const HOME = env.HOME ?? env.HOMEPATH;
|
|
146
|
+
const root = HOME ?? env.LOCALAPPDATA;
|
|
146
147
|
if (!root) throw new Error("cannot find home directory");
|
|
147
148
|
const cwd = join(dirname(fileURLToPath(import.meta.url)), "../");
|
|
148
149
|
function deploy() {
|
|
150
|
+
const config = join(HOME, ".copilot/config.json");
|
|
151
|
+
if (existsSync(config)) rmSync(config);
|
|
149
152
|
const dir = join(root, ".copilot/skills/codereview");
|
|
150
153
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
151
154
|
const skillRoot = join(cwd, ".skills/review");
|