diff --git a/src/cli.ts b/src/cli.ts index a7a9ed1af..07325cbf6 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -812,9 +812,30 @@ if (cliFlags.maintain) { const prefs = (loadEffectiveSFPreferences()?.preferences ?? {}) as Record; const coverage = computeBenchmarkCoverage(prefs); writeBenchmarkCoverage(coverage); + // Self-feedback triage drain. The daemon's 6h maintenance timer fires + // `sf --maintain` in every allowed repo (set via daemon config), so + // triage runs unattended across the whole project portfolio. Bounded + // at max=10 per invocation to keep each run finite. Items beyond the + // bound flush on subsequent maintenance ticks. + let triageCount = 0; + try { + const { handleTriage } = await import("./headless-triage.js"); + const triageResult = await handleTriage(process.cwd(), { + apply: true, + json: true, // suppress chatty stdout in the maintenance path + max: 10, + }); + triageCount = triageResult.exitCode === 0 ? 10 : 0; + } catch (err) { + process.stderr.write( + `[sf --maintain] triage drain failed (non-fatal): ${ + err instanceof Error ? err.message : String(err) + }\n`, + ); + } const ms = Date.now() - startedAt; process.stdout.write( - `[sf --maintain] catalog + quota refresh + coverage audit done in ${ms}ms — coverage ${coverage.summary.coveredCount}/${coverage.summary.total} (${coverage.uncovered.length} uncovered)\n`, + `[sf --maintain] catalog + quota refresh + coverage audit + triage drain done in ${ms}ms — coverage ${coverage.summary.coveredCount}/${coverage.summary.total} (${coverage.uncovered.length} uncovered), triage attempted up to ${triageCount} candidates\n`, ); } catch (err) { process.stderr.write(