diff --git a/install.sh b/install.sh index fa51d55..05dde0c 100755 --- a/install.sh +++ b/install.sh @@ -92,6 +92,18 @@ backup_dir() { say "backed up existing $target to $backup" } +# Per-file backup for shared directories like $HOOKS_DIR, where other kits +# may drop sibling files we must not touch. Only the specific file is moved +# aside to .bak-TIMESTAMP. +backup_file() { + local target="$1" + [ -f "$target" ] || return 0 + local backup="${target}.bak-$(date +%s)" + mv "$target" "$backup" + BACKUP_PAIRS+=("$target|$backup") + say "backed up existing $target to $backup" +} + # Activate KeiSeiKit hooks by merging settings-snippet.json into the user's # settings.json. Idempotent: # - If settings.json is absent, copy snippet verbatim (minus _comment key). @@ -230,9 +242,12 @@ if [[ -f "$KIT_DIR/_assembler/.gitignore" ]]; then fi # --- copy hooks (refresh; hooks are logic, not config) --------------------- +# $HOOKS_DIR is shared with other kits — back up each KeiSeiKit-owned hook +# individually rather than the whole directory, so foreign hooks are not +# dragged into .bak-TIMESTAMP snapshots on every re-run. say "copying hooks -> $HOOKS_DIR/" -backup_dir "$HOOKS_DIR" for h in assemble-agents.sh assemble-validate.sh no-hand-edit-agents.sh; do + backup_file "$HOOKS_DIR/$h" cp -f "$KIT_DIR/hooks/$h" "$HOOKS_DIR/$h" chmod +x "$HOOKS_DIR/$h" done