From c0d10b4025a7627ac44b5c5278f98a0252ea63c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 1 Sep 2026 13:26:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A7=20UI=20HTML=20Agent?= =?UTF-8?q?=20=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除 ui.design.to_html 与 agc_ui_design_to_html 的工具目录和分发逻辑 清理 Runtime policy、native catalog 与 DirectProject prompt 引用 保留 UI 编辑器直接生成代码能力 --- .../src-tauri/src/agent/direct_runtime.rs | 2 -- .../src-tauri/src/agent/direct_tools_mcp.rs | 28 ------------------- .../agent/runtime_actions/action_execution.rs | 1 - .../runtime_actions/autonomous_policy.rs | 1 - .../agent/runtime_actions/parallel_ledger.rs | 2 -- .../runtime_actions/tool_policy_snapshot.rs | 2 -- .../src-tauri/src/agent/runtime_tools.rs | 2 -- .../src/agent/runtime_tools/policy.rs | 1 - .../src/agent/runtime_tools/ui_html.rs | 14 ---------- .../src-tauri/src/agent_native_tools.rs | 11 -------- .../src/ui_editor/html_renderer/mod.rs | 19 ++++++------- 11 files changed, 9 insertions(+), 74 deletions(-) delete mode 100644 apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/ui_html.rs diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs index 6829b7598..c5105706d 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_runtime.rs @@ -3656,7 +3656,6 @@ fn build_direct_codex_system_prompt_with_search( "工作区边界:只在当前项目目录内工作;不要读取或输出凭据、Token、Cookie、auth.json、.env 或宿主私密路径。遇到阻断必须说明具体原因、文件和下一步,不要声称未验证的成功。".to_string(), "AGC 工具授权边界:DirectProject 的 agc_tools 由当前客户端桥接到 AGC 后端,使用客户端已有登录会话和受控凭据完成授权。用户不需要、也不得向你提供、配置、粘贴或创建 API Key、Token、Cookie、URL 或 .env。工具返回 401/403 时,只说明 AGC 客户端登录或权限状态异常并停止,不要索要凭据、猜测外部 API,也不要暴露内部 URL。".to_string(), DIRECT_AGC_ENGINEERING_GUIDANCE.to_string(), - "UI 设计 HTML 转换工具 `agc_tools.agc_ui_design_to_html` 当前暂未实现。".to_string(), "工程执行要求:优先复用现有结构;按需读取真实文件,不依赖客户端预注入源码快照;修改后运行与改动相关的本地验证。不要创建 Supervisor、专业 Agent 或平行项目。".to_string(), format!("提示词与技能:{skill_index}"), ]; @@ -4573,7 +4572,6 @@ mod tests { assert!(prompt.contains("agc_tools.taonier_prepare_game_art")); assert!(prompt.contains("agc_tools.agc_generate_image")); assert!(prompt.contains("agc_tools.agc_browser_playtest")); - assert!(prompt.contains("agc_tools.agc_ui_design_to_html")); assert!(prompt.contains("DirectProject 提供 Codex 原生文件、搜索、命令、图片查看、Skill")); assert!(!prompt.contains("客户端会在系统上下文提供有界的当前游戏文件快照")); assert!(prompt.contains("Codex 不直接保存或伪造项目版本")); diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs index 1ebb9dac5..a2ad7f737 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs @@ -356,23 +356,6 @@ fn direct_tools_mcp_specs_for(controlled_web_search: bool) -> Value { "additionalProperties": false } }), - json!({ - "name": "agc_ui_design_to_html", - "description": "UI 设计 HTML 转换工具当前暂未实现。", - "inputSchema": { - "type": "object", - "properties": { - "assetId": { - "type": "string", - "minLength": 1, - "maxLength": 160, - "description": "当前项目 manifest 中 kind=UI 的 JSON 设计资源 assetId" - } - }, - "required": ["assetId"], - "additionalProperties": false - } - }), ]; let mut tools = tools; if controlled_web_search { @@ -1014,15 +997,6 @@ async fn call_agc_browser_playtest(arguments: &Value) -> Value { call_client_tool_bridge("agc_browser_playtest", arguments).await } -fn call_agc_ui_design_to_html(root: &Path, arguments: &Value) -> Value { - let _ = (root, arguments); - mcp_tool_result( - "agc_ui_design_to_html 暂未实现".to_string(), - Vec::new(), - true, - ) -} - async fn call_agc_web_search(arguments: &Value) -> Value { if !controlled_web_search_enabled() { return mcp_tool_result("AGC 受控联网搜索未启用".to_string(), Vec::new(), true); @@ -1094,7 +1068,6 @@ async fn handle_direct_tools_mcp_request(root: &Path, request: Value) -> Option< } "agc_remove_background" => call_agc_remove_background(&arguments).await, "agc_browser_playtest" => call_agc_browser_playtest(&arguments).await, - "agc_ui_design_to_html" => call_agc_ui_design_to_html(root, &arguments), "agc_web_search" => call_agc_web_search(&arguments).await, _ => mcp_tool_result("未知或未审核的 AGC 工具".to_string(), Vec::new(), true), }; @@ -1230,7 +1203,6 @@ mod tests { "agc_create_or_derive_resource", "agc_remove_background", "agc_browser_playtest", - "agc_ui_design_to_html" ] ); let serialized = specs.to_string(); diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/action_execution.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/action_execution.rs index 58e696980..a2063143b 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/action_execution.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/action_execution.rs @@ -421,7 +421,6 @@ pub(crate) async fn execute_game_creator_agent_runtime_tool_action_with_pending_ "ui.workflow.run" => { observe_agent_runtime_ui_workflow(root, agent_id, run_id, task, &action.input).await } - "ui.design.to_html" => observe_agent_runtime_ui_design_to_html(root, &action.input), "blackboard.write" => { observe_agent_runtime_blackboard_write(root, agent_id, run_id, &action.input) } diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/autonomous_policy.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/autonomous_policy.rs index a6cb76010..eeb2f00ff 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/autonomous_policy.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/autonomous_policy.rs @@ -1097,7 +1097,6 @@ pub(in crate::agent) fn validate_agent_runtime_autonomous_read_only_delivery_pla | "command.output_read" | "command.poll" | "image.inspect" => false, - "ui.design.to_html" => false, "preview.validate" => agent_id != "preview-playtest" && agent_id != "code-prototype", "command.run_limited" => { agent_id != "preview-readiness" && agent_id != "code-prototype" diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/parallel_ledger.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/parallel_ledger.rs index 1de96d573..d047701d8 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/parallel_ledger.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/parallel_ledger.rs @@ -12,7 +12,6 @@ pub(crate) fn agent_runtime_tool_is_parallel_safe_read(tool: &str) -> bool { | "file.list" | "file.read" | "task.list" - | "ui.design.to_html" ) } @@ -101,7 +100,6 @@ pub(in crate::agent) fn game_creator_agent_runtime_tool_command_id( "image.inspect" => Some("image.inspect"), "canvas.asset_generate" => Some("canvas.asset_generate"), "ui.workflow.run" => Some("asset.register"), - "ui.design.to_html" => Some("ui.design.to_html"), "blackboard.write" => Some("memory.write"), "agent.message" => Some("conversation.write"), "agent.delegate" => Some("agent.delegate"), diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/tool_policy_snapshot.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/tool_policy_snapshot.rs index eb24abcdc..0a58e049f 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/tool_policy_snapshot.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/tool_policy_snapshot.rs @@ -100,7 +100,6 @@ pub(crate) fn agent_runtime_executable_tools() -> Vec<&'static str> { "image.inspect", "canvas.asset_generate", "ui.workflow.run", - "ui.design.to_html", "blackboard.write", "agent.message", "agent.delegate", @@ -340,7 +339,6 @@ pub(crate) fn agent_runtime_autonomous_design_foundation_command_is_allowed( | "image.inspect" | "canvas.asset_generate" | "canvas.asset_import" - | "ui.design.to_html" | "agent.audit" | "agent.run_status" ) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools.rs index 0148f6d0f..1478ae0aa 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools.rs @@ -17,7 +17,6 @@ mod project_ops; mod run_status; mod task_ops; mod ui_workflow; -mod ui_html; pub(in crate::agent) use action_history::*; pub(in crate::agent) use command_ops::*; @@ -36,7 +35,6 @@ pub(in crate::agent) use project_ops::*; pub(in crate::agent) use run_status::*; pub(in crate::agent) use task_ops::*; pub(in crate::agent) use ui_workflow::*; -pub(in crate::agent) use ui_html::*; #[cfg(test)] pub(crate) use delegation::observe_agent_runtime_agent_delegate_at_locked; diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/policy.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/policy.rs index bceb052b7..8fc4f477f 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/policy.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/policy.rs @@ -49,7 +49,6 @@ fn autonomous_design_foundation_command_is_allowed(command_id: &str) -> bool { | "canvas.asset_import" | "asset.register" | "ui.workflow.run" - | "ui.design.to_html" | "agent.audit" | "agent.action_history" | "agent.run_status" diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/ui_html.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/ui_html.rs deleted file mode 100644 index 648fccef5..000000000 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/ui_html.rs +++ /dev/null @@ -1,14 +0,0 @@ -use super::*; -use serde_json::Value; - -pub(in crate::agent) fn observe_agent_runtime_ui_design_to_html( - root: &Path, - input: &Value, -) -> AgentRuntimeToolObservation { - AgentRuntimeToolObservation { - tool: "ui.design.to_html".to_string(), - status: "error".to_string(), - summary: "ui.design.to_html 暂未实现".to_string(), - detail: None, - } -} diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent_native_tools.rs b/apps/ai-game-creator-shell/src-tauri/src/agent_native_tools.rs index 2c4daca1f..8ef1b13d1 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent_native_tools.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent_native_tools.rs @@ -1391,9 +1391,6 @@ fn runtime_tool_description(tool: &str) -> &'static str { "ui.workflow.run" => { "先用 discover 从受控 game/ui-pages.json 或页面声明标记自动发现全部功能页面,再把已登记 ui-prototype 与每个页面的设计图桥接成独立 UI JSON State;可同时载入已登记图片、图标和项目字体,执行 Provider 结构识别、多树合并与分批组件绑定、回读阶段,并且只有所有页面已绑定且已应用到 game/ 后才允许 finalize。项目根目录由 Runtime 注入,模型不得传入宿主路径。" } - "ui.design.to_html" => { - "UI 设计 HTML 转换工具当前暂未实现。" - } "blackboard.write" => "向项目级共享黑板追加稳定结论。", "agent.message" => "向一个目标 Agent 写入定向上下文消息。", "agent.delegate" => { @@ -1686,14 +1683,6 @@ fn runtime_tool_input_schema(tool: &str) -> Value { } } }), - "ui.design.to_html" => json!({ - "type": "object", - "required": ["assetId"], - "additionalProperties": false, - "properties": { - "assetId": { "type": "string", "minLength": 1, "maxLength": 160 } - } - }), "blackboard.write" => two_string_input_schema("title", "content"), "agent.message" => two_string_input_schema("agentId", "content"), "agent.delegate" => json!({ diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/html_renderer/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/html_renderer/mod.rs index d33c76490..a835d5713 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/html_renderer/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/html_renderer/mod.rs @@ -107,16 +107,15 @@ pub(crate) fn render_ui_design_state_js( let escaped = escape_template_literal(&pretty_html_fragment(&fragment)); modules.push(format!("export const {export_name} = `\n{escaped}\n`;")); } - let mut output = String::from( - "// UI 设计生成模块:仅导出 HTML 片段,不执行任何注入逻辑。\n\ - // 重新生成会覆盖本文件中的手动修改。\n\ - // 可通过宿主页面设置 --ui-scale 调整整体像素缩放,例如:\n\ - // document.documentElement.style.setProperty('--ui-scale', '0.85');\n\ - // 注入示例(仅供 Agent 按需修改):\n\ - // import { tree_example } from './generated-xxx.js';\n\ - // document.body.insertAdjacentHTML('beforeend', tree_example);\n\ - // const node = document.querySelector('[ui-node-id=\"...\"]');\n\n", - ); + let mut output = String::from(concat!( + "// UI 设计生成模块:仅导出 HTML 片段,不执行任何注入逻辑。\n", + "// 重新生成会覆盖本文件中的手动修改。\n", + "// 每个 tree 根节点已按对应 UI design 尺寸直接设置 --ui-scale。\n", + "// 注入示例(仅供 Agent 按需修改):\n", + "// import { tree_example } from '/ui/generated-xxx.js';\n", + "// document.body.insertAdjacentHTML('beforeend', tree_example);\n", + "// const node = document.querySelector('[ui-node-id=\"...\"]');\n\n", + )); output.push_str(&modules.join("\n\n")); if !output.ends_with('\n') { output.push('\n');