Class: Woods::Configuration

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

Overview

════════════════════════════════════════════════════════════════════════Configuration ════════════════════════════════════════════════════════════════════════

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

rubocop:disable Metrics/MethodLength



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/woods.rb', line 144

def initialize # rubocop:disable Metrics/MethodLength
  @output_dir = nil # Resolved lazily; Rails.root is nil at require time
  @embedding_model = 'text-embedding-3-small'
  @max_context_tokens = 8000
  @similarity_threshold = 0.7
  @include_framework_sources = true
  @gem_configs = {}
  @extractors = %i[models controllers services components view_components jobs mailers graphql serializers
                   managers policies validators rails_source]
  @pretty_json = true
  @concurrent_extraction = false
  @precompute_flows = false
  @extract_navigation_edges = true
  @enable_snapshots = false
  @context_format = :markdown
  @session_tracer_enabled = false
  @session_tracer_allow_production = false
  @session_store = nil
  @session_id_proc = nil
  @session_exclude_paths = []
  @console_mcp_enabled = false
  @console_mcp_path = '/mcp/console'
  # Accept token from config or env var. Nil by default — the railtie
  # refuses to wire the middleware in production without a real token
  # and only warns loudly in non-prod when unset.
  @console_mcp_token = ENV.fetch('WOODS_CONSOLE_MCP_TOKEN', nil)
  # Origins allowed to reach the embedded console MCP. Loopback only
  # by default; override in host initializers for tunneled or internal
  # dashboard access.
  @console_mcp_allowed_origins = %w[
    http://localhost
    http://127.0.0.1
    http://[::1]
  ]
  @console_redacted_columns = DEFAULT_CONSOLE_REDACTED_COLUMNS.dup
  @console_redacted_key_values = []
  @console_embedded_read_tools = false
  @console_blocked_tables = DEFAULT_CONSOLE_BLOCKED_TABLES.dup
  @console_disabled_scanner_patterns = []
  @console_credential_defense_enabled = true
  @console_credential_rotation_warning = true
  @console_unsafe_eval_enabled = nil # nil = fall back to env WOODS_CONSOLE_UNSAFE_EVAL
  # Required collaborators when the opt-in is on. Both default to nil;
  # the server refuses to boot with the opt-in set unless the host has
  # wired them (fail-closed — see Server.build_embedded).
  @console_unsafe_eval_confirmation = nil
  @console_unsafe_eval_audit_log_path = nil
  @notion_api_token = nil
  @notion_database_ids = {}
  @unblocked_api_token = nil
  @unblocked_collection_id = nil
  @unblocked_repo_url = nil
  @cache_enabled = false
  @cache_store = nil      # :redis, :solid_cache, :memory, or a CacheStore instance
  @cache_options = {}     # { redis: client, cache: store, ttl: { embeddings: 86400, ... } }
  @dump_retention_count = 3
end

Instance Attribute Details

#cache_enabledObject

Returns the value of attribute cache_enabled.



141
142
143
# File 'lib/woods.rb', line 141

def cache_enabled
  @cache_enabled
end

#cache_optionsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def cache_options
  @cache_options
end

#cache_storeObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def cache_store
  @cache_store
end

#concurrent_extractionObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def concurrent_extraction
  @concurrent_extraction
end

#console_blocked_tablesObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_blocked_tables
  @console_blocked_tables
end

#console_credential_defense_enabledObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_credential_defense_enabled
  @console_credential_defense_enabled
end

#console_credential_rotation_warningObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_credential_rotation_warning
  @console_credential_rotation_warning
end

#console_disabled_scanner_patternsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_disabled_scanner_patterns
  @console_disabled_scanner_patterns
end

#console_embedded_read_toolsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_embedded_read_tools
  @console_embedded_read_tools
end

#console_mcp_allowed_originsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_mcp_allowed_origins
  @console_mcp_allowed_origins
end

#console_mcp_enabledObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_mcp_enabled
  @console_mcp_enabled
end

#console_mcp_pathObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_mcp_path
  @console_mcp_path
end

#console_mcp_tokenObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_mcp_token
  @console_mcp_token
end

#console_redacted_columnsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_redacted_columns
  @console_redacted_columns
end

#console_redacted_key_valuesObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_redacted_key_values
  @console_redacted_key_values
end

#console_unsafe_eval_audit_log_pathObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_unsafe_eval_audit_log_path
  @console_unsafe_eval_audit_log_path
