@jakobm/peacekeeper 0.25.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +464 -89
- package/dist/cmdabra.yaml +174 -110
- package/dist/package.json +6 -5
- package/dist/src/modules/cli/legacy-commands.js +37 -0
- package/dist/src/modules/cli/service.js +48 -39
- package/dist/src/modules/configuration/convention-rules.js +93 -0
- package/dist/src/modules/configuration/facade.js +1 -0
- package/dist/src/modules/configuration/project-config-defaults.json +5 -1
- package/dist/src/modules/configuration/project-config.js +28 -9
- package/dist/src/modules/configuration/update-config.js +16 -2
- package/dist/src/modules/dependencies.yaml +4 -4
- package/dist/src/modules/external.js +5 -0
- package/dist/src/modules/lifecycle/checkpoint-instructions.js +1 -1
- package/dist/src/modules/lifecycle/cleanup-ended-session.js +1 -1
- package/dist/src/modules/maintenance/cleanup-merged-branches.js +4 -4
- package/dist/src/modules/maintenance/initialize-codex-worktree.js +1 -1
- package/dist/src/modules/maintenance/remove-empty-directories.js +1 -1
- package/dist/src/modules/projects/check-project-requirements.txt +32 -31
- package/dist/src/modules/projects/check-project.js +16 -16
- package/dist/src/modules/projects/codex-setup-prefix.sh +2 -2
- package/dist/src/modules/projects/create-project-core.js +13 -28
- package/dist/src/modules/projects/generate-github-setup.js +16 -55
- package/dist/src/modules/projects/github-setup-prefix.sh +29 -2
- package/dist/src/modules/projects/github-setup-repository-template.sh +1 -40
- package/dist/src/modules/projects/github-setup-suffix-template.sh +7 -5
- package/dist/src/modules/projects/install-hooks.js +6 -5
- package/dist/src/modules/releases/configure-github.js +57 -0
- package/dist/src/modules/releases/facade.js +3 -2
- package/dist/src/modules/releases/github-configuration.js +166 -0
- package/dist/src/modules/releases/github-policy.js +45 -11
- package/dist/src/modules/releases/github-remote.js +230 -0
- package/dist/src/modules/testing/check-conventions.js +41 -0
- package/dist/src/modules/testing/check-test-receipt.js +17 -22
- package/dist/src/modules/testing/conventions.js +168 -0
- package/dist/src/modules/testing/facade.js +2 -1
- package/dist/src/modules/testing/receipt-state.js +27 -1
- package/dist/src/modules/testing/record-test-receipt.js +14 -13
- package/dist/src/modules/testing/run-tests.js +23 -14
- package/dist/src/modules/testing/types.js +1 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -6,6 +6,37 @@ The public npm package is `@jakobm/peacekeeper`; its CLI command is `peacekeeper
|
|
|
6
6
|
Install it with `npm install --save-exact @jakobm/peacekeeper@<version>`, selecting
|
|
7
7
|
a published version. Replace the example dependency pin below with that version.
|
|
8
8
|
|
|
9
|
+
## Command groups
|
|
10
|
+
|
|
11
|
+
Use `peacekeeper <group> <command>`. Running a group without a command displays
|
|
12
|
+
its help; `--help` also works at the root, group, and command levels. Shell
|
|
13
|
+
completion follows the same hierarchy.
|
|
14
|
+
|
|
15
|
+
| Group | Commands |
|
|
16
|
+
| --- | --- |
|
|
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` |
|
|
21
|
+
| `codex` | `install-hooks`, `init-worktree`, `checkpoint`, `session-start`, `stop`, `session-end` |
|
|
22
|
+
| `cleanup` | `merged-branches`, `empty-directories`, `queue-merged-worktree` |
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
peacekeeper project check
|
|
26
|
+
peacekeeper test run --checkpoint
|
|
27
|
+
peacekeeper github configure --help
|
|
28
|
+
peacekeeper release publish patch
|
|
29
|
+
peacekeeper cleanup merged-branches --execute
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The previous flat command names remain accepted for existing scripts and hooks.
|
|
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.
|
|
36
|
+
Help and generated project files use the grouped names. Update existing package
|
|
37
|
+
scripts and CI to those names, and run `peacekeeper codex install-hooks` to migrate
|
|
38
|
+
lifecycle hooks while preserving unrelated handlers.
|
|
39
|
+
|
|
9
40
|
## Architecture
|
|
10
41
|
|
|
11
42
|
All application code and tests are authored in TypeScript. Domain modules belong to the
|
|
@@ -23,7 +54,8 @@ as `src/modules/cli/types.ts` from the root `cmdabra.yaml`; `npm run typecheck`
|
|
|
23
54
|
verifies that it is current before checking the TypeScript project.
|
|
24
55
|
|
|
25
56
|
Generate the dependency views and SVG diagram with `npm run architecture`. The
|
|
26
|
-
checked-in output lives in `architecture/`.
|
|
57
|
+
checked-in output lives in `architecture/`. Peacekeeper's configured
|
|
58
|
+
`generated-files` convention verifies that output during `npm test`.
|
|
27
59
|
|
|
28
60
|
Checkpoint and session lifecycle hooks use the same Cmdabra and Portico composition
|
|
29
61
|
as other CLI commands. Dependencies must therefore be installed in every worktree
|
|
@@ -34,15 +66,33 @@ The CLI also exposes Cmdabra's global `--cmdabra-complete` option for
|
|
|
34
66
|
It accepts the current word index followed by all command-line words and prints
|
|
35
67
|
completion candidates without running a command.
|
|
36
68
|
|
|
69
|
+
## Testing Peacekeeper
|
|
70
|
+
|
|
71
|
+
Run `npm test` with the pinned Volta toolchain to build and run type checks,
|
|
72
|
+
module boundaries, repository conventions, and the complete test suite.
|
|
73
|
+
|
|
74
|
+
Read-only CLI behavior is covered by human-readable `.case` acceptance files in
|
|
75
|
+
[`tests/acceptance`](tests/acceptance/README.md), following the pattern used by
|
|
76
|
+
Ledlight and Cmdabra. Each case runs the actual CLI in an isolated temporary Git
|
|
77
|
+
repository and compares stdout, stderr, and exit status. Sections supply command
|
|
78
|
+
arguments, project configuration, files, environment, and stdin as needed. The
|
|
79
|
+
runner also rejects unexpected file changes.
|
|
80
|
+
|
|
81
|
+
Keep network operations, publishing, background workers, and repository mutations
|
|
82
|
+
in the existing integration suites with controlled dependencies. Acceptance cases
|
|
83
|
+
cover deterministic output and local preflight failures for those commands.
|
|
84
|
+
CLI syntax validation and generated help output are covered by Cmdabra's own tests.
|
|
85
|
+
Expected output is reviewed text; tests never regenerate it automatically.
|
|
86
|
+
|
|
37
87
|
## Create a compliant TypeScript project
|
|
38
88
|
|
|
39
|
-
`create
|
|
89
|
+
`project create` creates a minimal ESM TypeScript library in an existing, completely
|
|
40
90
|
empty GitHub repository. The command version owns the generated project contract,
|
|
41
91
|
all tool pins, and the exact `@jakobm/peacekeeper` development dependency. This
|
|
42
92
|
command additionally requires Volta so generation and verification use those pins.
|
|
43
93
|
|
|
44
94
|
```sh
|
|
45
|
-
peacekeeper
|
|
95
|
+
peacekeeper project create \
|
|
46
96
|
--repository https://github.com/OWNER/REPOSITORY.git \
|
|
47
97
|
--directory /absolute/path/to/REPOSITORY \
|
|
48
98
|
--package-name @scope/REPOSITORY \
|
|
@@ -68,50 +118,151 @@ An argument or preflight failure creates nothing. A later failure leaves the loc
|
|
|
68
118
|
directory for inspection but does not commit or push. A push failure leaves the
|
|
69
119
|
verified local commit. Inspect or remove the directory before retrying.
|
|
70
120
|
|
|
71
|
-
The
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
To
|
|
121
|
+
The generator creates an executable `setup-github-config.sh` and never runs it.
|
|
122
|
+
Use it in two steps, with the same plan directory:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
./setup-github-config.sh ./github-plans
|
|
126
|
+
# Review every saved plan, including protection deletions.
|
|
127
|
+
./setup-github-config.sh --execute ./github-plans
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The wrapper invokes the generator's exact `@jakobm/peacekeeper` version through
|
|
131
|
+
`npm exec --package`, then runs `groundskeeper secrets sync --name
|
|
132
|
+
RELEASE_POLICY_TOKEN --new-repo OWNER/REPO` only after every configuration has
|
|
133
|
+
succeeded and been read back. Planning never synchronizes secrets. Published
|
|
134
|
+
projects also require initial manual npm publication and trusted publishing
|
|
135
|
+
configuration; generating or running GitHub setup does not publish a package.
|
|
136
|
+
|
|
137
|
+
To generate the same wrapper for existing repositories:
|
|
88
138
|
|
|
89
139
|
```sh
|
|
90
|
-
peacekeeper generate-
|
|
140
|
+
peacekeeper github generate-setup \
|
|
91
141
|
--repository https://github.com/OWNER/REPOSITORY.git \
|
|
92
|
-
--repository https://github.com/OWNER/ANOTHER-REPOSITORY.git
|
|
142
|
+
--repository https://github.com/OWNER/ANOTHER-REPOSITORY.git > setup-github-config.sh
|
|
93
143
|
```
|
|
94
144
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
Generation reads and validates remote policy and captures the exact source SHA
|
|
146
|
+
for each repository. The wrapper refuses to plan from a different commit if that
|
|
147
|
+
source subsequently moves. For a single repository, `--policy-pr NUMBER` selects
|
|
148
|
+
an introduction/upgrade PR, and `--source-ref COMMIT_SHA` asserts its expected head
|
|
149
|
+
(or the expected default-branch SHA). Generate separate wrappers for repositories
|
|
150
|
+
with different explicit policy sources. Existing generated scripts retain their
|
|
151
|
+
old implementation; regenerate them to adopt this flow.
|
|
152
|
+
|
|
153
|
+
## Plan and apply exact GitHub configuration
|
|
154
|
+
|
|
155
|
+
`github configure` owns GitHub policy for one explicit `OWNER/REPO` on github.com.
|
|
156
|
+
It works outside a Git checkout and reads policy files exclusively from GitHub;
|
|
157
|
+
local configuration, dependencies and target-repository code are not executed.
|
|
158
|
+
Dry-run is the default:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
peacekeeper github configure --repository OWNER/REPO --plan-file github-plan.json
|
|
162
|
+
peacekeeper github configure --plan-file github-plan.json --execute
|
|
163
|
+
|
|
164
|
+
# Bootstrap using an open PR in the same repository targeting its default branch.
|
|
165
|
+
peacekeeper github configure --repository OWNER/REPO --policy-pr 31 \
|
|
166
|
+
--source-ref FULL_HEAD_SHA --plan-file bootstrap-plan.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The source is resolved to an exact commit before reading `peacekeeper.config.yaml`
|
|
170
|
+
and `.github/CODEOWNERS`. An absent configuration uses the running version's
|
|
171
|
+
bundled defaults, including repository-owner fallback for a null
|
|
172
|
+
`git.requiredApprover`. Absence is established from the source Git tree; API or
|
|
173
|
+
permission failures never select defaults. Invalid YAML/schema and legacy
|
|
174
|
+
`peacekeeper.config.json` are errors. The personal repository owner must be the
|
|
175
|
+
required approver, and CODEOWNERS must contain exactly one effective rule,
|
|
176
|
+
`* @OWNER`, even when configuration defaults are used.
|
|
177
|
+
|
|
178
|
+
A policy PR's files are read at its exact head SHA. The result marks this as
|
|
179
|
+
bootstrap: GitHub uses CODEOWNERS from the target branch, so ownership changes in
|
|
180
|
+
that PR only become effective after merge. This command configures GitHub settings
|
|
181
|
+
and never merges the PR or claims that unmerged ownership files are already active.
|
|
182
|
+
`--source-ref` is an expected SHA guard for the selected source, not a way to skip
|
|
183
|
+
PR validation or select an unrelated historical commit.
|
|
184
|
+
|
|
185
|
+
The owned surface is exactly:
|
|
186
|
+
|
|
187
|
+
- Repository merge methods: merge commits enabled, squash and rebase disabled.
|
|
188
|
+
- Repository auto-merge availability and automatic merged-branch deletion enabled.
|
|
189
|
+
- Exactly the two canonical active branch rulesets from the bundled shared policy.
|
|
190
|
+
- No classic branch protection rules anywhere in the repository.
|
|
191
|
+
|
|
192
|
+
**Every other repository-owned branch ruleset and every classic protection rule
|
|
193
|
+
will be deleted, including protections for other branches and wildcard rules
|
|
194
|
+
that do not currently match a branch.** The canonical rulesets protect only the
|
|
195
|
+
default branch; other branches can lose protection. There is no preserve-other-
|
|
196
|
+
branches option. Future exceptions belong in versioned Peacekeeper configuration.
|
|
197
|
+
Secrets, collaborators, deploy keys, webhooks, environments, security settings,
|
|
198
|
+
and tag/push rulesets are outside the owned surface and are preserved. Inherited
|
|
199
|
+
active branch rules that cannot be proven compatible with the canonical policy
|
|
200
|
+
are blockers and must be resolved at their source. Missing bypass visibility or
|
|
201
|
+
incomplete inventory blocks planning instead of assuming there are no restrictions.
|
|
202
|
+
|
|
203
|
+
Dry-run shows every creation, update and deletion with before/after policy and
|
|
204
|
+
blockers. `--plan-file` saves a new JSON file exclusively (existing files are not
|
|
205
|
+
overwritten). Omit it to inspect a plan without saving. Execute requires the saved
|
|
206
|
+
plan. Policy-source overrides cannot be combined with `--execute`; an optional
|
|
207
|
+
`--repository OWNER/REPO` asserts the saved target without changing it. Generated
|
|
208
|
+
wrappers always use this assertion before synchronizing secrets.
|
|
209
|
+
Before writing, Peacekeeper validates the plan against its current canonical
|
|
210
|
+
policy, exact package version, source SHA, default branch/SHA, stable repo identity
|
|
211
|
+
and relevant observed GitHub configuration. A moved source or changed precondition
|
|
212
|
+
requires a new plan. Editing the plan does not authorize arbitrary API requests.
|
|
213
|
+
|
|
214
|
+
The executor establishes and checks the canonical protections before deletions,
|
|
215
|
+
checks relevant remote state between operations and reads the entire owned surface
|
|
216
|
+
back before success. GitHub has no transactions: concurrent changes can still
|
|
217
|
+
occur between checks and API writes. Failures report completed/attempted operations
|
|
218
|
+
and read-back state where available. After a partial failure, plan again into a
|
|
219
|
+
new file/directory and apply the remaining changes; already correct configuration
|
|
220
|
+
needs no rollback. The same recovery applies to a partially completed multi-repo
|
|
221
|
+
wrapper. After verified success, a fresh plan has no changes. Secret synchronization
|
|
222
|
+
is a separate step; a secret-sync failure does not roll back GitHub settings.
|
|
223
|
+
|
|
224
|
+
Use a manually authenticated GitHub identity with repository Administration write
|
|
225
|
+
access for execute, and sufficient Contents/Administration read access for complete
|
|
226
|
+
policy inspection. Do not put admin-write credentials in Actions secrets.
|
|
227
|
+
The shared policy model also serves `release verify-protection`; that existing
|
|
228
|
+
command retains its documented semantic alternatives, including equivalent classic
|
|
229
|
+
protection, while github configure verifies the exact owned configuration.
|
|
230
|
+
|
|
231
|
+
### Machine-readable contract
|
|
232
|
+
|
|
233
|
+
Add `--json` for a JSON result on stdout. Human output is not an automation API.
|
|
234
|
+
Every result contains `resultFormatVersion: 1`, `peacekeeperVersion`, and `status`.
|
|
235
|
+
Planning results include `plan`; failures include an error and/or blocker details.
|
|
236
|
+
Status values are `planned`, `blocked`, `stale`, `partial`, `verification-failed`,
|
|
237
|
+
`succeeded`, and `failed`. Execute results include `completed` and, when available,
|
|
238
|
+
`attempted`, `observed`, `readbackError` and `bootstrap`. A blocked plan can be saved
|
|
239
|
+
for inspection but cannot execute. Planning errors that prevent a complete plan
|
|
240
|
+
return structured blockers without writing a plan file.
|
|
241
|
+
|
|
242
|
+
Saved plans use `formatVersion: 1` and contain `peacekeeperVersion`,
|
|
243
|
+
`repository: { id, slug }`, `source: { kind, sha, defaultBranch, defaultSha,
|
|
244
|
+
policyPr? }`, `bootstrap`, `configSource` (`remote` or `defaults`), `observed`,
|
|
245
|
+
`desired`, `changes` and `blockers`. `observed` covers owned repository settings,
|
|
246
|
+
repository-owned/inherited branch rulesets, and complete classic protection rules
|
|
247
|
+
with allowance actors. `desired` carries canonical settings/rulesets and absence
|
|
248
|
+
requirements. Changes identify their resource `kind`, `action`, existing `id`
|
|
249
|
+
where applicable, and `before`/`after` policy as applicable.
|
|
250
|
+
|
|
251
|
+
Policy arrays are normalized as unordered collections. Response metadata is
|
|
252
|
+
excluded; unknown rule parameters remain significant. GitHub's empty
|
|
253
|
+
`required_reviewers` list and null check integration IDs normalize away, and omitted
|
|
254
|
+
`require_extra_approval_for_unattributed_changes` uses GitHub's true default.
|
|
255
|
+
These rules apply equally to canonical policy and observed state.
|
|
256
|
+
|
|
257
|
+
Exit status is 0 for an unblocked plan (even with changes) or verified execute
|
|
258
|
+
success, 1 for blockers, stale/invalid plans, partial execution or other operational
|
|
259
|
+
failures, and 2 for Cmdabra syntax errors. Plan/execute is a Peacekeeper-owned
|
|
260
|
+
contract, not a generic API request format. Groundskeeper should retain plans
|
|
261
|
+
unchanged and return them to the same exactly pinned Peacekeeper version.
|
|
111
262
|
|
|
112
263
|
When moving an existing project to Peacekeeper, update its dependency and lockfile,
|
|
113
264
|
package scripts, and configuration filename together. Replace previous lifecycle
|
|
114
|
-
hook commands with the definitions below before running `peacekeeper install-hooks`.
|
|
265
|
+
hook commands with the definitions below before running `peacekeeper codex install-hooks`.
|
|
115
266
|
The installer recognizes Peacekeeper commands; it does not translate commands
|
|
116
267
|
from a differently named package. Each existing worktree needs the new dependency
|
|
117
268
|
and configuration. Test receipts start fresh under the new package identity;
|
|
@@ -130,9 +281,9 @@ Include these entries in the caller's `package.json`, alongside its other script
|
|
|
130
281
|
"private": true,
|
|
131
282
|
"scripts": {
|
|
132
283
|
"lint": "eslint .",
|
|
133
|
-
"test": "peacekeeper run
|
|
134
|
-
"cleanup:branches": "peacekeeper cleanup
|
|
135
|
-
"cleanup:empty-directories": "peacekeeper
|
|
284
|
+
"test": "peacekeeper test run",
|
|
285
|
+
"cleanup:branches": "peacekeeper cleanup merged-branches",
|
|
286
|
+
"cleanup:empty-directories": "peacekeeper cleanup empty-directories"
|
|
136
287
|
},
|
|
137
288
|
"devDependencies": {
|
|
138
289
|
"eslint": "^9.39.5"
|
|
@@ -153,9 +304,12 @@ Peacekeeper uses the complete bundled [defaults](src/modules/configuration/proje
|
|
|
153
304
|
The defaults contain no test commands; configure those before running tests or
|
|
154
305
|
recording or reusing a test receipt.
|
|
155
306
|
|
|
156
|
-
Run `peacekeeper update-config` to create the file or recursively fill missing
|
|
307
|
+
Run `peacekeeper project update-config` to create the file or recursively fill missing
|
|
157
308
|
fields from the defaults. Existing values, including empty arrays, are preserved.
|
|
158
309
|
Comments in an existing YAML file are preserved. Review newly inserted values.
|
|
310
|
+
The old `tests.commands` field is migrated to `tests.all`; `tests.checkpoint`
|
|
311
|
+
defaults to an empty list. If both `commands` and `all` exist, resolve that
|
|
312
|
+
ambiguity manually before updating.
|
|
159
313
|
Invalid YAML, unknown fields, or invalid existing
|
|
160
314
|
values cause failure without changing the file. Repeating the command on a
|
|
161
315
|
complete valid file leaves it unchanged.
|
|
@@ -164,11 +318,11 @@ The former `peacekeeper.config.json` filename is not accepted. Rename and conver
|
|
|
164
318
|
it before upgrading so Peacekeeper cannot silently fall back to defaults.
|
|
165
319
|
|
|
166
320
|
All CLI commands validate configuration before executing, except help,
|
|
167
|
-
`
|
|
321
|
+
`project check --explain`, and `project update-config`. Checkpoint hooks instead validate
|
|
168
322
|
the event worktree configuration when the event requires instructions or a check.
|
|
169
323
|
An incomplete existing file fails
|
|
170
324
|
with missing field paths and a repair hint. Updates introducing new fields
|
|
171
|
-
therefore require `peacekeeper update-config` before ordinary commands can run.
|
|
325
|
+
therefore require `peacekeeper project update-config` before ordinary commands can run.
|
|
172
326
|
|
|
173
327
|
Complete example:
|
|
174
328
|
|
|
@@ -186,11 +340,17 @@ git:
|
|
|
186
340
|
- test
|
|
187
341
|
releaseTestWorkflow: test.yml
|
|
188
342
|
tests:
|
|
189
|
-
|
|
343
|
+
all:
|
|
190
344
|
- eslint .
|
|
345
|
+
- peacekeeper project check-conventions
|
|
191
346
|
- node --test
|
|
347
|
+
checkpoint:
|
|
348
|
+
- eslint .
|
|
349
|
+
- peacekeeper project check-conventions
|
|
192
350
|
receiptMaxAgeMinutes: 60
|
|
193
351
|
npmTestUsesRunner: true
|
|
352
|
+
conventions:
|
|
353
|
+
rules: []
|
|
194
354
|
loggingDirectory: tmp/logs
|
|
195
355
|
loggingEnabled: true
|
|
196
356
|
projectChecks:
|
|
@@ -199,7 +359,30 @@ projectChecks:
|
|
|
199
359
|
- test
|
|
200
360
|
```
|
|
201
361
|
|
|
202
|
-
`git.remote` and `git.defaultBranch` identify the branch used for checkpointing and cleanup. `git.branchPrefix` names new task branches. `git.requiredApprover` names the personal GitHub repository owner who must approve other users' PRs and may bypass only the approval ruleset from a PR. Set it explicitly after `update-config`; its bundled default is `null`. The root project must contain `.github/CODEOWNERS` with the single non-comment rule `* @OWNER`, matching this value.
|
|
362
|
+
`git.remote` and `git.defaultBranch` identify the branch used for checkpointing and cleanup. `git.branchPrefix` names new task branches. `git.requiredApprover` names the personal GitHub repository owner who must approve other users' PRs and may bypass only the approval ruleset from a PR. Set it explicitly after `project update-config`; its bundled default is `null`. The root project must contain `.github/CODEOWNERS` with the single non-comment rule `* @OWNER`, matching this value.
|
|
363
|
+
|
|
364
|
+
`peacekeeper test run` is the full test command and runs `tests.all`.
|
|
365
|
+
`peacekeeper test run --checkpoint` runs `tests.checkpoint` instead; the flag
|
|
366
|
+
is off by default. Each consuming project chooses both lists. Every checkpoint
|
|
367
|
+
command must also occur in `all` as the **exact same shell command string**.
|
|
368
|
+
Invalid membership fails configuration validation before either mode executes
|
|
369
|
+
any test commands, including with `--force` or existing receipts. An empty
|
|
370
|
+
checkpoint list is valid, as is one containing all commands. `tests.all` must
|
|
371
|
+
contain at least one command before tests or receipt commands can be used.
|
|
372
|
+
|
|
373
|
+
Both modes always run the local `project check` validation first, even when all
|
|
374
|
+
selected commands have valid receipts or the checkpoint list is empty. Explicit
|
|
375
|
+
`project check` invocations in either list are rejected as redundant. Commands
|
|
376
|
+
run in list order from the caller's Git root; install any executables they use.
|
|
377
|
+
Repeated identical strings run once per invocation. The runner stops at the
|
|
378
|
+
first failure and records a receipt immediately after each successful command.
|
|
379
|
+
|
|
380
|
+
`receiptMaxAgeMinutes` controls how long each command receipt can be reused.
|
|
381
|
+
Set `npmTestUsesRunner` to `true` only when the caller's `npm test` script invokes
|
|
382
|
+
`peacekeeper test run`; the rerun hint then uses `npm test -- --force` (and
|
|
383
|
+
`--checkpoint` when selected). Otherwise it uses the explicit package path.
|
|
384
|
+
`loggingDirectory` stores hook invocation logs relative to the primary Git
|
|
385
|
+
worktree's root.
|
|
203
386
|
|
|
204
387
|
`loggingEnabled` has the bundled default `true`; set it to `false` to disable invocation logs and the background cleanup worker's log file. Existing logs are kept. The setting is read from the primary checkout's configuration, including for linked worktrees. SessionStart and Stop logs include the process and event working directories, event type, primary-checkout classification, and hook response or error. Only selected event fields are logged, never the full incoming payload. These logs require the Peacekeeper script to start; a missing Node.js executable or package must be diagnosed in Codex's own logs.
|
|
205
388
|
|
|
@@ -223,21 +406,38 @@ branch's upstream. If a push fails, earlier pushes are kept and the checkpoint
|
|
|
223
406
|
records a failure; fix the cause and rerun the checkpoint command to retry without
|
|
224
407
|
creating another commit when there are no new changes.
|
|
225
408
|
|
|
226
|
-
Receipts are stored outside the repository under `peacekeeper-test-receipts` in
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
409
|
+
Receipts are stored outside the repository under `peacekeeper-test-receipts` in
|
|
410
|
+
Node.js's `os.tmpdir()`. Each Git root has one file containing separate receipts
|
|
411
|
+
keyed by exact command strings, independent of the selected test level. After
|
|
412
|
+
`test run --checkpoint`, a subsequent `test run` skips shared commands with
|
|
413
|
+
valid receipts and runs the remaining commands. Running `all` also covers
|
|
414
|
+
`checkpoint`. Receipt validation fingerprints changed files and the process
|
|
415
|
+
environment; changing a command creates a different cache identity. Legacy
|
|
416
|
+
whole-suite receipts are ignored and replaced as commands pass.
|
|
417
|
+
|
|
418
|
+
Each command's previous receipt is invalidated before it runs. Successful
|
|
419
|
+
commands keep their receipts if a later command fails, so a retry can resume
|
|
420
|
+
with the failed or untested commands. `--force` and CI bypass reuse and invalidate
|
|
421
|
+
all selected receipts up front, including commands not reached after a failure;
|
|
422
|
+
receipts for unselected commands are preserved. Failed project validation
|
|
423
|
+
invalidates all command receipts for the repository.
|
|
424
|
+
|
|
425
|
+
The runner compares repository contents and the test environment before and
|
|
426
|
+
after each command. If either changes during that command, it exits with an
|
|
427
|
+
error and records no receipt for it. Rerun tests on the resulting contents.
|
|
232
428
|
Test-generated files should be ignored or written outside the repository.
|
|
233
429
|
|
|
430
|
+
`test check-receipt` succeeds only when every command in `tests.all` has a valid
|
|
431
|
+
receipt. `test record-receipt` certifies those commands without executing them.
|
|
432
|
+
Both support `--checkpoint` to select `tests.checkpoint` instead.
|
|
433
|
+
|
|
234
434
|
### 3. `.codex/hooks.json`
|
|
235
435
|
|
|
236
436
|
Install or update the project hooks from the caller's Git worktree:
|
|
237
437
|
|
|
238
438
|
```sh
|
|
239
|
-
npm exec --no -- peacekeeper install-hooks --dry-run
|
|
240
|
-
npm exec --no -- peacekeeper install-hooks
|
|
439
|
+
npm exec --no -- peacekeeper codex install-hooks --dry-run
|
|
440
|
+
npm exec --no -- peacekeeper codex install-hooks
|
|
241
441
|
```
|
|
242
442
|
|
|
243
443
|
The command creates or updates `.codex/hooks.json` at the Git root. It preserves
|
|
@@ -271,7 +471,7 @@ The installed file contains these definitions (other existing hooks are retained
|
|
|
271
471
|
"hooks": [
|
|
272
472
|
{
|
|
273
473
|
"type": "command",
|
|
274
|
-
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\"
|
|
474
|
+
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\" codex session-start",
|
|
275
475
|
"timeout": 30,
|
|
276
476
|
"statusMessage": "Loading Codex checkpoint instructions"
|
|
277
477
|
}
|
|
@@ -283,7 +483,7 @@ The installed file contains these definitions (other existing hooks are retained
|
|
|
283
483
|
"hooks": [
|
|
284
484
|
{
|
|
285
485
|
"type": "command",
|
|
286
|
-
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\"
|
|
486
|
+
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\" codex stop",
|
|
287
487
|
"timeout": 30,
|
|
288
488
|
"statusMessage": "Checking for an uncommitted Codex checkpoint"
|
|
289
489
|
}
|
|
@@ -295,7 +495,7 @@ The installed file contains these definitions (other existing hooks are retained
|
|
|
295
495
|
"hooks": [
|
|
296
496
|
{
|
|
297
497
|
"type": "command",
|
|
298
|
-
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\"
|
|
498
|
+
"command": "node \"$(git rev-parse --show-toplevel)/node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js\" codex session-end",
|
|
299
499
|
"timeout": 3,
|
|
300
500
|
"statusMessage": "Scheduling merged branch cleanup"
|
|
301
501
|
}
|
|
@@ -306,14 +506,14 @@ The installed file contains these definitions (other existing hooks are retained
|
|
|
306
506
|
}
|
|
307
507
|
```
|
|
308
508
|
|
|
309
|
-
The commands resolve the package from the current Git worktree. Install dependencies in each worktree where the hooks will run; the commands need that worktree's `node_modules/@jakobm/peacekeeper`. The checkpoint hooks apply only to linked worktrees. `SessionStart` supplies the checkpoint instructions before work begins, including on resume, fork, and after compaction; no matcher is needed. `Stop` uses the same package-owned instructions as a fallback. You do not need to copy checkpoint rules into each project's `AGENTS.md`. Explicit user instructions not to commit or push take precedence: the agent must skip the checkpoint command when they conflict, even if `Stop` requests it. The hook checks Git state and cannot determine user intent itself. When uncommitted changes remain, the `Stop` hook asks the agent to review the diff and run `checkpoint
|
|
509
|
+
The commands resolve the package from the current Git worktree. Install dependencies in each worktree where the hooks will run; the commands need that worktree's `node_modules/@jakobm/peacekeeper`. The checkpoint hooks apply only to linked worktrees. `SessionStart` supplies the checkpoint instructions before work begins, including on resume, fork, and after compaction; no matcher is needed. `Stop` uses the same package-owned instructions as a fallback. You do not need to copy checkpoint rules into each project's `AGENTS.md`. Explicit user instructions not to commit or push take precedence: the agent must skip the checkpoint command when they conflict, even if `Stop` requests it. The hook checks Git state and cannot determine user intent itself. When uncommitted changes remain, the `Stop` hook asks the agent to review the diff and run `codex checkpoint` with a descriptive English commit message. That command stages all changes and commits them on a task branch; it refuses the configured default branch. With `git.checkpointPushRemotes`, it pushes without force to each listed remote, including new branches. An empty array keeps the branch local.
|
|
310
510
|
|
|
311
511
|
`SessionEnd` starts a detached worker to clean up the session worktree and branch only if the captured branch tip is still unchanged and fully merged into the remote default branch. Dirty or locked worktrees are kept. Worker output is appended to `cleanup-ended-session.log` in the shared Git directory. Cleanup does not require the primary worktree to have the default branch checked out. A local default branch that can fast-forward is updated before cleanup: a branch not checked out in any worktree is moved atomically, while a checked-out branch is merged in its clean worktree so its files and index stay synchronized. A dirty or diverged default branch is left unchanged. Codex loads project hooks only after the project hook source is trusted; review them with `/hooks`. The three-second `SessionEnd` timeout is the maximum documented for that event. See the [Codex hooks reference](https://learn.chatgpt.com/docs/hooks) for hook loading, trust, and timeout behavior.
|
|
312
512
|
|
|
313
513
|
### Adopting shared checkpoint instructions
|
|
314
514
|
|
|
315
515
|
For a project that already uses the Stop hook, upgrade to a package release that
|
|
316
|
-
includes `
|
|
516
|
+
includes `codex session-start` and `codex install-hooks`, then run the installer above.
|
|
317
517
|
The installer also updates `Stop` and `SessionEnd`. Review and trust the updated hooks with `/hooks`,
|
|
318
518
|
then start a new session or resume one to load the instructions. The pinned package version must include these commands.
|
|
319
519
|
|
|
@@ -324,7 +524,7 @@ them. The shared policy then follows the installed package version.
|
|
|
324
524
|
|
|
325
525
|
## Check the setup
|
|
326
526
|
|
|
327
|
-
From the caller's Git worktree, run `npm test` for
|
|
527
|
+
From the caller's Git worktree, run `npm test` for `tests.all`, `npm test -- --checkpoint` for `tests.checkpoint`, `npm test -- --force` to bypass command receipts, `npm run cleanup:branches` to preview merged branch cleanup, and `npm run cleanup:empty-directories` to preview removal of empty directories and directories containing only ignored files. The latter command protects the root `.git`, `node_modules`, and `tmp` directories; other selected directories are removed recursively, including their ignored contents. Add `-- --execute` to either cleanup package script to apply it. Run `npm exec --no -- peacekeeper --help` for the complete command list. To create a manual checkpoint, use `npm exec --no -- peacekeeper codex checkpoint --subject "<subject>" --body "<body paragraph>"`.
|
|
328
528
|
|
|
329
529
|
Directory cleanup also preserves nested Git repositories and linked worktrees,
|
|
330
530
|
including their parent directories when those parents are ignored. It does not
|
|
@@ -350,20 +550,195 @@ are stored there and session cleanup reads that checkout's configuration.
|
|
|
350
550
|
The hook definitions can then be reviewed and trusted in Codex; committing them
|
|
351
551
|
does not grant trust automatically.
|
|
352
552
|
|
|
553
|
+
## Configured repository conventions
|
|
554
|
+
|
|
555
|
+
Define general file conventions in `peacekeeper.config.yaml` and run:
|
|
556
|
+
|
|
557
|
+
```sh
|
|
558
|
+
peacekeeper project check-conventions
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
Add `peacekeeper project check-conventions` explicitly to `tests.all` to include it
|
|
562
|
+
in the normal test run at the desired position. It is not added automatically.
|
|
563
|
+
Each rule is reported as a Node.js test. Violations, file errors, failed generators,
|
|
564
|
+
and invalid configuration cause a nonzero exit status; one failing rule does not
|
|
565
|
+
hide the results of later rules. A failed command in `test run` has no passing
|
|
566
|
+
receipt; successful earlier commands retain their own receipts.
|
|
567
|
+
|
|
568
|
+
All configured paths and generator working directories are relative to the Git
|
|
569
|
+
root, even when the command is invoked from a subdirectory. Use forward slashes
|
|
570
|
+
on every platform. There is no separate conventions file. `conventions.rules: []`
|
|
571
|
+
is valid and reports that no rules are configured. Existing projects must run
|
|
572
|
+
`peacekeeper project update-config` to add this field before ordinary commands can run;
|
|
573
|
+
existing rules and YAML comments are preserved.
|
|
574
|
+
|
|
575
|
+
Standalone checks always run and do not create or reuse test receipts. When
|
|
576
|
+
included in `tests.all`, they follow `test run`' existing receipt reuse;
|
|
577
|
+
use `peacekeeper test run --force` to rerun the full configured test flow.
|
|
578
|
+
Run `project check-conventions --update` separately from that flow when updating output.
|
|
579
|
+
|
|
580
|
+
The `testing` module owns rule execution and Node test reporting. The
|
|
581
|
+
`configuration` module owns the rule contract and strict validation, and `cli`
|
|
582
|
+
maps the command through the testing facade.
|
|
583
|
+
|
|
584
|
+
Peacekeeper's own configuration checks generated architecture output, kebab-case
|
|
585
|
+
TypeScript filenames, the two permitted files at the module root, test and fixture
|
|
586
|
+
files in the test tree, and sorted dependency lists. These rules run as an explicit
|
|
587
|
+
step in `npm test`; the architecture output check uses the same rule runner as
|
|
588
|
+
consumer projects.
|
|
589
|
+
|
|
590
|
+
### Allowed files
|
|
591
|
+
|
|
592
|
+
```yaml
|
|
593
|
+
conventions:
|
|
594
|
+
rules:
|
|
595
|
+
- check: allowed-files
|
|
596
|
+
files: "tests/acceptance/**/*"
|
|
597
|
+
allow:
|
|
598
|
+
- "tests/acceptance/**/*.case"
|
|
599
|
+
- "tests/acceptance/**/README.md"
|
|
600
|
+
|
|
601
|
+
- check: allowed-files
|
|
602
|
+
files: "scripts/*"
|
|
603
|
+
allow: []
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
`files` selects existing files using glob patterns. `*` matches within one path
|
|
607
|
+
segment; `**` includes subdirectories. Directories themselves are not checked.
|
|
608
|
+
Hidden files are included. Symbolic directory links are not recursively followed.
|
|
609
|
+
|
|
610
|
+
Each selected file must match at least one `allow` pattern. The patterns in
|
|
611
|
+
`allow` are also relative to the repository root. An explicit empty
|
|
612
|
+
list forbids every selected file; omitting `allow` is a configuration error.
|
|
613
|
+
Overlapping rules must each pass independently.
|
|
614
|
+
|
|
615
|
+
The literal directory prefix before the first glob segment must exist. For
|
|
616
|
+
example, `scripts/*` fails when `scripts` is missing, but passes when it exists
|
|
617
|
+
and contains no direct files. These rules constrain existing files; they do not
|
|
618
|
+
require files to be present.
|
|
619
|
+
|
|
620
|
+
### Corresponding files
|
|
621
|
+
|
|
622
|
+
```yaml
|
|
623
|
+
conventions:
|
|
624
|
+
rules:
|
|
625
|
+
- check: corresponding-files
|
|
626
|
+
from: "tests/unit/src/{path}.test.ts"
|
|
627
|
+
to: "src/{path}.ts"
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
Each matching `from` file must have an existing file at its corresponding `to`
|
|
631
|
+
path. `{path}` captures a nonempty relative path, including subdirectories, and
|
|
632
|
+
substitutes it unchanged into the target. Both templates must contain exactly
|
|
633
|
+
one `{path}` placeholder and no other glob patterns. The literal source
|
|
634
|
+
directory must exist; an existing empty source directory is allowed.
|
|
635
|
+
|
|
636
|
+
The check is one-way: extra target files are allowed. A directory at the target
|
|
637
|
+
path does not count as a corresponding file. Missing targets are reported with
|
|
638
|
+
both the source and expected target paths.
|
|
639
|
+
|
|
640
|
+
An empty `conventions.rules` list is valid. Unknown checks and fields,
|
|
641
|
+
absolute paths, parent traversal, and negated patterns are configuration errors.
|
|
642
|
+
|
|
643
|
+
### Sorted YAML lists
|
|
644
|
+
|
|
645
|
+
```yaml
|
|
646
|
+
conventions:
|
|
647
|
+
rules:
|
|
648
|
+
- check: sorted-yaml-lists
|
|
649
|
+
file: "src/modules/dependencies.yaml"
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
Recursively checks every list containing only strings, including lists nested
|
|
653
|
+
inside mappings or other lists. Ordering uses JavaScript's case-sensitive
|
|
654
|
+
string sort, without locale rules. Empty lists and duplicate values are allowed.
|
|
655
|
+
Other lists are traversed for nested string lists, but are not themselves sorted.
|
|
656
|
+
Failures identify the file and the YAML value path. Missing files and invalid
|
|
657
|
+
YAML fail the check. `file` must be a literal relative path.
|
|
658
|
+
|
|
659
|
+
### Document links
|
|
660
|
+
|
|
661
|
+
```yaml
|
|
662
|
+
conventions:
|
|
663
|
+
rules:
|
|
664
|
+
- check: document-links
|
|
665
|
+
document: "README.md"
|
|
666
|
+
files: "docs/**/*"
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
Every selected file must be the destination of an inline Markdown link in
|
|
670
|
+
`document`. Destinations are relative to the document's directory; URL-encoded
|
|
671
|
+
paths, fragments, query strings, and optional double-quoted titles are supported.
|
|
672
|
+
External URLs do not cover local files. Extra links are allowed. This simple
|
|
673
|
+
check recognizes inline link syntax only, not reference links or HTML links;
|
|
674
|
+
it does not parse Markdown blocks, so link-shaped text in code also counts.
|
|
675
|
+
The file selection has the same directory and glob semantics as `allowed-files`.
|
|
676
|
+
A missing document fails, and `document` must be a literal relative path.
|
|
677
|
+
|
|
678
|
+
### File names
|
|
679
|
+
|
|
680
|
+
```yaml
|
|
681
|
+
conventions:
|
|
682
|
+
rules:
|
|
683
|
+
- check: file-names
|
|
684
|
+
files: "{src,scripts,tests}/**/*.ts"
|
|
685
|
+
match: '^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\.test|\.d)?\.ts$'
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
`files` selects files using the same glob and directory semantics as
|
|
689
|
+
`allowed-files`. `match` is a case-sensitive JavaScript regular expression
|
|
690
|
+
using Unicode mode, applied to each file's basename including its extensions.
|
|
691
|
+
Directory names are not checked. Use `^` and `$` to require a full-name match;
|
|
692
|
+
without anchors, substring matches are allowed. Invalid expressions are
|
|
693
|
+
configuration errors. Failures report the file and expected expression.
|
|
694
|
+
YAML single quotes preserve regex backslashes without extra escaping.
|
|
695
|
+
|
|
696
|
+
The example requires kebab-case TypeScript filenames with optional `.test` or
|
|
697
|
+
`.d` suffixes. Adjust the expression to the calling project's naming conventions.
|
|
698
|
+
|
|
699
|
+
### Generated files
|
|
700
|
+
|
|
701
|
+
```yaml
|
|
702
|
+
conventions:
|
|
703
|
+
rules:
|
|
704
|
+
- check: generated-files
|
|
705
|
+
run: 'portico architecture --modules dist/src/modules --output "{output}"'
|
|
706
|
+
expected: architecture
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Runs a shell command from the repository root, with local
|
|
710
|
+
`node_modules/.bin` programs available. Quote `"{output}"` in the command:
|
|
711
|
+
the runner substitutes a temporary output directory and removes it afterward.
|
|
712
|
+
The command must succeed. The expected directory must exist and contain exactly
|
|
713
|
+
the same relative file paths and bytes, including hidden and nested files.
|
|
714
|
+
Empty directories are not compared. Generation must be deterministic.
|
|
715
|
+
|
|
716
|
+
Run `peacekeeper project check-conventions --update` to regenerate all configured outputs.
|
|
717
|
+
This replaces each expected directory only after its generator succeeds, removing
|
|
718
|
+
stale files. Expected directories must contain only reproducible generated output;
|
|
719
|
+
review the diff before committing. Git metadata paths and expected paths containing
|
|
720
|
+
symbolic links are rejected. Temporary output is removed after each rule.
|
|
721
|
+
|
|
722
|
+
Other convention rules are still checked and are never automatically repaired.
|
|
723
|
+
The command does not sort YAML, rename files, create corresponding source files,
|
|
724
|
+
or insert document links. Updates happen per rule, so generated files may have
|
|
725
|
+
been updated even if another rule fails. A failed generator preserves that rule's
|
|
726
|
+
previous expected files and reports its exit status and output.
|
|
727
|
+
|
|
353
728
|
## Check project conventions locally
|
|
354
729
|
|
|
355
|
-
Run `peacekeeper check
|
|
730
|
+
Run `peacekeeper project check` to check the local project configuration.
|
|
356
731
|
|
|
357
732
|
Declare the mandatory boolean `publishesToNpm` in `peacekeeper.config.yaml`.
|
|
358
|
-
Its default is `false`; `update-config` inserts `false` without inferring intent
|
|
733
|
+
Its default is `false`; `project update-config` inserts `false` without inferring intent
|
|
359
734
|
from package metadata. Set it to `true` for packages published to npm (including
|
|
360
735
|
restricted scoped packages). Peacekeeper itself sets it to `true`.
|
|
361
|
-
A missing field in an existing configuration is a
|
|
736
|
+
A missing field in an existing configuration is a project check error.
|
|
362
737
|
|
|
363
738
|
With `true`, declare a publishable package (`private` absent or `false`), a valid
|
|
364
739
|
npm name, stable version, description, license, nonempty `files` list, and
|
|
365
740
|
`publishConfig` with registry `https://registry.npmjs.org/` and explicit access
|
|
366
|
-
`public` or `restricted`. Add a direct `peacekeeper release` package script
|
|
741
|
+
`public` or `restricted`. Add a direct `peacekeeper release publish` package script
|
|
367
742
|
(the npm-exec and local Node CLI forms are also supported), a packaging check
|
|
368
743
|
after `npm ci` in the selected PR workflow
|
|
369
744
|
(`npm pack`, optionally `--dry-run --json`, or `npm run test:package`), and the
|
|
@@ -379,13 +754,13 @@ proven free of publication code by this local check. Remove dedicated npm
|
|
|
379
754
|
publishing credentials and trusted-publisher registrations separately.
|
|
380
755
|
Internal `npm pack`, build scripts, module entry points and CLI metadata remain
|
|
381
756
|
allowed, as do deployment workflows and read authentication for dependencies.
|
|
382
|
-
PR checks, lockfiles, toolchain requirements and `verify-
|
|
757
|
+
PR checks, lockfiles, toolchain requirements and `release verify-protection`
|
|
383
758
|
remain independent of publication intent, including `git.releaseRequiredChecks`.
|
|
384
759
|
|
|
385
760
|
All projects must declare nonblank `author` and `repository` values in
|
|
386
761
|
`package.json`. npm object forms are supported with nonblank `author.name`
|
|
387
762
|
and `repository.url` strings.
|
|
388
|
-
Run `peacekeeper
|
|
763
|
+
Run `peacekeeper project check --explain` for the complete expected
|
|
389
764
|
architecture, requirements, configuration examples, and verification limits.
|
|
390
765
|
The command prints the bundled [formal requirements](src/modules/projects/check-project-requirements.txt),
|
|
391
766
|
which can also be read without a repository or project configuration.
|
|
@@ -401,8 +776,8 @@ Platform-specific `setup.linux.script`, `setup.macos.script`, and
|
|
|
401
776
|
`setup.windows.script` overrides, when present, must start with the same prefix.
|
|
402
777
|
The setup requires Bash and curl, activates or installs Volta, logs tool versions,
|
|
403
778
|
and runs `npm ci` using the package.json pins. It then runs
|
|
404
|
-
`peacekeeper
|
|
405
|
-
`peacekeeper cleanup
|
|
779
|
+
`peacekeeper codex init-worktree --sync-primary` followed by
|
|
780
|
+
`peacekeeper cleanup merged-branches --execute` before any project-specific setup,
|
|
406
781
|
initializing each new linked worktree from the exact commit fetched from the
|
|
407
782
|
configured remote default branch, safely synchronizing the primary checkout, and
|
|
408
783
|
removing merged branches and their linked worktrees.
|
|
@@ -418,8 +793,8 @@ The required sequence ends like this:
|
|
|
418
793
|
script = '''
|
|
419
794
|
# ...the required Peacekeeper setup prefix...
|
|
420
795
|
npm ci
|
|
421
|
-
npm exec --no -- peacekeeper
|
|
422
|
-
npm exec --no -- peacekeeper cleanup
|
|
796
|
+
npm exec --no -- peacekeeper codex init-worktree --sync-primary
|
|
797
|
+
npm exec --no -- peacekeeper cleanup merged-branches --execute
|
|
423
798
|
# Add custom project setup below
|
|
424
799
|
'''
|
|
425
800
|
```
|
|
@@ -435,7 +810,7 @@ completion in the linked worktree's private Git directory, retries interrupted
|
|
|
435
810
|
|
|
436
811
|
## Assess unpublished changes
|
|
437
812
|
|
|
438
|
-
Run `peacekeeper assess
|
|
813
|
+
Run `peacekeeper release assess` (or `npm exec --no -- peacekeeper release assess`)
|
|
439
814
|
from a project using Peacekeeper. A syntactically valid invocation writes one
|
|
440
815
|
pretty-printed JSON object to stdout, with fields ordered as `recommendation`,
|
|
441
816
|
`model`, `releaseSha`, `previousReleaseSha`, and `motivation`:
|
|
@@ -499,7 +874,7 @@ give `noop`; incomplete or ambiguous evidence gives `undetermined`. Codex has
|
|
|
499
874
|
The caller's branch and uncommitted files are preserved. Fetching updates remote
|
|
500
875
|
tracking refs; temporary worktrees and assessment refs are cleaned up afterward.
|
|
501
876
|
The command only recommends a release: it does not change versions, create a PR,
|
|
502
|
-
commit, tag, push, or publish, and it does not change `peacekeeper release`.
|
|
877
|
+
commit, tag, push, or publish, and it does not change `peacekeeper release publish`.
|
|
503
878
|
Codex logs are captured separately from the final JSON. AI assessments can be
|
|
504
879
|
wrong; the result applies to the fetched commit, and callers should reassess if
|
|
505
880
|
the default branch changes before using it.
|
|
@@ -559,10 +934,10 @@ inspection only when GitHub omits them from its response.
|
|
|
559
934
|
Enable `allow_auto_merge` in repository settings: this permits opting in per PR;
|
|
560
935
|
Peacekeeper never enables auto-merge on individual PRs.
|
|
561
936
|
|
|
562
|
-
`check
|
|
563
|
-
`tests.
|
|
937
|
+
`project check` makes no network requests. It runs implicitly before
|
|
938
|
+
`tests.all` or `tests.checkpoint`, including when reusing receipts, and checks that the configured
|
|
564
939
|
PR workflow uses only `pull_request`, with `branches` set to exactly
|
|
565
|
-
`[git.defaultBranch]`, and runs `verify-
|
|
940
|
+
`[git.defaultBranch]`, and runs `release verify-protection` with `GH_TOKEN` after `npm ci` and
|
|
566
941
|
before tests in a job listed in `git.releaseRequiredChecks`. The job and step must
|
|
567
942
|
not skip verification or ignore failures. The online verifier then checks that
|
|
568
943
|
exactly those configured check names are mandatory on GitHub, including its own
|
|
@@ -573,7 +948,7 @@ For example, in a required `test` job:
|
|
|
573
948
|
|
|
574
949
|
```yaml
|
|
575
950
|
- run: npm ci
|
|
576
|
-
- run: peacekeeper verify-
|
|
951
|
+
- run: peacekeeper release verify-protection
|
|
577
952
|
env:
|
|
578
953
|
GH_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
|
|
579
954
|
- run: npm test
|
|
@@ -584,15 +959,15 @@ This creates a local-to-CI chain: missing workflows are detected on the next loc
|
|
|
584
959
|
continuous monitoring. Removing both CI and the local invocation prevents this
|
|
585
960
|
chain from running. No central scheduled audit is required by this setup.
|
|
586
961
|
|
|
587
|
-
The PR test job runs `peacekeeper verify-
|
|
962
|
+
The PR test job runs `peacekeeper release verify-protection` before its tests.
|
|
588
963
|
The command reads the actual default branch from GitHub, regardless of the PR
|
|
589
964
|
base. Other release commands require their configured branch to match it.
|
|
590
|
-
`peacekeeper release` checks the default branch before preparing a release
|
|
965
|
+
`peacekeeper release publish` checks the default branch before preparing a release
|
|
591
966
|
and again immediately before each merge attempt. Before publishing,
|
|
592
|
-
`peacekeeper verify
|
|
967
|
+
`peacekeeper release verify` checks the policy, matching package/tag/lockfile
|
|
593
968
|
versions, a same-repository merged `release/v<version>` PR, and successful required
|
|
594
969
|
jobs in its latest PR workflow run. Manual tags without that PR are rejected.
|
|
595
|
-
`verify-
|
|
970
|
+
`release verify-version` remains available for local version checks alone.
|
|
596
971
|
|
|
597
972
|
API failures, missing permissions, and unverifiable rules stop the commands.
|
|
598
973
|
Bypass actors are the exception when GitHub omits them: policy verification then
|
|
@@ -659,7 +1034,7 @@ configuration compatibility, but no longer selects the default-branch merge meth
|
|
|
659
1034
|
From a clean repository root, run `npm run release -- patch`, `minor`, or `major`.
|
|
660
1035
|
The required `prerelease` script runs `npm ci` first, replacing `node_modules`
|
|
661
1036
|
with the exact dependency versions in the committed lockfile before npm resolves
|
|
662
|
-
and starts Peacekeeper. Always use the npm script; invoking `peacekeeper release`
|
|
1037
|
+
and starts Peacekeeper. Always use the npm script; invoking `peacekeeper release publish`
|
|
663
1038
|
directly bypasses this dependency bootstrap.
|
|
664
1039
|
The command fetches the default branch and uses a temporary detached worktree to
|
|
665
1040
|
increment the package and lockfile versions. Your current branch and local default
|
|
@@ -699,17 +1074,17 @@ normally or with a handled error; a killed process may leave a temporary worktre
|
|
|
699
1074
|
that needs manual cleanup.
|
|
700
1075
|
|
|
701
1076
|
Other npm projects can use this command through package scripts such as
|
|
702
|
-
`"prerelease": "npm ci"` and `"release": "peacekeeper release"`. npm runs the
|
|
1077
|
+
`"prerelease": "npm ci"` and `"release": "peacekeeper release publish"`. npm runs the
|
|
703
1078
|
former automatically before the latter. The project must use a root package
|
|
704
1079
|
with a stable version, a `peacekeeper.config.yaml` with
|
|
705
1080
|
`git.releaseRequiredChecks`, and the supported tag-triggered GitHub Actions
|
|
706
|
-
publish job. Add `peacekeeper verify-
|
|
707
|
-
test job and `peacekeeper verify
|
|
1081
|
+
publish job. Add `peacekeeper release verify-protection` to a required PR
|
|
1082
|
+
test job and `peacekeeper release verify` before publishing, with `GH_TOKEN`
|
|
708
1083
|
and `RELEASE_TAG` set for release verification. Both commands are shipped with
|
|
709
1084
|
the package; no verifier script or artifact upload needs to be copied.
|
|
710
1085
|
Set `git.releaseTestWorkflow` to the PR workflow filename (for this
|
|
711
1086
|
repository: `"test.yml"`). Keep publishing in a separate workflow to satisfy
|
|
712
|
-
`check
|
|
1087
|
+
`project check`'s PR-only trigger policy. All configured check names
|
|
713
1088
|
must be jobs in the selected PR workflow's run.
|
|
714
1089
|
The `publish` job must contain a step whose command is exactly `npm publish`.
|
|
715
1090
|
Its `if` can be omitted when the workflow triggers only on pushes of
|
|
@@ -719,10 +1094,10 @@ For combined workflows or other triggers, the job must use the exact condition
|
|
|
719
1094
|
Explicit alternative job conditions are not supported. Workspaces are not supported.
|
|
720
1095
|
|
|
721
1096
|
Configuration migration: previously optional fields must now be declared. Run
|
|
722
|
-
`peacekeeper update-config`, review the inserted defaults, and commit the result.
|
|
1097
|
+
`peacekeeper project update-config`, review the inserted defaults, and commit the result.
|
|
723
1098
|
The default `git.checkpointPushRemotes` value publishes to `origin`; use an
|
|
724
1099
|
explicit empty array to keep checkpoint branches local. Empty
|
|
725
1100
|
`git.releaseRequiredChecks` is valid configuration but blocks release
|
|
726
|
-
policy verification; empty `tests.
|
|
1101
|
+
policy verification; empty `tests.all` blocks test execution and receipts.
|
|
727
1102
|
`projectChecks` always explicitly selects the workflow and jobs. This change does
|
|
728
|
-
not add online GitHub verification to `check
|
|
1103
|
+
not add online GitHub verification to `project check`.
|