@astryxdesign/cli 0.6.3-canary.dea6813 → 0.6.3-canary.e7819e0

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 (176) hide show
  1. package/README.md +18 -32
  2. package/api/build/build.doc.mjs +3 -3
  3. package/api/build/build.test.mjs +3 -14
  4. package/api/build/build.type.d.mts +1 -35
  5. package/api/build/build.type.mjs +3 -24
  6. package/api/build/help/help.d.mts +5 -8
  7. package/api/build/help/help.mjs +6 -56
  8. package/api/component/component.doc.mjs +2 -11
  9. package/api/component/component.mjs +0 -29
  10. package/api/component/component.test.mjs +0 -38
  11. package/api/component/component.type.d.mts +1 -11
  12. package/api/component/component.type.mjs +1 -8
  13. package/api/discover/discover.doc.mjs +1 -1
  14. package/api/gap-report/gap-report.doc.mjs +4 -7
  15. package/api/init/init.doc.mjs +0 -4
  16. package/api/init/init.test.mjs +1 -41
  17. package/api/init/remove/remove.mjs +1 -1
  18. package/api/init/run/run.mjs +10 -20
  19. package/api/integration/add-contribution.mjs +0 -11
  20. package/api/integration/add-contribution.test.mjs +0 -80
  21. package/api/integration/integrationAdd.doc.mjs +4 -7
  22. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  23. package/api/integration/validate-integration.mjs +0 -2
  24. package/api/integration/validateIntegration.doc.mjs +1 -1
  25. package/api/json/parseResponse.doc.mjs +2 -2
  26. package/api/layout/expand/expand.mjs +5 -7
  27. package/api/layout/grammar/grammar.mjs +1 -2
  28. package/api/layout/layoutExpand.doc.mjs +1 -1
  29. package/api/search/search.d.mts +9 -2
  30. package/api/search/search.doc.mjs +1 -5
  31. package/api/search/search.mjs +3 -10
  32. package/api/search/search.test.mjs +0 -34
  33. package/api/swizzle/copy/copy.mjs +11 -28
  34. package/api/swizzle/swizzle.doc.mjs +1 -1
  35. package/api/template/copy/copy.mjs +23 -17
  36. package/api/template/copy/copy.test.mjs +0 -17
  37. package/api/template/template.doc.mjs +1 -2
  38. package/api/theme/add/add.mjs +3 -20
  39. package/api/theme/build/build.mjs +37 -114
  40. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  41. package/api/theme/build/font-warning.mjs +3 -3
  42. package/api/theme/build/font-warning.test.mjs +2 -5
  43. package/api/theme/palette/generate/generate.mjs +2 -7
  44. package/api/theme/palette/generate/generate.test.mjs +0 -96
  45. package/api/theme/palette/generate/generator.mjs +1 -8
  46. package/api/theme/palette/generate/generator.test.mjs +0 -10
  47. package/api/theme/template/template.mjs +2 -11
  48. package/api/theme/template/template.test.mjs +0 -15
  49. package/api/theme/themeBuild.doc.mjs +4 -7
  50. package/api/theme/themeTemplate.doc.mjs +1 -4
  51. package/api/upgrade/_adapter.mjs +4 -27
  52. package/api/upgrade/list/list.mjs +1 -2
  53. package/api/upgrade/status/status.mjs +2 -2
  54. package/api/upgrade/upgrade.doc.mjs +1 -2
  55. package/api/upgrade/upgrade.type.d.mts +0 -4
  56. package/api/upgrade/upgrade.type.mjs +0 -1
  57. package/assets/codemods/term-log.mjs +8 -32
  58. package/assets/codemods/term-log.test.mjs +1 -19
  59. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -47
  60. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +10 -57
  61. package/authoring/config/config.doc.mjs +1 -1
  62. package/authoring/config/type.ts +3 -15
  63. package/clients/cli/commands/blog.mjs +8 -23
  64. package/clients/cli/commands/blog.test.mjs +1 -42
  65. package/clients/cli/commands/build-theme.mjs +5 -5
  66. package/clients/cli/commands/build-theme.path-safety.test.mjs +1 -86
  67. package/clients/cli/commands/build-theme.variants.test.mjs +0 -76
  68. package/clients/cli/commands/build.doc.mjs +1 -4
  69. package/clients/cli/commands/build.mjs +47 -32
  70. package/clients/cli/commands/component/index.mjs +7 -2
  71. package/clients/cli/commands/component-package.test.mjs +0 -18
  72. package/clients/cli/commands/component-resolution.test.mjs +0 -21
  73. package/clients/cli/commands/component.test.mjs +0 -19
  74. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  75. package/clients/cli/commands/discover.broken-integration.test.mjs +0 -48
  76. package/clients/cli/commands/discover.doc.mjs +2 -4
  77. package/clients/cli/commands/discover.mjs +3 -3
  78. package/clients/cli/commands/doctor.mjs +16 -6
  79. package/clients/cli/commands/doctor.test.mjs +0 -42
  80. package/clients/cli/commands/gap-report.doc.mjs +5 -16
  81. package/clients/cli/commands/gap-report.test.mjs +0 -72
  82. package/clients/cli/commands/hook/index.mjs +17 -7
  83. package/clients/cli/commands/init.doc.mjs +8 -19
  84. package/clients/cli/commands/integration-add.doc.mjs +5 -21
  85. package/clients/cli/commands/interactive-guard.test.mjs +24 -101
  86. package/clients/cli/commands/json-contract.test.mjs +0 -33
  87. package/clients/cli/commands/layout-check.doc.mjs +3 -14
  88. package/clients/cli/commands/layout-expand.doc.mjs +4 -21
  89. package/clients/cli/commands/layout.doc.mjs +2 -2
  90. package/clients/cli/commands/layout.mjs +9 -21
  91. package/clients/cli/commands/search.doc.mjs +3 -6
  92. package/clients/cli/commands/search.mjs +7 -17
  93. package/clients/cli/commands/search.test.mjs +0 -75
  94. package/clients/cli/commands/swizzle.doc.mjs +1 -2
  95. package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -42
  96. package/clients/cli/commands/template.doc.mjs +6 -28
  97. package/clients/cli/commands/theme-add.doc.mjs +1 -2
  98. package/clients/cli/commands/theme-build.doc.mjs +6 -7
  99. package/clients/cli/commands/theme-palette-generate.test.mjs +0 -19
  100. package/clients/cli/commands/theme-template.behavior.test.mjs +0 -12
  101. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  102. package/clients/cli/commands/upgrade.doc.mjs +6 -17
  103. package/clients/cli/index.mjs +30 -13
  104. package/clients/cli/lib/cli-error.test.mjs +0 -7
  105. package/clients/cli/lib/component-format.mjs +9 -9
  106. package/clients/cli/lib/component-format.test.mjs +1 -1
  107. package/clients/cli/lib/define-command.mjs +6 -32
  108. package/clients/cli/lib/hook-format.mjs +5 -5
  109. package/clients/cli/lib/json-shim.mjs +2 -38
  110. package/clients/cli/lib/json-shim.test.mjs +0 -83
  111. package/clients/cli/lib/manifest.d.ts +0 -2
  112. package/clients/cli/lib/manifest.mjs +0 -22
  113. package/clients/cli/lib/manifest.test.mjs +0 -17
  114. package/clients/cli/lib/update-check.mjs +83 -0
  115. package/clients/cli/lib/update-check.test.mjs +137 -0
  116. package/clients/cli/update-hint-commands.test.mjs +54 -0
  117. package/foundation/agent-docs/agent-docs.d.mts +0 -4
  118. package/foundation/agent-docs/agent-docs.mjs +3 -69
  119. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +4 -266
  120. package/foundation/config/integration-debug.test.mjs +3 -28
  121. package/foundation/config/project.mjs +9 -123
  122. package/foundation/config/project.test.mjs +0 -126
  123. package/foundation/discovery/template-adapter.d.mts +5 -14
  124. package/foundation/discovery/template-adapter.mjs +25 -292
  125. package/foundation/fs/module-loader.d.mts +0 -1
  126. package/foundation/fs/module-loader.mjs +1 -50
  127. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +94 -129
  128. package/foundation/integrations/autolink.mjs +1 -6
  129. package/foundation/response/base.d.ts +4 -8
  130. package/foundation/response/error-codes.doc.mjs +2 -1
  131. package/foundation/response/error-codes.mjs +1 -1
  132. package/foundation/response/error-codes.test.mjs +0 -83
  133. package/foundation/response/json-contract.test.mjs +0 -11
  134. package/foundation/response/json.d.mts +2 -4
  135. package/foundation/response/json.mjs +10 -8
  136. package/foundation/response/response-types.doc.mjs +3 -3
  137. package/foundation/xle/expand.d.mts +0 -2
  138. package/foundation/xle/expand.mjs +2 -3
  139. package/package.json +9 -9
  140. package/api/integration/add-contribution.component-names.test.mjs +0 -120
  141. package/api/json/envelope-types.test.mjs +0 -76
  142. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  143. package/api/search/search-return-type.test.mjs +0 -54
  144. package/api/theme/add/add.binary.test.mjs +0 -91
  145. package/api/theme/add/add.staging.test.mjs +0 -66
  146. package/api/theme/build/build.receipt-doc.test.mjs +0 -111
  147. package/api/upgrade/list/list.test.mjs +0 -73
  148. package/authoring/config/debug-composition.test.mjs +0 -92
  149. package/clients/cli/command-load-failure.test.mjs +0 -83
  150. package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -161
  151. package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
  152. package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -50
  153. package/clients/cli/commands/build.playbook.test.mjs +0 -75
  154. package/clients/cli/commands/build.text-fields.test.mjs +0 -40
  155. package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
  156. package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
  157. package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
  158. package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
  159. package/clients/cli/commands/init.flag-help.test.mjs +0 -153
  160. package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
  161. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  162. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  163. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
  164. package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
  165. package/clients/cli/commands/template.flag-help.test.mjs +0 -117
  166. package/clients/cli/commands/template.path-help.test.mjs +0 -40
  167. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -87
  168. package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -188
  169. package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -88
  170. package/clients/cli/latest-version-env.test.mjs +0 -50
  171. package/clients/cli/lib/doc-text-ascii.test.mjs +0 -82
  172. package/clients/cli/lib/exit-codes.test.mjs +0 -97
  173. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -248
  174. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
  175. package/foundation/fs/module-loader.stdout.test.mjs +0 -332
  176. package/foundation/xle/expand.test.mjs +0 -54
@@ -29,11 +29,11 @@ export const doc = {
29
29
  {
30
30
  flag: '--limit <n>',
31
31
  param: 'options.limit',
32
- description: 'Max number of results, a positive integer (default 20)',
32
+ description: 'Max number of results (default 20)',
33
33
  },
34
34
  {
35
35
  flag: '--verbose',
36
- description: "Also print each result's score and match reason",
36
+ description: 'Verbose output (include import paths and match reason)',
37
37
  },
38
38
  ],
39
39
  examples: [
@@ -45,10 +45,7 @@ export const doc = {
45
45
  ],
46
46
  exitCodes: [
47
47
  {code: 0, when: 'success (including zero matches)'},
48
- {
49
- code: 1,
50
- when: 'invalid --type, a --limit that is not a positive integer, or @astryxdesign/core cannot be found',
51
- },
48
+ {code: 1, when: 'invalid --type or a non-positive --limit'},
52
49
  ],
53
50
  related: ['component', 'hook', 'docs', 'template', 'build'],
54
51
  };
@@ -16,7 +16,7 @@
16
16
  * astryx search button Ranked results across all domains
17
17
  * astryx search modal --type component Filter to a single domain
18
18
  * astryx search forms --limit 5 Cap the result count
19
- * astryx search button --verbose Also print score / reason
19
+ * astryx search button --verbose Verbose (include import / reason)
20
20
  * astryx search button --json Typed JSON envelope
