@astryxdesign/cli 0.1.2-canary.bfcbf64 → 0.1.2-canary.c11faf5

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 (132) hide show
  1. package/docs/layout.doc.dense.mjs +90 -0
  2. package/docs/layout.doc.mjs +160 -0
  3. package/docs/principles.doc.dense.mjs +2 -2
  4. package/docs/principles.doc.mjs +4 -0
  5. package/docs/principles.doc.zh.mjs +2 -2
  6. package/package.json +7 -7
  7. package/src/api/blog.mjs +192 -0
  8. package/src/api/blog.test.mjs +144 -0
  9. package/src/api/index.mjs +1 -0
  10. package/src/commands/agent-docs.mjs +3 -0
  11. package/src/commands/blog.mjs +60 -0
  12. package/src/commands/build-theme.import-path.test.mjs +2 -12
  13. package/src/commands/build-theme.mjs +117 -0
  14. package/src/commands/build-theme.prose.test.mjs +5 -15
  15. package/src/commands/build-theme.watch.test.mjs +149 -0
  16. package/src/commands/ensure-core-built.mjs +120 -0
  17. package/src/index.mjs +1 -0
  18. package/src/lib/error-codes.mjs +8 -0
  19. package/src/lib/site.mjs +20 -0
  20. package/templates/blocks/components/AvatarStatusDot/AvatarStatusDotVariants.doc.mjs +14 -0
  21. package/templates/blocks/components/AvatarStatusDot/AvatarStatusDotVariants.tsx +28 -0
  22. package/templates/blocks/components/Blockquote/BlockquoteTestimonials.doc.mjs +14 -0
  23. package/templates/blocks/components/Blockquote/BlockquoteTestimonials.tsx +34 -0
  24. package/templates/blocks/components/Blockquote/BlockquoteWithCite.doc.mjs +14 -0
  25. package/templates/blocks/components/Blockquote/BlockquoteWithCite.tsx +21 -0
  26. package/templates/blocks/components/BreadcrumbItem/BreadcrumbItemBasic.doc.mjs +14 -0
  27. package/templates/blocks/components/BreadcrumbItem/BreadcrumbItemBasic.tsx +15 -0
  28. package/templates/blocks/components/ButtonGroup/ButtonGroupBasic.doc.mjs +14 -0
  29. package/templates/blocks/components/ButtonGroup/ButtonGroupBasic.tsx +16 -0
  30. package/templates/blocks/components/ChatDictationButton/ChatDictationButtonBasic.doc.mjs +19 -0
  31. package/templates/blocks/components/ChatDictationButton/ChatDictationButtonBasic.tsx +34 -0
  32. package/templates/blocks/components/CheckboxListItem/CheckboxListItemBasic.doc.mjs +14 -0
  33. package/templates/blocks/components/CheckboxListItem/CheckboxListItemBasic.tsx +30 -0
  34. package/templates/blocks/components/CollapsibleGroup/CollapsibleGroupAccordion.doc.mjs +14 -0
  35. package/templates/blocks/components/CollapsibleGroup/CollapsibleGroupAccordion.tsx +31 -0
  36. package/templates/blocks/components/CommandPaletteEmpty/CommandPaletteEmptyBasic.doc.mjs +14 -0
  37. package/templates/blocks/components/CommandPaletteEmpty/CommandPaletteEmptyBasic.tsx +26 -0
  38. package/templates/blocks/components/CommandPaletteFooter/CommandPaletteFooterBasic.doc.mjs +14 -0
  39. package/templates/blocks/components/CommandPaletteFooter/CommandPaletteFooterBasic.tsx +32 -0
  40. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.doc.mjs +18 -0
  41. package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.tsx +32 -0
  42. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemBasic.doc.mjs +14 -0
  43. package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemBasic.tsx +27 -0
  44. package/templates/blocks/components/ContextMenu/ContextMenuBasic.doc.mjs +14 -0
  45. package/templates/blocks/components/ContextMenu/ContextMenuBasic.tsx +32 -0
  46. package/templates/blocks/components/DialogHeader/DialogHeaderBasic.doc.mjs +14 -0
  47. package/templates/blocks/components/DialogHeader/DialogHeaderBasic.tsx +30 -0
  48. package/templates/blocks/components/DropdownMenu/DropdownMenuShowcase.tsx +0 -6
  49. package/templates/blocks/components/DropdownMenuItem/DropdownMenuItemBasic.doc.mjs +14 -0
  50. package/templates/blocks/components/DropdownMenuItem/DropdownMenuItemBasic.tsx +27 -0
  51. package/templates/blocks/components/DropdownMenuItem/DropdownMenuItemShowcase.tsx +1 -5
  52. package/templates/blocks/components/FieldLabel/FieldLabelBasic.doc.mjs +14 -0
  53. package/templates/blocks/components/FieldLabel/FieldLabelBasic.tsx +20 -0
  54. package/templates/blocks/components/FieldStatus/FieldStatusBasic.doc.mjs +14 -0
  55. package/templates/blocks/components/FieldStatus/FieldStatusBasic.tsx +23 -0
  56. package/templates/blocks/components/FileInput/FileInputBasic.doc.mjs +14 -0
  57. package/templates/blocks/components/FileInput/FileInputBasic.tsx +22 -0
  58. package/templates/blocks/components/GridSpan/GridSpanColumns.doc.mjs +14 -0
  59. package/templates/blocks/components/GridSpan/GridSpanColumns.tsx +38 -0
  60. package/templates/blocks/components/HStack/HStackBasic.doc.mjs +14 -0
  61. package/templates/blocks/components/HStack/HStackBasic.tsx +16 -0
  62. package/templates/blocks/components/Hooks/useKeyboardHintHookUsage.doc.mjs +14 -0
  63. package/templates/blocks/components/Hooks/useKeyboardHintHookUsage.tsx +57 -0
  64. package/templates/blocks/components/InputGroup/InputGroupBasic.doc.mjs +14 -0
  65. package/templates/blocks/components/InputGroup/InputGroupBasic.tsx +27 -0
  66. package/templates/blocks/components/LayoutContent/LayoutContentBasic.doc.mjs +23 -0
  67. package/templates/blocks/components/LayoutContent/LayoutContentBasic.tsx +40 -0
  68. package/templates/blocks/components/LayoutFooter/LayoutFooterActions.doc.mjs +22 -0
  69. package/templates/blocks/components/LayoutFooter/LayoutFooterActions.tsx +41 -0
  70. package/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.doc.mjs +23 -0
  71. package/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.tsx +40 -0
  72. package/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.doc.mjs +22 -0
  73. package/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.tsx +37 -0
  74. package/templates/blocks/components/Lightbox/LightboxGallery.doc.mjs +14 -0
  75. package/templates/blocks/components/Lightbox/LightboxGallery.tsx +53 -0
  76. package/templates/blocks/components/Lightbox/LightboxShowcase.tsx +4 -3
  77. package/templates/blocks/components/Lightbox/LightboxVideo.doc.mjs +14 -0
  78. package/templates/blocks/components/Lightbox/LightboxVideo.tsx +27 -0
  79. package/templates/blocks/components/Lightbox/LightboxZoom.doc.mjs +14 -0
  80. package/templates/blocks/components/Lightbox/LightboxZoom.tsx +33 -0
  81. package/templates/blocks/components/MetadataListItem/MetadataListItemBasic.doc.mjs +14 -0
  82. package/templates/blocks/components/MetadataListItem/MetadataListItemBasic.tsx +19 -0
  83. package/templates/blocks/components/MobileNavToggle/MobileNavToggleBasic.doc.mjs +23 -0
  84. package/templates/blocks/components/MobileNavToggle/MobileNavToggleBasic.tsx +42 -0
  85. package/templates/blocks/components/MoreMenu/MoreMenuShowcase.tsx +0 -6
  86. package/templates/blocks/components/NavIcon/NavIconBasic.doc.mjs +14 -0
  87. package/templates/blocks/components/NavIcon/NavIconBasic.tsx +16 -0
  88. package/templates/blocks/components/RadioListItem/RadioListItemBasic.doc.mjs +14 -0
  89. package/templates/blocks/components/RadioListItem/RadioListItemBasic.tsx +30 -0
  90. package/templates/blocks/components/Resizable/ResizableSidebar.doc.mjs +25 -0
  91. package/templates/blocks/components/Resizable/ResizableSidebar.tsx +67 -0
  92. package/templates/blocks/components/SegmentedControlItem/SegmentedControlItemBasic.doc.mjs +14 -0
  93. package/templates/blocks/components/SegmentedControlItem/SegmentedControlItemBasic.tsx +21 -0
  94. package/templates/blocks/components/SelectorOption/SelectorOptionBasic.doc.mjs +14 -0
  95. package/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +39 -0
  96. package/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonBasic.doc.mjs +14 -0
  97. package/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonBasic.tsx +55 -0
  98. package/templates/blocks/components/SideNavHeading/SideNavHeadingBasic.doc.mjs +14 -0
  99. package/templates/blocks/components/SideNavHeading/SideNavHeadingBasic.tsx +38 -0
  100. package/templates/blocks/components/SideNavItem/SideNavItemBasic.doc.mjs +14 -0
  101. package/templates/blocks/components/SideNavItem/SideNavItemBasic.tsx +49 -0
  102. package/templates/blocks/components/SideNavSection/SideNavSectionBasic.doc.mjs +14 -0
  103. package/templates/blocks/components/SideNavSection/SideNavSectionBasic.tsx +71 -0
  104. package/templates/blocks/components/StackItem/StackItemFill.doc.mjs +14 -0
  105. package/templates/blocks/components/StackItem/StackItemFill.tsx +28 -0
  106. package/templates/blocks/components/TabMenu/TabMenuBasic.doc.mjs +14 -0
  107. package/templates/blocks/components/TabMenu/TabMenuBasic.tsx +23 -0
  108. package/templates/blocks/components/ToggleButtonGroup/ToggleButtonGroupVertical.doc.mjs +14 -0
  109. package/templates/blocks/components/ToggleButtonGroup/ToggleButtonGroupVertical.tsx +47 -0
  110. package/templates/blocks/components/TopNavHeading/TopNavHeadingBasic.doc.mjs +14 -0
  111. package/templates/blocks/components/TopNavHeading/TopNavHeadingBasic.tsx +22 -0
  112. package/templates/blocks/components/TopNavItem/TopNavItemBasic.doc.mjs +14 -0
  113. package/templates/blocks/components/TopNavItem/TopNavItemBasic.tsx +21 -0
  114. package/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuBasic.doc.mjs +20 -0
  115. package/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuBasic.tsx +46 -0
  116. package/templates/blocks/components/TopNavMegaMenuFeaturedCard/TopNavMegaMenuFeaturedCardBasic.doc.mjs +14 -0
  117. package/templates/blocks/components/TopNavMegaMenuFeaturedCard/TopNavMegaMenuFeaturedCardBasic.tsx +16 -0
  118. package/templates/blocks/components/TopNavMegaMenuItem/TopNavMegaMenuItemBasic.doc.mjs +14 -0
  119. package/templates/blocks/components/TopNavMegaMenuItem/TopNavMegaMenuItemBasic.tsx +26 -0
  120. package/templates/blocks/components/TopNavMenu/TopNavMenuBasic.doc.mjs +14 -0
  121. package/templates/blocks/components/TopNavMenu/TopNavMenuBasic.tsx +43 -0
  122. package/templates/blocks/components/TypeaheadItem/TypeaheadItemBasic.doc.mjs +14 -0
  123. package/templates/blocks/components/TypeaheadItem/TypeaheadItemBasic.tsx +43 -0
  124. package/templates/blocks/components/VStack/VStackBasic.doc.mjs +14 -0
  125. package/templates/blocks/components/VStack/VStackBasic.tsx +20 -0
  126. package/templates/pages/kanban-board/page.tsx +729 -0
  127. package/templates/pages/kanban-board/template.doc.mjs +12 -0
  128. package/templates/pages/shell-side-nav/page.tsx +0 -1
  129. package/templates/blocks/components/TreeListBranches/TreeListBranchesShowcase.doc.mjs +0 -14
  130. package/templates/blocks/components/TreeListBranches/TreeListBranchesShowcase.tsx +0 -64
  131. package/templates/blocks/components/TreeListItem/TreeListItemShowcase.doc.mjs +0 -14
  132. package/templates/blocks/components/TreeListItem/TreeListItemShowcase.tsx +0 -60
