# -*- coding: utf-8 -*- """把「配一次 → 零窗口」流程测试接进 verify_all.ps1。""" from __future__ import annotations import sys from pathlib import Path TARGET = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_tests\verify_all.ps1") ANCHOR = 'Record "静默模式" ($silentCode -eq 0)' ADDITION = '''Record "静默模式" ($silentCode -eq 0) # ---------------------------------------------------------------- 1j Banner "1j/7 配一次→零窗口(令牌重连,全程无窗口)" Stop-Strays & python (Join-Path $root "_tests\\test_pair_once_flow.py") *> (Join-Path $env:TEMP "lr_flow.txt") $flowCode = $LASTEXITCODE Get-Content (Join-Path $env:TEMP "lr_flow.txt") -Encoding UTF8 -ErrorAction SilentlyContinue | Select-Object -Last 3 Record "配一次→零窗口" ($flowCode -eq 0)''' def main() -> int: raw = TARGET.read_bytes() bom = raw[:3] == b"\xef\xbb\xbf" text = raw.decode("utf-8-sig") if "test_pair_once_flow.py" in text: print(" 已经加过") return 0 if ANCHOR not in text: print(" [失败] 锚点没找到") return 1 text = text.replace(ANCHOR, ADDITION, 1) data = text.encode("utf-8") if bom: data = b"\xef\xbb\xbf" + data TARGET.write_bytes(data) print(" verify_all.ps1: 已插入「配一次→零窗口」阶段") return 0 if __name__ == "__main__": sys.exit(main())