anhedral 0.4.1 → 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.
- package/README.md +29 -256
- package/assets/anhedral-cli-init-technical.svg +322 -0
- package/assets/anhedral-cli-init.svg +257 -173
- package/dist/bin.js +28 -162
- package/dist/dependencies.d.ts +7 -56
- package/dist/dependencies.js +96 -305
- package/dist/index.d.ts +2 -7
- package/dist/index.js +1 -4
- package/dist/{templates → platforms}/desktop.d.ts +1 -1
- package/dist/{templates → platforms}/desktop.js +28 -266
- package/dist/{templates → platforms}/extension.d.ts +1 -1
- package/dist/platforms/extension.js +401 -0
- package/dist/{templates → platforms}/mobile.d.ts +1 -1
- package/dist/platforms/mobile.js +232 -0
- package/dist/project.d.ts +4 -0
- package/dist/project.js +1 -0
- package/dist/standard-products.d.ts +2 -0
- package/dist/standard-products.js +6 -0
- package/dist/standard.d.ts +18 -0
- package/dist/standard.js +578 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/application-stack-standard.md +700 -0
- package/package.json +34 -49
- package/CHANGELOG.md +0 -132
- package/CONTRIBUTING.md +0 -73
- package/SECURITY.md +0 -37
- package/SKILL.md +0 -244
- package/assets/images/svg/ably-symbol-color.svg +0 -8
- package/bin/anhedral.js +0 -2
- package/dist/architecture/contributions.d.ts +0 -28
- package/dist/architecture/contributions.js +0 -125
- package/dist/architecture/index.d.ts +0 -12
- package/dist/architecture/index.js +0 -6
- package/dist/architecture/manifest.d.ts +0 -53
- package/dist/architecture/manifest.js +0 -283
- package/dist/architecture/modules.d.ts +0 -37
- package/dist/architecture/modules.js +0 -184
- package/dist/architecture/plan.d.ts +0 -58
- package/dist/architecture/plan.js +0 -145
- package/dist/architecture/templates.d.ts +0 -10
- package/dist/architecture/templates.js +0 -23
- package/dist/cli.d.ts +0 -32
- package/dist/cli.js +0 -235
- package/dist/composers/root.d.ts +0 -6
- package/dist/composers/root.js +0 -35
- package/dist/print.d.ts +0 -8
- package/dist/print.js +0 -48
- package/dist/prompts.d.ts +0 -5
- package/dist/prompts.js +0 -19
- package/dist/scaffold.d.ts +0 -76
- package/dist/scaffold.js +0 -1895
- package/dist/template-source.d.ts +0 -20
- package/dist/template-source.js +0 -180
- package/dist/templates/api.d.ts +0 -2
- package/dist/templates/api.js +0 -3122
- package/dist/templates/assets-private-proxy.d.ts +0 -3
- package/dist/templates/assets-private-proxy.js +0 -277
- package/dist/templates/electron-updater.d.ts +0 -3
- package/dist/templates/electron-updater.js +0 -358
- package/dist/templates/extension.js +0 -732
- package/dist/templates/mobile.js +0 -720
- package/dist/templates/shared.d.ts +0 -2
- package/dist/templates/shared.js +0 -520
- package/dist/templates/web.d.ts +0 -2
- package/dist/templates/web.js +0 -412
- package/dist/toolchain.d.ts +0 -3
- package/dist/toolchain.js +0 -8
- package/dist/ui.d.ts +0 -33
- package/dist/ui.js +0 -199
- package/dist/workspace-config.d.ts +0 -11
- package/dist/workspace-config.js +0 -372
- package/docs/conventions.md +0 -92
- package/docs/master-stack-map.md +0 -199
- package/docs/output-tree-contract.md +0 -482
- package/docs/references/manual-scaffolding.md +0 -403
- package/docs/references/provisioning.md +0 -220
- package/scripts/render-master-stack-map.mjs +0 -510
- package/templates/api-fastify/apps/api/tsconfig.json +0 -20
- package/templates/catalog.json +0 -23
- package/templates/db-drizzle/packages/db/tsconfig.json +0 -14
- package/templates/desktop-electron/apps/desktop/tsconfig.json +0 -37
- package/templates/extension-wxt/apps/extension/tsconfig.json +0 -41
- package/templates/mobile-expo/apps/mobile/expo-env.d.ts +0 -1
- package/templates/web-next/apps/web/next-env.d.ts +0 -6
package/README.md
CHANGED
|
@@ -1,283 +1,56 @@
|
|
|
1
1
|
# Anhedral
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[](https://www.npmjs.com/package/anhedral)
|
|
3
|
+
Initialize client-owned applications using the [Anhedral Application Stack & Delivery Standard](docs/application-stack-standard.md).
|
|
5
4
|
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-

|
|
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
|
-
Anhedral is open source under the [Apache License 2.0](LICENSE). You may use,
|
|
19
|
-
modify, and distribute it subject to that license, including its notice and
|
|
20
|
-
redistribution requirements. Generated applications remain ordinary project
|
|
21
|
-
source that their developers can customize and license for their products.
|
|
22
|
-
|
|
23
|
-
## Recommended: use the coding-agent skill
|
|
24
|
-
|
|
25
|
-
Install the Anhedral skill for Codex, Claude Code, or another compatible coding
|
|
26
|
-
agent:
|
|
7
|
+

|
|
27
8
|
|
|
28
9
|
```sh
|
|
29
|
-
pnpm dlx
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```text
|
|
35
|
-
Use $anhedral-init to create and provision my application.
|
|
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
|
|
36
14
|
```
|
|
37
15
|
|
|
38
|
-
|
|
39
|
-
custom domain. It selects the CLI command with you, detects Computer Use and
|
|
40
|
-
subagent support, generates the project, and walks through the selected cloud
|
|
41
|
-
providers. It pauses for sign-in, MFA, payments, secret generation, and final
|
|
42
|
-
release submissions. Paste secrets directly into the instructed uncommitted
|
|
43
|
-
`.env` file or protected provider field—never into chat.
|
|
16
|
+
To use a local checkout, run `pnpm build`, then `node dist/bin.js new <directory>`.
|
|
44
17
|
|
|
45
|
-
|
|
18
|
+
Applications: `next`, `expo`, `electron`, `wxt`, `hono`.
|
|
46
19
|
|
|
47
|
-
|
|
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`.
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
pnpm dlx anhedral@latest new my-product
|
|
51
|
-
cd my-product
|
|
52
|
-
```
|
|
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.
|
|
53
23
|
|
|
54
|
-
|
|
55
|
-
For the complete stack, copy the package-local environment examples, configure
|
|
56
|
-
the selected managed providers—including a Neon `DATABASE_URL`—and create the
|
|
57
|
-
reviewed initial migration before running `pnpm dev`. Anhedral intentionally
|
|
58
|
-
does not generate a local Postgres substitute or pretend that production
|
|
59
|
-
provider credentials already exist.
|
|
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.
|
|
60
25
|
|
|
61
|
-
|
|
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.
|
|
62
27
|
|
|
63
|
-
|
|
64
|
-
pnpm dlx anhedral@latest new my-product --web --api --db --auth
|
|
65
|
-
pnpm dlx anhedral@latest new my-api --api --db
|
|
66
|
-
pnpm dlx anhedral@latest new my-clients --web --mobile
|
|
67
|
-
```
|
|
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.
|
|
68
29
|
|
|
69
|
-
`
|
|
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.
|
|
70
31
|
|
|
71
|
-
|
|
72
|
-
mkdir my-product && cd my-product
|
|
73
|
-
pnpm dlx anhedral@latest init --web --api --db --auth
|
|
74
|
-
```
|
|
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.
|
|
75
33
|
|
|
76
|
-
|
|
34
|
+
The CLI supports `new`, `init`, `--help`, and `--version`. Use `anhedral --help` for options.
|
|
77
35
|
|
|
78
|
-
##
|
|
36
|
+
## Workspace layout
|
|
79
37
|
|
|
80
38
|
```text
|
|
81
|
-
|
|
82
|
-
├──
|
|
83
|
-
|
|
84
|
-
│ ├── mobile/ # Expo Router + React Native Reusables
|
|
85
|
-
│ ├── api/ # Fastify routes, backend modules, auth, providers
|
|
86
|
-
│ ├── desktop/ # Electron + React
|
|
87
|
-
│ ├── extension/ # WXT browser extension
|
|
88
|
-
│ ├── assets-private-proxy/ # Cloudflare Worker for private asset delivery
|
|
89
|
-
│ └── desktop-updater-worker/ # private R2 Electron update delivery
|
|
90
|
-
├── packages/
|
|
91
|
-
│ ├── contracts/ # shared Zod network contracts
|
|
92
|
-
│ ├── api-client/ # typed client used by every frontend
|
|
93
|
-
│ ├── db/ # Drizzle schema and reviewed migrations
|
|
94
|
-
│ └── realtime/ # Ably client when billing is selected
|
|
95
|
-
├── docs/
|
|
96
|
-
│ ├── DEVELOPMENT.md # task-oriented feature recipes
|
|
97
|
-
│ └── STACK.md # tool map and official documentation
|
|
98
|
-
├── README.md # first run and where-to-write-code map
|
|
99
|
-
├── PRODUCTION.md # selection-specific release runbook
|
|
100
|
-
├── SKILL.md # repository guidance for coding agents
|
|
101
|
-
├── ANHEDRAL.md # generator and ownership notes
|
|
102
|
-
└── anhedral.json # modules, versions, provenance, ownership
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Whole directories are omitted when their module is not selected. Generated documentation is selection-aware.
|
|
106
|
-
|
|
107
|
-
## Developer experience
|
|
39
|
+
demo/
|
|
40
|
+
├── anhedral-factory/ Factory application and service workspaces
|
|
41
|
+
└── default-stack-demo/ Preserved, tested default stack snapshot
|
|
108
42
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
import { ProjectList } from '@/components/projects/project-list';
|
|
114
|
-
|
|
115
|
-
export default function ProjectsPage() {
|
|
116
|
-
return <ProjectList />;
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
// packages/contracts/src/app.ts
|
|
122
|
-
import { z } from 'zod';
|
|
123
|
-
|
|
124
|
-
export const ProjectSchema = z.object({ id: z.string(), name: z.string() });
|
|
125
|
-
export const ProjectListSchema = z.array(ProjectSchema);
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
// packages/db/src/app-schema.ts
|
|
130
|
-
import { pgTable, text } from 'drizzle-orm/pg-core';
|
|
131
|
-
|
|
132
|
-
export const projects = pgTable('projects', {
|
|
133
|
-
id: text('id').primaryKey(),
|
|
134
|
-
name: text('name').notNull(),
|
|
135
|
-
});
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
```ts
|
|
139
|
-
// apps/api/src/routes/app.ts
|
|
140
|
-
import type { FastifyPluginAsync } from 'fastify';
|
|
141
|
-
import { db } from '@shared/db';
|
|
142
|
-
import { projects } from '@shared/db/schema';
|
|
143
|
-
|
|
144
|
-
export const appRoutes: FastifyPluginAsync = async (app) => {
|
|
145
|
-
app.get('/projects', async () => db.select().from(projects));
|
|
146
|
-
};
|
|
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
|
|
147
47
|
```
|
|
148
48
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```text
|
|
152
|
-
contracts -> database/service -> Fastify route -> typed API client -> frontend
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
- Write web product code under `apps/web` using Next.js conventions.
|
|
156
|
-
- Write mobile product code under `apps/mobile` using Expo Router conventions.
|
|
157
|
-
- Register product routes in `apps/api/src/routes/app.ts` and add server-only feature modules under `apps/api/src` using Fastify conventions.
|
|
158
|
-
- Write product tables in `packages/db/src/app-schema.ts` and queries under `packages/db` using Drizzle conventions.
|
|
159
|
-
- Share only network contracts and client-safe packages with frontends.
|
|
160
|
-
- Import the underlying framework directly whenever its API is the right tool.
|
|
161
|
-
|
|
162
|
-
## The stack
|
|
163
|
-
|
|
164
|
-
| Concern | Default | Why Anhedral includes it |
|
|
165
|
-
| --- | --- | --- |
|
|
166
|
-
| Web | Next.js + Vercel | App Router, React server rendering, routing, deployment |
|
|
167
|
-
| Native | Expo Router | One TypeScript application for iOS and Android |
|
|
168
|
-
| API | Fastify | Typed validation, structured logging, plugin boundaries |
|
|
169
|
-
| Database | Neon + Drizzle | Managed Postgres with TypeScript schema and SQL-like queries |
|
|
170
|
-
| Authentication | Clerk | Connected frontend and backend identity/session flows |
|
|
171
|
-
| UI | shadcn/ui + React Native Reusables | Accessible source code the application owns |
|
|
172
|
-
| Storage | private Cloudflare R2 | Signed uploads and controlled asset delivery |
|
|
173
|
-
| Billing/realtime | RevenueCat + Stripe + Ably | Unified billing entitlements and realtime invalidation |
|
|
174
|
-
| Desktop | Electron | Predictable cross-platform TypeScript desktop runtime |
|
|
175
|
-
| Desktop updates | electron-updater + private R2 + Worker | Signed automatic updates through a product-owned custom domain |
|
|
176
|
-
| Extension | WXT | Browser-extension entrypoints, builds, and packaging |
|
|
177
|
-
| Workspace | pnpm + Turborepo | Strict dependencies and dependency-aware tasks |
|
|
178
|
-
|
|
179
|
-
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.
|
|
180
|
-
|
|
181
|
-
## Commands
|
|
182
|
-
|
|
183
|
-
```text
|
|
184
|
-
anhedral new <directory> [modules...] Generate a new readable workspace
|
|
185
|
-
anhedral init [modules...] Generate in the current empty directory
|
|
186
|
-
anhedral add <module...> Add connected stack capabilities
|
|
187
|
-
anhedral ui add <component...> Add source-owned UI components
|
|
188
|
-
anhedral upgrade Transactionally upgrade a supported project
|
|
189
|
-
anhedral doctor Check ownership and generator drift
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
Useful examples:
|
|
193
|
-
|
|
194
|
-
```sh
|
|
195
|
-
anhedral add storage --dry-run
|
|
196
|
-
anhedral add desktop extension
|
|
197
|
-
anhedral add electron-updater
|
|
198
|
-
anhedral ui add button dialog
|
|
199
|
-
anhedral ui add data-table --target web --dry-run
|
|
200
|
-
anhedral upgrade --dry-run
|
|
201
|
-
anhedral doctor --json
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
`--dry-run` builds the complete plan without changing the project. `--json` emits machine-readable output. `--verbose` streams child-tool diagnostics.
|
|
205
|
-
|
|
206
|
-
Application lifecycle commands remain visible in the generated root `package.json`:
|
|
207
|
-
|
|
208
|
-
```sh
|
|
209
|
-
pnpm dev
|
|
210
|
-
pnpm dev:all
|
|
211
|
-
pnpm dev:web
|
|
212
|
-
pnpm dev:api
|
|
213
|
-
pnpm typecheck
|
|
214
|
-
pnpm verify
|
|
215
|
-
pnpm build
|
|
216
|
-
pnpm db:generate
|
|
217
|
-
pnpm db:migrate
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
`pnpm dev` starts the primary product loop: the first selected client plus the
|
|
221
|
-
API when present, or the API by itself for backend-only projects. In the full
|
|
222
|
-
stack that means web plus API. `pnpm dev:all` appears only when the project has
|
|
223
|
-
additional surfaces and intentionally starts all of them. Only commands
|
|
224
|
-
relevant to selected modules are generated.
|
|
225
|
-
|
|
226
|
-
## Extensibility and ownership
|
|
227
|
-
|
|
228
|
-
Anhedral owns initial assembly and safe structural additions. It does not own product architecture after generation.
|
|
229
|
-
|
|
230
|
-
- `README.md`, `PRODUCTION.md`, application features, pages, routes, services, and domain code are developer-owned.
|
|
231
|
-
- Root workspace configuration is mergeable.
|
|
232
|
-
- Integration substrate is recorded in `anhedral.json`; `anhedral add` refuses to overwrite modified managed files.
|
|
233
|
-
- UI components are copied into the application so developers can edit them normally.
|
|
234
|
-
- Provider integrations use ordinary SDKs and configuration files with no hidden control plane.
|
|
235
|
-
|
|
236
|
-
Before a structural change:
|
|
237
|
-
|
|
238
|
-
```sh
|
|
239
|
-
anhedral doctor
|
|
240
|
-
anhedral add <module> --dry-run
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
When `doctor` reports that a project was generated by a supported older release, run `anhedral upgrade --dry-run`, inspect the plan, and then run `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.
|
|
244
|
-
|
|
245
|
-
## Documentation contract
|
|
246
|
-
|
|
247
|
-
Every generated project teaches both humans and coding agents how to work in it:
|
|
248
|
-
|
|
249
|
-
- `README.md` answers how to run the app and where frontend/backend code goes.
|
|
250
|
-
- `docs/DEVELOPMENT.md` provides end-to-end feature and common-task recipes.
|
|
251
|
-
- `docs/STACK.md` maps generated files to each tool's official documentation.
|
|
252
|
-
- `SKILL.md` gives coding agents concise repository-specific workflow and safety rules.
|
|
253
|
-
- `PRODUCTION.md` covers only the accounts, environment, infrastructure, DNS, stores, and release steps selected for that project.
|
|
254
|
-
|
|
255
|
-
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).
|
|
256
|
-
|
|
257
|
-
The complete lifecycle, runtime, cloud, command, and coding-agent topology is in
|
|
258
|
-
the [Anhedral master stack map](docs/master-stack-map.md).
|
|
259
|
-
|
|
260
|
-
## Module dependency rules
|
|
261
|
-
|
|
262
|
-
Anhedral resolves integrations as a deterministic graph:
|
|
263
|
-
|
|
264
|
-
```text
|
|
265
|
-
auth -> api + db
|
|
266
|
-
billing -> auth
|
|
267
|
-
storage -> auth
|
|
268
|
-
native-subscriptions -> mobile + billing
|
|
269
|
-
electron-updater -> desktop
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Adding a capability brings the infrastructure it actually requires. Unselected providers do not leave dead source files or environment placeholders behind.
|
|
273
|
-
|
|
274
|
-
## Verification
|
|
275
|
-
|
|
276
|
-
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.
|
|
277
50
|
|
|
278
51
|
```sh
|
|
279
|
-
pnpm
|
|
280
|
-
pnpm
|
|
52
|
+
pnpm --dir demo/anhedral-factory dev
|
|
53
|
+
pnpm --dir demo/anhedral-factory check
|
|
281
54
|
```
|
|
282
55
|
|
|
283
|
-
|
|
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.
|