anhedral 0.1.10 → 0.3.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 (83) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/CONTRIBUTING.md +70 -0
  3. package/LICENSE +21 -17
  4. package/README.md +151 -152
  5. package/SECURITY.md +35 -0
  6. package/SKILL.md +177 -0
  7. package/bin/anhedral.js +1 -1
  8. package/dist/architecture/contributions.d.ts +28 -0
  9. package/dist/architecture/contributions.js +118 -0
  10. package/dist/architecture/index.d.ts +12 -0
  11. package/dist/architecture/index.js +6 -0
  12. package/dist/architecture/manifest.d.ts +53 -0
  13. package/dist/architecture/manifest.js +283 -0
  14. package/dist/architecture/modules.d.ts +37 -0
  15. package/dist/architecture/modules.js +176 -0
  16. package/dist/architecture/plan.d.ts +58 -0
  17. package/dist/architecture/plan.js +145 -0
  18. package/dist/architecture/templates.d.ts +10 -0
  19. package/dist/architecture/templates.js +23 -0
  20. package/dist/bin.d.ts +2 -0
  21. package/dist/bin.js +167 -0
  22. package/dist/cli.d.ts +24 -2
  23. package/dist/cli.js +186 -21
  24. package/dist/composers/root.d.ts +6 -0
  25. package/dist/composers/root.js +34 -0
  26. package/dist/dependencies.d.ts +29 -9
  27. package/dist/dependencies.js +220 -60
  28. package/dist/index.d.ts +8 -2
  29. package/dist/index.js +5 -31
  30. package/dist/print.js +15 -0
  31. package/dist/prompts.d.ts +5 -0
  32. package/dist/prompts.js +19 -0
  33. package/dist/render.d.ts +11 -0
  34. package/dist/render.js +74 -0
  35. package/dist/scaffold.d.ts +56 -12
  36. package/dist/scaffold.js +1466 -1158
  37. package/dist/template-source.d.ts +20 -0
  38. package/dist/template-source.js +180 -0
  39. package/dist/templates/api.d.ts +2 -0
  40. package/dist/templates/api.js +3114 -0
  41. package/dist/templates/assets-private-proxy.d.ts +3 -0
  42. package/dist/templates/assets-private-proxy.js +277 -0
  43. package/dist/templates/desktop.d.ts +2 -0
  44. package/dist/templates/desktop.js +572 -0
  45. package/dist/templates/extension.d.ts +1 -1
  46. package/dist/templates/extension.js +322 -248
  47. package/dist/templates/mobile.d.ts +2 -0
  48. package/dist/templates/mobile.js +720 -0
  49. package/dist/templates/shared.d.ts +2 -0
  50. package/dist/templates/shared.js +503 -0
  51. package/dist/templates/web.d.ts +2 -0
  52. package/dist/templates/web.js +412 -0
  53. package/dist/toolchain.d.ts +0 -8
  54. package/dist/toolchain.js +0 -21
  55. package/dist/transaction.d.ts +22 -0
  56. package/dist/transaction.js +822 -0
  57. package/dist/ui.d.ts +33 -0
  58. package/dist/ui.js +199 -0
  59. package/dist/util.d.ts +1 -5
  60. package/dist/util.js +70 -159
  61. package/dist/version.d.ts +2 -0
  62. package/dist/version.js +2 -0
  63. package/dist/workspace-config.d.ts +11 -0
  64. package/dist/workspace-config.js +372 -0
  65. package/docs/conventions.md +89 -0
  66. package/docs/output-tree-contract.md +442 -0
  67. package/package.json +56 -13
  68. package/references/manual-scaffolding.md +386 -0
  69. package/templates/api-fastify/apps/api/tsconfig.json +20 -0
  70. package/templates/catalog.json +23 -0
  71. package/templates/db-drizzle/packages/db/tsconfig.json +14 -0
  72. package/templates/desktop-electron/apps/desktop/tsconfig.json +37 -0
  73. package/templates/extension-wxt/apps/extension/tsconfig.json +41 -0
  74. package/templates/mobile-expo/apps/mobile/expo-env.d.ts +1 -0
  75. package/templates/web-next/apps/web/next-env.d.ts +6 -0
  76. package/dist/branding.d.ts +0 -5
  77. package/dist/branding.js +0 -17
  78. package/dist/commands.d.ts +0 -7
  79. package/dist/commands.js +0 -24
  80. package/dist/templates/backend.d.ts +0 -2
  81. package/dist/templates/backend.js +0 -2115
  82. package/dist/templates/frontend.d.ts +0 -2
  83. package/dist/templates/frontend.js +0 -1268
