@mergelight/cli 0.1.18 → 0.1.19

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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync, writeFileSync } from "node:fs";
2
+ import { appendFileSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { parseArgs } from "node:util";
4
4
  import { currentRepo, fetchPullRequest, parsePrRef } from "./github.js";
5
5
  import { serve } from "./mcp/server.js";
@@ -7,11 +7,14 @@ import { declinesOf, fetchContext, MAX_REASON, reportReview } from "./cloud.js";
7
7
  import { GitHub } from "./publish/api.js";
8
8
  import { writeAccess } from "./publish/handled.js";
9
9
  import { publishTeamChecks } from "./publish/team-checks.js";
10
- import { answerRemembered, confirmReasons, approveCheck, checkLimitTitle, checkLoginTitle, failCheck, failSummary, previousFindings, publishReview, startCheck, startSummary, syncApproval, UNREVIEWED, APPROVALS_OFF, updatePendingSummary } from "./publish/publish.js";
11
- import { configuredModel, LimitError, LoginError, loginFailureMessage } from "./providers/codex.js";
12
- import { limitNotice, loginNotice } from "./publish/markdown.js";
10
+ import { answerRemembered, confirmReasons, approveCheck, checkHeldTitle, checkLimitTitle, checkLoginTitle, failCheck, failSummary, previousReview, publishReview, startCheck, startSummary, syncApproval, UNREVIEWED, APPROVALS_OFF, updatePendingSummary } from "./publish/publish.js";
11
+ import { configuredModel, HeldLoginError, LimitError, LoginError, loginFailureMessage } from "./providers/codex.js";
12
+ import { heldLoginNotice, limitNotice, loginNotice } from "./publish/markdown.js";
13
13
  import { renderRejected, renderTerminal } from "./render.js";
14
14
  import { reviewPullRequest } from "./review.js";
15
+ import { jobsCommand } from "./jobs-command.js";
16
+ import { pushJobs } from "./push-jobs.js";
17
+ import { jobsReport } from "./run-jobs.js";
15
18
  import { askForApp, connect, githubConnect } from "./connect.js";
16
19
  import { init, realInitDeps } from "./init.js";
17
20
  import { realDeps, setup } from "./setup.js";
@@ -25,6 +28,11 @@ Usage
25
28
  mergelight mcp Run the MCP server, so your coding agent can read findings
26
29
  mergelight setup <owner/repo> Set up the GitHub Action on a repository
27
30
  mergelight connect <pr> In the Action: connect ChatGPT from the pull request
31
+ mergelight jobs <pr> [--out <file>] Run the team's jobs from .mergelight/jobs on a pull request, and
32
+ write what they changed to a file. Nothing is pushed or posted
33
+ mergelight push-jobs <pr> --from <file>
34
+ Check a jobs file again against the base branch, and push it as
35
+ one commit to the pull request's branch. Runs no AI
28
36
 
29
37
  <pr> is a pull request URL, owner/repo#123, or a number inside a clone.
30
38
 
@@ -43,7 +51,12 @@ Options
43
51
  --effort <level> Reasoning effort: low, medium, high (default: high)
44
52
  --verify-with <name> Who checks the findings: claude or codex
45
53
  (default: claude when Claude Code is installed)
54
+ --verify-missed <name>
55
+ The AI that was meant to check but had no login: the summary says so
46
56
  --verify-model <name> Model for the checker (default for claude: opus)
57
+ --jobs <file> With --post: the file mergelight jobs wrote, for the Jobs part of the summary
58
+ --jobs-commit <sha> With --jobs: the commit the push step made. It is the one reviewed
59
+ --jobs-why <text> With --jobs: why the push step pushed nothing
47
60
  --keep Keep the temporary checkout
48
61
  --by <login> Who approved, for approve
49
62
  With approve, --at is the commit they approved: an older one doesn't count
@@ -51,8 +64,12 @@ Options
51
64
  --skip-branches <a,b> For setup: don't review pull requests from these branches
52
65
  --relogin For setup: log in to Codex again
53
66
  --no-pin For setup: follow @v0 and get each release by itself, instead of pinning to the latest
67
+ --with-jobs For setup: also run the team's jobs from .mergelight/jobs (see docs/jobs.md)
54
68
  --yes For setup: don't stop to ask whether the app is installed
55
69
  --no-save For connect: there's nowhere to save a login, so ask for the app instead
70
+ --for check --ai <name> --reviewer <name>
71
+ For connect: connect the AI that checks another AI's review. Nobody
72
+ connecting it holds nothing up: the reviewer checks instead
56
73
  -h, --help Show this help
57
74
 
58
75
  Reviews run on your own logged-in Codex CLI, and Claude Code if you check with it.
@@ -113,8 +130,18 @@ async function main() {
113
130
  relogin: { type: "boolean" },
114
131
  pin: { type: "boolean" },
115
132
  "no-pin": { type: "boolean" },
133
+ "with-jobs": { type: "boolean" },
116
134
  yes: { type: "boolean" },
117
135
  "no-save": { type: "boolean" },
136
+ for: { type: "string" },
137
+ ai: { type: "string" },
138
+ reviewer: { type: "string" },
139
+ "verify-missed": { type: "string" },
140
+ "verify-missed-why": { type: "string" },
141
+ from: { type: "string" },
142
+ jobs: { type: "string" },
143
+ "jobs-commit": { type: "string" },
144
+ "jobs-why": { type: "string" },
118
145
  help: { type: "boolean", short: "h" },
119
146
  },
120
147
  });
@@ -135,6 +162,7 @@ async function main() {
135
162
  skipBranches: values["skip-branches"]?.split(",").map((b) => b.trim()).filter(Boolean),
136
163
  relogin: values.relogin,
137
164
  pin: !values["no-pin"],
165
+ jobs: values["with-jobs"],
138
166
  yes: values.yes,
139
167
  }, realDeps());
140
168
  }
@@ -156,7 +184,7 @@ async function main() {
156
184
  await serve();
157
185
  return 0;
158
186
  }
159
- if (!["review", "post", "approve", "connect"].includes(command) || !target) {
187
+ if (!["review", "post", "approve", "connect", "jobs", "push-jobs"].includes(command) || !target) {
160
188
  process.stderr.write(HELP);
161
189
  return 1;
162
190
  }
@@ -171,6 +199,12 @@ async function main() {
171
199
  log(`mergelight: --verify-with must be codex or claude, not "${verifyWith}"`);
172
200
  return 1;
173
201
  }
202
+ // The AI the team asked to check, which had no login, so the reviewer's own AI checked instead.
203
+ const verifyMissed = values["verify-missed"];
204
+ if (verifyMissed !== undefined && verifyMissed !== "codex" && verifyMissed !== "claude") {
205
+ log(`mergelight: --verify-missed must be codex or claude, not "${verifyMissed}"`);
206
+ return 1;
207
+ }
174
208
  if (command === "post") {
175
209
  const review = JSON.parse(readFileSync(target, "utf8"));
176
210
  const result = await publishReview(review, { dryRun, log, yellowBlocks: values["yellow-blocks"], approve: !values["no-approve"] });
@@ -178,16 +212,72 @@ async function main() {
178
212
  return 0;
179
213
  }
180
214
  const ref = parsePrRef(target, values.repo ?? (await currentRepo()));
215
+ if (command === "jobs") {
216
+ const progress = progressPrinter();
217
+ try {
218
+ // A log line clears the progress line first, so the two never run together in a terminal.
219
+ const clearing = (line) => log(process.stderr.isTTY ? `\r\x1b[2K${line}` : line);
220
+ return await jobsCommand(ref, { provider, model: values.model, effort: values.effort, out: values.out, at: values.at, keep: values.keep, log: clearing, onProgress: progress.onProgress });
221
+ }
222
+ catch (err) {
223
+ progress.stop();
224
+ log(`mergelight: ${err instanceof Error ? err.message : String(err)}`);
225
+ return 1;
226
+ }
227
+ finally {
228
+ progress.stop();
229
+ }
230
+ }
231
+ if (command === "push-jobs") {
232
+ if (!values.from) {
233
+ log("push-jobs needs --from <file>, the file mergelight jobs wrote");
234
+ return 1;
235
+ }
236
+ try {
237
+ return await pushJobs(ref, { from: values.from, dryRun, log });
238
+ }
239
+ catch (err) {
240
+ log(`mergelight: ${err instanceof Error ? err.message : String(err)}`);
241
+ return 1;
242
+ }
243
+ }
181
244
  if (command === "connect") {
245
+ // --for check: connect the AI that checks another AI's review. It never stops the review: when nobody
246
+ // connects it, or it can't be saved, the reviewer's own AI checks, and the review's summary says so.
247
+ const check = values.for === "check";
248
+ const ai = values.ai;
249
+ const reviewer = values.reviewer;
250
+ if (values.for !== undefined && values.for !== "check" && values.for !== "review") {
251
+ log(`mergelight: --for must be review or check, not "${values.for}"`);
252
+ return 1;
253
+ }
254
+ if (check && ((ai !== "codex" && ai !== "claude") || (reviewer !== "codex" && reviewer !== "claude") || ai === reviewer)) {
255
+ log("mergelight: connect --for check needs --ai and --reviewer, each codex or claude, and not the same.");
256
+ return 1;
257
+ }
258
+ // For a review, --ai claude offers only Claude's link: the workflow says Claude reviews, and it has no login yet.
259
+ if (!check && ai !== undefined && ai !== "claude") {
260
+ log(`mergelight: for a review, --ai can only be claude, not "${ai}"`);
261
+ return 1;
262
+ }
182
263
  try {
183
264
  const api = new GitHub(ref.owner, ref.repo, { log });
184
265
  const { headSha } = await fetchPullRequest(ref);
266
+ if (check) {
267
+ if (values["no-save"]) {
268
+ log(`There's nowhere to save a ${ai === "codex" ? "ChatGPT" : "Claude"} login without the Mergelight AI app, so the reviewer's own AI checks this time.`);
269
+ return 0;
270
+ }
271
+ await connect(githubConnect(api, ref.number, headSha, log, process.env, { purpose: "check", ai: ai, reviewer: reviewer }));
272
+ return 0;
273
+ }
274
+ const login = ai === "claude" ? "Claude" : "ChatGPT";
185
275
  if (values["no-save"]) {
186
- await askForApp(api, ref.number, headSha);
187
- log("Install the Mergelight AI app: without it there's nowhere to save the ChatGPT login.");
276
+ await askForApp(api, ref.number, headSha, login);
277
+ log(`Install the Mergelight AI app: without it there's nowhere to save the ${login} login.`);
188
278
  return 1;
189
279
  }
190
- return await connect(githubConnect(api, ref.number, headSha, log));
280
+ return await connect(githubConnect(api, ref.number, headSha, log, process.env, ai === "claude" ? { purpose: "review", ai: "claude" } : { purpose: "review" }));
191
281
  }
192
282
  catch (err) {
193
283
  log(`mergelight: ${err instanceof Error ? err.message : String(err)}`);
@@ -204,18 +294,60 @@ async function main() {
204
294
  }
205
295
  // review
206
296
  const api = new GitHub(ref.owner, ref.repo, { dryRun, log });
297
+ // What the team's jobs did just before: shown in the summary, and their commit is the one reviewed.
298
+ let jobs = null;
299
+ if (values.jobs) {
300
+ try {
301
+ jobs = jobsReport(JSON.parse(readFileSync(values.jobs, "utf8")), { commit: values["jobs-commit"], why: values["jobs-why"] });
302
+ }
303
+ catch (err) {
304
+ log(`Couldn't read the jobs file, so the summary leaves the jobs out: ${err.message}`);
305
+ }
306
+ }
307
+ const jobCommit = jobs?.commit ? { sha: jobs.commit, jobs: jobs.outcomes.filter((o) => o.status === "changed").map((o) => o.name) } : undefined;
308
+ // The commit the push step names is the one to review, also when the jobs file can't be read.
309
+ values.at ??= jobCommit?.sha ?? (/^[0-9a-f]{40}$/.test(values["jobs-commit"] ?? "") ? values["jobs-commit"] : undefined);
207
310
  let checkRunId = null;
208
311
  let summaryComment = null;
209
312
  /** The edit that names the models, so a result or a failure notice is always written after it. */
210
313
  let naming = Promise.resolve();
314
+ // The jobs' commit is reviewed only while it is still the pull request's newest: a review started again
315
+ // later, after more pushes, reads the newest commit instead, never older code over a newer result.
316
+ if (values.post && values["jobs-commit"] && values.at?.toLowerCase() === values["jobs-commit"].toLowerCase()) {
317
+ // Read from the branch itself, which moves at once: the pull request's head can still name the
318
+ // commit before the jobs' for a few seconds after their push.
319
+ const pr = await fetchPullRequest(ref);
320
+ const branch = pr.headRef
321
+ ? await api.get(`git/ref/heads/${pr.headRef.split("/").map(encodeURIComponent).join("/")}`).catch(() => null)
322
+ : null;
323
+ // Not told: no review, rather than one that may read older code than the newest.
324
+ if (!branch)
325
+ throw new Error(`Couldn't read ${pr.headRef ?? "the branch"} to tell whether the jobs' commit is still the newest. Run the review again.`);
326
+ const newest = branch.object.sha;
327
+ if (newest.toLowerCase() !== values.at.toLowerCase()) {
328
+ log(`The jobs' commit ${values.at.slice(0, 7)} isn't the newest any more, so this review reads ${newest.slice(0, 7)}.`);
329
+ values.at = newest;
330
+ }
331
+ }
211
332
  let headSha = values.at ?? null;
212
333
  if (values.post) {
213
334
  headSha ??= (await fetchPullRequest(ref)).headSha;
214
- checkRunId = await startCheck(api, headSha, provider ?? "codex");
335
+ // A connect earlier in this run left its check going: the review carries it on, so no check stands
336
+ // finished in between, which a branch rule could take for a review that passed.
337
+ const handedOver = process.env.MERGELIGHT_PROVIDER ? Number(process.env.MERGELIGHT_CHECK_RUN) || undefined : undefined;
338
+ // The review's own check, as soon as it exists: the Action's last step finishes it if the review is
339
+ // cancelled first. Only in the Action, so another review later in a workflow never takes it for its
340
+ // own. The connect's check stays on the list too: the last step leaves it alone once it is finished,
341
+ // and finishes it when closing it here failed.
342
+ const record = (id) => {
343
+ if (process.env.MERGELIGHT_PROVIDER && process.env.GITHUB_ENV)
344
+ appendFileSync(process.env.GITHUB_ENV, `MERGELIGHT_CHECK_RUN=${[id, handedOver].filter(Boolean).join(" ")}\n`);
345
+ };
346
+ checkRunId = await startCheck(api, headSha, provider ?? "codex", handedOver, record);
215
347
  // Says which AI reviews from the start. The models' exact names follow once the first reviewer answers.
216
348
  // Without --provider the review runs on Codex, as reviewPullRequest decides.
217
349
  const firstGuess = values.model ?? (provider === "claude" ? "opus" : configuredModel());
218
- summaryComment = await startSummary(api, ref.number, { reviewer: { name: provider ?? "codex", model: firstGuess ?? null } }).catch((e) => {
350
+ summaryComment = await startSummary(api, ref.number, { reviewer: { name: provider ?? "codex", model: firstGuess ?? null } }, process.env.MERGELIGHT_PROMPT || undefined).catch((e) => {
219
351
  log(`Couldn't post the summary yet: ${e.message}`);
220
352
  return null;
221
353
  });
@@ -228,13 +360,22 @@ async function main() {
228
360
  let checksPosted = false;
229
361
  try {
230
362
  // The login step already found this login can't be refreshed, so don't send every reviewer to find out.
231
- if (process.env.MERGELIGHT_LOGIN_LOST === "1")
232
- throw new LoginError(loginFailureMessage(process.env.SECRET_NAME || undefined));
363
+ // Only when Codex is in this review: a Claude review whose Codex checker lost its login is checked by Claude.
364
+ const usesCodex = (provider ?? "codex") === "codex" || verifyWith === "codex";
365
+ if (usesCodex && process.env.MERGELIGHT_LOGIN_LOST === "1") {
366
+ const secret = process.env.SECRET_NAME || undefined;
367
+ // The login step says why when it held the login back on purpose, as for one other repositories share.
368
+ const note = process.env.MERGELIGHT_LOGIN_NOTE;
369
+ throw note ? new HeldLoginError(note) : new LoginError(loginFailureMessage(secret));
370
+ }
233
371
  // Before the threads are read: a reply written after this counts as newer than this review.
234
372
  const startedAt = new Date();
235
- let previous = values.post ? await previousFindings(api, ref.number, headSha ?? undefined) : undefined;
373
+ const earlier = values.post ? await previousReview(api, ref.number, headSha ?? undefined) : undefined;
374
+ let previous = earlier?.findings;
236
375
  const review = await reviewPullRequest(ref, {
237
376
  previous,
377
+ // The round this review becomes: from LATE_ROUND on, the loop breaker lets fewer findings hold the merge.
378
+ ...(earlier ? { round: earlier.round + 1 } : {}),
238
379
  memories: cloud.memories,
239
380
  rules: cloud.rules,
240
381
  rulesUnread: cloud.failed === true,
@@ -242,8 +383,10 @@ async function main() {
242
383
  writtenSkills: cloud.writtenSkills,
243
384
  checks: cloud.checks,
244
385
  onTeamChecks: (results) => (answered = results),
386
+ jobCommit,
245
387
  onModels: (models) => {
246
- naming = updatePendingSummary(api, summaryComment, models).catch((e) => {
388
+ // One after the other: a later name never lands before an earlier one, nor after the result.
389
+ naming = naming.then(() => updatePendingSummary(api, summaryComment, models)).catch((e) => {
247
390
  log(`Couldn't name the models yet: ${e.message}`);
248
391
  });
249
392
  },
@@ -258,6 +401,19 @@ async function main() {
258
401
  onProgress: progress.onProgress,
259
402
  });
260
403
  progress.stop();
404
+ if (verifyMissed && verifyMissed !== review.verifier?.name && !review.checker_missed) {
405
+ review.checker_missed = verifyMissed;
406
+ const why = values["verify-missed-why"];
407
+ if (why === "not-installed" || why === "login-failed")
408
+ review.checker_missed_why = why;
409
+ // Held back on purpose, as a login other repositories share: the login step's own words say why.
410
+ if (why === "held" && process.env.MERGELIGHT_LOGIN_NOTE) {
411
+ review.checker_missed_why = why;
412
+ review.checker_missed_note = process.env.MERGELIGHT_LOGIN_NOTE;
413
+ }
414
+ }
415
+ if (jobs)
416
+ review.jobs = { ...jobs, ...(jobs.commit ? { reviewed: review.pr.head_sha.toLowerCase() === jobs.commit.toLowerCase() } : {}) };
261
417
  const json = JSON.stringify(review, null, 2);
262
418
  if (values.out)
263
419
  writeFileSync(values.out, `${json}\n`);
@@ -310,11 +466,13 @@ async function main() {
310
466
  if (values.post && headSha) {
311
467
  const login = err instanceof LoginError ? err : null;
312
468
  const limit = err instanceof LimitError ? err : null;
313
- const title = limit ? checkLimitTitle(limit.plan) : login ? checkLoginTitle(login.plan) : undefined;
314
- const notice = limit ? limitNotice(limit.plan, limit.resets) : login ? loginNotice(login.plan, message) : undefined;
315
- await failCheck(api, checkRunId, headSha, message, log, title).catch((e) => log(`Couldn't update the check: ${e.message}`));
469
+ // Held back on purpose is no login that failed: its own words say why.
470
+ const held = err instanceof HeldLoginError;
471
+ const title = limit ? checkLimitTitle(limit.plan) : held ? checkHeldTitle : login ? checkLoginTitle(login.plan) : undefined;
472
+ const notice = limit ? limitNotice(limit.plan, limit.resets) : held ? heldLoginNotice(message) : login ? loginNotice(login.plan, message) : undefined;
473
+ await failCheck(api, checkRunId, headSha, message, log, title, jobs).catch((e) => log(`Couldn't update the check: ${e.message}`));
316
474
  await naming;
317
- await failSummary(api, ref.number, notice).catch((e) => log(`Couldn't update the summary: ${e.message}`));
475
+ await failSummary(api, ref.number, notice, jobs).catch((e) => log(`Couldn't update the summary: ${e.message}`));
318
476
  // The newest commit wasn't reviewed. An approval Mergelight gave to an earlier commit must not count for this one.
319
477
  // With approvals turned off, none of Mergelight's approvals stands, this commit's included.
320
478
  await syncApproval(api, ref.number, "yellow", headSha, log, values["no-approve"] ? { why: APPROVALS_OFF } : { why: UNREVIEWED, otherCommitsOnly: true });
package/dist/cloud.js CHANGED
@@ -291,10 +291,11 @@ export async function fetchContext(deps = {}) {
291
291
  return { ...NOTHING, failed: true };
292
292
  }
293
293
  const answer = res.answer;
294
+ // Not on the dashboard: nothing of it, but whether the org's plan includes Jobs still counts.
294
295
  if (answer?.connected !== true)
295
- return NOTHING;
296
+ return { ...NOTHING, answered: true, ...(answer?.jobs === true ? { jobs: true } : {}) };
296
297
  const skills = Array.isArray(answer.skills) ? answer.skills.filter(isSkillPath).slice(0, 10) : [];
297
- return { connected: true, memories: readMemories(answer.memories), rules: readRules(answer.rules), skills, checks: readChecks(answer.checks), writtenSkills: readWrittenSkills(answer.written_skills) };
298
+ return { connected: true, answered: true, memories: readMemories(answer.memories), rules: readRules(answer.rules), skills, checks: readChecks(answer.checks), writtenSkills: readWrittenSkills(answer.written_skills), jobs: answer.jobs === true };
298
299
  }
299
300
  catch (err) {
300
301
  d.log(`Couldn't reach the Mergelight server (${err.message}). The review runs without it.`);
@@ -42,6 +42,11 @@ export function readPastedCode(body) {
42
42
  const text = body.trim();
43
43
  return /^[\w.~-]{10,500}#[\w.~-]{20,500}$/.test(text) ? text : null;
44
44
  }
45
+ /** How `script` runs the sign-in in a terminal of its own: Linux has util-linux's script, and macOS the BSD one, whose options differ. */
46
+ export function scriptArgs(platform = process.platform) {
47
+ const command = "stty cols 3000 rows 50; exec claude setup-token";
48
+ return platform === "darwin" || platform === "freebsd" ? ["-qF", "/dev/null", "sh", "-c", command] : ["-qfc", command, "/dev/null"];
49
+ }
45
50
  /**
46
51
  * Starts the sign-in. It needs a terminal, so `script` gives it one, wide enough that the link and the token
47
52
  * stay on one line. Nothing it prints is logged, because the token is in there. Null if no link appears.
@@ -53,7 +58,7 @@ export function startClaudeSignIn(spawnImpl = spawn, wait = { link: LINK_WAIT_MS
53
58
  let onOutput = () => { };
54
59
  let child;
55
60
  try {
56
- child = spawnImpl("script", ["-qfc", "stty cols 3000 rows 50; exec claude setup-token", "/dev/null"], { stdio: ["pipe", "pipe", "ignore"], env: { ...agentEnv(), TERM: "xterm-256color", BROWSER: "true" } });
61
+ child = spawnImpl("script", scriptArgs(), { stdio: ["pipe", "pipe", "ignore"], env: { ...agentEnv(), TERM: "xterm-256color", BROWSER: "true" } });
57
62
  }
58
63
  catch {
59
64
  resolve(null);
@@ -140,7 +145,14 @@ export async function waitForPastedCode(deps, timeoutMs = WAIT_MS, pollMs = POLL
140
145
  const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
141
146
  const end = now() + timeoutMs;
142
147
  while (now() < end && !deps.stopped?.()) {
143
- const code = readPastedCode((await deps.read().catch(() => null)) ?? "");
148
+ // A read GitHub never answers mustn't hold the wait past its end: the review waits for it.
149
+ let timer;
150
+ const late = new Promise((resolve) => {
151
+ timer = setTimeout(() => resolve(null), Math.max(0, end - now()));
152
+ });
153
+ const text = await Promise.race([deps.read().catch(() => null), late]);
154
+ clearTimeout(timer);
155
+ const code = readPastedCode(text ?? "");
144
156
  if (code)
145
157
  return code;
146
158
  await sleep(pollMs);
@@ -148,10 +160,11 @@ export async function waitForPastedCode(deps, timeoutMs = WAIT_MS, pollMs = POLL
148
160
  return null;
149
161
  }
150
162
  /** Hands the token to the rest of the job: hidden in its logs, and available to the steps that save and use it. */
151
- export function shareClaudeToken(token, env = process.env, print = console.log) {
163
+ export function shareClaudeToken(token, env = process.env, print = console.log, reviews = true) {
152
164
  if (!/^sk-ant-oat[\w-]+$/.test(token))
153
165
  throw new Error("That doesn't look like a Claude token.");
154
166
  print(`::add-mask::${token}`);
167
+ // A login connected to check the review leaves the reviewer as it is.
155
168
  if (env.GITHUB_ENV)
156
- appendFileSync(env.GITHUB_ENV, `MERGELIGHT_CLAUDE_TOKEN=${token}\nMERGELIGHT_PROVIDER=claude\nMERGELIGHT_CONNECT=0\n`);
169
+ appendFileSync(env.GITHUB_ENV, reviews ? `MERGELIGHT_CLAUDE_TOKEN=${token}\nMERGELIGHT_PROVIDER=claude\nMERGELIGHT_CONNECT=0\n` : `MERGELIGHT_CLAUDE_TOKEN=${token}\n`);
157
170
  }