@aotter/mantle 0.1.4 → 0.1.5-alpha.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 (67) hide show
  1. package/README.md +16 -16
  2. package/dist/cli/generate-cloudflare.d.ts +7 -0
  3. package/dist/cli/generate-cloudflare.d.ts.map +1 -0
  4. package/dist/cli/generate-cloudflare.js +123 -0
  5. package/dist/cli/generate-cloudflare.js.map +1 -0
  6. package/dist/cli/generate-project.d.ts +25 -0
  7. package/dist/cli/generate-project.d.ts.map +1 -0
  8. package/dist/cli/generate-project.js +282 -0
  9. package/dist/cli/generate-project.js.map +1 -0
  10. package/dist/cli/generate-sites.d.ts +8 -0
  11. package/dist/cli/generate-sites.d.ts.map +1 -0
  12. package/dist/cli/generate-sites.js +273 -0
  13. package/dist/cli/generate-sites.js.map +1 -0
  14. package/dist/cli/generate.d.ts.map +1 -1
  15. package/dist/cli/generate.js +121 -10
  16. package/dist/cli/generate.js.map +1 -1
  17. package/dist/cli/main.d.ts +1 -1
  18. package/dist/cli/main.d.ts.map +1 -1
  19. package/dist/cli/main.js +10 -10
  20. package/docs/adr/0021-retire-starter-scaffolding.md +1 -1
  21. package/docs/adr/0026-progressive-generate.md +36 -0
  22. package/docs/adr/0027-scheduled-procedure-triggers.md +31 -0
  23. package/docs/adr/0028-schema-ttl-expiry.md +33 -0
  24. package/docs/adr/README.md +5 -2
  25. package/docs/agent-prompts.md +40 -78
  26. package/docs/examples/host-chatgpt-sites/README.md +1 -1
  27. package/docs/examples/host-chatgpt-sites/drizzle/0004_mantle.sql +10 -0
  28. package/docs/examples/host-chatgpt-sites/drizzle/0005_mantle.sql +24 -0
  29. package/docs/examples/host-chatgpt-sites/drizzle/meta/_journal.json +1 -1
  30. package/docs/examples/host-chatgpt-sites/drizzle/meta/mantle-state.json +60 -0
  31. package/docs/examples/host-chatgpt-sites/package.json +1 -1
  32. package/docs/examples/host-chatgpt-sites/scripts/migration.mjs +42 -8
  33. package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +9 -6
  34. package/docs/examples/host-local-admin-otp/package.json +2 -2
  35. package/docs/examples/host-minimal-worker/package.json +2 -2
  36. package/docs/handbook/chatgpt-sites/generated-app.md +84 -0
  37. package/docs/handbook/chatgpt-sites/index.md +21 -11
  38. package/docs/handbook/cloudflare/authentication.md +19 -2
  39. package/docs/handbook/cloudflare/bindings.md +4 -11
  40. package/docs/handbook/cloudflare/conventional-worker.md +7 -3
  41. package/docs/handbook/cloudflare/deploy-and-operate.md +1 -1
  42. package/docs/handbook/concepts/runtime-and-adapters.md +7 -0
  43. package/docs/handbook/guides/agent-setup.md +3 -3
  44. package/docs/handbook/navigation.json +3 -2
  45. package/docs/handbook/reference/diagnostics.md +5 -0
  46. package/docs/handbook/reference/procedure.md +52 -1
  47. package/docs/handbook/reference/schema.md +27 -1
  48. package/docs/handbook/reference/surface.md +3 -3
  49. package/docs/handbook/reference/trigger.md +21 -1
  50. package/docs/handbook/releases/index.md +55 -0
  51. package/docs/handbook/start/overview.md +5 -2
  52. package/docs/handbook/start/project-and-cli.md +103 -119
  53. package/docs/handbook/start/quickstart-admin.md +6 -4
  54. package/docs/handbook/start/quickstart-worker.md +17 -8
  55. package/docs/skills/develop/SKILL.md +14 -6
  56. package/docs/skills/integrate/SKILL.md +60 -0
  57. package/package.json +18 -17
  58. package/skills/README.md +3 -1
  59. package/skills/develop/SKILL.md +14 -6
  60. package/skills/install/SKILL.md +100 -137
  61. package/skills/integrate/SKILL.md +60 -0
  62. package/templates/chatgpt-sites/auth.ts +66 -0
  63. package/templates/chatgpt-sites/build.mjs +14 -0
  64. package/templates/chatgpt-sites/env.ts +1 -0
  65. package/templates/chatgpt-sites/mcp.ts +48 -0
  66. package/templates/chatgpt-sites/public-mcp.ts +29 -0
  67. package/templates/chatgpt-sites/smoke-local.mjs +20 -0
@@ -1,140 +1,124 @@
1
1
  ---
2
- description: The files you own in a Mantle project, every mantle and mantle-harness command with its flags, the generated module, the daily check loop, and version pins.
2
+ description: Generate a full Mantle app or select smaller modules, then safely rerun the CLI as your manifests evolve.
3
3
  ---
4
- # Project layout and the CLI loop
4
+ # Project layout and CLI
5
5
 
6
- This page describes a directly authored Mantle project: which files are yours, what the installed CLI does to them, and the loop you run before every commit. Surfaces are optional — take only what you need. [The minimal Worker](./quickstart-worker.md) is Spec + adapter without Admin. [Local Admin](./quickstart-admin.md) is the opt-in Dev UI path when humans need a console.
6
+ `mantle generate` can assemble a new application or compile manifests in an
7
+ existing one. A new hosted app defaults to Spec, Runtime, API, MCP, Admin and
8
+ an editable blank home. You can select a smaller set explicitly. It never
9
+ invents a business Schema or publishes a deployment.
7
10
 
