next-issue 14.4.21 → 14.4.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.
@@ -28,8 +28,9 @@ export async function baseMoved(cwd, base, remote) {
28
28
  }
29
29
  export async function revertOnBase(cwd, revert) {
30
30
  try {
31
- if (await pushRevert(cwd, revert)) {
32
- return true;
31
+ const reverted = await pushRevert(cwd, revert);
32
+ if (reverted !== 'failed') {
33
+ return reverted;
33
34
  }
34
35
  }
35
36
  catch (error) {
@@ -37,11 +38,12 @@ export async function revertOnBase(cwd, revert) {
37
38
  throw error;
38
39
  }
39
40
  await putBranchBack(cwd, revert.branch);
40
- return false;
41
+ return 'failed';
41
42
  }
42
43
  function putBranchBack(cwd, branch) {
43
44
  return evenWhenStopped(async () => {
44
45
  await succeeds(cwd, ['revert', '--abort']);
46
+ await succeeds(cwd, ['cherry-pick', '--abort']);
45
47
  await git(cwd, ['checkout', '--force', branch]);
46
48
  });
47
49
  }
@@ -67,7 +69,14 @@ async function pushRevert(cwd, revert) {
67
69
  await git(cwd, ['checkout', '--force', '--detach', target]);
68
70
  await git(cwd, ['clean', '-fd']);
69
71
  if (!(await succeeds(cwd, ['revert', '--no-commit', ...shas.toReversed()]))) {
70
- return false;
72
+ return 'failed';
73
+ }
74
+ if (await succeeds(cwd, ['diff', '--cached', '--quiet', 'HEAD'])) {
75
+ await git(cwd, ['revert', '--abort']);
76
+ await git(cwd, ['cherry-pick', '--no-commit', ...shas]);
77
+ await git(cwd, ['commit', '--no-verify', '-m', reapply]);
78
+ await git(cwd, ['checkout', '-B', branch]);
79
+ return 'already reverted';
71
80
  }
72
81
  await git(cwd, ['commit', '--no-verify', '-m', message]);
73
82
  const reverted = await revision(cwd);
@@ -75,8 +84,8 @@ async function pushRevert(cwd, revert) {
75
84
  if ((await pushToBase(cwd, remote, base)).pushed ||
76
85
  (await isOnBase(cwd, base, remote, reverted))) {
77
86
  await commitReapply(cwd, reverted, reapply, branch);
78
- return true;
87
+ return 'pushed';
79
88
  }
80
89
  }
81
- return false;
90
+ return 'failed';
82
91
  }
@@ -125,7 +125,7 @@ async function claimIssues(loop, seen, tried, pool) {
125
125
  }
126
126
  seen.add(issue.number);
127
127
  const slot = pool.slots.claim();
128
- pool.running.set(issue.number, loop.process(issue, undefined, slot).then((report) => ({ issue: issue.number, slot, report }), (failure) => ({ issue: issue.number, slot, failure })));
128
+ pool.running.set(issue.number, loop.process(issue, slot).then((report) => ({ issue: issue.number, slot, report }), (failure) => ({ issue: issue.number, slot, failure })));
129
129
  }
130
130
  return { claiming: true, unclaimed: false };
131
131
  }
