Skip to content

Instantly share code, notes, and snippets.

@towry
Last active August 21, 2026 12:44
Show Gist options
  • Select an option

  • Save towry/f6b63a9267bf5fe55c498bd7617e05e3 to your computer and use it in GitHub Desktop.

Select an option

Save towry/f6b63a9267bf5fe55c498bd7617e05e3 to your computer and use it in GitHub Desktop.
Cursor Cloud Agent install: clone towry/dots and deploy the local Cursor plugin (no secrets)
#!/usr/bin/env bash
# Public Cursor Cloud Agent install stub. No tokens, keys, or private URLs.
# Canonical copy: towry/dots nix/cursor-cloud/gist-install.sh
#
# Designed for `curl … | bash`: self-contained, no BASH_SOURCE or sibling files.
# Never print git remotes (they may contain x-access-token).
set -euo pipefail
dots_gh_token() {
if [ -n "${DOTS_GH_TOKEN:-}" ]; then
printf '%s' "$DOTS_GH_TOKEN"
elif [ -n "${GH_TOKEN:-}" ]; then
printf '%s' "$GH_TOKEN"
fi
}
dots_git_with_token() {
local token=$1
local auth
shift
auth=$(printf 'x-access-token:%s' "$token" | base64 | tr -d '\n')
GIT_CONFIG_COUNT=2 \
GIT_CONFIG_KEY_0="credential.helper" \
GIT_CONFIG_VALUE_0="" \
GIT_CONFIG_KEY_1="http.https://github.com/.extraheader" \
GIT_CONFIG_VALUE_1="AUTHORIZATION: basic ${auth}" \
git "$@"
}
dots_sync_github_repo() {
local repo=$1
local cache_dir=$2
local token
token=$(dots_gh_token || true)
mkdir -p "$(dirname "$cache_dir")"
if [ -d "$cache_dir/.git" ]; then
if [ -n "$token" ]; then
dots_git_with_token "$token" -C "$cache_dir" fetch --quiet origin
else
git -C "$cache_dir" fetch --quiet origin
fi
git -C "$cache_dir" reset --quiet --hard origin/main
return 0
fi
rm -rf "$cache_dir"
if [ -n "$token" ]; then
if command -v gh >/dev/null 2>&1; then
if GH_TOKEN="$token" gh repo clone "$repo" "$cache_dir"; then
return 0
fi
fi
if dots_git_with_token "$token" clone --quiet "https://github.com/${repo}.git" "$cache_dir"; then
return 0
fi
echo "dots-repo: failed to clone ${repo} with provided token" >&2
return 1
fi
if ! command -v gh >/dev/null 2>&1; then
echo "dots-repo: set DOTS_GH_TOKEN or GH_TOKEN to clone ${repo} (gh unavailable)" >&2
return 1
fi
if gh repo clone "$repo" "$cache_dir"; then
return 0
fi
echo "dots-repo: failed to clone ${repo}; set DOTS_GH_TOKEN or GH_TOKEN if gh cannot read it" >&2
return 1
}
dots_github_repo="${DOTS_GITHUB_REPO:-towry/dots}"
cache_dir="${DOTS_CACHE_DIR:-${HOME}/.cache/towry-dots}"
workspace="${CURSOR_WORKSPACE:-$(pwd -P)}"
is_dots_root() {
local dir=$1
[ -f "$dir/nix/cursor-cloud/bootstrap.sh" ] \
&& [ -f "$dir/nix/hm/ai/cursor/agents-catalog.json" ] \
&& [ -d "$dir/.agents/skills" ]
}
run_bootstrap() {
local root=$1
export DOTS_ROOT="$root"
export CURSOR_WORKSPACE="$workspace"
exec bash "$root/nix/cursor-cloud/bootstrap.sh"
}
if is_dots_root "$workspace"; then
run_bootstrap "$workspace"
fi
if [ -n "${DOTS_ROOT:-}" ] && is_dots_root "$DOTS_ROOT"; then
run_bootstrap "$DOTS_ROOT"
fi
if ! dots_sync_github_repo "$dots_github_repo" "$cache_dir"; then
echo "gist-install: failed to sync ${dots_github_repo} (set DOTS_GH_TOKEN or GH_TOKEN in this environment's secrets)" >&2
exit 1
fi
if ! is_dots_root "$cache_dir"; then
echo "gist-install: clone is missing Cursor bootstrap sources" >&2
exit 1
fi
run_bootstrap "$cache_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment