summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rexfile77
1 files changed, 41 insertions, 36 deletions
diff --git a/Rexfile b/Rexfile
index 3d4cdce..4a54e7c 100644
--- a/Rexfile
+++ b/Rexfile
@@ -181,55 +181,32 @@ task 'home_lazygit', sub { ensure "$DOT/lazygit/*" => "$HOME/.config/lazygit/" }
desc 'Install ~/.config/opencode';
task 'home_opencode', sub { ensure "$DOT/opencode/*" => "$HOME/.config/opencode/" };
-desc 'Install prompt links for AI tools';
+desc 'Install prompt links for AI tools (legacy alias for home_agents)';
task 'home_prompts', sub {
- if ( -d "$HOME/Notes/Prompts/commands" ) {
- Rex::Logger::info("Installing prompt links");
-
- my $ensure_symlink = sub {
- my ( $source, $target, $label ) = @_;
-
- if ( -l $target ) {
- my $existing = readlink $target;
- if ( defined $existing && $existing eq $source ) {
- return;
- }
- CORE::unlink($target) or die "Could not replace $label symlink at $target: $!";
- }
- elsif ( -d $target ) {
- my ($leaf) = $target =~ m{([^/]+)$};
- my $nested = "$target/$leaf";
- if ( -l $nested && readlink($nested) eq $source ) {
- CORE::unlink($nested) or die "Could not remove nested $label symlink at $nested: $!";
- rmdir $target or die "Could not remove legacy $label directory at $target: $!";
- }
- else {
- die "Refusing to overwrite existing directory at $target while linking $label";
- }
- }
- elsif ( -e $target ) {
- die "Refusing to overwrite existing path at $target while linking $label";
- }
+ run_task 'home_agents';
+};
- symlink $source => $target or die "Could not create $label symlink ($source -> $target): $!";
- };
+desc 'Install agent dotfile symlinks';
+task 'home_agents', sub {
+ if ( -d "$HOME/Notes/Prompts/commands" ) {
+ Rex::Logger::info("Installing agent dotfile symlinks");
- # For most agents, commands and skills live under ~/.<tool>/{commands,skills}.
- my @tool_dirs = ( '.cursor', '.claude', '.agents', '.opencode' );
+ # Most agents store custom commands/skills directly under ~/.<tool>.
+ my @tool_dirs = ( '.cursor', '.claude', '.agents', '.opencode', '.pi', '.amp' );
for my $tool_dir (@tool_dirs) {
file "$HOME/$tool_dir" => ensure => 'directory', mode => '0750';
- $ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/$tool_dir/commands", "$tool_dir commands" );
- $ensure_symlink->( "$HOME/Notes/Prompts/skills", "$HOME/$tool_dir/skills", "$tool_dir skills" );
+ ensure_symlink( "$HOME/Notes/Prompts/commands", "$HOME/$tool_dir/commands", "$tool_dir commands" );
+ ensure_symlink( "$HOME/Notes/Prompts/skills", "$HOME/$tool_dir/skills", "$tool_dir skills" );
}
# Codex CLI custom slash commands are loaded from ~/.codex/prompts.
file "$HOME/.codex" => ensure => 'directory', mode => '0750';
- $ensure_symlink->( "$HOME/Notes/Prompts/commands", "$HOME/.codex/prompts", ".codex prompts" );
+ ensure_symlink( "$HOME/Notes/Prompts/commands", "$HOME/.codex/prompts", ".codex prompts" );
}
else {
- Rex::Logger::info("Not installing prompt links");
+ Rex::Logger::info("Not installing agent dotfile symlinks");
}
};
@@ -282,6 +259,34 @@ sub isFileSymlink() {
return -l $file && -e $file;
}
+sub ensure_symlink {
+ my ( $source, $target, $label ) = @_;
+
+ if ( -l $target ) {
+ my $existing = readlink $target;
+ if ( defined $existing && $existing eq $source ) {
+ return;
+ }
+ CORE::unlink($target) or die "Could not replace $label symlink at $target: $!";
+ }
+ elsif ( -d $target ) {
+ my ($leaf) = $target =~ m{([^/]+)$};
+ my $nested = "$target/$leaf";
+ if ( -l $nested && readlink($nested) eq $source ) {
+ CORE::unlink($nested) or die "Could not remove nested $label symlink at $nested: $!";
+ rmdir $target or die "Could not remove legacy $label directory at $target: $!";
+ }
+ else {
+ die "Refusing to overwrite existing directory at $target while linking $label";
+ }
+ }
+ elsif ( -e $target ) {
+ die "Refusing to overwrite existing path at $target while linking $label";
+ }
+
+ symlink $source => $target or die "Could not create $label symlink ($source -> $target): $!";
+}
+
desc 'Vale and proselint';
task 'home_vale', sub {
ensure "$DOT/vale.ini" => "$HOME/.vale.ini";