@astryxdesign/cli 0.6.5 → 0.6.6

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 (217) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +16 -15
  3. package/api/build/_adapter.d.mts +50 -2
  4. package/api/build/_adapter.mjs +98 -10
  5. package/api/build/build.doc.mjs +2 -2
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/kit/kit.mjs +98 -22
  8. package/api/build/kit/rank.d.mts +32 -8
  9. package/api/build/kit/rank.mjs +291 -97
  10. package/api/build/kit/rank.test.mjs +231 -48
  11. package/api/build/kit/weights.d.mts +82 -0
  12. package/api/build/kit/weights.json +1 -0
  13. package/api/build/kit/weights.mjs +305 -0
  14. package/api/build/kit/weights.test.mjs +190 -0
  15. package/api/docs/docs.d.mts +6 -0
  16. package/api/docs/docs.depth.test.mjs +132 -0
  17. package/api/docs/docs.doc.mjs +31 -2
  18. package/api/docs/docs.mjs +44 -1
  19. package/api/docs/docs.test.mjs +279 -0
  20. package/api/docs/docs.type.d.mts +38 -1
  21. package/api/docs/docs.type.mjs +18 -1
  22. package/api/docs/integration-tree.test.mjs +572 -0
  23. package/api/docs/integrationDocs.test.mjs +336 -0
  24. package/api/docs/node/node.d.mts +28 -3
  25. package/api/docs/node/node.mjs +146 -23
  26. package/api/error.d.mts +22 -0
  27. package/api/error.mjs +42 -0
  28. package/api/gap-report/gap-report.d.mts +3 -1
  29. package/api/gap-report/gap-report.mjs +12 -2
  30. package/api/gap-report/gap-report.test.mjs +106 -0
  31. package/api/hook/list/list.d.mts +1 -1
  32. package/api/integration/add-contribution.d.mts +2 -1
  33. package/api/integration/add-contribution.mjs +7 -3
  34. package/api/integration/add-contribution.test.mjs +3 -3
  35. package/api/integration/add-theme.mjs +338 -26
  36. package/api/integration/add-theme.test.mjs +314 -1
  37. package/api/integration/authoring-checks.mjs +10 -7
  38. package/api/integration/authoring-checks.type.d.mts +8 -0
  39. package/api/integration/authoring-checks.type.mjs +7 -3
  40. package/api/integration/integration-authoring.type.d.mts +4 -1
  41. package/api/integration/integration-authoring.type.mjs +6 -1
  42. package/api/integration/integrationAdd.doc.mjs +6 -0
  43. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  44. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  45. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  46. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  47. package/api/integration/pack-check.mjs +12 -3
  48. package/api/integration/pack-check.test.mjs +52 -3
  49. package/api/integration/validate-integration.d.mts +4 -2
  50. package/api/integration/validate-integration.mjs +7 -2
  51. package/api/integration/validate-integration.test.mjs +55 -0
  52. package/api/integration/validate-integration.type.d.mts +5 -0
  53. package/api/integration/validate-integration.type.mjs +5 -1
  54. package/api/integration/validateIntegration.doc.mjs +1 -1
  55. package/api/layout/expand/expand.mjs +12 -7
  56. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  57. package/api/layout/layout.type.d.mts +1 -0
  58. package/api/layout/layout.type.mjs +1 -0
  59. package/api/layout/layoutExpand.doc.mjs +1 -1
  60. package/api/search/search.d.mts +36 -5
  61. package/api/search/search.doc.mjs +4 -4
  62. package/api/search/search.mjs +194 -54
  63. package/api/search/search.test.mjs +825 -0
  64. package/api/search/search.type.d.mts +5 -5
  65. package/api/search/search.type.mjs +5 -5
  66. package/api/swizzle/copy/copy.mjs +66 -3
  67. package/api/swizzle/swizzle.doc.mjs +4 -0
  68. package/api/template/copy/copy.mjs +14 -8
  69. package/api/template/copy/copy.receipt.test.mjs +77 -0
  70. package/api/template/show/show.mjs +15 -4
  71. package/api/template/show/show.test.mjs +76 -0
  72. package/api/template/template-integration.test.mjs +14 -0
  73. package/api/template/template.d.mts +1 -1
  74. package/api/template/template.doc.mjs +6 -2
  75. package/api/template/template.mjs +1 -0
  76. package/api/template/template.type.d.mts +2 -0
  77. package/api/template/template.type.mjs +2 -0
  78. package/api/theme/build/build.d.mts +24 -0
  79. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  80. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  81. package/api/theme/build/build.mjs +381 -77
  82. package/api/theme/build/build.project-core.test.mjs +165 -0
  83. package/api/theme/build/build.test.mjs +190 -1
  84. package/api/theme/build/icon-imports.d.mts +47 -0
  85. package/api/theme/build/icon-imports.mjs +691 -0
  86. package/api/theme/themeBuild.doc.d.mts +4 -1
  87. package/api/theme/themeBuild.doc.mjs +14 -3
  88. package/api/upgrade/run/run.mjs +20 -3
  89. package/api/upgrade/run/run.test.mjs +45 -1
  90. package/api/upgrade/upgrade.doc.mjs +1 -1
  91. package/api/upgrade/upgrade.type.d.mts +1 -0
  92. package/api/upgrade/upgrade.type.mjs +1 -0
  93. package/assets/docs/icons.doc.mjs +1 -0
  94. package/assets/docs/theme.doc.mjs +3 -2
  95. package/assets/docs/tokens.doc.mjs +3 -3
  96. package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
  97. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  98. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  99. package/assets/docs/tree/checks.doc.mjs +1 -1
  100. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  101. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  102. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  103. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  104. package/assets/docs/tree/troubleshooting.doc.mjs +9 -5
  105. package/assets/docs/tree/versioning.doc.mjs +7 -6
  106. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  107. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  108. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  109. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  110. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  111. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  112. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  113. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  114. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  115. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  116. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  117. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  118. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  119. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  120. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  121. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  122. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  123. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  124. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  125. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  126. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  127. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  128. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  129. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  130. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  131. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  132. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  133. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  134. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  135. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  136. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  137. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  138. package/assets/templates/pages/library/template.doc.mjs +15 -1
  139. package/assets/templates/pages/login/template.doc.mjs +10 -1
  140. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  141. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  142. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  143. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  144. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  145. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  146. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  147. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  148. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  149. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  150. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  151. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  152. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  153. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  154. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  155. package/assets/templates/pages/table/template.doc.mjs +11 -1
  156. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  157. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  158. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  159. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  160. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  161. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  162. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  163. package/assets/templates/themes/butter/icons.tsx +2 -0
  164. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  165. package/assets/templates/themes/gothic/icons.tsx +2 -0
  166. package/assets/templates/themes/matcha/icons.tsx +2 -0
  167. package/assets/templates/themes/neutral/icons.tsx +2 -0
  168. package/assets/templates/themes/stone/icons.tsx +2 -0
  169. package/assets/templates/themes/y2k/icons.tsx +2 -0
  170. package/authoring/doctypes/template/parse.d.mts +2 -0
  171. package/authoring/doctypes/template/parse.mjs +1 -0
  172. package/authoring/doctypes/template/parse.test.mjs +21 -0
  173. package/authoring/doctypes/template/template.doc.mjs +6 -0
  174. package/authoring/doctypes/template/type.ts +10 -0
  175. package/clients/cli/commands/build-theme.mjs +8 -2
  176. package/clients/cli/commands/discover.mjs +29 -1
  177. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  178. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  179. package/clients/cli/commands/docs.doc.mjs +15 -2
  180. package/clients/cli/commands/docs.mjs +222 -5
  181. package/clients/cli/commands/docs.test.mjs +383 -0
  182. package/clients/cli/commands/doctor.mjs +4 -4
  183. package/clients/cli/commands/gap-report.mjs +12 -0
  184. package/clients/cli/commands/gap-report.test.mjs +63 -0
  185. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  186. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  187. package/clients/cli/commands/integration.mjs +3 -1
  188. package/clients/cli/commands/layout-expand.doc.mjs +3 -1
  189. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  190. package/clients/cli/commands/layout.mjs +16 -0
  191. package/clients/cli/commands/search.doc.mjs +5 -4
  192. package/clients/cli/commands/search.mjs +30 -6
  193. package/clients/cli/commands/search.test.mjs +60 -16
  194. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  195. package/clients/cli/commands/template.mjs +19 -5
  196. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  197. package/clients/cli/commands/theme-list.behavior.test.mjs +41 -0
  198. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  199. package/clients/cli/commands/write-failure.test.mjs +175 -0
  200. package/clients/cli/lib/manifest.mjs +44 -165
  201. package/clients/cli/lib/manifest.test.mjs +98 -7
  202. package/foundation/agent-docs/agent-docs.mjs +2 -1
  203. package/foundation/agent-docs/agent-docs.test.mjs +1168 -0
  204. package/foundation/discovery/template-adapter.d.mts +14 -0
  205. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  206. package/foundation/discovery/template-adapter.mjs +21 -1
  207. package/foundation/discovery/theme-discovery.d.mts +6 -0
  208. package/foundation/discovery/theme-discovery.mjs +9 -0
  209. package/foundation/doc-compiler/doc-loads.test.mjs +3 -3
  210. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  211. package/foundation/doc-compiler/tree.test.mjs +649 -0
  212. package/foundation/integrations/cli-requirement.d.mts +57 -13
  213. package/foundation/integrations/cli-requirement.mjs +84 -22
  214. package/foundation/integrations/cli-requirement.test.mjs +135 -8
  215. package/foundation/response/response-types.doc.d.mts +5 -5
  216. package/foundation/response/response-types.doc.mjs +13 -13
  217. package/package.json +1 -1
