@jakobm/peacekeeper 0.28.0 → 0.30.1

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.
@@ -12,10 +12,27 @@ Purpose and scope
12
12
  of problems behind those prerequisites. Fix them and run the command again.
13
13
  --explain prints this entire document without loading or checking a project.
14
14
 
15
+ Strict version history
16
+ strictVersionHistory is an optional top-level boolean, defaulting to false
17
+ even in existing files. project update-config inserts an explicit false.
18
+ github check always verifies GitHub protection. When strictVersionHistory is
19
+ true, it also requires the incoming package.json version to be strictly
20
+ greater by semver precedence than the actual default branch version on GitHub.
21
+ The default branch package is fetched by immutable commit SHA. API failures,
22
+ missing or invalid versions, equal versions, and lower versions fail the check.
23
+ Strict required checks force parallel PRs to update and rerun after a merge.
24
+ Offline project check, local tests, checkpoints and publication verification
25
+ do not perform this incoming-version comparison. PR workflows must use
26
+ github check; older verification command names are unsupported.
27
+ This applies to future first-parent merges; it does not audit old history
28
+ or require every version to be published. With strict history, release publish
29
+ publishes the existing default-branch version without a version-bump PR.
30
+
15
31
  Project configuration
16
32
  package.json is required at the Git root. Without peacekeeper.config.yaml,
17
33
  bundled defaults apply. An existing configuration must declare every schema
18
- field, including nested fields; unknown fields and invalid values fail.
34
+ field, including nested fields, except the optional strictVersionHistory boolean
35
+ and tests.aptPackages and tests.playwrightBrowsers lists; unknown fields and invalid values fail.
19
36
  Run peacekeeper project update-config to create or complete it without overwriting
20
37
  existing values. Migrate tests.commands to tests.all and add tests.checkpoint
21
38
  as an empty list. Review inserted defaults. Empty tests.all blocks tests
@@ -107,13 +124,15 @@ Required PR workflow and jobs
107
124
  in separate workflows.
108
125
 
109
126
  Each required name must match exactly one static job display name (name), or
110
- the job ID if name is absent. Expressions in required names are rejected.
111
- Required jobs and all their needs dependencies must use local steps, must
127
+ the job ID if name is absent. For an approved reusable PR call, use the full
128
+ GitHub check name: "<caller name or ID> / test". Expressions in required names
129
+ are rejected. Required jobs and all their needs dependencies must use local
130
+ steps or the approved reusable PR workflow described below, must
112
131
  not allow failure, and must not have conditions that skip required PR checks.
113
132
  Accepted job conditions are absent, success(), ${{ success() }}, or exactly:
114
133
  ${{ github.event_name == 'pull_request' }}
115
134
 
116
- Each required test job must run unconditional npm ci before an unconditional
135
+ Each required test job using local steps must run unconditional npm ci before an unconditional
117
136
  supported validation command, with neither step allowed to fail. Commands
118
137
  must be direct run steps, exactly one of:
119
138
  npm test
@@ -121,11 +140,59 @@ Required PR workflow and jobs
121
140
  npm run test:<name> (name contains letters, digits, _ or -)
122
141
  npm pack --dry-run
123
142
  npm pack --dry-run --json
124
- Shell wrappers, combined commands, and reusable workflows cannot establish
143
+ Shell wrappers, combined commands, and unapproved reusable workflows cannot establish
125
144
  these requirements. Conditional reporting steps after tests are allowed.
126
145
  An unconditional step either omits if or sets it to success() or
127
146
  ${{ success() }}.
128
147
 
