@astryxdesign/cli 0.1.3 → 0.1.4-canary.01e5b29

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/docs/browser-support.doc.mjs +200 -0
  3. package/docs/getting-started.doc.mjs +4 -0
  4. package/docs/layout.doc.mjs +2 -2
  5. package/docs/migration.doc.mjs +134 -0
  6. package/docs/styling.doc.mjs +53 -0
  7. package/docs/theme.doc.mjs +2 -2
  8. package/docs/working-with-ai.doc.mjs +1 -1
  9. package/package.json +15 -10
  10. package/src/api/component.mjs +2 -1
  11. package/src/api/doctor.mjs +13 -2
  12. package/src/api/template.mjs +14 -3
  13. package/src/codemods/__tests__/registry.test.mjs +1 -0
  14. package/src/codemods/__tests__/runner.test.mjs +38 -0
  15. package/src/codemods/registry.mjs +1 -0
  16. package/src/codemods/runner.mjs +2 -0
  17. package/src/codemods/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +43 -0
  18. package/src/codemods/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +36 -0
  19. package/src/codemods/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +41 -0
  20. package/src/codemods/transforms/v0.1.0/drop-xds-prefix-imports.mjs +65 -13
  21. package/src/codemods/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +43 -3
  22. package/src/codemods/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +45 -0
  23. package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +93 -0
  24. package/src/codemods/transforms/v0.1.5/index.mjs +19 -0
  25. package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +140 -0
  26. package/src/commands/agent-docs.mjs +9 -6
  27. package/src/commands/agent-docs.test.mjs +33 -0
  28. package/src/commands/build-theme.color-scheme.test.mjs +153 -0
  29. package/src/commands/build-theme.mjs +118 -14
  30. package/src/commands/build-theme.variants.test.mjs +193 -0
  31. package/src/commands/component-resolution.test.mjs +4 -4
  32. package/src/commands/doctor.test.mjs +38 -3
  33. package/src/commands/init.mjs +1 -1
  34. package/src/commands/swizzle.mjs +34 -0
  35. package/src/commands/swizzle.routing.test.mjs +67 -0
  36. package/src/lib/component-discovery.mjs +8 -4
  37. package/src/lib/component-format.mjs +13 -2
  38. package/src/lib/component-format.test.mjs +42 -0
  39. package/src/utils/paths.test.mjs +2 -2
  40. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +14 -0
  41. package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +58 -0
  42. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +14 -0
  43. package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +24 -0
  44. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +13 -0
  45. package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +33 -0
  46. package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +25 -23
  47. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +27 -48
  48. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +15 -0
  49. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +39 -0
  50. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +15 -0
  51. package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +39 -0
  52. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +31 -54
  53. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +15 -0
  54. package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +27 -0
  55. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +15 -0
  56. package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +38 -0
  57. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +14 -0
  58. package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +44 -0
  59. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +15 -0
  60. package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +107 -0
  61. package/templates/blocks/components/MetadataListItem/MetadataListItemBasic.doc.mjs +1 -1
  62. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +15 -0
  63. package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +47 -0
  64. package/templates/blocks/components/TabList/TabListTabsWithActions.doc.mjs +1 -1
  65. package/templates/blocks/components/Table/TableRowExpansionTable.doc.mjs +14 -0
  66. package/templates/blocks/components/Table/TableRowExpansionTable.tsx +99 -0
  67. package/templates/blocks/components/ToggleButtonGroup/ToggleButtonGroupVertical.doc.mjs +1 -1
  68. package/templates/pages/classic-gallery/page.tsx +1 -1
  69. package/templates/pages/dashboard/page.tsx +1 -1
  70. package/templates/pages/documentation/page.tsx +1 -1
  71. package/templates/pages/incident-console/page.tsx +580 -0
  72. package/templates/pages/incident-console/template.doc.mjs +12 -0
  73. package/templates/pages/messaging-shell/page.tsx +676 -0
  74. package/templates/pages/messaging-shell/template.doc.mjs +12 -0
  75. package/templates/pages/mixed-gallery/page.tsx +1 -1
  76. package/templates/pages/payment-form/page.tsx +2 -6
  77. package/templates/pages/product-detail/page.tsx +3 -11
  78. package/templates/pages/product-gallery/page.tsx +1 -1
  79. package/templates/pages/settings/page.tsx +1 -1
  80. package/templates/pages/side-gallery/page.tsx +1 -1
  81. package/templates/pages/table-page/page.tsx +1 -1
  82. package/templates/pages/table-page-chart/page.tsx +4 -14
  83. package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
  84. package/templates/pages/table-page-shoe-store-heatmap/page.tsx +5 -19
  85. package/templates/themes/stone/stoneTheme.ts +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @xds/cli
2
2
 
