@mergelight/cli 0.1.19 → 0.1.23

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.
@@ -190,7 +190,7 @@ export async function answerRemembered(api, number, ids, cut, log = () => { }) {
190
190
  export const CHECK_FAILED_TITLE = "Couldn't review this pull request";
191
191
  export const checkLoginTitle = (plan) => `The ${plan} login didn't work`;
192
192
  export const checkHeldTitle = `${CHECK_FAILED_TITLE}: the ChatGPT login was held back`;
193
- export const checkLimitTitle = (plan) => (plan === "OpenAI" || plan === "Anthropic" ? `${CHECK_FAILED_TITLE}: the ${plan} API key has no usage left` : `${CHECK_FAILED_TITLE}: your ${plan} plan hit its limit`);
193
+ export const checkLimitTitle = (plan) => (plan === "OpenAI" || plan === "Anthropic" || plan === "Gemini" ? `${CHECK_FAILED_TITLE}: the ${plan} API key has no usage left` : `${CHECK_FAILED_TITLE}: your ${plan} plan hit its limit`);
194
194
  export const isFailedCheckTitle = (title) => Boolean(title && (title.startsWith(CHECK_FAILED_TITLE) || /^The \w+ login didn't work$/.test(title)));
195
195
  /**
196
196
  * Creates the check, or updates it if it has an id. GitHub only lets Apps write
@@ -215,7 +215,7 @@ export async function writeCheck(api, id, headSha, body, log) {
215
215
  * happening. A login that can't write checks hears about it once, from the last write.
216
216
  */
217
217
  export async function startCheck(api, headSha, provider, handedOver, started) {
218
- const tool = provider === "claude" ? "Claude" : provider === "codex" ? "Codex" : null;
218
+ const tool = provider === "claude" ? "Claude" : provider === "codex" ? "Codex" : provider === "antigravity" ? "Antigravity" : null;
219
219
  // Always a check of the review's own, for the commit it reads: approvals and verdicts then go to the
220
220
  // check this review made, never to an older one.
221
221
  const run = await writeCheck(api, null, headSha, {
@@ -429,6 +429,12 @@ export const UNREVIEWED = "Mergelight couldn't review the newest commit, so its
429
429
  export const APPROVAL_MARKER = "<!-- mergelight:approval -->";
430
430
  /** Only these post Mergelight's reviews, so a person's review that quotes the marker is never touched. */
431
431
  const OWN_REVIEWERS = new Set(["mergelight-ai[bot]", "github-actions[bot]"]);
432
+ /** The Mergelight AI app: every review it posts is Mergelight's, so its approval needs no marker, and shows none. */
433
+ const APP_REVIEWER = "mergelight-ai[bot]";
434
+ /** What an approval says when it needs the marker: posted as github-actions[bot], which other workflows use too. */
435
+ const APPROVAL_TEXT = "🟢 Mergelight found nothing that needs fixing in this commit.";
436
+ /** Mergelight's own approvals: any by its app, and those with the marker by the workflow's own bot. */
437
+ const isOwnApproval = (r) => r.user?.login === APP_REVIEWER || (OWN_REVIEWERS.has(r.user?.login ?? "") && (r.body ?? "").includes(APPROVAL_MARKER));
432
438
  /**
433
439
  * Green approves the pull request, like a reviewer would. Anything else takes back an approval Mergelight gave
434
440
  * earlier, so an old approval can't stand next to a newer finding. Yellow and red never request changes, so a
@@ -436,16 +442,21 @@ const OWN_REVIEWERS = new Set(["mergelight-ai[bot]", "github-actions[bot]"]);
436
442
  */
437
443
  export async function syncApproval(api, number, light, headSha, log = () => { }, dismissal = {}) {
438
444
  try {
439
- const ours = (await api.list(`pulls/${number}/reviews`)).filter((r) => OWN_REVIEWERS.has(r.user?.login ?? "") && (r.body ?? "").includes(APPROVAL_MARKER));
445
+ const ours = (await api.list(`pulls/${number}/reviews`)).filter(isOwnApproval);
440
446
  const standing = ours.filter((r) => r.state === "APPROVED");
441
447
  if (light === "green") {
442
448
  if (standing.some((r) => r.commit_id === headSha))
443
449
  return "already";
444
- await api.write("POST", `pulls/${number}/reviews`, {
445
- commit_id: headSha,
446
- event: "APPROVE",
447
- body: `${APPROVAL_MARKER}\n🟢 Mergelight found nothing that needs fixing in this commit.`,
448
- });
450
+ // A plain approval, like a person's: the summary says the rest.
451
+ const posted = await api.write("POST", `pulls/${number}/reviews`, { commit_id: headSha, event: "APPROVE" });
452
+ // Posted by the workflow's own bot, which other workflows approve as too: the marker tells this one
453
+ // apart, so a later review can take it back. One that can't be told apart is taken back at once.
454
+ if (posted?.id && posted.user?.login !== APP_REVIEWER) {
455
+ await api.write("PUT", `pulls/${number}/reviews/${posted.id}`, { body: `${APPROVAL_MARKER}\n${APPROVAL_TEXT}` }).catch(async (err) => {
456
+ await api.write("PUT", `pulls/${number}/reviews/${posted.id}/dismissals`, { message: "Mergelight couldn't mark this approval as its own, so it takes it back. The next review approves again.", event: "DISMISS" });
457
+ throw err;
458
+ });
459
+ }
449
460
  return "approved";
450
461
  }
451
462
  const taken = dismissal.otherCommitsOnly ? standing.filter((r) => r.commit_id !== headSha) : standing;
package/dist/review.js CHANGED
@@ -6,7 +6,7 @@ import { fetchPullRequest } from "./github.js";
6
6
  import { buildCheckPrompt, buildHunterPrompt, buildSweepPrompt, buildVerifierPrompt, focusesFor, ruleApplies, usedMemories, } from "./prompt.js";
7
7
  import { LimitError, LoginError, SandboxError } from "./providers/codex.js";
8
8
  import { MAX_REPO_RULES } from "./repo-rules.js";
9
- import { claudeAvailable, runModel as runOneModel, TOOLING } from "./providers/index.js";
9
+ import { claudeAvailable, FILE_TOOLS, PROVIDER_LABEL, runModel as runOneModel, TOOLING } from "./providers/index.js";
10
10
  import { candidateSchema, checkSchema, reviewSchema, reviewSchemaWithDecisions } from "./schema.js";
11
11
  import { CHECK_TIMEOUT_MS, startTeamChecks } from "./checks.js";
12
12
  import { run } from "./run.js";
@@ -126,12 +126,13 @@ function counting(tally) {
126
126
  /** Tells the prompts which tools the agent has. Without a shell it can't run git diff, so a big diff goes into the checkout. */
127
127
  function forProvider(dir, input, provider) {
128
128
  const tooling = TOOLING[provider];
129
+ const fileTools = tooling === "files" ? FILE_TOOLS[provider] : undefined;
129
130
  if (tooling !== "files" || !input.diffTruncated)
130
- return { ...input, tooling };
131
+ return { ...input, tooling, fileTools };
131
132
  const diffFile = ".mergelight/pr.diff";
132
133
  mkdirSync(join(dir, ".mergelight"), { recursive: true });
133
134
  writeFileSync(join(dir, diffFile), input.diff);
134
- return { ...input, tooling, diffFile };
135
+ return { ...input, tooling, fileTools, diffFile };
135
136
  }
136
137
  /** The diff one of the team's checks reads: at most this much of it goes into the question. */
137
138
  const MAX_CHECK_DIFF = 150_000;
@@ -175,8 +176,8 @@ export async function verifyCandidates(dir, input, found, opts) {
175
176
  }
176
177
  /** Every rule a team can have for one repository: 50 for the org and 50 of its own on the dashboard, and those in its rule files. None is dropped. */
177
178
  const MAX_RULES = 100 + MAX_REPO_RULES;
178
- /** The summary, with what the reader must know about the team's rules: a guarded file was changed, or the rules couldn't be read. */
179
- export function summaryWith(summary, needsHuman, rulesUnread) {
179
+ /** The summary, with what the reader must know about the team's rules: a guarded file was changed, the rules couldn't be read, or the org's plan ended. */
180
+ export function summaryWith(summary, needsHuman, rulesUnread, planEnded = false) {
180
181
  // As code, so a name like __init__.py shows as it is and not as bold text.
181
182
  const code = (path) => `\`${path.replace(/`/g, "'").replace(/[\u0000-\u001f\u007f]/g, "?")}\``;
182
183
  const guarded = needsHuman.length
@@ -184,7 +185,9 @@ export function summaryWith(summary, needsHuman, rulesUnread) {
184
185
  : "";
185
186
  // A team may have rules that would have changed this review. Running without them must never be silent.
186
187
  const unread = rulesUnread ? " Mergelight couldn't get your team's rules, skills, checks and earlier decisions from its server, so this review ran without them." : "";
187
- return `${summary}${guarded}${unread}`;
188
+ // Said, not held: a team that stopped paying still gets its reviews, and must know they ran without its rules.
189
+ const ended = planEnded && !rulesUnread ? " Your org's Mergelight plan ended or is paused, so this review ran without the rules, skills, checks and saved decisions on your Mergelight dashboard." : "";
190
+ return `${summary}${guarded}${unread}${ended}`;
188
191
  }
189
192
  /**
190
193
  * The light, with the team's "always needs a human" files taken into account. Such a file keeps a
@@ -254,6 +257,7 @@ export async function reviewPullRequest(ref, opts = {}) {
254
257
  diffTruncated: ws.diffTruncated,
255
258
  previous: opts.previous,
256
259
  ...(opts.round ? { round: opts.round } : {}),
260
+ ...(opts.teamAnswer ? { teamAnswer: opts.teamAnswer } : {}),
257
261
  memories: memoriesFor(opts.memories, ws.changedFiles.map((f) => f.path), pr.number),
258
262
  // Matched against every path the pull request touches, exactly as git has it.
259
263
  skills: teamSkills,
@@ -275,9 +279,10 @@ export async function reviewPullRequest(ref, opts = {}) {
275
279
  unread = notRead(input.actionSources);
276
280
  }
277
281
  // Who checks is known before the hunt, so the first reviewer that answers can name both models.
278
- const verifyWith = opts.verifyWith ?? (provider === "claude" || (await claudeAvailable()) ? "claude" : "codex");
282
+ // Antigravity checks its own findings unless told otherwise: nothing says another AI here has a login.
283
+ const verifyWith = opts.verifyWith ?? (provider === "antigravity" ? "antigravity" : provider === "claude" || (await claudeAvailable()) ? "claude" : "codex");
279
284
  // The reviewer's model only carries over to the same AI: a Claude model name means nothing to Codex.
280
- const verifyModel = verifyWith === "codex" ? (opts.verifyModel ?? (provider === "codex" ? opts.model : undefined)) : (opts.verifyModel ?? "opus");
285
+ const verifyModel = verifyWith === "claude" ? (opts.verifyModel ?? "opus") : (opts.verifyModel ?? (provider === verifyWith ? opts.model : undefined));
281
286
  let named = false;
282
287
  const nameModels = (reviewerModel) => {
283
288
  if (named)
@@ -348,7 +353,7 @@ export async function reviewPullRequest(ref, opts = {}) {
348
353
  const teamChecks = opts.checks?.length
349
354
  ? startTeamChecks(opts.checks, ws.touchedPaths, async (check, files) => (await runModel(provider, {
350
355
  cwd: ws.dir,
351
- prompt: buildCheckPrompt({ ...input, tooling: TOOLING[provider] }, check, files, await checkDiff(ws.dir, ws.mergeBase, ws.headSha, files)),
356
+ prompt: buildCheckPrompt({ ...input, tooling: TOOLING[provider], fileTools: TOOLING[provider] === "files" ? FILE_TOOLS[provider] : undefined }, check, files, await checkDiff(ws.dir, ws.mergeBase, ws.headSha, files)),
352
357
  schema: checkSchema,
353
358
  model: hunterModel,
354
359
  effort,
@@ -362,7 +367,7 @@ export async function reviewPullRequest(ref, opts = {}) {
362
367
  // Opus checks better than Codex: in the eval it posted a third less and kept the same finds.
363
368
  if (!opts.verifyWith && verifyWith === "codex")
364
369
  progress("Claude Code isn't installed, so Codex checks the findings");
365
- progress(`Checking ${found.length} candidate${found.length === 1 ? "" : "s"}${verifyWith === "codex" ? "" : ` with ${verifyWith}`}`);
370
+ progress(`Checking ${found.length} candidate${found.length === 1 ? "" : "s"}${verifyWith === "codex" ? "" : ` with ${PROVIDER_LABEL[verifyWith]}`}`);
366
371
  const servedModelSoFar = () => {
367
372
  const first = hunts.find((h) => h.status === "fulfilled");
368
373
  return first?.status === "fulfilled" ? first.value.model : null;
@@ -386,8 +391,8 @@ export async function reviewPullRequest(ref, opts = {}) {
386
391
  if (verifyWith === provider || !(err instanceof LoginError || err instanceof LimitError || err instanceof SandboxError))
387
392
  throw err;
388
393
  checkerFailed = err instanceof LimitError ? "limit" : err instanceof SandboxError ? "sandbox" : "login-failed";
389
- progress(`${verifyWith === "codex" ? "Codex" : "Claude"} couldn't check (${err.message.slice(0, 120)}), so ${provider === "codex" ? "Codex" : "Claude"} checks the findings`);
390
- const fallbackModel = provider === "codex" ? opts.model : (opts.model ?? "opus");
394
+ progress(`${PROVIDER_LABEL[verifyWith]} couldn't check (${err.message.slice(0, 120)}), so ${PROVIDER_LABEL[provider]} checks the findings`);
395
+ const fallbackModel = provider === "claude" ? (opts.model ?? "opus") : opts.model;
391
396
  // The live comment names the AI that checks now.
392
397
  opts.onModels?.({ reviewer: { name: provider, model: servedModelSoFar() }, checker: { name: provider, model: fallbackModel ?? null } });
393
398
  verified = await verifyWithAi(provider, fallbackModel);
@@ -416,7 +421,7 @@ export async function reviewPullRequest(ref, opts = {}) {
416
421
  verifier: { name: checkedBy, model: verified.model, effort, cost_usd: verified.cost_usd },
417
422
  ...(checkerFailed ? { checker_missed: verifyWith, checker_missed_why: checkerFailed } : {}),
418
423
  light: lightWith(verified.findings, needsHuman),
419
- summary: summaryWith(verified.summary, needsHuman, opts.rulesUnread === true),
424
+ summary: summaryWith(verified.summary, needsHuman, opts.rulesUnread === true, opts.planEnded === true),
420
425
  ...(needsHuman.length ? { needs_human: needsHuman } : {}),
421
426
  findings: verified.findings,
422
427
  ...(input.memories?.length ? { used_memories: usedMemories(input.memories, verified.rejected, found) } : {}),
package/dist/setup.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { rolledOut } from "./update.js";
1
2
  import { spawn } from "node:child_process";
2
3
  import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
4
  import { tmpdir } from "node:os";
@@ -43,9 +44,14 @@ export function workflowFiles(skipBranches = [], pin, jobs = false) {
43
44
  });
44
45
  }
45
46
  /** The latest release, as a commit. */
47
+ /** The version @v0 points to: the newest release whose canary passed, never one still being tried. */
46
48
  async function latestPin(deps) {
47
- const tag = (await deps.gh(["api", `repos/${ACTION}/releases/latest`, "--jq", ".tag_name"])).trim();
48
- const sha = (await deps.gh(["api", `repos/${ACTION}/commits/${tag}`, "--jq", ".sha"])).trim();
49
+ // Every page: GitHub lists v0 after all the version tags, so it falls past the first page in time.
50
+ const tags = JSON.parse(await deps.gh(["api", "--paginate", "--slurp", `repos/${ACTION}/tags?per_page=100`])).flat();
51
+ const tag = rolledOut(tags);
52
+ const sha = tags.find((t) => t.name === tag)?.commit.sha;
53
+ if (!tag || !sha)
54
+ throw new Error("Couldn't tell which Mergelight release is current. Run setup again, or use --no-pin.");
49
55
  return { sha, tag };
50
56
  }
51
57
  /** A ChatGPT login is only useful in CI if it can refresh itself. */
package/dist/update.js CHANGED
@@ -4,7 +4,8 @@ import { readFileSync } from "node:fs";
4
4
  * tells those people when there's a newer release. It's only a hint, so anything going wrong
5
5
  * here just means no hint.
6
6
  */
7
- const CURRENT = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
7
+ /** This package's version, like 0.1.19. */
8
+ export const CURRENT = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
8
9
  const parts = (version) => version.replace(/^v/, "").split(".").map(Number);
9
10
  export function isNewer(candidate, than) {
10
11
  const [a, b] = [parts(candidate), parts(than)];
@@ -15,6 +16,16 @@ export function isNewer(candidate, than) {
15
16
  }
16
17
  return false;
17
18
  }
19
+ /**
20
+ * The version @v0 points to: the newest release whose canary review passed. A newer release that is still
21
+ * being tried has no one pointed at it yet. Null when it can't be told.
22
+ */
23
+ export function rolledOut(tags) {
24
+ const v0 = tags.find((t) => t.name === "v0")?.commit.sha;
25
+ if (!v0)
26
+ return null;
27
+ return tags.filter((t) => t.commit.sha === v0 && /^v\d+\.\d+\.\d+$/.test(t.name)).map((t) => t.name).sort((a, b) => (isNewer(a, b) ? -1 : 1))[0] ?? null;
28
+ }
18
29
  /** The changes a release's generated notes list, without the version bumps. */
19
30
  export function releaseNews(notes) {
20
31
  return [...notes.matchAll(/^\* (.+?) by @\S+ in https:\/\/\S+$/gm)].map((m) => m[1]).filter((title) => !/^Release v\d/.test(title));
@@ -25,7 +36,12 @@ export async function newerVersion(api, current = CURRENT, ref = process.env.MER
25
36
  return null;
26
37
  try {
27
38
  const releases = await api.get("/repos/mergelightai/mergelight/releases?per_page=30");
28
- const newer = releases.filter((r) => !r.draft && !r.prerelease && isNewer(r.tag_name, current)).sort((a, b) => (isNewer(a.tag_name, b.tag_name) ? -1 : 1));
39
+ // Never past the version @v0 points to: a release still in its canary isn't offered yet.
40
+ // Every page: GitHub lists v0 after all the version tags, so it falls past the first page in time.
41
+ const top = rolledOut(await api.list("/repos/mergelightai/mergelight/tags"));
42
+ if (!top)
43
+ return null;
44
+ const newer = releases.filter((r) => !r.draft && !r.prerelease && isNewer(r.tag_name, current) && !isNewer(r.tag_name, top)).sort((a, b) => (isNewer(a.tag_name, b.tag_name) ? -1 : 1));
29
45
  if (!newer.length)
30
46
  return null;
31
47
  return { tag: newer[0].tag_name, current: `v${current.replace(/^v/, "")}`, news: newer.flatMap((r) => releaseNews(r.body ?? "")) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mergelight/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.23",
4
4
  "description": "AI code review that runs on the Claude or ChatGPT plan you already pay for.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -130,9 +130,27 @@ export function isDue(event, expiry, now) {
130
130
  * Returns the reason if it can tell that something went wrong. Its logs stay out of ours, since they
131
131
  * deal with the login.
132
132
  */
133
+ /**
134
+ * A known cause of a failed refresh in what Codex wrote to its error output, or null. Only the cause, never
135
+ * the output itself, which can hold tokens.
136
+ */
137
+ export function refreshFailure(text) {
138
+ if (/refresh_token_reused|already (?:been )?used/i.test(text)) return "the refresh token was already used";
139
+ if (/refresh_token_expired|refresh token (?:has )?expired/i.test(text)) return "the refresh token ran out";
140
+ if (/refresh_token_invalidated|invalid_grant/i.test(text)) return "the refresh token was refused";
141
+ const status = /\b(?:status(?: code)?|HTTP)[\s:=]*([45]\d\d)\b/i.exec(text)?.[1];
142
+ return status ? `HTTP ${status}` : null;
143
+ }
144
+
133
145
  export function forceRefresh({ env = process.env, spawnImpl = spawn, timeoutMs = 90_000 } = {}) {
134
146
  return new Promise((resolve) => {
135
- const child = spawnImpl("codex", ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env });
147
+ const child = spawnImpl("codex", ["app-server"], { stdio: ["pipe", "pipe", "pipe"], env });
148
+ // Read, so Codex never waits on a full pipe, and kept only to find a known cause in.
149
+ let errors = "";
150
+ child.stderr?.setEncoding?.("utf8");
151
+ child.stderr?.on("data", (chunk) => {
152
+ if (errors.length < 64 * 1024) errors += chunk;
153
+ });
136
154
  const send = (message) => child.stdin.write(`${JSON.stringify(message)}\n`);
137
155
  let done = false;
138
156
  const finish = (reason = null) => {
@@ -140,7 +158,8 @@ export function forceRefresh({ env = process.env, spawnImpl = spawn, timeoutMs =
140
158
  done = true;
141
159
  clearTimeout(timer);
142
160
  child.kill();
143
- resolve(reason);
161
+ // A failed refresh can still answer normally: then Codex's error output may name the cause.
162
+ resolve(reason ?? refreshFailure(errors));
144
163
  };
145
164
  const timer = setTimeout(() => finish("Codex didn't answer in time"), timeoutMs);
146
165
  child.on("error", (err) => finish(err.message));
@@ -7,23 +7,29 @@ name: Mergelight
7
7
  on:
8
8
  pull_request:
9
9
  types: [opened, synchronize, reopened, ready_for_review, edited]
10
+ # A comment that mentions @mergelight-ai on a pull request reviews it again, reading the comment as your
11
+ # team's answer to the findings: what's fixed, and what to leave and why. Only people who can push count.
12
+ issue_comment:
13
+ types: [created]
10
14
 
11
15
  # Each job says what it may do. Only push-jobs may push, and it runs no AI.
12
16
  permissions: {}
13
17
 
14
18
  # A new push cancels the older run of the same pull request. An edit that changes only the title or
15
19
  # description starts nothing, so it gets a group of its own and never cancels a run that is working.
16
- # A run started again by hand waits for the one going instead of cancelling it.
20
+ # So does every comment: one that doesn't mention Mergelight starts nothing either. A run started again
21
+ # by hand waits for the one going instead of cancelling it.
17
22
  concurrency:
18
- group: mergelight-pr-${{ github.event.pull_request.number }}${{ (github.event.action == 'edited' && !github.event.changes.base) && '-edit' || '' }}
23
+ group: mergelight-pr-${{ github.event.pull_request.number || github.event.issue.number }}${{ github.event_name == 'issue_comment' && format('-comment-{0}', github.event.comment.id) || ((github.event.action == 'edited' && !github.event.changes.base) && '-edit' || '') }}
19
24
  cancel-in-progress: ${{ github.run_attempt == 1 }}
20
25
 
21
26
  jobs:
22
27
  # The AI does the jobs, with a token that can only read, and writes what they changed to a file.
23
28
  run-jobs:
24
29
  # Forks and Dependabot get no secrets, and drafts aren't ready. An edit only counts when the target
25
- # branch changed, so a new title starts nothing.
30
+ # branch changed, so a new title starts nothing. A comment runs no jobs.
26
31
  if: >
32
+ github.event_name == 'pull_request' &&
27
33
  (github.event.action != 'edited' || github.event.changes.base) &&
28
34
  !github.event.pull_request.draft &&
29
35
  github.actor != 'dependabot[bot]' &&
@@ -89,13 +95,19 @@ jobs:
89
95
  # The review, as in mergelight.yml, of the commit the jobs pushed when they pushed one.
90
96
  review:
91
97
  needs: [run-jobs, push-jobs]
92
- # Also after jobs that failed or had nothing to push, but not in a run a newer push cancelled.
98
+ # Also after jobs that failed or had nothing to push, but not in a run a newer push cancelled. A comment
99
+ # counts when it mentions Mergelight on a pull request, and isn't a bot's.
93
100
  if: >
94
101
  !cancelled() &&
102
+ ((github.event_name == 'issue_comment' &&
103
+ github.event.issue.pull_request &&
104
+ contains(github.event.comment.body, '@mergelight-ai') &&
105
+ github.event.comment.user.type != 'Bot') ||
106
+ (github.event_name == 'pull_request' &&
95
107
  (github.event.action != 'edited' || github.event.changes.base) &&
96
108
  !github.event.pull_request.draft &&
97
109
  github.actor != 'dependabot[bot]' &&
98
- github.event.pull_request.head.repo.full_name == github.repository
110
+ github.event.pull_request.head.repo.full_name == github.repository))
99
111
  runs-on: ubuntu-latest
100
112
  # Room for the first login, which can wait up to 16 minutes, and then a long review.
101
113
  timeout-minutes: 45
@@ -5,6 +5,10 @@ name: Mergelight
5
5
  on:
6
6
  pull_request:
7
7
  types: [opened, synchronize, reopened, ready_for_review, edited]
8
+ # A comment that mentions @mergelight-ai on a pull request reviews it again, reading the comment as your
9
+ # team's answer to the findings: what's fixed, and what to leave and why. Only people who can push count.
10
+ issue_comment:
11
+ types: [created]
8
12
 
9
13
  permissions:
10
14
  contents: read
@@ -15,18 +19,25 @@ permissions:
15
19
  jobs:
16
20
  review:
17
21
  # Forks and Dependabot get no secrets, and drafts aren't ready for review. An edit only counts when the
18
- # target branch changed, so a new title doesn't start a review.
22
+ # target branch changed, so a new title doesn't start a review. A comment counts when it mentions
23
+ # Mergelight on a pull request, and isn't a bot's.
19
24
  if: >
25
+ (github.event_name == 'issue_comment' &&
26
+ github.event.issue.pull_request &&
27
+ contains(github.event.comment.body, '@mergelight-ai') &&
28
+ github.event.comment.user.type != 'Bot') ||
29
+ (github.event_name == 'pull_request' &&
20
30
  (github.event.action != 'edited' || github.event.changes.base) &&
21
31
  !github.event.pull_request.draft &&
22
32
  github.actor != 'dependabot[bot]' &&
23
- github.event.pull_request.head.repo.full_name == github.repository
33
+ github.event.pull_request.head.repo.full_name == github.repository)
24
34
  runs-on: ubuntu-latest
25
35
  # Room for the first login, which can wait up to 16 minutes, and then a long review.
26
36
  timeout-minutes: 45
27
- # A new push cancels the older review of the same PR.
37
+ # A new push cancels the older review of the same PR. A comment's review has a group of its own, so
38
+ # neither cancels the other.
28
39
  concurrency:
29
- group: mergelight-pr-${{ github.event.pull_request.number }}
40
+ group: mergelight-pr-${{ github.event.pull_request.number || github.event.issue.number }}${{ github.event_name == 'issue_comment' && format('-comment-{0}', github.event.comment.id) || '' }}
30
41
  cancel-in-progress: true
31
42
  steps:
32
43
  # Not pinned, on purpose. @v0 moves to each new release, so fixes reach you without