Class: Aidp::ToolingDetector
- Inherits:
-
Object
- Object
- Aidp::ToolingDetector
- Defined in:
- lib/aidp/tooling_detector.rb
Overview
Detect basic project tooling to seed work loop test & lint commands. Lightweight heuristic pass – prefers safety over guessing incorrectly. Provides framework-aware command suggestions with optimal flags for output filtering.
Defined Under Namespace
Classes: CommandInfo, Result
Constant Summary collapse
- DETECTORS =
[ :ruby_bundle, :rspec, :minitest, :ruby_standardrb, :node_jest, :node_mocha, :node_eslint, :python_pytest, :python_ruff ].freeze
- FRAMEWORKS =
Framework identifiers for output filtering
{ rspec: :rspec, minitest: :minitest, jest: :jest, mocha: :jest, # Mocha uses similar output format pytest: :pytest }.freeze
Class Method Summary collapse
- .detect(root = Dir.pwd) ⇒ Object
-
.framework_from_command(command) ⇒ Symbol
Detect framework from a command string.
-
.recommended_flags(framework) ⇒ Hash
Get recommended command flags for better output filtering.
Instance Method Summary collapse
- #detect ⇒ Object
-
#detect_with_details ⇒ Array<CommandInfo>
Get detailed command information including framework and suggested flags.
-
#initialize(root = Dir.pwd) ⇒ ToolingDetector
constructor
A new instance of ToolingDetector.
Constructor Details
#initialize(root = Dir.pwd) ⇒ ToolingDetector
Returns a new instance of ToolingDetector.
108 109 110 |
# File 'lib/aidp/tooling_detector.rb', line 108 def initialize(root = Dir.pwd) @root = root end |
Class Method Details
.detect(root = Dir.pwd) ⇒ Object
46 47 48 |
# File 'lib/aidp/tooling_detector.rb', line 46 def self.detect(root = Dir.pwd) new(root).detect end |
.framework_from_command(command) ⇒ Symbol
Detect framework from a command string
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/aidp/tooling_detector.rb', line 53 def self.framework_from_command(command) return :unknown unless command.is_a?(String) case command.downcase when /\brspec\b/ :rspec when /\bminitest\b/, /\bruby.*test/, /\brake test\b/ :minitest when /\bjest\b/, /\bmocha\b/ :jest when /\bpytest\b/ :pytest else :unknown end end |
.recommended_flags(framework) ⇒ Hash
Get recommended command flags for better output filtering
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 |
# File 'lib/aidp/tooling_detector.rb', line 73 def self.recommended_flags(framework) case framework when :rspec { standard: "--format progress", verbose: "--format documentation", failures_only: "--format failures --format progress" } when :minitest { standard: "", verbose: "-v", failures_only: "" } when :jest { standard: "", verbose: "--verbose", failures_only: "--reporters=default --silent=false" } when :pytest { standard: "-q", verbose: "-v", failures_only: "-q --tb=short" } else { standard: "", verbose: "", failures_only: "" } end end |
Instance Method Details
#detect ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/aidp/tooling_detector.rb', line 112 def detect tests = [] linters = [] formatters = [] frameworks = {} detect_ruby_tools(tests, linters, formatters, frameworks) detect_node_tools(tests, linters, formatters, frameworks) detect_python_tools(tests, linters, formatters, frameworks) result = Result.new( test_commands: tests.uniq, lint_commands: linters.uniq, formatter_commands: formatters.uniq, frameworks: frameworks ) # Store framework mappings in the result frameworks.each do |cmd, framework| result.test_command_frameworks[cmd] = framework end result end |
#detect_with_details ⇒ Array<CommandInfo>
Get detailed command information including framework and suggested flags
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/aidp/tooling_detector.rb', line 139 def detect_with_details commands = [] if ruby_project? if rspec? commands << CommandInfo.new( command: bundle_prefix("rspec"), framework: :rspec, flags: self.class.recommended_flags(:rspec) ) end if minitest? commands << CommandInfo.new( command: bundle_prefix("ruby -Itest test"), framework: :minitest, flags: self.class.recommended_flags(:minitest) ) end end if node_project? if jest? commands << CommandInfo.new( command: npm_or_yarn("test"), framework: :jest, flags: self.class.recommended_flags(:jest) ) end end if python_pytest? commands << CommandInfo.new( command: "pytest", framework: :pytest, flags: self.class.recommended_flags(:pytest) ) end commands end |