DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(rust): 按平台门控 Windows 专用代码,消除三平台 Rust 编译警告
hairyf7b3c498ba0ab
diff --git a/src-tauri/src/config/constants.rs b/src-tauri/src/config/constants.rsindex c406d91b..9050f8fe 100644--- a/src-tauri/src/config/constants.rs+++ b/src-tauri/src/config/constants.rs@@ -26,14 +26,18 @@ pub const PNPM_SHA256: &str = "deafa7ec98a1218b6a047289b92fbe2395c1e22d3495bb711pub const PNPM_BASE_URL: &str = "https://registry.npmjs.org/pnpm/-/";/// Windows 空白环境使用的免安装 MinGit 版本。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 MinGit 任务与单测使用pub const MINGIT_VERSION: &str = "2.53.0.2";/// MinGit x64 官方发行包 SHA-256。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 MinGit 任务与单测使用pub const MINGIT_X64_SHA256: &str ="d4bf83d6a860ccae9af44e508e1e00a39f09db6fa78a9ba5543b94d87ca22a29";/// MinGit ARM64 官方发行包 SHA-256。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 MinGit 任务与单测使用pub const MINGIT_ARM64_SHA256: &str ="842d50edc6bbcf39693e60a8ebb9dabb89b96b932b63aae12d218522b3e497f3";/// Git for Windows 官方发行资产地址前缀。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 MinGit 任务与单测使用pub const MINGIT_BASE_URL: &str ="https://github.com/git-for-windows/git/releases/download/v2.53.0.windows.2/";@@ -70,10 +74,13 @@ pub const PNPM_CORE_DIR: &str = "pnpm";pub const PNPM_ENTRY_RELATIVE: &str = "bin/pnpm.cjs";/// 开发构建的用户级 shim 根目录名,不与 release 的 CLI 集成目录冲突。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 bin 目录计算使用pub const CLI_ROOT_DEV_DIR_NAME: &str = "deepseek-harness-dev";/// Windows 免安装 Git 的安装目录与 CLI 入口(相对安装目录)。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 MinGit 安装路径使用pub const MINGIT_CORE_DIR: &str = "git";+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 MinGit 安装路径使用pub const MINGIT_ENTRY_RELATIVE: &str = "cmd/git.exe";/// 旧版数据目录名:迁移前 $DSH_HOME 位于 `{app_data}/data/dsh`,diff --git a/src-tauri/src/config/runtime.rs b/src-tauri/src/config/runtime.rsindex 2da3a035..4fffa569 100644--- a/src-tauri/src/config/runtime.rs+++ b/src-tauri/src/config/runtime.rs@@ -316,6 +316,7 @@ pub fn get_pnpm_download_url() -> String {}/// Windows 免安装 Git 的安装目录。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 Git 运行时探测使用pub fn get_mingit_install_path<R: Runtime>(app_handle: &AppHandle<R>) -> PathBuf {get_base_dir(app_handle).join("dependencies")@@ -323,11 +324,13 @@ pub fn get_mingit_install_path<R: Runtime>(app_handle: &AppHandle<R>) -> PathBuf}/// Windows 免安装 Git 的 CLI 入口。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 Git 运行时探测使用pub fn get_mingit_binary_path<R: Runtime>(app_handle: &AppHandle<R>) -> PathBuf {get_mingit_install_path(app_handle).join(MINGIT_ENTRY_RELATIVE)}/// Windows MinGit 官方发行包文件名。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 MinGit 任务与单测使用fn mingit_pkg_filename(arch: &str) -> Result<String, String> {match arch {"x86_64" => Ok(format!("MinGit-{MINGIT_VERSION}-64-bit.zip")),@@ -337,6 +340,7 @@ fn mingit_pkg_filename(arch: &str) -> Result<String, String> {}/// Windows MinGit 官方发行包下载地址。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 MinGit 任务使用pub fn get_mingit_download_url() -> Result<String, String> {Ok(format!("{MINGIT_BASE_URL}{}",@@ -345,6 +349,7 @@ pub fn get_mingit_download_url() -> Result<String, String> {}/// Windows MinGit 官方发行包固定 SHA-256。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 MinGit 任务使用pub fn get_mingit_sha256() -> Result<&'static str, String> {match env::consts::ARCH {"x86_64" => Ok(MINGIT_X64_SHA256),diff --git a/src-tauri/src/service/cli/path/mod.rs b/src-tauri/src/service/cli/path/mod.rsindex db6210a3..5159e75a 100644--- a/src-tauri/src/service/cli/path/mod.rs+++ b/src-tauri/src/service/cli/path/mod.rs@@ -16,6 +16,7 @@ use tauri::{AppHandle, Manager};use super::shim::SHIM_CMD_NAME;#[cfg(unix)]use super::shim::SHIM_SH_NAME;+#[cfg(windows)]use crate::config::CLI_ROOT_DEV_DIR_NAME;#[cfg(not(windows))]@@ -36,6 +37,7 @@ pub(crate) use pnpm::find_user_pnpm_executable;pub use pnpm::{find_user_pnpm, pnpm_env_value};/// Windows 下 shim 根目录名(`%LOCALAPPDATA%\<此目录>\bin`)+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 bin 目录计算使用const CLI_ROOT_DIR_NAME: &str = "deepseek-harness";/// Unix 下 shim 所在目录(XDG 约定)diff --git a/src-tauri/src/service/cli/shim/build.rs b/src-tauri/src/service/cli/shim/build.rsindex d1af8f1a..c32df6ac 100644--- a/src-tauri/src/service/cli/shim/build.rs+++ b/src-tauri/src/service/cli/shim/build.rs@@ -149,6 +149,7 @@ exec "$NODE" "$DSH_BIN" "$@"/// 实现要点:/// - 不用 `findstr` 匹配路径(`\` 会被当正则转义导致过滤失效);/// - 块内变量判断用 for 变量(`%%~xp`)而非 `%VAR%`(块解析时机陷阱)。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 shim 落盘与单测使用pub fn build_pnpm_cmd_shim(app_dir: &Path) -> String {let pnpm_bin = app_dir.join("dependencies/pnpm/bin/pnpm.cjs");@@ -229,6 +230,7 @@ exit /b 1/// Windows `pnpm.ps1` 内容:优先转发用户 pnpm(`Get-Command pnpm -All`,/// 排除本 shim 目录),否则用 node 运行捆绑 pnpm.cjs。/// `DSH_PREFER_BUNDLED_PNPM=1` 时捆绑版优先(见模块头注)。+#[cfg_attr(all(not(windows), not(test)), allow(dead_code))] // 仅 Windows 的 shim 落盘与单测使用pub fn build_pnpm_ps1_shim(app_dir: &Path) -> String {let pnpm_bin = app_dir.join("dependencies/pnpm/bin/pnpm.cjs");diff --git a/src-tauri/src/service/cli/shim/mod.rs b/src-tauri/src/service/cli/shim/mod.rsindex e6e60264..53ef3592 100644--- a/src-tauri/src/service/cli/shim/mod.rs+++ b/src-tauri/src/service/cli/shim/mod.rs@@ -16,9 +16,13 @@ mod write;pub use write::{is_generated_shim, user_dsh_preserved, write_shims};/// Windows 下 shim 文件名(cmd 为主入口,ps1 供 PowerShell 原生体验)+#[cfg(windows)]pub const SHIM_CMD_NAME: &str = "dsh.cmd";+#[cfg(windows)]pub const SHIM_PS1_NAME: &str = "dsh.ps1";+#[cfg(windows)]pub const PNPM_SHIM_CMD_NAME: &str = "pnpm.cmd";+#[cfg(windows)]pub const PNPM_SHIM_PS1_NAME: &str = "pnpm.ps1";/// Unix 下 shim 文件名diff --git a/src-tauri/src/service/download/installable.rs b/src-tauri/src/service/download/installable.rsindex f7de048f..d90401e1 100644--- a/src-tauri/src/service/download/installable.rs+++ b/src-tauri/src/service/download/installable.rs@@ -10,6 +10,8 @@ pub enum InstallKind {Node,Dsh,Pnpm,+ /// 仅 Windows 构造:`Git` 安装任务按 `#[cfg(windows)]` 加入任务列表。+ #[cfg_attr(not(windows), allow(dead_code))]Git,}diff --git a/src-tauri/src/service/plugin/install/allowlist.rs b/src-tauri/src/service/plugin/install/allowlist.rsindex 6c3c172c..c71a6724 100644--- a/src-tauri/src/service/plugin/install/allowlist.rs+++ b/src-tauri/src/service/plugin/install/allowlist.rs@@ -218,7 +218,7 @@ fn apply_allow_build_keys(content: &str, keys: &[String]) -> Result<String, Stri// 把 `allowBuilds` 内同名键去重(保留最后写入的值)后再解析,自愈损坏状态。// 「多文档」(`---` 分隔,issue #526)同样让 serde_yaml 与 pnpm 都拒绝——交给// `parse_workspace_document` 归一化成单文档并标记需要回写。- let (mut doc, mut repaired): (Value, bool) = match parse_workspace_document(content) {+ let (mut doc, repaired): (Value, bool) = match parse_workspace_document(content) {Ok((value, normalized)) => (value, normalized),Err(first_err) => {let normalized = collapse_allow_builds_duplicates(content);diff --git a/src-tauri/src/service/profile/mod.rs b/src-tauri/src/service/profile/mod.rsindex dab0cd24..72ae4a27 100644--- a/src-tauri/src/service/profile/mod.rs+++ b/src-tauri/src/service/profile/mod.rs@@ -551,16 +551,14 @@ pub fn remove(app_handle: &AppHandle, id: &str) -> Result<(), String> {/// 克隆档案:全量复制源档案目录,自动递增命名(web → web-1 → web-2)。///+/// 以 `profiles_root` 为根,便于单测注入临时目录;调用方(`bridge::clone_profile`)+/// 自行从 `AppHandle` 解析 `$DSH_HOME/profiles`,并把密集的目录树复制放进+/// `spawn_blocking`,避免阻塞 Tauri 异步运行时。+////// - `source_id` 经 `fs_guard::validate_id` 校验,拒绝路径穿越;/// - `name` 为 `None` 时按 source_id 自动递增;`Some` 时规范化并校验冲突;/// - 复制后清除搬入的 pnpm 元数据(`.modules.yaml`),并重写 manifest name 为/// `dsh-profile-<new-id>`。-pub fn clone(app_handle: &AppHandle, source_id: &str, name: Option<&str>) -> Result<Profile, String> {- let profiles_root = config::get_dsh_data_path(app_handle).join("profiles");- clone_with_root(&profiles_root, source_id, name)-}--/// 克隆实现(以 `profiles_root` 为根,便于单测注入临时目录)。pub fn clone_with_root(profiles_root: &Path, source_id: &str, name: Option<&str>) -> Result<Profile, String> {fs_guard::validate_id(source_id)?;let src_dir = fs_guard::join_safe(profiles_root, source_id)?;diff --git a/src-tauri/src/service/workflow/install.rs b/src-tauri/src/service/workflow/install.rsindex dc493a4a..45e1d4ae 100644--- a/src-tauri/src/service/workflow/install.rs+++ b/src-tauri/src/service/workflow/install.rs@@ -47,6 +47,9 @@ pub async fn install(.get_webview_window("main").ok_or("Failed to get main window")?;log::debug!("Main window obtained");+ // 仅 Windows 会继续 push MinGit 任务(见下方 `#[cfg(windows)]`),+ // 异平台的 `mut` 因此多余,按平台放行。+ #[cfg_attr(not(windows), allow(unused_mut))]let mut tasks: Vec<Box<dyn download::Installable>> = vec![Box::new(download::Nodejs),Box::new(download::Dsh),