code-aide 1.20.1__tar.gz → 1.21.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_aide-1.20.1 → code_aide-1.21.1}/PKG-INFO +23 -1
- {code_aide-1.20.1 → code_aide-1.21.1}/README.md +22 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/TODO.md +18 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/script-archive/claude-install.sh +2 -1
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/__init__.py +1 -1
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/app_bundle.py +6 -2
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/commands_actions.py +1 -1
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/data/tools.json +11 -1
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/install.py +8 -0
- code_aide-1.21.1/src/code_aide/macos_quarantine.py +95 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/operation_handlers.py +8 -5
- code_aide-1.21.1/tests/conftest.py +23 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_commands_actions.py +35 -3
- code_aide-1.21.1/tests/test_macos_quarantine.py +218 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_operations.py +7 -0
- code_aide-1.21.1/tests/test_quarantine_integration.py +133 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/.github/workflows/ci.yml +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/.github/workflows/publish.yml +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/.gitignore +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/.gitlab-ci.yml +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/.pre-commit-config.yaml +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/AGENTS.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/CLAUDE.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/LICENSE +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/Makefile +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/pyproject.toml +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/script-archive/README.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/script-archive/amp-install.sh +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/script-archive/antigravity-install.sh +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/script-archive/cursor-install.sh +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/2026-05-03-qwen3.6-code-quality-analysis-original.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/2026-05-03-qwen3.6-code-quality-analysis.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/antigravity-cli-integration.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/auto-migrate-deprecated-installs.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/claude-native-installer-migration.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/missing-coding-llm-cli-tools.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/pre-commit-uv-setup.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/remove-bundled-version-baseline.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/specs/unify-upgrade-eligibility-with-shared-evaluator.md +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/__main__.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/commands_tools.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/config.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/console.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/constants.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/detection.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/detection_types.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/entry.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/install_types.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/npm_cache.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/operations.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/package_info.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/package_managers.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/path_copies.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/prereqs.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/release_assets.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/status.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/status_print.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/tool_groups.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/src/code_aide/versions.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_app_bundle.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_commands_tools.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_config.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_console.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_constants.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_detection.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_entry.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_error_paths.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_install.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_install_types.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_npm_cache.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_package_info.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_package_managers.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_path_copies.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_prereqs.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_release_assets.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_status.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/tests/test_versions.py +0 -0
- {code_aide-1.20.1 → code_aide-1.21.1}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: code-aide
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.21.1
|
|
4
4
|
Summary: Manage AI coding CLI tools (Claude, Antigravity, Copilot, Cursor, Gemini, Amp, Codex)
|
|
5
5
|
Project-URL: Homepage, https://github.com/dajobe/code-aide
|
|
6
6
|
Project-URL: Repository, https://github.com/dajobe/code-aide
|
|
@@ -172,6 +172,7 @@ consulted when the relevant install method or platform applies.
|
|
|
172
172
|
| `install_sha256` | script | SHA-256 of the install script body — required for verified installs |
|
|
173
173
|
| `download_sha256` | Cache | SHA-256 of the downloaded tarball for direct_download tools; recorded by `update-versions`, verified on install |
|
|
174
174
|
| `install_script_path_prepend` | script | Extra directories prepended to `PATH` when the install script runs (e.g. `["~/.local/bin"]`) |
|
|
175
|
+
| `macos_quarantine_paths` | script | Tool-owned paths for macOS quarantine cleanup; expands `~` and resolves executable symlinks |
|
|
175
176
|
| `download_url_template` | direct | URL template with `{version}`, `{os}`, `{arch}` placeholders |
|
|
176
177
|
| `install_dir` | direct | Directory to extract into; supports `{version}` |
|
|
177
178
|
| `bin_dir` | direct | Directory where symlinks for `command` are created (e.g. `~/.local/bin`) |
|
|
@@ -272,6 +273,27 @@ uv run pytest tests/test_install.py::TestDetectOsArch -v
|
|
|
272
273
|
|
|
273
274
|
Apache-2.0
|
|
274
275
|
|
|
276
|
+
## macOS quarantine during installation
|
|
277
|
+
|
|
278
|
+
After successful installs and upgrades, code-aide removes the
|
|
279
|
+
`com.apple.quarantine` attribute from the installed npm package (including
|
|
280
|
+
nested native helpers), direct-download directory, or verified app bundle.
|
|
281
|
+
Script installs clear their configured artifact paths and resolved command.
|
|
282
|
+
Homebrew upgrades clear the selected formula or cask directory. Symlinks inside
|
|
283
|
+
these directories are not followed into other installations.
|
|
284
|
+
|
|
285
|
+
This addresses Gatekeeper prompts that can block unattended use, including
|
|
286
|
+
Codex's `codex-code-mode-host` helper and the resulting "timed out negotiating
|
|
287
|
+
with the code-mode host" error when quarantine is the cause. Helpers do not need
|
|
288
|
+
to be on `PATH`. Other causes of that timeout are unaffected.
|
|
289
|
+
|
|
290
|
+
Cleanup preserves other extended attributes and does not change system-wide
|
|
291
|
+
Gatekeeper settings. It runs without `sudo`; permission failures are reported as
|
|
292
|
+
install or upgrade failures, leaving the installed files in place. Dry runs and
|
|
293
|
+
non-macOS hosts do not change extended attributes. Existing installs can be
|
|
294
|
+
processed with `code-aide install --force TOOL` or `code-aide upgrade TOOL`.
|
|
295
|
+
Updates performed independently by a tool's own updater are outside this step.
|
|
296
|
+
|
|
275
297
|
## npm download cache lifetime
|
|
276
298
|
|
|
277
299
|
Standalone install, upgrade, removal (including migration), and installation
|
|
@@ -145,6 +145,7 @@ consulted when the relevant install method or platform applies.
|
|
|
145
145
|
| `install_sha256` | script | SHA-256 of the install script body — required for verified installs |
|
|
146
146
|
| `download_sha256` | Cache | SHA-256 of the downloaded tarball for direct_download tools; recorded by `update-versions`, verified on install |
|
|
147
147
|
| `install_script_path_prepend` | script | Extra directories prepended to `PATH` when the install script runs (e.g. `["~/.local/bin"]`) |
|
|
148
|
+
| `macos_quarantine_paths` | script | Tool-owned paths for macOS quarantine cleanup; expands `~` and resolves executable symlinks |
|
|
148
149
|
| `download_url_template` | direct | URL template with `{version}`, `{os}`, `{arch}` placeholders |
|
|
149
150
|
| `install_dir` | direct | Directory to extract into; supports `{version}` |
|
|
150
151
|
| `bin_dir` | direct | Directory where symlinks for `command` are created (e.g. `~/.local/bin`) |
|
|
@@ -245,6 +246,27 @@ uv run pytest tests/test_install.py::TestDetectOsArch -v
|
|
|
245
246
|
|
|
246
247
|
Apache-2.0
|
|
247
248
|
|
|
249
|
+
## macOS quarantine during installation
|
|
250
|
+
|
|
251
|
+
After successful installs and upgrades, code-aide removes the
|
|
252
|
+
`com.apple.quarantine` attribute from the installed npm package (including
|
|
253
|
+
nested native helpers), direct-download directory, or verified app bundle.
|
|
254
|
+
Script installs clear their configured artifact paths and resolved command.
|
|
255
|
+
Homebrew upgrades clear the selected formula or cask directory. Symlinks inside
|
|
256
|
+
these directories are not followed into other installations.
|
|
257
|
+
|
|
258
|
+
This addresses Gatekeeper prompts that can block unattended use, including
|
|
259
|
+
Codex's `codex-code-mode-host` helper and the resulting "timed out negotiating
|
|
260
|
+
with the code-mode host" error when quarantine is the cause. Helpers do not need
|
|
261
|
+
to be on `PATH`. Other causes of that timeout are unaffected.
|
|
262
|
+
|
|
263
|
+
Cleanup preserves other extended attributes and does not change system-wide
|
|
264
|
+
Gatekeeper settings. It runs without `sudo`; permission failures are reported as
|
|
265
|
+
install or upgrade failures, leaving the installed files in place. Dry runs and
|
|
266
|
+
non-macOS hosts do not change extended attributes. Existing installs can be
|
|
267
|
+
processed with `code-aide install --force TOOL` or `code-aide upgrade TOOL`.
|
|
268
|
+
Updates performed independently by a tool's own updater are outside this step.
|
|
269
|
+
|
|
248
270
|
## npm download cache lifetime
|
|
249
271
|
|
|
250
272
|
Standalone install, upgrade, removal (including migration), and installation
|
|
@@ -11,6 +11,7 @@ All items below are deferred; none are scheduled.
|
|
|
11
11
|
| 2 | Cross-distro package detection | Med | High | Only Gentoo supported; other Linux distros get nothing |
|
|
12
12
|
| 3 | Split large modules | Low | High | Refactoring only; no behavior change |
|
|
13
13
|
| 4 | Tests for edge cases | Med | Med | PATH oddities, more version parsing corners |
|
|
14
|
+
| 5 | Stop Antigravity profile edits | Low | Med | Installer appends PATH lines to shell profiles |
|
|
14
15
|
|
|
15
16
|
## CLI and Automation UX
|
|
16
17
|
|
|
@@ -23,6 +24,23 @@ All items below are deferred; none are scheduled.
|
|
|
23
24
|
where practical; note that non-Gentoo system installs currently report "up to
|
|
24
25
|
date" because no available version is detectable.
|
|
25
26
|
|
|
27
|
+
## Installer Side Effects
|
|
28
|
+
|
|
29
|
+
- [ ] Figure out a way to stop the Antigravity CLI installer from editing shell
|
|
30
|
+
profiles. Installing `agy` appended `# Added by Antigravity CLI installer` and
|
|
31
|
+
`export PATH="$HOME/.local/bin:$PATH"` to `~/.bash_profile` and `~/.profile`.
|
|
32
|
+
On hosts where those files are symlinks into a dotfiles repository, this
|
|
33
|
+
dirties the repository and duplicates a PATH entry the dotfiles already set.
|
|
34
|
+
- `install.sh` itself does not touch profiles; its last step runs `agy
|
|
35
|
+
install` (or `agy install --dir DIR`) with no way to pass flags through.
|
|
36
|
+
- `agy install` accepts `--skip-path` (no PATH appending) and `--skip-aliases`
|
|
37
|
+
(no alias purging), so the fix is likely to get that call made with
|
|
38
|
+
`--skip-path`: for example, replicate the script's download, checksum, and
|
|
39
|
+
extract steps in code-aide and run `agy install --skip-path` ourselves, or
|
|
40
|
+
ask upstream to honor a flag or environment variable in `install.sh`.
|
|
41
|
+
- Check whether `agy` self-updates (`self_updates: true`) re-run the profile
|
|
42
|
+
step, and whether `code-aide upgrade` hits the same path.
|
|
43
|
+
|
|
26
44
|
## Maintainability and Tests
|
|
27
45
|
|
|
28
46
|
- [ ] Split larger modules into smaller focused files where practical
|
|
@@ -223,7 +223,8 @@ chmod +x "$binary_path"
|
|
|
223
223
|
# Run claude install to set up launcher and shell integration
|
|
224
224
|
echo "Setting up Claude Code..."
|
|
225
225
|
install_code=0
|
|
226
|
-
|
|
226
|
+
# From the download folder, so the result doesn't depend on where the script was started
|
|
227
|
+
(cd "$DOWNLOAD_DIR" && exec "$binary_path" install ${TARGET:+"$TARGET"}) || install_code=$?
|
|
227
228
|
|
|
228
229
|
# Clean up downloaded file
|
|
229
230
|
rm -f "$binary_path"
|
|
@@ -25,7 +25,7 @@ import time
|
|
|
25
25
|
import urllib.request
|
|
26
26
|
from typing import Any, Dict, List, Optional
|
|
27
27
|
|
|
28
|
-
from code_aide import __version__
|
|
28
|
+
from code_aide import __version__, macos_quarantine
|
|
29
29
|
from code_aide.console import error, info, success, warning
|
|
30
30
|
from code_aide.detection_types import DetectedInstallInfo
|
|
31
31
|
from code_aide.install_types import InstallMethod, InstallType, parse_install_type
|
|
@@ -410,7 +410,7 @@ def install_app_bundle(
|
|
|
410
410
|
and (dryrun or signature_ok(bundle))
|
|
411
411
|
):
|
|
412
412
|
info(f"{name} {version} is already active at {link}")
|
|
413
|
-
return
|
|
413
|
+
return dryrun or macos_quarantine.clear_quarantine(bundle)
|
|
414
414
|
|
|
415
415
|
if dryrun:
|
|
416
416
|
info(f"[DRYRUN] Would download: {url}")
|
|
@@ -439,7 +439,11 @@ def install_app_bundle(
|
|
|
439
439
|
if not ensure_app_stopped(tool_config, f"switch {name} to {version}"):
|
|
440
440
|
return False
|
|
441
441
|
if staged_bundle and staging:
|
|
442
|
+
if not macos_quarantine.clear_quarantine(staged_bundle):
|
|
443
|
+
return False
|
|
442
444
|
_move_into_place(staged_bundle, bundle, staging)
|
|
445
|
+
elif not macos_quarantine.clear_quarantine(bundle):
|
|
446
|
+
return False
|
|
443
447
|
_repoint_link(link, bundle)
|
|
444
448
|
except (OSError, RuntimeError, subprocess.CalledProcessError) as exc:
|
|
445
449
|
error(f"Failed to install {name}: {exc}")
|
|
@@ -154,7 +154,7 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
154
154
|
if tools_to_upgrade:
|
|
155
155
|
info(f"Upgrading out-of-date tools: {', '.join(tools_to_upgrade)}")
|
|
156
156
|
else:
|
|
157
|
-
info("
|
|
157
|
+
info("No tools are eligible for automatic upgrade")
|
|
158
158
|
return
|
|
159
159
|
|
|
160
160
|
tools_to_upgrade = resolve_tool_names(tools_to_upgrade, TOOLS)
|
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
"command": "claude",
|
|
34
34
|
"install_type": "script",
|
|
35
35
|
"install_url": "https://claude.ai/install.sh",
|
|
36
|
-
"
|
|
36
|
+
"macos_quarantine_paths": [
|
|
37
|
+
"~/.local/bin/claude"
|
|
38
|
+
],
|
|
39
|
+
"install_sha256": "2c5506d110560bf618bbe88f678f2c2a0047c86a9c6585fc84976120b1de0b44",
|
|
37
40
|
"version_url": "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/latest",
|
|
38
41
|
"prerequisites": [],
|
|
39
42
|
"min_node_version": null,
|
|
@@ -72,6 +75,9 @@
|
|
|
72
75
|
],
|
|
73
76
|
"install_type": "script",
|
|
74
77
|
"install_url": "https://antigravity.google/cli/install.sh",
|
|
78
|
+
"macos_quarantine_paths": [
|
|
79
|
+
"~/.local/bin/agy"
|
|
80
|
+
],
|
|
75
81
|
"install_sha256": "62966c07365423bd4dc209355060744058fb30d60f5323e2d360e39de64e5042",
|
|
76
82
|
"version_manifest_url_template": "https://antigravity-cli-auto-updater-974169037036.us-central1.run.app/manifests/{platform}.json",
|
|
77
83
|
"prerequisites": [],
|
|
@@ -89,6 +95,10 @@
|
|
|
89
95
|
"command": "amp",
|
|
90
96
|
"install_type": "script",
|
|
91
97
|
"install_url": "https://ampcode.com/install.sh",
|
|
98
|
+
"macos_quarantine_paths": [
|
|
99
|
+
"~/.amp/bin",
|
|
100
|
+
"~/.local/bin/amp"
|
|
101
|
+
],
|
|
92
102
|
"install_sha256": "83b0a61b09cb653b92e47e039e3aba8bda60c62c0eea6e1467c1b1b12c258cc9",
|
|
93
103
|
"install_script_path_prepend": [
|
|
94
104
|
"~/.local/bin"
|
|
@@ -28,6 +28,7 @@ from code_aide.console import (
|
|
|
28
28
|
warning,
|
|
29
29
|
)
|
|
30
30
|
from code_aide.npm_cache import npm_cache_environment, stop_process_group
|
|
31
|
+
from code_aide import macos_quarantine
|
|
31
32
|
from code_aide.install_types import InstallType, get_tool_install_type
|
|
32
33
|
from code_aide.release_assets import (
|
|
33
34
|
install_marker_matches,
|
|
@@ -403,6 +404,9 @@ def install_direct_download(
|
|
|
403
404
|
return False
|
|
404
405
|
_extract_tarball(tarball_data, install_dir, cfg, version)
|
|
405
406
|
|
|
407
|
+
if not macos_quarantine.clear_quarantine(install_dir):
|
|
408
|
+
return False
|
|
409
|
+
|
|
406
410
|
os.makedirs(bin_dir, exist_ok=True)
|
|
407
411
|
symlinks = cfg.get("symlinks", {})
|
|
408
412
|
link_paths = []
|
|
@@ -531,6 +535,8 @@ def install_tool(
|
|
|
531
535
|
info(f"[DRYRUN] Would install npm package: {npm_package}")
|
|
532
536
|
else:
|
|
533
537
|
run_command(["npm", "install", "-g", npm_package], check=True)
|
|
538
|
+
if not macos_quarantine.clear_npm_quarantine(npm_package):
|
|
539
|
+
return InstallOutcome(False)
|
|
534
540
|
npm_bin_dir = get_npm_global_bin_dir()
|
|
535
541
|
if npm_bin_dir:
|
|
536
542
|
bin_dirs = (npm_bin_dir,)
|
|
@@ -553,6 +559,8 @@ def install_tool(
|
|
|
553
559
|
if dryrun:
|
|
554
560
|
success(f"{tool_config['name']} verification passed")
|
|
555
561
|
else:
|
|
562
|
+
if not macos_quarantine.clear_script_quarantine(tool_config):
|
|
563
|
+
return InstallOutcome(False)
|
|
556
564
|
success(f"{tool_config['name']} installed successfully")
|
|
557
565
|
info(tool_config["next_steps"])
|
|
558
566
|
if "docs_url" in tool_config:
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Remove quarantine from tool-owned install artifacts on macOS."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import platform
|
|
5
|
+
import re
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from code_aide.console import info, run_command, warning
|
|
11
|
+
|
|
12
|
+
QUARANTINE = "com.apple.quarantine"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def clear_quarantine(path: str) -> bool:
|
|
16
|
+
"""Clear only quarantine, without following symlinks inside an install tree.
|
|
17
|
+
|
|
18
|
+
Callers supply a package directory, verified bundle, or resolved executable,
|
|
19
|
+
never a shared bin directory. No sudo or interactive approval is attempted.
|
|
20
|
+
"""
|
|
21
|
+
if platform.system() != "Darwin":
|
|
22
|
+
return True
|
|
23
|
+
try:
|
|
24
|
+
# macOS Python does not expose os.removexattr. Apple's utility treats
|
|
25
|
+
# missing attributes as success with -r; -s never dereferences links.
|
|
26
|
+
run_command(["/usr/bin/xattr", "-r", "-d", "-s", QUARANTINE, path], timeout=60)
|
|
27
|
+
except (OSError, subprocess.SubprocessError) as exc:
|
|
28
|
+
detail = (
|
|
29
|
+
exc.stderr if isinstance(exc, subprocess.CalledProcessError) else str(exc)
|
|
30
|
+
)
|
|
31
|
+
warning(f"Could not clear macOS quarantine at {path}: {detail}")
|
|
32
|
+
warning("Installation files remain in place; fix their permissions and retry.")
|
|
33
|
+
return False
|
|
34
|
+
info(f"Cleared macOS quarantine from installed artifacts in {path}")
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def clear_npm_quarantine(package: str, prefix_args: list[str] | None = None) -> bool:
|
|
39
|
+
"""Clear the installed package, including its nested native dependencies."""
|
|
40
|
+
if platform.system() != "Darwin":
|
|
41
|
+
return True
|
|
42
|
+
# Only package names, never paths, tags, URLs, or a whole npm scope.
|
|
43
|
+
if not re.fullmatch(r"(?:@[\w.-]+/)?[\w.-]+", package) or any(
|
|
44
|
+
part in (".", "..") for part in package.lstrip("@").split("/")
|
|
45
|
+
):
|
|
46
|
+
warning(
|
|
47
|
+
f"Cannot locate installed npm package for quarantine cleanup: {package}"
|
|
48
|
+
)
|
|
49
|
+
return False
|
|
50
|
+
try:
|
|
51
|
+
root = run_command(
|
|
52
|
+
["npm", "root", "-g", *(prefix_args or [])], timeout=30
|
|
53
|
+
).stdout.strip()
|
|
54
|
+
if not os.path.isabs(root):
|
|
55
|
+
raise ValueError("npm did not report an absolute global package directory")
|
|
56
|
+
target = os.path.join(root, package)
|
|
57
|
+
if os.path.realpath(target) != os.path.join(os.path.realpath(root), package):
|
|
58
|
+
raise ValueError(
|
|
59
|
+
"the installed npm package is linked outside its directory"
|
|
60
|
+
)
|
|
61
|
+
return clear_quarantine(target)
|
|
62
|
+
except (OSError, ValueError, subprocess.SubprocessError) as exc:
|
|
63
|
+
warning(f"Could not clear macOS quarantine for {package}: {exc}")
|
|
64
|
+
return False
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def clear_script_quarantine(cfg: dict[str, Any]) -> bool:
|
|
68
|
+
"""Clear configured script artifacts and the resolved command, if present."""
|
|
69
|
+
if platform.system() != "Darwin":
|
|
70
|
+
return True
|
|
71
|
+
paths = [os.path.expanduser(p) for p in cfg.get("macos_quarantine_paths", [])]
|
|
72
|
+
command = shutil.which(cfg["command"])
|
|
73
|
+
if command:
|
|
74
|
+
paths.append(command)
|
|
75
|
+
succeeded = True
|
|
76
|
+
for path in dict.fromkeys(paths):
|
|
77
|
+
if os.path.exists(path):
|
|
78
|
+
succeeded = clear_quarantine(os.path.realpath(path)) and succeeded
|
|
79
|
+
return succeeded
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def clear_brew_quarantine(package: str, *, cask: bool) -> bool:
|
|
83
|
+
"""Clear one Homebrew package's artifacts after a successful upgrade."""
|
|
84
|
+
if platform.system() != "Darwin":
|
|
85
|
+
return True
|
|
86
|
+
try:
|
|
87
|
+
path = run_command(
|
|
88
|
+
["brew", "--caskroom" if cask else "--prefix", package], timeout=30
|
|
89
|
+
).stdout.strip()
|
|
90
|
+
if not os.path.isabs(path) or os.path.basename(path) != package.split("/")[-1]:
|
|
91
|
+
raise ValueError("Homebrew did not report the requested package directory")
|
|
92
|
+
return clear_quarantine(os.path.realpath(path))
|
|
93
|
+
except (OSError, ValueError, subprocess.SubprocessError) as exc:
|
|
94
|
+
warning(f"Could not clear macOS quarantine for {package}: {exc}")
|
|
95
|
+
return False
|
|
@@ -32,6 +32,7 @@ from code_aide.app_bundle import (
|
|
|
32
32
|
remove_app_bundle,
|
|
33
33
|
)
|
|
34
34
|
from code_aide.constants import TOOLS
|
|
35
|
+
from code_aide import macos_quarantine
|
|
35
36
|
from code_aide.path_copies import npm_prefix_for
|
|
36
37
|
from code_aide.install_types import (
|
|
37
38
|
InstallMethod,
|
|
@@ -78,7 +79,7 @@ def _upgrade_brew_formula(_name: str, cfg: Dict, detail: Optional[str]) -> bool:
|
|
|
78
79
|
error(f"No brew formula detected for {cfg['name']}")
|
|
79
80
|
return False
|
|
80
81
|
run_command(["brew", "upgrade", detail], check=True, capture=False)
|
|
81
|
-
return
|
|
82
|
+
return macos_quarantine.clear_brew_quarantine(detail, cask=False)
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
def _upgrade_brew_cask(_name: str, cfg: Dict, detail: Optional[str]) -> bool:
|
|
@@ -88,7 +89,7 @@ def _upgrade_brew_cask(_name: str, cfg: Dict, detail: Optional[str]) -> bool:
|
|
|
88
89
|
if not _cask_app_stopped(cfg, detail, "upgrade it"):
|
|
89
90
|
return False
|
|
90
91
|
run_command(["brew", "upgrade", "--cask", detail], check=True, capture=False)
|
|
91
|
-
return True
|
|
92
|
+
return macos_quarantine.clear_brew_quarantine(detail, cask=True)
|
|
92
93
|
|
|
93
94
|
|
|
94
95
|
def _upgrade_npm(_name: str, cfg: Dict, detail: Optional[str]) -> bool:
|
|
@@ -96,22 +97,24 @@ def _upgrade_npm(_name: str, cfg: Dict, detail: Optional[str]) -> bool:
|
|
|
96
97
|
if not npm_package:
|
|
97
98
|
error(f"No npm package configured for {cfg['name']}")
|
|
98
99
|
return False
|
|
100
|
+
prefix_args = _npm_prefix_args(cfg)
|
|
99
101
|
run_command(
|
|
100
|
-
["npm", "install", "-g", *
|
|
102
|
+
["npm", "install", "-g", *prefix_args, f"{npm_package}@latest"],
|
|
101
103
|
check=True,
|
|
102
104
|
)
|
|
103
|
-
return
|
|
105
|
+
return macos_quarantine.clear_npm_quarantine(npm_package, prefix_args)
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
def _upgrade_script(name: str, cfg: Dict, _detail: Optional[str]) -> bool:
|
|
107
109
|
if get_tool_install_type(cfg) == InstallType.DIRECT_DOWNLOAD:
|
|
108
110
|
return install_direct_download(name, cfg)
|
|
109
|
-
|
|
111
|
+
installed = run_install_script(
|
|
110
112
|
cfg["install_url"],
|
|
111
113
|
cfg["name"],
|
|
112
114
|
cfg.get("install_sha256"),
|
|
113
115
|
env=get_install_script_env(cfg),
|
|
114
116
|
)
|
|
117
|
+
return installed and macos_quarantine.clear_script_quarantine(cfg)
|
|
115
118
|
|
|
116
119
|
|
|
117
120
|
def _upgrade_direct_download(name: str, cfg: Dict, _detail: Optional[str]) -> bool:
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Keep mocked installer tests from inspecting or modifying real installations."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from code_aide import macos_quarantine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@pytest.fixture(autouse=True)
|
|
9
|
+
def isolate_quarantine_cleanup(request, monkeypatch):
|
|
10
|
+
# These tests mock installers, sometimes using names of real local tools.
|
|
11
|
+
# Quarantine behavior is exercised with isolated artifacts in its own tests.
|
|
12
|
+
if request.module.__name__ in {
|
|
13
|
+
"test_macos_quarantine",
|
|
14
|
+
"test_quarantine_integration",
|
|
15
|
+
}:
|
|
16
|
+
return
|
|
17
|
+
for name in (
|
|
18
|
+
"clear_quarantine",
|
|
19
|
+
"clear_npm_quarantine",
|
|
20
|
+
"clear_script_quarantine",
|
|
21
|
+
"clear_brew_quarantine",
|
|
22
|
+
):
|
|
23
|
+
monkeypatch.setattr(macos_quarantine, name, lambda *args, **kwargs: True)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Unit tests for mutating CLI commands."""
|
|
2
2
|
|
|
3
|
+
import argparse
|
|
3
4
|
import contextlib
|
|
4
5
|
import io
|
|
5
6
|
import sys
|
|
@@ -387,7 +388,7 @@ class TestCmdUpgrade(unittest.TestCase):
|
|
|
387
388
|
commands_actions.cmd_upgrade(args)
|
|
388
389
|
|
|
389
390
|
output = buf.getvalue()
|
|
390
|
-
self.assertIn("
|
|
391
|
+
self.assertIn("No tools are eligible for automatic upgrade", output)
|
|
391
392
|
mock_upgrade.assert_not_called()
|
|
392
393
|
|
|
393
394
|
def test_default_upgrade_skips_tool_when_installed_is_newer_than_catalog(self):
|
|
@@ -421,7 +422,38 @@ class TestCmdUpgrade(unittest.TestCase):
|
|
|
421
422
|
commands_actions.cmd_upgrade(args)
|
|
422
423
|
|
|
423
424
|
output = buf.getvalue()
|
|
424
|
-
self.assertIn("
|
|
425
|
+
self.assertIn("No tools are eligible for automatic upgrade", output)
|
|
426
|
+
mock_upgrade.assert_not_called()
|
|
427
|
+
|
|
428
|
+
def test_default_upgrade_skips_outdated_self_updating_tool(self):
|
|
429
|
+
tools = {
|
|
430
|
+
"selfup": {
|
|
431
|
+
"name": "Self-updating Tool",
|
|
432
|
+
"command": "selfup",
|
|
433
|
+
"install_type": "script",
|
|
434
|
+
"latest_version": "2.0.0",
|
|
435
|
+
"self_updates": True,
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
args = argparse.Namespace(tools=[])
|
|
439
|
+
|
|
440
|
+
with (
|
|
441
|
+
mock.patch.dict(constants._TOOLS_DATA, tools, clear=True),
|
|
442
|
+
mock.patch.object(commands_actions, "ensure_versions_cache"),
|
|
443
|
+
mock.patch(
|
|
444
|
+
"code_aide.status.detect_install_method",
|
|
445
|
+
return_value={"method": "script", "detail": None},
|
|
446
|
+
),
|
|
447
|
+
mock.patch(
|
|
448
|
+
"code_aide.status.get_tool_status",
|
|
449
|
+
return_value={"installed": True, "version": "1.0.0"},
|
|
450
|
+
),
|
|
451
|
+
mock.patch.object(commands_actions, "upgrade_tool") as mock_upgrade,
|
|
452
|
+
contextlib.redirect_stdout(io.StringIO()) as output,
|
|
453
|
+
):
|
|
454
|
+
commands_actions.cmd_upgrade(args)
|
|
455
|
+
|
|
456
|
+
self.assertIn("No tools are eligible for automatic upgrade", output.getvalue())
|
|
425
457
|
mock_upgrade.assert_not_called()
|
|
426
458
|
|
|
427
459
|
def test_default_upgrade_skips_system_managed_tool(self):
|
|
@@ -462,7 +494,7 @@ class TestCmdUpgrade(unittest.TestCase):
|
|
|
462
494
|
commands_actions.cmd_upgrade(args)
|
|
463
495
|
|
|
464
496
|
output = buf.getvalue()
|
|
465
|
-
self.assertIn("
|
|
497
|
+
self.assertIn("No tools are eligible for automatic upgrade", output)
|
|
466
498
|
mock_upgrade.assert_not_called()
|
|
467
499
|
|
|
468
500
|
def test_default_upgrade_refreshes_versions_cache(self):
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""Quarantine cleanup boundaries and installer integration."""
|
|
2
|
+
|
|
3
|
+
import platform
|
|
4
|
+
import subprocess
|
|
5
|
+
from unittest import mock
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from code_aide import constants, install, operation_handlers
|
|
10
|
+
from code_aide import macos_quarantine as quarantine
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture
|
|
14
|
+
def darwin(monkeypatch):
|
|
15
|
+
monkeypatch.setattr(quarantine.platform, "system", lambda: "Darwin")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.parametrize("system", ["Linux", "FreeBSD"])
|
|
19
|
+
def test_other_platforms_do_not_probe_or_modify(system, monkeypatch):
|
|
20
|
+
monkeypatch.setattr(quarantine.platform, "system", lambda: system)
|
|
21
|
+
with mock.patch.object(quarantine, "run_command") as run:
|
|
22
|
+
assert quarantine.clear_quarantine("/missing")
|
|
23
|
+
assert quarantine.clear_npm_quarantine("@openai/codex")
|
|
24
|
+
assert quarantine.clear_script_quarantine({"command": "codex"})
|
|
25
|
+
assert quarantine.clear_brew_quarantine("codex", cask=True)
|
|
26
|
+
run.assert_not_called()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.mark.parametrize(
|
|
30
|
+
"failure",
|
|
31
|
+
[
|
|
32
|
+
PermissionError("denied"),
|
|
33
|
+
subprocess.CalledProcessError(1, "xattr", stderr="denied"),
|
|
34
|
+
subprocess.TimeoutExpired("xattr", 60),
|
|
35
|
+
],
|
|
36
|
+
)
|
|
37
|
+
def test_cleanup_failure_is_reported(darwin, capsys, failure):
|
|
38
|
+
with mock.patch.object(quarantine, "run_command", side_effect=failure) as run:
|
|
39
|
+
assert not quarantine.clear_quarantine("/package with spaces")
|
|
40
|
+
run.assert_called_once_with(
|
|
41
|
+
[
|
|
42
|
+
"/usr/bin/xattr",
|
|
43
|
+
"-r",
|
|
44
|
+
"-d",
|
|
45
|
+
"-s",
|
|
46
|
+
quarantine.QUARANTINE,
|
|
47
|
+
"/package with spaces",
|
|
48
|
+
],
|
|
49
|
+
timeout=60,
|
|
50
|
+
)
|
|
51
|
+
assert "Could not clear macOS quarantine" in capsys.readouterr().out
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_npm_uses_selected_prefix(tmp_path, darwin):
|
|
55
|
+
root = tmp_path / "prefix with spaces/lib/node_modules"
|
|
56
|
+
prefix_args = ["--prefix", str(tmp_path / "prefix with spaces")]
|
|
57
|
+
with (
|
|
58
|
+
mock.patch.object(
|
|
59
|
+
quarantine, "run_command", return_value=mock.Mock(stdout=str(root))
|
|
60
|
+
) as run,
|
|
61
|
+
mock.patch.object(quarantine, "clear_quarantine", return_value=True) as clean,
|
|
62
|
+
):
|
|
63
|
+
assert quarantine.clear_npm_quarantine("@openai/codex", prefix_args)
|
|
64
|
+
run.assert_called_once_with(["npm", "root", "-g", *prefix_args], timeout=30)
|
|
65
|
+
clean.assert_called_once_with(str(root / "@openai/codex"))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@pytest.mark.parametrize(
|
|
69
|
+
"package", ["../other", "@../other", "@openai", "/tmp/tool", "tool@latest"]
|
|
70
|
+
)
|
|
71
|
+
def test_npm_refuses_non_package_paths(package, darwin):
|
|
72
|
+
with mock.patch.object(quarantine, "run_command") as run:
|
|
73
|
+
assert not quarantine.clear_npm_quarantine(package)
|
|
74
|
+
run.assert_not_called()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_npm_refuses_linked_package(tmp_path, darwin):
|
|
78
|
+
root = tmp_path / "node_modules"
|
|
79
|
+
root.mkdir()
|
|
80
|
+
(root / "tool").symlink_to(tmp_path / "unrelated")
|
|
81
|
+
with mock.patch.object(
|
|
82
|
+
quarantine, "run_command", return_value=mock.Mock(stdout=str(root))
|
|
83
|
+
):
|
|
84
|
+
assert not quarantine.clear_npm_quarantine("tool")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_npm_probe_timeout_reports_failure(darwin):
|
|
88
|
+
with mock.patch.object(
|
|
89
|
+
quarantine, "run_command", side_effect=subprocess.TimeoutExpired("npm", 30)
|
|
90
|
+
):
|
|
91
|
+
assert not quarantine.clear_npm_quarantine("tool")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_script_resolves_only_executable_not_shared_bin(tmp_path, darwin):
|
|
95
|
+
binary = tmp_path / "versions/1.0/tool"
|
|
96
|
+
binary.parent.mkdir(parents=True)
|
|
97
|
+
binary.touch()
|
|
98
|
+
link = tmp_path / "bin/tool"
|
|
99
|
+
link.parent.mkdir()
|
|
100
|
+
link.symlink_to(binary)
|
|
101
|
+
with (
|
|
102
|
+
mock.patch.object(quarantine.shutil, "which", return_value=None),
|
|
103
|
+
mock.patch.object(quarantine, "clear_quarantine", return_value=True) as clean,
|
|
104
|
+
):
|
|
105
|
+
assert quarantine.clear_script_quarantine(
|
|
106
|
+
{"command": "tool", "macos_quarantine_paths": [str(link)]}
|
|
107
|
+
)
|
|
108
|
+
clean.assert_called_once_with(str(binary.resolve()))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@pytest.mark.parametrize("cask", [True, False])
|
|
112
|
+
def test_brew_cleans_package_directory(tmp_path, darwin, cask):
|
|
113
|
+
root = tmp_path / "codex"
|
|
114
|
+
with (
|
|
115
|
+
mock.patch.object(
|
|
116
|
+
quarantine, "run_command", return_value=mock.Mock(stdout=str(root))
|
|
117
|
+
) as run,
|
|
118
|
+
mock.patch.object(quarantine, "clear_quarantine", return_value=True) as clean,
|
|
119
|
+
):
|
|
120
|
+
assert quarantine.clear_brew_quarantine("codex", cask=cask)
|
|
121
|
+
run.assert_called_once_with(
|
|
122
|
+
["brew", "--caskroom" if cask else "--prefix", "codex"], timeout=30
|
|
123
|
+
)
|
|
124
|
+
clean.assert_called_once_with(str(root.resolve()))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@pytest.mark.parametrize("succeeded", [True, False])
|
|
128
|
+
def test_npm_install_cleans_before_reporting_success(darwin, succeeded):
|
|
129
|
+
cfg = {
|
|
130
|
+
"command": "tool",
|
|
131
|
+
"name": "Tool",
|
|
132
|
+
"install_type": "npm",
|
|
133
|
+
"npm_package": "tool",
|
|
134
|
+
"next_steps": "Run tool",
|
|
135
|
+
}
|
|
136
|
+
with (
|
|
137
|
+
mock.patch.dict(constants._TOOLS_DATA, {"tool": cfg}),
|
|
138
|
+
mock.patch.object(install, "command_exists", return_value=False),
|
|
139
|
+
mock.patch.object(install, "run_command"),
|
|
140
|
+
mock.patch.object(
|
|
141
|
+
install, "get_npm_global_bin_dir", return_value="/prefix/bin"
|
|
142
|
+
),
|
|
143
|
+
mock.patch.object(
|
|
144
|
+
quarantine, "clear_npm_quarantine", return_value=succeeded
|
|
145
|
+
) as clean,
|
|
146
|
+
mock.patch.object(install, "success") as success,
|
|
147
|
+
):
|
|
148
|
+
assert bool(install.install_tool("tool")) is succeeded
|
|
149
|
+
clean.assert_called_once_with("tool")
|
|
150
|
+
assert success.called is succeeded
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_failed_install_and_dryrun_never_clean(darwin):
|
|
154
|
+
cfg = {
|
|
155
|
+
"command": "tool",
|
|
156
|
+
"name": "Tool",
|
|
157
|
+
"install_type": "npm",
|
|
158
|
+
"npm_package": "tool",
|
|
159
|
+
}
|
|
160
|
+
with (
|
|
161
|
+
mock.patch.dict(constants._TOOLS_DATA, {"tool": cfg}),
|
|
162
|
+
mock.patch.object(install, "command_exists", return_value=False),
|
|
163
|
+
mock.patch.object(
|
|
164
|
+
install, "run_command", side_effect=subprocess.CalledProcessError(1, "npm")
|
|
165
|
+
),
|
|
166
|
+
mock.patch.object(quarantine, "clear_npm_quarantine") as clean,
|
|
167
|
+
):
|
|
168
|
+
assert not install.install_tool("tool")
|
|
169
|
+
assert install.install_tool("tool", dryrun=True)
|
|
170
|
+
clean.assert_not_called()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def test_npm_upgrade_preserves_prefix(darwin):
|
|
174
|
+
with (
|
|
175
|
+
mock.patch.object(
|
|
176
|
+
operation_handlers, "_npm_prefix_args", return_value=["--prefix", "/chosen"]
|
|
177
|
+
),
|
|
178
|
+
mock.patch.object(operation_handlers, "run_command"),
|
|
179
|
+
mock.patch.object(
|
|
180
|
+
quarantine, "clear_npm_quarantine", return_value=False
|
|
181
|
+
) as clean,
|
|
182
|
+
):
|
|
183
|
+
assert not operation_handlers._upgrade_npm("tool", {"name": "Tool"}, "package")
|
|
184
|
+
clean.assert_called_once_with("package", ["--prefix", "/chosen"])
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS extended attributes")
|
|
188
|
+
def test_real_macos_nested_helpers_preserve_other_attributes_and_external_links(
|
|
189
|
+
tmp_path,
|
|
190
|
+
):
|
|
191
|
+
package = tmp_path / "package with spaces"
|
|
192
|
+
helper = package / "node_modules/native/bin/codex-code-mode-host"
|
|
193
|
+
helper.parent.mkdir(parents=True)
|
|
194
|
+
helper.touch()
|
|
195
|
+
outside = tmp_path / "other-tool"
|
|
196
|
+
outside.mkdir()
|
|
197
|
+
unrelated = outside / "binary"
|
|
198
|
+
unrelated.touch()
|
|
199
|
+
(package / "linked-directory").symlink_to(outside, target_is_directory=True)
|
|
200
|
+
(package / "linked-binary").symlink_to(unrelated)
|
|
201
|
+
|
|
202
|
+
def xattr(*args):
|
|
203
|
+
return subprocess.run(
|
|
204
|
+
["/usr/bin/xattr", *map(str, args)],
|
|
205
|
+
check=True,
|
|
206
|
+
capture_output=True,
|
|
207
|
+
text=True,
|
|
208
|
+
).stdout
|
|
209
|
+
|
|
210
|
+
for path in (package, helper, unrelated):
|
|
211
|
+
xattr("-w", quarantine.QUARANTINE, "0081;00000000;code-aide-test;", path)
|
|
212
|
+
xattr("-w", "com.code-aide.test", "preserved", path)
|
|
213
|
+
assert quarantine.clear_quarantine(str(package))
|
|
214
|
+
assert quarantine.QUARANTINE not in xattr(helper)
|
|
215
|
+
assert quarantine.QUARANTINE not in xattr(package)
|
|
216
|
+
assert xattr("-p", "com.code-aide.test", helper).strip() == "preserved"
|
|
217
|
+
assert quarantine.QUARANTINE in xattr(unrelated)
|
|
218
|
+
assert quarantine.clear_quarantine(str(package)) # Missing attributes are harmless.
|
|
@@ -415,6 +415,13 @@ class TestMigrateInstallMethod(unittest.TestCase):
|
|
|
415
415
|
class TestCmdUpgradeDefaultSelection(unittest.TestCase):
|
|
416
416
|
"""Tests for default cmd_upgrade behavior."""
|
|
417
417
|
|
|
418
|
+
def setUp(self):
|
|
419
|
+
# Selection uses fixture versions; refreshing would write fake tools
|
|
420
|
+
# into the user's real cache and make results depend on its age.
|
|
421
|
+
refresh = mock.patch.object(cli_commands_actions, "ensure_versions_cache")
|
|
422
|
+
refresh.start()
|
|
423
|
+
self.addCleanup(refresh.stop)
|
|
424
|
+
|
|
418
425
|
def test_default_upgrades_only_out_of_date_installed_tools(self):
|
|
419
426
|
tools = {
|
|
420
427
|
"old": {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Verify cleanup ordering across native install methods."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import io
|
|
5
|
+
import plistlib
|
|
6
|
+
import tarfile
|
|
7
|
+
from unittest import mock
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from code_aide import app_bundle, constants, install, operation_handlers
|
|
12
|
+
from code_aide import macos_quarantine as quarantine
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture(autouse=True)
|
|
16
|
+
def darwin(monkeypatch):
|
|
17
|
+
monkeypatch.setattr(quarantine.platform, "system", lambda: "Darwin")
|
|
18
|
+
monkeypatch.setattr(quarantine.platform, "machine", lambda: "arm64")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.parametrize(
|
|
22
|
+
"installer_ok,cleanup_ok", [(True, True), (True, False), (False, True)]
|
|
23
|
+
)
|
|
24
|
+
@pytest.mark.parametrize("upgrade", [True, False])
|
|
25
|
+
def test_script_install_and_upgrade(installer_ok, cleanup_ok, upgrade):
|
|
26
|
+
cfg = {
|
|
27
|
+
"name": "Tool",
|
|
28
|
+
"command": "tool",
|
|
29
|
+
"install_type": "script",
|
|
30
|
+
"install_url": "https://example.com",
|
|
31
|
+
"next_steps": "Run tool",
|
|
32
|
+
}
|
|
33
|
+
module = operation_handlers if upgrade else install
|
|
34
|
+
with (
|
|
35
|
+
mock.patch.dict(constants._TOOLS_DATA, {"tool": cfg}),
|
|
36
|
+
mock.patch.object(install, "command_exists", return_value=False),
|
|
37
|
+
mock.patch.object(module, "run_install_script", return_value=installer_ok),
|
|
38
|
+
mock.patch.object(
|
|
39
|
+
quarantine, "clear_script_quarantine", return_value=cleanup_ok
|
|
40
|
+
) as clean,
|
|
41
|
+
):
|
|
42
|
+
result = (
|
|
43
|
+
operation_handlers._upgrade_script("tool", cfg, None)
|
|
44
|
+
if upgrade
|
|
45
|
+
else install.install_tool("tool")
|
|
46
|
+
)
|
|
47
|
+
assert bool(result) is (installer_ok and cleanup_ok)
|
|
48
|
+
assert clean.called is installer_ok
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.parametrize("cask", [True, False])
|
|
52
|
+
def test_brew_upgrade_propagates_cleanup_failure(cask):
|
|
53
|
+
handler = (
|
|
54
|
+
operation_handlers._upgrade_brew_cask
|
|
55
|
+
if cask
|
|
56
|
+
else operation_handlers._upgrade_brew_formula
|
|
57
|
+
)
|
|
58
|
+
with (
|
|
59
|
+
mock.patch.object(operation_handlers, "run_command"),
|
|
60
|
+
mock.patch.object(operation_handlers, "_cask_app_stopped", return_value=True),
|
|
61
|
+
mock.patch.object(
|
|
62
|
+
quarantine, "clear_brew_quarantine", return_value=False
|
|
63
|
+
) as clean,
|
|
64
|
+
):
|
|
65
|
+
assert not handler("tool", {"name": "Tool"}, "package")
|
|
66
|
+
clean.assert_called_once_with("package", cask=cask)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.parametrize("valid_checksum", [True, False])
|
|
70
|
+
def test_direct_download_cleans_after_verification_before_link(
|
|
71
|
+
tmp_path, valid_checksum
|
|
72
|
+
):
|
|
73
|
+
data = io.BytesIO()
|
|
74
|
+
with tarfile.open(fileobj=data, mode="w:gz") as archive:
|
|
75
|
+
member = tarfile.TarInfo("package/helper")
|
|
76
|
+
member.size = 4
|
|
77
|
+
archive.addfile(member, io.BytesIO(b"test"))
|
|
78
|
+
content = data.getvalue()
|
|
79
|
+
destination = tmp_path / "versions/1"
|
|
80
|
+
link = tmp_path / "bin/tool"
|
|
81
|
+
cfg = {
|
|
82
|
+
"name": "Tool",
|
|
83
|
+
"latest_version": "1",
|
|
84
|
+
"install_dir": str(destination),
|
|
85
|
+
"bin_dir": str(link.parent),
|
|
86
|
+
"symlinks": {"tool": "helper"},
|
|
87
|
+
"download_url_template": "https://example.com/{version}/{os}/{arch}",
|
|
88
|
+
"download_sha256": (
|
|
89
|
+
hashlib.sha256(content).hexdigest() if valid_checksum else "wrong"
|
|
90
|
+
),
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
def clear(path):
|
|
94
|
+
assert path == str(destination)
|
|
95
|
+
assert (destination / "helper").read_bytes() == b"test"
|
|
96
|
+
assert not link.exists()
|
|
97
|
+
return True
|
|
98
|
+
|
|
99
|
+
with (
|
|
100
|
+
mock.patch.object(install, "fetch_url", return_value=(content, {})),
|
|
101
|
+
mock.patch.object(quarantine, "clear_quarantine", side_effect=clear) as clean,
|
|
102
|
+
):
|
|
103
|
+
assert install.install_direct_download("tool", cfg) is valid_checksum
|
|
104
|
+
assert clean.called is valid_checksum
|
|
105
|
+
assert link.exists() is valid_checksum
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.parametrize(
|
|
109
|
+
"dryrun,cleanup_ok", [(False, True), (False, False), (True, True)]
|
|
110
|
+
)
|
|
111
|
+
def test_existing_verified_bundle_cleanup(tmp_path, dryrun, cleanup_ok):
|
|
112
|
+
bundle = tmp_path / "v1/Tool.app"
|
|
113
|
+
(bundle / "Contents").mkdir(parents=True)
|
|
114
|
+
with (bundle / "Contents/Info.plist").open("wb") as handle:
|
|
115
|
+
plistlib.dump({"CFBundleShortVersionString": "1"}, handle)
|
|
116
|
+
link = tmp_path / "Tool.app"
|
|
117
|
+
link.symlink_to(bundle)
|
|
118
|
+
cfg = {
|
|
119
|
+
"name": "Tool",
|
|
120
|
+
"latest_version": "1",
|
|
121
|
+
"install_dir": str(tmp_path / "v{version}"),
|
|
122
|
+
"app_bundle_name": "Tool.app",
|
|
123
|
+
"app_link": str(link),
|
|
124
|
+
"download_url_template": "https://example.com/{version}/{arch}",
|
|
125
|
+
}
|
|
126
|
+
with (
|
|
127
|
+
mock.patch.object(app_bundle, "signature_ok", return_value=True),
|
|
128
|
+
mock.patch.object(
|
|
129
|
+
quarantine, "clear_quarantine", return_value=cleanup_ok
|
|
130
|
+
) as clean,
|
|
131
|
+
):
|
|
132
|
+
assert app_bundle.install_app_bundle("tool", cfg, dryrun=dryrun) is cleanup_ok
|
|
133
|
+
assert clean.called is not dryrun
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_aide-1.20.1 → code_aide-1.21.1}/specs/2026-05-03-qwen3.6-code-quality-analysis-original.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_aide-1.20.1 → code_aide-1.21.1}/specs/unify-upgrade-eligibility-with-shared-evaluator.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|