Module: Antigravity::Connection::BinaryFetcher

Defined in:
lib/antigravity/connection/binary_fetcher.rb

Overview

Downloads and extracts the localharness binary from the official google-antigravity PyPI wheel. Used when the binary isn't already installed via Antigravity.app or a manual setup.

Constant Summary collapse

PYPI_PACKAGE =
'google-antigravity'
INSTALL_DIR =
File.expand_path('~/.antigravity/bin')
BINARY_NAME =
'localharness'
PLATFORM_MAP =

Platform mapping: Ruby's RUBY_PLATFORM -> PyPI wheel platform tag

{
  /darwin.*arm/i   => 'macosx_11_0_arm64',
  /darwin.*x86/i   => 'macosx_10_15_x86_64',
  /darwin/i        => 'macosx_11_0_arm64',    # default macOS = ARM
  /linux.*x86_64/i => 'manylinux2014_x86_64',
  /linux.*aarch/i  => 'manylinux2014_aarch64',
}.freeze

Class Method Summary collapse

Class Method Details

.fetch!(quiet: false) ⇒ String

Fetch and install the binary. Returns the installed path.

Parameters:

  • quiet (Boolean) (defaults to: false)

    suppress progress output

Returns:

  • (String)

    path to the installed binary



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/antigravity/connection/binary_fetcher.rb', line 33

def fetch!(quiet: false)
  platform = detect_platform
  say("🔍 Detecting platform: #{platform}", quiet: quiet)

  # Step 1: Find the wheel URL from PyPI
  say("📡 Querying PyPI for #{PYPI_PACKAGE}...", quiet: quiet)
  wheel_url = find_wheel_url(platform)

  # Step 2: Download the wheel
  say("⏳ Downloading binary... this will take some time (~50MB wheel)", quiet: quiet)
  wheel_path = download_wheel(wheel_url, quiet: quiet)

  # Step 3: Extract the binary
  say("📦 Extracting localharness binary...", quiet: quiet)
  binary_path = extract_binary(wheel_path)

  # Step 4: Make executable
  FileUtils.chmod(0o755, binary_path)
  say("✅ Installed localharness at #{binary_path}", quiet: quiet)

  binary_path
ensure
  # Clean up temp wheel
  FileUtils.rm_f(wheel_path) if wheel_path && File.exist?(wheel_path.to_s)
end

.installed?Boolean

Check if the binary is already installed via fetch

Returns:

  • (Boolean)


60
61
62
63
# File 'lib/antigravity/connection/binary_fetcher.rb', line 60

def installed?
  path = File.join(INSTALL_DIR, BINARY_NAME)
  File.executable?(path)
end

.installed_pathObject



65
66
67
# File 'lib/antigravity/connection/binary_fetcher.rb', line 65

def installed_path
  File.join(INSTALL_DIR, BINARY_NAME)
end