@astryxdesign/cli 0.1.6 → 0.1.7-canary.04cd8f7

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 (107) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +115 -19
  3. package/docs/cli-integrations.doc.mjs +150 -0
  4. package/docs/getting-started.doc.mjs +9 -9
  5. package/docs/internationalization.doc.mjs +243 -0
  6. package/docs/layout.doc.dense.mjs +5 -0
  7. package/docs/migration.doc.mjs +18 -18
  8. package/docs/principles.doc.dense.mjs +5 -5
  9. package/docs/principles.doc.mjs +6 -6
  10. package/docs/principles.doc.zh.mjs +5 -5
  11. package/docs/styling-libraries.doc.mjs +3 -3
  12. package/docs/styling.doc.mjs +4 -4
  13. package/docs/theme.doc.dense.mjs +12 -12
  14. package/docs/theme.doc.mjs +7 -7
  15. package/docs/theme.doc.zh.mjs +10 -10
  16. package/docs/tokens.doc.dense.mjs +6 -7
  17. package/docs/tokens.doc.mjs +1 -1
  18. package/docs/tokens.doc.zh.mjs +6 -7
  19. package/docs/working-with-ai.doc.mjs +18 -18
  20. package/package.json +13 -10
  21. package/src/api/docOverlays.test.mjs +133 -0
  22. package/src/api/docs.mjs +14 -2
  23. package/src/api/doctor.mjs +3 -3
  24. package/src/api/integration-block-exports.test.mjs +240 -0
  25. package/src/api/template-suffix.test.mjs +246 -0
  26. package/src/api/template.mjs +104 -28
  27. package/src/api/validate-integration.mjs +0 -8
  28. package/src/codemods/__tests__/registry.test.mjs +1 -0
  29. package/src/codemods/ensure-jscodeshift.mjs +11 -27
  30. package/src/codemods/registry.mjs +1 -0
  31. package/src/codemods/run-codemod.mjs +1 -1
  32. package/src/codemods/runner.mjs +2 -2
  33. package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +120 -0
  34. package/src/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +112 -0
  35. package/src/codemods/transforms/v0.1.7/index.mjs +27 -0
  36. package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +188 -0
  37. package/src/codemods/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +197 -0
  38. package/src/commands/agent-docs.mjs +21 -8
  39. package/src/commands/agent-docs.test.mjs +31 -4
  40. package/src/commands/build-theme.mjs +10 -71
  41. package/src/commands/build.mjs +15 -15
  42. package/src/commands/component/index.mjs +4 -4
  43. package/src/commands/discover.mjs +7 -5
  44. package/src/commands/docs.mjs +4 -4
  45. package/src/commands/hook/index.mjs +4 -4
  46. package/src/commands/init.mjs +48 -152
  47. package/src/commands/init.next-steps.test.mjs +1 -1
  48. package/src/commands/interactive-guard.test.mjs +19 -22
  49. package/src/commands/json-contract.test.mjs +1 -1
  50. package/src/commands/layout.mjs +1 -1
  51. package/src/commands/search.mjs +4 -4
  52. package/src/commands/swizzle.mjs +11 -34
  53. package/src/commands/template.mjs +11 -31
  54. package/src/commands/upgrade.mjs +9 -6
  55. package/src/commands/upgrade.test.mjs +1 -1
  56. package/src/config.mjs +5 -14
  57. package/src/doc.mjs +27 -0
  58. package/src/doc.test.mjs +383 -0
  59. package/src/index.mjs +5 -6
  60. package/src/integration.mjs +4 -15
  61. package/src/lib/component-discovery.importpath.test.mjs +59 -0
  62. package/src/lib/component-discovery.mjs +15 -5
  63. package/src/lib/component-format.mjs +47 -14
  64. package/src/lib/component-format.test.mjs +95 -1
  65. package/src/lib/component-loader.mjs +104 -2
  66. package/src/lib/componentDocOverlay.test.mjs +111 -0
  67. package/src/lib/config-schema.mjs +0 -30
  68. package/src/lib/hook-format.mjs +8 -3
  69. package/src/lib/term-log.mjs +48 -0
  70. package/src/lib/xle/registry.mjs +0 -5
  71. package/src/schemas/doc-schema.mjs +226 -0
  72. package/src/schemas/template-schema.mjs +47 -0
  73. package/src/template.mjs +9 -67
  74. package/src/types/config.d.ts +11 -66
  75. package/src/types/doc.d.ts +23 -0
  76. package/src/types/integration.d.ts +7 -18
  77. package/src/types/template-api.d.ts +14 -50
  78. package/src/utils/package-manager.mjs +78 -0
  79. package/src/utils/package-manager.test.mjs +108 -1
  80. package/src/utils/path-safety.mjs +0 -18
  81. package/src/utils/update-check.mjs +2 -1
  82. package/templates/blocks/components/Avatar/AvatarGroup.tsx +5 -7
  83. package/templates/blocks/components/Avatar/AvatarShowcase.tsx +4 -6
  84. package/templates/blocks/components/Avatar/AvatarUserCard.tsx +3 -5
  85. package/templates/blocks/components/Avatar/AvatarWithImage.tsx +8 -6
  86. package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +3 -5
  87. package/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx +1 -1
  88. package/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx +1 -1
  89. package/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +1 -1
  90. package/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +1 -1
  91. package/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx +1 -1
  92. package/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx +1 -1
  93. package/templates/blocks/components/TabList/TabListTabsWithActions.doc.mjs +1 -1
  94. package/templates/blocks/components/TabList/TabListTabsWithActions.tsx +2 -7
  95. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +14 -0
  96. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +41 -0
  97. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +13 -0
  98. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +78 -0
  99. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +14 -0
  100. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +38 -0
  101. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +14 -0
  102. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +47 -0
  103. package/templates/pages/ide/page.tsx +35 -41
  104. package/templates/pages/theme-showcase/page.tsx +7 -7
  105. package/templates/themes/neutral/neutralTheme.ts +63 -32
  106. package/src/utils/interactive.mjs +0 -76
  107. package/src/utils/interactive.test.mjs +0 -70
