@astryxdesign/cli 0.7.15 → 0.7.16-canary.g07c77c0

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 (159) 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 +17 -0
  8. package/api/doctor/_adapter.mjs +43 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.mjs +18 -4
  11. package/api/doctor/theme-checks.mjs +1 -1
  12. package/api/integration/add-contribution.mjs +3 -3
  13. package/api/integration/pack-check.mjs +14 -8
  14. package/api/integration/validate-integration.mjs +1 -1
  15. package/api/search/_adapter.mjs +15 -16
  16. package/api/search/_entries.d.mts +2 -1
  17. package/api/search/_entries.mjs +28 -1
  18. package/api/swizzle/_moduleGraph.mjs +1 -1
  19. package/api/theme/_adapter.d.mts +5 -2
  20. package/api/theme/_adapter.mjs +43 -12
  21. package/api/theme/_fork.mjs +1 -1
  22. package/api/theme/build/build.d.mts +116 -32
  23. package/api/theme/build/build.mjs +449 -102
  24. package/api/theme/eject/eject.mjs +22 -1
  25. package/api/theme/template/template.d.mts +19 -0
  26. package/api/theme/template/template.mjs +102 -25
  27. package/api/theme/theme.type.d.mts +5 -1
  28. package/api/theme/theme.type.mjs +2 -1
  29. package/api/theme/themeBuild.doc.mjs +3 -3
  30. package/api/theme/themeEject.doc.mjs +1 -1
  31. package/api/theme/themeTemplate.doc.mjs +9 -3
  32. package/api/theme-edit/_adapter.d.mts +32 -2
  33. package/api/theme-edit/_adapter.mjs +213 -36
  34. package/api/theme-edit/_check.d.mts +69 -3
  35. package/api/theme-edit/_check.mjs +1517 -218
  36. package/api/theme-edit/_color.d.mts +2 -8
  37. package/api/theme-edit/_color.mjs +292 -219
  38. package/api/theme-edit/_compiler.d.mts +1 -0
  39. package/api/theme-edit/_compiler.mjs +20 -1
  40. package/api/theme-edit/_context.d.mts +29 -0
  41. package/api/theme-edit/_context.mjs +426 -40
  42. package/api/theme-edit/_css.d.mts +60 -1
  43. package/api/theme-edit/_css.mjs +404 -28
  44. package/api/theme-edit/_edit.d.mts +9 -0
  45. package/api/theme-edit/_edit.mjs +1300 -135
  46. package/api/theme-edit/_how-commands.d.mts +11 -26
  47. package/api/theme-edit/_how-commands.mjs +30 -2
  48. package/api/theme-edit/_how-question.d.mts +7 -0
  49. package/api/theme-edit/_how-question.mjs +1304 -176
  50. package/api/theme-edit/_how.mjs +144 -30
  51. package/api/theme-edit/_overview.mjs +2 -0
  52. package/api/theme-edit/_palette.d.mts +11 -0
  53. package/api/theme-edit/_palette.mjs +194 -65
  54. package/api/theme-edit/_parts.d.mts +33 -0
  55. package/api/theme-edit/_parts.mjs +138 -9
  56. package/api/theme-edit/_png.d.mts +18 -0
  57. package/api/theme-edit/_png.mjs +95 -14
  58. package/api/theme-edit/_preview-app.d.mts +9 -0
  59. package/api/theme-edit/_preview-app.mjs +1191 -71
  60. package/api/theme-edit/_preview.d.mts +16 -3
  61. package/api/theme-edit/_preview.mjs +335 -30
  62. package/api/theme-edit/_project.d.mts +11 -0
  63. package/api/theme-edit/_project.mjs +46 -12
  64. package/api/theme-edit/_settings.d.mts +240 -5
  65. package/api/theme-edit/_settings.mjs +2561 -115
  66. package/api/theme-edit/_tables.d.mts +24 -0
  67. package/api/theme-edit/_tables.mjs +211 -149
  68. package/api/theme-edit/_vet.d.mts +42 -0
  69. package/api/theme-edit/_vet.mjs +144 -0
  70. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  71. package/api/theme-edit/theme-edit.type.mjs +1 -1
  72. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  73. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  74. package/api/upgrade/registry/registry.mjs +6 -1
  75. package/assets/codemods/parse.mjs +2 -2
  76. package/assets/docs/tree/single-component.doc.mjs +11 -2
  77. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  78. package/assets/docs.generated.json +2 -2
  79. package/assets/preview-app/next.config.mjs +7 -1
  80. package/assets/preview-app/package.json +1 -0
  81. package/assets/preview-app/src/app/globals.css +1 -0
  82. package/assets/self-audit.generated.json +1 -1
  83. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  84. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  85. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  86. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  87. package/assets/templates/components.generated.json +1 -1
  88. package/assets/templates/pages/dashboard/page.tsx +1 -1
  89. package/authoring/doctypes/_schema.d.mts +52 -5
  90. package/authoring/doctypes/_schema.mjs +62 -7
  91. package/authoring/doctypes/base/type.ts +10 -0
  92. package/authoring/doctypes/component/component.doc.mjs +1 -1
  93. package/authoring/doctypes/function/function.doc.mjs +6 -0
  94. package/authoring/doctypes/function/type.ts +3 -0
  95. package/authoring/doctypes/legacy.mjs +5 -1
  96. package/authoring/index.d.ts +1 -0
  97. package/authoring/shadcn/source-variants.d.mts +1 -1
  98. package/authoring/shadcn/source-variants.mjs +32 -10
  99. package/clients/cli/build-id.generated.json +1 -1
  100. package/clients/cli/commands/doctor.doc.mjs +2 -2
  101. package/clients/cli/commands/experimental/theme.mjs +237 -45
  102. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  103. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  105. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  106. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  108. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  109. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  110. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  111. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  112. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  113. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  114. package/clients/cli/commands/theme.mjs +190 -46
  115. package/clients/cli/formatters/index.mjs +7 -4
  116. package/clients/cli/lib/cli-error.mjs +9 -3
  117. package/clients/cli/lib/component-format.mjs +27 -9
  118. package/clients/cli/lib/json-shim.mjs +72 -2
  119. package/clients/cli/manifest.generated.json +1 -1
  120. package/clients/cli/run.mjs +49 -0
  121. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  122. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  123. package/foundation/agent-docs/agent-docs.mjs +3 -2
  124. package/foundation/config/config-writer.mjs +2 -2
  125. package/foundation/config/project.mjs +60 -14
  126. package/foundation/discovery/component-discovery.mjs +5 -17
  127. package/foundation/discovery/icon-set-writer.mjs +1 -1
  128. package/foundation/discovery/module-exports.mjs +1 -15
  129. package/foundation/discovery/template-adapter.mjs +44 -19
  130. package/foundation/discovery/template-source-tree.mjs +3 -16
  131. package/foundation/discovery/theme-discovery.d.mts +5 -1
  132. package/foundation/discovery/theme-discovery.mjs +30 -35
  133. package/foundation/fs/exact-codec.d.mts +35 -0
  134. package/foundation/fs/exact-codec.mjs +148 -0
  135. package/foundation/fs/gather-cache.d.mts +15 -5
  136. package/foundation/fs/gather-cache.mjs +123 -30
  137. package/foundation/fs/paths.d.mts +39 -0
  138. package/foundation/fs/paths.mjs +44 -11
  139. package/foundation/fs/read-record.mjs +11 -1
  140. package/foundation/integrations/contribution-fixes.mjs +1 -16
  141. package/foundation/integrations/may-have-integrations.mjs +3 -2
  142. package/foundation/integrations/public-imports.mjs +1 -1
  143. package/foundation/render/embedded-imports.mjs +1 -1
  144. package/foundation/render/host-exit.d.mts +8 -0
  145. package/foundation/render/host-exit.mjs +11 -0
  146. package/foundation/render/page-host.mjs +56 -10
  147. package/foundation/render/page-worker.mjs +14 -0
  148. package/foundation/render/render-page.mjs +37 -2
  149. package/foundation/response/error-codes.d.mts +2 -1
  150. package/foundation/response/error-codes.d.ts +1 -0
  151. package/foundation/response/error-codes.doc.mjs +5 -0
  152. package/foundation/response/error-codes.mjs +3 -0
  153. package/foundation/response/json.d.mts +15 -0
  154. package/foundation/response/json.mjs +52 -1
  155. package/foundation/response/response-types.doc.mjs +1 -1
  156. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  157. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  158. package/foundation/xle/browser.d.mts +2 -2
  159. 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
