Class: Aidp::Evaluations::ContextCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/evaluations/context_capture.rb

Overview

Captures rich context for evaluation records

Gathers information about:

  • Prompt metadata (template, persona, skills, provider, model, tokens, settings)

  • Work-loop data (unit count, checkpoints, retries, file modifications)

  • Environment details (devcontainer status, Ruby version, branch info)

Examples:

Capturing context

context = ContextCapture.new(project_dir: Dir.pwd)
data = context.capture(step_name: "01_INIT", iteration: 3)

Instance Method Summary collapse

Constructor Details

#initialize(project_dir: Dir.pwd, config: nil) ⇒ ContextCapture



18
19
20
21
22
23
# File 'lib/aidp/evaluations/context_capture.rb', line 18

def initialize(project_dir: Dir.pwd, config: nil)
  @project_dir = project_dir
  @config = config

  Aidp.log_debug("context_capture", "initialize", project_dir: project_dir)
end

Instance Method Details

#capture(step_name: nil, iteration: nil, provider: nil, model: nil, additional: {}) ⇒ Hash

Capture full context for an evaluation



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/aidp/evaluations/context_capture.rb', line 33

def capture(step_name: nil, iteration: nil, provider: nil, model: nil, additional: {})
  Aidp.log_debug("context_capture", "capture",
    step_name: step_name, iteration: iteration, provider: provider)

  {
    prompt: capture_prompt_context(step_name),
    work_loop: capture_work_loop_context(step_name, iteration),
    environment: capture_environment_context,
    provider: {
      name: provider,
      model: model
    },
    timestamp: Time.now.iso8601
  }.merge(additional)
end

#capture_minimalHash

Capture minimal context (for quick evaluations)



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/aidp/evaluations/context_capture.rb', line 52

def capture_minimal
  Aidp.log_debug("context_capture", "capture_minimal")

  {
    environment: {
      ruby_version: RUBY_VERSION,
      branch: current_git_branch,
      aidp_version: aidp_version
    },
    timestamp: Time.now.iso8601
  }
end

#capture_watch(repo:, number:, processor_type:) ⇒ Hash

Capture watch mode context for evaluating watch outputs



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/aidp/evaluations/context_capture.rb', line 71

def capture_watch(repo:, number:, processor_type:)
  Aidp.log_debug("context_capture", "capture_watch",
    repo: repo, number: number, processor_type: processor_type)

  {
    watch: {
      repo: repo,
      number: number,
      processor_type: processor_type,
      state: load_watch_state(repo, number, processor_type)
    },
    environment: capture_environment_context,
    timestamp: Time.now.iso8601
  }
end