@astryxdesign/cli 0.7.3-canary.ca48bb7 → 0.7.3-canary.cac3d8d

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.
Files changed (53) hide show
  1. package/api/build/_adapter.mjs +37 -25
  2. package/api/build/blocks/blocks.d.mts +68 -20
  3. package/api/build/blocks/blocks.mjs +472 -196
  4. package/api/build/blocks/blocks.test.mjs +185 -168
  5. package/api/build/blocks/blocks.weights.json +1 -1
  6. package/api/build/build.type.mjs +1 -1
  7. package/api/build/kit/answer.d.mts +4 -1
  8. package/api/build/kit/answer.mjs +11 -3
  9. package/api/build/kit/signals.d.mts +11 -0
  10. package/api/build/kit/signals.mjs +8 -7
  11. package/api/build/kit/weights.d.mts +8 -22
  12. package/api/build/kit/weights.mjs +87 -8
  13. package/api/build/kit/weights.test.mjs +96 -0
  14. package/api/build/tree.mjs +2 -1
  15. package/api/build/tree.test.mjs +27 -27
  16. package/api/component/_adapter.mjs +39 -5
  17. package/api/discover/_adapter.d.mts +1 -2
  18. package/api/discover/_adapter.mjs +6 -8
  19. package/api/discover/discover.mjs +0 -1
  20. package/api/docs/_adapter.mjs +4 -0
  21. package/api/doctor/_adapter.d.mts +33 -13
  22. package/api/doctor/_adapter.mjs +55 -25
  23. package/api/doctor/doctor.d.mts +23 -5
  24. package/api/doctor/doctor.mjs +81 -16
  25. package/api/doctor/doctor.test.mjs +58 -0
  26. package/api/search/_gather-templates.d.mts +0 -1
  27. package/api/search/_gather-templates.mjs +25 -0
  28. package/api/search/search.integration-block.test.mjs +100 -0
  29. package/api/template/template.mjs +5 -1
  30. package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
  31. package/clients/cli/commands/doctor.doc.mjs +1 -1
  32. package/clients/cli/commands/outside-project.test.mjs +99 -0
  33. package/clients/cli/commands/setup-nudge.test.mjs +17 -0
  34. package/clients/cli/index.mjs +25 -8
  35. package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
  36. package/foundation/agent-docs/agent-doc-state.mjs +24 -2
  37. package/foundation/agent-docs/agent-docs.mjs +5 -5
  38. package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
  39. package/foundation/agent-docs/computer-agent-text.mjs +135 -8
  40. package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
  41. package/foundation/integrations/public-imports.mjs +1 -1
  42. package/foundation/release/cache.test.mjs +24 -21
  43. package/foundation/release/global-state.d.mts +8 -4
  44. package/foundation/release/global-state.mjs +4 -2
  45. package/foundation/release/notices.d.mts +62 -8
  46. package/foundation/release/notices.mjs +136 -25
  47. package/foundation/release/notices.test.mjs +21 -0
  48. package/foundation/text/string-utils.d.mts +2 -1
  49. package/foundation/text/string-utils.mjs +16 -5
  50. package/foundation/text/suggest-order.d.mts +72 -0
  51. package/foundation/text/suggest-order.mjs +363 -0
  52. package/foundation/text/suggest-order.test.mjs +259 -0
  53. 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 and its state on disk.
68
- * @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}>}}
67
+ * The computer-level agent text's setting, its state on disk, and the command
68
+ * the skill file tells agents to run and the install step it records for when
69
+ * that command is not found (each null when there is no file, or it names
70
+ * none).
71
+ * @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>, command: string | null, install: string | null}}
69
72
  */
70
73
  export function computerAgentTextState(): {
71
74
  settings: import("../../foundation/env/user-settings.mjs").ComputerAgentTextSettings;
@@ -74,6 +77,8 @@ export function computerAgentTextState(): {
74
77
  state: import("../../foundation/agent-docs/computer-agent-text.mjs").ComputerAgentTextState;
75
78
  link?: true;
76
79
  }>;
80
+ command: string | null;
81
+ install: string | null;
77
82
  };
