Require --force to delete a chat line when nobody can confirm it
Rebased onto main. This was stacked on #652, which has since merged; the branch has been rebased so the diff is this PR's own 6 files and nothing else. Earlier review comments referring to a stacked base or a larger changed-file count predate that rebase.
⚠️ BREAKING
basecamp chat delete <id> now fails without --force in machine-output modes (--agent, --json, --quiet, config-driven json/quiet, BASECAMP_NONINTERACTIVE) and wherever stdin cannot answer a prompt. Add --force to restore the previous behavior. The flag is unchanged and was already the documented form in SKILL.md.
The problem
A chat line delete is permanent — the API does not trash it. It used to happen unconfirmed in exactly the modes where nobody could object.
Machine-output mode skips the confirmation prompt, which is right. But it then deleted anyway: basecamp chat delete <id> --json destroyed a message with no statement of intent anywhere in the invocation and nobody in a position to object. Skipping a confirmation is not the same as answering one.
TestChatDeleteSkipsPromptInAgentMode pinned that behavior. It is inverted here.
The invariant
A permanent delete happens only with --force, or with a confirmation that will be shown and can be answered. Three outcomes, no fourth:
--force | proceed — intent stated |
| a prompt that will be shown and can be answered | ask, and honor the answer |
| anything else | refuse, naming --force, before any request |
"Anything else" merges two cases that used to end differently:
- Machine mode skipped the prompt and deleted regardless.
- A terminal with redirected stdin did show the prompt —
isMachineOutputreads flags, the env var and stdout, never stdin — to a caller with nothing to type, where bubbletea waits on/dev/ttyrather than failing (the hang class from #652).
Same missing affirmation, so the same answer.
Placement and scope
The refusal lands before any account, project or chat lookup, so an invocation that cannot proceed does not spend two round trips discovering it. Asserted by a request counter, not by inspection.
isNonInteractiveCommand is read but not widened: missingArg and noChanges use it to choose between showing help and returning a structured error, and changing it would move behavior across many commands at once. This PR changes one command.
Tests
TestChatDeleteConfirmationMatrix covers agent / json / quiet / config-driven json / BASECAMP_NONINTERACTIVE / piped stdin / stdin on /dev/null, plus the forced positives, each asserting zero requests on refusal. Two e2e cases resolve before any request, so no cassette is needed — a delete that reached the wire would itself be the bug.
Release mechanics
- No
.surface-breakingentry belongs here. That file receives removed.surfacelines; the snapshot is unchanged at 18438 entries, becausechat deleteand--forceboth still exist. This is a behavioral break, not a surface removal, so that check will never fire on it — worth stating explicitly rather than leaving a reviewer to wonder. - The
breakinglabel is applied and is the sole input to the release notes' Breaking Changes section (.github/release.yml:8). There is no CHANGELOG to edit.
bin/ci green on this branch.
Summary by cubic
Require explicit intent for permanent chat deletes. Previously machine-output or undrivable prompts could delete without confirmation; now deletion only proceeds with --force or when a prompt will be shown and can be answered, and we refuse early with a usage hint naming --force.
- Bolded breadcrumbs now reflect the reader: for machine-readable output we append --force; for human formats we omit it. If a human format flag (
--styled,--md) overrides a machine-output config, we carry that flag so the suggestion remains runnable and confirmable. - Guard:
ensureDeleteConfirmablerefuses before any account/project/chat lookup whendeleteNeedsForceis true (set byBASECAMP_NONINTERACTIVE, by the rendered audience viaEffectiveFormatfor machine readers, or when stdin/stderr can’t answer a prompt). We do not widenisNonInteractiveCommand. - Tests/docs: invert the agent-mode test, add a confirmation matrix and bounded promptability checks, update e2e/smoke to pass --force under
--json, update help text examples, and clarify inskills/basecamp/SKILL.mdthat--forceis required.
Migration
- Add --force when deleting in
--agent,--json,--quiet, configjson|quiet, whenBASECAMP_NONINTERACTIVEis set, or when stdin/stderr are not terminals.