YujunZhou/tellonce / codex
tellonce
VerifiedUse to view, explain, correct, delete or reorganize the user's saved preferences, or to record one by hand when automatic recording is off; learning and rule injection otherwise run automatically through Codex hooks.
uninstall.sh
View on GitHub#!/usr/bin/env bash
# Codex tellonce uninstall.
# - Removes per-project state marker (managed_runtime.txt) — keeps logs/state
# by default; `--purge-state` wipes the project's tellonce state.
# - Optionally removes hook registrations from ~/.codex/hooks.json
# (--purge-hooks). Default: keep registered, just disable per project.
# - Optionally removes global skill dir from ~/.codex/skills/tellonce/
# (--purge-skill). Default: leave global runtime so other projects can use it.
set -euo pipefail
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SKILL_DIR}/.." && pwd)"
PYTHON="${PYTHON:-python3}"
GLOBAL_DIR="${HOME}/.codex/skills/tellonce"
HOOKS_JSON="${HOME}/.codex/hooks.json"
# Match install.sh's clone detection (both conditions): when the user's
# clone/checkout occupies the default path, the generated runtime lives in
# the sibling -runtime dir. Never rm -rf the user's source tree via
# --purge-skill.
if [[ -d "${GLOBAL_DIR}" ]]; then
GLOBAL_DIR_REAL_PRE="$(cd "${GLOBAL_DIR}" && pwd -P)"
REPO_ROOT_REAL="$(cd "${REPO_ROOT}" && pwd -P)"
if [[ "${GLOBAL_DIR_REAL_PRE}" == "${REPO_ROOT_REAL}" || -e "${GLOBAL_DIR}/.git" ]]; then
GLOBAL_DIR="${HOME}/.codex/skills/tellonce-runtime"
fi
fi
# Resolve where tellonce_codex module lives — prefer global install (most
# common), fall back to repo-local source layout (development).
if [[ -d "${GLOBAL_DIR}/tellonce_codex" ]]; then
PYTHON_PATH_ROOT="${GLOBAL_DIR}"
elif [[ -d "${SKILL_DIR}/tellonce_codex" ]]; then
PYTHON_PATH_ROOT="${SKILL_DIR}"
else
PYTHON_PATH_ROOT="${REPO_ROOT}/codex"
fi
PURGE_STATE=false
PURGE_HOOKS=false
PURGE_SKILL=false
PASSTHRU=()
while [[ $# -gt 0 ]]; do
case "$1" in
--purge-state) PURGE_STATE=true; PASSTHRU+=("$1"); shift ;;
--purge-hooks) PURGE_HOOKS=true; shift ;;
--purge-skill) PURGE_SKILL=true; shift ;;
*) PASSTHRU+=("$1"); shift ;;
esac
done
# --purge-skill implies --purge-hooks: deleting the runtime while keeping the
# hooks.json registrations would leave every Codex event firing 5 missing
# commands.
if [[ "${PURGE_SKILL}" == true && "${PURGE_HOOKS}" != true ]]; then
echo "(--purge-skill implies --purge-hooks: registrations must not outlive the scripts they point to)"
PURGE_HOOKS=true
fi
# 1. Project-level uninstall via tellonce_codex. Cleanup requested for global
# hooks/runtime must still run if project state is corrupt, but the final exit
# code must report the failure.
PROJECT_RC=0
PYTHONPATH="${PYTHON_PATH_ROOT}" "${PYTHON}" -m tellonce_codex uninstall \
${PASSTHRU[@]+"${PASSTHRU[@]}"} || PROJECT_RC=$?
if [[ "${PROJECT_RC}" -ne 0 ]]; then
echo "⚠ project-level uninstall failed (rc=${PROJECT_RC}); continuing with requested global cleanup" >&2
fi
# 2. Optionally drop hook registrations from ~/.codex/hooks.json
HOOK_RC=0
if [[ "${PURGE_HOOKS}" == true ]]; then
if [[ -f "${HOOKS_JSON}" ]]; then
echo "Removing Tellonce hook registrations from ${HOOKS_JSON}"
PYTHONPATH="${PYTHON_PATH_ROOT}" "${PYTHON}" -m tellonce_codex.install_codex_hooks \
--hooks-json "${HOOKS_JSON}" \
--remove || HOOK_RC=$?
fi
else
echo "(skipping hook registration removal — pass --purge-hooks to drop ~/.codex/hooks.json entries)"
fi
# 3. Optionally remove global skill dir + shell wrapper
if [[ "${PURGE_SKILL}" == true && "${HOOK_RC}" -eq 0 ]]; then
if [[ -d "${GLOBAL_DIR}" ]]; then
RESOLVED_GLOBAL="$(cd "${GLOBAL_DIR}" && pwd -P)"
if [[ "${RESOLVED_GLOBAL}" == "/" ]] || [[ "${RESOLVED_GLOBAL}" == "${HOME}" ]]; then
echo "❌ refusing to remove suspicious skill dir: ${RESOLVED_GLOBAL}"
exit 1
fi
if [[ "${PURGE_SKILL}" == true && "${HOOK_RC}" -ne 0 ]]; then
echo "⚠ preserving ${GLOBAL_DIR} because hook registration removal failed" >&2
fi
echo "Removing global skill dir ${GLOBAL_DIR}"
rm -rf "${GLOBAL_DIR}"
fi
# Also remove the shell wrapper installed at ~/.local/bin/tellonce_codex
WRAPPER="${HOME}/.local/bin/tellonce_codex"
if [[ -f "${WRAPPER}" ]]; then
# Defensive: only delete if the file looks like ours
if grep -q "tellonce_codex — shell wrapper installed by codex/install.sh" "${WRAPPER}" 2>/dev/null; then
rm -f "${WRAPPER}"
echo "Removing shell wrapper ${WRAPPER}"
fi
fi
fi
echo ""
if [[ "${PROJECT_RC}" -ne 0 || "${HOOK_RC}" -ne 0 ]]; then
echo "⚠ codex tellonce cleanup completed with errors" >&2
[[ "${PROJECT_RC}" -ne 0 ]] && exit "${PROJECT_RC}"
exit "${HOOK_RC}"
fi
echo "✓ codex tellonce uninstall complete"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |