Class: RubynCode::CLI::Commands::Rewind

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/rewind.rb

Overview

‘/rewind` — restore the session to an earlier checkpoint, mirroring Claude Code’s /rewind. A checkpoint is taken at the start of each user turn, capturing the conversation and the original contents of any files changed that turn.

/rewind                list checkpoints
/rewind <id>           restore code + conversation to checkpoint <id>
/rewind <id> code      restore only the files
/rewind <id> chat      restore only the conversation

Constant Summary collapse

SCOPES =
{ 'code' => :code, 'chat' => :chat, 'both' => :both }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, all_names, hidden?

Class Method Details

.command_nameObject



16
# File 'lib/rubyn_code/cli/commands/rewind.rb', line 16

def self.command_name = '/rewind'

.descriptionObject



17
# File 'lib/rubyn_code/cli/commands/rewind.rb', line 17

def self.description  = 'Rewind to an earlier checkpoint (/rewind to list)'

Instance Method Details

#execute(args, ctx) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/rubyn_code/cli/commands/rewind.rb', line 21

def execute(args, ctx)
  manager = ctx.checkpoint_manager
  return ctx.renderer.info('Checkpoints are not available in this session.') unless manager

  id = args.first
  return list(manager, ctx) if id.nil?

  restore(manager, ctx, id, args[1])
end