-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsettings.ts
More file actions
40 lines (33 loc) · 1 KB
/
settings.ts
File metadata and controls
40 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
export const SETTINGS_PATH = join(homedir(), ".pi", "agent", "settings.json");
export interface InterviewThemeSettings {
mode?: "auto" | "light" | "dark";
name?: string;
lightPath?: string;
darkPath?: string;
toggleHotkey?: string;
}
export interface InterviewSettings {
browser?: string;
timeout?: number;
port?: number;
theme?: InterviewThemeSettings;
snapshotDir?: string; // Default: ~/.pi/interview-snapshots/
autoSaveOnSubmit?: boolean; // Default: true
}
export function loadSettings(): InterviewSettings {
if (!existsSync(SETTINGS_PATH)) {
return {};
}
const parsed = JSON.parse(readFileSync(SETTINGS_PATH, "utf-8"));
if (typeof parsed !== "object" || parsed === null) {
return {};
}
const interview = (parsed as Record<string, unknown>).interview;
if (typeof interview !== "object" || interview === null) {
return {};
}
return interview as InterviewSettings;
}