@astryxdesign/cli 0.6.3-canary.dea6813 → 0.6.3-canary.e7819e0

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 (176) hide show
  1. package/README.md +18 -32
  2. package/api/build/build.doc.mjs +3 -3
  3. package/api/build/build.test.mjs +3 -14
  4. package/api/build/build.type.d.mts +1 -35
  5. package/api/build/build.type.mjs +3 -24
  6. package/api/build/help/help.d.mts +5 -8
  7. package/api/build/help/help.mjs +6 -56
  8. package/api/component/component.doc.mjs +2 -11
  9. package/api/component/component.mjs +0 -29
  10. package/api/component/component.test.mjs +0 -38
  11. package/api/component/component.type.d.mts +1 -11
  12. package/api/component/component.type.mjs +1 -8
  13. package/api/discover/discover.doc.mjs +1 -1
  14. package/api/gap-report/gap-report.doc.mjs +4 -7
  15. package/api/init/init.doc.mjs +0 -4
  16. package/api/init/init.test.mjs +1 -41
  17. package/api/init/remove/remove.mjs +1 -1
  18. package/api/init/run/run.mjs +10 -20
  19. package/api/integration/add-contribution.mjs +0 -11
  20. package/api/integration/add-contribution.test.mjs +0 -80
  21. package/api/integration/integrationAdd.doc.mjs +4 -7
  22. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  23. package/api/integration/validate-integration.mjs +0 -2
  24. package/api/integration/validateIntegration.doc.mjs +1 -1
  25. package/api/json/parseResponse.doc.mjs +2 -2
  26. package/api/layout/expand/expand.mjs +5 -7
  27. package/api/layout/grammar/grammar.mjs +1 -2
  28. package/api/layout/layoutExpand.doc.mjs +1 -1
  29. package/api/search/search.d.mts +9 -2
  30. package/api/search/search.doc.mjs +1 -5
  31. package/api/search/search.mjs +3 -10
  32. package/api/search/search.test.mjs +0 -34
  33. package/api/swizzle/copy/copy.mjs +11 -28
  34. package/api/swizzle/swizzle.doc.mjs +1 -1
  35. package/api/template/copy/copy.mjs +23 -17
  36. package/api/template/copy/copy.test.mjs +0 -17
  37. package/api/template/template.doc.mjs +1 -2
  38. package/api/theme/add/add.mjs +3 -20
  39. package/api/theme/build/build.mjs +37 -114
  40. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  41. package/api/theme/build/font-warning.mjs +3 -3
  42. package/api/theme/build/font-warning.test.mjs +2 -5
  43. package/api/theme/palette/generate/generate.mjs +2 -7
  44. package/api/theme/palette/generate/generate.test.mjs +0 -96
  45. package/api/theme/palette/generate/generator.mjs +1 -8
  46. package/api/theme/palette/generate/generator.test.mjs +0 -10
  47. package/api/theme/template/template.mjs +2 -11
  48. package/api/theme/template/template.test.mjs +0 -15
  49. package/api/theme/themeBuild.doc.mjs +4 -7
  50. package/api/theme/themeTemplate.doc.mjs +1 -4
  51. package/api/upgrade/_adapter.mjs +4 -27
  52. package/api/upgrade/list/list.mjs +1 -2
  53. package/api/upgrade/status/status.mjs +2 -2
  54. package/api/upgrade/upgrade.doc.mjs +1 -2
  55. package/api/upgrade/upgrade.type.d.mts +0 -4
  56. package/api/upgrade/upgrade.type.mjs +0 -1
  57. package/assets/codemods/term-log.mjs +8 -32
  58. package/assets/codemods/term-log.test.mjs +1 -19
  59. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -47
  60. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +10 -57
  61. package/authoring/config/config.doc.mjs +1 -1
  62. package/authoring/config/type.ts +3 -15
  63. package/clients/cli/commands/blog.mjs +8 -23
  64. package/clients/cli/commands/blog.test.mjs +1 -42
  65. package/clients/cli/commands/build-theme.mjs +5 -5
  66. package/clients/cli/commands/build-theme.path-safety.test.mjs +1 -86
  67. package/clients/cli/commands/build-theme.variants.test.mjs +0 -76
  68. package/clients/cli/commands/build.doc.mjs +1 -4
  69. package/clients/cli/commands/build.mjs +47 -32
  70. package/clients/cli/commands/component/index.mjs +7 -2
  71. package/clients/cli/commands/component-package.test.mjs +0 -18
  72. package/clients/cli/commands/component-resolution.test.mjs +0 -21
  73. package/clients/cli/commands/component.test.mjs +0 -19
  74. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  75. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -48
  76. package/clients/cli/commands/discover.doc.mjs +2 -4
  77. package/clients/cli/commands/discover.mjs +3 -3
  78. package/clients/cli/commands/doctor.mjs +16 -6
  79. package/clients/cli/commands/doctor.test.mjs +0 -42
  80. package/clients/cli/commands/gap-report.doc.mjs +5 -16
  81. package/clients/cli/commands/gap-report.test.mjs +0 -72
  82. package/clients/cli/commands/hook/index.mjs +17 -7
  83. package/clients/cli/commands/init.doc.mjs +8 -19
  84. package/clients/cli/commands/integration-add.doc.mjs +5 -21
  85. package/clients/cli/commands/interactive-guard.test.mjs +24 -101
  86. package/clients/cli/commands/json-contract.test.mjs +0 -33
  87. package/clients/cli/commands/layout-check.doc.mjs +3 -14
  88. package/clients/cli/commands/layout-expand.doc.mjs +4 -21
  89. package/clients/cli/commands/layout.doc.mjs +2 -2
  90. package/clients/cli/commands/layout.mjs +9 -21
  91. package/clients/cli/commands/search.doc.mjs +3 -6
  92. package/clients/cli/commands/search.mjs +7 -17
  93. package/clients/cli/commands/search.test.mjs +0 -75
  94. package/clients/cli/commands/swizzle.doc.mjs +1 -2
  95. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -42
  96. package/clients/cli/commands/template.doc.mjs +6 -28
  97. package/clients/cli/commands/theme-add.doc.mjs +1 -2
  98. package/clients/cli/commands/theme-build.doc.mjs +6 -7
  99. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -19
  100. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -12
  101. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  102. package/clients/cli/commands/upgrade.doc.mjs +6 -17
  103. package/clients/cli/index.mjs +30 -13
  104. package/clients/cli/lib/cli-error.test.mjs +0 -7
  105. package/clients/cli/lib/component-format.mjs +9 -9
  106. package/clients/cli/lib/component-format.test.mjs +1 -1
  107. package/clients/cli/lib/define-command.mjs +6 -32
  108. package/clients/cli/lib/hook-format.mjs +5 -5
  109. package/clients/cli/lib/json-shim.mjs +2 -38
  110. package/clients/cli/lib/json-shim.test.mjs +0 -83
  111. package/clients/cli/lib/manifest.d.ts +0 -2
  112. package/clients/cli/lib/manifest.mjs +0 -22
  113. package/clients/cli/lib/manifest.test.mjs +0 -17
  114. package/clients/cli/lib/update-check.mjs +83 -0
  115. package/clients/cli/lib/update-check.test.mjs +137 -0
  116. package/clients/cli/update-hint-commands.test.mjs +54 -0
  117. package/foundation/agent-docs/agent-docs.d.mts +0 -4
  118. package/foundation/agent-docs/agent-docs.mjs +3 -69
  119. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +4 -266
  120. package/foundation/config/integration-debug.test.mjs +3 -28
  121. package/foundation/config/project.mjs +9 -123
  122. package/foundation/config/project.test.mjs +0 -126
  123. package/foundation/discovery/template-adapter.d.mts +5 -14
  124. package/foundation/discovery/template-adapter.mjs +25 -292
  125. package/foundation/fs/module-loader.d.mts +0 -1
  126. package/foundation/fs/module-loader.mjs +1 -50
  127. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +94 -129
  128. package/foundation/integrations/autolink.mjs +1 -6
  129. package/foundation/response/base.d.ts +4 -8
  130. package/foundation/response/error-codes.doc.mjs +2 -1
  131. package/foundation/response/error-codes.mjs +1 -1
  132. package/foundation/response/error-codes.test.mjs +0 -83
  133. package/foundation/response/json-contract.test.mjs +0 -11
  134. package/foundation/response/json.d.mts +2 -4
  135. package/foundation/response/json.mjs +10 -8
  136. package/foundation/response/response-types.doc.mjs +3 -3
  137. package/foundation/xle/expand.d.mts +0 -2
  138. package/foundation/xle/expand.mjs +2 -3
  139. package/package.json +9 -9
  140. package/api/integration/add-contribution.component-names.test.mjs +0 -120
  141. package/api/json/envelope-types.test.mjs +0 -76
  142. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  143. package/api/search/search-return-type.test.mjs +0 -54
  144. package/api/theme/add/add.binary.test.mjs +0 -91
  145. package/api/theme/add/add.staging.test.mjs +0 -66
  146. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  147. package/api/upgrade/list/list.test.mjs +0 -73
  148. package/authoring/config/debug-composition.test.mjs +0 -92
  149. package/clients/cli/command-load-failure.test.mjs +0 -83
  150. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -161
  151. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  152. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -50
  153. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  154. package/clients/cli/commands/build.text-fields.test.mjs +0 -40
  155. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  156. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  157. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  158. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  159. package/clients/cli/commands/init.flag-help.test.mjs +0 -153
  160. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  161. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  162. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  163. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
  164. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  165. package/clients/cli/commands/template.flag-help.test.mjs +0 -117
  166. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  167. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -87
  168. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -188
  169. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -88
  170. package/clients/cli/latest-version-env.test.mjs +0 -50
  171. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -82
  172. package/clients/cli/lib/exit-codes.test.mjs +0 -97
  173. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -248
  174. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  175. package/foundation/fs/module-loader.stdout.test.mjs +0 -332
  176. package/foundation/xle/expand.test.mjs +0 -54
