@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
|
@@ -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.2f47a4a",
|
|
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.2f47a4a",
|
|
110
|
+
"@astryxdesign/core": "0.7.3-canary.2f47a4a",
|
|
111
|
+
"@astryxdesign/lab": "0.7.3-canary.2f47a4a",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.2f47a4a"
|
|
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.2f47a4a",
|
|
130
|
+
"@astryxdesign/core": "0.7.3-canary.2f47a4a",
|
|
131
|
+
"@astryxdesign/lab": "0.7.3-canary.2f47a4a",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.3-canary.2f47a4a",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|