feat: 0.5.1 - two escape hatches and self-repair
The goal is users who dare to install it. Three additions: 1. doctor.ps1 -Fix Runs the 12 checks, then repairs what is safe to repair: re-copy the runtime copy, add exports["./client"], add the dependencies entry, sync missing skills. It deliberately does NOT touch the profile's own cordis.patch.yml (that could break other plugins) - it only prints a hint. 2. install.ps1 -Rollback Restores package.json from the newest package.json.bak-* and removes the plugin directories. One command back to the pre-install state. 3. Friendly install ending Prints the three next steps (quit/reopen, doctor, moyun_ultimate_profile) plus the two escape commands, instead of a single terse line. doctor also detects and reports whether the install is in FULL or COMPLEMENT mode by reading the bundle patch, so complement mode is no longer misreported.
This commit is contained in:
parent
af44f4b3c9
commit
d18db479b7
24
README.md
24
README.md
@ -339,6 +339,27 @@ powershell -ExecutionPolicy Bypass -File .\install.ps1 -Mode complement
|
|||||||
powershell -ExecutionPolicy Bypass -File .\install.ps1 -DryRun # 只看扫描结果,不动文件
|
powershell -ExecutionPolicy Bypass -File .\install.ps1 -DryRun # 只看扫描结果,不动文件
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 装错了怎么办(两条退路)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 退路 1:让位给别人,不卸载(最温和)
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\switch-mode.ps1 -Mode complement
|
||||||
|
|
||||||
|
# 退路 2:整体回滚到安装前(从 package.json.bak-* 恢复 + 删插件目录)
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Rollback
|
||||||
|
```
|
||||||
|
|
||||||
|
### 出问题能自愈
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\doctor.ps1 -Fix
|
||||||
|
```
|
||||||
|
|
||||||
|
`-Fix` 会自动修它**能安全修**的:重拷运行副本、补 `exports["./client"]`、
|
||||||
|
补 dependencies 登记、同步缺失的技能目录。
|
||||||
|
|
||||||
|
**不改的**:profile 用户层的 config(那可能影响别的插件,只给提示不动手)。
|
||||||
|
|
||||||
### 方式二:手动(三步)
|
### 方式二:手动(三步)
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
@ -373,7 +394,8 @@ npm install moyun-ultimate # 发布后可用
|
|||||||
### 一键自检(推荐先跑这个)
|
### 一键自检(推荐先跑这个)
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
powershell -ExecutionPolicy Bypass -File .\doctor.ps1
|
powershell -ExecutionPolicy Bypass -File .\doctor.ps1 # 只检查
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\doctor.ps1 -Fix # 检查 + 自动修复能修的
|
||||||
```
|
```
|
||||||
|
|
||||||
逐项检查 11 个点,输出 `[OK]` / `[WARN]` / `[FAIL]`。本机实测输出:
|
逐项检查 11 个点,输出 `[OK]` / `[WARN]` / `[FAIL]`。本机实测输出:
|
||||||
|
|||||||
178
doctor.ps1
178
doctor.ps1
@ -1,19 +1,22 @@
|
|||||||
# moyun-ultimate doctor: checks install state and prints [OK]/[WARN]/[FAIL]
|
# moyun-ultimate doctor: checks install state, and with -Fix repairs what it can
|
||||||
# ASCII only (PS 5.1 reads BOM-less UTF-8 as ANSI).
|
# ASCII only (PS 5.1 reads BOM-less UTF-8 as ANSI).
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[string]$Profile = 'desktop',
|
[string]$Profile = 'desktop',
|
||||||
[string]$DshHome = ''
|
[string]$DshHome = '',
|
||||||
|
[switch]$Fix
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = 'Continue'
|
$ErrorActionPreference = 'Continue'
|
||||||
$PkgName = 'moyun-ultimate'
|
$PkgName = 'moyun-ultimate'
|
||||||
$ok = 0; $warn = 0; $fail = 0
|
$ok = 0; $warn = 0; $fail = 0
|
||||||
|
$fixable = New-Object System.Collections.Generic.List[string]
|
||||||
|
|
||||||
function Say($tag, $msg) {
|
function Say($tag, $msg) {
|
||||||
switch ($tag) {
|
switch ($tag) {
|
||||||
'OK' { Write-Host "[OK] $msg" -ForegroundColor Green; $script:ok++ }
|
'OK' { Write-Host "[OK] $msg" -ForegroundColor Green; $script:ok++ }
|
||||||
'WARN' { Write-Host "[WARN] $msg" -ForegroundColor Yellow; $script:warn++ }
|
'WARN' { Write-Host "[WARN] $msg" -ForegroundColor Yellow; $script:warn++ }
|
||||||
'FAIL' { Write-Host "[FAIL] $msg" -ForegroundColor Red; $script:fail++ }
|
'FAIL' { Write-Host "[FAIL] $msg" -ForegroundColor Red; $script:fail++ }
|
||||||
|
'FIX' { Write-Host "[FIX] $msg" -ForegroundColor Cyan }
|
||||||
'INFO' { Write-Host " $msg" -ForegroundColor Gray }
|
'INFO' { Write-Host " $msg" -ForegroundColor Gray }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,6 +49,7 @@ if (-not (Test-Path $profileDir)) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Say INFO "profile = $Profile"
|
Say INFO "profile = $Profile"
|
||||||
|
if ($Fix) { Say INFO "-Fix mode : will repair what it can (backup created first)" }
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# --- 1. runtime copy ---
|
# --- 1. runtime copy ---
|
||||||
@ -53,7 +57,8 @@ if (Test-Path $runDir) {
|
|||||||
$n = (Get-ChildItem $runDir -Recurse -File).Count
|
$n = (Get-ChildItem $runDir -Recurse -File).Count
|
||||||
Say OK "runtime copy present: node_modules\$PkgName ($n files)"
|
Say OK "runtime copy present: node_modules\$PkgName ($n files)"
|
||||||
} else {
|
} else {
|
||||||
Say FAIL "runtime copy MISSING: $runDir -> run install.ps1"
|
Say FAIL "runtime copy MISSING: $runDir"
|
||||||
|
$fixable.Add('copy-runtime')
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 2. source copy ---
|
# --- 2. source copy ---
|
||||||
@ -62,16 +67,19 @@ if (Test-Path $plugDir) {
|
|||||||
Say OK "source copy present: plugins\$PkgName ($n files)"
|
Say OK "source copy present: plugins\$PkgName ($n files)"
|
||||||
} else {
|
} else {
|
||||||
Say WARN "source copy missing: plugins\$PkgName (runtime still works)"
|
Say WARN "source copy missing: plugins\$PkgName (runtime still works)"
|
||||||
|
$fixable.Add('copy-source')
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 3/4. package.json registration ---
|
# --- 3/4. package.json registration ---
|
||||||
|
$hasDep = $false
|
||||||
|
$hasBundle = $false
|
||||||
if (Test-Path $pkgJson) {
|
if (Test-Path $pkgJson) {
|
||||||
try {
|
try {
|
||||||
$j = Get-Content $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json
|
$j = Get-Content $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||||
$hasDep = $j.dependencies.PSObject.Properties.Name -contains $PkgName
|
$hasDep = $j.dependencies.PSObject.Properties.Name -contains $PkgName
|
||||||
$hasBundle = $j.dsh.profile.bundles -contains $PkgName
|
$hasBundle = $j.dsh.profile.bundles -contains $PkgName
|
||||||
if ($hasDep) { Say OK "dependencies has $PkgName" } else { Say FAIL "dependencies MISSING $PkgName" }
|
if ($hasDep) { Say OK "dependencies has $PkgName" } else { Say FAIL "dependencies MISSING $PkgName"; $fixable.Add('dep') }
|
||||||
if ($hasBundle){ Say OK "bundles has $PkgName" } else { Say FAIL "bundles MISSING $PkgName" }
|
if ($hasBundle) { Say OK "bundles has $PkgName" } else { Say FAIL "bundles MISSING $PkgName"; $fixable.Add('bundle') }
|
||||||
Say INFO "bundles total = $($j.dsh.profile.bundles.Count)"
|
Say INFO "bundles total = $($j.dsh.profile.bundles.Count)"
|
||||||
} catch {
|
} catch {
|
||||||
Say FAIL "package.json parse error: $($_.Exception.Message)"
|
Say FAIL "package.json parse error: $($_.Exception.Message)"
|
||||||
@ -89,6 +97,7 @@ if (Test-Path $runPkg) {
|
|||||||
Say OK "exports has './client' -> $($rj.exports.'./client')"
|
Say OK "exports has './client' -> $($rj.exports.'./client')"
|
||||||
} else {
|
} else {
|
||||||
Say FAIL "exports MISSING './client' (status badge will not load)"
|
Say FAIL "exports MISSING './client' (status badge will not load)"
|
||||||
|
$fixable.Add('exports')
|
||||||
}
|
}
|
||||||
Say INFO "installed version = $($rj.version)"
|
Say INFO "installed version = $($rj.version)"
|
||||||
} catch {
|
} catch {
|
||||||
@ -99,7 +108,7 @@ if (Test-Path $runPkg) {
|
|||||||
# --- 6. prompt files ---
|
# --- 6. prompt files ---
|
||||||
$promptFiles = @(
|
$promptFiles = @(
|
||||||
'ultimatum-mode.md', '10-refusal-kernel.md', '20-execution.md',
|
'ultimatum-mode.md', '10-refusal-kernel.md', '20-execution.md',
|
||||||
'ultimatum-mode-mirror.md', '40-routing.md'
|
'ultimatum-mode-mirror.md', '40-routing.md', '50-anticensor.md'
|
||||||
)
|
)
|
||||||
if (Test-Path $runDir) {
|
if (Test-Path $runDir) {
|
||||||
$missing = @()
|
$missing = @()
|
||||||
@ -107,36 +116,42 @@ if (Test-Path $runDir) {
|
|||||||
if (-not (Test-Path (Join-Path $runDir "prompts\$f"))) { $missing += $f }
|
if (-not (Test-Path (Join-Path $runDir "prompts\$f"))) { $missing += $f }
|
||||||
}
|
}
|
||||||
if ($missing.Count -eq 0) {
|
if ($missing.Count -eq 0) {
|
||||||
Say OK "five prompt layers present (5/5)"
|
Say OK "six prompt layers present (6/6)"
|
||||||
} else {
|
} else {
|
||||||
Say FAIL "prompt files missing: $($missing -join ', ')"
|
Say FAIL "prompt files missing: $($missing -join ', ')"
|
||||||
|
$fixable.Add('copy-runtime')
|
||||||
}
|
}
|
||||||
# frames
|
|
||||||
$frameDir = Join-Path $runDir 'prompts\frames'
|
$frameDir = Join-Path $runDir 'prompts\frames'
|
||||||
if (Test-Path $frameDir) {
|
if (Test-Path $frameDir) {
|
||||||
$fc = (Get-ChildItem $frameDir -File).Count
|
$fc = (Get-ChildItem $frameDir -File).Count
|
||||||
Say OK "frames present ($fc files)"
|
Say OK "frames present ($fc files)"
|
||||||
} else {
|
} else {
|
||||||
Say WARN "frames dir missing (moyun_frame will return fewer templates)"
|
Say WARN "frames dir missing"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 7. permission layer config ---
|
# --- 7. permission layer config ---
|
||||||
$ownPatch = Join-Path $runDir 'cordis.patch.yml'
|
$ownPatch = Join-Path $runDir 'cordis.patch.yml'
|
||||||
|
$mode = 'unknown'
|
||||||
if (Test-Path $ownPatch) {
|
if (Test-Path $ownPatch) {
|
||||||
$pt = Get-Content $ownPatch -Raw -Encoding UTF8
|
$pt = Get-Content $ownPatch -Raw -Encoding UTF8
|
||||||
$hasSandbox = $pt -match 'id:\s*sandbox-policy'
|
$hasSandbox = $pt -match 'id:\s*sandbox-policy'
|
||||||
$hasApproval = $pt -match 'id:\s*approval'
|
$hasApproval = $pt -match 'id:\s*approval'
|
||||||
$hasPerm = $pt -match 'id:\s*permission'
|
$hasPerm = $pt -match 'id:\s*permission'
|
||||||
if ($hasSandbox -and $hasApproval -and $hasPerm) {
|
if ($hasSandbox -and $hasApproval -and $hasPerm) {
|
||||||
Say OK "permission layer config present (sandbox-policy / approval / permission)"
|
$mode = 'full'
|
||||||
} else {
|
Say OK "permission layer config present -> mode: FULL"
|
||||||
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" }
|
if ($pt -match 'danger-full-access') { Say OK "sandbox mode is danger-full-access" }
|
||||||
|
} elseif ($pt -match 'COMPLEMENT MODE') {
|
||||||
|
$mode = 'complement'
|
||||||
|
Say OK "COMPLEMENT mode: permission layer yields to other plugins"
|
||||||
|
Say INFO " prompt layers + skills still apply; this is intentional, not a fault"
|
||||||
|
} else {
|
||||||
|
Say WARN "permission layer config incomplete"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Say FAIL "cordis.patch.yml missing in runtime copy"
|
Say FAIL "cordis.patch.yml missing in runtime copy"
|
||||||
|
$fixable.Add('copy-runtime')
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 8. approval answerer in index.js ---
|
# --- 8. approval answerer in index.js ---
|
||||||
@ -144,22 +159,27 @@ $idx = Join-Path $runDir 'index.js'
|
|||||||
if (Test-Path $idx) {
|
if (Test-Path $idx) {
|
||||||
$it = Get-Content $idx -Raw -Encoding UTF8
|
$it = Get-Content $idx -Raw -Encoding UTF8
|
||||||
if ($it -match 'installApprovalAnswerer') { Say OK "approval answerer code present" }
|
if ($it -match 'installApprovalAnswerer') { Say OK "approval answerer code present" }
|
||||||
else { Say WARN "approval answerer code NOT found (0.1.x build?)" }
|
else { Say WARN "approval answerer code NOT found (old build?)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 9. skills landed ---
|
# --- 9. skills landed ---
|
||||||
$skillsDir = Join-Path $DshHome 'skills'
|
$skillsDir = Join-Path $DshHome 'skills'
|
||||||
|
$want = 0
|
||||||
|
$srcSkills = Join-Path $runDir 'skills'
|
||||||
|
if (Test-Path $srcSkills) { $want = (Get-ChildItem $srcSkills -Directory).Count }
|
||||||
if (Test-Path $skillsDir) {
|
if (Test-Path $skillsDir) {
|
||||||
$sn = (Get-ChildItem $skillsDir -Directory).Count
|
$sn = (Get-ChildItem $skillsDir -Directory).Count
|
||||||
Say INFO "skills in DSH_HOME\skills = $sn"
|
Say INFO "skills in DSH_HOME\skills = $sn"
|
||||||
$srcSkills = Join-Path $runDir 'skills'
|
if ($want -gt 0) {
|
||||||
if (Test-Path $srcSkills) {
|
|
||||||
$want = (Get-ChildItem $srcSkills -Directory).Count
|
|
||||||
if ($sn -ge $want) { Say OK "skills synced ($sn >= $want)" }
|
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 "skills not fully synced ($sn of $want)"
|
||||||
|
$fixable.Add('skills')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Say WARN "DSH_HOME\skills not found"
|
Say WARN "DSH_HOME\skills not found"
|
||||||
|
$fixable.Add('skills')
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 10. user-layer override check ---
|
# --- 10. user-layer override check ---
|
||||||
@ -171,8 +191,9 @@ if (Test-Path $profPatch) {
|
|||||||
}
|
}
|
||||||
if ($ovr.Count -gt 0) {
|
if ($ovr.Count -gt 0) {
|
||||||
Say WARN "user-layer profile/cordis.patch.yml overrides: $($ovr -join ', ')"
|
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 " -> user layer applies AFTER bundle layer, so it wins."
|
||||||
Say INFO " blocks there, or set permission: false in this plugin's config."
|
Say INFO " Delete those blocks there, or run: .\switch-mode.ps1 -Mode complement"
|
||||||
|
Say INFO " (not auto-fixed: touching a profile's own config can break other plugins)"
|
||||||
} else {
|
} else {
|
||||||
Say OK "no user-layer override of permission ids"
|
Say OK "no user-layer override of permission ids"
|
||||||
}
|
}
|
||||||
@ -180,27 +201,128 @@ if (Test-Path $profPatch) {
|
|||||||
Say INFO "no user-layer cordis.patch.yml (bundle layer wins by default)"
|
Say INFO "no user-layer cordis.patch.yml (bundle layer wins by default)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 11. conflicting plugins ---
|
# --- 11. conflicting plugins (precise) ---
|
||||||
|
$CONFLICT_IDS = @('sandbox-policy', 'approval', 'permission', 'spill-policy', 'tool-result-pruner')
|
||||||
if (Test-Path $pkgJson) {
|
if (Test-Path $pkgJson) {
|
||||||
try {
|
try {
|
||||||
$j = Get-Content $pkgJson -Raw -Encoding UTF8 | ConvertFrom-Json
|
$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') }
|
$hard = @()
|
||||||
if ($others) {
|
$scanned = 0
|
||||||
Say WARN "other jailbreak-ish plugins in bundles: $($others -join ', ')"
|
foreach ($b in @($j.dsh.profile.bundles)) {
|
||||||
Say INFO " -> if they also override approval/permission, only one wins (last applied)"
|
if ($b -eq $PkgName) { continue }
|
||||||
|
$bp = Join-Path $profileDir "node_modules\$b\cordis.patch.yml"
|
||||||
|
if (-not (Test-Path $bp)) { continue }
|
||||||
|
$scanned++
|
||||||
|
$bt = Get-Content $bp -Raw -Encoding UTF8
|
||||||
|
$ids = @()
|
||||||
|
foreach ($m in [regex]::Matches($bt, '(?m)^\s*-?\s*id:\s*([A-Za-z0-9_\-]+)')) { $ids += $m.Groups[1].Value }
|
||||||
|
$hit = @($ids | Where-Object { $CONFLICT_IDS -contains $_ } | Sort-Object -Unique)
|
||||||
|
if ($hit.Count -gt 0) { $hard += ("$b(" + ($hit -join '/') + ")") }
|
||||||
|
}
|
||||||
|
if ($hard.Count -eq 0) {
|
||||||
|
Say OK "no permission-config conflict (scanned $scanned plugins)"
|
||||||
} else {
|
} else {
|
||||||
Say OK "no conflicting jailbreak plugin in bundles"
|
Say WARN ("hard conflict: " + ($hard -join ', '))
|
||||||
|
Say INFO " -> only one contender can own the permission layer; pick one"
|
||||||
|
if ($mode -eq 'full') { Say INFO " or run: .\switch-mode.ps1 -Mode complement" }
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---------- FIX ----------
|
||||||
|
if ($Fix -and $fixable.Count -gt 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "=====================" -ForegroundColor Cyan
|
||||||
|
Write-Host "repairing $($fixable.Count) item(s)" -ForegroundColor Cyan
|
||||||
|
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||||
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
|
|
||||||
|
# backup package.json once
|
||||||
|
if ((Test-Path $pkgJson) -and ($fixable -contains 'dep' -or $fixable -contains 'bundle')) {
|
||||||
|
Copy-Item $pkgJson "$pkgJson.bak-doctor-$stamp" -Force
|
||||||
|
Say FIX "backup: package.json.bak-doctor-$stamp"
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy-runtime / copy-source: re-copy from the package source next to this script
|
||||||
|
foreach ($k in @('copy-runtime', 'copy-source')) {
|
||||||
|
if ($fixable -contains $k) {
|
||||||
|
$dst = if ($k -eq 'copy-runtime') { $runDir } else { $plugDir }
|
||||||
|
if (Test-Path $here) {
|
||||||
|
if (Test-Path $dst) { Remove-Item $dst -Recurse -Force }
|
||||||
|
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
||||||
|
Copy-Item "$here\*" $dst -Recurse -Force
|
||||||
|
Say FIX "re-copied package files into $dst"
|
||||||
|
} else {
|
||||||
|
Say WARN "cannot re-copy: run this from the package directory"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# exports./client
|
||||||
|
if ($fixable -contains 'exports') {
|
||||||
|
try {
|
||||||
|
$rj = Get-Content $runPkg -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||||
|
if (-not $rj.exports) {
|
||||||
|
$rj | Add-Member -NotePropertyName exports -NotePropertyValue ([pscustomobject]@{}) -Force
|
||||||
|
}
|
||||||
|
$rj.exports | Add-Member -NotePropertyName './client' -NotePropertyValue './client.js' -Force
|
||||||
|
[IO.File]::WriteAllText($runPkg, ($rj | ConvertTo-Json -Depth 10), (New-Object Text.UTF8Encoding($false)))
|
||||||
|
Say FIX "added exports['./client'] to runtime package.json"
|
||||||
|
} catch { Say WARN "could not patch exports: $($_.Exception.Message)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
# dep / bundle
|
||||||
|
if ($fixable -contains 'dep' -or $fixable -contains 'bundle') {
|
||||||
|
$raw = Get-Content $pkgJson -Raw -Encoding UTF8
|
||||||
|
$out = New-Object System.Collections.Generic.List[string]
|
||||||
|
$depAdded = $false
|
||||||
|
foreach ($l in ($raw -split "`n")) {
|
||||||
|
if (-not $depAdded -and $fixable -contains 'dep' -and $l -match '^\s*"dependencies":\s*\{') {
|
||||||
|
$out.Add($l)
|
||||||
|
$out.Add(" `"$PkgName`": `"file:./plugins/$PkgName`",")
|
||||||
|
$depAdded = $true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$out.Add($l)
|
||||||
|
}
|
||||||
|
[IO.File]::WriteAllText($pkgJson, ($out -join "`n"), (New-Object Text.UTF8Encoding($false)))
|
||||||
|
if ($fixable -contains 'dep') { Say FIX "added dependencies entry" }
|
||||||
|
if ($fixable -contains 'bundle') {
|
||||||
|
Say WARN "bundles entry must be added by the DSH plugin panel (it rewrites the list on save)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# skills
|
||||||
|
if ($fixable -contains 'skills') {
|
||||||
|
try {
|
||||||
|
if (-not (Test-Path $skillsDir)) { New-Item -ItemType Directory -Force -Path $skillsDir | Out-Null }
|
||||||
|
$copied = 0
|
||||||
|
foreach ($d in (Get-ChildItem $srcSkills -Directory -ErrorAction SilentlyContinue)) {
|
||||||
|
$target = Join-Path $skillsDir $d.Name
|
||||||
|
if (-not (Test-Path $target)) {
|
||||||
|
Copy-Item $d.FullName $target -Recurse -Force
|
||||||
|
$copied++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Say FIX "synced $copied skill directories into DSH_HOME\skills"
|
||||||
|
} catch { Say WARN "skill sync failed: $($_.Exception.Message)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Say INFO "re-run doctor.ps1 to confirm; then fully quit and reopen DSH."
|
||||||
|
} elseif ($Fix) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "nothing to repair" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
# --- summary ---
|
# --- summary ---
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "=====================" -ForegroundColor Cyan
|
Write-Host "=====================" -ForegroundColor Cyan
|
||||||
Write-Host ("RESULT: OK={0} WARN={1} FAIL={2}" -f $ok, $warn, $fail) -ForegroundColor Cyan
|
Write-Host ("RESULT: OK={0} WARN={1} FAIL={2} MODE={3}" -f $ok, $warn, $fail, $mode) -ForegroundColor Cyan
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
if ($fail -gt 0) {
|
if ($fail -gt 0) {
|
||||||
Write-Host "ACTION: fix the [FAIL] items above, then fully quit DSH and reopen." -ForegroundColor Red
|
Write-Host "ACTION: fix the [FAIL] items above, then fully quit DSH and reopen." -ForegroundColor Red
|
||||||
|
if (-not $Fix) { Write-Host " or try: powershell -File .\doctor.ps1 -Fix" -ForegroundColor Yellow }
|
||||||
exit 2
|
exit 2
|
||||||
} elseif ($warn -gt 0) {
|
} elseif ($warn -gt 0) {
|
||||||
Write-Host "ACTION: review [WARN] items. Plugin should still work." -ForegroundColor Yellow
|
Write-Host "ACTION: review [WARN] items. Plugin should still work." -ForegroundColor Yellow
|
||||||
|
|||||||
39
install.ps1
39
install.ps1
@ -11,6 +11,7 @@ param(
|
|||||||
[ValidateSet('auto', 'full', 'complement')]
|
[ValidateSet('auto', 'full', 'complement')]
|
||||||
[string]$Mode = 'auto',
|
[string]$Mode = 'auto',
|
||||||
[switch]$Uninstall,
|
[switch]$Uninstall,
|
||||||
|
[switch]$Rollback,
|
||||||
[switch]$DryRun
|
[switch]$DryRun
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
@ -121,6 +122,31 @@ function Apply-Mode([string]$effective) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($Rollback) {
|
||||||
|
Write-Output '--- rollback ---'
|
||||||
|
$baks = @(Get-ChildItem (Split-Path $pkgJson -Parent) -Filter "package.json.bak-*" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending)
|
||||||
|
if ($baks.Count -eq 0) {
|
||||||
|
Write-Output ' no backup found - nothing to roll back to'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$newest = $baks[0]
|
||||||
|
Write-Output (' newest backup: ' + $newest.Name + ' (' + $newest.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss') + ')')
|
||||||
|
if ($DryRun) {
|
||||||
|
Write-Output ' would restore it and remove plugin dirs'
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
Copy-Item $newest.FullName $pkgJson -Force
|
||||||
|
Write-Output ' package.json restored'
|
||||||
|
foreach ($d in @($plugDir, $runDir)) {
|
||||||
|
if (Test-Path $d) { Remove-Item $d -Recurse -Force; Write-Output (' removed ' + $d) }
|
||||||
|
}
|
||||||
|
$null = Get-Pkg
|
||||||
|
Write-Output ' JSON valid'
|
||||||
|
Write-Output ''
|
||||||
|
Write-Output 'Rolled back. Fully quit DSH and reopen it.'
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
if ($Uninstall) {
|
if ($Uninstall) {
|
||||||
Write-Output '--- uninstall ---'
|
Write-Output '--- uninstall ---'
|
||||||
foreach ($d in @($plugDir, $runDir)) {
|
foreach ($d in @($plugDir, $runDir)) {
|
||||||
@ -220,6 +246,13 @@ if (-not $hasBundle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Output ''
|
Write-Output ''
|
||||||
Write-Output ("DONE ($effective mode). Fully quit DSH and reopen it.")
|
Write-Output ('DONE (' + $effective + ' mode).')
|
||||||
Write-Output 'Switch modes later: powershell -File .\switch-mode.ps1 -Mode full|complement'
|
Write-Output ''
|
||||||
Write-Output 'Verify after restart: powershell -File .\doctor.ps1'
|
Write-Output 'Next three steps:'
|
||||||
|
Write-Output ' 1. Fully quit DSH (including the tray icon), then reopen it.'
|
||||||
|
Write-Output ' 2. Verify: powershell -ExecutionPolicy Bypass -File .\doctor.ps1'
|
||||||
|
Write-Output ' 3. Ask the agent: moyun_ultimate_profile'
|
||||||
|
Write-Output ''
|
||||||
|
Write-Output 'If something looks wrong:'
|
||||||
|
Write-Output ' switch modes : powershell -File .\switch-mode.ps1 -Mode complement'
|
||||||
|
Write-Output ' undo install : powershell -File .\install.ps1 -Rollback'
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "moyun-ultimate",
|
"name": "moyun-ultimate",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"displayName": "墨昀·终极破甲",
|
"displayName": "墨昀·终极破甲",
|
||||||
"description": "墨昀·终极破甲:五层提示词内核 + 内置权限层 —— 人格双槽 × 反拒绝机制 × 执行强度 × 换框模板 × 技能路由,内置 63 个攻防技能(逆向 24 / 渗透 16 / 云 8 / 取证 6 / 其它 9)。Layered prompt core with five sections and 63 built-in skills.",
|
"description": "墨昀·终极破甲:五层提示词内核 + 内置权限层 —— 人格双槽 × 反拒绝机制 × 执行强度 × 换框模板 × 技能路由,内置 63 个攻防技能(逆向 24 / 渗透 16 / 云 8 / 取证 6 / 其它 9)。Layered prompt core with five sections and 63 built-in skills.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -39,7 +39,7 @@
|
|||||||
"dsh": {
|
"dsh": {
|
||||||
"id": "moyun-ultimate",
|
"id": "moyun-ultimate",
|
||||||
"name": "墨昀·终极破甲",
|
"name": "墨昀·终极破甲",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"permissions": "六段提示词注入(含输出抗审), 内置权限层(沙箱/审批/结果), 拒绝投影状态条, 换框模板工具, 状态自查工具(含 provider 审核风险评估), 技能审计工具, 63 技能自动同步",
|
"permissions": "六段提示词注入(含输出抗审), 内置权限层(沙箱/审批/结果), 拒绝投影状态条, 换框模板工具, 状态自查工具(含 provider 审核风险评估), 技能审计工具, 63 技能自动同步",
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"patch": "./cordis.patch.yml"
|
"patch": "./cordis.patch.yml"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user