@se-studio/skills 1.10.27 → 1.14.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.
@@ -20,6 +20,14 @@ const repoRoot = join(here, '..', '..', '..', '..');
20
20
  /** First `@se-studio/skills` release that understands the promote line `CI covers the changes since`. */
21
21
  export const SKILLS_PROMOTE_LINE_MIN = '1.10.7';
22
22
 
23
+ /**
24
+ * A site whose cms-driven.baseline.json holds more than this many violations needs work.
25
+ * Keep equal to DEBT_THRESHOLD in @se-studio/site-check (a test checks this).
26
+ */
27
+ export const BASELINE_DEBT_MAX = 25;
28
+ /** A baseline this many days old with debt still in it has stopped shrinking. */
29
+ export const BASELINE_STALE_DAYS = 90;
30
+
23
31
  /** Compare `1.2.3` style versions; anything unparsable sorts as 0.0.0. */
24
32
  export function compareVersions(a, b) {
25
33
  const parse = (v) => (String(v).match(/\d+/g) ?? []).slice(0, 3).map(Number);
@@ -42,7 +50,13 @@ const numeric = (spec) => String(spec).replace(/^[^\d]*/, '');
42
50
  * @returns {{ findings: {id: string, owner: 'core'|'customer', text: string}[],
43
51
  * pins: Record<string, {spec: string, where: string}[]> }}
44
52
  */
45
- export function auditFiles({ files, tree = [], coreBlockVersion, coreVersions }) {
53
+ export function auditFiles({
54
+ files,
55
+ tree = [],
56
+ coreBlockVersion,
57
+ coreVersions,
58
+ today = new Date().toISOString().slice(0, 10),
59
+ }) {
46
60
  const findings = [];
47
61
  const add = (id, owner, text) => findings.push({ id, owner, text });
48
62
  /** @type {Record<string, {spec: string, where: string}[]>} */
@@ -208,6 +222,21 @@ export function auditFiles({ files, tree = [], coreBlockVersion, coreVersions })
208
222
  '.claude/settings.json does not run `claude-pretool.mjs` (copy customer-guardrails/claude-settings.json)',
209
223
  );
210
224
  }
225
+ const claudeSettings = files['.claude/settings.json'] ?? '';
226
+ if (/claude-pretool/.test(claudeSettings) && !/mcp__/.test(claudeSettings)) {
227
+ add(
228
+ 'claude-mcp-matcher-missing',
229
+ 'customer',
230
+ '.claude/settings.json PreToolUse matcher lacks `mcp__.*`: an MCP merge tool (mcp__github__merge_pull_request) would skip the merge gate (copy customer-guardrails/claude-settings.json)',
231
+ );
232
+ }
233
+ if (!files['.claude/hooks/merge-guard.mjs']) {
234
+ add(
235
+ 'merge-guard-missing',
236
+ 'customer',
237
+ '.claude/hooks/merge-guard.mjs is missing: without `pnpm install` the Claude hook fails open and a merge is not checked (copy customer-guardrails/claude-merge-guard.mjs and register it, see customer-guardrails/README.md)',
238
+ );
239
+ }
211
240
  if (!/merge-gate/.test(files['.github/workflows/merge-gate-audit.yml'] ?? '')) {
212
241
  add(
213
242
  'merge-audit-missing',
@@ -249,9 +278,100 @@ export function auditFiles({ files, tree = [], coreBlockVersion, coreVersions })
249
278
  );
250
279
  }
251
280
 
281
+ const localGuard = tree.find((t) => /(^|\/)scripts\/check-cms-driven\.mjs$/.test(t.path));
282
+ if (localGuard) {
283
+ add(
284
+ 'local-cms-driven-copy',
285
+ 'customer',
286
+ `${localGuard.path} is a local copy of the colour and layout guard: use the \`check-cms-driven\` bin from @se-studio/site-check and delete the copy`,
287
+ );
288
+ }
289
+
290
+ for (const [path, body] of Object.entries(files)) {
291
+ if (!/(^|\/)cms-driven\.baseline\.json$/.test(path)) continue;
292
+ const baseline = safeJson(body);
293
+ if (!baseline || !Number.isInteger(baseline.total) || baseline.total === 0) continue;
294
+ const dir = path.slice(0, path.length - 'cms-driven.baseline.json'.length);
295
+ if (!safeJson(files[`${dir}cms-driven.config.json`] ?? '')?.r3) {
296
+ add(
297
+ 'guardrail-baseline-orphan',
298
+ 'customer',
299
+ `${path}: there is a baseline but \`${dir}cms-driven.config.json\` has no \`r3\`, so the guard is off and the debt is not being checked`,
300
+ );
301
+ }
302
+ if (baseline.total > BASELINE_DEBT_MAX) {
303
+ add(
304
+ 'guardrail-baseline-debt',
305
+ 'customer',
306
+ `${path}: ${baseline.total} baselined colour violations (over ${BASELINE_DEBT_MAX}): this site needs work. Replace literals with palette tokens, then run \`check-cms-driven --update-baseline\``,
307
+ );
308
+ }
309
+ const age = (Date.parse(today) - Date.parse(baseline.generatedAt)) / 86_400_000;
310
+ if (age > BASELINE_STALE_DAYS) {
311
+ add(
312
+ 'guardrail-baseline-stale',
313
+ 'customer',
314
+ `${path}: baseline last changed ${baseline.generatedAt} (${Math.floor(age)} days ago) with ${baseline.total} violation(s) still in it: debt is not shrinking`,
315
+ );
316
+ }
317
+ }
318
+
319
+ for (const [path, body] of Object.entries(files)) {
320
+ if (!/(^|\/)cms-driven\.config\.json$/.test(path)) continue;
321
+ const until = safeJson(body)?.remake?.until;
322
+ if (typeof until !== 'string') continue;
323
+ const daysLeft = (Date.parse(until) - Date.parse(today)) / 86_400_000;
324
+ if (daysLeft < 0) {
325
+ add(
326
+ 'remake-mode-expired',
327
+ 'customer',
328
+ `${path}: remake mode ended ${until} but is still in the config: remove it. The guard is strict again, so any copied styles not in the baseline now fail`,
329
+ );
330
+ } else {
331
+ add(
332
+ 'remake-mode-active',
333
+ 'customer',
334
+ `${path}: remake mode until ${until} (${Math.floor(daysLeft)} day(s) left): colour and CSS-island guards are relaxed. Snapshot the debt with \`check-cms-driven --update-baseline\` before it ends`,
335
+ );
336
+ }
337
+ }
338
+
252
339
  return { findings, pins };
253
340
  }