package/CHANGELOG.md ADDED
@@ -0,0 +1,97 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## Unreleased
8
+
9
+ ## 0.3.0 - 2026-07-21
10
+
11
+ ### Added
12
+
13
+ - Add a unified `anhedral ui add` workflow that routes DOM clients to shadcn/ui and Expo clients to React Native Reusables.
14
+ - Add interactive starter-component selection after app surfaces and feature sets, with NativeWind or Uniwind selection for Expo.
15
+ - Add React Native Reusables-ready Expo configuration, theme CSS, aliases, utilities, Metro integration, and portal hosting.
16
+ - Add manifest schema v5 UI configuration and per-client component installation records.
17
+ - Add staged provider execution, dry-run plans, duplicate-install detection, target validation, and provider routing tests.
18
+ - Add `anhedral new <directory>` as the primary complete-stack creation flow while retaining `init` for an empty current directory.
19
+ - Generate selection-aware `README.md`, `docs/DEVELOPMENT.md`, `docs/STACK.md`, and `SKILL.md` guidance that maps product tasks to ordinary framework source.
20
+ - Publish the repository skill, manual scaffolding reference, conventions, and output-tree contract with the npm package.
21
+
22
+ ### Changed
23
+
24
+ - Pin the component installer to shadcn 4.13.0 and run all provider mutations inside Anhedral transaction staging.
25
+ - Preserve Anhedral's exact Expo SDK dependency while resolving React Native Reusables registry dependencies before the root workspace install.
26
+ - Present Anhedral as a readable TypeScript stack generator with native Next.js, Expo, Fastify, Drizzle, Electron, and WXT conventions rather than a proprietary application runtime.
27
+ - Use argument-vector process execution for workspace installation instead of invoking a command through a shell.
28
+ - Remove the retired one-app compiler experiment from the production CLI and package surface.
29
+
30
+ ### Security
31
+
32
+ - Reject symbolic-link scaffold roots before creating transaction metadata or modifying their targets.
33
+ - Override vulnerable `shell-quote` and `sharp` dependency ranges in generated workspaces.
34
+
35
+ ## 0.2.1 - 2026-07-16
36
+
37
+ ### Added
38
+
39
+ - Add integrity-checked bundled framework substrates, typed module contributions, deterministic root composers, and manifest schema v4 template provenance.
40
+ - Add template tamper, symbolic-link, package-content, and contribution-composition regression tests.
41
+ - Add exact-artifact portability checks at the minimum Node.js 20 and 22 releases and the pinned Node.js 24 release on macOS and Windows.
42
+ - Add scheduled and release-gated Electron, WXT, and Expo native runtime acceptance lanes.
43
+ - Add deterministic workflow, Renovate extraction, release declaration, registry recovery, and module-topology policy tests.
44
+
45
+ ### Security
46
+
47
+ - Reject altered template catalogs, mismatched substrate digests, symbolic links, forbidden generated artifacts, and oversized template trees before transactional commit.
48
+ - Scan all tracked text, built output, and final package tarballs for high-confidence secret formats before publication.
49
+ - Clarify that public package availability grants no installation, execution, or generated-output rights without a separate written agreement.
50
+
51
+ ## 0.2.0 - 2026-07-15
52
+
53
+ ### Added
54
+
55
+ - Add manifest schema v3 with deterministic module dependency resolution, file ownership, hashes, modes, and an explicit toolchain channel.
56
+ - Add transactional `init` and `add` operations with locking, journaling, rollback, dry-run plans, and JSON output.
57
+ - Add the `anhedral doctor` command.
58
+ - Add deterministic output-tree contracts for representative scaffold combinations.
59
+
60
+ ### Changed
61
+
62
+ - Generate only the dependencies, source files, environment keys, apps, and shared packages required by selected modules.
63
+ - Align Vercel Services output with the current `services` schema and mount Fastify routes under the preserved `/api` path.
64
+ - Refresh the verified Next.js, Expo, Clerk, Electron, WXT, Vite, and RevenueCat integration matrix.
65
+ - Separate the side-effect-free package API from the executable CLI entry point.
66
+ - Preserve user-owned documentation, workflows, package fields, and mergeable root configuration during incremental adds.
67
+ - Build from a clean `dist/` directory before tests and packaging.
68
+ - Publish one verified tarball and compare its integrity with npm before tagging.
69
+ - Pin the release Node.js/npm packer so recovery rebuilds remain reproducible.
70
+ - Install the exact release artifact and run its `.bin/anhedral` shim in package smoke tests.
71
+ - Enforce an explicit npm package allowlist and artifact size policy.
72
+ - Test the CLI on Node.js 20, 22, and 24 in CI.
73
+ - Wire Clerk controls and token-aware API helpers into web and mobile templates, and make the desktop account action open Clerk sign-in or profile UI.
74
+ - Bootstrap RevenueCat only for `native-subscriptions`, connect native purchases to the authenticated user, and expose a native paywall action.
75
+ - Put pnpm overrides, build permissions, and peer policy in `pnpm-workspace.yaml`, with conflict-safe structural merges.
76
+ - Keep public API GET requests simple by omitting unused platform and content-type headers.
77
+ - Remove unused provider dependencies and environment placeholders from generated clients.
78
+ - Wire Tailwind CSS v4 into generated web and desktop builds, including semantic shadcn color tokens.
79
+ - Keep canonical module IDs and valid RFC 3986 URI schemes in generated project metadata and documentation.
80
+ - Refresh generator-owned Node.js and pnpm policy during incremental adds when the recorded package manifest is unmodified.
81
+
82
+ ### Removed
83
+
84
+ - Remove pre-schema-v3 manifest migration, generated-layout adoption, deprecated module aliases, and duplicate `stack.json` output. Projects must be generated with the current CLI and use canonical module IDs.
85
+
86
+ ### Security
87
+
88
+ - Reject modified managed files and unowned path collisions before committing incremental changes.
89
+ - Validate recovery journals, reject symlink traversal, and persist transaction intent before moving files.
90
+ - Audit every locked CLI dependency through OSV after pnpm's retired audit endpoint became unavailable.
91
+ - Make RevenueCat webhook processing fail closed and persist idempotency records when billing is selected.
92
+ - Scope npm credentials to the single publish step in the protected release job.
93
+ - Separate read-only release verification from npm publication and Git tag creation.
94
+ - Pin GitHub Actions to verified upstream commit SHAs.
95
+ - Default Fastify proxy trust to off, require an explicit bounded trusted-hop count, and minimize conditional Chrome permissions.
96
+ - Reconcile exact package versions against detailed OSV advisory ranges when the batch index is over-broad.
97
+ - Reject manifest-recorded directories and other non-regular paths during project health checks.
@@ -0,0 +1,70 @@
1
+ # Contributing
2
+
3
+ ## Local setup
4
+
5
+ Anhedral requires Node.js 20.19+ or 22.12+ and pnpm 10.34.5.
6
+
7
+ ```sh
8
+ pnpm install --frozen-lockfile
9
+ pnpm build
10
+ pnpm lint
11
+ pnpm check:security
12
+ pnpm check:release-policy
13
+ pnpm audit:osv
14
+ pnpm test
15
+ ```
16
+
17
+ ## Before opening a pull request
18
+
19
+ Run the checks relevant to the files you changed:
20
+
21
+ ```sh
22
+ pnpm typecheck
23
+ pnpm test
24
+ pnpm test:pack
25
+ pnpm test:packlist
26
+ pnpm test:release-tooling
27
+ ```
28
+
29
+ Changes to generated templates or dependency pins should also run:
30
+
31
+ ```sh
32
+ pnpm test:deps
33
+ pnpm test:e2e
34
+ ```
35
+
36
+ The E2E test installs upstream packages in a disposable operating-system temp directory, so it requires network access and may take several minutes. It removes the workspace in a `finally` block; set `ANHEDRAL_E2E_KEEP=1` only when you intentionally need to inspect a failed or completed run.
37
+
38
+ After an intentional scaffold-output change, regenerate and review the path/mode/SHA-256 contracts and generated tree documentation:
39
+
40
+ ```sh
41
+ pnpm build
42
+ node tests/update-output-tree-contracts.js
43
+ ```
44
+
45
+ ## Package changes
46
+
47
+ - Keep the public package allowlist narrow.
48
+ - Do not commit `dist/`, tarballs, `release-artifact/`, or temporary E2E/demo workspaces.
49
+ - Add or update a regression test for CLI behavior and generated configuration changes.
50
+ - Keep stable toolchain commands pinned; mutable upstream versions belong only in the `latest` lane.
51
+ - Run the OSV audit against a newly installed representative generated lockfile when changing framework or runtime pins.
52
+
53
+ ## Ownership and required review
54
+
55
+ Repository administrators must map the following roles to real maintainers in branch protection, the protected `npm` environment, private vulnerability reporting, and workflow-failure notifications:
56
+
57
+ - **Generator owner:** core architecture, transactions, manifests, and generated-file ownership.
58
+ - **Runtime owner:** application templates, provider integrations, and the stable dependency manifest.
59
+ - **Release owner:** package metadata, CI workflows, registry publication, tags, and recovery.
60
+ - **Security responder:** vulnerability intake, secret-exposure response, and supply-chain incidents.
61
+
62
+ No `CODEOWNERS` file is committed until an actual GitHub user or team slug is selected. A placeholder would create false confidence without enforcing review. Require at least one appropriate owner review for generator/runtime changes and a release-owner review for `.github/workflows/`, `scripts/`, `package.json`, `renovate.json`, `SECURITY.md`, or `docs/RELEASING.md`.
63
+
64
+ Scheduled Toolchain Drift failures and release-workflow failures must alert the release owner. Security-policy, secret-scan, or OSV failures must additionally alert the security responder. Configure those routes in repository notification settings and test them after changing ownership.
65
+
66
+ ## Releases
67
+
68
+ Do not run `npm publish` from a development checkout. Version changes are reviewed before release, and CI publishes the verified tarball. See [docs/RELEASING.md](docs/RELEASING.md).
69
+
70
+ This repository and package are proprietary. Public availability of an npm artifact does not grant permission to install or run it. Contributor and customer rights, including rights in generated output, come only from a separate written agreement with Anhedral, Inc.
package/LICENSE CHANGED
@@ -1,22 +1,26 @@
1
- All Rights Reserved
2
-
3
1
  Copyright (c) 2026 Anhedral, Inc.
4
2
 
5
- THE CONTENTS OF THIS PROJECT ARE PROPRIETARY AND CONFIDENTIAL.
6
- UNAUTHORIZED COPYING, TRANSFERRING OR REPRODUCTION OF THE CONTENTS
7
- OF THIS PROJECT, VIA ANY MEDIUM, IS STRICTLY PROHIBITED.
3
+ All Rights Reserved.
4
+
5
+ The contents of this project are proprietary and confidential.
6
+ Unauthorized use, copying, modification, distribution, transfer, or
7
+ reproduction of this project, in whole or in part and by any medium,
8
+ is strictly prohibited except under a separate written agreement with
9
+ Anhedral, Inc.
8
10
 
9
- The receipt or possession of the source code and/or any parts thereof
10
- does not convey or imply any right to use them for any purpose other
11
- than the purpose for which they were provided to you.
11
+ Receipt or possession of the source code or any portion of it does not
12
+ convey or imply a license or any right to use it beyond the purpose for
13
+ which Anhedral, Inc. provided it.
12
14
 
13
- The software is provided "AS IS", without warranty of any kind,
14
- express or implied, including but not limited to the warranties of
15
- merchantability, fitness for a particular purpose and noninfringement.
16
- In no event shall the authors or copyright holders be liable for any
17
- claim, damages or other liability, whether in an action of contract,
18
- tort or otherwise, arising from, out of or in connection with the
19
- software or the use or other dealings in the software.
15
+ Public availability of package metadata, documentation, source code, or a
16
+ downloadable package artifact does not constitute an offer, license, or
17
+ authorization to install or execute the software. Installation, execution,
18
+ and any rights to use, modify, own, deploy, or distribute output generated by
19
+ the software require a separate written agreement with Anhedral, Inc. Nothing
20
+ in this notice expands the rights granted by such an agreement.
20
21
 
