@spaceflow/review 4.0.0 → 4.0.1

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 (3) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +219 -0
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.0.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@3.0.0...@spaceflow/review@4.0.0) (2026-04-13)
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * **publish:** 修复 monorepo 格式 tag 识别问题,避免错误的 major bump
8
+
9
+ ### 新特性
10
+
11
+ * **publish:** 修复 monorepo 格式 tag 识别问题,避免错误的 major bump ([6379b71](https://github.com/Lydanne/spaceflow/commit/6379b71f5694a814f40866020bc8dd7614399e83))
12
+
13
+ ### 修复BUG
14
+
15
+ * **review:** 更新 README,补充本地审查、MCP 工具、系统规则等新功能说明 ([ee6942f](https://github.com/Lydanne/spaceflow/commit/ee6942fe9043aff479f0ae4d6cff1623cc8df80f))
16
+
17
+ ### 其他修改
18
+
19
+ * **publish:** released version 1.0.0 [no ci] ([ef8afbf](https://github.com/Lydanne/spaceflow/commit/ef8afbf82aae414555b8923e068ae3f7702d30e8))
20
+ * **review-summary:** released version 3.0.0 [no ci] ([b344696](https://github.com/Lydanne/spaceflow/commit/b344696ffaaef7957cf04e34fec5ae838982aeb8))
21
+
3
22
  ## [3.0.0](https://github.com/Lydanne/spaceflow/compare/@spaceflow/review@2.0.0...@spaceflow/review@3.0.0) (2026-04-13)
4
23
 
5
24
  ### 代码重构
package/README.md CHANGED
@@ -159,6 +159,225 @@ spaceflow review -p 123 --fail-on-issues -l openai
159
159
 
160
160
  规则搜索目录包括:`review.references` 配置路径、`.claude/skills`、`.cursor/skills`、`review-specs`。
161
161
 
162
+ ## 审查规范格式
163
+
164
+ 审查规范使用 Markdown 文件定义,文件名格式为 `<extensions>.<type>.md`,放置在 `references/` 目录或远程仓库中。
165
+
166
+ ### 文件名约定
167
+
168
+ ```
169
+ <extensions>.<type>.md
170
+ ```
171
+
172
+ - **extensions** — 适用的文件扩展名,多个用 `&` 连接(如 `js&ts`、`vue`)
173
+ - **type** — 规范类别(如 `base`、`file-name`、`nest`)
174
+
175
+ 示例:`js&ts.base.md` → 适用于 `.js` 和 `.ts` 文件的基础规范
176
+
177
+ ### 规则定义格式
178
+
179
+ 每条规则使用 `##` 或 `###` 标题,后跟规则 ID(用反引号方括号包裹):
180
+
181
+ ```markdown
182
+ ## 规则标题 `[RuleId]`
183
+
184
+ 规则描述文本...
185
+
186
+ > - severity `warn`
187
+ > - override `[OverriddenRuleId]`
188
+ > - includes `*.service.ts` `*.controller.ts`
189
+
190
+ ### Example: 示例标题
191
+
192
+ #### Good: 正确示例
193
+
194
+ ```typescript
195
+ const MAX_COUNT = 100;
196
+ ```
197
+
198
+ #### Bad: 错误示例
199
+
200
+ ```typescript
201
+ const maxCount = 100;
202
+ ```
203
+ ```
204
+
205
+ ### 规则配置项
206
+
207
+ 在规则描述中使用引用块(`>`)声明配置:
208
+
209
+ | 配置项 | 格式 | 说明 |
210
+ | ------------ | ----------------------------- | ------------------------------------------------------------ |
211
+ | `severity` | `> - severity \`warn\`` | 严重级别(`off` / `warn` / `error`),默认 `error` |
212
+ | `override` | `> - override \`[RuleId]\`` | 覆盖指定规则(前缀匹配),被覆盖的规则问题会被过滤 |
213
+ | `includes` | `> - includes \`*.ts\` \`*.js\`` | 文件匹配模式,仅对匹配的文件生效,支持 `status|glob` 前缀 |
214
+
215
+ ### Override 机制
216
+
217
+ Override 允许高优先级规则覆盖低优先级规则,避免重复报告:
218
+
219
+ - 使用前缀匹配:`override [JsTs.FileName]` 会覆盖 `JsTs.FileName` 及其子规则(如 `JsTs.FileName.UpperCamel`)
220
+ - 作用域感知:只有当 issue 文件匹配 override 所在 spec 的 `includes` 时才生效
221
+ - 文件级 override 写在规范文件头部(第一个 `##` 规则之前),对所有规则生效
222
+
223
+ ### 远程规范引用
224
+
225
+ `references` 支持以下格式:
226
+
227
+ ```json
228
+ {
229
+ "review": {
230
+ "references": [
231
+ "./references", // 本地目录
232
+ "https://github.com/org/repo/tree/main/specs", // GitHub 仓库目录
233
+ "https://gitea.example.com/org/repo/src/branch/main/specs" // Gitea 仓库目录
234
+ ]
235
+ }
236
+ }
237
+ ```
238
+
239
+ 拉取优先级:Git Provider API → tea CLI → git clone 回退 → 本地缓存
240
+
241
+ ## 审查流程
242
+
243
+ ```
244
+ 1. 解析上下文(PR/分支/本地模式) → ReviewContext
245
+ 2. 加载审查规范(本地 + 远程) → ReviewSpec[]
246
+ 3. 获取变更文件和代码内容
247
+ 4. 系统规则检查(静态,不依赖 LLM)
248
+ 5. LLM 并行审查(按文件分发,注入匹配的规范)
249
+ 6. 问题过滤(去重、includes、override、非变更行)
250
+ 7. 历史问题验证(可选,verifyFixes)
251
+ 8. 删除代码分析(可选,analyzeDeletions)
252
+ 9. AI 生成 PR 描述(可选,generateDescription)
253
+ 10. 输出结果(PR 评论 / 终端 / JSON)
254
+ ```
255
+
256
+ ### 参数优先级
257
+
258
+ 命令行 > PR 标题参数 > 配置文件 > 默认值
259
+
260
+ ## 问题生命周期
261
+
262
+ 每个审查问题(Issue)有以下状态流转:
263
+
264
+ ```
265
+ 发现 → 待处理 → 已修复 / 已解决 / 无效
266
+ ```
267
+
268
+ | 状态 | 标记 | 说明 |
269
+ | ---------- | ----------- | -------------------------------------- |
270
+ | 待处理 | 🔴/🟡 | 新发现的问题,尚未处理 |
271
+ | 已修复 | 🟢 | AI 验证代码已修改,问题不再存在 |
272
+ | 已解决 | ⚪ | 用户手动点击 resolve |
273
+ | 无效 | ❌ | AI 验证或用户标记为误报 |
274
+
275
+ 严重级别对应的 Emoji:
276
+
277
+ | 级别 | Emoji | 说明 |
278
+ | ------ | ----- | ------------ |
279
+ | error | 🔴 | 必须修复 |
280
+ | warn | 🟡 | 建议修复 |
281
+ | off | ⚪ | 规则已关闭 |
282
+
283
+ ### 增量审查
284
+
285
+ 多次运行 review 时自动追踪问题状态:
286
+
287
+ - **轮次(round)** — 每次审查递增,记录问题在哪一轮发现
288
+ - **去重** — 相同文件+行号+规则的问题不会重复报告
289
+ - **行号追踪** — 代码变更导致行号移动时自动更新 `originalLine`
290
+ - **变更文件处理** — `invalidateChangedFiles` 控制变更文件的历史问题是否标记为无效
291
+
292
+ ## Includes 模式语法
293
+
294
+ `includes` 配置支持 glob 模式和变更类型前缀:
295
+
296
+ ### 基本语法
297
+
298
+ ```json
299
+ {
300
+ "includes": ["**/*.ts", "!**/*.spec.ts", "!**/*.config.ts"]
301
+ }
302
+ ```
303
+
304
+ - `!` 前缀表示排除模式
305
+ - 使用 [micromatch](https://github.com/micromatch/micromatch) 匹配
306
+
307
+ ### 变更类型前缀
308
+
309
+ `<status>|<glob>` 语法,仅匹配指定变更类型的文件:
310
+
311
+ | 前缀 | 说明 | 示例 |
312
+ | ----------- | ------ | ------------------------- |
313
+ | `added\|` | 新增文件 | `added\|**/*.ts` |
314
+ | `modified\|` | 修改文件 | `modified\|**/*.ts` |
315
+ | `deleted\|` | 删除文件 | `deleted\|**/*.ts` |
316
+
317
+ 无前缀则不限变更类型。
318
+
319
+ > 注意:文件的 status 是相对 base 分支的全量 diff 结果。例如在当前分支首次引入的文件,无论后续多少次 commit 修改,其 status 始终为 `added`。
320
+
321
+ ### whenModifiedCode 过滤
322
+
323
+ `whenModifiedCode` 配置可进一步缩小审查范围,只关注特定代码结构:
324
+
325
+ ```json
326
+ {
327
+ "whenModifiedCode": ["function", "class"]
328
+ }
329
+ ```
330
+
331
+ 支持的类型:`function`、`class`、`interface`、`type`、`method`
332
+
333
+ 配置后,LLM 只会收到匹配代码块范围内的代码,其余代码被裁剪。
334
+
335
+ ## 输出格式
336
+
337
+ ### markdown(默认 PR 模式)
338
+
339
+ 发布为 PR Review Comment,包含:
340
+
341
+ - 按文件分组的问题列表(含严重级别 Emoji)
342
+ - 每个问题的规则 ID、发现时间、开发人员
343
+ - 修复建议代码片段
344
+ - 文件摘要和统计信息
345
+ - 隐藏的 JSON 数据区(用于增量审查状态追踪)
346
+
347
+ ### terminal
348
+
349
+ 终端彩色输出,适合本地审查:
350
+
351
+ - 🟢 已修复 / 🔴 待处理 error / 🟡 待处理 warn / ⚪ 已解决
352
+ - 按文件分组的摘要和问题详情
353
+
354
+ ### json
355
+
356
+ 原始 `ReviewResult` JSON 结构化输出,适合程序化处理:
357
+
358
+ ```json
359
+ {
360
+ "success": true,
361
+ "title": "AI 生成的 PR 标题",
362
+ "description": "PR 功能总结",
363
+ "issues": [...],
364
+ "summary": [...],
365
+ "deletionImpact": {...},
366
+ "round": 2,
367
+ "headSha": "abc1234",
368
+ "stats": {
369
+ "total": 10,
370
+ "validTotal": 8,
371
+ "fixed": 3,
372
+ "resolved": 2,
373
+ "invalid": 2,
374
+ "pending": 3,
375
+ "fixRate": 37.5,
376
+ "resolveRate": 25
377
+ }
378
+ }
379
+ ```
380
+
162
381
  ## PR 标题参数
163
382
 
164
383
  支持在 PR 标题末尾添加参数覆盖默认配置:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaceflow/review",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Spaceflow 代码审查插件,使用 LLM 对 PR 代码进行自动审查",
5
5
  "license": "MIT",
6
6
  "author": "Lydanne",