@kyuki3rain/cupola 0.0.0-stage → 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.
Files changed (125) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/LICENSE +202 -0
  3. package/README.md +41 -2
  4. package/dist/adr.js +106 -0
  5. package/dist/branch-store.js +73 -0
  6. package/dist/catalog.js +137 -0
  7. package/dist/check.js +192 -0
  8. package/dist/cli.js +8 -0
  9. package/dist/code.js +216 -0
  10. package/dist/commands/change.js +728 -0
  11. package/dist/commands/epic.js +311 -0
  12. package/dist/commands/execution.js +482 -0
  13. package/dist/commands/install.js +109 -0
  14. package/dist/commands/locks.js +243 -0
  15. package/dist/commands/reaction.js +185 -0
  16. package/dist/commands/revision.js +139 -0
  17. package/dist/commands/run.js +1021 -0
  18. package/dist/commands/setup.js +414 -0
  19. package/dist/commands/spec.js +80 -0
  20. package/dist/commands/status.js +1457 -0
  21. package/dist/commands/trace.js +474 -0
  22. package/dist/commands/wait.js +105 -0
  23. package/dist/commands/work.js +126 -0
  24. package/dist/commands/workspace.js +137 -0
  25. package/dist/commands/worktree.js +422 -0
  26. package/dist/config.js +353 -0
  27. package/dist/day.js +29 -0
  28. package/dist/e2e-project.js +62 -0
  29. package/dist/e2e.js +207 -0
  30. package/dist/engine/cc-sdd.js +164 -0
  31. package/dist/epic.js +379 -0
  32. package/dist/execution.js +272 -0
  33. package/dist/feedback.js +20 -0
  34. package/dist/frontmatter.js +20 -0
  35. package/dist/git.js +365 -0
  36. package/dist/host/git.js +224 -0
  37. package/dist/host/github.js +387 -0
  38. package/dist/host/host.js +3 -0
  39. package/dist/host/index.js +63 -0
  40. package/dist/install.js +182 -0
  41. package/dist/io.js +46 -0
  42. package/dist/main.js +866 -0
  43. package/dist/method/v1.js +56 -0
  44. package/dist/reaction.js +110 -0
  45. package/dist/record.js +507 -0
  46. package/dist/release.js +84 -0
  47. package/dist/repo.js +13 -0
  48. package/dist/runbook.js +132 -0
  49. package/dist/safe-write.js +80 -0
  50. package/dist/spec.js +171 -0
  51. package/dist/status.js +321 -0
  52. package/dist/templates.js +50 -0
  53. package/dist/trace.js +275 -0
  54. package/dist/tracker/files.js +99 -0
  55. package/dist/tracker/github-issues.js +217 -0
  56. package/dist/tracker/index.js +34 -0
  57. package/dist/tracker/tracker.js +69 -0
  58. package/dist/tree.js +59 -0
  59. package/dist/trust.js +13 -0
  60. package/dist/version.js +5 -0
  61. package/dist/work.js +170 -0
  62. package/dist/workspace.js +324 -0
  63. package/npm-shrinkwrap.json +2014 -0
  64. package/package.json +41 -4
  65. package/skills/cupola-abort/SKILL.md +51 -0
  66. package/skills/cupola-adr/SKILL.md +54 -0
  67. package/skills/cupola-ask/SKILL.md +42 -0
  68. package/skills/cupola-catalog/SKILL.md +41 -0
  69. package/skills/cupola-catalog-draft/SKILL.md +116 -0
  70. package/skills/cupola-complete/SKILL.md +107 -0
  71. package/skills/cupola-decide/SKILL.md +99 -0
  72. package/skills/cupola-doc/SKILL.md +52 -0
  73. package/skills/cupola-e2e-setup/SKILL.md +78 -0
  74. package/skills/cupola-e2e-test/SKILL.md +115 -0
  75. package/skills/cupola-epic-accept/SKILL.md +166 -0
  76. package/skills/cupola-epic-create/SKILL.md +160 -0
  77. package/skills/cupola-epic-revise/SKILL.md +92 -0
  78. package/skills/cupola-epic-run/SKILL.md +166 -0
  79. package/skills/cupola-fix/SKILL.md +117 -0
  80. package/skills/cupola-init/SKILL.md +143 -0
  81. package/skills/cupola-intake/SKILL.md +95 -0
  82. package/skills/cupola-operate/SKILL.md +81 -0
  83. package/skills/cupola-resolve/SKILL.md +93 -0
  84. package/skills/cupola-respond/SKILL.md +73 -0
  85. package/skills/cupola-review/SKILL.md +131 -0
  86. package/skills/cupola-spec-design/SKILL.md +169 -0
  87. package/skills/cupola-spec-impl/SKILL.md +137 -0
  88. package/skills/cupola-spec-run/SKILL.md +137 -0
  89. package/skills/cupola-steering/SKILL.md +53 -0
  90. package/skills/cupola-try/SKILL.md +38 -0
  91. package/templates/install/.kiro/steering/e2e.md +48 -0
  92. package/templates/install/.kiro/steering/operations.md +109 -0
  93. package/templates/install/.kiro/steering/principles.md +25 -0
  94. package/templates/install/CLAUDE.md +19 -0
  95. package/templates/install/adr/TEMPLATE.md +38 -0
  96. package/templates/install/cc-sdd/patches.json +31 -0
  97. package/templates/method-1/behavior-area.md +43 -0
  98. package/templates/method-1/behavior-index.md +16 -0
  99. package/templates/method-1/card.md +49 -0
  100. package/templates/method-1/case-draft.md +25 -0
  101. package/templates/method-1/case.md +38 -0
  102. package/templates/method-1/catalog-spec.md +33 -0
  103. package/templates/method-1/changes/adr.md +4 -0
  104. package/templates/method-1/changes/catalog.md +29 -0
  105. package/templates/method-1/changes/doc.md +5 -0
  106. package/templates/method-1/changes/e2e.md +7 -0
  107. package/templates/method-1/changes/epic.md +30 -0
  108. package/templates/method-1/changes/fix.md +21 -0
  109. package/templates/method-1/changes/release.md +23 -0
  110. package/templates/method-1/changes/spec.md +55 -0
  111. package/templates/method-1/changes/system.md +13 -0
  112. package/templates/method-1/cupola-issue-draft.md +17 -0
  113. package/templates/method-1/epic.md +147 -0
  114. package/templates/method-1/execution.md +55 -0
  115. package/templates/method-1/fix-spec.md +34 -0
  116. package/templates/method-1/fix.md +39 -0
  117. package/templates/method-1/lock.json +13 -0
  118. package/templates/method-1/no-go.md +28 -0
  119. package/templates/method-1/phase-outcome.json +29 -0
  120. package/templates/method-1/reaction.md +17 -0
  121. package/templates/method-1/record.json +63 -0
  122. package/templates/method-1/report.md +27 -0
  123. package/templates/method-1/runbook.md +45 -0
  124. package/templates/method-1/runner-result.json +6 -0
  125. package/templates/methods.json +13 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,184 @@
1
+ # Changelog
2
+
3
+ Cupola follows [Semantic Versioning](https://semver.org/). Before 1.0, a minor version may change
4
+ behavior; a patch version only fixes. Documents Cupola writes record their format as `method`: work in
5
+ flight keeps its method until done, and `cupola update` moves the rest forward.
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
+
165
+ ## 0.1.0
166
+
167
+ First public release.
168
+
169
+ - Skills and a CLI for the whole flow on top of cc-sdd: cases, epics, specs in three modes (full, fix,
170
+ catalog), gates G1–G5, one repository or several, in components.
171
+ - A user guide (`docs/guide.md`, Japanese `docs/guide.ja.md`).
172
+ - Every document can live in the hub (`documents: "hub"`): other repositories hold only code.
173
+ - `cupola wait` follows an epic past its gates on its own.
174
+ - Only trusted people are acted on: by default the repository's owners, members, and collaborators
175
+ (`trust` in `.cupola/config.json`). An issue someone else opened is not taken as a case; their
176
+ comments are counted, never followed.
177
+ - At G3, a change can be sent back by leaving feedback on it; the run answers it in review.
178
+ - `timezone` in `.cupola/config.json` (an IANA name) sets the day records and documents are dated in;
179
+ `cupola init` writes the machine's zone.
180
+ - Writes stay inside the repository (symlinks, repository names, IDs are checked).
181
+ - `cupola init` denies Claude Code the git commands only a human runs (force pushes, pushes to the
182
+ default branch, changing remotes).
183
+ - cc-sdd is checked against a digest before it is installed; dependencies are pinned by
184
+ `npm-shrinkwrap.json`.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025-2026 kyuki3rain
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # Cupola
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **Status: beta.**
4
+
5
+ Cupola is a way of building software with AI agents in which **people decide how the system should
6
+ behave, and AI builds it**. You agree on use cases and examples; the AI writes the tests and the code,
7
+ works through to the next point where a person is needed, and shows you what changed in behavior and
8
+ how it was verified. You don't review code.
9
+
10
+ It runs in [Claude Code](https://claude.com/claude-code) as `cupola-*` skills and a small CLI, on top of
11
+ [cc-sdd](https://github.com/gotalab/cc-sdd).
12
+
13
+ ```sh
14
+ npx @kyuki3rain/cupola init # in your repository
15
+ ```
16
+
17
+ Then, in Claude Code: `cupola-init`.
18
+
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.
22
+ - **A behavior catalog.** What the system promises, one line per behavior, traced to the tests that
23
+ check it and their latest results.
24
+ - **Any shape of system.** One repository, a monorepo, or several repositories, in components.
25
+ - **Nothing to keep in your head.** `cupola status <work>` always names whose turn it is and the one
26
+ thing to do next.
27
+
28
+ Read the **[guide](docs/guide.md)** to set up a project and take a first problem to its release.
29
+
30
+ ## 日本語
31
+
32
+ > **ベータ版です。**
33
+
34
+ Cupola は、AI エージェントと一緒にソフトウェアを作るための進め方です。**システムがどう振る舞うべきかは人が決め、作るのは AI です。** 人はユースケースと例について合意します。AI はテストとコードを書き、人が必要になるところまで進みます。そして、振る舞いの何が変わったか、どう確かめたかを見せます。人はコードをレビューしません。
35
+
36
+ [Claude Code](https://claude.com/claude-code) の上で、`cupola-*` スキルと小さな CLI として動きます。土台は [cc-sdd](https://github.com/gotalab/cc-sdd) です。
37
+
38
+ 使い方は **[ガイド](docs/guide.ja.md)** を見てください。
39
+
40
+ ## License
41
+
42
+ [Apache-2.0](LICENSE)
package/dist/adr.js ADDED
@@ -0,0 +1,106 @@
1
+ import { existsSync } from "node:fs";
2
+ import { readdir, readFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { z } from "zod";
5
+ import { parseFrontMatter } from "./frontmatter.js";
6
+ /**
7
+ * Decision records: `<paths.adr>/<id>.md`, by default `.cupola/adr/`. Their index is derived from
8
+ * their front matter whenever it is read (`cupola adr list`), never stored.
9
+ */
10
+ const Adr = z.strictObject({
11
+ kind: z.literal("adr"),
12
+ method: z.number().int(),
13
+ id: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "an imperative slug in kebab case"),
14
+ date: z.union([z.string().regex(/^\d{4}-\d{2}-\d{2}$/), z.date()]),
15
+ summary: z.string().min(1),
16
+ "applies-to": z.array(z.string()).min(1),
17
+ from: z.string().min(1),
18
+ supersedes: z.union([z.string(), z.array(z.string())]).optional(),
19
+ });
20
+ async function readAdrs(root, adrDir) {
21
+ const dir = join(root, adrDir);
22
+ const adrs = [];
23
+ const problems = [];
24
+ if (!existsSync(dir))
25
+ return { adrs, problems };
26
+ for (const f of (await readdir(dir)).sort()) {
27
+ if (!f.endsWith(".md") || f === "README.md" || f === "TEMPLATE.md")
28
+ continue;
29
+ const file = `${adrDir}/${f}`;
30
+ const parsed = Adr.safeParse(parseFrontMatter(await readFile(join(dir, f), "utf8")).data);
31
+ if (!parsed.success) {
32
+ for (const i of parsed.error.issues)
33
+ problems.push({
34
+ file,
35
+ message: `front matter ${i.path.join(".") || "(root)"}: ${i.message}`,
36
+ });
37
+ continue;
38
+ }
39
+ const date = parsed.data.date instanceof Date
40
+ ? parsed.data.date.toISOString().slice(0, 10)
41
+ : parsed.data.date;
42
+ if (parsed.data.id !== f.slice(0, -3))
43
+ problems.push({ file, message: `id is ${parsed.data.id}, but the file is ${f}` });
44
+ const s = parsed.data.supersedes;
45
+ adrs.push({
46
+ ...parsed.data,
47
+ date,
48
+ supersedes: s === undefined ? [] : Array.isArray(s) ? s : [s],
49
+ });
50
+ }
51
+ const ids = new Set(adrs.map((a) => a.id));
52
+ for (const a of adrs) {
53
+ for (const sup of a.supersedes)
54
+ if (!ids.has(sup))
55
+ problems.push({
56
+ file: `${adrDir}/${a.id}.md`,
57
+ message: `supersedes ${sup}, which does not exist`,
58
+ });
59
+ }
60
+ return { adrs, problems };
61
+ }
62
+ /**
63
+ * The index, derived from the records whenever it is read (never stored):
64
+ * newest first. With `appliesTo`, only the ADRs whose `applies-to` holds one of
65
+ * the values or a dotted child of it (`operations` matches `operations.lifetime`).
66
+ */
67
+ export async function listAdrs(root, adrDir, appliesTo = []) {
68
+ const { adrs, problems } = await readAdrs(root, adrDir);
69
+ const by = new Map(adrs.flatMap((a) => a.supersedes.map((sup) => [sup, a.id])));
70
+ const matches = (a) => appliesTo.length === 0 ||
71
+ a["applies-to"].some((x) => appliesTo.some((w) => x === w || x.startsWith(`${w}.`)));
72
+ const entries = adrs
73
+ .filter(matches)
74
+ .sort((a, b) => b.date.localeCompare(a.date) || a.id.localeCompare(b.id))
75
+ .map((a) => {
76
+ const sup = by.get(a.id);
77
+ return {
78
+ id: a.id,
79
+ date: a.date,
80
+ "applies-to": a["applies-to"],
81
+ summary: a.summary.replace(/\s+/g, " "),
82
+ file: `${adrDir}/${a.id}.md`,
83
+ ...(sup ? { supersededBy: sup } : {}),
84
+ };
85
+ });
86
+ return { adrs: entries, problems };
87
+ }
88
+ /** The text form: current ADRs, then superseded ones. */
89
+ export function renderAdrList(adrs) {
90
+ const current = adrs
91
+ .filter((a) => !a.supersededBy)
92
+ .map((a) => `${a.id} — ${a.date} — ${a["applies-to"].join(", ")} — ${a.summary}`);
93
+ const superseded = adrs
94
+ .filter((a) => a.supersededBy)
95
+ .map((a) => `${a.id} — superseded by ${a.supersededBy}`);
96
+ const lines = current.length > 0 ? current : ["No ADRs."];
97
+ return superseded.length > 0
98
+ ? [...lines, "", "Superseded:", ...superseded].join("\n")
99
+ : lines.join("\n");
100
+ }
101
+ /** For `cupola check`: every ADR's front matter, its id, and what it supersedes. */
102
+ export async function checkAdrs(root, adrDir) {
103
+ if (!existsSync(join(root, adrDir)))
104
+ return [];
105
+ return (await readAdrs(root, adrDir)).problems;
106
+ }
@@ -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
+ }