@kyuki3rain/cupola 0.1.0 → 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/CHANGELOG.md +158 -0
- package/README.md +3 -2
- package/dist/branch-store.js +73 -0
- package/dist/commands/change.js +245 -39
- package/dist/commands/epic.js +3 -3
- package/dist/commands/execution.js +482 -0
- package/dist/commands/locks.js +69 -1
- package/dist/commands/reaction.js +185 -0
- package/dist/commands/revision.js +4 -4
- package/dist/commands/run.js +68 -62
- package/dist/commands/setup.js +54 -22
- package/dist/commands/spec.js +1 -1
- package/dist/commands/status.js +437 -138
- package/dist/commands/trace.js +106 -29
- package/dist/commands/wait.js +14 -11
- package/dist/commands/work.js +12 -7
- package/dist/commands/workspace.js +16 -5
- package/dist/commands/worktree.js +3 -3
- package/dist/config.js +66 -2
- package/dist/epic.js +24 -5
- package/dist/execution.js +272 -0
- package/dist/feedback.js +3 -17
- package/dist/host/git.js +224 -0
- package/dist/host/github.js +145 -48
- package/dist/host/host.js +3 -1
- package/dist/host/index.js +63 -0
- package/dist/main.js +143 -48
- package/dist/reaction.js +110 -0
- package/dist/record.js +52 -18
- package/dist/runbook.js +26 -5
- package/dist/status.js +158 -27
- package/dist/templates.js +2 -1
- package/dist/tracker/files.js +9 -66
- package/dist/tracker/index.js +8 -1
- package/dist/tree.js +17 -0
- package/dist/work.js +27 -6
- package/dist/workspace.js +37 -12
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/cupola-abort/SKILL.md +11 -5
- package/skills/cupola-adr/SKILL.md +23 -10
- package/skills/cupola-catalog/SKILL.md +1 -1
- package/skills/cupola-catalog-draft/SKILL.md +6 -4
- package/skills/cupola-complete/SKILL.md +35 -15
- package/skills/cupola-decide/SKILL.md +64 -25
- package/skills/cupola-e2e-setup/SKILL.md +1 -1
- package/skills/cupola-epic-accept/SKILL.md +14 -10
- package/skills/cupola-epic-create/SKILL.md +67 -27
- package/skills/cupola-epic-revise/SKILL.md +39 -18
- package/skills/cupola-epic-run/SKILL.md +81 -42
- package/skills/cupola-fix/SKILL.md +7 -5
- package/skills/cupola-init/SKILL.md +79 -24
- package/skills/cupola-intake/SKILL.md +19 -2
- package/skills/cupola-operate/SKILL.md +62 -45
- package/skills/cupola-resolve/SKILL.md +21 -14
- package/skills/cupola-respond/SKILL.md +73 -0
- package/skills/cupola-review/SKILL.md +14 -15
- package/skills/cupola-spec-design/SKILL.md +15 -10
- package/skills/cupola-spec-impl/SKILL.md +6 -4
- package/skills/cupola-spec-run/SKILL.md +29 -17
- package/skills/cupola-steering/SKILL.md +13 -6
- package/skills/cupola-try/SKILL.md +38 -0
- package/templates/install/.kiro/steering/operations.md +2 -2
- package/templates/install/.kiro/steering/principles.md +1 -1
- package/templates/install/cc-sdd/patches.json +1 -1
- package/templates/method-1/card.md +11 -3
- package/templates/method-1/case.md +2 -2
- package/templates/method-1/changes/catalog.md +1 -1
- package/templates/method-1/changes/epic.md +3 -2
- package/templates/method-1/changes/fix.md +1 -1
- package/templates/method-1/changes/release.md +1 -1
- package/templates/method-1/changes/spec.md +1 -1
- package/templates/method-1/cupola-issue-draft.md +1 -1
- package/templates/method-1/epic.md +17 -6
- package/templates/method-1/execution.md +55 -0
- package/templates/method-1/no-go.md +28 -0
- package/templates/method-1/reaction.md +17 -0
- package/templates/method-1/record.json +3 -3
- package/templates/method-1/report.md +3 -3
- package/templates/method-1/runbook.md +8 -2
- package/templates/method-1/runner-result.json +1 -1
- package/dist/commands/procedure.js +0 -92
- package/dist/procedure.js +0 -60
- package/templates/method-1/send-back.md +0 -23
package/dist/commands/status.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { codeChanges } from "../code.js";
|
|
2
|
-
import { epicPath, resolveComponents } from "../config.js";
|
|
2
|
+
import { epicCardsDir, epicPath, resolveComponents } from "../config.js";
|
|
3
3
|
import { E2E_PROFILE } from "../e2e.js";
|
|
4
4
|
import { projectProfile } from "../e2e-project.js";
|
|
5
5
|
import { EpicFront, parseEpic } from "../epic.js";
|
|
6
|
-
import { fromPeople, trusted } from "../feedback.js";
|
|
7
6
|
import { git, originDefaultBranch } from "../git.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { endingCard, parseRecord } from "../record.js";
|
|
7
|
+
import { codeHost } from "../host/index.js";
|
|
8
|
+
import { hostReactions, pendingOf, sessionReactions, triesOf } from "../reaction.js";
|
|
9
|
+
import { endingCard, parseRecord, redoFromAcceptance, } from "../record.js";
|
|
11
10
|
import { releaseChanges, releasesOf } from "../release.js";
|
|
12
11
|
import { epicBranchName, specName, specNamesOf } from "../spec.js";
|
|
13
|
-
import { deriveStatus } from "../status.js";
|
|
12
|
+
import { ago, askOf, blockedBy, deriveStatus, withReactions, } from "../status.js";
|
|
14
13
|
import { gitTree } from "../tree.js";
|
|
15
|
-
import { findSpecDocument, MissingWorkError, readCards, runDir, workBranchName } from "../work.js";
|
|
14
|
+
import { findSpecDocument, isWorkId, MissingWorkError, readCards, readCardsIn, runDir, WORK_BRANCH_PREFIX, workBranchName, } from "../work.js";
|
|
16
15
|
import { locateWork, workspace } from "../workspace.js";
|
|
17
16
|
import { recordsAbort } from "./epic.js";
|
|
17
|
+
import { executionStatus, executionsFor } from "./execution.js";
|
|
18
18
|
import { environmentsInUse } from "./locks.js";
|
|
19
19
|
import { carriedOut, droppedBecause, pendingPlan, redesignToTakeIn } from "./revision.js";
|
|
20
20
|
import { trackerOf } from "./work.js";
|
|
@@ -111,9 +111,9 @@ onlyCase = false) {
|
|
|
111
111
|
io.out(json ? JSON.stringify(result) : describe(result));
|
|
112
112
|
return 0;
|
|
113
113
|
}
|
|
114
|
-
/** Marks a Log line of a case found not solved at
|
|
114
|
+
/** Marks a Log line of a case found not solved at resolution, naming the epics judged. */
|
|
115
115
|
const NOT_SOLVED = /<!--\s*cupola:not-solved\s+(\{.*?\})\s*-->/g;
|
|
116
|
-
/** The epics a case's Log says
|
|
116
|
+
/** The epics a case's Log says resolution already judged not enough. */
|
|
117
117
|
export function judgedEpics(caseText) {
|
|
118
118
|
const judged = new Set();
|
|
119
119
|
for (const m of caseText.matchAll(NOT_SOLVED)) {
|
|
@@ -134,8 +134,10 @@ export function notSolvedMarker(epics) {
|
|
|
134
134
|
return `<!-- cupola:not-solved ${JSON.stringify({ epics })} -->`;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* A case's agreed
|
|
138
|
-
*
|
|
137
|
+
* A case's epics with their statuses: the agreed ones — on origin's default
|
|
138
|
+
* branch — that list it, and those under agreement, whose epic change is open
|
|
139
|
+
* and whose draft on its branch lists it. Undefined when the tracker has no
|
|
140
|
+
* such case.
|
|
139
141
|
*/
|
|
140
142
|
export async function caseEpics(io, root, config, id) {
|
|
141
143
|
const doc = await (await trackerOf(io)).show(id);
|
|
@@ -151,24 +153,82 @@ export async function caseEpics(io, root, config, id) {
|
|
|
151
153
|
const agreed = gitTree(root, ref);
|
|
152
154
|
const judged = judgedEpics(doc.text);
|
|
153
155
|
const epics = [];
|
|
154
|
-
for (const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
for (const epic of (await agreed.dirs(config.paths.epics)).sort()) {
|
|
157
|
+
const raw = await agreed.read(epicPath(config.paths, epic));
|
|
158
|
+
if (raw === undefined)
|
|
159
|
+
continue;
|
|
158
160
|
const front = EpicFront.safeParse(parseEpic(raw).front);
|
|
159
161
|
if (!front.success || !front.data.cases.includes(caseId))
|
|
160
162
|
continue;
|
|
161
|
-
const
|
|
163
|
+
const of = await workStatus(io, root, config, epic);
|
|
164
|
+
const pending = (of.executions ?? []).filter((e) => e.id === null).map((e) => e.runbook);
|
|
165
|
+
epics.push({
|
|
166
|
+
id: epic,
|
|
167
|
+
status: of.status,
|
|
168
|
+
judged: judged.has(epic),
|
|
169
|
+
...(pending.length > 0 ? { pending } : {}),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
for (const epic of await epicsUnderAgreement(io, root, config, caseId)) {
|
|
173
|
+
if (epics.some((e) => e.id === epic))
|
|
174
|
+
continue;
|
|
162
175
|
const of = await workStatus(io, root, config, epic);
|
|
163
176
|
epics.push({ id: epic, status: of.status, judged: judged.has(epic) });
|
|
164
177
|
}
|
|
165
178
|
return { doc, epics };
|
|
166
179
|
}
|
|
167
180
|
/**
|
|
168
|
-
* The
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
|
|
181
|
+
* The epics under agreement that list a case: a draft on its work branch on
|
|
182
|
+
* origin whose change is open. An epic whose change was closed is abandoned;
|
|
183
|
+
* one whose change was merged is agreed, and read from the default branch.
|
|
184
|
+
*/
|
|
185
|
+
async function epicsUnderAgreement(io, root, config, caseId) {
|
|
186
|
+
const prefix = WORK_BRANCH_PREFIX;
|
|
187
|
+
const heads = await git(root, ["ls-remote", "--heads", "origin", `refs/heads/${prefix}*`]);
|
|
188
|
+
const ids = heads
|
|
189
|
+
.split("\n")
|
|
190
|
+
.map((line) => line.split("\t")[1] ?? "")
|
|
191
|
+
.filter((ref) => ref.startsWith(`refs/heads/${prefix}`))
|
|
192
|
+
.map((ref) => ref.slice(`refs/heads/${prefix}`.length))
|
|
193
|
+
.filter(isWorkId);
|
|
194
|
+
if (ids.length === 0)
|
|
195
|
+
return [];
|
|
196
|
+
try {
|
|
197
|
+
await git(root, [
|
|
198
|
+
"fetch",
|
|
199
|
+
"--quiet",
|
|
200
|
+
"origin",
|
|
201
|
+
`+refs/heads/${prefix}*:refs/remotes/origin/${prefix}*`,
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// another fetch holds a ref: the tracking refs it writes are as fresh
|
|
206
|
+
}
|
|
207
|
+
const host = (io.host ?? codeHost)(root);
|
|
208
|
+
const found = [];
|
|
209
|
+
for (const id of ids.sort()) {
|
|
210
|
+
const branch = workBranchName(id);
|
|
211
|
+
const ref = `refs/remotes/origin/${branch}`;
|
|
212
|
+
if (!(await hasRef(root, ref)))
|
|
213
|
+
continue;
|
|
214
|
+
const raw = await gitTree(root, ref).read(epicPath(config.paths, id));
|
|
215
|
+
if (raw === undefined)
|
|
216
|
+
continue;
|
|
217
|
+
const front = EpicFront.safeParse(parseEpic(raw).front);
|
|
218
|
+
if (!front.success || !front.data.cases.includes(caseId))
|
|
219
|
+
continue;
|
|
220
|
+
if ((await host.findChange(branch))?.state === "open")
|
|
221
|
+
found.push(id);
|
|
222
|
+
}
|
|
223
|
+
return found;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The status of a case: open until an epic lists it — agreed, or under
|
|
227
|
+
* agreement with its change open — or an execution works on it; in progress
|
|
228
|
+
* while one is not done, awaiting resolution when all are, and resolved
|
|
229
|
+
* once closed. Work resolution found not enough, aborted epics, and dropped executions
|
|
230
|
+
* no longer count, so the case is open again. Its Log is read for nothing else
|
|
231
|
+
* than what resolution judged.
|
|
172
232
|
*/
|
|
173
233
|
export async function caseStatus(io, root, config, id) {
|
|
174
234
|
const found = await caseEpics(io, root, config, id);
|
|
@@ -176,12 +236,19 @@ export async function caseStatus(io, root, config, id) {
|
|
|
176
236
|
return undefined;
|
|
177
237
|
const { doc, epics } = found;
|
|
178
238
|
id = doc.id;
|
|
239
|
+
const judged = judgedEpics(doc.text);
|
|
240
|
+
const executions = (await executionsFor(io, root, config, id)).map((e) => ({
|
|
241
|
+
id: e.id,
|
|
242
|
+
runbook: e.runbook,
|
|
243
|
+
status: e.status.status,
|
|
244
|
+
}));
|
|
179
245
|
const base = {
|
|
180
246
|
work: { kind: "case", id, component: "" },
|
|
181
247
|
change: null,
|
|
182
248
|
cards: [],
|
|
183
249
|
run: null,
|
|
184
250
|
epics,
|
|
251
|
+
executions,
|
|
185
252
|
};
|
|
186
253
|
if (!doc.open) {
|
|
187
254
|
return {
|
|
@@ -192,7 +259,10 @@ export async function caseStatus(io, root, config, id) {
|
|
|
192
259
|
next: { kind: "nothing", text: "Resolved." },
|
|
193
260
|
};
|
|
194
261
|
}
|
|
195
|
-
const counted =
|
|
262
|
+
const counted = [
|
|
263
|
+
...epics.filter((e) => !e.judged && e.status !== "aborted" && e.status !== "dropped"),
|
|
264
|
+
...executions.filter((e) => !judged.has(e.id) && e.status !== "dropped"),
|
|
265
|
+
];
|
|
196
266
|
if (counted.length === 0) {
|
|
197
267
|
return {
|
|
198
268
|
...base,
|
|
@@ -201,12 +271,12 @@ export async function caseStatus(io, root, config, id) {
|
|
|
201
271
|
gate: null,
|
|
202
272
|
next: {
|
|
203
273
|
kind: "nothing",
|
|
204
|
-
text: "No agreed
|
|
274
|
+
text: "No epic (agreed or under agreement) or execution works on it; turn it into an epic when you choose.",
|
|
205
275
|
command: `cupola-epic-create ${id}`,
|
|
206
276
|
},
|
|
207
277
|
};
|
|
208
278
|
}
|
|
209
|
-
const running = counted.filter((e) => e.status !== "done");
|
|
279
|
+
const running = counted.filter((e) => e.status !== "done" || (e.pending?.length ?? 0) > 0);
|
|
210
280
|
if (running.length > 0) {
|
|
211
281
|
return {
|
|
212
282
|
...base,
|
|
@@ -215,7 +285,7 @@ export async function caseStatus(io, root, config, id) {
|
|
|
215
285
|
gate: null,
|
|
216
286
|
next: {
|
|
217
287
|
kind: "nothing",
|
|
218
|
-
text: `It follows its epics: ${running.map((e) => `${e.id} (${e.status})`).join(", ")}.`,
|
|
288
|
+
text: `It follows its ${executions.length > 0 ? "work" : "epics"}: ${running.map((e) => `${e.id} (${e.status === "done" ? `released; ${e.pending?.join(", ")} not started` : e.status})`).join(", ")}.`,
|
|
219
289
|
},
|
|
220
290
|
};
|
|
221
291
|
}
|
|
@@ -223,10 +293,10 @@ export async function caseStatus(io, root, config, id) {
|
|
|
223
293
|
...base,
|
|
224
294
|
status: "awaiting-resolution",
|
|
225
295
|
turn: "human",
|
|
226
|
-
gate: "
|
|
296
|
+
gate: "resolution",
|
|
227
297
|
next: {
|
|
228
298
|
kind: "gate",
|
|
229
|
-
text: `Its epics are done (${counted.map((e) => e.id).join(", ")}); judge whether the problem is gone.`,
|
|
299
|
+
text: `Its ${executions.length > 0 ? "work is" : "epics are"} done (${counted.map((e) => e.id).join(", ")}); judge whether the problem is gone.`,
|
|
230
300
|
command: `cupola-resolve ${id}`,
|
|
231
301
|
},
|
|
232
302
|
};
|
|
@@ -272,6 +342,10 @@ async function codeLeft(io, ws, branch, component, hub) {
|
|
|
272
342
|
}
|
|
273
343
|
/** The status of any work item: a spec, fix, or catalog spec, or else an epic. */
|
|
274
344
|
export async function workStatus(io, hubRoot, config, id) {
|
|
345
|
+
// An execution of a runbook lives in the hub; its status comes from its own record.
|
|
346
|
+
const execution = await executionStatus(io, hubRoot, config, id);
|
|
347
|
+
if (execution)
|
|
348
|
+
return execution;
|
|
275
349
|
const branch = workBranchName(id);
|
|
276
350
|
// The work lives in its component's repository; epics, cases, and revisions in the hub.
|
|
277
351
|
const ws = await workspace({ ...io, cwd: hubRoot });
|
|
@@ -338,22 +412,30 @@ export async function workStatus(io, hubRoot, config, id) {
|
|
|
338
412
|
const record = raw === undefined ? undefined : parseRecord(raw);
|
|
339
413
|
const read = await readCards(tree, id);
|
|
340
414
|
const inEpic = doc.kind === "spec" && doc.epic ? doc.epic : undefined;
|
|
415
|
+
// The epic whose run runs it: a spec's, or a fix spec's its acceptance check added.
|
|
416
|
+
const runBy = (doc.kind === "spec" || doc.kind === "fix-spec") && doc.epic ? doc.epic : undefined;
|
|
417
|
+
const workOf = {
|
|
418
|
+
kind: doc.kind,
|
|
419
|
+
id,
|
|
420
|
+
component: doc.component,
|
|
421
|
+
...(runBy ? { epic: runBy } : {}),
|
|
422
|
+
};
|
|
341
423
|
const cards = inEpic ? await carriedOut(io, hub, id, inEpic, read) : read;
|
|
342
|
-
const host = (io.host ??
|
|
424
|
+
const host = (io.host ?? codeHost)(root);
|
|
343
425
|
const change = await host.findChange(branch);
|
|
344
426
|
// The only spec of an epic outside the hub is released with its `system` change:
|
|
345
427
|
// merged alone, it is not done until that one is merged too.
|
|
346
428
|
if (inEpic && change?.state === "merged" && located.slug !== ws.hub.slug) {
|
|
347
|
-
const system = await (io.host ??
|
|
429
|
+
const system = await (io.host ?? codeHost)(hub).findChange(workBranchName(`${inEpic}-system`));
|
|
348
430
|
if (system?.state === "open") {
|
|
349
431
|
return {
|
|
350
|
-
work:
|
|
432
|
+
work: workOf,
|
|
351
433
|
change: system,
|
|
352
434
|
cards: [],
|
|
353
435
|
run: null,
|
|
354
436
|
status: "awaiting-acceptance",
|
|
355
437
|
turn: "human",
|
|
356
|
-
gate: "
|
|
438
|
+
gate: "acceptance",
|
|
357
439
|
next: {
|
|
358
440
|
kind: "gate",
|
|
359
441
|
text: `${id} is merged; merge its system change too (${system.url}), then run the command.`,
|
|
@@ -368,13 +450,13 @@ export async function workStatus(io, hubRoot, config, id) {
|
|
|
368
450
|
: undefined;
|
|
369
451
|
if (code) {
|
|
370
452
|
return {
|
|
371
|
-
work:
|
|
453
|
+
work: workOf,
|
|
372
454
|
change: code.change,
|
|
373
455
|
cards: [],
|
|
374
456
|
run: null,
|
|
375
457
|
status: "awaiting-acceptance",
|
|
376
458
|
turn: "human",
|
|
377
|
-
gate: "
|
|
459
|
+
gate: "acceptance",
|
|
378
460
|
next: {
|
|
379
461
|
kind: "gate",
|
|
380
462
|
text: `${id} ${code.text}`,
|
|
@@ -389,21 +471,41 @@ export async function workStatus(io, hubRoot, config, id) {
|
|
|
389
471
|
: [];
|
|
390
472
|
const dropped = inEpic ? await droppedBecause(io, hub, inEpic, doc.component) : undefined;
|
|
391
473
|
const redesign = inEpic ? await redesignToTakeIn(hub, tree, id) : undefined;
|
|
474
|
+
// The run takes an agreed redesign in before anything runs: shown as it will run, from the
|
|
475
|
+
// acceptance tests, not as the record says before it is taken in. A phase running now is shown
|
|
476
|
+
// as it is.
|
|
477
|
+
const retaken = redesign !== undefined && record !== undefined && !record.active;
|
|
478
|
+
const shown = retaken ? structuredClone(record) : record;
|
|
479
|
+
if (retaken && shown)
|
|
480
|
+
redoFromAcceptance(shown);
|
|
392
481
|
const pending = inEpic && change?.state !== "merged" && change?.state !== "closed"
|
|
393
482
|
? await pendingPlan(io, hub, inEpic, doc.component)
|
|
394
483
|
: undefined;
|
|
395
|
-
const environment = await environmentWait(root, tree,
|
|
396
|
-
|
|
484
|
+
const environment = await environmentWait(root, tree, shown, id);
|
|
485
|
+
// Reactions are read at acceptance only (ready, no run going), so that a run in progress costs nothing.
|
|
486
|
+
const gate = change?.state === "open" && !change.draft && !record
|
|
487
|
+
? await gateReactions(root, host, change, tree, id, ws.config)
|
|
488
|
+
: undefined;
|
|
489
|
+
// A change of an epic's spec closed with nothing recording why: not dropped, but the human's.
|
|
490
|
+
const closedByHand = runBy &&
|
|
491
|
+
change?.state === "closed" &&
|
|
492
|
+
!endingCard(record, cards) &&
|
|
493
|
+
!(await droppedBecause(io, hub, runBy, doc.component))
|
|
494
|
+
? runBy
|
|
495
|
+
: undefined;
|
|
397
496
|
const left = change?.state === "merged" && (await untidy(root, branch));
|
|
398
497
|
const derived = deriveStatus({
|
|
399
|
-
work:
|
|
498
|
+
work: workOf,
|
|
400
499
|
change,
|
|
401
|
-
|
|
500
|
+
...(change ? { reach: await host.reach(change, id) } : {}),
|
|
501
|
+
record: shown,
|
|
402
502
|
cards,
|
|
403
|
-
...(
|
|
503
|
+
...(gate ? { gate } : {}),
|
|
504
|
+
...(closedByHand ? { closedByHand } : {}),
|
|
404
505
|
...(left ? { untidy: true } : {}),
|
|
405
506
|
...(environment ? { environment } : {}),
|
|
406
|
-
|
|
507
|
+
// A finish followed by a redesign is not an interrupted finish: the run starts again.
|
|
508
|
+
finished: subject === `cupola: ${id}: finish` && redesign === undefined,
|
|
407
509
|
...(doc.epic && waitsFor.length > 0
|
|
408
510
|
? { waiting: { for: waitsFor, resume: `cupola-epic-run ${doc.epic}` } }
|
|
409
511
|
: {}),
|
|
@@ -418,12 +520,25 @@ export async function workStatus(io, hubRoot, config, id) {
|
|
|
418
520
|
: {}),
|
|
419
521
|
...(inEpic && pending
|
|
420
522
|
? {
|
|
421
|
-
revision:
|
|
523
|
+
revision: {
|
|
524
|
+
text: `R${pending.revision} of ${inEpic} plans to ${pending.plan} it; it waits until the revision is agreed (its start gate)`,
|
|
525
|
+
epic: inEpic,
|
|
526
|
+
url: (await (io.host ?? codeHost)(hub).findChange(workBranchName(inEpic)))?.url,
|
|
527
|
+
},
|
|
422
528
|
}
|
|
423
529
|
: {}),
|
|
424
530
|
});
|
|
425
|
-
|
|
426
|
-
|
|
531
|
+
if (retaken && derived.next.kind === "run") {
|
|
532
|
+
return {
|
|
533
|
+
...derived,
|
|
534
|
+
next: {
|
|
535
|
+
...derived.next,
|
|
536
|
+
text: `${derived.next.text} R${redesign} of ${inEpic}, agreed, redesigns it: the run takes it in first, so the record still shows the phases before it.`,
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
// At acceptance with every document in the hub, its code change is merged first.
|
|
541
|
+
if (derived.gate === "acceptance" && change?.state === "open" && ws.config.documents === "hub") {
|
|
427
542
|
const codes = (await codeChanges(io, ws, branch, [doc.component])).flatMap((c) => c.change?.state === "open" ? [c.change.url] : []);
|
|
428
543
|
if (codes.length > 0)
|
|
429
544
|
return {
|
|
@@ -529,10 +644,10 @@ async function fixSpecsIn(root, config, epic, known) {
|
|
|
529
644
|
/**
|
|
530
645
|
* An epic whose specs are all done: *accepting* while its own
|
|
531
646
|
* record on the epic branch runs the acceptance check and opens the release,
|
|
532
|
-
* *awaiting release*
|
|
647
|
+
* *awaiting release* once the release change is ready, *done* once it is
|
|
533
648
|
* merged.
|
|
534
649
|
*/
|
|
535
|
-
async function acceptance(io, root, id, specs, result) {
|
|
650
|
+
async function acceptance(io, root, config, id, specs, result) {
|
|
536
651
|
const branch = epicBranchName(id);
|
|
537
652
|
// With several repositories, one release per repository, merged in order.
|
|
538
653
|
const ws = await workspace({ ...io, cwd: root });
|
|
@@ -540,7 +655,7 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
540
655
|
const pendingRelease = each?.find((r) => r.change?.state !== "merged");
|
|
541
656
|
const release = each
|
|
542
657
|
? ((pendingRelease ?? each.at(-1))?.change ?? null)
|
|
543
|
-
: ((await (io.host ??
|
|
658
|
+
: ((await (io.host ?? codeHost)(root).findChange(branch)) ?? null);
|
|
544
659
|
const releases = each?.map((r) => ({
|
|
545
660
|
repo: r.repo.slug,
|
|
546
661
|
order: r.order,
|
|
@@ -553,17 +668,31 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
553
668
|
...(releases ? { releases } : {}),
|
|
554
669
|
});
|
|
555
670
|
if (release?.state === "merged") {
|
|
671
|
+
// cupola-complete deletes the epic branch: while it is on origin, complete has not run.
|
|
672
|
+
const complete = `cupola-complete ${id}`;
|
|
673
|
+
const untidied = await git(root, [
|
|
674
|
+
"ls-remote",
|
|
675
|
+
"--heads",
|
|
676
|
+
"origin",
|
|
677
|
+
`refs/heads/${branch}`,
|
|
678
|
+
]).then((out) => out.trim() !== "", () => false);
|
|
556
679
|
return withRelease(result({
|
|
557
680
|
status: "done",
|
|
558
|
-
turn: "none",
|
|
681
|
+
turn: untidied ? "human" : "none",
|
|
559
682
|
gate: null,
|
|
560
|
-
next:
|
|
683
|
+
next: untidied
|
|
684
|
+
? {
|
|
685
|
+
kind: "run",
|
|
686
|
+
text: `Released: \`${complete}\` tidies up and moves on.`,
|
|
687
|
+
command: complete,
|
|
688
|
+
}
|
|
689
|
+
: { kind: "nothing", text: "Released." },
|
|
561
690
|
}));
|
|
562
691
|
}
|
|
563
692
|
const { tree } = await workTree(root, branch);
|
|
564
693
|
const raw = await tree.read(`${runDir(id)}/record.json`);
|
|
565
694
|
const record = raw === undefined ? undefined : parseRecord(raw);
|
|
566
|
-
// A wrong composition stops the check with a card: the human's turn
|
|
695
|
+
// A wrong composition stops the check with a card: the human's turn: a decision.
|
|
567
696
|
const cards = await carriedOut(io, root, id, id, await readCards(tree, id));
|
|
568
697
|
const unanswered = cards.filter((c) => !c.answered).map((c) => c.card);
|
|
569
698
|
if (unanswered.length > 0) {
|
|
@@ -571,7 +700,7 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
571
700
|
...withRelease(result({
|
|
572
701
|
status: "awaiting-decision",
|
|
573
702
|
turn: "human",
|
|
574
|
-
gate:
|
|
703
|
+
gate: null,
|
|
575
704
|
next: {
|
|
576
705
|
kind: "gate",
|
|
577
706
|
text: `Answer cards ${unanswered.join(", ")} of the acceptance check.`,
|
|
@@ -579,6 +708,7 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
579
708
|
},
|
|
580
709
|
})),
|
|
581
710
|
cards: unanswered,
|
|
711
|
+
...askOf(cards, unanswered),
|
|
582
712
|
};
|
|
583
713
|
}
|
|
584
714
|
const ending = endingCard(record, cards);
|
|
@@ -610,20 +740,39 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
610
740
|
const k = pendingRelease
|
|
611
741
|
? `${pendingRelease.order} of ${pendingRelease.of} (${pendingRelease.repo.slug})`
|
|
612
742
|
: "";
|
|
613
|
-
|
|
743
|
+
const releaseHost = pendingRelease?.host ?? (io.host ?? codeHost)(root);
|
|
744
|
+
const { read, merge } = await releaseHost.reach(release, id, { release: true });
|
|
745
|
+
const reactions = await gateReactions(root, releaseHost, release, tree, id, config);
|
|
746
|
+
return withReactions(withRelease(result({
|
|
614
747
|
status: "awaiting-release",
|
|
615
748
|
turn: "human",
|
|
616
|
-
gate: "
|
|
749
|
+
gate: "release",
|
|
617
750
|
next: {
|
|
618
751
|
kind: "gate",
|
|
619
|
-
text: each
|
|
620
|
-
? `Read "Release"
|
|
621
|
-
: `Read "Release"
|
|
752
|
+
text: `${each
|
|
753
|
+
? `Read "Release" in ${read} and ${merge}, release ${k}${merged > 0 ? `, after the ${merged} merged before it are deployed` : ""}; merge the rest in order, then run the command.`
|
|
754
|
+
: `Read "Release" in ${read} and ${merge} to release the epic, then run the command.`} Or comment, or give a No-Go (it revises the epic) on the change or with \`cupola-decide ${id}\`.`,
|
|
622
755
|
command: `cupola-complete ${id}`,
|
|
623
756
|
},
|
|
624
|
-
}));
|
|
757
|
+
})), id, reactions);
|
|
625
758
|
}
|
|
626
759
|
const active = record?.active;
|
|
760
|
+
const blocked = blockedBy(record);
|
|
761
|
+
if (blocked) {
|
|
762
|
+
return {
|
|
763
|
+
...withRelease(result({
|
|
764
|
+
status: "blocked",
|
|
765
|
+
turn: "human",
|
|
766
|
+
gate: null,
|
|
767
|
+
next: {
|
|
768
|
+
kind: "run",
|
|
769
|
+
text: `The acceptance check is blocked: ${blocked.blocker}. Fix that, then resume it.`,
|
|
770
|
+
command: `cupola-epic-run ${id}`,
|
|
771
|
+
},
|
|
772
|
+
})),
|
|
773
|
+
blocked,
|
|
774
|
+
};
|
|
775
|
+
}
|
|
627
776
|
const environment = await environmentWait(root, tree, record, id);
|
|
628
777
|
if (environment) {
|
|
629
778
|
return withRelease(result({
|
|
@@ -633,7 +782,7 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
633
782
|
next: {
|
|
634
783
|
kind: "nothing",
|
|
635
784
|
text: `The acceptance check waits: ${environment}. It resumes when that is released.`,
|
|
636
|
-
command: `cupola-epic-
|
|
785
|
+
command: `cupola-epic-run ${id}`,
|
|
637
786
|
},
|
|
638
787
|
}));
|
|
639
788
|
}
|
|
@@ -644,13 +793,13 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
644
793
|
next: active
|
|
645
794
|
? {
|
|
646
795
|
kind: "nothing",
|
|
647
|
-
text: `The acceptance check is running (${active.who}, session ${active.session}). If that session has ended,
|
|
648
|
-
command: `cupola-epic-
|
|
796
|
+
text: `The acceptance check is running (${active.who}, session ${active.session}, ${ago(active.since) ?? `since ${active.since}`}). If that session has ended, take it over with \`cupola-epic-run ${id} --take-over ${active.session}\`.`,
|
|
797
|
+
command: `cupola-epic-run ${id} --take-over ${active.session}`,
|
|
649
798
|
}
|
|
650
799
|
: {
|
|
651
800
|
kind: "run",
|
|
652
801
|
text: "Every spec is done; run the acceptance check across specs and open the release.",
|
|
653
|
-
command: `cupola-epic-
|
|
802
|
+
command: `cupola-epic-run ${id}`,
|
|
654
803
|
},
|
|
655
804
|
}));
|
|
656
805
|
}
|
|
@@ -662,7 +811,7 @@ async function acceptance(io, root, id, specs, result) {
|
|
|
662
811
|
export async function specDesignDone(root, spec) {
|
|
663
812
|
const path = `.kiro/specs/${spec}/spec.json`;
|
|
664
813
|
const own = (await workTree(root, workBranchName(spec))).tree;
|
|
665
|
-
// A design that ended with
|
|
814
|
+
// A design that ended with decision cards is settled only once they are answered; cards from
|
|
666
815
|
// later phases do not reopen it.
|
|
667
816
|
const raw = await own.read(`${runDir(spec)}/record.json`);
|
|
668
817
|
if (raw !== undefined) {
|
|
@@ -708,6 +857,26 @@ paths, tree, epic, component) {
|
|
|
708
857
|
}
|
|
709
858
|
return waits;
|
|
710
859
|
}
|
|
860
|
+
/**
|
|
861
|
+
* The session of an epic's run, read from the markers of the runners it has running: the epic's
|
|
862
|
+
* run names its session `cupola-<epic>-<unix seconds>` and each runner `<session>-<component>`.
|
|
863
|
+
* A spec run on its own (`cupola-<spec>-<unix seconds>`) is not the epic's run.
|
|
864
|
+
*/
|
|
865
|
+
export function epicRunSession(epic, specs) {
|
|
866
|
+
const pattern = new RegExp(`^cupola-${epic}-(\\d+)-[a-z0-9]`);
|
|
867
|
+
const runs = specs.flatMap((s) => {
|
|
868
|
+
const started = s.active ? pattern.exec(s.active.session)?.[1] : undefined;
|
|
869
|
+
return started ? [{ spec: s.id, started: Number(started) }] : [];
|
|
870
|
+
});
|
|
871
|
+
if (runs.length === 0)
|
|
872
|
+
return undefined;
|
|
873
|
+
// Two at once is not expected; the one started last is named.
|
|
874
|
+
const started = Math.max(...runs.map((r) => r.started));
|
|
875
|
+
return {
|
|
876
|
+
session: `cupola-${epic}-${started}`,
|
|
877
|
+
specs: runs.filter((r) => r.started === started).map((r) => r.spec),
|
|
878
|
+
};
|
|
879
|
+
}
|
|
711
880
|
/**
|
|
712
881
|
* Each spec of an epic with two or more specs, then the fix specs its
|
|
713
882
|
* acceptance check added, with its status and whether the epic's run can
|
|
@@ -741,12 +910,26 @@ async function specsOfEpic(io, root, config, id, specs) {
|
|
|
741
910
|
const active = of.run?.active
|
|
742
911
|
? { id: of.run.active.id, session: of.run.active.session }
|
|
743
912
|
: null;
|
|
913
|
+
// An agreed revision the epic's run takes in before the spec runs: a dropped spec's change
|
|
914
|
+
// still open is closed; a redesigned spec's change at acceptance goes back to draft (its status
|
|
915
|
+
// then sends it to the epic's run instead of its own).
|
|
916
|
+
const takeIn = of.status === "dropped" && of.change?.state === "open"
|
|
917
|
+
? "close"
|
|
918
|
+
: of.status === "ai-working" &&
|
|
919
|
+
of.change?.state === "open" &&
|
|
920
|
+
!of.change.draft &&
|
|
921
|
+
of.next.command === `cupola-epic-run ${id}`
|
|
922
|
+
? "draft"
|
|
923
|
+
: undefined;
|
|
744
924
|
each.push({
|
|
745
925
|
id: spec,
|
|
746
926
|
status: of.status,
|
|
747
927
|
gate: of.gate,
|
|
748
928
|
active,
|
|
749
|
-
|
|
929
|
+
// A blocked spec waits for a human to fix what stopped it.
|
|
930
|
+
movable: of.status === "ai-working" && active === null && !takeIn,
|
|
931
|
+
...(takeIn ? { takeIn } : {}),
|
|
932
|
+
...(of.blocked ? { blocked: of.blocked } : {}),
|
|
750
933
|
});
|
|
751
934
|
}
|
|
752
935
|
catch (error) {
|
|
@@ -776,11 +959,37 @@ async function specsOfEpic(io, root, config, id, specs) {
|
|
|
776
959
|
return each;
|
|
777
960
|
}
|
|
778
961
|
/**
|
|
779
|
-
* The status of an epic
|
|
962
|
+
* The status of an epic, and, once it is agreed, the cards it was merged with
|
|
963
|
+
* still open. Merging with cards open stops nothing: the runs take each as
|
|
964
|
+
* settled on its recommendation, and the status keeps listing them so they are
|
|
965
|
+
* not forgotten — information only, with no effect on status, turn, or next.
|
|
966
|
+
*/
|
|
967
|
+
async function epicStatus(io, root, config, tree, id) {
|
|
968
|
+
const r = await epicStatusOf(io, root, config, tree, id);
|
|
969
|
+
if (!r || r.gate === "start" || r.status === "draft" || r.status === "aborted")
|
|
970
|
+
return r;
|
|
971
|
+
const unanswered = await neverAnswered(root, config, id);
|
|
972
|
+
return unanswered.length > 0 ? { ...r, unanswered } : r;
|
|
973
|
+
}
|
|
974
|
+
/** An agreed epic's cards never answered, as merged (origin's default branch, or this commit). */
|
|
975
|
+
async function neverAnswered(root, config, id) {
|
|
976
|
+
try {
|
|
977
|
+
const cards = await readCardsIn(await hubAgreed(root), epicCardsDir(config.paths, id));
|
|
978
|
+
return cards
|
|
979
|
+
.filter((c) => !c.answered)
|
|
980
|
+
.map((c) => ({ card: c.card, recommended: c.recommended ?? null, ask: c.ask ?? [] }));
|
|
981
|
+
}
|
|
982
|
+
catch {
|
|
983
|
+
// A card that cannot be read leaves out what is only information.
|
|
984
|
+
return [];
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* The status of an epic: awaiting start while its `epic`
|
|
780
989
|
* change is open; once merged, an epic with one spec takes its spec's
|
|
781
990
|
* statuses, and the run that creates the spec is `cupola-epic-run`.
|
|
782
991
|
*/
|
|
783
|
-
async function
|
|
992
|
+
async function epicStatusOf(io, root, config, tree, id) {
|
|
784
993
|
const path = epicPath(config.paths, id);
|
|
785
994
|
const base = await originDefaultBranch(root);
|
|
786
995
|
let agreed;
|
|
@@ -806,14 +1015,15 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
806
1015
|
throw new Error(`${path}: its front matter is not an epic's (cupola check says why)`);
|
|
807
1016
|
const specs = front.data.specs;
|
|
808
1017
|
const procedures = front.data.procedures.map((r) => r.runbook);
|
|
809
|
-
// After
|
|
810
|
-
|
|
1018
|
+
// After the start gate, the instruction that moves the epic: its specs' run, or the executions of its
|
|
1019
|
+
// procedures, which cupola-complete creates.
|
|
1020
|
+
const start = specs.length > 0 ? `cupola-epic-run ${id}` : `cupola-complete ${id}`;
|
|
811
1021
|
const work = {
|
|
812
1022
|
kind: "epic",
|
|
813
1023
|
id,
|
|
814
1024
|
component: specs.length === 1 ? (specs[0]?.component ?? "") : specs.map((s) => s.component).join(", "),
|
|
815
1025
|
};
|
|
816
|
-
const change = (await (io.host ??
|
|
1026
|
+
const change = (await (io.host ?? codeHost)(root).findChange(workBranchName(id))) ?? null;
|
|
817
1027
|
const result = (r) => ({
|
|
818
1028
|
work,
|
|
819
1029
|
change,
|
|
@@ -821,35 +1031,58 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
821
1031
|
run: null,
|
|
822
1032
|
...r,
|
|
823
1033
|
});
|
|
824
|
-
// An open epic change — the first one, or a revision of an agreed epic — is
|
|
1034
|
+
// An open epic change — the first one, or a revision of an agreed epic — is the start gate.
|
|
825
1035
|
if (change?.state === "open") {
|
|
1036
|
+
const host = (io.host ?? codeHost)(root);
|
|
1037
|
+
const reactions = await gateReactions(root, host, change, tree, id, config);
|
|
1038
|
+
const g1 = (r) => withReactions(r, id, reactions);
|
|
1039
|
+
// Its cards are on its branch: those still open are what the start gate has to settle first.
|
|
1040
|
+
const all = await readCardsIn(tree, epicCardsDir(config.paths, id));
|
|
1041
|
+
const open = all.filter((c) => !c.answered).map((c) => c.card);
|
|
1042
|
+
const skill = agreed === undefined ? "cupola-epic-create" : "cupola-epic-revise";
|
|
1043
|
+
if (open.length > 0) {
|
|
1044
|
+
return g1({
|
|
1045
|
+
...result({
|
|
1046
|
+
status: "awaiting-start",
|
|
1047
|
+
turn: "human",
|
|
1048
|
+
gate: "start",
|
|
1049
|
+
next: {
|
|
1050
|
+
kind: "gate",
|
|
1051
|
+
text: `Answer cards ${open.join(", ")} with cupola-decide ${id}, which has ${skill} reflect them in the epic (${change.url}); merge the change once no card is open.`,
|
|
1052
|
+
command: start,
|
|
1053
|
+
},
|
|
1054
|
+
}),
|
|
1055
|
+
cards: open,
|
|
1056
|
+
...askOf(all, open),
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
826
1059
|
if (agreed === undefined) {
|
|
827
|
-
return result({
|
|
828
|
-
status: "awaiting-
|
|
1060
|
+
return g1(result({
|
|
1061
|
+
status: "awaiting-start",
|
|
829
1062
|
turn: "human",
|
|
830
|
-
gate: "
|
|
1063
|
+
gate: "start",
|
|
831
1064
|
next: {
|
|
832
1065
|
kind: "gate",
|
|
833
|
-
text: `Read the epic and merge its change to agree (${change.url}); to change
|
|
1066
|
+
text: `Read the epic and merge its change to agree (${change.url}); to change it, comment, ask for a try, or give a No-Go on the change or with cupola-decide ${id}.`,
|
|
834
1067
|
command: start,
|
|
835
1068
|
},
|
|
836
|
-
});
|
|
1069
|
+
}));
|
|
837
1070
|
}
|
|
838
|
-
// A revision of a running epic:
|
|
1071
|
+
// A revision of a running epic: the start gate again, while the specs it leaves alone go on.
|
|
839
1072
|
const running = specs.length >= 2 ? await specsOfEpic(io, root, config, id, specs) : undefined;
|
|
840
|
-
return {
|
|
1073
|
+
return g1({
|
|
841
1074
|
...result({
|
|
842
|
-
status: "awaiting-
|
|
1075
|
+
status: "awaiting-start",
|
|
843
1076
|
turn: "human",
|
|
844
|
-
gate: "
|
|
1077
|
+
gate: "start",
|
|
845
1078
|
next: {
|
|
846
1079
|
kind: "gate",
|
|
847
|
-
text: `Read the revision and merge its change to agree (${change.url}); to change it,
|
|
1080
|
+
text: `Read the revision and merge its change to agree (${change.url}); to change it, comment, ask for a try, or give a No-Go on the change or with cupola-decide ${id}. Specs it leaves alone go on with the command.`,
|
|
848
1081
|
command: start,
|
|
849
1082
|
},
|
|
850
1083
|
}),
|
|
851
1084
|
...(running ? { specs: running } : {}),
|
|
852
|
-
};
|
|
1085
|
+
});
|
|
853
1086
|
}
|
|
854
1087
|
// A merged change is agreement even when origin's default branch could not be read.
|
|
855
1088
|
if (agreed === undefined && change?.state !== "merged") {
|
|
@@ -873,13 +1106,10 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
873
1106
|
},
|
|
874
1107
|
});
|
|
875
1108
|
}
|
|
876
|
-
// Aborted after
|
|
1109
|
+
// Aborted after its start: recorded on its cases, where its status comes from.
|
|
877
1110
|
const tracker = await trackerOf(io);
|
|
878
|
-
const caseTexts = [];
|
|
879
1111
|
for (const c of front.data.cases) {
|
|
880
1112
|
const shown = await tracker.show(c);
|
|
881
|
-
if (shown)
|
|
882
|
-
caseTexts.push(shown.text);
|
|
883
1113
|
if (shown && recordsAbort(shown.text, id)) {
|
|
884
1114
|
return result({
|
|
885
1115
|
status: "aborted",
|
|
@@ -889,27 +1119,54 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
889
1119
|
});
|
|
890
1120
|
}
|
|
891
1121
|
}
|
|
892
|
-
// Released, or
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
if (
|
|
1122
|
+
// Released, or with no specs agreed: cupola-complete tidies up and creates one execution per
|
|
1123
|
+
// procedure, the last thing it does; the epic is operating until every execution is done.
|
|
1124
|
+
const afterRelease = async (released) => {
|
|
1125
|
+
if (procedures.length === 0)
|
|
896
1126
|
return released;
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1127
|
+
const found = await executionsFor(io, root, config, id, procedures);
|
|
1128
|
+
const each = procedures.map((runbook) => {
|
|
1129
|
+
const live = found.filter((e) => e.runbook === runbook && e.status.status !== "dropped");
|
|
1130
|
+
return { runbook, of: live.at(-1) };
|
|
1131
|
+
});
|
|
1132
|
+
const executions = each.map((e) => ({
|
|
1133
|
+
id: e.of?.id ?? null,
|
|
1134
|
+
runbook: e.runbook,
|
|
1135
|
+
status: e.of?.status.status ?? "not-created",
|
|
1136
|
+
}));
|
|
1137
|
+
const missing = each.filter((e) => !e.of).map((e) => e.runbook);
|
|
1138
|
+
if (released.next.command?.startsWith("cupola-complete "))
|
|
1139
|
+
return { ...released, executions };
|
|
1140
|
+
if (missing.length > 0) {
|
|
1141
|
+
const complete = `cupola-complete ${id}`;
|
|
1142
|
+
return {
|
|
1143
|
+
...released,
|
|
1144
|
+
status: "done",
|
|
1145
|
+
turn: "human",
|
|
1146
|
+
gate: null,
|
|
1147
|
+
executions,
|
|
1148
|
+
next: {
|
|
1149
|
+
kind: "run",
|
|
1150
|
+
text: `${specs.length > 0 ? "Released" : "Agreed"}: \`${complete}\` tidies up and creates the executions of ${missing.join(", ")}.`,
|
|
1151
|
+
command: complete,
|
|
1152
|
+
},
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
const current = each.find((e) => e.of && e.of.status.status !== "done");
|
|
1156
|
+
if (!current?.of)
|
|
1157
|
+
return { ...released, executions };
|
|
1158
|
+
const of = current.of.status;
|
|
902
1159
|
return {
|
|
903
1160
|
...released,
|
|
904
1161
|
status: "operating",
|
|
905
|
-
turn:
|
|
906
|
-
gate:
|
|
907
|
-
|
|
908
|
-
next: {
|
|
1162
|
+
turn: of.turn,
|
|
1163
|
+
gate: of.gate,
|
|
1164
|
+
executions,
|
|
1165
|
+
next: { ...of.next, text: `${current.of.id} (${of.status}): ${of.next.text}` },
|
|
909
1166
|
};
|
|
910
1167
|
};
|
|
911
1168
|
if (specs.length === 0) {
|
|
912
|
-
return
|
|
1169
|
+
return afterRelease(result({
|
|
913
1170
|
status: "done",
|
|
914
1171
|
turn: "none",
|
|
915
1172
|
gate: null,
|
|
@@ -925,10 +1182,10 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
925
1182
|
const ws = await workspace({ ...io, cwd: root });
|
|
926
1183
|
const slug = ws.repoOf(only.component);
|
|
927
1184
|
const specRoot = slug === ws.here.slug ? root : ws.checkout(slug).main;
|
|
928
|
-
const specChange = await (io.host ??
|
|
1185
|
+
const specChange = await (io.host ?? codeHost)(specRoot).findChange(workBranchName(spec));
|
|
929
1186
|
// Outside the hub, its system catalog entries came in a `system` change merged with it.
|
|
930
1187
|
const system = specChange?.state === "merged" && slug !== ws.hub.slug
|
|
931
|
-
? await (io.host ??
|
|
1188
|
+
? await (io.host ?? codeHost)(root).findChange(workBranchName(`${id}-system`))
|
|
932
1189
|
: undefined;
|
|
933
1190
|
if (system?.state === "open") {
|
|
934
1191
|
return {
|
|
@@ -939,7 +1196,7 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
939
1196
|
run: null,
|
|
940
1197
|
status: "awaiting-acceptance",
|
|
941
1198
|
turn: "human",
|
|
942
|
-
gate: "
|
|
1199
|
+
gate: "acceptance",
|
|
943
1200
|
next: {
|
|
944
1201
|
kind: "gate",
|
|
945
1202
|
text: `${spec} is merged; merge its system change too (${system.url}), then run the command.`,
|
|
@@ -959,7 +1216,7 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
959
1216
|
run: null,
|
|
960
1217
|
status: "awaiting-acceptance",
|
|
961
1218
|
turn: "human",
|
|
962
|
-
gate: "
|
|
1219
|
+
gate: "acceptance",
|
|
963
1220
|
next: {
|
|
964
1221
|
kind: "gate",
|
|
965
1222
|
text: `${spec} ${code.text}`,
|
|
@@ -971,7 +1228,7 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
971
1228
|
// Merging it released the epic; `cupola-complete <spec>` tidies up and moves the cases on.
|
|
972
1229
|
if (await untidy(ws.config.documents === "hub" ? root : specRoot, workBranchName(spec))) {
|
|
973
1230
|
const complete = `cupola-complete ${spec}`;
|
|
974
|
-
return {
|
|
1231
|
+
return afterRelease({
|
|
975
1232
|
work,
|
|
976
1233
|
spec,
|
|
977
1234
|
change: specChange,
|
|
@@ -985,9 +1242,9 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
985
1242
|
text: `Merged: \`${complete}\` tidies up and moves on.`,
|
|
986
1243
|
command: complete,
|
|
987
1244
|
},
|
|
988
|
-
};
|
|
1245
|
+
});
|
|
989
1246
|
}
|
|
990
|
-
return
|
|
1247
|
+
return afterRelease({
|
|
991
1248
|
work,
|
|
992
1249
|
spec,
|
|
993
1250
|
change: specChange,
|
|
@@ -1013,22 +1270,41 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
1013
1270
|
const each = await specsOfEpic(io, root, config, id, specs);
|
|
1014
1271
|
const movable = each.filter((s) => s.movable);
|
|
1015
1272
|
const gates = each.filter((s) => s.gate).map((s) => `${s.id} at ${s.gate}`);
|
|
1273
|
+
// A blocked spec is the human's to fix, as a gate is theirs to judge.
|
|
1274
|
+
const blocked = each
|
|
1275
|
+
.filter((s) => s.status === "blocked")
|
|
1276
|
+
.map((s) => `${s.id} blocked (${s.blocked?.blocker ?? "no reason was given"})`);
|
|
1277
|
+
const yours = [...gates, ...blocked];
|
|
1016
1278
|
const running = each.filter((s) => s.active);
|
|
1017
1279
|
const finished = each.every((s) => s.status === "done" || s.status === "dropped");
|
|
1018
1280
|
if (finished) {
|
|
1019
|
-
const accepted = await acceptance(io, root, id, specs, result);
|
|
1281
|
+
const accepted = await acceptance(io, root, config, id, specs, result);
|
|
1020
1282
|
return {
|
|
1021
|
-
...(accepted.status === "done" ?
|
|
1283
|
+
...(accepted.status === "done" ? await afterRelease(accepted) : accepted),
|
|
1022
1284
|
specs: each,
|
|
1023
1285
|
};
|
|
1024
1286
|
}
|
|
1025
1287
|
let next;
|
|
1026
1288
|
let turn;
|
|
1027
|
-
|
|
1289
|
+
// A revision to take in is the epic's run's work, as a spec to start is.
|
|
1290
|
+
const takeIn = each.filter((s) => s.takeIn);
|
|
1291
|
+
if (movable.length > 0 || takeIn.length > 0) {
|
|
1292
|
+
const work = [
|
|
1293
|
+
...takeIn.map((s) => `${s.takeIn} the change of ${s.id}`),
|
|
1294
|
+
...(movable.length > 0 ? [`run ${movable.map((s) => s.id).join(", ")}`] : []),
|
|
1295
|
+
].join(", then ");
|
|
1028
1296
|
turn = "ai";
|
|
1029
1297
|
next = {
|
|
1030
1298
|
kind: "run",
|
|
1031
|
-
text:
|
|
1299
|
+
text: `${work.charAt(0).toUpperCase()}${work.slice(1)}${yours.length > 0 ? `; waiting for you: ${yours.join(", ")}` : ""}.`,
|
|
1300
|
+
command: `cupola-epic-run ${id}`,
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
else if (gates.length === 0 && blocked.length > 0) {
|
|
1304
|
+
turn = "human";
|
|
1305
|
+
next = {
|
|
1306
|
+
kind: "run",
|
|
1307
|
+
text: `Waiting for you: ${blocked.join(", ")}. Fix that, then resume the epic's run.`,
|
|
1032
1308
|
command: `cupola-epic-run ${id}`,
|
|
1033
1309
|
};
|
|
1034
1310
|
}
|
|
@@ -1036,14 +1312,20 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
1036
1312
|
turn = "human";
|
|
1037
1313
|
next = {
|
|
1038
1314
|
kind: "gate",
|
|
1039
|
-
text: `Waiting for you: ${
|
|
1315
|
+
text: `Waiting for you: ${yours.join(", ")}; see each spec's status.`,
|
|
1040
1316
|
};
|
|
1041
1317
|
}
|
|
1042
1318
|
else if (running.length > 0) {
|
|
1043
1319
|
turn = "ai";
|
|
1320
|
+
// The epic's run's session takes over all its runners at once; a spec run by hand, its own.
|
|
1321
|
+
const ran = epicRunSession(id, running);
|
|
1322
|
+
const sessions = ran
|
|
1323
|
+
? [ran.session]
|
|
1324
|
+
: [...new Set(running.map((s) => s.active?.session ?? ""))].filter(Boolean);
|
|
1325
|
+
const takeOver = sessions.map((s) => `\`cupola-epic-run ${id} --take-over ${s}\``);
|
|
1044
1326
|
next = {
|
|
1045
1327
|
kind: "nothing",
|
|
1046
|
-
text: `Running: ${running.map((s) => `${s.id} (session ${s.active?.session})`).join(", ")}. If
|
|
1328
|
+
text: `Running: ${running.map((s) => `${s.id} (session ${s.active?.session})`).join(", ")}. If that session has ended, take it over with ${takeOver.join(" or ")}.`,
|
|
1047
1329
|
};
|
|
1048
1330
|
}
|
|
1049
1331
|
else if (each.some((s) => s.status === "waiting")) {
|
|
@@ -1061,33 +1343,40 @@ async function epicStatus(io, root, config, tree, id) {
|
|
|
1061
1343
|
text: `Nothing can move: ${each.map((s) => `${s.id} (${s.status})`).join(", ")}.`,
|
|
1062
1344
|
};
|
|
1063
1345
|
}
|
|
1064
|
-
|
|
1346
|
+
const session = epicRunSession(id, running);
|
|
1347
|
+
return {
|
|
1348
|
+
...result({ status: "in-progress", turn, gate: null, next }),
|
|
1349
|
+
specs: each,
|
|
1350
|
+
...(session ? { running: session } : {}),
|
|
1351
|
+
};
|
|
1065
1352
|
}
|
|
1353
|
+
// Only an epic with one spec gets here (two or more return above): its spec is not created yet.
|
|
1066
1354
|
return result({
|
|
1067
|
-
status:
|
|
1355
|
+
status: "ai-working",
|
|
1068
1356
|
turn: "ai",
|
|
1069
1357
|
gate: null,
|
|
1070
1358
|
next: {
|
|
1071
1359
|
kind: "run",
|
|
1072
|
-
text:
|
|
1360
|
+
text: "Agreed; create its spec and run it.",
|
|
1073
1361
|
command: `cupola-epic-run ${id}`,
|
|
1074
1362
|
},
|
|
1075
1363
|
});
|
|
1076
1364
|
}
|
|
1077
1365
|
const LABELS = {
|
|
1078
1366
|
accepting: "accepting",
|
|
1079
|
-
"awaiting-release": "awaiting release
|
|
1367
|
+
"awaiting-release": "awaiting release",
|
|
1080
1368
|
waiting: "waiting",
|
|
1081
1369
|
open: "open",
|
|
1082
|
-
"awaiting-resolution": "awaiting resolution
|
|
1370
|
+
"awaiting-resolution": "awaiting resolution",
|
|
1083
1371
|
resolved: "resolved",
|
|
1084
|
-
"awaiting-
|
|
1372
|
+
"awaiting-start": "awaiting start",
|
|
1085
1373
|
"in-progress": "in progress",
|
|
1086
1374
|
draft: "draft",
|
|
1087
1375
|
aborted: "aborted",
|
|
1088
1376
|
"ai-working": "AI working",
|
|
1089
|
-
|
|
1090
|
-
"awaiting-
|
|
1377
|
+
blocked: "blocked",
|
|
1378
|
+
"awaiting-decision": "awaiting decision",
|
|
1379
|
+
"awaiting-acceptance": "awaiting acceptance",
|
|
1091
1380
|
operating: "operating",
|
|
1092
1381
|
done: "done",
|
|
1093
1382
|
dropped: "dropped",
|
|
@@ -1095,7 +1384,7 @@ const LABELS = {
|
|
|
1095
1384
|
export function describe(r) {
|
|
1096
1385
|
const whose = r.turn === "human"
|
|
1097
1386
|
? r.gate
|
|
1098
|
-
? `your turn, at ${r.gate}`
|
|
1387
|
+
? `your turn, at the ${r.gate} gate`
|
|
1099
1388
|
: "your turn"
|
|
1100
1389
|
: r.turn === "ai"
|
|
1101
1390
|
? "the AI's turn"
|
|
@@ -1106,11 +1395,25 @@ export function describe(r) {
|
|
|
1106
1395
|
if (r.spec)
|
|
1107
1396
|
lines.push(` spec: ${r.spec}`);
|
|
1108
1397
|
for (const e of r.epics ?? [])
|
|
1109
|
-
lines.push(` epic: ${e.id} (${LABELS[e.status]}${e.judged ? ", judged not enough at
|
|
1110
|
-
if (r.
|
|
1111
|
-
lines.push(`
|
|
1398
|
+
lines.push(` epic: ${e.id} (${LABELS[e.status]}${e.judged ? ", judged not enough at resolution" : ""})`);
|
|
1399
|
+
if (r.execution)
|
|
1400
|
+
lines.push(` execution of ${r.execution.runbook} for ${r.execution.for}: ${r.execution.stopped ? `stopped at ${r.execution.stopped}` : r.execution.done.length > 0 ? `done ${r.execution.done.join(", ")}` : "no step done"}${r.execution.result ? `, ${r.execution.result}` : ""}`);
|
|
1401
|
+
for (const e of r.executions ?? [])
|
|
1402
|
+
lines.push(` execution: ${e.id ?? `${e.runbook} (not created)`}${e.id ? ` (${e.status === "not-created" ? "not created" : LABELS[e.status]})` : ""}`);
|
|
1112
1403
|
if (r.change)
|
|
1113
1404
|
lines.push(` change: ${r.change.url}${r.change.draft ? " (draft)" : ""}`);
|
|
1405
|
+
for (const a of r.ask ?? [])
|
|
1406
|
+
lines.push(` card ${a.card}: ask ${a.ask.join(", ")}`);
|
|
1407
|
+
if (r.unanswered?.length)
|
|
1408
|
+
lines.push(` never answered (taken as recommended): ${r.unanswered
|
|
1409
|
+
.map((u) => `card ${u.card}${u.recommended ? ` → ${u.recommended}` : ""}${u.ask.length > 0 ? ` (ask ${u.ask.join(", ")})` : ""}`)
|
|
1410
|
+
.join(", ")}`);
|
|
1411
|
+
for (const p of r.reactions ?? [])
|
|
1412
|
+
lines.push(` reaction not processed: ${p.kind} ${p.id} by ${p.who} (${p.at})`);
|
|
1413
|
+
if (r.tries?.length)
|
|
1414
|
+
lines.push(` tries: ${r.tries.map((n) => `try-${n}`).join(", ")}`);
|
|
1415
|
+
if (r.unread)
|
|
1416
|
+
lines.push(` reactions not read: ${r.unread}`);
|
|
1114
1417
|
if (r.run?.phase)
|
|
1115
1418
|
lines.push(` phase: ${r.run.phase}${r.run.active ? ` (running, ${r.run.active.who})` : ""}`);
|
|
1116
1419
|
lines.push(` next: ${r.next.text}${r.next.command ? ` → ${r.next.command}` : ""}`);
|
|
@@ -1122,31 +1425,27 @@ async function hubAgreed(hub) {
|
|
|
1122
1425
|
return base ? gitTree(hub, `refs/remotes/origin/${base}`) : gitTree(hub, "HEAD");
|
|
1123
1426
|
}
|
|
1124
1427
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1428
|
+
* The reactions of a work at its gate: those on its open change that people
|
|
1429
|
+
* the configuration trusts gave, and those given in a session (its files on
|
|
1430
|
+
* `tree`); the ones not processed yet, the tries built, and why the change's
|
|
1431
|
+
* could not be read, if they could not — then none of them is processed, and
|
|
1432
|
+
* the status says so rather than showing none.
|
|
1128
1433
|
*/
|
|
1129
|
-
export async function
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
return fromPeople(feedback, reviewer, config.trust).length;
|
|
1138
|
-
}
|
|
1139
|
-
catch {
|
|
1140
|
-
// Feedback that cannot be read (too much of it) sends nothing back; the dialogue still can.
|
|
1141
|
-
return 0;
|
|
1142
|
-
}
|
|
1434
|
+
export async function gateReactions(root, host, change, tree, id, config) {
|
|
1435
|
+
const fromHost = change?.state === "open" ? await hostReactions(host, change, config) : { reactions: [] };
|
|
1436
|
+
const all = [...fromHost.reactions, ...(await sessionReactions(tree, id))].sort((a, b) => a.at.localeCompare(b.at));
|
|
1437
|
+
return {
|
|
1438
|
+
reactions: pendingOf(all),
|
|
1439
|
+
tries: await triesOf(root, id),
|
|
1440
|
+
...(fromHost.unread ? { unread: fromHost.unread } : {}),
|
|
1441
|
+
};
|
|
1143
1442
|
}
|
|
1144
1443
|
/**
|
|
1145
1444
|
* Whether a merged work's own worktree is still here: `cupola-complete` removes
|
|
1146
1445
|
* it last, so one left means it has not run. The main checkout is not the work's,
|
|
1147
1446
|
* even with the branch checked out there.
|
|
1148
1447
|
*/
|
|
1149
|
-
async function untidy(cwd, branch) {
|
|
1448
|
+
export async function untidy(cwd, branch) {
|
|
1150
1449
|
try {
|
|
1151
1450
|
await git(cwd, ["worktree", "prune"]);
|
|
1152
1451
|
const blocks = (await git(cwd, ["worktree", "list", "--porcelain"])).split("\n\n").slice(1);
|