148
+ Standard CI preparation
149
+ Optional tests.aptPackages and tests.playwrightBrowsers lists default to empty.
150
+ Apt entries select Ubuntu packages with optional exact versions. Playwright
151
+ browsers select chromium, firefox or webkit from the project's installed CLI.
152
+ An empty browser list skips browser and Playwright system dependency installation.
153
+ The standard PR job runs test prepare after npm ci, before npm test, and validates
154
+ project configuration independently of the chosen test engine. The lists must
155
+ contain unique nonempty strings; invalid package names and browsers fail.
156
+ Keep the intended verification in npm test and additional workflow behavior
157
+ in repository-defined GitHub Actions steps. See README for the full contract.
158
+
159
+ Approved reusable PR workflow
160
+ Instead of repeating setup, policy verification and test steps in every repo,
161
+ call the central workflow with a full SHA approved by this Peacekeeper version:
162
+ jobs:
163
+ test:
164
+ uses: jakobmattsson/peacekeeper/.github/workflows/reusable-pr.yml@071a6102729107f4f4f01851e0b661355985a676
165
+ secrets:
166
+ RELEASE_POLICY_TOKEN: ${{ secrets.RELEASE_POLICY_TOKEN }}
167
+ Declare permissions.contents as read (or write) at the caller job or workflow.
168
+ Keep the caller's PR trigger and branch restriction described above. The central
169
+ workflow owns checkout, Volta, npm ci, github check and npm test.
170
+ The consumer must install a Peacekeeper version supporting this contract as a project dependency.
171
+
172
+ Set both projectChecks.requiredJobs and git.releaseRequiredChecks to include
173
+ "test / test" (or "<caller name> / test" with an explicit name). Npm projects
174
+ must also set git.releaseTestWorkflow to projectChecks.testWorkflow. Require
175
+ the same full context in GitHub protection and verify it in a PR run.
176
+
177
+ No inputs are accepted. Put project-specific checks, including packaging, in
178
+ tests.all. Only the explicitly mapped RELEASE_POLICY_TOKEN secret
179
+ is accepted; its value must reference a repository secret. Inherited secrets,
180
+ arbitrary inputs, matrices, runner/step/environment overrides and ignored
181
+ failures are rejected. Required-job conditions and needs checks still apply.
182
+
183
+ The approved workflow path and commit SHAs are bundled in
184
+ releases/reusable-workflows.json. Local checks validate this caller contract
185
+ without downloading or expanding the central workflow. Unknown SHAs, branches
186
+ and tags are rejected. Other reusable workflows cannot replace required jobs.
187
+ Inline required jobs continue to use the detailed local-step rules above.
188
+ Publication can call reusable-publish.yml at a SHA in that allowlist through
189
+ a separate caller workflow.
190
+ Keep the local push tags trigger and explicit secret mapping. Declare contents:
191
+ read and id-token: write in the caller; the callee cannot raise its permissions.
192
+ This workflow owns setup, npm ci, release verify and npm publish. It accepts no
193
+ inputs and exposes one static publish job, producing "publish / publish".
194
+ Keep the caller filename registered with npm trusted publishing.
195
+
129
196
  Matrix example: tests on three platforms and one static required gate:
130
197
  jobs:
131
198
  matrix-tests:
@@ -212,9 +279,8 @@ Publication: publishesToNpm=true
212
279
  directly invoke peacekeeper release publish (also supported: npm exec --no --
213
280
  peacekeeper release publish or the local Node CLI forms). Run releases through
214
281
  npm run release so npm does not bypass the prerelease installation.
215
- The selected PR workflow must declare an unconditional packaging check after
216
- npm ci: npm pack (optionally
217
- --dry-run, optionally followed by --json), or npm run test:package.
282
+ Put packaging checks in tests.all, such as npm pack --dry-run --json or
283
+ npm run test:package. No workflow step receives special packaging treatment.
218
284
  npm script aliases are resolved without executing them. Package installation
219
285
  tests using a temporary consumer are recommended; script names do not prove
220
286
  assertion coverage. npm publish must not be conditional or allowed to fail.
@@ -229,11 +295,11 @@ Publication: publishesToNpm=true
229
295
  Internal packing, prepack/build scripts, main/exports/types/bin, deployment
230
296
  workflows, OIDC for other services, and dependency read authentication remain
231
297
  allowed. Workflow filenames and job names alone do not imply npm publication.
232
- Toolchain, hooks, PR checks and release verify-protection still apply.
298
+ Toolchain, hooks, PR checks and github check still apply.
233
299
 
