Repository navigation
feat(cli): install lifecycle, templates, localization, MCP, and a catalog composer - #442
Conversation
…alog composer Six features that extend Payload Components past a one-way `add`. **Install lifecycle** — `list`, `diff`, `update`, `remove`. The manifest `version` and `.payload-components/state.json` already recorded everything needed for an upgrade path; nothing consumed it. `diff` reports version, file, and wiring drift and exits non-zero so CI can gate on it. `update` re-installs stale components and refuses any file the consumer edited unless `--force`. `remove` is the exact inverse of the fragment patcher plus deletion of the files no other recorded component ships, so a shared family base survives while a sibling variant is installed; it leaves package dependencies and stored content alone, and skips the generators when nothing changed. **Path-resolved install targets** — the actual blocker to a second target. support-matrix.json now declares candidate paths and anchors per host-file role; detectProject resolves them into DetectedProject.hostFiles and the patchers write those paths. Adds `payload-blocks-app` for the same page-blocks shape at non-starter paths. A bare create-payload-app is still unsupported on purpose: installed blocks import starter primitives a blank app lacks. **Localization** — `add <block> --localized` installs a shipped localizeFields helper and wraps the block config's field list in it, covering the shared family base for free. Leaves only, never containers, since Payload rejects nested localization. Recorded in state so `update` re-applies it, and drift detection compares against the localized canonical form. **Templates** — payload-components/templates/*.json is generated from src/lib/templates by `pnpm templates:build`, committed, and reproducibility gated. `add-template <slug>` installs the union of a concept's blocks and prints its page plan. It installs blocks, not content. **MCP** — `payload-components mcp` is a hand-rolled JSON-RPC 2.0 stdio server so the published CLI keeps shipping only ajv and semver. Every tool is read-only: stdout is the transport, and installing belongs in the user's shell where the change is visible. **Catalog composer** — tick blocks across families on /components and get one install command in a docked tray, with the selection shareable via ?add=. Also fixes a packaging bug the new template manifests exposed: the npm files allowlist did not ship them, so `add-template` would have failed only once published. test:pack now asserts every runtime asset ships, which needed listFilesRecursive fixed — it was dropping path prefixes for nested entries and could not have caught this. Co-Authored-By: Claude Opus 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedToo many files! This PR contains 129 files, which is 29 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (129)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…tries, and template seeding Five features that close gaps the install lifecycle work opened, stacked on #442. **doctor --json + exit codes.** `list` and `diff` gained `--json`; `doctor` did not, so the install story was not fully CI-checkable. Findings are now collected rather than printed as they happen, so one run renders either the human report (byte-identical to before) or JSON. Every finding carries a scope — project, scripts, state, or a component name — and the exit code separates the two failures that need different responses: 2 means the project cannot accept installs at all, 1 means a recorded install drifted. **Changelogs and content-breaking upgrades.** `update` could move a consumer from 0.1.0 to 0.2.0 with no way to say what changed, and no way to signal that stored Payload data needed migrating first. Manifests now carry release notes, validated on load: real semver, ordered newest first, the manifest's own version present, and a `breaking` entry must declare its migration — otherwise `update` could refuse an upgrade without being able to explain why. `diff` prints pending entries; `update` holds a breaking component back entirely until --accept-breaking. That is deliberately not --force: one means "discard my local edits", the other means "I have migrated my content". Seeded from real history — stats-proof and content-quote were already at 0.2.0 from the logoLabel change. **payload-components new.** Adding a component touches a dozen files whose shape is entirely derivable from the slug. The generator writes those, appends to the mechanical lists, and prints the decisions it refuses to guess: where the component ranks in the curated catalog order, its dbName abbreviation (checked against every existing block), the Content model prose, the demo copy. **Third-party registries.** `add @scope/name` was documented in content/docs/registry.mdx and never implemented; the pinned shadcn supports it natively. The boundary is explicit: files only, https only, no Payload wiring, no install state, and --demo/--localized rejected, because a third-party item has no manifest to record a contract against. **add-template --demo.** One draft Page per page of a concept, reusing writeSeedScript unchanged. The blocker was that the ownership record was keyed to the first manifest, and every shipped template starts three to five of its pages with the same block — so those pages would all have claimed the same record. Ownership identity is now an optional, explicit part of SeedTarget that defaults to the old behavior, leaving all 27 pinned seed tests untouched. Also fixes two things found while mapping the authoring surface: hero-aurora and hero-kinetic existed as doc pages but were missing from the sidebar (the meta check only ran one direction — now it runs both), and the component-template README still named four files that have since become derived. Co-Authored-By: Claude Opus 5 <[email protected]>
`payload-components add` has always required a repo shaped like the official Payload website starter. A project scaffolded by `create-payload-app` fails detection before any block is even considered: no blocks renderer, no Pages collection with a `layout` field, and none of the primitives installed blocks import. PR #442 removed the hardcoded-path blocker; this removes the last one. `payload-components init --scaffold` copies eight files and registers two collections. The surface is small because the research narrowed it: across all 154 shipped source files there are exactly four consumer imports outside shadcn UI — `cn` (69 files), `Media` (38), `CMSLink` (30), `linkGroup` (22) — and `Media` is used with exactly two props at all 46 of its call sites. Three deliberate choices: - **It reproduces the starter's shape, so it needs no target of its own.** A scaffolded project detects as `payload-website-starter`, because that is honestly what it now is. An earlier draft added a third support-matrix target and widened `supportedTargets` across all 67 manifests; that turned out to be pure churn and was dropped. - **Nothing is overwritten.** A project that already has its own `cn`, `Media`, or Pages collection keeps it, and a re-run creates nothing. Files are copied through the same guarded helper `--localized` uses, not through shadcn — these are not catalog components and must never appear in the catalog. - **A config it cannot parse is reported, not rewritten.** Registering the collections is text-anchored on `collections: [`; without that anchor the command prints the two lines to add rather than guessing at the shape of someone's `buildConfig` call. The primitives are intentionally thinner than the starter's: `CMSLink` renders through `next/link` and `cn` rather than a `Button` a bare app does not have, and `Media` covers the two props blocks actually pass. They are the consumer's code after install — the CLI does not track or update them. Known limitation: this is target code that cannot be typechecked in this repository (payload-components/source is excluded from tsc, and there is no `payload` dependency here). Coverage proves the bundle turns an undetectable project into a detected one, that it is idempotent, and that it never clobbers. Proving it *compiles* against a real Payload app needs a fresh-smoke scenario — network plus a database — which is not in this change. Co-Authored-By: Claude Opus 5 <[email protected]>
…tries, and template seeding (#447) Five features that close gaps the install lifecycle work opened, stacked on #442. **doctor --json + exit codes.** `list` and `diff` gained `--json`; `doctor` did not, so the install story was not fully CI-checkable. Findings are now collected rather than printed as they happen, so one run renders either the human report (byte-identical to before) or JSON. Every finding carries a scope — project, scripts, state, or a component name — and the exit code separates the two failures that need different responses: 2 means the project cannot accept installs at all, 1 means a recorded install drifted. **Changelogs and content-breaking upgrades.** `update` could move a consumer from 0.1.0 to 0.2.0 with no way to say what changed, and no way to signal that stored Payload data needed migrating first. Manifests now carry release notes, validated on load: real semver, ordered newest first, the manifest's own version present, and a `breaking` entry must declare its migration — otherwise `update` could refuse an upgrade without being able to explain why. `diff` prints pending entries; `update` holds a breaking component back entirely until --accept-breaking. That is deliberately not --force: one means "discard my local edits", the other means "I have migrated my content". Seeded from real history — stats-proof and content-quote were already at 0.2.0 from the logoLabel change. **payload-components new.** Adding a component touches a dozen files whose shape is entirely derivable from the slug. The generator writes those, appends to the mechanical lists, and prints the decisions it refuses to guess: where the component ranks in the curated catalog order, its dbName abbreviation (checked against every existing block), the Content model prose, the demo copy. **Third-party registries.** `add @scope/name` was documented in content/docs/registry.mdx and never implemented; the pinned shadcn supports it natively. The boundary is explicit: files only, https only, no Payload wiring, no install state, and --demo/--localized rejected, because a third-party item has no manifest to record a contract against. **add-template --demo.** One draft Page per page of a concept, reusing writeSeedScript unchanged. The blocker was that the ownership record was keyed to the first manifest, and every shipped template starts three to five of its pages with the same block — so those pages would all have claimed the same record. Ownership identity is now an optional, explicit part of SeedTarget that defaults to the old behavior, leaving all 27 pinned seed tests untouched. Also fixes two things found while mapping the authoring surface: hero-aurora and hero-kinetic existed as doc pages but were missing from the sidebar (the meta check only ran one direction — now it runs both), and the component-template README still named four files that have since become derived. Co-authored-by: Claude Opus 5 <[email protected]>
`payload-components add` has always required a repo shaped like the official Payload website starter. A project scaffolded by `create-payload-app` fails detection before any block is even considered: no blocks renderer, no Pages collection with a `layout` field, and none of the primitives installed blocks import. PR #442 removed the hardcoded-path blocker; this removes the last one. `payload-components init --scaffold` copies eight files and registers two collections. The surface is small because the research narrowed it: across all 154 shipped source files there are exactly four consumer imports outside shadcn UI — `cn` (69 files), `Media` (38), `CMSLink` (30), `linkGroup` (22) — and `Media` is used with exactly two props at all 46 of its call sites. Three deliberate choices: - **It reproduces the starter's shape, so it needs no target of its own.** A scaffolded project detects as `payload-website-starter`, because that is honestly what it now is. An earlier draft added a third support-matrix target and widened `supportedTargets` across all 67 manifests; that turned out to be pure churn and was dropped. - **Nothing is overwritten.** A project that already has its own `cn`, `Media`, or Pages collection keeps it, and a re-run creates nothing. Files are copied through the same guarded helper `--localized` uses, not through shadcn — these are not catalog components and must never appear in the catalog. - **A config it cannot parse is reported, not rewritten.** Registering the collections is text-anchored on `collections: [`; without that anchor the command prints the two lines to add rather than guessing at the shape of someone's `buildConfig` call. The primitives are intentionally thinner than the starter's: `CMSLink` renders through `next/link` and `cn` rather than a `Button` a bare app does not have, and `Media` covers the two props blocks actually pass. They are the consumer's code after install — the CLI does not track or update them. Known limitation: this is target code that cannot be typechecked in this repository (payload-components/source is excluded from tsc, and there is no `payload` dependency here). Coverage proves the bundle turns an undetectable project into a detected one, that it is idempotent, and that it never clobbers. Proving it *compiles* against a real Payload app needs a fresh-smoke scenario — network plus a database — which is not in this change. Co-Authored-By: Claude Opus 5 <[email protected]>
`payload-components add` has always required a repo shaped like the official Payload website starter. A project scaffolded by `create-payload-app` fails detection before any block is even considered: no blocks renderer, no Pages collection with a `layout` field, and none of the primitives installed blocks import. PR #442 removed the hardcoded-path blocker; this removes the last one. `payload-components init --scaffold` copies eight files and registers two collections. The surface is small because the research narrowed it: across all 154 shipped source files there are exactly four consumer imports outside shadcn UI — `cn` (69 files), `Media` (38), `CMSLink` (30), `linkGroup` (22) — and `Media` is used with exactly two props at all 46 of its call sites. Three deliberate choices: - **It reproduces the starter's shape, so it needs no target of its own.** A scaffolded project detects as `payload-website-starter`, because that is honestly what it now is. An earlier draft added a third support-matrix target and widened `supportedTargets` across all 67 manifests; that turned out to be pure churn and was dropped. - **Nothing is overwritten.** A project that already has its own `cn`, `Media`, or Pages collection keeps it, and a re-run creates nothing. Files are copied through the same guarded helper `--localized` uses, not through shadcn — these are not catalog components and must never appear in the catalog. - **A config it cannot parse is reported, not rewritten.** Registering the collections is text-anchored on `collections: [`; without that anchor the command prints the two lines to add rather than guessing at the shape of someone's `buildConfig` call. The primitives are intentionally thinner than the starter's: `CMSLink` renders through `next/link` and `cn` rather than a `Button` a bare app does not have, and `Media` covers the two props blocks actually pass. They are the consumer's code after install — the CLI does not track or update them. Known limitation: this is target code that cannot be typechecked in this repository (payload-components/source is excluded from tsc, and there is no `payload` dependency here). Coverage proves the bundle turns an undetectable project into a detected one, that it is idempotent, and that it never clobbers. Proving it *compiles* against a real Payload app needs a fresh-smoke scenario — network plus a database — which is not in this change. Co-authored-by: Claude Opus 5 <[email protected]>
#443 caught something this branch missed. postcss is declared TWICE — as a direct devDependency and as a pnpm override — and the original commit only moved the override. Dependabot raised GHSA-fxqj-rqcc-2cmp against both manifest paths for exactly that reason: one alert on pnpm-lock.yaml (the resolution) and a second on package.json (the declared devDependency range). The override already forced the tree to 8.5.23, so nothing was actually resolving vulnerable — but the declaration was still an exact pin on 8.5.18, and the package.json alert tracks the declaration. Also merges origin/dev, which has moved to 1.3.0 (#442, #447, #448, #449) since this branch was cut. Verified against current dev: lint, format:check, source:build, tsc --noEmit, test:registry all clean, and 505 int tests passing. pnpm install --frozen-lockfile passes, so the lockfile and manifest agree the way CI checks them. Co-Authored-By: Claude Opus 5 <[email protected]>
…ble pins (#444) * security(deps): unstick the js-yaml and postcss overrides off vulnerable pins Both pins had gone stale the same way fast-uri did in #441: the override version that was patched when it was written now sits inside the advisory's widened range, so the pin was holding the tree ON a known vulnerable version rather than off one. js-yaml pin 4.3.0 GHSA-5p4m-2wfm-xmqj (high) >= 4.0.0, < 4.3.1 postcss pin 8.5.18 GHSA-fxqj-rqcc-2cmp (medium) <= 8.5.22 Bumps js-yaml to 4.3.1 and postcss to 8.5.23, and widens the js-yaml range key from <4.3.0 to <4.3.1 so the override still covers everything the advisory does. Both surfaced on main the moment #437 promoted, because Dependabot only reports against the default branch. They will not close until this reaches main in turn. Verified: lint, format:check, source:build, tsc --noEmit clean, and 381 int tests passing. Co-Authored-By: Claude Opus 5 <[email protected]> * security(deps): bump the postcss devDependency alongside the override #443 caught something this branch missed. postcss is declared TWICE — as a direct devDependency and as a pnpm override — and the original commit only moved the override. Dependabot raised GHSA-fxqj-rqcc-2cmp against both manifest paths for exactly that reason: one alert on pnpm-lock.yaml (the resolution) and a second on package.json (the declared devDependency range). The override already forced the tree to 8.5.23, so nothing was actually resolving vulnerable — but the declaration was still an exact pin on 8.5.18, and the package.json alert tracks the declaration. Also merges origin/dev, which has moved to 1.3.0 (#442, #447, #448, #449) since this branch was cut. Verified against current dev: lint, format:check, source:build, tsc --noEmit, test:registry all clean, and 505 int tests passing. pnpm install --frozen-lockfile passes, so the lockfile and manifest agree the way CI checks them. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Six features that take Payload Components past a one-way
add. Each is completein the repo's sense — source, tests, and docs together.
1. Install lifecycle —
list,diff,update,removeaddwas the only verb. Manifests already carried aversionand.payload-components/state.jsonalready recordedmanifestVersionper install,but nothing consumed either, so a consumer who installed
[email protected]hadno upgrade path and no way to know they were stale.
listjoins the shipped catalog with what the project recorded. Works inany directory, including one that was never initialized.
--json.diffreports version, file-content, and wiring drift, and exits 1 soCI can gate on install drift. Content comparison is normalized, so line
endings and a trailing newline are never reported as edits.
--json.updatere-installs recorded components at the version the CLI ships.Files are deleted first so the registry install rewrites them —
addtreats apresent file as satisfied, which is right for a fresh install and wrong for an
upgrade. A component with a locally edited file is skipped, named, and the
command exits 1 until
--force.removeis the exact inverse of the fragment patcher (proved by abyte-for-byte round-trip test) plus deletion of only the files no other
recorded component ships — so a shared family base survives while a sibling
variant is installed. It leaves package dependencies and stored Page content
alone, and skips the generators when a repeat run changes nothing.
Shared logic lives in
inventory.ts(catalog × state) andcomponent-files.ts(canonical content + file ownership).
2. Install targets are path-resolved
The real blocker to any second target: host file paths were hardcoded constants.
support-matrix.jsonnow declares candidate paths and required anchors per role(
renderBlocks,pagesLayout);detectProjectresolves them intoDetectedProject.hostFiles, and apply/remove/verify patch those paths.Manifests still declare canonical starter paths in
recovery.patchedFiles;resolveRecoveryPatchedFilesmaps them onto the resolved ones.Adds
payload-blocks-appfor the same page-blocks shape at non-starter paths —a flat
Pages.ts, a renderer undersrc/components, or a repo withoutsrc/.Deliberately not claimed: a bare
create-payload-appproject. Installedblock components import starter primitives (
@/components/Media,@/components/Link,@/fields/linkGroup,@/utilities/ui) a blank app does nothave, so widening
supportedTargetsthere would produce installs that do notcompile. Shipping those as a base bundle is the natural follow-on and is now the
only thing in the way; noted in
ROADMAP.md.3. Localization
add <block> --localizedinstalls a shippedlocalizeFieldshelper and wrapsthe installed block config's field list in it. Because the wrap sits outside the
shared family base's spread, one call covers shared and variant fields together.
Leaves only (
text,textarea,richText), never containers — Payload rejectsa localized field nested inside a localized parent. A field that already declares
localizedis untouched. The choice is recorded in install state soupdatere-applies it, and drift detection compares against the localized canonical
form so a localized install does not read as permanently modified.
4. Templates are installable
payload-components/templates/*.jsonis generated fromsrc/lib/templatesbypnpm templates:build, committed, and reproducibility-gated the same way thepublic registry is.
add-template <slug>installs the union of a concept'sblocks and prints its page plan;
templateslists them.It installs blocks, not content — the curated copy in the previews is not seeded.
The site copy and
/llms.txtwere updated to say exactly that instead of the old"not an installable template yet".
5. MCP server
payload-components mcp— hand-rolled JSON-RPC 2.0 over stdio, no SDK, becausethe published CLI ships only
ajvandsemverat runtime by design.Every tool is read-only. stdout is the transport, and the install pipeline
both prints to stdout and spawns children that inherit it, so a mutating tool
would corrupt the protocol stream. It is also the better boundary: the server
answers which block and what will it change, and installing stays an explicit
payload-components addin the user's shell where the change is visible.Reporting tools capture the stdout their handlers would have written and return
it as the tool result.
6. Catalog composer
Tick blocks across families on
/componentsand get one install command in adocked tray.
addtakes any number of names, so this is a real single command.The selection is shareable via
?add=and survives back/forward; unknown slugsin a hand-edited URL can never reach the command.
Packaging bug this surfaced
payload-components/templates/was not in the npmfilesallowlist, soadd-templatewould have failed only once published — every local test wouldhave passed.
test:packnow asserts each runtime asset actually ships, whichrequired fixing
listFilesRecursive: it was dropping path prefixes for nestedentries and could not have caught this.
Review fixes
Three defects found reviewing the branch before opening this, all now covered by
tests:
diffchecked the canonical starter paths regardless of the detected target,so every install on a non-starter layout reported as unwired.
add --dry-runprinted canonical host paths instead of the ones it wouldactually patch.
get_componentover MCP did not pass the localized flag, so a localizedinstall showed as modified.
Verification
pnpm test:releasegreen on this branch, on thedevbase:lint·format:check·tsctest:registrytest:inttest:e2e(production mode)test:packThe MCP server was also smoked as a real spawned process (
initialize→tools/call), not just through its module.Note for reviewers: three committed blog figures changed.
tools/blog/visual-system/catalog.tsexcerpts live CLI source by anchor, so reshaping an excerpted function requires
pnpm blog:visuals:figures.🤖 Generated with Claude Code