hudada-cli
Version:
专为程序员准备的本地文档搜索,快捷开发工具
3 lines (2 loc) • 497 B
JavaScript
import r from"fs";import o from"path";import t from"chalk";const e=o.join(process.cwd(),"ai_history.json");function n(o){try{r.writeFileSync(e,JSON.stringify(o,null,2))}catch(r){console.error(t.yellow("保存历史记录失败"))}}function c(){try{if(r.existsSync(e)){const o=r.readFileSync(e,"utf8");return JSON.parse(o)}}catch(r){console.error(t.yellow("读取历史记录失败,将创建新的历史记录"))}return{messages:[]}}export{c as loadHistory,n as saveHistory};