@operad-io/dev 0.1.1 → 0.2.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 +1 -1
- package/dev.schema.json +41 -28
- package/package.json +9 -6
- package/skills/setup/SKILL.md +57 -0
- package/src/access-grants.ts +59 -0
- package/src/actions.ts +70 -16
- package/src/announce.ts +128 -16
- package/src/chat.ts +512 -36
- package/src/check-host.ts +111 -0
- package/src/check-load.ts +67 -0
- package/src/check.ts +17 -12
- package/src/clock.ts +29 -0
- package/src/commands.ts +103 -34
- package/src/create-actions.ts +210 -0
- package/src/flaky.ts +45 -29
- package/src/flow-compiler.ts +155 -68
- package/src/followups.ts +20 -22
- package/src/gate.ts +192 -73
- package/src/git.ts +47 -0
- package/src/index.ts +46 -6
- package/src/integrate.ts +82 -42
- package/src/integration-queue.ts +23 -10
- package/src/lock.ts +101 -5
- package/src/mainclone.ts +3 -3
- package/src/model-error.ts +70 -0
- package/src/model.ts +48 -35
- package/src/notcode.ts +51 -15
- package/src/places.ts +2 -2
- package/src/prepare.ts +7 -2
- package/src/project-flows.ts +135 -4
- package/src/project-settings.ts +81 -0
- package/src/register-requests.ts +87 -0
- package/src/repository-key.ts +4 -0
- package/src/rerun.ts +23 -7
- package/src/retry.ts +2 -12
- package/src/rework.ts +8 -0
- package/src/schedule.ts +317 -86
- package/src/service.ts +116 -152
- package/src/settings.ts +305 -60
- package/src/standing.ts +23 -6
- package/src/step-edge.ts +22 -0
- package/src/steps.ts +469 -123
- package/src/throughput.ts +4 -21
- package/src/timeouts.ts +10 -2
- package/src/views.ts +147 -81
- package/src/waits.ts +59 -0
package/src/announce.ts
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
import type { PluginStepResult, StepContext } from "@operad-io/engine";
|
|
10
10
|
import { messageOf } from "@operad-io/engine";
|
|
11
|
-
import type { TaskData } from "./model.ts";
|
|
11
|
+
import type { ReviewFinding, TaskData } from "./model.ts";
|
|
12
|
+
import { severityRank } from "./rework.ts";
|
|
13
|
+
import { edgeParamsOf, type EdgeParams } from "./step-edge.ts";
|
|
14
|
+
import { WAIT_ACTIONS, waitChoiceInfo, type WaitAction } from "./waits.ts";
|
|
12
15
|
import {
|
|
13
16
|
cancelledStep,
|
|
14
17
|
claimAllows,
|
|
@@ -21,10 +24,7 @@ import {
|
|
|
21
24
|
export const WAITING_EVENT = "dev.waiting";
|
|
22
25
|
|
|
23
26
|
/** The edge a task took into the wait, as the flow names it in its params. */
|
|
24
|
-
export
|
|
25
|
-
readonly from: string;
|
|
26
|
-
readonly result: string;
|
|
27
|
-
}
|
|
27
|
+
export type AnnounceParams = EdgeParams;
|
|
28
28
|
|
|
29
29
|
/** Why a task waits: the short reason for the key, and what to add to the line. */
|
|
30
30
|
export interface WaitingReason {
|
|
@@ -34,16 +34,6 @@ export interface WaitingReason {
|
|
|
34
34
|
readonly step?: string | undefined;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function paramsOf(params: unknown): AnnounceParams {
|
|
38
|
-
const record =
|
|
39
|
-
typeof params === "object" && params !== null && !Array.isArray(params)
|
|
40
|
-
? (params as Record<string, unknown>)
|
|
41
|
-
: {};
|
|
42
|
-
const from = typeof record.from === "string" ? record.from : "";
|
|
43
|
-
const result = typeof record.result === "string" ? record.result : "";
|
|
44
|
-
return { from, result };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
37
|
/** The step a repair run says stopped, from the line the worktree step wrote. */
|
|
48
38
|
function stoppedStep(task: TaskData, fallback: string): string {
|
|
49
39
|
const lines = task.brief.replace(/\r\n/g, "\n").split("\n");
|
|
@@ -145,6 +135,104 @@ export function waitingReason(
|
|
|
145
135
|
}
|
|
146
136
|
}
|
|
147
137
|
|
|
138
|
+
/** The most serious finding of the review that is at or above the fix level. */
|
|
139
|
+
function highestFinding(
|
|
140
|
+
task: TaskData,
|
|
141
|
+
fixLevel: string | undefined,
|
|
142
|
+
): ReviewFinding | undefined {
|
|
143
|
+
const findings = (task.attempt?.review?.findings ?? []).filter(
|
|
144
|
+
(finding) =>
|
|
145
|
+
finding.preExisting !== true &&
|
|
146
|
+
finding.pre_existing !== true &&
|
|
147
|
+
(fixLevel === undefined ||
|
|
148
|
+
severityRank(finding.severity) >= severityRank(fixLevel)),
|
|
149
|
+
);
|
|
150
|
+
return [...findings].sort(
|
|
151
|
+
(left, right) =>
|
|
152
|
+
severityRank(right.severity) - severityRank(left.severity) ||
|
|
153
|
+
left.file.localeCompare(right.file) ||
|
|
154
|
+
left.line - right.line,
|
|
155
|
+
)[0];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function findingSentence(finding: ReviewFinding): string {
|
|
159
|
+
const trigger = finding.trigger.trim();
|
|
160
|
+
return `${finding.severity} finding at ${finding.file}:${finding.line}: ${finding.summary}${
|
|
161
|
+
trigger.length === 0 ? "" : ` (${trigger})`
|
|
162
|
+
}`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Why the task waits, in one or two plain sentences. It reads the task's own
|
|
167
|
+
* record for the review's highest finding, the failed check's command and the
|
|
168
|
+
* integration's reason; the choice list is never part of a prompt.
|
|
169
|
+
*/
|
|
170
|
+
export function waitingPrompt(
|
|
171
|
+
found: WaitingReason,
|
|
172
|
+
task: TaskData,
|
|
173
|
+
fixLevel: string | undefined,
|
|
174
|
+
): string {
|
|
175
|
+
const attempt = task.attempt;
|
|
176
|
+
const finding = highestFinding(task, fixLevel);
|
|
177
|
+
if (found.reason === "ready to merge") {
|
|
178
|
+
return "The checks and the review passed; the task is ready to merge.";
|
|
179
|
+
}
|
|
180
|
+
if (found.reason === "work did nothing") {
|
|
181
|
+
return "The worker changed nothing.";
|
|
182
|
+
}
|
|
183
|
+
if (found.reason === "work timed out") {
|
|
184
|
+
return `The worker timed out.${found.detail === undefined ? "" : ` ${found.detail}.`}`;
|
|
185
|
+
}
|
|
186
|
+
if (found.reason === "work failed") {
|
|
187
|
+
return `The worker failed${found.detail === undefined ? "" : `: ${found.detail}`}.`;
|
|
188
|
+
}
|
|
189
|
+
if (found.reason === "conflict") {
|
|
190
|
+
return "The worker's changes conflict with main.";
|
|
191
|
+
}
|
|
192
|
+
if (found.reason === "review timed out twice") {
|
|
193
|
+
return "review timed out twice";
|
|
194
|
+
}
|
|
195
|
+
if (found.reason === "review did not finish") {
|
|
196
|
+
return `review did not finish${found.detail === undefined ? "" : ` (${found.detail})`}`;
|
|
197
|
+
}
|
|
198
|
+
if (found.reason === "review failed twice in a row") {
|
|
199
|
+
return `The review failed twice in a row.${
|
|
200
|
+
finding === undefined ? "" : ` Highest finding: ${findingSentence(finding)}.`
|
|
201
|
+
}`;
|
|
202
|
+
}
|
|
203
|
+
if (found.reason === "review findings" || found.reason === "rework limit") {
|
|
204
|
+
const source = attempt?.rework?.source;
|
|
205
|
+
if (source === "review" || (source === undefined && attempt?.review !== undefined)) {
|
|
206
|
+
return finding === undefined
|
|
207
|
+
? "The review failed."
|
|
208
|
+
: `The review failed: ${findingSentence(finding)}.`;
|
|
209
|
+
}
|
|
210
|
+
const command = attempt?.verify?.command;
|
|
211
|
+
return typeof command !== "string" || command.length === 0
|
|
212
|
+
? `The check failed${attempt?.verify?.message === undefined ? "." : `: ${attempt.verify.message}.`}`
|
|
213
|
+
: `The check failed: \`${command}\`.`;
|
|
214
|
+
}
|
|
215
|
+
if (found.reason === "gate failed") {
|
|
216
|
+
const command = attempt?.verify?.command;
|
|
217
|
+
return typeof command !== "string" || command.length === 0
|
|
218
|
+
? `The check failed${attempt?.verify?.message === undefined ? "." : `: ${attempt.verify.message}.`}`
|
|
219
|
+
: `The check failed: \`${command}\`.`;
|
|
220
|
+
}
|
|
221
|
+
if (found.reason === "merge refused") {
|
|
222
|
+
return `The merge failed${found.detail === undefined ? "" : `: ${found.detail}`}.`;
|
|
223
|
+
}
|
|
224
|
+
if (found.reason === "no verified commit") {
|
|
225
|
+
return "The task has no verified commit to merge.";
|
|
226
|
+
}
|
|
227
|
+
if (found.reason === "dependency cancelled") {
|
|
228
|
+
return "A task this one waits for was cancelled.";
|
|
229
|
+
}
|
|
230
|
+
if (found.reason.startsWith("run stopped during ")) {
|
|
231
|
+
return `The run stopped during ${found.reason.slice("run stopped during ".length)}.`;
|
|
232
|
+
}
|
|
233
|
+
return `${found.reason.charAt(0).toUpperCase()}${found.reason.slice(1)}.`;
|
|
234
|
+
}
|
|
235
|
+
|
|
148
236
|
/** One line a person reads: the task, why it waits, and the detail if any. */
|
|
149
237
|
export function waitingSummary(taskId: string, found: WaitingReason): string {
|
|
150
238
|
const detail = found.detail === undefined ? "" : ` (${found.detail})`;
|
|
@@ -158,7 +246,7 @@ export async function runAnnounce(
|
|
|
158
246
|
): Promise<PluginStepResult> {
|
|
159
247
|
const context = await taskContext(ctx);
|
|
160
248
|
if (!claimAllows(ctx, context.task)) return cancelledStep();
|
|
161
|
-
const edge =
|
|
249
|
+
const edge = edgeParamsOf(stepParams);
|
|
162
250
|
const path = context.task.attempt?.worktree;
|
|
163
251
|
const conflicted =
|
|
164
252
|
edge.from === "work" &&
|
|
@@ -213,6 +301,30 @@ export async function runAnnounce(
|
|
|
213
301
|
await ctx.logger.write(`could not mark the task waiting: ${messageOf(error)}`);
|
|
214
302
|
}
|
|
215
303
|
}
|
|
304
|
+
// The wait that follows asks the person. It carries this task's own reason
|
|
305
|
+
// and choice information; asking with no grace hands the question over to
|
|
306
|
+
// the wait step at once, keeping one item and one wait id.
|
|
307
|
+
const choices = edge.choices;
|
|
308
|
+
if (choices !== undefined && choices.length > 0) {
|
|
309
|
+
const actions = choices.filter((choice): choice is WaitAction =>
|
|
310
|
+
(WAIT_ACTIONS as readonly string[]).includes(choice),
|
|
311
|
+
);
|
|
312
|
+
await ctx.ask({
|
|
313
|
+
prompt: waitingPrompt(
|
|
314
|
+
found,
|
|
315
|
+
context.task,
|
|
316
|
+
context.settings.reviewer.fixLevel,
|
|
317
|
+
),
|
|
318
|
+
choices,
|
|
319
|
+
choiceInfo: waitChoiceInfo(
|
|
320
|
+
actions,
|
|
321
|
+
found.reason === "ready to merge",
|
|
322
|
+
),
|
|
323
|
+
graceSecs: 0,
|
|
324
|
+
onTimeout: "waiting",
|
|
325
|
+
resume: null,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
216
328
|
// A stopped run keeps its result, so the wait can say which step stopped.
|
|
217
329
|
return {
|
|
218
330
|
result: found.step === undefined ? "done" : "interrupted",
|