Agent/Hook/Result.pm

filter: Statementstmt 100% 53 / 53 Branchbran 71.4% 10 / 14 Conditioncond 83.3% 10 / 12 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 17 / 17 Podpod 100% 13 / 13 totaltotal 93.0% 107 / 115 CC 15 SCAR 11.3
CC
15
Cov
92%
merge
7.0
_permission
4.0
update_tool_output
2.1
CRAP 3.1
« Agent/Message/Result.pm ↑ Summary Agent/MCP/Server.pm »
1 package Claude::Agent::Hook::Result;
2  
3 9 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub proceed {
Subroutine proceed: called CC=1 SCAR=0.0
Pod documented
8 1 return {};
9 }
10  
11 2 ▶sub allow {
Subroutine allow: called CC=1 SCAR=0.0
Pod documented
12 2 my ($class, %args) = @_;
13 2 return _permission('allow', %args);
14 }
15  
16 4 ▶sub deny {
Subroutine deny: called CC=1 SCAR=0.0
Pod documented
17 4 my ($class, %args) = @_;
18 4 return _permission('deny', %args);
19 }
20  
21 1 ▶sub ask {
Subroutine ask: called CC=1 SCAR=0.0
Pod documented
22 1 my ($class, %args) = @_;
23 1 return _permission('ask', %args);
24 }
25  
26 1 ▶sub defer {
Subroutine defer: called CC=1 SCAR=0.0
Pod documented
27 1 my ($class, %args) = @_;
28 1 return _permission('defer', %args);
29 }
30  
31 8 ▶sub _permission {
Subroutine _permission: called CC=4 SCAR=13.9
32 8 my ($decision, %args) = @_;
33 my %specific = (
34 8 ▶ hookEventName => $args{event} // 'PreToolUse',
Condition100%2/2
$args{"event"} // "PreToolUse"
l!l
17
MC/DC100%1/1
$args{"event"} // "PreToolUse"
$args{"event"}
Truth table100%2/2
A
A= $args{"event"}
Aresult
11
00
35 permissionDecision => $decision,
36 );
37 8 ▶ $specific{permissionDecisionReason} = $args{reason} if defined $args{reason};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"reason"} 7 1 8
38 8 ▶ $specific{updatedInput} = $args{updated_input} if defined $args{updated_input};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"updated_input"} 1 7 8
39 8 return { hookSpecificOutput => \%specific };
40 }
41  
42 1 ▶sub block {
Subroutine block: called CC=2 SCAR=7.0
Pod documented
43 1 my ($class, %args) = @_;
44 1 my $result = { decision => 'block' };
45 1 ▶ $result->{reason} = $args{reason} if defined $args{reason};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"reason"} 1 0 1
46 1 return $result;
47 }
48  
49 1 ▶sub stop {
Subroutine stop: called CC=2 SCAR=7.0
Pod documented
50 1 my ($class, %args) = @_;
51 1 my $result = { continue => \0 };
52 1 ▶ $result->{stopReason} = $args{reason} if defined $args{reason};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"reason"} 1 0 1
53 1 return $result;
54 }
55  
56 4 ▶sub add_context {
Subroutine add_context: called CC=2 SCAR=6.9
Pod documented
57 4 my ($class, $text, %args) = @_;
58 return {
59 hookSpecificOutput => {
60 4 ▶ hookEventName => $args{event} // 'PreToolUse',
Condition100%2/2
$args{"event"} // "PreToolUse"
l!l
22
MC/DC100%1/1
$args{"event"} // "PreToolUse"
$args{"event"}
Truth table100%2/2
A
A= $args{"event"}
Aresult
11
00
61 additionalContext => $text,
62 },
63 };
64 }
65  
66 1 ▶sub update_tool_output {
Subroutine update_tool_output: called CC=2 SCAR=7.2
Pod documented
67 1 my ($class, $output, %args) = @_;
68 return {
69 hookSpecificOutput => {
70 1 ▶ hookEventName => $args{event} // 'PostToolUse',
Condition50%1/2
$args{"event"} // "PostToolUse"
l!l
01
MC/DC0%0/1
$args{"event"} // "PostToolUse"
$args{"event"}
Truth table50%1/2
A
A= $args{"event"}
Aresult
11
00
71 updatedToolOutput => $output,
72 },
73 };
74 }
75  
76 2 ▶sub system_message {
Subroutine system_message: called CC=1 SCAR=0.0
Pod documented
77 2 my ($class, $text) = @_;
78 2 return { systemMessage => $text };
79 }
80  
81 1 ▶sub suppress_output {
Subroutine suppress_output: called CC=1 SCAR=0.0
Pod documented
82 1 return { suppressOutput => \1 };
83 }
84  
85 1 ▶sub async {
Subroutine async: called CC=2 SCAR=7.0
Pod documented
86 1 my ($class, %args) = @_;
87 1 my $result = { async => \1 };
88 1 ▶ $result->{asyncTimeout} = $args{timeout} if defined $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"timeout"} 1 0 1
89 1 return $result;
90 }
91  
92 1 ▶sub merge {
Subroutine merge: called CC=7 SCAR=19.5
Pod documented
93 1 my ($class, @results) = @_;
94 1 my %merged;
95 1 for my $result (@results) {
96 3 ▶ next unless ref $result eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $result eq "HASH" 0 3 3
97 3 for my $key (keys %$result) {
98 3 ▶ if ($key eq 'hookSpecificOutput' && ref $merged{$key} eq 'HASH' && ref $result->{$key} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'hookSpecificOutput' and ref $merged{$key} eq 'HASH' and ref $result->{$key} eq 'HASH') { } 1 2 3
Condition83%5/6
$key eq "hookSpecificOutput" and ref $merged{$key} eq "HASH" and ref $result->{$key} eq "HASH"
!ll&&!rl&&r
201
$key eq "hookSpecificOutput" and ref $merged{$key} eq "HASH"
!ll&&!rl&&r
111
MC/DC66%2/3
$key eq "hookSpecificOutput" and ref $merged{$key} eq "HASH" and ref $result->{$key} eq "HASH"
$key eq "hookSpecificOutput" ref $merged{$key} eq "HASH" ref $result->{$key} eq "HASH"
Truth table75%3/4
A and B and C
A= $key eq "hookSpecificOutput"B= ref $merged{$key} eq "HASH"C= ref $result->{$key} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
99 1 $merged{$key} = { %{$merged{$key}}, %{$result->{$key}} };
100 }
101 else {
102 2 $merged{$key} = $result->{$key};
103 }
104 }
105 }
106 1 return \%merged;
107 }
108  
109 9 1;
110  
111 __END__
« Agent/Message/Result.pm ↑ Summary Agent/MCP/Server.pm »