@jakobm/peacekeeper 0.29.0 → 0.30.2

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 (76) hide show
  1. package/README.md +121 -48
  2. package/dist/cmdabra.yaml +5 -5
  3. package/dist/package.json +5 -5
  4. package/dist/src/container.js +4 -2
  5. package/dist/src/modules/implementations/+module-cli/cli-public.js +2 -0
  6. package/dist/src/modules/{cli → implementations/+module-cli}/legacy-commands.js +0 -5
  7. package/dist/src/modules/{cli → implementations/+module-cli}/service.js +2 -2
  8. package/dist/src/modules/{configuration/facade.js → implementations/+module-configuration/configuration-public.js} +2 -1
  9. package/dist/src/modules/{configuration → implementations/+module-configuration}/project-config-defaults.json +2 -1
  10. package/dist/src/modules/{configuration → implementations/+module-configuration}/project-config.js +7 -1
  11. package/dist/src/modules/{lifecycle/facade.js → implementations/+module-lifecycle/lifecycle-public.js} +2 -1
  12. package/dist/src/modules/{maintenance/facade.js → implementations/+module-maintenance/maintenance-public.js} +2 -1
  13. package/dist/src/modules/{projects → implementations/+module-projects}/check-project-requirements.txt +36 -13
  14. package/dist/src/modules/{projects → implementations/+module-projects}/check-project.js +3 -3
  15. package/dist/src/modules/{projects → implementations/+module-projects}/create-project-core.js +1 -1
  16. package/dist/src/modules/{projects/facade.js → implementations/+module-projects/projects-public.js} +2 -1
  17. package/dist/src/modules/{releases → implementations/+module-releases}/assess-release-core.js +6 -5
  18. package/dist/src/modules/implementations/+module-releases/check-github.js +27 -0
  19. package/dist/src/modules/{releases → implementations/+module-releases}/github-policy.js +1 -1
  20. package/dist/src/modules/{releases → implementations/+module-releases}/release-core.js +63 -14
  21. package/dist/src/modules/{releases → implementations/+module-releases}/release.js +2 -1
  22. package/dist/src/modules/{releases/facade.js → implementations/+module-releases/releases-public.js} +3 -2
  23. package/dist/src/modules/{releases → implementations/+module-releases}/reusable-workflows.js +1 -1
  24. package/dist/src/modules/{releases → implementations/+module-releases}/reusable-workflows.json +1 -1
  25. package/dist/src/modules/{releases → implementations/+module-releases}/verify-release-core.js +4 -4
  26. package/dist/src/modules/implementations/+module-releases/version-history.js +27 -0
  27. package/dist/src/modules/{testing/facade.js → implementations/+module-testing/testing-public.js} +2 -1
  28. package/dist/src/modules/{external.js → implementations/external.js} +6 -6
  29. package/package.json +5 -5
  30. package/dist/src/modules/cli/facade.js +0 -1
  31. package/dist/src/modules/releases/verify-release-protection.js +0 -25
  32. /package/dist/src/modules/{cli → implementations/+module-cli}/types.js +0 -0
  33. /package/dist/src/modules/{configuration → implementations/+module-configuration}/convention-rules.js +0 -0
  34. /package/dist/src/modules/{configuration → implementations/+module-configuration}/update-config.js +0 -0
  35. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/checkpoint-codex-changes.js +0 -0
  36. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/checkpoint-codex-session-start.js +0 -0
  37. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/checkpoint-codex-stop.js +0 -0
  38. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/checkpoint-instructions.js +0 -0
  39. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/cleanup-ended-session.js +0 -0
  40. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/log-script-invocation.js +0 -0
  41. /package/dist/src/modules/{lifecycle → implementations/+module-lifecycle}/queue-merged-worktree-cleanup.js +0 -0
  42. /package/dist/src/modules/{maintenance → implementations/+module-maintenance}/cleanup-merged-branches.js +0 -0
  43. /package/dist/src/modules/{maintenance → implementations/+module-maintenance}/initialize-codex-worktree.js +0 -0
  44. /package/dist/src/modules/{maintenance → implementations/+module-maintenance}/remove-empty-directories.js +0 -0
  45. /package/dist/src/modules/{projects → implementations/+module-projects}/create-project.js +0 -0
  46. /package/dist/src/modules/{projects → implementations/+module-projects}/generate-github-setup.js +0 -0
  47. /package/dist/src/modules/{projects → implementations/+module-projects}/github-setup-prefix.sh +0 -0
  48. /package/dist/src/modules/{projects → implementations/+module-projects}/github-setup-repository-template.sh +0 -0
  49. /package/dist/src/modules/{projects → implementations/+module-projects}/github-setup-suffix-template.sh +0 -0
  50. /package/dist/src/modules/{projects → implementations/+module-projects}/install-hooks.js +0 -0
  51. /package/dist/src/modules/{releases → implementations/+module-releases}/assess-release-schema.json +0 -0
  52. /package/dist/src/modules/{releases → implementations/+module-releases}/assess-release.js +0 -0
  53. /package/dist/src/modules/{releases → implementations/+module-releases}/configure-github.js +0 -0
  54. /package/dist/src/modules/{releases → implementations/+module-releases}/github-base-protection-policy.json +0 -0
  55. /package/dist/src/modules/{releases → implementations/+module-releases}/github-configuration.js +0 -0
  56. /package/dist/src/modules/{releases → implementations/+module-releases}/github-owner-approval-policy.json +0 -0
  57. /package/dist/src/modules/{releases → implementations/+module-releases}/github-remote.js +0 -0
  58. /package/dist/src/modules/{releases → implementations/+module-releases}/release-protection.js +0 -0
  59. /package/dist/src/modules/{releases → implementations/+module-releases}/verify-release-version.js +0 -0
  60. /package/dist/src/modules/{releases → implementations/+module-releases}/verify-release.js +0 -0
  61. /package/dist/src/modules/{testing → implementations/+module-testing}/check-conventions.js +0 -0
  62. /package/dist/src/modules/{testing → implementations/+module-testing}/check-test-receipt.js +0 -0
  63. /package/dist/src/modules/{testing → implementations/+module-testing}/conventions.js +0 -0
  64. /package/dist/src/modules/{testing → implementations/+module-testing}/prepare-tests.js +0 -0
  65. /package/dist/src/modules/{testing → implementations/+module-testing}/receipt-state.js +0 -0
  66. /package/dist/src/modules/{testing → implementations/+module-testing}/record-test-receipt.js +0 -0
  67. /package/dist/src/modules/{testing → implementations/+module-testing}/run-tests.js +0 -0
  68. /package/dist/src/modules/{testing → implementations/+module-testing}/types.js +0 -0
  69. /package/dist/src/modules/{cli/interface.js → interfaces/cli.js} +0 -0
  70. /package/dist/src/modules/{configuration/interface.js → interfaces/configuration.js} +0 -0
  71. /package/dist/src/modules/{dependencies.yaml → interfaces/dependencies.yaml} +0 -0
  72. /package/dist/src/modules/{lifecycle/interface.js → interfaces/lifecycle.js} +0 -0
  73. /package/dist/src/modules/{maintenance/interface.js → interfaces/maintenance.js} +0 -0
  74. /package/dist/src/modules/{projects/interface.js → interfaces/projects.js} +0 -0
  75. /package/dist/src/modules/{releases/interface.js → interfaces/releases.js} +0 -0
  76. /package/dist/src/modules/{testing/interface.js → interfaces/testing.js} +0 -0
