@spaceflow/review 0.70.0 → 0.72.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,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.71.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@0.70.0...@spaceflow/review@0.71.0) (2026-04-02)
4
+
5
+ ### 新特性
6
+
7
+ * **review:** 添加 skipDuplicateWorkflow 和 autoApprove 配置选项支持 ([3ede6e3](https://github.com/Lydanne/spaceflow/commit/3ede6e30d89ced5ef57e154e42f723da5e3c5d92))
8
+
9
+ ### 修复BUG
10
+
11
+ * **review-summary:** 在用户名前添加 @ 符号以支持用户提及 ([a4aa03f](https://github.com/Lydanne/spaceflow/commit/a4aa03f377bb26e1fa7adc90568d89f2bb9936ce))
12
+ * **review-summary:** 在用户名前添加 @ 符号以支持用户提及 ([fd83df4](https://github.com/Lydanne/spaceflow/commit/fd83df4a647e6c4d42617b44fdaf0ebbec7892e4))
13
+
14
+ ### 其他修改
15
+
16
+ * **review-summary:** released version 0.38.0 [no ci] ([119c2a8](https://github.com/Lydanne/spaceflow/commit/119c2a8861a02e68a4e31135aa88799fe63d29ff))
17
+ * **review-summary:** released version 0.39.0 [no ci] ([40fbd43](https://github.com/Lydanne/spaceflow/commit/40fbd435b3895b22b04dce7cce4c487f0edbdd2a))
18
+ * **scripts:** released version 0.29.0 [no ci] ([496843a](https://github.com/Lydanne/spaceflow/commit/496843add224941b646837d8fc8ec03f790530fc))
19
+ * **shell:** released version 0.29.0 [no ci] ([368f8c8](https://github.com/Lydanne/spaceflow/commit/368f8c83ae3e485df5bfd4128e46aef4a6689eb0))
20
+
21
+ ## [0.70.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@0.69.0...@spaceflow/review@0.70.0) (2026-04-02)
22
+
23
+ ### 新特性
24
+
25
+ * **review:** 新增自动批准功能,当所有问题解决时自动提交 APPROVE review ([4155342](https://github.com/Lydanne/spaceflow/commit/4155342511f76d6cd9001a14a144fce55a7a8946))
26
+ * **review:** 添加 workflow 重复运行检测,防止同一 PR 并发审查 ([a3777af](https://github.com/Lydanne/spaceflow/commit/a3777affb10b6fb4f88a83660ce2a81f9f2d6498))
27
+
28
+ ### 其他修改
29
+
30
+ * **core:** released version 0.27.0 [no ci] ([053d624](https://github.com/Lydanne/spaceflow/commit/053d624997b04e47537dac4ca0c7a99ed4a4cd36))
31
+ * **publish:** released version 0.51.0 [no ci] ([1fbe22a](https://github.com/Lydanne/spaceflow/commit/1fbe22a538cdcb6264e3937c5706d75f67fa4f2a))
32
+ * **review-summary:** released version 0.37.0 [no ci] ([455c581](https://github.com/Lydanne/spaceflow/commit/455c58140def453d95c8fc85b1ea8fde39037abc))
33
+
3
34
  ## [0.69.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@0.68.0...@spaceflow/review@0.69.0) (2026-03-04)
4
35
 
5
36
  ### 代码重构
package/dist/index.js CHANGED
@@ -2024,7 +2024,9 @@ class ReviewService {
2024
2024
  showAll: options.showAll ?? false,
2025
2025
  flush: options.flush ?? false,
2026
2026
  eventAction: options.eventAction,
2027
- localMode
2027
+ localMode,
2028
+ skipDuplicateWorkflow: options.skipDuplicateWorkflow ?? reviewConf.skipDuplicateWorkflow ?? false,
2029
+ autoApprove: options.autoApprove ?? reviewConf.autoApprove ?? false
2028
2030
  };
2029
2031
  }
2030
2032
  /**
@@ -2207,6 +2209,7 @@ class ReviewService {
2207
2209
  }
2208
2210
  // 检查是否有其他同名 review workflow 正在运行中(防止同一 PR 重复审查)
2209
2211
  // 需要显式启用 skipDuplicateWorkflow 配置
2212
+ // 注意:Gitea Actions API 要求用户是 repo owner,否则会返回 403
2210
2213
  if (skipDuplicateWorkflow && ci && pr?.head?.sha) {
2211
2214
  const headSha = pr.head.sha;
2212
2215
  // 获取当前 PR 编号(从 CI 环境变量)
@@ -2215,25 +2218,33 @@ class ReviewService {
2215
2218
  const ref = process.env.GITHUB_REF || process.env.GITEA_REF || "";
2216
2219
  const prMatch = ref.match(/refs\/pull\/(\d+)/);
2217
2220
  const currentPrNumber = prMatch ? parseInt(prMatch[1], 10) : prNumber;
2218
- const runningWorkflows = await this.gitProvider.listWorkflowRuns(owner, repo, {
2219
- status: "in_progress"
2220
- });
2221
- // 获取当前 workflow 名称和 run ID
2222
- const currentWorkflowName = process.env.GITHUB_WORKFLOW || process.env.GITEA_WORKFLOW;
2223
- const currentRunId = process.env.GITHUB_RUN_ID || process.env.GITEA_RUN_ID;
2224
- // 只检查同 PR 同名的其他 workflow run(排除当前 run)
2225
- const duplicateReviewRuns = runningWorkflows.filter((w)=>w.sha === headSha && w.name === currentWorkflowName && (!currentRunId || String(w.id) !== currentRunId));
2226
- if (duplicateReviewRuns.length > 0) {
2221
+ try {
2222
+ const runningWorkflows = await this.gitProvider.listWorkflowRuns(owner, repo, {
2223
+ status: "in_progress"
2224
+ });
2225
+ // 获取当前 workflow 名称和 run ID
2226
+ const currentWorkflowName = process.env.GITHUB_WORKFLOW || process.env.GITEA_WORKFLOW;
2227
+ const currentRunId = process.env.GITHUB_RUN_ID || process.env.GITEA_RUN_ID;
2228
+ // 只检查同 PR 同名的其他 workflow run(排除当前 run)
2229
+ const duplicateReviewRuns = runningWorkflows.filter((w)=>w.sha === headSha && w.name === currentWorkflowName && (!currentRunId || String(w.id) !== currentRunId));
2230
+ if (duplicateReviewRuns.length > 0) {
2231
+ if (shouldLog(verbose, 1)) {
2232
+ console.log(`⏭️ 跳过审查: 当前 PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中`);
2233
+ }
2234
+ return {
2235
+ success: true,
2236
+ description: `跳过审查: PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中,等待完成后重新审查`,
2237
+ issues: [],
2238
+ summary: [],
2239
+ round: 1
2240
+ };
2241
+ }
2242
+ } catch (error) {
2243
+ // Gitea Actions API 可能返回 403(需要 repo owner 权限)
2244
+ // 捕获错误后跳过重复检查,继续执行审查
2227
2245
  if (shouldLog(verbose, 1)) {
2228
- console.log(`⏭️ 跳过审查: 当前 PR #${currentPrNumber} ${duplicateReviewRuns.length} 个同名 workflow 正在运行中`);
2246
+ console.warn(`⚠️ 无法检查重复 workflow(可能缺少 repo owner 权限),跳过此检查:`, error instanceof Error ? error.message : error);
2229
2247
  }
2230
- return {
2231
- success: true,
2232
- description: `跳过审查: PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中,等待完成后重新审查`,
2233
- issues: [],
2234
- summary: [],
2235
- round: 1
2236
- };
2237
2248
  }
2238
2249
  }
2239
2250
  } else if (effectiveBaseRef && effectiveHeadRef) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaceflow/review",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "description": "Spaceflow 代码审查插件,使用 LLM 对 PR 代码进行自动审查",
5
5
  "license": "MIT",
6
6
  "author": "Lydanne",
@@ -28,7 +28,7 @@
28
28
  "@spaceflow/cli": "0.40.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@spaceflow/core": "0.27.0"
31
+ "@spaceflow/core": "0.28.0"
32
32
  },
33
33
  "spaceflow": {
34
34
  "type": "flow",
@@ -306,6 +306,9 @@ export class ReviewService {
306
306
  flush: options.flush ?? false,
307
307
  eventAction: options.eventAction,
308
308
  localMode,
309
+ skipDuplicateWorkflow:
310
+ options.skipDuplicateWorkflow ?? reviewConf.skipDuplicateWorkflow ?? false,
311
+ autoApprove: options.autoApprove ?? reviewConf.autoApprove ?? false,
309
312
  };
310
313
  }
311
314
 
@@ -537,6 +540,7 @@ export class ReviewService {
537
540
 
538
541
  // 检查是否有其他同名 review workflow 正在运行中(防止同一 PR 重复审查)
539
542
  // 需要显式启用 skipDuplicateWorkflow 配置
543
+ // 注意:Gitea Actions API 要求用户是 repo owner,否则会返回 403
540
544
  if (skipDuplicateWorkflow && ci && pr?.head?.sha) {
541
545
  const headSha = pr.head.sha;
542
546
  // 获取当前 PR 编号(从 CI 环境变量)
@@ -546,32 +550,43 @@ export class ReviewService {
546
550
  const prMatch = ref.match(/refs\/pull\/(\d+)/);
547
551
  const currentPrNumber = prMatch ? parseInt(prMatch[1], 10) : prNumber;
548
552
 
549
- const runningWorkflows = await this.gitProvider.listWorkflowRuns(owner, repo, {
550
- status: "in_progress",
551
- });
552
- // 获取当前 workflow 名称和 run ID
553
- const currentWorkflowName = process.env.GITHUB_WORKFLOW || process.env.GITEA_WORKFLOW;
554
- const currentRunId = process.env.GITHUB_RUN_ID || process.env.GITEA_RUN_ID;
555
- // 只检查同 PR 同名的其他 workflow run(排除当前 run)
556
- const duplicateReviewRuns = runningWorkflows.filter(
557
- (w) =>
558
- w.sha === headSha &&
559
- w.name === currentWorkflowName &&
560
- (!currentRunId || String(w.id) !== currentRunId),
561
- );
562
- if (duplicateReviewRuns.length > 0) {
553
+ try {
554
+ const runningWorkflows = await this.gitProvider.listWorkflowRuns(owner, repo, {
555
+ status: "in_progress",
556
+ });
557
+ // 获取当前 workflow 名称和 run ID
558
+ const currentWorkflowName = process.env.GITHUB_WORKFLOW || process.env.GITEA_WORKFLOW;
559
+ const currentRunId = process.env.GITHUB_RUN_ID || process.env.GITEA_RUN_ID;
560
+ // 只检查同 PR 同名的其他 workflow run(排除当前 run)
561
+ const duplicateReviewRuns = runningWorkflows.filter(
562
+ (w) =>
563
+ w.sha === headSha &&
564
+ w.name === currentWorkflowName &&
565
+ (!currentRunId || String(w.id) !== currentRunId),
566
+ );
567
+ if (duplicateReviewRuns.length > 0) {
568
+ if (shouldLog(verbose, 1)) {
569
+ console.log(
570
+ `⏭️ 跳过审查: 当前 PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中`,
571
+ );
572
+ }
573
+ return {
574
+ success: true,
575
+ description: `跳过审查: PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中,等待完成后重新审查`,
576
+ issues: [],
577
+ summary: [],
578
+ round: 1,
579
+ };
580
+ }
581
+ } catch (error) {
582
+ // Gitea Actions API 可能返回 403(需要 repo owner 权限)
583
+ // 捕获错误后跳过重复检查,继续执行审查
563
584
  if (shouldLog(verbose, 1)) {
564
- console.log(
565
- `⏭️ 跳过审查: 当前 PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中`,
585
+ console.warn(
586
+ `⚠️ 无法检查重复 workflow(可能缺少 repo owner 权限),跳过此检查:`,
587
+ error instanceof Error ? error.message : error,
566
588
  );
567
589
  }
568
- return {
569
- success: true,
570
- description: `跳过审查: PR #${currentPrNumber} 有 ${duplicateReviewRuns.length} 个同名 workflow 正在运行中,等待完成后重新审查`,
571
- issues: [],
572
- summary: [],
573
- round: 1,
574
- };
575
590
  }
576
591
  }
577
592
  } else if (effectiveBaseRef && effectiveHeadRef) {