export interface ExtensionSettings { showDangerWarning: boolean copyOnTranslate: boolean preferredShell: 'bash' | 'zsh' | 'fish' | 'powershell' theme: 'light' | 'dark' | 'auto' contextMenuEnabled: boolean inlinePanelEnabled: boolean } const DEFAULT_SETTINGS: ExtensionSettings = { showDangerWarning: true, copyOnTranslate: true, preferredShell: 'bash', theme: 'auto', contextMenuEnabled: true, inlinePanelEnabled: true, } export async function getSettings(): Promise { try { const result = await chrome.storage.sync.get('screwdriver_settings') return { ...DEFAULT_SETTINGS, ...(result.screwdriver_settings ?? {}) } } catch { return DEFAULT_SETTINGS } } export async function setSettings(settings: Partial): Promise { const current = await getSettings() await chrome.storage.sync.set({ screwdriver_settings: { ...current, ...settings }, }) } export interface ClipboardItem { id: string text: string timestamp: number type: 'command' | 'transform' | 'conflict' | 'regex' } export async function addClipboardItem(item: Omit): Promise { const result = await chrome.storage.local.get('screwdriver_history') const history: ClipboardItem[] = result.screwdriver_history ?? [] const newItem: ClipboardItem = { ...item, id: `${Date.now()}_${Math.random().toString(36).slice(2)}`, timestamp: Date.now(), } const updated = [newItem, ...history].slice(0, 50) await chrome.storage.local.set({ screwdriver_history: updated }) } export async function getClipboardHistory(): Promise { const result = await chrome.storage.local.get('screwdriver_history') return result.screwdriver_history ?? [] } export async function clearClipboardHistory(): Promise { await chrome.storage.local.remove('screwdriver_history') }