import { join } from "node:path"; import { describe, expect, it } from "vitest"; import { DEBUG_LOG_FILENAME, getGlobalConfigDir, getGlobalConfigPath, getGlobalLogsDir, getLegacyExtensionConfigPath, getLegacyGlobalPolicyPath, getLegacyProjectPolicyPath, getProjectConfigPath, REVIEW_LOG_FILENAME, } from "../src/config-paths"; describe("config-paths", () => { const agentDir = "/home/user/.pi/agent"; const cwd = "/projects/my-app"; const extensionRoot = "/opt/extensions/pi-quick-perms"; describe("new layout paths", () => { it("getGlobalConfigDir returns extensions/pi-quick-perms under agentDir", () => { expect(getGlobalConfigDir(agentDir)).toBe( join(agentDir, "extensions", "pi-quick-perms"), ); }); it("getGlobalConfigPath returns config.json under the global config dir", () => { expect(getGlobalConfigPath(agentDir)).toBe( join(agentDir, "extensions", "pi-quick-perms", "config.json"), ); }); it("getGlobalLogsDir returns logs under the global config dir", () => { expect(getGlobalLogsDir(agentDir)).toBe( join(agentDir, "extensions", "pi-quick-perms", "logs"), ); }); it("getProjectConfigPath returns .pi/extensions/pi-permission-system/config.json under cwd", () => { expect(getProjectConfigPath(cwd)).toBe( join(cwd, ".pi", "extensions", "pi-permission-system", "config.json"), ); }); }); describe("legacy paths", () => { it("getLegacyGlobalPolicyPath returns pi-permissions.jsonc under agentDir", () => { expect(getLegacyGlobalPolicyPath(agentDir)).toBe( join(agentDir, "pi-permissions.jsonc"), ); }); it("getLegacyProjectPolicyPath returns .pi/agent/pi-permissions.jsonc under cwd", () => { expect(getLegacyProjectPolicyPath(cwd)).toBe( join(cwd, ".pi", "agent", "pi-permissions.jsonc"), ); }); it("getLegacyExtensionConfigPath returns config.json under extensionRoot", () => { expect(getLegacyExtensionConfigPath(extensionRoot)).toBe( join(extensionRoot, "config.json"), ); }); }); describe("log filenames", () => { it("DEBUG_LOG_FILENAME is a .jsonl file", () => { expect(DEBUG_LOG_FILENAME).toBe("pi-quick-perms-debug.jsonl"); }); it("REVIEW_LOG_FILENAME is a .jsonl file", () => { expect(REVIEW_LOG_FILENAME).toBe( "pi-quick-perms-permission-review.jsonl", ); }); }); });