@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/trace.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { checkAdrs } from "../adr.js";
|
|
5
5
|
import { behaviorDirs, loadCatalog, renderIndex } from "../catalog.js";
|
|
6
6
|
import { checkCatalog, checkFixCatalog, checkFixMarkers, checkIndexes, checkOrphans, checkPlaceholders, checkStrayCatalog, } from "../check.js";
|
|
7
|
-
import { loadConfig, resolveComponents } from "../config.js";
|
|
7
|
+
import { EPIC_FILE, epicCardsDir, epicPath, loadConfig, resolveComponents, } from "../config.js";
|
|
8
8
|
import { checkProfile, E2E_PROFILE } from "../e2e.js";
|
|
9
9
|
import { checkEpic, parseEpic } from "../epic.js";
|
|
10
|
+
import { checkExecution } from "../execution.js";
|
|
10
11
|
import { git, originDefaultBranch } from "../git.js";
|
|
11
12
|
import { repoRoot } from "../repo.js";
|
|
12
|
-
import { checkRunbook } from "../runbook.js";
|
|
13
|
+
import { checkRunbook, executionsDir, parseRunbook, RUNBOOK_FILE, RunbookFront, runbookPath, } from "../runbook.js";
|
|
13
14
|
import { writeInside } from "../safe-write.js";
|
|
14
15
|
import { buildTrace, findAllMarkers, readReports, } from "../trace.js";
|
|
15
16
|
import { fsTree, gitTree } from "../tree.js";
|
|
16
|
-
import { findSpecDocument } from "../work.js";
|
|
17
|
+
import { findSpecDocument, readCardsIn } from "../work.js";
|
|
17
18
|
import { checkoutDirs, identifyRepo, workspace } from "../workspace.js";
|
|
18
19
|
/**
|
|
19
20
|
* `cupola trace [<area>] [--index]`: the map requirement → tests → latest
|
|
@@ -118,27 +119,25 @@ async function epicExamples(root, config) {
|
|
|
118
119
|
if (ws && !ws.here.isHub) {
|
|
119
120
|
const base = await originDefaultBranch(ws.hub.main);
|
|
120
121
|
const tree = gitTree(ws.hub.main, base ? `refs/remotes/origin/${base}` : "HEAD");
|
|
121
|
-
files = (await tree.
|
|
122
|
-
name:
|
|
123
|
-
read: () => tree.read(
|
|
122
|
+
files = (await tree.dirs(epics)).map((id) => ({
|
|
123
|
+
name: id,
|
|
124
|
+
read: () => tree.read(epicPath(config.paths, id)),
|
|
124
125
|
}));
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
name: f,
|
|
132
|
-
read: () => readFile(join(dir, f), "utf8"),
|
|
128
|
+
const here = fsTree(root);
|
|
129
|
+
files = (await here.dirs(epics)).map((id) => ({
|
|
130
|
+
name: id,
|
|
131
|
+
read: () => here.read(epicPath(config.paths, id)),
|
|
133
132
|
}));
|
|
134
133
|
}
|
|
135
|
-
for (const f of files
|
|
134
|
+
for (const f of files) {
|
|
136
135
|
const byId = new Map();
|
|
137
136
|
for (const e of parseEpic((await f.read()) ?? "").entries) {
|
|
138
137
|
const examples = e.fields.find((x) => x.key === "examples")?.value ?? "";
|
|
139
138
|
byId.set(e.id, examples.split(/[,\s]+/).filter((x) => /^X\d+$/.test(x)));
|
|
140
139
|
}
|
|
141
|
-
out.set(f.name
|
|
140
|
+
out.set(f.name, byId);
|
|
142
141
|
}
|
|
143
142
|
return out;
|
|
144
143
|
}
|
|
@@ -160,13 +159,68 @@ async function checkEpics(root, config) {
|
|
|
160
159
|
if (!existsSync(dir) || (await hubEpics(root, config)))
|
|
161
160
|
return [];
|
|
162
161
|
const components = resolveComponents(config).map((c) => c.name);
|
|
163
|
-
const
|
|
164
|
-
const runbooks = new
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
const here = fsTree(root);
|
|
163
|
+
const runbooks = new Map();
|
|
164
|
+
for (const id of await here.dirs(config.paths.runbooks)) {
|
|
165
|
+
const raw = await here.read(runbookPath(config.paths, id));
|
|
166
|
+
if (raw === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
const front = RunbookFront.safeParse(parseRunbook(raw).front);
|
|
169
|
+
runbooks.set(id, front.success ? Object.keys(front.data.params) : []);
|
|
170
|
+
}
|
|
171
|
+
const problems = [];
|
|
172
|
+
// An epic is a folder: its document and its cards.
|
|
173
|
+
for (const f of (await here.list(epics)).filter((f) => f.endsWith(".md")).sort()) {
|
|
174
|
+
problems.push({
|
|
175
|
+
file: `${epics}/${f}`,
|
|
176
|
+
message: `an epic is a folder: move it to ${epics}/${f.slice(0, -3)}/${EPIC_FILE}`,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
for (const id of (await here.dirs(epics)).sort()) {
|
|
180
|
+
const path = epicPath(config.paths, id);
|
|
181
|
+
const text = await here.read(path);
|
|
182
|
+
if (text === undefined) {
|
|
183
|
+
problems.push({
|
|
184
|
+
file: `${epics}/${id}`,
|
|
185
|
+
message: `no ${EPIC_FILE}: an epic's folder holds it`,
|
|
186
|
+
});
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
problems.push(...checkEpic(path, text, components, runbooks));
|
|
190
|
+
problems.push(...(await checkEpicCards(root, epicCardsDir(config.paths, id))));
|
|
191
|
+
}
|
|
192
|
+
return problems;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* An epic's decision cards: numbered files `<n>-<slug>.md`, each a `decision`
|
|
196
|
+
* whose options all continue — at the start gate an answer is reflected in the epic, it
|
|
197
|
+
* starts or ends nothing. Open cards are no problem: the start gate is where they are answered.
|
|
198
|
+
*/
|
|
199
|
+
async function checkEpicCards(root, dir) {
|
|
167
200
|
const problems = [];
|
|
168
|
-
|
|
169
|
-
|
|
201
|
+
let cards;
|
|
202
|
+
try {
|
|
203
|
+
cards = await readCardsIn(fsTree(root), dir);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
return [{ file: dir, message: error.message }];
|
|
207
|
+
}
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
for (const c of cards) {
|
|
210
|
+
const file = `${dir}/${c.file}`;
|
|
211
|
+
if (seen.has(c.card))
|
|
212
|
+
problems.push({ file, message: `card ${c.card} is numbered twice` });
|
|
213
|
+
seen.add(c.card);
|
|
214
|
+
if (!c.file.startsWith(`${c.card}-`))
|
|
215
|
+
problems.push({ file, message: `card ${c.card}: its file name starts with ${c.card}-` });
|
|
216
|
+
if (c.type !== "decision")
|
|
217
|
+
problems.push({ file, message: `an epic's card is a decision, not ${c.type}` });
|
|
218
|
+
const other = (c.offers ?? []).filter((e) => e !== "continue");
|
|
219
|
+
if (other.length > 0)
|
|
220
|
+
problems.push({
|
|
221
|
+
file,
|
|
222
|
+
message: `an epic's card only continues (its answer is reflected in the epic), not ${other.join(", ")}`,
|
|
223
|
+
});
|
|
170
224
|
}
|
|
171
225
|
return problems;
|
|
172
226
|
}
|
|
@@ -178,8 +232,34 @@ async function checkRunbooks(root, config) {
|
|
|
178
232
|
return [];
|
|
179
233
|
const components = resolveComponents(config).map((c) => c.name);
|
|
180
234
|
const problems = [];
|
|
181
|
-
|
|
182
|
-
|
|
235
|
+
const here = fsTree(root);
|
|
236
|
+
// A runbook is a folder: its document and its executions.
|
|
237
|
+
for (const f of (await here.list(runbooks)).filter((f) => f.endsWith(".md")).sort()) {
|
|
238
|
+
problems.push({
|
|
239
|
+
file: `${runbooks}/${f}`,
|
|
240
|
+
message: `a runbook is a folder: move it to ${runbooks}/${f.slice(0, -3)}/${RUNBOOK_FILE}`,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
for (const id of (await here.dirs(runbooks)).sort()) {
|
|
244
|
+
const path = runbookPath(config.paths, id);
|
|
245
|
+
const raw = await here.read(path);
|
|
246
|
+
if (raw === undefined) {
|
|
247
|
+
problems.push({
|
|
248
|
+
file: `${runbooks}/${id}`,
|
|
249
|
+
message: `no ${RUNBOOK_FILE}: a runbook's folder holds it`,
|
|
250
|
+
});
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
problems.push(...checkRunbook(path, raw, components));
|
|
254
|
+
const steps = parseRunbook(raw).steps.map((s) => s.id);
|
|
255
|
+
const dir = executionsDir(config.paths, id);
|
|
256
|
+
for (const f of (await here.list(dir)).sort()) {
|
|
257
|
+
if (!/^\d+\.md$/.test(f)) {
|
|
258
|
+
problems.push({ file: `${dir}/${f}`, message: "an execution is numbered: <n>.md" });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
problems.push(...checkExecution(`${dir}/${f}`, (await here.read(`${dir}/${f}`)) ?? "", steps));
|
|
262
|
+
}
|
|
183
263
|
}
|
|
184
264
|
return problems;
|
|
185
265
|
}
|
|
@@ -197,10 +277,7 @@ async function checkEpicRefs(root, config, refs) {
|
|
|
197
277
|
const dir = join(root, config.paths.epics);
|
|
198
278
|
if (!existsSync(dir))
|
|
199
279
|
return [];
|
|
200
|
-
return checkRefsIn(refs, config,
|
|
201
|
-
const path = join(dir, `${epicId}.md`);
|
|
202
|
-
return existsSync(path) ? readFile(path, "utf8") : undefined;
|
|
203
|
-
});
|
|
280
|
+
return checkRefsIn(refs, config, (epicId) => fsTree(root).read(epicPath(config.paths, epicId)));
|
|
204
281
|
}
|
|
205
282
|
/**
|
|
206
283
|
* Outside the hub, the epics are the hub's agreed ones: its origin's
|
|
@@ -212,7 +289,7 @@ async function hubEpics(root, config) {
|
|
|
212
289
|
return undefined;
|
|
213
290
|
const base = await originDefaultBranch(ws.hub.main);
|
|
214
291
|
const tree = gitTree(ws.hub.main, base ? `refs/remotes/origin/${base}` : "HEAD");
|
|
215
|
-
return (epic) => tree.read(
|
|
292
|
+
return (epic) => tree.read(epicPath(config.paths, epic));
|
|
216
293
|
}
|
|
217
294
|
async function checkRefsIn(refs, config, read) {
|
|
218
295
|
const epics = new Map();
|
|
@@ -239,7 +316,7 @@ async function checkRefsIn(refs, config, read) {
|
|
|
239
316
|
problems.push({
|
|
240
317
|
file: m.file,
|
|
241
318
|
line: m.line,
|
|
242
|
-
message: `@req ${m.ref}: no ${config.paths
|
|
319
|
+
message: `@req ${m.ref}: no ${epicPath(config.paths, epicId)}`,
|
|
243
320
|
});
|
|
244
321
|
else if (!ids.has(id)) {
|
|
245
322
|
problems.push({
|
package/dist/commands/wait.js
CHANGED
|
@@ -3,7 +3,7 @@ import { MissingWorkError } from "../work.js";
|
|
|
3
3
|
import { workspace } from "../workspace.js";
|
|
4
4
|
import { caseStatus, describe, workStatus } from "./status.js";
|
|
5
5
|
/** The gates of an epic's lifecycle a session waits on: the human merges, then the work goes on. */
|
|
6
|
-
const WAITED = ["
|
|
6
|
+
const WAITED = ["start", "acceptance", "release"];
|
|
7
7
|
const INTERVAL_S = 60;
|
|
8
8
|
/** Readings that fail in a row before the wait gives up: the code host is gone, not slow. */
|
|
9
9
|
const FAILURES = 10;
|
|
@@ -21,11 +21,14 @@ function key(r) {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* `cupola wait <work> [--timeout <s>] [--interval <s>]`: waits, without a
|
|
24
|
-
* model running, until a work item at a gate of its epic's lifecycle (
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* model running, until a work item at a gate of its epic's lifecycle (start,
|
|
25
|
+
* acceptance, release) moves on — the human merged, reacted (a comment, a try, a No-Go: its
|
|
26
|
+
* next is then `cupola-respond`, which the waiting session runs), or closed
|
|
27
|
+
* it — and prints its new status. A work at a gate with reactions not
|
|
28
|
+
* processed yet is not waited on: they are processed first. Nor is a work at
|
|
29
|
+
* no such gate: running,
|
|
30
|
+
* done, awaiting a decision (answered in the session), blocked (the human fixes it, then
|
|
31
|
+
* resumes the run), or a case (resolution is the case's own, judged later).
|
|
29
32
|
*/
|
|
30
33
|
export async function wait(io, id, opts) {
|
|
31
34
|
const timeout = seconds(opts.timeout, "--timeout");
|
|
@@ -44,19 +47,19 @@ export async function wait(io, id, opts) {
|
|
|
44
47
|
catch (error) {
|
|
45
48
|
if (!(error instanceof MissingWorkError))
|
|
46
49
|
throw error;
|
|
47
|
-
// A case, not a work item: its
|
|
50
|
+
// A case, not a work item: its resolution is the case's own gate, judged later.
|
|
48
51
|
const found = await caseStatus(io, root, ws.config, id);
|
|
49
52
|
if (!found)
|
|
50
53
|
throw error;
|
|
51
54
|
io.out(opts.json
|
|
52
55
|
? JSON.stringify({ waited: false, changed: false, next: found.next, status: found })
|
|
53
|
-
: `nothing to wait for; a case's
|
|
56
|
+
: `nothing to wait for; a case's resolution is judged later. ${describe(found)}`);
|
|
54
57
|
return 0;
|
|
55
58
|
}
|
|
56
59
|
const out = (result, s, next = s.next) => io.out(opts.json
|
|
57
60
|
? JSON.stringify({ ...result, next, status: s })
|
|
58
61
|
: `${result.changed ? "moved on" : result.timedOut ? "timed out; still" : "nothing to wait for;"} ${describe(s)}${next !== s.next ? `\nnext: ${next.command}` : ""}`);
|
|
59
|
-
if (first.turn !== "human" || !WAITED.includes(first.gate
|
|
62
|
+
if (first.turn !== "human" || !(first.gate && WAITED.includes(first.gate))) {
|
|
60
63
|
out({ waited: false, changed: false }, first);
|
|
61
64
|
return 0;
|
|
62
65
|
}
|
|
@@ -86,9 +89,9 @@ export async function wait(io, id, opts) {
|
|
|
86
89
|
continue;
|
|
87
90
|
}
|
|
88
91
|
if (key(current) !== key(first)) {
|
|
89
|
-
// Merged at
|
|
92
|
+
// Merged at acceptance or release: what follows is the gate's own command (merge it, then run it),
|
|
90
93
|
// though the status, derived from the merge alone, says there is nothing left.
|
|
91
|
-
const merged = first.gate !== "
|
|
94
|
+
const merged = first.gate !== "start" && current.change?.state === "merged" && first.next.command
|
|
92
95
|
? {
|
|
93
96
|
kind: "run",
|
|
94
97
|
text: `Merged: ${first.next.command}.`,
|
package/dist/commands/work.js
CHANGED
|
@@ -7,7 +7,7 @@ import { repoRoot } from "../repo.js";
|
|
|
7
7
|
import { trackerFor } from "../tracker/index.js";
|
|
8
8
|
import { fromDraft } from "../tracker/tracker.js";
|
|
9
9
|
import { workspace } from "../workspace.js";
|
|
10
|
-
import { caseStatus, notSolvedMarker } from "./status.js";
|
|
10
|
+
import { caseStatus, judgedEpics, notSolvedMarker } from "./status.js";
|
|
11
11
|
export async function trackerOf(io) {
|
|
12
12
|
// Cases live in the hub: from another repository, through the hub's checkout.
|
|
13
13
|
const ws = await workspace(io);
|
|
@@ -63,7 +63,7 @@ export async function workLog(io, id, opts) {
|
|
|
63
63
|
return 0;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* `cupola work close <case> --body-file <f>`:
|
|
66
|
+
* `cupola work close <case> --body-file <f>`: resolution found the problem gone. The
|
|
67
67
|
* human's words go to the Log, and the case is closed.
|
|
68
68
|
*/
|
|
69
69
|
export async function workClose(io, id, opts) {
|
|
@@ -76,8 +76,8 @@ export async function workClose(io, id, opts) {
|
|
|
76
76
|
const ready = opts.withoutEpic ? "open" : "awaiting-resolution";
|
|
77
77
|
if (found.status !== "resolved" && found.status !== ready) {
|
|
78
78
|
throw new Error(opts.withoutEpic
|
|
79
|
-
? `${caseId} is ${found.status}: only a case no
|
|
80
|
-
: `${caseId} is ${found.status}: a case is closed at
|
|
79
|
+
? `${caseId} is ${found.status}: only a case no epic works on is closed without one`
|
|
80
|
+
: `${caseId} is ${found.status}: a case is closed at resolution, once its epics are done (one that needs no work: --without-epic)`);
|
|
81
81
|
}
|
|
82
82
|
const day = await today(io);
|
|
83
83
|
const closed = found.status === "resolved"
|
|
@@ -91,7 +91,7 @@ export async function workClose(io, id, opts) {
|
|
|
91
91
|
return 0;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
* `cupola work reopen <case> --body-file <f>`:
|
|
94
|
+
* `cupola work reopen <case> --body-file <f>`: resolution found the problem not gone.
|
|
95
95
|
* The reason goes to the Log with the epics judged, which then no longer
|
|
96
96
|
* count, so the case is open again.
|
|
97
97
|
*/
|
|
@@ -102,7 +102,12 @@ export async function workReopen(io, id, opts) {
|
|
|
102
102
|
if (!found)
|
|
103
103
|
throw new Error(`no case ${id}`);
|
|
104
104
|
const caseId = found.work.id;
|
|
105
|
-
|
|
105
|
+
// Its epics and executions alike: the marker names each work judged.
|
|
106
|
+
const judgedBefore = judgedEpics((await (await trackerOf(io)).show(caseId))?.text ?? "");
|
|
107
|
+
const epics = [
|
|
108
|
+
...(found.epics ?? []),
|
|
109
|
+
...(found.executions ?? []).flatMap((e) => e.id ? [{ id: e.id, status: e.status, judged: judgedBefore.has(e.id) }] : []),
|
|
110
|
+
];
|
|
106
111
|
// Run again after a lost answer: every done epic is judged, and the case is open.
|
|
107
112
|
if (found.status === "open" && epics.some((e) => e.status === "done" && e.judged)) {
|
|
108
113
|
const left = epics.filter((e) => e.status === "done" && !e.judged);
|
|
@@ -112,7 +117,7 @@ export async function workReopen(io, id, opts) {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
if (found.status !== "awaiting-resolution") {
|
|
115
|
-
throw new Error(`${caseId} is ${found.status}: a case is judged at
|
|
120
|
+
throw new Error(`${caseId} is ${found.status}: a case is judged at resolution, once all its epics are done`);
|
|
116
121
|
}
|
|
117
122
|
const judged = epics.filter((e) => e.status === "done" && !e.judged).map((e) => e.id);
|
|
118
123
|
await (await trackerOf(io)).log(caseId, `${await today(io)} not solved yet after ${judged.join(", ")}: ${line} ${notSolvedMarker(judged)}`);
|
|
@@ -3,9 +3,10 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { appendFile, mkdir, readdir, readFile, stat } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
+
import { cloneUrlOf } from "../config.js";
|
|
6
7
|
import { git } from "../git.js";
|
|
7
8
|
import { repoOf } from "../host/github.js";
|
|
8
|
-
import { checkoutDirs, cloneDir, workspaceOfHub } from "../workspace.js";
|
|
9
|
+
import { checkoutDirs, cloneDir, sameUrl, workspaceOfHub } from "../workspace.js";
|
|
9
10
|
const run = promisify(execFile);
|
|
10
11
|
/** The clone URL of a repository, from the hub's: the same host and form, another `owner/name`. */
|
|
11
12
|
export function cloneUrl(hubUrl, slug) {
|
|
@@ -42,7 +43,12 @@ export async function workspaceSetup(io, opts) {
|
|
|
42
43
|
let cloned = false;
|
|
43
44
|
if (!existsSync(dir)) {
|
|
44
45
|
try {
|
|
45
|
-
await run("git", [
|
|
46
|
+
await run("git", [
|
|
47
|
+
"clone",
|
|
48
|
+
"--quiet",
|
|
49
|
+
cloneUrlOf(ws.config, slug) ?? cloneUrl(hubUrl, slug),
|
|
50
|
+
dir,
|
|
51
|
+
]);
|
|
46
52
|
cloned = true;
|
|
47
53
|
}
|
|
48
54
|
catch (error) {
|
|
@@ -54,10 +60,15 @@ export async function workspaceSetup(io, opts) {
|
|
|
54
60
|
results.push({ repo: slug, dir, cloned, problem: `${dir} exists and is not a git checkout` });
|
|
55
61
|
continue;
|
|
56
62
|
}
|
|
57
|
-
const
|
|
63
|
+
const originUrl = await git(dir, ["remote", "get-url", "origin"]).catch(() => "");
|
|
64
|
+
const origin = repoOf(originUrl);
|
|
58
65
|
const named = await git(dir, ["config", "--get", "cupola.repo"]).catch(() => "");
|
|
59
|
-
const local = /^(\/|file:|\.)/.test(
|
|
60
|
-
|
|
66
|
+
const local = /^(\/|file:|\.)/.test(originUrl);
|
|
67
|
+
const byUrl = sameUrl(cloneUrlOf(ws.config, slug), originUrl);
|
|
68
|
+
if (!local &&
|
|
69
|
+
!byUrl &&
|
|
70
|
+
origin !== slug.toLowerCase() &&
|
|
71
|
+
named.toLowerCase() !== slug.toLowerCase()) {
|
|
61
72
|
results.push({
|
|
62
73
|
repo: slug,
|
|
63
74
|
dir,
|
|
@@ -2,7 +2,7 @@ import { existsSync, realpathSync } from "node:fs";
|
|
|
2
2
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { mountWork } from "../code.js";
|
|
4
4
|
import { git, originDefaultBranch } from "../git.js";
|
|
5
|
-
import {
|
|
5
|
+
import { codeHost } from "../host/index.js";
|
|
6
6
|
import { assertWorkId, workBranchName } from "../work.js";
|
|
7
7
|
import { locateWork, workspace } from "../workspace.js";
|
|
8
8
|
/** The main checkout of the repository the work lives in. */
|
|
@@ -169,7 +169,7 @@ export async function worktreeRemove(io, id, opts) {
|
|
|
169
169
|
// An epic branch is removed once its release change is merged.
|
|
170
170
|
const branch = opts.epicBranch ? `epic/${id}` : workBranchName(id);
|
|
171
171
|
const { main, ws } = await workCheckout(io, id, branch, opts.epicBranch ? undefined : opts.component);
|
|
172
|
-
const change = await (io.host ??
|
|
172
|
+
const change = await (io.host ?? codeHost)(main).findChange(branch);
|
|
173
173
|
if (change?.state !== "merged" && change?.state !== "closed") {
|
|
174
174
|
throw new Error(`${id}'s change is ${change ? change.state : "not opened"}; worktrees are removed after the merge`);
|
|
175
175
|
}
|
|
@@ -351,7 +351,7 @@ async function epicBranchRepos(io, ws, id) {
|
|
|
351
351
|
out.push({
|
|
352
352
|
slug,
|
|
353
353
|
main,
|
|
354
|
-
change: (await (io.host ??
|
|
354
|
+
change: (await (io.host ?? codeHost)(main).findChange(`epic/${id}`)) ?? undefined,
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
357
|
return out;
|
package/dist/config.js
CHANGED
|
@@ -24,6 +24,15 @@ const component = z.strictObject({
|
|
|
24
24
|
.optional(),
|
|
25
25
|
role: z.string().min(1),
|
|
26
26
|
});
|
|
27
|
+
/** A code host adapter: GitHub, or plain git, which needs nothing but the repository's origin. */
|
|
28
|
+
export const HOST_KINDS = ["github", "git"];
|
|
29
|
+
const host = z.strictObject({ kind: z.enum(HOST_KINDS) });
|
|
30
|
+
/** What a repository has of its own, apart from the project's: its host, and where it is cloned from. */
|
|
31
|
+
const repository = z.strictObject({
|
|
32
|
+
host: host.optional(),
|
|
33
|
+
/** The clone URL, when it is not the hub's with another `owner/name` (another host). */
|
|
34
|
+
url: z.string().min(1).optional(),
|
|
35
|
+
});
|
|
27
36
|
const board = z.strictObject({
|
|
28
37
|
kind: z.literal("github-projects"),
|
|
29
38
|
owner: z.string().min(1),
|
|
@@ -85,7 +94,10 @@ export const configSchema = z
|
|
|
85
94
|
.optional(),
|
|
86
95
|
hub: repoSlug,
|
|
87
96
|
components: z.array(component).min(1),
|
|
88
|
-
host
|
|
97
|
+
/** The code host of every repository that does not name its own in `repositories`. */
|
|
98
|
+
host,
|
|
99
|
+
/** Per repository (`owner/name`): its own host and clone URL. */
|
|
100
|
+
repositories: z.record(repoSlug, repository).default({}),
|
|
89
101
|
tracker: z.strictObject({ kind: z.enum(["github-issues", "files"]) }),
|
|
90
102
|
engine: z.strictObject({ kind: z.literal("cc-sdd") }),
|
|
91
103
|
board: board.optional(),
|
|
@@ -151,6 +163,35 @@ export const configSchema = z
|
|
|
151
163
|
}
|
|
152
164
|
places.add(place);
|
|
153
165
|
});
|
|
166
|
+
const repos = [config.hub, ...config.components.map((c) => c.repo ?? config.hub)].map((r) => r.toLowerCase());
|
|
167
|
+
for (const slug of Object.keys(config.repositories)) {
|
|
168
|
+
if (!repos.includes(slug.toLowerCase()))
|
|
169
|
+
ctx.addIssue({
|
|
170
|
+
code: "custom",
|
|
171
|
+
path: ["repositories", slug],
|
|
172
|
+
message: "is neither the hub nor a component's repository",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const hubKind = hostKindOf(config, config.hub);
|
|
176
|
+
if (config.tracker.kind === "github-issues" && hubKind !== "github")
|
|
177
|
+
ctx.addIssue({
|
|
178
|
+
code: "custom",
|
|
179
|
+
path: ["tracker", "kind"],
|
|
180
|
+
message: `github-issues needs the hub on GitHub; its host is ${hubKind}: use files`,
|
|
181
|
+
});
|
|
182
|
+
if (config.board && hubKind !== "github")
|
|
183
|
+
ctx.addIssue({
|
|
184
|
+
code: "custom",
|
|
185
|
+
path: ["board"],
|
|
186
|
+
message: `a GitHub project needs the hub on GitHub; its host is ${hubKind}`,
|
|
187
|
+
});
|
|
188
|
+
const plain = [...new Set(repos)].filter((r) => hostKindOf(config, r) === "git");
|
|
189
|
+
if (plain.length > 0 && config.review.reviewer !== "subagent")
|
|
190
|
+
ctx.addIssue({
|
|
191
|
+
code: "custom",
|
|
192
|
+
path: ["review", "reviewer"],
|
|
193
|
+
message: `${plain.join(", ")} ${plain.length > 1 ? "are" : "is"} on a git host, which has no reviewer to ask: use subagent`,
|
|
194
|
+
});
|
|
154
195
|
if (config.documents !== "hub")
|
|
155
196
|
return;
|
|
156
197
|
// Code repositories are mounted in the hub's tree by their names: each name is its own place
|
|
@@ -204,6 +245,19 @@ export function resolveComponents(config) {
|
|
|
204
245
|
};
|
|
205
246
|
});
|
|
206
247
|
}
|
|
248
|
+
/** What `repositories` says of a repository, matched case-insensitively. */
|
|
249
|
+
function repositoryOf(config, slug) {
|
|
250
|
+
const key = Object.keys(config.repositories).find((k) => k.toLowerCase() === slug.toLowerCase());
|
|
251
|
+
return key === undefined ? undefined : config.repositories[key];
|
|
252
|
+
}
|
|
253
|
+
/** The code host of a repository: its own, or the project's. */
|
|
254
|
+
export function hostKindOf(config, slug) {
|
|
255
|
+
return repositoryOf(config, slug)?.host?.kind ?? config.host.kind;
|
|
256
|
+
}
|
|
257
|
+
/** The clone URL a repository names for itself, if any. */
|
|
258
|
+
export function cloneUrlOf(config, slug) {
|
|
259
|
+
return repositoryOf(config, slug)?.url;
|
|
260
|
+
}
|
|
207
261
|
/** The directory a repository is cloned into under the hub: its last path segment. */
|
|
208
262
|
export function cloneName(slug) {
|
|
209
263
|
return slug.split("/")[1] ?? slug;
|
|
@@ -283,7 +337,17 @@ export async function pathsAt(root) {
|
|
|
283
337
|
throw error;
|
|
284
338
|
}
|
|
285
339
|
}
|
|
340
|
+
/** The name of an epic's document inside its folder. */
|
|
341
|
+
export const EPIC_FILE = "epic.md";
|
|
342
|
+
/** An epic's folder, relative to the hub's root: its document and its cards. */
|
|
343
|
+
export function epicDir(paths, epic) {
|
|
344
|
+
return `${paths.epics}/${epic}`;
|
|
345
|
+
}
|
|
286
346
|
/** The path of an epic's document, relative to the hub's root. */
|
|
287
347
|
export function epicPath(paths, epic) {
|
|
288
|
-
return `${paths
|
|
348
|
+
return `${epicDir(paths, epic)}/${EPIC_FILE}`;
|
|
349
|
+
}
|
|
350
|
+
/** Where an epic's decision cards are, relative to the hub's root. */
|
|
351
|
+
export function epicCardsDir(paths, epic) {
|
|
352
|
+
return `${epicDir(paths, epic)}/cards`;
|
|
289
353
|
}
|
package/dist/epic.js
CHANGED
|
@@ -23,9 +23,15 @@ export const EpicFront = z
|
|
|
23
23
|
after: z.array(z.string()).optional(),
|
|
24
24
|
}))
|
|
25
25
|
.default([]),
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Runbooks carried out after the specs are released (or, with no specs, once
|
|
28
|
+
* agreed), in this order: one execution each, given these params.
|
|
29
|
+
*/
|
|
27
30
|
procedures: z
|
|
28
|
-
.array(z.strictObject({
|
|
31
|
+
.array(z.strictObject({
|
|
32
|
+
runbook: z.string().regex(KEBAB, "runbook ids are kebab-case"),
|
|
33
|
+
params: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
|
34
|
+
}))
|
|
29
35
|
.default([]),
|
|
30
36
|
})
|
|
31
37
|
.refine((f) => f.specs.length + f.procedures.length > 0, {
|
|
@@ -163,7 +169,7 @@ const CATALOG_ID = /^[a-z0-9-]+\.[a-z0-9-]+$/;
|
|
|
163
169
|
* the skill reads from the tracker.
|
|
164
170
|
*/
|
|
165
171
|
export function checkEpic(file, raw, components,
|
|
166
|
-
/** The runbooks in the hub, when known. */
|
|
172
|
+
/** The runbooks in the hub, when known, each with the params it declares. */
|
|
167
173
|
runbooks) {
|
|
168
174
|
const problems = [];
|
|
169
175
|
const p = (message, line) => problems.push({ file, ...(line ? { line } : {}), message });
|
|
@@ -181,9 +187,10 @@ runbooks) {
|
|
|
181
187
|
p(`front matter ${issue.path.join(".") || "(root)"}: ${issue.message}`);
|
|
182
188
|
}
|
|
183
189
|
const fm = front.success ? front.data : undefined;
|
|
184
|
-
|
|
190
|
+
// The epic's folder is named by its id: `<id>/epic.md`.
|
|
191
|
+
const name = file.split("/").at(-2);
|
|
185
192
|
if (fm && fm.id !== name)
|
|
186
|
-
p(`id is ${fm.id}, but the
|
|
193
|
+
p(`id is ${fm.id}, but the epic's folder is ${name}`);
|
|
187
194
|
const specComponents = fm?.specs.map((s) => s.component) ?? [];
|
|
188
195
|
const procedures = fm?.procedures.map((r) => r.runbook) ?? [];
|
|
189
196
|
procedures.forEach((r, i) => {
|
|
@@ -192,6 +199,18 @@ runbooks) {
|
|
|
192
199
|
if (runbooks && !runbooks.has(r))
|
|
193
200
|
p(`procedures: no runbook ${r}`);
|
|
194
201
|
});
|
|
202
|
+
for (const r of fm?.procedures ?? []) {
|
|
203
|
+
const declared = runbooks?.get(r.runbook);
|
|
204
|
+
if (!declared)
|
|
205
|
+
continue;
|
|
206
|
+
const given = Object.keys(r.params ?? {});
|
|
207
|
+
const missing = declared.filter((k) => !given.includes(k));
|
|
208
|
+
const unknown = given.filter((k) => !declared.includes(k));
|
|
209
|
+
if (missing.length > 0)
|
|
210
|
+
p(`procedures: ${r.runbook} needs params ${missing.join(", ")}`);
|
|
211
|
+
if (unknown.length > 0)
|
|
212
|
+
p(`procedures: ${r.runbook} has no params ${unknown.join(", ")}`);
|
|
213
|
+
}
|
|
195
214
|
for (const s of fm?.specs ?? []) {
|
|
196
215
|
if (!components.includes(s.component))
|
|
197
216
|
p(`specs: ${s.component} is not a configured component`);
|