openuispec 0.2.2 → 0.2.3

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.
@@ -1,5 +1,5 @@
1
1
  <!-- openuispec-rules-start -->
2
- <!-- openuispec-rules-version: 0.2.1 -->
2
+ <!-- openuispec-rules-version: 0.2.2 -->
3
3
  # OpenUISpec — AI Assistant Rules
4
4
  # ================================
5
5
  # This project uses OpenUISpec to define UI as a semantic spec.
@@ -1,5 +1,5 @@
1
1
  <!-- openuispec-rules-start -->
2
- <!-- openuispec-rules-version: 0.2.1 -->
2
+ <!-- openuispec-rules-version: 0.2.2 -->
3
3
  # OpenUISpec — AI Assistant Rules
4
4
  # ================================
5
5
  # This project uses OpenUISpec to define UI as a semantic spec.
@@ -65,6 +65,39 @@ function toolError(err: unknown): { content: [{ type: "text"; text: string }]; i
65
65
  return { content: [{ type: "text" as const, text: `Error: ${formatError(err)}` }], isError: true };
66
66
  }
67
67
 
68
+ function formatAuditValue(value: unknown): string {
69
+ if (typeof value === "string") return value;
70
+ return JSON.stringify(value);
71
+ }
72
+
73
+ function collectStateRoleAuditItems(node: unknown, prefix = ""): string[] {
74
+ if (!node || typeof node !== "object" || Array.isArray(node)) {
75
+ return [];
76
+ }
77
+
78
+ const items: string[] = [];
79
+ const record = node as Record<string, unknown>;
80
+
81
+ const states = record.states;
82
+ if (states && typeof states === "object" && !Array.isArray(states)) {
83
+ for (const [stateName, roles] of Object.entries(states as Record<string, unknown>)) {
84
+ if (!roles || typeof roles !== "object" || Array.isArray(roles)) continue;
85
+ for (const [roleName, roleValue] of Object.entries(roles as Record<string, unknown>)) {
86
+ const statePath = prefix ? `${prefix}.states.${stateName}.${roleName}` : `states.${stateName}.${roleName}`;
87
+ items.push(`${statePath} = ${formatAuditValue(roleValue)}`);
88
+ }
89
+ }
90
+ }
91
+
92
+ for (const [key, value] of Object.entries(record)) {
93
+ if (key === "states" || !value || typeof value !== "object" || Array.isArray(value)) continue;
94
+ const childPrefix = prefix ? `${prefix}.${key}` : key;
95
+ items.push(...collectStateRoleAuditItems(value, childPrefix));
96
+ }
97
+
98
+ return items;
99
+ }
100
+
68
101
  // ── create server ────────────────────────────────────────────────────
69
102
 
70
103
  export const server = new McpServer(
@@ -173,6 +206,17 @@ function buildAuditChecklist(projectDir: string, target: string, screenFilter?:
173
206
  lines.push(`- [ ] ${item}`);
174
207
  }
175
208
  }
209
+
210
+ const stateRoleItems = collectStateRoleAuditItems(variant?.tokens);
211
+ if (stateRoleItems.length) {
212
+ if (!mustHandle?.length) {
213
+ lines.push(`\n### ${contractName}.${variantName}`);
214
+ }
215
+ lines.push(`- [ ] Explicit state-role tokens are implemented for ${contractName}.${variantName}`);
216
+ for (const item of stateRoleItems) {
217
+ lines.push(`- [ ] ${item}`);
218
+ }
219
+ }
176
220
  }
177
221
 
178
222
  // Top-level generation.must_handle
@@ -183,6 +227,14 @@ function buildAuditChecklist(projectDir: string, target: string, screenFilter?:
183
227
  lines.push(`- [ ] ${item}`);
184
228
  }
185
229
  }
230
+
231
+ const topLevelStateRoleItems = collectStateRoleAuditItems(contract?.tokens);
232
+ if (topLevelStateRoleItems.length) {
233
+ lines.push(`\n### ${contractName} (state-role tokens)`);
234
+ for (const item of topLevelStateRoleItems) {
235
+ lines.push(`- [ ] ${item}`);
236
+ }
237
+ }
186
238
  } catch { /* skip unparseable files */ }
187
239
  }
188
240
  lines.push("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openuispec",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A semantic UI specification format for AI-native, platform-native app development",