#!/usr/bin/env bash # Installs the Claude Code bridge for JoboCop (macOS and Linux). # Usage: ./install.sh [extension-id] # Without an ID it allows both JoboCop IDs: the Chrome Web Store one and the development one # from the manifest "key". Pass an ID only for a build of your own without that key. set -euo pipefail NAME="app.jobocop.bridge" # Earlier versions installed the bridge under these names and folders; we remove them. LEGACY_NAMES=("com.bos.job_application_filler" "com.secretremote.autofill") LEGACY_DIRS=("$HOME/.bos-job-application-filler" "$HOME/.secretremote-autofill") # Keep in step with EXTENSION_IDS in src/ai.js. STORE_ID="" # Chrome Web Store, filled in after the first upload DEV_ID="laiejbgdbcmcannblobjbjjfhgdolnif" # from the "key" in manifest.json if [[ -n "${1:-}" ]]; then IDS=("$1"); else IDS=($STORE_ID $DEV_ID); fi for id in "${IDS[@]}"; do if [[ ! "$id" =~ ^[a-p]{32}$ ]]; then echo "That doesn't look like an extension ID: $id" echo "Copy the 32-letter ID from the extension's AI answers settings." exit 1 fi done ORIGINS=$(printf '"chrome-extension://%s/",' "${IDS[@]}") ORIGINS="[${ORIGINS%,}]" SRC="$(cd "$(dirname "$0")" && pwd)" # The bridge lives outside the extension folder, so moving the extension doesn't break it. DIR="$HOME/.jobocop" NODE="$(command -v node || true)" CLAUDE="$(command -v claude || true)" if [[ -z "$NODE" ]]; then echo "Node.js was not found. Install it from https://nodejs.org, open a new terminal and run this again." exit 1 fi if [[ -z "$CLAUDE" ]]; then echo "Claude Code ('claude') was not found in your PATH. Install Claude Code, run 'claude' once to sign in, then run this again." exit 1 fi mkdir -p "$DIR" # Run from the extension's native-host folder, host.js is next to this script. Run as # `curl -fsSL https://jobocop.app/bridge/install.sh | bash`, it is downloaded from the same place. if [[ -f "$SRC/host.js" ]]; then cp "$SRC/host.js" "$DIR/host.js" else curl -fsSL https://jobocop.app/bridge/host.js -o "$DIR/host.js" fi # Chrome starts the bridge without your shell's PATH, so remember the absolute paths now. cat > "$DIR/run-host.sh" < "$BASE/$b/NativeMessagingHosts/$NAME.json" for old in "${LEGACY_NAMES[@]}"; do rm -f "$BASE/$b/NativeMessagingHosts/$old.json"; done echo "Installed for $b" installed=1 fi done rm -rf "${LEGACY_DIRS[@]}" if [[ $installed -eq 0 ]]; then echo "No Chromium-based browser profile was found under $BASE." exit 1 fi echo echo "Done. Claude Code: $CLAUDE" echo "Go back to the extension and click Test connection." echo "Bridge files: $DIR (run the installer again after updating the extension)"