Table of Contents

Method LoadFromDirectoryAsync

Namespace
LMKit.Agents.Skills
Assembly
LM-Kit.NET.dll

LoadFromDirectoryAsync(string, bool, Action<string, Exception>, CancellationToken)

Asynchronously loads all skills from subdirectories of the specified path.

Each immediate subdirectory is checked for a SKILL.md file. Invalid skills are skipped and logged via errorHandler.

public Task<int> LoadFromDirectoryAsync(string directoryPath, bool overwrite = false, Action<string, Exception> errorHandler = null, CancellationToken cancellationToken = default)

Parameters

directoryPath string

The path containing skill subdirectories.

overwrite bool

Whether to overwrite existing skills.

errorHandler Action<string, Exception>

Optional callback for handling parse errors. If null, errors are silently ignored.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<int>

A task that represents the asynchronous operation, containing the number of skills successfully loaded.

Examples

Asynchronously loading all skills from a directory:

var registry = new SkillRegistry();
int loaded = await registry.LoadFromDirectoryAsync("./skills");
Console.WriteLine($"Loaded {loaded} skills asynchronously");

Exceptions

ArgumentNullException

Thrown when directoryPath is null.

DirectoryNotFoundException

Thrown when the specified directory does not exist.

OperationCanceledException

Thrown when the operation is cancelled.