@astryxdesign/cli 0.7.15 → 0.7.16-canary.g3aa244b

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 (163) hide show
  1. package/README.md +5 -3
  2. package/api/build/_adapter.d.mts +1 -0
  3. package/api/build/blocks/blocks.d.mts +1 -0
  4. package/api/build/blocks/blocks.mjs +18 -1
  5. package/api/component/_adapter.d.mts +1 -1
  6. package/api/component/_adapter.mjs +28 -1
  7. package/api/doctor/_adapter.d.mts +35 -0
  8. package/api/doctor/_adapter.mjs +69 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.d.mts +18 -0
  11. package/api/doctor/doctor.doc.mjs +1 -1
  12. package/api/doctor/doctor.mjs +104 -4
  13. package/api/doctor/theme-checks.mjs +6 -10
  14. package/api/integration/add-contribution.mjs +3 -3
  15. package/api/integration/pack-check.mjs +14 -8
  16. package/api/integration/validate-integration.mjs +1 -1
  17. package/api/search/_adapter.mjs +15 -16
  18. package/api/search/_entries.d.mts +2 -1
  19. package/api/search/_entries.mjs +28 -1
  20. package/api/swizzle/_moduleGraph.mjs +1 -1
  21. package/api/theme/_adapter.d.mts +5 -2
  22. package/api/theme/_adapter.mjs +43 -12
  23. package/api/theme/_fork.mjs +1 -1
  24. package/api/theme/build/build.d.mts +116 -32
  25. package/api/theme/build/build.mjs +449 -102
  26. package/api/theme/eject/eject.mjs +22 -1
  27. package/api/theme/template/template.d.mts +19 -0
  28. package/api/theme/template/template.mjs +102 -25
  29. package/api/theme/theme.type.d.mts +5 -1
  30. package/api/theme/theme.type.mjs +2 -1
  31. package/api/theme/themeBuild.doc.mjs +3 -3
  32. package/api/theme/themeEject.doc.mjs +1 -1
  33. package/api/theme/themeTemplate.doc.mjs +9 -3
  34. package/api/theme-edit/_adapter.d.mts +32 -2
  35. package/api/theme-edit/_adapter.mjs +264 -40
  36. package/api/theme-edit/_check.d.mts +93 -4
  37. package/api/theme-edit/_check.mjs +1727 -223
  38. package/api/theme-edit/_color.d.mts +2 -8
  39. package/api/theme-edit/_color.mjs +292 -219
  40. package/api/theme-edit/_compiler.d.mts +1 -0
  41. package/api/theme-edit/_compiler.mjs +20 -1
  42. package/api/theme-edit/_context.d.mts +31 -1
  43. package/api/theme-edit/_context.mjs +445 -41
  44. package/api/theme-edit/_css.d.mts +60 -1
  45. package/api/theme-edit/_css.mjs +404 -28
  46. package/api/theme-edit/_edit.d.mts +25 -0
  47. package/api/theme-edit/_edit.mjs +1532 -149
  48. package/api/theme-edit/_how-commands.d.mts +11 -26
  49. package/api/theme-edit/_how-commands.mjs +30 -2
  50. package/api/theme-edit/_how-question.d.mts +7 -0
  51. package/api/theme-edit/_how-question.mjs +1304 -176
  52. package/api/theme-edit/_how.mjs +144 -30
  53. package/api/theme-edit/_overview.mjs +2 -0
  54. package/api/theme-edit/_palette.d.mts +38 -0
  55. package/api/theme-edit/_palette.mjs +305 -71
  56. package/api/theme-edit/_parts.d.mts +33 -0
  57. package/api/theme-edit/_parts.mjs +138 -9
  58. package/api/theme-edit/_png.d.mts +18 -0
  59. package/api/theme-edit/_png.mjs +95 -14
  60. package/api/theme-edit/_preview-app.d.mts +36 -1
  61. package/api/theme-edit/_preview-app.mjs +1415 -96
  62. package/api/theme-edit/_preview.d.mts +64 -3
  63. package/api/theme-edit/_preview.mjs +514 -31
  64. package/api/theme-edit/_project.d.mts +11 -0
  65. package/api/theme-edit/_project.mjs +46 -12
  66. package/api/theme-edit/_settings.d.mts +278 -5
  67. package/api/theme-edit/_settings.mjs +2741 -195
  68. package/api/theme-edit/_tables.d.mts +24 -0
  69. package/api/theme-edit/_tables.mjs +211 -149
  70. package/api/theme-edit/_vet.d.mts +42 -0
  71. package/api/theme-edit/_vet.mjs +144 -0
  72. package/api/theme-edit/theme-edit.type.d.mts +20 -2
  73. package/api/theme-edit/theme-edit.type.mjs +6 -2
  74. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  75. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  76. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  77. package/api/upgrade/registry/registry.mjs +6 -1
  78. package/assets/codemods/parse.mjs +2 -2
  79. package/assets/docs/tree/single-component.doc.mjs +11 -2
  80. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  81. package/assets/docs.generated.json +2 -2
  82. package/assets/preview-app/next.config.mjs +7 -1
  83. package/assets/preview-app/package.json +1 -0
  84. package/assets/preview-app/src/app/globals.css +1 -0
  85. package/assets/self-audit.generated.json +1 -1
  86. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  87. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  88. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  89. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  90. package/assets/templates/components.generated.json +1 -1
  91. package/assets/templates/pages/dashboard/page.tsx +1 -1
  92. package/authoring/doctypes/_schema.d.mts +52 -5
  93. package/authoring/doctypes/_schema.mjs +62 -7
  94. package/authoring/doctypes/base/type.ts +10 -0
  95. package/authoring/doctypes/component/component.doc.mjs +1 -1
  96. package/authoring/doctypes/function/function.doc.mjs +6 -0
  97. package/authoring/doctypes/function/type.ts +3 -0
  98. package/authoring/doctypes/legacy.mjs +5 -1
  99. package/authoring/index.d.ts +1 -0
  100. package/authoring/shadcn/source-variants.d.mts +1 -1
  101. package/authoring/shadcn/source-variants.mjs +32 -10
  102. package/clients/cli/build-id.generated.json +1 -1
  103. package/clients/cli/commands/doctor.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental/theme.mjs +239 -45
  105. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  106. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  108. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  109. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  110. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  111. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  112. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  113. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  115. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  116. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  117. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  118. package/clients/cli/commands/theme.mjs +190 -46
  119. package/clients/cli/formatters/index.mjs +7 -4
  120. package/clients/cli/lib/cli-error.mjs +9 -3
  121. package/clients/cli/lib/component-format.mjs +27 -9
  122. package/clients/cli/lib/json-shim.mjs +72 -2
  123. package/clients/cli/manifest.generated.json +1 -1
  124. package/clients/cli/run.mjs +49 -0
  125. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  126. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  127. package/foundation/agent-docs/agent-docs.mjs +3 -2
  128. package/foundation/config/config-writer.mjs +2 -2
  129. package/foundation/config/project.mjs +60 -14
  130. package/foundation/discovery/component-discovery.mjs +5 -17
  131. package/foundation/discovery/icon-set-writer.mjs +1 -1
  132. package/foundation/discovery/module-exports.mjs +1 -15
  133. package/foundation/discovery/template-adapter.mjs +44 -19
  134. package/foundation/discovery/template-source-tree.mjs +3 -16
  135. package/foundation/discovery/theme-discovery.d.mts +5 -1
  136. package/foundation/discovery/theme-discovery.mjs +61 -43
  137. package/foundation/fs/exact-codec.d.mts +35 -0
  138. package/foundation/fs/exact-codec.mjs +148 -0
  139. package/foundation/fs/gather-cache.d.mts +15 -5
  140. package/foundation/fs/gather-cache.mjs +129 -31
  141. package/foundation/fs/paths.d.mts +39 -0
  142. package/foundation/fs/paths.mjs +44 -11
  143. package/foundation/fs/read-record.mjs +11 -1
  144. package/foundation/integrations/contribution-fixes.mjs +1 -16
  145. package/foundation/integrations/may-have-integrations.mjs +3 -2
  146. package/foundation/integrations/public-imports.mjs +1 -1
  147. package/foundation/render/embedded-imports.mjs +1 -1
  148. package/foundation/render/host-exit.d.mts +8 -0
  149. package/foundation/render/host-exit.mjs +11 -0
  150. package/foundation/render/page-host.mjs +56 -10
  151. package/foundation/render/page-worker.mjs +14 -0
  152. package/foundation/render/render-page.mjs +37 -2
  153. package/foundation/response/error-codes.d.mts +2 -1
  154. package/foundation/response/error-codes.d.ts +1 -0
  155. package/foundation/response/error-codes.doc.mjs +5 -0
  156. package/foundation/response/error-codes.mjs +3 -0
  157. package/foundation/response/json.d.mts +15 -0
  158. package/foundation/response/json.mjs +52 -1
  159. package/foundation/response/response-types.doc.mjs +1 -1
  160. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  161. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  162. package/foundation/xle/browser.d.mts +2 -2
  163. package/package.json +7 -6
