openuispec 0.1.4 → 0.1.5
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/cli/init.ts +53 -35
- package/package.json +1 -1
package/cli/init.ts
CHANGED
|
@@ -125,49 +125,67 @@ function aiRulesBlock(specDir: string, targets: string[]): string {
|
|
|
125
125
|
# ================================
|
|
126
126
|
# This project uses OpenUISpec to define UI as a semantic spec.
|
|
127
127
|
# Spec files are the single source of truth for all UI across platforms.
|
|
128
|
+
# Targets: ${targetList}
|
|
129
|
+
|
|
130
|
+
## What is OpenUISpec
|
|
131
|
+
OpenUISpec is a YAML-based spec format that describes an app's UI semantically — tokens, screens, flows, and platform overrides. AI reads the spec and generates native code (SwiftUI, Compose, React). AI reads native code and updates the spec. The spec is the sync layer between platforms.
|
|
128
132
|
|
|
129
133
|
## Spec location
|
|
130
134
|
- Spec root: \`${specDir}/\`
|
|
131
|
-
- Manifest: \`${specDir}/openuispec.yaml\`
|
|
132
|
-
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
##
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
- Manifest: \`${specDir}/openuispec.yaml\` — always read this first.
|
|
136
|
+
- Tokens: \`${specDir}/tokens/\` — colors, typography, spacing, motion, icons, themes
|
|
137
|
+
- Screens: \`${specDir}/screens/\` — one YAML file per screen
|
|
138
|
+
- Flows: \`${specDir}/flows/\` — multi-step navigation journeys
|
|
139
|
+
- Contracts: \`${specDir}/contracts/\` — UI component definitions
|
|
140
|
+
- Platform: \`${specDir}/platform/\` — per-target overrides (iOS, Android, Web)
|
|
141
|
+
- Locales: \`${specDir}/locales/\` — i18n strings (JSON, ICU MessageFormat)
|
|
142
|
+
|
|
143
|
+
## If spec directories are empty (first-time setup)
|
|
144
|
+
This means the project has existing UI code but hasn't been specced yet. Your job:
|
|
145
|
+
|
|
146
|
+
1. **Find existing screens** — scan the codebase for UI screen files (SwiftUI views, Compose screens, React components/pages).
|
|
147
|
+
2. **Create stubs** — for each screen, create \`${specDir}/screens/<name>.yaml\` with:
|
|
148
|
+
\`\`\`yaml
|
|
149
|
+
screen_name:
|
|
150
|
+
semantic: "Brief description of what this screen does"
|
|
151
|
+
status: stub
|
|
152
|
+
layout:
|
|
153
|
+
type: scroll_vertical
|
|
154
|
+
\`\`\`
|
|
155
|
+
3. **Extract tokens** — scan the codebase for colors, fonts, spacing values and create token files in \`${specDir}/tokens/\`.
|
|
156
|
+
4. **Update the manifest** — fill in \`data_model\` and \`api.endpoints\` in \`${specDir}/openuispec.yaml\` based on the existing code.
|
|
157
|
+
5. **Spec screens on demand** — when the user asks to spec a screen, read the native code, create a full spec, and change \`status: draft\` → \`ready\`.
|
|
143
158
|
|
|
144
159
|
## Screen and flow status
|
|
145
|
-
Screens and flows have a \`status\` field that controls drift tracking:
|
|
146
160
|
- \`stub\` — placeholder, not yet specced. Drift detection skips these.
|
|
147
|
-
- \`draft\` —
|
|
161
|
+
- \`draft\` — actively being specced. Tracked by drift.
|
|
148
162
|
- \`ready\` — fully specified (default if omitted). Tracked by drift.
|
|
149
163
|
|
|
150
|
-
|
|
151
|
-
1.
|
|
152
|
-
2.
|
|
153
|
-
3.
|
|
154
|
-
4.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
-
|
|
164
|
+
## Making UI changes
|
|
165
|
+
1. Read the relevant spec files before modifying any UI code.
|
|
166
|
+
2. If the change requires a spec update, modify the spec FIRST, then update code.
|
|
167
|
+
3. Never modify generated code without updating the spec.
|
|
168
|
+
4. When adding a new screen, create the corresponding spec file.
|
|
169
|
+
5. When removing a screen, remove the spec file and update flow references.
|
|
170
|
+
|
|
171
|
+
## After modifying spec files
|
|
172
|
+
1. Run \`openuispec validate\` to check specs against the schema.
|
|
173
|
+
2. Run \`openuispec drift --snapshot --target <target>\` for each affected platform.
|
|
174
|
+
3. Run \`openuispec drift\` to verify no untracked drift remains.
|
|
175
|
+
|
|
176
|
+
## Spec format reference
|
|
177
|
+
- 7 contract families: nav_container, surface, action_trigger, input_field, data_display, collection, feedback
|
|
178
|
+
- Custom contracts: prefixed with \`x_\` (e.g., \`x_media_player\`)
|
|
179
|
+
- Data binding: \`$data:\`, \`$state:\`, \`$param:\`, \`$t:\` prefixes
|
|
180
|
+
- Actions: typed objects (navigate, api_call, set_state, confirm, sequence, feedback, etc.)
|
|
181
|
+
- Adaptive layout: size classes (compact, regular, expanded) with per-section overrides
|
|
182
|
+
|
|
183
|
+
## CLI commands
|
|
184
|
+
- \`openuispec init\` — scaffold a new spec project
|
|
185
|
+
- \`openuispec validate [group...]\` — validate spec files against schemas
|
|
186
|
+
- \`openuispec drift --target <t>\` — check for spec drift
|
|
187
|
+
- \`openuispec drift --snapshot --target <t>\` — snapshot current state
|
|
188
|
+
- \`openuispec drift --all\` — include stubs in drift check
|
|
171
189
|
`;
|
|
172
190
|
}
|
|
173
191
|
|