@aotter/mantle 0.1.2-alpha.5 → 0.1.2-rc.1

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 (111) hide show
  1. package/README.md +11 -6
  2. package/dist/cli/generate.d.ts +9 -0
  3. package/dist/cli/generate.d.ts.map +1 -1
  4. package/dist/cli/generate.js +40 -1
  5. package/dist/cli/generate.js.map +1 -1
  6. package/dist/cli/main.d.ts +1 -1
  7. package/dist/cli/main.d.ts.map +1 -1
  8. package/dist/cli/main.js +37 -9
  9. package/dist/cli/main.js.map +1 -1
  10. package/docs/adapter-guide.md +1 -1
  11. package/docs/adr/0011-adapter-port-spec.md +4 -2
  12. package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +21 -0
  13. package/docs/adr/README.md +1 -1
  14. package/docs/adr/adr-lite-845-frontend-client.md +38 -0
  15. package/docs/agent-prompts.md +92 -0
  16. package/docs/api-mcp-authorization.md +1 -1
  17. package/docs/auth-hosting-model.md +12 -13
  18. package/docs/examples/README.md +22 -0
  19. package/docs/examples/builtin-commerce.md +269 -0
  20. package/docs/examples/builtin-intake.md +143 -0
  21. package/docs/examples/builtin-legal-documents.md +189 -0
  22. package/docs/examples/builtin-procurement.md +241 -0
  23. package/docs/examples/builtin-publication.md +241 -0
  24. package/docs/examples/builtin-reservation.md +149 -0
  25. package/docs/examples/cf-primitives-commerce-inventory.md +809 -0
  26. package/docs/examples/cf-primitives-guarded-api.md +429 -0
  27. package/docs/examples/cf-primitives-intake-hooks.md +319 -0
  28. package/docs/examples/host-chatgpt-sites/.openai/hosting.json +1 -0
  29. package/docs/examples/host-chatgpt-sites/README.md +39 -0
  30. package/docs/examples/host-chatgpt-sites/drizzle/0000_sites_users.sql +8 -0
  31. package/docs/examples/host-chatgpt-sites/drizzle/0001_mantle.sql +294 -0
  32. package/docs/examples/host-chatgpt-sites/drizzle/0002_article_cover.sql +5 -0
  33. package/docs/examples/host-chatgpt-sites/drizzle/meta/_journal.json +1 -0
  34. package/docs/examples/host-chatgpt-sites/manifests/site.yaml +27 -0
  35. package/docs/examples/host-chatgpt-sites/package-lock.json +7088 -0
  36. package/docs/examples/host-chatgpt-sites/package.json +1 -0
  37. package/docs/examples/host-chatgpt-sites/public/site.css +1 -0
  38. package/docs/examples/host-chatgpt-sites/scripts/build.mjs +12 -0
  39. package/docs/examples/host-chatgpt-sites/scripts/check.mjs +99 -0
  40. package/docs/examples/host-chatgpt-sites/scripts/migration.mjs +9 -0
  41. package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +63 -0
  42. package/docs/examples/host-chatgpt-sites/src/index.ts +46 -0
  43. package/docs/examples/host-chatgpt-sites/src/mcp.ts +49 -0
  44. package/docs/examples/host-chatgpt-sites/src/media.ts +109 -0
  45. package/docs/examples/host-chatgpt-sites/src/r2-lab.ts +38 -0
  46. package/docs/examples/host-chatgpt-sites/src/storage-fingerprint.json +1 -0
  47. package/docs/examples/host-chatgpt-sites/src/web.ts +35 -0
  48. package/docs/examples/host-chatgpt-sites/tsconfig.json +1 -0
  49. package/docs/examples/host-chatgpt-sites/wrangler.jsonc +10 -0
  50. package/docs/examples/host-local-admin-otp/.dev.vars.example +3 -0
  51. package/docs/examples/host-local-admin-otp/README.md +71 -0
  52. package/docs/examples/host-local-admin-otp/ensure-dev-vars.mjs +5 -0
  53. package/docs/examples/host-local-admin-otp/package.json +29 -0
  54. package/docs/examples/host-local-admin-otp/public/.gitkeep +1 -0
  55. package/docs/examples/host-local-admin-otp/smoke.mjs +141 -0
  56. package/docs/examples/host-local-admin-otp/src/index.ts +54 -0
  57. package/docs/examples/host-local-admin-otp/wrangler.jsonc +23 -0
  58. package/docs/examples/{minimal-worker → host-minimal-worker}/README.md +8 -5
  59. package/docs/examples/host-minimal-worker/manifests/site.yaml +25 -0
  60. package/docs/examples/{minimal-worker → host-minimal-worker}/package.json +3 -3
  61. package/docs/examples/host-minimal-worker/tsconfig.json +17 -0
  62. package/docs/handbook/cloudflare/authentication.md +79 -10
  63. package/docs/handbook/cloudflare/bindings.md +9 -7
  64. package/docs/handbook/cloudflare/chatgpt-sites.md +29 -0
  65. package/docs/handbook/cloudflare/conventional-worker.md +3 -3
  66. package/docs/handbook/cloudflare/deferred-hooks-queues.md +0 -1
  67. package/docs/handbook/cloudflare/deploy-and-operate.md +14 -20
  68. package/docs/handbook/cloudflare/media-r2.md +2 -2
  69. package/docs/handbook/cloudflare/public-web.md +1 -1
  70. package/docs/handbook/cloudflare/site-chrome.md +75 -0
  71. package/docs/handbook/concepts/authorization.md +2 -2
  72. package/docs/handbook/concepts/four-atoms.md +2 -2
  73. package/docs/handbook/concepts/lifecycle-and-locales.md +1 -1
  74. package/docs/handbook/concepts/mcp-and-agents.md +1 -1
  75. package/docs/handbook/concepts/procedures-and-triggers.md +1 -1
  76. package/docs/handbook/concepts/views.md +2 -2
  77. package/docs/handbook/examples/commerce-transaction.md +4 -806
  78. package/docs/handbook/examples/commerce.md +11 -0
  79. package/docs/handbook/examples/guarded-api.md +3 -420
  80. package/docs/handbook/examples/hub.md +10 -0
  81. package/docs/handbook/examples/intake-form.md +6 -313
  82. package/docs/handbook/examples/intake-hooks.md +11 -0
  83. package/docs/handbook/examples/legal-documents.md +3 -211
  84. package/docs/handbook/examples/procurement-approvals.md +3 -233
  85. package/docs/handbook/examples/publication.md +3 -233
  86. package/docs/handbook/examples/reservation.md +3 -213
  87. package/docs/handbook/navigation.json +17 -2
  88. package/docs/handbook/reference/authorization.md +1 -1
  89. package/docs/handbook/reference/procedure.md +2 -2
  90. package/docs/handbook/reference/schema.md +3 -3
  91. package/docs/handbook/reference/site-config.md +5 -16
  92. package/docs/handbook/reference/surface.md +3 -7
  93. package/docs/handbook/sites/equipment-checkout.md +231 -0
  94. package/docs/handbook/sites/host-reference.md +116 -0
  95. package/docs/handbook/sites/index.md +117 -0
  96. package/docs/handbook/start/project-and-cli.md +22 -14
  97. package/docs/handbook/start/quickstart-admin.md +239 -0
  98. package/docs/handbook/start/quickstart-worker.md +21 -22
  99. package/docs/migration-0.1.2.md +26 -0
  100. package/docs/release-process.md +90 -6
  101. package/docs/sealed-pipeline-ownership.md +1 -1
  102. package/docs/transaction-patterns.md +2 -2
  103. package/package.json +15 -15
  104. package/skills/develop/SKILL.md +32 -23
  105. package/skills/install/SKILL.md +34 -11
  106. package/skills/provision/SKILL.md +19 -5
  107. /package/docs/examples/{minimal-worker → host-local-admin-otp}/manifests/site.yaml +0 -0
  108. /package/docs/examples/{minimal-worker → host-local-admin-otp}/tsconfig.json +0 -0
  109. /package/docs/examples/{minimal-worker → host-minimal-worker}/smoke.mjs +0 -0
  110. /package/docs/examples/{minimal-worker → host-minimal-worker}/src/index.ts +0 -0
  111. /package/docs/examples/{minimal-worker → host-minimal-worker}/wrangler.jsonc +0 -0
