next-issue 6.6.48 → 6.6.50

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/README.md CHANGED
@@ -105,7 +105,9 @@ the run handles one issue. For each issue:
105
105
  summary and one entry per finding, each rated `blocking` or `minor`. A
106
106
  reply without a valid block hands the issue to a person. The findings are the only ground
107
107
  truth. The reviewer gives no approve or reject field, because such a field
108
- can contradict the findings. The harness puts the result on the issue.
108
+ can contradict the findings. The harness puts the result on the issue. A
109
+ result longer than a GitHub comment (65536 characters) is cut to fit, with a
110
+ last line that says so.
109
111
  6. An open finding is any finding, blocking or minor, while a review round is
110
112
  left. In the last round, only a blocking finding stays open: a minor finding
111
113
  there goes on the issue but starts no fix, because a fix in the last
@@ -254,6 +256,8 @@ Each agent that writes to the issue names itself in the first line of the
254
256
  comment: `### Review: approved`, `### Review: changes requested`,
255
257
  `### Fixer: no change` and `### Fixer: settled with no change`. The account is
256
258
  the same for all of them, so the heading, not the author, tells them apart.
259
+ A comment longer than 65536 characters is cut to fit, with a last line that
260
+ says so.
257
261
  The agents get no comment that starts with one of these headings or with
258
262
  `next-issue needs help:`, so a comment of an agent never returns to a
259
263
  prompt: the dispute of the fixer reaches the reviewer through the state file.
@@ -1,3 +1,4 @@
1
+ import { refuseWhenStopped } from './children.mjs';
1
2
  import { minutesToMs, secondsToMs } from './durations.mjs';
2
3
  import { asError } from './errors.mjs';
3
4
  import { pause, REAL_CLOCK } from './poll.mjs';
@@ -20,6 +21,7 @@ export async function pollChecks(probe, options, clock = REAL_CLOCK) {
20
21
  let shown;
21
22
  let failures = 0;
22
23
  for (;;) {
24
+ refuseWhenStopped();
23
25
  if (rest() === 0) {
24
26
  return 'timeout';
25
27
  }
package/dist/handover.mjs CHANGED
@@ -7,6 +7,7 @@ import { oneAtATime } from './lock.mjs';
7
7
  import { revertFailedFix } from './revert.mjs';
8
8
  import { logIssueError } from './skip.mjs';
9
9
  import { dropState, writeState } from './state.mjs';
10
+ import { fitComment } from './text.mjs';
10
11
  export async function escalateAndFinish(job, note, reason) {
11
12
  const reverted = await revertFailedFix(job);
12
13
  try {
@@ -105,16 +106,9 @@ async function handOver(context, log, issue, state, reason) {
105
106
  await setStatus(context, issue, config.labels.needsHuman);
106
107
  await ports.commentOnIssue(repo, issue, handOverComment(reason));
107
108
  }
108
- const COMMENT_LIMIT = 65536;
109
109
  const CUT = '\n\nThe reason was too long for a GitHub comment and was cut.';
110
110
  function handOverComment(reason) {
111
- const comment = `${HAND_OVER} ${reason}`;
112
- if (comment.length <= COMMENT_LIMIT) {
113
- return comment;
114
- }
115
- const end = COMMENT_LIMIT - CUT.length;
116
- const splitsPair = /[\uD800-\uDBFF]/.test(comment.charAt(end - 1));
117
- return `${comment.slice(0, splitsPair ? end - 1 : end)}${CUT}`;
111
+ return fitComment(`${HAND_OVER} ${reason}`, CUT);
118
112
  }
119
113
  export async function claimedError(context, log, issue, state, error, started) {
120
114
  const { reason } = logIssueError(log, error, started);
package/dist/poll.mjs CHANGED
@@ -1,9 +1,25 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
+ import { onStop, runStopped } from './children.mjs';
2
3
  import { secondsToMs, timerMs } from './durations.mjs';
3
4
  export const REAL_CLOCK = {
4
5
  now: () => Date.now(),
5
- sleep: (ms) => delay(ms),
6
+ sleep: (ms) => sleepUntilStopped(ms),
6
7
  };
8
+ async function sleepUntilStopped(ms) {
9
+ if (runStopped()) {
10
+ return;
11
+ }
12
+ const controller = new AbortController();
13
+ const forget = onStop(() => controller.abort());
14
+ try {
15
+ await delay(ms, undefined, { signal: controller.signal });
16
+ }
17
+ catch {
18
+ }
19
+ finally {
20
+ forget();
21
+ }
22
+ }
7
23
  export function pause(clock, options, rest) {
8
24
  return clock.sleep(timerMs(Math.min(secondsToMs(options.intervalSeconds), rest)));
9
25
  }
package/dist/review.mjs CHANGED
@@ -6,7 +6,9 @@ import { ROUND_CONTINUE, runRole, setStatus } from './job.mjs';
6
6
  import { landApproved } from './land.mjs';
7
7
  import { capDiff, history, reviewPrompt } from './prompts.mjs';
8
8
  import { writeState } from './state.mjs';
9
+ import { fitComment } from './text.mjs';
9
10
  import { blockingFindings, formatFindings, formatVerdict, openFindings, parseVerdict, } from './verdict.mjs';
11
+ const CUT = '\n\nThis comment was too long for GitHub and was cut.';
10
12
  export async function reviewRound(job) {
11
13
  const { context, issue, state } = job;
12
14
  const { repo, config, ports } = context;
@@ -23,7 +25,7 @@ export async function reviewRound(job) {
23
25
  const { round, limit } = budgetUse(job, 'reviewRounds');
24
26
  const open = openFindings(verdict, round >= limit);
25
27
  recordVerdict(job, verdict, open);
26
- await ports.commentOnIssue(repo, issue.number, formatVerdict(verdict, open));
28
+ await ports.commentOnIssue(repo, issue.number, fitComment(formatVerdict(verdict, open), CUT));
27
29
  if (open.length === 0) {
28
30
  return landApproved(job);
29
31
  }
@@ -89,6 +91,6 @@ async function unfixedRound(job, fix) {
89
91
  }
90
92
  await writeState(repo, state);
91
93
  const heading = fix.unrelated === undefined ? 'settled with no change' : 'no change';
92
- await ports.commentOnIssue(repo, issue.number, `### Fixer: ${heading}\n\n${note}`);
94
+ await ports.commentOnIssue(repo, issue.number, fitComment(`### Fixer: ${heading}\n\n${note}`, CUT));
93
95
  return ROUND_CONTINUE;
94
96
  }
package/dist/text.mjs CHANGED
@@ -13,3 +13,12 @@ export function truncate(text, max, ellipsis) {
13
13
  export function keepTail(text, limit) {
14
14
  return limit !== undefined && text.length > limit ? text.slice(-limit) : text;
15
15
  }
16
+ const COMMENT_LIMIT = 65536;
17
+ export function fitComment(comment, cut) {
18
+ if (comment.length <= COMMENT_LIMIT) {
19
+ return comment;
20
+ }
21
+ const end = COMMENT_LIMIT - cut.length;
22
+ const splitsPair = /[\uD800-\uDBFF]/.test(comment.charAt(end - 1));
23
+ return `${comment.slice(0, splitsPair ? end - 1 : end)}${cut}`;
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.48",
3
+ "version": "6.6.50",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",