Class: Ace::Idea::Organisms::IdeaDoctor

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/idea/organisms/idea_doctor.rb

Overview

Orchestrates comprehensive health checks for the ideas system. Runs structure validation, frontmatter validation, and scope/status consistency checks across all ideas in a root directory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path, options = {}) ⇒ IdeaDoctor

Returns a new instance of IdeaDoctor.

Parameters:

  • root_path (String)

    Path to ideas root directory

  • options (Hash) (defaults to: {})

    Diagnosis options (:check, :verbose, etc.)



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ace/idea/organisms/idea_doctor.rb', line 20

def initialize(root_path, options = {})
  @root_path = root_path
  @options = options
  @issues = []
  @stats = {
    ideas_scanned: 0,
    folders_checked: 0,
    errors: 0,
    warnings: 0,
    info: 0
  }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/ace/idea/organisms/idea_doctor.rb', line 16

def options
  @options
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



16
17
18
# File 'lib/ace/idea/organisms/idea_doctor.rb', line 16

def root_path
  @root_path
end

Instance Method Details

#auto_fixable?(issue) ⇒ Boolean

Check if an issue can be auto-fixed

Parameters:

  • issue (Hash)

    Issue to check

Returns:

  • (Boolean)


70
71
72
73
74
# File 'lib/ace/idea/organisms/idea_doctor.rb', line 70

def auto_fixable?(issue)
  return false unless issue[:type] == :error || issue[:type] == :warning

  Molecules::IdeaDoctorFixer::FIXABLE_PATTERNS.any? { |pattern| issue[:message].match?(pattern) }
end

#run_diagnosisHash

Run comprehensive health check

Returns:

  • (Hash)

    Diagnosis results



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
# File 'lib/ace/idea/organisms/idea_doctor.rb', line 35

def run_diagnosis
  unless @root_path && Dir.exist?(@root_path)
    return {
      valid: false,
      health_score: 0,
      issues: [{type: :error, message: "Ideas root directory not found: #{@root_path}"}],
      stats: @stats,
      duration: 0,
      root_path: @root_path
    }
  end

  @start_time = Time.now

  if options[:check]
    run_specific_check(options[:check])
  else
    run_full_check
  end

  health_score = calculate_health_score

  {
    valid: @stats[:errors] == 0,
    health_score: health_score,
    issues: @issues,
    stats: @stats,
    duration: Time.now - @start_time,
    root_path: @root_path
  }
end