next-issue 6.6.45 → 6.6.47

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
@@ -37,7 +37,7 @@ not tried again in that run. The run ends when no unseen issue is left. When
37
37
  the fetch fails, the run claims no new issue, ends once the running issues end,
38
38
  writes the summary of the issues it handled and exits with code 1.
39
39
 
40
- Only one run goes at a time in a repository. A run holds `.next-issue/run.lock`, with its process id and the start time of that process, from its start to its end, and the worker takes the same lock for each run it starts. A run that starts while another run, from the worker or from the command line, is going claims no issue and fails at once with an error that names the other run and its process id (a command-line run exits with code 1, and a run started from the worker ends with status `failed` and the error text): `the worker (process id <n>) has a run going in this repository` or `another next-issue run (process id <n>) is going in this repository`. A lock whose process is gone, or started at another time, is stale and taken over, as with the worker lock.
40
+ Only one worker or command-line run goes at a time in a repository. Both hold one lock, `.next-issue/worker.lock`, with the process id and the start time of that process: the worker for its whole life, and a command-line run from its start to its end. A run that the worker starts takes no lock of its own, since the worker runs at most one run at a time. A command-line run that starts while any worker is alive, busy or idle, or while another command-line run is going, claims no issue and exits with code 1 and the error `another next-issue worker or run (process id <n>) is going in this repository`. Run `next-issue stop` first to stop the worker. A lock whose process is gone, or started at another time, is stale and taken over.
41
41
 
42
42
  Every command uses the main worktree of the repository as its root, the first one that `git worktree list` shows, even when it runs in a linked worktree. So `.next-issue/`, with the config, the locks, the worker socket, the saved state and the notes, and `.worktrees/` are always in the main worktree, and a run or worker started from a linked worktree gets the same refusal as one started from the main worktree.
43
43
 
@@ -115,12 +115,16 @@ the run handles one issue. For each issue:
115
115
  Approved changes land one at a time, so the next one waits until the
116
116
  checks of the last one end, and other issues go on meanwhile. The
117
117
  harness fetches the remote base, merges it into the branch and makes the
118
- change one commit on top of it, with the subject of the newest commit of
119
- the change. When git merges the base cleanly, no agent runs. When git
120
- reports conflicted files, the fixer gets the list from the check budget,
121
- `maxCiFixes`, removes the conflict markers, and the harness commits the
122
- merge. A merge that the fixer commits itself counts only when the branch
123
- then holds the base commit that was merged and the listed files hold no
118
+ change one commit on top of it, with the subject of the implementer's
119
+ commit. A review fix keeps that subject, but a commit fix for the
120
+ implementer's commit replaces it, and a fix for failed checks after the
121
+ landing lands under the fixer's own subject. The reapply commit after a
122
+ revert uses the subject of the change. When git merges the base cleanly,
123
+ no agent runs. When git reports conflicted files, the fixer gets the
124
+ list from the check budget, `maxCiFixes`, removes the conflict markers,
125
+ and the harness commits the merge. A merge that the fixer commits itself
126
+ counts only when the branch then holds the base commit that was merged
127
+ and the listed files hold no
124
128
  conflict marker. With the budget used up, or when the fixer leaves a
125
129
  conflict marker or the merge unresolved, aborts the merge, or fails, the
126
130
  harness undoes the merge and hands the issue to a person with the reason
@@ -269,7 +273,12 @@ Press `Ctrl-C` to stop the run step by step:
269
273
  3. The third press stops every agent, kills the command that runs and every
270
274
  child of it, so the run dies in the middle of a step. The saved state lets the next run continue the
271
275
  issue, but the issue keeps `status:in-progress` and the run writes no
272
- summary.
276
+ summary. Edits that an agent did not commit stay in the worktree. When
277
+ the issue resumes in review, the harness drops them before the reviewer
278
+ starts, so the reviewer sees only the commits of the branch. Files that
279
+ git ignores, such as build output, stay. When it
280
+ resumes before the first commit, the implementer runs again and the
281
+ commit holds them.
273
282
 
274
283
  Signals that arrive within 100 ms of the last counted one count as one press,
275
284
  because `npx` and `npm exec` pass on a press as a second signal.
@@ -496,7 +505,8 @@ silent skip.
496
505
  Every agent prompt holds `.next-issue/notes.md` when it exists, so lessons
497
506
  such as test commands, tool quirks and deliberate behaviour carry over from one
498
507
  issue to the next. The implementer and the fixer may add a short note to it, and
499
- the prompt asks them to keep only what still holds. The reviewer only reads it.
508
+ the prompt asks them to keep only what still holds. The reviewer and the hunter
509
+ only read it.
500
510
 