234
300
  Online release policy and GitHub token setup
235
301
  These are online installation requirements; project check only verifies the
236
- local declarations above. Use release verify-protection to check the branch
302
+ local declarations above. Use github check to check the branch
237
303
  policy and release verify before publishing to check the release itself.
238
304
 
239
305
  Enable "Automatically delete head branches" (delete_branch_on_merge=true) in
@@ -279,15 +345,22 @@ Online release policy and GitHub token setup
279
345
  Fork PRs do not receive repository secrets; do not expose this token by
280
346
  running fork code with pull_request_target.
281
347
 
282
- release verify-protection uses GITHUB_BASE_REF, or git.defaultBranch outside
283
- PR CI. It can be run before tests in a required trusted PR job. release verify
348
+ github check reads the actual default branch from GitHub. It can be run before
349
+ tests in a required trusted PR job. release verify
284
350
  checks matching package/tag/lockfile versions, that the tagged commit belongs
285
351
  to the default branch and is the merge commit of a same-repository merged
286
- release/v<version> PR, and the latest selected PR workflow run and required
352
+ PR (regardless of branch name), and the latest selected PR workflow run and required
287
353
  jobs. The workflow and all matching required jobs must conclude success.
288
- A manually created tag without that release PR is rejected. API access errors
289
- and unverifiable protection settings stop verification. Use the release
290
- command to prepare the release PR and tag through the supported workflow.
354
+ A tag without a qualifying merged PR is rejected. API access errors
355
+ and unverifiable protection settings stop verification. Use npm run release
356
+ to publish the existing version at the fetched default-branch commit. It checks
357
+ the merged PR and CI before tagging; the publish workflow verifies them again.
358
+ With strictVersionHistory true, --bump is rejected because versions must be
359
+ assigned before merge. With false, an unpublished existing version can be
360
+ released directly, or npm run release -- --bump patch (minor/major) prepares
361
+ a version-bump PR, waits for merge, then tags its merge commit. Already-published
362
+ versions and registry access errors stop a new release. Retries reuse the
363
+ pinned revision, PR and matching tag rather than creating another bump.
291
364
 
292
365
  Complete npm trusted-publishing example with Volta
293
366
  Keep publishing in a separate publish.yml as shown below, with exactly one
@@ -382,7 +455,8 @@ Using this check in the test chain
382
455
  existing receipt. This check remains entirely local.
383
456
 
384
457
  Default-branch GitHub policy chain
385
- The configured PR workflow must run release verify-protection with step GH_TOKEN
458
+ The configured PR workflow must use the approved reusable PR workflow in a
459
+ required release job, or run github check with step GH_TOKEN
386
460
  after npm ci and before tests in at least one job in git.releaseRequiredChecks.
387
461
  Verification must be unconditional and must not allow failure. The existing
388
462
  required-job validation applies to that job and its dependencies.
@@ -1,6 +1,7 @@
1
+ // --- Implementation ---
1
2
  export default ({ configuration, releases, external: { fs, modulesRoot, output, path, runtime, semver, YAML, } }) => {
2
3
  const { projectConfig } = configuration;
3
- const { inspectWorkflow, ensureLockfilesMatch } = releases;
4
+ const { inspectWorkflow, ensureLockfilesMatch, reusableWorkflow, reusableWorkflowErrors } = releases;
4
5
  function read(root, file, parse = JSON.parse) {
5
6
  try {
6
7
  return parse(fs.readFileSync(path.join(root, file), 'utf8'));
@@ -18,6 +19,11 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
18
19
  const testCommand = /^npm (?:test|run test(?::[\w-]+)?|pack --dry-run(?: --json)?)$/u;
19
20
  const installCommand = /^npm ci$/u;
20
21
  const verifyCommand = /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) (?:release verify|verify-release)$/u;
22
+ const reusable = reusableWorkflow('pr');
23
+ function checkName(id, job) {
24
+ const name = job.name || id;
25
+ return job.uses ? `${name} / ${reusable.jobName}` : name;
26
+ }
21
27
  function checkProject(cwd = runtime.cwd()) {
22
28
  const config = projectConfig(cwd);
23
29
  const root = config.root;
@@ -144,6 +150,19 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
144
150
  });
145
151
  }
