From 9ce3d3e9a00e2f9c9a1e7ce0895a3e58790b7c57 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sat, 28 Nov 2026 09:39:25 +0100 Subject: [PATCH 1/4] feat(catalog): add agy (Google Antigravity CLI) Add a catalog entry and a dedicated installer for agy. The installer runs the official script from antigravity.google, which checks the binary's SHA512 against the release manifest. When ~/.local/bin is already on PATH, it passes --skip-path to the script's final `agy install` step, so ~/.bashrc and ~/.profile get no redundant PATH line. Updates go through `agy update`; uninstall removes ~/.local/bin/agy and leaves ~/.config/antigravity in place. The entry sets skip_upstream: agy updates itself and publishes no release feed the collectors read, as for gcloud. Signed-off-by: Sebastian Mendel --- AGENTS.md | 2 +- CHANGELOG.md | 1 + README.md | 4 +- catalog/COVERAGE.md | 6 +- catalog/README.md | 2 +- catalog/agy.json | 17 +++++ docs/API_REFERENCE.md | 4 +- docs/CATALOG_GUIDE.md | 2 +- scripts/AGENTS.md | 3 +- scripts/install_agy.sh | 121 ++++++++++++++++++++++++++++++++++ tests/test_install_agy.py | 129 +++++++++++++++++++++++++++++++++++++ tests/test_update_fixes.py | 1 + 12 files changed, 281 insertions(+), 11 deletions(-) create mode 100644 catalog/agy.json create mode 100755 scripts/install_agy.sh create mode 100644 tests/test_install_agy.py diff --git a/AGENTS.md b/AGENTS.md index c1301d6..3a4ef93 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -137,7 +137,7 @@ This repo **is** a CLI tool manager, so the word "upgrade" is overloaded: **AI CLI Preparation v2.0** — Tool version auditing and installation management for AI coding agents. - **Modules:** 21 Python modules under `cli_audit/` (see [`cli_audit/AGENTS.md`](./cli_audit/AGENTS.md)) -- **Catalog:** 107 JSON tool definitions under `catalog/` +- **Catalog:** 108 JSON tool definitions under `catalog/` - **Installers:** 34 Bash scripts under `scripts/` (see [`scripts/AGENTS.md`](./scripts/AGENTS.md)) - **Phase 1:** Detection & auditing (complete) - **Phase 2:** Installation & upgrade management (complete) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b46bc..6ed2bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] ### Added +- `agy` catalog entry (`catalog/agy.json` + `scripts/install_agy.sh`): the Google Antigravity CLI, installed with the official installer from antigravity.google. When `~/.local/bin` is already on `PATH`, the installer passes `--skip-path` so `~/.bashrc` and `~/.profile` get no extra PATH line; updates run `agy update`. - `pi` catalog entry: the pi coding agent, installed from npm as `@earendil-works/pi-coding-agent` (the earlier `@mariozechner/pi-coding-agent` package is deprecated); upstream version from GitHub `earendil-works/pi`. - `jules` catalog entry: the Google Jules CLI (`@google/jules`), Google's asynchronous coding agent, with bash completion from `jules completion bash`. - `herdr` catalog entry (`catalog/herdr.json`): terminal multiplexer for coding agents, installed as a raw linux binary from GitHub releases (x86_64, aarch64) with bash completion. diff --git a/README.md b/README.md index c908ae2..f6c37d2 100644 --- a/README.md +++ b/README.md @@ -478,7 +478,7 @@ make test-parallel # Parallel via pytest-xdist ## Installation scripts -All 107 cataloged tools can be installed, upgraded, uninstalled, or reconciled via generic Make targets: +All 108 cataloged tools can be installed, upgraded, uninstalled, or reconciled via generic Make targets: ```bash # Generic pattern targets - work for ANY cataloged tool @@ -543,7 +543,7 @@ When ambiguous, the audit may report a generic bucket (e.g., `~/.local/bin`). Th ### Actions: install, upgrade, uninstall, reconcile -All pattern targets (`install-%`, `upgrade-%`, `uninstall-%`, `reconcile-%`) work for any of the 107 cataloged tools. They use a three-step fallback: dedicated script, then generic installer, then error. +All pattern targets (`install-%`, `upgrade-%`, `uninstall-%`, `reconcile-%`) work for any of the 108 cataloged tools. They use a three-step fallback: dedicated script, then generic installer, then error. ```bash # Upgrade any tool diff --git a/catalog/COVERAGE.md b/catalog/COVERAGE.md index 03b308f..8a36e6e 100644 --- a/catalog/COVERAGE.md +++ b/catalog/COVERAGE.md @@ -2,14 +2,14 @@ This file documents which tools have catalog entries and how each one is installed. -## Catalog entries (107) +## Catalog entries (108) -Counted from `catalog/*.json` on 2026-09-22. Every tool the audit tracks has a catalog entry; its `install_method` selects the installer (`scripts/installers/.sh`). `dedicated_script` runs the script named in the entry's `script` field. `auto` goes through the reconciliation system (`reconcile_tool` in `scripts/lib/reconcile.sh`). +Counted from `catalog/*.json` on 2026-11-28. Every tool the audit tracks has a catalog entry; its `install_method` selects the installer (`scripts/installers/.sh`). `dedicated_script` runs the script named in the entry's `script` field. `auto` goes through the reconciliation system (`reconcile_tool` in `scripts/lib/reconcile.sh`). | install_method | Count | Tools | |---|---|---| | `github_release_binary` | 38 | ast-grep, curlie, dasel, direnv, dive, fx, fzf, gh, gh-aw, gh-aw-firewall, git-absorb, git-branchless, git-lfs, gitleaks, glab, golangci-lint, google-workspace-cli, gosec, herdr, jq, just, kubectl, mlr, ninja, opengrep, qsv, rga, sd, shellcheck, shfmt, symfony, tfsec, trivy, vhs, watchexec, xsv, yq, zellij | -| `dedicated_script` | 18 | blesh, byobu, claude, composer, docker, gem, go, node, parallel, pip, python, ruby, rust, tmux, tree, uv, wslu, yarn | +| `dedicated_script` | 19 | agy, blesh, byobu, claude, composer, docker, gem, go, node, parallel, pip, python, ruby, rust, tmux, tree, uv, wslu, yarn | | `auto` | 13 | actionlint, bat, delta, difftastic, dust, fd, gup, hyperfine, jj, pnpm, ripgrep, scc, tokei | | `uv_tool` | 12 | ansible-core, bandit, black, flake8, gam, git-filter-repo, httpie, isort, pre-commit, ruff, semgrep, trustmux | | `package_manager` | 10 | bwrap, ctags, entr, git, php, pipx, poetry, prename, rename.ul, sponge | diff --git a/catalog/README.md b/catalog/README.md index 8dde570..812cd69 100644 --- a/catalog/README.md +++ b/catalog/README.md @@ -71,7 +71,7 @@ Install tools via system package managers (apt, brew, dnf, pacman). 2. The tool will automatically be available via `make install-`, `make upgrade-`, `make uninstall-`, and `make reconcile-` 3. No need to create a custom install script! -Currently **107 tools** are cataloged. +Currently **108 tools** are cataloged. ## Environment Variables diff --git a/catalog/agy.json b/catalog/agy.json new file mode 100644 index 0000000..bf056cf --- /dev/null +++ b/catalog/agy.json @@ -0,0 +1,17 @@ +{ + "name": "agy", + "category": "ai", + "install_method": "dedicated_script", + "description": "Google Antigravity CLI - AI coding agent that runs in your terminal", + "homepage": "https://antigravity.google/docs/cli/install", + "binary_name": "agy", + "script": "install_agy.sh", + "skip_upstream": true, + "version_command": "timeout 2 agy --version 2>/dev/null | grep -oE '[0-9]+\\.[0-9]+\\.[0-9]+' | head -1", + "guide": { + "display_name": "Google Antigravity CLI", + "install_action": "upgrade", + "order": 406 + }, + "notes": "Official installer: curl -fsSL https://antigravity.google/cli/install.sh | bash (binary in ~/.local/bin/agy, SHA512 checked against the release manifest). Updates itself in the background; 'agy update' updates on demand. First run signs in with a Google account." +} diff --git a/docs/API_REFERENCE.md b/docs/API_REFERENCE.md index e533b77..d11b194 100644 --- a/docs/API_REFERENCE.md +++ b/docs/API_REFERENCE.md @@ -125,7 +125,7 @@ class ToolCatalog: ```python from cli_audit import ToolCatalog -# Load catalog (107 tools) +# Load catalog (108 tools) catalog = ToolCatalog() entries = catalog.load_all() @@ -140,7 +140,7 @@ if catalog.has("fzf"): fzf = catalog.get("fzf") # List all tools -all_tools = catalog.list_all() # Returns list of 107 tool names +all_tools = catalog.list_all() # Returns list of 108 tool names ``` #### `cli_audit.collectors` - Upstream Version Collection diff --git a/docs/CATALOG_GUIDE.md b/docs/CATALOG_GUIDE.md index 8b239e9..e352194 100644 --- a/docs/CATALOG_GUIDE.md +++ b/docs/CATALOG_GUIDE.md @@ -15,7 +15,7 @@ The catalog system allows tool definitions to be managed as JSON files instead o - **Clear Separation**: Data (JSON) vs Logic (Python) **Location**: `catalog/` directory at project root -**Current Size**: 107 JSON tool definitions +**Current Size**: 108 JSON tool definitions ## Quick Start diff --git a/scripts/AGENTS.md b/scripts/AGENTS.md index d5c2c25..fa6f829 100644 --- a/scripts/AGENTS.md +++ b/scripts/AGENTS.md @@ -25,6 +25,7 @@ - `install_tool.sh`: Main orchestrator - reads catalog, delegates to installers - `install_group.sh`: Install tool groups - `install_claude.sh`: Claude Code CLI (native installer) +- `install_agy.sh`: Google Antigravity CLI (official installer; `agy update` for updates) - `install_ansible.sh`, `install_brew.sh`, `install_composer.sh` - `install_docker.sh`, `install_gem.sh`, `install_parallel.sh`, `install_yarn.sh` - `install_tmux.sh`, `install_tree.sh` (single-binary utilities) @@ -128,7 +129,7 @@ make scripts-perms # Ensure all scripts are executable ./scripts/install_node.sh reconcile ``` -**Via Make (works for all 107 cataloged tools):** +**Via Make (works for all 108 cataloged tools):** ```bash make install-python # Install Python toolchain (dedicated script) make upgrade-python # Upgrade Python toolchain diff --git a/scripts/install_agy.sh b/scripts/install_agy.sh new file mode 100755 index 0000000..c3725c4 --- /dev/null +++ b/scripts/install_agy.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Netresearch DTT GmbH +# Dedicated installer for the Google Antigravity CLI (agy) +# Uses the official installer; updates go through the CLI's own updater +set -euo pipefail + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ACTION="${1:-install}" +INSTALLER_URL="https://antigravity.google/cli/install.sh" +BIN_DIR="$HOME/.local/bin" +AGY_BIN="$BIN_DIR/agy" +# curl may only use https, including on redirects +CURL_HTTPS_ONLY=(--proto '=https') + +get_current_version() { + timeout 2 agy --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true +} + +# True when ~/.local/bin is already a PATH entry +bin_dir_on_path() { + case ":$PATH:" in + *":$BIN_DIR:"*) return 0 ;; + *) return 1 ;; + esac +} + +# Run the official installer. It downloads the binary, checks its SHA512 +# against the release manifest and then runs `agy install`, which appends a +# PATH line to ~/.bashrc and ~/.profile. When ~/.local/bin is already on PATH +# that line only moves the directory to the front, so pass --skip-path. +install_native() { + if ! command -v curl >/dev/null 2>&1; then + echo "[agy] curl is required for the official installer" >&2 + return 1 + fi + local work_dir installer_script + work_dir="$(mktemp -d "${TMPDIR:-/tmp}/cli-audit-agy.XXXXXX")" || return 1 + installer_script="$work_dir/install.sh" + + if ! curl "${CURL_HTTPS_ONLY[@]}" -fsSL "$INSTALLER_URL" -o "$installer_script"; then + echo "[agy] Failed to download $INSTALLER_URL" >&2 + rm -rf "$work_dir" + return 1 + fi + + if bin_dir_on_path; then + # The anchor is the line that hands over to `agy install`; if Google + # changes it, install without the patch rather than fail + if grep -qF '"$BINARY_PATH" install || true' "$installer_script"; then + # sed without -i: BSD and GNU sed disagree on its argument + sed 's/"\$BINARY_PATH" install || true/"\$BINARY_PATH" install --skip-path || true/' \ + "$installer_script" >"$installer_script.patched" && mv "$installer_script.patched" "$installer_script" + else + echo "[agy] Warning: installer layout changed; it may add a PATH line to your shell profile" >&2 + fi + fi + + local rc=0 + bash "$installer_script" || rc=$? + rm -rf "$work_dir" + return "$rc" +} + +install_agy() { + local before after path + before="$(get_current_version)" + + if [ -x "$AGY_BIN" ]; then + echo "[agy] Already installed at $AGY_BIN; it updates itself (run: agy update)" >&2 + elif ! install_native; then + echo "[agy] Error: installation failed" >&2 + echo "[agy] Install manually: curl -fsSL $INSTALLER_URL | bash" >&2 + return 1 + fi + + hash -r 2>/dev/null || true + after="$(get_current_version)" + path="$(command -v agy 2>/dev/null || true)" + + printf "[%s] before: %s\n" "agy" "${before:-}" + printf "[%s] after: %s\n" "agy" "${after:-}" + if [ -n "$path" ]; then printf "[%s] path: %s\n" "agy" "$path"; fi + + if [ -f "$DIR/lib/install_strategy.sh" ]; then + . "$DIR/lib/install_strategy.sh" + refresh_snapshot "agy" 2>/dev/null || true + fi +} + +upgrade_agy() { + if [ ! -x "$AGY_BIN" ]; then + echo "[agy] Not installed, running install..." >&2 + install_agy + return $? + fi + "$AGY_BIN" update /dev/null || true + printf "[%s] after: %s\n" "agy" "$(get_current_version)" +} + +uninstall_agy() { + if [ ! -e "$AGY_BIN" ]; then + echo "[agy] Not installed at $AGY_BIN" >&2 + return 0 + fi + rm -f "$AGY_BIN" + hash -r 2>/dev/null || true + echo "[agy] Removed $AGY_BIN" >&2 + echo "[agy] Settings and sign-in remain in ~/.config/antigravity; remove them by hand if wanted" >&2 +} + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + case "$ACTION" in + install) install_agy ;; + update|upgrade) upgrade_agy ;; + uninstall) uninstall_agy ;; + reconcile) install_agy ;; + *) echo "Usage: $0 {install|update|upgrade|uninstall|reconcile}" ; exit 2 ;; + esac +fi diff --git a/tests/test_install_agy.py b/tests/test_install_agy.py new file mode 100644 index 0000000..4e230fc --- /dev/null +++ b/tests/test_install_agy.py @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Netresearch DTT GmbH +"""Tests for the agy (Google Antigravity CLI) catalog entry and scripts/install_agy.sh.""" + +from __future__ import annotations + +import json +import os +import subprocess +import sys +from pathlib import Path + +import pytest + +skip_on_windows = pytest.mark.skipif(sys.platform == "win32", reason="Shell script tests require POSIX shell") + +PROJECT_ROOT = Path(__file__).parent.parent +SCRIPT = PROJECT_ROOT / "scripts" / "install_agy.sh" + +# The hand-over at the end of https://antigravity.google/cli/install.sh, +# copied verbatim; the fake binary records the arguments it is called with +FAKE_INSTALLER = """#!/bin/bash +set -euo pipefail +CUSTOM_DIR="" +BINARY_PATH="$HOME/.local/bin/agy" +mkdir -p "$HOME/.local/bin" +printf '#!/bin/sh\\necho "$*" >> "$HOME/agy-args"\\necho 1.5.19\\n' > "$BINARY_PATH" +chmod +x "$BINARY_PATH" +if [ -n "$CUSTOM_DIR" ]; then + # Run with custom directory and absorb non-fatal soft warning exits + "$BINARY_PATH" install --dir "$CUSTOM_DIR" || true +else + # Run standard configuration and absorb non-fatal soft warning exits + "$BINARY_PATH" install || true +fi +""" + +CURL_STUB = """#!/usr/bin/env bash +out="" +while [ $# -gt 0 ]; do + if [ "$1" = "-o" ]; then out="$2"; shift; fi + shift +done +cat "$CURL_PAYLOAD" > "$out" +""" + + +def _write_exe(path: Path, body: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(body) + path.chmod(0o755) + + +class TestAgyCatalog: + def test_catalog_entry(self): + data = json.loads((PROJECT_ROOT / "catalog" / "agy.json").read_text()) + assert data["name"] == "agy" + assert data["install_method"] == "dedicated_script" + assert data["script"] == "install_agy.sh" + assert data["binary_name"] == "agy" + assert data["skip_upstream"] is True + assert "agy --version" in data["version_command"] + + def test_script_is_executable(self): + assert os.access(SCRIPT, os.X_OK) + + +@skip_on_windows +class TestInstallAgy: + def _run(self, home: Path, action: str, path_has_bin: bool, installer: str = FAKE_INSTALLER): + stubs = home / "stubs" + _write_exe(stubs / "curl", CURL_STUB) + payload = home / "payload" + payload.write_text(installer) + # A copy without scripts/lib, so refresh_snapshot does not write the + # repository's local_state.json + script = home / "scripts" / "install_agy.sh" + _write_exe(script, SCRIPT.read_text()) + path = f"{stubs}:/usr/bin:/bin" + if path_has_bin: + path = f"{home}/.local/bin:{path}" + return subprocess.run( + ["bash", str(script), action], + capture_output=True, + text=True, + timeout=20, + env={"HOME": str(home), "PATH": path, "CURL_PAYLOAD": str(payload)}, + ) + + def _args(self, home: Path) -> list[str]: + return (home / "agy-args").read_text().splitlines() + + def test_install_skips_path_line_when_bin_dir_on_path(self, tmp_path: Path): + result = self._run(tmp_path, "install", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert "install --skip-path" in self._args(tmp_path) + + def test_install_keeps_path_line_when_bin_dir_missing_from_path(self, tmp_path: Path): + result = self._run(tmp_path, "install", path_has_bin=False) + assert result.returncode == 0, result.stderr + assert "install" in self._args(tmp_path) + assert "install --skip-path" not in self._args(tmp_path) + + def test_install_warns_when_installer_layout_changed(self, tmp_path: Path): + changed = FAKE_INSTALLER.replace('"$BINARY_PATH" install || true', '"$BINARY_PATH" setup || true') + result = self._run(tmp_path, "install", path_has_bin=True, installer=changed) + assert result.returncode == 0, result.stderr + assert "installer layout changed" in result.stderr + assert self._args(tmp_path)[0] == "setup" + + def test_install_leaves_existing_binary_alone(self, tmp_path: Path): + _write_exe(tmp_path / ".local" / "bin" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "install", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert "Already installed" in result.stderr + assert not [a for a in self._args(tmp_path) if a.startswith("install")] + + def test_update_runs_agy_update(self, tmp_path: Path): + _write_exe(tmp_path / ".local" / "bin" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "update", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert self._args(tmp_path)[0] == "update" + + def test_uninstall_removes_binary(self, tmp_path: Path): + binary = tmp_path / ".local" / "bin" / "agy" + _write_exe(binary, "#!/bin/sh\n") + result = self._run(tmp_path, "uninstall", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert not binary.exists() diff --git a/tests/test_update_fixes.py b/tests/test_update_fixes.py index 8fae8a7..973e4bf 100644 --- a/tests/test_update_fixes.py +++ b/tests/test_update_fixes.py @@ -638,6 +638,7 @@ def test_fd_candidates_field_preserved_in_catalog_entry(self): # All 14 dedicated scripts from the catalog DEDICATED_SCRIPTS = [ + "agy", "claude", "composer", "docker", From 9b0871d850bdcb2c6b09a6fe83082332275ce1c4 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sat, 28 Nov 2026 09:45:37 +0100 Subject: [PATCH 2/4] fix(scripts): find an existing agy and match PATH entries robustly Review of the agy installer: - Act on the first agy on PATH when ~/.local/bin/agy does not exist, so install does not add a second copy and update runs that copy's `agy update`; read its version without timeout(1), which macOS lacks. - Treat a PATH entry with a trailing slash, or one that resolves to ~/.local/bin through a symlinked HOME, as ~/.local/bin. - Warn when patching the installer fails, report a failed `agy update`, refresh the snapshot after an update, and remove a dangling ~/.local/bin/agy symlink on uninstall. - Indent with four spaces as .editorconfig and scripts/AGENTS.md ask. - Tests run a copy of the script without scripts/lib, so they no longer rewrite the repository's local_state.json. - Update the remaining catalog counts, add agy to TOOL_ECOSYSTEM.md and to the completion coverage (agy has no completion command). Signed-off-by: Sebastian Mendel --- catalog/COVERAGE.md | 6 +- catalog/README.md | 2 +- docs/INDEX.md | 4 +- docs/TOOL_ECOSYSTEM.md | 8 ++ scripts/install_agy.sh | 200 +++++++++++++++++++++++-------------- tests/test_install_agy.py | 65 +++++++++++- tests/test_update_fixes.py | 4 +- 7 files changed, 200 insertions(+), 89 deletions(-) diff --git a/catalog/COVERAGE.md b/catalog/COVERAGE.md index 8a36e6e..f90326b 100644 --- a/catalog/COVERAGE.md +++ b/catalog/COVERAGE.md @@ -28,8 +28,8 @@ A sweep on 2026-07-22 (commit 9b6c053) audited the entries present in that commit for a bash-completion generator: each generator was executed and its output validated against `complete -…` / `compgen ` / `COMPREPLY`, then checked to confirm it registers the entry's own `binary_name`. codex, pip and -pipx were not installed then; see the end of this section. herdr, jules, pi -and vault were checked when they were added. Five entries are not audited: +pipx were not installed then; see the end of this section. agy, herdr, jules, +pi and vault were checked when they were added. Five entries are not audited: blesh, bw, bwrap, byobu, trustmux. **42 entries declare `bash_completion`** — 41 `command`, 1 `source_path` (rbenv). @@ -57,7 +57,7 @@ The completion file is named after `binary_name`, so a script that registers a ### No bash completion available -actionlint, ansible-core, aws, bandit, claude, ctags, curlie, difftastic, +actionlint, agy, ansible-core, aws, bandit, claude, ctags, curlie, difftastic, direnv, dust, entr, eslint, flake8, gam, gem, gemini, gh-aw-firewall, git, git-branchless, git-filter-repo, go, google-workspace-cli, gosec, httpie, hyperfine, isort, jq, ninja, opengrep, php, pi, pre-commit, prename, prettier, diff --git a/catalog/README.md b/catalog/README.md index 812cd69..dc8e90c 100644 --- a/catalog/README.md +++ b/catalog/README.md @@ -96,6 +96,6 @@ make upgrade ## Architecture -All 107 tools have catalog entries. The generic installer (`scripts/install_tool.sh`) reads a tool's catalog JSON and delegates to the appropriate method-specific installer under `scripts/installers/`. Tools with complex installation needs (python, node, docker, rust, etc.) use `install_method: "dedicated_script"` to route to their existing bespoke scripts. +All 108 tools have catalog entries. The generic installer (`scripts/install_tool.sh`) reads a tool's catalog JSON and delegates to the appropriate method-specific installer under `scripts/installers/`. Tools with complex installation needs (python, node, docker, rust, etc.) use `install_method: "dedicated_script"` to route to their existing bespoke scripts. See [ADR-007](../docs/adr/ADR-007-generic-tool-installation-architecture.md) for the full architectural decision record. diff --git a/docs/INDEX.md b/docs/INDEX.md index 17f46d8..179c255 100644 --- a/docs/INDEX.md +++ b/docs/INDEX.md @@ -10,7 +10,7 @@ AI CLI Preparation is a specialized environment audit tool designed to ensure AI coding agents (like Claude Code) have access to all necessary developer tools. This documentation provides comprehensive technical details for developers, contributors, and integrators. -**Architecture:** Modular design with 21 specialized Python modules and 107 JSON tool catalog entries, evolved from a 3,387-line monolith to a maintainable, extensible system. +**Architecture:** Modular design with 21 specialized Python modules and 108 JSON tool catalog entries, evolved from a 3,387-line monolith to a maintainable, extensible system. **Project Status:** - **Phase 1 (Detection & Auditing):** ✅ Complete - Modular refactoring complete @@ -37,7 +37,7 @@ AI CLI Preparation is a specialized environment audit tool designed to ensure AI 2. **[CATALOG_GUIDE.md](CATALOG_GUIDE.md)** - JSON Catalog System ⭐ **NEW** - Tool definition schema and structure - - 107 JSON catalog entries + - 108 JSON catalog entries - Creating and managing catalog entries - ToolCatalog API and usage patterns - Community contribution workflows diff --git a/docs/TOOL_ECOSYSTEM.md b/docs/TOOL_ECOSYSTEM.md index 78cded6..06f1ffb 100644 --- a/docs/TOOL_ECOSYSTEM.md +++ b/docs/TOOL_ECOSYSTEM.md @@ -576,6 +576,14 @@ CLI_AUDIT_JSON=1 uv run python audit.py | jq '.[] | select(.category == "securit - **Install:** `npm install -g @google/gemini-cli` - **Upgrade:** `npm update -g @google/gemini-cli` +### agy +- **Purpose:** Google Antigravity CLI - AI coding agent that runs in your terminal +- **Executable:** `agy` +- **Upstream:** Official installer (https://antigravity.google/cli/install.sh); no release feed, the CLI updates itself +- **Use Case:** Terminal coding agent backed by Google models +- **Install:** `make install-agy` (runs the official installer) +- **Upgrade:** `agy update` + ### jules - **Purpose:** Google Jules CLI - terminal client for Jules, Google's asynchronous coding agent - **Executable:** `jules` diff --git a/scripts/install_agy.sh b/scripts/install_agy.sh index c3725c4..6cd2f8a 100755 --- a/scripts/install_agy.sh +++ b/scripts/install_agy.sh @@ -13,16 +13,48 @@ AGY_BIN="$BIN_DIR/agy" # curl may only use https, including on redirects CURL_HTTPS_ONLY=(--proto '=https') +# The agy to act on: ~/.local/bin/agy (where the official installer puts it), +# else the first agy on PATH (an install with --dir or by another method) +find_agy() { + if [ -x "$AGY_BIN" ]; then + printf '%s\n' "$AGY_BIN" + else + command -v agy 2>/dev/null || true + fi +} + get_current_version() { - timeout 2 agy --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true + local bin + bin="$(find_agy)" + [ -n "$bin" ] || return 0 + # macOS has no timeout(1) + if command -v timeout >/dev/null 2>&1; then + timeout 2 "$bin" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true + else + "$bin" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true + fi } -# True when ~/.local/bin is already a PATH entry +# True when a PATH entry is ~/.local/bin, also written with a trailing slash +# or through a symlinked parent bin_dir_on_path() { - case ":$PATH:" in - *":$BIN_DIR:"*) return 0 ;; - *) return 1 ;; - esac + local entry resolved_bin="" resolved + local -a entries + [ -d "$BIN_DIR" ] && resolved_bin="$(cd "$BIN_DIR" && pwd -P)" + IFS=: read -r -a entries <<<"$PATH" + for entry in "${entries[@]}"; do + [ -n "$entry" ] || continue + [ "${entry%/}" = "$BIN_DIR" ] && return 0 + if [ -n "$resolved_bin" ] && [ -d "$entry" ]; then + resolved="$(cd "$entry" && pwd -P)" || continue + [ "$resolved" = "$resolved_bin" ] && return 0 + fi + done + return 1 +} + +warn_path_line() { + echo "[agy] Warning: $1; the installer may add a PATH line to ~/.bashrc and ~/.profile" >&2 } # Run the official installer. It downloads the binary, checks its SHA512 @@ -30,92 +62,108 @@ bin_dir_on_path() { # PATH line to ~/.bashrc and ~/.profile. When ~/.local/bin is already on PATH # that line only moves the directory to the front, so pass --skip-path. install_native() { - if ! command -v curl >/dev/null 2>&1; then - echo "[agy] curl is required for the official installer" >&2 - return 1 - fi - local work_dir installer_script - work_dir="$(mktemp -d "${TMPDIR:-/tmp}/cli-audit-agy.XXXXXX")" || return 1 - installer_script="$work_dir/install.sh" + if ! command -v curl >/dev/null 2>&1; then + echo "[agy] curl is required for the official installer" >&2 + return 1 + fi + local work_dir installer_script + work_dir="$(mktemp -d "${TMPDIR:-/tmp}/cli-audit-agy.XXXXXX")" || return 1 + installer_script="$work_dir/install.sh" + + if ! curl "${CURL_HTTPS_ONLY[@]}" -fsSL "$INSTALLER_URL" -o "$installer_script"; then + echo "[agy] Failed to download $INSTALLER_URL" >&2 + rm -rf "$work_dir" + return 1 + fi - if ! curl "${CURL_HTTPS_ONLY[@]}" -fsSL "$INSTALLER_URL" -o "$installer_script"; then - echo "[agy] Failed to download $INSTALLER_URL" >&2 + if bin_dir_on_path; then + # The anchor is the line that hands over to `agy install`; if Google + # changes it, install without the patch rather than fail + if ! grep -qF '"$BINARY_PATH" install || true' "$installer_script"; then + warn_path_line "installer layout changed" + # sed without -i: BSD and GNU sed disagree on its argument + elif ! { sed 's/"\$BINARY_PATH" install || true/"\$BINARY_PATH" install --skip-path || true/' \ + "$installer_script" >"$installer_script.patched" && + mv "$installer_script.patched" "$installer_script"; }; then + warn_path_line "could not patch the installer" + fi + fi + + local rc=0 + bash "$installer_script" || rc=$? rm -rf "$work_dir" - return 1 - fi - - if bin_dir_on_path; then - # The anchor is the line that hands over to `agy install`; if Google - # changes it, install without the patch rather than fail - if grep -qF '"$BINARY_PATH" install || true' "$installer_script"; then - # sed without -i: BSD and GNU sed disagree on its argument - sed 's/"\$BINARY_PATH" install || true/"\$BINARY_PATH" install --skip-path || true/' \ - "$installer_script" >"$installer_script.patched" && mv "$installer_script.patched" "$installer_script" - else - echo "[agy] Warning: installer layout changed; it may add a PATH line to your shell profile" >&2 + return "$rc" +} + +refresh_agy_snapshot() { + if [ -f "$DIR/lib/install_strategy.sh" ]; then + . "$DIR/lib/install_strategy.sh" + refresh_snapshot "agy" 2>/dev/null || true fi - fi +} - local rc=0 - bash "$installer_script" || rc=$? - rm -rf "$work_dir" - return "$rc" +report() { + local before="$1" after path + hash -r 2>/dev/null || true + after="$(get_current_version)" + path="$(find_agy)" + printf "[%s] before: %s\n" "agy" "${before:-}" + printf "[%s] after: %s\n" "agy" "${after:-}" + if [ -n "$path" ]; then printf "[%s] path: %s\n" "agy" "$path"; fi } install_agy() { - local before after path - before="$(get_current_version)" - - if [ -x "$AGY_BIN" ]; then - echo "[agy] Already installed at $AGY_BIN; it updates itself (run: agy update)" >&2 - elif ! install_native; then - echo "[agy] Error: installation failed" >&2 - echo "[agy] Install manually: curl -fsSL $INSTALLER_URL | bash" >&2 - return 1 - fi - - hash -r 2>/dev/null || true - after="$(get_current_version)" - path="$(command -v agy 2>/dev/null || true)" + local before existing + before="$(get_current_version)" + existing="$(find_agy)" - printf "[%s] before: %s\n" "agy" "${before:-}" - printf "[%s] after: %s\n" "agy" "${after:-}" - if [ -n "$path" ]; then printf "[%s] path: %s\n" "agy" "$path"; fi + if [ -n "$existing" ]; then + echo "[agy] Already installed at $existing; it updates itself (run: agy update)" >&2 + elif ! install_native; then + echo "[agy] Error: installation failed" >&2 + echo "[agy] Install manually: curl -fsSL $INSTALLER_URL | bash" >&2 + return 1 + fi - if [ -f "$DIR/lib/install_strategy.sh" ]; then - . "$DIR/lib/install_strategy.sh" - refresh_snapshot "agy" 2>/dev/null || true - fi + report "$before" + refresh_agy_snapshot } upgrade_agy() { - if [ ! -x "$AGY_BIN" ]; then - echo "[agy] Not installed, running install..." >&2 - install_agy - return $? - fi - "$AGY_BIN" update /dev/null || true - printf "[%s] after: %s\n" "agy" "$(get_current_version)" + local before existing + existing="$(find_agy)" + if [ -z "$existing" ]; then + echo "[agy] Not installed, running install..." >&2 + install_agy + return $? + fi + before="$(get_current_version)" + if ! "$existing" update &2 + return 1 + fi + report "$before" + refresh_agy_snapshot } uninstall_agy() { - if [ ! -e "$AGY_BIN" ]; then - echo "[agy] Not installed at $AGY_BIN" >&2 - return 0 - fi - rm -f "$AGY_BIN" - hash -r 2>/dev/null || true - echo "[agy] Removed $AGY_BIN" >&2 - echo "[agy] Settings and sign-in remain in ~/.config/antigravity; remove them by hand if wanted" >&2 + if [ ! -e "$AGY_BIN" ] && [ ! -L "$AGY_BIN" ]; then + echo "[agy] Not installed at $AGY_BIN" >&2 + return 0 + fi + rm -f "$AGY_BIN" + hash -r 2>/dev/null || true + echo "[agy] Removed $AGY_BIN" >&2 + echo "[agy] Left in place: settings and sign-in in ~/.config/antigravity, and any" >&2 + echo "[agy] 'Added by Antigravity CLI installer' PATH line in ~/.bashrc and ~/.profile" >&2 } if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - case "$ACTION" in - install) install_agy ;; - update|upgrade) upgrade_agy ;; - uninstall) uninstall_agy ;; - reconcile) install_agy ;; - *) echo "Usage: $0 {install|update|upgrade|uninstall|reconcile}" ; exit 2 ;; - esac + case "$ACTION" in + install) install_agy ;; + update|upgrade) upgrade_agy ;; + uninstall) uninstall_agy ;; + reconcile) install_agy ;; + *) echo "Usage: $0 {install|update|upgrade|uninstall|reconcile}" ; exit 2 ;; + esac fi diff --git a/tests/test_install_agy.py b/tests/test_install_agy.py index 4e230fc..2370346 100644 --- a/tests/test_install_agy.py +++ b/tests/test_install_agy.py @@ -67,7 +67,16 @@ def test_script_is_executable(self): @skip_on_windows class TestInstallAgy: - def _run(self, home: Path, action: str, path_has_bin: bool, installer: str = FAKE_INSTALLER): + def _run( + self, + home: Path, + action: str, + path_has_bin: bool, + installer: str = FAKE_INSTALLER, + bin_entry: str | None = None, + extra_path: str = "", + env_home: Path | None = None, + ): stubs = home / "stubs" _write_exe(stubs / "curl", CURL_STUB) payload = home / "payload" @@ -77,18 +86,21 @@ def _run(self, home: Path, action: str, path_has_bin: bool, installer: str = FAK script = home / "scripts" / "install_agy.sh" _write_exe(script, SCRIPT.read_text()) path = f"{stubs}:/usr/bin:/bin" + if extra_path: + path = f"{extra_path}:{path}" if path_has_bin: - path = f"{home}/.local/bin:{path}" + path = f"{bin_entry or str(home) + '/.local/bin'}:{path}" return subprocess.run( ["bash", str(script), action], capture_output=True, text=True, timeout=20, - env={"HOME": str(home), "PATH": path, "CURL_PAYLOAD": str(payload)}, + env={"HOME": str(env_home or home), "PATH": path, "CURL_PAYLOAD": str(payload)}, ) def _args(self, home: Path) -> list[str]: - return (home / "agy-args").read_text().splitlines() + args = home / "agy-args" + return args.read_text().splitlines() if args.exists() else [] def test_install_skips_path_line_when_bin_dir_on_path(self, tmp_path: Path): result = self._run(tmp_path, "install", path_has_bin=True) @@ -101,6 +113,21 @@ def test_install_keeps_path_line_when_bin_dir_missing_from_path(self, tmp_path: assert "install" in self._args(tmp_path) assert "install --skip-path" not in self._args(tmp_path) + def test_install_skips_path_line_for_trailing_slash_entry(self, tmp_path: Path): + result = self._run(tmp_path, "install", path_has_bin=True, bin_entry=f"{tmp_path}/.local/bin/") + assert result.returncode == 0, result.stderr + assert "install --skip-path" in self._args(tmp_path) + + def test_install_skips_path_line_when_home_is_a_symlink(self, tmp_path: Path): + real = tmp_path / "real" + (real / ".local" / "bin").mkdir(parents=True) + link = tmp_path / "link" + link.symlink_to(real) + # HOME is the symlink, PATH holds the resolved directory + result = self._run(real, "install", path_has_bin=True, env_home=link) + assert result.returncode == 0, result.stderr + assert "install --skip-path" in self._args(real) + def test_install_warns_when_installer_layout_changed(self, tmp_path: Path): changed = FAKE_INSTALLER.replace('"$BINARY_PATH" install || true', '"$BINARY_PATH" setup || true') result = self._run(tmp_path, "install", path_has_bin=True, installer=changed) @@ -115,11 +142,31 @@ def test_install_leaves_existing_binary_alone(self, tmp_path: Path): assert "Already installed" in result.stderr assert not [a for a in self._args(tmp_path) if a.startswith("install")] + def test_install_leaves_agy_elsewhere_on_path_alone(self, tmp_path: Path): + _write_exe(tmp_path / "opt" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "install", path_has_bin=True, extra_path=f"{tmp_path}/opt") + assert result.returncode == 0, result.stderr + assert f"Already installed at {tmp_path}/opt/agy" in result.stderr + assert not (tmp_path / ".local" / "bin" / "agy").exists() + + def test_update_uses_agy_elsewhere_on_path(self, tmp_path: Path): + _write_exe(tmp_path / "opt" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "update", path_has_bin=True, extra_path=f"{tmp_path}/opt") + assert result.returncode == 0, result.stderr + assert "update" in self._args(tmp_path) + assert not (tmp_path / ".local" / "bin" / "agy").exists() + + def test_update_reports_failure(self, tmp_path: Path): + _write_exe(tmp_path / ".local" / "bin" / "agy", '#!/bin/sh\n[ "$1" = update ] && exit 3\nexit 0\n') + result = self._run(tmp_path, "update", path_has_bin=True) + assert result.returncode == 1 + assert "update' failed" in result.stderr + def test_update_runs_agy_update(self, tmp_path: Path): _write_exe(tmp_path / ".local" / "bin" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') result = self._run(tmp_path, "update", path_has_bin=True) assert result.returncode == 0, result.stderr - assert self._args(tmp_path)[0] == "update" + assert "update" in self._args(tmp_path) def test_uninstall_removes_binary(self, tmp_path: Path): binary = tmp_path / ".local" / "bin" / "agy" @@ -127,3 +174,11 @@ def test_uninstall_removes_binary(self, tmp_path: Path): result = self._run(tmp_path, "uninstall", path_has_bin=True) assert result.returncode == 0, result.stderr assert not binary.exists() + + def test_uninstall_removes_dangling_symlink(self, tmp_path: Path): + binary = tmp_path / ".local" / "bin" / "agy" + binary.parent.mkdir(parents=True) + binary.symlink_to(tmp_path / "gone") + result = self._run(tmp_path, "uninstall", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert not binary.is_symlink() diff --git a/tests/test_update_fixes.py b/tests/test_update_fixes.py index 973e4bf..5eb823f 100644 --- a/tests/test_update_fixes.py +++ b/tests/test_update_fixes.py @@ -636,7 +636,7 @@ def test_fd_candidates_field_preserved_in_catalog_entry(self): # 13. Dedicated scripts: uninstall handler contract (Issue #36) # =========================================================================== -# All 14 dedicated scripts from the catalog +# Dedicated scripts from the catalog DEDICATED_SCRIPTS = [ "agy", "claude", @@ -658,7 +658,7 @@ def test_fd_candidates_field_preserved_in_catalog_entry(self): @skip_on_windows class TestDedicatedScriptUninstallHandler: - """Tests that all 14 dedicated scripts handle the uninstall action (Issue #36).""" + """Tests that the listed dedicated scripts handle the uninstall action (Issue #36).""" @pytest.mark.parametrize("catalog_name", DEDICATED_SCRIPTS) def test_dedicated_script_handles_uninstall_action(self, catalog_name): From f58fb2f119fec04b8f33f758814e0e6c83a7d7ba Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sat, 28 Nov 2026 09:50:05 +0100 Subject: [PATCH 3/4] fix(scripts): handle relative PATH entries and leftover agy links Second review of the agy installer: - Ignore relative PATH entries when deciding whether ~/.local/bin is on PATH; they match only from the current directory. - Remove a dangling ~/.local/bin/agy before running the official installer, whose cp refuses to write through it. - On uninstall, name an agy found elsewhere on PATH instead of only reporting that ~/.local/bin/agy is absent. - Drop timeout(1) from the catalog version_command; macOS has none. - Correct the installer script count (41) in AGENTS.md and scripts/AGENTS.md. Signed-off-by: Sebastian Mendel --- AGENTS.md | 4 ++-- catalog/agy.json | 2 +- scripts/AGENTS.md | 2 +- scripts/install_agy.sh | 16 ++++++++++++++-- tests/test_install_agy.py | 25 +++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3a4ef93..bf2a593 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -77,7 +77,7 @@ This repo **is** a CLI tool manager, so the word "upgrade" is overloaded: ## Index of scoped AGENTS.md - [cli_audit/AGENTS.md](./cli_audit/AGENTS.md) — Python package (21 modules) -- [scripts/AGENTS.md](./scripts/AGENTS.md) — Installation scripts (Bash, 34 scripts) +- [scripts/AGENTS.md](./scripts/AGENTS.md) — Installation scripts (Bash, 41 scripts) - [tests/AGENTS.md](./tests/AGENTS.md) — Test suite (pytest, 14 test files) ## Commands (verified 2026-04-16) @@ -138,7 +138,7 @@ This repo **is** a CLI tool manager, so the word "upgrade" is overloaded: - **Modules:** 21 Python modules under `cli_audit/` (see [`cli_audit/AGENTS.md`](./cli_audit/AGENTS.md)) - **Catalog:** 108 JSON tool definitions under `catalog/` -- **Installers:** 34 Bash scripts under `scripts/` (see [`scripts/AGENTS.md`](./scripts/AGENTS.md)) +- **Installers:** 41 Bash scripts under `scripts/` (see [`scripts/AGENTS.md`](./scripts/AGENTS.md)) - **Phase 1:** Detection & auditing (complete) - **Phase 2:** Installation & upgrade management (complete) - **Entry point:** `audit.py` → `cli_audit` package diff --git a/catalog/agy.json b/catalog/agy.json index bf056cf..7a8f90e 100644 --- a/catalog/agy.json +++ b/catalog/agy.json @@ -7,7 +7,7 @@ "binary_name": "agy", "script": "install_agy.sh", "skip_upstream": true, - "version_command": "timeout 2 agy --version 2>/dev/null | grep -oE '[0-9]+\\.[0-9]+\\.[0-9]+' | head -1", + "version_command": "agy --version 2>/dev/null | grep -oE '[0-9]+\\.[0-9]+\\.[0-9]+' | head -1", "guide": { "display_name": "Google Antigravity CLI", "install_action": "upgrade", diff --git a/scripts/AGENTS.md b/scripts/AGENTS.md index fa6f829..e3afd7c 100644 --- a/scripts/AGENTS.md +++ b/scripts/AGENTS.md @@ -6,7 +6,7 @@ ## Overview -34 Bash scripts for installing developer tools with multiple actions: +41 Bash scripts for installing developer tools with multiple actions: - **install**: Fresh installation (default action) - **update**: Upgrade to latest version - **uninstall**: Remove installation diff --git a/scripts/install_agy.sh b/scripts/install_agy.sh index 6cd2f8a..bd1fa7a 100755 --- a/scripts/install_agy.sh +++ b/scripts/install_agy.sh @@ -43,7 +43,8 @@ bin_dir_on_path() { [ -d "$BIN_DIR" ] && resolved_bin="$(cd "$BIN_DIR" && pwd -P)" IFS=: read -r -a entries <<<"$PATH" for entry in "${entries[@]}"; do - [ -n "$entry" ] || continue + # Relative entries (., bin) depend on the current directory + case "$entry" in /*) ;; *) continue ;; esac [ "${entry%/}" = "$BIN_DIR" ] && return 0 if [ -n "$resolved_bin" ] && [ -d "$entry" ]; then resolved="$(cd "$entry" && pwd -P)" || continue @@ -76,6 +77,11 @@ install_native() { return 1 fi + # A dangling ~/.local/bin/agy makes the installer's cp refuse to write + if [ -L "$AGY_BIN" ] && [ ! -e "$AGY_BIN" ]; then + rm -f "$AGY_BIN" + fi + if bin_dir_on_path; then # The anchor is the line that hands over to `agy install`; if Google # changes it, install without the patch rather than fail @@ -148,7 +154,13 @@ upgrade_agy() { uninstall_agy() { if [ ! -e "$AGY_BIN" ] && [ ! -L "$AGY_BIN" ]; then - echo "[agy] Not installed at $AGY_BIN" >&2 + local other + other="$(command -v agy 2>/dev/null || true)" + if [ -n "$other" ]; then + echo "[agy] Not installed at $AGY_BIN; $other was installed another way, remove it by hand" >&2 + else + echo "[agy] Not installed at $AGY_BIN" >&2 + fi return 0 fi rm -f "$AGY_BIN" diff --git a/tests/test_install_agy.py b/tests/test_install_agy.py index 2370346..60a922b 100644 --- a/tests/test_install_agy.py +++ b/tests/test_install_agy.py @@ -76,6 +76,7 @@ def _run( bin_entry: str | None = None, extra_path: str = "", env_home: Path | None = None, + cwd: Path | None = None, ): stubs = home / "stubs" _write_exe(stubs / "curl", CURL_STUB) @@ -95,6 +96,7 @@ def _run( capture_output=True, text=True, timeout=20, + cwd=cwd, env={"HOME": str(env_home or home), "PATH": path, "CURL_PAYLOAD": str(payload)}, ) @@ -128,6 +130,22 @@ def test_install_skips_path_line_when_home_is_a_symlink(self, tmp_path: Path): assert result.returncode == 0, result.stderr assert "install --skip-path" in self._args(real) + def test_install_ignores_relative_path_entries(self, tmp_path: Path): + # "." resolves to ~/.local/bin only because the script runs from there + (tmp_path / ".local" / "bin").mkdir(parents=True) + result = self._run(tmp_path, "install", path_has_bin=True, bin_entry=".", cwd=tmp_path / ".local" / "bin") + assert result.returncode == 0, result.stderr + assert "install --skip-path" not in self._args(tmp_path) + + def test_install_replaces_dangling_symlink(self, tmp_path: Path): + binary = tmp_path / ".local" / "bin" / "agy" + binary.parent.mkdir(parents=True) + binary.symlink_to(tmp_path / "gone") + result = self._run(tmp_path, "install", path_has_bin=True) + assert result.returncode == 0, result.stderr + assert not binary.is_symlink() + assert "install --skip-path" in self._args(tmp_path) + def test_install_warns_when_installer_layout_changed(self, tmp_path: Path): changed = FAKE_INSTALLER.replace('"$BINARY_PATH" install || true', '"$BINARY_PATH" setup || true') result = self._run(tmp_path, "install", path_has_bin=True, installer=changed) @@ -175,6 +193,13 @@ def test_uninstall_removes_binary(self, tmp_path: Path): assert result.returncode == 0, result.stderr assert not binary.exists() + def test_uninstall_names_agy_installed_elsewhere(self, tmp_path: Path): + _write_exe(tmp_path / "opt" / "agy", "#!/bin/sh\n") + result = self._run(tmp_path, "uninstall", path_has_bin=True, extra_path=f"{tmp_path}/opt") + assert result.returncode == 0, result.stderr + assert f"{tmp_path}/opt/agy was installed another way" in result.stderr + assert (tmp_path / "opt" / "agy").exists() + def test_uninstall_removes_dangling_symlink(self, tmp_path: Path): binary = tmp_path / ".local" / "bin" / "agy" binary.parent.mkdir(parents=True) From 5067c0f1ecd43feb0a16e1c71ceb06eb6565ba79 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sat, 28 Nov 2026 10:03:32 +0100 Subject: [PATCH 4/4] fix(scripts): act on the agy on PATH and skip environment bins CodeRabbit review of the agy installer: - Look up agy on PATH first and fall back to ~/.local/bin/agy, so update acts on the copy a plain `agy` runs and the audit reports. - Skip virtualenv and conda bins in that lookup, with the patterns of detect_all_installations in lib/capability.sh. - Put ~/.local/bin on PATH for the snapshot refresh, so the audit sees a fresh install when the directory is not on PATH yet. - CHANGELOG: name the unpatched fallback that adds the PATH line. Signed-off-by: Sebastian Mendel --- CHANGELOG.md | 2 +- scripts/install_agy.sh | 22 +++++++++++++++++----- tests/test_install_agy.py | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed2bf6..414753c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] ### Added -- `agy` catalog entry (`catalog/agy.json` + `scripts/install_agy.sh`): the Google Antigravity CLI, installed with the official installer from antigravity.google. When `~/.local/bin` is already on `PATH`, the installer passes `--skip-path` so `~/.bashrc` and `~/.profile` get no extra PATH line; updates run `agy update`. +- `agy` catalog entry (`catalog/agy.json` + `scripts/install_agy.sh`): the Google Antigravity CLI, installed with the official installer from antigravity.google. When `~/.local/bin` is already on `PATH`, the installer passes `--skip-path` so `~/.bashrc` and `~/.profile` get no extra PATH line (if Google changes the line it patches, it warns and runs the unpatched installer, which adds that line); updates run `agy update`. - `pi` catalog entry: the pi coding agent, installed from npm as `@earendil-works/pi-coding-agent` (the earlier `@mariozechner/pi-coding-agent` package is deprecated); upstream version from GitHub `earendil-works/pi`. - `jules` catalog entry: the Google Jules CLI (`@google/jules`), Google's asynchronous coding agent, with bash completion from `jules completion bash`. - `herdr` catalog entry (`catalog/herdr.json`): terminal multiplexer for coding agents, installed as a raw linux binary from GitHub releases (x86_64, aarch64) with bash completion. diff --git a/scripts/install_agy.sh b/scripts/install_agy.sh index bd1fa7a..d33444d 100755 --- a/scripts/install_agy.sh +++ b/scripts/install_agy.sh @@ -13,13 +13,24 @@ AGY_BIN="$BIN_DIR/agy" # curl may only use https, including on redirects CURL_HTTPS_ONLY=(--proto '=https') -# The agy to act on: ~/.local/bin/agy (where the official installer puts it), -# else the first agy on PATH (an install with --dir or by another method) +# The agy to act on: the first agy on PATH, which is the copy a plain `agy` +# runs and the audit reports, else ~/.local/bin/agy (where the official +# installer puts it). Virtualenv and conda bins are environments, not +# installations; the patterns follow detect_all_installations in +# lib/capability.sh. find_agy() { + local candidate + while IFS= read -r candidate; do + case "$candidate" in + */venv/bin/*|*/.venv/bin/*|*/venvs/*/bin/*|*/.venvs/*/bin/*|*/virtualenvs/*/bin/*|*/.virtualenvs/*/bin/*) continue ;; + */envs/*/bin/*|*/conda/*/bin/*|*/miniconda*/bin/*|*/anaconda*/bin/*) continue ;; + */env/bin/*) continue ;; + esac + printf '%s\n' "$candidate" + return 0 + done < <(type -P -a agy 2>/dev/null || true) if [ -x "$AGY_BIN" ]; then printf '%s\n' "$AGY_BIN" - else - command -v agy 2>/dev/null || true fi } @@ -104,7 +115,8 @@ install_native() { refresh_agy_snapshot() { if [ -f "$DIR/lib/install_strategy.sh" ]; then . "$DIR/lib/install_strategy.sh" - refresh_snapshot "agy" 2>/dev/null || true + # The audit looks on PATH; let it see a fresh ~/.local/bin/agy + PATH="$BIN_DIR:$PATH" refresh_snapshot "agy" 2>/dev/null || true fi } diff --git a/tests/test_install_agy.py b/tests/test_install_agy.py index 60a922b..51ebdc5 100644 --- a/tests/test_install_agy.py +++ b/tests/test_install_agy.py @@ -167,6 +167,22 @@ def test_install_leaves_agy_elsewhere_on_path_alone(self, tmp_path: Path): assert f"Already installed at {tmp_path}/opt/agy" in result.stderr assert not (tmp_path / ".local" / "bin" / "agy").exists() + def test_install_ignores_agy_in_a_virtualenv(self, tmp_path: Path): + _write_exe(tmp_path / "proj" / ".venv" / "bin" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "install", path_has_bin=True, extra_path=f"{tmp_path}/proj/.venv/bin") + assert result.returncode == 0, result.stderr + assert "install --skip-path" in self._args(tmp_path) + assert (tmp_path / ".local" / "bin" / "agy").exists() + + def test_update_prefers_the_agy_on_path(self, tmp_path: Path): + # ~/.local/bin is not on PATH; the copy on PATH is the one a plain agy runs + _write_exe(tmp_path / ".local" / "bin" / "agy", '#!/bin/sh\necho "local $*" >> "$HOME/agy-args"\n') + _write_exe(tmp_path / "opt" / "agy", '#!/bin/sh\necho "opt $*" >> "$HOME/agy-args"\n') + result = self._run(tmp_path, "update", path_has_bin=False, extra_path=f"{tmp_path}/opt") + assert result.returncode == 0, result.stderr + assert "opt update" in self._args(tmp_path) + assert "local update" not in self._args(tmp_path) + def test_update_uses_agy_elsewhere_on_path(self, tmp_path: Path): _write_exe(tmp_path / "opt" / "agy", '#!/bin/sh\necho "$*" >> "$HOME/agy-args"\n') result = self._run(tmp_path, "update", path_has_bin=True, extra_path=f"{tmp_path}/opt")