@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16

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 (120) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/README.md +1 -1
  3. package/api/build/_adapter.d.mts +9 -0
  4. package/api/build/_adapter.mjs +24 -0
  5. package/api/build/kit/shell.weights.json +1 -0
  6. package/api/build/kit/shellcall.d.mts +26 -0
  7. package/api/build/kit/shellcall.mjs +87 -0
  8. package/api/build/kit/start.mjs +67 -4
  9. package/api/build/kit/weights.d.mts +15 -0
  10. package/api/build/kit/weights.mjs +27 -0
  11. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  12. package/api/doctor/_adapter.d.mts +3 -2
  13. package/api/doctor/_adapter.mjs +7 -1
  14. package/api/doctor/doctor.d.mts +8 -0
  15. package/api/doctor/doctor.mjs +53 -8
  16. package/api/doctor/theme-checks.mjs +157 -8
  17. package/api/icon/_adapter.d.mts +7 -3
  18. package/api/icon/_adapter.mjs +12 -3
  19. package/api/icon/icon.type.d.mts +15 -0
  20. package/api/icon/icon.type.mjs +10 -3
  21. package/api/icon/iconUse.doc.mjs +19 -5
  22. package/api/icon/list/list.mjs +7 -1
  23. package/api/icon/use/use.d.mts +8 -5
  24. package/api/icon/use/use.mjs +95 -13
  25. package/api/init/run/run.mjs +1 -0
  26. package/api/template/template.type.d.mts +6 -2
  27. package/api/template/template.type.mjs +2 -1
  28. package/api/theme/_adapter.mjs +16 -2
  29. package/api/theme/build/build.d.mts +10 -6
  30. package/api/theme/build/build.mjs +42 -29
  31. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  32. package/api/theme/palette/generate/generator.mjs +141 -2
  33. package/api/theme/theme.type.d.mts +39 -0
  34. package/api/theme/theme.type.mjs +21 -0
  35. package/api/theme/themeBuild.doc.mjs +1 -1
  36. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  37. package/api/theme-edit/_adapter.d.mts +1 -0
  38. package/api/theme-edit/_adapter.mjs +79 -21
  39. package/api/theme-edit/_check.d.mts +25 -2
  40. package/api/theme-edit/_check.mjs +251 -61
  41. package/api/theme-edit/_context.d.mts +2 -1
  42. package/api/theme-edit/_context.mjs +19 -1
  43. package/api/theme-edit/_edit.d.mts +16 -0
  44. package/api/theme-edit/_edit.mjs +360 -59
  45. package/api/theme-edit/_how-question.d.mts +8 -0
  46. package/api/theme-edit/_how-question.mjs +169 -22
  47. package/api/theme-edit/_marks.d.mts +13 -0
  48. package/api/theme-edit/_marks.mjs +15 -0
  49. package/api/theme-edit/_palette.d.mts +27 -0
  50. package/api/theme-edit/_palette.mjs +112 -8
  51. package/api/theme-edit/_preview-app.d.mts +46 -1
  52. package/api/theme-edit/_preview-app.mjs +367 -36
  53. package/api/theme-edit/_preview.d.mts +55 -0
  54. package/api/theme-edit/_preview.mjs +231 -6
  55. package/api/theme-edit/_project.d.mts +4 -0
  56. package/api/theme-edit/_project.mjs +27 -6
  57. package/api/theme-edit/_settings.d.mts +61 -2
  58. package/api/theme-edit/_settings.mjs +317 -115
  59. package/api/theme-edit/_tables.mjs +1 -1
  60. package/api/theme-edit/theme-edit.type.d.mts +30 -2
  61. package/api/theme-edit/theme-edit.type.mjs +10 -2
  62. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  63. package/assets/docs/author-a-theme.doc.mjs +1 -1
  64. package/assets/docs/theme.doc.dense.mjs +1 -1
  65. package/assets/docs/theme.doc.mjs +1 -1
  66. package/assets/docs/theme.doc.zh.mjs +4 -3
  67. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  68. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  69. package/assets/docs.generated.json +2 -2
  70. package/assets/self-audit.generated.json +1 -1
  71. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  72. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  73. package/assets/templates/components.generated.json +1 -1
  74. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  75. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  76. package/authoring/config/config.doc.mjs +8 -0
  77. package/authoring/config/parse.d.mts +1 -0
  78. package/authoring/config/parse.mjs +12 -0
  79. package/authoring/config/type.ts +8 -0
  80. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  81. package/clients/cli/build-id.generated.json +1 -1
  82. package/clients/cli/commands/experimental/icon.mjs +61 -6
  83. package/clients/cli/commands/experimental/theme.mjs +9 -2
  84. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  85. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  86. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  87. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  88. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  89. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  90. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  91. package/clients/cli/commands/theme.doc.mjs +7 -2
  92. package/clients/cli/commands/theme.mjs +41 -18
  93. package/clients/cli/commands.generated.json +1 -1
  94. package/clients/cli/index.mjs +25 -5
  95. package/clients/cli/manifest.generated.json +1 -1
  96. package/foundation/agent-docs/agent-docs.mjs +1 -1
  97. package/foundation/config/config-writer.d.mts +23 -0
  98. package/foundation/config/config-writer.mjs +150 -56
  99. package/foundation/config/project.mjs +43 -2
  100. package/foundation/discovery/component-discovery.mjs +6 -5
  101. package/foundation/discovery/icon-set-checks.mjs +164 -48
  102. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  103. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  104. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  105. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  106. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  107. package/foundation/discovery/icon-set-writer.mjs +57 -16
  108. package/foundation/discovery/template-icons.d.mts +27 -10
  109. package/foundation/discovery/template-icons.mjs +142 -26
  110. package/foundation/discovery/theme-discovery.d.mts +25 -0
  111. package/foundation/discovery/theme-discovery.mjs +48 -7
  112. package/foundation/fs/gather-cache.mjs +6 -2
  113. package/foundation/integrations/autolink.d.mts +4 -2
  114. package/foundation/integrations/autolink.mjs +4 -2
  115. package/foundation/integrations/cli-requirement.d.mts +16 -5
  116. package/foundation/integrations/cli-requirement.mjs +27 -6
  117. package/foundation/integrations/may-have-integrations.mjs +5 -2
  118. package/foundation/integrations/missing-dependency.d.mts +9 -0
  119. package/foundation/integrations/missing-dependency.mjs +100 -0
  120. package/package.json +6 -6
@@ -20,7 +20,9 @@
20
20
  * discovery (foundation/discovery/template-adapter.mjs) for its records, by theme discovery
21
21
  * (foundation/discovery/theme-discovery.mjs) for each integration's themes,
22
22
  * and by `doctor` (api/doctor/_adapter.mjs) for its file-only docs checks,
23
- * in a run that records modules and variables to its end. Gathers are kept only once the folder exists: the first such run
23
+ * in a run that records modules and variables to its end. The commands
24
+ * whose runs keep these entries are `search`, `build`, `component`,
25
+ * `template`, `theme`, `discover`, `docs` and `doctor`. Gathers are kept only once the folder exists: the first such run
24
26
  * on a machine just makes it, so a one-off run pays nothing to store one. Only a published CLI stores anything:
25
27
  * its build id (clients/cli/build-id.generated.json, written at `prepack`)
26
28
  * names its exact code, so a checkout, whose code may change between runs
@@ -64,6 +66,7 @@ const INTEGRATION_COMMANDS = new Set([
64
66
  'template',
65
67
  'theme',
66
68
  'discover',
69
+ 'docs',
67
70
  ]);
68
71
 
69
72
  /** The run's commands whose gathers are kept. */
@@ -74,6 +77,7 @@ const KEPT_COMMANDS = new Set([
74
77
  'template',
75
78
  'theme',
76
79
  'discover',
80
+ 'docs',
77
81
  // The project check alone (no subcommand): its docs checks are kept.
78
82
  'doctor',
79
83
  ]);
@@ -251,7 +255,7 @@ export async function recordRunFor(argv, fn) {
251
255
  return fn();
252
256
  }
253
257
  // Gathers are kept only once the folder exists: the first recorded run on a
254
- // machine (search, build, component, template, theme or discover) just makes
258
+ // machine (search, build, component, template, theme, discover or docs) just makes
255
259
  // it, so a one-off run never pays to store one.
256
260
  const dir = cacheDirPath();