21
21
  */
22
22
 
@@ -54,10 +54,11 @@ export function registerSearch(program) {
54
54
  // Never let the nudge break the command.
55
55
  }
56
56
 
57
- // Number(), not parseInt(): parseInt truncates `1.5` and `5abc` into
58
- // integers the API would reject. The API validates the value, so the
59
- // flag and `search({limit})` accept and refuse the same inputs.
60
- const limit = options.limit != null ? Number(options.limit) : 20;
57
+ // Parse --limit to a number; the API validates it (positive integer) and
58
+ // throws ERR_INVALID_ARGUMENT, so we pass NaN through rather than
59
+ // pre-rejecting with a generic code here.
60
+ const limit =
61
+ options.limit != null ? Number.parseInt(options.limit, 10) : 20;
61
62
 
62
63
  /** @type {import('../../../api/search/search.type.mjs').SearchResponse} */
63
64
  let result;
@@ -116,25 +117,14 @@ export function registerSearch(program) {
116
117
  ? [
117
118
  'name',
118
119
  'domain',
119
- 'title',
120
120
  'displayName',
121
- 'kind',
122
121
  'score',
123
122
  'reason',
124
123
  'import',
125
124
  'description',
126
125
  'command',
127
126
  ]
128
- : [
129
- 'name',
130
- 'domain',
131
- 'title',
132
- 'displayName',
133
- 'kind',
134
- 'import',
135
- 'description',
136
- 'command',
137
- ];
127
+ : ['name', 'domain', 'displayName', 'import', 'description', 'command'];
138
128
 
139
129
  // The heading mirrors the JSON: `matchCount` is what matched, and the
140
130
  // records below are the slice `--limit` allowed. Saying only "(20)" when
@@ -11,8 +11,6 @@
11
11
  */
12
12
 
13
13
  import {describe, it, expect} from 'vitest';
14
- import * as fs from 'node:fs';
15
- import * as os from 'node:os';
16
14
  import * as path from 'node:path';
17
15
  import {fileURLToPath} from 'node:url';
18
16
  import {search, scoreCandidate, SEARCH_DOMAINS} from '../../../api/search/search.mjs';
@@ -30,33 +28,6 @@ const OPTS = {cwd: REPO_ROOT};
30
28
  // the vitest per-test timeout. Give both the same generous scan budget.
31
29
  const SCAN_TIMEOUT = 30_000;
32
30
 
33
- /**
34
- * A JSON value as the formatters print it (they normalize typography to ASCII).
35
- * @param {unknown} value
36
- */
37
- function asText(value) {
38
- return (Array.isArray(value) ? value.join(', ') : String(value))
39
- .replace(/[\u2014\u2013]/g, '-')
40
- .replace(/[\u2018\u2019]/g, "'")
41
- .replace(/[\u201C\u201D]/g, '"')
42
- .replace(/\u2026/g, '...')
43
- .replace(/\u00a0/g, ' ')
44
- .trimEnd();
45
- }
46
-
47
- /**
48
- * Whether some text line prints `key:` with this value. The command field gains
49
- * the caller's invocation prefix, so the value is matched as the line's end; a
50
- * multi-line value is matched by its first line.
51
- * @param {string[]} lines
52
- * @param {string} key
53
- * @param {unknown} value
54
- */
55
- function printsField(lines, key, value) {
56
- const shown = asText(value).split('\n')[0].trimEnd();
57
- return lines.some(line => line.startsWith(`${key}:`) && line.trimEnd().endsWith(shown));
58
- }
59
-
60
31
  describe('search() API — ranking', () => {
61
32
  it('ranks an exact component name match first', async () => {
62
33
  const {data} = await search('button', OPTS);
@@ -201,20 +172,6 @@ describe('search CLI — exit codes + JSON contract', () => {
201
172
  expect(r.status).toBe(1);
202
173
  });
203
174
 
204
- it.each(['1.5', '5abc'])(
205
- 'refuses --limit %s like search({limit}) does, in both modes',
206
- async value => {
207
- await expect(
208
- search('x', {...OPTS, limit: Number(value)}),
209
- ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
210
- const json = await runCli(['--json', 'search', 'x', '--limit', value], REPO_ROOT);
211
- expect(json.status).toBe(1);
212
- expect(JSON.parse(json.stdout)).toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
213
- const text = await runCli(['search', 'x', '--limit', value], REPO_ROOT);
214
- expect(text.status).toBe(1);
215
- },
216
- );
217
-
218
175
  it('emits a valid --json envelope', async () => {
219
176
  const r = await runCli(['--json', 'search', 'button'], REPO_ROOT);
220
177
  expect(r.status).toBe(0);
@@ -266,25 +223,6 @@ describe('search CLI — exit codes + JSON contract', () => {
266
223
  expect(r.stdout).toContain('description:');
267
224
  });
268
225
 
269
- it('prints every result field under its JSON key (score and reason with --verbose)', async () => {
270
- // One query that reaches all four domains, so every per-domain field shows.
271
- const args = ['search', 'theme', '--limit', '60'];
272
- const env = JSON.parse((await runCli(['--json', ...args], REPO_ROOT)).stdout);
273
- expect(new Set(env.data.results.map(r => r.domain))).toEqual(new Set(SEARCH_DOMAINS));
274
- const plain = (await runCli(args, REPO_ROOT)).stdout.split('\n');
275
- const verbose = (await runCli([...args, '--verbose'], REPO_ROOT)).stdout.split('\n');
276
- for (const result of env.data.results) {
277
- for (const [key, value] of Object.entries(result)) {
278
- if (value == null || value === '') continue;
279
- const label = `${result.domain} ${result.name}: ${key}`;
280
- expect(printsField(verbose, key, value), label).toBe(true);
281
- if (key !== 'score' && key !== 'reason') {
282
- expect(printsField(plain, key, value), label).toBe(true);
283
- }
284
- }
285
- }
286
- }, 90_000);
287
-
288
226
  it('--verbose exits 0 and prints import/match detail', async () => {
289
227
  // Regression: the boolean verbose flag was named --detail, which collided
290
228
  // with the value-taking global `--detail <level>` — a bare `search
@@ -298,17 +236,4 @@ describe('search CLI — exit codes + JSON contract', () => {
298
236
  expect(r.stdout).toContain('score:');
299
237
  expect(r.stdout).toContain('reason:');
300
238
  });
301
-
302
- it('exits 1 with ERR_CORE_NOT_FOUND when no @astryxdesign/core is reachable', async () => {
303
- const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-cli-no-core-'));
304
- try {
305
- const json = await runCli(['--json', 'search', 'button'], empty);
306
- expect(json.status).toBe(1);
307
- expect(JSON.parse(json.stdout)).toMatchObject({code: 'ERR_CORE_NOT_FOUND'});
308
- const text = await runCli(['search', 'button'], empty);
309
- expect(text.status).toBe(1);
310
- } finally {
311
- fs.rmSync(empty, {recursive: true, force: true});
312
- }
313
- });
314
239
  }, SCAN_TIMEOUT);
@@ -40,8 +40,7 @@ export const doc = {
40
40
  {
41
41
  flag: '-f, --overwrite',
42
42
  param: 'options.overwrite',
43
- description:
44
- 'Replace existing files. Without it, existing files fail the command with ERR_FILE_EXISTS and nothing is written',
43
+ description: 'Overwrite existing files without prompting',
45
44
  },
46
45
  ],
47
46
  examples: [
@@ -74,37 +74,6 @@ describe('swizzle path safety', () => {
74
74
  expect(fs.existsSync(absTarget)).toBe(false);
75
75
  });
76
76
 
77
- it('rejects a component directory that is a symlink out of the project', async () => {
78
- const {project, outside} = buildFakeRepo(tmpDir);
79
- const base = path.join(project, 'components', 'astryx');
80
- fs.mkdirSync(base, {recursive: true});
81
- fs.symlinkSync(outside, path.join(base, 'Button'));
82
-
83
- const result = await runCli(['--json', 'swizzle', 'Button'], project);
84
-
85
- expect(result.code).not.toBe(0);
86
- expect(JSON.parse(result.stdout).code).toBe('ERR_PATH_TRAVERSAL');
87
- expect(fs.readdirSync(outside)).toEqual([]);
88
- });
89
-
90
- it('rejects an existing file that is a symlink out of the project, even with --overwrite', async () => {
91
- const {project, outside} = buildFakeRepo(tmpDir);
92
- const outDir = path.join(project, 'components', 'astryx', 'Button');
93
- fs.mkdirSync(outDir, {recursive: true});
94
- const target = path.join(outside, 'kept.txt');
95
- fs.writeFileSync(target, 'kept\n');
96
- fs.symlinkSync(target, path.join(outDir, 'Button.tsx'));
97
-
98
- const result = await runCli(
99
- ['--json', 'swizzle', 'Button', '--overwrite'],
100
- project,
101
- );
102
-
103
- expect(result.code).not.toBe(0);
104
- expect(JSON.parse(result.stdout).code).toBe('ERR_PATH_TRAVERSAL');
105
- expect(fs.readFileSync(target, 'utf-8')).toBe('kept\n');
106
- });
107
-
108
77
  it('requires --overwrite in non-interactive mode when files already exist', async () => {
109
78
  const {project} = buildFakeRepo(tmpDir);
110
79
  const outDir = path.join(project, 'components', 'astryx', 'Button');
@@ -123,15 +92,4 @@ describe('swizzle path safety', () => {
123
92
  // Existing file unchanged
124
93
  expect(fs.readFileSync(existingPath, 'utf-8')).toBe('// my customizations\n');
125
94
  });
126
-
127
- // The CLI never prompts: without --overwrite it refuses with a code, and the
128
- // manifest agents read must say so.
129
- it('describes --overwrite by its refusal, not a prompt', async () => {
130
- const {project} = buildFakeRepo(tmpDir);
131
- const result = await runCli(['--json', 'manifest'], project);
132
- const swizzle = JSON.parse(result.stdout).data.commands.find(c => c.name === 'swizzle');
133
- const overwrite = swizzle.options.find(o => o.flag.includes('--overwrite'));
134
- expect(overwrite.description).not.toMatch(/prompt/i);
135
- expect(overwrite.description).toContain('ERR_FILE_EXISTS');
136
- });
137
95
  });
@@ -23,29 +23,11 @@ export const doc = {
23
23
  'a discovered template.',
24
24
  fn: 'template',
25
25
  args: [
26
- {
27
- name: 'name',
28
- param: 'name',
29
- required: false,
30
- description: 'Template id (see --list). Omit it to list the templates.',
31
- },
32
- {
33
- name: 'path',
34
- param: 'options.targetPath',
35
- required: false,
36
- description:
37
- 'Where to scaffold the template, relative to the project root. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; ' +
38
- "any other path is a directory, which receives page.tsx for a page template or the block's own file name for a block. " +
39
- 'Omit it to print the source.',
40
- },
26
+ {name: 'name', param: 'name', required: false},
27
+ {name: 'path', param: 'options.targetPath', required: false},
41
28
  ],
42
29
  options: [
43
- {
44
- flag: '--list',
45
- param: 'options.list',
46
- description:
47
- 'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are ignored',
48
- },
30
+ {flag: '--list', param: 'options.list', description: 'List available templates'},
49
31
  {
50
32
  flag: '--type <type>',
51
33
  param: 'options.type',
@@ -61,22 +43,18 @@ export const doc = {
61
43
  flag: '--skeleton',
62
44
  param: 'options.skeleton',
63
45
  description:
64
- 'Show layout skeleton with spatial annotations (padding, gap, nesting) instead of the source. Needs <name>. ' +
65
- 'It writes nothing, so <path> and --overwrite are ignored; --list and --cdn take precedence',
46
+ 'Show layout skeleton with spatial annotations (padding, gap, nesting)',
66
47
  },
67
48
  {
68
49
  flag: '--cdn [path]',
69
50
  param: 'options.cdn',
70
51
  description:
71
- 'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are ignored. ' +
72
- 'The page goes to the --cdn value, else to <path>, else cdn.template.html, and that path is always the file itself. ' +
73
- 'A value right after --cdn (anything not starting with -) is taken as that path',
52
+ 'Write the no-build-step CDN starter page (default: cdn.template.html)',
74
53
  },
75
54
  {
76
55
  flag: '-f, --overwrite',
77
56
  param: 'options.overwrite',
78
- description:
79
- 'Replace an existing target file. Without it an existing file is refused (ERR_FILE_EXISTS) and an existing CDN page is left as is',
57
+ description: 'Overwrite existing files without prompting',
80
58
  },
81
59
  ],
82
60
  examples: [
@@ -28,8 +28,7 @@ export const doc = {
28
28
  {
29
29
  flag: '-f, --overwrite',
30
30
  param: 'options.overwrite',
31
- description:
32
- 'Replace existing files. Without it, existing files fail the command with ERR_FILE_EXISTS and nothing is written',
31
+ description: 'Overwrite existing files without prompting',
33
32
  },
34
33
  {flag: '--list', description: 'List available themes'},
35
34
  {
@@ -28,35 +28,34 @@ export const doc = {
28
28
  {
29
29
  flag: '--family',
30
30
  description:
31
- 'Build the selected extension family into one keyed CSS, JS, and declaration set. Requires --family-key; refused with --out or --watch (ERR_THEME_INVALID)',
31
+ 'Build the selected extension family into one keyed CSS, JS, and declaration set',
32
32
  },
33
33
  {
34
34
  flag: '--family-key <key>',
35
35
  description:
36
- 'Lower-kebab filename stem required with --family and refused without it; must differ from every member name (ERR_THEME_INVALID)',
36
+ 'Lower-kebab filename stem required with --family; must differ from every member name',
37
37
  },
38
38
  {
39
39
  flag: '-o, --out <path>',
40
40
  param: 'options.out',
41
- description:
42
- 'Output CSS file path; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A relative path must stay inside the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
41
+ description: 'Output CSS file path (single theme only)',
43
42
  },
44
43
  {
45
44
  flag: '--icons-specifier <specifier>',
46
45
  param: 'options.iconsSpecifier',
47
46
  description:
48
- "Override the icon-registry import in the generated JS module, for example ./icons.mjs (default: the specifier in the theme source's own import). With --family it applies to every member's icon import",
47
+ 'Override the icon-registry import in the generated JS module (for example, ./icons.mjs)',
49
48
  },
50
49
  {
51
50
  flag: '-w, --watch',
52
51
  description:
53
- 'Rebuild automatically when a theme file changes (Ctrl-C to stop). Refused with --check, --family, or --json (ERR_THEME_INVALID)',
52
+ 'Rebuild automatically when a theme file changes (Ctrl-C to stop)',
54
53
  },
55
54
  {
56
55
  flag: '-c, --check',
57
56
  param: 'options.check',
58
57
  description:
59
- 'Verify the committed outputs match the source without writing; exit non-zero if stale. Composes with --family and several files; refused with --watch (ERR_THEME_INVALID)',
58
+ 'Verify the committed outputs match the source without writing; exit non-zero if stale',
60
59
  },
61
60
  ],
62
61
  examples: [
@@ -132,23 +132,4 @@ describe('astryx theme palette generate', () => {
132
132
  code: 'ERR_PALETTE_GENERATION',
133
133
  });
134
134
  });
135
-
136
- it('returns ERR_WRITE_FAILED for an output path it cannot use', async () => {
137
- fs.writeFileSync(path.join(temporaryDirectory, 'blocker'), '');
138
- const {status, stdout} = await runCli(
139
- [
140
- '--json',
141
- 'theme',
142
- 'palette',
143
- 'generate',
144
- 'palette.config.json',
145
- '--out',
146
- 'blocker/ocean.palette.ts',
147
- ],
148
- {cwd: temporaryDirectory},
149
- );
150
-
151
- expect(status).toBe(1);
152
- expect(JSON.parse(stdout)).toMatchObject({code: 'ERR_WRITE_FAILED'});
153
- });
154
135
  });
@@ -82,16 +82,4 @@ describe('astryx theme template', () => {
82
82
  expect(stderr).toMatch(/outside the project root/);
83
83
  expect(fs.existsSync(path.join(path.dirname(tmpDir), 'escaped.ts'))).toBe(false);
84
84
  });
85
-
86
- it('fails a write with ERR_WRITE_FAILED under --json', async () => {
87
- fs.writeFileSync(path.join(tmpDir, 'blocker'), '');
88
-
89
- const {status, stdout} = await runCli(
90
- ['--json', 'theme', 'template', 'blocker/theme.ts'],
91
- {cwd: tmpDir},
92
- );
93
-
94
- expect(status).toBe(1);
95
- expect(JSON.parse(stdout).code).toBe('ERR_WRITE_FAILED');
96
- });
97
85
  });
@@ -36,7 +36,7 @@ export const doc = {
36
36
  ],
37
37
  exitCodes: [
38
38
  {code: 0, when: 'success, including when an existing file was left untouched'},
39
- {code: 1, when: 'the target path escapes the project, or the file cannot be written'},
39
+ {code: 1, when: 'the target path escapes the project'},
40
40
  ],
41
41
  related: ['theme add', 'theme list', 'theme build'],
42
42
  };
@@ -19,7 +19,6 @@ export const doc = {
19
19
  'running the registered codemods, and refreshes the fully rendered managed ' +
20
20
  'agent-docs block when Core or configured integration guidance changes. ' +
21
21
  'Dry-run by default. --apply writes codemod and receipt changes, runs hooks, then refreshes agent docs. ' +
22
- 'Anything a post-codemod hook prints goes to stderr, so stdout carries only the result. ' +
23
22
  'ShadCN-copied compositions are checked automatically during a normal upgrade, or alone with --registry.',
24
23
  fn: 'upgrade',
25
24
  options: [
@@ -27,8 +26,7 @@ export const doc = {
27
26
  flag: '--from <version>',
28
27
  param: 'options.from',
29
28
  description:
30
- 'Previous version before the dependency upgrade; required unless --list or --registry is set. ' +
31
- 'The target is the installed @astryxdesign/core version, or legacy @xds/core when @astryxdesign/core is not installed',
29
+ 'Previous version before the dependency upgrade; required unless --list or --registry is set',
32
30
  },
33
31
  {
34
32
  flag: '--apply',
@@ -46,9 +44,7 @@ export const doc = {
46
44
  {
47
45
  flag: '--codemod <name>',
48
46
  param: 'options.codemod',
49
- description:
50
- 'Run only the named codemod. Optional codemods run only when named here; a normal run skips them. ' +
51
- 'Also skips the check of ShadCN-copied compositions. An unknown name exits 1 with ERR_UNKNOWN_CODEMOD when the version range has codemods',
47
+ description: 'Run a specific transform only',
52
48
  },
53
49
  {
54
50
  flag: '--skip-codemod <name...>',
@@ -72,23 +68,20 @@ export const doc = {
72
68
  {
73
69
  flag: '--install-deps',
74
70
  param: 'options.installDeps',
75
- description:
76
- 'Install jscodeshift when it is missing. Without it, a missing jscodeshift fails the command with ERR_DEP_MISSING',
71
+ description: 'Auto-install jscodeshift without prompting',
77
72
  default: false,
78
73
  },
79
74
  {
80
75
  flag: '--registry',
81
76
  param: 'options.registry',
82
77
  description:
83
- 'Only reconcile ShadCN-copied compositions; --from is not required. ' +
84
- 'Combining it with --list, --from, --force, --codemod, --skip-codemod, --integration or --install-deps exits 1 with ERR_INVALID_ARGUMENT',
78
+ 'Only reconcile ShadCN-copied compositions; --from is not required',
85
79
  default: false,
86
80
  },
87
81
  {
88
82
  flag: '--list',
89
83
  param: 'options.list',
90
- description:
91
- 'List available codemods and do nothing else. Every other flag is ignored, except --registry, which is refused (exit 1)',
84
+ description: 'List available codemods',
92
85
  default: false,
93
86
  },
94
87
  ],
@@ -104,11 +97,7 @@ export const doc = {
104
97
  {code: 0, when: 'success (including dry-run previews)'},
105
98
  {
106
99
  code: 1,
107
- when:
108
- 'missing or invalid --from, --registry with --list or a migration flag, a --path escape, ' +
109
- 'no installed @astryxdesign/core (or legacy @xds/core), jscodeshift missing and not installed by --install-deps, ' +
110
- 'an astryx.config that fails validation and that no pending config codemod repairs, ' +
111
- 'an unknown codemod, a codemod or post-codemod hook failure, or unresolved registry items',
100
+ when: 'missing or invalid --from, a --path escape, an unknown codemod, a codemod failure, or unresolved registry items',
112
101
  },
113
102
  ],
114
103
  related: ['init', 'doctor'],
@@ -16,6 +16,7 @@ import {Command, Option} from 'commander';
16
16
  import {fileURLToPath} from 'node:url';
17
17
  import * as fs from 'node:fs';
18
18
  import * as path from 'node:path';
19
+ import {checkForUpdate} from './lib/update-check.mjs';
19
20
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
20
21
  import {API_VERSION, setJsonMode} from '../../foundation/response/json.mjs';
21
22
  import {buildManifest} from './lib/manifest.mjs';
@@ -24,8 +25,7 @@ import {emit, section, text, records} from './formatters/index.mjs';
24
25
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
25
26
  import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
26
27
  import {installJsonShim} from './lib/json-shim.mjs';
27
- import {addExitCodesHelp, markReportsResult} from './lib/define-command.mjs';
28
- import {doc as manifestDoc} from './commands/manifest.doc.mjs';
28
+ import {markReportsResult} from './lib/define-command.mjs';
29
29
  import {isAstryxInitialized} from '../../foundation/agent-docs/agent-docs.mjs';
30
30
  import * as debug from '../../foundation/debug/index.mjs';
31
31
 
@@ -275,6 +275,7 @@ const commands = [
275
275
  {name: 'doctor', path: './commands/doctor.mjs', register: 'registerDoctor'},
276
276
  ];
277
277
 
278
+ const UPDATE_HINT_COMMANDS = new Set(['component', 'docs']);
278
279
  const SETUP_NUDGE_EXEMPT = new Set(['init', 'agent-docs']);
279
280
 
280
281
  /**
@@ -351,7 +352,7 @@ export async function createProgram() {
351
352
  )
352
353
  .option(
353
354
  '--json',
354
- 'Output as typed JSON. Success envelope: { apiVersion, type, data, meta? }. Error envelope: { apiVersion, error, code, suggestions? }.',
355
+ 'Output as typed JSON. Success envelope: { type, data }. Error envelope: { error, suggestions? }.',
355
356
  )
356
357
  .addHelpCommand('help', 'Show all commands')
357
358
  .action((options, cmd) => {
@@ -498,6 +499,25 @@ export async function createProgram() {
498
499
  process.exit(1);
499
500
  });
500
501
 
502
+ /**
503
+ * Post-action hook: print update hint after any command output.
504
+ * Only fires for commands that produce output agents read (component, docs, etc.).
505
+ * Suppressed when --json is active to avoid contaminating stdout.
506
+ */
507
+ program.hook('postAction', (thisCommand, actionCommand) => {
508
+ if (program.opts().json) return;
509
+ try {
510
+ if (UPDATE_HINT_COMMANDS.has(actionCommand.name())) {
511
+ const hint = checkForUpdate();
512
+ if (hint) {
513
+ console.error(`\n${hint}`);
514
+ }
515
+ }
516
+ } catch {
517
+ // Never let update check break the CLI
518
+ }
519
+ });
520
+
501
521
  /**
502
522
  * Enforcement layer 3 — setup nudge. If this project hasn't run `astryx init`
503
523
  * yet (no Astryx marker in any agent-doc file — see isAstryxInitialized), remind
@@ -537,18 +557,16 @@ export async function createProgram() {
537
557
  mod[cmd.register](program);
538
558
  } catch (e) {
539
559
  // Command fails to load but CLI still works
540
- const reason = /** @type {any} */ (e).message;
541
560
  const stub = program
542
561
  .command(cmd.name)
543
- .description(`(failed to load: ${reason})`)
562
+ .description(`(failed to load: ${/** @type {any} */ (e).message})`)
544
563
  .action(() => {
545
564
  // Nothing loaded, so nothing was answered — say that rather than
546
565
  // leaving the run's result unreported.
547
566
  debug.recordCommandResult(debug.NO_RESULT_SET);
548
- // cliError, so --json still gets its one envelope.
549
- cliError(`Command "${cmd.name}" failed to load: ${reason}`, {
550
- code: ERROR_CODES.ERR_UNKNOWN,
551
- });
567
+ console.error(`Command "${cmd.name}" failed to load:`);
568
+ console.error(/** @type {any} */ (e).message);
569
+ process.exit(1);
552
570
  });
553
571
  markReportsResult(stub);
554
572
  }
@@ -583,21 +601,20 @@ export async function createProgram() {
583
601
  }
584
602
  // Human-readable summary as greppable records (agents should use --json).
585
603
  // One record per command: name, whether it supports --json, and the
586
- // description. Field names are the manifest entry's own keys.
604
+ // description.
587
605
  emit(
588
606
  section(`${manifest.name} v${manifest.version} (${manifest.commands.length} commands)`),
589
607
  records(
590
608
  manifest.commands.map(c => ({
591
- name: c.name,
609
+ command: c.name,
592
610
  json: c.json ? 'yes' : '',
593
611
  description: c.description || '',
594
612
  })),
595
- {fields: ['name', 'json', 'description']},
613
+ {fields: ['command', 'json', 'description']},
596
614
  ),
597
615
  text(`Run \`${getCliInvocation()} manifest --json\` for the full structured manifest.`),
598
616
  );
599
617
  });
600
- addExitCodesHelp(manifestCommand, manifestDoc.exitCodes);
601
618
  markReportsResult(manifestCommand);
602
619
 
603
620
  // Hidden command used by package.json postinstall scripts
@@ -133,13 +133,6 @@ describe('cliError — JSON mode', () => {
133
133
  expect(env.suggestions).toEqual([{name: 'Button', reason: 'closest match'}]);
134
134
  });
135
135
 
136
- it('replaces an unregistered code with ERR_UNKNOWN', () => {
137
- expect(() =>
138
- cliError('EACCES: permission denied', {code: 'EACCES'}),
139
- ).toThrow('__exit_1__');
140
- expect(JSON.parse(stdout[0]).code).toBe('ERR_UNKNOWN');
141
- });
142
-
143
136
  it('always exits 1 in JSON mode (custom exitCode is ignored — contract)', () => {
144
137
  expect(() => cliError('msg', {exitCode: 2})).toThrow('__exit_1__');
145
138
  expect(exitCode).toBe(1);