Dist-Conformance
view release on metacpan or search on metacpan
lib/Dist/Conformance/Check/ClaudeMd.pm view on Meta::CPAN
package Dist::Conformance::Check::ClaudeMd 0.003;
# ABSTRACT: CLAUDE.md exists and names the skills that it must
use 5.040;
use warnings FATAL => 'all';
use re '/aasx';
use Mojo::Base 'Dist::Conformance::Check', -signatures;
use Dist::Conformance::Schema();
sub config_schema ($) {
return {
required => [qw{file mentions}],
properties => {
file => $Dist::Conformance::Schema::PATH,
mentions => { type => 'array', items => { type => 'string', minLength => 1 } },
template => $Dist::Conformance::Schema::PATH,
},
};
}
sub check ( $self, $snapshot ) {
my ( $file, $mentions ) = @{ $self->config }{qw{file mentions}};
my $text = $snapshot->content($file) // return ( 'fail', "$file is missing" );
my @absent = grep { index( $text, $_ ) < 0 } @$mentions;
return ( 'fail', "$file does not name " . join ', ', @absent ) if @absent;
return ( 'pass', @$mentions ? 'names ' . join ', ', @$mentions : "$file exists" );
}
sub update ( $self, $update ) {
my ( $status, $detail ) = $self->check( $update->snapshot );
return if $status ne 'fail';
my $start = defined $self->config->{template} ? ', starting from ' . $self->config->{template} : q{};
$update->by_hand("$detail: write it by hand$start, because its prose cannot be generated");
return;
}
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Conformance::Check::ClaudeMd - CLAUDE.md exists and names the skills that it must
=head1 VERSION
version 0.003
=head1 DESCRIPTION
The instructions that an agent reads first. The check passes when the file
exists and contains each string of C<mentions>. It fails when the file is
missing, or when a string is not in it.
Its update writes nothing. What the file says about a repository is prose that
a person writes, so the update names the file, the template to start from, and
what the file lacks.
=head1 METHODS
=head2 check
=head2 update
Records what the file needs, for a person.
=head1 IN A FLAVOR
checks:
ClaudeMd:
file: CLAUDE.md
template: templates/CLAUDE.md
mentions:
- perl-slop:reading-perl
=head1 CONFIGURATION
=over
=item file
Required. The path of the file.
=item mentions
Required. The strings that the file must contain, such as the names of the
skills that it tells an agent to load. An empty list asks only that the file
( run in 1.606 second using v1.01-cache-2.11-cpan-1236ad508bc )