Skills.Loader (fnord v0.9.29)

View Source

Load and validate skill definitions from TOML files.

This module is responsible for file IO and TOML decoding. It returns validated %Skills.Skill{} structs and includes file provenance so higher layers can explain override behavior.

Summary

Functions

Load all *.toml skill definitions from the given directory.

Load a single skill TOML file.

Load a list of TOML files as skill definitions.

Types

load_error()

@type load_error() ::
  {:toml_error, path :: String.t(), term()}
  | {:fs_error, path :: String.t(), term()}
  | {:invalid_skill, path :: String.t(), Skills.Skill.decode_error()}
  | {:duplicate_skill_name, String.t(), [String.t()]}

loaded_skill()

@type loaded_skill() :: %{
  skill: Skills.Skill.t(),
  name: String.t(),
  source: skill_source(),
  path: String.t()
}

skill_source()

@type skill_source() :: :user | :project

Functions

load_dir(dir, source)

@spec load_dir(String.t(), skill_source()) ::
  {:ok, [loaded_skill()]} | {:error, load_error()}

Load all *.toml skill definitions from the given directory.

Returns a list of loaded skill maps containing the validated skill struct and provenance (source, path).

Duplicate names within the directory are returned as an error.

load_file(path, source)

@spec load_file(String.t(), skill_source()) ::
  {:ok, loaded_skill()} | {:error, load_error()}

Load a single skill TOML file.

load_files(paths, source)

@spec load_files([String.t()], skill_source()) ::
  {:ok, [loaded_skill()]} | {:error, load_error()}

Load a list of TOML files as skill definitions.

Duplicate names within the file set are returned as an error.