DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(plugin): install bundled internal plugins via link: deps
hairyff3d25e938b74
diff --git a/src-tauri/src/service/plugin/install.rs b/src-tauri/src/service/plugin/install.rsindex 15f3776b..8ce879e1 100644--- a/src-tauri/src/service/plugin/install.rs+++ b/src-tauri/src/service/plugin/install.rs@@ -25,7 +25,7 @@ use tauri::{AppHandle, Emitter, Manager, WebviewWindow};use super::errors;use super::installed::{is_installed, profile_dir};-use super::preset::{bundled_plugin_dir, file_dep_spec, load_presets, PreinstallPluginInfo};+use super::preset::{bundled_dep_spec, bundled_plugin_dir, load_presets, PreinstallPluginInfo};use super::process::{run_plugin_process, PreinstallLogPayload, PREINSTALL_LOG_EVENT};use super::recovery::is_actionable_plugin_ref;use super::uninstall_recovery;@@ -60,8 +60,9 @@ pub async fn install(app_handle: &AppHandle, ids: &[String]) -> Result<(), Strinlet preset = preset_map.get(id.as_str()).ok_or_else(|| format!("PREINSTALL_INVALID_ID: {id}"))?;- // 内置插件改为从随包分发的捆绑目录安装(`file:` 本地依赖,见- // preset::file_dep_spec),其余沿用清单声明的 spec;随后统一把+ // 内置插件改为从随包分发的捆绑目录安装(`link:` 本地联接依赖,见+ // preset::bundled_dep_spec;不用 `file:`——pnpm 对盘符冒号的绝对路径+ // 会当相对路径解析),其余沿用清单声明的 spec;随后统一把// `github:user/repo` 规范为显式 `git+https://...`,绕开 pnpm 对// GitHub 简写「HTTPS 探测失败即回退 SSH」的已知缺陷(pnpm issue// #3948 / #7243 / #13276):公开仓库一旦落进 git+ssh,在没有 SSH 配置@@ -220,7 +221,7 @@ fn preset_spec_for_install(preset.id)})?;- Ok(file_dep_spec(&dir))+ Ok(bundled_dep_spec(&dir))}/// 构建 `dsh plugin` 子进程的环境变量:隔离 $DSH_HOME、关闭遥测与颜色,@@ -1006,12 +1007,13 @@ mod tests {#[test]fn install_spec_uses_bundled_dir_for_internal_preset() {- // 内置插件:安装依赖为 file:<捆绑目录>(正斜杠规范形)+ // 内置插件:安装依赖为 link:<捆绑目录>(正斜杠规范形;pnpm 对+ // `file:D:/...` 的盘符绝对路径会按相对解析,必须用 `link:`)let p = preset("dsh-tauri", "[email protected]", true);let dir = PathBuf::from("C:\\Apps\\dsh\\resources\\preset-plugins\\dsh-tauri");assert_eq!(preset_spec_for_install(&p, Some(dir)).unwrap(),- "file:C:/Apps/dsh/resources/preset-plugins/dsh-tauri"+ "link:C:/Apps/dsh/resources/preset-plugins/dsh-tauri");}diff --git a/src-tauri/src/service/plugin/preset.rs b/src-tauri/src/service/plugin/preset.rsindex 36ea5258..d4d14cab 100644--- a/src-tauri/src/service/plugin/preset.rs+++ b/src-tauri/src/service/plugin/preset.rs@@ -155,13 +155,16 @@ fn parse_dev_internal_dir(content: &str) -> Option<PathBuf> {None}-/// 内置插件的安装依赖形式:`file:<绝对路径>`(正斜杠、去尾部斜杠)。+/// 内置插件的安装依赖形式:`link:<绝对路径>`(正斜杠、去尾部斜杠)。///-/// pnpm 按传入形式把 `file:` 依赖写入 profile 的 package.json,这里生成规范形,-/// 安装(`install.rs`)与启动自愈(`internal.rs`)共用同一基准比对路径是否正确。-pub(crate) fn file_dep_spec(dir: &std::path::Path) -> String {+/// 用 `link:` 而非 `file:`:pnpm 会把 `file:D:/...`(Windows 盘符冒号)当相对+/// 路径拼到 cwd 下(报 `scandir <cwd>\D:\... ENOENT`),而 `link:` 正确按绝对+/// 路径解析并建立目录联接(junction,改源码重启服务即热更新)。pnpm 按传入+/// 形式把 `link:` 依赖写入 profile 的 package.json;安装(`install.rs`)与启动+/// 自愈(`internal.rs`)共用这一规范形比对路径是否正确。+pub(crate) fn bundled_dep_spec(dir: &std::path::Path) -> String {let normalized = dir.to_string_lossy().replace('\\', "/");- format!("file:{}", normalized.trim_end_matches('/'))+ format!("link:{}", normalized.trim_end_matches('/'))}/// 解析预设清单 JSON@@ -356,15 +359,15 @@ mod tests {}#[test]- fn file_dep_spec_normalizes_windows_separators() {+ fn bundled_dep_spec_normalizes_windows_separators() {assert_eq!(- file_dep_spec(std::path::Path::new("C:\\Apps\\dsh\\resources\\preset-plugins\\dsh-tauri")),- "file:C:/Apps/dsh/resources/preset-plugins/dsh-tauri"+ bundled_dep_spec(std::path::Path::new("C:\\Apps\\dsh\\resources\\preset-plugins\\dsh-tauri")),+ "link:C:/Apps/dsh/resources/preset-plugins/dsh-tauri");// 尾部斜杠去除(Windows 盘符 C:\ 不会出现,路径恒为子目录)assert_eq!(- file_dep_spec(std::path::Path::new("/opt/dsh/plugins/x/")),- "file:/opt/dsh/plugins/x"+ bundled_dep_spec(std::path::Path::new("/opt/dsh/plugins/x/")),+ "link:/opt/dsh/plugins/x");}