@@ -2,14 +2,15 @@
2
2
 
3
3
  /**
4
4
  * @file Tests for build's page ranker: long ideas, head nouns, family bases,
5
- * rare-word weighting, and family words taken from the templates themselves.
5
+ * rare-word weighting, keywords, family words taken from the templates
6
+ * themselves, and parts told from pages by the system's own components.
6
7
  */
7
8
 
8
9
  import {describe, it, expect} from 'vitest';
9
10
  import * as path from 'node:path';
10
11
  import {fileURLToPath} from 'node:url';
11
- import {pickStart, rankPages} from './rank.mjs';
12
- import {loadPageTemplates} from '../_adapter.mjs';
12
+ import {ideaKind, pickStart, rankPages} from './rank.mjs';
13
+ import {loadComponents, loadPageTemplates} from '../_adapter.mjs';
13
14
 
14
15
  // api/build/kit/ -> up 5 = repo root (has packages/core and the templates).
15
16
  const REPO = path.resolve(
@@ -17,14 +18,24 @@ const REPO = path.resolve(
17
18
  '../../../../..',
18
19
  );
19
20
 
20
- /** @param {string} name @param {string} category @param {string} description */
21
- const page = (name, category, description) => ({
21
+ /**
22
+ * @param {string} name
23
+ * @param {string} category
24
+ * @param {string} description
25
+ * @param {string[]} [keywords]
26
+ */
27
+ const page = (name, category, description, keywords = []) => ({
22
28
  name,
23
29
  displayName: name,
24
30
  category,
25
31
  description,
32
+ keywords,
33
+ command: `astryx template ${name} --type page`,
26
34
  });
27
35
 
36
+ /** @param {string} name @param {string[]} [keywords] */
37
+ const component = (name, keywords = []) => ({name, keywords});
38
+
28
39
  describe('rankPages on the shipped page templates', () => {
29
40
  /** @param {string} query */
30
41
  const start = async query =>
@@ -49,6 +60,19 @@ describe('rankPages on the shipped page templates', () => {
49
60
  );
50
61
  });
51
62
 
63
+ it('keeps the family base when a variant shares one incidental word', async () => {
64
+ // "comparison" and "cohort" name dashboard variants, but here each is one
65
+ // small part of a general dashboard.
66
+ expect(
67
+ await start(
68
+ 'support dashboard with ticket volume charts and a small comparison note',
69
+ ),
70
+ ).toBe('dashboard');
71
+ expect(
72
+ await start('sales dashboard with a cohort filter and weekly charts'),
73
+ ).toBe('dashboard');
74
+ });
75
+
52
76
  it('lets the head noun decide between families', async () => {
53
77
  // Both ideas mention a table and summary numbers; the head says which
54
78
  // page it is.
@@ -64,6 +88,14 @@ describe('rankPages on the shipped page templates', () => {
64
88
  ).toMatch(/^table-/);
65
89
  });
66
90
 
91
+ it('keeps a variant that leads when its family base cannot start alone', async () => {
92
+ // The dashboard base matches only the family word here; the funnel
93
+ // dashboard matches the idea.
94
+ expect(await start('a funnel for a dashboard')).toBe(
95
+ 'dashboard-cohort-funnel',
96
+ );
97
+ });
98
+
67
99
  it('does not start from one rare word', async () => {
68
100
  // "board" is the kanban board's own word; a game board is not a kanban.
69
101
  expect(
@@ -75,11 +107,10 @@ describe('rankPages on the shipped page templates', () => {
75
107
  describe('rankPages on any catalog', () => {
76
108
  it('ranks only the templates it is given', () => {
77
109
  const ranked = rankPages('dashboard', [
78
- page(
110
+ page('dashboard', 'Dashboard - Analytics', 'Tiles, charts, tables.', [
79
111
  'dashboard',
80
- 'Dashboard - Analytics',
81
- 'Tiles, charts, tables. Dashboard, metrics.',
82
- ),
112
+ 'metrics',
113
+ ]),
83
114
  ]);
84
115
  expect(ranked.map(r => r.name)).toEqual(['dashboard']);
85
116
  });
@@ -88,17 +119,14 @@ describe('rankPages on any catalog', () => {
88
119
  // An integration's family: its word is in two of its ids, so an idea
89
120
  // naming it picks the family, and its base template leads it.
90
121
  const catalog = [
91
- page(
122
+ page('dashboard', 'Dashboard - Analytics', 'Tiles, charts, tables.', [
92
123
  'dashboard',
93
- 'Dashboard - Analytics',
94
- 'Tiles, charts, tables. Dashboard, metrics.',
95
- ),
96
- page('widget', 'Widget - Basic', 'One compact card. Widget, tile.'),
97
- page(
98
- 'widget-grid',
99
- 'Widget - Grid',
100
- 'Many compact cards in a grid. Widget wall.',
101
- ),
124
+ 'metrics',
125
+ ]),
126
+ page('widget', 'Widget - Basic', 'One compact card.', ['widget', 'tile']),
127
+ page('widget-grid', 'Widget - Grid', 'Many compact cards in a grid.', [
128
+ 'widget wall',
129
+ ]),
102
130
  ];
103
131
  const ranked = rankPages('weather widget with charts', catalog);
104
132
  expect(ranked[0].name).toBe('widget');
@@ -106,15 +134,41 @@ describe('rankPages on any catalog', () => {
106
134
  expect(pickStart(ranked)?.name).toBe('widget');
107
135
  });
108
136
 
137
+ it("counts a template's keywords above words in its description", () => {
138
+ // Both mention uptime; only one names it as an idea it serves.
139
+ const catalog = [
140
+ page('ops', 'Dashboard - Ops', 'Uptime strips beside alert rows.'),
141
+ page('health', 'Dashboard - Health', 'Status tiles over time charts.', [
142
+ 'uptime',
143
+ ]),
144
+ ];
145
+ expect(rankPages('uptime overview', catalog)[0].name).toBe('health');
146
+ });
147
+
148
+ it("lets a variant displace its family's base only with two words of its own", () => {
149
+ const catalog = [
150
+ page('widget', 'Widget - Basic', 'One compact card.', ['widget']),
151
+ page('widget-weather', 'Widget - Weather', 'A forecast card.', [
152
+ 'weather',
153
+ 'forecast',
154
+ 'radar',
155
+ ]),
156
+ ];
157
+ // One word of the variant's own: still the family's base.
158
+ expect(rankPages('weather widget', catalog)[0].name).toBe('widget');
159
+ // Two: the variant.
160
+ expect(rankPages('weather widget with radar', catalog)[0].name).toBe(
161
+ 'widget-weather',
162
+ );
163
+ });
164
+
109
165
  it('weighs a word by how rare it is among page templates', () => {
110
166
  const catalog = [
111
- page('alpha', 'Dashboard - Alpha', 'Status tiles. Status overview.'),
112
- page('beta', 'Dashboard - Beta', 'Status rows. Status list.'),
113
- page(
114
- 'gamma',
115
- 'Dashboard - Gamma',
116
- 'Funnel of stages. Funnel conversion.',
117
- ),
167
+ page('alpha', 'Dashboard - Alpha', 'Status tiles.', ['status overview']),
168
+ page('beta', 'Dashboard - Beta', 'Status rows.', ['status list']),
169
+ page('gamma', 'Dashboard - Gamma', 'Funnel of stages.', [
170
+ 'funnel conversion',
171
+ ]),
118
172
  ];
119
173
  // "status" is on two templates, "funnel" on one: the rare word wins.
120
174
  const ranked = rankPages('status funnel', catalog);
@@ -127,22 +181,24 @@ describe('rankPages structure signals', () => {
127
181
  page(
128
182
  'dialog-panel',
129
183
  'Settings - Dialog',
130
- 'Preferences inside a modal container. Settings, or modal dialog.',
131
- ),
132
- page(
133
- 'tree-table',
134
- 'Table - Tree',
135
- 'Nested rows under parents. Tree, nested rows, file browser.',
136
- ),
137
- page(
138
- 'item-detail',
139
- 'Content - Item Detail',
140
- 'One item with its media. Product, listing, or item detail.',
184
+ 'Preferences inside a modal container.',
185
+ ['settings', 'modal dialog'],
141
186
  ),
187
+ page('tree-table', 'Table - Tree', 'Nested rows under parents.', [
188
+ 'tree',
189
+ 'nested rows',
190
+ 'file browser',
191
+ ]),
192
+ page('item-detail', 'Content - Item Detail', 'One item with its media.', [
193
+ 'product',
194
+ 'listing',
195
+ 'item detail',
196
+ ]),
142
197
  page(
143
198
  'docs-catalog',
144
199
  'Content - Documentation Catalog',
145
- 'A grid of category cards. Documentation, docs, or API index.',
200
+ 'A grid of category cards.',
201
+ ['documentation', 'docs', 'api index'],
146
202
  ),
147
203
  ];
148
204
 
@@ -179,18 +235,145 @@ describe('rankPages structure signals', () => {
179
235
  it('does not treat a synonym as a family name', () => {
180
236
  // "landing" is a synonym of "hero" in search, not a family word here.
181
237
  const heroes = [
182
- page(
183
- 'hero-centered',
184
- 'Gallery - Hero',
185
- 'A centered hero. Hero, banner, or landing.',
186
- ),
187
- page(
188
- 'hero-split',
189
- 'Gallery - Hero Split',
190
- 'A split hero. Hero or splash.',
191
- ),
238
+ page('hero-centered', 'Gallery - Hero', 'A centered hero.', [
239
+ 'hero',
240
+ 'banner',
241
+ 'landing',
242
+ ]),
243
+ page('hero-split', 'Gallery - Hero Split', 'A split hero.', [
244
+ 'hero',
245
+ 'splash',
246
+ ]),
192
247
  ];
193
248
  const ranked = rankPages('internal landing page', heroes);
194
249
  expect(ranked.every(r => !r.familyNamed)).toBe(true);
195
250
  });
196
251
  });
252
+
253
+ describe('ideaKind: a part of a page, told by the components the system ships', () => {
254
+ const pages = [
255
+ page('table', 'Table - Basic', 'Rows of records.'),
256
+ page('table-filter', 'Table - Filtering', 'Rows narrowed by filters.'),
257
+ page('settings', 'Settings', 'Grouped preferences.'),
258
+ ];
259
+ const components = [
260
+ component('DateRangeInput', ['date picker']),
261
+ component('Tooltip'),
262
+ component('Calendar'),
263
+ component('Table'),
264
+ component('Dialog', ['modal']),
265
+ ];
266
+ /** @param {string} idea @param {object[]} [using] */
267
+ const kind = (idea, using = components) => ideaKind(idea, pages, using);
268
+
269
+ it('takes a part from a component name or keyword at the head', () => {
270
+ expect(kind('a date range input')).toBe('part');
271
+ expect(kind('a date picker with presets')).toBe('part');
272
+ expect(kind('a tooltip')).toBe('part');
273
+ });
274
+
275
+ it('takes a page word or a family word at the head as a page', () => {
276
+ expect(kind('a calendar')).toBe('part');
277
+ expect(kind('a team calendar page')).toBe('page');
278
+ // Table is a component, but table is also a family of page templates.
279
+ expect(kind('a data table with filters')).toBe('page');
280
+ });
281
+
282
+ it("reads parts from the project's own components", () => {
283
+ // An integration's component joins the vocabulary by existing.
284
+ expect(kind('a revenue gauge')).toBe('page');
285
+ expect(
286
+ kind('a revenue gauge', [...components, component('AcmeGauge')]),
287
+ ).toBe('part');
288
+ });
289
+
290
+ it("takes an idea that lists a page's worth of pieces as a page", () => {
291
+ expect(kind('a calendar with a tooltip')).toBe('part');
292
+ expect(kind('a calendar, a tooltip, and a date range input')).toBe('page');
293
+ });
294
+
295
+ it('takes the frame of a container phrase as the frame, not the head', () => {
296
+ expect(kind('a dialog')).toBe('part');
297
+ expect(kind('saved drafts in a modal')).toBe('page');
298
+ });
299
+
300
+ it('takes a change to an existing page or part as an edit', () => {
301
+ expect(kind('add a sort toggle to the existing reports table')).toBe(
302
+ 'edit',
303
+ );
304
+ expect(kind('reuse the existing tooltip on the chart')).toBe('edit');
305
+ });
306
+
307
+ it('does not take "existing" that names no page or part as an edit', () => {
308
+ expect(kind('a new settings page inspired by the existing one')).toBe(
309
+ 'page',
310
+ );
311
+ expect(kind('show existing users in a settings page')).toBe('page');
312
+ });
313
+
314
+ it('does not take a request for a new page as an edit', () => {
315
+ expect(
316
+ kind('a new settings page based on the existing settings page'),
317
+ ).toBe('page');
318
+ expect(kind('clone the existing table as a new page')).toBe('page');
319
+ // "A new column" asks for a part, so the change stays a change.
320
+ expect(kind('add a new column to the existing reports table')).toBe('edit');
321
+ });
322
+ });
323
+
324
+ describe('pickStart on parts and edits (spec:AST-048/FR3)', () => {
325
+ const shipped = Promise.all([loadPageTemplates(REPO), loadComponents(REPO)]);
326
+ /** @param {string} query */
327
+ const start = async query => {
328
+ const [catalog, components] = await shipped;
329
+ const kind = ideaKind(query, catalog, components);
330
+ return pickStart(rankPages(query, catalog), kind)?.name ?? null;
331
+ };
332
+
333
+ it('starts a part from the page it names, else from the app shell', async () => {
334
+ expect(await start('an empty state for a settings page')).toBe('settings');
335
+ expect(await start('a date range picker')).toBeNull();
336
+ expect(await start('compact status pill with a tooltip')).toBeNull();
337
+ });
338
+
339
+ it('starts an edit of an existing page or part from the app shell', async () => {
340
+ for (const idea of [
341
+ 'add a sparkline column to the existing incidents table',
342
+ 'add a sort toggle to the existing reports dashboard',
343
+ 'swap the existing banner for a toast',
344
+ ]) {
345
+ expect(await start(idea)).toBeNull();
346
+ }
347
+ });
348
+
349
+ it('starts a new page that mentions something existing from its template', async () => {
350
+ expect(await start('a new dashboard inspired by the existing one')).toBe(
351
+ 'dashboard',
352
+ );
353
+ expect(await start('show existing users in a table page')).toMatch(
354
+ /^table/,
355
+ );
356
+ });
357
+
358
+ it('starts a new page that names an existing one from its template', async () => {
359
+ for (const idea of [
360
+ 'a new dashboard based on the existing dashboard',
361
+ 'a new dashboard like the existing dashboard',
362
+ 'clone the existing dashboard as a new page',
363
+ ]) {
364
+ expect(await start(idea)).toBe('dashboard');
365
+ }
366
+ });
367
+
368
+ it('reads a bare "existing" phrase that names a page as the builder\'s page', async () => {
369
+ expect(
370
+ await start('existing reports dashboard with a date filter'),
371
+ ).toBeNull();
372
+ });
373
+
374
+ it('still starts a whole page from its template', async () => {
375
+ expect(
376
+ await start('saved drafts in a modal with resume and delete row actions'),
377
+ ).toBe('settings-dialog');
378
+ });
379
+ });
@@ -0,0 +1,82 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The Porter stem of a lowercase word.
6
+ * @param {string} word
7
+ * @returns {string}
8
+ */
9
+ export function stem(word: string): string;
10
+ /**
11
+ * Lowercase words of an idea that can carry weight: letters only, two or more.
12
+ * @param {string} idea
13
+ * @returns {string[]}
14
+ */
15
+ export function weightWords(idea: string): string[];
16
+ /**
17
+ * Where an idea starts, by the blended weights.
18
+ * @param {string} idea
19
+ * @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
20
+ * @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
21
+ * @param {{name: string}[]} catalog the project's ready page templates
22
+ * @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
23
+ * `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
24
+ * @returns {string | null | undefined} a template id, null for the app shell,
25
+ * undefined without weights
26
+ */
27
+ export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: {
28
+ name: string;
29
+ }[], { weights, newPage }?: {
30
+ weights?: WeightsFile | null;
31
+ newPage?: boolean;
32
+ }): string | null | undefined;
33
+ /**
34
+ * @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
35
+ * per-template word weights, blended with the page ranker's own scores, picks
36
+ * the template an idea starts from.
37
+ *
38
+ * @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
39
+ * project's ready page templates, and the weights (`weights.json` beside this
40
+ * file, read by the adapter): the candidates (the app shell as `SHELL`, then page template ids), one or more
41
+ * word tables (stemmed words, a bias per candidate, and one row of weights
42
+ * per word, a character per candidate) and the blend numbers.
43
+ * @output `weighStart(idea, ranked, pick, catalog)`: the template id to start
44
+ * from, null for the app shell, or undefined when no table is available, in
45
+ * which case the ranker's own pick stands.
46
+ * @position Beside rank.mjs (api/build/kit/); kit.mjs calls it for every
47
+ * whole page (a part or an edit follows the ranker's placement rules). The
48
+ * ranker's pick of a template the tables do not list stands, so a new
49
+ * template can start a build.
50
+ */
51
+ /** The app shell, as one candidate. */
52
+ export const SHELL: "SHELL";
53
+ export type WeightTable = {
54
+ /**
55
+ * stemmed words
56
+ */
57
+ words: string[];
58
+ /**
59
+ * one per candidate
60
+ */
61
+ bias: number[];
62
+ clip: number;
63
+ step: number;
64
+ /**
65
+ * one per word: a character per candidate,
66
+ * weight = (charCode - 97) * step - clip
67
+ */
68
+ rows: string[];
69
+ };
70
+ export type WeightsFile = {
71
+ version: number;
72
+ /**
73
+ * `SHELL`, then page template ids
74
+ */
75
+ candidates: string[];
76
+ tables: WeightTable[];
77
+ /**
78
+ * three numbers per member (the tables, in order,
79
+ * with the ranker second), then one for `SHELL`
80
+ */
81
+ blend: number[];
82
+ };