openuispec 0.1.15 → 0.1.17

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
@@ -17,11 +17,19 @@ The result: each platform feels native, but every app stays consistent because i
17
17
 
18
18
  ## How it works
19
19
 
20
- ![How OpenUISpec works](https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/how-it-works.jpg)
20
+ <picture>
21
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/how-it-works-dark.png">
22
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/how-it-works-light.png">
23
+ <img alt="How OpenUISpec works" src="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/how-it-works-light.png">
24
+ </picture>
21
25
 
22
26
  ## Workflows
23
27
 
24
- ![OpenUISpec workflows](https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/workflows.png)
28
+ <picture>
29
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/workflows-dark.png">
30
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/workflows-light.png">
31
+ <img alt="OpenUISpec workflows" src="https://raw.githubusercontent.com/rsktash/openuispec/main/docs/images/workflows-light.png">
32
+ </picture>
25
33
 
26
34
  ## Key concepts
27
35
 
@@ -62,7 +70,8 @@ openuispec/
62
70
  │ ├── flow.schema.json # Navigation flow schema
63
71
  │ ├── platform.schema.json # Platform adaptation schema
64
72
  │ ├── locale.schema.json # Locale file schema
65
- │ ├── custom-contract.schema.json # Custom contract extension schema
73
+ │ ├── contract.schema.json # Standard contract extension schema
74
+ │ ├── custom-contract.schema.json # Custom contract extension schema (x_ prefixed)
66
75
  │ ├── tokens/
67
76
  │ │ ├── color.schema.json # Color token schema
68
77
  │ │ ├── typography.schema.json # Typography token schema
@@ -91,7 +100,8 @@ openuispec/
91
100
  │ │ ├── layout.yaml # Size classes, primitives, reflow rules
92
101
  │ │ ├── themes.yaml # Light, dark, warm variants
93
102
  │ │ └── icons.yaml # Icon registry with platform mappings
94
- │ ├── contracts/ # 7 contract family stubs + custom contracts
103
+ │ ├── contracts/ # Standard contract extensions + custom contracts
104
+ │ │ ├── input_field.yaml # Standard contract with cut_corner variant
95
105
  │ │ └── x_media_player.yaml # Custom media player contract (Section 12)
96
106
  │ ├── screens/
97
107
  │ │ ├── home.yaml # Task list with search, filters, FAB, adaptive nav
@@ -130,7 +140,8 @@ Every file type has a corresponding JSON Schema in `schema/`. **Read the schema
130
140
  | `flows/*.yaml` | `flow.schema.json` | `<flow_id>` | [create_task.yaml](./examples/taskflow/flows/create_task.yaml) |
131
141
  | `platform/*.yaml` | `platform.schema.json` | `platform` | [ios.yaml](./examples/taskflow/platform/ios.yaml) |
132
142
  | `locales/*.json` | `locale.schema.json` | (object) | [en.json](./examples/taskflow/locales/en.json) |
133
- | `contracts/x_*.yaml` | `custom-contract.schema.json` | `contract` | [x_media_player.yaml](./examples/taskflow/contracts/x_media_player.yaml) |
143
+ | `contracts/<name>.yaml` | `contract.schema.json` | `<contract_name>` | [input_field.yaml](./examples/taskflow/contracts/input_field.yaml) |
144
+ | `contracts/x_*.yaml` | `custom-contract.schema.json` | `<x_name>` | [x_media_player.yaml](./examples/taskflow/contracts/x_media_player.yaml) |
134
145
  | `tokens/color.yaml` | `tokens/color.schema.json` | `color` | [color.yaml](./examples/taskflow/tokens/color.yaml) |
135
146
  | `tokens/typography.yaml` | `tokens/typography.schema.json` | `typography` | [typography.yaml](./examples/taskflow/tokens/typography.yaml) |
136
147
  | `tokens/spacing.yaml` | `tokens/spacing.schema.json` | `spacing` | [spacing.yaml](./examples/taskflow/tokens/spacing.yaml) |
