@jakobm/peacekeeper 0.27.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 +19 -37
- package/dist/package.json +1 -2
- package/dist/src/modules/dependencies.yaml +1 -1
- package/dist/src/modules/external.js +0 -2
- package/dist/src/modules/projects/check-project-requirements.txt +7 -27
- package/dist/src/modules/projects/check-project.js +4 -30
- package/dist/src/modules/projects/create-project-core.js +1 -5
- package/package.json +1 -2
- package/dist/src/modules/projects/codex-setup-prefix.sh +0 -25
package/README.md
CHANGED
|
@@ -34,8 +34,8 @@ For example, `run-tests --checkpoint` maps to `test run --checkpoint`,
|
|
|
34
34
|
`checkpoint-codex-changes` maps to `codex checkpoint`, and `release patch` maps
|
|
35
35
|
to `release publish patch`. Bare `release` now displays the release group's help.
|
|
36
36
|
Help and generated project files use the grouped names. Update existing package
|
|
37
|
-
scripts and CI to those names
|
|
38
|
-
|
|
37
|
+
scripts and CI to those names. The legacy hook installer remains available, but its repository-local files
|
|
38
|
+
conflict with the current project requirements.
|
|
39
39
|
|
|
40
40
|
## Architecture
|
|
41
41
|
|
|
@@ -59,7 +59,7 @@ checked-in output lives in `architecture/`. Peacekeeper's configured
|
|
|
59
59
|
|
|
60
60
|
Checkpoint and session lifecycle hooks use the same Cmdabra and Portico composition
|
|
61
61
|
as other CLI commands. Dependencies must therefore be installed in every worktree
|
|
62
|
-
before its hooks run;
|
|
62
|
+
before its hooks run; run `npm ci` explicitly when preparing a worktree.
|
|
63
63
|
|
|
64
64
|
The CLI also exposes Cmdabra's global `--cmdabra-complete` option for
|
|
65
65
|
[shell completion adapters](https://github.com/jakobmattsson/cmdabra#shell-completion).
|
|
@@ -431,7 +431,12 @@ Test-generated files should be ignored or written outside the repository.
|
|
|
431
431
|
receipt. `test record-receipt` certifies those commands without executing them.
|
|
432
432
|
Both support `--checkpoint` to select `tests.checkpoint` instead.
|
|
433
433
|
|
|
434
|
-
###
|
|
434
|
+
### Legacy repository hooks
|
|
435
|
+
|
|
436
|
+
Repository-local `.codex` is no longer supported by `project check`. Remove
|
|
437
|
+
existing `.codex` directories when upgrading, preserving any needed setup outside
|
|
438
|
+
the repository first. New projects do not generate them. The commands below
|
|
439
|
+
remain available for explicit legacy use and create files rejected by project validation.
|
|
435
440
|
|
|
436
441
|
Install or update the project hooks from the caller's Git worktree:
|
|
437
442
|
|
|
@@ -765,39 +770,16 @@ architecture, requirements, configuration examples, and verification limits.
|
|
|
765
770
|
The command prints the bundled [formal requirements](src/modules/projects/check-project-requirements.txt),
|
|
766
771
|
which can also be read without a repository or project configuration.
|
|
767
772
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
and runs `npm ci` using the package.json pins. It then runs
|
|
779
|
-
`peacekeeper codex init-worktree --sync-primary` followed by
|
|
780
|
-
`peacekeeper cleanup merged-branches --execute` before any project-specific setup,
|
|
781
|
-
initializing each new linked worktree from the exact commit fetched from the
|
|
782
|
-
configured remote default branch, safely synchronizing the primary checkout, and
|
|
783
|
-
removing merged branches and their linked worktrees.
|
|
784
|
-
A passing check validates the parsed script text; it does not run setup or prove
|
|
785
|
-
that a fresh environment works. Verify that separately in a new Codex worktree.
|
|
786
|
-
Prefix changes in future Peacekeeper versions require updating each project's
|
|
787
|
-
environment configuration.
|
|
788
|
-
|
|
789
|
-
The required sequence ends like this:
|
|
790
|
-
|
|
791
|
-
```toml
|
|
792
|
-
[setup]
|
|
793
|
-
script = '''
|
|
794
|
-
# ...the required Peacekeeper setup prefix...
|
|
795
|
-
npm ci
|
|
796
|
-
npm exec --no -- peacekeeper codex init-worktree --sync-primary
|
|
797
|
-
npm exec --no -- peacekeeper cleanup merged-branches --execute
|
|
798
|
-
# Add custom project setup below
|
|
799
|
-
'''
|
|
800
|
-
```
|
|
773
|
+
The repository root must not contain `.codex`, even as an empty directory, file,
|
|
774
|
+
or symbolic link. Remove it when upgrading, preserving any needed setup outside
|
|
775
|
+
the repository first. Validation reports the violation without changing files.
|
|
776
|
+
New projects omit both environment configuration and repository hooks. The legacy
|
|
777
|
+
`codex install-hooks` command still creates `.codex/hooks.json` when explicitly
|
|
778
|
+
requested; that output fails `project check`.
|
|
779
|
+
|
|
780
|
+
Prepare new worktrees explicitly: select the pinned Volta toolchain, run `npm ci`,
|
|
781
|
+
and, when needed, run `peacekeeper codex init-worktree --sync-primary` for a fresh
|
|
782
|
+
worktree. Keep project-specific setup in your external environment configuration.
|
|
801
783
|
|
|
802
784
|
`--sync-primary` makes Peacekeeper also update a clean primary checkout when its
|
|
803
785
|
default branch can be fast-forwarded safely. A clean non-default branch there is
|
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",
|
|
@@ -40,7 +40,6 @@
|
|
|
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",
|
|
@@ -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: [
|
|
14
|
+
projects: [YAML, buffer, fs, modulesRoot, output, packageVersion, path, projectConfigDefaults, runtime, semver, spawnSync, structuredClone, url]
|
|
15
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
|
});
|
|
@@ -78,33 +78,13 @@ Toolchain: package.json and all Node-based CI jobs
|
|
|
78
78
|
- run: npm ci
|
|
79
79
|
- run: npm test
|
|
80
80
|
|
|
81
|
-
Codex
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
If setup.linux, setup.macos or setup.windows overrides are present, their
|
|
89
|
-
script values must start with the same prefix to prevent bypassing setup.
|
|
90
|
-
|
|
91
|
-
Copy the reference into a TOML multiline literal string to preserve shell
|
|
92
|
-
backslashes. Preserve project-specific steps when replacing an older prefix.
|
|
93
|
-
The prefix requires Bash and curl, activates or installs Volta without editing
|
|
94
|
-
shell profiles, logs tool versions, runs npm ci using package.json pins, then
|
|
95
|
-
initializes the linked worktree and safely synchronizes the primary checkout.
|
|
96
|
-
Peacekeeper only reads this reference; it never executes the shell file or
|
|
97
|
-
the project's setup script. Passing validates declarations, not successful
|
|
98
|
-
provisioning, network access or availability of project-specific prerequisites.
|
|
99
|
-
Verify actual setup separately in a clean Codex worktree. New prefix versions
|
|
100
|
-
require updating consumer configurations.
|
|
101
|
-
|
|
102
|
-
Codex lifecycle hooks
|
|
103
|
-
.codex/hooks.json must contain the current peacekeeper hooks exactly once
|
|
104
|
-
for each lifecycle event, in their expected order, without group conditions.
|
|
105
|
-
Unrelated hooks are allowed. Repair with:
|
|
106
|
-
peacekeeper codex install-hooks
|
|
107
|
-
Hook installation does not itself grant Codex trust.
|
|
81
|
+
Codex configuration
|
|
82
|
+
The repository root must not contain .codex, including an empty directory,
|
|
83
|
+
file or symbolic link. Remove existing repository-local Codex configuration.
|
|
84
|
+
Preserve any needed setup outside the repository before removing it.
|
|
85
|
+
Project validation only reports the path; it does not delete or migrate files.
|
|
86
|
+
New projects do not generate .codex. The legacy codex install-hooks command
|
|
87
|
+
still creates .codex/hooks.json explicitly and therefore conflicts with this rule.
|
|
108
88
|
|
|
109
89
|
All GitHub Actions workflows
|
|
110
90
|
Every .yml/.yaml file under .github/workflows must parse and declare jobs.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export default ({ configuration,
|
|
1
|
+
export default ({ configuration, releases, external: { fs, modulesRoot, output, path, runtime, semver, YAML, } }) => {
|
|
2
2
|
const { projectConfig } = configuration;
|
|
3
|
-
const { planHooks, classifyCommand } = installHooks;
|
|
4
3
|
const { inspectWorkflow, ensureLockfilesMatch } = releases;
|
|
5
4
|
function read(root, file, parse = JSON.parse) {
|
|
6
5
|
try {
|
|
@@ -145,33 +144,8 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
145
144
|
});
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
|
-
check('
|
|
149
|
-
|
|
150
|
-
const document = read(root, file, TOML.parse);
|
|
151
|
-
requireThat(document.version === 1, `${file}: version must be 1.`);
|
|
152
|
-
const prefix = fs.readFileSync(path.join(modulesRoot, 'projects/codex-setup-prefix.sh'), 'utf8');
|
|
153
|
-
requireThat(typeof document.setup?.script === 'string' && document.setup.script.startsWith(prefix), `${file}: setup.script must start with the exact prefix below, including the newline after the final comment. Preserve custom project setup after that comment.\n${prefix}`);
|
|
154
|
-
// Platform overrides replace the default setup and must preserve its contract too.
|
|
155
|
-
for (const platform of ['linux', 'macos', 'windows']) {
|
|
156
|
-
if (!Object.hasOwn(document.setup || {}, platform))
|
|
157
|
-
continue;
|
|
158
|
-
const script = document.setup[platform]?.script;
|
|
159
|
-
requireThat(typeof script === 'string' && script.startsWith(prefix), `${file}: setup.${platform}.script must start with the same required setup prefix.\n${prefix}`);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
check('hooks', () => {
|
|
163
|
-
const document = read(root, '.codex/hooks.json');
|
|
164
|
-
const localSource = fs.realpathSync(root) === fs.realpathSync(path.resolve(modulesRoot, '../../..'));
|
|
165
|
-
const expected = planHooks(document, localSource).document;
|
|
166
|
-
for (const event of new Set([...Object.keys(document.hooks || {}), ...Object.keys(expected.hooks)])) {
|
|
167
|
-
const owned = groups => groups.flatMap(group => {
|
|
168
|
-
const handlers = group.hooks.filter(hook => classifyCommand(hook.command) !== 'other');
|
|
169
|
-
if (handlers.length)
|
|
170
|
-
requireThat(Object.keys(group).every(key => key === 'hooks'), '.codex/hooks.json: peacekeeper lifecycle hooks must not have group conditions.');
|
|
171
|
-
return handlers;
|
|
172
|
-
});
|
|
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
|
-
}
|
|
147
|
+
check('Codex configuration', () => {
|
|
148
|
+
requireThat(!fs.lstatSync(path.join(root, '.codex'), { throwIfNoEntry: false }), '.codex must be removed from the repository root; repository-local Codex configuration is no longer supported. Preserve any needed setup outside the repository before removing it.');
|
|
175
149
|
});
|
|
176
150
|
const published = config.publishesToNpm;
|
|
177
151
|
check('publication', () => {
|
|
@@ -329,7 +303,7 @@ export default ({ configuration, installHooks, releases, external: { fs, isDeepS
|
|
|
329
303
|
runtime.exitCode = 1;
|
|
330
304
|
}
|
|
331
305
|
else
|
|
332
|
-
output.log(`Project checks passed: package, tools,
|
|
306
|
+
output.log(`Project checks passed: package, tools, Codex configuration, CI${published ? ', publication' : ' (publishesToNpm=false; publication skipped)'}.`);
|
|
333
307
|
}
|
|
334
308
|
function run(options = {}) {
|
|
335
309
|
try {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export default ({
|
|
2
|
-
const { planHooks } = installHooks;
|
|
1
|
+
export default ({ external: { fs, modulesRoot, packageVersion, path, projectConfigDefaults, runtime, spawnSync, url: Url, YAML, } }) => {
|
|
3
2
|
const TOOLCHAIN = Object.freeze({
|
|
4
3
|
node: '22.14.0',
|
|
5
4
|
npm: '11.21.0',
|
|
@@ -128,9 +127,6 @@ export default ({ installHooks, external: { fs, modulesRoot, packageVersion, pat
|
|
|
128
127
|
defaults.tests.all = ['npm run typecheck', 'npm run build', 'npm run test:unit', ...(options.published ? ['npm run test:package'] : [])];
|
|
129
128
|
defaults.tests.npmTestUsesRunner = true;
|
|
130
129
|
write(root, 'peacekeeper.config.yaml', YAML.stringify(defaults, { lineWidth: 0 }));
|
|
131
|
-
write(root, '.codex/hooks.json', json(planHooks({}).document));
|
|
132
|
-
const prefix = fs.readFileSync(path.join(modulesRoot, 'projects/codex-setup-prefix.sh'), 'utf8');
|
|
133
|
-
write(root, '.codex/environments/environment.toml', `version = 1\nname = ${JSON.stringify(options.repositoryName)}\n\n[setup]\nscript = '''\n${prefix}'''\n`);
|
|
134
130
|
write(root, '.github/workflows/test.yml', workflow(options.published));
|
|
135
131
|
write(root, '.github/CODEOWNERS', `* @${options.owner}\n`);
|
|
136
132
|
if (options.published)
|
package/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",
|
|
@@ -40,7 +40,6 @@
|
|
|
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",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Stop setup if a command or any part of a pipeline fails.
|
|
2
|
-
set -eo pipefail
|
|
3
|
-
|
|
4
|
-
# Put Volta's shims first in PATH so package.json selects Node and npm versions.
|
|
5
|
-
export VOLTA_HOME="${VOLTA_HOME:-$HOME/.volta}"
|
|
6
|
-
export PATH="$VOLTA_HOME/bin:$PATH"
|
|
7
|
-
|
|
8
|
-
# Install Volta if missing, without modifying shell profiles.
|
|
9
|
-
if ! command -v volta >/dev/null 2>&1; then
|
|
10
|
-
curl --proto '=https' --tlsv1.2 -fsS https://get.volta.sh | bash -s -- --skip-setup
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
# Log tool versions to help diagnose setup failures.
|
|
14
|
-
volta --version
|
|
15
|
-
node --version
|
|
16
|
-
npm --version
|
|
17
|
-
|
|
18
|
-
# Install the exact dependency versions recorded in the lockfile.
|
|
19
|
-
npm ci
|
|
20
|
-
|
|
21
|
-
# Initialize the linked worktree and safely synchronize the primary checkout.
|
|
22
|
-
npm exec --no -- peacekeeper codex init-worktree --sync-primary
|
|
23
|
-
npm exec --no -- peacekeeper cleanup merged-branches --execute
|
|
24
|
-
|
|
25
|
-
# Add custom project setup below
|