end

#console_unsafe_eval_confirmationObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_unsafe_eval_confirmation
  @console_unsafe_eval_confirmation
end

#console_unsafe_eval_enabledObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def console_unsafe_eval_enabled
  @console_unsafe_eval_enabled
end

#context_formatObject

Returns the value of attribute context_format.



141
142
143
# File 'lib/woods.rb', line 141

def context_format
  @context_format
end

#dump_retention_countObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def dump_retention_count
  @dump_retention_count
end

#embedding_modelObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def embedding_model
  @embedding_model
end

#embedding_optionsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def embedding_options
  @embedding_options
end

#embedding_providerObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def embedding_provider
  @embedding_provider
end

#enable_snapshotsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def enable_snapshots
  @enable_snapshots
end

#extract_navigation_edgesObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def extract_navigation_edges
  @extract_navigation_edges
end

#extractorsObject

Returns the value of attribute extractors.



141
142
143
# File 'lib/woods.rb', line 141

def extractors
  @extractors
end

#gem_configsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def gem_configs
  @gem_configs
end

#graph_storeObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def graph_store
  @graph_store
end

#include_framework_sourcesObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def include_framework_sources
  @include_framework_sources
end

#log_levelObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def log_level
  @log_level
end

#max_context_tokensObject

Returns the value of attribute max_context_tokens.



141
142
143
# File 'lib/woods.rb', line 141

def max_context_tokens
  @max_context_tokens
end

#metadata_storeObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def 
  @metadata_store
end

#metadata_store_optionsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def 
  @metadata_store_options
end

#notion_api_tokenObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def notion_api_token
  @notion_api_token
end

#notion_database_idsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def notion_database_ids
  @notion_database_ids
end

#precompute_flowsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def precompute_flows
  @precompute_flows
end

#pretty_jsonObject

Returns the value of attribute pretty_json.



141
142
143
# File 'lib/woods.rb', line 141

def pretty_json
  @pretty_json
end

#session_exclude_pathsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def session_exclude_paths
  @session_exclude_paths
end

#session_id_procObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def session_id_proc
  @session_id_proc
end

#session_storeObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def session_store
  @session_store
end

#session_tracer_allow_productionObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def session_tracer_allow_production
  @session_tracer_allow_production
end

#session_tracer_enabledObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def session_tracer_enabled
  @session_tracer_enabled
end

#similarity_thresholdObject

Returns the value of attribute similarity_threshold.



141
142
143
# File 'lib/woods.rb', line 141

def similarity_threshold
  @similarity_threshold
end

#unblocked_api_tokenObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def unblocked_api_token
  @unblocked_api_token
end

#unblocked_collection_idObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def unblocked_collection_id
  @unblocked_collection_id
end

#unblocked_repo_urlObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def unblocked_repo_url
  @unblocked_repo_url
end

#vector_storeObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def vector_store
  @vector_store
end

#vector_store_optionsObject

rubocop:disable Metrics/ClassLength



123
124
125
# File 'lib/woods.rb', line 123

def vector_store_options
  @vector_store_options
end

Instance Method Details

#add_gem(gem_name, paths:, priority: :medium) ⇒ Object

Add a gem to be indexed

Parameters:

  • gem_name (String)

    Name of the gem

  • paths (Array<String>)

    Relative paths within the gem to index

  • priority (Symbol) (defaults to: :medium)

    :high, :medium, or :low



278
279
280
# File 'lib/woods.rb', line 278

def add_gem(gem_name, paths:, priority: :medium)
  @gem_configs[gem_name] = { paths: paths, priority: priority }
end

#output_dirPathname, String

Returns Output directory, defaulting to Rails.root/tmp/woods.

Returns:

  • (Pathname, String)

    Output directory, defaulting to Rails.root/tmp/woods



203
204
205
# File 'lib/woods.rb', line 203

def output_dir
  @output_dir ||= defined?(Rails) && Rails.root ? Rails.root.join('tmp/woods') : 'tmp/woods'
end

#output_dir=(value) ⇒ Object

Parameters:

  • value (Object)

    Must respond to #to_s

Raises:



209
210
211
212
213
# File 'lib/woods.rb', line 209

def output_dir=(value)
  raise ConfigurationError, 'output_dir cannot be nil' if value.nil?

  @output_dir = value
end