| 1 | package Langertha::Raider::Application; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Internal application service that builds and runs a raider for a workspace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 75 | our $VERSION = '0.503'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 75 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 75 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 75 | ▶ | use IO::Async::Loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 75 | ▶ | use Future::AsyncAwait; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 75 | ▶ | use Net::Async::MCP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 75 | ▶ | use MCP::Run::Bash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 75 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 75 | ▶ | use Scalar::Util qw( blessed refaddr weaken ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 75 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 75 | ▶ | use Langertha::Raider::HallTools qw( build_hall_tools_server ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 75 | ▶ | use Langertha::Raider::FileTools qw( build_file_tools_server ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 75 | ▶ | use Langertha::Raider::WebTools qw( build_web_tools_server ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 75 | ▶ | use Langertha::Raider::PerlTools qw( build_perl_tools_server ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 75 | ▶ | use Langertha::Raider::Packs qw( build_packs ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 75 | ▶ | use Langertha::Raider::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 75 | ▶ | use Langertha::Raider::Instructions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 75 | ▶ | use Langertha::Raider::Detect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 75 | ▶ | use Langertha::Raider::EngineResolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 75 | ▶ | use Langertha::Raider::ToolEffects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 75 | ▶ | use Langertha::Raider::SessionStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 75 | ▶ | use Langertha::Raider; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 75 | has engine_name => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | builder => '_build_engine_name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | init_arg => 'engine', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 15 | ▶ | sub _build_engine_name { $_[0]->engine_resolver->engine_name } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_engine_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 75 | has engine_resolver => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | isa => 'Langertha::Raider::EngineResolver', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | builder => '_build_engine_resolver', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 306 | ▶ | sub engine_resolver_class { 'Langertha::Raider::EngineResolver' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
engine_resolver_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # The resolver gets what was passed to the constructor (-e, -m, -k), so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # its answers and those of the attributes here are the same. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 306 | ▶ | sub _build_engine_resolver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_engine_resolver: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 306 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 306 | my $explicit = $self->_explicit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | return $self->engine_resolver_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | config => $self->config, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | engine_options => $self->engine_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ( $explicit->{engine} ? ( engine => $self->engine_name ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ( $explicit->{model} ? ( model => $self->model ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 306 | ▶ | ( $explicit->{api_key} ? ( api_key => $self->api_key ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ( $self->has_provider ? ( provider => $self->provider ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 75 | has provider => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | predicate => 'has_provider', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 75 | has model => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | predicate => 'has_explicit_model', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | builder => '_build_model', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 96 | ▶ | sub _build_model { $_[0]->engine_resolver->model } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_model: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 255 | ▶ | sub has_model { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_model: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 255 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 255 | ▶ | return 1 if $self->has_explicit_model; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 92 | ▶ | return length($self->model) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 110 | ▶ | sub api_key_env { $_[0]->engine_resolver->api_key_env } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_key_env: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 75 | has api_key => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | builder => '_build_api_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 75 | has mission => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | builder => '_build_mission', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 75 | has _explicit_mission => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | init_arg => 'mission', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | predicate => '_has_explicit_mission', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 75 | has bare => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 202 | ▶ | sub _build_mission { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_mission: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 202 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 202 | my @items = ( $self->_instructions_text, $self->_tools_text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 202 | my @skills = $self->_load_skill_texts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 202 | ▶ | push @items, "Loaded skills (domain knowledge the user enabled for this session):\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | .join("\n\n", @skills)."\n" if @skills; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 202 | my @pack_texts = $self->packs->skill_texts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 202 | ▶ | push @items, "Active packs:\n\n".join("\n\n", @pack_texts)."\n" if @pack_texts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 202 | return join "\n\n---\n", @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # The instructions item: the -M text, or the default persona with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # project instructions file (.raider/instructions.md, else .raider.md). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 202 | ▶ | sub _instructions_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_instructions_text: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 202 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 202 | ▶ | return $self->_explicit_mission if $self->_has_explicit_mission; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 155 | my $base = $self->_persona_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 155 | ▶ | return $base if $self->bare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 148 | my $instructions = $self->instructions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 148 | my $custom = $instructions->text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 148 | ▶ | $base .= "\n\n---\nUser's custom instructions (from ".$instructions->file."):\n\n$custom\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | if defined $custom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 148 | return $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # The tool description item, derived from the tool servers mounted for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # this raider (ADR 0005) -- the same servers the catalogue comes from; -M | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # never replaces it (ADR 0014). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 202 | ▶ | sub _tools_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tools_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 202 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 202 | my @tools = $self->_mounted_tools; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | return 'Working directory: '.$self->root."\n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ."Tools (MCP):\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 202 | .join('', map { ' - '.$self->_tool_signature($_)."\n" } @tools); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # The MCP::Tool objects of the mounted tool servers, in mount order -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # what the prompt describes, the engine offers and Langertha::Raider::Skill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # documents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 240 | ▶ | sub _mounted_tools { map { @{ $_->tools } } @{ $_[0]->_tool_servers } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mounted_tools: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # name(required, ..., [optional], ...) from the tool's input schema: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # required parameters in their schema order, then the optional ones sorted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1690 | ▶ | sub _tool_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tool_signature: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1690 | my ($self, $tool) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1690 | ▶ | my $schema = $tool->input_schema // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tool->input_schema // {}
MC/DC0%0/1
$tool->input_schema // {}
$tool->input_schema
Truth table50%1/2
A
A= $tool->input_schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1690 | ▶ | my @required = @{ $schema->{required} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$schema{"required"} // []
MC/DC100%1/1
$$schema{"required"} // []
$$schema{"required"}
Truth table100%2/2
A
A= $$schema{"required"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1690 | my %required = map { $_ => 1 } @required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1690 | ▶ | my @optional = sort grep { !$required{$_} } keys %{ $schema->{properties} // {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$schema{"properties"} // {}
MC/DC0%0/1
$$schema{"properties"} // {}
$$schema{"properties"}
Truth table50%1/2
A
A= $$schema{"properties"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1690 | return $tool->name.'('.join(', ', @required, map { '['.$_.']' } @optional).')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # The default persona: what the agent is (persona_intro), how it works, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # and how a turn ends (persona_turn_end). The first and the last part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # depend on the surface the agent is reached through. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 155 | ▶ | sub _persona_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_persona_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 155 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 155 | return $self->persona_intro."\n".$self->_persona_body.$self->persona_turn_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 16 | ▶ | sub persona_intro { <<'EOM' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
persona_intro: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | You are Langertha, viking shield-maiden. Autonomous agent on user's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | machine. No pause, no abort, no ask to stop. You do things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | EOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 16 | ▶ | sub persona_turn_end { <<'EOM' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
persona_turn_end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | You have no yield / ask / abort tool. Task done: plain text reply. User | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | answers in the next turn. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | EOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Points at the instructions file in use (.raider.md in a legacy project). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 155 | ▶ | sub _persona_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_persona_body: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 155 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 155 | my $label = $self->instructions->label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 155 | return <<"EOM"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | Name, persona, tone are defaults. User can rename you, rewrite your | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | background, or change persona entirely via C<$label> in working dir. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | If present, its content appended below as user's custom instructions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | User's custom instructions override this default where they conflict. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | How you work: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | - User turn = task. Pursue with tools until done. Unlimited iterations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | - Read before write. No guessing file contents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | - After write_file / edit_file: verify. Re-read, or run check (perl -c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | tests, etc.). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | - Small targeted edits > full rewrites. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | - bash is full shell, not sandbox. Use freely. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | - Skip irreversible ops (rm -rf, git reset --hard, force pushes) unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | user explicit ask. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | EOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | has root => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | default => sub { Path::Tiny->cwd->stringify }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 75 | has allowed_commands => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | predicate => 'has_allowed_commands', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 75 | has max_iterations => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | default => 10_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 75 | has on_event => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | predicate => 'has_on_event', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 75 | has on_journal_error => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | isa => 'CodeRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | predicate => 'has_on_journal_error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 75 | has perl => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 336 | ▶ | sub perl_tools_enabled { $_[0]->perl_tools_grant->{enabled} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_tools_enabled: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 432 | ▶ | sub perl_tools_grant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perl_tools_grant: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 432 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 432 | ▶ | return { enabled => 1, reason => $self->source_label('perl') } if $self->perl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 402 | my $yml = $self->_load_yml_options->{perl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 402 | ▶ | if (defined $yml) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 21 | ▶ | my $where = exists $self->_cli_app_options->{perl} ? $self->source_label('engine_options') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | : $self->config->value_label($self->engine_name, 'perl'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 21 | ▶ | return { enabled => $yml ? 1 : 0, reason => 'perl: '.( $yml ? 'true' : 'false' ).' ('.$where.')' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 381 | my $packs = $self->packs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 53 | my @by = map { 'pack '.$_.' ('.$packs->sources->{$_}{source}.')' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 421 | grep { grep { $_ eq 'perl' } @{ $packs->packs_by_name->{$_}->tools } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 381 | @{ $packs->enabled_pack_names }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 381 | ▶ | return @by ? { enabled => 1, reason => join(', ', @by) } : { enabled => 0, reason => 'not requested' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 75 | has preferred_lib_target => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | predicate => 'has_preferred_lib_target', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 75 | has pack_names => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | predicate => 'has_pack_names', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | has no_pack_names => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 415 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 75 | has detect => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | predicate => 'has_detect_flag', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 75 | has packs => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | isa => 'Langertha::Raider::Packs::Collection', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | builder => '_build_packs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 686 | ▶ | sub detect_class { 'Langertha::Raider::Detect' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detect_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 357 | ▶ | sub _build_packs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_packs: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 357 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # --bare: only --pack counts, not packs:, defaults or detection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 357 | ▶ | my ( $list, $source, $reason ) = !$self->bare ? $self->_explicit_packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | : $self->has_pack_names ? ( $self->pack_names, flag => $self->source_label('pack_names') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | : ( [] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 356 | my $collection = build_packs(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 356 | ▶ | if ($list && ref $list eq 'ARRAY' && ( @$list || $self->bare )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$list and ref $list eq "ARRAY" and @$list || $self->bare
$list and ref $list eq "ARRAY"
@$list or $self->bare
MC/DC25%1/4
$list and ref $list eq "ARRAY" and @$list || $self->bare
$list
ref $list eq "ARRAY"
@$list
$self->bare
Truth table60%3/5
A and B and C or D
A= $listB= ref $list eq "ARRAY"C= @$listD= $self->bare
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # Explicit packs — enable exactly those | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 47 | for my $name (@{$collection->all_pack_names}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 354 | $collection->disable($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 47 | for my $name (@$list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 39 | $collection->enable($name, $source, $reason); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 356 | $collection->disable($_, flag => $self->source_label('no_pack_names')) for @{$self->no_pack_names}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 356 | $self->_detect_packs($collection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 353 | return $collection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # The explicit pack list with its source: --pack, then -o packs=, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # packs: in .raider.yml. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 342 | ▶ | sub _explicit_packs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_explicit_packs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 342 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 342 | ▶ | return ( $self->pack_names, flag => $self->source_label('pack_names') ) if $self->has_pack_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 330 | my $opt = $self->_cli_app_options->{packs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 330 | ▶ | return ( $opt, flag => $self->source_label('engine_options packs') ) if defined $opt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 326 | my $engine = $self->engine_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 326 | return ( $self->config->options($engine)->{packs}, config => $self->config->value_label($engine, 'packs').' packs:' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 460 | ▶ | sub detection_state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detection_state: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 460 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 460 | ▶ | return ( 0, $self->source_label('bare') ) if $self->bare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 438 | ▶ | return ( $self->detect ? ( 1, $self->source_label('detect') ) : ( 0, $self->source_label('no_detect') ) ) if $self->has_detect_flag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 411 | ▶ | return ( 0, 'detect: false' ) unless $self->_detect_settings->{enabled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 399 | return ( 1, 'default' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # detect: and no_detect: from .raider.yml, -o on top. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 735 | ▶ | sub _detect_settings { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detect_settings: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 735 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 735 | my $yml = $self->_load_yml_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 735 | return $self->config->normalize_detect($yml->{detect}, $yml->{no_detect}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 365 | ▶ | sub _detect_packs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detect_packs: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 365 | my ($self, $collection) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 365 | my %detections; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 365 | $collection->detections(\%detections); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 365 | my ( $enabled ) = $self->detection_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 363 | ▶ | return unless $enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 324 | my $settings = $self->_detect_settings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 324 | my %rules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 324 | for my $name (@{$collection->all_pack_names}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2330 | my $pack = $collection->packs_by_name->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2330 | ▶ | next unless $pack->has_detect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 362 | $rules{$name} = [ 'pack default', $pack->detect, $pack->path.'/pack.yml detect' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | $rules{$_} = [ $self->config->detect_rule_label($self->engine_name, $_), $settings->{rules}{$_}, 'detect.'.$_ ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 324 | for keys %{$settings->{rules}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 324 | my %no_pack = map { $_ => 1 } @{$self->no_pack_names}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 324 | my $detect = $self->detect_class->new(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 324 | for my $name (sort keys %rules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 362 | my ( $from, $rule, $label ) = @{$rules{$name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 362 | $self->detect_class->validate_rule($rule, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 361 | ▶ | my $record = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 361 | my ( $result, $reason, $notes ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 361 | ▶ | $detections{$name} = { rule_from => $from, result => $result, reason => $reason, notes => $notes // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$notes // []
MC/DC100%1/1
$notes // []
$notes
Truth table100%2/2
A
A= $notes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 361 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | my $skip = !$collection->packs_by_name->{$name} ? 'unknown pack' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | : $no_pack{$name} ? $self->source_label('no_pack_names') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 361 | ▶ | : $settings->{off}{$name} ? $settings->{off}{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | : $collection->is_active($name) ? 'already active' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 361 | ▶ | if ($skip) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 14 | $record->(skipped => $skip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 14 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 347 | my $result = $detect->evaluate($rule, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 347 | ▶ | unless ($result->{matched}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 307 | $record->('not matched', $result->{reason}, $result->{notes}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 307 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 40 | ▶ | if (my $holder = $collection->enable_detected($name, $result->{reason})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | my $kind = $collection->sources->{$holder}{source} eq 'detected' ? 'detected' : 'explicit'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | $record->(skipped => $kind.' '.$holder.' holds exclusive group '.$collection->packs_by_name->{$name}->exclusive_group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 37 | $record->(matched => $result->{reason}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 323 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 9 | ▶ | sub redetect_packs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
redetect_packs: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | my $collection = $self->packs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 9 | for my $name (@{ [ @{$collection->active_pack_names} ] }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 11 | ▶ | $collection->disable($name) if ($collection->sources->{$name}{source} // '') eq 'detected'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$collection->sources->{$name}{"source"} // ""
MC/DC0%0/1
$collection->sources->{$name}{"source"} // ""
$collection->sources->{$name}{"source"}
Truth table50%1/2
A
A= $collection->sources->{$name}{"source"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 9 | $self->_detect_packs($collection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 9 | ▶ | return grep { ($collection->sources->{$_}{source} // '') eq 'detected' } @{$collection->active_pack_names}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$collection->sources->{$_}{"source"} // ""
MC/DC0%0/1
$collection->sources->{$_}{"source"} // ""
$collection->sources->{$_}{"source"}
Truth table50%1/2
A
A= $collection->sources->{$_}{"source"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 75 | has max_context_tokens => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | default => 40_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 75 | has context_compress_threshold => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | default => 0.7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 75 | has skill_sources => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | isa => 'ArrayRef[HashRef]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | builder => '_build_skill_sources', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 75 | has cli_skill_sources => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | isa => 'ArrayRef[HashRef]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | predicate => 'has_cli_skill_sources', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 75 | has config => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | isa => 'Langertha::Raider::Config', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 259 | ▶ | sub _build_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_config: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 259 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 259 | return Langertha::Raider::Config->new(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 75 | has instructions => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | isa => 'Langertha::Raider::Instructions', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 300 | ▶ | sub instructions_class { 'Langertha::Raider::Instructions' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instructions_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 300 | ▶ | sub _build_instructions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_instructions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 300 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 300 | return $self->instructions_class->new(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # Which settings were passed to the constructor (the command-line flags), for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # explain_config. Lazy attributes cannot tell that apart once built. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | has _explicit => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 422 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 422 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 422 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 422 | $self->_explicit->{$_} = 1 for grep { exists $args->{$_} } qw( engine model api_key perl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 213 | ▶ | sub _build_skill_sources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_skill_sources: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 213 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 213 | ▶ | return [] if $self->bare; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | return [ $self->config->skill_specs( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | $self->engine_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 205 | ▶ | @{ $self->_cli_app_options->{skills} // [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_cli_app_options->{"skills"} // []
MC/DC100%1/1
$self->_cli_app_options->{"skills"} // []
$self->_cli_app_options->{"skills"}
Truth table100%2/2
A
A= $self->_cli_app_options->{"skills"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 205 | $self->has_cli_skill_sources ? @{$self->cli_skill_sources} : (), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 202 | ▶ | sub _load_skill_texts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_skill_texts: called CC=21 SCAR=36.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 202 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 202 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 202 | for my $spec (@{$self->skill_sources}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 16 | ▶ | my $type = $spec->{type} // 'dir'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$spec{"type"} // "dir"
MC/DC0%0/1
$$spec{"type"} // "dir"
$$spec{"type"}
Truth table50%1/2
A
A= $$spec{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 16 | my $rel = $spec->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 16 | ▶ | next unless defined $rel && length $rel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rel and length $rel
MC/DC0%0/2
defined $rel and length $rel
defined $rel
length $rel
Truth table33%1/3
A and B
A= defined $relB= length $rel
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 16 | my $base = Path::Tiny::path($rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 16 | ▶ | $base = Path::Tiny::path($self->root)->child($rel) unless $base->is_absolute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 16 | ▶ | next unless $type eq 'file' || -d $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type eq "file" or -d $base
MC/DC100%2/2
$type eq "file" or -d $base
$type eq "file"
-d $base
Truth table100%3/3
A or B
A= $type eq "file"B= -d $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 12 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 12 | ▶ | if ($type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # Single markdown file — $base is that file, not a directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | my $f = Path::Tiny::path($rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 4 | ▶ | $f = Path::Tiny::path($self->root)->child($rel) unless $f->is_absolute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 4 | ▶ | next unless -f $f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | @files = ($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | elsif ($type eq 'claude') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # Claude layout: $base/<skill>/SKILL.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | for my $dir ($base->children) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my $f = $dir->child('SKILL.md'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | push @files, $f if -f $f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 8 | ▶ | my $glob = $spec->{glob} // '*.md'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$spec{"glob"} // "*.md"
MC/DC0%0/1
$$spec{"glob"} // "*.md"
$$spec{"glob"}
Truth table50%1/2
A
A= $$spec{"glob"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 8 | push @files, $base->children(qr/\Q$glob\E$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # Fallback: recurse if nothing matched at the top level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 8 | ▶ | if (!@files) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 8 | ▶ | @files = grep { -f $_ && /\.md$/ } $base->children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
-f $_ && /\.md$/
MC/DC0%0/2
-f $_ && /\.md$/
-f $_
/\.md$/
Truth table33%1/3
A && B
A= -f $_B= /\.md$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 8 | for my $f (sort @files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 8 | ▶ | my $name = $type eq 'claude' ? $f->parent->basename : $f->basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 8 | ▶ | my $body = eval { $f->slurp_utf8 } // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
eval { // (next)
MC/DC0%0/1
eval {
do {
$f->slurp_utf8
}
} // (next)
eval {
do {
$f->slurp_utf8
}
}
Truth table50%1/2
A
A= eval {
do {
$f->slurp_utf8
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # Strip YAML frontmatter if present. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 8 | $body =~ s/\A---\s*\n.*?\n---\s*\n//s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 8 | push @out, "### Skill: $name\n\n$body"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 202 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | has engine_options => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 386 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # The -o pairs that configure raider itself, the list keys split on commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # as they would read from .raider.yml. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1837 | ▶ | sub _cli_app_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cli_app_options: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1837 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1837 | my $opts = $self->engine_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1837 | my %app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1837 | for my $key (grep { $self->config->is_app_key($_) } keys %$opts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 118 | my $value = $opts->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 118 | ▶ | $value = [ split /,/, $value ] if ($key eq 'packs' || $key eq 'skills') && !ref $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$key eq "packs" || $key eq "skills" and not ref $value
$key eq "packs" or $key eq "skills"
MC/DC66%2/3
$key eq "packs" || $key eq "skills" and not ref $value
$key eq "packs"
$key eq "skills"
not ref $value
Truth table60%3/5
A or B and not(C)
A= $key eq "packs"B= $key eq "skills"C= not ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 118 | $app{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1837 | return \%app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 88 | ▶ | sub _cli_engine_options { $_[0]->engine_resolver->cli_engine_options } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cli_engine_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1193 | ▶ | sub _load_yml_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_yml_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1193 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1193 | my %app = %{ $self->_cli_app_options }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1193 | delete $app{skills}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1193 | return { %{ $self->config->options($self->engine_name) }, %app }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 9 | ▶ | sub _engine_yml_options { $_[0]->engine_resolver->engine_yml_options } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_engine_yml_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | has loop => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | isa => 'IO::Async::Loop', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 296 | ▶ | default => sub { IO::Async::Loop->new }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 75 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 75 | has _engine => (is => 'ro', lazy => 1, builder => '_build_engine'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 75 | has _raider => (is => 'ro', lazy => 1, builder => '_build_raider', predicate => '_has_raider'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 75 | has _mcps => (is => 'ro', lazy => 1, builder => '_build_mcps', predicate => '_has_mcps'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # The active tool set (ADR 0005): the MCP servers mounted for this raider. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # The engine's clients (_mcps) and the prompt's tool description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # (_tools_text) both come from it. _remount_tool_servers brings it in line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | # again when the Perl tools grant changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 75 | has _tool_servers => (is => 'ro', lazy => 1, builder => '_build_tool_servers', predicate => '_has_tool_servers'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # The servers the set is assembled from, each built once, so a remount | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # keeps the servers (and their clients) that stay mounted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 75 | has _stock_tool_servers => (is => 'ro', lazy => 1, builder => '_build_stock_tool_servers'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 75 | has _perl_tool_server => (is => 'ro', lazy => 1, builder => '_build_perl_tool_server'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 75 | has _hall_tool_server => (is => 'ro', lazy => 1, builder => '_build_hall_tool_server'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | ▶ | sub _build_api_key { $_[0]->engine_resolver->api_key } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_api_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 129 | ▶ | sub _engine_class { $_[0]->engine_resolver->engine_class } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_engine_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 119 | ▶ | sub _build_mcps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_mcps: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 119 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 119 | return [ map { $self->_mcp_client($_) } @{ $self->_tool_servers } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 380 | ▶ | sub _mcp_client { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mcp_client: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 380 | my ($self, $server) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 380 | my $client = Net::Async::MCP->new(server => $server); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 380 | $self->loop->add($client); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 380 | return $client; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 321 | ▶ | sub _build_tool_servers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_tool_servers: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 321 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 321 | ▶ | @{ $self->_stock_tool_servers }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_hall_tool_server // ()
MC/DC0%0/2
$self->_hall_tool_server // ()
$self->_hall_tool_server
()
Truth table66%2/3
A // B
A= $self->_hall_tool_serverB= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | ( $self->perl_tools_enabled ? $self->_perl_tool_server : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | ( $self->_hall_tool_server // () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 296 | ▶ | sub _build_stock_tool_servers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_stock_tool_servers: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 296 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 296 | my $files = build_file_tools_server(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 296 | ▶ | my $bash = MCP::Run::Bash->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | tool_name => 'bash', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | tool_description => 'Run a shell command with bash -c. Returns exit code, stdout, and stderr. Use this for ls, grep, find, git, cat, running tests, any shell pipeline — anything you would type at a terminal.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | working_directory => $self->root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ($self->has_allowed_commands ? (allowed_commands => $self->allowed_commands) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | timeout => 120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 296 | my $web = build_web_tools_server(loop => $self->loop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 296 | return [ $files, $bash, $web ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 53 | ▶ | sub _build_perl_tool_server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_perl_tool_server: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 53 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | my $lib_target = $self->has_preferred_lib_target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | ? $self->preferred_lib_target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 53 | ▶ | : ($self->_load_yml_options->{preferred_lib_target} // undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_load_yml_options->{"preferred_lib_target"} // undef
MC/DC100%1/1
$self->_load_yml_options->{"preferred_lib_target"} // undef
$self->_load_yml_options->{"preferred_lib_target"}
Truth table100%2/2
A
A= $self->_load_yml_options->{"preferred_lib_target"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 53 | return build_perl_tools_server( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | root => $self->root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | loop => $self->loop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | lib_target => $lib_target, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # Hall-side tools: when we were spawned by raider-hall, expose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # telegram_reply / hall_status / hall_spawn so the agent can talk back. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 296 | ▶ | sub _build_hall_tool_server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_hall_tool_server: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 296 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 296 | ▶ | return unless $ENV{RAIDER_HALL_SOCKET} && -S $ENV{RAIDER_HALL_SOCKET}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ENV{"RAIDER_HALL_SOCKET"} and -S $ENV{"RAIDER_HALL_SOCKET"}
MC/DC50%1/2
$ENV{"RAIDER_HALL_SOCKET"} and -S $ENV{"RAIDER_HALL_SOCKET"}
$ENV{"RAIDER_HALL_SOCKET"}
-S $ENV{"RAIDER_HALL_SOCKET"}
Truth table66%2/3
A and B
A= $ENV{"RAIDER_HALL_SOCKET"}B= -S $ENV{"RAIDER_HALL_SOCKET"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 1 | return build_hall_tools_server(socket => $ENV{RAIDER_HALL_SOCKET}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # Remounts the tool set after the Perl tools grant changed (/pack, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # /reload): assembles it again, keeps the servers and clients that stay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # adds clients for new servers and drops the clients of unmounted ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # Both arrays change in place -- the engine holds this very _mcps array as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # its mcp_servers, so the raider's next tool gather sees the new set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # Returns true when the set changed. Before the set is built there is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # nothing to remount; the lazy build reads the current grant. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 27 | ▶ | sub _remount_tool_servers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remount_tool_servers: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 27 | ▶ | return 0 unless $self->_has_tool_servers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 25 | my $servers = $self->_tool_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 25 | my $want = $self->_build_tool_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 25 | ▶ | return 0 if join(',', map { refaddr $_ } @$servers) eq join(',', map { refaddr $_ } @$want); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 6 | ▶ | if ($self->_has_mcps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 6 | my $mcps = $self->_mcps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 6 | my %client = map { refaddr($servers->[$_]) => $mcps->[$_] } 0..$#$servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 6 | ▶ | my @clients = map { delete $client{refaddr $_} // $self->_mcp_client($_) } @$want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $client{builtin::refaddr($_)} // $self->_mcp_client($_)
MC/DC0%0/2
delete $client{builtin::refaddr($_)} // $self->_mcp_client($_)
delete $client{builtin::refaddr($_)}
$self->_mcp_client($_)
Truth table66%2/3
A // B
A= delete $client{builtin::refaddr($_)}B= $self->_mcp_client($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 6 | $self->loop->remove($_) for values %client; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 6 | @$mcps = @clients; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 6 | @$servers = @$want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 97 | ▶ | sub _build_engine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_engine: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 97 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 97 | return $self->engine_resolver->build_engine(mcp_servers => $self->_mcps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # Engine constructor arguments (Langertha::Raider::EngineResolver/engine_args). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | ▶ | sub _engine_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_engine_args: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 1 | return $self->engine_resolver->engine_args(mcp_servers => $self->_mcps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # The plugins of the raider, as name + {args} pairs for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # Langertha::Raider/plugins; a surface adds its own in front. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 140 | ▶ | sub _raider_plugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_raider_plugins: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 140 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 140 | weaken(my $app = $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # Events last, so it reports the tool calls that actually run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | return ( '+Langertha::Raider::Plugin::Situation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 140 | ▶ | '+Langertha::Raider::Plugin::Events', { on_event => sub { $app->event(@_) if $app } } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 140 | ▶ | sub _build_raider { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_raider: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 140 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 140 | my @plugins = $self->_raider_plugins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 140 | ▶ | return Langertha::Raider->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | engine => $self->_engine, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | mission => $self->mission, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | max_iterations => $self->max_iterations, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | max_context_tokens => $self->max_context_tokens, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | context_compress_threshold => $self->context_compress_threshold, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | (@plugins ? (plugins => \@plugins) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 70 | ▶ | async sub raid_f { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raid_f: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 70 | my ($self, @messages) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 70 | for my $mcp (@{$self->_mcps}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 49 | await $mcp->initialize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 70 | my $raider = $self->_raider; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # A cancel_run that came before the raider was there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 70 | ▶ | $raider->cancel if $self->_run && $self->_run->{cancelled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_run and $self->_run->{"cancelled"}
MC/DC50%1/2
$self->_run and $self->_run->{"cancelled"}
$self->_run
$self->_run->{"cancelled"}
Truth table66%2/3
A and B
A= $self->_runB= $self->_run->{"cancelled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 70 | return await $raider->raid_f(@messages); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 75 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 70 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 70 | my ($self, @messages) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 70 | my $f = $self->raid_f(@messages); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 70 | $self->loop->await($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 69 | return $f->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # The ADR 0015 event types the journal records from the events of a run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # run.finished is written by end_run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 75 | my %JOURNAL_TYPE = map { $_ => 1 } qw( run.started message tool.call tool.result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | # The run in progress: { session, run, on_event, t0 }. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 75 | has _run => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | predicate => 'has_run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | clearer => '_clear_run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 142 | ▶ | sub run_prompt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_prompt: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 142 | my ( $self, $text, %o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 142 | ▶ | return unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $text and length $text
MC/DC50%1/2
defined $text and length $text
defined $text
length $text
Truth table66%2/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 141 | $self->begin_run(%o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 141 | $self->event('message', role => 'user', content => $text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 141 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 141 | ▶ | unless (eval { $result = $self->run($text); 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 18 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 18 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 18 | return $self->end_run(failed => error => $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 122 | ▶ | if (blessed $result && $result->can('is_cancelled') && $result->is_cancelled) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
builtin::blessed($result) and $result->can("is_cancelled") and $result->is_cancelled
builtin::blessed($result) and $result->can("is_cancelled")
MC/DC66%2/3
builtin::blessed($result) and $result->can("is_cancelled") and $result->is_cancelled
builtin::blessed($result)
$result->can("is_cancelled")
$result->is_cancelled
Truth table75%3/4
A and B and C
A= builtin::blessed($result)B= $result->can("is_cancelled")C= $result->is_cancelled
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 6 | return { %{ $self->end_run('cancelled') }, result => $result }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 116 | $self->event('message', role => 'assistant', content => "$result"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 116 | my $metrics = $self->raider->metrics; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 116 | my $end = $self->end_run(completed => metrics => $metrics); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 116 | return { %$end, result => $result, response => "$result", metrics => $metrics }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 142 | ▶ | sub begin_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_run: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 142 | my ( $self, %o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 142 | my $session = $o{session}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $self->_run({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | session => $session, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | run => $session ? $session->next_run : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | on_event => $o{on_event}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 142 | ▶ | t0 => Time::HiRes::time(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 142 | ▶ | $self->event('run.started', engine => $self->engine_name, $self->has_model ? ( model => $self->model ) : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 142 | $self->event('run.state', state => 'running'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 142 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 143 | ▶ | sub end_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_run: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 143 | my ( $self, $status, %fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 143 | ▶ | my $run = $self->_run or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 142 | my $elapsed = 0 + sprintf('%.3f', Time::HiRes::time() - $run->{t0}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | my %end = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | status => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 142 | ▶ | ( map { defined $fields{$_} ? ( $_ => $fields{$_} ) : () } qw( error signal ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | elapsed => $elapsed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 142 | ▶ | if (my $session = $run->{session}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 84 | ▶ | my $metrics = $fields{metrics} // eval { $self->raider->metrics }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fields{"metrics"} // eval {
MC/DC0%0/2
$fields{"metrics"} // eval {
do {
$self->raider->metrics
}
}
$fields{"metrics"}
eval {
do {
$self->raider->metrics
}
}
Truth table66%2/3
A // B
A= $fields{"metrics"}B= eval {
do {
$self->raider->metrics
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 84 | ▶ | $self->_append($run, 'run.finished', run => $run->{run}, %end, $metrics ? ( metrics => $metrics ) : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 84 | $end{session} = { id => $session->id, path => ''.$session->path }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 142 | $self->event('run.state', state => $status); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 142 | $self->_clear_run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # A cancel that came too late for the raid must not hit the next run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 142 | ▶ | $self->_raider->clear_cancel if $self->_has_raider; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 142 | return \%end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 7 | ▶ | sub cancel_run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cancel_run: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 7 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 7 | ▶ | my $run = $self->_run or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 6 | $run->{cancelled} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 6 | ▶ | $self->_raider->cancel if $self->_has_raider; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 902 | ▶ | sub event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 902 | my ( $self, $type, %payload ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 902 | ▶ | if (my $run = $self->_run) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 902 | ▶ | $self->_append($run, $type, run => $run->{run}, %payload) if $run->{session} && $JOURNAL_TYPE{$type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$run{"session"} and $JOURNAL_TYPE{$type}
MC/DC100%2/2
$$run{"session"} and $JOURNAL_TYPE{$type}
$$run{"session"}
$JOURNAL_TYPE{$type}
Truth table100%3/3
A and B
A= $$run{"session"}B= $JOURNAL_TYPE{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 902 | ▶ | $run->{on_event}->($type, %payload) if $run->{on_event}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 902 | ▶ | $self->on_event->($type, %payload) if $self->has_on_event; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 902 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 3 | ▶ | sub record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | my ( $self, $session, $type, %fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 3 | return $self->_append({ session => $session }, $type, %fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # Appends to the session of $run (a run, or just { session }); reports | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | # only the first failure of each $run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 511 | ▶ | sub _append { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_append: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 511 | my ( $self, $run, $type, %fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 511 | my $session = $run->{session}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 511 | ▶ | return 1 if eval { $session->append($type, %fields); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 33 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 33 | ▶ | return 0 if $run->{journal_failed}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 6 | ▶ | if ($self->has_on_journal_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 6 | $self->on_journal_error->($session, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | warn 'session '.$session->id.' not fully saved: '.$error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 6 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 296 | ▶ | sub raider { $_[0]->_raider } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 89 | ▶ | sub loaded_skill_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loaded_skill_names: called CC=16 SCAR=34.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 89 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 89 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 89 | for my $spec (@{$self->skill_sources}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 7 | ▶ | my $type = $spec->{type} // 'dir'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$spec{"type"} // "dir"
MC/DC0%0/1
$$spec{"type"} // "dir"
$$spec{"type"}
Truth table50%1/2
A
A= $$spec{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 7 | my $rel = $spec->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 7 | ▶ | next unless defined $rel && length $rel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rel and length $rel
MC/DC0%0/2
defined $rel and length $rel
defined $rel
length $rel
Truth table33%1/3
A and B
A= defined $relB= length $rel
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 7 | my $base = Path::Tiny::path($rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 7 | ▶ | $base = Path::Tiny::path($self->root)->child($rel) unless $base->is_absolute; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 7 | ▶ | if ($type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 3 | ▶ | push @names, $base->basename if -f $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 4 | ▶ | next unless -d $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 4 | ▶ | if ($type eq 'claude') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | for my $dir (sort $base->children) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | next unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | push @names, $dir->basename if -f $dir->child('SKILL.md'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 4 | for my $f (sort $base->children) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 4 | ▶ | push @names, $f->basename if -f $f && $f =~ /\.md$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $f and $f =~ /\.md$/
MC/DC0%0/2
-f $f and $f =~ /\.md$/
-f $f
$f =~ /\.md$/
Truth table33%1/3
A and B
A= -f $fB= $f =~ /\.md$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 89 | return @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 75 | has session_store => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | isa => 'Langertha::Raider::SessionStore', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | builder => '_build_session_store', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 119 | ▶ | sub session_store_class { 'Langertha::Raider::SessionStore' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_store_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 119 | ▶ | sub _build_session_store { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_session_store: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 119 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 119 | return $self->session_store_class->new(root => $self->root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 58 | ▶ | sub create_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 58 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 58 | return $self->session_store->create; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 15 | ▶ | sub open_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 15 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 15 | return $self->session_store->open($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 10 | ▶ | sub replay_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replay_session: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 10 | my ($self, $session) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 10 | my $journal = $session->journal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 10 | my $raider = $self->raider; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 10 | $raider->add_history($_->{role}, $_->{content}) for @{ $journal->history_messages }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 10 | $raider->add_session_history(@{ $journal->session_history_messages }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 10 | return $journal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 3 | ▶ | sub fork_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fork_session: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 3 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 3 | my $store = $self->session_store; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | my $history = $store->read($id)->history_messages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 3 | my $session = $store->create(forked_from => $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 3 | $session->append('message', role => $_->{role}, content => $_->{content}) for @$history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 3 | $session->release; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 3 | return { id => $session->id, path => ''.$session->path, forked_from => $id, messages => scalar @$history }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 5 | ▶ | sub remove_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 5 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 5 | my $store = $self->session_store; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 5 | my $path = ''.$store->path_of($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 5 | $store->remove($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 3 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 27 | ▶ | sub reload_mission { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload_mission: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 27 | my $remounted = $self->_remount_tool_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 27 | my $new = $self->_build_mission; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # Hot-swap on the running raider, history and metrics stay. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 27 | my $raider = $self->_raider; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 27 | $raider->_set_mission($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # A raid resumed from a continuation re-gathers its tools too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 27 | ▶ | $raider->_tools_dirty(1) if $remounted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 27 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 221 | ▶ | sub mission_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mission_source: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 221 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 221 | ▶ | return $self->source_label('mission') if $self->_has_explicit_mission; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 156 | my $instructions = $self->instructions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 156 | ▶ | return !$self->bare && $instructions->file_exists ? $instructions->label : 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->bare and $instructions->file_exists
MC/DC100%2/2
not $self->bare and $instructions->file_exists
not $self->bare
$instructions->file_exists
Truth table100%3/3
not(A) and B
A= not $self->bareB= $instructions->file_exists
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 32 | ▶ | sub source_labels { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source_labels: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 487 | ▶ | sub source_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source_label: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 487 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 487 | ▶ | return $self->source_labels->{$key} // $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->source_labels->{$key} // $key
MC/DC0%0/2
$self->source_labels->{$key} // $key
$self->source_labels->{$key}
$key
Truth table66%2/3
A // B
A= $self->source_labels->{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 89 | ▶ | sub explain_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
explain_config: called CC=33 SCAR=35.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 89 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 89 | my $engine = $self->engine_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 89 | my $report = $self->config->explain($engine); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 88 | my $explicit = $self->_explicit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 88 | my $app_opts = $self->_cli_app_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 88 | my $opts = { %{ $self->_cli_engine_options }, %$app_opts }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 88 | my $opt_label = $self->source_label('engine_options'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | # Config file values as candidates: [ source, value, shadowed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # merged_with ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 88 | my ( %yml, @yml_skills ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 88 | for my $v (@{ $report->{values} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | my $candidate = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | $self->_yml_source($v->{source}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | $v->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 13 | ▶ | [ map { $self->_yml_source($_) } @{ $v->{shadowed} } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 82 | ( $v->{merged_with} ? [ map { $self->_yml_source($_) } @{ $v->{merged_with} } ] : () ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 82 | ▶ | if ($v->{merged}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 10 | push @yml_skills, { %$v, source => $candidate->[0], shadowed => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 72 | $yml{ $v->{key} } = { applies_to => $v->{applies_to}, candidate => $candidate }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 88 | my %from_yml = map { $_ => $yml{$_}{candidate} } keys %yml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 88 | my $env_var = $self->engine_resolver->env_var_for_engine($engine); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 88 | ▶ | my $env_key = defined $env_var && length($ENV{$env_var} // '') ? $env_var : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
defined $env_var and length($ENV{$env_var} // "")
$ENV{$env_var} // ""
MC/DC50%1/2
defined $env_var and length($ENV{$env_var} // "")
defined $env_var
$ENV{$env_var}
Truth table66%2/3
A and B
A= defined $env_varB= $ENV{$env_var}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 88 | my $default_model = $self->engine_resolver->default_model_for_engine($engine); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 88 | my $yml_key = $from_yml{api_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | my @values = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | $self->_explain_entry(engine => 'raider', [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | $explicit->{engine} ? [ $self->source_label('engine'), $engine ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | defined $opts->{engine} ? [ $opt_label, $opts->{engine} ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | $from_yml{engine}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | ], [ $env_key ? 'env '.$env_key : 'default', $engine ]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | $self->_explain_entry(model => 'engine', [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | $explicit->{model} ? [ $self->source_label('model'), $self->model ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | defined $opts->{model} ? [ $opt_label, $opts->{model} ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | $from_yml{model}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ], defined $default_model ? [ 'default', $default_model ] : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | $self->_explain_entry(api_key => 'engine', [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | $explicit->{api_key} ? [ $self->source_label('api_key'), '(set)' ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 88 | ▶ | defined $opts->{api_key} ? [ $opt_label, '(set)' ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | $yml_key ? [ $yml_key->[0], '(set)', $yml_key->[2] ] : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | ], $env_key ? [ 'env '.$env_key, '(set)' ] : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | my %flag = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ( $self->has_pack_names ? ( packs => [ $self->source_label('pack_names'), $self->pack_names ] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 88 | ▶ | ( $explicit->{perl} && $self->perl ? ( perl => [ $self->source_label('perl'), 1 ] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition66%2/3
$$explicit{"perl"} and $self->perl
MC/DC50%1/2
$$explicit{"perl"} and $self->perl
$$explicit{"perl"}
$self->perl
Truth table66%2/3
A and B
A= $$explicit{"perl"}B= $self->perl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | ( $self->has_detect_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | ? ( detect => [ $self->source_label($self->detect ? 'detect' : 'no_detect'), $self->detect ? 1 : 0 ] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 88 | my %key = map { $_ => 1 } keys %$opts, keys %yml, keys %flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 88 | delete @key{qw( engine model api_key skills project_tools )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 88 | my @ignored = @{ $report->{ignored} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | push @ignored, { key => $opt_label.' project_tools', reason => 'only ~/.raider/config.yml grants tools to projects' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 88 | ▶ | if exists $opts->{project_tools}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 88 | for my $key (sort keys %key) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 68 | ▶ | my $applies_to = $self->config->is_app_key($key) ? 'raider' : 'engine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | push @values, $self->_explain_entry($key, $applies_to, [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | $flag{$key} // ( exists $opts->{$key} ? [ $opt_label, $opts->{$key} ] : undef ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 68 | ▶ | $from_yml{$key}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$flag{$key} // (exists $$opts{$key} ? [$opt_label, $$opts{$key}] : undef)
MC/DC100%2/2
$flag{$key} // (exists $$opts{$key} ? [$opt_label, $$opts{$key}] : undef)
$flag{$key}
(exists $$opts{$key} ? [$opt_label, $$opts{$key}] : undef)
Truth table100%3/3
A // B
A= $flag{$key}B= (exists $$opts{$key} ? [$opt_label, $$opts{$key}] : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 88 | push @values, @yml_skills; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | push @values, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | key => 'skills', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | value => $app_opts->{skills}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | source => $opt_label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | shadowed => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | merged => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | applies_to => 'raider', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 88 | ▶ | } if $app_opts->{skills}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 88 | ▶ | push @values, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | key => 'skills', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | value => $self->cli_skill_sources, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | source => $self->source_label('cli_skill_sources'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | shadowed => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | merged => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | applies_to => 'raider', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } if $self->has_cli_skill_sources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 88 | my ( $detecting, $why ) = $self->detection_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | %$report, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | values => \@values, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ignored => \@ignored, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | ( $report->{project_tools} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 88 | ▶ | ? ( project_tools => { %{ $report->{project_tools} }, tools => $self->_project_tools_report($report->{project_tools}) } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | detection => $detecting ? 'on' : 'off ('.$why.')', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | instructions => $self->mission_source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | bare => $self->bare ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | packs => $self->packs->activation_report, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | skipped_packs => $self->packs->skipped_packs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | perl_tools => $self->perl_tools_grant, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | tools => $self->_tool_effects_report, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | ignored_instructions_files => [ $self->instructions->ignored_files ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | # One entry per mounted tool: name, source (engine:N, the 1-based mount | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # position -- the name the internal gate sees) and its effect classes from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | # Langertha::Raider::ToolEffects, undef when the table does not know it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 88 | ▶ | sub _tool_effects_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tool_effects_report: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 88 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 88 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | return [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 286 | my $source = 'engine:'.++$n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 682 | map { { name => $_->name, source => $source, effects => $self->_tool_effects_class->effects_for($_->name) } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 286 | @{ $_->tools }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 88 | } @{ $self->_tool_servers } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 689 | ▶ | sub _tool_effects_class { 'Langertha::Raider::ToolEffects' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tool_effects_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | # One entry per tool name that project_tools names or an active pack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | # requests: the matching selectors that grant it, the packs that request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | # it, and whether raider knows the name (a built-in or mounted tool, or a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # tool group). Information only: the active tool set does not follow it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 9 | ▶ | sub _project_tools_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_project_tools_report: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 9 | my ($self, $project_tools) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 9 | my ( %granted, %requested ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 9 | for my $s (@{ $project_tools->{selectors} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 14 | for my $name (@{ $s->{tools} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 29 | ▶ | $granted{$name} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$granted{$name} //= []
MC/DC100%1/1
$granted{$name} //= []
$granted{$name}
Truth table100%2/2
A
A= $granted{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 29 | ▶ | push @{ $granted{$name} }, $s->{selector} if $s->{matched}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 9 | my $packs = $self->packs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 9 | for my $pack (@{ $packs->enabled_pack_names }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 12 | push @{ $requested{$_} }, 'pack '.$pack for @{ $packs->packs_by_name->{$pack}->tools }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 9 | my %mounted = map { $_->name => 1 } $self->_mounted_tools; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 9 | my %group = map { $_ => 1 } $self->_tool_group_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | return [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 28 | my $name = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | granted_by => $granted{$name} // [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | requested_by => $requested{$name} // [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | known => $group{$name} ? 'tool group' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 28 | ▶ | : $mounted{$name} || $self->_tool_effects_class->effects_for($name) ? 'tool' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%7/7
$granted{$name} // []
$requested{$name} // []
$mounted{$name} or $self->_tool_effects_class->effects_for($name)
MC/DC100%1/1
$granted{$name} // []
$granted{$name}
MC/DC100%1/1
$requested{$name} // []
$requested{$name}
MC/DC100%2/2
$mounted{$name} or $self->_tool_effects_class->effects_for($name)
$mounted{$name}
$self->_tool_effects_class->effects_for($name)
Truth table100%2/2
A
A= $granted{$name}
Truth table100%2/2
A
A= $requested{$name}
Truth table100%3/3
A or B
A= $mounted{$name}B= $self->_tool_effects_class->effects_for($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 9 | } sort keys %{ { %granted, %requested } } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # The tool groups raider grants by name today: what a pack's tools: may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | # request (perl, the Perl tools of perl_tools_grant). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 9 | ▶ | sub _tool_group_names { qw( perl ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tool_group_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 99 | ▶ | sub _yml_source { $_[0]->config->layer_label($_[1]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_yml_source: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | # One explain entry from candidates [ source, value, shadowed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | # merged_with ], highest priority first; the fallback counts only when no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | # candidate is set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 332 | ▶ | sub _explain_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_explain_entry: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 332 | my ($self, $key, $applies_to, $candidates, $fallback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 332 | my @have = grep { defined } @$candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 332 | ▶ | @have = ($fallback) if !@have && $fallback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not @have and $fallback
MC/DC100%2/2
not @have and $fallback
not @have
$fallback
Truth table100%3/3
not(A) and B
A= not @haveB= $fallback
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 332 | ▶ | return unless @have; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 327 | my ($win, @rest) = @have; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | value => $win->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | source => $win->[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 327 | ▶ | shadowed => [ @{ $win->[2] // [] }, map { ( $_->[0], @{ $_->[3] // [] }, @{ $_->[2] // [] } ) } @rest ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$$win[2] // []
$$_[3] // []
$$_[2] // []
MC/DC100%1/1
$$win[2] // []
$$win[2]
MC/DC100%1/1
$$_[3] // []
$$_[3]
MC/DC0%0/1
$$_[2] // []
$$_[2]
Truth table100%2/2
A
A= $$win[2]
Truth table100%2/2
A
A= $$_[3]
Truth table50%1/2
A
A= $$_[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | applies_to => $applies_to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | ( $win->[3] ? ( merged_with => $win->[3] ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 75 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 75 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | Langertha::Raider::Application - Internal application service that builds and runs a raider for a workspace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | version 0.503 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | # Internal to Langertha-Raider -- no API promise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | my $app = Langertha::Raider::Application->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | root => '/path/to/project', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | engine_options => { temperature => 0.2 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | my $result = $app->run('Explore the repo and summarize it.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | my $raider = $app->raider; # the Langertha::Raider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | B<Internal module.> Its interface may change without notice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | The application service the surfaces share (ADR 0002): for one workspace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | (L</root>) it reads the project config file (L<Langertha::Raider::Config>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | F<.raider/config.yml>, else the legacy F<.raider.yml>; below, F<.raider.yml> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | stands for whichever is in use, laid over the home file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | F<~/.raider/config.yml>), picks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | the engine through L<Langertha::Raider::EngineResolver>, activates the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | packs (L<Langertha::Raider::Packs>, ADR 0012), compiles the mission (ADR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0004, ADR 0014), mounts the tool servers -- files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | (L<Langertha::Raider::FileTools>), C<bash> (L<MCP::Run::Bash>), web | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | (L<Langertha::Raider::WebTools>), the Perl tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | (L<Langertha::Raider::PerlTools>) when granted, the Hall tools when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | spawned by a Hall -- and builds the L<Langertha::Raider> that runs the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | raids. It opens, creates and replays the sessions of the project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | (L</session_store>, ADR 0015) and records every run in the session's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | journal (L</run_prompt>), handing the run's events on to the surface. It | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | prints nothing; presentation such as the live trace belongs to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | the surface, see L<Langertha::Raider::CLI>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | =head2 engine_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | Langertha engine class shortcut (e.g. C<'anthropic'>, C<'openai'>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | C<'deepseek'>, C<'groq'>, C<'mistral'>, C<'gemini'>, C<'ollama'>), passed as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | C<engine>. Defaults to C<-o engine=>, then to C<engine:> in F<.raider.yml>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | then to the first C<*_API_KEY> environment variable found, then to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | C<'anthropic'> (L<Langertha::Raider::EngineResolver/engine_name>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | =head2 engine_resolver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | The L<Langertha::Raider::EngineResolver> that picks engine, model and API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | key from the flags, the C<-o> options, F<.raider.yml> and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | environment, and builds the engine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | =head2 provider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | The completed provider activation of C<raider --provider> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | (L<Langertha::Raider::Provider::Activation/activate_f>), or none. It | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | decides engine, model and URL; see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | L<Langertha::Raider::EngineResolver/provider>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | =head2 model | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | Model identifier to pass to the engine. Defaults to C<model> in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | L</engine_options>, then C<model:> in F<.raider.yml>, then the per-engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | cheap default. An explicit C<model> always wins; this is the model the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | engine is built with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | =head2 api_key_env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | Name of the environment variable used for the current engine's API key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | (for display / debugging). Returns undef for engines that don't use an API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | key (e.g. ollama). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | =head2 api_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | API key for the engine. Defaults to C<api_key> in L</engine_options>, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | C<api_key:> in F<.raider.yml>, then an engine-appropriate environment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | variable. An explicit C<api_key> always wins. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | =head2 mission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | System prompt of the Raider, compiled from separate items (ADR 0004, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | ADR 0014): the instructions (a generic assistant persona plus the project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | instructions file, L</instructions>), the tool description, the loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | skills and the active packs. The tool description lists the tools of the mounted tool servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | -- the same servers the engine gets -- each as C<name(required, [optional])> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | from its input schema (ADR 0005); a tool that is not mounted is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | described. A C<mission> passed to the constructor (C<-M>) replaces the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | instructions item only, also across L</reload_mission>; the other items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | still apply. With L</bare> the skills, the instructions file and all packs not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | switched on by C<--pack> or C</pack> are left out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | =head2 bare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | C<--bare>: an isolated context. No instructions file (F<.raider.md>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | F<.raider/instructions.md>), no skills, no pack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | detection, and no packs from C<packs:> or C<enabled_by_default>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | C<--pack NAME> and C</pack NAME> still switch a pack on explicitly. What | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | remains is the instructions (the default persona, or the C<-M> text) and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | the tool description. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | =head2 persona_intro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | The first paragraph of the default persona: who the agent is and where it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | runs. The command line (L<Langertha::Raider::CLI>) says it is a CLI. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | =head2 persona_turn_end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | The last paragraph of the default persona: how the agent ends a turn and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | who answers next. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | =head2 root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | Working directory for tool operations. Defaults to the current process cwd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | File tools are confined to this directory, including realpath checks for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | symlink escapes; bash commands inherit it as their default working directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | =head2 allowed_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | Optional arrayref restricting which bash commands may run (first word match). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | When undef, any command is allowed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | =head2 max_iterations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | Maximum tool-calling iterations per raid. Defaults to 10_000 — effectively | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | unlimited, so a raid only ends when the model itself stops emitting tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | calls. The conversation history is preserved between raids, so the next user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | message in the REPL simply continues the same thread. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | Set this to a smaller number if you want a hard safety cap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | =head2 on_event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | Optional code reference called as C<< $on_event->($type, %payload) >> for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | every event of the application (L</event>): the run events of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | L</run_prompt> and every C<tool.call> and C<tool.result> of a raid, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | come from L<Langertha::Raider::Plugin::Events>. A surface that follows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | one run passes its consumer to L</run_prompt> instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | =head2 on_journal_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | Optional code reference called as C<< $on_journal_error->($session, $error) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | when an event cannot be written to a session journal (a full disk): once | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | per run, and once per L</record>. The run goes on. Without it the error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | is a C<warn>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | =head2 perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | Enable the PerlTools MCP server (perl_eval, perl_check, perl_cpanm). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | Off by default; set via C<--perl> CLI flag or C<perl: true> in F<.raider.yml>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | Without either, the tools also come with the C<perl> pack, which is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | detected in a Perl workspace; see L</perl_tools_enabled>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | =head2 perl_tools_enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | Whether the PerlTools server is mounted: C<--perl> turns it on; else an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | explicit C<perl:> (in F<.raider.yml> or C<-o perl=>) decides either way; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | else it is on when an active pack requests the C<perl> tools (the bundled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | C<perl> pack, detected by F<cpanfile>, F<dist.ini>, F<Makefile.PL> or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | F<lib/**/*.pm>). Granting a pack's request here stands in for the local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | tool policy of ADR 0005, which does not exist yet; C<perl: false> is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | local denial. A pack switched on or off later is followed by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | L</reload_mission>, which remounts the server to match. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | =head2 perl_tools_grant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | my $grant = $app->perl_tools_grant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | # { enabled => 1, reason => 'pack perl (detected)' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | L</perl_tools_enabled> with the reason: L</perl> by its L</source_label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | (C<--perl> on the command line), C<perl: true> or C<perl: false> with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | where it was set (C<.raider.yml> or the label of C<engine_options>, C<-o>), the active | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | packs requesting the tools with their activation source, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | C<not requested>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | =head2 preferred_lib_target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | Override the default local::lib target for perl_cpanm. When unset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | defaults to F<.raider/lib/> for standalone raiders. Can be set via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | C<preferred_lib_target> in F<.raider.yml>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | =head2 pack_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | Optional list of pack names supplied by the CLI, usually from repeatable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | C<--pack NAME>. When present, these override the C<packs:> list in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | F<.raider.yml>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | =head2 no_pack_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | Pack names switched off from the command line (repeatable C<--no-pack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | NAME>). They win over C<--pack>, C<packs:>, the bundled defaults and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | detection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | =head2 detect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | Pack detection from the command line: C<0> for C<--no-detect>, C<1> for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | C<--detect>. When not given, C<detect:> in F<.raider.yml> decides; the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | default is on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | =head2 packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | L<Langertha::Raider::Packs::Collection> of the installed packs: those in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | F<< L</root>/.raider/packs/ >>, F<~/.raider/packs/>, the bundled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | C<share/packs/> and C<$RAIDER_PACK_DIRS>, the first place winning for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | name (L<Langertha::Raider::Packs/build_packs>). Which are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | enabled, highest priority first (ADR 0012); with L</bare> only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | C<--pack NAME> applies: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | =item 1. C<--no-pack NAME> switches a pack off; C<--pack NAME> (or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | C<-o packs=a,b>) enables the listed ones exclusively; C<--no-detect> / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | C<--detect> switch detection off or on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | =item 2. C<packs:> in F<.raider.yml> (C<[caveman, git-guru]>) enables the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | listed ones exclusively when no flag named packs; C<detect: false> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | C<no_detect: [NAME]> switch detection off entirely or per pack. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | =item 3. Packs whose detection rule matches L</root> are added. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | Without explicit packs the bundled defaults (C<enabled_by_default>) are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | Detection rules come from a pack's F<pack.yml> (C<detect:>, the pack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | default) and from C<detect:> in F<~/.raider/config.yml> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | F<.raider.yml>, which replace the pack default per pack name, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | project's rule over the home's. Each rule is evaluated against L</root> with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | L<Langertha::Raider::Detect> when L</packs> is built and on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | L</redetect_packs> (C</reload>), never per model call. A detected pack is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | added to the enabled ones; in an exclusive group it gives way to an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | explicit pack and replaces a bundled default. The outcome per pack is in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | L<Langertha::Raider::Packs::Collection/activation_report>. An invalid rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | croaks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | Detection only decides which packs are active, it grants nothing (ADR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0005). Rules from the project's F<.raider.yml> or F<.raider/config.yml> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | are evaluated and packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | from its F<.raider/packs/> are loaded right away: the workspace trust | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | decision of ADR 0004, which is meant to gate both, does not exist yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | =head2 detection_state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | my ( $on, $why ) = $app->detection_state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | Whether pack detection runs, and what decided it: L</bare> or L</detect> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | by their L</source_label> (C<--bare>, C<--detect>, C<--no-detect> on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | command line), C<detect: false> or C<default>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | =head2 redetect_packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | my @detected = $app->redetect_packs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | Drops the packs that were enabled by detection, evaluates the rules again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | against L</root> and returns the names of the packs detected now. Packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | enabled any other way stay as they are. C</reload> calls it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | =head2 max_context_tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | Trigger history auto-compression once the last prompt exceeds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | C<context_compress_threshold * max_context_tokens>. Defaults to 40_000, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | keeps the running session comfortably under typical per-minute rate limits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | (Anthropic org default: 50k input tokens/min on Haiku). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | =head2 context_compress_threshold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | Fraction of L</max_context_tokens> at which compression kicks in. Defaults to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | C<0.7>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | =head2 skill_sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | ArrayRef of skill-source specs to load and append to the mission. Each spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | is a hashref: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | { type => 'claude', path => '.claude/skills' } # Claude Code SKILL.md tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | { type => 'dir', path => 'my-skills', glob => '*.md' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | Defaults to the C<skills> entries of F<.raider.yml> (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | L<Langertha::Raider::Config>) followed by L</cli_skill_sources>. Passing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | C<skill_sources> explicitly replaces both. With L</bare> there are none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | =head2 cli_skill_sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | ArrayRef of skill-source specs from the command line (C<--claude>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | C<--openai>, C<--skills DIR>). They are added to the F<.raider.yml> skills, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | duplicates dropped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | =head2 config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | The L<Langertha::Raider::Config> of L</root>: F<.raider/config.yml>, else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | F<.raider.yml>, over F<~/.raider/config.yml>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | =head2 instructions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | The L<Langertha::Raider::Instructions> of L</root>: the project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | instructions file, F<.raider/instructions.md>, else F<.raider.md>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | =head2 engine_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | HashRef of the C<-o KEY=VALUE> options. Engine attributes (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | C<temperature>, C<response_size>, C<seed>) are forwarded to the engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | constructor, merged on top of values loaded from C<.raider.yml> in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | working directory. Raider's own keys (see | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | L<Langertha::Raider::Config/is_app_key>) configure raider like their | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | F<.raider.yml> counterparts and override them; C<packs> and C<skills> take | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | a comma-separated list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | =head2 raid_f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | my $result = await $app->raid_f($prompt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | Async variant: drives one raid iteration and returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | L<Langertha::Raider::Result>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | =head2 run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | my $result = $app->run($prompt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | Synchronous convenience wrapper around L</raid_f>. Runs the I/O loop until the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | raid completes and returns the result (which stringifies to the final text). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | =head2 run_prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | my $outcome = $app->run_prompt($text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | session => $session, # optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | on_event => sub { my ( $type, %payload ) = @_; ... }, # optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | Runs C<$text> as one run (L</run>) and records it, whichever surface | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | asks: in the journal of the L<Langertha::Raider::Session> as the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | session's next run (ADR 0015) -- C<run.started>, the user input as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | C<message>, every C<tool.call> and C<tool.result> with the whole result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | text, the final answer as C<message>, and C<run.finished> with the end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | state and the raider's metrics, also when the run failed. A journal write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | that fails goes to L</on_journal_error>; the run goes on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | Every event of the run goes to C<on_event> (and L</on_event>) through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | L</event>: the journal types and C<run.state> (C<running>, then the end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | state), as ADR 0013 names them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | Returns the outcome as a hash reference: C<status> (C<completed>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | C<failed>, or C<cancelled> after L</cancel_run>), C<elapsed> (seconds, to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | the millisecond), C<result> (the L<Langertha::Raider::Result>, also of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | cancelled run), C<response> (its text) and C<metrics> of a completed run, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | C<error> of a failed one, and C<session> (C<id>, C<path>) when there is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | one. An empty C<$text> runs nothing and returns nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | =head2 begin_run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | $app->begin_run(session => $session, on_event => $consumer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | Starts a run as L</run_prompt> does, for a surface that drives L</run> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | itself: the run gets the next run id of C<session>, C<run.started> (engine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | and model) and C<run.state> C<running>. L</end_run> ends it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | =head2 end_run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | my $end = $app->end_run(interrupted => signal => 'TERM'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | Ends the run in progress, if there is one: C<run.finished> with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | C<$status> and the given C<error> and C<signal> into the journal, with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | given C<metrics> or else the raider's, then C<run.state> with C<$status>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | Returns C<status>, C<elapsed>, the C<error> and C<signal> given and, with a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | session, C<session> (C<id>, C<path>) -- or nothing outside a run. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | surface calls it for a run it ends itself, as the command line does for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | signal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | =head2 cancel_run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | $app->cancel_run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | Cancels the run in progress (ADR 0009): its raid stops at the next safe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | point (L<Langertha::Raider/cancel>) and L</run_prompt> ends the run as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | C<cancelled> -- C<run.finished> with that status, and a tool call cut off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | gets its C<tool.result> with status C<cancelled>. Tool subprocesses are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | not signalled here; that is the surface's to do. Only records the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | request, so a signal handler may call it. Outside a run it does nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | and returns false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | =head2 event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | $app->event('tool.call', call => 'c1', name => 'bash', arguments => { ... }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | One event of the application, handed to every consumer: the session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | journal of the run in progress for the types it records (with the run's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | C<run> id), the C<on_event> of that run, and L</on_event>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | =head2 record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | $app->record($session, 'history.cleared'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | Appends one event outside a run to the session journal. A write that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | fails goes to L</on_journal_error> and returns false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | =head2 raider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | Returns the underlying L<Langertha::Raider> instance (lazily built). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | =head2 loaded_skill_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | Returns a list of skill names currently discoverable from the configured | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | L</skill_sources>. Intended for banner/status display. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | =head2 session_store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | The L<Langertha::Raider::SessionStore> of the project in L</root> (ADR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0003, ADR 0015), built on first use. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | =head2 create_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | my $session = $app->create_session; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | A new session in L</session_store>, open for writing and locked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | (L<Langertha::Raider::SessionStore/create>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | =head2 open_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | my $session = $app->open_session($id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | Opens the session C<$id> of L</session_store> for writing; croaks C<... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | is in use> while another raider holds it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | (L<Langertha::Raider::SessionStore/open>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | =head2 replay_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | my $journal = $app->replay_session($session); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | Replays the journal the L<Langertha::Raider::Session> was opened with into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | L</raider> (ADR 0015): C<history> from the C<message> events of the runs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | that got an answer, C<session_history> from all events. Nothing is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | executed. Returns the L<Langertha::Raider::Session::Journal>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | =head2 fork_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | my $fork = $app->fork_session($id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | # { id, path, forked_from, messages } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | A new session in L</session_store> whose C<session.created> names the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | session C<$id> in C<forked_from>, and which takes over its working | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | history -- what a resume would replay into C<history> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | (L<Langertha::Raider::Session::Journal/history_messages>) -- as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | C<message> events outside any run. The original is only read (no lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | needed) and never changed. Returns the new session's C<id> and C<path>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | C<forked_from> and how many C<messages> it took over. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | =head2 remove_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | my $path = $app->remove_session($id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | Deletes the session C<$id> of L</session_store>, journal and lock file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | (L<Langertha::Raider::SessionStore/remove>, which croaks C<session ID is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | in use> while another raider has it open). Returns the journal's path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | =head2 reload_mission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | Rebuilds the mission (e.g. after the instructions file has been edited) and swaps it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | into the underlying L<Langertha::Raider>. An explicit L</mission> is kept. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | When L</perl_tools_grant> changed since the tool servers were mounted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | (C</pack>, C</reload>), the PerlTools server is mounted or unmounted first, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | so the engine offers the same tools the new mission describes from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | next raid on; a raid resumed from a pending question re-gathers them too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | =head2 mission_source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | Where the instructions item of L</mission> comes from: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | L</source_label> of C<mission> (C<-M> on the command line) for a mission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | passed to the constructor; the L<Langertha::Raider::Instructions/label> of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | the instructions file (C<.raider/instructions.md> or C<.raider.md>) when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | it customizes the default persona (never with L</bare>); C<default> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | =head2 source_label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | my $label = $app->source_label('pack_names'); # 'pack_names', '--pack' in the CLI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | How reports name a setting that was passed to the constructor: in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | L</explain_config>, L</perl_tools_grant>, L</detection_state>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | L</mission_source> and the pack sources. The keys are C<engine>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | C<model>, C<api_key>, C<engine_options>, C<engine_options packs>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | C<pack_names>, C<no_pack_names>, C<perl>, C<detect>, C<no_detect>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | C<bare>, C<mission> and C<cli_skill_sources>. A surface names its own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | way of setting them in L</source_labels>; without, the label is the key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | =head2 source_labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | The labels of L</source_label> by key; none here. The command line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | (L<Langertha::Raider::CLI>) returns its flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | =head2 explain_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | my $report = $app->explain_config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | Where each effective setting came from, constructor arguments included. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | The shape of L<Langertha::Raider::Config/explain>, with C<source> (and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | C<shadowed>) naming an argument by its L</source_label> (the command line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | names its flags: C<-e>, C<-m>, C<-k>, C<-o>, C<--pack>, C<--perl>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | C<--claude/--openai/--skills>), a layer of the config file by its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | L<Langertha::Raider::Config/label> (C<.raider.yml>, C<.raider.yml default:>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | C<.raider/config.yml openai:>), a layer of the home file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | F<~/.raider/config.yml> (C<home>, C<home default:>, C<home openai:>), an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | environment variable (C<env OPENAI_API_KEY>) or C<default>. A value merged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | from both files (C<no_detect>, C<detect>) names the home layer in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | C<merged_with>. API key values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | are never included. Builds no engine. C<file> is the config file in use and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | C<ignored_files> the config files next to it that are not loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | (L<Langertha::Raider::Config/ignored_files>); C<home_file> is the home | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | file, present only when it is loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | C<detection> says whether pack detection runs (C<on>, or C<off> with what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | switched it off) and C<packs> is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | L<Langertha::Raider::Packs::Collection/activation_report>: each pack with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | its source (C<flag>, C<config>, C<default>, C<detected>, C<manual>), its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | C<origin> (C<project>, C<home>, C<shipped>, C<env>) and, for detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | rules, the clause that matched or failed. C<skipped_packs> is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | L<Langertha::Raider::Packs::Collection/skipped_packs>. C<perl_tools> is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | L</perl_tools_grant>: whether the Perl tools are mounted, and why. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | C<instructions> is L</mission_source> and C<bare> is L</bare>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | C<ignored_instructions_files> are the instructions files that are present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | but not used (L<Langertha::Raider::Instructions/ignored_files>): a legacy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | F<.raider.md> next to F<.raider/instructions.md>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | C<tools> lists the mounted tools, each with its C<name>, its C<source> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | (C<engine:N>) and C<effects>: what it can do, from a static built-in table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | (C<read>, C<write>, C<network>, C<code>, C<message>; empty when it only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | steers the run), or undef when the table does not know the tool. Information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | only -- nothing is enforced by it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | C<project_tools> is present when F<~/.raider/config.yml> has one (ADR 0011; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | L<Langertha::Raider::Config/project_tools>): the C<file> and C<label> it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | was read from, C<selectors> with whether each matches L</root> and why, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | and C<tools>, one entry per tool name that a selector names or an active | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | pack requests (the C<tools:> of its F<pack.yml>; a project has no other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | way to request a tool yet): C<granted_by>, the matching selectors naming | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | it (empty: not granted); C<requested_by>, the requesting packs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | (C<pack perl>); and C<known>, C<tool> for a built-in or mounted tool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | C<tool group> for C<perl>, undef for a name raider does not know (not an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | error). Information only -- the mounted tools do not follow it yet. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | C<project_tools> in the project file, inside a section, or given with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | C<-o> is not read and is listed in C<ignored>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | =item * L<Langertha::Raider> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | =item * L<Langertha::Raider::CLI> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | =item * L<Langertha::Raider::EngineResolver> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | =head2 Issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | L<https://github.com/Getty/langertha-raider/issues>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | =head2 IRC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | This software is copyright (c) 2026 by Torsten Raudssus. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||