From 3df1e8c6636ae58f36fb2b32b3eff5be1271a280 Mon Sep 17 00:00:00 2001 From: Zachary Lloyd Date: Tue, 5 May 2026 08:06:40 -0700 Subject: [PATCH 1/4] Add opt-in common skills installer Co-Authored-By: Oz --- .agents/common-skills.lock | 2 + script/bootstrap | 92 +++++++++++- script/install_common_skills | 273 +++++++++++++++++++++++++++++++++++ script/macos/bootstrap | 1 + script/run | 10 ++ script/windows/bootstrap.ps1 | 66 +++++++++ 6 files changed, 438 insertions(+), 6 deletions(-) create mode 100644 .agents/common-skills.lock create mode 100755 script/install_common_skills diff --git a/.agents/common-skills.lock b/.agents/common-skills.lock new file mode 100644 index 000000000..0be237ec4 --- /dev/null +++ b/.agents/common-skills.lock @@ -0,0 +1,2 @@ +repo=https://github.com/warpdotdev/common-skills/ +ref=63729ade412300f8b602527a150af30a3b1235b4 diff --git a/script/bootstrap b/script/bootstrap index 59c814e41..e91e97c43 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,24 +1,104 @@ #!/usr/bin/env bash +set -eo pipefail # Bootstrap dispatches to the platform-specific install scripts. Each step # that needs root sources `script/warp_sudo` and asks for confirmation # before running. Pass -y / --yes (or set WARP_SKIP_SUDO_PROMPT=1) to skip # the prompts in unattended environments. +OS_TYPE="$(uname -s)" +COMMON_SKILLS_REPO_URL="${WARP_COMMON_SKILLS_REPO_URL:-https://github.com/warpdotdev/common-skills/}" +INSTALL_COMMON_SKILLS=0 +PLATFORM_ARGS=() + +usage() { + cat < + Use a specific common-skills git ref. +EOF +} + +print_bootstrap_preview() { + local platform="$1" + + echo "Warp bootstrap is starting for ${platform}." + echo "It will:" + + if [[ "${platform}" = "macOS" ]]; then + echo " - Configure Xcode as the active developer directory." + echo " - Install or update Cargo, Homebrew, PowerShell, Docker, gcloud, and related development tools." + echo " - Add the aarch64-apple-darwin Rust target." + elif [[ "${platform}" = "Linux" ]]; then + echo " - Update apt package metadata." + echo " - Install dependencies needed to build, run, and test Warp." + echo " - Install linuxdeploy and check gcloud authentication." + fi + + if [[ "${INSTALL_COMMON_SKILLS}" -eq 0 ]]; then + echo " - Skip common agent skills unless --install-common-skills is provided." + elif [[ "${WARP_SKIP_COMMON_SKILLS_INSTALL:-}" = "1" ]]; then + echo " - Skip common agent skills because WARP_SKIP_COMMON_SKILLS_INSTALL=1." + else + echo " - Install or update common agent skills from ${COMMON_SKILLS_REPO_URL} if needed." + fi + echo "Run ./script/bootstrap --help to see options and environment overrides." + echo +} + for arg in "$@"; do - case "$arg" in - -y|--yes) export WARP_SKIP_SUDO_PROMPT=1 ;; + case "${arg}" in + -h|--help) + usage + exit 0 + ;; + -y|--yes) + export WARP_SKIP_SUDO_PROMPT=1 + PLATFORM_ARGS+=("${arg}") + ;; + --install-common-skills) + INSTALL_COMMON_SKILLS=1 + ;; + *) + PLATFORM_ARGS+=("${arg}") + ;; esac done -OS_TYPE="$(uname -s)" +maybe_install_common_skills() { + if [[ "${INSTALL_COMMON_SKILLS}" -eq 1 ]]; then + ./script/install_common_skills --if-needed + fi +} if [[ "$OS_TYPE" = "Darwin" ]]; then - ./script/macos/bootstrap "$@" + print_bootstrap_preview "macOS" + ./script/macos/bootstrap "${PLATFORM_ARGS[@]}" + maybe_install_common_skills elif [[ "$OS_TYPE" = "Linux" ]]; then - ./script/linux/bootstrap "$@" + print_bootstrap_preview "Linux" + ./script/linux/bootstrap "${PLATFORM_ARGS[@]}" + maybe_install_common_skills elif [[ "$OS_TYPE" =~ ^[MINGW64_NT|MSYS_NT] ]]; then - ./script/windows/bootstrap.ps1 "$@" + if [[ "${INSTALL_COMMON_SKILLS}" -eq 1 ]]; then + ./script/windows/bootstrap.ps1 "${PLATFORM_ARGS[@]}" -InstallCommonSkills + else + ./script/windows/bootstrap.ps1 "${PLATFORM_ARGS[@]}" + fi else echo "No bootstrap script defined for the current platform!" exit 1 diff --git a/script/install_common_skills b/script/install_common_skills new file mode 100755 index 000000000..63b0bcda5 --- /dev/null +++ b/script/install_common_skills @@ -0,0 +1,273 @@ +#!/usr/bin/env bash + +set -eo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)" +LOCK_FILE="${REPO_ROOT}/.agents/common-skills.lock" +STAMP_FILENAME=".common-skills-install.json" + +IF_NEEDED=0 +NON_INTERACTIVE=0 +FORCE=0 +QUIET=0 +DEST_DIR="${WARP_COMMON_SKILLS_DEST_DIR:-}" + +usage() { + cat < + Override the git ref from .agents/common-skills.lock. +EOF +} + +log() { + if [[ "${QUIET}" -ne 1 ]]; then + echo "$@" + fi +} + +lock_value() { + local key="$1" + sed -n "s/^${key}=//p" "${LOCK_FILE}" | tail -n 1 +} + +stamp_path_for_dest() { + local dest_dir="$1" + echo "${dest_dir}/.agents/skills/${STAMP_FILENAME}" +} + +stamp_value() { + local stamp_file="$1" + local key="$2" + + if [[ ! -f "${stamp_file}" ]]; then + return + fi + + sed -n "s/.*\"${key}\"[[:space:]]*:[[:space:]]*\"\([^\"]*\)\".*/\1/p" "${stamp_file}" | tail -n 1 +} + +repo_root() { + git -C "${REPO_ROOT}" rev-parse --show-toplevel 2>/dev/null || echo "${REPO_ROOT}" +} + +choose_dest_dir() { + local home_dir="${HOME}" + local repo_dir="$(repo_root)" + local response="" + + if [[ -n "${DEST_DIR}" ]]; then + echo "${DEST_DIR}" + return + fi + + if [[ "${NON_INTERACTIVE}" -eq 1 ]]; then + if [[ -f "$(stamp_path_for_dest "${home_dir}")" ]]; then + echo "${home_dir}" + return + fi + + if [[ -f "$(stamp_path_for_dest "${repo_dir}")" ]]; then + echo "${repo_dir}" + return + fi + + echo "" + return + fi + + if [[ ! -t 0 ]]; then + echo "" + return + fi + + echo "Install common agent skills from warpdotdev/common-skills:" >&2 + echo " 1) ${home_dir}/.agents/skills (recommended for Warp team members)" >&2 + echo " 2) ${repo_dir}/.agents/skills (recommended for OpenWarp contributors)" >&2 + + while true; do + read -r -p "Choose an install location [1/2]: " response + case "${response}" in + 1) + echo "${home_dir}" + return + ;; + 2) + echo "${repo_dir}" + return + ;; + *) + echo "Please choose 1 or 2." >&2 + ;; + esac + done +} + +prepare_common_skills_source() { + local repo_url="$1" + local ref="$2" + local source_dir="$3" + + if [[ -d "${repo_url}" ]]; then + echo "${repo_url}" + return + fi + + git clone "${repo_url}" "${source_dir}" + git -C "${source_dir}" checkout --quiet "${ref}" + echo "${source_dir}" +} + +actual_source_ref() { + local source_dir="$1" + git -C "${source_dir}" rev-parse HEAD +} + +remove_existing_common_skill_dirs() { + local source_dir="$1" + local dest_dir="$2" + local source_skills_dir="${source_dir}/.agents/skills" + local dest_skills_dir="${dest_dir}/.agents/skills" + local skill_dir="" + + if [[ ! -d "${source_skills_dir}" ]]; then + echo "error: common-skills source does not contain ${source_skills_dir}" >&2 + return 1 + fi + + while IFS= read -r skill_dir; do + rm -rf "${dest_skills_dir}/$(basename "${skill_dir}")" + done < <(find "${source_skills_dir}" -mindepth 1 -maxdepth 1 -type d | sort) +} + +write_stamp() { + local dest_dir="$1" + local repo_url="$2" + local ref="$3" + local stamp_file="$(stamp_path_for_dest "${dest_dir}")" + local installed_at="" + + installed_at="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + mkdir -p "$(dirname "${stamp_file}")" + cat > "${stamp_file}" <&2 + exit 1 + fi + DEST_DIR="$2" + shift 2 + ;; + --quiet) + QUIET=1 + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "error: unknown argument: $1" >&2 + usage >&2 + exit 1 + ;; + esac +done + +if [[ "${WARP_SKIP_COMMON_SKILLS_INSTALL:-}" = "1" ]]; then + log "Skipping common-skills install because WARP_SKIP_COMMON_SKILLS_INSTALL=1." + exit 0 +fi + +if [[ ! -f "${LOCK_FILE}" ]]; then + echo "error: missing common-skills lock file: ${LOCK_FILE}" >&2 + exit 1 +fi + +LOCK_REPO="$(lock_value repo)" +LOCK_REF="$(lock_value ref)" +COMMON_SKILLS_REPO_URL="${WARP_COMMON_SKILLS_REPO_URL:-${LOCK_REPO}}" +COMMON_SKILLS_REF="${WARP_COMMON_SKILLS_REF:-${LOCK_REF}}" + +if [[ -z "${COMMON_SKILLS_REPO_URL}" || -z "${COMMON_SKILLS_REF}" ]]; then + echo "error: ${LOCK_FILE} must define repo= and ref=" >&2 + exit 1 +fi + +DEST_DIR="$(choose_dest_dir)" + +if [[ -z "${DEST_DIR}" ]]; then + log "Common skills are not installed yet; run ./script/bootstrap once or set WARP_COMMON_SKILLS_DEST_DIR." + exit 0 +fi + +if [[ -d "${COMMON_SKILLS_REPO_URL}" && -z "${WARP_COMMON_SKILLS_REF:-}" ]]; then + COMMON_SKILLS_REF="$(git -C "${COMMON_SKILLS_REPO_URL}" rev-parse HEAD)" +fi + +STAMP_FILE="$(stamp_path_for_dest "${DEST_DIR}")" +STAMP_REPO="$(stamp_value "${STAMP_FILE}" repo)" +STAMP_REF="$(stamp_value "${STAMP_FILE}" ref)" + +if [[ "${FORCE}" -ne 1 && "${IF_NEEDED}" -eq 1 && "${STAMP_REPO}" = "${COMMON_SKILLS_REPO_URL}" && "${STAMP_REF}" = "${COMMON_SKILLS_REF}" ]]; then + log "Common skills are already up to date." + exit 0 +fi + +SOURCE_CLONE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/common-skills-source.XXXXXX")" +SKILLS_CLONE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/common-skills.XXXXXX")" + +cleanup() { + rm -rf "${SOURCE_CLONE_DIR}" "${SKILLS_CLONE_DIR}" +} +trap cleanup EXIT + +SOURCE_DIR="$(prepare_common_skills_source "${COMMON_SKILLS_REPO_URL}" "${COMMON_SKILLS_REF}" "${SOURCE_CLONE_DIR}")" +ACTUAL_REF="$(actual_source_ref "${SOURCE_DIR}")" + +echo "Installing common agent skills from ${COMMON_SKILLS_REPO_URL} at ${ACTUAL_REF}." +remove_existing_common_skill_dirs "${SOURCE_DIR}" "${DEST_DIR}" +WARP_COMMON_SKILLS_REPO_URL="${SOURCE_DIR}" \ + bash "${SOURCE_DIR}/scripts/install.sh" --clone-dir "${SKILLS_CLONE_DIR}" --dest-dir "${DEST_DIR}" +write_stamp "${DEST_DIR}" "${COMMON_SKILLS_REPO_URL}" "${ACTUAL_REF}" diff --git a/script/macos/bootstrap b/script/macos/bootstrap index 12317f602..77734fd68 100755 --- a/script/macos/bootstrap +++ b/script/macos/bootstrap @@ -11,6 +11,7 @@ if ! [ -d "/Applications/Xcode.app" ]; then echo "Please install Xcode from the App Store before continuing." exit 1 fi +echo "You may be prompted for your password so bootstrap can set Xcode as the active developer directory." warp_sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer # Mimic actually launching XCode, which performs some necessary set-up of the diff --git a/script/run b/script/run index 25f1925bf..59b578e11 100755 --- a/script/run +++ b/script/run @@ -19,6 +19,7 @@ cd "${REPO_ROOT}" OS_TYPE="$(uname -s)" FEATURES="gui" +INSTALL_COMMON_SKILLS=0 ./script/install_channel_config || echo "Skipping internal channel config installation (no repo access)." @@ -63,6 +64,10 @@ while (( "$#" )); do exit 1 fi ;; + --install-common-skills) + INSTALL_COMMON_SKILLS=1 + shift + ;; --release) CARGO_PARAMS+=("$1") MAC_ARGS+=("$1") @@ -87,6 +92,11 @@ while (( "$#" )); do esac done +if [[ "$INSTALL_COMMON_SKILLS" -eq 1 ]]; then + echo "Checking common agent skills version..." + ./script/install_common_skills --if-needed --non-interactive --quiet || echo "Skipping common-skills update." +fi + # These cargo features were removed and replaced by environment variables read # by warp-channel-config. Intercept them here so that existing --features # invocations keep working. diff --git a/script/windows/bootstrap.ps1 b/script/windows/bootstrap.ps1 index 71109641d..e9e1638e6 100644 --- a/script/windows/bootstrap.ps1 +++ b/script/windows/bootstrap.ps1 @@ -1,7 +1,64 @@ #!/usr/bin/env powershell +param( + [switch]$Help, + [switch]$InstallCommonSkills +) $ErrorActionPreference = 'Stop' +if ([string]::IsNullOrWhiteSpace($env:WARP_COMMON_SKILLS_REPO_URL)) { + $commonSkillsRepoUrl = 'https://github.com/warpdotdev/common-skills/' +} else { + $commonSkillsRepoUrl = $env:WARP_COMMON_SKILLS_REPO_URL +} + +function Show-Usage { + Write-Output 'Usage: .\script\windows\bootstrap.ps1 [-Help] [-InstallCommonSkills]' + Write-Output '' + Write-Output 'Prepare this checkout for Warp development on Windows.' + Write-Output '' + Write-Output 'Options:' + Write-Output ' -Help Show this help message.' + Write-Output ' -InstallCommonSkills Install or update common agent skills from warpdotdev/common-skills.' + Write-Output '' + Write-Output 'Environment:' + Write-Output ' WARP_SKIP_COMMON_SKILLS_INSTALL=1' + Write-Output ' Skip installing common agent skills.' + Write-Output ' WARP_COMMON_SKILLS_DEST_DIR=C:\path\to\base-dir' + Write-Output ' Install common skills into C:\path\to\base-dir\.agents\skills without prompting.' + Write-Output ' WARP_COMMON_SKILLS_REPO_URL=C:\path\to\common-skills-or-git-url' + Write-Output ' Use a specific common-skills checkout or repository URL.' + Write-Output ' WARP_COMMON_SKILLS_REF=' + Write-Output ' Use a specific common-skills git ref.' +} + +function Show-BootstrapPreview { + Write-Output 'Warp bootstrap is starting for Windows.' + Write-Output 'It will:' + Write-Output ' - Check for Git for Windows.' + Write-Output ' - Install Rust if cargo is unavailable.' + Write-Output ' - Install Visual Studio Build Tools, jq, CMake, InnoSetup, and gcloud as needed.' + Write-Output ' - Install Cargo test dependencies.' + + if (-not $InstallCommonSkills) { + Write-Output ' - Skip common agent skills unless -InstallCommonSkills is provided.' + } elseif ($env:WARP_SKIP_COMMON_SKILLS_INSTALL -eq '1') { + Write-Output ' - Skip common agent skills because WARP_SKIP_COMMON_SKILLS_INSTALL=1.' + } else { + Write-Output " - Install or update common agent skills from $commonSkillsRepoUrl if needed." + } + + Write-Output 'Run .\script\windows\bootstrap.ps1 -Help to see options and environment overrides.' + Write-Output '' +} + +if ($Help) { + Show-Usage + exit 0 +} + +Show-BootstrapPreview + # Git for Windows can be installed system-wide (Program Files) or per-user (LOCALAPPDATA\Programs\Git). $gitBinCandidates = @( "$env:PROGRAMFILES\Git\bin", @@ -13,6 +70,11 @@ if (-not $gitBinDir) { Write-Error 'https://gitforwindows.org/' exit 1 } +$env:PATH = "$gitBinDir;$env:PATH" + +function Install-CommonSkills { + & "$gitBinDir\bash.exe" "$PWD\script\install_common_skills" --if-needed +} if (-not (Get-Command -Name cargo -Type Application -ErrorAction SilentlyContinue)) { Write-Output 'Installing rust...' @@ -69,3 +131,7 @@ if ($identityToken.Trim().Length -eq 0) { Read-Host gcloud auth login } + +if ($InstallCommonSkills) { + Install-CommonSkills +} From 6501e30a1e72d0ec816f90dfc3705554881fbf6e Mon Sep 17 00:00:00 2001 From: Zachary Lloyd Date: Tue, 5 May 2026 16:53:57 -0700 Subject: [PATCH 2/4] Honor explicit common skills refs for local sources Co-Authored-By: Oz --- script/install_common_skills | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/install_common_skills b/script/install_common_skills index 63b0bcda5..74c41f13e 100755 --- a/script/install_common_skills +++ b/script/install_common_skills @@ -127,6 +127,12 @@ prepare_common_skills_source() { local source_dir="$3" if [[ -d "${repo_url}" ]]; then + if [[ -n "${WARP_COMMON_SKILLS_REF:-}" ]]; then + git clone "${repo_url}" "${source_dir}" + git -C "${source_dir}" checkout --quiet "${ref}" + echo "${source_dir}" + return + fi echo "${repo_url}" return fi From 6c7a5aeb27de29b29dbb7231ccfacccf70a340d1 Mon Sep 17 00:00:00 2001 From: Zachary Lloyd Date: Wed, 6 May 2026 11:33:15 -0700 Subject: [PATCH 3/4] Use npx skills CLI for common skills install Co-Authored-By: Oz --- .agents/common-skills.lock | 2 +- script/install_common_skills | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.agents/common-skills.lock b/.agents/common-skills.lock index 0be237ec4..ad69d56e9 100644 --- a/.agents/common-skills.lock +++ b/.agents/common-skills.lock @@ -1,2 +1,2 @@ repo=https://github.com/warpdotdev/common-skills/ -ref=63729ade412300f8b602527a150af30a3b1235b4 +ref=12d2e2b787d7af4ef1b4455949b864fc5637dcff diff --git a/script/install_common_skills b/script/install_common_skills index 74c41f13e..74aee1c1d 100755 --- a/script/install_common_skills +++ b/script/install_common_skills @@ -163,6 +163,21 @@ remove_existing_common_skill_dirs() { rm -rf "${dest_skills_dir}/$(basename "${skill_dir}")" done < <(find "${source_skills_dir}" -mindepth 1 -maxdepth 1 -type d | sort) } +install_common_skills_from_source() { + local source_dir="$1" + local dest_dir="$2" + + if [[ "${dest_dir}" = "${HOME}" ]]; then + HOME="${dest_dir}" npx --yes skills@latest add "${source_dir}" --skill '*' --agent warp --copy --global -y + return + fi + + mkdir -p "${dest_dir}" + ( + cd "${dest_dir}" + npx --yes skills@latest add "${source_dir}" --skill '*' --agent warp --copy -y + ) +} write_stamp() { local dest_dir="$1" @@ -262,10 +277,9 @@ if [[ "${FORCE}" -ne 1 && "${IF_NEEDED}" -eq 1 && "${STAMP_REPO}" = "${COMMON_SK fi SOURCE_CLONE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/common-skills-source.XXXXXX")" -SKILLS_CLONE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/common-skills.XXXXXX")" cleanup() { - rm -rf "${SOURCE_CLONE_DIR}" "${SKILLS_CLONE_DIR}" + rm -rf "${SOURCE_CLONE_DIR}" } trap cleanup EXIT @@ -274,6 +288,5 @@ ACTUAL_REF="$(actual_source_ref "${SOURCE_DIR}")" echo "Installing common agent skills from ${COMMON_SKILLS_REPO_URL} at ${ACTUAL_REF}." remove_existing_common_skill_dirs "${SOURCE_DIR}" "${DEST_DIR}" -WARP_COMMON_SKILLS_REPO_URL="${SOURCE_DIR}" \ - bash "${SOURCE_DIR}/scripts/install.sh" --clone-dir "${SKILLS_CLONE_DIR}" --dest-dir "${DEST_DIR}" +install_common_skills_from_source "${SOURCE_DIR}" "${DEST_DIR}" write_stamp "${DEST_DIR}" "${COMMON_SKILLS_REPO_URL}" "${ACTUAL_REF}" From 3fa4491c3975b144145e7aa7cd1e92b9799d7de7 Mon Sep 17 00:00:00 2001 From: Zachary Lloyd Date: Wed, 6 May 2026 11:46:43 -0700 Subject: [PATCH 4/4] Fix PowerShell lint for common skills bootstrap Co-Authored-By: Oz --- script/windows/bootstrap.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/windows/bootstrap.ps1 b/script/windows/bootstrap.ps1 index e9e1638e6..0ec2ff586 100644 --- a/script/windows/bootstrap.ps1 +++ b/script/windows/bootstrap.ps1 @@ -72,7 +72,7 @@ if (-not $gitBinDir) { } $env:PATH = "$gitBinDir;$env:PATH" -function Install-CommonSkills { +function Install-CommonSkill { & "$gitBinDir\bash.exe" "$PWD\script\install_common_skills" --if-needed } @@ -133,5 +133,5 @@ if ($identityToken.Trim().Length -eq 0) { } if ($InstallCommonSkills) { - Install-CommonSkills + Install-CommonSkill }