254
341
 
342
+ const GUARD_FILES = new Set([
343
+ '.husky/pre-commit',
344
+ '.husky/pre-push',
345
+ '.githooks/pre-commit',
346
+ '.githooks/pre-push',
347
+ '.claude/settings.json',
348
+ '.claude/hooks/merge-guard.mjs',
349
+ '.github/workflows/merge-gate-audit.yml',
350
+ ]);
351
+
352
+ /**
353
+ * Which tracked paths `auditFiles` needs the contents of. Shared with `se-agent-guard doctor`,
354
+ * which audits the working tree with the same checks.
355
+ * @param {string[]} paths
356
+ */
357
+ export function wantedPaths(paths) {
358
+ return paths.filter((f) => {
359
+ if (GUARD_FILES.has(f)) return true;
360
+ if (f.includes('node_modules/')) return false;
361
+ if (
362
+ f === 'AGENTS.md' ||
363
+ /^\.cursor\/rules\/[^/]+\.mdc$/.test(f) ||
364
+ /^docs\/[^/]+\.md$/.test(f)
365
+ ) {
366
+ return true;
367
+ }
368
+ return (
369
+ /(^|\/)(package\.json|cms-driven\.baseline\.json|cms-driven\.config\.json)$/.test(f) &&
370
+ f.split('/').length <= 4
371
+ );
372
+ });
373
+ }
374
+
255
375
  // ---------- git and gh plumbing (not used by tests) ----------
256
376
 
257
377
  const run = (cmd, args, cwd) =>
@@ -324,27 +444,7 @@ function readFromOrigin(path, branch) {
324
444
  mode: line.slice(0, line.indexOf(' ')),
325
445
  path: line.slice(line.indexOf('\t') + 1),
326
446
  }));
327
- const GUARD_FILES = new Set([
328
- '.husky/pre-commit',
329
- '.husky/pre-push',
330
- '.githooks/pre-commit',
331
- '.githooks/pre-push',
332
- '.claude/settings.json',
333
- '.github/workflows/merge-gate-audit.yml',
334
- ]);
335
- const wanted = tree
336
- .map((t) => t.path)
337
- .filter((f) => {
338
- if (GUARD_FILES.has(f)) return true;
339
- if (f.includes('node_modules/')) return false;
340
- if (
341
- f === 'AGENTS.md' ||
342
- /^\.cursor\/rules\/[^/]+\.mdc$/.test(f) ||
343
- /^docs\/[^/]+\.md$/.test(f)
344
- )
345
- return true;
346
- return /(^|\/)package\.json$/.test(f) && f.split('/').length <= 4;
347
- });
447
+ const wanted = wantedPaths(tree.map((t) => t.path));
348
448
  const files = {};
