anhedral 0.4.1 → 0.4.2

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 (47) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/README.md +68 -55
  4. package/SKILL.md +107 -12
  5. package/dist/architecture/index.d.ts +2 -2
  6. package/dist/architecture/index.js +1 -1
  7. package/dist/architecture/modules.d.ts +5 -1
  8. package/dist/architecture/modules.js +4 -1
  9. package/dist/bin.js +113 -84
  10. package/dist/cli.d.ts +7 -7
  11. package/dist/cli.js +62 -16
  12. package/dist/dependencies.d.ts +1 -0
  13. package/dist/dependencies.js +11 -8
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +1 -1
  16. package/dist/project.d.ts +30 -0
  17. package/dist/project.js +1 -0
  18. package/dist/prompts.d.ts +4 -3
  19. package/dist/prompts.js +29 -7
  20. package/dist/scaffold.d.ts +12 -24
  21. package/dist/scaffold.js +330 -123
  22. package/dist/templates/api.d.ts +1 -1
  23. package/dist/templates/api.js +67 -2
  24. package/dist/templates/assets-private-proxy.d.ts +1 -1
  25. package/dist/templates/desktop.d.ts +1 -1
  26. package/dist/templates/desktop.js +189 -36
  27. package/dist/templates/electron-updater.d.ts +1 -1
  28. package/dist/templates/electron-updater.js +1 -1
  29. package/dist/templates/extension.d.ts +1 -1
  30. package/dist/templates/extension.js +138 -14
  31. package/dist/templates/first-run.d.ts +2 -0
  32. package/dist/templates/first-run.js +167 -0
  33. package/dist/templates/mobile.d.ts +1 -1
  34. package/dist/templates/mobile.js +158 -17
  35. package/dist/templates/shared.d.ts +1 -1
  36. package/dist/templates/shared.js +64 -7
  37. package/dist/templates/web.d.ts +1 -1
  38. package/dist/templates/web.js +185 -28
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/docs/NORTHSTAR.md +114 -0
  42. package/docs/conventions.md +6 -4
  43. package/docs/engineering-principles.md +88 -0
  44. package/docs/output-tree-contract.md +16 -5
  45. package/docs/references/manual-scaffolding.md +22 -4
  46. package/docs/references/provisioning.md +434 -77
  47. package/package.json +3 -1
@@ -4,6 +4,18 @@ Use this checklist after the user asks a coding agent to create or provision an
4
4
  Anhedral project. Keep one lead agent responsible for the plan, names, secrets,
5
5
  and final verification.
6
6
 
7
+ ## Contents
8
+
9
+ 1. Start with user inputs
10
+ 2. Bootstrap a workstation from zero
11
+ 3. Resolve accounts, CLIs, and unavoidable browser work
12
+ 4. Discover agent capabilities
13
+ 5. Generate and verify the local project
14
+ 6. Authentication and secret boundaries
15
+ 7. Domain foundation
16
+ 8. Provision selected providers
17
+ 9. Verify and hand off
18
+
7
19
  ## 1. Start with user inputs
8
20
 
9
21
  Before running `anhedral new` or opening a provider dashboard, ask the user:
@@ -27,7 +39,102 @@ resource ledger containing the project stem, display name, domain, selected
27
39
  modules, provider team, resource name, hostname, environment, status, and next
28
40
  user action. Never put credential values in the ledger.
29
41
 
