Class: Chocomint::Config

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

Overview

config/config.yml を読み込み、環境変数オーバーライドを適用する。

Constant Summary collapse

DEFAULT_PATH =
File.expand_path("../../config/config.yml", __dir__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Config

Returns a new instance of Config.



17
18
19
20
# File 'lib/chocomint/config.rb', line 17

def initialize(data)
  @data = deep_stringify(data)
  apply_env_overrides!
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/chocomint/config.rb', line 10

def data
  @data
end

Class Method Details

.load(path = DEFAULT_PATH) ⇒ Object



12
13
14
15
# File 'lib/chocomint/config.rb', line 12

def self.load(path = DEFAULT_PATH)
  raw = File.exist?(path) ? YAML.safe_load(File.read(path)) : {}
  new(raw || {})
end

Instance Method Details

#allow_all_commands?Boolean

true なら run_command で allowed_commands の whitelist チェックを行わず任意コマンドを実行する。

Returns:

  • (Boolean)


46
# File 'lib/chocomint/config.rb', line 46

def allow_all_commands? = security.fetch("allow_all_commands", false)

#allowed_commandsObject



44
45
# File 'lib/chocomint/config.rb', line 44

def allowed_commands = security.fetch("allowed_commands", [])
# true なら run_command で allowed_commands の whitelist チェックを行わず任意コマンドを実行する。

#allowed_dirsObject



42
# File 'lib/chocomint/config.rb', line 42

def allowed_dirs    = security.fetch("allowed_dirs", ["."])

#console_ws_portObject

AI エディタのコンソール (WebSocket) 用ポート。既定は HTTP ポート+1。



32
33
# File 'lib/chocomint/config.rb', line 32

def console_ws_port = ENV.fetch("CHOCOMINT_WS_PORT", server.fetch("ws_port", server_port + 1)).to_i
# コンソール接続に要求する共有トークン。未設定なら nil (ローカル限定運用向け)。

#console_ws_tokenObject

コンソール接続に要求する共有トークン。未設定なら nil (ローカル限定運用向け)。



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

def console_ws_token = ENV.fetch("CHOCOMINT_WS_TOKEN", server.fetch("ws_token", nil))

#executionObject



24
# File 'lib/chocomint/config.rb', line 24

def execution = @data.fetch("execution", {})

#llmObject



22
# File 'lib/chocomint/config.rb', line 22

def llm      = @data.fetch("llm", {})

#loggingObject



26
# File 'lib/chocomint/config.rb', line 26

def logging  = @data.fetch("logging", {})

#max_file_bytesObject



43
# File 'lib/chocomint/config.rb', line 43

def max_file_bytes  = security.fetch("max_file_bytes", 10_485_760)

#max_output_bytesObject



40
# File 'lib/chocomint/config.rb', line 40

def max_output_bytes = execution.fetch("max_output_bytes", 1_048_576)

#max_retryObject



36
37
# File 'lib/chocomint/config.rb', line 36

def max_retry       = execution.fetch("max_retry", 10)
# マルチステップ実行のステップ数上限。未設定なら max_retry を流用する (暴走防止)。

#max_stepsObject

マルチステップ実行のステップ数上限。未設定なら max_retry を流用する (暴走防止)。



38
# File 'lib/chocomint/config.rb', line 38

def max_steps       = execution.fetch("max_steps", max_retry)

#securityObject



25
# File 'lib/chocomint/config.rb', line 25

def security = @data.fetch("security", {})

#serverObject



27
# File 'lib/chocomint/config.rb', line 27

def server   = @data.fetch("server", {})

#server_hostObject



29
# File 'lib/chocomint/config.rb', line 29

def server_host = ENV.fetch("CHOCOMINT_HOST", server.fetch("host", "127.0.0.1"))

#server_portObject



30
31
# File 'lib/chocomint/config.rb', line 30

def server_port = ENV.fetch("CHOCOMINT_PORT", server.fetch("port", 9210)).to_i
# AI エディタのコンソール (WebSocket) 用ポート。既定は HTTP ポート+1。

#sqlite_pathObject



48
# File 'lib/chocomint/config.rb', line 48

def sqlite_path     = logging.fetch("sqlite_path", "./logs/execution.db")

#timeout_secObject



39
# File 'lib/chocomint/config.rb', line 39

def timeout_sec     = execution.fetch("timeout_sec", 30)

#verifierObject



23
# File 'lib/chocomint/config.rb', line 23

def verifier = @data.fetch("verifier", {})

#verifier_enabled?Boolean

Returns:

  • (Boolean)


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

def verifier_enabled? = verifier.fetch("enabled", false)