fix(install): per-file backup for shared hooks dir
$HOOKS_DIR ($HOME/.claude/hooks) is shared with other kits. Backing up the whole directory cumulatively bloats foreign hooks across re-runs. Switch to backup_file per KeiSeiKit-owned hook so only the 3 files we actually overwrite get a .bak-TIMESTAMP sibling. backup_dir remains for KeiSeiKit-owned directories (_blocks, _templates, _assembler, skills).
This commit is contained in:
parent
4e9cbb01f1
commit
69b06b8c0e
1 changed files with 16 additions and 1 deletions
17
install.sh
17
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 <file>.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
|
||||
|
|
|
|||
Loading…
Reference in a new issue