@mortar-ai/skill 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,8 +34,11 @@ experience.
34
34
  The skill teaches Claude:
35
35
 
36
36
  - **Core contract** — Fabric-owned client/config files, schema-first workflow,
37
- one migration operation per call, supported migration kinds, access-policy
38
- invariants, version boundaries, and completion checks.
37
+ real versioned SQL plan/apply, supported DDL, access-policy invariants,
38
+ OpenAPI-driven application code, version boundaries, and completion checks.
39
+ - **OpenAPI reference** — the canonical Mortar REST contract is mirrored from
40
+ `mortar/docs/public/openapi.yaml` for on-demand operation/schema lookup; the
41
+ AI Turn writes project-language request and response code through Harness.
39
42
  - **Database reference** — CRUD, filters, atomic row mutations, trusted
40
43
  cross-table transactions, and ACID boundaries.
41
44
  - **Auth reference** — email/password, phone OTP, sessions, password reset, and
@@ -69,9 +72,11 @@ Idempotent — overwrites in place.
69
72
 
70
73
  ## Maintainer release
71
74
 
72
- `SKILL.md` and `references/` are the hand-edited instruction sources. Keep the
73
- core short and move capability detail into a routed reference. Regenerate the
74
- manifest and Harness copy before testing or publishing:
75
+ `SKILL.md` and the Markdown files in `references/` are the hand-edited
76
+ instruction sources. `references/openapi.yaml` is generated from the canonical
77
+ `mortar/docs/public/openapi.yaml`; never edit the mirror directly. Keep the core
78
+ short and move capability detail into a routed reference. Regenerate the
79
+ manifest, OpenAPI mirror, and Harness copy before testing or publishing:
75
80
 
76
81
  ```bash
77
82
  npm run sync
package/SKILL.md CHANGED
@@ -28,9 +28,10 @@ itself does not run on Mortar. Do not infer its setup from another BaaS.
28
28
  import { mortar } from '../../utils/mortar/client';
29
29
  ```
30
30
 
31
- - `src/integrations/mortar/client.ts`, its `types.ts`, and the WeChat equivalents
32
- under `utils/mortar/` are platform-owned. Never create, overwrite, or replace
33
- them.
31
+ - `src/integrations/mortar/client.ts`, its compatibility `types.ts`, and the
32
+ WeChat equivalents under `utils/mortar/` are platform-owned wiring. Never
33
+ create, overwrite, or replace them. Generate application-owned request,
34
+ response, and domain types in ordinary project paths for the current runtime.
34
35
  - Never add `VITE_MORTAR_*`, `MORTAR_URL`, or client-side API-key environment
35
36
  variables. Never hand-write `createClient(...)`, `src/lib/mortar.ts`, or a
36
37
  second wrapper/client in a Fabric project.
@@ -52,31 +53,52 @@ below; if platform provisioning fails, report that platform failure.
52
53
 
53
54
  1. Call `mortar_schema` before designing or changing backend data. It returns
54
55
  the current live schema, including console changes.
55
- 2. For each schema change, call `mortar_migrate` once with one operation. It
56
- applies the live change first; only after success does Fabric append a
57
- migration record under `mortar/migrations/`.
58
- 3. `mortar/migrations/` is a platform-owned output journal. Never create or edit
59
- SQL there: a file in that directory does not execute or change the live
60
- tenant. Do not edit or create `mortar.config.json`. Do not edit generated
61
- `integrations/mortar/types.ts`; Fabric regenerates it from the live schema.
62
- 4. Install or update `@mortar-ai/client` with npm when needed and let npm own the
56
+ 2. Author database schema as exact Mortar logical SQL and submit `{ name, sql }`
57
+ to `mortar_migrate`. Fabric asks Mortar to parse a language-neutral typed
58
+ plan, applies the workspace review policy, writes those exact bytes under
59
+ `mortar/migrations/` with source-revision CAS, then Mortar re-verifies the
60
+ checksum and expected schema revision and commits the whole plan atomically.
61
+ 3. Use `mortar_resource` for non-database desired state. Function source and its
62
+ manifest live under `mortar/functions/<name>/`; bucket policy lives under
63
+ `mortar/storage/buckets/`; cron schedules live under `mortar/cron/`. Fabric
64
+ writes the approved artifact before reconciling the live resource.
65
+ 4. These source directories are platform-protected because direct edits would
66
+ bypass plan/apply. Submit the exact source through the matching tool; do not
67
+ edit or create `mortar.config.json`. Mortar returns contracts and live state,
68
+ never generated project files. The AI Turn owns runtime-specific app models
69
+ and request/response code through Harness; do not call or invent a Mortar
70
+ source-code-generation endpoint.
71
+ 5. Before writing application request/response code, locate the relevant
72
+ `operationId` in `references/openapi.yaml`, read its request, response, error,
73
+ security, and `x-mortar-trust-surface` fields, and combine that contract with
74
+ `mortar_schema` plus the project's language and conventions. Never expose an
75
+ operation marked `x-mortar-project-code: forbidden` in an app bundle.
76
+ 6. Install or update `@mortar-ai/client` with npm when needed and let npm own the
63
77
  lockfile. Atomic batches, server-side filtered mutations, and
