| 1 | package App::Saisons::Adapter::Claude; | ||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use App::Saisons (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use JSON::PP; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use POSIX qw(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Time::Local qw(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use App::Saisons::Launcher (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | sub new { bless {}, shift } | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub name { 'Claude Code' } | ||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | sub tag { "\x{2736} Cld" } | ||||||||||||||||||||||||||||||
|
Subroutine
tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | sub tag_color { 'bold red' } | ||||||||||||||||||||||||||||||
|
Subroutine
tag_color: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | sub find_sessions { | ||||||||||||||||||||||||||||||
|
Subroutine
find_sessions: called CC=23 SCAR=45.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 14 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 15 | 3 | my $projects_dir = "$ENV{HOME}/.claude/projects"; | |||||||||||||||||||||||||||||||
| 16 | 3 | my %running_names; | |||||||||||||||||||||||||||||||
| 17 | 3 | my $sessions_dir = "$ENV{HOME}/.claude/sessions"; | |||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | if (opendir my $sdh, $sessions_dir) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | while (my $f = readdir $sdh) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | next unless $f =~ /^\d+\.json$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | open my $fh, '<', "$sessions_dir/$f" or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 22 | 0 | my $json = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||
| 23 | 0 | close $fh; | |||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $obj = eval { decode_json($json) } or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | next unless $obj->{sessionId} && $obj->{name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$obj->{"sessionId"} and $obj->{"name"}
MC/DC0%0/2
$obj->{"sessionId"} and $obj->{"name"}
$obj->{"sessionId"}
$obj->{"name"}
Truth table0%0/3
A and B
A= $obj->{"sessionId"}B= $obj->{"name"}
| |||||||||||||||||||||||||||||||||
| 26 | 0 | $running_names{ $obj->{sessionId} } = $obj->{name}; | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | 0 | closedir $sdh; | |||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | 3 | my %by_id; | |||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | opendir my $dh, $projects_dir or return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 32 | 3 | for my $project (sort readdir $dh) { | |||||||||||||||||||||||||||||||
| 33 | 9 | ▶ | next if $project =~ /^\./; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | 3 | my $dir = "$projects_dir/$project"; | |||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | opendir my $pdh, $dir or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | 3 | for my $file (sort readdir $pdh) { | |||||||||||||||||||||||||||||||
| 38 | 18 | ▶ | next unless $file =~ /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 6 | my $id = $1; | |||||||||||||||||||||||||||||||
| 40 | 6 | my ($title, $date, $epoch, $cwd, $first_msg) = _extract_meta("$dir/$file"); | |||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | $cwd //= _derive_path($project); | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$cwd //= _derive_path($project)
MC/DC0%0/2
$cwd //= _derive_path($project)
$cwd
_derive_path($project)
Truth table33%1/3
A //= B
A= $cwdB= _derive_path($project)
| |||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | $title //= $running_names{$id} // $first_msg // '(no title)'; | ||||||||||||||||||||||||||||||
|
Condition14%1/7
$title //= ($running_names{$id} // $first_msg) // "(no title)"
($running_names{$id} // $first_msg) // "(no title)"
$running_names{$id} // $first_msg
MC/DC0%0/1
$title //= ($running_names{$id} // $first_msg) // "(no title)"
$title
Truth table50%1/2
A
A= $title
| |||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | my $size = -s "$dir/$file" // 0; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
-s "$dir/$file" // 0
MC/DC0%0/1
-s "$dir/$file" // 0
-s "$dir/$file"
Truth table50%1/2
A
A= -s "$dir/$file"
| |||||||||||||||||||||||||||||||||
| 44 | 6 | my $session_dir = "$dir/$id"; | |||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | my $candidate = { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | id => $id, | ||||||||||||||||||||||||||||||||
| 47 | project => $project, | ||||||||||||||||||||||||||||||||
| 48 | cwd => $cwd, | ||||||||||||||||||||||||||||||||
| 49 | title => $title, | ||||||||||||||||||||||||||||||||
| 50 | date => $date, | ||||||||||||||||||||||||||||||||
| 51 | epoch => $epoch, | ||||||||||||||||||||||||||||||||
| 52 | _file => "$dir/$file", | ||||||||||||||||||||||||||||||||
| 53 | _dir => (-d $session_dir ? $session_dir : undef), | ||||||||||||||||||||||||||||||||
| 54 | _size => $size, | ||||||||||||||||||||||||||||||||
| 55 | _adapter => $self, | ||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||
| 57 | # Deduplicate: keep the copy with the larger file (more content). | ||||||||||||||||||||||||||||||||
| 58 | # Duplicates arise when Claude writes back to the old project dir | ||||||||||||||||||||||||||||||||
| 59 | # after a move_session. The moved copy has the full conversation; | ||||||||||||||||||||||||||||||||
| 60 | # the leftover is tiny (only metadata records, no cwd). | ||||||||||||||||||||||||||||||||
| 61 | 6 | ▶ | if (!exists $by_id{$id} || $size > $by_id{$id}{_size}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $by_id{$id} or $size > $by_id{$id}{"_size"}
MC/DC0%0/2
not exists $by_id{$id} or $size > $by_id{$id}{"_size"}
not exists $by_id{$id}
$size > $by_id{$id}{"_size"}
Truth table33%1/3
not(A) or B
A= not exists $by_id{$id}B= $size > $by_id{$id}{"_size"}
| |||||||||||||||||||||||||||||||||
| 62 | 6 | $by_id{$id} = $candidate; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||
| 65 | 3 | closedir $pdh; | |||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | 3 | closedir $dh; | |||||||||||||||||||||||||||||||
| 68 | 3 | return values %by_id; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub running { | ||||||||||||||||||||||||||||||
|
Subroutine
running: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 71 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 72 | 0 | my %running; | |||||||||||||||||||||||||||||||
| 73 | 0 | my $sessions_dir = "$ENV{HOME}/.claude/sessions"; | |||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | opendir my $sdh, $sessions_dir or return %running; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | while (my $f = readdir $sdh) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | next unless $f =~ /^\d+\.json$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | open my $fh, '<', "$sessions_dir/$f" or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | 0 | my $json = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||
| 79 | 0 | close $fh; | |||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $obj = eval { decode_json($json) } or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $pid = $obj->{pid} or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $sid = $obj->{sessionId} or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | next unless kill(0, $pid); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | 0 | $running{$sid} = 1; | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | 0 | closedir $sdh; | |||||||||||||||||||||||||||||||
| 87 | 0 | return %running; | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub launch { | ||||||||||||||||||||||||||||||
|
Subroutine
launch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self, $sessions, $launcher) = @_; | |||||||||||||||||||||||||||||||
| 91 | 0 | for my $s (@$sessions) { | |||||||||||||||||||||||||||||||
| 92 | 0 | my $cmd = "cd \Q$s->{cwd}\E && claude --resume \Q$s->{id}\E"; | |||||||||||||||||||||||||||||||
| 93 | 0 | App::Saisons::Launcher::launch_cmd($cmd, $s->{cwd}, $launcher, $s->{title}); | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub delete_session { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 97 | 0 | my ($self, $session) = @_; | |||||||||||||||||||||||||||||||
| 98 | 0 | return unlink $session->{_file}; | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | sub move_session { | ||||||||||||||||||||||||||||||
|
Subroutine
move_session: called CC=8 SCAR=21.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 101 | 1 | my ($self, $session, $new_cwd) = @_; | |||||||||||||||||||||||||||||||
| 102 | 1 | my $projects_dir = "$ENV{HOME}/.claude/projects"; | |||||||||||||||||||||||||||||||
| 103 | 1 | my $old_cwd = $session->{cwd}; | |||||||||||||||||||||||||||||||
| 104 | 1 | my $old_file = $session->{_file}; | |||||||||||||||||||||||||||||||
| 105 | 1 | (my $new_project = $new_cwd) =~ s|/|-|g; | |||||||||||||||||||||||||||||||
| 106 | 1 | $new_project =~ s/^-//; | |||||||||||||||||||||||||||||||
| 107 | 1 | $new_project = "-$new_project"; | |||||||||||||||||||||||||||||||
| 108 | 1 | my $new_dir = "$projects_dir/$new_project"; | |||||||||||||||||||||||||||||||
| 109 | 1 | my $new_file = "$new_dir/$session->{id}.jsonl"; | |||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | unless (-d $new_dir) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | mkdir $new_dir or return (0, "Cannot create $new_dir: $!"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | open my $in, '<', $old_file or return (0, "Cannot read $old_file: $!"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | open my $out, '>', $new_file or return (0, "Cannot write $new_file: $!"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 1 | my $old_quoted = quotemeta($old_cwd); | |||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | while (my $line = <$in>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | 4 | $line =~ s/"cwd":"$old_quoted"/"cwd":"$new_cwd"/g; | |||||||||||||||||||||||||||||||
| 118 | 4 | print $out $line; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | 1 | close $in; | |||||||||||||||||||||||||||||||
| 121 | 1 | close $out; | |||||||||||||||||||||||||||||||
| 122 | 1 | unlink $old_file; | |||||||||||||||||||||||||||||||
| 123 | 1 | my $old_dir = "$projects_dir/$session->{project}"; | |||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | opendir my $dh, $old_dir or return (1, ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 125 | 1 | my @remaining = grep { !/^\./ } readdir $dh; | |||||||||||||||||||||||||||||||
| 126 | 1 | closedir $dh; | |||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | rmdir $old_dir unless @remaining; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 1 | $session->{cwd} = $new_cwd; | |||||||||||||||||||||||||||||||
| 129 | 1 | $session->{project} = $new_project; | |||||||||||||||||||||||||||||||
| 130 | 1 | $session->{_file} = $new_file; | |||||||||||||||||||||||||||||||
| 131 | 1 | return (1, ''); | |||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub load_messages { | ||||||||||||||||||||||||||||||
|
Subroutine
load_messages: called CC=13 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 134 | 1 | my ($self, $session) = @_; | |||||||||||||||||||||||||||||||
| 135 | 1 | my @messages; | |||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | open my $fh, '<', $session->{_file} or return @messages; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | next unless /"role":"(user|assistant)"/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 3 | my $role = $1; | |||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | my $obj = eval { decode_json($_) } or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | my $content = $obj->{message}{content} // next; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->{"message"}{"content"} // (next)
MC/DC0%0/1
$obj->{"message"}{"content"} // (next)
$obj->{"message"}{"content"}
Truth table50%1/2
A
A= $obj->{"message"}{"content"}
| |||||||||||||||||||||||||||||||||
| 142 | 3 | my $text = ''; | |||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | if (!ref $content) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 144 | 0 | $text = $content; | |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||
| 146 | elsif (ref $content eq 'ARRAY') { | ||||||||||||||||||||||||||||||||
| 147 | 3 | for my $block (@$content) { | |||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | next unless ref $block eq 'HASH' && ($block->{type} // '') eq 'text'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
ref $block eq "HASH" and ($block->{"type"} // "") eq "text"
$block->{"type"} // ""
MC/DC0%0/2
ref $block eq "HASH" and ($block->{"type"} // "") eq "text"
ref $block eq "HASH"
$block->{"type"}
Truth table33%1/3
A and B
A= ref $block eq "HASH"B= $block->{"type"}
| |||||||||||||||||||||||||||||||||
| 149 | 3 | $text .= $block->{text}; | |||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | 3 | ▶ | next unless length $text; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 153 | 3 | push @messages, { role => $role, text => $text }; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | 1 | close $fh; | |||||||||||||||||||||||||||||||
| 156 | 1 | return @messages; | |||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||
| 158 | 6 | ▶ | sub _extract_meta { | ||||||||||||||||||||||||||||||
|
Subroutine
_extract_meta: called CC=17 SCAR=29.8
| |||||||||||||||||||||||||||||||||
| 159 | 6 | my ($file) = @_; | |||||||||||||||||||||||||||||||
| 160 | 6 | my ($title, $date, $epoch, $cwd, $first_msg) = (undef, '0000-00-00', 0, undef, undef); | |||||||||||||||||||||||||||||||
| 161 | 6 | print STDERR "\033[2KLoading $file ...\r"; | |||||||||||||||||||||||||||||||
| 162 | 6 | ▶ | open my $fh, '<:utf8', $file or return ($title, $date, $epoch, $cwd); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 21 | ▶ | $title = $1 if !defined $title && /"aiTitle":"([^"]+)"/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $title and /"aiTitle":"([^"]+)"/
MC/DC50%1/2
not defined $title and /"aiTitle":"([^"]+)"/
not defined $title
/"aiTitle":"([^"]+)"/
Truth table66%2/3
not(A) and B
A= not defined $titleB= /"aiTitle":"([^"]+)"/
| |||||||||||||||||||||||||||||||||
| 165 | 21 | ▶ | $cwd = $1 if !$cwd && /"cwd":"([^"]+)"/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $cwd and /"cwd":"([^"]+)"/
MC/DC50%1/2
not $cwd and /"cwd":"([^"]+)"/
not $cwd
/"cwd":"([^"]+)"/
Truth table66%2/3
not(A) and B
A= not $cwdB= /"cwd":"([^"]+)"/
| |||||||||||||||||||||||||||||||||
| 166 | 21 | ▶ | if (!$first_msg && /"role":"user"/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $first_msg and /"role":"user"/
MC/DC50%1/2
not $first_msg and /"role":"user"/
not $first_msg
/"role":"user"/
Truth table66%2/3
not(A) and B
A= not $first_msgB= /"role":"user"/
| |||||||||||||||||||||||||||||||||
| 167 | 6 | ▶ | my $obj = eval { decode_json($_) } or next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 168 | 6 | my $c = $obj->{message}{content}; | |||||||||||||||||||||||||||||||
| 169 | 6 | ▶ | my $txt = ref $c eq 'ARRAY' ? ($c->[0]{text} // '') : ($c // ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
$c->[0]{"text"} // ""
$c // ""
MC/DC0%0/1
$c->[0]{"text"} // ""
$c->[0]{"text"}
MC/DC0%0/1
$c // ""
$c
Truth table50%1/2
A
A= $c->[0]{"text"}
Truth table0%0/2
A
A= $c
| |||||||||||||||||||||||||||||||||
| 170 | 6 | ▶ | next if $txt =~ /^This session is being continued from a previous conversation/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | 6 | ▶ | ($first_msg) = split /\n/, $txt if length $txt; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | 21 | ▶ | if (/"timestamp":"(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | 21 | my $ts = "$1T$2:$3:$4"; | |||||||||||||||||||||||||||||||
| 175 | 21 | ▶ | if ($ts gt $date) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 176 | 15 | $date = $ts; | |||||||||||||||||||||||||||||||
| 177 | 15 | $epoch = Time::Local::timegm($4, $3, $2, | |||||||||||||||||||||||||||||||
| 178 | substr($1,8,2), substr($1,5,2)-1, substr($1,0,4)-1900); | ||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | 6 | close $fh; | |||||||||||||||||||||||||||||||
| 183 | 6 | print STDERR "\033[2K\r"; | |||||||||||||||||||||||||||||||
| 184 | 6 | return ($title, $date, $epoch, $cwd, $first_msg); | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | sub _derive_path { | ||||||||||||||||||||||||||||||
|
Subroutine
_derive_path: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 187 | 3 | my ($project) = @_; | |||||||||||||||||||||||||||||||
| 188 | 3 | return $project; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | 2 | 1; | |||||||||||||||||||||||||||||||