package/README.md CHANGED
@@ -223,6 +223,7 @@ if (isError(result)) {
223
223
  | `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
224
224
  | `ERR_THEME_INVALID` | A theme definition or contributed theme descriptor is invalid. |
225
225
  | `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a defineTheme result. |
226
+ | `ERR_THEME_STALE` | `theme build --check` found stale or missing outputs: exit 1, in the check result (`code`), not an error. |
226
227
  | `ERR_PALETTE_GENERATION` | A palette generation request or one of its constraints was invalid. |
227
228
  | `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
228
229
  | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
@@ -511,7 +512,7 @@ Every response has a `type` discriminant. The full set is below (generated from
511
512
  | `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
512
513
  | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |
513
514
  | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
514
- | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |
515
+ | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), the full list of checked paths, and, when any is stale or missing, code ERR_THEME_STALE. Writes nothing. |
515
516
  | `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
516
517
  | `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |
517
518
  | `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |
@@ -540,8 +541,9 @@ Every response has a `type` discriminant. The full set is below (generated from
540
541
 
541
542
  ## Doctor
542
543
 
543
- `astryx doctor` runs read-only health checks against your project and
544
- environment. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and
544
+ `astryx doctor` runs health checks against your project and environment. It
545
+ changes nothing in the project; once the per-user cache folder exists, it
546
+ keeps its docs checks and integration check results there. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and
545
547
  includes an actionable `fix` when one is available. Field names match the
546
548
  `--json` keys. The exact checks and values depend on the project; the output
547
549
  shape is stable:
@@ -77,6 +77,7 @@ export function loadTreeWeights(): import("../../foundation/route/route.mjs").Cl
77
77
  export function keptBlockCatalog<T>(key: unknown[], compute: () => T, codec: {
78
78
  encode: (value: T) => any;
79
79
  decode: (stored: any) => T;
80
+ valid?: (value: any) => boolean;
80
81
  }): T;
81
82
  /**
82
83
  * The block picker's weights (blocks/blocks.weights.json), read once; null
@@ -90,6 +90,7 @@ export function pickBlocks(request: string, signals: {
90
90
  export type KeepCatalog = <T>(key: unknown[], compute: () => T, codec: {
91
91
  encode: (value: T) => any;
92
92
  decode: (stored: any) => T;
93
+ valid?: (value: any) => boolean;
93
94
  }) => T;
94
95
  export type BlockPickerWeights = {
95
96
  /**
@@ -45,7 +45,7 @@ import {STOPWORDS} from '../../search/_query.mjs';
45
45
  /**
46
46
  * Keeps a value derived from the catalog between runs (build's adapter does
47
47
  * it beside the kept search catalog), or works it out.
48
- * @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T}) => T} KeepCatalog
48
+ * @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T, valid?: (value: any) => boolean}) => T} KeepCatalog
49
49
  */
50
50
 
51
51
  /**
@@ -410,6 +410,23 @@ function computeCatalog(key, catalog, components, weights) {
410
410
  * projection as its numbers.
411
411
  */
412
412
  const CATALOG_CODEC = {
413
+ /**
414
+ * What decode can get wrong in a read-back catalog: its key, each block's
415
+ * component, and projections of one width with finite numbers.
416
+ * @param {any} read
417
+ */
418
+ valid: read => {
419
+ if (read == null || typeof read.key !== 'string') return false;
420
+ const blocks = [...read.blocks.values()];
421
+ const width = blocks[0]?.projected.length;
422
+ return blocks.every(
423
+ (/** @type {any} */ b) =>
424
+ typeof b.component === 'string' &&
425
+ b.projected.length > 0 &&
426
+ b.projected.length === width &&
427
+ [...b.projected].every(Number.isFinite),
428
+ );
429
+ },
413
430
  /** @param {ReturnType<typeof computeCatalog>} read */
414
431
  encode: read => ({
415
432
  key: read.key,
@@ -206,7 +206,7 @@ export function extractProps(docs: LoadedComponentDoc): any[];
206
206
  * Augment a loaded `component.detail` doc with ownership metadata. Adds
207
207
  * `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