64
78
  `DatabaseTransactions` require version 0.8.0 or newer. Do not rewrite
65
79
  unrelated dependencies.
66
- 5. Before a multi-step mutation, choose the real consistency boundary. A
80
+ 7. Before a multi-step mutation, choose the real consistency boundary. A
67
81
  one-table batch or filtered mutation may use the public singleton;
68
82
  cross-table row + queue transactions require trusted server code; object
69
83
  storage and external services never join a PostgreSQL transaction.
70
- 6. Type-check and build. Handle every `{ data, error }` SDK result in UI code.
71
-
72
- Supported migration kinds are `create_table`, `drop_table`, `set_table_access`,
73
- `add_column`, `drop_column`, `create_index`, `set_bucket_access`,
74
- `deploy_function`, `delete_function`, `upsert_cron`, and `delete_cron`.
75
- Destructive and backend-changing operations must respect the workspace approval
76
- gate. This list is exhaustive: arbitrary PostgreSQL, data backfills, PL/pgSQL
77
- functions, transactions, and triggers are not migration inputs. If required
78
- behavior cannot be expressed by one of these operations, report the unsupported
79
- Mortar capability instead of authoring a SQL file that only looks executable.
84
+ 8. Type-check and build. Handle every `{ data, error }` SDK result in UI code.
85
+
86
+ Supported database DDL is `CREATE TABLE`, `DROP TABLE`, `ALTER TABLE … ADD/DROP
87
+ COLUMN`, `ALTER TABLE … SET ACCESS`, and `CREATE INDEX`. Put
88
+ `-- mortar:access public_insert` (or another access mode) immediately before a
89
+ `CREATE TABLE` when the default `public_read` is wrong. Resource kinds are
90
+ `set_bucket_access`, `deploy_function`, `delete_function`, `upsert_cron`, and
91
+ `delete_cron`; they belong to `mortar_resource`, never SQL. Destructive and
92
+ backend-changing operations respect the workspace approval gate. Arbitrary
93
+ PostgreSQL, `DEFAULT`, `UNIQUE`, `CHECK`, foreign keys, data backfills, PL/pgSQL,
94
+ transactions, and triggers are not inputs.
95
+
96
+ Every row already has server-owned `id`, `created_at`, and `updated_at`
97
+ metadata. Do not declare those names as application columns or send them in
98
+ ordinary insert/update payloads; only pass `id` as row identity through the
99
+ documented upsert contract. They are flattened into SDK results and may be used
100
+ for ordering or indexes. Today, `NOT NULL` enforces payload presence; logical
101
+ type names guide application types but do not runtime-validate payload values.
80
102
 
81
103
  ## Access and safety invariants
82
104
 
@@ -90,6 +112,11 @@ Mortar capability instead of authoring a SQL file that only looks executable.
90
112
  - Generate an unguessable logical object key for each public upload.
91
113
  - Client-side filters are UX, not authorization. Choose a server-enforced access
92
114
  policy for private or owner-scoped rows.
115
+ - Client validation and an in-flight submit guard are UX, not server validation
116
+ or retry-safe idempotency. Public row insert has no idempotency key or durable
117
+ uniqueness constraint. Never claim direct insert is exactly-once; when the
118
+ product requires durable deduplication, use a reviewed server-side contract
119
+ that actually implements it or state the limitation.
93
120
  - Never put `app` or `admin` keys, `DatabaseTransactions`, operator clients, or
94
121
  other privileged capabilities in Web, Desktop renderer, Keel/React Native, or
95
122
  WeChat bundles.
@@ -105,6 +132,12 @@ Agent Skills hosts resolve the same paths relative to this `SKILL.md`.
105
132
 
