// PEP-172: no agent works in the directory FORGE itself runs from (the live copy). import assert from "node:assert/strict"; import { mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { describe, test } from "node:test"; import { runner } from "./helpers.ts"; describe("PEP-172: копия живого сайта — не для агентов", () => { test("каталог, из которого работает FORGE, узнаётся (PEPPA_ROOT, через символьные ссылки тоже)", () => { const live = mkdtempSync(join(tmpdir(), "mock-live-")); const other = mkdtempSync(join(tmpdir(), "mock-ws-")); const prev = process.env.PEPPA_ROOT; process.env.PEPPA_ROOT = live; try { assert.equal(runner.isLiveCheckout(live), true); assert.equal(runner.isLiveCheckout(`${live}/`), true); assert.equal(runner.isLiveCheckout(other), false); assert.equal(runner.isLiveCheckout(join(other, "missing")), false); } finally { if (prev === undefined) delete process.env.PEPPA_ROOT; else process.env.PEPPA_ROOT = prev; rmSync(live, { recursive: true, force: true }); rmSync(other, { recursive: true, force: true }); } }); });