#!/usr/bin/env node import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; const cli = "/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/server-tools/persona-host-write-admission/host-write-admission.mjs"; function check(host, target) { const r = spawnSync(process.execPath, [cli, "check", "--host", host, "--path", target], { encoding: "utf8" }); return { code: r.status, body: JSON.parse(r.stdout) }; } function hook(host, body) { const r = spawnSync(process.execPath, [cli, "hook", "--host", host], { input: JSON.stringify(body), encoding: "utf8" }); return { code: r.status, body: JSON.parse(r.stdout) }; } assert.equal(check("qwen", "/Volumes/JZAO/铸渊-ICE-GL-ZY001/QWEN-DEV-20260905/a.tcs").code, 0); assert.equal(check("qwen", "/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/routing/a.json").code, 2); assert.equal(check("qwen", "/Volumes/JZAO/铸渊-ICE-GL-ZY001/BRIDGE/runtime-state/qwen/ice-ch-zc001/a.json").code, 0); assert.equal(check("qwen", "/Volumes/JZAO/铸渊-ICE-GL-ZY001/ZCODE-DEV-20260906/a.json").code, 2); assert.equal(check("zcode", "/Volumes/JZAO/铸渊-ICE-GL-ZY001/ZCODE-DEV-20260906/a.txt").code, 0); assert.equal(check("zcode", "/Volumes/JZAO/铸渊-ICE-GL-ZY001/AGENTS.md").code, 2); assert.equal(check("qoder", "/Users/bingshuolingdianyuanhe/.qoder/skills/a.txt").code, 2); assert.equal(check("codex", "/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/routing/a.json").code, 0); const deniedEdit = hook("zcode", { tool_name: "Edit", tool_input: { file_path: "/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/routing/a.json" } }); assert.equal(deniedEdit.code, 2); assert.equal(deniedEdit.body.hookSpecificOutput.permissionDecision, "deny"); const allowedEdit = hook("zcode", { tool_name: "Edit", tool_input: { file_path: "/Volumes/JZAO/铸渊-ICE-GL-ZY001/ZCODE-DEV-20260906/a.json" } }); assert.equal(allowedEdit.code, 0); assert.equal(allowedEdit.body.hookSpecificOutput.permissionDecision, "allow"); const deniedShell = hook("zcode", { tool_name: "Bash", tool_input: { command: "touch /Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/routing/a.json" } }); assert.equal(deniedShell.code, 2); assert.equal(deniedShell.body.hookSpecificOutput.permissionDecision, "deny"); const allowedRead = hook("zcode", { tool_name: "Read", tool_input: { file_path: "/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main/routing/a.json" } }); assert.equal(allowedRead.code, 0); assert.equal(allowedRead.body.hookSpecificOutput.permissionDecision, "allow"); console.log("HOST_WRITE_ADMISSION_TESTS_PASS 12/12");