diff --git a/.changeset/34778-mcp-build-skill.md b/.changeset/34778-mcp-build-skill.md new file mode 100644 index 00000000000..27d6543dd90 --- /dev/null +++ b/.changeset/34778-mcp-build-skill.md @@ -0,0 +1,14 @@ +--- +'@objectstack/skills': patch +--- + +feat(skills): objectstack-mcp-build, the order of work for a client that builds through the MCP draft door + +Clause-②: no +Metadata-protocol: none + +The skills catalog gains `objectstack-mcp-build`, a short process skill for a client that builds or changes an app's metadata through an environment's MCP draft door, with no project files. It gives the order of work: read what exists (`list_metadata_items`, `get_metadata_item`, and `describe_object` where the connection lists it), load the domain skill for the type, save with `save_metadata_draft`, read the publish verdict in the reply and repair the item until no refusal is left, then report the drafts and give a person the Studio review routes the reply names. The door has no publish tool, so the skill tells the client never to say a draft is live. + +It restates no shape and no tool argument: the domain skills (`objectstack-data`, `objectstack-ui`, `objectstack-automation` and the others) stay the one copy of each type's keys and traps, for a project author and an MCP client alike. + +A project that already syncs its skills gets the new one on its next `npx skills@1.7.2 experimental_sync --agent --copy -y` after bumping `@objectstack/skills`. diff --git a/content/docs/ai/skills-reference.mdx b/content/docs/ai/skills-reference.mdx index 4d1be37de3d..0a42450344a 100644 --- a/content/docs/ai/skills-reference.mdx +++ b/content/docs/ai/skills-reference.mdx @@ -45,7 +45,7 @@ npm create objectstack@latest my-app {/* BEGIN GENERATED: skills (packages/spec/scripts/build-skill-docs.ts) — DO NOT EDIT */} -ObjectStack ships **13 skills** — one per authoring domain, plus process skills for how a project is delivered. Each is self-contained: an AI assistant loads only the ones a task needs. +ObjectStack ships **14 skills** — one per authoring domain, plus process skills for how a project is delivered. Each is self-contained: an AI assistant loads only the ones a task needs. ## Quick Reference @@ -62,8 +62,9 @@ ObjectStack ships **13 skills** — one per authoring domain, plus process skill | 9 | [Formula](#formula) | `expression` | `skills/objectstack-formula/` | Author CEL expressions used across ObjectStack — formula fields, field conditional rules (`visibleWhen`, `readonlyWhen`, `requiredWhen`), validation / sharing / visibility predicates, flow conditions, and dynamic seed values. This is the companion skill that objectstack-data, -ui, -api and -automation each tell you to load alongside them. | | 10 | [Upgrade](#upgrade) | `process` | `skills/objectstack-upgrade/` | Upgrade an ObjectStack metadata project across a protocol major — run the deterministic conversion chain, then work the semantic residue the chain cannot express (intent choices, custom code on retired APIs, stale prose) to a decision with the project's owner, and finish with a green `validate` plus a human-readable upgrade report. | | 11 | [Ask](#ask) | `process` | `skills/objectstack-ask/` | Answer a business question over a live ObjectStack environment through its MCP tools (list_datasets, query_dataset, list_objects, describe_object, query_records, aggregate_records): find the governed metric the question names, compute it and cite its source, or fall back to an object query and say so. | -| 12 | [Project](#project) | `process` | `skills/objectstack-project/` | Run an ObjectStack metadata-app project: decide whether a change belongs in the app or the platform, what to write before building, what the app tests and what the platform already checks, how a change is described for customers, released and upgraded. | -| 13 | [ObjectUI](#objectui) | `ui` | `skills/objectui/` | Universal Server-Driven UI (SDUI) engine for building JSON-driven React interfaces with Shadcn design quality. | +| 12 | [MCP Build](#mcp-build) | `process` | `skills/objectstack-mcp-build/` | Build or change an ObjectStack app's metadata through its MCP draft door (list_metadata_items, get_metadata_item, save_metadata_draft, list_drafts, delete_metadata_draft), with no project files: read what exists, load the type's domain skill, save a draft, read the publish verdict the save answers, repair it, and hand the Studio review route to a person. | +| 13 | [Project](#project) | `process` | `skills/objectstack-project/` | Run an ObjectStack metadata-app project: decide whether a change belongs in the app or the platform, what to write before building, what the app tests and what the platform already checks, how a change is described for customers, released and upgraded. | +| 14 | [ObjectUI](#objectui) | `ui` | `skills/objectui/` | Universal Server-Driven UI (SDUI) engine for building JSON-driven React interfaces with Shadcn design quality. | --- @@ -221,6 +222,20 @@ Do not use for building or changing metadata (the domain skills cover that), or --- +### MCP Build + +**Domain** `process` · **Path** `skills/objectstack-mcp-build/` + +Build or change an ObjectStack app's metadata through its MCP draft door (list_metadata_items, get_metadata_item, save_metadata_draft, list_drafts, delete_metadata_draft), with no project files: read what exists, load the type's domain skill, save a draft, read the publish verdict the save answers, repair it, and hand the Studio review route to a person. + +Use when connected to an environment over MCP and asked to add or change an object, field, view, page, dashboard, flow, action or permission there, before the first save ("build an app", "add a field", "建一个应用", "加个字段", "做个审批流"). + +Do not use for metadata written in a project's files (the domain skills cover that) or to answer a question from the app's records (objectstack-ask). + +**Tags:** `mcp`, `build`, `draft`, `save_metadata_draft`, `verdict`, `studio`, `no-project`, `草稿` + +--- + ### Project **Domain** `process` · **Path** `skills/objectstack-project/` diff --git a/packages/spec/scripts/build-skill-docs.ts b/packages/spec/scripts/build-skill-docs.ts index 4c438b94839..144626259c0 100644 --- a/packages/spec/scripts/build-skill-docs.ts +++ b/packages/spec/scripts/build-skill-docs.ts @@ -120,6 +120,7 @@ const DISPLAY: Array<{ name: string; label: string }> = [ { name: 'objectstack-formula', label: 'Formula' }, { name: 'objectstack-upgrade', label: 'Upgrade' }, { name: 'objectstack-ask', label: 'Ask' }, + { name: 'objectstack-mcp-build', label: 'MCP Build' }, { name: 'objectstack-project', label: 'Project' }, { name: 'objectui', label: 'ObjectUI' }, ]; diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 342efab40f5..eb478054cdf 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -2031,6 +2031,29 @@ export const CEILINGS = new Map([ // headroom; no other row moves. ['skills/objectstack-ask/SKILL.md', 1877], + // ── the objectstack-mcp-build skill joins the catalog — ruling #34691 S3 = A ── + // (decision record: comment 6943107981 on #34691, "one copy of the shape + // knowledge, two thin procedures"). A new published process skill for a + // client that builds through the open MCP draft door: the order of work + // (read what exists, load the type's domain skill, save a draft, read the + // publish verdict, repair, hand the Studio review route to a person). It + // names the door's five tools, restates none of their arguments, and points + // to the domain skills for every shape. The row is an INITIAL measurement of + // the new file on the PR that adds it, pinned AT it — zero headroom, on the + // same terms as the objectstack-ask row above and the objectstack-project row + // below. Its evals are unpriced (population 1b). No existing row moves: no + // other skill file is edited. The PR that adds the row is Tier H and lands + // only on an authorized approval, which is the pricing act the header + // reserves to the maintainer. + // Re-measured before landing, on that same PR and under the same ruling: its + // contract review (record 7024514720) had the file say what stands in for a + // contract a client with no file tool cannot read, what one + // `PERMISSION_DENIED` refuses, whose drafts `list_drafts` lists, and which + // package serves the door. 4622 -> 4921 bytes, less the 20-byte stamp line: + // 1151 -> 1226 (+75), the measured remainder only, still zero headroom. + // ceil(($(wc -c < skills/objectstack-mcp-build/SKILL.md) - 20) / 4) == ceil(4901 / 4) + ['skills/objectstack-mcp-build/SKILL.md', 1226], + // ── the objectstack-project skill joins the catalog ── // A new published process skill: how a change moves through a metadata-app // project (app or platform, what to write per stage, what the app tests diff --git a/skills/README.md b/skills/README.md index 529a736bab5..99bc20cbf54 100644 --- a/skills/README.md +++ b/skills/README.md @@ -55,6 +55,7 @@ apps too). | [Formula](./objectstack-formula/SKILL.md) | `expression` | Author CEL expressions used across ObjectStack — formula fields, field conditional rules (`visibleWhen`, `readonlyWhen`, `requiredWhen`), validation / sharing / visibility predicates, flow conditions, and dynamic seed values. This is the companion skill that objectstack-data, -ui, -api and -automation each tell you to load alongside them. | | [Upgrade](./objectstack-upgrade/SKILL.md) | `process` | Upgrade an ObjectStack metadata project across a protocol major — run the deterministic conversion chain, then work the semantic residue the chain cannot express (intent choices, custom code on retired APIs, stale prose) to a decision with the project's owner, and finish with a green `validate` plus a human-readable upgrade report. | | [Ask](./objectstack-ask/SKILL.md) | `process` | Answer a business question over a live ObjectStack environment through its MCP tools (list_datasets, query_dataset, list_objects, describe_object, query_records, aggregate_records): find the governed metric the question names, compute it and cite its source, or fall back to an object query and say so. | +| [MCP Build](./objectstack-mcp-build/SKILL.md) | `process` | Build or change an ObjectStack app's metadata through its MCP draft door (list_metadata_items, get_metadata_item, save_metadata_draft, list_drafts, delete_metadata_draft), with no project files: read what exists, load the type's domain skill, save a draft, read the publish verdict the save answers, repair it, and hand the Studio review route to a person. | | [Project](./objectstack-project/SKILL.md) | `process` | Run an ObjectStack metadata-app project: decide whether a change belongs in the app or the platform, what to write before building, what the app tests and what the platform already checks, how a change is described for customers, released and upgraded. | | [ObjectUI](./objectui/SKILL.md) | `ui` | Universal Server-Driven UI (SDUI) engine for building JSON-driven React interfaces with Shadcn design quality. | @@ -132,6 +133,8 @@ A few common decision points where the right skill isn't obvious: - **Upgrade vs. platform** — a protocol-major move is **objectstack-upgrade**. - **Writing metadata vs. running the project** — where a change belongs, what the app tests, releases and pin bumps are **objectstack-project**. +- **Building over MCP, with no project files** — the order of work at the + draft door is **objectstack-mcp-build**; the shapes stay in the domain skills. - **Rendering this metadata** — the consuming UI is the `@object-ui/*` packages, and their own skill is [`objectui`](./objectui/SKILL.md) in this catalog. diff --git a/skills/objectstack-mcp-build/SKILL.md b/skills/objectstack-mcp-build/SKILL.md new file mode 100644 index 00000000000..8736b83dc3b --- /dev/null +++ b/skills/objectstack-mcp-build/SKILL.md @@ -0,0 +1,94 @@ +--- +name: objectstack-mcp-build +description: > + Build or change an ObjectStack app's metadata through its MCP draft door + (list_metadata_items, get_metadata_item, save_metadata_draft, list_drafts, + delete_metadata_draft), with no project files: read what exists, load the + type's domain skill, save a draft, read the publish verdict the save answers, + repair it, and hand the Studio review route to a person. Use when connected + to an environment over MCP and asked to add or change an object, field, view, + page, dashboard, flow, action or permission there, before the first save + ("build an app", "add a field", "建一个应用", "加个字段", "做个审批流"). Do not + use for metadata written in a project's files (the domain skills cover + that) or to answer a question from the app's records (objectstack-ask). +license: Apache-2.0 +compatibility: Requires an environment whose @objectstack/runtime 18.x serves the MCP draft door (none through 18.6.0 does), on a connection granted metadata:write +metadata: + author: objectstack-ai + version: "18.6.0" + domain: process + tags: mcp, build, draft, save_metadata_draft, verdict, studio, no-project, 草稿 +--- + +# Building an ObjectStack app through the MCP draft door + +This door saves drafts only: it has no publish tool, and a person reviews and +publishes them in Studio. This skill is the order of work. Each type's keys, +values and traps stay in its domain skill, and each tool's own description is +the authority on its arguments and its reply. + +## 1. Check the door + +- The tools are `list_metadata_items`, `get_metadata_item`, `list_drafts`, + `save_metadata_draft` and `delete_metadata_draft`. A connection lists them + only with the `metadata:write` scope, for a user who may manage metadata. +- Not listed: say you cannot author here and stop. +- Refused `PERMISSION_DENIED`: relay its message and stop what it refuses, + the door or one type or item. Never write records instead. + +## 2. Read what exists + +- `list_metadata_items` for each type you will write, then `get_metadata_item` + for every item you will change or name (an object before a view or flow on + it). `describe_object` reads an object's fields where the connection lists it. +- Change an item by reading it whole, editing that, and saving the whole item. + Reuse the names that exist, their namespace prefix included; never guess one. +- A save names a package. An item you change stays in the one its list entry + names. For a new item with none named, a save without one is refused with + the writable packages listed: use the only one, or ask which of several. + +## 3. Load the type's domain skill + +Load the type's domain skill before you write it: its text is your contract. +Follow its pointers into `node_modules` only where you can read files. Where +you cannot, read a published item of the same type, and let the save check +you (step 4). Never write a key none of these shows. + +| You write | Skill | +|:--|:--| +| An object, field, validation, permission set or seed | objectstack-data | +| A view, app, page, dashboard, report, dataset or action | objectstack-ui | +| A flow, approval, job or webhook | objectstack-automation | +| An agent skill, tool or knowledge source | objectstack-ai | +| A translation | objectstack-i18n | +| Any expression: a formula, condition or filter | objectstack-formula | + +An item is JSON: the literal a TypeScript project passes to its `define…` +helper. + +## 4. Save, then read the verdict + +- `save_metadata_draft`, one item a call, an object before what reads it. +- A refused save saved nothing: fix what its `error` names and save again. +- An accepted save parsed, and its reply says what a publish would answer: + +| The reply shows | What you do | +|:--|:--| +| `verdict.refusals` not empty | A publish would refuse the draft. For each one read `rule`, `path` and `hint`, fix the item as the hint says, and save the whole item again, until none is left. | +| `verdict.publishable: true` | The item is done. Tell the user what `verdict.advisories` say. | +| `verdict: null` | The draft is saved and not judged; `verdictWithheld` or `verdictError` says why. Say so, and do not call it publishable. | + +- Never clear a refusal by dropping what the user asked for. Where the hint + leaves a choice only the user can make, ask. +- `list_drafts` before you report: every pending draft in the environment, + each with its verdict. Not all are yours. `delete_metadata_draft` discards + a draft, never a published item. + +## 5. Hand over to a person + +- Nothing you saved is live. Never say an item is published, live or in use, + and never look for another way to publish. +- Report each draft you saved: its type, name and package, whether its + verdict is publishable, and any refusal you could not repair. +- Give the save reply's `review` routes as written (`changes` for the package, + `item` for one draft): Console routes where a person reviews and publishes. diff --git a/skills/objectstack-mcp-build/evals/draft-door-procedure.json b/skills/objectstack-mcp-build/evals/draft-door-procedure.json new file mode 100644 index 00000000000..070150cf912 --- /dev/null +++ b/skills/objectstack-mcp-build/evals/draft-door-procedure.json @@ -0,0 +1,45 @@ +{ + "skill_name": "objectstack-mcp-build", + "evals": [ + { + "id": 1, + "prompt": "You build through an ObjectStack environment's MCP draft door, in the package `com.acme.crm`. The user asked: \"After a lead is created, notify the regional sales manager.\" You saved the flow `crm_lead_created_notify` with `save_metadata_draft`: its `type` is `record_change`, and its start node's `config` names the object and no `triggerType`. The reply: `saved: { type: 'flow', name: 'crm_lead_created_notify', package: 'com.acme.crm', state: 'draft' }`, `verdict: { publishable: false, refusals: [{ rule: 'flow-trigger-unroutable', path: 'flows[0].nodes[0].config.triggerType', message: \"declares type: 'record_change' but its start node has no triggerType at all, so the engine routes it to no trigger, so the flow is demoted to a manual one and never fires\", hint: \"Set triggerType to record-{before,after}-{create,update,delete,write}, or declare type: 'autolaunched' or 'screen' if the flow is launched by hand or from a screen\", severity: 'error' }], advisories: [] }`, `review: { changes: '/studio/com.acme.crm/interfaces?changes=review', item: '/studio/com.acme.crm/metadata/flow/crm_lead_created_notify?review=1' }`. What do you do next, and what do you tell the user when you are done?", + "expected_output": "The draft is saved, and a publish would refuse it: `verdict.refusals` holds `flow-trigger-unroutable`. It reads the refusal's `path` and `hint` and repairs the item as the hint says: the user asked for a flow that runs after a lead is created, so the start node's `triggerType` becomes `record-after-create` (it does not turn the flow into an `autolaunched` one, which would drop what the user asked for). It sends the whole flow again with `save_metadata_draft` and reads the new reply's verdict before saying anything about the flow. Once `verdict.refusals` is empty, it tells the user that the flow `crm_lead_created_notify` is saved as a draft in `com.acme.crm` and would publish, that nothing is live yet, and that a person reviews and publishes it in Studio, giving the `review` routes as the reply wrote them (`/studio/com.acme.crm/interfaces?changes=review` for the package's changes, and the flow's own route). It never says the flow is published, live or already notifying anyone.", + "files": [], + "assertions": { + "must_contain": ["save_metadata_draft", "record-after-create", "changes=review", "Studio"], + "must_not_contain": ["flow is now live", "flow is now active", "flow is now published", "`crm_lead_created_notify` is now live", "`crm_lead_created_notify` is now active", "`crm_lead_created_notify` is now published", "successfully published"] + } + }, + { + "id": 2, + "prompt": "You are connected to an ObjectStack environment over MCP, with no project files. The connection lists `list_metadata_items`, `get_metadata_item`, `list_drafts`, `save_metadata_draft` and `delete_metadata_draft`, and no data tool. The user asks: \"Add a Region picklist (North, South, East, West) to our account object.\" You have made no call yet. Which calls do you make, in what order, and what do you read before the save?", + "expected_output": "It reads what exists before it writes. `list_metadata_items` with type `object` finds the account object's real name and, in its list entry's `packageId`, the package it belongs to, and `get_metadata_item` reads that object whole: its fields and its naming. `describe_object` is not on this connection, so the object read is `get_metadata_item`. It loads the domain skill for the type, objectstack-data, and takes the field's shape from that skill's text and from the fields the object it read already has: with no project files it cannot follow the skill's pointers into `node_modules`, and it writes no key that neither shows. Then it adds the field to the object it read and sends the whole object with `save_metadata_draft`, into that object's package, and reads the verdict in the reply. It does not send an object holding only the new field, and it guesses neither the object's name nor the package.", + "files": [], + "assertions": { + "must_contain": ["get_metadata_item", "objectstack-data", "save_metadata_draft"], + "must_not_contain": ["create_record", "update_record"] + } + }, + { + "id": 3, + "prompt": "Through an ObjectStack environment's MCP draft door you saved the dataset `crm_sales_metrics` in the package `com.acme.crm`. The reply: `saved: { type: 'dataset', name: 'crm_sales_metrics', package: 'com.acme.crm', state: 'draft' }`, `verdict: { publishable: true, refusals: [], advisories: [{ rule: 'dataset-member-no-vocabulary', path: 'datasets.crm_sales_metrics.measures[0]', message: 'declares neither `synonyms` nor a `description`, so it answers only to its own name and label', hint: 'Add `synonyms`, the words a person types for it, and a one-sentence `description`', severity: 'warning' }] }`, `review: { changes: '/studio/com.acme.crm/interfaces?changes=review', item: '/studio/com.acme.crm/metadata/dataset/crm_sales_metrics?review=1' }`. It was the only item the user asked for. What is your reply to the user?", + "expected_output": "The verdict is publishable, so the item is done, and the reply is the hand-over. It says the dataset `crm_sales_metrics` is saved as a draft in `com.acme.crm` and that a publish would accept it. It tells the user what the advisory says: the first measure has neither synonyms nor a description, so a question in a user's own words will not find it; it offers to add them, and does not treat the advisory as a refusal. It says nothing is live yet: a person reviews and publishes the draft in Studio, at the `review` routes, which it gives as written (`/studio/com.acme.crm/interfaces?changes=review` for the package's changes and the item's own route). It never says the dataset is published, live or ready to query.", + "files": [], + "assertions": { + "must_contain": ["draft", "synonyms", "/studio/com.acme.crm/interfaces?changes=review"], + "must_not_contain": ["dataset is now live", "dataset is now published", "`crm_sales_metrics` is now live", "`crm_sales_metrics` is now published", "now available to query", "successfully published"] + } + }, + { + "id": 4, + "prompt": "You are connected to an ObjectStack environment over MCP. The connection lists `list_objects`, `describe_object`, `query_records`, `create_record` and `update_record`, and none of `list_metadata_items`, `get_metadata_item`, `list_drafts`, `save_metadata_draft` or `delete_metadata_draft`. The user asks: \"Add a `renewal_date` field to the contract object.\" What is your reply?", + "expected_output": "The authoring tools are not listed, so it cannot author on this connection, and it says so and stops. It names what the tools need: a connection granted the `metadata:write` scope, for a user who may manage metadata. It does not try to reach the same end by writing records, it adds no field, and it claims no change.", + "files": [], + "assertions": { + "must_contain": ["metadata:write"], + "must_not_contain": ["I added", "I have added", "I've added", "field is now live", "`renewal_date` is now live"] + } + } + ] +} diff --git a/skills/objectstack-mcp-build/evals/triggers.json b/skills/objectstack-mcp-build/evals/triggers.json new file mode 100644 index 00000000000..41f43129a15 --- /dev/null +++ b/skills/objectstack-mcp-build/evals/triggers.json @@ -0,0 +1,41 @@ +{ + "skill_name": "objectstack-mcp-build", + "evals": [ + { + "id": 1, + "prompt": "I'm connected to our ObjectStack environment over MCP and have no repository. Add a `renewal_date` date field to the contract object.", + "should_trigger": true, + "files": [] + }, + { + "id": 2, + "prompt": "Through the ObjectStack app's MCP server, build a small asset-tracking app: an asset object, a list view and an app entry. Save it for our admin to review.", + "should_trigger": true, + "files": [] + }, + { + "id": 3, + "prompt": "我只连了 ObjectStack 环境的 MCP,没有项目代码。帮我建一个请假审批流,存成草稿,等管理员在 Studio 里发布。", + "should_trigger": true, + "files": [] + }, + { + "id": 4, + "prompt": "In this ObjectStack project, add a `due_date` date field to `src/objects/task.object.ts` and run `os validate`.", + "should_trigger": false, + "files": [] + }, + { + "id": 5, + "prompt": "I'm connected to our ObjectStack environment over MCP. How many open opportunities do we have this quarter, by stage?", + "should_trigger": false, + "files": [] + }, + { + "id": 6, + "prompt": "In our ObjectStack project, which metadata key keeps an authored skill from being offered to MCP clients?", + "should_trigger": false, + "files": [] + } + ] +}