Class: Aidp::Planning::Mappers::PersonaMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/planning/mappers/persona_mapper.rb

Overview

Maps tasks to personas using Zero Framework Cognition (ZFC) NO heuristics, NO regex, NO keyword matching - pure AI decision making

Instance Method Summary collapse

Constructor Details

#initialize(ai_decision_engine:, config: nil, mode: :waterfall) ⇒ PersonaMapper

Returns a new instance of PersonaMapper.



12
13
14
15
16
# File 'lib/aidp/planning/mappers/persona_mapper.rb', line 12

def initialize(ai_decision_engine:, config: nil, mode: :waterfall)
  @ai_decision_engine = ai_decision_engine
  @config = config
  @mode = mode
end

Instance Method Details

#assign_personas(task_list, available_personas: nil) ⇒ Hash

Assign personas to tasks using ZFC

Parameters:

  • task_list (Array<Hash>)

    List of tasks to assign

  • available_personas (Array<String>) (defaults to: nil)

    Available persona names

Returns:

  • (Hash)

    Persona assignments



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/aidp/planning/mappers/persona_mapper.rb', line 22

def assign_personas(task_list, available_personas: nil)
  Aidp.log_debug("persona_mapper", "assign_personas", task_count: task_list.size)

  available_personas ||= default_personas

  assignments = {}

  task_list.each do |task|
    persona = assign_task_to_persona(task, available_personas)
    assignments[task[:id] || task[:name]] = {
      persona: persona,
      task: task[:name],
      phase: task[:phase],
      rationale: "AI-determined based on task characteristics"
    }

    Aidp.log_debug("persona_mapper", "assigned", task: task[:name], persona: persona)
  end

  {
    assignments: assignments,
    metadata: {
      generated_at: Time.now.iso8601,
      total_assignments: assignments.size,
      personas_used: assignments.values.map { |a| a[:persona] }.uniq
    }
  }
end

#generate_persona_map(assignments) ⇒ String

Generate persona_map.yml configuration

Parameters:

  • assignments (Hash)

    Persona assignments

Returns:

  • (String)

    YAML configuration



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/aidp/planning/mappers/persona_mapper.rb', line 54

def generate_persona_map(assignments)
  Aidp.log_debug("persona_mapper", "generate_persona_map")

  config = {
    "version" => "1.0",
    "generated_at" => Time.now.iso8601,
    "assignments" => format_assignments_for_yaml(assignments[:assignments])
  }

  YAML.dump(config)
end