vibe.templates_mgmt.provider

Template Data Provider (Refactored).

Defines the TemplateDataProvider class responsible for orchestrating the loading, caching, and management of template bundles. It delegates all storage-specific operations to a VirtualFileSystem instance, keeping the main provider focused on the template loading pipeline.

ComponentNotFoundError

Raised when a component cannot be located in any of the configured sources.

ComponentSource

Holds information about a located component source.

FileContent

Represents the content and modification time of a file.

LoadedAST

Represents a parsed Jinja AST and related analysis artifacts.

StaticAnalysis

Holds results from visiting the AST for structural info.

VirtualFileSystem

Acts as a storage abstraction layer.

Provides a consistent API for reading files, checking existence, and locating components regardless of the backend (filesystem, Git, embedded).

read

read(vpath: str) -> FileContent

VFS: Reads file content from a virtual path.

exists

exists(vpath: str) -> bool

VFS: Checks if a file or directory exists at a virtual path.

load_python_module

load_python_module(base_virtual_path: str, module_basename: str, unique_id: str) -> object | None

VFS: Dynamically loads a Python module, using filesystem path for debuggability where possible.

locate_component

locate_component(component_id_path_str: str, host_template_data: TemplateData) -> ComponentSource

VFS: Locates a component given its ID path by dispatching to a source-aware helper.

TemplateDataProvider

Orchestrates loading, caching, and validation of template bundles.

Delegates all storage-specific operations to a VirtualFileSystem instance.

get_template_data

get_template_data(template_id: str, version_spec: str | None = None, user_context: dict[str, Any] | None = None, session_context_for_check: dict[str, Any] | None = None, refresh: bool = False, skip_static_validation: bool = False) -> TemplateData

Handle caching, version resolution, and loading.

Parameters:
  • template_id (str) –

    Template bundle identifier.

  • version_spec (str | None, default: None ) –

    Optional git version spec or tag.

  • user_context (dict[str, Any] | None, default: None ) –

    User context for version resolution.

  • session_context_for_check (dict[str, Any] | None, default: None ) –

    Session context for validation checks.

  • refresh (bool, default: False ) –

    Whether to bypass cached template data.

  • skip_static_validation (bool, default: False ) –

    If True, skips the static_check_template validation step. Useful when loading templates outside of Flask app context.

get_component_data

get_component_data(component_id: str, host_template_data: TemplateData) -> ComponentTemplateData | None

Public method to get data for a single component, used by appendices and other systems.

resolve_definition

resolve_definition(template_data: TemplateData, definition_id: str, resolution_stack: list[str] | None = None) -> dict[str, Any] | None

Resolve nested definitions by id within a template, detecting cycles and caching results.

register_interview_mode_globals

register_interview_mode_globals(mode: str, globals_dict: dict[str, Any]) -> None

Register template globals for a specific interview mode.

Parameters:
  • mode (str) –

    The interview_mode value (e.g., "review")

  • globals_dict (dict[str, Any]) –

    Dict of name -> callable to add to template environments