257
261
  if (!withoutRecording(() => fs.existsSync(dir))) {
@@ -74,8 +74,10 @@ export function loadAutolinkCandidates({ projectDir, loaded, fresh, }: {
74
74
  * rest of that package's contributions — including the load-error marker
75
75
  * `loadIntegrations` returns for it. A CONFIGURED integration is the opposite
76
76
  * case: the project named it, so its failure is an issue the project owns and
77
- * can act on. An autolinked one is a dependency's own packaging bug, which the
78
- * consuming project can neither fix nor silence, and which
77
+ * can act on. An autolinked one is dropped here either way; the project reports
78
+ * it only when a package the dependency requires is missing (a broken install
79
+ * it can repair, INV14). Otherwise it is the dependency's own packaging bug,
80
+ * which the consuming project can neither fix nor silence, and which
79
81
  * `astryx doctor integration validate <package>` reports on demand.
80
82
  *
81
83
  * One package reached twice (an alias beside the package it aliases, at the
@@ -218,8 +218,10 @@ export async function loadAutolinkCandidates({
218
218
  * rest of that package's contributions — including the load-error marker
219
219
  * `loadIntegrations` returns for it. A CONFIGURED integration is the opposite
220
220
  * case: the project named it, so its failure is an issue the project owns and
221
- * can act on. An autolinked one is a dependency's own packaging bug, which the
222
- * consuming project can neither fix nor silence, and which
221
+ * can act on. An autolinked one is dropped here either way; the project reports
222
+ * it only when a package the dependency requires is missing (a broken install
223
+ * it can repair, INV14). Otherwise it is the dependency's own packaging bug,
224
+ * which the consuming project can neither fix nor silence, and which
223
225
  * `astryx doctor integration validate <package>` reports on demand.
224
226
  *
225
227
  * One package reached twice (an alias beside the package it aliases, at the
@@ -129,15 +129,18 @@ export function templateIconsCliProblem(pkg: any): string | null;
129
129
  * refused by a CLI it may run, or null when the `@astryxdesign/cli` range it
130
130
  * declares (in dependencies, devDependencies, optionalDependencies, or
131
131
  * peerDependencies) admits only CLIs that read the key. A list value needs a
132
- * later release than a string. A project that declares no range, or one that
133
- * is not a version range (`workspace:`, `file:`, `link:`), gets null: nothing
134
- * says which CLI it runs.
132
+ * later release than a string, and `experimental.iconVariant` a later
133
+ * release than either. A project that declares no range, or one that is not
134
+ * a version range (`workspace:`, `file:`, `link:`), gets null: nothing says
135
+ * which CLI it runs.
135
136
  * @param {any} pkg the project's package.json
136
- * @param {{list?: boolean}} [options] `list`: the value is a list
137
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value is
138
+ * a list; `variant`: the config also sets `experimental.iconVariant`
137
139
  * @returns {string | null}
138
140
  */
139
- export function projectIconSetCliWarning(pkg: any, { list }?: {
141
+ export function projectIconSetCliWarning(pkg: any, { list, variant }?: {
140
142
  list?: boolean;
143
+ variant?: boolean;
141
144
  }): string | null;
142
145
  export const CLI_PACKAGE: "@astryxdesign/cli";
143
146
  /**
@@ -233,3 +236,11 @@ export const CONFIG_ICON_SET_CLI: "0.7.4";
233
236
  * a list (a main set and backups). Earlier releases refuse the list form.
234
237
  */
235
238
  export const CONFIG_ICON_SET_LIST_CLI: "0.7.12";
239
+ /**
240
+ * The first stable CLI release that reads `experimental.iconVariant`, the
241
+ * look the project's icon sets draw. Earlier releases refuse an astryx.config
242
+ * that sets it ("Unrecognized key").
243
+ *
244
+ * Tied to the next patch slot.
245
+ */
246
+ export const CONFIG_ICON_VARIANT_CLI: "0.7.16";
@@ -410,19 +410,33 @@ export const CONFIG_ICON_SET_CLI = '0.7.4';
410
410
  */
411
411
  export const CONFIG_ICON_SET_LIST_CLI = '0.7.12';
412
412
 
413
+ /**
414
+ * The first stable CLI release that reads `experimental.iconVariant`, the
415
+ * look the project's icon sets draw. Earlier releases refuse an astryx.config
416
+ * that sets it ("Unrecognized key").
417
+ *
418
+ * Tied to the next patch slot.
419
+ */
420
+ export const CONFIG_ICON_VARIANT_CLI = '0.7.16';
421
+
413
422
  /**
414
423
  * Why an app project whose astryx.config sets `experimental.iconSet` would be
415
424
  * refused by a CLI it may run, or null when the `@astryxdesign/cli` range it
416
425
  * declares (in dependencies, devDependencies, optionalDependencies, or
417
426
  * peerDependencies) admits only CLIs that read the key. A list value needs a
418
- * later release than a string. A project that declares no range, or one that
419
- * is not a version range (`workspace:`, `file:`, `link:`), gets null: nothing
420
- * says which CLI it runs.
427
+ * later release than a string, and `experimental.iconVariant` a later
428
+ * release than either. A project that declares no range, or one that is not
429
+ * a version range (`workspace:`, `file:`, `link:`), gets null: nothing says
430
+ * which CLI it runs.
421
431
  * @param {any} pkg the project's package.json
422
- * @param {{list?: boolean}} [options] `list`: the value is a list
432
+ * @param {{list?: boolean, variant?: boolean}} [options] `list`: the value is
433
+ * a list; `variant`: the config also sets `experimental.iconVariant`
423
434
  * @returns {string | null}
424
435
  */
425
- export function projectIconSetCliWarning(pkg, {list = false} = {}) {
436
+ export function projectIconSetCliWarning(
437
+ pkg,
438
+ {list = false, variant = false} = {},
439
+ ) {
426
440
  const field = [
427
441
  'dependencies',
428
442
  'devDependencies',
@@ -432,11 +446,18 @@ export function projectIconSetCliWarning(pkg, {list = false} = {}) {
432
446
  if (!field) return null;
433
447
  const range = pkg[field][CLI_PACKAGE];
434
448
  if (range.includes(':')) return null;
435
- const needed = list ? CONFIG_ICON_SET_LIST_CLI : CONFIG_ICON_SET_CLI;
449
+ const needed = variant
450
+ ? CONFIG_ICON_VARIANT_CLI
451
+ : list
452
+ ? CONFIG_ICON_SET_LIST_CLI
453
+ : CONFIG_ICON_SET_CLI;
436
454
  const lowest = lowestAdmitted(range);
437
455
  if (lowest != null && semverCompare(lowest, needed) >= 0) {
438
456
  return null;
439
457
  }
458
+ if (variant) {
459
+ return `The project's ${CLI_PACKAGE} range "${range}" (${field}) admits a release before ${needed}, which refuses an astryx.config that sets \`experimental.iconVariant\` ("Unrecognized key"), so commands that load the project configuration, such as \`doctor\` and \`discover\`, fail there. Require "${CLI_PACKAGE}": ">=${needed}".`;
460
+ }
440
461
  if (list) {
441
462
  return `The project's ${CLI_PACKAGE} range "${range}" (${field}) admits a release before ${needed}, which refuses \`experimental.iconSet\` written as a list, so commands that load the project configuration, such as \`doctor\` and \`discover\`, fail there. Require "${CLI_PACKAGE}": ">=${needed}".`;
442
463
  }
@@ -11,8 +11,11 @@
11
11
  * integrations installed beside the running CLI load, spec AST-081 FR12),
12
12
  * so no configured, self-resolved, autolinked or computer-level integration
13
13
  * can load.
14
- * @position Read by foundation/fs/gather-cache.mjs: `component`, `template`,
15
- * `theme` and `discover` record a run only for what is worth keeping where
14
+ * @position Read by clients/cli/index.mjs, which loads the project before
15
+ * help and before each command only where an integration can load (to read
16
+ * the commands integrations declare), and by foundation/fs/gather-cache.mjs:
17
+ * `component`, `template`, `theme`, `discover` and `docs` record a run only
18
+ * for what is worth keeping where
16
19
  * an integration can load (its kept check results, and template
17
20
  * discovery's records), so a project with none skips the recorder entirely. A true
18
21
  * answer only means the run records, so a check that says true too often
@@ -0,0 +1,9 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The missing package's name when the package that imports it declares it.
6
+ * @param {string} message
7
+ * @returns {string | null}
8
+ */
9
+ export function missingDeclaredDependency(message: string): string | null;
@@ -0,0 +1,100 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Whether a module load error is a broken install: a package that the
5
+ * importing package declares is missing.
6
+ * @input A load error's message, as Node words it for an ES module ("Cannot
7
+ * find package 'x' imported from /file") or for CommonJS ("Cannot find
8
+ * module 'x'" with its require stack).
9
+ * @output `missingDeclaredDependency(message)`: the missing package's name
10
+ * when the package holding the importing file declares it as a package its
11
+ * consumers' install must hold (dependencies, or a peerDependencies entry
12
+ * not marked optional in peerDependenciesMeta), else null. A dev dependency
13
+ * is never installed for a consumer and an optional one may be skipped by
14
+ * design, so a manifest that needs either has a packaging bug, which
15
+ * reinstalling does not clear. A package listed both as a dependency and
16
+ * as an optional one is optional, as npm reads it.
17
+ * @position Read by the project (foundation/config/project.mjs) to tell an
18
+ * install the user can repair from a dependency's own packaging bug, which
19
+ * stays out of the project's issues.
20
+ */
21
+
22
+ import * as fs from 'node:fs';
23
+ import * as path from 'node:path';
24
+ import {fileURLToPath} from 'node:url';
25
+
26
+ /**
27
+ * Whether a package.json declares `name` as a package its consumers' install
28
+ * must hold: a dependency, or a peer not marked optional.
29
+ * @param {any} pkg
30
+ * @param {string} name
31
+ * @returns {boolean}
32
+ */
33
+ function requires(pkg, name) {
34
+ /** @param {unknown} field */
35
+ const has = field =>
36
+ field != null && typeof field === 'object' && Object.hasOwn(field, name);
37
+ // npm treats a package listed in both as optional (fsevents, say).
38
+ if (has(pkg.optionalDependencies)) return false;
39
+ if (has(pkg.dependencies)) return true;
40
+ return (
41
+ has(pkg.peerDependencies) &&
42
+ pkg.peerDependenciesMeta?.[name]?.optional !== true
43
+ );
44
+ }
45
+
46
+ /**
47
+ * The missing package and the file that imported it, from a load error.
48
+ * @param {string} message
49
+ * @returns {{name: string, importer: string} | null}
50
+ */
51
+ function parse(message) {
52
+ const esm =
53
+ /Cannot find (?:package|module) '([^']+)' imported from ([^\n]+)/.exec(
54
+ message,
55
+ );
56
+ const cjs =
57
+ /Cannot find module '([^']+)'\s*\nRequire stack:\n- ([^\n]+)/.exec(message);
58
+ const hit = esm ?? cjs;
59
+ if (!hit) return null;
60
+ const [, spec, found] = hit;
61
+ const from = found.trim();
62
+ if (spec.startsWith('.') || path.isAbsolute(spec) || spec.startsWith('node:'))
63
+ return null;
64
+ const parts = spec.split('/');
65
+ const name = spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
66
+ let importer = from;
67
+ try {
68
+ if (from.startsWith('file:')) importer = fileURLToPath(from);
69
+ } catch {
70
+ return null;
71
+ }
72
+ return {name, importer};
73
+ }
74
+
75
+ /**
76
+ * The missing package's name when the package that imports it declares it.
77
+ * @param {string} message
78
+ * @returns {string | null}
79
+ */
80
+ export function missingDeclaredDependency(message) {
81
+ const found = parse(message);
82
+ if (!found) return null;
83
+ let dir = path.dirname(found.importer);
84
+ for (;;) {
85
+ const file = path.join(dir, 'package.json');
86
+ if (fs.existsSync(file)) {
87
+ try {
88
+ const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
89
+ if (typeof pkg?.name === 'string') {
90
+ return requires(pkg, found.name) ? found.name : null;
91
+ }
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
96
+ const parent = path.dirname(dir);
97
+ if (parent === dir) return null;
98
+ dir = parent;
99
+ }
100
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.16-canary.ge95b87c",
3
+ "version": "0.7.16",
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",
@@ -127,7 +127,7 @@
127
127
  "zod": "^4.6.7"
128
128
  },
129
129
  "peerDependencies": {
130
- "@astryxdesign/core": "0.7.16-canary.ge95b87c"
130
+ "@astryxdesign/core": "*"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/core": {
@@ -135,10 +135,10 @@
135
135
  }
136
136
  },
137
137
  "devDependencies": {
138
- "@astryxdesign/charts": "0.7.16-canary.ge95b87c",
139
- "@astryxdesign/core": "0.7.16-canary.ge95b87c",
140
- "@astryxdesign/lab": "0.7.16-canary.ge95b87c",
141
- "@astryxdesign/theme-neutral": "0.7.16-canary.ge95b87c",
138
+ "@astryxdesign/charts": "*",
139
+ "@astryxdesign/core": "*",
140
+ "@astryxdesign/lab": "*",
141
+ "@astryxdesign/theme-neutral": "*",
142
142
  "@heroicons/react": "^2.2.0",
143
143
  "@stylexjs/stylex": "^0.19.1",
144
144
  "@types/babel__core": "^7.20.5",