oclaw/runtime/operations/scripts/verify_forwarders.py
oliver 4a23b715a2 重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。

Made-with: Cursor
2026-04-25 01:24:23 +08:00

58 lines
1.7 KiB
Python

from __future__ import annotations
from pathlib import Path
from oclaw.platform.config.runtime_paths import oclaw_root, runtime_operations_scripts_root
def verify_forwarders() -> tuple[bool, list[str]]:
root_scripts = (oclaw_root() / "scripts").resolve()
real_scripts = runtime_operations_scripts_root()
errors: list[str] = []
required = [
"start_all.ps1",
"start_gateway.ps1",
"start_desktop.ps1",
"start_ops.ps1",
"start_ops.sh",
"status_ops.sh",
"stop_ops.sh",
]
for name in required:
rp = root_scripts / name
if not rp.exists():
errors.append(f"missing forwarder: {rp}")
continue
tp = real_scripts / name
if not tp.exists():
errors.append(f"missing target: {tp}")
continue
text = rp.read_text(encoding="utf-8", errors="ignore")
normalized = text.replace("\\", "/")
while "//" in normalized:
normalized = normalized.replace("//", "/")
marker_exact = f"runtime/operations/scripts/{name}".replace("\\", "/")
marker_base = "runtime/operations/scripts"
if name.endswith(".sh"):
ok = (marker_base in normalized) and (f"/{name}" in normalized)
else:
ok = marker_exact in normalized
if not ok:
errors.append(f"forwarder target mismatch: {rp}")
return (len(errors) == 0), errors
def main() -> int:
ok, errors = verify_forwarders()
if ok:
print("forwarders_ok=1")
return 0
print("forwarders_ok=0")
for err in errors:
print(err)
return 1
if __name__ == "__main__":
raise SystemExit(main())