Skip to content

Astryx config + integration API#3280

Merged
ejhammond merged 21 commits into
mainfrom
xds-unprefix-integration
Jul 1, 2026
Merged

Astryx config + integration API#3280
ejhammond merged 21 commits into
mainfrom
xds-unprefix-integration

Conversation

@ejhammond

@ejhammond ejhammond commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Brings the Astryx config + integration API work (developed on xds-unprefix-integration) to main. This is a cohesive set of CLI changes establishing a strict, validated configuration surface, a first-class integration system, file-based codemods and static templates, plus the internal architecture to support them. main is merged in, so this includes the 0.1.2 release and the Shell page templates.

Scope note: this branch grew since it was opened — it now carries 17 feature PRs (98 files, ~+7500/−2900). The list below is the full, current scope.

Config + integration core

Authoring APIs (new subpath exports)

Commands

Config codemods

Architecture / internals

Validation

Full CLI test suite green (1621 tests), pnpm build + verify-exports clean across all packages, typecheck and changeset gates pass. main was merged into the branch conflict-free and the merged result re-validated end to end (including the docsite XLE-playground removal from main, which is orthogonal to the CLI XLE work here).

Notes for reviewers

  • Pre-1.0: all changesets are patch-level; merging this does not publish — publishing remains the separate manual release workflow.
  • The branch's temporary CI trigger (used to run PR checks against the integration branch during development) was reverted, so .github/workflows/ci.yml is identical to main.

ejhammond and others added 16 commits June 29, 2026 22:20
Delete the standalone gap-report command and its supporting helpers.
After a successful swizzle the CLI now prints a short maintainer
feedback note pointing at the issue tracker (and, when the gh CLI is
available, a ready-to-run 'gh issue create' command) instead of
filing issues directly.

