删除无调用方的 pick_local_file 与 delete_local_* 三条 Tauri 命令
- commands.rs 删除 pick_local_file、delete_local_project_file、delete_local_game_memory 三条命令实现 - main.rs 取消上述三条命令的注册 - Rust 用例只保留写命令推进 revision 的断言(删除两条已退役命令的断言并同步改名) - check-config.mjs 移除这三条命令的白名单条目与旧说明 - check-config.mjs 把旧命令聊天剩下的 15 条无前端调用方命令登记为 native-only,并删掉随该死链失效的 guardrail 片段
This commit is contained in:
@@ -119,17 +119,10 @@ const allowedUncalledTauriCommands = [
|
||||
'chat_with_game_creator_role_agent_stream',
|
||||
'check_game_creator_llm_config',
|
||||
'confirm_game_creator_agent_runtime_task',
|
||||
// 下面两条命令前端、native Runtime 与 CLI swarm 都没有调用方,只有 Rust 测试直接
|
||||
// 调用命令函数本身;保留注册是为了不动本地记忆 / 本地文件这两块 native 能力。
|
||||
'delete_local_game_memory',
|
||||
'delete_local_project_file',
|
||||
'diff_local_project_checkpoint',
|
||||
'get_game_creation_agent_capabilities',
|
||||
'get_limited_local_commands',
|
||||
'list_local_project_export_packages',
|
||||
// 前端画板导出包入口已不再调用它,Rust 侧也只剩命令注册;若确认这条能力退役,
|
||||
// 需要连同 main.rs 注册、commands.rs 实现和前端调用方用例一起删除。
|
||||
'pick_local_file',
|
||||
'read_game_creator_agent_runtime',
|
||||
'read_local_agent_memory',
|
||||
'read_local_game_memory',
|
||||
@@ -187,6 +180,26 @@ const allowedUncalledTauriCommands = [
|
||||
'read_agc_plugin_panel',
|
||||
'set_agc_plugin_project_path',
|
||||
'set_agc_plugin_enabled',
|
||||
// 下面这些命令的调用方只有随 Project Supervisor 前端链路一起删除的旧命令聊天入口;
|
||||
// 现在 App 前端、工作台与策划聊天都没有接线(检查点 / 恢复 / 索引 / 导出包 / 预览 /
|
||||
// 画板同步 / 素材登记 / 权限策略 / 本地草案 / 平台美术),Rust 侧只剩注册与实现,
|
||||
// `*_at` helper 仍由 Rust 用例覆盖。接回新入口还是删除属于 native 能力取舍,先按
|
||||
// native-only 登记,避免孤儿检查一直报错。
|
||||
'activate_local_game_preview',
|
||||
'build_local_project_index',
|
||||
'control_agent_run',
|
||||
'create_local_project_checkpoint',
|
||||
'export_local_project_package',
|
||||
'generate_local_game_draft',
|
||||
'generate_platform_art_asset',
|
||||
'import_canvas_asset',
|
||||
'import_canvas_export',
|
||||
'open_canvas_project',
|
||||
'register_local_asset',
|
||||
'restore_local_project_checkpoint',
|
||||
'run_limited_local_command',
|
||||
'sync_canvas_project_assets',
|
||||
'write_project_permission_policy',
|
||||
];
|
||||
const sourceExtensions = new Set([
|
||||
'.json',
|
||||
@@ -1869,12 +1882,8 @@ for (const snippet of [
|
||||
'官方账号服务(固定)',
|
||||
'runtime_config.save',
|
||||
"'/run:运行自检,启动本地 HTTP 预览并载入客户端运行视图'",
|
||||
"'activate_local_game_preview'",
|
||||
'已切换到客户端运行视图',
|
||||
'async function executeRunLocal',
|
||||
'function needsInitializedChatProject',
|
||||
'function resolvePendingCommandProjectPath',
|
||||
'resolveChatProjectPath(localProject) ?? draftProjectPath',
|
||||
"'/remember [short|long|blackboard] 内容:追加短期、长期或黑板记忆'",
|
||||
"'/memory-set [short|long|blackboard] 内容:覆盖保存对应记忆'",
|
||||
'function parseRememberInput',
|
||||
@@ -1883,7 +1892,6 @@ for (const snippet of [
|
||||
"'permission.confirm'",
|
||||
"'permission.cancel'",
|
||||
"'command.auto'",
|
||||
"'agent.run_status'",
|
||||
'function summarizeAgentRunTrace',
|
||||
]) {
|
||||
if (!appSource.includes(snippet)) {
|
||||
|
||||
@@ -814,37 +814,6 @@ pub(crate) async fn pick_local_project_directory(
|
||||
Ok(Some(path.to_string_lossy().into_owned()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) async fn pick_local_file(app: tauri::AppHandle) -> Result<Option<String>, String> {
|
||||
let (sender, receiver) = tokio::sync::oneshot::channel();
|
||||
let mut dialog = app.dialog().file().set_title("选择本地文件");
|
||||
if let Some(window) = app.get_webview_window("client") {
|
||||
dialog = dialog.set_parent(&window);
|
||||
}
|
||||
dialog.pick_file(move |path| {
|
||||
let _ = sender.send(path);
|
||||
});
|
||||
let Some(path) = receiver
|
||||
.await
|
||||
.map_err(|_| "本地文件选择器意外关闭".to_string())?
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
let path = path
|
||||
.into_path()
|
||||
.map_err(|error| format!("读取本地文件失败:{error}"))?;
|
||||
#[cfg(windows)]
|
||||
crate::register_game_creator_user_selected_path(&path, false);
|
||||
if let Err(error) =
|
||||
crate::prepare_game_creator_user_selected_path_for_read(&path, false, "用户选择文件")
|
||||
{
|
||||
#[cfg(windows)]
|
||||
crate::revoke_game_creator_user_selected_path(&path);
|
||||
return Err(error);
|
||||
}
|
||||
Ok(Some(path.to_string_lossy().into_owned()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn open_local_project_directory(
|
||||
app: tauri::AppHandle,
|
||||
@@ -5474,18 +5443,6 @@ pub(crate) fn write_local_project_file(
|
||||
write_local_project_file_at(root, relative_path.trim(), &content)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn delete_local_project_file(
|
||||
project_path: String,
|
||||
relative_path: String,
|
||||
) -> Result<LocalProjectFileMutationResult, String> {
|
||||
let root = Path::new(project_path.trim());
|
||||
enforce_project_permission_policy(root, "file.delete")?;
|
||||
let _lock = acquire_project_write_lock(root, "file.delete")?;
|
||||
advance_agent_runtime_project_revision_locked(root)?;
|
||||
delete_local_project_file_at(root, relative_path.trim())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn read_local_game_memory(
|
||||
project_path: String,
|
||||
@@ -5534,18 +5491,6 @@ pub(crate) fn write_local_game_memory(
|
||||
write_local_game_memory_at(root, scope.trim(), &content)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn delete_local_game_memory(
|
||||
project_path: String,
|
||||
scope: String,
|
||||
) -> Result<LocalGameMemoryResult, String> {
|
||||
let root = Path::new(project_path.trim());
|
||||
enforce_project_permission_policy(root, "memory.delete")?;
|
||||
let _lock = acquire_project_write_lock(root, "memory.delete")?;
|
||||
advance_agent_runtime_project_revision_locked(root)?;
|
||||
delete_local_game_memory_at(root, scope.trim())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn list_game_creator_agent_sessions(
|
||||
project_path: String,
|
||||
|
||||
@@ -2514,7 +2514,6 @@ fn main() {
|
||||
rename_local_game_project,
|
||||
suggest_automatic_project_name,
|
||||
polish_local_project_prompt,
|
||||
pick_local_file,
|
||||
pick_client_extension_file,
|
||||
pick_client_extension_directory,
|
||||
list_client_extensions,
|
||||
@@ -2635,12 +2634,10 @@ fn main() {
|
||||
read_local_project_media_preview,
|
||||
cancel_local_project_resource_preview_scope,
|
||||
write_local_project_file,
|
||||
delete_local_project_file,
|
||||
read_local_game_memory,
|
||||
read_local_agent_memory,
|
||||
write_local_agent_memory,
|
||||
write_local_game_memory,
|
||||
delete_local_game_memory,
|
||||
list_game_creator_agent_sessions,
|
||||
create_game_creator_agent_session,
|
||||
fork_game_creator_agent_session,
|
||||
|
||||
@@ -2777,7 +2777,7 @@ fn agent_run_history_prunes_to_latest_hundred_traces() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn developer_project_file_and_memory_mutations_advance_project_revision() {
|
||||
fn developer_project_file_and_memory_writes_advance_project_revision() {
|
||||
let root = unique_project_path();
|
||||
init_local_game_project_at(&root, "project-1", "开发面板 revision").expect("project init");
|
||||
let project_path = root.to_string_lossy().into_owned();
|
||||
@@ -2800,16 +2800,11 @@ fn developer_project_file_and_memory_mutations_advance_project_revision() {
|
||||
"项目记忆".to_string(),
|
||||
)
|
||||
.expect("write project memory through command");
|
||||
delete_local_game_memory(project_path.clone(), "long".to_string())
|
||||
.expect("delete project memory through command");
|
||||
delete_local_project_file(project_path, "game/revision.txt".to_string())
|
||||
.expect("delete project file through command");
|
||||
|
||||
assert_eq!(
|
||||
read_game_creator_agent_runtime_project_revision(&root)
|
||||
.expect("read developer mutation revision")
|
||||
.revision,
|
||||
5
|
||||
3
|
||||
);
|
||||
fs::remove_dir_all(root).ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user