feat: enable-all command (symmetric to disable-all)

Bulk-enable every parked skill into selected target(s). Idempotent —
skips already-active. Useful as a 'restore-from-archive' helper after
disable-all or filesystem mishap.

usage: opc-skills enable-all [--target T] [-y|--yes]
This commit is contained in:
salva
2026-05-01 00:23:19 +03:00
parent a6e9fedf72
commit f53f9320a8

View File

@@ -395,6 +395,56 @@ cmd_disable_all() {
echo "done."
}
# enable every parked skill into selected target(s) — symmetric to disable-all
# usage: cmd_enable_all [--target T] [-y|--yes]
# Idempotent: skips skills already active in a target.
cmd_enable_all() {
parse_target_flag "$@"
set -- "${REMAINING_ARGS[@]}"
require_dirs
local force=0
if [ "${1:-}" = "-y" ] || [ "${1:-}" = "--yes" ]; then
force=1
fi
IFS=',' read -ra tgts <<< "$PARSED_TARGETS"
# For each target, list parked skills NOT already active there
local -A pending=()
local -a parked_list
mapfile -t parked_list < <(skill_dirs_in "$PARKED")
local total=0 t
for t in "${tgts[@]}"; do
local base; base=$(target_dir "$t")
local n
for n in "${parked_list[@]}"; do
[ -z "$n" ] && continue
if [ ! -d "$base/$n" ]; then
pending["$t:$n"]=1
total=$((total+1))
fi
done
done
[ "$total" -gt 0 ] || { echo "all parked skills already active in [${tgts[*]}]"; exit 0; }
echo "Will enable $total (target:skill) entries from parked → active in [${tgts[*]}]:"
echo "(${#parked_list[@]} parked × ${#tgts[@]} targets, minus already-active)"
if [ "$force" -ne 1 ]; then
printf "Proceed? [y/N] "
read -r ans </dev/tty || ans=""
case "$ans" in y|Y|yes|YES) ;; *) echo "cancelled"; exit 0 ;; esac
fi
local key tn
local enabled=0
for key in "${!pending[@]}"; do
t="${key%%:*}"; tn="${key#*:}"
base=$(target_dir "$t")
if [ ! -d "$PARKED/$tn" ] || [ -d "$base/$tn" ]; then continue; fi
cp -r "$PARKED/$tn" "$base/$tn"
update_index_active_set "$tn" "$t" "add"
enabled=$((enabled+1))
done
sync_shared_refs_to_targets
echo "enabled $enabled skill(s)."
}
# batch disable by prefix/category — fzf multi-pick within ACTIVE
cmd_disable_category() {
require_dirs
@@ -714,7 +764,7 @@ usage() {
opc-skills — multi-target skill manager (opencode + claude)
Targets: opencode, claude (or "both"/"all"; default = opencode,claude)
Use --target X / --target=X / -t X with enable/disable/disable-all to scope ops.
Use --target X / --target=X / -t X with enable/disable/enable-all/disable-all to scope ops.
Inspection:
status per-target counts + parked
@@ -727,6 +777,8 @@ Inspection:
Single skill:
enable [--target T] <folder> copy parked → active in selected targets
disable [--target T] <folder> remove from active in selected targets (parked kept)
enable-all [--target T] [-y|--yes] enable every parked skill into selected targets
(idempotent — skips already-active; useful as restore-from-archive)
disable-all [--target T] [-y|--yes] disable every active skill across targets
Bulk by axis (default: opencode+claude):
@@ -775,6 +827,7 @@ main() {
tags) cmd_tags "$@" ;;
enable) cmd_enable "$@" ;;
disable) cmd_disable "$@" ;;
enable-all) cmd_enable_all "$@" ;;
disable-all) cmd_disable_all "$@" ;;
enable-category|enable-cat) cmd_enable_category "$@" ;;
disable-category|disable-cat) cmd_disable_category "$@" ;;