8
- Agents can bootstrap with the install skill; human authors can follow this guide directly. For installation paths and the pinned-package handoff, see [Agent setup](../guides/agent-setup.md):
11
+ ## Start a new app
9
12
 
10
- ```sh
11
- npx skills add aotter/mantle
12
- ```
13
-
14
- ## You own the project
15
-
16
- Core is a manifest compiler and a runtime, not a project generator. You write `package.json`, the manifests, the Worker entry, handlers, TypeScript and provider configuration. `mantle generate` compiles what exists; it never initializes a missing project or invents a default Schema, frontend or home route.
17
-
18
- ```txt
19
- my-service/
20
- ├── package.json exact-pinned @aotter/mantle* + peers, scripts
21
- ├── tsconfig.json includes src/ and .mantle/generated/
22
- ├── wrangler.jsonc Worker name, flags, vars, bindings
23
- ├── .dev.vars local secrets for wrangler dev; never committed
24
- ├── manifests/
25
- │ └── site.yaml immediate .yaml/.yml files; multi-document with ---
26
- ├── src/
27
- │ ├── index.ts createMantleWorker({ plan, extend })
28
- │ └── mantle/handlers/ handler refs (a convention; any path under src/)
29
- ├── public/ required ASSETS root when Admin is installed; generate writes public/_mantle/admin/
30
- ├── .mantle/generated/
31
- │ └── mantle.ts written by mantle generate
32
- ├── .agents/skills/mantle-*/ written by mantle skills
33
- └── .claude/skills/mantle-*/ same bytes, for Claude compatibility
34
- ```
35
-
36
- The minimal Worker reference keeps `.mantle/`, `.agents/`, `.claude/`, `.wrangler/`, `.dev.vars*` and `.env*` out of git and regenerates the first three in its `check` script. Committing the generated files is also workable, because `generate --check` and `skills --check` detect drift either way. Commit the lockfile in a real application and install with `--frozen-lockfile` afterwards.
37
-
38
- `mantle validate` greps `./src` for the names of `handler.kind: ref` Procedures; a handler that is not found anywhere under `src/` produces a `HANDLER_NOT_REGISTERED` warning, so keep handlers under that root or pass `--source`.
39
-
40
- ## The CLI
41
-
42
- The umbrella package installs two binaries, `mantle` and `mantle-harness`. Run them through the package manager, for example `pnpm exec mantle generate`. Defaults shown are the pinned ones. Bare `mantle` / `mantle --help` prints a layered overview of optional surfaces (Minimal Spec + generate, Runtime / adapter, opt-in Admin). `generate --help` and `validate --help` stay on the compile path. After a successful `generate`, the CLI says Admin is opt-in: next steps when `@aotter/mantle-admin-ui` is installed, otherwise an API-only tip.
43
-
44
- | Command | Flags | Does |
45
- |---|---|---|
46
- | `mantle generate` | `--manifests <dir>` (default `./manifests`), `-o, --output <dir>` (default `.mantle/generated`), `--namespace <name>` (default `Mantle`), `--check` | Validate, link and compile manifests; write `mantle.ts`; sync Admin assets when installed. `--check` exits 1 without writing when output is stale. |
47
- | `mantle validate` | `--manifests <dir>`, `--source <dir>` (default `./src`), `--no-source`, `--phase preview\|deploy` (default `preview`), `--format json\|text`, `--json` | Static manifest and handler-source validation. Exit 0 with warnings allowed, 1 on any error, 2 on a CLI invocation problem. |
48
- | `mantle skills` | `--check` | Copy every skill marked `projection: project` into `.agents/skills/mantle-<name>/` and `.claude/skills/mantle-<name>/`. `--check` exits 1 when a projection is stale. |
49
- | `mantle emit-openapi` | `--manifests <dir>`, `--title <str>` (default `mantle`), `--version <str>` (default `0.1.0`), `--session-cookie-name <str>`, `-o, --output <file>` | Emit OpenAPI 3.1 for HTTP Triggers and `GET /api/views/<name>` routes to stdout or a file. MCP is out of scope. |
50
- | `mantle-harness indexes` | `--manifests <dir>`, `--rows <n>` (default 2000), `--require <view>` (repeatable), `--require-public`, `--format text\|json` | Execute compiled Views in crowded SQLite and inspect query plans; exit 1 when a required View lacks its access path. |
51
- | `mantle-harness http` | `--base-url <url>`, `--route <name=path-or-url>` (repeatable, required), `--rounds <n>` (default 20), `--warmup <n>` (default 2), `--format text\|json` | Sample a running Worker and report p50/p95 timings plus query-count and `rows_read` metric headers. |
52
-
53
- Advanced manifest primitives live in the `@aotter/mantle-spec` package's own `mantle-spec` binary: `mantle-spec introspect [--manifests <dir>]` dumps the parsed manifest tree as JSON, and `mantle-spec emit-types [--manifests <dir>] [--namespace <name>] [-o <file>]` emits standalone `.d.ts` declarations. Add `@aotter/mantle-spec` as a direct dependency to run them. The full flag reference is in [HTTP, MCP, CLI and packages](../reference/surface.md).
54
-
55
- ### What `generate` does and does not do
56
-
57
- `generate` reads the manifest directory, runs the same validation as `validate` (without the handler-source grep), links the set, and emits one `.mantle/generated/mantle.ts`. When `@aotter/mantle-admin-ui` is installed it also syncs the **prebuilt** Admin SPA into `public/_mantle/admin/`, excluding the package's `server.*` exports; Core-only installs skip that copy. Any error diagnostic stops the run with exit 1.
58
-
59
- Do not Vite-build Admin unless you are developing `@aotter/mantle-admin-ui` itself. A Cloudflare project that serves Admin must declare Static Assets:
13
+ Choose a host before running the command. The integrated hosts are `cf` and
14
+ `chatgpt-sites`; `--features spec` works without a host. Install one exact
15
+ published SDK version, then let the CLI declare its matching optional packages:
60
16
 
