From 112d43a4c3d5c723c62a7393b19490a88c527e75 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 3 Jan 2026 12:16:01 -0800 Subject: [PATCH] refactor(deploy): move functions to top of file (code-review) --- bin/deploy-skill.sh | 144 ++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/bin/deploy-skill.sh b/bin/deploy-skill.sh index 8fdd134..5ac7a22 100755 --- a/bin/deploy-skill.sh +++ b/bin/deploy-skill.sh @@ -37,77 +37,6 @@ EOF exit 1 } -if [[ -z "$SKILL_NAME" ]]; then - usage -fi - -SKILL_SOURCE="$SKILLS_REPO/skills/$SKILL_NAME" -SKILL_DEST="$DOTFILES_REPO/claude/skills/$SKILL_NAME" - -# Validate skill exists -if [[ ! -d "$SKILL_SOURCE" ]]; then - echo "Error: Skill not found: $SKILL_SOURCE" >&2 - echo "" >&2 - usage -fi - -# Validate dotfiles repo exists -if [[ ! -d "$DOTFILES_REPO" ]]; then - echo "Error: Dotfiles repo not found: $DOTFILES_REPO" >&2 - exit 1 -fi - -# Check if skill has SKILL.md -if [[ ! -f "$SKILL_SOURCE/SKILL.md" ]]; then - echo "Error: $SKILL_NAME missing SKILL.md" >&2 - exit 1 -fi - -# Check if already deployed -if [[ -d "$SKILL_DEST" ]]; then - echo "⚠️ Skill already deployed: $SKILL_DEST" - read -p "Overwrite? [y/N] " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Cancelled" - exit 1 - fi - rm -rf "$SKILL_DEST" -fi - -# Check for security docs -SECURITY_WARNING="" -if [[ -f "$SKILL_SOURCE/SECURITY.md" ]]; then - SECURITY_WARNING=" -⚠️ ⚠️ ⚠️ SECURITY WARNING ⚠️ ⚠️ ⚠️ - -This skill has security documentation. -READ BEFORE DEPLOYING: $SKILL_DEST/SECURITY.md - -Security-sensitive skills should only be deployed after: -1. Reviewing security documentation -2. Understanding risks and mitigations -3. Configuring protection mechanisms -" -fi - -echo "Deploying skill: $SKILL_NAME" -echo "" -echo "Source: $SKILL_SOURCE" -echo "Dest: $SKILL_DEST" -echo "" - -# Copy skill -mkdir -p "$(dirname "$SKILL_DEST")" -cp -r "$SKILL_SOURCE" "$SKILL_DEST" - -echo "✓ Skill copied to dotfiles" -echo "" - -if [[ -n "$SECURITY_WARNING" ]]; then - echo "$SECURITY_WARNING" -fi - # Function to inject config into Nix file inject_nix_config() { local target_file="$1" @@ -184,6 +113,77 @@ inject_home_file() { inject_nix_config "$target_file" "$config_block" "$home_path" } +if [[ -z "$SKILL_NAME" ]]; then + usage +fi + +SKILL_SOURCE="$SKILLS_REPO/skills/$SKILL_NAME" +SKILL_DEST="$DOTFILES_REPO/claude/skills/$SKILL_NAME" + +# Validate skill exists +if [[ ! -d "$SKILL_SOURCE" ]]; then + echo "Error: Skill not found: $SKILL_SOURCE" >&2 + echo "" >&2 + usage +fi + +# Validate dotfiles repo exists +if [[ ! -d "$DOTFILES_REPO" ]]; then + echo "Error: Dotfiles repo not found: $DOTFILES_REPO" >&2 + exit 1 +fi + +# Check if skill has SKILL.md +if [[ ! -f "$SKILL_SOURCE/SKILL.md" ]]; then + echo "Error: $SKILL_NAME missing SKILL.md" >&2 + exit 1 +fi + +# Check if already deployed +if [[ -d "$SKILL_DEST" ]]; then + echo "⚠️ Skill already deployed: $SKILL_DEST" + read -p "Overwrite? [y/N] " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Cancelled" + exit 1 + fi + rm -rf "$SKILL_DEST" +fi + +# Check for security docs +SECURITY_WARNING="" +if [[ -f "$SKILL_SOURCE/SECURITY.md" ]]; then + SECURITY_WARNING=" +⚠️ ⚠️ ⚠️ SECURITY WARNING ⚠️ ⚠️ ⚠️ + +This skill has security documentation. +READ BEFORE DEPLOYING: $SKILL_DEST/SECURITY.md + +Security-sensitive skills should only be deployed after: +1. Reviewing security documentation +2. Understanding risks and mitigations +3. Configuring protection mechanisms +" +fi + +echo "Deploying skill: $SKILL_NAME" +echo "" +echo "Source: $SKILL_SOURCE" +echo "Dest: $SKILL_DEST" +echo "" + +# Copy skill +mkdir -p "$(dirname "$SKILL_DEST")" +cp -r "$SKILL_SOURCE" "$SKILL_DEST" + +echo "✓ Skill copied to dotfiles" +echo "" + +if [[ -n "$SECURITY_WARNING" ]]; then + echo "$SECURITY_WARNING" +fi + echo "Configuring system..." echo "" @@ -233,4 +233,4 @@ echo "" echo " cd $DOTFILES_REPO" echo " sudo nixos-rebuild switch --flake .#delpad" echo "" -echo "Then restart your agents." +echo "Then restart your agents." \ No newline at end of file