package/README.md CHANGED
@@ -16,8 +16,8 @@ completion follows the same hierarchy.
16
16
  | --- | --- |
17
17
  | `project` | `create`, `check`, `update-config`, `check-conventions` |
18
18
  | `test` | `run`, `check-receipt`, `record-receipt`, `prepare` |
19
- | `github` | `configure`, `generate-setup` |
20
- | `release` | `assess`, `verify`, `verify-protection`, `verify-version`, `publish` |
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.
@@ -47,10 +48,17 @@ names to explicit operations on each domain's frozen facade. Modules
47
48
  receive private factories, permitted module facades, and external services through
48
49
  Portico injection; direct runtime imports inside the module tree are rejected by
49
50
  the configured `portico check`. Each module declares its type-only contract in
50
- `interface.ts` and exports its named `porticoFacade` factory from `facade.ts`.
51
+ `src/modules/interfaces/<module>.ts` and exports its named `createPorticoModule` factory
52
+ from `src/modules/implementations/+module-<module>/<module>-public.ts`.
53
+ Portico 0.12 loads the native ESM module tree asynchronously through
54
+ `createRepositoryContainer({ modulesRoot })`; factories and facade resolution remain
55
+ synchronous after initialization. Explicit `+module-` directories identify module
56
+ boundaries, while ordinary directories can group private factories within an owner.
57
+ Shared public domain types are referenced with type-only imports from their owning
58
+ contracts; private implementation types remain local to their module.
51
59
  Permitted dependencies are declared in
52
- `src/modules/dependencies.yaml`. Cmdabra generates the CLI implementation contract
53
- as `src/modules/cli/types.ts` from the root `cmdabra.yaml`; `npm run typecheck`
60
+ `src/modules/interfaces/dependencies.yaml`. Cmdabra generates the CLI implementation contract
61
+ as `src/modules/implementations/+module-cli/types.ts` from the root `cmdabra.yaml`; `npm run typecheck`
54
62
  verifies that it is current before checking the TypeScript project.
55
63
 
56
64
  Generate the dependency views and SVG diagram with `npm run architecture`. The
@@ -66,6 +74,10 @@ The CLI also exposes Cmdabra's global `--cmdabra-complete` option for
66
74
  It accepts the current word index followed by all command-line words and prints
67
75
  completion candidates without running a command.
68
76
 
77
+ Use `peacekeeper --cmdabra-completion bash` to print a completion script or
78
+ `peacekeeper --cmdabra-install-completion bash` to install it. Both options
79
+ support `bash`, `zsh`, and `fish`.
80
+
69
81
  ## Testing Peacekeeper
70
82
 
71
83
  Run `npm test` with the pinned Volta toolchain to build and run type checks,
@@ -94,7 +106,8 @@ through OIDC. Put project-specific checks, including packaging checks, in
94
106
  `tests.all`. Neither workflow accepts inputs.
