# 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.'