anhedral 0.18.0 → 0.19.0

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 (119) hide show
  1. package/README.md +6 -6
  2. package/assets/contracts/deployment-provenance.json +6 -6
  3. package/assets/contracts/operations-provenance.json +2 -1
  4. package/assets/launch/oj/OJ.LICENSE +21 -0
  5. package/assets/launch/oj/run.mjs +82 -0
  6. package/assets/launch/oj/runtime.json +21 -0
  7. package/assets/launch/root.tsx.txt +1 -2
  8. package/assets/launch/server.ts.txt +4 -2
  9. package/assets/ui/catalog.json +36 -324
  10. package/dist/{platforms/web.d.ts → api-proxy.d.ts} +1 -3
  11. package/dist/api-proxy.js +48 -0
  12. package/dist/capability-catalog.d.ts +3 -57
  13. package/dist/capability-catalog.js +3 -90
  14. package/dist/capability-command.d.ts +2 -2
  15. package/dist/capability-command.js +32 -96
  16. package/dist/capability-recipes.js +8 -343
  17. package/dist/cli-commands.js +3 -1
  18. package/dist/command-schema.js +106 -0
  19. package/dist/command-types.d.ts +1 -0
  20. package/dist/composition.d.ts +4 -14
  21. package/dist/composition.js +6 -6
  22. package/dist/contracts/cli-transport.d.ts +139 -40
  23. package/dist/contracts/cli-transport.js +96 -27
  24. package/dist/contracts/deployment.d.ts +7 -56
  25. package/dist/contracts/deployment.js +9 -45
  26. package/dist/contracts/production-transport.d.ts +71 -0
  27. package/dist/contracts/production-transport.js +56 -0
  28. package/dist/contracts/source-profile.js +1 -1
  29. package/dist/contracts/staging-transport.d.ts +2 -2
  30. package/dist/dependencies.d.ts +0 -27
  31. package/dist/dependencies.js +3 -67
  32. package/dist/index.d.ts +0 -4
  33. package/dist/index.js +0 -2
  34. package/dist/launch.d.ts +11 -5
  35. package/dist/launch.js +21 -9
  36. package/dist/platform-command.js +245 -42
  37. package/dist/platform-production.d.ts +16 -0
  38. package/dist/platform-production.js +135 -0
  39. package/dist/platform-state.d.ts +2 -0
  40. package/dist/platform-state.js +23 -1
  41. package/dist/platforms/tanstack.d.ts +2 -0
  42. package/dist/platforms/tanstack.js +113 -20
  43. package/dist/registry/usage.js +1 -0
  44. package/dist/scaffold/bootstrap.d.ts +3 -3
  45. package/dist/scaffold/styling.d.ts +3 -2
  46. package/dist/ui-catalog.d.ts +3 -5
  47. package/dist/ui-catalog.js +8 -24
  48. package/dist/ui-command.d.ts +1 -1
  49. package/dist/ui-command.js +18 -57
  50. package/dist/ui-project.d.ts +2 -2
  51. package/dist/ui-project.js +8 -36
  52. package/dist/version.d.ts +1 -1
  53. package/dist/version.js +1 -1
  54. package/docs/capabilities.md +7 -7
  55. package/docs/software-factory.md +55 -16
  56. package/docs/stack-standard.md +1 -1
  57. package/package.json +1 -4
  58. package/assets/stack/ai-schema.ts.txt +0 -5
  59. package/assets/stack/ai.ts.txt +0 -30
  60. package/assets/stack/desktop.rs.txt +0 -21
  61. package/assets/stack/event-retention.sql.txt +0 -10
  62. package/assets/stack/events-schema.ts.txt +0 -12
  63. package/assets/stack/events.ts.txt +0 -59
  64. package/assets/stack/mobile-auth.ts.txt +0 -25
  65. package/assets/stack/mobile-billing.tsx.txt +0 -63
  66. package/assets/stack/mobile-session.tsx.txt +0 -83
  67. package/assets/stack/native-button.tsx.txt +0 -108
  68. package/assets/stack/native-global.css.txt +0 -4
  69. package/assets/stack/native-lib-utils.ts.txt +0 -5
  70. package/assets/stack/native-metro.config.js.txt +0 -6
  71. package/assets/stack/native-nativewind-env.d.ts.txt +0 -1
  72. package/assets/stack/native-tailwind.config.js.txt +0 -73
  73. package/assets/stack/native-text.tsx.txt +0 -89
  74. package/assets/stack/purchases.ts.txt +0 -65
  75. package/assets/stack/revenuecat.ts.txt +0 -88
  76. package/assets/stack/rtc-schema.ts.txt +0 -10
  77. package/assets/stack/rtc.ts.txt +0 -122
  78. package/assets/stack/web-sign-in.tsx.txt +0 -51
  79. package/dist/capabilities.d.ts +0 -11
  80. package/dist/capabilities.js +0 -14
  81. package/dist/dependency-order.d.ts +0 -2
  82. package/dist/dependency-order.js +0 -24
  83. package/dist/platforms/lint.d.ts +0 -1
  84. package/dist/platforms/lint.js +0 -5
  85. package/dist/platforms/web.js +0 -251
  86. package/dist/project-config.d.ts +0 -3
  87. package/dist/project-config.js +0 -16
  88. package/dist/registry/context.d.ts +0 -3
  89. package/dist/registry/context.js +0 -20
  90. package/dist/registry/options.d.ts +0 -2
  91. package/dist/registry/options.js +0 -47
  92. package/dist/registry/resolve.d.ts +0 -11
  93. package/dist/registry/resolve.js +0 -46
  94. package/dist/registry/types.d.ts +0 -60
  95. package/dist/scaffold/api.d.ts +0 -2
  96. package/dist/scaffold/api.js +0 -38
  97. package/dist/scaffold/backend.d.ts +0 -2
  98. package/dist/scaffold/backend.js +0 -36
  99. package/dist/scaffold/compose.d.ts +0 -4
  100. package/dist/scaffold/compose.js +0 -30
  101. package/dist/scaffold/database.d.ts +0 -2
  102. package/dist/scaffold/database.js +0 -41
  103. package/dist/scaffold/documentation.d.ts +0 -2
  104. package/dist/scaffold/documentation.js +0 -71
  105. package/dist/scaffold/environment.d.ts +0 -4
  106. package/dist/scaffold/environment.js +0 -22
  107. package/dist/scaffold/stack-documentation.d.ts +0 -2
  108. package/dist/scaffold/stack-documentation.js +0 -6
  109. package/dist/scaffold/storage.d.ts +0 -2
  110. package/dist/scaffold/storage.js +0 -21
  111. package/dist/scaffold/workspace.d.ts +0 -3
  112. package/dist/scaffold/workspace.js +0 -141
  113. package/dist/stack-registry.d.ts +0 -35
  114. package/dist/stack-registry.js +0 -189
  115. package/dist/standard.d.ts +0 -8
  116. package/dist/standard.js +0 -109
  117. package/dist/workspace-graph.d.ts +0 -7
  118. package/dist/workspace-graph.js +0 -74
  119. /package/dist/{registry/types.js → command-types.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { ANHEDRAL_STACK_DEPENDENCIES, WEB_DEPENDENCIES } from '../dependencies.js';
4
- import { CapabilityEditor } from '../capability-editor.js';
4
+ import { CapabilityEditor, fingerprint } from '../capability-editor.js';
5
5
  import { resourceName } from '../render.js';
6
6
  import { json, put, workerConfig } from '../scaffold/files.js';
7
7
  import { initializeUiMetadata } from '../ui-project.js';
@@ -17,9 +17,10 @@ export function scaffoldTanstack(root, name) {
17
17
  version: '0.1.0',
18
18
  type: 'module',
19
19
  scripts: {
20
- dev: 'vite dev --host 0.0.0.0 --port 3000',
21
- build: 'vite build',
22
- preview: 'vite preview --host 0.0.0.0 --port 3000',
20
+ dev: 'node ../../scripts/oj.mjs dev . --host=0.0.0.0 --port 3000',
21
+ build: 'node ../../scripts/oj.mjs build .',
22
+ preview: 'wrangler dev --config dist/ssr/wrangler.json --port 3000',
23
+ deploy: 'wrangler deploy --config dist/ssr/wrangler.json',
23
24
  typecheck: 'wrangler types && tsr generate && tsc --noEmit',
24
25
  lint: 'eslint . --max-warnings 0',
25
26
  },
@@ -120,36 +121,128 @@ export function cn(...values: ClassValue[]) { return twMerge(clsx(values)); }
120
121
  put(root, `${app}/public/robots.txt`, 'User-agent: *\nAllow: /\n');
121
122
  put(root, `${app}/public/_headers`, '/assets/*\n Cache-Control: public, max-age=31536000, immutable\n/*\n X-Content-Type-Options: nosniff\n');
122
123
  }
123
- function isTanstack(e) {
124
- return Boolean(e.json('apps/web/package.json').dependencies?.['@tanstack/react-start']);
124
+ function assertTanstack(e) {
125
+ if (!e.json('apps/web/package.json').dependencies?.['@tanstack/react-start'])
126
+ throw Error('Only the Anhedral Stack TanStack Start foundation is supported.');
125
127
  }
126
- /** Fingerprinted composition adapters; application routes stay source-owned. */
127
- export function composeTanstack(e, installed) {
128
- if (!isTanstack(e))
129
- return;
128
+ const ojScripts = {
129
+ dev: 'node ../../scripts/oj.mjs dev . --host=0.0.0.0 --port 3000',
130
+ build: 'node ../../scripts/oj.mjs build .',
131
+ preview: 'wrangler dev --config dist/ssr/wrangler.json --port 3000',
132
+ deploy: 'wrangler deploy --config dist/ssr/wrangler.json',
133
+ };
134
+ const previousScripts = {
135
+ dev: 'vite dev --host 0.0.0.0 --port 3000',
136
+ build: 'vite build',
137
+ preview: 'vite preview --host 0.0.0.0 --port 3000',
138
+ };
139
+ const ojFiles = {
140
+ 'scripts/oj.mjs': 'oj/run.mjs',
141
+ 'scripts/oj-runtime.json': 'oj/runtime.json',
142
+ 'scripts/OJ.LICENSE': 'oj/OJ.LICENSE',
143
+ };
144
+ function tanstackViteConfiguration(installed) {
130
145
  const backend = installed.includes('hono');
131
- const auth = installed.includes('database-auth');
132
- e.owned('apps/web/src/server.ts', template(backend ? 'server.ts.txt' : 'minimal-server.ts.txt'));
133
- e.owned('apps/web/src/lib/application.server.ts', template(backend ? 'application.server.ts.txt' : 'minimal-application.server.ts.txt').replaceAll('__AUTHENTICATION__', String(auth)));
134
- e.owned('apps/web/vite.config.ts', `import { fileURLToPath } from 'node:url';
146
+ return `import { fileURLToPath } from 'node:url';
135
147
  import { defineConfig } from 'vite';
136
148
  import { cloudflare } from '@cloudflare/vite-plugin';
137
149
  import { tanstackStart } from '@tanstack/react-start/plugin/vite';
138
150
  import react from '@vitejs/plugin-react';
139
- export default defineConfig({
151
+ export default defineConfig(${backend ? '({ command }) => (' : ''}{
140
152
  resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
141
153
  plugins: [
142
- cloudflare({ viteEnvironment: { name: 'ssr' }, ${backend ? "auxiliaryWorkers: [{ configPath: '../api/wrangler.jsonc' }], persistState: { path: fileURLToPath(new URL('../api/.wrangler/state', import.meta.url)) }, " : ''}remoteBindings: false }),
154
+ cloudflare({ viteEnvironment: { name: 'ssr' }, ${backend ? "auxiliaryWorkers: command === 'serve' ? [{ configPath: '../api/wrangler.jsonc' }] : [], persistState: { path: fileURLToPath(new URL('../api/.wrangler/state', import.meta.url)) }, " : ''}remoteBindings: false }),
143
155
  tanstackStart({ server: { entry: './server.ts' } }),
144
156
  react(),
145
157
  ],
146
- });
147
- `);
158
+ }${backend ? ')' : ''});
159
+ `;
160
+ }
161
+ /** One-time source upgrade, planned in the same bounded overlay as each addition. */
162
+ export function normalizeOjFoundation(e, installed, refreshConfiguration = false) {
163
+ assertTanstack(e);
164
+ const file = 'apps/web/package.json';
165
+ const scripts = e.json(file).scripts;
166
+ if (!scripts || typeof scripts !== 'object' || Array.isArray(scripts))
167
+ throw Error('Preserve invalid web scripts; reconcile the Anhedral Stack launcher first.');
168
+ // Never overwrite a customer launcher while claiming the runtime was upgraded.
169
+ for (const [name, desired] of Object.entries(ojScripts)) {
170
+ const current = scripts[name];
171
+ const previous = Reflect.get(previousScripts, name);
172
+ const previousOjDev = name === 'dev' && current === 'node ../../scripts/oj.mjs dev . --host 0.0.0.0 --port 3000';
173
+ if (current !== undefined && current !== desired && current !== previous && !previousOjDev)
174
+ throw Error(`Preserve customized web launcher scripts.${name}. Reconcile it with the pinned OJ runtime before adding capabilities. No files were changed.`);
175
+ }
176
+ let changed = false;
177
+ const serverEntry = 'apps/web/src/server.ts';
178
+ const currentEntry = e.read(serverEntry);
179
+ // Repair only the exact shipped adapter whose default-entry shim drops Start context in OJ.
180
+ if (installed.includes('hono') &&
181
+ currentEntry !== null &&
182
+ fingerprint(currentEntry) ===
183
+ '703adff2e57adfbbdb7fa90b4dadffde8617c86cc31a185943931ef7c623eca7' &&
184
+ e.managed[serverEntry] === fingerprint(currentEntry)) {
185
+ e.owned(serverEntry, template('server.ts.txt'));
186
+ changed = true;
187
+ }
188
+ const rootRoute = 'apps/web/src/routes/__root.tsx';
189
+ const rootSource = e.read(rootRoute);
190
+ // A one-way repair of the exact shipped document, without owning customer routes.
191
+ if (rootSource !== null &&
192
+ fingerprint(rootSource) === '21af7892e39130c9ec3d7ffb583b3f5d24bee771440ca253d8d7b8ce41be9801') {
193
+ e.writes.set(rootRoute, template('root.tsx.txt'));
194
+ changed = true;
195
+ }
196
+ else if (rootSource !== null && /\bfrom\s*(['"])\.\.\/styles\.css\?url\1/.test(rootSource))
197
+ throw Error('Preserve customized root route CSS. Reconcile its stylesheet URL import with the OJ side-effect CSS pattern before adding capabilities. No files were changed.');
198
+ for (const [name, desired] of Object.entries(ojScripts)) {
199
+ if (scripts[name] !== desired) {
200
+ e.set(file, ['scripts', name], desired);
201
+ changed = true;
202
+ }
203
+ }
204
+ for (const [destination, asset] of Object.entries(ojFiles)) {
205
+ const desired = template(asset);
206
+ if (e.read(destination) !== desired) {
207
+ e.owned(destination, desired);
208
+ changed = true;
209
+ }
210
+ else if (e.managed[destination] !== fingerprint(desired)) {
211
+ e.managed[destination] = fingerprint(desired);
212
+ changed = true;
213
+ }
214
+ }
215
+ const ignore = e.read('.gitignore') ?? '';
216
+ if (!ignore.split(/\r?\n/).includes('.oj-cache/')) {
217
+ e.writes.set('.gitignore', ignore + (ignore && !ignore.endsWith('\n') ? '\n' : '') + '.oj-cache/\n');
218
+ changed = true;
219
+ }
220
+ const configuration = 'apps/web/vite.config.ts';
221
+ const currentConfiguration = e.read(configuration);
222
+ const desiredConfiguration = tanstackViteConfiguration(installed);
223
+ if (currentConfiguration !== desiredConfiguration &&
224
+ (changed ||
225
+ refreshConfiguration ||
226
+ (currentConfiguration !== null &&
227
+ e.managed[configuration] === fingerprint(currentConfiguration)))) {
228
+ e.owned(configuration, desiredConfiguration);
229
+ changed = true;
230
+ }
231
+ return changed;
232
+ }
233
+ /** Fingerprinted composition adapters; application routes stay source-owned. */
234
+ export function composeTanstack(e, installed) {
235
+ assertTanstack(e);
236
+ normalizeOjFoundation(e, installed);
237
+ const backend = installed.includes('hono');
238
+ const auth = installed.includes('database-auth');
239
+ e.owned('apps/web/src/server.ts', template(backend ? 'server.ts.txt' : 'minimal-server.ts.txt'));
240
+ e.owned('apps/web/src/lib/application.server.ts', template(backend ? 'application.server.ts.txt' : 'minimal-application.server.ts.txt').replaceAll('__AUTHENTICATION__', String(auth)));
241
+ e.owned('apps/web/vite.config.ts', tanstackViteConfiguration(installed));
148
242
  }
149
243
  /** Install account source only when the backend authentication capability is added. */
150
244
  export function addTanstackAuth(e) {
151
- if (!isTanstack(e))
152
- return;
245
+ assertTanstack(e);
153
246
  e.create('apps/web/src/lib/auth-client.ts', template('auth-client.ts.txt'));
154
247
  e.create('apps/web/src/routes/sign-in.tsx', template('sign-in.tsx.txt'));
155
248
  }
@@ -41,6 +41,7 @@ Inspect source and UI:
41
41
  Optional Platform access:
42
42
  login/logout Approve or revoke a CLI session.
43
43
  whoami Inspect the current identity and optional local context.
44
+ projects List or create Platform projects.
44
45
  link/unlink Select an existing project or remove its local link.
45
46
  source Upload source or inspect its receipt.
46
47
  deploy Plan, prepare or inspect a candidate; never activates it.
@@ -1,4 +1,4 @@
1
- import type { StandardRunner } from '../registry/types.js';
2
- export declare function assertWorkspaceRuntime(run: StandardRunner, version?: string): void;
1
+ import type { CommandRunner } from '../command-types.js';
2
+ export declare function assertWorkspaceRuntime(run: CommandRunner, version?: string): void;
3
3
  /** No downloaded template, disposable Next app or initialization-time cloud operation. */
4
- export declare function bootstrapWorkspace(root: string, name: string, run: StandardRunner): void;
4
+ export declare function bootstrapWorkspace(root: string, name: string, run: CommandRunner): void;
@@ -1,3 +1,4 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
1
  /** One shared token source for native components and DOM CSS. */
3
- export declare function scaffoldStyling({ root }: Pick<RecipeContext, 'root'>): void;
2
+ export declare function scaffoldStyling({ root }: {
3
+ root: string;
4
+ }): void;
@@ -1,4 +1,4 @@
1
- export type UiPlatform = 'web' | 'native';
1
+ export type UiPlatform = 'web';
2
2
  export interface UiSource {
3
3
  item: string;
4
4
  dependencies: string[];
@@ -8,18 +8,16 @@ export interface UiSource {
8
8
  export interface UiComponent {
9
9
  name: string;
10
10
  web: UiSource | null;
11
- native: UiSource | null;
12
11
  }
13
12
  export declare const UI_CATALOG: {
14
13
  schemaVersion: number;
15
14
  revision: string;
16
- nativeStyling: string;
17
15
  shadcnCliVersion: string;
18
16
  sources: Record<string, string>;
19
17
  components: UiComponent[];
20
18
  };
21
- /** Resolve names only. Upstream shadcn owns dependency resolution and source installation. */
22
- export declare function resolveUiItems(names: string[], platform: UiPlatform, extensionRoot?: string): {
19
+ /** Resolve source-owned shadcn names for the single Anhedral Stack web foundation. */
20
+ export declare function resolveUiItems(names: string[], platform: UiPlatform): {
23
21
  name: string;
24
22
  source: string;
25
23
  item: string;
@@ -1,31 +1,15 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import path from 'node:path';
1
+ import { readFileSync } from 'node:fs';
4
2
  export const UI_CATALOG = JSON.parse(readFileSync(new URL('../assets/ui/catalog.json', import.meta.url), 'utf8'));
5
- const extensions = fileURLToPath(new URL('../assets/ui/extensions/', import.meta.url));
6
- /** Resolve names only. Upstream shadcn owns dependency resolution and source installation. */
7
- export function resolveUiItems(names, platform, extensionRoot = extensions) {
8
- const registry = JSON.parse(readFileSync(path.join(extensionRoot, 'registry.json'), 'utf8'));
3
+ /** Resolve source-owned shadcn names for the single Anhedral Stack web foundation. */
4
+ export function resolveUiItems(names, platform) {
5
+ if (platform !== 'web')
6
+ throw Error('Only the Anhedral Stack web UI is supported.');
9
7
  return [...new Set(names)].map((name) => {
10
8
  if (!/^[a-z][a-z0-9-]{0,79}$/.test(name))
11
9
  throw Error(`Invalid component name: ${name}.`);
12
10
  const component = UI_CATALOG.components.find((item) => item.name === name);
13
- if (!component)
14
- throw Error(`Unknown UI component: ${name}. Run anhedral ui list.`);
15
- if (platform === 'native' && registry.items.some((item) => item.name === name)) {
16
- const file = path.join(extensionRoot, `${name}.json`);
17
- if (!existsSync(file))
18
- throw Error(`Missing reviewed Anhedral extension: ${name}.`);
19
- return { name, source: 'anhedral', item: file };
20
- }
21
- if (!component[platform])
22
- throw Error(`${name} is not yet available for ${platform}. No substitute was installed.`);
23
- return {
24
- name,
25
- source: platform === 'web' ? 'shadcn' : 'react-native-reusables',
26
- item: platform === 'web'
27
- ? name
28
- : `https://reactnativereusables.com/r/nativewind/${component.native.item}.json`,
29
- };
11
+ if (!component?.web)
12
+ throw Error(`Unknown shadcn component: ${name}. Run anhedral ui list.`);
13
+ return { name, source: 'shadcn', item: name };
30
14
  });
31
15
  }
@@ -2,4 +2,4 @@ import { type OutputOptions } from './cli-output.js';
2
2
  export type UiRunner = (args: string[], cwd: string) => string | Promise<string>;
3
3
  /** Public UI surface: one Anhedral Stack web target, with no native install fallback. */
4
4
  export declare function runAnhedralUiCommand(args: string[], output: OutputOptions, run?: UiRunner): Promise<void>;
5
- export declare function runUiCommand(args: string[], output: OutputOptions, run?: UiRunner, mode?: 'compatibility' | 'public'): Promise<void>;
5
+ export declare function runUiCommand(args: string[], output: OutputOptions, run?: UiRunner): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { existsSync, writeFileSync } from 'node:fs';
1
+ import { existsSync } from 'node:fs';
2
2
  import { MAX_PROJECT_JSON_BYTES, readBoundedFile } from './bounded-file.js';
3
3
  import path from 'node:path';
4
4
  import { stripVTControlCharacters } from 'node:util';
@@ -98,7 +98,7 @@ function assertAnhedralStackTarget(target) {
98
98
  if (existsSync(metadata)) {
99
99
  const project = JSON.parse(readBoundedFile(metadata, MAX_PROJECT_JSON_BYTES).toString('utf8'));
100
100
  if (project?.schemaVersion !== 1 ||
101
- ![ANHEDRAL_STACK.id, 'anhedral-web-launch'].includes(project.setup?.stack) ||
101
+ project.setup?.stack !== ANHEDRAL_STACK.id ||
102
102
  project.composition?.contractVersion !== 2 ||
103
103
  project.composition?.foundation !== ANHEDRAL_STACK.foundation.id ||
104
104
  path.join(root, 'apps', 'web') !== target.root)
@@ -113,40 +113,32 @@ function assertAnhedralStackTarget(target) {
113
113
  }
114
114
  /** Public UI surface: one Anhedral Stack web target, with no native install fallback. */
115
115
  export async function runAnhedralUiCommand(args, output, run = runUpstream) {
116
- return runUiCommand(args, output, run, 'public');
116
+ return runUiCommand(args, output, run);
117
117
  }
118
- export async function runUiCommand(args, output, run = runUpstream, mode = 'compatibility') {
119
- if (mode === 'public' && args.some((arg) => /^--(?:native|all)(?:=|$)/.test(arg)))
118
+ export async function runUiCommand(args, output, run = runUpstream) {
119
+ if (args.some((arg) => /^--(?:native|all)(?:=|$)/.test(arg)))
120
120
  throw commandArgumentError('ui', 'Anhedral UI supports the Anhedral Stack web application only. Use --web or select apps/web with --cwd.');
121
- // Retained direct library callers can inspect legacy source; the executable uses public mode.
122
- const legacySelectors = mode === 'compatibility' ? args.filter((arg) => ['--native', '--all'].includes(arg)) : [];
123
- if (new Set(legacySelectors).size !== legacySelectors.length)
124
- throw commandArgumentError('ui', 'Specify each UI selector only once.');
125
- const parsed = commandArguments('ui', args.filter((arg) => !legacySelectors.includes(arg)));
121
+ const parsed = commandArguments('ui', args);
126
122
  const [action, ...names] = parsed.positional;
127
123
  if (!['init', 'add', 'list', 'diff', 'doctor'].includes(action))
128
124
  throw commandArgumentError('ui', 'Choose ui init, add, list, diff or doctor.');
129
125
  if (['add', 'diff'].includes(action) ? !names.length || names.length > 50 : names.length > 0)
130
126
  throw commandArgumentError('ui', 'Supply component names only for add/diff (at most 50).');
131
- const selectors = ['--web', '--native', '--all'].filter((flag) => parsed.has(flag) || legacySelectors.includes(flag));
132
- if (selectors.length > 1)
133
- throw commandArgumentError('ui', 'Choose one of --web, --native or --all.');
134
- const selector = mode === 'public' ? 'web' : selectors[0]?.slice(2);
127
+ const selector = 'web';
135
128
  let result;
136
129
  if (action === 'list') {
137
130
  result = {
138
131
  catalogRevision: UI_CATALOG.revision,
139
- ...(mode === 'public' ? { platform: 'web' } : { nativeStyling: UI_CATALOG.nativeStyling }),
132
+ ...{ platform: 'web' },
140
133
  components: UI_CATALOG.components
141
- .filter((item) => !selector || selector === 'all' || item[selector])
142
- .map((item) => (mode === 'public' ? { name: item.name, web: item.web } : item)),
134
+ .filter((item) => item[selector])
135
+ .map((item) => ({ name: item.name, web: item.web })),
143
136
  };
144
137
  }
145
138
  else {
146
139
  const targets = detectUiTargets(process.cwd(), selector);
147
- if (mode === 'public')
148
- for (const target of targets)
149
- assertAnhedralStackTarget(target);
140
+ for (const target of targets)
141
+ assertAnhedralStackTarget(target);
150
142
  if (action === 'doctor') {
151
143
  const reports = targets.map(inspectUiTarget);
152
144
  result = {
@@ -157,27 +149,21 @@ export async function runUiCommand(args, output, run = runUpstream, mode = 'comp
157
149
  process.exitCode = 1;
158
150
  }
159
151
  else {
160
- // Preflight every target before invoking any installer, including explicit --all.
152
+ // Preflight every target before invoking any installer, before source installation.
161
153
  const plans = targets.map((target) => {
162
154
  assertUiMetadataPaths(target.root);
163
155
  const report = inspectUiTarget(target);
164
156
  const configExists = existsSync(path.join(target.root, 'components.json'));
165
- const nativeInit = action === 'init' && target.platform === 'native';
166
- const issues = nativeInit
167
- ? report.issues.filter((issue) => !issue.startsWith('Missing components.json'))
168
- : report.issues;
169
- if ((action !== 'init' || target.platform === 'native' || configExists) && issues.length)
157
+ const issues = report.issues;
158
+ if ((action !== 'init' || configExists) && issues.length)
170
159
  throw Error(issues.join('\n') + '\n' + report.guide);
171
- if (nativeInit && !configExists && !existsSync(path.join(target.root, 'global.css')))
172
- throw Error('Native init needs the upstream NativeWind global.css. Complete the RNR setup first.');
173
160
  const items = action === 'init' ? [] : resolveUiItems(names, target.platform);
174
161
  return {
175
162
  root: target.root,
176
163
  platform: target.platform,
177
164
  items,
178
- nativeInit,
179
165
  command: action === 'init'
180
- ? configExists || nativeInit
166
+ ? configExists
181
167
  ? []
182
168
  : ['init', '--base', 'base', '--defaults', '--no-reinstall', '--no-monorepo']
183
169
  : [
@@ -190,29 +176,6 @@ export async function runUiCommand(args, output, run = runUpstream, mode = 'comp
190
176
  });
191
177
  if (!parsed.has('--dry-run')) {
192
178
  for (const plan of plans) {
193
- if (plan.nativeInit && !existsSync(path.join(plan.root, 'components.json'))) {
194
- if (!existsSync(path.join(plan.root, 'global.css')))
195
- throw Error('Native init needs the upstream NativeWind global.css. Complete the RNR setup first.');
196
- writeFileSync(path.join(plan.root, 'components.json'), JSON.stringify({
197
- $schema: 'https://ui.shadcn.com/schema.json',
198
- style: 'new-york',
199
- rsc: false,
200
- tsx: true,
201
- tailwind: {
202
- config: 'tailwind.config.js',
203
- css: 'global.css',
204
- baseColor: 'neutral',
205
- cssVariables: true,
206
- },
207
- aliases: {
208
- components: '@/components',
209
- ui: '@/components/ui',
210
- utils: '@/lib/utils',
211
- lib: '@/lib',
212
- hooks: '@/hooks',
213
- },
214
- }, null, 2) + '\n', { flag: 'wx' });
215
- }
216
179
  const vendorOutput = plan.command.length ? await run(plan.command, plan.root) : '';
217
180
  if (action === 'init' || action === 'add')
218
181
  initializeUiMetadata(plan.root, plan.platform);
@@ -229,10 +192,8 @@ export async function runUiCommand(args, output, run = runUpstream, mode = 'comp
229
192
  }
230
193
  createReporter(output, () => action === 'list'
231
194
  ? UI_CATALOG.components
232
- .filter((item) => !selector || selector === 'all' || item[selector])
233
- .map((item) => mode === 'public'
234
- ? `${item.name}\tshadcn`
235
- : `${item.name}\tweb: ${item.web ? 'shadcn' : 'unavailable'}\tnative: ${item.native ? 'RNR (validation required)' : 'unavailable'}`)
195
+ .filter((item) => item[selector])
196
+ .map((item) => `${item.name}\tshadcn`)
236
197
  .join('\n')
237
198
  : action === 'doctor'
238
199
  ? result.targets
@@ -8,10 +8,10 @@ export interface UiTarget {
8
8
  platform: UiPlatform;
9
9
  manifest: Manifest;
10
10
  }
11
- export declare function detectUiTargets(cwd: string, selector?: UiPlatform | 'all'): UiTarget[];
11
+ export declare function detectUiTargets(cwd: string, selector?: UiPlatform): UiTarget[];
12
12
  export declare function inspectUiTarget(target: UiTarget): {
13
13
  root: string;
14
- platform: UiPlatform;
14
+ platform: "web";
15
15
  configurationReady: boolean;
16
16
  issues: string[];
17
17
  runtimeAcceptance: string;
@@ -15,10 +15,8 @@ export function detectUiTargets(cwd, selector) {
15
15
  return;
16
16
  const manifest = readUiJson(file);
17
17
  const dependencies = { ...manifest.devDependencies, ...manifest.dependencies };
18
- if (dependencies.next || dependencies['@tanstack/react-start'])
18
+ if (dependencies['@tanstack/react-start'])
19
19
  targets.push({ root: directory, platform: 'web', manifest });
20
- if (dependencies.expo)
21
- targets.push({ root: directory, platform: 'native', manifest });
22
20
  }
23
21
  for (;;) {
24
22
  inspect(root);
@@ -34,14 +32,14 @@ export function detectUiTargets(cwd, selector) {
34
32
  break;
35
33
  root = parent;
36
34
  }
37
- if (selector && selector !== 'all')
35
+ if (selector)
38
36
  targets = targets.filter((target) => target.platform === selector);
39
37
  if (!targets.length)
40
- throw Error('No matching Next.js, TanStack Start or Expo application found. Use --cwd to select an application.');
41
- if (targets.length > 1 && selector !== 'all')
42
- throw Error('Multiple UI applications found. Select --web, --native, --all, or use --cwd for one application.');
38
+ throw Error('No Anhedral Stack TanStack Start application found. Use --cwd to select apps/web.');
39
+ if (targets.length > 1)
40
+ throw Error('Multiple web applications found. Use --cwd to select apps/web.');
43
41
  if (new Set(targets.map((target) => target.root)).size !== targets.length)
44
- throw Error('Web and native UI must use separate application directories.');
42
+ throw Error('UI application directories must be distinct.');
45
43
  return targets;
46
44
  }
47
45
  export function inspectUiTarget(target) {
@@ -55,36 +53,13 @@ export function inspectUiTarget(target) {
55
53
  const marker = path.join(target.root, '.anhedral-ui.json');
56
54
  if (existsSync(marker) && readUiJson(marker).platform !== target.platform)
57
55
  issues.push('Existing Anhedral UI configuration targets another platform.');
58
- if (target.platform === 'native') {
59
- const dependencies = { ...target.manifest.devDependencies, ...target.manifest.dependencies };
60
- for (const dependency of [
61
- 'class-variance-authority',
62
- 'clsx',
63
- 'tailwind-merge',
64
- 'tailwindcss-animate',
65
- '@rn-primitives/portal',
66
- ])
67
- if (!dependencies[dependency])
68
- issues.push(`Missing RNR baseline dependency: ${dependency}. Complete the upstream setup first.`);
69
- if (!/^\D*4\./.test(dependencies.nativewind ?? ''))
70
- issues.push('Set up NativeWind 4 using the RNR manual guide before native UI installation.');
71
- if (!['metro.config.js', 'metro.config.cjs', 'metro.config.ts'].some((name) => existsSync(path.join(target.root, name))))
72
- issues.push('Missing Metro configuration. Complete the upstream NativeWind setup first.');
73
- if (config?.rsc)
74
- issues.push('Native components.json must set rsc to false.');
75
- }
76
56
  return {
77
57
  root: target.root,
78
58
  platform: target.platform,
79
59
  configurationReady: issues.length === 0,
80
60
  issues,
81
61
  runtimeAcceptance: 'not evaluated',
82
- guide: target.platform === 'native'
83
- ? 'https://reactnativereusables.com/docs/installation/manual'
84
- : target.manifest.dependencies?.['@tanstack/react-start'] ||
85
- target.manifest.devDependencies?.['@tanstack/react-start']
86
- ? 'https://ui.shadcn.com/docs/installation/tanstack'
87
- : 'https://ui.shadcn.com/docs/installation/next',
62
+ guide: 'https://ui.shadcn.com/docs/installation/tanstack',
88
63
  };
89
64
  }
90
65
  /** Check CLI-owned destinations before upstream or attribution writes. */
@@ -122,15 +97,12 @@ export function initializeUiMetadata(root, platform) {
122
97
  schemaVersion: 1,
123
98
  platform,
124
99
  catalogRevision: UI_CATALOG.revision,
125
- nativeStyling: platform === 'native' ? UI_CATALOG.nativeStyling : undefined,
126
100
  sourceOwned: true,
127
101
  automaticUpdates: false,
128
102
  }, null, 2) + '\n', { flag: 'wx' });
129
103
  const licenses = path.join(root, 'ANHEDRAL_UI_LICENSES');
130
104
  mkdirSync(licenses, { recursive: true });
131
- for (const name of platform === 'native'
132
- ? ['LICENSE.react-native-reusables', 'LICENSE.shadcn']
133
- : ['LICENSE.shadcn']) {
105
+ for (const name of ['LICENSE.shadcn']) {
134
106
  const destination = path.join(licenses, name);
135
107
  if (!existsSync(destination))
136
108
  writeFileSync(destination, readFileSync(new URL(`../assets/ui/${name}`, import.meta.url)), {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const GENERATOR_VERSION = "0.18.0";
1
+ export declare const GENERATOR_VERSION = "0.19.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const GENERATOR_VERSION = '0.18.0';
1
+ export const GENERATOR_VERSION = '0.19.0';
@@ -11,21 +11,21 @@ anhedral add r2 stripe
11
11
  anhedral stack status --json
12
12
  ```
13
13
 
14
- | Selection | Source added | Requires |
15
- | --- | --- | --- |
16
- | `backend` | Hono API, Drizzle/D1, Better Auth and web sign-in starter | Anhedral Stack web foundation |
17
- | `r2` | Private storage binding and authenticated owner-scoped file routes | `backend` |
18
- | `stripe` | Subscription Checkout, signed webhooks and canonical entitlement checks | `backend` |
14
+ | Selection | Source added | Requires |
15
+ | --------- | ----------------------------------------------------------------------- | ----------------------------- |
16
+ | `backend` | Hono API, Drizzle/D1, Better Auth and web sign-in starter | Anhedral Stack web foundation |
17
+ | `r2` | Private storage binding and authenticated owner-scoped file routes | `backend` |
18
+ | `stripe` | Subscription Checkout, signed webhooks and canonical entitlement checks | `backend` |
19
19
 
20
20
  `backend` is one public selection; its provenance records the concrete Hono and database/auth capabilities. Use `--with-dependencies` to include missing prerequisites in the same planned source transaction. `stack list` describes this stack's additions. `status`/`doctor` check source completeness, not live service activation.
21
21
 
22
22
  ## Source protection
23
23
 
24
- Additions never reinitialize an application. They plan all selected changes before writing, reject collisions and preserve unrelated JSON/JSONC settings. Composition adapters are fingerprinted in `anhedral.json`; modified adapters require reconciliation instead of silent replacement. Add product routes in `apps/api/src/index.ts`, custom types in `custom-environment.ts`, and auth method configuration in `auth-features.ts`/`auth.ts`.
24
+ Adding a capability also upgrades a canonical earlier TanStack Start foundation to the pinned OJ launchers and runtime helpers in the same source transaction, including when that capability is already installed. The exact earlier canonical document also receives the OJ-compatible side-effect CSS import; safe customized documents stay untouched, while edited documents retaining the earlier stylesheet URL import require reconciliation. Customized launchers or generated configuration require reconciliation before any writes. Additions never reinitialize an application. They plan all selected changes before writing, reject collisions and preserve unrelated JSON/JSONC settings. Composition adapters are fingerprinted in `anhedral.json`; modified adapters require reconciliation instead of silent replacement. Add product routes in `apps/api/src/index.ts`, custom types in `custom-environment.ts`, and auth method configuration in `auth-features.ts`/`auth.ts`.
25
25
 
26
26
  Journaled transactions preserve recovery evidence and refuse ambiguous recreated files. Dependency installation follows source commit; a post-commit install failure keeps source for repair/retry. Reviewed dependency patches precede the frozen install. `--skip-install` writes source only. `--dry-run` performs no writes or network requests. Repeating an addition preserves source; normal installation may still retry dependencies.
27
27
 
28
- There is no implicit capability removal or resource/data deletion. Existing applications retain their source and identity. Legacy generators and broader recipe implementations are retained for compatibility and recovery, not exposed as current stack options.
28
+ There is no implicit capability removal or resource/data deletion. Existing applications retain their source and identity. Only the OJ/TanStack Start foundation and these three additions are supported.
29
29
 
30
30
  ## Local setup and validation
31
31