Jido.AI.Skill.Diagnostics (Jido AI v2.2.0)

Copy Markdown View Source

Tracks parsing and loading warnings for skill diagnostics.

Diagnostics capture non-fatal issues encountered during skill loading, including:

  • Parent directory name mismatches
  • Cosmetic naming violations
  • Truncated fields
  • Missing optional metadata

Diagnostics enable tooling to display warnings to users without blocking skill functionality.

Usage

# Create fresh diagnostics
diagnostics = Diagnostics.new()

# Add a warning
diagnostics = Diagnostics.add_warning(diagnostics, Diagnostics.Warning.new(:name_mismatch, "..."))

# Check for issues
Diagnostics.has_warnings?(diagnostics)
Diagnostics.has_errors?(diagnostics)

# Convert to map for storage
Diagnostics.to_map(diagnostics)

Summary

Functions

Adds an error to the diagnostics (non-fatal in lenient mode).

Adds a warning to the diagnostics.

Returns the count of errors.

Formats diagnostics for display in logs or tooling.

Returns true if there are any errors.

Returns true if there are any warnings or errors.

Returns true if there are any warnings.

Creates a new empty diagnostics struct.

Converts diagnostics to a plain map for storage in metadata.

Returns the count of warnings.

Types

t()

@type t() :: %Jido.AI.Skill.Diagnostics{
  errors: [map()],
  timestamp: DateTime.t() | nil,
  warnings: [Jido.AI.Skill.Diagnostics.Warning.t()]
}

Functions

add_error(diag, error)

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

Adds an error to the diagnostics (non-fatal in lenient mode).

add_warning(diag, warning)

@spec add_warning(t(), Jido.AI.Skill.Diagnostics.Warning.t()) :: t()

Adds a warning to the diagnostics.

error_count(diagnostics)

@spec error_count(t()) :: non_neg_integer()

Returns the count of errors.

format(diag)

@spec format(t() | nil) :: String.t()

Formats diagnostics for display in logs or tooling.

has_errors?(diagnostics)

@spec has_errors?(t()) :: boolean()

Returns true if there are any errors.

has_issues?(diag)

@spec has_issues?(t()) :: boolean()

Returns true if there are any warnings or errors.

has_warnings?(diagnostics)

@spec has_warnings?(t()) :: boolean()

Returns true if there are any warnings.

new()

@spec new() :: t()

Creates a new empty diagnostics struct.

to_map(diag)

@spec to_map(t() | nil) :: map() | nil

Converts diagnostics to a plain map for storage in metadata.

warning_count(diagnostics)

@spec warning_count(t()) :: non_neg_integer()

Returns the count of warnings.