DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(plugin): 补丁层 YAML 语法错误可显式隔离,安全模式不再被 home 层拖死(fixes #525)
hairyf37559e11bd7f
diff --git a/docs/AGENTS.desktop.md b/docs/AGENTS.desktop.mdindex 539146d5..842ff4f0 100644--- a/docs/AGENTS.desktop.md+++ b/docs/AGENTS.desktop.md@@ -345,6 +345,8 @@ export function FooComponent(props: FooProps) {- 原生模块 ABI(issue #441):预打包核心的原生模块(`fs-ext` 等 node-gyp 包)在 pkg 构建期编译,ABI 只与构建期 Node 大版本一致,而本地 Node 只按 semver 挑选。`service/core/runtime.rs::prepare_active_runtime` 在 spawn 前用 `NATIVE_PROBE_SCRIPT` 探测(require 核心里的原生包,`NODE_MODULE_VERSION` 不匹配即 ABI 失败):先补 sharp/koffi 平台包,再改用与核心对齐的捆绑运行时(`config::set_prefer_bundled_node_runtime`,`get_node_binary_path`/`get_active_node_version`/`Nodejs::check_installed` 均受其影响,`launch.rs` 会在 prepare 后重新解析 node 路径),再 `npm rebuild`(用所选运行时自带的 npm),最后返回 `CORE_NATIVE_ABI_MISMATCH:` 诊断。CLI shim 的 node 选择仍是 semver-only。- pnpm store 绑定(`ERR_PNPM_UNEXPECTED_STORE`):pnpm 只在「自己解析出的 store」与档案 `node_modules/.modules.yaml` 里的 `storeDir` 一致时才继续安装,否则直接退出 —— 用户的 pnpm 用户级/全局配置(`store-dir`)或 `npm_config_store_dir` 环境变量把 store 指到别处(典型:用户在其他分区的工程里跑过 pnpm,pnpm 把那份 store 写进全局配置)时,档案安装会**在自身完全健康的情况下**失败,报错却是「插件安装失败」。`service/plugin/install/env.rs::build_plugin_envs` 因此把档案记录的 `storeDir` 显式注入子进程的 `npm_config_store_dir`(环境变量优先级高于 `.npmrc` 与全局配置,`Command::envs` 又会覆盖继承值),`ensure_pnpm` 的 store **主版本**匹配(`profile_store_major`)只解决 pnpm 10/11 布局不兼容,解决不了「同主版本、不同路径」。`storeDir` 解析见 `install/pnpm.rs::parse_store_dir_from_modules_yaml`。+- 补丁层 YAML 语法错误(issue #525):`$DSH_HOME/cordis.patch.yml`(全局层)会叠加到**每个**档案(含 `safe`),所以手写 YAML 里一个未加引号的 `: `(典型:`FOO: !!js process.env.X ? process.env.X : ''`)会让所有档案都起不来,报 `INTERNAL_PLUGIN_INSTALL_FAILED: INTERNAL_PLUGIN_PATCH_PARSE_FAILED: <路径>: <解析错误>`(dsh 上游契约要求**显式失败**,不会静默跳过损坏层,`loadOptionalPatches` 的 JSDoc 明确「present patch file that fails is a misconfiguration and must fail loud at boot」)。桌面端因此只做「显式隔离」而不自动跳过:`service/plugin/patch_guard.rs` 的 `quarantine_patch_layers_in(profile_dir, dsh_home)` 把**无法解析**的层重命名为 `<原名>.broken-<UTC yyyymmddhhmmss>`(同名追加 `-2`/`-3`,**不删除**),由错误页「隔离损坏的补丁文件」按钮(`quarantine_broken_patch_layers`)与「安全模式」(`enter_safe_mode`)触发;`repair_loader_state` 的解析错误现在按 `patch_layer_paths()`(当前档案层 + 全局层)逐个上报,前端用 `INTERNAL_PLUGIN_PATCH_PARSE_FAILED` 前缀识别并给出 `errors.patch_layer_parse_failed` + `buttons.quarantine_patch` 入口。+## Summary- **API Import**: 直接 `import { invoke } from '@tauri-apps/api/core'`(本仓库没有 `@/apis` 层);类型就近定义在 hooks/组件文件中diff --git "a/docs/testing/06-plugin/03-\346\217\222\344\273\266\345\274\202\345\270\270\344\270\216\346\201\242\345\244\215.md" "b/docs/testing/06-plugin/03-\346\217\222\344\273\266\345\274\202\345\270\270\344\270\216\346\201\242\345\244\215.md"index 0df88c39..d52e676b 100644--- "a/docs/testing/06-plugin/03-\346\217\222\344\273\266\345\274\202\345\270\270\344\270\216\346\201\242\345\244\215.md"+++ "b/docs/testing/06-plugin/03-\346\217\222\344\273\266\345\274\202\345\270\270\344\270\216\346\201\242\345\244\215.md"@@ -32,3 +32,10 @@[前置条件] profile 已安装 dshmarket(核心)与 @deepseek-ai/dsh-base(官方包)[测试步骤] 1. 直接调用 recover_plugin(id 为 dshmarket)并观察返回。2. 再调用 recover_plugin(id 为 @deepseek-ai/dsh-base)。3. 核对 profile 清单与 plugin-errors.json[预期结果] 1. 返回 PLUGIN_RECOVERY_REFUSED,拒绝删除核心包 dshmarket。2. 同样拒绝删除官方包 @deepseek-ai/dsh-base,前端不提示可修复移除。3. 这些受保护包从 profile 清单与 node_modules 未被动过,错误记录未被清除++## [P1] 验证补丁层 YAML 语法错误可被显式隔离并恢复启动++[测试类型] 可靠性+[前置条件] 已装入 dsh 内核可运行;`$DSH_HOME`(release 为 `~/.dsh`)下的全局补丁层 `~/.dsh/cordis.patch.yml` 被写成无法解析的 YAML(例如 `!!js` 表达式中含未加引号的 `: `:`YUNXIAO_ACCESS_TOKEN: !!js process.env.TOKEN ? process.env.TOKEN : ''`)+[测试步骤] 1. 在上述状态下启动桌面端,观察「Plugin installation」阶段的失败原因与界面提示。2. 点击错误页出现的「隔离损坏的补丁文件」按钮(或在错误页点击「安全模式」)。3. 观察 `~/.dsh` 下文件变化、应用是否重启成功与 toast 提示。4. 修复原 YAML 后把备份文件改回 `cordis.patch.yml`,重启确认恢复+[预期结果] 1. 阶段失败原因为 `INTERNAL_PLUGIN_INSTALL_FAILED: INTERNAL_PLUGIN_PATCH_PARSE_FAILED: <补丁文件路径>: <YAML 解析错误>`,界面展示 `errors.patch_layer_parse_failed` 提示(含解析器给出的位置),并额外提供「隔离损坏的补丁文件」按钮;不会静默跳过损坏层(dsh 上游契约要求显式失败)。2. 隔离动作把无法解析的层重命名为 `<原名>.broken-<UTC yyyymmddhhmmss>`(同名已存在时追加 `-2`、`-3`…),**不删除文件**;仅隔离本次启动实际组合的层(当前档案层 + 全局 `$DSH_HOME/cordis.patch.yml`)。3. 应用重启后正常进入 Running(`http://127.0.0.1:3080/healthz` 返回 200),成功隔离的每层各弹一条 `patch.quarantined_toast`(`<原路径> → <备份路径>`),重命名失败时弹 `patch.quarantine_failed_toast`(含路径与错误)且不阻断启动。4. 用户把备份改回原名后,补丁层重新生效;再次触发隔离时因原文件已不存在而不产生任何备份文件(幂等)diff --git a/docs/testing/all_cases.md b/docs/testing/all_cases.mdindex 24b73f88..1f4c689b 100644--- a/docs/testing/all_cases.md+++ b/docs/testing/all_cases.md@@ -931,6 +931,13 @@[测试步骤] 1. 直接调用 recover_plugin(id 为 dshmarket)并观察返回。2. 再调用 recover_plugin(id 为 @deepseek-ai/dsh-base)。3. 核对 profile 清单与 plugin-errors.json[预期结果] 1. 返回 PLUGIN_RECOVERY_REFUSED,拒绝删除核心包 dshmarket。2. 同样拒绝删除官方包 @deepseek-ai/dsh-base,前端不提示可修复移除。3. 这些受保护包从 profile 清单与 node_modules 未被动过,错误记录未被清除+## [P1] 验证补丁层 YAML 语法错误可被显式隔离并恢复启动++[测试类型] 可靠性+[前置条件] 已装入 dsh 内核可运行;`$DSH_HOME`(release 为 `~/.dsh`)下的全局补丁层 `~/.dsh/cordis.patch.yml` 被写成无法解析的 YAML(例如 `!!js` 表达式中含未加引号的 `: `:`YUNXIAO_ACCESS_TOKEN: !!js process.env.TOKEN ? process.env.TOKEN : ''`)+[测试步骤] 1. 在上述状态下启动桌面端,观察「Plugin installation」阶段的失败原因与界面提示。2. 点击错误页出现的「隔离损坏的补丁文件」按钮(或在错误页点击「安全模式」)。3. 观察 `~/.dsh` 下文件变化、应用是否重启成功与 toast 提示。4. 修复原 YAML 后把备份文件改回 `cordis.patch.yml`,重启确认恢复+[预期结果] 1. 阶段失败原因为 `INTERNAL_PLUGIN_INSTALL_FAILED: INTERNAL_PLUGIN_PATCH_PARSE_FAILED: <补丁文件路径>: <YAML 解析错误>`,界面展示 `errors.patch_layer_parse_failed` 提示(含解析器给出的位置),并额外提供「隔离损坏的补丁文件」按钮;不会静默跳过损坏层(dsh 上游契约要求显式失败)。2. 隔离动作把无法解析的层重命名为 `<原名>.broken-<UTC yyyymmddhhmmss>`(同名已存在时追加 `-2`、`-3`…),**不删除文件**;仅隔离本次启动实际组合的层(当前档案层 + 全局 `$DSH_HOME/cordis.patch.yml`)。3. 应用重启后正常进入 Running(`http://127.0.0.1:3080/healthz` 返回 200),成功隔离的每层各弹一条 `patch.quarantined_toast`(`<原路径> → <备份路径>`),重命名失败时弹 `patch.quarantine_failed_toast`(含路径与错误)且不阻断启动。4. 用户把备份改回原名后,补丁层重新生效;再次触发隔离时因原文件已不存在而不产生任何备份文件(幂等)+## 预装插件安装引导diff --git a/src-tauri/src/bridge/lifecycle.rs b/src-tauri/src/bridge/lifecycle.rsindex c933954a..2b2b6a32 100644--- a/src-tauri/src/bridge/lifecycle.rs+++ b/src-tauri/src/bridge/lifecycle.rs@@ -345,11 +345,39 @@ pub async fn restart_harness(app_handle: AppHandle) -> Result<(), String> {/// 自愈与首次引导安装都作用于「当时的活动档案」);这些插件由启动前的清除流程卸载/// (见 `service::plugin::safe::purge_user_plugins_in_safe_profile`),本命令只负责/// 切档案——服务仍在运行时删除插件目录不安全,必须等重启后的 spawn 之前再清。+///+/// 补丁层是这里唯一的例外:**home 层(`$DSH_HOME/cordis.patch.yml`)作用于所有+/// 档案**,安全档案也不例外,因此一处手写笔误(典型是 `!!js` 表达式含 `: ` 却没加+/// 引号)会让安全模式也起不来,把兜底入口一起废掉(issue #525)。这里在切档案前把+/// 解析不了的补丁文件改名为同名 `.broken-<时间戳>` 备份(只改名、不删除),保证+/// 「安全模式一定起得来」;记录回传前端提示备份路径,用户修好语法后改回原名即可恢复。#[tauri::command]-pub async fn enter_safe_mode(app_handle: AppHandle) -> Result<(), String> {+pub async fn enter_safe_mode(+ app_handle: AppHandle,+) -> Result<crate::service::plugin::PatchQuarantineReport, String> {crate::service::profile::ensure_safe_profile(&app_handle)?;+ let report = crate::service::plugin::quarantine_patch_layers_in(+ &crate::service::profile::profile_dir_of(+ &app_handle,+ crate::service::profile::SAFE_PROFILE,+ ),+ &config::get_dsh_data_path(&app_handle),+ );crate::service::profile::set_active(&app_handle, crate::service::profile::SAFE_PROFILE)?;- Ok(())+ Ok(report)+}++/// 隔离解析失败的补丁层:当前档案层 + home 层(错误页「隔离损坏的补丁文件」入口)。+///+/// 与 [`enter_safe_mode`] 共用同一套隔离逻辑,区别只在作用范围——本命令让用户留在+/// 自己的档案里恢复,不切档案、不动插件。补丁文件只改名保存,内容原样保留。+#[tauri::command]+pub async fn quarantine_broken_patch_layers(+ app_handle: AppHandle,+) -> Result<crate::service::plugin::PatchQuarantineReport, String> {+ Ok(crate::service::plugin::quarantine_active_patch_layers(+ &app_handle,+ ))}/// 获取当前 Harness 服务状态diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex 4002c5fc..9e746a5b 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -566,6 +566,7 @@ pub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {crate::bridge::shutdown_harness,crate::bridge::restart_harness,crate::bridge::enter_safe_mode,+ crate::bridge::quarantine_broken_patch_layers,crate::bridge::get_dsh_status,crate::bridge::get_preinstall_plugins,crate::bridge::get_preinstall_pending,diff --git a/src-tauri/src/service/plugin/internal/mod.rs b/src-tauri/src/service/plugin/internal/mod.rsindex f1038ec5..3536c812 100644--- a/src-tauri/src/service/plugin/internal/mod.rs+++ b/src-tauri/src/service/plugin/internal/mod.rs@@ -185,10 +185,7 @@ pub(crate) fn repair_loader_state(app_handle: &AppHandle) -> Result<(), String>}}- for patch_path in [- profile.join("cordis.patch.yml"),- config::get_dsh_data_path(app_handle).join("cordis.patch.yml"),- ] {+ for patch_path in super::patch_layer_paths(&profile, &config::get_dsh_data_path(app_handle)) {let Ok(raw) = std::fs::read_to_string(&patch_path) else {continue;};diff --git a/src-tauri/src/service/plugin/mod.rs b/src-tauri/src/service/plugin/mod.rsindex 2f43c52f..afb21219 100644--- a/src-tauri/src/service/plugin/mod.rs+++ b/src-tauri/src/service/plugin/mod.rs@@ -26,6 +26,7 @@//! - [`process`]:dsh 子进程启动与输出流逐行转发//! - [`recovery`]:插件异常定位与一键离线卸载//! - [`safe`]:安全档案启动前的用户插件清除(只留内置插件与核心包)+//! - [`patch_guard`]:补丁层 YAML 语法错误的显式隔离(安全模式 / 错误页恢复入口)//! - [`cancel`]:Windows 下取消正在进行的安装//! - [`watch`]:已安装插件文件监控(轮询指纹比对 + `dsh-plugins-updated` 事件推送)@@ -35,6 +36,7 @@ pub mod errors;mod install;mod installed;mod internal;+mod patch_guard;mod preset;mod process;pub mod recovery;@@ -59,6 +61,10 @@ pub(crate) use preset::{remove_legacy_bundled_plugins,};pub(crate) use safe::purge_user_plugins_in_safe_profile;+pub(crate) use patch_guard::{+ patch_layer_paths, quarantine_active_patch_layers, quarantine_patch_layers_in,+ PatchQuarantineReport,+};pub use disable::{disable, enable};pub use recovery::{detect as detect_recovery, uninstall as uninstall_recovery, PluginRecoveryInfo,diff --git a/src-tauri/src/service/plugin/patch_guard.rs b/src-tauri/src/service/plugin/patch_guard.rsnew file mode 100644index 00000000..db65f473--- /dev/null+++ b/src-tauri/src/service/plugin/patch_guard.rs@@ -0,0 +1,296 @@+//! 补丁层语法错误的隔离:让安全模式在用户补丁层损坏时仍然可用。+//!+//! `$DSH_HOME/cordis.patch.yml`(机器级 home 层)与+//! `$DSH_HOME/profiles/<id>/cordis.patch.yml`(档案层)都是用户可手写的 YAML+//! 补丁层。上游 dsh 的契约是「文件存在却不能被应用时必须大声失败,绝不静默跳过」+//! (`@deepseek-ai/dsh-app-boot` 的 `loadOptionalPatches` 明确写着这一点),桌面端+//! 的内置插件自愈([`super::internal::repair_loader_state`])同样在解析阶段直接失败。+//! 于是一处手写笔误——典型是 `!!js` 表达式里带 `: `/`?` 却没加引号——会让应用+//! **永久不可用**:每次启动都停在同一处,而唯一的兜底入口「安全模式」也走同一份+//! home 层(home 层作用于所有档案,安全档案不例外),连兜底一起失效(issue #525)。+//!+//! 因此这里提供「隔离」这一**显式**恢复动作:把解析不了的补丁文件改名为+//! `<原文件名>.broken-<UTC 时间戳>`(绝不删除,内容原样保留),决定权交回用户+//! ——修好语法后改回原名即可恢复。只有用户点「安全模式」或错误页的「隔离损坏的+//! 补丁文件」时才执行,绝不自动发生;普通档案的启动路径仍然按上游契约大声失败,+//! 由前端给出「哪个文件、哪一行、怎么改」的针对性提示。++use std::path::{Path, PathBuf};++use tauri::AppHandle;++use super::profile_dir;+use crate::config;++/// dsh 的补丁层文件名:档案层与 home 层同名,靠目录区分。+const PATCH_FILENAME: &str = "cordis.patch.yml";++/// 一个已被隔离(改名保存)的补丁层。+#[derive(Debug, Clone, serde::Serialize)]+pub struct QuarantinedPatchLayer {+ /// 原始补丁文件路径。+ pub original: String,+ /// 备份路径(`<原名>.broken-<UTC 时间戳>`)。+ pub backup: String,+ /// 解析错误(serde_yaml 文本,含行列号)。+ pub error: String,+}++/// 一个无法移动的损坏补丁层(隔离失败):调用方只记录,不阻断。+#[derive(Debug, Clone, serde::Serialize)]+pub struct PatchQuarantineFailure {+ /// 补丁文件路径。+ pub path: String,+ /// 改名失败原因。+ pub error: String,+}++/// 一次隔离动作的结果:成功移走的层 + 未能移走的层。+#[derive(Debug, Default, Clone, serde::Serialize)]+pub struct PatchQuarantineReport {+ /// 已隔离(改名保存)的补丁层,前端据此提示备份路径。+ pub quarantined: Vec<QuarantinedPatchLayer>,+ /// 隔离失败的补丁层,只进日志与提示,不影响其它层。+ pub failures: Vec<PatchQuarantineFailure>,+}++/// 补丁层路径:档案层在前、home 层在后(与 dsh 的层叠顺序一致)。+///+/// 与 [`super::internal::repair_loader_state`] 共用同一份清单,避免两处对+/// 「哪些补丁层需要自愈」的认知漂移。+pub(crate) fn patch_layer_paths(profile_dir: &Path, dsh_home: &Path) -> [PathBuf; 2] {+ [+ profile_dir.join(PATCH_FILENAME),+ dsh_home.join(PATCH_FILENAME),+ ]+}++/// 解析补丁层:语法错误时返回 serde_yaml 的错误文本(含行列号)。+///+/// 文件不存在、读不出来(权限错位/竞态)都不算语法错误——那些由可写性预检与+/// 上游自身的错误路径负责,本模块只处理「文件在、但 YAML 解析不了」。+fn parse_error(path: &Path) -> Option<String> {+ let raw = std::fs::read_to_string(path).ok()?;+ serde_yaml::from_str::<serde_yaml::Value>(&raw)+ .err()+ .map(|error| error.to_string())+}++/// 备份路径 `<原名>.broken-<stamp>`;已存在时追加 `-2`、`-3`…,绝不覆盖已有备份。+fn backup_path(path: &Path, stamp: &str) -> PathBuf {+ let name = path+ .file_name()+ .map(|name| name.to_string_lossy().into_owned())+ .unwrap_or_default();+ let mut candidate = path.with_file_name(format!("{name}.broken-{stamp}"));+ let mut suffix = 2;+ while candidate.exists() {+ candidate = path.with_file_name(format!("{name}.broken-{stamp}-{suffix}"));+ suffix += 1;+ }+ candidate+}++/// 隔离给定补丁层里所有解析失败的文件。+///+/// 每层独立处理:某一层改名失败不阻断其它层(与启动期其它自愈同一策略——清理不+/// 彻底只是恢复效果打折,把已能恢复的层留在原地则让应用彻底不可用)。+fn quarantine_layers(paths: &[PathBuf], stamp: &str) -> PatchQuarantineReport {+ let mut report = PatchQuarantineReport::default();+ for path in paths {+ let Some(error) = parse_error(path) else {+ continue;+ };+ let backup = backup_path(path, stamp);+ match std::fs::rename(path, &backup) {+ Ok(()) => {+ log::warn!(+ "PATCH_LAYER_QUARANTINED: {} -> {} ({error})",+ path.display(),+ backup.display()+ );+ report.quarantined.push(QuarantinedPatchLayer {+ original: path.display().to_string(),+ backup: backup.display().to_string(),+ error,+ });+ }+ Err(rename_error) => {+ let message = rename_error.to_string();+ log::warn!(+ "PATCH_LAYER_QUARANTINE_FAILED: {}: {message}",+ path.display()+ );+ report.failures.push(PatchQuarantineFailure {+ path: path.display().to_string(),+ error: message,+ });+ }+ }+ }+ report+}++/// 生成 UTC 时间戳(`yyyymmddhhmmss`),与档案备份、插件快照的命名一致。+fn now_stamp() -> String {+ use time::OffsetDateTime;+ let now = OffsetDateTime::now_utc();+ let date = now.date();+ let time = now.time();+ format!(+ "{:04}{:02}{:02}{:02}{:02}{:02}",+ date.year(),+ date.month() as u8,+ date.day(),+ time.hour(),+ time.minute(),+ time.second()+ )+}++/// 隔离指定档案层与 home 层里解析失败的补丁文件。+///+/// 只改名、不删除、不改内容:用户可以修好语法后把备份改回原名。+pub(crate) fn quarantine_patch_layers_in(+ profile_dir: &Path,+ dsh_home: &Path,+) -> PatchQuarantineReport {+ quarantine_layers(&patch_layer_paths(profile_dir, dsh_home), &now_stamp())+}++/// 隔离「当前档案层 + home 层」里解析失败的补丁文件。+///+/// 由错误页的「隔离损坏的补丁文件并重启」入口调用:用户想留在自己的档案里恢复。+pub(crate) fn quarantine_active_patch_layers(app_handle: &AppHandle) -> PatchQuarantineReport {+ quarantine_patch_layers_in(+ &profile_dir(app_handle),+ &config::get_dsh_data_path(app_handle),+ )+}++#[cfg(test)]+mod tests {+ use super::*;++ /// 构造独立的临时目录,供补丁层用例使用。+ fn tmp_dir(name: &str) -> PathBuf {+ let dir = std::env::temp_dir().join(format!(+ "dsh-patch-guard-{name}-{}-{}",+ std::process::id(),+ now_stamp()+ ));+ let _ = std::fs::remove_dir_all(&dir);+ std::fs::create_dir_all(&dir).unwrap();+ dir+ }++ /// issue #525 的真实形态:`!!js` 表达式带 `: ` 却没加引号。+ const BROKEN_UNQUOTED_JS: &str = r#"- id: session-telemetry-otel+ config:+ YUNXIAO_ACCESS_TOKEN: !!js process.env.TOKEN ? process.env.TOKEN : (function () { return '' })()+"#;+ const VALID_LAYER: &str = "- id: dsh-base\n disabled: false\n";++ #[test]+ fn parse_error_reports_unquoted_js_expression() {+ let dir = tmp_dir("parse-error");+ let path = dir.join(PATCH_FILENAME);+ std::fs::write(&path, BROKEN_UNQUOTED_JS).unwrap();++ // 这一形态必须被判为语法错误,否则 #525 的补丁层不会被隔离。+ assert!(parse_error(&path).is_some());+ std::fs::write(&path, VALID_LAYER).unwrap();+ assert!(parse_error(&path).is_none());+ // 不存在的文件不是语法错误(由上游与可写性预检负责)。+ assert!(parse_error(&dir.join("missing.yml")).is_none());+ let _ = std::fs::remove_dir_all(&dir);+ }++ #[test]+ fn quarantine_moves_only_unparsable_layers() {+ let profile = tmp_dir("quarantine-profile");+ let home = tmp_dir("quarantine-home");+ let profile_patch = profile.join(PATCH_FILENAME);+ let home_patch = home.join(PATCH_FILENAME);+ std::fs::write(&profile_patch, VALID_LAYER).unwrap();+ std::fs::write(&home_patch, BROKEN_UNQUOTED_JS).unwrap();++ let report = quarantine_patch_layers_in(&profile, &home);++ assert!(report.failures.is_empty(), "{:?}", report.failures);+ assert_eq!(report.quarantined.len(), 1);+ let record = &report.quarantined[0];+ assert_eq!(record.original, home_patch.display().to_string());+ // 原文件被移走、备份保留原始内容(绝不删除)。+ assert!(!home_patch.exists());+ assert_eq!(std::fs::read_to_string(&record.backup).unwrap(), BROKEN_UNQUOTED_JS);+ // 合法的档案层原样保留,且不产生备份。+ assert_eq!(std::fs::read_to_string(&profile_patch).unwrap(), VALID_LAYER);+ assert_eq!(std::fs::read_dir(&profile).unwrap().count(), 1);+ let _ = std::fs::remove_dir_all(&profile);+ let _ = std::fs::remove_dir_all(&home);+ }++ #[test]+ fn quarantine_is_idempotent() {+ let profile = tmp_dir("idempotent-profile");+ let home = tmp_dir("idempotent-home");+ std::fs::write(home.join(PATCH_FILENAME), BROKEN_UNQUOTED_JS).unwrap();++ assert_eq!(quarantine_patch_layers_in(&profile, &home).quarantined.len(), 1);+ // 第二次调用:文件已不在,不再产生任何动作(可反复点「安全模式」)。+ let second = quarantine_patch_layers_in(&profile, &home);+ assert!(second.quarantined.is_empty());+ assert!(second.failures.is_empty());+ let _ = std::fs::remove_dir_all(&profile);+ let _ = std::fs::remove_dir_all(&home);+ }++ #[test]+ fn backup_path_never_overwrites_existing_backup() {+ let dir = tmp_dir("backup-collision");+ let patch = dir.join(PATCH_FILENAME);+ std::fs::write(&patch, BROKEN_UNQUOTED_JS).unwrap();+ let first = dir.join(format!("{PATCH_FILENAME}.broken-20260914123456"));+ std::fs::write(&first, "keep me\n").unwrap();++ let report = quarantine_layers(+ &[patch.clone()],+ "20260914123456",+ );++ assert_eq!(report.quarantined.len(), 1);+ let record = &report.quarantined[0];+ assert!(record.backup.ends_with("-2"), "{}", record.backup);+ // 既有备份内容不被覆盖。+ assert_eq!(std::fs::read_to_string(&first).unwrap(), "keep me\n");+ assert_eq!(std::fs::read_to_string(&record.backup).unwrap(), BROKEN_UNQUOTED_JS);+ let _ = std::fs::remove_dir_all(&dir);+ }++ #[test]+ fn quarantine_ignores_valid_and_missing_layers() {+ let profile = tmp_dir("valid-profile");+ let home = tmp_dir("valid-home");+ std::fs::write(profile.join(PATCH_FILENAME), VALID_LAYER).unwrap();+ std::fs::write(home.join(PATCH_FILENAME), "[]\n").unwrap();++ let report = quarantine_patch_layers_in(&profile, &home);++ assert!(report.quarantined.is_empty());+ assert!(report.failures.is_empty());+ assert_eq!(+ std::fs::read_to_string(profile.join(PATCH_FILENAME)).unwrap(),+ VALID_LAYER+ );+ let _ = std::fs::remove_dir_all(&profile);+ let _ = std::fs::remove_dir_all(&home);+ }++ #[test]+ fn patch_layer_paths_are_profile_then_home() {+ let paths = patch_layer_paths(Path::new("/profiles/safe"), Path::new("/dsh-home"));+ assert_eq!(paths[0], Path::new("/profiles/safe").join(PATCH_FILENAME));+ assert_eq!(paths[1], Path::new("/dsh-home").join(PATCH_FILENAME));+ }+}diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex 29d7ac2f..80b511d1 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -89,6 +89,7 @@"errors.client_boot_failed": "The client reported a failure while loading plugins.","errors.plugin_route_conflict": "Detected a plugin route conflict: two plugins registered the same route twice. Uninstall the recently added plugin (e.g. dsh-web-ui-all / dsh-better-sidebar) from the Plugins panel, or run dsh plugin --profile <profile> remove <package> for the active profile and retry.","errors.inotify_limit": "The Harness service crashed on startup: your system reached the limit for file watchers (inotify ENOSPC). Increase the watcher limit and restart — e.g. run `sudo sysctl fs.inotify.max_user_watches=524288` (and add `fs.inotify.max_user_watches=524288` to `/etc/sysctl.conf` to persist), then restart the app.",+ "errors.patch_layer_parse_failed": "A patch layer has a YAML syntax error, so Harness cannot parse it: {{detail}}. The usual cause is an unquoted `!!js` expression that contains `:` or `?` — quote it (`!!js \"…\"`) or use a block scalar (`|-`), then retry. You can also use \"Quarantine broken patch files\" to start anyway; that file is renamed to a `.broken-<timestamp>` backup and restored by renaming it back.","ui.service_url": "Service URL","ui.port": "Port","ui.zoom": "Zoom",@@ -123,7 +124,10 @@"buttons.copy": "Copy","buttons.copy_logs": "Copy Logs","buttons.safe_mode": "Safe Mode",- "hints.safe_mode": "Restart with only the core bundles and built-in plugins, uninstalling any other plugin from that profile to isolate the ones that fail to start. Switch back to your profile in the sidebar to exit safe mode.",+ "buttons.quarantine_patch": "Quarantine broken patch files",+ "patch.quarantined_toast": "Quarantined an unparsable patch file: {{original}} → {{backup}}. Fix the syntax and rename it back to restore it.",+ "patch.quarantine_failed_toast": "Failed to quarantine a broken patch file: {{path}} ({{error}})",+ "hints.safe_mode": "Restart with only the core bundles and built-in plugins, uninstalling any other plugin from that profile to isolate the ones that fail to start. Patch files that cannot be parsed (a YAML syntax error) are also moved aside as `.broken-<timestamp>` backups. Switch back to your profile in the sidebar to exit safe mode.","messages.clipboard_copied": "Copied to clipboard","messages.clipboard_failed": "Copy failed","messages.copy_success": "URL copied to clipboard",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 3f0d8728..7fb4aca4 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -89,6 +89,7 @@"errors.client_boot_failed": "客户端加载插件时报告了失败。","errors.plugin_route_conflict": "检测到插件路由冲突:两个插件重复注册了同一路由。请在「插件」面板卸载最近安装的插件(如 dsh-web-ui-all / dsh-better-sidebar),或在终端对当前档案执行 dsh plugin --profile <档案名> remove <包名> 后重试。","errors.inotify_limit": "Harness 服务启动即崩溃:系统文件监视(inotify)数量达到上限。请调高监视上限后重试——例如执行 `sudo sysctl fs.inotify.max_user_watches=524288`(并将 `fs.inotify.max_user_watches=524288` 写入 `/etc/sysctl.conf` 以持久化),然后重启应用。",+ "errors.patch_layer_parse_failed": "补丁层存在 YAML 语法错误,Harness 无法解析:{{detail}}。常见原因是 `!!js` 表达式里含 `:` 或 `?` 却未加引号——请改成 `!!js \"…\"`(或块标量 `|-`)后重试;也可以点「隔离损坏的补丁文件」,把该文件改名为 `.broken-<时间戳>` 备份后先启动(修好语法后改回原名即可恢复)。","ui.service_url": "服务地址","ui.port": "端口","ui.zoom": "界面缩放",@@ -123,7 +124,10 @@"buttons.copy": "复制","buttons.copy_logs": "复制日志","buttons.safe_mode": "安全模式",- "hints.safe_mode": "仅加载核心组件与内置插件重启,并卸载该档案中的其它插件以隔离启动失败。在侧边栏切回原档案即可退出安全模式。",+ "buttons.quarantine_patch": "隔离损坏的补丁文件",+ "patch.quarantined_toast": "已隔离无法解析的补丁文件:{{original}} → {{backup}}。修好语法后改回原名即可恢复。",+ "patch.quarantine_failed_toast": "隔离补丁文件失败:{{path}}({{error}})",+ "hints.safe_mode": "仅加载核心组件与内置插件重启,并卸载该档案中的其它插件以隔离启动失败;解析不了的补丁文件(YAML 语法错误)也会被改名为 `.broken-<时间戳>` 备份。在侧边栏切回原档案即可退出安全模式。","messages.clipboard_copied": "已复制到剪贴板","messages.clipboard_failed": "复制失败","messages.copy_success": "地址已复制到剪贴板",diff --git a/src/layout/components/setup.tsx b/src/layout/components/setup.tsxindex 7aa80477..5d9f8bc3 100644--- a/src/layout/components/setup.tsx+++ b/src/layout/components/setup.tsx@@ -45,6 +45,7 @@ export function Setup() {errorLogs,pluginConflictHint,inotifyLimitHint,+ patchLayerHint,} = useStore(store.harness)const error = status === 'error'const installing = status === 'installing'@@ -55,8 +56,11 @@ export function Setup() {const logs = installing? installer.logs: (error && errorLogs.length > 0 ? errorLogs : undefined)- // 错误态的针对性提示:插件路由冲突 / Linux inotify 文件监视上限,二选一优先展示- const hint = error ? (pluginConflictHint || inotifyLimitHint) : undefined+ // 错误态的针对性提示:插件路由冲突 / Linux inotify 文件监视上限 / 补丁层语法错误,+ // 三者互斥(由各自的失败特征识别),优先展示最具体的一条。+ const hint = error ? (patchLayerHint || pluginConflictHint || inotifyLimitHint) : undefined+ // 补丁层语法错误:提供「隔离损坏的补丁文件」恢复入口(改名备份后重启,不删文件)+ const patchLayerBroken = error && patchLayerHint !== ''return (<Loadable@@ -82,6 +86,16 @@ export function Setup() {>{t('app.retry')}</button>+ <If cond={patchLayerBroken}>+ <button+ className={button({ tone: 'primary', size: 'sm' })}+ onClick={() => {+ void store.harness.quarantineBrokenPatchLayers()+ }}+ >+ {t('buttons.quarantine_patch')}+ </button>+ </If><buttonclassName={button({ tone: 'ghost', size: 'sm' })}onClick={() => copyLogsHandler(t)}diff --git a/src/store/modules/harness/patch-layer.ts b/src/store/modules/harness/patch-layer.tsnew file mode 100644index 00000000..44a15509--- /dev/null+++ b/src/store/modules/harness/patch-layer.ts@@ -0,0 +1,27 @@+/**+ * 补丁层 YAML 语法错误的识别与信息提取(纯函数,便于单测)。+ *+ * Rust 侧 `service::plugin::internal::repair_loader_state` 解析档案层 / home 层的+ * `cordis.patch.yml` 失败时抛出 `INTERNAL_PLUGIN_PATCH_PARSE_FAILED: <路径>: <错误>`+ * (见 `service::plugin::patch_guard` 的模块说明),随后被包成+ * `INTERNAL_PLUGIN_INSTALL_FAILED` 并挂在「Plugin installation 阶段」——用户看到的+ * 是「插件安装失败」,实际原因却是补丁文件写错了(issue #525)。这里把它识别出来,+ * 转成「哪个文件、哪一行、怎么改」的针对性提示与隔离入口。+ */++/** Rust 侧补丁层解析失败的错误码。 */+export const PATCH_PARSE_ERROR_CODE = 'INTERNAL_PLUGIN_PATCH_PARSE_FAILED'++/** 启动失败信息里是否包含补丁层解析失败。 */+export function containsPatchLayerParseError(message: string): boolean {+ return message.includes(`${PATCH_PARSE_ERROR_CODE}:`)+}++/** 提取补丁层解析失败的「路径 + YAML 错误(含行列号)」片段(无则空串)。 */+export function patchLayerErrorDetail(message: string): string {+ const marker = `${PATCH_PARSE_ERROR_CODE}:`+ const at = message.indexOf(marker)+ if (at < 0)+ return ''+ return message.slice(at + marker.length).trim()+}diff --git a/src/store/modules/harness/store.ts b/src/store/modules/harness/store.tsindex 951b7583..1e19ef76 100644--- a/src/store/modules/harness/store.ts+++ b/src/store/modules/harness/store.ts@@ -9,6 +9,7 @@ import type {SidebarBusyAction,StartupError,} from './types'+import type { PatchQuarantineReport } from '@/types/plugin'import { invoke } from '@tauri-apps/api/core'import { listen } from '@tauri-apps/api/event'import i18next from 'i18next'@@ -36,6 +37,7 @@ import {checkHealthViaProxy,generateTimestampedUrl,internalPluginReason,+ notifyPatchQuarantine,pollHarnessReadiness,startupError,} from './utils'@@ -87,6 +89,8 @@ export const harness = defineStore({pluginConflictHint: '',/** 识别到 Linux inotify 文件监视上限(ENOSPC)时的针对性提示(Loadable children 展示) */inotifyLimitHint: '',+ /** 识别到补丁层 YAML 语法错误时的针对性提示(含文件与行列号,Loadable children 展示) */+ patchLayerHint: '',serviceUrl: 'http://127.0.0.1:3080',/** 带时间戳的 iframe 地址(boot 时生成一次,避免缓存) */iframeSrc: '',@@ -205,6 +209,8 @@ export const harness = defineStore({error.logs,error.pluginConflictHint,error.inotifyLimitHint,+ undefined,+ error.patchLayerHint,)},@@ -319,6 +325,7 @@ export const harness = defineStore({error.pluginConflictHint,error.inotifyLimitHint,this.serviceRunning,+ error.patchLayerHint,)},@@ -372,6 +379,7 @@ export const harness = defineStore({this.errorLogs = []this.pluginConflictHint = ''this.inotifyLimitHint = ''+ this.patchLayerHint = ''preinstall.error = ''// 服务(重)启动成功:清空插件异常修复态(若曾进入),并重置已「暂不处理」的插件recovery.reset()@@ -400,6 +408,7 @@ export const harness = defineStore({this.errorLogs = []this.pluginConflictHint = ''this.inotifyLimitHint = ''+ this.patchLayerHint = ''recovery.reset()this.serviceHealthy = falsethis.iframeLoaded = false@@ -480,6 +489,7 @@ export const harness = defineStore({this.errorLogs = []this.pluginConflictHint = ''this.inotifyLimitHint = ''+ this.patchLayerHint = ''recovery.clear()this.status = 'ready'let unlistenInstall: UnlistenFn | null = null@@ -604,11 +614,12 @@ export const harness = defineStore({},/** 进入错误态(供本模块与 harness-updater 模块共用) */- fail(message: string, logs?: string[], pluginConflictHint?: string, inotifyLimitHint?: string, keepServiceRunning = false) {+ fail(message: string, logs?: string[], pluginConflictHint?: string, inotifyLimitHint?: string, keepServiceRunning = false, patchLayerHint?: string) {this.errorMsg = messagethis.errorLogs = logs ?? []this.pluginConflictHint = pluginConflictHint ?? ''this.inotifyLimitHint = inotifyLimitHint ?? ''+ this.patchLayerHint = patchLayerHint ?? ''this.status = 'error'this.serviceRunning = keepServiceRunning},@@ -648,17 +659,57 @@ export const harness = defineStore({* 进入安全模式:切到 safe 档案(仅核心 bundles、无用户插件)并重启服务。* 启动失败的插件(如 pending waiting for service)被隔离,应用先恢复可用;* 用户在档案列表切回原档案即退出安全模式。+ *+ * 后端同时会隔离「解析不了的补丁层」(安全档案层 + home 层,见+ * `service::plugin::patch_guard`):home 层作用于所有档案,不隔离的话一处+ * 手写笔误会让安全模式也起不来(issue #525)。结果用 toast 告知备份路径。*/async enterSafeMode() {if (this.busyAction)returntry {- await invoke('enter_safe_mode')+ const report = await invoke<PatchQuarantineReport>('enter_safe_mode')+ notifyPatchQuarantine(report)}catch (err) {console.error('[Harness] enter safe mode failed:', err)const error = await attachStartupDiagnostics(err)- this.fail(error.message, error.logs, error.pluginConflictHint, error.inotifyLimitHint)+ this.fail(+ error.message,+ error.logs,+ error.pluginConflictHint,+ error.inotifyLimitHint,+ undefined,+ error.patchLayerHint,+ )+ return+ }+ await this.restart()+ },++ /**+ * 隔离解析不了的补丁层(当前档案层 + home 层)并重启:错误页在补丁层语法+ * 错误时的专用恢复入口,让用户留在自己的档案里恢复,不切档案、不动插件。+ * 补丁文件只改名保存为 `.broken-<时间戳>` 备份,修好语法后改回原名即可恢复。+ */+ async quarantineBrokenPatchLayers() {+ if (this.busyAction)+ return+ try {+ const report = await invoke<PatchQuarantineReport>('quarantine_broken_patch_layers')+ notifyPatchQuarantine(report)+ }+ catch (err) {+ console.error('[Harness] quarantine broken patch layers failed:', err)+ const error = await attachStartupDiagnostics(err)+ this.fail(+ error.message,+ error.logs,+ error.pluginConflictHint,+ error.inotifyLimitHint,+ undefined,+ error.patchLayerHint,+ )return}await this.restart()@@ -686,6 +737,7 @@ export const harness = defineStore({this.errorLogs = []this.pluginConflictHint = ''this.inotifyLimitHint = ''+ this.patchLayerHint = ''recovery.reset()},diff --git a/src/store/modules/harness/types.ts b/src/store/modules/harness/types.tsindex a5f3c145..f4006d51 100644--- a/src/store/modules/harness/types.ts+++ b/src/store/modules/harness/types.ts@@ -61,6 +61,8 @@ export interface StartupError extends Error {pluginConflictHint?: string/** Linux inotify 文件监视上限(ENOSPC)导致服务启动即崩溃时的针对性提示 */inotifyLimitHint?: string+ /** 补丁层 YAML 语法错误(`cordis.patch.yml` 手写错误)时的针对性提示 */+ patchLayerHint?: stringphase?: StartupPhaselastReason?: string}diff --git a/src/store/modules/harness/utils.ts b/src/store/modules/harness/utils.tsindex 3cc94b42..6e70a81d 100644--- a/src/store/modules/harness/utils.ts+++ b/src/store/modules/harness/utils.ts@@ -1,15 +1,18 @@/* eslint-disable no-control-regex */import type { ReadinessPollResult, ReadinessProbeResult, StartupPhase } from './readiness'import type { InternalPluginsPhasePayload, StartupError } from './types'+import type { PatchQuarantineReport } from '@/types/plugin'import { invoke } from '@tauri-apps/api/core'import i18next from 'i18next'import { containsInotifyLimitError, pickErrorLines } from '@/components/logs.utils'+import { toast } from '@/utils/toast'import {HEALTH_PROBE_INITIAL_INTERVAL,HEALTH_PROBE_MAX_INTERVAL,LOG_TAIL_MAX_BYTES,STARTUP_INACTIVITY_TIMEOUT,} from './constants'+import { containsPatchLayerParseError, patchLayerErrorDetail } from './patch-layer'import { pollReadiness } from './readiness'/**@@ -166,9 +169,37 @@ export async function attachStartupDiagnostics(err: unknown): Promise<StartupErrdiagnosed.inotifyLimitHint = i18next.t('errors.inotify_limit')}}+ // 补丁层 YAML 语法错误(issue #525):真实原因是用户手写的 `cordis.patch.yml`+ // 解析不了,但失败阶段是「Plugin installation」,很容易被当成插件损坏。这里挂上+ // 「哪个文件、哪一行、怎么改」的提示(错误页据此给出隔离入口)。+ if (containsPatchLayerParseError(diagnosed.message)) {+ diagnosed.patchLayerHint = i18next.t('errors.patch_layer_parse_failed', {+ detail: patchLayerErrorDetail(diagnosed.message),+ })+ }return diagnosed}+/**+ * 把补丁层隔离结果告知用户:成功项逐个提示「原路径 → 备份路径」(改回原名即可+ * 恢复),失败项给出原因。隔离是显式恢复动作,用户必须知道文件被移到了哪里;+ * 没有隔离项时完全不打扰(正常情况下点安全模式不会弹任何提示)。+ */+export function notifyPatchQuarantine(report: PatchQuarantineReport): void {+ for (const layer of report.quarantined) {+ toast(+ i18next.t('patch.quarantined_toast', { backup: layer.backup, original: layer.original }),+ { variant: 'accent', timeout: 10_000 },+ )+ }+ for (const failure of report.failures) {+ toast(+ i18next.t('patch.quarantine_failed_toast', { path: failure.path, error: failure.error }),+ { variant: 'danger', timeout: 0 },+ )+ }+}+export type InternalPluginPhaseTranslate = (key: string,options?: Record<string, number>,diff --git a/src/types/plugin.ts b/src/types/plugin.tsindex fd113e86..211f8577 100644--- a/src/types/plugin.ts+++ b/src/types/plugin.ts@@ -40,3 +40,27 @@ export interface DshPlugin {/** 异常信息(安装/升级/卸载失败或页面运行期上报);undefined = 正常 */error?: PluginErrorInfo | null}++/** Rust 侧 service::plugin::patch_guard::QuarantinedPatchLayer 的序列化形态 */+export interface QuarantinedPatchLayer {+ /** 原始补丁文件路径(`$DSH_HOME/cordis.patch.yml` 或档案层的同名文件) */+ original: string+ /** 备份路径(`<原名>.broken-<UTC 时间戳>`):修好语法后改回原名即可恢复 */+ backup: string+ /** 解析错误(serde_yaml 文本,含行列号) */+ error: string+}++/** Rust 侧 service::plugin::patch_guard::PatchQuarantineFailure 的序列化形态 */+export interface PatchQuarantineFailure {+ path: string+ error: string+}++/** Rust 侧 service::plugin::patch_guard::PatchQuarantineReport 的序列化形态 */+export interface PatchQuarantineReport {+ /** 已隔离(改名保存)的补丁层 */+ quarantined: QuarantinedPatchLayer[]+ /** 隔离失败的补丁层(只提示,不阻断其它层) */+ failures: PatchQuarantineFailure[]+}diff --git a/test/patch-layer.test.ts b/test/patch-layer.test.tsnew file mode 100644index 00000000..17f72a1d--- /dev/null+++ b/test/patch-layer.test.ts@@ -0,0 +1,35 @@+import { describe, expect, it } from 'vitest'+import { containsPatchLayerParseError, patchLayerErrorDetail } from '../src/store/modules/harness/patch-layer'++/**+ * issue #525:用户手写的 `cordis.patch.yml` 解析失败时,启动失败信息里的真实+ * 原因被包在「Plugin installation 阶段失败」里,前端必须能识别出来并给出+ * 「哪个文件、哪一行、怎么改」的提示与隔离入口。+ */+const REAL_FAILURE = 'Harness 在Plugin installation阶段失败。最后的就绪状态:'+ + 'INTERNAL_PLUGIN_INSTALL_FAILED: INTERNAL_PLUGIN_PATCH_PARSE_FAILED: '+ + 'C:\\Users\\Administrator\\.dsh\\cordis.patch.yml: '+ + 'mapping values are not allowed in this context at line 15 column 155'++describe('patch layer diagnostics', () => {+ it('recognizes a wrapped patch parse failure', () => {+ expect(containsPatchLayerParseError(REAL_FAILURE)).toBe(true)+ })++ it('ignores unrelated startup failures', () => {+ expect(containsPatchLayerParseError('Harness 在process-boot阶段失败')).toBe(false)+ // 只是提到错误码(例如日志行)但没有 `:` 分隔的细节时不算命中。+ expect(containsPatchLayerParseError('see INTERNAL_PLUGIN_PATCH_PARSE_FAILED for details')).toBe(false)+ })++ it('extracts the file path and YAML error with line and column', () => {+ expect(patchLayerErrorDetail(REAL_FAILURE)).toBe(+ 'C:\\Users\\Administrator\\.dsh\\cordis.patch.yml: '+ + 'mapping values are not allowed in this context at line 15 column 155',+ )+ })++ it('returns an empty detail when the code is absent', () => {+ expect(patchLayerErrorDetail('Harness 在plugin-install阶段失败')).toBe('')+ })+})diff --git a/vitest.config.ts b/vitest.config.tsindex 5dde5382..0eda74e2 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -28,6 +28,8 @@ export default defineConfig({'test/wake-lock.test.ts',// issue #469:收起桌宠必须是销毁窗口(隐藏窗口里的视频仍在播放并持锁)。'test/pet-window-lifecycle.test.ts',+ // issue #525:补丁层 YAML 语法错误的识别与信息提取(纯函数回归)。+ 'test/patch-layer.test.ts',],maxWorkers: 4,testTimeout: 30_000,