95
107
 
96
108
  Install a Peacekeeper version containing this support before switching. Older
97
- versions reject required reusable jobs. A minimal `.github/workflows/test.yml` is:
109
+ versions may reject required reusable jobs or lack the `github check` command
110
+ used by the revised workflow. A minimal `.github/workflows/test.yml` is:
98
111
 
99
112
  ```yaml
100
113
  on:
@@ -104,7 +117,7 @@ permissions:
104
117
  contents: read
105
118
  jobs:
106
119
  test:
107
- uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@17a6c202c0f3cd66f1bb4a42d1dc8c78e7eb60d6
120
+ uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@071a6102729107f4f4f01851e0b661355985a676
108
121
  secrets:
109
122
  RELEASE_POLICY_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
110
123
  ```
@@ -156,7 +169,7 @@ these thin callers, including publication for npm projects.
156
169
 
157
170
  Peacekeeper trusts reviewed central implementations through the full workflow
158
171
  commit SHAs bundled in
159
- [`reusable-workflows.json`](src/modules/releases/reusable-workflows.json).
172
+ [`reusable-workflows.json`](src/modules/implementations/+module-releases/reusable-workflows.json).
160
173
  Caller contracts are checked offline, without downloading remote YAML. Unknown
161
174
  SHAs, branch names, tags, inherited secrets, inputs, matrices and runner/step
162
175
  or failure-handling overrides are rejected. Inline workflows remain supported.
@@ -167,6 +180,51 @@ single static `test` or `publish` job, explicit policy secret, no-input contract
167
180
  and verified setup and step order. Contract tests check both implementations
168
181
  through the public project checker. Consumers deliberately update approved pins.
169
182
 
183
+ ## Strict version history
184
+
185
+ Set the optional top-level `strictVersionHistory` boolean in
186
+ `peacekeeper.config.yaml` to require an increasing package version for each
187
+ future merge to the default branch:
188
+
189
+ ```yaml
190
+ strictVersionHistory: true
191
+ ```
192
+
193
+ Peacekeeper itself enables this setting; every PR must increase the package version.
194
+
195
+ The default is `false`, including for existing files that omit the field.
196
+ `project update-config` inserts an explicit `false` without changing an existing
197
+ value. With `false`, GitHub protection remains mandatory and versions may stay
198
+ unchanged between merges.
199
+
200
+ `peacekeeper github check` verifies the repository's GitHub protection and, when
201
+ strict history is enabled, compares the incoming checkout's `package.json`
202
+ version with the version on GitHub's actual default branch. It reads the branch
203
+ commit through its Git reference, without downloading the commit diff, and then
204
+ fetches its package metadata by that immutable SHA. Local
205
+ remote-tracking refs, full Git history and an explicit base argument are not
206
+ needed. Missing or invalid versions and unavailable API data fail verification.
207
+ The version must be strictly greater according to semver precedence; changing
208
+ build metadata alone does not count as an increase.
209
+
210
+ Required strict status checks force a parallel PR to update and pass CI again
211
+ after another PR merges. A version already taken by that merge must be raised
212
+ again. The rule applies to the default branch's first-parent merge history;
213
+ feature-branch commits may share versions. It does not audit older history or
214
+ require every version to be published, and it does not select the appropriate
215
+ major/minor/patch increment for you.
216
+
217
+ The GitHub check is separate from offline `project check`, local tests and
218
+ checkpoints, so development can proceed before choosing a version. Use
219
+ `github check` in PR workflows. Older verification command names and workflow
220
+ revisions that invoke them are unsupported by this version of Peacekeeper.
221
+
222
+ Publication's `release verify` continues to verify GitHub protection, tag/package/
223
+ lockfile agreement and the merged PR's CI independently. It does not apply the
224
+ incoming-version comparison to an already merged release. With strict history,
225
+ `npm run release` publishes the existing default-branch version without creating
226
+ a version-bump PR.
227
+
170
228
  ## Standard CI test environment
171
229
 
172
230
  The central PR workflow runs one Ubuntu 24.04 job. It cancels superseded runs for
@@ -345,7 +403,7 @@ is a separate step; a secret-sync failure does not roll back GitHub settings.
345
403
  Use a manually authenticated GitHub identity with repository Administration write
346
404
  access for execute, and sufficient Contents/Administration read access for complete
347
405
  policy inspection. Do not put admin-write credentials in Actions secrets.
348
- The shared policy model also serves `release verify-protection`; that existing
406
+ The shared policy model also serves `github check`; that existing
349
407
  command retains its documented semantic alternatives, including equivalent classic
350
408
  protection, while github configure verifies the exact owned configuration.
351
409
 
