Add `todolists position` to reorder to-do lists (#484)
Closes #484.
Adds basecamp todolists position <id|url>... to reorder a to-do list within its todoset. todos and todolistgroups already had position; to-do lists could only be created/updated/archived/restored/trashed, so a multi-phase plan displayed newest-first with no CLI fix short of the raw api passthrough looped in reverse.
Behavior
- Single list:
basecamp todolists position 789 --to 1— one explicit 1-based position (1 = top).--torequired. - Bulk order:
basecamp todolists position 701 702 703 704 705— sets the visible order top-to-bottom. Accepts several incomplete lists from the same todoset; always places them at the top (position 1).
ID / URL args only, matching todolists show/update (no name resolution, no --todoset).
Why the restrictions
- Bulk is position-1 only. Reverse-iterating N lists onto the same slot only reconstructs the typed order when the slot is
1; for a baseN > 1, whether a list lands above or below the block depends on where it started, on the server'sposition_offsetfor loose to-dos, and on hidden completed lists.2+IDs with any--toother than 1 is a usage error. - Bulk rejects completed lists. The dedicated controller positions among visible/incomplete siblings only. Preflight
Gets every list and rejects anyCompleted == true(naming it) before issuing any PUT. - Same-todoset preflight. Syntax can't tell that five IDs share one todoset; bulk requires identical
Parent.ID/Bucket.ID(and non-nil parent/bucket) before mutating, so lists from different todosets aren't independently reordered while the output claims one order. - Fail fast, count applied. A half-applied reorder is a wrong order, so it stops at the first error and reports applied-vs-attempted (e.g.
Reordered 1 of 3 todolists; failed at #702), hinting to rerun the whole command.
Dedicated route (please don't "simplify" this)
Uses PUT /todosets/todolists/{id}/position.json, not the generic /recordings/{id}/position.json the issue's workaround used. The generic route skips the to-do-list position math and mis-places lists when loose to-dos or hidden completed lists exist.
Naming
Follows the to-do family: canonical position, aliases move/reorder, --to leading in help with --position accepted for parity. A to-do list has no destination container, so --to N is unambiguously an index (no clash with cards move --to <column>).
SDK
Bumped to 93ace8d5 (basecamp-sdk#398, TodolistsService.Reposition) as a pseudo-version — no wait for a v0.8.1 tag. The same span also absorbs, both benign:
- #396 —
Templates.CreateProjectrequest-envelope fix; internal, signature unchanged, no CLI edit. - #392 — SDK tests only.
Only one new SDK service method arrived, so the completeness bar is satisfied by this one command.
Tests
- Unit (
internal/commands/todolists_test.go): guard tests + request-level tests asserting reverse apply order and{"position":1}bodies, single-list body, same-parent/nil/completed rejection with zero PUTs, preflight-failure = zero mutations, partial-failure accounting (exactly two PUTs,Code/HTTPStatuspreserved), output shape, and every breadcrumb variant. - e2e usage tests (
errors.bats), a smoke test (smoke_todos_write.bats, run before archive so the target is active), and alias OOS markers (smoke_aliases.bats). API-COVERAGE.md, catalog,SKILL.md, and.surfaceupdated. Fullbin/cigreen.
Summary by cubic
Adds basecamp todolists position to reorder to‑do lists within a todoset, covering the last missing reposition action in the to‑do family. Supports single moves and a safe bulk top‑of‑list reorder, with improved error handling that preserves underlying codes and warns on partial reorders. Closes #484.
-
New Features
- Command:
basecamp todolists position <id|url>...(aliases:move,reorder). - Single:
--to Nrequired (1-based). - Bulk: same‑todoset, incomplete only; always places at top; applies in reverse to preserve typed order; fails fast. Preserves underlying error code/status/hint; adds applied-count + rerun hint only when some changes landed (includes transport/runtime failures).
- URL guard: accepts only non-collection
todolistsURLs; rejectstodo/card/collection URLs. - Uses
PUT /todosets/todolists/{id}/position.json; adds breadcrumbs when project context is known.
- Command:
-
Dependencies
- Bump
github.com/basecamp/basecamp-sdk/gotov0.8.1-0.20260724184307-e2c1abea4aeaaddingTodolists.Reposition. Also includes create-timevisible_to_clientssupport fortodolists create, and a templates request-envelope fix (no CLI behavior change here).
- Bump