21
- The above copyright notice and this permission notice shall be
22
- included in all copies or substantial portions of the software.
22
+ The software is provided "AS IS", without warranty of any kind, express
23
+ or implied, including but not limited to the warranties of merchantability,
24
+ fitness for a particular purpose, and noninfringement. In no event shall
25
+ Anhedral, Inc. or its contributors be liable for any claim, damages, or
26
+ other liability arising from, out of, or in connection with the software.
package/README.md CHANGED
@@ -1,220 +1,219 @@
1
1
  # Anhedral
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/anhedral.svg)](https://www.npmjs.com/package/anhedral)
4
- [![license](https://img.shields.io/npm/l/anhedral.svg)](./LICENSE)
5
4
  [![node](https://img.shields.io/node/v/anhedral.svg)](https://www.npmjs.com/package/anhedral)
6
5
 
7
- One command to start a production-shaped Expo, Fastify, and Chrome extension application.
6
+ Anhedral generates a complete, production-oriented TypeScript stack whose source code stays understandable and customizable.
8
7
 
9
- Anhedral is an opinionated init CLI for teams that want one stable full-stack architecture instead of a menu of half-finished choices. It generates a single pnpm monorepo with an Expo app for web/iOS/Android, a Fastify API, a WXT Chrome extension, shared packages, and deployment-ready structure for Vercel, EAS, and the Chrome Web Store.
8
+ > **Three-second version:** Start with the full TypeScript stack. Keep every escape hatch.
10
9
 
11
- ![Anhedral init CLI](docs/anhedral-cli-init.png)
10
+ 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.
12
11
 
13
- ## Quick Start
12
+ > **Proprietary software:** Public visibility of package metadata, documentation, or an npm artifact does not grant permission to install, execute, copy, modify, or distribute Anhedral. Installation and use are limited to parties covered by a separate written agreement with Anhedral, Inc. Rights in projects generated by Anhedral are also governed by that agreement.
13
+
14
+ ## Create an application
15
+
16
+ Create the complete stack:
14
17
 
15
18
  ```sh
16
- pnpm dlx anhedral@latest init
19
+ pnpm dlx anhedral@latest new my-product
20
+ cd my-product
21
+ pnpm dev
17
22
  ```
18
23
 
19
- Or with npm:
24
+ With no module flags, `new` includes every supported application surface and backend capability. Generate a focused stack by naming only what the product needs:
20
25
 
21
26
  ```sh
22
- npx anhedral@latest init
27
+ pnpm dlx anhedral@latest new my-product --web --api --db --auth
28
+ pnpm dlx anhedral@latest new my-api --api --db
29
+ pnpm dlx anhedral@latest new my-clients --web --mobile
23
30
  ```
24
31
 
25
- Use `--skip-install` when you want deterministic file generation before installing dependencies:
32
+ `init` generates the same workspace in the current empty directory:
26
33
 
27
34
  ```sh
28
- pnpm dlx anhedral@latest init --skip-install
29
- pnpm install
35
+ mkdir my-product && cd my-product
36
+ pnpm dlx anhedral@latest init --web --api --db --auth
30
37
  ```
31
38
 
32
- ## What It Generates
33
-
34
- ```txt
35
- .
36
- ├─ Frontend/ Expo + React Native Reusables app
37
- ├─ Backend/ Fastify API
38
- ├─ Extension/ WXT Chrome extension
39
- ├─ packages/
40
- │ ├─ api-client/ shared typed API client
41
- │ ├─ config/ shared config helpers
42
- │ ├─ contracts/ shared Zod request/response contracts
43
- │ ├─ db/ Drizzle schema, Neon client, migrations
44
- │ └─ types/ shared TypeScript types
45
- ├─ PRODUCTION.md deployment checklist
46
- ├─ turbo.json workspace task graph
47
- └─ package.json root scripts
39
+ Interactive terminals prompt for surfaces and capabilities. CI and coding agents should pass explicit module flags.
40
+
41
+ ## What gets generated
42
+
43
+ ```text
44
+ my-product/
45
+ ├── apps/
46
+ │ ├── web/ # Next.js App Router + source-owned shadcn/ui
47
+ │ ├── mobile/ # Expo Router + React Native Reusables
48
+ │ ├── api/ # Fastify routes, services, auth, providers
49
+ │ ├── desktop/ # Electron + React
50
+ │ ├── extension/ # WXT browser extension
51
+ │ └── assets-private-proxy/ # Cloudflare Worker for private R2 delivery
52
+ ├── packages/
53
+ │ ├── contracts/ # shared Zod network contracts
54
+ │ ├── api-client/ # typed client used by every frontend
55
+ │ ├── db/ # Drizzle schema and reviewed migrations
56
+ │ └── realtime/ # Ably client when billing is selected
57
+ ├── docs/
58
+ │ ├── DEVELOPMENT.md # task-oriented feature recipes
59
+ │ └── STACK.md # tool map and official documentation
60
+ ├── README.md # first run and where-to-write-code map
61
+ ├── PRODUCTION.md # selection-specific release runbook
62
+ ├── SKILL.md # repository guidance for coding agents
63
+ ├── ANHEDRAL.md # generator and ownership notes
64
+ └── anhedral.json # modules, versions, provenance, ownership
48
65
  ```
49
66
 
50
- The generated app is intentionally one repository. Deploy the same Git repo as two Vercel projects:
51
-
52
- - `Frontend`: Expo web export, built with `pnpm build:web`, output to `dist`
53
- - `Backend`: Fastify API, built with `pnpm build`, entrypoint at `src/index.ts`
54
-
55
- The same `Frontend` source is used for native iOS and Android builds through EAS. The `Extension` source builds a WXT Chrome extension ZIP for the Chrome Web Store.
56
-
57
- ## Stack
67
+ Whole directories are omitted when their module is not selected. Generated documentation is selection-aware.
58
68
 
59
- Anhedral supports one carefully maintained stack:
69
+ ## Developer experience
60
70
 
61
- - Expo + React Native Reusables frontend
62
- - Fastify backend
63
- - WXT Chrome extension
64
- - Neon + Drizzle
65
- - Cloudflare R2/CDN
66
- - Clerk auth
67
- - RevenueCat + Stripe
68
- - Vercel deployment
69
- - pnpm workspaces + Turborepo
71
+ Developers use each tool normally:
70
72
 
71
- The goal is stability. The generated project avoids framework sprawl, duplicate schemas, and separate frontend/backend/extension repositories.
73
+ ```tsx
74
+ // apps/web/app/projects/page.tsx
75
+ import { ProjectList } from '@/components/projects/project-list';
72
76
 
73
- ## Why This Stack
74
-
75
- Anhedral is built around one idea: a startup should be able to launch every major client from one repository without committing to infrastructure that becomes expensive, fragmented, or hard to change later.
76
-
77
- The stack is intentionally narrow:
77
+ export default function ProjectsPage() {
78
+ return <ProjectList />;
79
+ }
80
+ ```
78
81
 
79
- | Choice | Why Anhedral uses it |
80
- | --- | --- |
81
- | Expo | One React Native codebase targets web browsers, iOS, and Android. Compared with separate web and native apps, Expo keeps product iteration faster and avoids rebuilding shared screens, auth flows, and client logic three times. |
82
- | React Native Reusables | It brings shadcn-style primitives to React Native and Expo without locking the app into a heavy design system. Compared with bespoke component scaffolds, it gives teams accessible primitives they can replace or extend as the product becomes specific. |
83
- | Fastify | Fastify is small, fast, TypeScript-friendly, and works well as a central API layer on Vercel. Compared with pushing logic into many frontend routes, serverless functions, or client SDK calls, a Fastify backend centralizes auth, billing, storage, database access, webhooks, and internal APIs in one place. |
84
- | TypeScript | The whole stack shares types, contracts, and API clients. Compared with untyped template code, this catches frontend/backend drift before deploy and makes the generated app safer to evolve. |
85
- | Zod contracts | Request and response schemas live in shared packages. Compared with duplicating interfaces across clients, Zod lets the backend validate inputs while the frontend parses responses from the same source of truth. |
86
- | Neon + Drizzle | Neon gives serverless Postgres that can start free and scale with usage; Drizzle keeps schema and queries close to TypeScript. Compared with proprietary document databases or opaque ORMs, this keeps the data layer portable, SQL-native, and easy to inspect. |
87
- | Cloudflare R2/CDN | R2 provides S3-compatible object storage without S3-style egress fees. Compared with storing files in the database or coupling uploads to one app client, signed storage routes give every client the same upload/download primitive. |
88
- | Clerk | Clerk handles modern auth across web, native, and extension clients. Compared with hand-rolled auth, it removes a high-risk surface area while still letting the backend own authorization decisions. |
89
- | RevenueCat + Stripe | RevenueCat coordinates native subscriptions and Stripe web billing behind one entitlement model. Compared with separate payment implementations per platform, the backend can ask one question: what is this user allowed to access? |
90
- | WXT | WXT gives the Chrome extension a modern TypeScript/Vite workflow and supports the Side Panel API. Compared with hand-maintained manifest scaffolds, it reduces extension build and packaging mistakes. |
91
- | Vercel | Vercel deploys the Expo web app and Fastify API from the same Git repository with separate project roots. Compared with manually wiring CI/CD early, teams get preview deployments and production deploys from normal commits. |
82
+ ```ts
83
+ // packages/contracts/src/projects.ts
84
+ import { z } from 'zod';
92
85
 
93
- Every part of the stack can be started on free tiers and scales automatically as traffic grows. That matters because the first production architecture should not force a team to choose between moving quickly and being able to handle success.
86
+ export const ProjectSchema = z.object({ id: z.string(), name: z.string() });
87
+ export const ProjectListSchema = z.array(ProjectSchema);
88
+ ```
94
89
 
95
- The bigger advantage is architectural: Anhedral creates all target clients plus one backend that can serve internal and external requests. Product logic, auth decisions, subscription entitlements, storage access, database writes, and webhooks have a central home. That helps startups avoid the common failure mode where every client invents its own rules, and the team later cannot respond quickly when the product needs to shift.
90
+ ```ts
91
+ // apps/api/src/routes/projects.ts
92
+ import { db } from '@shared/db';
93
+ import { projects } from '@shared/db/schema';
96
94
 
97
- ## Local Development
95
+ export async function listProjects() {
96
+ return db.select().from(projects);
97
+ }
98
+ ```
98
99
 
99
- From the generated project root:
100
+ The convention is a conventional vertical flow, not an Anhedral DSL:
100
101
 
101
- ```sh
102
- pnpm install
103
- pnpm dev
102
+ ```text
103
+ contracts -> database/service -> Fastify route -> typed API client -> frontend
104
104
  ```
105
105
 
106
- Run one surface at a time:
107
-
108
- ```sh
109
- pnpm dev:frontend
110
- pnpm dev:backend
111
- pnpm dev:extension
106
+ - Write web product code under `apps/web` using Next.js conventions.
107
+ - Write mobile product code under `apps/mobile` using Expo Router conventions.
108
+ - Write backend routes and services under `apps/api` using Fastify conventions.
109
+ - Write tables and queries under `packages/db` using Drizzle conventions.
110
+ - Share only network contracts and client-safe packages with frontends.
111
+ - Import the underlying framework directly whenever its API is the right tool.
112
+
113
+ ## The stack
114
+
115
+ | Concern | Default | Why Anhedral includes it |
116
+ | --- | --- | --- |
117
+ | Web | Next.js + Vercel | App Router, React server rendering, routing, deployment |
118
+ | Native | Expo Router | One TypeScript application for iOS and Android |
119
+ | API | Fastify | Typed validation, structured logging, plugin boundaries |
120
+ | Database | Neon + Drizzle | Managed Postgres with TypeScript schema and SQL-like queries |
121
+ | Authentication | Clerk | Connected frontend and backend identity/session flows |
122
+ | UI | shadcn/ui + React Native Reusables | Accessible source code the application owns |
123
+ | Storage | private Cloudflare R2 | Signed uploads and controlled asset delivery |
124
+ | Billing/realtime | RevenueCat + Ably | Durable entitlements and client invalidation |
125
+ | Desktop | Electron | Predictable cross-platform TypeScript desktop runtime |
126
+ | Extension | WXT | Browser-extension entrypoints, builds, and packaging |
127
+ | Workspace | pnpm + Turborepo | Strict dependencies and dependency-aware tasks |
128
+
129
+ 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.
130
+
131
+ ## Commands
132
+
133
+ ```text
134
+ anhedral new <directory> [modules...] Generate a new readable workspace
135
+ anhedral init [modules...] Generate in the current empty directory
136
+ anhedral add <module...> Add connected stack capabilities
137
+ anhedral ui add <component...> Add source-owned UI components
138
+ anhedral doctor Check ownership and generator drift
112
139
  ```
113
140
 
114
- Verify before deployment:
141
+ Useful examples:
115
142
 
116
143
  ```sh
117
- pnpm verify
118
- pnpm verify:frontend
119
- pnpm verify:backend
120
- pnpm verify:extension
144
+ anhedral add storage --dry-run
145
+ anhedral add desktop extension
146
+ anhedral ui add button dialog
147
+ anhedral ui add data-table --target web --dry-run
148
+ anhedral doctor --json
121
149
  ```
122
150
 
123
- Database workflow:
151
+ `--dry-run` builds the complete plan without changing the project. `--json` emits machine-readable output. `--verbose` streams child-tool diagnostics.
152
+
153
+ Application lifecycle commands remain visible in the generated root `package.json`:
124
154
 
125
155
  ```sh
156
+ pnpm dev
157
+ pnpm dev:web
158
+ pnpm dev:api
159
+ pnpm typecheck
160
+ pnpm verify
161
+ pnpm build
126
162
  pnpm db:generate
127
163
  pnpm db:migrate
128
164
  ```
129
165
 
130
- ## Provider Setup
131
-
132
- Generated projects include placeholder env values so the repository can be inspected before accounts are provisioned. Real auth, billing, uploads, native builds, and extension sign-in require provider keys.
133
-
134
- The generated `README.md` and `PRODUCTION.md` explain where every key belongs:
166
+ Only commands relevant to selected modules are generated.
135
167
 
136
- - Neon: `DATABASE_URL`
137
- - Clerk: `EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY`, `CLERK_PUBLISHABLE_KEY`, `CLERK_SECRET_KEY`, `VITE_CLERK_PUBLISHABLE_KEY`
138
- - RevenueCat + Stripe: `EXPO_PUBLIC_RC_*`, `RC_SECRET_API_KEY`, `RC_WEBHOOK_SECRET`
139
- - Cloudflare R2/CDN: `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_BUCKET`
140
- - Vercel: two projects from the same Git repository, rooted at `Frontend` and `Backend`
141
- - EAS: native iOS and Android builds from `Frontend`
142
- - Chrome Web Store: WXT ZIP upload from `Extension/.output`
168
+ ## Extensibility and ownership
143
169
 
144
- ## Deployment
170
+ Anhedral owns initial assembly and safe structural additions. It does not own product architecture after generation.
145
171
 
146
- ### Vercel
172
+ - `README.md`, `PRODUCTION.md`, application features, pages, routes, services, and domain code are developer-owned.
173
+ - Root workspace configuration is mergeable.
174
+ - Integration substrate is recorded in `anhedral.json`; `anhedral add` refuses to overwrite modified managed files.
175
+ - UI components are copied into the application so developers can edit them normally.
176
+ - Provider integrations use ordinary SDKs and configuration files with no hidden control plane.
147
177
 
148
- Import the same GitHub repository twice:
149
-
150
- | Project | Root Directory | Build Command | Output |
151
- | --- | --- | --- | --- |
152
- | Frontend | `Frontend` | `pnpm build:web` | `dist` |
153
- | Backend | `Backend` | `pnpm build` | Fastify entrypoint |
154
-
155
- Enable Vercel access to source files outside each project root so workspace packages under `packages/*` resolve during builds.
156
-
157
- ### EAS
158
-
159
- Use `Frontend` as the Expo project root:
178
+ Before a structural change:
160
179
 
161
180
  ```sh
162
- cd Frontend
163
- pnpm dlx eas-cli@latest login
164
- pnpm dlx eas-cli@latest init
165
- pnpm dlx eas-cli@latest build --platform all --profile production
166
- pnpm dlx eas-cli@latest submit --platform all --latest --profile production
181
+ anhedral doctor
182
+ anhedral add <module> --dry-run
167
183
  ```
168
184
 
169
- ### Chrome Extension
170
-
171
- ```sh
172
- pnpm extension:zip
173
- ```
174
-
175
- Upload `Extension/.output/*-chrome.zip` to the Chrome Web Store Developer Dashboard.
176
-
177
- ## Dependency Policy
178
-
179
- `pnpm dlx anhedral@latest init` gives users the latest published Anhedral CLI, but generated projects use the dependency manifest verified for that release.
180
-
181
- Runtime dependency versions live in `src/dependencies.ts`. Generated projects also receive a `stack.json` file recording the exact stack and dependency manifest used for that init run.
185
+ ## Documentation contract
182
186
 
183
- This keeps generated apps reproducible while still allowing Anhedral itself to move forward quickly through verified releases.
187
+ Every generated project teaches both humans and coding agents how to work in it:
184
188
 
185
- ## Development
189
+ - `README.md` answers how to run the app and where frontend/backend code goes.
190
+ - `docs/DEVELOPMENT.md` provides end-to-end feature and common-task recipes.
191
+ - `docs/STACK.md` maps generated files to each tool's official documentation.
192
+ - `SKILL.md` gives coding agents concise repository-specific workflow and safety rules.
193
+ - `PRODUCTION.md` covers only the accounts, environment, infrastructure, DNS, stores, and release steps selected for that project.
186
194
 
187
- Work on the CLI locally:
195
+ 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).
188
196
 
189
- ```sh
190
- pnpm install
191
- pnpm build
192
- pnpm test:all
193
- ```
197
+ ## Module dependency rules
194
198
 
195
- Refresh the checked-in demo output:
199
+ Anhedral resolves integrations as a deterministic graph:
196
200
 
197
- ```sh
198
- pnpm demo:refresh
201
+ ```text
202
+ auth -> api + db
203
+ billing -> auth
204
+ storage -> auth
205
+ native-subscriptions -> mobile + billing
199
206
  ```
200
207
 
201
- Validate upstream scaffold drift:
208
+ Adding a capability brings the infrastructure it actually requires. Unselected providers do not leave dead source files or environment placeholders behind.
202
209
 
203
- ```sh
204
- pnpm test:e2e:latest
205
- ```
206
-
207
- ## Release
208
-
209
- Official releases are automatic on merges to `main`. The release workflow bumps the patch version, runs the release checks, creates a release commit and tag, and publishes to npm.
210
+ ## Verification
210
211
 
211
- Manual fallback:
212
+ The generator and representative public stacks are checked with:
212
213
 
213
214
  ```sh
214
- pnpm release:check
215
- npm publish --provenance=false --ignore-scripts
215
+ pnpm typecheck
216
+ pnpm test:all
216
217
  ```
217
218
 
218
- ## License
219
-
220
- MIT
219
+ Generated workspaces include their own package-level tests, full-stack `verify` command, CI workflow, production environment validation, migration drift gate, and deployment configuration.
package/SECURITY.md ADDED
@@ -0,0 +1,35 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are made on the current development branch and released as a new npm version. Consumers should use the latest version published under the `latest` dist-tag.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Do not open a public issue for a suspected vulnerability. Use GitHub's private vulnerability reporting or security-advisory flow for this repository. If repository access is unavailable, contact the package maintainers through the owner information on the [anhedral npm package](https://www.npmjs.com/package/anhedral).
10
+
11
+ Include the affected version, reproduction steps, impact, and any suggested mitigation. Please avoid accessing data that is not yours and allow maintainers time to investigate before public disclosure.
12
+
13
+ ## Supply-chain policy
14
+
15
+ - Release artifacts are built and tested in a read-only job.
16
+ - The exact tarball uploaded by CI is the artifact submitted to npm.
17
+ - npm integrity is checked before and after publication.
18
+ - npm credentials are exposed only to the publish step in the protected `npm` environment.
19
+ - A Git tag and GitHub release are created only after npm confirms the expected artifact integrity.
20
+ - GitHub Actions are pinned to reviewed commit SHAs, and the release Node.js/npm packer is pinned to an exact version.
21
+ - CI queries OSV for every exact package version in `pnpm-lock.yaml` and every dependency version shipped by the generator; it fails closed if the service remains unavailable after bounded retries or reports a finding.
22
+ - Local policy scans every tracked or non-ignored working-tree text file and built `dist/` file for high-confidence credential formats. Release jobs repeat the scan against the exact gzip tarball before it crosses the publish boundary. Placeholder examples use explicit non-secret values rather than allowlisting token-shaped strings.
23
+ - Release declarations must be valid Semantic Versioning and have a matching `CHANGELOG.md` section. Local deterministic checks validate workflow policy and confirm every Renovate custom manager still extracts a maintained pin.
24
+
25
+ Generated projects pin their stable dependency manifest, explicitly allow only required dependency build scripts, and record the selected toolchain channel in `anhedral.json`. The `latest` channel is for upstream-drift testing and is not the reproducible default.
26
+
27
+ Incremental generation rejects path traversal, symbolic-link targets, unowned collisions, modified managed files, and managed-file permission drift. Transaction journals are validated before recovery, fsynced before filesystem moves, and advanced only around durable rename barriers where the host filesystem supports directory synchronization.
28
+
29
+ UI component installation is an explicit networked supply-chain operation. Anhedral pins the shadcn installer version, routes Expo only to the official HTTPS React Native Reusables registry, validates component names and target paths, and runs provider mutation inside transaction staging. Provider-generated files and dependency manifests must pass ownership checks before commit. Users should review `--dry-run` output and the resulting source diff; registry content is upstream-maintained and is not part of Anhedral's immutable bundled-template catalog.
30
+
31
+ ## Secret response
32
+
33
+ If a secret-shaped finding is real, do not merely remove it from the latest commit. Revoke or rotate the credential first, identify every log, artifact, cache, fork, and package version that may contain it, and coordinate history or artifact cleanup with the security responder. Treat false positives by changing the example to an unmistakable placeholder; do not add broad path exclusions.
34
+
35
+ Anhedral is proprietary software. Security reports and public package availability do not grant permission to install, execute, or test the software outside the reporter's written agreement with Anhedral, Inc.