#[path = "build_support/runtime_prompt_bundle.rs"] mod runtime_prompt_bundle; use std::collections::BTreeSet; use std::env; use std::fs; use std::path::PathBuf; fn seed_task_group_id( group: &shared_contracts::game_creation_app::GameCreationAppAgentGroup, ) -> &'static str { use shared_contracts::game_creation_app::GameCreationAppAgentGroup; match group { GameCreationAppAgentGroup::Design => "design", GameCreationAppAgentGroup::Art => "art", GameCreationAppAgentGroup::Code => "code", GameCreationAppAgentGroup::Balance => "balance", GameCreationAppAgentGroup::Audio => "audio", GameCreationAppAgentGroup::Publishing => "publishing", } } fn validate_seed_task_catalog(compiled: &runtime_prompt_bundle::CompiledPromptBundle) { let actual = compiled .specialist_nodes .iter() .map(|node| { ( node.task_id.clone(), node.group_id.clone(), node.role.clone(), ) }) .collect::>(); let expected = shared_contracts::game_creation_app::new_game_creation_app_seed_tasks() .into_iter() .map(|task| { ( task.id, seed_task_group_id(&task.group).to_string(), task.role, ) }) .collect::>(); if actual != expected { panic!( "Prompt Bundle agentCatalog 与正式 seed DAG 的 taskId/group/role 不一致\nactual={actual:#?}\nexpected={expected:#?}" ); } } fn main() { let manifest_dir = PathBuf::from( env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR must be available"), ); let manifest_path = manifest_dir.join("prompts/runtime/manifest.json"); let compiled = runtime_prompt_bundle::compile_manifest(&manifest_path) .unwrap_or_else(|error| panic!("Prompt Bundle 编译失败:{error}")); validate_seed_task_catalog(&compiled); for dependency in &compiled.dependencies { println!("cargo:rerun-if-changed={}", dependency.display()); } let output_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR must be available")) .join("agent_runtime_prompt_bundle.rs"); fs::write(&output_path, compiled.rust_source) .unwrap_or_else(|error| panic!("写入 Prompt Bundle 生成代码失败:{error}")); tauri_build::build() }