revdeck 0.19.2 → 0.20.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
@@ -4,10 +4,16 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [0.19.2] - 2026-11-30
7
+ ## [0.20.0] - 2026-12-03
8
8
 
9
9
  ### Added
10
10
 
11
+ - Local branch review without an MR: `revdeck review --local [--base <ref>]` builds a `base...HEAD`
12
+ snapshot (merge-base, remote-tracking base preferred), serves the usual agent context and rules, and
13
+ keeps findings/summary in daemon memory under a stable `local-…` id. `revdeck report --local
14
+ [--out <file>]` renders a markdown report from the same view, `--ui` opens it as a read-only UI
15
+ preview, and the `revdeck_local` MCP tool opens the snapshot for agents. Threads, reactions, checks,
16
+ approvals, version history and publishing are not available for local reviews.
11
17
  - The API client warns once in the console when a single path is requested more than 30 times per
12
18
  second — the signature of an effect that reads the state it writes. Recovery, retries and polling
13
19
  stay far below the threshold.
package/README.md CHANGED
@@ -186,6 +186,8 @@ Russian READMEs live in this repository; translation fixes are welcome.
186
186
  | `revdeck review <N\|URL>` | review someone else's MR: context, rules, diff |
187
187
  | `revdeck feedback <N\|URL>` | work through findings on your own MR: threads, fixes, replies |
188
188
  | `revdeck open <N\|URL>` | load a review without a scenario; suggests review or feedback |
189
+ | `revdeck review --local [--base <ref>]` | review the current branch against its base, without an MR |
190
+ | `revdeck report --local [--out <file>] [--ui]` | markdown report for a local review plus a UI link |
189
191
  | `revdeck context <N> [--scenario review\|feedback]` | agent context: rules, files, threads, findings |
190
192
  | `revdeck diff <N> [--file]` | files and hunks |
191
193
  | `revdeck threads <N>` | discussions |
@@ -322,6 +324,29 @@ the platform user is known. The scenario is client-side: it is not stored in the
322
324
  the database. Existing projects get the new router by rerunning `revdeck init`; a command file you have
323
325
  customized is left alone.
324
326
 
327
+ ## Reviewing your branch without an MR
328
+
329
+ `revdeck review --local [--base <ref>]` reviews the current branch against its base. No platform, MR
330
+ number or token is needed: the source is `git diff base...HEAD`.
331
+
332
+ - The base is `--base` → `provider.base` → `origin/HEAD` → `develop`/`main`/`master`. The
333
+ comparison is always three-dot, i.e. from the merge-base, so commits that are not on your branch
334
+ never leak into the diff.
335
+ - The working copy may be dirty: uncommitted changes are not part of the diff, but the context and the
336
+ report say how many files there are.
337
+ - The agent context is the same: rules for changed paths, shards, roles, risk. Platform threads,
338
+ reactions, checks, approvals and merge status are absent — this is a local diff.
339
+ - The local review id is printed after the context and is stable per branch, so findings and the
340
+ summary go through the usual commands: `revdeck findings <id> set --file f.json`,
341
+ `revdeck summary <id> --file s.json`. In MCP, `revdeck_local` opens the snapshot and
342
+ `revdeck_context` works on it as usual.
343
+ - `revdeck report --review <id>` or `revdeck report --local` renders a markdown report (by default
344
+ `.revdeck/review-<branch>-<date>.md`); `--ui` opens the same snapshot in the UI.
345
+
346
+ A local review lives in daemon memory: it never reaches the database or the review list, and the UI
347
+ link works for an hour or until a restart. There is no platform publishing — the markdown report is
348
+ the only artifact.
349
+
325
350
  ## Multi-agent review
326
351
 
327
352
  Configure independent reviewers in `.revdeck.yml`:
package/README.ru.md CHANGED
@@ -124,6 +124,7 @@ revdeck init # .revdeck.yml, skill в .agents/.claude, MCP-конфиг
124
124
  revdeck doctor # проверка окружения и адаптеров
125
125
  revdeck review 42 # чужой MR: контекст, правила, ревью
126
126
  revdeck feedback 42 # свой MR: разбор замечаний
127
+ revdeck review --local # своя ветка без MR: diff против базовой ветки
127
128
  revdeck open 42 # только открыть MR/PR без сценария
128
129
  revdeck ui # ссылка на локальный интерфейс
