Class: Ask::CodingHarness::Config

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

Overview

Configuration for the coding harness.

Global instance: Ask::CodingHarness.config. Settings are read from environment variables when not set explicitly, so a zero-config ach serve works out of the box.

Ask::CodingHarness.configure do |c|
c.workspace = "/path/to/project"
c.model = "claude-sonnet-4"
c.approval = :require
end

Constant Summary collapse

DEFAULT_TOOLS =

Default tools made available to the agent. All come from ask-tools-shell and run through Ask::Sandbox.provider.

%w[bash read write edit glob grep code apply_patch].freeze
DEFAULT_APPROVAL_REQUIRED =

Tools that queue for human approval when approval mode is :require.

%w[bash write edit apply_patch code repl].freeze
APPROVAL_MODES =

Approval modes:

:off      — never prompt; everything executes immediately
:require  — mutating/dangerous tools queue for human approval
:auto     — auto-approve everything (same as :off, but the queue
          exists and can be inspected)
%i[off require auto].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ask/coding_harness/config.rb', line 36

def initialize
  @host = ENV.fetch("ACH_HOST", "0.0.0.0")
  @port = (ENV["ACH_PORT"] || "8080").to_i
  @workspace = ENV["ACH_WORKSPACE"] || ENV["ASKODA_WORKSPACE"] || Dir.pwd
  @db_path = ENV["ACH_DB_PATH"] || ENV["ASKODA_DB_PATH"] || default_db_path
  @model = ENV["ACH_MODEL"] || ENV["ASK_AGENT_MODEL"] || "deepseek-v4-flash"
  @max_turns = (ENV["ACH_MAX_TURNS"] || ENV["ASK_AGENT_MAX_TURNS"] || "25").to_i
  @turn_timeout = (ENV["ACH_TURN_TIMEOUT"] || "600").to_i
  @approval = :require
  self.approval = (ENV["ACH_APPROVAL"] || "require").to_sym
  @approval_required = DEFAULT_APPROVAL_REQUIRED.dup
  @plan_mode = env_flag("ACH_PLAN_MODE", default: false)
  @todos = env_flag("ACH_TODOS", default: true)
  @tools = DEFAULT_TOOLS.dup
  @adapter = ENV["ACH_ADAPTER"] || ENV["CODING_PROVIDER"] || "ask_agent"
  @adapter_opts = {}
  @system_prompt = nil
  @system_prompt_append = ENV["ACH_SYSTEM_PROMPT"]
  @system_prompt_guidelines = []
  validate!
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def adapter
  @adapter
end

#adapter_optsObject

Returns the value of attribute adapter_opts.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def adapter_opts
  @adapter_opts
end

#approval_requiredObject

Returns the value of attribute approval_required.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def approval_required
  @approval_required
end

#db_pathObject

Returns the value of attribute db_path.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def db_path
  @db_path
end

#hostObject

Returns the value of attribute host.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def host
  @host
end

#max_turnsObject

Returns the value of attribute max_turns.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def max_turns
  @max_turns
end

#modelObject

Returns the value of attribute model.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def model
  @model
end

#plan_modeObject

Returns the value of attribute plan_mode.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def plan_mode
  @plan_mode
end

#system_promptObject

Returns the value of attribute system_prompt.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def system_prompt
  @system_prompt
end

#system_prompt_appendObject

Returns the value of attribute system_prompt_append.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def system_prompt_append
  @system_prompt_append
end

#system_prompt_guidelinesObject

Returns the value of attribute system_prompt_guidelines.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def system_prompt_guidelines
  @system_prompt_guidelines
end

#todosObject

Returns the value of attribute todos.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def todos
  @todos
end

#toolsObject

Returns the value of attribute tools.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def tools
  @tools
end

#turn_timeoutObject

Returns the value of attribute turn_timeout.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def turn_timeout
  @turn_timeout
end

#workspaceObject

Returns the value of attribute workspace.



31
32
33
# File 'lib/ask/coding_harness/config.rb', line 31

def workspace
  @workspace
end

Instance Method Details

#approvalObject



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

def approval
  @approval
end

#approval=(value) ⇒ Object



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

def approval=(value)
  mode = value.to_sym
  unless APPROVAL_MODES.include?(mode)
    raise ArgumentError, "approval must be one of #{APPROVAL_MODES.inspect}, got #{value.inspect}"
  end
  @approval = mode
end

#approval_policy_toolsObject

Names of the tools the approval policy gates behind human approval.



91
92
93
94
# File 'lib/ask/coding_harness/config.rb', line 91

def approval_policy_tools
  return [] unless approval_required?
  Array(@approval_required).map(&:to_s)
end

#approval_required?Boolean

True when mutating tools queue for human approval.

Returns:

  • (Boolean)


86
87
88
# File 'lib/ask/coding_harness/config.rb', line 86

def approval_required?
  @approval == :require
end

#approvals?Boolean

True when the approval queue is active (mode :require or :auto).

Returns:

  • (Boolean)


81
82
83
# File 'lib/ask/coding_harness/config.rb', line 81

def approvals?
  %i[require auto].include?(@approval)
end

#portObject



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

def port
  @port
end

#port=(value) ⇒ Object

Raises:

  • (ArgumentError)


62
63
64
65
66
# File 'lib/ask/coding_harness/config.rb', line 62

def port=(value)
  @port = value.to_i
  raise ArgumentError, "invalid port: #{@port.inspect}" if @port <= 0 || @port > 65_535
  @port
end