61
- ```jsonc
62
- "assets": { "directory": "./public", "binding": "ASSETS" }
17
+ ```sh
18
+ mkdir my-app && cd my-app
19
+ npm init -y
20
+ npm pkg set type=module
21
+ MANTLE_VERSION=$(npm view @aotter/mantle@latest version)
22
+ npm install --save-exact "@aotter/mantle@$MANTLE_VERSION"
23
+ npx mantle generate --host cf
24
+ npm install
25
+ npx mantle generate
26
+ npm run build
63
27
  ```
64
28
 
65
- That binding is a hard requirement. If `/admin` returns SPA `index.html` (`200`) while `/_mantle/admin/assets/*` is `404`, the page white-screens. Leave `/_mantle` out of `run_worker_first` so those files stay on the assets layer. `generate` warns when it syncs Admin and the local wrangler config has no `ASSETS` binding.
66
-
67
- It does not project skills, update packages, change styling, provision providers, or deploy. It does not create manifests: a missing or empty `manifests/` directory is an error, not a prompt.
68
-
69
- ## The generated module
70
-
71
- `.mantle/generated/mantle.ts` exports:
29
+ Confirm `MANTLE_VERSION` is a stable release, without a prerelease suffix.
30
+ Use `--host chatgpt-sites` for a Site; [its guide](../chatgpt-sites/generated-app.md)
31
+ continues with D1 migration, owner identity and local smoke. If you already
32
+ use pnpm, keep that one package manager and run `pnpm install` /
33
+ `pnpm exec mantle`. The first `generate` may exit asking you to install newly
34
+ declared packages; the second completes generation. A README or lockfile from
35
+ bootstrapping still counts as a new app. Once choices are saved, omit flags on
36
+ rerun.
72
37
 
73
- | Export | Purpose |
74
- |---|---|
75
- | `plan` | The sealed RuntimePlan with its fingerprint. The conventional Worker imports only this. |
76
- | `MantleHandlers<Env>` | The handler map type: one typed function per `handler.kind: ref` Procedure, receiving `(input, ctx)`. |
77
- | `createMantle({ storage, handlers, ports })` | Prepares storage eagerly once and returns the typed binding. No caching or retry. |
78
- | `bindMantle(runtime)` | The same typed binding over a runtime whose lifecycle the host already owns. |
79
-
80
- The binding exposes `mantle.views.<lowerCamelName>()`, `mantle.procedures.<name>(input, ctx)`, `mantle.entries.<collection>.createDraft({ data, authorId })`, typed indexed field reads such as `mantle.entries.<collection>.findManyByDataField({ field, value, limit })`, and the underlying `mantle.runtime`. Generated property names are deterministic lower-camel identifiers; calls keep the authored wire names internally. See [Typed queries](../guides/typed-queries.md) for internal Views and entry-reader examples. Details are in [HTTP, MCP, CLI and packages](../reference/surface.md).
81
-
82
- ## The daily loop
38
+ For a smaller composition, list wanted modules positively:
83
39
 
84
40
  ```sh
85
- pnpm install --frozen-lockfile
86
- pnpm exec mantle validate
87
- pnpm exec mantle generate
88
- pnpm exec mantle generate --check
89
- pnpm exec tsc --noEmit
90
- pnpm test # only when the project declares a test script
91
- pnpm exec mantle-harness indexes --require-public --format text
92
- pnpm exec wrangler dev --local
41
+ npx mantle generate --host cf --features spec,api
42
+ npx mantle generate --features spec
93
43
  ```
94
44
 
95
- Run the harness after any change to a Schema index, View filter or ordering, or public route; declare the smallest ordered index the measured path needs and respect SQLite's leftmost-prefix rule. Before a deploy, run `mantle validate --phase deploy`. Probe at least one declared route on the local origin; a `200` from a public View does not prove Admin or MCP login works. When Admin is installed, also probe `/admin/sign-in` and one `/_mantle/admin/assets/*` URL — both must be `200`. HTML 200 with asset 404 is the white-screen class of bug.
96
-
97
- ## Connecting an agent
45
+ Dependencies are expanded in the saved selection: `api` includes Runtime and
46
+ Spec; `admin` includes Runtime, API and MCP. Supported features are `spec`,
47
+ `runtime`, `api`, `mcp`, `admin`, `web`. No host is needed for Spec-only. Use an
48
+ explicit host in automation so a terminal prompt cannot stall. The selection
49
+ lives in `mantle.config.json`; changing it later requires a deliberate migration,
50
+ not an accidental CLI flag.
98
51
 
99
- `mantle skills` projects the skills the installed package marks `projection: project`. At this version those are `develop`, `plugin`, `theme` and `update`; `mantle`, `media-gc` and `provision` stay opt-in because they create projects, delete remote objects or handle production secrets. Both tool layouts receive identical bytes. Generation never rewrites these files.
52
+ ## Files and ownership
100
53
 
101
- Install the bootstrap skill in the agent host. Cold start uses
102
- the install skill; an already-installed project pins packages from `package.json`:
54
+ | File | Owner | What happens on rerun |
55
+ |---|---|---|
56
+ | `manifests/*.yaml`, `src/handlers.ts`, `src/home.ts` | You | Preserved. Add domain behavior and edit the blank home here. |
57
+ | `package.json`, `mantle.config.json`, `wrangler.jsonc` | Shared | Required versions and scripts are added; existing user values are preserved or conflicts reported. |
58
+ | `.mantle/generated/*`, `src/storage-fingerprint.json` | CLI | Rebuilt from the saved selection and manifests. |
59
+ | `drizzle/*.sql` on Sites | Review and apply | New migrations append; applied migrations are never rewritten. |
60
+ | `public/_mantle/admin/*` | CLI | Prebuilt Admin assets copied from the selected exact package. |
61
+ | `.openai/hosting.json` on Sites | Sites | Binding metadata is created locally; existing project metadata is preserved. |
62
+
63
+ A generated Worker imports the sealed `plan`, your handler map and the selected
64
+ modules. Generated files carry a marker so the CLI can distinguish them from
65
+ user-owned code. A rerun refuses to replace an unmarked file. Existing
66
+ applications without a saved selection keep their direct-authoring compile
67
+ behavior. For integration into an independently authored application, use the
68
+ installed `docs/skills/integrate/SKILL.md` to choose an embedding, incremental
69
+ replacement or rebuild strategy. Generation does not verify arbitrary host
70
+ entry points or deployment wiring.
71
+
72
+ `generate` accepts `--manifests <dir>` (default `./manifests`), `--output <dir>`
73
+ (default `.mantle/generated`), `--namespace <name>`, `--host cf|chatgpt-sites`,
74
+ `--features <comma-list>` and `--check`. Check mode exits nonzero
75
+ on drift and does not write. Sites also accepts `--review-unique-indexes` for
76
+ an explicit, source-bound unique tuple migration and duplicate preflight;
77
+ [review the D1 procedure](../chatgpt-sites/generated-app.md) before applying
78
+ it. `mantle validate` checks grammar and linked
79
+ capabilities; `--phase deploy` adds deployment checks. `mantle skills` projects
80
+ the installed SDK's project skills into `.agents/skills/` and `.claude/skills/`;
81
+ `mantle skills --check` detects drift. `mantle emit-openapi` describes HTTP
82
+ Triggers and View REST routes; `mantle-harness indexes` and `http` inspect
83
+ queries and running routes. [Command reference](../reference/surface.md).
84
+
85
+ ## Verify the assembled app
103
86
 
104
87
  ```sh
105
- # Canonical
106
- npx skills add aotter/mantle
107
-
108
- # Claude Code — two separate prompts
109
- /plugin marketplace add aotter/mantle
110
- /plugin install mantle@mantle
111
-
112
- # Codex
113
- codex plugin marketplace add aotter/mantle
114
- codex plugin add mantle@mantle
88
+ npx mantle generate --check
89
+ npx mantle skills
90
+ npx mantle skills --check
91
+ npm run typecheck
92
+ npm run build
93
+ npm run dev
115
94
  ```
116
95
 
117
- The projected `develop` skill tells the agent to read `package.json` for the installed version, the manifests and adapter config, and the docs under `node_modules/@aotter/mantle/docs/` before editing. To connect an MCP client to the running Worker, see [MCP and agents](../concepts/mcp-and-agents.md).
118
-
119
- ## Version pins
120
-
121
- - Pin every `@aotter/mantle*` package to one exact version and move them together. Check that release's peer ranges when you move.
122
- - This handbook describes the snapshot in this source tree. Use the docs that ship with the version in `package.json`, not a floating branch.
123
- - The authoring CLI is `generate`, `validate`, `emit-openapi` and `skills`. `mantle-harness` is the measurement binary. There is no `create` / `update` happy path.
124
- - When you change versions: pin the new exact version and refresh the lockfile; keep the Worker, D1, KV identity, origins, auth mode and secrets; then run `generate`, `generate --check`, `skills`, `skills --check`, `validate`, typecheck and tests before deploying.
96
+ Run scripts that exist in the selected project; Spec-only has no server to
97
+ start. Run `npx mantle validate` after adding the first Manifest: the validator
98
+ reports `MANIFEST_ROOT_NOT_FOUND` on an intentionally empty app. A full
99
+ Cloudflare app should serve the blank home and Admin assets.
100
+ For local CF Admin, copy `.dev.vars.example` to `.dev.vars`, replace
101
+ `ADMIN_EMAIL` with the intended owner's address and `BETTER_AUTH_SECRET` with
102
+ a random 32-byte secret, and keep `PUBLIC_ORIGIN` equal to the loopback URL
103
+ wrangler prints. Open `/admin/sign-in` with that email and read the OTP in
104
+ wrangler logs. Check that `/_mantle/admin/assets/*` loads, an anonymous
105
+ `/admin/api/site-settings` request is denied, and the signed-in owner can read
106
+ it. Verify anonymous staff MCP access fails before claiming it works. A full
107
+ Site must also apply its reviewed
108
+ D1 migration before the Worker boots. The public MCP endpoint is discoverable
109
+ without a staff session; the staff endpoint requires the host's verified
110
+ identity and a Mantle role. See [MCP and agents](../concepts/mcp-and-agents.md).
111
+
112
+ For an already installed app, confirm `node_modules/@aotter/mantle/package.json`
113
+ and the lockfile agree. Use that package's CLI and `docs/` tree; the latest
114
+ GitHub handbook may describe a newer release. Keep all selected
115
+ `@aotter/mantle*` packages on one exact version. The prior direct-authoring
116
+ contract remains valid for older installed SDKs; upgrade deliberately using
117
+ [release notes](../releases/index.md).
125
118
 
126
119
  ## Source
127
- - [`docs/direct-authoring.md`](../../../docs/direct-authoring.md)
128
- - [`docs/examples/host-local-admin-otp/README.md`](../../../docs/examples/host-local-admin-otp/README.md)
129
- - [`docs/examples/host-local-admin-otp/wrangler.jsonc`](../../../docs/examples/host-local-admin-otp/wrangler.jsonc)
130
- - [`docs/examples/host-minimal-worker/.gitignore`](../../../docs/examples/host-minimal-worker/.gitignore)
131
- - [`packages/mantle/README.md`](../../../packages/mantle/README.md)
132
- - [`packages/mantle/src/cli/main.ts`](../../../packages/mantle/src/cli/main.ts)
133
- - [`packages/mantle/src/cli/generate.ts`](../../../packages/mantle/src/cli/generate.ts)
134
- - [`packages/mantle/src/cli/skills.ts`](../../../packages/mantle/src/cli/skills.ts)
135
- - [`packages/mantle/src/cli/harness.ts`](../../../packages/mantle/src/cli/harness.ts)
136
- - [`packages/mantle/src/codegen/emitMantleModule.ts`](../../../packages/mantle/src/codegen/emitMantleModule.ts)
137
- - [`packages/mantle-spec/src/infrastructure/cli/ValidateCommand.ts`](../../../packages/mantle-spec/src/infrastructure/cli/ValidateCommand.ts)
138
- - [`packages/mantle-spec/src/infrastructure/cli/EmitOpenapiCommand.ts`](../../../packages/mantle-spec/src/infrastructure/cli/EmitOpenapiCommand.ts)
139
- - [`packages/mantle-spec/src/infrastructure/cli/MantleCli.ts`](../../../packages/mantle-spec/src/infrastructure/cli/MantleCli.ts)
140
- - [`docs/skills/develop/SKILL.md`](../../skills/develop/SKILL.md)
120
+
121
+ - [Generate CLI](../../../packages/mantle/src/cli/generate.ts)
122
+ - [Project selection and package pins](../../../packages/mantle/src/cli/generate-project.ts)
123
+ - [Cloudflare assembly](../../../packages/mantle/src/cli/generate-cloudflare.ts)
124
+ - [ChatGPT Sites assembly](../../../packages/mantle/src/cli/generate-sites.ts)
@@ -3,9 +3,11 @@ description: "Open local Admin in one shot: follow the official OTP example, bin
3
3
  ---
4
4
  # Quickstart: local Admin
5
5
 
6
- Admin is **opt-in**: use it when humans need a Dev UI. A complete Mantle
7
- service does not require this surface. The default embed path — Spec + Worker
8
- without Admin — is [Quickstart: a minimal Worker](./quickstart-worker.md).
6
+ New generated CF and Sites apps include Admin by default. To leave it out,
7
+ select smaller features explicitly. This tutorial shows the existing
8
+ direct-authored Worker integration with local email OTP; use it when you own
9
+ the Worker entry. [Project layout and CLI](./project-and-cli.md) describes the
10
+ new generated path.
9
11
 
10
12
  The procedural source of truth is the official example:
11
13
 
@@ -29,7 +31,7 @@ Traps (documented on the example):
29
31
  - `pnpm check` / smoke rewrites `.dev.vars` to a smoke-only port — restore it
30
32
  from `.dev.vars.example` before `pnpm dev`.
31
33
 
32
- Install every `@aotter/mantle*` package from the `latest` dist-tag; see
34
+ Pin every selected `@aotter/mantle*` package to the same exact version; see
33
35
  [Versions](../reference/surface.md#versions). Admin needs both
34
36
  `@aotter/mantle-admin` and `@aotter/mantle-admin-ui`, wrangler `ASSETS` on
35
37
  `./public`, and `createAuth` email-otp + `ConsoleEmailSender`.
@@ -3,7 +3,13 @@ description: "Author a minimal Cloudflare Worker from scratch: one Schema, one p
3
3
  ---
4
4
  # Quickstart: a minimal Worker
5
5
 
6
- This page reproduces Core's API-only Worker reference as a from-scratch walkthrough. It is the embed / adapter path: View REST without Admin, Auth or a visitor frontend. Admin is opt-in when humans need a console — [Quickstart: local Admin](./quickstart-admin.md). Resolve the intended release once and pin every `@aotter/mantle*` package to it; see [Versions](../reference/surface.md#versions).
6
+ This page reproduces the API-only Worker reference as a direct-authoring
7
+ walkthrough: View REST without Admin, Auth or a visitor frontend. For a new
8
+ project, `mantle generate --host cf --features spec,api` assembles that smaller
9
+ composition. Omit `--features` to include Admin, MCP and a blank home. The
10
+ [local Admin tutorial](./quickstart-admin.md) covers an authored Worker entry.
11
+ Pin every selected `@aotter/mantle*` package to one exact version; see
12
+ [Versions](../reference/surface.md#versions).
7
13
 
8
14
  ## Prerequisites
9
15
 
@@ -13,10 +19,9 @@ This page reproduces Core's API-only Worker reference as a from-scratch walkthro
13
19
 
14
20
  ## 1. `package.json`
15
21
 
16
- The `latest` entries below are bootstrap placeholders. Step 5 replaces both
17
- with one exact version before the first build. For a prerelease evaluation,
18
- select its exact version explicitly rather than mixing channels. The other
19
- entries are the peers and tools used by this reference.
22
+ Step 5 adds the two Mantle packages at one exact version. For a prerelease
23
+ evaluation, select its exact version explicitly rather than mixing channels.
24
+ The entries below are the peers and tools used by this direct-authored reference.
20
25
 
21
26
  ```json
22
27
  {
@@ -31,8 +36,6 @@ entries are the peers and tools used by this reference.
31
36
  "check": "mantle generate && mantle generate --check && mantle validate && mantle skills && mantle skills --check && tsc --noEmit"
32
37
  },
33
38
  "dependencies": {
34
- "@aotter/mantle": "latest",
35
- "@aotter/mantle-cloudflare": "latest",
36
39
  "better-auth": "1.7.2",
37
40
  "hono": "^4.13.3",
38
41
  "zod": "^4.5.4",
@@ -172,7 +175,13 @@ curl -i http://127.0.0.1:8787/mcp/staff
172
175
  - `.mantle/generated/mantle.ts` — one module with the sealed `plan`, generated types (`MantleHandlers<Env>`), `createMantle` and `bindMantle`. The Worker entry above imports only `plan`.
173
176
  - `public/_mantle/admin/` — the Admin SPA, synced only when `@aotter/mantle-admin-ui` is installed. This project did not install it, so nothing is written there and `/admin` has no assets.
174
177
 
175
- `generate` fails on missing or invalid manifests and never creates a project, a default Schema or a home route. `mantle generate --check` reports stale output without writing. The reference keeps `.mantle/`, `.agents/` and `.claude/` out of git and regenerates them in `check`; see [Project layout and the CLI loop](./project-and-cli.md).
178
+ This walkthrough uses the existing direct-authored Worker entry; in that legacy
179
+ compile mode, `generate` expects the supplied manifests and does not add a
180
+ home route. New applications can instead use `mantle generate --host cf`
181
+ with `--features spec,api` for a smaller assembled Worker. The CLI never
182
+ invents a Schema. `mantle generate --check` reports stale output without
183
+ writing. The reference keeps `.mantle/`, `.agents/` and `.claude/` out of git
184
+ and regenerates them in `check`; see [Project layout and CLI](./project-and-cli.md).
176
185
 
177
186
  ## Next steps
178
187
 
@@ -57,9 +57,11 @@ pnpm exec mantle --help
57
57
  pnpm validate
58
58
  ```
59
59
 
60
- This CLI validates and derives artifacts from application-authored manifests.
61
- It does not create projects, business schemas or a visitor homepage. There is
62
- no `mantle create` / `mantle update` happy path.
60
+ On 0.1.5 and newer, `generate --host cf|chatgpt-sites` assembles a new blank
61
+ app; no `--features` selects Spec, Runtime, API, MCP, Admin and Web. Explicit
62
+ `--features` selects a smaller composition. It never invents a business
63
+ Schema. Existing authored apps keep compile mode, and older installed CLIs
64
+ may not support project generation. Check this project's CLI help first.
63
65
 
64
66
  ## Core Model
65
67
 
@@ -155,7 +157,10 @@ teaching the project Mantle internals.
155
157
 
156
158
  ## Auth Composition
157
159
 
158
- Admin is opt-in. A project without `@aotter/mantle-admin-ui` is complete.
160
+ Generated full apps select Admin by default; smaller selections can omit it.
161
+ A project without `@aotter/mantle-admin-ui` is complete when Admin was not
162
+ selected. If Admin was selected but its package is missing, install the
163
+ CLI-declared exact version and rerun generation.
159
164
  When Admin is installed, `createMantleWorker({ auth })` with `email-otp`
160
165
  and `ConsoleEmailSender` is the local human path (OTP in wrangler logs).
161
166
  That override owns Auth construction; Core still owns `/admin` and
@@ -164,8 +169,11 @@ and an `ASSETS` binding. A white screen at `/admin` with HTML 200 and
164
169
  `/_mantle/admin/assets/*` 404 is a missing assets binding, not a missing
165
170
  frontend build.
166
171
 
167
- Conventional Cloudflare projects that do not replace Auth declare
168
- `MANTLE_AUTH_MODE=hosted` or `self-managed`; Core owns that standard
172
+ Generated Cloudflare apps use `MANTLE_AUTH_MODE=local-otp` on loopback after
173
+ copying `.dev.vars.example` to `.dev.vars` and setting a real owner email and
174
+ random secret. Production uses `hosted` or `self-managed` with provider
175
+ credentials and `ADMIN_GITHUB_LOGIN`. Conventional Cloudflare projects that
176
+ do not replace Auth use those two production modes; Core owns that standard
169
177
  composition and rejects partial or mixed bindings. Preserve the explicit
170
178
  mode recorded in Worker config, keep provider secrets out of source, and
171
179
  do not infer a mode from whichever credentials happen to be present.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: integrate
3
+ description: Integrate Mantle into an existing application. Use when the application has its own code, routes, storage or deployment and the owner wants to add Mantle, replace part of it, or rebuild with Mantle while migrating frontend and data.
4
+ metadata:
5
+ source: "@aotter/mantle"
6
+ sourcePath: docs/skills/integrate/SKILL.md
7
+ applies_to: mantle grammar v0.1
8
+ projection: package
9
+ projectionReason: Existing-project migration is opt-in; a fresh generated app does not need this brief.
10
+ ---
11
+
12
+ # Integrate Mantle into an existing application
13
+
14
+ Work in the target application. Read its installed `@aotter/mantle` version,
15
+ CLI help and package-local docs before editing. If Mantle is absent, inspect
16
+ the application first, then install an exact SDK version only after choosing an
17
+ integration strategy. Use the installed version's contract; do not copy
18
+ `develop` branch examples into an older consumer.
19
+
20
+ ## Inspect and decide
21
+
22
+ Map the actual entry points, router, frontend, auth, storage, data volume and
23
+ relationships, deployment pipeline, URLs, background jobs and existing tests.
24
+ Identify which behavior the owner wants Mantle to own and what must remain
25
+ stable. Compare three approaches using the application's evidence:
26
+
27
+ 1. **Embed selectively:** keep the host and call Mantle's parser, Runtime or
28
+ selected surfaces through its documented package APIs. The host owns wiring.
29
+ 2. **Replace incrementally:** move one bounded capability at a time. Define
30
+ where reads and writes go during coexistence and how each step is checked.
31
+ 3. **Rebuild and migrate:** create a separate new Mantle application, port the
32
+ frontend and business behavior, and transform/import existing data. Prefer
33
+ this when adapting the old structure costs more than rebuilding. Preserve
34
+ relevant IDs, relations, URLs and identity semantics; rehearse the data
35
+ transfer before a production cutover.
36
+
37
+ Explain the chosen path and its concrete tradeoffs to the owner. A small
38
+ prototype or read-only inventory may resolve uncertainty. Do not run a generic
39
+ project converter or assume the current application's shape matches a
40
+ generated Cloudflare or ChatGPT Sites skeleton.
41
+
42
+ ## Implement and verify
43
+
44
+ - For embedding, retain user-owned entry/config/build files. Use the installed
45
+ direct-authoring docs and CLI to validate manifests and emit bindings; wire
46
+ the selected Mantle capabilities into the existing host explicitly.
47
+ - For incremental replacement, establish a clear owner for each data write
48
+ and request route at every stage. Verify old and new behavior together.
49
+ - For rebuilding, generate in a **separate directory** with the installed
50
+ CLI, move frontend and handlers deliberately, and plan data mapping and
51
+ import separately. Review database migrations before application or cutover.
52
+ - Run the application's build and representative behavior checks for the
53
+ changed routes, auth and data. `mantle generate --check` checks generated
54
+ output against its declared selection; it cannot certify host integration.
55
+ For live data, record migration counts and a rollback or recovery path
56
+ appropriate to the project.
57
+
58
+ Leave existing data and deployment untouched until the requested migration
59
+ and release steps are ready. Report which capabilities Mantle now owns,
60
+ what was verified, and what remains for application deployment or cutover.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aotter/mantle",
3
- "version": "0.1.4",
3
+ "version": "0.1.5-alpha.1",
4
4
  "description": "Embeddable Mantle Core umbrella with Spec and Runtime; Web, Admin, Auth, Bun, Vercel, Cloudflare, and Admin UI are optional peer packages.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://mantle.tools/",
@@ -80,11 +80,12 @@
80
80
  "dist",
81
81
  "docs",
82
82
  "skills",
83
+ "templates",
83
84
  "README.md"
84
85
  ],
85
86
  "dependencies": {
86
- "@aotter/mantle-runtime": "0.1.4",
87
- "@aotter/mantle-spec": "0.1.4"
87
+ "@aotter/mantle-runtime": "0.1.5-alpha.1",
88
+ "@aotter/mantle-spec": "0.1.5-alpha.1"
88
89
  },
89
90
  "peerDependencies": {
90
91
  "aws4fetch": "^1.0.20",
@@ -92,13 +93,13 @@
92
93
  "hono": "^4.12.0",
93
94
  "@libsql/client": "^0.17.4",
94
95
  "zod": "^4.5.0",
95
- "@aotter/mantle-admin-ui": "0.1.4",
96
- "@aotter/mantle-auth": "0.1.4",
97
- "@aotter/mantle-vercel": "0.1.4",
98
- "@aotter/mantle-bun": "0.1.4",
99
- "@aotter/mantle-web": "0.1.4",
100
- "@aotter/mantle-cloudflare": "0.1.4",
101
- "@aotter/mantle-admin": "0.1.4"
96
+ "@aotter/mantle-admin": "0.1.5-alpha.1",
97
+ "@aotter/mantle-admin-ui": "0.1.5-alpha.1",
98
+ "@aotter/mantle-auth": "0.1.5-alpha.1",
99
+ "@aotter/mantle-bun": "0.1.5-alpha.1",
100
+ "@aotter/mantle-cloudflare": "0.1.5-alpha.1",
101
+ "@aotter/mantle-vercel": "0.1.5-alpha.1",
102
+ "@aotter/mantle-web": "0.1.5-alpha.1"
102
103
  },
103
104
  "peerDependenciesMeta": {
104
105
  "@aotter/mantle-admin": {
@@ -144,13 +145,13 @@
144
145
  "typescript": "^6.0.3",
145
146
  "vitest": "^4.1.11",
146
147
  "zod": "^4.5.4",
147
- "@aotter/mantle-admin": "0.1.4",
148
- "@aotter/mantle-admin-ui": "0.1.4",
149
- "@aotter/mantle-auth": "0.1.4",
150
- "@aotter/mantle-bun": "0.1.4",
151
- "@aotter/mantle-cloudflare": "0.1.4",
152
- "@aotter/mantle-vercel": "0.1.4",
153
- "@aotter/mantle-web": "0.1.4"
148
+ "@aotter/mantle-admin": "0.1.5-alpha.1",
149
+ "@aotter/mantle-admin-ui": "0.1.5-alpha.1",
150
+ "@aotter/mantle-auth": "0.1.5-alpha.1",
151
+ "@aotter/mantle-bun": "0.1.5-alpha.1",
152
+ "@aotter/mantle-cloudflare": "0.1.5-alpha.1",
153
+ "@aotter/mantle-vercel": "0.1.5-alpha.1",
154
+ "@aotter/mantle-web": "0.1.5-alpha.1"
154
155
  },
155
156
  "engines": {
156
157
  "node": ">=22"
package/skills/README.md CHANGED
@@ -5,6 +5,7 @@ Agent-readable skill briefs for consumers of `@aotter/mantle-*`. Discoverable by
5
5
  | Skill | When to invoke |
6
6
  |---|---|
7
7
  | [`develop`](../docs/skills/develop/SKILL.md) | `mantle:develop`: Core-owned workflow for manifest, runtime, handler, adapter, validation, and MCP work in any Mantle project. |
8
+ | [`integrate`](../docs/skills/integrate/SKILL.md) | `mantle:integrate`: choose and carry out an existing application's Mantle integration or rebuild and data migration. |
8
9
  | [`media-gc`](../docs/skills/media-gc/SKILL.md) | `mantle:media-gc`: audit or remove stale uncommitted public media objects with the connected Cloudflare API. |
9
10
  | [`plugin`](../docs/skills/plugin/SKILL.md) | `mantle:plugin`: Core-owned marketplace workflow for plan-first capability installs across applications and adapters. |
10
11
  | [`theme`](../docs/skills/theme/SKILL.md) | `mantle:theme`: Core-owned visual workflow. Reads project-owned theme and UI contracts. |
@@ -26,6 +27,7 @@ enforces the columns below.
26
27
  | Skill | Routes on | Entry-path constraints (read before acting) | Path-gated sections | Projection | Restricted because |
27
28
  |---|---|---|---|---|---|
28
29
  | `develop` | existing project; manifest, runtime, handler, adapter, or MCP work | four-atom model; adapter neutrality; no direct D1/KV/Postgres writes; no committed secrets | performance harness; local MCP client; locale rules | project | — |
30
+ | `integrate` | independently authored application; add Mantle or rebuild with migration | inspect application before strategy; version-matched SDK; protect live data | embed; incrementally replace; rebuild and migrate | package | Existing-project migration is opt-in; a fresh generated app does not need this brief. |
29
31
  | `plugin` | user wants an installable capability | plan before apply; lock entry is the removal manifest; delete only plugin-owned files and atoms | apply; remove | project | — |
30
32
  | `theme` | brand or visual direction in a project | repo-owned theme and UI contracts | — | project | — |
31
33
  | `update` | SDK upgrade or plugin lock review | never blindly overwrite user-owned code | — | project | — |
@@ -61,7 +63,7 @@ contracts.
61
63
 
62
64
  `skills/install/SKILL.md` declares `name: mantle`. It is the only repository
63
65
  skill discovered by the no-flag command and copied as a small directory.
64
- The other six skills live in `docs/skills/` and ship with the npm package.
66
+ The other seven skills live in `docs/skills/` and ship with the npm package.
65
67
  `mantle skills` projects the four ongoing workflows after package installation.
66
68
 
67
69
  Other marketplace hosts point to the same entry:
@@ -57,9 +57,11 @@ pnpm exec mantle --help
57
57
  pnpm validate
58
58
  ```
59
59
 
60
- This CLI validates and derives artifacts from application-authored manifests.
61
- It does not create projects, business schemas or a visitor homepage. There is
62
- no `mantle create` / `mantle update` happy path.
60
+ On 0.1.5 and newer, `generate --host cf|chatgpt-sites` assembles a new blank
61
+ app; no `--features` selects Spec, Runtime, API, MCP, Admin and Web. Explicit
62
+ `--features` selects a smaller composition. It never invents a business
63
+ Schema. Existing authored apps keep compile mode, and older installed CLIs
64
+ may not support project generation. Check this project's CLI help first.
63
65
 
64
66
  ## Core Model
65
67
 
@@ -155,7 +157,10 @@ teaching the project Mantle internals.
155
157
 
156
158
  ## Auth Composition
157
159
 
158
- Admin is opt-in. A project without `@aotter/mantle-admin-ui` is complete.
160
+ Generated full apps select Admin by default; smaller selections can omit it.
161
+ A project without `@aotter/mantle-admin-ui` is complete when Admin was not
162
+ selected. If Admin was selected but its package is missing, install the
163
+ CLI-declared exact version and rerun generation.
159
164
  When Admin is installed, `createMantleWorker({ auth })` with `email-otp`
160
165
  and `ConsoleEmailSender` is the local human path (OTP in wrangler logs).
161
166
  That override owns Auth construction; Core still owns `/admin` and
@@ -164,8 +169,11 @@ and an `ASSETS` binding. A white screen at `/admin` with HTML 200 and
164
169
  `/_mantle/admin/assets/*` 404 is a missing assets binding, not a missing
165
170
  frontend build.
166
171
 
167
- Conventional Cloudflare projects that do not replace Auth declare
168
- `MANTLE_AUTH_MODE=hosted` or `self-managed`; Core owns that standard
172
+ Generated Cloudflare apps use `MANTLE_AUTH_MODE=local-otp` on loopback after
173
+ copying `.dev.vars.example` to `.dev.vars` and setting a real owner email and
174
+ random secret. Production uses `hosted` or `self-managed` with provider
175
+ credentials and `ADMIN_GITHUB_LOGIN`. Conventional Cloudflare projects that
176
+ do not replace Auth use those two production modes; Core owns that standard
169
177
  composition and rejects partial or mixed bindings. Preserve the explicit
170
178
  mode recorded in Worker config, keep provider secrets out of source, and
171
179
  do not infer a mode from whichever credentials happen to be present.