129
130
  ```
@@ -174,6 +175,8 @@ self-hosted GitLab), по умолчанию выбирается `gitlab`. Пе
174
175
  | `revdeck review <N│URL>` | ревью чужого MR: контекст, правила, diff |
175
176
  | `revdeck feedback <N│URL>` | разбор замечаний к своему MR: треды, правки, ответы |
176
177
  | `revdeck open <N│URL>` | загрузить ревью без сценария; подсказывает review или feedback |
178
+ | `revdeck review --local [--base <ветка>]` | ревью текущей ветки против базовой, без MR |
179
+ | `revdeck report --local [--out <файл>] [--ui]` | markdown-отчёт по локальному ревью и ссылка в UI |
177
180
  | `revdeck context <N> [--scenario review│feedback]` | контекст для агента: правила, файлы, треды, замечания |
178
181
  | `revdeck diff <N> [--file]` | файлы и hunks |
179
182
  | `revdeck threads <N>` | обсуждения |
@@ -312,6 +315,27 @@ MR (`это ваш MR` / `чужой MR`), поэтому `open` может по
312
315
  проекты получают новый роутер после повторного `revdeck init`; изменённый вручную командный файл
313
316
  остаётся нетронутым.
314
317
 
318
+ ## Своя ветка без MR
319
+
320
+ `revdeck review --local [--base <ветка>]` ревьюит текущую ветку против базовой ветки. Платформа,
321
+ номер MR и токены не нужны: источник — `git diff base...HEAD`.
322
+
323
+ - База выбирается так: `--base` → `provider.base` → `origin/HEAD` → `develop`/`main`/`master`.
324
+ Сравнение всегда трёхточечное, то есть от merge-base: чужие коммиты в diff не попадают.
325
+ - В рабочей копии может быть грязно: незакоммиченные изменения в diff не входят, но о них
326
+ сообщается и в контексте, и в отчёте.
327
+ - Контекст для агента тот же: правила по изменённым путям, шарды, роли, risk. Платформенных тредов,
328
+ реакций, checks, approvals и merge-статуса нет — это локальный diff.
329
+ - Id локального ревью печатается после контекста и стабилен для ветки, поэтому замечания и выжимка
330
+ пишутся обычными командами: `revdeck findings <id> set --file f.json`,
331
+ `revdeck summary <id> --file s.json`. MCP: `revdeck_local` открывает такой снимок, дальше работает
332
+ `revdeck_context`.
333
+ - `revdeck report --review <id>` или `revdeck report --local` собирает markdown-отчёт (по умолчанию
334
+ `.revdeck/review-<ветка>-<дата>.md`); `--ui` открывает тот же снимок в интерфейсе.
335
+
336
+ Локальное ревью живёт в памяти демона: оно не попадает в базу и список ревью, ссылка в UI действует
337
+ час или до рестарта. Публикации в платформу у него нет — артефакт только markdown-отчёт.
338
+
315
339
  ## Многоагентное ревью
316
340
 
317
341
  Независимые ревьюеры настраиваются в `.revdeck.yml`:
package/dist/cli.js CHANGED
@@ -853,7 +853,7 @@ var VERSION;
853
853
  var init_version = __esm({
854
854
  "src/version.ts"() {
855
855
  "use strict";
856
- VERSION = "0.19.2";
856
+ VERSION = "0.20.0";
857
857
  }
858
858
  });
859
859
 
@@ -1604,25 +1604,40 @@ function renderContext(review, rules2, options = {}) {
1604
1604
  const push = (line = "") => {
1605
1605
  lines.push(line);
1606
1606
  };
1607
- push(`# ${t("\u0420\u0435\u0432\u044C\u044E", "Review")} ${review.info.ref.project}#${review.info.ref.number}: ${review.info.title}`);
1608
- push(review.info.webUrl);
1609
- const own = isOwnReview(review);
1607
+ const local = review.info.local;
1608
+ if (local) push(`# ${t("\u0420\u0435\u0432\u044C\u044E \u0432\u0435\u0442\u043A\u0438", "Branch review")} \`${local.branch}\``);
1609
+ else push(`# ${t("\u0420\u0435\u0432\u044C\u044E", "Review")} ${review.info.ref.project}#${review.info.ref.number}: ${review.info.title}`);
1610
+ if (review.info.webUrl) push(review.info.webUrl);
1611
+ const own = local ? null : isOwnReview(review);
1610
1612
  const ownSuffix = own === null ? "" : own ? ` \xB7 ${t("\u044D\u0442\u043E \u0432\u0430\u0448 MR", "your MR")}` : ` \xB7 ${t("\u0447\u0443\u0436\u043E\u0439 MR", "someone else's MR")}`;
1611
- push(`${review.info.sourceBranch} \u2192 ${review.info.targetBranch} \xB7 ${review.info.state} \xB7 ${t("\u0430\u0432\u0442\u043E\u0440", "by")} ${review.info.author}${ownSuffix}`);
1613
+ const stateLabel = local ? t("\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff", "local diff") : review.info.state;
1614
+ push(`${review.info.sourceBranch} \u2192 ${review.info.targetBranch} \xB7 ${stateLabel} \xB7 ${t("\u0430\u0432\u0442\u043E\u0440", "by")} ${review.info.author}${ownSuffix}`);
1612
1615
  push("");
1613
1616
  const merge = review.info.merge;
1614
1617
  const targetBranch = review.info.targetBranch;
1615
1618
  const shortSha = (sha) => sha ? sha.slice(0, 12) : "?";
1616
1619
  push(`## ${t("\u0412\u0435\u0442\u043A\u0430 \u0438 \u0431\u0430\u0437\u0430 \u0441\u0440\u0430\u0432\u043D\u0435\u043D\u0438\u044F", "Branch and comparison base")}`);
