summaryrefslogtreecommitdiff
path: root/scripts/setup.sh
diff options
context:
space:
mode:
authorChristopher Warner <cwarner@kernelcode.com>2026-10-10 18:47:24 -0400
committerChristopher Warner <cwarner@kernelcode.com>2026-10-10 18:47:24 -0400
commit5c61196f27b9342e5f25414c11df5710f956f406 (patch)
treec81f15f54c9baa35f61ce3c71b81f1c1e7b5f590 /scripts/setup.sh
parent78862ba855c6e66cac64a86c25dca6149d8fb2fd (diff)
downloadiphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.gz
iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.bz2
iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.tar.xz
iphone-notes-5c61196f27b9342e5f25414c11df5710f956f406.zip
feat!: rewrite icloud-note CLI in Rust with chromiumoxide
Replace the Node/Playwright driver with a single Rust binary so create/status stay headless without a visible browser. Move the previous implementation to legacy/nodejs for reference. BREAKING CHANGE: the supported CLI is the Rust `icloud-note` binary; the Node entrypoint is no longer installed by setup.sh. Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'scripts/setup.sh')
-rwxr-xr-xscripts/setup.sh43
1 files changed, 25 insertions, 18 deletions
diff --git a/scripts/setup.sh b/scripts/setup.sh
index a4a03fa..9c64c4c 100755
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -1,36 +1,43 @@
#!/usr/bin/env bash
-# Install Playwright + Chromium for icloud-note under ~/.config/icloud-notes
+# Build Rust icloud-note, ensure Chromium, install to ~/.local/bin, link agent skill.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
CONFIG_DIR="${ICLOUD_NOTES_CONFIG:-$HOME/.config/icloud-notes}"
-SKILL_SCRIPT="$REPO_ROOT/scripts/icloud-note.mjs"
-BIN="$HOME/.local/bin/icloud-note"
+BIN_DIR="$HOME/.local/bin"
+BIN="$BIN_DIR/icloud-note"
AGENTS_SKILL="$HOME/.agents/skills/iphone-icloud-notes"
CURSOR_SKILL="$HOME/.cursor/skills/iphone-icloud-notes"
-mkdir -p "$CONFIG_DIR" "$HOME/.local/bin" "$HOME/.agents/skills" "$HOME/.cursor/skills"
+mkdir -p "$CONFIG_DIR" "$BIN_DIR" "$HOME/.agents/skills" "$HOME/.cursor/skills"
chmod 700 "$CONFIG_DIR"
-cd "$CONFIG_DIR"
-if [[ ! -f package.json ]]; then
- npm init -y >/dev/null
+# Prefer existing Playwright Chromium; otherwise install via npx playwright
+if [[ -z "${ICLOUD_NOTES_CHROME:-}" ]]; then
+ if compgen -G "$HOME/.cache/ms-playwright/chromium-*/chrome-linux64/chrome" > /dev/null; then
+ CHROME="$(ls -1 "$HOME/.cache/ms-playwright"/chromium-*/chrome-linux64/chrome | head -1)"
+ echo "ok: using Playwright Chromium at $CHROME"
+ elif command -v npm >/dev/null 2>&1; then
+ echo "Installing Playwright Chromium for automation…"
+ mkdir -p "$CONFIG_DIR"
+ cd "$CONFIG_DIR"
+ if [[ ! -f package.json ]]; then
+ npm init -y >/dev/null
+ fi
+ npm install playwright@latest
+ npx playwright install chromium
+ else
+ echo "warn: no Chromium found and npm unavailable; install Chromium or set ICLOUD_NOTES_CHROME" >&2
+ fi
fi
-npm install playwright@latest
-npx playwright install chromium
+cd "$REPO_ROOT"
+cargo build --release
+install -m 755 "$REPO_ROOT/target/release/icloud-note" "$BIN"
-cat > "$BIN" <<EOF
-#!/usr/bin/env bash
-exec node "$SKILL_SCRIPT" "\$@"
-EOF
-chmod 755 "$BIN" "$SKILL_SCRIPT" "$REPO_ROOT/scripts/setup.sh"
-
-# Point agent skill dirs at this repo (source of truth)
ln -sfn "$REPO_ROOT" "$AGENTS_SKILL"
ln -sfn "$REPO_ROOT" "$CURSOR_SKILL"
-echo "ok: playwright installed in $CONFIG_DIR"
-echo "ok: wrapper $BIN"
+echo "ok: installed $BIN"
echo "ok: skill linked -> $REPO_ROOT"
echo "Next: icloud-note login"