NAME

Skilletor::Backend - Choose a source's backend (author mode) and build it – one value for trust and fetch

VERSION

version 0.001

SYNOPSIS

use Skilletor::Backend;
use Skilletor::Cache qw( cache_root );

my $src     = $config->source('shared');
my $backend = Skilletor::Backend->resolve( $src, $home );
# { kind => 'local', address => '/home/me/dev/skills', origin => 'user' }

unless ( $state->is_trusted( shared => $backend ) ) { ... }   # project origin: ask first

my $loc = Skilletor::Backend->make( $backend, cache_root($home) )->resolve;

DESCRIPTION

The reference's resolveBackend and makeBackend (engine.ts; spec §3, §4.3): choosing the backend and checking trust work on one value, so they cannot disagree. A source with a local whose directory exists is read from there (author mode); else its git, else its url. The backend carries the origin of the field it came from – what trust is checked against – and the source's path as a list.

Class methods throughout; override "local_class", "git_class" or "url_class" in a subclass to swap a backend.

resolve

Skilletor::Backend->resolve( $source, $home );

{ kind, address, origin, ref?, path? }. A local address is absolute and, when the directory exists, its real path.

make

Skilletor::Backend->make( $backend, $cache_root, $timeout_ms );

The Skilletor::Role::Source object for it.

identity

The backend identity a run resolves once (JSON.stringify([kind, address, ref ?? null])).

trust_request

Skilletor::Backend->trust_request( $name, $backend );   # { name, kind, url }

local_dir

Skilletor::Backend->local_dir( $path, $home );   # { path, exists }

A local field as an absolute path; the real path when it is an existing directory.

local_class

The class built for a local backend (Skilletor::Source::Local).

git_class

The class built for a git backend (Skilletor::Source::Git).

url_class

The class built for a url backend (Skilletor::Source::Url).

SUPPORT

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.