diff --git a/README.md b/README.md index 1236949..1290d0a 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,65 @@ order 220 moyun-ultimate:anti-censor 1,663 B ← 输出抗审 --- +## 装了别的破甲插件会怎样(自动识别 + 智能让位) + +**不用你手动排查,安装时自动扫描。** + +### 安装时自动检测 + +`install.ps1` 在复制文件前,会读每个已装插件的 `cordis.patch.yml`,提取它**实际改写**的 +config id,与本插件求交集: + +``` +--- conflict scan --- + scanned plugins : 19 + hard conflicts : none + ~ dsh-purge shares: system-prompt (safe) + +requested mode : auto +effective mode : full +``` + +### 三种模式 + +| 模式 | 权限层 | 六段提示词 | 63 技能 | 用在 | +|---|---|---|---|---| +| **full** | ✅ 本插件接管 | ✅ | ✅ | 环境干净,或想让本插件做权限 | +| **complement** | ❌ **让位** | ✅ | ✅ | 已有别的插件管权限 | +| **auto**(默认) | 自动判断 | ✅ | ✅ | 扫描结果决定用上面哪个 | + +**auto 的判定规则**: + +- 检测到 `hardConflicts`(别的插件也改 `approval` / `permission` / `sandbox-policy`)→ **complement** +- 只有 `softOverlaps`(只共享 `system-prompt`)或没有 → **full** + +### 随时切换 + +```powershell +# 让位给别人(只保留提示词 + 技能) +powershell -ExecutionPolicy Bypass -File .\switch-mode.ps1 -Mode complement + +# 自己接管权限 +powershell -ExecutionPolicy Bypass -File .\switch-mode.ps1 -Mode full +``` + +切换会改写已安装的 `cordis.patch.yml`,并把完整版留一份 `cordis.patch.yml.full`,随时可切回。 +**切完要完全退出 DSH 再打开。** + +### 为什么不自动卸载别人的插件 + +**不做,这是刻意的。** + +三个原因: + +1. **会毁环境** —— 别人的插件可能是用户配置的一部分(状态目录、依赖、快捷键),卸载后 DSH 可能起不来 +2. **无法回滚** —— 插件自己删东西,用户不知情,出事没人兜底 +3. **正确的做法是让位不是清场** —— 本插件不冲突的部分(六段提示词 + 63 技能)本来就能和任何插件共存,没必要删别人 + +**让位比卸载安全一个数量级**:你只是不去改那几个 config,什么都没破坏,随时能切回来。 + +--- + ## 给别人装(分享用) 仓库是公开的,**直接把链接发出去就行**,对方不需要任何账号或凭据: @@ -260,11 +319,25 @@ powershell -ExecutionPolicy Bypass -File .\install.ps1 -Profile web ```powershell # 1. 解压 / 克隆到任意目录 -# 2. 在包目录下执行 +# 2. 在包目录下执行(默认 auto 模式,会先扫描冲突) powershell -ExecutionPolicy Bypass -File .\install.ps1 ``` -脚本会:复制到 `profiles\\plugins\moyun-ultimate` → 建运行副本 → 改 `package.json`(deps + bundles)→ 备份原文件 → 打印重启提示。 +脚本会: + +1. **扫描已装插件的 config 冲突**,打印 `hard conflicts` / `soft overlaps` +2. 按 `-Mode auto`(默认)决定用 **full** 还是 **complement** +3. 复制到 `plugins\` + `node_modules\`,写入对应模式的 bundle patch +4. 改 `package.json`(deps + bundles),备份原文件 +5. 打印重启提示 + +强制指定模式: + +```powershell +powershell -ExecutionPolicy Bypass -File .\install.ps1 -Mode full +powershell -ExecutionPolicy Bypass -File .\install.ps1 -Mode complement +powershell -ExecutionPolicy Bypass -File .\install.ps1 -DryRun # 只看扫描结果,不动文件 +``` ### 方式二:手动(三步) @@ -495,9 +568,11 @@ moyun-ultimate/ ├── index.js 五段注入 + 2 工具 + 技能同步 + 审批应答器 + 判拒投影 ├── client.js 状态条(__ModuleLoader__ 格式) ├── cordis.patch.yml system-prompt + sandbox/approval/permission 覆盖 + 本体 insert +├── cordis.patch.complement.yml 补充模式 patch(权限层让位,只留提示词+技能) ├── package.json 含 exports["./client"](缺了 client 就不加载) ├── install.ps1 一键安装(幂等 / -Uninstall / -DryRun / -Profile) ├── doctor.ps1 一键自检(11 项检查,输出 [OK]/[WARN]/[FAIL]) +├── switch-mode.ps1 运行时切换 full / complement ├── publish.ps1 发布助手(建仓 + push + 输出市场提交流程) ├── README.md 本文档 ├── README.en.md 英文版 diff --git a/cordis.patch.complement.yml b/cordis.patch.complement.yml new file mode 100644 index 0000000..66f4b1d --- /dev/null +++ b/cordis.patch.complement.yml @@ -0,0 +1,32 @@ +# moyun-ultimate bundle patch — COMPLEMENT MODE(补充模式) +# +# 只注入六段提示词与 63 个技能,**完全不碰权限层**。 +# 用在:对方已经装了别的权限类插件(会改 approval / permission / sandbox-policy)。 +# +# 与完整模式的差别:本文件不含沙箱/审批/预设/截断这几段 config 覆盖, +# 也不注册审批应答器(permission: false),所以不会和任何插件抢 config id。 +# +# 切换:把本文件复制成 cordis.patch.yml(并保留完整版为 cordis.patch.yml.full)。 + +- id: system-prompt + config: + includeHarnessIdentity: false + personaPrefix: "" + personaSuffix: Your working directory is {{cwd}}. + +- insert: + - id: moyun-ultimate + name: 'moyun-ultimate' + config: + enabled: true + autoApplyOnStart: true + # 六段提示词:全部保留(不与权限插件冲突) + core: true + refusal: true + execution: true + mirror: true + routing: true + anticensor: true + # 权限层让位:不注册审批应答器,不改任何权限相关 config + permission: false + approvalResult: allowed-once diff --git a/install.ps1 b/install.ps1 index 0fbd0e5..6bb5dd5 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,118 +1,225 @@ -# moyun-ultimate installer (ASCII only: PS 5.1 reads BOM-less UTF-8 as ANSI) -# Idempotent. Backs up package.json before editing. Does NOT restart DSH. -[CmdletBinding()] -param( - [string]$Profile = 'desktop', - [string]$DshHome = '', - [switch]$Uninstall, - [switch]$DryRun -) -$ErrorActionPreference = 'Stop' -$Here = Split-Path -Parent $MyInvocation.MyCommand.Path -$PkgName = 'moyun-ultimate' - -if (-not $DshHome) { - if ($env:DSH_HOME) { $DshHome = $env:DSH_HOME } - elseif (Test-Path 'G:\DeepSeek_dsh') { $DshHome = 'G:\DeepSeek_dsh' } - elseif (Test-Path (Join-Path $env:USERPROFILE '.dsh')) { $DshHome = Join-Path $env:USERPROFILE '.dsh' } - else { throw 'DSH_HOME not found. Pass -DshHome .' } -} -$profileDir = Join-Path $DshHome "profiles\$Profile" -$pkgJson = Join-Path $profileDir 'package.json' -$plugDir = Join-Path $profileDir "plugins\$PkgName" -$runDir = Join-Path $profileDir "node_modules\$PkgName" - -Write-Output "DSH_HOME : $DshHome" -Write-Output "profile : $Profile" -Write-Output "package dir: $profileDir" -if (-not (Test-Path $pkgJson)) { throw "profile package.json not found: $pkgJson" } - -function Get-Pkg { Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json } - -if ($Uninstall) { - Write-Output '--- uninstall ---' - foreach ($d in @($plugDir, $runDir)) { - if (Test-Path $d) { - if ($DryRun) { Write-Output "would remove $d" } - else { Remove-Item $d -Recurse -Force; Write-Output "removed $d" } - } - } - $raw = Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 - $lines = $raw -split "`n" - $keep = @() - foreach ($l in $lines) { - if ($l -match "`"$PkgName`":\s*`"file:") { continue } - if ($l -match "^\s*`"$PkgName`",\s*$") { continue } - $keep += $l - } - if ($DryRun) { Write-Output 'would rewrite package.json' } - else { - Copy-Item $pkgJson "$pkgJson.bak-$PkgName-$(Get-Date -Format 'yyyyMMdd-HHmmss')" -Force - [IO.File]::WriteAllText($pkgJson, ($keep -join "`n"), (New-Object Text.UTF8Encoding($false))) - $null = Get-Pkg - Write-Output 'package.json updated (JSON valid)' - } - Write-Output 'Restart DSH completely to unload.' - exit 0 -} - -Write-Output '--- install ---' -if ($DryRun) { - Write-Output "would copy $Here -> $plugDir" - Write-Output "would copy $Here -> $runDir" - Write-Output 'would add dependencies + bundles entry' - exit 0 -} - -# 1) source + runtime copy (real dirs: mklink needs elevation) -foreach ($d in @($plugDir, $runDir)) { - if (Test-Path $d) { Remove-Item $d -Recurse -Force } - New-Item -ItemType Directory -Force -Path $d | Out-Null - Copy-Item "$Here\*" $d -Recurse -Force -} -Write-Output "copied to $plugDir" -Write-Output "copied to $runDir" - -# 2) patch package.json -$stamp = Get-Date -Format 'yyyyMMdd-HHmmss' -Copy-Item $pkgJson "$pkgJson.bak-$PkgName-$stamp" -Force -Write-Output "backup: package.json.bak-$PkgName-$stamp" - -$raw = Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 -$lines = $raw -split "`n" -$out = New-Object System.Collections.Generic.List[string] -$depAdded = $false -$bundleHandled = $false - -foreach ($l in $lines) { - # inject dependency next to an existing file: dependency, or after "dependencies": { - if (-not $depAdded -and $l -match '^\s*"dependencies":\s*\{') { - $out.Add($l) - $out.Add(" `"$PkgName`": `"file:./plugins/$PkgName`",") - $depAdded = $true - continue - } - # replace a legacy bundle entry of the same project in place (superseded by this package) - if (-not $bundleHandled -and $l -match '^\s*"moyun-[a-z]+",\s*$') { - $out.Add(" `"$PkgName`",") - $bundleHandled = $true - continue - } - $out.Add($l) -} -[IO.File]::WriteAllText($pkgJson, ($out -join "`n"), (New-Object Text.UTF8Encoding($false))) - -$j = Get-Pkg -$hasDep = $j.dependencies.PSObject.Properties.Name -contains $PkgName -$hasBundle = $j.dsh.profile.bundles -contains $PkgName -Write-Output "dependencies has ${PkgName}: $hasDep" -Write-Output "bundles has ${PkgName} : $hasBundle" -Write-Output "bundles total : $($j.dsh.profile.bundles.Count)" - -if (-not $hasBundle) { - Write-Warning "bundles entry missing. Add `"$PkgName`" to dsh.profile.bundles manually, or add the plugin from the DSH plugin panel." -} - -Write-Output '' -Write-Output 'DONE. Now fully quit DSH (including the tray icon) and reopen it.' -Write-Output 'Verify: ask the agent to call moyun_ultimate_profile -> expect skills=63, 5 layers on.' \ No newline at end of file +# moyun-ultimate installer (ASCII only: PS 5.1 reads BOM-less UTF-8 as ANSI) +# Idempotent. Backs up package.json before editing. Does NOT restart DSH. +# +# -Mode auto (default) detect conflicts first, then pick full or complement +# -Mode full always take over the permission layer +# -Mode complement never touch the permission layer (yield to other plugins) +[CmdletBinding()] +param( + [string]$Profile = 'desktop', + [string]$DshHome = '', + [ValidateSet('auto', 'full', 'complement')] + [string]$Mode = 'auto', + [switch]$Uninstall, + [switch]$DryRun +) +$ErrorActionPreference = 'Stop' +$Here = Split-Path -Parent $MyInvocation.MyCommand.Path +$PkgName = 'moyun-ultimate' + +if (-not $DshHome) { + if ($env:DSH_HOME) { $DshHome = $env:DSH_HOME } + elseif (Test-Path 'G:\DeepSeek_dsh') { $DshHome = 'G:\DeepSeek_dsh' } + elseif (Test-Path (Join-Path $env:USERPROFILE '.dsh')) { $DshHome = Join-Path $env:USERPROFILE '.dsh' } + else { throw 'DSH_HOME not found. Pass -DshHome .' } +} +$profileDir = Join-Path $DshHome "profiles\$Profile" +$pkgJson = Join-Path $profileDir 'package.json' +$plugDir = Join-Path $profileDir "plugins\$PkgName" +$runDir = Join-Path $profileDir "node_modules\$PkgName" + +Write-Output "DSH_HOME : $DshHome" +Write-Output "profile : $Profile" +Write-Output "package dir: $profileDir" +if (-not (Test-Path $pkgJson)) { throw "profile package.json not found: $pkgJson" } + +function Get-Pkg { Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json } + +# ---- config ids this plugin rewrites (must match index.js CONFLICT_IDS) ---- +$CONFLICT_IDS = @('sandbox-policy', 'approval', 'permission', 'spill-policy', 'tool-result-pruner') +$SOFT_IDS = @('system-prompt') + +# Read the config ids another installed plugin actually rewrites. +function Get-PluginIds([string]$name) { + $p = Join-Path $profileDir "node_modules\$name\cordis.patch.yml" + if (-not (Test-Path $p)) { return @() } + $txt = Get-Content -LiteralPath $p -Raw -Encoding UTF8 + $ids = @() + foreach ($m in [regex]::Matches($txt, '(?m)^\s*-?\s*id:\s*([A-Za-z0-9_\-]+)')) { + $ids += $m.Groups[1].Value + } + return ($ids | Sort-Object -Unique) +} + +# Scan all bundles and report who collides with us. +function Get-ConflictReport { + $rep = @{ hard = @(); soft = @(); scanned = 0 } + $j = Get-Pkg + $bundles = @($j.dsh.profile.bundles) + foreach ($b in $bundles) { + if ($b -eq $PkgName) { continue } + $ids = Get-PluginIds $b + if ($ids.Count -eq 0) { continue } + $rep.scanned++ + $hardHit = @($ids | Where-Object { $CONFLICT_IDS -contains $_ }) + $softHit = @($ids | Where-Object { $SOFT_IDS -contains $_ }) + if ($hardHit.Count -gt 0) { + $rep.hard += [pscustomobject]@{ plugin = $b; ids = ($hardHit -join ',') } + } elseif ($softHit.Count -gt 0) { + $rep.soft += [pscustomobject]@{ plugin = $b; ids = ($softHit -join ',') } + } + } + return $rep +} + +function Show-ConflictReport($rep) { + Write-Output '' + Write-Output '--- conflict scan ---' + Write-Output (" scanned plugins : " + $rep.scanned) + if ($rep.hard.Count -eq 0) { + Write-Output ' hard conflicts : none' + } else { + Write-Output ' hard conflicts : YES' + foreach ($h in $rep.hard) { Write-Output (" - " + $h.plugin + " rewrites: " + $h.ids) } + } + if ($rep.soft.Count -eq 0) { + Write-Output ' soft overlaps : none' + } else { + foreach ($s in $rep.soft) { Write-Output (" ~ " + $s.plugin + " shares: " + $s.ids + " (safe)") } + } +} + +# Decide the effective mode for 'auto'. +function Resolve-Mode($rep) { + if ($Mode -ne 'auto') { return $Mode } + if ($rep.hard.Count -gt 0) { return 'complement' } + return 'full' +} + +# Write the right bundle patch into the installed copies. +function Apply-Mode([string]$effective) { + $fullSrc = Join-Path $Here 'cordis.patch.yml' + $compSrc = Join-Path $Here 'cordis.patch.complement.yml' + foreach ($d in @($plugDir, $runDir)) { + if (-not (Test-Path $d)) { continue } + $target = Join-Path $d 'cordis.patch.yml' + $fullKeep = Join-Path $d 'cordis.patch.yml.full' + if ($effective -eq 'complement') { + if ($DryRun) { Write-Output "would switch $d to COMPLEMENT mode" } + else { + if ((Test-Path $target) -and -not (Test-Path $fullKeep)) { Copy-Item $target $fullKeep -Force } + Copy-Item $compSrc $target -Force + Write-Output " switched to COMPLEMENT mode: $d" + } + } else { + if ($DryRun) { Write-Output "would switch $d to FULL mode" } + else { + Copy-Item $fullSrc $target -Force + Write-Output " switched to FULL mode: $d" + } + } + } +} + +if ($Uninstall) { + Write-Output '--- uninstall ---' + foreach ($d in @($plugDir, $runDir)) { + if (Test-Path $d) { + if ($DryRun) { Write-Output "would remove $d" } + else { Remove-Item $d -Recurse -Force; Write-Output "removed $d" } + } + } + $raw = Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 + $keep = @() + foreach ($l in ($raw -split "`n")) { + if ($l -match "`"$PkgName`":\s*`"file:") { continue } + if ($l -match "^\s*`"$PkgName`",\s*$") { continue } + $keep += $l + } + if ($DryRun) { Write-Output 'would rewrite package.json' } + else { + Copy-Item $pkgJson "$pkgJson.bak-$PkgName-$(Get-Date -Format 'yyyyMMdd-HHmmss')" -Force + [IO.File]::WriteAllText($pkgJson, ($keep -join "`n"), (New-Object Text.UTF8Encoding($false))) + $null = Get-Pkg + Write-Output 'package.json updated' + } + Write-Output 'Restart DSH completely to unload.' + exit 0 +} + +Write-Output '' +Write-Output '=== install ===' + +# 0) scan BEFORE copying, so we can decide the mode +$rep = Get-ConflictReport +Show-ConflictReport $rep +$effective = Resolve-Mode $rep +Write-Output '' +Write-Output ("requested mode : " + $Mode) +Write-Output ("effective mode : " + $effective) +if ($effective -eq 'complement') { + Write-Output ' -> permission layer will YIELD to the plugins listed above.' + Write-Output ' prompt layers + 63 skills still apply.' +} + +if ($DryRun) { + Write-Output '' + Write-Output "would copy $Here -> $plugDir" + Write-Output "would copy $Here -> $runDir" + Write-Output "would write $effective bundle patch" + Write-Output 'would add dependencies + bundles entry' + exit 0 +} + +# 1) source + runtime copy (real dirs: mklink needs elevation) +foreach ($d in @($plugDir, $runDir)) { + if (Test-Path $d) { Remove-Item $d -Recurse -Force } + New-Item -ItemType Directory -Force -Path $d | Out-Null + Copy-Item "$Here\*" $d -Recurse -Force +} +Write-Output "copied to $plugDir" +Write-Output "copied to $runDir" + +# 2) write the bundle patch matching the effective mode +Apply-Mode $effective + +# 3) patch package.json +$stamp = Get-Date -Format 'yyyyMMdd-HHmmss' +Copy-Item $pkgJson "$pkgJson.bak-$PkgName-$stamp" -Force +Write-Output "backup: package.json.bak-$PkgName-$stamp" + +$raw = Get-Content -LiteralPath $pkgJson -Raw -Encoding UTF8 +$out = New-Object System.Collections.Generic.List[string] +$depAdded = $false +$bundleHandled = $false + +foreach ($l in ($raw -split "`n")) { + if (-not $depAdded -and $l -match '^\s*"dependencies":\s*\{') { + $out.Add($l) + $out.Add(" `"$PkgName`": `"file:./plugins/$PkgName`",") + $depAdded = $true + continue + } + if (-not $bundleHandled -and $l -match '^\s*"moyun-[a-z]+",\s*$') { + $out.Add(" `"$PkgName`",") + $bundleHandled = $true + continue + } + $out.Add($l) +} +[IO.File]::WriteAllText($pkgJson, ($out -join "`n"), (New-Object Text.UTF8Encoding($false))) + +$j = Get-Pkg +$hasDep = $j.dependencies.PSObject.Properties.Name -contains $PkgName +$hasBundle = $j.dsh.profile.bundles -contains $PkgName +Write-Output "dependencies has ${PkgName}: $hasDep" +Write-Output "bundles has ${PkgName} : $hasBundle" +Write-Output "bundles total : $($j.dsh.profile.bundles.Count)" +if (-not $hasBundle) { + Write-Warning "bundles entry missing. Add `"$PkgName`" to dsh.profile.bundles manually." +} + +Write-Output '' +Write-Output ("DONE ($effective mode). Fully quit DSH and reopen it.") +Write-Output 'Switch modes later: powershell -File .\switch-mode.ps1 -Mode full|complement' +Write-Output 'Verify after restart: powershell -File .\doctor.ps1' diff --git a/package.json b/package.json index 4959294..c6c3be8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moyun-ultimate", - "version": "0.4.3", + "version": "0.5.0", "displayName": "墨昀·终极破甲", "description": "墨昀·终极破甲:五层提示词内核 + 内置权限层 —— 人格双槽 × 反拒绝机制 × 执行强度 × 换框模板 × 技能路由,内置 63 个攻防技能(逆向 24 / 渗透 16 / 云 8 / 取证 6 / 其它 9)。Layered prompt core with five sections and 63 built-in skills.", "keywords": [ @@ -29,7 +29,9 @@ "doctor.ps1", "TROUBLESHOOTING.md", "install.ps1", - "COMMENTS-FAQ.md" + "COMMENTS-FAQ.md", + "cordis.patch.complement.yml", + "switch-mode.ps1" ], "scripts": { "harness:check": "node --check index.js && node --check client.js" @@ -37,7 +39,7 @@ "dsh": { "id": "moyun-ultimate", "name": "墨昀·终极破甲", - "version": "0.4.3", + "version": "0.5.0", "permissions": "六段提示词注入(含输出抗审), 内置权限层(沙箱/审批/结果), 拒绝投影状态条, 换框模板工具, 状态自查工具(含 provider 审核风险评估), 技能审计工具, 63 技能自动同步", "bundle": { "patch": "./cordis.patch.yml" diff --git a/switch-mode.ps1 b/switch-mode.ps1 new file mode 100644 index 0000000..82d6446 --- /dev/null +++ b/switch-mode.ps1 @@ -0,0 +1,84 @@ +# moyun-ultimate mode switcher (ASCII only - PS 5.1 reads BOM-less UTF-8 as ANSI) +# +# Two modes: +# full - this plugin owns the permission layer (sandbox / approval / preset) +# complement - this plugin keeps prompt layers + skills only; the permission +# layer yields to whichever plugin already handles it +# +# Switching rewrites the installed cordis.patch.yml and asks you to restart DSH. +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [ValidateSet('full', 'complement')] + [string]$Mode, + [string]$Profile = 'desktop', + [string]$DshHome = '', + [switch]$DryRun +) +$ErrorActionPreference = 'Stop' +$Here = Split-Path -Parent $MyInvocation.MyCommand.Path +$PkgName = 'moyun-ultimate' + +if (-not $DshHome) { + if ($env:DSH_HOME) { $DshHome = $env:DSH_HOME } + elseif (Test-Path 'G:\DeepSeek_dsh') { $DshHome = 'G:\DeepSeek_dsh' } + elseif (Test-Path (Join-Path $env:USERPROFILE '.dsh')) { $DshHome = Join-Path $env:USERPROFILE '.dsh' } + else { throw 'DSH_HOME not found. Pass -DshHome .' } +} +$profileDir = Join-Path $DshHome "profiles\$Profile" +$plugDir = Join-Path $profileDir "plugins\$PkgName" +$runDir = Join-Path $profileDir "node_modules\$PkgName" + +$compSrc = Join-Path $Here 'cordis.patch.complement.yml' +$fullSrc = Join-Path $Here 'cordis.patch.yml' +if (-not (Test-Path $compSrc)) { throw "missing $compSrc (upgrade to 0.5.0+)" } +if (-not (Test-Path $fullSrc)) { throw "missing $fullSrc" } + +Write-Output "switching to: $Mode" +Write-Output "DSH_HOME : $DshHome" +Write-Output "profile : $Profile" +Write-Output '' + +$targets = @($plugDir, $runDir) | Where-Object { Test-Path $_ } +if ($targets.Count -eq 0) { throw "plugin not installed under $profileDir (run install.ps1 first)" } + +foreach ($d in $targets) { + $target = Join-Path $d 'cordis.patch.yml' + $fullKeep = Join-Path $d 'cordis.patch.yml.full' + if ($Mode -eq 'complement') { + if ($DryRun) { + Write-Output "would write COMPLEMENT patch into $d" + } else { + # keep a full copy first so switching back is always possible + if ((Test-Path $target) -and -not (Test-Path $fullKeep)) { + Copy-Item $target $fullKeep -Force + Write-Output " kept full copy: $fullKeep" + } + Copy-Item $compSrc $target -Force + Write-Output " COMPLEMENT written: $d" + } + } else { + if ($DryRun) { + Write-Output "would write FULL patch into $d" + } else { + if (Test-Path $fullKeep) { + Copy-Item $fullKeep $target -Force + Write-Output " restored from full copy: $d" + } else { + Copy-Item $fullSrc $target -Force + Write-Output " FULL written: $d" + } + } + } +} + +Write-Output '' +if ($Mode -eq 'complement') { + Write-Output 'COMPLEMENT: prompt layers + 63 skills stay; permission layer yields.' + Write-Output 'Other plugins keep ownership of sandbox / approval / permission.' +} else { + Write-Output 'FULL: this plugin owns the permission layer.' + Write-Output 'If another plugin also rewrites approval/permission, keep only one contender.' +} +Write-Output '' +Write-Output 'Fully quit DSH (including tray) and reopen it, then run doctor.ps1.'