| 1 | package Skilletor::ClaudeSettings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: The plugin requirement in a project's committed .claude/settings.json (spec ยง6.8, k140) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 31 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 31 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 31 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 31 | ▶ | use Errno (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 31 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 31 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 31 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 31 | ▶ | use Skilletor::FSUtil qw( encode_text node_fs_error path_join read_text same_path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 31 | ▶ | use Skilletor::JSON qw( js_ordered js_parse js_sort_keys js_stringify js_type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 31 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 31 | our @EXPORT_OK = qw( plan_claude_settings skilletor_marketplace not_declarable OFFICIAL_MARKETPLACE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 31 | ▶ | use constant OFFICIAL_MARKETPLACE => 'claude-plugins-official'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 31 | ▶ | use constant PLUGIN => 'skilletor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _is_object { js_type( $_[0] ) eq 'object' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_object: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # A JSON object file, or undef (missing, unreadable, not JSON, not an object). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub _read_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_object: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my ( $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $v = eval { js_parse( read_text($path) ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | return _is_object($v) ? $v : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # `name@marketplace` โ its parts; undef for a key of another form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub _plugin_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_plugin_key: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ( $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $at = rindex $key, '@'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return undef if $at <= 0 || $at == length($key) - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$at <= 0 or $at == length($key) - 1
MC/DC0%0/2
$at <= 0 or $at == length($key) - 1
$at <= 0
$at == length($key) - 1
Truth table0%0/3
A or B
A= $at <= 0B= $at == length($key) - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return { name => substr( $key, 0, $at ), marketplace => substr( $key, $at + 1 ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub _str { js_type( $_[0] ) eq 'string' ? $_[0] : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_str: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # skilletor's installs from installed_plugins.json (a list per key; an older file's single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # object is read as a list of one). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub _skilletor_installs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skilletor_installs: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my ( $claude_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $file = _read_object( path_join( $claude_dir, 'plugins', 'installed_plugins.json' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $plugins = $file ? $file->{plugins} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return () unless _is_object($plugins); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | for my $key ( keys %$plugins ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $k = _plugin_key($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | next unless $k && $k->{name} eq PLUGIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$k and $k->{"name"} eq "skilletor"
MC/DC0%0/2
$k and $k->{"name"} eq "skilletor"
$k
$k->{"name"} eq "skilletor"
Truth table0%0/3
A and B
A= $kB= $k->{"name"} eq "skilletor"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $value = $plugins->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | for my $e ( js_type($value) eq 'array' ? @$value : ($value) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | next unless _is_object($e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | push @out, { marketplace => $k->{marketplace}, map { ( $_ => _str( $e->{$_} ) ) } qw( scope installPath projectPath ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub _unique { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unique: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return grep { !$seen{$_}++ } map { $_->{marketplace} } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # The marketplace skilletor is installed from, for this project: the install the running plugin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # is, else the one marketplace of the user's install and this project's. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub skilletor_marketplace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skilletor_marketplace: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ( $claude_dir, $project_dir, $plugin_root ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my @installs = _skilletor_installs($claude_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( defined $plugin_root && length $plugin_root ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $plugin_root and length $plugin_root
MC/DC0%0/2
defined $plugin_root and length $plugin_root
defined $plugin_root
length $plugin_root
Truth table0%0/3
A and B
A= defined $plugin_rootB= length $plugin_root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my @running = _unique( grep { defined $_->{installPath} && same_path( $_->{installPath}, $plugin_root ) } @installs ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_->{'installPath'} && same_path($_->{'installPath'}, $plugin_root)
MC/DC0%0/2
defined $_->{'installPath'} && same_path($_->{'installPath'}, $plugin_root)
defined $_->{'installPath'}
same_path($_->{'installPath'}, $plugin_root)
Truth table0%0/3
A && B
A= defined $_->{'installPath'}B= same_path($_->{'installPath'}, $plugin_root)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | return { name => $running[0] } if @running == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | my @here = _unique( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | ( defined $_->{scope} && $_->{scope} eq 'user' ) || ( defined $_->{projectPath} && same_path( $_->{projectPath}, $project_dir ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
defined $_->{'scope'} && $_->{'scope'} eq 'user' || defined $_->{'projectPath'} && same_path($_->{'projectPath'}, $project_dir)
defined $_->{"scope"} and $_->{"scope"} eq "user"
defined $_->{"projectPath"} and same_path($_->{"projectPath"}, $project_dir)
MC/DC0%0/4
defined $_->{'scope'} && $_->{'scope'} eq 'user' || defined $_->{'projectPath'} && same_path($_->{'projectPath'}, $project_dir)
defined $_->{"scope"}
$_->{"scope"} eq "user"
defined $_->{"projectPath"}
same_path($_->{"projectPath"}, $project_dir)
Truth table0%0/7
A and B || C and D
A= defined $_->{"scope"}B= $_->{"scope"} eq "user"C= defined $_->{"projectPath"}D= same_path($_->{"projectPath"}, $project_dir)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } @installs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return { name => $here[0] } if @here == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return @here > 1 ? { ambiguous => [ js_sort_keys(@here) ] } : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub _is_remote_git { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_remote_git: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my ( $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | return ( $url =~ m{\A(?:https?|ssh|git)://}i || $url =~ m{\A[\w.-]+\@[\w.-]+:(?!//)}a ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$url =~ m[\A(?:https?|ssh|git)://]i or $url =~ m[\A[\w.-]+\@[\w.-]+:(?!//)]a
MC/DC0%0/2
$url =~ m[\A(?:https?|ssh|git)://]i or $url =~ m[\A[\w.-]+\@[\w.-]+:(?!//)]a
$url =~ m[\A(?:https?|ssh|git)://]i
$url =~ m[\A[\w.-]+\@[\w.-]+:(?!//)]a
Truth table0%0/3
A or B
A= $url =~ m[\A(?:https?|ssh|git)://]iB= $url =~ m[\A[\w.-]+\@[\w.-]+:(?!//)]a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Why a marketplace source must not go into a committed file, or undef when it may. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub not_declarable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not_declarable: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my ( $source ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | return 'no readable source' unless _is_object($source); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $kind = js_type( $source->{source} ) eq 'string' ? $source->{source} : 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return undef if $kind eq 'github' && js_type( $source->{repo} ) eq 'string' && length $source->{repo}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$kind eq "github" and js_type($source->{"repo"}) eq "string" and length $source->{"repo"}
$kind eq "github" and js_type($source->{"repo"}) eq "string"
MC/DC0%0/3
$kind eq "github" and js_type($source->{"repo"}) eq "string" and length $source->{"repo"}
$kind eq "github"
js_type($source->{"repo"}) eq "string"
length $source->{"repo"}
Truth table0%0/4
A and B and C
A= $kind eq "github"B= js_type($source->{"repo"}) eq "string"C= length $source->{"repo"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | return undef if $kind eq 'git' && js_type( $source->{url} ) eq 'string' && _is_remote_git( $source->{url} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$kind eq "git" and js_type($source->{"url"}) eq "string" and _is_remote_git($source->{"url"})
$kind eq "git" and js_type($source->{"url"}) eq "string"
MC/DC0%0/3
$kind eq "git" and js_type($source->{"url"}) eq "string" and _is_remote_git($source->{"url"})
$kind eq "git"
js_type($source->{"url"}) eq "string"
_is_remote_git($source->{"url"})
Truth table0%0/4
A and B and C
A= $kind eq "git"B= js_type($source->{"url"}) eq "string"C= _is_remote_git($source->{"url"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | return undef if $kind eq 'url' && js_type( $source->{url} ) eq 'string' && $source->{url} =~ m{\Ahttps?://}i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$kind eq "url" and js_type($source->{"url"}) eq "string" and $source->{"url"} =~ m[\Ahttps?://]i
$kind eq "url" and js_type($source->{"url"}) eq "string"
MC/DC0%0/3
$kind eq "url" and js_type($source->{"url"}) eq "string" and $source->{"url"} =~ m[\Ahttps?://]i
$kind eq "url"
js_type($source->{"url"}) eq "string"
$source->{"url"} =~ m[\Ahttps?://]i
Truth table0%0/4
A and B and C
A= $kind eq "url"B= js_type($source->{"url"}) eq "string"C= $source->{"url"} =~ m[\Ahttps?://]i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return 'a git source on a local path' if $kind eq 'git'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return 'a '.$kind.' source'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # The text layout of an existing file: its indent, line ending and final newline. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub _layout_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_layout_of: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ( $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my $indent = ( $text =~ /^([ \t]+)"/m && length($1) <= 10 ) ? $1 : ' '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$text =~ /^([ \t]+)"/m and length $1 <= 10
MC/DC0%0/2
$text =~ /^([ \t]+)"/m and length $1 <= 10
$text =~ /^([ \t]+)"/m
length $1 <= 10
Truth table0%0/3
A and B
A= $text =~ /^([ \t]+)"/mB= length $1 <= 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return ( $indent, ( index( $text, "\r\n" ) >= 0 ? "\r\n" : "\n" ), ( $text =~ /\n\z/ ? 1 : 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub _message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ( $err ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return $err->message if blessed $err && $err->can('message'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($err) and $err->can("message")
MC/DC0%0/2
builtin::blessed($err) and $err->can("message")
builtin::blessed($err)
$err->can("message")
Truth table0%0/3
A and B
A= builtin::blessed($err)B= $err->can("message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return "$err" =~ s/ at \S+ line \d+\.?\n?\z//r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Plan the additions; reads the settings file and Claude Code's plugin state only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub plan_claude_settings { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan_claude_settings: not called CC=41 SCAR=74.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ( %a ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $plan = { enabled => [], declared => [], warnings => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | my $leave = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | push @{ $plan->{warnings} }, $a{label}.' '.$_[0].'; plugin requirement not written'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $plan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $bytes = encode_text( $a{file} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( my @st = lstat $bytes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return $leave->('is a symbolic link') if -l _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return $leave->('is not a file') unless -f _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( open my $fh, '<:raw', $bytes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $text = read_text( $a{file} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return $leave->( 'cannot be read ('.node_fs_error( 0 + $!, 'open', $a{file} ).')' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | elsif ( !$!{ENOENT} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $leave->( 'cannot be read ('.node_fs_error( 0 + $!, 'lstat', $a{file} ).')' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $settings = js_ordered(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ( defined $text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return $leave->( 'is not valid JSON ('._message($@).')' ) unless eval { $parsed = js_parse($text); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return $leave->('is not a JSON object') unless _is_object($parsed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $settings = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | for my $key (qw( enabledPlugins extraKnownMarketplaces )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return $leave->( 'has an "'.$key.'" that is not an object' ) if exists $settings->{$key} && !_is_object( $settings->{$key} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $settings->{$key} and not _is_object($settings->{$key})
MC/DC0%0/2
exists $settings->{$key} and not _is_object($settings->{$key})
exists $settings->{$key}
not _is_object($settings->{$key})
Truth table0%0/3
A and not(B)
A= exists $settings->{$key}B= not _is_object($settings->{$key})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $enabled = $settings->{enabledPlugins} // js_ordered(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$settings->{"enabledPlugins"} // js_ordered()
MC/DC0%0/2
$settings->{"enabledPlugins"} // js_ordered()
$settings->{"enabledPlugins"}
js_ordered()
Truth table0%0/3
A // B
A= $settings->{"enabledPlugins"}B= js_ordered()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $declared = $settings->{extraKnownMarketplaces} // js_ordered(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$settings->{"extraKnownMarketplaces"} // js_ordered()
MC/DC0%0/2
$settings->{"extraKnownMarketplaces"} // js_ordered()
$settings->{"extraKnownMarketplaces"}
js_ordered()
Truth table0%0/3
A // B
A= $settings->{"extraKnownMarketplaces"}B= js_ordered()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my $known = _read_object( path_join( $a{claude_dir}, 'plugins', 'known_marketplaces.json' ) ) // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_read_object(path_join($a{"claude_dir"}, "plugins", "known_marketplaces.json")) // {}
MC/DC0%0/1
_read_object(path_join($a{"claude_dir"}, "plugins", "known_marketplaces.json")) // {}
_read_object(path_join($a{"claude_dir"}, "plugins", "known_marketplaces.json"))
Truth table0%0/2
A
A= _read_object(path_join($a{"claude_dir"}, "plugins", "known_marketplaces.json"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my $source_of = sub { _is_object( $known->{ $_[0] } ) ? $known->{ $_[0] }{source} : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $needs = 'a committed file takes a github, git or url source'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # skilletor itself โ unless the file names it already, from any marketplace, on or off. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | unless ( grep { my $k = _plugin_key($_); $k && $k->{name} eq PLUGIN } keys %$enabled ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$k && $k->{'name'} eq 'skilletor'
MC/DC0%0/2
$k && $k->{'name'} eq 'skilletor'
$k
$k->{'name'} eq 'skilletor'
Truth table0%0/3
A && B
A= $kB= $k->{'name'} eq 'skilletor'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $own = skilletor_marketplace( $a{claude_dir}, $a{project_dir}, $a{plugin_root} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( $own->{ambiguous} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | push @{ $plan->{warnings} }, 'skilletor is installed from several marketplaces ('.join( ', ', @{ $own->{ambiguous} } ).'); ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | .$a{label}.' does not get it โ enable the one teammates should use'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | elsif ( defined $own->{name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $m = $own->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | my $why = ( $m eq OFFICIAL_MARKETPLACE || exists $declared->{$m} ) ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | : !exists $known->{$m} ? q{no entry in Claude Code's known marketplaces} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$m eq "claude-plugins-official" or exists $declared->{$m}
MC/DC0%0/2
$m eq "claude-plugins-official" or exists $declared->{$m}
$m eq "claude-plugins-official"
exists $declared->{$m}
Truth table0%0/3
A or B
A= $m eq "claude-plugins-official"B= exists $declared->{$m}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | : not_declarable( $source_of->($m) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( defined $why ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | push @{ $plan->{warnings} }, 'skilletor\'s marketplace "'.$m.'" has '.$why.' on this machine; '.$a{label} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | .' does not get skilletor@'.$m.' ('.$needs.')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | push @{ $plan->{enabled} }, PLUGIN.'@'.$m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Every marketplace an entry that is not switched off needs, in the order of the entries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my @additions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my @wanted = ( ( grep { my $on = $enabled->{$_}; !( js_type($on) eq 'boolean' && !$on ) } keys %$enabled ), @{ $plan->{enabled} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
js_type($on) eq 'boolean' && !$on
MC/DC0%0/2
js_type($on) eq 'boolean' && !$on
js_type($on) eq 'boolean'
!$on
Truth table0%0/3
A && not(B)
A= js_type($on) eq 'boolean'B= !$on
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | for my $key (@wanted) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $k = _plugin_key($key) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $m = $k->{marketplace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | next if $seen{$m}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | next if $m eq OFFICIAL_MARKETPLACE || exists $declared->{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$m eq "claude-plugins-official" or exists $declared->{$m}
MC/DC0%0/2
$m eq "claude-plugins-official" or exists $declared->{$m}
$m eq "claude-plugins-official"
exists $declared->{$m}
Truth table0%0/3
A or B
A= $m eq "claude-plugins-official"B= exists $declared->{$m}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $users = join ', ', grep { my $x = _plugin_key($_); $x && $x->{marketplace} eq $m } @wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$x && $x->{'marketplace'} eq $m
MC/DC0%0/2
$x && $x->{'marketplace'} eq $m
$x
$x->{'marketplace'} eq $m
Truth table0%0/3
A && B
A= $xB= $x->{'marketplace'} eq $m
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | unless ( exists $known->{$m} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | push @{ $plan->{warnings} }, 'marketplace "'.$m.'" ('.$users.') is not known to Claude Code on this machine; not declared in '.$a{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( defined( my $why = not_declarable( $source_of->($m) ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | push @{ $plan->{warnings} }, 'marketplace "'.$m.'" ('.$users.') has '.$why.' on this machine; not declared in '.$a{label}.' ('.$needs.')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | push @additions, [ $m, js_ordered( source => $source_of->($m) ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | push @{ $plan->{declared} }, $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return $plan unless @{ $plan->{enabled} } || @additions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$plan->{"enabled"};} or @additions
MC/DC0%0/2
@{$plan->{"enabled"};} or @additions
@{$plan->{"enabled"};}
@additions
Truth table0%0/3
A or B
A= @{$plan->{"enabled"};}B= @additions
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # Add only: every key stays where it was, new ones go last. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $next = js_ordered( map { ( $_ => $settings->{$_} ) } keys %$settings ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( @{ $plan->{enabled} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $e = js_ordered( map { ( $_ => $enabled->{$_} ) } keys %$enabled ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $e->{$_} = JSON::MaybeXS::true() for @{ $plan->{enabled} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $next->{enabledPlugins} = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (@additions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $d = js_ordered( map { ( $_ => $declared->{$_} ) } keys %$declared ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $d->{ $_->[0] } = $_->[1] for @additions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $next->{extraKnownMarketplaces} = $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | my ( $indent, $eol, $final ) = defined $text ? _layout_of($text) : ( ' ', "\n", 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $body = js_stringify( $next, $indent ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $body = join $eol, split /\n/, $body, -1 if $eol ne "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $plan->{next} = $body.( $final ? $eol : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | return $plan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 31 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||