view release on metacpan or search on metacpan
lib/App/Rad.pm view on Meta::CPAN
=head2 include I<[command_name]> I<-perl_params> I<'your subroutine code'>
Includes the given subroutine into your program on-the-fly, just as you would writing it directly into your program.
Let's say you have your simple I<'myapp.pl'> program that uses App::Rad sitting on your system quietly. One day, perhaps during your sysadmin's tasks, you create a really amazing one-liner to solve a really hairy problem, and want to keep it for post...
For instance, to change a CSV file in place, adding a column on position #2 containing the line number, you might do something like this (this is merely illustrative, it's not actually the best way to do it):
$ perl -i -paF, -le 'splice @F,1,0,$.; $_=join ",",@F' somesheet.csv
view all matches for this distribution
view release on metacpan or search on metacpan
.claude/skills/perl-ai-langertha/SKILL.md view on Meta::CPAN
print $response; # Stringifies to content
# Async
use Future::AsyncAwait;
my $response = await $engine->simple_chat_f('Tell me a story.');
say $response->model; # Model name
say $response->prompt_tokens; # Token usage
say $response->completion_tokens;
say $response->thinking; # Chain-of-thought (if available)
```
`Langertha::Response` overloads `""` so it works in string contexts.
</simple-chat>
.claude/skills/perl-ai-langertha/SKILL.md view on Meta::CPAN
mcp_servers => [$mcp], # Pass MCP server(s)
);
# One-shot tool calling
my $response = await $engine->chat_with_tools_f('Find all .pm files in lib/');
say $response;
```
</tool-calling>
<raider>
## Raider â Autonomous Agent
.claude/skills/perl-ai-langertha/SKILL.md view on Meta::CPAN
# Raid (autonomous tool-calling loop)
my $result = await $raider->raid_f('Review lib/App.pm');
# Result handling
say $result; # Stringified response
say $result->is_question; # Agent asked a question
say $result->is_abort; # Agent aborted
# Continue conversation (has context from previous raids)
my $r2 = await $raider->raid_f('Now suggest improvements.');
# Respond to question
.claude/skills/perl-ai-langertha/SKILL.md view on Meta::CPAN
$raider->add_history('user', $content); # Replay from DB
$raider->clear_history; # Reset
# Metrics
my $m = $raider->metrics;
say "Iterations: $m->{iterations}";
say "Tool calls: $m->{tool_calls}";
```
### Raid Loop (simplified)
1. Auto-compress history if context threshold exceeded
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Rakubrew.pm view on Meta::CPAN
sub run_script {
my ($self) = @_;
my @args = @{$self->{args}};
sub _cant_access_home {
say STDERR "Can't create rakubrew home directory in $prefix";
say STDERR "Probably rakubrew was denied access. You can either change that folder to be writable";
say STDERR "or set a different rakubrew home directory by setting the `\$RAKUBREW_HOME` environment";
say STDERR "prior to calling the rakubrew shell hook. ";
exit 1;
}
unless (-d $prefix) {
_cant_access_home() unless mkdir $prefix;
lib/App/Rakubrew.pm view on Meta::CPAN
&& !(@args && $args[0] eq 'init')
&& !(@args && $args[0] eq 'home')
&& !(@args && $args[0] =~ /^internal_/)
|| @args && $args[0] eq 'shell'
|| @args >= 2 && $args[0] eq 'mode' && $args[1] eq 'env') {
say STDERR << "EOL";
The shell hook required to run rakubrew in either 'env' mode or with the 'shell' command seems not to be installed.
Run '$brew_name init' for installation instructions if you want to use those features,
or run '$brew_name mode shim' to use 'shim' mode which doesn't require a shell hook.
EOL
exit 1;
lib/App/Rakubrew.pm view on Meta::CPAN
my $arg = shift(@args) // 'help';
if ($arg eq 'version' || $arg eq 'current') {
if (my $c = get_version()) {
if (@args && $args[0] eq '--short') {
say "$c"
}
else {
say "Currently running $c"
}
} else {
say STDERR "Not running anything at the moment. Use '$brew_name switch' to set a version";
exit 1;
}
} elsif ($arg eq 'versions' || $arg eq 'list') {
my $cur = get_version() // '';
lib/App/Rakubrew.pm view on Meta::CPAN
my $version_line = '';
$version_line .= 'BROKEN ' if is_version_broken($_);
$version_line .= $_ eq $cur ? '* ' : ' ';
$version_line .= $_;
$version_line .= ' -> ' . (get_version_path($_, 1) || '') if is_registered_version($_);
say $version_line;
} get_versions();
} elsif ($arg eq 'global' || $arg eq 'switch') {
if (!@args) {
my $version = get_global_version();
if ($version) {
say $version;
}
else {
say "$brew_name: no global version configured";
}
}
else {
$self->match_and_run($args[0], sub {
set_global_version(shift);
lib/App/Rakubrew.pm view on Meta::CPAN
} elsif ($arg eq 'shell') {
if (!@args) {
my $shell_version = get_shell_version();
if (defined $shell_version) {
say "$shell_version";
}
else {
say "$brew_name: no shell-specific version configured";
}
}
else {
my $version = shift @args;
if ($version ne '--unset') {
lib/App/Rakubrew.pm view on Meta::CPAN
} elsif ($arg eq 'local') {
validate_brew_mode();
if (!@args) {
my $version = get_local_version();
if ($version) {
say $version;
}
else {
say "$brew_name: no local version configured for this directory";
}
}
else {
my $version = shift @args;
if ($version eq '--unset') {
lib/App/Rakubrew.pm view on Meta::CPAN
my ($cur_backend, $cur_rakudo) = split '-', (get_version() // ''), 2;
$cur_backend //= '';
$cur_rakudo //= '';
my @downloadables = App::Rakubrew::Download::available_precomp_archives();
say "Available Rakudo versions:";
map {
my $ver = $_;
my $d = (grep {$_->{ver} eq $ver} @downloadables) ? 'D' : ' ';
my $s = $cur_rakudo eq $ver ? '*' : ' ';
say "$s$d $ver";
} App::Rakubrew::Build::available_rakudos();
say '';
$cur_backend |= '';
$cur_rakudo |= '';
say "Available backends:";
map { say $cur_backend eq $_ ? "* $_" : " $_" } App::Rakubrew::Variables::available_backends();
} elsif ($arg eq 'build-rakudo' || $arg eq 'build') {
my ($impl, $ver, @args) =
App::Rakubrew::VersionHandling::match_version(@args);
if (!$ver) {
lib/App/Rakubrew.pm view on Meta::CPAN
@versions = grep { /^\d\d\d\d\.\d\d/ } @versions;
$ver = $versions[-1];
}
if ($impl eq "panda") {
say "panda is discontinued; please use zef (rakubrew build-zef) instead";
} elsif ($impl eq "zef") {
my $version = get_version();
if (!$version) {
say STDERR "$brew_name: No version set.";
exit 1;
}
App::Rakubrew::Build::build_zef($version);
# Might have new executables now -> rehash.
rehash();
say "Done, built zef for $version";
} elsif (!exists $impls{$impl}) {
my $warning = "Cannot build Rakudo with backend '$impl': this backend ";
if ($impl eq "parrot") {
$warning .= "is no longer supported.";
} else {
$warning .= "does not exist.";
}
say $warning;
exit 1;
}
else {
my $configure_opts = '';
if (@args && $args[0] =~ /^--configure-opts=/) {
lib/App/Rakubrew.pm view on Meta::CPAN
$configure_opts =~ s/^'//;
$configure_opts =~ s/'$//;
}
if ($configure_opts =~ /--prefix/) {
say STDERR "Building Rakudo in a custom folder is not supported. If you need";
say STDERR "this it's recommended to build it manually and then use the";
say STDERR "`register` command to make that installation available in Rakubrew.";
exit 1;
}
my $name = "$impl-$ver";
$name = $impl if $impl eq 'moar-blead' && $ver eq 'main';
lib/App/Rakubrew.pm view on Meta::CPAN
# Might have new executables now -> rehash.
rehash();
if (get_version() eq 'system') {
set_global_version($name);
}
say "Done, $name built";
}
} elsif ($arg eq 'triple') {
my ($rakudo_ver, $nqp_ver, $moar_ver) = @args[0 .. 2];
my $name = App::Rakubrew::Build::build_triple($rakudo_ver, $nqp_ver, $moar_ver);
lib/App/Rakubrew.pm view on Meta::CPAN
# Might have new executables now -> rehash
rehash();
if (get_version() eq 'system') {
set_global_version($name);
}
say "Done, $name built";
} elsif ($arg eq 'download-rakudo' || $arg eq 'download') {
my ($impl, $ver, @args) =
App::Rakubrew::VersionHandling::match_version(@args);
if (!exists $impls{$impl}) {
say STDERR "Cannot download Rakudo on '$impl': this backend does not exist.";
exit 1;
}
my $name = App::Rakubrew::Download::download_precomp_archive($impl, $ver);
# Might have new executables now -> rehash
rehash();
if (get_version() eq 'system') {
set_global_version("$name");
}
say "Done, $name installed";
} elsif ($arg eq 'register') {
my ($name, $path) = @args[0 .. 1];
if (!$name || !$path) {
say STDERR "$brew_name: Need a version name and rakudo installation path";
exit 1;
}
if (version_exists($name)) {
say STDERR "$brew_name: Version $name already exists";
exit 1;
}
sub invalid {
my $path = shift;
say STDERR "$brew_name: No valid rakudo installation found at '$path'";
exit 1;
}
$path = rel2abs($path);
invalid($path) if is_version_path_broken($path);
$path = clean_version_path($path);
lib/App/Rakubrew.pm view on Meta::CPAN
} elsif ($arg eq 'build-zef') {
my $version = get_version();
my $zef_version = shift(@args);
if (!$version) {
say STDERR "$brew_name: No version set.";
exit 1;
}
say("Building zef ", $zef_version || "latest");
App::Rakubrew::Build::build_zef($version, $zef_version);
# Might have new executables now -> rehash
rehash();
say "Done, built zef for $version";
} elsif ($arg eq 'build-panda') {
say "panda is discontinued; please use zef (rakubrew build-zef) instead";
} elsif ($arg eq 'exec') {
my $param = shift @args;
if ($param eq '--with') {
my $version = shift @args;
lib/App/Rakubrew.pm view on Meta::CPAN
$self->do_exec($param, \@args);
}
} elsif ($arg eq 'which') {
if (!@args) {
say STDERR "Usage: $brew_name which <command>";
}
else {
my $version = get_version();
if (!$version) {
say STDERR "$brew_name: No version set.";
exit 1;
}
map {say $_} which($args[0], $version);
}
} elsif ($arg eq 'whence') {
if (!@args) {
say STDERR "Usage: $brew_name whence [--path] <command>";
}
else {
my $param = shift @args;
my $pathmode = $param eq '--path';
my $prog = $pathmode ? shift(@args) : $param;
map {say $_} whence($prog, $pathmode);
}
} elsif ($arg eq 'mode') {
if (!@args) {
say get_brew_mode();
}
else {
set_brew_mode($args[0]);
}
lib/App/Rakubrew.pm view on Meta::CPAN
} elsif ($arg eq 'init') {
$self->init(@args);
} elsif ($arg eq 'home') {
say $prefix;
} elsif ($arg eq 'test') {
my $version = shift @args;
if (!$version) {
$self->test(get_version());
lib/App/Rakubrew.pm view on Meta::CPAN
# figure out what to do with this
# filename, let Windows have a try.
# The first line is potentially the shebang. Thus the search for "perl" and/or perl6/raku.
my ($basename, undef, $suffix) = my_fileparse($prog_name);
if($suffix =~ /^\Q\.(exe|bat|cmd)\E\z/i) {
say $path;
}
elsif($suffix =~ /^\Q\.nqp\E\z/i) {
say which('nqp', get_version()).' '.$path;
}
else {
open(my $fh, '<', $path);
my $first_line = <$fh>;
close($fh);
if($first_line =~ /#!.*(perl6|raku)/) {
say get_raku(get_version()) . ' ' . $path;
}
elsif($first_line =~ /#!.*perl/) {
say 'perl '.$path;
}
else {
say $path;
}
}
} elsif ($arg eq 'internal_update') {
App::Rakubrew::Update::internal_update(@args);
} elsif ($arg eq 'rakubrew-version') {
say "rakubrew v$VERSION Build type: $distro_format OS: $^O";
} else {
require Pod::Usage;
my $help_text = "";
open my $pod_fh, ">", \$help_text;
lib/App/Rakubrew.pm view on Meta::CPAN
close $pod_fh;
my $backends = join '|', App::Rakubrew::Variables::available_backends(), 'all';
say $help_text;
}
}
sub match_and_run {
my ($self, $version, $action) = @_;
if (!$version) {
say "Which version do you mean?";
say "Available builds:";
map {say} get_versions();
return;
}
if (grep { $_ eq $version } get_versions()) {
$action->($version);
}
else {
say "Sorry, '$version' not found.";
my @match = grep { /\Q$version/ } get_versions();
if (@match) {
say "Did you mean:";
say $_ for @match;
}
}
}
sub test {
lib/App/Rakubrew.pm view on Meta::CPAN
$self->match_and_run($version, sub {
my $matched = shift;
verify_version($matched);
my $v_dir = catdir($versions_dir, $matched);
if (!-d $v_dir) {
say STDERR "Version $matched was not built by rakubrew.";
say STDERR "Refusing to try running spectest there.";
exit 1;
}
chdir catdir($versions_dir, $matched);
say "Spectesting $matched";
if (!-f 'Makefile') {
say STDERR "Can only run spectest in self built Rakudos.";
say STDERR "This Rakudo is not self built.";
exit 1;
}
run(App::Rakubrew::Build::determine_make($matched), 'spectest');
});
}
lib/App/Rakubrew.pm view on Meta::CPAN
sub nuke {
my ($self, $version) = @_;
$self->match_and_run($version, sub {
my $matched = shift;
if (is_registered_version($matched)) {
say "Unregistering $matched";
unlink(catfile($versions_dir, $matched));
}
elsif ($matched eq 'system') {
say 'I refuse to nuke system Raku!';
exit 1;
}
elsif ($matched eq get_version()) {
say "$matched is currently active. I refuse to nuke.";
exit 1;
}
else {
say "Nuking $matched";
remove_tree(catdir($versions_dir, $matched));
}
});
# Might have lost executables -> rehash
rehash();
lib/App/Rakubrew.pm view on Meta::CPAN
my $self = shift;
my $brew_exec = catfile($RealBin, $brew_name);
if (+@_ == 1) {
# We have an argument. That has to be the shell.
# We already retrieved the shell above, so no need to look at the passed argument here again.
say $self->{hook}->get_init_code;
}
else {
my $shell = ref($self->{hook});
$shell =~ s/.+:://;
my $shell_text = join('|', App::Rakubrew::Shell->available_shells);
my $text = <<EOT;
Your shell has been identified as $shell. If that's wrong, run
$brew_exec init --shell $shell_text
EOT
say $text;
say $self->{hook}->install_note;
}
}
sub de_par_environment {
# The PAR packager modifies the environment.
view all matches for this distribution