Class: Ocak::Config
- Inherits:
-
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_dir ⇒ Object
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
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
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_labels ⇒ Object
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_authors ⇒ Object
71
|
# File 'lib/ocak/config.rb', line 71
def allowed_authors = dig(:safety, :allowed_authors) || []
|
#audit_mode ⇒ Object
68
|
# File 'lib/ocak/config.rb', line 68
def audit_mode = @overrides[:audit_mode] || dig(:pipeline, :audit_mode) || false
|
#cost_budget ⇒ Object
66
|
# File 'lib/ocak/config.rb', line 66
def cost_budget = dig(:pipeline, :cost_budget)
|
34
|
# File 'lib/ocak/config.rb', line 34
def format_command = dig(:stack, :format_command)
|
#framework ⇒ Object
31
|
# File 'lib/ocak/config.rb', line 31
def framework = dig(:stack, :framework)
|
#issue_backend ⇒ Object
76
|
# File 'lib/ocak/config.rb', line 76
def issue_backend = dig(:issues, :backend)
|
#label_awaiting_review ⇒ Object
85
|
# File 'lib/ocak/config.rb', line 85
def label_awaiting_review = dig(:labels, :awaiting_review) || 'auto-pending-human'
|
#label_completed ⇒ Object
82
|
# File 'lib/ocak/config.rb', line 82
def label_completed = dig(:labels, :completed) || 'completed'
|
#label_failed ⇒ Object
83
|
# File 'lib/ocak/config.rb', line 83
def label_failed = dig(:labels, :failed) || 'pipeline-failed'
|
#label_in_progress ⇒ Object
81
|
# File 'lib/ocak/config.rb', line 81
def label_in_progress = dig(:labels, :in_progress) || 'auto-doing'
|
#label_ready ⇒ Object
80
|
# File 'lib/ocak/config.rb', line 80
def label_ready = dig(:labels, :ready) || 'auto-ready'
|
#label_reready ⇒ Object
84
|
# File 'lib/ocak/config.rb', line 84
def label_reready = dig(:labels, :reready) || 'auto-reready'
|
#language ⇒ Object
30
|
# File 'lib/ocak/config.rb', line 30
def language = dig(:stack, :language) || 'unknown'
|
#lint_check_command ⇒ Object
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
cmd.gsub(/\s+(?:-A|--fix-dry-run|--fix-type\s+\S+|--unsafe-fix|--fix|--write|--allow-dirty)\b/, '').strip
end
|
#lint_command ⇒ Object
33
|
# File 'lib/ocak/config.rb', line 33
def lint_command = dig(:stack, :lint_command)
|
#local_issues? ⇒ Boolean
77
|
# File 'lib/ocak/config.rb', line 77
def local_issues? = issue_backend == 'local'
|
#log_dir ⇒ Object
62
63
64
|
# File 'lib/ocak/config.rb', line 62
def log_dir
validate_path(dig(:pipeline, :log_dir) || 'logs/pipeline')
end
|
#manual_review ⇒ Object
67
|
# File 'lib/ocak/config.rb', line 67
def manual_review = @overrides[:manual_review] || dig(:pipeline, :manual_review) || false
|
#max_issues_per_run ⇒ Object
73
|
# File 'lib/ocak/config.rb', line 73
def max_issues_per_run = dig(:safety, :max_issues_per_run) || 5
|
#max_parallel ⇒ Object
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_interval ⇒ Object
56
|
# File 'lib/ocak/config.rb', line 56
def poll_interval = @overrides[:poll_interval] || dig(:pipeline, :poll_interval) || 60
|
72
|
# File 'lib/ocak/config.rb', line 72
def = dig(:safety, :require_comment)
|
#security_commands ⇒ Object
50
51
52
|
# File 'lib/ocak/config.rb', line 50
def security_commands
dig(:stack, :security_commands) || []
end
|
#setup_command ⇒ Object
35
|
# File 'lib/ocak/config.rb', line 35
def setup_command = dig(:stack, :setup_command)
|
#steps ⇒ Object
92
93
94
|
# File 'lib/ocak/config.rb', line 92
def steps
@data[:steps] || default_steps
end
|
#test_command ⇒ Object
32
|
# File 'lib/ocak/config.rb', line 32
def test_command = dig(:stack, :test_command)
|
#worktree_dir ⇒ Object
58
59
60
|
# File 'lib/ocak/config.rb', line 58
def worktree_dir
validate_path(dig(:pipeline, :worktree_dir) || '.claude/worktrees')
end
|