(projectRoot: string, rec: Omit<Episode, 'ts'>)
| 44 | |
| 45 | /** Append one episode after an objectively-successful task. Best-effort. */ |
| 46 | export async function recordEpisode(projectRoot: string, rec: Omit<Episode, 'ts'>): Promise<void> { |
| 47 | try { |
| 48 | if (!rec.prompt.trim()) return; |
| 49 | const full = episodesPath(projectRoot); |
| 50 | await fs.mkdir(path.dirname(full), { recursive: true }); |
| 51 | await fs.appendFile(full, JSON.stringify({ ts: new Date().toISOString(), ...rec }) + '\n', 'utf-8'); |
| 52 | } catch (e: any) { |
| 53 | logger.debug('Episode not recorded', { err: e?.message }); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** Read this project's episodes (most recent `limit`). */ |
| 58 | export async function readEpisodes(projectRoot: string, limit = 500): Promise<Episode[]> { |
no test coverage detected