anhedral 0.4.2 → 0.6.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 (89) hide show
  1. package/README.md +29 -269
  2. package/assets/anhedral-cli-init-technical.svg +322 -0
  3. package/assets/anhedral-cli-init.svg +257 -173
  4. package/dist/bin.js +28 -191
  5. package/dist/dependencies.d.ts +7 -57
  6. package/dist/dependencies.js +96 -308
  7. package/dist/index.d.ts +2 -7
  8. package/dist/index.js +1 -4
  9. package/dist/platforms/desktop.js +401 -0
  10. package/dist/platforms/extension.js +401 -0
  11. package/dist/platforms/mobile.js +232 -0
  12. package/dist/project.d.ts +0 -26
  13. package/dist/standard-products.d.ts +2 -0
  14. package/dist/standard-products.js +6 -0
  15. package/dist/standard.d.ts +18 -0
  16. package/dist/standard.js +578 -0
  17. package/dist/version.d.ts +1 -1
  18. package/dist/version.js +1 -1
  19. package/docs/application-stack-standard.md +700 -0
  20. package/package.json +34 -51
  21. package/CHANGELOG.md +0 -178
  22. package/CONTRIBUTING.md +0 -77
  23. package/SECURITY.md +0 -37
  24. package/SKILL.md +0 -339
  25. package/assets/images/svg/ably-symbol-color.svg +0 -8
  26. package/bin/anhedral.js +0 -2
  27. package/dist/architecture/contributions.d.ts +0 -28
  28. package/dist/architecture/contributions.js +0 -125
  29. package/dist/architecture/index.d.ts +0 -12
  30. package/dist/architecture/index.js +0 -6
  31. package/dist/architecture/manifest.d.ts +0 -53
  32. package/dist/architecture/manifest.js +0 -283
  33. package/dist/architecture/modules.d.ts +0 -41
  34. package/dist/architecture/modules.js +0 -187
  35. package/dist/architecture/plan.d.ts +0 -58
  36. package/dist/architecture/plan.js +0 -145
  37. package/dist/architecture/templates.d.ts +0 -10
  38. package/dist/architecture/templates.js +0 -23
  39. package/dist/cli.d.ts +0 -32
  40. package/dist/cli.js +0 -281
  41. package/dist/composers/root.d.ts +0 -6
  42. package/dist/composers/root.js +0 -35
  43. package/dist/print.d.ts +0 -8
  44. package/dist/print.js +0 -48
  45. package/dist/prompts.d.ts +0 -6
  46. package/dist/prompts.js +0 -41
  47. package/dist/scaffold.d.ts +0 -64
  48. package/dist/scaffold.js +0 -2102
  49. package/dist/template-source.d.ts +0 -20
  50. package/dist/template-source.js +0 -180
  51. package/dist/templates/api.d.ts +0 -2
  52. package/dist/templates/api.js +0 -3187
  53. package/dist/templates/assets-private-proxy.d.ts +0 -3
  54. package/dist/templates/assets-private-proxy.js +0 -277
  55. package/dist/templates/desktop.js +0 -792
  56. package/dist/templates/electron-updater.d.ts +0 -3
  57. package/dist/templates/electron-updater.js +0 -358
  58. package/dist/templates/extension.js +0 -856
  59. package/dist/templates/first-run.d.ts +0 -2
  60. package/dist/templates/first-run.js +0 -167
  61. package/dist/templates/mobile.js +0 -861
  62. package/dist/templates/shared.d.ts +0 -2
  63. package/dist/templates/shared.js +0 -577
  64. package/dist/templates/web.d.ts +0 -2
  65. package/dist/templates/web.js +0 -569
  66. package/dist/toolchain.d.ts +0 -3
  67. package/dist/toolchain.js +0 -8
  68. package/dist/ui.d.ts +0 -33
  69. package/dist/ui.js +0 -199
  70. package/dist/workspace-config.d.ts +0 -11
  71. package/dist/workspace-config.js +0 -372
  72. package/docs/NORTHSTAR.md +0 -114
  73. package/docs/conventions.md +0 -94
  74. package/docs/engineering-principles.md +0 -88
  75. package/docs/master-stack-map.md +0 -199
  76. package/docs/output-tree-contract.md +0 -493
  77. package/docs/references/manual-scaffolding.md +0 -421
  78. package/docs/references/provisioning.md +0 -577
  79. package/scripts/render-master-stack-map.mjs +0 -510
  80. package/templates/api-fastify/apps/api/tsconfig.json +0 -20
  81. package/templates/catalog.json +0 -23
  82. package/templates/db-drizzle/packages/db/tsconfig.json +0 -14
  83. package/templates/desktop-electron/apps/desktop/tsconfig.json +0 -37
  84. package/templates/extension-wxt/apps/extension/tsconfig.json +0 -41
  85. package/templates/mobile-expo/apps/mobile/expo-env.d.ts +0 -1
  86. package/templates/web-next/apps/web/next-env.d.ts +0 -6
  87. /package/dist/{templates → platforms}/desktop.d.ts +0 -0
  88. /package/dist/{templates → platforms}/extension.d.ts +0 -0
  89. /package/dist/{templates → platforms}/mobile.d.ts +0 -0