@@ -17,12 +17,11 @@ docs govern runtime/API behavior.
17
17
  ## First Read
18
18
 
19
19
  1. `package.json` for the installed `@aotter/mantle*` versions.
20
- 2. `manifests/site.yaml`, the active adapter config, and `src/auth.ts` when present. If the project is older, check `src/mantleConfig.ts`.
21
- 3. The active `.mantle/overlays/<type>/seed.json`, when present; generated
22
- homepages commonly import visible copy and form structure from it.
23
- 4. Optional local context: `.mantle/launch-state.json`, `.mantle/handoff.md`,
24
- `.mantle/plugins.json`, `.mantle/plugins.lock.json`, and `.mantle/recipes/`.
25
- 5. Installed Core docs in `node_modules/@aotter/mantle/docs/`.
20
+ 2. `manifests/site.yaml`, the active adapter config (`wrangler.jsonc`), and
21
+ the Worker entry. Custom Auth lives in that entry's `createAuth` factory.
22
+ 3. Optional local context: `.mantle/plugins.json`, `.mantle/plugins.lock.json`,
23
+ and `.mantle/recipes/`. Legacy launch/handoff files are context only.
24
+ 4. Installed Core docs in `node_modules/@aotter/mantle/docs/`.
26
25
 
27
26
  If `node_modules/` is missing, run `pnpm install --frozen-lockfile` before
