import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { __test } from "../index.ts"; function project(settings?: unknown): { cwd: string; agentDir: string } { const cwd = mkdtempSync(path.join(tmpdir(), "angel-settings-project-")); const agentDir = mkdtempSync(path.join(tmpdir(), "angel-settings-agent-")); if (settings !== undefined) { mkdirSync(path.join(cwd, ".pi")); writeFileSync( path.join(cwd, ".pi", "settings.json"), JSON.stringify(settings), ); } return { cwd, agentDir }; } describe("angel settings", () => { it("loads the project Pi settings angel block", () => { const { cwd, agentDir } = project({ angel: { enabled: false, maxCallsPerTask: 4 }, }); expect(__test.loadSettings(cwd, agentDir)).toMatchObject({ enabled: false, maxCallsPerTask: 4, }); }); it("defaults when settings are missing", () => { const { cwd, agentDir } = project(); expect(__test.loadSettings(cwd, agentDir)).toEqual({}); }); });