@@ -15,7 +15,7 @@
15
15
  * the whole CLI, use `astryx search <query>` instead.
16
16
  */
17
17
 
18
- import {getRunPrefix} from '../utils/package-manager.mjs';
18
+ import {getCliInvocation, formatCliCommand} from '../utils/package-manager.mjs';
19
19
  import {jsonOut, humanLog} from '../lib/json.mjs';
20
20
  import {cliError} from '../lib/cli-error.mjs';
21
21
  import {search as searchApi} from '../api/search.mjs';
@@ -47,25 +47,25 @@ function printPlaybook(run) {
47
47
  'How to build a page with Astryx',
48
48
  '',
49
49
  "1. Find a starting point for what you're building:",
50
- ` ${run} astryx build "<what you're building>"`,
50
+ ` ${run} build "<what you're building>"`,
51
51
  ' → returns the closest [page] template, the [block]s that cover parts,',
52
52
  ' and the [component]s to fill the gaps, with a "Compose:" suggestion.',
53
53
  '',
54
54
  '2. If a [page] template matches → scaffold it and adapt:',
55
- ` ${run} astryx template <name> [path]`,
55
+ ` ${run} template <name> [path]`,
56
56
  '',
57
57
  '3. If nothing matches exactly → compose:',
58
- ` ${run} astryx template <name> --skeleton # study a close page's layout`,
59
- ` ${run} astryx template <BlockName> # drop in each block from the kit`,
60
- ` ${run} astryx component <Name> # fill remaining gaps (read props)`,
58
+ ` ${run} template <name> --skeleton # study a close page's layout`,
59
+ ` ${run} template <BlockName> # drop in each block from the kit`,
60
+ ` ${run} component <Name> # fill remaining gaps (read props)`,
61
61
  '',
62
62
  '4. Rules (keep it on-system):',
63
63
  ' - No <div>/raw HTML for layout — use VStack/HStack/Grid/Stack/Card etc.',
64
- ' - No style={{}} — use component props; design tokens via `astryx docs tokens`.',
64
+ ` - No style={{}} — use component props; design tokens via \`${run} docs tokens\`.`,
65
65
  ' - Wrap the app in <Theme theme={...}> and import core reset.css + astryx.css.',
66
66
  '',
67
- `Tip: \`${run} astryx build "<idea>"\` is the fastest way in. For a neutral`,
68
- `lookup of any component/doc/template, use \`${run} astryx search <query>\`.`,
67
+ `Tip: \`${run} build "<idea>"\` is the fastest way in. For a neutral`,
68
+ `lookup of any component/doc/template, use \`${run} search <query>\`.`,
69
69
  '',
70
70
  ];
71
71
  for (const l of lines) humanLog(l);
