Files
fish-config/functions/save_antigravity_session.fish
T
rootiest 681a48f3c5 feat(deps): catalog python3 as a recommended dependency
python3 is used unguarded by the AI session helpers and (guarded) by the
paru/yay log cleaner, but was absent from the dependency catalog and docs.
uv does not provide python3 on PATH, and Arch's base omits it, so it is
tracked separately rather than assumed via uv.

- Add python3 (recommended tier, pm: python) to _fish_deps_catalog.fish
- Guard python3 calls in save_claude_session/save_antigravity_session with
  `type -q python3`, emitting valid empty JSON when absent (Convention §6)
- Document python3 in docs/fish-config.md (§5.6 tiers + catalog entry)
2026-06-11 23:15:17 -04:00

39 lines
1.2 KiB
Fish
Executable File

#!/usr/bin/env fish
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# 1. Read the JSON from stdin
set -l input (cat)
# 2. Extract session_id using Python
# If python3 is unavailable, emit valid empty JSON and skip session
# tracking rather than erroring (see AGENTS.md Convention §6).
if not type -q python3
echo '{}'
exit 0
end
set -l sid (echo $input | python3 -c "import sys,json; print(json.load(sys.stdin).get('session_id', ''))")
set -l session_file ".antigravity_session"
if test -n "$sid"
# 3. Save the session ID locally
echo "$sid" >$session_file
# 4. Smart .gitignore check
# We only attempt this if we are inside a Git repository
if git rev-parse --is-inside-work-tree >/dev/null 2>&1
# If 'git check-ignore' fails, it means the file is NOT currently ignored
if not git check-ignore -q $session_file
# Append a labeled entry to .gitignore
echo -e "\n# AI Session IDs\n$session_file" >>.gitignore
end
end
# 5. Update universal variable for cross-terminal access
set -U LAST_ANTIGRAVITY_SESSION "$sid"
end
# MANDATORY: Every hook must output valid JSON or an empty object
echo '{}'