Skip to content

feat!: use cli-core's confirmation flow for destructive commands - #141

Merged
scottlovegrove merged 2 commits into
mainfrom
scottl/adopt-cli-core-confirmation
Dec 3, 2026
Merged

scottlovegrove merged 2 commits into
mainfrom
scottl/adopt-cli-core-confirmation

Conversation

@scottlovegrove

Copy link
Copy Markdown
Collaborator

Bumps @todoist/cli-core to 2.1.0 and moves tdc's --yes / --dry-run flow onto the shared helpers from todoist/cli-core#198, so destructive commands behave the same way in tdc as in td (todoist/todoist-cli#734).

  • channel delete, comment delete, msg delete, groups delete, thread delete, thread done/undone and conversation done/undone call requireConfirmation before any request and previewUnlessConfirmed once the target is resolved. Without --yes they print the same Would … line and Use --yes to confirm. as before. channel delete now names the resolved channel (Would delete: Engineering (id:CH500)) rather than echoing the ref, and channel/comment/msg delete now look the target up before showing that preview.
  • Bulk thread mark-read / mark-unread use requireConfirmation for their guard but keep their own per-thread preview rows (dryRun: true under --json), since a multi-thread plan doesn't fit the single-message envelope.
  • Every printDryRun caller imports it from cli-core. The local copy and its tests are gone; cli-core tests the same cases and its version is identical.
  • The skill content documents the contract, and CODEBASE.md points at channel/delete.ts as the example.

This is breaking for scripts, hence feat!: under --json without --yes or --dry-run, these commands now fail with CONFIRMATION_REQUIRED ("Pass --yes to execute , or --dry-run to preview it.") instead of MISSING_YES_FLAG, and they fail before any API call. --dry-run --json now prints a { "status": "preview", "command", "messages" } object instead of the plain-text preview. MISSING_YES_FLAG is no longer used anywhere and has been removed from the error codes.

Checked with npm run verify, and with the built CLI: tdc thread done <ref> --json fails with CONFIRMATION_REQUIRED, and tdc thread done <ref> --dry-run --json on a real inbox thread prints the preview envelope without changing anything.

Bump @todoist/cli-core to 2.1.0 and move tdc's --yes / --dry-run
flow onto its shared helpers, so it behaves like the other Todoist
CLIs:

- channel delete, comment delete, msg delete, groups delete, thread
  delete, thread done/undone and conversation done/undone call
  requireConfirmation before any request and previewUnlessConfirmed
  once the target is resolved. Without --yes they print the same
  "Would ..." line and "Use --yes to confirm."; channel delete now
  names the resolved channel rather than echoing the ref.
- bulk thread mark-read / mark-unread use requireConfirmation for
  their guard and keep their per-thread preview rows.
- every printDryRun caller imports it from cli-core, and the local
  copy and its tests are gone (cli-core tests the same cases).

BREAKING CHANGE: a destructive command run with --json but without
--yes or --dry-run now fails with CONFIRMATION_REQUIRED ("Pass --yes
to execute <command>, or --dry-run to preview it.") instead of
MISSING_YES_FLAG, and fails before any API call. --dry-run --json now
prints a { "status": "preview", "command", "messages" } object
instead of the plain-text dry-run preview.
@scottlovegrove scottlovegrove self-assigned this Dec 3, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migrates the destructive commands (channel/comment/msg/thread delete, thread and conversation done/undone, bulk mark-read/mark-unread) onto cli-core 2.1.0's shared confirmation helpers, replacing the local printDryRun and retiring MISSING_YES_FLAG in favor of CONFIRMATION_REQUIRED that fires before any API call, with a new JSON preview envelope. It's a clean, internally consistent migration: handler wiring, tests, skill content, and docs all line up, and the security-sensitive ordering (private-channel and ownership checks still precede previews) is preserved.

Few things worth tightening:

  • The channel delete tests pass Engineering as the ref while the resolved channel is also named Engineering, so the assertions can't tell whether the preview uses the resolved channel or echoes the ref — the exact behavior this PR changes. Use a ref that differs from the name (e.g. CH500 or eng) so Would delete: Engineering (id:CH500) only passes when the resolved name is used.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (2)
  • P3 src/commands/thread/helpers.ts:141: needsConfirmation on line 140 already encodes this bulk guard, so if (rawRefs.length > 1) reads as if requireConfirmation fires even with --yes/--dry-run. Reuse the variable (if (needsConfirmation)) — cli-core's helper no-ops on --yes/--dry-run, so the behaviour is unchanged — and there's a single expression of the condition to keep in sync.
  • P3 src/commands/thread/thread.test.ts:2102: This preview test only checks the output envelope. The fixture thread isn't archived, so a regression that ignored --dry-run and archived anyway would be caught only by the extra result log, not by a direct side-effect assertion. Add expect(client.inbox.archiveThread).not.toHaveBeenCalled(), matching the new preview tests for thread delete/channel delete/etc. Same gap in the conversation done preview test (conversation.test.ts:1228), where conversations.archiveConversation should be asserted not called.

Share Feedback • Review Logs • Trace

Comment thread src/commands/channel/channel.test.ts Resolved
The channel delete preview tests passed the channel's own name as the
ref, so they could not tell the resolved name from an echo of the ref.
Use a different ref. The thread and conversation done --dry-run --json
tests now also assert nothing was archived, and the bulk read-state
guard reuses needsConfirmation instead of restating the condition.
@scottlovegrove scottlovegrove added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Dec 3, 2026
@scottlovegrove
scottlovegrove merged commit 92541cb into main Dec 3, 2026
5 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/adopt-cli-core-confirmation branch December 3, 2026 14:21
doist-release-bot Bot added a commit that referenced this pull request Dec 3, 2026
## [6.0.0](v5.6.0...v6.0.0) (2026-12-03)

### ⚠ BREAKING CHANGES

* use cli-core's confirmation flow for destructive commands (#141)

### Features

* use cli-core's confirmation flow for destructive commands ([#141](#141)) ([92541cb](92541cb))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 🚢 Ship PR requires passing checks before merge, but no independent human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants