Class: Aidp::CLI::ToolsCommand
- Inherits:
-
Object
- Object
- Aidp::CLI::ToolsCommand
- Defined in:
- lib/aidp/cli/tools_command.rb
Overview
CLI commands for managing tool metadata
Provides commands for:
-
aidp tools lint - Validate all metadata
-
aidp tools info <id> - Display tool details
-
aidp tools reload - Force cache regeneration
-
aidp tools list - List all tools
Instance Method Summary collapse
-
#initialize(project_dir: Dir.pwd, prompt: TTY::Prompt.new, query_class: nil) ⇒ ToolsCommand
constructor
Initialize tools command.
-
#run(args) ⇒ Integer
Run tools command.
-
#run_info(tool_id) ⇒ Object
Run info command.
-
#run_lint ⇒ Object
Run lint command.
-
#run_list ⇒ Object
Run list command.
-
#run_reload ⇒ Object
Run reload command.
-
#show_help ⇒ Object
Show help message.
Constructor Details
#initialize(project_dir: Dir.pwd, prompt: TTY::Prompt.new, query_class: nil) ⇒ ToolsCommand
Initialize tools command
25 26 27 28 29 |
# File 'lib/aidp/cli/tools_command.rb', line 25 def initialize(project_dir: Dir.pwd, prompt: TTY::Prompt.new, query_class: nil) @project_dir = project_dir @prompt = prompt @query_class = query_class || Metadata::Query end |
Instance Method Details
#run(args) ⇒ Integer
Run tools command
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 |
# File 'lib/aidp/cli/tools_command.rb', line 35 def run(args) subcommand = args.shift case subcommand when "lint" run_lint when "info" tool_id = args.shift unless tool_id @prompt.say("Error: tool ID required") @prompt.say("Usage: aidp tools info <tool_id>") return 1 end run_info(tool_id) when "reload" run_reload when "list" run_list when nil, "help", "--help", "-h" show_help 0 else @prompt.say("Unknown subcommand: #{subcommand}") show_help 1 end end |
#run_info(tool_id) ⇒ Object
Run info command
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/aidp/cli/tools_command.rb', line 117 def run_info(tool_id) Aidp.log_info("tools", "Showing tool info", tool_id: tool_id) cache = create_cache query = @query_class.new(cache: cache) tool = query.find_by_id(tool_id) unless tool @prompt.error("Tool not found: #{tool_id}") return 1 end display_tool_details(tool) 0 end |
#run_lint ⇒ Object
Run lint command
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 110 111 112 |
# File 'lib/aidp/cli/tools_command.rb', line 78 def run_lint Aidp.log_info("tools", "Running tool metadata lint") @prompt.say("\nValidating tool metadata...") cache = create_cache query = @query_class.new(cache: cache) begin query.directory rescue => e @prompt.error("Failed to load tool directory: #{e.}") Aidp.log_error("tools", "Lint failed", error: e.) return 1 end # Reload to get fresh validation tools = load_all_tools validator = Metadata::Validator.new(tools) results = validator.validate_all # Display results display_lint_results(results) # Write error log if there are errors invalid_results = results.reject(&:valid) if invalid_results.any? log_path = File.join(@project_dir, ".aidp", "logs", "metadata_errors.log") validator.write_error_log(results, log_path) @prompt.warn("\nError log written to: #{log_path}") end invalid_results.empty? ? 0 : 1 end |
#run_list ⇒ Object
Run list command
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/aidp/cli/tools_command.rb', line 156 def run_list Aidp.log_info("tools", "Listing all tools") cache = create_cache query = @query_class.new(cache: cache) query.directory stats = query.statistics @prompt.say("\nTool Directory Statistics:") @prompt.say(" Total tools: #{stats["total_tools"]}") @prompt.say(" By type:") stats["by_type"].each do |type, count| @prompt.say(" #{type}: #{count}") end @prompt.say("\nAll Tools:") # Group by type %w[skill persona template].each do |type| tools = query.find_by_type(type) next if tools.empty? @prompt.say("\n#{type.capitalize}s (#{tools.size}):") display_tools_table(tools) end 0 end |
#run_reload ⇒ Object
Run reload command
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/aidp/cli/tools_command.rb', line 136 def run_reload Aidp.log_info("tools", "Reloading tool directory") @prompt.say("\nRegenerating tool directory cache...") cache = create_cache begin cache.reload @prompt.ok("Tool directory cache regenerated successfully") rescue => e @prompt.error("Failed to reload cache: #{e.}") Aidp.log_error("tools", "Reload failed", error: e.) return 1 end 0 end |
#show_help ⇒ Object
Show help message
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/aidp/cli/tools_command.rb', line 64 def show_help @prompt.say("\nAIDP Tools Management") @prompt.say("\nUsage:") @prompt.say(" aidp tools lint Validate all tool metadata") @prompt.say(" aidp tools info <id> Show detailed tool information") @prompt.say(" aidp tools reload Force regenerate tool directory cache") @prompt.say(" aidp tools list List all available tools") @prompt.say("\nExamples:") @prompt.say(" aidp tools lint") @prompt.say(" aidp tools info ruby_rspec_tdd") @prompt.say(" aidp tools reload") end |