Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/37105-skills-teach-forms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/skills': patch
---

docs(skills): `objectstack-ui` teaches a form as a `form` item in `forms:`, and `views:` as lists only

Clause-②: no
Metadata-protocol: none

ADR-0159 makes a form a metadata type of its own. The published skill now teaches that one shape and no other.

`skills/objectstack-ui/rules/list-views.md`: the section *Form Views* is now *Forms*. A form is a `form` item in the stack's `forms:`, written with `defineForm` in a `*.form.ts`: `name` (`OBJECT.KEY`, its prefix equal to `object`), `object`, and the form body at the top level. It is a form something opens, either a public form (it declares `sharing.publicLink`) or one an action of `type: 'form'` opens by its `target`; `os validate` warns `form-consumer-less` on a form with neither. The record's New and Edit forms stay the object's `fieldGroups` and are never a `form` item. The section carries one type-checked `defineForm` example and teaches:

- `viewKind`, `config` and `data` are refused on a `form` item: a form is bound with `object`.
- A form left open on a public address another form holds is refused, naming both forms (`form-public-address-taken` from `os validate`, `409 FORM_ADDRESS_TAKEN` from a save). A form holds its address while its `publicLink` names it, switched on or off.
- Translations sit under `forms.NAME` (`.label`, `.title`, `.description`, `.submitBehavior.*`, `.sections.SECTION.*`); a section with no key there reads `objects.OBJECT._sections.SECTION`.

No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says never to author a form inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item): one an action opens, or that declares a `publicLink` or `overrides`, moves to `forms:`, and only the rest is deleted, since New and Edit never loaded it.

`skills/objectstack-ui/SKILL.md`: Trap 1, the routing table's form row (`*.form.ts`) and the Action Types `form` row name the `form` item. `rules/navigation.md` says `form` item and links the renamed heading.

A reader who linked `rules/list-views.md#form-views` or `#field-conditional-rules-in-forms` finds those headings gone: the first is `#forms`, and the second is one clause of the Forms paragraph that points at objectstack-data's Conditional Field Rules.

The words are paid for in the same file, and the three token ceilings follow their files down: `rules/list-views.md` 4510 to 4509, `SKILL.md` 2228 to 2227, `rules/navigation.md` 2559 to 2556. Cut from `rules/list-views.md`: the *Field Conditional Rules in Forms* section, the third copy of the `defineView` scaffold (the `userActions: { search: false }` example, now its one key inline), and a sentence of Master-Detail item 1 that `SKILL.md` Trap 2 states word for word.

`evals/views-apps-actions-pages.json`: case 25 now expects a `form` item an action opens, with its sections' `columns`; new case 28 expects a public `form` item and the answer that the address is held by a switched-off form that keeps its link. Cases 1, 6 and 19 keep their prompts and no longer name a form authored inside a view.
24 changes: 21 additions & 3 deletions scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,11 @@ export const CEILINGS = new Map([
// 2262 -> 2228: the Action Types table drops its `ask_ai` row and the footnote under it
// drops the same name, the type having left `ActionType` (ADR-0160 D7). 9075 bytes (9048
// priced) -> 8937 (8910 priced) -> 2228 tokens; the row follows the measurement down.
['skills/objectstack-ui/SKILL.md', 2228], // -34 to the measurement (was 2262)
// 2228 -> 2227 (#37105, ADR-0159 card 4, the skill): Trap 1, the routing table's form row
// and the Action Types `form` row name the `form` item (`forms:`, `defineForm`,
// `*.form.ts`) where they named a form view. 8937 bytes (8910 priced) -> 8933 (8906
// priced) -> 2227 tokens; net shrink, so the row follows the measurement down.
['skills/objectstack-ui/SKILL.md', 2227], // -1 to the measurement (was 2228)
// 8333 -> 6193: RE-LOCK at the landed count after the #19715 split (decision
// batch #213 item 1, maintainer 「1 2 4 同意」): the worked R1, the report
// template and the v17-canonical shapes block moved VERBATIM into
Expand Down Expand Up @@ -2114,7 +2118,17 @@ export const CEILINGS = new Map([
// line into `skills/objectstack-ui`; it authorises its own measured delta and no more.
// 17790 -> 18039 bytes (+249) -> 4510 tokens, ceiling +62, pinned AT the measurement.
// ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18039 / 4)
['skills/objectstack-ui/rules/list-views.md', 4510],
// 4510 -> 4509 (#37105, ADR-0159 card 4, the skill): `## Form Views` becomes `## Forms` and
// teaches the `form` item: one checked `defineForm` example, the top-level body, the two
// refusals an author meets, the `forms` translation family, and one sentence on a form
// found inside a view. The container example loses its form member. PAID BY DELETION in
// this file: `## Field Conditional Rules in Forms` folds into one clause of the Forms
// paragraph, the third copy of the container scaffold (the `userActions: { search: false }`
// example) becomes its one key inline, and Master-Detail item 1 drops the sentence
// SKILL.md Trap 2 states word for word. 18039 -> 18035 bytes -> 4509 tokens; net shrink,
// so the row follows the measurement down.
// ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18035 / 4)
['skills/objectstack-ui/rules/list-views.md', 4509], // -1 to the measurement (was 4510)
// 2273 -> 2196 (#27059): LOWERED. The Surface bullet points at `rules/record-page.md`,
// says create / edit is a modal or the `editMode: 'page'` route, and the Overlay-width
// bullet moved there whole (the `size` bucket, the deprecated pixel keys); the ceiling
Expand All @@ -2134,7 +2148,11 @@ export const CEILINGS = new Map([
// absorbed, ceiling +380, pinned AT the measurement. Authority as the `rules/actions.md`
// row above.
// ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10255 / 4)
['skills/objectstack-ui/rules/navigation.md', 2559], // -5 to the measurement (was 2564)
// 2559 -> 2556 (#37105): Record Presentation says `form` item where it said form view,
// and its link follows the list-views heading that card renames to Forms. 10235 -> 10222
// bytes -> 2556 tokens; the row follows the measurement down.
// ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10222 / 4)
['skills/objectstack-ui/rules/navigation.md', 2556], // -3 to the measurement (was 2559)
// 5501 -> 5692 (#19715, card item 4): a 5-line table of contents at the top,
// anchors to the file's existing headings, nothing else changed. +191 tokens,
// zero headroom to absorb any of it, ceiling +191. Maintainer ruling
Expand Down
10 changes: 5 additions & 5 deletions skills/objectstack-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ metadata:

Two more: [List Views](#list-views), [Actions](#actions).

1. **New and Edit are the object's fields and `fieldGroups`, never a form
view**: they load no `form` or `formViews.create`, which parse.
1. **New and Edit are the object's fields and `fieldGroups`, never a `form`
item**: they load no `form` item, which parses.
`showOnCreate: false` keeps a field off every create surface (refused
beside `required: true`): [Form Views](./rules/list-views.md#form-views).
beside `required: true`): [Forms](./rules/list-views.md#forms).
2. **A record entered with its line items is a parent field group naming the
child** (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList:
'invoice_line' }]`), before any custom page; without it nothing changes:
Expand Down Expand Up @@ -74,7 +74,7 @@ Two more: [List Views](#list-views), [Actions](#actions).
| Authoring | In | Open first |
|:--|:--|:--|
| A list, board, calendar, gallery or gantt: columns, `filter`, quick filters, toolbar search, sorting, grouping | `src/views/*.view.ts` | [List Views](./rules/list-views.md) |
| New / Edit form (field groups, `showOnCreate`, line items, field rules); a named or public form | the object; `src/views/*.view.ts` | [Form Views](./rules/list-views.md#form-views) |
| New / Edit form (field groups, `showOnCreate`, line items, field rules); a public or action-opened form (`defineForm`, `forms:`) | the object; `*.form.ts` | [Forms](./rules/list-views.md#forms) |
| An app and its navigation; who sees or opens it; object nav, a `filters` slice or an interface page | `src/apps/*.app.ts` | [Navigation](./rules/navigation.md) |
| What a record page shows: related lists, a slotted or full page; how a record opens | the object | [Record Page](./rules/record-page.md) |
| A button or operation: `locations`, visibility, dialog and toast copy, params, new tab, the body's `ctx`, refusing by code (`refusals`) | `src/actions/*.action.ts`, `*.actions.ts` | [Actions](./rules/actions.md) |
Expand Down Expand Up @@ -147,7 +147,7 @@ never its label ([Actions](./rules/actions.md)):
| `modal` | Open the page named by `target`; a `body` runs only on `script` |
| `flow` | Launch a screen/auto-launched flow by name; a multi-step operation is this, with a flow you also author |
| `api` | Call a registered API endpoint |
| `form` | Open a FormView by name (routed to `/_console/forms/:name`) |
| `form` | Open the `form` item `target` names (`OBJECT.KEY`) on its own page |

Every type but `script` requires `target`.

Expand Down
3 changes: 2 additions & 1 deletion skills/objectstack-ui/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ view / page / dashboard / report metadata.
- `views-apps-actions-pages.json` — `defineView` containers, `App.create`
navigation, `defineAction` surfaces, record / interface pages, package
docs, the New and Edit form built from the object (field groups,
`showOnCreate`, line items), a named form's section `columns`, a view added
`showOnCreate`, line items), a `form` item an action opens and its section
`columns`, a public `form` item on an address another form holds, a view added
beside the list (and the empty board over a field added with it), a write
button whose body writes, the view kind the request names, an AI-exposed
delete gated by `ai.requiresConfirmation`, not `confirmText`.
Expand Down
26 changes: 19 additions & 7 deletions skills/objectstack-ui/evals/views-apps-actions-pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{
"id": 1,
"prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form with the case details in one section. None of the project's files are in this directory: write the file in your answer.",
"expected_output": "One `defineView({ list, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`). No `form` in the container: the edit form is built from the object, so the answer says its section is a `fieldGroups` entry of `support_case` (an internal `form` parses and is not loaded).",
"expected_output": "One `defineView({ list, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`). No form in the container and no `form` item: the edit form is built from the object, so the answer says its section is a `fieldGroups` entry of `support_case` (a `form` item is a public form or one an action opens; New and Edit load none).",
"files": [],
"assertions": {
"must_contain": ["defineView", "provider: 'object'", "listViews", "groupByField", "link: true", "{current_user_id}", "owner_id"],
"must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'", "form: {"]
"must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'", "form: {", "defineForm("]
}
},
{
Expand Down Expand Up @@ -54,7 +54,7 @@
{
"id": 6,
"prompt": "Invoice entry as a stepped form — header, then line items, then review — saving the invoice and its lines together.",
"expected_output": "No form view and no screen flow (nothing branches): the invoice's New form is built from the object, so header, then lines, then the rest is the order of `invoice`'s `fieldGroups`. Line items come from the DATA MODEL: a field group naming the `master_detail` child (`fieldGroups: [{ key: 'header', ... }, { key: 'lines', label: 'Lines', relatedList: 'invoice_line' }, ...]`), which draws the editable grid in the form and saves parent + children in one atomic `/api/v1/batch`; without the group the form has no lines, whatever `inlineEdit` says. The hand-over says the steps are sections of one form, not a wizard: a `formViews` wizard is not loaded by New or Edit, and a named form an action opens draws no line items. No custom page, and no 'Add line' button (the ghost row exists).",
"expected_output": "No form view and no screen flow (nothing branches): the invoice's New form is built from the object, so header, then lines, then the rest is the order of `invoice`'s `fieldGroups`. Line items come from the DATA MODEL: a field group naming the `master_detail` child (`fieldGroups: [{ key: 'header', ... }, { key: 'lines', label: 'Lines', relatedList: 'invoice_line' }, ...]`), which draws the editable grid in the form and saves parent + children in one atomic `/api/v1/batch`; without the group the form has no lines, whatever `inlineEdit` says. The hand-over says the steps are sections of one form, not a wizard: a wizard `form` item is not loaded by New or Edit, and a form an action opens draws no line items. No custom page, and no 'Add line' button (the ghost row exists).",
"files": [],
"assertions": {
"must_contain": ["fieldGroups", "relatedList", "master_detail"],
Expand Down Expand Up @@ -184,7 +184,7 @@
{
"id": 19,
"prompt": "Shape the New and Edit form of `opportunity`: 42 fields in six sections (Basics, Amounts, Dates, Partner, Shipping, Internal Notes). Reps fill Basics and Amounts on every create and the other four rarely, and `loss_reason` is never known at create. The form opens in the New dialog, mostly on wide screens.",
"expected_output": "No form view: New and Edit are built from the object. Six `fieldGroups` entries on `opportunity` in that order, with `collapse: 'collapsed'` on the four rarely filled ones, and `showOnCreate: false` on `loss_reason`, which edit, the record page and lists still show (it must not be `required: true`: the pair is refused). Not a `form`, `formViews.default` or `formViews.create` (each parses and is not loaded), and no `modalSize` or `columns`: the dialog's size and column count are derived.",
"expected_output": "No form view: New and Edit are built from the object. Six `fieldGroups` entries on `opportunity` in that order, with `collapse: 'collapsed'` on the four rarely filled ones, and `showOnCreate: false` on `loss_reason`, which edit, the record page and lists still show (it must not be `required: true`: the pair is refused). Not a `form` item (it parses, and New and Edit load none), and no `modalSize` or `columns`: the dialog's size and column count are derived.",
"files": [],
"assertions": {
"must_contain": ["fieldGroups", "collapse: 'collapsed'", "showOnCreate: false"],
Expand Down Expand Up @@ -244,11 +244,12 @@
{
"id": 25,
"prompt": "`crm_account` declares the field groups `basic_info` and `contact_info`. A 'New Intake' button opens an intake form on its own page; the team wants each group two columns wide there, and asks for the same two columns in the ordinary New dialog. Write the metadata and say what each surface does.",
"expected_output": "A named form under `formViews` whose sections reference the groups and declare the count, `sections: [{ group: 'basic_info', columns: 2 }, { group: 'contact_info', columns: 2 }]`, opened by a `type: 'form'` action whose `target` names it. The answer says the form page reads each section's `columns` (1 to 4, one column on a phone), and that the New and Edit dialog is built from the object's `fieldGroups`, never from this form view, at a column count the platform derives and nobody authors. Not `columns` on the form view itself (the form page does not read it), not a `columns` key on a `fieldGroups` entry, not `modalSize`, and not an answer that two columns cannot be authored anywhere.",
"expected_output": "A `form` item in the stack's `forms:`, `defineForm({ name: 'crm_account.intake', object: 'crm_account', sections: [{ group: 'basic_info', columns: 2 }, { group: 'contact_info', columns: 2 }] })`: the name is `OBJECT.KEY` with the form's `object` as its prefix, and the body is at the top level (no `viewKind`, no `config`, and no `data`, which is refused: a form is bound with `object`). A `type: 'form'` action whose `target` is `crm_account.intake` opens it. The answer says the form page reads each section's `columns` (1 to 4, one column on a phone), and that the New and Edit dialog is built from the object's `fieldGroups`, never from a `form` item, at a column count the platform derives and nobody authors. Not a form authored inside a `defineView` container, not `columns` on the form itself (the form page does not read it), not a `columns` key on a `fieldGroups` entry, not `modalSize`, and not an answer that two columns cannot be authored anywhere.",
"files": [],
"assertions": {
"must_contain": ["formViews", "group: 'contact_info', columns: 2", "type: 'form'", "fieldGroups"],
"must_not_contain": ["modalSize:", "formViews.default"]
"must_contain": ["object: 'crm_account'", "'crm_account.", "group: 'contact_info', columns: 2", "type: 'form'", "fieldGroups"],
"must_contain_any": [["defineForm", "forms:"]],
"must_not_contain": ["modalSize:", "defineView(", "provider: 'object'"]
}
},
{
Expand All @@ -270,6 +271,17 @@
"must_contain": ["groupByField", "summary", "avg", "estimate_hours", "showFieldLabels: false", "hideEmptyFields: false"],
"must_not_contain": ["showFieldLabels: true"]
}
},
{
"id": 28,
"prompt": "Publish a 'Contact us' web form on `crm_lead` that anonymous visitors fill in at `/forms/contact-us`: name, email and message. The retired form `crm_lead.old_contact` is switched off (`sharing.enabled: false`) and still declares `publicLink: 'contact-us'`. Write the metadata and say what `os validate` answers.",
"expected_output": "One `form` item in the stack's `forms:`: `defineForm({ name: 'crm_lead.contact_us', object: 'crm_lead', sections: [{ fields: ['name', 'email', 'message'] }], sharing: { enabled: true, allowAnonymous: true, publicLink: 'contact-us' } })`. The name is `OBJECT.KEY` with the form's `object` as its prefix, and the body is at the top level (no `data`: a form is bound with `object`). Visitors read it at `GET /api/v1/forms/contact-us` and submit to `POST /api/v1/forms/contact-us/submit`. The answer says `os validate` refuses the new form with `form-public-address-taken`, naming both forms: the retired form holds its address while its `publicLink` names it, switched on or off, so its link is cleared first (until then a save of the new form answers `409 FORM_ADDRESS_TAKEN`). Not a form authored inside a `defineView` container, not a second form left on the address, and not a claim that switching the old form off frees the address.",
"files": [],
"assertions": {
"must_contain": ["object: 'crm_lead'", "'crm_lead.", "enabled: true", "allowAnonymous: true", "publicLink"],
"must_contain_any": [["defineForm", "forms:"], ["form-public-address-taken", "FORM_ADDRESS_TAKEN", "holds its address"]],
"must_not_contain": ["defineView(", "provider: 'object'"]
}
}
]
}
Loading
Loading