@jakobm/peacekeeper 0.26.0 → 0.28.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 +307 -129
- package/dist/cmdabra.yaml +174 -116
- package/dist/package.json +5 -6
- 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 +2 -2
- package/dist/src/modules/external.js +0 -2
- 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 +38 -57
- package/dist/src/modules/projects/check-project.js +19 -45
- package/dist/src/modules/projects/create-project-core.js +13 -32
- 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 -6
- package/dist/src/modules/projects/codex-setup-prefix.sh +0 -25
package/dist/cmdabra.yaml
CHANGED
|
@@ -1,120 +1,178 @@
|
|
|
1
1
|
name: peacekeeper
|
|
2
2
|
description: Shared repository test, Git worktree, and Codex hook commands
|
|
3
3
|
commands:
|
|
4
|
-
|
|
5
|
-
description: Create
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
description:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
4
|
+
project:
|
|
5
|
+
description: Create, configure and validate projects.
|
|
6
|
+
commands:
|
|
7
|
+
create:
|
|
8
|
+
description: Create and verify a compliant TypeScript library in an empty GitHub repository.
|
|
9
|
+
named-options:
|
|
10
|
+
repository:
|
|
11
|
+
description: GitHub HTTPS repository URL.
|
|
12
|
+
required: true
|
|
13
|
+
directory:
|
|
14
|
+
description: Directory in which to create the project.
|
|
15
|
+
required: true
|
|
16
|
+
package-name:
|
|
17
|
+
description: npm package name.
|
|
18
|
+
required: true
|
|
19
|
+
author-name:
|
|
20
|
+
description: Package author name.
|
|
21
|
+
required: true
|
|
22
|
+
author-email:
|
|
23
|
+
description: Package author email address.
|
|
24
|
+
required: true
|
|
25
|
+
publish-to-npm:
|
|
26
|
+
description: Whether the package will be published to npm.
|
|
27
|
+
type: enum
|
|
28
|
+
choices:
|
|
29
|
+
- "true"
|
|
30
|
+
- "false"
|
|
31
|
+
required: true
|
|
32
|
+
check:
|
|
33
|
+
description: Validate local toolchain, hooks, CI and publication conventions.
|
|
34
|
+
named-options:
|
|
35
|
+
explain:
|
|
36
|
+
description: Print the complete expected project architecture.
|
|
37
|
+
type: boolean
|
|
38
|
+
update-config:
|
|
39
|
+
description: Create or complete project configuration using bundled defaults.
|
|
40
|
+
check-conventions:
|
|
41
|
+
description: Test configured repository conventions.
|
|
42
|
+
named-options:
|
|
43
|
+
update:
|
|
44
|
+
description: Replace generated output directories after successful generation; check other rules.
|
|
45
|
+
type: boolean
|
|
46
|
+
test:
|
|
47
|
+
description: Run tests and manage command receipts.
|
|
48
|
+
commands:
|
|
49
|
+
run:
|
|
50
|
+
description: Run tests.all, reusing valid receipts for individual commands.
|
|
51
|
+
named-options:
|
|
52
|
+
force:
|
|
53
|
+
description: Run tests even when valid command receipts exist.
|
|
54
|
+
type: boolean
|
|
55
|
+
checkpoint:
|
|
56
|
+
description: Run tests.checkpoint instead of tests.all.
|
|
57
|
+
type: boolean
|
|
58
|
+
check-receipt:
|
|
59
|
+
description: Check whether every selected command has a valid test receipt.
|
|
60
|
+
named-options:
|
|
61
|
+
checkpoint:
|
|
62
|
+
description: Check tests.checkpoint instead of tests.all.
|
|
63
|
+
type: boolean
|
|
64
|
+
record-receipt:
|
|
65
|
+
description: Record receipts for selected commands without running tests.
|
|
66
|
+
named-options:
|
|
67
|
+
checkpoint:
|
|
68
|
+
description: Record tests.checkpoint instead of tests.all.
|
|
69
|
+
type: boolean
|
|
70
|
+
github:
|
|
71
|
+
description: Configure GitHub repository policy.
|
|
72
|
+
commands:
|
|
73
|
+
configure:
|
|
74
|
+
description: Plan or apply exact GitHub policy from a SHA-pinned remote source.
|
|
75
|
+
named-options:
|
|
76
|
+
repository:
|
|
77
|
+
description: GitHub OWNER/REPO; required for planning, or assert the saved plan target during execute.
|
|
78
|
+
policy-pr:
|
|
79
|
+
description: Open same-repository PR targeting the default branch to use as the policy source.
|
|
80
|
+
source-ref:
|
|
81
|
+
description: Expected full commit SHA of the selected default branch or policy PR.
|
|
82
|
+
plan-file:
|
|
83
|
+
description: Save a new plan here, or read this saved plan with --execute.
|
|
84
|
+
execute:
|
|
85
|
+
description: Apply the saved plan after checking current remote preconditions.
|
|
86
|
+
type: boolean
|
|
87
|
+
json:
|
|
88
|
+
description: Print a structured result for automation.
|
|
89
|
+
type: boolean
|
|
90
|
+
generate-setup:
|
|
91
|
+
description: Print commands that configure GitHub policy for one or more repositories.
|
|
92
|
+
named-options:
|
|
93
|
+
repository:
|
|
94
|
+
description: GitHub HTTPS repository URL; may be repeated.
|
|
95
|
+
required: true
|
|
96
|
+
repeatable: true
|
|
97
|
+
policy-pr:
|
|
98
|
+
description: Policy PR for a single repository.
|
|
99
|
+
source-ref:
|
|
100
|
+
description: Expected full policy commit SHA for a single repository.
|
|
54
101
|
release:
|
|
55
|
-
description:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
description:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
description:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
description:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
102
|
+
description: Assess, verify and publish releases.
|
|
103
|
+
commands:
|
|
104
|
+
assess:
|
|
105
|
+
description: Assess unpublished changes with Codex and return a JSON recommendation.
|
|
106
|
+
verify:
|
|
107
|
+
description: Verify release versions, required CI and strict branch protection.
|
|
108
|
+
verify-protection:
|
|
109
|
+
description: Require strict mandatory release checks without bypass.
|
|
110
|
+
verify-version:
|
|
111
|
+
description: Check a release tag against package and lockfile versions.
|
|
112
|
+
publish:
|
|
113
|
+
description: Publish a version through a GitHub Actions npm workflow.
|
|
114
|
+
positional-arguments:
|
|
115
|
+
bump:
|
|
116
|
+
description: Version increment to publish.
|
|
117
|
+
type: enum
|
|
118
|
+
choices:
|
|
119
|
+
- major
|
|
120
|
+
- minor
|
|
121
|
+
- patch
|
|
122
|
+
codex:
|
|
123
|
+
description: Manage Codex hooks, worktrees and session events.
|
|
124
|
+
commands:
|
|
125
|
+
install-hooks:
|
|
126
|
+
description: Install or update project Codex hooks while preserving other hooks.
|
|
127
|
+
named-options:
|
|
128
|
+
dry-run:
|
|
129
|
+
description: Preview changes without writing hooks.
|
|
130
|
+
type: boolean
|
|
131
|
+
init-worktree:
|
|
132
|
+
description: Initialize a linked Codex worktree from the configured default branch.
|
|
133
|
+
named-options:
|
|
134
|
+
sync-primary:
|
|
135
|
+
description: Safely publish and update the primary checkout too.
|
|
136
|
+
type: boolean
|
|
137
|
+
checkpoint:
|
|
138
|
+
description: Commit a linked worktree and push according to project configuration.
|
|
139
|
+
named-options:
|
|
140
|
+
subject:
|
|
141
|
+
description: Commit subject.
|
|
142
|
+
required: true
|
|
143
|
+
body:
|
|
144
|
+
description: Commit body paragraph; may be repeated.
|
|
145
|
+
required: true
|
|
146
|
+
repeatable: true
|
|
147
|
+
session-start:
|
|
148
|
+
description: Load checkpoint instructions for a linked Codex worktree.
|
|
149
|
+
stop:
|
|
150
|
+
description: Handle the Codex Stop hook and request a checkpoint if needed.
|
|
151
|
+
session-end:
|
|
152
|
+
description: Queue cleanup for a merged Codex session worktree.
|
|
153
|
+
named-options:
|
|
154
|
+
worker:
|
|
155
|
+
description: Internal encoded cleanup target for the detached session worker.
|
|
156
|
+
cleanup:
|
|
157
|
+
description: Clean up merged branches, worktrees and empty directories.
|
|
158
|
+
commands:
|
|
159
|
+
merged-branches:
|
|
160
|
+
description: Preview or delete merged worktrees and branches.
|
|
161
|
+
named-options:
|
|
162
|
+
dry-run:
|
|
163
|
+
description: Preview cleanup without deleting anything.
|
|
164
|
+
type: boolean
|
|
165
|
+
execute:
|
|
166
|
+
description: Delete the displayed worktrees and branches.
|
|
167
|
+
type: boolean
|
|
168
|
+
empty-directories:
|
|
169
|
+
description: Preview or remove directories containing only ignored files.
|
|
170
|
+
named-options:
|
|
171
|
+
dry-run:
|
|
172
|
+
description: Preview cleanup without deleting anything.
|
|
173
|
+
type: boolean
|
|
174
|
+
execute:
|
|
175
|
+
description: Remove the displayed directories.
|
|
176
|
+
type: boolean
|
|
177
|
+
queue-merged-worktree:
|
|
178
|
+
description: Queue cleanup for the current merged worktree.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakobm/peacekeeper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Shared repository test, Git worktree, and Codex hook commands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jakob Mattsson",
|
|
@@ -28,19 +28,18 @@
|
|
|
28
28
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
29
29
|
"build": "npm run clean && npm run check:cli-types && tsc && tsc -p tsconfig.test.json && node dist/scripts/copy-assets.js",
|
|
30
30
|
"typecheck": "npm run check:cli-types && tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
31
|
-
"test": "npm run build && node dist/bin/peacekeeper.js run
|
|
31
|
+
"test": "npm run build && node dist/bin/peacekeeper.js test run",
|
|
32
32
|
"prepare": "npm run build",
|
|
33
33
|
"architecture": "npm run build && portico architecture --modules dist/src/modules --output architecture",
|
|
34
34
|
"prerelease": "npm ci",
|
|
35
|
-
"release": "node dist/bin/peacekeeper.js release",
|
|
36
|
-
"cleanup:branches": "node dist/bin/peacekeeper.js cleanup
|
|
37
|
-
"cleanup:empty-directories": "node dist/bin/peacekeeper.js
|
|
35
|
+
"release": "node dist/bin/peacekeeper.js release publish",
|
|
36
|
+
"cleanup:branches": "node dist/bin/peacekeeper.js cleanup merged-branches",
|
|
37
|
+
"cleanup:empty-directories": "node dist/bin/peacekeeper.js cleanup empty-directories"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": "^22.14.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@iarna/toml": "^2.2.5",
|
|
44
43
|
"@jakobm/cmdabra": "^0.7.0",
|
|
45
44
|
"@jakobm/portico": "^0.8.1",
|
|
46
45
|
"glob": "^14.0.4",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// --- Implementation ---
|
|
2
|
+
export default () => {
|
|
3
|
+
// These names are a compatibility contract for existing scripts and hooks.
|
|
4
|
+
const commands = {
|
|
5
|
+
'create-project': ['project', 'create'],
|
|
6
|
+
'check-project': ['project', 'check'],
|
|
7
|
+
'update-config': ['project', 'update-config'],
|
|
8
|
+
'check-conventions': ['project', 'check-conventions'],
|
|
9
|
+
'run-tests': ['test', 'run'],
|
|
10
|
+
'check-test-receipt': ['test', 'check-receipt'],
|
|
11
|
+
'record-test-receipt': ['test', 'record-receipt'],
|
|
12
|
+
'configure-github': ['github', 'configure'],
|
|
13
|
+
'generate-github-setup': ['github', 'generate-setup'],
|
|
14
|
+
'assess-release': ['release', 'assess'],
|
|
15
|
+
'verify-release': ['release', 'verify'],
|
|
16
|
+
'verify-release-protection': ['release', 'verify-protection'],
|
|
17
|
+
'verify-release-version': ['release', 'verify-version'],
|
|
18
|
+
'release': ['release', 'publish'],
|
|
19
|
+
'install-hooks': ['codex', 'install-hooks'],
|
|
20
|
+
'initialize-codex-worktree': ['codex', 'init-worktree'],
|
|
21
|
+
'checkpoint-codex-changes': ['codex', 'checkpoint'],
|
|
22
|
+
'checkpoint-codex-session-start': ['codex', 'session-start'],
|
|
23
|
+
'checkpoint-codex-stop': ['codex', 'stop'],
|
|
24
|
+
'cleanup-ended-session': ['codex', 'session-end'],
|
|
25
|
+
'cleanup-merged-branches': ['cleanup', 'merged-branches'],
|
|
26
|
+
'remove-empty-directories': ['cleanup', 'empty-directories'],
|
|
27
|
+
'queue-merged-worktree-cleanup': ['cleanup', 'queue-merged-worktree'],
|
|
28
|
+
};
|
|
29
|
+
function normalize(rawArgs) {
|
|
30
|
+
const [command, ...rest] = rawArgs;
|
|
31
|
+
// The new release group shares the old publish command's name.
|
|
32
|
+
if (command === 'release' && !['major', 'minor', 'patch'].includes(rest[0]))
|
|
33
|
+
return rawArgs;
|
|
34
|
+
return Object.hasOwn(commands, command) ? [...commands[command], ...rest] : rawArgs;
|
|
35
|
+
}
|
|
36
|
+
return { commands, normalize };
|
|
37
|
+
};
|
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
// --- Implementation ---
|
|
2
|
+
export default ({ configuration, legacyCommands, lifecycle, maintenance, projects, releases, testing, external: { cliConfigPath, runCli, runtime }, }) => {
|
|
2
3
|
function executionMode({ dryRun, execute }) {
|
|
3
4
|
if (dryRun && execute)
|
|
4
5
|
throw new Error('--dry-run and --execute cannot be combined');
|
|
5
6
|
return Boolean(execute);
|
|
6
7
|
}
|
|
7
8
|
const implementation = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
9
|
+
project: {
|
|
10
|
+
create: options => projects.createProject({
|
|
11
|
+
repository: options.repository,
|
|
12
|
+
directory: options.directory,
|
|
13
|
+
packageName: options.packageName,
|
|
14
|
+
authorName: options.authorName,
|
|
15
|
+
authorEmail: options.authorEmail,
|
|
16
|
+
published: options.publishToNpm === 'true',
|
|
17
|
+
}),
|
|
18
|
+
check: options => projects.checkProject({ explain: options.explain }),
|
|
19
|
+
updateConfig: () => configuration.updateConfig(),
|
|
20
|
+
checkConventions: options => testing.checkConventions({ update: options.update }),
|
|
21
|
+
},
|
|
22
|
+
test: {
|
|
23
|
+
run: options => testing.runTests({ force: options.force, checkpoint: options.checkpoint }),
|
|
24
|
+
checkReceipt: options => testing.checkTestReceipt({ checkpoint: options.checkpoint }),
|
|
25
|
+
recordReceipt: options => testing.recordTestReceipt({ checkpoint: options.checkpoint }),
|
|
26
|
+
},
|
|
27
|
+
github: {
|
|
28
|
+
configure: options => releases.configureGithub(options),
|
|
29
|
+
generateSetup: options => projects.generateGithubSetup(options),
|
|
30
|
+
},
|
|
31
|
+
release: {
|
|
32
|
+
assess: () => releases.assessRelease(),
|
|
33
|
+
verify: () => releases.verifyRelease(),
|
|
34
|
+
verifyProtection: () => releases.verifyReleaseProtection(),
|
|
35
|
+
verifyVersion: () => releases.verifyReleaseVersion(),
|
|
36
|
+
publish: bump => releases.release(bump),
|
|
37
|
+
},
|
|
38
|
+
codex: {
|
|
39
|
+
installHooks: options => projects.installHooks({ dryRun: options.dryRun }),
|
|
40
|
+
initWorktree: options => maintenance.initializeCodexWorktree({ syncPrimary: options.syncPrimary }),
|
|
41
|
+
checkpoint: options => lifecycle.checkpointCodexChanges({
|
|
42
|
+
subject: options.subject,
|
|
43
|
+
bodyParagraphs: options.body,
|
|
44
|
+
}),
|
|
45
|
+
sessionStart: () => lifecycle.checkpointCodexSessionStart(),
|
|
46
|
+
stop: () => lifecycle.checkpointCodexStop(),
|
|
47
|
+
sessionEnd: options => lifecycle.cleanupEndedSession(options.worker ? ['--worker', options.worker] : []),
|
|
48
|
+
},
|
|
49
|
+
cleanup: {
|
|
50
|
+
mergedBranches: options => maintenance.cleanupMergedBranches({ execute: executionMode(options) }),
|
|
51
|
+
emptyDirectories: options => maintenance.removeEmptyDirectories({ execute: executionMode(options) }),
|
|
52
|
+
queueMergedWorktree: () => lifecycle.queueMergedWorktreeCleanup(),
|
|
53
|
+
},
|
|
46
54
|
};
|
|
47
55
|
function cliProcess(rawArgs) {
|
|
48
56
|
return {
|
|
@@ -58,7 +66,7 @@ export default ({ configuration, lifecycle, maintenance, projects, releases, tes
|
|
|
58
66
|
}
|
|
59
67
|
return {
|
|
60
68
|
async run(rawArgs) {
|
|
61
|
-
await runCli(cliConfigPath, implementation, cliProcess(rawArgs));
|
|
69
|
+
await runCli(cliConfigPath, implementation, cliProcess(legacyCommands.normalize(rawArgs)));
|
|
62
70
|
},
|
|
63
71
|
};
|
|
64
72
|
};
|
|
@@ -13,7 +13,7 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
|
|
|
13
13
|
git: { remote: true, defaultBranch: true, branchPrefix: true, requiredApprover: true,
|
|
14
14
|
checkpointPushRemotes: true, releaseMergeMethod: true,
|
|
15
15
|
releaseRequiredChecks: true, releaseTestWorkflow: true },
|
|
16
|
-
tests: {
|
|
16
|
+
tests: { all: true, checkpoint: true, receiptMaxAgeMinutes: true, npmTestUsesRunner: true },
|
|
17
17
|
conventions: { rules: true },
|
|
18
18
|
loggingDirectory: true,
|
|
19
19
|
loggingEnabled: true,
|
|
@@ -45,7 +45,7 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
|
|
|
45
45
|
const errors = [];
|
|
46
46
|
validateShape(config, CONFIG_SCHEMA, 'config', errors);
|
|
47
47
|
if (errors.length)
|
|
48
|
-
throw new Error(`${file}: ${errors.join('; ')}. Run peacekeeper update-config to add missing fields.`);
|
|
48
|
+
throw new Error(`${file}: ${errors.join('; ')}. Run peacekeeper project update-config to add missing fields.`);
|
|
49
49
|
try {
|
|
50
50
|
conventionRules.validate(config.conventions.rules);
|
|
51
51
|
}
|
|
@@ -91,9 +91,15 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
|
|
|
91
91
|
throw new Error(`${file}: loggingEnabled must be a boolean`);
|
|
92
92
|
}
|
|
93
93
|
requireNonemptyString(config.loggingDirectory, 'loggingDirectory', file);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
for (const level of ['all', 'checkpoint']) {
|
|
95
|
+
if (!Array.isArray(config.tests[level])
|
|
96
|
+
|| config.tests[level].some((command) => typeof command !== 'string' || command.trim() === '')) {
|
|
97
|
+
throw new Error(`${file}: tests.${level} must be an array of command strings`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const missing = config.tests.checkpoint.filter(command => !config.tests.all.includes(command));
|
|
101
|
+
if (missing.length) {
|
|
102
|
+
throw new Error(`${file}: every command in tests.checkpoint must also appear in tests.all; missing: ${JSON.stringify(missing)}`);
|
|
97
103
|
}
|
|
98
104
|
if (!Number.isSafeInteger(config.tests.receiptMaxAgeMinutes)
|
|
99
105
|
|| config.tests.receiptMaxAgeMinutes < 1) {
|
|
@@ -117,10 +123,16 @@ export default ({ conventionRules, external: { execFileSync, fs, path, projectCo
|
|
|
117
123
|
return { root, ...config };
|
|
118
124
|
}
|
|
119
125
|
function requireTestCommands(root) {
|
|
120
|
-
if (!projectConfig(root).tests.
|
|
121
|
-
throw new Error('Configure tests.
|
|
126
|
+
if (!projectConfig(root).tests.all.length) {
|
|
127
|
+
throw new Error('Configure tests.all before running tests or using a test receipt.');
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
|
-
|
|
130
|
+
function codeownersError(contents, approver) {
|
|
131
|
+
const lines = typeof contents === 'string' ? contents.split(/\r?\n/u)
|
|
132
|
+
.map(line => line.trim()).filter(line => line && !line.startsWith('#')) : [];
|
|
133
|
+
return lines.length === 1 && lines[0] === `* @${approver}` ? undefined
|
|
134
|
+
: `.github/CODEOWNERS: use exactly one ownership rule, "* @${approver}", so only git.requiredApprover can satisfy required code-owner review.`;
|
|
135
|
+
}
|
|
136
|
+
const api = { CONFIG_FILE, LEGACY_CONFIG_FILE, CONFIG_SCHEMA, validateConfig, projectConfig, repositoryRoot, requireTestCommands, codeownersError };
|
|
125
137
|
return api;
|
|
126
138
|
};
|
|
@@ -37,10 +37,24 @@ export default ({ projectConfig, external: { fs, isDeepStrictEqual, output, path
|
|
|
37
37
|
if (document.errors.length)
|
|
38
38
|
throw new Error(`${file}: ${document.errors.map(error => error.message).join('; ')}`);
|
|
39
39
|
const original = document.toJS();
|
|
40
|
-
const
|
|
40
|
+
const migrated = complete(original, {});
|
|
41
|
+
const legacyCommands = migrated?.tests && Object.hasOwn(migrated.tests, 'commands');
|
|
42
|
+
if (legacyCommands) {
|
|
43
|
+
if (Object.hasOwn(migrated.tests, 'all')) {
|
|
44
|
+
throw new Error(`${file}: both tests.commands and tests.all exist; remove tests.commands after reviewing both lists.`);
|
|
45
|
+
}
|
|
46
|
+
migrated.tests = { ...migrated.tests, all: migrated.tests.commands };
|
|
47
|
+
delete migrated.tests.commands;
|
|
48
|
+
}
|
|
49
|
+
const updated = complete(migrated, defaults);
|
|
41
50
|
validateConfig(updated, file);
|
|
42
51
|
if (!exists || !isDeepStrictEqual(original, updated)) {
|
|
43
|
-
|
|
52
|
+
if (legacyCommands) {
|
|
53
|
+
const tests = document.getIn(['tests'], true);
|
|
54
|
+
const commands = tests.items.find(pair => pair.key.value === 'commands');
|
|
55
|
+
commands.key.value = 'all';
|
|
56
|
+
}
|
|
57
|
+
addMissing(document, migrated, defaults);
|
|
44
58
|
fs.writeFileSync(file, document.toString({ lineWidth: 0 }));
|
|
45
59
|
output.log(`Updated ${file}. Review defaults before using project commands.`);
|
|
46
60
|
}
|
|
@@ -11,6 +11,6 @@ allowed-external:
|
|
|
11
11
|
configuration: [YAML, execFileSync, fs, hasMagic, isDeepStrictEqual, output, path, projectConfigDefaults, runtime]
|
|
12
12
|
lifecycle: [buffer, clock, executablePath, fs, output, path, runtime, spawn, spawnSync]
|
|
13
13
|
maintenance: [execFileSync, fs, output, path, runtime, spawnSync]
|
|
14
|
-
projects: [
|
|
15
|
-
releases: [YAML, assessReleaseSchema, clock, execFileSync, fs, modulesRoot, os, output, path, runtime, semver, spawnSync, structuredClone, url]
|
|
14
|
+
projects: [YAML, buffer, fs, modulesRoot, output, packageVersion, path, projectConfigDefaults, runtime, semver, spawnSync, structuredClone, url]
|
|
15
|
+
releases: [YAML, assessReleaseSchema, buffer, clock, execFileSync, fs, modulesRoot, os, output, packageVersion, path, projectConfigDefaults, runtime, semver, spawnSync, structuredClone, url]
|
|
16
16
|
testing: [YAML, clock, crypto, execFileSync, fs, globSync, hasMagic, modulesRoot, os, output, path, runtime, spawnSync, test]
|
|
@@ -7,7 +7,6 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
7
7
|
import test from 'node:test';
|
|
8
8
|
import { globSync, hasMagic } from 'glob';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
-
import TOML from '@iarna/toml';
|
|
11
10
|
import semver from 'semver';
|
|
12
11
|
import YAML from 'yaml';
|
|
13
12
|
import assessReleaseSchema from './releases/assess-release-schema.json' with { type: 'json' };
|
|
@@ -48,7 +47,6 @@ export default () => ({
|
|
|
48
47
|
spawnSync,
|
|
49
48
|
structuredClone,
|
|
50
49
|
test,
|
|
51
|
-
TOML,
|
|
52
50
|
url: URL,
|
|
53
51
|
YAML,
|
|
54
52
|
});
|
|
@@ -10,7 +10,7 @@ export default () => {
|
|
|
10
10
|
+ `(${config.git.defaultBranch}), first create and switch to a descriptive task branch named with the ${config.git.branchPrefix} prefix. `
|
|
11
11
|
+ 'Write an English commit message with a concise, descriptive single-line subject and a body '
|
|
12
12
|
+ 'separated from it by a blank line. The English body should explain the change using between '
|
|
13
|
-
+ 'one and ten sentences. Run `npm exec --no -- peacekeeper
|
|
13
|
+
+ 'one and ten sentences. Run `npm exec --no -- peacekeeper codex checkpoint '
|
|
14
14
|
+ '--subject "<subject>" --body "<body paragraph>"`; repeat `--body` for additional paragraphs when useful. '
|
|
15
15
|
+ 'The command stages all changes, so do not include unrelated changes. '
|
|
16
16
|
+ 'Push behavior follows the project configuration. Unless an explicit user instruction disables '
|
|
@@ -219,7 +219,7 @@ export default ({ configuration, logScriptInvocation: invocation, maintenance, e
|
|
|
219
219
|
const logPath = loggingEnabled ? path.join(target.commonGitDirectory, 'cleanup-ended-session.log') : null;
|
|
220
220
|
const logFile = loggingEnabled ? fs.openSync(logPath, 'a') : 'ignore';
|
|
221
221
|
const payload = buffer.from(JSON.stringify(target)).toString('base64url');
|
|
222
|
-
const child = spawn(runtime.execPath, [executablePath, '
|
|
222
|
+
const child = spawn(runtime.execPath, [executablePath, 'codex', 'session-end', '--worker', payload], {
|
|
223
223
|
cwd: target.repositoryRoot,
|
|
224
224
|
detached: true,
|
|
225
225
|
stdio: ['ignore', logFile, logFile],
|