@@ -57,6 +57,8 @@ function create(meta) {
|
||||
createdAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
plan: [],
|
||||
planMode: meta.planMode || { state: 'inactive', planPath: 'plan.md', reminderCount: 0 },
|
||||
goal: meta.goal || null,
|
||||
};
|
||||
fs.writeFileSync(path.join(dir, 'summary.json'), JSON.stringify(summary, null, 2));
|
||||
fs.writeFileSync(path.join(dir, 'chat_history.jsonl'), '');
|
||||
@@ -78,7 +80,10 @@ function load(id) {
|
||||
|
||||
function saveSummary(summary) {
|
||||
summary.updatedAt = Date.now();
|
||||
fs.writeFileSync(path.join(sessionDir(summary.id), 'summary.json'), JSON.stringify(summary, null, 2));
|
||||
const copy = Object.assign({}, summary);
|
||||
delete copy.history;
|
||||
delete copy.updates;
|
||||
fs.writeFileSync(path.join(sessionDir(summary.id), 'summary.json'), JSON.stringify(copy, null, 2));
|
||||
}
|
||||
|
||||
function appendHistory(id, msg) {
|
||||
@@ -95,6 +100,24 @@ function replaceHistory(id, history) {
|
||||
fs.writeFileSync(file, body ? body + '\n' : '');
|
||||
}
|
||||
|
||||
function planFile(id) {
|
||||
return path.join(sessionDir(id), 'plan.md');
|
||||
}
|
||||
|
||||
function readPlan(id) {
|
||||
try {
|
||||
return fs.readFileSync(planFile(id), 'utf8');
|
||||
} catch (_) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function writePlan(id, text) {
|
||||
const file = planFile(id);
|
||||
fs.writeFileSync(file, String(text != null ? text : ''));
|
||||
return file;
|
||||
}
|
||||
|
||||
function list() {
|
||||
const root = sessionsRoot();
|
||||
let names = [];
|
||||
@@ -121,6 +144,10 @@ module.exports = {
|
||||
appendHistory,
|
||||
appendUpdate,
|
||||
replaceHistory,
|
||||
sessionDir,
|
||||
planFile,
|
||||
readPlan,
|
||||
writePlan,
|
||||
list,
|
||||
makeId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user