feat(terminal): add guided goals, tasks, and confirmed deletion

This commit is contained in:
Codex committed 2026-09-28 14:13:21 +08:00
1 parent 8ffeb2897f
commit 78c1ffe1fd
7 files changed
+175 -10

No files matched your search

+28
View File
@@ -34,6 +34,27 @@
task.done = done; task.completedAt = done ? new Date().toISOString() : null;
persistBoard(data); return task;
},
setGoalDone(id, done) {
const data = board(), goal = data.goals.find(item => item.id === id);
if (!goal) throw new Error('notFound');
goal.done = done; goal.completedAt = done ? new Date().toISOString() : null;
persistBoard(data); return goal;
},
deleteTask(id) {
const data = board(), task = data.tasks.find(item => item.id === id);
if (!task) throw new Error('notFound');
data.tasks = data.tasks.filter(item => item.id !== id);
const all = mems();
if (all.some(item => item.taskId === id)) save('lifeos_memories', all.map(item => item.taskId === id ? { ...item, taskId: '', updatedAt: new Date().toISOString() } : item));
persistBoard(data); return task;
},
deleteGoal(id) {
const data = board(), goal = data.goals.find(item => item.id === id);
if (!goal) throw new Error('notFound');
data.goals = data.goals.filter(item => item.id !== id);
data.tasks.forEach(task => { if (task.goalId === id) task.goalId = ''; });
persistBoard(data); return goal;
},
createMemory({ date = day(), title, text = '', mood = 'cloudy', energy = 3, tags = [], location = '', taskId = '', replace = false }) {
title = String(title || '').trim();
if (title.length > 120) throw new Error('invalidTitle');
@@ -45,6 +66,13 @@
const film = filmFor(mood, Number(energy)), now = new Date().toISOString();
const memory = { ...old, id: old?.id || `memory_${crypto.randomUUID()}`, date, title, text: String(text).trim(), mood, energy: Number(energy), tags: [...new Set(tags.map(tag => String(tag).trim()).filter(Boolean))].slice(0, 12), location: String(location).trim().slice(0, 100), taskId, filmTitle: film.filmTitle, filmSubtitle: film.filmSubtitle, filmLine: film.filmLine, createdAt: old?.createdAt || now, updatedAt: now };
save('lifeos_memories', [...all.filter(item => item.date !== date), memory].sort((a, b) => b.date.localeCompare(a.date))); renderAll(); return memory;
},
deleteMemory(id) {
const all = mems(), memory = all.find(item => item.id === id);
if (!memory) throw new Error('notFound');
save('lifeos_memories', all.filter(item => item.id !== id));
save('lifeos_museum', museum().filter(item => item.memoryId !== id));
renderAll(); return memory;
}
};
})();