Acme-Claude-Shell
view release on metacpan or search on metacpan
lib/Acme/Claude/Shell/Session.pm view on Meta::CPAN
my $input = $term->readline($prompt_str);
last unless defined $input;
$input =~ s/^\s+|\s+$//g;
next unless length $input;
# Built-in commands
last if $input =~ /^(exit|quit)$/i;
if ($input =~ /^history$/i) {
my $selected = $self->_show_history;
if (defined $selected && length $selected) {
# User selected a command to re-run - process it
$term->addhistory($selected);
_append_to_history($selected);
await $self->_process_input($selected);
}
next;
}
if ($input =~ /^clear$/i) {
system('clear');
next;
}
if ($input =~ /^help$/i) {
$self->_show_help;
next;
lib/Acme/Claude/Shell/Session.pm view on Meta::CPAN
unless (@history) {
if ($self->colorful) {
status('info', "No history yet.");
} else {
print "No history yet.\n";
}
return;
}
# Get last 20 unique entries for selection
my @recent = @history > 20 ? @history[-20..-1] : @history;
# Use choose_from for interactive selection
my $selected = choose_from(
\@recent,
prompt => "Select a command to re-run (or press 'q' to cancel):",
inline_prompt => @history > 20 ? "(Last 20 of " . scalar(@history) . ")" : "",
layout => 2, # Single column for readability
);
return $selected;
}
sub _system_prompt {
my ($self) = @_;
return <<'PROMPT';
You are an AI shell assistant. The user describes tasks in natural language,
and you translate them into shell commands.
When the user asks you to do something:
1. Explain what command(s) you'll run and why
( run in 0.638 second using v1.01-cache-2.11-cpan-0e6a335f810 )