@astryxdesign/cli 0.7.3-canary.296edaf → 0.7.3-canary.2f47a4a
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/doctor/_adapter.d.mts +9 -3
- package/api/doctor/_adapter.mjs +32 -5
- package/api/doctor/doctor.d.mts +16 -1
- package/api/doctor/doctor.mjs +29 -2
- 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/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/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +119 -7
- package/foundation/agent-docs/computer-agent-text.test.mjs +76 -0
- package/foundation/release/cache.test.mjs +24 -21
- 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);
|
|
@@ -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. */
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -19,13 +19,20 @@ import {
|
|
|
19
19
|
lastNoticeSkip,
|
|
20
20
|
projectLag,
|
|
21
21
|
} from '../../foundation/release/notices.mjs';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
coreVersionOf,
|
|
24
|
+
installPlaceOf,
|
|
25
|
+
isGlobalCopy,
|
|
26
|
+
} from '../../foundation/release/choose.mjs';
|
|
23
27
|
import {readReleaseFacts} from '../../foundation/release/project.mjs';
|
|
24
28
|
import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
25
29
|
import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
|
|
26
30
|
import {
|
|
31
|
+
computerSkillFile,
|
|
27
32
|
displayHomePath,
|
|
28
33
|
inspectComputerAgentText,
|
|
34
|
+
skillCommandOf,
|
|
35
|
+
skillInstallStepOf,
|
|
29
36
|
} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
30
37
|
import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
|
|
31
38
|
import * as fs from 'node:fs';
|
|
@@ -288,12 +295,29 @@ function declaredPackageNames(cwd) {
|
|
|
288
295
|
}
|
|
289
296
|
|
|
290
297
|
/**
|
|
291
|
-
* The computer-level agent text's setting
|
|
292
|
-
*
|
|
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}}
|
|
293
303
|
*/
|
|
294
304
|
export function computerAgentTextState() {
|
|
295
305
|
const settings = computerAgentTextSettings();
|
|
296
|
-
|
|
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
|
+
};
|
|
297
321
|
}
|
|
298
322
|
|
|
299
323
|
export {displayHomePath};
|
|
@@ -306,7 +330,7 @@ export {displayHomePath};
|
|
|
306
330
|
* command that upgrades it.
|
|
307
331
|
* @param {string} cwd
|
|
308
332
|
* @param {{project: boolean}} options
|
|
309
|
-
* @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}>}}
|
|
310
334
|
*/
|
|
311
335
|
export function releaseFacts(cwd, {project}) {
|
|
312
336
|
const answered = answeredBy(cwd);
|
|
@@ -333,6 +357,9 @@ export function releaseFacts(cwd, {project}) {
|
|
|
333
357
|
searchPathCommands: astryxCommandsOnSearchPath().map(row => ({
|
|
334
358
|
...row,
|
|
335
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,
|
|
336
363
|
})),
|
|
337
364
|
};
|
|
338
365
|
}
|
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -188,6 +188,10 @@ export function checkCliCommand(ctx: DoctorContext): DoctorCheck;
|
|
|
188
188
|
* each file of the computer-level agent text against this release's rendering
|
|
189
189
|
* @property {import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings} [agentTextSettings]
|
|
190
190
|
* the person's choices about the computer-level agent text
|
|
191
|
+
* @property {string | null} [agentTextCommand] the command the skill file
|
|
192
|
+
* tells agents to run, or null
|
|
193
|
+
* @property {string | null} [agentTextInstall] the install step the skill
|
|
194
|
+
* file records for when that command is not found, or null
|
|
191
195
|
* @property {string} [cwd] the folder doctor runs in, for the printed fix
|
|
192
196
|
* @property {import('../../foundation/release/notices.mjs').GlobalBehind | null} [globalBehind]
|
|
193
197
|
* the CLI installed for the computer, when it is older than the newest
|
|
@@ -200,7 +204,7 @@ export function checkCliCommand(ctx: DoctorContext): DoctorCheck;
|
|
|
200
204
|
* the newest update notice that did not print, and why (diagnostic only)
|
|
201
205
|
* @property {{pid: number | null, host: string | null, since: number} | null} [stateLock]
|
|
202
206
|
* who holds the state file's lock now (diagnostic only)
|
|
203
|
-
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null}>} [searchPathCommands]
|
|
207
|
+
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null, runner?: boolean}>} [searchPathCommands]
|
|
204
208
|
* every `astryx` on the search path, with the command that upgrades it
|
|
205
209
|
* the `astryx` commands on the search path, in order
|
|
206
210
|
* @property {import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]} [computerIntegrations]
|
|
@@ -446,6 +450,16 @@ export type ComputerContext = {
|
|
|
446
450
|
* the person's choices about the computer-level agent text
|
|
447
451
|
*/
|
|
448
452
|
agentTextSettings?: import("../../foundation/env/user-settings.mjs").ComputerAgentTextSettings | undefined;
|
|
453
|
+
/**
|
|
454
|
+
* the command the skill file
|
|
455
|
+
* tells agents to run, or null
|
|
456
|
+
*/
|
|
457
|
+
agentTextCommand?: string | null | undefined;
|
|
458
|
+
/**
|
|
459
|
+
* the install step the skill
|
|
460
|
+
* file records for when that command is not found, or null
|
|
461
|
+
*/
|
|
462
|
+
agentTextInstall?: string | null | undefined;
|
|
449
463
|
/**
|
|
450
464
|
* the folder doctor runs in, for the printed fix
|
|
451
465
|
*/
|
|
@@ -487,6 +501,7 @@ export type ComputerContext = {
|
|
|
487
501
|
*/
|
|
488
502
|
searchPathCommands?: (import("../../foundation/env/search-path.mjs").SearchPathCommand & {
|
|
489
503
|
upgrade?: string | null;
|
|
504
|
+
runner?: boolean;
|
|
490
505
|
})[] | undefined;
|
|
491
506
|
/**
|
|
492
507
|
* the integrations installed beside the running CLI
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -66,6 +66,7 @@ import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
|
66
66
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
67
67
|
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
68
68
|
import {availableLine, RUN_FROM_PROJECT, upgradeLine} from '../../foundation/release/notices.mjs';
|
|
69
|
+
import {COMPUTER_COMMAND, COMPUTER_INSTALL_STEP} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
69
70
|
import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, insideProjectElsewhere, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
|
|
70
71
|
|
|
71
72
|
/**
|
|
@@ -1491,6 +1492,10 @@ export function checkCliCommand(ctx) {
|
|
|
1491
1492
|
* each file of the computer-level agent text against this release's rendering
|
|
1492
1493
|
* @property {import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings} [agentTextSettings]
|
|
1493
1494
|
* the person's choices about the computer-level agent text
|
|
1495
|
+
* @property {string | null} [agentTextCommand] the command the skill file
|
|
1496
|
+
* tells agents to run, or null
|
|
1497
|
+
* @property {string | null} [agentTextInstall] the install step the skill
|
|
1498
|
+
* file records for when that command is not found, or null
|
|
1494
1499
|
* @property {string} [cwd] the folder doctor runs in, for the printed fix
|
|
1495
1500
|
* @property {import('../../foundation/release/notices.mjs').GlobalBehind | null} [globalBehind]
|
|
1496
1501
|
* the CLI installed for the computer, when it is older than the newest
|
|
@@ -1503,7 +1508,7 @@ export function checkCliCommand(ctx) {
|
|
|
1503
1508
|
* the newest update notice that did not print, and why (diagnostic only)
|
|
1504
1509
|
* @property {{pid: number | null, host: string | null, since: number} | null} [stateLock]
|
|
1505
1510
|
* who holds the state file's lock now (diagnostic only)
|
|
1506
|
-
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null}>} [searchPathCommands]
|
|
1511
|
+
* @property {Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade?: string | null, runner?: boolean}>} [searchPathCommands]
|
|
1507
1512
|
* every `astryx` on the search path, with the command that upgrades it
|
|
1508
1513
|
* the `astryx` commands on the search path, in order
|
|
1509
1514
|
* @property {import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]} [computerIntegrations]
|
|
@@ -1714,6 +1719,8 @@ export function checkComputerAgentText(ctx) {
|
|
|
1714
1719
|
};
|
|
1715
1720
|
}
|
|
1716
1721
|
const entries = ctx.agentText ?? /** @type {NonNullable<typeof state>} */ (state).entries;
|
|
1722
|
+
const command = ctx.agentText ? (ctx.agentTextCommand ?? null) : /** @type {NonNullable<typeof state>} */ (state).command;
|
|
1723
|
+
const recorded = (ctx.agentText ? ctx.agentTextInstall : /** @type {NonNullable<typeof state>} */ (state).install) ?? null;
|
|
1717
1724
|
const fix = `Run \`${formatCliCommand('astryx init --user', ctx.cwd)}\`.`;
|
|
1718
1725
|
const [file, ...links] = entries;
|
|
1719
1726
|
const home = (/** @type {{path: string}} */ e) => displayHomePath(e.path);
|
|
@@ -1742,9 +1749,29 @@ export function checkComputerAgentText(ctx) {
|
|
|
1742
1749
|
};
|
|
1743
1750
|
}
|
|
1744
1751
|
const current = file.state === 'current';
|
|
1752
|
+
const status = `${current ? 'The computer-level agent text matches this release' : "The computer-level agent text differs from this release's"}: ${home(file)}.`;
|
|
1753
|
+
// The skill outlives the CLI it names when the home folder outlasts the
|
|
1754
|
+
// folder the CLI is installed in, as on a machine whose system folders
|
|
1755
|
+
// reset on restart. Reported only when no `astryx` command is on the search
|
|
1756
|
+
// path at all, apart from a package runner's own copy, which it puts first
|
|
1757
|
+
// only for the run it starts (the way back when the global CLI is gone).
|
|
1758
|
+
// Any other `astryx`, even one the scan cannot trace to the package, such
|
|
1759
|
+
// as the shim of Volta, asdf or mise, may well run the CLI, so doctor stays
|
|
1760
|
+
// quiet here and cli-on-path reports what it can; never a false "gone".
|
|
1761
|
+
// The reinstalled copy refreshes the text too.
|
|
1762
|
+
const rows = ctx.searchPathCommands;
|
|
1763
|
+
if (command === COMPUTER_COMMAND && rows && !rows.some(r => !r.runner)) {
|
|
1764
|
+
return {
|
|
1765
|
+
...base,
|
|
1766
|
+
message: `${status} It tells agents to run \`${COMPUTER_COMMAND}\`, but no \`${COMPUTER_COMMAND}\` command is on the search path, so agents that read it find no CLI to run (as when a restart removes the CLI installed for the computer and keeps the home folder).${linkNote}`,
|
|
1767
|
+
fix: recorded
|
|
1768
|
+
? `Run \`${recorded}\`, the step the skill names for when \`${COMPUTER_COMMAND}\` is not found.`
|
|
1769
|
+
: `Install it for the computer: \`${COMPUTER_INSTALL_STEP}\`.`,
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1745
1772
|
return {
|
|
1746
1773
|
...base,
|
|
1747
|
-
message: `${
|
|
1774
|
+
message: `${status}${linkNote}`,
|
|
1748
1775
|
...(!current || missing.length > 0 || dangling.length > 0 ? {fix} : {}),
|
|
1749
1776
|
};
|
|
1750
1777
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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 */
|
|
5
4
|
/**
|
|
6
5
|
* Build template candidates (page + block) from the template discovery API.
|
|
7
6
|
* @param {string} cwd
|
|
@@ -8,9 +8,31 @@ import {CORE_PACKAGE} from '../../foundation/discovery/component-discovery.mjs';
|
|
|
8
8
|
import {discoverTemplates, extractComponents} from '../template/template.mjs';
|
|
9
9
|
import {listAvailableThemes} from '../theme/_adapter.mjs';
|
|
10
10
|
import {templateLookupIds} from '../../foundation/discovery/template-adapter.mjs';
|
|
11
|
+
import {sameWord, wordsOf} from './_words.mjs';
|
|
11
12
|
|
|
12
13
|
/** @typedef {import('./_lexical.mjs').Candidate} Candidate */
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* A template's authored display name as another name and title of it, when the
|
|
17
|
+
* name stands for the template: two words or more that hold every word of the
|
|
18
|
+
* component the block shows (`exampleFor`), as "Rich Text Editor" does for
|
|
19
|
+
* RichTextEditor. A query that is the name then names the entry whole, and one
|
|
20
|
+
* that holds it as a phrase ("rich text") reaches search's title tier, above
|
|
21
|
+
* entries that match one of its words. A label of the variant alone ("Inside a
|
|
22
|
+
* card" for a Comments block) does not name the block, so it stays out.
|
|
23
|
+
* @param {{displayName?: string, exampleFor?: string}} t
|
|
24
|
+
* @returns {{aliases?: string[], titles?: string[]}}
|
|
25
|
+
*/
|
|
26
|
+
function subjectName(t) {
|
|
27
|
+
const name = String(t.displayName ?? '').trim();
|
|
28
|
+
const words = wordsOf(name);
|
|
29
|
+
const subject = wordsOf(String(t.exampleFor ?? ''));
|
|
30
|
+
if (words.length < 2 || subject.length === 0) return {};
|
|
31
|
+
return subject.every(s => words.some(w => sameWord(s, w)))
|
|
32
|
+
? {aliases: [name], titles: [name]}
|
|
33
|
+
: {};
|
|
34
|
+
}
|
|
35
|
+
|
|
14
36
|
/**
|
|
15
37
|
* Build template candidates (page + block) from the template discovery API.
|
|
16
38
|
* @param {string} cwd
|
|
@@ -67,6 +89,9 @@ export async function gatherTemplates(cwd) {
|
|
|
67
89
|
// as its prose does, not as a name: one of them matching one word of a
|
|
68
90
|
// short idea is not a direct match.
|
|
69
91
|
prose: t.keywords ?? [],
|
|
92
|
+
// A display name that names the block's subject is another name of it
|
|
93
|
+
// and its title (subjectName).
|
|
94
|
+
...subjectName(t),
|
|
70
95
|
_displayName: t.name,
|
|
71
96
|
_package: t.package ?? CORE_PACKAGE,
|
|
72
97
|
_kind: t.type, // 'page' | 'block'
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file An integration's own block answers a query that names it, though no
|
|
5
|
+
* learned table lists it: its authored display name is a title search reads,
|
|
6
|
+
* so "rich text editor" finds the rich text package's block first and build
|
|
7
|
+
* offers it, while a variant label that does not name the block (Lab's "Inside
|
|
8
|
+
* a card") captures nothing.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import {fileURLToPath} from 'node:url';
|
|
15
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
16
|
+
import {search} from './search.mjs';
|
|
17
|
+
import {build} from '../build/build.mjs';
|
|
18
|
+
|
|
19
|
+
const SLOW = 60_000;
|
|
20
|
+
const packages = path.resolve(
|
|
21
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
22
|
+
'../../..',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
describe('an integration block found by its display name', () => {
|
|
26
|
+
/** @type {string} */
|
|
27
|
+
let dir;
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-integration-block-'));
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
path.join(dir, 'package.json'),
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
name: 'consumer',
|
|
34
|
+
dependencies: {
|
|
35
|
+
'@astryxdesign/core': '*',
|
|
36
|
+
'@astryxdesign/richtext': '*',
|
|
37
|
+
'@astryxdesign/lab': '*',
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
const scope = path.join(dir, 'node_modules', '@astryxdesign');
|
|
42
|
+
fs.mkdirSync(scope, {recursive: true});
|
|
43
|
+
for (const name of ['core', 'richtext', 'lab'])
|
|
44
|
+
fs.symlinkSync(path.join(packages, name), path.join(scope, name), 'dir');
|
|
45
|
+
});
|
|
46
|
+
afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
47
|
+
|
|
48
|
+
it.each(['rich text editor', 'rich text', 'text editor'])(
|
|
49
|
+
'`%s` ranks the rich text block first among templates',
|
|
50
|
+
async query => {
|
|
51
|
+
const {results} = (await search(query, {cwd: dir, type: 'template'}))
|
|
52
|
+
.data;
|
|
53
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
54
|
+
name: 'RichTextEditorShowcase',
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
SLOW,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
it(
|
|
61
|
+
'a whole display name names the block outright',
|
|
62
|
+
async () => {
|
|
63
|
+
const {results} = (
|
|
64
|
+
await search('rich text editor', {cwd: dir, type: 'template'})
|
|
65
|
+
).data;
|
|
66
|
+
expect(results[0]).toMatchObject({
|
|
67
|
+
name: 'RichTextEditorShowcase',
|
|
68
|
+
reason: 'exact name',
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
SLOW,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
it(
|
|
75
|
+
"a variant label that does not name the block's subject is no title",
|
|
76
|
+
async () => {
|
|
77
|
+
const {results} = (
|
|
78
|
+
await search('table inside a card', {cwd: dir, type: 'template'})
|
|
79
|
+
).data;
|
|
80
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
81
|
+
name: 'TableInCard',
|
|
82
|
+
});
|
|
83
|
+
const kit = (await build('a settings form inside a card', {cwd: dir}))
|
|
84
|
+
.data;
|
|
85
|
+
expect(kit.blocks[0]?.name).not.toBe('CommentsInCard');
|
|
86
|
+
},
|
|
87
|
+
SLOW,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
it(
|
|
91
|
+
'build offers the rich text block for a request that names it',
|
|
92
|
+
async () => {
|
|
93
|
+
const kit = (
|
|
94
|
+
await build('a comment box with a rich text editor', {cwd: dir})
|
|
95
|
+
).data;
|
|
96
|
+
expect(kit.blocks.map(b => b.name)).toContain('RichTextEditorShowcase');
|
|
97
|
+
},
|
|
98
|
+
SLOW,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
@@ -24,6 +24,9 @@ export const docs = {
|
|
|
24
24
|
'docker',
|
|
25
25
|
'read-only home',
|
|
26
26
|
'cache the release cache',
|
|
27
|
+
'agent machine',
|
|
28
|
+
'restart',
|
|
29
|
+
'ephemeral machine',
|
|
27
30
|
],
|
|
28
31
|
description:
|
|
29
32
|
"What Astryx does in CI and containers: no update checks or notices, the project's version as always, and how to cache versions or work with a read-only home folder.",
|
|
@@ -74,6 +77,16 @@ export const docs = {
|
|
|
74
77
|
},
|
|
75
78
|
],
|
|
76
79
|
},
|
|
80
|
+
{
|
|
81
|
+
id: 'short-lived',
|
|
82
|
+
title: 'Machines that keep only the home folder',
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'prose',
|
|
86
|
+
text: 'Some agent machines keep the home folder across restarts but not system folders. A global install there disappears on restart while the agent guide in the home folder stays, so agents are told to run a global astryx command that is gone; the guide says to run the command that installed the CLI, such as `npm i -g @astryxdesign/cli`, when that command is not found, and `astryx doctor` names the same step. To keep the CLI across restarts, install it into a folder in your home and put its `bin` folder on your PATH, as for a permission error ({@link generic:install-once}), or run that command when the machine starts.',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
77
90
|
{
|
|
78
91
|
id: 'more',
|
|
79
92
|
title: 'More on global mode',
|
|
@@ -21,7 +21,7 @@ export const doc = {
|
|
|
21
21
|
"the docs the CLI reads, the newest release the computer knows of, with the install and upgrade commands when the project's release is older, and every `astryx` command on the search path, warning when the first one is not the Astryx CLI or predates the hand-off. It writes nothing, but loading astryx.config runs that file's code. " +
|
|
22
22
|
'The `integration` subcommands provide authoring checks for one integration package. ' +
|
|
23
23
|
'Outside a project it checks the computer instead: the Node version, the release that answered, ' +
|
|
24
|
-
|
|
24
|
+
"the newest release this computer knows of, with the command that upgrades the CLI installed for the computer when it is older, the astryx commands on the search path, the integrations installed for the computer (warning about one it skips), and whether the computer-level agent text (`astryx init --user`) is present, matches this release, was edited, or is turned off (info only); when that text names `astryx` and no `astryx` command is on the search path, apart from a package runner's own copy, it says so and names the install step the text records, or npm's when it records none. " +
|
|
25
25
|
'It never fails a check because the folder has no project.',
|
|
26
26
|
fn: 'doctor',
|
|
27
27
|
subcommands: ['integration'],
|