Class: ClaudeTaskMaster::Loop

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_task_master/loop.rb

Overview

The main work loop Keeps calling Claude until success criteria met

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state:, model: 'sonnet', **opts) ⇒ Loop

Options:

no_merge: Don't auto-merge PRs, require manual merge
max_sessions: Stop after N sessions
pause_on_pr: Pause after creating each PR for review
verbose: Show verbose output


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/claude_task_master/loop.rb', line 16

def initialize(state:, model: 'sonnet', **opts)
  @state = state
  @claude = Claude.new(model:)
  @pastel = Pastel.new
  @options = {
    no_merge: opts[:no_merge] || false,
    max_sessions: opts[:max_sessions],
    pause_on_pr: opts[:pause_on_pr] || false,
    verbose: opts[:verbose] || false
  }
  @session_count = 0
end

Instance Attribute Details

#claudeObject (readonly)

Returns the value of attribute claude.



9
10
11
# File 'lib/claude_task_master/loop.rb', line 9

def claude
  @claude
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/claude_task_master/loop.rb', line 9

def options
  @options
end

#pastelObject (readonly)

Returns the value of attribute pastel.



9
10
11
# File 'lib/claude_task_master/loop.rb', line 9

def pastel
  @pastel
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/claude_task_master/loop.rb', line 9

def state
  @state
end

Instance Method Details

#resumeObject

Resume from existing state



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/claude_task_master/loop.rb', line 47

def resume
  unless state.exists?
    raise ConfigError, 'No existing state found. Start fresh with a goal.'
  end

  current_state = state.load_state
  puts pastel.cyan("Resuming claude-task-master...")
  puts pastel.dim("Goal: #{state.goal[0..100]}#{'...' if state.goal.length > 100}")
  puts pastel.dim("Status: #{current_state[:status]}")
  puts pastel.dim("Session: #{current_state[:session_count]}")
  show_options
  puts

  if current_state[:status] == 'planning'
    plan_phase
  end

  work_loop
end

#run(goal:, criteria:) ⇒ Object

Run the full loop from start



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/claude_task_master/loop.rb', line 30

def run(goal:, criteria:)
  puts pastel.cyan("Starting claude-task-master...")
  puts pastel.dim("Goal: #{goal[0..100]}#{'...' if goal.length > 100}")
  show_options
  puts

  # Initialize state
  state.init(goal:, criteria:)

  # Phase 1: Planning
  plan_phase

  # Phase 2: Work loop
  work_loop
end