diff --git a/.changeset/39203-skills-action-notices.md b/.changeset/39203-skills-action-notices.md new file mode 100644 index 00000000000..3665e7826c5 --- /dev/null +++ b/.changeset/39203-skills-action-notices.md @@ -0,0 +1,14 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): objectstack-ui and objectstack-i18n teach the action `notices` key + +Clause-②: no +Metadata-protocol: none + +An action that opens a dialog before it runs can declare `notices`: warnings the confirm or param dialog draws above its description while a condition holds. The two published skills that an author of such an action reads now say how to write it. + +- `skills/objectstack-ui/rules/actions.md` gains one bullet under "Visibility, Disable & Feedback": the map from a snake_case notice name to `{ severity, title, body, visible }` with one notice spelled out, the closed `severity` set (`info` by default, `warning`, `error`, `success`), `title` / `body` as plain I18nLabels with at least one of the two and no hole, markup or link, `visible` in the action's own `visible` shape and scope (never the values typed into the dialog), that a notice is display only and gates nothing, and that the key is refused on an action with neither `confirmText` nor a non-empty `params`. +- `skills/objectstack-i18n/SKILL.md` lists `notices.{notice}.{title,body}` in the key map under `_actions.{action}` (and so under `globalActions.{action}`). +- One eval case per bundle exercises it: a param-dialog warning on an expired quote, and where that warning's Chinese text goes in a bundle. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 082d4b95e8b..97796111dee 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -2265,7 +2265,20 @@ export const CEILINGS = new Map([ // Same ruling (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 (ruling record 6513306068, // letter B). // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(15670 / 4) - ['skills/objectstack-ui/rules/actions.md', 3918], + // 3918 -> 4062 (#39203): one bullet under "Visibility, Disable & Feedback" teaches the action + // `notices` key: the named map and one spelled notice, the closed `severity` set, `title` / + // `body` as plain I18nLabels with at least one, `visible` in the action's own shape and scope + // (never the dialog's values), that it is display only, and that it is refused on an action + // that opens no dialog. PAID DOWN FIRST by 20 bytes of restatement in this file: the second + // " (Declared refusals)" pointer closing the "Refusing by code" paragraph (the same paragraph + // names that section four lines up). Nothing else in the file restates another passage (see + // the notes above), so the same ruling's second half carries the rest. Arithmetic: the file + // was 15669 bytes; the text adds 598, the cut removes 20, so it is 16247 bytes -> 4062 tokens, + // headroom 0 before, ceiling +144, the measured remainder only, pinned AT the measurement. + // Same ruling (2026-10-27, tap A): 「A:先削重复,余额按实测提高」 (ruling record 6513306068, + // letter B). + // ceil($(wc -c < skills/objectstack-ui/rules/actions.md) / 4) == ceil(16247 / 4) + ['skills/objectstack-ui/rules/actions.md', 4062], // 6090 -> 6252 (#19715, card item 4): a 5-line table of contents at the top, // anchors to the file's existing headings, nothing else changed. +162 tokens, // zero headroom to absorb any of it, ceiling +162. Maintainer ruling diff --git a/skills/objectstack-i18n/SKILL.md b/skills/objectstack-i18n/SKILL.md index f4642467566..5805616ac25 100644 --- a/skills/objectstack-i18n/SKILL.md +++ b/skills/objectstack-i18n/SKILL.md @@ -80,7 +80,8 @@ objects.{object}: label, pluralLabel, description bulkActions.{bulkActionDefs_name} _actions.{action}: label, description, confirmText, submitText, cancelText, successMessage, disabledReason, params.{param}(.options.{value}), - outcomeMessages.{outcome}, resultDialog.{title,description,acknowledge}, + outcomeMessages.{outcome}, notices.{notice}.{title,body}, + resultDialog.{title,description,acknowledge}, resultDialog.fields.{path}, resultDialog.columns.{path}.{column_path}, preflight.fields.{path}, preflight.columns.{path}.{column_path}, refusals.{CODE}.message, refusals.{CODE}.reasons.{reason}.message, texts.{key}.message @@ -115,7 +116,7 @@ messages: flat dotted ids ('common.save'); dashboards, metadataForms, settingsCo - A form's `sections` are read before `_sections`, key by key. - `columns` is a sibling of `fields`: a `format: 'table'` field's `path`, then a column's (`resultDialog: { columns: { rows: { email: '邮箱', 'error.message': '原因' } } }`). - `preflight` holds `fields` and `columns` only, no `title`. + `preflight`: no `title`. - `_relatedLists.{list}` is on the parent, for a `relatedLists` entry that authors a `label`; one without has no key and shows the child field's `relatedListTitle`, else its plural label. - A report block is keyed by its `name`; a `books` group by its stable `key`, never its diff --git a/skills/objectstack-i18n/evals/bundles-locales-coverage.json b/skills/objectstack-i18n/evals/bundles-locales-coverage.json index 5cf24350f40..ccbe3237500 100644 --- a/skills/objectstack-i18n/evals/bundles-locales-coverage.json +++ b/skills/objectstack-i18n/evals/bundles-locales-coverage.json @@ -174,6 +174,17 @@ ], "must_not_contain": ["defineApp", "name: 'setup'"] } + }, + { + "id": 18, + "prompt": "The `crm_send_quote` action on `quote` declares `notices: { quote_expired: { severity: 'warning', title: 'This quote has expired', body: 'Update the validity date before sending.', visible: P`record.valid_until < today()` } }`. Our zh-CN users still read that warning in English in the dialog. Where does its Chinese text go in the bundle?", + "expected_output": "In the zh-CN `TranslationData`, under the action's own node, keyed by the notice NAME the action declares: `objects: { quote: { _actions: { crm_send_quote: { notices: { quote_expired: { title: '报价已过期', body: '发送前请更新有效期。' } } } } } }`, that is `objects.quote._actions.crm_send_quote.notices.quote_expired.title` and `.body`. Only `title` and `body` are translated: `severity` and the `visible` condition are not copy and have no key. The name is the stable key, so reordering the notices moves no translation; a key under a notice name the action does not declare is refused by `os validate` (`translation-target-unknown`). An action with no `objectName` takes the same keys under `globalActions.crm_send_quote.notices`. Not a `messages` id, and never keyed by the notice's position.", + "files": [], + "assertions": { + "must_contain": ["_actions", "crm_send_quote", "notices", "quote_expired"], + "must_contain_any": [["title:", "\"title\":", ".title"], ["body:", "\"body\":", ".body"]], + "must_not_contain": ["notices.0", "notices[0]"] + } } ] } diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index ccee86dcd7c..f92efe705b2 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -29,7 +29,8 @@ view / page / dashboard / report metadata. `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`. + delete gated by `ai.requiresConfirmation`, not `confirmText`, a conditional + warning a param dialog draws before submit (`notices`). - `triggers.json` — trigger cases: requests that should load this skill (`should_trigger: true`) and near misses that should not (`false`), graded on whether the skill was loaded, never on the answer. diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index 83b44c35770..664c3f45849 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -282,6 +282,17 @@ "must_contain_any": [["defineForm", "forms:"], ["form-public-address-taken", "FORM_ADDRESS_TAKEN", "holds its address"]], "must_not_contain": ["defineView(", "provider: 'object'"] } + }, + { + "id": 29, + "prompt": "Our `quote` object has a 'Send Quote' action, `crm_send_quote`, that asks for the recipient's email in a dialog. When the quote is already past its `valid_until` date, the dialog should warn the sender before they submit, and say nothing otherwise. Add that to the action.", + "expected_output": "The one `defineAction` keeps its `params` (the dialog the notice is drawn in) and gains `notices`, a map keyed by a snake_case notice name: `notices: { quote_expired: { severity: 'warning', title: 'This quote has expired', body: 'Its validity date has passed. Update the date before sending.', visible: P`record.valid_until < today()` } }`. `visible` is a bare CEL predicate over the same scope as the action's own `visible` (the record, the user, `features`), never the values typed into the dialog; `title` / `body` are plain text with no `{{ }}` hole. The answer says the notice is display only: it does not stop the submit, so a rule that must hold is a hook or validation. Not a second twin action per condition, not the unconditional `description`, not `confirmText` (refused beside `params`), and not `alerts` / `warnings` (refused, naming `notices`).", + "files": [], + "assertions": { + "must_contain": ["notices", "params", "visible", "record.valid_until"], + "must_contain_any": [["severity: 'warning'", "severity: \"warning\""], ["body:", "title:"]], + "must_not_contain": ["alerts:", "warnings:", "confirmText:", "dismissible", "visibleWhen"] + } } ] } diff --git a/skills/objectstack-ui/rules/actions.md b/skills/objectstack-ui/rules/actions.md index 1f4000af972..ef9567dbc4e 100644 --- a/skills/objectstack-ui/rules/actions.md +++ b/skills/objectstack-ui/rules/actions.md @@ -51,6 +51,7 @@ there: a wrong name draws nothing. - `pressed` — a CEL predicate over the same scope as `visible` that marks the action as already done by this reader: while TRUE the record header draws it pressed (`aria-pressed`). Display-only, never a gate; a boolean literal is refused, and `active` / `activeWhen` / `pressedWhen` are refused naming this key. A per-reader fact (the reader's vote) is a block the object declares under `attachedOnRead`, filled per caller by a service or `afterFind` hook, read as `has(record.viewer) && record.viewer.vote == 'helpful'`. - `confirmText` — set for any destructive or irreversible operation; the confirm dialog of a param-less action. It gates no AI call: an `ai.exposed` one also sets `ai.requiresConfirmation: true`. A registered action is refused it beside a non-empty `params` (put the question on `description`); a view's `bulkActionDefs` entry pairs the two by its own contract. - `submitText` — the verb on the param dialog's submit button ("Send", "Log Call") in place of "Confirm": an I18nLabel, refused blank and refused without a non-empty `params` (no dialog opens); `submitLabel` / `confirmLabel` are refused naming this key. +- `notices` — conditional warnings the confirm or param dialog draws above its `description`: `{ mail_off: { severity: 'warning', body: 'No email will be sent.', visible: P`features.emailDelivery != true` } }`. The snake_case name is the notice's translation key. `severity`: `info` (default), `warning`, `error`, `success`; `title` / `body`: I18nLabels, at least one, plain text (no hole, markup or link); `visible`: the action's own `visible` shape and scope, never the dialog's values. Display only, never a gate; refused with neither `confirmText` nor a non-empty `params` (no dialog opens). - `preflight` — a read the param dialog shows above the params before submit: `{ read: { url }, path?, fields?, seed? }` sends one `GET` (no other `method`, no body or credentials) to a same-origin API path (one leading `/`) whose only holes are `${param.NAME}` (a declared param; re-read when it changes), `${ctx.recordId}` and `${ctx.record.FIELD}`. `path` selects the answer's sub-tree (`data`); `fields` rows are `resultDialog.fields`' (omitted: JSON). Each `seed: [{ param, path }]` entry fills a declared param, drawn read-only and submitted as shown: seeded once, no `defaultValue` / `defaultFromRow` / `carryOver`, read by no hole; mark it `required` so Confirm waits for the answer. Refused without a non-empty `params` and beside `execution: 'aggregate'`. UX, not authorization: the endpoint still checks a seeded value. - `resultDialog` — a one-shot dialog that shows the server answer in place of the success toast (so no `successMessage`; `outcomeMessages` is refused beside it): `{ title?, description?, acknowledge?, format?, fields? }`. `fields: [{ path, label?, format? }]`, `path` a dot path into `result.data` (omitted: the whole answer as JSON); `format` is one of `qrcode`, `code-list`, `secret`, `text`, `json`, or `table` with `columns: [{ path, label?, format? }]` (one row per element of the array at `path`, one cell per column; required with `table` and refused beside any other format). The dialog-level `format` (default `json`) and a cell's (default `text`) take every format but `table`. A `text` or `code-list` cell draws the value with no copy control; a `secret` or `qrcode` cell keeps its own. - `successMessage` / `errorMessage` — toast copy; without `successMessage` the UI shows "Action completed". @@ -151,7 +152,7 @@ sentence is answered as `userMessage`, translated at `objects.._actions..refusals..message` (objectstack-i18n); the console's failure toast shows it unless the action sets `errorMessage`. For several reasons throw `reasons: [{ reason, params? }, …]`, not `reason`: `userMessage` is one line per reason, then -the code's `message` (Declared refusals). +the code's `message`. ### Writing in the organization's language (`texts`)