openuispec 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ This scaffolds a spec directory, starter tokens, and **configures the MCP server
|
|
|
46
46
|
## Key concepts
|
|
47
47
|
|
|
48
48
|
- **Tokens** — design values (color, typography, spacing, elevation, motion) with semantic names and constrained ranges
|
|
49
|
-
- **Contracts** — 7
|
|
49
|
+
- **Contracts** — 7 reusable UI component families defined by role, props, interaction states, and accessibility
|
|
50
50
|
- **Screens** — compositions of contracts with data bindings, adaptive layout, and conditional rendering
|
|
51
51
|
- **Flows** — multi-screen navigation journeys, intent-based and platform-agnostic
|
|
52
52
|
- **Actions** — 13 typed action types with composition, error handling, and optimistic updates
|
|
@@ -80,7 +80,7 @@ When you ask your AI to "add a settings page" or "update the home feed," the MCP
|
|
|
80
80
|
|
|
81
81
|
**Using without MCP?** You can provide spec context to any AI manually:
|
|
82
82
|
|
|
83
|
-
> Generate a native iOS app from this OpenUISpec. Follow all contract
|
|
83
|
+
> Generate a native iOS app from this OpenUISpec. Follow all contract UI states, apply token ranges for iOS, and implement navigation flows as defined.
|
|
84
84
|
|
|
85
85
|
## Examples
|
|
86
86
|
|
package/docs/file-formats.md
CHANGED
|
@@ -77,7 +77,7 @@ generation:
|
|
|
77
77
|
language: kotlin
|
|
78
78
|
root: "../shared"
|
|
79
79
|
scope: "Business logic, data models, repositories, API clients, view models. No UI rendering."
|
|
80
|
-
# tracks: [manifest
|
|
80
|
+
# tracks: [manifest] # optional — enables hash-based drift detection for this layer
|
|
81
81
|
paths:
|
|
82
82
|
domain: "commonMain/domain/"
|
|
83
83
|
features: "commonMain/features/"
|
|
@@ -87,7 +87,7 @@ taskflow/
|
|
|
87
87
|
|
|
88
88
|
Pass the entire `taskflow/` directory as context to an AI code generator with the prompt:
|
|
89
89
|
|
|
90
|
-
> Generate a native {ios|android|web} application from this OpenUISpec. Follow all contract
|
|
90
|
+
> Generate a native {ios|android|web} application from this OpenUISpec. Follow all contract UI states, apply token ranges for the target platform, and implement the navigation flows as defined. Use the platform adaptation file for target-specific overrides.
|
|
91
91
|
|
|
92
92
|
The AI should produce:
|
|
93
93
|
1. Compilable platform code (Swift/Kotlin/TypeScript)
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"states": {
|
|
32
32
|
"type": "object",
|
|
33
|
-
"description": "
|
|
33
|
+
"description": "UI interaction states (e.g. idle, active, disabled, loading, error) — each key is a state name. These are visual/interaction states, not business logic states.",
|
|
34
34
|
"additionalProperties": {
|
|
35
35
|
"$ref": "https://openuispec.rsteam.uz/schema/custom-contract.schema.json#/$defs/state_def"
|
|
36
36
|
}
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
},
|
|
166
166
|
"state_def": {
|
|
167
167
|
"type": "object",
|
|
168
|
-
"description": "A single
|
|
168
|
+
"description": "A single UI interaction state",
|
|
169
169
|
"properties": {
|
|
170
170
|
"semantic": {
|
|
171
171
|
"type": "string"
|
|
@@ -38,22 +38,28 @@
|
|
|
38
38
|
"description": "Paths to spec component directories",
|
|
39
39
|
"properties": {
|
|
40
40
|
"tokens": {
|
|
41
|
-
"type": "string"
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Visual design tokens — colors, typography, spacing, elevation, motion. Affects UI rendering only, not business logic."
|
|
42
43
|
},
|
|
43
44
|
"contracts": {
|
|
44
|
-
"type": "string"
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Reusable UI component definitions — buttons, inputs, lists, surfaces. Each contract specifies visual props, UI interaction states (pressed, disabled, loading), and accessibility. These are UI rendering specifications, not business logic or domain state machines."
|
|
45
47
|
},
|
|
46
48
|
"screens": {
|
|
47
|
-
"type": "string"
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Screen layouts composed from contracts — defines what UI components appear on each screen, their data bindings, and visual arrangement."
|
|
48
51
|
},
|
|
49
52
|
"flows": {
|
|
50
|
-
"type": "string"
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Multi-screen navigation journeys — defines screen sequences, transitions, and navigation triggers. UI navigation structure, not business workflow logic."
|
|
51
55
|
},
|
|
52
56
|
"platform": {
|
|
53
|
-
"type": "string"
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "Per-target platform overrides — native UI behavior, framework-specific generation config. One file per target (ios.yaml, android.yaml, web.yaml)."
|
|
54
59
|
},
|
|
55
60
|
"locales": {
|
|
56
|
-
"type": "string"
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Localization string files — one JSON file per supported locale containing translated UI text."
|
|
57
63
|
}
|
|
58
64
|
},
|
|
59
65
|
"required": [
|
|
@@ -175,7 +181,7 @@
|
|
|
175
181
|
},
|
|
176
182
|
"tracks": {
|
|
177
183
|
"type": "array",
|
|
178
|
-
"description": "Spec categories this shared layer tracks for drift.
|
|
184
|
+
"description": "Spec categories this shared layer tracks for hash-based drift detection. Optional — when omitted, the layer relies on scope alone. Categories: manifest (project config, data models, API endpoints), tokens (visual design tokens — UI only), contracts (reusable UI component definitions — UI only, not business logic), screens (screen layouts — UI only), flows (navigation journeys — UI only), platform (per-target overrides — UI only), locales (translated UI strings).",
|
|
179
185
|
"items": {
|
|
180
186
|
"type": "string",
|
|
181
187
|
"enum": ["manifest", "tokens", "contracts", "screens", "flows", "platform", "locales"]
|
package/spec/openuispec-v0.1.md
CHANGED
|
@@ -19,7 +19,7 @@ OpenUISpec is a shared UI sync language for native products, optimized for solo
|
|
|
19
19
|
|
|
20
20
|
1. **Semantic over visual.** The spec defines behavioral intent, not pixel layouts. A "primary action trigger" maps to `Button` in SwiftUI, `Button` in Compose, and `<button>` in HTML — the spec never says "button."
|
|
21
21
|
2. **Constrained freedom.** Tokens use ranges, not exact values. Close enough to be recognizably the same brand; loose enough for each platform to feel native.
|
|
22
|
-
3. **Contract-driven.** Every component is a
|
|
22
|
+
3. **Contract-driven.** Every UI component is a reusable contract with typed props, UI interaction states (pressed, disabled, loading, error — not business logic states), and accessibility requirements. If a UI state exists in the spec, the generated code must handle it.
|
|
23
23
|
4. **AI-first authoring.** The spec is structured for machine consumption: strongly typed, validatable, with generation hints that tell AI what it must, should, and may produce.
|
|
24
24
|
5. **Platform respect.** iOS should feel like iOS. Android should feel like Android. Web should feel like the web. The spec preserves platform identity; it does not erase it.
|
|
25
25
|
|
|
@@ -555,7 +555,7 @@ The `custom` section follows the same shape as `registry` categories. App-specif
|
|
|
555
555
|
|
|
556
556
|
## 4. Component contracts
|
|
557
557
|
|
|
558
|
-
Each contract defines a **
|
|
558
|
+
Each contract defines a **reusable UI component family** — a category of UI elements that share the same role, props shape, UI interaction states, and accessibility pattern. The AI maps each contract to the most appropriate native widget per platform. Contracts describe how components look and respond to user interaction — they are UI rendering specifications, not business logic or domain state machines.
|
|
559
559
|
|
|
560
560
|
### Contract anatomy
|
|
561
561
|
|
|
@@ -565,7 +565,7 @@ Every contract contains:
|
|
|
565
565
|
|---------|---------|----------|
|
|
566
566
|
| `semantic` | Human-readable description of what this family does | Yes |
|
|
567
567
|
| `props` | Typed inputs the component accepts | Yes |
|
|
568
|
-
| `states` |
|
|
568
|
+
| `states` | UI interaction states (e.g. idle, pressed, disabled, loading, error) with valid transitions | Yes |
|
|
569
569
|
| `a11y` | Accessibility role, label pattern, focus behavior | Yes |
|
|
570
570
|
| `tokens` | Visual token bindings per variant | Yes |
|
|
571
571
|
| `platform_mapping` | Default native widget per platform | Yes |
|
|
@@ -1765,7 +1765,7 @@ When omitted, the item contract's default variant is used.
|
|
|
1765
1765
|
|
|
1766
1766
|
#### `state_binding`
|
|
1767
1767
|
|
|
1768
|
-
Binds a contract's
|
|
1768
|
+
Binds a contract's UI interaction states to data paths. This allows screen-level data to drive contract states declaratively, without requiring an explicit action.
|
|
1769
1769
|
|
|
1770
1770
|
```yaml
|
|
1771
1771
|
- contract: action_trigger
|
|
@@ -1783,7 +1783,7 @@ Binds a contract's state machine states to data paths. This allows screen-level
|
|
|
1783
1783
|
- Values must be data paths that resolve to `bool`
|
|
1784
1784
|
- When the bound value is `true`, the contract transitions to that state
|
|
1785
1785
|
- When the bound value returns to `false`, the contract transitions back to `default`
|
|
1786
|
-
- If multiple state bindings are `true` simultaneously, priority follows the contract's state
|
|
1786
|
+
- If multiple state bindings are `true` simultaneously, priority follows the contract's state priority order (e.g., `loading` takes precedence over `disabled`)
|
|
1787
1787
|
|
|
1788
1788
|
---
|
|
1789
1789
|
|
|
@@ -2966,7 +2966,7 @@ props:
|
|
|
2966
2966
|
condition: "tasks.$empty"
|
|
2967
2967
|
```
|
|
2968
2968
|
|
|
2969
|
-
Collection contracts handle `$loading`, `$error`, and `$empty` automatically via their
|
|
2969
|
+
Collection contracts handle `$loading`, `$error`, and `$empty` automatically via their built-in UI states (see Section 4.7). For non-collection data, screens can use `condition:` to show appropriate UI.
|
|
2970
2970
|
|
|
2971
2971
|
### 10.9 AI generation requirements
|
|
2972
2972
|
|
|
@@ -3161,7 +3161,7 @@ Custom contracts allow spec authors to define domain-specific component families
|
|
|
3161
3161
|
Use a custom contract when the component:
|
|
3162
3162
|
|
|
3163
3163
|
- Has domain-specific behavior that doesn't map cleanly to any built-in family
|
|
3164
|
-
- Requires
|
|
3164
|
+
- Requires dedicated UI interaction states (e.g., play/pause/seek for media)
|
|
3165
3165
|
- Needs platform-specific libraries or frameworks not covered by core contracts
|
|
3166
3166
|
- Would clutter the core spec if included as a built-in
|
|
3167
3167
|
|
|
@@ -3327,7 +3327,7 @@ ios:
|
|
|
3327
3327
|
|
|
3328
3328
|
**MUST:**
|
|
3329
3329
|
- Read and parse all registered custom contract definitions before generating code
|
|
3330
|
-
- Handle every declared
|
|
3330
|
+
- Handle every declared UI interaction state
|
|
3331
3331
|
- Apply `platform_mapping` to select the correct native component
|
|
3332
3332
|
- Include all `dependencies` in the generated project configuration (Package.swift, build.gradle, package.json)
|
|
3333
3333
|
- Implement all items listed in `generation.must_handle`
|
|
@@ -3822,7 +3822,7 @@ A drift detector compares:
|
|
|
3822
3822
|
- **Spec → Code**: Does the generated code match what the spec describes? (e.g., a button's action type, a screen's data sources, a flow's step order)
|
|
3823
3823
|
- **Code → Spec**: Does the current platform code contain UI decisions not reflected in the spec? (e.g., a new field added to a form, a navigation path changed)
|
|
3824
3824
|
|
|
3825
|
-
Drift detection is scoped to the semantic layer — it compares behavioral intent (contracts, props,
|
|
3825
|
+
Drift detection is scoped to the semantic layer — it compares behavioral intent (contracts, props, UI interaction states, data bindings), not visual details (padding values, animation curves). Platform-specific polish is expected to diverge from the spec; behavioral contracts are not.
|
|
3826
3826
|
|
|
3827
3827
|
Resolution strategies:
|
|
3828
3828
|
- **Update spec** — The code change is intentional; update the spec to match
|