| 60 | // ── Fleet stats ─────────────────────────────────────────────────────────────── |
| 61 | |
| 62 | function readFleetStats() { |
| 63 | const sessions = []; |
| 64 | |
| 65 | if (!fs.existsSync(FLEET_DIR)) return { active_sessions: [], latest: null }; |
| 66 | |
| 67 | const files = fs.readdirSync(FLEET_DIR).filter(f => f.startsWith('session-') && f.endsWith('.md')); |
| 68 | |
| 69 | for (const f of files) { |
| 70 | const content = fs.readFileSync(path.join(FLEET_DIR, f), 'utf8'); |
| 71 | // Check for Status: active in frontmatter or body (case-insensitive) |
| 72 | if (/Status:\s*active/i.test(content)) { |
| 73 | sessions.push(f.replace(/\.md$/, '')); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | const latest = sessions.length > 0 ? sessions[sessions.length - 1] : null; |
| 78 | return { active_sessions: sessions, latest }; |
| 79 | } |
| 80 | |
| 81 | // ── Hook install check ──────────────────────────────────────────────────────── |
| 82 | |