Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions hooks/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@ if [ -f "$PLUGIN_JSON" ]; then
fi
LOCAL_VERSION="${LOCAL_VERSION:-unknown}"

# Check for latest release on GitHub (non-blocking, 3s timeout)
# Check for latest release on GitHub (non-blocking, 3s timeout, cached 24h)
REPO="Ibrahim-3d/orchestrator-supaconductor"
CACHE_DIR="${HOME}/.cache/supaconductor"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to respect the XDG_CACHE_HOME environment variable if it is set, falling back to ~/.cache otherwise. This adheres better to the XDG Base Directory Specification followed by many Linux distributions and CLI tools.

Suggested change
CACHE_DIR="${HOME}/.cache/supaconductor"
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/supaconductor"

CACHE_FILE="${CACHE_DIR}/last-update-check"
update_message=""
if command -v curl &>/dev/null; then
latest_tag=$(curl -s --max-time 3 \
"https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \
| sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \
| sed 's/^v//' | head -1) || true
latest_tag=""
# Skip network call if cache is less than 24 hours old
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 -quiet 2>/dev/null | grep -q .; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The -quiet flag is not a standard option for the find command in most common implementations (GNU, BSD/macOS, etc.). Including it will cause the find command to fail with an error. Due to pipefail being set at the top of the script, the entire condition will evaluate to false, meaning the cache will never be used and the script will perform a network request on every session start, defeating the purpose of this change.

Suggested change
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 -quiet 2>/dev/null | grep -q .; then
if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 2>/dev/null | grep -q .; then

latest_tag=$(cat "$CACHE_FILE")
else
latest_tag=$(curl -s --max-time 3 \
"https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \
| sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \
| sed 's/^v//' | head -1) || true
if [ -n "$latest_tag" ]; then
mkdir -p "$CACHE_DIR"
printf '%s' "$latest_tag" > "$CACHE_FILE"
fi
fi

if [ -n "$latest_tag" ] && [ "$latest_tag" != "$LOCAL_VERSION" ]; then
update_message="\\n\\n**UPDATE AVAILABLE:** SupaConductor v${latest_tag} is available (you have v${LOCAL_VERSION}). Tell the user: A new version of SupaConductor is available (v${latest_tag}). Update with: claude plugin update orchestrator-supaconductor"
Expand Down