30
- ## 2. Discover agent capabilities
42
+ ## 2. Bootstrap a workstation from zero
43
+
44
+ Inspect before installing anything:
45
+
46
+ ```sh
47
+ node --version
48
+ npm --version
49
+ pnpm --version
50
+ git --version
51
+ ```
52
+
53
+ Use the current Node.js 24 LTS release for a new Anhedral workstation. It
54
+ satisfies the generator and the stricter Expo/mobile engine range. If Node.js is
55
+ missing, open `https://nodejs.org/en/download` with Computer Use, choose Node.js
56
+ 24 LTS for the user's OS and architecture, and stop while the user runs the
57
+ installer and approves administrator or operating-system prompts.
58
+
59
+ npm arrives with Node.js. It can bootstrap pnpm, but it must not replace pnpm
60
+ inside the generated workspace. Install the exact package-manager version
61
+ declared by the Anhedral package:
62
+
63
+ ```sh
64
+ npm install --global pnpm@10.34.5
65
+ ```
66
+
67
+ Ask before global installation. If Git is absent, install it with the official
68
+ installer or applicable OS package manager. Common interactive boundaries are:
69
+
70
+ - macOS: `xcode-select --install` opens the Command Line Tools installer.
71
+ - Windows: `winget install --id Git.Git -e` may raise UAC and installer prompts.
72
+ - Debian/Ubuntu: `sudo apt-get install git` requires the user's administrator
73
+ approval.
74
+
75
+ Ask which real name and email the user wants before configuring Git identity.
76
+ Do not invent or copy an account identity:
77
+
78
+ ```sh
79
+ git config --global user.name "<confirmed name>"
80
+ git config --global user.email "<confirmed email>"
81
+ ```
82
+
83
+ Re-run the four version checks. A browser is also required for OAuth device
84
+ flows, passkeys, MFA, CAPTCHA, terms, payments, dashboards, and store consoles.
85
+
86
+ The generated project uses transient, pinned CLIs through `pnpm dlx`; do not
87
+ globally install Anhedral, Vercel CLI, Neon CLI, Wrangler, EAS CLI, shadcn, or
88
+ WXT. npm can launch Anhedral with `npx`, but the resulting monorepo and all
89
+ documented lifecycle commands still require pnpm. Downloading the public
90
+ Anhedral package requires no npm account or `npm login`. No Anhedral module
91
+ requires Docker or a local Postgres installation.
92
+
93
+ Conditional local tools:
94
+
95
+ - GitHub CLI (`gh`) is recommended for repository creation and Git credential
96
+ setup, but Git plus the GitHub website also works.
97
+ - Clerk CLI and Ably CLI are optional management clients. They are not generated
98
+ dependencies. Record the exact version if using them and never run
99
+ `clerk init` over Anhedral's existing integration source.
100
+ - EAS cloud builds need no local Xcode, Android Studio, Ruby, CocoaPods, or JDK.
101
+ Install Xcode only for local iOS builds/manual Apple upload; install Android
102
+ Studio and a JDK only for local Android builds or emulator work.
103
+ - Build Electron artifacts on their target OS. macOS signing/notarization needs
104
+ Xcode tooling; Windows signing needs a Windows runner and an
105
+ organization-owned certificate.
106
+ - Use Chrome or another Chromium browser to load and test an unpacked extension.
107
+
108
+ ## 3. Resolve accounts, CLIs, and unavoidable browser work
109
+
110
+ Create accounts only for selected modules. Prefer organization-owned teams,
111
+ enable MFA, name at least two recovery owners for production, and record billing
112
+ ownership without recording credentials.
113
+
114
+ | Provider/account | Required when | CLI-covered work | Browser, Computer Use, or user-only work |
115
+ | --- | --- | --- | --- |
116
+ | GitHub | Recommended for every production project; required for the normal Git-triggered Vercel flow | `gh auth login`, repository creation, remote setup, push, environment/repository APIs | Account/org creation, SSO authorization, billing, visibility policy, branch-protection review |
117
+ | Vercel | `web` or `api` deployment | Generated link, preview, production, inspect, domain-inspect commands; environment variables are also supported by Vercel CLI | Account/team creation, GitHub OAuth import, selecting the Services framework preset, plan/billing, some domain and environment review |
118
+ | Neon | `db` directly or through `auth`, `billing`, or `storage` | Generated OAuth login and project creation; Neon CLI/API can manage branches and projects | Account/org creation, plan/billing, one-time safe placement of pooled connection strings, backup/restore policy review |
119
+ | Clerk | `auth` directly or through dependent features | Supplemental Clerk CLI can log in, create/link apps, manage config, inspect deployment status, and call Clerk APIs | Workspace/team/billing, social-provider OAuth apps and consent, branding/security controls, DNS review, secret handling, physical-device verification |
120
+ | RevenueCat | `billing` or `native-subscriptions` | Developer API v2 can create projects, apps, products, entitlements, offerings, and webhooks after a secret key exists | Initial account/key bootstrap in the normal path, store credential connection, Test Store/dashboard setup, plan/billing, purchase/paywall review |
121
+ | Ably | `billing` | Supplemental Ably CLI can log in, create apps, configure rules, and create keys | Account/team/billing and safe one-time API-key handling |
122
+ | Stripe | Only if the user explicitly chooses web subscriptions through RevenueCat Billing or a manual Stripe integration | Stripe CLI can log in, test webhooks, and manage supported resources | Business activation, identity/KYC, bank/tax details, terms, live-mode review; generated Anhedral billing contains no Stripe checkout or webhook |
123
+ | Cloudflare | `storage`, `electron-updater`, or Cloudflare-authoritative DNS | Generated Wrangler login, R2 bucket/CORS commands, Worker checks/deploys, custom domains, and direct lifecycle commands | Account/zone creation, R2 purchase/enablement, domain purchase or registrar delegation, DNS/email preservation, one-time S3 key reveal, plan/billing |
124
+ | Expo/EAS | `mobile` cloud build or distribution | Generated login, project init, builds, credential flows, and submissions | Expo account/team/billing and user participation in Apple/Google credential prompts |
125
+ | Apple Developer + App Store Connect | iOS store release, iOS device signing, or signed/notarized macOS distribution | EAS can create/manage many signing assets and upload builds; Apple tools can notarize desktop builds | Paid membership, legal agreements, tax/banking, role grants, app record/metadata/privacy, TestFlight groups, final review/release decisions |
126
+ | Google Play Console | Android store release | EAS builds/submits after a service account is connected | Developer registration/payment, app creation, policy/data-safety/content declarations, service-account authorization, testing/release controls |
127
+ | Chrome Web Store | Public/trusted distribution of `extension` | Generated WXT verification and ZIP creation; Web Store APIs can automate later uploads after OAuth setup | Developer registration fee, contact verification, first listing, screenshots/privacy/permission declarations, reviewer instructions, final submission |
128
+ | Domain registrar | Custom production domain; mandatory for generated Worker custom domains | Registrar-specific APIs may exist but are not an Anhedral dependency | Search/purchase, registrant data, payment, renewal, transfer locks, nameserver/DNSSEC changes and destructive confirmations |
129
+ | Certificate authority | Public Windows desktop distribution | Signing can run in target-OS CI after credentials are installed | Organization validation, certificate purchase/issuance, hardware/cloud key custody, renewal |
130
+
131
+ RevenueCat's Test Store supports development purchases without Apple, Google, or
132
+ Stripe accounts. Native production purchases require the relevant app-store
133
+ accounts. The generated `billing` module supplies entitlement reconciliation,
134
+ webhook handling, Neon state, and Ably invalidation; it does not generate a web
135
+ checkout. Record that distinction in the project ledger before provisioning.
136
+
137
+ ## 4. Discover agent capabilities
31
138
 
