Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions archdev/scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ function Install-ArchDev {
$minVersion = [Version]"0.49.6"

function Test-Version([string]$Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
# Drain native output before selecting a line. Select-Object -First 1 in
# the native pipeline may stop the process and manufacture a nonzero exit.
$versionLines = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -ne 0) { return $false }
$raw = ($versionLines | Select-Object -First 1) -replace "[^0-9.]", ""
try {
return ([Version]$raw -ge $minVersion)
} catch {
Expand Down Expand Up @@ -132,10 +136,13 @@ function Update-HomebrewArchDev([string]$Binary) {
}
$version = $null
if (Test-LinkedFile $Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
$versionOutput = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -eq 0) {
$raw = ($versionOutput | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
}
}
# Only a readable, too-old version needs an upgrade; anything else is broken.
# Only a successful, too-old version needs an upgrade; anything else is broken.
$action = if ($version -and $version -lt $minVersion) { "upgrade" } else { "reinstall" }
[Console]::Error.WriteLine("Updating Homebrew-managed ArchDev at ${Binary}: brew $action $brewFormula")
# Callers read stdout as the archdev path, so brew's progress goes to stderr.
Expand All @@ -145,6 +152,8 @@ function Update-HomebrewArchDev([string]$Binary) {
}
}

# Cache success only for this invocation, never across an install/repair.
$skillChecked = $false
$existing = Get-Command archdev -ErrorAction SilentlyContinue
$candidate = if ($existing) { Resolve-ArchDevPath $existing.Source } else { $null }
$homebrewArchDev = Find-HomebrewArchDev $candidate
Expand All @@ -153,12 +162,16 @@ if ($homebrewArchDev) {
if ($candidate -and $candidate -ne $archdev) {
[Console]::Error.WriteLine("Using Homebrew-managed ArchDev at $archdev; $candidate comes first on PATH.")
}
if (-not (Test-LinkedFile $archdev) -or -not (Test-Skill $archdev)) {
if ((Test-LinkedFile $archdev) -and (Test-Skill $archdev)) {
$skillChecked = $true
} else {
Update-HomebrewArchDev $archdev
}
} else {
$archdev = if ($candidate) { $candidate } else { Install-ArchDev }
if (-not (Test-Skill $archdev)) {
if (Test-Skill $archdev) {
$skillChecked = $true
} else {
[Console]::Error.WriteLine("Updating ArchDev: this skill requires 0.49.6+ and repository hook setup with --local.")
$archdev = Install-ArchDev
}
Expand All @@ -170,9 +183,7 @@ if ($homebrewArchDev -and -not (Test-LinkedFile $archdev)) {
if (-not (Test-Path -LiteralPath $archdev -PathType Leaf)) {
throw "ArchDev installer did not create an executable at $archdev"
}
& $archdev --version *> $null
if ($LASTEXITCODE -ne 0) { throw "ArchDev version verification failed" }
if (-not (Test-Skill $archdev)) {
if (-not $skillChecked -and -not (Test-Skill $archdev)) {
if ($homebrewArchDev) { throw "Homebrew-managed ArchDev at $archdev still fails the capability check after brew; not installing a second copy." }
throw "Installed ArchDev lacks required commands or --local hook setup (need 0.49.6+); stopping without a global fallback"
}
Expand Down
33 changes: 21 additions & 12 deletions archdev/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ install_archdev() (

version_ok() {
local raw version
raw="$("$1" --version 2>/dev/null | head -n 1)"
version="$(printf '%s' "$raw" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
raw="$("$1" --version 2>/dev/null)" || return 1
checked_version="${raw%%$'\n'*}"
version="$(printf '%s' "$checked_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
[[ -n "$version" ]] || return 1
[[ "$(printf '%s\n%s\n' "$min_version" "$version" | sort -V | head -n 1)" == "$min_version" ]]
}
Expand Down Expand Up @@ -132,7 +133,7 @@ find_homebrew_archdev() {
# missing, crashes, or a current version fails the capability probes, where
# upgrade would be a no-op.
update_homebrew_archdev() {
local binary="$1" action=reinstall brew version=""
local binary="$1" action=reinstall brew raw version=""
# The brew that owns this keg; another prefix's brew could install a second copy.
brew="$(real_path "$binary")"
brew="${brew%%/Cellar/archdev/*}/bin/brew"
Expand All @@ -141,11 +142,11 @@ update_homebrew_archdev() {
printf 'Not installing a second copy of ArchDev.\n' >&2
return 1
fi
if [[ -x "$binary" ]]; then
version="$("$binary" --version 2>/dev/null | head -n 1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)"
if [[ -x "$binary" ]] && raw="$("$binary" --version 2>/dev/null)"; then
version="$(printf '%s' "${raw%%$'\n'*}" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)"
fi
# Only a readable, too-old version needs an upgrade; anything else is broken.
if [[ -n "$version" ]] && ! version_ok "$binary"; then
# Only a successful, too-old version needs an upgrade; anything else is broken.
if [[ -n "$version" && "$(printf '%s\n%s\n' "$min_version" "$version" | sort -V | head -n 1)" != "$min_version" ]]; then
action=upgrade
fi
printf 'Updating Homebrew-managed ArchDev at %s: brew %s %s\n' "$binary" "$action" "$brew_formula" >&2
Expand All @@ -155,14 +156,20 @@ update_homebrew_archdev() {
fi
}

# Reuse successful checks only within this invocation. Installing or repairing
# the binary leaves this false so the replacement is checked from scratch.
skill_checked=false
checked_version=""
candidate="$(command -v archdev 2>/dev/null || true)"
homebrew_archdev="$(find_homebrew_archdev "$candidate" || true)"
if [[ -n "$homebrew_archdev" ]]; then
executable="$homebrew_archdev"
if [[ -n "$candidate" && "$(absolute_path "$candidate")" != "$executable" ]]; then
printf 'Using Homebrew-managed ArchDev at %s; %s comes first on PATH.\n' "$executable" "$(absolute_path "$candidate")" >&2
fi
if ! supports_skill "$executable"; then
if supports_skill "$executable"; then
skill_checked=true
else
update_homebrew_archdev "$executable" || exit 1
fi
else
Expand All @@ -172,7 +179,9 @@ else
install_archdev || exit 1
executable="$(absolute_path "$install_dir/archdev")"
fi
if ! supports_skill "$executable"; then
if supports_skill "$executable"; then
skill_checked=true
else
printf 'Updating ArchDev: this skill requires 0.49.6+ and repository hook setup with --local.\n' >&2
install_archdev || exit 1
executable="$(absolute_path "$install_dir/archdev")"
Expand All @@ -188,14 +197,14 @@ fi
exit 1
}

"$executable" --version >&2
supports_skill "$executable" || {
if [[ "$skill_checked" != true ]] && ! supports_skill "$executable"; then
if [[ -n "$homebrew_archdev" ]]; then
printf 'Homebrew-managed ArchDev at %s still fails the capability check after brew; not installing a second copy.\n' "$executable" >&2
fi
printf 'Installed ArchDev lacks required commands or --local hook setup (need 0.49.6+); stopping without a global fallback.\n' >&2
exit 1
}
fi
printf '%s\n' "$checked_version" >&2

# Resolving the executable must not choose configuration scope. Install and
# repair hooks only through the approved branch in https://archdev.ai/install.md.
Expand Down
29 changes: 20 additions & 9 deletions plugins/antigravity/skills/archdev/scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ function Install-ArchDev {
$minVersion = [Version]"0.49.6"

function Test-Version([string]$Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
# Drain native output before selecting a line. Select-Object -First 1 in
# the native pipeline may stop the process and manufacture a nonzero exit.
$versionLines = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -ne 0) { return $false }
$raw = ($versionLines | Select-Object -First 1) -replace "[^0-9.]", ""
try {
return ([Version]$raw -ge $minVersion)
} catch {
Expand Down Expand Up @@ -132,10 +136,13 @@ function Update-HomebrewArchDev([string]$Binary) {
}
$version = $null
if (Test-LinkedFile $Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
$versionOutput = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -eq 0) {
$raw = ($versionOutput | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
}
}
# Only a readable, too-old version needs an upgrade; anything else is broken.
# Only a successful, too-old version needs an upgrade; anything else is broken.
$action = if ($version -and $version -lt $minVersion) { "upgrade" } else { "reinstall" }
[Console]::Error.WriteLine("Updating Homebrew-managed ArchDev at ${Binary}: brew $action $brewFormula")
# Callers read stdout as the archdev path, so brew's progress goes to stderr.
Expand All @@ -145,6 +152,8 @@ function Update-HomebrewArchDev([string]$Binary) {
}
}

# Cache success only for this invocation, never across an install/repair.
$skillChecked = $false
$existing = Get-Command archdev -ErrorAction SilentlyContinue
$candidate = if ($existing) { Resolve-ArchDevPath $existing.Source } else { $null }
$homebrewArchDev = Find-HomebrewArchDev $candidate
Expand All @@ -153,12 +162,16 @@ if ($homebrewArchDev) {
if ($candidate -and $candidate -ne $archdev) {
[Console]::Error.WriteLine("Using Homebrew-managed ArchDev at $archdev; $candidate comes first on PATH.")
}
if (-not (Test-LinkedFile $archdev) -or -not (Test-Skill $archdev)) {
if ((Test-LinkedFile $archdev) -and (Test-Skill $archdev)) {
$skillChecked = $true
} else {
Update-HomebrewArchDev $archdev
}
} else {
$archdev = if ($candidate) { $candidate } else { Install-ArchDev }
if (-not (Test-Skill $archdev)) {
if (Test-Skill $archdev) {
$skillChecked = $true
} else {
[Console]::Error.WriteLine("Updating ArchDev: this skill requires 0.49.6+ and repository hook setup with --local.")
$archdev = Install-ArchDev
}
Expand All @@ -170,9 +183,7 @@ if ($homebrewArchDev -and -not (Test-LinkedFile $archdev)) {
if (-not (Test-Path -LiteralPath $archdev -PathType Leaf)) {
throw "ArchDev installer did not create an executable at $archdev"
}
& $archdev --version *> $null
if ($LASTEXITCODE -ne 0) { throw "ArchDev version verification failed" }
if (-not (Test-Skill $archdev)) {
if (-not $skillChecked -and -not (Test-Skill $archdev)) {
if ($homebrewArchDev) { throw "Homebrew-managed ArchDev at $archdev still fails the capability check after brew; not installing a second copy." }
throw "Installed ArchDev lacks required commands or --local hook setup (need 0.49.6+); stopping without a global fallback"
}
Expand Down
33 changes: 21 additions & 12 deletions plugins/antigravity/skills/archdev/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ install_archdev() (

version_ok() {
local raw version
raw="$("$1" --version 2>/dev/null | head -n 1)"
version="$(printf '%s' "$raw" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
raw="$("$1" --version 2>/dev/null)" || return 1
checked_version="${raw%%$'\n'*}"
version="$(printf '%s' "$checked_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)"
[[ -n "$version" ]] || return 1
[[ "$(printf '%s\n%s\n' "$min_version" "$version" | sort -V | head -n 1)" == "$min_version" ]]
}
Expand Down Expand Up @@ -132,7 +133,7 @@ find_homebrew_archdev() {
# missing, crashes, or a current version fails the capability probes, where
# upgrade would be a no-op.
update_homebrew_archdev() {
local binary="$1" action=reinstall brew version=""
local binary="$1" action=reinstall brew raw version=""
# The brew that owns this keg; another prefix's brew could install a second copy.
brew="$(real_path "$binary")"
brew="${brew%%/Cellar/archdev/*}/bin/brew"
Expand All @@ -141,11 +142,11 @@ update_homebrew_archdev() {
printf 'Not installing a second copy of ArchDev.\n' >&2
return 1
fi
if [[ -x "$binary" ]]; then
version="$("$binary" --version 2>/dev/null | head -n 1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)"
if [[ -x "$binary" ]] && raw="$("$binary" --version 2>/dev/null)"; then
version="$(printf '%s' "${raw%%$'\n'*}" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)"
fi
# Only a readable, too-old version needs an upgrade; anything else is broken.
if [[ -n "$version" ]] && ! version_ok "$binary"; then
# Only a successful, too-old version needs an upgrade; anything else is broken.
if [[ -n "$version" && "$(printf '%s\n%s\n' "$min_version" "$version" | sort -V | head -n 1)" != "$min_version" ]]; then
action=upgrade
fi
printf 'Updating Homebrew-managed ArchDev at %s: brew %s %s\n' "$binary" "$action" "$brew_formula" >&2
Expand All @@ -155,14 +156,20 @@ update_homebrew_archdev() {
fi
}

# Reuse successful checks only within this invocation. Installing or repairing
# the binary leaves this false so the replacement is checked from scratch.
skill_checked=false
checked_version=""
candidate="$(command -v archdev 2>/dev/null || true)"
homebrew_archdev="$(find_homebrew_archdev "$candidate" || true)"
if [[ -n "$homebrew_archdev" ]]; then
executable="$homebrew_archdev"
if [[ -n "$candidate" && "$(absolute_path "$candidate")" != "$executable" ]]; then
printf 'Using Homebrew-managed ArchDev at %s; %s comes first on PATH.\n' "$executable" "$(absolute_path "$candidate")" >&2
fi
if ! supports_skill "$executable"; then
if supports_skill "$executable"; then
skill_checked=true
else
update_homebrew_archdev "$executable" || exit 1
fi
else
Expand All @@ -172,7 +179,9 @@ else
install_archdev || exit 1
executable="$(absolute_path "$install_dir/archdev")"
fi
if ! supports_skill "$executable"; then
if supports_skill "$executable"; then
skill_checked=true
else
printf 'Updating ArchDev: this skill requires 0.49.6+ and repository hook setup with --local.\n' >&2
install_archdev || exit 1
executable="$(absolute_path "$install_dir/archdev")"
Expand All @@ -188,14 +197,14 @@ fi
exit 1
}

"$executable" --version >&2
supports_skill "$executable" || {
if [[ "$skill_checked" != true ]] && ! supports_skill "$executable"; then
if [[ -n "$homebrew_archdev" ]]; then
printf 'Homebrew-managed ArchDev at %s still fails the capability check after brew; not installing a second copy.\n' "$executable" >&2
fi
printf 'Installed ArchDev lacks required commands or --local hook setup (need 0.49.6+); stopping without a global fallback.\n' >&2
exit 1
}
fi
printf '%s\n' "$checked_version" >&2

# Resolving the executable must not choose configuration scope. Install and
# repair hooks only through the approved branch in https://archdev.ai/install.md.
Expand Down
29 changes: 20 additions & 9 deletions plugins/claude/skills/archdev/scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ function Install-ArchDev {
$minVersion = [Version]"0.49.6"

function Test-Version([string]$Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
# Drain native output before selecting a line. Select-Object -First 1 in
# the native pipeline may stop the process and manufacture a nonzero exit.
$versionLines = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -ne 0) { return $false }
$raw = ($versionLines | Select-Object -First 1) -replace "[^0-9.]", ""
try {
return ([Version]$raw -ge $minVersion)
} catch {
Expand Down Expand Up @@ -132,10 +136,13 @@ function Update-HomebrewArchDev([string]$Binary) {
}
$version = $null
if (Test-LinkedFile $Binary) {
$raw = (& $Binary --version 2>$null | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
$versionOutput = @(& $Binary --version 2>$null)
if ($LASTEXITCODE -eq 0) {
$raw = ($versionOutput | Select-Object -First 1) -replace "[^0-9.]", ""
try { $version = [Version]$raw } catch { $version = $null }
}
}
# Only a readable, too-old version needs an upgrade; anything else is broken.
# Only a successful, too-old version needs an upgrade; anything else is broken.
$action = if ($version -and $version -lt $minVersion) { "upgrade" } else { "reinstall" }
[Console]::Error.WriteLine("Updating Homebrew-managed ArchDev at ${Binary}: brew $action $brewFormula")
# Callers read stdout as the archdev path, so brew's progress goes to stderr.
Expand All @@ -145,6 +152,8 @@ function Update-HomebrewArchDev([string]$Binary) {
}
}

# Cache success only for this invocation, never across an install/repair.
$skillChecked = $false
$existing = Get-Command archdev -ErrorAction SilentlyContinue
$candidate = if ($existing) { Resolve-ArchDevPath $existing.Source } else { $null }
$homebrewArchDev = Find-HomebrewArchDev $candidate
Expand All @@ -153,12 +162,16 @@ if ($homebrewArchDev) {
if ($candidate -and $candidate -ne $archdev) {
[Console]::Error.WriteLine("Using Homebrew-managed ArchDev at $archdev; $candidate comes first on PATH.")
}
if (-not (Test-LinkedFile $archdev) -or -not (Test-Skill $archdev)) {
if ((Test-LinkedFile $archdev) -and (Test-Skill $archdev)) {
$skillChecked = $true
} else {
Update-HomebrewArchDev $archdev
}
} else {
$archdev = if ($candidate) { $candidate } else { Install-ArchDev }
if (-not (Test-Skill $archdev)) {
if (Test-Skill $archdev) {
$skillChecked = $true
} else {
[Console]::Error.WriteLine("Updating ArchDev: this skill requires 0.49.6+ and repository hook setup with --local.")
$archdev = Install-ArchDev
}
Expand All @@ -170,9 +183,7 @@ if ($homebrewArchDev -and -not (Test-LinkedFile $archdev)) {
if (-not (Test-Path -LiteralPath $archdev -PathType Leaf)) {
throw "ArchDev installer did not create an executable at $archdev"
}
& $archdev --version *> $null
if ($LASTEXITCODE -ne 0) { throw "ArchDev version verification failed" }
if (-not (Test-Skill $archdev)) {
if (-not $skillChecked -and -not (Test-Skill $archdev)) {
if ($homebrewArchDev) { throw "Homebrew-managed ArchDev at $archdev still fails the capability check after brew; not installing a second copy." }
throw "Installed ArchDev lacks required commands or --local hook setup (need 0.49.6+); stopping without a global fallback"
}
Expand Down
Loading
Loading