501
511
  ## Retry an issue that waits for a person
502
512
 
@@ -603,11 +613,14 @@ affect another. The worker:
603
613
  When the path of the socket file is too long for the system, about 103
604
614
  bytes on macOS and 107 on Linux, it exits with an error that says so;
605
615
  - holds `.next-issue/worker.lock` in the repository, with its process id and
606
- the start time of that process, so only one worker runs per repository. A
616
+ the start time of that process, so only one worker or command-line run goes
617
+ per repository. A worker that starts while a command-line run holds the lock
618
+ exits with `another worker is running`. A
607
619
  lock is stale, and is taken over, when no process has that id or the process
608
620
  with that id started at another time, for example because the system gave
609
621
  the id of a worker that was killed or lost in a reboot to another process.
610
- A lock without a start time, from an older version, is stale too. A worker
622
+ A lock without a start time, from an older version, is held while a process
623
+ with that id is alive, and stale otherwise. A worker
611
624
  that cannot read its own start time exits with an error and takes no lock.
612
625
  When several workers start at once, one takes the lock and the others exit
613
626
  with `another worker is running`. A worker that stops removes the lock file
@@ -661,9 +674,12 @@ affect another. The worker:
661
674
 
662
675
  Stop the worker of a repository with `next-issue stop` in that repository.
663
676
  Workers of other repositories carry on. This sends `SIGTERM` to the process in
664
- the lock file when the lock is not stale, so the worker stops at once and a
665
- run that is going resumes from its saved state next time. When no worker is
666
- running, the command says so and exits with 0.
677
+ the lock file when the lock is not stale and the worker socket file takes a
678
+ connection, so the worker stops at once and a run that is going resumes from
679
+ its saved state next time. When no worker is running, the command says so and
680
+ exits with 0. When a command-line run holds the lock, the command sends no
681
+ signal, says `no worker is running; a command-line run (process id <n>) is
682
+ going, press Ctrl-C there to stop it` and exits with 0.
667
683
 
668
684
  Versions before one worker per repository ran one worker for the machine,
669
685
  with `next-issue.sock`, `next-issue.lock` and `next-issue.roots.json` in
package/dist/cli.mjs CHANGED
@@ -9,7 +9,7 @@ import { ensureExcluded, excludeFile, removeIgnored } from './ignore.mjs';
9
9
  import { listenForInterrupts } from './interrupt.mjs';
10
10
  import { stopWorker } from './lock.mjs';
11
11
  import { followLog, newestRunLog } from './logs.mjs';
12
- import { runRepo } from './run.mjs';
12
+ import { runLocked } from './run.mjs';
13
13
  import { serve } from './serve.mjs';
14
14
  import { STATE_DIR } from './state.mjs';
15
15
  import { formatSummary } from './summary.mjs';
@@ -44,16 +44,19 @@ async function main() {
44
44
  }