28
27
  falling back to remote docs. Remote docs must use a tag matching the installed
@@ -30,9 +29,14 @@ version; never use `develop` branch docs for a versioned consumer project.
30
29
 
31
30
  ## Existing Examples
32
31
 
33
- Read installed `docs/handbook/start/project-and-cli.md`, `docs/examples/minimal-worker/`
34
- and `docs/handbook/examples/commerce-transaction.md` before inventing a pattern. The reference
35
- consumer is test/documentation, not a Starter or a fixed application shape.
32
+ Read installed `docs/handbook/start/project-and-cli.md` and
33
+ `docs/examples/README.md`. Use `docs/examples/host-minimal-worker/` for Spec +
34
+ adapter without Admin. Read `docs/examples/host-local-admin-otp/` only when the
35
+ project already has Admin or the human asked for Dev UI — that path is opt-in.
36
+ Ingest only `docs/examples/builtin-*.md` Manifests as grammar for new domains.
37
+ Read `docs/examples/cf-primitives-*.md` before inventing Durable Object, Queue,
38
+ cron, or `ref` handler patterns.
39
+ References are test/documentation, not a Starter or a fixed application shape.
36
40
 
37
41
  Public rendering is opt-in consumer wiring: `mountPublicRoutes`, a
38
42
  `TemplateRegistry`, and a matching `publicPathResolver` must agree on the
