lib/App/Briefing/Team.pm

filter: Statementstmt 50.9% 210 / 412 Branchbran 46.2% 111 / 240 Conditioncond 36.2% 29 / 80 MC/DCmcdc 29.1% 14 / 48 Subroutinesub 57.1% 12 / 21 Podpod 100% 2 / 2 totaltotal 47.0% 378 / 803 CC 167 SCAR 42.2
CC
167
Cov
48%
_parse_agent
127.0
_parse_agent
127.0
_check_agents
71.8
CRAP 68.3
↑ Summary lib/App/Briefing/CLI.pm »
1 package App::Briefing::Team;
2 # ABSTRACT: Findings about a project's Claude Code agent team
3  
4 131 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 131 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 131 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 131 our $VERSION = '0.006000';
9  
10 131 has briefing => ( is => 'ro', required => 1 );
11  
12  
13 2527 ▶sub _trim {
Subroutine _trim: called CC=2 SCAR=10.1
14 0 ▶ my ( $value ) = @_;
Subroutine _trim: not called CC=2 SCAR=10.1
15 0 ▶ $value = '' unless defined $value;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $value 0 2527 2527
unless defined $value 0 0 0
16 0 $value =~ s/\A\s+//;
17 0 $value =~ s/\s+\z//;
18 0 return $value;
19 }
20  
21 277 ▶sub _unquote {
Subroutine _unquote: called CC=3 SCAR=14.2
22 0 ▶ my ( $value ) = @_;
Subroutine _unquote: not called CC=3 SCAR=14.2
23 0 $value = _trim($value);
24 0 ▶ if ($value =~ /\A"([^"]*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value =~ /\A"([^"]*)/) 2 275 277
if ($value =~ /\A"([^"]*)/) 0 0 0
25 0 return $1;
26 }
27 0 ▶ if ($value =~ /\A'([^']*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value =~ /\A'([^']*)/) 1 274 275
if ($value =~ /\A'([^']*)/) 0 0 0
28 0 return $1;
29 }
30 0 $value =~ s/[ \t]#.*\z//s;
31 0 return _trim($value);
32 }
33  
34 # Reads only the frontmatter, like the team check always did: the lines between
35 # a first line "---" (a BOM before it is fine) and the next "---".
36 143 ▶sub _parse_agent {
Subroutine _parse_agent: called CC=25 SCAR=48.4
37 0 ▶ my ( $text ) = @_;
Subroutine _parse_agent: not called CC=25 SCAR=48.4
38 0 my %agent = (
39 frontmatter => 0,
40 has_name => 0,
41 name => '',
42 description => 0,
43 allowed => 0,
44 top_skills => 0,
45 bad_list => 0,
46 );
47 0 ▶ $text = '' unless defined $text;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $text 0 143 143
unless defined $text 0 0 0
48 0 $text =~ s/\A\x{FEFF}//;
49 0 my @lines = split /\r?\n/, $text;
50 0 ▶ return \%agent unless @lines && _trim( $lines[0] ) eq '---';
Branch: 2 branches
BranchTrueFalseTotal
unless @lines and _trim($lines[0]) eq "---" 1 142 143
unless @lines and _trim($lines[0]) eq "---" 0 0 0
Condition33%2/6
@lines and _trim($lines[0]) eq "---"
!ll&&!rl&&r
01142
@lines and _trim($lines[0]) eq "---"
!ll&&!rl&&r
000
MC/DC50%1/2
@lines and _trim($lines[0]) eq "---"
@lines _trim($lines[0]) eq "---"
MC/DC0%0/2
@lines and _trim($lines[0]) eq "---"
@lines _trim($lines[0]) eq "---"
Truth table66%2/3
A and B
A= @linesB= _trim($lines[0]) eq "---"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= @linesB= _trim($lines[0]) eq "---"
ABresult
0X0
100
111
51 0 $agent{frontmatter} = 1;
52 0 shift @lines;
53  
54 0 my ( $mode, $briefing_indent ) = ( '', -1 );
55 0 for my $line (@lines) {
56 0 my $trimmed = _trim($line);
57 0 ▶ last if $trimmed eq '---';
Branch: 2 branches
BranchTrueFalseTotal
if $trimmed eq "---" 142 707 849
if $trimmed eq "---" 0 0 0
58 0 ▶ next if $trimmed eq '' || $trimmed =~ /\A#/;
Branch: 2 branches
BranchTrueFalseTotal
if $trimmed eq "" or $trimmed =~ /\A#/ 0 707 707
if $trimmed eq "" or $trimmed =~ /\A#/ 0 0 0
Condition16%1/6
$trimmed eq "" or $trimmed =~ /\A#/
l!l&&r!l&&!r
00707
$trimmed eq "" or $trimmed =~ /\A#/
l!l&&r!l&&!r
000
MC/DC0%0/2
$trimmed eq "" or $trimmed =~ /\A#/
$trimmed eq "" $trimmed =~ /\A#/
MC/DC0%0/2
$trimmed eq "" or $trimmed =~ /\A#/
$trimmed eq "" $trimmed =~ /\A#/
Truth table33%1/3
A or B
A= $trimmed eq ""B= $trimmed =~ /\A#/
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $trimmed eq ""B= $trimmed =~ /\A#/
ABresult
1X1
011
000
59  
60 0 ▶ if ($line =~ /\A[ \t]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ /\A[ \t]/) 284 423 707
if ($line =~ /\A[ \t]/) 0 0 0
61 0 ▶ if ($mode eq 'description') {
Branch: 4 branches
BranchTrueFalseTotal
if ($mode eq 'description') { } 6 278 284
elsif ($mode eq 'briefing') { } 276 2 278
if ($mode eq 'description') { } 0 0 0
elsif ($mode eq 'briefing') { } 0 0 0
62 0 $agent{description} = 1;
63 }
64 elsif ($mode eq 'briefing') {
65 0 my ($indent) = $line =~ /\A([ \t]*)/;
66 0 ▶ $briefing_indent = length $indent if $briefing_indent == -1;
Branch: 2 branches
BranchTrueFalseTotal
if $briefing_indent == -1 138 138 276
if $briefing_indent == -1 0 0 0
67 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent) 138 138 276
if ($trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent) 0 0 0
Condition33%2/6
$trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent
!ll&&!rl&&r
1380138
$trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent
!ll&&!rl&&r
000
MC/DC50%1/2
$trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent
$trimmed =~ /\Askills:(.*)\z/s length $indent == $briefing_indent
MC/DC0%0/2
$trimmed =~ /\Askills:(.*)\z/s and length $indent == $briefing_indent
$trimmed =~ /\Askills:(.*)\z/s length $indent == $briefing_indent
Truth table66%2/3
A and B
A= $trimmed =~ /\Askills:(.*)\z/sB= length $indent == $briefing_indent
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $trimmed =~ /\Askills:(.*)\z/sB= length $indent == $briefing_indent
ABresult
0X0
100
111
68 $trimmed =~ /\Askills:(.*)\z/s
69 && length($indent) == $briefing_indent
70 ) {
71 0 my $value = _trim($1);
72 0 ▶ $agent{bad_list} = 1
Branch: 2 branches
BranchTrueFalseTotal
if $value =~ /\A\[/ and not $value =~ /\]/ 1 137 138
if $value =~ /\A\[/ and not $value =~ /\]/ 0 0 0
Condition50%3/6
$value =~ /\A\[/ and not $value =~ /\]/
!ll&&!rl&&r
13611
$value =~ /\A\[/ and not $value =~ /\]/
!ll&&!rl&&r
000
MC/DC100%2/2
$value =~ /\A\[/ and not $value =~ /\]/
$value =~ /\A\[/ not $value =~ /\]/
MC/DC0%0/2
$value =~ /\A\[/ and not $value =~ /\]/
$value =~ /\A\[/ not $value =~ /\]/
Truth table100%3/3
A and not(B)
A= $value =~ /\A\[/B= not $value =~ /\]/
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $value =~ /\A\[/B= not $value =~ /\]/
ABresult
0X0
100
111
73 if $value =~ /\A\[/ && $value !~ /\]/;
74 }
75 }
76 0 next;
77 }
78  
79 0 $mode = '';
80 0 ▶ next unless $trimmed =~ /\A([^:]*):(.*)\z/s;
Branch: 2 branches
BranchTrueFalseTotal
unless $trimmed =~ /\A([^:]*):(.*)\z/s 0 423 423
unless $trimmed =~ /\A([^:]*):(.*)\z/s 0 0 0
81 0 my ( $key, $value ) = ( _trim($1), _trim($2) );
82 0 ▶ if ($key eq 'name') {
Branch: 10 branches
BranchTrueFalseTotal
if ($key eq 'name') { } 141 282 423
elsif ($key eq 'description') { } 141 141 282
elsif ($key eq 'allowed-tools') { } 1 140 141
elsif ($key eq 'skills') { } 2 138 140
elsif ($key eq 'briefing') { } 138 0 138
if ($key eq 'name') { } 0 0 0
elsif ($key eq 'description') { } 0 0 0
elsif ($key eq 'allowed-tools') { } 0 0 0
elsif ($key eq 'skills') { } 0 0 0
elsif ($key eq 'briefing') { } 0 0 0
83 0 $agent{has_name} = 1;
84 0 $agent{name} = _unquote($value);
85 }
86 elsif ($key eq 'description') {
87 0 ▶ if ($value eq '' || $value =~ /\A[#>|]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value eq '' or $value =~ /\A[#>|]/) { } 5 136 141
if ($value eq '' or $value =~ /\A[#>|]/) { } 0 0 0
Condition50%3/6
$value eq "" or $value =~ /\A[#>|]/
l!l&&r!l&&!r
14136
$value eq "" or $value =~ /\A[#>|]/
l!l&&r!l&&!r
000
MC/DC100%2/2
$value eq "" or $value =~ /\A[#>|]/
$value eq "" $value =~ /\A[#>|]/
MC/DC0%0/2
$value eq "" or $value =~ /\A[#>|]/
$value eq "" $value =~ /\A[#>|]/
Truth table100%3/3
A or B
A= $value eq ""B= $value =~ /\A[#>|]/
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $value eq ""B= $value =~ /\A[#>|]/
ABresult
1X1
011
000
88 0 $mode = 'description';
89 }
90 else {
91 0 ▶ $agent{description} = 1 if length _unquote($value);
Branch: 2 branches
BranchTrueFalseTotal
if length _unquote($value) 135 1 136
if length _unquote($value) 0 0 0
92 }
93 }
94 elsif ($key eq 'allowed-tools') {
95 0 $agent{allowed} = 1;
96 }
97 elsif ($key eq 'skills') {
98 0 $agent{top_skills} = 1;
99 }
100 elsif ($key eq 'briefing') {
101 0 ( $mode, $briefing_indent ) = ( 'briefing', -1 );
102 }
103 }
104 0 return \%agent;
105 }
106  
107 67 ▶sub _agent_files {
Subroutine _agent_files: called CC=9 SCAR=30.5
108 0 ▶ my ( $self ) = @_;
Subroutine _agent_files: not called CC=9 SCAR=30.5
109 0 my $fs = $self->briefing->filesystem;
110 0 my $root = $fs->join_path( $self->briefing->cwd, '.claude', 'agents' );
111 0 my @found;
112 0 my @pending = ('');
113 0 ▶ while (@pending) {
Branch: 2 branches
BranchTrueFalseTotal
if (@pending) 68 67 135
if (@pending) 0 0 0
114 0 my $relative = shift @pending;
115 0 ▶ my $directory = length $relative ? $fs->join_path( $root, $relative ) : $root;
Branch: 2 branches
BranchTrueFalseTotal
length $relative ? : 1 67 68
length $relative ? : 0 0 0
116 0 for my $name (@{ $fs->children($directory) }) {
117 0 ▶ my $child = length $relative ? $relative.'/'.$name : $name;
Branch: 2 branches
BranchTrueFalseTotal
length $relative ? : 1 146 147
length $relative ? : 0 0 0
118 0 my $path = $fs->join_path( $root, $child );
119 0 ▶ if ($fs->is_dir($path)) {
Branch: 4 branches
BranchTrueFalseTotal
if ($fs->is_dir($path)) { } 1 146 147
elsif ($name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)) { } 145 2 147
if ($fs->is_dir($path)) { } 0 0 0
elsif ($name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)) { } 0 0 0
120 0 push @pending, $child;
121 }
122 ▶ elsif ($name =~ /\.md\z/ && ($fs->is_file($path) || $fs->is_dangling_symlink($path))) {
Condition33%4/12
$name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)
!ll&&!rl&&r
10145
$fs->is_file($path) or $fs->is_dangling_symlink($path)
l!l&&r!l&&!r
14320
$name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)
!ll&&!rl&&r
000
$fs->is_file($path) or $fs->is_dangling_symlink($path)
l!l&&r!l&&!r
000
MC/DC33%1/3
$name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)
$name =~ /\.md\z/ $fs->is_file($path) $fs->is_dangling_symlink($path)
MC/DC0%0/3
$name =~ /\.md\z/ and $fs->is_file($path) || $fs->is_dangling_symlink($path)
$name =~ /\.md\z/ $fs->is_file($path) $fs->is_dangling_symlink($path)
Truth table75%3/4
A and B or C
A= $name =~ /\.md\z/B= $fs->is_file($path)C= $fs->is_dangling_symlink($path)
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
A and B or C
A= $name =~ /\.md\z/B= $fs->is_file($path)C= $fs->is_dangling_symlink($path)
ABCresult
0XX0
1000
11X1
1011
123 0 push @found, [ $child, $path ];
124 }
125 }
126 }
127 0 return [ sort { $a->[0] cmp $b->[0] } @found ];
128 }
129  
130 360 ▶sub _finding {
Subroutine _finding: called CC=2 SCAR=9.8
131 0 ▶ my ( $what, $status, $name, $text ) = @_;
Subroutine _finding: not called CC=2 SCAR=9.8
132 my @fields = map {
133 0 ▶ my $field = defined $_ ? $_ : '';
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 1440 0 1440
defined $_ ? : 0 0 0
134 0 $field =~ s/\t/ /g;
135 0 $field =~ s/\r//g;
136 0 $field =~ s/\n/ /g;
137 0 $field;
138 } ( $what, $status, $name, $text );
139 0 return { what => $fields[0], status => $fields[1], name => $fields[2], text => $fields[3] };
140 }
141  
142 67 ▶sub _check_agents {
Subroutine _check_agents: called CC=20 SCAR=42.7
143 0 ▶ my ( $self, $findings ) = @_;
Subroutine _check_agents: not called CC=20 SCAR=42.7
144 0 my $briefing = $self->briefing;
145 0 my $fs = $briefing->filesystem;
146 0 my ( @agents, @pairs );
147  
148 0 for my $entry (@{ $self->_agent_files }) {
149 0 my ( $relative, $path ) = @{$entry};
150 0 my $base = $relative;
151 0 $base =~ s{\A.*/}{};
152 0 $base =~ s/\.md\z//;
153 0 $base =~ s/\A\.local\.(?=.)//;
154  
155 0 ▶ if ($fs->is_dangling_symlink($path)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fs->is_dangling_symlink($path)) 2 143 145
if ($fs->is_dangling_symlink($path)) 0 0 0
156 0 push @{$findings},
157 _finding( 'agent', 'warn', $relative, 'dangling symlink (Claude Code cannot load it)' );
158 0 next;
159 }
160 0 my $agent = _parse_agent( $fs->slurp_utf8($path) );
161 0 ▶ if (!$agent->{frontmatter}) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($agent->{"frontmatter"}) 1 142 143
unless ($agent->{"frontmatter"}) 0 0 0
162 0 push @{$findings},
163 _finding( 'agent', 'warn', $relative, 'no frontmatter (Claude Code does not load it)' );
164 0 next;
165 }
166 0 push @agents, { name => $base, file => $relative };
167  
168 0 my $skills = $briefing->claude_agent_skills($path);
169 0 my @problems;
170 0 ▶ if (!$agent->{has_name} || !length $agent->{name}) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $agent->{'has_name'} && length $agent->{'name'}) { } 1 141 142
elsif ($agent->{'name'} ne $base) { } 4 137 141
if (not $agent->{'has_name'} && length $agent->{'name'}) { } 0 0 0
elsif ($agent->{'name'} ne $base) { } 0 0 0
Condition33%2/6
$agent->{'has_name'} && length $agent->{'name'}
!ll&&!rl&&r
10141
$agent->{'has_name'} && length $agent->{'name'}
!ll&&!rl&&r
000
MC/DC50%1/2
$agent->{'has_name'} && length $agent->{'name'}
$agent->{'has_name'} length $agent->{'name'}
MC/DC0%0/2
$agent->{'has_name'} && length $agent->{'name'}
$agent->{'has_name'} length $agent->{'name'}
Truth table66%2/3
A && B
A= $agent->{'has_name'}B= length $agent->{'name'}
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= $agent->{'has_name'}B= length $agent->{'name'}
ABresult
0X0
100
111
171 0 push @problems, [ 'missing', 'no name' ];
172 }
173 elsif ($agent->{name} ne $base) {
174 push @problems,
175 0 [ 'missing', "name '".$agent->{name}."' differs from the file name" ];
176 }
177 push @problems, [ 'missing', 'description is empty' ]
178 0 ▶ unless $agent->{description};
Branch: 2 branches
BranchTrueFalseTotal
unless $agent->{"description"} 4 138 142
unless $agent->{"description"} 0 0 0
179 push @problems,
180 [ 'missing', 'allowed-tools: ignored by Claude Code; use disallowedTools' ]
181 0 ▶ if $agent->{allowed};
Branch: 2 branches
BranchTrueFalseTotal
if $agent->{"allowed"} 1 141 142
if $agent->{"allowed"} 0 0 0
182 0 ▶ if ($agent->{bad_list}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($agent->{'bad_list'}) { } 1 141 142
elsif (not @{$skills;}) { } 4 137 141
if ($agent->{'bad_list'}) { } 0 0 0
elsif (not @{$skills;}) { } 0 0 0
183 0 push @problems, [
184 'missing',
185 'briefing.skills is not readable (keep the list on one line or use one "- name" per line)',
186 ];
187 }
188 0 elsif (!@{$skills}) {
189 0 push @problems, [ 'warn', 'no briefing' ];
190 }
191 push @problems, [ 'warn', 'skills: briefing reads only briefing.skills' ]
192 0 ▶ if $agent->{top_skills};
Branch: 2 branches
BranchTrueFalseTotal
if $agent->{"top_skills"} 2 140 142
if $agent->{"top_skills"} 0 0 0
193  
194 0 ▶ if (@problems) {
Branch: 2 branches
BranchTrueFalseTotal
if (@problems) { } 16 126 142
if (@problems) { } 0 0 0
195 0 push @{$findings}, _finding( 'agent', $_->[0], $relative, $_->[1] )
196 0 for @problems;
197 }
198 else {
199 0 push @{$findings}, _finding( 'agent', 'ok', $relative, '' );
200 }
201 0 push @pairs, [ $relative, $_ ] for @{$skills};
202 }
203  
204 0 ▶ push @{$findings}, _finding( 'agent', 'missing', '.claude/agents', 'no agent files' )
Branch: 2 branches
BranchTrueFalseTotal
unless @agents 1 66 67
unless @agents 0 0 0
205 unless @agents;
206  
207 0 my %seen;
208 0 for my $pair (@pairs) {
209 0 my $skill = $pair->[1];
210 0 ▶ next if $seen{$skill}++;
Branch: 2 branches
BranchTrueFalseTotal
if $seen{$skill}++ 63 76 139
if $seen{$skill}++ 0 0 0
211 0 my $reason = $briefing->skill_problem($skill);
212 0 ▶ if (!defined $reason) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $reason) 66 10 76
unless (defined $reason) 0 0 0
213 0 push @{$findings}, _finding( 'skill', 'ok', $skill, '' );
214 0 next;
215 }
216 0 for my $other (grep { $_->[1] eq $skill } @pairs) {
217 0 push @{$findings}, _finding(
218 'skill',
219 'missing',
220 $skill,
221 $other->[0].' declares it; '.$reason.'; briefing would refuse the spawn',
222 );
223 }
224 }
225 0 return \@agents;
226 }
227  
228 67 ▶sub _check_hooks {
Subroutine _check_hooks: called CC=16 SCAR=41.4
229 0 ▶ my ( $self, $findings, $agents ) = @_;
Subroutine _check_hooks: not called CC=16 SCAR=41.4
230 0 ▶ return unless @{$agents};
Branch: 2 branches
BranchTrueFalseTotal
unless @{$agents;} 1 66 67
unless @{$agents;} 0 0 0
231 0 my $briefing = $self->briefing;
232 # Same role match as ack-team: NAME-worker or NAME-worker-SUFFIX; else the first agent.
233 0 my ($worker) = grep { $_->{name} =~ /-worker(?:-.+)?\z/s } @{$agents};
234 0 ▶ $worker = $agents->[0] unless $worker;
Branch: 2 branches
BranchTrueFalseTotal
unless $worker 1 65 66
unless $worker 0 0 0
235  
236 0 for my $agent (@{$agents}) {
237 0 my $name = $agent->{name};
238 0 my $guard = $briefing->process_hook(
239 {
240 hook_event_name => 'PreToolUse',
241 session_id => 'briefing-doctor',
242 cwd => $briefing->cwd,
243 tool_name => 'Agent',
244 tool_input => { subagent_type => $name, description => 'check' },
245 },
246 );
247 my $decision = ref $guard->{output} eq 'HASH'
248 ? $guard->{output}{hookSpecificOutput}
249 0 ▶ : undef;
Branch: 2 branches
BranchTrueFalseTotal
ref $guard->{'output'} eq 'HASH' ? : 12 130 142
ref $guard->{'output'} eq 'HASH' ? : 0 0 0
250 0 ▶ if (ref $decision eq 'HASH' && ( $decision->{permissionDecision} // '' ) eq 'deny') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny") 12 130 142
if (ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny") 0 0 0
Condition30%3/10
ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny"
!ll&&!rl&&r
130012
$decision->{"permissionDecision"} // ""
l!l
120
ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny"
!ll&&!rl&&r
000
$decision->{"permissionDecision"} // ""
l!l
00
MC/DC50%1/2
ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny"
ref $decision eq "HASH" $decision->{"permissionDecision"}
MC/DC0%0/2
ref $decision eq "HASH" and ($decision->{"permissionDecision"} // "") eq "deny"
ref $decision eq "HASH" $decision->{"permissionDecision"}
Truth table66%2/3
A and B
A= ref $decision eq "HASH"B= $decision->{"permissionDecision"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $decision eq "HASH"B= $decision->{"permissionDecision"}
ABresult
0X0
100
111
251 0 ▶ push @{$findings}, _finding(
Branch: 2 branches
BranchTrueFalseTotal
length($decision->{'permissionDecisionReason'} // '') ? : 12 0 12
length($decision->{'permissionDecisionReason'} // '') ? : 0 0 0
Condition25%1/4
$decision->{"permissionDecisionReason"} // ""
l!l
120
$decision->{"permissionDecisionReason"} // ""
l!l
00
MC/DC0%0/1
$decision->{"permissionDecisionReason"} // ""
$decision->{"permissionDecisionReason"}
MC/DC0%0/1
$decision->{"permissionDecisionReason"} // ""
$decision->{"permissionDecisionReason"}
Truth table50%1/2
A
A= $decision->{"permissionDecisionReason"}
Aresult
11
00
Truth table0%0/2
A
A= $decision->{"permissionDecisionReason"}
Aresult
11
00
252 'hook', 'missing', $name,
253 length( $decision->{permissionDecisionReason} // '' )
254 ? $decision->{permissionDecisionReason}
255 0 : 'the hook denied the spawn',
256 );
257 0 next;
258 }
259 0 ▶ next unless $agent == $worker;
Branch: 2 branches
BranchTrueFalseTotal
unless $agent == $worker 74 56 130
unless $agent == $worker 0 0 0
260  
261 0 my $start = $briefing->process_hook(
262 {
263 hook_event_name => 'SubagentStart',
264 session_id => 'briefing-doctor',
265 cwd => $briefing->cwd,
266 agent_type => $name,
267 },
268 );
269 my $context = ref $start->{output} eq 'HASH'
270 && ref $start->{output}{hookSpecificOutput} eq 'HASH'
271 ? $start->{output}{hookSpecificOutput}{additionalContext}
272 0 ▶ : undef;
Branch: 2 branches
BranchTrueFalseTotal
ref $start->{'output'} eq 'HASH' && ref $start->{'output'}{'hookSpecificOutput'} eq 'HASH' ? : 52 4 56
ref $start->{'output'} eq 'HASH' && ref $start->{'output'}{'hookSpecificOutput'} eq 'HASH' ? : 0 0 0
Condition33%2/6
ref $start->{"output"} eq "HASH" and ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
!ll&&!rl&&r
4052
ref $start->{"output"} eq "HASH" and ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
!ll&&!rl&&r
000
MC/DC50%1/2
ref $start->{"output"} eq "HASH" and ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
ref $start->{"output"} eq "HASH" ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
MC/DC0%0/2
ref $start->{"output"} eq "HASH" and ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
ref $start->{"output"} eq "HASH" ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
Truth table66%2/3
A and B
A= ref $start->{"output"} eq "HASH"B= ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $start->{"output"} eq "HASH"B= ref $start->{"output"}{"hookSpecificOutput"} eq "HASH"
ABresult
0X0
100
111
273 0 ▶ $context = '' unless defined $context;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $context 4 52 56
unless defined $context 0 0 0
274 0 ▶ if ($context =~ /could not be loaded: (.*?)\.\n/s) {
Branch: 4 branches
BranchTrueFalseTotal
if ($context =~ /could not be loaded: (.*?)\.\n/s) { } 0 56 56
elsif (length $context) { } 52 4 56
if ($context =~ /could not be loaded: (.*?)\.\n/s) { } 0 0 0
elsif (length $context) { } 0 0 0
275 0 push @{$findings}, _finding(
276 'hook', 'missing', $name,
277 'the hook reports skills that could not be loaded: '.$1,
278 );
279 }
280 elsif (length $context) {
281 0 push @{$findings}, _finding( 'hook', 'ok', $name, '' );
282 }
283 else {
284 0 push @{$findings}, _finding( 'hook', 'warn', $name, 'the hook briefs nothing for this agent' );
285 }
286 }
287 0 return;
288 }
289  
290 67 ▶sub _check_settings {
Subroutine _check_settings: called CC=14 SCAR=36.8
291 0 ▶ my ( $self, $findings ) = @_;
Subroutine _check_settings: not called CC=14 SCAR=36.8
292 0 my $fs = $self->briefing->filesystem;
293 0 my $name = '.claude/settings.json';
294 0 my $file = $fs->join_path( $self->briefing->cwd, '.claude', 'settings.json' );
295 0 ▶ if (!$fs->is_readable_file($file)) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($fs->is_readable_file($file)) 2 65 67
unless ($fs->is_readable_file($file)) 0 0 0
296 0 push @{$findings}, _finding( 'settings', 'missing', $name, 'not found or not readable' );
297 0 return;
298 }
299 0 my $settings = eval {
300 0 JSON::MaybeXS->new( utf8 => 0 )->decode( $fs->slurp_utf8($file) );
301 };
302 0 ▶ if (ref $settings ne 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $settings ne "HASH") 2 63 65
if (ref $settings ne "HASH") 0 0 0
303 0 push @{$findings}, _finding(
304 'settings', 'missing', $name,
305 'the settings file is not a valid JSON object. Correct the JSON syntax and run briefing doctor again.',
306 );
307 0 return;
308 }
309  
310 0 ▶ my $enabled = ref $settings->{enabledPlugins} eq 'HASH' ? $settings->{enabledPlugins} : {};
Branch: 2 branches
BranchTrueFalseTotal
ref $settings->{'enabledPlugins'} eq 'HASH' ? : 61 2 63
ref $settings->{'enabledPlugins'} eq 'HASH' ? : 0 0 0
311 my $markets = ref $settings->{extraKnownMarketplaces} eq 'HASH'
312 ? $settings->{extraKnownMarketplaces}
313 0 ▶ : {};
Branch: 2 branches
BranchTrueFalseTotal
ref $settings->{'extraKnownMarketplaces'} eq 'HASH' ? : 61 2 63
ref $settings->{'extraKnownMarketplaces'} eq 'HASH' ? : 0 0 0
314 0 my ( $bad, $briefing ) = ( 0, 0 );
315 0 for my $key (sort keys %{$enabled}) {
316 0 my $value = $enabled->{$key};
317 0 ▶ next unless JSON::MaybeXS::is_bool($value) && $value;
Branch: 2 branches
BranchTrueFalseTotal
unless JSON::MaybeXS::is_bool($value) and $value 8 106 114
unless JSON::MaybeXS::is_bool($value) and $value 0 0 0
Condition50%3/6
JSON::MaybeXS::is_bool($value) and $value
!ll&&!rl&&r
62106
JSON::MaybeXS::is_bool($value) and $value
!ll&&!rl&&r
000
MC/DC100%2/2
JSON::MaybeXS::is_bool($value) and $value
JSON::MaybeXS::is_bool($value) $value
MC/DC0%0/2
JSON::MaybeXS::is_bool($value) and $value
JSON::MaybeXS::is_bool($value) $value
Truth table100%3/3
A and B
A= JSON::MaybeXS::is_bool($value)B= $value
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= JSON::MaybeXS::is_bool($value)B= $value
ABresult
0X0
100
111
318 0 ▶ $briefing = 1 if $key =~ /\Abriefing@/;
Branch: 2 branches
BranchTrueFalseTotal
if $key =~ /\Abriefing@/ 54 52 106
if $key =~ /\Abriefing@/ 0 0 0
319 0 ▶ next unless $key =~ /\@([^@]*)\z/;
Branch: 2 branches
BranchTrueFalseTotal
unless $key =~ /\@([^\@]*)\z/ 0 106 106
unless $key =~ /\@([^\@]*)\z/ 0 0 0
320 0 my $market = $1;
321 0 ▶ next if $market eq 'claude-plugins-official' || exists $markets->{$market};
Branch: 2 branches
BranchTrueFalseTotal
if $market eq "claude-plugins-official" or exists $markets->{$market} 105 1 106
if $market eq "claude-plugins-official" or exists $markets->{$market} 0 0 0
Condition50%3/6
$market eq "claude-plugins-official" or exists $markets->{$market}
l!l&&r!l&&!r
50551
$market eq "claude-plugins-official" or exists $markets->{$market}
l!l&&r!l&&!r
000
MC/DC100%2/2
$market eq "claude-plugins-official" or exists $markets->{$market}
$market eq "claude-plugins-official" exists $markets->{$market}
MC/DC0%0/2
$market eq "claude-plugins-official" or exists $markets->{$market}
$market eq "claude-plugins-official" exists $markets->{$market}
Truth table100%3/3
A or B
A= $market eq "claude-plugins-official"B= exists $markets->{$market}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $market eq "claude-plugins-official"B= exists $markets->{$market}
ABresult
1X1
011
000
322 0 push @{$findings}, _finding(
323 'settings', 'missing', $key,
324 "marketplace '".$market."' is not in extraKnownMarketplaces",
325 );
326 0 $bad = 1;
327 }
328 0 ▶ if (!$briefing) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($briefing) 9 54 63
unless ($briefing) 0 0 0
329 0 push @{$findings}, _finding(
330 'settings', 'missing', 'briefing',
331 'the briefing plugin is not enabled in enabledPlugins',
332 );
333 0 $bad = 1;
334 }
335 0 ▶ push @{$findings}, _finding( 'settings', 'ok', $name, '' ) unless $bad;
Branch: 2 branches
BranchTrueFalseTotal
unless $bad 53 10 63
unless $bad 0 0 0
336 0 return;
337 }
338  
339 67 ▶sub findings {
Subroutine findings: called CC=1 SCAR=1.2
Pod documented
340 0 ▶ my ( $self ) = @_;
Subroutine findings: not called CC=1 SCAR=1.2
Pod documented
341 0 my @findings;
342 0 my $agents = $self->_check_agents( \@findings );
343 0 $self->_check_settings( \@findings );
344 0 $self->_check_hooks( \@findings, $agents );
345 0 return \@findings;
346 }
347  
348  
349  
350 131 1;
351  
352 __END__
↑ Summary lib/App/Briefing/CLI.pm »