Skip to content

feat: add --yes and --dry-run to deletes, from cli-core's confirmation flow - #205

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
Contributor

Bumps @todoist/cli-core to 2.1.0 and moves ol document delete, ol collection delete and ol attachment delete onto its shared confirmation flow (requireConfirmation and previewUnlessConfirmed, added in todoist/cli-core#198), so deletes confirm the same way as in todoist-cli and the other CLIs.

  • --yes deletes. Without it, a delete now previews what it would delete (Would delete document: <title> (<urlId>), then Use --yes to confirm.) and exits 0, where it used to fail with CONFIRMATION_REQUIRED.
  • --dry-run prints the standard [dry-run] Would delete …: rows, or under --json a { status: "preview", command, messages } object. Documents and collections are resolved first (a read) so the preview can name them; an attachment is previewed by id.
  • --json is new on the deletes. Without --yes or --dry-run it fails with CONFIRMATION_REQUIRED ("Pass --yes to execute ol document delete, or --dry-run to preview it.") before any API call. With --yes it prints { id, deleted: true }, the shape comms-cli and twist-cli use.
  • --confirm still works as a hidden alias of --yes, so existing scripts keep deleting. That's why this is a feat rather than a breaking change: the error code is the same, and only its message and the human no-flag behaviour change.

The old error went through formatError and process.exit(1), which ignored --json; the new one is thrown and printed by the global handler, as JSON under --json. The flags live in addDeleteOptions (src/lib/delete-options.ts). SKILL_CONTENT, the README, AGENTS.md, CODEBASE.md and the agent skills and checks now describe --yes and --dry-run instead of --confirm.

Checked against a real Outline account with read-only previews only: ol doc delete <urlId>, --dry-run and --dry-run --json named the document and deleted nothing, and ol attachment delete <id> --json failed with CONFIRMATION_REQUIRED and its hint without a request. No real delete was run.

…n flow

Bump @todoist/cli-core to 2.1.0 and move ol document delete, ol
collection delete and ol attachment delete onto its requireConfirmation
and previewUnlessConfirmed, so deletes confirm the same way as in the
other CLIs:

- --yes deletes. Without it a delete previews what it would delete and
  exits 0, instead of failing with CONFIRMATION_REQUIRED.
- --dry-run prints the standard [dry-run] preview, or under --json a
  { status: "preview", command, messages } object.
- --json is new on deletes. Without --yes or --dry-run it fails with
  CONFIRMATION_REQUIRED before any API call; with --yes it prints
  { id, deleted: true }.
- --confirm keeps working as a hidden alias of --yes.

The old error went through formatError and process.exit, which ignored
--json; the new one is thrown and rendered by the global handler.
@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 PR bumps @todoist/cli-core to 2.1.0 and moves the document, collection and attachment delete commands onto the shared requireConfirmation / previewUnlessConfirmed flow, adding --yes and --dry-run, a consistent --json shape, and keeping the hidden --confirm alias so existing scripts keep working. No inline issues were flagged in the review — reviewers confirmed the confirmation gating happens before any API call, the output and docs (SKILL_CONTENT, README, AGENTS.md, CODEBASE.md, agent checks) match the implementation, and the change introduces no security concerns. Two minor reuse notes surfaced in general review: the new delete output path hand-rolls JSON serialization instead of routing through the shared output helper, and it skips --ndjson support that sibling commands on the same files provide — both worth a look in a follow-up if you want the delete commands fully aligned with the rest of the surface.

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

Optional follow-up notes (2)
  • P3 src/commands/document.ts:304: The dry-run details label ID: document.urlId shows the URL slug, but the delete then calls documents.delete with document.id (line 310), a different value. The collection delete's dry-run shows the actual ID under the same ID: label, so the label means different things across the two commands. Either print document.id here, or label the row URL ID so users aren't shown a value under ID that isn't the one used for the deletion.
  • P3 src/lib/delete-options.ts:29: printDeleted writes JSON by hand with JSON.stringify, bypassing outputItem / formatJson from src/lib/output.ts, which AGENTS.md and .agents/checks/architecture.md say all command output goes through. Every delete command will now inherit this, so it's worth routing it through the shared helper — e.g. outputItem({ id, deleted: true }, () => 'Deleted.', ['id', 'deleted'], { json: opts.json }) — so --json formatting and any future output-mode changes stay in one place.

Share Feedback • Review Logs • Trace

The document delete dry run printed the URL id under "ID", while the
delete itself uses the document id, and collection delete's "ID" row
is the real id. Print the real id under "ID" and the URL id under
"URL ID". The delete result now goes through outputItem like other
command output, rather than serialising JSON by hand.
@scottlovegrove scottlovegrove added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Dec 3, 2026
@scottlovegrove
scottlovegrove merged commit 5215467 into main Dec 3, 2026
5 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/adopt-cli-core-confirmation branch December 3, 2026 14:22
doist-release-bot Bot added a commit that referenced this pull request Dec 3, 2026
## [3.2.0](v3.1.8...v3.2.0) (2026-12-03)

### Features

* add --yes and --dry-run to deletes, from cli-core's confirmation flow ([#205](#205)) ([5215467](5215467))
scottlovegrove added a commit that referenced this pull request Dec 3, 2026
The 3.2.0 release failed because publishing ran the agent tooling's
tests: `prepublishOnly` runs `npm test`, which included
`.agents/scripts/**`, and `lib/patches.test.ts` timed out on the release
runner. Publishing should test what it is about to publish, not the
tooling that checks our own work.

`npm test` (and so `prepublishOnly` and `pre-push`) now covers only
`src/`. The agent tooling's tests run with `npm run test:agents` from a
new `vitest.agents.config.ts`, as a separate "Run agent tooling tests"
step in `test.yml`, which now also runs on every push to `main` and
`next`, so both suites run on every pull request and every merge without
being on the publish path.

`npm run verify` gains a `tests:agents` step that starts after the
package tests and has `onlyWhenChanged`: it runs when a path the agent
tests read changed since `main` (`.agents/`, `vitest.agents.config.ts`,
`package.json`, `package-lock.json`, `.github/workflows/`,
`lefthook.yml`, `.claude/`, `.codex/`, `.cursor/`, `.pi/`, the agent
docs, `src/_fixtures/`, `.oxfmtrc.json`, `tsconfig.json`, `.gitignore`),
when a file was deleted or renamed (the agent docs may name it), and
when nothing changed. Otherwise it prints that it skipped them and that
CI runs them on every pull request. A skipped step counts as passed, so
steps after it still run. A test checks every path in the list exists,
apart from `.cursor/`, which must stay free of a hooks file.

This releases 3.2.1, which ships the confirmation-flow change from #205.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚢 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