@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: reaction
|
|
3
|
+
method: 1
|
|
4
|
+
reaction: {{n}} # 1, 2, … within this work; the file is <n>.md
|
|
5
|
+
type: {{comment | try | no-go}}
|
|
6
|
+
who: {{who gave it: a login or a name}}
|
|
7
|
+
at: {{ISO 8601 time it was given}}
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<!--
|
|
11
|
+
A reaction given in a session outside a gate (while a run goes on), or to a work whose host takes none, kept in
|
|
12
|
+
.cupola/runs/<work>/reactions/ until the next gate processes it. Written by `cupola reaction add`; the gate that
|
|
13
|
+
processes it removes the file (`cupola reaction reply`), so a file here is always unprocessed. Only a No-Go
|
|
14
|
+
changes the work; a comment is answered; a try is built by cupola-try.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
{{The person's words, quoted as given. Empty for a No-Go given without any.}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "Progress record. Written only by `cupola run record` (and `cupola run next` for the marker); agents never edit it by hand. Lives on the work's branch, removed in the last commit before the change is marked ready (for an epic's own record, before
|
|
2
|
+
"$comment": "Progress record. Written only by `cupola run record` (and `cupola run next` for the marker); agents never edit it by hand. Lives on the work's branch, removed in the last commit before the change is marked ready (for an epic's own record, before release). `phases` is the method's phase table for the work's mode: full is shown here, and in full mode `accept` is `skipped` unless the epic has one spec. Mode `epic` (an epic with two or more specs): `accept`, `open-release`.",
|
|
3
3
|
"kind": "record",
|
|
4
4
|
"method": 1,
|
|
5
5
|
"work": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"component": "{{component}}",
|
|
10
10
|
"mode": "{{full | fix | catalog | epic}}"
|
|
11
11
|
},
|
|
12
|
-
"lineage": "{{uuid, fixed when the record is created; a
|
|
12
|
+
"lineage": "{{uuid, fixed when the record is created; a No-Go starts a new record with a new lineage}}",
|
|
13
13
|
"serial": 0,
|
|
14
14
|
"started_from": {
|
|
15
|
-
"card": "{{
|
|
15
|
+
"card": "{{No-Go card number, or null}}"
|
|
16
16
|
},
|
|
17
17
|
"active": null,
|
|
18
18
|
"phases": [
|
|
@@ -9,12 +9,12 @@ sections 2 and 4, so every skill reports the same thing for the same state.
|
|
|
9
9
|
- {{phase}} — {{one line result}}
|
|
10
10
|
|
|
11
11
|
## Where things stand
|
|
12
|
-
- {{work item}}: **{{status}}** — {{whose turn: the AI's (running / stopped) | yours, at
|
|
12
|
+
- {{work item}}: **{{status}}** — {{whose turn: the AI's (running / stopped) | yours, at a gate or a decision}}
|
|
13
13
|
- epic {{epic-id}}: {{status}}
|
|
14
14
|
|
|
15
15
|
## For you to look at
|
|
16
16
|
- cards: {{n}} on {{spec}} — {{question, one line each}}{{ — explainer: <url>, when it has one}}
|
|
17
|
-
- needs confirmation: {{change
|
|
17
|
+
- needs confirmation: {{where to read the change, as `cupola status` names it}} ({{n}} items){{; explainers: <url>, … when any}}
|
|
18
18
|
- case drafts filed: {{case-id — one line}}
|
|
19
19
|
- provisional fixes: {{entry — case}}
|
|
20
20
|
- unverified requirements: {{IDs}}
|
|
@@ -22,6 +22,6 @@ sections 2 and 4, so every skill reports the same thing for the same state.
|
|
|
22
22
|
|
|
23
23
|
## Next
|
|
24
24
|
{{exactly one of:}}
|
|
25
|
-
- **
|
|
25
|
+
- **Your turn ({{start | acceptance | release | resolution — a gate; or decision}}):** {{what to judge}}, at {{where to read the change | cards}}. Then: `{{command with real IDs}}`
|
|
26
26
|
- **Run:** `{{command with real IDs}}`
|
|
27
27
|
- **Nothing to push.**{{ Available when you choose: `command with real IDs` — one line each; …, when the skill lists any}}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
kind: runbook
|
|
3
3
|
method: 1
|
|
4
|
-
id: {{runbook-id}} # kebab-case name, never reused; also
|
|
4
|
+
id: {{runbook-id}} # kebab-case name, never reused; also its folder (<paths.runbooks>/<id>/runbook.md)
|
|
5
5
|
title: "{{one line: what the procedure does}}" # inside the quotes, write \" for a quote
|
|
6
6
|
applies-to: [{{component}}] # the components whose running system or surroundings it operates on
|
|
7
|
+
params: # what one run is given, each with what it means; {} when nothing
|
|
8
|
+
{{name}}: "{{what it is, e.g. the tenant whose keys are rotated}}"
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
<!--
|
|
10
12
|
FORMAT NOTES (for agents)
|
|
11
13
|
- A runbook is the procedure a human carries out on the running system or outside the code: a data
|
|
12
14
|
migration, a backfill, a production setting, access for someone, a request to another team. It is
|
|
13
|
-
written so the next person can repeat it, and kept:
|
|
15
|
+
written so the next person can repeat it, agreed at an epic's start, and kept: each run of it is an
|
|
16
|
+
execution, recorded next to it (`executions/<n>.md`), and a later epic reuses it as it is, or revises it.
|
|
17
|
+
- params: what differs between runs (a tenant, a date, a list), by name. The steps name them as
|
|
18
|
+
`<name>`; each execution records their values. A runbook with no params takes `params: {}`. An epic
|
|
19
|
+
gives the values in its `procedures`; a case's execution takes them from the case (cupola-intake).
|
|
14
20
|
- Humans read and run it: write it in the configured language. Keys and IDs stay English.
|
|
15
21
|
- Two layers. Before the precise-layer marker: what it is for, when it is used, who runs it, and what
|
|
16
22
|
it needs. After it: the steps, in order.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "What a spec runner returns to the session — the only thing the session reads. One object, printed as the runner's last line. Machine-read: strict.",
|
|
3
3
|
"spec": "{{work id}}",
|
|
4
|
-
"stopped": "{{
|
|
4
|
+
"stopped": "{{decision | acceptance | release | waiting | blocked | not-a-fix}}",
|
|
5
5
|
"note": "{{one line, ≤ 120 characters}}"
|
|
6
6
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { epicPath } from "../config.js";
|
|
4
|
-
import { today } from "../day.js";
|
|
5
|
-
import { originDefaultBranch } from "../git.js";
|
|
6
|
-
import { procedureMarker, procedureRecords, } from "../procedure.js";
|
|
7
|
-
import { parseRunbook } from "../runbook.js";
|
|
8
|
-
import { epicFront } from "../spec.js";
|
|
9
|
-
import { gitTree } from "../tree.js";
|
|
10
|
-
import { workspace } from "../workspace.js";
|
|
11
|
-
import { workStatus } from "./status.js";
|
|
12
|
-
import { trackerOf } from "./work.js";
|
|
13
|
-
const RESULTS = ["done", "stopped", "finished"];
|
|
14
|
-
/**
|
|
15
|
-
* `cupola procedure record <epic> <runbook> --result done|stopped --step <P#>`,
|
|
16
|
-
* or `--result finished`: records one step of the procedure a human is
|
|
17
|
-
* carrying out, or its end, as a Log line on every case of the epic. The epic must be operating,
|
|
18
|
-
* on that procedure.
|
|
19
|
-
*/
|
|
20
|
-
export async function procedureRecord(io, epic, runbook, opts) {
|
|
21
|
-
const result = opts.result;
|
|
22
|
-
if (!RESULTS.includes(result))
|
|
23
|
-
throw new Error("give --result done, stopped, or finished");
|
|
24
|
-
const step = opts.step;
|
|
25
|
-
if (result === "finished" ? step !== undefined : step === undefined)
|
|
26
|
-
throw new Error(result === "finished"
|
|
27
|
-
? "a finished procedure names no step"
|
|
28
|
-
: `give the step it records: --step <P#>`);
|
|
29
|
-
if (!opts.bodyFile)
|
|
30
|
-
throw new Error("give the line: --body-file <file>");
|
|
31
|
-
const line = (await readFile(resolve(io.cwd, opts.bodyFile), "utf8")).trim();
|
|
32
|
-
if (line === "" || line.includes("\n"))
|
|
33
|
-
throw new Error("a Log entry is one line");
|
|
34
|
-
if (line.includes("{{"))
|
|
35
|
-
throw new Error("the Log entry still has template placeholders ({{…}})");
|
|
36
|
-
// Epics, runbooks, and cases are the hub's.
|
|
37
|
-
const ws = await workspace(io);
|
|
38
|
-
const root = ws.here.isHub ? ws.root : ws.hub.main;
|
|
39
|
-
const now = await workStatus(io, root, ws.config, epic);
|
|
40
|
-
if (now.work.kind !== "epic")
|
|
41
|
-
throw new Error(`${epic} is not an epic`);
|
|
42
|
-
if (now.status !== "operating" || !now.procedure)
|
|
43
|
-
throw new Error(`${epic} is ${now.status}: a procedure is recorded while its epic is operating`);
|
|
44
|
-
if (now.procedure.runbook !== runbook)
|
|
45
|
-
throw new Error(`${epic} carries out ${now.procedure.runbook} now, not ${runbook}`);
|
|
46
|
-
// Operating means agreed: the epic and its runbooks are on origin's default branch.
|
|
47
|
-
const base = await originDefaultBranch(root);
|
|
48
|
-
const agreed = gitTree(root, base ? `refs/remotes/origin/${base}` : "HEAD");
|
|
49
|
-
const path = epicPath(ws.config.paths, epic);
|
|
50
|
-
const { front } = epicFront(path, (await agreed.read(path)) ?? "");
|
|
51
|
-
const bookPath = `${ws.config.paths.runbooks}/${runbook}.md`;
|
|
52
|
-
const raw = await agreed.read(bookPath);
|
|
53
|
-
if (raw === undefined)
|
|
54
|
-
throw new Error(`no ${bookPath} on origin's default branch`);
|
|
55
|
-
const steps = parseRunbook(raw).steps.map((s) => s.id);
|
|
56
|
-
// Steps are carried out in the runbook's order: the next is the first not done yet.
|
|
57
|
-
const next = steps.find((s) => !now.procedure?.done.includes(s));
|
|
58
|
-
if (step !== undefined) {
|
|
59
|
-
if (!steps.includes(step))
|
|
60
|
-
throw new Error(`${runbook} has no step ${step}`);
|
|
61
|
-
if (step !== next)
|
|
62
|
-
throw new Error(next
|
|
63
|
-
? `${runbook} goes on at ${next}, not ${step}: steps are recorded in the runbook's order`
|
|
64
|
-
: `every step of ${runbook} is done: record it finished`);
|
|
65
|
-
}
|
|
66
|
-
else if (next) {
|
|
67
|
-
throw new Error(`${runbook} is not done: ${next} is next`);
|
|
68
|
-
}
|
|
69
|
-
const tracker = await trackerOf(io);
|
|
70
|
-
const day = await today(io);
|
|
71
|
-
const record = { epic, runbook, ...(step ? { step } : {}), result };
|
|
72
|
-
const marker = procedureMarker(record);
|
|
73
|
-
const what = `epic ${epic}: ${runbook}${step ? ` ${step}` : ""} ${result}`;
|
|
74
|
-
// Run again after a write that reached only some cases: the cases that have it are left alone.
|
|
75
|
-
const latest = (text) => procedureRecords([text], epic).at(-1);
|
|
76
|
-
const same = (r) => r !== undefined && JSON.stringify(r) === JSON.stringify(record);
|
|
77
|
-
const texts = new Map();
|
|
78
|
-
for (const c of front.cases)
|
|
79
|
-
texts.set(c, (await tracker.show(c))?.text ?? "");
|
|
80
|
-
const retry = [...texts.values()].some((t) => same(latest(t)));
|
|
81
|
-
const logged = [];
|
|
82
|
-
for (const c of front.cases) {
|
|
83
|
-
if (retry && same(latest(texts.get(c) ?? "")))
|
|
84
|
-
continue;
|
|
85
|
-
await tracker.log(c, `${day} ${what}: ${line} ${marker}`);
|
|
86
|
-
logged.push(c);
|
|
87
|
-
}
|
|
88
|
-
io.out(opts.json
|
|
89
|
-
? JSON.stringify({ epic, runbook, step, result, logged })
|
|
90
|
-
: `${what}; logged on ${logged.join(", ") || "no case (already recorded)"}`);
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
package/dist/procedure.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How far an epic's procedures have run. Each step a
|
|
3
|
-
* human carries out is recorded as a Log line on every case of the epic, with
|
|
4
|
-
* a marker; the status is derived from those lines and never stored.
|
|
5
|
-
*/
|
|
6
|
-
const MARKER = /<!--\s*cupola:procedure\s+(\{.*?\})\s*-->/g;
|
|
7
|
-
/** The marker `cupola procedure record` appends to the Log line. */
|
|
8
|
-
export function procedureMarker(r) {
|
|
9
|
-
const { epic, runbook, step, result } = r;
|
|
10
|
-
return `<!-- cupola:procedure ${JSON.stringify({ epic, runbook, ...(step ? { step } : {}), result })} -->`;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The records of one epic, in the order they were written. Every case of the
|
|
14
|
-
* epic carries the same lines; when a write reached only some of them, the
|
|
15
|
-
* case with the most records has them all.
|
|
16
|
-
*/
|
|
17
|
-
export function procedureRecords(caseTexts, epic) {
|
|
18
|
-
let best = [];
|
|
19
|
-
for (const text of caseTexts) {
|
|
20
|
-
const out = [];
|
|
21
|
-
for (const m of text.matchAll(MARKER)) {
|
|
22
|
-
let r;
|
|
23
|
-
try {
|
|
24
|
-
r = JSON.parse(m[1] ?? "{}");
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
continue; // a marker edited by hand: it records nothing
|
|
28
|
-
}
|
|
29
|
-
if (r.epic !== epic || typeof r.runbook !== "string")
|
|
30
|
-
continue;
|
|
31
|
-
if (r.result !== "done" && r.result !== "stopped" && r.result !== "finished")
|
|
32
|
-
continue;
|
|
33
|
-
out.push({
|
|
34
|
-
epic,
|
|
35
|
-
runbook: r.runbook,
|
|
36
|
-
...(typeof r.step === "string" ? { step: r.step } : {}),
|
|
37
|
-
result: r.result,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (out.length > best.length)
|
|
41
|
-
best = out;
|
|
42
|
-
}
|
|
43
|
-
return best;
|
|
44
|
-
}
|
|
45
|
-
/** The procedure to carry out next, or undefined when every one is finished. */
|
|
46
|
-
export function currentProcedure(procedures, records) {
|
|
47
|
-
for (const runbook of procedures) {
|
|
48
|
-
const own = records.filter((r) => r.runbook === runbook);
|
|
49
|
-
if (own.some((r) => r.result === "finished"))
|
|
50
|
-
continue;
|
|
51
|
-
const last = own.at(-1);
|
|
52
|
-
const done = own.filter((r) => r.result === "done" && r.step).map((r) => r.step);
|
|
53
|
-
return {
|
|
54
|
-
runbook,
|
|
55
|
-
done: [...new Set(done)],
|
|
56
|
-
...(last?.result === "stopped" && last.step ? { stopped: last.step } : {}),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
kind: card
|
|
3
|
-
method: 1
|
|
4
|
-
card: {{n}}
|
|
5
|
-
type: send-back # always answered when written; written only by cupola-decide at G3
|
|
6
|
-
about: [{{E2 | X3 | <catalog-id> | A4 | needs-confirmation item}}]
|
|
7
|
-
redo: {{phase name of the work's mode}} # earliest phase the send-back touches; later phases run again
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<!--
|
|
11
|
-
HUMAN layer (what is wrong) followed by the AI's reading of it (precise, one fact per line).
|
|
12
|
-
Feedback left on the change is the other way to send it back; the run answers it in review.
|
|
13
|
-
-->
|
|
14
|
-
|
|
15
|
-
# {{What is wrong, in one line}}
|
|
16
|
-
|
|
17
|
-
> {{The human's own words, quoted as given.}}
|
|
18
|
-
|
|
19
|
-
## Read as
|
|
20
|
-
|
|
21
|
-
<!-- Written by cupola-decide after confirming with the human in the same dialogue. One line each. -->
|
|
22
|
-
- {{expected behavior that the change does not meet, with its ID}}
|
|
23
|
-
- {{what must change; what must not}}
|