next-issue 2.4.5 → 2.4.6

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
@@ -30,9 +30,12 @@ and exits with code 1. For each issue:
30
30
  state keeps the branch name that the state holds, and a worktree that
31
31
  holds that branch already stays in use. A branch that exists on the
32
32
  remote is the start, and a local branch that fell behind the remote is
33
- fast-forwarded. A fast-forward of the base that is not safe leaves the
34
- local base branch as it is and writes a `base.behind` event. A new branch
35
- then starts from the remote base.
33
+ fast-forwarded. An issue with no saved state does not reuse a local
34
+ `<n>` branch: it resets that branch, and any worktree that holds it, to
35
+ the remote branch, or to the remote base when there is none. A
36
+ fast-forward of the base that is not safe leaves the local base branch as
37
+ it is and writes a `base.behind` event. A new branch then starts from the
38
+ remote base.
36
39
  4. Let the implementer agent do the work, then commit and push. When a git
37
40
  hook stops a commit, the agent that made the change gets the hook output,
38
41
  fixes it, and the harness commits again. A `commit:` line in the reply of
package/dist/git.mjs CHANGED
@@ -29,7 +29,7 @@ export const WORKTREE_DIR = '.worktrees';
29
29
  export function worktreePath(repo, issue) {
30
30
  return join(repo.root, WORKTREE_DIR, String(issue));
31
31
  }
32
- export async function addWorktree(repo, issue, branch, base, remote) {
32
+ export async function addWorktree(repo, issue, branch, base, remote, start) {
33
33
  const upstream = `${remote}/${branch}`;
34
34
  await must('git', ['fetch', remote], { cwd: repo.root });
35
35
  const baseUpdated = await updateBase(repo, base, remote);
@@ -37,12 +37,16 @@ export async function addWorktree(repo, issue, branch, base, remote) {
37
37
  const pushed = await hasBranch(repo, upstream, '--remotes');
38
38
  const existing = await findWorktree(repo, branch);
39
39
  const path = existing ?? worktreePath(repo, issue);
40
+ const target = pushed ? upstream : `${remote}/${base}`;
40
41
  if (existing === undefined) {
41
- const args = (await hasBranch(repo, branch))
42
+ const args = !start && (await hasBranch(repo, branch))
42
43
  ? ['worktree', 'add', path, branch]
43
- : ['worktree', 'add', '-b', branch, path, pushed ? upstream : `${remote}/${base}`];
44
+ : ['worktree', 'add', '-B', branch, path, target];
44
45
  await must('git', args, { cwd: repo.root });
45
46
  }
47
+ else if (start) {
48
+ await discardChanges(path, target);
49
+ }
46
50
  if (pushed) {
47
51
  await run('git', ['merge', '--ff-only', upstream], { cwd: path });
48
52
  }
package/dist/pipeline.mjs CHANGED
@@ -132,7 +132,7 @@ export async function processIssue(context, issue) {
132
132
  };
133
133
  const state = saved === undefined ? fresh : context.reset ? resetState(saved) : saved;
134
134
  try {
135
- const report = await work(context, issue, log, state);
135
+ const report = await work(context, issue, log, state, saved === undefined);
136
136
  log.event('issue.end', { outcome: report.outcome, reason: report.reason, ms: report.ms }, 'quiet');
137
137
  return report;
138
138
  }
@@ -159,7 +159,7 @@ export async function processIssue(context, issue) {
159
159
  function skipped(issue) {
160
160
  return { issue: issue.number, outcome: 'skipped', ciFixes: 0, reviewRounds: 0, ms: 0 };
161
161
  }
162
- async function work(context, issue, log, state) {
162
+ async function work(context, issue, log, state, start) {
163
163
  const started = Date.now();
164
164
  const { repo, config, ports } = context;
165
165
  const branch = state.branch;
@@ -168,7 +168,7 @@ async function work(context, issue, log, state) {
168
168
  await writeState(repo, state);
169
169
  });
170
170
  const comments = await log.step('comments', {}, () => ports.issueComments(repo, issue.number));
171
- const added = await log.step('worktree', { branch }, () => ports.addWorktree(repo, issue.number, branch, context.base, config.remote));
171
+ const added = await log.step('worktree', { branch }, () => ports.addWorktree(repo, issue.number, branch, context.base, config.remote, start));
172
172
  const worktree = added.path;
173
173
  if (!added.baseUpdated) {
174
174
  log.event('base.behind', { base: context.base }, 'quiet');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",