also looking at this
fix(reports): honour reports.enabled and reports.period, drop the key nothing could read
#1429
7 files
+118
-9
| @@ -3172,6 +3172,7 @@ cli | ||
| 3172 | 3172 | .option('--format <name>', 'Output format: markdown|json', { default: 'markdown' }) |
| 3173 | 3173 | .option('--prompt <focus>', 'Focus for the AI narrative, when a provider is configured') |
| 3174 | 3174 | .option('--publish', 'Publish to the repository\'s report issue') |
| 3175 | .option('--scheduled', 'This is the workflow\'s scheduled run; honour reports.enabled') | |
| 3175 | 3176 | .option('--verbose, -v', 'Enable verbose logging') |
| 3176 | 3177 | .example('buddy report --period 7d') |
| 3177 | 3178 | .example('buddy report --prompt "focus on security posture" --publish') |
| @@ -3180,6 +3181,7 @@ cli | ||
| 3180 | 3181 | format?: string |
| 3181 | 3182 | prompt?: string |
| 3182 | 3183 | publish?: boolean |
| 3184 | scheduled?: boolean | |
| 3183 | 3185 | }) => { |
| 3184 | 3186 | const quiet = options.format === 'json' |
| 3185 | 3187 | const logger = options.verbose ? Logger.verbose() : quiet ? Logger.silent() : Logger.quiet() |
| @@ -3199,7 +3201,9 @@ cli | ||
| 3199 | 3201 | withNarrative, |
| 3200 | 3202 | } = await import('../src/reports') |
| 3201 | 3203 | |
| 3202 | const period = (options.period ?? '30d') as '7d' | '30d' | '90d' | |
| 3204 | // The flag wins, then config, then the default. `reports.period` was | |
| 3205 | // documented, defaulted and never consulted — only the flag was. | |
| 3206 | const period = (options.period ?? config.reports?.period ?? '30d') as '7d' | '30d' | '90d' | |
| 3203 | 3207 | if (!REPORT_PERIODS.includes(period)) { |
| 3204 | 3208 | logger.error(`❌ Unknown period '${period}'. Expected one of ${REPORT_PERIODS.join(', ')}.`) |
| 3205 | 3209 | process.exit(1) |
| @@ -3267,6 +3271,16 @@ cli | ||
| 3267 | 3271 | logger, |
| 3268 | 3272 | ) |
| 3269 | 3273 | |
| 3274 | // The generated workflow passes --scheduled, so this is where the | |
| 3275 | // documented "default: false" is actually enforced. It cannot be | |
| 3276 | // enforced in the workflow: a cron trigger cannot read the config. | |
| 3277 | const { shouldPublishReport } = await import('../src/reports') | |
| 3278 | const gate = shouldPublishReport({ scheduled: Boolean(options.scheduled), enabled: config.reports?.enabled }) | |
| 3279 | if (options.publish && !gate.publish) { | |
| 3280 | logger.info(`ℹ️ Not publishing: ${gate.reason}`) | |
| 3281 | return | |
| 3282 | } | |
| 3283 | ||
| 3270 | 3284 | if (!options.publish) { |
| 3271 | 3285 | process.stdout.write(`${report}\n`) |
| 3272 | 3286 | return |