@lucasvu/scope-ui 0.0.6 → 0.0.8
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/AI_SETUP.md +2 -0
- package/README.md +2 -1
- package/bin/scope-ui-init.mjs +90 -27
- package/package.json +1 -1
package/AI_SETUP.md
CHANGED
|
@@ -43,6 +43,8 @@ npx scope-ui-init --theme graphite
|
|
|
43
43
|
|
|
44
44
|
File generate ra sẽ là source of truth cho palette, surface, radius và shadow của project. Agent phải bám vào file này thay vì tự nghĩ màu mới.
|
|
45
45
|
|
|
46
|
+
`AGENTS.md` sẽ có thêm block brief dạng YAML để agent điền các giá trị như `routeUrl`, `sidebarItems`, `pageTitle`, `filters`, `fields`, `tableColumns` trước khi bắt đầu viết JSX.
|
|
47
|
+
|
|
46
48
|
```css
|
|
47
49
|
:root {
|
|
48
50
|
--tw-primary: 12 88% 56%;
|
package/README.md
CHANGED
|
@@ -114,8 +114,9 @@ Nếu muốn AI render UI đúng và ổn định theo thư viện này, đừng
|
|
|
114
114
|
- Chạy `npx scope-ui-init --list-themes` để xem preset được duyệt
|
|
115
115
|
- Chạy `npx scope-ui-init --theme <preset>` ở project consumer sau khi đã cài `@lucasvu/scope-ui` để tạo `AGENTS.md` và `src/styles/ui-theme.css`
|
|
116
116
|
- Khoá project vào một preset thay vì tự bịa palette mới cho từng page
|
|
117
|
-
- Để agent đọc luôn playbook trong `AGENTS.md` để đi đúng thứ tự: kiểm tra import, chọn component, dựng layout, rồi mới tinh chỉnh token
|
|
117
|
+
- Để agent đọc luôn playbook trong `AGENTS.md` để đi đúng thứ tự: điền brief, kiểm tra import, chọn component, dựng layout, rồi mới tinh chỉnh token
|
|
118
118
|
- Buộc agent điền screen brief trước khi code: `routeUrl`, `sidebarItems`, `activeSidebarItemId`, `pageTitle`, `actions`, `filters`, `fields`, `tableColumns`
|
|
119
|
+
- `AGENTS.md` mới sẽ có sẵn block brief dạng YAML để agent hoặc dev điền trực tiếp trước khi code
|
|
119
120
|
- Chỉ dùng các component canonical ở root package; tránh `MainFe` nếu không phải legacy screen
|
|
120
121
|
- Cho agent đọc `uiAiManifest` để biết component nào dùng cho intent nào, props quan trọng là gì, và khi nào không nên dùng
|
|
121
122
|
- Cho agent đọc `uiScreenBlueprint`, `uiThemeContract` và `uiThemePresets` để biết screen recipe, preset và token nào được phép override
|
package/bin/scope-ui-init.mjs
CHANGED
|
@@ -349,37 +349,87 @@ Theme preset summary:
|
|
|
349
349
|
- ${themePreset.description}
|
|
350
350
|
- Recommended for: ${themePreset.recommendedFor.join(', ')}
|
|
351
351
|
|
|
352
|
-
|
|
352
|
+
## Required Flow
|
|
353
|
+
|
|
354
|
+
When asked to build or edit a screen, follow these steps in order:
|
|
355
|
+
|
|
353
356
|
1. Read \`${themeFile}\`, \`node_modules/${PACKAGE_NAME}/README.md\`, \`node_modules/${PACKAGE_NAME}/AI_SETUP.md\`, and the exported \`uiScreenBlueprint\` contract before generating UI.
|
|
354
357
|
2. Fill the screen brief first. If route url, sidebar items, active sidebar item, title, actions, filters, fields, or columns are missing, ask for them or leave clear TODO placeholders instead of inventing them.
|
|
355
358
|
3. Verify the app entry imports \`${PACKAGE_NAME}/styles.css\` first and the project theme file right after it.
|
|
356
359
|
4. Identify the page kind (\`list | form | detail | dashboard\`), then map each block to canonical components from \`uiAiManifest\` before writing JSX.
|
|
357
|
-
5. Build the shell in this order: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> top actions -> page body cards/grids.
|
|
358
|
-
6. For list pages, build filters first and then the \`DataTable\`. For form pages, build section cards and fields. For detail pages, build summary cards and related tables. For dashboard pages, build stat cards and then supporting tables
|
|
360
|
+
5. Build the shell in this exact order: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> top actions -> page body cards/grids.
|
|
361
|
+
6. For list pages, build filters first and then the \`DataTable\`. For form pages, build section cards and fields. For detail pages, build summary cards and related tables. For dashboard pages, build stat cards and then supporting cards/tables.
|
|
359
362
|
7. Keep all colors, radius, surface, and shadow decisions inside \`${themeFile}\`. If the preset is insufficient, update tokens there instead of styling one page ad hoc.
|
|
360
|
-
8. Before finishing,
|
|
361
|
-
|
|
362
|
-
Screen
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
363
|
+
8. Before finishing, run the output checklist in this file.
|
|
364
|
+
|
|
365
|
+
## Screen Brief
|
|
366
|
+
|
|
367
|
+
Complete this brief before writing JSX:
|
|
368
|
+
|
|
369
|
+
\`\`\`yaml
|
|
370
|
+
pageKind: list | form | detail | dashboard
|
|
371
|
+
routeUrl:
|
|
372
|
+
sidebarItems:
|
|
373
|
+
- id:
|
|
374
|
+
title:
|
|
375
|
+
href:
|
|
376
|
+
activeSidebarItemId:
|
|
377
|
+
breadcrumbs:
|
|
378
|
+
- label:
|
|
379
|
+
href:
|
|
380
|
+
current:
|
|
381
|
+
pageTitle:
|
|
382
|
+
pageSubtitle:
|
|
383
|
+
primaryAction:
|
|
384
|
+
label:
|
|
385
|
+
href:
|
|
386
|
+
secondaryActions:
|
|
387
|
+
- label:
|
|
388
|
+
href:
|
|
389
|
+
summaryStats:
|
|
390
|
+
- label:
|
|
391
|
+
value:
|
|
392
|
+
delta:
|
|
393
|
+
trend:
|
|
394
|
+
filters:
|
|
395
|
+
- type:
|
|
396
|
+
label:
|
|
397
|
+
key:
|
|
398
|
+
tableColumns:
|
|
399
|
+
- key:
|
|
400
|
+
title:
|
|
401
|
+
type:
|
|
402
|
+
rowActions:
|
|
403
|
+
- label:
|
|
404
|
+
key:
|
|
405
|
+
formSections:
|
|
406
|
+
- title:
|
|
407
|
+
fields: []
|
|
408
|
+
fields:
|
|
409
|
+
- name:
|
|
410
|
+
type:
|
|
411
|
+
label:
|
|
412
|
+
required:
|
|
413
|
+
helperText:
|
|
414
|
+
detailSections:
|
|
415
|
+
- title:
|
|
416
|
+
type:
|
|
417
|
+
emptyState:
|
|
418
|
+
title:
|
|
419
|
+
description:
|
|
420
|
+
actionLabel:
|
|
421
|
+
permissions: []
|
|
422
|
+
\`\`\`
|
|
423
|
+
|
|
424
|
+
## Page Frame Recipes
|
|
425
|
+
|
|
426
|
+
- \`list\`: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> header actions -> optional stats -> filter \`Card\` -> \`DataTable\` \`Card\`
|
|
427
|
+
- \`form\`: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> primary/cancel actions -> sectioned form \`Card\` blocks -> bottom action row
|
|
428
|
+
- \`detail\`: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> status/actions -> summary metadata \`Card\` -> detail \`Card\` blocks -> related \`DataTable\`
|
|
429
|
+
- \`dashboard\`: \`Sidebar\` -> \`Breadcrumb\` -> \`PageTitle\` -> header actions -> \`Stat\` row -> filters -> insight \`Card\` blocks and \`DataTable\`
|
|
430
|
+
|
|
431
|
+
## Hard Rules
|
|
432
|
+
|
|
383
433
|
- import \`${PACKAGE_NAME}/styles.css\` once at the app entry
|
|
384
434
|
- import the project theme override file after the package stylesheet
|
|
385
435
|
- use root exports from \`${PACKAGE_NAME}\`
|
|
@@ -395,7 +445,8 @@ Do not:
|
|
|
395
445
|
- restyle individual pages if the preset tokens can solve it globally
|
|
396
446
|
- create duplicate Button/Input/Select wrappers unless a project-specific behavior is required
|
|
397
447
|
|
|
398
|
-
Component
|
|
448
|
+
## Component Choice
|
|
449
|
+
|
|
399
450
|
- \`Input\` for short text
|
|
400
451
|
- \`Textarea\` for multiline text
|
|
401
452
|
- \`Select\` for small fixed options
|
|
@@ -405,6 +456,18 @@ Component choice:
|
|
|
405
456
|
- \`MultiSelect\` for multi-pick
|
|
406
457
|
- \`Field\` only for custom controls or grouped content
|
|
407
458
|
- \`DataTable\` for tabular records
|
|
459
|
+
|
|
460
|
+
## Output Check
|
|
461
|
+
|
|
462
|
+
Before finishing, confirm all of these are true:
|
|
463
|
+
|
|
464
|
+
- The screen brief is complete or unresolved values are clearly marked as TODO.
|
|
465
|
+
- The shell contains \`Sidebar\`, \`Breadcrumb\`, and \`PageTitle\` in the correct order.
|
|
466
|
+
- The chosen components match the page kind and the brief.
|
|
467
|
+
- No \`MainFe\` imports were used.
|
|
468
|
+
- No hardcoded brand colors were added in page components.
|
|
469
|
+
- Theme decisions live in \`${themeFile}\`, not in ad hoc JSX styling.
|
|
470
|
+
- Spacing, card structure, and actions are consistent with the shared preset.
|
|
408
471
|
`
|
|
409
472
|
}
|
|
410
473
|
|