@@ -45,6 +45,11 @@ export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mj
45
45
  import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
46
46
  import {cssImports} from '../../foundation/render/embedded-imports.mjs';
47
47
  import * as path from 'node:path';
48
+ import {
49
+ persistedGather,
50
+ recordedRun,
51
+ } from '../../foundation/fs/gather-cache.mjs';
52
+ import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
48
53
  import {
49
54
  Project,
50
55
  availableComputerIntegrations,
@@ -83,6 +88,44 @@ export {
83
88
  authoringAuditData,
84
89
  } from './_authoring-audit.mjs';
85
90
 
91
+ /** A doctor check record, kept as it is. */
92
+ const CHECK_CODEC = {
93
+ encode: (/** @type {any} */ check) => check,
94
+ decode: (/** @type {any} */ check) => check,
95
+ /** A check record: its id, label, status and message. */
96
+ valid: (/** @type {any} */ check) =>
97
+ check != null &&
98
+ typeof check === 'object' &&
99
+ typeof check.id === 'string' &&
100
+ typeof check.label === 'string' &&
101
+ typeof check.status === 'string' &&
102
+ typeof check.message === 'string',
103
+ };
104
+
105
+ /**
106
+ * A doctor check that reads only files, kept between runs through the kept
107
+ * gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
108
+ * folder, module and environment variable it read unchanged reads the check
109
+ * back. Only the docs checks go through here; a check that depends on the
110
+ * time, the network or anything else the stamps do not see never does.
111
+ * @template T
112
+ * @param {{name: string, cwd: string, coreDir: string | null}} where - The
113
+ * check, the project folder, and the Core folder the project loads.
114
+ * @param {() => Promise<T>} check
115
+ * @returns {Promise<T>}
116
+ */
117
+ export function keptFileCheck({name, cwd, coreDir}, check) {
118
+ // Only a recorded run (a plain `doctor` from the bin) reads or keeps one: a
119
+ // hosted run names its commands its own way, so it always checks.
120
+ if (!recordedRun()) return check();
121
+ return persistedGather(
122
+ // With the command name the checks print commands with.
123
+ ['doctor-check', name, cwd, coreDir, getCliInvocation(cwd)],
124
+ check,
125
+ CHECK_CODEC,
126
+ );
127
+ }
128
+
86
129
  /**
87
130
  * Package written to the generated app record for one discovered theme.
88
131
  * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
@@ -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']);
@@ -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,
@@ -2192,7 +2193,7 @@ export function checkGatherCache() {
2192
2193
  id: 'gather-cache',
2193
2194
  label: 'Kept catalog cache',
2194
2195
  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.`,
2196
+ message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's 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
2197
  };
2197
2198
  }
2198
2199
 
@@ -2465,9 +2466,22 @@ export async function runChecks(options = {}) {
2465
2466
  );
2466
2467
  }
2467
2468
  checks.push(await checkAuthoringDocs(ctx));
2468
- checks.push(await checkCliDocs(ctx));
2469
- checks.push(await checkDocsTree(ctx));
2470
- checks.push(await checkDocsProgressiveDisclosure(ctx));
2469
+ // The checks that read only files, each kept while every file it read is
2470
+ // unchanged; the Core the project loads is part of what they read.
2471
+ const where = {cwd, coreDir: coreDir ?? null};
2472
+ checks.push(
2473
+ await keptFileCheck({name: 'cli-docs', ...where}, () => checkCliDocs(ctx)),
2474
+ );
2475
+ checks.push(
2476
+ await keptFileCheck({name: 'docs-tree', ...where}, () =>
2477
+ checkDocsTree(ctx),
2478
+ ),
2479
+ );
2480
+ checks.push(
2481
+ await keptFileCheck({name: 'docs-progressive', ...where}, () =>
2482
+ checkDocsProgressiveDisclosure(ctx),
2483
+ ),
2484
+ );
2471
2485
 
2472
2486
  const summary = {pass: 0, warn: 0, fail: 0, info: 0};
2473
2487
  for (const c of checks) summary[c.status] += 1;
@@ -8,7 +8,7 @@
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,
@@ -13,7 +13,7 @@
13
13
 
14
14
  import * as fs from 'node:fs';
15
15
  import * as path from 'node:path';
16
- import jscodeshift from 'jscodeshift';
16
+ import {jscodeshift as loadJscodeshift} from '../../foundation/runtime/lazy-dependencies.mjs';
17
17
  import {AstryxError} from '../error.mjs';
18
18
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
19
19
  import {
@@ -928,8 +928,8 @@ async function addAgentDoc(line, options) {
928
928
  const source = manifestExists
929
929
  ? fs.readFileSync(manifestFile, 'utf-8')
930
930
  : 'export default {};\n';
931
- const j = jscodeshift.withParser('tsx');
932
- /** @type {ReturnType<ReturnType<typeof jscodeshift.withParser>>} */
931
+ const j = loadJscodeshift().withParser('tsx');
932
+ /** @type {ReturnType<ReturnType<ReturnType<typeof loadJscodeshift>['withParser']>>} */
933
933
  let ast;
934
934
  try {
935
935
  ast = j(source);
@@ -49,7 +49,7 @@ import {
49
49
  } from '../../foundation/discovery/docs-discovery.mjs';
50
50
  import {discoverIntegrationThemes} from '../../foundation/discovery/theme-discovery.mjs';
51
51
  import {inspectPackageExport} from '../../foundation/discovery/package-exports.mjs';
52
- import {parse as parseModule} from '@babel/parser';
52
+ import {babelParse as parseModule} from '../../foundation/runtime/lazy-dependencies.mjs';
53
53
  import {moduleExportsName} from '../../foundation/discovery/module-exports.mjs';
54
54
  import {
55
55
  ThemeImportError,
@@ -57,7 +57,7 @@ import {
57
57
  } from '../../foundation/discovery/theme-imports.mjs';
58
58
  import {
59
59
  normalizeThemeBuildForCompare,
60
- themeBuild,
60
+ themeBuildWithHandOff,
61
61
  } from '../theme/build/build.mjs';
62
62
  import {
63
63
  discoverIntegrationComponents,
@@ -641,8 +641,12 @@ async function validateIncompleteThemeExports(
641
641
  if (outputs.some(output => output.kind !== 'font stylesheet')) {
642
642
  // The scratch directory is the write root; the package stays the cwd,
643
643
  // so the build selects the package's Core and its paths as before.
644
- const scratchBuild = {out: expectedCss, __writeRoot: expectedDir};
645
- const receipt = await themeBuild(source, scratchBuild, {cwd: packageDir});
644
+ const receipt = await themeBuildWithHandOff(
645
+ source,
646
+ {out: expectedCss},
647
+ {cwd: packageDir},
648
+ {writeRoot: expectedDir},
649
+ );
646
650
  if (receipt == null || receipt.type !== 'theme.build') {
647
651
  throw new Error('the theme build produced no complete receipt');
648
652
  }
@@ -1079,10 +1083,12 @@ async function validatePackedThemeExports(
1079
1083
  try {
1080
1084
  // The scratch directory is the write root; the package stays the cwd,
1081
1085
  // so the build selects the package's Core and its paths as before.
1082
- const scratchBuild = {out: expectedCss, __writeRoot: expectedDir};
1083
- const receipt = await themeBuild(source, scratchBuild, {
1084
- cwd: localIntegration.__packageDir,
1085
- });
1086
+ const receipt = await themeBuildWithHandOff(
1087
+ source,
1088
+ {out: expectedCss},
1089
+ {cwd: localIntegration.__packageDir},
1090
+ {writeRoot: expectedDir},
1091
+ );
1086
1092
  if (receipt == null || receipt.type !== 'theme.build') {
1087
1093
  issues.push(
1088
1094
  error(
@@ -293,7 +293,7 @@ async function findUnreachableContributionIssues(
293
293
  issues.push(
294
294
  warning(
295
295
  'unreachable_contribution',
296
- `Found contribution metadata "${path.relative(packageDir, full)}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
296
+ `Found contribution metadata "${path.relative(packageDir, full).split(path.sep).join('/')}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
297
297
  ),
298
298
  );
299
299
  }
@@ -6,9 +6,9 @@
6
6
  * domain, _gather-*.mjs) and loads the tree's static data before it runs.
7
7
  */
8
8
 
9
- import {readFileSync, realpathSync} from 'node:fs';
9
+ import {readFileSync} from 'node:fs';
10
10
  import * as path from 'node:path';
11
- import {requireCoreDir} from '../../foundation/fs/paths.mjs';
11
+ import {realDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
12
12
  import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
13
13
  import {persistedGather} from '../../foundation/fs/gather-cache.mjs';
14
14
  import {
@@ -130,19 +130,6 @@ async function gatherDomains(options) {
130
130
  };
131
131
  }
132
132
 
133
- /**
134
- * The folder's real path, so a link and its target share a kept gather.
135
- * @param {string} dir
136
- * @returns {string}
137
- */
138
- function realFolder(dir) {
139
- try {
140
- return realpathSync(dir);
141
- } catch {
142
- return dir;
143
- }
144
- }
145
-
146
133
  /**
147
134
  * A gathered catalog as plain JSON and back, for a gather kept between runs
148
135
  * (persistedGather). A template's derived component names are read once and
@@ -150,6 +137,18 @@ function realFolder(dir) {
150
137
  * objects it shares.
151
138
  */
152
139
  const GATHER_CODEC = {
140
+ /**
141
+ * The shape a read-back gather needs: its candidates and components.
142
+ * @param {any} gathered
143
+ */
144
+ valid: gathered =>
145
+ gathered != null &&
146
+ Array.isArray(gathered.all) &&
147
+ Array.isArray(gathered.components) &&
148
+ gathered.all.every(
149
+ (/** @type {any} */ c) => c != null && typeof c === 'object',
150
+ ) &&
151
+ gathered.components.every((/** @type {any} */ c) => c != null),
153
152
  /**
154
153
  * @param {any} gathered
155
154
  * @returns {any}
@@ -264,7 +263,7 @@ export function gatherCandidatesReused(options) {
264
263
  gather = reusedWhileUnchanged(
265
264
  () =>
266
265
  persistedGather(
267
- [realFolder(cwd), type ?? null],
266
+ [realDir(cwd), type ?? null],
268
267
  () => gatherCandidates({cwd, type}),
269
268
  GATHER_CODEC,
270
269
  // A gather that skipped Core (a failed install still in its
@@ -17,11 +17,12 @@ export function entryTable(all: any[], cards: Record<string, {
17
17
  * A table's plain-JSON form and back. Candidates are kept as their place in
18
18
  * `all`, maps as their entries in order, so the table reads back the same.
19
19
  * @param {any[]} all
20
- * @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
20
+ * @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable, valid: (table: any) => boolean}}
21
21
  */
22
22
  export function tableCodec(all: any[]): {
23
23
  encode: (table: EntryTable) => any;
24
24
  decode: (stored: any) => EntryTable;
25
+ valid: (table: any) => boolean;
25
26
  };
26
27
  /**
27
28
  * @param {any[]} all
@@ -97,10 +97,37 @@ let last = null;
97
97
  * A table's plain-JSON form and back. Candidates are kept as their place in
98
98
  * `all`, maps as their entries in order, so the table reads back the same.
99
99
  * @param {any[]} all
100
- * @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable}}
100
+ * @returns {{encode: (table: EntryTable) => any, decode: (stored: any) => EntryTable, valid: (table: any) => boolean}}
101
101
  */
102
102
  export function tableCodec(all) {
103
103
  return {
104
+ /**
105
+ * The shape a read-back table needs: a candidate for every id, and its
106
+ * fields.
107
+ * @param {any} table
108
+ */
109
+ valid: table =>
110
+ table != null &&
111
+ Array.isArray(table.ids) &&
112
+ Array.isArray(table.candidate) &&
113
+ table.candidate.length === table.ids.length &&
114
+ table.candidate.every((/** @type {any} */ c) => c != null) &&
115
+ Array.isArray(table.domain) &&
116
+ table.domain.length === table.ids.length &&
117
+ Array.isArray(table.name) &&
118
+ table.name.length === table.ids.length &&
119
+ table.fields != null &&
120
+ ['name', 'desc', 'card'].every(f => {
121
+ const field = table.fields[f];
122
+ return (
123
+ field != null &&
124
+ field.post instanceof Map &&
125
+ field.idf instanceof Map &&
126
+ Array.isArray(field.len) &&
127
+ field.len.length === table.ids.length &&
128
+ typeof field.avg === 'number'
129
+ );
130
+ }),
104
131
  encode(table) {
105
132
  const place = new Map(all.map((c, k) => [c, k]));
106
133
  const t = /** @type {any} */ (table);
@@ -15,7 +15,7 @@ import * as path from 'node:path';
15
15
  import {isBuiltin} from 'node:module';
16
16
  import {packageOf} from '../../foundation/render/served-packages.mjs';
17
17
  import {resolveInstalledPackageDir} from '../../foundation/integrations/installed-package.mjs';
18
- import {parse} from '@babel/parser';
18
+ import {babelParse as parse} from '../../foundation/runtime/lazy-dependencies.mjs';
19
19
  import {
20
20
  inspectPackageExport,
21
21
  sourceExportTarget,
@@ -78,8 +78,10 @@ export function listUnmigratedThemeCopies(cwd: string): import("../../foundation
78
78
  * @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
79
79
  * `takenSlugs`: the slugs of the themes the project can use, which a fork's
80
80
  * new folder name may not take
81
- * @returns {{outputDir: string, files: string[]}} the project-relative output
82
- * directory and the files written, named as the fork names them
81
+ * @returns {{outputDir: string, files: string[], editorFolder: string | null}}
82
+ * the output directory relative to the working folder, the files written,
83
+ * named as the fork names them, and the folder the theme editor made that
84
+ * holds the fork, relative to the working folder, or null
83
85
  */
84
86
  export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, { cwd, targetPath: typedPath, overwrite, takenSlugs }: {
85
87
  cwd: string;
@@ -89,6 +91,7 @@ export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-
89
91
  }): {
90
92
  outputDir: string;
91
93
  files: string[];
94
+ editorFolder: string | null;
92
95
  };
93
96
  /**
94
97
  * The packages the fork imports that the app does not declare. A fork that