@@ -79,7 +79,7 @@ export function registerBuild(program) {
79
79
  .option('--limit <n>', 'Max candidates to draw from (default 60)')
80
80
  .option('--detail', 'Verbose output (include import paths and match reason)')
81
81
  .action(async (query, options) => {
82
- const run = getRunPrefix();
82
+ const run = getCliInvocation();
83
83
  const json = program.opts().json || false;
84
84
 
85
85
  // No query → print the playbook (the "how to build" skill).
@@ -115,7 +115,7 @@ export function registerBuild(program) {
115
115
  if (results.length === 0) {
116
116
  humanLog('');
117
117
  humanLog(`No matches for "${q}".`);
118
- humanLog(`Try a broader term, or browse: ${run} astryx component --list`);
118
+ humanLog(`Try a broader term, or browse: ${run} component --list`);
119
119
  humanLog('');
120
120
  return;
121
121
  }
@@ -138,7 +138,7 @@ export function registerBuild(program) {
138
138
  humanLog('');
139
139
  humanLog(` [${label}] ${display}`);
140
140
  if (r.description) humanLog(` ${r.description}`);
141
- humanLog(` → ${run} ${r.command}`);
141
+ humanLog(` → ${formatCliCommand(r.command)}`);
142
142
  if (options.detail) {
143
143
  if (r.import) humanLog(` import: ${r.import}`);
144
144
  humanLog(` match: ${r.reason} (score ${r.score})`);
@@ -151,9 +151,9 @@ export function registerBuild(program) {
151
151
  // START — the single recommended path.
152
152
  humanLog('');
153
153
  if (directMatch) {
154
- humanLog(`START → Scaffold the \`${pages[0].name}\` page template, then adapt: ${run} astryx template ${pages[0].name} ./src/App.tsx`);
154
+ humanLog(`START → Scaffold the \`${pages[0].name}\` page template, then adapt: ${run} template ${pages[0].name} ./src/App.tsx`);
155
155
  } else if (pages.length) {
156
- humanLog(`START → No exact page template. Use \`${pages[0].name}\` as a layout reference (${run} astryx template ${pages[0].name} --skeleton) and compose the pieces below.`);
156
+ humanLog(`START → No exact page template. Use \`${pages[0].name}\` as a layout reference (${run} template ${pages[0].name} --skeleton) and compose the pieces below.`);
157
157
  } else {
158
158
  humanLog(`START → No page template fits. Frame with AppShell and compose the blocks + components below.`);
159
159
  }
@@ -168,7 +168,7 @@ export function registerBuild(program) {
168
168
  // FRAME — always (the page shell).
169
169
  humanLog('');
170
170
  humanLog(`FRAME — page shell (always): ${FRAME.join(', ')}`);
171
- humanLog(` full-page → AppShell; or Layout + SideNav/TopNav. ${run} astryx component AppShell`);
171
+ humanLog(` full-page → AppShell; or Layout + SideNav/TopNav. ${run} component AppShell`);
172
172
 
173
173
  // BLOCKS — idea-specific composed patterns.
174
174
  if (blocks.length) {
@@ -18,7 +18,7 @@ import {
18
18
  formatBriefAll,
19
19
  } from '../../lib/component-format.mjs';
20
20
  import {resolveTheme} from '../../lib/resolve-theme.mjs';
21
- import {getRunPrefix} from '../../utils/package-manager.mjs';
21
+ import {getCliInvocation} from '../../utils/package-manager.mjs';
22
22
  import {jsonOut, humanLog} from '../../lib/json.mjs';
23
23
  import {cliError} from '../../lib/cli-error.mjs';
24
24
  import {ERROR_CODES} from '../../lib/error-codes.mjs';
@@ -39,7 +39,7 @@ export function registerComponent(program) {
39
39
  .option('--blocks', 'List example blocks: showcase, examples, and related')
40
40
  .option('--package <name>', 'Scope lookup to an external package (e.g. @acme/xds-widgets)')
41
41
  .action(async (name, options) => {
42
- const run = getRunPrefix();
42
+ const run = getCliInvocation();
43
43
  const zh = program.opts().zh || false;
44
44
  const dense = program.opts().dense || false;
45
45
  const lang = program.opts().lang || null;
@@ -142,7 +142,7 @@ export function registerComponent(program) {
142
142
  }
143
143
  humanLog('');
144
144
  humanLog(`Import from the path shown (e.g. import {Button} from '@astryxdesign/core/Button')`);
145
- humanLog(`Usage: ${run} astryx component <name>`);
145
+ humanLog(`Usage: ${run} component <name>`);
146
146
  humanLog('');
147
147
  }
148
148
  break;
@@ -165,7 +165,7 @@ export function registerComponent(program) {
165
165
  humanLog('');
166
166
  }
167
167
  humanLog(`Import from the path shown (e.g. import {Button} from '@astryxdesign/core/Button')`);
168
- humanLog(`Usage: ${run} astryx component <name>`);
168
+ humanLog(`Usage: ${run} component <name>`);
169
169
  humanLog('');
170
170
  break;
171
171
  }
@@ -14,6 +14,7 @@ import {formatFull, formatBrief, formatCompact} from '../lib/component-format.mj
14
14
  import {jsonOut, humanLog} from '../lib/json.mjs';
15
15
  import {cliError} from '../lib/cli-error.mjs';
16
16
  import {discover as discoverApi} from '../api/discover.mjs';
17
+ import {getCliInvocation} from '../utils/package-manager.mjs';
17
18
 
18
19
  export function registerDiscover(program) {
19
20
  program
@@ -25,6 +26,7 @@ export function registerDiscover(program) {
25
26
  const json = program.opts().json || false;
26
27
  const lang = program.opts().lang || null;
27
28
  const zh = program.opts().zh || false;
29
+ const run = getCliInvocation();
28
30
 
29
31
  let result;
30
32
  try {
@@ -80,9 +82,9 @@ export function registerDiscover(program) {
80
82
  humanLog('');
81
83
  }
82
84
  humanLog('Usage:');
83
- humanLog(' astryx discover <package> Browse a package');
84
- humanLog(' astryx discover <package>/Component View component docs');
85
- humanLog(' astryx discover <search> Search all packages');
85
+ humanLog(` ${run} discover <package> Browse a package`);
86
+ humanLog(` ${run} discover <package>/Component View component docs`);
87
+ humanLog(` ${run} discover <search> Search all packages`);
86
88
  humanLog('');
87
89
  }
88
90
  break;
@@ -99,7 +101,7 @@ export function registerDiscover(program) {
99
101
  humanLog('');
100
102
  for (const comp of result.data.components) humanLog(' ' + comp);
101
103
  humanLog('');
102
- humanLog('Usage: astryx discover ' + result.data.name + '/<ComponentName>');
104
+ humanLog(`Usage: ${run} discover ` + result.data.name + '/<ComponentName>');
103
105
  humanLog('');
104
106
  break;
105
107
  }
@@ -122,7 +124,7 @@ export function registerDiscover(program) {
122
124
  humanLog('Found ' + result.data.matches.length + ' matches for "' + result.data.query + '":');
123
125
  humanLog('');
124
126
  for (const m of result.data.matches) {
125
- humanLog(' astryx discover ' + m.package + '/' + m.component);
127
+ humanLog(` ${run} discover ` + m.package + '/' + m.component);
126
128
  }
127
129
  humanLog('');
128
130
  break;
@@ -12,7 +12,7 @@
12
12
  * astryx docs <topic> <section> Print one section
13
13
  */
14
14
 
15
- import {getRunPrefix} from '../utils/package-manager.mjs';
15
+ import {getCliInvocation} from '../utils/package-manager.mjs';
16
16
  import {jsonOut, humanLog} from '../lib/json.mjs';
17
17
  import {cliError} from '../lib/cli-error.mjs';
18
18
  import {docs as docsApi} from '../api/docs.mjs';
@@ -105,7 +105,7 @@ export function registerDocs(program) {
105
105
  .command('docs [topic] [section]')
106
106
  .description('Print reference docs')
107
107
  .action(async (topic, section) => {
108
- const run = getRunPrefix();
108
+ const run = getCliInvocation();
109
109
  const lang = program.opts().lang || null;
110
110
  const zh = program.opts().zh || false;
111
111
  const dense = program.opts().dense || false;
@@ -130,8 +130,8 @@ export function registerDocs(program) {
130
130
  for (const entry of result.data) {
131
131
  humanLog(` ${entry.topic.padEnd(14)} ${entry.description}`);
132
132
  }
133
- humanLog(`\nUsage: ${run} astryx docs <topic>`);
134
- humanLog(` ${run} astryx docs <topic> <section>\n`);
133
+ humanLog(`\nUsage: ${run} docs <topic>`);
134
+ humanLog(` ${run} docs <topic> <section>\n`);
135
135
  break;
136
136
  }
137
137
 
@@ -12,7 +12,7 @@ import {
12
12
  formatHookBrief,
13
13
  formatHookParams,
14
14
  } from '../../lib/hook-format.mjs';
15
- import {getRunPrefix} from '../../utils/package-manager.mjs';
15
+ import {getCliInvocation} from '../../utils/package-manager.mjs';
16
16
  import {jsonOut, humanLog} from '../../lib/json.mjs';
17
17
  import {cliError} from '../../lib/cli-error.mjs';
18
18
  import {ERROR_CODES} from '../../lib/error-codes.mjs';
@@ -27,7 +27,7 @@ export function registerHook(program) {
27
27
  .option('--category <category>', 'List hooks in a specific category')
28
28
  .option('--params', 'Print only the parameters table')
29
29
  .action(async (name, options) => {
30
- const run = getRunPrefix();
30
+ const run = getCliInvocation();
31
31
  const zh = program.opts().zh || false;
32
32
  const lang = program.opts().lang || null;
33
33
  const detailSource = program.getOptionValueSource('detail');
@@ -76,7 +76,7 @@ export function registerHook(program) {
76
76
  for (const h of hookNames) humanLog(` ${h}`);
77
77
  }
78
78
  humanLog('');
79
- humanLog(`Usage: ${run} astryx hook <name>`);
79
+ humanLog(`Usage: ${run} hook <name>`);
80
80
  humanLog('');
81
81
  }
82
82
  break;
@@ -93,7 +93,7 @@ export function registerHook(program) {
93
93
  }
94
94
  humanLog('');
95
95
  }
96
- humanLog(`Usage: ${run} astryx hook <name>`);
96
+ humanLog(`Usage: ${run} hook <name>`);
97
97
  humanLog('');
98
98
  break;
99
99
  }
@@ -1,33 +1,33 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file init command — Interactive initialization wizard + feature installer
4
+ * @file init command — non-interactive setup + feature installer
5
5
  *
6
- * Interactive: `astryx init` walks through all features
7
- * Non-interactive: `astryx init --features agents,theme,template`
6
+ * `astryx init` is non-interactive by default: it installs the AGENTS.md/
7
+ * CLAUDE.md cheat sheet with NO prompts, so it behaves identically for humans,
8
+ * AI agents, CI, and piped I/O — it never hangs or errors on a missing TTY.
9
+ * Non-interactive feature install: `astryx init --features agents,theme,template`
8
10
  * Re-runnable: safe to run multiple times, idempotent
9
11
  *
10
12
  * Features:
11
13
  * agents — Install AGENTS.md/CLAUDE.md cheat sheet for AI coding agents
12
- * theme — Scaffold a custom theme file
14
+ * theme — Point to the theme workflow (`astryx theme`)
13
15
  * template — Copy a starter page template
14
16
  */
15
17
 
16
- import * as p from '@clack/prompts';
17
18
  import * as path from 'node:path';
18
19
  import * as fs from 'node:fs';
19
20
  import {CLI_ROOT} from '../utils/paths.mjs';
20
21
  import {PathSafetyError} from '../utils/path-safety.mjs';
21
- import {getRunPrefix} from '../utils/package-manager.mjs';
22
+ import {getCliInvocation} from '../utils/package-manager.mjs';
22
23
  import {installAgentDocs, removeAgentDocs} from './agent-docs.mjs';
23
24
  import {listTemplates} from './template.mjs';
24
25
  import {humanLog} from '../lib/json.mjs';
25
26
  import {cliError} from '../lib/cli-error.mjs';
26
27
  import {ERROR_CODES} from '../lib/error-codes.mjs';
27
- import {requireInteractive} from '../utils/interactive.mjs';
28
28
 
29
29
  const VALID_FEATURES = ['agents', 'theme', 'template'];
30
- const run = getRunPrefix();
30
+ const run = getCliInvocation();
31
31
 
32
32
  /**
33
33
  * Build the "Next steps" lines printed at the end of `astryx init`.
@@ -40,10 +40,10 @@ const run = getRunPrefix();
40
40
  *
41
41
  * Exported for testing.
42
42
  *
43
- * @param {string} runPrefix package-manager run prefix (e.g. `npx`)
43
+ * @param {string} invocation install-aware CLI invocation stem (e.g. `npx astryx`, `pnpm exec astryx`, or `npx @astryxdesign/cli` for one-off runs)
44
44
  * @returns {string[]} ordered list of human-facing lines
45
45
  */
46
- export function getNextSteps(runPrefix) {
46
+ export function getNextSteps(invocation) {
47
47
  return [
48
48
  '',
49
49
  ' Next steps:',
@@ -54,23 +54,15 @@ export function getNextSteps(runPrefix) {
54
54
  " import { neutralTheme } from '@astryxdesign/theme-neutral/built'",
55
55
  " import '@astryxdesign/theme-neutral/theme.css'",
56
56
  ' <Theme theme={neutralTheme}>...</Theme>',
57
- ` For custom themes, run \`${runPrefix} astryx theme build <file>\` to generate the built artifacts.`,
58
- ` 4. ${runPrefix} astryx --help for all commands`,
57
+ ` For custom themes, run \`${invocation} theme build <file>\` to generate the built artifacts.`,
58
+ ` 4. ${invocation} --help for all commands`,
59
59
  '',
60
60
  ];
61
61
  }
62
62
 
63
- function isCancel(value) {
64
- if (p.isCancel(value)) {
65
- p.cancel('Setup cancelled.');
66
- process.exit(0);
67
- }
68
- return value;
69
- }
70
-
71
63
  // ─── Feature: agents ─────────────────────────────────────────────────────────
72
64
 
73
- function runAgents(targetDir, {interactive = true, agent, agentDocsPath} = {}) {
65
+ function runAgents(targetDir, {agent, agentDocsPath} = {}) {
74
66
  try {
75
67
  const paths = agentDocsPath
76
68
  ? Array.isArray(agentDocsPath)
@@ -79,114 +71,55 @@ function runAgents(targetDir, {interactive = true, agent, agentDocsPath} = {}) {
79
71
  : undefined;
80
72
  const written = installAgentDocs(targetDir, {agent, paths});
81
73
  const summary = written.join(', ');
82
- if (interactive) {
83
- p.log.success(`AI agent docs installed → ${summary}`);
84
- } else {
85
- humanLog(`✓ AI agent docs installed → ${summary}`);
86
- }
74
+ humanLog(`✓ AI agent docs installed → ${summary}`);
87
75
  } catch (err) {
88
76
  // PathSafetyError carries a precise, user-actionable message —
89
77
  // surface it instead of the generic "could not install" warning so
90
78
  // misconfigured --agent-docs-path values aren't silently swallowed.
91
79
  if (err instanceof PathSafetyError) {
92
- const msg = `Error: ${err.message}`;
93
- if (interactive) {
94
- p.log.error(msg);
95
- } else {
96
- console.error(msg);
97
- }
80
+ console.error(`Error: ${err.message}`);
98
81
  process.exitCode = 1;
99
82
  return;
100
83
  }
101
- const msg = `Could not install agent docs. Try again with \`${run} astryx init --features agents\`.`;
102
- if (interactive) {
103
- p.log.warning(msg);
104
- } else {
105
- console.error(msg);
106
- }
84
+ console.error(`Could not install agent docs. Try again with \`${run} init --features agents\`.`);
107
85
  }
108
86
  }
109
87
 
110
88
  // ─── Feature: theme ──────────────────────────────────────────────────────────
111
89
 
112
- async function runTheme({interactive = true} = {}) {
113
- if (!interactive) {
114
- humanLog(`✓ Theme scaffolding requires interactive mode. Run \`${run} astryx theme\` instead.`);
115
- return;
116
- }
117
-
118
- p.note(
119
- 'Create a custom theme with your brand colors.\n' +
120
- `Run \`${run} astryx theme\` for the full theme wizard.\n` +
121
- `Run \`${run} astryx theme --list\` to see existing themes.`,
122
- 'Themes',
123
- );
90
+ function runTheme() {
91
+ humanLog(`✓ For a custom theme, run \`${run} theme\` (browse) or \`${run} theme add <slug>\` (scaffold).`);
124
92
  }
125
93
 
126
94
  // ─── Feature: template ───────────────────────────────────────────────────────
127
95
 
128
- async function runTemplate(targetDir, {interactive = true, templateName} = {}) {
96
+ function runTemplate(targetDir, {templateName} = {}) {
129
97
  const templates = listTemplates();
130
98
  if (templates.length === 0) return;
131
99
 
132
- if (!interactive) {
133
- if (!templateName) {
134
- // Point agents at the build workflow rather than dumping page-template
135
- // names `build` surfaces pages AND blocks AND components for an idea,
136
- // and `build` with no args is the full how-to-build playbook.
137
- humanLog('✓ To build UI, use these commands:');
138
- humanLog('');
139
- humanLog(` ${run} astryx build "<what you're building>" build a page kit: closest template + blocks + components`);
140
- humanLog(` ${run} astryx build the how-to-build workflow (read this first)`);
141
- humanLog(` ${run} astryx search <query> find anything — components, docs, templates, blocks`);
142
- humanLog('');
143
- return;
144
- }
145
-
146
- if (!templates.includes(templateName)) {
147
- cliError(`Unknown template "${templateName}". Available: ${templates.join(', ')}`, {code: ERROR_CODES.ERR_UNKNOWN_TEMPLATE});
148
- return;
149
- }
150
-
151
- const outputDir = path.resolve(targetDir, `./src/pages/${templateName}`);
152
- const srcPath = path.join(CLI_ROOT, 'templates', 'pages', templateName, 'page.tsx');
153
- fs.mkdirSync(outputDir, {recursive: true});
154
- fs.copyFileSync(srcPath, path.join(outputDir, 'page.tsx'));
155
- humanLog(`✓ Template created at ${path.relative(targetDir, outputDir)}/page.tsx`);
100
+ if (!templateName) {
101
+ // Point agents at the build workflow rather than dumping page-template
102
+ // names `build` surfaces pages AND blocks AND components for an idea,
103
+ // and `build` with no args is the full how-to-build playbook.
104
+ humanLog('✓ To build UI, use these commands:');
105
+ humanLog('');
106
+ humanLog(` ${run} build "<what you're building>" build a page — kit: closest template + blocks + components`);
107
+ humanLog(` ${run} build the how-to-build workflow (read this first)`);
108
+ humanLog(` ${run} search <query> find anything components, docs, templates, blocks`);
109
+ humanLog('');
156
110
  return;
157
111
  }
158
112
 
159
- const TEMPLATE_OPTIONS = [
160
- {value: 'skip', label: 'Skip No template'},
161
- {value: 'blank', label: 'Blank Page — Minimal scaffold'},
162
- {value: 'table', label: 'Table Page — Data table with actions'},
163
- {value: 'login', label: 'Login Page — Auth form with inputs'},
164
- ];
165
-
166
- const templateChoice = isCancel(
167
- await p.select({
168
- message: 'Start with a page template?',
169
- options: TEMPLATE_OPTIONS,
170
- }),
171
- );
172
-
173
- if (templateChoice === 'skip') return;
174
-
175
- const targetPath = isCancel(
176
- await p.text({
177
- message: 'Where should the template be created?',
178
- initialValue: `./src/pages/${templateChoice}`,
179
- placeholder: `./src/pages/${templateChoice}`,
180
- }),
181
- );
182
-
183
- const outputDir = path.resolve(targetDir, targetPath);
184
- const srcPath = path.join(CLI_ROOT, 'templates', 'pages', templateChoice, 'page.tsx');
113
+ if (!templates.includes(templateName)) {
114
+ cliError(`Unknown template "${templateName}". Available: ${templates.join(', ')}`, {code: ERROR_CODES.ERR_UNKNOWN_TEMPLATE});
115
+ return;
116
+ }
185
117
 
118
+ const outputDir = path.resolve(targetDir, `./src/pages/${templateName}`);
119
+ const srcPath = path.join(CLI_ROOT, 'templates', 'pages', templateName, 'page.tsx');
186
120
  fs.mkdirSync(outputDir, {recursive: true});
187
121
  fs.copyFileSync(srcPath, path.join(outputDir, 'page.tsx'));
188
-
189
- p.log.success(`Template created at ${path.relative(targetDir, outputDir)}/page.tsx`);
122
+ humanLog(`✓ Template created at ${path.relative(targetDir, outputDir)}/page.tsx`);
190
123
  }
191
124
 
192
125
  // ─── Command ─────────────────────────────────────────────────────────────────
@@ -200,7 +133,7 @@ export function registerInit(program) {
200
133
  .option('--remove-agents', 'Remove AI agent docs from all agent doc files')
201
134
  .option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, hermes, all')
202
135
  .option('--agent-docs-path <path...>', 'Explicit file path(s) for agent docs')
203
- .action(async (options) => {
136
+ .action((options) => {
204
137
  const targetDir = process.cwd();
205
138
 
206
139
  // Remove mode
@@ -224,62 +157,25 @@ export function registerInit(program) {
224
157
 
225
158
  for (const feature of features) {
226
159
  if (feature === 'agents') runAgents(targetDir, {
227
- interactive: false,
228
160
  agent: options.agent,
229
161
  agentDocsPath: options.agentDocsPath,
230
162
  });
231
- if (feature === 'theme') await runTheme({interactive: false});
232
- if (feature === 'template') await runTemplate(targetDir, {interactive: false});
163
+ if (feature === 'theme') runTheme();
164
+ if (feature === 'template') runTemplate(targetDir, {});
233
165
  }
234
166
  return;
235
167
  }
236
168
 
237
- // Interactive wizard
238
- //
239
- // Guard: this wizard blocks on prompts. In a non-interactive context
240
- // (CI, piped stdin/stdout, no TTY) it would hang forever. Fail fast
241
- // with actionable guidance via the shared interactivity contract.
242
- requireInteractive({
243
- command: 'init',
244
- hint: `\`${run} astryx init --all\` or \`--features agents,theme,template\``,
169
+ // No flags: TTY-free default. `astryx init` installs the AI agent cheat
170
+ // sheet with NO prompts, so it behaves identically for humans, agents, CI,
171
+ // and piped I/O it never hangs or errors on a missing TTY. (A guided
172
+ // `--interactive` setup may return later as an explicit opt-in.)
173
+ runAgents(targetDir, {
174
+ agent: options.agent,
175
+ agentDocsPath: options.agentDocsPath,
245
176
  });
246
-
247
- p.intro('Welcome to the design system');
248
-
249
- p.note(
250
- 'A design system for building internal tools\nwith 300+ React components.',
251
- 'About',
252
- );
253
-
254
- // Feature: agents
255
- const shouldInstallAgents = isCancel(
256
- await p.confirm({
257
- message: 'Install AI agent support? (adds a design system cheat sheet to AGENTS.md)',
258
- initialValue: true,
259
- }),
260
- );
261
-
262
- if (shouldInstallAgents) {
263
- const s = p.spinner();
264
- s.start('Installing agent docs');
265
- runAgents(targetDir);
266
- s.stop('Done');
267
- }
268
-
269
- // Feature: swizzle awareness
270
- p.note(
271
- `You can customize any component with:\n ${run} astryx swizzle Button\n ${run} astryx swizzle --list`,
272
- 'Component Customization',
273
- );
274
-
275
- // Feature: template
276
- await runTemplate(targetDir);
277
-
278
- // Feature: theme awareness
279
- await runTheme();
280
-
281
- // Outro
282
- p.outro('Design system initialized!');
177
+ humanLog('');
178
+ humanLog(` Tip: \`${run} init --all\` also points you to the theme and page-building workflows.`);
283
179
 
284
180
  for (const line of getNextSteps(run)) {
285
181
  humanLog(line);
@@ -23,7 +23,7 @@ import {describe, it, expect} from 'vitest';
23
23
  import {getNextSteps} from './init.mjs';
24
24
 
25
25
  describe('init Next steps theme guidance', () => {
26
- const text = getNextSteps('npx').join('\n');
26
+ const text = getNextSteps('npx astryx').join('\n');
27
27
 
28
28
  it('mentions the base CSS imports so the app is not left unstyled', () => {
29
29
  expect(text).toContain("'@astryxdesign/core/reset.css'");
@@ -1,15 +1,13 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file Subprocess no-hang tests for the interactivity contract.
4
+ * @file Subprocess no-hang tests for `astryx init`.
5
5
  *
6
- * The wizard command `init` blocks on @clack/prompts. In a
7
- * non-interactive context it must fail fast (exit 1) instead of hanging.
8
- * These tests spawn the CLI as a real subprocess with stdin/stdout NOT a TTY
9
- * (stdio 'ignore'/'pipe'), which is exactly the CI / piped condition. If the
10
- * guard were missing, spawnSync would hit the timeout (signal SIGTERM,
11
- * status null) — so asserting `signal === null && status === 1` proves the
12
- * process exited cleanly rather than hanging.
6
+ * TTY was removed from the CLI: `init` is non-interactive by default and must
7
+ * run cleanly (exit 0, writing the agent cheat sheet) instead of hanging on a
8
+ * prompt. These tests spawn the CLI with stdin/stdout NOT a TTY (the CI / piped
9
+ * / agent condition). A hang would show as signal SIGTERM + status null; we
10
+ * assert `signal === null && status === 0` to prove it exits cleanly and works.
13
11
  */
14
12
 
15
13
  import {describe, it, expect, beforeEach, afterEach} from 'vitest';
@@ -42,25 +40,24 @@ afterEach(() => {
42
40
  fs.rmSync(tmpDir, {recursive: true, force: true});
43
41
  });
44
42
 
45
- describe('init non-interactive safety', () => {
46
- it('fails fast (exit 1, no hang) and writes no files', () => {
43
+ describe('init is non-interactive by default (no TTY needed)', () => {
44
+ it('runs cleanly (exit 0, no hang) and writes agent docs', () => {
47
45
  const r = runCli(['init']);
48
- expect(r.signal).toBeNull();
49
- expect(r.status).toBe(1);
50
- expect(fs.readdirSync(tmpDir)).toEqual([]);
46
+ expect(r.signal).toBeNull(); // did not hang
47
+ expect(r.status).toBe(0); // succeeded without a TTY
48
+ expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0); // wrote the cheat sheet
51
49
  });
52
50
 
53
- it('prints actionable guidance (--all / --features)', () => {
54
- const out = (() => {
55
- const r = runCli(['init']);
56
- return r.stderr + r.stdout;
57
- })();
58
- expect(out).toMatch(/requires a TTY/i);
59
- expect(out).toMatch(/--all/);
60
- expect(out).toMatch(/--features/);
51
+ it('writes an agent-doc file containing the ASTRYX cheat-sheet marker', () => {
52
+ runCli(['init']);
53
+ // init injects into AGENTS.md/CLAUDE.md if present, else creates .claude/CLAUDE.md
54
+ const candidates = ['AGENTS.md', 'CLAUDE.md', '.cursorrules', path.join('.claude', 'CLAUDE.md')];
55
+ const doc = candidates.find(f => fs.existsSync(path.join(tmpDir, f)));
56
+ expect(doc).toBeTruthy();
57
+ expect(fs.readFileSync(path.join(tmpDir, doc), 'utf8')).toMatch(/ASTRYX:START/);
61
58
  });
62
59
 
63
- it('still runs --features agents non-interactively (guard does not over-catch)', () => {
60
+ it('still runs --features agents non-interactively', () => {
64
61
  const r = runCli(['init', '--features', 'agents']);
65
62
  expect(r.signal).toBeNull();
66
63
  expect(r.status).toBe(0);
@@ -45,7 +45,7 @@ function runCli(args, {cwd} = {}) {
45
45
 
46
46
  function parseJson(stdout) {
47
47
  // CLI emits a single JSON document. If anything else snuck onto stdout
48
- // (clack output, console.log strings, etc.) JSON.parse will throw —
48
+ // (log output, console.log strings, etc.) JSON.parse will throw —
49
49
  // which is exactly the failure mode we want to catch in tests.
50
50
  return JSON.parse(stdout);
51
51
  }
@@ -20,7 +20,7 @@ import {layoutExpand, layoutCheck, layoutGrammar} from '../api/layout.mjs';
20
20
  /** Resolve the expression from arg, --file, or stdin ('-'). */
21
21
  async function readExpression(expr, options) {
22
22
  if (options.file) return fs.readFileSync(options.file, 'utf-8');
23
- if (expr === '-' || (!expr && !process.stdin.isTTY)) {
23
+ if (expr === '-') {
24
24
  const chunks = [];
25
25
  for await (const chunk of process.stdin) chunks.push(chunk);
26
26
  return Buffer.concat(chunks).toString('utf-8');