@@ -48,21 +48,4 @@ describe('template.copy — overwrite + path safety', () => {
48
48
  ).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
49
49
  expect(fs.existsSync(path.join(dir, '..', 'escape.tsx'))).toBe(false);
50
50
  }, SLOW);
51
-
52
- it('rejects a directory target whose page.tsx is a symlink leading outside cwd', async () => {
53
- const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-copy-outside-'));
54
- try {
55
- const victim = path.join(outside, 'victim.tsx');
56
- fs.writeFileSync(victim, 'OUTSIDE');
57
- fs.mkdirSync(path.join(dir, 'dest'));
58
- fs.symlinkSync(victim, path.join(dir, 'dest', 'page.tsx'));
59
-
60
- await expect(
61
- template('blank', {targetPath: './dest', overwrite: true, cwd: dir}),
62
- ).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
63
- expect(fs.readFileSync(victim, 'utf-8')).toBe('OUTSIDE');
64
- } finally {
65
- fs.rmSync(outside, {recursive: true, force: true});
66
- }
67
- }, SLOW);
68
51
  });
@@ -75,8 +75,7 @@ export const doc = {
75
75
  name: 'options.targetPath',
76
76
  type: 'string',
77
77
  description:
78
- 'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy. ' +
79
- 'A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block\'s own file name for a block.',
78
+ 'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy.',
80
79
  },
