refactor(deploy): move functions to top of file (code-review)
This commit is contained in:
parent
f00c0e7e20
commit
112d43a4c3
|
|
@ -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."
|
||||
Loading…
Reference in a new issue