/** * Settings singleton with sync get/set and background persistence. * * Usage: * import { settings } from "./settings"; * * const enabled = settings.get("compaction.enabled"); // sync read * settings.set("theme.dark", "titanium"); // sync write, saves in background * * For tests: * const isolated = Settings.isolated({ "compaction.enabled": false }); */ import { procmgr } from "@oh-my-pi/pi-utils"; import type { ModelRole } from "../config/model-registry"; import { AgentStorage } from "../session/agent-storage"; import { type EditMode } from "../utils/edit-mode"; import { type BashInterceptorRule, type GroupPrefix, type GroupTypeMap, type SettingPath, type SettingValue } from "./settings-schema"; export type * from "./settings-schema"; export * from "./settings-schema"; /** Raw settings object as stored in YAML */ export interface RawSettings { [key: string]: unknown; } export interface SettingsOptions { /** Current working directory for project settings discovery */ cwd?: string; /** Agent directory for config.yml storage */ agentDir?: string; /** Don't persist to disk (for tests) */ inMemory?: boolean; /** Initial overrides */ overrides?: Partial>; } export declare class Settings { #private; private constructor(); /** * Initialize the global singleton. * Call once at startup before accessing `settings`. */ static init(options?: SettingsOptions): Promise; /** * Create an isolated instance for testing. * Does not affect the global singleton. */ static isolated(overrides?: Partial>): Settings; /** * Get the global singleton. * Throws if not initialized. */ static get instance(): Settings; /** * Get a setting value (sync). * Returns the merged value from global + project + overrides, or the default. */ get

(path: P): SettingValue

; /** * Set a setting value (sync). * Updates global settings and queues a background save. * Triggers hooks for settings that have side effects. */ set

(path: P, value: SettingValue

): void; /** * Apply runtime overrides (not persisted). */ override

(path: P, value: SettingValue

): void; /** * Clear a runtime override. */ clearOverride(path: SettingPath): void; /** * Flush any pending saves to disk. * Call before exit to ensure all changes are persisted. */ flush(): Promise; cloneForCwd(cwd: string): Promise; getStorage(): AgentStorage | null; getCwd(): string; getAgentDir(): string; getPlansDirectory(): string; /** * Get shell configuration based on settings. */ getShellConfig(): procmgr.ShellConfig; /** * Get all settings in a group with full type safety. */ getGroup(prefix: G): GroupTypeMap[G]; /** * Get the edit variant for a specific model. * Returns "patch", "replace", "hashline", "vim", "apply_patch", or null (use global default). */ getEditVariantForModel(model: string | undefined): EditMode | null; /** * Get bash interceptor rules (typed accessor for complex array config). */ getBashInterceptorRules(): BashInterceptorRule[]; /** * Set a model role (helper for modelRoles record). */ setModelRole(role: ModelRole | string, modelId: string): void; /** * Get a model role (helper for modelRoles record). */ getModelRole(role: ModelRole | string): string | undefined; /** * Get all model roles (helper for modelRoles record). */ getModelRoles(): ReadOnlyDict; overrideModelRoles(roles: ReadOnlyDict): void; /** * Set disabled providers (for compatibility with discovery system). */ setDisabledProviders(ids: string[]): void; } export declare function isSettingsInitialized(): boolean; /** * Reset the global singleton for testing. * @internal */ export declare function resetSettingsForTest(): void; /** * The global settings singleton. * Must call `Settings.init()` before using. */ export declare const settings: Settings;