also looking at this
fix(review): honour the ai.review settings that nothing read
#1406
7 files
+282
-8
| @@ -291,6 +291,8 @@ interface CLIOptions { | ||
| 291 | 291 | respectLatest?: boolean |
| 292 | 292 | /** Which settings pages `open-settings` should open: repo, org or both. */ |
| 293 | 293 | type?: string |
| 294 | /** Set by the generated workflow: honour the `ai.review` filters. */ | |
| 295 | auto?: boolean | |
| 294 | 296 | } |
| 295 | 297 | |
| 296 | 298 | cli |
| @@ -1558,6 +1560,7 @@ cli | ||
| 1558 | 1560 | .option('--fail-on <severity>', 'Exit non-zero when a finding at or above this severity is found') |
| 1559 | 1561 | .option('--profile <name>', 'Review profile: chill|assertive') |
| 1560 | 1562 | .option('--summary-only', 'Post only the summary, without inline findings') |
| 1563 | .option('--auto', 'Treat this as an automatic trigger, honouring the ai.review filters') | |
| 1561 | 1564 | .option('--dry-run', 'Print the review instead of posting it') |
| 1562 | 1565 | .example('buddy review 42') |
| 1563 | 1566 | .example('buddy review --staged --light') |
| @@ -1621,12 +1624,24 @@ cli | ||
| 1621 | 1624 | gitProvider = await providerFor(config, 'reviewing a pull request', log) |
| 1622 | 1625 | |
| 1623 | 1626 | const number = Number.parseInt(prNumber, 10) |
| 1624 | diff = await gitProvider.getPullRequestDiff(number) | |
| 1625 | 1627 | |
| 1626 | 1628 | // Carry forward what earlier reviews already said, so a re-review |
| 1627 | 1629 | // reports only what is new rather than repeating itself. |
| 1628 | 1630 | const prs = await gitProvider.getPullRequests('open') |
| 1629 | 1631 | const pr = prs.find(candidate => candidate.number === number) |
| 1632 | ||
| 1633 | // `--auto` is what the generated workflow passes. Without it this is | |
| 1634 | // someone at a terminal, who has already decided they want a review. | |
| 1635 | if (pr) { | |
| 1636 | const { reviewSkipReason } = await import('../src/review/filters') | |
| 1637 | const skip = reviewSkipReason(config, pr, options.auto ? 'automatic' : 'requested') | |
| 1638 | if (skip) { | |
| 1639 | log.info(`🔍 Skipping PR #${number}: ${skip}`) | |
| 1640 | return | |
| 1641 | } | |
| 1642 | } | |
| 1643 | ||
| 1644 | diff = await gitProvider.getPullRequestDiff(number) | |
| 1630 | 1645 | const state = parseReviewState(pr?.body) |
| 1631 | 1646 | seenFingerprints = state?.fingerprints ?? [] |
| 1632 | 1647 | prBody = pr?.body ?? null |