@@ -0,0 +1,90 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../core/src/docs-types').ReferenceTranslationDoc} */
4
+
5
+ export const docsDense = {
6
+ description:
7
+ 'frame-first app layout: shell choice, region budgets, cards vs rows',
8
+ sections: [
9
+ {
10
+ title: 'Frame First',
11
+ content: [
12
+ {
13
+ type: 'prose',
14
+ text: 'decide frame before content. content-first (Card-wrapped sections in a scroll column) = prototype look.',
15
+ },
16
+ {
17
+ type: 'list',
18
+ items: [
19
+ 'pick frame: AppShell (nav apps) | Layout+LayoutPanel+LayoutContent (multi-pane tools) | plain column (docs/forms)',
20
+ 'budget regions in px first: side nav 240-280, rail 64-72, inspector 340-420, facet rail 220-260',
21
+ 'container policy per region: dense data = rows; dashboards/galleries = card grids',
22
+ 'write responsive contract up front',
23
+ ],
24
+ },
25
+ null,
26
+ ],
27
+ },
28
+ {
29
+ title: 'App Archetypes',
30
+ content: [
31
+ {
32
+ type: 'prose',
33
+ text: 'container choice tracks archetype, not preference.',
34
+ },
35
+ null,
36
+ {
37
+ type: 'prose',
38
+ text: 'start from matching template (astryx template --list), study with --skeleton.',
39
+ },
40
+ ],
41
+ },
42
+ {
43
+ title: 'Cards vs Rows',
44
+ content: [
45
+ {
46
+ type: 'prose',
47
+ text: 'Card = widget container, NOT list-item wrapper. dense/scannable/selectable data = rows: Table (columnar) or List/Item (single-line), edge-to-edge, 32-40px rows, dividers.',
48
+ },
49
+ {
50
+ type: 'list',
51
+ items: [
52
+ 'Table+plugins: hosts, deployments, monitors, users',
53
+ 'List/Item rows: issues, files, conversations',
54
+ 'Card: KPI tiles, chart panels, gallery entries, settings groups',
55
+ 'EmptyState for zero-match',
56
+ ],
57
+ },
58
+ {
59
+ type: 'list',
60
+ items: [
61
+ 'no Card-wrapped list items (card soup)',
62
+ 'no stacked full-width Cards as page structure',
63
+ 'no Cards in Cards',
64
+ 'no decorative Badge — counts/enums only; StatusDot/Token for status',
65
+ ],
66
+ },
67
+ ],
68
+ },
69
+ {
70
+ title: 'Panels and Inspectors',
71
+ content: [
72
+ {
73
+ type: 'prose',
74
+ text: 'master-detail: row select opens fixed-width inspector (LayoutPanel end slot + width budget + resizable/useResizable). overlay content <=1024px, do not compress.',
75
+ },
76
+ null,
77
+ ],
78
+ },
79
+ {
80
+ title: 'Responsive Contract',
81
+ content: [
82
+ {
83
+ type: 'prose',
84
+ text: 'declare breakpoint behavior as comment at frame root: which regions collapse/overlay/drop at which widths.',
85
+ },
86
+ null,
87
+ ],
88
+ },
89
+ ],
90
+ };
@@ -0,0 +1,160 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../core/src/docs-types').ReferenceDoc} */
4
+
5
+ export const docs = {
6
+ name: 'layout',
7
+ title: 'Layout',
8
+ category: 'guide',
9
+ description:
10
+ 'Frame-first app layout: choosing a shell, budgeting regions, and when to use cards vs rows.',
11
+
12
+ sections: [
13
+ {
14
+ title: 'Frame First',
15
+ content: [
16
+ {
17
+ type: 'prose',
18
+ text: 'Decide the frame before writing any content. Real applications are built top-down: pick the shell, name its regions, give each region an explicit size budget, then fill regions with content. Content-first layout (writing sections and wrapping each one in a Card) produces a padded scroll column that reads as a prototype, not a product.',
19
+ },
20
+ {
21
+ type: 'list',
22
+ style: 'ordered',
23
+ items: [
24
+ 'Pick the frame: AppShell (top nav and/or side nav apps), Layout + LayoutPanel + LayoutContent (multi-pane tools like explorers and consoles), or a plain content column (documents, marketing, forms)',
25
+ 'Budget regions in px before filling them: side nav 240–280, icon rail 64–72, detail/inspector panel 340–420, filter/facet rail 220–260',
26
+ 'Decide the container policy per region: dense data renders as rows; widget dashboards and galleries render as card grids (see Cards vs Rows)',
27
+ 'Write the responsive contract up front: which regions collapse, overlay, or drop at which breakpoints (see Responsive Contract)',
28
+ ],
29
+ },
30
+ {
31
+ type: 'code',
32
+ lang: 'tsx',
33
+ label: 'A three-region tool frame',
34
+ code: `// Frame: nav 256 | content flex | inspector 380 (resizable)
35
+ <AppShell sideNav={<SideNav>{/* nav items */}</SideNav>} contentPadding={0}>
36
+ <Layout>
37
+ <LayoutContent>{/* dense list or table, edge-to-edge */}</LayoutContent>
38
+ <LayoutPanel width={380} resizable={{minSizePx: 320, maxSizePx: 480}} hasDivider>
39
+ {/* inspector for the selected row */}
40
+ </LayoutPanel>
41
+ </Layout>
42
+ </AppShell>`,
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ title: 'App Archetypes',
48
+ content: [
49
+ {
50
+ type: 'prose',
51
+ text: 'Match the frame and container policy to the kind of app you are building. These recipes are distilled from product-scale apps built with the design system; container choice tracks the archetype, not personal preference.',
52
+ },
53
+ {
54
+ type: 'table',
55
+ headers: ['Archetype', 'Frame', 'Container policy'],
56
+ rows: [
57
+ [
58
+ 'Tracker / work tool (issues, tickets, CRM)',
59
+ 'AppShell + SideNav; inspector LayoutPanel on select',
60
+ 'Rows only. Grouped edge-to-edge lists, zero cards',
61
+ ],
62
+ [
63
+ 'Console / observability (metrics, logs, deploys)',
64
+ 'AppShell + SideNav or TopNav + TabList',
65
+ 'Card grid for dashboard widgets; Table for everything else',
66
+ ],
67
+ [
68
+ 'Messaging / feed',
69
+ 'Column frame: rail + sidebar + stream + panel',
70
+ 'Rows and bubbles. No cards in the stream',
71
+ ],
72
+ [
73
+ 'Media library / gallery',
74
+ 'AppShell + TopNav; grid content',
75
+ 'Card grid (ClickableCard) with dense metadata rows in detail views',
76
+ ],
77
+ [
78
+ 'Settings / forms',
79
+ 'AppShell + SideNav or settings template',
80
+ 'Sections with FormLayout; Card only to group dangerous or billing actions',
81
+ ],
82
+ ],
83
+ },
84
+ {
85
+ type: 'prose',
86
+ text: 'Start from a template that matches the archetype (`npx astryx template --list`), then study its structure with `--skeleton` before customizing.',
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ title: 'Cards vs Rows',
92
+ content: [
93
+ {
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.',
96
+ },
97
+ {
98
+ type: 'list',
99
+ style: 'do',
100
+ items: [
101
+ 'Table (with selection/sorting plugins) for columnar records: hosts, deployments, monitors, users',
102
+ 'List/Item rows for scannable single-line records: issues, files, conversations',
103
+ 'Card for self-contained widgets: KPI tiles, chart panels, gallery entries, settings groups',
104
+ 'EmptyState inside the region when a filter matches nothing',
105
+ ],
106
+ },
107
+ {
108
+ type: 'list',
109
+ style: 'dont',
110
+ items: [
111
+ 'Wrapping each list item in a Card (card soup)',
112
+ 'Stacking full-width Cards as a substitute for page structure',
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',
115
+ ],
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ title: 'Panels and Inspectors',
121
+ content: [
122
+ {
123
+ type: 'prose',
124
+ text: 'Master-detail is the backbone of tool UIs: selecting a row opens a fixed-width inspector panel rather than navigating away. Use LayoutPanel in the end slot with an explicit width budget; add resizable (useResizable) for user control, and let the panel overlay the content region below ~1024px instead of compressing it.',
125
+ },
126
+ {
127
+ type: 'code',
128
+ lang: 'tsx',
129
+ label: 'Inspector that overlays at narrow widths',
130
+ code: `<LayoutPanel
131
+ width={380}
132
+ hasDivider
133
+ isScrollable
134
+ label="Details"
135
+ resizable={{minSizePx: 320, maxSizePx: 480, autoSaveId: 'inspector'}}>
136
+ {selected ? <DetailFields item={selected} /> : <EmptyState title="Nothing selected" />}
137
+ </LayoutPanel>`,
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ title: 'Responsive Contract',
143
+ content: [
144
+ {
145
+ type: 'prose',
146
+ text: 'Declare breakpoint behavior as a contract before building, and keep it in a comment at the frame root. A typical contract: full frame above 1024px; inspector panels overlay the content column at 1024px and below; the side nav collapses into MobileNav at 768px and below. Deciding this up front keeps every region change intentional instead of emergent.',
147
+ },
148
+ {
149
+ type: 'code',
150
+ lang: 'tsx',
151
+ label: 'Contract comment at the frame root',
152
+ code: `// Responsive contract:
153
+ // > 1024px nav 256 | content | inspector 380
154
+ // <= 1024px inspector overlays content (position: absolute, end-aligned)
155
+ // <= 768px nav collapses into MobileNav drawer; toolbar actions wrap`,
156
+ },
157
+ ],
158
+ },
159
+ ],
160
+ };
@@ -6,9 +6,9 @@ export const docsDense = {
6
6
  description: 'core design principles + rules for the design system',
7
7
  sections: [
8
8
  { title: 'Philosophy', content: [{ type: 'list', items: ['components over primitives', 'semantic tokens over hardcoded values', 'theme-agnostic code', 'open internals'] }] },
9
- { title: 'Rules', content: [{ type: 'list', items: ['use components', 'StyleX or Tailwind for styling', 'semantic tokens only', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
9
+ { title: 'Rules', content: [{ type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content (astryx docs layout)', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling', 'semantic tokens only', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
10
10
  { title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout. See astryx docs styling.' }] },
11
- { title: 'Anti-Patterns', content: [{ type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'read docs before inventing props'] }] },
11
+ { title: 'Anti-Patterns', content: [{ type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'no Card-wrapped list items — frame first, rows for dense data (astryx docs layout)', 'no decorative Badge — StatusDot/Token for status', 'read docs before inventing props'] }] },
12
12
  { title: 'Tokens', content: [{ type: 'prose', text: 'run npx astryx docs tokens for full reference' }] },
13
13
  ],
14
14
  };
@@ -39,6 +39,8 @@ export const docs = {
39
39
  style: 'ordered',
40
40
  items: [
41
41
  'Use components for everything they cover',
42
+ 'Layout is frame-first: pick the shell and budget regions before writing content (see \`npx astryx docs layout\`)',
43
+ 'Dense data renders as rows (Table, List/Item), edge-to-edge with dividers; Card is for widgets, galleries, and settings groups',
42
44
  'StyleX or Tailwind for custom styling; both are first-class (see \`npx astryx docs styling\`)',
43
45
  'Semantic tokens, not hardcoded values (see \`npx astryx docs tokens\`)',
44
46
  'CSS custom properties for colors, not hex values',
@@ -74,6 +76,8 @@ export const docs = {
74
76
  'Hardcoded colors (#fff). Use var(--color-*) or Tailwind semantic classes (text-primary, bg-surface)',
75
77
  'Hardcoded spacing (16px). Use spacing tokens or Tailwind spacing utilities',
76
78
  'Hardcoded <a> elements. Use useLinkComponent() so consumers can swap in their framework router via LinkProvider',
79
+ 'Wrapping every list item or page section in a Card. Decide the frame first; dense data renders as rows (see \`npx astryx docs layout\`)',
80
+ 'Badge as decoration. Reserve Badge for counts and enumerated states; use StatusDot or Token for status',
77
81
  'Inventing props. Read component docs first',
78
82
  ],
79
83
  },
@@ -6,9 +6,9 @@ export const docsZh = {
6
6
  description: 'XDS 核心设计原则和规则。',
7
7
  sections: [
8
8
  { title: '设计哲学', content: [{ type: 'list', items: ['组件优于原始元素 — 优先使用 XDS 组件', '语义化令牌优于硬编码值', '主题无关的代码 — 深色模式自动生效', '开放的内部机制 — 所有基础组件均可导出和组合'] }] },
9
- { title: '规则', content: [{ type: 'list', items: ['所有支持的场景都使用 XDS 组件', '使用 StyleX 或 Tailwind 进行样式设置', '使用语义化令牌,不使用硬编码值', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
9
+ { title: '规则', content: [{ type: 'list', items: ['所有支持的场景都使用 XDS 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 astryx docs layout)', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置', '使用语义化令牌,不使用硬编码值', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
10
10
  { title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。详见 astryx docs styling。' }] },
11
- { title: '反模式', content: [{ type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要自创属性。先阅读组件文档'] }] },
11
+ { title: '反模式', content: [{ type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要把每个列表项都包在 Card 里 — 先定框架,密集数据用行渲染(见 astryx docs layout)', '不要把 Badge 当装饰 — 状态请使用 StatusDot 或 Token', '不要自创属性。先阅读组件文档'] }] },
12
12
  { title: '设计令牌', content: [{ type: 'prose', text: '运行 npx astryx docs tokens 查看完整参考' }] },
13
13
  ],
14
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.2-canary.bfcbf64",
3
+ "version": "0.1.2-canary.c11faf5",
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",
@@ -75,9 +75,9 @@
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/core": "0.1.2-canary.bfcbf64",
79
- "@astryxdesign/lab": "0.1.2-canary.bfcbf64",
80
- "@astryxdesign/theme-neutral": "0.1.2-canary.bfcbf64",
78
+ "@astryxdesign/core": "0.1.2-canary.c11faf5",
79
+ "@astryxdesign/lab": "0.1.2-canary.c11faf5",
80
+ "@astryxdesign/theme-neutral": "0.1.2-canary.c11faf5",
81
81
  "gpt-tokenizer": "^2.0.0"
82
82
  },
83
83
  "peerDependenciesMeta": {
@@ -92,9 +92,9 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@astryxdesign/core": "0.1.2-canary.bfcbf64",
96
- "@astryxdesign/lab": "0.1.2-canary.bfcbf64",
97
- "@astryxdesign/theme-neutral": "0.1.2-canary.bfcbf64",
95
+ "@astryxdesign/core": "0.1.2-canary.c11faf5",
96
+ "@astryxdesign/lab": "0.1.2-canary.c11faf5",
97
+ "@astryxdesign/theme-neutral": "0.1.2-canary.c11faf5",
98
98
  "gpt-tokenizer": "^2.0.0"
99
99
  },
100
100
  "scripts": {
@@ -0,0 +1,192 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Programmatic API for the blog command.
5
+ *
6
+ * The blog is read the same way any feed reader reads it: over the published
7
+ * RSS feed. Listing parses the feed; reading a post fetches the plaintext
8
+ * (.txt) alternate the feed advertises for each item. Nothing here touches the
9
+ * blog's source files — the CLI is just a consumer of the public feed, so the
10
+ * blog's structure can change freely without touching the CLI.
11
+ */
12
+
13
+ import {AstryxError} from './error.mjs';
14
+ import {ERROR_CODES} from '../lib/error-codes.mjs';
15
+ import {SITE_URL, SITE_ORIGIN} from '../lib/site.mjs';
16
+
17
+ /** Abort a feed/post fetch that hangs, and cap how much we'll read. */
18
+ const FETCH_TIMEOUT_MS = 15000;
19
+ const MAX_BYTES = 5 * 1024 * 1024; // 5 MB — a blog feed is never larger.
20
+
21
+ const FEED_URL = new URL('/rss.xml', SITE_URL).toString();
22
+
23
+ async function fetchText(url) {
24
+ const controller = new AbortController();
25
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
26
+ let res;
27
+ try {
28
+ res = await fetch(url, {
29
+ signal: controller.signal,
30
+ redirect: 'follow',
31
+ });
32
+ } catch (e) {
33
+ clearTimeout(timer);
34
+ const reason = e.name === 'AbortError' ? 'timed out' : e.message;
35
+ throw new AstryxError(
36
+ `Could not reach ${url}: ${reason}`,
37
+ [],
38
+ ERROR_CODES.ERR_FETCH_FAILED,
39
+ );
40
+ }
41
+ clearTimeout(timer);
42
+ if (!res.ok) {
43
+ throw new AstryxError(
44
+ `Request to ${url} failed with ${res.status}`,
45
+ [],
46
+ ERROR_CODES.ERR_FETCH_FAILED,
47
+ );
48
+ }
49
+ const body = await res.text();
50
+ if (body.length > MAX_BYTES) {
51
+ throw new AstryxError(
52
+ `Response from ${url} exceeded ${MAX_BYTES} bytes`,
53
+ [],
54
+ ERROR_CODES.ERR_FETCH_FAILED,
55
+ );
56
+ }
57
+ return body;
58
+ }
59
+
60
+ /**
61
+ * Defense in depth: a post's plaintext URL comes from feed content. Require it
62
+ * to live on the canonical origin so even a tampered feed can't redirect the
63
+ * CLI to another host.
64
+ */
65
+ function assertCanonicalOrigin(target) {
66
+ let targetOrigin;
67
+ try {
68
+ targetOrigin = new URL(target).origin;
69
+ } catch {
70
+ throw new AstryxError(
71
+ `Post has an invalid plaintext URL: "${target}"`,
72
+ [],
73
+ ERROR_CODES.ERR_FETCH_FAILED,
74
+ );
75
+ }
76
+ if (targetOrigin !== SITE_ORIGIN) {
77
+ throw new AstryxError(
78
+ `Refusing to fetch post text from a non-canonical origin (${targetOrigin})`,
79
+ [],
80
+ ERROR_CODES.ERR_FETCH_FAILED,
81
+ );
82
+ }
83
+ }
84
+
85
+ function unescapeXml(value) {
86
+ return value
87
+ .replace(/&lt;/g, '<')
88
+ .replace(/&gt;/g, '>')
89
+ .replace(/&quot;/g, '"')
90
+ .replace(/&apos;/g, "'")
91
+ .replace(/&amp;/g, '&');
92
+ }
93
+
94
+ function tag(item, name) {
95
+ const m = item.match(new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`));
96
+ return m ? unescapeXml(m[1].trim()) : '';
97
+ }
98
+
99
+ function tagAll(item, name) {
100
+ const out = [];
101
+ const re = new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`, 'g');
102
+ let m;
103
+ while ((m = re.exec(item))) out.push(unescapeXml(m[1].trim()));
104
+ return out;
105
+ }
106
+
107
+ /** Extract the plaintext alternate href from an <item>. */
108
+ function textHref(item) {
109
+ // Match the atom:link alternate regardless of attribute order/quoting; then
110
+ // confirm it's the text/plain alternate before trusting the href.
111
+ const re = /<atom:link\b[^>]*?\/?>/g;
112
+ let m;
113
+ while ((m = re.exec(item))) {
114
+ const el = m[0];
115
+ if (/rel\s*=\s*["']alternate["']/.test(el) &&
116
+ /type\s*=\s*["']text\/plain["']/.test(el)) {
117
+ const href = el.match(/href\s*=\s*["']([^"']+)["']/);
118
+ if (href) return unescapeXml(href[1]);
119
+ }
120
+ }
121
+ return null;
122
+ }
123
+
124
+ /** Derive a slug from a post link (last path segment). */
125
+ function slugFromLink(link) {
126
+ try {
127
+ const path = new URL(link).pathname.replace(/\/$/, '');
128
+ return path.slice(path.lastIndexOf('/') + 1);
129
+ } catch {
130
+ return link;
131
+ }
132
+ }
133
+
134
+ function parseFeed(xml) {
135
+ const items = [];
136
+ const re = /<item>([\s\S]*?)<\/item>/g;
137
+ let m;
138
+ while ((m = re.exec(xml))) {
139
+ const raw = m[1];
140
+ const link = tag(raw, 'link');
141
+ items.push({
142
+ slug: slugFromLink(link),
143
+ title: tag(raw, 'title'),
144
+ description: tag(raw, 'description'),
145
+ date: tag(raw, 'pubDate'),
146
+ type: tag(raw, 'category'),
147
+ authors: tagAll(raw, 'author'),
148
+ link,
149
+ textUrl: textHref(raw),
150
+ });
151
+ }
152
+ return items;
153
+ }
154
+
155
+ /**
156
+ * List posts (from the feed), or read one post (via its .txt alternate).
157
+ * Both envelopes carry `feedUrl` so a caller can hit the RSS feed directly.
158
+ * The feed is always the canonical site — there is no user-supplied URL.
159
+ *
160
+ * @param {string} [slug]
161
+ * @returns {Promise<{type: string, data: unknown}>}
162
+ */
163
+ export async function blog(slug) {
164
+ const xml = await fetchText(FEED_URL);
165
+ const posts = parseFeed(xml);
166
+
167
+ if (!slug) {
168
+ return {type: 'blog.list', data: {feedUrl: FEED_URL, posts}};
169
+ }
170
+
171
+ const normalized = slug.toLowerCase();
172
+ const post = posts.find(p => p.slug.toLowerCase() === normalized);
173
+ if (!post) {
174
+ throw new AstryxError(
175
+ `No blog post with slug "${slug}"`,
176
+ posts.map(p => ({name: p.slug, reason: 'available post'})),
177
+ ERROR_CODES.ERR_UNKNOWN_POST,
178
+ );
179
+ }
180
+
181
+ if (!post.textUrl) {
182
+ throw new AstryxError(
183
+ `Post "${slug}" has no plaintext alternate in the feed`,
184
+ [],
185
+ ERROR_CODES.ERR_FETCH_FAILED,
186
+ );
187
+ }
188
+
189
+ assertCanonicalOrigin(post.textUrl);
190
+ const text = await fetchText(post.textUrl);
191
+ return {type: 'blog.detail', data: {...post, feedUrl: FEED_URL, text}};
192
+ }
@@ -0,0 +1,144 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Tests for the blog API — reads the blog over the canonical RSS feed
5
+ * and fetches each post's plaintext (.txt) alternate. `fetch` is stubbed so
6
+ * the tests never hit the network. The feed origin is fixed (not
7
+ * user-configurable), so the tests assert the canonical URLs directly.
8
+ */
9
+
10
+ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
11
+ import {blog} from './blog.mjs';
12
+ import {AstryxError} from './error.mjs';
13
+ import {SITE_URL} from '../lib/site.mjs';
14
+
15
+ const FEED = `<?xml version="1.0" encoding="UTF-8"?>
16
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
17
+ <channel>
18
+ <title>Astryx Blog</title>
19
+ <link>${SITE_URL}/blog</link>
20
+ <item>
21
+ <title>How Astryx works</title>
22
+ <link>${SITE_URL}/blog/how-astryx-works</link>
23
+ <guid isPermaLink="true">${SITE_URL}/blog/how-astryx-works</guid>
24
+ <description>Under the hood &amp; more</description>
25
+ <category>engineering</category>
26
+ <author>cvkxx</author>
27
+ <author>cixzhang</author>
28
+ <pubDate>Mon, 29 Jun 2026 00:00:00 GMT</pubDate>
29
+ <atom:link rel="alternate" type="text/plain" href="${SITE_URL}/blog/how-astryx-works.txt" />
30
+ </item>
31
+ <item>
32
+ <title>Introducing Astryx</title>
33
+ <link>${SITE_URL}/blog/introducing-astryx</link>
34
+ <guid isPermaLink="true">${SITE_URL}/blog/introducing-astryx</guid>
35
+ <description>The launch</description>
36
+ <category>update</category>
37
+ <author>cvkxx</author>
38
+ <pubDate>Thu, 18 Jun 2026 00:00:00 GMT</pubDate>
39
+ <atom:link rel="alternate" type="text/plain" href="${SITE_URL}/blog/introducing-astryx.txt" />
40
+ </item>
41
+ </channel>
42
+ </rss>`;
43
+
44
+ const POST_TEXT = '# How Astryx works\n\nThe body of the post.';
45
+ const FEED_URL = `${SITE_URL}/rss.xml`;
46
+ const TXT_URL = `${SITE_URL}/blog/how-astryx-works.txt`;
47
+
48
+ /** Build a fetch stub from a url→{status,body} map. */
49
+ function stubFetch(routes) {
50
+ return vi.fn(async (url, opts) => {
51
+ const u = String(url);
52
+ const r = routes[u];
53
+ if (!r) return {ok: false, status: 404, text: async () => 'not found'};
54
+ if (r.throw) throw r.throw;
55
+ return {ok: r.status < 400, status: r.status, text: async () => r.body};
56
+ });
57
+ }
58
+
59
+ beforeEach(() => {
60
+ vi.stubGlobal('fetch', stubFetch({
61
+ [FEED_URL]: {status: 200, body: FEED},
62
+ [TXT_URL]: {status: 200, body: POST_TEXT},
63
+ [`${SITE_URL}/blog/introducing-astryx.txt`]: {status: 200, body: 'launch body'},
64
+ }));
65
+ });
66
+
67
+ afterEach(() => {
68
+ vi.unstubAllGlobals();
69
+ });
70
+
71
+ describe('blog API', () => {
72
+ it('lists posts parsed from the canonical feed', async () => {
73
+ const res = await blog();
74
+ expect(res.type).toBe('blog.list');
75
+ expect(res.data.feedUrl).toBe(FEED_URL);
76
+ expect(res.data.posts.map(p => p.slug)).toEqual([
77
+ 'how-astryx-works',
78
+ 'introducing-astryx',
79
+ ]);
80
+ expect(res.data.posts[0].authors).toEqual(['cvkxx', 'cixzhang']);
81
+ expect(res.data.posts[0].textUrl).toBe(TXT_URL);
82
+ // Entity decoding works (&amp; -> &).
83
+ expect(res.data.posts[0].description).toBe('Under the hood & more');
84
+ // The list never fetches post bodies.
85
+ expect(res.data.posts[0].text).toBeUndefined();
86
+ });
87
+
88
+ it('reads a post via its plaintext alternate', async () => {
89
+ const res = await blog('how-astryx-works');
90
+ expect(res.type).toBe('blog.detail');
91
+ expect(res.data.text).toBe(POST_TEXT);
92
+ expect(res.data.feedUrl).toBe(FEED_URL);
93
+ expect(fetch).toHaveBeenCalledWith(TXT_URL, expect.any(Object));
94
+ });
95
+
96
+ it('is case-insensitive on the slug', async () => {
97
+ const res = await blog('How-Astryx-Works');
98
+ expect(res.data.slug).toBe('how-astryx-works');
99
+ });
100
+
101
+ it('throws ERR_UNKNOWN_POST with suggestions for a bad slug', async () => {
102
+ await expect(blog('does-not-exist')).rejects.toMatchObject({
103
+ code: 'ERR_UNKNOWN_POST',
104
+ });
105
+ try {
106
+ await blog('does-not-exist');
107
+ } catch (e) {
108
+ expect(e).toBeInstanceOf(AstryxError);
109
+ expect(Array.isArray(e.suggestions)).toBe(true);
110
+ expect(e.suggestions.length).toBeGreaterThan(0);
111
+ }
112
+ });
113
+
114
+ it('throws ERR_FETCH_FAILED when the feed request fails', async () => {
115
+ vi.stubGlobal('fetch', stubFetch({
116
+ [FEED_URL]: {status: 500, body: 'boom'},
117
+ }));
118
+ await expect(blog()).rejects.toMatchObject({code: 'ERR_FETCH_FAILED'});
119
+ });
120
+
121
+ it('refuses a post whose plaintext URL is on a different origin (SSRF guard)', async () => {
122
+ const evilFeed = FEED.replace(
123
+ `${SITE_URL}/blog/how-astryx-works.txt`,
124
+ 'http://169.254.169.254/latest/meta-data',
125
+ );
126
+ vi.stubGlobal('fetch', stubFetch({
127
+ [FEED_URL]: {status: 200, body: evilFeed},
128
+ 'http://169.254.169.254/latest/meta-data': {status: 200, body: 'SECRETS'},
129
+ }));
130
+ await expect(blog('how-astryx-works')).rejects.toMatchObject({
131
+ code: 'ERR_FETCH_FAILED',
132
+ });
133
+ // The internal host must never be fetched.
134
+ expect(fetch).not.toHaveBeenCalledWith(
135
+ 'http://169.254.169.254/latest/meta-data',
136
+ expect.anything(),
137
+ );
138
+ });
139
+
140
+ it('always reads from the canonical feed URL', async () => {
141
+ await blog();
142
+ expect(fetch).toHaveBeenCalledWith(FEED_URL, expect.any(Object));
143
+ });
144
+ });
package/src/api/index.mjs CHANGED
@@ -21,6 +21,7 @@
21
21
 
22
22
  export {component} from './component.mjs';
23
23
  export {docs} from './docs.mjs';
24
+ export {blog} from './blog.mjs';
24
25
  export {discover} from './discover.mjs';
25
26
  export {template} from './template.mjs';
26
27
  export {themeAdd, listThemes} from './theme-add.mjs';