实现游戏工作台P0/P1可运行版本能力
冻结工作台运行版本、会话、参数、资源与消息跨端合同 新增可信 Runtime 验证后的不可变可运行版本登记与快照校验 支持 Tauri 客户端选择、切换并运行历史版本快照 收紧普通预览授权边界并同步资源高亮与明确错误展示 补充前后端测试、PRD、技术方案和项目决策记录
This commit is contained in:
@@ -1249,6 +1249,88 @@ pub(in crate::agent) fn project_autonomous_manifest_ready_task_terminal_at_locke
|
||||
}),
|
||||
)?;
|
||||
}
|
||||
if status == GameCreationAppTaskStatus::Completed && state.agent_id == "preview-playtest" {
|
||||
let manifest_before_completion = read_manifest_for_project(root)?;
|
||||
let required_tasks = autonomous_manifest_seed_tasks_for_source(&root_parent_binding.source);
|
||||
let required_by_id = required_tasks
|
||||
.iter()
|
||||
.map(|task| (task.id.as_str(), task))
|
||||
.collect::<std::collections::HashMap<_, _>>();
|
||||
let mut prerequisite_ids = std::collections::BTreeSet::new();
|
||||
let mut pending_ids = vec![state.agent_id.as_str()];
|
||||
while let Some(task_id) = pending_ids.pop() {
|
||||
if !prerequisite_ids.insert(task_id) {
|
||||
continue;
|
||||
}
|
||||
let task = required_by_id
|
||||
.get(task_id)
|
||||
.ok_or_else(|| format!("可运行版本项目完整性合同缺少任务:{task_id}"))?;
|
||||
pending_ids.extend(task.dependencies.iter().map(String::as_str));
|
||||
}
|
||||
let incomplete = required_tasks
|
||||
.iter()
|
||||
.filter(|required| prerequisite_ids.contains(required.id.as_str()))
|
||||
.filter(|required| required.id != state.agent_id)
|
||||
.filter(|required| {
|
||||
manifest_before_completion
|
||||
.tasks
|
||||
.iter()
|
||||
.find(|task| task.id == required.id)
|
||||
.is_none_or(|task| task.status != GameCreationAppTaskStatus::Completed)
|
||||
})
|
||||
.map(|task| task.id.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
if !incomplete.is_empty() {
|
||||
return Err(format!(
|
||||
"可运行版本项目完整性检查未通过:{}",
|
||||
incomplete.join("、")
|
||||
));
|
||||
}
|
||||
let readiness_records =
|
||||
latest_game_creator_agent_runtime_tasks(read_all_game_creator_agent_runtime_tasks(
|
||||
&game_creator_agent_runtime_task_path(root, "preview-readiness"),
|
||||
)?);
|
||||
let readiness = readiness_records
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|record| {
|
||||
record.parent_agent_id.as_deref() == Some(parent_agent_id.as_str())
|
||||
&& record.parent_run_id.as_deref() == Some(parent_run_id.as_str())
|
||||
&& record.status == "completed"
|
||||
})
|
||||
.ok_or_else(|| "可运行版本缺少 preview-readiness 完成回执".to_string())?;
|
||||
let current_revision = read_game_creator_agent_runtime_project_revision(root)?;
|
||||
let readiness_gate = read_game_creator_agent_runtime_verification_gate(
|
||||
root,
|
||||
&readiness.agent_id,
|
||||
&readiness.run_id,
|
||||
)?;
|
||||
if readiness_gate.last_verification_tool.as_deref() != Some("game.static_smoke")
|
||||
|| readiness_gate.last_verification_status.as_deref()
|
||||
!= Some(AGENT_RUNTIME_VERIFICATION_STATUS_PASSED)
|
||||
|| readiness_gate.verified_revision != Some(current_revision.revision)
|
||||
{
|
||||
return Err("可运行版本缺少当前 revision 的 game.static_smoke 通过凭证".to_string());
|
||||
}
|
||||
let contract = autonomous_playtest_completion_contract_for_state_at(root, state)?
|
||||
.ok_or_else(|| "可运行版本缺少 preview.validate 完成合同".to_string())?;
|
||||
let receipt = read_autonomous_playtest_receipt(root, &contract)?
|
||||
.ok_or_else(|| "可运行版本缺少 preview.validate 成功回执".to_string())?;
|
||||
verify_autonomous_playtest_evidence_files_at(root, &receipt)?;
|
||||
if receipt.revision != current_revision.revision {
|
||||
return Err(format!(
|
||||
"可运行版本 revision 不一致:receipt={} current={}",
|
||||
receipt.revision, current_revision.revision
|
||||
));
|
||||
}
|
||||
register_current_runnable_game_version_at(
|
||||
root,
|
||||
current_revision.revision,
|
||||
&receipt.agent_id,
|
||||
&receipt.run_id,
|
||||
&receipt.report.path,
|
||||
)?;
|
||||
}
|
||||
update_manifest_task_status_at(root, &state.agent_id, status.clone())?;
|
||||
append_agent_db_record(
|
||||
root,
|
||||
|
||||
+132
@@ -698,6 +698,138 @@ fn autonomous_preview_manifest_tasks_accept_bound_current_revision_receipts() {
|
||||
assert!(autonomous_game_build_completion_blocker_at_locked(&root, &playtest_state).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preview_playtest_terminal_registers_a_runnable_snapshot_before_downstream_publish_tasks_complete(
|
||||
) {
|
||||
let (_temporary, root, parent_state, contract) =
|
||||
autonomous_fixture("做一个完整小游戏", "autonomous-runnable-version-parent");
|
||||
for task_id in ["publish-strategy", "publish-package"] {
|
||||
update_manifest_task_status_at(&root, task_id, GameCreationAppTaskStatus::Pending)
|
||||
.unwrap_or_else(|error| panic!("leave downstream {task_id} pending: {error}"));
|
||||
}
|
||||
let task_ids = read_manifest_for_project(&root)
|
||||
.expect("read autonomous manifest")
|
||||
.tasks
|
||||
.into_iter()
|
||||
.map(|task| task.id)
|
||||
.collect::<Vec<_>>();
|
||||
for task_id in task_ids {
|
||||
if !matches!(
|
||||
task_id.as_str(),
|
||||
"preview-readiness" | "preview-playtest" | "publish-strategy" | "publish-package"
|
||||
) {
|
||||
update_manifest_task_status_at(&root, &task_id, GameCreationAppTaskStatus::Completed)
|
||||
.unwrap_or_else(|error| panic!("complete prerequisite {task_id}: {error}"));
|
||||
}
|
||||
}
|
||||
|
||||
update_manifest_task_status_at(
|
||||
&root,
|
||||
"preview-readiness",
|
||||
GameCreationAppTaskStatus::Running,
|
||||
)
|
||||
.expect("mark preview readiness running");
|
||||
let readiness_child =
|
||||
queue_autonomous_manifest_child_fixture(&root, &parent_state, "preview-readiness");
|
||||
let revision = advance_game_index_revision(
|
||||
&root,
|
||||
&parent_state,
|
||||
"<!doctype html><title>可运行版本</title><canvas></canvas>",
|
||||
);
|
||||
let readiness_state = agent_runtime_state_from_task_record(&readiness_child);
|
||||
mark_verification_passed(&root, &readiness_state, "game.static_smoke");
|
||||
let readiness_terminal = AgentRuntimeTaskRecord {
|
||||
status: "completed".to_string(),
|
||||
phase: "completed".to_string(),
|
||||
updated_at: unix_timestamp(),
|
||||
..readiness_child
|
||||
};
|
||||
append_game_creator_agent_runtime_task_record(&root, &readiness_terminal)
|
||||
.expect("persist completed preview readiness record");
|
||||
project_autonomous_manifest_ready_task_terminal_at(
|
||||
&root,
|
||||
&agent_runtime_state_from_task_record(&readiness_terminal),
|
||||
)
|
||||
.expect("project preview readiness completion");
|
||||
|
||||
update_manifest_task_status_at(
|
||||
&root,
|
||||
"preview-playtest",
|
||||
GameCreationAppTaskStatus::Running,
|
||||
)
|
||||
.expect("mark preview playtest running");
|
||||
let playtest_child =
|
||||
queue_autonomous_manifest_child_fixture(&root, &parent_state, "preview-playtest");
|
||||
let playtest_state = agent_runtime_state_from_task_record(&playtest_child);
|
||||
let result = browser_result_fixture(
|
||||
&root,
|
||||
&parent_state,
|
||||
revision,
|
||||
BrowserPlaytestScenario::GenericV1,
|
||||
);
|
||||
let action = AgentRuntimeToolAction {
|
||||
tool: "preview.validate".to_string(),
|
||||
reason: Some("验证可运行版本".to_string()),
|
||||
input: serde_json::json!({}),
|
||||
};
|
||||
let action_fingerprint =
|
||||
agent_runtime_tool_action_fingerprint(&action, &playtest_state.current_task);
|
||||
let action_id =
|
||||
agent_runtime_tool_action_id(&playtest_state.run_id, 1, 0, 1, &action_fingerprint);
|
||||
write_autonomous_playtest_receipt_at(
|
||||
&root,
|
||||
&contract,
|
||||
&action_id,
|
||||
&action_fingerprint,
|
||||
revision,
|
||||
&result,
|
||||
)
|
||||
.expect("persist runnable playtest receipt");
|
||||
let playtest_terminal = AgentRuntimeTaskRecord {
|
||||
status: "completed".to_string(),
|
||||
phase: "completed".to_string(),
|
||||
updated_at: unix_timestamp(),
|
||||
..playtest_child
|
||||
};
|
||||
append_game_creator_agent_runtime_task_record(&root, &playtest_terminal)
|
||||
.expect("persist completed preview playtest record");
|
||||
project_autonomous_manifest_ready_task_terminal_at(
|
||||
&root,
|
||||
&agent_runtime_state_from_task_record(&playtest_terminal),
|
||||
)
|
||||
.expect("project preview playtest and register runnable version");
|
||||
|
||||
let manifest = read_manifest_for_project(&root).expect("read runnable manifest");
|
||||
assert_eq!(manifest.runnable_versions.len(), 1);
|
||||
let version = &manifest.runnable_versions[0];
|
||||
assert_eq!(version.project_revision, revision);
|
||||
assert_eq!(
|
||||
version.created_reason,
|
||||
RunnableGameVersionCreatedReason::Initial
|
||||
);
|
||||
assert_eq!(
|
||||
manifest.current_runnable_version_id.as_deref(),
|
||||
Some(version.version_id.as_str())
|
||||
);
|
||||
assert!(root
|
||||
.join(&version.artifact_path)
|
||||
.join("game/index.html")
|
||||
.is_file());
|
||||
for task_id in ["publish-strategy", "publish-package"] {
|
||||
let status = manifest
|
||||
.tasks
|
||||
.iter()
|
||||
.find(|task| task.id == task_id)
|
||||
.map(|task| &task.status)
|
||||
.unwrap_or_else(|| panic!("missing downstream task {task_id}"));
|
||||
assert_ne!(
|
||||
status,
|
||||
&GameCreationAppTaskStatus::Completed,
|
||||
"runnable registration must not wait for downstream {task_id} completion"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn autonomous_completion_rejects_formal_artifact_unchanged_from_run_baseline() {
|
||||
let baseline_bytes =
|
||||
|
||||
@@ -23,20 +23,23 @@ use reqwest::header;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared_contracts::game_creation_app::{
|
||||
new_game_creation_app_manifest, new_game_creation_app_seed_tasks,
|
||||
validate_game_iteration_versions, GameCreationAgentArtifactTrace,
|
||||
GameCreationAgentCapabilityDescriptor, GameCreationAgentPassPlanTrace,
|
||||
GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep,
|
||||
validate_game_iteration_versions, validate_runnable_game_versions,
|
||||
GameCreationAgentArtifactTrace, GameCreationAgentCapabilityDescriptor,
|
||||
GameCreationAgentPassPlanTrace, GameCreationAgentRepairRouteTrace, GameCreationAgentRunStep,
|
||||
GameCreationAgentRunTaskGraphTrace, GameCreationAgentRunTrace, GameCreationAgentToolCallTrace,
|
||||
GameCreationAppAgentGroup, GameCreationAppAssetManifestEntry, GameCreationAppAssetSource,
|
||||
GameCreationAppAssetSourceKind, GameCreationAppCommandRunState,
|
||||
GameCreationAppCommandRunStatus, GameCreationAppLimitedRunCommandDescriptor,
|
||||
GameCreationAppManifest, GameCreationAppPermission, GameCreationAppPreviewState,
|
||||
GameCreationAppPreviewStatus, GameCreationAppTaskState, GameCreationAppTaskStatus,
|
||||
ProjectResourceCanvasLayout, ProjectResourceCanvasLayoutMode, ProjectResourceCanvasPosition,
|
||||
GameIterationVersionResourceBinding, ProjectResourceCanvasLayout,
|
||||
ProjectResourceCanvasLayoutMode, ProjectResourceCanvasPosition, RunnableGameVersion,
|
||||
RunnableGameVersionCreatedReason, RunnableGameVersionValidation,
|
||||
UpdateProjectResourceCanvasLayoutResult, UpdateProjectResourceCanvasLayoutStatus,
|
||||
GAME_CREATION_AGENT_CAPABILITIES, GAME_CREATION_AGENT_RUN_SCHEMA_VERSION,
|
||||
GAME_CREATION_AGENT_TOOL_CALL_MAX, GAME_CREATION_APP_COMMANDS,
|
||||
GAME_CREATION_APP_LIMITED_RUN_COMMANDS, GAME_CREATION_RESOURCE_LAYOUT_SCHEMA_VERSION,
|
||||
RUNNABLE_GAME_VERSION_SCHEMA_VERSION,
|
||||
};
|
||||
use tauri::{Emitter, Manager};
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
@@ -147,6 +150,14 @@ struct LocalPreviewStatus {
|
||||
root: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RunnableGameVersionLaunchResult {
|
||||
manifest: GameCreationAppManifest,
|
||||
version: RunnableGameVersion,
|
||||
preview: LocalPreviewResult,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct LocalGameProjectRevisionStatus {
|
||||
@@ -2380,6 +2391,7 @@ fn main() {
|
||||
open_game_creator_launcher_window,
|
||||
open_project_supervisor_chat_window,
|
||||
start_local_game_preview,
|
||||
launch_local_game_runnable_version,
|
||||
activate_local_game_preview,
|
||||
stop_local_game_preview,
|
||||
stop_local_game_preview_if_matches,
|
||||
|
||||
@@ -382,6 +382,14 @@ pub(crate) fn activate_local_game_preview(
|
||||
pub(crate) fn start_local_game_preview_for_project(
|
||||
root: &Path,
|
||||
) -> Result<(LocalPreviewResult, mpsc::Sender<()>), String> {
|
||||
start_local_game_preview_for_served_root(root, root)
|
||||
}
|
||||
|
||||
pub(crate) fn start_local_game_preview_for_served_root(
|
||||
project_root: &Path,
|
||||
served_root: &Path,
|
||||
) -> Result<(LocalPreviewResult, mpsc::Sender<()>), String> {
|
||||
let root = project_root;
|
||||
if root.as_os_str().is_empty() {
|
||||
return Err("项目目录不能为空".to_string());
|
||||
}
|
||||
@@ -389,7 +397,10 @@ pub(crate) fn start_local_game_preview_for_project(
|
||||
return Err("项目目录必须是绝对路径".to_string());
|
||||
}
|
||||
|
||||
let game_root = root.join("game");
|
||||
if served_root.as_os_str().is_empty() || !served_root.is_absolute() {
|
||||
return Err("预览产物目录无效".to_string());
|
||||
}
|
||||
let game_root = served_root.join("game");
|
||||
if !game_root.is_dir() {
|
||||
return Err(format!("游戏目录不存在:{}", game_root.display()));
|
||||
}
|
||||
@@ -409,7 +420,7 @@ pub(crate) fn start_local_game_preview_for_project(
|
||||
listener
|
||||
.set_nonblocking(true)
|
||||
.map_err(|error| format!("设置预览监听失败:{error}"))?;
|
||||
let served_root = root.to_path_buf();
|
||||
let served_root = served_root.to_path_buf();
|
||||
let (stop_sender, stop_receiver) = mpsc::channel();
|
||||
|
||||
thread::spawn(move || loop {
|
||||
@@ -443,6 +454,80 @@ pub(crate) fn start_local_game_preview_for_project(
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn launch_local_game_runnable_version(
|
||||
project_path: String,
|
||||
expected_project_id: String,
|
||||
version_id: Option<String>,
|
||||
registry: tauri::State<'_, PreviewRegistry>,
|
||||
) -> Result<RunnableGameVersionLaunchResult, String> {
|
||||
let root = Path::new(project_path.trim());
|
||||
enforce_project_permission_policy(root, "preview.start")?;
|
||||
let _lock = acquire_project_write_lock(root, "preview.start")?;
|
||||
let current_manifest = read_existing_manifest_for_project(root)?;
|
||||
if current_manifest.project_id != expected_project_id.trim() {
|
||||
return Err("可运行版本项目身份不一致".to_string());
|
||||
}
|
||||
let version_id = version_id
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(str::to_string)
|
||||
.or(current_manifest.current_runnable_version_id.clone())
|
||||
.ok_or_else(|| "当前无可运行版本".to_string())?;
|
||||
|
||||
let _ = registry.stop_for_project(Some(root));
|
||||
let (_, version, artifact_root) =
|
||||
resolve_runnable_game_version_at(root, expected_project_id.trim(), &version_id)?;
|
||||
let (preview, stop) = match start_local_game_preview_for_served_root(root, &artifact_root) {
|
||||
Ok(result) => result,
|
||||
Err(error) => {
|
||||
let _ = record_preview_state(root, GameCreationAppPreviewStatus::Failed, None, None);
|
||||
return Err(format!("可运行版本预览启动失败:{error}"));
|
||||
}
|
||||
};
|
||||
if let Err(error) = record_preview_state(
|
||||
root,
|
||||
GameCreationAppPreviewStatus::Running,
|
||||
Some(preview.url.clone()),
|
||||
Some(preview.port),
|
||||
) {
|
||||
let _ = stop.send(());
|
||||
return Err(error);
|
||||
}
|
||||
if let Err(error) = append_preview_log(root, "running", Some(&preview.url)) {
|
||||
let _ = stop.send(());
|
||||
let _ = record_preview_state(root, GameCreationAppPreviewStatus::Failed, None, None);
|
||||
return Err(error);
|
||||
}
|
||||
let (preview, previous_preview) = registry.set_running(preview, stop);
|
||||
if let Some(previous_preview) = previous_preview.as_ref() {
|
||||
record_replaced_preview_stop(previous_preview);
|
||||
}
|
||||
if let Err(error) = append_preview_start_trace_step(root, &preview) {
|
||||
let _ = registry.stop();
|
||||
let _ = record_preview_state(root, GameCreationAppPreviewStatus::Failed, None, None);
|
||||
return Err(error);
|
||||
}
|
||||
let (manifest, selected_version, _) = match select_current_runnable_game_version_at(
|
||||
root,
|
||||
expected_project_id.trim(),
|
||||
&version.version_id,
|
||||
) {
|
||||
Ok(selected) => selected,
|
||||
Err(error) => {
|
||||
let _ = registry.stop();
|
||||
let _ = record_preview_state(root, GameCreationAppPreviewStatus::Failed, None, None);
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
Ok(RunnableGameVersionLaunchResult {
|
||||
manifest,
|
||||
version: selected_version,
|
||||
preview,
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_preview_stream(mut stream: TcpStream, root: &Path) {
|
||||
// The listener is nonblocking so its accept loop can observe the stop channel. Windows may
|
||||
// inherit that mode on accepted sockets; switch each connection back to blocking mode before
|
||||
|
||||
@@ -12,6 +12,7 @@ mod manifest;
|
||||
mod memory;
|
||||
mod resource_dependency_graph;
|
||||
mod resource_layout;
|
||||
mod runnable_versions;
|
||||
mod verification;
|
||||
|
||||
pub(crate) use agent_db::*;
|
||||
@@ -23,4 +24,5 @@ pub(crate) use manifest::*;
|
||||
pub(crate) use memory::*;
|
||||
pub(crate) use resource_dependency_graph::*;
|
||||
pub(crate) use resource_layout::*;
|
||||
pub(crate) use runnable_versions::*;
|
||||
pub(crate) use verification::*;
|
||||
|
||||
@@ -635,6 +635,12 @@ pub(crate) fn read_manifest(path: &Path) -> Result<GameCreationAppManifest, Stri
|
||||
.map_err(|error| format!("解析 {label} 失败:{}: {error}", source_path.display()))?;
|
||||
validate_game_iteration_versions(&manifest.versions)
|
||||
.map_err(|error| format!("校验 {label} 项目版本失败:{error}"))?;
|
||||
validate_runnable_game_versions(
|
||||
&manifest.project_id,
|
||||
&manifest.runnable_versions,
|
||||
manifest.current_runnable_version_id.as_deref(),
|
||||
)
|
||||
.map_err(|error| format!("校验 {label} 可运行版本失败:{error}"))?;
|
||||
Ok(manifest)
|
||||
}
|
||||
|
||||
@@ -714,6 +720,12 @@ pub(crate) fn write_manifest(
|
||||
) -> Result<(), String> {
|
||||
validate_game_iteration_versions(&manifest.versions)
|
||||
.map_err(|error| format!("校验 manifest 项目版本失败:{error}"))?;
|
||||
validate_runnable_game_versions(
|
||||
&manifest.project_id,
|
||||
&manifest.runnable_versions,
|
||||
manifest.current_runnable_version_id.as_deref(),
|
||||
)
|
||||
.map_err(|error| format!("校验 manifest 可运行版本失败:{error}"))?;
|
||||
if manifest_storage_exists(path)? {
|
||||
let existing = read_manifest(path)?;
|
||||
if existing.versions.len() > manifest.versions.len()
|
||||
@@ -725,6 +737,15 @@ pub(crate) fn write_manifest(
|
||||
{
|
||||
return Err("项目版本记录写入后不可修改、删除或重排".to_string());
|
||||
}
|
||||
if existing.runnable_versions.len() > manifest.runnable_versions.len()
|
||||
|| existing
|
||||
.runnable_versions
|
||||
.iter()
|
||||
.zip(&manifest.runnable_versions)
|
||||
.any(|(existing, candidate)| existing != candidate)
|
||||
{
|
||||
return Err("可运行版本记录写入后不可修改、删除或重排".to_string());
|
||||
}
|
||||
}
|
||||
let payload = serde_json::to_string_pretty(manifest)
|
||||
.map_err(|error| format!("序列化 manifest 失败:{error}"))?;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3221,6 +3221,39 @@ fn local_preview_server_serves_game_index() {
|
||||
fs::remove_dir_all(root).ok();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_preview_can_serve_an_immutable_version_snapshot_instead_of_the_working_tree() {
|
||||
let root = unique_project_path();
|
||||
init_local_game_project_at(&root, "project-snapshot", "快照预览测试").expect("project init");
|
||||
fs::write(root.join("game/index.html"), "<main>working tree</main>")
|
||||
.expect("write working tree game");
|
||||
let snapshot_root = root.join(".agent/runnable-versions/runnable-r1/artifact");
|
||||
fs::create_dir_all(snapshot_root.join("game")).expect("create snapshot game directory");
|
||||
fs::create_dir_all(snapshot_root.join("assets")).expect("create snapshot assets directory");
|
||||
fs::write(
|
||||
snapshot_root.join("game/index.html"),
|
||||
"<main>immutable snapshot</main>",
|
||||
)
|
||||
.expect("write snapshot game");
|
||||
|
||||
let (preview, stop) = start_local_game_preview_for_served_root(&root, &snapshot_root)
|
||||
.expect("snapshot preview start");
|
||||
let mut stream = TcpStream::connect(("127.0.0.1", preview.port)).expect("preview connect");
|
||||
stream
|
||||
.write_all(b"GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n")
|
||||
.expect("request");
|
||||
let mut response = String::new();
|
||||
stream.read_to_string(&mut response).expect("response");
|
||||
|
||||
assert!(response.contains("200 OK"), "{response}");
|
||||
assert!(response.contains("immutable snapshot"), "{response}");
|
||||
assert!(!response.contains("working tree"), "{response}");
|
||||
assert_eq!(preview.root, root.to_string_lossy());
|
||||
|
||||
let _ = stop.send(());
|
||||
fs::remove_dir_all(root).ok();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_preview_server_drains_split_browser_headers_before_response() {
|
||||
let root = unique_project_path();
|
||||
|
||||
@@ -566,6 +566,7 @@ type AppProps = {
|
||||
gameChatOnly?: boolean;
|
||||
initialSupervisorMessage?: string;
|
||||
onPreviewChange?: (preview: GameCreationAppPreviewState | null) => void;
|
||||
onManifestChange?: (manifest: GameCreationAppManifest) => void;
|
||||
onAgentRuntimeSummariesChange?: (
|
||||
summaries: ProjectAgentRuntimeSummary[],
|
||||
) => void;
|
||||
@@ -580,6 +581,7 @@ export function App({
|
||||
gameChatOnly = false,
|
||||
initialSupervisorMessage = '',
|
||||
onPreviewChange,
|
||||
onManifestChange,
|
||||
onAgentRuntimeSummariesChange,
|
||||
onAgentResultsChange,
|
||||
}: AppProps = {}) {
|
||||
@@ -609,6 +611,11 @@ export function App({
|
||||
const [manifest, setManifest] = useState<GameCreationAppManifest>(
|
||||
initialProjectManifest ?? seedManifest,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (projectSupervisorOnly) {
|
||||
onManifestChange?.(manifest);
|
||||
}
|
||||
}, [manifest, onManifestChange, projectSupervisorOnly]);
|
||||
const [projectStatus, setProjectStatus] = useState(
|
||||
eagerSupervisorProject ? '已初始化' : '未初始化',
|
||||
);
|
||||
|
||||
@@ -51,6 +51,7 @@ export function WorkspaceLauncherShell({
|
||||
setAgentRuntimeSummaries: setActiveProjectAgentRuntimeSummaries,
|
||||
activeProjectAgentResults,
|
||||
setAgentResults: setActiveProjectAgentResults,
|
||||
updateCurrentProjectManifest,
|
||||
resetLauncherHomeDraft,
|
||||
createHomeDraft,
|
||||
openProject,
|
||||
@@ -157,6 +158,8 @@ export function WorkspaceLauncherShell({
|
||||
agentResults={activeProjectAgentResults}
|
||||
onHomeOpen={() => setLauncherView('home')}
|
||||
onProjectsOpen={() => setLauncherView('projects')}
|
||||
onManifestChange={updateCurrentProjectManifest}
|
||||
onPreviewChange={setActiveProjectPreview}
|
||||
supervisor={
|
||||
<ProjectSupervisor
|
||||
key={currentProjectContext.projectPath}
|
||||
@@ -164,6 +167,7 @@ export function WorkspaceLauncherShell({
|
||||
initialProjectManifest={currentProjectContext.manifest}
|
||||
projectSupervisorOnly
|
||||
onPreviewChange={setActiveProjectPreview}
|
||||
onManifestChange={updateCurrentProjectManifest}
|
||||
onAgentRuntimeSummariesChange={
|
||||
setActiveProjectAgentRuntimeSummaries
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ export type ProjectSupervisorComponentProps = {
|
||||
initialProjectManifest?: GameCreationAppManifest;
|
||||
projectSupervisorOnly?: boolean;
|
||||
onPreviewChange?: (preview: GameCreationAppPreviewState | null) => void;
|
||||
onManifestChange?: (manifest: GameCreationAppManifest) => void;
|
||||
onAgentRuntimeSummariesChange?: (
|
||||
summaries: ProjectAgentRuntimeSummary[],
|
||||
) => void;
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
type Dispatch,
|
||||
type FormEvent,
|
||||
type SetStateAction,
|
||||
useCallback,
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
@@ -96,6 +97,16 @@ export function useHomeProjectCreation({
|
||||
rememberRecentWorkspace(context.projectPath);
|
||||
}
|
||||
|
||||
const updateCurrentProjectManifest = useCallback((manifest: GameCreationAppManifest) => {
|
||||
setCurrentProjectContext((current) =>
|
||||
current && current.manifest.projectId === manifest.projectId
|
||||
? current.manifest === manifest
|
||||
? current
|
||||
: { ...current, manifest }
|
||||
: current,
|
||||
);
|
||||
}, []);
|
||||
|
||||
async function importHomeAttachments(
|
||||
invoke: TauriInvoke,
|
||||
nextProjectPath: string,
|
||||
@@ -436,6 +447,7 @@ export function useHomeProjectCreation({
|
||||
setAgentRuntimeSummaries,
|
||||
activeProjectAgentResults,
|
||||
setAgentResults,
|
||||
updateCurrentProjectManifest,
|
||||
pendingNonEmptyProject,
|
||||
resetLauncherHomeDraft,
|
||||
createHomeDraft,
|
||||
|
||||
@@ -4038,6 +4038,14 @@ iframe.preview-frame {
|
||||
0 0 0 2px rgb(216 115 66 / 14%);
|
||||
}
|
||||
|
||||
.game-resource-card.is-current-version {
|
||||
border-color: #c85f31;
|
||||
background: #fff7f1;
|
||||
box-shadow:
|
||||
0 8px 22px rgb(195 105 62 / 18%),
|
||||
inset 0 0 0 2px rgb(216 115 66 / 16%);
|
||||
}
|
||||
|
||||
.game-resource-card-icon {
|
||||
display: grid;
|
||||
grid-row: 1 / 4;
|
||||
@@ -4423,6 +4431,25 @@ iframe.preview-frame {
|
||||
background: #fffdfa;
|
||||
}
|
||||
|
||||
.game-run-version-picker {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: #76574a;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.game-run-version-picker select {
|
||||
min-width: 190px;
|
||||
height: 30px;
|
||||
border: 1px solid #e4cfc4;
|
||||
border-radius: 9px;
|
||||
background: #fff;
|
||||
color: #65483d;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.game-run-preview {
|
||||
position: relative;
|
||||
display: grid;
|
||||
@@ -4497,10 +4524,17 @@ iframe.preview-frame {
|
||||
|
||||
.game-run-panels {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.game-run-status {
|
||||
margin: 0;
|
||||
color: #8b634f;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.game-run-panels > section {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
FileText,
|
||||
FolderTree,
|
||||
Gamepad2,
|
||||
@@ -8,11 +6,8 @@ import {
|
||||
Info,
|
||||
ListFilter,
|
||||
Music2,
|
||||
Pause,
|
||||
Play,
|
||||
Search,
|
||||
Settings2,
|
||||
SlidersHorizontal,
|
||||
Sparkles,
|
||||
X,
|
||||
} from 'lucide-react';
|
||||
@@ -35,7 +30,9 @@ import type {
|
||||
GameCreationAppManifest,
|
||||
GameCreationAppPreviewState,
|
||||
ProjectResourceCanvasLayoutMode,
|
||||
RunnableGameVersion,
|
||||
} from '../../../../../packages/shared/src/contracts/gameCreationApp';
|
||||
import { resolveTauriInvoke } from '../../app/tauri';
|
||||
import {
|
||||
LocalGamePreviewFrame,
|
||||
resolveEmbeddedPreviewUrl,
|
||||
@@ -150,6 +147,18 @@ export type ProjectDevelopmentViewProps = {
|
||||
supervisor: ReactNode;
|
||||
onHomeOpen: () => void;
|
||||
onProjectsOpen: () => void;
|
||||
onManifestChange?: (manifest: GameCreationAppManifest) => void;
|
||||
onPreviewChange?: (preview: GameCreationAppPreviewState | null) => void;
|
||||
};
|
||||
|
||||
type RunnableGameVersionLaunchResult = {
|
||||
manifest: GameCreationAppManifest;
|
||||
version: RunnableGameVersion;
|
||||
preview: {
|
||||
url: string;
|
||||
port: number;
|
||||
root: string;
|
||||
};
|
||||
};
|
||||
|
||||
const categoryOrder: ResourceCategory[] = [
|
||||
@@ -354,6 +363,7 @@ function summarizeAgent(
|
||||
const ResourceCard = memo(function ResourceCard({
|
||||
resource,
|
||||
selected,
|
||||
currentVersion,
|
||||
relationState,
|
||||
x,
|
||||
y,
|
||||
@@ -361,6 +371,7 @@ const ResourceCard = memo(function ResourceCard({
|
||||
}: {
|
||||
resource: ProjectResource;
|
||||
selected: boolean;
|
||||
currentVersion: boolean;
|
||||
relationState: 'version-binding' | null;
|
||||
x: number;
|
||||
y: number;
|
||||
@@ -371,6 +382,8 @@ const ResourceCard = memo(function ResourceCard({
|
||||
<button
|
||||
type="button"
|
||||
className={`game-resource-card${selected ? ' is-selected' : ''}${
|
||||
currentVersion ? ' is-current-version' : ''
|
||||
}${
|
||||
relationState ? ` is-relation-${relationState}` : ''
|
||||
}`}
|
||||
aria-pressed={selected}
|
||||
@@ -409,6 +422,8 @@ export default function ProjectDevelopmentView({
|
||||
agentRuntimeSummaries = emptyProjectAgentRuntimeSummaries,
|
||||
agentResults = emptyProjectAgentResults,
|
||||
supervisor,
|
||||
onManifestChange,
|
||||
onPreviewChange,
|
||||
}: ProjectDevelopmentViewProps) {
|
||||
const [mode, setMode] = useState<WorkbenchMode>('resources');
|
||||
const [sortMode, setSortMode] = useState<ResourceSortMode>('dependency');
|
||||
@@ -423,8 +438,13 @@ export default function ProjectDevelopmentView({
|
||||
const [approvalDialogOpen, setApprovalDialogOpen] = useState(false);
|
||||
const [approvalNotice, setApprovalNotice] = useState('');
|
||||
const [showAllAgentGroups, setShowAllAgentGroups] = useState(false);
|
||||
const [runPlaying, setRunPlaying] = useState(false);
|
||||
const [activeSlice, setActiveSlice] = useState(0);
|
||||
const [runStatus, setRunStatus] = useState('');
|
||||
const [runSwitching, setRunSwitching] = useState(false);
|
||||
const [selectedRunnableVersionId, setSelectedRunnableVersionId] = useState(
|
||||
manifest.currentRunnableVersionId ?? '',
|
||||
);
|
||||
const [activeRunnablePreviewVersionId, setActiveRunnablePreviewVersionId] =
|
||||
useState<string | null>(null);
|
||||
const [imagePreview, setImagePreview] = useState<ImagePreviewState>({
|
||||
status: 'idle',
|
||||
resourceId: null,
|
||||
@@ -443,13 +463,22 @@ export default function ProjectDevelopmentView({
|
||||
const resourceListScrollRef = useRef({ left: 0, top: 0 });
|
||||
const restoreResourceListScrollRef = useRef(false);
|
||||
|
||||
const preview = previewOverride ?? manifest.preview ?? null;
|
||||
const embeddedPreviewUrl = resolveEmbeddedPreviewUrl(preview);
|
||||
const runAvailable =
|
||||
embeddedPreviewUrl !== null ||
|
||||
manifest.tasks.some(
|
||||
(task) => task.id === 'code-prototype' && task.status === 'completed',
|
||||
);
|
||||
const preview =
|
||||
previewOverride !== undefined
|
||||
? previewOverride
|
||||
: (manifest.preview ?? null);
|
||||
const runnableVersions = manifest.runnableVersions ?? [];
|
||||
const currentRunnableVersionId =
|
||||
selectedRunnableVersionId || manifest.currentRunnableVersionId || '';
|
||||
const currentRunnableVersion =
|
||||
runnableVersions.find(
|
||||
(version) => version.versionId === currentRunnableVersionId,
|
||||
) ?? null;
|
||||
const embeddedPreviewUrl =
|
||||
activeRunnablePreviewVersionId === currentRunnableVersionId
|
||||
? resolveEmbeddedPreviewUrl(preview)
|
||||
: null;
|
||||
const runAvailable = runnableVersions.length > 0 && currentRunnableVersion !== null;
|
||||
const projectedResources = useMemo(
|
||||
() => projectResourcesFromReadModels(manifest, attachments, agentResults),
|
||||
[agentResults, attachments, manifest],
|
||||
@@ -602,14 +631,13 @@ export default function ProjectDevelopmentView({
|
||||
[resourceLayout.positions],
|
||||
);
|
||||
const selectedVersionBindingResourceIds = useMemo(() => {
|
||||
const selectedVersion = resources.find(
|
||||
(resource) => resource.id === selectedResourceId,
|
||||
)?.version;
|
||||
if (!selectedVersion) {
|
||||
if (!currentRunnableVersion) {
|
||||
return new Set<string>();
|
||||
}
|
||||
const boundManifestAssetIds = new Set(
|
||||
selectedVersion.resourceBindings.map((binding) => binding.resourceId),
|
||||
currentRunnableVersion.resourceBindings.map(
|
||||
(binding) => binding.resourceId,
|
||||
),
|
||||
);
|
||||
return new Set(
|
||||
resources
|
||||
@@ -620,7 +648,7 @@ export default function ProjectDevelopmentView({
|
||||
)
|
||||
.map((resource) => resource.id),
|
||||
);
|
||||
}, [resources, selectedResourceId]);
|
||||
}, [currentRunnableVersion, resources]);
|
||||
const normalizedSearch = searchText.trim().toLowerCase();
|
||||
const visibleResources = useMemo(
|
||||
() =>
|
||||
@@ -738,6 +766,14 @@ export default function ProjectDevelopmentView({
|
||||
? textPreview.preview.mediaType
|
||||
: focusedResource?.mediaType;
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedRunnableVersionId(manifest.currentRunnableVersionId ?? '');
|
||||
}, [manifest.currentRunnableVersionId, manifest.projectId]);
|
||||
|
||||
useEffect(() => {
|
||||
setActiveRunnablePreviewVersionId(null);
|
||||
}, [manifest.projectId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (embeddedPreviewUrl) {
|
||||
setFocusedResourceId(null);
|
||||
@@ -955,12 +991,60 @@ export default function ProjectDevelopmentView({
|
||||
setFocusedResourceId(null);
|
||||
}
|
||||
|
||||
async function launchRunnableVersion(versionId: string) {
|
||||
const invoke = resolveTauriInvoke();
|
||||
if (!invoke) {
|
||||
setRunStatus('需要在 Tauri App 内运行');
|
||||
return false;
|
||||
}
|
||||
setRunSwitching(true);
|
||||
setRunStatus('正在启动可运行版本');
|
||||
setSelectedRunnableVersionId(versionId);
|
||||
setActiveRunnablePreviewVersionId(null);
|
||||
onPreviewChange?.(null);
|
||||
try {
|
||||
const result = await invoke<RunnableGameVersionLaunchResult>(
|
||||
'launch_local_game_runnable_version',
|
||||
{
|
||||
projectPath,
|
||||
expectedProjectId: manifest.projectId,
|
||||
versionId,
|
||||
},
|
||||
);
|
||||
onManifestChange?.(result.manifest);
|
||||
onPreviewChange?.({
|
||||
status: 'running',
|
||||
url: result.preview.url,
|
||||
port: result.preview.port,
|
||||
});
|
||||
setSelectedRunnableVersionId(result.version.versionId);
|
||||
setActiveRunnablePreviewVersionId(result.version.versionId);
|
||||
setRunStatus(`正在运行版本 ${result.version.versionId}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
setSelectedRunnableVersionId(manifest.currentRunnableVersionId ?? '');
|
||||
setActiveRunnablePreviewVersionId(null);
|
||||
setRunStatus(message);
|
||||
onPreviewChange?.({ status: 'failed' });
|
||||
return false;
|
||||
} finally {
|
||||
setRunSwitching(false);
|
||||
}
|
||||
}
|
||||
|
||||
function showRunView() {
|
||||
if (!runAvailable) {
|
||||
if (!currentRunnableVersion) {
|
||||
setRunStatus(
|
||||
runnableVersions.length > 0
|
||||
? '当前可运行版本选择无效'
|
||||
: '当前无可运行版本',
|
||||
);
|
||||
return;
|
||||
}
|
||||
setFocusedResourceId(null);
|
||||
setMode('run');
|
||||
void launchRunnableVersion(currentRunnableVersion.versionId);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -1034,6 +1118,26 @@ export default function ProjectDevelopmentView({
|
||||
按类型
|
||||
</button>
|
||||
</>
|
||||
) : mode === 'run' && currentRunnableVersion ? (
|
||||
<label className="game-run-version-picker">
|
||||
运行版本
|
||||
<select
|
||||
aria-label="当前运行版本"
|
||||
value={currentRunnableVersion.versionId}
|
||||
disabled={runSwitching}
|
||||
onChange={(event) => {
|
||||
const versionId = event.currentTarget.value;
|
||||
setSelectedRunnableVersionId(versionId);
|
||||
void launchRunnableVersion(versionId);
|
||||
}}
|
||||
>
|
||||
{runnableVersions.map((version, index) => (
|
||||
<option key={version.versionId} value={version.versionId}>
|
||||
{`版本 ${index + 1} · revision ${version.projectRevision}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1044,7 +1148,7 @@ export default function ProjectDevelopmentView({
|
||||
className="game-run-unavailable"
|
||||
role="status"
|
||||
>
|
||||
首个可运行原型尚未完成,运行视图暂不可用
|
||||
{runStatus || '当前无可运行版本'}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
@@ -1389,6 +1493,10 @@ export default function ProjectDevelopmentView({
|
||||
key={resource.id}
|
||||
resource={resource}
|
||||
selected={resource.id === selectedResourceId}
|
||||
currentVersion={
|
||||
resource.version?.versionId ===
|
||||
currentRunnableVersion?.versionId
|
||||
}
|
||||
relationState={relationState}
|
||||
x={position.x}
|
||||
y={position.y}
|
||||
@@ -1417,92 +1525,44 @@ export default function ProjectDevelopmentView({
|
||||
) : (
|
||||
<div className="game-run-preview-empty">
|
||||
<Sparkles size={28} aria-hidden="true" />
|
||||
<strong>客户端运行画面尚未载入</strong>
|
||||
<span>发送 /run 或 /preview 后将在这里直接运行游戏</span>
|
||||
<strong>
|
||||
{runSwitching ? '正在切换可运行版本' : '运行画面未启动'}
|
||||
</strong>
|
||||
<span>{runStatus || '请重新启动当前可运行版本'}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="game-run-slice-controls"
|
||||
aria-label="测试切片控件"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="上一个测试切片"
|
||||
onClick={() =>
|
||||
setActiveSlice((current) => Math.max(0, current - 1))
|
||||
}
|
||||
>
|
||||
<ChevronLeft size={16} aria-hidden="true" />
|
||||
上一项
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={runPlaying ? '暂停测试' : '播放测试'}
|
||||
onClick={() => setRunPlaying((playing) => !playing)}
|
||||
>
|
||||
{runPlaying ? (
|
||||
<Pause size={18} aria-hidden="true" />
|
||||
) : (
|
||||
<Play size={18} aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
<span>{`测试切片 ${activeSlice + 1}`}</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="下一个测试切片"
|
||||
onClick={() => setActiveSlice((current) => current + 1)}
|
||||
>
|
||||
下一项
|
||||
<ChevronRight size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="game-run-panels">
|
||||
<section aria-label="资源信息面板">
|
||||
<section aria-label="可运行版本信息">
|
||||
<header>
|
||||
<Info size={16} aria-hidden="true" />
|
||||
信息展示
|
||||
当前版本
|
||||
</header>
|
||||
{selectedResource ? (
|
||||
{currentRunnableVersion ? (
|
||||
<dl>
|
||||
<div>
|
||||
<dt>名称</dt>
|
||||
<dd>{selectedResource.label}</dd>
|
||||
<dt>版本</dt>
|
||||
<dd>{currentRunnableVersion.versionId}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>路径</dt>
|
||||
<dd>{selectedResource.path}</dd>
|
||||
<dt>修订</dt>
|
||||
<dd>{currentRunnableVersion.projectRevision}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>类型</dt>
|
||||
<dd>{selectedResource.mediaType}</dd>
|
||||
<dt>验证</dt>
|
||||
<dd>静态检查与交互试玩均通过</dd>
|
||||
</div>
|
||||
</dl>
|
||||
) : (
|
||||
<p>暂停后选择资源可查看已登记信息</p>
|
||||
<p>当前无可运行版本</p>
|
||||
)}
|
||||
</section>
|
||||
<section aria-label="数值微调面板">
|
||||
<header>
|
||||
<SlidersHorizontal size={16} aria-hidden="true" />
|
||||
数值微调
|
||||
</header>
|
||||
<label>
|
||||
角色移动速度
|
||||
<input type="number" disabled placeholder="未载入" />
|
||||
</label>
|
||||
<label>
|
||||
跳跃高度
|
||||
<input type="number" disabled placeholder="未载入" />
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
disabled
|
||||
aria-label="新增微调数值项"
|
||||
placeholder="用自然语言新增微调项(尚未接入)"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
{runStatus ? (
|
||||
<p className="game-run-status" role="status">
|
||||
{runStatus}
|
||||
</p>
|
||||
) : null}
|
||||
</section>
|
||||
)}
|
||||
</section>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type {
|
||||
GameCreationAppManifest,
|
||||
GameIterationVersion,
|
||||
ProjectResourceCanvasSection,
|
||||
RunnableGameVersion,
|
||||
} from '../../../../../packages/shared/src/contracts/gameCreationApp';
|
||||
|
||||
export type ProjectResourceCategory = ProjectResourceCanvasSection;
|
||||
@@ -23,7 +23,7 @@ export type ProjectAgentResultSummary = {
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
export type ProjectVersionResourceSummary = GameIterationVersion & {
|
||||
export type ProjectVersionResourceSummary = RunnableGameVersion & {
|
||||
label: string;
|
||||
childVersionIds: string[];
|
||||
};
|
||||
@@ -231,7 +231,7 @@ export function projectResourcesFromReadModels(
|
||||
}
|
||||
|
||||
const childVersionIdsByParent = new Map<string, string[]>();
|
||||
for (const version of manifest.versions ?? []) {
|
||||
for (const version of manifest.runnableVersions ?? []) {
|
||||
if (!version.parentVersionId) {
|
||||
continue;
|
||||
}
|
||||
@@ -239,7 +239,9 @@ export function projectResourcesFromReadModels(
|
||||
children.push(version.versionId);
|
||||
childVersionIdsByParent.set(version.parentVersionId, children);
|
||||
}
|
||||
for (const [index, manifestVersion] of (manifest.versions ?? []).entries()) {
|
||||
for (const [index, manifestVersion] of (
|
||||
manifest.runnableVersions ?? []
|
||||
).entries()) {
|
||||
const version: ProjectVersionResourceSummary = {
|
||||
...manifestVersion,
|
||||
label: `版本 ${index + 1}`,
|
||||
@@ -251,8 +253,8 @@ export function projectResourcesFromReadModels(
|
||||
category: 'version',
|
||||
subtype: 'project-version',
|
||||
label: version.label,
|
||||
path: `项目版本 · ${version.versionId}`,
|
||||
mediaType: '正式项目版本',
|
||||
path: `可运行版本 · ${version.versionId}`,
|
||||
mediaType: '正式可运行版本',
|
||||
sourceLabel: version.parentVersionId
|
||||
? `项目修订 ${version.projectRevision} · 父版本 ${version.parentVersionId}`
|
||||
: `项目修订 ${version.projectRevision} · 初始版本`,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
ProjectResourceCanvasLayout,
|
||||
ProjectResourceCanvasPosition,
|
||||
RunnableGameVersion,
|
||||
} from '../../../../packages/shared/src/contracts/gameCreationApp';
|
||||
import {
|
||||
consumeInitialGameChatMessage,
|
||||
@@ -56,6 +57,36 @@ import {
|
||||
within,
|
||||
} from './harness';
|
||||
|
||||
function runnableVersionFixture(
|
||||
projectId: string,
|
||||
versionId: string,
|
||||
projectRevision: number,
|
||||
overrides: Partial<RunnableGameVersion> = {},
|
||||
): RunnableGameVersion {
|
||||
return {
|
||||
schemaVersion: 'game-creator-runnable-version.v1',
|
||||
versionId,
|
||||
projectId,
|
||||
parentVersionId: null,
|
||||
projectRevision,
|
||||
artifactPath: `.agent/runnable-versions/${versionId}/artifact`,
|
||||
artifactSha256: 'a'.repeat(64),
|
||||
entryPath: 'game/index.html',
|
||||
resourceBindings: [],
|
||||
createdReason: 'initial',
|
||||
validation: {
|
||||
staticSmokePassed: true,
|
||||
previewValidatePassed: true,
|
||||
playtestPassed: true,
|
||||
agentId: 'program-agent',
|
||||
runId: `run-${projectRevision}`,
|
||||
reportPath: `.agent/runtime/browser-validations/program-agent/run-${projectRevision}/1/validation.json`,
|
||||
},
|
||||
createdAt: projectRevision * 100,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function resourceGraphForInputs(args?: Record<string, unknown>) {
|
||||
const resources =
|
||||
(args?.resources as
|
||||
@@ -647,7 +678,7 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
fireEvent.click(runTab);
|
||||
expect(runTab.getAttribute('aria-selected')).toBe('false');
|
||||
expect(
|
||||
screen.getByText('首个可运行原型尚未完成,运行视图暂不可用'),
|
||||
screen.getByText('当前无可运行版本'),
|
||||
).not.toBeNull();
|
||||
expect(screen.getByLabelText('附件导入失败')).not.toBeNull();
|
||||
expect(screen.getByText('broken-reference.png')).not.toBeNull();
|
||||
@@ -693,27 +724,20 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
source: { kind: 'generated' },
|
||||
},
|
||||
];
|
||||
manifest.versions = [
|
||||
{
|
||||
versionId: 'version-root',
|
||||
parentVersionId: null,
|
||||
projectRevision: 3,
|
||||
manifest.runnableVersions = [
|
||||
runnableVersionFixture('workbench-versions', 'version-root', 3, {
|
||||
resourceBindings: [{ slotId: 'player', resourceId: 'asset-player' }],
|
||||
createdReason: 'initial',
|
||||
createdAt: 100,
|
||||
},
|
||||
{
|
||||
versionId: 'version-child',
|
||||
}),
|
||||
runnableVersionFixture('workbench-versions', 'version-child', 4, {
|
||||
parentVersionId: 'version-root',
|
||||
projectRevision: 4,
|
||||
resourceBindings: [
|
||||
{ slotId: 'player', resourceId: 'asset-player' },
|
||||
{ slotId: 'historical', resourceId: 'asset-removed' },
|
||||
],
|
||||
createdReason: 'agent-revision',
|
||||
createdAt: 200,
|
||||
},
|
||||
}),
|
||||
];
|
||||
manifest.currentRunnableVersionId = 'version-child';
|
||||
|
||||
render(
|
||||
React.createElement(ProjectDevelopmentView, {
|
||||
@@ -1838,6 +1862,13 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
throw new Error('missing code-prototype seed task');
|
||||
}
|
||||
codePrototype.status = 'completed';
|
||||
const runnableVersion = runnableVersionFixture(
|
||||
'workbench-runnable',
|
||||
'runnable-r7',
|
||||
7,
|
||||
);
|
||||
manifest.runnableVersions = [runnableVersion];
|
||||
manifest.currentRunnableVersionId = runnableVersion.versionId;
|
||||
manifest.preview = {
|
||||
status: 'running',
|
||||
url: 'http://127.0.0.1:4173',
|
||||
@@ -1868,6 +1899,22 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
|
||||
};
|
||||
}
|
||||
if (command === 'launch_local_game_runnable_version') {
|
||||
expect(args).toEqual({
|
||||
projectPath: '/tmp/workbench-runnable',
|
||||
expectedProjectId: 'workbench-runnable',
|
||||
versionId: 'runnable-r7',
|
||||
});
|
||||
return {
|
||||
manifest,
|
||||
version: runnableVersion,
|
||||
preview: {
|
||||
url: 'http://127.0.0.1:4173',
|
||||
port: 4173,
|
||||
root: '/tmp/workbench-runnable',
|
||||
},
|
||||
};
|
||||
}
|
||||
throw new Error(`unexpected invoke ${command}`);
|
||||
},
|
||||
);
|
||||
@@ -1893,16 +1940,26 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
expect(runTab.disabled).toBe(false);
|
||||
fireEvent.click(runTab);
|
||||
expect(screen.getByLabelText('运行表现层')).not.toBeNull();
|
||||
const previewFrame = screen.getByTitle(
|
||||
const previewFrame = (await screen.findByTitle(
|
||||
'可运行工作台 游戏运行画面',
|
||||
) as HTMLIFrameElement;
|
||||
)) as HTMLIFrameElement;
|
||||
expect(previewFrame.getAttribute('src')).toBe('http://127.0.0.1:4173/');
|
||||
expect(previewFrame.getAttribute('sandbox')).toBe(
|
||||
'allow-scripts allow-same-origin allow-forms allow-pointer-lock',
|
||||
);
|
||||
expect(screen.getByLabelText('测试切片控件')).not.toBeNull();
|
||||
expect(screen.getByLabelText('资源信息面板')).not.toBeNull();
|
||||
expect(screen.getByLabelText('数值微调面板')).not.toBeNull();
|
||||
await waitFor(() => {
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
'launch_local_game_runnable_version',
|
||||
{
|
||||
projectPath: '/tmp/workbench-runnable',
|
||||
expectedProjectId: 'workbench-runnable',
|
||||
versionId: 'runnable-r7',
|
||||
},
|
||||
);
|
||||
});
|
||||
expect(screen.getByLabelText('可运行版本信息')).not.toBeNull();
|
||||
expect(screen.queryByLabelText('测试切片控件')).toBeNull();
|
||||
expect(screen.queryByLabelText('数值微调面板')).toBeNull();
|
||||
|
||||
fireEvent.click(screen.getByRole('tab', { name: '资源管理' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '按类型' }));
|
||||
@@ -1930,6 +1987,166 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
);
|
||||
});
|
||||
|
||||
it('unloads the old iframe before switching to another runnable version snapshot', async () => {
|
||||
const manifest = createGameCreationAppManifest(
|
||||
'workbench-version-switch',
|
||||
'版本切换测试',
|
||||
);
|
||||
const first = runnableVersionFixture(
|
||||
manifest.projectId,
|
||||
'runnable-r1',
|
||||
1,
|
||||
);
|
||||
const second = runnableVersionFixture(
|
||||
manifest.projectId,
|
||||
'runnable-r2',
|
||||
2,
|
||||
{
|
||||
parentVersionId: first.versionId,
|
||||
createdReason: 'agent-revision',
|
||||
},
|
||||
);
|
||||
manifest.runnableVersions = [first, second];
|
||||
manifest.currentRunnableVersionId = first.versionId;
|
||||
manifest.preview = {
|
||||
status: 'running',
|
||||
url: 'http://127.0.0.1:4101',
|
||||
port: 4101,
|
||||
};
|
||||
let resolveSecondLaunch: ((value: unknown) => void) | null = null;
|
||||
const secondLaunch = new Promise((resolve) => {
|
||||
resolveSecondLaunch = resolve;
|
||||
});
|
||||
const invoke = vi.fn(async (command: string, args?: Record<string, unknown>) => {
|
||||
if (command !== 'launch_local_game_runnable_version') {
|
||||
throw new Error(`unexpected invoke ${command}`);
|
||||
}
|
||||
if (args?.versionId === first.versionId) {
|
||||
return {
|
||||
manifest,
|
||||
version: first,
|
||||
preview: {
|
||||
url: 'http://127.0.0.1:4101',
|
||||
port: 4101,
|
||||
root: '/tmp/workbench-version-switch',
|
||||
},
|
||||
};
|
||||
}
|
||||
return secondLaunch;
|
||||
});
|
||||
window.__TAURI__ = { core: { invoke } };
|
||||
|
||||
function StatefulWorkbench() {
|
||||
const [liveManifest, setLiveManifest] = React.useState(manifest);
|
||||
const [preview, setPreview] = React.useState(manifest.preview ?? null);
|
||||
return React.createElement(ProjectDevelopmentView, {
|
||||
projectName: manifest.name,
|
||||
projectPath: '/tmp/workbench-version-switch',
|
||||
manifest: liveManifest,
|
||||
attachments: [],
|
||||
recentRunStatus: null,
|
||||
recentRunStopReason: null,
|
||||
preview,
|
||||
supervisor: React.createElement('div', null, '项目总控'),
|
||||
onHomeOpen: vi.fn(),
|
||||
onProjectsOpen: vi.fn(),
|
||||
onManifestChange: setLiveManifest,
|
||||
onPreviewChange: setPreview,
|
||||
});
|
||||
}
|
||||
|
||||
render(React.createElement(StatefulWorkbench));
|
||||
fireEvent.click(screen.getByRole('tab', { name: '运行' }));
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen
|
||||
.getByTitle('版本切换测试 游戏运行画面')
|
||||
.getAttribute('src'),
|
||||
).toBe('http://127.0.0.1:4101/');
|
||||
});
|
||||
|
||||
fireEvent.change(screen.getByLabelText('当前运行版本'), {
|
||||
target: { value: second.versionId },
|
||||
});
|
||||
expect(screen.queryByTitle('版本切换测试 游戏运行画面')).toBeNull();
|
||||
expect(screen.getByText('正在切换可运行版本')).not.toBeNull();
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
'launch_local_game_runnable_version',
|
||||
{
|
||||
projectPath: '/tmp/workbench-version-switch',
|
||||
expectedProjectId: manifest.projectId,
|
||||
versionId: second.versionId,
|
||||
},
|
||||
);
|
||||
|
||||
const switchedManifest = {
|
||||
...manifest,
|
||||
currentRunnableVersionId: second.versionId,
|
||||
preview: {
|
||||
status: 'running' as const,
|
||||
url: 'http://127.0.0.1:4102',
|
||||
port: 4102,
|
||||
},
|
||||
};
|
||||
await act(async () => {
|
||||
resolveSecondLaunch?.({
|
||||
manifest: switchedManifest,
|
||||
version: second,
|
||||
preview: {
|
||||
url: 'http://127.0.0.1:4102',
|
||||
port: 4102,
|
||||
root: '/tmp/workbench-version-switch',
|
||||
},
|
||||
});
|
||||
await secondLaunch;
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen
|
||||
.getByTitle('版本切换测试 游戏运行画面')
|
||||
.getAttribute('src'),
|
||||
).toBe('http://127.0.0.1:4102/');
|
||||
});
|
||||
});
|
||||
|
||||
it('shows a precise runnable version launch failure without embedding a preview', async () => {
|
||||
const manifest = createGameCreationAppManifest(
|
||||
'workbench-version-failure',
|
||||
'版本错误测试',
|
||||
);
|
||||
const version = runnableVersionFixture(
|
||||
manifest.projectId,
|
||||
'runnable-r3',
|
||||
3,
|
||||
);
|
||||
manifest.runnableVersions = [version];
|
||||
manifest.currentRunnableVersionId = version.versionId;
|
||||
const invoke = vi.fn(async () => {
|
||||
throw new Error('可运行版本 revision 不一致');
|
||||
});
|
||||
window.__TAURI__ = { core: { invoke } };
|
||||
|
||||
render(
|
||||
React.createElement(ProjectDevelopmentView, {
|
||||
projectName: manifest.name,
|
||||
projectPath: '/tmp/workbench-version-failure',
|
||||
manifest,
|
||||
attachments: [],
|
||||
recentRunStatus: null,
|
||||
recentRunStopReason: null,
|
||||
supervisor: React.createElement('div', null, '项目总控'),
|
||||
onHomeOpen: vi.fn(),
|
||||
onProjectsOpen: vi.fn(),
|
||||
}),
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole('tab', { name: '运行' }));
|
||||
expect(
|
||||
(await screen.findAllByText('可运行版本 revision 不一致')).length,
|
||||
).toBeGreaterThan(0);
|
||||
expect(screen.queryByTitle('版本错误测试 游戏运行画面')).toBeNull();
|
||||
});
|
||||
|
||||
it('marks an unvalidated UI prototype as a candidate image', () => {
|
||||
const manifest = createGameCreationAppManifest(
|
||||
'workbench-ui-candidate',
|
||||
@@ -1984,7 +2201,7 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
).not.toBeNull();
|
||||
});
|
||||
|
||||
it('refuses to embed a non-loopback game preview in the client workbench', () => {
|
||||
it('does not treat completed code or an ordinary loopback preview as run authorization', () => {
|
||||
const manifest = createGameCreationAppManifest(
|
||||
'workbench-remote-preview',
|
||||
'远程预览拒绝测试',
|
||||
@@ -1998,8 +2215,8 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
codePrototype.status = 'completed';
|
||||
manifest.preview = {
|
||||
status: 'running',
|
||||
url: 'https://example.com/game',
|
||||
port: 443,
|
||||
url: 'http://127.0.0.1:4188',
|
||||
port: 4188,
|
||||
};
|
||||
|
||||
render(
|
||||
@@ -2018,7 +2235,10 @@ export function registerProjectWorkbenchFoundationTests() {
|
||||
|
||||
fireEvent.click(screen.getByRole('tab', { name: '运行' }));
|
||||
expect(screen.queryByTitle('远程预览拒绝测试 游戏运行画面')).toBeNull();
|
||||
expect(screen.getByText('客户端运行画面尚未载入')).not.toBeNull();
|
||||
expect(screen.getByText('当前无可运行版本')).not.toBeNull();
|
||||
expect(
|
||||
screen.getByRole('tab', { name: '运行' }).getAttribute('aria-selected'),
|
||||
).toBe('false');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { createGameCreationAppManifest } from '../../../packages/shared/src/contracts/gameCreationApp';
|
||||
import {
|
||||
createGameCreationAppManifest,
|
||||
type RunnableGameVersion,
|
||||
} from '../../../packages/shared/src/contracts/gameCreationApp';
|
||||
import { projectResourcesFromReadModels } from '../src/view/project-development/resourceProjectionModel';
|
||||
|
||||
function runnableVersionFixture(
|
||||
projectId: string,
|
||||
versionId: string,
|
||||
projectRevision: number,
|
||||
overrides: Partial<RunnableGameVersion> = {},
|
||||
): RunnableGameVersion {
|
||||
return {
|
||||
schemaVersion: 'game-creator-runnable-version.v1',
|
||||
versionId,
|
||||
projectId,
|
||||
parentVersionId: null,
|
||||
projectRevision,
|
||||
artifactPath: `.agent/runnable-versions/${versionId}/artifact`,
|
||||
artifactSha256: 'a'.repeat(64),
|
||||
entryPath: 'game/index.html',
|
||||
resourceBindings: [],
|
||||
createdReason: 'initial',
|
||||
validation: {
|
||||
staticSmokePassed: true,
|
||||
previewValidatePassed: true,
|
||||
playtestPassed: true,
|
||||
agentId: 'program-agent',
|
||||
runId: `run-${projectRevision}`,
|
||||
reportPath: `.agent/runtime/browser-validations/program-agent/run-${projectRevision}/1/validation.json`,
|
||||
},
|
||||
createdAt: projectRevision * 100,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('项目资源投影', () => {
|
||||
it('只把明确资源投影到固定分类,未知任务产物不会伪装成项目版本', () => {
|
||||
const manifest = createGameCreationAppManifest(
|
||||
@@ -49,18 +82,14 @@ describe('项目资源投影', () => {
|
||||
source: { kind: 'generated' },
|
||||
},
|
||||
];
|
||||
manifest.versions = [
|
||||
{
|
||||
versionId: 'version-1',
|
||||
parentVersionId: null,
|
||||
projectRevision: 7,
|
||||
manifest.runnableVersions = [
|
||||
runnableVersionFixture('resource-projection', 'version-1', 7, {
|
||||
resourceBindings: [
|
||||
{ slotId: 'background-music', resourceId: 'registered-bgm' },
|
||||
],
|
||||
createdReason: 'initial',
|
||||
createdAt: 1,
|
||||
},
|
||||
}),
|
||||
];
|
||||
manifest.currentRunnableVersionId = 'version-1';
|
||||
|
||||
const resources = projectResourcesFromReadModels(
|
||||
manifest,
|
||||
@@ -137,16 +166,10 @@ describe('项目资源投影', () => {
|
||||
'stable-resource-id',
|
||||
'稳定资源身份测试',
|
||||
);
|
||||
manifest.versions = [
|
||||
{
|
||||
versionId: 'stable-version',
|
||||
parentVersionId: null,
|
||||
projectRevision: 1,
|
||||
resourceBindings: [],
|
||||
createdReason: 'initial',
|
||||
createdAt: 1,
|
||||
},
|
||||
manifest.runnableVersions = [
|
||||
runnableVersionFixture('stable-resource-id', 'stable-version', 1),
|
||||
];
|
||||
manifest.currentRunnableVersionId = 'stable-version';
|
||||
const first = projectResourcesFromReadModels(
|
||||
manifest,
|
||||
[],
|
||||
@@ -184,24 +207,14 @@ describe('项目资源投影', () => {
|
||||
'version-projection',
|
||||
'版本投影测试',
|
||||
);
|
||||
manifest.versions = [
|
||||
{
|
||||
versionId: 'version-root',
|
||||
parentVersionId: null,
|
||||
projectRevision: 2,
|
||||
resourceBindings: [],
|
||||
createdReason: 'initial',
|
||||
createdAt: 100,
|
||||
},
|
||||
{
|
||||
versionId: 'version-child',
|
||||
manifest.runnableVersions = [
|
||||
runnableVersionFixture('version-projection', 'version-root', 2),
|
||||
runnableVersionFixture('version-projection', 'version-child', 3, {
|
||||
parentVersionId: 'version-root',
|
||||
projectRevision: 3,
|
||||
resourceBindings: [],
|
||||
createdReason: 'agent-revision',
|
||||
createdAt: 200,
|
||||
},
|
||||
}),
|
||||
];
|
||||
manifest.currentRunnableVersionId = 'version-child';
|
||||
|
||||
const versions = projectResourcesFromReadModels(manifest, [], []).filter(
|
||||
(resource) => resource.category === 'version',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AI 游戏创作项目开发工作台 PRD
|
||||
|
||||
更新时间:`2026-08-04`(依赖视图视觉口径调整)
|
||||
更新时间:`2026-08-04`(可运行版本 P0/P1)
|
||||
|
||||
## 1. 产品定位
|
||||
|
||||
@@ -281,7 +281,7 @@ type UpdateProjectResourceCanvasLayoutResult =
|
||||
资源身份固定使用 manifest asset ID、正式 version ID、Agent ID + run ID 或已导入资源稳定路径;显示标题、来源文案变化不得改变 `resourceId`,从而避免布局、依赖边、选择和聚焦状态因改名失效。
|
||||
|
||||
```ts
|
||||
type ProjectResourceDescriptor = {
|
||||
type GameResourceDescriptor = {
|
||||
resourceId: string;
|
||||
category: 'document' | 'version' | 'art' | 'audio';
|
||||
subtype: string;
|
||||
@@ -305,31 +305,48 @@ type ProjectVersionResourceReplacement = {
|
||||
|
||||
三项兼容性必须同时为 true 才能创建下一版本。
|
||||
|
||||
### 5.4 游戏迭代版本(P1)
|
||||
### 5.4 可运行游戏版本(P0 合同,P1 实现)
|
||||
|
||||
阶段六实现状态(2026-08-03):正式版本业务真相扩展在本地项目 `.agent/manifest.json` 的可选 `versions` 字段中;旧项目字段缺失时等价于空列表,不根据 checkpoint、布局 sidecar、预览记录或 `game-creator-project-revision.v1` 自动伪造版本。版本数组只允许追加,已有记录不得删除、重排或修改;首轮没有版本创建按钮,也不自动把当前编辑态登记为版本。
|
||||
`GameIterationVersion` 与 manifest `versions` 是上一阶段资源管理使用的只读迭代记录,不代表已经通过试玩,也不再作为运行入口授权。唯一可运行事实源是 `.agent/manifest.json` 中由可信 Rust / Runtime 追加的 `runnableVersions` 与可变选择指针 `currentRunnableVersionId`;前端、Agent 文本、任务完成状态、checkpoint、布局 sidecar 和普通 preview 状态均无权自行创建可运行版本。
|
||||
|
||||
```ts
|
||||
type GameIterationVersion = {
|
||||
type RunnableGameVersion = {
|
||||
schemaVersion: 'game-creator-runnable-version.v1';
|
||||
versionId: string;
|
||||
projectId: string;
|
||||
parentVersionId: string | null;
|
||||
projectRevision: number;
|
||||
artifactPath: `.agent/runnable-versions/${string}/artifact`;
|
||||
artifactSha256: string;
|
||||
entryPath: 'game/index.html';
|
||||
resourceBindings: Array<{ slotId: string; resourceId: string }>;
|
||||
createdReason: 'initial' | 'resource-replacement' | 'agent-revision';
|
||||
createdReason: 'initial' | 'agent-revision';
|
||||
validation: {
|
||||
staticSmokePassed: true;
|
||||
previewValidatePassed: true;
|
||||
playtestPassed: true;
|
||||
agentId: string;
|
||||
runId: string;
|
||||
reportPath: string;
|
||||
};
|
||||
createdAt: number;
|
||||
};
|
||||
|
||||
type GameCreationAppManifest = {
|
||||
// 既有字段省略
|
||||
versions?: GameIterationVersion[];
|
||||
runnableVersions?: RunnableGameVersion[];
|
||||
currentRunnableVersionId?: string | null;
|
||||
};
|
||||
```
|
||||
|
||||
- `versions` 按追加顺序保存。第一条必须是 `initial + parentVersionId=null`;后续记录必须引用数组中更早出现的父版本,创建原因不能再是 `initial`,从而天然排除自引用、悬空父版本和父子环。
|
||||
- `projectRevision` 与 `createdAt` 必须是 JavaScript 安全非负整数;子版本的修订必须严格大于父版本,创建时间不得早于父版本。
|
||||
- 当前 revision 只有同时满足 `preview-playtest` 传递前置任务闭包的项目完整性检查、当前 revision 的 `game.static_smoke` 通过、当前 revision 的 `preview.validate` 与真实交互试玩通过,才允许由 Runtime 登记版本。试玩后的 `publish-strategy / publish-package` 等下游交付节点不阻断可运行版本登记。首个通过版本自动登记为 `initial`;后续 Agent 修订重新完整通过后登记为 `agent-revision`。
|
||||
- 每条版本在登记时把 `game/` 与 `assets/` 复制到受保护的不可变快照目录,计算确定性 SHA-256;运行旧版本只服务该快照,不读取当前编辑工作树。启动前必须复核目录、版本描述、revision 与摘要,任何漂移都按“版本损坏”失败关闭。
|
||||
- `runnableVersions` 按追加顺序保存。第一条必须是 `initial + parentVersionId=null`;后续记录必须引用数组中更早出现的父版本并使用 `agent-revision`。同一 project revision 最多一条,重复完成投影必须幂等返回原记录。
|
||||
- `projectId` 必须等于当前 manifest,`projectRevision` 必须为 JavaScript 安全正整数;子版本 revision 严格大于父版本,创建时间不得早于父版本。
|
||||
- 同一版本内 `slotId` 唯一;`resourceId` 固定保存 manifest asset ID,不保存资源卡显示名称、External Editor resource ID、路径或布局 ID。历史资源已不在当前 manifest 时仍保留原绑定,但界面不为其合成资源卡。
|
||||
- Tauri manifest 存储边界在每次写入前校验完整版本图,并与磁盘中的旧 `versions` 前缀逐项比较;只允许追加新记录,已有记录被修改、删除或重排时写入失败且原文件保持不变。
|
||||
- 版本卡标题由稳定追加序号生成,卡片与聚焦态展示 `versionId / projectRevision / createdReason / parentVersionId`;聚焦态额外展示直接子版本和全部 slot 绑定。点击版本卡只高亮当前投影中唯一匹配 `asset:<resourceId>` 的资源卡,不修改版本或资源。
|
||||
- Tauri manifest 存储边界在每次写入前校验完整版本图,并与磁盘中的旧 `runnableVersions` 前缀逐项比较;只允许追加,已有记录被修改、删除或重排时写入失败且原文件保持不变。`currentRunnableVersionId` 只能指向现存记录,允许通过专用 Tauri 命令更新。
|
||||
- 运行入口只读取当前可运行版本。切换版本时先停止当前项目旧 preview、立即卸载 iframe,再复核并启动目标快照;启动成功后回写当前选择和 loopback preview。无版本、版本损坏、版本描述 revision 不一致、权限拒绝或预览启动失败分别显示明确原因。
|
||||
- 资源管理只从 `runnableVersions` 投影“可运行版本”卡。当前选择版本的全部现存绑定资产始终高亮;点击其它版本可只读查看其父子关系和历史绑定,不改变当前运行选择。
|
||||
|
||||
### 5.5 测试切片与数值参数(P2)
|
||||
|
||||
@@ -355,9 +372,40 @@ type GameTunableParameterDefinition = {
|
||||
writePath: string;
|
||||
codeMutationAllowed: false;
|
||||
};
|
||||
|
||||
type GameRunSession = {
|
||||
sessionId: string;
|
||||
projectId: string;
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
status: 'starting' | 'playing' | 'paused' | 'stopped' | 'failed';
|
||||
stale: boolean;
|
||||
staleReason: 'project-revision-changed' | 'version-changed' | null;
|
||||
startedAt: number;
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
type GameHostMessage = {
|
||||
schemaVersion: 'game-creator-host-message.v1';
|
||||
sessionId: string;
|
||||
sequence: number;
|
||||
type: 'host.start' | 'host.pause' | 'host.resume' | 'host.stop';
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
};
|
||||
|
||||
type GameRuntimeMessage = {
|
||||
schemaVersion: 'game-creator-runtime-message.v1';
|
||||
sessionId: string;
|
||||
sequence: number;
|
||||
type: 'runtime.ready' | 'runtime.state' | 'runtime.completed' | 'runtime.failed';
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
detail?: Record<string, unknown>;
|
||||
};
|
||||
```
|
||||
|
||||
参数写入立即增加编辑态 revision;当前 preview/slice 保持旧 revision,并显示“需要重新拉起”。
|
||||
revision 不一致统一表示编辑工作树已经晚于当前 Session 绑定版本;Session 和切片标记 `stale`,但不热更新、不改写旧版本,也不把 stale 当失败。参数写入立即增加编辑态 revision;当前 preview/slice 保持旧 revision,并显示“需要重新拉起”。P1 尚不实现切片、参数和 Runtime message bridge。
|
||||
|
||||
### 5.6 Agent 泥点归因(P2)
|
||||
|
||||
@@ -376,23 +424,19 @@ type ProjectAgentMudPointAttribution = {
|
||||
|
||||
## 6. 分阶段范围
|
||||
|
||||
### P0:当前实施切片
|
||||
### P0:合同冻结
|
||||
|
||||
- 复用现有四区工作台壳。
|
||||
- 资源/运行切换与客户端内 loopback 预览。
|
||||
- 固定四类资源投影、只读资源画布与中央主视窗资源聚焦;资源聚焦工具栏 / 工具侧边栏及后续媒体能力暂缓。
|
||||
- Supervisor 正式会话、上传、Runtime 确认与安全错误。
|
||||
- 当前 run 专业状态与项目历史成果分离。
|
||||
- 默认三专业组,并可展开另外三组。
|
||||
- 严格审批有效;风险/无需审批可点击查看未开放原因。
|
||||
- 橙色低保真视觉与 `1280×800` 横屏边界。
|
||||
- 冻结 `RunnableGameVersion`、`GameTestSlice`、`GameRunSession`、`GameTunableParameterDefinition`、`GameResourceDescriptor`、`GameHostMessage`、`GameRuntimeMessage`。
|
||||
- 冻结 revision 不一致与 stale 语义;切片和参数属于正式 P2,技术方案不得再称为本地 UI 草稿。
|
||||
- 明确 `versions` 不是运行授权,`runnableVersions` 才是唯一权威来源。
|
||||
|
||||
### P1
|
||||
|
||||
- 已实施依赖/类型两套坐标持久化、首次默认不重叠布局、历史坐标跨重启恢复与自动协调 CAS 冲突处理;资源卡手动拖动暂缓。
|
||||
- 资源关系线在布局持久化验收通过后单独实施,不与本切片捆绑伪造完成。
|
||||
- 已实施正式版本只读模型、版本卡、父子关系与引用资源高亮;资源兼容性判断和不可变下一迭代版本创建仍待后续切片。
|
||||
- 美术/音频编辑状态接线。
|
||||
- Runtime 在首轮完整验证通过后自动登记首个不可变可运行版本。
|
||||
- Agent 后续修订在新 revision 完整验证通过后登记 `agent-revision` 子版本。
|
||||
- 工作台运行入口、当前版本选择、旧 preview 停止、iframe 卸载和目标快照启动全部消费正式可运行版本。
|
||||
- 当前版本绑定资源在 dependency / type 两种资源管理布局中高亮。
|
||||
- 无版本、损坏、revision 不一致和 preview 启动失败提供独立错误状态。
|
||||
|
||||
### P2
|
||||
|
||||
@@ -436,14 +480,14 @@ type ProjectAgentMudPointAttribution = {
|
||||
7. 4096 资源链式 fixture 继续验证拓扑、聚合复杂度和自动布局性能;拖动局部更新与真实 Chromium 拖动帧预算暂缓,不作为当前验收条件。最右侧自环与箭头仍需完整显示。
|
||||
8. Rust 图读取延迟时,dependency sidecar 在图进入 `ready / failed` 前没有读取或写入;首次布局直接使用 Rust 返回的最终 producer 与 dependency depth。重新打开旧布局时手动位置逐项不变,自动位置按最终拓扑协调且相同结果不增加 revision。
|
||||
|
||||
### 7.4 P1 正式项目版本阶段六验收
|
||||
### 7.4 P1 可运行版本验收
|
||||
|
||||
1. manifest 缺少 `versions` 时旧项目正常打开且不显示伪造版本;存在合法记录时,固定“项目版本”分区按追加顺序显示稳定版本卡。
|
||||
2. 根版本、父版本和直接子版本关系在卡片或聚焦态可见;悬空父版本、自引用、重复 ID、非递增修订、倒退时间、重复 slot 和超限数字均失败关闭。
|
||||
3. 点击版本卡后,当前 manifest 中仍存在的绑定资产卡被高亮;历史已删除资产只在版本详情保留 ID,不创建幽灵卡,也不把 External Editor resource ID 猜成 manifest asset ID。
|
||||
4. 版本聚焦态只读展示身份、修订、创建原因、父子关系、创建时间和 slot 绑定,不提供编辑、替换、切换、回滚或运行按钮。
|
||||
5. 任意现有 manifest 写入只能保留磁盘版本前缀并追加新记录;修改、删除或重排已有版本时写入失败,原 manifest 字节不被覆盖。
|
||||
6. 版本选择和高亮不写 manifest、布局 sidecar 或 project revision;dependency / type 两种布局都可显示绑定高亮,既有依赖关系 SVG 语义不变。
|
||||
1. 任务完成或 `code-prototype=completed` 不能直接放行运行;只有同 revision 完整性、static smoke、preview.validate 和 playtest 全部通过后,Rust 才自动登记版本。
|
||||
2. 首版登记为 `initial`,后续新 revision 登记为 `agent-revision`;同一 revision 重放幂等,记录只允许追加且旧记录不可修改、删除或重排。
|
||||
3. 每个版本持有独立 `game/assets` 快照与摘要。当前工作树后续变化不改变旧版本;摘要、描述或 revision 被篡改时启动失败且不回退当前工作树。
|
||||
4. manifest 没有 `runnableVersions` 时点击运行显示“当前无可运行版本”;合法版本存在时运行入口启动 `currentRunnableVersionId`,不读取 `code-prototype` 状态决定可用性。
|
||||
5. 切换版本先停止旧 preview 并卸载 iframe,再启动目标 loopback 快照;失败时不继续显示旧 iframe,并给出损坏、revision 不一致或启动失败的明确原因。
|
||||
6. 当前版本卡与仍存在的绑定资产在 dependency / type 两种布局中高亮;历史已删除绑定只留在版本详情,不创建幽灵卡。
|
||||
|
||||
### 7.5 阶段七完整验收
|
||||
|
||||
@@ -455,7 +499,7 @@ type ProjectAgentMudPointAttribution = {
|
||||
|
||||
## 8. 非目标
|
||||
|
||||
- 当前收口不实现资源卡手动拖动,也不实现资源聚焦工具栏、资源聚焦工具侧边栏、美术编辑、音频编辑 / 替换、资源重新生成、资源替换、下一迭代版本创建入口、运行版本切换、版本回滚、运行模块扩展、测试切片、运行态消费版本、数值参数或泥点归因。正式版本记录已经成为 manifest 业务真相,但当前只读取、校验和展示已有记录。
|
||||
- 当前收口不实现资源卡手动拖动,也不实现资源聚焦工具栏、资源聚焦工具侧边栏、美术编辑、音频编辑 / 替换、资源重新生成、资源替换、手动创建版本或版本回滚。P1 实现运行版本登记、选择、切换和运行态消费;测试切片、数值参数、Host/Runtime 消息桥与泥点归因仍属于 P2。
|
||||
- 本切片不持久化资源聚焦状态、画布缩放 / 平移、搜索条件、筛选条件或当前 mode;聚焦退出时的列表上下文恢复只限当前前端会话,这些状态如需跨重启保存必须另行扩展合同,不能塞入 `game-creator-resource-layout.v1`。
|
||||
- 不修改 SpacetimeDB schema。
|
||||
- 不开放普通用户 Agent.md/Skill。
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# 决策记录
|
||||
|
||||
## 2026-08-04 工作台 P0/P1 以不可变快照建立唯一可运行版本事实源
|
||||
|
||||
- 背景:2026-08-03 资源管理阶段新增的 `manifest.versions` 只用于只读项目迭代卡,当时明确不承担运行版本切换;本轮飞书需求正式进入运行工作台 P0/P1,不能再以 `code-prototype=completed`、普通 preview、checkpoint 或前端状态推断游戏已经可运行。
|
||||
- 决策:保留 `manifest.versions` 作为通用迭代历史,新增由可信 Rust / Runtime 独占追加的 `runnableVersions` 与唯一可变选择指针 `currentRunnableVersionId`。每条记录必须绑定 project/revision、父版本、三项通过凭证、固定 entry、资源槽位和不可变 SHA-256;首版为 `initial`,后续为 `agent-revision`,已有记录在 manifest 存储边界禁止修改、删除或重排。
|
||||
- 产物边界:Runtime 只有在当前 revision 的 `preview-playtest` 传递前置任务闭包、`game.static_smoke`、`preview.validate` 与真实试玩证据全部通过后才自动登记;试玩后的发布节点不阻断登记。`game/` 与可选 `assets/` 被有界复制到 `.agent/runnable-versions/<versionId>/artifact`,版本描述与文件摘要在每次启动前复核。旧版本始终运行该快照,不运行当前工作树;快照已安装但 manifest 写入中断时,重试复用原描述时间与摘要,身份或内容冲突则失败关闭。
|
||||
- 工作台消费:运行入口只读取 `runnableVersions/currentRunnableVersionId`。切换时先停止旧 preview 并卸载 iframe,复核并启动目标快照,成功后才更新选择指针和 loopback preview;无版本、项目身份不符、快照损坏、revision 不一致和启动失败必须原样展示明确错误。资源管理只投影正式可运行版本,并持续高亮当前版本仍存在的绑定资产。
|
||||
- P0/P2 边界:同时冻结测试切片、运行会话、数值参数、资源描述及 Host/Runtime 消息的 TypeScript/Rust 合同;数值参数的 `codeMutationAllowed` 固定为 `false`,消息类型固定为 `host.* / runtime.*`。本轮不实现测试切片、数值微调、消息桥、泥点归因或资源替换,这些仍属于 P2。
|
||||
- 关联文档:`docs/prd/【AI游戏创作】项目开发工作台PRD-2026-07-20.md`、`docs/technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md`。
|
||||
|
||||
## 2026-08-03 资源管理阶段七以完整 CI 与可重复界面合同收口
|
||||
|
||||
- 背景:飞书资源管理需求的阶段零至阶段六已经分别完成资源卡禁拖、固定资源投影、中央聚焦、安全文档 / 媒体预览、依赖深度与正式版本只读模型;最后需要统一复核需求边界并用当前主分支完整门禁排除集成回归。
|
||||
|
||||
@@ -361,10 +361,10 @@ game-project/
|
||||
2026-07-20 起,产品状态机、P0/P1/P2 范围与后续数据合同以 [`【AI游戏创作】项目开发工作台PRD-2026-07-20.md`](../prd/【AI游戏创作】项目开发工作台PRD-2026-07-20.md) 为准;本节只保留当前实现边界。
|
||||
|
||||
- 页面骨架固定为左侧现有全局导航、中间主视窗、右侧陶泥儿对话和底部子 Agent 状态栏;不新建第二套客户端或平行项目页。
|
||||
- 中间主视窗提供 `资源管理 / 运行` 切换。`code-prototype` 任务完成前运行入口保持视觉不可用,但仍可点击查看“当前无可运行版本”,不能使用会阻断说明交互的原生 `disabled` 或 `aria-disabled`;完成后才允许进入运行表现层。切回资源管理只修改前端展示态,不伪造后端预览暂停结果。
|
||||
- 中间主视窗提供 `资源管理 / 运行` 切换。2026-08-04 起运行入口不再读取 `code-prototype` 任务状态,只读取 manifest 的正式 `runnableVersions + currentRunnableVersionId`;无版本时保持视觉不可用但仍可点击查看“当前无可运行版本”,不能使用会阻断说明交互的原生 `disabled` 或 `aria-disabled`。切回资源管理只修改前端展示态,不伪造后端预览暂停结果。
|
||||
- 资源管理从当前 `GameCreationAppManifest`(包含可选 `versions`)、合法 Agent 文本回执和已导入附件派生资源,固定按文档、项目版本、美术资源、音乐音效资源分区;未知任务产物不再兜底为版本,任务声明中的未登记音频也不冒充正式音频。`按依赖 / 按类型` 使用各自前端排列,dependency 模式额外绘制当前 manifest 与资源投影可证明的依赖关系。排列与图层都不写回 manifest,不能推断或伪造缺失依赖。
|
||||
- 资源卡支持点击聚焦、搜索和类型筛选。2026-07-28 起完成两套二维坐标与本地 CAS sidecar;2026-07-31 起 dependency 模式增加不持久化的原生 SVG 关系图层。2026-08-03 mentor 决定暂缓资源卡拖动,当前卡片不挂载 Pointer Down / Move / Up / Cancel 拖动入口,只允许自动布局和点击聚焦。聚焦态替换中央主视窗内容,保留左侧导航、右侧对话和底部 Agent 状态栏,退出后恢复搜索、布局模式、滚动位置与选中资源;不提供工具栏、工具侧边栏或可拖动标题栏。阶段四已补齐安全本地文档、扩展美术媒体与音频聚焦,正文独立滚动,视频 / 音频使用内置媒体控件,失败显示空态;美术编辑、音频编辑 / 替换、版本替换或运行模块仍不在本阶段。
|
||||
- 运行表现层首版直接嵌入当前项目的 loopback 游戏画面,并展示上一项 / 暂停继续 / 下一项切片控制、素材信息和数值微调面板。`preview.start` 启动本地 server 后把真实 URL 回写工作台,`preview.open` 只激活客户端内运行视图,不再调用系统浏览器;切片、参数调整和自然语言新增调节项首版仍只保留本地 UI 草稿,不修改代码或 manifest。
|
||||
- 运行表现层嵌入当前项目的 loopback 游戏画面。P1 由专用可运行版本命令停止旧 preview、卸载 iframe、复核版本快照并启动目标版本;普通 `preview.start` 继续服务 Agent 当前工作树验证,不能作为工作台运行授权或旧版本切换入口。测试切片、参数调整和 Host/Runtime message bridge 已冻结为正式 P2 合同,不再称为本地 UI 草稿,本轮不接线。
|
||||
- 右侧继续复用现有 Project Supervisor 会话、Runtime 澄清和确认链路;输入区展示 `严格审批 / 风险审批 / 无需审批` 独立面板。P0 只有严格审批可选;风险审批和无需审批保持视觉不可用但允许点击查看原因,不替代 Runtime 的逐动作权限、确认、sandbox 或 reconciliation 门禁。风险 Rank 算法记录在 `docs/project-memory/todos/【待解决】AI游戏创作高风险审批Rank-2026-07-20.md`,前端不得自行计算。
|
||||
- 底部状态栏默认展示策划、美术、程序 3 组,并允许在同一栏展开数值、音频、发布组;状态来自 manifest 与当前 Supervisor run 的 Runtime,悬停显示当前任务与进度。累计泥点必须等待后端计费归因投影;Agent.md 编辑和自定义 Skill 在来源审核、版本、权限、sandbox 与回滚合同完备前不向普通用户开放。
|
||||
- 当前 run 专业状态与项目历史成果分离:状态继续严格匹配当前 `parentRunId`;已有文本成果从专业 Agent 持久对话中合法的 `agent-finalization-<32 lower hex>` assistant 恢复,并以“历史成果”来源投影到资源管理文档区。新 run 失败、待确认、候选为空或持久对话瞬时读取失败不得清除已恢复的旧成功回执,普通失败 assistant 也不得被当作成果。
|
||||
@@ -414,7 +414,15 @@ game-project/
|
||||
|
||||
2026-08-03 阶段六:正式迭代版本直接扩展本地 `.agent/manifest.json`,不新增 checkpoint / layout sidecar / SpacetimeDB 平行业务真相。共享 Rust / TypeScript 合同新增可选 `versions: GameIterationVersion[]`;旧项目缺失字段时只读为空,不回填。Rust 在 manifest 读写边界校验版本唯一性、父先于子、根/原因一致、父子修订与时间单调、slot 唯一和 JavaScript 安全整数,并在覆盖已有 manifest 前要求磁盘版本数组是新数组的逐项相等前缀,从存储边界保证历史记录不可修改、删除或重排。
|
||||
|
||||
工作台资源投影只从 `manifest.versions` 构建版本卡,按数组追加顺序生成稳定“版本 N”标题;不再接收前端独立 `projectVersions` 注入。`resourceBindings.resourceId` 只解释为 manifest asset ID,并映射到现有 `asset:<id>` 卡片。选中版本后在 dependency / type 两种布局中高亮当前仍存在的绑定资产;缺失历史资产只留在版本聚焦详情,不能合成幽灵卡或猜测 External Editor resource ID。版本聚焦复用中央只读容器,展示身份、修订、原因、父版本、直接子版本、创建时间与 slot 绑定。本阶段不提供版本创建、替换、切换、回滚、测试切片或运行态消费入口。
|
||||
2026-08-04 起工作台资源投影只从 `manifest.runnableVersions` 构建可运行版本卡,按数组追加顺序生成稳定“版本 N”标题;旧 `manifest.versions` 继续保留上一阶段通用迭代历史,但不提供运行授权。`resourceBindings.resourceId` 只解释为 manifest asset ID,并映射到现有 `asset:<id>` 卡片。当前运行版本在 dependency / type 两种布局中持续高亮仍存在的绑定资产;缺失历史资产只留在版本聚焦详情,不能合成幽灵卡或猜测 External Editor resource ID。版本聚焦复用中央只读容器,展示身份、修订、原因、父版本、直接子版本、创建时间与 slot 绑定。
|
||||
|
||||
### 可运行版本 P0/P1
|
||||
|
||||
- P0 权威合同位于工作台 PRD §5.3-§5.5 与前后端 `shared-contracts`:`RunnableGameVersion`、`GameTestSlice`、`GameRunSession`、`GameTunableParameterDefinition`、`GameResourceDescriptor`、`GameHostMessage`、`GameRuntimeMessage`。revision 不一致只产生 `stale`,不热更新旧 Session,也不原地修改旧版本。
|
||||
- P1 登记点位于自主 Runtime `preview-playtest` 成功终态投影。该点必须已经通过当前 source 中 `preview-playtest` 的传递前置任务闭包、当前 revision `game.static_smoke`、当前 revision `preview.validate`、真实 playtest 回执和证据文件复核;试玩后的发布下游节点不参与登记门禁,其它任务状态、Agent 文本或前端事件均不能登记。
|
||||
- 登记时在项目写锁内复制普通文件 `game/` 与 `assets/` 到 `.agent/runnable-versions/<versionId>/artifact/`,拒绝链接、越界、超限和入口缺失,生成包含 projectId / versionId / revision 的受保护描述与确定性 SHA-256,再向 `.agent/manifest.json` 追加版本。首条为 `initial`,后续为 `agent-revision`;同 revision 重放幂等。版本记录和快照都不可原地修改。
|
||||
- `currentRunnableVersionId` 是唯一可变选择指针。专用 Tauri 命令在项目锁内复核项目身份、版本结构、快照描述、revision 与摘要;切换时先停止当前项目 registry server,再启动目标快照。启动失败不得回退当前工作树或继续展示旧 iframe。
|
||||
- 普通 Agent `preview.start / preview.validate` 仍对当前编辑工作树执行,Runner registry 与 Tauri 用户可见 registry 的既有隔离不变;工作台运行专用命令只能服务已登记快照。
|
||||
|
||||
历史命令式 drag preview 句柄与局部连接索引可以保留,但项目工作台不再向资源卡传入该入口。拖动热路径、4096 张真实卡片拖动重渲染和 Chromium p95 门槛统一暂缓;当前回归只要求 Pointer Move 不改变卡片坐标、SVG path 或布局 revision。`ResizeObserver` 仍保持单图层单实例,任何实时 DOM 几何都不得通过 Tauri IPC 往返 Rust。
|
||||
|
||||
@@ -431,7 +439,7 @@ game-project/
|
||||
- 用户能创建本地 Web 游戏项目。
|
||||
- 用户进入项目开发页后能看到资源管理主视窗、陶泥儿对话栏和底部策划 / 美术 / 程序 Agent 状态栏;`1280×800` 最小横屏窗口和更大桌面窗口均不得出现页面级横向 / 纵向溢出,对话输入与底部 Agent 状态栏始终位于视口内。
|
||||
- 资源管理可在按依赖 / 按类型之间切换、搜索资源并点击打开当前资源详情;dependency 模式展示可验证的资源引用和聚合任务流,搜索过滤端点、选择高亮直接上下游。资源卡不可拖动,Pointer Move 不更新坐标、线段或手动布局;所有展示数据来自当前 manifest、当前资源投影或当前项目导入附件。
|
||||
- 首个 `code-prototype` 任务未完成时运行入口不可进入并给出可感知提示;完成后可进入运行表现层,真实预览直接加载到客户端内受限运行容器。
|
||||
- manifest 没有合法 `runnableVersions + currentRunnableVersionId` 时运行入口不可进入并提示“当前无可运行版本”;只有 Runtime 为通过完整性、静态检查、preview.validate 与真实试玩的当前 revision 登记正式版本后,运行入口才从该版本的不可变快照加载受限 loopback 画面,`code-prototype` 任务状态本身不授权运行。
|
||||
- 审批档位通过独立弹出面板切换,默认严格审批;界面选择不得绕过 Runtime 现有确认门禁。
|
||||
- 聊天输入 `/plan` 可在普通聊天消息里查看下一轮分工计划,不读取任务文件、不启动 run、不修改项目,也不新增普通用户计划面板。
|
||||
- 聊天输入 `/guide` 可在普通聊天消息里查看普通用户操作导引,不读取文件、不启动 run、不启动预览、不写项目,也不新增普通用户导引面板。
|
||||
|
||||
@@ -556,6 +556,106 @@ export interface GameIterationVersion {
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
export const RUNNABLE_GAME_VERSION_SCHEMA_VERSION =
|
||||
'game-creator-runnable-version.v1' as const;
|
||||
|
||||
export type RunnableGameVersionCreatedReason = 'initial' | 'agent-revision';
|
||||
|
||||
export interface RunnableGameVersionValidation {
|
||||
staticSmokePassed: true;
|
||||
previewValidatePassed: true;
|
||||
playtestPassed: true;
|
||||
agentId: string;
|
||||
runId: string;
|
||||
reportPath: string;
|
||||
}
|
||||
|
||||
export interface RunnableGameVersion {
|
||||
schemaVersion: typeof RUNNABLE_GAME_VERSION_SCHEMA_VERSION;
|
||||
versionId: string;
|
||||
projectId: string;
|
||||
parentVersionId: string | null;
|
||||
projectRevision: number;
|
||||
artifactPath: string;
|
||||
artifactSha256: string;
|
||||
entryPath: 'game/index.html';
|
||||
resourceBindings: GameIterationVersionResourceBinding[];
|
||||
createdReason: RunnableGameVersionCreatedReason;
|
||||
validation: RunnableGameVersionValidation;
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
export type GameTestSliceStatus =
|
||||
| 'idle'
|
||||
| 'starting'
|
||||
| 'playing'
|
||||
| 'paused'
|
||||
| 'completed'
|
||||
| 'failed';
|
||||
|
||||
export interface GameTestSlice {
|
||||
sliceId: string;
|
||||
versionId: string;
|
||||
title: string;
|
||||
order: number;
|
||||
startCondition: string;
|
||||
endCondition: string;
|
||||
status: GameTestSliceStatus;
|
||||
}
|
||||
|
||||
export interface GameRunSession {
|
||||
sessionId: string;
|
||||
projectId: string;
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
status: 'starting' | 'playing' | 'paused' | 'stopped' | 'failed';
|
||||
stale: boolean;
|
||||
staleReason: 'project-revision-changed' | 'version-changed' | null;
|
||||
startedAt: number;
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export interface GameTunableParameterDefinition {
|
||||
parameterId: string;
|
||||
label: string;
|
||||
valueType: 'integer' | 'number' | 'boolean' | 'enum';
|
||||
min?: number;
|
||||
max?: number;
|
||||
step?: number;
|
||||
enumValues?: string[];
|
||||
writePath: string;
|
||||
codeMutationAllowed: false;
|
||||
}
|
||||
|
||||
export interface GameResourceDescriptor {
|
||||
resourceId: string;
|
||||
category: 'document' | 'version' | 'art' | 'audio';
|
||||
subtype: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
durationMs?: number;
|
||||
format: string;
|
||||
}
|
||||
|
||||
export interface GameHostMessage {
|
||||
schemaVersion: 'game-creator-host-message.v1';
|
||||
sessionId: string;
|
||||
sequence: number;
|
||||
type: 'host.start' | 'host.pause' | 'host.resume' | 'host.stop';
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
}
|
||||
|
||||
export interface GameRuntimeMessage {
|
||||
schemaVersion: 'game-creator-runtime-message.v1';
|
||||
sessionId: string;
|
||||
sequence: number;
|
||||
type: 'runtime.ready' | 'runtime.state' | 'runtime.completed' | 'runtime.failed';
|
||||
versionId: string;
|
||||
projectRevision: number;
|
||||
detail?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface GameCreationAppManifest {
|
||||
schemaVersion: string;
|
||||
projectId: string;
|
||||
@@ -566,6 +666,8 @@ export interface GameCreationAppManifest {
|
||||
preview?: GameCreationAppPreviewState | null;
|
||||
commandRuns?: GameCreationAppCommandRunState[];
|
||||
versions?: GameIterationVersion[];
|
||||
runnableVersions?: RunnableGameVersion[];
|
||||
currentRunnableVersionId?: string | null;
|
||||
}
|
||||
|
||||
export interface GameCreationAgentToolCallTrace {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user