32
139
  Inspect the environment before planning execution:
33
140
 
@@ -56,9 +163,18 @@ Recommended subagent sequence:
56
163
  If subagents are unavailable, perform the same phases serially. Their absence is
57
164
  not a blocker.
58
165
 
59
- ## 3. Generate the project
166
+ ## 5. Generate and verify the local project
60
167
 
61
- Prefer the skill-guided CLI path:
168
+ If the user wants the coding-agent workflow and the skill is not installed,
169
+ install it after pnpm is available:
170
+
171
+ ```sh
172
+ pnpm dlx skills add https://github.com/anhedral/anhedral-init --skill anhedral-init
173
+ ```
174
+
175
+ The user must install and authenticate their chosen compatible coding-agent
176
+ application separately. Anhedral also works without an agent. Prefer this
177
+ explicit CLI path for generation:
62
178
 
63
179
  ```sh
64
180
  pnpm dlx anhedral@latest new <project-name> <explicit-modules...> --toolchain stable
@@ -74,14 +190,35 @@ pnpm dlx anhedral@latest new acme desktop electron-updater --toolchain stable
74
190
 
75
191
  Then:
76
192
 
77
- 1. Read the generated `README.md` and `PRODUCTION.md` completely.
78
- 2. Read `anhedral.json` and confirm the resolved module closure with the user.
79
- 3. Copy only package-local environment examples that exist.
80
- 4. Run `pnpm dlx anhedral@latest doctor`, `pnpm verify`, and `pnpm build` before
81
- provisioning. Fix code-generation or build failures before creating cloud
82
- resources.
83
-
84
- ## 4. Authentication and secret boundaries
193
+ 1. Read `anhedral.json`, the root `package.json`, the generated `SKILL.md`,
194
+ `README.md`, `PRODUCTION.md`, and every selected package's `.env.example`.
195
+ Confirm the resolved module closure, account matrix, generated CLI scripts,
196
+ and environment inventory with the user.
197
+ 2. If modules were added to an existing project, remember that user-owned
198
+ `README.md` and `PRODUCTION.md` are not regenerated. Reconcile them against
199
+ `anhedral.json`, root scripts, managed `SKILL.md`, and environment examples
200
+ before treating them as current.
201
+ 3. Run `pnpm first-run`; it creates only missing package-local environment
202
+ files and never replaces existing configuration.
203
+ 4. Run `pnpm ready` and record the missing variable names by provider. Failure
204
+ is expected before provisioning; never fill placeholders merely to make it
205
+ pass.
206
+ 5. Run `pnpm typecheck` and `pnpm anhedral:doctor`. Run provider-independent
207
+ package checks that can succeed without credentials. Fix generator,
208
+ installation, or type failures before creating cloud resources.
209
+ 6. Create the organization-owned Git remote before Vercel import. With GitHub
210
+ CLI installed, authenticate with `gh auth login`, confirm the intended
211
+ account with `gh auth status`, then use `gh repo create` only after the user
212
+ chooses the owner and visibility. Review the initial commit and push.
213
+ 7. Provision development resources first using the next sections. Put real
214
+ values directly into uncommitted package-local environment files. Generate
215
+ and review the initial database migration, run `pnpm ready`, `pnpm verify`,
216
+ `pnpm build`, and only then start `pnpm dev`.
217
+ 8. Deploy and validate a preview before creating or connecting production
218
+ resources. Keep development, preview, and production identities, databases,
219
+ webhooks, keys, and billing data isolated.
220
+
221
+ ## 6. Authentication and secret boundaries
85
222
 
86
223
  Computer Use may navigate dashboards, fill non-secret settings, create approved
87
224
  resources, deploy, configure DNS, and verify results. Apply these hard stops:
@@ -105,31 +242,60 @@ resources, deploy, configure DNS, and verify results. Apply these hard stops:
105
242
  them. Treat any provider value marked secret as secret even if it appears in a
106
243
  browser page.
107
244
 
245
+ Use this control sequence whenever a CLI opens a browser:
246
+
247
+ 1. Run the selected generated login command and state which account/team it must
248
+ authorize.
249
+ 2. Yield control at the browser's sign-in, passkey, MFA, CAPTCHA, SSO, consent,
250
+ or device-code confirmation.
251
+ 3. After the user confirms completion, resume in the terminal and run the
252
+ provider's identity/status command or a read-only list operation.
253
+ 4. If the CLI cannot configure the remaining setting, open the exact dashboard
254
+ page with Computer Use, narrate the non-secret fields being changed, and
255
+ stop at any consequential final button.
256
+ 5. Return to the CLI or a read-only browser view to verify the saved state. A
257
+ successful click is not verification.
258
+
259
+ Classify every remaining action accurately:
260
+
261
+ - **CLI-covered:** safe to automate after authentication and approval.
262
+ - **API-capable but not generated:** use only with explicit approval, a pinned
263
+ client/version, and a redacting secret flow.
264
+ - **Computer Use:** dashboard setup with no suitable generated command.
265
+ - **User-only:** credentials, MFA, CAPTCHA, payments, legal agreements, secret
266
+ reveal/copy, and final production/store decisions.
267
+
108
268
  When the user finishes a secret step, ask only for confirmation such as
109
269
  "`CLERK_SECRET_KEY` is saved in `apps/api/.env`". Do not ask them to repeat the
110
270
  value. Mirror production secrets into Vercel or another deployment provider by
111
271
  having the user paste into that provider's protected environment-variable UI,
112
272
  or by using an approved secret-input flow that never prints the value.
113
273
 
114
- ## 5. Domain foundation
274
+ ## 7. Domain foundation
115
275
 
116
- Use Cloudflare as authoritative DNS and Vercel as the web/API runtime. A domain
117
- can remain registered at GoDaddy; changing nameservers is not a registrar
118
- transfer.
276
+ Use Cloudflare as authoritative DNS when `storage` or `electron-updater` is
277
+ selected because the generated Workers require custom domains in an active
278
+ Cloudflare zone. For web/API-only projects, retain the user's chosen DNS
279
+ provider and create only the records Vercel reports. A domain can remain with
280
+ its current registrar; changing nameservers is not a registrar transfer.
119
281
 
120
- 1. If the user has no domain, use Computer Use to search the approved registrar
121
- (usually GoDaddy), select the exact domain, and fill registration settings.
282
+ 1. If the user has no domain, use Computer Use to search the approved registrar,
283
+ select the exact domain, and fill registration settings.
122
284
  Stop before the paid purchase confirmation. Ask the user to review price,
123
285
  renewal terms, registrant, and organization ownership and submit it.
124
286
  2. Inventory existing DNS before changing nameservers. Preserve MX, TXT, SPF,
125
287
  DKIM, DMARC, verification, CAA, and application records. A domain with active
126
288
  email requires an explicit preservation review.
127
- 3. Add the domain as a Cloudflare zone. Stop for Cloudflare authentication. Copy
128
- the two assigned authoritative nameservers.
129
- 4. At the registrar, replace the authoritative nameservers with Cloudflare's
130
- exact values. Disable conflicting registrar DNSSEC/DS records first when
131
- required; wait until Cloudflare reports the zone **Active**, then enable
132
- DNSSEC in Cloudflare and publish the requested DS record at the registrar.
289
+ 3. When Cloudflare is required, add the domain as a Cloudflare zone. Stop for
290
+ Cloudflare authentication, account selection, plan choice, and any purchase.
291
+ Copy the two assigned authoritative nameservers.
292
+ 4. At the registrar, use Computer Use to replace the authoritative nameservers
293
+ with Cloudflare's exact values. Disable conflicting registrar DNSSEC/DS
294
+ records first when required; wait until Cloudflare reports the zone
295
+ **Active**, then enable DNSSEC in Cloudflare and publish the requested DS
296
+ record at the registrar. Nameserver and DS changes are destructive DNS
297
+ mutations: inventory and preserve email records first, obtain approval, and
298
+ verify authoritative answers afterward.
133
299
  5. Do not transfer registration unless the user separately requests it. A
134
300
  transfer changes billing/registrar ownership and may be subject to locks.
135
301
 
@@ -152,69 +318,260 @@ or R2. Configure `custom_domain: true` in the generated Wrangler file and deploy
152
318
  Cloudflare creates the DNS record and certificate. Remove any conflicting A,
153
319
  AAAA, or CNAME record before attaching the Worker hostname.
154
320
 
155
- ## 6. Provision selected providers
321
+ ## 8. Provision selected providers
322
+
323
+ For a newly generated project, use `PRODUCTION.md` together with
324
+ `anhedral.json`, root scripts, and package-local environment examples. After
325
+ `anhedral add`, the user-owned README and production guide may be stale; the
326
+ manifest, managed skill, scripts, and environment examples determine the actual
327
+ provider set.
156
328
 
157
- Follow the generated `PRODUCTION.md`; it is the selection-specific authority.
158
329
  Use this dependency order so downstream configuration receives real URLs and
159
330
  public identifiers:
160
331
 
161
- 1. **GitHub**: create or select the organization repository, review the initial
162
- diff, and push. Stop before changing repository visibility or overwriting an
163
- existing remote.
164
- 2. **Neon (`db`)**: create separate development/preview/production projects or
165
- branches. At connection-string generation, stop and have the user save the
166
- pooled URL as `DATABASE_URL` in `packages/db/.env`, `apps/api/.env` when
167
- required, and the protected Vercel API environment.
168
- 3. **Clerk (`auth`)**: create development and production instances and configure
169
- allowed origins, redirect URLs, and native/extension identifiers. Stop at key
170
- generation/reveal. Put the secret key only in server environments and the
171
- publishable key in each selected client's documented public variable.
172
- 4. **RevenueCat and Ably (`billing`)**: create projects/apps, entitlement,
173
- products, webhook URL/secret, and Ably API key. Stop at every secret creation.
174
- Keep RevenueCat secret and Ably API keys server-only; clients receive only
175
- documented public SDK keys or scoped Ably tokens.
176
- 5. **Cloudflare R2 (`storage`)**: run the generated login, bucket, CORS, Worker
177
- check, and Worker deploy commands. Keep R2 private and `r2.dev` disabled.
178
- Stop when Cloudflare requests authentication or before creating S3/API token
179
- secrets; have the user save them under the exact `R2_*` names. Attach
180
- `assets.<domain>` as the generated Worker Custom Domain.
181
- 6. **Vercel (`web`/`api`)**: link/import the root repository, select the generated
182
- Services configuration, populate Development/Preview/Production variables,
183
- deploy, then add `app.<domain>`. Inspect Vercel's exact DNS requirements and
184
- create them in Cloudflare DNS. Verify domain status and TLS after propagation.
185
- 7. **Electron updater (`electron-updater`)**: edit both generated
186
- `updates.example.com` values, set the matching HTTPS origin in
187
- `apps/desktop/electron-builder.env`, run
188
- `pnpm desktop:updates:first-provision` exactly once, and verify the private R2 binding plus
189
- Worker Custom Domain. Build/sign on each native OS and upload artifacts
190
- before channel metadata with the generated publish command.
191
- 8. **Expo/EAS and stores (`mobile`)**: create/link the EAS project, configure
192
- public build variables and signing credentials, and build internal releases.
193
- Stop at Apple/Google sign-in, credential, paid membership, agreement, and
194
- store-submission boundaries.
195
- 9. **Chrome Web Store (`extension`)**: configure a stable extension ID, test the
196
- generated ZIP as trusted/unlisted, and complete listing/privacy fields. Stop
197
- before developer registration payment and final store submission.
332
+ 1. **GitHub and source control**
333
+
334
+ - CLI: install GitHub CLI if selected, run `gh auth login`, stop at browser
335
+ authorization, and verify the intended identity with `gh auth status`.
336
+ Create the repository only after the user chooses the organization and
337
+ visibility. Review the remote before pushing; never overwrite an existing
338
+ remote or history.
339
+ - Computer Use: create or select the organization, authorize SSO/GitHub App
340
+ access, review repository visibility, configure protected environments and
341
+ branch rules, and enable required checks.
342
+ - User-only: organization billing, SSO/MFA, visibility policy, destructive
343
+ repository replacement, and final access grants.
344
+
345
+ 2. **Neon (`db`, including dependency-added database)**
346
+
347
+ - CLI: run `pnpm neon:login`; Neon opens an OAuth flow. After the user
348
+ authorizes it, run `pnpm neon:project:create --name <canonical-name>` for
349
+ the first environment. Use the pinned Neon CLI recorded in
350
+ `anhedral.json` for additional project/branch commands.
351
+ - Create isolated development, preview, and production projects or branches.
352
+ Prefer pooled connection strings for serverless Vercel traffic.
353
+ - Computer Use/user-only: account and organization creation, plan/billing,
354
+ backup/restore policy, IP restrictions, and the one-time safe placement of
355
+ each connection string. The user saves `DATABASE_URL` directly in
356
+ `packages/db/.env`, `apps/api/.env` when present, and protected deployment
357
+ environments without pasting it into chat.
358
+ - Local gate: run `pnpm db:generate`, inspect and commit the SQL and metadata,
359
+ run `pnpm verify:db`, then run `pnpm db:migrate` against the intended
360
+ development database. Never generate migrations in the deployment build.
361
+
362
+ 3. **Clerk (`auth`)**
363
+
364
+ - CLI/API-capable: the supplemental Clerk CLI can run `clerk auth login`,
365
+ `clerk apps create`, `clerk link`, `clerk config pull/patch`,
366
+ `clerk deploy`, `clerk deploy status`, and `clerk api`. Run it through a
367
+ recorded version and do not run `clerk init`, because Anhedral already
368
+ generated the SDK integration. Stop at its browser authorization.
369
+ - Create development and production instances. Put `CLERK_SECRET_KEY` only
370
+ in API/server environments. Put the publishable key into each selected
371
+ client's exact public variable.
372
+ - Computer Use: configure the root domain, DNS records, subdomain allowlist,
373
+ authorized parties, production OAuth applications, redirect URLs,
374
+ webhooks, email settings, native bundle/package identifiers, and extension
375
+ sync host/CRX ID when selected. Clerk workspace membership, billing,
376
+ analytics/logs, branding, and Protect settings remain dashboard work.
377
+ - User-only: social-provider OAuth consent/credentials, passkeys/MFA, secret
378
+ reveal/copy, and the final certificate/deployment confirmation. Verify the
379
+ production instance with `clerk deploy status` or a read-only dashboard
380
+ view and test on physical devices where applicable.
381
+
382
+ 4. **RevenueCat and Ably (`billing`/`native-subscriptions`)**
383
+
384
+ - Start development with RevenueCat's Test Store. It needs no Apple, Google,
385
+ or Stripe account. Create the project, Test Store products, entitlement
386
+ whose lookup key exactly matches `RC_ENTITLEMENT_ID`, current offering, and
387
+ packages. Add platform apps only for selected purchase surfaces.
388
+ - RevenueCat API v2 can automate projects, apps, products, entitlements,
389
+ offerings, package/product attachments, and webhook integrations after a
390
+ secret key exists. The normal blank-account path still requires dashboard
391
+ signup and safe secret-key creation. Put `RC_SECRET_API_KEY` server-side and
392
+ platform public keys only in their documented `EXPO_PUBLIC_RC_*` variables.
393
+ - Configure the RevenueCat webhook only after an HTTPS preview API exists:
394
+ `https://<preview-or-domain>/api/webhooks/revenuecat`. The user creates a
395
+ high-entropy authorization value and places the same value in RevenueCat's
396
+ Authorization header and the server's `RC_WEBHOOK_SECRET`; never expose it
397
+ to the agent.
398
+ - Supplemental Ably CLI: authenticate with `ably login`, verify the account,
399
+ create/select an app with `ably apps create`/`ably apps switch`, and create
400
+ the least-privilege server key with `ably auth keys create`. Because key
401
+ creation can print a credential, the user must run or complete that step
402
+ privately and save `ABLY_API_KEY` directly in server environments.
403
+ - The generated API issues scoped per-user Ably tokens; do not put a root
404
+ Ably key in clients. Set `CRON_SECRET` and verify the authenticated
405
+ realtime outbox flush schedule.
406
+ - Stripe is not required for Test Store or native store purchases. If the
407
+ user chooses RevenueCat Billing or manual Stripe web subscriptions, stop
408
+ and scope a separate implementation: account activation/KYC, products and
409
+ prices, Checkout/Customer Portal, webhook verification, tax, refunds, and
410
+ RevenueCat mapping are not generated by Anhedral.
411
+
412
+ 5. **Cloudflare zone and R2 (`storage`)**
413
+
414
+ - Computer Use/user-only prerequisite: create/select the Cloudflare account
415
+ and active DNS zone, complete R2 purchase/enablement if requested, preserve
416
+ existing DNS/email records, and finish nameserver/DNSSEC changes. Wrangler
417
+ cannot replace registrar payment, registrant, or account-recovery work.
418
+ - CLI: run `pnpm r2:login`, stop at OAuth, verify the account, then run
419
+ `pnpm r2:bucket:create`, `pnpm r2:cors:list`, edit the complete user-owned
420
+ CORS template, and run `pnpm r2:cors:set`. The set operation replaces the
421
+ entire policy, so retain all approved origins.
422
+ - Computer Use/user-only secret step: in R2, create an Object Read & Write S3
423
+ token scoped to the selected bucket. The user clicks the final create
424
+ button and privately stores the one-time Access Key ID and Secret Access
425
+ Key under the exact `R2_*` variables. R2 must be enabled before these
426
+ credentials can be generated.
427
+ - Replace `assets.example.com` in the generated Wrangler file with the real
428
+ hostname. Run `pnpm assets:proxy:check` and
429
+ `pnpm assets:proxy:deploy`; Wrangler creates the Worker binding, managed
430
+ DNS record, TLS certificate, and Worker Custom Domain.
431
+ - Lifecycle rules are CLI-capable but currently have no generated root
432
+ wrapper. Using the exact Wrangler version in `anhedral.json`, add and list
433
+ a rule for `storage/staging/` whose expiration exceeds the application
434
+ cleanup grace period. Treat any lifecycle replacement as destructive and
435
+ preview/list existing rules first.
436
+
437
+ ```sh
438
+ pnpm dlx wrangler@<recorded-version> r2 bucket lifecycle list <bucket>
439
+ pnpm dlx wrangler@<recorded-version> r2 bucket lifecycle add <bucket> staging-cleanup storage/staging/ --expire-days 1
440
+ pnpm dlx wrangler@<recorded-version> r2 bucket lifecycle list <bucket>
441
+ ```
442
+
443
+ 6. **Vercel (`web`/`api`)**
444
+
445
+ - CLI: run `pnpm deploy:vercel:link`; stop at OAuth/device authorization and
446
+ explicitly confirm the team/project. Generated commands then cover preview,
447
+ production, inspection, and domain inspection.
448
+ - Computer Use: import/connect the GitHub repository for automatic preview
449
+ deployments, keep the repository root, and select the **Services**
450
+ framework preset. A `services` block in `vercel.json` is not sufficient
451
+ unless the project setting is also Services.
452
+ - Add Development, Preview, and Production environment values in protected
453
+ fields. Vercel CLI supports environment management, but use an interactive
454
+ secret-input flow or dashboard so values never appear in agent output.
455
+ Keep server-only values out of public-prefixed variables.
456
+ - Deploy Preview first. Verify `/api/health`, `/api/ready`, web routing,
457
+ authentication, migrations, scheduled endpoints, and provider callbacks.
458
+ Add `app.<domain>` only after preview is healthy, inspect the exact
459
+ A/CNAME/TXT requirements, create those records at the authoritative DNS
460
+ provider, and verify DNS plus TLS. Keep Vercel records DNS-only when
461
+ Cloudflare is authoritative.
462
+ - User-only: team billing, GitHub OAuth/SSO consent, production promotion,
463
+ domain-conflict takeover, and destructive environment replacement.
464
+
465
+ 7. **Complete URL-dependent provider configuration**
466
+
467
+ After the preview URL and production hostname exist, return to Clerk,
468
+ RevenueCat, CORS, OAuth providers, and store consoles. Replace temporary
469
+ callback/origin values with exact HTTPS URLs, configure separate preview and
470
+ production webhooks, redeploy public-key changes, and verify delivery logs.
471
+
472
+ 8. **Electron updater (`electron-updater`)**
473
+
474
+ - Replace both `updates.example.com` values, set the identical HTTPS origin
475
+ in `apps/desktop/electron-builder.env`, run the generated Cloudflare login,
476
+ and run `pnpm desktop:updates:first-provision` exactly once. Later deploys
477
+ use `pnpm desktop:updates:worker:deploy`.
478
+ - Wrangler covers the private bucket, Worker binding, custom domain, DNS, and
479
+ TLS after the Cloudflare zone exists. Cloudflare account/R2 activation and
480
+ registrar work retain the same Computer Use/user stops described above.
481
+ - Build and sign on each target OS. Apple Developer enrollment, notarization
482
+ agreements/credentials, Windows certificate purchase and organization
483
+ validation, hardware/cloud key custody, and CI secret entry require the
484
+ user or provider UI.
485
+ - Upload signed immutable installers and blockmaps before mutable channel
486
+ metadata with `pnpm desktop:updates:publish`. Test upgrade and rollback from
487
+ a previously installed signed release.
488
+
489
+ 9. **Expo/EAS and stores (`mobile`)**
490
+
491
+ - CLI: run `pnpm mobile:eas:login`, stop for Expo authentication, verify the
492
+ account/team, then run `pnpm mobile:eas:init`. Commit the EAS project ID and
493
+ configuration. Build internal iOS/Android artifacts with the generated
494
+ preview scripts before store builds.
495
+ - EAS can generate/manage signing credentials and cloud builds. The user must
496
+ participate in Apple/Google credential prompts; never relay passwords,
497
+ MFA, private keys, service-account JSON, or signing certificates through
498
+ chat.
499
+ - Computer Use/user-only for Apple: enroll in the paid Developer Program,
500
+ accept legal agreements, configure tax/banking and roles, create the App
501
+ Store Connect app record and bundle ID, complete metadata/privacy/export
502
+ compliance, manage TestFlight groups, and make final review/release choices.
503
+ - Computer Use/user-only for Google: register/pay for Play Console, create the
504
+ app/package, complete policy/data-safety/content declarations, create and
505
+ authorize the service account, configure testers/tracks, and make final
506
+ rollout choices. EAS CLI can upload the service-account key privately and
507
+ submit builds; use the current Expo guidance for whether the first release
508
+ still needs a console step.
509
+ - Run generated production build and submit commands only after internal
510
+ device testing. TestFlight processing/review and Play review/rollout are
511
+ external asynchronous gates, not successful CLI completion.
512
+
513
+ 10. **Chrome Web Store (`extension`)**
514
+
515
+ - CLI: run `pnpm verify:extension` and `pnpm extension:zip`, then load the
516
+ unpacked production output in Chrome and test permissions, auth, API calls,
517
+ service-worker wakeup, and sign-out.
518
+ - Computer Use/user-only: register the developer account, verify the contact
519
+ email, accept the agreement, pay the fee, create the first item, upload the
520
+ ZIP, fill listing/screenshots/category/regions, justify permissions,
521
+ complete privacy/limited-use declarations, provide reviewer instructions,
522
+ and submit.
523
+ - Publish first to trusted testers or unlisted visibility. Capture the stable
524
+ store-assigned CRX ID, reconcile Clerk and backend allowlists, rebuild if
525
+ needed, and test the store-installed artifact before production review.
526
+
527
+ 11. **Desktop distribution without updater**
528
+
529
+ Build platform-specific artifacts on macOS, Windows, and Linux runners.
530
+ Computer Use/user involvement remains necessary for Apple Developer and
531
+ notarization enrollment, Windows certificate purchase/validation, OS
532
+ trust prompts, and distribution-channel listing or final release. An
533
+ unsigned local package is not equivalent to a production-ready desktop
534
+ release.
198
535
 
