next-issue 0.5.0 → 0.5.2
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/observe.mjs +1 -1
- package/dist/pipeline.mjs +28 -13
- package/package.json +1 -1
package/dist/observe.mjs
CHANGED
|
@@ -121,7 +121,7 @@ export function message(error) {
|
|
|
121
121
|
return error instanceof Error ? error.message : String(error);
|
|
122
122
|
}
|
|
123
123
|
function render(record) {
|
|
124
|
-
const time = String(record.ts).slice(
|
|
124
|
+
const time = new Date(String(record.ts)).toTimeString().slice(0, 8);
|
|
125
125
|
const issue = record.issue === undefined ? "" : ` #${record.issue}`;
|
|
126
126
|
const extras = Object.entries(record)
|
|
127
127
|
.filter(([key]) => !["ts", "runId", "kind", "issue"].includes(key))
|
package/dist/pipeline.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CODING, READ_ONLY, runAgent } from "./agents.mjs";
|
|
2
2
|
import { managedLabels } from "./config.mjs";
|
|
3
3
|
import { run } from "./exec.mjs";
|
|
4
|
-
import { addWorktree, branchName, commitAll, diff, push, removeWorktree, worktreePath, } from "./git.mjs";
|
|
4
|
+
import { addWorktree, branchName, commitAll, diff, hasWorktree, push, removeWorktree, worktreePath, } from "./git.mjs";
|
|
5
5
|
import { assignIssue, commentOnPr, createPr, failedCheckLogs, findPr, issueComments, markPrReady, setLabel, waitForChecks, } from "./github.mjs";
|
|
6
6
|
import { message } from "./observe.mjs";
|
|
7
7
|
import { fixPrompt, implementPrompt, parseCommitSubject, reviewPrompt } from "./prompts.mjs";
|
|
@@ -55,6 +55,7 @@ export async function processIssue(context, issue) {
|
|
|
55
55
|
catch (failure) {
|
|
56
56
|
log.event("hand-over.error", { error: message(failure) }, "quiet");
|
|
57
57
|
}
|
|
58
|
+
await cleanUp(context, log, issue.number);
|
|
58
59
|
return {
|
|
59
60
|
issue: issue.number,
|
|
60
61
|
outcome: "error",
|
|
@@ -79,15 +80,18 @@ async function work(context, issue, log, state) {
|
|
|
79
80
|
const worktree = await log.step("worktree", { branch }, () => addWorktree(repo, issue.number, context.base, config.remote));
|
|
80
81
|
const job = { context, issue, log, state, branch, worktree, comments };
|
|
81
82
|
const escalate = (reason) => handOver(context, log, issue.number, state, reason);
|
|
82
|
-
const finish = (outcome, reason) =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
const finish = async (outcome, reason) => {
|
|
84
|
+
await cleanUp(context, log, issue.number);
|
|
85
|
+
return {
|
|
86
|
+
issue: issue.number,
|
|
87
|
+
outcome,
|
|
88
|
+
reason,
|
|
89
|
+
pr: state.pr,
|
|
90
|
+
ciFixes: state.ciFixes,
|
|
91
|
+
reviewRounds: state.reviewRounds,
|
|
92
|
+
ms: Date.now() - started,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
91
95
|
if (config.setupCommand !== undefined) {
|
|
92
96
|
const setup = await log.step("setup", { cmd: config.setupCommand }, () => run("bash", ["-lc", config.setupCommand], { cwd: worktree }));
|
|
93
97
|
if (setup.code !== 0) {
|
|
@@ -182,9 +186,6 @@ async function work(context, issue, log, state) {
|
|
|
182
186
|
await setStatus(context, issue.number, state.pr, config.labels.done);
|
|
183
187
|
state.phase = "done";
|
|
184
188
|
await writeState(repo, state);
|
|
185
|
-
if (!(await removeWorktree(repo, issue.number))) {
|
|
186
|
-
log.event("worktree.kept", { path: worktreePath(repo, issue.number) }, "quiet");
|
|
187
|
-
}
|
|
188
189
|
return finish("done");
|
|
189
190
|
}
|
|
190
191
|
const mark = fingerprint(blocking);
|
|
@@ -220,6 +221,20 @@ async function fixRound(job, reason, detail, earlier = []) {
|
|
|
220
221
|
await push(worktree, context.config.remote, branch);
|
|
221
222
|
return true;
|
|
222
223
|
}
|
|
224
|
+
async function cleanUp(context, log, issue) {
|
|
225
|
+
const path = worktreePath(context.repo, issue);
|
|
226
|
+
try {
|
|
227
|
+
if (!(await hasWorktree(context.repo, path))) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (!(await removeWorktree(context.repo, issue))) {
|
|
231
|
+
log.event("worktree.kept", { path }, "quiet");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
log.event("worktree.error", { error: message(error) }, "quiet");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
223
238
|
async function handOver(context, log, issue, state, reason) {
|
|
224
239
|
log.event("hand-over", { reason }, "quiet");
|
|
225
240
|
state.phase = "needs-human";
|