@aotter/mantle 0.2.1-alpha.1 → 0.2.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -177
- package/dist/build/compiler.d.ts +4 -4
- package/dist/build/compiler.js +3 -3
- package/dist/domain/describe/{chunk-P6PP6VVV.js → chunk-CW7X5Q5T.js} +1 -1
- package/dist/domain/describe/index.js +1 -1
- package/dist/domain/describe/public.d.ts +3 -0
- package/dist/domain/describe/public.js +1 -0
- package/dist/infrastructure/help.js +1 -3
- package/dist/kernel/mcp-apps.d.ts +3 -2
- package/dist/kernel/mcp-apps.js +7 -2
- package/dist/kernel/mcp-handler.js +20 -8
- package/dist/kernel/mcp.d.ts +18 -0
- package/dist/kernel/mcp.js +1 -0
- package/dist/usecase/adminDescriptors.js +1 -1
- package/dist/usecase/generate.js +20 -4
- package/dist/usecase/rest.js +2 -4
- package/docs/examples/README.md +2 -2
- package/docs/examples/app-shell/README.md +1 -1
- package/docs/examples/app-shell/accept.mjs +12 -2
- package/docs/examples/app-shell/package.json +3 -3
- package/docs/handbook/cloudflare/authentication.md +1 -1
- package/docs/handbook/cloudflare/deploy-and-operate.md +20 -8
- package/docs/handbook/cloudflare/media-r2.md +31 -0
- package/docs/handbook/examples/hub.md +1 -1
- package/docs/handbook/guides/agent-setup.md +25 -67
- package/docs/handbook/guides/agent-workflow-acceptance.md +32 -5
- package/docs/handbook/guides/mcp-apps.md +43 -1
- package/docs/{skills/performance/SKILL.md → handbook/guides/performance.md} +53 -32
- package/docs/handbook/guides/size-and-startup.md +2 -2
- package/docs/handbook/guides/typed-queries.md +12 -0
- package/docs/handbook/navigation.json +4 -0
- package/docs/handbook/reference/describe.md +16 -6
- package/docs/handbook/reference/surface.md +10 -0
- package/docs/handbook/releases/index.md +85 -2
- package/docs/{upgrade-0.1-to-0.2.md → handbook/releases/upgrade-0.1-to-0.2.md} +13 -13
- package/docs/handbook/start/agents.md +25 -4
- package/docs/handbook/start/quickstart-worker.md +1 -1
- package/package.json +2 -3
- package/skills/README.md +7 -69
- package/skills/mantle/SKILL.md +15 -81
- package/dist/domain/describe/target-hash.js +0 -1
- package/docs/skills/develop/SKILL.md +0 -100
- package/docs/skills/integrate/SKILL.md +0 -51
- package/docs/skills/media-gc/SKILL.md +0 -109
- package/docs/skills/provision/SKILL.md +0 -44
- package/docs/skills/update/SKILL.md +0 -42
|
@@ -15,6 +15,23 @@ From 0.2.0-alpha.7, Mantle publishes three packages together at one version:
|
|
|
15
15
|
and `@aotter/mantle-admin` (optional Admin server, SPA and MCP App).
|
|
16
16
|
Pin every package you use to the same exact version and upgrade them together.
|
|
17
17
|
|
|
18
|
+
## Upgrade an application
|
|
19
|
+
|
|
20
|
+
1. Pin every Mantle package to the same exact published version; never follow a dist-tag. Read every release section
|
|
21
|
+
between your version and the target, including its breaking changes.
|
|
22
|
+
2. Regenerate with the project's own command and review the emitted TypeScript, SQL and policy diffs. A schema change
|
|
23
|
+
needs a data-preserving migration written with the host's tool and rehearsed on a copy
|
|
24
|
+
([Install and change schemas](../cloudflare/deploy-and-operate.md#install-and-change-schemas)); the initial
|
|
25
|
+
`schema.sql` never rebuilds production tables.
|
|
26
|
+
3. Keep users, sessions, content and application code. Follow [Customising Admin](../guides/native-admin.md#customising-admin)
|
|
27
|
+
for the application-built Admin; old UI subpaths have no aliases.
|
|
28
|
+
4. Re-run the project's checks, member and Admin OTP, affected REST/MCP/Admin routes, private-field visibility, OCC and
|
|
29
|
+
unknown outcomes, then [acceptance](../guides/agent-workflow-acceptance.md) before an authorized cutover. Updating a
|
|
30
|
+
dependency never publishes a package.
|
|
31
|
+
|
|
32
|
+
From 0.1.x, follow [Upgrade 0.1 to 0.2](upgrade-0.1-to-0.2.md) instead: a new database, a reviewed and rehearsed data
|
|
33
|
+
move, and never booting 0.2 against a 0.1.x database.
|
|
34
|
+
|
|
18
35
|
## 0.2.1 — in preparation
|
|
19
36
|
|
|
20
37
|
0.2.1 adds Schema locks: a manifest rule that refuses a row's update or delete
|
|
@@ -33,6 +50,72 @@ and interactive transactions can use `store.batch` for atomic multi-writes, and
|
|
|
33
50
|
`mantle bundle` under `wrangler dev` reports stale generated output in one line
|
|
34
51
|
instead of a failed build.
|
|
35
52
|
|
|
53
|
+
### Upgrading to 0.2.1-alpha.3
|
|
54
|
+
|
|
55
|
+
- **Agent guidance has one home, the handbook.** The package no longer ships `docs/skills/`, so the `mantle help
|
|
56
|
+
skills/<name>` topics are gone. Their guidance is now in handbook pages:
|
|
57
|
+
[performance pass](../guides/performance.md),
|
|
58
|
+
[deploy and operate](../cloudflare/deploy-and-operate.md),
|
|
59
|
+
[cleaning up stale uploads](../cloudflare/media-r2.md#clean-up-stale-uploads),
|
|
60
|
+
[upgrading an application](#upgrade-an-application) and
|
|
61
|
+
[adoption in an existing app](../guides/typed-queries.md#adopt-mantle-in-an-existing-application).
|
|
62
|
+
`mantle help` reaches all of them from the entry page.
|
|
63
|
+
- **The `mantle` skill no longer depends on the SDK version.** It routes to `mantle help`, so
|
|
64
|
+
`npx skills add aotter/mantle@mantle` no longer needs a release tag. A skill installed from an earlier tag still
|
|
65
|
+
names `docs/skills/` paths; reinstall it.
|
|
66
|
+
- **Docs moves.** The 0.1 → 0.2 upgrade guide is now the topic `mantle help upgrade-0.1-to-0.2`. The package README is
|
|
67
|
+
an index of topics.
|
|
68
|
+
- **The agent workflow checks in with the user.** Once the manifests generate, `pnpm accept --open` opens the Developer
|
|
69
|
+
UI (`/admin/dev`) so the user can see the wiring. The agent then stops twice with a plan: before acceptance and
|
|
70
|
+
before the performance pass. It finishes with an acceptance summary and a before → after performance summary
|
|
71
|
+
([agents](../start/agents.md)).
|
|
72
|
+
|
|
73
|
+
Regenerate to pick up the rest of this release. No manifest or API changes:
|
|
74
|
+
|
|
75
|
+
- **Developer UI diagrams.**
|
|
76
|
+
- The data model is a real ER diagram: keys, types and crow's-foot cardinality, with three display modes.
|
|
77
|
+
- System wiring is laid out in columns, with a minimap.
|
|
78
|
+
- A Procedure's logic is one graph, the same in the wiring side panel and on the Procedure page: a transaction box,
|
|
79
|
+
CASE as ordered branch rows, and COMMIT and ROLLBACK ends. The SQL syntax trees stay available, folded, on the
|
|
80
|
+
Procedure page.
|
|
81
|
+
- Their wording is translated in every Admin language that has translations.
|
|
82
|
+
- **Smaller startup.**
|
|
83
|
+
- Generated Workers emit a repeated SQL statement once. REST loads a Procedure on its first request, the way views and
|
|
84
|
+
MCP already did. The reference D1 Worker's startup is about 20% smaller.
|
|
85
|
+
- Admin loads sign-in, OAuth consent and the collection list on demand.
|
|
86
|
+
- The Admin MCP App uses native select and popover controls.
|
|
87
|
+
|
|
88
|
+
### Upgrading to 0.2.1-alpha.2
|
|
89
|
+
|
|
90
|
+
Pin the selected packages to `0.2.1-alpha.2` and regenerate. Breaking change:
|
|
91
|
+
|
|
92
|
+
- **`@aotter/mantle/describe`** keeps only `matchTarget` and the
|
|
93
|
+
`AppDescription`, `DescribeTarget` and `TargetRequest` types. `describeApp`,
|
|
94
|
+
`diffApp` and the `@aotter/mantle/target-hash` subpath are removed.
|
|
95
|
+
**`mantle describe` output is the supported way to get a description outside
|
|
96
|
+
the CLI:** run `mantle describe <target> manifests/*.yaml > describe.json` in
|
|
97
|
+
Node.js or Bun (for example in a deploy step) and give the JSON to
|
|
98
|
+
`matchTarget`. Do not import compiler files from `dist`; a Worker cannot
|
|
99
|
+
compile manifests that contain SQL ([describe](../reference/describe.md)).
|
|
100
|
+
Use `mantle describe --diff` instead of `diffApp`, and `_meta.targetHash`
|
|
101
|
+
instead of `targetHash()`.
|
|
102
|
+
|
|
103
|
+
Hand-built MCP tools gain three opt-in capabilities; without them the output
|
|
104
|
+
is unchanged ([MCP Apps](../guides/mcp-apps.md), [surface](../reference/surface.md)):
|
|
105
|
+
|
|
106
|
+
- `Tool.meta` merges into the tool's listed `_meta`. `ui.visibility: ["app"]`
|
|
107
|
+
can now hide a Procedure from clients without MCP Apps; it is a listing hint,
|
|
108
|
+
and calls are authorized as before.
|
|
109
|
+
- `withResultMeta(data, meta)` returns `meta` only in the result `_meta`, so a
|
|
110
|
+
value such as a signed upload URL stays out of `content`. `callTool` returns
|
|
111
|
+
`{ data, _meta }`; drop `_meta` before forwarding a result to a model.
|
|
112
|
+
- `toolsPageSize` pages `tools/list` with an opaque `nextCursor`.
|
|
113
|
+
|
|
114
|
+
Also: generation reports a SQL parser that cannot load in the current runtime
|
|
115
|
+
as such, instead of `SQL_SYNTAX`, and the handbook renders under Vue-based
|
|
116
|
+
site generators (bare `<placeholder>` text is now quoted, and `pnpm check`
|
|
117
|
+
fails on any that return).
|
|
118
|
+
|
|
36
119
|
### Upgrading to 0.2.1-alpha.1
|
|
37
120
|
|
|
38
121
|
Pin `@aotter/mantle`, and any selected `@aotter/mantle-ui` and
|
|
@@ -68,7 +151,7 @@ and deployment; selected REST, MCP, public pages, publishing, translations and
|
|
|
68
151
|
media compose around the generated operations.
|
|
69
152
|
|
|
70
153
|
This is a breaking upgrade from 0.1.x: follow the [0.1-to-0.2 migration
|
|
71
|
-
guide](
|
|
154
|
+
guide](upgrade-0.1-to-0.2.md), use a new 0.2 database and explicitly move
|
|
72
155
|
data. From alpha.11, pin the three selected packages to 0.2.0, regenerate and
|
|
73
156
|
review owned output; the stable version commit changes release metadata and
|
|
74
157
|
documentation rather than adding another runtime API.
|
|
@@ -185,7 +268,7 @@ the native migration above supersede their runtime and CLI instructions.
|
|
|
185
268
|
|
|
186
269
|
0.2.0 replaces 0.1.x's grammar and composition; no stable 0.1.5 was released
|
|
187
270
|
(`0.1.5-alpha.1` was a prerelease). It breaks every consumer, and
|
|
188
|
-
`
|
|
271
|
+
`mantle help upgrade-0.1-to-0.2` is the guide for moving a project
|
|
189
272
|
by hand.
|
|
190
273
|
|
|
191
274
|
- **Manifests are `cms.mantle.aotter.net/v2`.** Views are one SQL `SELECT` and
|
|
@@ -5,11 +5,11 @@ migration tool and no in-place upgrade of a 0.1.x database: a coding agent
|
|
|
5
5
|
rebuilds the project on 0.2.0 and plans a reviewed data move for it.
|
|
6
6
|
|
|
7
7
|
1. **Rebuild the project on 0.2.0** with the current handbook: the
|
|
8
|
-
[0.2.0 release notes](
|
|
9
|
-
[native SDK migration](
|
|
10
|
-
the [CLI and generated ownership](
|
|
11
|
-
[app shell](examples/app-shell/) and the [Schema](
|
|
12
|
-
[View](
|
|
8
|
+
[0.2.0 release notes](index.md#upgrading-to-020) and the
|
|
9
|
+
[native SDK migration](index.md#native-sdk-migration-alpha7),
|
|
10
|
+
the [CLI and generated ownership](../start/project-and-cli.md), the
|
|
11
|
+
[app shell](../../examples/app-shell/) and the [Schema](../reference/schema.md),
|
|
12
|
+
[View](../reference/view.md) and [Procedure](../reference/procedure.md)
|
|
13
13
|
references. The application owns routing, Auth, native handles and database
|
|
14
14
|
migrations. Install the same exact version of `@aotter/mantle`,
|
|
15
15
|
`@aotter/mantle-ui` and, when selecting Admin, `@aotter/mantle-admin`.
|
|
@@ -44,18 +44,18 @@ for human review before it touches production data.
|
|
|
44
44
|
|
|
45
45
|
- **Through the SDK.** The generated `store(db, caller)`, or `ctx.store` in a
|
|
46
46
|
`ref` handler, with a trusted caller such as `{ kind: "system", reason }`
|
|
47
|
-
([authorization](
|
|
47
|
+
([authorization](../concepts/authorization.md)). It accepts no value
|
|
48
48
|
for `id`, `version`, `created_at`, `updated_at`, `author_id`, `status`,
|
|
49
49
|
`published_at` or the scope column, for any caller: it sets them itself, so new IDs, versions,
|
|
50
50
|
timestamps and authors replace the old ones. Publishing goes through the
|
|
51
51
|
generated `<schema>.publish` Procedure, which sets `published_at` to now
|
|
52
|
-
([lifecycle](
|
|
52
|
+
([lifecycle](../concepts/lifecycle-and-locales.md)). With new IDs,
|
|
53
53
|
remap every `x-mantle-ref`, every `translates.on` key and any ID embedded
|
|
54
54
|
in JSON; `x-mantle-ref` is not a foreign key, so a missed one dangles
|
|
55
55
|
quietly.
|
|
56
56
|
- **Through SQL**, to keep IDs, history and authors: `INSERT` the rows with
|
|
57
57
|
every native column set, as
|
|
58
|
-
[reserved entry columns](
|
|
58
|
+
[reserved entry columns](../reference/schema.md#reserved-entry-columns)
|
|
59
59
|
lists. This bypasses row policy, so review it like a migration.
|
|
60
60
|
|
|
61
61
|
### Entry columns on D1
|
|
@@ -86,7 +86,7 @@ for human review before it touches production data.
|
|
|
86
86
|
|
|
87
87
|
0.1.4 used Better Auth 1.7.2 with hand-written DDL; 0.2.0 uses 1.7.7, with the
|
|
88
88
|
tables `mantle generate --auth src/auth.ts` adds to `schema.sql`
|
|
89
|
-
([auth](
|
|
89
|
+
([auth](../cloudflare/authentication.md)).
|
|
90
90
|
|
|
91
91
|
- The 0.2 caller subject is the Better Auth `user.id`. Keep user IDs, so that
|
|
92
92
|
`author_id` and owner scopes still name the right people.
|
|
@@ -97,13 +97,13 @@ tables `mantle generate --auth src/auth.ts` adds to `schema.sql`
|
|
|
97
97
|
- 0.1.4 roles `owner`, `editor` and `contributor` have no 0.2 meaning. The
|
|
98
98
|
admin layer is Better Auth's admin plugin `adminRoles` (default
|
|
99
99
|
`["admin"]`) and `adminUserIds`
|
|
100
|
-
([authorization](
|
|
100
|
+
([authorization](../reference/authorization.md)); decide each mapping
|
|
101
101
|
deliberately.
|
|
102
102
|
- A 0.1.4 `githubLogin` column must be declared in `user.additionalFields`
|
|
103
103
|
to keep it.
|
|
104
104
|
- Leave sessions, verification rows and OAuth tokens behind; users sign in
|
|
105
105
|
again. Mantle re-creates its OAuth resource rows from configuration
|
|
106
|
-
([OAuth](
|
|
106
|
+
([OAuth](../guides/oauth.md)). Check `jwks`, OAuth clients and
|
|
107
107
|
consents against Better Auth 1.7.7 and your secrets and URLs before copying
|
|
108
108
|
any.
|
|
109
109
|
- The admin MCP endpoint moved from `/mcp/staff` to `/mcp/admin`; update MCP
|
|
@@ -115,7 +115,7 @@ tables `mantle generate --auth src/auth.ts` adds to `schema.sql`
|
|
|
115
115
|
epoch **milliseconds**. Copy the rows as they are.
|
|
116
116
|
- Each variant keeps its stored `storageKey` and `publicUrl`, so 0.1.x objects
|
|
117
117
|
in the same bucket keep working while their prefixes stay served
|
|
118
|
-
([media](
|
|
118
|
+
([media](../cloudflare/media-r2.md)).
|
|
119
119
|
- Do not carry over `pending_media_uploads`; an upload expires after 15
|
|
120
120
|
minutes.
|
|
121
121
|
- `site_config` keeps its `key`/`value` columns; compare its keys with the
|
|
@@ -256,7 +256,7 @@ Schema reference; do not repeat them.
|
|
|
256
256
|
| 0.1.x | 0.2.0 |
|
|
257
257
|
|---|---|
|
|
258
258
|
| builtin `create` | `handler: { sql: "INSERT INTO s (a, b) VALUES (input.a, input.b) RETURNING id" }` (on a `publishing` Schema the row starts as a draft, as before) |
|
|
259
|
-
| builtin `update` (always version-checked, merges over the stored row) | `UPDATE s SET a = COALESCE(input.a, a), … WHERE id = input.id AND version = input.expectedVersion`. Keep both: without the version the lock is lost; without `COALESCE` an omitted optional field is cleared. `COALESCE` also means `null` cannot clear a field; give clearing its own flag input ([clear flag](
|
|
259
|
+
| builtin `update` (always version-checked, merges over the stored row) | `UPDATE s SET a = COALESCE(input.a, a), … WHERE id = input.id AND version = input.expectedVersion`. Keep both: without the version the lock is lost; without `COALESCE` an omitted optional field is cleared. `COALESCE` also means `null` cannot clear a field; give clearing its own flag input ([clear flag](../guides/sql-patterns.md#change-only-the-fields-given-coalesce), [leave out, replace or clear](../guides/native-admin.md#leave-out-replace-or-clear)) |
|
|
260
260
|
| builtin `upsert` with `match` | `INSERT … ON CONFLICT (<match columns>) DO UPDATE SET x = EXCLUDED.x`; the conflict columns are a unique index; on a scoped Schema the scope field may be named or left out, Store adds it |
|
|
261
261
|
| builtin `delete` | `DELETE FROM s WHERE id = input.id AND version = input.expectedVersion` |
|
|
262
262
|
| builtin `archive` | a `ref` handler: `ctx.store.write([{ update: "s", set: { status: "archived" }, where: { id }, lock: expectedVersion }])` (SQL cannot set `status`) |
|
|
@@ -7,12 +7,14 @@ description: "The entry point `mantle help` prints first: choose a complete app
|
|
|
7
7
|
Topics are the handbook paths below (for example `guides/native-admin`) or their last segment when unique (`native-admin`).
|
|
8
8
|
The installed package's `docs/` is the source of every topic, so the text always matches the installed version.
|
|
9
9
|
|
|
10
|
+
Node 22.22 or newer. Pin every `@aotter/mantle*` package to one exact version.
|
|
11
|
+
|
|
10
12
|
## Choose how much Mantle owns
|
|
11
13
|
|
|
12
14
|
| You want | Do |
|
|
13
15
|
| --- | --- |
|
|
14
16
|
| A complete application | `mantle init [directory]`, then follow its `README.md`. It writes the app shell once: Better Auth email OTP with `admin` and `user`, the Admin console, MCP for both roles, REST, and a member `/sign-in` page. Existing files stop it; `--dry-run` lists what it would write. |
|
|
15
|
-
| Only typed SQL and bindings inside an app you already have | Skip `init`. Write manifests and run `mantle generate <target> <output-directory> <manifest>...`; see `mantle help project-and-cli` and
|
|
17
|
+
| Only typed SQL and bindings inside an app you already have | Skip `init`. Write manifests and run `mantle generate <target> <output-directory> <manifest>...`; see `mantle help project-and-cli` and [adopting Mantle in an existing app](../guides/typed-queries.md#adopt-mantle-in-an-existing-application). |
|
|
16
18
|
|
|
17
19
|
`init` writes the `cloudflare-d1` shell, the default target. `bun-sqlite`, `bun-postgres` and `cloudflare-postgres`
|
|
18
20
|
generate the same bindings; their app entry is yours (`mantle help service-entry`).
|
|
@@ -36,14 +38,33 @@ the app entry (`--entry`) never imports, it warns and names the topic that shows
|
|
|
36
38
|
canonical and Open Graph tags, JSON-LD and an answer block on detail pages, Markdown alternates, `/sitemap.xml`,
|
|
37
39
|
`/robots.txt` and `/llms.txt`. A brief that names a site, shop or catalogue for visitors includes all of them.
|
|
38
40
|
4. `pnpm generate`, implement every handler it lists, `pnpm check`, then `pnpm smoke`.
|
|
39
|
-
5.
|
|
41
|
+
5. **Show the user the wiring.** As soon as the manifests generate, run `pnpm accept --open`: it starts the app,
|
|
42
|
+
signs the admin in without a one-time code and opens the Developer UI (`/admin/dev`) in the user's browser, showing
|
|
43
|
+
the Schemas, Views, Procedures and Triggers and how they connect, with each surface's routes and tools. Tell the user
|
|
44
|
+
what they are looking at. Keep building while they look; the app rebuilds on every change. Without a browser on the
|
|
45
|
+
machine, give the user the admin URL it prints.
|
|
46
|
+
6. **Stop and ask before acceptance.** Propose the [acceptance plan](../guides/agent-workflow-acceptance.md#propose-the-run-first)
|
|
47
|
+
and wait for the user's go-ahead. Then run [role-only acceptance](../guides/agent-workflow-acceptance.md)
|
|
40
48
|
(`mantle help agent-workflow-acceptance`). Scripted smoke is not acceptance. `pnpm accept` starts the app and hands
|
|
41
49
|
each role to a fresh evaluator as a URL that carries that role's session. After a repair, the guide's
|
|
42
50
|
[re-verification rule](../guides/agent-workflow-acceptance.md#re-verify-what-a-repair-touches) decides which roles
|
|
43
51
|
and surfaces run again.
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
7. **Stop and ask before the performance pass.** For every role and surface acceptance reports CONVERGED, propose the
|
|
53
|
+
[performance plan](../guides/performance.md#propose-the-pass-first) (which parts run, how much test data, which
|
|
54
|
+
targets) and wait for the go-ahead; then run the [performance pass](../guides/performance.md). BLOCKED or UNVERIFIED
|
|
55
|
+
parts are reported as they are, never optimized. A declined step is reported as not run, never as done.
|
|
56
|
+
8. **Report what changed, not only that it passed:** the [acceptance summary](../guides/agent-workflow-acceptance.md#summarise-for-the-user)
|
|
57
|
+
and the [performance summary](../guides/performance.md#summarise-for-the-user), then the layered status.
|
|
46
58
|
|
|
47
59
|
The first verified sign-in with `ADMIN_EMAIL` becomes the admin. Further administrators are added in Admin:
|
|
48
60
|
**More → Administrators** invites by email, and **More → Members** grants Admin to an existing member.
|
|
49
61
|
[Authentication](../cloudflare/authentication.md#identity-helpers) documents the same operations as an API.
|
|
62
|
+
|
|
63
|
+
## Other tasks
|
|
64
|
+
|
|
65
|
+
| Task | Read |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Upgrade Mantle | [Upgrade an application](../releases/index.md#upgrade-an-application) |
|
|
68
|
+
| Deploy, only when the user asks | [Deploy and operate](../cloudflare/deploy-and-operate.md) |
|
|
69
|
+
| A slow page, first request or query | [Performance pass](../guides/performance.md) |
|
|
70
|
+
| Stale media uploads, only when the user asks | [Clean up stale uploads](../cloudflare/media-r2.md#clean-up-stale-uploads) |
|
|
@@ -3,7 +3,7 @@ description: Generate a small native D1 service and mount an application-owned W
|
|
|
3
3
|
---
|
|
4
4
|
# Quickstart: a service on Workers
|
|
5
5
|
|
|
6
|
-
Create an application outside the SDK checkout. Install `@aotter/mantle
|
|
6
|
+
Create an application outside the SDK checkout. Install one exact `@aotter/mantle` version ([Releases](../releases/index.md)), TypeScript, Wrangler and Cloudflare Worker types; `node_modules/@aotter/mantle/docs/examples/app-shell/package.json` lists the versions this release is tested with. Read that installed version's handbook; this page describes the native 0.2 contract.
|
|
7
7
|
|
|
8
8
|
Save `manifests/tickets.yaml`:
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aotter/mantle",
|
|
3
|
-
"version": "0.2.1-alpha.
|
|
3
|
+
"version": "0.2.1-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"engines": {
|
|
@@ -68,8 +68,7 @@
|
|
|
68
68
|
"./json-body": "./dist/kernel/json-body.js",
|
|
69
69
|
"./generate/auth": "./dist/infrastructure/generateAuth.js",
|
|
70
70
|
"./package.json": "./package.json",
|
|
71
|
-
"./describe": "./dist/domain/describe/
|
|
72
|
-
"./target-hash": "./dist/domain/describe/target-hash.js"
|
|
71
|
+
"./describe": "./dist/domain/describe/public.js"
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
75
74
|
"@modelcontextprotocol/server": "2.3.1",
|
package/skills/README.md
CHANGED
|
@@ -1,71 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mantle agent skill
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[`mantle`](mantle/SKILL.md) is the one consumer skill, shipped by the plugins and by `npx skills add aotter/mantle@mantle`.
|
|
4
|
+
Installation: [agent setup](../docs/handbook/guides/agent-setup.md).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
installed version. Nothing copies them into a project; 0.2 has no
|
|
11
|
-
`mantle skills` command.
|
|
12
|
-
|
|
13
|
-
| Skill | When to invoke |
|
|
14
|
-
|---|---|
|
|
15
|
-
| [`mantle`](mantle/SKILL.md) | Create or continue a Mantle application and deploy to a user-owned host. |
|
|
16
|
-
| [`develop`](../docs/skills/develop/SKILL.md) | Change manifests, SQL, handlers, the service entry or surfaces of an existing project. |
|
|
17
|
-
| [`integrate`](../docs/skills/integrate/SKILL.md) | Add Mantle to an application that has its own code, users or data, or rebuild one and migrate. |
|
|
18
|
-
| [`update`](../docs/skills/update/SKILL.md) | Upgrade `@aotter/mantle`, including from 0.1.x. |
|
|
19
|
-
| [`provision`](../docs/skills/provision/SKILL.md) | Ship to Cloudflare Workers or ChatGPT Sites with production sign-in. |
|
|
20
|
-
| [`media-gc`](../docs/skills/media-gc/SKILL.md) | Audit or remove stale, uncommitted R2 uploads. |
|
|
21
|
-
| [`performance`](../docs/skills/performance/SKILL.md) | Make an accepted app fast: Lighthouse, cold start, backend load, indexes and Views. Runs after acceptance converges. |
|
|
22
|
-
|
|
23
|
-
## Install
|
|
24
|
-
|
|
25
|
-
Use the [agent setup guide](../docs/handbook/guides/agent-setup.md) for Codex,
|
|
26
|
-
Claude Code, Cursor and GitHub Copilot. Pin the plugin checkout to the same
|
|
27
|
-
release tag as the application's SDK; alpha releases on `develop` can be newer
|
|
28
|
-
than the default `main` branch. For a skill-only installation:
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
npx skills add aotter/mantle@mantle
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Without a version it follows `main`, the latest stable release; pin the SDK's
|
|
35
|
-
release tag with `npx skills add aotter/mantle#v0.2.1-alpha.1@mantle`.
|
|
36
|
-
The explicit skill name (`@mantle`) excludes repository maintainer skills. The manifests
|
|
37
|
-
are generated by `scripts/sync-plugin-manifests.mjs` and checked with `--check`.
|
|
38
|
-
When upgrading, update the marketplace ref or local tagged checkout and refresh
|
|
39
|
-
the plugin. Verify the loaded manifest version; Claude Code's plugin version
|
|
40
|
-
is Core's, so packaged skill changes reach users through the next Core release.
|
|
41
|
-
|
|
42
|
-
## Disclosure audit
|
|
43
|
-
|
|
44
|
-
Every skill is one `SKILL.md`; the plugin skill carries local acceptance references.
|
|
45
|
-
`scripts/check-skills.mjs` holds this table, the front matter and the links to
|
|
46
|
-
each other: `metadata.projection` is `plugin` for `skills/mantle` and
|
|
47
|
-
`package` for `docs/skills/*`, a reason in the last column must equal
|
|
48
|
-
`metadata.projectionReason`, and a relative link must stay inside what ships
|
|
49
|
-
(the skill's own directory for the plugin, `docs/` for the package).
|
|
50
|
-
|
|
51
|
-
| Skill | Routes on | Entry constraints | Distribution | Restricted because |
|
|
52
|
-
|---|---|---|---|---|
|
|
53
|
-
| `mantle` | new project, existing project, self-host deployment | the installed package's docs win; never use the SDK checkout as the application; no deploy during a cold start | plugin | The plugin's authoring entry skill is installed from the repository; workflow documentation comes from the installed SDK package. |
|
|
54
|
-
| `develop` | manifest, SQL, handler, service or surface work | read the installed version first; never edit generated files; writes through Store/Procedures, richer reads through internal Views | package | — |
|
|
55
|
-
| `integrate` | an application with its own code, users or data | inspect before choosing; the application keeps its users; one writer per table | package | — |
|
|
56
|
-
| `update` | an SDK upgrade | never overwrite application files; 0.1.x moves by the upgrade guide to a new database | package | — |
|
|
57
|
-
| `provision` | ship to production | secrets never in source, chat or logs; a new database for 0.2; self-hosting is always an option | package | Creates remote resources and handles production secrets; opt-in only. |
|
|
58
|
-
| `media-gc` | stale R2 uploads | audit by default; exact keys only, never a prefix delete; re-audit before applying | package | Destructive remote object deletion and Cloudflare-specific; opt-in only. |
|
|
59
|
-
| `performance` | converged acceptance, a slow page, first request or query | accepted behavior only; never trade scope, authorization, OCC or atomicity for speed; local unless deployment is authorized | package | — |
|
|
60
|
-
|
|
61
|
-
## Audience
|
|
62
|
-
|
|
63
|
-
These are for **AI agents acting for consumers of Mantle**, not for
|
|
64
|
-
contributors to the SDK, who read the repository's `CONTRIBUTING.md`.
|
|
65
|
-
|
|
66
|
-
## Conventions
|
|
67
|
-
|
|
68
|
-
Each SKILL.md has front matter (`name`, a trigger-complete `description`,
|
|
69
|
-
`metadata.source`, `sourcePath`, `applies_to`, `projection`), the reads to do
|
|
70
|
-
first, concrete commands, the rules an agent must not break, and what to report
|
|
71
|
-
when done. Commands and prose match the package version that carries the skill.
|
|
6
|
+
The skill only routes to `mantle help`, which prints the installed package's handbook. It holds no contract, version
|
|
7
|
+
number or workflow detail of its own, so it never drifts from the SDK an application pins: put any rule an agent must
|
|
8
|
+
follow in the handbook instead. `scripts/check-skills.mjs` enforces that this is the only skill, its front matter, a
|
|
9
|
+
line budget, no version strings, and that every `mantle help <topic>` it names exists.
|
package/skills/mantle/SKILL.md
CHANGED
|
@@ -1,90 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mantle
|
|
3
|
-
description: Create, continue, test or deploy a Mantle application
|
|
3
|
+
description: Create, continue, upgrade, test, speed up or deploy a Mantle application (@aotter/mantle manifests, SQL Views and Procedures, MCP, REST, Admin, mantle generate). Every contract comes from the installed version's `mantle help`.
|
|
4
4
|
metadata:
|
|
5
5
|
source: "@aotter/mantle"
|
|
6
6
|
sourcePath: skills/mantle/SKILL.md
|
|
7
|
-
applies_to: mantle 0.2
|
|
8
|
-
projection: plugin
|
|
9
|
-
projectionReason: The plugin's authoring entry skill is installed from the repository; workflow documentation comes from the installed SDK package.
|
|
10
7
|
---
|
|
11
8
|
|
|
12
9
|
# Mantle
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
entry page
|
|
25
|
-
and
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Find the project and its version
|
|
29
|
-
|
|
30
|
-
Work in the user's application, outside the SDK checkout. Read package.json, the lockfile, installed SDK README and node_modules/@aotter/mantle/docs/. Those files define the exact version's contract. Preserve existing identity, handles, routes and resources.
|
|
31
|
-
For existing older applications, use their installed docs until the user requests an upgrade; if an older version
|
|
32
|
-
lacks a guide named here, record the missing guidance and keep that version's contract.
|
|
33
|
-
|
|
34
|
-
## Choose the installed package skill
|
|
35
|
-
|
|
36
|
-
- Read `node_modules/@aotter/mantle/docs/skills/develop/SKILL.md` to change an existing project's manifests, SQL, handlers, service entry or surfaces.
|
|
37
|
-
- Read `node_modules/@aotter/mantle/docs/skills/integrate/SKILL.md` to add Mantle to an application with existing code, users or data.
|
|
38
|
-
- Read `node_modules/@aotter/mantle/docs/skills/update/SKILL.md` to upgrade Mantle, including from 0.1.x.
|
|
39
|
-
- Read `node_modules/@aotter/mantle/docs/skills/provision/SKILL.md` only for an authorized production deployment.
|
|
40
|
-
- Read `node_modules/@aotter/mantle/docs/skills/media-gc/SKILL.md` only to audit or remove stale uncommitted media uploads.
|
|
41
|
-
- Read `node_modules/@aotter/mantle/docs/skills/performance/SKILL.md` after acceptance converges, or when a page, first request or query is slow.
|
|
42
|
-
|
|
43
|
-
## New application
|
|
44
|
-
|
|
45
|
-
Node must be 22.22 or newer. Stable 0.2.0 is available as `@aotter/mantle@0.2.0`; pin selected Mantle packages to that exact version. Create it with `npx @aotter/mantle@<exact version> init <directory>`, then follow
|
|
46
|
-
`mantle help` ("Build from a product brief") and the app's `README.md`. Without the user listing them, a complete app
|
|
47
|
-
includes:
|
|
48
|
-
|
|
49
|
-
- Email OTP sign-in, the two roles `admin` and `user`, Admin for `admin`, MCP for both roles (`/mcp`, `/mcp/admin`)
|
|
50
|
-
and REST: the shell already wires them; keep them.
|
|
51
|
-
- Real business rules in SQL Procedures (`mantle help sql-patterns`), not in handler code around separate writes.
|
|
52
|
-
- For visitor pages, everything in `mantle help public-pages` (SEO, AEO, sitemap, robots, `llms.txt`), styled.
|
|
53
|
-
- Local HTTP checks (`mantle help local-testing`), then independent acceptance with `pnpm accept`
|
|
54
|
-
(`mantle help agent-workflow-acceptance`), then the installed `docs/skills/performance/SKILL.md`.
|
|
55
|
-
|
|
56
|
-
Take patterns from `mantle help examples` into the app's own manifests and `src/`; do not copy an example directory
|
|
57
|
-
over the app. Resolve each `AGENT:` or name the ones you left. Generation only, inside an app you already have: skip
|
|
58
|
-
`init` and use `mantle generate` (`mantle help project-and-cli`).
|
|
59
|
-
|
|
60
|
-
## Accept before reporting done
|
|
61
|
-
|
|
62
|
-
Before reporting any new app or feature as done, follow `mantle help agent-workflow-acceptance`: a private rubric,
|
|
63
|
-
then one fresh agent per role given only its role and the URLs `pnpm accept` prints, at most three rounds. The first
|
|
64
|
-
delivery covers every role and surface; after a repair, the guide's "Re-verify what a repair touches" rule decides what
|
|
65
|
-
re-runs: a page-only repair re-runs the affected UI, while auth, scope, SQL Procedure, unique index or shared-transport changes widen
|
|
66
|
-
to every surface they reach. State the round and revision of any evidence you reuse. If it was
|
|
67
|
-
not run, report the work as UNVERIFIED rather than done; if it could not run, BLOCKED. Report status per layer as that
|
|
68
|
-
guide's "Report done-ness in layers" defines; a block from your environment (approval policy, missing browser,
|
|
69
|
-
network) is BLOCKED on its layer, not a product failure, and does not discard the other layers.
|
|
70
|
-
|
|
71
|
-
Once acceptance is CONVERGED, read the installed `docs/skills/performance/SKILL.md`: it decides which of front end,
|
|
72
|
-
cold start and backend load apply, and runs them before you report done. This is the one exception to installed docs
|
|
73
|
-
winning: if the installed package predates that skill, read
|
|
74
|
-
[the 0.2.1 copy](https://github.com/aotter/mantle/blob/v0.2.1/docs/skills/performance/SKILL.md) and the pages it links
|
|
75
|
-
from the installed docs with `mantle help <topic>`.
|
|
76
|
-
|
|
77
|
-
## Deployment
|
|
78
|
-
|
|
79
|
-
Deploy only when the user requests it, following the installed `docs/skills/provision/SKILL.md` and the selected
|
|
80
|
-
host's native workflow. Local project creation alone is not deployment authorization.
|
|
81
|
-
|
|
82
|
-
## Existing project and handoff
|
|
83
|
-
|
|
84
|
-
Preserve the user's manifests, `src/` files, identity, package versions and provider resources. Run the project's
|
|
85
|
-
generate command with `--check` and its own tests before and after a change.
|
|
86
|
-
|
|
87
|
-
Report the project path, the exact Mantle version, what you changed, the four-layer status with each layer's checks
|
|
88
|
-
and results (the independent acceptance verdict, CONVERGED / BLOCKED / UNVERIFIED, is layer 3), the performance verdict
|
|
89
|
-
(PASS / PARTIAL / SKIPPED) with its before and after numbers, and anything left for the user, including what would
|
|
90
|
-
unblock a BLOCKED layer.
|
|
11
|
+
This skill only routes; it holds no contract. The installed `@aotter/mantle` is the authority, and `mantle help` prints
|
|
12
|
+
its docs one topic at a time.
|
|
13
|
+
|
|
14
|
+
1. **Start with `mantle help`.** In a project run `npx mantle help`; before one exists, `npx @aotter/mantle@<exact
|
|
15
|
+
version> help`. It prints the entry page (how to choose, build and accept); `mantle help <topic>` prints one page and
|
|
16
|
+
ends with the commands for the pages it links. `mantle help topics` lists them all. For a new app, do every step of its
|
|
17
|
+
"Build from a product brief". Follow it rather than this file, an SDK checkout or an online copy.
|
|
18
|
+
2. **Work in the user's application.** Read its `package.json` and lockfile for the exact Mantle version and keep using
|
|
19
|
+
that version's docs until the user asks to upgrade (`mantle help releases/index`). Preserve existing code, identity,
|
|
20
|
+
versions and resources.
|
|
21
|
+
3. **Stop for the user at the entry page's checkpoints:** show the running Admin and its Developer UI once the manifests
|
|
22
|
+
generate, and ask before acceptance and before the performance pass. Never report done without them; end with what
|
|
23
|
+
each one found and changed, and each layer as CONVERGED, BLOCKED or UNVERIFIED.
|
|
24
|
+
4. **Deploy, delete remote data or publish nothing unless the user asks for that exact action.**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{canonical,hash,hashDefinition,targetHash}from"./chunk-P6PP6VVV.js";export{canonical,hash,hashDefinition,targetHash};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: develop
|
|
3
|
-
description: Work on an existing Mantle 0.2 project — manifests, SQL Views and Procedures, ref handlers, the service entry, surfaces, identity, MCP tool design and independent acceptance — using the installed package's contract.
|
|
4
|
-
metadata:
|
|
5
|
-
source: "@aotter/mantle"
|
|
6
|
-
sourcePath: docs/skills/develop/SKILL.md
|
|
7
|
-
applies_to: mantle 0.2
|
|
8
|
-
projection: package
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Mantle Develop
|
|
12
|
-
|
|
13
|
-
## Workflow
|
|
14
|
-
|
|
15
|
-
Read the installed SDK README, then follow the version-matched [project and CLI
|
|
16
|
-
workflow](../../handbook/start/project-and-cli.md) before editing.
|
|
17
|
-
|
|
18
|
-
Use the native Store/query/surface entries and app-owned fetch from the [service
|
|
19
|
-
composition guide](../../handbook/cloudflare/service-entry.md).
|
|
20
|
-
Pair every HTTP Trigger with an MCP Trigger by default; see [Trigger](../../handbook/reference/trigger.md)
|
|
21
|
-
for the generate warning and deliberate asymmetry exception.
|
|
22
|
-
Keep optional modules out of unused entry imports and auth dynamically loaded.
|
|
23
|
-
Run actual public/member/admin HTTP, MCP and UI scenarios; verify stored state,
|
|
24
|
-
visibility, OCC and restart persistence, not just a 200 response.
|
|
25
|
-
Before reporting any new app or feature as done, follow the [independent
|
|
26
|
-
acceptance guide](../../handbook/guides/agent-workflow-acceptance.md): write a
|
|
27
|
-
private rubric, then give one fresh agent per role (`admin`, `user`) only its
|
|
28
|
-
role and entry points, across every surface it uses. After a repair, re-run
|
|
29
|
-
the scope its [re-verification
|
|
30
|
-
rule](../../handbook/guides/agent-workflow-acceptance.md#re-verify-what-a-repair-touches)
|
|
31
|
-
names and state which evidence you reused. This is not limited to
|
|
32
|
-
MCP; if it was not run, say so explicitly and report the work as UNVERIFIED
|
|
33
|
-
rather than done. Hand off with the guide's [layered
|
|
34
|
-
report](../../handbook/guides/agent-workflow-acceptance.md#report-done-ness-in-layers):
|
|
35
|
-
an environment block is BLOCKED on its layer, never a product failure. For MCP workflows, also run the guide's design audit before implementing
|
|
36
|
-
tools. Once acceptance converges, follow the [performance skill](../performance/SKILL.md) before reporting done.
|
|
37
|
-
|
|
38
|
-
For native Admin, read the [current guide](../../handbook/guides/native-admin.md):
|
|
39
|
-
the app builds Admin with `mantle bundle`. To customise pages, slots, hooks or
|
|
40
|
-
MCP-host-safe components, follow [Customising Admin](../../handbook/guides/native-admin.md#customising-admin).
|
|
41
|
-
Custom structured inputs and browser pages can use the optional
|
|
42
|
-
`@aotter/mantle-admin/media` controlled `MediaPicker`: pass `readOnly` and an exact
|
|
43
|
-
`uploadPurpose` (omit for selection only), apply `onSelect` to the local draft,
|
|
44
|
-
and keep its import out of the MCP App entry. See the native Admin media example.
|
|
45
|
-
Keep matching SDK, Admin and UI versions. Ref handlers retain caller-bound
|
|
46
|
-
`ctx.store`; generic Admin reads use shared generated View templates and writes
|
|
47
|
-
use native Procedure fragments.
|
|
48
|
-
Check actual member/Admin OTP, private scope/TTL/translation visibility, paging,
|
|
49
|
-
statistics, safe/exact OCC and no automatic retry after unknown 503 outcomes.
|
|
50
|
-
|
|
51
|
-
For application-owned MCP App entries and host checks, follow the [MCP Apps
|
|
52
|
-
guide](../../handbook/guides/mcp-apps.md).
|
|
53
|
-
|
|
54
|
-
Build a custom frontend with `App` from `@modelcontextprotocol/ext-apps`: register
|
|
55
|
-
`ontoolinput`/`ontoolresult` before `connect()`, and use `callServerTool` for
|
|
56
|
-
host-proxied calls. Keep protocol negotiation and message routing in the official
|
|
57
|
-
client; importing its types while writing a second `postMessage` bridge is
|
|
58
|
-
insufficient.
|
|
59
|
-
|
|
60
|
-
For Admin UI upgrades, follow the installed handbook's
|
|
61
|
-
[retained-page recipe](../../handbook/guides/mcp-apps.md#keep-old-conversations-working-after-an-upgrade).
|
|
62
|
-
Keep deployed snapshots in source/artifact storage and pass `previous` to
|
|
63
|
-
`adminMcpApps`; verify old conversations after a changed UI build without host
|
|
64
|
-
tool refresh, reconnection or cache clearing. Keep tool contracts compatible
|
|
65
|
-
through the declared retention window.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Place admin MCP Procedures in Admin deliberately: `spec.uiSchema.collectionAction:
|
|
69
|
-
<schema-name>` adds a collection-header action; `spec.target: { schema, id,
|
|
70
|
-
version? }` selects row actions and binds the row id / reviewed OCC version to
|
|
71
|
-
the named inputs. Other admin operations appear under Operations in the sidebar.
|
|
72
|
-
Keep state conditions in the SQL WHERE: simple AND equality/IN literals become
|
|
73
|
-
row-menu hints, while the Procedure remains the authority. Required-ref child
|
|
74
|
-
collections fold under their parent's sidebar group; with two or more required
|
|
75
|
-
`id` refs, set Schema `uiSchema.nav.parentField` to the parent's ref (generate
|
|
76
|
-
refuses otherwise); use `uiSchema.nav.standalone: true` for a top-level entry.
|
|
77
|
-
|
|
78
|
-
## Database changes
|
|
79
|
-
|
|
80
|
-
The runtime never creates, alters or checks tables. Boot and requests run no DDL, introspection or schema checks.
|
|
81
|
-
|
|
82
|
-
For the first install, apply generated `schema.sql`, including selected auth/site DDL, to an empty database. Apply selected seed SQL explicitly.
|
|
83
|
-
|
|
84
|
-
For every later schema change, the application's coding agent diffs the regenerated `schema.sql`, writes a migration with the host's native tool (`wrangler d1 migrations` or the app's PostgreSQL migration tool), rehearses it on a copy, and applies it before deploying the new code.
|
|
85
|
-
|
|
86
|
-
Destructive changes and type changes need explicit data migration. Mantle drops nothing. Initial `schema.sql` is not an upgrade script.
|
|
87
|
-
|
|
88
|
-
## Data paths
|
|
89
|
-
|
|
90
|
-
Writes use Store `insert` / `update` / `delete`, `batch`, `transaction`, or declared Procedures. Never use raw SQL writes: they bypass scope, TTL, publishing and system-column rules. For reads beyond an id lookup or simple AND filter (joins, aggregates, OR, reuse), declare an internal View so the SQL is reviewable and typed. Store `findById`, `find` and `first` remain suitable for handler lookups and embedding in an existing app. Ref handlers receive `ctx.store` bound to the same Caller and transaction.
|
|
91
|
-
|
|
92
|
-
For published-content replacement with preview and rollback, follow `mantle help revisions`: Core supplies OCC, Schema locks and atomic `store.batch`; the recipe binds the previewed revision ID/version and atomically seals it while switching the parent. Applications own retention and review policy; Core does not mandate a preparation step. Keep the previewed version on submit and require another preview after a revision conflict.
|
|
93
|
-
Use its custom Native Admin preview/switch page: freeze the reviewed content and both row versions, then submit them through the authorized operation. Do not make editors copy version numbers or silently replace the reviewed snapshot after a refresh; conflicts require another explicit preview.
|
|
94
|
-
|
|
95
|
-
For simple creates/partial updates, prefer Store-backed ref Procedures; keep
|
|
96
|
-
Procedure `requires`/generated input checks, use only allowed patch fields and
|
|
97
|
-
return safe business fields with the actual returned ID/version. Preserve
|
|
98
|
-
omitted fields and document null semantics. Retain SQL for atomic conditional
|
|
99
|
-
or related writes; D1 batches cannot consume an earlier result. Follow the
|
|
100
|
-
[Store write guidance](../../handbook/guides/typed-queries.md#prefer-store-backed-ref-procedures-for-simple-writes).
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: integrate
|
|
3
|
-
description: Add Mantle 0.2 to an existing application, or rebuild one on Mantle and migrate its data. Use when the application already has its own code, routes, users, storage or deployment.
|
|
4
|
-
metadata:
|
|
5
|
-
source: "@aotter/mantle"
|
|
6
|
-
sourcePath: docs/skills/integrate/SKILL.md
|
|
7
|
-
applies_to: mantle 0.2
|
|
8
|
-
projection: package
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Integrate Mantle into an existing application
|
|
12
|
-
|
|
13
|
-
## Workflow
|
|
14
|
-
|
|
15
|
-
Read the installed SDK README, then follow the version-matched [project and CLI
|
|
16
|
-
workflow](../../handbook/start/project-and-cli.md) before editing.
|
|
17
|
-
|
|
18
|
-
Keep the application router, database/pool, identity and frontend. Replace
|
|
19
|
-
Core consumers explicitly and compose only selected generated entries. Resolve
|
|
20
|
-
one Caller per request with the shared cookie-session origin check. Rehearse
|
|
21
|
-
data-preserving schema/auth/role migrations on a copy and retain rollback artifacts.
|
|
22
|
-
Initial schema.sql is for an empty database, not an in-place upgrade. Requests run
|
|
23
|
-
no DDL or storage checks; the only request-time write outside app operations is
|
|
24
|
-
the configured OAuth resource row (see [OAuth](../../handbook/guides/oauth.md)).
|
|
25
|
-
Verify cutover with actual app tests. Before reporting user-facing work done, run
|
|
26
|
-
[independent acceptance](../../handbook/guides/agent-workflow-acceptance.md), then the
|
|
27
|
-
[performance skill](../performance/SKILL.md).
|
|
28
|
-
|
|
29
|
-
Preserve the app router, verified identity and native resources. For selected
|
|
30
|
-
Admin, follow the [native guide](../../handbook/guides/native-admin.md) for its
|
|
31
|
-
application-built bundle and service composition.
|
|
32
|
-
Do not import old `/spec`, `/core` or runtime surface APIs. Review data/role
|
|
33
|
-
migrations explicitly; full cross-target int64 parity and automated transfer
|
|
34
|
-
are not this release's upgrade contract.
|
|
35
|
-
|
|
36
|
-
## Partial adoption in TypeScript/Node
|
|
37
|
-
|
|
38
|
-
Keep the app's router, pool/handle, identity and frontend. Declare only the Schemas and operations being adopted; import selected `views/<encoded-name>.ts` or `procedures/<encoded-name>.ts`, then call `(appHandle, verifiedCaller, validatedInput)`. Bun.SQL and postgres.js fit directly; [node-postgres can adapt](../../handbook/guides/postgres-adapters.md). No Admin/auth/surface module is required for direct queries.
|
|
39
|
-
|
|
40
|
-
Existing tables need explicit migration into the declared storage shape, including system columns and constraints. Initial schema.sql must not be applied over an occupied database. Rehearse on a copy and test scope, TTL, publication, OCC and persisted state with the app's own identity.
|
|
41
|
-
|
|
42
|
-
Writes use Store or declared Procedures; never raw SQL writes to adopted collections. Use internal Views for joins, aggregates, OR and reusable reads. Store findById/find/first remain useful for simple AND lookups in existing handlers.
|
|
43
|
-
|
|
44
|
-
Direct declared Schema-column outputs in Views and SQL Procedure `RETURNING`
|
|
45
|
-
keep their authored field names; explicit aliases keep SQL casing rules. Store
|
|
46
|
-
rows and nested SQL relations use storage names. Boundary validators support a
|
|
47
|
-
permissive `format: email` check (one `@`, non-empty parts, no whitespace). For
|
|
48
|
-
LEFT JOIN paging, join on the joined Schema's id or single-field unique key and
|
|
49
|
-
keep the base indexed, non-null order/id tuple. Generation always emits `Handlers`
|
|
50
|
-
(empty without ref Procedures); pass `handlers` at `adminBindings()`, generated REST/MCP options and
|
|
51
|
-
`webmcpRoutes(catalogue, tools, handlers)`, as the app shell does.
|