208
208
  * swizzleable source file exists for the owner). Existing doc fields (name,
209
- * usage, props, …) are preserved.
209
+ * usage, props, …) are preserved; each example carries its `kind`.
210
210
  * @param {LoadedComponentDoc} docs
211
211
  * @param {OwnershipSubject} owner
212
212
  * @param {string} componentName
@@ -589,11 +589,26 @@ export function extractProps(docs) {
589
589
  );
590
590
  }
591
591
 
592
+ /**
593
+ * Give every example its `kind`, so a JSON reader never has to know the
594
+ * default: an example with no `kind` is a `demo`.
595
+ * @param {unknown} examples
596
+ * @returns {unknown}
597
+ */
598
+ function withExampleKinds(examples) {
599
+ if (!Array.isArray(examples)) return examples;
600
+ return examples.map(example =>
601
+ example && typeof example === 'object'
602
+ ? {...example, kind: example.kind ?? 'demo'}
603
+ : example,
604
+ );
605
+ }
606
+
592
607
  /**
593
608
  * Augment a loaded `component.detail` doc with ownership metadata. Adds
594
609
  * `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
595
610
  * swizzleable source file exists for the owner). Existing doc fields (name,
596
- * usage, props, …) are preserved.
611
+ * usage, props, …) are preserved; each example carries its `kind`.
597
612
  * @param {LoadedComponentDoc} docs
598
613
  * @param {OwnershipSubject} owner
599
614
  * @param {string} componentName
@@ -605,8 +620,20 @@ export function withOwnership(docs, owner, componentName, coreDir) {
605
620
  owner.package === CORE_PACKAGE
606
621
  ? (docs.import ?? resolveImportPath(coreDir, componentName))
607
622
  : resolveIntegrationImportPath(owner, componentName, docs.import);
623
+ /** @type {any} */
624
+ const doc = docs;
608
625
  return /** @type {any} */ ({
609
626
  ...docs,
627
+ ...(doc.examples ? {examples: withExampleKinds(doc.examples)} : {}),
628
+ ...(Array.isArray(doc.components)
629
+ ? {
630
+ components: doc.components.map((/** @type {any} */ entry) =>
631
+ entry?.examples
632
+ ? {...entry, examples: withExampleKinds(entry.examples)}
633
+ : entry,
634
+ ),
635
+ }
636
+ : {}),
610
637
  package: owner.package,
611
638
  import: importSpec,
612
639
  sourceAvailable: owner.sourcePath != null,
@@ -1,6 +1,23 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * A doctor check that reads only files, kept between runs through the kept
6
+ * gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
7
+ * folder, module and environment variable it read unchanged reads the check
8
+ * back. Only the docs checks go through here; a check that depends on the
9
+ * time, the network or anything else the stamps do not see never does.
10
+ * @template T
11
+ * @param {{name: string, cwd: string, coreDir: string | null}} where - The
12
+ * check, the project folder, and the Core folder the project loads.
13
+ * @param {() => Promise<T>} check
14
+ * @returns {Promise<T>}
15
+ */
16
+ export function keptFileCheck<T>({ name, cwd, coreDir }: {
17
+ name: string;
18
+ cwd: string;
19
+ coreDir: string | null;
20
+ }, check: () => Promise<T>): Promise<T>;
4
21
  /**
5
22
  * Package written to the generated app record for one discovered theme.
6
23
  * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
@@ -71,6 +88,24 @@ export function doctorElementPropOrigins(file: string, element: Parameters<typeo
71
88
  * @returns {Set<string>}
72
89
  */
73
90
  export function doctorStylesheetImports(css: string): Set<string>;
91
+ /**
92
+ * The `@astryxdesign/core` range a package's peerDependencies declare, and
93
+ * whether it accepts `coreVersion` (spec:AST-017/FR12). The one rule every
94
+ * doctor check uses to compare a package with the installed Core:
95
+ * `theme-core-peers` for added theme packages, `integration-core-range` for
96
+ * every other loaded integration.
97
+ * @param {{peerDependencies?: Record<string, unknown>} | null | undefined} pkg
98
+ * @param {string | null | undefined} coreVersion
99
+ * Any declared string is judged by `satisfiesRange`, so an empty range
100
+ * accepts every Core; only a missing range is `null`.
101
+ * @returns {{range: string | null, accepts: boolean}}
102
+ */
103
+ export function corePeerRange(pkg: {
104
+ peerDependencies?: Record<string, unknown>;
105
+ } | null | undefined, coreVersion: string | null | undefined): {
106
+ range: string | null;
107
+ accepts: boolean;
108
+ };
74
109
  /** @param {string} projectDir */
75
110
  export function findDoctorCoreDir(projectDir: string): string | null;
76
111
  /** @param {string} projectDir @param {string} packageName */
@@ -44,7 +44,13 @@ export {placeholderFixes} from '../../foundation/discovery/template-icons.mjs';
44
44
  export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mjs';
45
45
  import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
46
46
  import {cssImports} from '../../foundation/render/embedded-imports.mjs';
47
+ import {satisfiesRange} from '../../foundation/env/semver.mjs';
47
48
  import * as path from 'node:path';
49
+ import {
50
+ persistedGather,
51
+ recordedRun,
52
+ } from '../../foundation/fs/gather-cache.mjs';
53
+ import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
48
54
  import {
49
55
  Project,
50
56
  availableComputerIntegrations,
@@ -83,6 +89,44 @@ export {
83
89
  authoringAuditData,
84
90
  } from './_authoring-audit.mjs';
85
91
 
92
+ /** A doctor check record, kept as it is. */
93
+ const CHECK_CODEC = {
94
+ encode: (/** @type {any} */ check) => check,
95
+ decode: (/** @type {any} */ check) => check,
96
+ /** A check record: its id, label, status and message. */
97
+ valid: (/** @type {any} */ check) =>
98
+ check != null &&
99
+ typeof check === 'object' &&
100
+ typeof check.id === 'string' &&
101
+ typeof check.label === 'string' &&
102
+ typeof check.status === 'string' &&
103
+ typeof check.message === 'string',
104
+ };
105
+
106
+ /**
107
+ * A doctor check that reads only files, kept between runs through the kept
108
+ * gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
109
+ * folder, module and environment variable it read unchanged reads the check
110
+ * back. Only the docs checks go through here; a check that depends on the
111
+ * time, the network or anything else the stamps do not see never does.
112
+ * @template T
113
+ * @param {{name: string, cwd: string, coreDir: string | null}} where - The
114
+ * check, the project folder, and the Core folder the project loads.
115
+ * @param {() => Promise<T>} check
116
+ * @returns {Promise<T>}
117
+ */
118
+ export function keptFileCheck({name, cwd, coreDir}, check) {
119
+ // Only a recorded run (a plain `doctor` from the bin) reads or keeps one: a
120
+ // hosted run names its commands its own way, so it always checks.
121
+ if (!recordedRun()) return check();
122
+ return persistedGather(
123
+ // With the command name the checks print commands with.
124
+ ['doctor-check', name, cwd, coreDir, getCliInvocation(cwd)],
125
+ check,
126
+ CHECK_CODEC,
127
+ );
128
+ }
129
+
86
130
  /**
87
131
  * Package written to the generated app record for one discovered theme.
88
132
  * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
@@ -256,6 +300,31 @@ export function doctorStylesheetImports(css) {
256
300
  return new Set(cssImports(css));
257
301
  }
258
302
 
303
+ /**
304
+ * The `@astryxdesign/core` range a package's peerDependencies declare, and
305
+ * whether it accepts `coreVersion` (spec:AST-017/FR12). The one rule every
306
+ * doctor check uses to compare a package with the installed Core:
307
+ * `theme-core-peers` for added theme packages, `integration-core-range` for
308
+ * every other loaded integration.
309
+ * @param {{peerDependencies?: Record<string, unknown>} | null | undefined} pkg
310
+ * @param {string | null | undefined} coreVersion
311
+ * Any declared string is judged by `satisfiesRange`, so an empty range
312
+ * accepts every Core; only a missing range is `null`.
313
+ * @returns {{range: string | null, accepts: boolean}}
314
+ */
315
+ export function corePeerRange(pkg, coreVersion) {
316
+ const raw = pkg?.peerDependencies?.['@astryxdesign/core'];
317
+ const range = typeof raw === 'string' ? raw.trim() : null;
318
+ return {
319
+ range,
320
+ accepts:
321
+ range !== null &&
322
+ typeof coreVersion === 'string' &&
323
+ coreVersion !== '' &&
324
+ satisfiesRange(coreVersion, range),
325
+ };
326
+ }
327
+
259
328
  /** @param {string} projectDir */
260
329
  export function findDoctorCoreDir(projectDir) {
261
330
  return findProjectCoreDir(projectDir);
@@ -30,7 +30,7 @@ import {
30
30
  resolveBuiltPath,
31
31
  } from './_adapter.mjs';
32
32
  import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
33
- import {parse as parseModule} from '@babel/parser';
33
+ import {babelParse as parseModule} from '../../foundation/runtime/lazy-dependencies.mjs';
34
34
 
35
35
  /** Source files, read for imports and JSX. */
36
36
  const SOURCE_EXT = new Set(['.tsx', '.jsx', '.ts', '.js', '.mjs', '.cjs']);
@@ -86,6 +86,19 @@ export function checkPeerDeps(ctx: DoctorContext): DoctorCheck;
86
86
  * @returns {DoctorCheck}
87
87
  */
88
88
  export function checkIntegrationIssues(ctx: DoctorContext): DoctorCheck;
89
+ /**
90
+ * Every loaded integration's `@astryxdesign/core` peer range admits the
91
+ * installed Core: a package's declared peer ranges define the Core versions it
92
+ * supports (spec:AST-017 FR12). A package made for another Core installs with
93
+ * only a package manager warning, and its components, themes and docs may not
94
+ * work. New, so it warns: a project that passed before keeps passing.
95
+ * Packages of added themes are left to `theme-core-peers` (spec:AST-050 FR11),
96
+ * which applies the same rule. Null when Core is not installed or no other
97
+ * loaded integration declares a Core range.
98
+ * @param {DoctorContext} ctx
99
+ * @returns {DoctorCheck | null}
100
+ */
101
+ export function checkIntegrationCoreRange(ctx: DoctorContext): DoctorCheck | null;
89
102
  /**
90
103
  * The project's icon sets (AST-084 FR17). Fails when `experimental.iconSet`
91
104
  * names a set, main or backup, that is not installed, that is installed but
@@ -387,6 +400,11 @@ export type DoctorContext = {
387
400
  * false means the copy that started the run answered it (spec AST-081 FR2).
388
401
  */
389
402
  ownCli?: boolean | undefined;
403
+ /**
404
+ * - Packages of the project's added
405
+ * themes, which `theme-core-peers` checks against Core
406
+ */
407
+ addedThemePackages?: string[] | undefined;
390
408
  /**
391
409
  * - The Core release the project names
392
410
  * (installed, else locked, else declared), as the daily hint reads it.
@@ -20,7 +20,7 @@ export const doc = {
20
20
  '@astryxdesign/core install and version alignment with the CLI, installed ' +
21
21
  'themes and wiring, astryx.config validity, whether every integration ' +
22
22
  'astryx.config names loads (a failed one fails the run), integrations linked from ' +
23
- 'package.json without a config entry, core peer dependencies, ' +
23
+ 'package.json without a config entry, core peer dependencies, whether the @astryxdesign/core peer range of each loaded integration includes the installed Core (`integration-core-range`, a warning; added theme packages are checked by `theme-core-peers` instead), ' +
24
24
  'integration provider identity and contribution issues, agent docs, the ' +
25
25
  'detected package manager, and the health of the docs the CLI reads (authoring ' +
26
26
  'and CLI docs, the docs tree, doc size), and returns a structured ' +
@@ -100,6 +100,7 @@ import {
100
100
  COMPUTER_INSTALL_STEP,
101
101
  } from '../../foundation/agent-docs/computer-agent-text.mjs';
102
102
  import {
103
+ keptFileCheck,
103
104
  alignCommand,
104
105
  addCliCommandFor,
105
106
  computerAgentTextState,
@@ -117,6 +118,9 @@ import {
117
118
  releaseFacts,
118
119
  builtIntegrationPackages,
119
120
  authoringAudit,
121
+ corePeerRange,
122
+ isLocalThemeOwner,
123
+ readThemeState,
120
124
  } from './_adapter.mjs';
121
125
  import {checkBuilt} from './built-checks.mjs';
122
126
 
@@ -140,6 +144,8 @@ import {checkBuilt} from './built-checks.mjs';
140
144
  * @property {string|null} coreDir - Resolved core package directory, or null.
141
145
  * @property {boolean} [ownCli] - Whether the project installs its own CLI;
142
146
  * false means the copy that started the run answered it (spec AST-081 FR2).
147
+ * @property {string[]} [addedThemePackages] - Packages of the project's added
148
+ * themes, which `theme-core-peers` checks against Core
143
149
  * @property {string|null} [projectCore] - The Core release the project names
144
150
  * (installed, else locked, else declared), as the daily hint reads it.
145
151
  * @property {string|null} configPath - Resolved astryx.config.mjs path, or null.
@@ -190,6 +196,22 @@ function readPkg(pkgPath) {
190
196
  }
191
197
  }
192
198
 
199
+ /**
200
+ * Packages that own the project's added themes (local themes excluded); empty
201
+ * when the project manages no themes or its theme state cannot be read.
202
+ * @param {string} cwd
203
+ * @returns {string[]}
204
+ */
205
+ function addedThemePackages(cwd) {
206
+ try {
207
+ return Object.values(readThemeState(cwd).themes ?? {}).filter(
208
+ owner => typeof owner === 'string' && !isLocalThemeOwner(owner),
209
+ );
210
+ } catch {
211
+ return [];
212
+ }
213
+ }
214
+
193
215
  /**
194
216
  * Read the version of an installed package from a resolved directory.
195
217
  * @param {string|null} dir
@@ -1005,6 +1027,69 @@ export function checkIntegrationIssues(ctx) {
1005
1027
  };
1006
1028
  }
1007
1029
 
1030
+ /**
1031
+ * Every loaded integration's `@astryxdesign/core` peer range admits the
1032
+ * installed Core: a package's declared peer ranges define the Core versions it
1033
+ * supports (spec:AST-017 FR12). A package made for another Core installs with
1034
+ * only a package manager warning, and its components, themes and docs may not
1035
+ * work. New, so it warns: a project that passed before keeps passing.
1036
+ * Packages of added themes are left to `theme-core-peers` (spec:AST-050 FR11),
1037
+ * which applies the same rule. Null when Core is not installed or no other
1038
+ * loaded integration declares a Core range.
1039
+ * @param {DoctorContext} ctx
1040
+ * @returns {DoctorCheck | null}
1041
+ */
1042
+ export function checkIntegrationCoreRange(ctx) {
1043
+ const core = pkgVersion(ctx.coreDir);
1044
+ if (!core || ctx.integrations == null) return null;
1045
+ // `theme-core-peers` already judges each added theme package by the same
1046
+ // rule (`corePeerRange`), with a fix that keeps the theme setup working.
1047
+ const reportedByThemeChecks = new Set(ctx.addedThemePackages ?? []);
1048
+ /** @type {Array<{name: string, version: string | null, range: string, accepts: boolean}>} */
1049
+ const declared = [];
1050
+ for (const integration of ctx.integrations) {
1051
+ if (integration.__loadError != null || !integration.__packageDir) continue;
1052
+ const pkg = readPkg(path.join(integration.__packageDir, 'package.json'));
1053
+ const name = typeof pkg?.name === 'string' ? pkg.name : integration.name;
1054
+ if (reportedByThemeChecks.has(name)) continue;
1055
+ const {range, accepts} = corePeerRange(pkg, core);
1056
+ // An integration need not depend on Core; only a declared, non-empty range
1057
+ // is a claim about which Core it supports.
1058
+ if (range == null || range === '') continue;
1059
+ declared.push({
1060
+ name,
1061
+ version: typeof pkg?.version === 'string' ? pkg.version : null,
1062
+ range,
1063
+ accepts,
1064
+ });
1065
+ }
1066
+ if (declared.length === 0) return null;
1067
+ const excluded = declared.filter(d => !d.accepts);
1068
+ const label = 'Integrations support the installed Core';
1069
+ if (excluded.length === 0) {
1070
+ return {
1071
+ id: 'integration-core-range',
1072
+ label,
1073
+ status: 'pass',
1074
+ message: `${declared.length} loaded integration${declared.length === 1 ? ' supports' : 's support'} @astryxdesign/core ${core} (${nameIntegrations(declared)}).`,
1075
+ };
1076
+ }
1077
+ return {
1078
+ id: 'integration-core-range',
1079
+ label,
1080
+ status: 'warn',
1081
+ message: `${excluded
1082
+ .map(
1083
+ d =>
1084
+ `${d.name}${d.version ? `@${d.version}` : ''} supports @astryxdesign/core ${d.range}`,
1085
+ )
1086
+ .join(
1087
+ '; ',
1088
+ )}, but the project has ${core}. ${excluded.length === 1 ? 'Its' : 'Their'} components, themes and docs were made for another Core and may not work.`,
1089
+ fix: `Install a release of ${excluded.length === 1 ? 'that package' : 'each package'} whose @astryxdesign/core range includes ${core}, or move the project to a Core in that range. When no such release exists, ask the package's owner for one.`,
1090
+ };
1091
+ }
1092
+
1008
1093
  /**
1009
1094
  * The project's icon sets (AST-084 FR17). Fails when `experimental.iconSet`
1010
1095
  * names a set, main or backup, that is not installed, that is installed but
@@ -2192,7 +2277,7 @@ export function checkGatherCache() {
2192
2277
  id: 'gather-cache',
2193
2278
  label: 'Kept catalog cache',
2194
2279
  status: 'info',
2195
- message: `search, build, component, template, theme and discover keep what they gather (search's catalogs and each integration's check results) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2280
+ message: `search, build, component, template, theme, discover, docs and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, integrations' theme records, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2196
2281
  };
2197
2282
  }
2198
2283
 
@@ -2210,6 +2295,7 @@ export const SYNC_CHECKS = [
2210
2295
  checkConfiguredIntegrations,
2211
2296
  checkProviderIdentity,
2212
2297
  checkIntegrationIssues,
2298
+ checkIntegrationCoreRange,
2213
2299
  checkIconSets,
2214
2300
  checkIconPlaceholders,
2215
2301
  checkAgentDocs,
@@ -2400,6 +2486,7 @@ export async function runChecks(options = {}) {
2400
2486
  coreDir,
2401
2487
  ownCli: projectHasOwnCli(cwd),
2402
2488
  projectCore: projectCoreVersion(cwd),
2489
+ addedThemePackages: addedThemePackages(cwd),
2403
2490
  configPath,
2404
2491
  integrations,
2405
2492
  docsCatalog,
@@ -2465,9 +2552,22 @@ export async function runChecks(options = {}) {
2465
2552
  );
2466
2553
  }
2467
2554
  checks.push(await checkAuthoringDocs(ctx));
2468
- checks.push(await checkCliDocs(ctx));
2469
- checks.push(await checkDocsTree(ctx));
2470
- checks.push(await checkDocsProgressiveDisclosure(ctx));
2555
+ // The checks that read only files, each kept while every file it read is
2556
+ // unchanged; the Core the project loads is part of what they read.
2557
+ const where = {cwd, coreDir: coreDir ?? null};
2558
+ checks.push(
2559
+ await keptFileCheck({name: 'cli-docs', ...where}, () => checkCliDocs(ctx)),
2560
+ );
2561
+ checks.push(
2562
+ await keptFileCheck({name: 'docs-tree', ...where}, () =>
2563
+ checkDocsTree(ctx),
2564
+ ),
2565
+ );
2566
+ checks.push(
2567
+ await keptFileCheck({name: 'docs-progressive', ...where}, () =>
2568
+ checkDocsProgressiveDisclosure(ctx),
2569
+ ),
2570
+ );
2471
2571
 
2472
2572
  const summary = {pass: 0, warn: 0, fail: 0, info: 0};
2473
2573
  for (const c of checks) summary[c.status] += 1;
@@ -8,12 +8,13 @@
8
8
  */
9
9
 
10
10
  import * as path from 'node:path';
11
- import {parse} from '@babel/parser';
11
+ import {babelParse as parse} from '../../foundation/runtime/lazy-dependencies.mjs';
12
12
  import postcss from 'postcss';
13
13
  import {
14
14
  collectUnloadedFonts,
15
15
  discoverDoctorThemes,
16
16
  discoverDoctorUnmigratedCopies,
17
+ corePeerRange,
17
18
  findDoctorCoreDir,
18
19
  doctorElementPropOrigins,
19
20
  doctorStylesheetImports,
@@ -41,7 +42,6 @@ import {
41
42
  getCliInvocation,
42
43
  formatCliCommand,
43
44
  } from '../../foundation/env/package-manager.mjs';
44
- import {satisfiesRange} from '../../foundation/env/semver.mjs';
45
45
  import {logger} from '../logger.mjs';
46
46
 
47
47
  /** @typedef {import('./doctor.mjs').DoctorCheck} DoctorCheck */
@@ -1248,17 +1248,13 @@ export async function checkAppThemes(cwd) {
1248
1248
  const pkg = packageDir
1249
1249
  ? readPackageJson(path.join(packageDir, 'package.json'))
1250
1250
  : null;
1251
- const range = pkg?.peerDependencies?.['@astryxdesign/core'];
1252
- if (
1253
- !coreVersion ||
1254
- typeof range !== 'string' ||
1255
- !satisfiesRange(coreVersion, range)
1256
- ) {
1251
+ const {range, accepts} = corePeerRange(pkg, coreVersion);
1252
+ if (!accepts) {
1257
1253
  peerProblems.push({
1258
1254
  slug,
1259
1255
  owner,
1260
- range: typeof range === 'string' ? range : null,
1261
- message: `${slug}: ${owner} requires ${typeof range === 'string' ? range : 'an undeclared Core range'}, installed ${coreVersion ?? 'none'}`,
1256
+ range,
1257
+ message: `${slug}: ${owner} requires ${range ?? 'an undeclared Core range'}, installed ${coreVersion ?? 'none'}`,
1262
1258
  });
1263
1259
  }
1264
1260
  }