78
83
  /**
79
84
  * The release facts doctor reports, read here so the checks stay pure
@@ -83,7 +88,7 @@ export function computerAgentTextState(): {
83
88
  * command that upgrades it.
84
89
  * @param {string} cwd
85
90
  * @param {{project: boolean}} options
86
- * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
91
+ * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null, runner: boolean}>}}
87
92
  */
88
93
  export function releaseFacts(cwd: string, { project }: {
89
94
  project: boolean;
@@ -101,6 +106,7 @@ export function releaseFacts(cwd: string, { project }: {
101
106
  stateLock: ReturnType<typeof stateLockHolder>;
102
107
  searchPathCommands: Array<import("../../foundation/env/search-path.mjs").SearchPathCommand & {
103
108
  upgrade: string | null;
109
+ runner: boolean;
104
110
  }>;
105
111
  };
106
112
  /** Whether `cwd` is outside every project. */
@@ -108,13 +114,14 @@ export function outsideProject(cwd: string): boolean;
108
114
  /**
109
115
  * The commands that bring a project's own CLI and Core to one release, with
110
116
  * the project's package manager: Core up to the CLI, then its codemods, when
111
- * the CLI is newer; else the CLI to the Core's release.
117
+ * the CLI is newer; else the CLI to the Core's release. Null when no
118
+ * command fits (see `alignCliAndCore`).
112
119
  * @param {string} cwd
113
120
  * @param {string} cli
114
121
  * @param {string} core
115
- * @returns {string}
122
+ * @returns {string | null}
116
123
  */
117
- export function alignCommand(cwd: string, cli: string, core: string): string;
124
+ export function alignCommand(cwd: string, cli: string, core: string): string | null;
118
125
  /**
119
126
  * The Core release the project at `cwd` names: installed, else locked, else
120
127
  * declared; the version the daily hint and notice compare against (spec
@@ -131,19 +138,32 @@ export function projectCoreVersion(cwd: string): string | null;
131
138
  export function projectHasOwnCli(cwd: string): boolean;
132
139
  /**
133
140
  * The command that adds the CLI at `version` with the project's package
134
- * manager.
141
+ * manager, and the Core it matches: from a folder whose package.json declares
142
+ * no Astryx package, in the Astryx project above at that project's Core; null
143
+ * when there is none (see `cliInstallAdvice`).
135
144
  * @param {string} cwd
136
145
  * @param {string} version
137
- * @returns {string}
146
+ * @returns {{command: string, core: string} | null}
138
147
  */
139
- export function addCliCommandFor(cwd: string, version: string): string;
148
+ export function addCliCommandFor(cwd: string, version: string): {
149
+ command: string;
150
+ core: string;
151
+ } | null;
140
152
  /**
141
- * The command that adds a package with the folder's package manager, read
142
- * from its lockfiles and `packageManager` field.
153
+ * The command that adds a package to the project of `cwd`; null in a folder
154
+ * that belongs to no project or whose package.json is not the project's (see
155
+ * `projectAddCommand`).
143
156
  * @param {string} cwd
144
- * @returns {(name: string) => string}
157
+ * @returns {((name: string) => string) | null}
158
+ */
159
+ export function installCommandFor(cwd: string): ((name: string) => string) | null;
160
+ /**
161
+ * Whether `cwd` is inside a project whose package.json is not the project's,
162
+ * so advice points at the project's folder (see `installFolder`).
163
+ * @param {string} cwd
164
+ * @returns {boolean}
145
165
  */
146
- export function installCommandFor(cwd: string): (name: string) => string;
166
+ export function insideProjectElsewhere(cwd: string): boolean;
147
167
  export { resolveRecordedTheme } from "../theme/theme.mjs";
148
168
  export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
149
169
  export const SOURCE_EXTENSIONS: Set<string>;
@@ -10,8 +10,10 @@ import {
10
10
  stateLockHolder,
11
11
  } from '../../foundation/release/global-state.mjs';
12
12
  import {
13
- addCliCommand,
14
13
  alignCliAndCore,
14
+ cliInstallAdvice,
15
+ installFolder,
16
+ projectAddCommand,
15
17
  globalBehind,
16
18
  globalUpgradeCommand,
17
19
  lastNoticeSkip,
@@ -19,16 +21,18 @@ import {
19
21
  } from '../../foundation/release/notices.mjs';
20
22
  import {
21
23
  coreVersionOf,
24
+ installPlaceOf,
22
25
  isGlobalCopy,
23
- projectRootOf,
24
26
  } from '../../foundation/release/choose.mjs';
25
27
  import {readReleaseFacts} from '../../foundation/release/project.mjs';
26
- import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
27
28
  import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
28
29
  import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
29
30
  import {
31
+ computerSkillFile,
30
32
  displayHomePath,
31
33
  inspectComputerAgentText,
34
+ skillCommandOf,
35
+ skillInstallStepOf,
32
36
  } from '../../foundation/agent-docs/computer-agent-text.mjs';
33
37
  import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
34
38
  import * as fs from 'node:fs';
@@ -291,12 +295,29 @@ function declaredPackageNames(cwd) {
291
295
  }
292
296
 
293
297
  /**
294
- * The computer-level agent text's setting and its state on disk.
295
- * @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}>}}
298
+ * The computer-level agent text's setting, its state on disk, and the command
299
+ * the skill file tells agents to run and the install step it records for when
300
+ * that command is not found (each null when there is no file, or it names
301
+ * none).
302
+ * @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>, command: string | null, install: string | null}}
296
303
  */
297
304
  export function computerAgentTextState() {
298
305
  const settings = computerAgentTextSettings();
299
- return {settings, entries: inspectComputerAgentText({links: settings.links})};
306
+ let command = null;
307
+ let install = null;
308
+ try {
309
+ const text = fs.readFileSync(computerSkillFile(), 'utf8');
310
+ command = skillCommandOf(text);
311
+ install = skillInstallStepOf(text);
312
+ } catch {
313
+ // No skill file, or one that cannot be read: no command to check.
314
+ }
315
+ return {
316
+ settings,
317
+ entries: inspectComputerAgentText({links: settings.links}),
318
+ command,
319
+ install,
320
+ };
300
321
  }
301
322
 
302
323
  export {displayHomePath};
@@ -309,7 +330,7 @@ export {displayHomePath};
309
330
  * command that upgrades it.
310
331
  * @param {string} cwd
311
332
  * @param {{project: boolean}} options
312
- * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
333
+ * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null, runner: boolean}>}}
313
334
  */
314
335
  export function releaseFacts(cwd, {project}) {
315
336
  const answered = answeredBy(cwd);
@@ -336,6 +357,9 @@ export function releaseFacts(cwd, {project}) {
336
357
  searchPathCommands: astryxCommandsOnSearchPath().map(row => ({
337
358
  ...row,
338
359
  upgrade: row.cliRoot ? globalUpgradeCommand(row.cliRoot) : null,
360
+ // A package runner's temporary install, which it puts first on the
361
+ // search path only for the run it starts.
362
+ runner: row.cliRoot ? installPlaceOf(row.cliRoot).runner : false,
339
363
  })),
340
364
  };
341
365
  }
@@ -348,11 +372,12 @@ export function outsideProject(/** @type {string} */ cwd) {
348
372
  /**
349
373
  * The commands that bring a project's own CLI and Core to one release, with
350
374
  * the project's package manager: Core up to the CLI, then its codemods, when
351
- * the CLI is newer; else the CLI to the Core's release.
375
+ * the CLI is newer; else the CLI to the Core's release. Null when no
376
+ * command fits (see `alignCliAndCore`).
352
377
  * @param {string} cwd
353
378
  * @param {string} cli
354
379
  * @param {string} core
355
- * @returns {string}
380
+ * @returns {string | null}
356
381
  */
357
382
  export function alignCommand(cwd, cli, core) {
358
383
  return alignCliAndCore({cwd, cli, core});
@@ -380,30 +405,35 @@ export function projectHasOwnCli(cwd) {
380
405
 
381
406
  /**
382
407
  * The command that adds the CLI at `version` with the project's package
383
- * manager.
408
+ * manager, and the Core it matches: from a folder whose package.json declares
409
+ * no Astryx package, in the Astryx project above at that project's Core; null
410
+ * when there is none (see `cliInstallAdvice`).
384
411
  * @param {string} cwd
385
412
  * @param {string} version
386
- * @returns {string}
413
+ * @returns {{command: string, core: string} | null}
387
414
  */
388
415
  export function addCliCommandFor(cwd, version) {
389
- return addCliCommand(projectRootOf(readReleaseFacts(cwd)) ?? cwd, version);
416
+ const advice = cliInstallAdvice({cwd, core: version});
417
+ return advice?.command ? {command: advice.command, core: advice.core} : null;
390
418
  }
391
419
 
392
420
  /**
393
- * The command that adds a package with the folder's package manager, read
394
- * from its lockfiles and `packageManager` field.
421
+ * The command that adds a package to the project of `cwd`; null in a folder
422
+ * that belongs to no project or whose package.json is not the project's (see
423
+ * `projectAddCommand`).
395
424
  * @param {string} cwd
396
- * @returns {(name: string) => string}
425
+ * @returns {((name: string) => string) | null}
397
426
  */
398
427
  export function installCommandFor(cwd) {
399
- const pm = detectPackageManager(cwd);
400
- const verb =
401
- pm === 'pnpm'
402
- ? 'pnpm add'
403
- : pm === 'yarn'
404
- ? 'yarn add'
405
- : pm === 'bun'
406
- ? 'bun add'
407
- : 'npm install';
408
- return name => `${verb} ${name}`;
428
+ return projectAddCommand(cwd);
429
+ }
430
+
431
+ /**
432
+ * Whether `cwd` is inside a project whose package.json is not the project's,
433
+ * so advice points at the project's folder (see `installFolder`).
434
+ * @param {string} cwd
435
+ * @returns {boolean}
436
+ */
437
+ export function insideProjectElsewhere(cwd) {
438
+ return installFolder(cwd)?.moved === true;
409
439
  }
@@ -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]
@@ -259,15 +263,18 @@ export function checkComputerIntegrations(ctx: ComputerContext): DoctorCheck;
259
263
  * Inside a project, the integrations installed for the computer that the
260
264
  * project does not install: available, never used (spec AST-081 FR12).
261
265
  * Always info.
262
- * @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: (name: string) => string}} input
266
+ * @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: ((name: string) => string) | null, elsewhere?: boolean}} input
263
267
  * `install`: the command that adds a package with the project's package
