Files
MyAiConfiguration/scripts/lib/install-options.sh
T
Julian LechnerandClaude Opus 5.5 79694fbaa2 fix(config): resolve Python reliably, add command-safety hook, harden CI
- Resolve Python 3.11+ through shared Resolve-Python.ps1/resolve-python.sh,
  which probe python, python3 and py -3 and skip the Windows Store alias.
  Build and capability checks fail early with an actionable message; doctor
  reports missing Python and the skipped hooks.
- Fix check-capabilities.sh comparing only the major version.
- Register Validate-CommandSafety as a PreToolUse hook for Claude and Codex;
  shared logic in command-safety.py catches rm -rf variants, git reset --hard,
  git clean -f, Remove-Item -Recurse, del/rd /s /q and nested shells.
- Replace duplicated placeholder chains in both builds with
  adapters/placeholders.tsv.
- Restore shell parity: add test-capabilities.sh, rename credentials.ps1 to
  with-credential.ps1 and qmd-warm.sh to start-qmd-warm.sh.
- CI: build once and pass generated/ as an artifact, lint Python with ruff
  and JavaScript modules with node --check, require SHA pins for all actions.
- Add evals for all own skills and update documentation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 09:34:54 +01:00

62 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# shellcheck source=../../shared/hooks/scripts/resolve-python.sh
. "$(dirname -- "${BASH_SOURCE[0]}")/../../shared/hooks/scripts/resolve-python.sh"
resolve_python || true
# shellcheck disable=SC2154
read_install_boolean() {
local prompt=$1 default=$2 hint=y/N answer
[ "$default" = false ] || hint=Y/n
while :; do
printf '%s [%s] ' "$prompt" "$hint" >&2
IFS= read -r answer || { printf 'Input ended before install options were confirmed.\n' >&2; return 1; }
answer=${answer%$'\r'}
case "$answer" in
'') printf '%s\n' "$default"; return ;;
y|Y|yes|Yes|YES) printf 'true\n'; return ;;
n|N|no|No|NO) printf 'false\n'; return ;;
esac
done
}
read_install_options() {
flashbang=true
statusline=true
semantic_retrieval=false
local saved key value
if [ -f "$home_path/.my-ai-configuration/selection.json" ]; then
if saved=$(run_python "$root/scripts/lib/selection-state.py" read --home "$home_path" --manifest "$root/adapters/plugins.tsv" --format tsv --allow-legacy); then
while IFS=$'\t' read -r key value; do
value=${value%$'\r'}
case "$key" in flashbang) flashbang=$value ;; statusline) statusline=$value ;; semantic_retrieval) semantic_retrieval=$value ;; esac
done <<< "$saved"
else
printf 'WARN Saved options could not be read; confirm new options below.\n' >&2
fi
fi
[ "$dry_run" = false ] || return 0
flashbang=$(read_install_boolean 'Enable the Flashbang notification hook?' "$flashbang") || return
statusline=$(read_install_boolean 'Apply the custom status line?' "$statusline") || return
semantic_retrieval=$(read_semantic_retrieval_option "$semantic_retrieval") || return
}
read_semantic_retrieval_option() {
local default=$1 hint=y/N/a answer
[ "$default" = false ] || hint=Y/n/a
while :; do
printf 'Enable local QMD search models (Qwen3 embedding, Qwen3 reranker, QMD query expansion)? [%s] ' "$hint" >&2
IFS= read -r answer || { printf 'Input ended before semantic retrieval was confirmed.\n' >&2; return 1; }
answer=${answer%$'\r'}
case "$answer" in
'') printf '%s\n' "$default"; return ;;
y|Y|yes|Yes|YES) printf 'true\n'; return ;;
n|N|no|No|NO) printf 'false\n'; return ;;
a|A|auto|Auto|AUTO)
if test_qmd_device "$root" "$home_path"; then printf 'true\n'; return; else status=$?; fi
[ "$status" -eq 1 ] && { printf 'false\n'; return; }
return "$status"
;;
esac
done
}