next-issue 6.10.0 → 7.1.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
@@ -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.
@@ -683,6 +683,14 @@ issue to the next. The implementer and the fixer may add a short note to it, and
683
683
  the prompt asks them to keep only what still holds. The reviewer and the hunter
684
684
  only read it.
685
685
 
686
+ Every agent also reads each `AGENTS.md` that pi finds, such as the one in your
687
+ home folder and the one in the repository. The other rules there, such as code
688
+ conventions and test style, still apply. But the harness owns the issue, the
689
+ worktree, the branch, git, the commit, the push and the checks, and the prompt
690
+ says so: a workflow rule in `AGENTS.md` about these, such as "push to main" or
691
+ "watch ci", does not apply to the agent. The hunter still files its issues with
692
+ `gh issue create`.
693
+
686
694
  ## Retry an issue that waits for a person
687
695
 
688
696
  When the implementer makes no change, the hand-over comment holds its full
@@ -735,31 +743,41 @@ an issue for the next run to clean up.
735
743
 
736
744
  ## Commands and options
737
745
 
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.
746
+ | Argument | Effect |
747
+ | ----------- | ---------------------------------------------------------------------------------------------------- |
748
+ | `start` | Start a run: claim issues, fix them and push them to the base branch |
749
+ | `init` | Write the config file with the defaults |
750
+ | `serve` | Run the worker of this repository that pi extensions talk to, see [Worker](#worker) |
751
+ | `stop` | Stop the worker of this repository, see [Worker](#worker) |
752
+ | `logs` | Show the latest run log and follow it, see [Observability](#observability) |
753
+ | `--force` | Replace an existing config file, with `init` |
754
+ | `--once` | Stop after the first handled issue, with `start` |
755
+ | `--max <n>` | Handle at most n issues, with `start` |
756
+ | `--watch` | Keep running, and read the open issues again after each pass, with `start` |
757
+ | `--hunt` | Hunt the repository for bugs alongside the issues, with `start`, see [Hunt for bugs](#hunt-for-bugs) |
758
+ | `--reset` | Drop the saved budgets and findings, and keep the rest of the state, with `start` |
759
+ | `--json` | Print the machine summary instead of the text one, or the raw JSON lines with `logs` |
760
+ | `--verbose` | Show every command and all agent output |
761
+ | `--quiet` | Show only the milestones and the summary |
762
+ | `--help` | Show the option list |
763
+
764
+ `--once`, `--max <n>`, `--watch`, `--hunt` and `--reset` belong to `start`, and
765
+ any other command refuses them. `next-issue` with no command prints the option
766
+ list on standard error, starts nothing and exits with 1.
767
+
768
+ The exit code of `next-issue start` is 1 when an issue needs a person or
769
+ failed, and 0 when it does not, so a cron job or a CI step can read the result
770
+ of the run.
771
+
772
+ Versions before 7.0.0 started a run with no command, as `next-issue` or
773
+ `next-issue --once`. From 7.0.0 a run needs `next-issue start`, and the old
774
+ form starts nothing and exits with 1.
757
775
 
758
776
  ## Watch for new issues
759
777
 
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
778
+ A run without `--watch` ends when no unseen issue is left. With
779
+ `next-issue start --watch`, the harness then waits, reads the open issues again
780
+ and runs another pass, so it picks up an issue that someone opens during the run, or one whose blocker
763
781
  closes. Each pass tries every open issue again, also one that an earlier pass
764
782
  skipped. An issue that failed in an earlier pass is not tried again until the
765
783
  next run.
@@ -785,7 +803,7 @@ The watch stops:
785
803
 
786
804
  ## Hunt for bugs
787
805
 
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:
806
+ 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
807
 
790
808
  - 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
809
  - follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
@@ -828,9 +846,9 @@ affect another. The worker:
828
846
  stops nothing;
829
847
  - runs at most one run at a time. A client starts it with
830
848
  `{ "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
849
+ `next-issue start` with those args, or with none when `args` is left out. It takes
832
850
  `--once`, `--max <n>`, `--watch`, `--hunt`, `--reset`, `--verbose` and
833
- `--quiet`, and refuses a command, `--json`, `--force`, `--help` or an
851
+ `--quiet`, and refuses a command (`start` too), `--json`, `--force`, `--help` or an
834
852
  unknown argument with an `error` message;
835
853
  - sends every client the progress of every run when it connects and on every
836
854
  change: for each running issue the issue, the step, the tool count and the
@@ -935,7 +953,14 @@ Releases are automatic and need no pull request. Push a
935
953
  [conventional commit](https://www.conventionalcommits.org/) to `main`. The
936
954
  workflow reads the commits since the last tag and picks the bump: `feat` gives a
937
955
  minor, `fix` gives a patch, and a `!` mark or a `BREAKING CHANGE` body gives a
938
- major. Any other type releases nothing.
956
+ major. Any other type releases nothing. The notes of the GitHub release list the
957
+ subject and short hash of each breaking, `feat` and `fix` commit since the
958
+ previous tag, grouped by type, and end with the compare link from that tag.
959
+
960
+ The release is the `release` job of the `ci` workflow, and it runs only after
961
+ the `check` job of the same commit passes. A commit that fails the typecheck,
962
+ lint, format check, tests or build releases nothing. As the release is part of
963
+ the `push` run, the harness waits for it like any other check.
939
964
 
940
965
  The workflow then gives `next-issue` and `@ravshansbox/pi-next-issue` the same
941
966
  new version and publishes both packages to npm with a
@@ -952,6 +977,10 @@ version, and makes the GitHub release if it is missing. A package that npm
952
977
  refuses as a version it already holds, but does not serve yet, counts as
953
978
  published. So when a step fails after the tag push, the next run finishes that
954
979
  release before it makes a new one. To repair a release without a new commit,
955
- run the workflow by hand; a manual run does nothing else.
980
+ run the `ci` workflow by hand; after the checks pass, the release job only
981
+ repairs and does nothing else.
982
+ The job uses the npm that comes with Node 24 and never installs another one.
983
+ Trusted publishing needs npm 11.5.1 or later, so the job stops with an error
984
+ before anything else when the bundled npm is older.
956
985
  The release job stays on a GitHub runner, because npm takes provenance only
957
986
  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/prompts.mjs CHANGED
@@ -1,6 +1,12 @@
1
1
  import { ISSUE_SECTIONS } from './issue-format.mjs';
2
2
  import { paragraphs } from './text.mjs';
3
+ const OTHER_RULES = 'The other rules of `AGENTS.md`, such as code conventions and test style, still apply.';
4
+ const HARNESS_RULES = [
5
+ 'The harness owns the issue, the worktree, the branch, git, the commit, the push and the checks. The workflow rules of `AGENTS.md` about these do not apply to you.',
6
+ OTHER_RULES,
7
+ ].join('\n');
3
8
  const COMMIT_RULES = [
9
+ HARNESS_RULES,
4
10
  'Do not run git, gh or any push command. The harness commits for you.',
5
11
  'End your final message with one line in the form `commit: <conventional commit subject>`.',
6
12
  ].join('\n');
@@ -92,6 +98,7 @@ export function reviewPrompt(issue, comments, diff, earlier, reply) {
92
98
  'Read files and run commands to prove what you say: the tests, the type check or the linter.',
93
99
  'The worktree is ready to use. Do not change a file. Do not write with git or gh, and do not check out another commit or branch.',
94
100
  'The harness discards each change that you make, so a change is only lost work.',
101
+ HARNESS_RULES,
95
102
  reviewScope(earlier),
96
103
  'Mark a finding blocking only for a wrong result, a missing part of the issue, a regression or a broken convention.',
97
104
  'End your final message with the result as a json block in a ```json fence, in the form {"summary": "<short summary>", "findings": [{"severity": "blocking" or "minor", "detail": "<what is wrong and where>"}]}.',
@@ -178,6 +185,8 @@ export function huntPrompt(instructions, ready, source, count, repository) {
178
185
  '## Rules',
179
186
  [
180
187
  'Run no test suite and no build. Change no file. Do not commit or push.',
188
+ 'The harness owns the worktree, git and the checks. The workflow rules of `AGENTS.md` about these do not apply to you.',
189
+ OTHER_RULES,
181
190
  `File up to ${issues}, your most serious findings first. File nothing when you find no real problem.`,
182
191
  `Before you file an issue, search the open and closed issues for a duplicate, for example with \`gh issue list --repo ${repository} --state all --search "<words>"\`. Do not file a finding when a duplicate exists.`,
183
192
  `File each issue with \`gh issue create --repo ${repository}${label} --title "<conventional commit subject>" --body-file -\`.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.10.0",
3
+ "version": "7.1.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",