@astryxdesign/cli 0.7.3-canary.f8fad28 → 0.7.3-canary.fba04ed

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 (55) 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/tree.mjs +2 -1
  12. package/api/build/tree.test.mjs +27 -27
  13. package/api/component/_adapter.mjs +39 -5
  14. package/api/discover/_adapter.d.mts +1 -2
  15. package/api/discover/_adapter.mjs +6 -8
  16. package/api/discover/discover.mjs +0 -1
  17. package/api/docs/_adapter.mjs +4 -0
  18. package/api/doctor/_adapter.d.mts +33 -13
  19. package/api/doctor/_adapter.mjs +55 -25
  20. package/api/doctor/doctor.d.mts +23 -5
  21. package/api/doctor/doctor.mjs +81 -16
  22. package/api/doctor/doctor.test.mjs +58 -0
  23. package/api/integration/validate-integration-gaps.test.mjs +3 -0
  24. package/api/integration/validateIntegration.doc.mjs +1 -1
  25. package/api/search/_gather-templates.d.mts +0 -1
  26. package/api/search/_gather-templates.mjs +25 -0
  27. package/api/search/search.integration-block.test.mjs +100 -0
  28. package/api/template/template.mjs +5 -1
  29. package/assets/docs/tree/checks.doc.mjs +1 -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.d.mts +37 -0
  42. package/foundation/integrations/public-imports.mjs +839 -46
  43. package/foundation/integrations/public-imports.test.mjs +971 -46
  44. package/foundation/release/cache.test.mjs +24 -21
  45. package/foundation/release/global-state.d.mts +8 -4
  46. package/foundation/release/global-state.mjs +4 -2
  47. package/foundation/release/notices.d.mts +62 -8
  48. package/foundation/release/notices.mjs +136 -25
  49. package/foundation/release/notices.test.mjs +21 -0
  50. package/foundation/text/string-utils.d.mts +2 -1
  51. package/foundation/text/string-utils.mjs +16 -5
  52. package/foundation/text/suggest-order.d.mts +72 -0
  53. package/foundation/text/suggest-order.mjs +363 -0
  54. package/foundation/text/suggest-order.test.mjs +259 -0
  55. package/package.json +9 -9
@@ -24,10 +24,18 @@ 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
- import {MARKER_END, MARKER_START} from './agent-doc-state.mjs';
32
+ import {
33
+ MARKER_END,
34
+ MARKER_START,
35
+ SELF_CHECK_CSS,
36
+ WORKFLOW_STEPS,
37
+ WORKFLOW_TITLE,
38
+ } from './agent-doc-state.mjs';
31
39
  import {runWithCliDoor} from '../env/cli-command.mjs';
32
40
  import {runCli} from '../../test-utils/run-cli.mjs';
33
41
  import {parse as parseYaml} from 'yaml';
@@ -123,17 +131,106 @@ describe('renderComputerAgentText', () => {
123
131
 
124
132
  it('stays short, and tells agents to read docs through the CLI', () => {
125
133
  const text = renderComputerAgentText({command: 'astryx'});
126
- expect(text.split('\n').length).toBeLessThanOrEqual(15);
134
+ expect(text.split('\n').length).toBeLessThanOrEqual(22);
127
135
  expect(text).toContain(
128
136
  "Then read `astryx component <Name>` or `astryx docs <topic>`, not the package's files.",
129
137
  );
130
138
  });
131
139
 
140
+ // Discovery alone leaves the build to the agent's own page route, which
141
+ // may not install packages; the skill names the route and the project
142
+ // agent docs' own workflow lines.
143
+ it('gives the build workflow: a project with Astryx installed and init run, the shared template steps, then check and deliver the build', () => {
144
+ const text = renderComputerAgentText({command: 'astryx'});
145
+ expect(text).toContain(
146
+ 'To build UI, work in a project folder (create one if there is none). Add `@astryxdesign/core` and `@astryxdesign/cli` to a new project or one without `@astryxdesign/core`; to a project that already has `@astryxdesign/core`, add `@astryxdesign/cli` at the same version. Run `astryx init` there and follow the agent docs it writes.',
147
+ );
148
+ for (const line of [WORKFLOW_TITLE, ...WORKFLOW_STEPS]) {
149
+ expect(text).toContain(line);
150
+ }
151
+ expect(text).toContain(`re-read each file; ${SELF_CHECK_CSS}.`);
152
+ expect(text).toContain('deliver that build');
153
+ });
154
+
132
155
  it("uses the host's door when one is set", () => {
133
156
  const text = runWithCliDoor('acme astryx', () => renderComputerAgentText());
134
157
  expect(text).toContain("`acme astryx search '<what you need>'`");
135
158
  expect(text).not.toMatch(/`astryx /u);
136
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
+ });
137
234
  });
138
235
 
139
236
  describe('the link table', () => {
@@ -18,6 +18,24 @@ export function splitSpecifier(specifier: string): {
18
18
  * @returns {ImportStatement[]}
19
19
  */
20
20
  export function readImports(text: string): ImportStatement[];
21
+ /**
22
+ * Every name (runtime or type) a module exports, and whether the list is
23
+ * complete: an `export *` from another package, `export =`, or a module that
24
+ * does not parse leaves it incomplete, and then no name is judged missing.
25
+ * @param {string} file
26
+ * @param {ExportNameCache} [cache] export lists already read in this check
27
+ * @returns {{names: Set<string>, complete: boolean, types: Set<string>, typed: boolean}}
28
+ * `types`: the names exported only as types (an interface, a type alias,
29
+ * `export type`); `typed`: the list includes every type the module
30
+ * exports (TypeScript source, or a JavaScript module whose declaration
31
+ * file was read in full), so a name absent from it is absent as a type too
32
+ */
33
+ export function moduleExportNames(file: string, cache?: ExportNameCache): {
34
+ names: Set<string>;
35
+ complete: boolean;
36
+ types: Set<string>;
37
+ typed: boolean;
38
+ };
21
39
  /**
22
40
  * Every public-import finding for one package, as notes, and the report of
23
41
  * what could not be judged. It returns no issues: the notes are listed
@@ -56,6 +74,16 @@ export type ImportStatement = {
56
74
  */
57
75
  typeOnly?: boolean | undefined;
58
76
  };
77
+ /**
78
+ * Export lists read during one public-import check, by file. Scoped to that
79
+ * check, so a later check in the same process rereads every module.
80
+ */
81
+ export type ExportNameCache = Map<string, {
82
+ names: Set<string>;
83
+ complete: boolean;
84
+ types: Set<string>;
85
+ typed: boolean;
86
+ }>;
59
87
  export type Context = {
60
88
  packageDir: string;
61
89
  /**
@@ -70,6 +98,15 @@ export type Context = {
70
98
  * what could not be judged
71
99
  */
72
100
  unchecked: PublicImportUnchecked[];
101
+ /**
102
+ * export lists read in this check
103
+ */
104
+ exportNames: ExportNameCache;
105
+ /**
106
+ * why no name is judged missing
107
+ * (a module augmentation in the package); null when none, unset until read
108
+ */
109
+ augmentation?: string | null | undefined;
73
110
  /**
74
111
  * the package.json `files` entries, normalized
75
112
  */