45
45
  function run(root, args) {
46
46
  const interrupts = listenForInterrupts((text) => void write(process.stderr, `${text}\n`));
47
- return runRepo(root, args, {
47
+ return runLocked(root, args, {
48
48
  interrupts,
49
49
  print: (summary) => write(process.stdout, args.json ? prettyJson(summary) : formatSummary(summary)),
50
50
  });
51
51
  }
52
+ const STOPPED = {
53
+ none: () => 'next-issue: no worker is running\n',
54
+ run: (pid) => `next-issue: no worker is running; a command-line run (process id ${pid}) is going, press Ctrl-C there to stop it\n`,
55
+ worker: (pid) => `next-issue: stopped the worker with process id ${pid}\n`,
56
+ };
52
57
  async function stop(root) {
53
- const pid = await stopWorker(workerPaths(root).lockPath);
54
- await write(process.stdout, pid === undefined
55
- ? 'next-issue: no worker is running\n'
56
- : `next-issue: stopped the worker with process id ${pid}\n`);
58
+ const { stopped, pid } = await stopWorker(workerPaths(root));
59
+ await write(process.stdout, STOPPED[stopped](pid));
57
60
  return 0;
58
61
  }
59
62
  async function logs(root, json) {
package/dist/fix.mjs CHANGED
@@ -32,7 +32,15 @@ export async function fixRound(job, reason, detail, earlier, kind) {
32
32
  return disputedFix(job, before, reason, { resolved });
33
33
  }
34
34
  const subject = parseCommitSubject(text, `fix: address feedback on issue #${issue.number}`);
35
- if (!(await commitWork(job, before, subject, 'fixer'))) {
35
+ const title = job.state.title;
36
+ if (kind === 'checks') {
37
+ job.state.changeTitle ??= title;
38
+ }
39
+ const committed = await commitWork(job, before, subject, 'fixer');
40
+ if (kind === 'review') {
41
+ job.state.title = title;
42
+ }
43
+ if (!committed) {
36
44
  log.event('commit.empty', { reason }, 'quiet');
37
45
  return { committed: false };
38
46
  }
package/dist/hunt.mjs CHANGED
@@ -6,6 +6,7 @@ import { minutesToMs } from './durations.mjs';
6
6
  import { readTextIfPresent } from './files.mjs';
7
7
  import { slug } from './gh.mjs';
8
8
  import { git, gitFetch, remoteRef } from './git.mjs';
9
+ import { withNotes } from './job.mjs';
9
10
  import { oneAtATime } from './lock.mjs';
10
11
  import { huntPrompt } from './prompts.mjs';
11
12
  import { skipReason } from './skip.mjs';
@@ -43,7 +44,7 @@ export async function hunt(context, count) {
43
44
  const result = await ports.runAgent(recorder, {
44
45
  name: 'hunter',
45
46
  cwd,
46
- prompt: huntPrompt(instructions, config.labels.ready, config.labels.hunt, count, slug(repo)),
47
+ prompt: await withNotes(repo.root, huntPrompt(instructions, config.labels.ready, config.labels.hunt, count, slug(repo)), false),
47
48
  profile: REVIEWING,
48
49
  timeoutMs: minutesToMs(config.agentTimeoutMinutes),
49
50
  });
package/dist/job.mjs CHANGED
@@ -13,15 +13,18 @@ export function gateRound(gate) {
13
13
  }
14
14
  return gate.fixed ? ROUND_CONTINUE : undefined;
15
15
  }
16
+ export async function withNotes(root, prompt, writable) {
17
+ const path = notesPath(root);
18
+ const notes = await readTextIfPresent(path);
19
+ return paragraphs([notesBlock(path, notes, writable), prompt]);
20
+ }
16
21
  export async function runRole(job, role, prompt, profile) {
17
22
  const { config, ports, repo } = job.context;
18
- const path = notesPath(repo.root);
19
- const notes = await readTextIfPresent(path);
20
23
  const writable = role === 'implementer' || role === 'fixer';
21
24
  return ports.runAgent(job.log, {
22
25
  name: role,
23
26
  cwd: job.worktree,
24
- prompt: paragraphs([notesBlock(path, notes, writable), prompt]),
27
+ prompt: await withNotes(repo.root, prompt, writable),
25
28
  profile,
26
29
  model: config.models[role],
27
30
  timeoutMs: minutesToMs(config.agentTimeoutMinutes),
package/dist/lock.mjs CHANGED
@@ -2,6 +2,7 @@ import { execFile } from 'node:child_process';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { readFileSync, statSync } from 'node:fs';
4
4
  import { link, open, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
5
+ import { createConnection } from 'node:net';
5
6
  import { basename, dirname, join } from 'node:path';
6
7
  import { setTimeout as delay } from 'node:timers/promises';
7
8
  import { promisify } from 'node:util';
@@ -33,9 +34,12 @@ async function holderOf(text) {
33
34
  const [first = '', ...rest] = text.trim().split(' ');
34
35
  const pid = Number(first);
35
36
  const started = rest.join(' ');
36
- if (!(pid > 0) || started === '') {
37
+ if (!(pid > 0)) {
37
38
  return undefined;
38
39
  }
40
+ if (started === '') {
41
+ return isAlive(pid) ? pid : undefined;
42
+ }
39
43
  return (await processStart(pid)) === started ? pid : undefined;
40
44
  }
41
45
  export async function lockHolder(lockPath) {
@@ -143,12 +147,26 @@ async function removeDeadDrafts(path) {
143
147
  }
144
148
  }
145
149
  }
146
- export async function stopWorker(lockPath) {
147
- const pid = await lockHolder(lockPath);
148
- if (pid !== undefined) {
149
- process.kill(pid, 'SIGTERM');
150
+ function listening(socketPath) {
151
+ return new Promise((resolve) => {
152
+ const socket = createConnection(socketPath);
153
+ socket.once('connect', () => {
154
+ socket.destroy();
155
+ resolve(true);
156
+ });
157
+ socket.once('error', () => resolve(false));
158
+ });
159
+ }
160
+ export async function stopWorker(paths) {
161
+ const pid = await lockHolder(paths.lockPath);
162
+ if (pid === undefined) {
163
+ return { stopped: 'none' };
164
+ }
165
+ if (!(await listening(paths.socketPath))) {
166
+ return { stopped: 'run', pid };
150
167
  }
151
- return pid;
168
+ process.kill(pid, 'SIGTERM');
169
+ return { stopped: 'worker', pid };
152
170
  }
153
171
  function textOf(path) {
154
172
  try {
package/dist/revert.mjs CHANGED
@@ -25,7 +25,7 @@ export function sentence(text) {
25
25
  }
26
26
  export function reapplyMessage(job) {
27
27
  const { number } = job.issue;
28
- return `${job.state.title ?? `fix: resolve issue #${number}`}\n\nRefs #${number}`;
28
+ return `${job.state.changeTitle ?? job.state.title ?? `fix: resolve issue #${number}`}\n\nRefs #${number}`;
29
29
  }
30
30
  export async function revert(job) {
31
31
  const { context, issue, log, state, branch, worktree } = job;
package/dist/review.mjs CHANGED
@@ -61,6 +61,9 @@ async function runReviewer(job, earlier) {
61
61
  cut: full.length > config.diffMaxChars,
62
62
  };
63
63
  const before = await ports.revision(worktree);
64
+ if (await ports.discardChanges(worktree, before, job.branch)) {
65
+ log.event('review.clean', { round: state.reviewRounds }, 'quiet');
66
+ }
64
67
  const review = await log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier, earlier.length === 0 ? state.implementerReply : state.fixerReply), REVIEWING));
65
68
  if (await ports.discardChanges(worktree, before, job.branch)) {
66
69
  log.event('review.discard', { round: state.reviewRounds }, 'quiet');
package/dist/run.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { mkdir, rm } from 'node:fs/promises';
2
- import { join } from 'node:path';
2
+ import { dirname } from 'node:path';
3
3
  import { recordCommands } from './command-records.mjs';
4
4
  import { loadConfig } from './config.mjs';
5
5
  import { minutesToMs } from './durations.mjs';
@@ -17,23 +17,20 @@ import { pendingIssues } from './pending.mjs';
17
17
  import { processIssue } from './pipeline.mjs';
18
18
  import { PORTS } from './ports.mjs';
19
19
  import { pruneRuns } from './prune-runs.mjs';
20
- import { stateDir } from './state.mjs';
21
20
  import { count } from './summary.mjs';
22
21
  import { packageVersion } from './version.mjs';
23
22
  import { watchIssues } from './watch.mjs';
24
23
  import { workerPaths } from './worker-paths.mjs';
25
- export function runRepo(root, args, controls) {
26
- return withRunLock(root, () => runLoaded(root, args, controls));
27
- }
28
- async function withRunLock(root, work) {
29
- await mkdir(stateDir(root), { recursive: true });
30
- const path = join(stateDir(root), 'run.lock');
24
+ export async function runLocked(root, args, controls) {
25
+ const path = workerPaths(root).lockPath;
26
+ await mkdir(dirname(path), { recursive: true });
31
27
  const held = await lock(path, 0);
32
28
  if (held === undefined) {
33
- throw new Error(await runningMessage(root, path));
29
+ const pid = await lockHolder(path);
30
+ throw new Error(`another next-issue worker or run (process id ${pid ?? 'unknown'}) is going in this repository`);
34
31
  }
35
32
  try {
36
- return await work();
33
+ return await runRepo(root, args, controls);
37
34
  }
38
35
  finally {
39
36
  if (held.owns()) {
@@ -41,13 +38,7 @@ async function withRunLock(root, work) {
41
38
  }
42
39
  }
43
40
  }
44
- async function runningMessage(root, path) {
45
- const pid = await lockHolder(path);
46
- return pid !== undefined && pid === (await lockHolder(workerPaths(root).lockPath))
47
- ? `the worker (process id ${pid}) has a run going in this repository`
48
- : `another next-issue run (process id ${pid ?? 'unknown'}) is going in this repository`;
49
- }
50
- async function runLoaded(root, args, controls) {
41
+ export async function runRepo(root, args, controls) {
51
42
  const config = await loadConfig(root);
52
43
  return withDefaultTimeout(minutesToMs(config.commandTimeoutMinutes), () => runWithConfig(root, args, controls, config));
53
44
  }
package/dist/state.mjs CHANGED
@@ -51,6 +51,7 @@ function isState(value) {
51
51
  PHASES.includes(value.phase) &&
52
52
  typeof value.branch === 'string' &&
53
53
  isOptional(value.title, 'string') &&
54
+ isOptional(value.changeTitle, 'string') &&
54
55
  isOptional(value.implementerReply, 'string') &&
55
56
  isOptional(value.fixerReply, 'string') &&
56
57
  typeof value.ciFixes === 'number' &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.45",
3
+ "version": "6.6.47",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",