199
536
  Create strong `CRON_SECRET` and webhook secrets through a password manager or a
200
537
  local non-logging generator. The user places them directly into server and
201
538
  deployment environments.
202
539
 
203
- ## 7. Verify and hand off
204
-
205
- After configuration:
206
-
207
- 1. Run `pnpm verify`, `pnpm build`, and `anhedral doctor`.
208
- 2. Verify Vercel deployment health, custom-domain status, DNS answers, and TLS.
209
- 3. Verify every selected Worker accepts its intended GET/HEAD behavior, rejects
210
- forbidden methods/hosts, and cannot expose or list the private bucket.
211
- 4. Verify database migration status, auth redirect/sign-out, billing webhook and
212
- entitlement refresh, storage upload/read policy, and scheduled jobs as
213
- selected.
214
- 5. Record resource names, URLs, provider teams, and remaining manual approvals.
215
- Record no secrets.
216
- 6. Stop before production/store release and give the user a concise checklist of
217
- the exact final buttons or approvals still required.
540
+ ## 9. Verify and hand off
541
+
542
+ Track these end-to-end completion gates:
543
+
544
+ 1. **Workstation ready:** supported Node.js, exact pnpm, npm, Git, browser, and
545
+ only the selected native tools are present; real Git identity is confirmed.
546
+ 2. **Generated safely:** modules and dependency closure are confirmed,
547
+ installation completed, `anhedral.json` is healthy, environment files are
548
+ uncommitted, and no provider was created under the wrong personal/team
549
+ account.
550
+ 3. **Development ready:** development provider values are present, `pnpm ready`
551
+ succeeds, reviewed database migrations are committed/applied,
552
+ `pnpm verify`, `pnpm build`, and `pnpm anhedral:doctor` succeed, and the
553
+ generated starter feature works end to end through a signed-in user.
554
+ 4. **Preview ready:** Git-triggered or manual Vercel preview is healthy;
555
+ `/api/health` and `/api/ready` pass; preview auth, database, webhooks,
556
+ scheduled jobs, CORS, Workers, and selected client API URLs use isolated
557
+ preview resources.
558
+ 5. **Production infrastructure ready:** provider teams and billing owners are
559
+ correct, production secrets are protected, migration state is current,
560
+ custom-domain DNS resolves, TLS is issued, Clerk certificates/auth work,
561
+ Workers have correct bindings/domains, and logs show successful health and
562
+ callback probes.
563
+ 6. **Distribution ready:** internal EAS/TestFlight/Play builds, trusted Chrome
564
+ Web Store artifact, and signed desktop installers/updater are tested as
565
+ selected. Store metadata, privacy declarations, reviewer credentials, tax
566
+ and legal agreements, signing/notarization, rollback, and staged rollout are
567
+ complete.
568
+ 7. **Handoff ready:** record resource names, public IDs, URLs, teams, owners,
569
+ renewal/recovery responsibilities, runbooks, and remaining external review
570
+ statuses. Record no secrets. Give the user the exact final buttons or
571
+ approvals still pending.
218
572
 
219
573
  Do not claim completion while a dashboard is merely open, DNS is still pending,
220
574
  TLS is unissued, an environment value is absent, or verification has not run.
575
+ Likewise, a successful CLI upload is not an approved store release, a Vercel
576
+ deployment URL is not a healthy application, and a generated project is not a
577
+ provisioned product.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anhedral",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Generate a complete, readable TypeScript product stack with Next.js, Expo, Fastify, Neon, Drizzle, Clerk, R2, Electron updates, WXT, and Vercel.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,10 +18,12 @@
18
18
  "bin",
19
19
  "dist",
20
20
  "docs/conventions.md",
21
+ "docs/engineering-principles.md",
21
22
  "assets/anhedral-cli-init.svg",
22
23
  "assets/images/svg/ably-symbol-color.svg",
23
24
  "assets/images/svg/logo-white-subtract.svg",
24
25
  "docs/master-stack-map.md",
26
+ "docs/NORTHSTAR.md",
25
27
  "docs/output-tree-contract.md",
26
28
  "docs/references",
27
29
  "scripts/render-master-stack-map.mjs",