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.
Files changed (2) hide show
  1. package/cli/init.ts +53 -35
  2. 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
- - Always read \`openuispec.yaml\` first to understand the project structure.
133
-
134
- ## Before making UI changes
135
- 1. Read the relevant spec files (screens, tokens, flows) before modifying any UI code.
136
- 2. If the change requires a spec update, modify the spec files FIRST, then update generated code.
137
- 3. Never modify generated code directly change the spec and regenerate.
138
-
139
- ## After modifying spec files
140
- 1. Run \`openuispec drift --snapshot --target <target>\` for each affected platform.
141
- 2. Targets in this project: ${targetList}.
142
- 3. Run \`openuispec drift\` to verify no untracked drift remains.
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\` — in progress, actively being specced. Tracked by drift.
161
+ - \`draft\` — actively being specced. Tracked by drift.
148
162
  - \`ready\` — fully specified (default if omitted). Tracked by drift.
149
163
 
150
- When adopting OpenUISpec in an existing project:
151
- 1. Create spec files for existing screens as \`status: stub\` initially.
152
- 2. When speccing a screen from existing code, change status to \`draft\`.
153
- 3. Once the spec is complete and reviewed, change to \`ready\` (or remove the field).
154
- 4. Only \`draft\` and \`ready\` screens trigger drift failures in CI.
155
-
156
- ## Spec file conventions
157
- - Tokens (colors, typography, spacing, motion, icons) live in \`${specDir}/tokens/\`.
158
- - Contracts (UI component definitions) live in \`${specDir}/contracts/\`.
159
- - Screens live in \`${specDir}/screens/\`. One screen per file.
160
- - Navigation flows live in \`${specDir}/flows/\`.
161
- - Platform overrides live in \`${specDir}/platform/\`.
162
- - Localization strings live in \`${specDir}/locales/\`.
163
-
164
- ## Key rules
165
- - The spec uses 7 contract families: nav_container, surface, action_trigger, input_field, data_display, collection, feedback.
166
- - Custom contracts are prefixed with \`x_\` (e.g., \`x_media_player\`).
167
- - Data binding uses \`$data:\`, \`$state:\`, \`$param:\`, \`$t:\` prefixes.
168
- - Actions use typed action objects (navigate, api_call, set_state, confirm, etc.).
169
- - When adding a new screen, also create the corresponding spec file.
170
- - When renaming or removing a screen, update the spec and all flow references.
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openuispec",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A semantic UI specification format for AI-native, platform-native app development",