@jakobm/peacekeeper 0.28.0 → 0.30.1

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/README.md CHANGED
@@ -15,9 +15,9 @@ completion follows the same hierarchy.
15
15
  | Group | Commands |
16
16
  | --- | --- |
17
17
  | `project` | `create`, `check`, `update-config`, `check-conventions` |
18
- | `test` | `run`, `check-receipt`, `record-receipt` |
19
- | `github` | `configure`, `generate-setup` |
20
- | `release` | `assess`, `verify`, `verify-protection`, `verify-version`, `publish` |
18
+ | `test` | `run`, `check-receipt`, `record-receipt`, `prepare` |
19
+ | `github` | `check`, `configure`, `generate-setup` |
20
+ | `release` | `assess`, `verify`, `verify-version`, `publish` |
21
21
  | `codex` | `install-hooks`, `init-worktree`, `checkpoint`, `session-start`, `stop`, `session-end` |
22
22
  | `cleanup` | `merged-branches`, `empty-directories`, `queue-merged-worktree` |
23
23
 
@@ -31,8 +31,9 @@ peacekeeper cleanup merged-branches --execute
31
31
 
32
32
  The previous flat command names remain accepted for existing scripts and hooks.
33
33
  For example, `run-tests --checkpoint` maps to `test run --checkpoint`,
34
- `checkpoint-codex-changes` maps to `codex checkpoint`, and `release patch` maps
35
- to `release publish patch`. Bare `release` now displays the release group's help.
34
+ and `checkpoint-codex-changes` maps to `codex checkpoint`. The old `release patch`
35
+ syntax has been removed; use `npm run release -- --bump patch`. Bare
36
+ `release` displays the release group's help.
36
37
  Help and generated project files use the grouped names. Update existing package
37
38
  scripts and CI to those names. The legacy hook installer remains available, but its repository-local files
38
39
  conflict with the current project requirements.
@@ -66,6 +67,10 @@ The CLI also exposes Cmdabra's global `--cmdabra-complete` option for
66
67
  It accepts the current word index followed by all command-line words and prints
67
68
  completion candidates without running a command.
68
69
 
70
+ Use `peacekeeper --cmdabra-completion bash` to print a completion script or
71
+ `peacekeeper --cmdabra-install-completion bash` to install it. Both options
72
+ support `bash`, `zsh`, and `fish`.
73
+
69
74
  ## Testing Peacekeeper
70
75
 
71
76
  Run `npm test` with the pinned Volta toolchain to build and run type checks,
@@ -84,6 +89,172 @@ cover deterministic output and local preflight failures for those commands.
84
89
  CLI syntax validation and generated help output are covered by Cmdabra's own tests.
85
90
  Expected output is reviewed text; tests never regenerate it automatically.
86
91
 
