aub-workspace 0.3.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.
Files changed (152) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/bin/aub-workspace.mjs +246 -0
  4. package/package.json +32 -0
  5. package/vendor/aub/apps/editor/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  6. package/vendor/aub/apps/editor/dist/assets/angular-importer.lib-dB_jK4mR.js +32 -0
  7. package/vendor/aub/apps/editor/dist/assets/canvas-tools-CuYC7cA2.js +364 -0
  8. package/vendor/aub/apps/editor/dist/assets/design-bridge.lib-DJvaK6AX.js +1 -0
  9. package/vendor/aub/apps/editor/dist/assets/export-agent-prompt.lib-BsP0KNqo.js +2 -0
  10. package/vendor/aub/apps/editor/dist/assets/export-md.lib-DdmdeWgO.js +3 -0
  11. package/vendor/aub/apps/editor/dist/assets/handoff-package.lib-DDYpcEma.js +20 -0
  12. package/vendor/aub/apps/editor/dist/assets/implementation-report.lib-CmsSB_8s.js +1 -0
  13. package/vendor/aub/apps/editor/dist/assets/index-BCH-ek3h.js +2 -0
  14. package/vendor/aub/apps/editor/dist/assets/index-lAnc928Q.css +1 -0
  15. package/vendor/aub/apps/editor/dist/assets/index-vt1nM1M4.js +507 -0
  16. package/vendor/aub/apps/editor/dist/assets/jszip.min-CRfXyL92.js +12 -0
  17. package/vendor/aub/apps/editor/dist/assets/react-vendor-ByX9Pqse.js +40 -0
  18. package/vendor/aub/apps/editor/dist/brand/android-chrome-192x192.png +0 -0
  19. package/vendor/aub/apps/editor/dist/brand/android-chrome-512x512.png +0 -0
  20. package/vendor/aub/apps/editor/dist/brand/app-icon-1024.png +0 -0
  21. package/vendor/aub/apps/editor/dist/brand/app-icon-192.png +0 -0
  22. package/vendor/aub/apps/editor/dist/brand/app-icon-512.png +0 -0
  23. package/vendor/aub/apps/editor/dist/brand/apple-touch-icon.png +0 -0
  24. package/vendor/aub/apps/editor/dist/brand/aub-logo-mark.svg +28 -0
  25. package/vendor/aub/apps/editor/dist/brand/favicon-16x16.png +0 -0
  26. package/vendor/aub/apps/editor/dist/brand/favicon-32x32.png +0 -0
  27. package/vendor/aub/apps/editor/dist/brand/favicon-48x48.png +0 -0
  28. package/vendor/aub/apps/editor/dist/brand/favicon.ico +0 -0
  29. package/vendor/aub/apps/editor/dist/brand/favicon.svg +9 -0
  30. package/vendor/aub/apps/editor/dist/brand/maskable-icon-512.png +0 -0
  31. package/vendor/aub/apps/editor/dist/brand/mstile-150x150.png +0 -0
  32. package/vendor/aub/apps/editor/dist/brand/safari-pinned-tab.svg +8 -0
  33. package/vendor/aub/apps/editor/dist/browserconfig.xml +9 -0
  34. package/vendor/aub/apps/editor/dist/index.html +22 -0
  35. package/vendor/aub/apps/editor/dist/manifest.webmanifest +28 -0
  36. package/vendor/aub/apps/editor/dist/template-previews/admin-table.png +0 -0
  37. package/vendor/aub/apps/editor/dist/template-previews/booking.png +0 -0
  38. package/vendor/aub/apps/editor/dist/template-previews/calendar.png +0 -0
  39. package/vendor/aub/apps/editor/dist/template-previews/catalog.png +0 -0
  40. package/vendor/aub/apps/editor/dist/template-previews/chat.png +0 -0
  41. package/vendor/aub/apps/editor/dist/template-previews/checkout.png +0 -0
  42. package/vendor/aub/apps/editor/dist/template-previews/crm.png +0 -0
  43. package/vendor/aub/apps/editor/dist/template-previews/dashboard.png +0 -0
  44. package/vendor/aub/apps/editor/dist/template-previews/feed.png +0 -0
  45. package/vendor/aub/apps/editor/dist/template-previews/files.png +0 -0
  46. package/vendor/aub/apps/editor/dist/template-previews/kanban.png +0 -0
  47. package/vendor/aub/apps/editor/dist/template-previews/landing.png +0 -0
  48. package/vendor/aub/apps/editor/dist/template-previews/mail.png +0 -0
  49. package/vendor/aub/apps/editor/dist/template-previews/onboarding.png +0 -0
  50. package/vendor/aub/apps/editor/dist/template-previews/pricing.png +0 -0
  51. package/vendor/aub/apps/editor/dist/template-previews/product-detail.png +0 -0
  52. package/vendor/aub/apps/editor/dist/template-previews/settings.png +0 -0
  53. package/vendor/aub/apps/editor/dist/template-previews/wiki.png +0 -0
  54. package/vendor/aub/apps/mcp-server/dist/aub.js +15 -0
  55. package/vendor/aub/apps/mcp-server/dist/context.js +1 -0
  56. package/vendor/aub/apps/mcp-server/dist/http.js +123 -0
  57. package/vendor/aub/apps/mcp-server/dist/index.js +23 -0
  58. package/vendor/aub/apps/mcp-server/dist/repo.js +17 -0
  59. package/vendor/aub/apps/mcp-server/dist/schema.js +42 -0
  60. package/vendor/aub/apps/mcp-server/dist/server.js +80 -0
  61. package/vendor/aub/apps/mcp-server/dist/tools/approve-component-candidate.js +27 -0
  62. package/vendor/aub/apps/mcp-server/dist/tools/diff-blueprints.js +27 -0
  63. package/vendor/aub/apps/mcp-server/dist/tools/export-handoff.js +87 -0
  64. package/vendor/aub/apps/mcp-server/dist/tools/export-prompt.js +35 -0
  65. package/vendor/aub/apps/mcp-server/dist/tools/export-template-authoring-prompt.js +13 -0
  66. package/vendor/aub/apps/mcp-server/dist/tools/generate-template-from-source.js +25 -0
  67. package/vendor/aub/apps/mcp-server/dist/tools/get-aub-session.js +13 -0
  68. package/vendor/aub/apps/mcp-server/dist/tools/get-blueprint.js +28 -0
  69. package/vendor/aub/apps/mcp-server/dist/tools/get-project.js +45 -0
  70. package/vendor/aub/apps/mcp-server/dist/tools/get-workspace-status.js +10 -0
  71. package/vendor/aub/apps/mcp-server/dist/tools/import-design-bridge.js +62 -0
  72. package/vendor/aub/apps/mcp-server/dist/tools/list-blueprints.js +11 -0
  73. package/vendor/aub/apps/mcp-server/dist/tools/list-projects.js +11 -0
  74. package/vendor/aub/apps/mcp-server/dist/tools/lock-blueprint.js +33 -0
  75. package/vendor/aub/apps/mcp-server/dist/tools/migrate-blueprint.js +38 -0
  76. package/vendor/aub/apps/mcp-server/dist/tools/resolve-component.js +51 -0
  77. package/vendor/aub/apps/mcp-server/dist/tools/scaffold-blueprint.js +53 -0
  78. package/vendor/aub/apps/mcp-server/dist/tools/scan-project-ui.js +18 -0
  79. package/vendor/aub/apps/mcp-server/dist/tools/submit-report.js +48 -0
  80. package/vendor/aub/apps/mcp-server/dist/tools/update-aub-session.js +14 -0
  81. package/vendor/aub/apps/mcp-server/dist/tools/validate-blueprint.js +67 -0
  82. package/vendor/aub/apps/mcp-server/dist/tools/validate-project.js +74 -0
  83. package/vendor/aub/apps/mcp-server/dist/tools/write-blueprint.js +72 -0
  84. package/vendor/aub/apps/mcp-server/dist/workspace.js +138 -0
  85. package/vendor/aub/docs/agent-handoff.md +85 -0
  86. package/vendor/aub/docs/agent-handoff.zh-Hant.md +85 -0
  87. package/vendor/aub/docs/template-authoring-agent.md +86 -0
  88. package/vendor/aub/schema/aub-ci.schema.json +34 -0
  89. package/vendor/aub/schema/aub.registry.schema.json +118 -0
  90. package/vendor/aub/schema/design-bridge.schema.json +44 -0
  91. package/vendor/aub/schema/implementation-report.schema.json +93 -0
  92. package/vendor/aub/schema/project-types.ts +72 -0
  93. package/vendor/aub/schema/registry/components.json +118 -0
  94. package/vendor/aub/schema/types.js +13 -0
  95. package/vendor/aub/schema/types.ts +348 -0
  96. package/vendor/aub/schema/ui-blueprint-lock.schema.json +61 -0
  97. package/vendor/aub/schema/ui-blueprint.schema.json +1339 -0
  98. package/vendor/aub/schema/ui-project.schema.json +139 -0
  99. package/vendor/aub/scripts/agent-implementation-benchmark.lib.mjs +125 -0
  100. package/vendor/aub/scripts/angular-importer.lib.mjs +982 -0
  101. package/vendor/aub/scripts/check-editor-bundle-budget.mjs +36 -0
  102. package/vendor/aub/scripts/ci-verify.lib.mjs +256 -0
  103. package/vendor/aub/scripts/ci-verify.mjs +45 -0
  104. package/vendor/aub/scripts/create-authoring-kit.mjs +84 -0
  105. package/vendor/aub/scripts/create-implementation-report.mjs +24 -0
  106. package/vendor/aub/scripts/design-bridge.lib.d.mts +32 -0
  107. package/vendor/aub/scripts/design-bridge.lib.mjs +69 -0
  108. package/vendor/aub/scripts/diff-blueprint.lib.d.mts +18 -0
  109. package/vendor/aub/scripts/diff-blueprint.lib.mjs +148 -0
  110. package/vendor/aub/scripts/diff-blueprint.mjs +25 -0
  111. package/vendor/aub/scripts/export-agent-prompt.lib.d.mts +10 -0
  112. package/vendor/aub/scripts/export-agent-prompt.lib.mjs +160 -0
  113. package/vendor/aub/scripts/export-agent-prompt.mjs +79 -0
  114. package/vendor/aub/scripts/export-md.lib.d.mts +3 -0
  115. package/vendor/aub/scripts/export-md.lib.mjs +302 -0
  116. package/vendor/aub/scripts/export-md.mjs +43 -0
  117. package/vendor/aub/scripts/generate-registry-artifacts.lib.mjs +118 -0
  118. package/vendor/aub/scripts/generate-registry-artifacts.mjs +65 -0
  119. package/vendor/aub/scripts/generate-site-locales.mjs +545 -0
  120. package/vendor/aub/scripts/handoff-package.lib.d.mts +20 -0
  121. package/vendor/aub/scripts/handoff-package.lib.mjs +111 -0
  122. package/vendor/aub/scripts/implementation-report.lib.d.mts +21 -0
  123. package/vendor/aub/scripts/implementation-report.lib.mjs +97 -0
  124. package/vendor/aub/scripts/import-angular-component.mjs +72 -0
  125. package/vendor/aub/scripts/import-design-bridge.mjs +59 -0
  126. package/vendor/aub/scripts/lock-blueprint.lib.d.mts +23 -0
  127. package/vendor/aub/scripts/lock-blueprint.lib.mjs +58 -0
  128. package/vendor/aub/scripts/lock-blueprint.mjs +36 -0
  129. package/vendor/aub/scripts/migrate-blueprint-cli.mjs +28 -0
  130. package/vendor/aub/scripts/migrate-blueprint.d.mts +5 -0
  131. package/vendor/aub/scripts/migrate-blueprint.mjs +95 -0
  132. package/vendor/aub/scripts/package-workspace-cli.mjs +34 -0
  133. package/vendor/aub/scripts/project.lib.d.mts +44 -0
  134. package/vendor/aub/scripts/project.lib.mjs +175 -0
  135. package/vendor/aub/scripts/project.mjs +332 -0
  136. package/vendor/aub/scripts/registry.lib.d.mts +52 -0
  137. package/vendor/aub/scripts/registry.lib.mjs +222 -0
  138. package/vendor/aub/scripts/run-agent-implementation.mjs +423 -0
  139. package/vendor/aub/scripts/run-agent-readability.mjs +145 -0
  140. package/vendor/aub/scripts/run-ollama-prompt.mjs +30 -0
  141. package/vendor/aub/scripts/scaffold-blueprint.lib.d.mts +38 -0
  142. package/vendor/aub/scripts/scaffold-blueprint.lib.mjs +316 -0
  143. package/vendor/aub/scripts/scaffold-blueprint.mjs +86 -0
  144. package/vendor/aub/scripts/score-agent-implementation.mjs +27 -0
  145. package/vendor/aub/scripts/score-agent-readability.mjs +54 -0
  146. package/vendor/aub/scripts/sync-brand-assets.mjs +33 -0
  147. package/vendor/aub/scripts/validate-blueprint.lib.d.mts +14 -0
  148. package/vendor/aub/scripts/validate-blueprint.lib.mjs +136 -0
  149. package/vendor/aub/scripts/validate.mjs +128 -0
  150. package/vendor/aub/scripts/verify-implementation-report.mjs +36 -0
  151. package/vendor/aub/scripts/workspace-loop.lib.d.mts +17 -0
  152. package/vendor/aub/scripts/workspace-loop.lib.mjs +674 -0
@@ -0,0 +1,138 @@
1
+ import { readdir, readFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import { extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
+ import yaml from 'js-yaml';
5
+ import { parseProjectText } from './aub.js';
6
+ const IGNORED_DIRS = new Set(['node_modules', 'dist', '.git', '.aub', '.pnpm-store']);
7
+ const BLUEPRINT_PATTERN = /\.ui\.(json|ya?ml)$/i;
8
+ export const PROJECT_PATTERN = /\.aub\.project\.(json|ya?ml)$/i;
9
+ export function resolveWorkspacePath(root, filePath) {
10
+ const absRoot = resolve(root);
11
+ const absPath = resolve(absRoot, filePath);
12
+ const rel = relative(absRoot, absPath);
13
+ if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
14
+ throw new Error(`Path must stay inside the workspace root: ${filePath}`);
15
+ }
16
+ return absPath;
17
+ }
18
+ function isYaml(filePath) {
19
+ const ext = extname(filePath).toLowerCase();
20
+ return ext === '.yaml' || ext === '.yml';
21
+ }
22
+ export function parseBlueprintText(text, filePath) {
23
+ const document = isYaml(filePath) ? yaml.load(text) : JSON.parse(text);
24
+ if (!document || typeof document !== 'object') {
25
+ throw new Error(`File does not contain a Blueprint object: ${filePath}`);
26
+ }
27
+ return document;
28
+ }
29
+ export async function readBlueprintFile(absPath) {
30
+ const text = await readFile(absPath, 'utf8');
31
+ return parseBlueprintText(text, absPath);
32
+ }
33
+ function toEntry(root, absPath, blueprint) {
34
+ return {
35
+ path: relative(root, absPath).split(sep).join('/'),
36
+ absPath,
37
+ screenId: blueprint?.screen?.id ?? '',
38
+ screenName: blueprint?.screen?.name ?? '',
39
+ version: blueprint?.version ?? '',
40
+ };
41
+ }
42
+ async function walk(dir, out, pattern) {
43
+ let dirents;
44
+ try {
45
+ dirents = await readdir(dir, { withFileTypes: true });
46
+ }
47
+ catch {
48
+ return;
49
+ }
50
+ for (const dirent of dirents) {
51
+ const full = join(dir, dirent.name);
52
+ if (dirent.isDirectory()) {
53
+ if (IGNORED_DIRS.has(dirent.name) || dirent.name.startsWith('.'))
54
+ continue;
55
+ await walk(full, out, pattern);
56
+ }
57
+ else if (dirent.isFile() && pattern.test(dirent.name)) {
58
+ out.push(full);
59
+ }
60
+ }
61
+ }
62
+ export async function listBlueprints(root) {
63
+ const files = [];
64
+ await walk(root, files, BLUEPRINT_PATTERN);
65
+ const entries = [];
66
+ for (const absPath of files.sort()) {
67
+ try {
68
+ const blueprint = await readBlueprintFile(absPath);
69
+ entries.push(toEntry(root, absPath, blueprint));
70
+ }
71
+ catch {
72
+ // Skip files that fail to parse; validate_blueprint surfaces details on demand.
73
+ }
74
+ }
75
+ return entries;
76
+ }
77
+ // Resolve a ref that is either a file path (absolute or relative to root) or a screen id.
78
+ export async function resolveBlueprint(root, ref) {
79
+ const trimmed = ref.trim();
80
+ if (!trimmed)
81
+ throw new Error('A blueprint ref (file path or screen id) is required.');
82
+ const candidate = isAbsolute(trimmed) ? trimmed : resolve(root, trimmed);
83
+ if (BLUEPRINT_PATTERN.test(trimmed) || existsSync(candidate)) {
84
+ if (!existsSync(candidate)) {
85
+ throw new Error(`Blueprint file not found: ${trimmed}`);
86
+ }
87
+ const blueprint = await readBlueprintFile(candidate);
88
+ return { blueprint, entry: toEntry(root, candidate, blueprint) };
89
+ }
90
+ const entries = await listBlueprints(root);
91
+ const match = entries.find((entry) => entry.screenId === trimmed);
92
+ if (!match) {
93
+ throw new Error(`No blueprint found for ref "${ref}" (not a file path and no matching screen id).`);
94
+ }
95
+ const blueprint = await readBlueprintFile(match.absPath);
96
+ return { blueprint, entry: match };
97
+ }
98
+ export async function listProjects(root) {
99
+ const files = [];
100
+ await walk(root, files, PROJECT_PATTERN);
101
+ const entries = [];
102
+ for (const absPath of files.sort()) {
103
+ try {
104
+ const text = await readFile(absPath, 'utf8');
105
+ const project = parseProjectText(text, absPath);
106
+ entries.push({
107
+ path: relative(root, absPath).split(sep).join('/'),
108
+ absPath,
109
+ id: project?.id ?? '',
110
+ name: project?.name ?? '',
111
+ screenCount: Array.isArray(project?.screens) ? project.screens.length : 0,
112
+ });
113
+ }
114
+ catch {
115
+ // Skip files that fail to parse; validate_project surfaces details on demand.
116
+ }
117
+ }
118
+ return entries;
119
+ }
120
+ // Resolve a ref that is either a project file path (absolute or relative to root) or a project id.
121
+ export async function resolveProjectRef(root, ref) {
122
+ const trimmed = ref.trim();
123
+ if (!trimmed)
124
+ throw new Error('A project ref (file path or project id) is required.');
125
+ const candidate = isAbsolute(trimmed) ? trimmed : resolve(root, trimmed);
126
+ if (PROJECT_PATTERN.test(trimmed) || existsSync(candidate)) {
127
+ if (!existsSync(candidate)) {
128
+ throw new Error(`Project file not found: ${trimmed}`);
129
+ }
130
+ return { projectPath: candidate };
131
+ }
132
+ const entries = await listProjects(root);
133
+ const match = entries.find((entry) => entry.id === trimmed);
134
+ if (!match) {
135
+ throw new Error(`No project found for ref "${ref}" (not a file path and no matching project id).`);
136
+ }
137
+ return { projectPath: match.absPath };
138
+ }
@@ -0,0 +1,85 @@
1
+ # AUB Agent Handoff Guide
2
+
3
+ This guide is for coding agents that receive an AUB UI Blueprint or an `.aub.zip` handoff package.
4
+
5
+ > 繁體中文版:[`agent-handoff.zh-Hant.md`](./agent-handoff.zh-Hant.md)
6
+
7
+ ## Explain AUB to the user
8
+
9
+ AUB is a visual UI contract between a person and a coding agent. The user arranges a screen in the AUB editor, then exports structured layout, component semantics, interactions, responsive behavior, screenshots, and verifiable acceptance criteria.
10
+
11
+ In your first response:
12
+
13
+ 1. Reply in the user's language.
14
+ 2. Explain that AUB describes what the interface must do and how it will be verified.
15
+ 3. List the AUB files and supporting evidence you found.
16
+ 4. State whether you will author, plan, implement, or review.
17
+ 5. Identify unresolved product decisions. Ask only when the repository and supplied evidence cannot resolve them.
18
+
19
+ ## Recognize the inputs
20
+
21
+ An AUB handoff package can contain:
22
+
23
+ | File | Purpose | Authority |
24
+ |---|---|---|
25
+ | `*.ui.json` | Complete machine-readable UI contract | **Source of truth** |
26
+ | `*.ui.md` | Human- and agent-readable rendering of the Blueprint | Derived reference |
27
+ | `screenshots/*.png` | Visual evidence for each viewport | Supporting reference |
28
+ | `*.agent.md` | Agent-neutral task prompt | Execution instructions |
29
+ | `*.codex.md` | Codex-specific task prompt | Execution instructions |
30
+ | `implementation-report.template.json` | Required node and acceptance report | Completion contract |
31
+ | `implementation-report.schema.json` | Schema for the completed report | Validation contract |
32
+ | `manifest.json` | Package metadata, hashes, and entrypoint | Integrity metadata |
33
+
34
+ If files conflict, follow this precedence:
35
+
36
+ 1. Valid `*.ui.json`
37
+ 2. Explicit repository constraints
38
+ 3. Acceptance criteria and responsive rules in the Blueprint
39
+ 4. Generated `*.ui.md`
40
+ 5. Screenshots
41
+ 6. Prose outside the package
42
+
43
+ Do not silently resolve a conflict. Explain it and propose a concrete resolution.
44
+
45
+ ## Choose the task
46
+
47
+ - **Author**: Convert product requirements or an existing screen into one schema-valid Blueprint.
48
+ - **Plan**: Map Blueprint nodes and acceptance ids to the target repository without editing files.
49
+ - **Implement**: Change the target repository until the Blueprint and every acceptance item are satisfied.
50
+ - **Review**: Compare an existing implementation with the Blueprint and report mismatches by severity.
51
+
52
+ ## Required workflow
53
+
54
+ 1. Read the target repository's instructions, including applicable `AGENTS.md`, `CLAUDE.md`, and `.github/copilot-instructions.md`.
55
+ 2. Inspect existing routes, components, design tokens, dependencies, tests, and implementation patterns.
56
+ 3. Validate the Blueprint before relying on it.
57
+ 4. Map every Blueprint node id to an existing or new implementation component.
58
+ When `aub.registry.json` declares a matching production implementation, reuse its module,
59
+ export, source, and prop mappings before considering a new component.
60
+ 5. Preserve hierarchy, semantic component type, layout mode, viewport geometry, interactions, responsive rules, states, and constraints.
61
+ 6. Use repository-native components and tokens when they satisfy the contract.
62
+ 7. Run checks that cover every changed surface.
63
+ 8. Complete the implementation report with a file mapping and evidence for every acceptance id.
64
+
65
+ ## Non-negotiable rules
66
+
67
+ - Treat `*.ui.json` as the source of truth. Markdown and screenshots do not override it.
68
+ - Do not redesign the screen, weaken acceptance criteria, or replace declared behavior with a preferred pattern.
69
+ - Do not invent missing product behavior. Record uncertainty and ask the user when it materially affects the result.
70
+ - Do not change `auto` layout to `freeform`, or the reverse, unless the Blueprint or an approved conflict resolution requires it.
71
+ - Preserve accessible names, focus behavior, minimum target sizes, and responsive overflow constraints.
72
+ - Report blockers explicitly. Partial completion must not be presented as complete.
73
+
74
+ ## Completion response
75
+
76
+ Reply in the user's language and include:
77
+
78
+ 1. What was implemented or reviewed.
79
+ 2. Files changed or inspected.
80
+ 3. Validation commands and exact results.
81
+ 4. Every acceptance id with `pass`, `fail`, or `needs-review` and concrete evidence.
82
+ 5. Unresolved decisions, conflicts, or blockers.
83
+ 6. The completed `implementation-report.json` when the task is implementation or review.
84
+
85
+ An implementation is complete only when the report maps every node, every required acceptance item passes with evidence, and no unresolved blocker remains.
@@ -0,0 +1,85 @@
1
+ # AUB Agent 交付指南
2
+
3
+ 本指南提供給收到 AUB UI Blueprint 或 `.aub.zip` 交付包的編碼 Agent。
4
+
5
+ > English version: [`agent-handoff.md`](./agent-handoff.md)
6
+
7
+ ## 先向使用者說明 AUB
8
+
9
+ AUB 是使用者與編碼 Agent 之間的視覺 UI 合約。使用者在 AUB 編輯器中安排畫面,再匯出結構化的版面、元件語意、互動、響應式行為、畫面截圖與可驗證的驗收條件。
10
+
11
+ 第一次回覆時:
12
+
13
+ 1. 使用使用者目前使用的語言。
14
+ 2. 說明 AUB 定義了介面應該做什麼,以及最後如何驗收。
15
+ 3. 列出找到的 AUB 檔案與輔助證據。
16
+ 4. 說明這次要執行生成、規劃、實作或審查。
17
+ 5. 指出尚未決定的產品問題。只有 repository 與既有證據都無法回答時才詢問使用者。
18
+
19
+ ## 辨識輸入內容
20
+
21
+ AUB 交付包可能包含:
22
+
23
+ | 檔案 | 用途 | 權威性 |
24
+ |---|---|---|
25
+ | `*.ui.json` | 完整且可由機器讀取的 UI 合約 | **唯一真實來源** |
26
+ | `*.ui.md` | Blueprint 的人類與 Agent 可讀版本 | 衍生參考 |
27
+ | `screenshots/*.png` | 各 viewport 的視覺證據 | 輔助參考 |
28
+ | `*.agent.md` | Agent 中立的任務提示 | 執行指示 |
29
+ | `*.codex.md` | Codex 專用任務提示 | 執行指示 |
30
+ | `implementation-report.template.json` | 必填的節點與驗收報告 | 完成契約 |
31
+ | `implementation-report.schema.json` | 完成報告使用的 schema | 驗證契約 |
32
+ | `manifest.json` | 交付包 metadata、雜湊與入口 | 完整性資料 |
33
+
34
+ 若檔案彼此衝突,依以下順序判定:
35
+
36
+ 1. 通過驗證的 `*.ui.json`
37
+ 2. Repository 的明確限制
38
+ 3. Blueprint 內的驗收條件與響應式規則
39
+ 4. 自動產生的 `*.ui.md`
40
+ 5. 截圖
41
+ 6. 交付包外的文字描述
42
+
43
+ 不得默默自行處理衝突。必須向使用者說明,並提出具體解法。
44
+
45
+ ## 選擇任務
46
+
47
+ - **生成**:把產品需求或既有畫面轉成一份通過 schema 驗證的 Blueprint。
48
+ - **規劃**:把 Blueprint 節點與 acceptance id 對應到目標 repository,不修改檔案。
49
+ - **實作**:修改目標 repository,直到符合 Blueprint 與所有驗收條件。
50
+ - **審查**:比較既有實作與 Blueprint,依嚴重程度回報不一致之處。
51
+
52
+ ## 必須遵守的流程
53
+
54
+ 1. 讀取目標 repository 的規則,包括適用的 `AGENTS.md`、`CLAUDE.md` 與 `.github/copilot-instructions.md`。
55
+ 2. 檢查既有 route、元件、design token、依賴、測試與實作慣例。
56
+ 3. 驗證 Blueprint 後才能依賴其內容。
57
+ 4. 將每個 Blueprint node id 對應到既有或新建的實作元件。
58
+ 若 `aub.registry.json` 宣告了符合的 production implementation,必須先重用其中的
59
+ module、export、source 與 prop mapping,再考慮新建元件。
60
+ 5. 保留階層、語意元件類型、layout mode、各 viewport 幾何、互動、響應式規則、狀態與限制。
61
+ 6. 只要符合合約,應優先使用 repository 既有元件與 token。
62
+ 7. 執行涵蓋所有修改面的檢查。
63
+ 8. 完成 implementation report,提供每個節點的檔案對應,以及每個 acceptance id 的證據。
64
+
65
+ ## 不可妥協的規則
66
+
67
+ - `*.ui.json` 是唯一真實來源;Markdown 與截圖不得覆蓋它。
68
+ - 不得自行重新設計、降低驗收條件,或用偏好的模式取代已宣告的行為。
69
+ - 不得猜測缺少的產品行為。應記錄不確定性;若會實質影響結果,再詢問使用者。
70
+ - 除非 Blueprint 或使用者核准的衝突解法要求,不得任意互換 `auto` 與 `freeform` layout。
71
+ - 必須保留 accessible name、focus 行為、最小操作尺寸與響應式 overflow 限制。
72
+ - 必須明確回報阻塞。部分完成不得宣稱為全部完成。
73
+
74
+ ## 完成時的回覆
75
+
76
+ 使用使用者的語言回覆,並包含:
77
+
78
+ 1. 已實作或已審查的內容。
79
+ 2. 修改或檢查過的檔案。
80
+ 3. 驗證命令與精確結果。
81
+ 4. 每個 acceptance id 的 `pass`、`fail` 或 `needs-review`,以及具體證據。
82
+ 5. 尚未解決的決策、衝突或阻塞。
83
+ 6. 若任務是實作或審查,附上完成的 `implementation-report.json`。
84
+
85
+ 只有在報告已對應所有節點、所有必要驗收條件都有通過證據,且沒有未解決阻塞時,才能視為完成。
@@ -0,0 +1,86 @@
1
+ # Template Authoring for Existing Projects
2
+
3
+ This guide is for coding agents that scan an existing application and produce
4
+ AUB workspace templates.
5
+
6
+ ## Contract
7
+
8
+ Agents must treat AUB as a semantic contract system, not a screenshot copier.
9
+ When scanning an app:
10
+
11
+ 1. Inspect routes, layouts, reusable components, design tokens, and project
12
+ conventions before generating a template.
13
+ 2. Use core AUB component types when the meaning is clear.
14
+ 3. Put project-specific components in `.aub/component-candidates.json`.
15
+ 4. Never write a scanned component directly into `aub.registry.json`.
16
+ 5. Generate `.aub/templates/<slug>.aub.template.json` with source references,
17
+ confidence, and `status: "candidate"` unless a human has already approved it.
18
+
19
+ ## Workspace Template Shape
20
+
21
+ ```json
22
+ {
23
+ "format": "aub-workspace-template",
24
+ "format_version": "0.1.0",
25
+ "id": "settings",
26
+ "name": "Settings",
27
+ "category": "workspace",
28
+ "framework": "react",
29
+ "source": {
30
+ "kind": "route",
31
+ "path": "src/pages/settings.tsx",
32
+ "route": "/settings"
33
+ },
34
+ "blueprint": {
35
+ "version": "0.3.0"
36
+ },
37
+ "registryRefs": ["app:settings_panel"],
38
+ "confidence": 0.72,
39
+ "status": "candidate"
40
+ }
41
+ ```
42
+
43
+ The embedded `blueprint` must be a complete, schema-valid `.ui.json` document.
44
+
45
+ ## Component Candidates
46
+
47
+ Scanned custom components belong in `.aub/component-candidates.json`:
48
+
49
+ ```json
50
+ {
51
+ "format": "aub-component-candidates",
52
+ "format_version": "0.1.0",
53
+ "candidates": [{
54
+ "id": "src-components-insight-card-insight_card",
55
+ "status": "candidate",
56
+ "sourcePath": "src/components/InsightCard.tsx",
57
+ "framework": "react",
58
+ "componentName": "InsightCard",
59
+ "suggestedType": "app:insight_card",
60
+ "suggestedCoreType": "card",
61
+ "isContainer": true,
62
+ "props": ["title"],
63
+ "usageCount": 3,
64
+ "confidence": 0.72,
65
+ "reason": "Static scan found a reusable project component."
66
+ }]
67
+ }
68
+ ```
69
+
70
+ Users review each candidate in the editor:
71
+
72
+ - **Map core** records that the project component should be represented by an
73
+ existing AUB core type.
74
+ - **Create extension** writes a namespaced component entry to `aub.registry.json`.
75
+ - **Ignore** leaves the component out of the registry.
76
+
77
+ ## MCP Workflow
78
+
79
+ 1. `scan_project_ui` writes `.aub/component-candidates.json`.
80
+ 2. `generate_template_from_source` writes a candidate workspace template.
81
+ 3. The user opens the template in the AUB editor and reviews component
82
+ candidates.
83
+ 4. The editor saves the reviewed Blueprint with `write_blueprint` and updates
84
+ `.aub/session.json` with `update_aub_session`.
85
+ 5. The implementation agent reads `get_aub_session`, `get_blueprint`, and
86
+ `resolve_component` before changing production code.
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://henrylau1103.github.io/AUB/schema/aub-ci.schema.json",
4
+ "title": "AUB CI Configuration",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["version"],
8
+ "properties": {
9
+ "$schema": { "type": "string" },
10
+ "version": { "const": "1.0.0" },
11
+ "blueprints": {
12
+ "type": "array",
13
+ "items": { "type": "string", "minLength": 1 },
14
+ "uniqueItems": true
15
+ },
16
+ "projects": {
17
+ "type": "array",
18
+ "items": { "type": "string", "minLength": 1 },
19
+ "uniqueItems": true
20
+ },
21
+ "reports": {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["blueprint", "report"],
27
+ "properties": {
28
+ "blueprint": { "type": "string", "minLength": 1 },
29
+ "report": { "type": "string", "minLength": 1 }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://henrylau1103.github.io/AUB/schema/aub.registry.schema.json",
4
+ "title": "AUB Extension Component Registry",
5
+ "description": "Project-level registry of namespaced (team:component) custom component types and their production implementation mappings. Resolved by AUB validation and bundled into agent handoffs.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["components"],
9
+ "properties": {
10
+ "$schema": { "type": "string" },
11
+ "version": {
12
+ "type": "string",
13
+ "description": "Optional registry document version (SemVer recommended)."
14
+ },
15
+ "description": { "type": "string" },
16
+ "components": {
17
+ "type": "array",
18
+ "description": "Custom component type declarations.",
19
+ "items": { "$ref": "#/$defs/extensionComponent" }
20
+ }
21
+ },
22
+ "$defs": {
23
+ "extensionComponent": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["name", "isContainer"],
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "pattern": "^[a-z][a-z0-9]*:[a-z][a-z0-9_]*$",
31
+ "description": "Namespaced type, team:component (e.g. acme:data_card). Must not collide with a core type."
32
+ },
33
+ "isContainer": {
34
+ "type": "boolean",
35
+ "description": "true if the component may declare children; false for a leaf."
36
+ },
37
+ "description": {
38
+ "type": "string",
39
+ "description": "What the component is — agents read this to resolve the type without guessing."
40
+ },
41
+ "implementations": {
42
+ "type": "array",
43
+ "description": "Production component mappings. Agents should reuse these implementations instead of recreating the component.",
44
+ "items": { "$ref": "#/$defs/componentImplementation" },
45
+ "minItems": 1
46
+ }
47
+ }
48
+ },
49
+ "componentImplementation": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["id", "framework", "module"],
53
+ "properties": {
54
+ "id": {
55
+ "type": "string",
56
+ "pattern": "^[a-z][a-z0-9_-]*$",
57
+ "description": "Stable mapping id, for example react or angular."
58
+ },
59
+ "framework": {
60
+ "enum": ["react", "vue", "angular", "svelte", "web-component", "html", "other"]
61
+ },
62
+ "module": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "description": "Package or module specifier used by the target repository."
66
+ },
67
+ "export": {
68
+ "type": "string",
69
+ "minLength": 1,
70
+ "description": "Exported component symbol. Omit for a default export or custom element."
71
+ },
72
+ "importStyle": {
73
+ "enum": ["named", "default", "namespace", "side-effect", "custom-element"],
74
+ "default": "named"
75
+ },
76
+ "sourcePath": {
77
+ "type": "string",
78
+ "minLength": 1,
79
+ "description": "Optional repository-relative source file for code navigation."
80
+ },
81
+ "storybookUrl": {
82
+ "type": "string",
83
+ "format": "uri"
84
+ },
85
+ "docsUrl": {
86
+ "type": "string",
87
+ "format": "uri"
88
+ },
89
+ "props": {
90
+ "type": "object",
91
+ "description": "Map production prop names to Blueprint data paths.",
92
+ "propertyNames": {
93
+ "pattern": "^[A-Za-z_$][A-Za-z0-9_$.-]*$"
94
+ },
95
+ "additionalProperties": { "$ref": "#/$defs/propMapping" }
96
+ },
97
+ "notes": {
98
+ "type": "string",
99
+ "description": "Implementation constraints that the coding agent must preserve."
100
+ }
101
+ }
102
+ },
103
+ "propMapping": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "required": ["from"],
107
+ "properties": {
108
+ "from": {
109
+ "type": "string",
110
+ "minLength": 1,
111
+ "description": "Blueprint data path such as content.title, bindings.value, states.loading, or literal:compact."
112
+ },
113
+ "required": { "type": "boolean" },
114
+ "description": { "type": "string" }
115
+ }
116
+ }
117
+ }
118
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/HenryLau1103/AUB/schema/1.0.0/design-bridge.schema.json",
4
+ "title": "AUB Design Bridge",
5
+ "description": "Vendor-neutral envelope for moving an explicitly authored semantic UI Blueprint from Figma or Penpot into AUB without inferring component meaning.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["format", "version", "source", "blueprint", "node_map"],
9
+ "properties": {
10
+ "$schema": { "type": "string" },
11
+ "format": { "const": "aub-design-bridge" },
12
+ "version": { "const": "1.0.0" },
13
+ "source": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": ["kind", "document_id", "frame_id"],
17
+ "properties": {
18
+ "kind": { "type": "string", "enum": ["figma", "penpot"] },
19
+ "document_id": { "type": "string", "minLength": 1 },
20
+ "page_id": { "type": "string", "minLength": 1 },
21
+ "frame_id": { "type": "string", "minLength": 1 },
22
+ "url": { "type": "string", "format": "uri" },
23
+ "exported_at": { "type": "string", "format": "date-time" }
24
+ }
25
+ },
26
+ "blueprint": {
27
+ "$ref": "https://github.com/HenryLau1103/AUB/schema/0.3.0/ui-blueprint.schema.json"
28
+ },
29
+ "node_map": {
30
+ "type": "object",
31
+ "minProperties": 1,
32
+ "additionalProperties": {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "required": ["source_id"],
36
+ "properties": {
37
+ "source_id": { "type": "string", "minLength": 1 },
38
+ "source_name": { "type": "string" },
39
+ "component_key": { "type": "string" }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }