Agent/DryRun.pm

filter: Statementstmt 13.1% 19 / 145 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 60.0% 6 / 10 Podpod 100% 3 / 3 totaltotal 8.5% 28 / 326 CC 71 SCAR 73.2
CC
71
Cov
7%
is_write_tool
2352.0
format_preview
420.0
__ANON__
20.0
CRAP 1517.4
↑ Summary Agent/Query.pm »
1 package Claude::Agent::DryRun;
2  
3 8 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 our @EXPORT_OK = qw(create_dry_run_hooks is_write_tool format_preview);
9  
10 8 ▶use Claude::Agent::Hook::Matcher;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Claude::Agent::Hook::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub create_dry_run_hooks {
Subroutine create_dry_run_hooks: not called CC=2 SCAR=17.9
Pod documented
14 0 my ($on_dry_run) = @_;
15  
16 0 ▶ unless ($ENV{CLAUDE_AGENT_DRY_RUN_NO_WARN}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"CLAUDE_AGENT_DRY_RUN_NO_WARN"}) 0 0 0
17 0 warn "=" x 72 . "\n";
18 0 warn "[DRY-RUN MODE WARNING]\n";
19 0 warn "Dry-run mode provides PREVIEW FUNCTIONALITY ONLY, not security.\n";
20 0 warn "Bash command detection uses regex heuristics that can be BYPASSED via:\n";
21 0 warn " - Command substitution: \$(echo rm) -rf\n";
22 0 warn " - Variable expansion: \$cmd where cmd=rm\n";
23 0 warn " - Aliases, scripts, or encoded commands\n";
24 0 warn "For security-critical use, use tool whitelisting or sandboxing.\n";
25 0 warn "Set CLAUDE_AGENT_DRY_RUN_NO_WARN=1 to suppress this warning.\n";
26 0 warn "=" x 72 . "\n";
27 }
28  
29 return {
30 PreToolUse => [
31 Claude::Agent::Hook::Matcher->new(
32 0 ▶ hooks => [sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
33 0 my ($input, $tool_use_id, $context) = @_;
34 0 my $tool_name = $input->{tool_name};
35 0 my $tool_input = $input->{tool_input};
36  
37 0 ▶ if (is_write_tool($tool_name, $tool_input)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_write_tool($tool_name, $tool_input)) 0 0 0
38 0 my $preview = format_preview($tool_name, $tool_input);
39  
40 0 ▶ if ($on_dry_run && ref($on_dry_run) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_dry_run and ref $on_dry_run eq 'CODE') { } 0 0 0
Condition0%0/3
$on_dry_run and ref $on_dry_run eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
$on_dry_run and ref $on_dry_run eq "CODE"
$on_dry_run ref $on_dry_run eq "CODE"
Truth table0%0/3
A and B
A= $on_dry_runB= ref $on_dry_run eq "CODE"
ABresult
0X0
100
111
41 0 $on_dry_run->($tool_name, $tool_input, $preview);
42 }
43 else {
44 0 print "[DRY-RUN] $preview\n";
45 }
46  
47 0 return Claude::Agent::Hook::Result->deny(
48 reason => "[DRY-RUN] $preview",
49 );
50 }
51  
52 0 return Claude::Agent::Hook::Result->proceed();
53 0 }],
54 ),
55 ],
56 };
57 }
58  
59 0 ▶sub is_write_tool {
Subroutine is_write_tool: not called CC=48 SCAR=77.6
Pod documented
60 0 my ($tool_name, $tool_input) = @_;
61  
62 0 ▶ return 1 if $tool_name eq 'Write';
Branch: 1 branch
BranchTrueFalseTotal
if $tool_name eq "Write" 0 0 0
63 0 ▶ return 1 if $tool_name eq 'Edit';
Branch: 1 branch
BranchTrueFalseTotal
if $tool_name eq "Edit" 0 0 0
64 0 ▶ return 1 if $tool_name eq 'NotebookEdit';
Branch: 1 branch
BranchTrueFalseTotal
if $tool_name eq "NotebookEdit" 0 0 0
65  
66 0 ▶ if ($tool_name eq 'Bash') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name eq "Bash") 0 0 0
67 0 ▶ my $command = $tool_input->{command} // '';
Condition0%0/2
$tool_input->{"command"} // ""
l!l
00
MC/DC0%0/1
$tool_input->{"command"} // ""
$tool_input->{"command"}
Truth table0%0/2
A
A= $tool_input->{"command"}
Aresult
11
00
68  
69 0 ▶ if (!defined $ENV{CLAUDE_AGENT_DRY_RUN_STRICT} || $ENV{CLAUDE_AGENT_DRY_RUN_STRICT}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"} or $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}) 0 0 0
Condition0%0/3
not defined $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"} or $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"} or $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}
not defined $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"} $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}
Truth table0%0/3
not(A) or B
A= not defined $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}B= $ENV{"CLAUDE_AGENT_DRY_RUN_STRICT"}
ABresult
1X1
011
000
70 my $safe_commands_env = $ENV{CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS}
71 0 ▶ // 'ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv';
Condition0%0/2
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"} // "ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv"
l!l
00
MC/DC0%0/1
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"} // "ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv"
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"}
Truth table0%0/2
A
A= $ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"}
Aresult
11
00
72 0 my @raw_commands = split /,/, $safe_commands_env;
73 0 my @valid_commands = grep { /^[a-zA-Z0-9_-]+$/ } @raw_commands;
74 0 ▶ if (@valid_commands < @raw_commands) {
Branch: 1 branch
BranchTrueFalseTotal
if (@valid_commands < @raw_commands) 0 0 0
75 0 my %valid_set = map { $_ => 1 } @valid_commands;
76 0 my @filtered = grep { !$valid_set{$_} } @raw_commands;
77 warn sprintf("[DRY-RUN CONFIG] Filtered %d invalid entries from CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS: %s\n",
78 0 scalar(@filtered), join(', ', map { "'$_'" } @filtered));
79 }
80 0 my %safe_commands = map { $_ => 1 } @valid_commands;
81  
82 0 my ($first_cmd) = $command =~ /^\s*(\S+)/;
83 0 ▶ $first_cmd //= '';
Condition0%0/2
$first_cmd //= ""
l!l
00
MC/DC0%0/1
$first_cmd //= ""
$first_cmd
Truth table0%0/2
A
A= $first_cmd
Aresult
11
00
84 0 ▶ if ($first_cmd =~ m{^/}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first_cmd =~ m[^/]u) 0 0 0
85 0 ▶ return 1 unless $first_cmd =~ m{^/(usr/)?s?bin/};
Branch: 1 branch
BranchTrueFalseTotal
unless $first_cmd =~ m[^/(usr/)?s?bin/]u 0 0 0
86 }
87 0 $first_cmd =~ s{^.*/}{};
88  
89 0 ▶ return 1 unless $safe_commands{$first_cmd};
Branch: 1 branch
BranchTrueFalseTotal
unless $safe_commands{$first_cmd} 0 0 0
90 0 ▶ return 1 if $command =~ /[>|]/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /[>|]/u 0 0 0
91 0 return 0;
92 }
93  
94 0 state $heuristic_warned = 0;
95 0 ▶ if (!$heuristic_warned++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($heuristic_warned++) 0 0 0
96 0 warn "[DEPRECATION WARNING] Dry-run heuristic mode (CLAUDE_AGENT_DRY_RUN_STRICT=0) is "
97 . "deprecated and provides NO security guarantees. This fallback may be removed in "
98 . "future versions. Use strict mode (default) for any security-sensitive applications.\n";
99 }
100  
101 0 ▶ if (!$ENV{CLAUDE_AGENT_DRY_RUN_QUIET}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"CLAUDE_AGENT_DRY_RUN_QUIET"}) 0 0 0
102 0 state $dry_run_warned = 0;
103 0 ▶ warn "[DRY-RUN WARNING] Bash command detection is bypassable. "
Branch: 1 branch
BranchTrueFalseTotal
unless $dry_run_warned++ 0 0 0
104 . "Set CLAUDE_AGENT_DRY_RUN_STRICT=1 for stricter protection.\n"
105 unless $dry_run_warned++;
106 }
107 0 my @dangerous_cmds = qw(rm rmdir mv cp mkdir touch chmod chown dd truncate install ln patch rsync shred);
108 0 for my $cmd (@dangerous_cmds) {
109 0 ▶ return 1 if $command =~ /^\s*$cmd\b/ || $command =~ /[;|&]\s*$cmd\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /^\s*$cmd\b/u or $command =~ /[;|&]\s*$cmd\b/u 0 0 0
Condition0%0/3
$command =~ /^\s*$cmd\b/u or $command =~ /[;|&]\s*$cmd\b/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$command =~ /^\s*$cmd\b/u or $command =~ /[;|&]\s*$cmd\b/u
$command =~ /^\s*$cmd\b/u $command =~ /[;|&]\s*$cmd\b/u
Truth table0%0/3
A or B
A= $command =~ /^\s*$cmd\b/uB= $command =~ /[;|&]\s*$cmd\b/u
ABresult
1X1
011
000
110 }
111 0 ▶ return 1 if $command =~ /^\s*wget\b/ || $command =~ /[;|&]\s*wget\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /^\s*wget\b/u or $command =~ /[;|&]\s*wget\b/u 0 0 0
Condition0%0/3
$command =~ /^\s*wget\b/u or $command =~ /[;|&]\s*wget\b/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$command =~ /^\s*wget\b/u or $command =~ /[;|&]\s*wget\b/u
$command =~ /^\s*wget\b/u $command =~ /[;|&]\s*wget\b/u
Truth table0%0/3
A or B
A= $command =~ /^\s*wget\b/uB= $command =~ /[;|&]\s*wget\b/u
ABresult
1X1
011
000
112 0 ▶ return 1 if $command =~ /^\s*curl\s+.*-[oO]/ || $command =~ /[;|&]\s*curl\s+.*-[oO]/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /^\s*curl\s+.*-[oO]/u or $command =~ /[;|&]\s*curl\s+.*-[oO]/u 0 0 0
Condition0%0/3
$command =~ /^\s*curl\s+.*-[oO]/u or $command =~ /[;|&]\s*curl\s+.*-[oO]/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$command =~ /^\s*curl\s+.*-[oO]/u or $command =~ /[;|&]\s*curl\s+.*-[oO]/u
$command =~ /^\s*curl\s+.*-[oO]/u $command =~ /[;|&]\s*curl\s+.*-[oO]/u
Truth table0%0/3
A or B
A= $command =~ /^\s*curl\s+.*-[oO]/uB= $command =~ /[;|&]\s*curl\s+.*-[oO]/u
ABresult
1X1
011
000
113 0 ▶ return 1 if $command =~ /<<[<]?/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /<<[<]?/u 0 0 0
114 0 ▶ return 1 if $command =~ /\b(perl|python|ruby|sh|bash)\s+(-[ec]|-.*[ec])/i;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(perl|python|ruby|sh|bash)\s+(-[ec]|-.*[ec])/iu 0 0 0
115 0 ▶ return 1 if $command =~ /\beval\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\beval\b/u 0 0 0
116 0 ▶ return 1 if $command =~ /\b(source|\.)\s+/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(source|\.)\s+/u 0 0 0
117 0 ▶ return 1 if $command =~ /\bxargs\b.*\b(rm|mv|cp)\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\bxargs\b.*\b(rm|mv|cp)\b/u 0 0 0
118 0 ▶ return 1 if $command =~ /\b(git\s+(add|commit|push|reset|checkout|merge|rebase))\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(git\s+(add|commit|push|reset|checkout|merge|rebase))\b/u 0 0 0
119 0 ▶ return 1 if $command =~ /\b(npm\s+(install|uninstall|update|publish))\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(npm\s+(install|uninstall|update|publish))\b/u 0 0 0
120 0 ▶ return 1 if $command =~ /\b(pip\s+(install|uninstall))\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(pip\s+(install|uninstall))\b/u 0 0 0
121 0 ▶ return 1 if $command =~ /\b(cargo\s+(build|install|publish))\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(cargo\s+(build|install|publish))\b/u 0 0 0
122 0 ▶ return 1 if $command =~ /\b(make|cmake)\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\b(make|cmake)\b/u 0 0 0
123 0 ▶ return 1 if $command =~ /[>|]\s*\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /[>|]\s*\S/u 0 0 0
124 0 ▶ return 1 if $command =~ /`[^`]*[>|]/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /`[^`]*[>|]/u 0 0 0
125 0 ▶ return 1 if $command =~ /\$\([^)]*[>|]/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\$\([^)]*[>|]/u 0 0 0
126 0 ▶ return 1 if $command =~ /\btee\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\btee\b/u 0 0 0
127 0 ▶ return 1 if $command =~ /\bsed\s+-i/;
Branch: 1 branch
BranchTrueFalseTotal
if $command =~ /\bsed\s+-i/u 0 0 0
128  
129 0 ▶ return 1 if $tool_input->{dangerouslyDisableSandbox};
Branch: 1 branch
BranchTrueFalseTotal
if $tool_input->{"dangerouslyDisableSandbox"} 0 0 0
130  
131 0 ▶ if (!$ENV{CLAUDE_AGENT_DRY_RUN_QUIET}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"CLAUDE_AGENT_DRY_RUN_QUIET"}) 0 0 0
132 my $safe_commands_env = $ENV{CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS}
133 0 ▶ // 'ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv';
Condition0%0/2
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"} // "ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv"
l!l
00
MC/DC0%0/1
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"} // "ls,cat,head,tail,grep,find,which,pwd,whoami,date,echo,wc,file,stat,type,uname,env,printenv"
$ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"}
Truth table0%0/2
A
A= $ENV{"CLAUDE_AGENT_DRY_RUN_SAFE_COMMANDS"}
Aresult
11
00
134 0 my %safe_commands = map { $_ => 1 } split /,/, $safe_commands_env;
135 0 my ($first_cmd) = $command =~ /^\s*(\S+)/;
136 0 ▶ $first_cmd //= '';
Condition0%0/2
$first_cmd //= ""
l!l
00
MC/DC0%0/1
$first_cmd //= ""
$first_cmd
Truth table0%0/2
A
A= $first_cmd
Aresult
11
00
137 0 $first_cmd =~ s{^.*/}{};
138 0 ▶ if (!$safe_commands{$first_cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($safe_commands{$first_cmd}) 0 0 0
139 0 warn "[DRY-RUN NOTICE] Command '$first_cmd' is not in safe list but allowed by heuristics. "
140 . "In strict mode (default), this would be blocked.\n";
141 }
142 }
143 }
144  
145 0 ▶ if ($tool_name =~ /^mcp__/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name =~ /^mcp__/u) 0 0 0
146 0 ▶ my $write_tools_env = $ENV{CLAUDE_AGENT_MCP_WRITE_TOOLS} // '';
Condition0%0/2
$ENV{"CLAUDE_AGENT_MCP_WRITE_TOOLS"} // ""
l!l
00
MC/DC0%0/1
$ENV{"CLAUDE_AGENT_MCP_WRITE_TOOLS"} // ""
$ENV{"CLAUDE_AGENT_MCP_WRITE_TOOLS"}
Truth table0%0/2
A
A= $ENV{"CLAUDE_AGENT_MCP_WRITE_TOOLS"}
Aresult
11
00
147 0 my %write_mcp_tools = map { $_ => 1 } split /,/, $write_tools_env;
148 0 ▶ return 1 if $write_mcp_tools{$tool_name};
Branch: 1 branch
BranchTrueFalseTotal
if $write_mcp_tools{$tool_name} 0 0 0
149 0 return 0;
150 }
151  
152 0 return 0;
153 }
154  
155 0 ▶sub format_preview {
Subroutine format_preview: not called CC=20 SCAR=60.4
Pod documented
156 0 my ($tool_name, $tool_input) = @_;
157  
158 0 ▶ if ($tool_name eq 'Write') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name eq "Write") 0 0 0
159 0 ▶ my $path = $tool_input->{file_path} // 'unknown';
Condition0%0/2
$tool_input->{"file_path"} // "unknown"
l!l
00
MC/DC0%0/1
$tool_input->{"file_path"} // "unknown"
$tool_input->{"file_path"}
Truth table0%0/2
A
A= $tool_input->{"file_path"}
Aresult
11
00
160 0 ▶ my $content = $tool_input->{content} // '';
Condition0%0/2
$tool_input->{"content"} // ""
l!l
00
MC/DC0%0/1
$tool_input->{"content"} // ""
$tool_input->{"content"}
Truth table0%0/2
A
A= $tool_input->{"content"}
Aresult
11
00
161 0 my $lines = () = $content =~ /\n/g;
162 0 $lines++;
163 0 my $bytes = length($content);
164 0 return "Would write $bytes bytes ($lines lines) to: $path";
165 }
166  
167 0 ▶ if ($tool_name eq 'Edit') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name eq "Edit") 0 0 0
168 0 ▶ my $path = $tool_input->{file_path} // 'unknown';
Condition0%0/2
$tool_input->{"file_path"} // "unknown"
l!l
00
MC/DC0%0/1
$tool_input->{"file_path"} // "unknown"
$tool_input->{"file_path"}
Truth table0%0/2
A
A= $tool_input->{"file_path"}
Aresult
11
00
169 0 ▶ my $old = $tool_input->{old_string} // '';
Condition0%0/2
$tool_input->{"old_string"} // ""
l!l
00
MC/DC0%0/1
$tool_input->{"old_string"} // ""
$tool_input->{"old_string"}
Truth table0%0/2
A
A= $tool_input->{"old_string"}
Aresult
11
00
170 0 ▶ my $new = $tool_input->{new_string} // '';
Condition0%0/2
$tool_input->{"new_string"} // ""
l!l
00
MC/DC0%0/1
$tool_input->{"new_string"} // ""
$tool_input->{"new_string"}
Truth table0%0/2
A
A= $tool_input->{"new_string"}
Aresult
11
00
171 0 ▶ my $old_preview = length($old) > 50 ? substr($old, 0, 47) . '...' : $old;
Branch: 1 branch
BranchTrueFalseTotal
length $old > 50 ? : 0 0 0
172 0 ▶ my $new_preview = length($new) > 50 ? substr($new, 0, 47) . '...' : $new;
Branch: 1 branch
BranchTrueFalseTotal
length $new > 50 ? : 0 0 0
173 0 $old_preview =~ s/\n/\\n/g;
174 0 $new_preview =~ s/\n/\\n/g;
175 0 ▶ my $replace_all = $tool_input->{replace_all} ? ' (all occurrences)' : '';
Branch: 1 branch
BranchTrueFalseTotal
$tool_input->{'replace_all'} ? : 0 0 0
176 0 return "Would edit $path$replace_all: '$old_preview' -> '$new_preview'";
177 }
178  
179 0 ▶ if ($tool_name eq 'Bash') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name eq "Bash") 0 0 0
180 0 ▶ my $cmd = $tool_input->{command} // 'unknown';
Condition0%0/2
$tool_input->{"command"} // "unknown"
l!l
00
MC/DC0%0/1
$tool_input->{"command"} // "unknown"
$tool_input->{"command"}
Truth table0%0/2
A
A= $tool_input->{"command"}
Aresult
11
00
181 0 ▶ my $desc = $tool_input->{description} // '';
Condition0%0/2
$tool_input->{"description"} // ""
l!l
00
MC/DC0%0/1
$tool_input->{"description"} // ""
$tool_input->{"description"}
Truth table0%0/2
A
A= $tool_input->{"description"}
Aresult
11
00
182 0 ▶ my $cmd_preview = length($cmd) > 80 ? substr($cmd, 0, 77) . '...' : $cmd;
Branch: 1 branch
BranchTrueFalseTotal
length $cmd > 80 ? : 0 0 0
183 0 ▶ return $desc ? "Would run: $cmd_preview ($desc)" : "Would run: $cmd_preview";
Branch: 1 branch
BranchTrueFalseTotal
$desc ? : 0 0 0
184 }
185  
186 0 ▶ if ($tool_name eq 'NotebookEdit') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool_name eq "NotebookEdit") 0 0 0
187 0 ▶ my $path = $tool_input->{notebook_path} // 'unknown';
Condition0%0/2
$tool_input->{"notebook_path"} // "unknown"
l!l
00
MC/DC0%0/1
$tool_input->{"notebook_path"} // "unknown"
$tool_input->{"notebook_path"}
Truth table0%0/2
A
A= $tool_input->{"notebook_path"}
Aresult
11
00
188 0 ▶ my $mode = $tool_input->{edit_mode} // 'replace';
Condition0%0/2
$tool_input->{"edit_mode"} // "replace"
l!l
00
MC/DC0%0/1
$tool_input->{"edit_mode"} // "replace"
$tool_input->{"edit_mode"}
Truth table0%0/2
A
A= $tool_input->{"edit_mode"}
Aresult
11
00
189 0 return "Would $mode cell in notebook: $path";
190 }
191  
192 0 my $input_preview = join(', ', map { "$_=$tool_input->{$_}" }
193 0 grep { defined $tool_input->{$_} } sort keys %$tool_input);
194 0 ▶ $input_preview = substr($input_preview, 0, 100) . '...' if length($input_preview) > 100;
Branch: 1 branch
BranchTrueFalseTotal
if length $input_preview > 100 0 0 0
195 0 return "Would execute $tool_name with: $input_preview";
196 }
197  
198  
199 8 1;
200  
201 __END__
↑ Summary Agent/Query.pm »