fix(#4096): honor --dry-run in todo complete and write completion keys inside the frontmatter fence (#4325)

* fix(#4096): honor --dry-run in todo complete and upsert completion keys inside the frontmatter fence

* review(#4096): tighten todo complete flag rejection to any dash-prefixed token

* chore(#4096): backfill PR number in changeset

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-05 13:49:58 -04:00
committed by GitHub
parent 3d03ae65e6
commit 7ff196c505
9 changed files with 225 additions and 15 deletions

View File

@@ -2699,7 +2699,20 @@ function dispatchOverlayCapabilityCommand({ command, args, cwd, raw, error, load
function routeTodo({ args, cwd, raw, error }) {
const subcommand = args[1];
if (subcommand === 'complete') {
commands.cmdTodoComplete(cwd, args[2], raw);
// #4096: this verb's flag surface is closed. `--dry-run` is parsed
// and plumbed (mirroring routeMilestone / #2118), and any OTHER
// flag fails loudly instead of being silently ignored — an
// accepted-but-ignored safety flag converts a deliberate preview
// into the mutation it was meant to avoid. (`--raw` is spliced by
// the dispatcher before routing; it stays in the set as a guard
// against that splice ever moving.)
const TODO_COMPLETE_KNOWN_FLAGS = new Set(['--dry-run', '--raw']);
for (const a of args.slice(3)) {
if (typeof a === 'string' && a.startsWith('-') && !TODO_COMPLETE_KNOWN_FLAGS.has(a)) {
error(`Unknown flag for todo complete: ${a}`, ERROR_REASON.USAGE);
}
}
commands.cmdTodoComplete(cwd, args[2], { dryRun: args.includes('--dry-run') }, raw);
} else if (subcommand === 'match-phase') {
commands.cmdTodoMatchPhase(cwd, args[2], raw);
} else {