ui-director-skill 0.1.0 → 2.0.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/INSTALL.md +23 -105
- package/README.md +33 -292
- package/SKILL.md +8 -103
- package/bin/ui.mjs +103 -23
- package/config/optional-skills.json +16 -0
- package/config/quality-rubric.json +13 -0
- package/config/workflows.json +15 -0
- package/examples/usage.md +25 -27
- package/lib/core.mjs +55 -9
- package/lib/workflows.mjs +137 -0
- package/package.json +3 -2
- package/references/design-workflows.md +21 -0
- package/references/platforms.md +17 -0
- package/references/project-inspection.md +8 -22
- package/references/quality-gates.md +10 -53
- package/references/routing.md +21 -52
- package/references/specialists.md +9 -0
- package/templates/DECISIONS.md +4 -0
- package/templates/DESIGN.md +27 -0
- package/templates/PRODUCT.md +6 -0
- package/templates/REVIEW.md +18 -0
package/bin/ui.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
commandExists,
|
|
6
6
|
currentCommit,
|
|
7
7
|
diffProvider,
|
|
8
|
+
directorSkillTargets,
|
|
8
9
|
ensureState,
|
|
9
10
|
installDirectorSkill,
|
|
10
11
|
installProvider,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
validateProvider,
|
|
24
25
|
writeLock,
|
|
25
26
|
} from '../lib/core.mjs';
|
|
27
|
+
import { checkUpstreams, previewRoute, scaffoldDesign, validateDesign } from '../lib/workflows.mjs';
|
|
26
28
|
|
|
27
29
|
const VERSION = packageVersion();
|
|
28
30
|
const root = resolve(process.cwd());
|
|
@@ -31,7 +33,47 @@ const cmd = args[0] || 'status';
|
|
|
31
33
|
const target = args[1];
|
|
32
34
|
|
|
33
35
|
function help() {
|
|
34
|
-
console.log(`UI Director ${VERSION}
|
|
36
|
+
console.log(`UI Director ${VERSION}
|
|
37
|
+
|
|
38
|
+
Usage: ui [command] [arguments]
|
|
39
|
+
|
|
40
|
+
ui init Install the skill and restore managed providers
|
|
41
|
+
ui init --local Install the skill using built-in guidance
|
|
42
|
+
ui upgrade Back up and refresh the project skill
|
|
43
|
+
ui doctor Check the installation and any managed providers
|
|
44
|
+
ui route "<request>" Preview intent, platform, deliverable and mode
|
|
45
|
+
Options: --intent, --platform, --deliverable, --mode
|
|
46
|
+
ui design-init Create missing design documents and project profile
|
|
47
|
+
ui migrate Draft DESIGN.md for an existing MASTER.md
|
|
48
|
+
Both accept --platform and --dry-run
|
|
49
|
+
ui validate-design [file] Check the structure of DESIGN.md
|
|
50
|
+
ui check-upstreams Find optional skills in local skill directories
|
|
51
|
+
ui status Show managed provider status (default)
|
|
52
|
+
ui update [provider] Update managed providers
|
|
53
|
+
ui diff [provider] Show upstream changes
|
|
54
|
+
ui rollback [provider] Roll back managed providers
|
|
55
|
+
ui resolve <capability> Resolve a managed capability to checked-out files
|
|
56
|
+
ui --version Print version
|
|
57
|
+
ui --help Show this help
|
|
58
|
+
|
|
59
|
+
Managed providers: ui-ux-pro-max, jakub-skills, design-system, impeccable
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function readOptions(tokens, labels, flags = []) {
|
|
64
|
+
const options = {};
|
|
65
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
66
|
+
const label = tokens[i];
|
|
67
|
+
if (flags.includes(label)) {
|
|
68
|
+
options[label.slice(2)] = true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (!labels.includes(label)) throw new Error(`Unknown option '${label}'.`);
|
|
72
|
+
const value = tokens[++i];
|
|
73
|
+
if (!value || value.startsWith('--')) throw new Error(`Missing value for '${label}'.`);
|
|
74
|
+
options[label.slice(2)] = value;
|
|
75
|
+
}
|
|
76
|
+
return options;
|
|
35
77
|
}
|
|
36
78
|
|
|
37
79
|
function names() {
|
|
@@ -61,7 +103,43 @@ async function main() {
|
|
|
61
103
|
if (cmd === '--help' || cmd === '-h' || cmd === 'help') return help();
|
|
62
104
|
if (cmd === '--version' || cmd === '-v' || cmd === 'version') return console.log(VERSION);
|
|
63
105
|
|
|
106
|
+
if (cmd === 'route') {
|
|
107
|
+
const options = readOptions(args.slice(2), ['--intent', '--platform', '--deliverable', '--mode']);
|
|
108
|
+
console.log(JSON.stringify(previewRoute(target ?? '', options), null, 2));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (cmd === 'design-init' || cmd === 'migrate') {
|
|
113
|
+
const options = readOptions(args.slice(1), ['--platform'], ['--dry-run']);
|
|
114
|
+
for (const { status, file } of scaffoldDesign(root, {
|
|
115
|
+
platform: options.platform, migrate: cmd === 'migrate', dryRun: options['dry-run'],
|
|
116
|
+
})) console.log(`${status}: ${file}`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (cmd === 'validate-design') {
|
|
121
|
+
if (args.length > 2) throw new Error('Usage: ui validate-design [file]');
|
|
122
|
+
const result = validateDesign(root, target);
|
|
123
|
+
console.log(JSON.stringify(result, null, 2));
|
|
124
|
+
if (result.warnings.length) process.exitCode = 1;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (cmd === 'check-upstreams') {
|
|
129
|
+
readOptions(args.slice(1), []);
|
|
130
|
+
console.log(JSON.stringify(checkUpstreams(root), null, 2));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (cmd === 'upgrade' || (cmd === 'init' && target === '--local')) {
|
|
135
|
+
const extra = cmd === 'upgrade' ? args.slice(1) : args.slice(2);
|
|
136
|
+
readOptions(extra, []);
|
|
137
|
+
for (const path of installDirectorSkill(root, { backup: cmd === 'upgrade' })) console.log(`Installed: ${path}`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
64
141
|
if (cmd === 'init') {
|
|
142
|
+
readOptions(args.slice(1), []);
|
|
65
143
|
assertRuntime();
|
|
66
144
|
ensureState(root);
|
|
67
145
|
const hasLock = lockExists(root);
|
|
@@ -101,31 +179,33 @@ async function main() {
|
|
|
101
179
|
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
|
102
180
|
console.log(`${nodeMajor >= 18 ? '✓' : '✗'} Node ${process.versions.node}`);
|
|
103
181
|
if (nodeMajor < 18) errors.push('Node 18+ is required');
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
for (const
|
|
111
|
-
|
|
112
|
-
}
|
|
182
|
+
if (lockExists(root) || names().some((name) => existsSync(providerDir(root, name)))) {
|
|
183
|
+
const hasGit = commandExists('git');
|
|
184
|
+
console.log(`${hasGit ? '✓' : '✗'} Git`);
|
|
185
|
+
if (!hasGit) errors.push('Git is required for managed providers');
|
|
186
|
+
|
|
187
|
+
const results = validateAll(root);
|
|
188
|
+
for (const [name, result] of Object.entries(results)) {
|
|
189
|
+
console.log(`${result.ok ? '✓' : '✗'} ${name}`);
|
|
190
|
+
for (const e of result.errors) console.log(` - ${e}`);
|
|
191
|
+
if (!result.ok) errors.push(`${name}: ${result.errors.join('; ')}`);
|
|
192
|
+
}
|
|
113
193
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
194
|
+
const lockResult = validateLockState(root);
|
|
195
|
+
console.log(`${lockResult.ok ? '✓' : '✗'} lockfile`);
|
|
196
|
+
for (const e of lockResult.errors) console.log(` - ${e}`);
|
|
197
|
+
if (!lockResult.ok) errors.push(...lockResult.errors.map((e) => `lockfile: ${e}`));
|
|
198
|
+
} else {
|
|
199
|
+
console.log('· Built-in guidance (no managed providers configured)');
|
|
200
|
+
}
|
|
118
201
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
202
|
+
const requiredFiles = [
|
|
203
|
+
'SKILL.md', 'bin/ui.mjs', 'lib/workflows.mjs', 'config/providers.json', 'config/workflows.json',
|
|
204
|
+
'config/optional-skills.json', 'config/quality-rubric.json', 'references/quality-gates.md',
|
|
205
|
+
'templates/DESIGN.md', 'package.json',
|
|
122
206
|
];
|
|
123
|
-
for (const
|
|
124
|
-
const
|
|
125
|
-
const complete = existsSync(s)
|
|
126
|
-
&& existsSync(resolve(target, 'bin', 'ui.mjs'))
|
|
127
|
-
&& existsSync(resolve(target, 'config', 'providers.json'))
|
|
128
|
-
&& existsSync(resolve(target, 'package.json'));
|
|
207
|
+
for (const target of directorSkillTargets(root)) {
|
|
208
|
+
const complete = requiredFiles.every((file) => existsSync(resolve(target, file)));
|
|
129
209
|
console.log(`${complete ? '✓' : '✗'} ${target}`);
|
|
130
210
|
if (!complete) errors.push(`skill installation is incomplete: ${target}`);
|
|
131
211
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
{ "id": "pro-max", "aliases": ["ui-ux-pro-max"], "stages": ["research", "system"], "platforms": ["web", "mobile", "desktop"] },
|
|
3
|
+
{ "id": "frontend", "aliases": ["frontend-design"], "stages": ["visual"], "platforms": ["web"] },
|
|
4
|
+
{ "id": "taste", "aliases": ["taste-skill"], "stages": ["visual"], "platforms": ["web"] },
|
|
5
|
+
{ "id": "taste-classics", "aliases": ["design-taste-frontend", "high-end-visual-design", "minimalist-ui", "industrial-brutalist-ui"], "stages": ["visual"], "platforms": ["web"] },
|
|
6
|
+
{ "id": "hallmark", "aliases": ["hallmark"], "stages": ["research", "system", "visual", "deslop", "qa"], "platforms": ["web"] },
|
|
7
|
+
{ "id": "unslop", "aliases": ["unslop"], "stages": ["deslop"], "platforms": ["web"] },
|
|
8
|
+
{ "id": "impeccable", "aliases": ["impeccable"], "stages": ["baseline", "deslop", "qa"], "platforms": ["web"] },
|
|
9
|
+
{ "id": "emil", "aliases": ["animate", "review-animations", "animation-performance"], "stages": ["motion", "motion-review"], "platforms": ["web"] },
|
|
10
|
+
{ "id": "vercel", "aliases": ["web-design-guidelines"], "stages": ["qa"], "platforms": ["web"] },
|
|
11
|
+
{ "id": "stitch", "aliases": ["stitch", "design-md", "stitch-design"], "stages": ["research", "system", "prototype"], "platforms": ["web"] },
|
|
12
|
+
{ "id": "figma", "aliases": ["figma-implement-design", "figma-generate-design", "figma"], "stages": ["research", "prototype"], "platforms": ["web", "mobile", "desktop"] },
|
|
13
|
+
{ "id": "playwright", "aliases": ["playwright-interactive", "playwright", "screenshot"], "stages": ["baseline", "qa"], "platforms": ["web"] },
|
|
14
|
+
{ "id": "design-qa", "aliases": ["design-qa"], "stages": ["qa"], "platforms": ["web", "mobile", "desktop"] },
|
|
15
|
+
{ "id": "cook", "aliases": ["cook"], "stages": ["qa"], "platforms": ["web"] }
|
|
16
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": { "STANDARD": 85, "CRAFT": 92, "REFERENCE": 92 },
|
|
3
|
+
"dimensions": {
|
|
4
|
+
"visual": 25,
|
|
5
|
+
"ux": 20,
|
|
6
|
+
"consistency": 15,
|
|
7
|
+
"distinctiveness": 15,
|
|
8
|
+
"motion": 10,
|
|
9
|
+
"engineering": 10,
|
|
10
|
+
"accessibility": 5
|
|
11
|
+
},
|
|
12
|
+
"hardGates": ["scope", "functionality", "safety", "required_evidence", "critical_accessibility"]
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"platforms": ["web", "mobile", "desktop", "other"],
|
|
3
|
+
"deliverables": ["concept", "specification", "prototype", "implementation", "audit"],
|
|
4
|
+
"modes": { "FAST": 1, "STANDARD": 3, "CRAFT": 5, "REFERENCE": 8 },
|
|
5
|
+
"workflows": {
|
|
6
|
+
"AUDIT": ["qa"],
|
|
7
|
+
"MOTION": ["motion", "motion-review"],
|
|
8
|
+
"SYSTEM": ["research", "system", "qa"],
|
|
9
|
+
"DESLOP": ["baseline", "deslop", "qa"],
|
|
10
|
+
"POLISH": ["baseline", "system", "visual", "prototype", "qa"],
|
|
11
|
+
"REFERENCE": ["research", "system", "visual", "prototype", "qa"],
|
|
12
|
+
"NEW_SCREEN": ["research", "system", "visual", "prototype", "qa"],
|
|
13
|
+
"BRAND": ["research", "system", "visual", "prototype", "qa"]
|
|
14
|
+
}
|
|
15
|
+
}
|
package/examples/usage.md
CHANGED
|
@@ -11,16 +11,9 @@ Use ui-director to add an AI agent management page to the existing admin console
|
|
|
11
11
|
Expected logical route:
|
|
12
12
|
|
|
13
13
|
```text
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
→ layout
|
|
18
|
-
→ typography
|
|
19
|
-
→ interface
|
|
20
|
-
→ implementation
|
|
21
|
-
→ accessibility (if interactive/forms)
|
|
22
|
-
→ audit
|
|
23
|
-
→ polish
|
|
14
|
+
NEW_SCREEN / STANDARD / implementation
|
|
15
|
+
|
|
16
|
+
inspect existing screen → system → visual → prototype → qa
|
|
24
17
|
```
|
|
25
18
|
|
|
26
19
|
`research` should normally be skipped.
|
|
@@ -36,18 +29,9 @@ Use ui-director to create a professional quantitative trading dashboard from scr
|
|
|
36
29
|
Expected route:
|
|
37
30
|
|
|
38
31
|
```text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
research
|
|
42
|
-
→ interface
|
|
43
|
-
→ layout
|
|
44
|
-
→ typography
|
|
45
|
-
→ colors
|
|
46
|
-
→ implementation
|
|
47
|
-
→ accessibility
|
|
48
|
-
→ audit
|
|
49
|
-
→ distill
|
|
50
|
-
→ polish
|
|
32
|
+
NEW_SCREEN / CRAFT / implementation
|
|
33
|
+
|
|
34
|
+
research → system → visual → prototype → qa
|
|
51
35
|
```
|
|
52
36
|
|
|
53
37
|
## Small accessibility fix
|
|
@@ -61,10 +45,24 @@ Use ui-director to fix keyboard navigation and focus behavior in this settings f
|
|
|
61
45
|
Expected route:
|
|
62
46
|
|
|
63
47
|
```text
|
|
64
|
-
|
|
48
|
+
FAST / implementation
|
|
49
|
+
|
|
50
|
+
inspect the current form → target keyboard and focus behavior → verify the affected states
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Read-only review
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
```text
|
|
56
|
+
Use ui-director to audit the desktop settings flow. Report findings with screenshots
|
|
57
|
+
or reproduction steps. Leave product source untouched.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The route should be `AUDIT` with the `audit` deliverable. Report any checks that require a desktop runtime when it is unavailable.
|
|
61
|
+
|
|
62
|
+
## Match a supplied reference
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
Use ui-director in REFERENCE mode to implement a new account screen using the supplied
|
|
66
|
+
reference for hierarchy and density. Use approved product tokens. Compare the same
|
|
67
|
+
viewport and states after rendering.
|
|
70
68
|
```
|
package/lib/core.mjs
CHANGED
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
lstatSync,
|
|
7
7
|
mkdirSync,
|
|
8
8
|
readFileSync,
|
|
9
|
+
readdirSync,
|
|
9
10
|
renameSync,
|
|
10
11
|
rmSync,
|
|
11
12
|
writeFileSync,
|
|
12
13
|
} from 'node:fs';
|
|
13
|
-
import { dirname, join, resolve } from 'node:path';
|
|
14
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
15
16
|
|
|
16
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -384,15 +385,60 @@ export function writeLock(root) {
|
|
|
384
385
|
return lock;
|
|
385
386
|
}
|
|
386
387
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
388
|
+
const skillFiles = ['SKILL.md', 'references', 'bin', 'lib', 'config', 'adapters', 'package.json', 'templates'];
|
|
389
|
+
|
|
390
|
+
export function directorSkillTargets(root) {
|
|
391
|
+
return ['.agents', '.claude'].map((agent) => join(resolve(root), agent, 'skills', 'ui-director'));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export function assertRealDirectory(path) {
|
|
395
|
+
const entry = lstatSync(path, { throwIfNoEntry: false });
|
|
396
|
+
if (entry && !entry.isDirectory()) throw new Error(`Expected a directory at ${path}`);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function checkCopyDestination(src, dest) {
|
|
400
|
+
const current = lstatSync(dest, { throwIfNoEntry: false });
|
|
401
|
+
if (!current) return;
|
|
402
|
+
if (!lstatSync(src).isDirectory()) {
|
|
403
|
+
if (!current.isFile() || current.nlink > 1) throw new Error(`Unsafe file destination: ${dest}`);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
assertRealDirectory(dest);
|
|
407
|
+
for (const entry of readdirSync(src)) checkCopyDestination(join(src, entry), join(dest, entry));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export function installDirectorSkill(root, { backup = false } = {}) {
|
|
411
|
+
const targets = directorSkillTargets(root);
|
|
412
|
+
const writable = targets.filter((target) => target !== packageRoot);
|
|
413
|
+
for (const target of writable) {
|
|
414
|
+
for (const path of [dirname(dirname(target)), dirname(target), target]) assertRealDirectory(path);
|
|
415
|
+
for (const name of skillFiles) checkCopyDestination(join(packageRoot, name), join(target, name));
|
|
416
|
+
if (backup && existsSync(target) && readdirSync(target).length) {
|
|
417
|
+
const entry = join(target, 'SKILL.md');
|
|
418
|
+
if (!existsSync(entry) || !/^name:\s*ui-director\s*$/m.test(readFileSync(entry, 'utf8'))) {
|
|
419
|
+
throw new Error(`Existing directory is not a UI Director installation: ${target}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (backup && writable.some((target) => existsSync(target) && readdirSync(target).length)) {
|
|
425
|
+
const state = projectState(root);
|
|
426
|
+
const backups = join(state, 'skill-backups');
|
|
427
|
+
assertRealDirectory(state);
|
|
428
|
+
assertRealDirectory(backups);
|
|
429
|
+
const snapshot = join(backups, randomUUID());
|
|
430
|
+
mkdirSync(snapshot, { recursive: true });
|
|
431
|
+
for (const target of writable.filter((path) => existsSync(path) && readdirSync(path).length)) {
|
|
432
|
+
const agent = basename(dirname(dirname(target)));
|
|
433
|
+
const dest = join(snapshot, agent, 'ui-director');
|
|
434
|
+
cpSync(target, dest, { recursive: true, verbatimSymlinks: true });
|
|
435
|
+
console.log(`Backup: ${dest}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
for (const target of writable) {
|
|
394
440
|
mkdirSync(target, { recursive: true });
|
|
395
|
-
for (const name of
|
|
441
|
+
for (const name of skillFiles) {
|
|
396
442
|
const src = join(packageRoot, name);
|
|
397
443
|
const dest = join(target, name);
|
|
398
444
|
cpSync(src, dest, { recursive: true, force: true });
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { assertRealDirectory, packageRoot, projectState, readJson } from './core.mjs';
|
|
6
|
+
|
|
7
|
+
const rules = readJson(join(packageRoot, 'config', 'workflows.json'));
|
|
8
|
+
const catalog = readJson(join(packageRoot, 'config', 'optional-skills.json'));
|
|
9
|
+
|
|
10
|
+
function choice(value, allowed, label) {
|
|
11
|
+
if (!allowed.includes(value)) throw new Error(`Invalid ${label} '${value}'. Choose: ${allowed.join(', ')}.`);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function inferIntent(task) {
|
|
16
|
+
if (/复刻|还原|像素级|reference match|pixel.perfect|截图转|figma\s*转代码/.test(task)) return 'REFERENCE';
|
|
17
|
+
if (/去\s*ai\s*味|去除\s*ai\s*味|deslop|unslop|模板化/.test(task)) return 'DESLOP';
|
|
18
|
+
if (/设计系统|设计规范|design system|design tokens/.test(task)) return 'SYSTEM';
|
|
19
|
+
if (/动效|动画|微交互|\banimation\b|\bmotion\b/.test(task)
|
|
20
|
+
&& !/重设计|改版|从零|新页面|新增|官网|redesign|new screen|landing page/.test(task)) return 'MOTION';
|
|
21
|
+
if (/优化|美化|重设计|改版|redesign|polish/.test(task)) return 'POLISH';
|
|
22
|
+
if (/官网|品牌网站|landing page|marketing site/.test(task)) return 'BRAND';
|
|
23
|
+
return 'NEW_SCREEN';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function previewRoute(request, options = {}) {
|
|
27
|
+
const task = request.trim().toLowerCase();
|
|
28
|
+
if (!task) throw new Error('Usage: ui route "<request>" [--intent ...] [--platform ...] [--deliverable ...] [--mode ...]');
|
|
29
|
+
const explicitIntent = options.intent && choice(options.intent.toUpperCase(), Object.keys(rules.workflows), 'intent');
|
|
30
|
+
const explicitDeliverable = options.deliverable && choice(options.deliverable.toLowerCase(), rules.deliverables, 'deliverable');
|
|
31
|
+
const platform = options.platform
|
|
32
|
+
? choice(options.platform.toLowerCase(), rules.platforms, 'platform')
|
|
33
|
+
: /desktop|桌面应用|electron|winui/.test(task) ? 'desktop'
|
|
34
|
+
: /\bandroid\b|\bios\b|移动端|手机|\bmobile\b/.test(task) ? 'mobile' : 'web';
|
|
35
|
+
const readOnly = /(?:只|仅)(?:做|做一次)?(?:审查|审核|评审|检查)|(?:不要?|别)(?:修改|改代码)|\b(?:audit only|review only|read-only|do not modify)\b/.test(task);
|
|
36
|
+
const review = /审查|审核|评审|\baudit\b|\breview\b/.test(task)
|
|
37
|
+
&& !/修复|实现|重设计|改版|修改|\bfix\b|redesign|implement/.test(task);
|
|
38
|
+
const intent = readOnly || explicitDeliverable === 'audit'
|
|
39
|
+
? 'AUDIT' : explicitIntent || (review ? 'AUDIT' : inferIntent(task));
|
|
40
|
+
const concept = /只给方案|只要方案|仅设计方案|只做设计方案|不写代码|concept only/.test(task);
|
|
41
|
+
const deliverable = intent === 'AUDIT' ? 'audit'
|
|
42
|
+
: concept ? 'concept' : explicitDeliverable || (intent === 'SYSTEM' ? 'specification' : 'implementation');
|
|
43
|
+
const mode = options.mode
|
|
44
|
+
? choice(options.mode.toUpperCase(), Object.keys(rules.modes), 'mode')
|
|
45
|
+
: intent === 'REFERENCE' ? 'REFERENCE' : 'STANDARD';
|
|
46
|
+
const sourceWritesAllowed = ['prototype', 'implementation'].includes(deliverable);
|
|
47
|
+
const stages = rules.workflows[intent].filter((stage) => sourceWritesAllowed || stage !== 'prototype');
|
|
48
|
+
if (!['AUDIT', 'SYSTEM', 'MOTION'].includes(intent) && /动效|动画|\banimation\b|\bmotion\b/.test(task)) {
|
|
49
|
+
stages.splice(stages.indexOf('qa'), 0, 'motion');
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
intent, platform, deliverable, mode, stages,
|
|
53
|
+
maxRepairRounds: sourceWritesAllowed ? rules.modes[mode] : 0,
|
|
54
|
+
sourceWritesAllowed,
|
|
55
|
+
candidateSkills: catalog.filter((skill) => skill.platforms.includes(platform)
|
|
56
|
+
&& skill.stages.some((stage) => stages.includes(stage))).map((skill) => skill.id),
|
|
57
|
+
note: 'Heuristic preview. Confirm scope and available skills in the host before use.',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function skillMetadata(file) {
|
|
62
|
+
if (!lstatSync(file, { throwIfNoEntry: false })?.isFile()) return null;
|
|
63
|
+
const bytes = readFileSync(file);
|
|
64
|
+
const header = bytes.toString('utf8').match(/^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
|
|
65
|
+
const name = header?.match(/^name:[ \t]*["']?([\w-]+)["']?[ \t]*(?:#.*)?$/m)?.[1];
|
|
66
|
+
if (!name) return null;
|
|
67
|
+
const version = header.match(/^version:[ \t]*(.+)$/m)?.[1]?.trim();
|
|
68
|
+
return { name, path: file, version: version ?? null, sha256: createHash('sha256').update(bytes).digest('hex') };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function checkUpstreams(root, home = homedir()) {
|
|
72
|
+
const common = ['.agents', '.claude', '.opencode', '.hermes'];
|
|
73
|
+
const directories = [
|
|
74
|
+
...common.map((agent) => join(root, agent, 'skills')),
|
|
75
|
+
...common.map((agent) => join(home, agent, 'skills')),
|
|
76
|
+
join(home, '.config', 'opencode', 'skills'),
|
|
77
|
+
];
|
|
78
|
+
const candidates = [];
|
|
79
|
+
for (const dir of new Set(directories)) {
|
|
80
|
+
if (!lstatSync(dir, { throwIfNoEntry: false })?.isDirectory()) continue;
|
|
81
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
82
|
+
if (!entry.isDirectory()) continue;
|
|
83
|
+
const candidate = skillMetadata(join(dir, entry.name, 'SKILL.md'));
|
|
84
|
+
if (candidate) candidates.push(candidate);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
scope: 'Local metadata scan only. Confirm source and availability through the host.',
|
|
89
|
+
skills: catalog.map((skill) => ({ ...skill, matches: candidates.filter(({ name }) => skill.aliases.includes(name)) })),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function scaffoldDesign(root, { platform = 'web', migrate = false, dryRun = false } = {}) {
|
|
94
|
+
choice(platform, rules.platforms, 'platform');
|
|
95
|
+
const legacyPath = join('design-system', 'MASTER.md');
|
|
96
|
+
const legacy = lstatSync(join(root, legacyPath), { throwIfNoEntry: false })?.isFile();
|
|
97
|
+
if (migrate && !legacy) throw new Error('No design-system/MASTER.md found. For a new project, run ui design-init.');
|
|
98
|
+
const profile = {
|
|
99
|
+
schema_version: 2, platform, design_system: legacy ? 'design-system/MASTER.md' : 'DESIGN.md',
|
|
100
|
+
product_spec: 'PRODUCT.md', mode: 'STANDARD',
|
|
101
|
+
...(legacy ? { migration_status: 'legacy-authoritative-until-reviewed' } : {}),
|
|
102
|
+
};
|
|
103
|
+
const templates = [
|
|
104
|
+
['PRODUCT.md', 'PRODUCT.md'],
|
|
105
|
+
['DESIGN.md', 'DESIGN.md'],
|
|
106
|
+
['DECISIONS.md', join('design-system', 'DECISIONS.md')],
|
|
107
|
+
];
|
|
108
|
+
const files = new Map([[join(projectState(root), 'project.json'), `${JSON.stringify(profile, null, 2)}\n`]]);
|
|
109
|
+
for (const [template, target] of templates) {
|
|
110
|
+
const content = readFileSync(join(packageRoot, 'templates', template), 'utf8');
|
|
111
|
+
files.set(join(root, target), template === 'DESIGN.md' && legacy
|
|
112
|
+
? `${content}\n## Legacy migration\n\nReview this draft against [the approved system](design-system/MASTER.md) before adopting it.\n`
|
|
113
|
+
: content);
|
|
114
|
+
}
|
|
115
|
+
for (const file of files.keys()) assertRealDirectory(dirname(file));
|
|
116
|
+
return [...files].map(([file, content]) => {
|
|
117
|
+
if (lstatSync(file, { throwIfNoEntry: false })) return { status: 'kept', file };
|
|
118
|
+
if (dryRun) return { status: 'would create', file };
|
|
119
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
120
|
+
writeFileSync(file, content, { flag: 'wx' });
|
|
121
|
+
return { status: 'created', file };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function validateDesign(root, file = 'DESIGN.md') {
|
|
126
|
+
const path = resolve(root, file);
|
|
127
|
+
const content = readFileSync(path, 'utf8').replace(/^\uFEFF/, '');
|
|
128
|
+
const warnings = [];
|
|
129
|
+
if (/^---\r?\n/.test(content) && !/^---\r?\n[\s\S]*?^---\r?$/m.test(content)) {
|
|
130
|
+
warnings.push('Unclosed front matter');
|
|
131
|
+
}
|
|
132
|
+
for (const heading of ['Overview', 'Colors', 'Typography', 'Layout', 'Components']) {
|
|
133
|
+
if (!new RegExp(`^#{1,6}\\s+${heading}\\s*\$`, 'im').test(content)) warnings.push(`Missing section: ${heading}`);
|
|
134
|
+
}
|
|
135
|
+
if (/\b(?:TODO|TBD)\b|\bdraft pending review\b/i.test(content)) warnings.push('Draft placeholders still require review');
|
|
136
|
+
return { path, warnings, scope: 'Local structure only. Does not validate an external schema or design quality.' };
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-director-skill",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "UI/UX
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "UI/UX orchestration skill with design-system governance, optional specialists and evidence-based visual review",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"config",
|
|
31
31
|
"adapters",
|
|
32
32
|
"references",
|
|
33
|
+
"templates",
|
|
33
34
|
"examples"
|
|
34
35
|
],
|
|
35
36
|
"license": "MIT"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Design workflows
|
|
2
|
+
|
|
3
|
+
## Research and reference matching
|
|
4
|
+
|
|
5
|
+
Identify the audience, main task, entry and exit, content priorities and product constraints. Inspect existing screens first. For each reference, record its source, dimensions, state and the attributes the user wants to carry over. Match viewport, scale and state when comparing screenshots. Check composition, geometry, typography, spacing, color, assets and interactions separately. Adapt to the target design system and use original or approved assets. Record any differences that cannot be verified.
|
|
6
|
+
|
|
7
|
+
## Design system and visual direction
|
|
8
|
+
|
|
9
|
+
Inspect approved design documents, code tokens and components. Establish a clear hierarchy, density and visual direction for the audience and product. For an established product use Token Lock. Add a token or variant only to meet an identified need, and document its approval and effect. For a new product, define semantic roles, theme variants and states from the actual content and usage. Reuse established components for implementation, testing and accessibility.
|
|
10
|
+
|
|
11
|
+
## Prototype and implementation
|
|
12
|
+
|
|
13
|
+
Agree on the deliverable and target stack. For an implementation task, work against actual routes, component contracts and data. Build and exercise the primary interaction along with relevant errors and recovery. Label mock data in a prototype. Use design-file or rendering tools when available and within scope. Check the result against the [quality gates](quality-gates.md).
|
|
14
|
+
|
|
15
|
+
## Motion and interaction
|
|
16
|
+
|
|
17
|
+
For each transition, specify the trigger, start and end states, repeated input, interruption, cancellation, failure and reduced-motion behavior. Use a duration and easing that support the interaction. Review actual motion where possible and measure frame or interaction timing when it matters. Use the target stack's rendering tools.
|
|
18
|
+
|
|
19
|
+
## Visual refinement (DESLOP)
|
|
20
|
+
|
|
21
|
+
Start from the captured baseline. Fix the defects that impede reading or action first. Inspect repetitive cards, decorative badges, default gradients, inconsistent typography, excessive spacing changes and filler copy. Keep visual elements that support information, brand or interaction. Preserve approved tokens and behavior, then rerender to verify the targeted edits.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Platform guidance
|
|
2
|
+
|
|
3
|
+
## Web
|
|
4
|
+
|
|
5
|
+
Verify real browser rendering at relevant widths and zoom levels. Check semantic controls, keyboard focus, accessible names, layout shifts, form states and reduced motion. Exercise primary interactions in the project's browser and framework.
|
|
6
|
+
|
|
7
|
+
## Mobile
|
|
8
|
+
|
|
9
|
+
Check safe areas, system navigation, dynamic type, touch targets, keyboard, offline and permission states. Exercise relevant lifecycle events and record whether verification used a simulator or a physical device.
|
|
10
|
+
|
|
11
|
+
## Desktop
|
|
12
|
+
|
|
13
|
+
Check window resizing and lifecycle, high-DPI scaling, focus, keyboard shortcuts, pointer actions and readable density. Capture real window states and test native behavior in its runtime.
|
|
14
|
+
|
|
15
|
+
## Other targets
|
|
16
|
+
|
|
17
|
+
Use the actual input model, layout primitives and rendering tools. Identify any assumptions before borrowing platform-specific guidance. Record the runtime or device used in verification.
|
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
# Project
|
|
1
|
+
# Project inspection
|
|
2
2
|
|
|
3
|
-
For an existing
|
|
3
|
+
Read the user brief and any project instructions, then inspect the relevant routes, components, states and tests. For an existing interface, examine neighboring screens and the rendering stack before proposing a change.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- Check the project profile at `.ui-director/project.json` if present. Read PRODUCT.md, DESIGN.md and any approved `design-system/MASTER.md` the project uses. Trace approved rules back to components, tokens and themes in code.
|
|
6
|
+
- Identify the primary journey, density, typography, semantic colors, spacing, layout and interaction conventions. Check real loading, error, empty, disabled and permission states where applicable.
|
|
7
|
+
- Keep approved rules and actual implementation distinct in the brief. If they disagree, retain user-approved constraints and use the discrepancy as a review finding. Reconcile it within the requested scope.
|
|
8
|
+
- Apply Token Lock to existing products. Reuse approved semantic values and component variants. Propose an explicit exception or reviewed addition when an existing value cannot meet a real requirement.
|
|
9
|
+
- Record the platform, scope, constraints, approvals, acceptance checks and evidence needed. Pass only relevant decisions and evidence to the next stage. Keep one-off work in the response when the task calls for no persistent artifacts.
|
|
6
10
|
|
|
7
|
-
|
|
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.
|
|
11
|
+
Use [PRODUCT](../templates/PRODUCT.md), [DESIGN](../templates/DESIGN.md), and [DECISIONS](../templates/DECISIONS.md) when project documents are requested and the repository has no suitable format. For legacy migration, retain MASTER.md and review the new draft before switching the project's design authority.
|