ui-director-skill 0.1.0

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/lib/core.mjs ADDED
@@ -0,0 +1,482 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { execFileSync } from 'node:child_process';
3
+ import {
4
+ cpSync,
5
+ existsSync,
6
+ lstatSync,
7
+ mkdirSync,
8
+ readFileSync,
9
+ renameSync,
10
+ rmSync,
11
+ writeFileSync,
12
+ } from 'node:fs';
13
+ import { dirname, join, resolve } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ export const packageRoot = resolve(__dirname, '..');
18
+
19
+ export function readJson(path) {
20
+ return JSON.parse(readFileSync(path, 'utf8'));
21
+ }
22
+
23
+ export function packageVersion() {
24
+ return readJson(join(packageRoot, 'package.json')).version;
25
+ }
26
+
27
+ export function providersConfig() {
28
+ return readJson(join(packageRoot, 'config', 'providers.json'));
29
+ }
30
+
31
+ export function capabilitiesConfig() {
32
+ return readJson(join(packageRoot, 'config', 'capabilities.json'));
33
+ }
34
+
35
+ export function adapterConfig(name) {
36
+ return readJson(join(packageRoot, 'adapters', `${name}.json`));
37
+ }
38
+
39
+ export function projectState(root = process.cwd()) {
40
+ return join(resolve(root), '.ui-director');
41
+ }
42
+
43
+ export function providerDir(root, name) {
44
+ return join(projectState(root), 'providers', name);
45
+ }
46
+
47
+ export function lockPath(root) {
48
+ return join(projectState(root), 'skills.lock.json');
49
+ }
50
+
51
+ export function run(cmd, args, opts = {}) {
52
+ const output = execFileSync(cmd, args, {
53
+ cwd: opts.cwd || process.cwd(),
54
+ encoding: 'utf8',
55
+ stdio: opts.stdio || ['ignore', 'pipe', 'pipe'],
56
+ env: process.env,
57
+ });
58
+ return output == null ? '' : String(output).trim();
59
+ }
60
+
61
+ export function commandExists(cmd) {
62
+ try {
63
+ const probe = process.platform === 'win32' ? 'where' : 'which';
64
+ run(probe, [cmd]);
65
+ return true;
66
+ } catch {
67
+ return false;
68
+ }
69
+ }
70
+
71
+ export function git(args, cwd, stdio) {
72
+ return run('git', args, { cwd, stdio });
73
+ }
74
+
75
+ export function shortSha(sha) {
76
+ return sha ? sha.slice(0, 8) : '-';
77
+ }
78
+
79
+ export function currentCommit(dir) {
80
+ if (!existsSync(join(dir, '.git'))) return null;
81
+ try { return git(['rev-parse', 'HEAD'], dir); } catch { return null; }
82
+ }
83
+
84
+ export function currentTree(dir) {
85
+ if (!existsSync(join(dir, '.git'))) return null;
86
+ try { return git(['rev-parse', 'HEAD^{tree}'], dir); } catch { return null; }
87
+ }
88
+
89
+ export function remoteCommit(dir, branch) {
90
+ try { return git(['rev-parse', `origin/${branch}`], dir); } catch { return null; }
91
+ }
92
+
93
+ export function ensureState(root) {
94
+ mkdirSync(join(projectState(root), 'providers'), { recursive: true });
95
+ }
96
+
97
+ function isObjectId(value) {
98
+ return typeof value === 'string' && /^[0-9a-f]{40}$/i.test(value);
99
+ }
100
+
101
+ function normalizedRemote(value) {
102
+ return String(value || '').trim().replace(/\/+$/, '').replace(/\.git$/, '');
103
+ }
104
+
105
+ function remoteUrl(dir) {
106
+ try { return git(['remote', 'get-url', 'origin'], dir); } catch { return null; }
107
+ }
108
+
109
+ function assertProviderRemote(dir, name, cfg) {
110
+ const actual = remoteUrl(dir);
111
+ if (!actual) throw new Error(`${name} has no origin remote; refusing to fetch an unverified provider.`);
112
+ if (normalizedRemote(actual) !== normalizedRemote(cfg.repo)) {
113
+ throw new Error(`${name} origin mismatch: expected ${cfg.repo}, found ${actual}.`);
114
+ }
115
+ }
116
+
117
+ function assertCleanCheckout(dir, name) {
118
+ const changes = checkoutChanges(dir);
119
+ if (changes) {
120
+ throw new Error(`${name} has local changes; refusing to overwrite the provider checkout.`);
121
+ }
122
+ }
123
+
124
+ function checkoutChanges(dir) {
125
+ return git(['status', '--porcelain', '--untracked-files=all'], dir);
126
+ }
127
+
128
+ export function installProvider(root, name, cfg, lockedCommit = null) {
129
+ const dir = providerDir(root, name);
130
+ if (lockedCommit && !isObjectId(lockedCommit)) {
131
+ throw new Error(`${name}: lockfile commit must be a full 40-character Git object id.`);
132
+ }
133
+
134
+ if (existsSync(join(dir, '.git'))) {
135
+ const before = currentCommit(dir);
136
+ if (!before) throw new Error(`${name}: provider checkout has no readable HEAD.`);
137
+ assertProviderRemote(dir, name, cfg);
138
+ if (!lockedCommit || before === lockedCommit) {
139
+ return { changed: false, created: false, commit: before };
140
+ }
141
+
142
+ assertCleanCheckout(dir, name);
143
+ try {
144
+ git(['fetch', '--depth', '1', 'origin', lockedCommit], dir, 'ignore');
145
+ git(['reset', '--hard', lockedCommit], dir, 'ignore');
146
+ } catch {
147
+ throw new Error(`${name}: locked commit ${lockedCommit} could not be fetched. Run 'ui update ${name}' only if you intentionally want a newer version.`);
148
+ }
149
+ const after = currentCommit(dir);
150
+ if (after !== lockedCommit) {
151
+ throw new Error(`${name}: checkout did not reach locked commit ${lockedCommit}.`);
152
+ }
153
+ return { changed: after !== before, created: false, commit: after };
154
+ }
155
+
156
+ if (existsSync(dir)) {
157
+ throw new Error(`${name}: provider path exists but is not a Git checkout; refusing to remove it automatically: ${dir}`);
158
+ }
159
+ mkdirSync(dirname(dir), { recursive: true });
160
+ console.log(` cloning ${name}...`);
161
+ run('git', ['clone', '--depth', '20', '--branch', cfg.branch, cfg.repo, dir], { stdio: 'inherit' });
162
+
163
+ // If the project already has a lockfile, reproduce that exact provider commit.
164
+ if (lockedCommit && currentCommit(dir) !== lockedCommit) {
165
+ try {
166
+ git(['fetch', '--depth', '1', 'origin', lockedCommit], dir, 'ignore');
167
+ git(['reset', '--hard', lockedCommit], dir, 'ignore');
168
+ } catch {
169
+ throw new Error(`${name}: locked commit ${lockedCommit} could not be fetched. Run 'ui update ${name}' only if you intentionally want a newer version.`);
170
+ }
171
+ }
172
+ const commit = currentCommit(dir);
173
+ if (!commit) throw new Error(`${name}: clone completed without a readable HEAD.`);
174
+ if (lockedCommit && commit !== lockedCommit) {
175
+ throw new Error(`${name}: clone did not reach locked commit ${lockedCommit}.`);
176
+ }
177
+ return { changed: true, created: true, commit };
178
+ }
179
+
180
+ function candidateExists(base, rel) {
181
+ try { return lstatSync(join(base, ...rel.split('/'))).isFile(); } catch { return false; }
182
+ }
183
+
184
+ export function validateProvider(root, name) {
185
+ const dir = providerDir(root, name);
186
+ const adapter = adapterConfig(name);
187
+ const errors = [];
188
+
189
+ if (!existsSync(join(dir, '.git'))) {
190
+ errors.push('provider checkout is missing');
191
+ return { ok: false, errors };
192
+ }
193
+
194
+ const cfg = providersConfig().providers[name];
195
+ const actualRemote = remoteUrl(dir);
196
+ if (!actualRemote) {
197
+ errors.push('provider origin remote is missing');
198
+ } else if (!cfg || normalizedRemote(actualRemote) !== normalizedRemote(cfg.repo)) {
199
+ errors.push(`provider origin mismatch (expected ${cfg?.repo || 'configured repository'}, found ${actualRemote})`);
200
+ }
201
+
202
+ try {
203
+ if (checkoutChanges(dir)) errors.push('provider checkout has local changes');
204
+ } catch {
205
+ errors.push('provider checkout status is unavailable');
206
+ }
207
+
208
+ for (const rel of adapter.required || []) {
209
+ if (!candidateExists(dir, rel)) errors.push(`missing required path: ${rel}`);
210
+ }
211
+
212
+ for (const group of adapter.requiredAny || []) {
213
+ if (!group.some((rel) => candidateExists(dir, rel))) {
214
+ errors.push(`none of candidate paths exist: ${group.join(' | ')}`);
215
+ }
216
+ }
217
+
218
+ for (const [cap, candidates] of Object.entries(adapter.capabilities || {})) {
219
+ if (!candidates.some((rel) => candidateExists(dir, rel))) {
220
+ errors.push(`capability '${cap}' cannot be resolved (${candidates.join(' | ')})`);
221
+ }
222
+ }
223
+
224
+ return { ok: errors.length === 0, errors };
225
+ }
226
+
227
+ export function validateAll(root) {
228
+ const cfg = providersConfig();
229
+ const results = {};
230
+ for (const name of Object.keys(cfg.providers)) {
231
+ results[name] = validateProvider(root, name);
232
+ }
233
+ return results;
234
+ }
235
+
236
+ export function resolveCapability(root, capability) {
237
+ const caps = capabilitiesConfig().capabilities;
238
+ const entry = caps[capability];
239
+ if (!entry) throw new Error(`Unknown capability '${capability}'. Available: ${Object.keys(caps).join(', ')}`);
240
+
241
+ const base = providerDir(root, entry.provider);
242
+ const adapter = adapterConfig(entry.provider);
243
+ const providerCheck = validateProvider(root, entry.provider);
244
+ if (!providerCheck.ok) {
245
+ throw new Error(`Provider '${entry.provider}' failed validation:\n- ${providerCheck.errors.join('\n- ')}`);
246
+ }
247
+ if (lockExists(root)) {
248
+ const lockCheck = validateLockState(root);
249
+ if (!lockCheck.ok) {
250
+ throw new Error(`Provider state failed lock validation:\n- ${lockCheck.errors.join('\n- ')}`);
251
+ }
252
+ }
253
+ const candidates = adapter.capabilities?.[entry.adapterKey] || [];
254
+ const matches = candidates
255
+ .filter((rel) => candidateExists(base, rel))
256
+ .map((rel) => join(base, ...rel.split('/')));
257
+
258
+ if (!matches.length) {
259
+ throw new Error(`Capability '${capability}' is unavailable. Run 'ui init' or 'ui doctor'.`);
260
+ }
261
+ return matches;
262
+ }
263
+
264
+ function defaultLock() {
265
+ return { schemaVersion: 1, updatedAt: null, providers: {} };
266
+ }
267
+
268
+ export function lockExists(root) {
269
+ return existsSync(lockPath(root));
270
+ }
271
+
272
+ export function validateLockDocument(lock) {
273
+ const errors = [];
274
+ if (!lock || typeof lock !== 'object' || Array.isArray(lock)) {
275
+ return ['lockfile root must be an object'];
276
+ }
277
+ if (lock.schemaVersion !== 1) errors.push('unsupported lockfile schemaVersion (expected 1)');
278
+ if (!lock.providers || typeof lock.providers !== 'object' || Array.isArray(lock.providers)) {
279
+ errors.push('lockfile providers must be an object');
280
+ return errors;
281
+ }
282
+ for (const [name, entry] of Object.entries(lock.providers)) {
283
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
284
+ errors.push(`provider '${name}' entry must be an object`);
285
+ continue;
286
+ }
287
+ if (entry.commit !== null && entry.commit !== undefined && !isObjectId(entry.commit)) {
288
+ errors.push(`provider '${name}' commit must be a full 40-character Git object id or null`);
289
+ }
290
+ if (entry.tree !== null && entry.tree !== undefined && !isObjectId(entry.tree)) {
291
+ errors.push(`provider '${name}' tree must be a full 40-character Git object id or null`);
292
+ }
293
+ if (entry.repo !== undefined && typeof entry.repo !== 'string') {
294
+ errors.push(`provider '${name}' repo must be a string`);
295
+ }
296
+ if (entry.branch !== undefined && typeof entry.branch !== 'string') {
297
+ errors.push(`provider '${name}' branch must be a string`);
298
+ }
299
+ }
300
+ return errors;
301
+ }
302
+
303
+ export function loadLock(root) {
304
+ const path = lockPath(root);
305
+ if (!existsSync(path)) return defaultLock();
306
+ let lock;
307
+ try {
308
+ lock = readJson(path);
309
+ } catch (error) {
310
+ throw new Error(`Invalid UI Director lockfile at ${path}: ${error.message}`);
311
+ }
312
+ const errors = validateLockDocument(lock);
313
+ if (errors.length) throw new Error(`Invalid UI Director lockfile at ${path}:\n- ${errors.join('\n- ')}`);
314
+ return lock;
315
+ }
316
+
317
+ export function validateLockConfig(root, lock = loadLock(root)) {
318
+ const cfg = providersConfig();
319
+ const errors = [];
320
+ for (const [name, provider] of Object.entries(cfg.providers)) {
321
+ const entry = lock.providers?.[name];
322
+ if (!entry) {
323
+ errors.push(`provider '${name}' is missing from lockfile`);
324
+ continue;
325
+ }
326
+ if (!isObjectId(entry.commit)) errors.push(`provider '${name}' has no locked commit`);
327
+ if (entry.repo !== provider.repo) errors.push(`provider '${name}' lock repo does not match configured repo`);
328
+ if (entry.branch !== provider.branch) errors.push(`provider '${name}' lock branch does not match configured branch`);
329
+ }
330
+ return { ok: errors.length === 0, errors };
331
+ }
332
+
333
+ export function validateLockState(root) {
334
+ if (!lockExists(root)) return { ok: false, errors: ['lockfile is missing'] };
335
+ let lock;
336
+ try {
337
+ lock = loadLock(root);
338
+ } catch (error) {
339
+ return { ok: false, errors: [error.message] };
340
+ }
341
+
342
+ const configCheck = validateLockConfig(root, lock);
343
+ const errors = [...configCheck.errors];
344
+ for (const [name, provider] of Object.entries(providersConfig().providers)) {
345
+ const entry = lock.providers?.[name];
346
+ const dir = providerDir(root, name);
347
+ const current = currentCommit(dir);
348
+ if (!entry || !current) continue;
349
+ if (entry.commit !== current) errors.push(`provider '${name}' HEAD ${shortSha(current)} does not match lock ${shortSha(entry.commit)}`);
350
+ if (entry.tree && currentTree(dir) !== entry.tree) errors.push(`provider '${name}' tree hash does not match lock`);
351
+ const actualRemote = remoteUrl(dir);
352
+ if (!actualRemote || normalizedRemote(actualRemote) !== normalizedRemote(provider.repo)) {
353
+ errors.push(`provider '${name}' origin does not match configured repo`);
354
+ }
355
+ }
356
+ return { ok: errors.length === 0, errors };
357
+ }
358
+
359
+ export function writeLock(root) {
360
+ const cfg = providersConfig();
361
+ const lock = {
362
+ schemaVersion: 1,
363
+ updatedAt: new Date().toISOString(),
364
+ providers: {},
365
+ };
366
+ for (const [name, p] of Object.entries(cfg.providers)) {
367
+ const dir = providerDir(root, name);
368
+ lock.providers[name] = {
369
+ repo: p.repo,
370
+ branch: p.branch,
371
+ commit: currentCommit(dir),
372
+ tree: currentTree(dir),
373
+ };
374
+ }
375
+ mkdirSync(projectState(root), { recursive: true });
376
+ const target = lockPath(root);
377
+ const temporary = `${target}.${randomUUID()}.tmp`;
378
+ try {
379
+ writeFileSync(temporary, `${JSON.stringify(lock, null, 2)}\n`, { mode: 0o644 });
380
+ renameSync(temporary, target);
381
+ } finally {
382
+ if (existsSync(temporary)) rmSync(temporary, { force: true });
383
+ }
384
+ return lock;
385
+ }
386
+
387
+ export function installDirectorSkill(root) {
388
+ const targets = [
389
+ join(resolve(root), '.agents', 'skills', 'ui-director'),
390
+ join(resolve(root), '.claude', 'skills', 'ui-director'),
391
+ ];
392
+ const copyNames = ['SKILL.md', 'references', 'bin', 'lib', 'config', 'adapters', 'package.json'];
393
+ for (const target of targets) {
394
+ mkdirSync(target, { recursive: true });
395
+ for (const name of copyNames) {
396
+ const src = join(packageRoot, name);
397
+ const dest = join(target, name);
398
+ cpSync(src, dest, { recursive: true, force: true });
399
+ }
400
+ }
401
+ return targets;
402
+ }
403
+
404
+ export function fetchProvider(root, name) {
405
+ const cfg = providersConfig().providers[name];
406
+ if (!cfg) throw new Error(`Unknown provider '${name}'`);
407
+ const dir = providerDir(root, name);
408
+ if (!existsSync(join(dir, '.git'))) throw new Error(`${name} is not installed. Run 'ui init'.`);
409
+ assertProviderRemote(dir, name, cfg);
410
+ git(['fetch', 'origin', cfg.branch], dir, 'ignore');
411
+ return remoteCommit(dir, cfg.branch);
412
+ }
413
+
414
+ export function updateProvider(root, name) {
415
+ const cfg = providersConfig().providers[name];
416
+ if (!cfg) throw new Error(`Unknown provider '${name}'`);
417
+ const dir = providerDir(root, name);
418
+ if (!existsSync(join(dir, '.git'))) installProvider(root, name, cfg);
419
+
420
+ const before = currentCommit(dir);
421
+ if (!before) throw new Error(`${name}: provider checkout has no readable HEAD.`);
422
+ assertProviderRemote(dir, name, cfg);
423
+ const initialCheck = validateProvider(root, name);
424
+ if (!initialCheck.ok) {
425
+ throw new Error(`${name} is not valid before update:\n- ${initialCheck.errors.join('\n- ')}`);
426
+ }
427
+ git(['fetch', 'origin', cfg.branch], dir, 'ignore');
428
+ const target = remoteCommit(dir, cfg.branch);
429
+ if (!target) throw new Error(`${name}: origin/${cfg.branch} is unavailable after fetch.`);
430
+ if (before === target) return { name, changed: false, before, after: before };
431
+
432
+ // Preserve a rollback ref before moving HEAD.
433
+ assertCleanCheckout(dir, name);
434
+ git(['update-ref', 'refs/ui-director/previous', before], dir);
435
+ git(['reset', '--hard', target], dir, 'ignore');
436
+
437
+ const check = validateProvider(root, name);
438
+ if (!check.ok) {
439
+ git(['reset', '--hard', before], dir, 'ignore');
440
+ throw new Error(`${name} update rejected:\n- ${check.errors.join('\n- ')}`);
441
+ }
442
+
443
+ return { name, changed: true, before, after: currentCommit(dir) };
444
+ }
445
+
446
+ export function rollbackProvider(root, name) {
447
+ const cfg = providersConfig().providers[name];
448
+ if (!cfg) throw new Error(`Unknown provider '${name}'`);
449
+ const dir = providerDir(root, name);
450
+ if (!existsSync(join(dir, '.git'))) throw new Error(`${name} is not installed.`);
451
+ assertProviderRemote(dir, name, cfg);
452
+ assertCleanCheckout(dir, name);
453
+ let previous;
454
+ try { previous = git(['rev-parse', 'refs/ui-director/previous'], dir); }
455
+ catch { throw new Error(`${name} has no recorded previous version.`); }
456
+
457
+ const before = currentCommit(dir);
458
+ git(['reset', '--hard', previous], dir, 'ignore');
459
+ const check = validateProvider(root, name);
460
+ if (!check.ok) {
461
+ git(['reset', '--hard', before], dir, 'ignore');
462
+ throw new Error(`${name} rollback target failed validation.`);
463
+ }
464
+ git(['update-ref', 'refs/ui-director/previous', before], dir);
465
+ return { name, before, after: currentCommit(dir) };
466
+ }
467
+
468
+ export function diffProvider(root, name) {
469
+ const cfg = providersConfig().providers[name];
470
+ if (!cfg) throw new Error(`Unknown provider '${name}'`);
471
+ const dir = providerDir(root, name);
472
+ if (!existsSync(join(dir, '.git'))) return `${name}: not installed`;
473
+ assertProviderRemote(dir, name, cfg);
474
+ git(['fetch', 'origin', cfg.branch], dir, 'ignore');
475
+ const local = currentCommit(dir);
476
+ const remote = remoteCommit(dir, cfg.branch);
477
+ if (!local || !remote) throw new Error(`${name}: could not resolve local and remote commits.`);
478
+ if (local === remote) return `${name}: up to date (${shortSha(local)})`;
479
+ const stat = git(['diff', '--stat', `${local}..${remote}`], dir);
480
+ const log = git(['log', '--oneline', '--no-decorate', `${local}..${remote}`, '-n', '12'], dir);
481
+ return `${name}: ${shortSha(local)} -> ${shortSha(remote)}\n${log || '(no commit summary)'}\n${stat || ''}`.trim();
482
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "ui-director-skill",
3
+ "version": "0.1.0",
4
+ "description": "UI/UX orchestrator skill with updateable specialist providers",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matrixhawk/ui-director-skill.git"
9
+ },
10
+ "homepage": "https://github.com/matrixhawk/ui-director-skill#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/matrixhawk/ui-director-skill/issues"
13
+ },
14
+ "scripts": {
15
+ "test": "node --test"
16
+ },
17
+ "bin": {
18
+ "ui": "bin/ui.mjs",
19
+ "ui-director": "bin/ui.mjs"
20
+ },
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "files": [
25
+ "SKILL.md",
26
+ "README.md",
27
+ "INSTALL.md",
28
+ "bin",
29
+ "lib",
30
+ "config",
31
+ "adapters",
32
+ "references",
33
+ "examples"
34
+ ],
35
+ "license": "MIT"
36
+ }
@@ -0,0 +1,25 @@
1
+ # Project Inspection
2
+
3
+ For an existing product, inspect before designing.
4
+
5
+ Look for:
6
+
7
+ 1. Framework and rendering stack.
8
+ 2. Styling system: CSS, Tailwind, CSS-in-JS, native theme, etc.
9
+ 3. Component library and local reusable components.
10
+ 4. Semantic color tokens and theme variables.
11
+ 5. Typography scale and font usage.
12
+ 6. Spacing, radius, elevation/shadow and breakpoint conventions.
13
+ 7. Representative neighboring screens/components.
14
+ 8. Existing interaction patterns: dialogs, forms, tables, navigation, toasts, loading and errors.
15
+
16
+ Priority order:
17
+
18
+ 1. Existing design system.
19
+ 2. Existing product consistency.
20
+ 3. Supplied design/specification.
21
+ 4. Explicit user requirements.
22
+ 5. Professional UI/UX principles.
23
+ 6. External inspiration.
24
+
25
+ Never create a parallel component/token system just because a specialist skill suggests one.
@@ -0,0 +1,59 @@
1
+ # Quality Gates
2
+
3
+ Substantial UI work is not done merely because code compiles.
4
+
5
+ ## G1 — Consistency
6
+
7
+ - Existing primitives/components reused where appropriate.
8
+ - Semantic tokens preferred over arbitrary values.
9
+ - Typography, spacing, radius and states match the product.
10
+
11
+ ## G2 — Hierarchy
12
+
13
+ - Page purpose is obvious.
14
+ - Primary action is discoverable.
15
+ - Reading order and grouping are coherent.
16
+ - Avoid card-in-card and separator noise.
17
+
18
+ ## G3 — Usability
19
+
20
+ - Loading, empty, disabled and error states are handled when relevant.
21
+ - Labels and actions are unambiguous.
22
+ - Destructive or irreversible actions have appropriate safeguards.
23
+
24
+ ## G4 — Accessibility
25
+
26
+ - Keyboard navigation works where applicable.
27
+ - Visible focus states exist.
28
+ - Controls have meaningful accessible names.
29
+ - Contrast and hit targets are reasonable.
30
+ - Reduced-motion preferences are respected where motion is used.
31
+
32
+ ## G5 — Responsive / Stress
33
+
34
+ - No accidental horizontal overflow.
35
+ - Long text/localization does not destroy layout.
36
+ - Small screens reflow instead of simply shrinking.
37
+ - Zoom and content growth remain usable.
38
+
39
+ ## G6 — Polish
40
+
41
+ - Optical alignment, spacing rhythm and type hierarchy are coherent.
42
+ - Hover/focus/pressed/selected states are intentional.
43
+ - Motion has interaction purpose.
44
+ - Decoration does not outrank information.
45
+
46
+ ## Anti-AI UI defaults
47
+
48
+ Avoid unless justified by the product:
49
+
50
+ - default purple/blue gradients
51
+ - gratuitous glassmorphism
52
+ - every section as a rounded card
53
+ - nested cards
54
+ - decorative rounded icon tiles everywhere
55
+ - bento grids without information rationale
56
+ - excessive muted-gray secondary copy
57
+ - meaningless badges
58
+ - oversized marketing copy that reduces useful density
59
+ - animation without purpose
@@ -0,0 +1,58 @@
1
+ # Routing Rules
2
+
3
+ UI Director routes by *capability*, not by hard-coded provider names.
4
+
5
+ ## Task types
6
+
7
+ - `CREATE`: a new product/surface from scratch.
8
+ - `EXTEND`: add a page, flow or component to an existing product.
9
+ - `REDESIGN`: materially replace an existing UI direction.
10
+ - `FIX`: solve a bounded UX/UI problem.
11
+ - `AUDIT`: review before changing anything.
12
+
13
+ ## Routes
14
+
15
+ ### CREATE — visual direction unclear
16
+
17
+ `research -> interface -> layout -> typography -> colors -> implementation -> accessibility -> audit -> distill -> polish`
18
+
19
+ Do not load every capability blindly. Colors, writing and accessibility are loaded only when relevant.
20
+
21
+ ### CREATE — visual direction already clear
22
+
23
+ Skip broad `research`.
24
+
25
+ `interface -> layout -> typography -> implementation -> audit -> polish`
26
+
27
+ ### EXTEND — existing product
28
+
29
+ `design-system -> relevant design-engineering capabilities -> implementation -> audit -> polish`
30
+
31
+ External inspiration must not override incumbent product conventions.
32
+
33
+ ### REDESIGN
34
+
35
+ `design-system -> optional research -> interface -> layout -> typography -> optional colors -> implementation -> critique -> audit -> polish`
36
+
37
+ ### FIX
38
+
39
+ Use the narrowest capability set:
40
+
41
+ - spacing, hierarchy, grouping, responsive structure -> `layout`
42
+ - type scale, line length, wrapping, truncation -> `typography`
43
+ - palette, theme, semantic color, contrast -> `colors`
44
+ - keyboard, focus, ARIA, hit target, reduced motion -> `accessibility`
45
+ - labels, errors, empty states, microcopy -> `writing`
46
+ - radius, shadows, motion, interaction polish -> `interface`
47
+
48
+ ### AUDIT
49
+
50
+ `audit -> critique (if needed) -> targeted remediation capability`
51
+
52
+ Do not redesign before identifying defects.
53
+
54
+ ## Mode selection
55
+
56
+ - `FAST`: small, bounded fixes; usually 1-2 capabilities.
57
+ - `STANDARD`: normal feature/page work; inspect, build, audit, polish.
58
+ - `DEEP`: new products, major redesigns, complex flows, design systems or high-impact surfaces.