The swizzle.copy JSON result drops the gapReport fields and adds an
optional feedback object { issuesUrl, ghCommand? }.
…ort (#3261)

Replace the loose passthrough config and integration API with a locked,
strict v1 surface.

AstryxConfig is now { integrations?: string[]; issuesUrl?: string;
hooks?: { postCodemod?: PostCodemodHook[] } } and validates with a strict
Zod schema — unknown keys are hard errors. AstryxIntegration is now
{ components?; templates?; codemods?; issuesUrl? }, also strict.

- New @astryxdesign/cli/integration subpath export with createIntegration;
  createConfig stays on @astryxdesign/cli/config.
- Integrations resolve by package name only. Each package declares a single
  conventional root manifest (astryx.integration.{ts,mjs,js}) sibling to its
  package.json; identity (name/version) comes from package.json. .ts manifests
  load via jiti.
- App config loads from astryx.config.{ts,mjs,js} sibling to the nearest
  package.json (no upward closest-config walk); multiple configs is an error,
  missing yields an empty config.
- Post-codemod hooks now come from app config (hooks.postCodemod) and run via
  execFile; dry-run previews, apply executes in order and fails on nonzero exit.

Clean breaking change — the prior config/integration API was not in real use.
Add createPageTemplate/createBlockTemplate authoring helpers exported from
@astryxdesign/cli/template, validated with zod and tagging each doc with its
page/block type.

Add type-driven, package-scoped discovery for integration-provided templates:
a template id is the path under the integration's templates root minus the
.doc.* suffix, with a required same-stem <id>.tsx source. The doc's type
decides scaffolding (no /pages vs /blocks requirement). The template command
gains --package, ambiguity errors that list candidates, and list entries that
always carry id/name/description/type/package. Built-in template discovery,
command behavior, and tests are unchanged.
Add createCodemod/createConfigCodemod authoring helpers behind a new
@astryxdesign/cli/codemod export, and consume an integration's resolved
codemods directory during `astryx upgrade`. Integration codemods are
discovered version-first (<codemodsRoot>/<version>/<id>.<ext>), validated
strictly, and run alongside the core registry codemods ordered by version
(config codemods first, then code codemods). Broken discovery or a throwing
transform fails the upgrade.
Add 'astryx validate-integration' to validate one integration package at a
time — its conventional manifest, declared contribution roots, and the
codemod/template/component contributions — reporting findings with the
AstryxIntegrationIssue model (code, severity, message).

With no argument it validates the local package (nearest package.json +
sibling manifest); with a package name it validates an installed package
from node_modules. Supports --json via the integration.validate envelope
and exits 1 when any error-severity issue is present.
…ack (#3267)

Generalize `astryx swizzle` so it can copy integration-owned components,
not just core. Component resolution now goes through package ownership
(core + configured integrations); --package scopes the lookup and an
ambiguous name across packages errors with the candidate list instead of
silently preferring core.

Escaping relative imports are rewritten to the OWNING package's subpaths
(rewriteImports gains an optional ownerPackage param defaulting to core).
The copy now also excludes *.doc.* files. Maintainer feedback is routed
through config: core uses config.issuesUrl (falling back to the default),
integration components use their manifest issuesUrl, and the note is
omitted entirely when no issues URL is available. The swizzle.copy JSON
envelope gains an owner `package` field.
…3274)

Add a compact, non-blocking nudge: when a configured integration has
validation issues, component, template, and upgrade print exactly one
line per integration to stderr pointing at validate-integration, instead
of silently skipping broken contributions.

The nudge reuses the validate-integration validators via a new
validateLoadedIntegration export (no validation logic duplicated) and a
shared warnOnIntegrationIssues helper. It writes to stderr only (never
corrupts --json envelopes), is suppressed in --json mode, never throws,
and never changes the exit code.
…fig (#3275)

Register app-local XLE components through the validated config under
experimental.xle.components (object form: { from, description?, default? })
instead of the previous unvalidated layout.components read. The raw-read
shim and its special cwd-first config lookup are removed; XLE now resolves
the config via loadConfig, consistent with the rest of the CLI.
…tion loading (#3276)

Config and integration loading each duplicated a jiti singleton + user-module
import helper and a conventional-file-by-basename discovery filter. Extract both
into packages/cli/src/lib/module-loader.mjs (importUserModule, findPresentFiles)
and route both callers through it. No behavior change; all error messages and
return shapes are preserved.
* feat(cli): add Project configuration API with pluggable cache

Introduce the Project class as a single, lazy, memoized entry point for
reading resolved project configuration and discovery (components, templates,
codemods) plus integration issue routing. Add a small pluggable cache
(InMemoryConfigCache) keyed by a config content hash + cwd + discovery kind.

* refactor(cli): migrate all callers to Project and remove loadConfig

Route every config/discovery read through Project.load: discover, doctor,
layout, template, component, swizzle, and the component/template command
wrappers. findConfigPath now lives in lib/project.mjs as the single home.
Removes lib/config.mjs (loadConfig) with no shim.

* feat(cli): skip broken integrations on upgrade and add --skip-codemod

Upgrade now treats an integration definition error (bad manifest/export,
duplicate ids, missing root) as skip-and-warn rather than a hard failure,
while an execution-time codemod throw still aborts the run. Adds a variadic
--skip-codemod flag to exclude named codemods (core transform name or
integration codemod id) so users can re-run past a failed codemod.
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 1, 2026 3:25pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jun 30, 2026
…nfig-surface codemod (#3286)

Remove the legacy in-CLI config codemod (migrate-xds-config-surfaces) and
its bespoke {config:{packageJson,astryxConfig,xdsConfig}} execution machinery.
The @xds/* config rename is handled by a separate out-of-band migration, so
this codemod is redundant for the remaining holdouts — they reach 0.1.x with
configs already renamed.

Extract the modern (file, api)/jscodeshift config and code runners into a
shared run-codemod.mjs used by both the core registry runner and the
integration runner, so there is a single implementation. Core registry config
codemods now route through the same path: a core entry signals config via
meta.codemodType === 'config'.
….xle.components (#3290)

The published 0.1.2 CLI read XLE app-component registration from
astryx.config.* under layout.components. The next release relocates this
to experimental.xle.components, validated by a strict schema that rejects
unknown keys, so consumers with layout.components would hard-error on
upgrade. This adds a v0.1.3 config codemod that performs the straight
relocation.

Semantics are identical between the old and new shapes; this is purely a
move plus a string to object normalization:
- string 'X' becomes { from: 'X' } (named import, key = export name)
- object { from, description?, default? } is carried over unchanged

The transform recognizes the default export as either a bare object
literal or a createConfig({ ... }) wrapper, and bails with a clear
migrate-manually error when the config cannot be statically analyzed,
when experimental.xle already exists, when layout has keys other than
components, or when an entry is neither a string nor an object literal.
…ndary (#3293)

Add a single shared loadModuleWithSchema(file, schema, {label}) that imports a
user-authored module, takes its default export, and validates it against a zod
schema. Route all four user-module loaders (config, integration, codemod,
template) through it so loading and validation are uniform and happen at the
load/discovery boundary.

The create* factories (createConfig, createIntegration, createCodemod,
createConfigCodemod, createPageTemplate, createBlockTemplate) become pure typed
identity helpers: they stamp the type discriminator where applicable and return
the definition unchanged, performing no runtime validation. Their value is the
exported TypeScript surface for editor DX.

Define the metadata envelope schemas the loader validates: AstryxConfigSchema
and AstryxIntegrationSchema (existing), CodemodEnvelopeSchema (a discriminated
union over the stamped type), and TemplateEnvelopeSchema (BaseTemplateSchema +
type). The bespoke 'must default-export a createCodemod result' structural
check is removed in favor of schema validation, so a plain object matching the
envelope is accepted regardless of how it was produced.

Config strictness at the load boundary is preserved (unknown keys still
rejected). The built-in core .doc.mjs / template.doc.mjs loader and convention
are untouched; only the integration template path moves to loadModuleWithSchema.
…y-run guidance) (#3295)

upgrade loaded astryx.config strictly before running any codemods, so a
consumer whose config still had the legacy layout.components key — exactly
what the v0.1.3 config codemod migrate-layout-components-to-experimental
repairs — got rejected at load and the codemod that would fix it never ran.

Reorder the pipeline so core codemods (config + code) run before
Project.load. In --apply the config codemod writes the repaired config to
disk, then the strict load succeeds. In dry-run, a config that fails
validation but is fixable by a pending core config codemod no longer aborts:
it reports the fixable error and the exact --codemod ... --apply command to
repair it, then finishes the dry-run cleanly (integrations are processed on
the --apply run). Strictness is unchanged; a genuine config error or a
throwing transform still aborts.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid, well-structured PR — the config/integration schemas, new subpath exports, and Project API all read cleanly and the CLI package's own test suite is green. One blocker before this can land, though: the smoke-test check is failing for real (all three branch runs, not a flake), and the cause is this PR's own contract change.

Root cause (reproduced locally: PASS 155 / FAIL 151)

This PR intentionally changes the component --list JSON contract from bare strings to package-qualified objects:

- data: components                 // ["AppShell", "Button", ...]
+ data: listData  // { AppShell: [{ name: "AppShell", package: "@astryxdesign/core" }], ... }

That's a reasonable pre-1.0 change and the CLI vitest suite was updated for it. But the repo-level parity harness .github/scripts/api-cli-parity-test.mjs was not updated — it still does:

Object.values(componentList.data).flat()   // now yields {name, package} OBJECTS, not strings

…then feeds each object in as a component name, so every case runs as component [object Object]. The CLI degrades gracefully (No component named "[object Object]") but the API throws name.replace is not a function, and the resulting mismatch fails all 151 component cases.

Requested change

Since this PR changed the list contract, please update the parity harness in the same PR so the shape stays in sync — e.g.:

const allComponents = componentList.data && !componentList.error
  ? Object.values(componentList.data).flat().map(c => (typeof c === 'string' ? c : c.name))
  : [];

Optional (non-blocking)

The API's component(name) throws name.replace is not a function on a non-string name, while the CLI returns a clean error. Only reachable via the broken harness today, but a small type guard would make the two paths degrade identically.

Note on the other red check

dependency-check also shows red, but that looks like infra flakiness rather than a code issue: it passed on two earlier runs of this same branch, and the PR adds no new dependencies (only subpath exports). A re-run should clear it — no change needed on your end.

github-actions Bot added a commit that referenced this pull request Jul 1, 2026
@ejhammond ejhammond enabled auto-merge (squash) July 1, 2026 15:31
@ejhammond ejhammond merged commit 39ed50d into main Jul 1, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants