Last active
April 27, 2026 13:04
-
-
Save edxeth/39c2d6c9ff7622269080bc13b7ebb7a6 to your computer and use it in GitHub Desktop.
fff-update: convenience wrapper to update TIA's sandboxed FFF extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # fff-update: update TIA's sandboxed FFF pi extension without reinstalling TIA. | |
| # | |
| # Install: | |
| # mkdir -p ~/.local/bin | |
| # curl -fsSL https://gist.githubusercontent.com/edxeth/39c2d6c9ff7622269080bc13b7ebb7a6/raw/fff-update -o ~/.local/bin/fff-update | |
| # chmod +x ~/.local/bin/fff-update | |
| # | |
| # Usage: | |
| # fff-update # update to latest stable FFF | |
| # fff-update nightly # update to latest nightly FFF | |
| # fff-update 0.6.4 # update to an exact FFF version | |
| # | |
| # After updating, restart `tia pi` so pi reloads the extension. | |
| # | |
| # Notes: | |
| # - Updates: ~/.local/share/tia/pi-agent/extensions/fff | |
| # - Preserves: ~/.local/share/tia/pi-agent/fff frecency/history state | |
| # - Honors TIA_ROOT and XDG_DATA_HOME if you use non-default TIA paths | |
| set -euo pipefail | |
| usage() { | |
| sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//' | |
| } | |
| if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then | |
| usage | |
| exit 0 | |
| fi | |
| channel="${1:-}" | |
| need_cmd() { | |
| command -v "$1" >/dev/null 2>&1 || { | |
| printf 'Error: missing required command: %s\n' "$1" >&2 | |
| exit 1 | |
| } | |
| } | |
| need_cmd npm | |
| case "$channel" in | |
| "") | |
| version="$(npm view @ff-labs/pi-fff version)" | |
| ;; | |
| nightly) | |
| version="$(npm view @ff-labs/pi-fff dist-tags.nightly)" | |
| ;; | |
| *) | |
| version="$channel" | |
| ;; | |
| esac | |
| if [[ -z "$version" || "$version" == "undefined" ]]; then | |
| printf 'Error: could not resolve FFF version for %s\n' "$channel" >&2 | |
| exit 1 | |
| fi | |
| TIA_ROOT="${TIA_ROOT:-${XDG_DATA_HOME:-$HOME/.local/share}/tia}" | |
| EXT_DIR="$TIA_ROOT/pi-agent/extensions/fff" | |
| STATE_DIR="$TIA_ROOT/pi-agent/fff" | |
| # Fail before mutating if either package/version does not exist. | |
| npm view "@ff-labs/pi-fff@$version" version >/dev/null | |
| npm view "@ff-labs/fff-node@$version" version >/dev/null | |
| mkdir -p "$EXT_DIR" "$STATE_DIR" | |
| cat > "$EXT_DIR/package.json" <<JSON | |
| { | |
| "type": "module", | |
| "name": "tia-pi-fff-extension", | |
| "private": true, | |
| "dependencies": { | |
| "@ff-labs/pi-fff": "$version", | |
| "@ff-labs/fff-node": "$version" | |
| } | |
| } | |
| JSON | |
| cat > "$EXT_DIR/index.ts" <<'TS' | |
| export { default } from "@ff-labs/pi-fff/src/index.ts"; | |
| TS | |
| rm -rf "$EXT_DIR/node_modules" | |
| rm -f "$EXT_DIR/bun.lock" "$EXT_DIR/package-lock.json" | |
| if command -v bun >/dev/null 2>&1; then | |
| (cd "$EXT_DIR" && bun install --production --omit=peer) | |
| else | |
| (cd "$EXT_DIR" && npm install --omit=dev --legacy-peer-deps) | |
| fi | |
| printf 'FFF updated to %s\n' "$version" | |
| printf 'Extension: %s\n' "$EXT_DIR" | |
| printf 'State: %s\n' "$STATE_DIR" | |
| printf 'Restart tia pi to load it.\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment