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



97
98
99
100
101
102
# File 'lib/ocak/config.rb', line 97

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

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

#all_labelsObject



87
88
89
# File 'lib/ocak/config.rb', line 87

def all_labels
  [label_ready, label_in_progress, label_completed, label_failed, label_reready, label_awaiting_review]
end

#allowed_authorsObject

Safety



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

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

#audit_modeObject



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

def audit_mode    = @overrides[:audit_mode] || dig(:pipeline, :audit_mode) || false

#cost_budgetObject



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

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)

#issue_backendObject

Issues



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

def issue_backend = dig(:issues, :backend)

#label_awaiting_reviewObject



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

def label_awaiting_review = dig(:labels, :awaiting_review) || 'auto-pending-human'

#label_completedObject



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

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

#label_failedObject



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

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

#label_in_progressObject



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

def label_in_progress = dig(:labels, :in_progress) || 'auto-doing'

#label_readyObject

Labels



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

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

#label_rereadyObject



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

def label_reready         = dig(:labels, :reready) || 'auto-reready'

#languageObject

Stack



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

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

#lint_check_commandObject

Returns the lint command suitable for check-only verification. Uses explicit lint_check_command config if provided; otherwise strips known fix flags from lint_command.



39
40
41
42
43
44
45
46
47
48
# File 'lib/ocak/config.rb', line 39

def lint_check_command
  explicit = dig(:stack, :lint_check_command)
  return explicit if explicit && !explicit.empty?

  cmd = lint_command
  return nil unless cmd

  # Longer --fix-* variants must precede --fix in the alternation due to \b matching after 'fix'
  cmd.gsub(/\s+(?:-A|--fix-dry-run|--fix-type\s+\S+|--unsafe-fix|--fix|--write|--allow-dirty)\b/, '').strip
end

#lint_commandObject



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

def lint_command   = dig(:stack, :lint_command)

#local_issues?Boolean

Returns:

  • (Boolean)


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

def local_issues? = issue_backend == 'local'

#log_dirObject



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

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

#manual_reviewObject



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

def manual_review = @overrides[:manual_review] || dig(:pipeline, :manual_review) || false

#max_issues_per_runObject



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

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

#max_parallelObject

Pipeline



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

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

#override(key, value) ⇒ Object



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

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

#poll_intervalObject



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

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

#require_commentObject



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

def require_comment    = dig(:safety, :require_comment)

#security_commandsObject



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

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



92
93
94
# File 'lib/ocak/config.rb', line 92

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



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

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