How I built self‑maintaining projects for my desktop AI companion: folder attach, one work‑log line, and a session‑scoped undo
Описание и применение
Автор создал систему, где AI‑компаньон автоматически определяет проект по каталогу, записывает одну строку журнала работы за каждый ход, синхронизирует задачи и поддерживает отмену только своих записей в рамках сессии.
Задача
The assistant either remembered nothing about the current project or everything globally, causing notes from one project to bleed into another.
Результат
The companion now automatically maintains a per‑project work log and todo list, supports deterministic undo of its own actions, and avoids cross‑project contamination.
Рабочий процесс
- Detect project by matching the current working directory against stored roots, using strict boundary checks and longest‑match rule.
- If a project is detected, set the session prompt to that project without changing the saved active project.
- After each turn, append one work‑log line summarizing file changes (max 400 chars, first 5 filenames).
- Sync the session checklist: add up to 5 new todos, close matching open todos, tag all entries with source {kind:"auto‑worklog",sessionId,turnId}.
- If the turn has no file changes or checklist movement, write nothing (no‑work).
- Maintain a file lock to prevent interleaved writes; skip the turn if the lock is held.
- Keep the work‑log bounded to 100 entries, dropping the oldest.
- Provide an optional background extraction pass (PROJECT_INLINE_CONSOLIDATION=on) that reads the session journal once it reaches 400 chars and extracts decisions and todos.
- Implement /project undo to delete all entries whose source kind starts with "auto" and matches the current session id, reopening any auto‑closed todos.
- Report the count of undone entries.
Доказательства
I work across several folders in a day — Ankita itself, a demo site, a scratch repo — and every assistant I tried either remembered nothing about the project I was in, or remembered everything globally, so notes from one project bled into another.
A project is a root path plus notes, decisions, todos, and a work log, stored in src/memory/projects.mjs (ProjectStore).
After each turn, maintainTurn in src/memory/project-maintenance.mjs writes what the turn did into its project.
/project undo calls removeAutoEntries with the current session id, and it deletes only entries whose source kind starts with auto and matches that session.
- Дата записи: 2026-11-01T19:59:02.068Z