@@ -61,7 +61,7 @@ export async function revert(job) {
61
61
  const { context, issue, log, state, branch, worktree } = job;
62
62
  const { repo, config, ports, base } = context;
63
63
  const shas = state.landed ?? [];
64
- const pushed = await log.step('revert', { base, shas }, () => ports.revertOnBase(worktree, {
64
+ const reverted = await log.step('revert', { base, shas }, () => ports.revertOnBase(worktree, {
65
65
  base,
66
66
  remote: config.remote,
67
67
  branch,
@@ -74,13 +74,16 @@ export async function revert(job) {
74
74
  },
75
75
  }));
76
76
  state.reverting = undefined;
77
- if (!pushed) {
77
+ if (reverted === 'failed') {
78
78
  await writeState(repo, state);
79
79
  return ` The revert of the change on ${base} failed, so the landed commits stay on ${base}.`;
80
80
  }
81
81
  restoreChange(state);
82
82
  releaseSettled(state);
83
83
  await writeState(repo, state);
84
+ if (reverted === 'already reverted') {
85
+ return ` The change is already reverted on ${base}, so the harness pushed no revert.`;
86
+ }
84
87
  await updateLocalBase(job);
85
88
  return ` The harness reverted the change on ${base}.`;
86
89
  }
@@ -5,17 +5,16 @@ export async function watchIssues(watch) {
5
5
  const running = new Set();
6
6
  const failed = new Set();
7
7
  const ended = new AbortController();
8
- const claims = claimAlarm();
9
8
  const hunting = watch.hunter === undefined
10
9
  ? undefined
11
- : huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, claims, watch.issues, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
10
+ : huntIssues(watch.hunter, watch.hunting ?? onOff(true), running, failed, watch.issues, watch.refreshed, () => ended.signal.aborted || watch.stop(), ended.signal);
12
11
  try {
13
12
  return await watchPasses(failed, {
14
13
  ...watch,
15
- process: async (issue, _claimed, slot) => {
14
+ process: async (issue, slot) => {
16
15
  running.add(issue.number);
17
16
  try {
18
- const report = await watch.process(issue, claims.ring, slot);
17
+ const report = await watch.process(issue, slot);
19
18
  recordFailures(failed, [report]);
20
19
  return report;
21
20
  }
@@ -30,25 +29,6 @@ export async function watchIssues(watch) {
30
29
  await hunting;
31
30
  }
32
31
  }
33
- function claimAlarm() {
34
- let rung = false;
35
- let controller = new AbortController();
36
- return {
37
- ring: () => {
38
- rung = true;
39
- controller.abort();
40
- },
41
- take: () => {
42
- const was = rung;
43
- rung = false;
44
- return was;
45
- },
46
- signal: () => {
47
- controller = new AbortController();
48
- return controller.signal;
49
- },
50
- };
51
- }
52
32
  function aborted(signal) {
53
33
  return new Promise((resolve) => {
54
34
  if (signal.aborted) {
@@ -59,7 +39,7 @@ function aborted(signal) {
59
39
  }
60
40
  });
61
41
  }
62
- async function huntIssues(hunter, hunting, running, failed, claims, issues, refreshes, stopped, signal) {
42
+ async function huntIssues(hunter, hunting, running, failed, issues, refreshes, stopped, signal) {
63
43
  let step = 0;
64
44
  while (!stopped()) {
65
45
  if (!hunting.on()) {
@@ -71,7 +51,6 @@ async function huntIssues(hunter, hunting, running, failed, claims, issues, refr
71
51
  if (stopped()) {
72
52
  return;
73
53
  }
74
- claims.take();
75
54
  const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
76
55
  if (waiting !== undefined && waiting < hunter.cap && hunting.on()) {
77
56
  if (await hunter.hunt(hunter.cap - waiting)) {
@@ -79,16 +58,16 @@ async function huntIssues(hunter, hunting, running, failed, claims, issues, refr
79
58
  await issues().catch(() => undefined);
80
59
  }
81
60
  }
82
- if (claims.take() || stopped() || !hunting.on()) {
61
+ if (stopped() || !hunting.on()) {
83
62
  continue;
84
63
  }
85
64
  const changed = hunting.changed();
86
65
  const refreshed = refreshes?.() ?? new AbortController().signal;
87
- await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, claims.signal(), changed, refreshed]));
66
+ await hunter.wait(backOffMinutes(step), AbortSignal.any([signal, changed, refreshed]));
88
67
  if (changed.aborted || refreshed.aborted) {
89
68
  step = 0;
90
69
  }
91
- else if (!claims.take()) {
70
+ else {
92
71
  step += 1;
93
72
  }
94
73
  }
@@ -11,7 +11,7 @@ import { hasLabel } from '../shared/labels.mjs';
11
11
  import { newState, readState, resetState, } from '../shared/state.mjs';
12
12
  import { beforeBaseSettled } from '../shared/unsettled.mjs';
13
13
  import { setUp } from './worktree-setup.mjs';
14
- export async function processIssue(context, issue, claimed = () => undefined, slot) {
14
+ export async function processIssue(context, issue, slot) {
15
15
  const { repo } = context;
16
16
  const started = Date.now();
17
17
  const log = context.recorder.scope({ issue: issue.number });
@@ -35,7 +35,6 @@ export async function processIssue(context, issue, claimed = () => undefined, sl
35
35
  if (skip !== undefined) {
36
36
  return skip;
37
37
  }
38
- claimed();
39
38
  log.event('issue.start', { title: issue.title, createdAt: issue.createdAt });
40
39
  const state = startState(issue, saved, handedOver);
41
40
  let report;
@@ -47,7 +47,7 @@ async function handle(args, config, repo, recorder, controls) {
47
47
  const context = await startRun(args, config, repo, recorder, interrupts);
48
48
  const loop = {
49
49
  issues: () => pendingIssues(context),
50
- process: (issue, claimed, slot) => processIssue(context, issue, claimed, slot),
50
+ process: (issue, slot) => processIssue(context, issue, slot),
51
51
  stop: interrupts.afterIssue,
52
52
  concurrency: config.concurrency,
53
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "14.4.21",
3
+ "version": "14.4.23",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",