@jakobm/peacekeeper 0.26.0 → 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 +294 -98
- package/dist/cmdabra.yaml +174 -116
- package/dist/package.json +5 -5
- package/dist/src/modules/cli/legacy-commands.js +37 -0
- package/dist/src/modules/cli/service.js +48 -40
- package/dist/src/modules/configuration/facade.js +1 -0
- package/dist/src/modules/configuration/project-config-defaults.json +2 -1
- package/dist/src/modules/configuration/project-config.js +20 -8
- package/dist/src/modules/configuration/update-config.js +16 -2
- package/dist/src/modules/dependencies.yaml +1 -1
- 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-test-receipt.js +17 -22
- 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 +5 -5
|
@@ -89,7 +89,7 @@ export default ({ external: { execFileSync, fs, output, path, runtime, } }) => {
|
|
|
89
89
|
log(`Would remove ${directory}`);
|
|
90
90
|
log('');
|
|
91
91
|
log('To remove these directories, run:');
|
|
92
|
-
log(' npm exec --no -- peacekeeper
|
|
92
|
+
log(' npm exec --no -- peacekeeper cleanup empty-directories --execute');
|
|
93
93
|
}
|
|
94
94
|
function main({ execute = false } = {}) {
|
|
95
95
|
try {
|
|
@@ -5,7 +5,7 @@ Purpose and scope
|
|
|
5
5
|
lifecycle hooks, and runs reproducible PR checks. Published npm packages also
|
|
6
6
|
verify a release before publishing the tested version.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
project check reads local files at the Git root. It makes no network requests,
|
|
9
9
|
runs no project scripts, and changes no files. Failure exits with status 1.
|
|
10
10
|
Independent failures are reported together. Missing or unreadable prerequisites
|
|
11
11
|
can block dependent checks; the reported failures are not an exhaustive list
|
|
@@ -16,9 +16,10 @@ Project configuration
|
|
|
16
16
|
package.json is required at the Git root. Without peacekeeper.config.yaml,
|
|
17
17
|
bundled defaults apply. An existing configuration must declare every schema
|
|
18
18
|
field, including nested fields; unknown fields and invalid values fail.
|
|
19
|
-
Run peacekeeper update-config to create or complete it without overwriting
|
|
20
|
-
existing values.
|
|
21
|
-
|
|
19
|
+
Run peacekeeper project update-config to create or complete it without overwriting
|
|
20
|
+
existing values. Migrate tests.commands to tests.all and add tests.checkpoint
|
|
21
|
+
as an empty list. Review inserted defaults. Empty tests.all blocks tests
|
|
22
|
+
and receipts. Help, --explain and project update-config bypass completeness checking.
|
|
22
23
|
|
|
23
24
|
projectChecks.testWorkflow selects the PR workflow filename.
|
|
24
25
|
projectChecks.requiredJobs selects required job names.
|
|
@@ -42,7 +43,7 @@ Project configuration
|
|
|
42
43
|
|
|
43
44
|
git.requiredApprover must identify the personal GitHub account that owns the
|
|
44
45
|
repository. Its bundled default is null so migrations must choose explicitly.
|
|
45
|
-
|
|
46
|
+
project check requires .github/CODEOWNERS to contain exactly one non-comment
|
|
46
47
|
rule matching that account:
|
|
47
48
|
* @OWNER
|
|
48
49
|
Additional ownership patterns or owners are rejected because GitHub accepts
|
|
@@ -102,7 +103,7 @@ Codex lifecycle hooks
|
|
|
102
103
|
.codex/hooks.json must contain the current peacekeeper hooks exactly once
|
|
103
104
|
for each lifecycle event, in their expected order, without group conditions.
|
|
104
105
|
Unrelated hooks are allowed. Repair with:
|
|
105
|
-
peacekeeper install-hooks
|
|
106
|
+
peacekeeper codex install-hooks
|
|
106
107
|
Hook installation does not itself grant Codex trust.
|
|
107
108
|
|
|
108
109
|
All GitHub Actions workflows
|
|
@@ -172,7 +173,7 @@ Required PR workflow and jobs
|
|
|
172
173
|
GitHub check contexts and branch protection still need online verification.
|
|
173
174
|
|
|
174
175
|
If any matrix leg fails or is cancelled, the dependent test gate is normally
|
|
175
|
-
skipped, not failed.
|
|
176
|
+
skipped, not failed. release verify requires each configured release job to
|
|
176
177
|
conclude success, so a skipped gate blocks publication (even if the overall
|
|
177
178
|
workflow conclusion were success).
|
|
178
179
|
|
|
@@ -185,7 +186,7 @@ Required PR workflow and jobs
|
|
|
185
186
|
names in that setting. Alternatively, use separate static required jobs for
|
|
186
187
|
each platform and list all of them in git.releaseRequiredChecks. A gate using
|
|
187
188
|
always() to fail explicitly on failed dependencies is not currently accepted
|
|
188
|
-
by check
|
|
189
|
+
by project check's required-job condition rules.
|
|
189
190
|
|
|
190
191
|
Publication: publishesToNpm=true
|
|
191
192
|
package.json version must be exact and stable (no prerelease). Commit a
|
|
@@ -199,13 +200,13 @@ Publication: publishesToNpm=true
|
|
|
199
200
|
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
|
|
200
201
|
The publish job must not allow failure.
|
|
201
202
|
|
|
202
|
-
In publish steps, run unconditional npm ci, then unconditional verify
|
|
203
|
+
In publish steps, run unconditional npm ci, then unconditional release verify,
|
|
203
204
|
then npm publish. Neither install nor verification may allow failure.
|
|
204
205
|
Accepted direct verification commands:
|
|
205
|
-
peacekeeper verify
|
|
206
|
-
npm exec --no -- peacekeeper verify
|
|
207
|
-
node dist/bin/peacekeeper.js verify
|
|
208
|
-
node node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js verify
|
|
206
|
+
peacekeeper release verify
|
|
207
|
+
npm exec --no -- peacekeeper release verify
|
|
208
|
+
node dist/bin/peacekeeper.js release verify
|
|
209
|
+
node node_modules/@jakobm/peacekeeper/dist/bin/peacekeeper.js release verify
|
|
209
210
|
The node paths may also start with ./.
|
|
210
211
|
|
|
211
212
|
Verification must receive these environment inputs, directly on the step or
|
|
@@ -218,9 +219,9 @@ Publication: publishesToNpm=true
|
|
|
218
219
|
contents: write is also accepted. The same toolchain rules apply to publishing.
|
|
219
220
|
|
|
220
221
|
Publication intent comes only from the mandatory boolean publishesToNpm.
|
|
221
|
-
Its bundled default is false. update-config inserts false even if existing
|
|
222
|
+
Its bundled default is false. project update-config inserts false even if existing
|
|
222
223
|
package metadata looks publishable; explicitly select true when migrating.
|
|
223
|
-
A missing field in an existing configuration fails check
|
|
224
|
+
A missing field in an existing configuration fails project check.
|
|
224
225
|
|
|
225
226
|
With true, package.json private must be absent or false. Require a valid npm
|
|
226
227
|
name, nonblank description and license, nonempty files list, and publishConfig
|
|
@@ -228,8 +229,8 @@ Publication: publishesToNpm=true
|
|
|
228
229
|
scripts.prerelease must be exactly npm ci. npm runs it before scripts.release,
|
|
229
230
|
so release starts with the dependency versions committed in the lockfile even
|
|
230
231
|
when node_modules was installed before the latest pull. scripts.release must
|
|
231
|
-
directly invoke peacekeeper release (also supported: npm exec --no --
|
|
232
|
-
peacekeeper release or the local Node CLI forms). Run releases through
|
|
232
|
+
directly invoke peacekeeper release publish (also supported: npm exec --no --
|
|
233
|
+
peacekeeper release publish or the local Node CLI forms). Run releases through
|
|
233
234
|
npm run release so npm does not bypass the prerelease installation.
|
|
234
235
|
The selected PR workflow must declare an unconditional packaging check after
|
|
235
236
|
npm ci: npm pack (optionally
|
|
@@ -241,19 +242,19 @@ Publication: publishesToNpm=true
|
|
|
241
242
|
authentication needed by private dependencies to the npm ci step.
|
|
242
243
|
|
|
243
244
|
With false, require private: true and reject publishConfig, files, npm
|
|
244
|
-
publication/release scripts,
|
|
245
|
+
publication/release scripts, release verify steps and npm-publish actions.
|
|
245
246
|
Scan command lists and npm script aliases; arbitrary shell wrappers, reusable
|
|
246
247
|
workflows and external scripts cannot be fully inspected. Remove dedicated
|
|
247
248
|
publishing credentials and npm trusted-publisher registration separately.
|
|
248
249
|
Internal packing, prepack/build scripts, main/exports/types/bin, deployment
|
|
249
250
|
workflows, OIDC for other services, and dependency read authentication remain
|
|
250
251
|
allowed. Workflow filenames and job names alone do not imply npm publication.
|
|
251
|
-
Toolchain, hooks, PR checks and verify-
|
|
252
|
+
Toolchain, hooks, PR checks and release verify-protection still apply.
|
|
252
253
|
|
|
253
254
|
Online release policy and GitHub token setup
|
|
254
|
-
These are online installation requirements;
|
|
255
|
-
local declarations above. Use verify-
|
|
256
|
-
policy and
|
|
255
|
+
These are online installation requirements; project check only verifies the
|
|
256
|
+
local declarations above. Use release verify-protection to check the branch
|
|
257
|
+
policy and release verify before publishing to check the release itself.
|
|
257
258
|
|
|
258
259
|
Enable "Automatically delete head branches" (delete_branch_on_merge=true) in
|
|
259
260
|
the repository settings. The online release policy commands require it.
|
|
@@ -298,8 +299,8 @@ Online release policy and GitHub token setup
|
|
|
298
299
|
Fork PRs do not receive repository secrets; do not expose this token by
|
|
299
300
|
running fork code with pull_request_target.
|
|
300
301
|
|
|
301
|
-
verify-
|
|
302
|
-
PR CI. It can be run before tests in a required trusted PR job. verify
|
|
302
|
+
release verify-protection uses GITHUB_BASE_REF, or git.defaultBranch outside
|
|
303
|
+
PR CI. It can be run before tests in a required trusted PR job. release verify
|
|
303
304
|
checks matching package/tag/lockfile versions, that the tagged commit belongs
|
|
304
305
|
to the default branch and is the merge commit of a same-repository merged
|
|
305
306
|
release/v<version> PR, and the latest selected PR workflow run and required
|
|
@@ -361,7 +362,7 @@ Complete npm trusted-publishing example with Volta
|
|
|
361
362
|
env:
|
|
362
363
|
GH_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
|
|
363
364
|
RELEASE_TAG: ${{ github.ref_name }}
|
|
364
|
-
run: npm exec --no -- peacekeeper verify
|
|
365
|
+
run: npm exec --no -- peacekeeper release verify
|
|
365
366
|
- run: npm publish
|
|
366
367
|
|
|
367
368
|
Volta selects the pinned tools and its registry-url input configures npm's
|
|
@@ -375,7 +376,7 @@ Complete npm trusted-publishing example with Volta
|
|
|
375
376
|
publishing does not authenticate dependency installation. Add any necessary
|
|
376
377
|
build step before publication, keeping npm publish as its own direct step.
|
|
377
378
|
|
|
378
|
-
|
|
379
|
+
project check verifies supported local workflow structure, not the npm OIDC
|
|
379
380
|
minimum versions, trusted-publisher registration, package visibility, registry
|
|
380
381
|
credentials, or actual publishing access. Verify those external settings too.
|
|
381
382
|
Upstream references for provider-specific setup and changing prerequisites:
|
|
@@ -389,19 +390,19 @@ What a passing check does and does not establish
|
|
|
389
390
|
installed dependency versions, or check Git remotes and ignored files.
|
|
390
391
|
It cannot confirm actual GitHub branch protection, token/secret access,
|
|
391
392
|
successful workflow runs, or npm trusted publisher configuration. Those need
|
|
392
|
-
online verification;
|
|
393
|
+
online verification; release verify handles the release checks it supports.
|
|
393
394
|
|
|
394
395
|
Using this check in the test chain
|
|
395
|
-
run
|
|
396
|
-
tests.
|
|
397
|
-
Explicit
|
|
396
|
+
test run always runs project check as an implicit first step before
|
|
397
|
+
tests.all or tests.checkpoint, including when command receipts skip execution.
|
|
398
|
+
Explicit project check invocations in either test list are rejected as redundant
|
|
398
399
|
because the runner always includes this step automatically. Supported direct
|
|
399
400
|
peacekeeper, npm exec, npx and node CLI forms are checked, including commands
|
|
400
401
|
separated by shell control operators. Failure stops the run and invalidates any
|
|
401
402
|
existing receipt. This check remains entirely local.
|
|
402
403
|
|
|
403
404
|
Default-branch GitHub policy chain
|
|
404
|
-
The configured PR workflow must run verify-
|
|
405
|
+
The configured PR workflow must run release verify-protection with step GH_TOKEN
|
|
405
406
|
after npm ci and before tests in at least one job in git.releaseRequiredChecks.
|
|
406
407
|
Verification must be unconditional and must not allow failure. The existing
|
|
407
408
|
required-job validation applies to that job and its dependencies.
|
|
@@ -18,7 +18,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
18
18
|
}
|
|
19
19
|
const testCommand = /^npm (?:test|run test(?::[\w-]+)?|pack --dry-run(?: --json)?)$/u;
|
|
20
20
|
const installCommand = /^npm ci$/u;
|
|
21
|
-
const verifyCommand = /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) verify-release$/u;
|
|
21
|
+
const verifyCommand = /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) (?:release verify|verify-release)$/u;
|
|
22
22
|
function checkProject(cwd = runtime.cwd()) {
|
|
23
23
|
const config = projectConfig(cwd);
|
|
24
24
|
const root = config.root;
|
|
@@ -44,9 +44,11 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
check('tests', () => {
|
|
47
|
-
const projectCheck = /(?:^|&&|\|\||;|\n)\s*(?:peacekeeper|npm\s+exec\s+--no\s+--\s+peacekeeper|npx\s+--no-install\s+peacekeeper|node\s+(?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?bin\/peacekeeper\.js)\s+check-project(?=\s|$|;|&|\|)/u;
|
|
48
|
-
for (const [
|
|
49
|
-
|
|
47
|
+
const projectCheck = /(?:^|&&|\|\||;|\n)\s*(?:peacekeeper|npm\s+exec\s+--no\s+--\s+peacekeeper|npx\s+--no-install\s+peacekeeper|node\s+(?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js)\s+(?:project\s+check|check-project)(?=\s|$|;|&|\|)/u;
|
|
48
|
+
for (const level of ['all', 'checkpoint']) {
|
|
49
|
+
for (const [index, command] of config.tests[level].entries()) {
|
|
50
|
+
requireThat(!projectCheck.test(command), `tests.${level}[${index}]: remove project check; it is redundant because Peacekeeper always includes it automatically before the configured test commands, even when reusing a test receipt.`);
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
check('package', () => {
|
|
@@ -60,10 +62,8 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
60
62
|
if (typeof approver !== 'string')
|
|
61
63
|
return;
|
|
62
64
|
const file = '.github/CODEOWNERS';
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
.filter(line => line && !line.startsWith('#'));
|
|
66
|
-
requireThat(isDeepStrictEqual(lines, [`* @${approver}`]), `${file}: use exactly one ownership rule, "* @${approver}", so only git.requiredApprover can satisfy required code-owner review.`);
|
|
65
|
+
const error = configuration.codeownersError(read(root, file, value => value), approver);
|
|
66
|
+
requireThat(!error, error || '');
|
|
67
67
|
});
|
|
68
68
|
const workflows = new Map();
|
|
69
69
|
check('CI', () => {
|
|
@@ -170,14 +170,14 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
170
170
|
requireThat(Object.keys(group).every(key => key === 'hooks'), '.codex/hooks.json: peacekeeper lifecycle hooks must not have group conditions.');
|
|
171
171
|
return handlers;
|
|
172
172
|
});
|
|
173
|
-
requireThat(isDeepStrictEqual(owned(document.hooks?.[event] || []), owned(expected.hooks[event] || [])), `.codex/hooks.json: missing, duplicate or outdated ${event} lifecycle hooks; run peacekeeper install-hooks.`);
|
|
173
|
+
requireThat(isDeepStrictEqual(owned(document.hooks?.[event] || []), owned(expected.hooks[event] || [])), `.codex/hooks.json: missing, duplicate or outdated ${event} lifecycle hooks; run peacekeeper codex install-hooks.`);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
const published = config.publishesToNpm;
|
|
177
177
|
check('publication', () => {
|
|
178
178
|
const nonblank = value => typeof value === 'string' && value.trim().length > 0;
|
|
179
179
|
const scripts = manifest.scripts || {};
|
|
180
|
-
const releaseCommand = /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) release
|
|
180
|
+
const releaseCommand = /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) release(?: publish)?$/u;
|
|
181
181
|
// Resolve npm script aliases without executing project code. Cycles stop here.
|
|
182
182
|
function commands(command, seen = new Set()) {
|
|
183
183
|
if (typeof command !== 'string')
|
|
@@ -201,7 +201,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
201
201
|
&& ['public', 'restricted'].includes(manifest.publishConfig?.access), 'package.json: publishConfig must declare registry https://registry.npmjs.org/ and access public or restricted.');
|
|
202
202
|
requireThat(Array.isArray(manifest.files) && manifest.files.length > 0 && manifest.files.every(nonblank), 'package.json: published packages require a nonempty files list.');
|
|
203
203
|
requireThat(typeof scripts.prerelease === 'string' && scripts.prerelease.trim() === 'npm ci', 'package.json: scripts.prerelease must be exactly npm ci so release uses the locked dependencies.');
|
|
204
|
-
requireThat(typeof scripts.release === 'string' && releaseCommand.test(scripts.release.trim()), 'package.json: scripts.release must invoke peacekeeper release directly.');
|
|
204
|
+
requireThat(typeof scripts.release === 'string' && releaseCommand.test(scripts.release.trim()), 'package.json: scripts.release must invoke peacekeeper release publish directly.');
|
|
205
205
|
const testWorkflow = workflows.get(config.projectChecks.testWorkflow);
|
|
206
206
|
requireThat(testWorkflow && Object.values(testWorkflow.jobs).some((rawJob) => {
|
|
207
207
|
const job = rawJob;
|
|
@@ -262,7 +262,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
262
262
|
const steps = job.steps || [];
|
|
263
263
|
const installed = steps.findIndex(step => directCommand(step, installCommand) && unconditional(step.if) && !step['continue-on-error']);
|
|
264
264
|
const tested = steps.findIndex(step => directCommand(step, testCommand) && unconditional(step.if) && !step['continue-on-error']);
|
|
265
|
-
const policy = steps.findIndex(step => directCommand(step, /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) verify-release-protection$/u)
|
|
265
|
+
const policy = steps.findIndex(step => directCommand(step, /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) (?:release verify-protection|verify-release-protection)$/u)
|
|
266
266
|
&& unconditional(step.if) && !step['continue-on-error'] && step.env?.GH_TOKEN);
|
|
267
267
|
if (policy > installed && installed >= 0 && policy < tested && config.git.releaseRequiredChecks.includes(job.name || id))
|
|
268
268
|
policyJobs += 1;
|
|
@@ -277,7 +277,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
277
277
|
checked.clear();
|
|
278
278
|
requiredJob(...matching[0], true);
|
|
279
279
|
}
|
|
280
|
-
requireThat(policyJobs > 0, `${filename}: a job in git.releaseRequiredChecks must run unconditional verify-
|
|
280
|
+
requireThat(policyJobs > 0, `${filename}: a job in git.releaseRequiredChecks must run unconditional release verify-protection with GH_TOKEN after npm ci and before tests.`);
|
|
281
281
|
});
|
|
282
282
|
if (published)
|
|
283
283
|
check('publication', () => {
|
|
@@ -306,9 +306,9 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
306
306
|
requireThat(publish >= 0 && unconditional(steps[publish].if) && !steps[publish]['continue-on-error'], `${publishing.path}: npm publish must be unconditional and must not allow failure.`);
|
|
307
307
|
const publishEnvironment = { ...workflow.env, ...job.env, ...steps[publish]?.env };
|
|
308
308
|
requireThat(!['NPM_TOKEN', 'NODE_AUTH_TOKEN'].some(key => Object.hasOwn(publishEnvironment, key)), `${publishing.path}: remove npm publishing tokens from the publish step; use OIDC. Scope private dependency read authentication to npm ci.`);
|
|
309
|
-
requireThat(installed >= 0 && verify > installed && verify < publish && unconditional(steps[verify].if) && !steps[verify]['continue-on-error'], `${publishing.path}: run
|
|
309
|
+
requireThat(installed >= 0 && verify > installed && verify < publish && unconditional(steps[verify].if) && !steps[verify]['continue-on-error'], `${publishing.path}: run release verify unconditionally before npm publish.`);
|
|
310
310
|
const environment = { ...workflow.env, ...job.env, ...steps[verify]?.env };
|
|
311
|
-
requireThat(environment.RELEASE_TAG === '${{ github.ref_name }}' && environment.GH_TOKEN, `${publishing.path}:
|
|
311
|
+
requireThat(environment.RELEASE_TAG === '${{ github.ref_name }}' && environment.GH_TOKEN, `${publishing.path}: release verify needs RELEASE_TAG from github.ref_name and GH_TOKEN.`);
|
|
312
312
|
const permissions = job.permissions || workflow.permissions;
|
|
313
313
|
requireThat(permissions && permissions['id-token'] === 'write' && ['read', 'write'].includes(permissions.contents), `${publishing.path}: declare contents: read and id-token: write for publishing.`);
|
|
314
314
|
const selected = config.git.releaseTestWorkflow;
|
|
@@ -321,7 +321,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
321
321
|
runtime.stdout.write(fs.readFileSync(path.join(modulesRoot, 'projects/check-project-requirements.txt'), 'utf8'));
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
|
-
output.log('Run peacekeeper
|
|
324
|
+
output.log('Run peacekeeper project check --explain for the complete expected project architecture and requirements.');
|
|
325
325
|
const { errors, published } = checkProject();
|
|
326
326
|
if (errors.length) {
|
|
327
327
|
for (const error of errors)
|
|
@@ -19,7 +19,7 @@ npm --version
|
|
|
19
19
|
npm ci
|
|
20
20
|
|
|
21
21
|
# Initialize the linked worktree and safely synchronize the primary checkout.
|
|
22
|
-
npm exec --no -- peacekeeper
|
|
23
|
-
npm exec --no -- peacekeeper cleanup
|
|
22
|
+
npm exec --no -- peacekeeper codex init-worktree --sync-primary
|
|
23
|
+
npm exec --no -- peacekeeper cleanup merged-branches --execute
|
|
24
24
|
|
|
25
25
|
# Add custom project setup below
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export default ({ installHooks,
|
|
1
|
+
export default ({ installHooks, external: { fs, modulesRoot, packageVersion, path, projectConfigDefaults, runtime, spawnSync, url: Url, YAML, } }) => {
|
|
2
2
|
const { planHooks } = installHooks;
|
|
3
|
-
const { createGithubPolicy, githubSetupPlan } = releases;
|
|
4
3
|
const TOOLCHAIN = Object.freeze({
|
|
5
4
|
node: '22.14.0',
|
|
6
5
|
npm: '11.21.0',
|
|
@@ -64,10 +63,10 @@ export default ({ installHooks, releases, external: { fs, modulesRoot, packageVe
|
|
|
64
63
|
fs.writeFileSync(target, contents, { mode });
|
|
65
64
|
}
|
|
66
65
|
function workflow(published) {
|
|
67
|
-
return `name: Test\n\non:\n pull_request:\n branches: [main]\n\npermissions:\n contents: read\n\njobs:\n test:\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - name: Verify strict release policy\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n run: npm exec --no -- peacekeeper verify-
|
|
66
|
+
return `name: Test\n\non:\n pull_request:\n branches: [main]\n\npermissions:\n contents: read\n\njobs:\n test:\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - name: Verify strict release policy\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n run: npm exec --no -- peacekeeper release verify-protection\n - run: npm test\n${published ? `\n package:\n name: Test package\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - run: npm run test:package\n` : ''}`;
|
|
68
67
|
}
|
|
69
68
|
function publishWorkflow() {
|
|
70
|
-
return `name: Publish\n\non:\n push:\n tags: ['v*']\n\npermissions:\n contents: read\n\njobs:\n publish:\n name: Publish to npm\n runs-on: ubuntu-24.04\n permissions:\n contents: read\n actions: read\n pull-requests: read\n id-token: write\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n with:\n registry-url: https://registry.npmjs.org\n - run: npm ci\n - name: Verify release\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n RELEASE_TAG: \${{ github.ref_name }}\n run: npm exec --no -- peacekeeper verify
|
|
69
|
+
return `name: Publish\n\non:\n push:\n tags: ['v*']\n\npermissions:\n contents: read\n\njobs:\n publish:\n name: Publish to npm\n runs-on: ubuntu-24.04\n permissions:\n contents: read\n actions: read\n pull-requests: read\n id-token: write\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n with:\n registry-url: https://registry.npmjs.org\n - run: npm ci\n - name: Verify release\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n RELEASE_TAG: \${{ github.ref_name }}\n run: npm exec --no -- peacekeeper release verify\n - run: npm publish\n`;
|
|
71
70
|
}
|
|
72
71
|
function renderTemplate(filename, replacements) {
|
|
73
72
|
let template = fs.readFileSync(path.join(modulesRoot, `projects/${filename}`), 'utf8');
|
|
@@ -81,27 +80,13 @@ export default ({ installHooks, releases, external: { fs, modulesRoot, packageVe
|
|
|
81
80
|
return template.trim();
|
|
82
81
|
}
|
|
83
82
|
function githubSetup(repositories) {
|
|
84
|
-
const prefix = renderTemplate('github-setup-prefix.sh', {});
|
|
85
|
-
const configured = repositories.map(({ owner, repositoryName,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
catch (error) {
|
|
92
|
-
throw new Error(`GitHub setup for ${owner}/${repositoryName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
-
}
|
|
94
|
-
return renderTemplate('github-setup-repository-template.sh', {
|
|
95
|
-
OWNER: shellSingleQuotedContent(owner),
|
|
96
|
-
REPOSITORY_NAME: shellSingleQuotedContent(repositoryName),
|
|
97
|
-
DEFAULT_BRANCH: shellSingleQuotedContent(plan.branchPath),
|
|
98
|
-
REPOSITORY_PATCH_ARGUMENTS: plan.repositoryPatchArguments,
|
|
99
|
-
BASE_RULESET: plan.baseRuleset,
|
|
100
|
-
APPROVAL_RULESET: plan.approvalRuleset,
|
|
101
|
-
REQUIRED_APPROVER: shellSingleQuotedContent(requiredApprover),
|
|
102
|
-
REQUIRED_APPROVER_LOWER: shellSingleQuotedContent(requiredApprover.toLowerCase()),
|
|
103
|
-
});
|
|
104
|
-
});
|
|
83
|
+
const prefix = renderTemplate('github-setup-prefix.sh', { VERSION: shellSingleQuotedContent(packageVersion) });
|
|
84
|
+
const configured = repositories.map(({ owner, repositoryName, policyPr, sourceRef }) => renderTemplate('github-setup-repository-template.sh', {
|
|
85
|
+
REPOSITORY: shellSingleQuotedContent(`${owner}/${repositoryName}`),
|
|
86
|
+
PLAN_NAME: shellSingleQuotedContent(`${owner}--${repositoryName}.json`),
|
|
87
|
+
POLICY_PR: shellSingleQuotedContent(policyPr === undefined ? '' : String(policyPr)),
|
|
88
|
+
SOURCE_REF: shellSingleQuotedContent(sourceRef || ''),
|
|
89
|
+
}));
|
|
105
90
|
const argumentsValue = repositories
|
|
106
91
|
.map(({ owner, repositoryName }) => `--new-repo ${shellLiteral(`${owner}/${repositoryName}`)}`)
|
|
107
92
|
.join(' ');
|
|
@@ -126,8 +111,8 @@ export default ({ installHooks, releases, external: { fs, modulesRoot, packageVe
|
|
|
126
111
|
repository: { type: 'git', url: `git+${options.repository}` }, license: 'MIT',
|
|
127
112
|
engines: { node: '>=20' }, volta: { node: TOOLCHAIN.node, npm: TOOLCHAIN.npm },
|
|
128
113
|
main: './dist/index.js', types: './dist/index.d.ts', exports: { '.': { types: './dist/index.d.ts', import: './dist/index.js' } },
|
|
129
|
-
scripts: { build: 'tsc -p tsconfig.json', prepare: 'npm run build', typecheck: 'tsc -p tsconfig.json --noEmit', test: 'peacekeeper run
|
|
130
|
-
...(options.published ? { 'test:package': 'node scripts/test-package.cjs', prerelease: 'npm ci', release: 'peacekeeper release' } : {}) },
|
|
114
|
+
scripts: { build: 'tsc -p tsconfig.json', prepare: 'npm run build', typecheck: 'tsc -p tsconfig.json --noEmit', test: 'peacekeeper test run', 'test:unit': 'node --test test/*.test.js',
|
|
115
|
+
...(options.published ? { 'test:package': 'node scripts/test-package.cjs', prerelease: 'npm ci', release: 'peacekeeper release publish' } : {}) },
|
|
131
116
|
devDependencies: { '@jakobm/peacekeeper': version, '@types/node': TOOLCHAIN.nodeTypes, typescript: TOOLCHAIN.typescript },
|
|
132
117
|
...(options.published ? { files: ['dist/'], publishConfig: { access: 'public', registry: 'https://registry.npmjs.org/' } } : {}),
|
|
133
118
|
};
|
|
@@ -140,7 +125,7 @@ export default ({ installHooks, releases, external: { fs, modulesRoot, packageVe
|
|
|
140
125
|
const defaults = JSON.parse(JSON.stringify(projectConfigDefaults));
|
|
141
126
|
defaults.publishesToNpm = options.published;
|
|
142
127
|
defaults.git.requiredApprover = options.owner;
|
|
143
|
-
defaults.tests.
|
|
128
|
+
defaults.tests.all = ['npm run typecheck', 'npm run build', 'npm run test:unit', ...(options.published ? ['npm run test:package'] : [])];
|
|
144
129
|
defaults.tests.npmTestUsesRunner = true;
|
|
145
130
|
write(root, 'peacekeeper.config.yaml', YAML.stringify(defaults, { lineWidth: 0 }));
|
|
146
131
|
write(root, '.codex/hooks.json', json(planHooks({}).document));
|
|
@@ -1,59 +1,20 @@
|
|
|
1
|
-
export default ({
|
|
2
|
-
|
|
3
|
-
const { githubSetup, repositoryIdentity } = createProjectCore;
|
|
4
|
-
function api(endpoint, missingAllowed = false) {
|
|
5
|
-
const response = spawnSync('gh', ['api', '--hostname', 'github.com', '--method', 'GET', endpoint], {
|
|
6
|
-
encoding: 'utf8',
|
|
7
|
-
});
|
|
8
|
-
if (response.status === 0) {
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(response.stdout);
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
throw new Error(`GitHub returned invalid JSON for ${endpoint}.`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (missingAllowed && /HTTP 404\b/u.test(response.stderr || ''))
|
|
17
|
-
return undefined;
|
|
18
|
-
throw new Error(`Cannot read GitHub configuration (${endpoint}): ${response.error?.message
|
|
19
|
-
|| response.stderr?.trim() || `exit ${response.status}`}`);
|
|
20
|
-
}
|
|
21
|
-
function loadRepositorySetup(repository) {
|
|
22
|
-
const identity = repositoryIdentity(repository);
|
|
23
|
-
const slug = `${identity.owner}/${identity.repositoryName}`;
|
|
24
|
-
const metadata = api(`repos/${slug}`);
|
|
25
|
-
if (typeof metadata?.default_branch !== 'string' || !metadata.default_branch) {
|
|
26
|
-
throw new Error(`GitHub did not return a default branch for ${slug}.`);
|
|
27
|
-
}
|
|
28
|
-
const endpoint = `repos/${slug}/contents/peacekeeper.config.yaml?ref=${encodeURIComponent(metadata.default_branch)}`;
|
|
29
|
-
const file = api(endpoint, true);
|
|
30
|
-
let config;
|
|
31
|
-
if (file === undefined) {
|
|
32
|
-
const legacyEndpoint = `repos/${slug}/contents/peacekeeper.config.json?ref=${encodeURIComponent(metadata.default_branch)}`;
|
|
33
|
-
if (api(legacyEndpoint, true) !== undefined) {
|
|
34
|
-
throw new Error(`${slug}/peacekeeper.config.json: rename this legacy JSON configuration to peacekeeper.config.yaml and convert it to YAML.`);
|
|
35
|
-
}
|
|
36
|
-
config = structuredClone(projectConfigDefaults);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (file.type !== 'file' || file.encoding !== 'base64' || typeof file.content !== 'string') {
|
|
40
|
-
throw new Error(`${slug}/peacekeeper.config.yaml: GitHub returned invalid file contents.`);
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
config = YAML.parse(Buffer.from(file.content, 'base64').toString('utf8'));
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
throw new Error(`${slug}/peacekeeper.config.yaml: ${error instanceof Error ? error.message : String(error)}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
validateConfig(config, `${slug}/peacekeeper.config.yaml`);
|
|
50
|
-
return { ...identity, requiredChecks: config.git.releaseRequiredChecks,
|
|
51
|
-
requiredApprover: config.git.requiredApprover || identity.owner,
|
|
52
|
-
defaultBranch: metadata.default_branch };
|
|
53
|
-
}
|
|
54
|
-
function run({ repository: repositories }) {
|
|
1
|
+
export default ({ createProjectCore, releases, external: { runtime } }) => {
|
|
2
|
+
function run({ repository: repositories, policyPr, sourceRef }) {
|
|
55
3
|
try {
|
|
56
|
-
|
|
4
|
+
if (repositories.length !== 1 && (policyPr !== undefined || sourceRef !== undefined)) {
|
|
5
|
+
throw new Error('--policy-pr and --source-ref require exactly one --repository. Generate separate wrappers for different policy sources.');
|
|
6
|
+
}
|
|
7
|
+
const sources = repositories.map(repository => {
|
|
8
|
+
const identity = createProjectCore.repositoryIdentity(repository);
|
|
9
|
+
const plan = releases.planGithub({ repository: `${identity.owner}/${identity.repositoryName}`, policyPr, sourceRef });
|
|
10
|
+
if (plan.blockers.length)
|
|
11
|
+
throw new Error(`${repository}: ${plan.blockers.join('; ')}`);
|
|
12
|
+
return { ...identity, sourceRef: plan.source.sha, policyPr: plan.source.policyPr };
|
|
13
|
+
});
|
|
14
|
+
const slugs = sources.map(source => `${source.owner}/${source.repositoryName}`.toLowerCase());
|
|
15
|
+
if (new Set(slugs).size !== slugs.length)
|
|
16
|
+
throw new Error('Each repository may be specified only once.');
|
|
17
|
+
runtime.stdout.write(createProjectCore.githubSetup(sources));
|
|
57
18
|
}
|
|
58
19
|
catch (error) {
|
|
59
20
|
runtime.stderr.write(`Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
|
|
4
|
+
# Run this script with a plan directory to review and save the GitHub changes.
|
|
5
|
+
# Run it again with --execute and the same directory to apply those saved plans.
|
|
6
|
+
# Review deletions carefully: protection on other branches will be removed.
|
|
7
|
+
mode=plan
|
|
8
|
+
if [[ "${1:-}" == --execute ]]; then
|
|
9
|
+
mode=execute
|
|
10
|
+
shift
|
|
11
|
+
fi
|
|
12
|
+
if [[ $# != 1 || -z "$1" ]]; then
|
|
13
|
+
printf 'Usage: %s [--execute] PLAN_DIRECTORY\n' "$0" >&2
|
|
14
|
+
exit 2
|
|
15
|
+
fi
|
|
16
|
+
plan_directory=$1
|
|
17
|
+
if [[ "$mode" == plan ]]; then
|
|
18
|
+
mkdir -p -- "$plan_directory"
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
configure_repository() {
|
|
22
|
+
local repository=$1 plan_name=$2 policy_pr=$3 source_ref=$4
|
|
23
|
+
local args=(github configure --plan-file "$plan_directory/$plan_name")
|
|
24
|
+
if [[ "$mode" == execute ]]; then
|
|
25
|
+
args+=(--execute --repository "$repository")
|
|
26
|
+
else
|
|
27
|
+
args+=(--repository "$repository")
|
|
28
|
+
if [[ -n "$policy_pr" ]]; then args+=(--policy-pr "$policy_pr"); fi
|
|
29
|
+
if [[ -n "$source_ref" ]]; then args+=(--source-ref "$source_ref"); fi
|
|
30
|
+
fi
|
|
31
|
+
npm exec --yes --package '@jakobm/peacekeeper@{{VERSION}}' -- peacekeeper "${args[@]}"
|
|
32
|
+
}
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
gh repo view '{{OWNER}}/{{REPOSITORY_NAME}}' >/dev/null
|
|
3
|
-
if [[ "$(gh api 'repos/{{OWNER}}/{{REPOSITORY_NAME}}' --jq '.owner.login | ascii_downcase')" != '{{REQUIRED_APPROVER_LOWER}}' ]]; then
|
|
4
|
-
printf 'Expected %s/%s to be owned by the personal account %s.\n' '{{OWNER}}' '{{REPOSITORY_NAME}}' '{{REQUIRED_APPROVER}}' >&2
|
|
5
|
-
exit 1
|
|
6
|
-
fi
|
|
7
|
-
|
|
8
|
-
# Configure repository-wide branch cleanup, auto-merge, and merge methods.
|
|
9
|
-
gh api --method PATCH 'repos/{{OWNER}}/{{REPOSITORY_NAME}}' {{REPOSITORY_PATCH_ARGUMENTS}} >/dev/null
|
|
10
|
-
|
|
11
|
-
# Create or update one named ruleset without changing unrelated rulesets.
|
|
12
|
-
upsert_ruleset() {
|
|
13
|
-
local name=$1 ids count id
|
|
14
|
-
ids=$(gh api --paginate 'repos/{{OWNER}}/{{REPOSITORY_NAME}}/rulesets?includes_parents=false' --jq ".[] | select(.name == \"$name\") | .id" </dev/null)
|
|
15
|
-
count=$(printf '%s\n' "$ids" | sed '/^$/d' | wc -l | tr -d ' ')
|
|
16
|
-
if [[ "$count" == 0 ]]; then
|
|
17
|
-
gh api --method POST 'repos/{{OWNER}}/{{REPOSITORY_NAME}}/rulesets' --input - >/dev/null
|
|
18
|
-
elif [[ "$count" == 1 ]]; then
|
|
19
|
-
id=$ids
|
|
20
|
-
gh api --method PUT 'repos/{{OWNER}}/{{REPOSITORY_NAME}}/rulesets/'"$id" --input - >/dev/null
|
|
21
|
-
else
|
|
22
|
-
printf 'Multiple rulesets named %s exist; remove duplicates before retrying.\n' "$name" >&2
|
|
23
|
-
exit 1
|
|
24
|
-
fi
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
# Protect the default branch with pull requests, merge commits, and strict CI.
|
|
28
|
-
upsert_ruleset 'Peacekeeper base protection' <<'JSON'
|
|
29
|
-
{{BASE_RULESET}}
|
|
30
|
-
JSON
|
|
31
|
-
|
|
32
|
-
# Require fresh code-owner approval while allowing the owner to bypass this rule.
|
|
33
|
-
upsert_ruleset 'Peacekeeper owner approval' <<JSON
|
|
34
|
-
{{APPROVAL_RULESET}}
|
|
35
|
-
JSON
|
|
36
|
-
|
|
37
|
-
# Remove legacy branch protection now superseded by the rulesets above.
|
|
38
|
-
if gh api 'repos/{{OWNER}}/{{REPOSITORY_NAME}}/branches/{{DEFAULT_BRANCH}}/protection' >/dev/null 2>&1; then
|
|
39
|
-
gh api --method DELETE 'repos/{{OWNER}}/{{REPOSITORY_NAME}}/branches/{{DEFAULT_BRANCH}}/protection' >/dev/null
|
|
40
|
-
fi
|
|
1
|
+
configure_repository '{{REPOSITORY}}' '{{PLAN_NAME}}' '{{POLICY_PR}}' '{{SOURCE_REF}}'
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
if [[ "$mode" == execute ]]; then
|
|
2
|
+
# Synchronize the release-policy secret only after every saved plan succeeded.
|
|
3
|
+
groundskeeper secrets sync --name RELEASE_POLICY_TOKEN {{NEW_REPO_ARGUMENTS}}
|
|
4
|
+
printf 'GitHub configuration and secret synchronization completed.\n'
|
|
5
|
+
else
|
|
6
|
+
printf 'Plans saved. Review them, then rerun this script with --execute and the same directory.\n'
|
|
7
|
+
fi
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export default ({ configuration, external: { fs, modulesRoot, output, path, runtime } }) => {
|
|
2
2
|
const { repositoryRoot } = configuration;
|
|
3
3
|
const DEFINITIONS = [
|
|
4
|
-
['SessionStart', '
|
|
5
|
-
['Stop', '
|
|
6
|
-
['SessionEnd', '
|
|
4
|
+
['SessionStart', 'codex session-start', 30, 'Loading Codex checkpoint instructions'],
|
|
5
|
+
['Stop', 'codex stop', 30, 'Checking for an uncommitted Codex checkpoint'],
|
|
6
|
+
['SessionEnd', 'codex session-end', 3, 'Scheduling merged branch cleanup'],
|
|
7
7
|
];
|
|
8
|
-
const COMMANDS = DEFINITIONS.map(([, command]) => command)
|
|
8
|
+
const COMMANDS = [...DEFINITIONS.map(([, command]) => command),
|
|
9
|
+
'checkpoint-codex-session-start', 'checkpoint-codex-stop', 'cleanup-ended-session'];
|
|
9
10
|
// Recognize complete, standalone invocations only. Shell composition, arguments,
|
|
10
11
|
// environment assignments, and wrappers require inspection instead of replacement.
|
|
11
12
|
function classifyCommand(command) {
|
|
@@ -14,7 +15,7 @@ export default ({ configuration, external: { fs, modulesRoot, output, path, runt
|
|
|
14
15
|
const related = /peacekeeper|checkpoint-codex-(?:stop|session-start)|cleanup-ended-session/.test(command);
|
|
15
16
|
if (!related)
|
|
16
17
|
return 'other';
|
|
17
|
-
const text = command.trim();
|
|
18
|
+
const text = command.trim().replace(/[ \t]+/gu, ' ');
|
|
18
19
|
const action = COMMANDS.find((name) => text.endsWith(` ${name}`) || text.endsWith(`\t${name}`));
|
|
19
20
|
if (!action) {
|
|
20
21
|
const legacy = /^(?:node\s+)(?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?scripts\/(checkpoint-codex-stop|checkpoint-codex-session-start|cleanup-ended-session)\.js$/;
|