Class: Aidp::ToolingDetector

Inherits:
Object
  • Object
show all
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.

Defined Under Namespace

Classes: Result

Constant Summary collapse

DETECTORS =
[
  :ruby_bundle,
  :rspec,
  :ruby_standardrb,
  :node_jest,
  :node_mocha,
  :node_eslint,
  :python_pytest
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root = Dir.pwd) ⇒ ToolingDetector

Returns a new instance of ToolingDetector.



23
24
25
# File 'lib/aidp/tooling_detector.rb', line 23

def initialize(root = Dir.pwd)
  @root = root
end

Class Method Details

.detect(root = Dir.pwd) ⇒ Object



19
20
21
# File 'lib/aidp/tooling_detector.rb', line 19

def self.detect(root = Dir.pwd)
  new(root).detect
end

Instance Method Details

#detectObject



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
# File 'lib/aidp/tooling_detector.rb', line 27

def detect
  tests = []
  linters = []

  if ruby_project?
    tests << bundle_prefix("rspec") if rspec?
    linters << bundle_prefix("standardrb") if standard_rb?
  end

  if node_project?
    tests << npm_or_yarn("test") if package_script?("test")
    %w[lint eslint].each do |script|
      if package_script?(script)
        linters << npm_or_yarn(script)
        break
      end
    end
  end

  if python_pytest?
    tests << "pytest -q"
  end

  Result.new(
    test_commands: tests.uniq,
    lint_commands: linters.uniq
  )
end