yera.cli.resources.setup_wizard

Setup wizard infrastructure.

Symbols

def create_profile — Create or update a named profile and conditionally set it as the default.
def print_setup_summary — Print the wizard completion summary, profile state, and follow-up hints.
def resolve_profile_name — Resolve the target profile name, prompting interactively if not supplied.
def run_batch_model_discovery — Discover models for all available providers and persist them to the universe.
def run_provider_detection — Attempt auto-detection and setup for each provider in the handler map.

create_profile

create_profile(
    profile_name: str,
    update: bool,
    ctx: AppContext,
) → None

Create or update a named profile and conditionally set it as the default.

Writes a new Profile record, preserving the description from any pre-existing profile of the same name. Sets the profile as the system default when no profiles previously existed, or when update is True. Prints a status line to the console indicating whether the operation is a fresh setup or an update.

Parameters

profile_name
type: str

Name of the profile to create or overwrite.

update
type: bool

When True, treats the operation as an update and re-applies the default pointer.

ctx
type: AppContext

Application context carrying the console for status output.

resolve_profile_name

resolve_profile_name(
    profile_arg: str | None,
    update: bool,
    ctx: AppContext,
) → str

Resolve the target profile name, prompting interactively if not supplied.

If profile_arg is None, the user is prompted via the console with "default" as the fallback. When update is False, raises YeraError if the resolved name already exists in the stored profiles, preventing accidental overwrites.

Parameters

profile_arg
type: str | None

Explicit profile name passed by the caller, or None to trigger an interactive prompt.

update
type: bool

When True, an existing profile with the resolved name is allowed; no error is raised.

ctx
type: AppContext

Application context carrying the console used for the prompt.

Returns

type: str

The resolved, stripped profile name string.

Raises

YeraError

If the resolved name already exists and update is False.

run_batch_model_discovery

run_batch_model_discovery(
    available_providers: list[str],
    discovery_handler_map: dict,
    ctx: AppContext,
    connection_name: str,
) → list[BaseModelConfig] | None

Discover models for all available providers and persist them to the universe.

For each provider in available_providers, looks up the corresponding discovery handler, resolves the active connection object from the loaded providers config, and runs model discovery. All discovered models across all providers are aggregated and written to the model universe in a single call.

Parameters

available_providers
type: list[str]

Ordered list of provider type strings to discover models for. Providers without a matching handler or connection are silently skipped.

discovery_handler_map
type: dict

Mapping of provider type string to discovery handler class.

ctx
type: AppContext

Application context carrying console and error console.

connection_name
type: str

The connection name to resolve for each provider.

Returns

type: list[BaseModelConfig] | None

The aggregated list of discovered BaseModelConfig instances, or None if available_providers is empty.

run_provider_detection

run_provider_detection(
    profile_name: str,
    provider_handler_map: dict,
    ctx: AppContext,
    connection_name: str,
) → tuple[list[str], list[str]]

Attempt auto-detection and setup for each provider in the handler map.

Iterates over the provided handler map, skipping any provider that is already configured. For each remaining provider, runs the setup flow and, on success, writes an updated profile associating the provider with the given connection name. Providers that fail auto-detection are skipped with a console hint for manual configuration.

Parameters

profile_name
type: str

Name of the profile to write successful providers into.

provider_handler_map
type: dict

Mapping of provider type string to handler class.

ctx
type: AppContext

Application context carrying console, error console, and config state.

connection_name
type: str

The connection name to associate with each detected provider.

Returns

type: list[str]

A two-tuple of (successful, skipped) where each element is a list of provider type strings.