264
- * manager (read by the adapter)
268
+ * manager (read by the adapter); null when the folder belongs to no
269
+ * project, or `elsewhere`: its package.json is not the project's, where the
270
+ * fix points at the project's folder
265
271
  * @returns {DoctorCheck}
266
272
  */
267
- export function checkComputerIntegrationsAvailable({ installed, candidates, install }: {
273
+ export function checkComputerIntegrationsAvailable({ installed, candidates, install, elsewhere }: {
268
274
  installed: Set<string>;
269
275
  candidates: import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[];
270
- install: (name: string) => string;
276
+ install: ((name: string) => string) | null;
277
+ elsewhere?: boolean;
271
278
  }): DoctorCheck;
272
279
  /**
273
280
  * Run all diagnostic checks and return a structured report.
@@ -443,6 +450,16 @@ export type ComputerContext = {
443
450
  * the person's choices about the computer-level agent text
444
451
  */
445
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;
446
463
  /**
447
464
  * the folder doctor runs in, for the printed fix
448
465
  */
@@ -484,6 +501,7 @@ export type ComputerContext = {
484
501
  */
485
502
  searchPathCommands?: (import("../../foundation/env/search-path.mjs").SearchPathCommand & {
486
503
  upgrade?: string | null;
504
+ runner?: boolean;
487
505
  })[] | undefined;
488
506
  /**
489
507
  * the integrations installed beside the running CLI
@@ -65,8 +65,9 @@ import {typedEdges} from '../docs/node/node.mjs';
65
65
  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
- import {availableLine, upgradeLine} from '../../foundation/release/notices.mjs';
69
- import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
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';
70
+ import {alignCommand, addCliCommandFor, computerAgentTextState, installCommandFor, insideProjectElsewhere, projectCoreVersion, projectHasOwnCli, computerIntegrationsOutside, computerIntegrationsToAdd, displayHomePath, outsideProject, releaseFacts} from './_adapter.mjs';
70
71
 
71
72
  /**
72
73
  * @typedef {'pass'|'warn'|'fail'|'info'} DoctorStatus
@@ -286,15 +287,25 @@ export function checkVersionAlignment(ctx) {
286
287
  // the run (spec AST-081 FR2): say so, and how to add the CLI at Core's
287
288
  // version.
288
289
  if (ctx.ownCli === false) {
290
+ // The same comparison as the daily hint: the CLI against the Core the
291
+ // run reads (spec AST-081 FR2). The command adds the CLI in the project
292
+ // spec:AST-040 FR9 defines; from a folder inside it whose package.json
293
+ // is not the project's, or in no project, the fix says how to reach one.
294
+ const add = addCliCommandFor(ctx.cwd, coreVersion);
295
+ const matches = coreVersion === cliVersion;
296
+ const fix = add
297
+ ? `${matches ? 'To pin it for the team and CI' : 'To match'}, run: ${add.command}.`
298
+ : matches
299
+ ? null
300
+ : NO_PROJECT_FIX;
289
301
  return {
290
302
  id: 'version-alignment',
291
303
  label: '@astryxdesign/core <-> @astryxdesign/cli alignment',
292
- status: coreVersion === cliVersion ? 'info' : 'warn',
293
- message:
294
- coreVersion === cliVersion
295
- ? `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered and matches its Core.`
296
- : `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered while its Core is ${coreVersion}.`,
297
- fix: `${coreVersion === cliVersion ? 'To pin it for the team and CI' : 'To match'}, run: ${addCliCommandFor(ctx.cwd, coreVersion)}.`,
304
+ status: matches ? 'info' : 'warn',
305
+ message: matches
306
+ ? `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered and matches its Core.`
307
+ : `This project has no Astryx CLI installed; CLI ${cliVersion}, the one you started, answered while its Core is ${coreVersion}.`,
308
+ ...(fix ? {fix} : {}),
298
309
  };
299
310
  }
300
311
  // The project's own CLI answers this project whatever its version
@@ -308,10 +319,31 @@ export function checkVersionAlignment(ctx) {
308
319
  message: drift
309
320
  ? `This project's CLI ${cliVersion} answers it, but its Core is ${coreVersion}: templates, docs, and agent text come from CLI ${cliVersion}, components from Core ${coreVersion}.`
310
321
  : `@astryxdesign/core v${coreVersion} is in step with @astryxdesign/cli v${cliVersion}.`,
311
- ...(drift ? {fix: `To align them, run: ${alignCommand(ctx.cwd, cliVersion, coreVersion)}.`} : {}),
322
+ ...(drift ? alignFix(ctx.cwd, cliVersion, coreVersion) : {}),
312
323
  };
313
324
  }
314
325
 
326
+ /**
327
+ * The fix for a CLI and Core on different releases, when a command fits.
328
+ * @param {string} cwd
329
+ * @param {string} cli
330
+ * @param {string} core
331
+ * @returns {{fix?: string}}
332
+ */
333
+ function alignFix(cwd, cli, core) {
334
+ // From a folder inside a project whose package.json is not the project's,
335
+ // aligning the project would leave this warning in place, so no command
336
+ // fits there (alignCommand returns none): point at the project instead.
337
+ const command = alignCommand(cwd, cli, core);
338
+ return {fix: command ? `To align them, run: ${command}.` : NO_PROJECT_FIX};
339
+ }
340
+
341
+ /**
342
+ * The fix where no install command fits: the folder's package.json is not an
343
+ * Astryx project's (spec AST-040 FR9), and adding there would make it one.
344
+ */
345
+ const NO_PROJECT_FIX = RUN_FROM_PROJECT;
346
+
315
347
  /**
316
348
  * Check 5 — astryx.config.mjs (if present) loads and has a valid shape.
317
349
  * @param {DoctorContext} ctx
@@ -1460,6 +1492,10 @@ export function checkCliCommand(ctx) {
1460
1492
  * each file of the computer-level agent text against this release's rendering
1461
1493
  * @property {import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings} [agentTextSettings]
1462
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
1463
1499
  * @property {string} [cwd] the folder doctor runs in, for the printed fix
1464
1500
  * @property {import('../../foundation/release/notices.mjs').GlobalBehind | null} [globalBehind]
1465
1501
  * the CLI installed for the computer, when it is older than the newest
@@ -1472,7 +1508,7 @@ export function checkCliCommand(ctx) {
1472
1508
  * the newest update notice that did not print, and why (diagnostic only)
1473
1509
  * @property {{pid: number | null, host: string | null, since: number} | null} [stateLock]
1474
1510
  * who holds the state file's lock now (diagnostic only)
1475
- * @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]
1476
1512
  * every `astryx` on the search path, with the command that upgrades it
1477
1513
  * the `astryx` commands on the search path, in order
1478
1514
  * @property {import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]} [computerIntegrations]
@@ -1559,6 +1595,7 @@ function checkFailureNote(failed) {
1559
1595
  const SKIP_REASONS = {
1560
1596
  'already-shown': 'it had already printed that day',
1561
1597
  'no-newer': 'no newer release was known',
1598
+ 'no-project': 'the folder belongs to no Astryx project, so no install command fits',
1562
1599
  };
1563
1600
 
1564
1601
  /**
@@ -1682,6 +1719,8 @@ export function checkComputerAgentText(ctx) {
1682
1719
  };
1683
1720
  }
1684
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;
1685
1724
  const fix = `Run \`${formatCliCommand('astryx init --user', ctx.cwd)}\`.`;
1686
1725
  const [file, ...links] = entries;
1687
1726
  const home = (/** @type {{path: string}} */ e) => displayHomePath(e.path);
@@ -1710,9 +1749,29 @@ export function checkComputerAgentText(ctx) {
1710
1749
  };
1711
1750
  }
1712
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
+ }
1713
1772
  return {
1714
1773
  ...base,
1715
- message: `${current ? 'The computer-level agent text matches this release' : "The computer-level agent text differs from this release's"}: ${home(file)}.${linkNote}`,
1774
+ message: `${status}${linkNote}`,
1716
1775
  ...(!current || missing.length > 0 || dangling.length > 0 ? {fix} : {}),
1717
1776
  };
