blib/lib/Acme/Claude/Shell.pm

filter: Statementstmt 75.0% 24 / 32 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 32 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 33.6% 35 / 104 CC 20 SCAR 43.3
CC
20
Cov
34%
shell
110.0
run
110.0
_detect_color
2.1
CRAP 76.3
« blib/lib/Acme/Claude/Shell/Session.pm ↑ Summary blib/lib/Acme/Claude/Shell/Hooks.pm »
1 package Acme::Claude::Shell;
2  
3 4 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 our @EXPORT_OK = qw(shell run);
9  
10 4 our $VERSION = '0.04';
11  
12 4 ▶use Acme::Claude::Shell::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Acme::Claude::Shell::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use IO::Async::Loop;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub shell {
Subroutine shell: not called CC=10 SCAR=47.0
Pod documented
17 0 my (%args) = @_;
18  
19 0 ▶ my $loop = $args{loop} // IO::Async::Loop->new;
Condition0%0/3
$args{"loop"} // "IO::Async::Loop"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"loop"} // "IO::Async::Loop"->new
$args{"loop"} "IO::Async::Loop"->new
Truth table0%0/3
A // B
A= $args{"loop"}B= "IO::Async::Loop"->new
ABresult
1X1
011
000
20  
21 my $session = Acme::Claude::Shell::Session->new(
22 loop => $loop,
23 dry_run => $args{dry_run} // 0,
24 safe_mode => $args{safe_mode} // 1,
25 working_dir => $args{working_dir} // '.',
26 colorful => $args{colorful} // _detect_color(),
27 ($args{model} ? (model => $args{model}) : ()),
28 ($args{effort} ? (effort => $args{effort}) : ()),
29 verbose => $args{verbose} // 0,
30 0 ▶ audit_log => $args{audit_log} // 0,
Branch: 2 branches
BranchTrueFalseTotal
$args{'model'} ? : 0 0 0
$args{'effort'} ? : 0 0 0
Condition0%0/13
$args{"dry_run"} // 0
l!l
00
$args{"safe_mode"} // 1
l!l
00
$args{"working_dir"} // "."
l!l
00
$args{"colorful"} // _detect_color()
l!l&&r!l&&!r
000
$args{"verbose"} // 0
l!l
00
$args{"audit_log"} // 0
l!l
00
MC/DC0%0/1
$args{"dry_run"} // 0
$args{"dry_run"}
MC/DC0%0/1
$args{"safe_mode"} // 1
$args{"safe_mode"}
MC/DC0%0/1
$args{"working_dir"} // "."
$args{"working_dir"}
MC/DC0%0/2
$args{"colorful"} // _detect_color()
$args{"colorful"} _detect_color()
MC/DC0%0/1
$args{"verbose"} // 0
$args{"verbose"}
MC/DC0%0/1
$args{"audit_log"} // 0
$args{"audit_log"}
Truth table0%0/2
A
A= $args{"dry_run"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"safe_mode"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"working_dir"}
Aresult
11
00
Truth table0%0/3
A // B
A= $args{"colorful"}B= _detect_color()
ABresult
1X1
011
000
Truth table0%0/2
A
A= $args{"verbose"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"audit_log"}
Aresult
11
00
31 );
32  
33 0 return $session->run->get;
34 }
35  
36 0 ▶sub run {
Subroutine run: not called CC=10 SCAR=47.0
Pod documented
37 0 my ($prompt, %args) = @_;
38  
39 0 ▶ my $loop = $args{loop} // IO::Async::Loop->new;
Condition0%0/3
$args{"loop"} // "IO::Async::Loop"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"loop"} // "IO::Async::Loop"->new
$args{"loop"} "IO::Async::Loop"->new
Truth table0%0/3
A // B
A= $args{"loop"}B= "IO::Async::Loop"->new
ABresult
1X1
011
000
40  
41 my $query = Acme::Claude::Shell::Query->new(
42 loop => $loop,
43 dry_run => $args{dry_run} // 0,
44 safe_mode => $args{safe_mode} // 1,
45 working_dir => $args{working_dir} // '.',
46 colorful => $args{colorful} // _detect_color(),
47 ($args{model} ? (model => $args{model}) : ()),
48 ($args{effort} ? (effort => $args{effort}) : ()),
49 verbose => $args{verbose} // 0,
50 0 ▶ audit_log => $args{audit_log} // 0,
Branch: 2 branches
BranchTrueFalseTotal
$args{'model'} ? : 0 0 0
$args{'effort'} ? : 0 0 0
Condition0%0/13
$args{"dry_run"} // 0
l!l
00
$args{"safe_mode"} // 1
l!l
00
$args{"working_dir"} // "."
l!l
00
$args{"colorful"} // _detect_color()
l!l&&r!l&&!r
000
$args{"verbose"} // 0
l!l
00
$args{"audit_log"} // 0
l!l
00
MC/DC0%0/1
$args{"dry_run"} // 0
$args{"dry_run"}
MC/DC0%0/1
$args{"safe_mode"} // 1
$args{"safe_mode"}
MC/DC0%0/1
$args{"working_dir"} // "."
$args{"working_dir"}
MC/DC0%0/2
$args{"colorful"} // _detect_color()
$args{"colorful"} _detect_color()
MC/DC0%0/1
$args{"verbose"} // 0
$args{"verbose"}
MC/DC0%0/1
$args{"audit_log"} // 0
$args{"audit_log"}
Truth table0%0/2
A
A= $args{"dry_run"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"safe_mode"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"working_dir"}
Aresult
11
00
Truth table0%0/3
A // B
A= $args{"colorful"}B= _detect_color()
ABresult
1X1
011
000
Truth table0%0/2
A
A= $args{"verbose"}
Aresult
11
00
Truth table0%0/2
A
A= $args{"audit_log"}
Aresult
11
00
51 );
52  
53 0 return $query->run($prompt)->get;
54 }
55  
56 1 ▶sub _detect_color {
Subroutine _detect_color: called CC=2 SCAR=7.6
57 1 ▶ return -t STDOUT ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-t STDOUT ? : 0 1 1
58 }
59  
60  
61 4 1;
62  
63 __END__
« blib/lib/Acme/Claude/Shell/Session.pm ↑ Summary blib/lib/Acme/Claude/Shell/Hooks.pm »