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.
hooks/userpromptsubmit-pending-inject.sh
View on GitHub#!/usr/bin/env bash
# Codex UserPromptSubmit hook: cross-session pending memory reminders.
# Mirrors CC's memory-pending-inject.sh.
#
# pending_queue_manager.py emits raw text (legacy CC contract); we wrap it in
# the codex hookSpecificOutput JSON envelope (UserPromptSubmitHookSpecificOutputWire
# requires hookEventName + additionalContext, additionalProperties: false).
set +e
# Portable timeout: GNU `timeout` is absent on stock macOS. Fall back to
# gtimeout (brew coreutils) or, failing that, run without a timeout.
_pt_timeout() {
_pt_secs="$1"; shift
if command -v timeout >/dev/null 2>&1; then timeout "${_pt_secs}" "$@"
elif command -v gtimeout >/dev/null 2>&1; then gtimeout "${_pt_secs}" "$@"
else "$@"; fi
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SHARED_LIB="${SCRIPT_DIR}/../shared_lib"
if [[ ! -f "${SHARED_LIB}/pending_queue_manager.py" ]]; then
exit 0
fi
PT_STDIN="$(cat)"
[[ -z "${PT_STDIN}" ]] && exit 0
CODEX_CWD="$(echo "${PT_STDIN}" | PYTHONIOENCODING=utf-8 python3 -c '
import json, sys
try:
d = json.load(sys.stdin)
print(d.get("cwd") or "")
except Exception:
print("")
' 2>/dev/null)"
if [[ -n "${CODEX_CWD}" && -d "${CODEX_CWD}" ]]; then
export B5_PROJECT_ROOT="${CODEX_CWD}"
fi
# Same shared memory-dir bridge as userpromptsubmit-retrieve-inject.sh.
if [[ -z "${B5_MEMORY_DIR:-}" && -n "${B5_PROJECT_ROOT:-}" ]]; then
export B5_MEMORY_DIR="${B5_PROJECT_ROOT}/.tellonce/memory"
fi
PT_TEXT="$(PYTHONIOENCODING=utf-8 PYTHONPATH="${SHARED_LIB}" \
_pt_timeout 15 python3 "${SHARED_LIB}/pending_queue_manager.py" inject 2>/dev/null)"
if [ -n "${PT_TEXT}" ]; then
PT_TEXT="${PT_TEXT}" PYTHONIOENCODING=utf-8 python3 -c '
import json, os
text = os.environ.get("PT_TEXT","")
header = "### Pending memory finalize required (carried over from prior session):"
body = header + "\n" + text
print(json.dumps({
"hookSpecificOutput": {
"hookEventName": "UserPromptSubmit",
"additionalContext": body,
}
}, ensure_ascii=False))
' 2>/dev/null
fi
exit 0
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 |