| 371 | } |
| 372 | |
| 373 | // Check if a fleet session merged cleanly this session |
| 374 | const fleetDir = path.join(PROJECT_ROOT, '.planning', 'fleet'); |
| 375 | if (fs.existsSync(fleetDir)) { |
| 376 | const fleetFiles = fs.readdirSync(fleetDir).filter(f => f.endsWith('.md')); |
| 377 | for (const f of fleetFiles) { |
| 378 | try { |
| 379 | const content = fs.readFileSync(path.join(fleetDir, f), 'utf8'); |
| 380 | const stat = fs.statSync(path.join(fleetDir, f)); |
| 381 | if (stat.mtimeMs >= fiveMinutesAgo && /status:\s*completed/i.test(content) && !/conflict/i.test(content)) { |
| 382 | config.trust[counterKeys.fleetMerges] = (config.trust[counterKeys.fleetMerges] || 0) + 1; |
| 383 | break; |
| 384 | } |
| 385 | } catch { /* skip unreadable files */ } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | // Check if an improve loop completed this session |
| 390 | const improveLogsDir = path.join(PROJECT_ROOT, '.planning', 'improvement-logs'); |
| 391 | if (fs.existsSync(improveLogsDir)) { |
| 392 | try { |
| 393 | const targets = fs.readdirSync(improveLogsDir).filter(d => { |
| 394 | try { return fs.statSync(path.join(improveLogsDir, d)).isDirectory(); } catch { return false; } |
| 395 | }); |
| 396 | for (const target of targets) { |
| 397 | const loopFiles = fs.readdirSync(path.join(improveLogsDir, target)).filter(f => f.startsWith('loop-') && f.endsWith('.md')); |
| 398 | for (const lf of loopFiles) { |
| 399 | try { |