next-issue 5.1.0 → 5.3.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/README.md CHANGED
@@ -66,8 +66,10 @@ the run handles one issue. For each issue:
66
66
  base when there is none. A fast-forward of the base that is not safe
67
67
  leaves the local base branch as it is and writes a `base.behind` event. A
68
68
  new branch then starts from the remote base.
69
- 4. Let the implementer agent do the work, then commit it. The branch is not
70
- pushed. When a git
69
+ 4. Let the implementer agent do the work, then commit it. For a behaviour
70
+ change, the implementer writes the test first and quotes its failing output
71
+ in its reply. The harness keeps that reply in the state file for the
72
+ reviewer. The branch is not pushed. When a git
71
73
  hook stops a commit, the agent that made the change gets the hook output,
72
74
  fixes it, and the harness commits again. A `commit:` line in the reply of
73
75
  the agent replaces the subject, so a hook that rejects the subject can pass.
@@ -80,6 +82,10 @@ the run handles one issue. For each issue:
80
82
  reviewer reads files and runs commands in the worktree, so it can prove a
81
83
  finding with the tests or the type check. The harness then throws away every
82
84
  change that the reviewer left, so no such change can reach a later commit.
85
+ The first reviewer also gets the reply of the implementer, and raises a
86
+ finding when a behaviour change has no failing run of its test. A later
87
+ reviewer gets the reply of the last review fixer instead, who quotes the
88
+ failing run of a test for a behaviour change.
83
89
  The reviewer ends its last message with its verdict as a json block: a
84
90
  summary and one entry per finding, each rated `blocking` or `minor`. A
85
91
  reply without a valid block hands the issue to a person. The findings are the only ground
@@ -405,6 +411,11 @@ run stopped. A state file that is not valid JSON, or that does not hold a valid
405
411
  state, gives the issue an `error` outcome that names the file, rather than a
406
412
  silent skip.
407
413
 
414
+ Every agent prompt holds `.next-issue/notes.md` when it exists, so lessons
415
+ such as test commands, tool quirks and deliberate behaviour carry over from one
416
+ issue to the next. The implementer and the fixer may add a short note to it, and
417
+ the prompt asks them to keep only what still holds. The reviewer only reads it.
418
+
408
419
  ## Retry an issue that waits for a person
409
420
 
410
421
  A hand-over marks the state file as handed over. To give the issue another try,