1617
1620
  push(
1618
- `${t("\u041A\u0443\u0434\u0430 \u043C\u0435\u0440\u0436\u0438\u0442\u0441\u044F", "Merges into")}: ${targetBranch ? `\`${targetBranch}\`` : t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u043E (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`
1621
+ `${local ? t("\u0411\u0430\u0437\u0430 \u0441\u0440\u0430\u0432\u043D\u0435\u043D\u0438\u044F", "Compared against") : t("\u041A\u0443\u0434\u0430 \u043C\u0435\u0440\u0436\u0438\u0442\u0441\u044F", "Merges into")}: ${targetBranch ? `\`${targetBranch}\`` : t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C\u043E (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`
1619
1622
  );
1620
1623
  push(`${t("\u0418\u0441\u0442\u043E\u0447\u043D\u0438\u043A", "Source")}: \`${review.info.sourceBranch || "?"}\``);
1621
1624
  if (review.info.commit.base || review.info.commit.head) {
1622
1625
  push(`${t("\u0421\u043D\u0438\u043C\u043E\u043A diff", "Diff snapshot")}: \`${shortSha(review.info.commit.base)}\` \u2192 \`${shortSha(review.info.commit.head)}\``);
1623
1626
  }
1624
1627
  push(`${t("\u0421\u043D\u0438\u043C\u043E\u043A \u043E\u0431\u043D\u043E\u0432\u043B\u0451\u043D", "Snapshot updated")}: ${when(review.syncedAt, language)}`);
1625
- if (!targetBranch) {
1628
+ if (local) {
1629
+ push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C (\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff)", "not applicable (local diff)")}`);
1630
+ push(t(
1631
+ "> \u042D\u0442\u043E \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff \u0431\u0435\u0437 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B: \u0442\u0440\u0435\u0434\u043E\u0432, \u0440\u0435\u0430\u043A\u0446\u0438\u0439, CI-checks \u0438 approvals \u043D\u0435\u0442. \u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u043F\u0443\u0431\u043B\u0438\u043A\u0443\u044E\u0442\u0441\u044F, \u043E\u0442\u0447\u0451\u0442 \u2014 \u0435\u0434\u0438\u043D\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439 \u0430\u0440\u0442\u0435\u0444\u0430\u043A\u0442.",
1632
+ "> This is a local diff without a platform: there are no threads, reactions, CI checks or approvals. Findings are not published; the report is the only artifact."
1633
+ ));
1634
+ if (local.dirty > 0) {
1635
+ push(t(
1636
+ `> \u0412 \u0440\u0430\u0431\u043E\u0447\u0435\u0439 \u043A\u043E\u043F\u0438\u0438 ${local.dirty} \u0444\u0430\u0439\u043B\u043E\u0432 \u0441 \u043D\u0435\u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0447\u0435\u043D\u043D\u044B\u043C\u0438 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F\u043C\u0438 \u2014 \u043E\u043D\u0438 \u043D\u0435 \u0432\u0445\u043E\u0434\u044F\u0442 \u0432 diff.`,
1637
+ `> The working copy has ${local.dirty} files with uncommitted changes \u2014 they are not part of the diff.`
1638
+ ));
1639
+ }
1640
+ } else if (!targetBranch) {
1626
1641
  push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C", "not applicable")}`);
1627
1642
  } else if (!merge) {
1628
1643
  push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${t("\u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u044F\u043B\u0441\u044F", "not checked")}`);
@@ -1631,8 +1646,8 @@ function renderContext(review, rules2, options = {}) {
1631
1646
  "> No merge status was reported: do not claim there are no findings until the target and conflicts are checked."
1632
1647
  ));
1633
1648
  } else {
1634
- const stateLabel = merge.state === "clean" ? t("\u0447\u0438\u0441\u0442\u043E", "clean") : merge.state === "conflict" ? t("\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442", "conflict") : merge.state === "behind" ? t("\u043E\u0442\u0441\u0442\u0430\u0451\u0442 \u043E\u0442 target", "behind target") : merge.state === "unknown" ? t("\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043D", "unknown") : t("\u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430 \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0438\u043B\u0430", "not reported");
1635
- push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${stateLabel}${merge.detail ? ` \xB7 ${merge.detail}` : ""}`);
1649
+ const stateLabel2 = merge.state === "clean" ? t("\u0447\u0438\u0441\u0442\u043E", "clean") : merge.state === "conflict" ? t("\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442", "conflict") : merge.state === "behind" ? t("\u043E\u0442\u0441\u0442\u0430\u0451\u0442 \u043E\u0442 target", "behind target") : merge.state === "unknown" ? t("\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043D", "unknown") : t("\u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430 \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0438\u043B\u0430", "not reported");
1650
+ push(`${t("\u0421\u0442\u0430\u0442\u0443\u0441 \u043C\u0435\u0440\u0436\u0430", "Merge status")}: ${stateLabel2}${merge.detail ? ` \xB7 ${merge.detail}` : ""}`);
1636
1651
  if (merge.targetSha) push(`${t("Target head", "Target head")}: \`${shortSha(merge.targetSha)}\``);
1637
1652
  if (merge.state === "conflict") {
1638
1653
  push(t(
@@ -1703,11 +1718,19 @@ function renderContext(review, rules2, options = {}) {
1703
1718
  }
1704
1719
  push("");
1705
1720
  if (options.scenario === "feedback") {
1706
- push(`## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043A \u0441\u0432\u043E\u0435\u043C\u0443 MR", "Scenario: feedback on your own MR")}`);
1707
- push(t(
1708
- "\u041F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: `Feedback.md` \u0438\u0437 skill revdeck. \u0421\u043D\u0430\u0447\u0430\u043B\u0430 \u0441\u0432\u0435\u0440\u044C\u0442\u0435 \u0440\u0430\u0431\u043E\u0447\u0443\u044E \u0432\u0435\u0442\u043A\u0443 \u0441 MR, \u0437\u0430\u0442\u0435\u043C \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0442\u0440\u0435\u0434\u044B \u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C.",
1709
- "Procedure: `Feedback.md` from the revdeck skill. First verify the working branch matches the MR, then work through open threads and line comments."
1710
- ));
1721
+ const local2 = Boolean(review.info.local);
1722
+ push(
1723
+ local2 ? `## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0434\u043E\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u0441\u0432\u043E\u0435\u0439 \u0432\u0435\u0442\u043A\u0438", "Scenario: improving your branch")}` : `## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043A \u0441\u0432\u043E\u0435\u043C\u0443 MR", "Scenario: feedback on your own MR")}`
1724
+ );
1725
+ push(
1726
+ local2 ? t(
1727
+ "\u041F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: `Feedback.md` \u0438\u0437 skill revdeck. \u0421\u0432\u0435\u0440\u044C\u0442\u0435 diff \u0441 \u0431\u0430\u0437\u043E\u0439, \u043E\u0442\u043C\u0435\u0442\u044C\u0442\u0435 \u043D\u0435\u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0447\u0435\u043D\u043D\u043E\u0435 \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043D\u044B\u0435 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F; \u043E\u0442\u0447\u0451\u0442 \u0441\u043E\u0431\u0438\u0440\u0430\u0435\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A.",
1728
+ "Procedure: `Feedback.md` from the revdeck skill. Check the diff against the base, note uncommitted changes and work through the findings; the human builds the report."
1729
+ ) : t(
1730
+ "\u041F\u0440\u043E\u0446\u0435\u0434\u0443\u0440\u0430: `Feedback.md` \u0438\u0437 skill revdeck. \u0421\u043D\u0430\u0447\u0430\u043B\u0430 \u0441\u0432\u0435\u0440\u044C\u0442\u0435 \u0440\u0430\u0431\u043E\u0447\u0443\u044E \u0432\u0435\u0442\u043A\u0443 \u0441 MR, \u0437\u0430\u0442\u0435\u043C \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435 \u0442\u0440\u0435\u0434\u044B \u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u043A \u0441\u0442\u0440\u043E\u043A\u0430\u043C.",
1731
+ "Procedure: `Feedback.md` from the revdeck skill. First verify the working branch matches the MR, then work through open threads and line comments."
1732
+ )
1733
+ );
1711
1734
  push("");
1712
1735
  } else if (options.scenario === "review") {
1713
1736
  push(`## ${t("\u0421\u0446\u0435\u043D\u0430\u0440\u0438\u0439: \u0440\u0435\u0432\u044C\u044E \u0447\u0443\u0436\u043E\u0433\u043E MR", "Scenario: reviewing someone else's MR")}`);
@@ -2377,6 +2400,30 @@ Next: ${next}.`;
2377
2400
  }
2378
2401
  }
2379
2402
  );
2403
+ server.registerTool(
2404
+ "revdeck_local",
2405
+ {
2406
+ title: "Review the current branch",
2407
+ description: "Open or refresh a local review of the current branch against its base (origin/HEAD, provider.base or the base argument): diff, rules and a stable review id. No platform is used: threads, checks, approvals and publishing are unavailable. Use the returned id with revdeck_context and revdeck_draft_findings; the markdown report is built by the human in CLI.",
2408
+ inputSchema: {
2409
+ base: z2.string().min(1).max(255).optional().describe("Base ref to compare against, for example origin/main or develop")
2410
+ }
2411
+ },
2412
+ async ({ base }) => {
2413
+ try {
2414
+ const current2 = await scope();
2415
+ const result = await call("reviews.openLocal", {
2416
+ root: daemonRoot(current2.root),
2417
+ ...base ? { base } : {}
2418
+ });
2419
+ const review = result.review;
2420
+ return ok(`${summarize(review)}
2421
+ Next: revdeck_context(review="${review.id}", scenario="feedback").`, { reviewId: review.id });
2422
+ } catch (error) {
2423
+ return failure(error);
2424
+ }
2425
+ }
2426
+ );
2380
2427
  server.registerTool(
2381
2428
  "revdeck_feature",
2382
2429
  {
@@ -2992,7 +3039,7 @@ ${failed.map((item) => `- ${item.id}: ${item.error}`).join("\n")}` : ""),
2992
3039
  // src/cli/main.ts
2993
3040
  init_paths();
2994
3041
  init_config();
2995
- import { open as open2, readFile as readFile8, stat as stat2, writeFile as writeFile5 } from "node:fs/promises";
3042
+ import { mkdir as mkdir5, open as open2, readFile as readFile8, stat as stat2, writeFile as writeFile5 } from "node:fs/promises";
2996
3043
  import { readFileSync } from "node:fs";
2997
3044
  import { parseArgs } from "node:util";
2998
3045
  import path11 from "node:path";
@@ -4711,6 +4758,138 @@ function normalizeContentType(value) {
4711
4758
 
4712
4759
  // src/cli/main.ts
4713
4760
  init_context();
4761
+
4762
+ // src/core/report-md.ts
4763
+ init_locale();
4764
+ var LEVEL_ORDER = ["blocker", "major", "minor", "question"];
4765
+ var LEVEL_LABELS = {
4766
+ blocker: { ru: "\u{1F7E5} blocker", en: "\u{1F7E5} blocker" },
4767
+ major: { ru: "\u{1F7E7} major", en: "\u{1F7E7} major" },
4768
+ minor: { ru: "\u{1F7E8} minor", en: "\u{1F7E8} minor" },
4769
+ question: { ru: "\u{1F7E6} question", en: "\u{1F7E6} question" }
4770
+ };
4771
+ function sectionLines(title, items) {
4772
+ const list3 = (items ?? []).map((item) => item.trim()).filter(Boolean);
4773
+ if (!list3.length) return [];
4774
+ return ["", `### ${title}`, ...list3.map((item) => `- ${item}`)];
4775
+ }
4776
+ function renderLocalReport(view, options = {}) {
4777
+ const language = options.language ?? "en";
4778
+ const t = (ru, en) => language === "ru" ? ru : en;
4779
+ const local = view.info.local;
4780
+ const branch = local?.branch ?? view.info.sourceBranch;
4781
+ const base = local?.base ?? view.info.targetBranch;
4782
+ const files = view.files.length;
4783
+ const filesWord = plural(files, "\u0444\u0430\u0439\u043B", "\u0444\u0430\u0439\u043B\u0430", "\u0444\u0430\u0439\u043B\u043E\u0432", "file", "files");
4784
+ const lines = [];
4785
+ lines.push(`# ${t(`\u0420\u0435\u0432\u044C\u044E \u0432\u0435\u0442\u043A\u0438 \`${branch}\``, `Review of branch \`${branch}\``)}`);
4786
+ lines.push("");
4787
+ lines.push(`- ${t("\u0412\u0435\u0442\u043A\u0430", "Branch")}: \`${branch}\``);
4788
+ lines.push(`- ${t("\u0411\u0430\u0437\u0430", "Base")}: \`${base}\` (merge-base \`${view.info.commit.base.slice(0, 12)}\`)`);
4789
+ lines.push(`- ${t("Head", "Head")}: \`${view.info.commit.head.slice(0, 12)}\``);
4790
+ lines.push(`- ${t("\u0418\u0437\u043C\u0435\u043D\u0435\u043D\u043E", "Changed")}: ${files} ${filesWord}, +${view.stats.additions} \u2212${view.stats.deletions}`);
4791
+ if (local && local.dirty > 0) {
4792
+ lines.push(
4793
+ `- ${t(
4794
+ `\u041D\u0435\u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0447\u0435\u043D\u043D\u044B\u0435 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F: ${local.dirty} (\u0432 diff \u043D\u0435 \u0432\u0445\u043E\u0434\u044F\u0442)`,
4795
+ `Uncommitted changes: ${local.dirty} (not part of the diff)`
4796
+ )}`
4797
+ );
4798
+ }
4799
+ lines.push(`- ${t("\u041F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0430: \u043D\u0435 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F, \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u044B", "Platform: not used, findings are not published")}`);
4800
+ lines.push("");
4801
+ const summary2 = view.summary;
4802
+ lines.push(`## ${t("\u0412\u044B\u0436\u0438\u043C\u043A\u0430", "Summary")}`);
4803
+ if (!summary2) {
4804
+ lines.push("");
4805
+ lines.push(t("\u0412\u044B\u0436\u0438\u043C\u043A\u0430 \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043D\u0430.", "No summary was written."));
4806
+ } else {
4807
+ const title = summary2.title.trim();
4808
+ const scope2 = summary2.scope.trim();
4809
+ lines.push("");
4810
+ if (title) lines.push(`**${title}**${scope2 ? ` \xB7 \`${scope2}\`` : ""}`);
4811
+ else if (scope2) lines.push(`\`${scope2}\``);
4812
+ if (summary2.summary.trim()) lines.push("", summary2.summary.trim());
4813
+ lines.push(...sectionLines(t("\u0427\u0442\u043E \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u043E", "What changed"), summary2.changes));
4814
+ lines.push(...sectionLines(t("\u041D\u0430 \u0447\u0442\u043E \u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C", "What to focus on"), summary2.focus));
4815
+ lines.push(...sectionLines(t("\u0427\u0442\u043E \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u043E", "What was checked"), summary2.coverage));
4816
+ lines.push(...sectionLines(t("\u0427\u0442\u043E \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D\u043E", "Not checked"), summary2.unknowns));
4817
+ lines.push(...sectionLines(t("\u0423\u0436\u0435 \u0441\u043A\u0430\u0437\u0430\u043D\u043E \u0432 \u0442\u0440\u0435\u0434\u0430\u0445", "Already covered"), summary2.duplicates));
4818
+ lines.push(...sectionLines(t("\u041A\u0430\u043D\u0434\u0438\u0434\u0430\u0442\u044B \u0432 \u043F\u0440\u0430\u0432\u0438\u043B\u0430", "Rule candidates"), summary2.ruleCandidates));
4819
+ }
4820
+ lines.push("");
4821
+ lines.push(`## ${t("\u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F", "Findings")}`);
4822
+ const active = view.findings.filter((finding) => finding.status !== "rejected");
4823
+ if (!active.length) {
4824
+ lines.push("");
4825
+ lines.push(t("\u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0439 \u043D\u0435\u0442.", "No findings."));
4826
+ } else {
4827
+ for (const level of LEVEL_ORDER) {
4828
+ const group = active.filter((finding) => finding.level === level);
4829
+ if (!group.length) continue;
4830
+ lines.push("", `### ${LEVEL_LABELS[level][language]}`);
4831
+ for (const finding of group) lines.push(...findingLines(finding, language));
4832
+ }
4833
+ }
4834
+ lines.push("");
4835
+ lines.push(`## ${t("\u041E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0438\u044F", "Limitations")}`);
4836
+ lines.push("");
4837
+ lines.push(
4838
+ `- ${t(
4839
+ "\u0422\u0440\u0435\u0434\u044B, \u0440\u0435\u0430\u043A\u0446\u0438\u0438, CI-checks, approvals \u0438 merge-\u0441\u0442\u0430\u0442\u0443\u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B: \u044D\u0442\u043E \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff.",
4840
+ "Platform threads, reactions, CI checks, approvals and merge status are unavailable: this is a local diff."
4841
+ )}`
4842
+ );
4843
+ lines.push(
4844
+ `- ${t(
4845
+ "\u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043B\u0438\u0441\u044C \u0432 GitLab/GitHub. \u041E\u0442\u0447\u0451\u0442 \u2014 \u0435\u0434\u0438\u043D\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439 \u0430\u0440\u0442\u0435\u0444\u0430\u043A\u0442 \u0440\u0435\u0432\u044C\u044E.",
4846
+ "Findings were not published to GitLab/GitHub. The report is the only review artifact."
4847
+ )}`
4848
+ );
4849
+ if (view.threads.length === 0) {
4850
+ lines.push(`- ${t("\u041E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0439 \u0432 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u0435 \u043D\u0435\u0442: \u0441\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u0442\u044C \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043D\u0435 \u0441 \u0447\u0435\u043C.", "There are no platform discussions to compare findings against.")}`);
4851
+ }
4852
+ lines.push("");
4853
+ return lines.join("\n").trimEnd() + "\n";
4854
+ }
4855
+ function findingLines(finding, language) {
4856
+ const where = finding.line === null ? `\`${finding.file}\`` : `\`${finding.file}:${finding.line}\``;
4857
+ const heading = `- ${where} \u2014 **${finding.title.trim() || finding.id}**`;
4858
+ const meta = [];
4859
+ if (finding.status !== "draft") meta.push(finding.status);
4860
+ if (finding.rule) meta.push(`${language === "ru" ? "\u043F\u0440\u0430\u0432\u0438\u043B\u043E" : "rule"}: ${finding.rule}`);
4861
+ const lines = [meta.length ? `${heading} \xB7 ${meta.join(" \xB7 ")}` : heading];
4862
+ const body = finding.body.trim() || finding.comment.trim();
4863
+ if (body) {
4864
+ for (const line of body.split("\n")) lines.push(` ${line}`);
4865
+ }
4866
+ if (finding.agentNote?.trim()) {
4867
+ lines.push(` > ${language === "ru" ? "\u0434\u043B\u044F \u0430\u0433\u0435\u043D\u0442\u0430" : "for the agent"}: ${finding.agentNote.trim()}`);
4868
+ }
4869
+ return lines;
4870
+ }
4871
+
4872
+ // src/core/local.ts
4873
+ init_locale();
4874
+ function localPreviewRef(view) {
4875
+ const local = view.info.local;
4876
+ if (!local) return null;
4877
+ return {
4878
+ platform: "local",
4879
+ host: view.info.ref.host,
4880
+ project: view.info.ref.project,
4881
+ number: 0,
4882
+ localId: view.id,
4883
+ projectKey: local.projectKey,
4884
+ branch: local.branch,
4885
+ base: local.base
4886
+ };
4887
+ }
4888
+ function encodePreviewRef(ref) {
4889
+ return Buffer.from(JSON.stringify(ref), "utf8").toString("base64url");
4890
+ }
4891
+
4892
+ // src/cli/main.ts
4714
4893
  init_scenario();
4715
4894
  for (const stream of [process.stdout, process.stderr]) {
4716
4895
  stream.on("error", (error) => {
@@ -4733,6 +4912,8 @@ var OPTIONS = {
4733
4912
  host: { type: "string" },
4734
4913
  port: { type: "string" },
4735
4914
  branch: { type: "string" },
4915
+ base: { type: "string" },
4916
+ local: { type: "boolean", default: false },
4736
4917
  file: { type: "string" },
4737
4918
  body: { type: "string" },
4738
4919
  "body-file": { type: "string" },
@@ -4801,6 +4982,8 @@ var HELP_RU = `revdeck ${VERSION} \u2014 \u0440\u0435\u0432\u044C\u044E GitLab/G
4801
4982
  revdeck feature \u0444\u0438\u0447\u0438: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
4802
4983
  revdeck list \u0440\u0435\u0432\u044C\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0433\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430 (--all \u2014 \u0432\u0441\u0435 \u043F\u0440\u043E\u0435\u043A\u0442\u044B; --remote \u2014 \u0441 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B)
4803
4984
  revdeck review <N> \u0440\u0435\u0432\u044C\u044E \u0447\u0443\u0436\u043E\u0433\u043E MR: \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442, \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0438 diff
4985
+ revdeck review --local [--base <\u0432\u0435\u0442\u043A\u0430>] \u0440\u0435\u0432\u044C\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0439 \u0432\u0435\u0442\u043A\u0438 \u0431\u0435\u0437 MR
4986
+ revdeck report --local|--review <id> [--out <\u0444\u0430\u0439\u043B>] [--ui] markdown-\u043E\u0442\u0447\u0451\u0442 \u043F\u043E \u0440\u0435\u0432\u044C\u044E
4804
4987
  revdeck feedback <N> \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u044F \u043A \u0441\u0432\u043E\u0435\u043C\u0443 MR: \u0442\u0440\u0435\u0434\u044B, \u043F\u0440\u0430\u0432\u043A\u0438, \u043E\u0442\u0432\u0435\u0442\u044B
4805
4988
  revdeck open <url|N...> \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u043E\u0434\u043D\u043E \u0438\u043B\u0438 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0440\u0435\u0432\u044C\u044E
4806
4989
  revdeck ui [N] \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441
@@ -4844,6 +5027,8 @@ var HELP_EN = `revdeck ${VERSION} \u2014 code review for GitLab/GitHub, for huma
4844
5027
  revdeck feature features: list|create|get|add|remove|reorder|notes|note|note-delete|context|update|archive|delete
4845
5028
  revdeck list reviews of the current project (--all \u2014 all projects; --remote \u2014 from the platform)
4846
5029
  revdeck review <N> review someone else's MR: context, rules and diff
5030
+ revdeck review --local [--base <ref>] review the current branch without an MR
5031
+ revdeck report --local|--review <id> [--out <file>] [--ui] markdown report for a review
4847
5032
  revdeck feedback <N> work through feedback on your own MR: threads, fixes, replies
4848
5033
  revdeck open <url|N...> only open one or more reviews
4849
5034
  revdeck ui [N] link to the local UI
@@ -4963,7 +5148,9 @@ async function main2() {
4963
5148
  case "context":
4964
5149
  return context(root, positionals[0], values);
4965
5150
  case "review":
4966
- return context(root, positionals[0], withScenario(values, "review"));
5151
+ return context(root, positionals[0], withScenario(values, values.local === true ? "feedback" : "review"));
5152
+ case "report":
5153
+ return report(root, values);
4967
5154
  case "feedback":
4968
5155
  return context(root, positionals[0], withScenario(values, "feedback"));
4969
5156
  case "stats":
@@ -5028,6 +5215,10 @@ function reviewArg(values, positional) {
5028
5215
  return values.review ?? positional;
5029
5216
  }
5030
5217
  async function resolveReview(client2, root, arg, values) {
5218
+ if (arg && /^local-/.test(arg)) {
5219
+ const result = await client2.request("reviews.get", { review: arg });
5220
+ return { review: result.review, id: result.review.id };
5221
+ }
5031
5222
  if (arg && /^(gitlab|github):/.test(arg)) {
5032
5223
  const result = await client2.request("reviews.get", { review: arg });
5033
5224
  return { review: result.review, id: result.review.id };
@@ -5702,7 +5893,14 @@ function withScenario(values, scenario) {
5702
5893
  async function context(root, arg, values) {
5703
5894
  const scenario = parseScenario(values.scenario);
5704
5895
  await withClient(async ({ client: client2 }) => {
5705
- const { review } = await resolveReview(client2, root, reviewArg(values, arg), values);
5896
+ const local = values.local === true;
5897
+ if (local && (arg || values.review)) {
5898
+ fail(tr("--local \u043D\u0435 \u0441\u043E\u0447\u0435\u0442\u0430\u0435\u0442\u0441\u044F \u0441 \u043D\u043E\u043C\u0435\u0440\u043E\u043C \u0440\u0435\u0432\u044C\u044E", "--local cannot be combined with a review number"));
5899
+ }
5900
+ const { review } = local ? await client2.request("reviews.openLocal", {
5901
+ root: toHostRoot(root),
5902
+ ...values.base ? { base: String(values.base) } : {}
5903
+ }).then((result) => ({ review: result.review, id: result.review.id })) : await resolveReview(client2, root, reviewArg(values, arg), values);
5706
5904
  const shard = parseShard(values.shard);
5707
5905
  const { rules: rules2 } = await client2.request("rules.get", {
5708
5906
  review: review.id,
@@ -5721,8 +5919,59 @@ async function context(root, arg, values) {
5721
5919
  ...role ? { role } : {},
5722
5920
  ...shard ? { shard } : {}
5723
5921
  }));
5922
+ if (local) {
5923
+ writers.err(
5924
+ tr(
5925
+ `\u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 diff: ${review.info.local?.branch} \u043F\u0440\u043E\u0442\u0438\u0432 ${review.info.local?.base} \xB7 id ${review.id}`,
5926
+ `local diff: ${review.info.local?.branch} against ${review.info.local?.base} \xB7 id ${review.id}`
5927
+ )
5928
+ );
5929
+ writers.err(tr(`\u0434\u0430\u043B\u044C\u0448\u0435: revdeck report --review ${review.id} --ui`, `next: revdeck report --review ${review.id} --ui`));
5930
+ }
5931
+ });
5932
+ }
5933
+ async function report(root, values) {
5934
+ await withClient(async ({ client: client2 }) => {
5935
+ let id = typeof values.review === "string" ? values.review : "";
5936
+ if (!id && values.local === true) {
5937
+ const result = await client2.request("reviews.openLocal", {
5938
+ root: toHostRoot(root),
5939
+ ...values.base ? { base: String(values.base) } : {}
5940
+ });
5941
+ id = result.review.id;
5942
+ }
5943
+ if (!id) {
5944
+ fail(tr("\u0443\u043A\u0430\u0436\u0438\u0442\u0435 --review <id> \u0438\u043B\u0438 --local", "pass --review <id> or --local"), tr("revdeck report --local", "revdeck report --local"));
5945
+ }
5946
+ const { review } = await client2.request("reviews.get", { review: id });
5947
+ const markdown = renderLocalReport(review, { language: locale() });
5948
+ if (values.out === "-") {
5949
+ writers.out(markdown);
5950
+ } else {
5951
+ const branch = (review.info.local?.branch ?? "diff").replace(/[^A-Za-z0-9._-]+/g, "-");
5952
+ const fallback = path11.join(root, ".revdeck", `review-${branch}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.md`);
5953
+ const target = values.out ? path11.resolve(root, String(values.out)) : fallback;
5954
+ await mkdir5(path11.dirname(target), { recursive: true });
5955
+ await writeFile5(target, markdown, "utf8");
5956
+ writers.out(tr(`\u043E\u0442\u0447\u0451\u0442: ${target}`, `report: ${target}`));
5957
+ }
5958
+ if (values.ui) printLocalUi(review, values, values.out === "-");
5724
5959
  });
5725
5960
  }
5961
+ function printLocalUi(review, values, toStderr = false) {
5962
+ const info = daemonInfoSync();
5963
+ if (!info) return writers.err(tr("\u0434\u0435\u043C\u043E\u043D \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D: revdeck daemon start", "the daemon is not running: revdeck daemon start"));
5964
+ if (!info.token) {
5965
+ return writers.err(
5966
+ tr("UI-\u0442\u043E\u043A\u0435\u043D \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u0445\u043E\u0441\u0442\u0435: \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u043E\u0442\u0447\u0451\u0442 \u043D\u0430 \u0445\u043E\u0441\u0442\u0435", "the UI token is available on the host only: open the report on the host")
5967
+ );
5968
+ }
5969
+ const ref = localPreviewRef(review);
5970
+ if (!ref) return writers.err(tr("\u044D\u0442\u043E \u043D\u0435 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u0435 \u0440\u0435\u0432\u044C\u044E: \u0443 \u043D\u0435\u0433\u043E \u043D\u0435\u0442 \u0441\u043D\u0438\u043C\u043A\u0430 \u0432 UI", "this is not a local review: there is no UI snapshot"));
5971
+ const url = `${uiBaseUrl(info)}/?t=${info.token}#/view/${encodePreviewRef(ref)}/overview`;
5972
+ (toStderr ? writers.err : writers.out)(`UI: ${url}`);
5973
+ if (values.open) openBrowser(url);
5974
+ }
5726
5975
  async function versions(arg, values) {
5727
5976
  await withClient(async ({ client: client2 }) => {
5728
5977
  const { review } = await resolveReview(client2, findRepoRoot(), reviewArg(values, arg), values);