next-issue 17.2.15 → 17.4.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/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseArgs, USAGE } from './shared/args.mjs';
3
- import { loadConfig, moveOldConfig, rejectOldConfig, writeDefaultConfig, } from './shared/config.mjs';
4
- import { OLD_CONFIG_FILE } from './shared/config-fields.mjs';
3
+ import { loadConfig, moveOldConfig, rejectOldConfig, removeUnknownFields, writeDefaultConfig, } from './shared/config.mjs';
4
+ import { CONFIG_FILE, OLD_CONFIG_FILE } from './shared/config-fields.mjs';
5
5
  import { message } from './shared/errors.mjs';
6
6
  import { detectRepo, repoRoot } from './shared/git.mjs';
7
7
  import { basePackage, requireScripts } from './shared/setup.mjs';
@@ -49,6 +49,7 @@ async function main() {
49
49
  if (args.command === 'logs') {
50
50
  return logs(root);
51
51
  }
52
+ await removeUnknownConfig(root, process.stderr);
52
53
  if (args.command === 'start') {
53
54
  requireScripts(await rootBasePackage(root));
54
55
  }
@@ -81,6 +82,7 @@ async function init(root, args) {
81
82
  else {
82
83
  await write(process.stdout, `moved ${OLD_CONFIG_FILE} to ${moved}\n`);
83
84
  }
85
+ await removeUnknownConfig(root, process.stdout);
84
86
  await excludeStateDirectories(root, process.stdout);
85
87
  for (const folder of await installSkills(scope)) {
86
88
  await write(process.stdout, `wrote ${folder}\n`);
@@ -98,6 +100,11 @@ async function rootBasePackage(root) {
98
100
  const { remote } = await loadConfig(root);
99
101
  return basePackage(await detectRepo(root, remote), remote);
100
102
  }
103
+ async function removeUnknownConfig(root, stream) {
104
+ for (const entry of await removeUnknownFields(root)) {
105
+ await write(stream, `removed ${entry} from ${CONFIG_FILE}\n`);
106
+ }
107
+ }
101
108
  async function excludeStateDirectories(root, stream) {
102
109
  const exclude = await excludeFile(root);
103
110
  const entries = [
@@ -4,6 +4,7 @@ import { CONFIG_FILE, checkNames, OLD_CONFIG_FILE, record, rejectUnknown, text,
4
4
  import { MAX_TIMER_MS } from './durations.mjs';
5
5
  import { hasCode, message, parseJson } from './errors.mjs';
6
6
  import { readTextIfPresent, replaceJson, sortKeys, unlessMissing, writeJson } from './files.mjs';
7
+ import { isRecord } from './records.mjs';
7
8
  const DEFAULTS = {
8
9
  remote: 'origin',
9
10
  issueLimit: 100,
@@ -133,6 +134,44 @@ export async function loadConfig(root, options = {}) {
133
134
  }
134
135
  return config;
135
136
  }
137
+ export async function removeUnknownFields(root) {
138
+ const path = configFile(root);
139
+ const raw = await readTextIfPresent(path);
140
+ const file = raw === undefined ? undefined : parsedOrUndefined(raw);
141
+ if (!isObject(file)) {
142
+ return [];
143
+ }
144
+ const removed = [
145
+ ...removeUnknown(file, FIELDS, ''),
146
+ ...removeUnknown(file.models, MODEL_ROLES, 'models.'),
147
+ ...removeUnknown(file.labels, LABEL_NAMES, 'labels.'),
148
+ ];
149
+ if (removed.length > 0) {
150
+ await replaceJson(path, file);
151
+ }
152
+ return removed;
153
+ }
154
+ function parsedOrUndefined(raw) {
155
+ try {
156
+ return JSON.parse(raw);
157
+ }
158
+ catch {
159
+ return undefined;
160
+ }
161
+ }
162
+ function isObject(value) {
163
+ return isRecord(value) && !Array.isArray(value);
164
+ }
165
+ function removeUnknown(value, known, prefix) {
166
+ if (!isObject(value)) {
167
+ return [];
168
+ }
169
+ const unknown = Object.keys(value).filter((key) => !known.includes(key));
170
+ for (const key of unknown) {
171
+ delete value[key];
172
+ }
173
+ return unknown.map((key) => `${prefix}${key}`);
174
+ }
136
175
  async function sortConfigFile(root, file) {
137
176
  const sorted = sortKeys({
138
177
  ...file,
@@ -144,9 +183,6 @@ async function sortConfigFile(root, file) {
144
183
  }
145
184
  function parseConfig(value) {
146
185
  const file = record(value, 'the file');
147
- if (file.draftPullRequest !== undefined) {
148
- throw new Error(`${CONFIG_FILE}: draftPullRequest is no longer used, because changes land on the base branch with no pull request. Remove the field.`);
149
- }
150
186
  rejectUnknown(file, FIELDS, 'field');
151
187
  const config = defaults();
152
188
  if (file.remote !== undefined) {
@@ -5,15 +5,23 @@ import { message } from './errors.mjs';
5
5
  import { git, isDirty } from './git.mjs';
6
6
  export class HookError extends Error {
7
7
  }
8
- export async function commitAll(cwd, commitMessage) {
8
+ export async function commitAll(cwd, commitMessage, options = {}) {
9
9
  if (!(await isDirty(cwd))) {
10
10
  return false;
11
11
  }
12
- await commitEverything(cwd, commitMessage);
12
+ await commitEverything(cwd, commitMessage, options);
13
13
  return true;
14
14
  }
15
- export async function commitEverything(cwd, commitMessage) {
15
+ /** Commits what the setup wrote on top of the change, with no hooks, so every check sees it. */
16
+ export async function saveSetupOutput(cwd) {
17
+ await commitAll(cwd, 'chore: setup output', { hooks: false });
18
+ }
19
+ export async function commitEverything(cwd, commitMessage, { hooks = true } = {}) {
16
20
  await git(cwd, ['add', '-A']);
21
+ if (!hooks) {
22
+ await git(cwd, ['commit', '--no-verify', '-m', commitMessage]);
23
+ return;
24
+ }
17
25
  const folder = await mkdtemp(join(tmpdir(), 'next-issue-message-'));
18
26
  const file = join(folder, 'COMMIT_EDITMSG');
19
27
  try {
@@ -59,6 +59,9 @@ export async function reapplyRevert(cwd, reapply) {
59
59
  }
60
60
  async function commitReapply(cwd, reverted, message, branch) {
61
61
  await git(cwd, ['revert', '--no-commit', reverted]);
62
+ await commitOnBranch(cwd, message, branch);
63
+ }
64
+ async function commitOnBranch(cwd, message, branch) {
62
65
  await git(cwd, ['commit', '--no-verify', '-m', message]);
63
66
  await git(cwd, ['checkout', '-B', branch]);
64
67
  }
@@ -74,8 +77,7 @@ async function pushRevert(cwd, revert) {
74
77
  if (await succeeds(cwd, ['diff', '--cached', '--quiet', 'HEAD'])) {
75
78
  await git(cwd, ['revert', '--abort']);
76
79
  await git(cwd, ['cherry-pick', '--no-commit', ...shas]);
77
- await git(cwd, ['commit', '--no-verify', '-m', reapply]);
78
- await git(cwd, ['checkout', '-B', branch]);
80
+ await commitOnBranch(cwd, reapply, branch);
79
81
  return 'already reverted';
80
82
  }
81
83
  await git(cwd, ['commit', '--no-verify', '-m', message]);
@@ -97,19 +97,6 @@ export async function resetHard(cwd, target) {
97
97
  await git(cwd, ['reset', '--hard', target]);
98
98
  await git(cwd, ['clean', '-fd']);
99
99
  }
100
- /** Commits every edit in the worktree, with no hooks, so a later checkout cannot throw it away. */
101
- export async function saveEdits(cwd, commitMessage) {
102
- if (!(await isDirty(cwd))) {
103
- return false;
104
- }
105
- await git(cwd, ['add', '-A']);
106
- await git(cwd, ['commit', '--no-verify', '-m', commitMessage]);
107
- return true;
108
- }
109
- /** Commits what the setup wrote on top of the change, with no hooks, so every check sees it. */
110
- export async function saveSetupOutput(cwd) {
111
- await saveEdits(cwd, 'chore: setup output');
112
- }
113
100
  export async function setAside(cwd, target, branch) {
114
101
  await git(cwd, ['branch', branch]);
115
102
  await discardChanges(cwd, target);
@@ -48,10 +48,6 @@ export async function viewIssue(repo, issue) {
48
48
  const parsed = await viewJson(repo, 'issue', issue, `${ISSUE_FIELDS},state`);
49
49
  return { ...toIssue(parsed), open: parsed.state === 'OPEN' };
50
50
  }
51
- export async function issueComments(repo, issue) {
52
- const parsed = await viewJson(repo, 'issue', issue, 'comments');
53
- return parsed.comments.map((comment) => ({ author: comment.author.login, body: comment.body }));
54
- }
55
51
  export async function threadComments(repo, number) {
56
52
  const raw = await ghApi(repo, `issues/${number}/comments`, '.[] | [.user.login, .body, .html_url, .created_at] | @json', { paginate: true });
57
53
  return lines(raw).map((line) => parseComment(line, number));
@@ -67,7 +67,7 @@ async function replyAfter(comments, last, writer, pending) {
67
67
  }
68
68
  export async function writerComments(context, log, issue) {
69
69
  const { repo, ports } = context;
70
- const comments = (await ports.issueComments(repo, issue)).filter((comment) => !fromHarness(comment));
70
+ const comments = (await ports.threadComments(repo, issue)).filter((comment) => !fromHarness(comment));
71
71
  return writerQuotes(comments, writers(repo, ports), (comment) => log.event('comment.skip', { author: comment.author }));
72
72
  }
73
73
  export async function handOverReply(context, issue, pending) {
@@ -7,12 +7,6 @@ import { paragraphs, withoutClosingReferences } from './text.mjs';
7
7
  export const ROUND_CONTINUE = { done: false };
8
8
  export const GATE_PASSED = { done: false, fixed: false };
9
9
  export const GATE_FIXED = { done: false, fixed: true };
10
- export function gateRound(gate) {
11
- if (gate.done) {
12
- return gate;
13
- }
14
- return gate.fixed ? ROUND_CONTINUE : undefined;
15
- }
16
10
  export async function withNotes(root, prompt, writable) {
17
11
  const path = notesPath(root);
18
12
  const notes = await readTextIfPresent(path);
@@ -14,14 +14,14 @@ export function oneAtATime(root, work) {
14
14
  worktreeQueues.set(root, result.catch(() => undefined));
15
15
  return result;
16
16
  }
17
- export async function processStart(pid, zone = { TZ: 'UTC' }) {
17
+ export async function processStart(pid) {
18
18
  const stat = await readTextOrEmpty(`/proc/${pid}/stat`);
19
19
  if (stat !== '') {
20
20
  return stat.slice(stat.lastIndexOf(')') + 2).split(' ')[19];
21
21
  }
22
22
  try {
23
23
  const { stdout } = await promisify(execFile)('ps', ['-o', 'lstart=', '-p', String(pid)], {
24
- env: { ...process.env, LC_ALL: 'C', ...zone },
24
+ env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' },
25
25
  });
26
26
  return stdout.trim() || undefined;
27
27
  }
@@ -33,17 +33,14 @@ async function holderOf(text) {
33
33
  const [first = '', ...rest] = text.trim().split(' ');
34
34
  const pid = Number(first);
35
35
  const started = rest.join(' ');
36
- if (!(pid > 0)) {
36
+ if (!(pid > 0) || started === '') {
37
37
  return undefined;
38
38
  }
39
- if (started === '') {
40
- return isAlive(pid) ? pid : undefined;
41
- }
42
39
  const now = await processStart(pid);
43
40
  if (now === undefined) {
44
41
  return isAlive(pid) ? pid : undefined;
45
42
  }
46
- return now === started || (await processStart(pid, {})) === started ? pid : undefined;
43
+ return now === started ? pid : undefined;
47
44
  }
48
45
  export async function lockHolder(lockPath) {
49
46
  return holderOf(await readTextOrEmpty(lockPath));
@@ -1,11 +1,11 @@
1
1
  import { runAgent } from './agents.mjs';
2
2
  import { failedCiLogs, rerunFailedCi, waitForCiChecks } from './ci-checks.mjs';
3
3
  import { run } from './exec.mjs';
4
- import { commitAll } from './git-commit.mjs';
4
+ import { commitAll, saveSetupOutput } from './git-commit.mjs';
5
5
  import { baseMoved, pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
6
6
  import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
7
- import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, revision, saveEdits, saveSetupOutput, setAside, } from './git.mjs';
8
- import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, issueEditors, labeler, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
7
+ import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, revision, setAside, } from './git.mjs';
8
+ import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueEditors, labeler, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
9
9
  import { huntWorktree } from './hunt.mjs';
10
10
  import { ensureLabel, setLabel } from './labels.mjs';
11
11
  import { detectSetupCommand } from './setup.mjs';
@@ -42,7 +42,6 @@ export const PORTS = {
42
42
  isDirty,
43
43
  isLanded,
44
44
  isOnBase,
45
- issueComments,
46
45
  issueEditors,
47
46
  labeler,
48
47
  latestSubject,
@@ -59,7 +58,6 @@ export const PORTS = {
59
58
  runAgent,
60
59
  runCheck,
61
60
  runSetup,
62
- saveEdits,
63
61
  saveSetupOutput,
64
62
  setAside,
65
63
  setLabel,
@@ -1,7 +1,8 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { realpath } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
- import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, revision, saveEdits, succeeds, } from './git.mjs';
4
+ import { commitAll } from './git-commit.mjs';
5
+ import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, revision, succeeds, } from './git.mjs';
5
6
  export const WORKTREE_DIR = '.claude/worktrees';
6
7
  export function huntPath(repo) {
7
8
  return join(repo.root, WORKTREE_DIR, 'next-issue-hunt');
@@ -40,7 +41,7 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
40
41
  async function keepDetachedEdits(path, branch) {
41
42
  if (!existsSync(join(path, '.git')) ||
42
43
  (await currentBranch(path)) !== undefined ||
43
- !(await saveEdits(path, 'chore: edits left on a detached HEAD'))) {
44
+ !(await commitAll(path, 'chore: edits left on a detached HEAD', { hooks: false }))) {
44
45
  return;
45
46
  }
46
47
  await git(path, ['branch', `${branch}-detached-${(await revision(path)).slice(0, 7)}`]);
@@ -59,7 +59,7 @@ async function disputedFix(job, before, reason, note, kind) {
59
59
  const { context, issue, log, worktree, branch } = job;
60
60
  const { ports } = context;
61
61
  // A retry or the revert after a failed check cleans this worktree, so edits left there would be lost.
62
- const saved = await ports.saveEdits(worktree, commitMessage(`fix: edits left by the ${kind === 'review' ? 'review' : 'check'} fixer`, issue));
62
+ const saved = await ports.commitAll(worktree, commitMessage(`fix: edits left by the ${kind === 'review' ? 'review' : 'check'} fixer`, issue), { hooks: false });
63
63
  const disputed = await ports.revision(worktree);
64
64
  if (disputed === before) {
65
65
  return disputedNote(job, reason, note, { stray: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "17.2.15",
3
+ "version": "17.4.0",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",
@@ -44,12 +44,12 @@
44
44
  "devDependencies": {
45
45
  "@types/node": "^26.6.6",
46
46
  "@types/ws": "^8.18.2",
47
- "oxfmt": "^0.78.0",
48
- "oxlint": "^1.93.0",
47
+ "oxfmt": "^0.79.0",
48
+ "oxlint": "^1.94.0",
49
49
  "typescript": "^7.0.2"
50
50
  },
51
51
  "dependencies": {
52
- "@anthropic-ai/claude-agent-sdk": "^0.3.327",
52
+ "@anthropic-ai/claude-agent-sdk": "^0.3.330",
53
53
  "ws": "^8.23.0"
54
54
  }
55
55
  }