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/sessionstart-init.sh
View on GitHub#!/usr/bin/env bash
# Codex SessionStart hook: lazy-initialize project state when codex enters a
# fresh project (no .codex/tellonce/ dir yet). Idempotent — exits
# fast if state already exists.
#
# - Pass --no-hooks so SessionStart NEVER writes ~/.codex/hooks.json.
# Hooks should only be registered by the bash install.sh phase 2 path
# where the user explicitly opted in.
# - Redirect BOTH stdout and stderr to /dev/null. Codex SessionStart hook
# stdout is the JSON channel; install()'s "added 5 / skipped 0" output
# would be invalid hook JSON and codex would log "invalid session start
# JSON output".
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)"
SKILL_DIR="${SCRIPT_DIR}/.."
PT_STDIN="$(cat)"
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 [[ -z "${CODEX_CWD}" || ! -d "${CODEX_CWD}" ]]; then
exit 0
fi
if [[ -f "${CODEX_CWD}/.codex/tellonce.disabled" ]]; then
exit 0
fi
# Already initialized?
if [[ -f "${CODEX_CWD}/.codex/tellonce/registration.json" ]]; then
exit 0
fi
# Init state. Silence stdout entirely (codex parses it as JSON; we have
# nothing to inject) and silence stderr too (any Python noise must not
# surface to the user during routine SessionStart).
PYTHONIOENCODING=utf-8 PYTHONPATH="${SKILL_DIR}" \
_pt_timeout 10 python3 -m tellonce_codex install --project-root "${CODEX_CWD}" --no-hooks \
> /dev/null 2>/dev/null
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 |