anhedral 0.16.0 → 0.18.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 (195) hide show
  1. package/README.md +42 -20
  2. package/assets/contracts/LICENSE +201 -0
  3. package/assets/contracts/LICENSE.environment +201 -0
  4. package/assets/contracts/LICENSE.operations +201 -0
  5. package/assets/contracts/deployment-provenance.json +15 -0
  6. package/assets/contracts/environment-provenance.json +11 -0
  7. package/assets/contracts/operations-provenance.json +11 -0
  8. package/assets/launch/application.server.ts.txt +13 -0
  9. package/assets/launch/auth-client.ts.txt +4 -0
  10. package/assets/launch/home.tsx.txt +20 -0
  11. package/assets/launch/minimal-application.server.ts.txt +5 -0
  12. package/assets/launch/minimal-server.ts.txt +7 -0
  13. package/assets/launch/request-context.ts.txt +3 -0
  14. package/assets/launch/root.tsx.txt +27 -0
  15. package/assets/launch/router.tsx.txt +21 -0
  16. package/assets/launch/server.ts.txt +13 -0
  17. package/assets/launch/sign-in.tsx.txt +53 -0
  18. package/assets/launch/styles.css.txt +19 -0
  19. package/assets/security/credential-patterns.d.mts +3 -0
  20. package/assets/security/credential-patterns.mjs +59 -0
  21. package/assets/stack/api-index.ts.txt +6 -1
  22. package/assets/stack/event-retention.sql.txt +10 -0
  23. package/assets/stack/stripe.ts.txt +30 -13
  24. package/assets/ui/UPSTREAM.json +1 -18
  25. package/dist/bin.js +55 -36
  26. package/dist/capabilities.d.ts +1 -1
  27. package/dist/capability-catalog.d.ts +44 -11
  28. package/dist/capability-catalog.js +96 -11
  29. package/dist/capability-command.d.ts +2 -2
  30. package/dist/capability-command.js +178 -27
  31. package/dist/capability-editor.js +6 -5
  32. package/dist/capability-recipes.js +54 -6
  33. package/dist/cli-arguments.d.ts +2 -0
  34. package/dist/cli-arguments.js +101 -50
  35. package/dist/cli-commands.d.ts +1 -1
  36. package/dist/cli-commands.js +30 -6
  37. package/dist/cli-errors.d.ts +18 -0
  38. package/dist/cli-errors.js +63 -0
  39. package/dist/cli-output.d.ts +22 -0
  40. package/dist/cli-output.js +42 -7
  41. package/dist/command-runner.d.ts +1 -0
  42. package/dist/command-runner.js +88 -0
  43. package/dist/command-schema.d.ts +16 -0
  44. package/dist/command-schema.js +390 -21
  45. package/dist/completion.d.ts +2 -0
  46. package/dist/completion.js +201 -0
  47. package/dist/composition.d.ts +35 -0
  48. package/dist/composition.js +28 -0
  49. package/dist/contracts/cli-transport.d.ts +217 -0
  50. package/dist/contracts/cli-transport.js +167 -0
  51. package/dist/contracts/deployment.d.ts +282 -0
  52. package/dist/contracts/deployment.js +234 -0
  53. package/dist/contracts/environment-file.d.ts +7 -0
  54. package/dist/contracts/environment-file.js +112 -0
  55. package/dist/contracts/environment-transport.d.ts +79 -0
  56. package/dist/contracts/environment-transport.js +110 -0
  57. package/dist/contracts/runtime-logs-transport.d.ts +127 -0
  58. package/dist/contracts/runtime-logs-transport.js +50 -0
  59. package/dist/contracts/source-bundle.d.ts +11 -0
  60. package/dist/contracts/source-bundle.js +197 -0
  61. package/dist/contracts/source-profile.d.ts +4 -0
  62. package/dist/contracts/source-profile.js +5 -0
  63. package/dist/contracts/staging-transport.d.ts +79 -0
  64. package/dist/contracts/staging-transport.js +43 -0
  65. package/dist/dependencies.d.ts +10 -4
  66. package/dist/dependencies.js +17 -54
  67. package/dist/index.d.ts +6 -0
  68. package/dist/index.js +4 -0
  69. package/dist/launch.d.ts +21 -0
  70. package/dist/launch.js +250 -0
  71. package/dist/platform-command.d.ts +9 -0
  72. package/dist/platform-command.js +584 -0
  73. package/dist/platform-environment.d.ts +18 -0
  74. package/dist/platform-environment.js +257 -0
  75. package/dist/platform-operations.d.ts +26 -0
  76. package/dist/platform-operations.js +155 -0
  77. package/dist/platform-source.d.ts +8 -0
  78. package/dist/platform-source.js +111 -0
  79. package/dist/platform-state.d.ts +13 -0
  80. package/dist/platform-state.js +207 -0
  81. package/dist/platforms/tanstack.d.ts +8 -0
  82. package/dist/platforms/tanstack.js +155 -0
  83. package/dist/registry/options.js +34 -31
  84. package/dist/registry/resolve.js +2 -0
  85. package/dist/registry/usage.d.ts +4 -1
  86. package/dist/registry/usage.js +58 -4
  87. package/dist/scaffold/documentation.js +17 -48
  88. package/dist/scaffold/styling.d.ts +1 -1
  89. package/dist/scaffold/workspace.js +11 -7
  90. package/dist/stack-registry.d.ts +2 -4
  91. package/dist/stack-registry.js +1 -11
  92. package/dist/standard.js +21 -6
  93. package/dist/transaction.js +28 -3
  94. package/dist/ui-command.d.ts +4 -2
  95. package/dist/ui-command.js +79 -38
  96. package/dist/ui-project.d.ts +2 -0
  97. package/dist/ui-project.js +38 -8
  98. package/dist/util.js +40 -61
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.js +1 -1
  101. package/docs/capabilities.md +22 -88
  102. package/docs/software-factory.md +189 -16
  103. package/docs/stack-standard.md +6 -18
  104. package/docs/ui.md +9 -22
  105. package/docs/verification.md +6 -1067
  106. package/package.json +33 -22
  107. package/assets/ui/native/_controls.tsx +0 -521
  108. package/assets/ui/native/_core.tsx +0 -118
  109. package/assets/ui/native/_data.tsx +0 -200
  110. package/assets/ui/native/_display.tsx +0 -453
  111. package/assets/ui/native/_feedback.tsx +0 -242
  112. package/assets/ui/native/_legacy-dialog.tsx +0 -38
  113. package/assets/ui/native/_motion.tsx +0 -520
  114. package/assets/ui/native/_overlay.tsx +0 -402
  115. package/assets/ui/native/_selection.tsx +0 -366
  116. package/assets/ui/native/accordion.tsx +0 -1
  117. package/assets/ui/native/alert-dialog.tsx +0 -11
  118. package/assets/ui/native/alert.tsx +0 -1
  119. package/assets/ui/native/aspect-ratio.tsx +0 -1
  120. package/assets/ui/native/attachment.tsx +0 -8
  121. package/assets/ui/native/avatar.tsx +0 -8
  122. package/assets/ui/native/badge.tsx +0 -1
  123. package/assets/ui/native/breadcrumb.tsx +0 -9
  124. package/assets/ui/native/bubble.tsx +0 -1
  125. package/assets/ui/native/button-group.tsx +0 -1
  126. package/assets/ui/native/button.tsx +0 -86
  127. package/assets/ui/native/calendar.tsx +0 -170
  128. package/assets/ui/native/card.tsx +0 -44
  129. package/assets/ui/native/carousel.tsx +0 -1
  130. package/assets/ui/native/chart.tsx +0 -193
  131. package/assets/ui/native/checkbox.tsx +0 -1
  132. package/assets/ui/native/code-block.tsx +0 -137
  133. package/assets/ui/native/collapsible.tsx +0 -1
  134. package/assets/ui/native/combobox.tsx +0 -1
  135. package/assets/ui/native/command.tsx +0 -11
  136. package/assets/ui/native/context-menu.tsx +0 -16
  137. package/assets/ui/native/data-table.tsx +0 -1
  138. package/assets/ui/native/date-picker.tsx +0 -43
  139. package/assets/ui/native/dialog.tsx +0 -15
  140. package/assets/ui/native/direction.tsx +0 -1
  141. package/assets/ui/native/drawer.tsx +0 -10
  142. package/assets/ui/native/dropdown-menu.tsx +0 -16
  143. package/assets/ui/native/empty.tsx +0 -8
  144. package/assets/ui/native/field.tsx +0 -13
  145. package/assets/ui/native/hover-card.tsx +0 -1
  146. package/assets/ui/native/input-group.tsx +0 -8
  147. package/assets/ui/native/input-otp.tsx +0 -1
  148. package/assets/ui/native/input.tsx +0 -28
  149. package/assets/ui/native/item.tsx +0 -12
  150. package/assets/ui/native/kbd.tsx +0 -1
  151. package/assets/ui/native/label.tsx +0 -4
  152. package/assets/ui/native/layout.tsx +0 -26
  153. package/assets/ui/native/marker.tsx +0 -1
  154. package/assets/ui/native/menubar.tsx +0 -17
  155. package/assets/ui/native/message-scroller.tsx +0 -6
  156. package/assets/ui/native/message.tsx +0 -10
  157. package/assets/ui/native/native-select.tsx +0 -1
  158. package/assets/ui/native/navigation-menu.tsx +0 -10
  159. package/assets/ui/native/pagination.tsx +0 -9
  160. package/assets/ui/native/popover.tsx +0 -1
  161. package/assets/ui/native/progress.tsx +0 -1
  162. package/assets/ui/native/questionnaire.tsx +0 -130
  163. package/assets/ui/native/radio-group.tsx +0 -1
  164. package/assets/ui/native/registry.json +0 -1103
  165. package/assets/ui/native/resizable.tsx +0 -1
  166. package/assets/ui/native/scroll-area.tsx +0 -1
  167. package/assets/ui/native/select.tsx +0 -11
  168. package/assets/ui/native/separator.tsx +0 -1
  169. package/assets/ui/native/sheet.tsx +0 -10
  170. package/assets/ui/native/sidebar.tsx +0 -22
  171. package/assets/ui/native/skeleton.tsx +0 -1
  172. package/assets/ui/native/slider.tsx +0 -1
  173. package/assets/ui/native/spinner.tsx +0 -1
  174. package/assets/ui/native/switch.tsx +0 -1
  175. package/assets/ui/native/table.tsx +0 -10
  176. package/assets/ui/native/tabs.tsx +0 -1
  177. package/assets/ui/native/text.tsx +0 -20
  178. package/assets/ui/native/textarea.tsx +0 -1
  179. package/assets/ui/native/theme-switcher.tsx +0 -22
  180. package/assets/ui/native/toast.tsx +0 -11
  181. package/assets/ui/native/toggle-group.tsx +0 -1
  182. package/assets/ui/native/toggle.tsx +0 -1
  183. package/assets/ui/native/tooltip.tsx +0 -1
  184. package/assets/ui/native/trace.tsx +0 -20
  185. package/assets/ui/native/typography.tsx +0 -15
  186. package/assets/ui/theme-storage.ts +0 -25
  187. package/assets/ui/theme.tsx +0 -66
  188. package/dist/platforms/mobile.d.ts +0 -2
  189. package/dist/platforms/mobile.js +0 -137
  190. package/dist/scaffold/expo-runtime.d.ts +0 -3
  191. package/dist/scaffold/expo-runtime.js +0 -42
  192. package/dist/scaffold/native-ui.d.ts +0 -2
  193. package/dist/scaffold/native-ui.js +0 -74
  194. package/docs/anhedral-stack.md +0 -7
  195. package/docs/native-ui.md +0 -102
