Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(wrapper): keep the host token copy when an interactive uninstall is declined

AkitaOnRails96346d9c2196
diff --git a/bin/ai-memory b/bin/ai-memory
index bbdc39a7..ac5a3de6 100755
--- a/bin/ai-memory
+++ b/bin/ai-memory
@@ -832,18 +832,24 @@ case "${WRAPPER_SUBCOMMAND}" in
esac
# A full `uninstall --apply` unwires every hook and MCP entry that reads the
# host copy of the volume's root bearer, so the copy goes too once the
-# container reports success. A dry run or an `--only` subset keeps it.
+# container reports success. A dry run or an `--only` subset keeps it, and so
+# does an interactive run without `--yes`: uninstall then asks for
+# confirmation, and declining prints "aborted." and still exits 0, with
+# nothing removed.
DROPS_VOLUME_TOKEN=0
if [ "${WRAPPER_SUBCOMMAND}" = "uninstall" ]; then
uninstall_apply=0
uninstall_only=0
+ uninstall_yes=0
for arg in ${WRAPPER_ARGS[@]+"${WRAPPER_ARGS[@]:$((idx + 1))}"}; do
case "${arg}" in
--apply) uninstall_apply=1 ;;
--only | --only=*) uninstall_only=1 ;;
+ --yes) uninstall_yes=1 ;;
esac
done
- if [ "${uninstall_apply}" -eq 1 ] && [ "${uninstall_only}" -eq 0 ]; then
+ if [ "${uninstall_apply}" -eq 1 ] && [ "${uninstall_only}" -eq 0 ] \
+ && { [ "${uninstall_yes}" -eq 1 ] || [ ! -t 0 ]; }; then
DROPS_VOLUME_TOKEN=1
fi
fi
diff --git a/scripts/check-native-packaging.sh b/scripts/check-native-packaging.sh
index 7fcb29b3..c1b69543 100755
--- a/scripts/check-native-packaging.sh
+++ b/scripts/check-native-packaging.sh
@@ -313,6 +313,18 @@ FAKE
fail "a failing uninstall must keep its exit status"
fi
test -s "${token_copy}" || fail "a failed uninstall must keep the host token copy"
+ # On a terminal without --yes, uninstall asks first, and a declined prompt
+ # still exits 0 with nothing removed, so the copy must stay. `script` gives
+ # the wrapper a pseudo-terminal on stdin (util-linux syntax; skipped where
+ # it is missing).
+ if script -qec true /dev/null >/dev/null 2>&1; then
+ script -qec "env HOME='${token_home}' XDG_DATA_HOME='${token_home}/.local/share' \
+ AI_MEMORY_NO_VERSION_CHECK=1 AI_MEMORY_NO_TTY=1 \
+ AI_MEMORY_DOCKER='${token_docker}' AI_MEMORY_NATIVE_BIN='${token_native}' \
+ AI_MEMORY_DOCKER_TEST_LOG='${token_docker_log}' AI_MEMORY_WRAPPER_TEST_LOG='${token_log}' \
+ bin/ai-memory uninstall --apply" /dev/null </dev/null >/dev/null 2>&1 || true
+ test -s "${token_copy}" || fail "an interactive uninstall without --yes must keep the host token copy"
+ fi
token_wrapper uninstall --apply --yes
test ! -e "${token_copy}" || fail "uninstall --apply must remove the host token copy"