next-issue 6.9.0 → 7.0.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
@@ -4,7 +4,7 @@ A small harness that works through the open issues of a GitHub repository with
4
4
  the [pi](https://github.com/earendil-works/pi) SDK. Run it inside a git repository.
5
5
 
6
6
  ```bash
7
- npx -y next-issue@latest
7
+ npx -y next-issue@latest start
8
8
  ```
9
9
 
10
10
  ## Overview
@@ -144,7 +144,7 @@ the run handles one issue. For each issue:
144
144
  conflict marker or the merge unresolved, aborts the merge, or fails, the
145
145
  harness undoes the merge and hands the issue to a person with the reason
146
146
  `merge conflict`. When `checks` lists commands, the harness then runs
147
- each one in the worktree, in order, with `bash -lc` and stderr merged
147
+ each one in the worktree, in order, with `bash -c` and stderr merged
148
148
  into stdout, each for at most `checksTimeoutMinutes`. Their output goes
149
149
  to the run log (`check.output`, and `check.fail` for a failure). A
150
150
  command that fails or does not finish stops the landing before the push:
@@ -393,7 +393,7 @@ The one exception is the answer to a hand-over, see
393
393
 
394
394
  ## Stop a run
395
395
 
396
- Press `Ctrl-C` to stop the run step by step:
396
+ Press `Ctrl-C` to stop a `next-issue start` run step by step:
397
397
 
398
398
  1. The first press stops new claims. The harness finishes every issue that it
399
399
  holds and then writes the summary as usual.
@@ -735,31 +735,41 @@ an issue for the next run to clean up.
735
735
 
736
736
  ## Commands and options
737
737
 
738
- | Argument | Effect |
739
- | ----------- | -------------------------------------------------------------------------------------- |
740
- | `init` | Write the config file with the defaults |
741
- | `serve` | Run the worker of this repository that pi extensions talk to, see [Worker](#worker) |
742
- | `stop` | Stop the worker of this repository, see [Worker](#worker) |
743
- | `logs` | Show the latest run log and follow it, see [Observability](#observability) |
744
- | `--force` | Replace an existing config file, with `init` |
745
- | `--once` | Stop after the first handled issue |
746
- | `--max <n>` | Handle at most n issues |
747
- | `--watch` | Keep running, and read the open issues again after each pass |
748
- | `--hunt` | Hunt the repository for bugs alongside the issues, see [Hunt for bugs](#hunt-for-bugs) |
749
- | `--reset` | Drop the saved budgets and findings, and keep the rest of the state |
750
- | `--json` | Print the machine summary instead of the text one, or the raw JSON lines with `logs` |
751
- | `--verbose` | Show every command and all agent output |
752
- | `--quiet` | Show only the milestones and the summary |
753
- | `--help` | Show the option list |
754
-
755
- The exit code is 1 when an issue needs a person or failed, and 0 when it does
756
- not, so a cron job or a CI step can read the result of the run.
738
+ | Argument | Effect |
739
+ | ----------- | ---------------------------------------------------------------------------------------------------- |
740
+ | `start` | Start a run: claim issues, fix them and push them to the base branch |
741
+ | `init` | Write the config file with the defaults |
742
+ | `serve` | Run the worker of this repository that pi extensions talk to, see [Worker](#worker) |
743
+ | `stop` | Stop the worker of this repository, see [Worker](#worker) |
744
+ | `logs` | Show the latest run log and follow it, see [Observability](#observability) |
745
+ | `--force` | Replace an existing config file, with `init` |
746
+ | `--once` | Stop after the first handled issue, with `start` |
747
+ | `--max <n>` | Handle at most n issues, with `start` |
748
+ | `--watch` | Keep running, and read the open issues again after each pass, with `start` |
749
+ | `--hunt` | Hunt the repository for bugs alongside the issues, with `start`, see [Hunt for bugs](#hunt-for-bugs) |
750
+ | `--reset` | Drop the saved budgets and findings, and keep the rest of the state, with `start` |
751
+ | `--json` | Print the machine summary instead of the text one, or the raw JSON lines with `logs` |
752
+ | `--verbose` | Show every command and all agent output |
753
+ | `--quiet` | Show only the milestones and the summary |
754
+ | `--help` | Show the option list |
755
+
756
+ `--once`, `--max <n>`, `--watch`, `--hunt` and `--reset` belong to `start`, and
757
+ any other command refuses them. `next-issue` with no command prints the option
758
+ list on standard error, starts nothing and exits with 1.
759
+
760
+ The exit code of `next-issue start` is 1 when an issue needs a person or
761
+ failed, and 0 when it does not, so a cron job or a CI step can read the result
762
+ of the run.
763
+
764
+ Versions before 7.0.0 started a run with no command, as `next-issue` or
765
+ `next-issue --once`. From 7.0.0 a run needs `next-issue start`, and the old
766
+ form starts nothing and exits with 1.
757
767
 
758
768
  ## Watch for new issues
759
769
 
760
- A run without `--watch` ends when no unseen issue is left. With `--watch`, the
761
- harness then waits, reads the open issues again and runs another pass, so it
762
- picks up an issue that someone opens during the run, or one whose blocker
770
+ A run without `--watch` ends when no unseen issue is left. With
771
+ `next-issue start --watch`, the harness then waits, reads the open issues again
772
+ and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker
763
773
  closes. Each pass tries every open issue again, also one that an earlier pass
764
774
  skipped. An issue that failed in an earlier pass is not tried again until the
765
775
  next run.
@@ -785,7 +795,7 @@ The watch stops:
785
795
 
786
796
  ## Hunt for bugs
787
797
 
788
- With `--hunt`, which turns on `--watch`, the harness runs a hunter agent at the same time as the issues. Before each hunt it reads the open issues with the `labels.ready` label and counts those that are ready to claim and are not running. An issue that failed earlier in the run does not count, since the watch does not try it again. It counts a blocked issue only when each of its open blockers is in the same repository and is running or ready to claim, since those blockers can land and close; a blocker that cannot move, such as one with `labels.needsHuman`, `labels.skip` or `labels.done`, one without `labels.ready`, or one in another repository, leaves it out. It looks only at the direct blockers, and reads them one issue at a time, so it runs one `gh` call at a time. It hunts only while that count is less than `huntCap`, 1 by default. Otherwise it waits and checks again, with the same back-off as the watch: 1, 2, 3, 5, 10, then 10 minutes, back to 1 minute after a hunt that files an issue. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing backs off like a failed one. When the harness claims an issue, the hunter wakes: it ends its wait at once, or skips the wait after a hunt that is going, and checks the count again. A wake keeps the back-off where it was. The hunter:
798
+ With `next-issue start --hunt`, which turns on `--watch`, the harness runs a hunter agent at the same time as the issues. Before each hunt it reads the open issues with the `labels.ready` label and counts those that are ready to claim and are not running. An issue that failed earlier in the run does not count, since the watch does not try it again. It counts a blocked issue only when each of its open blockers is in the same repository and is running or ready to claim, since those blockers can land and close; a blocker that cannot move, such as one with `labels.needsHuman`, `labels.skip` or `labels.done`, one without `labels.ready`, or one in another repository, leaves it out. It looks only at the direct blockers, and reads them one issue at a time, so it runs one `gh` call at a time. It hunts only while that count is less than `huntCap`, 1 by default. Otherwise it waits and checks again, with the same back-off as the watch: 1, 2, 3, 5, 10, then 10 minutes, back to 1 minute after a hunt that files an issue. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing backs off like a failed one. When the harness claims an issue, the hunter wakes: it ends its wait at once, or skips the wait after a hunt that is going, and checks the count again. A wake keeps the back-off where it was. The hunter:
789
799
 
790
800
  - works in its own worktree at `.worktrees/hunt`, on a detached `HEAD` at the remote base branch, which the harness fetches and checks out before each hunt. A branch that the hunter checks out keeps its commits, and an issue that resumes never uses the hunt worktree as its own;
791
801
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
@@ -828,9 +838,9 @@ affect another. The worker:
828
838
  stops nothing;
829
839
  - runs at most one run at a time. A client starts it with
830
840
  `{ "type": "start", "root": "<path>", "args": [...] }`. Each run is like
831
- `next-issue` with those args, or with none when `args` is left out. It takes
841
+ `next-issue start` with those args, or with none when `args` is left out. It takes
832
842
  `--once`, `--max <n>`, `--watch`, `--hunt`, `--reset`, `--verbose` and
833
- `--quiet`, and refuses a command, `--json`, `--force`, `--help` or an
843
+ `--quiet`, and refuses a command (`start` too), `--json`, `--force`, `--help` or an
834
844
  unknown argument with an `error` message;
835
845
  - sends every client the progress of every run when it connects and on every
836
846
  change: for each running issue the issue, the step, the tool count and the
@@ -953,5 +963,8 @@ refuses as a version it already holds, but does not serve yet, counts as
953
963
  published. So when a step fails after the tag push, the next run finishes that
954
964
  release before it makes a new one. To repair a release without a new commit,
955
965
  run the workflow by hand; a manual run does nothing else.
966
+ The job uses the npm that comes with Node 24 and never installs another one.
967
+ Trusted publishing needs npm 11.5.1 or later, so the job stops with an error
968
+ before anything else when the bundled npm is older.
956
969
  The release job stays on a GitHub runner, because npm takes provenance only
957
970
  from a GitHub runner.
package/dist/args.mjs CHANGED
@@ -12,27 +12,44 @@ const LEVELS = new Map([
12
12
  ['--verbose', 'verbose'],
13
13
  ['--quiet', 'quiet'],
14
14
  ]);
15
- export const USAGE = `next-issue [command] [options]
15
+ export const USAGE = `next-issue <command> [options]
16
16
 
17
+ start start a run: claim issues, fix them and push them to the base branch
18
+ --once stop after the first handled issue
19
+ --max <n> handle at most n issues
20
+ --watch keep running and read the issues again after each pass
21
+ --hunt hunt the repository for bugs and file issues alongside the issues, turns on --watch
22
+ --reset drop the saved budgets and findings first
17
23
  init write ${CONFIG_FILE} with the defaults and add .next-issue/ and .worktrees/ to info/exclude
18
24
  serve run the worker of this repository that pi extensions talk to
19
25
  stop stop the worker of this repository
20
26
  logs show the latest run log and follow it
21
27
 
22
- --once stop after the first handled issue
23
- --max <n> handle at most n issues
24
- --watch keep running and read the issues again after each pass
25
- --hunt hunt the repository for bugs and file issues alongside the issues, turns on --watch
26
- --reset drop the saved budgets and findings first
27
28
  --json print the machine summary instead of the text one, or raw lines with logs
28
29
  --force replace an existing config file, with init
29
30
  --verbose show every command and all agent output
30
31
  --quiet show only the milestones and the summary
31
32
  --help show this text
32
33
  `;
34
+ const RUN_FLAGS = new Set(['--once', '--max', '--watch', '--hunt', '--reset']);
33
35
  export function parseArgs(argv) {
36
+ const { args, flag, runFlag } = readArgs(argv);
37
+ if (args.help) {
38
+ return args;
39
+ }
40
+ if (args.command === undefined && flag !== undefined) {
41
+ throw new Error('no command given: use next-issue start to start a run, or see next-issue --help');
42
+ }
43
+ if (args.command !== undefined && args.command !== 'start' && runFlag !== undefined) {
44
+ throw new Error(`${args.command} does not take ${runFlag}: it belongs to start`);
45
+ }
46
+ if (args.command === 'serve' && flag !== undefined) {
47
+ throw new Error(`serve does not take ${flag}`);
48
+ }
49
+ return args;
50
+ }
51
+ function readArgs(argv) {
34
52
  const args = {
35
- command: 'run',
36
53
  once: false,
37
54
  help: false,
38
55
  json: false,
@@ -43,11 +60,15 @@ export function parseArgs(argv) {
43
60
  level: 'normal',
44
61
  };
45
62
  let flag;
63
+ let runFlag;
46
64
  for (let index = 0; index < argv.length; index += 1) {
47
65
  const arg = argv[index];
48
- if (index !== 0 && arg !== '--help') {
66
+ if ((index !== 0 || arg.startsWith('-')) && arg !== '--help') {
49
67
  flag ??= arg;
50
68
  }
69
+ if (RUN_FLAGS.has(arg)) {
70
+ runFlag ??= arg;
71
+ }
51
72
  if (index === 0 && !arg.startsWith('-')) {
52
73
  args.command = command(arg);
53
74
  }
@@ -64,14 +85,11 @@ export function parseArgs(argv) {
64
85
  throw new Error(`Unknown argument: ${arg}`);
65
86
  }
66
87
  }
67
- if (args.command === 'serve' && !args.help && flag !== undefined) {
68
- throw new Error(`serve does not take ${flag}`);
69
- }
70
88
  args.watch ||= args.hunt;
71
- return args;
89
+ return { args, flag, runFlag };
72
90
  }
73
91
  function command(arg) {
74
- if (arg !== 'init' && arg !== 'serve' && arg !== 'stop' && arg !== 'logs') {
92
+ if (arg !== 'start' && arg !== 'init' && arg !== 'serve' && arg !== 'stop' && arg !== 'logs') {
75
93
  throw new Error(`Unknown command: ${arg}`);
76
94
  }
77
95
  return arg;
@@ -85,13 +103,13 @@ function whole(value, option) {
85
103
  }
86
104
  const OUTPUT_ONLY = ['json', 'force', 'help'];
87
105
  export function parseStartArgs(argv) {
88
- const args = parseArgs(argv);
89
- if (args.command !== 'run') {
106
+ const { args } = readArgs(argv);
107
+ if (args.command !== undefined) {
90
108
  throw new Error(`start does not take ${args.command}`);
91
109
  }
92
110
  const refused = OUTPUT_ONLY.find((name) => args[name]);
93
111
  if (refused !== undefined) {
94
112
  throw new Error(`start does not take --${refused}`);
95
113
  }
96
- return args;
114
+ return { ...args, command: 'start' };
97
115
  }
package/dist/cli.mjs CHANGED
@@ -26,6 +26,10 @@ async function main() {
26
26
  await write(process.stdout, USAGE);
27
27
  return 0;
28
28
  }
29
+ if (args.command === undefined) {
30
+ await write(process.stderr, USAGE);
31
+ return 1;
32
+ }
29
33
  const root = await repoRoot(process.cwd());
30
34
  if (args.command === 'init') {
31
35
  return init(root, args.force);
package/dist/ports.mjs CHANGED
@@ -15,7 +15,7 @@ async function runSetup(command, cwd, timeoutMs) {
15
15
  }
16
16
  /** Runs a check command with its stderr in its stdout, so the output keeps the order it was written in. */
17
17
  async function runCheck(command, cwd, timeoutMs, tailChars) {
18
- const result = await run('bash', ['-lc', `exec 2>&1\n${command}`], { cwd, timeoutMs, tailChars });
18
+ const result = await run('bash', ['-c', `exec 2>&1\n${command}`], { cwd, timeoutMs, tailChars });
19
19
  return { code: result.code, output: result.stdout, timedOut: result.timedOut };
20
20
  }
21
21
  export const PORTS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.9.0",
3
+ "version": "7.0.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",