Class: ClaudeTaskMaster::CLI
- Inherits:
-
Thor
- Object
- Thor
- ClaudeTaskMaster::CLI
- Defined in:
- lib/claude_task_master/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clean ⇒ Object
- #comments(pr_number = nil) ⇒ Object
- #context ⇒ Object
- #default_action ⇒ Object
- #doctor ⇒ Object
- #logs ⇒ Object
- #plan ⇒ Object
- #pr(subcommand = 'status') ⇒ Object
- #progress ⇒ Object
- #resume ⇒ Object
- #start(goal) ⇒ Object
- #status ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
9 10 11 |
# File 'lib/claude_task_master/cli.rb', line 9 def self.exit_on_failure? true end |
Instance Method Details
#clean ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/claude_task_master/cli.rb', line 263 def clean state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No state directory to clean.") return end unless [:force] puts pastel.yellow("This will delete .claude-task-master/ and all session data.") print "Are you sure? (y/N) " response = $stdin.gets.chomp.downcase unless response == 'y' || response == 'yes' puts "Aborted." return end end FileUtils.rm_rf(state.dir) puts pastel.green("Cleaned up .claude-task-master/") end |
#comments(pr_number = nil) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/claude_task_master/cli.rb', line 325 def comments(pr_number = nil) state = State.new pastel = Pastel.new # Get PR number from state if not provided if pr_number.nil? && state.exists? current = state.load_state pr_number = current[:pr_number] end if pr_number.nil? puts pastel.yellow("No PR number provided and no active PR in state.") puts "Usage: claude-task-master comments 123" return end puts pastel.cyan.bold("PR ##{pr_number} Comments") puts if [:unresolved] threads = GitHub.unresolved_threads(pr_number.to_i) if threads.empty? puts pastel.green("No unresolved threads!") else puts pastel.yellow("#{threads.size} unresolved thread(s):") threads.each do |thread| puts puts pastel.dim(" Author: #{thread[:author]}") puts pastel.dim(" File: #{thread[:file_path]}:#{thread[:line]}") puts " #{thread[:body]&.lines&.first&.strip}" end end else all_comments = GitHub.pr_comments(pr_number.to_i) comments = [:actionable] ? all_comments.select(&:actionable?) : all_comments if comments.empty? puts pastel.green([:actionable] ? "No actionable comments!" : "No comments!") else comments.each do |comment| puts severity_badge(comment.severity, pastel) puts pastel.dim(" #{comment.file_path}:#{comment.line_range}") puts pastel.dim(" Author: #{comment.}") puts " #{comment.summary || comment.body&.lines&.first&.strip}" puts pastel.dim(" #{comment.html_url}") puts end end end rescue StandardError => e puts pastel.red("Error fetching comments: #{e.}") end |
#context ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/claude_task_master/cli.rb', line 287 def context state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No active task.") return end context_path = File.join(state.dir, 'context.md') if File.exist?(context_path) puts File.read(context_path) else puts pastel.dim("No context file yet.") end end |
#default_action ⇒ Object
412 413 414 415 416 417 418 419 |
# File 'lib/claude_task_master/cli.rb', line 412 def default_action state = State.new if state.exists? invoke :resume else invoke :help end end |
#doctor ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/claude_task_master/cli.rb', line 168 def doctor pastel = Pastel.new all_good = true puts pastel.cyan.bold("claude-task-master doctor") puts # Check Claude CLI print "Claude CLI: " if Claude.available? version = Claude.version puts pastel.green("#{version}") else puts pastel.red("NOT FOUND") puts pastel.dim(" Install: npm install -g @anthropic-ai/claude-code") all_good = false end # Check gh CLI print "GitHub CLI: " gh_version = `gh --version 2>&1`.split("\n").first rescue nil if gh_version puts pastel.green(gh_version) else puts pastel.red("NOT FOUND") puts pastel.dim(" Install: https://cli.github.com/") all_good = false end # Check gh auth print "GitHub Auth: " if GitHub.available? puts pastel.green("authenticated") else puts pastel.yellow("NOT AUTHENTICATED") puts pastel.dim(" Run: gh auth login") all_good = false end # Check git print "Git: " git_version = `git --version 2>&1`.strip rescue nil if git_version puts pastel.green(git_version) else puts pastel.red("NOT FOUND") all_good = false end # Check Ruby version print "Ruby: " if RUBY_VERSION >= '3.1.0' puts pastel.green("#{RUBY_VERSION}") else puts pastel.yellow("#{RUBY_VERSION} (recommend 3.1+)") end # Check current repo print "Git repo: " if system('git rev-parse --git-dir > /dev/null 2>&1') repo = GitHub.current_repo puts pastel.green(repo || 'local repo') else puts pastel.yellow("not in a git repository") end # Check for CLAUDE.md print "CLAUDE.md: " if File.exist?('CLAUDE.md') puts pastel.green("present") else puts pastel.dim("not found (optional)") end # Check for existing state print "State dir: " state = State.new if state.exists? current = state.load_state puts pastel.cyan("exists (status: #{current[:status]})") else puts pastel.dim("none") end puts if all_good puts pastel.green.bold("All prerequisites met!") else puts pastel.red.bold("Some prerequisites missing. Fix them before running.") exit 1 end end |
#logs ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/claude_task_master/cli.rb', line 133 def logs state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No active task.") return end logs_dir = File.join(state.dir, 'logs') log_files = Dir.glob(File.join(logs_dir, 'session-*.md')).sort if [:session] filename = format('session-%03d.md', [:session]) path = File.join(logs_dir, filename) if File.exist?(path) puts File.read(path) else puts pastel.red("Session #{[:session]} not found.") end else log_files.last([:last]).each do |path| puts pastel.cyan("=== #{File.basename(path)} ===") puts File.read(path) puts end end end |
#plan ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/claude_task_master/cli.rb', line 113 def plan state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No active task.") return end plan_content = state.plan if plan_content puts plan_content else puts pastel.yellow("No plan yet. Run 'claude-task-master resume' to generate one.") end end |
#pr(subcommand = 'status') ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/claude_task_master/cli.rb', line 380 def pr(subcommand = 'status') state = State.new pastel = Pastel.new pr_number = [:number] if pr_number.nil? && state.exists? current = state.load_state pr_number = current[:pr_number] end if pr_number.nil? puts pastel.yellow("No PR number provided and no active PR in state.") return end case subcommand when 'status', 'info' show_pr_info(pr_number, pastel) when 'checks', 'ci' show_pr_checks(pr_number, pastel) when 'merge' merge_current_pr(pr_number, pastel) else puts pastel.yellow("Unknown subcommand: #{subcommand}") puts "Available: status, checks, merge" end end |
#progress ⇒ Object
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/claude_task_master/cli.rb', line 305 def progress state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No active task.") return end progress_path = File.join(state.dir, 'progress.md') if File.exist?(progress_path) puts File.read(progress_path) else puts pastel.dim("No progress log yet.") end end |
#resume ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/claude_task_master/cli.rb', line 64 def resume check_prerequisites! state = State.new unless state.exists? pastel = Pastel.new puts pastel.red("No existing state found in .claude-task-master/") puts "Run 'claude-task-master start \"your goal\"' to begin." exit 1 end loop_opts = { no_merge: [:no_merge], max_sessions: [:max_sessions], pause_on_pr: [:pause_on_pr], verbose: [:verbose] } loop = Loop.new(state:, model: [:model], **loop_opts) loop.resume end |
#start(goal) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/claude_task_master/cli.rb', line 33 def start(goal) check_prerequisites! criteria = [:criteria] || prompt_for_criteria state = State.new loop_opts = { no_merge: [:no_merge], max_sessions: [:max_sessions], pause_on_pr: [:pause_on_pr], verbose: [:verbose] } loop = Loop.new(state:, model: [:model], **loop_opts) loop.run(goal:, criteria:) end |
#status ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/claude_task_master/cli.rb', line 86 def status state = State.new pastel = Pastel.new unless state.exists? puts pastel.yellow("No active task. Run 'claude-task-master start \"goal\"' to begin.") return end current = state.load_state puts pastel.cyan.bold("claude-task-master status") puts puts "Goal: #{state.goal}" puts "Criteria: #{state.criteria}" puts puts "Status: #{status_color(current[:status], pastel)}" puts "Current task: #{current[:current_task] || 'none'}" puts "PR: #{current[:pr_number] ? "##{current[:pr_number]}" : 'none'}" puts "Sessions: #{current[:session_count]}" puts "Started: #{current[:started_at]}" puts "Updated: #{current[:updated_at]}" puts puts "State dir: #{state.dir}" end |
#version ⇒ Object
163 164 165 |
# File 'lib/claude_task_master/cli.rb', line 163 def version puts "claude-task-master #{VERSION}" end |