@@ -421,7 +479,7 @@ Run `npm install` from the project root and commit the resulting `package-lock.j
421
479
 
422
480
  Place this file at the caller's Git root. Every field, including nested fields,
423
481
  is required. Unknown fields and invalid values are rejected. If no file exists,
424
- Peacekeeper uses the complete bundled [defaults](src/modules/configuration/project-config-defaults.json).
482
+ Peacekeeper uses the complete bundled [defaults](src/modules/implementations/+module-configuration/project-config-defaults.json).
425
483
  The defaults contain no test commands; configure those before running tests or
426
484
  recording or reusing a test receipt.
427
485
 
@@ -442,13 +500,14 @@ All CLI commands validate configuration before executing, except help,
442
500
  `project check --explain`, and `project update-config`. Checkpoint hooks instead validate
443
501
  the event worktree configuration when the event requires instructions or a check.
444
502
  An incomplete existing file fails
445
- with missing field paths and a repair hint. Updates introducing new fields
503
+ with missing field paths and a repair hint. Updates introducing new required fields
446
504
  therefore require `peacekeeper project update-config` before ordinary commands can run.
447
505
 
448
506
  Complete example:
449
507
 
450
508
  ```yaml
451
509
  publishesToNpm: false
510
+ strictVersionHistory: false
452
511
  git:
453
512
  remote: origin
454
513
  defaultBranch: main
@@ -772,7 +831,7 @@ absolute paths, parent traversal, and negated patterns are configuration errors.
772
831
  conventions:
773
832
  rules:
774
833
  - check: sorted-yaml-lists
775
- file: "src/modules/dependencies.yaml"
834
+ file: "src/modules/interfaces/dependencies.yaml"
776
835
  ```
777
836
 
778
837
  Recursively checks every list containing only strings, including lists nested
@@ -880,7 +939,7 @@ proven free of publication code by this local check. Remove dedicated npm
880
939
  publishing credentials and trusted-publisher registrations separately.
881
940
  Internal `npm pack`, build scripts, module entry points and CLI metadata remain
882
941
  allowed, as do deployment workflows and read authentication for dependencies.
883
- PR checks, lockfiles, toolchain requirements and `release verify-protection`
942
+ PR checks, lockfiles, toolchain requirements and `github check`
884
943
  remain independent of publication intent, including `git.releaseRequiredChecks`.
885
944
 
886
945
  All projects must declare nonblank `author` and `repository` values in
@@ -888,7 +947,7 @@ All projects must declare nonblank `author` and `repository` values in
888
947
  and `repository.url` strings.
889
948
  Run `peacekeeper project check --explain` for the complete expected
890
949
  architecture, requirements, configuration examples, and verification limits.
891
- The command prints the bundled [formal requirements](src/modules/projects/check-project-requirements.txt),
950
+ The command prints the bundled [formal requirements](src/modules/implementations/+module-projects/check-project-requirements.txt),
892
951
  which can also be read without a repository or project configuration.
893
952
 
894
953
  The repository root must not contain `.codex`, even as an empty directory, file,
@@ -946,8 +1005,10 @@ model selection remains at Codex's default.
946
1005
  default-branch commit being assessed. Peacekeeper supplies these full commit IDs,
947
1006
  independently of the AI response. They remain available when Codex cannot complete
948
1007
  its analysis. Each is `null` if it could not be resolved and verified. The target
949
- identifies the source code a release would start from at assessment time; a later
950
- release adds its version commit and tags the actual release PR merge commit.
1008
+ identifies the source code at assessment time. The target package version may
1009
+ already be higher than the published version; assessment still considers all changes
1010
+ since the published release. A release without a bump tags the selected default-branch
1011
+ commit; a release with a bump tags the resulting release PR merge commit.
951
1012
 
952
1013
  The command requires Git, npm, an authenticated GitHub CLI (`gh`) with repository
953
1014
  read access, and an installed, authenticated Codex CLI supporting `codex exec`,
@@ -956,8 +1017,9 @@ which must match `git.defaultBranch`, and pins its exact commit. It uses the
956
1017
  highest stable version published on the public npm registry as the baseline;
957
1018
  prereleases and tags without npm publication do not advance that baseline.
958
1019
  The published version must have a matching remote `v<version>` tag in the target's
959
- ancestry. Package names and versions at the tag and target must agree with npm;
960
- when npm supplies `gitHead`, it must match the tag's commit. Missing tags,
1020
+ ancestry. The package name at both revisions and the version at the published
1021
+ tag must agree with npm; the target version may already be higher. When npm
1022
+ supplies `gitHead`, it must match the tag's commit. Missing tags,
961
1023
  inconsistent metadata, no previous stable publication, unsupported private or
962
1024
  workspace packages, and unavailable history or services produce `undetermined`.
963
1025
  It does not guess an older baseline when the latest stable release cannot be verified.
@@ -1040,7 +1102,7 @@ the release command enables auto-merge on its release PRs.
1040
1102
  `project check` makes no network requests. It runs implicitly before
1041
1103
  `tests.all` or `tests.checkpoint`, including when reusing receipts, and checks that the configured
1042
1104
  PR workflow uses only `pull_request`, with `branches` set to exactly
1043
- `[git.defaultBranch]`, and runs `release verify-protection` with `GH_TOKEN` after `npm ci` and
1105
+ `[git.defaultBranch]`, and runs `github check` with `GH_TOKEN` after `npm ci` and
1044
1106
  before tests in a job listed in `git.releaseRequiredChecks`, either through local
1045
1107
  steps or the approved central PR workflow above. The job and step must
1046
1108
  not skip verification or ignore failures. The online verifier then checks that
@@ -1052,7 +1114,7 @@ For example, in a required `test` job:
1052
1114
 
1053
1115
  ```yaml
