moyun-ultimate/switch-mode.ps1
moyun f7a064a9a8 feat: 0.7.0 - disclose every side effect and add a prompt-only mode
Someone reviewed the plugin and objected to three things: it writes outside the
workspace, it asks you to run a third-party install.ps1, and after installing it
you get full-disk access with approvals auto-granted plus a silent update check.

All three are accurate. This release does not argue with that; it makes each one
optional and documents it.

- SECURITY.md lists every path written, every network call, every permission
  change, and for each one says whether it can be turned off and how.
- syncSkills: false - do not copy the 63 skills into \/skills
- cordis.patch.prompt-only.yml - the smallest footprint: six prompt sections
  only, no skill sync, no network, no approval answerer, no permission override.
- switch-mode.ps1 gains a third mode: full / complement / prompt-only
- install.ps1 -Mode prompt-only installs in that shape in one step

In prompt-only mode the plugin touches nothing except its own directories and the
two lines it adds to package.json.
2026-11-17 15:35:27 +08:00

100 lines
4.1 KiB
PowerShell

# 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', 'prompt-only')]
[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 <path>.' }
}
$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'
$poSrc = Join-Path $Here 'cordis.patch.prompt-only.yml'
if (-not (Test-Path $compSrc)) { throw "missing $compSrc (upgrade to 0.5.0+)" }
if (-not (Test-Path $fullSrc)) { throw "missing $fullSrc" }
if (-not (Test-Path $poSrc)) { throw "missing $poSrc (upgrade to 0.7.0+)" }
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 'prompt-only') {
if ($DryRun) {
Write-Output "would write PROMPT-ONLY patch into $d"
} else {
if ((Test-Path $target) -and -not (Test-Path $fullKeep)) {
Copy-Item $target $fullKeep -Force
Write-Output " kept full copy: $fullKeep"
}
Copy-Item $poSrc $target -Force
Write-Output " PROMPT-ONLY written: $d"
}
} elseif ($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 'prompt-only') {
Write-Output 'PROMPT-ONLY: only the six prompt sections. No skills sync, no network, no permission layer.'
} elseif ($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.'