81
80
  {
82
81
  name: 'options.overwrite',
@@ -26,20 +26,6 @@ function defaultTargetDir(slug) {
26
26
  return path.join('src', 'themes', slug);
27
27
  }
28
28
 
29
- /**
30
- * The bytes to write for one listed file. Only UTF-8 text loses our header;
31
- * anything else (a font, an image) is copied verbatim, since decoding it would
32
- * corrupt it.
33
- * @param {Buffer} bytes
34
- * @returns {Buffer | string}
35
- */
36
- function scaffoldContents(bytes) {
37
- const text = bytes.toString('utf-8');
38
- return Buffer.from(text, 'utf-8').equals(bytes)
39
- ? stripCopyrightHeader(text)
40
- : bytes;
41
- }
42
-
43
29
  /**
44
30
  * Copy a bundled theme's files into the consumer's project (defaults to
45
31
  * `src/themes/<slug>/`). Writes are staged to temp files then renamed, rolling
@@ -148,12 +134,9 @@ export async function themeAdd(slug, options = {}) {
148
134
  label: `theme destination for ${w.name}`,
149
135
  });
150
136
  fs.mkdirSync(path.dirname(dest), {recursive: true});
151
- // The staging file is an output path too: confine it, and never write
152
- // through an entry that already exists under its name.
153
- const tmp = assertWithin(`${w.name}.${process.pid}.tmp`, resolvedDir, {
154
- label: `theme staging file for ${w.name}`,
155
- });
156
- fs.writeFileSync(tmp, scaffoldContents(fs.readFileSync(w.src)), {flag: 'wx'});
137
+ const tmp = `${dest}.${process.pid}.tmp`;
138
+ const contents = stripCopyrightHeader(fs.readFileSync(w.src, 'utf-8'));
139
+ fs.writeFileSync(tmp, contents);
157
140
  staged.push({tmp, dest});
158
141
  }
159
142
  for (const s of staged) {
@@ -224,10 +224,10 @@ function staleBuildOutputs(writes, cwd) {
224
224
  /** @param {Array<{dest: string, content: string}>} writes */
225
225
  function writeBuildOutputs(writes) {
226
226
  if (writes.length === 0) return;
227
+ fs.mkdirSync(path.dirname(writes[0].dest), {recursive: true});
227
228
  /** @type {Array<{tmp: string, dest: string}>} */
228
229
  const staged = [];
229
230
  try {
230
- fs.mkdirSync(path.dirname(writes[0].dest), {recursive: true});
231
231
  for (const write of writes) {
232
232
  const tmp = `${write.dest}.${process.pid}.tmp`;
233
233
  fs.writeFileSync(tmp, write.content);
@@ -1871,7 +1871,7 @@ function validatePrivateVars(themeDef) {
1871
1871
  if (prop.startsWith('--_')) {
1872
1872
  errors.push(
1873
1873
  `Component "${component}" (${[key, ...path].join(' ')}) sets private var "${prop}". ` +
1874
- `Private vars (--_*) are internal; use standard CSS properties ` +
1874
+ `Private vars (--_*) are internal — use standard CSS properties ` +
1875
1875
  `(e.g. borderRadius, padding) instead. The pipeline expands them automatically.`,
1876
1876
  );
1877
1877
  }
@@ -1931,7 +1931,20 @@ function getThemeComponentLayers(themeDef) {
1931
1931
  */
1932
1932
  function validateCustomHeadingTypes(themeDef) {
1933
1933
  const layers = getThemeComponentLayers(themeDef);
1934
- const customTypes = customHeadingTypes(themeDef);
1934
+ const customTypes = new Set();
1935
+ for (const {components} of layers) {
1936
+ const headingRules = components.heading;
1937
+ if (!headingRules || typeof headingRules !== 'object') continue;
1938
+
1939
+ for (const key of Object.keys(headingRules)) {
1940
+ for (const pair of key.split('+')) {
1941
+ const colon = pair.indexOf(':');
1942
+ if (colon === -1 || pair.slice(0, colon) !== 'type') continue;
1943
+ const value = pair.slice(colon + 1);
1944
+ if (value && !BUILTIN_HEADING_TYPES.has(value)) customTypes.add(value);
1945
+ }
1946
+ }
1947
+ }
1935
1948
 
1936
1949
  const errors = [];
1937
1950
  for (const type of customTypes) {
@@ -1958,65 +1971,10 @@ function validateCustomHeadingTypes(themeDef) {
1958
1971
  return errors;
1959
1972
  }
1960
1973
 
1961
- /**
1962
- * Custom Heading type names declared on the root or media-surface component
1963
- * maps: the names the generated `HeadingTypeMap` augmentation enrolls.
1964
- *
1965
- * @param {{components?: Record<string, Record<string, unknown>>}} themeDef
1966
- * @returns {Set<string>}
1967
- */
1968
- function customHeadingTypes(themeDef) {
1969
- /** @type {Set<string>} */
1970
- const customTypes = new Set();
1971
- for (const {components} of getThemeComponentLayers(themeDef)) {
1972
- const headingRules = components.heading;
1973
- if (!headingRules || typeof headingRules !== 'object') continue;
1974
-
1975
- for (const key of Object.keys(headingRules)) {
1976
- for (const pair of key.split('+')) {
1977
- const colon = pair.indexOf(':');
1978
- if (colon === -1 || pair.slice(0, colon) !== 'type') continue;
1979
- const value = pair.slice(colon + 1);
1980
- if (value && !BUILTIN_HEADING_TYPES.has(value)) customTypes.add(value);
1981
- }
1982
- }
1983
- }
1984
- return customTypes;
1985
- }
1986
-
1987
- /**
1988
- * Custom Heading types with no standalone rule in the generated CSS. A type
1989
- * whose every declaration the compiler dropped still passes the source check,
1990
- * and its augmentation would then name a type that has no styles.
1991
- *
1992
- * @param {Set<string>} types
1993
- * @param {string} css - Generated root component and media-surface rules.
1994
- * @returns {string[]}
1995
- */
1996
- function headingTypesWithoutEmittedRule(types, css) {
1997
- /** @type {string[]} */
1998
- const missing = [];
1999
- for (const type of types) {
2000
- const selector = `.astryx-heading[data-type="${type}"]`;
2001
- let emitted = false;
2002
- for (
2003
- let at = css.indexOf(selector);
2004
- at !== -1 && !emitted;
2005
- at = css.indexOf(selector, at + 1)
2006
- ) {
2007
- // A following attribute is a combined selector, not the standalone rule.
2008
- emitted = css[at + selector.length] !== '[';
2009
- }
2010
- if (!emitted) missing.push(type);
2011
- }
2012
- return missing;
2013
- }
2014
-
2015
1974
  /**
2016
1975
  * Return true when a style object contains a declaration that the theme
2017
- * generator can emit. Empty pseudo blocks and blank values do not count: they
2018
- * produce no usable CSS and would leave the generated type augmentation
2019
- * without a usable rule.
1976
+ * generator can emit. Empty pseudo blocks do not count: they produce no CSS
1977
+ * and would leave the generated type augmentation without a usable rule.
2020
1978
  *
2021
1979
  * @param {unknown} styles
2022
1980
  * @returns {boolean}
@@ -2030,12 +1988,7 @@ function hasUsableStyleDeclaration(styles) {
2030
1988
  if (hasUsableStyleDeclaration(value)) return true;
2031
1989
  continue;
2032
1990
  }
2033
- if (
2034
- value !== undefined &&
2035
- value !== null &&
2036
- typeof value !== 'object' &&
2037
- String(value).trim() !== ''
2038
- ) {
1991
+ if (value !== undefined && value !== null && typeof value !== 'object') {
2039
1992
  return true;
2040
1993
  }
2041
1994
  }
@@ -2210,14 +2163,14 @@ async function themeBuildInternal(
2210
2163
  const noticeMessages = [];
2211
2164
  for (const w of warnings) {
2212
2165
  warningMessages.push(w);
2213
- logger.warn(` [warn] ${w}`);
2166
+ logger.warn(` ⚠ ${w}`);
2214
2167
  }
2215
2168
 
2216
2169
  // Validate no private vars are set directly
2217
2170
  const privateVarErrors = validatePrivateVars(themeDef);
2218
2171
  for (const e of privateVarErrors) {
2219
2172
  warningMessages.push(e);
2220
- logger.error(` [error] ${e}`);
2173
+ logger.error(` ✗ ${e}`);
2221
2174
  }
2222
2175
  if (privateVarErrors.length > 0) {
2223
2176
  logger.error(
@@ -2243,7 +2196,7 @@ async function themeBuildInternal(
2243
2196
  // capability exports are checked against what the theme actually asks for.
2244
2197
  if (!_defineTheme || !_generateThemeRulesSplit) {
2245
2198
  throw new AstryxError(
2246
- 'Could not load @astryxdesign/core/theme: `astryx theme build` requires a ' +
2199
+ 'Could not load @astryxdesign/core/theme — `astryx theme build` requires a ' +
2247
2200
  'built, resolvable @astryxdesign/core so it emits the same CSS as the ' +
2248
2201
  'runtime <Theme>. Build @astryxdesign/core first (e.g. `pnpm -F @astryxdesign/core ' +
2249
2202
  'build`)' +
@@ -2432,29 +2385,10 @@ async function themeBuildInternal(
2432
2385
  for (const message of droppedDeclarations) {
2433
2386
  const w = `Declaration ${message}. The generated CSS omits it; fix the value in the theme source.`;
2434
2387
  warningMessages.push(w);
2435
- logger.warn(` [warn] ${w}`);
2436
- }
2437
- const unemittedHeadingTypes = headingTypesWithoutEmittedRule(
2438
- customHeadingTypes(themeDef),
2439
- `${component.join('\n')}\n${onMediaCss}`,
2440
- );
2441
- if (unemittedHeadingTypes.length > 0) {
2442
- throw new AstryxError(
2443
- unemittedHeadingTypes
2444
- .map(
2445
- type =>
2446
- `Custom Heading type "${type}" has no declaration the theme ` +
2447
- `compiler could emit: every declaration in its standalone ` +
2448
- `"type:${type}" rule was dropped. Give that rule at least one ` +
2449
- 'valid declaration.',
2450
- )
2451
- .join('\n'),
2452
- undefined,
2453
- ERROR_CODES.ERR_THEME_INVALID,
2454
- );
2388
+ logger.warn(` ⚠ ${w}`);
2455
2389
  }
2456
2390
  if (cssParts.length === 0) {
2457
- logger.log('No overrides found; nothing to build.');
2391
+ logger.log('No overrides found — nothing to build.');
2458
2392
  return null;
2459
2393
  }
2460
2394
  // The data-token defaults are theme-independent and go in @layer
@@ -2505,18 +2439,7 @@ async function themeBuildInternal(
2505
2439
  // Guard: relative paths must not escape cwd via `../`. Absolute paths are
2506
2440
  // trusted (the user explicitly controls where output goes, like gcc -o).
2507
2441
  if (!path.isAbsolute(options.out)) {
2508
- try {
2509
- assertWithin(options.out, cwd, {label: 'output path'});
2510
- } catch (err) {
2511
- if (err instanceof PathSafetyError) {
2512
- throw new AstryxError(
2513
- err.message,
2514
- undefined,
2515
- ERROR_CODES.ERR_PATH_TRAVERSAL,
2516
- );
2517
- }
2518
- throw err;
2519
- }
2442
+ assertWithin(options.out, cwd, {label: 'output path'});
2520
2443
  }
2521
2444
  } else {
2522
2445
  outPath = path.join(path.dirname(filePath), `${baseName}.css`);
@@ -2625,10 +2548,10 @@ async function themeBuildInternal(
2625
2548
  const stale = staleBuildOutputs(writes, cwd);
2626
2549
  const upToDate = stale.length === 0;
2627
2550
  if (upToDate) {
2628
- logger.log(`\n[ok] Theme outputs are up to date with ${sourceRelative}.`);
2551
+ logger.log(`\n✓ Theme outputs are up to date with ${sourceRelative}.`);
2629
2552
  } else {
2630
2553
  logger.error(
2631
- `\n[fail] ${stale.length} theme output(s) are out of date with ${sourceRelative}:`,
2554
+ `\n✗ ${stale.length} theme output(s) are out of date with ${sourceRelative}:`,
2632
2555
  );
2633
2556
  for (const s of stale) {
2634
2557
  logger.error(
@@ -2650,17 +2573,17 @@ async function themeBuildInternal(
2650
2573
 
2651
2574
  writeBuildOutputs(writes);
2652
2575
 
2653
- logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
2576
+ logger.log(`\n✓ ${path.relative(cwd, outPath)}`);
2654
2577
  logger.log(
2655
2578
  ` ${tokenCount} token overrides, ${componentCount} component overrides`,
2656
2579
  );
2657
2580
  logger.log(` ${size} KB`);
2658
- logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
2659
- logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
2581
+ logger.log(`✓ ${path.relative(cwd, jsPath)}`);
2582
+ logger.log(`✓ ${path.relative(cwd, dtsPath)}`);
2660
2583
  if (variantDtsPath && variantDecl) {
2661
2584
  const augCount = (variantDecl.match(/': true;/g) || []).length;
2662
2585
  logger.log(
2663
- `[ok] ${path.relative(cwd, variantDtsPath)} (${augCount} type augmentations)`,
2586
+ `✓ ${path.relative(cwd, variantDtsPath)} (${augCount} type augmentations)`,
2664
2587
  );
2665
2588
  }
2666
2589
 
@@ -2670,7 +2593,7 @@ async function themeBuildInternal(
2670
2593
  const cssImport = importSpecifier(relOutDir, cssBase) + '.css';
2671
2594
  const exportName = `${toIdentifier(baseName)}Theme`;
2672
2595
  logger.log(`
2673
- Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
2596
+ Install in your app (paths are relative to a file in src/ — adjust if yours lives elsewhere):
2674
2597
 
2675
2598
  import { ${exportName} } from '${jsImport}';
2676
2599
  import '${cssImport}';
@@ -2702,7 +2625,7 @@ Or with a <link> tag:
2702
2625
  // Adaptation rules are resolved theme writes in their own right, so a family
2703
2626
  // named only inside one needs the same notice as one named at the root.
2704
2627
  for (const family of unloadedFonts) {
2705
- const msg = `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`;
2628
+ const msg = `Font "${family}" is named by this theme but not loaded — add a <link> or @font-face in your app (recipe: astryx docs typography)`;
2706
2629
  noticeMessages.push(msg);
2707
2630
  logger.log(` note: ${msg}`);
2708
2631
  }
@@ -2996,11 +2919,11 @@ export async function themeBuildFamily(
2996
2919
  const upToDate = stale.length === 0;
2997
2920
  if (upToDate) {
2998
2921
  logger.log(
2999
- `\n[ok] Theme family outputs are up to date with ${sourceRelative}.`,
2922
+ `\n✓ Theme family outputs are up to date with ${sourceRelative}.`,
3000
2923
  );
3001
2924
  } else {
3002
2925
  logger.error(
3003
- `\n[fail] ${stale.length} theme family output(s) are out of date:`,
2926
+ `\n✗ ${stale.length} theme family output(s) are out of date:`,
3004
2927
  );
3005
2928
  for (const entry of stale) {
3006
2929
  logger.error(
@@ -3020,7 +2943,7 @@ export async function themeBuildFamily(
3020
2943
  };
3021
2944
  }
3022
2945
  writeBuildOutputs(writes);
3023
- for (const output of Object.values(outputs)) logger.log(`[ok] ${output}`);
2946
+ for (const output of Object.values(outputs)) logger.log(`✓ ${output}`);
3024
2947
  const themeBindings = members.map(member => bindings.get(member.theme.name));
3025
2948
  const relOutDir = path.relative(cwd, outDir) || '.';
3026
2949
  const jsImport = importSpecifier(relOutDir, baseName);
@@ -3038,7 +2961,7 @@ Or load the same stylesheet natively:
3038
2961
  ];
3039
2962
  const notices = unloadedFonts.map(
3040
2963
  family =>
3041
- `Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`,
2964
+ `Font "${family}" is named by this theme family but not loaded — add a <link> or @font-face in your app (recipe: astryx docs typography)`,
3042
2965
  );
3043
2966
  for (const notice of notices) logger.log(` note: ${notice}`);
3044
2967
  return {
@@ -19,7 +19,7 @@
19
19
  * next one is covered without touching this file.
20
20
  *
21
21
  * Asserted on the receipt's `warnings` rather than on a rejection: a private
22
- * var is reported (logged `[error]`, collected into the receipt) and the build then
22
+ * var is reported (logged `✗`, collected into the receipt) and the build then
23
23
  * emits its CSS and resolves anyway. Asserting a throw would pass for the
24
24
  * wrong reason — it never throws, which is why a throwaway build read as a
25
25
  * pass on the first version of #5214.
@@ -211,11 +211,11 @@ export function formatFontLoadingHelp(themeName, families) {
211
211
  const first = families[0];
212
212
  const slug = first.toLowerCase().replace(/ /g, '-');
213
213
  return `
214
- [note] Theme "${themeName}" names fonts it does not load: ${named}
215
- The built CSS only sets font-family; load these in your app, or every
214
+ ⚠ Theme "${themeName}" names fonts it does not load: ${named}
215
+ The built CSS only sets font-family — load these in your app, or every
216
216
  browser quietly falls back.
217
217
 
218
- Google Fonts (add :wght@... axes as your theme's weights require):
218
+ Google Fonts (add :wght@… axes as your theme's weights require):
219
219
 
220
220
  <link rel="preconnect" href="https://fonts.googleapis.com" />
221
221
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
@@ -227,15 +227,12 @@ describe('formatFontLoadingHelp', () => {
227
227
  const help = formatFontLoadingHelp('ocean', ['Fraunces', 'JetBrains Mono']);
228
228
 
229
229
  it('names the theme and every family in the headline', () => {
230
- expect(help).toContain('[note] Theme "ocean"');
230
+ expect(help).toContain('⚠');
231
+ expect(help).toContain('ocean');
231
232
  expect(help).toContain('"Fraunces"');
232
233
  expect(help).toContain('"JetBrains Mono"');
233
234
  });
234
235
 
235
- it('is plain ASCII', () => {
236
- expect(help).not.toMatch(/[\u0080-\uffff]/);
237
- });
238
-
239
236
  it('includes the Google Fonts recipe: preconnect pair + the exact css2 URL', () => {
240
237
  expect(help).toContain(
241
238
  '<link rel="preconnect" href="https://fonts.googleapis.com"',
@@ -86,8 +86,7 @@ function serializePalette(palette, indentation = 0) {
86
86
 
87
87
  /** @param {TonalPaletteCandidate} candidate */
88
88
  export function serializePaletteCandidate(candidate) {
89
- const stops = candidate.stops.map(stop => ` ${JSON.stringify(stop)}`);
90
- return `{\n "schemaVersion": 1,\n "status": "candidate",\n "recipe": ${JSON.stringify(candidate.recipe)},\n "black": ${JSON.stringify(candidate.black)},\n "white": ${JSON.stringify(candidate.white)},\n "stops": [\n${stops.join(',\n')}\n ],\n "palette": ${serializePalette(candidate.palette, 2)}\n}\n`;
89
+ return `{\n "schemaVersion": 1,\n "status": "candidate",\n "recipe": ${JSON.stringify(candidate.recipe)},\n "black": ${JSON.stringify(candidate.black)},\n "white": ${JSON.stringify(candidate.white)},\n "stops": ${JSON.stringify(candidate.stops)},\n "palette": ${serializePalette(candidate.palette, 2)}\n}\n`;
91
90
  }
92
91
 
93
92
  /** @param {TonalPaletteCandidate} candidate @param {string} outputPath */
@@ -169,11 +168,7 @@ function existingFileIdentity(filePath) {
169
168
  ) {
170
169
  return null;
171
170
  }
172
- throw new AstryxError(
173
- `Could not write palette candidate: ${error instanceof Error ? error.message : String(error)}`,
174
- undefined,
175
- ERROR_CODES.ERR_WRITE_FAILED,
176
- );
171
+ throw error;
177
172
  }
178
173
  }
179
174
 
@@ -1,11 +1,9 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- import {createHash} from 'node:crypto';
4
3
  import * as fs from 'node:fs';
5
4
  import * as os from 'node:os';
6
5
  import * as path from 'node:path';
7
6
  import {afterEach, describe, expect, it} from 'vitest';
8
- import {isErrorCode} from '../../../../foundation/response/error-codes.mjs';
9
7
  import {themePaletteGenerate} from './generate.mjs';
10
8
 
11
9
  const temporaryDirectories = [];
@@ -103,81 +101,6 @@ describe('themePaletteGenerate', () => {
103
101
  expect(result.data.receipt).toBe('ocean.palette.receipt.json');
104
102
  });
105
103
 
106
- it('writes candidate JSON byte-identical to the recipe fixtures', () => {
107
- const families = [
108
- {id: 'neutral', name: 'Neutral', seed: '#777777', kind: 'neutral'},
109
- {id: 'blue', name: 'Blue', seed: '#0074e2'},
110
- {id: 'orange', name: 'Orange', seed: '#d57113'},
111
- ];
112
- const fixtures = [
113
- [
114
- {families},
115
- 3755,
116
- '11c40191d508274d89d631bb4e1cb662f70ff0dce6c0dec101c317f9f69d3e25',
117
- ],
118
- [
119
- {
120
- modeStrategy: 'light-only',
121
- stops: [20, 50, 80],
122
- families: [
123
- {
124
- id: 'blue',
125
- name: 'Blue',
126
- seed: '#0074e2',
127
- anchors: [
128
- {mode: 'light', stop: 50, color: '#1682d5', policy: 'exact'},
129
- ],
130
- },
131
- ],
132
- },
133
- 327,
134
- 'c42929be3c4b5cb857cada078f62bb5a2242c1a22cfa4ae7546a18592540f7f3',
135
- ],
136
- [
137
- {
138
- modeStrategy: 'dark-only',
139
- stops: [40],
140
- families: [{id: 'red', name: 'Red', seed: '#d62830'}],
141
- },
142
- 258,
143
- '88d3d69865c74c7fb14347b9967575285a7d44ab893087a08bc842bb66b29bbb',
144
- ],
145
- [
146
- {
147
- stops: [60, 80, 95],
148
- families: [
149
- {id: 'green', name: 'Green', seed: '#358a3a'},
150
- {id: 'teal', name: 'Teal', seed: '#0c7365'},
151
- {id: 'cyan', name: 'Cyan', seed: '#0c6f82'},
152
- ],
153
- },
154
- 910,
155
- '873821574fdbe3357304dbc06986bd2e5ec88af80d0f36305626fd826c3cf07b',
156
- ],
157
- ];
158
-
159
- for (const [request, bytes, sha256] of fixtures) {
160
- const cwd = fixture();
161
- fs.writeFileSync(
162
- path.join(cwd, 'palette.config.json'),
163
- JSON.stringify(request),
164
- );
165
-
166
- const printed = themePaletteGenerate('palette.config.json', {}, {cwd});
167
- expect(printed.data.generationReceipt.candidateSha256).toBe(sha256);
168
-
169
- const result = themePaletteGenerate(
170
- 'palette.config.json',
171
- {out: 'candidate.json'},
172
- {cwd},
173
- );
174
- const written = fs.readFileSync(path.join(cwd, 'candidate.json'));
175
- expect(written.length).toBe(bytes);
176
- expect(createHash('sha256').update(written).digest('hex')).toBe(sha256);
177
- expect(result.data.generationReceipt.candidateSha256).toBe(sha256);
178
- }
179
- });
180
-
181
104
  it('preserves mixed decimal and integer stop order in every artifact', () => {
182
105
  const cwd = fixture();
183
106
  fs.writeFileSync(
@@ -344,23 +267,4 @@ describe('themePaletteGenerate', () => {
344
267
  themePaletteGenerate('palette.config.json', {}, {cwd}),
345
268
  ).toThrow('Could not parse palette config');
346
269
  });
347
-
348
- it('reports an output path it cannot use with a registered error code', () => {
349
- const cwd = fixture();
350
- fs.writeFileSync(path.join(cwd, 'blocker'), '');
351
-
352
- for (const options of [
353
- {out: 'blocker/ocean.palette.json'},
354
- {preview: 'blocker/ocean.palette.html'},
355
- ]) {
356
- let error;
357
- try {
358
- themePaletteGenerate('palette.config.json', options, {cwd});
359
- } catch (caught) {
360
- error = caught;
361
- }
362
- expect(error).toMatchObject({code: 'ERR_WRITE_FAILED'});
363
- expect(isErrorCode(error.code)).toBe(true);
364
- }
365
- });
366
270
  });
@@ -37,7 +37,6 @@ export const COMPACT_11_STOPS = Object.freeze([
37
37
 
38
38
  const DARK_CHROMA_FACTOR = 0.85;
39
39
  const RESERVED_FAMILY_IDS = new Set(['black', 'white']);
40
- const NEUTRAL_PROFILES = ['neutral-v1', 'warm-v1', 'cool-v1', 'custom'];
41
40
 
42
41
  /** @param {number} value @param {number} minimum @param {number} maximum */
43
42
  function clamp(value, minimum, maximum) {
@@ -666,17 +665,11 @@ export function normalizeGenerationRequest(input) {
666
665
  anchors,
667
666
  };
668
667
  });
669
- const neutralProfile = input.neutralProfile ?? 'neutral-v1';
670
- // The receipt records this request, so an unknown profile fails even when no
671
- // neutral family reads it.
672
- if (!NEUTRAL_PROFILES.includes(neutralProfile)) {
673
- throw new Error(`Unknown neutral profile: ${String(neutralProfile)}`);
674
- }
675
668
  /** @type {NormalizedRequest} */
676
669
  const request = {
677
670
  recipe: PALETTE_RECIPE,
678
671
  vibrancy: input.vibrancy ?? 50,
679
- neutralProfile,
672
+ neutralProfile: input.neutralProfile ?? 'neutral-v1',
680
673
  modeStrategy,
681
674
  stops,
682
675
  families: normalizedFamilies,
@@ -293,16 +293,6 @@ describe('astryx-oklch-v1 palette generator', () => {
293
293
  ).toThrow('Anchor mode dark is not generated by mode strategy light-only');
294
294
  });
295
295
 
296
- it('rejects an unknown neutral profile even without a neutral family', () => {
297
- expect(() =>
298
- generatePaletteSet({neutralProfile: 'warm-v2', families: [families[1]]}),
299
- ).toThrow('Unknown neutral profile: warm-v2');
300
- expect(
301
- generatePaletteSet({neutralProfile: 'warm-v1', families: [families[1]]})
302
- .request.neutralProfile,
303
- ).toBe('warm-v1');
304
- });
305
-
306
296
  it('normalizes anchor colors in the generation receipt', () => {
307
297
  const result = generatePaletteSet({
308
298
  modeStrategy: 'light-only',
@@ -62,17 +62,8 @@ export function themeTemplate(options = {}) {
62
62
 
63
63
  // Our repo header has no business in someone else's source tree.
64
64
  const contents = stripCopyrightHeader(fs.readFileSync(THEME_TEMPLATE_SRC, 'utf-8'));
65
- try {
66
- fs.mkdirSync(path.dirname(resolved), {recursive: true});
67
- fs.writeFileSync(resolved, contents);
68
- } catch (err) {
69
- const message = err instanceof Error ? err.message : String(err);
70
- throw new AstryxError(
71
- `Failed to write the theme template to ${relative}: ${message}`,
72
- undefined,
73
- ERROR_CODES.ERR_WRITE_FAILED,
74
- );
75
- }
65
+ fs.mkdirSync(path.dirname(resolved), {recursive: true});
66
+ fs.writeFileSync(resolved, contents);
76
67
 
77
68
  return {type: 'theme.template', data: {path: relative, written: true, reason: null}};
78
69
  }
@@ -14,7 +14,6 @@ import * as fs from 'node:fs';
14
14
  import * as path from 'node:path';
15
15
  import * as os from 'node:os';
16
16
  import {themeTemplate, THEME_TEMPLATE_DEFAULT_PATH} from './template.mjs';
17
- import {isErrorCode} from '../../../foundation/response/error-codes.mjs';
18
17
 
19
18
  let tmpDir;
20
19
  beforeEach(() => {
@@ -80,18 +79,4 @@ describe('themeTemplate()', () => {
80
79
  );
81
80
  expect(fs.existsSync(path.join(path.dirname(tmpDir), 'escaped.ts'))).toBe(false);
82
81
  });
83
-
84
- it('reports a failed write with a registered error code', () => {
85
- fs.writeFileSync(path.join(tmpDir, 'blocker'), '');
86
-
87
- let error;
88
- try {
89
- themeTemplate({cwd: tmpDir, targetPath: 'blocker/theme.ts'});
90
- } catch (caught) {
91
- error = caught;
92
- }
93
-
94
- expect(error).toMatchObject({code: 'ERR_WRITE_FAILED'});
95
- expect(isErrorCode(error.code)).toBe(true);
96
- });
97
82
  });
@@ -73,7 +73,7 @@ export const doc = {
73
73
  {
74
74
  type: 'theme.build',
75
75
  description:
76
- 'Build receipt {name, tokenCount, componentCount, sizeKB, outputs, warnings, notices}: the theme name; how many tokens (portable plus theme-local) and component targets it overrides; the CSS size in KB; the written outputs {css, js, dts, and variantsDts when custom prop values were augmented}; warnings, the defects the author should fix, including exact canonical replacements for deprecated component target keys and declarations the generator dropped; and notices, advisories about a correct theme, such as a font it names but does not load. Resolves to null instead when the theme produced no CSS (nothing to build).',
76
+ 'Build receipt: theme name, token- and component-override counts, output size in KB, the written outputs {css, js, dts, and variantsDts when custom prop values were augmented}, and validation warnings—including exact canonical replacements for deprecated component target keys. Resolves to null instead when the theme produced no CSS (nothing to build).',
77
77
  },
78
78
  {
79
79
  type: 'theme.build.check',
@@ -87,13 +87,10 @@ export const doc = {
87
87
  code: 'ERR_THEME_LOAD',
88
88
  when: 'the file cannot be loaded or parsed into a defineTheme() result',
89
89
  },
90
- {
91
- code: 'ERR_THEME_INVALID',
92
- when: 'the resolved theme is invalid, for example it has no name, or a custom Heading type has no standalone rule with a declaration the compiler can emit',
93
- },
90
+ {code: 'ERR_THEME_INVALID', when: 'the resolved theme has no name'},
94
91
  {
95
92
  code: 'ERR_PATH_TRAVERSAL',
96
- when: 'the theme name contains a path separator or traversal marker, or a relative `out` path resolves outside cwd (including through a symlink)',
93
+ when: 'the theme name contains a path separator or traversal marker',
97
94
  },
98
95
  {
99
96
  code: 'ERR_CORE_NOT_FOUND',
@@ -105,7 +102,7 @@ export const doc = {
105
102
  },
106
103
  {
107
104
  code: 'ERR_WRITE_FAILED',
108
- when: 'creating the output directory or writing the outputs fails (staged temp files are rolled back)',
105
+ when: 'writing the outputs fails (staged temp files are rolled back)',
109
106
  },
110
107
  ],
111
108
  examples: [