Settings Module
Purpose
- Manage global application settings (theme, language, telemetry, editor preferences, git defaults).
- Provide HTTP endpoints for reading/updating settings and emit events so caches refresh consistently.
Data & Event Flow
- Service Layer (
service.ts)ensureAppSettingslazily bootstraps defaults and caches them in memory.updateAppSettingswrites to SQLite and refreshes the cache.
- Routes (
routes.ts)/settingsGET loads (ensuring defaults)./settingsPATCH validates input, updates settings, and emitssettings.global.updated.
- Listeners (
listeners.ts)- Subscribes to
settings.global.updatedand callsensureAppSettingsto refresh the cache immediately.
- Subscribes to
Key Entry Points
service.ts: cache-aware CRUD operations for the singleton settings row.routes.ts: Hono endpoints.listeners.ts: cache invalidation hook.
Open Tasks
- Extend events/listeners to notify interested modules (e.g., editor defaults, git defaults) when settings change.
- Add validation and persistence for future editor command templates per agent.
- Write tests covering cache refresh and failure scenarios.