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

Bulk-enable every parked agent into selected target(s) from THAT
target's parked source (format-aware). Idempotent — skips already-active.

usage: opc-agents enable-all [--target T] [-y|--yes]
This commit is contained in:
salva
2026-05-01 00:23:21 +03:00
parent 72f02387eb
commit 7587c02a9f

View File

@@ -328,6 +328,51 @@ cmd_disable_all() {
done
}
# enable every parked agent into selected target(s) — symmetric to disable-all
# usage: cmd_enable_all [--target T] [-y|--yes]
# Per-target: only reads from THAT target's parked source (format-aware).
# Idempotent: skips agents already active.
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"
local -a pairs=()
local t pdir adir n
for t in "${tgts[@]}"; do
pdir=$(target_parked "$t") || continue
adir=$(target_active "$t") || continue
while IFS= read -r n; do
[ -z "$n" ] && continue
[ -f "$adir/$n.md" ] && continue # already active
pairs+=("$t:$n")
done < <(agent_names_in "$pdir")
done
[ "${#pairs[@]}" -gt 0 ] || { echo "all parked agents already active in [${tgts[*]}]"; exit 0; }
echo "Will enable ${#pairs[@]} (target:agent) entries:"
printf ' %s\n' "${pairs[@]:0:20}"
[ "${#pairs[@]}" -gt 20 ] && echo " ... and $((${#pairs[@]} - 20)) more"
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 p enabled=0
for p in "${pairs[@]}"; do
t="${p%%:*}"; n="${p#*:}"
pdir=$(target_parked "$t"); adir=$(target_active "$t")
[ -f "$pdir/$n.md" ] || continue
[ -f "$adir/$n.md" ] && continue
cp "$pdir/$n.md" "$adir/$n.md"
enabled=$((enabled+1))
done
echo "enabled $enabled agent(s)."
}
# enable category (by prefix)
cmd_enable_category() {
require_dirs
@@ -633,7 +678,7 @@ usage() {
opc-agents — multi-target agent manager (opencode + claude)
Targets: opencode, claude (or "both"/"all"; default = opencode,claude)
Use --target / -t with enable/disable/disable-all to scope the operation.
Use --target / -t with enable/disable/enable-all/disable-all to scope the operation.
status per-target counts (parked + active) + mode breakdown
list {active|parked|all} list agent names (active = opencode set)
@@ -641,6 +686,8 @@ Use --target / -t with enable/disable/disable-all to scope the operation.
variants suffix-based variant counts (PARKED opencode)
enable [--target T] <name> copy parked → active in selected targets
disable [--target T] <name> remove from active in selected targets
enable-all [--target T] [-y|--yes] enable every parked agent into selected targets
(idempotent — restore-from-archive helper)
disable-all [--target T] [-y|--yes] [--keep-primary]
disable every active agent across targets
enable-category <prefix> fzf multi-pick within a base-persona prefix, then enable
@@ -682,6 +729,7 @@ main() {
variants|vars) cmd_variants "$@" ;;
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 "$@" ;;