@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.
Files changed (35) hide show
  1. package/README.md +294 -98
  2. package/dist/cmdabra.yaml +174 -116
  3. package/dist/package.json +5 -5
  4. package/dist/src/modules/cli/legacy-commands.js +37 -0
  5. package/dist/src/modules/cli/service.js +48 -40
  6. package/dist/src/modules/configuration/facade.js +1 -0
  7. package/dist/src/modules/configuration/project-config-defaults.json +2 -1
  8. package/dist/src/modules/configuration/project-config.js +20 -8
  9. package/dist/src/modules/configuration/update-config.js +16 -2
  10. package/dist/src/modules/dependencies.yaml +1 -1
  11. package/dist/src/modules/lifecycle/checkpoint-instructions.js +1 -1
  12. package/dist/src/modules/lifecycle/cleanup-ended-session.js +1 -1
  13. package/dist/src/modules/maintenance/cleanup-merged-branches.js +4 -4
  14. package/dist/src/modules/maintenance/initialize-codex-worktree.js +1 -1
  15. package/dist/src/modules/maintenance/remove-empty-directories.js +1 -1
  16. package/dist/src/modules/projects/check-project-requirements.txt +32 -31
  17. package/dist/src/modules/projects/check-project.js +16 -16
  18. package/dist/src/modules/projects/codex-setup-prefix.sh +2 -2
  19. package/dist/src/modules/projects/create-project-core.js +13 -28
  20. package/dist/src/modules/projects/generate-github-setup.js +16 -55
  21. package/dist/src/modules/projects/github-setup-prefix.sh +29 -2
  22. package/dist/src/modules/projects/github-setup-repository-template.sh +1 -40
  23. package/dist/src/modules/projects/github-setup-suffix-template.sh +7 -5
  24. package/dist/src/modules/projects/install-hooks.js +6 -5
  25. package/dist/src/modules/releases/configure-github.js +57 -0
  26. package/dist/src/modules/releases/facade.js +3 -2
  27. package/dist/src/modules/releases/github-configuration.js +166 -0
  28. package/dist/src/modules/releases/github-policy.js +45 -11
  29. package/dist/src/modules/releases/github-remote.js +230 -0
  30. package/dist/src/modules/testing/check-test-receipt.js +17 -22
  31. package/dist/src/modules/testing/receipt-state.js +27 -1
  32. package/dist/src/modules/testing/record-test-receipt.js +14 -13
  33. package/dist/src/modules/testing/run-tests.js +23 -14
  34. package/dist/src/modules/testing/types.js +1 -0
  35. package/package.json +5 -5
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
- update-config:
5
- description: Create or complete project configuration using bundled defaults.
6
- create-project:
7
- description: Create and verify a compliant TypeScript library in an empty GitHub repository.
8
- named-options:
9
- repository:
10
- description: GitHub HTTPS repository URL.
11
- required: true
12
- directory:
13
- description: Directory in which to create the project.
14
- required: true
15
- package-name:
16
- description: npm package name.
17
- required: true
18
- author-name:
19
- description: Package author name.
20
- required: true
21
- author-email:
22
- description: Package author email address.
23
- required: true
24
- publish-to-npm:
25
- description: Whether the package will be published to npm.
26
- type: enum
27
- choices: ["true", "false"]
28
- required: true
29
- generate-github-setup:
30
- description: Print commands that configure GitHub policy for one or more repositories.
31
- named-options:
32
- repository:
33
- description: GitHub HTTPS repository URL; may be repeated.
34
- required: true
35
- repeatable: true
36
- check-project:
37
- description: Validate local toolchain, hooks, CI and publication conventions.
38
- named-options:
39
- explain:
40
- description: Print the complete expected project architecture.
41
- type: boolean
42
- install-hooks:
43
- description: Install or update project Codex hooks while preserving other hooks.
44
- named-options:
45
- dry-run:
46
- description: Preview changes without writing hooks.
47
- type: boolean
48
- verify-release:
49
- description: Verify release versions, required CI and strict branch protection.
50
- verify-release-protection:
51
- description: Require strict mandatory release checks without bypass.
52
- verify-release-version:
53
- description: Check a release tag against package and lockfile versions.
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: Publish a version through a GitHub Actions npm workflow.
56
- positional-arguments:
57
- bump:
58
- description: Version increment to publish.
59
- type: enum
60
- choices: [major, minor, patch]
61
- assess-release:
62
- description: Assess unpublished changes with Codex and return a JSON recommendation.
63
- check-conventions:
64
- description: Test configured repository conventions.
65
- named-options:
66
- update:
67
- description: Replace generated output directories after successful generation; check other rules.
68
- type: boolean
69
- run-tests:
70
- description: Run configured tests, reusing a valid test receipt.
71
- named-options:
72
- force:
73
- description: Run tests even when a valid receipt exists.
74
- type: boolean
75
- check-test-receipt:
76
- description: Check whether a valid test receipt exists.
77
- record-test-receipt:
78
- description: Record a test receipt without running tests.
79
- checkpoint-codex-changes:
80
- description: Commit a linked worktree and push according to project configuration.
81
- named-options:
82
- subject:
83
- description: Commit subject.
84
- required: true
85
- body:
86
- description: Commit body paragraph; may be repeated.
87
- required: true
88
- repeatable: true
89
- checkpoint-codex-session-start:
90
- description: Load checkpoint instructions for a linked Codex worktree.
91
- checkpoint-codex-stop:
92
- description: Handle the Codex Stop hook and request a checkpoint if needed.
93
- cleanup-ended-session:
94
- description: Queue cleanup for a merged Codex session worktree.
95
- queue-merged-worktree-cleanup:
96
- description: Queue cleanup for the current merged worktree.
97
- initialize-codex-worktree:
98
- description: Initialize a linked Codex worktree from the configured default branch.
99
- named-options:
100
- sync-primary:
101
- description: Safely publish and update the primary checkout too.
102
- type: boolean
103
- cleanup-merged-branches:
104
- description: Preview or delete merged worktrees and branches.
105
- named-options:
106
- dry-run:
107
- description: Preview cleanup without deleting anything.
108
- type: boolean
109
- execute:
110
- description: Delete the displayed worktrees and branches.
111
- type: boolean
112
- remove-empty-directories:
113
- description: Preview or remove directories containing only ignored files.
114
- named-options:
115
- dry-run:
116
- description: Preview cleanup without deleting anything.
117
- type: boolean
118
- execute:
119
- description: Remove the displayed directories.
120
- type: boolean
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.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Shared repository test, Git worktree, and Codex hook commands",
5
5
  "license": "MIT",