92
+ ## Reuse the central workflows
93
+
94
+ Use Peacekeeper's reusable workflows for PR checks and npm publication. They
95
+ check out the calling repository, select its pinned Node/npm versions through
96
+ Volta, and run `npm ci`. The PR workflow verifies GitHub policy and runs
97
+ `npm test`; the publish workflow verifies the release and runs `npm publish`
98
+ through OIDC. Put project-specific checks, including packaging checks, in
99
+ `tests.all`. Neither workflow accepts inputs.
100
+
101
+ Install a Peacekeeper version containing this support before switching. Older
102
+ versions may reject required reusable jobs or lack the `github check` command
103
+ used by the revised workflow. A minimal `.github/workflows/test.yml` is:
104
+
105
+ ```yaml
106
+ on:
107
+ pull_request:
108
+ branches: [main]
109
+ permissions:
110
+ contents: read
111
+ jobs:
112
+ test:
113
+ uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@071a6102729107f4f4f01851e0b661355985a676
114
+ secrets:
115
+ RELEASE_POLICY_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
116
+ ```
117
+
118
+ For npm packages, keep a separate publishing entrypoint with its existing filename
119
+ (the filename forms part of the npm trusted-publisher registration):
120
+
121
+ ```yaml
122
+ on:
123
+ push:
124
+ tags: ['v*']
125
+ permissions:
126
+ contents: read
127
+ id-token: write
128
+ jobs:
129
+ publish:
130
+ uses: jakobmattsson/peacekeeper/.github/workflows/reusable-publish.yml@a438e3d706a1812fea72dc0858378566f4e3bb21
131
+ secrets:
132
+ RELEASE_POLICY_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
133
+ ```
134
+
135
+ The caller owns event triggers, explicit permissions, and secret mapping.
136
+ GitHub does not let the called workflow raise permissions granted by the caller;
137
+ publication therefore declares `id-token: write` in both. `name` is optional.
138
+ Use `git.defaultBranch` in the PR trigger. Pass the policy secret explicitly;
139
+ `secrets: inherit` is not supported, and its source may have another name.
140
+ The policy token is exposed only to verification. Configure repository secrets,
141
+ GitHub protection, and npm trusted publishing separately; fork PRs do not receive
142
+ repository secrets. npm must authorize the calling repository and entrypoint.
143
+
144
+ GitHub names the checks `test / test` and `publish / publish`: the caller job's
145
+ name (or ID), followed by the central job name. Merge these fields into the full
146
+ project configuration:
147
+
148
+ ```yaml
149
+ projectChecks:
150
+ testWorkflow: test.yml
151
+ requiredJobs: ['test / test']
152
+ git:
153
+ releaseTestWorkflow: test.yml
154
+ releaseRequiredChecks: ['test / test']
155
+ ```
156
+
157
+ If the caller has `name: CI`, require `CI / test` instead. Update GitHub's required
158
+ checks to the same name when migrating and confirm it in a PR run. A skipped or
159
+ renamed check cannot satisfy release verification. Additional local jobs remain
160
+ supported and are validated separately when required. `project create` generates
161
+ these thin callers, including publication for npm projects.
162
+
163
+ Peacekeeper trusts reviewed central implementations through the full workflow
164
+ commit SHAs bundled in
165
+ [`reusable-workflows.json`](src/modules/releases/reusable-workflows.json).
166
+ Caller contracts are checked offline, without downloading remote YAML. Unknown
167
+ SHAs, branch names, tags, inherited secrets, inputs, matrices and runner/step
168
+ or failure-handling overrides are rejected. Inline workflows remain supported.
169
+
170
+ To approve an update, review, test and commit the central workflows first, then
171
+ add that commit's full SHA to the allowlist in a subsequent commit. Preserve the
172
+ single static `test` or `publish` job, explicit policy secret, no-input contract,
173
+ and verified setup and step order. Contract tests check both implementations
174
+ through the public project checker. Consumers deliberately update approved pins.
175
+
176
+ ## Strict version history
177
+
178
+ Set the optional top-level `strictVersionHistory` boolean in
179
+ `peacekeeper.config.yaml` to require an increasing package version for each
180
+ future merge to the default branch:
181
+
182
+ ```yaml
183
+ strictVersionHistory: true
184
+ ```
185
+
186
+ Peacekeeper itself enables this setting; every PR must increase the package version.
187
+
188
+ The default is `false`, including for existing files that omit the field.
189
+ `project update-config` inserts an explicit `false` without changing an existing
190
+ value. With `false`, GitHub protection remains mandatory and versions may stay
191
+ unchanged between merges.
192
+
193
+ `peacekeeper github check` verifies the repository's GitHub protection and, when
194
+ strict history is enabled, compares the incoming checkout's `package.json`
195
+ version with the version on GitHub's actual default branch. It reads the branch
196
+ commit and then fetches its package metadata by that immutable SHA. Local
197
+ remote-tracking refs, full Git history and an explicit base argument are not
198
+ needed. Missing or invalid versions and unavailable API data fail verification.
199
+ The version must be strictly greater according to semver precedence; changing
200
+ build metadata alone does not count as an increase.
201
+
202
+ Required strict status checks force a parallel PR to update and pass CI again
203
+ after another PR merges. A version already taken by that merge must be raised
204
+ again. The rule applies to the default branch's first-parent merge history;
205
+ feature-branch commits may share versions. It does not audit older history or
206
+ require every version to be published, and it does not select the appropriate
207
+ major/minor/patch increment for you.
208
+
209
+ The GitHub check is separate from offline `project check`, local tests and
210
+ checkpoints, so development can proceed before choosing a version. Use
211
+ `github check` in PR workflows. Older verification command names and workflow
212
+ revisions that invoke them are unsupported by this version of Peacekeeper.
213
+
214
+ Publication's `release verify` continues to verify GitHub protection, tag/package/
215
+ lockfile agreement and the merged PR's CI independently. It does not apply the
216
+ incoming-version comparison to an already merged release. With strict history,
217
+ `npm run release` publishes the existing default-branch version without creating
218
+ a version-bump PR.
219
+
220
+ ## Standard CI test environment
221
+
222
+ The central PR workflow runs one Ubuntu 24.04 job. It cancels superseded runs for
223
+ one PR, installs npm dependencies, validates the project, prepares the test
224
+ prerequisites, verifies GitHub policy and runs `npm test`.
225
+
226
+ Declare the optional test prerequisites in `peacekeeper.config.yaml`:
227
+
228
+ ```yaml
229
+ tests:
230
+ aptPackages: [ledger, bash-completion]
231
+ playwrightBrowsers: [chromium, webkit]
232
+ ```
233
+
234
+ Both lists default to empty. `aptPackages` installs Ubuntu packages, optionally
235
+ pinned as `name=version`. `playwrightBrowsers` installs the named browsers and
236
+ their system dependencies using the project's installed Playwright CLI. The
237
+ project's lockfile therefore selects the matching browser versions. An empty
238
+ browser list skips Playwright installation entirely, including its system
239
+ dependencies; Peacekeeper never installs the Playwright npm package itself.
240
+
241
+ `test prepare` installs these prerequisites after `npm ci` and before tests.
242
+ `project update-config` adds explicit empty lists to existing configurations.
243
+ The standard workflow allows 15 minutes for preparation, 30 minutes for tests
244
+ and 60 minutes for the overall job. Upgrade the approved PR workflow pin
245
+ together with Peacekeeper when adopting this preparation support.
246
+
247
+ Keep actual package, image and application checks in the canonical test chain.
248
+ `npm test` must run the complete intended verification. It can use Peacekeeper's
249
+ runner or the project's independent test engine. For an independent engine,
250
+ set `tests.npmTestUsesRunner: false` and `tests.all: ['npm test']`; that npm
251
+ script must not invoke `peacekeeper test run` recursively. Project validation
252
+ also runs explicitly in CI.
253
+
254
+ Projects needing additional setup or reporting can define their own workflows
255
+ with ordinary GitHub Actions steps. The standard workflow only configures the
256
+ two prerequisite lists above.
257
+
87
258
  ## Create a compliant TypeScript project