1054
1116
  - run: npm ci
1055
- - run: peacekeeper release verify-protection
1117
+ - run: peacekeeper github check
1056
1118
  env:
1057
1119
  GH_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
1058
1120
  - run: npm test
@@ -1063,14 +1125,16 @@ This creates a local-to-CI chain: missing workflows are detected on the next loc
1063
1125
  continuous monitoring. Removing both CI and the local invocation prevents this
1064
1126
  chain from running. No central scheduled audit is required by this setup.
1065
1127
 
1066
- The PR test job runs `peacekeeper release verify-protection` before its tests.
1128
+ The PR test job runs `peacekeeper github check` before its tests.
1067
1129
  The command reads the actual default branch from GitHub, regardless of the PR
1068
1130
  base. Other release commands require their configured branch to match it.
1069
1131
  `peacekeeper release publish` checks the default branch before preparing a release
1070
1132
  and again immediately before each merge attempt. Before publishing,
1071
1133
  `peacekeeper release verify` checks the policy, matching package/tag/lockfile
1072
- versions, a same-repository merged `release/v<version>` PR, and successful required
1073
- jobs in its latest PR workflow run. Manual tags without that PR are rejected.
1134
+ versions, a same-repository merged PR, and successful required
1135
+ jobs in its latest PR workflow run. The PR may be a feature PR or a release PR;
1136
+ its branch name and commit message do not determine publication eligibility.
1137
+ Tags without a qualifying merged PR are rejected.
1074
1138
  `release verify-version` remains available for local version checks alone.
1075
1139
 
1076
1140
  API failures, missing permissions, and unverifiable rules stop the commands.
@@ -1135,35 +1199,44 @@ state without a merge method. Saved unfinished releases that explicitly select
1135
1199
  squash or rebase must be restarted. `git.releaseMergeMethod` remains accepted for
1136
1200
  configuration compatibility, but no longer selects the default-branch merge method.
1137
1201
 
1138
- From a clean repository root, run `npm run release -- patch`, `minor`, or `major`.
1202
+ From a clean repository root, run `npm run release` to publish the existing version
1203
+ at the latest remote default-branch commit. With `strictVersionHistory: true`,
1204
+ versions must already have been assigned in the PRs that introduced the changes;
1205
+ release does not create a bump commit or another PR, and `--bump` is rejected.
1206
+ Not every default-branch version needs to be published.
1207
+
1208
+ With `strictVersionHistory: false` (the default), the same command publishes an
1209
+ already assigned, unpublished version. If that version is already on npm, choose
1210
+ an increment explicitly: `npm run release -- --bump patch`, `--bump minor`, or
1211
+ `--bump major`. Peacekeeper increments the version from the fetched default branch,
1212
+ updates the package and lockfiles in a temporary detached worktree, and opens a
1213
+ `release/v<version>` PR. It enables auto-merge for the expected PR head, then waits
1214
+ up to 20 minutes for GitHub to merge it, respecting checks, reviews, resolved
1215
+ conversations and branch freshness. The resulting merge commit is the release target.
1216
+
1139
1217
  The required `prerelease` script runs `npm ci` first, replacing `node_modules`
1140
1218
  with the exact dependency versions in the committed lockfile before npm resolves
1141
1219
  and starts Peacekeeper. Always use the npm script; invoking `peacekeeper release publish`
1142
- directly bypasses this dependency bootstrap.
1143
- The command fetches the default branch and uses a temporary detached worktree to
1144
- increment the package and lockfile versions. Your current branch and local default
1220
+ directly bypasses this dependency bootstrap. Your current branch and local default
1145
1221
  branch stay unchanged, including when the default branch is checked out elsewhere.
1146
- Before changing versions it logs `Preparing release from origin/<branch> at <SHA>.`
1147
- using the full source commit ID checked out in the temporary worktree.
1148
- It pushes a `release/v<version>` branch and opens a release PR. The command enables
1149
- auto-merge for the expected PR head using a merge commit, then waits up to 20
1150
- minutes for GitHub to complete the merge,
1151
- respecting required checks, reviews, resolved conversations, and branch freshness.
1152
- It never uses an administrator bypass or pushes directly to the default branch.
1153
-
1154
- After merge, the command verifies the package files at the PR's actual merge
1155
- commit, tags that commit with `v<version>`, and pushes the tag. The existing
1156
- workflow publishes through npm trusted publishing. The command then waits for
1157
- the publish job and for the version to appear on npm. Monitoring reads the run
1158
- status before its jobs so a job finishing between requests does not produce a
1159
- false publication failure. Git and an authenticated
1160
- GitHub CLI (`gh`) with Contents read/write, Pull requests read/write, Actions
1161
- read and the policy-reading access described above are required. Registry checks
1162
- use a temporary npm cache and request current metadata.
1222
+ The command pins the fetched source commit and logs its full SHA. It never uses
1223
+ an administrator bypass or pushes directly to the default branch.
1224
+
1225
+ Both paths verify the target package and lockfiles, GitHub protection, the merged
1226
+ PR and its successful required CI before creating and pushing `v<version>`.
1227
+ The version must be unpublished on npm; registry access failures stop the command.
1228
+ The tag-triggered workflow independently verifies the release and publishes through
1229
+ npm trusted publishing. The command waits for the publish job and npm visibility.
1230
+ Monitoring reads the run status before its jobs so a job finishing between requests
1231
+ does not produce a false publication failure. Git and an authenticated GitHub CLI
1232
+ (`gh`) with Contents read/write, Pull requests read/write, Actions read and the
1233
+ policy-reading access described above are required. Registry checks use a temporary
1234
+ npm cache and request current metadata.
1163
1235
 
