Class: Ocak::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ocak/config.rb

Defined Under Namespace

Classes: ConfigError, ConfigNotFound

Constant Summary collapse

CONFIG_FILE =
'ocak.yml'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, project_dir = Dir.pwd) ⇒ Config

Returns a new instance of Config.



18
19
20
21
22
23
# File 'lib/ocak/config.rb', line 18

def initialize(data, project_dir = Dir.pwd)
  @data = data || {}
  @project_dir = project_dir
  @overrides = {}
  validate!
end

Instance Attribute Details

#project_dirObject (readonly)

Returns the value of attribute project_dir.



9
10
11
# File 'lib/ocak/config.rb', line 9

def project_dir
  @project_dir
end

Class Method Details

.load(dir = Dir.pwd) ⇒ Object

Raises:



11
12
13
14
15
16
# File 'lib/ocak/config.rb', line 11

def self.load(dir = Dir.pwd)
  path = File.join(dir, CONFIG_FILE)
  raise ConfigNotFound, "No ocak.yml found in #{dir}. Run `ocak init` first." unless File.exist?(path)

  new(YAML.safe_load_file(path, symbolize_names: true), dir)
end

Instance Method Details

#agent_path(name) ⇒ Object

Agent paths



73
74
75
76
77
78
# File 'lib/ocak/config.rb', line 73

def agent_path(name)
  custom = dig(:agents, name.to_sym)
  return File.join(@project_dir, custom) if custom

  File.join(@project_dir, '.claude', 'agents', "#{name.to_s.tr('_', '-')}.md")
end

#allowed_authorsObject

Safety



57
# File 'lib/ocak/config.rb', line 57

def allowed_authors    = dig(:safety, :allowed_authors) || []

#cost_budgetObject



54
# File 'lib/ocak/config.rb', line 54

def cost_budget   = dig(:pipeline, :cost_budget)

#format_commandObject



34
# File 'lib/ocak/config.rb', line 34

def format_command = dig(:stack, :format_command)

#frameworkObject



31
# File 'lib/ocak/config.rb', line 31

def framework     = dig(:stack, :framework)

#label_completedObject



64
# File 'lib/ocak/config.rb', line 64

def label_completed  = dig(:labels, :completed) || 'completed'

#label_failedObject



65
# File 'lib/ocak/config.rb', line 65

def label_failed     = dig(:labels, :failed) || 'pipeline-failed'

#label_in_progressObject



63
# File 'lib/ocak/config.rb', line 63

def label_in_progress = dig(:labels, :in_progress) || 'in-progress'

#label_readyObject

Labels



62
# File 'lib/ocak/config.rb', line 62

def label_ready = dig(:labels, :ready) || 'auto-ready'

#languageObject

Stack



30
# File 'lib/ocak/config.rb', line 30

def language      = dig(:stack, :language) || 'unknown'

#lint_check_commandObject

Returns the lint command with auto-fix flags stripped, suitable for check-only verification.



38
39
40
41
42
43
# File 'lib/ocak/config.rb', line 38

def lint_check_command
  cmd = lint_command
  return nil unless cmd

  cmd.gsub(/\s+(?:-A|--fix|--write|--allow-dirty)\b/, '').strip
end

#lint_commandObject



33
# File 'lib/ocak/config.rb', line 33

def lint_command   = dig(:stack, :lint_command)

#log_dirObject



53
# File 'lib/ocak/config.rb', line 53

def log_dir       = dig(:pipeline, :log_dir) || 'logs/pipeline'

#max_issues_per_runObject



59
# File 'lib/ocak/config.rb', line 59

def max_issues_per_run = dig(:safety, :max_issues_per_run) || 5

#max_parallelObject

Pipeline



50
# File 'lib/ocak/config.rb', line 50

def max_parallel  = @overrides[:max_parallel] || dig(:pipeline, :max_parallel) || 3

#override(key, value) ⇒ Object



25
26
27
# File 'lib/ocak/config.rb', line 25

def override(key, value)
  @overrides[key] = value
end

#poll_intervalObject



51
# File 'lib/ocak/config.rb', line 51

def poll_interval = @overrides[:poll_interval] || dig(:pipeline, :poll_interval) || 60

#require_commentObject



58
# File 'lib/ocak/config.rb', line 58

def require_comment    = dig(:safety, :require_comment)

#security_commandsObject



45
46
47
# File 'lib/ocak/config.rb', line 45

def security_commands
  dig(:stack, :security_commands) || []
end

#setup_commandObject



35
# File 'lib/ocak/config.rb', line 35

def setup_command  = dig(:stack, :setup_command)

#stepsObject

Steps



68
69
70
# File 'lib/ocak/config.rb', line 68

def steps
  @data[:steps] || default_steps
end

#test_commandObject



32
# File 'lib/ocak/config.rb', line 32

def test_command   = dig(:stack, :test_command)

#worktree_dirObject



52
# File 'lib/ocak/config.rb', line 52

def worktree_dir  = dig(:pipeline, :worktree_dir) || '.claude/worktrees'