package/dist/fix.mjs CHANGED
@@ -19,6 +19,9 @@ export async function fixRound(job, reason, detail, earlier, kind) {
19
19
  const { ports } = context;
20
20
  const before = await ports.revision(worktree);
21
21
  const text = await runFixer(job, reason, detail, earlier, kind);
22
+ if (kind === 'review') {
23
+ job.state.fixerReply = text;
24
+ }
22
25
  const unrelated = parseUnrelated(text);
23
26
  if (unrelated !== undefined) {
24
27
  return disputedFix(job, before, reason, unrelated);
@@ -9,6 +9,7 @@ export async function implement(job) {
9
9
  const { context, issue, log, state, worktree, comments, reply } = job;
10
10
  const before = await context.ports.revision(worktree);
11
11
  const result = await log.step('implement', {}, () => runRole(job, 'implementer', implementPrompt(issue, comments, reply), CODING));
12
+ state.implementerReply = result.text;
12
13
  const subject = parseCommitSubject(result.text, fallbackTitle(issue));
13
14
  if (!(await commitWork(job, before, subject, 'implementer'))) {
14
15
  const escalated = await useEarlierCommit(job);
package/dist/job.mjs CHANGED
@@ -1,5 +1,9 @@
1
1
  import { managedLabels } from './config.mjs';
2
2
  import { minutesToMs } from './durations.mjs';
3
+ import { readTextIfPresent } from './files.mjs';
4
+ import { notesBlock } from './prompts.mjs';
5
+ import { notesPath } from './state.mjs';
6
+ import { paragraphs } from './text.mjs';
3
7
  export const ROUND_CONTINUE = { done: false };
4
8
  export const GATE_PASSED = { done: false, fixed: false };
5
9
  export const GATE_FIXED = { done: false, fixed: true };
@@ -9,12 +13,15 @@ export function gateRound(gate) {
9
13
  }
10
14
  return gate.fixed ? ROUND_CONTINUE : undefined;
11
15
  }
12
- export function runRole(job, role, prompt, profile) {
13
- const { config, ports } = job.context;
16
+ export async function runRole(job, role, prompt, profile) {
17
+ const { config, ports, repo } = job.context;
18
+ const path = notesPath(repo.root);
19
+ const notes = await readTextIfPresent(path);
20
+ const writable = role === 'implementer' || role === 'fixer';
14
21
  return ports.runAgent(job.log, {
15
22
  name: role,
16
23
  cwd: job.worktree,
17
- prompt,
24
+ prompt: paragraphs([notesBlock(path, notes, writable), prompt]),
18
25
  profile,
19
26
  model: config.models[role],
20
27
  timeoutMs: minutesToMs(config.agentTimeoutMinutes),
package/dist/prompts.mjs CHANGED
@@ -27,6 +27,7 @@ export function implementPrompt(issue, comments, reply = []) {
27
27
  '## Rules',
28
28
  'Read the repository conventions first. Keep the change minimal and focused on the issue.',
29
29
  'Add or update tests when the repository has a test suite.',
30
+ 'For a behaviour change, write the test first and run it before the change. Then quote its failing output in your final message.',
30
31
  COMMIT_RULES,
31
32
  ]);
32
33
  }
@@ -40,6 +41,20 @@ export function hookPrompt(issue, comments, role, output) {
40
41
  COMMIT_RULES,
41
42
  ]);
42
43
  }
44
+ export function notesBlock(path, notes, writable) {
45
+ const kept = notes?.trim() ?? '';
46
+ return paragraphs([
47
+ kept === ''
48
+ ? ''
49
+ : `## Shared notes\nEarlier agents left these notes for this repository.\n\n${kept}`,
50
+ writable
51
+ ? [
52
+ `When you learn something that the next issue needs, such as a test command, a tool quirk or deliberate behaviour, add a short note to ${path}.`,
53
+ 'Keep the file short: keep only what still holds, and remove a note that no longer holds.',
54
+ ].join('\n')
55
+ : '',
56
+ ]);
57
+ }
43
58
  export function capDiff(diff, maxChars) {
44
59
  return diff.length <= maxChars
45
60
  ? diff
@@ -47,7 +62,10 @@ export function capDiff(diff, maxChars) {
47
62
  }
48
63
  function reviewScope(earlier) {
49
64
  return earlier.length === 0
50
- ? 'Check correctness, scope, repository conventions and test cover.'
65
+ ? [
66
+ 'Check correctness, scope, repository conventions and test cover.',
67
+ 'Raise a finding when a behaviour change has no failing run of its test in the reply of the implementer.',
68
+ ].join('\n')
51
69
  : [
52
70
  'This is a later round. Judge two things only:',
53
71
  'whether the earlier findings below are now fixed, and whether the new commits broke something.',
@@ -57,7 +75,8 @@ function reviewScope(earlier) {
57
75
  `## Earlier findings\n${earlier.join('\n')}`,
58
76
  ].join('\n');
59
77
  }
60
- export function reviewPrompt(issue, comments, diff, earlier) {
78
+ export function reviewPrompt(issue, comments, diff, earlier, reply) {
79
+ const role = earlier.length === 0 ? 'implementer' : 'fixer';
61
80
  return [
62
81
  'You are the reviewer. Judge whether the diff solves the issue correctly.',
63
82
  issueBlock(issue, comments),
@@ -65,6 +84,7 @@ export function reviewPrompt(issue, comments, diff, earlier) {
65
84
  '```diff',
66
85
  diff,
67
86
  '```',
87
+ `## Reply of the ${role}\n${reply ?? '(no reply)'}`,
68
88
  '## Rules',
69
89
  'Read files and run commands to prove what you say: the tests, the type check or the linter.',
70
90
  'The worktree is ready to use. Do not change a file. Do not write with git or gh.',
@@ -93,7 +113,10 @@ const CONFLICT_RULE = [
93
113
  ].join('\n');
94
114
  const KIND_RULES = {
95
115
  checks: UNRELATED_RULE,
96
- review: DISPUTE_RULE,
116
+ review: [
117
+ DISPUTE_RULE,
118
+ 'For a behaviour change, run its test before the change and quote its failing output in your final message.',
119
+ ].join('\n'),
97
120
  conflict: CONFLICT_RULE,
98
121
  };
99
122
  function earlierBlock(earlier) {
package/dist/review.mjs CHANGED
@@ -61,7 +61,7 @@ async function runReviewer(job, earlier) {
61
61
  cut: full.length > config.diffMaxChars,
62
62
  };
63
63
  const before = await ports.revision(worktree);
64
- const review = await log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier), REVIEWING));
64
+ const review = await log.step('review', fields, () => runRole(job, 'reviewer', reviewPrompt(issue, comments, patch, earlier, earlier.length === 0 ? state.implementerReply : state.fixerReply), REVIEWING));
65
65
  if (await ports.discardChanges(worktree, before)) {
66
66
  log.event('review.discard', { round: state.reviewRounds }, 'quiet');
67
67
  }
package/dist/state.mjs CHANGED
@@ -7,6 +7,9 @@ export const STATE_DIR = '.next-issue';
7
7
  export function stateDir(root) {
8
8
  return join(root, STATE_DIR);
9
9
  }
10
+ export function notesPath(root) {
11
+ return join(stateDir(root), 'notes.md');
12
+ }
10
13
  export function runsDir(root) {
11
14
  return join(stateDir(root), 'runs');
12
15
  }
@@ -47,6 +50,8 @@ function isState(value) {
47
50
  PHASES.includes(value.phase) &&
48
51
  typeof value.branch === 'string' &&
49
52
  isOptional(value.title, 'string') &&
53
+ isOptional(value.implementerReply, 'string') &&
54
+ isOptional(value.fixerReply, 'string') &&
50
55
  typeof value.ciFixes === 'number' &&
51
56
  isOptional(value.commitFixes, 'number') &&
52
57
  (value.landed === undefined || isLanded(value.landed)) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",