@spaceflow/review 0.53.0 → 0.54.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.53.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@0.52.0...@spaceflow/review@0.53.0) (2026-03-02)
4
+
5
+ ### 修复BUG
6
+
7
+ * **core:** 重构配置 Schema 生成逻辑,使用 SpaceflowConfigSchema 作为基础 ([c73eb1c](https://github.com/Lydanne/spaceflow/commit/c73eb1ce5b6f212b8a932a15224db7e63822f8d0))
8
+
9
+ ### 其他修改
10
+
11
+ * **core:** released version 0.19.0 [no ci] ([c8bfe6b](https://github.com/Lydanne/spaceflow/commit/c8bfe6ba20893e2c3cd383ed7e7d3217b0492eb6))
12
+ * **publish:** released version 0.43.0 [no ci] ([1074b9c](https://github.com/Lydanne/spaceflow/commit/1074b9c5fb21a447093ef23300c451d790710b33))
13
+
3
14
  ## [0.52.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@0.51.0...@spaceflow/review@0.52.0) (2026-02-28)
4
15
 
5
16
  ### 测试用例
package/dist/index.js CHANGED
@@ -2505,15 +2505,18 @@ ${fileChanges || "无"}`;
2505
2505
  console.warn("⚠️ 清理旧行级评论失败:", error);
2506
2506
  }
2507
2507
  // 3. 发布新的行级评论(使用 PR Review API)
2508
+ let lineIssues = [];
2508
2509
  let comments = [];
2509
2510
  if (reviewConf.lineComments) {
2510
- comments = result.issues.filter((issue)=>!issue.fixed && issue.valid !== "false").map((issue)=>this.issueToReviewComment(issue)).filter((comment)=>comment !== null);
2511
+ lineIssues = result.issues.filter((issue)=>!issue.fixed && issue.valid !== "false");
2512
+ comments = lineIssues.map((issue)=>this.issueToReviewComment(issue)).filter((comment)=>comment !== null);
2511
2513
  }
2512
2514
  if (comments.length > 0) {
2515
+ const reviewBody = this.buildLineReviewBody(lineIssues);
2513
2516
  try {
2514
2517
  await this.gitProvider.createPullReview(owner, repo, prNumber, {
2515
2518
  event: REVIEW_STATE.COMMENT,
2516
- body: REVIEW_LINE_COMMENTS_MARKER,
2519
+ body: reviewBody,
2517
2520
  comments,
2518
2521
  commit_id: commitId
2519
2522
  });
@@ -2526,7 +2529,7 @@ ${fileChanges || "无"}`;
2526
2529
  try {
2527
2530
  await this.gitProvider.createPullReview(owner, repo, prNumber, {
2528
2531
  event: REVIEW_STATE.COMMENT,
2529
- body: successCount === 0 ? REVIEW_LINE_COMMENTS_MARKER : undefined,
2532
+ body: successCount === 0 ? reviewBody : undefined,
2530
2533
  comments: [
2531
2534
  comment
2532
2535
  ],
@@ -2869,6 +2872,22 @@ ${fileChanges || "无"}`;
2869
2872
  }
2870
2873
  }
2871
2874
  /**
2875
+ * 构建行级评论 Review 的 body(marker + 本轮统计信息)
2876
+ */ buildLineReviewBody(issues) {
2877
+ const errorCount = issues.filter((i)=>i.severity === "error").length;
2878
+ const warnCount = issues.filter((i)=>i.severity === "warn").length;
2879
+ const fileCount = new Set(issues.map((i)=>i.file)).size;
2880
+ const parts = [
2881
+ REVIEW_LINE_COMMENTS_MARKER
2882
+ ];
2883
+ parts.push(`**Spaceflow Review** — ${issues.length} 个问题,涉及 ${fileCount} 个文件`);
2884
+ const badges = [];
2885
+ if (errorCount > 0) badges.push(`🔴 ${errorCount} error`);
2886
+ if (warnCount > 0) badges.push(`🟡 ${warnCount} warn`);
2887
+ if (badges.length > 0) parts.push(badges.join(" "));
2888
+ return parts.join("\n");
2889
+ }
2890
+ /**
2872
2891
  * 将单个 ReviewIssue 转换为 CreatePullReviewComment
2873
2892
  */ issueToReviewComment(issue) {
2874
2893
  const lineNums = this.reviewSpecService.parseLineRange(issue.line);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaceflow/review",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Spaceflow 代码审查插件,使用 LLM 对 PR 代码进行自动审查",
5
5
  "license": "MIT",
6
6
  "author": "Lydanne",
@@ -1969,18 +1969,20 @@ ${fileChanges || "无"}`;
1969
1969
  console.warn("⚠️ 清理旧行级评论失败:", error);
1970
1970
  }
1971
1971
  // 3. 发布新的行级评论(使用 PR Review API)
1972
+ let lineIssues: ReviewIssue[] = [];
1972
1973
  let comments: CreatePullReviewComment[] = [];
1973
1974
  if (reviewConf.lineComments) {
1974
- comments = result.issues
1975
- .filter((issue) => !issue.fixed && issue.valid !== "false")
1975
+ lineIssues = result.issues.filter((issue) => !issue.fixed && issue.valid !== "false");
1976
+ comments = lineIssues
1976
1977
  .map((issue) => this.issueToReviewComment(issue))
1977
1978
  .filter((comment): comment is CreatePullReviewComment => comment !== null);
1978
1979
  }
1979
1980
  if (comments.length > 0) {
1981
+ const reviewBody = this.buildLineReviewBody(lineIssues);
1980
1982
  try {
1981
1983
  await this.gitProvider.createPullReview(owner, repo, prNumber, {
1982
1984
  event: REVIEW_STATE.COMMENT,
1983
- body: REVIEW_LINE_COMMENTS_MARKER,
1985
+ body: reviewBody,
1984
1986
  comments,
1985
1987
  commit_id: commitId,
1986
1988
  });
@@ -1993,7 +1995,7 @@ ${fileChanges || "无"}`;
1993
1995
  try {
1994
1996
  await this.gitProvider.createPullReview(owner, repo, prNumber, {
1995
1997
  event: REVIEW_STATE.COMMENT,
1996
- body: successCount === 0 ? REVIEW_LINE_COMMENTS_MARKER : undefined,
1998
+ body: successCount === 0 ? reviewBody : undefined,
1997
1999
  comments: [comment],
1998
2000
  commit_id: commitId,
1999
2001
  });
@@ -2427,6 +2429,24 @@ ${fileChanges || "无"}`;
2427
2429
  }
2428
2430
  }
2429
2431
 
2432
+ /**
2433
+ * 构建行级评论 Review 的 body(marker + 本轮统计信息)
2434
+ */
2435
+ protected buildLineReviewBody(issues: ReviewIssue[]): string {
2436
+ const errorCount = issues.filter((i) => i.severity === "error").length;
2437
+ const warnCount = issues.filter((i) => i.severity === "warn").length;
2438
+ const fileCount = new Set(issues.map((i) => i.file)).size;
2439
+
2440
+ const parts: string[] = [REVIEW_LINE_COMMENTS_MARKER];
2441
+ parts.push(`**Spaceflow Review** — ${issues.length} 个问题,涉及 ${fileCount} 个文件`);
2442
+ const badges: string[] = [];
2443
+ if (errorCount > 0) badges.push(`🔴 ${errorCount} error`);
2444
+ if (warnCount > 0) badges.push(`🟡 ${warnCount} warn`);
2445
+ if (badges.length > 0) parts.push(badges.join(" "));
2446
+
2447
+ return parts.join("\n");
2448
+ }
2449
+
2430
2450
  /**
2431
2451
  * 将单个 ReviewIssue 转换为 CreatePullReviewComment
2432
2452
  */