88
259
 
89
260
  `project create` creates a minimal ESM TypeScript library in an existing, completely
@@ -224,7 +395,7 @@ is a separate step; a secret-sync failure does not roll back GitHub settings.
224
395
  Use a manually authenticated GitHub identity with repository Administration write
225
396
  access for execute, and sufficient Contents/Administration read access for complete
226
397
  policy inspection. Do not put admin-write credentials in Actions secrets.
227
- The shared policy model also serves `release verify-protection`; that existing
398
+ The shared policy model also serves `github check`; that existing
228
399
  command retains its documented semantic alternatives, including equivalent classic
229
400
  protection, while github configure verifies the exact owned configuration.
230
401
 
@@ -321,13 +492,14 @@ All CLI commands validate configuration before executing, except help,
321
492
  `project check --explain`, and `project update-config`. Checkpoint hooks instead validate
322
493
  the event worktree configuration when the event requires instructions or a check.
323
494
  An incomplete existing file fails
324
- with missing field paths and a repair hint. Updates introducing new fields
495
+ with missing field paths and a repair hint. Updates introducing new required fields
325
496
  therefore require `peacekeeper project update-config` before ordinary commands can run.
326
497
 
327
498
  Complete example:
328
499
 
329
500
  ```yaml
330
501
  publishesToNpm: false
502
+ strictVersionHistory: false
331
503
  git:
332
504
  remote: origin
333
505
  defaultBranch: main
@@ -744,12 +916,12 @@ With `true`, declare a publishable package (`private` absent or `false`), a vali
744
916
  npm name, stable version, description, license, nonempty `files` list, and
745
917
  `publishConfig` with registry `https://registry.npmjs.org/` and explicit access
746
918
  `public` or `restricted`. Add a direct `peacekeeper release publish` package script
747
- (the npm-exec and local Node CLI forms are also supported), a packaging check
748
- after `npm ci` in the selected PR workflow
749
- (`npm pack`, optionally `--dry-run --json`, or `npm run test:package`), and the
750
- verified OIDC release workflow described below. Installation tests of the packed
751
- package in a temporary consumer project are recommended. A named package-test
752
- script is a declaration; the local check does not inspect its assertions.
919
+ (the npm-exec and local Node CLI forms are also supported) and the verified OIDC
920
+ release workflow described below. Put packaging checks such as
921
+ `npm pack --dry-run --json` or `npm run test:package` in `tests.all`.
922
+ Installation tests of the packed package in a temporary consumer project are
923
+ recommended. The local checker does not enforce a special packaging command
924
+ or inspect test-script assertions.
753
925
 
