next-issue 2.4.4 → 2.4.5

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,8 @@ and exits with code 1. For each issue:
37
37
  hook stops a commit, the agent that made the change gets the hook output,
38
38
  fixes it, and the harness commits again. A `commit:` line in the reply of
39
39
  the agent replaces the subject, so a hook that rejects the subject can pass.
40
- The budget is `maxCommitFixes`.
40
+ The budget is `maxCommitFixes`. Any other git failure in the commit stops
41
+ the run with an error.
41
42
  5. Open a draft pull request that closes the issue. Its title is the subject
42
43
  of the commit that starts it, so a squash merge gives a conventional
43
44
  commit.
package/dist/git.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { appendFile, readFile } from 'node:fs/promises';
1
+ import { appendFile, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
2
3
  import { join } from 'node:path';
3
4
  import { must, run } from './exec.mjs';
4
5
  const REMOTE_PATTERNS = [
@@ -97,14 +98,34 @@ export async function isDirty(cwd) {
97
98
  export async function diff(cwd, base, remote) {
98
99
  return must('git', ['diff', `${remote}/${base}...HEAD`], { cwd });
99
100
  }
101
+ export class HookError extends Error {
102
+ }
100
103
  export async function commitAll(cwd, message) {
101
104
  if (!(await isDirty(cwd))) {
102
105
  return false;
103
106
  }
104
107
  await must('git', ['add', '-A'], { cwd });
105
- await must('git', ['commit', '-m', message], { cwd });
108
+ const folder = await mkdtemp(join(tmpdir(), 'next-issue-message-'));
109
+ const file = join(folder, 'COMMIT_EDITMSG');
110
+ try {
111
+ await writeFile(file, `${message}\n`);
112
+ await runHook(cwd, 'pre-commit');
113
+ await runHook(cwd, 'commit-msg', file);
114
+ await must('git', ['commit', '--no-verify', '-F', file], { cwd });
115
+ }
116
+ finally {
117
+ await rm(folder, { recursive: true, force: true });
118
+ }
106
119
  return true;
107
120
  }
121
+ async function runHook(cwd, name, ...args) {
122
+ try {
123
+ await must('git', ['hook', 'run', '--ignore-missing', name, '--', ...args], { cwd });
124
+ }
125
+ catch (error) {
126
+ throw new HookError(error instanceof Error ? error.message : String(error));
127
+ }
128
+ }
108
129
  export async function discardChanges(cwd, target) {
109
130
  if (!(await isDirty(cwd)) && (await revision(cwd)) === target) {
110
131
  return false;
package/dist/pipeline.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CODING, REVIEWING, runAgent } from './agents.mjs';
2
2
  import { managedLabels } from './config.mjs';
3
3
  import { run } from './exec.mjs';
4
- import { addWorktree, branchName, commitAll, deleteBranch, diff, discardChanges, disputeBranches, findWorktree, isDirty, push, removeWorktree, resetToBase, revision, setAside, } from './git.mjs';
4
+ import { addWorktree, branchName, commitAll, deleteBranch, diff, discardChanges, disputeBranches, findWorktree, HookError, isDirty, push, removeWorktree, resetToBase, revision, setAside, } from './git.mjs';
5
5
  import { commentOnPr, createPr, failedBaseLogs, failedCheckLogs, findPr, issueComments, markPrReady, mergeCommit, mergePr, openBlockers, openIssues, prMerged, reopenIssue, setLabel, viewIssue, waitForBaseChecks, waitForChecks, } from './github.mjs';
6
6
  import { message } from './observe.mjs';
7
7
  import { capDiff, fixPrompt, hookPrompt, implementPrompt, parseCommitSubject, parseUnrelated, reviewPrompt, } from './prompts.mjs';
@@ -570,7 +570,7 @@ async function commitWork(job, before, subject, role) {
570
570
  }
571
571
  catch (error) {
572
572
  const used = state.commitFixes ?? 0;
573
- if (used >= config.maxCommitFixes) {
573
+ if (!(error instanceof HookError) || used >= config.maxCommitFixes) {
574
574
  throw error;
575
575
  }
576
576
  state.commitFixes = used + 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",