Class: Ace::PromptPrep::CLI::Commands::Process

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/prompt_prep/cli/commands/process.rb

Overview

ace-support-cli Command class for the process command

This wraps the existing PromptProcessor logic in a ace-support-cli compatible interface, maintaining complete parity with the Thor implementation.

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



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
105
106
107
108
109
# File 'lib/ace/prompt_prep/cli/commands/process.rb', line 63

def call(**options)
  # Determine bundle flag
  bundle_enabled = determine_bundle_enabled(options)

  # Determine enhance flag
  enhance_enabled = determine_enhance_enabled(options)

  # Resolve task prompt path (handles both explicit --task and auto-detection)
  task_prompt_path = resolve_task_prompt_path(options[:task])

  # Process prompt
  result = Organisms::PromptProcessor.call(
    input_path: task_prompt_path,
    bundle: bundle_enabled,
    enhance: enhance_enabled,
    model: options[:model],
    system_prompt: options[:system_prompt]
  )

  unless result[:success]
    raise Ace::Support::Cli::Error.new(result[:error])
  end

  # Handle output
  output_mode = options[:output] || "-"

  if output_mode == "-"
    # Output to stdout
    puts result[:content]
  else
    # Write to file
    require "fileutils"
    FileUtils.mkdir_p(File.dirname(output_mode))

    begin
      File.write(output_mode, result[:content], encoding: "utf-8")
      # Output summary to stdout
      $stdout.puts "Prompt archived and saved:"
      $stdout.puts "  Archive: #{result[:archive_path]}"
      $stdout.puts "  Output:  #{File.expand_path(output_mode)}"
    rescue => e
      raise Ace::Support::Cli::Error.new("Failed to write output file: #{e.message}")
    end
  end
rescue Ace::PromptPrep::Error => e
  raise Ace::Support::Cli::Error.new(e.message)
end