@astryxdesign/cli 0.7.2 → 0.7.3-canary.b74cf21
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 +99 -66
- package/api/build/_adapter.d.mts +58 -0
- package/api/build/_adapter.mjs +115 -3
- package/api/build/blocks/blocks.d.mts +42 -0
- package/api/build/blocks/blocks.mjs +169 -0
- package/api/build/blocks/blocks.test.mjs +108 -0
- package/api/build/blocks/blocks.weights.json +1 -0
- package/api/build/build.mjs +25 -6
- package/api/build/kit/answer.d.mts +14 -0
- package/api/build/kit/answer.mjs +85 -0
- package/api/build/kit/answer.test.mjs +38 -0
- package/api/build/kit/kind.d.mts +25 -0
- package/api/build/kit/kind.mjs +170 -0
- package/api/build/kit/kit.d.mts +2 -4
- package/api/build/kit/kit.mjs +8 -398
- package/api/build/kit/rank.d.mts +3 -32
- package/api/build/kit/rank.mjs +25 -342
- package/api/build/kit/rank.test.mjs +2 -1
- package/api/build/kit/signals.d.mts +60 -0
- package/api/build/kit/signals.mjs +284 -0
- package/api/build/kit/start.d.mts +32 -0
- package/api/build/kit/start.mjs +163 -0
- package/api/build/kit/words.d.mts +72 -0
- package/api/build/kit/words.mjs +202 -0
- package/api/build/tree.d.mts +20 -0
- package/api/build/tree.mjs +52 -0
- package/api/build/tree.test.mjs +177 -0
- package/api/build/tree.weights.json +1 -0
- package/api/discover/_adapter.mjs +36 -9
- package/api/discover/_adapter.test.mjs +42 -0
- package/api/docs/_adapter.mjs +17 -5
- package/api/docs/docs.test.mjs +7 -1
- package/api/doctor/doctor.mjs +86 -12
- package/api/init/init.doc.mjs +20 -6
- package/api/init/init.test.mjs +18 -2
- package/api/init/init.type.d.mts +3 -3
- package/api/init/init.type.mjs +3 -3
- package/api/init/remove/remove.mjs +17 -4
- package/api/init/remove/remove.test.mjs +114 -2
- package/api/init/run/run.mjs +69 -6
- package/api/integration/authoring-checks.mjs +83 -9
- package/api/integration/pack-check.mjs +14 -1
- package/api/integration/pack-check.test.mjs +18 -0
- package/api/integration/validate-integration-case-disk.test.mjs +111 -0
- package/api/integration/validate-integration-gaps.test.mjs +1672 -0
- package/api/integration/validate-integration.d.mts +9 -1
- package/api/integration/validate-integration.mjs +216 -26
- package/api/integration/validate-integration.type.d.mts +57 -1
- package/api/integration/validate-integration.type.mjs +44 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/ORDERING.md +28 -0
- package/api/search/_adapter.d.mts +66 -2
- package/api/search/_adapter.mjs +118 -10
- package/api/search/_candidate-score.d.mts +40 -0
- package/api/search/_candidate-score.mjs +238 -0
- package/api/search/_cards.json +6098 -0
- package/api/search/_compound.d.mts +50 -0
- package/api/search/_compound.mjs +170 -0
- package/api/search/_doc-searcher.d.mts +4 -0
- package/api/search/_doc-searcher.mjs +23 -0
- package/api/search/_doc-searcher.test.mjs +36 -0
- package/api/search/_doc-searcher.weights.json +1 -0
- package/api/search/_doc-text.d.mts +30 -0
- package/api/search/_doc-text.mjs +87 -0
- package/api/search/_entries.d.mts +52 -0
- package/api/search/_entries.mjs +158 -0
- package/api/search/_features.d.mts +35 -0
- package/api/search/_features.mjs +155 -0
- package/api/search/_gather-components.d.mts +26 -0
- package/api/search/_gather-components.mjs +284 -0
- package/api/search/_gather-docs.d.mts +20 -0
- package/api/search/_gather-docs.mjs +254 -0
- package/api/search/_gather-hooks.d.mts +12 -0
- package/api/search/_gather-hooks.mjs +52 -0
- package/api/search/_gather-templates.d.mts +25 -0
- package/api/search/_gather-templates.mjs +107 -0
- package/api/search/_lexical.d.mts +135 -0
- package/api/search/_lexical.mjs +351 -0
- package/api/search/_main-searcher.d.mts +19 -0
- package/api/search/_main-searcher.mjs +115 -0
- package/api/search/_main-searcher.test.mjs +106 -0
- package/api/search/_main-searcher.weights.json +1 -0
- package/api/search/_module-doc.d.mts +32 -0
- package/api/search/_module-doc.mjs +78 -0
- package/api/search/_order.d.mts +32 -0
- package/api/search/_order.mjs +162 -0
- package/api/search/_order.test.mjs +72 -0
- package/api/search/_priority.d.mts +50 -0
- package/api/search/_priority.mjs +139 -0
- package/api/search/_query-words.d.mts +25 -0
- package/api/search/_query-words.mjs +92 -0
- package/api/search/_query.d.mts +65 -0
- package/api/search/_query.mjs +176 -0
- package/api/search/_result.d.mts +97 -0
- package/api/search/_result.mjs +150 -0
- package/api/search/_score.d.mts +60 -0
- package/api/search/_score.mjs +283 -0
- package/api/search/_synonyms.d.mts +21 -0
- package/api/search/_synonyms.mjs +67 -0
- package/api/search/_template-searcher.d.mts +4 -0
- package/api/search/_template-searcher.mjs +23 -0
- package/api/search/_template-searcher.test.mjs +40 -0
- package/api/search/_template-searcher.weights.json +1 -0
- package/api/search/_titles.d.mts +33 -0
- package/api/search/_titles.mjs +65 -0
- package/api/search/_words.d.mts +64 -0
- package/api/search/_words.mjs +157 -0
- package/api/search/search.d.mts +22 -305
- package/api/search/search.doc.mjs +7 -5
- package/api/search/search.mjs +53 -2483
- package/api/search/search.type.d.mts +6 -1
- package/api/search/search.type.mjs +6 -1
- package/api/search/tree.d.mts +15 -0
- package/api/search/tree.mjs +40 -0
- package/api/search/tree.test.mjs +66 -0
- package/api/search/tree.weights.json +1 -0
- package/api/theme/build/build.packed-old-core.test.mjs +1 -0
- package/api/upgrade/_adapter.d.mts +0 -6
- package/api/upgrade/_adapter.mjs +52 -4
- package/api/upgrade/upgrade.test.mjs +194 -0
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +11 -0
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +3 -3
- package/assets/docs/tree/api.doc.mjs +6 -0
- package/assets/docs/tree/host-entry.doc.mjs +128 -0
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +6 -2
- package/authoring/debug/parse.d.mts +1 -1
- package/clients/cli/bin/astryx.mjs +7 -78
- package/clients/cli/commands/doctor.mjs +30 -0
- package/clients/cli/commands/doctor.test.mjs +65 -0
- package/clients/cli/commands/init.behavior.test.mjs +230 -1
- package/clients/cli/commands/init.doc.mjs +28 -9
- package/clients/cli/commands/init.flag-help.test.mjs +1 -0
- package/clients/cli/commands/init.mjs +2 -2
- package/clients/cli/commands/outside-project.test.mjs +2 -1
- package/clients/cli/commands/setup-nudge.test.mjs +61 -0
- package/clients/cli/index.mjs +19 -1
- package/clients/cli/run.mjs +108 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +20 -7
- package/foundation/agent-docs/agent-doc-state.mjs +35 -8
- package/foundation/agent-docs/agent-docs.d.mts +100 -12
- package/foundation/agent-docs/agent-docs.mjs +1010 -99
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +1239 -17
- package/foundation/agent-docs/agent-docs.test.mjs +678 -35
- package/foundation/config/project.mjs +15 -2
- package/foundation/discovery/component-discovery.d.mts +37 -0
- package/foundation/discovery/component-discovery.mjs +80 -5
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/docs-discovery.mjs +14 -1
- package/foundation/discovery/module-exports.d.mts +41 -0
- package/foundation/discovery/module-exports.mjs +253 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +8 -0
- package/foundation/fs/paths.mjs +30 -3
- package/foundation/integrations/computer-integrations.d.mts +6 -3
- package/foundation/integrations/computer-integrations.mjs +38 -9
- package/foundation/integrations/contribution-inventory.d.mts +15 -20
- package/foundation/integrations/contribution-inventory.mjs +41 -5
- package/foundation/integrations/integrations.d.mts +7 -0
- package/foundation/integrations/integrations.mjs +2 -0
- package/foundation/integrations/validate-contributions.d.mts +96 -0
- package/foundation/integrations/validate-contributions.mjs +996 -10
- package/foundation/release/handoff.d.mts +23 -4
- package/foundation/release/handoff.mjs +175 -8
- package/foundation/release/run-context.mjs +14 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/route/route.d.mts +285 -0
- package/foundation/route/route.mjs +324 -0
- package/foundation/route/route.test.mjs +153 -0
- package/foundation/runtime/hosted-runtime.test.mjs +403 -0
- package/foundation/runtime/locked-versions.d.mts +32 -0
- package/foundation/runtime/locked-versions.mjs +65 -0
- package/foundation/runtime/package-root.d.mts +91 -0
- package/foundation/runtime/package-root.mjs +174 -0
- package/foundation/runtime/package-set.d.mts +62 -0
- package/foundation/runtime/package-set.mjs +130 -0
- package/foundation/runtime/package-set.test.mjs +432 -0
- package/host/door-conformance.test.mjs +274 -0
- package/host/index.d.ts +116 -0
- package/host/index.mjs +295 -0
- package/host/index.test.mjs +302 -0
- package/package.json +14 -9
|
@@ -43,7 +43,6 @@ export function summarizeIssues(issues: Issue[]): {
|
|
|
43
43
|
errors: number;
|
|
44
44
|
warnings: number;
|
|
45
45
|
};
|
|
46
|
-
export { validateLoadedIntegration };
|
|
47
46
|
export type Issue = import("../../foundation/integrations/issue").AstryxIntegrationIssue;
|
|
48
47
|
export type ValidateResult = {
|
|
49
48
|
/**
|
|
@@ -75,6 +74,15 @@ export type ValidateResult = {
|
|
|
75
74
|
code: string;
|
|
76
75
|
message: string;
|
|
77
76
|
}[] | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Layout findings added after the last minor
|
|
79
|
+
* release: validate lists them as notes, which count nowhere, since they
|
|
80
|
+
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
81
|
+
* `integration verify` still fails on a package.json npm cannot pack.
|
|
82
|
+
*/
|
|
83
|
+
listed?: import("../../foundation/integrations/issue").AstryxIntegrationIssue[] | undefined;
|
|
78
84
|
integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
|
|
79
85
|
};
|
|
80
86
|
import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
|
|
87
|
+
import { isListedIssue } from '../../foundation/integrations/validate-contributions.mjs';
|
|
88
|
+
export { validateLoadedIntegration, isListedIssue };
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import * as fs from 'node:fs';
|
|
35
35
|
import * as path from 'node:path';
|
|
36
36
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
37
|
+
import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
|
|
37
38
|
import {integrationDocTypes} from '../docs/_adapter.mjs';
|
|
38
39
|
import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
|
|
39
40
|
import {
|
|
@@ -56,15 +57,20 @@ import {
|
|
|
56
57
|
// The on-disk contribution validators live in foundation: Project and
|
|
57
58
|
// integration-warnings need them too, and foundation must not depend on api.
|
|
58
59
|
import {
|
|
60
|
+
blockComponentsCheck,
|
|
61
|
+
componentDocNamesCheck,
|
|
59
62
|
INVALID_CLI_COMMAND,
|
|
63
|
+
isListedIssue,
|
|
64
|
+
issueListed as listed,
|
|
60
65
|
validateLoadedIntegration,
|
|
66
|
+
validateLoadedIntegrationListed,
|
|
61
67
|
issueError as error,
|
|
62
68
|
issueWarning as warning,
|
|
63
69
|
rootProblem,
|
|
64
70
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
65
71
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
66
72
|
|
|
67
|
-
export {validateLoadedIntegration};
|
|
73
|
+
export {validateLoadedIntegration, isListedIssue};
|
|
68
74
|
|
|
69
75
|
/**
|
|
70
76
|
* @typedef {import('../../foundation/integrations/issue').AstryxIntegrationIssue} Issue
|
|
@@ -80,6 +86,10 @@ export {validateLoadedIntegration};
|
|
|
80
86
|
* @property {Issue[]} issues
|
|
81
87
|
* @property {Array<{code: string, message: string}>} [notes] Information that
|
|
82
88
|
* fails nothing, such as `invalid_cli_command` (a malformed `cliCommand`).
|
|
89
|
+
* @property {Issue[]} [listed] Layout findings added after the last minor
|
|
90
|
+
* release: validate lists them as notes, which count nowhere, since they
|
|
91
|
+
* may not fail `--strict` until the next (architecture:cli-surface INV35);
|
|
92
|
+
* `integration verify` still fails on a package.json npm cannot pack.
|
|
83
93
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
|
|
84
94
|
*/
|
|
85
95
|
|
|
@@ -99,6 +109,14 @@ function findNearestPackageJson(cwd) {
|
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
|
|
112
|
+
const ROOT_KINDS = /** @type {const} */ ([
|
|
113
|
+
'components',
|
|
114
|
+
'templates',
|
|
115
|
+
'codemods',
|
|
116
|
+
'docs',
|
|
117
|
+
'themes',
|
|
118
|
+
]);
|
|
119
|
+
|
|
102
120
|
const UNREACHABLE_SCAN_LIMIT = 5_000;
|
|
103
121
|
const UNREACHABLE_SKIP_DIRS = new Set([
|
|
104
122
|
'node_modules',
|
|
@@ -148,27 +166,51 @@ function unreadThemeFolderIssues(packageDir, loaded) {
|
|
|
148
166
|
*
|
|
149
167
|
* @param {string} packageDir
|
|
150
168
|
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} loaded
|
|
169
|
+
* @param {string[]} [reported] folders whose files another issue already covers
|
|
151
170
|
* @returns {Promise<Issue[]>}
|
|
152
171
|
*/
|
|
153
|
-
async function findUnreachableContributionIssues(
|
|
172
|
+
async function findUnreachableContributionIssues(
|
|
173
|
+
packageDir,
|
|
174
|
+
loaded,
|
|
175
|
+
reported = [],
|
|
176
|
+
) {
|
|
177
|
+
// A root that is not a readable folder holds nothing: a fix must never
|
|
178
|
+
// send a file into it.
|
|
179
|
+
const usable = {...loaded};
|
|
180
|
+
for (const kind of ROOT_KINDS) {
|
|
181
|
+
const root = usable[kind];
|
|
182
|
+
if (root != null && rootProblem(root)) usable[kind] = undefined;
|
|
183
|
+
}
|
|
184
|
+
// Every declared root is skipped, readable or not: one that cannot be read
|
|
185
|
+
// has its own issue.
|
|
154
186
|
const roots = /** @type {string[]} */ (
|
|
155
|
-
[
|
|
156
|
-
loaded.components,
|
|
157
|
-
loaded.templates,
|
|
158
|
-
loaded.codemods,
|
|
159
|
-
loaded.docs,
|
|
160
|
-
loaded.themes,
|
|
161
|
-
].filter(Boolean)
|
|
187
|
+
ROOT_KINDS.map(kind => loaded[kind]).filter(Boolean)
|
|
162
188
|
);
|
|
189
|
+
// A folder a symlinked root points at is read through that root.
|
|
190
|
+
const realRoots = roots.map(root => {
|
|
191
|
+
try {
|
|
192
|
+
return fs.realpathSync(root);
|
|
193
|
+
} catch {
|
|
194
|
+
return root;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
163
197
|
/** @type {Issue[]} */
|
|
164
198
|
const issues = [];
|
|
165
|
-
const context = createFixContext(packageDir,
|
|
199
|
+
const context = createFixContext(packageDir, usable);
|
|
166
200
|
let scanned = 0;
|
|
167
201
|
let truncated = false;
|
|
168
202
|
|
|
169
203
|
/** @param {string} dir */
|
|
170
204
|
async function walk(dir) {
|
|
171
205
|
if (roots.some(root => pathIsInside(dir, root))) return;
|
|
206
|
+
if (reported.some(folder => pathIsInside(dir, folder))) return;
|
|
207
|
+
let realDir = dir;
|
|
208
|
+
try {
|
|
209
|
+
realDir = fs.realpathSync(dir);
|
|
210
|
+
} catch {
|
|
211
|
+
// Unreadable: reported below.
|
|
212
|
+
}
|
|
213
|
+
if (realRoots.some(root => pathIsInside(realDir, root))) return;
|
|
172
214
|
let entries;
|
|
173
215
|
try {
|
|
174
216
|
entries = fs
|
|
@@ -301,9 +343,36 @@ async function validateAtPackageDir(
|
|
|
301
343
|
return result;
|
|
302
344
|
}
|
|
303
345
|
|
|
304
|
-
/** @
|
|
305
|
-
const
|
|
346
|
+
/** @type {string[]} absolute roots inside the package */
|
|
347
|
+
const absoluteRoots = [];
|
|
348
|
+
/**
|
|
349
|
+
* @param {string | null | undefined} value
|
|
350
|
+
* @param {string} key the manifest key that declares it
|
|
351
|
+
*/
|
|
352
|
+
const resolveRoot = (value, key, kind = 'contribution root') => {
|
|
306
353
|
if (value == null) return undefined;
|
|
354
|
+
if (path.isAbsolute(value)) {
|
|
355
|
+
// An absolute root names this machine's disk, which no install shares,
|
|
356
|
+
// even when it happens to point inside the package.
|
|
357
|
+
const inside = path.relative(packageDir, value);
|
|
358
|
+
const relative =
|
|
359
|
+
inside === '' || (!inside.startsWith('..') && !path.isAbsolute(inside))
|
|
360
|
+
? `./${inside.split(path.sep).join('/')}`.replace(/\/$/u, '')
|
|
361
|
+
: null;
|
|
362
|
+
// The code an absolute root has always carried, reworded.
|
|
363
|
+
result.issues.push(
|
|
364
|
+
error(
|
|
365
|
+
'root_outside_package',
|
|
366
|
+
`The ${key} root "${value}" is an absolute path, so Astryx reads nothing from it: a root is relative to the package, so it resolves the same wherever the package is installed.` +
|
|
367
|
+
(relative
|
|
368
|
+
? ` Fix: set \`${key}: '${relative === './' ? '.' : relative}'\` in ${path.basename(manifestFile)}.`
|
|
369
|
+
: ` It also points outside the package. Fix: move the files into the package and set \`${key}\` to their folder relative to package.json, such as './${key}'.`),
|
|
370
|
+
),
|
|
371
|
+
);
|
|
372
|
+
// Its files are reported through this issue, not one by one.
|
|
373
|
+
if (relative) absoluteRoots.push(path.resolve(value));
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
307
376
|
try {
|
|
308
377
|
return assertWithin(value, packageDir, {label: kind});
|
|
309
378
|
} catch {
|
|
@@ -320,11 +389,11 @@ async function validateAtPackageDir(
|
|
|
320
389
|
const loaded = {
|
|
321
390
|
name: identity.name,
|
|
322
391
|
version: identity.version,
|
|
323
|
-
components: resolveRoot(manifest.components),
|
|
324
|
-
templates: resolveRoot(manifest.templates),
|
|
325
|
-
codemods: resolveRoot(manifest.codemods),
|
|
326
|
-
docs: resolveRoot(manifest.docs),
|
|
327
|
-
themes: resolveRoot(manifest.themes),
|
|
392
|
+
components: resolveRoot(manifest.components, 'components'),
|
|
393
|
+
templates: resolveRoot(manifest.templates, 'templates'),
|
|
394
|
+
codemods: resolveRoot(manifest.codemods, 'codemods'),
|
|
395
|
+
docs: resolveRoot(manifest.docs, 'docs'),
|
|
396
|
+
themes: resolveRoot(manifest.themes, 'themes'),
|
|
328
397
|
issuesUrl: manifest.issuesUrl,
|
|
329
398
|
agentDocs: manifest.agentDocs,
|
|
330
399
|
cliCommand: manifest.cliCommand,
|
|
@@ -332,6 +401,7 @@ async function validateAtPackageDir(
|
|
|
332
401
|
__agentDocsError: agentDocsError,
|
|
333
402
|
__unknownKeys: unknownKeys,
|
|
334
403
|
__spec: identity.name,
|
|
404
|
+
__declaredProviderId: manifest.providerId,
|
|
335
405
|
__packageDir: packageDir,
|
|
336
406
|
__manifestFile: manifestFile,
|
|
337
407
|
};
|
|
@@ -343,7 +413,9 @@ async function validateAtPackageDir(
|
|
|
343
413
|
// `integration check --strict` fails on any warning, and a new failure code
|
|
344
414
|
// joins only in a minor release (architecture:cli-surface INV35). Doctor's
|
|
345
415
|
// project check still warns about it.
|
|
346
|
-
|
|
416
|
+
const contribution = await validateLoadedIntegrationListed(loaded);
|
|
417
|
+
(result.listed ??= []).push(...contribution.listed);
|
|
418
|
+
for (const issue of contribution.issues) {
|
|
347
419
|
if (issue.code === INVALID_CLI_COMMAND) {
|
|
348
420
|
(result.notes ??= []).push({code: issue.code, message: issue.message});
|
|
349
421
|
} else {
|
|
@@ -370,7 +442,11 @@ async function validateAtPackageDir(
|
|
|
370
442
|
);
|
|
371
443
|
if (scanUnreachable) {
|
|
372
444
|
issues.push(
|
|
373
|
-
...(await findUnreachableContributionIssues(
|
|
445
|
+
...(await findUnreachableContributionIssues(
|
|
446
|
+
packageDir,
|
|
447
|
+
loaded,
|
|
448
|
+
absoluteRoots,
|
|
449
|
+
)),
|
|
374
450
|
);
|
|
375
451
|
}
|
|
376
452
|
|
|
@@ -397,7 +473,7 @@ export async function validateLocalIntegration(cwd = process.cwd()) {
|
|
|
397
473
|
return {found: false, issues: []};
|
|
398
474
|
}
|
|
399
475
|
|
|
400
|
-
/** @type {{name?: string, version?: string}} */
|
|
476
|
+
/** @type {{name?: string, version?: string, private?: boolean}} */
|
|
401
477
|
let pkg;
|
|
402
478
|
try {
|
|
403
479
|
pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
@@ -416,14 +492,103 @@ export async function validateLocalIntegration(cwd = process.cwd()) {
|
|
|
416
492
|
};
|
|
417
493
|
}
|
|
418
494
|
|
|
419
|
-
|
|
495
|
+
// npm publishes nothing without a name and a version, and the name is the
|
|
496
|
+
// provider ID every reader keys the package's contributions on.
|
|
497
|
+
// A package without one is still checked, under a placeholder name.
|
|
498
|
+
const fields = packageJsonFieldIssues(pkg, pkgJsonPath);
|
|
499
|
+
const name =
|
|
500
|
+
typeof pkg.name === 'string' && pkg.name !== ''
|
|
501
|
+
? pkg.name
|
|
502
|
+
: '(local package)';
|
|
503
|
+
const result = await validateAtPackageDir(
|
|
420
504
|
packageDir,
|
|
421
|
-
{
|
|
422
|
-
name: pkg.name ?? '(local package)',
|
|
423
|
-
version: pkg.version,
|
|
424
|
-
},
|
|
505
|
+
{name, version: pkg.version},
|
|
425
506
|
{scanUnreachable: true},
|
|
426
507
|
);
|
|
508
|
+
(result.listed ??= []).unshift(
|
|
509
|
+
...fields,
|
|
510
|
+
// Only a manifest that loaded says whether it declares a providerId; one
|
|
511
|
+
// that did not is reported as invalid_manifest.
|
|
512
|
+
...(result.integration
|
|
513
|
+
? providerIdIssues(
|
|
514
|
+
pkg.name,
|
|
515
|
+
result.integration.__declaredProviderId,
|
|
516
|
+
result.integration.__manifestFile,
|
|
517
|
+
)
|
|
518
|
+
: []),
|
|
519
|
+
);
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Whether `name` is a bare npm package name, the form a provider ID takes.
|
|
525
|
+
* @param {string} name
|
|
526
|
+
*/
|
|
527
|
+
function isPackageName(name) {
|
|
528
|
+
try {
|
|
529
|
+
normalizeProviderId(name);
|
|
530
|
+
return true;
|
|
531
|
+
} catch {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* A warning when no provider ID can be derived for the package: its
|
|
538
|
+
* package.json `name` is not a bare package name and its manifest declares
|
|
539
|
+
* no `providerId` that is one. Readers key the package's contributions on
|
|
540
|
+
* that ID; a missing name is its own warning.
|
|
541
|
+
* @param {unknown} name package.json `name`
|
|
542
|
+
* @param {unknown} declared the manifest's `providerId`
|
|
543
|
+
* @param {string} manifestFile
|
|
544
|
+
* @returns {Issue[]}
|
|
545
|
+
*/
|
|
546
|
+
function providerIdIssues(name, declared, manifestFile) {
|
|
547
|
+
if (typeof name !== 'string' || name === '') return [];
|
|
548
|
+
if (isPackageName(name)) return [];
|
|
549
|
+
if (typeof declared === 'string' && isPackageName(declared)) return [];
|
|
550
|
+
const manifest = path.basename(manifestFile);
|
|
551
|
+
return [
|
|
552
|
+
listed(
|
|
553
|
+
'no_provider_id',
|
|
554
|
+
`No provider ID can be derived for this package: package.json "name" ${JSON.stringify(name)} is not a bare package name (an optional @scope/ and a name, each starting with a lowercase letter or digit and holding only lowercase letters, digits, "-", ".", "_" and "~"), and ${manifest} declares no providerId that is one. Astryx files the package's components, templates and docs under that ID, so links to them and selecting the package cannot work. Fix: rename the package, such as "@your-scope/your-package", or set \`providerId: '@your-scope/your-package'\` in ${manifest}.`,
|
|
555
|
+
),
|
|
556
|
+
];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* A warning for each field npm needs that package.json lacks.
|
|
561
|
+
* @param {{name?: unknown, version?: unknown, private?: unknown}} pkg
|
|
562
|
+
* @param {string} pkgJsonPath
|
|
563
|
+
* @returns {Issue[]}
|
|
564
|
+
*/
|
|
565
|
+
function packageJsonFieldIssues(pkg, pkgJsonPath) {
|
|
566
|
+
/** @type {Issue[]} */
|
|
567
|
+
const issues = [];
|
|
568
|
+
const shown = path.basename(pkgJsonPath);
|
|
569
|
+
// Listed, so validate and `--strict` keep the result they had for these
|
|
570
|
+
// packages; `integration verify`, which packs, reports them as errors.
|
|
571
|
+
if (typeof pkg.name !== 'string' || pkg.name === '') {
|
|
572
|
+
issues.push(
|
|
573
|
+
listed(
|
|
574
|
+
'invalid_package_json',
|
|
575
|
+
`${shown} has no "name", so npm cannot pack or publish the package, and a project that installs it has no name to select it by. Fix: add "name": "@your-scope/your-package" to ${shown}.`,
|
|
576
|
+
),
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
// A private package is never published, so it needs no version.
|
|
580
|
+
if (
|
|
581
|
+
pkg.private !== true &&
|
|
582
|
+
(typeof pkg.version !== 'string' || pkg.version === '')
|
|
583
|
+
) {
|
|
584
|
+
issues.push(
|
|
585
|
+
listed(
|
|
586
|
+
'invalid_package_json',
|
|
587
|
+
`${shown} has no "version", so npm cannot pack or publish the package. Fix: add "version": "0.1.0" to ${shown}.`,
|
|
588
|
+
),
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
return issues;
|
|
427
592
|
}
|
|
428
593
|
|
|
429
594
|
/**
|
|
@@ -504,7 +669,30 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
504
669
|
const docTypes = integration
|
|
505
670
|
? await integrationDocTypes(integration, cwd)
|
|
506
671
|
: undefined;
|
|
507
|
-
|
|
672
|
+
// The component names docs and blocks give: those that cannot be judged
|
|
673
|
+
// are listed in their reports, and those judged wrong are notes.
|
|
674
|
+
const names = integration
|
|
675
|
+
? [
|
|
676
|
+
await componentDocNamesCheck(integration),
|
|
677
|
+
await blockComponentsCheck(integration),
|
|
678
|
+
]
|
|
679
|
+
: undefined;
|
|
680
|
+
const docNames = names?.[0].report;
|
|
681
|
+
const blockComponents = names?.[1].report;
|
|
682
|
+
// Notes fail nothing: a malformed `cliCommand`, and the findings added
|
|
683
|
+
// after the last minor release, each with its fix in the message, which
|
|
684
|
+
// may not fail `--strict` until the next (architecture:cli-surface INV35):
|
|
685
|
+
// the layout findings and the component names judged wrong.
|
|
686
|
+
const notes = result.found
|
|
687
|
+
? [
|
|
688
|
+
...(result.notes ?? []),
|
|
689
|
+
...(result.listed ?? []).map(issue => ({
|
|
690
|
+
code: issue.code,
|
|
691
|
+
message: issue.message,
|
|
692
|
+
})),
|
|
693
|
+
...(names ?? []).flatMap(each => each.notes),
|
|
694
|
+
]
|
|
695
|
+
: [];
|
|
508
696
|
return {
|
|
509
697
|
type: 'integration.validate',
|
|
510
698
|
data: {
|
|
@@ -526,6 +714,8 @@ export async function validateIntegration(pkg, options = {}) {
|
|
|
526
714
|
: result.issues,
|
|
527
715
|
...(notes.length > 0 ? {notes} : {}),
|
|
528
716
|
...(docTypes ? {docTypes} : {}),
|
|
717
|
+
...(docNames ? {docNames} : {}),
|
|
718
|
+
...(blockComponents ? {blockComponents} : {}),
|
|
529
719
|
},
|
|
530
720
|
};
|
|
531
721
|
}
|
|
@@ -36,7 +36,17 @@ export type ValidateIntegrationResponse = {
|
|
|
36
36
|
type: "integration.validate";
|
|
37
37
|
/**
|
|
38
38
|
* `notes`: information beside the issues that fails nothing, such as
|
|
39
|
-
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed
|
|
39
|
+
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed, and
|
|
40
|
+
* the package layout findings added after the last minor release, each with
|
|
41
|
+
* its fix in the message: two docs for one component
|
|
42
|
+
* (`duplicate_component_doc`), a root reached through a symlink
|
|
43
|
+
* (`symlinked_root`), a contribution file that cannot be read
|
|
44
|
+
* (`unreadable_file`), a package.json without `name` or `version`
|
|
45
|
+
* (`invalid_package_json`), no provider ID (`no_provider_id`), and a doc
|
|
46
|
+
* whose file name differs from its source only in letter case where the two
|
|
47
|
+
* still pair (`source_without_component_doc`); and `doc_name_mismatch` and
|
|
48
|
+
* `unknown_block_component` (see `docNames` and `blockComponents`); they
|
|
49
|
+
* become warnings in the next minor release
|
|
40
50
|
*/
|
|
41
51
|
data: {
|
|
42
52
|
validated: boolean;
|
|
@@ -48,6 +58,8 @@ export type ValidateIntegrationResponse = {
|
|
|
48
58
|
message: string;
|
|
49
59
|
}>;
|
|
50
60
|
docTypes?: DocTypesReport;
|
|
61
|
+
docNames?: DocNamesReport;
|
|
62
|
+
blockComponents?: BlockComponentsReport;
|
|
51
63
|
};
|
|
52
64
|
};
|
|
53
65
|
/**
|
|
@@ -57,3 +69,47 @@ export type ValidateIntegrationResponse = {
|
|
|
57
69
|
export type DocTypesReport = import("../../foundation/discovery/doc-types.mjs").DocTypesReport & {
|
|
58
70
|
fixtures?: number;
|
|
59
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Each component doc whose `name` differs from the name it is listed under,
|
|
74
|
+
* judged against its source. Present when the manifest loads. A name the
|
|
75
|
+
* module its printed import names provably does not export is a
|
|
76
|
+
* `doc_name_mismatch` note beside the issues, with its fix in the message
|
|
77
|
+
* (it becomes a warning in the next minor release), so `findings` is always
|
|
78
|
+
* empty; `unchecked` lists each doc whose source's
|
|
79
|
+
* exports could not all be read (a re-export from another package, `export
|
|
80
|
+
* =`, a destructured binding, a namespace): `file` (the doc, package-relative),
|
|
81
|
+
* `name` (what the doc says), and `reason`.
|
|
82
|
+
*/
|
|
83
|
+
export type DocNamesReport = {
|
|
84
|
+
status: "checked";
|
|
85
|
+
findings: [];
|
|
86
|
+
unchecked: Array<{
|
|
87
|
+
file: string;
|
|
88
|
+
name: string;
|
|
89
|
+
reason: string;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Each component name a template gives in `exampleFor` or `componentsUsed`
|
|
94
|
+
* that could not be judged. Present when the manifest loads. A name neither
|
|
95
|
+
* the package nor Core has, and the template does not import, is an
|
|
96
|
+
* `unknown_block_component` note beside the issues, with its fix in the
|
|
97
|
+
* message (it becomes a warning in the next minor release), so `findings` is
|
|
98
|
+
* always empty;
|
|
99
|
+
* `unchecked` lists each name that cannot be judged: one the template may
|
|
100
|
+
* reach through anything other than named imports and re-exports from
|
|
101
|
+
* Core, React, StyleX, local helpers or the package's own entry (an import from another
|
|
102
|
+
* package, a default or namespace import, an alias of or member read off an imported
|
|
103
|
+
* binding, require(), a dynamic import(), a local module this check cannot
|
|
104
|
+
* read), or, without Core installed, any name Core would have to resolve: `file` (the template doc, package-relative),
|
|
105
|
+
* `name`, and `reason`.
|
|
106
|
+
*/
|
|
107
|
+
export type BlockComponentsReport = {
|
|
108
|
+
status: "checked";
|
|
109
|
+
findings: [];
|
|
110
|
+
unchecked: Array<{
|
|
111
|
+
file: string;
|
|
112
|
+
name: string;
|
|
113
|
+
reason: string;
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
@@ -38,9 +38,19 @@
|
|
|
38
38
|
* "healthy" — the two are otherwise byte-identical.
|
|
39
39
|
* @typedef {object} ValidateIntegrationResponse
|
|
40
40
|
* @property {'integration.validate'} type
|
|
41
|
-
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport}} data
|
|
41
|
+
* @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport}} data
|
|
42
42
|
* `notes`: information beside the issues that fails nothing, such as
|
|
43
|
-
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed
|
|
43
|
+
* `invalid_cli_command`, a `cliCommand` that was ignored as malformed, and
|
|
44
|
+
* the package layout findings added after the last minor release, each with
|
|
45
|
+
* its fix in the message: two docs for one component
|
|
46
|
+
* (`duplicate_component_doc`), a root reached through a symlink
|
|
47
|
+
* (`symlinked_root`), a contribution file that cannot be read
|
|
48
|
+
* (`unreadable_file`), a package.json without `name` or `version`
|
|
49
|
+
* (`invalid_package_json`), no provider ID (`no_provider_id`), and a doc
|
|
50
|
+
* whose file name differs from its source only in letter case where the two
|
|
51
|
+
* still pair (`source_without_component_doc`); and `doc_name_mismatch` and
|
|
52
|
+
* `unknown_block_component` (see `docNames` and `blockComponents`); they
|
|
53
|
+
* become warnings in the next minor release
|
|
44
54
|
*/
|
|
45
55
|
|
|
46
56
|
/**
|
|
@@ -54,4 +64,36 @@
|
|
|
54
64
|
* components or docs root, which those readers skip) were not checked
|
|
55
65
|
*/
|
|
56
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Each component doc whose `name` differs from the name it is listed under,
|
|
69
|
+
* judged against its source. Present when the manifest loads. A name the
|
|
70
|
+
* module its printed import names provably does not export is a
|
|
71
|
+
* `doc_name_mismatch` note beside the issues, with its fix in the message
|
|
72
|
+
* (it becomes a warning in the next minor release), so `findings` is always
|
|
73
|
+
* empty; `unchecked` lists each doc whose source's
|
|
74
|
+
* exports could not all be read (a re-export from another package, `export
|
|
75
|
+
* =`, a destructured binding, a namespace): `file` (the doc, package-relative),
|
|
76
|
+
* `name` (what the doc says), and `reason`.
|
|
77
|
+
*
|
|
78
|
+
* @typedef {{status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}} DocNamesReport
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Each component name a template gives in `exampleFor` or `componentsUsed`
|
|
83
|
+
* that could not be judged. Present when the manifest loads. A name neither
|
|
84
|
+
* the package nor Core has, and the template does not import, is an
|
|
85
|
+
* `unknown_block_component` note beside the issues, with its fix in the
|
|
86
|
+
* message (it becomes a warning in the next minor release), so `findings` is
|
|
87
|
+
* always empty;
|
|
88
|
+
* `unchecked` lists each name that cannot be judged: one the template may
|
|
89
|
+
* reach through anything other than named imports and re-exports from
|
|
90
|
+
* Core, React, StyleX, local helpers or the package's own entry (an import from another
|
|
91
|
+
* package, a default or namespace import, an alias of or member read off an imported
|
|
92
|
+
* binding, require(), a dynamic import(), a local module this check cannot
|
|
93
|
+
* read), or, without Core installed, any name Core would have to resolve: `file` (the template doc, package-relative),
|
|
94
|
+
* `name`, and `reason`.
|
|
95
|
+
*
|
|
96
|
+
* @typedef {{status: 'checked', findings: [], unchecked: Array<{file: string, name: string, reason: string}>}} BlockComponentsReport
|
|
97
|
+
*/
|
|
98
|
+
|
|
57
99
|
export {};
|
|
@@ -62,7 +62,7 @@ export const doc = {
|
|
|
62
62
|
{
|
|
63
63
|
type: 'integration.validate',
|
|
64
64
|
description:
|
|
65
|
-
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked.',
|
|
65
|
+
'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed, and the package layout findings added after the last minor release, each with its fix in the message: `duplicate_component_doc`, `symlinked_root`, `unreadable_file`, `invalid_package_json` (no `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.docNames` lists the component doc names it could not judge: `status` (`checked`), `findings` (always empty; a doc name the module its import names provably does not export is a `doc_name_mismatch` note, with its fix in the message) and `unchecked` ({file, name, reason}: a doc whose `name` differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, `data.blockComponents` lists the component names templates give in `exampleFor` or `componentsUsed` that could not be judged: `status` (`checked`), `findings` (always empty; a name neither the package nor Core has, and the template does not import, is an `unknown_block_component` note, with its fix in the message) and `unchecked` ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed).',
|
|
66
66
|
},
|
|
67
67
|
],
|
|
68
68
|
examples: [
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Search ordering data
|
|
2
|
+
|
|
3
|
+
`astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one.
|
|
4
|
+
|
|
5
|
+
## Rule
|
|
6
|
+
|
|
7
|
+
`spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block, in the lexical ranker's order, placed by the learned position of the block's first match: moving each one on its own breaks search's existing rules for tied matches. Matches never cross bands or kinds. There is no model runtime: every number is a plain static value read at load time.
|
|
8
|
+
|
|
9
|
+
## Files
|
|
10
|
+
|
|
11
|
+
| File | What it holds |
|
|
12
|
+
| ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `tree.weights.json` | The root classifier: for each query word or word pair, one number per class (component, hook, doc, template, theme, none). The query's tokens vote, and a topic searcher takes the query only when its class wins by the floor in `tree.mjs`. |
|
|
14
|
+
| `_main-searcher.weights.json`, `_doc-searcher.weights.json`, `_template-searcher.weights.json` | One weight, mean and spread per signal for each searcher (see `SIGNALS` and `PER_DOMAIN` in `_features.mjs`). A match's place inside its band is the weighted sum of its standardized signals. |
|
|
15
|
+
| `_cards.json` | One card per Core component and hook: what it is, the words people use for it, and its main props, written from the item's own source. Cards feed one signal, word overlap with the card. |
|
|
16
|
+
|
|
17
|
+
The signals are counts over the query and each entry's own text: the lexical score and rank, BM25 over the entry's name, docs text and card, how many query words the entry covers, whether the query holds the entry's name, and the classifier's guess of the domain.
|
|
18
|
+
|
|
19
|
+
## Status
|
|
20
|
+
|
|
21
|
+
These files are static and reviewed. They are not computed when the CLI runs, and nothing at run time writes them.
|
|
22
|
+
|
|
23
|
+
## Refreshing
|
|
24
|
+
|
|
25
|
+
- A Core component or hook without a card is still matched and scored as usual; inside its band it is ordered by its other signals.
|
|
26
|
+
- When Core adds or renames items, a reviewed change adds or updates their cards and, if needed, refreshed weights.
|
|
27
|
+
- Any refresh must keep every test that pins search's behavior passing, including the ordering invariants in `_order.test.mjs`. It must also keep the `astryx search` output's matches, scores and reasons identical to the lexical ranker's.
|
|
28
|
+
- Any refresh must also be measured as `spec:AST-083` FR6 requires: against the held-out, fresh and synthetic evaluation sets, with no row worse than the previous order (a row is worse when the paired 95% confidence interval of its change lies entirely below zero).
|
|
@@ -1,11 +1,75 @@
|
|
|
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
|
+
/** @typedef {import('./_lexical.mjs').Candidate} Candidate */
|
|
4
5
|
/**
|
|
5
6
|
* The Core a typed search reads: the project's, else the release's own,
|
|
6
|
-
* installed into the per-user cache first when needed
|
|
7
|
-
* requireCoreDir does.
|
|
7
|
+
* installed into the per-user cache first when needed (a network install and
|
|
8
|
+
* an npm subprocess; spec AST-081 FR3). Throws as requireCoreDir does.
|
|
8
9
|
* @param {string} cwd
|
|
9
10
|
* @returns {string}
|
|
10
11
|
*/
|
|
11
12
|
export function requireSearchCoreDir(cwd: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Gathers every candidate the query's domains hold.
|
|
15
|
+
*
|
|
16
|
+
* @param {{cwd?: string, type?: string}} options
|
|
17
|
+
* @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null}>}
|
|
18
|
+
*/
|
|
19
|
+
export function gatherCandidates(options: {
|
|
20
|
+
cwd?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
all: Candidate[];
|
|
24
|
+
components: Candidate[];
|
|
25
|
+
searchedComponents: boolean;
|
|
26
|
+
outside: boolean;
|
|
27
|
+
coreSkipped: string | null;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* The search tree's static data, read once: the entry cards and each node's
|
|
31
|
+
* weights file.
|
|
32
|
+
*
|
|
33
|
+
* These files are static, reviewed data that only order matches inside a score
|
|
34
|
+
* band; ORDERING.md beside them says what each holds and how
|
|
35
|
+
* they are refreshed.
|
|
36
|
+
* @returns {SearchData}
|
|
37
|
+
*/
|
|
38
|
+
export function loadSearchData(): SearchData;
|
|
39
|
+
export { componentKeywords } from "./_gather-components.mjs";
|
|
40
|
+
export type Candidate = import("./_lexical.mjs").Candidate;
|
|
41
|
+
export type SearcherWeights = {
|
|
42
|
+
w: number[];
|
|
43
|
+
mu: number[];
|
|
44
|
+
sd: number[];
|
|
45
|
+
};
|
|
46
|
+
export type SearchData = {
|
|
47
|
+
/**
|
|
48
|
+
* Each Core component's and hook's source-built card: what it is, the words
|
|
49
|
+
* people type for it, its main props.
|
|
50
|
+
*/
|
|
51
|
+
cards: Record<string, {
|
|
52
|
+
what?: string;
|
|
53
|
+
synonyms?: string[];
|
|
54
|
+
props?: string[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* The root classifier's weights.
|
|
58
|
+
*/
|
|
59
|
+
router: import("../../foundation/route/route.mjs").ClassifierWeights;
|
|
60
|
+
/**
|
|
61
|
+
* The main searcher's weights.
|
|
62
|
+
*/
|
|
63
|
+
main: SearcherWeights;
|
|
64
|
+
/**
|
|
65
|
+
* The doc searcher's weights.
|
|
66
|
+
*/
|
|
67
|
+
doc: SearcherWeights;
|
|
68
|
+
/**
|
|
69
|
+
* The template searcher's weights.
|
|
70
|
+
*/
|
|
71
|
+
template: SearcherWeights;
|
|
72
|
+
};
|
|
73
|
+
export type SearchCatalog = Awaited<ReturnType<typeof gatherCandidates>> & {
|
|
74
|
+
data: SearchData;
|
|
75
|
+
};
|