( projectRoot: string, rec: Omit<TrajectoryRecord, 'ts' | 'project'>, )
| 59 | * swallowed — recording must never break a task that already succeeded. |
| 60 | */ |
| 61 | export async function recordTrajectory( |
| 62 | projectRoot: string, |
| 63 | rec: Omit<TrajectoryRecord, 'ts' | 'project'>, |
| 64 | ): Promise<void> { |
| 65 | try { |
| 66 | const full = trajectoryPath(projectRoot); |
| 67 | await fs.mkdir(path.dirname(full), { recursive: true }); |
| 68 | const line = JSON.stringify({ |
| 69 | ts: new Date().toISOString(), |
| 70 | project: projectRoot, |
| 71 | ...rec, |
| 72 | }); |
| 73 | await fs.appendFile(full, line + '\n', 'utf-8'); |
| 74 | logger.info('Trajectory recorded', { file: full, files: rec.filesChanged.length }); |
| 75 | } catch (e: any) { |
| 76 | logger.debug('Trajectory record failed (ignored)', { err: e?.message }); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /** Count trajectories recorded for a project (for the /flywheel status command). */ |
| 81 | export async function countTrajectories(projectRoot: string): Promise<number> { |
no test coverage detected