-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·35 lines (31 loc) · 1.65 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·35 lines (31 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# Install the Codex context-handover hook into ~/.codex/hooks/ and print the config to add.
set -euo pipefail
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
HOOK_DIR="$CODEX_HOME/hooks"
HOOK_PATH="$HOOK_DIR/context-handover.py"
mkdir -p "$HOOK_DIR"
cp "$SRC_DIR/context-handover.py" "$HOOK_PATH"
chmod +x "$HOOK_PATH"
echo "Installed: $HOOK_PATH"
CONFIG="$CODEX_HOME/config.toml"
echo
if grep -q "context-handover.py" "$CONFIG" 2>/dev/null; then
echo "config.toml already references context-handover.py — nothing to add."
else
echo "Add this to $CONFIG (Codex hook commands are NOT shell-expanded, so the absolute path is required):"
cat <<EOF
[hooks]
PreCompact = [{ hooks = [{ type = "command", command = "$HOOK_PATH", async = false, statusMessage = "Writing context handover" }] }]
PostCompact = [{ hooks = [{ type = "command", command = "$HOOK_PATH", async = false, statusMessage = "Refreshing context handover" }] }]
SessionStart = [{ hooks = [{ type = "command", command = "$HOOK_PATH", async = false, statusMessage = "Checking for context handover" }] }]
PreToolUse = [{ hooks = [{ type = "command", command = "$HOOK_PATH", async = false, timeout = 30 }] }]
UserPromptSubmit = [{ hooks = [{ type = "command", command = "$HOOK_PATH", async = false, statusMessage = "Injecting latest context handover" }] }]
EOF
echo
echo "(If you already have a [hooks] table, merge these five keys into it.)"
fi
echo
echo "Codex will prompt you to trust the hooks the first time they fire (Settings -> Hooks)."
echo "Optional: run ./set-auto-compact-limits.py to make Codex auto-compact at ~75% (see README)."