@astryxdesign/cli 0.7.14 → 0.7.15-canary.g2025dc7
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.
- package/README.md +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +1 -0
- package/api/doctor/_adapter.mjs +8 -0
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.mjs +20 -9
- package/api/theme/build/build.d.mts +15 -1
- package/api/theme/build/build.mjs +132 -32
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +14 -1
- package/api/theme/themeBuild.doc.mjs +6 -3
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme.mjs +118 -22
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +6 -0
- package/foundation/discovery/template-needs.mjs +20 -1
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +12 -11
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +724 -0
- package/foundation/fs/module-loader.mjs +7 -1
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +100 -7
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +476 -40
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +8 -6
package/api/build/_adapter.d.mts
CHANGED
|
@@ -74,6 +74,10 @@ export function loadWeights(): import("./kit/weights.mjs").WeightsFile | null;
|
|
|
74
74
|
* @returns {import('../../foundation/route/route.mjs').ClassifierWeights}
|
|
75
75
|
*/
|
|
76
76
|
export function loadTreeWeights(): import("../../foundation/route/route.mjs").ClassifierWeights;
|
|
77
|
+
export function keptBlockCatalog<T>(key: unknown[], compute: () => T, codec: {
|
|
78
|
+
encode: (value: T) => any;
|
|
79
|
+
decode: (stored: any) => T;
|
|
80
|
+
}): T;
|
|
77
81
|
/**
|
|
78
82
|
* The block picker's weights (blocks/blocks.weights.json), read once; null
|
|
79
83
|
* when the file is absent, unreadable, or not the shape the picker reads, in
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The build subject's environment access: the page templates a project
|
|
5
|
-
* can scaffold, the components it can use,
|
|
5
|
+
* can scaffold, the components it can use, the checked-in matcher weights, and
|
|
6
|
+
* the block picker's per-block vectors kept between runs.
|
|
6
7
|
*
|
|
7
8
|
* @input Template and component discovery for `cwd` — the CLI's own templates
|
|
8
9
|
* and Core's components, plus any that the project's configured integrations
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
* keywords, command}`, where `command` is the `astryx template` command that
|
|
12
13
|
* selects exactly that template; blocks as search names them; components as
|
|
13
14
|
* `{name, keywords}`; the kit's matcher weights, the root's classifier
|
|
14
|
-
* weights, and the block picker's weights
|
|
15
|
+
* weights, and the block picker's weights; `keptBlockCatalog`, which keeps
|
|
16
|
+
* the picker's per-block vectors beside the kept search catalog.
|
|
15
17
|
* @position Beside build.mjs (api/build/). The kit leaf reads templates and
|
|
16
18
|
* components only through here, because a subject's `_adapter.mjs` is its
|
|
17
19
|
* only environment access. This adds no discovery of its own: templates come
|
|
@@ -19,10 +21,12 @@
|
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
23
|
import fs from 'node:fs';
|
|
24
|
+
import {fileURLToPath} from 'node:url';
|
|
22
25
|
|
|
23
26
|
import {discoverTemplates} from '../template/template.mjs';
|
|
24
27
|
import {componentKeywords} from '../search/search.mjs';
|
|
25
28
|
import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
29
|
+
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
26
30
|
import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
|
|
27
31
|
|
|
28
32
|
/**
|
|
@@ -179,6 +183,28 @@ export function loadTreeWeights() {
|
|
|
179
183
|
/** @type {import('./blocks/blocks.mjs').BlockPickerWeights | null | undefined} */
|
|
180
184
|
let blockPicker;
|
|
181
185
|
|
|
186
|
+
/**
|
|
187
|
+
* The files the block picker's per-block vectors are worked out from, besides
|
|
188
|
+
* the catalog text: its module, its weights, and search's word rules (the
|
|
189
|
+
* stopwords).
|
|
190
|
+
*/
|
|
191
|
+
const BLOCK_CATALOG_INPUTS = [
|
|
192
|
+
fileURLToPath(new URL('./blocks/blocks.mjs', import.meta.url)),
|
|
193
|
+
fileURLToPath(new URL('./blocks/blocks.weights.json', import.meta.url)),
|
|
194
|
+
fileURLToPath(new URL('../search/_query.mjs', import.meta.url)),
|
|
195
|
+
];
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Keep the block picker's per-block vectors beside the kept search catalog
|
|
199
|
+
* (foundation/fs/gather-cache.mjs persistedDerived), keyed also by the files
|
|
200
|
+
* that work them out, so a later run with the same catalog text and code
|
|
201
|
+
* reads them back.
|
|
202
|
+
* @type {import('./blocks/blocks.mjs').KeepCatalog}
|
|
203
|
+
*/
|
|
204
|
+
export function keptBlockCatalog(key, compute, codec) {
|
|
205
|
+
return persistedDerived(key, compute, codec, BLOCK_CATALOG_INPUTS);
|
|
206
|
+
}
|
|
207
|
+
|
|
182
208
|
/**
|
|
183
209
|
* The block picker's weights (blocks/blocks.weights.json), read once; null
|
|
184
210
|
* when the file is absent, unreadable, or not the shape the picker reads, in
|
|
@@ -68,6 +68,7 @@ export function matchOf(request: {
|
|
|
68
68
|
* @param {string} request
|
|
69
69
|
* @param {{kitBlocks: string[], searched: BlockScore[], foreign: string[], catalog: CatalogBlock[], components: CatalogComponent[]}} signals
|
|
70
70
|
* @param {BlockPickerWeights} weights
|
|
71
|
+
* @param {KeepCatalog} [keep] keeps the per-block vectors between runs
|
|
71
72
|
* @returns {{names: string[], entries: Map<string, SearchResultEntry>}} as
|
|
72
73
|
* many names as build's own list, best first; an entry for each listed
|
|
73
74
|
* block search did not return
|
|
@@ -78,10 +79,18 @@ export function pickBlocks(request: string, signals: {
|
|
|
78
79
|
foreign: string[];
|
|
79
80
|
catalog: CatalogBlock[];
|
|
80
81
|
components: CatalogComponent[];
|
|
81
|
-
}, weights: BlockPickerWeights): {
|
|
82
|
+
}, weights: BlockPickerWeights, keep?: KeepCatalog): {
|
|
82
83
|
names: string[];
|
|
83
84
|
entries: Map<string, SearchResultEntry>;
|
|
84
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Keeps a value derived from the catalog between runs (build's adapter does
|
|
88
|
+
* it beside the kept search catalog), or works it out.
|
|
89
|
+
*/
|
|
90
|
+
export type KeepCatalog = <T>(key: unknown[], compute: () => T, codec: {
|
|
91
|
+
encode: (value: T) => any;
|
|
92
|
+
decode: (stored: any) => T;
|
|
93
|
+
}) => T;
|
|
85
94
|
export type BlockPickerWeights = {
|
|
86
95
|
/**
|
|
87
96
|
* stemmed words and `a_b` word pairs
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* vocabulary of stemmed words and word pairs with their idf (x1024), two
|
|
12
12
|
* signed byte matrices that map request words and doc words into one space, the
|
|
13
13
|
* lexical weight, the blocks the matrices were fitted with, and the ranking
|
|
14
|
-
* coefficients.
|
|
14
|
+
* coefficients. Optionally, a keeper from build's adapter (`keep`) that
|
|
15
|
+
* reads back the per-block vectors kept for the same catalog.
|
|
15
16
|
* @output `pickBlocks(...)`: block names, best first, as many as build's own
|
|
16
17
|
* list, and an entry (real score and reason) for each listed block search
|
|
17
18
|
* did not return.
|
|
@@ -38,8 +39,15 @@
|
|
|
38
39
|
* slot build gave them; the best of the others fill the remaining slots.
|
|
39
40
|
*/
|
|
40
41
|
|
|
42
|
+
import {createHash} from 'node:crypto';
|
|
41
43
|
import {STOPWORDS} from '../../search/_query.mjs';
|
|
42
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Keeps a value derived from the catalog between runs (build's adapter does
|
|
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
|
|
49
|
+
*/
|
|
50
|
+
|
|
43
51
|
/**
|
|
44
52
|
* @typedef {object} BlockPickerWeights
|
|
45
53
|
* @property {string[]} vocab stemmed words and `a_b` word pairs
|
|
@@ -325,14 +333,39 @@ const catalogs = new WeakMap();
|
|
|
325
333
|
* @param {CatalogBlock[]} catalog
|
|
326
334
|
* @param {CatalogComponent[]} components
|
|
327
335
|
* @param {BlockPickerWeights} weights
|
|
336
|
+
* @param {KeepCatalog} [keep] keeps the value between runs (build's adapter)
|
|
328
337
|
*/
|
|
329
|
-
function readCatalog(catalog, components, weights) {
|
|
338
|
+
function readCatalog(catalog, components, weights, keep) {
|
|
330
339
|
const key = JSON.stringify([
|
|
331
340
|
catalog.map(b => [b.name, b.displayName, b.description]),
|
|
332
341
|
components.map(c => [c.name, c.keywords]),
|
|
333
342
|
]);
|
|
334
343
|
const cached = catalogs.get(weights);
|
|
335
344
|
if (cached && cached.key === key) return cached;
|
|
345
|
+
const compute = () => computeCatalog(key, catalog, components, weights);
|
|
346
|
+
// A function of the catalog text and the shipped weights: where build's
|
|
347
|
+
// adapter keeps it between runs, a later run with the same text reads it
|
|
348
|
+
// back.
|
|
349
|
+
const read = keep
|
|
350
|
+
? keep(
|
|
351
|
+
['block-catalog', createHash('sha256').update(key).digest('hex')],
|
|
352
|
+
compute,
|
|
353
|
+
CATALOG_CODEC,
|
|
354
|
+
)
|
|
355
|
+
: compute();
|
|
356
|
+
catalogs.set(weights, read);
|
|
357
|
+
return read;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* readCatalog's value, worked out.
|
|
362
|
+
* @param {string} key
|
|
363
|
+
* @param {CatalogBlock[]} catalog
|
|
364
|
+
* @param {CatalogComponent[]} components
|
|
365
|
+
* @param {BlockPickerWeights} weights
|
|
366
|
+
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}}
|
|
367
|
+
*/
|
|
368
|
+
function computeCatalog(key, catalog, components, weights) {
|
|
336
369
|
const names = components.map(c => c.name).sort((a, b) => b.length - a.length);
|
|
337
370
|
const keywords = new Map(components.map(c => [c.name, c.keywords ?? []]));
|
|
338
371
|
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>} */
|
|
@@ -369,11 +402,54 @@ function readCatalog(catalog, components, weights) {
|
|
|
369
402
|
list.push([phrase(k), 1 / (shared.get(k) ?? 1)]);
|
|
370
403
|
phrases.set(c, list);
|
|
371
404
|
}
|
|
372
|
-
|
|
373
|
-
catalogs.set(weights, read);
|
|
374
|
-
return read;
|
|
405
|
+
return {key, blocks, phrases};
|
|
375
406
|
}
|
|
376
407
|
|
|
408
|
+
/**
|
|
409
|
+
* readCatalog's value as plain data and back: maps as entry lists, each
|
|
410
|
+
* projection as its numbers.
|
|
411
|
+
*/
|
|
412
|
+
const CATALOG_CODEC = {
|
|
413
|
+
/** @param {ReturnType<typeof computeCatalog>} read */
|
|
414
|
+
encode: read => ({
|
|
415
|
+
key: read.key,
|
|
416
|
+
blocks: [...read.blocks].map(([name, b]) => [
|
|
417
|
+
name,
|
|
418
|
+
b.component,
|
|
419
|
+
[...b.vector],
|
|
420
|
+
[...b.projected],
|
|
421
|
+
]),
|
|
422
|
+
phrases: [...read.phrases],
|
|
423
|
+
}),
|
|
424
|
+
/**
|
|
425
|
+
* @param {any} stored
|
|
426
|
+
* @returns {ReturnType<typeof computeCatalog>}
|
|
427
|
+
*/
|
|
428
|
+
decode: stored => ({
|
|
429
|
+
key: stored.key,
|
|
430
|
+
blocks: new Map(
|
|
431
|
+
stored.blocks.map(
|
|
432
|
+
(
|
|
433
|
+
/** @type {[string, string, [number, number][], number[]]} */ [
|
|
434
|
+
name,
|
|
435
|
+
component,
|
|
436
|
+
vector,
|
|
437
|
+
projected,
|
|
438
|
+
],
|
|
439
|
+
) => [
|
|
440
|
+
name,
|
|
441
|
+
{
|
|
442
|
+
component,
|
|
443
|
+
vector: new Map(vector),
|
|
444
|
+
projected: Float64Array.from(projected),
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
),
|
|
448
|
+
),
|
|
449
|
+
phrases: new Map(stored.phrases),
|
|
450
|
+
}),
|
|
451
|
+
};
|
|
452
|
+
|
|
377
453
|
/**
|
|
378
454
|
* How strongly the request names each component: its best phrase, longer
|
|
379
455
|
* phrases and earlier ones stronger, and half as strong once the request has
|
|
@@ -435,16 +511,17 @@ function writesName(words, block) {
|
|
|
435
511
|
* @param {string} request
|
|
436
512
|
* @param {{kitBlocks: string[], searched: BlockScore[], foreign: string[], catalog: CatalogBlock[], components: CatalogComponent[]}} signals
|
|
437
513
|
* @param {BlockPickerWeights} weights
|
|
514
|
+
* @param {KeepCatalog} [keep] keeps the per-block vectors between runs
|
|
438
515
|
* @returns {{names: string[], entries: Map<string, SearchResultEntry>}} as
|
|
439
516
|
* many names as build's own list, best first; an entry for each listed
|
|
440
517
|
* block search did not return
|
|
441
518
|
*/
|
|
442
|
-
export function pickBlocks(request, signals, weights) {
|
|
519
|
+
export function pickBlocks(request, signals, weights, keep) {
|
|
443
520
|
const own = signals.kitBlocks;
|
|
444
521
|
/** @type {Map<string, SearchResultEntry>} */
|
|
445
522
|
const entries = new Map();
|
|
446
523
|
if (own.length === 0) return {names: [], entries};
|
|
447
|
-
const cat = readCatalog(signals.catalog, signals.components, weights);
|
|
524
|
+
const cat = readCatalog(signals.catalog, signals.components, weights, keep);
|
|
448
525
|
const side = requestSideOf(request, weights);
|
|
449
526
|
/** @type {Map<string, {match: number, overlap: number}>} */
|
|
450
527
|
const scored = new Map();
|
package/api/build/build.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import {buildHelp} from './help/help.mjs';
|
|
|
20
20
|
import {buildKit} from './kit/kit.mjs';
|
|
21
21
|
import {
|
|
22
22
|
loadBlockPicker,
|
|
23
|
+
keptBlockCatalog,
|
|
23
24
|
loadTreeWeights,
|
|
24
25
|
withListingCache,
|
|
25
26
|
} from './_adapter.mjs';
|
|
@@ -59,7 +60,11 @@ export async function build(query, options = {}) {
|
|
|
59
60
|
await runTree(
|
|
60
61
|
BUILD_TREE,
|
|
61
62
|
{query, options},
|
|
62
|
-
{
|
|
63
|
+
{
|
|
64
|
+
weights: loadTreeWeights(),
|
|
65
|
+
blocks: loadBlockPicker(),
|
|
66
|
+
keepBlocks: keptBlockCatalog,
|
|
67
|
+
},
|
|
63
68
|
)
|
|
64
69
|
),
|
|
65
70
|
);
|
package/api/build/tree.d.mts
CHANGED
|
@@ -15,6 +15,10 @@ export type BuildContext = {
|
|
|
15
15
|
* the block picker's weights; null: build names its own blocks
|
|
16
16
|
*/
|
|
17
17
|
blocks: import("./blocks/blocks.mjs").BlockPickerWeights | null;
|
|
18
|
+
/**
|
|
19
|
+
* keeps the picker's per-block vectors between runs
|
|
20
|
+
*/
|
|
21
|
+
keepBlocks?: import("./blocks/blocks.mjs").KeepCatalog | undefined;
|
|
18
22
|
};
|
|
19
23
|
export type BuildAnswer = import("./build.type.mjs").BuildKitResponse;
|
|
20
24
|
import { kitSignals } from './kit/signals.mjs';
|
package/api/build/tree.mjs
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* (kit/signals.mjs), the block picker's blocks (blocks/blocks.mjs), and the
|
|
8
8
|
* kit around them (kit/answer.mjs).
|
|
9
9
|
* @input {query, options} and the data build's adapter gathered: the root's
|
|
10
|
-
* weights and the block picker's
|
|
10
|
+
* weights and the block picker's, and the adapter's keeper for the picker's
|
|
11
|
+
* per-block vectors
|
|
11
12
|
* @output the build.kit response
|
|
12
13
|
* @position api/build; build.mjs runs it with the shared route helper
|
|
13
14
|
*/
|
|
@@ -22,6 +23,7 @@ import {pickBlocks} from './blocks/blocks.mjs';
|
|
|
22
23
|
* @typedef {object} BuildContext
|
|
23
24
|
* @property {import('../../foundation/route/route.mjs').ClassifierWeights} weights the root's weights
|
|
24
25
|
* @property {import('./blocks/blocks.mjs').BlockPickerWeights | null} blocks the block picker's weights; null: build names its own blocks
|
|
26
|
+
* @property {import('./blocks/blocks.mjs').KeepCatalog} [keepBlocks] keeps the picker's per-block vectors between runs
|
|
25
27
|
* @typedef {import('./build.type.mjs').BuildKitResponse} BuildAnswer
|
|
26
28
|
*/
|
|
27
29
|
|
|
@@ -35,7 +37,12 @@ const main = defineSearcher({
|
|
|
35
37
|
run: async (request, ctx) => {
|
|
36
38
|
const signals = await kitSignals(request.query, request.options);
|
|
37
39
|
if (!ctx.blocks) return kitAnswer(signals);
|
|
38
|
-
const picked = pickBlocks(
|
|
40
|
+
const picked = pickBlocks(
|
|
41
|
+
request.query,
|
|
42
|
+
signals,
|
|
43
|
+
ctx.blocks,
|
|
44
|
+
ctx.keepBlocks,
|
|
45
|
+
);
|
|
39
46
|
return kitAnswer(signals, picked.names, picked.entries);
|
|
40
47
|
},
|
|
41
48
|
});
|
|
@@ -264,3 +264,4 @@ import { stateLockHolder } from '../../foundation/release/global-state.mjs';
|
|
|
264
264
|
import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
265
265
|
export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
|
|
266
266
|
export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
|
|
267
|
+
export { AUTHORING_AUDIT, authoringAudit, authoringAuditData } from "./_authoring-audit.mjs";
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -70,6 +70,14 @@ export {themeBuild, validateThemePrivateInputs} from '../theme/build/build.mjs';
|
|
|
70
70
|
export {resolveRecordedTheme} from '../theme/theme.mjs';
|
|
71
71
|
export {collectUnloadedFonts} from '../theme/build/font-warning.mjs';
|
|
72
72
|
|
|
73
|
+
// What the authoring-docs check reads (./_authoring-audit.mjs), reached only
|
|
74
|
+
// through this adapter.
|
|
75
|
+
export {
|
|
76
|
+
AUTHORING_AUDIT,
|
|
77
|
+
authoringAudit,
|
|
78
|
+
authoringAuditData,
|
|
79
|
+
} from './_authoring-audit.mjs';
|
|
80
|
+
|
|
73
81
|
/**
|
|
74
82
|
* Package written to the generated app record for one discovered theme.
|
|
75
83
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the authoring-docs check reads: the self-docs audit, the field
|
|
6
|
+
* reference's section keys, and the authoring-surface audit. They read only
|
|
7
|
+
* the CLI's own files, so `prepack` stores them for the published package
|
|
8
|
+
* (scripts/generate-self-audit.mjs).
|
|
9
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
10
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
11
|
+
*/
|
|
12
|
+
export function authoringAuditData(options?: {
|
|
13
|
+
root?: string;
|
|
14
|
+
sources?: string[];
|
|
15
|
+
topicKeys?: Set<string> | null;
|
|
16
|
+
}): Promise<AuthoringAuditData>;
|
|
17
|
+
/**
|
|
18
|
+
* The authoring-docs check's data: as stored at publish while what it read is
|
|
19
|
+
* unchanged, else read now. Another tree, list or topic index (tests) is
|
|
20
|
+
* always read now.
|
|
21
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
22
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
23
|
+
*/
|
|
24
|
+
export function authoringAudit(options?: {
|
|
25
|
+
root?: string;
|
|
26
|
+
sources?: string[];
|
|
27
|
+
topicKeys?: Set<string> | null;
|
|
28
|
+
}): Promise<AuthoringAuditData>;
|
|
29
|
+
/** The name the authoring-docs check's data is stored under. */
|
|
30
|
+
export const AUTHORING_AUDIT: "authoring-docs";
|
|
31
|
+
export type AuthoringAuditData = {
|
|
32
|
+
audit: Awaited<ReturnType<typeof import("../../foundation/discovery/authoring-self-docs.mjs").auditAuthoringSelfDocs>>;
|
|
33
|
+
/**
|
|
34
|
+
* - The field
|
|
35
|
+
* reference's section keys, or why they could not be read.
|
|
36
|
+
*/
|
|
37
|
+
topic: {
|
|
38
|
+
keys: Set<string> | null;
|
|
39
|
+
error?: string;
|
|
40
|
+
};
|
|
41
|
+
surface: Awaited<ReturnType<typeof import("../../foundation/discovery/authoring-surface.mjs").auditAuthoringSurface>>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file What Doctor's authoring-docs check reads, kept apart from the public
|
|
5
|
+
* doctor API: api/doctor/doctor.mjs reports it, and
|
|
6
|
+
* scripts/generate-self-audit.mjs stores it at publish.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
|
|
10
|
+
import {storedSelfAudit} from '../../foundation/discovery/stored-self-audit.mjs';
|
|
11
|
+
import {indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
12
|
+
import {guideEntry, lowerTopic, projectTree} from '../docs/_adapter.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} AuthoringAuditData
|
|
16
|
+
* @property {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-self-docs.mjs').auditAuthoringSelfDocs>>} audit
|
|
17
|
+
* @property {{keys: Set<string> | null, error?: string}} topic - The field
|
|
18
|
+
* reference's section keys, or why they could not be read.
|
|
19
|
+
* @property {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-surface.mjs').auditAuthoringSurface>>} surface
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The section keys the field reference lists (`astryx docs
|
|
24
|
+
* authoring/field-reference --index`), read the way that command reads them.
|
|
25
|
+
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
26
|
+
*/
|
|
27
|
+
async function authoringTopicKeys() {
|
|
28
|
+
try {
|
|
29
|
+
const {AUTHORING_REFERENCE_ROUTE} =
|
|
30
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
31
|
+
const catalog = DocsCatalog.fromBuiltins();
|
|
32
|
+
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
33
|
+
if (!node?.ref?.topicFile) {
|
|
34
|
+
return {keys: null, error: 'the docs tree has no field reference'};
|
|
35
|
+
}
|
|
36
|
+
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
37
|
+
return {keys: new Set(index.sections.map(section => section.id))};
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
keys: null,
|
|
41
|
+
error: err instanceof Error ? err.message : String(err),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* What the authoring-docs check reads: the self-docs audit, the field
|
|
48
|
+
* reference's section keys, and the authoring-surface audit. They read only
|
|
49
|
+
* the CLI's own files, so `prepack` stores them for the published package
|
|
50
|
+
* (scripts/generate-self-audit.mjs).
|
|
51
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
52
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
53
|
+
*/
|
|
54
|
+
export async function authoringAuditData(options = {}) {
|
|
55
|
+
const {auditAuthoringSelfDocs} =
|
|
56
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
57
|
+
const {auditAuthoringSurface} =
|
|
58
|
+
await import('../../foundation/discovery/authoring-surface.mjs');
|
|
59
|
+
const {root, sources} = options;
|
|
60
|
+
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
61
|
+
const topic =
|
|
62
|
+
options.topicKeys === undefined
|
|
63
|
+
? await authoringTopicKeys()
|
|
64
|
+
: {keys: options.topicKeys};
|
|
65
|
+
const surface = await auditAuthoringSurface({
|
|
66
|
+
root,
|
|
67
|
+
sources,
|
|
68
|
+
topicKeys: topic.keys,
|
|
69
|
+
});
|
|
70
|
+
return {audit, topic, surface};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The name the authoring-docs check's data is stored under. */
|
|
74
|
+
export const AUTHORING_AUDIT = 'authoring-docs';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The authoring-docs check's data as stored at publish, while the files it
|
|
78
|
+
* read are unchanged, else undefined.
|
|
79
|
+
* @returns {AuthoringAuditData | undefined}
|
|
80
|
+
*/
|
|
81
|
+
function storedAuthoringAudit() {
|
|
82
|
+
const value = /** @type {any} */ (storedSelfAudit(AUTHORING_AUDIT));
|
|
83
|
+
if (!value) return undefined;
|
|
84
|
+
const {keys, ...rest} = value.topic;
|
|
85
|
+
return {
|
|
86
|
+
...value,
|
|
87
|
+
topic: keys === null ? {keys: null, ...rest} : {keys: new Set(keys)},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The authoring-docs check's data: as stored at publish while what it read is
|
|
93
|
+
* unchanged, else read now. Another tree, list or topic index (tests) is
|
|
94
|
+
* always read now.
|
|
95
|
+
* @param {{root?: string, sources?: string[], topicKeys?: Set<string> | null}} [options]
|
|
96
|
+
* @returns {Promise<AuthoringAuditData>}
|
|
97
|
+
*/
|
|
98
|
+
export async function authoringAudit(options = {}) {
|
|
99
|
+
const fresh =
|
|
100
|
+
options.root !== undefined ||
|
|
101
|
+
options.sources !== undefined ||
|
|
102
|
+
options.topicKeys !== undefined;
|
|
103
|
+
return (
|
|
104
|
+
(fresh ? undefined : storedAuthoringAudit()) ?? authoringAuditData(options)
|
|
105
|
+
);
|
|
106
|
+
}
|
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -296,6 +296,13 @@ export function checkComputerIntegrationsAvailable({ installed, candidates, inst
|
|
|
296
296
|
install: ((name: string) => string) | null;
|
|
297
297
|
elsewhere?: boolean;
|
|
298
298
|
}): DoctorCheck;
|
|
299
|
+
/**
|
|
300
|
+
* Where `search` and `build` keep their gathered catalog between runs, and
|
|
301
|
+
* how much it holds; and, in a run under Yarn Plug'n'Play's loader, that the
|
|
302
|
+
* run keeps none (runsUnderPnp). Left out of a checkout, which keeps none.
|
|
303
|
+
* @returns {DoctorCheck | null}
|
|
304
|
+
*/
|
|
305
|
+
export function checkGatherCache(): DoctorCheck | null;
|
|
299
306
|
/**
|
|
300
307
|
* Run all diagnostic checks and return a structured report.
|
|
301
308
|
*
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
import * as fs from 'node:fs';
|
|
28
28
|
import * as path from 'node:path';
|
|
29
|
+
import {gatherCacheSummary} from '../../foundation/fs/gather-cache.mjs';
|
|
29
30
|
|
|
30
31
|
import {
|
|
31
32
|
MIN_NODE_VERSION,
|
|
@@ -73,12 +74,11 @@ import {
|
|
|
73
74
|
compileTopic,
|
|
74
75
|
docsLinkProblems,
|
|
75
76
|
guideEntry,
|
|
76
|
-
lowerTopic,
|
|
77
77
|
overlayLanguages,
|
|
78
78
|
projectTree,
|
|
79
79
|
} from '../docs/_adapter.mjs';
|
|
80
80
|
import {typedEdges} from '../docs/node/node.mjs';
|
|
81
|
-
import {detailView
|
|
81
|
+
import {detailView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
82
82
|
import {isExperimentalTreeNode} from '../../foundation/doc-compiler/tree.mjs';
|
|
83
83
|
import {
|
|
84
84
|
semverCompare,
|
|
@@ -116,6 +116,7 @@ import {
|
|
|
116
116
|
outsideProject,
|
|
117
117
|
releaseFacts,
|
|
118
118
|
builtIntegrationPackages,
|
|
119
|
+
authoringAudit,
|
|
119
120
|
} from './_adapter.mjs';
|
|
120
121
|
import {checkBuilt} from './built-checks.mjs';
|
|
121
122
|
|
|
@@ -1307,30 +1308,6 @@ function nameTypes(names) {
|
|
|
1307
1308
|
: `${names.slice(0, NAMED_TYPES).join(', ')} and ${names.length - NAMED_TYPES} more`;
|
|
1308
1309
|
}
|
|
1309
1310
|
|
|
1310
|
-
/**
|
|
1311
|
-
* The section keys the field reference lists (`astryx docs
|
|
1312
|
-
* authoring/field-reference --index`), read the way that command reads them.
|
|
1313
|
-
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
1314
|
-
*/
|
|
1315
|
-
async function authoringTopicKeys() {
|
|
1316
|
-
try {
|
|
1317
|
-
const {AUTHORING_REFERENCE_ROUTE} =
|
|
1318
|
-
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1319
|
-
const catalog = DocsCatalog.fromBuiltins();
|
|
1320
|
-
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
1321
|
-
if (!node?.ref?.topicFile) {
|
|
1322
|
-
return {keys: null, error: 'the docs tree has no field reference'};
|
|
1323
|
-
}
|
|
1324
|
-
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
1325
|
-
return {keys: new Set(index.sections.map(section => section.id))};
|
|
1326
|
-
} catch (err) {
|
|
1327
|
-
return {
|
|
1328
|
-
keys: null,
|
|
1329
|
-
error: err instanceof Error ? err.message : String(err),
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
1311
|
/**
|
|
1335
1312
|
* @param {Awaited<ReturnType<typeof import('../../foundation/discovery/authoring-surface.mjs').auditAuthoringSurface>>} surface
|
|
1336
1313
|
* @returns {string[]}
|
|
@@ -1386,12 +1363,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1386
1363
|
const id = 'authoring-docs';
|
|
1387
1364
|
const label = 'Authoring docs';
|
|
1388
1365
|
try {
|
|
1389
|
-
const {
|
|
1390
|
-
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1391
|
-
const {auditAuthoringSurface} =
|
|
1392
|
-
await import('../../foundation/discovery/authoring-surface.mjs');
|
|
1393
|
-
const {root, sources} = options;
|
|
1394
|
-
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
1366
|
+
const {audit, topic, surface: surfaceAudit} = await authoringAudit(options);
|
|
1395
1367
|
const problems = [
|
|
1396
1368
|
...audit.unreachable.map(
|
|
1397
1369
|
source =>
|
|
@@ -1405,19 +1377,13 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1405
1377
|
`authoring section "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
|
|
1406
1378
|
),
|
|
1407
1379
|
];
|
|
1408
|
-
const topic =
|
|
1409
|
-
options.topicKeys === undefined
|
|
1410
|
-
? await authoringTopicKeys()
|
|
1411
|
-
: {keys: options.topicKeys};
|
|
1412
1380
|
const surface = [
|
|
1413
1381
|
...('error' in topic
|
|
1414
1382
|
? [
|
|
1415
1383
|
`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: ${topic.error}`,
|
|
1416
1384
|
]
|
|
1417
1385
|
: []),
|
|
1418
|
-
...surfaceProblems(
|
|
1419
|
-
await auditAuthoringSurface({root, sources, topicKeys: topic.keys}),
|
|
1420
|
-
),
|
|
1386
|
+
...surfaceProblems(surfaceAudit),
|
|
1421
1387
|
];
|
|
1422
1388
|
if (problems.length + surface.length > 0) {
|
|
1423
1389
|
return {
|
|
@@ -2212,6 +2178,24 @@ async function runComputerChecks(cwd) {
|
|
|
2212
2178
|
return {checks, summary};
|
|
2213
2179
|
}
|
|
2214
2180
|
|
|
2181
|
+
/**
|
|
2182
|
+
* Where `search` and `build` keep their gathered catalog between runs, and
|
|
2183
|
+
* how much it holds; and, in a run under Yarn Plug'n'Play's loader, that the
|
|
2184
|
+
* run keeps none (runsUnderPnp). Left out of a checkout, which keeps none.
|
|
2185
|
+
* @returns {DoctorCheck | null}
|
|
2186
|
+
*/
|
|
2187
|
+
export function checkGatherCache() {
|
|
2188
|
+
const summary = gatherCacheSummary();
|
|
2189
|
+
if (summary == null) return null;
|
|
2190
|
+
const size = `${(summary.bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
2191
|
+
return {
|
|
2192
|
+
id: 'gather-cache',
|
|
2193
|
+
label: 'Search catalog cache',
|
|
2194
|
+
status: 'info',
|
|
2195
|
+
message: `search and build keep the catalogs they gather 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" : ''}; a catalog is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2215
2199
|
/**
|
|
2216
2200
|
* Ordered list of synchronous check functions. Append here to add a check.
|
|
2217
2201
|
* (checkConfig is async and is awaited separately by {@link runChecks}.)
|
|
@@ -2232,6 +2216,7 @@ export const SYNC_CHECKS = [
|
|
|
2232
2216
|
checkPeerDeps,
|
|
2233
2217
|
checkPackageManager,
|
|
2234
2218
|
checkCliCommand,
|
|
2219
|
+
checkGatherCache,
|
|
2235
2220
|
];
|
|
2236
2221
|
|
|
2237
2222
|
/**
|