Answers the issues raised in the comments: 1. "keeps triggering safety refusal" -> README now separates three layers: host permission (this package fixes it), model willingness (prompt layer), provider-side moderation (nothing can fix it). TROUBLESHOOTING gives a decision tree with commands. 2. "how do I verify it worked" -> doctor.ps1 checks 11 items and prints [OK]/[WARN]/[FAIL]. Verified locally: OK=11 WARN=2 FAIL=0. 3. "does it conflict with purge" -> documented: both target the same config ids, last-applied wins. doctor warns when a user-layer override or a conflicting plugin is detected. 4. "incomplete / missing stuff" -> documented that the 63 skills need their external binaries (nuclei/fscan/IDA/jadx...), which the package does not ship. 5. "stronger armor makes the model dumber" -> confirmed in README as a real trade-off with per-layer guidance on what to turn off.
212 lines
7.7 KiB
PowerShell
212 lines
7.7 KiB
PowerShell
# moyun-ultimate doctor: checks install state and prints [OK]/[WARN]/[FAIL]
|
|
# ASCII only (PS 5.1 reads BOM-less UTF-8 as ANSI).
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$Profile = 'desktop',
|
|
[string]$DshHome = ''
|
|
)
|
|
$ErrorActionPreference = 'Continue'
|
|
$PkgName = 'moyun-ultimate'
|
|
$ok = 0; $warn = 0; $fail = 0
|
|
|
|
function Say($tag, $msg) {
|
|
switch ($tag) {
|
|
'OK' { Write-Host "[OK] $msg" -ForegroundColor Green; $script:ok++ }
|
|
'WARN' { Write-Host "[WARN] $msg" -ForegroundColor Yellow; $script:warn++ }
|
|
'FAIL' { Write-Host "[FAIL] $msg" -ForegroundColor Red; $script:fail++ }
|
|
'INFO' { Write-Host " $msg" -ForegroundColor Gray }
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "moyun-ultimate doctor" -ForegroundColor Cyan
|
|
Write-Host "=====================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# --- resolve DSH_HOME ---
|
|
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' }
|
|
}
|
|
if (-not $DshHome -or -not (Test-Path $DshHome)) {
|
|
Say FAIL "DSH_HOME not found. Pass -DshHome <path>."
|
|
exit 1
|
|
}
|
|
Say INFO "DSH_HOME = $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"
|
|
$profPatch = Join-Path $profileDir 'cordis.patch.yml'
|
|
|
|
if (-not (Test-Path $profileDir)) {
|
|
Say FAIL "profile dir not found: $profileDir"
|
|
exit 1
|
|
}
|
|
Say INFO "profile = $Profile"
|
|
Write-Host ""
|
|
|
|
# --- 1. runtime copy ---
|
|
if (Test-Path $runDir) {
|
|
$n = (Get-ChildItem $runDir -Recurse -File).Count
|
|
Say OK "runtime copy present: node_modules\$PkgName ($n files)"
|
|
} else {
|
|
Say FAIL "runtime copy MISSING: $runDir -> run install.ps1"
|
|
}
|
|
|
|
# --- 2. source copy ---
|
|
if (Test-Path $plugDir) {
|
|
$n = (Get-ChildItem $plugDir -Recurse -File).Count
|
|
Say OK "source copy present: plugins\$PkgName ($n files)"
|
|
} else {
|
|
Say WARN "source copy missing: plugins\$PkgName (runtime still works)"
|
|
}
|
|
|
|
# --- 3/4. package.json registration ---
|
|
if (Test-Path $pkgJson) {
|
|
try {
|
|
$j = Get-Content $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
$hasDep = $j.dependencies.PSObject.Properties.Name -contains $PkgName
|
|
$hasBundle = $j.dsh.profile.bundles -contains $PkgName
|
|
if ($hasDep) { Say OK "dependencies has $PkgName" } else { Say FAIL "dependencies MISSING $PkgName" }
|
|
if ($hasBundle){ Say OK "bundles has $PkgName" } else { Say FAIL "bundles MISSING $PkgName" }
|
|
Say INFO "bundles total = $($j.dsh.profile.bundles.Count)"
|
|
} catch {
|
|
Say FAIL "package.json parse error: $($_.Exception.Message)"
|
|
}
|
|
} else {
|
|
Say FAIL "package.json not found: $pkgJson"
|
|
}
|
|
|
|
# --- 5. exports["./client"] ---
|
|
$runPkg = Join-Path $runDir 'package.json'
|
|
if (Test-Path $runPkg) {
|
|
try {
|
|
$rj = Get-Content $runPkg -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
if ($rj.exports.'./client') {
|
|
Say OK "exports has './client' -> $($rj.exports.'./client')"
|
|
} else {
|
|
Say FAIL "exports MISSING './client' (status badge will not load)"
|
|
}
|
|
Say INFO "installed version = $($rj.version)"
|
|
} catch {
|
|
Say FAIL "runtime package.json parse error"
|
|
}
|
|
}
|
|
|
|
# --- 6. prompt files ---
|
|
$promptFiles = @(
|
|
'ultimatum-mode.md', '10-refusal-kernel.md', '20-execution.md',
|
|
'ultimatum-mode-mirror.md', '40-routing.md'
|
|
)
|
|
if (Test-Path $runDir) {
|
|
$missing = @()
|
|
foreach ($f in $promptFiles) {
|
|
if (-not (Test-Path (Join-Path $runDir "prompts\$f"))) { $missing += $f }
|
|
}
|
|
if ($missing.Count -eq 0) {
|
|
Say OK "five prompt layers present (5/5)"
|
|
} else {
|
|
Say FAIL "prompt files missing: $($missing -join ', ')"
|
|
}
|
|
# frames
|
|
$frameDir = Join-Path $runDir 'prompts\frames'
|
|
if (Test-Path $frameDir) {
|
|
$fc = (Get-ChildItem $frameDir -File).Count
|
|
Say OK "frames present ($fc files)"
|
|
} else {
|
|
Say WARN "frames dir missing (moyun_frame will return fewer templates)"
|
|
}
|
|
}
|
|
|
|
# --- 7. permission layer config ---
|
|
$ownPatch = Join-Path $runDir 'cordis.patch.yml'
|
|
if (Test-Path $ownPatch) {
|
|
$pt = Get-Content $ownPatch -Raw -Encoding UTF8
|
|
$hasSandbox = $pt -match 'id:\s*sandbox-policy'
|
|
$hasApproval = $pt -match 'id:\s*approval'
|
|
$hasPerm = $pt -match 'id:\s*permission'
|
|
if ($hasSandbox -and $hasApproval -and $hasPerm) {
|
|
Say OK "permission layer config present (sandbox-policy / approval / permission)"
|
|
} else {
|
|
Say WARN "permission layer config incomplete (sandbox=$hasSandbox approval=$hasApproval permission=$hasPerm)"
|
|
Say INFO " -> this build predates 0.2.0; upgrade for built-in permission layer"
|
|
}
|
|
if ($pt -match 'danger-full-access') { Say OK "sandbox mode is danger-full-access" }
|
|
} else {
|
|
Say FAIL "cordis.patch.yml missing in runtime copy"
|
|
}
|
|
|
|
# --- 8. approval answerer in index.js ---
|
|
$idx = Join-Path $runDir 'index.js'
|
|
if (Test-Path $idx) {
|
|
$it = Get-Content $idx -Raw -Encoding UTF8
|
|
if ($it -match 'installApprovalAnswerer') { Say OK "approval answerer code present" }
|
|
else { Say WARN "approval answerer code NOT found (0.1.x build?)" }
|
|
}
|
|
|
|
# --- 9. skills landed ---
|
|
$skillsDir = Join-Path $DshHome 'skills'
|
|
if (Test-Path $skillsDir) {
|
|
$sn = (Get-ChildItem $skillsDir -Directory).Count
|
|
Say INFO "skills in DSH_HOME\skills = $sn"
|
|
$srcSkills = Join-Path $runDir 'skills'
|
|
if (Test-Path $srcSkills) {
|
|
$want = (Get-ChildItem $srcSkills -Directory).Count
|
|
if ($sn -ge $want) { Say OK "skills synced ($sn >= $want)" }
|
|
else { Say WARN "skills not fully synced ($sn of $want) -> restart DSH to trigger sync" }
|
|
}
|
|
} else {
|
|
Say WARN "DSH_HOME\skills not found"
|
|
}
|
|
|
|
# --- 10. user-layer override check ---
|
|
if (Test-Path $profPatch) {
|
|
$ut = Get-Content $profPatch -Raw -Encoding UTF8
|
|
$ovr = @()
|
|
foreach ($id in 'sandbox-policy', 'approval', 'permission') {
|
|
if ($ut -match ("-\s*id:\s*" + [regex]::Escape($id))) { $ovr += $id }
|
|
}
|
|
if ($ovr.Count -gt 0) {
|
|
Say WARN "user-layer profile/cordis.patch.yml overrides: $($ovr -join ', ')"
|
|
Say INFO " -> user layer applies AFTER bundle layer, so it wins. Either delete those"
|
|
Say INFO " blocks there, or set permission: false in this plugin's config."
|
|
} else {
|
|
Say OK "no user-layer override of permission ids"
|
|
}
|
|
} else {
|
|
Say INFO "no user-layer cordis.patch.yml (bundle layer wins by default)"
|
|
}
|
|
|
|
# --- 11. conflicting plugins ---
|
|
if (Test-Path $pkgJson) {
|
|
try {
|
|
$j = Get-Content $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
$others = $j.dsh.profile.bundles | Where-Object { $_ -ne $PkgName -and ($_ -match 'purge|ungate|po$|jailbreak|armor|unrestrict') }
|
|
if ($others) {
|
|
Say WARN "other jailbreak-ish plugins in bundles: $($others -join ', ')"
|
|
Say INFO " -> if they also override approval/permission, only one wins (last applied)"
|
|
} else {
|
|
Say OK "no conflicting jailbreak plugin in bundles"
|
|
}
|
|
} catch {}
|
|
}
|
|
|
|
# --- summary ---
|
|
Write-Host ""
|
|
Write-Host "=====================" -ForegroundColor Cyan
|
|
Write-Host ("RESULT: OK={0} WARN={1} FAIL={2}" -f $ok, $warn, $fail) -ForegroundColor Cyan
|
|
Write-Host ""
|
|
if ($fail -gt 0) {
|
|
Write-Host "ACTION: fix the [FAIL] items above, then fully quit DSH and reopen." -ForegroundColor Red
|
|
exit 2
|
|
} elseif ($warn -gt 0) {
|
|
Write-Host "ACTION: review [WARN] items. Plugin should still work." -ForegroundColor Yellow
|
|
exit 1
|
|
} else {
|
|
Write-Host "All good. Ask the agent to call moyun_ultimate_profile to confirm." -ForegroundColor Green
|
|
exit 0
|
|
}
|