Files
yvgude--lean-ctx/packages/chrome-lean-ctx/native-host/install.sh
T
wehub-resource-sync 26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

76 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
EXTENSION_ID="${1:-}"
if [[ -z "$EXTENSION_ID" ]]; then
echo "Usage: ./install.sh <chrome-extension-id>"
echo ""
echo "The extension ID is shown in the lean-ctx popup or at chrome://extensions"
exit 1
fi
LEAN_CTX=$(command -v lean-ctx 2>/dev/null || echo "$HOME/.cargo/bin/lean-ctx")
if [[ ! -x "$LEAN_CTX" ]]; then
echo "Error: lean-ctx not found in PATH or ~/.cargo/bin/"
echo "Install: cargo install lean-ctx"
exit 1
fi
HOST_NAME="com.leanctx.bridge"
case "$(uname)" in
Darwin)
TARGET_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
;;
Linux)
TARGET_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
;;
*)
echo "Unsupported platform: $(uname)"
exit 1
;;
esac
mkdir -p "$TARGET_DIR"
INSTALL_DIR="$HOME/.lean-ctx/chrome-bridge"
mkdir -p "$INSTALL_DIR"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cp "$SCRIPT_DIR/bridge.py" "$INSTALL_DIR/bridge.py"
chmod +x "$INSTALL_DIR/bridge.py"
PYTHON="/usr/bin/python3"
if [[ ! -x "$PYTHON" ]]; then
PYTHON="$(command -v python3 2>/dev/null || true)"
fi
if [[ -z "$PYTHON" ]]; then
echo "Error: python3 not found"
exit 1
fi
cat > "$INSTALL_DIR/bridge.sh" <<BRIDGE
#!/bin/bash
exec "$PYTHON" -u "$INSTALL_DIR/bridge.py" 2>>"\$HOME/.lean-ctx/bridge-stderr.log"
BRIDGE
chmod +x "$INSTALL_DIR/bridge.sh"
cat > "$TARGET_DIR/$HOST_NAME.json" <<MANIFEST
{
"name": "$HOST_NAME",
"description": "lean-ctx native messaging bridge for Chrome",
"path": "$INSTALL_DIR/bridge.sh",
"type": "stdio",
"allowed_origins": [
"chrome-extension://$EXTENSION_ID/"
]
}
MANIFEST
echo "Native messaging host installed successfully."
echo " Manifest: $TARGET_DIR/$HOST_NAME.json"
echo " Bridge: $INSTALL_DIR/bridge.sh"
echo " Python: $PYTHON"
echo ""
echo "Restart Chrome completely (Cmd+Q) to activate."