feat(checkpoint): add checkpoint list --json with --pending rewind-point view · Entire

feat(checkpoint): add checkpoint list --json with --pending rewind-point view

74673fc→main·

suhaanthayyil·2d ago·4 files·+443 added/-90 removed

Add machine-readable and pending-dataset modes to entire checkpoint list
so the deprecated rewind --list listing can be retired (see #1767):

The condensed --json path reuses the existing runExplainListJSON serializer.
The pending JSON shape lives in checkpoint_list.go (pendingRewindPointJSON) so
it survives independently of the rewind command; the rewind-point display label
is extracted into the shared rewindPointLabel used by both the interactive
rewind picker and the new --pending human view. --session is rejected with
--pending (the pending dataset is session-agnostic, matching rewind --list).

Removes the now-superseded rewind --list flag; the rewind action
(--to/--logs-only/--reset/interactive) is unchanged.

Changes

4

    52 unmodified lines
    ```
return cmd
}

// newCheckpointListCmd wraps the existing branch-default list view.
// newCheckpointListCmd wraps the existing branch-default list view and adds
// machine-readable (--json) and pending-rewind-point (--pending) modes.

// Dataset/format matrix:
//
//   (default)            condensed checkpoints on the branch, human view (pager)
//   --json               condensed checkpoints as JSON (branchCheckpointJSON shape)
//   --pending            live shadow-branch rewind points, human list
//   --pending --json     live shadow-branch rewind points as JSON — the drop-in
//                       replacement for the removed `rewind --list`
//
// The condensed dataset (entire/checkpoints/v1 for the branch) and the pending
// dataset (strategy.GetRewindPoints; task checkpoints, logs-only points,
// condensation IDs) are deliberately distinct — see issue #1767.
func newCheckpointListCmd() *cobra.Command {
    var sessionFlag string
    var noPagerFlag bool
    var jsonFlag bool
    var pendingFlag bool

cmd := &cobra.Command{ Use: "list", Short: "List checkpoints on the current branch", Long: `List checkpoints on the current branch.

Optionally filter by session ID with --session.`, By default shows condensed checkpoints from the checkpoints branch for the current branch. Use --pending to list the live session's shadow-branch rewind points instead (task checkpoints, logs-only points, condensation IDs).

Output modes: --json Machine-readable JSON instead of the human view. --pending Select the live shadow-branch rewind-point dataset. --pending --json Rewind points as JSON (replaces the removed rewind --list).

Optionally filter condensed checkpoints by session ID with --session (not applicable with --pending).`, RunE: func(cmd *cobra.Command, _ []string) error { if checkDisabledGuard(cmd.Context(), cmd.OutOrStdout()) { return nil } return runExplainBranchWithFilter(cmd.Context(), cmd.OutOrStdout(), cmd.ErrOrStderr(), noPagerFlag, sessionFlag) ctx := cmd.Context() w := cmd.OutOrStdout() errW := cmd.ErrOrStderr()

// --session filters the condensed dataset only; the pending dataset // mirrors the historical rewind --list, which had no session filter. if pendingFlag && sessionFlag != "" { return errors.New("--session cannot be combined with --pending") }

switch { case pendingFlag && jsonFlag: return runCheckpointPendingListJSON(ctx, w) case pendingFlag: return runCheckpointPendingListHuman(ctx, w) case jsonFlag: return runExplainListJSON(ctx, w, errW, sessionFlag, 0) default: return runExplainBranchWithFilter(ctx, w, errW, noPagerFlag, sessionFlag) } }, }

cmd.Flags().StringVar(&sessionFlag, "session", "", "Filter checkpoints by session ID (or prefix)") cmd.Flags().BoolVar(&noPagerFlag, "no-pager", false, "Disable pager output") cmd.Flags().BoolVar(&jsonFlag, "json", false, "Output as JSON instead of the human view") cmd.Flags().BoolVar(&pendingFlag, "pending", false, "List the live session's shadow-branch rewind points instead of condensed checkpoints") return cmd } ```

Changes

52 unmodified lines

List Actions

  1. List checkpoints on the current branch.

    • Optionally filter by session ID with --session.
  2. Console Output Modes:

    • --json: Machine-readable JSON instead of the human view.
    • --pending: Live shadow-branch rewind points, human list.
    • --pending --json: Live shadow-branch rewind points as JSON.

Functions