next-issue 6.6.93 → 6.6.95

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/conflict.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { parseCommitSubject } from './agent-reply.mjs';
2
- import { spendBudget } from './budget.mjs';
2
+ import { refundBudget, spendBudget } from './budget.mjs';
3
+ import { runStopped } from './children.mjs';
3
4
  import { commitWork, runFixer } from './fix.mjs';
4
5
  import { escalateAndFinish } from './handover.mjs';
5
6
  import { fallbackTitle } from './job.mjs';
@@ -70,6 +71,9 @@ async function resolve(job, merge) {
70
71
  return await commitWork(job, before, subject, 'fixer', (cwd, message) => ports.commitMerge(cwd, merge, message));
71
72
  }
72
73
  catch (error) {
74
+ if (files.length > 0 && runStopped()) {
75
+ await refundBudget(job, 'ciFixes');
76
+ }
73
77
  await ports.abortMerge(worktree, before);
74
78
  throw error;
75
79
  }
package/dist/handover.mjs CHANGED
@@ -139,28 +139,33 @@ async function cleanUp(context, log, branch) {
139
139
  log.event('worktree.error', { error: message(error) }, 'quiet');
140
140
  }
141
141
  }
142
- async function handOver(context, log, issue, state, reason) {
142
+ async function handOver(context, log, issue, state, reason, earlier) {
143
143
  const { repo, ports, config } = context;
144
144
  log.event('hand-over', { reason }, 'quiet');
145
145
  const { pendingHandOver: _pending, ...rest } = state;
146
+ let pending = earlier;
146
147
  try {
147
- const since = await threadEnd(context, issue);
148
- const pending = { reason, ...(since === undefined ? {} : { since }) };
148
+ // A retry keeps the thread time and the labelled mark of its earlier try.
149
+ const since = earlier?.since ?? (await threadEnd(context, issue));
150
+ pending = { ...earlier, reason, ...(since === undefined ? {} : { since }) };
149
151
  await writeState(repo, { ...rest, pendingHandOver: pending });
150
152
  await setStatus(context, issue, config.labels.needsHuman);
151
- await writeState(repo, { ...rest, pendingHandOver: { ...pending, labelled: true } });
153
+ pending = { ...pending, labelled: true };
154
+ await writeState(repo, { ...rest, pendingHandOver: pending });
152
155
  await ports.commentOnIssue(repo, issue, handOverComment(reason));
153
156
  }
154
157
  catch (error) {
155
- throw new HandOverFailed(reason, error);
158
+ throw new HandOverFailed(reason, error, pending);
156
159
  }
157
160
  await writeState(repo, { ...rest, handedOver: true });
158
161
  }
159
162
  class HandOverFailed extends Error {
160
163
  reason;
161
- constructor(reason, cause) {
164
+ pending;
165
+ constructor(reason, cause, pending) {
162
166
  super(message(cause), { cause });
163
167
  this.reason = reason;
168
+ this.pending = pending;
164
169
  }
165
170
  }
166
171
  function handOverReason(error, reason) {
@@ -173,7 +178,8 @@ function handOverComment(reason) {
173
178
  export async function claimedError(context, log, issue, state, error, started) {
174
179
  const { reason } = logIssueError(log, error, started);
175
180
  try {
176
- await handOver(context, log, issue.number, state, handOverReason(error, reason));
181
+ const earlier = error instanceof HandOverFailed ? error.pending : undefined;
182
+ await handOver(context, log, issue.number, state, handOverReason(error, reason), earlier);
177
183
  }
178
184
  catch (failure) {
179
185
  log.event('hand-over.error', { error: message(failure) }, 'quiet');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.93",
3
+ "version": "6.6.95",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",