Settings (fnord v0.8.82)

View Source

Summary

Functions

Check if model performance debugging is enabled via environment variable.

Delete project data from the settings, handling both old and new format.

Get the path to the store root directory.

Get a value from the settings store.

Get current auto-approve setting.

Get current auto-approval policy setting.

Get current edit mode setting.

Get fonz mode setting.

Check if automatic injection of hint docs is enabled. Defaults to true if unset.

Check if hint docs feature is enabled. Defaults to true if unset.

Get project data from the settings, handling both old and new format.

Gets the project root override path, or nil if not set.

Get all project configurations. Returns a map of project_name => project_config.

Get the project specified with --project. If the project name is not set, an error tuple is returned.

Get the user's home directory, allowing override for testing.

Get yes count from settings.

Get the list of global configuration keys that should not be treated as project names.

Check if a given key represents a valid project name (not a global config key). Returns false for global configuration keys like "approvals".

Check if the --project option is set.

Set auto-approve mode for the application. In this mode, file edits are automatically approved without user confirmation.

Set auto-approval policy for the application. This setting controls how unattended approvals are handled.

Set edit mode for the application.

Set fonz mode for application.

Set the project name for the --project option.

Set project data in the settings using the new nested format.

Set or clear a temporary project root override path. Pass a directory path to override or nil to clear the override.

Set the quiet mode for UI output.

Set the number of workers for concurrent operations.

Set yes count in settings.

Get the path to the settings file. If the file does not exist, it will be created.

Atomically update a top-level key in the settings file using a cross-process lock and a read-merge-write cycle.

Types

t()

@type t() :: %Settings{data: map(), path: binary()}

Functions

debug_models?()

@spec debug_models?() :: boolean()

Check if model performance debugging is enabled via environment variable.

delete_project_data(settings, project_name)

@spec delete_project_data(t(), binary()) :: t()

Delete project data from the settings, handling both old and new format.

fnord_home()

@spec fnord_home() :: binary()

Get the path to the store root directory.

get(settings, key, default \\ nil)

@spec get(t(), binary(), any()) :: any()

Get a value from the settings store.

get_auto_approve()

@spec get_auto_approve() :: boolean()

Get current auto-approve setting.

get_auto_policy()

@spec get_auto_policy() ::
  {:approve, non_neg_integer()} | {:deny, non_neg_integer()} | nil

Get current auto-approval policy setting.

get_edit_mode()

@spec get_edit_mode() :: boolean()

Get current edit mode setting.

get_fonz_mode()

@spec get_fonz_mode() :: boolean()

Get fonz mode setting.

get_hint_docs_auto_inject?()

@spec get_hint_docs_auto_inject?() :: boolean()

Check if automatic injection of hint docs is enabled. Defaults to true if unset.

get_hint_docs_enabled?()

@spec get_hint_docs_enabled?() :: boolean()

Check if hint docs feature is enabled. Defaults to true if unset.

get_project(settings)

@spec get_project(t()) :: {:ok, map()} | {:error, :project_not_found}

get_project_data(settings, project_name)

@spec get_project_data(t(), binary()) :: map() | nil

Get project data from the settings, handling both old and new format.

get_project_root_override()

@spec get_project_root_override() :: binary() | nil

Gets the project root override path, or nil if not set.

get_projects(settings)

@spec get_projects(t()) :: %{required(binary()) => map()}

Get all project configurations. Returns a map of project_name => project_config.

get_root(settings)

@spec get_root(t()) :: {:ok, binary()} | {:error, :not_found}

get_running_version()

get_selected_project()

@spec get_selected_project() :: {:ok, binary()} | {:error, :project_not_set}

Get the project specified with --project. If the project name is not set, an error tuple is returned.

get_user_home()

@spec get_user_home() :: binary() | nil | no_return()

Get the user's home directory, allowing override for testing.

get_yes_count()

@spec get_yes_count() :: non_neg_integer()

Get yes count from settings.

global_config_keys()

@spec global_config_keys() :: [binary()]

Get the list of global configuration keys that should not be treated as project names.

is_valid_project_name?(name)

@spec is_valid_project_name?(binary()) :: boolean()

Check if a given key represents a valid project name (not a global config key). Returns false for global configuration keys like "approvals".

list_projects(settings)

@spec list_projects(t()) :: [binary()]

new()

@spec new() :: t()

project_is_set?()

Check if the --project option is set.

set_auto_approve(auto_approve)

@spec set_auto_approve(boolean()) :: :ok

Set auto-approve mode for the application. In this mode, file edits are automatically approved without user confirmation.

set_auto_policy(policy)

@spec set_auto_policy({:approve | :deny, non_neg_integer()} | nil) :: :ok

Set auto-approval policy for the application. This setting controls how unattended approvals are handled.

The policy is a tuple consisting of an action and a timeout (or nil to disable):

  • :approve to automatically approve changes after a timeout.
  • :deny to automatically deny changes after a timeout.
  • nil to disable auto-approval.

The timeout is specified in milliseconds and determines how long to wait before applying the auto-approval policy.

When an approval is required, the system will first send a notification to the user after 60 seconds. If the user does not respond within the timeout specified by the auto-approval policy, the specified action will be taken automatically.

set_edit_mode(edit_mode)

@spec set_edit_mode(boolean()) :: :ok

Set edit mode for the application.

set_fonz_mode(fonz_mode)

@spec set_fonz_mode(boolean()) :: :ok

Set fonz mode for application.

set_project(project_name)

@spec set_project(atom() | binary()) :: :ok

Set the project name for the --project option.

set_project(settings, data)

@spec set_project(t(), map()) :: map()

set_project_data(settings, project_name, data)

@spec set_project_data(t(), binary(), map()) :: t()

Set project data in the settings using the new nested format.

set_project_root_override(path)

@spec set_project_root_override(binary() | nil) :: :ok

Set or clear a temporary project root override path. Pass a directory path to override or nil to clear the override.

set_quiet(quiet)

@spec set_quiet(boolean()) :: :ok

Set the quiet mode for UI output.

set_workers(workers)

@spec set_workers(pos_integer()) :: :ok

Set the number of workers for concurrent operations.

set_yes_count(count)

@spec set_yes_count(non_neg_integer()) :: :ok

Set yes count in settings.

settings_file()

@spec settings_file() :: binary()

Get the path to the settings file. If the file does not exist, it will be created.

update(settings, key, updater, default \\ %{})

@spec update(t(), binary(), (any() -> any() | :delete), any()) :: t() | no_return()

Atomically update a top-level key in the settings file using a cross-process lock and a read-merge-write cycle.

The updater receives the current value for key (or default when missing) and must return the new value. If the updater returns :delete, the key will be removed from the settings.

write_atomic!(path, content)