146
152
  }
153
+ const centralJobs = new Set();
154
+ for (const [file, workflow] of workflows)
155
+ for (const [id, job] of Object.entries(workflow.jobs)) {
156
+ if (typeof job?.uses !== 'string' || !job.uses.startsWith(`${reusable.workflow}@`))
157
+ continue;
158
+ check('CI', () => {
159
+ const before = errors.length;
160
+ for (const error of reusableWorkflowErrors('pr', job, workflow.permissions))
161
+ requireThat(false, `${file}/${id}: ${error}`);
162
+ if (errors.length === before)
163
+ centralJobs.add(job);
164
+ });
165
+ }
147
166
  check('Codex configuration', () => {
148
167
  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.');
149
168
  });
@@ -176,16 +195,6 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
176
195
  requireThat(Array.isArray(manifest.files) && manifest.files.length > 0 && manifest.files.every(nonblank), 'package.json: published packages require a nonempty files list.');
177
196
  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.');
178
197
  requireThat(typeof scripts.release === 'string' && releaseCommand.test(scripts.release.trim()), 'package.json: scripts.release must invoke peacekeeper release publish directly.');
179
- const testWorkflow = workflows.get(config.projectChecks.testWorkflow);
180
- requireThat(testWorkflow && Object.values(testWorkflow.jobs).some((rawJob) => {
181
- const job = rawJob;
182
- const steps = job.steps || [];
183
- const installed = steps.findIndex(step => directCommand(step, installCommand)
184
- && unconditional(step.if) && !step['continue-on-error']);
185
- return unconditional(job.if) && !job['continue-on-error'] && installed >= 0
186
- && steps.some((step, index) => index > installed && unconditional(step.if)
187
- && !step['continue-on-error'] && commands(step.run).some(command => /^npm (?:pack(?: --dry-run(?: --json)?)?|run test:package)$/u.test(command)));
188
- }), 'Add an unconditional npm pack or npm run test:package CI check after npm ci in projectChecks.testWorkflow for published packages.');
189
198
  }
190
199
  else {
191
200
  for (const field of ['publishConfig', 'files'])
@@ -195,6 +204,7 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
195
204
  for (const [file, workflow] of workflows)
196
205
  for (const [id, rawJob] of Object.entries(workflow.jobs)) {
197
206
  const job = rawJob;
207
+ requireThat(!(typeof job.uses === 'string' && job.uses.startsWith(`${reusableWorkflow('publish').workflow}@`)), `${file}/${id}: remove npm publication steps when publishesToNpm=false.`);
198
208
  for (const step of job.steps || [])
199
209
  requireThat(!publicationCommand(step.run)
200
210
  && !/npm-publish/iu.test(step.uses || ''), `${file}/${id}: remove npm publication steps when publishesToNpm=false.`);
@@ -224,7 +234,8 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
224
234
  if (!requireThat(job && typeof job === 'object', `${filename}/${id}: required job is missing; checks for this job are blocked.`))
225
235
  return;
226
236
  requireThat(unconditional(job.if) || job.if === "${{ github.event_name == 'pull_request' }}", `${filename}/${id}: required PR job must not be skipped by an if condition.`);
227
- requireThat(!job['continue-on-error'] && !job.uses, `${filename}/${id}: required jobs must have verifiable local steps and must not allow failure.`);
237
+ requireThat(!job['continue-on-error'], `${filename}/${id}: required jobs must not allow failure.`);
238
+ requireThat(!job.uses || centralJobs.has(job), `${filename}/${id}: required jobs must have verifiable local steps or use the approved reusable PR workflow.`);
228
239
  if (checked.has(id))
229
240
  return;
230
241
  checked.add(id);
@@ -233,10 +244,15 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
233
244
  requiredJob(dependency, jobs[dependency], false);
234
245
  if (!testsRequired)
235
246
  return;
247
+ if (job.uses) {
248
+ if (centralJobs.has(job) && config.git.releaseRequiredChecks.includes(checkName(id, job)))
249
+ policyJobs += 1;
250
+ return;
251
+ }
236
252
  const steps = job.steps || [];
237
253
  const installed = steps.findIndex(step => directCommand(step, installCommand) && unconditional(step.if) && !step['continue-on-error']);
238
254
  const tested = steps.findIndex(step => directCommand(step, testCommand) && unconditional(step.if) && !step['continue-on-error']);
239
- 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)
255
+ const policy = steps.findIndex(step => directCommand(step, /^(?:peacekeeper|npm exec --no -- peacekeeper|node (?:\.\/)?(?:node_modules\/@jakobm\/peacekeeper\/)?(?:dist\/)?bin\/peacekeeper\.js) github check$/u)
240
256
  && unconditional(step.if) && !step['continue-on-error'] && step.env?.GH_TOKEN);
241
257
  if (policy > installed && installed >= 0 && policy < tested && config.git.releaseRequiredChecks.includes(job.name || id))
242
258
  policyJobs += 1;
@@ -244,14 +260,14 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
244
260
  }