3
+ # 0.1.4
4
+
5
+ #### Fixes
6
+
7
+ - `astryx component <Name>` now prints the correct `defineTheme` component-override key. The theming example stripped a stale `xds-` prefix (left over from the astryx rename) instead of `astryx-`, so it advertised keys like `astryx-base-table` / `astryx-button`. Those double-prefix to `.astryx-astryx-*` selectors at runtime and silently match nothing. Keys are now the stable class name minus `astryx-` (e.g. `base-table`, `button`), which is what `generateThemeRules` expects (#3458).
8
+ - Harden the v0.1.0 upgrade codemods against three cases surfaced while migrating consumer apps:
9
+
10
+ #### Documentation
11
+
12
+ - Add a browser-support guide (`astryx docs browser-support`) documenting the support tiers, the modern platform features Astryx depends on (Popover API, CSS anchor positioning, `light-dark()`), which components are affected, and how consumers can support older browsers for their own audience.
13
+
14
+ #### Other Changes
15
+
16
+ - **drop-xds-prefix-imports**: when un-prefixing an `@xds/core` import (e.g. `XDSCodeBlock` → `CodeBlock`) would collide with a same-named local binding in the file (such as a local `export function CodeBlock` wrapper), alias the import to `Astryx<Name>` and rewrite its usages instead of producing a duplicate declaration that breaks the build.
17
+ - **migrate-xds-css-surfaces**: rewrite CSS `@import` of `@xds/*` package stylesheets (both `'…'`/`"…"` and `url(…)` forms), including the `@xds/core/xds.css` → `@astryxdesign/core/astryx.css` file rename and the `theme-default`/`theme-daily` → `theme-neutral` collapse.
18
+ - **migrate-xds-module-specifiers**: when collapsing `@xds/theme-default`/`@xds/theme-daily` to `@astryxdesign/theme-neutral`, remap the `defaultTheme` export to `neutralTheme`, aliasing back to the original local name (`neutralTheme as defaultTheme`) so downstream usages keep working.
19
+
20
+ #### Contributors
21
+
22
+ Thanks to everyone who contributed to this release:
23
+
24
+ - @cixzhang
25
+ - @ejhammond
26
+ - @ryanda9910
27
+
28
+ ---
29
+
3
30
  # 0.1.3
4
31
 
5
32
  #### New Features
@@ -9,7 +36,7 @@
9
36
  - Strict config + integration v1 schema (integrations, issuesUrl, hooks.postCodemod) and new @astryxdesign/cli/integration export.
10
37
  - File-based codemod API (createCodemod/createConfigCodemod) with the @astryxdesign/cli/codemod export and integration codemod discovery in upgrade.
11
38
  - component, template, and upgrade now print a one-line non-blocking warning when a configured integration has validation issues, pointing to validate-integration.
12
- - Add a Kanban Board page template: color-coded status columns, draggable task cards with priority tags, and board toolbar.
39
+ - Add a Kanban Board page template: color-coded status columns, draggable task cards with priority tags, and board toolbar. Based on a design by @cg-hub18.
13
40
  - Add frame-first layout guidance: new `astryx docs layout` topic (shell choice, region budgets, app archetypes, cards-vs-rows policy, responsive contracts), layout rules in the generated agent cheat sheet, and layout anti-patterns in `docs principles`.
14
41
  - Add a v0.1.3 config codemod that migrates astryx.config layout.components to experimental.xle.components.
15
42
  - Add v0.1.0 codemods for migrating `declare module "@xds/core/..."` type augmentations and `.xds-*` / `[data-xds-theme]` / `@layer xds-theme` CSS surfaces to their `@astryxdesign`/`astryx-*` equivalents.
@@ -53,6 +80,7 @@
53
80
  Thanks to everyone who contributed to this release:
54
81
 
55
82
  - @AKnassa
83
+ - @cg-hub18
56
84
  - @ejhammond
57
85
  - @ernestt
58
86
  - @harshavardhan194
@@ -0,0 +1,200 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../core/src/docs-types').ReferenceDoc} */
4
+
5
+ export const docs = {
6
+ name: 'browser-support',
7
+ title: 'Browser Support',
8
+ category: 'guide',
9
+ description:
10
+ 'What browsers Astryx targets, which modern platform features it depends on, and how to support older browsers for your own audience.',
11
+
12
+ sections: [
13
+ {
14
+ title: 'Overview',
15
+ content: [
16
+ {
17
+ type: 'prose',
18
+ text: 'Astryx is built on modern web platform features: the Popover API, CSS anchor positioning, and CSS `light-dark()`. These let components stay small, accessible, and dependency-free, but they also set a floor on which browsers render everything correctly.',
19
+ },
20
+ {
21
+ type: 'prose',
22
+ text: 'A design system does not own its traffic; the products built on it do. Their audiences range from evergreen-Chrome-only internal tools to public sites with meaningful older-Safari share. So Astryx does not declare a single hard browser floor the way an app would. Instead it defines tiers that describe what works at each level, and hands the final decision to you. Pick the tier that matches your audience.',
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ title: 'Support Tiers',
28
+ content: [
29
+ {
30
+ type: 'prose',
31
+ text: 'Astryx officially supports Tier 1 and Tier 2. Tier 3 is best-effort: components will not crash, but positioning and theming may degrade.',
32
+ },
33
+ {
34
+ type: 'table',
35
+ headers: ['Tier', 'Baseline', 'Representative versions', 'What your users experience'],
36
+ rows: [
37
+ [
38
+ 'Tier 1: Full fidelity',
39
+ 'Current Baseline (2026)',
40
+ 'Chrome 125+, Edge 125+, Safari 26+, Firefox 147+',
41
+ 'Everything works, including CSS anchor positioning. This is the reference target.',
42
+ ],
43
+ [
44
+ 'Tier 2: Functional',
45
+ 'Baseline − 2 years (2024)',
46
+ 'Chrome 114+, Edge 114+, Safari 17+, Firefox 125+',
47
+ 'Components open, dismiss, and are fully usable. Only anchor positioning is missing, so layered surfaces (tooltips, menus, popovers) may not be positioned next to their trigger.',
48
+ ],
49
+ [
50
+ 'Tier 3: Below Tier 2',
51
+ 'Older than Baseline − 2',
52
+ 'Anything older',
53
+ 'Best-effort. The only guarantee is "does not crash." `light-dark()` is unavailable, so theme colors may fall back to defaults.',
54
+ ],
55
+ ],
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ title: 'Which Features Set the Floor',
61
+ content: [
62
+ {
63
+ type: 'prose',
64
+ text: 'Only three modern features carry a browser requirement. Everything else Astryx uses (`:has()`, `color-mix()`, container queries, the `<dialog>` element) has been widely available since 2023 or earlier and needs no special handling.',
65
+ },
66
+ {
67
+ type: 'table',
68
+ headers: ['Feature', 'Role in Astryx', 'Widely available'],
69
+ rows: [
70
+ [
71
+ 'CSS Anchor Positioning',
72
+ 'Positions layered surfaces relative to their trigger (tooltips, menus, popovers, dropdowns).',
73
+ 'Baseline 2026: the tightest requirement.',
74
+ ],
75
+ [
76
+ 'Popover API',
77
+ 'Opens, stacks, and light-dismisses layered surfaces via the top layer.',
78
+ 'Baseline 2025.',
79
+ ],
80
+ [
81
+ 'CSS light-dark()',
82
+ 'Compiles every theme color tuple into a single value that responds to color scheme. Underpins the whole theming system.',
83
+ 'Widely available since mid-2024.',
84
+ ],
85
+ ],
86
+ },
87
+ {
88
+ type: 'prose',
89
+ text: 'The gap that matters is between Tier 1 and Tier 2: the Popover API and `light-dark()` reached wide availability well before anchor positioning. So in Tier 2 browsers, layered surfaces open and dismiss correctly; they just are not positioned. This is the one feature most consumers will need to reason about.',
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ title: 'Which Components Are Affected',
95
+ content: [
96
+ {
97
+ type: 'prose',
98
+ text: 'The browser requirement is concentrated in the layered-surface components: anything that renders content in an overlay positioned against a trigger:',
99
+ },
100
+ {
101
+ type: 'list',
102
+ style: 'unordered',
103
+ items: [
104
+ 'Tooltip',
105
+ 'HoverCard',
106
+ 'Popover',
107
+ 'ContextMenu',
108
+ 'Selector and MultiSelector (dropdown surfaces)',
109
+ 'Tokenizer (suggestion menu)',
110
+ 'Carousel (anchored controls)',
111
+ ],
112
+ },
113
+ {
114
+ type: 'prose',
115
+ text: 'If your product does not use any of these, it has no anchor-positioning requirement at all; it needs only `light-dark()` (Tier 2 and up) for correct theme colors. Layout, typography, forms, buttons, cards, tables, and navigation all work down to Tier 2 with no special handling.',
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ title: 'What Astryx Guarantees',
121
+ content: [
122
+ {
123
+ type: 'list',
124
+ style: 'do',
125
+ items: [
126
+ 'Components never throw on missing platform APIs. Where a browser lacks the Popover API, layers fall back to plain visibility instead of crashing.',
127
+ 'Tier 1 and Tier 2 are officially supported and tested.',
128
+ 'Non-layered components render correctly down to Tier 2.',
129
+ ],
130
+ },
131
+ {
132
+ type: 'list',
133
+ style: 'dont',
134
+ items: [
135
+ 'Astryx does not guarantee correct layer positioning below Tier 1 (anchor positioning). Closing that gap for a Tier 2 audience is a consumer choice; see below.',
136
+ 'Astryx does not ship a `light-dark()` fallback, so theme colors are not guaranteed below Tier 2.',
137
+ ],
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ title: 'Supporting Older Browsers',
143
+ content: [
144
+ {
145
+ type: 'prose',
146
+ text: 'If your audience includes Tier 2 browsers and you need correct layer positioning, you have three options, cheapest first. All of them are decisions you make for your audience; Astryx does not impose one.',
147
+ },
148
+ {
149
+ type: 'list',
150
+ style: 'ordered',
151
+ items: [
152
+ 'Polyfill anchor positioning. Load a CSS anchor positioning polyfill conditionally behind an `@supports` check so it costs nothing on Tier 1. This is the lowest-effort way to get correct positioning; note that polyfills may not cover every position-fallback feature.',
153
+ 'Provide a JS positioning fallback. Detect missing support with `CSS.supports("anchor-name", "--x")` and position layers with a measurement-based library (e.g. a floating-element positioner) when it returns false. More code, full control.',
154
+ 'Accept degraded positioning. Document for your users that on Tier 2 browsers, layered surfaces open correctly but may not sit next to their trigger. Cheapest, and often fine for internal tools on evergreen browsers.',
155
+ ],
156
+ },
157
+ {
158
+ type: 'prose',
159
+ text: 'Feature-detect at runtime rather than sniffing user agents:',
160
+ },
161
+ {
162
+ type: 'code',
163
+ lang: 'js',
164
+ label: 'Feature detection',
165
+ code: `// Popover API (Tier 2 and up)
166
+ const hasPopover = typeof HTMLElement !== 'undefined'
167
+ && typeof HTMLElement.prototype.showPopover === 'function';
168
+
169
+ // CSS anchor positioning (Tier 1)
170
+ const hasAnchorPositioning = CSS.supports('anchor-name', '--x');
171
+
172
+ // CSS light-dark() (Tier 2 and up)
173
+ const hasLightDark = CSS.supports('color', 'light-dark(#000, #fff)');`,
174
+ },
175
+ ],
176
+ },
177
+ {
178
+ title: 'How These Tiers Move Over Time',
179
+ content: [
180
+ {
181
+ type: 'prose',
182
+ text: 'The tiers are rolling, not frozen to specific versions. They track the Web Baseline year:',
183
+ },
184
+ {
185
+ type: 'list',
186
+ style: 'unordered',
187
+ items: [
188
+ 'Tier 1 tracks the current Baseline year.',
189
+ 'Tier 2 tracks Baseline minus two years.',
190
+ 'Tier 3 is everything older, and remains best-effort.',
191
+ ],
192
+ },
193
+ {
194
+ type: 'prose',
195
+ text: 'This is not an arbitrary window: Baseline − 2 is close to where anchor positioning stops being available while the Popover API and `light-dark()` still are, so the tier boundary tracks a real capability edge, not a guessed date. The version floors above are reviewed and advanced roughly once a year as new Baseline years land. Always feature-detect rather than hardcoding version numbers, so your app adapts automatically as the platform moves.',
196
+ },
197
+ ],
198
+ },
199
+ ],
200
+ };
@@ -69,6 +69,10 @@ export const docs = {
69
69
  type: 'prose',
70
70
  text: 'Available themes: @astryxdesign/theme-neutral (muted minimal, a good starting point), @astryxdesign/theme-butter, @astryxdesign/theme-chocolate, @astryxdesign/theme-gothic (dark-only), @astryxdesign/theme-matcha, @astryxdesign/theme-stone, and @astryxdesign/theme-y2k. See `npx astryx docs theme` for the full theming guide.',
71
71
  },
72
+ {
73
+ type: 'prose',
74
+ text: 'These stylesheets are cascade-layered: the reset loads in @layer reset and component styles in @layer astryx-base. If your project has existing global CSS, a legacy reset, or Tailwind, declare the layer order explicitly and assign every stylesheet to a layer deliberately: unlayered styles and later layers both override astryx-base regardless of specificity. See the Cascade Layer Safety section in `npx astryx docs migration` before building screens.',
75
+ },
72
76
  ],
73
77
  },
74
78
  {
@@ -92,7 +92,7 @@ export const docs = {
92
92
  content: [
93
93
  {
94
94
  type: 'prose',
95
- text: 'Card is a widget container, not a list-item wrapper. The fastest way to make an app look like a generic AI prototype is to wrap every record in a Card with a Badge. Dense data anything the user scans, filters, or selects belongs in rows: Table for columnar data, List/Item for single-line records, edge-to-edge with dividers and 32–40px row height.',
95
+ text: 'Card is a widget container, not a list-item wrapper. The fastest way to make an app look like a generic AI prototype is to wrap every record in a Card with a Badge. Dense data (anything the user scans, filters, or selects) belongs in rows: Table for columnar data, List/Item for single-line records, edge-to-edge with dividers and 32–40px row height.',
96
96
  },
97
97
  {
98
98
  type: 'list',
@@ -111,7 +111,7 @@ export const docs = {
111
111
  'Wrapping each list item in a Card (card soup)',
112
112
  'Stacking full-width Cards as a substitute for page structure',
113
113
  'Nesting Cards inside Cards',
114
- 'Using Badge as decoration reserve it for counts and enumerated states; use StatusDot or Token for status and metadata',
114
+ 'Using Badge as decoration: reserve it for counts and enumerated states; use StatusDot or Token for status and metadata',
115
115
  ],
116
116
  },
117
117
  ],
@@ -33,6 +33,7 @@ export const docs = {
33
33
  'Install the design system and run init so the project has package scripts, theme CSS, and agent docs.',
34
34
  'Wrap the app root with Theme and choose the initial light, dark, or system mode behavior.',
35
35
  'Make Tailwind and design system CSS layer order explicit before replacing components.',
36
+ 'Render the foundation smoke test page and confirm primitives keep their padding before migrating any surface.',
36
37
  'Move the persistent frame first: AppShell, TopNav, SideNav, page content, and mobile navigation.',
37
38
  'Replace shared primitives: Button, IconButton, TextInput, NumberInput, Switch, CheckboxInput, RadioList, Selector, Tabs, Dialog, AlertDialog, Banner, Toast, Badge, Card, Table, and ListItem.',
38
39
  'Replace global workflows: command palette, settings popover, theme toggle, search, filters, create flows, and destructive confirmation dialogs.',
@@ -125,6 +126,139 @@ export function AppRoot({children}: {children: React.ReactNode}) {
125
126
  @import "@astryxdesign/core/tailwind-theme.css";
126
127
  @import "tailwindcss/utilities.css" layer(utilities);`,
127
128
  },
129
+ {
130
+ type: 'prose',
131
+ text: 'On Tailwind v3 there is no preflight.css to import, so wrap the @tailwind base directive in a named layer instead. Keep utilities unlayered so existing app utility classes still win everywhere.',
132
+ },
133
+ {
134
+ type: 'code',
135
+ lang: 'css',
136
+ label: 'Tailwind v3 coexistence',
137
+ code: `@layer reset, tw-preflight, astryx-base, astryx-theme;
138
+
139
+ @import "@astryxdesign/core/reset.css";
140
+ @import "@astryxdesign/core/astryx.css";
141
+ @import "@astryxdesign/theme-neutral/theme.css";
142
+
143
+ @layer tw-preflight {
144
+ @tailwind base; /* layered: astryx-theme now wins over preflight */
145
+ }
146
+ @tailwind components;
147
+ @tailwind utilities; /* unlayered: legacy utility classes keep winning */`,
148
+ },
149
+ ],
150
+ },
151
+ {
152
+ title: 'Cascade Layer Safety',
153
+ content: [
154
+ {
155
+ type: 'prose',
156
+ text: 'In a stylesheet with no layers at all, a zero-specificity reset like `* { padding: 0 }` loses to any class selector, so most developers treat resets as harmless. Layers change the rules twice: unlayered styles beat every named layer, and a later layer beats an earlier one, both regardless of specificity. The same reset therefore wins against every component style either by staying unlayered or by landing in a layer declared after astryx-base. Same CSS, opposite outcome, and no error or warning when it happens.',
157
+ },
158
+ {
159
+ type: 'prose',
160
+ text: 'This is the most common way an adoption breaks, through one of two @import mechanisms. A top-level @import without the layer() keyword keeps the legacy reset unlayered, where it overrides every design system layer. And an @import nested inside a file that was itself imported into a layer inherits that surrounding layer, so a reset can silently land in a consumer layer above astryx-base. Either way the fix is the same: import the legacy reset into the lowest layer explicitly.',
161
+ },
162
+ {
163
+ type: 'code',
164
+ lang: 'css',
165
+ label: 'Legacy reset, explicitly layered',
166
+ code: `/* was: @import "./legacy-reset.css"; (unlayered: beats every layer) */
167
+ @import "./legacy-reset.css" layer(reset);`,
168
+ },
169
+ {
170
+ type: 'prose',
171
+ text: 'Audit the layers around the design system with this checklist before building screens.',
172
+ },
173
+ {
174
+ type: 'list',
175
+ style: 'unordered',
176
+ items: [
177
+ 'Declare the canonical @layer order once, before any @import. With webpack-based bundlers (including Next.js) the order declaration must live in its own CSS file imported first, such as layers.css, because webpack hoists @import content above the inline CSS that follows it.',
178
+ 'Audit every pre-existing global or reset stylesheet and assign each one to a layer deliberately. Top-level imports without layer() stay unlayered and beat every layer; imports nested inside a layered file inherit that layer.',
179
+ 'Remove or demote the app legacy reset. The design system ships its own :where() reset in the lowest layer, so any app reset belongs in that same reset layer and never in a layer above astryx-base.',
180
+ 'Layer Tailwind preflight. On Tailwind v4, import preflight.css with layer(base). On Tailwind v3, wrap the @tailwind base directive in a named layer (see the snippet in Theme and CSS Setup). Unlayered preflight overrides theme CSS silently.',
181
+ 'Set moduleResolution to bundler or node16 and newer so subpath imports like @astryxdesign/core/reset.css resolve.',
182
+ 'Theme with defineTheme and the accent family API instead of hand-writing individual color tokens. Derived tokens like --color-on-accent are generated from the accent scale automatically; hand-writing only --color-accent leaves --color-on-accent at its stale white default with no contrast guarantee against the new accent.',
183
+ 'Run the foundation smoke test below and view a few components in both light and dark mode before migrating any route.',
184
+ ],
185
+ },
186
+ {
187
+ type: 'prose',
188
+ text: 'One more mental model shift: a className or utility class you write on a component still reaches the DOM either way, but whether it overrides the component is a layer question, not a source order question. Keep app utilities in the utilities layer so they keep winning.',
189
+ },
190
+ ],
191
+ },
192
+ {
193
+ title: 'Foundation Smoke Test',
194
+ content: [
195
+ {
196
+ type: 'prose',
197
+ text: 'A broken layer order fails silently and identically on every page, so catch it before feature work instead of after N migrated screens. Render one throwaway page with a few primitives as the first migration step.',
198
+ },
199
+ {
200
+ type: 'code',
201
+ lang: 'tsx',
202
+ label: 'Foundation check page',
203
+ code: `import {useState} from 'react';
204
+ import {Button} from '@astryxdesign/core/Button';
205
+ import {Card} from '@astryxdesign/core/Card';
206
+ import {Table} from '@astryxdesign/core/Table';
207
+ import {TextInput} from '@astryxdesign/core/TextInput';
208
+ import {VStack} from '@astryxdesign/core/VStack';
209
+
210
+ export default function FoundationCheck() {
211
+ const [email, setEmail] = useState('');
212
+
213
+ return (
214
+ <div data-foundation-check>
215
+ <VStack gap={4}>
216
+ <Button label="Primary action" variant="primary" />
217
+ <TextInput
218
+ label="Email"
219
+ placeholder="you@example.com"
220
+ value={email}
221
+ onChange={setEmail}
222
+ />
223
+ <Card>One card with default padding</Card>
224
+ <Table
225
+ data={[{name: 'Foundation', status: 'ok'}]}
226
+ columns={[
227
+ {key: 'name', header: 'Name'},
228
+ {key: 'status', header: 'Status'},
229
+ ]}
230
+ />
231
+ </VStack>
232
+ </div>
233
+ );
234
+ }`,
235
+ },
236
+ {
237
+ type: 'prose',
238
+ text: 'If the button renders with visible padding, a filled primary background, and the input and card have borders and internal spacing, the foundation is sound. For an assertion that can run in any test runner or a dev-only effect, check that a primitive keeps non-zero padding:',
239
+ },
240
+ {
241
+ type: 'code',
242
+ lang: 'ts',
243
+ label: 'Foundation assertion',
244
+ code: `const button = document.querySelector<HTMLButtonElement>(
245
+ '[data-foundation-check] button',
246
+ );
247
+ if (!button) {
248
+ throw new Error('Foundation check page did not render a button.');
249
+ }
250
+ if (getComputedStyle(button).paddingInline === '0px') {
251
+ throw new Error(
252
+ 'Foundation broken: an unlayered reset or a later cascade layer is ' +
253
+ 'overriding component styles. Check that no app reset sits outside ' +
254
+ 'the reset layer.',
255
+ );
256
+ }`,
257
+ },
258
+ {
259
+ type: 'prose',
260
+ text: 'When this fails, the fix is almost always in the layer order: find the stylesheet that zeroes padding, and move it into the reset layer or delete it.',
261
+ },
128
262
  ],
129
263
  },
130
264
  {
@@ -338,6 +338,59 @@ const styles = stylex.create({
338
338
  },
339
339
  ],
340
340
  },
341
+ {
342
+ title: 'StyleX Build Setup (required for swizzled components)',
343
+ category: 'guide',
344
+ content: [
345
+ {
346
+ type: 'prose',
347
+ text: 'Astryx components ship pre-compiled, so consuming the published package needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one the component compiles but renders completely unstyled: no error, no warning. If a swizzled component looks unstyled, a missing StyleX compiler is almost always why. The same applies if you author your own StyleX with `stylex.create()`.',
348
+ },
349
+ {
350
+ type: 'table',
351
+ headers: ['Bundler', 'StyleX plugin'],
352
+ rows: [
353
+ ['Webpack', '@stylexjs/webpack-plugin'],
354
+ ['Vite / Rollup', '@stylexjs/rollup-plugin (or a community Vite plugin)'],
355
+ ['Babel (any bundler)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
356
+ ['Next.js (App Router, SWC)', 'An SWC-based transform; see the Next.js note below'],
357
+ ],
358
+ },
359
+ {
360
+ type: 'prose',
361
+ text: 'Next.js (App Router) is the sharp edge. StyleX\'s canonical compiler is a Babel plugin, but introducing a Babel config in Next.js disables the SWC compiler, which in turn breaks SWC-dependent features like `next/font`. So the "obvious" Babel setup is actively incompatible with a standard Next 15 App Router app.',
362
+ },
363
+ {
364
+ type: 'prose',
365
+ text: 'The working path on Next.js is an SWC-based StyleX transform (e.g. the community `@stylexswc/nextjs-plugin`) wired into `next.config`, which keeps SWC and `next/font` intact. See the example app `apps/example-nextjs-stylex` in the repo for a complete, working Next.js + StyleX + SWC configuration.',
366
+ },
367
+ {
368
+ type: 'code',
369
+ lang: 'js',
370
+ label: 'next.config.mjs: SWC-based StyleX transform (keeps next/font working)',
371
+ code: `import stylexPlugin from '@stylexswc/nextjs-plugin';
372
+
373
+ export default stylexPlugin({
374
+ rsOptions: {
375
+ // Resolve @astryxdesign/core's StyleX so swizzled component source compiles.
376
+ aliases: {'@/*': ['./src/*']},
377
+ unstable_moduleResolution: {type: 'commonJS'},
378
+ },
379
+ })({
380
+ // your existing Next.js config
381
+ });`,
382
+ },
383
+ {
384
+ type: 'list',
385
+ style: 'unordered',
386
+ items: [
387
+ 'Symptom of a missing compiler: swizzled component renders with no styles, but no build or runtime error.',
388
+ 'Do NOT add @stylexjs/babel-plugin to a Next.js App Router app; it disables SWC and breaks next/font.',
389
+ 'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler; only swizzled/authored StyleX source does.',
390
+ ],
391
+ },
392
+ ],
393
+ },
341
394
  {
342
395
  title: 'What NOT to Do',
343
396
  category: 'guide',
@@ -124,14 +124,14 @@ function App() {
124
124
  type: 'table',
125
125
  headers: ['Prop', 'Type', 'Default', 'Description'],
126
126
  rows: [
127
- ['theme', 'DefinedTheme', '', 'Theme object (required)'],
127
+ ['theme', 'DefinedTheme', '-', 'Theme object (required)'],
128
128
  [
129
129
  'mode',
130
130
  "'system' | 'light' | 'dark'",
131
131
  "'system'",
132
132
  'Color mode. system follows OS preference.',
133
133
  ],
134
- ['children', 'ReactNode', '', 'App content'],
134
+ ['children', 'ReactNode', '-', 'App content'],
135
135
  ],
136
136
  },
137
137
  ],
@@ -125,7 +125,7 @@ If you don't know all three, run \`npx astryx init --features agents\` to genera
125
125
  lang: 'json',
126
126
  label: 'package.json',
127
127
  code: `"scripts": {
128
- "xds": "node node_modules/@astryxdesign/cli/bin/astryx.mjs"
128
+ "astryx": "node node_modules/@astryxdesign/cli/bin/astryx.mjs"
129
129
  }`,
130
130
  },
131
131
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-canary.01e5b29",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -68,19 +68,23 @@
68
68
  "CHANGELOG.md"
69
69
  ],
70
70
  "dependencies": {
71
- "@clack/prompts": "^1.5.1",
71
+ "@clack/prompts": "^1.7.0",
72
72
  "commander": "^12.1.0",
73
73
  "jiti": "^2.7.0",
74
74
  "jscodeshift": "^17.3.0",
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/core": "*",
79
- "@astryxdesign/lab": "*",
80
- "@astryxdesign/theme-neutral": "*",
81
- "gpt-tokenizer": "^2.0.0"
78
+ "@astryxdesign/charts": "0.1.4-canary.01e5b29",
79
+ "@astryxdesign/core": "0.1.4-canary.01e5b29",
80
+ "@astryxdesign/lab": "0.1.4-canary.01e5b29",
81
+ "@astryxdesign/theme-neutral": "0.1.4-canary.01e5b29",
82
+ "gpt-tokenizer": "^3.4.0"
82
83
  },
83
84
  "peerDependenciesMeta": {
85
+ "@astryxdesign/charts": {
86
+ "optional": true
87
+ },
84
88
  "@astryxdesign/core": {
85
89
  "optional": true
86
90
  },
@@ -92,10 +96,11 @@
92
96
  }
93
97
  },
94
98
  "devDependencies": {
95
- "@astryxdesign/core": "*",
96
- "@astryxdesign/lab": "*",
97
- "@astryxdesign/theme-neutral": "*",
98
- "gpt-tokenizer": "^2.0.0"
99
+ "@astryxdesign/charts": "0.1.4-canary.01e5b29",
100
+ "@astryxdesign/core": "0.1.4-canary.01e5b29",
101
+ "@astryxdesign/lab": "0.1.4-canary.01e5b29",
102
+ "@astryxdesign/theme-neutral": "0.1.4-canary.01e5b29",
103
+ "gpt-tokenizer": "^3.4.0"
99
104
  },
100
105
  "scripts": {
101
106
  "astryx": "node bin/astryx.mjs",
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
11
12
  import {ERROR_CODES} from '../lib/error-codes.mjs';
12
13
  import {findCoreDir, discoverExternalPackages} from '../utils/paths.mjs';
13
14
  import {
@@ -560,7 +561,7 @@ export async function component(name, options = {}) {
560
561
 
561
562
  // Examples: blocks in the component's own directory, or
562
563
  // componentsUsed match for sub-components without a directory.
563
- const ownDir = allBlocks.filter(b => b.category.split('/').pop() === dirName);
564
+ const ownDir = allBlocks.filter(b => path.basename(b.category) === dirName);
564
565
  const examples = ownDir.length > 0
565
566
  ? ownDir
566
567
  : allBlocks.filter(b => b.componentsUsed?.some(c => c === dirName));
@@ -115,10 +115,21 @@ function findThemePackages(cwd) {
115
115
  return found;
116
116
  }
117
117
  for (const entry of entries) {
118
- if (!entry.isDirectory()) continue;
119
118
  if (!entry.name.startsWith('theme-')) continue;
119
+ const dir = path.join(scopeDir, entry.name);
120
+ // pnpm installs packages as symlinks into node_modules/.pnpm, and a
121
+ // symlink dirent reports isDirectory() as false — stat the target instead.
122
+ let isDir = entry.isDirectory();
123
+ if (!isDir && entry.isSymbolicLink()) {
124
+ try {
125
+ isDir = fs.statSync(dir).isDirectory();
126
+ } catch {
127
+ isDir = false;
128
+ }
129
+ }
130
+ if (!isDir) continue;
120
131
  const name = `@astryxdesign/${entry.name}`;
121
- found.push({name, version: pkgVersion(path.join(scopeDir, entry.name))});
132
+ found.push({name, version: pkgVersion(dir)});
122
133
  }
123
134
  return found;
124
135
  }
@@ -63,6 +63,17 @@ const DEMO_IMAGE_PATTERNS = [
63
63
  /https?:\/\/(?:[\w-]+\.)*lookaside\.facebook\.com\/[^\s'"`)]+/g,
64
64
  ];
65
65
 
66
+ /**
67
+ * Normalize path into Unix path (using forward slashes) for consistent comparison
68
+ * across Windows, macOS, and Linux.
69
+ *
70
+ * @param {string} p - The file path to normalize.
71
+ * @returns {string} The normalized Unix path.
72
+ */
73
+ function toPosixPath(p) {
74
+ return p.replace(/\\/g, '/');
75
+ }
76
+
66
77
  /**
67
78
  * Replace demo image references with a self-contained placeholder data URI so
68
79
  * scaffolded pages render with zero setup. Builders drop in their own images.
@@ -144,7 +155,7 @@ async function discoverBlocks() {
144
155
  const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
145
156
  if (!fs.existsSync(tsxPath)) continue;
146
157
  const doc = await loadDocModule(docPath);
147
- const relPath = path.relative(BLOCKS_DIR, path.dirname(docPath));
158
+ const relPath = toPosixPath(path.relative(BLOCKS_DIR, path.dirname(docPath)));
148
159
  blocks.push({
149
160
  type: 'block',
150
161
  dirName: basename,
@@ -180,7 +191,7 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
180
191
  const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
181
192
  if (!fs.existsSync(tsxPath)) continue;
182
193
  const doc = await loadDocModule(docPath);
183
- const relPath = path.relative(ext.blocksDir, path.dirname(docPath));
194
+ const relPath = toPosixPath(path.relative(ext.blocksDir, path.dirname(docPath)));
184
195
  blocks.push({
185
196
  type: 'block',
186
197
  dirName: basename,
@@ -428,7 +439,7 @@ export async function findShowcase(componentName, cwd, options) {
428
439
 
429
440
  // Priority 1: own directory (components/Badge/ for "Badge")
430
441
  const dirMatch = showcases.find(b => {
431
- const catDir = b.category.split('/').pop()?.toLowerCase();
442
+ const catDir = path.basename(b.category).toLowerCase();
432
443
  return catDir === lc;
433
444
  });
434
445
  if (dirMatch) return toResult(dirMatch);