754
926
  With `false`, set `package.json.private` to `true` and remove `publishConfig`,
755
927
  `files`, npm publication/release scripts, and npm publication workflow steps.
@@ -759,7 +931,7 @@ proven free of publication code by this local check. Remove dedicated npm
759
931
  publishing credentials and trusted-publisher registrations separately.
760
932
  Internal `npm pack`, build scripts, module entry points and CLI metadata remain
761
933
  allowed, as do deployment workflows and read authentication for dependencies.
762
- PR checks, lockfiles, toolchain requirements and `release verify-protection`
934
+ PR checks, lockfiles, toolchain requirements and `github check`
763
935
  remain independent of publication intent, including `git.releaseRequiredChecks`.
764
936
 
765
937
  All projects must declare nonblank `author` and `repository` values in
@@ -825,8 +997,10 @@ model selection remains at Codex's default.
825
997
  default-branch commit being assessed. Peacekeeper supplies these full commit IDs,
826
998
  independently of the AI response. They remain available when Codex cannot complete
827
999
  its analysis. Each is `null` if it could not be resolved and verified. The target
828
- identifies the source code a release would start from at assessment time; a later
829
- release adds its version commit and tags the actual release PR merge commit.
1000
+ identifies the source code at assessment time. The target package version may
1001
+ already be higher than the published version; assessment still considers all changes
1002
+ since the published release. A release without a bump tags the selected default-branch
1003
+ commit; a release with a bump tags the resulting release PR merge commit.
830
1004
 
831
1005
  The command requires Git, npm, an authenticated GitHub CLI (`gh`) with repository
832
1006
  read access, and an installed, authenticated Codex CLI supporting `codex exec`,
@@ -835,8 +1009,9 @@ which must match `git.defaultBranch`, and pins its exact commit. It uses the
835
1009
  highest stable version published on the public npm registry as the baseline;
836
1010
  prereleases and tags without npm publication do not advance that baseline.
837
1011
  The published version must have a matching remote `v<version>` tag in the target's
838
- ancestry. Package names and versions at the tag and target must agree with npm;
839
- when npm supplies `gitHead`, it must match the tag's commit. Missing tags,
1012
+ ancestry. The package name at both revisions and the version at the published
1013
+ tag must agree with npm; the target version may already be higher. When npm
1014
+ supplies `gitHead`, it must match the tag's commit. Missing tags,
840
1015
  inconsistent metadata, no previous stable publication, unsupported private or
841
1016
  workspace packages, and unavailable history or services produce `undetermined`.
842
1017
  It does not guess an older baseline when the latest stable release cannot be verified.
@@ -881,14 +1056,14 @@ with direct publishing enabled. Confirm npm publish access to the `@jakobm`
881
1056
  scope separately from GitHub repository access. The workflow verifies
882
1057
  the release and publishes via OIDC. It needs no npm access token.
883
1058
 
884
- `test.yml` runs `test` and `Test package` on pull requests. `package.yml` runs
1059
+ `test.yml` calls the central PR workflow, producing `test / test`. `package.yml` calls the central publication workflow and runs
885
1060
  on `v*` tags and only verifies and publishes. Merging to `main` does not start
886
1061
  another run.
887
1062
 
888
1063
  Release verification uses GitHub's enforced branch policy instead of retaining
889
1064
  artifacts of tested contents. Configure `git.releaseRequiredChecks` in the root
890
1065
  `peacekeeper.config.yaml` with the exact CI job names required for a release
891
- (for this repository: `["test", "Test package"]`). These checks must be mandatory
1066
+ (for this repository: `["test / test"]`). These checks must be mandatory
892
1067
  with **Require branches to be up to date before merging** enabled. Classic branch
893
1068
  protection may provide the base PR and check requirements. Active base rulesets
894
1069
  may provide them instead. Merge
@@ -914,13 +1089,14 @@ Required linear history and any applicable PR rule excluding merge commits fail
914
1089
  verification. Bypass actors for base PR and strict-check rules require manual
915
1090
  inspection only when GitHub omits them from its response.
916
1091
  Enable `allow_auto_merge` in repository settings: this permits opting in per PR;
917
- Peacekeeper never enables auto-merge on individual PRs.
1092
+ the release command enables auto-merge on its release PRs.
918
1093
 
919
1094
  `project check` makes no network requests. It runs implicitly before
920
1095
  `tests.all` or `tests.checkpoint`, including when reusing receipts, and checks that the configured
921
1096
  PR workflow uses only `pull_request`, with `branches` set to exactly
922
- `[git.defaultBranch]`, and runs `release verify-protection` with `GH_TOKEN` after `npm ci` and
923
- before tests in a job listed in `git.releaseRequiredChecks`. The job and step must
1097
+ `[git.defaultBranch]`, and runs `github check` with `GH_TOKEN` after `npm ci` and
1098
+ before tests in a job listed in `git.releaseRequiredChecks`, either through local
1099
+ steps or the approved central PR workflow above. The job and step must
924
1100
  not skip verification or ignore failures. The online verifier then checks that
925
1101
  exactly those configured check names are mandatory on GitHub, including its own
926
1102
  job; missing and additional checks are both configuration drift.
@@ -930,7 +1106,7 @@ For example, in a required `test` job:
930
1106
 
931
1107
  ```yaml
932
1108
  - run: npm ci
933
- - run: peacekeeper release verify-protection
1109
+ - run: peacekeeper github check
934
1110
  env:
935
1111
  GH_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
936
1112
  - run: npm test
@@ -941,14 +1117,16 @@ This creates a local-to-CI chain: missing workflows are detected on the next loc
941
1117
  continuous monitoring. Removing both CI and the local invocation prevents this
942
1118
  chain from running. No central scheduled audit is required by this setup.
943
1119
 
944
- The PR test job runs `peacekeeper release verify-protection` before its tests.
1120
+ The PR test job runs `peacekeeper github check` before its tests.
945
1121
  The command reads the actual default branch from GitHub, regardless of the PR
946
1122
  base. Other release commands require their configured branch to match it.
947
1123
  `peacekeeper release publish` checks the default branch before preparing a release
948
1124
  and again immediately before each merge attempt. Before publishing,
949
1125
  `peacekeeper release verify` checks the policy, matching package/tag/lockfile
950
- versions, a same-repository merged `release/v<version>` PR, and successful required
951
- jobs in its latest PR workflow run. Manual tags without that PR are rejected.
1126
+ versions, a same-repository merged PR, and successful required
1127
+ jobs in its latest PR workflow run. The PR may be a feature PR or a release PR;
1128
+ its branch name and commit message do not determine publication eligibility.
1129
+ Tags without a qualifying merged PR are rejected.
952
1130
  `release verify-version` remains available for local version checks alone.
953
1131
 
954
1132
  API failures, missing permissions, and unverifiable rules stop the commands.
@@ -1013,35 +1191,44 @@ state without a merge method. Saved unfinished releases that explicitly select
1013
1191
  squash or rebase must be restarted. `git.releaseMergeMethod` remains accepted for
1014
1192
  configuration compatibility, but no longer selects the default-branch merge method.
1015
1193
 
1016
- From a clean repository root, run `npm run release -- patch`, `minor`, or `major`.
1194
+ From a clean repository root, run `npm run release` to publish the existing version
1195
+ at the latest remote default-branch commit. With `strictVersionHistory: true`,
1196
+ versions must already have been assigned in the PRs that introduced the changes;
1197
+ release does not create a bump commit or another PR, and `--bump` is rejected.
1198
+ Not every default-branch version needs to be published.
1199
+
1200
+ With `strictVersionHistory: false` (the default), the same command publishes an
1201
+ already assigned, unpublished version. If that version is already on npm, choose
1202
+ an increment explicitly: `npm run release -- --bump patch`, `--bump minor`, or
1203
+ `--bump major`. Peacekeeper increments the version from the fetched default branch,
1204
+ updates the package and lockfiles in a temporary detached worktree, and opens a
1205
+ `release/v<version>` PR. It enables auto-merge for the expected PR head, then waits
1206
+ up to 20 minutes for GitHub to merge it, respecting checks, reviews, resolved
1207
+ conversations and branch freshness. The resulting merge commit is the release target.
1208
+
1017
1209
  The required `prerelease` script runs `npm ci` first, replacing `node_modules`
1018
1210
  with the exact dependency versions in the committed lockfile before npm resolves
1019
1211
  and starts Peacekeeper. Always use the npm script; invoking `peacekeeper release publish`
1020
- directly bypasses this dependency bootstrap.
1021
- The command fetches the default branch and uses a temporary detached worktree to
1022
- increment the package and lockfile versions. Your current branch and local default
1212
+ directly bypasses this dependency bootstrap. Your current branch and local default
1023
1213
  branch stay unchanged, including when the default branch is checked out elsewhere.
1024
- Before changing versions it logs `Preparing release from origin/<branch> at <SHA>.`
1025
- using the full source commit ID checked out in the temporary worktree.
1026
- It pushes a `release/v<version>` branch and opens a release PR. The merge method
1027
- follows the calling repository's configuration and GitHub settings. The command
1028
- waits up to 20 minutes for GitHub to accept the merge,
1029
- respecting required checks, reviews, resolved conversations, and branch freshness.
1030
- It never uses an administrator bypass or pushes directly to the default branch.
1031
-
1032
- After merge, the command verifies the package files at the PR's actual merge
1033
- commit, tags that commit with `v<version>`, and pushes the tag. The existing
1034
- workflow publishes through npm trusted publishing. The command then waits for
1035
- the publish job and for the version to appear on npm. Monitoring reads the run
1036
- status before its jobs so a job finishing between requests does not produce a
1037
- false publication failure. Git and an authenticated
1038
- GitHub CLI (`gh`) with Contents read/write, Pull requests read/write, Actions
1039
- read and the policy-reading access described above are required. Registry checks
1040
- use a temporary npm cache and request current metadata.
1214
+ The command pins the fetched source commit and logs its full SHA. It never uses
1215
+ an administrator bypass or pushes directly to the default branch.
1216
+
1217
+ Both paths verify the target package and lockfiles, GitHub protection, the merged
1218
+ PR and its successful required CI before creating and pushing `v<version>`.
1219
+ The version must be unpublished on npm; registry access failures stop the command.
1220
+ The tag-triggered workflow independently verifies the release and publishes through
1221
+ npm trusted publishing. The command waits for the publish job and npm visibility.
1222
+ Monitoring reads the run status before its jobs so a job finishing between requests
1223
+ does not produce a false publication failure. Git and an authenticated GitHub CLI
1224
+ (`gh`) with Contents read/write, Pull requests read/write, Actions read and the
1225
+ policy-reading access described above are required. Registry checks use a temporary
1226
+ npm cache and request current metadata.
1041
1227
 
1042
1228
  Retry the same command and release type after an interruption: release state is
1043
1229
  stored in `peacekeeper-release.json` in the shared Git directory, so retries
1044
- from another worktree of the same checkout continue the same PR and version.
1230
+ from another worktree of the same checkout continue the same target revision and
1231
+ version, even if the default branch has advanced.
1045
1232
  Already-merged PRs and already-pushed matching tags are reused. A local lock
1046
1233
  prevents concurrent commands in that checkout; an open release PR from a different
1047
1234
  checkout blocks a new release. Do not delete the state or manually create a new
@@ -1060,7 +1247,7 @@ Other npm projects can use this command through package scripts such as
1060
1247
  former automatically before the latter. The project must use a root package
1061
1248
  with a stable version, a `peacekeeper.config.yaml` with
1062
1249
  `git.releaseRequiredChecks`, and the supported tag-triggered GitHub Actions
1063
- publish job. Add `peacekeeper release verify-protection` to a required PR
1250
+ publish job. Add `peacekeeper github check` to a required PR
1064
1251
  test job and `peacekeeper release verify` before publishing, with `GH_TOKEN`
1065
1252
  and `RELEASE_TAG` set for release verification. Both commands are shipped with
1066
1253
  the package; no verifier script or artifact upload needs to be copied.
package/dist/cmdabra.yaml CHANGED
@@ -44,7 +44,7 @@ commands:
44
44
  description: Replace generated output directories after successful generation; check other rules.
45
45
  type: boolean
46
46
  test:
47
- description: Run tests and manage command receipts.
47
+ description: Prepare test prerequisites, run tests and manage command receipts.
48
48
  commands:
49
49
  run:
50
50
  description: Run tests.all, reusing valid receipts for individual commands.
@@ -67,9 +67,13 @@ commands:
67
67
  checkpoint:
68
68
  description: Record tests.checkpoint instead of tests.all.
69
69
  type: boolean
70
+ prepare:
71
+ description: Install tests.aptPackages and tests.playwrightBrowsers when configured.
70
72
  github:
71
- description: Configure GitHub repository policy.
73
+ description: Check and configure GitHub repository policy.
72
74
  commands:
75
+ check:
76
+ description: Verify GitHub protection and configured version history requirements.
73
77
  configure:
74
78
  description: Plan or apply exact GitHub policy from a SHA-pinned remote source.
75
79
  named-options:
@@ -105,15 +109,13 @@ commands:
105
109
  description: Assess unpublished changes with Codex and return a JSON recommendation.
106
110
  verify:
107
111
  description: Verify release versions, required CI and strict branch protection.
108
- verify-protection:
109
- description: Require strict mandatory release checks without bypass.
110
112
  verify-version:
111
113
  description: Check a release tag against package and lockfile versions.
112
114
  publish:
113
115
  description: Publish a version through a GitHub Actions npm workflow.
114
- positional-arguments:
116
+ named-options:
115
117
  bump:
116
- description: Version increment to publish.
118
+ description: Increment the default-branch version through a release PR (without strictVersionHistory).
117
119
  type: enum
118
120
  choices:
119
121
  - major
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakobm/peacekeeper",
3
- "version": "0.28.0",
3
+ "version": "0.30.1",
4
4
  "description": "Shared repository test, Git worktree, and Codex hook commands",
5
5
  "license": "MIT",
6
6
  "author": "Jakob Mattsson",
@@ -40,8 +40,8 @@
40
40
  "node": "^22.14.0"
41
41
  },
42
42
  "dependencies": {
43
- "@jakobm/cmdabra": "^0.7.0",
44
- "@jakobm/portico": "^0.8.1",
43
+ "@jakobm/cmdabra": "^0.9.0",
44
+ "@jakobm/portico": "^0.10.1",
45
45
  "glob": "^14.0.4",
46
46
  "semver": "^7.8.5",
47
47
  "yaml": "^2.9.1"
@@ -13,9 +13,7 @@ export default () => {
13
13
  'generate-github-setup': ['github', 'generate-setup'],
14
14
  'assess-release': ['release', 'assess'],
15
15
  'verify-release': ['release', 'verify'],
16
- 'verify-release-protection': ['release', 'verify-protection'],
17
16
  'verify-release-version': ['release', 'verify-version'],
18
- 'release': ['release', 'publish'],
19
17
  'install-hooks': ['codex', 'install-hooks'],
20
18
  'initialize-codex-worktree': ['codex', 'init-worktree'],
21
19
  'checkpoint-codex-changes': ['codex', 'checkpoint'],
@@ -28,9 +26,6 @@ export default () => {
28
26
  };
29
27
  function normalize(rawArgs) {
30
28
  const [command, ...rest] = rawArgs;
31
- // The new release group shares the old publish command's name.
32
- if (command === 'release' && !['major', 'minor', 'patch'].includes(rest[0]))
33
- return rawArgs;
34
29
  return Object.hasOwn(commands, command) ? [...commands[command], ...rest] : rawArgs;
35
30
  }
36
31
  return { commands, normalize };
@@ -20,20 +20,21 @@ export default ({ configuration, legacyCommands, lifecycle, maintenance, project
20
20
  checkConventions: options => testing.checkConventions({ update: options.update }),
21
21
  },
22
22
  test: {
23
+ prepare: () => testing.prepareTests(),
23
24
  run: options => testing.runTests({ force: options.force, checkpoint: options.checkpoint }),
24
25
  checkReceipt: options => testing.checkTestReceipt({ checkpoint: options.checkpoint }),
25
26
  recordReceipt: options => testing.recordTestReceipt({ checkpoint: options.checkpoint }),
26
27
  },
27
28
  github: {
29
+ check: () => releases.checkGithub(),
28
30
  configure: options => releases.configureGithub(options),
29
31
  generateSetup: options => projects.generateGithubSetup(options),
30
32
  },
31
33
  release: {
32
34
  assess: () => releases.assessRelease(),
33
35
  verify: () => releases.verifyRelease(),
34
- verifyProtection: () => releases.verifyReleaseProtection(),
35
36
  verifyVersion: () => releases.verifyReleaseVersion(),
36
- publish: bump => releases.release(bump),
37
+ publish: options => releases.release(options),
37
38
  },
38
39
  codex: {
39
40
  installHooks: options => projects.installHooks({ dryRun: options.dryRun }),
@@ -17,7 +17,9 @@
17
17
  "all": [],
18
18
  "checkpoint": [],
19
19
  "receiptMaxAgeMinutes": 60,
20
- "npmTestUsesRunner": false
20
+ "npmTestUsesRunner": false,
21
+ "aptPackages": [],
22
+ "playwrightBrowsers": []
21
23
  },
22
24
  "conventions": {
23
25
  "rules": []
@@ -30,5 +32,6 @@
30
32
  "test"
31
33
  ]
32
34
  },
33
- "publishesToNpm": false
35
+ "publishesToNpm": false,
36
+ "strictVersionHistory": false
34
37
  }
@@ -10,10 +10,11 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
10
10
  // Kept independent of the defaults so additions require an explicit default.
11
11
  const CONFIG_SCHEMA = {
12
12
  publishesToNpm: true,
13
+ strictVersionHistory: true,
13
14
  git: { remote: true, defaultBranch: true, branchPrefix: true, requiredApprover: true,
14
15
  checkpointPushRemotes: true, releaseMergeMethod: true,
15
16
  releaseRequiredChecks: true, releaseTestWorkflow: true },
16
- tests: { all: true, checkpoint: true, receiptMaxAgeMinutes: true, npmTestUsesRunner: true },
17
+ tests: { all: true, checkpoint: true, receiptMaxAgeMinutes: true, npmTestUsesRunner: true, aptPackages: true, playwrightBrowsers: true },
17
18
  conventions: { rules: true },
18
19
  loggingDirectory: true,
19
20
  loggingEnabled: true,
@@ -30,6 +31,10 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
30
31
  }
31
32
  for (const [key, child] of Object.entries(schema)) {
32
33
  const name = location === 'config' ? key : `${location}.${key}`;
34
+ if (location === 'config' && key === 'strictVersionHistory' && !Object.hasOwn(value, key))
35
+ continue;
36
+ if (location === 'tests' && ['aptPackages', 'playwrightBrowsers'].includes(key) && !Object.hasOwn(value, key))
37
+ continue;
33
38
  if (!Object.hasOwn(value, key))
34
39
  errors.push(`missing field ${name}`);
35
40
  else if (child !== true)
@@ -87,6 +92,9 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
87
92
  if (typeof config.publishesToNpm !== 'boolean') {
88
93
  throw new Error(`${file}: publishesToNpm must be a boolean`);
89
94
  }
95
+ if (Object.hasOwn(config, 'strictVersionHistory') && typeof config.strictVersionHistory !== 'boolean') {
96
+ throw new Error(`${file}: strictVersionHistory must be a boolean`);
97
+ }
90
98
  if (typeof config.loggingEnabled !== 'boolean') {
91
99
  throw new Error(`${file}: loggingEnabled must be a boolean`);
92
100
  }
@@ -97,6 +105,19 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
97
105
  throw new Error(`${file}: tests.${level} must be an array of command strings`);
98
106
  }
99
107
  }
108
+ for (const field of ['aptPackages', 'playwrightBrowsers']) {
109
+ const entries = config.tests[field] === undefined ? [] : config.tests[field];
110
+ if (!Array.isArray(entries) || entries.some(entry => typeof entry !== 'string' || !entry.trim())
111
+ || new Set(entries).size !== entries.length) {
112
+ throw new Error(`${file}: tests.${field} must be an array of unique nonempty strings`);
113
+ }
114
+ if (field === 'aptPackages' && entries.some(name => !/^[a-z0-9][a-z0-9+.-]*(?:=[A-Za-z0-9:.+~_-]+)?$/u.test(name))) {
115
+ throw new Error(`${file}: tests.aptPackages must contain package names with optional exact versions`);
116
+ }
117
+ if (field === 'playwrightBrowsers' && entries.some(browser => !['chromium', 'firefox', 'webkit'].includes(browser))) {
118
+ throw new Error(`${file}: tests.playwrightBrowsers must select chromium, firefox or webkit`);
119
+ }
120
+ }
100
121
  const missing = config.tests.checkpoint.filter(command => !config.tests.all.includes(command));
101
122
  if (missing.length) {
102
123
  throw new Error(`${file}: every command in tests.checkpoint must also appear in tests.all; missing: ${JSON.stringify(missing)}`);
@@ -120,7 +141,7 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
120
141
  ? YAML.parse(fs.readFileSync(file, 'utf8'))
121
142
  : JSON.parse(JSON.stringify(projectConfigDefaults));
122
143
  validateConfig(config, file);
123
- return { root, ...config };
144
+ return { root, strictVersionHistory: projectConfigDefaults.strictVersionHistory, ...config, tests: { ...projectConfigDefaults.tests, ...config.tests } };
124
145
  }
125
146
  function requireTestCommands(root) {
126
147
  if (!projectConfig(root).tests.all.length) {