6
6
  "author": "Jakob Mattsson",
@@ -28,13 +28,13 @@
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-tests",
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-merged-branches",
37
- "cleanup:empty-directories": "node dist/bin/peacekeeper.js remove-empty-directories"
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"
@@ -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
- export default ({ configuration, lifecycle, maintenance, projects, releases, testing, external: { cliConfigPath, runCli, runtime }, }) => {
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
- updateConfig: () => configuration.updateConfig(),
9
- checkProject: options => projects.checkProject({ explain: options.explain }),
10
- createProject: 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
- generateGithubSetup: options => projects.generateGithubSetup({ repository: options.repository }),
19
- installHooks: options => projects.installHooks({ dryRun: options.dryRun }),
20
- checkConventions: options => testing.checkConventions({ update: options.update }),
21
- checkTestReceipt: () => testing.checkTestReceipt(),
22
- recordTestReceipt: () => testing.recordTestReceipt(),
23
- runTests: options => testing.runTests({ force: options.force }),
24
- assessRelease: () => releases.assessRelease(),
25
- release: bump => releases.release(bump),
26
- verifyRelease: () => releases.verifyRelease(),
27
- verifyReleaseProtection: () => releases.verifyReleaseProtection(),
28
- verifyReleaseVersion: () => releases.verifyReleaseVersion(),
29
- checkpointCodexChanges: options => lifecycle.checkpointCodexChanges({
30
- subject: options.subject,
31
- bodyParagraphs: options.body,
32
- }),
33
- checkpointCodexSessionStart: () => lifecycle.checkpointCodexSessionStart(),
34
- checkpointCodexStop: () => lifecycle.checkpointCodexStop(),
35
- cleanupEndedSession: () => lifecycle.cleanupEndedSession(),
36
- queueMergedWorktreeCleanup: () => lifecycle.queueMergedWorktreeCleanup(),
37
- initializeCodexWorktree: options => maintenance.initializeCodexWorktree({
38
- syncPrimary: options.syncPrimary,
39
- }),
40
- cleanupMergedBranches: options => maintenance.cleanupMergedBranches({
41
- execute: executionMode(options),
42
- }),
43
- removeEmptyDirectories: options => maintenance.removeEmptyDirectories({
44
- execute: executionMode(options),
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
  };
@@ -1,4 +1,5 @@
1
1
  export const porticoFacade = ({ projectConfig, updateConfig }) => ({
2
+ codeownersError: projectConfig.codeownersError,
2
3
  projectConfig: projectConfig.projectConfig,
3
4
  repositoryRoot: projectConfig.repositoryRoot,
4
5
  requireTestCommands: projectConfig.requireTestCommands,
@@ -14,7 +14,8 @@
14
14
  "releaseTestWorkflow": "test.yml"
15
15
  },
16
16
  "tests": {
17
- "commands": [],
17
+ "all": [],
18
+ "checkpoint": [],
18
19
  "receiptMaxAgeMinutes": 60,
19
20
  "npmTestUsesRunner": false
20
21
  },
@@ -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: { commands: true, receiptMaxAgeMinutes: true, npmTestUsesRunner: true },
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
- if (!Array.isArray(config.tests.commands)
95
- || config.tests.commands.some((command) => typeof command !== 'string' || command.trim() === '')) {
96
- throw new Error(`${file}: tests.commands must be an array of command strings`);
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.commands.length) {
121
- throw new Error('Configure tests.commands before running tests or using a test receipt.');
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
- const api = { CONFIG_FILE, LEGACY_CONFIG_FILE, CONFIG_SCHEMA, validateConfig, projectConfig, repositoryRoot, requireTestCommands };
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 updated = complete(original, defaults);
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
- addMissing(document, original, defaults);
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
  }
@@ -12,5 +12,5 @@ allowed-external:
12
12
  lifecycle: [buffer, clock, executablePath, fs, output, path, runtime, spawn, spawnSync]
13
13
  maintenance: [execFileSync, fs, output, path, runtime, spawnSync]
14
14
  projects: [TOML, YAML, buffer, fs, isDeepStrictEqual, modulesRoot, output, packageVersion, path, projectConfigDefaults, runtime, semver, spawnSync, structuredClone, url]
15
- releases: [YAML, assessReleaseSchema, clock, execFileSync, fs, modulesRoot, os, output, path, 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]
@@ -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 checkpoint-codex-changes '
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, 'cleanup-ended-session', '--worker', payload], {
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],
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * Recommended usage:
7
7
  *
8
- * npm exec --no -- peacekeeper cleanup-merged-branches # Dry-run (default).
9
- * npm exec --no -- peacekeeper cleanup-merged-branches --dry-run # Explicit dry-run.
10
- * npm exec --no -- peacekeeper cleanup-merged-branches --execute # Apply the displayed cleanup.
8
+ * npm exec --no -- peacekeeper cleanup merged-branches # Dry-run (default).
9
+ * npm exec --no -- peacekeeper cleanup merged-branches --dry-run # Explicit dry-run.
10
+ * npm exec --no -- peacekeeper cleanup merged-branches --execute # Apply the displayed cleanup.
11
11
  *
12
12
  * Every run fetches the configured remote, including dry-runs, so the cleanup
13
13
  * plan uses current remote references. Dry-run does not remove anything,
@@ -252,7 +252,7 @@ export default ({ configuration, external: { execFileSync, fs, output, path, run
252
252
  if (!execute) {
253
253
  log('');
254
254
  log('To apply this cleanup, run:');
255
- log(' npm exec --no -- peacekeeper cleanup-merged-branches --execute');
255
+ log(' npm exec --no -- peacekeeper cleanup merged-branches --execute');
256
256
  }
257
257
  }
258
258
  function run({ execute = false } = {}) {
@@ -264,7 +264,7 @@ export default ({ configuration, external: { fs, output, path, runtime, spawnSyn
264
264
  const root = git(cwd, 'rev-parse', '--show-toplevel');
265
265
  const primaryRoot = primaryWorktree(root);
266
266
  if (samePath(root, primaryRoot)) {
267
- throw new Error('initialize-codex-worktree must run from a linked Git worktree');
267
+ throw new Error('codex init-worktree must run from a linked Git worktree');
268
268
  }
269
269
  const config = projectConfig(root);
270
270
  let state = readState(root);