@astryxdesign/cli 0.7.2 → 0.7.3-canary.06872b4
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/component/component.mjs +16 -2
- package/api/component/component.test.mjs +15 -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/doctor/doctor.test.mjs +28 -3
- 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 +123 -4
- package/api/integration/pack-check.test.mjs +87 -0
- package/api/integration/validate-integration-case-disk.test.mjs +111 -0
- package/api/integration/validate-integration-gaps.test.mjs +1964 -0
- package/api/integration/validate-integration.d.mts +11 -2
- package/api/integration/validate-integration.mjs +226 -32
- package/api/integration/validate-integration.type.d.mts +58 -1
- package/api/integration/validate-integration.type.mjs +45 -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 +57 -9
- package/api/upgrade/_adapter.mjs +198 -28
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.test.mjs +194 -0
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- 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/is-my-code-good.doc.mjs +287 -0
- package/assets/docs/tree/api.doc.mjs +6 -0
- package/assets/docs/tree/host-entry.doc.mjs +128 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +16 -37
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +6 -2
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -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/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -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 +20 -22
- package/foundation/config/project.test.mjs +56 -0
- 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/discovery/template-adapter.mjs +18 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/doc-compiler/doc-loads.test.mjs +8 -0
- package/foundation/doc-compiler/read.mjs +59 -1
- package/foundation/doc-compiler/read.test.mjs +11 -2
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +556 -38
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- 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 +27 -1
- package/foundation/integrations/integrations.mjs +61 -2
- package/foundation/integrations/validate-contributions.d.mts +115 -0
- package/foundation/integrations/validate-contributions.mjs +1168 -13
- 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
|
@@ -18,7 +18,12 @@ export type SearchResultEntry = {
|
|
|
18
18
|
*/
|
|
19
19
|
name: string;
|
|
20
20
|
/**
|
|
21
|
-
* -
|
|
21
|
+
* - How strongly the query matched this entry (higher is
|
|
22
|
+
* stronger). Search keeps the lexical ranker's order between score bands,
|
|
23
|
+
* including its domain priority, which can place a weaker non-doc match above
|
|
24
|
+
* a stronger doc; within a run of one score band and kind it orders matches
|
|
25
|
+
* by its static ordering weights, so a lower score can lead inside a band.
|
|
26
|
+
* Build's `blocks` use their own order.
|
|
22
27
|
*/
|
|
23
28
|
score: number;
|
|
24
29
|
/**
|
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
* @typedef {object} SearchResultEntry
|
|
18
18
|
* @property {SearchDomain} domain - Which content domain this result came from.
|
|
19
19
|
* @property {string} name - Primary identifier (component/hook name, doc topic or docs-tree route, template dir, theme slug).
|
|
20
|
-
* @property {number} score -
|
|
20
|
+
* @property {number} score - How strongly the query matched this entry (higher is
|
|
21
|
+
* stronger). Search keeps the lexical ranker's order between score bands,
|
|
22
|
+
* including its domain priority, which can place a weaker non-doc match above
|
|
23
|
+
* a stronger doc; within a run of one score band and kind it orders matches
|
|
24
|
+
* by its static ordering weights, so a lower score can lead inside a band.
|
|
25
|
+
* Build's `blocks` use their own order.
|
|
21
26
|
* @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
|
|
22
27
|
* @property {string} description - One-line description, when available.
|
|
23
28
|
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme; `astryx theme eject neutral` outside a project).
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export const SEARCH_TREE: import("../../foundation/route/route.mjs").Tree<SearchRequest, import("./_adapter.mjs").SearchCatalog, import("./search.type.mjs").SearchResponse>;
|
|
5
|
+
export type SearchRequest = {
|
|
6
|
+
query: string;
|
|
7
|
+
options: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
type?: import("./search.type.mjs").SearchDomain;
|
|
10
|
+
limit?: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type SearchCatalog = import("./_adapter.mjs").SearchCatalog;
|
|
14
|
+
export type SearchAnswer = import("./search.type.mjs").SearchResponse;
|
|
15
|
+
export type SearchKit = import("../../foundation/route/route.mjs").RouteKit<SearchRequest, SearchCatalog, SearchAnswer>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file How search answers: a root classifier reads the query's words and
|
|
5
|
+
* guesses the domain it wants (tree.weights.json), and hands it to that
|
|
6
|
+
* domain's topic searcher when it is sure enough; otherwise the main searcher
|
|
7
|
+
* keeps it. Adding a topic searcher is one file and one line here.
|
|
8
|
+
* @input {query, options} and the gathered catalog with its static data
|
|
9
|
+
* @output the search response
|
|
10
|
+
* @position api/search; search.mjs runs it with the shared route helper
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {routeKit} from '../../foundation/route/route.mjs';
|
|
14
|
+
import {routerTokens} from './_query-words.mjs';
|
|
15
|
+
import {doc} from './_doc-searcher.mjs';
|
|
16
|
+
import {main} from './_main-searcher.mjs';
|
|
17
|
+
import {template} from './_template-searcher.mjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{query: string, options: {cwd?: string, type?: import('./search.type.mjs').SearchDomain, limit?: number}}} SearchRequest
|
|
21
|
+
* @typedef {import('./_adapter.mjs').SearchCatalog} SearchCatalog
|
|
22
|
+
* @typedef {import('./search.type.mjs').SearchResponse} SearchAnswer
|
|
23
|
+
* @typedef {import('../../foundation/route/route.mjs').RouteKit<SearchRequest, SearchCatalog, SearchAnswer>} SearchKit
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** @type {SearchKit} */
|
|
27
|
+
const {defineClassifier, defineTree} = routeKit;
|
|
28
|
+
|
|
29
|
+
const root = defineClassifier({
|
|
30
|
+
id: 'root',
|
|
31
|
+
summary:
|
|
32
|
+
'Guesses the domain a query wants from its words and hands it to that topic searcher, else to the main searcher.',
|
|
33
|
+
searchers: {doc: doc.id, template: template.id},
|
|
34
|
+
fallback: main.id,
|
|
35
|
+
floor: 0.4,
|
|
36
|
+
features: request => routerTokens(request.query),
|
|
37
|
+
weights: catalog => catalog.data.router,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const SEARCH_TREE = defineTree('root', [root, main, doc, template]);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Tests for the search tree's root dispatcher (tree.mjs): the router
|
|
5
|
+
* sends a query to the topic searcher of the domain it wants, and every other
|
|
6
|
+
* query to the main searcher. Run against the real @astryxdesign/core.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect} from 'vitest';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {runTree} from '../../foundation/route/route.mjs';
|
|
13
|
+
import {gatherCandidates, loadSearchData} from './_adapter.mjs';
|
|
14
|
+
import {routeProbs, ROUTES} from './_query-words.mjs';
|
|
15
|
+
import {SEARCH_TREE} from './tree.mjs';
|
|
16
|
+
|
|
17
|
+
const REPO = path.resolve(
|
|
18
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
19
|
+
'../../../..',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/** @param {string} query */
|
|
23
|
+
async function route(query) {
|
|
24
|
+
const catalog = {
|
|
25
|
+
...(await gatherCandidates({cwd: REPO})),
|
|
26
|
+
data: loadSearchData(),
|
|
27
|
+
};
|
|
28
|
+
/** @type {string[]} */
|
|
29
|
+
const steps = [];
|
|
30
|
+
const answer = await runTree(
|
|
31
|
+
SEARCH_TREE,
|
|
32
|
+
{query, options: {cwd: REPO}},
|
|
33
|
+
catalog,
|
|
34
|
+
{
|
|
35
|
+
tuning: {onTrace: e => steps.push(e.id)},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
return {steps, answer: /** @type {any} */ (answer)};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('search tree', () => {
|
|
42
|
+
it('sends a doc question to the doc searcher', async () => {
|
|
43
|
+
const {steps, answer} = await route('how do I install a theme');
|
|
44
|
+
expect(steps).toEqual(['root', 'doc']);
|
|
45
|
+
expect(answer.data.results[0].domain).toBe('doc');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('sends a page request to the template searcher', async () => {
|
|
49
|
+
const {steps, answer} = await route('page of settings with a side menu');
|
|
50
|
+
expect(steps).toEqual(['root', 'template']);
|
|
51
|
+
expect(
|
|
52
|
+
answer.data.results.slice(0, 3).map((/** @type {any} */ r) => r.name),
|
|
53
|
+
).toContain('settings');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('sends a component query to the main searcher', async () => {
|
|
57
|
+
const {steps} = await route('date chooser');
|
|
58
|
+
expect(steps).toEqual(['root', 'main']);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('gives one probability per class that sums to one', () => {
|
|
62
|
+
const p = routeProbs(loadSearchData().router, 'toast notice');
|
|
63
|
+
expect(p).toHaveLength(ROUTES.length);
|
|
64
|
+
expect(p.reduce((a, b) => a + b, 0)).toBeCloseTo(1, 12);
|
|
65
|
+
});
|
|
66
|
+
});
|