next-issue 16.5.2 → 16.6.0

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.
@@ -19,7 +19,7 @@ export async function startInWorker(root, argv) {
19
19
  if (going(progress)) {
20
20
  const join = await joined(connection, root, argv, progress);
21
21
  if (join.joined) {
22
- return statusText(connection.version, join.progress);
22
+ return `a run is going already\n${statusText(connection.version, join.progress)}`;
23
23
  }
24
24
  if (!isNewer(version, connection.version) || !REFUSED_GOING.includes(join.refusal)) {
25
25
  throw new Error(join.refusal);
@@ -31,7 +31,7 @@ export async function startInWorker(root, argv) {
31
31
  if (given.hunt !== undefined) {
32
32
  latest = await switched(connection, root, 'hunt', given.hunt);
33
33
  }
34
- return statusText(connection.version, latest);
34
+ return `a run is going already\n${statusText(connection.version, latest)}`;
35
35
  }
36
36
  const id = randomUUID();
37
37
  const accepted = startedRun(connection, root, id);
@@ -103,18 +103,32 @@ export function statusInWorker(root) {
103
103
  }
104
104
  export function statusText(version, progress) {
105
105
  const lines = [
106
- `the run is ${progress.status} in worker ${version}`,
106
+ `${progress.status} in worker ${version}`,
107
107
  `watching ${onOffText(progress.watching)}, hunting ${onOffText(progress.hunting)}`,
108
108
  ];
109
109
  if (progress.upgrade !== undefined) {
110
110
  lines.push(`stopping for an upgrade to ${progress.upgrade.to}`);
111
111
  }
112
112
  if (progress.issues.length === 0) {
113
- lines.push('no issue is running');
113
+ lines.push(idleLine(progress));
114
114
  }
115
115
  lines.push(...progress.issues.map(issueLine));
116
116
  return `${lines.join('\n')}\n`;
117
117
  }
118
+ function idleLine(progress) {
119
+ if (progress.status !== 'running') {
120
+ return 'no issue is running';
121
+ }
122
+ const minutes = progress.nextLook === undefined
123
+ ? 0
124
+ : Math.ceil((Date.parse(progress.nextLook) - Date.now()) / 60_000);
125
+ if (minutes > 0) {
126
+ return `looking again in ${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`;
127
+ }
128
+ return progress.looking === true || progress.nextLook !== undefined
129
+ ? 'looking for an issue'
130
+ : 'no issue is running';
131
+ }
118
132
  function issueLine({ issue, step, round }) {
119
133
  const roundText = round === undefined ? '' : ` (round ${round})`;
120
134
  return `#${issue} ${step?.replaceAll('-', ' ') ?? 'starting'}${roundText}`;
@@ -1,3 +1,4 @@
1
+ import { minutesToMs } from '../shared/durations.mjs';
1
2
  const STEPS = {
2
3
  'implement.start': 'implementing',
3
4
  'review.start': 'reviewing',
@@ -7,13 +8,22 @@ const STEPS = {
7
8
  'ci-checks.start': 'waiting-for-checks',
8
9
  };
9
10
  export function startProgress(hunting = false) {
10
- return { status: 'running', hunting, issues: [] };
11
+ return { status: 'running', hunting, issues: [], looking: true };
11
12
  }
12
13
  export function applyEvent(progress, record) {
13
14
  const kind = record['kind'];
14
15
  if (kind === 'issues.fail') {
15
16
  return { ...progress, error: String(record['error']) };
16
17
  }
18
+ if (kind === 'watch.wait' && typeof record['minutes'] === 'number') {
19
+ const ts = typeof record['ts'] === 'string' ? Date.parse(record['ts']) : Date.now();
20
+ const nextLook = new Date(ts + minutesToMs(record['minutes'])).toISOString();
21
+ return { ...progress, looking: false, nextLook };
22
+ }
23
+ if (kind === 'watch.wake') {
24
+ const { nextLook: _nextLook, ...rest } = progress;
25
+ return { ...rest, looking: true };
26
+ }
17
27
  const issue = record['issue'];
18
28
  if (typeof kind !== 'string' || typeof issue !== 'number') {
19
29
  return progress;
@@ -75,10 +75,12 @@ export function watchRun(args, loop, context, controls, print) {
75
75
  controls.onHunter?.(() => hunt.busy());
76
76
  return watchIssues({
77
77
  ...loop,
78
- wait: (minutes, woken) => {
78
+ wait: async (minutes, woken) => {
79
79
  recorder.event('watch.wait', { minutes });
80
80
  passStart = recorder.summary();
81
- return interrupts.sleep(minutesToMs(minutes), woken);
81
+ const slept = await interrupts.sleep(minutesToMs(minutes), woken);
82
+ recorder.record('watch.wake');
83
+ return slept;
82
84
  },
83
85
  passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
84
86
  hunter: hunt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "16.5.2",
3
+ "version": "16.6.0",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",