349
449
  for (const f of wanted) {
350
450
  const body = tryRun('git', ['show', `${ref}:${f}`], path);
@@ -0,0 +1,48 @@
1
+ # Merge review template (mandatory)
2
+
3
+ Nick, **19 Nov 2026**: this is the one canonical copy of the review comment, the merge approval comment, and the check that comes before any merge. `AGENTS.md` ("Merge approval comment", "Review before merge") and the customer agents block ("Review and merge") point here and show the same two comments.
4
+
5
+ ## Why
6
+
7
+ On 19 Nov 2026 OM1 #106, Pedestal #128, PointMe #165 and core #521 and #522 were labelled `pushed-through`. The linked review had no markdown heading containing "review" and/or no verdict word, and the merges were run by bots that never ran the gate first. Using the exact shapes below, and running the check before merging, makes that hard to get wrong.
8
+
9
+ ## Run the check first (binds every bot, agent, tool and human script)
10
+
11
+ This applies to Claude, Cursor, Grok Bot fleet bots, Codex, local scripts, and people. Whatever merges a PR runs the check first and stops if it fails.
12
+
13
+ 1. Post the review comment, then the merge approval comment (below).
14
+ 2. Run `se-agent-guard merge-gate <n> --check` (customer repos: `pnpm exec se-agent-guard merge-gate <n> --check`). It reads the open PR's current head, writes nothing, and names each failed check with a `Fix:`.
15
+ 3. Merge only with `se-agent-guard safe-merge <n>` (it runs the check, then merges with `--match-head-commit`), or `gh pr merge <n> --merge --match-head-commit <head>` after the check passed.
16
+ 4. If the check fails: **STOP.** Fix exactly what it names. Never merge anyway, and never use an MCP merge tool or `gh api .../merge`.
17
+
18
+ A production promote (`main` or `production` as the base) also needs the human ask + confirm gate (`production-merge.md`); `safe-merge` refuses it unless a human set `SE_ALLOW_PRODUCTION_MERGE=1`.
19
+
20
+ ## Review comment
21
+
22
+ Post it **before** the approval, as a PR comment, never as a GitHub "PR review".
23
+
24
+ ```markdown
25
+ ## Code review of <full head SHA>
26
+ - Head SHA: <full head SHA>
27
+ - Verdict: PASS
28
+ - Findings: <none, or one line per finding prefixed BLOCKER: or NIT:>
29
+ ```
30
+
31
+ The verdict is exactly one of `PASS`, `NITS`, `BLOCKER` (the gate also accepts `LGTM`, `approved`, `NIT`, `BLOCKERS`).
32
+
33
+ After a review, a push that changes only lint, typecheck, tests or format uses the same shape with the heading `## Review (no code change) of <full head SHA>`, verdict `PASS`, and one more line: `- Since: <link to the earlier review>`.
34
+
35
+ ## Merge approval comment
36
+
37
+ Post it after the review.
38
+
39
+ ```markdown
40
+ ## Merge approval
41
+ - Who: <name of the person who said go>
42
+ - Where: <chat or agent session, or "GitHub">
43
+ - When: <Europe/London, from `TZ=Europe/London date '+%Y-%m-%d %H:%M %Z'`>
44
+ - Head SHA: <full head SHA>
45
+ - Review: <link to the review comment, https://github.com/<owner>/<repo>/pull/<n>#issuecomment-N>
46
+ ```
47
+
48
+ The `Review:` line may instead be a line of its own that reads `none, Nick override` (or `none, approver override`); on a production promote only, a line that is exactly `CI covers the changes since`. An approval that does not name the current head needs a fresh one after every new commit.
@@ -122,7 +122,7 @@ Step-by-step guides are available as **Cursor skills**. Use them when creating o
122
122
  | **CMS guidelines — orchestration** (full **fresh** clean regen vs **sync** incremental + stale removal vs **merge-only**) | `.agents/skills/contentful-cms-update-cms-guidelines/SKILL.md` — if the user is vague (“regenerate guidelines”), confirm **fresh** vs **sync** before acting |
123
123
  | **CMS guidelines — fragments** (full / single / merge-only; prefer **update-cms-guidelines** for true total regeneration) | `.agents/skills/contentful-cms-generate-cms-guidelines/SKILL.md` |
124
124
 
125
- **Skills — canonical source and sync:** All SE Studio skills live in **`packages/skills/skills/`** (the `@se-studio/skills` npm package). **In the monorepo**, edit sources there, run **`pnpm skills:validate`**, then **`pnpm skills:sync`** to copy into **`.agents/skills`**. The repo root keeps **`.cursor/skills`** as a **symlink** to **`.agents/skills`**. **Customer sites** depend on `@se-studio/skills` at an exact version and link its skills with `skills-npm --yes` in `prepare`; `npx skills add @se-studio/skills` is only for a one-off project without the dependency. Do not edit skills under **`.agents/skills`** by hand. Frontmatter rules: [`packages/skills/README.md`](packages/skills/README.md).
125
+ **Skills — canonical source and sync:** All SE Studio skills live in **`packages/skills/skills/`** (the `@se-studio/skills` npm package). **In the monorepo**, edit sources there, run **`pnpm skills:validate`**, then **`pnpm skills:sync`** to copy into **`.agents/skills`**. The repo root keeps **`.cursor/skills`** as a **symlink** to **`.agents/skills`**. **Customer sites** depend on `@se-studio/skills` at an exact version and link its skills with `skills-npm --yes` in `prepare`; `npx skills add @se-studio/skills` is only for a one-off project without the dependency. Do not edit skills under **`.agents/skills`** by hand. Frontmatter rules: `packages/skills/README.md`.
126
126
 
127
127
  See also **docs/AI_QUICK_REFERENCE.md** for a short task → doc/skill index.
128
128
 
@@ -379,22 +379,22 @@ When making changes, update the relevant documentation:
379
379
 
380
380
  ## Links
381
381
 
382
- - [Related Projects](./docs/RELATED_PROJECTS.md) – Client and studio projects that consume these packages (Contentful space IDs, environments, repo paths)
383
- - [AI Quick Reference](./docs/AI_QUICK_REFERENCE.md) – Task → doc/skill index for common app tasks
384
- - [GitHub issues implementation status](./docs/GITHUB_ISSUES_IMPLEMENTATION_STATUS.md) – closed issues mapped to code; open backlog summary
385
- - [Content Structure Guide](./docs/CONTENT_STRUCTURE_GUIDE.md) – Content author guide for CMS workflows
386
- - [Server vs Client Boundaries](./docs/SERVER_CLIENT_BOUNDARIES.md) – cms-server rule and pattern
387
- - [core-ui package export boundaries](./packages/core-ui/docs/PACKAGE_EXPORT_BOUNDARIES.md) – main vs `/server` entry; prevent client bundle CMS leaks
388
- - [Contentful webhook revalidation](./docs/CONTENTFUL_WEBHOOK_REVALIDATION.md) – Contentful webhooks for cache revalidation
389
- - [CMS Infrastructure Guide](./packages/core-ui/CMS_INFRASTRUCTURE.md)
390
- - [Contentful REST API Docs](./packages/contentful-rest-api/README.md) — LLM ref: [docs/llms.md](./packages/contentful-rest-api/docs/llms.md)
391
- - [Core Data Types Docs](./packages/core-data-types/README.md) — LLM ref: [docs/llms.md](./packages/core-data-types/docs/llms.md)
392
- - [Core UI Docs](./packages/core-ui/README.md) — LLM ref: [docs/llms.md](./packages/core-ui/docs/llms.md)
393
- - [A/B Testing Docs](./packages/ab-testing/README.md) — LLM ref: [docs/llms.md](./packages/ab-testing/docs/llms.md)
394
- - [HubSpot Docs](./packages/hubspot/README.md) — LLM ref: [docs/llms.md](./packages/hubspot/docs/llms.md) (optional package; **not** the fleet default forms provider)
395
- - [Search Docs](./packages/search/README.md) — LLM ref: [docs/llms.md](./packages/search/docs/llms.md)
396
- - [Markdown Renderer Docs](./packages/markdown-renderer/README.md) — LLM ref: [docs/llms.md](./packages/markdown-renderer/docs/llms.md)
397
- - [Contentful CMS CLI Docs](./packages/contentful-cms/README.md)
382
+ - Related Projects (`./docs/RELATED_PROJECTS.md`) – Client and studio projects that consume these packages (Contentful space IDs, environments, repo paths)
383
+ - AI Quick Reference (`./docs/AI_QUICK_REFERENCE.md`) – Task → doc/skill index for common app tasks
384
+ - GitHub issues implementation status (`./docs/GITHUB_ISSUES_IMPLEMENTATION_STATUS.md`) – closed issues mapped to code; open backlog summary
385
+ - Content Structure Guide (`./docs/CONTENT_STRUCTURE_GUIDE.md`) – Content author guide for CMS workflows
386
+ - Server vs Client Boundaries (`./docs/SERVER_CLIENT_BOUNDARIES.md`) – cms-server rule and pattern
387
+ - core-ui package export boundaries (`./packages/core-ui/docs/PACKAGE_EXPORT_BOUNDARIES.md`) – main vs `/server` entry; prevent client bundle CMS leaks
388
+ - Contentful webhook revalidation (`./docs/CONTENTFUL_WEBHOOK_REVALIDATION.md`) – Contentful webhooks for cache revalidation
389
+ - CMS Infrastructure Guide (`./packages/core-ui/CMS_INFRASTRUCTURE.md`)
390
+ - Contentful REST API Docs (`./packages/contentful-rest-api/README.md`) — LLM ref: docs/llms.md (`./packages/contentful-rest-api/docs/llms.md`)
391
+ - Core Data Types Docs (`./packages/core-data-types/README.md`) — LLM ref: docs/llms.md (`./packages/core-data-types/docs/llms.md`)
392
+ - Core UI Docs (`./packages/core-ui/README.md`) — LLM ref: docs/llms.md (`./packages/core-ui/docs/llms.md`)
393
+ - A/B Testing Docs (`./packages/ab-testing/README.md`) — LLM ref: docs/llms.md (`./packages/ab-testing/docs/llms.md`)
394
+ - HubSpot Docs (`./packages/hubspot/README.md`) — LLM ref: docs/llms.md (`./packages/hubspot/docs/llms.md`) (optional package; **not** the fleet default forms provider)
395
+ - Search Docs (`./packages/search/README.md`) — LLM ref: docs/llms.md (`./packages/search/docs/llms.md`)
396
+ - Markdown Renderer Docs (`./packages/markdown-renderer/README.md`) — LLM ref: docs/llms.md (`./packages/markdown-renderer/docs/llms.md`)
397
+ - Contentful CMS CLI Docs (`./packages/contentful-cms/README.md`)
398
398
 
399
399
  ### For consuming projects (in node_modules)
400
400
 
@@ -282,7 +282,7 @@ These links:
282
282
 
283
283
  ## Pipeline reference
284
284
 
285
- All per-component pipeline docs live in [`references/contentful-cms-cms-guidelines/`](../../references/contentful-cms-cms-guidelines/):
285
+ All per-component pipeline docs live in `references/contentful-cms-cms-guidelines/`:
286
286
 
287
287
  | File | Purpose |
288
288
  |---|---|
@@ -18,9 +18,9 @@ The management token must have permission to read API keys for each target space
18
18
 
19
19
  ## Site registry
20
20
 
21
- Canonical site list: [`docs/schema-audit/sites.registry.json`](../../../docs/schema-audit/sites.registry.json)
21
+ Canonical site list: `docs/schema-audit/sites.registry.json` (core repo)
22
22
 
23
- Customer-specific types/fields (excluded from core gap noise): [`docs/schema-audit/customer-overrides.registry.json`](../../../docs/schema-audit/customer-overrides.registry.json)
23
+ Customer-specific types/fields (excluded from core gap noise): `docs/schema-audit/customer-overrides.registry.json` (core repo)
24
24
 
25
25
  ## Two-phase workflow
26
26
 
@@ -251,7 +251,7 @@ rm <appDir>/docs/cms-guidelines/externals/<slug>.md
251
251
 
252
252
  **New components** (one or more):
253
253
 
254
- Run the [generate-all-guidelines](../generate-all-guidelines/SKILL.md) skill's Phase 1 (screenshots)
254
+ Run the [generate-all-guidelines](../contentful-cms-generate-all-guidelines/SKILL.md) skill's Phase 1 (screenshots)
255
255
  and Phase 3 (component subagents) for **only the new types**, then skip to Phase 4 (merge).
256
256
 
257
257
  If the new component does not yet have an `accepted-variants/components/<slug>.json` file (or `collections/<slug>.json` for a collection), run:
@@ -34,6 +34,7 @@ Canonical: `docs/PHILOSOPHY.md` §5a. Review: `customer-code-review.md`. Session
34
34
  ## Escape hatches (narrow)
35
35
 
36
36
  - `globals.css`: shared primitives only (keyframes, RTF element maps, true design-system utilities) — **not** per-page layout ports
37
+ - **Enforced, not just advised:** `check-cms-driven` (R3 colour literals, R4 new CSS files) fails a remake that copies live-site CSS. Open a time-boxed `remake` window in `cms-driven.config.json` only for the copy phase, then snapshot with `--update-baseline`. See the `@se-studio/site-check` README.
37
38
  - HtmlComponent + `customCss`: only when the recorded call is **keep** (`create-html-component.md`). A layout a registered type cannot express does not make that call. Do not move a section onto or off HtmlComponent after **keep** or **promote** is recorded. **Not** the default Webflow remake path.
38
39
 
39
40
  ## Related
@@ -55,12 +55,12 @@ Use exactly one:
55
55
 
56
56
  ## Report assembly
57
57
 
58
- Write [`docs/reports/markdown-accuracy-audit.md`](../../../../docs/reports/markdown-accuracy-audit.md):
58
+ Write `docs/reports/markdown-accuracy-audit.md` (core repo):
59
59
 
60
60
  1. Run metadata (timestamp, site count, URL count).
61
61
  2. Summary table of verdict counts.
62
62
  3. Per-site sections with table columns: **URL | HTML size | MD size | HTML ms | MD ms | Cache | Review**.
63
- 4. JSON sidecar [`docs/reports/markdown-accuracy-audit.json`](../../../../docs/reports/markdown-accuracy-audit.json) merging metrics + verdict + review text.
63
+ 4. JSON sidecar `docs/reports/markdown-accuracy-audit.json` (core repo) merging metrics + verdict + review text.
64
64
 
65
65
  Review in site batches (~6–13 URLs). Commit `.md` and `.json` to `dev`; artifacts dir stays gitignored.
66
66
 
@@ -192,20 +192,27 @@ Recommended pattern (in `app/sitemap.xml/route.ts` and the unindexed route — n
192
192
 
193
193
  ```ts
194
194
  import { createSitemapXmlRouteHandler } from '@se-studio/core-ui';
195
- import { redirects } from '@/generated/redirects';
196
- import { getSitemapEntries } from '@/lib/cms-server';
197
- import { baseUrl } from '@/lib/server-config';
195
+ import { getRedirectMap, getSitemapEntries } from '@/lib/cms-server';
196
+ import { baseUrl, draftOnly } from '@/lib/server-config';
198
197
 
199
198
  export const dynamic = 'force-dynamic';
200
199
  export const revalidate = 0;
201
200
 
202
201
  export const GET = createSitemapXmlRouteHandler({
203
- getEntries: () => getSitemapEntries({ includeUnindexed: false, redirectMap: redirects }),
202
+ // Live map (tag `redirect`, expired by the redirect sync route). `cache: 'force-cache'` is
203
+ // required: without it this read reaches Contentful on every crawler request.
204
+ getEntries: async () =>
205
+ getSitemapEntries({
206
+ includeUnindexed: false,
207
+ redirectMap: await getRedirectMap({ preview: draftOnly, cache: 'force-cache' }),
208
+ }),
204
209
  baseUrl,
205
210
  trailingSlash: true,
206
211
  });
207
212
  ```
208
213
 
214
+ A site still on the baked-map path can pass `redirects` from `@/generated/redirects` instead; sites on the live path (section 9) use the live map above so a redirect edit reaches the sitemap without a rebuild.
215
+
209
216
  Pure `fromPath` vanity redirects were already absent from sitemaps (no backing content entry). This mainly helps when you redirect *away from* live CMS pages/articles.
210
217
 
211
218
  ### 4.3 Webhook = Deploy Hook (the trigger)
@@ -228,7 +235,7 @@ Baked redirects require a **rebuild**, not ISR revalidation. Use a Contentful we
228
235
  ```
229
236
  This creates/replaces Contentful webhooks named `Vercel Deploy Hook (Redirects)` (and `… – Preview` when the preview URL is set). They fire on **Entry publish / unpublish / delete** filtered to content type `redirect`.
230
237
 
231
- The script lives at [`scripts/setup-redirect-deploy-hook.ts`](../../../../scripts/setup-redirect-deploy-hook.ts) in the monorepo; `example-empty` wires it via `package.json`.
238
+ The script lives at `scripts/setup-redirect-deploy-hook.ts` in the monorepo; `example-empty` wires it via `package.json`.
232
239
 
233
240
  **Manual setup:** same triggers and filter (`redirect` only), POST to the deploy hook URL. Do **not** point this at `/api/revalidate` — that only invalidates cache tags and will not regenerate `src/generated/redirects.ts`.
234
241
 
@@ -246,7 +253,7 @@ That's it. Publish a redirect → Vercel starts a build → `prebuild` runs `gen
246
253
  5. After the build finishes: `curl -I https://your-site/from-page-url/` → 301 to the target.
247
254
  6. Also test a raw-path rule and an external URL.
248
255
  7. Edit the rule → republish → new build → new behaviour.
249
- 8. (Optional) If you also want to clean up legacy per-page `redirectTo` fields, run migration 19.
256
+ 8. The legacy per-entry `redirectTo` field is gone (migration 39 removes it from page, pageVariant, article, articleType and tag; nothing ever read it). The `redirect` content type is the only supported mechanism. Count entries with `scripts/count-redirect-to.sh <site-repo>` before running it on a space: deleting a field deletes its data.
250
257
 
251
258
  ## 6. Preview / draft deployments
252
259
 
@@ -267,7 +274,7 @@ Then commit the updated `.agents/skills/...` (the monorepo keeps them in sync wi
267
274
 
268
275
  ## 8. Future work (explicitly out of scope for v1)
269
276
 
270
- - Edge Config + instant sync route (user request: "don't do the fast version at the moment").
277
+ - Edge Config for redirects: superseded by Vercel Bulk Redirects (see section 9).
271
278
  - Wildcards / prefix matching / query param control.
272
279
  - A "Redirects index" page visible to editors on the live site.
273
280
  - Host-based or A/B-aware redirects.
@@ -276,6 +283,59 @@ The `redirect` content type and the `buildRedirectMap` / `getRedirectMap` helper
276
283
 
277
284
  `buildRedirectMap` automatically drops self-redirects (A → A after normalization) and any rules that participate in longer cycles, emitting a console warning for cycles during build/generate. Internal paths are normalized with a trailing `/` to match your urlCalculators and sitemap hrefs.
278
285
 
286
+
287
+ ## 9. Live path: Vercel Bulk Redirects (no rebuild)
288
+
289
+ Vercel Bulk Redirects are a project-level list updated through the REST API (or `vercel redirects` CLI). A change goes live in seconds with no deployment, and the platform answers before Next.js (so before `proxy.ts`). Needs a Pro or Enterprise team (Pro: 1,000 rules). Proven in a pilot spike; the deploy-hook path above remains the fallback.
290
+
291
+ Library support in `@se-studio/contentful-rest-api`:
292
+
293
+ - `redirectMapToBulkRedirects(buildRedirectMap(redirects), options)` returns `{ rules, skipped }`. It emits each internal rule for the slashed **and** bare source, validates every rule, and sorts the output.
294
+ - `syncVercelBulkRedirects({ token, projectId, teamId, rules })` (from `/server`) does one `PUT overwrite:true` then promotes the staged version. It is idempotent: it reads Vercel's live list first and writes nothing (no new version) when it already matches. It refuses an empty list unless `allowEmpty` is set, a list over `maxRules`, and invalid or duplicate rules. A drop guard (`maxDropFraction`) exists but is **off by default**: a complete CMS read with fewer redirects is an intentional edit and is obeyed.
295
+
296
+ Verified behaviour (pilot spike, 2026-11-17):
297
+
298
+ - `PATCH` only edits an existing rule (404 on an empty project). `PUT` without `overwrite` merges; with `overwrite:true` it replaces the whole list.
299
+ - Matching is **exact on the trailing slash**: a rule for `/old/` does not match `/old`, so both are emitted.
300
+ - A matching platform rule fires before Next's trailing-slash 308.
301
+ - Staged changes are not live but are reachable on the staging alias; promote makes them live (about 1-5 s to reach the edge).
302
+ - Query strings are dropped unless `preserveQueryParams` is true.
303
+ - Vercel accepts a source without a leading `/` and self-redirects, so validation is ours.
304
+ - Every internal CMS rule becomes **two** Vercel rules (slashed and bare), so `maxRules` (default 1000, the Pro cap) is reached at about 500 CMS redirects.
305
+ - Sources must be literal paths: whitespace, control characters, backslash and the pattern characters `*`, `:`, `(`, `)` are rejected. Destinations may not contain whitespace, control characters or a backslash (a browser reads `/\evil.com` as `//evil.com`). Sources that differ only by case collide on Vercel (matching is case-insensitive); the later one is skipped and reported as `duplicate-source-case`.
306
+ - `allowedExternalHosts` (mapper and sync) restricts external destinations to listed hosts. Unset allows any `http(s)` host.
307
+
308
+ Token handling: use one **project-scoped** token per site, a Sensitive env var for Production only, a short expiry, and never reuse `REVALIDATION_SECRET` for the sync route. The sync route must read the published list from Contentful and take no redirect data from the request.
309
+
310
+ ### Wiring a site (live path)
311
+
312
+ 1. Copy `apps/example-empty/src/app/api/redirects-sync/route.ts`. It is two lines of handler: `createRedirectSyncHandler` (POST, the Contentful webhook target) and `createRedirectSyncStatusHandler` (GET, "does Vercel match the CMS?"), both from `@se-studio/contentful-rest-api/server`.
313
+ 2. Set env on the **one deployment allowed to write** (normally Production): `REDIRECT_SYNC_ENABLED=true`, `REDIRECT_SYNC_SECRET` (a dedicated secret, not `REVALIDATION_SECRET`), `VERCEL_API_TOKEN` (project-scoped, Sensitive), `VERCEL_PROJECT_ID` and `VERCEL_TEAM_ID` (**required even with a project-scoped token**: Vercel rejects the write with "projectId and teamId are required" without it). Anywhere else, or with any of these missing, the route returns 404 (a startup warning in the logs names what is missing).
314
+ If the site has a `route-build-policy.json`, add `/api/redirects-sync` to `allowedDynamic` (the route is a webhook plus a status view, so it renders per request). The template's comments are written as `why-external:` constraints so a verbatim copy passes a site's `check:comments` guard.
315
+ 3. Create the webhook: set `REDIRECT_SYNC_URL` (`https://<site>/api/redirects-sync`) and `REDIRECT_SYNC_SECRET` in `.env.local`, then `pnpm setup:redirect-sync-webhook`. It does not remove the old deploy-hook webhook; remove that once the live path is proven or redirects still rebuild the site.
316
+ 4. Keep the secrets in your local env file(s) too. `REDIRECT_SYNC_SECRET` and the Vercel values live in Vercel and Contentful (the webhook header); the setup script and the status check also need them on your machine, and nothing else records them. Never commit them. Write the token's expiry date down.
317
+ 5. Check: `curl -H "x-redirect-sync-secret: $REDIRECT_SYNC_SECRET" https://<site>/api/redirects-sync` returns the status view (below).
318
+
319
+ ### The status view (GET)
320
+
321
+ What is going on with redirects, in one call:
322
+
323
+ - `inSync`: `true` / `false`, or `null` when the Contentful read was partial (a comparison would mislead). A sync that failed, or never ran, shows up here as `false` with `drift.missing`, `drift.extra` and `drift.changed` (the sources that differ).
324
+ - `cms`: `complete`, `entries` (redirect entries in Contentful), `rules` (Vercel rules they produce, two per internal redirect), `inactive`, `warnings` (live entries worth a look, such as a From that is a published page), `errors` (entries that failed to convert), `problems` (entries that are **not live and why**: `missing-to` = the target page is unpublished or unresolved, `missing-from`, `self-redirect`, `cycle`, `duplicate-overridden`, or `rejected` with a `reason` such as an unsafe character or a disallowed host) and `skipped` (the rejected rules by source).
325
+ - `live`: how many rules Vercel serves now and the version (`id`, `name`, `lastModified`).
326
+
327
+ The CMS half is read through the Next data cache on the `redirect` tag. The production `/api/revalidate` webhook deliberately excludes `redirect`, so the sync route expires that tag itself after **every sync attempt, successful or not** (`afterSync`); it stays cached until the next redirect webhook arrives. That is why a **failed** sync shows as drift: the tag is expired, the next status call reads the new CMS list, and Vercel still has the old one. The Vercel half is read fresh on every call. A cache cannot show a **missed webhook** (nothing reached the route, so nothing changed from its point of view): add `?fresh=true` to read Contentful directly, and `cms.source` tells you which you got (`cached` or `fresh`). Check `problems` after unpublishing or moving a page: a redirect whose target is gone is dropped from the live list, not blocked.
328
+
329
+ How the handler behaves: the request body is never read (a caller can only trigger a re-sync, never inject a rule); the secret is compared in constant time; it refuses to sync when the Contentful read failed or was partial (502), and obeys a complete read, including an empty list; a sync that finds Vercel already up to date writes nothing; it waits a few seconds and re-reads Contentful, syncing again if the list changed (a webhook can fire before the delivery API shows the publish); a burst of webhooks is coalesced, so requests that arrive while a sync runs share one follow-up sync instead of each starting their own (this is per server instance; across instances the re-read and the skip-if-unchanged check keep the end state right). Rules it skips as invalid are listed in the response.
330
+
331
+ Renames and unpublishes: a redirect that points at a CMS page (`toInternal`) uses that page's URL as of the last sync, so the sync must also run when a page changes. `setup:redirect-sync-webhook` therefore fires on publish, unpublish and delete of `redirect` **and** of the types the Redirect pickers can point at, plus `personType` (a person's URL includes it): page, article, articleType, person, personType, tag, customType, tagType. Save and autosave are not topics. Most deliveries find nothing changed and write nothing, but each one still costs at least four Contentful reads (the redirect list is read twice, the second after the settle delay, and each read is at least two requests because core pages until an empty page) plus a Vercel read, so a bulk publish of 100 entries costs about 400 reads and 100 short function runs. The unpublish payload is documented to match the filter only if it carries `sys.contentType`; if a site's unpublishes do not re-sync, `?fresh=true` on the status view will show the drift. If a target page is unpublished, its redirect is dropped from the live list and shows as `missing-to` in `cms.problems`.
332
+
333
+ Use the **From internal** picker only for a page that is being retired. If the From page is still published, the redirect takes that live page out of service (and if the page is later renamed, the redirect follows it to the new URL). The status view lists these under `cms.warnings` (`source-is-live-page`). For an old URL that you are replacing, type it into `fromPath`.
334
+
335
+ `skeleton:check` enforces the live path (rule R6.9): the route above must exist, and the `sitemap.xml` / `sitemap-unindexed.xml` routes must call `getRedirectMap`. A site mid-rollout can skip `presence.t1.redirects-sync`, `redirects-sync.handlers` or `sitemap.redirects-live` in `skeleton.check.json` only with an expiry date (`until`, inclusive; add an `owner` so people know who finishes it), for example `{ "skip": [{ "id": "sitemap.redirects-live", "until": "2026-12-15", "owner": "<name>" }] }`; once the date passes the check fails as `skip.expired`.
336
+
337
+ Keep the baked `generate-redirects` map and `proxy.ts` lookup in place until a site's live path is proven; they are the fallback.
338
+
279
339
  ---
280
340
 
281
341
  **You now have editor-managed redirects that are as robust and low-surprise as your A/B tests, using only patterns that already exist in the codebase.**
@@ -29,7 +29,7 @@ Preview / `DRAFT_ONLY` Contentful access in local dev is expected and not a smok
29
29
  | `pnpm smoke-test:cache` | `build` + `start:dev` + double-pass `x-nextjs-cache` verify |
30
30
  | `pnpm smoke-test:deploy-check` | Post-build gate: `start:dev` (no rebuild) + functional smoke — use in Vercel `buildCommand` |
31
31
  | `pnpm smoke-test:live` | Live deployment URL smoke — GitHub Action + Vercel Deployment Checks |
32
- | `pnpm revalidation-test` | `build` + `start:dev` + revalidation matrix (warm → invalidate → cold → warm); see `revalidation.cases.json` and [CONTENTFUL_WEBHOOK_REVALIDATION.md](../../../../docs/CONTENTFUL_WEBHOOK_REVALIDATION.md) |
32
+ | `pnpm revalidation-test` | `build` + `start:dev` + revalidation matrix (warm → invalidate → cold → warm); see `revalidation.cases.json` and `docs/CONTENTFUL_WEBHOOK_REVALIDATION.md` (core repo) |
33
33
 
34
34
  Example `package.json` entries:
35
35
 
@@ -286,7 +286,7 @@ When placement says **core** (or the site is blocked on package behaviour): emit
286
286
 
287
287
  Before asking to merge to `dev` / `develop`, follow the review file once, at the final head SHA, and stop. Do not re-review on every push. A design review is only for schema, forms, analytics, caching, or security. A production promote does not get a second AI review (`CI covers the changes since`). Do not start a post-merge AI review; a skipped merge is labelled `pushed-through` only. Do not restate the checklist here.
288
288
 
289
- - **Core:** [`CODE_REVIEW_PROMPT.md`](../../../../CODE_REVIEW_PROMPT.md)
289
+ - **Core:** `CODE_REVIEW_PROMPT.md` (core repo)
290
290
  - **Customer:** [`customer-code-review.md`](../../references/agent-session/customer-code-review.md) (copied into the site as `CODE_REVIEW.md`)
291
291
 
292
292
  Findings: **BLOCKER** / **NIT**. No Bugbot; no `nick-go` label — Nick approves merges to integration branches **in chat**.