@@ -1 +0,0 @@
1
- export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './_motion';
@@ -1 +0,0 @@
1
- export { ScrollArea, ScrollBar } from './_data';
@@ -1,11 +0,0 @@
1
- export {
2
- Select,
3
- SelectTrigger,
4
- SelectValue,
5
- SelectContent,
6
- SelectItem,
7
- SelectGroup,
8
- SelectLabel,
9
- SelectItemText,
10
- SelectSeparator,
11
- } from './_selection';
@@ -1 +0,0 @@
1
- export { Separator } from './_display';
@@ -1,10 +0,0 @@
1
- export {
2
- Sheet,
3
- SheetTrigger,
4
- SheetContent,
5
- SheetClose,
6
- SheetHeader,
7
- SheetFooter,
8
- SheetTitle,
9
- SheetDescription,
10
- } from './_overlay';
@@ -1,22 +0,0 @@
1
- export {
2
- SidebarProvider,
3
- useSidebar,
4
- Sidebar,
5
- SidebarTrigger,
6
- SidebarInset,
7
- SidebarHeader,
8
- SidebarFooter,
9
- SidebarContent,
10
- SidebarGroup,
11
- SidebarGroupContent,
12
- SidebarGroupLabel,
13
- SidebarMenu,
14
- SidebarMenuItem,
15
- SidebarMenuButton,
16
- SidebarMenuAction,
17
- SidebarMenuBadge,
18
- SidebarSeparator,
19
- SidebarMenuSub,
20
- SidebarMenuSubItem,
21
- SidebarMenuSubButton,
22
- } from './_feedback';
@@ -1 +0,0 @@
1
- export { Skeleton } from './_display';
@@ -1 +0,0 @@
1
- export { Slider } from './_motion';
@@ -1 +0,0 @@
1
- export { Spinner } from './_display';
@@ -1 +0,0 @@
1
- export { Switch } from './_controls';
@@ -1,10 +0,0 @@
1
- export {
2
- Table,
3
- TableHeader,
4
- TableBody,
5
- TableFooter,
6
- TableRow,
7
- TableHead,
8
- TableCell,
9
- TableCaption,
10
- } from './_data';
@@ -1 +0,0 @@
1
- export { Tabs, TabsList, TabsTrigger, TabsContent } from './_controls';
@@ -1,20 +0,0 @@
1
- import { Text as NativeText, StyleSheet, type TextProps as NativeTextProps } from 'react-native';
2
- import { useTheme } from '../theme';
3
- export type TextProps = NativeTextProps & {
4
- variant?: 'heading' | 'title' | 'body' | 'muted' | 'caption' | 'label';
5
- };
6
- const typography = StyleSheet.create({
7
- heading: { fontSize: 24, lineHeight: 32, fontWeight: '600' },
8
- title: { fontSize: 16, lineHeight: 22, fontWeight: '500' },
9
- body: { fontSize: 14, lineHeight: 20, fontWeight: '400' },
10
- muted: { fontSize: 14, lineHeight: 20, fontWeight: '400' },
11
- caption: { fontSize: 12, lineHeight: 20, fontWeight: '400' },
12
- label: { fontSize: 14, lineHeight: 20, fontWeight: '500' },
13
- });
14
- export function Text({ variant = 'body', style, ...props }: TextProps) {
15
- const { colors } = useTheme();
16
- const color = ['muted', 'caption'].includes(variant)
17
- ? colors['muted-foreground']
18
- : colors.foreground;
19
- return <NativeText {...props} style={[typography[variant], { color }, style]} />;
20
- }
@@ -1 +0,0 @@
1
- export { Textarea } from './_controls';
@@ -1,22 +0,0 @@
1
- import { Stack } from './layout';
2
- import { Button } from './button';
3
- import { Text } from './text';
4
- import { useTheme } from '../theme';
5
- export function ThemeSwitcher() {
6
- const { preference, setPreference } = useTheme();
7
- return (
8
- <Stack>
9
- <Text variant="label">Appearance</Text>
10
- {(['system', 'light', 'dark'] as const).map((value) => (
11
- <Button
12
- key={value}
13
- variant={preference === value ? 'secondary' : 'ghost'}
14
- accessibilityState={{ selected: preference === value }}
15
- onPress={() => setPreference(value)}
16
- >
17
- {value === 'system' ? 'System' : value === 'light' ? 'Light' : 'Dark'}
18
- </Button>
19
- ))}
20
- </Stack>
21
- );
22
- }
@@ -1,11 +0,0 @@
1
- export {
2
- ToastProvider,
3
- useToast,
4
- Toast,
5
- Toaster,
6
- ToastViewport,
7
- ToastTitle,
8
- ToastDescription,
9
- ToastAction,
10
- ToastClose,
11
- } from './_feedback';
@@ -1 +0,0 @@
1
- export { ToggleGroup, ToggleGroupItem } from './_controls';
@@ -1 +0,0 @@
1
- export { Toggle } from './_controls';
@@ -1 +0,0 @@
1
- export { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, TooltipClose } from './_overlay';
@@ -1,20 +0,0 @@
1
- import { Box, LabelText, Muted, row } from './_core';
2
- import { Collapsible, CollapsibleTrigger, CollapsibleContent } from './_controls';
3
- import { CodeBlock } from './code-block';
4
- import type { ViewProps } from 'react-native';
5
- export const Trace = Box;
6
- export const TraceItem = Collapsible;
7
- export const TraceTrigger = CollapsibleTrigger;
8
- export const TraceContent = CollapsibleContent;
9
- export const TraceTitle = LabelText;
10
- export const TraceDescription = Muted;
11
- export const TraceIcon = Box;
12
- export const TraceHeader = ({ style, ...props }: ViewProps) => (
13
- <Box {...props} style={row(style)} />
14
- );
15
- export const TraceCode = CodeBlock;
16
- export const TraceStatus = ({
17
- status,
18
- }: {
19
- status: 'pending' | 'running' | 'complete' | 'error';
20
- }) => <LabelText accessibilityLiveRegion="polite">{status}</LabelText>;
@@ -1,15 +0,0 @@
1
- export {
2
- Typography,
3
- TypographyH1,
4
- TypographyH2,
5
- TypographyH3,
6
- TypographyH4,
7
- TypographyP,
8
- TypographyMuted,
9
- TypographyLead,
10
- TypographyLarge,
11
- TypographySmall,
12
- TypographyBlockquote,
13
- TypographyInlineCode,
14
- TypographyList,
15
- } from './_display';
@@ -1,25 +0,0 @@
1
- import { Appearance } from 'react-native';
2
- import AsyncStorage from '@react-native-async-storage/async-storage';
3
- import * as SystemUI from 'expo-system-ui';
4
- const key = 'anhedral-theme';
5
- export async function readPreference() {
6
- try {
7
- return await AsyncStorage.getItem(key);
8
- } catch {
9
- return null;
10
- }
11
- }
12
- export async function savePreference(value: string) {
13
- try {
14
- await AsyncStorage.setItem(key, value);
15
- } catch {
16
- /* Preferences remain usable without storage. */
17
- }
18
- }
19
- export function applyTheme(mode: 'light' | 'dark', background: string, preference: string) {
20
- Appearance.setColorScheme(preference === 'system' ? 'unspecified' : mode);
21
- void SystemUI.setBackgroundColorAsync(background).catch(() => {});
22
- }
23
- export function subscribePreference(_listener: (value: unknown) => void) {
24
- return () => {};
25
- }
@@ -1,66 +0,0 @@
1
- import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from 'react';
2
- import { useColorScheme } from 'react-native';
3
- import { styling } from '@workspace/styling';
4
- type ThemeColors = Record<string, string> & { background: string; foreground: string };
5
- const colors = (tokens: Record<string, string>) =>
6
- Object.fromEntries(
7
- Object.entries(tokens)
8
- .filter(([key]) => key !== '--radius')
9
- .map(([key, value]) => [key.slice(2), 'hsl(' + value.replaceAll(' ', ', ') + ')']),
10
- ) as ThemeColors;
11
- const themes = { light: colors(styling.themes.light), dark: colors(styling.themes.dark) };
12
- import { readPreference, savePreference, applyTheme, subscribePreference } from './theme-storage';
13
-
14
- export type ThemePreference = 'system' | 'light' | 'dark';
15
- export function isThemePreference(value: unknown): value is ThemePreference {
16
- return value === 'system' || value === 'light' || value === 'dark';
17
- }
18
- const ThemeContext = createContext<{
19
- preference: ThemePreference;
20
- mode: 'light' | 'dark';
21
- colors: typeof themes.light;
22
- setPreference: (value: ThemePreference) => void;
23
- } | null>(null);
24
- export function ThemeProvider({ children }: { children: ReactNode }) {
25
- const system = useColorScheme();
26
- const [preference, setPreferenceState] = useState<ThemePreference>('system');
27
- const [ready, setReady] = useState(false);
28
- const changed = useRef(false);
29
- const mode = preference === 'system' ? (system === 'dark' ? 'dark' : 'light') : preference;
30
- useEffect(() => {
31
- let active = true;
32
- void readPreference()
33
- .then((saved) => {
34
- if (active && !changed.current && isThemePreference(saved)) setPreferenceState(saved);
35
- })
36
- .finally(() => {
37
- if (active) setReady(true);
38
- });
39
- const unsubscribe = subscribePreference((saved) => {
40
- if (isThemePreference(saved)) setPreferenceState(saved);
41
- });
42
- return () => {
43
- active = false;
44
- unsubscribe();
45
- };
46
- }, []);
47
- useEffect(() => {
48
- if (ready) applyTheme(mode, themes[mode].background, preference);
49
- }, [mode, ready, preference]);
50
- function setPreference(value: ThemePreference) {
51
- if (!isThemePreference(value)) return;
52
- changed.current = true;
53
- setPreferenceState(value);
54
- void savePreference(value);
55
- }
56
- return (
57
- <ThemeContext.Provider value={{ preference, mode, colors: themes[mode], setPreference }}>
58
- {children}
59
- </ThemeContext.Provider>
60
- );
61
- }
62
- export function useTheme() {
63
- const value = useContext(ThemeContext);
64
- if (!value) throw new Error('Mount ThemeProvider at the application root.');
65
- return value;
66
- }
@@ -1,2 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldExpo(context: RecipeContext): Promise<void>;
@@ -1,137 +0,0 @@
1
- import { NATIVE_ESLINT_VERSION } from '../dependencies.js';
2
- import path from 'node:path';
3
- import { writeReactLintConfig } from './lint.js';
4
- import { appendGitignore, writeFile } from '../util.js';
5
- import { childPackageName, jsString } from '../render.js';
6
- import { MOBILE_APP_DEPENDENCIES } from '../dependencies.js';
7
- import { scaffoldNativeUI } from '../scaffold/native-ui.js';
8
- import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
9
- function expoScheme(projectName) {
10
- const unscoped = projectName.replace(/^@[^/]+\//, '');
11
- const safe = unscoped.toLowerCase().replace(/[^a-z0-9+.-]+/g, '-');
12
- let start = 0;
13
- let end = safe.length;
14
- while (start < end && '+.-'.includes(safe[start]))
15
- start++;
16
- while (end > start && '+.-'.includes(safe[end - 1]))
17
- end--;
18
- const normalized = safe.slice(start, end);
19
- const candidate = normalized || 'app';
20
- return /^[a-z]/.test(candidate) ? candidate : `app-${candidate}`;
21
- }
22
- export async function scaffoldExpo(context) {
23
- const { root, options } = context;
24
- const dir = path.join(root, 'apps/mobile');
25
- const projectName = options.name;
26
- const displayName = options.name;
27
- const nameLiteral = jsString(displayName);
28
- writeReactLintConfig(dir);
29
- writeFile(path.join(dir, 'babel.config.js'), "module.exports = function(api) { api.cache(true); return { presets: ['babel-preset-expo'] }; };\n");
30
- writeFile(path.join(dir, 'package.json'), JSON.stringify({
31
- name: childPackageName(projectName, 'mobile'),
32
- version: '0.1.0',
33
- private: true,
34
- main: 'expo-router/entry',
35
- scripts: {
36
- android: 'expo start -c --android',
37
- ios: 'expo start -c --ios',
38
- start: 'expo start -c',
39
- build: 'pnpm typecheck',
40
- typecheck: 'tsc --noEmit',
41
- lint: 'eslint . --max-warnings 0',
42
- },
43
- dependencies: {
44
- ...MOBILE_APP_DEPENDENCIES.dependencies,
45
- '@workspace/native-ui': 'workspace:*',
46
- '@workspace/styling': 'workspace:*',
47
- },
48
- devDependencies: {
49
- ...MOBILE_APP_DEPENDENCIES.devDependencies,
50
- '@workspace/eslint-config': 'workspace:*',
51
- eslint: NATIVE_ESLINT_VERSION,
52
- },
53
- }, null, 2) + '\n');
54
- writeFile(path.join(dir, 'app.json'), JSON.stringify({
55
- expo: {
56
- name: displayName,
57
- slug: projectName.replace(/^@[^/]+\//, ''),
58
- version: '1.0.0',
59
- orientation: 'portrait',
60
- userInterfaceStyle: 'automatic',
61
- scheme: expoScheme(projectName),
62
- platforms: ['ios', 'android'],
63
- plugins: ['expo-router', 'expo-status-bar'],
64
- experiments: { reactCompiler: true, typedRoutes: true },
65
- },
66
- }, null, 2) + '\n');
67
- writeFile(path.join(dir, 'tsconfig.json'), JSON.stringify({
68
- extends: 'expo/tsconfig.base',
69
- compilerOptions: {
70
- strict: true,
71
- noUncheckedIndexedAccess: true,
72
- paths: { '@/*': ['./*'] },
73
- },
74
- include: ['**/*.ts', '**/*.tsx', '.expo/types/**/*.ts', 'expo-env.d.ts'],
75
- exclude: ['node_modules', 'worker', '.output', 'worker-configuration.d.ts'],
76
- }, null, 2) + '\n');
77
- scaffoldNativeUI(root);
78
- writeFile(path.join(dir, 'components/ui/button.tsx'), "export { Button } from '@workspace/native-ui';\n");
79
- writeFile(path.join(dir, 'app/_layout.tsx'), `import '@/lib/development-client';
80
- import { ThemeProvider } from '@workspace/native-ui';
81
- import { SafeAreaProvider } from 'react-native-safe-area-context';
82
- import { Stack } from 'expo-router';
83
-
84
- export default function RootLayout() {
85
- return <SafeAreaProvider><ThemeProvider><Stack /></ThemeProvider></SafeAreaProvider>;
86
- }
87
- `);
88
- writeFile(path.join(dir, 'lib/development-client.ts'), 'export {};\n');
89
- writeFile(path.join(dir, 'lib/development-client.native.ts'), "import 'expo-dev-client';\n");
90
- writeFile(path.join(dir, 'app/index.tsx'), `import { useEffect, useState } from 'react';
91
- import { api } from '@/lib/api-client';
92
- import { StatusBar } from 'expo-status-bar';
93
- import { Linking } from 'react-native';
94
- import { Screen, Stack, Text } from '@workspace/native-ui';
95
- import { Button } from '@/components/ui/button';
96
-
97
- export default function HomeScreen() {
98
- const [connection, setConnection] = useState('Connecting to the API…');
99
- const [pending, setPending] = useState(true);
100
- useEffect(() => {
101
- let active = true;
102
- void api.health().then(
103
- () => { if (active) setConnection('API connected'); },
104
- () => { if (active) setConnection('Unable to reach the API. Check the server and device API origin.'); },
105
- ).finally(() => { if (active) setPending(false); });
106
- return () => { active = false; };
107
- }, []);
108
- async function checkConnection() {
109
- setPending(true);
110
- setConnection('Connecting to the API…');
111
- try { await api.health(); setConnection('API connected'); }
112
- catch { setConnection('Unable to reach the API. Check the server and device API origin.'); }
113
- finally { setPending(false); }
114
- }
115
-
116
- return <Screen><StatusBar style="auto" /><Stack>
117
- <Text variant="heading" accessibilityRole="header">{${nameLiteral}}</Text>
118
- <Text variant="muted">Native iOS and Android application generated by Anhedral.</Text>
119
- <Text accessibilityLiveRegion="polite">{connection}</Text>
120
- <Button disabled={pending} onPress={() => void checkConnection()}>{pending ? 'Connecting…' : 'Check API connection'}</Button>
121
- <Button onPress={() => void Linking.openURL('https://docs.expo.dev')}>Learn more</Button>
122
- </Stack></Screen>;
123
- }
124
- `);
125
- writeFile(path.join(dir, '.env.example'), '');
126
- scaffoldExpoRuntime(context);
127
- appendGitignore(dir, [
128
- '.env',
129
- '.env.*',
130
- '!.env.example',
131
- '.expo',
132
- '.wrangler',
133
- '.output',
134
- 'dist',
135
- 'node_modules',
136
- ]);
137
- }
@@ -1,3 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- /** Native uses the public product origin; all browser transport belongs to Next. */
3
- export declare function scaffoldExpoRuntime({ root }: RecipeContext): void;
@@ -1,42 +0,0 @@
1
- import { writeEnvironmentFile } from './environment.js';
2
- import { patchPackage, put } from './files.js';
3
- /** Native uses the public product origin; all browser transport belongs to Next. */
4
- export function scaffoldExpoRuntime({ root }) {
5
- const directory = 'apps/mobile';
6
- patchPackage(root, `${directory}/package.json`, {
7
- dependencies: { '@workspace/contracts': 'workspace:*' },
8
- });
9
- put(root, `${directory}/lib/api-client.ts`, `import { createApiClient } from '@workspace/contracts';
10
-
11
- type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
12
-
13
- function validProtocol(url: URL): boolean {
14
- return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
15
- }
16
- function nativeApiOrigin(): string {
17
- const configured = process.env.EXPO_PUBLIC_API_URL;
18
- if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
19
- const origin = new URL(configured);
20
- if (!validProtocol(origin)) throw new Error('EXPO_PUBLIC_API_URL requires HTTPS outside development.');
21
- if ([origin.username, origin.password, origin.pathname !== '/', origin.search, origin.hash].some(Boolean))
22
- throw new Error('EXPO_PUBLIC_API_URL must be an origin without credentials, path, query or fragment.');
23
- return origin.origin;
24
- }
25
- function apiBaseURL(): string {
26
- return nativeApiOrigin() + '/api';
27
- }
28
-
29
- // Consumers can extend transport headers for their own application. No server secret belongs here.
30
- function createApplicationApiClient(options: Options = {}) {
31
- const client = () => createApiClient(apiBaseURL(), {
32
- ...options, credentials: 'omit',
33
- });
34
- return {
35
- health: (init?: RequestInit) => client().health(init),
36
- };
37
- }
38
-
39
- export const api = createApplicationApiClient();
40
- `);
41
- writeEnvironmentFile(root, `${directory}/.env.example`, { EXPO_PUBLIC_API_URL: '' });
42
- }
@@ -1,2 +0,0 @@
1
- /** Anhedral-maintained native shadcn port. Never imported by the DOM application. */
2
- export declare function scaffoldNativeUI(root: string): void;
@@ -1,74 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { NATIVE_ESLINT_VERSION, NATIVE_UI_DEPENDENCIES, MOBILE_APP_DEPENDENCIES, } from '../dependencies.js';
4
- import { json, put } from './files.js';
5
- import { writeReactLintConfig } from '../platforms/lint.js';
6
- /** Anhedral-maintained native shadcn port. Never imported by the DOM application. */
7
- export function scaffoldNativeUI(root) {
8
- const assets = fileURLToPath(new URL('../../assets/ui/', import.meta.url));
9
- const registry = JSON.parse(readFileSync(assets + 'native/registry.json', 'utf8'));
10
- const components = [
11
- ...registry.components.map((item) => item.id),
12
- 'layout',
13
- 'text',
14
- 'theme-switcher',
15
- ];
16
- const nativeFiles = [...registry.components.map((item) => item.file), ...registry.supportFiles];
17
- for (const file of [
18
- 'theme.tsx',
19
- 'theme-storage.ts',
20
- 'LICENSE.shadcn',
21
- 'UPSTREAM.json',
22
- ...nativeFiles.map((name) => `native/${name}`),
23
- ]) {
24
- const source = readFileSync(fileURLToPath(new URL(`../../assets/ui/${file}`, import.meta.url)), 'utf8');
25
- put(root, `packages/native-ui/${file.endsWith('.tsx') || file.endsWith('.ts') ? 'src/' : ''}${file}`, source);
26
- }
27
- put(root, 'packages/native-ui/README.md', readFileSync(fileURLToPath(new URL('../../docs/native-ui.md', import.meta.url)), 'utf8'));
28
- put(root, 'packages/native-ui/NATIVE_COMPONENTS.json', readFileSync(assets + 'native/registry.json', 'utf8'));
29
- put(root, 'packages/native-ui/src/index.ts', `export * from './theme';\n` +
30
- components.map((name) => `export * from './native/${name}';\n`).join(''));
31
- json(root, 'packages/native-ui/package.json', {
32
- name: '@workspace/native-ui',
33
- private: true,
34
- type: 'module',
35
- exports: {
36
- '.': './src/index.ts',
37
- './components/*': './src/native/*.tsx',
38
- './theme': './src/theme.tsx',
39
- },
40
- scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
41
- dependencies: {
42
- ...NATIVE_UI_DEPENDENCIES.dependencies,
43
- 'react-native-safe-area-context': MOBILE_APP_DEPENDENCIES.dependencies['react-native-safe-area-context'],
44
- '@workspace/styling': 'workspace:*',
45
- },
46
- peerDependencies: {
47
- react: MOBILE_APP_DEPENDENCIES.dependencies.react,
48
- 'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
49
- },
50
- devDependencies: {
51
- typescript: MOBILE_APP_DEPENDENCIES.devDependencies.typescript,
52
- '@types/react': MOBILE_APP_DEPENDENCIES.devDependencies['@types/react'],
53
- react: MOBILE_APP_DEPENDENCIES.dependencies.react,
54
- 'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
55
- '@workspace/eslint-config': 'workspace:*',
56
- eslint: NATIVE_ESLINT_VERSION,
57
- },
58
- });
59
- json(root, 'packages/native-ui/tsconfig.json', {
60
- compilerOptions: {
61
- target: 'ES2022',
62
- lib: ['ES2022'],
63
- module: 'ESNext',
64
- moduleResolution: 'Bundler',
65
- strict: true,
66
- jsx: 'react-jsx',
67
- noEmit: true,
68
- skipLibCheck: true,
69
- esModuleInterop: true,
70
- },
71
- include: ['src/**/*.ts', 'src/**/*.tsx'],
72
- });
73
- writeReactLintConfig(root + '/packages/native-ui');
74
- }
@@ -1,7 +0,0 @@
1
- # Application foundation
2
-
3
- Start with Next.js, Anhedral UI and OpenNext for Cloudflare Workers. Only the web application is generated. Anhedral UI uses official shadcn web components and React Native Reusables native components, with a small optional Anhedral native extension layer.
4
-
5
- Grow the application deliberately: Hono for a separate API, Drizzle/D1 and Better Auth for persistence and identity, then optional storage, clients, payments, realtime and AI. Expo, Anhedral UI for Expo, WXT/Side Panel, GPUI, Stripe and RevenueCat are choices rather than automatic scaffold output. The exact “if needed” conditions remain open.
6
-
7
- Use `anhedral add` to compose the selected [capabilities](capabilities.md) after previewing their source changes. Consumers implement features and operate their services. The CLI has no Platform identity, payment broker or provider-management dependency. See [stack standard](stack-standard.md) and [UI commands](ui.md).