1164
1236
  Retry the same command and release type after an interruption: release state is
1165
1237
  stored in `peacekeeper-release.json` in the shared Git directory, so retries
1166
- from another worktree of the same checkout continue the same PR and version.
1238
+ from another worktree of the same checkout continue the same target revision and
1239
+ version, even if the default branch has advanced.
1167
1240
  Already-merged PRs and already-pushed matching tags are reused. A local lock
1168
1241
  prevents concurrent commands in that checkout; an open release PR from a different
1169
1242
  checkout blocks a new release. Do not delete the state or manually create a new
@@ -1182,7 +1255,7 @@ Other npm projects can use this command through package scripts such as
1182
1255
  former automatically before the latter. The project must use a root package
1183
1256
  with a stable version, a `peacekeeper.config.yaml` with
1184
1257
  `git.releaseRequiredChecks`, and the supported tag-triggered GitHub Actions
1185
- publish job. Add `peacekeeper release verify-protection` to a required PR
1258
+ publish job. Add `peacekeeper github check` to a required PR
1186
1259
  test job and `peacekeeper release verify` before publishing, with `GH_TOKEN`
1187
1260
  and `RELEASE_TAG` set for release verification. Both commands are shipped with
1188
1261
  the package; no verifier script or artifact upload needs to be copied.
package/dist/cmdabra.yaml CHANGED
@@ -70,8 +70,10 @@ commands:
70
70
  prepare:
71
71
  description: Install tests.aptPackages and tests.playwrightBrowsers when configured.
72
72
  github:
73
- description: Configure GitHub repository policy.
73
+ description: Check and configure GitHub repository policy.
74
74
  commands:
75
+ check:
76
+ description: Verify GitHub protection and configured version history requirements.
75
77
  configure:
76
78
  description: Plan or apply exact GitHub policy from a SHA-pinned remote source.
77
79
  named-options:
@@ -107,15 +109,13 @@ commands:
107
109
  description: Assess unpublished changes with Codex and return a JSON recommendation.
108
110
  verify:
109
111
  description: Verify release versions, required CI and strict branch protection.
110
- verify-protection:
111
- description: Require strict mandatory release checks without bypass.
112
112
  verify-version:
113
113
  description: Check a release tag against package and lockfile versions.
114
114
  publish:
115
115
  description: Publish a version through a GitHub Actions npm workflow.
116
- positional-arguments:
116
+ named-options:
117
117
  bump:
118
- description: Version increment to publish.
118
+ description: Increment the default-branch version through a release PR (without strictVersionHistory).
119
119
  type: enum
120
120
  choices:
121
121
  - major
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakobm/peacekeeper",
3
- "version": "0.29.0",
3
+ "version": "0.30.2",
4
4
  "description": "Shared repository test, Git worktree, and Codex hook commands",
5
5
  "license": "MIT",
6
6
  "author": "Jakob Mattsson",
@@ -23,8 +23,8 @@
23
23
  "dist/package.json"
24
24
  ],
