history.ts
1 import { 2 getCurrentProjectConfig, 3 saveCurrentProjectConfig, 4 } from './utils/config.js' 5 6 const MAX_HISTORY_ITEMS = 100 7 8 export function getHistory(): string[] { 9 return getCurrentProjectConfig().history ?? [] 10 } 11 12 export function addToHistory(command: string): void { 13 const projectConfig = getCurrentProjectConfig() 14 const history = projectConfig.history ?? [] 15 16 if (history[0] === command) { 17 return 18 } 19 20 history.unshift(command) 21 saveCurrentProjectConfig({ 22 ...projectConfig, 23 history: history.slice(0, MAX_HISTORY_ITEMS), 24 }) 25 }