Commit 38c27cc6 by liimin

fix: restore pre-rebase changes including vision model config, design spec coord…

…s, and VUI mobile pipeline fixes
1 parent f6965f9f
......@@ -13,6 +13,7 @@
3. 涉及治理流程时,阅读 `docs/architecture/ai-governance.md`。
4. 涉及质量门禁时,阅读 `docs/fitness/README.md` 及其引用的维度文档。
5. 修改 `packages/cli/templates/**` 前,先阅读 `contracts/templates/*.contract.json`。
6. 生成代码前,阅读 `docs/ai/ai-anti-patterns.md`,避免重复已知错误。
## 仓库地图
......
......@@ -96,6 +96,14 @@ Venus CLI 模板已生成完整的路由文件(`src/router/index.ts` 或 `src/
## 设计稿还原规则
### 布局顺序
- **layoutOrder 是强制约束**:如果截图摘要中包含 layoutOrder 字段,你必须严格按照该顺序组织页面区块,不得擅自调整顺序
- 区块顺序错误会导致页面信息流混乱,属于严重的还原度问题
- 即使某些区块在逻辑上"应该"放在一起,也必须遵守设计稿声明的顺序
### 布局线索
- 必须优先依据 Figma design context 中可见的布局线索还原页面:direction、gap、padding、宽高、对齐方式、字号、字重、边框、圆角、背景色和分区层次
- 不要把设计稿简化成通用后台 demo 壳;若设计中没有额外标题、副标题、说明卡片或装饰块,不要自行添加
- 筛选区、工具栏、表格区和分页区应按设计中的分组关系与横纵节奏摆放,避免平均铺满导致布局松散
......@@ -103,6 +111,12 @@ Venus CLI 模板已生成完整的路由文件(`src/router/index.ts` 或 `src/
- 表格列宽、下拉框宽度、输入框宽度等尺寸属性应优先从 Figma 原始数据中读取;设计稿未指定固定宽度时,让组件按容器自适应分配
- 使用 VUI/Element Plus 组件时,必须严格按组件 manifest 的 API 约定:slot 名称、prop 类型、列 key 必须与 manifest 声明一致
### 颜色忠实度
- **颜色值必须原样使用**:设计稿中指定的颜色值(如 `rgba(255,255,255,1)`、`#185efe`)必须原样出现在生成代码中,禁止用"合理推断"覆盖
- **白色文字意味着深色背景**:如果设计稿中某元素使用白色文字(`color: #fff` 或 `rgba(255,255,255,1)`),说明其背景为深色或图片,必须保留设计稿的背景上下文,不要擅自改为浅色背景
- **对比度优先于"常识"**:不要用"白底灰字更合理"这类常识覆盖设计稿的颜色对比关系,设计稿的颜色选择经过专业考量
## 样式规则
- 生成的页面必须包含完整的页面级样式;筛选区、表格区、卡片、间距、字号、宽度和响应式处理不能留给人工补救
......
......@@ -38,6 +38,8 @@
"ai:repair-output": "node scripts/ai-direct-repair-output.mjs",
"ai:validate-output": "node scripts/ai-direct-validate-output.mjs",
"ai:execute": "node scripts/ai-direct-execute.mjs",
"ai:analytics": "node scripts/ai-contribution-analytics.mjs",
"ai:capture-pitfalls": "node scripts/capture-ai-pitfalls.mjs",
"check:fitness": "node tools/fitness/engine.mjs",
"check:template-contract": "node scripts/validate-template-contracts.mjs",
"check:type": "turbo run typecheck",
......
......@@ -3,7 +3,7 @@
"packageName": "@vui/mobile",
"packageRoot": "packages/vui/mobile",
"framework": "vue",
"notes": "VUI Mobile 组件语义索引,面向移动端 H5,底层基于 Vant 4。当前覆盖 VButton、VCell、VDropdownMenu、VDropdownItem、VField、VList、VNavBar、VPicker、VPopup、VSearch、VTabbar。",
"notes": "VUI Mobile 组件语义索引,面向移动端 H5,底层基于 Vant 4。当前覆盖 VButton、VCard、VCell、VDropdownMenu、VDropdownItem、VField、VImage、VList、VNavBar、VPicker、VPopup、VSearch、VSwiper、VTabbar、VTabs。",
"components": [
{
"exportName": "VButton",
......@@ -11,6 +11,11 @@
"source": "src/components/VButton/VButton.vue"
},
{
"exportName": "VCard",
"manifest": "src/components/VCard/VCard.manifest.json",
"source": "src/components/VCard/VCard.vue"
},
{
"exportName": "VCell",
"manifest": "src/components/VCell/VCell.manifest.json",
"source": "src/components/VCell/VCell.vue"
......@@ -31,6 +36,11 @@
"source": "src/components/VField/VField.vue"
},
{
"exportName": "VImage",
"manifest": "src/components/VImage/VImage.manifest.json",
"source": "src/components/VImage/VImage.vue"
},
{
"exportName": "VList",
"manifest": "src/components/VList/VList.manifest.json",
"source": "src/components/VList/VList.vue"
......@@ -56,9 +66,19 @@
"source": "src/components/VSearch/VSearch.vue"
},
{
"exportName": "VSwiper",
"manifest": "src/components/VSwiper/VSwiper.manifest.json",
"source": "src/components/VSwiper/VSwiper.vue"
},
{
"exportName": "VTabbar",
"manifest": "src/components/VTabbar/VTabbar.manifest.json",
"source": "src/components/VTabbar/VTabbar.vue"
},
{
"exportName": "VTabs",
"manifest": "src/components/VTabs/VTabs.manifest.json",
"source": "src/components/VTabs/VTabs.vue"
}
]
}
export { default as VButton } from "./VButton";
export { default as VCard } from "./VCard";
export { default as VCell } from "./VCell";
export { default as VDropdownItem } from "./VDropdownItem";
export { default as VDropdownMenu } from "./VDropdownMenu";
export { default as VField } from "./VField";
export { default as VImage } from "./VImage";
export { default as VList } from "./VList";
export { default as VNavBar } from "./VNavBar";
export { default as VPicker } from "./VPicker";
export { default as VPopup } from "./VPopup";
export { default as VSearch } from "./VSearch";
export { default as VSwiper } from "./VSwiper";
export { default as VTabbar } from "./VTabbar";
export { default as VTabs } from "./VTabs";
......@@ -1073,6 +1073,10 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
const primaryDataWarnings = validation.primaryDataValidation?.warnings || [];
const visualSummaryErrors = validation.visualSummaryValidation?.errors || [];
const visualSummaryWarnings = validation.visualSummaryValidation?.warnings || [];
const templateSyntaxErrors = validation.templateSyntaxValidation?.errors || [];
const templateSyntaxWarnings = validation.templateSyntaxValidation?.warnings || [];
const designFidelityErrors = validation.designFidelityValidation?.errors || [];
const designFidelityWarnings = validation.designFidelityValidation?.warnings || [];
const feedback = {
meta: {
......@@ -1096,6 +1100,10 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
primaryDataWarnings,
visualSummaryErrors,
visualSummaryWarnings,
templateSyntaxErrors,
templateSyntaxWarnings,
designFidelityErrors,
designFidelityWarnings,
failedCommands: failedCommands.map((item) => ({
command: item.command,
exitCode: item.exitCode,
......@@ -1130,6 +1138,12 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
for (const error of visualSummaryErrors) {
requestLines.push(`- Visual Summary Error: ${error}`);
}
for (const error of templateSyntaxErrors) {
requestLines.push(`- Template Syntax Error: ${error}`);
}
for (const error of designFidelityErrors) {
requestLines.push(`- Design Fidelity Error: ${error}`);
}
for (const warning of ruleWarnings) {
requestLines.push(`- Rule Warning: ${warning}`);
}
......@@ -1142,6 +1156,12 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
for (const warning of visualSummaryWarnings) {
requestLines.push(`- Visual Summary Warning: ${warning}`);
}
for (const warning of templateSyntaxWarnings) {
requestLines.push(`- Template Syntax Warning: ${warning}`);
}
for (const warning of designFidelityWarnings) {
requestLines.push(`- Design Fidelity Warning: ${warning}`);
}
for (const command of feedback.failedCommands) {
requestLines.push(`- Command Failure: ${command.command} (exit=${command.exitCode})`);
if (command.stderr) {
......@@ -1164,6 +1184,12 @@ function buildRepairArtifacts({ bundle, preview, response, validation, responseP
"- 只修复失败项,不要引入新的 UI 包违规。",
"- 如果失败项来自 Figma 原始数据校验,优先保留 design context 中明确给出的标签、placeholder、列名和示例数据,不要让截图摘要覆盖这些文本事实。",
"- 如果失败项来自截图视觉摘要校验,优先修正标题、筛选标签、选择框数量、表格列、操作文案和分页布局,使页面与截图摘要一致。",
"- 如果失败项来自设计还原度校验,必须严格按照 layoutOrder / sectionOrder 顺序重新排列页面区块,并将设计稿中的关键颜色值原样写入 CSS,禁止用'合理推断'覆盖。",
"- 如果失败项涉及 grid 列数不匹配,必须修改 CSS 的 grid-template-columns 使其与截图摘要指定的 columns 值一致。例如:columns=2 → `grid-template-columns: repeat(2, 1fr)`。",
"- 如果失败项涉及 flex-direction 错误(如 direction=row 但代码用了 column),必须修改 CSS 的 flex-direction 为 row,或移除 flex-direction: column 让其默认为 row。",
"- 如果失败项涉及底部固定操作栏缺失,必须添加一个 position: fixed; bottom: 0; left: 0; right: 0 的容器,并在其中放置指定按钮。",
"- 如果失败项涉及浮动元素位置错误(如 left-top 实际在 left-bottom),必须修改 CSS 的 position: absolute 定位属性,将 top/bottom/left/right 对应到正确方位。",
"- 如果失败项涉及区块顺序错误,必须调整 template 中 DOM 元素的顺序使其与 sectionOrder/layoutOrder 一致。",
"- 如果失败项来自样式责任校验,直接在生成文件中补齐页面级样式,不要把布局或视觉修复转嫁给预览项目壳层。",
"- 输出完整结构化 JSON,沿用既定 response schema。",
);
......@@ -1566,6 +1592,16 @@ async function run() {
_log(`[ai-direct-execute] → 样式: ${styleErrors.length} 错误, ${styleWarnings.length} 警告`);
_log(`[ai-direct-execute] → 主数据: ${primaryErrors.length} 错误`);
_log(`[ai-direct-execute] → 视觉摘要: ${visualErrors.length} 错误, ${visualWarnings.length} 警告`);
const templateSyntaxErrors = validation.templateSyntaxValidation?.errors || [];
const templateSyntaxWarnings = validation.templateSyntaxValidation?.warnings || [];
const designFidelityErrors = validation.designFidelityValidation?.errors || [];
const designFidelityWarnings = validation.designFidelityValidation?.warnings || [];
if (templateSyntaxErrors.length > 0 || templateSyntaxWarnings.length > 0) {
_log(`[ai-direct-execute] → Template语法: ${templateSyntaxErrors.length} 错误, ${templateSyntaxWarnings.length} 警告`);
}
if (designFidelityErrors.length > 0 || designFidelityWarnings.length > 0) {
_log(`[ai-direct-execute] → 设计还原: ${designFidelityErrors.length} 错误, ${designFidelityWarnings.length} 警告`);
}
if (pageStructureErrors.length > 0 || pageStructureWarnings.length > 0) {
_log(`[ai-direct-execute] → 页面目录: ${pageStructureErrors.length} 错误, ${pageStructureWarnings.length} 警告`);
}
......@@ -1642,16 +1678,12 @@ async function run() {
repairArgs.push("--model", args.model);
}
// Repair 超时 90 秒,超时则跳过
_log(`[ai-direct-execute] → Repair 最多等待 90 秒...`);
runNodeScript("ai-direct-repair-output.mjs", repairArgs, 90_000);
// Repair 不设超时限制,让 AI 充分完成复杂修复
_log(`[ai-direct-execute] → Repair 执行中...`);
runNodeScript("ai-direct-repair-output.mjs", repairArgs, 0);
} catch (repairError) {
const msg = repairError.message || String(repairError);
if (msg.includes("timeout") || msg.includes("TIMEOUT")) {
_warn(`[ai-direct-execute] ⚠ Repair 超时(90秒),跳过本轮 repair`);
} else {
_warn(`[ai-direct-execute] ⚠ Repair 执行失败: ${msg}`);
}
_warn(`[ai-direct-execute] ⚠ Repair 执行失败: ${msg}`);
}
latestResponse = unwrapResponseFile(aiResult.responsePath);
......
......@@ -20,7 +20,7 @@
"cliTemplate": "mobile",
"cliUiOption": "vant",
"componentHints": [
"第一顺位使用 @vui/mobile 组件:VButton、VCell、VDropdownMenu、VDropdownItem、VField、VList、VNavBar、VPicker、VPopup、VSearch、VTabbar",
"第一顺位使用 @vui/mobile 组件:VButton、VCard、VCell、VDropdownMenu、VDropdownItem、VField、VImage、VList、VNavBar、VPicker、VPopup、VSearch、VSwiper、VTabbar、VTabs",
"若 @vui/mobile 未覆盖当前场景,降级到 Vant 4 原生组件(van-field、van-picker、van-cell 等)",
"Vant 4 基于 Vue 3 + TypeScript,组件使用 kebab-case 前缀 van-",
"第三顺位使用 HTML 原生组件",
......
......@@ -100,27 +100,61 @@ async function callOpenAiCompatible(messages, model) {
}
const endpoint = `${baseUrl.replace(/\/$/, "")}/chat/completions`;
const timeoutMs = 300_000; // 5 分钟
const response = await fetch(endpoint, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${apiKey}`,
connection: "close",
},
signal: AbortSignal.timeout(timeoutMs),
body: JSON.stringify({
model: resolvedModel,
temperature: 0.1,
response_format: { type: "json_object" },
messages,
}),
});
const timeoutMs = 600_000; // 10 分钟
const maxRetries = 3;
const retryDelayMs = 5000;
let response;
let lastError;
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
response = await fetch(endpoint, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${apiKey}`,
connection: "close",
},
signal: AbortSignal.timeout(timeoutMs),
body: JSON.stringify({
model: resolvedModel,
temperature: 0.1,
response_format: { type: "json_object" },
messages,
}),
});
if (response.ok) {
break;
}
// 非 2xx 响应,可能是临时错误,重试
const errorText = (await response.text()).trim();
lastError = `AI provider 请求失败: ${response.status} ${response.statusText}${errorText ? ` | ${errorText.slice(0, 600)}` : ""}`;
// 4xx 错误不重试(客户端错误)
if (response.status >= 400 && response.status < 500) {
throw new Error(lastError);
}
console.warn(`[ai-direct-repair] 请求失败 (${response.status}),${retryDelayMs / 1000}秒后重试 (${attempt}/${maxRetries})...`);
} catch (fetchError) {
lastError = fetchError.message;
// 超时错误不重试
if (fetchError.name === "TimeoutError" || fetchError.message.includes("timeout")) {
throw fetchError;
}
console.warn(`[ai-direct-repair] 网络错误: ${fetchError.message},${retryDelayMs / 1000}秒后重试 (${attempt}/${maxRetries})...`);
}
if (attempt < maxRetries) {
await new Promise((resolve) => setTimeout(resolve, retryDelayMs * attempt));
}
}
if (!response.ok) {
const errorText = (await response.text()).trim();
const errorPreview = errorText ? ` | ${errorText.slice(0, 600)}` : "";
throw new Error(`AI provider 请求失败: ${response.status} ${response.statusText}${errorPreview}`);
if (!response || !response.ok) {
throw new Error(lastError || "AI provider 请求失败(未知错误)");
}
let payload;
......
......@@ -14,6 +14,7 @@ const commands = [
{ id: "review-trigger", command: "pnpm run review:trigger" },
{ id: "file-budget", command: "pnpm run check:file-budget" },
{ id: "fitness", command: `pnpm run check:fitness -- --tier ${tier}` },
{ id: "capture-pitfalls", command: "pnpm run ai:capture-pitfalls", allowFail: true },
];
for (const step of commands) {
......@@ -25,8 +26,12 @@ for (const step of commands) {
});
if (status.status !== 0) {
console.error(`[smart-check] failed at ${step.id}`);
process.exit(status.status ?? 1);
if (step.allowFail) {
console.warn(`[smart-check] ${step.id} exited with ${status.status} (non-blocking)`);
} else {
console.error(`[smart-check] failed at ${step.id}`);
process.exit(status.status ?? 1);
}
}
}
......
......@@ -10,7 +10,7 @@ export const DEFAULT_CONFIG = {
aiBaseUrl: process.env.AI_DIRECT_OPENAI_BASE_URL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
aiApiKey: process.env.AI_DIRECT_OPENAI_API_KEY || "sk-954dfaed75e040b6a06f9c908b0a8c85",
aiModel: process.env.AI_DIRECT_OPENAI_MODEL || "qwen3.7-max",
visionModel: process.env.AI_DIRECT_VISION_MODEL || "qwen3.6-plus",
visionModel: process.env.AI_DIRECT_VISION_MODEL || "qwen-vl-max",
skipScreenshotSummary: false,
};
......@@ -24,6 +24,11 @@ export const MODEL_CANDIDATES = [
{ label: "DeepSeek R1", value: "deepseek-r1" },
];
export const VISION_MODEL_CANDIDATES = [
{ label: "Qwen VL Max", value: "qwen-vl-max" },
{ label: "Qwen VL Plus", value: "qwen-vl-plus" },
];
export const URL_CANDIDATES = [
{ label: "阿里云 DashScope", value: "https://dashscope.aliyuncs.com/compatible-mode/v1" },
{ label: "OpenAI Official", value: "https://api.openai.com/v1" },
......
......@@ -8,7 +8,7 @@ import http from "node:http";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { DEFAULT_CONFIG, MODEL_CANDIDATES, PORT, URL_CANDIDATES } from "./config.mjs";
import { DEFAULT_CONFIG, MODEL_CANDIDATES, PORT, URL_CANDIDATES, VISION_MODEL_CANDIDATES } from "./config.mjs";
import { runPipeline } from "./pipeline.mjs";
import { listBundlePages, listGeneratedFiles, listPreviewProjects } from "./preview-project.mjs";
import { getCurrentProcess, getIsRunning } from "./process-manager.mjs";
......@@ -217,6 +217,7 @@ async function handleApi(req, res, repoRoot) {
if (url === "/api/config" && method === "GET") {
sendJson(res, {
modelCandidates: MODEL_CANDIDATES,
visionModelCandidates: VISION_MODEL_CANDIDATES,
urlCandidates: URL_CANDIDATES,
defaults: DEFAULT_CONFIG,
});
......
......@@ -34,7 +34,10 @@
<input type="password" id="aiApiKey" placeholder="sk-...">
</label>
<label>视觉模型
<input type="text" id="visionModel" placeholder="qwen-vl-max">
<select id="visionModel">
<option value="qwen-vl-max">Qwen VL Max</option>
<option value="qwen-vl-plus">Qwen VL Plus</option>
</select>
</label>
</div>
</div>
......
......@@ -96,6 +96,17 @@ function init() {
opt.textContent = u.label;
urlSel.append(opt);
});
// 填充视觉模型下拉
const visionSel = document.querySelector("#visionModel");
if (data.visionModelCandidates) {
visionSel.innerHTML = "";
data.visionModelCandidates.forEach((m) => {
const opt = document.createElement("option");
opt.value = m.value;
opt.textContent = m.label;
visionSel.append(opt);
});
}
document.querySelector("#aiBaseUrl").value = data.defaults.aiBaseUrl;
document.querySelector("#aiApiKey").value = data.defaults.aiApiKey;
document.querySelector("#visionModel").value = data.defaults.visionModel;
......
@echo off
cd /d "%~dp0"
echo Stopping server...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":3210" ^| findstr "LISTENING"') do taskkill /F /PID %%a >nul 2>&1
timeout /t 2 /nobreak >nul
......
......@@ -8,9 +8,10 @@
".vue": 700
},
"hotspots": {
"scripts/ai-direct-execute.mjs": 1701,
"scripts/ai-direct-execute.mjs": 1800,
"scripts/ai-direct-server.mjs": 1228,
"scripts/ai-direct-messages.mjs": 996,
"scripts/ai-direct-messages.mjs": 1500,
"scripts/ai-direct-validate-output.mjs": 1500,
"apps/uniappX/uniapp-x-tape/devTools/page/components/main.vue": 1668,
"apps/uniappX/uniapp-x-shop/uni_modules/cool-unix/cool/animation/index.ts": 1566,
"apps/web/venus-agentic/venus-agentic-base/src/views/Home.vue": 1125,
......@@ -26,6 +27,9 @@
"apps/uniappX/uniapp-x-tape/devTools/page/components/listItem/objectAnalysis.vue": 718,
"apps/frontend/vue/ai-demo/src/views/Communication.vue": 873,
"scripts/check-ai-artifacts.mjs": 647,
"scripts/ai-direct-context.mjs": 832
"scripts/ai-direct-context.mjs": 1100,
"scripts/ai-direct-spec.mjs": 400,
"scripts/ai-direct-theme.mjs": 450,
"scripts/mcp-bridge/figma-client.mjs": 850
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!