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
39 changes: 39 additions & 0 deletions .changeset/34770-ai-skill-router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
'@objectstack/skills': patch
---

docs(skills): the objectstack-ai entry file becomes a router

Clause-②: no
Metadata-protocol: none

`skills/objectstack-ai/SKILL.md` goes from 30.0 KB to 9.0 KB (518 lines to 184). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. One sentence of the old entry is corrected (the pending answer, below); no other rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched.

**What the entry keeps.** Each of these parses, or is accepted, and then does nothing or the wrong thing:

- A tool record (`defineTool`, `*.tool.ts`) makes nothing executable: the default path is the Action's own opt-in, `ai: { exposed: true, description }`, named in a skill's `tools` as `action_<actionName>`.
- An opted-in action can still be no tool: `url`, `modal` and `form` are UI-only, and the in-app assistant skips a destructive one (`mode: 'delete'`, `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) unless the host runs `enableActionApproval: true`.
- `confirmText` is dialog copy and gates no AI call; `ai.requiresConfirmation: true` does.
- A stack-authored agent is never served: skills are the one extension, `agent.tools` and `agent.knowledge` are refused, and retrieval is scoped on the knowledge source (`aiExposed`, `source.where`).
- A skill's `triggerConditions` route on context the client reports, so they are never access control; over MCP the HTTP door offers a skill's prompt only when the server lists every tool the skill binds.
- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm` (the delete tools' own `confirm: true` is in their descriptions in `tools/list`); at every AI door, `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides.
- No page declares an AI button: the shell's 「问 AI」 entry opens the assistant on the current record.
- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap (no key adds an overlap), and an app that cuts its own passages indexes the child records with `strategy: 'whole'` and `documentBy`; an app that ships no source declares `requires: ['knowledge']`; mounted is not enabled, so with no embedder at boot the sources are held (listed, never searched, `search_knowledge` not offered) and `os knowledge status` says why; unmounted or held, a run-time save is refused.
- Sampling sits under an agent's `model`, and the deployment's AI settings choose the provider.
- `ai.requiresConfirmation` guards the action's own door and not the state: the whole of the old pitfall "Gating the action, not the state" stays, under the same title.

**What left, and what answers it now.**

- The skill key tables (`name`, `label`, `tools`, `surface`, `description`, `instructions`, `triggerConditions`, `active`, `context`) and the trigger-operator table: the contract, `node_modules/@objectstack/spec/src/ai/skill.zod.ts`. Its docblocks say which edition reads each key, that an incompatible `surface` binding is a load error, that a skill with blank `instructions`, `active: false` or `mcpPrompt: false` is not offered as an MCP prompt, and that the plugin's own stdio server applies no tool-binding filter; `SkillTriggerConditionSchema` refuses a `value` whose shape does not match its `operator`; the strict schema refuses a `permissions` key and a phrase-matching `trigger` key, each with what to write. The entry keeps the five context fields a condition can read.
- The four-rung tool-resolution ladder: `os validate`, whose `ai-skill-tool-unresolved` warning names the unresolved entry and suggests the `action_` spelling. The name lists are `PLATFORM_TOOLS_BY_PACKAGE`, `PLATFORM_PROVIDED_TOOL_NAMES`, `MCP_DOOR_TOOL_NAMES`, `MCP_FILE_TOOL_NAMES` and `PLATFORM_TOOL_FAMILY_PREFIXES`, exported from `@objectstack/spec/system`.
- The in-app `ask` paragraph (a package skill with `surface` `ask` or `both` loads for the app the user is in; a tool it names outside the allow-set is dropped with a diagnostic): cut, with no other home in this repository. It describes the cloud runtime.
- The action dispatch table (`script`, `api`, `flow`): https://objectstack.ai/docs/ai/actions-as-tools (§ What gets exposed). The entry names that page for dispatch only: its list of destructive signals still includes `confirmText` and its approval section still gives the retired pending answer, so the entry states both rules itself. The Human-in-the-loop paragraph: the confirmation contract, `ActionConfirmationRefusalReason` and the docblock above it in `@objectstack/spec/contracts`. The request-body assembly of a `type: 'api'` action (`recordIdParam`, `recordIdField`, `bodyShape`, `bodyExtra`): the contract, `node_modules/@objectstack/spec/src/ui/action.zod.ts`, whose docblocks are the one home of those four keys. That `confirmText` is dialog copy and no destructive signal stays in the entry (objectstack-ui, `rules/actions.md`, says the same). The cloud host's plugin options (`apiActionBaseUrl`, `apiActionHeaders`, a custom `apiClient`) and its two predicates (`actionSkipReason`, `actionRequiresApproval`): cut, with no other home in this repository; they belong to the cloud package that exports them. The old text said a queued call answers `{ status: 'pending_approval', pendingActionId }` from an `ai_pending_actions` row: from 19.0.0 every AI door answers `pending_confirmation` with a `pendingId`, and the entry now says that once, for every door.
- The MCP plugin snippet, the two environment switches (`OS_MCP_SERVER_ENABLED`, `OS_MCP_STDIO_ENABLED`) and the tool table: https://objectstack.ai/docs/ai/connect-mcp (§ What the agent gets, § Local stdio transport) and each tool's own description in `tools/list`, which carries the delete-confirmation rule, the `delete_records` preview and cap, and the `run_action` confirmation rule as the server enforces them. The confirmation contract, door by door and reason by reason: `ActionConfirmationRefusalReason` and the docblock above it, in `@objectstack/spec/contracts`. The plugin's `autoStart` option is a typed, documented option of `MCPServerPlugin` in `@objectstack/mcp`; the published page teaches the environment switch. Consuming an external MCP server (`@objectstack/connector-mcp`): objectstack-automation, `references/integration-recipes.md`.
- The knowledge-source key table (`adapter`, `source.metadataFields`, `source.documentBy`, `source.where`, `source.retrieval.mode`, `refresh.onRecordChange`, `aiExposed`), the store-resolution rule, that a run-time save needs `manage_knowledge_sources` beside `manage_metadata`, the `NAMESPACE-NAME` spelling of a package's source, and the code door (`KnowledgeServicePlugin({ sources })`, `registerSource`): the contract, `node_modules/@objectstack/spec/src/ai/knowledge-source.zod.ts`, and https://objectstack.ai/docs/ai/knowledge-rag. The keys retired in 19 (`id`, `contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, `source.kind: 'file'` / `'http'`): each is refused with its fix, the published page lists them under "Upgrading from 18", and `os migrate meta --from 18` lists a stack's edits. The five `knowledge-source-*` rules: `os validate` and publish, which print each with its fix. The splitting detail (what each strategy cuts at, `maxChars` against the Longest passage setting and the embedder's limit, the `minChars` merge, that a changed `split` rebuilds the index and refuses searches meanwhile): the `KnowledgeSplitSchema` docblock in the same contract file and the published page, § Splitting documents into passages. The retired `knowledge.chunk_overlap` setting and `KnowledgeChunk.metadata`: their refusals; the entry keeps "passages never overlap". That a run-time save is refused when the author may not search the object or query a field: the published page, § Writing a source. The rest of the document-unit rule (which field `documentBy` may name, that setting it rebuilds nothing and newly listing the parent field rebuilds the source in place, that `topK` then counts parents and the parent is the hit's `groupValue`): the `documentBy` docblock in the same contract file and the published page, § An app that cuts its own passages. The rest of the held state (the store half, what a held search and `os knowledge rebuild` answer, the two restarts of the remedy): the published page, § Turning it on, and the refusal itself, which names what is missing.
- The tool-record section: the contract, `node_modules/@objectstack/spec/src/ai/tool.zod.ts` (strict; required `name`, `label`, `description`, `parameters`; `outputSchema` marked experimental; the keys retired in 17, each refused with its replacement) and https://objectstack.ai/docs/ai/tools. `ai.outputSchema` and `ai.category` on the action: `ui/action.zod.ts`.
- The model-configuration table: `AIModelConfigSchema` in `node_modules/@objectstack/spec/src/ai/agent.zod.ts` (the `temperature` range and default, the retired `provider` key and the one residue value that still parses).
- The pitfall on `guardrails`: that an agent's `guardrails` and `memory` are limits and no gate is cut from this entry, since a stack does not author an agent; the keys and their prescriptions are in `ai/agent.zod.ts` (the two numbers required once long-term memory is enabled, and no `requireApprovalFor` key, which the strict schema refuses). Cut, with no other home in the published skills: that `approval: 'always'` on an MCP tool binding is an enforced gate (the value itself is `MCPApprovalPolicySchema` in `ai/mcp.zod.ts`), and that AI metadata edits land as drafts a person publishes.
- The platform-agents section: https://objectstack.ai/docs/ai/agents (the two agents and the surface each is bound to, that a skill reaches an agent only when their surfaces match, the MCP prompt rule and `mcpPrompt`, `visualize_data`). The table of the built-in skills (`schema_reader`, `data_explorer`, `actions_executor`, `metadata_authoring`, `solution_design`): cut, with no other home in this repository; they are the cloud runtime's. The retired-keys table of `AgentSchema`: the entry keeps that `agent.tools` and `agent.knowledge` are refused; the refusal names the upgrade guide.
- "Verify your work" and "References": first checks 4 and 3. That this domain has no CEL site and that a model-registry prompt template is the `template` dialect: cut from this entry; objectstack-formula teaches the three dialects and that a `template` is not CEL, and the keys that take an expression are typed in the contract. A scaffolded project's `npm run validate` alias is in that project's own `package.json`.

**Anchors that no longer exist in `SKILL.md`.** `#skill-configuration`, `#naming-the-tools-the-resolution-ladder`, `#skill-example`, `#trigger-conditions`, `#tool-metadata-definetool--not-the-default-path`, `#model-configuration`, `#verify-your-work`, `#references`, and the anchor of the "Platform agents — reference only" heading. The new ones are `#first-checks`, `#skills` and `#where-to-go`. The title's anchor and the anchors of "Actions as AI Tools", "MCP", "Context packs", "Knowledge Sources (RAG)" and "Common Pitfalls" are unchanged: other bundle files send the reader to three of those headings by name. No file in this repository linked an anchor of the old entry.
26 changes: 25 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,31 @@ export const CEILINGS = new Map([
// 30020 bytes, so the LANDED priced text is 29993 -> ceil(29993 / 4) = 7499;
// the row moves +10, the measured remainder only. Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(29993 / 4)
['skills/objectstack-ai/SKILL.md', 7499],
// 7499 -> 2242 (#34770): the entry becomes a router. It keeps four first checks, one
// type-checked skill and one type-checked knowledge source, the traps that parse and then do
// nothing or the wrong thing (a tool record that runs nothing, an opted-in action that is no
// tool, `confirmText` taken for a gate, `confirm` sent to `run_action`, a pending answer retried, a script deciding a pending
// item, a `file` field indexed for its text, a gate on the action with no lock on the state)
// and a routing list. The headings three other bundle files point at by name stay: Actions as
// AI Tools, MCP (the elicitation outcomes), Common Pitfalls. Nothing MOVED:
// `references/context-packs.md` takes context-pack text only and already held all of it (row
// below, untouched), so the rest is CUT behind what already says it: the contract
// (`ai/skill.zod.ts`, `ai/tool.zod.ts`, `ai/knowledge-source.zod.ts`, `ai/agent.zod.ts`, whose
// strict shapes refuse a wrong or retired key with the key to write, and the confirmation
// contract in `contracts/ai-service.ts`), `os validate` (`ai-skill-tool-unresolved`,
// `agent-authoring-withdrawn`, the `knowledge-source-*` rules), the MCP door's own tool
// descriptions, or the published AI pages. The two additions of 2026-12-01 above stay as one
// clause each: mounted is not enabled (held sources, `os knowledge status`), and an app that
// cuts its own passages indexes the child records with `documentBy`; the `documentBy` row and
// the rest of the held paragraph are the contract's docblock and the published knowledge
// page's. No row rises and no row is added. The file is 30020 bytes (29993 priced) -> 8995
// (8968 priced) -> 2242 tokens, pinned AT the measurement; the sum of all ceilings falls by
// the same 5257. (The review round put back that `confirmText` gates no AI call and that the
// pending answer is every AI door's, paid by wording cuts: 8997 -> 8995.)
// Authority: the ruling of record that orders the entry file down to router size, decision
// record #34691 S3 = A.
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8968 / 4)
['skills/objectstack-ai/SKILL.md', 2242],
// -12 (was 6331): the `http.server` decision-table row dropped a trailing
// clause that taught `contributes.routes` as a key that "parses but serves
// nothing". The key is retired — an authored entry is now REFUSED, carrying
Expand Down
Loading
Loading