next-issue 9.6.0 → 9.7.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
@@ -993,7 +993,7 @@ affect another. The worker:
993
993
  with `another worker is running`. A worker that stops removes the lock file
994
994
  only while it still holds the lock, and the socket file only while it is
995
995
  still the socket it bound;
996
- - refuses a `start`, `stop`, `watch`, `hunt` or `questions` message whose `root` is not
996
+ - refuses a `start`, `stop`, `watch`, `hunt`, `questions` or `upcoming` message whose `root` is not
997
997
  the exact path of its repository with an `error` message, and starts or
998
998
  stops nothing;
999
999
  - runs at most one run at a time. A client starts it with
@@ -1024,6 +1024,14 @@ affect another. The worker:
1024
1024
  a newer one. When the client adds an `"id"` to its message, the list that
1025
1025
  answers it carries the same `id` and is read after the message arrived. When the list cannot be read, the client gets
1026
1026
  `{ "type": "questions-error", "root": "<path>", "message": "<text>" }`;
1027
+ - answers `{ "type": "upcoming", "root": "<path>" }` with
1028
+ `{ "type": "upcoming", "root": "<path>", "claimable": [...], "blocked": [...] }`:
1029
+ the open issues with the `ready` label that a run would claim, oldest first,
1030
+ each with its `issue` number and `title`, without issues that have saved
1031
+ state or a label that stops a claim. An issue blocked by open issues is in
1032
+ `blocked` with their references in `blockers`. When the list cannot be read,
1033
+ the client gets
1034
+ `{ "type": "upcoming-error", "root": "<path>", "message": "<text>" }`;
1027
1035
  - stops a run when a client sends
1028
1036
  `{ "type": "stop", "root": "<path>", "after": "issue" | "round" | "now" }`.
1029
1037
  With no `after`, it stops after `issue`. `issue` works like a first
package/dist/serve.mjs CHANGED
@@ -11,6 +11,7 @@ import { startProgress } from './progress.mjs';
11
11
  import { isNewer } from './protocol.mjs';
12
12
  import { listQuestions, questionSender, send } from './questions.mjs';
13
13
  import { runRepo } from './run.mjs';
14
+ import { listUpcoming, sendUpcoming } from './upcoming.mjs';
14
15
  import { packageVersion } from './version.mjs';
15
16
  import { keepLogTrimmed, LOG_CHECK_MS } from './worker-log.mjs';
16
17
  import { checkSocketPath, workerPaths } from './worker-paths.mjs';
@@ -141,6 +142,9 @@ export async function startWorker(options) {
141
142
  else if (value.type === 'questions') {
142
143
  void sendQuestions(value.root, () => [socket], value.id);
143
144
  }
145
+ else if (value.type === 'upcoming') {
146
+ void sendUpcoming(options.upcoming ?? listUpcoming, socket, value.root);
147
+ }
144
148
  };
145
149
  sockets.on('connection', (socket) => {
146
150
  send(socket, { type: 'hello', version: options.version });
@@ -0,0 +1,40 @@
1
+ import { loadConfig } from './config.mjs';
2
+ import { message } from './errors.mjs';
3
+ import { detectRepo } from './git.mjs';
4
+ import { PORTS } from './ports.mjs';
5
+ import { send } from './questions.mjs';
6
+ import { skipReason } from './skip.mjs';
7
+ import { savedIssues } from './state.mjs';
8
+ /** The fresh issues the worker would claim, oldest first as it claims them; issues with saved state resume instead. */
9
+ export async function upcomingIssues(repo, config, ports) {
10
+ const { ready } = config.labels;
11
+ const issues = await ports.openIssues(repo, config.issueLimit, ready.length === 0 ? [] : [ready]);
12
+ const saved = new Set(await savedIssues(repo));
13
+ const upcoming = { claimable: [], blocked: [] };
14
+ for (const issue of issues) {
15
+ if (saved.has(issue.number) || skipReason(issue, config, false) !== undefined) {
16
+ continue;
17
+ }
18
+ const blockers = await ports.openBlockers(repo, issue.number);
19
+ const item = { issue: issue.number, title: issue.title };
20
+ if (blockers.length > 0) {
21
+ upcoming.blocked.push({ ...item, blockers });
22
+ }
23
+ else {
24
+ upcoming.claimable.push(item);
25
+ }
26
+ }
27
+ return upcoming;
28
+ }
29
+ export async function listUpcoming(root) {
30
+ const config = await loadConfig(root);
31
+ return upcomingIssues(await detectRepo(root, config.remote), config, PORTS);
32
+ }
33
+ export async function sendUpcoming(list, socket, root) {
34
+ try {
35
+ send(socket, { type: 'upcoming', root, ...(await list(root)) });
36
+ }
37
+ catch (error) {
38
+ send(socket, { type: 'upcoming-error', root, message: message(error) });
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "9.6.0",
3
+ "version": "9.7.0",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",