245
261
  for (const name of required) {
246
262
  const matching = Object.entries(jobs)
247
- .filter(([id, job]) => (job.name || id) === name);
263
+ .filter(([id, job]) => checkName(id, job) === name);
248
264
  if (!requireThat(matching.length === 1 && !name.includes('${{'), `${filename}: required job ${name} must have a unique static name. Match a job name (or ID when name is absent); checks for this job are blocked.`))
249
265
  continue;
250
266
  // Validate the test steps even if this job was visited as a dependency.
251
267
  checked.clear();
252
268
  requiredJob(...matching[0], true);
253
269
  }
254
- requireThat(policyJobs > 0, `${filename}: a job in git.releaseRequiredChecks must run unconditional release verify-protection with GH_TOKEN after npm ci and before tests.`);
270
+ requireThat(policyJobs > 0, `${filename}: a job in git.releaseRequiredChecks must run unconditional github check with GH_TOKEN after npm ci and before tests.`);
255
271
  });
256
272
  if (published)
257
273
  check('publication', () => {
@@ -272,6 +288,9 @@ export default ({ configuration, releases, external: { fs, modulesRoot, output,
272
288
  if (!workflow)
273
289
  throw new Error(`${publishing.path}: selected publish workflow was not loaded.`);
274
290
  const job = workflow.jobs.publish;
291
+ // inspectWorkflow already validates approved reusable publication callers.
292
+ if (job.uses)
293
+ return;
275
294
  const steps = job.steps || [];
276
295
  requireThat(!job['continue-on-error'], `${publishing.path}: publication must not allow failure.`);
277
296
  const installed = steps.findIndex(step => directCommand(step, installCommand) && unconditional(step.if) && !step['continue-on-error']);
@@ -1,4 +1,4 @@
1
- export default ({ external: { fs, modulesRoot, packageVersion, path, projectConfigDefaults, runtime, spawnSync, url: Url, YAML, } }) => {
1
+ export default ({ releases, external: { fs, modulesRoot, packageVersion, path, projectConfigDefaults, runtime, spawnSync, url: Url, YAML, } }) => {
2
2
  const TOOLCHAIN = Object.freeze({
3
3
  node: '22.14.0',
4
4
  npm: '11.21.0',
@@ -61,11 +61,17 @@ export default ({ external: { fs, modulesRoot, packageVersion, path, projectConf
61
61
  fs.mkdirSync(path.dirname(target), { recursive: true });
62
62
  fs.writeFileSync(target, contents, { mode });
63
63
  }
64
- function workflow(published) {
65
- 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` : ''}`;
66
- }
67
- function publishWorkflow() {
68
- 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`;
64
+ function workflow(kind) {
65
+ const definition = releases.reusableWorkflow(kind);
66
+ const id = kind === 'pr' ? 'test' : 'publish';
67
+ return YAML.stringify({
68
+ on: kind === 'pr' ? { pull_request: { branches: ['main'] } } : { push: { tags: ['v*'] } },
69
+ permissions: { contents: 'read', ...(kind === 'publish' ? { 'id-token': 'write' } : {}) },
70
+ jobs: { [id]: {
71
+ uses: `${definition.workflow}@${definition.refs.at(-1)}`,
72
+ secrets: { RELEASE_POLICY_TOKEN: '${{ secrets.RELEASE_POLICY_TOKEN }}' },
73
+ } },
74
+ }, { lineWidth: 0 });
69
75
  }
70
76
  function renderTemplate(filename, replacements) {
71
77
  let template = fs.readFileSync(path.join(modulesRoot, `projects/${filename}`), 'utf8');
@@ -124,13 +130,15 @@ export default ({ external: { fs, modulesRoot, packageVersion, path, projectConf
124
130
  const defaults = JSON.parse(JSON.stringify(projectConfigDefaults));
125
131
  defaults.publishesToNpm = options.published;
126
132
  defaults.git.requiredApprover = options.owner;
133
+ defaults.git.releaseRequiredChecks = ['test / test'];
134
+ defaults.projectChecks.requiredJobs = ['test / test'];
127
135
  defaults.tests.all = ['npm run typecheck', 'npm run build', 'npm run test:unit', ...(options.published ? ['npm run test:package'] : [])];
128
136
  defaults.tests.npmTestUsesRunner = true;
129
137
  write(root, 'peacekeeper.config.yaml', YAML.stringify(defaults, { lineWidth: 0 }));
130
- write(root, '.github/workflows/test.yml', workflow(options.published));
138
+ write(root, '.github/workflows/test.yml', workflow('pr'));
131
139
  write(root, '.github/CODEOWNERS', `* @${options.owner}\n`);
132
140
  if (options.published)
133
- write(root, '.github/workflows/publish.yml', publishWorkflow());
141
+ write(root, '.github/workflows/publish.yml', workflow('publish'));
134
142
  write(root, '.gitignore', 'node_modules/\n*.tgz\ntmp/\n');
135
143
  write(root, 'README.md', `# ${options.repositoryName}\n\nA TypeScript library generated by Peacekeeper.\n\n## API\n\n\`hello()\` returns \`"hello world"\`.\n`);
136
144
  write(root, 'LICENSE', `MIT License\n\nCopyright (c) ${options.authorName}\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n`);
@@ -1,9 +1,10 @@
1
1
  export default ({ configuration, releaseCore, external: { assessReleaseSchema: schema, fs, modulesRoot, os, path, runtime, semver, spawnSync: defaultSpawnSync, } }) => {
2
2
  const { projectConfig } = configuration;
3
3
  const { originRepository } = releaseCore;
4
- function assessmentPrompt({ name, version, previousReleaseSha, releaseSha }) {
4
+ function assessmentPrompt({ name, version, targetVersion, previousReleaseSha, releaseSha }) {
5
5
  return `Assess whether ${JSON.stringify(name)} needs a new npm release. This is an assessment only.
6
6
  The last published stable version is ${version}, at commit ${previousReleaseSha}.
7
+ The target package version is ${targetVersion}; an existing version bump is not evidence of the required release level.
7
8
  The target is commit ${releaseSha}, the fetched default branch. Assess ONLY ${previousReleaseSha}..${releaseSha}.
8
9
  Inspect the complete changes with git diff, git log and git show. Read relevant source files,
9
10
  README, package metadata and tests to understand the public API, CLI and user-visible behavior.
@@ -94,8 +95,8 @@ Do not delegate or launch other agents. Only read and assess; do not execute the
94
95
  const candidateSha = run('git', ['rev-parse', '--verify', `${ref}^{commit}`]);
95
96
  run('git', ['merge-base', '--is-ancestor', candidateSha, releaseSha]);
96
97
  const baseline = JSON.parse(run('git', ['show', `${candidateSha}:package.json`]));
97
- if (baseline.name !== name || baseline.version !== version || manifest.version !== version) {
98
- throw new Error('Published version, release tag and default branch package metadata disagree.');
98
+ if (baseline.name !== name || baseline.version !== version) {
99
+ throw new Error('Published version and release tag package metadata disagree.');
99
100
  }
100
101
  const metadata = JSON.parse(run('npm', ['view', `${name}@${version}`, '--json',
101
102
  '--registry', 'https://registry.npmjs.org/', '--prefer-online']));
@@ -111,7 +112,7 @@ Do not delegate or launch other agents. Only read and assess; do not execute the
111
112
  '-c', 'model_reasoning_effort="low"', '-c', 'model_verbosity="low"',
112
113
  '--ephemeral', '--output-schema', path.join(modulesRoot, 'releases/assess-release-schema.json'),
113
114
  '--output-last-message', output, '-'], worktree, {
114
- input: assessmentPrompt({ name, version, previousReleaseSha, releaseSha }), timeout: 20 * 60_000,
115
+ input: assessmentPrompt({ name, version, targetVersion: manifest.version, previousReleaseSha, releaseSha }), timeout: 20 * 60_000,
115
116
  });
116
117
  const { recommendation, motivation } = validateAssessment(JSON.parse(fs.readFileSync(output, 'utf8')));
117
118
  return { recommendation, model, releaseSha, previousReleaseSha, motivation };
@@ -0,0 +1,27 @@
1
+ // --- Implementation ---
2
+ export default ({ configuration, releaseCore, releaseProtection, versionHistory, external: { output, runtime, spawnSync, } }) => {
3
+ function check(cwd = runtime.cwd()) {
4
+ const config = configuration.projectConfig(cwd);
5
+ const remote = spawnSync('git', ['remote', 'get-url', config.git.remote], { cwd, encoding: 'utf8' });
6
+ if (remote.status !== 0)
7
+ throw new Error(remote.stderr);
8
+ const { host, slug } = releaseCore.originRepository(remote.stdout.trim());
9
+ const api = releaseProtection.githubApi((command, args, options) => spawnSync(command, args, { ...options, encoding: 'utf8' }), cwd, host);
10
+ const branch = api(`repos/${slug}`).default_branch;
11
+ releaseProtection.verifyProtection({ api, slug, branch,
12
+ ...releaseProtection.requiredPolicy(cwd), warn: message => output.warn(message) });
13
+ if (config.strictVersionHistory) {
14
+ versionHistory.verifyVersionHistory({ api, slug, branch, root: config.root });
15
+ }
16
+ }
17
+ function run() {
18
+ try {
19
+ check();
20
+ }
21
+ catch (error) {
22
+ output.error(error instanceof Error ? error.message : String(error));
23
+ runtime.exitCode = 1;
24
+ }
25
+ }
26
+ return { run };
27
+ };
@@ -1,12 +1,14 @@
1
- export const porticoFacade = ({ assessRelease, configureGithub, githubConfiguration, githubPolicy, release, releaseCore, verifyRelease, verifyReleaseProtection, verifyReleaseVersion }) => ({
1
+ export const porticoFacade = ({ assessRelease, checkGithub, configureGithub, githubConfiguration, githubPolicy, release, releaseCore, reusableWorkflows, verifyRelease, verifyReleaseVersion }) => ({
2
2
  assessRelease: assessRelease.run,
3
+ checkGithub: checkGithub.run,
3
4
  configureGithub: configureGithub.run,
4
5
  planGithub: githubConfiguration.plan,
5
6
  createGithubPolicy: githubPolicy.createGithubPolicy,
6
7
  ensureLockfilesMatch: releaseCore.ensureLockfilesMatch,
7
8
  inspectWorkflow: releaseCore.inspectWorkflow,
9
+ reusableWorkflow: reusableWorkflows.definition,
10
+ reusableWorkflowErrors: reusableWorkflows.callErrors,
8
11
  release: release.run,
9
12
  verifyRelease: verifyRelease.run,
10
- verifyReleaseProtection: verifyReleaseProtection.run,
11
13
  verifyReleaseVersion: verifyReleaseVersion.run,
12
14
  });