* Synthesize a single "PROJECT MEMORY" brief, injected through the existing * facts path (see loop.ts), so a new/resumed session in this directory * automatically knows what was done here before — and continues instead of * redoing it. Returns null when there's nothing to brief, so the call
(cwd: string, limit = 12)
| 456 | } |
| 457 | |
| 458 | getWorklog(cwd: string, limit = 20): WorklogEntry[] { |
| 459 | return this.db.prepare( |
| 460 | `SELECT kind, entry, created_at FROM project_worklog WHERE cwd = ? ORDER BY id DESC LIMIT ?`, |
| 461 | ).all(cwd, limit) as WorklogEntry[]; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Synthesize a single "PROJECT MEMORY" brief, injected through the existing |
| 466 | * facts path (see loop.ts), so a new/resumed session in this directory |
| 467 | * automatically knows what was done here before — and continues instead of |
| 468 | * redoing it. Returns null when there's nothing to brief, so the caller skips |
| 469 | * injection cleanly. |
| 470 | */ |
| 471 | getProjectBriefingFact(cwd: string, limit = 12): string | null { |
| 472 | const project = this.getProject(cwd); |
| 473 | const log = this.getWorklog(cwd, limit); |
| 474 | if (!project && log.length === 0) return null; |
| 475 | |
| 476 | const lines: string[] = []; |
| 477 | lines.push('PROJECT MEMORY — what was done in this project in earlier sessions (most recent first).'); |
| 478 | if (project) { |
| 479 | lines.push(`Project: ${project.name}${project.description ? ` — ${project.description}` : ''}`); |
| 480 | } |
| 481 | if (log.length) { |
| 482 | for (const e of log) { |
no test coverage detected