@astryxdesign/cli 0.7.10 → 0.7.11-canary.9782dea
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/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +1 -1
- package/api/build/kit/signals.mjs +9 -3
- package/api/build/kit/start.d.mts +19 -0
- package/api/build/kit/start.mjs +49 -2
- package/api/build/kit/weights.d.mts +12 -0
- package/api/build/kit/weights.mjs +52 -16
- package/api/docs/_adapter.mjs +2 -1
- package/api/doctor/_adapter.d.mts +28 -1
- package/api/doctor/_adapter.mjs +39 -2
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +9 -2
- package/api/doctor/theme-checks.d.mts +44 -3
- package/api/doctor/theme-checks.mjs +273 -6
- package/api/hook/hook.mjs +13 -0
- package/api/integration/pack-check.d.mts +8 -6
- package/api/integration/pack-check.mjs +16 -6
- package/api/render/_adapter.mjs +47 -1
- package/api/render/render.doc.mjs +2 -1
- package/api/search/_gather-components.mjs +2 -1
- package/api/swizzle/copy/copy.mjs +5 -1
- package/api/theme/build/build.mjs +15 -4
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/getting-started.doc.mjs +20 -0
- package/assets/docs/tree/building-blocks.doc.mjs +1 -0
- package/assets/docs/tree/global-integrations.doc.mjs +1 -0
- package/assets/docs/tree/help.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -0
- package/assets/docs/tree/render-pages.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.doc.mjs +15 -0
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.tsx +134 -0
- package/authoring/doctypes/_schema.d.mts +1 -1
- package/clients/cli/commands/build.doc.mjs +3 -2
- package/clients/cli/commands/build.mjs +34 -5
- package/clients/cli/index.mjs +36 -7
- package/foundation/discovery/authoring-self-docs.mjs +8 -3
- package/foundation/discovery/cli-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.mjs +16 -0
- package/foundation/discovery/docs-discovery.mjs +6 -4
- package/foundation/discovery/icon-definition-discovery.mjs +3 -3
- package/foundation/discovery/module-exports.d.mts +91 -4
- package/foundation/discovery/module-exports.mjs +316 -42
- package/foundation/discovery/template-adapter.mjs +5 -7
- package/foundation/discovery/theme-discovery.mjs +8 -10
- package/foundation/doc-compiler/tree.mjs +2 -2
- package/foundation/env/package-manager.d.mts +12 -4
- package/foundation/env/package-manager.mjs +15 -6
- package/foundation/env/semver.mjs +41 -9
- package/foundation/fs/listing-cache.d.mts +3 -1
- package/foundation/fs/listing-cache.mjs +63 -11
- package/foundation/fs/paths.mjs +2 -1
- package/foundation/release/notices.d.mts +16 -0
- package/foundation/release/notices.mjs +27 -6
- package/foundation/render/embedded-imports.d.mts +7 -0
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/page-worker.mjs +109 -4
- package/foundation/render/render-page.d.mts +16 -1
- package/foundation/render/render-page.mjs +25 -18
- package/foundation/render/served-packages.d.mts +33 -0
- package/foundation/render/served-packages.mjs +75 -0
- package/foundation/render/single-copy-hooks.d.mts +18 -0
- package/foundation/render/single-copy-hooks.mjs +44 -0
- package/foundation/text/string-utils.mjs +25 -25
- package/package.json +6 -6
package/api/build/build.doc.mjs
CHANGED
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
templateSetupNotes,
|
|
28
28
|
} from '../_adapter.mjs';
|
|
29
29
|
import {ideaKind} from './kind.mjs';
|
|
30
|
-
import {
|
|
31
|
-
import {asTemplate, chooseStart} from './start.mjs';
|
|
30
|
+
import {rankPages} from './rank.mjs';
|
|
31
|
+
import {asTemplate, chooseStart, pickStartAlternatives} from './start.mjs';
|
|
32
32
|
|
|
33
33
|
/** A page at/above this score is a confident direct match. */
|
|
34
34
|
const PAGE_DIRECT = 95;
|
|
@@ -247,7 +247,13 @@ export async function kitSignals(query, options = {}) {
|
|
|
247
247
|
/** @type {BuildStart | null} */
|
|
248
248
|
const start = chosen && {
|
|
249
249
|
...chosen,
|
|
250
|
-
alternatives:
|
|
250
|
+
alternatives: pickStartAlternatives(
|
|
251
|
+
ranked,
|
|
252
|
+
kind,
|
|
253
|
+
chosen.name,
|
|
254
|
+
catalog,
|
|
255
|
+
query,
|
|
256
|
+
).flatMap(r => {
|
|
251
257
|
const t = catalog.find(c => c.name === r.name);
|
|
252
258
|
return t ? [asTemplate(t)] : [];
|
|
253
259
|
}),
|
|
@@ -20,6 +20,25 @@
|
|
|
20
20
|
* @returns {Omit<BuildStart, 'alternatives'> | null}
|
|
21
21
|
*/
|
|
22
22
|
export function chooseStart(ranked: import("./rank.mjs").RankedPage[], kind: import("./rank.mjs").IdeaKind, pages: SearchResultEntry[], directMatch: boolean, catalog: PageTemplate[], idea: string): Omit<BuildStart, "alternatives"> | null;
|
|
23
|
+
/**
|
|
24
|
+
* The next best page templates beside the start (spec:AST-048/FR7), in the
|
|
25
|
+
* order the start itself is chosen from. The candidates are the ranker's (a
|
|
26
|
+
* template with matched words and half a start's score); a whole page orders
|
|
27
|
+
* them by the word weights' blend, the same ranking that picks its start, so
|
|
28
|
+
* the templates build names are the blend's best. The blend knows only the
|
|
29
|
+
* templates its tables list: one it does not list (a shell, an integration's
|
|
30
|
+
* template, or one added since the tables were fit) keeps the place the ranker
|
|
31
|
+
* gives it, so a new template is never pushed out by tables that have not seen
|
|
32
|
+
* it. A part or an edit, or a project without weights, keeps the ranker's
|
|
33
|
+
* order.
|
|
34
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
35
|
+
* @param {import('./rank.mjs').IdeaKind} kind
|
|
36
|
+
* @param {string} startName
|
|
37
|
+
* @param {PageTemplate[]} catalog
|
|
38
|
+
* @param {string} idea
|
|
39
|
+
* @returns {import('./rank.mjs').RankedPage[]}
|
|
40
|
+
*/
|
|
41
|
+
export function pickStartAlternatives(ranked: import("./rank.mjs").RankedPage[], kind: import("./rank.mjs").IdeaKind, startName: string, catalog: PageTemplate[], idea: string): import("./rank.mjs").RankedPage[];
|
|
23
42
|
export function asTemplate(t: PageTemplate): {
|
|
24
43
|
name: string;
|
|
25
44
|
package: string;
|
package/api/build/kit/start.mjs
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import {loadWeights} from '../_adapter.mjs';
|
|
9
9
|
import {asksForNewPage} from './kind.mjs';
|
|
10
|
-
import {pickStart} from './rank.mjs';
|
|
11
|
-
import {weighStart} from './weights.mjs';
|
|
10
|
+
import {pickAlternatives, pickStart} from './rank.mjs';
|
|
11
|
+
import {blendOrder, weighStart} from './weights.mjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import('../../search/search.type.mjs').SearchResultEntry} SearchResultEntry
|
|
@@ -161,3 +161,50 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
|
161
161
|
}
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The next best page templates beside the start (spec:AST-048/FR7), in the
|
|
167
|
+
* order the start itself is chosen from. The candidates are the ranker's (a
|
|
168
|
+
* template with matched words and half a start's score); a whole page orders
|
|
169
|
+
* them by the word weights' blend, the same ranking that picks its start, so
|
|
170
|
+
* the templates build names are the blend's best. The blend knows only the
|
|
171
|
+
* templates its tables list: one it does not list (a shell, an integration's
|
|
172
|
+
* template, or one added since the tables were fit) keeps the place the ranker
|
|
173
|
+
* gives it, so a new template is never pushed out by tables that have not seen
|
|
174
|
+
* it. A part or an edit, or a project without weights, keeps the ranker's
|
|
175
|
+
* order.
|
|
176
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
177
|
+
* @param {import('./rank.mjs').IdeaKind} kind
|
|
178
|
+
* @param {string} startName
|
|
179
|
+
* @param {PageTemplate[]} catalog
|
|
180
|
+
* @param {string} idea
|
|
181
|
+
* @returns {import('./rank.mjs').RankedPage[]}
|
|
182
|
+
*/
|
|
183
|
+
export function pickStartAlternatives(ranked, kind, startName, catalog, idea) {
|
|
184
|
+
const eligible = pickAlternatives(ranked, startName, ranked.length);
|
|
185
|
+
const byRanker = eligible.slice(0, 2);
|
|
186
|
+
if (kind !== 'page') return byRanker;
|
|
187
|
+
const weights = loadWeights();
|
|
188
|
+
const order = blendOrder(
|
|
189
|
+
idea,
|
|
190
|
+
ranked,
|
|
191
|
+
pickStart(ranked, kind),
|
|
192
|
+
catalog,
|
|
193
|
+
weights,
|
|
194
|
+
);
|
|
195
|
+
if (!weights || !order) return byRanker;
|
|
196
|
+
const listed = new Set(weights.candidates);
|
|
197
|
+
const at = new Map(order.map((name, i) => [name, i]));
|
|
198
|
+
// Unlisted templates keep their ranker slot; the rest follow the blend.
|
|
199
|
+
/** @type {(import('./rank.mjs').RankedPage | null)[]} */
|
|
200
|
+
const slots = byRanker.map(r => (listed.has(r.name) ? null : r));
|
|
201
|
+
const rest = eligible
|
|
202
|
+
.filter(r => listed.has(r.name) && at.has(r.name))
|
|
203
|
+
.sort(
|
|
204
|
+
(a, b) =>
|
|
205
|
+
/** @type {number} */ (at.get(a.name)) -
|
|
206
|
+
/** @type {number} */ (at.get(b.name)),
|
|
207
|
+
);
|
|
208
|
+
const out = slots.map(slot => slot ?? rest.shift() ?? null);
|
|
209
|
+
return /** @type {import('./rank.mjs').RankedPage[]} */ (out.filter(Boolean));
|
|
210
|
+
}
|
|
@@ -13,6 +13,18 @@ export function stem(word: string): string;
|
|
|
13
13
|
* @returns {string[]}
|
|
14
14
|
*/
|
|
15
15
|
export function weightWords(idea: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Every ready, non-shell template in the blend's own order, best first: the
|
|
18
|
+
* order the page start is chosen from, so the alternatives build names beside
|
|
19
|
+
* the start come from the same ranking. Null without weights.
|
|
20
|
+
* @param {string} idea
|
|
21
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
22
|
+
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
23
|
+
* @param {DescribedTemplate[]} catalog
|
|
24
|
+
* @param {WeightsFile | null} weights
|
|
25
|
+
* @returns {string[] | null}
|
|
26
|
+
*/
|
|
27
|
+
export function blendOrder(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: DescribedTemplate[], weights: WeightsFile | null): string[] | null;
|
|
16
28
|
/**
|
|
17
29
|
* Where an idea starts, by the blended weights.
|
|
18
30
|
* @param {string} idea
|
|
@@ -281,24 +281,16 @@ function familyAt(name, catalog, order) {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
|
-
*
|
|
284
|
+
* The blend's score for every candidate: the app shell and every ready,
|
|
285
|
+
* non-shell template, the table's first, then any the table does not list.
|
|
285
286
|
* @param {string} idea
|
|
286
|
-
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
287
|
-
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
288
|
-
* @param {DescribedTemplate[]} catalog
|
|
289
|
-
* @param {
|
|
290
|
-
*
|
|
291
|
-
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
292
|
-
* undefined without weights
|
|
287
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
288
|
+
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
289
|
+
* @param {DescribedTemplate[]} catalog
|
|
290
|
+
* @param {WeightsFile} weights
|
|
291
|
+
* @returns {{cands: string[], scores: number[], position: Map<string, number>}}
|
|
293
292
|
*/
|
|
294
|
-
|
|
295
|
-
idea,
|
|
296
|
-
ranked,
|
|
297
|
-
pick,
|
|
298
|
-
catalog,
|
|
299
|
-
{weights = null, newPage = false} = {},
|
|
300
|
-
) {
|
|
301
|
-
if (!weights) return undefined;
|
|
293
|
+
function blend(idea, ranked, pick, catalog, weights) {
|
|
302
294
|
const ready = new Set(catalog.map(t => t.name));
|
|
303
295
|
const shellIds = new Set(
|
|
304
296
|
ranked.filter(r => r.family === SHELL_FAMILY).map(r => r.name),
|
|
@@ -335,6 +327,50 @@ export function weighStart(
|
|
|
335
327
|
for (const f of feats) for (const x of f[i]) s += x * weights.blend[j++];
|
|
336
328
|
return s + (c === SHELL ? 1 : 0) * weights.blend[j];
|
|
337
329
|
});
|
|
330
|
+
return {cands, scores, position};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Every ready, non-shell template in the blend's own order, best first: the
|
|
335
|
+
* order the page start is chosen from, so the alternatives build names beside
|
|
336
|
+
* the start come from the same ranking. Null without weights.
|
|
337
|
+
* @param {string} idea
|
|
338
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
339
|
+
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
340
|
+
* @param {DescribedTemplate[]} catalog
|
|
341
|
+
* @param {WeightsFile | null} weights
|
|
342
|
+
* @returns {string[] | null}
|
|
343
|
+
*/
|
|
344
|
+
export function blendOrder(idea, ranked, pick, catalog, weights) {
|
|
345
|
+
if (!weights) return null;
|
|
346
|
+
const {cands, scores} = blend(idea, ranked, pick, catalog, weights);
|
|
347
|
+
return cands
|
|
348
|
+
.map((c, i) => ({c, s: scores[i], i}))
|
|
349
|
+
.filter(x => x.c !== SHELL)
|
|
350
|
+
.sort((x, y) => y.s - x.s || x.i - y.i)
|
|
351
|
+
.map(x => x.c);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Where an idea starts, by the blended weights.
|
|
356
|
+
* @param {string} idea
|
|
357
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked the ranker's output for the idea
|
|
358
|
+
* @param {import('./rank.mjs').RankedPage | null} pick the ranker's own start
|
|
359
|
+
* @param {DescribedTemplate[]} catalog the project's ready page templates
|
|
360
|
+
* @param {{weights?: WeightsFile | null, newPage?: boolean}} [options]
|
|
361
|
+
* `newPage`: the idea asks for a new page (rank.mjs `asksForNewPage`)
|
|
362
|
+
* @returns {string | null | undefined} a template id, null for the app shell,
|
|
363
|
+
* undefined without weights
|
|
364
|
+
*/
|
|
365
|
+
export function weighStart(
|
|
366
|
+
idea,
|
|
367
|
+
ranked,
|
|
368
|
+
pick,
|
|
369
|
+
catalog,
|
|
370
|
+
{weights = null, newPage = false} = {},
|
|
371
|
+
) {
|
|
372
|
+
if (!weights) return undefined;
|
|
373
|
+
const {cands, scores, position} = blend(idea, ranked, pick, catalog, weights);
|
|
338
374
|
/** @param {(c: string) => boolean} ok */
|
|
339
375
|
const best = ok => {
|
|
340
376
|
let at = -1;
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -700,7 +700,8 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
|
|
|
700
700
|
entry &&
|
|
701
701
|
!entry.tree &&
|
|
702
702
|
(providerOf(entry) === provider ||
|
|
703
|
-
catalog.aliasesOf(entry).includes(parsed.name.toLowerCase())
|
|
703
|
+
catalog.aliasesOf(entry).includes(parsed.name.toLowerCase()) ||
|
|
704
|
+
entry.replaces?.toLowerCase() === parsed.name.toLowerCase())
|
|
704
705
|
) {
|
|
705
706
|
let title = entry.title ?? entry.name;
|
|
706
707
|
let summary = entry.description ?? '';
|
|
@@ -15,8 +15,11 @@ export function readTextFileIfExists(file: string): string | null;
|
|
|
15
15
|
* links. The doctor parses the returned bytes without executing app code.
|
|
16
16
|
* @param {string} root
|
|
17
17
|
* @param {string} generatedModule
|
|
18
|
+
* @param {{stylesheets?: boolean}} [options] - also list `.css` files
|
|
18
19
|
*/
|
|
19
|
-
export function listProjectSourceFiles(root: string, generatedModule: string
|
|
20
|
+
export function listProjectSourceFiles(root: string, generatedModule: string, options?: {
|
|
21
|
+
stylesheets?: boolean;
|
|
22
|
+
}): string[];
|
|
20
23
|
/** @param {string} projectDir */
|
|
21
24
|
export function discoverDoctorThemes(projectDir: string): Promise<import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme[]>;
|
|
22
25
|
/**
|
|
@@ -30,6 +33,29 @@ export function resolveDoctorThemeImports(theme: import("../../foundation/discov
|
|
|
30
33
|
}): import("../../foundation/config/theme-state.mjs").ResolvedAppTheme;
|
|
31
34
|
/** @param {string} projectDir */
|
|
32
35
|
export function discoverDoctorUnmigratedCopies(projectDir: string): import("../../foundation/discovery/theme-discovery.mjs").UnmigratedThemeCopy[];
|
|
36
|
+
/**
|
|
37
|
+
* The real path of a file, links resolved; null when it does not exist.
|
|
38
|
+
* @param {string} file
|
|
39
|
+
* @returns {string | null}
|
|
40
|
+
*/
|
|
41
|
+
export function realDoctorFile(file: string): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Where each `<Name prop={value}>` value of a module is declared (see
|
|
44
|
+
* `elementPropOrigins`).
|
|
45
|
+
* @param {string} file
|
|
46
|
+
* @param {Parameters<typeof elementPropOrigins>[1]} element
|
|
47
|
+
*/
|
|
48
|
+
export function doctorElementPropOrigins(file: string, element: Parameters<typeof elementPropOrigins>[1]): ({
|
|
49
|
+
file: string;
|
|
50
|
+
name: string;
|
|
51
|
+
} | null)[];
|
|
52
|
+
/**
|
|
53
|
+
* The `@import` specifiers of a stylesheet, quoted or in `url()`, in any case
|
|
54
|
+
* (see `cssImports`); empty for CSS that does not parse.
|
|
55
|
+
* @param {string} css
|
|
56
|
+
* @returns {Set<string>}
|
|
57
|
+
*/
|
|
58
|
+
export function doctorStylesheetImports(css: string): Set<string>;
|
|
33
59
|
/** @param {string} projectDir */
|
|
34
60
|
export function findDoctorCoreDir(projectDir: string): string | null;
|
|
35
61
|
/** @param {string} projectDir @param {string} packageName */
|
|
@@ -212,6 +238,7 @@ export { displayHomePath };
|
|
|
212
238
|
/** `doctor --built` reads at most this many files, of at most this size. */
|
|
213
239
|
export const BUILT_FILE_LIMIT: 20000;
|
|
214
240
|
export const BUILT_FILE_MAX_MB: 5;
|
|
241
|
+
import { elementPropOrigins } from '../../foundation/discovery/module-exports.mjs';
|
|
215
242
|
import { globalBehind } from '../../foundation/release/notices.mjs';
|
|
216
243
|
import { projectLag } from '../../foundation/release/notices.mjs';
|
|
217
244
|
import { lastNoticeSkip } from '../../foundation/release/notices.mjs';
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -39,6 +39,8 @@ import {
|
|
|
39
39
|
} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
40
40
|
import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
|
|
41
41
|
import * as fs from 'node:fs';
|
|
42
|
+
import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
|
|
43
|
+
import {cssImports} from '../../foundation/render/embedded-imports.mjs';
|
|
42
44
|
import * as path from 'node:path';
|
|
43
45
|
import {
|
|
44
46
|
Project,
|
|
@@ -113,8 +115,9 @@ export function readTextFileIfExists(file) {
|
|
|
113
115
|
* links. The doctor parses the returned bytes without executing app code.
|
|
114
116
|
* @param {string} root
|
|
115
117
|
* @param {string} generatedModule
|
|
118
|
+
* @param {{stylesheets?: boolean}} [options] - also list `.css` files
|
|
116
119
|
*/
|
|
117
|
-
export function listProjectSourceFiles(root, generatedModule) {
|
|
120
|
+
export function listProjectSourceFiles(root, generatedModule, options = {}) {
|
|
118
121
|
/** @type {string[]} */
|
|
119
122
|
const files = [];
|
|
120
123
|
/** @type {string[]} */
|
|
@@ -137,7 +140,8 @@ export function listProjectSourceFiles(root, generatedModule) {
|
|
|
137
140
|
} else if (
|
|
138
141
|
entry.isFile() &&
|
|
139
142
|
file !== generatedModule &&
|
|
140
|
-
SOURCE_EXTENSIONS.has(path.extname(entry.name))
|
|
143
|
+
(SOURCE_EXTENSIONS.has(path.extname(entry.name)) ||
|
|
144
|
+
(options.stylesheets === true && path.extname(entry.name) === '.css'))
|
|
141
145
|
) {
|
|
142
146
|
files.push(file);
|
|
143
147
|
}
|
|
@@ -166,6 +170,39 @@ export function discoverDoctorUnmigratedCopies(projectDir) {
|
|
|
166
170
|
return discoverUnmigratedThemeCopies(projectDir);
|
|
167
171
|
}
|
|
168
172
|
|
|
173
|
+
/**
|
|
174
|
+
* The real path of a file, links resolved; null when it does not exist.
|
|
175
|
+
* @param {string} file
|
|
176
|
+
* @returns {string | null}
|
|
177
|
+
*/
|
|
178
|
+
export function realDoctorFile(file) {
|
|
179
|
+
try {
|
|
180
|
+
return fs.realpathSync(file);
|
|
181
|
+
} catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Where each `<Name prop={value}>` value of a module is declared (see
|
|
188
|
+
* `elementPropOrigins`).
|
|
189
|
+
* @param {string} file
|
|
190
|
+
* @param {Parameters<typeof elementPropOrigins>[1]} element
|
|
191
|
+
*/
|
|
192
|
+
export function doctorElementPropOrigins(file, element) {
|
|
193
|
+
return elementPropOrigins(file, element);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The `@import` specifiers of a stylesheet, quoted or in `url()`, in any case
|
|
198
|
+
* (see `cssImports`); empty for CSS that does not parse.
|
|
199
|
+
* @param {string} css
|
|
200
|
+
* @returns {Set<string>}
|
|
201
|
+
*/
|
|
202
|
+
export function doctorStylesheetImports(css) {
|
|
203
|
+
return new Set(cssImports(css));
|
|
204
|
+
}
|
|
205
|
+
|
|
169
206
|
/** @param {string} projectDir */
|
|
170
207
|
export function findDoctorCoreDir(projectDir) {
|
|
171
208
|
return findProjectCoreDir(projectDir);
|
|
@@ -24,7 +24,7 @@ export const doc = {
|
|
|
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 ' +
|
|
27
|
-
'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `{@command init --user}` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `{@pm install @astryxdesign/cli@latest --global}`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
|
|
27
|
+
'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add, and the `themes` check counts a theme as wired when package.json `astryx.theme` names one or when the source of the app (JavaScript, TypeScript and CSS files, outside dependencies and build output; type-only imports do not count) imports the built module or stylesheet of a discovered theme, the same imports theme add writes, or passes one to Theme (followed through module-scope variables, defineTheme extends, re-exports and installed packages; only a theme whose package is installed, or a local theme, counts), naming the file; a theme passed to Theme that cannot be traced, such as a prop or a variable declared inside a component, is reported as unconfirmed (info), not as missing. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `{@command init --user}` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `{@pm install @astryxdesign/cli@latest --global}`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
|
|
28
28
|
' In global mode: with `cwd` outside a project, it checks the computer instead (the Node version, the version that answered, the newest version it knows of, the astryx commands on the search path, the integrations installed globally, and the agent guide for the computer) and never fails a check because the folder has no project. See {@link namespace:global} and {@link generic:who-answers}.',
|
|
29
29
|
importPath: '@astryxdesign/cli/api',
|
|
30
30
|
signature: 'doctor(options?: DoctorOptions): Promise<DoctorResponse>',
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -65,7 +65,11 @@ import {typedEdges} from '../docs/node/node.mjs';
|
|
|
65
65
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
66
66
|
import {isExperimentalTreeNode} from '../../foundation/doc-compiler/tree.mjs';
|
|
67
67
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
68
|
-
import {
|
|
68
|
+
import {
|
|
69
|
+
checkAppThemes,
|
|
70
|
+
checkThemes,
|
|
71
|
+
themeImportWiring,
|
|
72
|
+
} from './theme-checks.mjs';
|
|
69
73
|
import {availableLine, RUN_FROM_PROJECT, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
70
74
|
import {COMPUTER_COMMAND, COMPUTER_INSTALL_STEP} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
71
75
|
import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, insideProjectElsewhere, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts, builtIntegrationPackages} from './_adapter.mjs';
|
|
@@ -2190,7 +2194,10 @@ export async function runChecks(options = {}) {
|
|
|
2190
2194
|
if (check) checks.push(check);
|
|
2191
2195
|
if (fn === checkVersionAlignment) {
|
|
2192
2196
|
const appThemeChecks = await checkAppThemes(cwd);
|
|
2193
|
-
checks.push(
|
|
2197
|
+
checks.push(
|
|
2198
|
+
checkThemes(cwd, appThemeChecks, await themeImportWiring(cwd)),
|
|
2199
|
+
...appThemeChecks,
|
|
2200
|
+
);
|
|
2194
2201
|
checks.push(await checkConfig(ctx));
|
|
2195
2202
|
}
|
|
2196
2203
|
}
|
|
@@ -1,18 +1,59 @@
|
|
|
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
|
+
* The themes the app wires itself, without a generated theme module or a
|
|
6
|
+
* package.json `astryx.theme`. A theme is wired when the app's own source
|
|
7
|
+
* imports its built module or stylesheet ({@link resolveDoctorThemeImports}
|
|
8
|
+
* names them: the imports `theme add` writes), or when the app passes it to
|
|
9
|
+
* Core's `Theme`: {@link doctorElementPropOrigins} follows the `theme` value through
|
|
10
|
+
* module-scope aliases, `defineTheme({extends})`, re-exports and installed
|
|
11
|
+
* packages to where it is declared, which must be inside an installed theme
|
|
12
|
+
* package or be a local theme's built module. Only themes the app can load
|
|
13
|
+
* count: a theme whose package is not installed is never wired. A `theme`
|
|
14
|
+
* value whose origin is anything else (a prop, a function result, a lookup)
|
|
15
|
+
* is reported as unconfirmed, never as missing. The scan reads app source only
|
|
16
|
+
* (no dependencies, build output, links or type-only imports) within the
|
|
17
|
+
* bounded source walk, and executes nothing.
|
|
18
|
+
* @param {string} cwd
|
|
19
|
+
* @returns {Promise<{
|
|
20
|
+
* wired: Array<{slug: string, owner: string, file: string}>,
|
|
21
|
+
* unconfirmed: Array<{file: string}>,
|
|
22
|
+
* }>}
|
|
23
|
+
*/
|
|
24
|
+
export function themeImportWiring(cwd: string): Promise<{
|
|
25
|
+
wired: Array<{
|
|
26
|
+
slug: string;
|
|
27
|
+
owner: string;
|
|
28
|
+
file: string;
|
|
29
|
+
}>;
|
|
30
|
+
unconfirmed: Array<{
|
|
31
|
+
file: string;
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
4
34
|
/**
|
|
5
35
|
* The `themes` check that every released doctor report carries. Its id is
|
|
6
36
|
* stable, so it stays beside the app-theme checks. Without a generated theme
|
|
7
37
|
* module it reports what it always has: whether an `@astryxdesign/theme-*`
|
|
8
38
|
* package is installed, and whether the app's package.json names a theme in
|
|
9
|
-
* `astryx.theme
|
|
10
|
-
*
|
|
39
|
+
* `astryx.theme`, or else whether the app's own source imports a theme's built
|
|
40
|
+
* module or stylesheet ({@link themeImportWiring}). With a generated module it
|
|
41
|
+
* reports the overall result of the app-theme checks.
|
|
11
42
|
* @param {string} cwd
|
|
12
43
|
* @param {DoctorCheck[]} appChecks - the checks {@link checkAppThemes} returned
|
|
44
|
+
* @param {{wired: Array<{slug: string, file: string}>, unconfirmed: Array<{file: string}>}} [wiring] -
|
|
45
|
+
* what {@link themeImportWiring} returned
|
|
13
46
|
* @returns {DoctorCheck}
|
|
14
47
|
*/
|
|
15
|
-
export function checkThemes(cwd: string, appChecks: DoctorCheck[]
|
|
48
|
+
export function checkThemes(cwd: string, appChecks: DoctorCheck[], wiring?: {
|
|
49
|
+
wired: Array<{
|
|
50
|
+
slug: string;
|
|
51
|
+
file: string;
|
|
52
|
+
}>;
|
|
53
|
+
unconfirmed: Array<{
|
|
54
|
+
file: string;
|
|
55
|
+
}>;
|
|
56
|
+
}): DoctorCheck;
|
|
16
57
|
/**
|
|
17
58
|
* Run all ten app-theme checks.
|
|
18
59
|
* @param {string} cwd
|