@astryxdesign/cli 0.7.3-canary.d421aed → 0.7.3-canary.da1020b
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/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
|
@@ -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'],
|
|
@@ -392,6 +392,97 @@ describe('doctor: the computer-level agent text', () => {
|
|
|
392
392
|
const A = '/home/me/.agents/skills/astryx/SKILL.md';
|
|
393
393
|
const C = '/home/me/.claude/skills/astryx';
|
|
394
394
|
|
|
395
|
+
it('a skill naming `astryx` with no Astryx CLI on the search path: says whether it is current, and names the step it records', () => {
|
|
396
|
+
const check = (/** @type {Record<string, any>} */ over) =>
|
|
397
|
+
checkComputerAgentText({
|
|
398
|
+
nodeVersion: '22.13.0',
|
|
399
|
+
answeredBy: {cli: '1.2.0', core: '1.2.0', copy: 'carried'},
|
|
400
|
+
latest: null,
|
|
401
|
+
agentText: [{path: A, state: 'current'}],
|
|
402
|
+
agentTextCommand: 'astryx',
|
|
403
|
+
searchPathCommands: [],
|
|
404
|
+
cwd: os.tmpdir(),
|
|
405
|
+
...over,
|
|
406
|
+
});
|
|
407
|
+
const recorded = check({agentTextInstall: 'pnpm add -g @astryxdesign/cli'});
|
|
408
|
+
// A package runner's own copy first on the search path does not count.
|
|
409
|
+
expect(
|
|
410
|
+
check({
|
|
411
|
+
agentTextInstall: 'pnpm add -g @astryxdesign/cli',
|
|
412
|
+
searchPathCommands: [
|
|
413
|
+
/** @type {any} */ ({
|
|
414
|
+
file: '/tmp/_npx/r/node_modules/.bin/astryx',
|
|
415
|
+
astryx: true,
|
|
416
|
+
runner: true,
|
|
417
|
+
}),
|
|
418
|
+
],
|
|
419
|
+
}).fix,
|
|
420
|
+
).toBe(
|
|
421
|
+
'Run `pnpm add -g @astryxdesign/cli`, the step the skill names for when `astryx` is not found.',
|
|
422
|
+
);
|
|
423
|
+
expect(recorded.status).toBe('info');
|
|
424
|
+
expect(recorded.message).toContain(
|
|
425
|
+
`The computer-level agent text matches this release: ${A}. It tells agents to run \`astryx\`, but no \`astryx\` command is on the search path`,
|
|
426
|
+
);
|
|
427
|
+
expect(recorded.fix).toBe(
|
|
428
|
+
'Run `pnpm add -g @astryxdesign/cli`, the step the skill names for when `astryx` is not found.',
|
|
429
|
+
);
|
|
430
|
+
// A skill from an earlier release records no step: npm's, worded as
|
|
431
|
+
// cli-on-path words it.
|
|
432
|
+
const older = check({
|
|
433
|
+
agentText: [{path: A, state: 'differs'}],
|
|
434
|
+
agentTextInstall: null,
|
|
435
|
+
});
|
|
436
|
+
expect(older.message).toContain(
|
|
437
|
+
"The computer-level agent text differs from this release's",
|
|
438
|
+
);
|
|
439
|
+
expect(older.fix).toBe(
|
|
440
|
+
'Install it for the computer: `npm i -g @astryxdesign/cli`.',
|
|
441
|
+
);
|
|
442
|
+
// With the Astryx CLI anywhere on the search path, even behind another
|
|
443
|
+
// program (cli-on-path's to report), or a skill naming a host's command,
|
|
444
|
+
// there is nothing to restore.
|
|
445
|
+
for (const over of [
|
|
446
|
+
{
|
|
447
|
+
searchPathCommands: [
|
|
448
|
+
/** @type {any} */ ({
|
|
449
|
+
file: '/usr/bin/astryx',
|
|
450
|
+
astryx: true,
|
|
451
|
+
version: '1.2.0',
|
|
452
|
+
}),
|
|
453
|
+
],
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
searchPathCommands: [
|
|
457
|
+
/** @type {any} */ ({file: '/opt/other/astryx', astryx: false}),
|
|
458
|
+
/** @type {any} */ ({
|
|
459
|
+
file: '/usr/bin/astryx',
|
|
460
|
+
astryx: true,
|
|
461
|
+
version: '1.2.0',
|
|
462
|
+
}),
|
|
463
|
+
],
|
|
464
|
+
},
|
|
465
|
+
{agentTextCommand: 'acme astryx'},
|
|
466
|
+
// An `astryx` the scan cannot trace (a Volta, asdf or mise shim, or
|
|
467
|
+
// another program): it may run the CLI, so no report here.
|
|
468
|
+
{
|
|
469
|
+
searchPathCommands: [
|
|
470
|
+
/** @type {any} */ ({
|
|
471
|
+
file: '/home/me/.volta/bin/astryx',
|
|
472
|
+
astryx: false,
|
|
473
|
+
runner: false,
|
|
474
|
+
}),
|
|
475
|
+
],
|
|
476
|
+
},
|
|
477
|
+
// Only a package runner's own copy: the CLI is still gone.
|
|
478
|
+
]) {
|
|
479
|
+
const other = check(over);
|
|
480
|
+
expect(other.message).toBe(
|
|
481
|
+
`The computer-level agent text matches this release: ${A}.`,
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
395
486
|
it('present and current, linked: no fix', () => {
|
|
396
487
|
const check = at([
|
|
397
488
|
{path: A, state: 'current'},
|
|
@@ -460,6 +551,14 @@ describe('doctor: the computer-level agent text', () => {
|
|
|
460
551
|
const home = tmpDir('home');
|
|
461
552
|
vi.stubEnv('HOME', home);
|
|
462
553
|
vi.stubEnv('USERPROFILE', home);
|
|
554
|
+
// The CLI installed for the computer, first on the search path, as the
|
|
555
|
+
// skill expects.
|
|
556
|
+
const bin = tmpDir('bin');
|
|
557
|
+
fs.symlinkSync(
|
|
558
|
+
path.join(CLI_ROOT, 'clients', 'cli', 'bin', 'astryx.mjs'),
|
|
559
|
+
path.join(bin, 'astryx'),
|
|
560
|
+
);
|
|
561
|
+
vi.stubEnv('PATH', `${bin}${path.delimiter}${process.env.PATH ?? ''}`);
|
|
463
562
|
try {
|
|
464
563
|
const find = r =>
|
|
465
564
|
r.envelope.data.checks.find(c => c.id === 'computer-agent-text');
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* What to do when the `astryx` command the text names is not found, as on a
|
|
6
|
+
* machine whose home folder outlives its system folders: the skill file
|
|
7
|
+
* survives a restart while the CLI installed for the computer does not.
|
|
8
|
+
* @param {string} install the install step
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
export function computerRestoreLine(install: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The install step the text names. `judge`: the step a file is judged by, the
|
|
14
|
+
* one it records first, so every copy of one release, two global installs
|
|
15
|
+
* included, finds the same text current. `write`: the step a write records,
|
|
16
|
+
* the global copy's own first, since only the CLI installed for the computer
|
|
17
|
+
* chooses it. Either way npm's when there is no other.
|
|
18
|
+
* @param {{cliRoot?: string, home?: string, for?: 'judge' | 'write'}} [options]
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function computerInstallStep({ cliRoot, home, for: use, }?: {
|
|
22
|
+
cliRoot?: string;
|
|
23
|
+
home?: string;
|
|
24
|
+
for?: "judge" | "write";
|
|
25
|
+
}): string;
|
|
26
|
+
/**
|
|
27
|
+
* The install step a skill file's text records, or null when it records
|
|
28
|
+
* none.
|
|
29
|
+
* @param {string} content
|
|
30
|
+
* @returns {string | null}
|
|
31
|
+
*/
|
|
32
|
+
export function skillInstallStepOf(content: string): string | null;
|
|
4
33
|
/**
|
|
5
34
|
* A home-folder path as a person reads it: `~/.claude/skills/astryx`.
|
|
6
35
|
* @param {string} file
|
|
@@ -32,13 +61,21 @@ export function computerSkillLinks(home?: string): Array<{
|
|
|
32
61
|
* @returns {string}
|
|
33
62
|
*/
|
|
34
63
|
export function computerAgentCommand(): string;
|
|
64
|
+
/**
|
|
65
|
+
* The command a skill file's text names: the one in its "Start with" line,
|
|
66
|
+
* or null when the text has none.
|
|
67
|
+
* @param {string} content
|
|
68
|
+
* @returns {string | null}
|
|
69
|
+
*/
|
|
70
|
+
export function skillCommandOf(content: string): string | null;
|
|
35
71
|
/**
|
|
36
72
|
* The full skill file.
|
|
37
|
-
* @param {{command?: string}} [options]
|
|
73
|
+
* @param {{command?: string, install?: string}} [options]
|
|
38
74
|
* @returns {string}
|
|
39
75
|
*/
|
|
40
|
-
export function renderComputerAgentText({ command, }?: {
|
|
76
|
+
export function renderComputerAgentText({ command, install, }?: {
|
|
41
77
|
command?: string;
|
|
78
|
+
install?: string;
|
|
42
79
|
}): string;
|
|
43
80
|
/**
|
|
44
81
|
* Read-only: the state of the skill file against this release's rendering,
|
|
@@ -43,6 +43,10 @@ import {createHash} from 'node:crypto';
|
|
|
43
43
|
import {cliDoor} from '../env/cli-command.mjs';
|
|
44
44
|
import {astryxCommandsOnSearchPath} from '../env/search-path.mjs';
|
|
45
45
|
import {samePath} from '../fs/path-compare.mjs';
|
|
46
|
+
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
47
|
+
import {CLI_PACKAGE} from '../env/package-manager.mjs';
|
|
48
|
+
import {isGlobalCopy} from '../release/choose.mjs';
|
|
49
|
+
import {globalUpgradeCommand} from '../release/notices.mjs';
|
|
46
50
|
import {
|
|
47
51
|
MARKER_START,
|
|
48
52
|
MARKER_END,
|
|
@@ -57,6 +61,83 @@ export const COMPUTER_COMMAND = 'astryx';
|
|
|
57
61
|
/** The install step for the CLI copy the computer-level text relies on. */
|
|
58
62
|
export const COMPUTER_INSTALL_STEP = 'npm i -g @astryxdesign/cli';
|
|
59
63
|
|
|
64
|
+
/**
|
|
65
|
+
* What to do when the `astryx` command the text names is not found, as on a
|
|
66
|
+
* machine whose home folder outlives its system folders: the skill file
|
|
67
|
+
* survives a restart while the CLI installed for the computer does not.
|
|
68
|
+
* @param {string} install the install step
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
export function computerRestoreLine(install) {
|
|
72
|
+
return `If \`${COMPUTER_COMMAND}\` is not found, run \`${install}\` first.`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The step the CLI installed for the computer names for itself: the command
|
|
77
|
+
* that installs it again with the same package manager into the same folder,
|
|
78
|
+
* as the update notice names it but with no version. Null for any other copy.
|
|
79
|
+
* @param {string} [cliRoot]
|
|
80
|
+
* @returns {string | null}
|
|
81
|
+
*/
|
|
82
|
+
function ownInstallStep(cliRoot = CLI_ROOT) {
|
|
83
|
+
try {
|
|
84
|
+
if (isGlobalCopy(cliRoot)) {
|
|
85
|
+
return globalUpgradeCommand(cliRoot).replace(
|
|
86
|
+
`${CLI_PACKAGE}@latest`,
|
|
87
|
+
CLI_PACKAGE,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// A copy whose install cannot be read names none of its own.
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The step the skill file in `home` records, or null.
|
|
98
|
+
* @param {string} home
|
|
99
|
+
* @returns {string | null}
|
|
100
|
+
*/
|
|
101
|
+
function recordedInstallStep(home) {
|
|
102
|
+
try {
|
|
103
|
+
return skillInstallStepOf(fs.readFileSync(computerSkillFile(home), 'utf8'));
|
|
104
|
+
} catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The install step the text names. `judge`: the step a file is judged by, the
|
|
111
|
+
* one it records first, so every copy of one release, two global installs
|
|
112
|
+
* included, finds the same text current. `write`: the step a write records,
|
|
113
|
+
* the global copy's own first, since only the CLI installed for the computer
|
|
114
|
+
* chooses it. Either way npm's when there is no other.
|
|
115
|
+
* @param {{cliRoot?: string, home?: string, for?: 'judge' | 'write'}} [options]
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
export function computerInstallStep({
|
|
119
|
+
cliRoot = CLI_ROOT,
|
|
120
|
+
home = os.homedir(),
|
|
121
|
+
for: use = 'write',
|
|
122
|
+
} = {}) {
|
|
123
|
+
const own = ownInstallStep(cliRoot);
|
|
124
|
+
const recorded = recordedInstallStep(home);
|
|
125
|
+
return (
|
|
126
|
+
(use === 'judge' ? (recorded ?? own) : (own ?? recorded)) ??
|
|
127
|
+
COMPUTER_INSTALL_STEP
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The install step a skill file's text records, or null when it records
|
|
133
|
+
* none.
|
|
134
|
+
* @param {string} content
|
|
135
|
+
* @returns {string | null}
|
|
136
|
+
*/
|
|
137
|
+
export function skillInstallStepOf(content) {
|
|
138
|
+
return /is not found, run `(.+?)` first\./u.exec(content)?.[1] ?? null;
|
|
139
|
+
}
|
|
140
|
+
|
|
60
141
|
/** The skill folder, relative to the home folder, that holds the one file. */
|
|
61
142
|
const SKILL_FOLDER = path.join('.agents', 'skills', 'astryx');
|
|
62
143
|
|
|
@@ -170,11 +251,13 @@ export function computerAgentCommand() {
|
|
|
170
251
|
}
|
|
171
252
|
|
|
172
253
|
/**
|
|
173
|
-
* The body lines, with `run` as the command
|
|
254
|
+
* The body lines, with `run` as the command and `install` as the step that
|
|
255
|
+
* installs it.
|
|
174
256
|
* @param {string} run
|
|
257
|
+
* @param {string} install
|
|
175
258
|
* @returns {string[]}
|
|
176
259
|
*/
|
|
177
|
-
function bodyLines(run) {
|
|
260
|
+
function bodyLines(run, install) {
|
|
178
261
|
return [
|
|
179
262
|
'Astryx, a design system and UI library, is available on this computer.',
|
|
180
263
|
'Use it when you build or change UI, pick components, or style or theme an app.',
|
|
@@ -190,16 +273,30 @@ function bodyLines(run) {
|
|
|
190
273
|
WORKFLOW_TITLE,
|
|
191
274
|
...WORKFLOW_STEPS.map(step => step.replaceAll('`astryx ', `\`${run} `)),
|
|
192
275
|
`Before you deliver, re-read each file; ${SELF_CHECK_CSS}. Then build the project and deliver that build, not a description of it.`,
|
|
276
|
+
// A host's door is the host's to restore; only the global command has an
|
|
277
|
+
// install step to name.
|
|
278
|
+
...(run === COMPUTER_COMMAND ? [computerRestoreLine(install)] : []),
|
|
193
279
|
];
|
|
194
280
|
}
|
|
195
281
|
|
|
282
|
+
/**
|
|
283
|
+
* The command a skill file's text names: the one in its "Start with" line,
|
|
284
|
+
* or null when the text has none.
|
|
285
|
+
* @param {string} content
|
|
286
|
+
* @returns {string | null}
|
|
287
|
+
*/
|
|
288
|
+
export function skillCommandOf(content) {
|
|
289
|
+
return /Start with `(.+?) search '/u.exec(content)?.[1] ?? null;
|
|
290
|
+
}
|
|
291
|
+
|
|
196
292
|
/**
|
|
197
293
|
* The full skill file.
|
|
198
|
-
* @param {{command?: string}} [options]
|
|
294
|
+
* @param {{command?: string, install?: string}} [options]
|
|
199
295
|
* @returns {string}
|
|
200
296
|
*/
|
|
201
297
|
export function renderComputerAgentText({
|
|
202
298
|
command = computerAgentCommand(),
|
|
299
|
+
install = COMPUTER_INSTALL_STEP,
|
|
203
300
|
} = {}) {
|
|
204
301
|
return withHash(
|
|
205
302
|
[
|
|
@@ -211,7 +308,7 @@ export function renderComputerAgentText({
|
|
|
211
308
|
'---',
|
|
212
309
|
'',
|
|
213
310
|
MARKER_START,
|
|
214
|
-
...bodyLines(command),
|
|
311
|
+
...bodyLines(command, install),
|
|
215
312
|
MARKER_END,
|
|
216
313
|
'',
|
|
217
314
|
].join('\n'),
|
|
@@ -419,7 +516,10 @@ export function inspectComputerAgentText({
|
|
|
419
516
|
command,
|
|
420
517
|
links = [],
|
|
421
518
|
} = {}) {
|
|
422
|
-
const expected = renderComputerAgentText({
|
|
519
|
+
const expected = renderComputerAgentText({
|
|
520
|
+
command,
|
|
521
|
+
install: computerInstallStep({home, for: 'judge'}),
|
|
522
|
+
});
|
|
423
523
|
const folder = path.join(home, SKILL_FOLDER);
|
|
424
524
|
const made = new Set(links);
|
|
425
525
|
return [
|
|
@@ -532,12 +632,24 @@ function writeCopy(at, expected) {
|
|
|
532
632
|
* @returns {{rows: import('../../api/init/init.type.mjs').InitUserFile[], links: string[]}}
|
|
533
633
|
*/
|
|
534
634
|
export function writeComputerAgentText({home = os.homedir(), command} = {}) {
|
|
535
|
-
|
|
635
|
+
// Judged by the step the file records, so a file another copy of this
|
|
636
|
+
// release wrote stays as it is; a write records this copy's own step.
|
|
637
|
+
const judged = renderComputerAgentText({
|
|
638
|
+
command,
|
|
639
|
+
install: computerInstallStep({home, for: 'judge'}),
|
|
640
|
+
});
|
|
536
641
|
const file = computerSkillFile(home);
|
|
537
642
|
const folder = path.dirname(file);
|
|
538
643
|
/** @type {import('../../api/init/init.type.mjs').InitUserFile[]} */
|
|
539
644
|
const rows = [];
|
|
540
|
-
const state = stateOf(file,
|
|
645
|
+
const state = stateOf(file, judged);
|
|
646
|
+
const expected =
|
|
647
|
+
state === 'current'
|
|
648
|
+
? judged
|
|
649
|
+
: renderComputerAgentText({
|
|
650
|
+
command,
|
|
651
|
+
install: computerInstallStep({home, for: 'write'}),
|
|
652
|
+
});
|
|
541
653
|
if (state === 'foreign' || state === 'edited') {
|
|
542
654
|
rows.push({path: file, action: 'kept', reason: keptReason(state)});
|
|
543
655
|
} else if (state === 'current') {
|
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
computerSkillLinks,
|
|
25
25
|
inspectComputerAgentText,
|
|
26
26
|
removeComputerAgentText,
|
|
27
|
+
computerInstallStep,
|
|
27
28
|
renderComputerAgentText,
|
|
29
|
+
skillInstallStepOf,
|
|
28
30
|
writeComputerAgentText,
|
|
29
31
|
} from './computer-agent-text.mjs';
|
|
30
32
|
import {
|
|
@@ -155,6 +157,80 @@ describe('renderComputerAgentText', () => {
|
|
|
155
157
|
expect(text).toContain("`acme astryx search '<what you need>'`");
|
|
156
158
|
expect(text).not.toMatch(/`astryx /u);
|
|
157
159
|
});
|
|
160
|
+
|
|
161
|
+
// A machine can keep the home folder and lose the CLI installed for the
|
|
162
|
+
// computer, so the skill says how to get it back, with no version.
|
|
163
|
+
it('names the install step for when `astryx` is not found, and only for the global command', () => {
|
|
164
|
+
expect(
|
|
165
|
+
renderComputerAgentText({
|
|
166
|
+
command: 'astryx',
|
|
167
|
+
install: 'npm i -g @astryxdesign/cli',
|
|
168
|
+
}),
|
|
169
|
+
).toContain(
|
|
170
|
+
'If `astryx` is not found, run `npm i -g @astryxdesign/cli` first.',
|
|
171
|
+
);
|
|
172
|
+
// It repeats the step that installed the copy writing it, which doctor
|
|
173
|
+
// reads back.
|
|
174
|
+
const bun = renderComputerAgentText({
|
|
175
|
+
command: 'astryx',
|
|
176
|
+
install: 'bun add -g @astryxdesign/cli',
|
|
177
|
+
});
|
|
178
|
+
expect(bun).toContain(
|
|
179
|
+
'If `astryx` is not found, run `bun add -g @astryxdesign/cli` first.',
|
|
180
|
+
);
|
|
181
|
+
expect(skillInstallStepOf(bun)).toBe('bun add -g @astryxdesign/cli');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Rendering is pure: its default step never depends on the skill in the
|
|
185
|
+
// home folder of the computer the test runs on.
|
|
186
|
+
it("renders npm's step by default, whatever skill the caller's home folder holds", () => {
|
|
187
|
+
const home = tmp('caller-home');
|
|
188
|
+
const file = computerSkillFile(home);
|
|
189
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
190
|
+
fs.writeFileSync(
|
|
191
|
+
file,
|
|
192
|
+
renderComputerAgentText({
|
|
193
|
+
command: 'astryx',
|
|
194
|
+
install: 'pnpm add -g @astryxdesign/cli',
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
const saved = process.env.HOME;
|
|
198
|
+
process.env.HOME = home;
|
|
199
|
+
try {
|
|
200
|
+
expect(renderComputerAgentText({command: 'astryx'})).toContain(
|
|
201
|
+
'run `npm i -g @astryxdesign/cli` first.',
|
|
202
|
+
);
|
|
203
|
+
} finally {
|
|
204
|
+
process.env.HOME = saved;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Only the CLI installed for the computer chooses the step; every other
|
|
209
|
+
// copy of the release, such as a project's own CLI, keeps the one the file
|
|
210
|
+
// records, so it neither reports the file as different nor rewrites it.
|
|
211
|
+
it('keeps the step the file records for a copy that is not installed for the computer', () => {
|
|
212
|
+
const home = tmp('home');
|
|
213
|
+
const file = computerSkillFile(home);
|
|
214
|
+
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
215
|
+
const pnpm = renderComputerAgentText({
|
|
216
|
+
command: 'astryx',
|
|
217
|
+
install: 'pnpm add -g @astryxdesign/cli',
|
|
218
|
+
});
|
|
219
|
+
fs.writeFileSync(file, pnpm);
|
|
220
|
+
expect(computerInstallStep({home})).toBe('pnpm add -g @astryxdesign/cli');
|
|
221
|
+
expect(inspectComputerAgentText({home, command: 'astryx'})[0].state).toBe(
|
|
222
|
+
'current',
|
|
223
|
+
);
|
|
224
|
+
writeComputerAgentText({home, command: 'astryx'});
|
|
225
|
+
expect(fs.readFileSync(file, 'utf8')).toBe(pnpm);
|
|
226
|
+
// No file yet: npm's step.
|
|
227
|
+
expect(computerInstallStep({home: tmp('empty-home')})).toBe(
|
|
228
|
+
'npm i -g @astryxdesign/cli',
|
|
229
|
+
);
|
|
230
|
+
expect(renderComputerAgentText({command: 'acme astryx'})).not.toContain(
|
|
231
|
+
'npm i -g',
|
|
232
|
+
);
|
|
233
|
+
});
|
|
158
234
|
});
|
|
159
235
|
|
|
160
236
|
describe('the link table', () => {
|
|
@@ -802,8 +802,28 @@ describe('stopped and damaged installs heal', () => {
|
|
|
802
802
|
});
|
|
803
803
|
});
|
|
804
804
|
|
|
805
|
+
/** @param {number} pid */
|
|
806
|
+
const alive = pid => {
|
|
807
|
+
try {
|
|
808
|
+
process.kill(pid, 0);
|
|
809
|
+
return true;
|
|
810
|
+
} catch {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
/** @param {() => boolean} done @param {number} ms */
|
|
816
|
+
const waitFor = async (done, ms) => {
|
|
817
|
+
const end = Date.now() + ms;
|
|
818
|
+
while (Date.now() < end) {
|
|
819
|
+
if (done()) return true;
|
|
820
|
+
await new Promise(r => setTimeout(r, 100));
|
|
821
|
+
}
|
|
822
|
+
return done();
|
|
823
|
+
};
|
|
824
|
+
|
|
805
825
|
describe('runNpm time limit', () => {
|
|
806
|
-
it('ends a package manager that ignores SIGTERM, leaving no process behind', () => {
|
|
826
|
+
it('ends a package manager that ignores SIGTERM, leaving no process behind', async () => {
|
|
807
827
|
const marker = tempDir('npm-pid');
|
|
808
828
|
const pidFile = path.join(marker, 'pid');
|
|
809
829
|
const result = runNpm([], {
|
|
@@ -819,30 +839,13 @@ describe('runNpm time limit', () => {
|
|
|
819
839
|
});
|
|
820
840
|
expect(/** @type {any} */ (result.error)?.code).toBe('ETIMEDOUT');
|
|
821
841
|
const pid = Number(fs.readFileSync(pidFile, 'utf-8'));
|
|
822
|
-
|
|
842
|
+
// The guard sends SIGKILL and exits at once; the killed process can still
|
|
843
|
+
// exist for a moment (the signal in flight, or awaiting reaping).
|
|
844
|
+
expect(await waitFor(() => !alive(pid), 5_000)).toBe(true);
|
|
823
845
|
});
|
|
824
846
|
});
|
|
825
847
|
|
|
826
848
|
describe('no install outlives its run', () => {
|
|
827
|
-
/** @param {number} pid */
|
|
828
|
-
const alive = pid => {
|
|
829
|
-
try {
|
|
830
|
-
process.kill(pid, 0);
|
|
831
|
-
return true;
|
|
832
|
-
} catch {
|
|
833
|
-
return false;
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
/** @param {() => boolean} done @param {number} ms */
|
|
837
|
-
const waitFor = async (done, ms) => {
|
|
838
|
-
const end = Date.now() + ms;
|
|
839
|
-
while (Date.now() < end) {
|
|
840
|
-
if (done()) return true;
|
|
841
|
-
await new Promise(r => setTimeout(r, 100));
|
|
842
|
-
}
|
|
843
|
-
return done();
|
|
844
|
-
};
|
|
845
|
-
|
|
846
849
|
it('ends npm when the run that started it is killed outright, and removes its process-id record', async () => {
|
|
847
850
|
const dir = tempDir('orphan');
|
|
848
851
|
const pidFile = path.join(dir, 'npm-pid');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.3-canary.
|
|
3
|
+
"version": "0.7.3-canary.da1020b",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"zod": "^4.4.3"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
110
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
111
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
112
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
109
|
+
"@astryxdesign/charts": "0.7.3-canary.da1020b",
|
|
110
|
+
"@astryxdesign/core": "0.7.3-canary.da1020b",
|
|
111
|
+
"@astryxdesign/lab": "0.7.3-canary.da1020b",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.da1020b"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"@astryxdesign/charts": {
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@astryxdesign/charts": "0.7.3-canary.
|
|
130
|
-
"@astryxdesign/core": "0.7.3-canary.
|
|
131
|
-
"@astryxdesign/lab": "0.7.3-canary.
|
|
132
|
-
"@astryxdesign/theme-neutral": "0.7.3-canary.
|
|
129
|
+
"@astryxdesign/charts": "0.7.3-canary.da1020b",
|
|
130
|
+
"@astryxdesign/core": "0.7.3-canary.da1020b",
|
|
131
|
+
"@astryxdesign/lab": "0.7.3-canary.da1020b",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.da1020b",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|