package/README.md CHANGED
@@ -1,296 +1,56 @@
1
1
  # Anhedral
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/anhedral.svg)](https://www.npmjs.com/package/anhedral)
4
- [![Node.js ^20.19.0 or >=22.12.0](https://img.shields.io/badge/Node.js-%5E20.19.0%20%7C%7C%20%3E%3D22.12.0-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
3
+ Initialize client-owned applications using the [Anhedral Application Stack & Delivery Standard](docs/application-stack-standard.md).
5
4
 
6
- Anhedral generates a complete, production-oriented TypeScript stack whose source code stays understandable and customizable.
5
+ Every new project starts from the official **shadcn pnpm/Turborepo monorepo**. The default creates **Next.js + React + TypeScript + Tailwind + shadcn/ui**, hosted on **Cloudflare Workers through OpenNext**. Select additional apps and services only when needed.
7
6
 
8
- > **Build once. Ship everywhere. Scale is built in.** Pick the platforms,
9
- > frameworks, and features your product needs; Anhedral assembles them into a
10
- > production-ready TypeScript workspace for web, iOS, Android, desktop, APIs,
11
- > and browser extensions. Start free, skip months of repetitive setup and
12
- > integration work, and focus on what makes your app unique.
13
-
14
- ![Anhedral Init Stack architecture diagram](assets/anhedral-cli-init.svg)
15
-
16
- Anhedral is not a new programming language and generated applications do not run inside a proprietary application framework. It assembles well-documented tools, connects their difficult integration boundaries, and leaves developers with ordinary Next.js, Expo Router, Fastify, Drizzle, Electron, and WXT projects.
17
-
18
- The measurable product and developer-experience contract is documented in the
19
- [Anhedral DX north star](docs/NORTHSTAR.md).
20
-
21
- Anhedral is open source under the [Apache License 2.0](LICENSE). You may use,
22
- modify, and distribute it subject to that license, including its notice and
23
- redistribution requirements. Generated applications remain ordinary project
24
- source that their developers can customize and license for their products.
25
-
26
- ## Recommended: use the coding-agent skill
27
-
28
- Install the Anhedral skill for Codex, Claude Code, or another compatible coding
29
- agent:
30
-
31
- ```sh
32
- pnpm dlx skills add https://github.com/anhedral/anhedral-init --skill anhedral-init
33
- ```
34
-
35
- Choose the agent and global or project scope when prompted. Then ask the agent:
36
-
37
- ```text
38
- Use $anhedral-init to create and provision my application.
39
- ```
40
-
41
- The skill begins by asking for the project name and whether you already own a
42
- custom domain. It selects the CLI command with you, detects Computer Use and
43
- subagent support, generates the project, and walks through the selected cloud
44
- providers. It pauses for sign-in, MFA, payments, secret generation, and final
45
- release submissions. Paste secrets directly into the instructed uncommitted
46
- `.env` file or protected provider field—never into chat.
47
-
48
- ## Create an application directly
49
-
50
- In an interactive terminal, start Anhedral and choose the surfaces and
51
- capabilities you need:
52
-
53
- ```sh
54
- pnpm dlx anhedral@latest new my-product
55
- cd my-product
56
- ```
57
-
58
- The suggested selection is a focused web app, and Anhedral shows the complete
59
- resolved stack before it writes anything. To explicitly create every supported
60
- surface and capability, use:
7
+ ![Anhedral CLI init stack](assets/anhedral-cli-init.svg)
61
8
 
62
9
  ```sh
63
- pnpm dlx anhedral@latest new my-product --all
10
+ pnpm dlx anhedral@latest new my-app
11
+ pnpm dlx anhedral@latest new mobile-app --expo
12
+ pnpm dlx anhedral@latest new product --next --expo --hono --neon --clerk --r2
13
+ pnpm dlx anhedral@latest init --wxt
64
14
  ```
65
15
 
66
- The generated `README.md` contains the exact next steps for the selected stack.
67
- Run `pnpm first-run` to create missing local environment files without
68
- overwriting anything, then use `pnpm ready` for a secret-safe readiness check.
69
- For the complete stack, configure the selected managed providers—including a
70
- Neon `DATABASE_URL`—and create the reviewed initial migration before running
71
- `pnpm dev`. Anhedral intentionally does not generate a local Postgres substitute
72
- or pretend that production provider credentials already exist.
16
+ To use a local checkout, run `pnpm build`, then `node dist/bin.js new <directory>`.
73
17
 
74
- In noninteractive environments, no module flags retain the complete-stack
75
- default for compatibility. Prefer `--all` when that is your intent, or name
76
- only what the product needs:
18
+ Applications: `next`, `expo`, `electron`, `wxt`, `hono`.
77
19
 
78
- ```sh
79
- pnpm dlx anhedral@latest new my-product --web --api --db --auth
80
- pnpm dlx anhedral@latest new my-api --api --db
81
- pnpm dlx anhedral@latest new my-clients --web --mobile
82
- ```
20
+ Optional capabilities: `neon`, `d1`, `local-data`, `clerk`, `better-auth`, `r2`, `kv`, `realtime`, `queues`, `cron`, `workflows`, `openai`, `ai-sdk`, `workers-ai`, `resend`, `stripe`, `revenuecat`, `sentry`, `basin`, `posthog`, `styling`.
83
21
 
84
- `init` generates the same workspace in the current empty directory:
22
+ Hono provides an OpenAPI Worker when a shared API is selected. Web-only endpoints belong in Next.js route handlers; `apps/api` is never added automatically. Workers services live under `apps/*`, reusable code under `packages/*`. Mobile-only, desktop-only, extension-only and API-only selections remove the unused Next.js starter after the shadcn bootstrap.
85
23
 
86
- ```sh
87
- mkdir my-product && cd my-product
88
- pnpm dlx anhedral@latest init --web --api --db --auth
89
- ```
24
+ Choose either Neon + Drizzle + Hyperdrive or D1 + Drizzle. Authentication is optional; Clerk and Better Auth are mutually exclusive. Better Auth requires an explicit database selection. Stripe is the web billing choice; RevenueCat is an optional addition for cross-store entitlements. Private files use R2 Worker bindings; clients never receive R2 credentials.
90
25
 
91
- Interactive terminals prompt for surfaces and capabilities. CI and coding agents should pass explicit module flags.
26
+ `--hosting=vercel` explicitly selects Vercel for Next.js. It requires project approval as an architecture exception. Vinext, GPUI/Rust, Containers and alternative source/CI platforms remain deliberate project adaptations rather than generated templates.
92
27
 
93
- ## What gets generated
28
+ `--dry-run --json` prints a plan without writes or network calls. `--skip-install` skips the final workspace installation; the official shadcn bootstrap still needs network access and can install dependencies. Generation resolves and retains a workspace lockfile. Commit it with the source.
94
29
 
95
- ```text
96
- my-product/
97
- ├── apps/
98
- │ ├── web/ # Next.js App Router + source-owned shadcn/ui
99
- │ ├── mobile/ # Expo Router + React Native Reusables
100
- │ ├── api/ # Fastify routes, backend modules, auth, providers
101
- │ ├── desktop/ # Electron + React
102
- │ ├── extension/ # WXT browser extension
103
- │ ├── assets-private-proxy/ # Cloudflare Worker for private asset delivery
104
- │ └── desktop-updater-worker/ # private R2 Electron update delivery
105
- ├── packages/
106
- │ ├── contracts/ # shared Zod network contracts
107
- │ ├── api-client/ # typed client used by every frontend
108
- │ ├── db/ # Drizzle schema and reviewed migrations
109
- │ └── realtime/ # Ably client when billing is selected
110
- ├── docs/
111
- │ ├── DEVELOPMENT.md # task-oriented feature recipes
112
- │ └── STACK.md # tool map and official documentation
113
- ├── README.md # first run and where-to-write-code map
114
- ├── PRODUCTION.md # selection-specific release runbook
115
- ├── SKILL.md # repository guidance for coding agents
116
- ├── ANHEDRAL.md # generator and ownership notes
117
- └── anhedral.json # modules, versions, provenance, ownership
118
- ```
30
+ Generated projects include `dev`, `build`, `lint`, `typecheck`, `test`, `audit`, `audit:full`, and `check`, plus GitHub Actions PR checks. Fallow is part of the deterministic gate. Tests run in workspaces that define them; add meaningful product and integration tests as behavior is implemented.
119
31
 
120
- Whole directories are omitted when their module is not selected. Generated documentation is selection-aware.
32
+ Provider packages and services are **starters**, not finished product features. Generated READMEs identify the remaining setup: resource IDs, migrations, product authorization, webhooks, native adapters and runtime SDK initialization. Initialization does not create cloud resources, activate billing, or deploy. Human approval is required for paid activation, material spending, architecture exceptions and production releases.
121
33
 
122
- ## Developer experience
34
+ The CLI supports `new`, `init`, `--help`, and `--version`. Use `anhedral --help` for options.
123
35
 
124
- Database-backed client stacks include a working `items` feature on day one. It
125
- connects the Drizzle table, Zod request/response contracts, Fastify list/create
126
- routes, typed client calls, and an idiomatic UI for every selected surface. Use
127
- it to verify the stack, then rename or replace these ordinary user-owned files
128
- with the product idea:
36
+ ## Workspace layout
129
37
 
130
38
  ```text
131
- packages/db/src/app-schema.ts
132
- packages/contracts/src/app.ts
133
- apps/api/src/routes/app.ts
134
- packages/api-client/src/app.ts
135
- apps/web/components/item-list.tsx
136
- apps/mobile/components/item-list.tsx
137
- apps/desktop/src/renderer/components/item-list.tsx
138
- apps/extension/src/components/item-list.tsx
139
- ```
39
+ demo/
40
+ ├── anhedral-factory/ Factory application and service workspaces
41
+ └── default-stack-demo/ Preserved, tested default stack snapshot
140
42
 
141
- Only paths for selected clients are generated. Shared contracts and API calls
142
- stay consistent while presentation follows Next.js, React Native, Electron, or
143
- browser-extension conventions.
144
-
145
- ```ts
146
- // packages/contracts/src/app.ts
147
- import { z } from 'zod';
148
-
149
- export const ItemSchema = z.object({
150
- id: z.string().uuid(),
151
- name: z.string(),
152
- createdAt: z.string().datetime(),
153
- });
154
- export const ItemListSchema = z.array(ItemSchema);
43
+ src/ Current initializer implementation
44
+ dist/ Generated JavaScript + declarations
45
+ .artifacts/release/ Generated npm tarball + integrity metadata
46
+ scripts/, tests/, docs/ Tooling, verification, and the stack standard
155
47
  ```
156
48
 
157
- The flow is a normal TypeScript architecture, not an Anhedral DSL:
158
-
159
- ```text
160
- contracts -> database/service -> Fastify route -> typed API client -> frontend
161
- ```
162
-
163
- - Write web product code under `apps/web` using Next.js conventions.
164
- - Write mobile product code under `apps/mobile` using Expo Router conventions.
165
- - Register product routes in `apps/api/src/routes/app.ts` and add server-only feature modules under `apps/api/src` using Fastify conventions.
166
- - Write product tables in `packages/db/src/app-schema.ts` and queries under `packages/db` using Drizzle conventions.
167
- - Share only network contracts and client-safe packages with frontends.
168
- - Import the underlying framework directly whenever its API is the right tool.
169
-
170
- ## The stack
171
-
172
- | Concern | Default | Why Anhedral includes it |
173
- | --- | --- | --- |
174
- | Web | Next.js + Vercel | App Router, React server rendering, routing, deployment |
175
- | Native | Expo Router | One TypeScript application for iOS and Android |
176
- | API | Fastify | Typed validation, structured logging, plugin boundaries |
177
- | Database | Neon + Drizzle | Managed Postgres with TypeScript schema and SQL-like queries |
178
- | Authentication | Clerk | Connected frontend and backend identity/session flows |
179
- | UI | shadcn/ui + React Native Reusables | Accessible source code the application owns |
180
- | Storage | private Cloudflare R2 | Signed uploads and controlled asset delivery |
181
- | Billing/realtime | RevenueCat + Stripe + Ably | Unified billing entitlements and realtime invalidation |
182
- | Desktop | Electron | Predictable cross-platform TypeScript desktop runtime |
183
- | Desktop updates | electron-updater + private R2 + Worker | Signed automatic updates through a product-owned custom domain |
184
- | Extension | WXT | Browser-extension entrypoints, builds, and packaging |
185
- | Workspace | pnpm + Turborepo | Strict dependencies and dependency-aware tasks |
186
-
187
- Anhedral does **not** generate or require local Postgres. Database-enabled projects use a managed Neon connection through `DATABASE_URL`; teams should use isolated Neon branches or projects for development, preview, and production.
188
-
189
- ## Commands
190
-
191
- ```text
192
- anhedral new <directory> [modules...] Generate a new readable workspace
193
- anhedral init [modules...] Generate in the current empty directory
194
- anhedral new <directory> --all Explicitly select the complete stack
195
- pnpm anhedral:add <module...> Add connected stack capabilities
196
- pnpm anhedral:ui <component...> Add source-owned UI components
197
- pnpm anhedral:upgrade Transactionally upgrade a supported project
198
- pnpm anhedral:doctor Check ownership and generator drift
199
- ```
200
-
201
- Useful examples:
202
-
203
- ```sh
204
- pnpm anhedral:add storage --dry-run
205
- pnpm anhedral:add desktop extension
206
- pnpm anhedral:add electron-updater
207
- pnpm anhedral:ui button dialog
208
- pnpm anhedral:ui data-table --target web --dry-run
209
- pnpm anhedral:upgrade --dry-run
210
- pnpm anhedral:doctor --json
211
- ```
212
-
213
- `--dry-run` builds the structural plan without changing the project. For `ui add`, it also shows the exact provider command; registry-generated file paths are resolved only when the plan is applied. `--json` emits machine-readable output. `--verbose` streams child-tool diagnostics.
214
-
215
- Application lifecycle commands remain visible in the generated root `package.json`:
216
-
217
- ```sh
218
- pnpm first-run
219
- pnpm ready
220
- pnpm dev
221
- pnpm dev:all
222
- pnpm dev:web
223
- pnpm dev:api
224
- pnpm typecheck
225
- pnpm verify
226
- pnpm build
227
- pnpm db:generate
228
- pnpm db:migrate
229
- ```
230
-
231
- `pnpm dev` starts the primary product loop: the first selected client plus the
232
- API when present, or the API by itself for backend-only projects. In the full
233
- stack that means web plus API. `pnpm dev:all` appears only when the project has
234
- additional surfaces and intentionally starts all of them. Only commands
235
- relevant to selected modules are generated.
236
-
237
- ## Extensibility and ownership
238
-
239
- Anhedral owns initial assembly and safe structural additions. It does not own product architecture after generation.
240
-
241
- - `README.md`, `PRODUCTION.md`, application features, pages, routes, services, and domain code are developer-owned.
242
- - Root workspace configuration is mergeable.
243
- - Integration substrate is recorded in `anhedral.json`; `pnpm anhedral:add` refuses to overwrite modified managed files.
244
- - UI components are copied into the application so developers can edit them normally.
245
- - Provider integrations use ordinary SDKs and configuration files with no hidden control plane.
246
-
247
- Before a structural change:
248
-
249
- ```sh
250
- pnpm anhedral:doctor
251
- pnpm anhedral:add <module> --dry-run
252
- ```
253
-
254
- When `doctor` reports that a project was generated by a supported older release, run `pnpm anhedral:upgrade --dry-run`, inspect the plan, and then run `pnpm anhedral:upgrade`. Version 0.4 supports transactional upgrades from 0.3 projects while preserving user-owned extension seams. If a 0.3 project changed a file that was generator-managed, the upgrade stops instead of overwriting it. Preserve the change in source control, restore that managed file to its recorded 0.3 content, run the upgrade, and then move the product behavior into the new user-owned `app.ts`, `app-schema.ts`, page, component, or `app-window.ts` seam.
255
-
256
- ## Documentation contract
257
-
258
- Every generated project teaches both humans and coding agents how to work in it:
259
-
260
- - `README.md` answers how to run the app and where frontend/backend code goes.
261
- - `docs/DEVELOPMENT.md` provides end-to-end feature and common-task recipes.
262
- - `docs/STACK.md` maps generated files to each tool's official documentation.
263
- - `SKILL.md` gives coding agents concise repository-specific workflow and safety rules.
264
- - `PRODUCTION.md` covers only the accounts, environment, infrastructure, DNS, stores, and release steps selected for that project.
265
-
266
- The generator's exact output contract is documented in [docs/output-tree-contract.md](docs/output-tree-contract.md). Contributor architecture remains available in the [source repository](https://github.com/anhedral/anhedral-init/tree/main/docs/architecture).
267
-
268
- The complete lifecycle, runtime, cloud, command, and coding-agent topology is in
269
- the [Anhedral master stack map](docs/master-stack-map.md).
270
- The repository's implementation policy is the
271
- [Zen of Anhedral](docs/engineering-principles.md).
272
-
273
- ## Module dependency rules
274
-
275
- Anhedral resolves integrations as a deterministic graph:
276
-
277
- ```text
278
- auth -> api + db
279
- billing -> auth
280
- storage -> auth
281
- native-subscriptions -> mobile + billing
282
- electron-updater -> desktop
283
- ```
284
-
285
- Adding a capability brings the infrastructure it actually requires. Unselected providers do not leave dead source files or environment placeholders behind.
286
-
287
- ## Verification
288
-
289
- The generator and representative public stacks are checked with:
49
+ Each demo retains its own pnpm workspace and lockfile; the root package remains the initializer. Dependencies, caches, generated artifacts, and local credentials are ignored.
290
50
 
291
51
  ```sh
292
- pnpm typecheck
293
- pnpm test:all
52
+ pnpm --dir demo/anhedral-factory dev
53
+ pnpm --dir demo/anhedral-factory check
294
54
  ```
295
55
 
296
- Generated workspaces include their own package-level tests, full-stack `verify` command, CI workflow, production environment validation, migration drift gate, and deployment configuration.
56
+ Anhedral is open source under the [Apache License 2.0](LICENSE). Generated applications remain ordinary project source that their developers can customize and license for their products.