Class: Ace::Git::Worktree::Commands::BootstrapCommand
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Commands::BootstrapCommand
- Defined in:
- lib/ace/git/worktree/commands/bootstrap_command.rb
Overview
Bootstrap command
Reruns recoverable preparation phases (toolchain trust and bootstrap policy) for an existing worktree in place.
Instance Method Summary collapse
-
#initialize(manager: nil) ⇒ BootstrapCommand
constructor
A new instance of BootstrapCommand.
-
#run(args = []) ⇒ Integer
Run bootstrap retry on existing worktree.
- #show_help ⇒ Object
Constructor Details
#initialize(manager: nil) ⇒ BootstrapCommand
Returns a new instance of BootstrapCommand.
18 19 20 |
# File 'lib/ace/git/worktree/commands/bootstrap_command.rb', line 18 def initialize(manager: nil) @manager = manager || Ace::Git::Worktree::Organisms::WorktreeManager.new end |
Instance Method Details
#run(args = []) ⇒ Integer
Run bootstrap retry on existing worktree
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ace/git/worktree/commands/bootstrap_command.rb', line 26 def run(args = []) = parse_arguments(args) return show_help if [:help] || [:identifier].nil? worktree_info = find_target_worktree([:identifier]) unless worktree_info puts "Error: Worktree matching '#{[:identifier]}' not found." return 1 end wt_path = worktree_info[:path] project_root = Dir.pwd config = Molecules::ConfigLoader.new(project_root).load_without_validation # Phase 1: Toolchain Trust truster = Molecules::ToolchainTruster.new(project_root: wt_path, policy: "required") trust_res = truster.verify_and_trust # Phase 2: Bootstrap execution executor = Molecules::BootstrapExecutor.new( project_root: project_root, worktree_path: wt_path, bootstrap_config: config.bootstrap, no_bootstrap: [:no_bootstrap] || false ) bootstrap_res = executor.run phases = [trust_res, bootstrap_res] req_failed = phases.any? { |p| p[:status] == "required_failed" } adv_failed = phases.any? { |p| p[:status] == "advisory_failed" } readiness = if req_failed "not_ready" elsif adv_failed "ready_with_warning" else "ready" end result = { identifier: [:identifier], worktree_path: wt_path, branch: worktree_info[:branch], readiness: readiness, phases: phases, retry_command: (readiness == "not_ready") ? "ace-git-worktree bootstrap #{[:identifier]}" : nil } if [:json] puts JSON.pretty_generate(result) else puts "Worktree Preparation Retry: #{wt_path}" puts "Readiness: #{readiness}" puts puts "Phases:" phases.each do |p| st = p[:status] icon = case st when "succeeded", "not_applicable" then "✓" when "skipped" then "↷" when "advisory_failed" then "⚠️" else "❌" end puts " #{icon} #{p[:phase]}: #{st}" puts " Command: #{p[:command]}" if p[:command] puts " Output: #{p[:output]}" if p[:output] && !p[:output].empty? && st.include?("failed") end if readiness == "not_ready" puts puts "Retry with: ace-git-worktree bootstrap #{[:identifier]}" end end (readiness == "not_ready") ? 1 : 0 rescue => e puts "Error: #{e.}" 1 end |
#show_help ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ace/git/worktree/commands/bootstrap_command.rb', line 106 def show_help puts <<~HELP ace-git-worktree bootstrap - Rerun preparation phases on existing worktree USAGE: ace-git-worktree bootstrap <identifier> [OPTIONS] OPTIONS: --json Output format as JSON --help, -h Show this help message EXAMPLES: ace-git-worktree bootstrap 081 ace-git-worktree bootstrap t.8vb.t.vyz.2 --json HELP 0 end |