next-issue 6.6.76 → 6.6.78

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
@@ -358,7 +358,9 @@ Every run has an id, `<timestamp>`, and writes these under `.next-issue/runs/`:
358
358
  - `<id>.jsonl` — one JSON object per event, with `ts`, `runId`, `kind`, and the
359
359
  `issue`, `role` or `round` in scope;
360
360
  - `<id>.summary.json` — token totals per agent role, event counts, and
361
- one report per issue with the outcome, the reason and the budgets used;
361
+ one report per issue with the outcome, the reason and the budgets used (in a
362
+ watch run, an issue skipped in several passes gets one report, and an issue
363
+ handled in more than one pass keeps a report for each);
362
364
  - `<id>/sessions/` — the full pi session of each agent call, with every
363
365
  message, tool call and tool result. The session id in a `usage` event is
364
366
  part of the file name.
@@ -721,7 +723,12 @@ affect another. The worker:
721
723
  - closes once no run is going when a client with a newer version connects, so
722
724
  that the client can start the newer worker;
723
725
  - stops every agent and command and exits on `SIGTERM` or `SIGINT`, and
724
- removes its socket and lock files.
726
+ removes its socket and lock files;
727
+ - keeps `.next-issue/worker.log`, where the extension writes the output of
728
+ the worker, within 10 MiB: when it starts and once a minute while it runs,
729
+ it cuts a log of more than 10 MiB to its newest 5 MiB, from the start of a
730
+ line. It skips the cut while a command that writes to the log runs. The
731
+ run logs under `.next-issue/runs/` hold the same events.
725
732
 
726
733
  Stop the worker of a repository with `next-issue stop` in that repository.
727
734
  Workers of other repositories carry on. This sends `SIGTERM` to the process in
package/dist/exec.mjs CHANGED
@@ -7,6 +7,10 @@ let observer;
7
7
  const DEFAULT_TIMEOUT_MS = minutesToMs(10);
8
8
  const defaultTimeout = new AsyncLocalStorage();
9
9
  const STDERR_TAIL = 200_000;
10
+ let shownCommands = 0;
11
+ export function showingCommands() {
12
+ return shownCommands > 0;
13
+ }
10
14
  export function setCommandObserver(next) {
11
15
  observer = next;
12
16
  }
@@ -66,9 +70,17 @@ export function run(command, args, options = {}) {
66
70
  const output = collect(child, options);
67
71
  const timer = deadline(limit, () => killTree(child));
68
72
  let done = false;
73
+ let shown = options.show === true;
74
+ if (shown) {
75
+ shownCommands += 1;
76
+ }
69
77
  const release = () => {
70
78
  timer.clear();
71
79
  unwatch();
80
+ if (shown) {
81
+ shown = false;
82
+ shownCommands -= 1;
83
+ }
72
84
  };
73
85
  const settle = (code) => {
74
86
  release();
package/dist/serve.mjs CHANGED
@@ -11,6 +11,7 @@ import { isNewer } from './protocol.mjs';
11
11
  import { listQuestions, questionSender, send } from './questions.mjs';
12
12
  import { runRepo } from './run.mjs';
13
13
  import { packageVersion } from './version.mjs';
14
+ import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
14
15
  import { checkSocketPath, workerPaths } from './worker-paths.mjs';
15
16
  import { active, endStatus, newRun, requestStop, runControls, runsMessage, startRefusal, stopPoint, } from './worker-run.mjs';
16
17
  import { broadcast, closer, fileId, listen, parseMessage, removeOwned, shutdown, } from './worker-server.mjs';
@@ -134,8 +135,9 @@ export async function startWorker(options) {
134
135
  idleTimer = setTimeout(closeWhenIdle, options.idleMs ?? IDLE_MS);
135
136
  return { closed, close, release: () => removeOwned(owned) };
136
137
  }
137
- export async function serve(root) {
138
- const paths = workerPaths(root);
138
+ export async function serve(root, logCheckMs = LOG_CHECK_MS) {
139
+ const { logPath, ...paths } = workerPaths(root);
140
+ const stopTrimming = keepLogTrimmed(logPath, logCheckMs);
139
141
  const worker = await startWorker({
140
142
  root,
141
143
  ...paths,
@@ -144,6 +146,7 @@ export async function serve(root) {
144
146
  questions: listQuestions,
145
147
  });
146
148
  if (worker === undefined) {
149
+ stopTrimming();
147
150
  process.stderr.write('next-issue: another worker is running\n');
148
151
  return 1;
149
152
  }
@@ -159,5 +162,6 @@ export async function serve(root) {
159
162
  process.on('SIGINT', onInterrupt);
160
163
  process.stderr.write(`next-issue: worker listening on ${paths.socketPath}\n`);
161
164
  await worker.closed;
165
+ stopTrimming();
162
166
  return 0;
163
167
  }
package/dist/watch.mjs CHANGED
@@ -76,7 +76,7 @@ async function watchPasses(args, failed, watch) {
76
76
  let step = 0;
77
77
  for (;;) {
78
78
  const pass = await runIssues({ once: false, max: limit === undefined ? undefined : limit - handled(reports) }, watch, new Set(failed));
79
- reports.push(...pass.reports);
79
+ addReports(reports, pass.reports);
80
80
  recordFailures(failed, pass.reports);
81
81
  if (handled(pass.reports) > 0) {
82
82
  await watch.passEnd(pass.reports);
@@ -95,6 +95,18 @@ async function watchPasses(args, failed, watch) {
95
95
  }
96
96
  }
97
97
  }
98
+ function addReports(reports, pass) {
99
+ for (const report of pass) {
100
+ const skip = reports.findIndex((entry) => entry.issue === report.issue && entry.outcome === 'skipped');
101
+ if (report.outcome !== 'skipped' && skip >= 0) {
102
+ reports[skip] = report;
103
+ }
104
+ else if (report.outcome !== 'skipped' ||
105
+ reports.every((entry) => entry.issue !== report.issue)) {
106
+ reports.push(report);
107
+ }
108
+ }
109
+ }
98
110
  function recordFailures(failed, reports) {
99
111
  for (const report of reports) {
100
112
  if (report.outcome === 'error') {
@@ -0,0 +1,36 @@
1
+ import { closeSync, fstatSync, ftruncateSync, openSync, readSync, writeSync } from 'node:fs';
2
+ import { showingCommands } from './exec.mjs';
3
+ export const LOG_LIMIT_BYTES = 10 * 1024 * 1024;
4
+ export const LOG_KEEP_BYTES = 5 * 1024 * 1024;
5
+ export const LOG_CHECK_MS = 60_000;
6
+ export function trimLog(path) {
7
+ if (showingCommands()) {
8
+ return;
9
+ }
10
+ try {
11
+ const file = openSync(path, 'r+');
12
+ try {
13
+ const size = fstatSync(file).size;
14
+ if (size <= LOG_LIMIT_BYTES) {
15
+ return;
16
+ }
17
+ const tail = Buffer.alloc(LOG_KEEP_BYTES);
18
+ const read = readSync(file, tail, 0, LOG_KEEP_BYTES, size - LOG_KEEP_BYTES);
19
+ const kept = tail.subarray(tail.indexOf(10) + 1, read);
20
+ writeSync(file, kept, 0, kept.length, 0);
21
+ ftruncateSync(file, kept.length);
22
+ }
23
+ finally {
24
+ closeSync(file);
25
+ }
26
+ }
27
+ catch {
28
+ return;
29
+ }
30
+ }
31
+ export function keepLogTrimmed(path, checkMs) {
32
+ trimLog(path);
33
+ const timer = setInterval(() => trimLog(path), checkMs);
34
+ timer.unref();
35
+ return () => clearInterval(timer);
36
+ }
@@ -5,6 +5,7 @@ export function workerPaths(root) {
5
5
  return {
6
6
  socketPath: join(dir, 'worker.sock'),
7
7
  lockPath: join(dir, 'worker.lock'),
8
+ logPath: join(dir, 'worker.log'),
8
9
  };
9
10
  }
10
11
  export function checkSocketPath(path, platform = process.platform) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.76",
3
+ "version": "6.6.78",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",