@@ -53,7 +57,8 @@ pnpm validate
53
57
  ```
54
58
 
55
59
  This CLI validates and derives artifacts from application-authored manifests.
56
- It does not create projects, business schemas or a visitor homepage.
60
+ It does not create projects, business schemas or a visitor homepage. There is
61
+ no `mantle create` / `mantle update` happy path.
57
62
 
58
63
  ## Core Model
59
64
 
@@ -72,11 +77,10 @@ the atoms cannot express the behavior.
72
77
 
73
78
  ## Content Edits
74
79
 
75
- - If a legacy homepage imports a repo seed, edit it for local/static copy.
76
- Otherwise follow the actual frontend content source. Use Admin or Staff MCP
77
- for runtime-backed content.
80
+ - Follow the actual frontend content source. Use Admin or Staff MCP for
81
+ runtime-backed content. Do not invent an overlay/seed homepage.
78
82
  - For a new submitted field, update the stored `Schema` and the public
79
- `Procedure.spec.input` before the seed/form. Keep public mutation inputs
83
+ `Procedure.spec.input` before any form UI. Keep public mutation inputs
80
84
  `additionalProperties: false`; otherwise JSON Schema's default may strip an
81
85
  undeclared field while returning success.
82
86
  - Use `lifecycle: operational` for submissions, inquiries, orders, and other
@@ -134,13 +138,20 @@ teaching the project Mantle internals.
134
138
 
135
139
  ## Auth Composition
136
140
 
137
- Conventional Cloudflare projects declare `MANTLE_AUTH_MODE=hosted` or
138
- `self-managed`; Core owns that standard Auth composition and rejects partial
139
- or mixed bindings. Preserve the explicit mode recorded in Worker config
140
- and any legacy launch state, keep provider secrets out of source, and do not infer a mode
141
- from whichever credentials happen to be present. A repo with an explicit
142
- `createMantleWorker({ auth })` override owns that custom composition; follow
143
- its handoff instead of replacing it with the conventional factory.
141
+ Admin is opt-in. A project without `@aotter/mantle-admin-ui` is complete.
142
+ When Admin is installed, `createMantleWorker({ auth })` with `email-otp`
143
+ and `ConsoleEmailSender` is the local human path (OTP in wrangler logs).
144
+ That override owns Auth construction; Core still owns `/admin` and
145
+ `/api/auth/*`. Admin also requires wrangler `assets.directory=./public`
146
+ and an `ASSETS` binding. A white screen at `/admin` with HTML 200 and
147
+ `/_mantle/admin/assets/*` 404 is a missing assets binding, not a missing
148
+ frontend build.
149
+
150
+ Conventional Cloudflare projects that do not replace Auth declare
151
+ `MANTLE_AUTH_MODE=hosted` or `self-managed`; Core owns that standard
152
+ composition and rejects partial or mixed bindings. Preserve the explicit
153
+ mode recorded in Worker config, keep provider secrets out of source, and
154
+ do not infer a mode from whichever credentials happen to be present.
144
155
 
145
156
  ## Performance Loop
146
157
 
@@ -213,8 +224,6 @@ cache.
213
224
 
214
225
  - Keep content models in the configured manifest directory; its immediate
215
226
  `.yaml` and `.yml` files are loaded together.
216
- - Use a generated overlay `seed.json` for the auth-free local first page when
217
- it is already imported by `src/web/content/*`.
218
227
  - Add TypeScript only for handlers, rendering, adapter wiring, or real behavior.
219
228
  - Do not write directly to D1, KV, Postgres, or object storage for content
220
229
  authoring. Use runtime use cases, admin APIs, or Staff MCP.
@@ -21,18 +21,37 @@ turn `generate` into implicit scaffolding.
21
21
  1. Determine the actual host and required surfaces from the request. Reuse an
22
22
  existing application when available; otherwise work in its own directory.
23
23
  Do not assume Cloudflare, public HTML or Admin is required. Check Node 22+
24
- and pnpm 9+ for these SDK examples.
24
+ and pnpm 9+ for these SDK examples. A ChatGPT Site is not a conventional
25
+ Cloudflare Worker deployment; use the installed
26
+ `docs/handbook/sites/index.md` integration guide and
27
+ `docs/examples/host-chatgpt-sites/` runnable reference when selected. Follow
28
+ its SDK availability instructions; while support is unreleased, use its
29
+ packed-checkout workflow rather than an older registry package.
25
30
  2. Choose the requested exact SDK version, or resolve the intended release
26
31
  channel once. Pin all selected `@aotter/mantle*` dependencies to that same
27
32
  version. Install only the adapter/optional packages the application needs.
28
33
  If a global scope registry overrides public npmjs, use a project-owned
29
34
  `.npmrc` with `@aotter:registry=https://registry.npmjs.org/`.
30
- 3. Read the installed `node_modules/@aotter/mantle/docs/handbook/start/project-and-cli.md`.
31
- The version-matched `docs/examples/minimal-worker/` is a runnable Cloudflare
32
- reference, not a template to install wholesale. Other hosts use the embedded
33
- adapter guides. Author package scripts, manifests, entry and configuration
34
- for the user's requirements. No default notes model, home page, icon,
35
- launch metadata or frontend is required.
35
+ 3. Interview the human for host and required surfaces. Do not assume Admin,
36
+ public HTML or Cloudflare. Scale:
37
+ - Spec + generate / embed Runtime — `docs/handbook/start/project-and-cli.md`.
38
+ - Adapter without Admin — `docs/examples/host-minimal-worker/`.
39
+ - Opt-in Admin / Dev UI — only when a human needs a console: interview
40
+ the bootstrap owner email, then `docs/examples/host-local-admin-otp/`
41
+ (`pnpm install && pnpm generate && pnpm dev`, `/admin/sign-in`, OTP
42
+ in wrangler logs). Admin needs `@aotter/mantle-admin`,
43
+ `@aotter/mantle-admin-ui`, wrangler `ASSETS` on `./public`, and
44
+ `createAuth` email-otp + `ConsoleEmailSender`. Do not Vite-build Admin.
45
+ - ChatGPT Sites with Admin/D1/R2 — follow `host-chatgpt-sites/`, not the
46
+ email-OTP Worker example. Preserve its Sites-owned identity ingress and
47
+ hosting manifest; author the user's Schema/View/Procedure/Trigger, then
48
+ review migrations, media policy and the local/production smoke gates.
49
+ Browser Admin WebMCP and Sites-session `/api/mcp/staff` do not enable remote staff OAuth MCP.
50
+ - Grammar — `docs/examples/README.md`; copy `builtin-*` Manifests only.
51
+ None of these is a template to install wholesale. Other hosts use the
52
+ embedded adapter guides. Author package scripts, manifests, entry and
53
+ configuration for the user's requirements. No default notes model, home
54
+ page, icon, launch metadata or visitor frontend is required.
36
55
  4. Compile and verify using the application's commands. The fundamental CLI
37
56
  sequence is:
38
57
 
@@ -44,10 +63,14 @@ pnpm exec mantle skills
44
63
  pnpm exec mantle skills --check
45
64
  ```
46
65
 
47
- Run the project's TypeScript check and start its actual local server. Probe a
48
- route the application declares; an API-only project may correctly return 404
49
- at `/`. Auth routes may return `503 setup_incomplete` until the selected auth
50
- provider is configured. Do not introduce an auth bypass to make smoke pass.
66
+ Run the project's TypeScript check and start its actual local server. Probe
67
+ a route the application declares. An API-only or adapter-only project may
68
+ correctly return 404 at `/` and have no Admin. When Admin was requested,
69
+ probe `/admin/sign-in` and a `/_mantle/admin/assets/*` URL — both must be
70
+ 200. A white screen is an assets 404, not a missing frontend build.
71
+ Conventional Auth routes may return `503 setup_incomplete` until that mode
72
+ is configured; the local OTP path replaces construction instead. Do not
73
+ introduce an auth bypass to make smoke pass.
51
74
 
52
75
  Commit the resolved lockfile in the application's normal workflow; subsequent
53
76
  installs use `pnpm install --frozen-lockfile`. Do not initialize/push a remote,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: provision
3
- description: Ship a local or Mantle landing-generated project to Cloudflare and finish production auth. Use when a Mantle project is ready for GitHub, Cloudflare deployment, self-hosted GitHub OAuth, paid Mantle hosted auth verification, production smoke testing, or operator handoff.
3
+ description: Ship a Mantle project through its selected host, routing ChatGPT Sites to its integration guide and conventional Cloudflare Workers to production auth and provisioning.
4
4
  metadata:
5
5
  source: "@aotter/mantle"
6
6
  sourcePath: skills/provision/SKILL.md
@@ -12,7 +12,11 @@ metadata:
12
12
  # Provision a Mantle Project
13
13
 
14
14
  Local cold start deliberately stops before this skill. Provision only after the
15
- user asks to create remote resources or ship production.
15
+ user asks to create remote resources or ship production. This flow is for
16
+ consumer-owned Cloudflare Workers. For a ChatGPT Site, use the installed
17
+ `docs/handbook/sites/index.md` integration guide and the Sites host's
18
+ publish workflow; do not run `wrangler deploy` or require R2 S3 credentials
19
+ merely because Sites exposes an R2 binding.
16
20
 
17
21
  ## Source of Truth
18
22
 
@@ -59,8 +63,8 @@ directly; boot syncs its canonical origin from `PUBLIC_ORIGIN`.
59
63
 
60
64
  ## Choose Auth
61
65
 
62
- - **Self-hosted — free:** configure the owner's per-site GitHub OAuth App and
63
- Worker secrets using the steps below.
66
+ - **Self-hosted email OTP:** use the application's production transactional-email sender. Replace `ConsoleEmailSender`; never deploy it.
67
+ - **Self-hosted GitHub OAuth — free fallback:** use when the application has no email provider. Configure the owner's per-site GitHub OAuth App and Worker secrets using the steps below.
64
68
  - **Mantle hosted auth — paid:** use only when the landing handoff records a
65
69
  hosted allocation and client configuration. Mantle Platform operates the
66
70
  identity provider; do not ask the user for a per-site GitHub OAuth App.
@@ -74,7 +78,17 @@ current Mantle landing flow explicitly supplies that handoff.
74
78
  For the exact boundary, read
75
79
  `node_modules/@aotter/mantle/docs/auth-hosting-model.md`.
76
80
 
77
- ## Self-hosted Auth
81
+ ## Self-hosted email OTP
82
+
83
+ Keep the application's custom `createAuth()` factory, replace
84
+ `ConsoleEmailSender` with its production `EmailSender`, and retain
85
+ `bootstrapOwner: { match: "email", value: <owner email> }`. Store sender
86
+ credentials and `BETTER_AUTH_SECRET` as Worker secrets, put `PUBLIC_ORIGIN` in
87
+ non-secret vars, deploy, then verify that the owner receives an OTP at
88
+ `/admin/sign-in`. If there is no production email provider, use GitHub OAuth
89
+ below instead of deploying console delivery.
90
+
91
+ ## Self-hosted GitHub OAuth
78
92
 
79
93
  1. Ask the user to create a GitHub OAuth App:
80
94