Files
Genarrative/apps/ai-game-creator-shell/src-tauri/src/project.rs
T
suzmii c5564e59ed feat(游戏共创): 客户端落地「从平台作品开始创作」取件链路(本地来源记录 + 新命令)
- 新增 `project/fork_source.rs`:项目改编来源记录落在 `.agent/fork-source.json`
  (`{schemaVersion,gameId,versionId,adoptedAtMillis}`,版本 `agc-fork-source.v1`)。
  位置理由:`.agent/**` 随项目快照上云、随用户整目录拷贝,且导出包不带 `.agent`,
  既随行又不干扰游戏产物;不改 `manifest.json`(它是 deny_unknown_fields + 只接受 v1)。
  写入走统一入口 `write_game_creator_private_file`;读取容忍缺失/损坏/异形/非普通文件,
  一律返回 None 而不报错、不 panic。
- 新增 `game_fork.rs` + `game_fork/desktop.rs` 与命令
  `create_local_project_from_platform_game`(在 `desktop.rs` 的 generate_handler 注册):
  取平台会话 → 取件元数据 → 带 Bearer 下载整包 → 校验字节数与 SHA-256(失败关闭、不落盘)
  → `init_local_game_project_at` 生成合规 Phaser4+Vite 脚手架 → 参考副本解压到
  `<project>/reference/<gameId>/`(复用 `safe_archive_relative_path` 与
  `extract_template_archive` 的条目数/单文件/符号链接门禁,按最小改动把后者提到 pub(crate))
  → 写来源记录;任一步失败都删掉半成品项目目录。
  参考副本必须落在子目录:`create_npm_scaffold` 的判据是「没有 manifest 且根/`game` 都没有
  index.html、package.json」,成品包若落在项目根或 `game/` 根,脚手架一个文件都不会生成。
- `game_distribution_publish.rs` 新增受鉴权取件实现:`fetch_platform_game_fork_source`
  (元数据 GET + 带 Bearer 的整包下载 + 404/409/403/401 四态可区分映射 + 下载路径同源校验)。
  不复用模板库的 `fetch_limited_bytes`:它写死 `client.get(url)`,带不了鉴权头,
  复用它会让受保护内容变成匿名下载。
- 埋点:新增 `CreationSource::PlatformGame`(`analytics/contract.rs` 的 values! 登记)并在建项
  成功后上报,来源标识沿用模板链路的 ID 槽位。
- 修既有编译错误:`game_distribution_publish.rs` 的资料摘要测试缺 `fork` 字段
  (上一提交给 `GameDistributionCreateGameRequest` 加了该字段但没同步该测试字面量),
  补 `fork: None` 以恢复测试目标可编译。
2026-10-05 17:30:46 +08:00

47 lines
1.1 KiB
Rust

use super::*;
use sha2::{Digest, Sha256};
use similar::TextDiff;
use std::io::{Seek, SeekFrom};
mod agent_db;
mod asset_export;
mod asset_rename;
mod bootstrap;
mod checkpoint;
mod conversation;
mod export;
mod external_editor_bindings;
mod filesystem;
mod fork_source;
mod manifest;
mod memory;
mod model_usage;
mod resource_dependency_graph;
mod resource_editor;
mod resource_layout;
mod verification;
mod version_resource_replacement;
mod write_lock;
pub(crate) use agent_db::*;
#[cfg(not(test))]
pub(crate) use asset_export::*;
pub(crate) use asset_rename::*;
pub(crate) use bootstrap::*;
pub(crate) use checkpoint::*;
pub(crate) use conversation::*;
pub(crate) use export::*;
pub(crate) use external_editor_bindings::*;
pub(crate) use filesystem::*;
pub(crate) use fork_source::*;
pub(crate) use manifest::*;
pub(crate) use memory::*;
pub(crate) use model_usage::*;
#[cfg(not(test))]
pub(crate) use resource_dependency_graph::*;
pub(crate) use resource_editor::*;
pub(crate) use resource_layout::*;
pub(crate) use verification::*;
pub(crate) use version_resource_replacement::*;
pub(crate) use write_lock::*;