1718
1777
  }
@@ -1764,12 +1823,14 @@ export function checkComputerIntegrations(ctx) {
1764
1823
  * Inside a project, the integrations installed for the computer that the
1765
1824
  * project does not install: available, never used (spec AST-081 FR12).
1766
1825
  * Always info.
1767
- * @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: (name: string) => string}} input
1826
+ * @param {{installed: Set<string>, candidates: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], install: ((name: string) => string) | null, elsewhere?: boolean}} input
1768
1827
  * `install`: the command that adds a package with the project's package
1769
- * manager (read by the adapter)
1828
+ * manager (read by the adapter); null when the folder belongs to no
1829
+ * project, or `elsewhere`: its package.json is not the project's, where the
1830
+ * fix points at the project's folder
1770
1831
  * @returns {DoctorCheck}
1771
1832
  */
1772
- export function checkComputerIntegrationsAvailable({installed, candidates, install}) {
1833
+ export function checkComputerIntegrationsAvailable({installed, candidates, install, elsewhere = false}) {
1773
1834
  const available = candidates.filter(c => !installed.has(c.name));
1774
1835
  const base = {id: 'computer-integrations', label: 'Integrations installed for this computer', status: /** @type {const} */ ('info')};
1775
1836
  if (available.length === 0) {
@@ -1779,7 +1840,11 @@ export function checkComputerIntegrationsAvailable({installed, candidates, insta
1779
1840
  return {
1780
1841
  ...base,
1781
1842
  message: `Installed for this computer but not in this project, so not used here: ${available.map(c => c.name).join(', ')}.`,
1782
- fix: `To use one in this project, run ${available.map(c => `\`${add(c.name)}\``).join(' or ')}.`,
1843
+ ...(add
1844
+ ? {fix: `To use one in this project, run ${available.map(c => `\`${add(c.name)}\``).join(' or ')}.`}
1845
+ : elsewhere
1846
+ ? {fix: NO_PROJECT_FIX}
1847
+ : {}),
1783
1848
  };
1784
1849
  }
1785
1850
 
@@ -2038,7 +2103,7 @@ export async function runChecks(options = {}) {
2038
2103
  {
2039
2104
  const loadedNames = (project?.loadedIntegrations ?? []).map((/** @type {{name: string}} */ i) => i.name);
2040
2105
  const candidates = await computerIntegrationsToAdd(cwd, loadedNames);
2041
- checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd)}));
2106
+ checks.push(checkComputerIntegrationsAvailable({installed: new Set(loadedNames), candidates, install: installCommandFor(cwd), elsewhere: insideProjectElsewhere(cwd)}));
2042
2107
  }
2043
2108
  checks.push(await checkAuthoringDocs(ctx));
2044
2109
  checks.push(await checkCliDocs(ctx));
@@ -31,7 +31,9 @@ import {
31
31
  checkIntegrationIssues,
32
32
  checkVersionAlignment,
33
33
  checkPackageManager,
34
+ checkComputerIntegrationsAvailable,
34
35
  } from './doctor.mjs';
36
+ import {installCommandFor} from './_adapter.mjs';
35
37
  import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
36
38
  import {Project} from '../../foundation/config/project.mjs';
37
39
 
@@ -223,7 +225,13 @@ describe("doctor — the project's own CLI and Core on different releases", () =
223
225
  ).version;
224
226
  /** @param {string} core */
225
227
  const at = core => {
228
+ // A project as spec:AST-040 FR9 defines it: its package.json declares
229
+ // an Astryx package.
226
230
  const dir = mkProject({
231
+ 'package.json': JSON.stringify({
232
+ name: 'app',
233
+ dependencies: {'@astryxdesign/core': core},
234
+ }),
227
235
  'package-lock.json': '{}',
228
236
  'node_modules/@astryxdesign/core/package.json': JSON.stringify({
229
237
  name: '@astryxdesign/core',
@@ -257,6 +265,10 @@ describe("doctor — the project's own CLI and Core on different releases", () =
257
265
 
258
266
  it('in a project with no CLI of its own, warns that the started copy answered and names the command that adds the CLI at Core', () => {
259
267
  const dir = mkProject({
268
+ 'package.json': JSON.stringify({
269
+ name: 'app',
270
+ dependencies: {'@astryxdesign/core': '0.0.1'},
271
+ }),
260
272
  'package-lock.json': '{}',
261
273
  'node_modules/@astryxdesign/core/package.json': JSON.stringify({
262
274
  name: '@astryxdesign/core',
@@ -279,6 +291,52 @@ describe("doctor — the project's own CLI and Core on different releases", () =
279
291
  });
280
292
  });
281
293
 
294
+ describe('the command that adds an integration installed for the computer', () => {
295
+ const app = () =>
296
+ mkProject({
297
+ 'package.json': JSON.stringify({
298
+ name: 'app',
299
+ dependencies: {'@astryxdesign/core': '0.7.0'},
300
+ }),
301
+ 'pnpm-lock.yaml': '',
302
+ 'tools/codegen/package.json': JSON.stringify({name: 'codegen'}),
303
+ });
304
+
305
+ it('adds it in the project, with its package manager', () => {
306
+ const dir = app();
307
+ expect(installCommandFor(dir)?.('@acme/a')).toBe('pnpm add @acme/a');
308
+ });
309
+
310
+ // A package.json that is not the project's (spec AST-040 FR9): a run
311
+ // there loads integrations from it, so a package added to the project
312
+ // stays unused there. No command; the fix points at the project.
313
+ it("from a tool folder inside the project, names no command and points at the project's folder", () => {
314
+ const dir = app();
315
+ expect(installCommandFor(path.join(dir, 'tools', 'codegen'))).toBeNull();
316
+ const c = checkComputerIntegrationsAvailable({
317
+ installed: new Set(),
318
+ candidates: [/** @type {any} */ ({name: '@acme/a'})],
319
+ install: null,
320
+ elsewhere: true,
321
+ });
322
+ expect(c.fix).toBe(
323
+ "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.",
324
+ );
325
+ });
326
+
327
+ it('in a folder that belongs to no project, names no command', () => {
328
+ const dir = mkProject({'package.json': JSON.stringify({name: 'tool'})});
329
+ expect(installCommandFor(dir)).toBeNull();
330
+ const c = checkComputerIntegrationsAvailable({
331
+ installed: new Set(),
332
+ candidates: [/** @type {any} */ ({name: '@acme/a'})],
333
+ install: null,
334
+ });
335
+ expect(c.status).toBe('info');
336
+ expect(c).not.toHaveProperty('fix');
337
+ });
338
+ });
339
+
282
340
  describe('checkCliCommand', () => {
283
341
  it('is informational when no integration declares a command', () => {
284
342
  const dir = mkProject({'pnpm-lock.yaml': ''});
@@ -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'