Files
MyAiConfiguration/scripts/tests/test-plugin-selection.sh
T
Julian LechnerandClaude Opus 5.5 b35e2254b3 feat(extensions): add Roast Room, bring Codex to parity, fix audit findings
Roast Room is installed as a managed Git clone under
~/.my-ai-configuration/roast-room, shared by Claude and Codex. A personal
launcher skill runs it from any folder, starts its live room when needed,
and only runs when invoked by name (/roast-room, $roast-room).

Codex now gets what was Claude-only before: the Caveman skill with a
SessionStart hook that keeps it on, PreCompact and session-pointer hooks,
execpolicy deny rules mirroring Claude's permissions.deny, and Impeccable's
custom agents registered in ~/.codex/agents. The command-safety hook checks
both shell dialects for Codex on Windows, where PowerShell text arrives as
Bash, in both the PowerShell and Bash packages.

Audit fixes:
- command-safety blocks git checkout -- / restore / push --force /
  stash clear and find -delete, and treats heredoc bodies as text
- removing a clone clears read-only Git files, git errors no longer abort
  the extension sync, and a lock left by a dead process is replaced
- with-credential passes child flags such as -k or -d through unchanged
  and resolves commands from PATH
- uninstall strips only owned hooks from settings.json and config.toml and
  keeps the selection while another client is installed; update keeps
  CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY; Bash merges write the same bytes as
  PowerShell
- qmd no longer trusts a stale daemon.json after a lost start race and
  prunes collections of deleted repositories
- Bash scripts avoid GNU-only find -printf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 09:02:47 +01:00

76 lines
3.8 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
summary=false
while [ $# -gt 0 ]; do
case "$1" in
--summary) summary=true; shift ;;
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;;
esac
done
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
. "$root/scripts/lib/plugins.sh"
# shellcheck disable=SC2034
names=(A B C)
checked=(true false true)
toggle_log=$(mktemp "$root/.plugin-toggle.XXXXXX")
test_home=$(mktemp -d "$root/.context7-test.XXXXXX")
trap 'rm -f -- "$toggle_log" "$test_home/.mcporter/mcporter.json"; rmdir -- "$test_home/.mcporter" "$test_home" 2>/dev/null || true' EXIT
read_plugin_toggle_selection names checked <<< $'1\n2\ndone' > "$toggle_log"
[ "$summary" = true ] || cat "$toggle_log"
[ "${checked[0]}" = false ] || { printf 'Toggling checked entry 1 must uncheck it.\n' >&2; exit 1; }
[ "${checked[1]}" = true ] || { printf 'Toggling unchecked entry 2 must check it.\n' >&2; exit 1; }
[ "${checked[2]}" = true ] || { printf 'Entry 3 was never toggled and must stay unchanged.\n' >&2; exit 1; }
read_plugin_toggle_selection names checked <<< '' > "$toggle_log"
[ "${checked[0]}" = false ] && [ "${checked[1]}" = true ]
test_plugin_output() {
printf 'download progress\nWARN test warning\n'
[ "$1" != fail ]
}
compact=$(summary=true run_plugin_command false test_plugin_output success)
[ "$compact" = 'WARN test warning' ] || { printf 'Plugin summary lost warnings or leaked progress.\n' >&2; exit 1; }
if diagnostics=$(summary=true run_plugin_command false test_plugin_output fail 2>&1); then
printf 'Plugin failure must fail.\n' >&2
exit 1
fi
[[ "$diagnostics" == *'download progress'* ]] && [[ "$diagnostics" == *'WARN test warning'* ]]
mkdir -p "$test_home/.mcporter"
printf '%s\n' '{"mcpServers":{"context7":{"baseUrl":"https://mcp.context7.com/mcp"}}}' > "$test_home/.mcporter/mcporter.json"
home_path=$test_home
plugin_installed() { return 1; }
selected=()
deselected=()
select_configured_plugins "$root" codex Update true selected deselected
[[ " ${selected[*]} " == *' Context7 '* ]] || { printf 'MCPorter Context7 must start checked when updating.\n' >&2; exit 1; }
printf '%s\n' '{"mcpServers":{"context7":{"baseUrl":"https://example.invalid/mcp"}}}' > "$test_home/.mcporter/mcporter.json"
select_configured_plugins "$root" codex Update true selected deselected
[[ " ${deselected[*]} " == *' Context7 '* ]] || { printf 'A different MCPorter server must not select Context7.\n' >&2; exit 1; }
for name in Caveman 'Roast Room'; do
[[ " ${selected[*]} ${deselected[*]} " == *" $name "* ]] || { printf '%s must be offered for Codex too.\n' "$name" >&2; exit 1; }
done
npm_prefix=$(mktemp -d "$root/.npm-test.XXXXXX")
cli_name="ai-config-test-cli-${npm_prefix##*.}"
npm() { printf '%s\n' "$npm_prefix"; }
if cli_installed "$cli_name"; then rm -rf -- "$npm_prefix"; printf 'A missing CLI must not be detected.\n' >&2; exit 1; fi
mkdir -p "$npm_prefix/bin"
touch "$npm_prefix/$cli_name.cmd" "$npm_prefix/bin/$cli_name"
chmod +x "$npm_prefix/bin/$cli_name"
if ! cli_installed "$cli_name"; then rm -rf -- "$npm_prefix"; printf 'A CLI in the npm global prefix must be detected when it is not on PATH.\n' >&2; exit 1; fi
rm -rf -- "$npm_prefix"
unset -f npm
# shellcheck disable=SC2034
selected=()
plugin_installed() { printf 'Empty selection must not query installed plugins.\n' >&2; exit 1; }
run_plugin_command() { printf 'Empty selection must not run commands.\n' >&2; exit 1; }
install_configured_plugins "$root" both false false selected false
uninstall_deselected_plugins "$root" both false selected false
if read_plugin_toggle_selection names checked </dev/null > "$toggle_log" 2>&1; then
printf 'Closed input must fail instead of looping.\n' >&2
exit 1
fi
if [ "$summary" = true ]; then printf 'Tests: PASS | plugin selection\n'; else printf 'PASS plugin toggle selection: toggle and confirm\n'; fi