@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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,164 @@ Cupola follows [Semantic Versioning](https://semver.org/). Before 1.0, a minor v
|
|
|
4
4
|
behavior; a patch version only fixes. Documents Cupola writes record their format as `method`: work in
|
|
5
5
|
flight keeps its method until done, and `cupola update` moves the rest forward.
|
|
6
6
|
|
|
7
|
+
## 0.2.0
|
|
8
|
+
|
|
9
|
+
### Epics and decision cards
|
|
10
|
+
|
|
11
|
+
- An epic is a folder: `<paths.epics>/<epic>/epic.md`, with its decision cards in `cards/`. Every point
|
|
12
|
+
the epic settled is listed under "Decisions"; the weighty ones become cards, settled at the epic's start
|
|
13
|
+
with `cupola-decide <epic>` before the epic is merged. `cupola status` lists an epic's open cards there.
|
|
14
|
+
**Moving:** an epic written as `<paths.epics>/<epic>.md` moves to `<paths.epics>/<epic>/epic.md`
|
|
15
|
+
(`cupola check` says which); nothing else in it changes.
|
|
16
|
+
- While an epic has open cards, its change is a draft whose description lists them; it is marked ready
|
|
17
|
+
once the last card is answered (`cupola change ready <work>`, and `cupola change draft <work>`, both
|
|
18
|
+
with `--body-file` to describe the change anew). Best effort: where the host refuses drafts, the change
|
|
19
|
+
is left as it is and nothing fails.
|
|
20
|
+
- An epic merged with cards still open counts as agreed, and the work goes on: each open card is taken as
|
|
21
|
+
settled on its recommended option. `cupola status <epic>` keeps listing them (`unanswered`) without
|
|
22
|
+
changing the status or what comes next, and the runs say which option was taken in their reports and
|
|
23
|
+
in each spec's "Needs confirmation", for acceptance.
|
|
24
|
+
- `cupola-decide <work> <card>…` answers only the cards named; without card numbers, every open card in
|
|
25
|
+
order, as before.
|
|
26
|
+
- A card may name who should answer it: `ask:` in its front matter (logins or roles, optional, so
|
|
27
|
+
existing cards stay valid). The skills fill it when the configuration, the steering, or the epic names
|
|
28
|
+
someone responsible; `cupola status` shows it next to each open card, and the epic's change lists it.
|
|
29
|
+
- Card answers are recorded only through `cupola-decide`, never read from comments on a change.
|
|
30
|
+
- An ADR is no longer a change of its own: `cupola-adr` commits it into the change of the work the choice
|
|
31
|
+
came from (the epic's change for the epic's dialogues and cards, the spec's or fix's change for decision
|
|
32
|
+
cards, the e2e change, the setup in `cupola-init`), and it is merged with that work. Only a dialogue
|
|
33
|
+
with no change of its own (`cupola-resolve`, or `cupola-adr` run directly) still opens `adr-<id>`.
|
|
34
|
+
`cupola adr list` reads ADRs once merged, as before.
|
|
35
|
+
|
|
36
|
+
### Reacting at the gates
|
|
37
|
+
|
|
38
|
+
- Reactions at the gates replace sending back. At an epic's gates (start, acceptance, release) a person reacts on the change or in a
|
|
39
|
+
session (`cupola-decide <work>`, now the gate dialogue for every kind): a **comment** is answered and
|
|
40
|
+
changes nothing (a request gets "to change it, give a No-Go"); a **try** (`/cupola try …` on GitHub)
|
|
41
|
+
has the new `cupola-try` build each variant on a branch of its own (`cupola-try/<work>/<n>`, removed by
|
|
42
|
+
`cupola-complete`) and reply with one comparison, the work and its status unchanged; a **No-Go** (a
|
|
43
|
+
review that requests changes on GitHub, or said explicitly in a session) is the only one that changes
|
|
44
|
+
the work. It reads its words and the gate's comments since the last No-Go, and goes back: at the start the AI
|
|
45
|
+
redraws the epic itself, at acceptance to the phase that needs it (a `no-go` card, from `cupola template
|
|
46
|
+
no-go`, replaces the `send-back` card; for an execution, back to a step), at release to a revision of the
|
|
47
|
+
epic. A No-Go with no content becomes a card asking whoever gave it. Approving is no reaction; nor is a
|
|
48
|
+
comment or a review that comments any longer a send-back.
|
|
49
|
+
- Reactions are processed only at a gate. A session waiting there (`cupola wait` now also wakes on a new
|
|
50
|
+
reaction) runs the new `cupola-respond <work>`; with none waiting, `cupola status` lists the reactions
|
|
51
|
+
not processed (`reactions`), keeps the gate's status, and names `cupola-respond <work>` next. What is
|
|
52
|
+
said while a run goes on — on its draft change, or in the session — waits for the next gate: a
|
|
53
|
+
session's reactions are kept with `cupola reaction add` in `.cupola/runs/<work>/reactions/`, which
|
|
54
|
+
`cupola run finish` keeps for the gate. New commands: `cupola reaction list|reply|add`, `cupola try
|
|
55
|
+
start|remove`. The code host adapter reads reactions and replies to them; a `git` host takes none.
|
|
56
|
+
`cupola change feedback` and `change answer` now serve only the review phase's reviewer.
|
|
57
|
+
- A change with more remarks than Cupola can read is no longer taken as having none: `cupola status`
|
|
58
|
+
says its reactions could not be read (`unread`) and are not processed.
|
|
59
|
+
|
|
60
|
+
### Runbooks and their executions
|
|
61
|
+
|
|
62
|
+
- Runbooks and their executions. A runbook is a folder, `<paths.runbooks>/<runbook>/runbook.md`, agreed
|
|
63
|
+
once at an epic's start and run any number of times; its front matter declares the `params` a run takes,
|
|
64
|
+
and an epic's `procedures` give their values. Each run is an **execution**, `<runbook>-<n>`, with a
|
|
65
|
+
permanent record (`executions/<n>.md`, from `cupola template execution`) on its own branch and change:
|
|
66
|
+
`cupola execution start <runbook> --for <epic|case> [--param <name>=<value>…]` creates it with a draft
|
|
67
|
+
change, and `cupola execution record <execution> --step <P#> --result done|stopped` (or `--result
|
|
68
|
+
finished|given-up`) records one step in the human's words per commit, marking the change ready at the
|
|
69
|
+
end. A person merges it at acceptance to accept it. A run may arrange the runbook in its record (steps
|
|
70
|
+
skipped, changed, or added, with why) and propose fixes to it; the runbook itself changes only at a
|
|
71
|
+
later epic's start. An execution is `waiting`, `operating`, `blocked` (stopped: whose turn, why, and how to
|
|
72
|
+
resume), `awaiting-acceptance`, or `done`, derived from its record and change.
|
|
73
|
+
- `cupola-intake` starts an execution of an agreed runbook for a case when it can fill the runbook's
|
|
74
|
+
params, with no epic; `cupola-operate <execution>` follows the arranged steps, records each one, and
|
|
75
|
+
ends with `--give-up` when the human stops it; `cupola-abort` records an epic's executions in progress
|
|
76
|
+
as given up and undoes nothing; `cupola-resolve` takes its evidence from the execution records.
|
|
77
|
+
- An epic's status comes only from its specs and executions, and a case's from its epics and
|
|
78
|
+
executions; a case's Log only tells people (released, an execution finished or given up). **Removed:**
|
|
79
|
+
`cupola procedure record` and its markers in the case Log.
|
|
80
|
+
- Fixed: `cupola-complete <epic>` stopped right after the release of an epic with procedures, which was
|
|
81
|
+
already `operating`. Now the released epic is `done` with next `cupola-complete <epic>` until complete
|
|
82
|
+
has tidied up (its epic branch is gone from origin) and, as its last step, created the executions of
|
|
83
|
+
its runbooks; only then is it `operating`, until they are done. An epic without specs goes the same
|
|
84
|
+
way after its start.
|
|
85
|
+
|
|
86
|
+
### Runs and their status
|
|
87
|
+
|
|
88
|
+
- Gates are named, not numbered: an epic's **start**, **acceptance** (of a spec, or of an execution's
|
|
89
|
+
record), and **release**, and a case's **resolution** (G1, G3, G4, and G5 before). `gate` in `cupola
|
|
90
|
+
status --json` carries the name (`start`, `acceptance`, `release`, `resolution`), and the status
|
|
91
|
+
`awaiting-agreement` is now `awaiting-start`. A decision is no longer a gate (G2) but an interrupt the
|
|
92
|
+
AI raises mid-run: `awaiting-decision` keeps its name, with `gate` null, like `blocked`. `cupola run
|
|
93
|
+
next`, `run record`, and `run finish` say `stopped` `decision`, `acceptance`, or `release` instead of
|
|
94
|
+
`G2`, `G3`, or `G4`, and so does a runner's result
|
|
95
|
+
(`cupola template runner-result`). The guide has the gates in one
|
|
96
|
+
table, then interrupts: from the AI (a decision, blocked) and from people (reactions).
|
|
97
|
+
- The epic's run takes in agreed revisions and merged specs on every loop, before it starts runners:
|
|
98
|
+
`cupola status <epic>` marks each spec it must handle first (`takeIn`: `close` the change of a
|
|
99
|
+
dropped spec, `draft` the change of a spec redesigned at acceptance), which is not movable until then, and
|
|
100
|
+
names the epic's run while its runners run (`running`); a spec's status names its epic
|
|
101
|
+
(`work.epic`). Answering a decision card of a spec in an epic resumes the epic's run, or leaves the spec to
|
|
102
|
+
the one already running, instead of running only that spec.
|
|
103
|
+
- Once a revision that redesigns a spec is agreed, `cupola status` shows the spec at its acceptance
|
|
104
|
+
tests, where its run resumes, instead of the phase its record named before the run took it in.
|
|
105
|
+
- A case is `in-progress` as soon as an epic listing it is under agreement (its epic change open), not
|
|
106
|
+
only once the epic is agreed: `cupola status <case>` names the epic, and `cupola-epic-create <case>`
|
|
107
|
+
points to it instead of starting a second epic. A closed epic change does not count.
|
|
108
|
+
- A run stopped by something outside the AI's control shows as `blocked` in `cupola status`: the
|
|
109
|
+
human's turn, with the reason and the command that resumes it. An epic does not start a blocked spec
|
|
110
|
+
again on its own, and lists it among the specs waiting for you.
|
|
111
|
+
- A spec of an epic whose change was closed by hand, with nothing recorded, is no longer `dropped`: it is
|
|
112
|
+
`blocked`, your turn, offering `cupola-abort <epic>`, a revision that drops it, or reopening the
|
|
113
|
+
change. Its epic does not go on to the acceptance check meanwhile, and its case does not go back to
|
|
114
|
+
`open`.
|
|
115
|
+
- A spec waiting on a revision of its epic under agreement is the human's turn: `cupola status` names
|
|
116
|
+
the epic change to read and merge at its start, instead of showing it as the AI's turn.
|
|
117
|
+
- Aborting an epic stops a phase that was running: its `cupola run record` stops the run without
|
|
118
|
+
recording the outcome, as `cupola run next` already did, and `cupola-abort` says so in its report.
|
|
119
|
+
- While a run is marked active, `cupola status` says who started it, in which session, and how long
|
|
120
|
+
ago, and names the take-over command for when that session is gone.
|
|
121
|
+
- An epic is taken over in one place: `cupola-epic-run <epic> --take-over <session or marker id>`. With
|
|
122
|
+
a session, it takes over every marker of the epic that session held (each spec's run, whose runners'
|
|
123
|
+
sessions start with it, and the acceptance check); `cupola run next --take-over` accepts a session as
|
|
124
|
+
well as a marker id, for records and shared e2e locks alike. `cupola status` names that command for a
|
|
125
|
+
running spec of an epic, the epic's runners, and its acceptance check, instead of
|
|
126
|
+
`cupola-spec-run … --take-over` or `cupola-epic-accept … --take-over`. A blocked or
|
|
127
|
+
waiting acceptance check is resumed with `cupola-epic-run <epic>` too; `cupola-epic-accept` is a phase
|
|
128
|
+
of the epic's run, not something a person types.
|
|
129
|
+
- `cupola locks [<component>]` lists the locks on shared e2e environments, read only: the
|
|
130
|
+
environment, the work, who holds it, in which session, since when and how long ago, and the id a run
|
|
131
|
+
takes it over with.
|
|
132
|
+
|
|
133
|
+
### Hosts and setup
|
|
134
|
+
|
|
135
|
+
- Several repositories are set up hub first: `cupola-init` sets up the hub, and once it is merged, run
|
|
136
|
+
again, clones the others and, with `documents: "repositories"`, installs Cupola in each with the hub's
|
|
137
|
+
configuration (`cupola init --config-file`) and that repository's own steering, as a change for its
|
|
138
|
+
owners to merge. `cupola doctor` lists what is still to set up (the hub's setup not merged, a
|
|
139
|
+
repository not cloned or without Cupola) as `pending`, apart from `problems`; it is ok once nothing
|
|
140
|
+
is pending. `cupola-steering` writes a component's steering in its own repository. A setup with
|
|
141
|
+
`documents: "hub"` is for trying Cupola out and does not move to `repositories` later.
|
|
142
|
+
- A repository can name its own code host and clone URL (`repositories` in `.cupola/config.json`).
|
|
143
|
+
- A `git` host, which needs nothing but the repository's origin: changes are kept on its
|
|
144
|
+
`cupola/changes` branch, and a person merges them with `cupola change merge <work>`, each as one
|
|
145
|
+
commit; any merge that brings the branch into its base counts too. `cupola init` makes Claude Code
|
|
146
|
+
ask before `cupola change merge`.
|
|
147
|
+
- How a person reads, merges, and reacts on a change comes from its host: on a `git` host, the acceptance
|
|
148
|
+
and release texts of `cupola status` point to `cupola change show <work>` (`--release` for an epic's
|
|
149
|
+
release, from any branch) and `cupola change merge`, and offer reactions only in a session. `cupola
|
|
150
|
+
change show` now prints the change for a person — title, state, where it is, and its description —
|
|
151
|
+
instead of only its name. The guide no longer says GitHub and `gh` are needed for a repository on a
|
|
152
|
+
`git` host.
|
|
153
|
+
- `cupola setup claude` also denies pushes to the repository's actual default branch (origin's HEAD),
|
|
154
|
+
not only to `main` and `master`.
|
|
155
|
+
- `cupola-init` fills `verification.test_reports` from where the project's test run writes JUnit XML,
|
|
156
|
+
without asking, and says what it wrote (or what to add) in its report.
|
|
157
|
+
- The guide explains `trust` (who is trusted by default, adding logins, and what it means with a `git`
|
|
158
|
+
host and the `files` tracker), and that an empty repository's first commit is pushed to `main` by a
|
|
159
|
+
person before the pull-request-based setup.
|
|
160
|
+
|
|
161
|
+
### Other
|
|
162
|
+
|
|
163
|
+
- The workflows' actions run on Node 24 (`actions/checkout` and `actions/setup-node` v7).
|
|
164
|
+
|
|
7
165
|
## 0.1.0
|
|
8
166
|
|
|
9
167
|
First public release.
|
package/README.md
CHANGED
|
@@ -16,8 +16,9 @@ npx @kyuki3rain/cupola init # in your repository
|
|
|
16
16
|
|
|
17
17
|
Then, in Claude Code: `cupola-init`.
|
|
18
18
|
|
|
19
|
-
- **A few gates, nothing in between.** People
|
|
20
|
-
|
|
19
|
+
- **A few gates, nothing in between.** People start an epic, accept changes, release, and judge
|
|
20
|
+
whether the problem is gone (start, acceptance, release, resolution). In between, the AI stops only to
|
|
21
|
+
raise the rare decision card, or when it is blocked; it never stops just to ask.
|
|
21
22
|
- **A behavior catalog.** What the system promises, one line per behavior, traced to the tests that
|
|
22
23
|
check it and their latest results.
|
|
23
24
|
- **Any shape of system.** One repository, a monorepo, or several repositories, in components.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { git, gitWith } from "./git.js";
|
|
5
|
+
export function branchStore(root, branch, trackingRef) {
|
|
6
|
+
async function tip() {
|
|
7
|
+
try {
|
|
8
|
+
await git(root, ["ls-remote", "--exit-code", "--heads", "origin", `refs/heads/${branch}`]);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error.code === 2)
|
|
12
|
+
return undefined;
|
|
13
|
+
throw new Error(`cannot reach origin to read ${branch}; try again when it is reachable`);
|
|
14
|
+
}
|
|
15
|
+
await git(root, ["fetch", "--quiet", "origin", `+refs/heads/${branch}:${trackingRef}`]);
|
|
16
|
+
return git(root, ["rev-parse", trackingRef]);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
tip,
|
|
20
|
+
async read(commit, path) {
|
|
21
|
+
try {
|
|
22
|
+
return await git(root, ["show", `${commit}:${path}`]);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
async list(commit, dir) {
|
|
29
|
+
return (await git(root, ["ls-tree", "--name-only", commit, `${dir}/`]))
|
|
30
|
+
.split("\n")
|
|
31
|
+
.filter((p) => p !== "");
|
|
32
|
+
},
|
|
33
|
+
async write(change, message) {
|
|
34
|
+
for (let attempt = 0;; attempt++) {
|
|
35
|
+
const parent = await tip();
|
|
36
|
+
const file = await change(parent, attempt > 0);
|
|
37
|
+
if (file === undefined)
|
|
38
|
+
return;
|
|
39
|
+
const dir = await mkdtemp(join(tmpdir(), "cupola-store-"));
|
|
40
|
+
try {
|
|
41
|
+
const env = { GIT_INDEX_FILE: join(dir, "index") };
|
|
42
|
+
await gitWith(root, parent ? ["read-tree", parent] : ["read-tree", "--empty"], { env });
|
|
43
|
+
const blob = await gitWith(root, ["hash-object", "-w", "--stdin"], { input: file.text });
|
|
44
|
+
await gitWith(root, ["update-index", "--add", "--cacheinfo", `100644,${blob},${file.path}`], { env });
|
|
45
|
+
const tree = await gitWith(root, ["write-tree"], { env });
|
|
46
|
+
const commit = await gitWith(root, ["commit-tree", tree, ...(parent ? ["-p", parent] : []), "-m", message], { env });
|
|
47
|
+
try {
|
|
48
|
+
await git(root, ["push", "--quiet", "origin", `${commit}:refs/heads/${branch}`]);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const stderr = error.stderr ?? "";
|
|
53
|
+
// Only a race is retried: someone else's write landed first. Anything else is reported.
|
|
54
|
+
const raced = /non-fast-forward|fetch first|\(stale info\)/.test(stderr);
|
|
55
|
+
if (!raced || attempt >= 2)
|
|
56
|
+
throw new Error(`could not push ${branch} to origin (${pushProblem(stderr)})`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
await rm(dir, { recursive: true, force: true });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The lines of a failed push's stderr that say why. */
|
|
67
|
+
export function pushProblem(stderr) {
|
|
68
|
+
return (stderr
|
|
69
|
+
.split("\n")
|
|
70
|
+
.map((l) => l.trim())
|
|
71
|
+
.filter((l) => /^(!|error:|fatal:|remote:)/.test(l) && !/^remote:\s*$/.test(l))
|
|
72
|
+
.join("; ") || "unknown reason");
|
|
73
|
+
}
|
package/dist/commands/change.js
CHANGED
|
@@ -4,8 +4,9 @@ import { codeChanges, epicBaseOf, mountsIn, workComponents } from "../code.js";
|
|
|
4
4
|
import { epicPath, loadConfig } from "../config.js";
|
|
5
5
|
import { byReviewer, trusted } from "../feedback.js";
|
|
6
6
|
import { git, originDefaultBranch, workBranch } from "../git.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { MergedOnHost } from "../host/host.js";
|
|
8
|
+
import { codeHost } from "../host/index.js";
|
|
9
|
+
import { releaseBody, releaseChanges, releasesOf } from "../release.js";
|
|
9
10
|
import { repoRoot } from "../repo.js";
|
|
10
11
|
import { epicBranchName, epicFront, readBlock } from "../spec.js";
|
|
11
12
|
import { fsTree } from "../tree.js";
|
|
@@ -30,7 +31,7 @@ export async function changeOpen(io, id, opts) {
|
|
|
30
31
|
if (!runsOn(branch, id)) {
|
|
31
32
|
throw new Error(`${id} is on ${workBranchName(id)}, but this checkout is on ${branch}`);
|
|
32
33
|
}
|
|
33
|
-
const host = (io.host ??
|
|
34
|
+
const host = (io.host ?? codeHost)(root);
|
|
34
35
|
const existing = await host.findChange(branch);
|
|
35
36
|
const onEpic = branch === epicBranchName(id);
|
|
36
37
|
// The workspace is read only where it matters: an epic's release, or code kept apart.
|
|
@@ -104,15 +105,22 @@ export async function changeOpen(io, id, opts) {
|
|
|
104
105
|
return 0;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
const open = (draft) => host.openChange({ branch, base, title: opts.title ?? "", body, draft });
|
|
109
|
+
let change;
|
|
110
|
+
if (existing?.state === "open")
|
|
111
|
+
change = existing;
|
|
112
|
+
else {
|
|
113
|
+
try {
|
|
114
|
+
change = await open(!opts.ready);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
// An epic's change is a draft only while cards are open, at best: where the host
|
|
118
|
+
// cannot open drafts, it opens ready.
|
|
119
|
+
if (opts.ready || !(await isEpic(root, id)))
|
|
120
|
+
throw error;
|
|
121
|
+
change = await open(false);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
116
124
|
const opened = ws0
|
|
117
125
|
? await openCodeChanges(io, ws0, root, id, branch, {
|
|
118
126
|
title: opts.title,
|
|
@@ -231,21 +239,141 @@ async function changeBranch(root, id) {
|
|
|
231
239
|
}
|
|
232
240
|
return workBranchName(id);
|
|
233
241
|
}
|
|
234
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* `cupola change show <work>`: the work item's change, or null. For a person,
|
|
244
|
+
* it reads as the change: its title, state, where it is, its code changes, and
|
|
245
|
+
* its description, which on a host without pages is nowhere else to read.
|
|
246
|
+
* With `--release`, the epic's release changes, whichever branch is checked out.
|
|
247
|
+
*/
|
|
235
248
|
export async function changeShow(io, id, opts) {
|
|
236
249
|
const root = await repoRoot(io.cwd);
|
|
237
|
-
|
|
250
|
+
if (opts.release)
|
|
251
|
+
return releaseShow(io, root, id, opts);
|
|
252
|
+
const host = (io.host ?? codeHost)(root);
|
|
238
253
|
const branch = await changeBranch(root, id);
|
|
239
254
|
const change = await host.findChange(branch);
|
|
240
255
|
const codes = change ? await codeOfHere(io, root, id, branch) : [];
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
256
|
+
// The description too: after the merge it is where the run's account of the work lives.
|
|
257
|
+
const body = change ? await host.body(change.number) : undefined;
|
|
258
|
+
if (opts.json) {
|
|
259
|
+
io.out(JSON.stringify(change ? { ...withCode(change, codes), body } : null));
|
|
245
260
|
return 0;
|
|
246
261
|
}
|
|
247
|
-
|
|
248
|
-
|
|
262
|
+
if (!change) {
|
|
263
|
+
io.out(`${id} has no change`);
|
|
264
|
+
return 0;
|
|
265
|
+
}
|
|
266
|
+
io.out(readable(change, `the change of ${id}`, codes.map((c) => c.change
|
|
267
|
+
? `code in ${c.slug}, ${stateOf(c.change)}: ${c.change.url}`
|
|
268
|
+
: `code in ${c.slug}: no change yet`), body));
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
/** `cupola change show <epic> --release`: each release change, in merge order, with its description. */
|
|
272
|
+
async function releaseShow(io, root, id, opts) {
|
|
273
|
+
const ws = await workspace(io);
|
|
274
|
+
const items = ws.repos.length > 1
|
|
275
|
+
? await epicReleases(io, ws, id)
|
|
276
|
+
: await (async () => {
|
|
277
|
+
const host = (io.host ?? codeHost)(root);
|
|
278
|
+
const change = await host.findChange(epicBranchName(id));
|
|
279
|
+
return change ? [{ repo: ws.here.slug, host, change }] : [];
|
|
280
|
+
})();
|
|
281
|
+
const shown = [];
|
|
282
|
+
for (const it of items)
|
|
283
|
+
shown.push({ repo: it.repo, change: it.change, body: await it.host.body(it.change.number) });
|
|
284
|
+
if (opts.json) {
|
|
285
|
+
io.out(JSON.stringify(shown.map((s) => ({ repo: s.repo, ...s.change, body: s.body }))));
|
|
286
|
+
return 0;
|
|
287
|
+
}
|
|
288
|
+
io.out(shown.length === 0
|
|
289
|
+
? `${id} has no release change`
|
|
290
|
+
: shown
|
|
291
|
+
.map((s, i) => readable(s.change, `the release of ${id}`, [`release ${i + 1} of ${shown.length}, in ${s.repo}`], s.body))
|
|
292
|
+
.join("\n\n"));
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
/** A change as a person reads it: title, state and name, more lines, then its description. */
|
|
296
|
+
function readable(change, untitled, more, body) {
|
|
297
|
+
return [
|
|
298
|
+
change.title || untitled,
|
|
299
|
+
`${stateOf(change)}: ${change.url}`,
|
|
300
|
+
...more,
|
|
301
|
+
"",
|
|
302
|
+
body?.trim() || "(no description)",
|
|
303
|
+
].join("\n");
|
|
304
|
+
}
|
|
305
|
+
/** An epic's release changes across the workspace's repositories, in merge order: those opened. */
|
|
306
|
+
async function epicReleases(io, ws, id) {
|
|
307
|
+
const branch = epicBranchName(id);
|
|
308
|
+
const path = epicPath(ws.config.paths, id);
|
|
309
|
+
const raw = (await git(ws.hub.main, ["show", `refs/remotes/origin/${branch}:${path}`]).catch(() => undefined)) ?? (await fsTree(ws.hub.main).read(path));
|
|
310
|
+
if (raw === undefined)
|
|
311
|
+
throw new Error(`${path} is not on ${branch}`);
|
|
312
|
+
const releases = await releaseChanges(io, ws, id, releasesOf(ws, epicFront(path, raw).front.specs));
|
|
313
|
+
return releases.flatMap((r) => r.change ? [{ repo: r.repo.slug, host: r.host, change: r.change }] : []);
|
|
314
|
+
}
|
|
315
|
+
/** A change's state as a person reads it. */
|
|
316
|
+
function stateOf(change) {
|
|
317
|
+
return change.state === "open" && change.draft ? "draft" : change.state;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* `cupola change merge <work> [--release]`: a person merges the work's ready
|
|
321
|
+
* changes that are on a host without a merge of its own (a git host), each as
|
|
322
|
+
* one commit on its base, in the order they go in: code before the hub, a
|
|
323
|
+
* release in its merge order. It stops at the first change that is merged on
|
|
324
|
+
* its host, saying so; run again once that one is merged. No skill runs it.
|
|
325
|
+
*/
|
|
326
|
+
export async function changeMerge(io, id, opts) {
|
|
327
|
+
const root = await repoRoot(io.cwd);
|
|
328
|
+
const branch = opts.release ? epicBranchName(id) : await changeBranch(root, id);
|
|
329
|
+
let items;
|
|
330
|
+
const config = await loadConfig(root);
|
|
331
|
+
const ws = config.documents === "hub" || branch === epicBranchName(id) ? await workspace(io) : undefined;
|
|
332
|
+
if (branch === epicBranchName(id) && ws && ws.repos.length > 1) {
|
|
333
|
+
items = await epicReleases(io, ws, id);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
const host = (io.host ?? codeHost)(root);
|
|
337
|
+
const change = await host.findChange(branch);
|
|
338
|
+
if (!change)
|
|
339
|
+
throw new Error(`${id} has no change`);
|
|
340
|
+
const codes = ws ? await codeOf(io, ws, root, id, branch) : [];
|
|
341
|
+
items = [
|
|
342
|
+
...codes.flatMap((c) => (c.change ? [{ repo: c.slug, host: c.host, change: c.change }] : [])),
|
|
343
|
+
{ repo: ws?.here.slug ?? "", host, change },
|
|
344
|
+
];
|
|
345
|
+
}
|
|
346
|
+
const done = [];
|
|
347
|
+
let waiting;
|
|
348
|
+
for (const it of items) {
|
|
349
|
+
if (it.change.state === "merged")
|
|
350
|
+
continue;
|
|
351
|
+
if (it.change.state === "closed")
|
|
352
|
+
throw new Error(`${it.change.url} is closed`);
|
|
353
|
+
if (!it.host.merge) {
|
|
354
|
+
waiting = it.change.url;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
await it.host.merge(it.change.number);
|
|
359
|
+
}
|
|
360
|
+
catch (error) {
|
|
361
|
+
if (error instanceof MergedOnHost) {
|
|
362
|
+
waiting = it.change.url;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
done.push(it.change.url);
|
|
368
|
+
}
|
|
369
|
+
if (opts.json)
|
|
370
|
+
io.out(JSON.stringify({ merged: done, ...(waiting ? { merge_on_host: waiting } : {}) }));
|
|
371
|
+
else {
|
|
372
|
+
const lines = done.map((u) => `merged ${u}`);
|
|
373
|
+
if (waiting)
|
|
374
|
+
lines.push(`merge ${waiting} on its host, then run this again`);
|
|
375
|
+
io.out(lines.length > 0 ? lines.join("\n") : `every change of ${id} is merged`);
|
|
376
|
+
}
|
|
249
377
|
return 0;
|
|
250
378
|
}
|
|
251
379
|
/**
|
|
@@ -254,9 +382,9 @@ export async function changeShow(io, id, opts) {
|
|
|
254
382
|
* a command interrupted halfway, or a change a human merged first, still
|
|
255
383
|
* reaches the others. `change` is the hub's change, whatever its state.
|
|
256
384
|
*/
|
|
257
|
-
async function openChangeOf(io, id) {
|
|
385
|
+
export async function openChangeOf(io, id) {
|
|
258
386
|
const root = await repoRoot(io.cwd);
|
|
259
|
-
const host = (io.host ??
|
|
387
|
+
const host = (io.host ?? codeHost)(root);
|
|
260
388
|
const branch = await changeBranch(root, id);
|
|
261
389
|
const change = await host.findChange(branch);
|
|
262
390
|
if (!change)
|
|
@@ -282,24 +410,98 @@ function seconds(value) {
|
|
|
282
410
|
throw new Error(`--wait takes seconds, not ${value}`);
|
|
283
411
|
return n;
|
|
284
412
|
}
|
|
285
|
-
/**
|
|
413
|
+
/** Whether the work is an epic: its document is in this checkout. */
|
|
414
|
+
async function isEpic(root, id) {
|
|
415
|
+
try {
|
|
416
|
+
return (await fsTree(root).read(epicPath((await loadConfig(root)).paths, id))) !== undefined;
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/** Replaces the description of the work's own change when a file is given. */
|
|
423
|
+
async function describeAnew(io, all, bodyFile) {
|
|
424
|
+
if (!bodyFile)
|
|
425
|
+
return;
|
|
426
|
+
const body = await readBody(io.cwd, bodyFile);
|
|
427
|
+
const own = all.find((c) => c.repo === undefined);
|
|
428
|
+
if (!own)
|
|
429
|
+
throw new Error("the work's own change is not open: its description cannot change");
|
|
430
|
+
await own.host.setBody(own.change.number, body);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* `cupola change ready <work> [--body-file <f>]`: describes the change anew
|
|
434
|
+
* when a file is given, then marks it ready for its gate — an epic's change
|
|
435
|
+
* once none of its cards is open. Best effort: a host that refuses leaves the
|
|
436
|
+
* change as it is, and the output says so; nothing fails because of it.
|
|
437
|
+
*/
|
|
438
|
+
export async function changeReady(io, id, opts) {
|
|
439
|
+
const { change, all } = await openChangeOf(io, id);
|
|
440
|
+
await describeAnew(io, all, opts.bodyFile);
|
|
441
|
+
const skipped = [];
|
|
442
|
+
for (const c of all) {
|
|
443
|
+
if (!c.change.draft)
|
|
444
|
+
continue;
|
|
445
|
+
try {
|
|
446
|
+
await c.host.markReady(c.change.number);
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
skipped.push(`${c.change.url}: ${error.message.split("\n")[0]}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const urls = all.map((c) => c.change.url);
|
|
453
|
+
io.out(opts.json
|
|
454
|
+
? JSON.stringify({
|
|
455
|
+
...change,
|
|
456
|
+
...(change.state === "open" && skipped.length === 0 ? { draft: false } : {}),
|
|
457
|
+
ready: urls,
|
|
458
|
+
...(skipped.length > 0 ? { skipped } : {}),
|
|
459
|
+
})
|
|
460
|
+
: [
|
|
461
|
+
`${urls.join(", ")} ${urls.length > 1 ? "are" : "is"} ready`,
|
|
462
|
+
...skipped.map((s) => `not marked ready (left as it is): ${s}`),
|
|
463
|
+
].join("\n"));
|
|
464
|
+
return 0;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* `cupola change draft <work> [--body-file <f>]`: turns the change back into a
|
|
468
|
+
* draft, as a No-Go does, describing it anew when a file is given. For an
|
|
469
|
+
* epic's change (kept a draft while cards are open) it is best effort: a host
|
|
470
|
+
* that refuses leaves it as it is.
|
|
471
|
+
*/
|
|
286
472
|
export async function changeDraft(io, id, opts) {
|
|
287
|
-
const { change, all, codes } = await openChangeOf(io, id);
|
|
288
|
-
// Code merged already cannot take rework: what
|
|
473
|
+
const { root, change, all, codes } = await openChangeOf(io, id);
|
|
474
|
+
// Code merged already cannot take rework: what a No-Go asks goes into a fix of its own.
|
|
289
475
|
const merged = codes.filter((c) => c.change?.state === "merged");
|
|
290
476
|
if (merged.length > 0)
|
|
291
477
|
throw new Error(`the code change of ${id} is merged already (${merged.map((c) => c.change?.url).join(", ")}): rework cannot go into it; file a case for a fix instead`);
|
|
292
|
-
|
|
293
|
-
|
|
478
|
+
await describeAnew(io, all, opts.bodyFile);
|
|
479
|
+
const epic = await isEpic(root, id);
|
|
480
|
+
const skipped = [];
|
|
481
|
+
for (const c of all) {
|
|
482
|
+
if (c.change.draft)
|
|
483
|
+
continue;
|
|
484
|
+
try {
|
|
294
485
|
await c.host.markDraft(c.change.number);
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
if (!epic)
|
|
489
|
+
throw error;
|
|
490
|
+
skipped.push(`${c.change.url}: ${error.message.split("\n")[0]}`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
295
493
|
const urls = all.map((c) => c.change.url);
|
|
296
494
|
io.out(opts.json
|
|
297
495
|
? JSON.stringify({
|
|
298
496
|
...change,
|
|
299
|
-
...(change.state === "open" ? { draft: true } : {}),
|
|
497
|
+
...(change.state === "open" && skipped.length === 0 ? { draft: true } : {}),
|
|
300
498
|
drafted: urls,
|
|
499
|
+
...(skipped.length > 0 ? { skipped } : {}),
|
|
301
500
|
})
|
|
302
|
-
:
|
|
501
|
+
: [
|
|
502
|
+
`${urls.join(", ")} ${urls.length > 1 ? "are drafts" : "is a draft"}`,
|
|
503
|
+
...skipped.map((s) => `not made a draft (left as it is): ${s}`),
|
|
504
|
+
].join("\n"));
|
|
303
505
|
return 0;
|
|
304
506
|
}
|
|
305
507
|
/**
|
|
@@ -354,9 +556,11 @@ function time(value, flag) {
|
|
|
354
556
|
}
|
|
355
557
|
/**
|
|
356
558
|
* `cupola change feedback <work> [--since <time>] [--wait <seconds>]`: the
|
|
357
|
-
*
|
|
358
|
-
* the
|
|
359
|
-
* until it has, or the time is
|
|
559
|
+
* review phase's findings — the open feedback the configured reviewer opened,
|
|
560
|
+
* with the replies someone trusted wrote in it — and whether the reviewer has
|
|
561
|
+
* answered since `since`. With `--wait`, polls until it has, or the time is
|
|
562
|
+
* up. What people opened is a reaction, processed at the gate (`cupola
|
|
563
|
+
* reaction`), not here; replies by anyone untrusted are counted under
|
|
360
564
|
* `others`, never shown.
|
|
361
565
|
*/
|
|
362
566
|
export async function changeFeedback(io, id, opts) {
|
|
@@ -373,7 +577,9 @@ export async function changeFeedback(io, id, opts) {
|
|
|
373
577
|
const answered = got.every((g) => g.answers.some((a) => byReviewer(a, reviewer) && Date.parse(a.at) > since));
|
|
374
578
|
const waiting = opts.wait !== undefined && !answered;
|
|
375
579
|
if (!waiting || now() >= deadline) {
|
|
376
|
-
const open = got
|
|
580
|
+
const open = got
|
|
581
|
+
.flatMap((g) => g.feedback)
|
|
582
|
+
.filter((f) => f.open && (!ok(f) || byReviewer(f, reviewer)));
|
|
377
583
|
const shown = open
|
|
378
584
|
.filter((f) => ok(f))
|
|
379
585
|
.map((f) => ({
|
|
@@ -413,9 +619,10 @@ export async function changeFeedback(io, id, opts) {
|
|
|
413
619
|
}
|
|
414
620
|
/**
|
|
415
621
|
* `cupola change answer <work> --feedback <id> --body-file <f> [--settle]`:
|
|
416
|
-
* answers open feedback that `change feedback` shows; with
|
|
417
|
-
* closes it (fixed, declined, or already answered). Feedback
|
|
418
|
-
* human is answered without `--settle`, and stays open.
|
|
622
|
+
* answers open feedback of the reviewer that `change feedback` shows; with
|
|
623
|
+
* `--settle`, also closes it (fixed, declined, or already answered). Feedback
|
|
624
|
+
* that goes to a human is answered without `--settle`, and stays open. What a
|
|
625
|
+
* person opened is a reaction: `cupola reaction reply` answers it at the gate.
|
|
419
626
|
*/
|
|
420
627
|
export async function changeAnswer(io, id, opts) {
|
|
421
628
|
if (!opts.feedback)
|
|
@@ -431,9 +638,8 @@ export async function changeAnswer(io, id, opts) {
|
|
|
431
638
|
const item = (await c.host.feedback(c.change.number, ok)).feedback.find((f) => f.id === opts.feedback && f.open && ok(f));
|
|
432
639
|
if (!item)
|
|
433
640
|
continue;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
throw new Error(`${item.id} was opened by ${item.author}, not the reviewer: answer it without --settle`);
|
|
641
|
+
if (!byReviewer(item, reviewer)) {
|
|
642
|
+
throw new Error(`${item.id} was opened by ${item.author}, not the reviewer: it is a reaction, answered at the gate with \`cupola reaction reply\``);
|
|
437
643
|
}
|
|
438
644
|
await c.host.answer(c.change.number, item.id, body, opts.settle === true);
|
|
439
645
|
io.out(opts.json
|
package/dist/commands/epic.js
CHANGED
|
@@ -5,7 +5,7 @@ import { epicPath, loadConfig, pathsAt } from "../config.js";
|
|
|
5
5
|
import { today } from "../day.js";
|
|
6
6
|
import { parseFrontMatter } from "../frontmatter.js";
|
|
7
7
|
import { git, originDefaultBranch } from "../git.js";
|
|
8
|
-
import {
|
|
8
|
+
import { codeHost } from "../host/index.js";
|
|
9
9
|
import { parseRecord } from "../record.js";
|
|
10
10
|
import { epicBranchName, epicFront, specNamesOf } from "../spec.js";
|
|
11
11
|
import { gitTree } from "../tree.js";
|
|
@@ -193,7 +193,7 @@ async function syncOne(io, root, id, opts) {
|
|
|
193
193
|
out({ epic: id, branch, merged: true, conflicts: [] }, `merged ${base} into ${branch}`);
|
|
194
194
|
return 0;
|
|
195
195
|
}
|
|
196
|
-
/** The Log marker of an epic aborted after
|
|
196
|
+
/** The Log marker of an epic aborted after its start, on each of its cases (its status derives from it). */
|
|
197
197
|
export function abortedMarker(epic) {
|
|
198
198
|
return `<!-- cupola:aborted ${JSON.stringify({ epic })} -->`;
|
|
199
199
|
}
|
|
@@ -282,7 +282,7 @@ export async function epicAbort(io, id, opts) {
|
|
|
282
282
|
const closed = [];
|
|
283
283
|
// Every repository the epic touches: its epic branch's change and its specs'.
|
|
284
284
|
for (const repo of repos) {
|
|
285
|
-
const host = (io.host ??
|
|
285
|
+
const host = (io.host ?? codeHost)(repo.main);
|
|
286
286
|
for (const branch of branches) {
|
|
287
287
|
const change = await host.findChange(branch);
|
|
288
288
|
if (change?.state !== "open")
|