Commit 997fd13f by liimin

fix(ai): 解决AI执行流程中provider请求挂起问题

- 诊断并确认大请求负载导致provider响应缓慢的问题
- 优化请求负载大小从219KB压缩至30KB以避免挂起
- 添加调试工具和环境配置用于追踪provider响应状态
- 更新执行结果记录以支持失败状态和修复轮次跟踪
- 添加截图摘要文件到上下文束以改进调试信息
- 修复命令完成但无响应日志输出的超时处理逻辑
1 parent da744985
Showing 25 changed files with 1346 additions and 272 deletions
DEBUG_SERVER_URL=http://127.0.0.1:7777/event
DEBUG_SESSION_ID=provider-hang
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"meta": { "meta": {
"generator": "scripts/ai-direct-context.mjs", "generator": "scripts/ai-direct-context.mjs",
"mode": "ai-direct", "mode": "ai-direct",
"generatedAt": "2026-06-01T12:26:59.210Z", "generatedAt": "2026-06-02T00:47:26.933Z",
"repoRoot": "D:/work/venus" "repoRoot": "D:/work/venus"
}, },
"figma": { "figma": {
...@@ -1464,6 +1464,7 @@ ...@@ -1464,6 +1464,7 @@
"designContextFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.design-context.html", "designContextFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.design-context.html",
"variableDefsFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.variable-defs.json", "variableDefsFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.variable-defs.json",
"screenshotFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.screenshot.png", "screenshotFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.screenshot.png",
"screenshotSummaryFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.screenshot-summary.json",
"promptFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.prompt.md" "promptFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.prompt.md"
} }
} }
{ {
"meta": { "meta": {
"generator": "scripts/ai-direct-execute.mjs", "generator": "scripts/ai-direct-execute.mjs",
"generatedAt": "2026-06-01T13:07:17.948Z", "generatedAt": "2026-06-02T04:30:31.599Z",
"mode": "openai-compatible", "mode": "openai-compatible",
"bundleFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json", "bundleFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json",
"previewFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json", "previewFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json",
"responseFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json", "responseFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json",
"validationFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.validation-result.json" "validationFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.validation-result.json"
}, },
"status": "passed", "status": "failed",
"repairRoundsAttempted": 0 "repairRoundsAttempted": 1,
"repairArtifacts": {
"feedbackFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.repair-feedback.json",
"requestFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.repair-request.md"
}
} }
{ {
"meta": { "meta": {
"generator": "scripts/ai-direct-preview-project.mjs", "generator": "scripts/ai-direct-preview-project.mjs",
"generatedAt": "2026-06-01T13:01:06.795Z", "generatedAt": "2026-06-02T04:27:13.503Z",
"mode": "reuse-existing", "mode": "reuse-existing",
"bundleFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json" "bundleFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json"
}, },
"previewProject": { "previewProject": {
"name": "allocationmanagement-qwen-autofix", "name": "allocationmanagement-qwen-autofix",
"projectRoot": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix", "projectRoot": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix",
"template": "vue", "template": "vue",
"ui": "element-plus", "ui": "element-plus",
"install": false, "install": false,
......
{ {
"meta": { "meta": {
"generator": "scripts/ai-direct-apply-output.mjs", "generator": "scripts/ai-direct-apply-output.mjs",
"generatedAt": "2026-06-01T13:05:34.471Z", "generatedAt": "2026-06-02T04:31:58.209Z",
"responseFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json", "responseFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json",
"previewFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json" "previewFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json"
}, },
"result": { "result": {
"projectRoot": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix", "projectRoot": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix",
"writtenFiles": [ "writtenFiles": [
{ {
"path": "apps/web/ai-previews/allocationmanagement-qwen-autofix/src/views/AllocationManagement.vue", "path": "apps/web/ai-previews/allocationmanagement-qwen-autofix/src/views/AllocationManagement.vue",
"language": "vue", "language": "vue",
"purpose": "调拨管理页面主视图" "purpose": "调拨管理页面主视图,包含筛选、搜索、表格和分页功能"
} }
], ],
"autoFixResults": [ "autoFixResults": [
...@@ -35,12 +35,13 @@ ...@@ -35,12 +35,13 @@
"dependencyPlan": { "dependencyPlan": {
"needsDependencyChange": false, "needsDependencyChange": false,
"packages": [], "packages": [],
"reason": "所需组件 @vui/vue 和 element-plus 均已在项目中安装。" "reason": "所有使用的组件均来自项目已安装的 @vui/vue 和 element-plus,无需新增依赖。"
}, },
"notes": [ "notes": [
"VUI 组件 VSelect 和 VInput 优先使用,分页组件因 VUI 未提供而降级使用 element-plus 的 ElPagination。", "为所有 ref 变量显式添加了泛型类型声明(如 ref<string>),确保 TypeScript 类型推断准确,解决搜索字段类型初始化警告。",
"表格多行文本通过 CSS white-space: pre-line 实现,以还原 Figma 中的换行效果。", "通过为 .allocation-management、.table-section 和 .data-table 添加 width: 100% 及 !important 确保表格横向铺满容器。",
"严格遵循多行标签首属性与标签名同行的 lint 规则。" "使用更全面的 :deep() 选择器并添加 !important 强制覆盖表头背景色为 #f4f6fc。",
"在 .pagination-section 和 :deep(.el-pagination) 上强制设置 justify-content: flex-start !important 确保分页器左对齐。"
], ],
"validationChecklist": [ "validationChecklist": [
"通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。", "通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。",
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
"未绕过项目现有路由、目录和命名约定。", "未绕过项目现有路由、目录和命名约定。",
"优先满足 VUI 第一顺位与按框架降级的规则。", "优先满足 VUI 第一顺位与按框架降级的规则。",
"预览项目基于 Venus CLI 生成的项目结构。", "预览项目基于 Venus CLI 生成的项目结构。",
"预览页面不依赖模板演示壳层样式,生成文件本身包含可运行的页面结构与样式。" "预览页面自带完整容器、间距、尺寸和必要样式,不依赖模板演示壳层。"
] ]
} }
} }
{ {
"summary": "生成调拨管理页面,包含筛选表单、列表头部、数据表格和分页组件。优先使用 @vui/vue 组件,分页降级使用 element-plus。", "summary": "修复了调拨管理页面的样式和类型问题。确保表格横向铺满容器,表头具有浅灰背景色,分页器左对齐,并为搜索字段及其他表单字段显式指定了 string 类型初始化。",
"dependencyPlan": { "dependencyPlan": {
"needsDependencyChange": false, "needsDependencyChange": false,
"packages": [], "packages": [],
"reason": "所需组件 @vui/vue 和 element-plus 均已在项目中安装。" "reason": "所有使用的组件均来自项目已安装的 @vui/vue 和 element-plus,无需新增依赖。"
}, },
"previewProject": { "previewProject": {
"mustUseVenusCli": true, "mustUseVenusCli": true,
...@@ -13,14 +13,15 @@ ...@@ -13,14 +13,15 @@
{ {
"path": "src/views/AllocationManagement.vue", "path": "src/views/AllocationManagement.vue",
"language": "vue", "language": "vue",
"purpose": "调拨管理页面主视图", "purpose": "调拨管理页面主视图,包含筛选、搜索、表格和分页功能",
"content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\nconst filterForm = ref({\n\toutWarehouse: \"\",\n\toutStore: \"\",\n\tinWarehouse: \"\",\n\tinStore: \"\",\n\tkeyword: \"\"\n});\n\nconst currentPage = ref(1);\nconst pageSize = ref(10);\n\nconst columns: Array<{\n\tkey: string;\n\tlabel: string;\n\twidth?: number | string;\n\talign?: \"left\" | \"center\" | \"right\";\n}> = [\n\t{ key: \"index\", label: \"序号\", width: 80, align: \"center\" },\n\t{ key: \"name\", label: \"商品名称\", width: 180 },\n\t{ key: \"spec\", label: \"规格\", width: 120 },\n\t{ key: \"code\", label: \"商品编码\", width: 150 },\n\t{ key: \"series\", label: \"系列\", width: 150 },\n\t{ key: \"category\", label: \"所属分类\", width: 120 },\n\t{ key: \"warehouse\", label: \"所属仓库\", width: 180 },\n\t{ key: \"store\", label: \"所属门店\", width: 180 },\n\t{ key: \"rollNo\", label: \"膜卷号\", width: 150 },\n\t{ key: \"actions\", label: \"操作\", width: 100, align: \"center\" }\n];\n\nconst tableData = Array.from({ length: 10 }).map((_, i) => ({\n\tid: i + 1,\n\tindex: i + 1,\n\tname: \"商品名称商品名称\\n商品名称\",\n\tspec: i % 2 === 0 ? \"A/B\" : \"灰色/中/muji\",\n\tcode: i % 3 === 0 ? \"12345678...\" : \"JC-JP-0077\",\n\tseries: \"太阳膜多规格\\n商品\",\n\tcategory: i % 2 === 0 ? \"太阳膜\" : \"自建商品\\n-精品\",\n\twarehouse: \"园区园区园区园区\\n园区园区\",\n\tstore: \"门店门店门店门店\\n门店\",\n\trollNo: i % 2 === 0 ? \"1234,5678...\" : \"JC-JP-0077\"\n}));\n\nconst handleSearch = () => {\n\tconsole.log(\"search\", filterForm.value);\n};\n\nconst handleSelect = (row: Record<string, unknown>) => {\n\tconsole.log(\"select\", row);\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"row-label\">调出方:</span>\n\t\t\t\t<div class=\"field-group\">\n\t\t\t\t\t<span class=\"field-label\"><span class=\"required\">*</span>调出仓库:</span>\n\t\t\t\t\t<VSelect v-model=\"filterForm.outWarehouse\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclass=\"custom-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"field-group\">\n\t\t\t\t\t<span class=\"field-label\"><span class=\"required\">*</span>调出门店:</span>\n\t\t\t\t\t<VSelect v-model=\"filterForm.outStore\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclass=\"custom-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"row-label\">调入方:</span>\n\t\t\t\t<div class=\"field-group\">\n\t\t\t\t\t<span class=\"field-label\"><span class=\"required\">*</span>调入仓库:</span>\n\t\t\t\t\t<VSelect v-model=\"filterForm.inWarehouse\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclass=\"custom-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"field-group\">\n\t\t\t\t\t<span class=\"field-label\"><span class=\"required\">*</span>调入门店:</span>\n\t\t\t\t\t<VSelect v-model=\"filterForm.inStore\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclass=\"custom-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-header\">\n\t\t\t<h3 class=\"table-title\">调拨列表</h3>\n\t\t\t<div class=\"table-actions\">\n\t\t\t\t<VInput v-model=\"filterForm.keyword\"\n\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\tclass=\"search-input\"\n\t\t\t\t>\n\t\t\t\t\t<template #prepend>\n\t\t\t\t\t\t<span class=\"prepend-text\">调拨:</span>\n\t\t\t\t\t</template>\n\t\t\t\t</VInput>\n\t\t\t\t<VButton type=\"primary\" @click=\"handleSearch\">查询</VButton>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<VTable :data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"id\"\n\t\t\t\tclass=\"custom-table\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<a class=\"action-link\" @click=\"handleSelect(row)\">选择</a>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\t\t</div>\n\n\t\t<div class=\"pagination-section\">\n\t\t\t<ElPagination v-model:current-page=\"currentPage\"\n\t\t\t\tv-model:page-size=\"pageSize\"\n\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t:total=\"800\"\n\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t/>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tpadding: 20px;\n\tbackground-color: #ffffff;\n\tfont-family: \"HarmonyOS Sans SC\", \"PingFang SC\", sans-serif;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.row-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.field-group {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tflex: 1;\n\tmax-width: 300px;\n}\n\n.field-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tmargin-right: 2px;\n}\n\n.custom-select {\n\tflex: 1;\n}\n\n.table-header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tmargin-top: 4px;\n}\n\n.table-title {\n\tcolor: #333333;\n\tfont-size: 16px;\n\tfont-weight: 500;\n\tline-height: 19px;\n\tmargin: 0;\n}\n\n.table-actions {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-input {\n\twidth: 280px;\n}\n\n.prepend-text {\n\tcolor: #333333;\n\tfont-size: 14px;\n}\n\n.table-section {\n\tmargin-top: 10px;\n}\n\n.custom-table {\n\tborder: 1px solid #e5e5e5;\n\tborder-radius: 4px;\n\toverflow: hidden;\n}\n\n:deep(.el-table th.el-table__cell) {\n\tbackground-color: #f4f6fc;\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 500;\n\tborder-bottom: 1px solid #e5e5e5;\n}\n\n:deep(.el-table td.el-table__cell) {\n\tcolor: #666666;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tborder-bottom: 1px solid #e5e5e5;\n}\n\n:deep(.el-table .cell) {\n\twhite-space: pre-line;\n\tline-height: 16px;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tfont-size: 14px;\n\tcursor: pointer;\n\ttext-decoration: none;\n}\n\n.action-link:hover {\n\ttext-decoration: underline;\n}\n\n.pagination-section {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\tmargin-top: 16px;\n}\n\n:deep(.el-pagination) {\n\t--el-pagination-button-bg-color: #ffffff;\n\t--el-pagination-hover-color: #5850ff;\n}\n\n:deep(.el-pagination .el-pager li) {\n\tbackground-color: #ffffff;\n\tborder: 1px solid #e8e8ea;\n\tborder-radius: 2px;\n\tcolor: #666666;\n\tfont-size: 12px;\n\tmin-width: 24px;\n\theight: 24px;\n\tline-height: 24px;\n\tmargin: 0 4px;\n}\n\n:deep(.el-pagination .el-pager li.is-active) {\n\tbackground-color: #5850ff;\n\tborder-color: #5850ff;\n\tcolor: #ffffff;\n}\n\n:deep(.el-pagination button.btn-prev),\n:deep(.el-pagination button.btn-next) {\n\tbackground-color: #ffffff;\n\tborder: 1px solid #e8e8ea;\n\tborder-radius: 2px;\n\tcolor: #999999;\n\tmin-width: 24px;\n\theight: 24px;\n}\n\n:deep(.el-pagination .el-pagination__sizes .el-input__wrapper) {\n\tborder: 1px solid #dcdfe5;\n\tborder-radius: 3px;\n\tbox-shadow: none;\n}\n</style>" "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\ninterface TableRow {\n\tindex: number;\n\tname: string;\n\tspec: string;\n\tcode: string;\n\tseries: string;\n\tcategory: string;\n\twarehouse: string;\n\tstore: string;\n\trollNo: string;\n}\n\nconst outWarehouse = ref<string>(\"\");\nconst outStore = ref<string>(\"\");\nconst inWarehouse = ref<string>(\"\");\nconst inStore = ref<string>(\"\");\nconst searchText = ref<string>(\"\");\n\nconst currentPage = ref<number>(1);\nconst pageSize = ref<number>(10);\nconst total = ref<number>(8);\n\nconst warehouseOptions = [\n\t{ label: \"仓库A\", value: \"1\" },\n\t{ label: \"仓库B\", value: \"2\" }\n];\n\nconst storeOptions = [\n\t{ label: \"门店A\", value: \"1\" },\n\t{ label: \"门店B\", value: \"2\" }\n];\n\nconst columns = [\n\t{ key: \"index\", label: \"序号\", width: 60, align: \"center\" as const },\n\t{ key: \"name\", label: \"商品名称\", align: \"left\" as const },\n\t{ key: \"spec\", label: \"规格\", align: \"left\" as const },\n\t{ key: \"code\", label: \"商品编码\", align: \"left\" as const },\n\t{ key: \"series\", label: \"系列\", align: \"left\" as const },\n\t{ key: \"category\", label: \"所属分类\", align: \"left\" as const },\n\t{ key: \"warehouse\", label: \"所属仓库\", align: \"left\" as const },\n\t{ key: \"store\", label: \"所属门店\", align: \"left\" as const },\n\t{ key: \"rollNo\", label: \"膜卷号\", align: \"left\" as const },\n\t{ key: \"actions\", label: \"操作\", width: 100, align: \"center\" as const }\n];\n\nconst tableData = ref<TableRow[]>([\n\t{ index: 1, name: \"商品A\", spec: \"100x100\", code: \"C001\", series: \"系列1\", category: \"分类1\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R001\" },\n\t{ index: 2, name: \"商品B\", spec: \"200x200\", code: \"C002\", series: \"系列2\", category: \"分类2\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R002\" },\n\t{ index: 3, name: \"商品C\", spec: \"300x300\", code: \"C003\", series: \"系列3\", category: \"分类3\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R003\" },\n\t{ index: 4, name: \"商品D\", spec: \"400x400\", code: \"C004\", series: \"系列4\", category: \"分类4\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R004\" },\n\t{ index: 5, name: \"商品E\", spec: \"500x500\", code: \"C005\", series: \"系列5\", category: \"分类5\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R005\" },\n\t{ index: 6, name: \"商品F\", spec: \"600x600\", code: \"C006\", series: \"系列6\", category: \"分类6\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R006\" },\n\t{ index: 7, name: \"商品G\", spec: \"700x700\", code: \"C007\", series: \"系列7\", category: \"分类7\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R007\" },\n\t{ index: 8, name: \"商品H\", spec: \"800x800\", code: \"C008\", series: \"系列8\", category: \"分类8\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R008\" }\n]);\n\nconst handleSearch = () => {\n\t// search logic\n};\n\nconst handleSelect = (row: TableRow) => {\n\t// select logic\n\tconsole.log(row);\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调出方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调入方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"toolbar-section\">\n\t\t\t<div class=\"toolbar-title\">调拨列表</div>\n\t\t\t<div class=\"toolbar-search\">\n\t\t\t\t<span class=\"search-label\">调拨:</span>\n\t\t\t\t<VInput\n\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\tclass=\"search-input\"\n\t\t\t\t/>\n\t\t\t\t<VButton\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleSearch\"\n\t\t\t\t>\n\t\t\t\t\t查询\n\t\t\t\t</VButton>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<VTable\n\t\t\t\t:data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"index\"\n\t\t\t\tclass=\"data-table\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<a\n\t\t\t\t\t\tclass=\"action-link\"\n\t\t\t\t\t\t@click=\"handleSelect(row)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t选择\n\t\t\t\t\t</a>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\t\t</div>\n\n\t\t<div class=\"pagination-section\">\n\t\t\t<ElPagination\n\t\t\t\tv-model:current-page=\"currentPage\"\n\t\t\t\tv-model:page-size=\"pageSize\"\n\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t:total=\"total\"\n\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t\tclass=\"pagination\"\n\t\t\t/>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tpadding: 20px;\n\tbackground: #ffffff;\n\tfont-family: \"HarmonyOS Sans SC\", sans-serif;\n\twidth: 100%;\n\tbox-sizing: border-box;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.filter-group-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tfont-size: 14px;\n}\n\n.item-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-select {\n\twidth: 200px;\n}\n\n.toolbar-section {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tmargin-top: 4px;\n}\n\n.toolbar-title {\n\tcolor: #333333;\n\tfont-size: 16px;\n\tfont-weight: 500;\n}\n\n.toolbar-search {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\twhite-space: nowrap;\n}\n\n.search-input {\n\twidth: 240px;\n}\n\n.table-section {\n\twidth: 100%;\n\toverflow: hidden;\n}\n\n.data-table {\n\twidth: 100% !important;\n}\n\n:deep(.el-table th.el-table__cell),\n:deep(.v-table-header),\n:deep(table th),\n:deep(.el-table__header th) {\n\tbackground-color: #f4f6fc !important;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tcursor: pointer;\n\tfont-size: 14px;\n\ttext-decoration: none;\n}\n\n.action-link:hover {\n\ttext-decoration: underline;\n}\n\n.pagination-section {\n\tdisplay: flex;\n\tjustify-content: flex-start !important;\n\tmargin-top: 8px;\n\twidth: 100%;\n}\n\n:deep(.el-pagination) {\n\tjustify-content: flex-start !important;\n}\n\n:deep(.el-pager li.is-active) {\n\tbackground-color: #5850ff;\n\tcolor: #ffffff;\n\tborder-radius: 2px;\n}\n</style>"
} }
], ],
"notes": [ "notes": [
"VUI 组件 VSelect 和 VInput 优先使用,分页组件因 VUI 未提供而降级使用 element-plus 的 ElPagination。", "为所有 ref 变量显式添加了泛型类型声明(如 ref<string>),确保 TypeScript 类型推断准确,解决搜索字段类型初始化警告。",
"表格多行文本通过 CSS white-space: pre-line 实现,以还原 Figma 中的换行效果。", "通过为 .allocation-management、.table-section 和 .data-table 添加 width: 100% 及 !important 确保表格横向铺满容器。",
"严格遵循多行标签首属性与标签名同行的 lint 规则。" "使用更全面的 :deep() 选择器并添加 !important 强制覆盖表头背景色为 #f4f6fc。",
"在 .pagination-section 和 :deep(.el-pagination) 上强制设置 justify-content: flex-start !important 确保分页器左对齐。"
], ],
"validationChecklist": [ "validationChecklist": [
"通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。", "通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。",
...@@ -28,6 +29,6 @@ ...@@ -28,6 +29,6 @@
"未绕过项目现有路由、目录和命名约定。", "未绕过项目现有路由、目录和命名约定。",
"优先满足 VUI 第一顺位与按框架降级的规则。", "优先满足 VUI 第一顺位与按框架降级的规则。",
"预览项目基于 Venus CLI 生成的项目结构。", "预览项目基于 Venus CLI 生成的项目结构。",
"预览页面不依赖模板演示壳层样式,生成文件本身包含可运行的页面结构与样式。" "预览页面自带完整容器、间距、尺寸和必要样式,不依赖模板演示壳层。"
] ]
} }
{ {
"meta": { "meta": {
"generator": "scripts/ai-direct-execute.mjs", "generator": "scripts/ai-direct-execute.mjs",
"generatedAt": "2026-06-01T12:01:32.435Z", "generatedAt": "2026-06-02T04:32:28.679Z",
"bundleFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json", "bundleFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json",
"previewFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json", "previewFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json",
"responseFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json" "responseFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json"
}, },
"status": "failed", "status": "failed",
"ruleErrors": [], "ruleErrors": [],
"ruleWarnings": [], "ruleWarnings": [],
"failedCommands": [ "styleErrors": [],
{ "styleWarnings": [],
"command": "pnpm run type-check", "primaryDataErrors": [
"exitCode": 2, "src/views/AllocationManagement.vue: Figma 原始数据要求表格横向铺满容器,当前未检测到完整的满宽表格样式",
"stdout": "\n> @venus/allocationmanagement-qwen-autofix@1.0.0 type-check D:\\work\\venus\\apps\\web\\ai-previews\\allocationmanagement-qwen-autofix\n> vue-tsc --noEmit\n\nsrc/views/AllocationManagement.vue(139,22): error TS2322: Type '({ key: string; label: string; width: number; align: string; } | { key: string; label: string; width: number; align?: undefined; })[]' is not assignable to type '{ align?: \"center\" | \"left\" | \"right\" | undefined; key: string; label: string; width?: string | number | undefined; }[]'.\r\n Type '{ key: string; label: string; width: number; align: string; } | { key: string; label: string; width: number; align?: undefined; }' is not assignable to type '{ align?: \"center\" | \"left\" | \"right\" | undefined; key: string; label: string; width?: string | number | undefined; }'.\r\n Type '{ key: string; label: string; width: number; align: string; }' is not assignable to type '{ align?: \"center\" | \"left\" | \"right\" | undefined; key: string; label: string; width?: string | number | undefined; }'.\r\n Types of property 'align' are incompatible.\r\n Type 'string' is not assignable to type '\"center\" | \"left\" | \"right\" | undefined'.\r\n ELIFECYCLE  Command failed with exit code 2.\n", "src/views/AllocationManagement.vue: Figma 原始数据要求分页器左对齐,当前未检测到 justify-content: flex-start"
"stderr": "",
"skipped": false,
"reason": ""
}
], ],
"primaryDataWarnings": [
"src/views/AllocationManagement.vue: 未明确检测到搜索字段使用 string 类型初始化,建议保持文本输入绑定到单值字符串字段"
],
"visualSummaryErrors": [],
"visualSummaryWarnings": [],
"failedCommands": [],
"originalResponse": { "originalResponse": {
"summary": "生成调拨管理页面,包含筛选表单、数据表格和分页组件。优先使用 @vui/vue 组件,分页降级使用 element-plus。", "summary": "修复了调拨管理页面的样式和类型问题。确保表格横向铺满容器,表头具有浅灰背景色,分页器左对齐,并为搜索字段及其他表单字段显式指定了 string 类型初始化。",
"dependencyPlan": { "dependencyPlan": {
"needsDependencyChange": false, "needsDependencyChange": false,
"packages": [], "packages": [],
"reason": "所有使用的组件均在项目已安装的 @vui/vue 和 element-plus 中。" "reason": "所有使用的组件均来自项目已安装的 @vui/vue 和 element-plus,无需新增依赖。"
}, },
"previewProject": { "previewProject": {
"mustUseVenusCli": true, "mustUseVenusCli": true,
...@@ -34,18 +36,23 @@ ...@@ -34,18 +36,23 @@
{ {
"path": "src/views/AllocationManagement.vue", "path": "src/views/AllocationManagement.vue",
"language": "vue", "language": "vue",
"purpose": "调拨管理页面主文件", "purpose": "调拨管理页面主视图,包含筛选、搜索、表格和分页功能",
"content": "<script setup lang=\"ts\">\nimport { reactive, ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\nconst form = reactive({\n\toutWarehouse: \"\",\n\toutStore: \"\",\n\tinWarehouse: \"\",\n\tinStore: \"\",\n\tkeyword: \"\"\n});\n\nconst warehouseOptions = [\n\t{ label: \"仓库A\", value: \"1\" },\n\t{ label: \"仓库B\", value: \"2\" }\n];\n\nconst storeOptions = [\n\t{ label: \"门店A\", value: \"1\" },\n\t{ label: \"门店B\", value: \"2\" }\n];\n\nconst columns = [\n\t{ key: \"index\", label: \"序号\", width: 80, align: \"center\" },\n\t{ key: \"name\", label: \"商品名称\", width: 180 },\n\t{ key: \"spec\", label: \"规格\", width: 120 },\n\t{ key: \"code\", label: \"商品编码\", width: 150 },\n\t{ key: \"series\", label: \"系列\", width: 150 },\n\t{ key: \"category\", label: \"所属分类\", width: 120 },\n\t{ key: \"warehouse\", label: \"所属仓库\", width: 150 },\n\t{ key: \"store\", label: \"所属门店\", width: 150 },\n\t{ key: \"rollNo\", label: \"膜卷号\", width: 150 }\n];\n\nconst tableData = ref(\n\tArray.from({ length: 10 }).map((_, i) => ({\n\t\tid: i + 1,\n\t\tindex: i + 1,\n\t\tname: \"商品名称商品名称\\n商品名称\",\n\t\tspec: i % 2 === 0 ? \"A/B\" : \"灰色/中/muji\",\n\t\tcode: i % 3 === 0 ? \"12345678...\" : \"JC-JP-0077\",\n\t\tseries: \"太阳膜多规格\\n商品\",\n\t\tcategory: \"太阳膜\",\n\t\twarehouse: \"园区园区园区园区\\n园区园区\",\n\t\tstore: \"门店门店门店门店\\n门店\",\n\t\trollNo: \"1234,5678...\"\n\t}))\n);\n\nconst pagination = reactive({\n\tcurrentPage: 1,\n\tpageSize: 10,\n\ttotal: 800\n});\n\nconst handleSearch = () => {\n\tconsole.log(\"search\", form);\n};\n\nconst handleSelect = (row: any) => {\n\tconsole.log(\"select\", row);\n};\n\nconst handleSizeChange = (val: number) => {\n\tpagination.pageSize = val;\n};\n\nconst handleCurrentChange = (val: number) => {\n\tpagination.currentPage = val;\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-label\">调出方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.outWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.outStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-label\">调入方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.inWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.inStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<div class=\"table-header\">\n\t\t\t\t<span class=\"table-title\">调拨列表</span>\n\t\t\t\t<div class=\"table-actions\">\n\t\t\t\t\t<div class=\"search-item\">\n\t\t\t\t\t\t<span class=\"item-label\">调拨:</span>\n\t\t\t\t\t\t<VInput\n\t\t\t\t\t\t\tv-model=\"form.keyword\"\n\t\t\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\t\t\tclearable\n\t\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<VButton type=\"primary\" @click=\"handleSearch\">\n\t\t\t\t\t\t查询\n\t\t\t\t\t</VButton>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<VTable\n\t\t\t\t:data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"id\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<span class=\"action-link\" @click=\"handleSelect(row)\">选择</span>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\n\t\t\t<div class=\"pagination-wrapper\">\n\t\t\t\t<ElPagination\n\t\t\t\t\tv-model:current-page=\"pagination.currentPage\"\n\t\t\t\t\tv-model:page-size=\"pagination.pageSize\"\n\t\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t\t:total=\"pagination.total\"\n\t\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t\t\t@size-change=\"handleSizeChange\"\n\t\t\t\t\t@current-change=\"handleCurrentChange\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tpadding: 20px;\n\tbackground: #fff;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tfont-family: \"HarmonyOS Sans SC\", \"PingFang SC\", sans-serif;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.filter-label {\n\tfont-size: 14px;\n\tcolor: #333;\n\twhite-space: nowrap;\n}\n\n.filter-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tfont-size: 14px;\n}\n\n.item-label {\n\tfont-size: 14px;\n\tcolor: #333;\n\twhite-space: nowrap;\n}\n\n.form-control {\n\twidth: 200px;\n}\n\n.table-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n}\n\n.table-header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n}\n\n.table-title {\n\tfont-size: 16px;\n\tfont-weight: 500;\n\tcolor: #333;\n}\n\n.table-actions {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tcursor: pointer;\n\tfont-size: 14px;\n}\n\n.pagination-wrapper {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\tmargin-top: 16px;\n}\n\n:deep(td) {\n\twhite-space: pre-line;\n}\n</style>" "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\ninterface TableRow {\n\tindex: number;\n\tname: string;\n\tspec: string;\n\tcode: string;\n\tseries: string;\n\tcategory: string;\n\twarehouse: string;\n\tstore: string;\n\trollNo: string;\n}\n\nconst outWarehouse = ref<string>(\"\");\nconst outStore = ref<string>(\"\");\nconst inWarehouse = ref<string>(\"\");\nconst inStore = ref<string>(\"\");\nconst searchText = ref<string>(\"\");\n\nconst currentPage = ref<number>(1);\nconst pageSize = ref<number>(10);\nconst total = ref<number>(8);\n\nconst warehouseOptions = [\n\t{ label: \"仓库A\", value: \"1\" },\n\t{ label: \"仓库B\", value: \"2\" }\n];\n\nconst storeOptions = [\n\t{ label: \"门店A\", value: \"1\" },\n\t{ label: \"门店B\", value: \"2\" }\n];\n\nconst columns = [\n\t{ key: \"index\", label: \"序号\", width: 60, align: \"center\" as const },\n\t{ key: \"name\", label: \"商品名称\", align: \"left\" as const },\n\t{ key: \"spec\", label: \"规格\", align: \"left\" as const },\n\t{ key: \"code\", label: \"商品编码\", align: \"left\" as const },\n\t{ key: \"series\", label: \"系列\", align: \"left\" as const },\n\t{ key: \"category\", label: \"所属分类\", align: \"left\" as const },\n\t{ key: \"warehouse\", label: \"所属仓库\", align: \"left\" as const },\n\t{ key: \"store\", label: \"所属门店\", align: \"left\" as const },\n\t{ key: \"rollNo\", label: \"膜卷号\", align: \"left\" as const },\n\t{ key: \"actions\", label: \"操作\", width: 100, align: \"center\" as const }\n];\n\nconst tableData = ref<TableRow[]>([\n\t{ index: 1, name: \"商品A\", spec: \"100x100\", code: \"C001\", series: \"系列1\", category: \"分类1\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R001\" },\n\t{ index: 2, name: \"商品B\", spec: \"200x200\", code: \"C002\", series: \"系列2\", category: \"分类2\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R002\" },\n\t{ index: 3, name: \"商品C\", spec: \"300x300\", code: \"C003\", series: \"系列3\", category: \"分类3\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R003\" },\n\t{ index: 4, name: \"商品D\", spec: \"400x400\", code: \"C004\", series: \"系列4\", category: \"分类4\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R004\" },\n\t{ index: 5, name: \"商品E\", spec: \"500x500\", code: \"C005\", series: \"系列5\", category: \"分类5\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R005\" },\n\t{ index: 6, name: \"商品F\", spec: \"600x600\", code: \"C006\", series: \"系列6\", category: \"分类6\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R006\" },\n\t{ index: 7, name: \"商品G\", spec: \"700x700\", code: \"C007\", series: \"系列7\", category: \"分类7\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R007\" },\n\t{ index: 8, name: \"商品H\", spec: \"800x800\", code: \"C008\", series: \"系列8\", category: \"分类8\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R008\" }\n]);\n\nconst handleSearch = () => {\n\t// search logic\n};\n\nconst handleSelect = (row: TableRow) => {\n\t// select logic\n\tconsole.log(row);\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调出方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调入方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"toolbar-section\">\n\t\t\t<div class=\"toolbar-title\">调拨列表</div>\n\t\t\t<div class=\"toolbar-search\">\n\t\t\t\t<span class=\"search-label\">调拨:</span>\n\t\t\t\t<VInput\n\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\tclass=\"search-input\"\n\t\t\t\t/>\n\t\t\t\t<VButton\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleSearch\"\n\t\t\t\t>\n\t\t\t\t\t查询\n\t\t\t\t</VButton>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<VTable\n\t\t\t\t:data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"index\"\n\t\t\t\tclass=\"data-table\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<a\n\t\t\t\t\t\tclass=\"action-link\"\n\t\t\t\t\t\t@click=\"handleSelect(row)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t选择\n\t\t\t\t\t</a>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\t\t</div>\n\n\t\t<div class=\"pagination-section\">\n\t\t\t<ElPagination\n\t\t\t\tv-model:current-page=\"currentPage\"\n\t\t\t\tv-model:page-size=\"pageSize\"\n\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t:total=\"total\"\n\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t\tclass=\"pagination\"\n\t\t\t/>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tpadding: 20px;\n\tbackground: #ffffff;\n\tfont-family: \"HarmonyOS Sans SC\", sans-serif;\n\twidth: 100%;\n\tbox-sizing: border-box;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.filter-group-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tfont-size: 14px;\n}\n\n.item-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-select {\n\twidth: 200px;\n}\n\n.toolbar-section {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tmargin-top: 4px;\n}\n\n.toolbar-title {\n\tcolor: #333333;\n\tfont-size: 16px;\n\tfont-weight: 500;\n}\n\n.toolbar-search {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\twhite-space: nowrap;\n}\n\n.search-input {\n\twidth: 240px;\n}\n\n.table-section {\n\twidth: 100%;\n\toverflow: hidden;\n}\n\n.data-table {\n\twidth: 100% !important;\n}\n\n:deep(.el-table th.el-table__cell),\n:deep(.v-table-header),\n:deep(table th),\n:deep(.el-table__header th) {\n\tbackground-color: #f4f6fc !important;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tcursor: pointer;\n\tfont-size: 14px;\n\ttext-decoration: none;\n}\n\n.action-link:hover {\n\ttext-decoration: underline;\n}\n\n.pagination-section {\n\tdisplay: flex;\n\tjustify-content: flex-start !important;\n\tmargin-top: 8px;\n\twidth: 100%;\n}\n\n:deep(.el-pagination) {\n\tjustify-content: flex-start !important;\n}\n\n:deep(.el-pager li.is-active) {\n\tbackground-color: #5850ff;\n\tcolor: #ffffff;\n\tborder-radius: 2px;\n}\n</style>"
} }
], ],
"notes": [ "notes": [
"VUI 当前未提供分页组件,因此分页功能降级使用 element-plus 的 ElPagination。", "为所有 ref 变量显式添加了泛型类型声明(如 ref<string>),确保 TypeScript 类型推断准确,解决搜索字段类型初始化警告。",
"表格中的多行文本通过 CSS white-space: pre-line 实现换行效果。" "通过为 .allocation-management、.table-section 和 .data-table 添加 width: 100% 及 !important 确保表格横向铺满容器。",
"使用更全面的 :deep() 选择器并添加 !important 强制覆盖表头背景色为 #f4f6fc。",
"在 .pagination-section 和 :deep(.el-pagination) 上强制设置 justify-content: flex-start !important 确保分页器左对齐。"
], ],
"validationChecklist": [ "validationChecklist": [
"通过 lint 和 typecheck", "通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。",
"组件导入合法且符合 VUI 优先规则", "未引入项目中不存在的组件 import。",
"页面样式完整,无需额外补充" "未绕过项目现有路由、目录和命名约定。",
"优先满足 VUI 第一顺位与按框架降级的规则。",
"预览项目基于 Venus CLI 生成的项目结构。",
"预览页面自带完整容器、间距、尺寸和必要样式,不依赖模板演示壳层。"
] ]
} }
} }
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
## Fix Targets ## Fix Targets
- Command Failure: pnpm run type-check (exit=2) - Primary Data Error: src/views/AllocationManagement.vue: Figma 原始数据要求表格横向铺满容器,当前未检测到完整的满宽表格样式
- Primary Data Error: src/views/AllocationManagement.vue: Figma 原始数据要求分页器左对齐,当前未检测到 justify-content: flex-start
- Primary Data Warning: src/views/AllocationManagement.vue: 未明确检测到搜索字段使用 string 类型初始化,建议保持文本输入绑定到单值字符串字段
## Original Response ## Original Response
```json ```json
{ {
"summary": "生成调拨管理页面,包含筛选表单、数据表格和分页组件。优先使用 @vui/vue 组件,分页降级使用 element-plus。", "summary": "修复了调拨管理页面的样式和类型问题。确保表格横向铺满容器,表头具有浅灰背景色,分页器左对齐,并为搜索字段及其他表单字段显式指定了 string 类型初始化。",
"dependencyPlan": { "dependencyPlan": {
"needsDependencyChange": false, "needsDependencyChange": false,
"packages": [], "packages": [],
"reason": "所有使用的组件均在项目已安装的 @vui/vue 和 element-plus 中。" "reason": "所有使用的组件均来自项目已安装的 @vui/vue 和 element-plus,无需新增依赖。"
}, },
"previewProject": { "previewProject": {
"mustUseVenusCli": true, "mustUseVenusCli": true,
...@@ -26,18 +28,23 @@ ...@@ -26,18 +28,23 @@
{ {
"path": "src/views/AllocationManagement.vue", "path": "src/views/AllocationManagement.vue",
"language": "vue", "language": "vue",
"purpose": "调拨管理页面主文件", "purpose": "调拨管理页面主视图,包含筛选、搜索、表格和分页功能",
"content": "<script setup lang=\"ts\">\nimport { reactive, ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\nconst form = reactive({\n\toutWarehouse: \"\",\n\toutStore: \"\",\n\tinWarehouse: \"\",\n\tinStore: \"\",\n\tkeyword: \"\"\n});\n\nconst warehouseOptions = [\n\t{ label: \"仓库A\", value: \"1\" },\n\t{ label: \"仓库B\", value: \"2\" }\n];\n\nconst storeOptions = [\n\t{ label: \"门店A\", value: \"1\" },\n\t{ label: \"门店B\", value: \"2\" }\n];\n\nconst columns = [\n\t{ key: \"index\", label: \"序号\", width: 80, align: \"center\" },\n\t{ key: \"name\", label: \"商品名称\", width: 180 },\n\t{ key: \"spec\", label: \"规格\", width: 120 },\n\t{ key: \"code\", label: \"商品编码\", width: 150 },\n\t{ key: \"series\", label: \"系列\", width: 150 },\n\t{ key: \"category\", label: \"所属分类\", width: 120 },\n\t{ key: \"warehouse\", label: \"所属仓库\", width: 150 },\n\t{ key: \"store\", label: \"所属门店\", width: 150 },\n\t{ key: \"rollNo\", label: \"膜卷号\", width: 150 }\n];\n\nconst tableData = ref(\n\tArray.from({ length: 10 }).map((_, i) => ({\n\t\tid: i + 1,\n\t\tindex: i + 1,\n\t\tname: \"商品名称商品名称\\n商品名称\",\n\t\tspec: i % 2 === 0 ? \"A/B\" : \"灰色/中/muji\",\n\t\tcode: i % 3 === 0 ? \"12345678...\" : \"JC-JP-0077\",\n\t\tseries: \"太阳膜多规格\\n商品\",\n\t\tcategory: \"太阳膜\",\n\t\twarehouse: \"园区园区园区园区\\n园区园区\",\n\t\tstore: \"门店门店门店门店\\n门店\",\n\t\trollNo: \"1234,5678...\"\n\t}))\n);\n\nconst pagination = reactive({\n\tcurrentPage: 1,\n\tpageSize: 10,\n\ttotal: 800\n});\n\nconst handleSearch = () => {\n\tconsole.log(\"search\", form);\n};\n\nconst handleSelect = (row: any) => {\n\tconsole.log(\"select\", row);\n};\n\nconst handleSizeChange = (val: number) => {\n\tpagination.pageSize = val;\n};\n\nconst handleCurrentChange = (val: number) => {\n\tpagination.currentPage = val;\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-label\">调出方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.outWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.outStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-label\">调入方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.inWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"form.inStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclearable\n\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<div class=\"table-header\">\n\t\t\t\t<span class=\"table-title\">调拨列表</span>\n\t\t\t\t<div class=\"table-actions\">\n\t\t\t\t\t<div class=\"search-item\">\n\t\t\t\t\t\t<span class=\"item-label\">调拨:</span>\n\t\t\t\t\t\t<VInput\n\t\t\t\t\t\t\tv-model=\"form.keyword\"\n\t\t\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\t\t\tclearable\n\t\t\t\t\t\t\tclass=\"form-control\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<VButton type=\"primary\" @click=\"handleSearch\">\n\t\t\t\t\t\t查询\n\t\t\t\t\t</VButton>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<VTable\n\t\t\t\t:data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"id\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<span class=\"action-link\" @click=\"handleSelect(row)\">选择</span>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\n\t\t\t<div class=\"pagination-wrapper\">\n\t\t\t\t<ElPagination\n\t\t\t\t\tv-model:current-page=\"pagination.currentPage\"\n\t\t\t\t\tv-model:page-size=\"pagination.pageSize\"\n\t\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t\t:total=\"pagination.total\"\n\t\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t\t\t@size-change=\"handleSizeChange\"\n\t\t\t\t\t@current-change=\"handleCurrentChange\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tpadding: 20px;\n\tbackground: #fff;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tfont-family: \"HarmonyOS Sans SC\", \"PingFang SC\", sans-serif;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.filter-label {\n\tfont-size: 14px;\n\tcolor: #333;\n\twhite-space: nowrap;\n}\n\n.filter-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tfont-size: 14px;\n}\n\n.item-label {\n\tfont-size: 14px;\n\tcolor: #333;\n\twhite-space: nowrap;\n}\n\n.form-control {\n\twidth: 200px;\n}\n\n.table-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n}\n\n.table-header {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n}\n\n.table-title {\n\tfont-size: 16px;\n\tfont-weight: 500;\n\tcolor: #333;\n}\n\n.table-actions {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tcursor: pointer;\n\tfont-size: 14px;\n}\n\n.pagination-wrapper {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\tmargin-top: 16px;\n}\n\n:deep(td) {\n\twhite-space: pre-line;\n}\n</style>" "content": "<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\nimport { VButton, VInput, VSelect, VTable } from \"@vui/vue\";\nimport { ElPagination } from \"element-plus\";\n\ninterface TableRow {\n\tindex: number;\n\tname: string;\n\tspec: string;\n\tcode: string;\n\tseries: string;\n\tcategory: string;\n\twarehouse: string;\n\tstore: string;\n\trollNo: string;\n}\n\nconst outWarehouse = ref<string>(\"\");\nconst outStore = ref<string>(\"\");\nconst inWarehouse = ref<string>(\"\");\nconst inStore = ref<string>(\"\");\nconst searchText = ref<string>(\"\");\n\nconst currentPage = ref<number>(1);\nconst pageSize = ref<number>(10);\nconst total = ref<number>(8);\n\nconst warehouseOptions = [\n\t{ label: \"仓库A\", value: \"1\" },\n\t{ label: \"仓库B\", value: \"2\" }\n];\n\nconst storeOptions = [\n\t{ label: \"门店A\", value: \"1\" },\n\t{ label: \"门店B\", value: \"2\" }\n];\n\nconst columns = [\n\t{ key: \"index\", label: \"序号\", width: 60, align: \"center\" as const },\n\t{ key: \"name\", label: \"商品名称\", align: \"left\" as const },\n\t{ key: \"spec\", label: \"规格\", align: \"left\" as const },\n\t{ key: \"code\", label: \"商品编码\", align: \"left\" as const },\n\t{ key: \"series\", label: \"系列\", align: \"left\" as const },\n\t{ key: \"category\", label: \"所属分类\", align: \"left\" as const },\n\t{ key: \"warehouse\", label: \"所属仓库\", align: \"left\" as const },\n\t{ key: \"store\", label: \"所属门店\", align: \"left\" as const },\n\t{ key: \"rollNo\", label: \"膜卷号\", align: \"left\" as const },\n\t{ key: \"actions\", label: \"操作\", width: 100, align: \"center\" as const }\n];\n\nconst tableData = ref<TableRow[]>([\n\t{ index: 1, name: \"商品A\", spec: \"100x100\", code: \"C001\", series: \"系列1\", category: \"分类1\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R001\" },\n\t{ index: 2, name: \"商品B\", spec: \"200x200\", code: \"C002\", series: \"系列2\", category: \"分类2\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R002\" },\n\t{ index: 3, name: \"商品C\", spec: \"300x300\", code: \"C003\", series: \"系列3\", category: \"分类3\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R003\" },\n\t{ index: 4, name: \"商品D\", spec: \"400x400\", code: \"C004\", series: \"系列4\", category: \"分类4\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R004\" },\n\t{ index: 5, name: \"商品E\", spec: \"500x500\", code: \"C005\", series: \"系列5\", category: \"分类5\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R005\" },\n\t{ index: 6, name: \"商品F\", spec: \"600x600\", code: \"C006\", series: \"系列6\", category: \"分类6\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R006\" },\n\t{ index: 7, name: \"商品G\", spec: \"700x700\", code: \"C007\", series: \"系列7\", category: \"分类7\", warehouse: \"仓库A\", store: \"门店A\", rollNo: \"R007\" },\n\t{ index: 8, name: \"商品H\", spec: \"800x800\", code: \"C008\", series: \"系列8\", category: \"分类8\", warehouse: \"仓库B\", store: \"门店B\", rollNo: \"R008\" }\n]);\n\nconst handleSearch = () => {\n\t// search logic\n};\n\nconst handleSelect = (row: TableRow) => {\n\t// select logic\n\tconsole.log(row);\n};\n</script>\n\n<template>\n\t<div class=\"allocation-management\">\n\t\t<div class=\"filter-section\">\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调出方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调出门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"outStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调出门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"filter-row\">\n\t\t\t\t<span class=\"filter-group-label\">调入方:</span>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入仓库:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inWarehouse\"\n\t\t\t\t\t\t:options=\"warehouseOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入仓库\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"filter-item\">\n\t\t\t\t\t<span class=\"required\">*</span>\n\t\t\t\t\t<span class=\"item-label\">调入门店:</span>\n\t\t\t\t\t<VSelect\n\t\t\t\t\t\tv-model=\"inStore\"\n\t\t\t\t\t\t:options=\"storeOptions\"\n\t\t\t\t\t\tplaceholder=\"请选择调入门店\"\n\t\t\t\t\t\tclass=\"filter-select\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"toolbar-section\">\n\t\t\t<div class=\"toolbar-title\">调拨列表</div>\n\t\t\t<div class=\"toolbar-search\">\n\t\t\t\t<span class=\"search-label\">调拨:</span>\n\t\t\t\t<VInput\n\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\tplaceholder=\"请输入商品名称/系列\"\n\t\t\t\t\tclass=\"search-input\"\n\t\t\t\t/>\n\t\t\t\t<VButton\n\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t@click=\"handleSearch\"\n\t\t\t\t>\n\t\t\t\t\t查询\n\t\t\t\t</VButton>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"table-section\">\n\t\t\t<VTable\n\t\t\t\t:data=\"tableData\"\n\t\t\t\t:columns=\"columns\"\n\t\t\t\trow-key=\"index\"\n\t\t\t\tclass=\"data-table\"\n\t\t\t>\n\t\t\t\t<template #actions=\"{ row }\">\n\t\t\t\t\t<a\n\t\t\t\t\t\tclass=\"action-link\"\n\t\t\t\t\t\t@click=\"handleSelect(row)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t选择\n\t\t\t\t\t</a>\n\t\t\t\t</template>\n\t\t\t</VTable>\n\t\t</div>\n\n\t\t<div class=\"pagination-section\">\n\t\t\t<ElPagination\n\t\t\t\tv-model:current-page=\"currentPage\"\n\t\t\t\tv-model:page-size=\"pageSize\"\n\t\t\t\t:page-sizes=\"[10, 20, 50, 100]\"\n\t\t\t\t:total=\"total\"\n\t\t\t\tlayout=\"total, sizes, prev, pager, next, jumper\"\n\t\t\t\tclass=\"pagination\"\n\t\t\t/>\n\t\t</div>\n\t</div>\n</template>\n\n<style scoped>\n.allocation-management {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tpadding: 20px;\n\tbackground: #ffffff;\n\tfont-family: \"HarmonyOS Sans SC\", sans-serif;\n\twidth: 100%;\n\tbox-sizing: border-box;\n}\n\n.filter-section {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 20px;\n}\n\n.filter-row {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n}\n\n.filter-group-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-item {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 4px;\n}\n\n.required {\n\tcolor: #eb4e4e;\n\tfont-size: 14px;\n}\n\n.item-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\tfont-weight: 400;\n\tline-height: 16px;\n\twhite-space: nowrap;\n}\n\n.filter-select {\n\twidth: 200px;\n}\n\n.toolbar-section {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tmargin-top: 4px;\n}\n\n.toolbar-title {\n\tcolor: #333333;\n\tfont-size: 16px;\n\tfont-weight: 500;\n}\n\n.toolbar-search {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.search-label {\n\tcolor: #333333;\n\tfont-size: 14px;\n\twhite-space: nowrap;\n}\n\n.search-input {\n\twidth: 240px;\n}\n\n.table-section {\n\twidth: 100%;\n\toverflow: hidden;\n}\n\n.data-table {\n\twidth: 100% !important;\n}\n\n:deep(.el-table th.el-table__cell),\n:deep(.v-table-header),\n:deep(table th),\n:deep(.el-table__header th) {\n\tbackground-color: #f4f6fc !important;\n}\n\n.action-link {\n\tcolor: #5850ff;\n\tcursor: pointer;\n\tfont-size: 14px;\n\ttext-decoration: none;\n}\n\n.action-link:hover {\n\ttext-decoration: underline;\n}\n\n.pagination-section {\n\tdisplay: flex;\n\tjustify-content: flex-start !important;\n\tmargin-top: 8px;\n\twidth: 100%;\n}\n\n:deep(.el-pagination) {\n\tjustify-content: flex-start !important;\n}\n\n:deep(.el-pager li.is-active) {\n\tbackground-color: #5850ff;\n\tcolor: #ffffff;\n\tborder-radius: 2px;\n}\n</style>"
} }
], ],
"notes": [ "notes": [
"VUI 当前未提供分页组件,因此分页功能降级使用 element-plus 的 ElPagination。", "为所有 ref 变量显式添加了泛型类型声明(如 ref<string>),确保 TypeScript 类型推断准确,解决搜索字段类型初始化警告。",
"表格中的多行文本通过 CSS white-space: pre-line 实现换行效果。" "通过为 .allocation-management、.table-section 和 .data-table 添加 width: 100% 及 !important 确保表格横向铺满容器。",
"使用更全面的 :deep() 选择器并添加 !important 强制覆盖表头背景色为 #f4f6fc。",
"在 .pagination-section 和 :deep(.el-pagination) 上强制设置 justify-content: flex-start !important 确保分页器左对齐。"
], ],
"validationChecklist": [ "validationChecklist": [
"通过 lint 和 typecheck", "通过 lint、typecheck、template contract、review trigger 和 fitness 等根级质量门禁。",
"组件导入合法且符合 VUI 优先规则", "未引入项目中不存在的组件 import。",
"页面样式完整,无需额外补充" "未绕过项目现有路由、目录和命名约定。",
"优先满足 VUI 第一顺位与按框架降级的规则。",
"预览项目基于 Venus CLI 生成的项目结构。",
"预览页面自带完整容器、间距、尺寸和必要样式,不依赖模板演示壳层。"
] ]
} }
``` ```
...@@ -46,4 +53,7 @@ ...@@ -46,4 +53,7 @@
- 保持 previewProject.mustUseVenusCli=true。 - 保持 previewProject.mustUseVenusCli=true。
- 只修复失败项,不要引入新的 UI 包违规。 - 只修复失败项,不要引入新的 UI 包违规。
- 如果失败项来自 Figma 原始数据校验,优先保留 design context 中明确给出的标签、placeholder、列名和示例数据,不要让截图摘要覆盖这些文本事实。
- 如果失败项来自截图视觉摘要校验,优先修正标题、筛选标签、选择框数量、表格列、操作文案和分页布局,使页面与截图摘要一致。
- 如果失败项来自样式责任校验,直接在生成文件中补齐页面级样式,不要把布局或视觉修复转嫁给预览项目壳层。
- 输出完整结构化 JSON,沿用既定 response schema。 - 输出完整结构化 JSON,沿用既定 response schema。
{
"meta": {
"generator": "scripts/ai-direct-repair-output.mjs",
"generatedAt": "2026-06-02T04:32:28.663Z",
"responseFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json",
"previewFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json",
"messagesFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.messages.json",
"requestFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.repair-request.md",
"feedbackFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.repair-feedback.json",
"provider": "openai-compatible",
"model": "qwen3.7-max"
},
"status": "failed",
"validationFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.validation-result.json"
}
{ {
"meta": { "meta": {
"generator": "scripts/ai-direct-validate-output.mjs", "generator": "scripts/ai-direct-validate-output.mjs",
"generatedAt": "2026-06-01T13:07:17.910Z", "generatedAt": "2026-06-02T04:32:58.568Z",
"responseFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json", "responseFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.provider-response.json",
"previewFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json", "previewFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.preview-project.json",
"bundleFile": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json" "bundleFile": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix/.ai-direct/allocationmanagement/allocationmanagement.ai-direct-context-bundle.json"
}, },
"status": "passed", "status": "passed",
"files": [ "files": [
...@@ -18,6 +18,14 @@ ...@@ -18,6 +18,14 @@
"errors": [], "errors": [],
"warnings": [] "warnings": []
}, },
"primaryDataValidation": {
"errors": [],
"warnings": []
},
"visualSummaryValidation": {
"errors": [],
"warnings": []
},
"commandResults": [ "commandResults": [
{ {
"command": "node scripts/lint-changed.mjs \"apps/web/ai-previews/allocationmanagement-qwen-autofix/src/views/AllocationManagement.vue\"", "command": "node scripts/lint-changed.mjs \"apps/web/ai-previews/allocationmanagement-qwen-autofix/src/views/AllocationManagement.vue\"",
...@@ -45,7 +53,7 @@ ...@@ -45,7 +53,7 @@
}, },
{ {
"command": "pnpm run type-check", "command": "pnpm run type-check",
"cwd": "D:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix", "cwd": "d:/work/venus/apps/web/ai-previews/allocationmanagement-qwen-autofix",
"exitCode": 0, "exitCode": 0,
"stdout": "\n> @venus/allocationmanagement-qwen-autofix@1.0.0 type-check D:\\work\\venus\\apps\\web\\ai-previews\\allocationmanagement-qwen-autofix\n> vue-tsc --noEmit\n\n", "stdout": "\n> @venus/allocationmanagement-qwen-autofix@1.0.0 type-check D:\\work\\venus\\apps\\web\\ai-previews\\allocationmanagement-qwen-autofix\n> vue-tsc --noEmit\n\n",
"stderr": "", "stderr": "",
......
{
"layoutOrder": [
"filters",
"toolbar",
"table",
"pagination"
],
"filterGroupLabels": [
"调出方",
"调入方"
],
"requiredSelectCount": 4,
"headerTitle": "调拨列表",
"searchLabel": "调拨",
"primaryActionLabel": "查询",
"tableColumns": [
"序号",
"商品名称",
"规格",
"商品编码",
"系列",
"所属分类",
"所属仓库",
"所属门店",
"膜卷号",
"操作"
],
"actionColumnLabel": "操作",
"actionLinkLabel": "选择",
"pagination": {
"present": true,
"containerAlignment": "left",
"totalTextVisible": true,
"pageSizeSelectorVisible": true,
"jumperVisible": true,
"activePageStyle": "blue-filled"
},
"style": {
"backgroundTone": "white",
"headerTone": "light-gray",
"primaryColor": "blue"
},
"notes": []
}
1. **整体布局**:垂直分块结构,自上而下依次为:顶部筛选表单区、中部列表标题与搜索区、主体数据表格区、底部分页区。 # Screenshot Visual Summary
2. **筛选表单**:两行布局。每行左侧为文本标签(“调出方”、“调入方”),右侧并列两个带红色星号的下拉选择框(仓库、门店),下拉框宽度均等且水平对齐。
3. **列表头部**:左侧为加粗标题“调拨列表”,右侧为搜索输入框(前缀文本“调拨:”)及蓝色实心“查询”按钮,整体靠右对齐。 - layoutOrder: filters -> toolbar -> table -> pagination
4. **表格结构**:10 列宽表格。表头浅灰色背景,深灰文字。列名依次为:序号、商品名称、规格、商品编码、系列、所属分类、所属仓库、所属门店、膜卷号、操作。 - filterGroupLabels: 调出方, 调入方
5. **表格样式**:表体白色背景,行高固定,行间有极细浅灰分割线。文本左对齐,最后一列“操作”显示蓝色“选择”链接。 - requiredSelectCount: 4
6. **分页组件**:底部通栏布局。左侧显示总数“共 800 条”及“每页 10 条”下拉框;右侧为分页器,含翻页箭头、数字页码(当前页“1”为蓝色背景白字)、“跳至 [ ] 页”输入框。 - headerTitle: 调拨列表
7. **色彩规范**:主交互色为蓝色(查询按钮、当前页码、操作链接)。必填项前缀红色星号。表头背景色略深于表体白色背景。 - searchLabel: 调拨
- primaryActionLabel: 查询
- tableColumns: 序号, 商品名称, 规格, 商品编码, 系列, 所属分类, 所属仓库, 所属门店, 膜卷号, 操作
- actionColumnLabel: 操作
- actionLinkLabel: 选择
- pagination.present: true
- pagination.containerAlignment: left
- pagination.totalTextVisible: true
- pagination.pageSizeSelectorVisible: true
- pagination.jumperVisible: true
- pagination.activePageStyle: blue-filled
- style.backgroundTone: white
- style.headerTone: light-gray
- style.primaryColor: blue
...@@ -4,54 +4,69 @@ import { ref } from "vue"; ...@@ -4,54 +4,69 @@ import { ref } from "vue";
import { VButton, VInput, VSelect, VTable } from "@vui/vue"; import { VButton, VInput, VSelect, VTable } from "@vui/vue";
import { ElPagination } from "element-plus"; import { ElPagination } from "element-plus";
const filterForm = ref({ interface TableRow {
outWarehouse: "", index: number;
outStore: "", name: string;
inWarehouse: "", spec: string;
inStore: "", code: string;
keyword: "" series: string;
}); category: string;
warehouse: string;
const currentPage = ref(1); store: string;
const pageSize = ref(10); rollNo: string;
}
const columns: Array<{
align?: "center" | "left" | "right"; const outWarehouse = ref<string>("");
key: string; const outStore = ref<string>("");
label: string; const inWarehouse = ref<string>("");
width?: number | string; const inStore = ref<string>("");
}> = [ const searchText = ref<string>("");
{ key: "index", label: "序号", width: 80, align: "center" },
{ key: "name", label: "商品名称", width: 180 }, const currentPage = ref<number>(1);
{ key: "spec", label: "规格", width: 120 }, const pageSize = ref<number>(10);
{ key: "code", label: "商品编码", width: 150 }, const total = ref<number>(8);
{ key: "series", label: "系列", width: 150 },
{ key: "category", label: "所属分类", width: 120 }, const warehouseOptions = [
{ key: "warehouse", label: "所属仓库", width: 180 }, { label: "仓库A", value: "1" },
{ key: "store", label: "所属门店", width: 180 }, { label: "仓库B", value: "2" }
{ key: "rollNo", label: "膜卷号", width: 150 },
{ key: "actions", label: "操作", width: 100, align: "center" }
]; ];
const tableData = Array.from({ length: 10 }).map((_, i) => ({ const storeOptions = [
id: i + 1, { label: "门店A", value: "1" },
index: i + 1, { label: "门店B", value: "2" }
name: "商品名称商品名称\n商品名称", ];
spec: i % 2 === 0 ? "A/B" : "灰色/中/muji",
code: i % 3 === 0 ? "12345678..." : "JC-JP-0077", const columns = [
series: "太阳膜多规格\n商品", { key: "index", label: "序号", width: 60, align: "center" as const },
category: i % 2 === 0 ? "太阳膜" : "自建商品\n-精品", { key: "name", label: "商品名称", align: "left" as const },
warehouse: "园区园区园区园区\n园区园区", { key: "spec", label: "规格", align: "left" as const },
store: "门店门店门店门店\n门店", { key: "code", label: "商品编码", align: "left" as const },
rollNo: i % 2 === 0 ? "1234,5678..." : "JC-JP-0077" { key: "series", label: "系列", align: "left" as const },
})); { key: "category", label: "所属分类", align: "left" as const },
{ key: "warehouse", label: "所属仓库", align: "left" as const },
{ key: "store", label: "所属门店", align: "left" as const },
{ key: "rollNo", label: "膜卷号", align: "left" as const },
{ key: "actions", label: "操作", width: 100, align: "center" as const }
];
const tableData = ref<TableRow[]>([
{ index: 1, name: "商品A", spec: "100x100", code: "C001", series: "系列1", category: "分类1", warehouse: "仓库A", store: "门店A", rollNo: "R001" },
{ index: 2, name: "商品B", spec: "200x200", code: "C002", series: "系列2", category: "分类2", warehouse: "仓库B", store: "门店B", rollNo: "R002" },
{ index: 3, name: "商品C", spec: "300x300", code: "C003", series: "系列3", category: "分类3", warehouse: "仓库A", store: "门店A", rollNo: "R003" },
{ index: 4, name: "商品D", spec: "400x400", code: "C004", series: "系列4", category: "分类4", warehouse: "仓库B", store: "门店B", rollNo: "R004" },
{ index: 5, name: "商品E", spec: "500x500", code: "C005", series: "系列5", category: "分类5", warehouse: "仓库A", store: "门店A", rollNo: "R005" },
{ index: 6, name: "商品F", spec: "600x600", code: "C006", series: "系列6", category: "分类6", warehouse: "仓库B", store: "门店B", rollNo: "R006" },
{ index: 7, name: "商品G", spec: "700x700", code: "C007", series: "系列7", category: "分类7", warehouse: "仓库A", store: "门店A", rollNo: "R007" },
{ index: 8, name: "商品H", spec: "800x800", code: "C008", series: "系列8", category: "分类8", warehouse: "仓库B", store: "门店B", rollNo: "R008" }
]);
const handleSearch = () => { const handleSearch = () => {
console.log("search", filterForm.value); // search logic
}; };
const handleSelect = (row: Record<string, unknown>) => { const handleSelect = (row: TableRow) => {
console.log("select", row); // select logic
console.log(row);
}; };
</script> </script>
...@@ -59,62 +74,71 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -59,62 +74,71 @@ const handleSelect = (row: Record<string, unknown>) => {
<div class="allocation-management"> <div class="allocation-management">
<div class="filter-section"> <div class="filter-section">
<div class="filter-row"> <div class="filter-row">
<span class="row-label">调出方:</span> <span class="filter-group-label">调出方:</span>
<div class="field-group"> <div class="filter-item">
<span class="field-label"><span class="required">*</span>调出仓库:</span> <span class="required">*</span>
<VSelect v-model="filterForm.outWarehouse" <span class="item-label">调出仓库:</span>
class="custom-select" <VSelect v-model="outWarehouse"
class="filter-select"
:options="warehouseOptions"
placeholder="请选择调出仓库" /> placeholder="请选择调出仓库" />
</div> </div>
<div class="field-group"> <div class="filter-item">
<span class="field-label"><span class="required">*</span>调出门店:</span> <span class="required">*</span>
<VSelect v-model="filterForm.outStore" <span class="item-label">调出门店:</span>
class="custom-select" <VSelect v-model="outStore"
class="filter-select"
:options="storeOptions"
placeholder="请选择调出门店" /> placeholder="请选择调出门店" />
</div> </div>
</div> </div>
<div class="filter-row"> <div class="filter-row">
<span class="row-label">调入方:</span> <span class="filter-group-label">调入方:</span>
<div class="field-group"> <div class="filter-item">
<span class="field-label"><span class="required">*</span>调入仓库:</span> <span class="required">*</span>
<VSelect v-model="filterForm.inWarehouse" <span class="item-label">调入仓库:</span>
class="custom-select" <VSelect v-model="inWarehouse"
class="filter-select"
:options="warehouseOptions"
placeholder="请选择调入仓库" /> placeholder="请选择调入仓库" />
</div> </div>
<div class="field-group"> <div class="filter-item">
<span class="field-label"><span class="required">*</span>调入门店:</span> <span class="required">*</span>
<VSelect v-model="filterForm.inStore" <span class="item-label">调入门店:</span>
class="custom-select" <VSelect v-model="inStore"
class="filter-select"
:options="storeOptions"
placeholder="请选择调入门店" /> placeholder="请选择调入门店" />
</div> </div>
</div> </div>
</div> </div>
<div class="table-header"> <div class="toolbar-section">
<h3 class="table-title"> <div class="toolbar-title">
调拨列表 调拨列表
</h3> </div>
<div class="table-actions"> <div class="toolbar-search">
<VInput v-model="filterForm.keyword" <span class="search-label">调拨:</span>
<VInput v-model="searchText"
class="search-input" class="search-input"
placeholder="请输入商品名称/系列"> placeholder="请输入商品名称/系列" />
<template #prepend> <VButton type="primary"
<span class="prepend-text">调拨:</span> @click="handleSearch">
</template>
</VInput>
<VButton type="primary" @click="handleSearch">
查询 查询
</VButton> </VButton>
</div> </div>
</div> </div>
<div class="table-section"> <div class="table-section">
<VTable class="custom-table" <VTable class="data-table"
:columns="columns" :columns="columns"
:data="tableData" :data="tableData"
row-key="id"> row-key="index">
<template #actions="{ row }"> <template #actions="{ row }">
<a class="action-link" @click="handleSelect(row)">选择</a> <a class="action-link"
@click="handleSelect(row)">
选择
</a>
</template> </template>
</VTable> </VTable>
</div> </div>
...@@ -122,9 +146,10 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -122,9 +146,10 @@ const handleSelect = (row: Record<string, unknown>) => {
<div class="pagination-section"> <div class="pagination-section">
<ElPagination v-model:current-page="currentPage" <ElPagination v-model:current-page="currentPage"
v-model:page-size="pageSize" v-model:page-size="pageSize"
class="pagination"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[10, 20, 50, 100]" :page-sizes="[10, 20, 50, 100]"
:total="800" /> :total="total" />
</div> </div>
</div> </div>
</template> </template>
...@@ -135,8 +160,10 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -135,8 +160,10 @@ const handleSelect = (row: Record<string, unknown>) => {
flex-direction: column; flex-direction: column;
gap: 16px; gap: 16px;
padding: 20px; padding: 20px;
background-color: #ffffff; background: #ffffff;
font-family: "HarmonyOS Sans SC", "PingFang SC", sans-serif; font-family: "HarmonyOS Sans SC", sans-serif;
width: 100%;
box-sizing: border-box;
} }
.filter-section { .filter-section {
...@@ -151,7 +178,7 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -151,7 +178,7 @@ const handleSelect = (row: Record<string, unknown>) => {
gap: 12px; gap: 12px;
} }
.row-label { .filter-group-label {
color: #333333; color: #333333;
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
...@@ -159,15 +186,18 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -159,15 +186,18 @@ const handleSelect = (row: Record<string, unknown>) => {
white-space: nowrap; white-space: nowrap;
} }
.field-group { .filter-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 4px;
flex: 1; }
max-width: 300px;
.required {
color: #eb4e4e;
font-size: 14px;
} }
.field-label { .item-label {
color: #333333; color: #333333;
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
...@@ -175,79 +205,59 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -175,79 +205,59 @@ const handleSelect = (row: Record<string, unknown>) => {
white-space: nowrap; white-space: nowrap;
} }
.required { .filter-select {
color: #eb4e4e; width: 200px;
margin-right: 2px;
} }
.custom-select { .toolbar-section {
flex: 1;
}
.table-header {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-top: 4px; margin-top: 4px;
} }
.table-title { .toolbar-title {
color: #333333; color: #333333;
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
line-height: 19px;
margin: 0;
} }
.table-actions { .toolbar-search {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
} }
.search-input { .search-label {
width: 280px;
}
.prepend-text {
color: #333333; color: #333333;
font-size: 14px; font-size: 14px;
white-space: nowrap;
} }
.table-section { .search-input {
margin-top: 10px; width: 240px;
} }
.custom-table { .table-section {
border: 1px solid #e5e5e5; width: 100%;
border-radius: 4px;
overflow: hidden; overflow: hidden;
} }
:deep(.el-table th.el-table__cell) { .data-table {
background-color: #f4f6fc; width: 100% !important;
color: #333333;
font-size: 14px;
font-weight: 500;
border-bottom: 1px solid #e5e5e5;
} }
:deep(.el-table td.el-table__cell) { :deep(.el-table th.el-table__cell),
color: #666666; :deep(.v-table-header),
font-size: 14px; :deep(table th),
font-weight: 400; :deep(.el-table__header th) {
border-bottom: 1px solid #e5e5e5; background-color: #f4f6fc !important;
}
:deep(.el-table .cell) {
white-space: pre-line;
line-height: 16px;
} }
.action-link { .action-link {
color: #5850ff; color: #5850ff;
font-size: 14px;
cursor: pointer; cursor: pointer;
font-size: 14px;
text-decoration: none; text-decoration: none;
} }
...@@ -257,46 +267,18 @@ const handleSelect = (row: Record<string, unknown>) => { ...@@ -257,46 +267,18 @@ const handleSelect = (row: Record<string, unknown>) => {
.pagination-section { .pagination-section {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-start !important;
margin-top: 16px; margin-top: 8px;
width: 100%;
} }
:deep(.el-pagination) { :deep(.el-pagination) {
--el-pagination-button-bg-color: #ffffff; justify-content: flex-start !important;
--el-pagination-hover-color: #5850ff;
}
:deep(.el-pagination .el-pager li) {
background-color: #ffffff;
border: 1px solid #e8e8ea;
border-radius: 2px;
color: #666666;
font-size: 12px;
min-width: 24px;
height: 24px;
line-height: 24px;
margin: 0 4px;
} }
:deep(.el-pagination .el-pager li.is-active) { :deep(.el-pager li.is-active) {
background-color: #5850ff; background-color: #5850ff;
border-color: #5850ff;
color: #ffffff; color: #ffffff;
}
:deep(.el-pagination button.btn-prev),
:deep(.el-pagination button.btn-next) {
background-color: #ffffff;
border: 1px solid #e8e8ea;
border-radius: 2px; border-radius: 2px;
color: #999999;
min-width: 24px;
height: 24px;
}
:deep(.el-pagination .el-pagination__sizes .el-input__wrapper) {
border: 1px solid #dcdfe5;
border-radius: 3px;
box-shadow: none;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -144,6 +144,7 @@ ...@@ -144,6 +144,7 @@
"designContextFile": { "type": "string" }, "designContextFile": { "type": "string" },
"variableDefsFile": { "type": "string" }, "variableDefsFile": { "type": "string" },
"screenshotFile": { "type": "string" }, "screenshotFile": { "type": "string" },
"screenshotSummaryFile": { "type": "string" },
"promptFile": { "type": "string" } "promptFile": { "type": "string" }
}, },
"additionalProperties": false "additionalProperties": false
......
# Debug Session: provider-hang [OPEN]
## Symptom
- `pnpm ai:execute` can finish `ai-direct-messages` and `ai-direct-preview-project`
- Execution then appears to hang before a new `provider-response`, `validation`, or `execute-result` artifact is produced
- A direct `ai-direct-validate-output` run also appears to stall after initial startup logs
## Scope
- Repo: `d:/work/venus`
- Target flow: `scripts/ai-direct-execute.mjs` and `scripts/ai-direct-validate-output.mjs`
- Preview project: `apps/web/ai-previews/allocationmanagement-qwen-autofix`
## Hypotheses
1. Provider request is not returning and Node `fetch` timeout is not aborting as expected.
2. A child command spawned by `ai-direct-validate-output` blocks under the sandboxed shell.
3. The request payload size causes the provider to respond extremely slowly, making the flow look hung.
4. The command completes but artifact writes are delayed or blocked by filesystem/sandbox behavior.
## Evidence Log
- `execute` instrumentation logged `run:before-provider` and `callOpenAiCompatible:start`, but never logged `provider response received` or `after-provider`.
- Logged provider request size is `219495` bytes.
- A tiny direct request to the same DashScope endpoint and model returned successfully within the test command timeout.
- During the hung run, no new `provider-response`, `validation`, or `execute-result` artifacts were written.
- After compacting the prompt, request size dropped to `54767` bytes and then to `30278` bytes.
- With `requestBytes = 30278`, instrumentation captured `provider response received` with `200 OK`.
- The end-to-end flow progressed through `apply` and `validate`, then hit a real `type-check` failure in generated `VTable` column typing and entered `auto-repair`.
- Over-compressing the prompt removed too much VUI signature detail, so a slim component-signature section was added back into the prompt snapshot.
## Hypothesis Status
| ID | Hypothesis | Status | Evidence |
|---|---|---|---|
| A | Provider request is not returning and `fetch` timeout is not aborting as expected | Confirmed (request stalls before response) | Debug log contains request-start events but no response event |
| B | A child command spawned by `ai-direct-validate-output` blocks under the sandboxed shell | Rejected for this hang | `execute` never reaches apply/validate stage in the captured run |
| C | Request payload size causes provider to respond extremely slowly | Confirmed | Large request is ~219 KB; tiny request to same endpoint/model succeeds quickly |
| D | Command completes but artifact writes are delayed or blocked by filesystem/sandbox behavior | Rejected | No after-provider log and no downstream artifact updates |
## Next Step
- Keep the reduced prompt payload, retain the slim VUI component signatures, and rerun the repair loop to verify the `VTable.columns` typing issue can now auto-converge.
...@@ -30,15 +30,15 @@ ...@@ -30,15 +30,15 @@
```text ```text
Figma Developer MCP Figma Developer MCP
-> raw design context / variables -> raw design context / variables / screenshot
project-intelligence project-intelligence
-> project-context -> project-context
component manifest / meta index component manifest / meta index
-> component facts -> component facts
ai-direct-context bundle ai-direct-context bundle
-> AI / IDE direct generation -> AI / IDE direct generation with screenshot visual summary
venus validation venus validation
-> lint / typecheck / contract / review trigger / fitness -> lint / typecheck / contract / review trigger / visual-summary adherence / fitness
``` ```
这条链路中,`venus` 不再主导“中间映射决策”,而是主导以下四件事: 这条链路中,`venus` 不再主导“中间映射决策”,而是主导以下四件事:
...@@ -213,6 +213,19 @@ AI 在生成页面时必须遵守以下原则: ...@@ -213,6 +213,19 @@ AI 在生成页面时必须遵守以下原则:
- 传入 `--provider openai-compatible` - 传入 `--provider openai-compatible`
- 通过环境变量 `AI_DIRECT_OPENAI_BASE_URL`、`AI_DIRECT_OPENAI_API_KEY`、`AI_DIRECT_OPENAI_MODEL` 直调兼容接口 - 通过环境变量 `AI_DIRECT_OPENAI_BASE_URL`、`AI_DIRECT_OPENAI_API_KEY`、`AI_DIRECT_OPENAI_MODEL` 直调兼容接口
常用执行开关:
- `--existing-preview-project-root`
- 复用已有预览项目,不再每次新建目录
- `--refresh-context`
- 强制重新拉取最新 Figma context、variables 和 screenshot
- `--auto-repair`
- 校验失败后自动发起 repair 回合
- `--max-repair-rounds`
- 控制自动 repair 最大轮次
- `--install`
- 在预览项目中安装依赖,以便本地 `type-check`
当校验失败时,总控脚本会生成: 当校验失败时,总控脚本会生成:
- `*.repair-feedback.json` - `*.repair-feedback.json`
...@@ -220,6 +233,20 @@ AI 在生成页面时必须遵守以下原则: ...@@ -220,6 +233,20 @@ AI 在生成页面时必须遵守以下原则:
用于把失败原因回喂给 AI 做下一轮修复。 用于把失败原因回喂给 AI 做下一轮修复。
当存在 Figma screenshot 时,链路还会额外生成:
- `*.screenshot.png`
- `*.screenshot-summary.json`
- `*.screenshot-summary.md`
其中结构化截图摘要会同时进入 prompt 和 validate,用于约束标题、筛选组、表格列、操作文案和分页布局等关键视觉事实。
典型执行方式:
```bash
pnpm ai:execute --bundle-file <bundle-file> --provider openai-compatible --existing-preview-project-root <project-root> --auto-repair --max-repair-rounds 2 --install
```
而不是在生成前替 AI 完成全部组件映射。 而不是在生成前替 AI 完成全部组件映射。
## 当前依赖的基础设施 ## 当前依赖的基础设施
...@@ -256,11 +283,11 @@ AI 在生成页面时必须遵守以下原则: ...@@ -256,11 +283,11 @@ AI 在生成页面时必须遵守以下原则:
当前推荐执行顺序: 当前推荐执行顺序:
1. `ai-direct-context` 通过 `figma-developer-mcp` 拉取 Figma 数据并生成 bundle 1. `ai-direct-context` 通过 `figma-developer-mcp` 拉取 Figma 数据并生成 bundle
2. `ai-direct-messages` 把 bundle、设计上下文和规则组装成可直接投喂 AI 的 messages/request 2. `ai-direct-messages` 把 bundle、设计上下文、截图视觉摘要和规则组装成可直接投喂 AI 的 messages/request
3. `ai-direct-preview-project` 使用 Venus CLI 创建预览项目骨架 3. `ai-direct-preview-project` 使用 Venus CLI 创建预览项目骨架
4. AI 返回结构化文件产物后,`ai-direct-apply-output` 将 `files[]` 落盘到预览项目 4. AI 返回结构化文件产物后,`ai-direct-apply-output` 将 `files[]` 落盘到预览项目
5. `ai-direct-validate-output` 对本次 AI 结果执行规则校验、定向 lint、review trigger、file budget 与可选 type-check 5. `ai-direct-validate-output` 对本次 AI 结果执行规则校验、样式责任校验、截图视觉摘要遵守性校验、定向 lint、review trigger、file budget 与可选 type-check
6. `ai-direct-execute` 可作为总控入口,自动串起上述步骤;在校验失败时生成 repair feedback 与 repair request 6. `ai-direct-execute` 可作为总控入口,自动串起上述步骤;在校验失败时生成 repair feedback 与 repair request,并可进入 auto-repair 回合
### 质量门禁 ### 质量门禁
......
...@@ -494,6 +494,7 @@ function buildBundle({ ...@@ -494,6 +494,7 @@ function buildBundle({
designContext, designContext,
variableDefsFile, variableDefsFile,
screenshotFile, screenshotFile,
screenshotSummaryFile,
designContextFile, designContextFile,
promptFile, promptFile,
workspaceExports, workspaceExports,
...@@ -536,6 +537,7 @@ function buildBundle({ ...@@ -536,6 +537,7 @@ function buildBundle({
designContextFile: normalizePath(designContextFile), designContextFile: normalizePath(designContextFile),
variableDefsFile: variableDefsFile ? normalizePath(variableDefsFile) : "", variableDefsFile: variableDefsFile ? normalizePath(variableDefsFile) : "",
screenshotFile: screenshotFile ? normalizePath(screenshotFile) : "", screenshotFile: screenshotFile ? normalizePath(screenshotFile) : "",
screenshotSummaryFile: screenshotSummaryFile ? normalizePath(screenshotSummaryFile) : "",
promptFile: normalizePath(promptFile), promptFile: normalizePath(promptFile),
}, },
}; };
...@@ -643,6 +645,7 @@ async function run() { ...@@ -643,6 +645,7 @@ async function run() {
const screenshotFile = screenshot const screenshotFile = screenshot
? path.join(outputDir, `${pageSlug}.screenshot${screenshotExtensionForMimeType(screenshot.mimeType)}`) ? path.join(outputDir, `${pageSlug}.screenshot${screenshotExtensionForMimeType(screenshot.mimeType)}`)
: ""; : "";
const screenshotSummaryFile = screenshot ? path.join(outputDir, `${pageSlug}.screenshot-summary.json`) : "";
const promptFile = path.join(outputDir, `${pageSlug}.prompt.md`); const promptFile = path.join(outputDir, `${pageSlug}.prompt.md`);
const bundleFile = path.join(outputDir, `${pageSlug}.ai-direct-context-bundle.json`); const bundleFile = path.join(outputDir, `${pageSlug}.ai-direct-context-bundle.json`);
...@@ -674,6 +677,7 @@ async function run() { ...@@ -674,6 +677,7 @@ async function run() {
designContext, designContext,
variableDefsFile, variableDefsFile,
screenshotFile, screenshotFile,
screenshotSummaryFile,
designContextFile, designContextFile,
promptFile, promptFile,
workspaceExports, workspaceExports,
......
...@@ -121,6 +121,34 @@ function normalizePath(targetPath) { ...@@ -121,6 +121,34 @@ function normalizePath(targetPath) {
return targetPath.replaceAll("\\", "/"); return targetPath.replaceAll("\\", "/");
} }
// #region debug-point A:report-helper
function reportDebugEvent(hypothesisId, location, msg, data = {}, runId = process.env.DEBUG_RUN_ID || "pre-fix") {
try {
const envPath = path.join(repoRoot, ".dbg", "provider-hang.env");
let debugServerUrl = "http://127.0.0.1:7777/event";
let sessionId = "provider-hang";
if (fs.existsSync(envPath)) {
const envText = fs.readFileSync(envPath, "utf8");
debugServerUrl = envText.match(/DEBUG_SERVER_URL=(.+)/)?.[1]?.trim() || debugServerUrl;
sessionId = envText.match(/DEBUG_SESSION_ID=(.+)/)?.[1]?.trim() || sessionId;
}
fetch(debugServerUrl, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
sessionId,
runId,
hypothesisId,
location,
msg,
data,
ts: Date.now(),
}),
}).catch(() => {});
} catch {}
}
// #endregion
function slugify(value) { function slugify(value) {
const normalized = String(value || "") const normalized = String(value || "")
.trim() .trim()
...@@ -257,6 +285,20 @@ async function callOpenAiCompatible(messages, model) { ...@@ -257,6 +285,20 @@ async function callOpenAiCompatible(messages, model) {
} }
const endpoint = `${baseUrl.replace(/\/$/, "")}/chat/completions`; const endpoint = `${baseUrl.replace(/\/$/, "")}/chat/completions`;
const requestBody = JSON.stringify({
model: resolvedModel,
temperature: 0.2,
response_format: { type: "json_object" },
messages,
});
// #region debug-point A:provider-request-start
reportDebugEvent("A", "scripts/ai-direct-execute.mjs:callOpenAiCompatible:start", "[DEBUG] provider request start", {
endpoint,
model: resolvedModel,
messageCount: messages.length,
requestBytes: Buffer.byteLength(requestBody, "utf8"),
});
// #endregion
const response = await fetch(endpoint, { const response = await fetch(endpoint, {
method: "POST", method: "POST",
headers: { headers: {
...@@ -264,14 +306,16 @@ async function callOpenAiCompatible(messages, model) { ...@@ -264,14 +306,16 @@ async function callOpenAiCompatible(messages, model) {
authorization: `Bearer ${apiKey}`, authorization: `Bearer ${apiKey}`,
connection: "close", connection: "close",
}, },
signal: AbortSignal.timeout(180000), signal: AbortSignal.timeout(180_000),
body: JSON.stringify({ body: requestBody,
model: resolvedModel,
temperature: 0.2,
response_format: { type: "json_object" },
messages,
}),
}); });
// #region debug-point A:provider-response
reportDebugEvent("A", "scripts/ai-direct-execute.mjs:callOpenAiCompatible:response", "[DEBUG] provider response received", {
status: response.status,
statusText: response.statusText,
ok: response.ok,
});
// #endregion
if (!response.ok) { if (!response.ok) {
const errorText = (await response.text()).trim(); const errorText = (await response.text()).trim();
...@@ -356,6 +400,14 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP ...@@ -356,6 +400,14 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
const feedbackPath = path.join(path.dirname(responsePath), `${baseName}.repair-feedback.json`); const feedbackPath = path.join(path.dirname(responsePath), `${baseName}.repair-feedback.json`);
const requestPath = path.join(path.dirname(responsePath), `${baseName}.repair-request.md`); const requestPath = path.join(path.dirname(responsePath), `${baseName}.repair-request.md`);
const failedCommands = (validation.commandResults || []).filter((item) => !item.ok); const failedCommands = (validation.commandResults || []).filter((item) => !item.ok);
const ruleErrors = validation.ruleValidation?.errors || [];
const ruleWarnings = validation.ruleValidation?.warnings || [];
const styleErrors = validation.styleValidation?.errors || [];
const styleWarnings = validation.styleValidation?.warnings || [];
const primaryDataErrors = validation.primaryDataValidation?.errors || [];
const primaryDataWarnings = validation.primaryDataValidation?.warnings || [];
const visualSummaryErrors = validation.visualSummaryValidation?.errors || [];
const visualSummaryWarnings = validation.visualSummaryValidation?.warnings || [];
const feedback = { const feedback = {
meta: { meta: {
...@@ -371,8 +423,14 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP ...@@ -371,8 +423,14 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
responseFile: normalizePath(responsePath), responseFile: normalizePath(responsePath),
}, },
status: validation.status, status: validation.status,
ruleErrors: validation.ruleValidation?.errors || [], ruleErrors,
ruleWarnings: validation.ruleValidation?.warnings || [], ruleWarnings,
styleErrors,
styleWarnings,
primaryDataErrors,
primaryDataWarnings,
visualSummaryErrors,
visualSummaryWarnings,
failedCommands: failedCommands.map((item) => ({ failedCommands: failedCommands.map((item) => ({
command: item.command, command: item.command,
exitCode: item.exitCode, exitCode: item.exitCode,
...@@ -395,9 +453,30 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP ...@@ -395,9 +453,30 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
"", "",
]; ];
for (const error of feedback.ruleErrors) { for (const error of ruleErrors) {
requestLines.push(`- Rule Error: ${error}`); requestLines.push(`- Rule Error: ${error}`);
} }
for (const error of styleErrors) {
requestLines.push(`- Style Error: ${error}`);
}
for (const error of primaryDataErrors) {
requestLines.push(`- Primary Data Error: ${error}`);
}
for (const error of visualSummaryErrors) {
requestLines.push(`- Visual Summary Error: ${error}`);
}
for (const warning of ruleWarnings) {
requestLines.push(`- Rule Warning: ${warning}`);
}
for (const warning of styleWarnings) {
requestLines.push(`- Style Warning: ${warning}`);
}
for (const warning of primaryDataWarnings) {
requestLines.push(`- Primary Data Warning: ${warning}`);
}
for (const warning of visualSummaryWarnings) {
requestLines.push(`- Visual Summary Warning: ${warning}`);
}
for (const command of feedback.failedCommands) { for (const command of feedback.failedCommands) {
requestLines.push(`- Command Failure: ${command.command} (exit=${command.exitCode})`); requestLines.push(`- Command Failure: ${command.command} (exit=${command.exitCode})`);
if (command.stderr) { if (command.stderr) {
...@@ -418,6 +497,9 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP ...@@ -418,6 +497,9 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
"", "",
"- 保持 previewProject.mustUseVenusCli=true。", "- 保持 previewProject.mustUseVenusCli=true。",
"- 只修复失败项,不要引入新的 UI 包违规。", "- 只修复失败项,不要引入新的 UI 包违规。",
"- 如果失败项来自 Figma 原始数据校验,优先保留 design context 中明确给出的标签、placeholder、列名和示例数据,不要让截图摘要覆盖这些文本事实。",
"- 如果失败项来自截图视觉摘要校验,优先修正标题、筛选标签、选择框数量、表格列、操作文案和分页布局,使页面与截图摘要一致。",
"- 如果失败项来自样式责任校验,直接在生成文件中补齐页面级样式,不要把布局或视觉修复转嫁给预览项目壳层。",
"- 输出完整结构化 JSON,沿用既定 response schema。", "- 输出完整结构化 JSON,沿用既定 response schema。",
); );
...@@ -464,10 +546,30 @@ async function run() { ...@@ -464,10 +546,30 @@ async function run() {
); );
const preview = readJson(previewPath); const preview = readJson(previewPath);
// #region debug-point A:before-provider
reportDebugEvent("A", "scripts/ai-direct-execute.mjs:run:before-provider", "[DEBUG] entering resolveAiResponse", {
bundleFile: normalizePath(bundlePath),
previewFile: normalizePath(previewPath),
provider: args.provider || "manual",
model: args.model || process.env.AI_DIRECT_OPENAI_MODEL || process.env.OPENAI_MODEL || "",
});
// #endregion
const aiResult = await resolveAiResponse({ args, bundlePath }); const aiResult = await resolveAiResponse({ args, bundlePath });
const plainResponse = aiResult.mode === "manual-replay" ? aiResult.response : aiResult.response; const plainResponse = aiResult.mode === "manual-replay" ? aiResult.response : aiResult.response;
// #region debug-point D:after-provider
reportDebugEvent("D", "scripts/ai-direct-execute.mjs:run:after-provider", "[DEBUG] resolveAiResponse completed", {
mode: aiResult.mode,
responseFile: normalizePath(aiResult.responsePath),
fileExists: fileExists(aiResult.responsePath),
});
// #endregion
persistPlainResponse(aiResult.responsePath, plainResponse); persistPlainResponse(aiResult.responsePath, plainResponse);
// #region debug-point D:before-apply
reportDebugEvent("D", "scripts/ai-direct-execute.mjs:run:before-apply", "[DEBUG] starting apply stage", {
responseFile: normalizePath(aiResult.responsePath),
});
// #endregion
runNodeScript("ai-direct-apply-output.mjs", [ runNodeScript("ai-direct-apply-output.mjs", [
"--response-file", "--response-file",
aiResult.responsePath, aiResult.responsePath,
...@@ -477,6 +579,12 @@ async function run() { ...@@ -477,6 +579,12 @@ async function run() {
let validationPassed = true; let validationPassed = true;
try { try {
// #region debug-point B:before-validate
reportDebugEvent("B", "scripts/ai-direct-execute.mjs:run:before-validate", "[DEBUG] starting validate stage", {
responseFile: normalizePath(aiResult.responsePath),
previewFile: normalizePath(previewPath),
});
// #endregion
runNodeScript("ai-direct-validate-output.mjs", [ runNodeScript("ai-direct-validate-output.mjs", [
"--response-file", "--response-file",
aiResult.responsePath, aiResult.responsePath,
...@@ -486,6 +594,11 @@ async function run() { ...@@ -486,6 +594,11 @@ async function run() {
} catch { } catch {
validationPassed = false; validationPassed = false;
} }
// #region debug-point D:after-validate
reportDebugEvent("D", "scripts/ai-direct-execute.mjs:run:after-validate", "[DEBUG] validate stage completed", {
validationPassed,
});
// #endregion
const validationPath = path.join( const validationPath = path.join(
path.dirname(aiResult.responsePath), path.dirname(aiResult.responsePath),
......
...@@ -236,15 +236,22 @@ function buildSystemPrompt(bundle) { ...@@ -236,15 +236,22 @@ function buildSystemPrompt(bundle) {
} }
function buildUserPrompt({ bundle, promptText, designContext, variableDefsText }) { function buildUserPrompt({ bundle, promptText, designContext, variableDefsText }) {
const compactBundle = buildPromptBundleSnapshot(bundle);
const compactDesignContext = buildPromptDesignContext(bundle, designContext);
const primaryFacts = extractPrimaryFigmaFacts(designContext);
return [ return [
"# Task Context", "# Task Context",
promptText.trim(), promptText.trim(),
"", "",
"# Bundle JSON", "# Bundle Snapshot",
JSON.stringify(bundle, null, 2), JSON.stringify(compactBundle, null, 2),
"",
"# Figma Design Context",
compactDesignContext,
"", "",
"# Raw Figma Design Context", "# Primary Figma Facts",
designContext, JSON.stringify(primaryFacts, null, 2),
"", "",
"# Variable Definitions", "# Variable Definitions",
variableDefsText || "{}", variableDefsText || "{}",
...@@ -260,12 +267,206 @@ function buildUserPrompt({ bundle, promptText, designContext, variableDefsText } ...@@ -260,12 +267,206 @@ function buildUserPrompt({ bundle, promptText, designContext, variableDefsText }
"- 页面级样式必须直接在本次生成文件中给出;不要假设我会再去 `allocationmanagement-qwen-autofix` 之类的目标产物里手工补样式。", "- 页面级样式必须直接在本次生成文件中给出;不要假设我会再去 `allocationmanagement-qwen-autofix` 之类的目标产物里手工补样式。",
"- 若生成 Vue 页面,请在页面文件中包含 `<style>`,并让页面在中性骨架下也具备完整布局和基本视觉层次。", "- 若生成 Vue 页面,请在页面文件中包含 `<style>`,并让页面在中性骨架下也具备完整布局和基本视觉层次。",
"- 请优先参考 design context 中可直接读取的布局与视觉参数,尽量还原真实的间距、分栏、输入控件宽度、表头层次与分页位置。", "- 请优先参考 design context 中可直接读取的布局与视觉参数,尽量还原真实的间距、分栏、输入控件宽度、表头层次与分页位置。",
"- 当 Figma 原始 design context、显式文本节点、placeholder、列名、示例数据与截图摘要发生冲突时,始终以 Figma 原始数据和组件事实源为准,截图只用于辅助校正视觉分组、留白、颜色和分页对齐。",
"- 如果 Figma 原始数据中存在工具栏搜索标签与输入框 placeholder,必须完整保留标签、冒号和输入框,不要因为截图理解偏差而省略。",
"- 如果 Figma 原始数据表明工具栏控件顺序是“标签 -> 文本输入框 -> 查询按钮”,必须保持该顺序,且查询按钮紧跟在文本输入框之后,不要把按钮挪到筛选区或标题区之外。",
"- 工具栏搜索控件应使用单值文本输入框,绑定 string 类型字段;不要误生成多值输入、数组输入、标签输入或选择器。",
"- 如果 Figma 原始数据中存在表格示例内容,预览页必须生成非空示例数据,并优先复用这些文本线索,而不是输出空表格。",
"- 如果 Figma 原始数据表明表格横向铺满容器,必须让表格组件和其外层容器宽度撑满可用空间,不要生成窄表格。",
"- 如果 Figma 原始数据表明表头存在浅灰背景、分页左对齐、当前页为带实色背景的小方形页码,请直接在页面样式中实现这些视觉事实。",
"- 如果设计稿里没有某些装饰信息,不要自己脑补 banner、渐变块、统计卡或解释性文案。", "- 如果设计稿里没有某些装饰信息,不要自己脑补 banner、渐变块、统计卡或解释性文案。",
"- 传给表格组件的 columns 类型必须与目标组件兼容,尤其 `align` 只能使用合法联合字面量,而不是宽泛字符串。", "- 传给表格组件的 columns 类型必须与目标组件兼容,尤其 `align` 只能使用合法联合字面量,而不是宽泛字符串。",
"- 如果预览骨架已有 `src/router.ts`,请直接修改它,不要新增 `src/router/index.ts` 与现有结构冲突。", "- 如果预览骨架已有 `src/router.ts`,请直接修改它,不要新增 `src/router/index.ts` 与现有结构冲突。",
].join("\n"); ].join("\n");
} }
function collectDesignContextTexts(designContext) {
const lines = String(designContext || "").split(/\r?\n/u);
const texts = [];
for (let index = 0; index < lines.length; index++) {
const line = lines[index];
const match = line.match(/^(\s*)text:\s*(.*)$/u);
if (!match) {
continue;
}
const baseIndent = match[1].length;
const rawValue = match[2].trim();
if (rawValue === "|-" || rawValue === "|") {
const blockLines = [];
let cursor = index + 1;
while (cursor < lines.length) {
const nextLine = lines[cursor];
if (!nextLine.trim()) {
blockLines.push("");
cursor++;
continue;
}
const nextMatch = nextLine.match(/^(\s+)(.*)$/u);
if (!nextMatch || nextMatch[1].length <= baseIndent) {
break;
}
if (nextMatch[2] || blockLines.length > 0) {
blockLines.push(nextMatch[2].trimEnd());
}
cursor++;
}
const blockText = blockLines.join("\n").trim();
if (blockText) {
texts.push(blockText);
}
index = cursor - 1;
continue;
}
if (rawValue) {
texts.push(rawValue.replaceAll(/^['"]|['"]$/gu, "").trim());
}
}
return [...new Set(texts.map((item) => item.trim()).filter(Boolean))];
}
function extractPrimaryFigmaFacts(designContext) {
const texts = collectDesignContextTexts(designContext);
const normalizedTexts = new Set(texts.map((item) => item.replace(/[::]$/u, "")));
const hasStandaloneColon = texts.includes(":") || texts.includes(":");
const toolbarSearchLabel = texts.includes("调拨") ? `调拨${hasStandaloneColon ? ":" : ""}` : "";
const knownColumns = ["序号", "商品名称", "规格", "商品编码", "系列", "所属分类", "所属仓库", "所属门店", "膜卷号", "操作"];
const excludedTexts = new Set([
"查询",
"调入仓库",
"调入方",
"调入门店",
"调出仓库",
"调出方",
"调出门店",
"调拨",
"调拨列表",
"选择",
...knownColumns,
]);
const sampleRowTexts = texts
.filter((item) => !excludedTexts.has(item.replace(/[::]$/u, "")))
.filter(
(item) =>
item.includes("\n") ||
/[A-Za-z0-9]/u.test(item) ||
item.includes("太阳膜") ||
item.includes("自建商品") ||
item.includes("精品"),
)
.slice(0, 8);
return {
filterGroupLabels: ["调出方", "调入方"].filter((item) => normalizedTexts.has(item)),
headerTitle: texts.find((item) => item === "调拨列表") || "",
toolbarSearchLabel,
toolbarSearchPlaceholder: texts.find((item) => item.includes("请输入商品名称/系列")) || "",
toolbarSearchInputKind: "text",
toolbarControlOrder: toolbarSearchLabel ? ["label", "input", "button"] : [],
toolbarActionLabel: texts.find((item) => item === "查询") || "",
tableColumns: knownColumns.filter((item) => normalizedTexts.has(item)),
tableSampleTexts: sampleRowTexts,
tableShouldFillWidth: true,
tableHeaderBackground: "#f4f6fc",
paginationAlignment: "left",
paginationActivePageBackground: "#5850ff",
paginationActivePageRadius: 2,
};
}
function buildPromptBundleSnapshot(bundle) {
const workspacePackageExports = (bundle.projectUi?.workspacePackageExports || []).map((item) => ({
packageName: item.packageName,
exportNames: item.exportNames || [],
}));
const availableVuiExports = (bundle.componentFacts?.vuiCatalog?.components || []).map((component) => component.exportName);
const vuiComponentSignatures = (bundle.componentFacts?.vuiCatalog?.components || []).map((component) => ({
exportName: component.exportName,
description: component.description || "",
props: (component.props || []).map((prop) => ({
name: prop.name,
type: prop.type,
})),
events: (component.events || []).map((event) => event.name),
slots: (component.slots || []).map((slot) => slot.name),
}));
return {
figma: {
figmaUrl: bundle.figma?.figmaUrl || "",
pageName: bundle.figma?.pageName || "",
pageTitle: bundle.figma?.pageTitle || "",
pageSlug: bundle.figma?.pageSlug || "",
designContextExcerpt: String(bundle.figma?.designContextExcerpt || "").slice(0, 2000),
},
projectContext: {
projectName: bundle.projectContext?.projectName || "",
framework: bundle.projectContext?.framework || "",
appType: bundle.projectContext?.appType || "",
pageDirs: bundle.projectContext?.directories?.pageDirs || [],
routeFiles: bundle.projectContext?.directories?.routeFiles || [],
existingPages: bundle.projectContext?.existingPages?.pages || [],
uiStack: bundle.projectContext?.uiStack || {},
constraints: bundle.projectContext?.constraints || [],
},
projectUi: {
projectInstalledPackages: bundle.projectUi?.projectInstalledPackages || [],
workspacePackageExports,
},
componentSelection: {
preferredPackages: bundle.componentFacts?.preferredPackages || [],
fallbackPackages: bundle.componentFacts?.fallbackPackages || [],
availableVuiExports,
vuiComponentSignatures,
},
rules: {
framework: bundle.rules?.framework || "",
preferredVuiPackage: bundle.rules?.preferredVuiPackage || "",
fallbackPackages: bundle.rules?.fallbackPackages || [],
previewProjectPolicy: bundle.rules?.previewProjectPolicy || {},
componentSelection: bundle.rules?.componentSelection || [],
generationConstraints: bundle.rules?.generationConstraints || [],
validationGoals: bundle.rules?.validationGoals || [],
},
artifacts: {
designContextFile: bundle.artifacts?.designContextFile || "",
variableDefsFile: bundle.artifacts?.variableDefsFile || "",
screenshotFile: bundle.artifacts?.screenshotFile || "",
screenshotSummaryFile: bundle.artifacts?.screenshotSummaryFile || "",
},
};
}
function buildPromptDesignContext(bundle, designContext) {
const trimmed = String(designContext || "").trim();
if (!trimmed) {
return String(bundle.figma?.designContextExcerpt || "").slice(0, 2000);
}
const maxLength = 12_000;
if (trimmed.length <= maxLength) {
return trimmed;
}
const excerpt = String(bundle.figma?.designContextExcerpt || "").slice(0, 2000);
const headLength = 8000;
return [
"# Excerpt",
excerpt,
"",
"# Raw Context Head",
trimmed.slice(0, headLength).trimEnd(),
"",
`# Context Note\nOriginal raw context truncated from ${trimmed.length} chars for provider stability. Prioritize the screenshot summary and excerpt above for restoration decisions.`,
].join("\n");
}
function resolveScreenshotMimeType(screenshotFilePath) { function resolveScreenshotMimeType(screenshotFilePath) {
const extension = path.extname(screenshotFilePath).toLowerCase(); const extension = path.extname(screenshotFilePath).toLowerCase();
if (extension === ".jpg" || extension === ".jpeg") { if (extension === ".jpg" || extension === ".jpeg") {
...@@ -277,9 +478,97 @@ function resolveScreenshotMimeType(screenshotFilePath) { ...@@ -277,9 +478,97 @@ function resolveScreenshotMimeType(screenshotFilePath) {
return "image/png"; return "image/png";
} }
function extractJsonPayload(text) {
const trimmed = String(text || "").trim();
if (!trimmed) {
throw new Error("视觉摘要返回为空");
}
try {
return JSON.parse(trimmed);
} catch {}
const fencedMatch = trimmed.match(/```(?:json)?\s*([\s\S]*?)```/i);
if (fencedMatch) {
return JSON.parse(fencedMatch[1].trim());
}
const start = trimmed.indexOf("{");
const end = trimmed.lastIndexOf("}");
if (start !== -1 && end !== -1 && end > start) {
return JSON.parse(trimmed.slice(start, end + 1));
}
throw new Error("无法从视觉摘要返回中提取 JSON");
}
function normalizeVisualSummary(summary) {
if (!summary || typeof summary !== "object") {
return null;
}
return {
layoutOrder: Array.isArray(summary.layoutOrder) ? summary.layoutOrder.filter(Boolean) : [],
filterGroupLabels: Array.isArray(summary.filterGroupLabels) ? summary.filterGroupLabels.filter(Boolean) : [],
requiredSelectCount: Number(summary.requiredSelectCount) || 0,
headerTitle: typeof summary.headerTitle === "string" ? summary.headerTitle : "",
searchLabel: typeof summary.searchLabel === "string" ? summary.searchLabel : "",
primaryActionLabel: typeof summary.primaryActionLabel === "string" ? summary.primaryActionLabel : "",
tableColumns: Array.isArray(summary.tableColumns) ? summary.tableColumns.filter(Boolean) : [],
actionColumnLabel: typeof summary.actionColumnLabel === "string" ? summary.actionColumnLabel : "",
actionLinkLabel: typeof summary.actionLinkLabel === "string" ? summary.actionLinkLabel : "",
pagination: {
present: Boolean(summary.pagination?.present),
containerAlignment:
typeof summary.pagination?.containerAlignment === "string" ? summary.pagination.containerAlignment : "",
totalTextVisible: Boolean(summary.pagination?.totalTextVisible),
pageSizeSelectorVisible: Boolean(summary.pagination?.pageSizeSelectorVisible),
jumperVisible: Boolean(summary.pagination?.jumperVisible),
activePageStyle: typeof summary.pagination?.activePageStyle === "string" ? summary.pagination.activePageStyle : "",
},
style: {
backgroundTone: typeof summary.style?.backgroundTone === "string" ? summary.style.backgroundTone : "",
headerTone: typeof summary.style?.headerTone === "string" ? summary.style.headerTone : "",
primaryColor: typeof summary.style?.primaryColor === "string" ? summary.style.primaryColor : "",
},
notes: Array.isArray(summary.notes) ? summary.notes.filter(Boolean) : [],
};
}
function renderVisualSummaryMarkdown(summary) {
if (!summary) {
return "";
}
return [
"# Screenshot Visual Summary",
"",
`- layoutOrder: ${summary.layoutOrder.join(" -> ") || "none"}`,
`- filterGroupLabels: ${summary.filterGroupLabels.join(", ") || "none"}`,
`- requiredSelectCount: ${summary.requiredSelectCount}`,
`- headerTitle: ${summary.headerTitle || "none"}`,
`- searchLabel: ${summary.searchLabel || "none"}`,
`- primaryActionLabel: ${summary.primaryActionLabel || "none"}`,
`- tableColumns: ${summary.tableColumns.join(", ") || "none"}`,
`- actionColumnLabel: ${summary.actionColumnLabel || "none"}`,
`- actionLinkLabel: ${summary.actionLinkLabel || "none"}`,
`- pagination.present: ${String(summary.pagination.present)}`,
`- pagination.containerAlignment: ${summary.pagination.containerAlignment || "none"}`,
`- pagination.totalTextVisible: ${String(summary.pagination.totalTextVisible)}`,
`- pagination.pageSizeSelectorVisible: ${String(summary.pagination.pageSizeSelectorVisible)}`,
`- pagination.jumperVisible: ${String(summary.pagination.jumperVisible)}`,
`- pagination.activePageStyle: ${summary.pagination.activePageStyle || "none"}`,
`- style.backgroundTone: ${summary.style.backgroundTone || "none"}`,
`- style.headerTone: ${summary.style.headerTone || "none"}`,
`- style.primaryColor: ${summary.style.primaryColor || "none"}`,
...(summary.notes.length > 0 ? ["", "## Notes", ...summary.notes.map((item) => `- ${item}`)] : []),
"",
].join("\n");
}
async function summarizeScreenshotWithVisionModel(screenshotFilePath) { async function summarizeScreenshotWithVisionModel(screenshotFilePath) {
if (!screenshotFilePath || !fileExists(screenshotFilePath)) { if (!screenshotFilePath || !fileExists(screenshotFilePath)) {
return ""; return null;
} }
const baseUrl = process.env.AI_DIRECT_OPENAI_BASE_URL || process.env.OPENAI_BASE_URL; const baseUrl = process.env.AI_DIRECT_OPENAI_BASE_URL || process.env.OPENAI_BASE_URL;
...@@ -291,7 +580,7 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) { ...@@ -291,7 +580,7 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) {
"qwen3.6-plus"; "qwen3.6-plus";
if (!baseUrl || !apiKey || !visionModel) { if (!baseUrl || !apiKey || !visionModel) {
return ""; return null;
} }
const mimeType = resolveScreenshotMimeType(screenshotFilePath); const mimeType = resolveScreenshotMimeType(screenshotFilePath);
...@@ -312,7 +601,37 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) { ...@@ -312,7 +601,37 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) {
{ {
role: "system", role: "system",
content: content:
"你是 Venus 的截图视觉摘要器。请只基于页面截图,提取对页面还原最关键的视觉信息:整体分区结构、每个区域的对齐关系、间距节奏、输入框/按钮/表格/分页的大致尺寸与位置、标题层级、边框和背景色。输出 6-12 条简洁要点,不要输出解释性前缀。", [
"你是 Venus 的截图视觉摘要器。",
"请只基于页面截图,输出一个 JSON 对象,不要输出解释性前缀或 markdown。",
"JSON 字段要求:",
"{",
' "layoutOrder": ["filters", "toolbar", "table", "pagination"],',
' "filterGroupLabels": ["调出方", "调入方"],',
' "requiredSelectCount": 4,',
' "headerTitle": "调拨列表",',
' "searchLabel": "调拨",',
' "primaryActionLabel": "查询",',
' "tableColumns": ["序号", "商品名称"],',
' "actionColumnLabel": "操作",',
' "actionLinkLabel": "选择",',
' "pagination": {',
' "present": true,',
' "containerAlignment": "split|left|right",',
' "totalTextVisible": true,',
' "pageSizeSelectorVisible": true,',
' "jumperVisible": true,',
' "activePageStyle": "blue-filled|blue-outline|plain"',
" },",
' "style": {',
' "backgroundTone": "white|gray|mixed",',
' "headerTone": "light-gray|white|mixed",',
' "primaryColor": "blue|green|red|mixed"',
" },",
' "notes": ["string"]',
"}",
"其中 layoutOrder 只描述大区块顺序;pagination.containerAlignment 表示分页区域整体是左右拆分、整体靠左还是整体靠右。",
].join("\n"),
}, },
{ {
role: "user", role: "user",
...@@ -340,7 +659,7 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) { ...@@ -340,7 +659,7 @@ async function summarizeScreenshotWithVisionModel(screenshotFilePath) {
} }
const payload = await response.json(); const payload = await response.json();
return String(payload.choices?.[0]?.message?.content || "").trim(); return normalizeVisualSummary(extractJsonPayload(payload.choices?.[0]?.message?.content || ""));
} }
function buildUserMessageContent({ function buildUserMessageContent({
...@@ -349,7 +668,7 @@ function buildUserMessageContent({ ...@@ -349,7 +668,7 @@ function buildUserMessageContent({
designContext, designContext,
variableDefsText, variableDefsText,
screenshotFilePath, screenshotFilePath,
screenshotSummaryText, screenshotSummary,
}) { }) {
const prompt = buildUserPrompt({ bundle, promptText, designContext, variableDefsText }); const prompt = buildUserPrompt({ bundle, promptText, designContext, variableDefsText });
const sections = [prompt]; const sections = [prompt];
...@@ -359,16 +678,18 @@ function buildUserMessageContent({ ...@@ -359,16 +678,18 @@ function buildUserMessageContent({
[ [
"# Screenshot Context", "# Screenshot Context",
`- Screenshot file: ${path.basename(screenshotFilePath)}`, `- Screenshot file: ${path.basename(screenshotFilePath)}`,
"- 该截图来自当前 Figma node 的渲染结果,请优先用它校正分区、留白、字段宽度、表格层次和分页位置。", "- 该截图来自当前 Figma node 的渲染结果,只用于辅助校正分区、留白、字段宽度、表格层次和分页位置。",
"- 如果截图分析与 Figma 原始 design context、显式文本节点或组件事实源冲突,以数据源为准,不要让截图覆盖文本事实。",
].join("\n"), ].join("\n"),
); );
} }
if (screenshotSummaryText) { if (screenshotSummary) {
sections.push( sections.push(
[ [
"# Screenshot Visual Summary", "# Screenshot Visual Summary JSON",
screenshotSummaryText, "- 以下摘要仅作视觉辅助,不得覆盖 Figma 原始文本、placeholder、列名、示例数据或组件 API 事实。",
JSON.stringify(screenshotSummary, null, 2),
].join("\n"), ].join("\n"),
); );
} }
...@@ -423,13 +744,15 @@ async function run() { ...@@ -423,13 +744,15 @@ async function run() {
const messagesPath = path.join(bundleDir, `${baseName}.messages.json`); const messagesPath = path.join(bundleDir, `${baseName}.messages.json`);
const requestPath = path.join(bundleDir, `${baseName}.request.md`); const requestPath = path.join(bundleDir, `${baseName}.request.md`);
const screenshotSummaryPath = path.join(bundleDir, `${baseName}.screenshot-summary.md`); const screenshotSummaryPath = path.join(bundleDir, `${baseName}.screenshot-summary.md`);
let screenshotSummaryText = ""; const screenshotSummaryJsonPath = path.join(bundleDir, `${baseName}.screenshot-summary.json`);
let screenshotSummary = null;
if (screenshotPath && fileExists(screenshotPath)) { if (screenshotPath && fileExists(screenshotPath)) {
try { try {
screenshotSummaryText = await summarizeScreenshotWithVisionModel(screenshotPath); screenshotSummary = await summarizeScreenshotWithVisionModel(screenshotPath);
if (screenshotSummaryText) { if (screenshotSummary) {
fs.writeFileSync(screenshotSummaryPath, `${screenshotSummaryText}\n`, "utf8"); fs.writeFileSync(screenshotSummaryJsonPath, `${JSON.stringify(screenshotSummary, null, 2)}\n`, "utf8");
fs.writeFileSync(screenshotSummaryPath, renderVisualSummaryMarkdown(screenshotSummary), "utf8");
} }
} catch (error) { } catch (error) {
console.warn(`[ai-direct-messages] warning: 截图视觉摘要生成失败,继续走文本上下文: ${error.message}`); console.warn(`[ai-direct-messages] warning: 截图视觉摘要生成失败,继续走文本上下文: ${error.message}`);
...@@ -449,7 +772,7 @@ async function run() { ...@@ -449,7 +772,7 @@ async function run() {
designContext, designContext,
variableDefsText, variableDefsText,
screenshotFilePath: screenshotPath, screenshotFilePath: screenshotPath,
screenshotSummaryText, screenshotSummary,
}), }),
}, },
]; ];
......
...@@ -154,14 +154,21 @@ function deriveFeedbackFile(responsePath) { ...@@ -154,14 +154,21 @@ function deriveFeedbackFile(responsePath) {
function buildRepairMessages({ systemMessage, requestText, feedback }) { function buildRepairMessages({ systemMessage, requestText, feedback }) {
const sections = [requestText.trim()]; const sections = [requestText.trim()];
const hasStructuredFeedback =
Boolean(feedback?.ruleErrors?.length) ||
Boolean(feedback?.styleErrors?.length) ||
Boolean(feedback?.visualSummaryErrors?.length) ||
Boolean(feedback?.failedCommands?.length);
if (feedback?.failedCommands?.length) { if (hasStructuredFeedback) {
sections.push( sections.push(
[ [
"## Repair Focus", "## Repair Focus",
"- 只修复失败项,不改变无关页面结构、样式和组件选型。", "- 只修复失败项,不改变无关页面结构、样式和组件选型。",
"- 输出完整结构化 JSON,并保持既有 response schema。", "- 输出完整结构化 JSON,并保持既有 response schema。",
"- 如果问题来自 TypeScript 类型,请给出最小必要类型声明,不要扩大为宽泛 string/any。", "- 如果问题来自 TypeScript 类型,请给出最小必要类型声明,不要扩大为宽泛 string/any。",
"- 如果问题来自截图视觉摘要,请优先修正标题、筛选标签、字段数量、表格列和分页布局。",
"- 如果问题来自样式责任校验,请直接在页面文件内补齐样式,不要依赖预览壳层补救。",
].join("\n"), ].join("\n"),
); );
} }
......
...@@ -49,6 +49,34 @@ function normalizePath(targetPath) { ...@@ -49,6 +49,34 @@ function normalizePath(targetPath) {
return targetPath.replaceAll("\\", "/"); return targetPath.replaceAll("\\", "/");
} }
// #region debug-point B:report-helper
function reportDebugEvent(hypothesisId, location, msg, data = {}, runId = process.env.DEBUG_RUN_ID || "pre-fix") {
try {
const envPath = path.join(repoRoot, ".dbg", "provider-hang.env");
let debugServerUrl = "http://127.0.0.1:7777/event";
let sessionId = "provider-hang";
if (fs.existsSync(envPath)) {
const envText = fs.readFileSync(envPath, "utf8");
debugServerUrl = envText.match(/DEBUG_SERVER_URL=(.+)/)?.[1]?.trim() || debugServerUrl;
sessionId = envText.match(/DEBUG_SESSION_ID=(.+)/)?.[1]?.trim() || sessionId;
}
fetch(debugServerUrl, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
sessionId,
runId,
hypothesisId,
location,
msg,
data,
ts: Date.now(),
}),
}).catch(() => {});
} catch {}
}
// #endregion
function collectImports(fileContent) { function collectImports(fileContent) {
const imports = []; const imports = [];
const importRegex = /import\s+([^;]+?)\s+from\s+["']([^"']+)["']/g; const importRegex = /import\s+([^;]+?)\s+from\s+["']([^"']+)["']/g;
...@@ -59,14 +87,14 @@ function collectImports(fileContent) { ...@@ -59,14 +87,14 @@ function collectImports(fileContent) {
const namedMatch = clause.match(/\{([^}]+)\}/); const namedMatch = clause.match(/\{([^}]+)\}/);
const namedImports = namedMatch const namedImports = namedMatch
? namedMatch[1] ? namedMatch[1]
.split(",") .split(",")
.map((part) => .map((part) =>
part part
.trim() .trim()
.split(/\s+as\s+/i)[0] .split(/\s+as\s+/i)[0]
.trim(), .trim(),
) )
.filter(Boolean) .filter(Boolean)
: []; : [];
imports.push({ imports.push({
...@@ -205,12 +233,395 @@ function validateGeneratedStyleOwnership({ response, bundle, preview }) { ...@@ -205,12 +233,395 @@ function validateGeneratedStyleOwnership({ response, bundle, preview }) {
return { errors, warnings }; return { errors, warnings };
} }
function countMatches(pattern, text) {
const matches = text.match(pattern);
return matches ? matches.length : 0;
}
function collectDesignContextTexts(designContext) {
const lines = String(designContext || "").split(/\r?\n/u);
const texts = [];
for (let index = 0; index < lines.length; index++) {
const line = lines[index];
const match = line.match(/^(\s*)text:\s*(.*)$/u);
if (!match) {
continue;
}
const baseIndent = match[1].length;
const rawValue = match[2].trim();
if (rawValue === "|-" || rawValue === "|") {
const blockLines = [];
let cursor = index + 1;
while (cursor < lines.length) {
const nextLine = lines[cursor];
if (!nextLine.trim()) {
blockLines.push("");
cursor++;
continue;
}
const nextMatch = nextLine.match(/^(\s+)(.*)$/u);
if (!nextMatch || nextMatch[1].length <= baseIndent) {
break;
}
if (nextMatch[2] || blockLines.length > 0) {
blockLines.push(nextMatch[2].trimEnd());
}
cursor++;
}
const blockText = blockLines.join("\n").trim();
if (blockText) {
texts.push(blockText);
}
index = cursor - 1;
continue;
}
if (rawValue) {
texts.push(rawValue.replaceAll(/^['"]|['"]$/gu, "").trim());
}
}
return [...new Set(texts.map((item) => item.trim()).filter(Boolean))];
}
function extractPrimaryFigmaFacts(designContext) {
const texts = collectDesignContextTexts(designContext);
const normalizedTexts = new Set(texts.map((item) => item.replace(/[::]$/u, "")));
const hasStandaloneColon = texts.includes(":") || texts.includes(":");
const toolbarSearchLabel = texts.includes("调拨") ? "调拨" : "";
const knownColumns = ["序号", "商品名称", "规格", "商品编码", "系列", "所属分类", "所属仓库", "所属门店", "膜卷号", "操作"];
const excludedTexts = new Set([
"查询",
"调入仓库",
"调入方",
"调入门店",
"调出仓库",
"调出方",
"调出门店",
"调拨",
"调拨列表",
"选择",
...knownColumns,
]);
const tableSampleTexts = texts
.filter((item) => !excludedTexts.has(item.replace(/[::]$/u, "")))
.filter(
(item) =>
item.includes("\n") ||
/[A-Za-z0-9]/u.test(item) ||
item.includes("太阳膜") ||
item.includes("自建商品") ||
item.includes("精品"),
)
.slice(0, 8);
return {
toolbarSearchLabel: hasStandaloneColon && toolbarSearchLabel ? `${toolbarSearchLabel}:` : toolbarSearchLabel,
toolbarSearchPlaceholder: texts.find((item) => item.includes("请输入商品名称/系列")) || "",
toolbarSearchInputKind: "text",
toolbarControlOrder: toolbarSearchLabel ? ["label", "input", "button"] : [],
toolbarActionLabel: texts.find((item) => item === "查询") || "",
tableSampleTexts,
tableShouldFillWidth: true,
tableHeaderBackground: "#f4f6fc",
paginationAlignment: "left",
paginationActivePageBackground: "#5850ff",
paginationActivePageRadius: 2,
};
}
function readDesignContext(bundle, bundlePath) {
const designContextFile = bundle.artifacts?.designContextFile;
if (!designContextFile) {
return "";
}
const bundleDir = path.dirname(bundlePath);
const designContextPath = path.isAbsolute(designContextFile)
? designContextFile
: path.resolve(bundleDir, designContextFile);
if (!fs.existsSync(designContextPath)) {
return "";
}
return fs.readFileSync(designContextPath, "utf8");
}
function readVisualSummary(bundle, bundlePath) {
const screenshotSummaryFile = bundle.artifacts?.screenshotSummaryFile;
if (!screenshotSummaryFile) {
return null;
}
const bundleDir = path.dirname(bundlePath);
const summaryPath = path.isAbsolute(screenshotSummaryFile)
? screenshotSummaryFile
: path.resolve(bundleDir, screenshotSummaryFile);
if (!fs.existsSync(summaryPath)) {
return null;
}
try {
return readJson(summaryPath);
} catch {
return null;
}
}
function validateVisualSummaryAdherence({ response, bundle, bundlePath }) {
const errors = [];
const warnings = [];
const summary = readVisualSummary(bundle, bundlePath);
if (!summary) {
return { errors, warnings };
}
const viewFiles = response.files.filter((file) => /^src\/views\/.+\.vue$/u.test(file.path));
if (viewFiles.length === 0) {
warnings.push("未检测到视图文件,跳过截图视觉摘要遵守性校验");
return { errors, warnings };
}
for (const file of viewFiles) {
const content = file.content;
if (summary.headerTitle && !content.includes(summary.headerTitle)) {
errors.push(`${file.path}: 未体现截图摘要中的标题 "${summary.headerTitle}"`);
}
for (const label of summary.filterGroupLabels || []) {
if (label && !content.includes(label)) {
errors.push(`${file.path}: 未体现截图摘要中的筛选分组标签 "${label}"`);
}
}
if (summary.requiredSelectCount > 0) {
const selectCount = countMatches(/<VSelect\b/g, content) + countMatches(/<ElSelect\b/g, content);
if (selectCount < summary.requiredSelectCount) {
errors.push(
`${file.path}: 筛选选择框数量不足,截图摘要期望至少 ${summary.requiredSelectCount} 个,当前检测到 ${selectCount} 个`,
);
}
}
if (summary.searchLabel && !content.includes(summary.searchLabel)) {
warnings.push(`${file.path}: 未检测到截图摘要中的搜索标签 "${summary.searchLabel}"`);
}
if (summary.primaryActionLabel && !content.includes(summary.primaryActionLabel)) {
errors.push(`${file.path}: 未体现截图摘要中的主按钮文案 "${summary.primaryActionLabel}"`);
}
if (Array.isArray(summary.tableColumns) && summary.tableColumns.length > 0) {
const presentColumns = summary.tableColumns.filter((column) => content.includes(column));
const minimumColumns = Math.max(summary.tableColumns.length - 1, 1);
if (presentColumns.length < minimumColumns) {
errors.push(
`${file.path}: 表格列命中不足,截图摘要要求 ${summary.tableColumns.length} 列,当前仅命中 ${presentColumns.length} 列`,
);
}
}
if (summary.actionLinkLabel && !content.includes(summary.actionLinkLabel)) {
errors.push(`${file.path}: 未体现截图摘要中的操作文案 "${summary.actionLinkLabel}"`);
}
if (summary.pagination?.present) {
if (!/<ElPagination\b/.test(content)) {
errors.push(`${file.path}: 截图摘要要求存在分页组件,但当前页面未检测到 ElPagination`);
}
if (summary.pagination.totalTextVisible && !/layout\s*=\s*"[^"]*total/.test(content)) {
errors.push(`${file.path}: 截图摘要要求分页显示总数,但分页 layout 未包含 total`);
}
if (summary.pagination.pageSizeSelectorVisible && !/layout\s*=\s*"[^"]*sizes/.test(content)) {
errors.push(`${file.path}: 截图摘要要求分页显示每页条数选择器,但分页 layout 未包含 sizes`);
}
if (summary.pagination.jumperVisible && !/layout\s*=\s*"[^"]*jumper/.test(content)) {
errors.push(`${file.path}: 截图摘要要求分页显示 jumper,但分页 layout 未包含 jumper`);
}
if (summary.pagination.containerAlignment === "split") {
const hasSplitLayout =
/\.pagination-[\w-]+\s*\{[\s\S]*justify-content:\s*space-between/u.test(content) ||
/\.pagination-[\w-]+\s*\{[\s\S]*display:\s*grid/u.test(content);
if (!hasSplitLayout) {
warnings.push(`${file.path}: 截图摘要提示分页区域应左右拆分布局,当前未检测到明显的 split 布局样式`);
}
}
}
}
return { errors, warnings };
}
function validatePrimaryFigmaDataAdherence({ response, bundle, bundlePath }) {
const errors = [];
const warnings = [];
const designContext = readDesignContext(bundle, bundlePath);
if (!designContext) {
return { errors, warnings };
}
const primaryFacts = extractPrimaryFigmaFacts(designContext);
const viewFiles = response.files.filter((file) => /^src\/views\/.+\.vue$/u.test(file.path));
for (const file of viewFiles) {
const content = file.content;
if (
primaryFacts.toolbarSearchLabel &&
!new RegExp(`${primaryFacts.toolbarSearchLabel.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`)}\\s*`, "u").test(content)
) {
errors.push(`${file.path}: 未体现 Figma 原始数据中的工具栏标签 "${primaryFacts.toolbarSearchLabel}"`);
}
if (primaryFacts.toolbarSearchPlaceholder && !content.includes(primaryFacts.toolbarSearchPlaceholder)) {
errors.push(`${file.path}: 未体现 Figma 原始数据中的输入框占位符 "${primaryFacts.toolbarSearchPlaceholder}"`);
}
if (primaryFacts.toolbarControlOrder.length > 0 && primaryFacts.toolbarActionLabel) {
const toolbarSearchBlockMatch = content.match(
/<div class="toolbar-search">[\s\S]*?<span class="search-label">[\s\S]*?<\/span>[\s\S]*?<(VInput|ElInput)\b[\s\S]*?<\/div>/u,
);
if (!toolbarSearchBlockMatch) {
errors.push(`${file.path}: 未检测到包含标签和文本输入框的工具栏搜索区块`);
} else {
const toolbarSearchBlock = toolbarSearchBlockMatch[0];
if (!/(<VInput\b|<ElInput\b)/u.test(toolbarSearchBlock)) {
errors.push(`${file.path}: 工具栏搜索区应使用文本输入框,而不是其他输入组件`);
}
if (/<VSelect\b|<ElSelect\b|multiple|tags/u.test(toolbarSearchBlock)) {
errors.push(`${file.path}: 工具栏搜索区应为单值文本输入框,不应生成数组/多值输入形态`);
}
}
const toolbarBlockMatch = content.match(/<div class="toolbar(?:-section)?">[\s\S]*?<\/div>\s*<\/div>/u);
if (toolbarBlockMatch) {
const toolbarBlock = toolbarBlockMatch[0];
const orderPattern =
/<span class="search-label">[\s\S]*?<\/span>[\s\S]*?<(VInput|ElInput)\b[\s\S]*?<(VButton|ElButton)\b[\s\S]*?>[\s\S]*?查询[\s\S]*?<\/(VButton|ElButton)>/u;
if (!orderPattern.test(toolbarBlock)) {
errors.push(`${file.path}: 工具栏控件顺序应为“标签 -> 文本输入框 -> 查询按钮”,且查询按钮需位于输入框后面`);
}
}
}
const searchInputMatch = content.match(/<(VInput|ElInput)\b[\s\S]*?v-model="([^"]+)"/u);
if (searchInputMatch?.[2]) {
const modelExpression = searchInputMatch[2];
const escapedModel = modelExpression.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`);
const stringModelPatterns = [
new RegExp(`${escapedModel}\\s*:\\s*["'\`]`, "u"),
new RegExp(`${escapedModel}\\s*:\\s*ref\\(\\s*["'\`]`, "u"),
new RegExp(`const\\s+${escapedModel}(?::\\s*[^=]+)?\\s*=\\s*["'\`]`, "u"),
new RegExp(`const\\s+${escapedModel}(?::\\s*[^=]+)?\\s*=\\s*ref(?:<[^>]+>)?\\(\\s*["'\`]`, "u"),
];
if (!stringModelPatterns.some((pattern) => pattern.test(content))) {
warnings.push(`${file.path}: 未明确检测到搜索字段使用 string 类型初始化,建议保持文本输入绑定到单值字符串字段`);
}
}
const tableDataMatch =
content.match(/<VTable\b[\s\S]*?:data="([^"]+)"/u) || content.match(/<ElTable\b[\s\S]*?:data="([^"]+)"/u);
if (tableDataMatch?.[1]) {
const dataVarName = tableDataMatch[1];
const escapedVarName = dataVarName.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`);
const hasNonEmptyData = [
new RegExp(`const\\s+${escapedVarName}(?::\\s*[^=]+)?\\s*=\\s*\\[\\s*\\{`, "u"),
new RegExp(`const\\s+${escapedVarName}(?::\\s*[^=]+)?\\s*=\\s*ref(?:<[^>]+>)?\\(\\s*\\[\\s*\\{`, "u"),
new RegExp(`const\\s+${escapedVarName}(?::\\s*[^=]+)?\\s*=\\s*reactive(?:<[^>]+>)?\\(\\s*\\[\\s*\\{`, "u"),
new RegExp(`const\\s+${escapedVarName}\\s*=\\s*Array\\.from\\(\\s*\\{\\s*length:\\s*[1-9]\\d*`, "u"),
new RegExp(`const\\s+${escapedVarName}(?::\\s*[^=]+)?\\s*=\\s*ref(?:<[^>]+>)?\\(\\s*Array\\.from\\(\\s*\\{\\s*length:\\s*[1-9]\\d*`, "u"),
].some((pattern) => pattern.test(content));
if (!hasNonEmptyData) {
errors.push(`${file.path}: 表格已绑定数据源 "${dataVarName}",但未检测到非空示例数据`);
}
if (primaryFacts.tableSampleTexts.length > 0) {
const sampleHits = primaryFacts.tableSampleTexts.filter((item) => content.includes(item)).length;
if (sampleHits === 0) {
warnings.push(`${file.path}: 未检测到 Figma 原始数据中的表格示例文本,建议优先复用设计稿里的示例值`);
}
}
} else if (/<VTable\b|<ElTable\b/u.test(content)) {
errors.push(`${file.path}: 检测到表格组件,但未找到明确的 :data 数据绑定`);
}
if (primaryFacts.tableShouldFillWidth) {
const hasFullWidthContainer =
/\.table-section\s*\{[\s\S]*width:\s*100%/u.test(content) ||
/\.table-[\w-]+\s*\{[\s\S]*width:\s*100%/u.test(content);
const hasFullWidthTable =
/:deep\(\.v-table\)\s*\{[\s\S]*width:\s*100%/u.test(content) ||
/:deep\(\.el-table\)\s*\{[\s\S]*width:\s*100%/u.test(content) ||
/\.[\w-]*table[\w-]*\s*\{[\s\S]*width:\s*100%/u.test(content);
if (!hasFullWidthContainer || !hasFullWidthTable) {
errors.push(`${file.path}: Figma 原始数据要求表格横向铺满容器,当前未检测到完整的满宽表格样式`);
}
}
if (primaryFacts.tableHeaderBackground) {
const hasHeaderBackground =
/:deep\(\.v-table th\)\s*\{[\s\S]*background-color:\s*#f5f7fa/u.test(content) ||
/:deep\(\.v-table th\)\s*\{[\s\S]*background-color:\s*#f4f6fc/u.test(content) ||
/:deep\(\.el-table__header th\)\s*\{[\s\S]*background-color:\s*#f5f7fa/u.test(content) ||
/:deep\(\.el-table__header th\)\s*\{[\s\S]*background-color:\s*#f4f6fc/u.test(content);
if (!hasHeaderBackground) {
errors.push(`${file.path}: Figma 原始数据要求表头具有浅灰背景色,当前未检测到对应样式`);
}
}
if (primaryFacts.paginationAlignment === "left") {
const hasLeftPagination =
/\.pagination-container\s*\{[\s\S]*justify-content:\s*flex-start/u.test(content) ||
/\.pagination-section\s*\{[\s\S]*justify-content:\s*flex-start/u.test(content) ||
/:deep\(\.el-pagination\)\s*\{[\s\S]*justify-content:\s*flex-start/u.test(content);
if (!hasLeftPagination) {
errors.push(`${file.path}: Figma 原始数据要求分页器左对齐,当前未检测到 justify-content: flex-start`);
}
}
if (primaryFacts.paginationActivePageBackground) {
const hasActivePagerStyle =
/:deep\(\.el-pager li\.is-active\)\s*\{[\s\S]*background-color:\s*#5850ff/u.test(content) ||
/:deep\(\.el-pager li\.is-active\)\s*\{[\s\S]*background:\s*#5850ff/u.test(content);
const hasPagerRadius =
/:deep\(\.el-pager li\.is-active\)\s*\{[\s\S]*border-radius:\s*([234])px/u.test(content);
if (!hasActivePagerStyle || !hasPagerRadius) {
errors.push(`${file.path}: Figma 原始数据要求当前页码具有实色方形背景,当前未检测到完整的激活页样式`);
}
}
}
return { errors, warnings };
}
function runCommand(command, cwd) { function runCommand(command, cwd) {
const startedAt = Date.now();
// #region debug-point B:command-start
reportDebugEvent("B", "scripts/ai-direct-validate-output.mjs:runCommand:start", "[DEBUG] validate subcommand start", {
command,
cwd: normalizePath(cwd),
});
// #endregion
const result = childProcess.spawnSync(command, { const result = childProcess.spawnSync(command, {
cwd, cwd,
shell: true, shell: true,
encoding: "utf8", encoding: "utf8",
}); });
// #region debug-point B:command-end
reportDebugEvent("B", "scripts/ai-direct-validate-output.mjs:runCommand:end", "[DEBUG] validate subcommand end", {
command,
cwd: normalizePath(cwd),
exitCode: result.status ?? 1,
durationMs: Date.now() - startedAt,
});
// #endregion
return { return {
command, command,
...@@ -258,9 +669,19 @@ function run() { ...@@ -258,9 +669,19 @@ function run() {
console.log("[ai-direct-validate-output] 校验 AI 结果..."); console.log("[ai-direct-validate-output] 校验 AI 结果...");
console.log(` → response: ${responsePath}`); console.log(` → response: ${responsePath}`);
console.log(` → project: ${projectRoot}`); console.log(` → project: ${projectRoot}`);
// #region debug-point B:validate-start
reportDebugEvent("B", "scripts/ai-direct-validate-output.mjs:run:start", "[DEBUG] validate entry", {
responseFile: normalizePath(responsePath),
previewFile: normalizePath(previewPath),
projectRoot: normalizePath(projectRoot),
changedFilesCount: changedFiles.length,
});
// #endregion
const uiRuleResult = validateUiRules({ response, bundle, preview }); const uiRuleResult = validateUiRules({ response, bundle, preview });
const styleOwnershipResult = validateGeneratedStyleOwnership({ response, bundle, preview }); const styleOwnershipResult = validateGeneratedStyleOwnership({ response, bundle, preview });
const primaryDataResult = validatePrimaryFigmaDataAdherence({ response, bundle, bundlePath });
const visualSummaryResult = validateVisualSummaryAdherence({ response, bundle, bundlePath });
const commands = [ const commands = [
runCommand(`node scripts/lint-changed.mjs ${changedFiles.map((file) => `"${file}"`).join(" ")}`, repoRoot), runCommand(`node scripts/lint-changed.mjs ${changedFiles.map((file) => `"${file}"`).join(" ")}`, repoRoot),
runCommand(`node scripts/review-trigger.mjs ${changedFiles.map((file) => `"${file}"`).join(" ")}`, repoRoot), runCommand(`node scripts/review-trigger.mjs ${changedFiles.map((file) => `"${file}"`).join(" ")}`, repoRoot),
...@@ -275,7 +696,11 @@ function run() { ...@@ -275,7 +696,11 @@ function run() {
const failedCommands = commands.filter((item) => !item.ok).map((item) => `${item.command} (exit=${item.exitCode})`); const failedCommands = commands.filter((item) => !item.ok).map((item) => `${item.command} (exit=${item.exitCode})`);
const status = const status =
uiRuleResult.errors.length === 0 && styleOwnershipResult.errors.length === 0 && failedCommands.length === 0 uiRuleResult.errors.length === 0 &&
styleOwnershipResult.errors.length === 0 &&
primaryDataResult.errors.length === 0 &&
visualSummaryResult.errors.length === 0 &&
failedCommands.length === 0
? "passed" ? "passed"
: "failed"; : "failed";
...@@ -291,6 +716,8 @@ function run() { ...@@ -291,6 +716,8 @@ function run() {
files: changedFiles, files: changedFiles,
ruleValidation: uiRuleResult, ruleValidation: uiRuleResult,
styleValidation: styleOwnershipResult, styleValidation: styleOwnershipResult,
primaryDataValidation: primaryDataResult,
visualSummaryValidation: visualSummaryResult,
commandResults: commands, commandResults: commands,
}; };
...@@ -299,6 +726,16 @@ function run() { ...@@ -299,6 +726,16 @@ function run() {
`${path.basename(responsePath, path.extname(responsePath))}.validation-result.json`, `${path.basename(responsePath, path.extname(responsePath))}.validation-result.json`,
); );
fs.writeFileSync(summaryPath, `${JSON.stringify(summary, null, 2)}\n`, "utf8"); fs.writeFileSync(summaryPath, `${JSON.stringify(summary, null, 2)}\n`, "utf8");
// #region debug-point D:validate-summary-written
reportDebugEvent("D", "scripts/ai-direct-validate-output.mjs:run:summary", "[DEBUG] validation summary written", {
summaryPath: normalizePath(summaryPath),
status,
ruleErrorCount: uiRuleResult.errors.length,
styleErrorCount: styleOwnershipResult.errors.length,
visualErrorCount: visualSummaryResult.errors.length,
failedCommandCount: failedCommands.length,
});
// #endregion
if (uiRuleResult.errors.length > 0) { if (uiRuleResult.errors.length > 0) {
console.error("[ai-direct-validate-output] 规则校验失败:"); console.error("[ai-direct-validate-output] 规则校验失败:");
...@@ -322,6 +759,28 @@ function run() { ...@@ -322,6 +759,28 @@ function run() {
console.warn(`[ai-direct-validate-output] warning: ${warning}`); console.warn(`[ai-direct-validate-output] warning: ${warning}`);
} }
if (primaryDataResult.errors.length > 0) {
console.error("[ai-direct-validate-output] Figma 原始数据校验失败:");
for (const error of primaryDataResult.errors) {
console.error(` - ${error}`);
}
}
for (const warning of primaryDataResult.warnings) {
console.warn(`[ai-direct-validate-output] warning: ${warning}`);
}
if (visualSummaryResult.errors.length > 0) {
console.error("[ai-direct-validate-output] 截图视觉摘要校验失败:");
for (const error of visualSummaryResult.errors) {
console.error(` - ${error}`);
}
}
for (const warning of visualSummaryResult.warnings) {
console.warn(`[ai-direct-validate-output] warning: ${warning}`);
}
if (failedCommands.length > 0) { if (failedCommands.length > 0) {
console.error("[ai-direct-validate-output] 命令校验失败:"); console.error("[ai-direct-validate-output] 命令校验失败:");
for (const item of failedCommands) { for (const item of failedCommands) {
......
...@@ -596,6 +596,13 @@ function validateAiDirectContextBundle(data, file) { ...@@ -596,6 +596,13 @@ function validateAiDirectContextBundle(data, file) {
if ("screenshotFile" in data.artifacts) { if ("screenshotFile" in data.artifacts) {
check(typeof data.artifacts.screenshotFile === "string", file, "artifacts.screenshotFile must be a string"); check(typeof data.artifacts.screenshotFile === "string", file, "artifacts.screenshotFile must be a string");
} }
if ("screenshotSummaryFile" in data.artifacts) {
check(
typeof data.artifacts.screenshotSummaryFile === "string",
file,
"artifacts.screenshotSummaryFile must be a string",
);
}
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!