@astryxdesign/cli 0.7.3-canary.f8fad28 → 0.7.3-canary.fba04ed
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/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -20
- package/api/build/blocks/blocks.mjs +472 -196
- package/api/build/blocks/blocks.test.mjs +185 -168
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +4 -1
- package/api/build/kit/answer.mjs +11 -3
- package/api/build/kit/signals.d.mts +11 -0
- package/api/build/kit/signals.mjs +8 -7
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +27 -27
- package/api/component/_adapter.mjs +39 -5
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.mjs +4 -0
- package/api/doctor/_adapter.d.mts +33 -13
- package/api/doctor/_adapter.mjs +55 -25
- package/api/doctor/doctor.d.mts +23 -5
- package/api/doctor/doctor.mjs +81 -16
- package/api/doctor/doctor.test.mjs +58 -0
- package/api/integration/validate-integration-gaps.test.mjs +3 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/template/template.mjs +5 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/outside-project.test.mjs +99 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/index.mjs +25 -8
- package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +5 -5
- package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +135 -8
- package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
- package/foundation/integrations/public-imports.d.mts +37 -0
- package/foundation/integrations/public-imports.mjs +839 -46
- package/foundation/integrations/public-imports.test.mjs +971 -46
- package/foundation/release/cache.test.mjs +24 -21
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
package/api/build/build.type.mjs
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
* @property {boolean} data.directMatch True when the top page template is a confident direct match.
|
|
78
78
|
* @property {BuildStart | null} data.start The page template to start from: the ranker's pick, else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
|
|
79
79
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
|
|
80
|
-
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5).
|
|
80
|
+
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
|
|
81
81
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
|
|
82
82
|
* @property {string[]} data.frame Always-on page-shell component names. Every page template already uses them.
|
|
83
83
|
* @property {string[]} data.foundation Always-on layout/typography/action component names. Every page template already uses them.
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
12
12
|
* @param {string[]} [blocks] block names; build's own when omitted
|
|
13
|
+
* @param {Map<string, import('../../search/search.type.mjs').SearchResultEntry>} [picked]
|
|
14
|
+
* the block picker's own entry (its real score and reason) for each named
|
|
15
|
+
* block search did not return
|
|
13
16
|
* @returns {import('../build.type.mjs').BuildKitResponse}
|
|
14
17
|
*/
|
|
15
|
-
export function kitAnswer(signals: import("./signals.mjs").KitSignals, blocks?: string[]): import("../build.type.mjs").BuildKitResponse;
|
|
18
|
+
export function kitAnswer(signals: import("./signals.mjs").KitSignals, blocks?: string[], picked?: Map<string, import("../../search/search.type.mjs").SearchResultEntry>): import("../build.type.mjs").BuildKitResponse;
|
package/api/build/kit/answer.mjs
CHANGED
|
@@ -32,9 +32,16 @@ const THIN_KIT = 3;
|
|
|
32
32
|
*
|
|
33
33
|
* @param {import('./signals.mjs').KitSignals} signals
|
|
34
34
|
* @param {string[]} [blocks] block names; build's own when omitted
|
|
35
|
+
* @param {Map<string, import('../../search/search.type.mjs').SearchResultEntry>} [picked]
|
|
36
|
+
* the block picker's own entry (its real score and reason) for each named
|
|
37
|
+
* block search did not return
|
|
35
38
|
* @returns {import('../build.type.mjs').BuildKitResponse}
|
|
36
39
|
*/
|
|
37
|
-
export function kitAnswer(
|
|
40
|
+
export function kitAnswer(
|
|
41
|
+
signals,
|
|
42
|
+
blocks = signals.kitBlocks,
|
|
43
|
+
picked = new Map(),
|
|
44
|
+
) {
|
|
38
45
|
// Entries by name, in build's order: two packages can ship a block with the
|
|
39
46
|
// same name, and each name in `blocks` takes the next entry of that name, so
|
|
40
47
|
// both stay listed.
|
|
@@ -48,11 +55,12 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
|
|
|
48
55
|
.flatMap(name => {
|
|
49
56
|
const entry = own.get(name)?.shift();
|
|
50
57
|
if (entry) return [entry];
|
|
51
|
-
// A block build does not name itself keeps search's own entry, once
|
|
58
|
+
// A block build does not name itself keeps search's own entry, once;
|
|
59
|
+
// one search did not return keeps the picker's entry.
|
|
52
60
|
const found =
|
|
53
61
|
own.has(name) || added.has(name)
|
|
54
62
|
? undefined
|
|
55
|
-
: signals.searchedEntries.get(name);
|
|
63
|
+
: (signals.searchedEntries.get(name) ?? picked.get(name));
|
|
56
64
|
if (!found) return [];
|
|
57
65
|
added.add(name);
|
|
58
66
|
return [found];
|
|
@@ -65,4 +65,15 @@ export type KitSignals = {
|
|
|
65
65
|
* the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
66
66
|
*/
|
|
67
67
|
foreign: string[];
|
|
68
|
+
/**
|
|
69
|
+
* every block the project can scaffold
|
|
70
|
+
*/
|
|
71
|
+
catalog: import("../_adapter.mjs").BlockTemplate[];
|
|
72
|
+
/**
|
|
73
|
+
* every component, with its keywords
|
|
74
|
+
*/
|
|
75
|
+
components: {
|
|
76
|
+
name: string;
|
|
77
|
+
keywords?: string[];
|
|
78
|
+
}[];
|
|
68
79
|
};
|
|
@@ -103,6 +103,8 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
|
103
103
|
* @property {Map<string, SearchResultEntry>} searchedEntries search's entry for each of those blocks (the first of a name)
|
|
104
104
|
* @property {Map<string, string>} blockText each of those blocks' display name and description, from the catalog
|
|
105
105
|
* @property {string[]} foreign the blocks, named, searched or scaffoldable, whose package is not Core's
|
|
106
|
+
* @property {import('../_adapter.mjs').BlockTemplate[]} catalog every block the project can scaffold
|
|
107
|
+
* @property {{name: string, keywords?: string[]}[]} components every component, with its keywords
|
|
106
108
|
*/
|
|
107
109
|
|
|
108
110
|
/**
|
|
@@ -232,13 +234,10 @@ export async function kitSignals(query, options = {}) {
|
|
|
232
234
|
// A part of a page starts where it lives (spec:AST-048/FR3); the project's
|
|
233
235
|
// own components say what a part is. The search above already gathered them
|
|
234
236
|
// unless it was narrowed to templates.
|
|
235
|
-
const
|
|
236
|
-
?
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
searchedComponents(result) ?? (await loadComponents(cwd)),
|
|
240
|
-
)
|
|
241
|
-
: 'page';
|
|
237
|
+
const components = wantsPages
|
|
238
|
+
? (searchedComponents(result) ?? (await loadComponents(cwd)))
|
|
239
|
+
: [];
|
|
240
|
+
const kind = wantsPages ? ideaKind(query, catalog, components) : 'page';
|
|
242
241
|
const chosen = wantsPages
|
|
243
242
|
? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
|
|
244
243
|
: null;
|
|
@@ -283,6 +282,8 @@ export async function kitSignals(query, options = {}) {
|
|
|
283
282
|
.filter(b => searchedBlocks.some(r => r.name === b.name))
|
|
284
283
|
.map(b => [b.name, `${b.displayName} ${b.description}`]),
|
|
285
284
|
),
|
|
285
|
+
catalog: templates.blocks,
|
|
286
|
+
components,
|
|
286
287
|
foreign: [
|
|
287
288
|
...new Set(
|
|
288
289
|
[...blocksKept, ...searchedBlocks, ...templates.blocks]
|
package/api/build/tree.mjs
CHANGED
|
@@ -35,7 +35,8 @@ const main = defineSearcher({
|
|
|
35
35
|
run: async (request, ctx) => {
|
|
36
36
|
const signals = await kitSignals(request.query, request.options);
|
|
37
37
|
if (!ctx.blocks) return kitAnswer(signals);
|
|
38
|
-
|
|
38
|
+
const picked = pickBlocks(request.query, signals, ctx.blocks);
|
|
39
|
+
return kitAnswer(signals, picked.names, picked.entries);
|
|
39
40
|
},
|
|
40
41
|
});
|
|
41
42
|
|
package/api/build/tree.test.mjs
CHANGED
|
@@ -60,55 +60,55 @@ const PINNED = [
|
|
|
60
60
|
'analytics dashboard with a KPI row and a sortable table',
|
|
61
61
|
[
|
|
62
62
|
'TableSortableTable',
|
|
63
|
-
'TableRichCellTable',
|
|
64
|
-
'TableBulkActionsTable',
|
|
65
63
|
'TableGridDividersTable',
|
|
66
|
-
'
|
|
64
|
+
'TableShowcase',
|
|
65
|
+
'TableGroupedRowsTable',
|
|
66
|
+
'TableStripedTable',
|
|
67
67
|
],
|
|
68
68
|
],
|
|
69
69
|
[
|
|
70
70
|
'settings page with notification toggles and a save bar',
|
|
71
71
|
[
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
72
|
+
'SwitchShowcase',
|
|
73
|
+
'SwitchSettingsPanel',
|
|
74
|
+
'ToggleButtonShowcase',
|
|
75
|
+
'ToggleButtonStates',
|
|
76
|
+
'SwitchWithDescription',
|
|
77
77
|
],
|
|
78
78
|
],
|
|
79
79
|
[
|
|
80
80
|
'empty state for a question bank with an import button',
|
|
81
81
|
[
|
|
82
|
-
'EmptyStateActions',
|
|
83
|
-
'EmptyStateCompact',
|
|
84
82
|
'EmptyStateContainer',
|
|
85
83
|
'EmptyStateShowcase',
|
|
86
|
-
'
|
|
84
|
+
'EmptyStateCompact',
|
|
85
|
+
'EmptyStateActions',
|
|
86
|
+
'CommandPaletteEmptyShowcase',
|
|
87
87
|
],
|
|
88
88
|
],
|
|
89
89
|
[
|
|
90
90
|
'login form with single sign-on buttons',
|
|
91
91
|
[
|
|
92
|
-
'
|
|
92
|
+
'ButtonWithIcon',
|
|
93
93
|
'CardWithInnerLayout',
|
|
94
|
-
'
|
|
95
|
-
'
|
|
96
|
-
'
|
|
94
|
+
'ButtonVariants',
|
|
95
|
+
'FormLayoutShowcase',
|
|
96
|
+
'FormLayoutMixedControls',
|
|
97
97
|
],
|
|
98
98
|
],
|
|
99
99
|
[
|
|
100
100
|
'calendar for booking appointments',
|
|
101
101
|
[
|
|
102
|
-
'CalendarRangeWithValue',
|
|
103
102
|
'CalendarSingle',
|
|
104
|
-
'CalendarTwoMonths',
|
|
105
|
-
'CalendarConstraints',
|
|
106
103
|
'CalendarShowcase',
|
|
104
|
+
'CalendarConstraints',
|
|
105
|
+
'CalendarRangeWithValue',
|
|
106
|
+
'CalendarTwoMonths',
|
|
107
107
|
],
|
|
108
108
|
],
|
|
109
109
|
[
|
|
110
110
|
'kanban board for sprint tasks with a filter bar',
|
|
111
|
-
['ToolbarTableFilter', '
|
|
111
|
+
['ToolbarTableFilter', 'PowerSearchShowcase'],
|
|
112
112
|
],
|
|
113
113
|
];
|
|
114
114
|
|
|
@@ -125,16 +125,15 @@ afterAll(() => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
describe('build tree', () => {
|
|
128
|
-
it('keeps
|
|
129
|
-
const phrase = 'calendar for booking appointments';
|
|
128
|
+
it('keeps a block the request names by its exact name in build’s slot', async () => {
|
|
129
|
+
const phrase = 'calendar for booking appointments with CalendarTwoMonths';
|
|
130
130
|
const answer = await build(phrase, {cwd: REPO});
|
|
131
131
|
const own = await withListingCache(() => buildKit(phrase, {cwd: REPO}));
|
|
132
132
|
if (answer?.type !== 'build.kit' || own.type !== 'build.kit')
|
|
133
133
|
throw new Error('expected a kit');
|
|
134
|
-
own.data.blocks.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
134
|
+
const k = own.data.blocks.findIndex(b => b.name === 'CalendarTwoMonths');
|
|
135
|
+
expect(k).toBeGreaterThanOrEqual(0);
|
|
136
|
+
expect(answer.data.blocks[k].name).toBe('CalendarTwoMonths');
|
|
138
137
|
});
|
|
139
138
|
|
|
140
139
|
it('runs with the network and subprocesses blocked', async () => {
|
|
@@ -166,8 +165,9 @@ describe('build tree', () => {
|
|
|
166
165
|
expect(answer.data.start?.alternatives).toEqual(
|
|
167
166
|
own.data.start?.alternatives,
|
|
168
167
|
);
|
|
169
|
-
// Every block is build's own entry
|
|
170
|
-
// score and reason; never more blocks than
|
|
168
|
+
// Every block is build's own entry, one search returned, or the picker's
|
|
169
|
+
// own, each with its real score and reason; never more blocks than
|
|
170
|
+
// build's own.
|
|
171
171
|
expect(answer.data.blocks.length).toBe(own.data.blocks.length);
|
|
172
172
|
for (const b of answer.data.blocks) {
|
|
173
173
|
expect(b.score).toBeGreaterThan(0);
|
|
@@ -44,6 +44,10 @@ import {Project} from '../../foundation/config/project.mjs';
|
|
|
44
44
|
import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
|
|
45
45
|
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
46
46
|
import {searchComponents} from '../../foundation/text/string-utils.mjs';
|
|
47
|
+
import {
|
|
48
|
+
rankComponentSuggestions,
|
|
49
|
+
synonymMatches,
|
|
50
|
+
} from '../../foundation/text/suggest-order.mjs';
|
|
47
51
|
import {AstryxError, coreDirOrThrow} from '../error.mjs';
|
|
48
52
|
import {
|
|
49
53
|
componentLinkProvider,
|
|
@@ -51,6 +55,28 @@ import {
|
|
|
51
55
|
loadDocsCatalog,
|
|
52
56
|
} from '../docs/_adapter.mjs';
|
|
53
57
|
|
|
58
|
+
/** @type {Record<string, {synonyms?: string[]}> | undefined} */
|
|
59
|
+
let cards;
|
|
60
|
+
/**
|
|
61
|
+
* Search's component cards (each component's other names), read once.
|
|
62
|
+
* @returns {Record<string, {synonyms?: string[]}>}
|
|
63
|
+
*/
|
|
64
|
+
function searchCards() {
|
|
65
|
+
if (!cards) {
|
|
66
|
+
try {
|
|
67
|
+
cards = JSON.parse(
|
|
68
|
+
fs.readFileSync(
|
|
69
|
+
new URL('../search/_cards.json', import.meta.url),
|
|
70
|
+
'utf8',
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
} catch {
|
|
74
|
+
cards = {};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return /** @type {Record<string, {synonyms?: string[]}>} */ (cards);
|
|
78
|
+
}
|
|
79
|
+
|
|
54
80
|
export {CORE_PACKAGE, unscopedComponentOwners};
|
|
55
81
|
|
|
56
82
|
/**
|
|
@@ -463,12 +489,20 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
463
489
|
resolvedOwnerPackage = CORE_PACKAGE;
|
|
464
490
|
resolvedSourcePath = findComponentSource(coreDir, resolvedName);
|
|
465
491
|
} else {
|
|
492
|
+
// How many to suggest: the near-top results, at most five and at
|
|
493
|
+
// least two. Which ones, and in what order, is the suggestion
|
|
494
|
+
// ranking's call.
|
|
466
495
|
const threshold = Math.max(topScore - 20, 1);
|
|
467
|
-
const
|
|
468
|
-
.filter(r => r.score >= threshold)
|
|
469
|
-
.
|
|
470
|
-
|
|
471
|
-
|
|
496
|
+
const count = Math.max(
|
|
497
|
+
results.filter(r => r.score >= threshold).slice(0, 5).length,
|
|
498
|
+
Math.min(2, results.length),
|
|
499
|
+
);
|
|
500
|
+
const candidates = rankComponentSuggestions(
|
|
501
|
+
dirName,
|
|
502
|
+
results,
|
|
503
|
+
Object.values(components).flat(),
|
|
504
|
+
synonymMatches(dirName, searchCards()),
|
|
505
|
+
).slice(0, count);
|
|
472
506
|
throw new AstryxError(
|
|
473
507
|
`No component named "${name}"`,
|
|
474
508
|
candidates.map(c => ({name: c.name, reason: c.reason})),
|
|
@@ -43,12 +43,11 @@ export function hasSources(project: Project | undefined): boolean;
|
|
|
43
43
|
* @param {Project | undefined} project
|
|
44
44
|
* @param {Array<{name: string}>} installed
|
|
45
45
|
* @param {Set<string>} declared
|
|
46
|
-
* @param {(name: string, version?: string) => string} add
|
|
47
46
|
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
48
47
|
*/
|
|
49
48
|
export function computerAvailableEntries(project: Project | undefined, installed: Array<{
|
|
50
49
|
name: string;
|
|
51
|
-
}>, declared: Set<string
|
|
50
|
+
}>, declared: Set<string>): Promise<import("./discover.type.mjs").DiscoverAvailableEntry[]>;
|
|
52
51
|
/**
|
|
53
52
|
* Package names the project's package.json declares in any dependency field.
|
|
54
53
|
* @param {Project | undefined} project
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
availableComputerIntegrations,
|
|
26
26
|
} from '../../foundation/config/project.mjs';
|
|
27
27
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
28
|
+
import {projectAddCommand} from '../../foundation/release/notices.mjs';
|
|
28
29
|
import {hostedRun} from '../../foundation/runtime/package-root.mjs';
|
|
29
30
|
import {
|
|
30
31
|
scanAllPackages,
|
|
@@ -274,17 +275,14 @@ const COMPUTER_SOURCE = 'installed for this computer';
|
|
|
274
275
|
* @param {Project | undefined} project
|
|
275
276
|
* @param {Array<{name: string}>} installed
|
|
276
277
|
* @param {Set<string>} declared
|
|
277
|
-
* @param {(name: string, version?: string) => string} add
|
|
278
278
|
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
279
279
|
*/
|
|
280
|
-
export async function computerAvailableEntries(
|
|
281
|
-
project,
|
|
282
|
-
installed,
|
|
283
|
-
declared,
|
|
284
|
-
add,
|
|
285
|
-
) {
|
|
280
|
+
export async function computerAvailableEntries(project, installed, declared) {
|
|
286
281
|
const cwd = project?.cwd ?? process.cwd();
|
|
287
282
|
if (isOutsideProject(cwd)) return [];
|
|
283
|
+
// The same command doctor names: in the project spec:AST-040 FR9 defines,
|
|
284
|
+
// and none where FR9 finds no project.
|
|
285
|
+
const add = projectAddCommand(cwd);
|
|
288
286
|
const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
|
|
289
287
|
return (await availableComputerIntegrations(cwd, have)).map(c => ({
|
|
290
288
|
name: c.name,
|
|
@@ -292,7 +290,7 @@ export async function computerAvailableEntries(
|
|
|
292
290
|
...(c.version ? {version: c.version} : {}),
|
|
293
291
|
...(c.description ? {description: c.description} : {}),
|
|
294
292
|
source: COMPUTER_SOURCE,
|
|
295
|
-
install: add(c.name),
|
|
293
|
+
...(add ? {install: add(c.name)} : {}),
|
|
296
294
|
}));
|
|
297
295
|
}
|
|
298
296
|
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
72
72
|
import {AstryxError} from '../error.mjs';
|
|
73
73
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
74
|
+
import {orderRouteSuggestions} from '../../foundation/text/suggest-order.mjs';
|
|
74
75
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
75
76
|
|
|
76
77
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
@@ -1622,6 +1623,9 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1622
1623
|
...catalog.names().map(name => ({name, reason: 'available topic'})),
|
|
1623
1624
|
];
|
|
1624
1625
|
}
|
|
1626
|
+
if (typeof topic === 'string') {
|
|
1627
|
+
suggestions = orderRouteSuggestions(topic, suggestions);
|
|
1628
|
+
}
|
|
1625
1629
|
// A route that moved names where it went, ahead of the usual suggestions
|
|
1626
1630
|
// (spec:AST-046 FR9, FR6).
|
|
1627
1631
|
const moved = movedRoute(topic, tree);
|
|
@@ -64,8 +64,11 @@ export function computerIntegrationsOutside(cwd: string): Promise<{
|
|
|
64
64
|
*/
|
|
65
65
|
export function computerIntegrationsToAdd(cwd: string, loadedNames: string[]): Promise<import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[]>;
|
|
66
66
|
/**
|
|
67
|
-
* The computer-level agent text's setting
|
|
68
|
-
*
|
|
67
|
+
* The computer-level agent text's setting, its state on disk, and the command
|
|
68
|
+
* the skill file tells agents to run and the install step it records for when
|
|
69
|
+
* that command is not found (each null when there is no file, or it names
|
|
70
|
+
* none).
|
|
71
|
+
* @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>, command: string | null, install: string | null}}
|
|
69
72
|
*/
|
|
70
73
|
export function computerAgentTextState(): {
|
|
71
74
|
settings: import("../../foundation/env/user-settings.mjs").ComputerAgentTextSettings;
|
|
@@ -74,6 +77,8 @@ export function computerAgentTextState(): {
|
|
|
74
77
|
state: import("../../foundation/agent-docs/computer-agent-text.mjs").ComputerAgentTextState;
|
|
75
78
|
link?: true;
|
|
76
79
|
}>;
|
|
80
|
+
command: string | null;
|
|
81
|
+
install: string | null;
|
|
77
82
|
};
|
|
78
83
|
/**
|
|
79
84
|
* The release facts doctor reports, read here so the checks stay pure
|
|
@@ -83,7 +88,7 @@ export function computerAgentTextState(): {
|
|
|
83
88
|
* command that upgrades it.
|
|
84
89
|
* @param {string} cwd
|
|
85
90
|
* @param {{project: boolean}} options
|
|
86
|
-
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
|
|
91
|
+
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null, runner: boolean}>}}
|
|
87
92
|
*/
|
|
88
93
|
export function releaseFacts(cwd: string, { project }: {
|
|
89
94
|
project: boolean;
|
|
@@ -101,6 +106,7 @@ export function releaseFacts(cwd: string, { project }: {
|
|
|
101
106
|
stateLock: ReturnType<typeof stateLockHolder>;
|
|
102
107
|
searchPathCommands: Array<import("../../foundation/env/search-path.mjs").SearchPathCommand & {
|
|
103
108
|
upgrade: string | null;
|
|
109
|
+
runner: boolean;
|
|
104
110
|
}>;
|
|
105
111
|
};
|
|
106
112
|
/** Whether `cwd` is outside every project. */
|
|
@@ -108,13 +114,14 @@ export function outsideProject(cwd: string): boolean;
|
|
|
108
114
|
/**
|
|
109
115
|
* The commands that bring a project's own CLI and Core to one release, with
|
|
110
116
|
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
111
|
-
* the CLI is newer; else the CLI to the Core's release.
|
|
117
|
+
* the CLI is newer; else the CLI to the Core's release. Null when no
|
|
118
|
+
* command fits (see `alignCliAndCore`).
|
|
112
119
|
* @param {string} cwd
|
|
113
120
|
* @param {string} cli
|
|
114
121
|
* @param {string} core
|
|
115
|
-
* @returns {string}
|
|
122
|
+
* @returns {string | null}
|
|
116
123
|
*/
|
|
117
|
-
export function alignCommand(cwd: string, cli: string, core: string): string;
|
|
124
|
+
export function alignCommand(cwd: string, cli: string, core: string): string | null;
|
|
118
125
|
/**
|
|
119
126
|
* The Core release the project at `cwd` names: installed, else locked, else
|
|
120
127
|
* declared; the version the daily hint and notice compare against (spec
|
|
@@ -131,19 +138,32 @@ export function projectCoreVersion(cwd: string): string | null;
|
|
|
131
138
|
export function projectHasOwnCli(cwd: string): boolean;
|
|
132
139
|
/**
|
|
133
140
|
* The command that adds the CLI at `version` with the project's package
|
|
134
|
-
* manager.
|
|
141
|
+
* manager, and the Core it matches: from a folder whose package.json declares
|
|
142
|
+
* no Astryx package, in the Astryx project above at that project's Core; null
|
|
143
|
+
* when there is none (see `cliInstallAdvice`).
|
|
135
144
|
* @param {string} cwd
|
|
136
145
|
* @param {string} version
|
|
137
|
-
* @returns {string}
|
|
146
|
+
* @returns {{command: string, core: string} | null}
|
|
138
147
|
*/
|
|
139
|
-
export function addCliCommandFor(cwd: string, version: string):
|
|
148
|
+
export function addCliCommandFor(cwd: string, version: string): {
|
|
149
|
+
command: string;
|
|
150
|
+
core: string;
|
|
151
|
+
} | null;
|
|
140
152
|
/**
|
|
141
|
-
* The command that adds a package
|
|
142
|
-
*
|
|
153
|
+
* The command that adds a package to the project of `cwd`; null in a folder
|
|
154
|
+
* that belongs to no project or whose package.json is not the project's (see
|
|
155
|
+
* `projectAddCommand`).
|
|
143
156
|
* @param {string} cwd
|
|
144
|
-
* @returns {(name: string) => string}
|
|
157
|
+
* @returns {((name: string) => string) | null}
|
|
158
|
+
*/
|
|
159
|
+
export function installCommandFor(cwd: string): ((name: string) => string) | null;
|
|
160
|
+
/**
|
|
161
|
+
* Whether `cwd` is inside a project whose package.json is not the project's,
|
|
162
|
+
* so advice points at the project's folder (see `installFolder`).
|
|
163
|
+
* @param {string} cwd
|
|
164
|
+
* @returns {boolean}
|
|
145
165
|
*/
|
|
146
|
-
export function
|
|
166
|
+
export function insideProjectElsewhere(cwd: string): boolean;
|
|
147
167
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
|
148
168
|
export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
|
|
149
169
|
export const SOURCE_EXTENSIONS: Set<string>;
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
stateLockHolder,
|
|
11
11
|
} from '../../foundation/release/global-state.mjs';
|
|
12
12
|
import {
|
|
13
|
-
addCliCommand,
|
|
14
13
|
alignCliAndCore,
|
|
14
|
+
cliInstallAdvice,
|
|
15
|
+
installFolder,
|
|
16
|
+
projectAddCommand,
|
|
15
17
|
globalBehind,
|
|
16
18
|
globalUpgradeCommand,
|
|
17
19
|
lastNoticeSkip,
|
|
@@ -19,16 +21,18 @@ import {
|
|
|
19
21
|
} from '../../foundation/release/notices.mjs';
|
|
20
22
|
import {
|
|
21
23
|
coreVersionOf,
|
|
24
|
+
installPlaceOf,
|
|
22
25
|
isGlobalCopy,
|
|
23
|
-
projectRootOf,
|
|
24
26
|
} from '../../foundation/release/choose.mjs';
|
|
25
27
|
import {readReleaseFacts} from '../../foundation/release/project.mjs';
|
|
26
|
-
import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
|
|
27
28
|
import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
28
29
|
import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
|
|
29
30
|
import {
|
|
31
|
+
computerSkillFile,
|
|
30
32
|
displayHomePath,
|
|
31
33
|
inspectComputerAgentText,
|
|
34
|
+
skillCommandOf,
|
|
35
|
+
skillInstallStepOf,
|
|
32
36
|
} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
33
37
|
import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
|
|
34
38
|
import * as fs from 'node:fs';
|
|
@@ -291,12 +295,29 @@ function declaredPackageNames(cwd) {
|
|
|
291
295
|
}
|
|
292
296
|
|
|
293
297
|
/**
|
|
294
|
-
* The computer-level agent text's setting
|
|
295
|
-
*
|
|
298
|
+
* The computer-level agent text's setting, its state on disk, and the command
|
|
299
|
+
* the skill file tells agents to run and the install step it records for when
|
|
300
|
+
* that command is not found (each null when there is no file, or it names
|
|
301
|
+
* none).
|
|
302
|
+
* @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>, command: string | null, install: string | null}}
|
|
296
303
|
*/
|
|
297
304
|
export function computerAgentTextState() {
|
|
298
305
|
const settings = computerAgentTextSettings();
|
|
299
|
-
|
|
306
|
+
let command = null;
|
|
307
|
+
let install = null;
|
|
308
|
+
try {
|
|
309
|
+
const text = fs.readFileSync(computerSkillFile(), 'utf8');
|
|
310
|
+
command = skillCommandOf(text);
|
|
311
|
+
install = skillInstallStepOf(text);
|
|
312
|
+
} catch {
|
|
313
|
+
// No skill file, or one that cannot be read: no command to check.
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
settings,
|
|
317
|
+
entries: inspectComputerAgentText({links: settings.links}),
|
|
318
|
+
command,
|
|
319
|
+
install,
|
|
320
|
+
};
|
|
300
321
|
}
|
|
301
322
|
|
|
302
323
|
export {displayHomePath};
|
|
@@ -309,7 +330,7 @@ export {displayHomePath};
|
|
|
309
330
|
* command that upgrades it.
|
|
310
331
|
* @param {string} cwd
|
|
311
332
|
* @param {{project: boolean}} options
|
|
312
|
-
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
|
|
333
|
+
* @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null, runner: boolean}>}}
|
|
313
334
|
*/
|
|
314
335
|
export function releaseFacts(cwd, {project}) {
|
|
315
336
|
const answered = answeredBy(cwd);
|
|
@@ -336,6 +357,9 @@ export function releaseFacts(cwd, {project}) {
|
|
|
336
357
|
searchPathCommands: astryxCommandsOnSearchPath().map(row => ({
|
|
337
358
|
...row,
|
|
338
359
|
upgrade: row.cliRoot ? globalUpgradeCommand(row.cliRoot) : null,
|
|
360
|
+
// A package runner's temporary install, which it puts first on the
|
|
361
|
+
// search path only for the run it starts.
|
|
362
|
+
runner: row.cliRoot ? installPlaceOf(row.cliRoot).runner : false,
|
|
339
363
|
})),
|
|
340
364
|
};
|
|
341
365
|
}
|
|
@@ -348,11 +372,12 @@ export function outsideProject(/** @type {string} */ cwd) {
|
|
|
348
372
|
/**
|
|
349
373
|
* The commands that bring a project's own CLI and Core to one release, with
|
|
350
374
|
* the project's package manager: Core up to the CLI, then its codemods, when
|
|
351
|
-
* the CLI is newer; else the CLI to the Core's release.
|
|
375
|
+
* the CLI is newer; else the CLI to the Core's release. Null when no
|
|
376
|
+
* command fits (see `alignCliAndCore`).
|
|
352
377
|
* @param {string} cwd
|
|
353
378
|
* @param {string} cli
|
|
354
379
|
* @param {string} core
|
|
355
|
-
* @returns {string}
|
|
380
|
+
* @returns {string | null}
|
|
356
381
|
*/
|
|
357
382
|
export function alignCommand(cwd, cli, core) {
|
|
358
383
|
return alignCliAndCore({cwd, cli, core});
|
|
@@ -380,30 +405,35 @@ export function projectHasOwnCli(cwd) {
|
|
|
380
405
|
|
|
381
406
|
/**
|
|
382
407
|
* The command that adds the CLI at `version` with the project's package
|
|
383
|
-
* manager.
|
|
408
|
+
* manager, and the Core it matches: from a folder whose package.json declares
|
|
409
|
+
* no Astryx package, in the Astryx project above at that project's Core; null
|
|
410
|
+
* when there is none (see `cliInstallAdvice`).
|
|
384
411
|
* @param {string} cwd
|
|
385
412
|
* @param {string} version
|
|
386
|
-
* @returns {string}
|
|
413
|
+
* @returns {{command: string, core: string} | null}
|
|
387
414
|
*/
|
|
388
415
|
export function addCliCommandFor(cwd, version) {
|
|
389
|
-
|
|
416
|
+
const advice = cliInstallAdvice({cwd, core: version});
|
|
417
|
+
return advice?.command ? {command: advice.command, core: advice.core} : null;
|
|
390
418
|
}
|
|
391
419
|
|
|
392
420
|
/**
|
|
393
|
-
* The command that adds a package
|
|
394
|
-
*
|
|
421
|
+
* The command that adds a package to the project of `cwd`; null in a folder
|
|
422
|
+
* that belongs to no project or whose package.json is not the project's (see
|
|
423
|
+
* `projectAddCommand`).
|
|
395
424
|
* @param {string} cwd
|
|
396
|
-
* @returns {(name: string) => string}
|
|
425
|
+
* @returns {((name: string) => string) | null}
|
|
397
426
|
*/
|
|
398
427
|
export function installCommandFor(cwd) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
428
|
+
return projectAddCommand(cwd);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Whether `cwd` is inside a project whose package.json is not the project's,
|
|
433
|
+
* so advice points at the project's folder (see `installFolder`).
|
|
434
|
+
* @param {string} cwd
|
|
435
|
+
* @returns {boolean}
|
|
436
|
+
*/
|
|
437
|
+
export function insideProjectElsewhere(cwd) {
|
|
438
|
+
return installFolder(cwd)?.moved === true;
|
|
409
439
|
}
|