106
133
  - Database CRUD, atomic row mutations, trusted cross-table transactions, and
107
134
  exact ACID boundaries: `references/database.md`
135
+ - Versioned SQL syntax, checksums/revisions, resource artifact layout, AI-owned
136
+ application types, legacy migrations, and the complete capability-to-source matrix:
137
+ `references/schema-migrations.md`
138
+ - The authoritative Mortar REST contract used to generate project-language
139
+ request/response code: `references/openapi.yaml`. Search by `operationId` and
140
+ read only the selected operation plus its referenced component schemas.
108
141
  - App-user signup/signin, OTP, session lifecycle, and private-user modeling:
109
142
  `references/auth.md`
110
143
  - Upload/download/list/signed URLs, immutable object versions, CORS, and
@@ -138,8 +171,18 @@ sed -n '1,240p' /tmp/skills/mortar/references/storage.md
138
171
  ## Completion checklist
139
172
 
140
173
  - Live schema was read before schema design.
141
- - Every live schema change went through one approved `mortar_migrate` operation.
174
+ - Every database schema change used reviewed exact SQL through `mortar_migrate`;
175
+ every function/bucket/cron change used `mortar_resource`.
142
176
  - Application code imports only the platform-owned singleton.
177
+ - Application request/response and domain types were written by the AI in
178
+ ordinary project source after consulting the relevant OpenAPI operations and
179
+ live schema; Mortar did not return generated source files. Model real
180
+ boundaries (for example form input versus persisted data) and reuse
181
+ SDK-inferred response types when sufficient instead of adding ceremonial
182
+ duplicate aliases.
183
+ - Application payloads do not redeclare or send server-owned row metadata, and
184
+ the UI does not overclaim client validation or duplicate suppression as a
185
+ durable backend guarantee.
143
186
  - No secret/admin client or hand-written fallback configuration entered the
144
187
  client bundle.
145
188
  - Every SDK error path is handled.
package/manifest.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "id": "mortar",
4
- "version": "0.5.0",
5
- "content_sha256": "sha256:cbfe4219fa15934c523c1c22fe9795489539d0083d199624d2d15ac50bfe7755",
4
+ "version": "0.7.0",
5
+ "content_sha256": "sha256:ec235e0f2e9c38e64ab906c8daca2daa98482313a4004fd1a73bc30f17671487",
6
6
  "source_repo": "liamxujia/appunvs",
7
7
  "source_path": "mortar/skill",
8
8
  "distributions": [
@@ -11,6 +11,6 @@
11
11
  ],
12
12
  "npm": {
13
13
  "package": "@mortar-ai/skill",
14
- "version": "0.5.0"
14
+ "version": "0.7.0"
15
15
  }
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mortar-ai/skill",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Agent skill package for building Fabric applications on Mortar (BaaS), with compact core guidance and on-demand references.",
5
5
  "main": "index.js",
6
6
  "files": ["SKILL.md", "references", "manifest.json", "index.js", "README.md"],
@@ -21,8 +21,8 @@ module, not a closed product taxonomy. A capability may span multiple
21
21
  application, primitive, account, or API packages, and one application module
22
22
  may support several capabilities.
23
23
 
24
- The current application modules are `auth`, `cron`, `data`, `files`, `queue`,
25
- `realtime`, and `secret`. Functions, comms, analytics,
24
+ The current application modules are `auth`, `cron`, `data`, `files`,
25
+ `migration`, `queue`, `realtime`, and `secret`. Functions, comms, analytics,
26
26
  accounts, and custom domains remain capabilities even when their implementation
27
27
  spans primitive, API, account, or other packages rather than a same-named
28
28
  application directory. `internal/usage` separately owns metering, quota,
@@ -89,7 +89,7 @@ deployment edge after Mortar verifies ownership.
89
89
  - **Trusted project/operator**: app/admin project keys in server, CI, CLI, MCP,
90
90
  or platform provisioning. Never ship these credentials or clients to a Web,
91
91
  Desktop renderer, Keel/React Native, or WeChat bundle.
92
- - **Account control plane**: account JWT or `mtr_pat_*` PAT against the apex
92
+ - **Account control plane**: Account session JWT or `mtr_pat_*` PAT against the apex
93
93
  `_accounts` routes. These credentials manage projects and ownership; they are
94
94
  not interchangeable with project or app-user credentials.
95
95
 
@@ -5,7 +5,7 @@ or atomic row-plus-job workflows. Cron and queue are shipped capabilities whose
5
5
  runtime availability depends on configuration; they are not “planned extension
6
6
  slots.”
7
7
 
8
- Fabric provisions schedules only through one `mortar_migrate` operation:
8
+ Fabric provisions schedules only through one `mortar_resource` operation:
9
9
  `upsert_cron` creates or updates a schedule for an already deployed function,
10
10
  and `delete_cron` removes it. Direct cron list/create/patch/delete endpoints are
11
11
  trusted operator surfaces. Cron is normally enabled and can be disabled by the
@@ -3,7 +3,7 @@
3
3
  Read this reference for Mortar accounts, projects, API keys, PATs, custom
4
4
  domains, plans, top-up, auto-top-up, capacity, or enterprise placement.
5
5
 
6
- The control plane uses the apex host and an account JWT or `mtr_pat_*` personal
6
+ The control plane uses the apex host and an Account session JWT or `mtr_pat_*` personal
7
7
  access token. It manages account identity, project lifecycle, project API keys,
8
8
  PATs, project usage, domain claims, plan/top-up settings, and enterprise intent.
9
9
  These credentials are not app-user sessions and cannot be substituted for a
@@ -29,6 +29,37 @@ Updates and deletes use the same filter chain. Useful operators include `eq`,
29
29
  `neq`, ranges, `like/ilike`, `in`, `is`, `order`, `limit`, `single`, and
30
30
  `maybeSingle`.
31
31
 
32
+ ## System row metadata versus application payload
33
+
34
+ Every stored row has server-owned `id`, `created_at`, and `updated_at` metadata.
35
+ The SDK flattens that `RowMeta` beside the application payload when returning a
36
+ row. Do not declare those names as logical application columns and do not send
37
+ them in ordinary insert/update payloads. The documented upsert contract is the
38
+ exception: it accepts `id` as row identity and removes system metadata from the
39
+ stored application payload. Use the server-generated `created_at` for ordering,
40
+ filters, and indexes instead of creating a second timestamp column.
41
+
42
+ Mortar's current logical schema enforces required-field presence through `NOT
43
+ NULL`. Type spellings drive the language-neutral schema and application types,
44
+ but the row API does not yet runtime-validate every value against those type
45
+ names. `DEFAULT`, `UNIQUE`, `CHECK`, and foreign-key constraints are not
46
+ supported logical DDL. Client-side format, range, and length checks remain UX;
47
+ do not describe them as database enforcement.
48
+
49
+ ## Duplicate suppression is not durable idempotency
50
+
51
+ Disabling a submit button while a request is in flight prevents rapid duplicate
52
+ clicks in that mounted client. It does not make a row insert retry-safe. The
53
+ public insert API has no idempotency-key contract or durable uniqueness
54
+ constraint, and the SDK intentionally does not automatically retry this
55
+ non-idempotent POST. A client-side select-then-insert check is still racy and is
56
+ often unavailable under `public_insert` because anonymous reads are denied.
57
+
58
+ If the product requires exactly-once submission or durable deduplication, do
59
+ not claim direct public insert satisfies it. Use a reviewed supported
60
+ server-side contract that really performs atomic deduplication, or state that
61
+ the guarantee is not currently available for that client path.
62
+
32
63
  ## Atomic row mutations
33
64
 
34
65
  Pass an array when every insert or upsert must succeed or fail together. Mortar
@@ -5,12 +5,17 @@ function logs. Cron is in `automation.md`; analytics is in `analytics.md`.
5
5
 
6
6
  ## Deploy and invoke functions
7
7
 
8
- Deploy or delete functions only through one `mortar_migrate` operation with
8
+ Deploy or delete functions only through one `mortar_resource` operation with
9
9
  kind `deploy_function` or `delete_function`. Do not edit `mortar.config.json`,
10
- write migration files, or call operator/admin SDK methods from application
10
+ directly write the protected function directory, or call operator/admin SDK methods from application
11
11
  code. Function list/deploy/delete/logs are trusted project or account/operator
12
12
  surfaces; the app-bundle client exposes invocation only.
13
13
 
14
+ The desired-state directory contains `function.json` plus the runtime entrypoint:
15
+ `index.js` for Node-compatible runtimes and `index.py` for Python-compatible
16
+ runtimes. Switching runtime removes the stale entrypoint; deleting a function
17
+ removes the manifest, both entrypoint forms, and the legacy flat `.js` artifact.
18
+
14
19
  Client bundles may invoke a function that the platform already deployed:
15
20
 
16
21
  ```ts