App-Raider

 view release on metacpan or  search on metacpan

lib/App/Raider.pm  view on Meta::CPAN

  default   => sub {
    my ($self) = @_;
    return default_model_for_engine($self->engine_name) // '';
  },
);

sub has_model {
  my ($self) = @_;
  return 1 if $self->has_explicit_model;
  return length($self->model) ? 1 : 0;
}


sub api_key_env {
  my ($self) = @_;
  return env_var_for_engine($self->engine_name);
}


has api_key => (
  is      => 'ro',
  isa     => 'Str',
  lazy    => 1,
  builder => '_build_api_key',
);


has mission => (
  is      => 'ro',
  isa     => 'Str',
  lazy    => 1,
  builder => '_build_mission',
);

sub _build_mission {
  my ($self) = @_;
  my $root = $self->root;
  my $base = <<"EOM";
You are Langertha, viking shield-maiden. Autonomous CLI agent on user's
local machine. CLI name: "raider". Just CLI. No pause, no abort, no ask
to stop. You do things.

Name, persona, tone are defaults. User can rename you, rewrite your
background, or change persona entirely via C<.raider.md> in working dir.
If present, its content appended below as user's custom instructions.
User's custom instructions override this default where they conflict.

Working directory: $root

Tools (MCP):
  - list_files(path)
  - read_file(path)
  - write_file(path, content)
  - edit_file(path, old_string, new_string)
  - bash(command, [working_directory], [timeout])
  - web_search(query, [limit])
  - web_fetch(url, [as_html])

How you work:
  - User turn = task. Pursue with tools until done. Unlimited iterations.
  - Read before write. No guessing file contents.
  - After write_file / edit_file: verify. Re-read, or run check (perl -c,
    tests, etc.).
  - Small targeted edits > full rewrites.
  - bash is full shell, not sandbox. Use freely.
  - Skip irreversible ops (rm -rf, git reset --hard, force pushes) unless
    user explicit ask.

Communication (Caveman mode, default):
  - Terse. Drop articles (a/an/the), filler (just/really/basically/
    actually/simply), pleasantries (sure/certainly/of course/happy to),
    hedging (maybe/perhaps/I think).
  - Fragments OK. Short synonyms (big not extensive, fix not "implement
    a solution for").
  - Technical terms exact. Code blocks unchanged. Errors quoted exact.
  - Pattern: `[thing] [action] [reason]. [next step].`
  - Not: "Sure! I'd be happy to help. The issue is likely caused by..."
  - Yes: "Bug in auth middleware. Token check uses `<` not `<=`. Fix:"
  - Drop caveman for: destructive ops warnings, irreversible confirmations,
    multi-step sequences where fragment order could confuse. Resume after.
  - User says "normal mode" or "stop caveman": revert, write normal.

You have no yield / ask / abort tool. Task done: plain text reply. CLI
loops back to user.
EOM

  my $custom_file = path($self->root)->child('.raider.md');
  if (-f $custom_file) {
    my $custom = eval { $custom_file->slurp_utf8 };
    if (defined $custom && length $custom) {
      $base .= "\n\n---\nUser's custom instructions (from $custom_file):\n\n$custom\n";
    }
  }

  my @skills = $self->_load_skill_texts;
  if (@skills) {
    $base .= "\n\n---\nLoaded skills (domain knowledge the user enabled for this session):\n\n"
           . join("\n\n", @skills) . "\n";
  }

  return $base;
}


has root => (
  is      => 'ro',
  isa     => 'Str',
  default => sub { Path::Tiny->cwd->stringify },
);


has allowed_commands => (
  is        => 'ro',
  isa       => 'ArrayRef[Str]',
  predicate => 'has_allowed_commands',
);


has max_iterations => (
  is      => 'ro',
  isa     => 'Int',



( run in 2.326 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )