An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): the setup reminder names the project's release and prints at most once a day (#10343)
Joeyb66434e90821
diff --git a/.changeset/cli-setup-reminder-once-a-day.md b/.changeset/cli-setup-reminder-once-a-day.mdnew file mode 100644index 0000000000..79fa976822--- /dev/null+++ b/.changeset/cli-setup-reminder-once-a-day.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] The reminder to run `astryx init` in a project that has not run it no longer prints before every command. It now prints after a command that succeeds, at most once a day per project, recorded in the per-user state as the daily hints are. It does not print with `--json`, after a command that fails, or when `CI` is set. `astryx doctor` still reports the missing setup in its agent-docs check every time. No JSON shape or exit code changes.++@josephfarinadiff --git a/.changeset/cli-tool-folder-reminder-project-core.md b/.changeset/cli-tool-folder-reminder-project-core.mdnew file mode 100644index 0000000000..64e76a3eeb--- /dev/null+++ b/.changeset/cli-tool-folder-reminder-project-core.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] In a folder inside an Astryx project whose own `package.json` declares no Astryx package, such as a tool folder that installs its own `@astryxdesign/core`, the setup reminder's `init` command now names the project's release, as run from the project's folder: the project's own CLI when it installs one, otherwise the package runner pinned to the project's Core, such as `npx @astryxdesign/[email protected] init`. It used to pin the release of the CLI that answered the run, whatever the project records. No JSON shape or exit code changes.++@josephfarinadiff --git a/packages/cli/clients/cli/cli-command.test.mjs b/packages/cli/clients/cli/cli-command.test.mjsindex f14db5e699..2daa489ba1 100644--- a/packages/cli/clients/cli/cli-command.test.mjs+++ b/packages/cli/clients/cli/cli-command.test.mjs@@ -6,7 +6,7 @@* bare.*/-import {afterEach, beforeEach, describe, expect, it} from 'vitest';+import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';import {spawnSync} from 'node:child_process';import * as fs from 'node:fs';import * as os from 'node:os';@@ -71,6 +71,16 @@ describe('the setup nudge in a project with no CLI of its own', () => {const app = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-cli-command-nudge-'),);+ // The reminder prints once a day per project and never under CI: give+ // this run its own per-user state, outside CI.+ const stateHome = fs.mkdtempSync(+ path.join(os.tmpdir(), 'astryx-cli-command-state-'),+ );+ vi.stubEnv('HOME', stateHome);+ vi.stubEnv('USERPROFILE', stateHome);+ vi.stubEnv('XDG_CONFIG_HOME', stateHome);+ vi.stubEnv('APPDATA', stateHome);+ vi.stubEnv('CI', '');try {// Only Core, of another release than the CLI that answers, an// integration declaring cliCommand, and no agent docs yet.@@ -105,7 +115,9 @@ describe('the setup nudge in a project with no CLI of its own', () => {'Next step: run `npm install @astryxdesign/[email protected]`, then `acme astryx init`',);} finally {+ vi.unstubAllEnvs();fs.rmSync(app, {recursive: true, force: true});+ fs.rmSync(stateHome, {recursive: true, force: true});}});});diff --git a/packages/cli/clients/cli/commands/setup-nudge.test.mjs b/packages/cli/clients/cli/commands/setup-nudge.test.mjsindex e86bcdf852..30eb0866ef 100644--- a/packages/cli/clients/cli/commands/setup-nudge.test.mjs+++ b/packages/cli/clients/cli/commands/setup-nudge.test.mjs@@ -6,13 +6,13 @@* Unit: isAstryxInitialized() detects the Astryx marker across EVERY agent-doc* location (including the previously-missed Hermes files) and legacy XDS blocks.*- * Integration: the CLI nudges (stderr) before a command when the project hasn't- * run init — INCLUDING in --json mode (agents pass --json, and stderr never- * corrupts the stdout JSON envelope). Quiet once set up, outside a project, and- * for the installer command itself.+ * Integration: the CLI reminds (stderr) after a successful command, at most+ * once a day per project, when the project hasn't run init. Quiet in --json,+ * under CI, after a failure, once set up, outside a project, and for the+ * installer command itself.*/-import {describe, it, expect, beforeEach, afterEach} from 'vitest';+import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';import * as fs from 'node:fs';import * as path from 'node:path';import * as os from 'node:os';@@ -22,6 +22,7 @@ import {isAstryxPromptInReach,} from '../../../foundation/agent-docs/agent-docs.mjs';import {runCli} from '../../../test-utils/run-cli.mjs';+import {userConfigDir} from '../../../foundation/env/user-dirs.mjs';/** This source checkout: the tests run the CLI from it. */const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');@@ -38,13 +39,28 @@ const MARKER = '<!-- ASTRYX:START -->';const NUDGE = /finish setup and install the Astryx agent prompt/;let tmp;+/** The per-user folder that records when the reminder last printed. */+let stateHome;beforeEach(() => {tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-setup-nudge-'));+ stateHome = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-setup-state-'));+ // Every platform's per-user folder lands under stateHome: macOS reads only+ // the home folder, Linux XDG_CONFIG_HOME, Windows APPDATA.+ vi.stubEnv('HOME', stateHome);+ vi.stubEnv('USERPROFILE', stateHome);+ vi.stubEnv('XDG_CONFIG_HOME', stateHome);+ vi.stubEnv('APPDATA', stateHome);+ vi.stubEnv('CI', '');});afterEach(() => {+ vi.unstubAllEnvs();fs.rmSync(tmp, {recursive: true, force: true});+ fs.rmSync(stateHome, {recursive: true, force: true});});+/** The per-user state file the reminder records its day in. */+const stateFile = () => path.join(userConfigDir(), 'state.json');+function write(rel, body) {const p = path.join(tmp, rel);fs.mkdirSync(path.dirname(p), {recursive: true});@@ -165,6 +181,74 @@ describe('enforcement layer 3 — per-command setup nudge', () => {expect(() => JSON.parse(r.stdout)).not.toThrow();});+ // An agent that leaves `init` to its person must not see the reminder+ // before every command: once a day per project, after a command that+ // succeeds.+ it('prints once a day per project: a second command the same day prints none', async () => {+ asProject();+ const first = await runCli(['docs', 'tokens'], tmp);+ expect(first.stderr).toMatch(NUDGE);+ // After the command's own output, never before it.+ expect(first.stderr.trimEnd().endsWith('install the Astryx agent prompt.')).toBe(true);+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).not.toMatch(NUDGE);+ expect((await runCli(['component', '--list'], tmp)).stderr).not.toMatch(NUDGE);+ });++ it('prints once again the next day', async () => {+ asProject();+ expect(stateFile().startsWith(stateHome)).toBe(true);+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).toMatch(NUDGE);+ const state = JSON.parse(fs.readFileSync(stateFile(), 'utf8'));+ const key = Object.keys(state.notifiedAt).find(k => k.startsWith('setup:'));+ expect(key).toBeDefined();+ state.notifiedAt[key] = Date.now() - 25 * 60 * 60 * 1000;+ fs.writeFileSync(stateFile(), JSON.stringify(state));+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).toMatch(NUDGE);+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).not.toMatch(NUDGE);+ });++ it('prints none under CI, and records nothing', async () => {+ asProject();+ vi.stubEnv('CI', 'true');+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).not.toMatch(NUDGE);+ vi.stubEnv('CI', '');+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).toMatch(NUDGE);+ });++ it('prints none after a command that fails', async () => {+ asProject();+ const r = await runCli(['component', 'NoSuchComponentAnywhere'], tmp);+ expect(r.status).not.toBe(0);+ expect(r.stderr).not.toMatch(NUDGE);+ // The day is not used up: the next command that succeeds prints it.+ expect((await runCli(['docs', 'tokens'], tmp)).stderr).toMatch(NUDGE);+ });++ it("a reminder kept to once a day is no update notice: doctor's update line never names it", async () => {+ asProject();+ await runCli(['docs', 'tokens'], tmp);+ await runCli(['docs', 'tokens'], tmp);+ const state = JSON.parse(fs.readFileSync(stateFile(), 'utf8'));+ expect(Object.keys(state.noticeSkips ?? {}).filter(k => k.startsWith('setup:'))).toEqual([]);+ const r = await runCli(['--json', 'doctor'], tmp);+ const newest = JSON.parse(r.stdout).data.checks.find(+ (/** @type {any} */ c) => c.id === 'newest-release',+ );+ expect(newest?.message ?? '').not.toContain('setup:');+ });++ it('doctor reports the missing setup in its own check, every time', async () => {+ asProject();+ for (let i = 0; i < 2; i++) {+ const r = await runCli(['--json', 'doctor'], tmp);+ const check = JSON.parse(r.stdout).data.checks.find(+ (/** @type {any} */ c) => c.id === 'agent-docs',+ );+ expect(check.message).toMatch(/^No agent docs found/u);+ expect(check.fix).toMatch(/init --features agents/u);+ }+ });+it('is quiet once set up (marker present)', async () => {asProject();write('AGENTS.md', MARKER);@@ -211,11 +295,25 @@ describe('enforcement layer 3 — per-command setup nudge', () => {write('functions/package.json', '{"name":"functions"}');const r = await runCli(['docs', 'tokens'], path.join(tmp, 'functions'));// Only `cd` comes first, so the app has no CLI of its own yet: the- // command is the scoped package at the answering release, never the bare+ // command is the scoped package at the project's release, never the bare// `astryx` name a package runner would fetch from the registry.- const {version} = JSON.parse(fs.readFileSync(new URL('../../../package.json', import.meta.url), 'utf8'));expect(r.stderr.trim()).toBe(- `Next step: run \`cd ${tmp}\`, then \`npx @astryxdesign/cli@${version} init\` to finish setup and install the Astryx agent prompt.`,+ `Next step: run \`cd ${tmp}\`, then \`npx @astryxdesign/[email protected] init\` to finish setup and install the Astryx agent prompt.`,+ );+ });++ // A tool folder that installs its own Core: the command runs in the+ // project's folder at the project's release, never at the release of the+ // CLI that answered the run.+ it("in a tool folder with its own Core, names the project's Core, not the answering CLI's release", async () => {+ write('package.json', JSON.stringify({name: 'app', dependencies: {'@astryxdesign/core': '^0.7.0'}}));+ write('package-lock.json', '{}');+ write('node_modules/@astryxdesign/core/package.json', JSON.stringify({name: '@astryxdesign/core', version: '0.7.3'}));+ write('tools/codegen/package.json', '{"name":"codegen"}');+ write('tools/codegen/node_modules/@astryxdesign/core/package.json', JSON.stringify({name: '@astryxdesign/core', version: '0.7.4'}));+ const r = await runCli(['docs', 'tokens'], path.join(tmp, 'tools', 'codegen'));+ expect(r.stderr.trim()).toBe(+ `Next step: run \`cd ${tmp}\`, then \`npx @astryxdesign/[email protected] init\` to finish setup and install the Astryx agent prompt.`,);});diff --git a/packages/cli/clients/cli/index.mjs b/packages/cli/clients/cli/index.mjsindex ff608a5ec4..19aafb24c2 100644--- a/packages/cli/clients/cli/index.mjs+++ b/packages/cli/clients/cli/index.mjs@@ -22,7 +22,8 @@ import {isOutsideProject} from '../../foundation/env/project-scope.mjs';import {findConfigPath} from '../../foundation/config/config-path.mjs';import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';import {answeredBy, runChoice} from '../../foundation/release/run-context.mjs';-import {cliInstallAdvice, installFolder} from '../../foundation/release/notices.mjs';+import {cliInstallAdvice, installFolder, projectRelease, SETUP_REMINDER_KEY, takeNotice} from '../../foundation/release/notices.mjs';+import {isCi} from '../../foundation/release/update-notice-env.mjs';import {buildManifest} from './lib/manifest.mjs';import {cliError} from './lib/cli-error.mjs';import {section, text, records} from './formatters/index.mjs';@@ -683,8 +684,11 @@ export async function createProgram({argv} = {}) {* repository root — see isAstryxPromptInReach), remind the user/agent that* setup is missing.*- * Uses `preAction` (not postAction) so it fires for EVERY valid command — even- * ones whose action errors or calls process.exit (postAction is skipped then).+ * `preAction` decides the line; `postAction` prints it after a command that+ * succeeds, at most once a day per project, recorded in the per-user state+ * as the daily hint is, and never under CI. An agent that leaves `init` to+ * its person then sees it once, not before every command. Doctor reports+ * the missing setup in its own check every time.** Suppressed in --json: that is machine output with a strict clean stdout+stderr* contract (json-shim.test: "error envelopes have empty stderr"), and --json@@ -695,8 +699,29 @@ export async function createProgram({argv} = {}) {* or one that neither installs nor declares Astryx), and inside the CLI's own* source checkout when it runs from there.*/+ /** @type {{root: string, line: string} | null} */+ let setupReminder = null;+ /**+ * Keep the reminder for `root` until the command ends.+ * @param {string} root+ * @param {string} line+ */+ const remindSetup = (root, line) => {+ setupReminder = {root, line};+ };+ program.hook('postAction', () => {+ try {+ const reminder = setupReminder;+ setupReminder = null;+ if (reminder == null || process.exitCode || isCi(process.env)) return;+ if (takeNotice(`${SETUP_REMINDER_KEY}${reminder.root}`)) console.error(reminder.line);+ } catch {+ // Never let the nudge break a command.+ }+ });program.hook('preAction', (thisCommand, actionCommand) => {try {+ setupReminder = null;if (program.opts().json) return; // machine mode — keep --json output cleanif (SETUP_NUDGE_EXEMPT.has(actionCommand.name())) return;const cwd = process.cwd();@@ -738,9 +763,12 @@ export async function createProgram({argv} = {}) {// before it, so the command is the picker's for that folder, never the// bare `astryx` name a package runner would fetch from the registry// (spec AST-081 FR5).+ // The command names the project's release, as run from its folder,+ // never the Core this folder installs for itself.if (target.moved) {- console.error(- setupNudge(getCliInvocation(target.dir), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),+ remindSetup(+ target.dir,+ setupNudge(getCliInvocation(target.dir, {release: projectRelease(target.dir)}), {before: `cd ${quoteCommandArgument(target.dir)}`}).trimEnd(),);return;}@@ -750,13 +778,14 @@ export async function createProgram({argv} = {}) {// version, then run that CLI's init.const add = cliInstallAdvice({cwd, core: choice.coreVersion});if (add?.command) {- console.error(+ remindSetup(+ add.root,setupNudge(getCliInvocation(add.root, {installed: true}), {before: add.command}).trimEnd(),);return;}}- console.error(setupNudge(getCliInvocation(cwd)).trimEnd());+ remindSetup(agentDocsTargetDir(cwd), setupNudge(getCliInvocation(cwd)).trimEnd());} catch {// Never let the nudge break a command.}diff --git a/packages/cli/clients/cli/latest-version-env.test.mjs b/packages/cli/clients/cli/latest-version-env.test.mjsindex 8752de3bd4..61c1c6c8c9 100644--- a/packages/cli/clients/cli/latest-version-env.test.mjs+++ b/packages/cli/clients/cli/latest-version-env.test.mjs@@ -27,6 +27,8 @@ beforeEach(() => {path.join(dir, 'package.json'),JSON.stringify({name: 'app', private: true, dependencies: {'@astryxdesign/core': '^0.0.1'}}),);+ // Set up, so the once-a-day setup reminder plays no part in what is compared.+ fs.writeFileSync(path.join(dir, 'AGENTS.md'), '<!-- ASTRYX:START -->\n<!-- ASTRYX:END -->\n');});afterEach(() => {diff --git a/packages/cli/foundation/env/package-manager.mjs b/packages/cli/foundation/env/package-manager.mjsindex 56efabe3fb..f2b0b36901 100644--- a/packages/cli/foundation/env/package-manager.mjs+++ b/packages/cli/foundation/env/package-manager.mjs@@ -509,21 +509,30 @@ export function cliBinResolves(targetDir = process.cwd()) {** With `installed`, the line follows a step that installs the project's own* CLI (an update notice, the hint that matches a project's CLI to its Core),- * so the guess is that CLI: `<run-prefix> astryx`. A declared `cliCommand`- * and a host's door still come first.+ * so the guess is that CLI: `<run-prefix> astryx`. With `release`, the line+ * runs in another project's folder than the run's, so the guess names that+ * project's release instead of the one that answered: its own CLI when it+ * installs one and the bin resolves there, otherwise the package runner+ * pinned to that release. A declared `cliCommand` and a host's door still+ * come first.** @param {string} [targetDir] the project the printed command runs in;* defaults to the working directory- * @param {{installed?: boolean}} [options]+ * @param {{installed?: boolean, release?: {version: string, own: boolean} | null}} [options]* @returns {string}*/-export function getCliInvocation(targetDir, {installed = false} = {}) {+export function getCliInvocation(+ targetDir,+ {installed = false, release = null} = {},+) {const declared = declaredCliCommand(targetDir);if (declared.command) return declared.command;const guess = () =>- installed+ installed || (release?.own && cliBinResolves(targetDir))? `${getRunPrefix(targetDir)} ${CLI_BIN}`- : guessCliInvocation(targetDir);+ : release+ ? `${getDlxPrefix(targetDir)} ${CLI_PACKAGE}@${release.version}`+ : guessCliInvocation(targetDir);if (declared.conflict) return guess();return cliDoor() ?? guess();}diff --git a/packages/cli/foundation/release/notices.mjs b/packages/cli/foundation/release/notices.mjsindex 23fd3bb6c0..4a2590c28b 100644--- a/packages/cli/foundation/release/notices.mjs+++ b/packages/cli/foundation/release/notices.mjs@@ -81,6 +81,12 @@ const FORGET_AFTER_MS = 30 * 24 * 60 * 60_000;*/const LATEST = '@astryxdesign/cli@latest';+/**+ * The key prefix of the once-a-day setup reminder. It is no update notice, so+ * no skip is recorded for it and doctor's update line never names it.+ */+export const SETUP_REMINDER_KEY = 'setup:';+/*** Whether notice `key` may print now; when it may, its time is recorded* first, and a time that cannot be recorded keeps it from printing.@@ -104,7 +110,9 @@ export function takeNotice(const shown = state.notifiedAt ?? {};const last = shown[key];if (typeof last === 'number' && now - last < NOTICE_INTERVAL_MS) {- const skips = withSkip(state.noticeSkips, key, 'already-shown', now);+ const skips = key.startsWith(SETUP_REMINDER_KEY)+ ? null+ : withSkip(state.noticeSkips, key, 'already-shown', now);if (skips) writeGlobalState({...state, noticeSkips: skips}, stateDir);return /** @type {const} */ ('already-shown');}@@ -198,6 +206,7 @@ export function lastNoticeSkip({stateDir = userConfigDir()} = {}) {readGlobalState(stateDir).noticeSkips ?? {},)) {if (+ !key.startsWith(SETUP_REMINDER_KEY) &&skip &&typeof skip.at === 'number' &&(!newest || skip.at > newest.at)@@ -459,6 +468,19 @@ export function installFolder(cwd) {export const RUN_FROM_PROJECT ="Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.";+/**+ * The release of the project at `dir`, for a command that runs in its folder+ * from a folder below it: its own CLI's version when it installs one, else+ * the Core it records; null when it records neither.+ * @param {string} dir+ * @returns {{version: string, own: boolean} | null}+ */+export function projectRelease(dir) {+ const facts = readReleaseFacts(dir);+ const version = facts.cli?.version ?? coreVersionOf(facts);+ return version ? {version, own: Boolean(facts.cli)} : null;+}+/*** The command that adds the CLI at Core's version, for a run in `cwd` whose* Core is `core`, with the project's package manager in the project root.@@ -534,11 +556,10 @@ export function projectLag({cwd, current: given, stateDir = userConfigDir()}) {const target = installFolder(cwd);if (target == null) return null;const root = target.moved ? target.dir : (projectRootOf(facts) ?? cwd);- // From a folder inside the project, the project's own release: its CLI's,- // else its Core's, so the project gets one notice and one --from.- const projectFacts = target.moved ? readReleaseFacts(root) : null;- const current = projectFacts- ? (projectFacts.cli?.version ?? coreVersionOf(projectFacts) ?? given)+ // From a folder inside the project, the project's own release, as the+ // setup reminder names it, so the project gets one notice and one --from.+ const current = target.moved+ ? (projectRelease(root)?.version ?? given): given;if (!isBehind(current, latest.version)) return null;const newest = latest.version;diff --git a/packages/cli/foundation/release/notices.test.mjs b/packages/cli/foundation/release/notices.test.mjsindex 0bc584ad0e..ed3b83178a 100644--- a/packages/cli/foundation/release/notices.test.mjs+++ b/packages/cli/foundation/release/notices.test.mjs@@ -167,6 +167,29 @@ describe('why a notice did not print (diagnostic state)', () => {});});+ // The setup reminder shares the once-a-day record but is no update+ // notice: no skip is recorded for it, and an old one is never reported.+ it('records no skip for the setup reminder, and lastNoticeSkip ignores one', () => {+ const stateDir = tempDir('state');+ updateGlobalState({latest: '0.7.1'}, stateDir);+ expect(takeNotice('setup:/app', {stateDir, now: 1000})).toBe(true);+ expect(takeNotice('setup:/app', {stateDir, now: 2000})).toBe(false);+ expect(readGlobalState(stateDir).noticeSkips).toBeUndefined();+ expect(lastNoticeSkip({stateDir})).toBeNull();+ updateGlobalState(+ {noticeSkips: {'setup:/app': {reason: 'already-shown', at: 3000}}},+ stateDir,+ );+ expect(lastNoticeSkip({stateDir})).toBeNull();+ expect(takeNotice('global', {stateDir, now: 4000})).toBe(true);+ expect(takeNotice('global', {stateDir, now: 5000})).toBe(false);+ expect(lastNoticeSkip({stateDir})).toEqual({+ key: 'global',+ reason: 'already-shown',+ at: 5000,+ });+ });+it('says a held lock timed out, and who holds it', () => {const stateDir = tempDir('state');const lockDir = path.join(stateDir, '.lock-state');diff --git a/vitest.global-setup.node.mjs b/vitest.global-setup.node.mjsindex efaac8a4f3..dc3418ce8c 100644--- a/vitest.global-setup.node.mjs+++ b/vitest.global-setup.node.mjs@@ -5,8 +5,9 @@* @input Shared ensureCoreBuilt helper and authored Sandbox template descriptors.* @output Holds this run's lease and builds Core. It rebuilds a Core build* older than its sources once no earlier run is still running. It- * regenerates the Sandbox template registry and route wrappers and packs the- * CLI, once, before any test worker forks.+ * regenerates the Sandbox template registry and route wrappers, packs the+ * CLI, and points the per-user folder at a folder of this run, once, before+ * any test worker forks.* @position Referenced by vitest.config.ts's `node` project. The build-theme* suites need a compiled Core; the Sandbox route contract imports generated* template metadata and scans ignored wrappers that do not exist in a fresh@@ -71,6 +72,19 @@ export default async function setup(project) {// An earlier run's child may have been stopped before it removed that// run's folder.sweepTrash(os.tmpdir(), Date.now());+ // The CLI records once-a-day notices in a per-user state file. Point the+ // per-user folder of every worker at a folder of this run, so no test+ // writes the developer's real one. macOS reads it under the home folder+ // only, so there the home folder moves too, and npm keeps its own cache.+ const userHome = fs.mkdtempSync(+ path.join(os.tmpdir(), 'astryx-test-user-'),+ );+ process.env.XDG_CONFIG_HOME = path.join(userHome, '.config');+ process.env.APPDATA = path.join(userHome, 'AppData', 'Roaming');+ if (process.platform === 'darwin') {+ process.env.npm_config_cache ??= path.join(os.homedir(), '.npm');+ process.env.HOME = userHome;+ }// `npm pack` costs about 5 s of CPU. Packing once here keeps that out of// every suite that places CLI copies, and out of their timed tests. A watch// session packs again before a rerun of this project's tests, so they see@@ -95,6 +109,7 @@ export default async function setup(project) {// Vitest gives close() 10 s, and the folder holds thousands of files.// It moves aside at once, and a detached child removes it.trashFolder(packDir);+ trashFolder(userHome);endRun();};} catch (error) {