From 98cecdfc5ee953730461bc0f98411e45bd857ff2 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Tue, 6 Oct 2026 17:32:10 +0800 Subject: [PATCH] =?UTF-8?q?chore(agc):=20=E6=B8=85=E7=90=86=E8=B7=A8?= =?UTF-8?q?=E5=88=86=E6=94=AF=E8=80=A6=E5=90=88=E5=90=8E=E5=A4=B1=E5=8E=BB?= =?UTF-8?q?=E6=B6=88=E8=B4=B9=E8=80=85=E7=9A=84=E9=80=80=E5=BD=B9=20DTO/?= =?UTF-8?q?=E5=B8=B8=E9=87=8F/=E5=87=BD=E6=95=B0=EF=BC=88=E7=94=B2?= =?UTF-8?q?=E7=BB=84=EF=BC=8Cbin=2024=20=E2=86=92=209=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main.rs:删 `use platform_agent::{build_game_creation_seed_task_graph, plan_game_creation_agent_pass, route_game_creation_repair_issues};` 与 shared-contracts 列表中已无消费者的 `GAME_CREATION_AGENT_RUN_SCHEMA_VERSION`。 main.rs:删退役 DTO/结构 `GenerateLocalGameDraftResult`、`AgentPassArtifactPaths`、`AgentPassAgenda`、`LlmGameDraft`、`LlmAgentHandoff`、`GameCreatorAgentLoopResult`(后三者互引,一并删除后无级联孤儿)。 main.rs:删退役常量 `GAME_CREATOR_AGENT_LOOP_MAX_PASSES`、`GAME_CREATOR_CONVERSATION_CONTEXT_MAX_MESSAGES`。 platform_session.rs:删 `platform_session_is_available`。 project/agent_db.rs:删 `append_jsonl_line`(其内部 `append_jsonl_line_unlocked` 仍有其他使用者)。 project/conversation.rs:删 `append_markdown_entry`。 project/manifest.rs:删 `record_draft_task_progress`。 config.rs:删 `build_game_creator_llm_client_without_redirects_from_llm_config`。 验证:bin 口径 warning 24 → 9,EXIT=0,无 error 行;每个符号删前均以 Git 全树引用矩阵确认(见 local://rust-warning-coupling-report-20261006.md §3a)。 --- .../src-tauri/src/config.rs | 9 --- .../src-tauri/src/main.rs | 79 +------------------ .../src-tauri/src/platform_session.rs | 4 - .../src-tauri/src/project/agent_db.rs | 6 -- .../src-tauri/src/project/conversation.rs | 25 ------ .../src-tauri/src/project/manifest.rs | 43 ---------- 6 files changed, 2 insertions(+), 164 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/config.rs b/apps/ai-game-creator-shell/src-tauri/src/config.rs index 640c447ae..016706721 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/config.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/config.rs @@ -151,15 +151,6 @@ pub(crate) fn build_game_creator_llm_client_from_llm_config( LlmClient::new(config).map_err(|error| format!("LLM client 初始化失败:{error}")) } -pub(crate) fn build_game_creator_llm_client_without_redirects_from_llm_config( - llm: &GameCreatorLlmConfig, - config_path: &str, -) -> Result { - let config = build_game_creator_platform_llm_config(llm, config_path)?; - LlmClient::new_without_redirects(config) - .map_err(|error| format!("LLM client 初始化失败:{error}")) -} - fn build_game_creator_platform_llm_config( llm: &GameCreatorLlmConfig, config_path: &str, 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 2b73a51c3..9114e0bdc 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -25,10 +25,6 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; // crate 根的 trait 导入会被 `use super::*` 的子模块继承(template_library 的流式下载依赖 // `StreamExt`,通知与 Agent 事件依赖 `Emitter`),不要因为根模块自身不再直接用到就删掉。 use futures::StreamExt; -use platform_agent::{ - build_game_creation_seed_task_graph, plan_game_creation_agent_pass, - route_game_creation_repair_issues, -}; use platform_llm::{ LlmApiKind, LlmClient, LlmConfig, LlmMessage, LlmProvider, LlmRunRequest, DEFAULT_RETRY_BACKOFF_MS, @@ -51,8 +47,8 @@ use shared_contracts::game_creation_app::{ GameIterationVersionResourceBinding, ProjectResourceCanvasLayout, ProjectResourceCanvasLayoutMode, ProjectResourceCanvasPosition, UpdateProjectResourceCanvasLayoutResult, UpdateProjectResourceCanvasLayoutStatus, - GAME_CREATION_AGENT_RUN_SCHEMA_VERSION, GAME_CREATION_AGENT_TOOL_CALL_MAX, - GAME_CREATION_APP_COMMANDS, GAME_CREATION_RESOURCE_LAYOUT_SCHEMA_VERSION, + GAME_CREATION_AGENT_TOOL_CALL_MAX, GAME_CREATION_APP_COMMANDS, + GAME_CREATION_RESOURCE_LAYOUT_SCHEMA_VERSION, }; // `Emitter` 同时被 `use super::*` 的子模块依赖(通知、Agent 事件等都从 crate 根取该 trait), // 不要因为根模块自身不再直接 `.emit(..)` 就删掉它。 @@ -229,17 +225,6 @@ struct LocalGameProjectRevisionStatus { revision: u64, } -#[derive(Debug, Eq, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -struct GenerateLocalGameDraftResult { - project_path: String, - game_index_path: String, - design_path: String, - short_memory_path: String, - long_memory_path: String, - manifest: GameCreationAppManifest, -} - #[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] struct GameCreatorManifestInvalidatedEvent { @@ -794,7 +779,6 @@ const GAME_CREATOR_REQUIRED_LLM_AGENT_IDS: [&str; 3] = [ ]; const MIN_GAME_CREATOR_LLM_REQUEST_TIMEOUT_MS: u64 = 1_000; const GAME_CREATOR_LLM_REQUEST_TIMEOUT_MS: u64 = 180_000; -const GAME_CREATOR_AGENT_LOOP_MAX_PASSES: u8 = 3; const GAME_CREATOR_AGENT_TOOL_CALL_MAX: u16 = GAME_CREATION_AGENT_TOOL_CALL_MAX; const GAME_CREATOR_AGENT_RUN_HISTORY_MAX_COUNT: usize = 100; const GAME_CREATOR_AGENT_DB_SCHEMA_VERSION: &str = "game-creator-agent-db.v1"; @@ -807,7 +791,6 @@ const AGENT_CONVERSATION_SESSION_SCHEMA_VERSION: &str = "game-creator-agent-sess const AGENT_RUNTIME_RUN_PROFILE_STANDARD: &str = "standard"; const AGENT_RUNTIME_AUTONOMOUS_SOURCE_FIELD_MAX_CHARS: usize = 8_000; const AGENT_RUNTIME_AUTONOMOUS_SOURCE_TOTAL_MAX_CHARS: usize = 10_000; -const GAME_CREATOR_CONVERSATION_CONTEXT_MAX_MESSAGES: usize = 12; fn default_agent_runtime_run_profile() -> String { AGENT_RUNTIME_RUN_PROFILE_STANDARD.to_string() @@ -948,18 +931,6 @@ fn game_creator_llm_agent_status_definitions() -> Vec, } -#[derive(Clone, Debug)] -struct AgentPassAgenda { - relative_path: String, - task_graph_relative_path: String, - active_task_ids: Vec, - carried_task_ids: Vec, - dependency_waves: Vec>, - repair_focus: Vec, - repair_routes: Vec, - summary: String, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -struct LlmGameDraft { - title: String, - design_markdown: String, - balance: serde_json::Value, - art_manifest: serde_json::Value, - audio_manifest: serde_json::Value, - publish_readme: String, - handoffs: Vec, - game_html: String, - handoff_summary: String, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -struct LlmAgentHandoff { - group: String, - role: String, - summary: String, - outputs: Vec, - next: String, -} - const DIAGNOSTIC_LOG_MAX_BYTES: u64 = 256 * 1024; static DIAGNOSTIC_LOG_LOCK: OnceLock> = OnceLock::new(); static STARTUP_ERROR_DIALOG_SHOWN: AtomicBool = AtomicBool::new(false); @@ -1344,16 +1279,6 @@ impl StartupLogSlot { } } -#[derive(Clone, Debug)] -struct GameCreatorAgentLoopResult { - run_id: String, - draft: LlmGameDraft, - spec_markdown: String, - findings_markdown: String, - passes: u8, - steps: Vec, -} - fn game_creator_gui_run_event_requests_runner_shutdown(event: &tauri::RunEvent) -> bool { matches!(event, tauri::RunEvent::Exit) } diff --git a/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs b/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs index 3e7ed9d46..d0ac16a17 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs @@ -482,10 +482,6 @@ pub(crate) fn acquire_platform_session_identity_lease( Ok(ValidatedPlatformSessionLease { _guard: current }) } -pub(crate) fn platform_session_is_available() -> bool { - current_platform_session().is_some() -} - #[cfg(test)] static PLATFORM_SESSION_TEST_LOCK: OnceLock> = OnceLock::new(); diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/agent_db.rs b/apps/ai-game-creator-shell/src-tauri/src/project/agent_db.rs index 35aea05c3..dcae47a21 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/agent_db.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/agent_db.rs @@ -4364,12 +4364,6 @@ fn repair_truncated_jsonl_tail_unlocked( }) } -pub(crate) fn append_jsonl_line(path: &Path, line: &str, error_label: &str) -> Result<(), String> { - let append_lock = project_append_lock_for(path)?; - let _append_guard = append_lock.lock(error_label)?; - append_jsonl_line_unlocked(path, line, error_label) -} - fn agent_db_has_conversation_message_audit_unlocked( file: &mut File, path: &Path, 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 1dfe09d94..47ebde536 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 @@ -1212,31 +1212,6 @@ pub(crate) fn normalize_game_creator_runtime_agent_id(agent_id: &str) -> Result< normalize_conversation_agent_id(agent_id) } -pub(crate) fn append_markdown_entry( - path: &Path, - header: &str, - entry: &str, - error_label: &str, -) -> Result<(), String> { - if let Some(parent) = path.parent() { - ensure_game_creator_private_directory_tree(parent, error_label)?; - prepare_game_creator_private_path_for_read(parent, true, error_label)?; - } - prepare_game_creator_private_path_for_read(path, false, error_label)?; - let needs_header = fs::metadata(path) - .map(|metadata| metadata.len() == 0) - .unwrap_or(true); - let bytes = if needs_header { - let mut bytes = Vec::with_capacity(header.len() + entry.len()); - bytes.extend_from_slice(header.as_bytes()); - bytes.extend_from_slice(entry.as_bytes()); - bytes - } else { - entry.as_bytes().to_vec() - }; - append_game_creator_private_file(path, &bytes, error_label) -} - #[cfg(not(test))] pub(crate) fn append_local_permission_log_at( root: &Path, diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/manifest.rs b/apps/ai-game-creator-shell/src-tauri/src/project/manifest.rs index 602d36e51..e48f9e687 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/manifest.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/manifest.rs @@ -1092,49 +1092,6 @@ pub(crate) fn ensure_manifest_has_seed_tasks( }) } -pub(crate) fn record_draft_task_progress( - root: &Path, - goal: &str, - updated_at: u64, - agent_log_path: &Path, -) -> Result { - let (manifest_path, mut manifest) = read_or_create_manifest(root)?; - ensure_manifest_seed_tasks(&mut manifest); - manifest.goal = Some(goal.to_string()); - for completed_task_id in [ - "design-director", - "balance-director", - "balance-seed", - "art-director", - "art-polish", - "audio-director", - "audio-asset-plan", - "code-director", - "code-prototype", - "quality-review", - ] { - set_task_status( - &mut manifest, - completed_task_id, - GameCreationAppTaskStatus::Completed, - ); - } - set_task_status( - &mut manifest, - "preview-readiness", - GameCreationAppTaskStatus::WaitingForConfirmation, - ); - manifest.command_runs.push(GameCreationAppCommandRunState { - command_id: "game.generate_draft".to_string(), - status: GameCreationAppCommandRunStatus::Completed, - output: "已完成 Planner/Generator/Evaluator loop、记忆写入和本地原型生成".to_string(), - log_path: agent_log_path.to_string_lossy().into_owned(), - updated_at, - }); - write_manifest(&manifest_path, &manifest)?; - Ok(manifest) -} - pub(crate) fn ensure_manifest_seed_tasks(manifest: &mut GameCreationAppManifest) { let seed_tasks = new_game_creation_app_seed_tasks(); if manifest.tasks.is_empty() {