25
25
  "scripts": {
26
- "generate:cli-types": "cmdabra generate-types cmdabra.yaml --output src/modules/cli/types.ts",
27
- "check:cli-types": "cmdabra generate-types cmdabra.yaml --output src/modules/cli/types.ts --check",
26
+ "generate:cli-types": "cmdabra generate-types cmdabra.yaml --output src/modules/implementations/+module-cli/types.ts",
27
+ "check:cli-types": "cmdabra generate-types cmdabra.yaml --output src/modules/implementations/+module-cli/types.ts --check",
28
28
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
29
29
  "build": "npm run clean && npm run check:cli-types && tsc && tsc -p tsconfig.test.json && node dist/scripts/copy-assets.js",
30
30
  "typecheck": "npm run check:cli-types && tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
@@ -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.12.0",
45
45
  "glob": "^14.0.4",
46
46
  "semver": "^7.8.5",
47
47
  "yaml": "^2.9.1"
@@ -1,7 +1,9 @@
1
1
  import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
+ import { createRepositoryContainer } from '@jakobm/portico';
3
4
  const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
4
5
  export async function createContainer() {
5
- const { default: portico } = await import('@jakobm/portico');
6
- return await portico.createRepositoryContainerAsync(path.resolve(currentDirectory, 'modules'));
6
+ return await createRepositoryContainer({
7
+ modulesRoot: path.resolve(currentDirectory, 'modules'),
8
+ });
7
9
  }
@@ -0,0 +1,2 @@
1
+ // --- Implementation ---
2
+ export const createPorticoModule = ({ service }) => ({ run: service.run });
@@ -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 };
@@ -26,15 +26,15 @@ export default ({ configuration, legacyCommands, lifecycle, maintenance, project
26
26
  recordReceipt: options => testing.recordTestReceipt({ checkpoint: options.checkpoint }),
27
27
  },
28
28
  github: {
29
+ check: () => releases.checkGithub(),
29
30
  configure: options => releases.configureGithub(options),
30
31
  generateSetup: options => projects.generateGithubSetup(options),
31
32
  },
32
33
  release: {
33
34
  assess: () => releases.assessRelease(),
34
35
  verify: () => releases.verifyRelease(),
35
- verifyProtection: () => releases.verifyReleaseProtection(),
36
36
  verifyVersion: () => releases.verifyReleaseVersion(),
37
- publish: bump => releases.release(bump),
37
+ publish: options => releases.release(options),
38
38
  },
39
39
  codex: {
40
40
  installHooks: options => projects.installHooks({ dryRun: options.dryRun }),
@@ -1,4 +1,5 @@
1
- export const porticoFacade = ({ projectConfig, updateConfig }) => ({
1
+ // --- Implementation ---
2
+ export const createPorticoModule = ({ projectConfig, updateConfig }) => ({
2
3
  codeownersError: projectConfig.codeownersError,
3
4
  projectConfig: projectConfig.projectConfig,
4
5
  repositoryRoot: projectConfig.repositoryRoot,
@@ -32,5 +32,6 @@
32
32
  "test"
33
33
  ]
34
34
  },
35
- "publishesToNpm": false
35
+ "publishesToNpm": false,
36
+ "strictVersionHistory": false
36
37
  }
@@ -10,6 +10,7 @@ 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 },
@@ -30,6 +31,8 @@ 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;
33
36
  if (location === 'tests' && ['aptPackages', 'playwrightBrowsers'].includes(key) && !Object.hasOwn(value, key))
34
37
  continue;
35
38
  if (!Object.hasOwn(value, key))
@@ -89,6 +92,9 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
89
92
  if (typeof config.publishesToNpm !== 'boolean') {
90
93
  throw new Error(`${file}: publishesToNpm must be a boolean`);
91
94
  }
95
+ if (Object.hasOwn(config, 'strictVersionHistory') && typeof config.strictVersionHistory !== 'boolean') {
96
+ throw new Error(`${file}: strictVersionHistory must be a boolean`);
97
+ }
92
98
  if (typeof config.loggingEnabled !== 'boolean') {
93
99
  throw new Error(`${file}: loggingEnabled must be a boolean`);
94
100
  }
@@ -135,7 +141,7 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
135
141
  ? YAML.parse(fs.readFileSync(file, 'utf8'))
136
142
  : JSON.parse(JSON.stringify(projectConfigDefaults));
137
143
  validateConfig(config, file);
138
- return { root, ...config, tests: { ...projectConfigDefaults.tests, ...config.tests } };
144
+ return { root, strictVersionHistory: projectConfigDefaults.strictVersionHistory, ...config, tests: { ...projectConfigDefaults.tests, ...config.tests } };
139
145
  }
140
146
  function requireTestCommands(root) {
141
147
  if (!projectConfig(root).tests.all.length) {
@@ -1,4 +1,5 @@
1
- export const porticoFacade = ({ checkpointCodexChanges, checkpointCodexSessionStart, checkpointCodexStop, cleanupEndedSession, queueMergedWorktreeCleanup }) => ({
1
+ // --- Implementation ---
2
+ export const createPorticoModule = ({ checkpointCodexChanges, checkpointCodexSessionStart, checkpointCodexStop, cleanupEndedSession, queueMergedWorktreeCleanup }) => ({
2
3
  checkpointCodexChanges: checkpointCodexChanges.run,
3
4
  checkpointCodexSessionStart: checkpointCodexSessionStart.run,
4
5
  checkpointCodexStop: checkpointCodexStop.run,
@@ -1,4 +1,5 @@
1
- export const porticoFacade = ({ cleanupMergedBranches, initializeCodexWorktree, removeEmptyDirectories }) => ({
1
+ // --- Implementation ---
2
+ export const createPorticoModule = ({ cleanupMergedBranches, initializeCodexWorktree, removeEmptyDirectories }) => ({
2
3
  applyPlan: cleanupMergedBranches.applyPlan,
3
4
  buildPlan: cleanupMergedBranches.buildPlan,
4
5
  cleanupMergedBranches: cleanupMergedBranches.run,
@@ -12,11 +12,27 @@ Purpose and scope
12
12
  of problems behind those prerequisites. Fix them and run the command again.
13
13
  --explain prints this entire document without loading or checking a project.
14
14
 
15
+ Strict version history
16
+ strictVersionHistory is an optional top-level boolean, defaulting to false
17
+ even in existing files. project update-config inserts an explicit false.
18
+ github check always verifies GitHub protection. When strictVersionHistory is
19
+ true, it also requires the incoming package.json version to be strictly
20
+ greater by semver precedence than the actual default branch version on GitHub.
21
+ The default branch package is fetched by immutable commit SHA. API failures,
22
+ missing or invalid versions, equal versions, and lower versions fail the check.
23
+ Strict required checks force parallel PRs to update and rerun after a merge.
24
+ Offline project check, local tests, checkpoints and publication verification
25
+ do not perform this incoming-version comparison. PR workflows must use
26
+ github check; older verification command names are unsupported.
27
+ This applies to future first-parent merges; it does not audit old history
28
+ or require every version to be published. With strict history, release publish
29
+ publishes the existing default-branch version without a version-bump PR.
30
+
15
31
  Project configuration
16
32
  package.json is required at the Git root. Without peacekeeper.config.yaml,
17
33
  bundled defaults apply. An existing configuration must declare every schema
18
- field, including nested fields, except the optional tests.aptPackages and
19
- tests.playwrightBrowsers lists; unknown fields and invalid values fail.
34
+ field, including nested fields, except the optional strictVersionHistory boolean
35
+ and tests.aptPackages and tests.playwrightBrowsers lists; unknown fields and invalid values fail.
20
36
  Run peacekeeper project update-config to create or complete it without overwriting
21
37
  existing values. Migrate tests.commands to tests.all and add tests.checkpoint
22
38
  as an empty list. Review inserted defaults. Empty tests.all blocks tests
@@ -145,12 +161,12 @@ Approved reusable PR workflow
145
161
  call the central workflow with a full SHA approved by this Peacekeeper version:
146
162
  jobs:
147
163
  test:
148
- uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@17a6c202c0f3cd66f1bb4a42d1dc8c78e7eb60d6
164
+ uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@071a6102729107f4f4f01851e0b661355985a676
149
165
  secrets:
150
166
  RELEASE_POLICY_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
151
167
  Declare permissions.contents as read (or write) at the caller job or workflow.
152
168
  Keep the caller's PR trigger and branch restriction described above. The central
153
- workflow owns checkout, Volta, npm ci, release verify-protection and npm test.
169
+ workflow owns checkout, Volta, npm ci, github check and npm test.
154
170
  The consumer must install a Peacekeeper version supporting this contract as a project dependency.
155
171
 
156
172
  Set both projectChecks.requiredJobs and git.releaseRequiredChecks to include
@@ -279,11 +295,11 @@ Publication: publishesToNpm=true
279
295
  Internal packing, prepack/build scripts, main/exports/types/bin, deployment
280
296
  workflows, OIDC for other services, and dependency read authentication remain
281
297
  allowed. Workflow filenames and job names alone do not imply npm publication.
282
- Toolchain, hooks, PR checks and release verify-protection still apply.
298
+ Toolchain, hooks, PR checks and github check still apply.
283
299
 
284
300
  Online release policy and GitHub token setup
285
301
  These are online installation requirements; project check only verifies the
286
- local declarations above. Use release verify-protection to check the branch
302
+ local declarations above. Use github check to check the branch
287
303
  policy and release verify before publishing to check the release itself.
288
304
 
289
305
  Enable "Automatically delete head branches" (delete_branch_on_merge=true) in
@@ -329,15 +345,22 @@ Online release policy and GitHub token setup
329
345
  Fork PRs do not receive repository secrets; do not expose this token by
330
346
  running fork code with pull_request_target.
331
347
 
332
- release verify-protection uses GITHUB_BASE_REF, or git.defaultBranch outside
333
- PR CI. It can be run before tests in a required trusted PR job. release verify
348
+ github check reads the actual default branch from GitHub. It can be run before
349
+ tests in a required trusted PR job. release verify
334
350
  checks matching package/tag/lockfile versions, that the tagged commit belongs
335
351
  to the default branch and is the merge commit of a same-repository merged
336
- release/v<version> PR, and the latest selected PR workflow run and required
352
+ PR (regardless of branch name), and the latest selected PR workflow run and required
337
353
  jobs. The workflow and all matching required jobs must conclude success.
338
- A manually created tag without that release PR is rejected. API access errors
339
- and unverifiable protection settings stop verification. Use the release
340
- command to prepare the release PR and tag through the supported workflow.
354
+ A tag without a qualifying merged PR is rejected. API access errors
355
+ and unverifiable protection settings stop verification. Use npm run release
356
+ to publish the existing version at the fetched default-branch commit. It checks
357
+ the merged PR and CI before tagging; the publish workflow verifies them again.
358
+ With strictVersionHistory true, --bump is rejected because versions must be
359
+ assigned before merge. With false, an unpublished existing version can be
360
+ released directly, or npm run release -- --bump patch (minor/major) prepares
361
+ a version-bump PR, waits for merge, then tags its merge commit. Already-published
362
+ versions and registry access errors stop a new release. Retries reuse the
363
+ pinned revision, PR and matching tag rather than creating another bump.
341
364
 
342
365
  Complete npm trusted-publishing example with Volta
343
366
  Keep publishing in a separate publish.yml as shown below, with exactly one
@@ -433,7 +456,7 @@ Using this check in the test chain
433
456
 
434
457
  Default-branch GitHub policy chain
435
458
  The configured PR workflow must use the approved reusable PR workflow in a
436
- required release job, or run release verify-protection with step GH_TOKEN
459
+ required release job, or run github check with step GH_TOKEN
437
460
  after npm ci and before tests in at least one job in git.releaseRequiredChecks.
438
461
  Verification must be unconditional and must not allow failure. The existing
439
462
  required-job validation applies to that job and its dependencies.