next-issue 8.3.1 → 8.3.3
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 +31 -12
- package/dist/agents.mjs +29 -4
- package/dist/config.mjs +1 -1
- package/dist/editors.mjs +25 -0
- package/dist/git-land.mjs +2 -2
- package/dist/github.mjs +47 -1
- package/dist/open-job.mjs +3 -0
- package/dist/pipeline.mjs +5 -0
- package/dist/ports.mjs +2 -1
- package/dist/prompts.mjs +1 -1
- package/dist/run.mjs +4 -4
- package/dist/serve.mjs +4 -1
- package/dist/worker-log.mjs +13 -1
- package/dist/worktree.mjs +3 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,8 +66,11 @@ the run handles one issue. For each issue:
|
|
|
66
66
|
state keeps the branch name that the state holds, and a worktree that
|
|
67
67
|
holds that branch already stays in use. A branch that exists on the
|
|
68
68
|
remote is the start, and a local branch that fell behind the remote is
|
|
69
|
-
fast-forwarded
|
|
70
|
-
|
|
69
|
+
fast-forwarded; a local branch that cannot be fast-forwarded stays as it
|
|
70
|
+
is and the harness writes a `branch.behind` event. The fetch prunes
|
|
71
|
+
remote branches, so a remote branch that was deleted does not count. A
|
|
72
|
+
local branch that the remote does not hold and that has no commits of
|
|
73
|
+
its own starts again from the remote base. An issue with no
|
|
71
74
|
saved state does not reuse a local `<n>` branch: it resets that branch,
|
|
72
75
|
and any worktree that holds it, to the remote branch, or to the remote
|
|
73
76
|
base when there is none. A worktree at `.worktrees/<n>` left on a
|
|
@@ -403,6 +406,8 @@ and comments the reason on the issue, when:
|
|
|
403
406
|
end. It halts this way even when the hand-over fails; the issue then ends
|
|
404
407
|
in error with both the reason and the hand-over error;
|
|
405
408
|
- the implementer asks questions about the issue (reason `questions`);
|
|
409
|
+
- a person without write access last changed the title or body of the issue
|
|
410
|
+
(reason `untrusted editor`, see [Safety](#safety));
|
|
406
411
|
- an agent does not finish in `agentTimeoutMinutes`;
|
|
407
412
|
- the setup command fails, or does not finish in `setupTimeoutMinutes`. On a
|
|
408
413
|
resume whose state holds a landed commit, or a push or revert that may have
|
|
@@ -544,9 +549,22 @@ admin access to the repository. The harness leaves out every other comment and
|
|
|
544
549
|
writes a `comment.skip` event with its author to the run log. If an access check
|
|
545
550
|
fails for a reason other than a 404, the issue stops with an error.
|
|
546
551
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
552
|
+
After the setup, and before any agent runs, the harness finds the last person to
|
|
553
|
+
change the body (the author when nobody edited it) and the last person to change
|
|
554
|
+
the title (the author when nobody renamed it). When either has no write or admin
|
|
555
|
+
access, no agent gets the issue: the harness hands it to a person with the
|
|
556
|
+
reason `untrusted editor`, and the comment names each such person. The agent
|
|
557
|
+
gets the title and body read in the same query as their editors, so an edit made
|
|
558
|
+
after the harness listed the issue is never sent unchecked. A writer who
|
|
559
|
+
checks the text and then changes the named title or body makes the issue go on
|
|
560
|
+
after the answer. This matters most on a public repository: anyone can open an
|
|
561
|
+
issue there, and its author can edit the body after a maintainer adds the ready
|
|
562
|
+
label, before the harness claims it. An issue opened by a person without write
|
|
563
|
+
access thus always waits for a writer to change it.
|
|
564
|
+
|
|
565
|
+
Thus a writer can still give an instruction to the agent, and the agent can
|
|
566
|
+
read other text, such as linked issues or files, by itself. Use the harness only
|
|
567
|
+
on a repository where you trust the writers, or run it in a container.
|
|
550
568
|
|
|
551
569
|
[ADR 0001](https://github.com/ravshansbox/next-issue/blob/main/docs/adr/0001-reviewer-isolation.md) records why the reviewer
|
|
552
570
|
keeps a full shell, and which other options were considered.
|
|
@@ -575,7 +593,7 @@ get the full summary object there instead, so the harness fits in a pipe. All
|
|
|
575
593
|
progress goes to standard error.
|
|
576
594
|
|
|
577
595
|
Recorded for each step: `claim`, `comments`, `reply`, `worktree`, `setup`,
|
|
578
|
-
`implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `main-checks`, `revert` and `hunt`, each with a
|
|
596
|
+
`editors`, `implement`, `review`, `fix`, `commit-fix`, `rebase`, `land`, `main-checks`, `revert` and `hunt`, each with a
|
|
579
597
|
`.start`, `.end` or `.error` event and a duration in `ms`. Every `git` and `gh`
|
|
580
598
|
command is recorded with its exit code and duration. A `tool` event holds the
|
|
581
599
|
tool name, and for a `bash` tool the command too. Each agent call adds a `usage`
|
|
@@ -708,7 +726,7 @@ because no pull request is opened.
|
|
|
708
726
|
| `checkIntervalSeconds` | `15` | The time between two check states, at most `2147483` |
|
|
709
727
|
| `checkGraceSeconds` | `60` | The time to wait for the first check to show, and for more checks after they all pass; the grace ends at the `checkTimeoutMinutes` limit, where checks that all pass, or no checks, still count as a pass |
|
|
710
728
|
| `checkTimeoutMinutes` | `60` | The limit for one check wait, at most `35791` |
|
|
711
|
-
| `agentTimeoutMinutes` | `30` | The limit for one agent call, at most `35791`
|
|
729
|
+
| `agentTimeoutMinutes` | `30` | The limit for one agent call, opening its session included, at most `35791` |
|
|
712
730
|
| `setupTimeoutMinutes` | `15` | The limit for the setup command, at most `35791` |
|
|
713
731
|
| `commandTimeoutMinutes` | `10` | The limit for one `git` or `gh` command, at most `35791` |
|
|
714
732
|
| `logMaxChars` | `20000` | The maximum length of the failed job logs, shared between the failed GitHub Actions runs (failed external checks are listed by name and link only) |
|
|
@@ -724,9 +742,9 @@ because no pull request is opened.
|
|
|
724
742
|
The hunter adds `labels.hunt` to each issue it files, so you can tell those
|
|
725
743
|
issues apart from your own and filter them.
|
|
726
744
|
|
|
727
|
-
The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman
|
|
728
|
-
and `
|
|
729
|
-
the run with an error that names both fields.
|
|
745
|
+
The names in `labels.ready`, `inProgress`, `inReview`, `done`, `needsHuman`,
|
|
746
|
+
`skip` and `hunt` must be distinct, also when case is ignored; two equal names
|
|
747
|
+
stop the run with an error that names both fields.
|
|
730
748
|
|
|
731
749
|
An empty `labels.ready` turns the ready requirement off. The harness then
|
|
732
750
|
claims every open issue that no other label holds back.
|
|
@@ -909,7 +927,7 @@ The watch stops:
|
|
|
909
927
|
|
|
910
928
|
## Hunt for bugs
|
|
911
929
|
|
|
912
|
-
With `next-issue start --hunt`, which turns on `--watch`, the harness runs a hunter agent at the same time as the issues. Before each hunt it reads the open issues with the `labels.ready` label and counts those that are ready to claim and are not running. An issue that failed earlier in the run does not count, since the watch does not try it again. It counts a blocked issue only when each of its open blockers is in the same repository and is running or ready to claim, since those blockers can land and close; a blocker that cannot move, such as one with `labels.needsHuman`, `labels.skip` or `labels.done`, one without `labels.ready`, or one in another repository, leaves it out. It looks only at the direct blockers, and reads them one issue at a time, so it runs one `gh` call at a time. It hunts only while that count is less than `huntCap`, 1 by default. Otherwise it waits and checks again, with the same back-off as the watch: 1, 2, 3, 5, 10, then 10 minutes. After a hunt that files an issue, it waits 1 minute before it checks the count again, even when the count is still less than `huntCap
|
|
930
|
+
With `next-issue start --hunt`, which turns on `--watch`, the harness runs a hunter agent at the same time as the issues. Before each hunt it reads the open issues with the `labels.ready` label and counts those that are ready to claim and are not running. An issue that failed earlier in the run does not count, since the watch does not try it again. It counts a blocked issue only when each of its open blockers is in the same repository and is running or ready to claim, since those blockers can land and close; a blocker that cannot move, such as one with `labels.needsHuman`, `labels.skip` or `labels.done`, one without `labels.ready`, or one in another repository, leaves it out. It looks only at the direct blockers, and reads them one issue at a time, so it runs one `gh` call at a time. It hunts only while that count is less than `huntCap`, 1 by default. Otherwise it waits and checks again, with the same back-off as the watch: 1, 2, 3, 5, 10, then 10 minutes. After a hunt that files an issue, it waits 1 minute before it checks the count again, even when the count is still less than `huntCap`. Each wait writes a `hunt.wait` event with the `minutes` to the run log. A hunt that files nothing backs off like a failed one. When the harness claims an issue, the hunter wakes: it ends its wait at once, or skips the wait after a hunt that is going, and checks the count again. A wake keeps the back-off where it was. The hunter:
|
|
913
931
|
|
|
914
932
|
- works in its own worktree at `.worktrees/hunt`, on a detached `HEAD` at the remote base branch, which the harness fetches and checks out before each hunt. A branch that the hunter checks out keeps its commits, and an issue that resumes never uses the hunt worktree as its own;
|
|
915
933
|
- follows `next-issue.hunt.md` in the repository root, or a short built-in prompt when the file is missing;
|
|
@@ -999,7 +1017,8 @@ affect another. The worker:
|
|
|
999
1017
|
an `error` and starts nothing. The setting lasts for the run only: a new run
|
|
1000
1018
|
takes it from its own flags. Only runs of the worker can switch; a
|
|
1001
1019
|
command-line run keeps what `--hunt` gave it. The progress of each run
|
|
1002
|
-
carries `hunting`, `true` while hunting is on
|
|
1020
|
+
carries `hunting`, `true` while hunting is on, and `watching`, `true` when
|
|
1021
|
+
the run watches for issues;
|
|
1003
1022
|
- asks a watching run to check for new issues now when a client sends
|
|
1004
1023
|
`{ "type": "refresh", "root": "<path>" }`. A run that waits between passes
|
|
1005
1024
|
starts a new pass at once, and its next wait starts again at 1 minute; a
|
package/dist/agents.mjs
CHANGED
|
@@ -26,15 +26,30 @@ export async function runAgent(recorder, request) {
|
|
|
26
26
|
process.env.GIT_OPTIONAL_LOCKS = '0';
|
|
27
27
|
process.argv[1] = PI_CLI;
|
|
28
28
|
log.event('agent.start', { model: request.model, timeoutMs: request.timeoutMs });
|
|
29
|
-
const session = await openSession(recorder, log, request, agentDir);
|
|
30
29
|
// pi drops an abort that comes before its run starts (during bindExtensions or the prompt
|
|
31
30
|
// preflight), so remember it and abort again once the run is active, before its first turn.
|
|
31
|
+
let opened;
|
|
32
32
|
let ended = false;
|
|
33
|
+
let expire = () => undefined;
|
|
34
|
+
const expired = new Promise((resolve) => {
|
|
35
|
+
expire = () => resolve(undefined);
|
|
36
|
+
});
|
|
33
37
|
const end = () => {
|
|
34
38
|
ended = true;
|
|
35
|
-
void
|
|
39
|
+
void opened?.abort();
|
|
36
40
|
};
|
|
37
|
-
const timer = deadline(request.timeoutMs,
|
|
41
|
+
const timer = deadline(request.timeoutMs, () => {
|
|
42
|
+
expire();
|
|
43
|
+
end();
|
|
44
|
+
});
|
|
45
|
+
const session = await openWithin(openSession(recorder, log, request, agentDir), expired).catch((error) => {
|
|
46
|
+
timer.clear();
|
|
47
|
+
throw error;
|
|
48
|
+
});
|
|
49
|
+
if (session === undefined) {
|
|
50
|
+
throw timeoutError(request);
|
|
51
|
+
}
|
|
52
|
+
opened = session;
|
|
38
53
|
const unsubscribe = session.subscribe((event) => observe(log, event));
|
|
39
54
|
const release = onStop(end);
|
|
40
55
|
try {
|
|
@@ -59,7 +74,7 @@ export async function runAgent(recorder, request) {
|
|
|
59
74
|
}
|
|
60
75
|
refuseWhenStopped();
|
|
61
76
|
if (timer.timedOut()) {
|
|
62
|
-
throw
|
|
77
|
+
throw timeoutError(request);
|
|
63
78
|
}
|
|
64
79
|
const failure = lastFailure(session);
|
|
65
80
|
if (failure !== undefined) {
|
|
@@ -74,6 +89,16 @@ export async function runAgent(recorder, request) {
|
|
|
74
89
|
session.dispose();
|
|
75
90
|
}
|
|
76
91
|
}
|
|
92
|
+
async function openWithin(opening, expired) {
|
|
93
|
+
const session = await Promise.race([opening, expired]);
|
|
94
|
+
if (session === undefined) {
|
|
95
|
+
opening.then((late) => late.dispose(), () => undefined);
|
|
96
|
+
}
|
|
97
|
+
return session;
|
|
98
|
+
}
|
|
99
|
+
function timeoutError(request) {
|
|
100
|
+
return new Error(`The ${request.name} agent did not finish in ${request.timeoutMs} ms.`);
|
|
101
|
+
}
|
|
77
102
|
function lastFailure(session) {
|
|
78
103
|
const last = session.messages.findLast((message) => message.role === 'assistant');
|
|
79
104
|
if (last === undefined || !('stopReason' in last) || last.stopReason !== 'error') {
|
package/dist/config.mjs
CHANGED
|
@@ -190,7 +190,7 @@ function parseLabels(value, defaultLabels) {
|
|
|
190
190
|
function rejectSameLabels(labels) {
|
|
191
191
|
const seen = new Map();
|
|
192
192
|
for (const name of LABEL_NAMES) {
|
|
193
|
-
if (
|
|
193
|
+
if (labels[name] === '') {
|
|
194
194
|
continue;
|
|
195
195
|
}
|
|
196
196
|
const key = labels[name].toLowerCase();
|
package/dist/editors.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { escalateAndFinish } from './handover.mjs';
|
|
2
|
+
/** Hands the issue over when a person without write access last changed its title or body; otherwise gives the job the title and body checked. */
|
|
3
|
+
export async function untrustedEditors(job) {
|
|
4
|
+
const { context, issue, log } = job;
|
|
5
|
+
const { repo, ports } = context;
|
|
6
|
+
const { title, body, editors } = await log.step('editors', {}, () => ports.issueEditors(repo, issue.number));
|
|
7
|
+
const untrusted = [];
|
|
8
|
+
for (const [part, login] of [
|
|
9
|
+
['title', editors.title],
|
|
10
|
+
['body', editors.body],
|
|
11
|
+
]) {
|
|
12
|
+
if (!(await ports.canWrite(repo, login))) {
|
|
13
|
+
untrusted.push({ part, login });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (untrusted.length === 0) {
|
|
17
|
+
job.issue = { ...issue, title, body };
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const changed = untrusted
|
|
21
|
+
.map(({ part, login }) => `the ${part} was last changed by @${login}, who has no write access to the repository`)
|
|
22
|
+
.join('; ');
|
|
23
|
+
const parts = untrusted.map(({ part }) => `the ${part}`).join(' and ');
|
|
24
|
+
return escalateAndFinish(job, `The worker did not send the issue to an agent: ${changed}. A person with write access can check the issue, then change ${parts} to go on.`, 'untrusted editor');
|
|
25
|
+
}
|
package/dist/git-land.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { evenWhenStopped } from './children.mjs';
|
|
2
|
-
import { fetchBase, git, isAncestor, isLanded, isOnBase, oneFetchAtATime, revision, succeeds, } from './git.mjs';
|
|
2
|
+
import { fetchBase, git, isAncestor, isDirty, isLanded, isOnBase, oneFetchAtATime, revision, succeeds, } from './git.mjs';
|
|
3
3
|
import { commitEverything } from './git-commit.mjs';
|
|
4
4
|
export const PUSH_TRIES = 3;
|
|
5
5
|
export async function squashOnto(cwd, target, message) {
|
|
6
|
-
if (await succeeds(cwd, ['diff', '--quiet', target])) {
|
|
6
|
+
if ((await succeeds(cwd, ['diff', '--quiet', target])) && !(await isDirty(cwd))) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
const head = await revision(cwd);
|
package/dist/github.mjs
CHANGED
|
@@ -16,7 +16,9 @@ function toIssue(item) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function labelFilter(labels) {
|
|
19
|
-
return labels.length === 0
|
|
19
|
+
return labels.length === 0
|
|
20
|
+
? ''
|
|
21
|
+
: ` label:${labels.map((label) => `"${label.replace(/[\\"]/g, '\\$&')}"`).join(',')}`;
|
|
20
22
|
}
|
|
21
23
|
export async function openIssues(repo, limit, labels) {
|
|
22
24
|
const parsed = await ghJson(repo, [
|
|
@@ -66,6 +68,50 @@ export async function canWrite(repo, login) {
|
|
|
66
68
|
throw error;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
71
|
+
const EDITORS_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
72
|
+
repository(owner: $owner, name: $name) {
|
|
73
|
+
issue(number: $number) {
|
|
74
|
+
title
|
|
75
|
+
body
|
|
76
|
+
author { login }
|
|
77
|
+
editor { login }
|
|
78
|
+
lastEditedAt
|
|
79
|
+
timelineItems(itemTypes: [RENAMED_TITLE_EVENT], last: 1) {
|
|
80
|
+
nodes { ... on RenamedTitleEvent { actor { login } } }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}`;
|
|
85
|
+
const GHOST = 'ghost';
|
|
86
|
+
/** The title and body of an issue with the last people to change them; the author when never changed, `ghost` for a deleted account. */
|
|
87
|
+
export async function issueEditors(repo, issue) {
|
|
88
|
+
const raw = await repeatable(repo, [
|
|
89
|
+
'api',
|
|
90
|
+
'graphql',
|
|
91
|
+
...hostname(repo),
|
|
92
|
+
'-f',
|
|
93
|
+
`query=${EDITORS_QUERY}`,
|
|
94
|
+
'-f',
|
|
95
|
+
`owner=${repo.owner}`,
|
|
96
|
+
'-f',
|
|
97
|
+
`name=${repo.name}`,
|
|
98
|
+
'-F',
|
|
99
|
+
`number=${issue}`,
|
|
100
|
+
'--jq',
|
|
101
|
+
'.data.repository.issue',
|
|
102
|
+
]);
|
|
103
|
+
const parsed = parseJson(raw, () => `gh gave editors of #${issue} that are not valid JSON: ${raw}`);
|
|
104
|
+
const author = parsed.author?.login ?? GHOST;
|
|
105
|
+
const renamed = parsed.timelineItems.nodes[0];
|
|
106
|
+
return {
|
|
107
|
+
title: parsed.title,
|
|
108
|
+
body: parsed.body,
|
|
109
|
+
editors: {
|
|
110
|
+
body: parsed.lastEditedAt === null ? author : (parsed.editor?.login ?? GHOST),
|
|
111
|
+
title: renamed === undefined ? author : (renamed.actor?.login ?? GHOST),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
69
115
|
const REPOSITORY_SLUG = '(.repository_url | split("/") | .[-2:] | join("/"))';
|
|
70
116
|
export async function openBlockers(repo, issue) {
|
|
71
117
|
const raw = await ghApi(repo, `issues/${issue}/dependencies/blocked_by`, `.[] | select(.state == "open") | ${REPOSITORY_SLUG} + "#" + (.number | tostring)`, { paginate: true });
|
package/dist/open-job.mjs
CHANGED
|
@@ -42,5 +42,8 @@ async function openWorktree(context, issue, log, branch, start) {
|
|
|
42
42
|
if (!added.baseUpdated) {
|
|
43
43
|
log.event('base.behind', { base: context.base }, 'quiet');
|
|
44
44
|
}
|
|
45
|
+
if (!added.branchUpdated) {
|
|
46
|
+
log.event('branch.behind', { branch }, 'quiet');
|
|
47
|
+
}
|
|
45
48
|
return added.path;
|
|
46
49
|
}
|
package/dist/pipeline.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { untrustedEditors } from './editors.mjs';
|
|
1
2
|
import { enterReview, settleSquash } from './enter-review.mjs';
|
|
2
3
|
import { branchName } from './git.mjs';
|
|
3
4
|
import { runStopped } from './children.mjs';
|
|
@@ -78,6 +79,10 @@ async function work(context, issue, log, state, start, handedOver, pending) {
|
|
|
78
79
|
if (setup.done) {
|
|
79
80
|
return setup.report;
|
|
80
81
|
}
|
|
82
|
+
const untrusted = await untrustedEditors(job);
|
|
83
|
+
if (untrusted !== undefined) {
|
|
84
|
+
return untrusted.report;
|
|
85
|
+
}
|
|
81
86
|
if (state.phase === 'claimed') {
|
|
82
87
|
const implemented = await implement(job);
|
|
83
88
|
if (implemented.done) {
|
package/dist/ports.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { commitAll } from './git-commit.mjs';
|
|
|
5
5
|
import { pushToBase, reapplyRevert, revertOnBase, squashOnto } from './git-land.mjs';
|
|
6
6
|
import { abortMerge, commitMerge, startMerge } from './git-merge.mjs';
|
|
7
7
|
import { changedFiles, deleteBranch, diff, discardChanges, disputeBranches, isDirty, isLanded, isOnBase, latestSubject, push, resetToBase, revision, saveEdits, saveSetupOutput, setAside, } from './git.mjs';
|
|
8
|
-
import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, openBlockers, openIssues, reopenIssue, repositorySlug, threadComments, viewIssue, } from './github.mjs';
|
|
8
|
+
import { canWrite, closeIssue, commentOnIssue, editIssueBody, issueComments, issueEditors, 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,6 +42,7 @@ export const PORTS = {
|
|
|
42
42
|
isLanded,
|
|
43
43
|
isOnBase,
|
|
44
44
|
issueComments,
|
|
45
|
+
issueEditors,
|
|
45
46
|
latestSubject,
|
|
46
47
|
openBlockers,
|
|
47
48
|
openIssues,
|
package/dist/prompts.mjs
CHANGED
|
@@ -206,7 +206,7 @@ export function huntPrompt(instructions, ready, source, count, repository) {
|
|
|
206
206
|
const kept = instructions?.trim() ?? '';
|
|
207
207
|
const label = [ready, source]
|
|
208
208
|
.filter((name) => name !== '')
|
|
209
|
-
.map((name) => ` --label "${name}"`)
|
|
209
|
+
.map((name) => ` --label "${name.replace(/[\\"$`]/g, '\\$&')}"`)
|
|
210
210
|
.join('');
|
|
211
211
|
return paragraphs([
|
|
212
212
|
`You are the hunter. Find the most serious problems in this repository and file up to ${issues} for them.`,
|
package/dist/run.mjs
CHANGED
|
@@ -48,11 +48,11 @@ async function runWithConfig(root, args, controls, config) {
|
|
|
48
48
|
await checkGitVersion();
|
|
49
49
|
const repo = await detectRepo(root, config.remote);
|
|
50
50
|
const recorder = await Recorder.create(repo.root, args.level, controls.onEvent);
|
|
51
|
-
const pruned = await pruneRuns(repo.root, config.keepRunDays);
|
|
52
|
-
if (pruned > 0) {
|
|
53
|
-
recorder.event('runs.pruned', { files: pruned, keepDays: config.keepRunDays }, 'verbose');
|
|
54
|
-
}
|
|
55
51
|
try {
|
|
52
|
+
const pruned = await pruneRuns(repo.root, config.keepRunDays);
|
|
53
|
+
if (pruned > 0) {
|
|
54
|
+
recorder.event('runs.pruned', { files: pruned, keepDays: config.keepRunDays }, 'verbose');
|
|
55
|
+
}
|
|
56
56
|
return await recordCommands(recorder, () => handle(args, config, repo, recorder, controls));
|
|
57
57
|
}
|
|
58
58
|
finally {
|
package/dist/serve.mjs
CHANGED
|
@@ -64,7 +64,7 @@ export async function startWorker(options) {
|
|
|
64
64
|
send(socket, { type: 'error', root, message: message(error) });
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
const run = newRun(startProgress(args.hunt), args.watch);
|
|
67
|
+
const run = newRun({ ...startProgress(args.hunt), watching: args.watch }, args.watch);
|
|
68
68
|
runs.set(root, run);
|
|
69
69
|
const update = (next) => {
|
|
70
70
|
run.progress = next;
|
|
@@ -96,6 +96,9 @@ export async function startWorker(options) {
|
|
|
96
96
|
};
|
|
97
97
|
const receive = (socket, value) => {
|
|
98
98
|
if (value.type === 'hello') {
|
|
99
|
+
if (typeof value.version !== 'string') {
|
|
100
|
+
throw new Error('a hello message needs its version as a string');
|
|
101
|
+
}
|
|
99
102
|
if (isNewer(value.version, options.version)) {
|
|
100
103
|
restart = true;
|
|
101
104
|
closeWhenIdle();
|
package/dist/worker-log.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export function trimLog(path) {
|
|
|
18
18
|
const read = readSync(file, tail, 0, LOG_KEEP_BYTES, size - LOG_KEEP_BYTES);
|
|
19
19
|
const kept = tail.subarray(tail.indexOf(10) + 1, read);
|
|
20
20
|
writeSync(file, kept, 0, kept.length, 0);
|
|
21
|
-
ftruncateSync(file, kept.length);
|
|
21
|
+
ftruncateSync(file, kept.length + copyAppended(file, size, kept.length));
|
|
22
22
|
}
|
|
23
23
|
finally {
|
|
24
24
|
closeSync(file);
|
|
@@ -28,6 +28,18 @@ export function trimLog(path) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
function copyAppended(file, from, to) {
|
|
32
|
+
let read = from;
|
|
33
|
+
let written = to;
|
|
34
|
+
for (let size = fstatSync(file).size; read < size; size = fstatSync(file).size) {
|
|
35
|
+
const appended = Buffer.alloc(size - read);
|
|
36
|
+
const length = readSync(file, appended, 0, appended.length, read);
|
|
37
|
+
writeSync(file, appended, 0, length, written);
|
|
38
|
+
read += length;
|
|
39
|
+
written += length;
|
|
40
|
+
}
|
|
41
|
+
return written - to;
|
|
42
|
+
}
|
|
31
43
|
export function keepLogTrimmed(path, checkMs) {
|
|
32
44
|
trimLog(path);
|
|
33
45
|
const timer = setInterval(() => trimLog(path), checkMs);
|
package/dist/worktree.mjs
CHANGED
|
@@ -31,10 +31,8 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
31
31
|
else if (start) {
|
|
32
32
|
await discardChanges(path, target);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return { path, baseUpdated };
|
|
34
|
+
const branchUpdated = !pushed || (await succeeds(path, ['merge', '--ff-only', upstream]));
|
|
35
|
+
return { path, baseUpdated, branchUpdated };
|
|
38
36
|
}
|
|
39
37
|
async function keepDetachedEdits(path, branch) {
|
|
40
38
|
if (!existsSync(join(path, '.git')) ||
|
|
@@ -55,7 +53,7 @@ async function hasBranch(repo, name, ...flags) {
|
|
|
55
53
|
return list.length > 0;
|
|
56
54
|
}
|
|
57
55
|
export async function fastForwardBase(repo, base, remote) {
|
|
58
|
-
await gitFetch(repo.root, [remote]);
|
|
56
|
+
await gitFetch(repo.root, ['--prune', remote]);
|
|
59
57
|
return updateBase(repo, base, remote);
|
|
60
58
|
}
|
|
61
59
|
async function updateBase(repo, base, remote) {
|