Acme-Claude-Shell
view release on metacpan or search on metacpan
bin/acme_claude_shell view on Meta::CPAN
# Check for piped input: acme_claude_shell -c - reads from stdin
my $command = $opts{'command'};
if (defined $command && $command eq '-') {
# Read command from stdin (for piping: echo "list files" | acme_claude_shell -c -)
local $/;
$command = <STDIN>;
chomp $command if defined $command;
}
# Single command mode or interactive
if (defined $command && length $command) {
run($command,
dry_run => $opts{'dry-run'},
safe_mode => $opts{'safe-mode'},
working_dir => $opts{'dir'},
colorful => $opts{'color'},
($opts{'model'} ? (model => $opts{'model'}) : ()),
);
} else {
shell(
dry_run => $opts{'dry-run'},
lib/Acme/Claude/Shell/Session.pm view on Meta::CPAN
# Track session prompts for saving
my @_session_prompts;
sub _load_history {
my ($term) = @_;
return unless -f $HISTORY_FILE;
open my $fh, '<:encoding(UTF-8)', $HISTORY_FILE or return;
while (my $line = <$fh>) {
chomp $line;
$term->addhistory($line) if length $line;
}
close $fh;
}
sub _append_to_history {
my ($input) = @_;
push @_session_prompts, $input;
# Append to file immediately
open my $fh, '>>:encoding(UTF-8)', $HISTORY_FILE or return;
lib/Acme/Claude/Shell/Session.pm view on Meta::CPAN
# REPL loop
while (1) {
my $prompt_str = $self->colorful
? colored(['bold', 'green'], 'acme_claude_shell> ')
: 'acme_claude_shell> ';
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;
lib/Acme/Claude/Shell/Tools.pm view on Meta::CPAN
return (0, undef);
}
elsif ($choice eq 'e') {
my $new_cmd;
if ($colorful) {
$new_cmd = prompt("Edit command:", $command);
} else {
print "Edit command [$command]: ";
$new_cmd = <STDIN>;
chomp $new_cmd if defined $new_cmd;
$new_cmd = $command unless length($new_cmd // '');
}
if ($colorful) {
status('info', "Modified command:");
print colored(['bold', 'white'], " $new_cmd\n\n");
} else {
print "Modified: $new_cmd\n";
}
# For dangerous commands after editing, still require confirmation
lib/Acme/Claude/Shell/Tools.pm view on Meta::CPAN
if ($name_match) {
if ($content_re) {
# Search file content
if (open my $fh, '<', $path) {
my $line_num = 0;
while (my $line = <$fh>) {
$line_num++;
if ($line =~ $content_re) {
chomp $line;
$line = substr($line, 0, 100) . '...' if length($line) > 100;
push @$results, "$rel_path:$line_num: $line";
last if @$results >= 100;
}
}
close $fh;
}
}
else {
push @$results, $rel_path;
}
( run in 0.674 second using v1.01-cache-2.11-cpan-140bd7fdf52 )