next-issue 16.1.0 → 16.3.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.
package/README.md CHANGED
@@ -40,23 +40,17 @@ Give an issue the `status:todo` label to have it picked up. See [Issue format](h
40
40
 
41
41
  ### Skills for Claude Code
42
42
 
43
- To install the `create-issue` skill, which writes an issue that the harness can claim, and the `answer-hand-over` skill, which helps you answer a hand-over, run:
44
-
45
- ```bash
46
- npx -y next-issue@latest update
47
- ```
48
-
49
- It asks whether to install them for your user or for the project. See [Skills](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#skills).
43
+ `init` (see [Configuration](#configuration)) installs the `create-issue` skill, which writes an issue that the harness can claim, and the `answer-hand-over` skill, which helps you answer a hand-over. It asks whether to install them for your user or for the project; `--scope user|project` answers in advance. Run `init` again after an upgrade of next-issue to get the skills of that version. See [Skills](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#skills).
50
44
 
51
45
  ## Configuration
52
46
 
53
- To write `.next-issue/config.json` with the defaults, run:
47
+ To set up a repository, run:
54
48
 
55
49
  ```bash
56
50
  npx -y next-issue@latest init
57
51
  ```
58
52
 
59
- A field that is not in the file keeps its default. See [Configuration](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#configuration) for the details.
53
+ It writes `.next-issue/config.json` with the defaults, or keeps the file when it is there already, and installs the skills. A field that is not in the file keeps its default. See [Configuration](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#configuration) for the details.
60
54
 
61
55
  | Field | Default | Effect |
62
56
  | ----------------------- | ------------------ | ------------------------------------------------------------------- |
@@ -90,14 +84,14 @@ A field that is not in the file keeps its default. See [Configuration](https://g
90
84
  | `start` | Start a run: claim issues, fix them and push them to the base branch |
91
85
  | `watch on\|off` | Switch watching of the going run |
92
86
  | `hunt on\|off` | Switch hunting of the going run |
93
- | `init` | Write the config file with the defaults |
87
+ | `init` | Write the config file with the defaults and install the skills |
94
88
  | `stop` | Stop the going run after its current issues |
89
+ | `status` | Show the going run, its worker and its running issues |
95
90
  | `logs` | Show the latest run log and follow it |
96
- | `update` | Install the `create-issue` and `answer-hand-over` skills for Claude Code |
97
91
  | `--force` | With `init`: replace an existing config file |
98
92
  | `--watch on\|off` | With `start`: read the open issues again after each pass. On by default |
99
93
  | `--hunt on\|off` | With `start`: hunt the repository for bugs. Off by default. Needs watching |
100
- | `--scope user\|project` | With `update`: install for the user (`~/.claude/skills/`) or the project |
94
+ | `--scope user\|project` | With `init`: install for the user (`~/.claude/skills/`) or the project |
101
95
  | `--help` | Show the option list |
102
96
 
103
97
  See [Commands and options](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#commands-and-options) for the details.
@@ -31,7 +31,7 @@ export async function chooseScope(scope) {
31
31
  return scope;
32
32
  }
33
33
  if (process.stdin.isTTY !== true) {
34
- throw new Error('update needs --scope user|project when there is no terminal to ask where to install the skills');
34
+ throw new Error('init needs --scope user|project when there is no terminal to ask where to install the skills');
35
35
  }
36
36
  return askScope(process.stdin, process.stdout);
37
37
  }
@@ -66,3 +66,23 @@ export function stopInWorker(root) {
66
66
  return 'next-issue: the run will stop after its current issues\n';
67
67
  });
68
68
  }
69
+ export function statusInWorker(root) {
70
+ return inWorker(root, async (connection, progress) => {
71
+ const lines = [
72
+ `next-issue: the run is ${progress.status} in worker ${connection.version}`,
73
+ `watching ${onOffText(progress.watching)}, hunting ${onOffText(progress.hunting)}`,
74
+ ];
75
+ if (progress.upgrade !== undefined) {
76
+ lines.push(`stopping for an upgrade to ${progress.upgrade.to}`);
77
+ }
78
+ if (progress.issues.length === 0) {
79
+ lines.push('no issue is running');
80
+ }
81
+ lines.push(...progress.issues.map(issueLine));
82
+ return `${lines.join('\n')}\n`;
83
+ });
84
+ }
85
+ function issueLine({ issue, step, round }) {
86
+ const roundText = round === undefined ? '' : ` (round ${round})`;
87
+ return `#${issue} ${step?.replaceAll('-', ' ') ?? 'starting'}${roundText}`;
88
+ }
package/dist/cli.mjs CHANGED
@@ -9,8 +9,8 @@ import { followLog, newestRunLog } from './cli/logs.mjs';
9
9
  import { serve } from './worker/serve.mjs';
10
10
  import { startInWorker } from './cli/start.mjs';
11
11
  import { STATE_DIR } from './shared/state.mjs';
12
- import { stopInWorker, switchInWorker } from './cli/switch-run.mjs';
13
- import { chooseScope, installSkills } from './cli/update.mjs';
12
+ import { statusInWorker, stopInWorker, switchInWorker } from './cli/switch-run.mjs';
13
+ import { chooseScope, installSkills } from './cli/skills.mjs';
14
14
  import { WORKTREE_DIR } from './shared/worktree.mjs';
15
15
  function write(stream, text) {
16
16
  return new Promise((resolve, reject) => {
@@ -28,18 +28,19 @@ async function main() {
28
28
  await write(process.stderr, USAGE);
29
29
  return 1;
30
30
  }
31
- if (args.command === 'update') {
32
- return update(args);
33
- }
34
31
  const root = await repoRoot(process.cwd());
35
32
  if (args.command === 'init') {
36
- return init(root, args.force);
33
+ return init(root, args);
37
34
  }
38
35
  await rejectOldConfig(root);
39
36
  if (args.command === 'stop') {
40
37
  await write(process.stdout, await stopInWorker(root));
41
38
  return 0;
42
39
  }
40
+ if (args.command === 'status') {
41
+ await write(process.stdout, await statusInWorker(root));
42
+ return 0;
43
+ }
43
44
  if (args.command === 'watch' || args.command === 'hunt') {
44
45
  await write(process.stdout, await switchInWorker(root, args.command, args.on));
45
46
  return 0;
@@ -63,22 +64,20 @@ async function logs(root) {
63
64
  const tail = process.stdout.isTTY ? Math.max(1, (process.stdout.rows || 24) - 1) : undefined;
64
65
  return followLog(root, file, { tail }, (text) => write(process.stdout, text));
65
66
  }
66
- async function update(args) {
67
+ async function init(root, args) {
67
68
  const scope = await chooseScope(args.scope);
68
- for (const folder of await installSkills(scope)) {
69
- await write(process.stdout, `wrote ${folder}\n`);
70
- }
71
- return 0;
72
- }
73
- async function init(root, force) {
74
- const moved = await moveOldConfig(root, force);
69
+ const moved = await moveOldConfig(root, args.force);
75
70
  if (moved === undefined) {
76
- await write(process.stdout, `wrote ${await writeDefaultConfig(root, force)}\n`);
71
+ const { path, written } = await writeDefaultConfig(root, args.force);
72
+ await write(process.stdout, `${written ? 'wrote' : 'kept'} ${path}\n`);
77
73
  }
78
74
  else {
79
75
  await write(process.stdout, `moved ${OLD_CONFIG_FILE} to ${moved}\n`);
80
76
  }
81
77
  await excludeStateDirectories(root, process.stdout);
78
+ for (const folder of await installSkills(scope)) {
79
+ await write(process.stdout, `wrote ${folder}\n`);
80
+ }
82
81
  return 0;
83
82
  }
84
83
  async function excludeStateDirectories(root, stream) {
@@ -7,7 +7,7 @@ const RUN_FLAGS = new Map([
7
7
  ['--watch', 'watch'],
8
8
  ['--hunt', 'hunt'],
9
9
  ]);
10
- const COMMANDS = ['start', 'init', 'serve', 'stop', 'logs', 'watch', 'hunt', 'update'];
10
+ const COMMANDS = ['start', 'init', 'serve', 'stop', 'status', 'logs', 'watch', 'hunt'];
11
11
  export const USAGE = `next-issue <command> [options]
12
12
 
13
13
  start start a run: claim issues, fix them and push them to the base branch
@@ -15,12 +15,12 @@ export const USAGE = `next-issue <command> [options]
15
15
  --hunt on|off hunt the repository for bugs and file issues alongside the issues, needs watching (default off)
16
16
  watch on|off switch watching of the going run; off also turns hunting off
17
17
  hunt on|off switch hunting of the going run; on also turns watching on
18
- init write ${CONFIG_FILE} with the defaults and add .next-issue/ and .worktrees/ to info/exclude
19
- stop stop the going run after its current issues
20
- logs show the latest run log and follow it
21
- update install the create-issue and answer-hand-over skills for Claude Code
18
+ init set up the repository: write ${CONFIG_FILE}, add .next-issue/ and .worktrees/ to info/exclude and install the skills; run it again after an upgrade
22
19
  --scope user|project
23
20
  user: in ~/.claude/skills; project: in .claude/skills of the main worktree (asks when not given)
21
+ stop stop the going run after its current issues
22
+ status show the going run, its worker and its running issues
23
+ logs show the latest run log and follow it
24
24
 
25
25
  --force replace an existing config file, with init
26
26
  --help show this text
@@ -36,8 +36,8 @@ export function parseArgs(argv) {
36
36
  if (args.command !== undefined && args.command !== 'start' && runFlag !== undefined) {
37
37
  throw new Error(`${args.command} does not take ${runFlag}: it belongs to start`);
38
38
  }
39
- if (args.command !== undefined && args.command !== 'update' && args.scope !== undefined) {
40
- throw new Error(`${args.command} does not take --scope: it belongs to update`);
39
+ if (args.command !== undefined && args.command !== 'init' && args.scope !== undefined) {
40
+ throw new Error(`${args.command} does not take --scope: it belongs to init`);
41
41
  }
42
42
  if ((args.command === 'watch' || args.command === 'hunt') && args.on === undefined) {
43
43
  throw new Error(`${args.command} takes on or off`);
@@ -93,11 +93,11 @@ export async function writeDefaultConfig(root, force) {
93
93
  }
94
94
  catch (error) {
95
95
  if (hasCode(error, 'EEXIST')) {
96
- throw existsAlready();
96
+ return { path, written: false };
97
97
  }
98
98
  throw error;
99
99
  }
100
- return path;
100
+ return { path, written: true };
101
101
  }
102
102
  export async function moveOldConfig(root, force) {
103
103
  const old = join(root, OLD_CONFIG_FILE);
@@ -35,10 +35,9 @@ async function sshHost(url, host) {
35
35
  : host;
36
36
  }
37
37
  export async function repoRoot(cwd) {
38
- const top = await git(cwd, ['rev-parse', '--show-toplevel']);
39
38
  const list = await git(cwd, ['worktree', 'list', '--porcelain']);
40
- const [first = '', second = ''] = list.split('\n');
41
- return first.startsWith('worktree ') && second !== 'bare' ? first.slice('worktree '.length) : top;
39
+ const [first = ''] = list.split('\n');
40
+ return first.slice('worktree '.length);
42
41
  }
43
42
  export async function detectRepo(cwd, remote) {
44
43
  const root = await repoRoot(cwd);
@@ -1,55 +1,3 @@
1
- const OUTCOMES = ['done', 'needs-human', 'error', 'skipped', 'stopped'];
2
- export function formatSummary(summary) {
3
- const tally = OUTCOMES.map((outcome) => `${count(summary.issues, outcome)} ${outcome}`).join(', ');
4
- const roles = Object.entries(summary.roles)
5
- .map(([role, totals]) => `${role} ${tokens(totals.total)} in ${totals.calls}`)
6
- .join(', ');
7
- const lines = [
8
- `run ${summary.runId}`,
9
- `issues ${summary.issues.length}: ${tally}`,
10
- ...summary.issues.map((report) => ` ${issueLine(report)}`),
11
- `tokens ${tokens(summary.total.total)}${roles.length > 0 ? ` (${roles})` : ''}`,
12
- `log ${summary.logFile}`,
13
- ];
14
- return `${lines.join('\n')}\n`;
15
- }
16
1
  export function count(reports, outcome) {
17
2
  return reports.filter((report) => report.outcome === outcome).length;
18
3
  }
19
- function issueLine(report) {
20
- const parts = [`#${report.issue} ${report.outcome.padEnd(11)}`];
21
- if (report.ciFixes > 0) {
22
- parts.push(`ci fixes ${report.ciFixes}`);
23
- }
24
- if (report.reviewRounds > 0) {
25
- parts.push(`reviews ${report.reviewRounds}`);
26
- }
27
- if (report.ms > 0) {
28
- parts.push(duration(report.ms));
29
- }
30
- if (report.reason !== undefined) {
31
- parts.push(`(${report.reason})`);
32
- }
33
- return parts.join(' ').trimEnd();
34
- }
35
- function duration(ms) {
36
- const seconds = Math.round(ms / 1000);
37
- if (seconds < 120) {
38
- return seconds < 60 ? `${seconds}s` : `1m${String(seconds - 60).padStart(2, '0')}s`;
39
- }
40
- const minutes = Math.round(seconds / 60);
41
- if (minutes < 60) {
42
- return `${minutes}m`;
43
- }
44
- const spare = minutes % 60;
45
- return spare === 0 ? `${Math.floor(minutes / 60)}h` : `${Math.floor(minutes / 60)}h${spare}m`;
46
- }
47
- function tokens(value) {
48
- if (value < 1000) {
49
- return String(value);
50
- }
51
- if (value < 1_000_000) {
52
- return `${(value / 1000).toFixed(1)}k`;
53
- }
54
- return `${(value / 1_000_000).toFixed(2)}M`;
55
- }
@@ -7,7 +7,7 @@ import { stopChildren, withRunChildren } from '../shared/children.mjs';
7
7
  import { message } from '../shared/errors.mjs';
8
8
  import { lock } from '../shared/lock.mjs';
9
9
  import { startProgress } from './progress.mjs';
10
- import { isNewer, } from '../shared/protocol.mjs';
10
+ import { isNewer } from '../shared/protocol.mjs';
11
11
  import { runRepo } from './run.mjs';
12
12
  import { packageVersion } from '../shared/version.mjs';
13
13
  import { resumeOnSuccessor } from '../shared/worker-client.mjs';
@@ -18,7 +18,6 @@ import { active, dropUpgrade, endStatus, newRun, requestStop, requestUpgrade, ru
18
18
  import { broadcast, closer, fileId, isLaunch, listen, parseMessage, removeOwned, send, sendAll, sendAllSent, shutdown, stopListening, } from './worker-server.mjs';
19
19
  const LOCK_WAIT_MS = 5_000;
20
20
  const IDLE_MS = 30_000;
21
- const REJOIN_GRACE_MS = 5_000;
22
21
  export async function startWorker(options) {
23
22
  checkSocketPath(options.socketPath);
24
23
  await mkdir(dirname(options.lockPath), { recursive: true });
@@ -38,23 +37,6 @@ export async function startWorker(options) {
38
37
  const server = createServer();
39
38
  const sockets = new WebSocketServer({ server });
40
39
  const busy = () => [...runs.values()].some(active);
41
- let followed = false;
42
- let lateEnd;
43
- const awaitRejoin = (end) => {
44
- if (followed) {
45
- return Promise.resolve();
46
- }
47
- return new Promise((resolve) => {
48
- const timer = setTimeout(resolve, REJOIN_GRACE_MS);
49
- lateEnd = {
50
- end,
51
- sent: () => {
52
- clearTimeout(timer);
53
- resolve();
54
- },
55
- };
56
- });
57
- };
58
40
  let idleTimer;
59
41
  const idleMs = options.idleMs ?? IDLE_MS;
60
42
  const handOver = async (how, run) => {
@@ -82,7 +64,7 @@ export async function startWorker(options) {
82
64
  }
83
65
  });
84
66
  const closeWhenIdle = () => {
85
- if ((restart !== undefined || sockets.clients.size === 0) && !busy() && lateEnd === undefined) {
67
+ if ((restart !== undefined || sockets.clients.size === 0) && !busy()) {
86
68
  void close();
87
69
  }
88
70
  };
@@ -111,9 +93,7 @@ export async function startWorker(options) {
111
93
  upgradeBetweenIssues(run, true);
112
94
  };
113
95
  const start = (refuse, root, argv, resume) => {
114
- const refusal = lateEnd === undefined
115
- ? startRefusal(runs.get(root), restart !== undefined)
116
- : 'the worker is closing, try again soon';
96
+ const refusal = startRefusal(runs.get(root), restart !== undefined);
117
97
  if (refusal !== undefined) {
118
98
  if (!resume) {
119
99
  refuse(refusal);
@@ -136,12 +116,6 @@ export async function startWorker(options) {
136
116
  };
137
117
  broadcast(sockets, runs);
138
118
  let summary;
139
- const ended = async (end) => {
140
- await sendAllSent(sockets, end);
141
- if (resume) {
142
- await awaitRejoin(end);
143
- }
144
- };
145
119
  withRunChildren(run.children, () => options.runRepo(root, args, {
146
120
  ...runControls(run, update),
147
121
  beforeClaim: () => upgradeToLatest(run),
@@ -158,7 +132,7 @@ export async function startWorker(options) {
158
132
  }))
159
133
  .then((code) => {
160
134
  update({ ...run.progress, status: endStatus(run) });
161
- return ended({
135
+ return sendAllSent(sockets, {
162
136
  type: 'end',
163
137
  root,
164
138
  code,
@@ -167,7 +141,7 @@ export async function startWorker(options) {
167
141
  }, (error) => {
168
142
  process.stderr.write(`next-issue failed: ${message(error)}\n`);
169
143
  update({ ...run.progress, status: 'failed', error: message(error) });
170
- return ended({ type: 'end', root, code: 1, error: message(error) });
144
+ return sendAllSent(sockets, { type: 'end', root, code: 1, error: message(error) });
171
145
  })
172
146
  .finally(() => void close());
173
147
  };
@@ -230,13 +204,6 @@ export async function startWorker(options) {
230
204
  else if (value.type === 'watch') {
231
205
  toggle(refuse, value.root, value.on, setWatching);
232
206
  }
233
- else if (value.type === 'rejoin') {
234
- followed = true;
235
- if (lateEnd !== undefined) {
236
- const { end, sent } = lateEnd;
237
- socket.send(JSON.stringify(end), () => sent());
238
- }
239
- }
240
207
  };
241
208
  sockets.on('connection', (socket) => {
242
209
  send(socket, { type: 'hello', version: options.version });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "16.1.0",
3
+ "version": "16.3.0",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",