feat: harden runtime readiness and session workflow
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { ensurePiTrust } from "./ensure-pi-trust.mjs";
|
||||
|
||||
test("adds the canonical harness path and preserves existing trust entries", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "thothii-pi-trust-"));
|
||||
const agentDir = join(root, "agent");
|
||||
ensurePiTrust("/first/harness", agentDir);
|
||||
writeFileSync(
|
||||
join(agentDir, "trust.json"),
|
||||
`${JSON.stringify({ "/existing/project": true }, null, 2)}\n`,
|
||||
);
|
||||
|
||||
assert.equal(ensurePiTrust("/app/harness/../harness", agentDir), true);
|
||||
const trust = JSON.parse(readFileSync(join(agentDir, "trust.json"), "utf8"));
|
||||
assert.deepEqual(trust, { "/existing/project": true, "/app/harness": true });
|
||||
assert.equal(ensurePiTrust("/app/harness", agentDir), false);
|
||||
});
|
||||
Reference in New Issue
Block a user