@texuli/spec
v0.18.0
Published
The schema-first blueprint contract: JSON schemas, the catalog vocabulary, deterministic TypeScript and Kotlin projections, and the conformance harness.
Maintainers
Readme
@texuli/spec
The blueprint contract of Texuli, an MIT-licensed
Svelte 5 component library by Dailybot, Inc. (Small pieces. Infinite
possibilities.). A blueprint is a JSON document, usually written by an
AI agent, that describes an interface as a tree of components from Texuli's
closed catalog. @texuli/spec is the platform-neutral source of truth for
that format: the generated TypeScript types, the closed component
vocabulary, a target-neutral blueprint validator and deterministic hashing.
In the stack: layer L0: the blueprint contract every agent-facing layer shares. @texuli/tokens (design-system documents), @texuli/catalog and @texuli/player build on it, and the Kotlin Multiplatform twin in native/ is generated from it.
Use it when you generate, store, diff or check blueprints, or build a renderer for them. The same contract also generates the Kotlin models used by Texuli's Kotlin Multiplatform twin. The package is framework-free: no DOM, no Svelte, no Node APIs and no runtime dependencies.
Status: 0.x release. Texuli is in development. The packages are published to npm as
0.18.0, a pre-1.0 release (1.0.0 will be the first stable release). Under 0.x, a new minor (0.18.0) may contain breaking changes, so pin the exact version or use^0.18.0, which accepts only 0.18.x.
New in
0.17.0.@texuli/[email protected]carries spec 0.15.0 (digest4c674bc59c8140ee2ff24e47f4de9c46689f48f07c8516128480db129f7a0a57): thedata-virtual-listcatalog entry listsmode(listboxorfeed),selectableandsurface(boxorplain). The kit models (changesModel,kitApproval,kitContentHash,KIT_ALLOW_LISTS) are Svelte-free in@texuli/spec/design-system. Bundles keep every allow entry up to the 4,096-key cap, refuse duplicate library source ids and a current-version history hash that disagrees with the document, count source limits in UTF-8 bytes and accept any ISO fraction in history timestamps. A stamp-only migration from0.14.0; every 0.14.0 blueprint and document stays valid.
New in
0.16.0.@texuli/[email protected]carried spec 0.14.0 (digest39b8e87b561ae37c3a3b3ef45b7cec29ad4b05fa9b01cd9032c1b9f05f383e24): catalog components gain the categorycoloraxis (noneorchart-1tochart-8, onavatar,badge,color-swatchandtag), the design-systemallowsection gainscolors(codeunknown-color), and the allow-manifest and bundle schemas carry the allowed colors. The catalog projection addscolor-swatch,data-virtual-list,link,listandmarkand the props of the typography, surface and input rounds. The blueprint allow check (checkBlueprintAllow) and the contract schemas are released. A stamp-only migration from0.13.0; every 0.13.0 blueprint and document stays valid.
New in
0.15.0.@texuli/[email protected]carried spec 0.13.0 (digest37897e1b4d669ca0f32ba49b4960c921e860c1bacb38a9f29a1072389708ffae): locked design systems (ADR-032). The design-system document gains the optionalallow(catalog ids,<ns>:<id>included, with their enabled variants, sizes, tones, densities and states),libraryandapprovalsections, validated with stable codes;checkDesignSystemAllow,designSystemContentHash,approveDesignSystemandinitLockedDesignSystemare in@texuli/spec/design-system, with thedata-tx-*root attribute names anddsRootAttributes. Catalog components gain optionalaxes,statesandimports; host catalog extensions ($defs.extension) merge throughmergeCatalogs. The blueprint allow check and the contract schemas (allow manifest, ds-check report, design-system bundle) shipped in it as in development and are released in0.16.0. A stamp-only migration from0.12.0; every 0.12.0 blueprint and document stays valid.
New in
0.14.0.@texuli/[email protected]carried spec 0.12.0 (digest049c93b4105fb765c2db5ff20272494f99fce52552aafaf85e00789fc1747a14): the app-tier catalog idsavatar-group-gridandcode-field, thesrcDarkanddarkModeprops ofmedia-image, thedata-timelinegroups with bands, markers, the bindablecollapsedandselectedRowand the newcollapseevent, a shadow layer'sdarkOpacity, theaa-non-textdesign-system code and the card contentfont-sizecomponent key. Every0.11.0envelope migrates by stampingspec.
New in
0.13.0.@texuli/[email protected]and0.13.1carried spec 0.11.0 (@texuli/[email protected]to@texuli/[email protected]carried spec0.10.0). It extends the design-system document only: structured shadows per elevation level (elevation.levels), product tokens (extensions) and a categorical palette of 1 to 8 colors. Every0.10.0document stays valid, and every0.10.0envelope migrates by stampingspec.
New in
0.10.0.@texuli/[email protected]carried spec 0.10.0: the design-system document (schemas/design-system.schema.json, formattexuli/design-system) with its new@texuli/spec/design-systemsubpath, and the optionaldesignSystemon the envelope and on adocument($defs.designSystemReference:{ ref: "[email protected]" }or{ inline: <document> }). Every0.9.0envelope migrates by stampingspec.
New in
0.9.0.@texuli/[email protected]carried spec 0.9.0, a stamp-only catalog projection refresh (the Button pending note and the cartesian charts'xKindandlocale, from the Protoyard gaps G94 and G97): the envelope, the$defsand the diagnostic codes are unchanged, and every0.8.0envelope migrates by stampingspec.
New in
0.8.0.@texuli/[email protected]carried spec 0.8.0, which adds data-source bindings (the@texuli/spec/sourcesubpath), the agent-emittableschema-form,canvas,spreadsheet,data-dashboardanddata-dashboard-widgetids with their closed shapes, the closed expression AST, and the pinnedschemas/canvas.schema.json. Every0.7.0envelope migrates by stampingspec.
New in
0.7.0.@texuli/[email protected]carries spec 0.7.0, which adds an optional nodekey(unique in the tree), the agent-emittabledocumentid with its$defs.documentshape, thepatchDocumentedit op with a bounded RFC 6902 patch, and the pinnedschemas/document.schema.json. Every0.6.0envelope migrates by stampingspec.
New in
0.6.0.@texuli/[email protected]carries spec 0.6.0: the closed motion vocabulary (@texuli/spec/motion, below), and the new@texuli/spec/streamsubpath reads streamed blueprints. Every0.5.0envelope migrates by stampingspec.
New in
0.4.0.@texuli/[email protected]carries spec 0.4.0: spec 0.3.0 (state, bindings, closed actions,reorder, workflow graphs), spec 0.4.0 (deck model v2 onlayout-deckanddeck-slide, below) and theworkflow,migrateandsurfacesubpaths described below.@texuli/[email protected]carried spec 0.2.0 and only the root andcodegensubpaths (RELEASE).
Install
npm install @texuli/specpnpm add @texuli/spec
# or
yarn add @texuli/specNo peer dependencies and no CSS. The package is ESM-only and ships TypeScript declarations. The normative JSON documents (the blueprint schema, the component catalog and the fixtures) live in the repository; they are not part of the npm package.
Quick start
import {
canonicalJson,
type Schema,
SPEC_COMPONENT_IDS,
SPEC_VERSION,
sha256,
validateInstance,
} from '@texuli/spec';
SPEC_VERSION; // '0.15.0' in @texuli/[email protected]
SPEC_COMPONENT_IDS.includes('alert'); // true: the closed component vocabulary
// The dialect validator: a closed subset of JSON Schema 2020-12.
const schema: Schema = {
type: 'object',
properties: { title: { type: 'string', maxLength: 80 } },
required: ['title'],
additionalProperties: false,
};
validateInstance(schema, { title: 'Weekly report' }); // []
validateInstance(schema, { title: 42, extra: true });
// [{ code: 'type', path: '$.title', … }, { code: 'additional-property', path: '$.extra', … }]
// Deterministic serialization and hashing, identical in every runtime.
const digest = sha256(canonicalJson({ b: 1, a: [true, null] }));To check a whole blueprint, pass the blueprint schema and catalog documents
from the repository's packages/spec/schemas/blueprint.schema.json and
packages/spec/catalog/components.json. Workflow graphs and migrations
are opt-in subpaths, so the root stays small: a host that renders workflow
graphs passes schemas/workflow.schema.json and validateWorkflowGraph
from @texuli/spec/workflow (without both, a workflow state variable or
a workflowGraph prop fails closed), and a host that reads older
envelopes runs migrateBlueprint from @texuli/spec/migrate first:
import { type Schema, type SpecCatalog, validateBlueprint } from '@texuli/spec';
import { migrateBlueprint } from '@texuli/spec/migrate';
import { validateWorkflowGraph } from '@texuli/spec/workflow';
const migrated = migrateBlueprint(blueprint); // 0.2.0 → … → 0.14.0 → 0.15.0; never throws
const result = validateBlueprint(migrated.blueprint, {
blueprintSchema: blueprintSchemaJson as Schema,
catalog: componentsJson as SpecCatalog,
workflowSchema: workflowSchemaJson as Schema, // only for workflow graphs
validateWorkflowGraph, // only for workflow graphs
});
if (!result.ok) {
for (const d of result.diagnostics) console.warn(d.code, d.path, d.message);
}
for (const w of result.warnings ?? []) console.info(w.code, w.path); // `deprecated`A node with an id outside the catalog fails with unknown-id. The other
codes are schema, unknown-prop, prop-type, enum-value,
missing-required, extension-prop, catalog-mismatch,
unsupported-profile, unknown-slot, and, from spec 0.3.0, state (a
refused state or flow declaration), unknown-state (a binding or action
names no declared variable), binding (a malformed, misplaced, read-only or
ill-fitting binding), action (an action with the wrong fields or target),
unknown-event (an on key the component does not fire) and workflow (a
workflow graph rule), from spec 0.7.0, duplicate-key (a node key used
twice in the tree), and, from spec 0.8.0, source (a malformed, misplaced or
ill-fitting data-source binding, or any binding when the host passes no
sources) and unknown-source (a source the host never registered).
Deprecated components and props add a deprecated
warning without failing.
What's inside
| Subpath | Purpose | Headline exports |
| --- | --- | --- |
| @texuli/spec | Runtime: types, vocabulary, validation, hashing | BlueprintEnvelope, SpecCatalog, SpecValidation, WorkflowGraph and the other generated types; SPEC_COMPONENT_IDS, SpecComponentProps, SPEC_CATALOG_HASH, SPEC_VERSION; validateBlueprint, validateTree, validateInstance, checkSchemaDocument; the contract constants (SPEC_ACTION_OPS, SPEC_EVENT_NAMES, SPEC_STATE_TYPES, SPEC_LIMITS, SPEC_PATTERNS, ACTION_FIELDS); canonicalJson, sha256 |
| @texuli/spec/workflow | Runtime, opt-in: workflow graph validation | validateWorkflowGraph (pass it in SpecDocuments.validateWorkflowGraph) |
| @texuli/spec/migrate | Runtime, opt-in: envelope migrations | migrateBlueprint, SPEC_MIGRATIONS, UNDECLARED_SPEC_VERSION |
| @texuli/spec/surface | Runtime: the state surface rules every validator shares (no imports) | checkStateSurface, surfaceInputs, SPEC_CONTROL_STATE_TYPES, SURFACE_PLAYER_CODES, LIST_TEXT_PATTERN |
| @texuli/spec/motion | Runtime (new in 0.6.0, spec 0.6.0): the closed motion vocabulary and its check, shared by the catalog and the player (motion.md) | SPEC_MOTION_PRESETS, SPEC_MOTION_DURATIONS, SPEC_MOTION_STAGGERS, SPEC_MOTION_LEVELS, checkNodeMotion, checkEnvelopeMotion |
| @texuli/spec/stream | Runtime, opt-in (new in 0.6.0): streamed blueprints (stream.md) | createJsonTokenizer, createBlueprintAssembler, createBlueprintStream, STREAM_NODE_ORDER |
| @texuli/spec/source | Runtime (new in 0.8.0, spec 0.8.0): data-source bindings, shared by the spec validator, @texuli/catalog and the player (source.md) | checkSourceBinding, isSourceBinding, SOURCE_BINDING_KEY, SPEC_SOURCE_LIMITS, SPEC_SOURCE_FILTER_OPERATORS, SpecSourceDescriptor |
| @texuli/spec/design-system | Runtime, opt-in (new in 0.10.0, spec 0.10.0): the design-system document contract (ADR-021) (design-system.md) | validateDesignSystem, validateDesignSystemPatch, applyDesignSystemPatch, migrateDesignSystem, checkDesignSystemReference, DesignSystem, DesignSystemPatch, DESIGN_SYSTEM_CODES, DESIGN_SYSTEM_LIMITS |
| @texuli/spec/codegen | Build time: generation and conformance | buildSpec, projectCatalog, checkConformance, checkCatalogContract, formatJson, nextSpecVersion, checkVersionHistory |
Key guarantees
- Closed vocabulary. Component ids, prop names, prop kinds and enum values are closed; anything outside the catalog is refused.
- No platform props from data. Web-only props (slots, events,
class,className,styleand the chartrenderer) are marked as web extensions, left out ofSpecComponentProps, and refused when a blueprint sets them. - Fails closed. The portable profile is refused until a capability is
audited portable, and a blueprint bound to another catalog hash is
refused when you pass
catalogHash. - Deterministic. Canonical JSON sorts keys at every depth, and every generated file carries the spec version and digest with no timestamps.
- Interaction as data, never code. Spec 0.3.0 adds local state,
bindings (
{"$state": name}, read-only{"$data": name}), a closed action set (setState,toggleState,moveItem,flowGo,emit,submit) on a closed event vocabulary, drag as data (reorder) and workflow graphs (at most 500 nodes and 2,000 edges). Nothing in a blueprint is evaluated. - Decks as data. Spec 0.4.0 (ADR-009) gives
layout-deckanddeck-slideoptional deck model v2 props: the 9:16 aspect, theslide,zoomandmorphtransitions, motion, navigation, outline, a slidelayoutwith itsprops,background, step labels and component slides. The change is additive: every 0.3.0 envelope is a valid 0.4.0 envelope, and the0.3.0 → 0.4.0migration only stampsspec. The deck model itself is validated by@texuli/deck, not by this package. - Motion as data (spec 0.6.0, new in
0.6.0). A node may declaremotion(enterandexitpresetsfade,rise,scale,slide-startandslide-end;layout;staggeranddurationin token steps) and the envelope amotion.level(full,subtle,none). Names map to the motion tokens: a blueprint never carries CSS, keyframes, milliseconds or code, and anything else is refused. The0.5.0 → 0.6.0migration only stampsspec. - Documents as data (spec 0.7.0, new in
0.7.0). Adocumentnode'sdocmust have the document shape ($defs.document); the document's own vocabulary and URL policy are checked by@texuli/documentthrough@texuli/catalog'svalidateDraft. Agents edit documents withpatchDocument(at most 1,000 RFC 6902 operations), addressed by nodekey. - Streams parse, never guess.
@texuli/spec/stream(new in0.6.0) reads a blueprint split anywhere in linear time under a byte budget and a depth cap, reports a node only once its shell (everything butchildren) has closed, and refuses duplicate and prototype keys. It judges no rule: the catalog checks each node, and the complete draft goes throughvalidateDraft. - Structure only. This validator checks structure. URL policy, tree
limits and rendering live in the runtime validator of
@texuli/catalog. The reducers that run the actions belong to the runtime (@texuli/player), which runs every 0.3.0 action from0.4.0). - A blueprint that validates paints. The state surface rules
(
@texuli/spec/surface) refuse exactly what the player refuses at paint time: form fields and submits outside anaction-form, nested forms, controls and fields that name no declared variable of their type, flow nodes without a matching view or event, and writers of a host-bound variable. The spec,@texuli/catalog'svalidateDraftand the Kotlin twin run the same rules. - Data as a named source, never a request (spec 0.8.0, new in
0.8.0). A component'ssourceableprop may read rows with{"$source": name, "query": {...}, "map": {...}}: an opaque name the host registered, and a closed query (projection, the@texuli/datagrid filter model, sort, search, a page size). It is checked against the host's source descriptors (SpecDocuments.sources) and refused without them; nothing in it is a URL, SQL or code (source.md). - Forms as data, never patterns or code (spec 0.8.0, new in
0.8.0). The agent-emittableschema-formid carries a closed form schema ($defs.formSchema): fields of 15 closed types in sections or steps (20 from0.10.0, which adds password, otp, color, datetime and the host-painted custom type), named formats and host validator names (never a regular expression), and conditions and cross-field rules in the closed expression AST of@texuli/core/expression($defs.expression, thenumberFormulaandconditionshapes extended with strings, booleans, field references and calls to a closed function table). The schema checks the shape; the forms validator (@texuli/forms/model,checkForminvalidateDraft) checks the rest at the host's tier. The Kotlin twin decodes the shape and its list caps and paints a placeholder (planned). - Dashboards as data (spec 0.8.0, new in
0.8.0). The agent-emittabledata-dashboardid holdsdata-dashboard-widgetchildren (widgetId,titleand aplacein grid units); widget content is ordinary catalog nodes, so its data comes only from host sources. The dashboard'slayout(a bounded list of{id, x, y, w, h}grid units) is bindable and sourceable, so a state or a host source persists what people arrange. The schema bounds the grid units;@texuli/catalogchecks the composition (widgets only directly in a dashboard, unique ids) on the web. The Kotlin twin decodes the props and paints a placeholder (planned). - Spreadsheets as data, formulas in a closed grammar (spec 0.8.0,
new in
0.8.0). The agent-emittablespreadsheetid (notsheet, which is the texuliSheetoverlay) carries a sheet in itssheetprop ($defs.sheet,$defs.sheetTab):formattexuli-sheet, 1 to 16 tabs of{ id, name, rows, columns, cells }with cells keyed by A1 address. The schema checks that envelope and its caps; the sheet validator (@texuli/sheets/model,checkSheetinvalidateDraft) parses every formula with the sheet grammar (noINDIRECT,OFFSETorRAND, a closed function set). The Kotlin twin decodes the envelope and its caps; painting it is planned. - List item text never hides or reorders itself. String fields of list
state items refuse control characters, bidirectional overrides and
isolates, and invisible formatting characters (
SPEC_PATTERNS.listText; ZWNJ and ZWJ stay allowed for scripts and emoji).
Versioning
The spec has its own semantic version (SPEC_VERSION), separate from the
npm package version. The spec digest is the SHA-256 of the manifest
that pins every normative file (schemas, catalog and fixtures); any
normative change moves the digest and requires a new spec version.
| Change class | Examples | Before 1.0.0 | From 1.0.0 | | --- | --- | --- | --- | | patch | Descriptions, diagnostic wording, a fixture for behavior that already holds | patch | patch | | minor | Optional fields, new catalog ids, new optional props, new diagnostic codes for data that was already refused | minor | minor | | major | Removing or renaming ids, props or fields; changing a prop type; making something required | minor | major |
For TypeScript consumers, a patch leaves the generated types and
SPEC_COMPONENT_IDS unchanged; code that compiled against a minor release
keeps compiling, though new optional fields and ids can appear in data it
reads. Native (Kotlin) builds compile the generated models from the same
spec, and their decoders are closed: a blueprint that uses a field from a
newer spec fails to decode on an older native build with a schema
diagnostic instead of passing silently. A blueprint binds to an exact
catalog hash, and from 0.3.0 may declare the exact spec version it was
written for (spec; omitted means 0.2.0). migrateBlueprint
(@texuli/spec/migrate) brings an
envelope up to the current spec with pure, per-version steps
(src/migrations/: 0.2.0 → 0.3.0, 0.3.0 → 0.4.0, 0.4.0 → 0.5.0,
0.5.0 → 0.6.0, 0.6.0 → 0.7.0, 0.7.0 → 0.8.0, 0.8.0 → 0.9.0,
0.9.0 → 0.10.0, 0.10.0 → 0.11.0, 0.11.0 → 0.12.0, 0.12.0 → 0.13.0, 0.13.0 → 0.14.0 and 0.14.0 → 0.15.0, each of which
only stamps spec); a compatible version
range is planned, not built. @texuli/[email protected] carries spec 0.15.0 (digest
4c674bc59c8140ee2ff24e47f4de9c46689f48f07c8516128480db129f7a0a57): catalog props a
patch could not carry (the data-virtual-list mode, selectable and surface).
@texuli/[email protected] and 0.16.1 carried spec 0.14.0 (digest
39b8e87b561ae37c3a3b3ef45b7cec29ad4b05fa9b01cd9032c1b9f05f383e24): the category color axis, the allow colors and the catalog ids added after
0.15.0 (above). @texuli/[email protected] carried spec 0.13.0 (digest
37897e1b4d669ca0f32ba49b4960c921e860c1bacb38a9f29a1072389708ffae): locked
design systems and catalog axes, states, imports and extensions (above).
@texuli/[email protected] to 0.14.4 carried spec 0.12.0 (digest
049c93b4105fb765c2db5ff20272494f99fce52552aafaf85e00789fc1747a14): two
app-tier catalog ids, the media-image dark source, the data-timeline
groups, markers and selection with the collapse event, and the
design-system additions above. @texuli/[email protected] and 0.13.1 carried spec 0.11.0 (digest
17845743d088b768c4441ea2196e5c350687533dbd0c95589cba938fb31fe993), which
extends the design-system document only (structured shadow levels, product
tokens, a categorical palette of 1 to 8 colors and pinned soft inks; every
0.10.0 document stays valid). @texuli/[email protected] to @texuli/[email protected]
carried spec 0.10.0 (digest
afcb9e3ed6b74b833a0f7477a657168621785ee98602ff582aa047e2d86aef17), which adds the
design-system document (PLAN_011 T-ds-spec) and the envelope's
designSystem (T-ds-blueprint), plus a catalog projection refresh
(data-filter-builder gains the optional issues prop and
fields[].optionLabels, T-gaps-100-104) and an additive forms field
vocabulary ($defs.formField gains the password, otp, color,
datetime and custom types and the kind, config, length,
protocols and clearable members, T-gaps-113-121; command-palette lists
searchLabel, T-gaps-107-110). @texuli/[email protected] carried spec 0.9.0 (digest
497df4d3b0c67d53483163ebd9bd73733b52caf5f8e2966478f1cf860e6f9d9d), an
additive catalog projection refresh (PLAN_011 T-gaps-87-95 and
T-gaps-96-98); @texuli/[email protected] carried spec 0.8.0 (digest
f6b6388280d247eb9c3106a925111f35b90d1ec3b59c23652542f06a9f103daf), which
adds data-source bindings, forms, canvases, dashboards and spreadsheets;
@texuli/[email protected] carried spec 0.7.0 (digest
43e44fa9a198d337d686b4e2d86882a06a676ae1e1c1f02d023b3a525795a8b2), which
adds node keys and documents; @texuli/[email protected] carried spec 0.6.0 (digest
37141b85b9ab9f02af849a62a9c97ba729d6c5c2705130290bcdf45b308ea4cc), which
adds the closed motion vocabulary (ADR-012); @texuli/[email protected] carried
spec 0.5.0, which added the data-cohort-table,
data-notification-inbox, data-filter-builder and time-field catalog
ids, and @texuli/[email protected] spec 0.4.0 (digest
fac29f542b16ddb78ab401c508e5b8346f655991c56e25aa811f4931661a8cb3). Every
pin is in versions.json.
The full rules (the digest, versions.json pins, regeneration and the
conformance harness) are in
contract.md.
Documentation
- Website: texuli.com, the agents overview and web and native
- Schemas, catalog and fixtures: packages/spec
- The contract in depth (the JSON Schema dialect, projections, conformance and versioning): contract.md
- The motion vocabulary (spec 0.6.0): motion.md
- Streamed blueprints (the incremental tokenizer, the canonical order and
node shells; new in
0.6.0): stream.md - Data-source bindings (spec 0.8.0; new in
0.8.0): source.md - The design-system document (spec 0.10.0; new in
0.10.0; extended in spec 0.11.0, new in0.13.0, spec 0.12.0, new in0.14.0, and spec 0.13.0 with the locked sections, new in0.15.0): design-system.md - The Kotlin Multiplatform twin that consumes the generated models: native/README.md
- Architecture: ARCHITECTURE.md
Related packages
@texuli/catalog: the agent catalog and the renderer with no HTML sinks.@texuli/player: the Svelte paint runtime for validated blueprints.texuli: the styled Svelte 5 components blueprints are built from.
Contributing
Source, issues and contribution guidelines live at github.com/DailybotHQ/texuli. Report bugs at github.com/DailybotHQ/texuli/issues.
License
MIT © Dailybot, Inc.
Powered by Dailybot.
