Files
isphere-ai-bridge/scripts/test-open-offline-real-frmP2PChat-contract.ps1
2026-07-11 20:58:26 +08:00

50 lines
1.7 KiB
PowerShell

param(
[string]$ScriptPath = "scripts/open-offline-real-frmP2PChat.ps1"
)
$ErrorActionPreference = "Stop"
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
$target = if ([System.IO.Path]::IsPathRooted($ScriptPath)) {
$ScriptPath
}
else {
Join-Path $repo $ScriptPath
}
if (-not (Test-Path -LiteralPath $target)) {
throw "script not found: $target"
}
$text = Get-Content -LiteralPath $target -Raw
$requiredPatterns = @(
@{ Name = "x86 PowerShell guard"; Pattern = "Environment]::Is64BitProcess" },
@{ Name = "AssemblyResolve dependency loader"; Pattern = "AssemblyResolve" },
@{ Name = "fake runtime mode parameter"; Pattern = "RuntimeMode" },
@{ Name = "self chat variant"; Pattern = "SelfChat" },
@{ Name = "skip roster variant"; Pattern = "SkipRosterManager" },
@{ Name = "CLR IL offset extraction"; Pattern = "GetILOffset" },
@{ Name = "IL offset JSON field"; Pattern = "il_offset_hex" },
@{ Name = "Config.BaseConfig fake runtime"; Pattern = "<BaseConfig>k__BackingField" },
@{ Name = "remote control config key"; Pattern = "Remote_Control_Visible" },
@{ Name = "fake frmMain activation target"; Pattern = "<frmMain>k__BackingField" },
@{ Name = "UserInfo cache warmup"; Pattern = "UserInfoCache" },
@{ Name = "result artifact output"; Pattern = "real-frmP2PChat-result" }
)
$missing = @()
foreach ($item in $requiredPatterns) {
if ($text -notmatch $item.Pattern) {
$missing += $item.Name
}
}
if ($missing.Count -gt 0) {
throw "contract missing: $($missing -join ', ')"
}
[pscustomobject]@{
ok = $true
script = $target
checked = $requiredPatterns.Count
} | ConvertTo-Json -Compress