package/cli/init.ts CHANGED
@@ -137,7 +137,7 @@ OpenUISpec is a YAML-based format that describes your app's UI semantically —
137
137
  | \`tokens/\` | Design tokens — colors, typography, spacing, elevation, motion, icons, themes |
138
138
  | \`screens/\` | Screen definitions — one YAML file per screen |
139
139
  | \`flows/\` | Navigation flows — multi-step user journeys |
140
- | \`contracts/\` | Component contracts — custom UI component definitions (\`x_\` prefixed) |
140
+ | \`contracts/\` | Component contracts — standard extensions (variants, tokens) and custom (\`x_\` prefixed) |
141
141
  | \`platform/\` | Platform overrides — per-target (iOS, Android, Web) behaviors |
142
142
  | \`locales/\` | Localization — i18n strings (JSON, ICU MessageFormat) |
143
143
 
@@ -222,7 +222,8 @@ Root keys: \`color\`, \`typography\`, \`spacing\`, \`elevation\`, \`motion\`, \`
222
222
  | \`flows/*.yaml\` | \`flow.schema.json\` | \`<flow_id>\` |
223
223
  | \`platform/*.yaml\` | \`platform.schema.json\` | \`platform\` |
224
224
  | \`locales/*.json\` | \`locale.schema.json\` | (object) |
225
- | \`contracts/x_*.yaml\` | \`custom-contract.schema.json\` | \`contract\` |
225
+ | \`contracts/<name>.yaml\` | \`contract.schema.json\` | \`<contract_name>\` |
226
+ | \`contracts/x_*.yaml\` | \`custom-contract.schema.json\` | \`<x_name>\` |
226
227
  | \`tokens/color.yaml\` | \`tokens/color.schema.json\` | \`color\` |
227
228
  | \`tokens/typography.yaml\` | \`tokens/typography.schema.json\` | \`typography\` |
228
229
  | \`tokens/spacing.yaml\` | \`tokens/spacing.schema.json\` | \`spacing\` |
@@ -300,7 +301,7 @@ OpenUISpec is a YAML-based spec format that describes an app's UI semantically
300
301
  - Tokens: \`${specDir}/tokens/\` — colors, typography, spacing, motion, icons, themes
301
302
  - Screens: \`${specDir}/screens/\` — one YAML file per screen
302
303
  - Flows: \`${specDir}/flows/\` — multi-step navigation journeys
303
- - Contracts: \`${specDir}/contracts/\` — UI component definitions
304
+ - Contracts: \`${specDir}/contracts/\` — standard extensions (variants, tokens) and custom (\`x_\` prefixed)
304
305
  - Platform: \`${specDir}/platform/\` — per-target overrides (iOS, Android, Web)
305
306
  - Locales: \`${specDir}/locales/\` — i18n strings (JSON, ICU MessageFormat)
306
307
 
@@ -373,7 +374,8 @@ Before creating or editing any spec file, read the corresponding JSON Schema. Do
373
374
  | \`flows/*.yaml\` | \`flow.schema.json\` | \`<flow_id>\` |
374
375
  | \`platform/*.yaml\` | \`platform.schema.json\` | \`platform\` |
375
376
  | \`locales/*.json\` | \`locale.schema.json\` | (object) |
376
- | \`contracts/x_*.yaml\` | \`custom-contract.schema.json\` | \`contract\` |
377
+ | \`contracts/<name>.yaml\` | \`contract.schema.json\` | \`<contract_name>\` |
378
+ | \`contracts/x_*.yaml\` | \`custom-contract.schema.json\` | \`<x_name>\` |
377
379
  | \`tokens/color.yaml\` | \`tokens/color.schema.json\` | \`color\` |
378
380
  | \`tokens/typography.yaml\` | \`tokens/typography.schema.json\` | \`typography\` |
379
381
  | \`tokens/spacing.yaml\` | \`tokens/spacing.schema.json\` | \`spacing\` |
Binary file
Binary file
@@ -1,7 +1,4 @@
1
- # action_trigger contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # action_trigger contract extension
2
+ # Base definition: spec Section 4.1
4
3
 
5
- contract: action_trigger
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ action_trigger: {}
@@ -1,7 +1,4 @@
1
- # collection contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # collection contract extension
2
+ # Base definition: spec Section 4.7
4
3
 
5
- contract: collection
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ collection: {}
@@ -1,7 +1,4 @@
1
- # data_display contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # data_display contract extension
2
+ # Base definition: spec Section 4.2
4
3
 
5
- contract: data_display
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ data_display: {}
@@ -1,7 +1,4 @@
1
- # feedback contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # feedback contract extension
2
+ # Base definition: spec Section 4.5
4
3
 
5
- contract: feedback
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ feedback: {}
@@ -1,7 +1,23 @@
1
- # input_field contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # input_field contract extension
2
+ # Base definition: spec Section 4.3
3
+ # Add project-specific variants, token overrides, and generation hints.
4
4
 
5
- contract: input_field
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
5
+ input_field:
6
+ variants:
7
+ cut_corner:
8
+ semantic: "Angled corner input for branded forms"
9
+ tokens:
10
+ cut_size: "spacing.sm"
11
+ border: { color: "color.semantic.border", width: 1 }
12
+ background: "color.semantic.surface"
13
+ platform_mapping:
14
+ ios: { shape: "CutCornerShape", clip: true }
15
+ android: { shape: "CutCornerShape" }
16
+ web: { style: "clip-path" }
17
+ generation:
18
+ must_handle:
19
+ - "Cut top-right and bottom-left corners by cut_size"
20
+ - "Maintain focus ring that follows the cut shape"
21
+ - "Placeholder text must remain readable against background"
22
+ should_handle:
23
+ - "Animate corner cut on focus"
@@ -1,7 +1,4 @@
1
- # nav_container contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # nav_container contract extension
2
+ # Base definition: spec Section 4.4
4
3
 
5
- contract: nav_container
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ nav_container: {}
@@ -1,7 +1,4 @@
1
- # surface contract — see spec Section 4 for full definition
2
- # This file serves as a machine-readable reference for AI generators.
3
- # The canonical definition lives in spec/openuispec-v0.1.md.
1
+ # surface contract extension
2
+ # Base definition: spec Section 4.6
4
3
 
5
- contract: surface
6
- spec_section: "4"
7
- source: "spec/openuispec-v0.1.md"
4
+ surface: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openuispec",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A semantic UI specification format for AI-native, platform-native app development",
@@ -0,0 +1,129 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openuispec.org/schema/contract.schema.json",
4
+ "title": "OpenUISpec Standard Contract Extension",
5
+ "description": "Extension file for a standard contract — add variants, override tokens, platform mapping, and generation hints",
6
+ "type": "object",
7
+ "minProperties": 1,
8
+ "maxProperties": 1,
9
+ "propertyNames": {
10
+ "enum": [
11
+ "action_trigger",
12
+ "data_display",
13
+ "input_field",
14
+ "nav_container",
15
+ "feedback",
16
+ "surface",
17
+ "collection"
18
+ ]
19
+ },
20
+ "additionalProperties": {
21
+ "$ref": "#/$defs/contract_extension"
22
+ },
23
+ "$defs": {
24
+ "contract_extension": {
25
+ "type": "object",
26
+ "description": "Extension definition — all fields are optional, they add to or override the spec-defined contract",
27
+ "properties": {
28
+ "variants": {
29
+ "type": "object",
30
+ "description": "Named style/behavior variants (e.g. cut_corner, branded, minimal)",
31
+ "additionalProperties": {
32
+ "$ref": "#/$defs/variant_def"
33
+ }
34
+ },
35
+ "additional_props": {
36
+ "type": "object",
37
+ "description": "Additional props beyond the spec definition",
38
+ "additionalProperties": {
39
+ "$ref": "https://openuispec.org/schema/custom-contract.schema.json#/$defs/prop_def"
40
+ }
41
+ },
42
+ "tokens": {
43
+ "type": "object",
44
+ "description": "Token overrides at the contract level",
45
+ "additionalProperties": true
46
+ },
47
+ "platform_mapping": {
48
+ "type": "object",
49
+ "description": "Platform mapping overrides",
50
+ "properties": {
51
+ "ios": { "type": "object", "additionalProperties": true },
52
+ "android": { "type": "object", "additionalProperties": true },
53
+ "web": { "type": "object", "additionalProperties": true }
54
+ },
55
+ "additionalProperties": {
56
+ "type": "object",
57
+ "additionalProperties": true
58
+ }
59
+ },
60
+ "generation": {
61
+ "type": "object",
62
+ "description": "AI generation compliance hints (merged with spec defaults)",
63
+ "properties": {
64
+ "must_handle": {
65
+ "type": "array",
66
+ "items": { "type": "string" }
67
+ },
68
+ "should_handle": {
69
+ "type": "array",
70
+ "items": { "type": "string" }
71
+ },
72
+ "may_handle": {
73
+ "type": "array",
74
+ "items": { "type": "string" }
75
+ }
76
+ },
77
+ "additionalProperties": false
78
+ },
79
+ "test_cases": {
80
+ "type": "array",
81
+ "description": "Additional behavioral test cases",
82
+ "items": {
83
+ "$ref": "https://openuispec.org/schema/custom-contract.schema.json#/$defs/test_case"
84
+ }
85
+ }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "variant_def": {
90
+ "type": "object",
91
+ "description": "A named variant with semantic description, tokens, platform mapping, and generation hints",
92
+ "properties": {
93
+ "semantic": {
94
+ "type": "string",
95
+ "description": "Human-readable description of this variant"
96
+ },
97
+ "tokens": {
98
+ "type": "object",
99
+ "description": "Visual token bindings for this variant",
100
+ "additionalProperties": true
101
+ },
102
+ "platform_mapping": {
103
+ "type": "object",
104
+ "description": "Per-platform implementation hints for this variant",
105
+ "properties": {
106
+ "ios": { "type": "object", "additionalProperties": true },
107
+ "android": { "type": "object", "additionalProperties": true },
108
+ "web": { "type": "object", "additionalProperties": true }
109
+ },
110
+ "additionalProperties": {
111
+ "type": "object",
112
+ "additionalProperties": true
113
+ }
114
+ },
115
+ "generation": {
116
+ "type": "object",
117
+ "description": "Generation hints specific to this variant",
118
+ "properties": {
119
+ "must_handle": { "type": "array", "items": { "type": "string" } },
120
+ "should_handle": { "type": "array", "items": { "type": "string" } },
121
+ "may_handle": { "type": "array", "items": { "type": "string" } }
122
+ },
123
+ "additionalProperties": false
124
+ }
125
+ },
126
+ "additionalProperties": false
127
+ }
128
+ }
129
+ }
@@ -275,18 +275,17 @@ const GROUPS: Record<string, ValidationGroup> = {
275
275
  },
276
276
  },
277
277
 
278
- custom_contracts: {
279
- label: "Custom contracts",
278
+ contracts: {
279
+ label: "Contracts",
280
280
  run(ajv, projectDir, includes) {
281
281
  let errors = 0;
282
282
  const dir = resolveInclude(projectDir, includes.contracts);
283
283
  for (const f of listFiles(dir, ".yaml")) {
284
- if (basename(f).startsWith("x_")) {
285
- errors += validateFile(
286
- ajv,
287
- f,
288
- `${BASE}custom-contract.schema.json`,
289
- );
284
+ const name = basename(f);
285
+ if (name.startsWith("x_")) {
286
+ errors += validateFile(ajv, f, `${BASE}custom-contract.schema.json`);
287
+ } else {
288
+ errors += validateFile(ajv, f, `${BASE}contract.schema.json`);
290
289
  }
291
290
  }
292
291
  return errors;
Binary file
Binary file