From 15660a98b25e73679d41efe2db2fa3256f6caaae Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Fri, 11 Sep 2026 21:09:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=20CI=EF=BC=9A=E8=A1=A5=E8=B7=91=20AGC?= =?UTF-8?q?=20src-tauri=20=E7=9A=84=20rustfmt=EF=BC=8C=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=9C=AC=E6=89=B9=E9=81=97=E7=95=99=E7=9A=84=208=20=E5=A4=84?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=81=8F=E5=B7=AE=20-=20=E5=8F=AA=E5=81=9A?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=87=8D=E6=8E=92=EF=BC=88=E5=BA=94=E5=90=88?= =?UTF-8?q?=E6=88=90=E9=95=BF=E8=A1=8C/=E5=BA=94=E6=8B=86=E5=A4=9A?= =?UTF-8?q?=E8=A1=8C=EF=BC=89=EF=BC=8C=E6=97=A0=E8=AF=AD=E4=B9=89=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=20-=20=E5=91=BD=E4=B8=AD=20agent/direct=5Fproject=5Fh?= =?UTF-8?q?istory.rs=E3=80=81agent/direct=5Fruntime.rs=E3=80=81main.rs?= =?UTF-8?q?=E3=80=81project/conversation.rs=E3=80=81project/conversation/t?= =?UTF-8?q?ests.rs=20-=20=E5=88=86=E5=88=AB=E6=9D=A5=E8=87=AA=20bfb928295?= =?UTF-8?q?=20/=202b44b6259=20/=20458a65cb5=20/=20f0d5687ab=20=E5=9B=9B?= =?UTF-8?q?=E7=AC=94=E6=8F=90=E4=BA=A4=E7=9A=84=E6=96=B0=E5=A2=9E=E8=A1=8C?= =?UTF-8?q?=20-=20=E6=88=90=E5=9B=A0=EF=BC=9Apre-commit=20=E7=9A=84=20lint?= =?UTF-8?q?-staged=20=E5=8F=AA=E8=A6=86=E7=9B=96=20*.{js,mjs,cjs,ts,tsx}?= =?UTF-8?q?=EF=BC=8CRust=20=E6=A0=BC=E5=BC=8F=E6=9C=AC=E5=9C=B0=E6=97=A0?= =?UTF-8?q?=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/agent/direct_project_history.rs | 19 ++++++++------ .../src-tauri/src/agent/direct_runtime.rs | 3 ++- .../src-tauri/src/main.rs | 4 +-- .../src-tauri/src/project/conversation.rs | 25 +++++++++---------- .../src/project/conversation/tests.rs | 10 ++++++-- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs index b2d46416d..a4f40e846 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs @@ -560,13 +560,9 @@ mod tests { #[test] fn legacy_conversation_rows_project_into_responses_message_items() { let root = init_history_project("legacy-projection"); - write_history_lines( - root.path(), - &[LEGACY_USER_ROW, LEGACY_ASSISTANT_ROW], - ); + write_history_lines(root.path(), &[LEGACY_USER_ROW, LEGACY_ASSISTANT_ROW]); - let items = - read_direct_project_history_items_at(root.path()).expect("read legacy history"); + let items = read_direct_project_history_items_at(root.path()).expect("read legacy history"); assert_eq!( items, vec![ @@ -611,7 +607,11 @@ mod tests { .iter() .map(|item| item.get("id").and_then(Value::as_str)) .collect::>(), - vec![Some("direct-codex:turn-0001:user"), Some("codex-item-2"), None] + vec![ + Some("direct-codex:turn-0001:user"), + Some("codex-item-2"), + None + ] ); assert_eq!( items[1], @@ -622,7 +622,10 @@ mod tests { "content": [{"type": "input_text", "text": "再加一个按钮"}], }) ); - assert_eq!(items[2]["content"][0]["text"], json!("已完成 第一行\n第二行 ")); + assert_eq!( + items[2]["content"][0]["text"], + json!("已完成 第一行\n第二行 ") + ); let chat = read_direct_project_chat_history_at(root.path()).expect("read mixed chat"); assert_eq!( 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 72116eadc..bc7d7b0e7 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 @@ -4571,7 +4571,8 @@ mod tests { #[test] fn direct_project_history_shape_failure_has_explicit_non_retryable_guidance() { - let error = "DirectProject 历史记录类型无效:$PROJECT_ROOT/.agent/conversations/project.jsonl"; + let error = + "DirectProject 历史记录类型无效:$PROJECT_ROOT/.agent/conversations/project.jsonl"; assert!(direct_project_history_shape_failure(error)); assert_eq!( direct_codex_failure_recovery_hint(DirectCodexFailureStage::CodeGeneration, error), diff --git a/apps/ai-game-creator-shell/src-tauri/src/main.rs b/apps/ai-game-creator-shell/src-tauri/src/main.rs index 9dec92e39..94e835a7c 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -30,8 +30,8 @@ use shared_contracts::game_creation_app::{ game_creation_app_asset_effective_category, new_game_creation_app_manifest, new_game_creation_app_seed_tasks, normalize_game_creation_app_asset_tags, validate_game_iteration_versions, GameCreationAgentArtifactTrace, - GameCreationAgentCapabilityDescriptor, - GameCreationAgentPassPlanTrace, GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep, + GameCreationAgentCapabilityDescriptor, GameCreationAgentPassPlanTrace, + GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep, GameCreationAgentRunTaskGraphTrace, GameCreationAgentRunTrace, GameCreationAgentToolCallTrace, GameCreationAppAgentGroup, GameCreationAppAssetManifestEntry, GameCreationAppAssetSource, GameCreationAppAssetSourceKind, GameCreationAppCommandRunState, diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs b/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs index f8a6ff808..3e0e26294 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/conversation.rs @@ -958,19 +958,18 @@ fn read_persisted_local_conversation_records_unlocked( if line.is_empty() { continue; } - let record = match serde_json::from_str::( - line, - ) { - Ok(record) => record, - // 项目主对话(agent_id=None)与 DirectProject 共用同一份 - // `project.jsonl`:DirectProject 写的是 Codex rollout 的 - // `response_item` 行。通用对话链只认自己的 legacy 行,遇到对方那种 - // 行就跳过;其余任何坏行继续失败关闭。 - Err(_) if is_direct_project_history_row(line) => continue, - Err(error) => { - return Err(format!("解析对话记录失败:{}: {error}", path.display())) - } - }; + let record = + match serde_json::from_str::(line) { + Ok(record) => record, + // 项目主对话(agent_id=None)与 DirectProject 共用同一份 + // `project.jsonl`:DirectProject 写的是 Codex rollout 的 + // `response_item` 行。通用对话链只认自己的 legacy 行,遇到对方那种 + // 行就跳过;其余任何坏行继续失败关闭。 + Err(_) if is_direct_project_history_row(line) => continue, + Err(error) => { + return Err(format!("解析对话记录失败:{}: {error}", path.display())) + } + }; records.push(record); } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs b/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs index 288f2e84c..9bad4a007 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/conversation/tests.rs @@ -293,7 +293,10 @@ fn mixed_project_history_rows_stay_readable_from_both_sides() { let history = std::fs::read_to_string(project_conversation_path(&root)).expect("read history"); assert_eq!(history.lines().count(), 3, "{history}"); - assert!(history.contains("模式切换后由通用写入器补写的回复"), "{history}"); + assert!( + history.contains("模式切换后由通用写入器补写的回复"), + "{history}" + ); // 通用对话链只读自己的 legacy 行,跳过 DirectProject 的行。 let conversation = read_local_conversation_at(&root, None).expect("read project conversation"); @@ -332,7 +335,10 @@ fn project_history_keeps_accepting_legacy_rows_while_no_direct_project_row_exist append_project_message(&root, "非 direct 模式的项目对话回复").expect("append legacy row"); let conversation = read_local_conversation_at(&root, None).expect("read legacy conversation"); assert_eq!(conversation.messages.len(), 1); - assert_eq!(conversation.messages[0].content, "非 direct 模式的项目对话回复"); + assert_eq!( + conversation.messages[0].content, + "非 direct 模式的项目对话回复" + ); std::fs::remove_dir_all(root).ok(); }