next-issue 6.6.79 → 6.6.81

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
@@ -53,7 +53,9 @@ the run handles one issue. For each issue:
53
53
  `status:in-progress` or `status:in-review` label. A `status:done`,
54
54
  `status:needs-human` or `status:blocked` label always stops the claim, a
55
55
  resume too, except a `status:needs-human` issue with an answer to its
56
- hand-over. An issue that GitHub lists as blocked by an open issue waits,
56
+ hand-over, and except an issue whose finish a stop cut short and that
57
+ was not handed over (see step 7 below). An issue that GitHub lists as
58
+ blocked by an open issue waits,
57
59
  because its blocker closes only when the change of the blocker lands.
58
60
  An issue with saved state under `.next-issue/` resumes instead, whatever its
59
61
  other labels and blockers.
@@ -171,10 +173,15 @@ the run handles one issue. For each issue:
171
173
  seconds after the others; a check that shows up in that time counts, and
172
174
  one that shows up later does not. A pending state
173
175
  waits again, up to `checkTimeoutMinutes`. A read that fails is tried three
174
- times. When the checks pass, the harness closes the issue and sets
175
- `status:done`, fetches the remote and fast-forwards the local base branch
176
- to the landed commit when that is safe, and the worktree, the local branch
177
- and the state file go away. A fetch that fails or a fast-forward that is
176
+ times. When the checks pass, the harness marks the state file as closing,
177
+ sets `status:done` and closes the issue. When a run stops or dies before
178
+ the close, the next run sees the mark, sets `status:done` and closes the
179
+ issue, with no new push, revert or hand-over. A label or close that fails
180
+ for another reason hands the issue over, and it then waits for a person
181
+ like any other hand-over. Then the harness fetches the remote and
182
+ fast-forwards the local base branch to the landed commit when that is
183
+ safe, and the worktree, the local branch and the state file go away. A
184
+ fetch that fails or a fast-forward that is
178
185
  not safe leaves the local base branch as it is and writes a `base.behind`
179
186
  event, and the issue is still done. When the checks fail, the harness
180
187
  reruns the failed GitHub Actions jobs once with
@@ -418,7 +425,9 @@ Three levels of console output:
418
425
  and the tools of your extensions. The reviewer gets all of them except
419
426
  `edit` and `write`. The agents run with `GIT_OPTIONAL_LOCKS=0`, so a
420
427
  `git status` from an agent or an extension does not hold the index lock
421
- while the harness commits.
428
+ while the harness commits. While an agent runs, `process.argv[1]` is the
429
+ pi CLI, so an extension that starts a child pi with `process.execPath` and
430
+ `process.argv[1]` (such as a `subagent` tool) runs pi, not next-issue.
422
431
 
423
432
  ## Configuration
424
433
 
package/dist/agents.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
1
4
  import { getAgentDir, } from '@earendil-works/pi-coding-agent';
2
5
  import { openSession } from './agent-session.mjs';
3
6
  import { onStop, refuseWhenStopped } from './children.mjs';
@@ -10,11 +13,18 @@ export const REVIEWING = {
10
13
  export const CODING = {
11
14
  tools: ['+grep', '+find', '+ls'],
12
15
  };
16
+ const PI_CLI = piCli();
17
+ function piCli() {
18
+ const root = dirname(dirname(fileURLToPath(import.meta.resolve('@earendil-works/pi-coding-agent'))));
19
+ const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
20
+ return join(root, manifest.bin.pi);
21
+ }
13
22
  export async function runAgent(recorder, request) {
14
23
  const log = recorder.scope({ role: request.name });
15
24
  const agentDir = request.runtime?.agentDir ?? getAgentDir();
16
25
  const started = Date.now();
17
26
  process.env.GIT_OPTIONAL_LOCKS = '0';
27
+ process.argv[1] = PI_CLI;
18
28
  log.event('agent.start', { model: request.model, timeoutMs: request.timeoutMs });
19
29
  const session = await openSession(recorder, log, request, agentDir);
20
30
  const timer = deadline(request.timeoutMs, () => void session.abort());
package/dist/handover.mjs CHANGED
@@ -28,11 +28,29 @@ export async function escalateAndFinish(job, note, reason) {
28
28
  }
29
29
  export async function finishDone(job) {
30
30
  const { context, issue } = job;
31
+ job.state.closing = true;
32
+ await writeState(context.repo, job.state);
31
33
  await setStatus(context, issue.number, context.config.labels.done);
32
34
  await context.ports.closeIssue(context.repo, issue.number);
33
35
  await updateLocalBase(job);
34
36
  return { done: true, report: await finish(job, 'done') };
35
37
  }
38
+ export async function finishClosing(context, issue, log, state, started) {
39
+ const job = {
40
+ context,
41
+ issue,
42
+ log,
43
+ state,
44
+ branch: state.branch,
45
+ worktree: '',
46
+ comments: [],
47
+ reply: [],
48
+ started,
49
+ mainBroken: false,
50
+ repairing: false,
51
+ };
52
+ return (await finishDone(job)).report;
53
+ }
36
54
  async function updateLocalBase(job) {
37
55
  const { context, log } = job;
38
56
  const { repo, ports, config, base } = context;
package/dist/pipeline.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { enterReview } from './enter-review.mjs';
2
2
  import { branchName } from './git.mjs';
3
3
  import { runStopped } from './children.mjs';
4
- import { claimedError, stop, stopNow } from './handover.mjs';
4
+ import { claimedError, finishClosing, stop, stopNow } from './handover.mjs';
5
5
  import { implement } from './implement.mjs';
6
6
  import { openJob } from './open-job.mjs';
7
7
  import { reviewRound } from './review.mjs';
@@ -19,7 +19,8 @@ export async function processIssue(context, issue, claimed = () => undefined) {
19
19
  catch (error) {
20
20
  return unclaimedError(log, issue, error, started);
21
21
  }
22
- const skip = await skipReport(context, log, issue, saved, started);
22
+ const closing = saved?.closing === true && saved.handedOver !== true;
23
+ const skip = closing ? undefined : await skipReport(context, log, issue, saved, started);
23
24
  if (skip !== undefined) {
24
25
  return skip;
25
26
  }
@@ -28,7 +29,9 @@ export async function processIssue(context, issue, claimed = () => undefined) {
28
29
  const state = startState(context, issue, saved);
29
30
  let report;
30
31
  try {
31
- report = await work(context, issue, log, state, saved === undefined, saved?.handedOver === true);
32
+ report = closing
33
+ ? await finishClosing(context, issue, log, state, started)
34
+ : await work(context, issue, log, state, saved === undefined, saved?.handedOver === true);
32
35
  }
33
36
  catch (error) {
34
37
  if (!runStopped()) {
package/dist/state.mjs CHANGED
@@ -65,7 +65,8 @@ function isState(value) {
65
65
  typeof value.reviewRounds === 'number' &&
66
66
  Array.isArray(value.reviewLog) &&
67
67
  value.reviewLog.every(isReviewRound) &&
68
- isOptional(value.handedOver, 'boolean'));
68
+ isOptional(value.handedOver, 'boolean') &&
69
+ isOptional(value.closing, 'boolean'));
69
70
  }
70
71
  export async function savedIssues(repo) {
71
72
  const names = (await unlessMissing(() => readdir(stateDir(repo.root)))) ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.79",
3
+ "version": "6.6.81",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",