diff --git a/.dwp/config.json b/.dwp/config.json index 81b8943..01f00c7 100644 --- a/.dwp/config.json +++ b/.dwp/config.json @@ -2,7 +2,7 @@ "addons": { "agentkit": { "enabled": true, - "version": "v1.5.0" + "version": "v1.5.1" }, "ai-diff-reviewer": { "enabled": true, diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a901000..da577fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: attributes: label: ak version description: Output of `ak --version`. - placeholder: agentkit 1.5.0 (interface 1) + placeholder: agentkit 1.5.1 (interface 1) validations: required: true - type: dropdown diff --git a/AGENTS.md b/AGENTS.md index 3e12554..15f4d0a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -54,4 +54,4 @@ The test map lives in [`docs/TESTING_GUIDE.md`](docs/TESTING_GUIDE.md). Structured work runs through the installed `deepworkplan` skill (`.agents/skills/deepworkplan/`); plans live in the gitignored `.dwp/`; only the addon registry `.dwp/config.json` is tracked (see the skill's `spec/CONFIG.md`). -DWP standard: 8.0.0 (onboarded 2026-10-08; upgraded 2026-10-09, 2026-10-11, 2026-10-12, 2026-10-13, 2026-10-25, 2026-11-15, 2026-11-16 and 2026-11-17; skill 8.0.3, vendored 2026-11-17 from tag commit 1033558, all 188 files verified against the release SHA256SUMS (digest f40ebde7…), together with herdr-peers 2.2.1 (tag commit 6b9f17d, all 37 skill files verified against its SHA256SUMS, digest 9855c625…); new plans use plan-contract/v8, existing plans keep their recorded generation; the addon registry records herdr-peers v2.2.1, coding-agents-kit v1.5.0 and ai-diff-reviewer v3.3.16) +DWP standard: 8.0.0 (onboarded 2026-10-08; upgraded 2026-10-09, 2026-10-11, 2026-10-12, 2026-10-13, 2026-10-25, 2026-11-15, 2026-11-16 and 2026-11-17; skill 8.0.3, vendored 2026-11-17 from tag commit 1033558, all 188 files verified against the release SHA256SUMS (digest f40ebde7…), together with herdr-peers 2.2.1 (tag commit 6b9f17d, all 37 skill files verified against its SHA256SUMS, digest 9855c625…); new plans use plan-contract/v8, existing plans keep their recorded generation; the addon registry records herdr-peers v2.2.1, coding-agents-kit v1.5.1 and ai-diff-reviewer v3.3.16) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42935d3..42fefd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,27 @@ permission posture changes. ## [Unreleased] +## [1.5.1] - 2026-11-18 + +A patch release. Interface stays **1**; the doctor JSON shape is unchanged. +npm-installed CLIs (Codex first) keep their per-platform native binary, and +an install that leaves a CLI unable to start is no longer called a success. + +### Fixed + +- `ak install` and `ak update` install npm CLIs with `--include=optional`, + so Codex's per-platform native binary (`@openai/codex-linux-arm64`, …), an + optional dependency, is always installed. The installed CLI must then + start (` --version` exits 0, probed without key variables): when npm + dropped the platform binary, ak uninstalls and installs it once more, and a + CLI that still does not start is a failed install with the CLI's own + error, never "installed". A broken copy npm did not install is reported, + never reinstalled over. +- `ak doctor` reports a CLI that resolves but does not start as a problem + that quotes its error and names the repair (`npm uninstall -g `, + then `ak install `, when the copy is in npm's prefix). The JSON + shape is unchanged: its `version_status` stays `unknown`. + ## [1.5.0] - 2026-11-16 A minor release. Interface stays **1**: `ak run --output-format json` gains @@ -830,7 +851,9 @@ First public release. **Interface 1.** Redesigned from the author's earlier coding-agents-setup-kit (wrappers, installers, provider writers) and profile work; see `CREDITS.md`. -[Unreleased]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.4.0...HEAD +[Unreleased]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.5.1...HEAD +[1.5.1]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.5.0...v1.5.1 +[1.5.0]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.4.0...v1.5.0 [1.4.0]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.3.0...v1.4.0 [1.3.0]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.2.0...v1.3.0 [1.2.0]: https://github.com/DailybotHQ/coding-agents-kit/compare/v1.1.0...v1.2.0 diff --git a/README.md b/README.md index 54a5c31..84f403c 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ python3 ≥ 3.9. Nothing else. ## Install ```bash -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit && ./coding-agents-kit/install.sh +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit && ./coding-agents-kit/install.sh ``` Verify the checkout against the release's checksums (every shipped file is @@ -113,7 +113,7 @@ listed): ```bash cd coding-agents-kit -curl -fsSLO https://github.com/DailybotHQ/coding-agents-kit/releases/download/v1.5.0/SHA256SUMS +curl -fsSLO https://github.com/DailybotHQ/coding-agents-kit/releases/download/v1.5.1/SHA256SUMS shasum -a 256 -c SHA256SUMS --ignore-missing # Linux: sha256sum -c SHA256SUMS --ignore-missing ``` @@ -121,7 +121,7 @@ Windows: `.\coding-agents-kit\install.ps1`. Scripts and containers: `./coding-agents-kit/install.sh --no-rc`. Details, upgrades and uninstall: [docs/install.md](docs/install.md). -Let an agent do it: `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit-setup`, then ask it +Let an agent do it: `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit-setup`, then ask it to set the kit up on this machine or to write a container recipe ([setup](docs/setup.md)). ## Quickstart @@ -191,9 +191,9 @@ ak pick codex --owner local:w1:p1 --count 2 # spreads lanes: every active l | Skill | For | Install | | --- | --- | --- | -| `agentkit` | launching kinds, accounts, `ak run`, `ak usage`, `ak pick` (`ak --skill`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit` | -| `agentkit-setup` | installing, configuring and repairing the kit (`ak --skill setup`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit-setup` | -| `agentkit-orchestrate` | several agents over several accounts and vendors (`ak --skill orchestrate`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit-orchestrate` | +| `agentkit` | launching kinds, accounts, `ak run`, `ak usage`, `ak pick` (`ak --skill`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit` | +| `agentkit-setup` | installing, configuring and repairing the kit (`ak --skill setup`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit-setup` | +| `agentkit-orchestrate` | several agents over several accounts and vendors (`ak --skill orchestrate`) | `npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit-orchestrate` | ### The grammar diff --git a/docs/doctor.md b/docs/doctor.md index 7a0beb4..97eae06 100644 --- a/docs/doctor.md +++ b/docs/doctor.md @@ -25,7 +25,7 @@ The JSON form is the contract. Schema: [`schema/doctor-v1.json`](schema/doctor-v ```json { "interface": 1, - "version": "1.5.0", + "version": "1.5.1", "os": "macos", "kinds": { "claude": { "cli": "claude", "provider": null, "installed": true, "path": "/…/claude", "version": "2.1.295 (Claude Code)", "logged_in": true }, @@ -55,7 +55,7 @@ The JSON form is the contract. Schema: [`schema/doctor-v1.json`](schema/doctor-v | `herdr_hooks` | per Herdr-integrated CLI, per profile: whether Herdr's state hook files are present in that home | | `default_profiles` | since 0.5.2: per CLI whose `AGENTKIT_DEFAULT_PROFILE_` is set, what a bare `ak ` launches (`@name`, `@default` or `pick`); see [Profiles](profiles.md#a-default-profile-per-cli) | | `daemons` | since 0.5.3: per CLI that records a background daemon in its home (Codex), per account: `present`, `absent` (nothing recorded), `missing` (the home records a daemon that is not on this machine, so `ak codex` adds `--no-daemon`) or `off` (`AGENTKIT_CODEX_NO_DAEMON=1`); see [Profiles](profiles.md#codex-and-its-app-server-daemon) | -| `env_file`, `problems` | where the env file is, its mode, and anything to fix. On Linux or in a container, a problem names each account whose file names the account but whose login token is not there (a macOS Keychain login does not travel), with the fix | +| `env_file`, `problems` | where the env file is, its mode, and anything to fix. A CLI that resolves but does not start (`--version` exits non-zero, for example Codex after npm dropped its platform binary) is a problem quoting the CLI's error, with the repair: `npm uninstall -g , then ak install ` when the broken copy is in npm's global prefix, otherwise removing or repairing that copy. Its `version_status` stays `unknown`, and doctor still runs one `--version` per CLI. On Linux or in a container, a problem names each account whose file names the account but whose login token is not there (a macOS Keychain login does not travel), with the fix | Consumers must ignore keys they do not know: minor versions may add some. No credential file is opened, with one exception: Claude's `.claude.json` diff --git a/docs/install.md b/docs/install.md index 5144350..9a59e09 100644 --- a/docs/install.md +++ b/docs/install.md @@ -8,14 +8,14 @@ macOS, Linux, WSL (and Git Bash): ```bash -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit ./coding-agents-kit/install.sh ``` Windows (PowerShell 5.1 or 7): ```powershell -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit .\coding-agents-kit\install.ps1 ``` @@ -109,10 +109,23 @@ does not match refuses the install and leaves nothing behind; a platform with no pinned digest (Windows, for the native binaries) is refused with the vendor's docs link; archives are unpacked only after every entry is checked to stay inside its directory. Vendor install scripts are never run. -For npm, the verified tarball is what npm installs; its dependencies are -resolved by npm from the registry, each checked against the registry's own -integrity. After install, each CLI's own updater may take over; the pins are -what a fresh machine gets. +For npm, the verified tarball is what npm installs +(`npm install -g --include=optional `); its dependencies are resolved by +npm from the registry, each checked against the registry's own integrity. +`--include=optional` matters for Codex, whose native binary is a per-platform +optional dependency (`@openai/codex-linux-arm64`, …): without it the CLI fails +with "Missing optional dependency". The install then has to **start**: ak +runs the installed copy's `--version` (with the same key-free environment +npm gets), and a CLI that does not start, its `--version` exiting non-zero +(npm can drop the platform binary on an in-place install), is uninstalled and +installed once more; still failing, the install fails with the CLI's own +error. A broken copy that npm did not install (another copy first on PATH) is +reported and never reinstalled over. `--include=optional` needs npm 7 or +later; npm 6 ignores it and installs optional dependencies by default. After +install, each CLI's own updater may take over; the pins are what a fresh +machine gets. A vendor's in-CLI update (Codex's "Update now" runs +`npm install -g @openai/codex`) skips these checks: prefer `ak update`, and if +an in-CLI update left the CLI broken, `ak doctor` names the repair. A CLI that cannot be pinned is stated in the data as `unverified = ""` and installs only with diff --git a/docs/schema/capacity-v1.json b/docs/schema/capacity-v1.json index f2a27dc..b5c0814 100644 --- a/docs/schema/capacity-v1.json +++ b/docs/schema/capacity-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/capacity-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/capacity-v1.json", "title": "ak capacity --json (capacity-v1)", "description": "One account's headroom and a verdict, computed with ak pick's arithmetic (pick.evaluate: the smallest free share of the governing windows, a 10% reserve on windows of 7 days or more) and pick's lower-only drill cap. The reading comes from the kit's usage cache when fresh (usage numbers only; ak usage is the only command that always reads live). Exit 0 for every reading; the verdict is here, not in the exit code. Never contains a secret value. Consumers check `schema` and `interface` first; additional keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/doctor-v1.json b/docs/schema/doctor-v1.json index 6fb11af..c855c55 100644 --- a/docs/schema/doctor-v1.json +++ b/docs/schema/doctor-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/doctor-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/doctor-v1.json", "title": "ak doctor --json (interface 1)", "description": "What coding-agents-kit reports about a machine. Never contains a secret value: keys are variable names only. Consumers check `interface` before reading anything else; additional top-level keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/leases-v1.json b/docs/schema/leases-v1.json index 6b3d959..bc65466 100644 --- a/docs/schema/leases-v1.json +++ b/docs/schema/leases-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/leases-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/leases-v1.json", "title": "ak lease ls --json (leases-v1)", "description": "Every active (unexpired) advisory account lease on this machine, oldest first. Leases grant nothing: ak pick --owner and the orchestration skill respect them. Holds profile names, owner addresses, times and a purpose note; never a secret value or a path. Additional keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/pick-v1.json b/docs/schema/pick-v1.json index 7e15b51..70b8894 100644 --- a/docs/schema/pick-v1.json +++ b/docs/schema/pick-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/pick-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/pick-v1.json", "title": "ak pick --json (pick-v1)", "description": "The account(s) with the most usable headroom for a kind, chosen from the same rows as `ak usage` by one documented policy (docs/usage.md#choosing-an-account). No login is refreshed, no reset is spent; since 0.6.0 a fresh reading may come from the kit's usage cache (usage numbers only; --max-age). Never contains a secret value or an account identity. Consumers check `schema` and `interface` before reading anything else; additional top-level keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/pick-v2.json b/docs/schema/pick-v2.json index 1a47fa1..d0024f2 100644 --- a/docs/schema/pick-v2.json +++ b/docs/schema/pick-v2.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/pick-v2.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/pick-v2.json", "title": "ak pick --kinds --json (pick-v2)", "description": "The cross-kind priority pick for daemons (herdr-peers autopilot --loop and its agents): the FIRST kind of --kinds with a qualifying account, chosen by the same rows, cache and policy as pick-v1 (docs/usage.md#choosing-an-account). Read-only: no login is refreshed, no reset is spent. `launch.argv` is the exact interactive argv to start that agent, so a caller never learns any CLI's own flags; `model` is what the caller asked for that kind (resolution happens at launch). Never contains a secret value or an account identity. Consumers check `schema` and `interface` before reading anything else; additional top-level keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/profiles-v1.json b/docs/schema/profiles-v1.json index 24b4c1d..80a80f7 100644 --- a/docs/schema/profiles-v1.json +++ b/docs/schema/profiles-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/profiles-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/profiles-v1.json", "title": "ak profiles --json (profiles-v1)", "description": "Every account the kit knows, portable to another host: names and kinds only. Never contains a secret value, an account identity or an absolute path. Another host recreates the set with `ak profiles add @` and logs each one in. Consumers check `schema` and `interface` first; additional keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/setup-probe-v1.json b/docs/schema/setup-probe-v1.json index 9bb1402..bffc045 100644 --- a/docs/schema/setup-probe-v1.json +++ b/docs/schema/setup-probe-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/setup-probe-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/setup-probe-v1.json", "title": "ak setup probe --json (setup-probe-v1)", "description": "What a machine or container looks like to someone about to install or configure coding-agents-kit. Read-only; it works from an uninstalled clone. Never contains a secret value: keys are variable names only. Consumers check `schema` and `interface` first; additional top-level keys may appear in later minor versions.", "type": "object", diff --git a/docs/schema/setup-verify-v1.json b/docs/schema/setup-verify-v1.json index 1519639..655348e 100644 --- a/docs/schema/setup-verify-v1.json +++ b/docs/schema/setup-verify-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/setup-verify-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/setup-verify-v1.json", "title": "ak setup verify --json (setup-verify-v1)", "description": "A closed list of named checks about a kit setup, each with a verdict and the one command that repairs it. Read-only: verify never applies a repair. Never contains a secret value. Consumers check `schema` and `interface` first.", "type": "object", diff --git a/docs/schema/update-v1.json b/docs/schema/update-v1.json index 202d23d..7e75ecb 100644 --- a/docs/schema/update-v1.json +++ b/docs/schema/update-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/update-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/update-v1.json", "title": "ak update --json (update-v1)", "description": "One ak update run: what each requested CLI's vendor discovery found, what was installed, what PATH resolves afterwards, and whether the pin moved. Additive within interface 1: new fields may appear, existing ones do not change meaning.", "type": "object", diff --git a/docs/schema/usage-v1.json b/docs/schema/usage-v1.json index 3194133..316f31e 100644 --- a/docs/schema/usage-v1.json +++ b/docs/schema/usage-v1.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.0/docs/schema/usage-v1.json", + "$id": "https://github.com/DailybotHQ/coding-agents-kit/blob/v1.5.1/docs/schema/usage-v1.json", "title": "ak usage --json (usage-v1)", "description": "Quota and usage of each account the kit can see, one row per credential identity. Never contains a secret value, an account identity (e-mail, organisation, id) or a token. The endpoints behind it are vendor-internal and unofficial: a row whose source changed shape reports status `error`, never a crash. Consumers check `schema` and `interface` before reading anything else; additional top-level keys may appear in later minor versions.", "type": "object", diff --git a/docs/setup.md b/docs/setup.md index 542b439..a378a1f 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -9,14 +9,14 @@ Two pieces work together: machine. It observes and renders; it never installs, repairs or decides, and it never writes anything except an explicit `--out FILE`. -Neither replaces the two commands you can always type yourself (`git clone --branch v1.5.0 …` and `install.sh`, see +Neither replaces the two commands you can always type yourself (`git clone --branch v1.5.1 …` and `install.sh`, see [install](install.md)). They exist so an agent can do the same thing safely, repeatably and on a machine you are not sitting at. ## Use the skill ```bash -npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit-setup +npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit-setup ``` or let the kit print it: `ak --skill setup`. Then ask your agent, for example: *"set up coding-agents-kit on this @@ -24,7 +24,7 @@ machine with a Claude and a Codex account"* or *"write a Dockerfile that runs th The skill starts from a clone of the pinned tag, so it works before `ak` exists: ```bash -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit python3 coding-agents-kit/lib/ak.py setup probe --json ``` diff --git a/docs/update.md b/docs/update.md index b50c280..99ed2ff 100644 --- a/docs/update.md +++ b/docs/update.md @@ -32,9 +32,11 @@ doctor, `ak install` and the next update agree. digests) — skipped; move the pin with `scripts/update-pins.sh`. 2. **Verify** exactly like `ak install`. A digest mismatch refuses before anything is installed and before the pin moves. -3. **Install** through the channel itself: `npm install -g` of the verified - tarball, or the verified binary written over `~/.local/bin/` - (a regular file there is first backed up to `.agentkit-orig`). +3. **Install** through the channel itself: `npm install -g + --include=optional` of the verified tarball, which then has to start as + for `ak install` (one clean reinstall, then a failed update), or the + verified binary written over `~/.local/bin/` (a regular file + there is first backed up to `.agentkit-orig`). 4. **Resolve** — the update only counts when PATH resolves the new release. A vendor-managed **symlink** is replaced only with `--take-over`, which prints what it pointed at; a **regular file** is never replaced by a diff --git a/lib/common.py b/lib/common.py index 85458c7..b1fa743 100644 --- a/lib/common.py +++ b/lib/common.py @@ -5,7 +5,7 @@ import subprocess import sys -VERSION = "1.5.0" +VERSION = "1.5.1" INTERFACE = 1 # Exit codes (the `ak run` contract uses the same numbers everywhere). @@ -83,6 +83,19 @@ def _probe(argv, timeout=5): return "" +def probe_status(argv, timeout=5, env=None): + """(exit status, stdout, first stderr line) of a short probe; the status + is None when the program could not run or did not finish in time. `env` + replaces the environment (pass a key-free one for code just installed).""" + try: + out = subprocess.run(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdin=subprocess.DEVNULL, timeout=timeout, env=env) + except (OSError, subprocess.SubprocessError): + return None, "", "" + err = [line.strip() for line in out.stderr.decode("utf-8", "replace").splitlines() if line.strip()] + return out.returncode, out.stdout.decode("utf-8", "replace"), (err[0][:200] if err else "") + + def is_cursor_binary(path): """The Cursor CLI ships `agent`, and so does the xAI Grok installer: a bare `agent` on PATH is not proof that Cursor is installed.""" diff --git a/lib/doctor.py b/lib/doctor.py index 75d9d31..6dcf7f4 100644 --- a/lib/doctor.py +++ b/lib/doctor.py @@ -23,16 +23,26 @@ import aliases import common import hooks +import installer import kinds import profiles from common import AkError, EXIT_USAGE -def _cli_version(exe): +def _cli_probe(exe): + """(version line or None, start problem or None) from ONE ` --version`. + + The problem says why the CLI does not start: its `--version` exits + non-zero (the CLI's first stderr line quoted). A timeout proves nothing + and is no problem; the version is the first stdout line either way.""" if not exe: - return None - out = common._probe([exe, "--version"], timeout=5).strip().splitlines() - return out[0].strip() if out else None + return None, None + status, out, err = common.probe_status([exe, "--version"], timeout=5) + lines = out.strip().splitlines() + version = lines[0].strip() if lines else None + if status is None or status == 0: + return version, None + return version, "`--version` exits %d%s" % (status, (": " + err) if err else "") _VERSION = re.compile(r"v?(\d+(?:\.\d+){1,3})(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?") @@ -111,9 +121,18 @@ def collect(model, env): cli = kind.cli_name if cli not in exe_cache: exe_cache[cli] = common.resolve_executable(kind.cli, env) - version_cache[cli] = _cli_version(exe_cache[cli]) + version_cache[cli], broken = _cli_probe(exe_cache[cli]) pinned = kind.cli.get("install", {}).get("version") status_cache[cli] = _version_status(cli, version_cache[cli], pinned, exe_cache[cli] is not None) + if broken: + inst = kind.cli.get("install", {}) + if inst.get("channel") == "npm" and inst.get("package") \ + and installer.in_npm_prefix(exe_cache[cli], installer.installer_env(env)): + how = "npm uninstall -g %s, then ak install %s" % (inst["package"], cli) + else: + how = "remove or repair the broken copy at %s, then ak install %s" % (exe_cache[cli], cli) + problems.append("%s: %s is installed but does not start (%s). Fix: %s" + % (cli, exe_cache[cli], broken, how)) if status_cache[cli] == "older": problems.append("%s: resolved %s reports %s, older than kit pin %s. Fix: ak update %s; " "then check this path again if another install shadows the updated CLI" diff --git a/lib/installer.py b/lib/installer.py index 1f6bab8..a62f8dd 100644 --- a/lib/installer.py +++ b/lib/installer.py @@ -9,7 +9,12 @@ tarball one archive per platform, checked against its sha256, unpacked safely into a versioned directory, then linked into ~/.local/bin; npm the registry tarball of @, checked against the - pinned `integrity` (sha512), then `npm install -g `. + pinned `integrity` (sha512), then `npm install -g + --include=optional `. The installed CLI must then + start (` --version`): npm can drop a package's platform + binary, an optional dependency, on an in-place install, so a CLI + that does not start is uninstalled and installed once more, and + still failing is a failed install, never a success. A platform with no pinned digest is refused. A CLI that cannot be pinned carries `unverified = ""` and installs only with @@ -238,7 +243,65 @@ def _extract(tmp, staging, inst): archive.extractall(staging, members=members) -def _install_npm(cli_name, inst, tmpdir, env, allow_unverified): +def npm_prefix_bin(env): + """The directory npm installs global packages into (its prefix's bin), + or None when npm does not say.""" + npm = common.which("npm", env) + if not npm: + return None + out = common._probe([npm, "config", "get", "prefix"], timeout=10).strip().splitlines() + prefix = out[0].strip() if out else "" + if not prefix or not os.path.isdir(prefix): + return None + if common.os_name() == "windows": + return prefix + return os.path.join(prefix, "bin") + + +def _npm_root(prefix_bin): + """npm's global prefix for a prefix bin directory (the same directory on + Windows, its parent elsewhere).""" + if not prefix_bin: + return None + return prefix_bin if common.os_name() == "windows" else os.path.dirname(prefix_bin) + + +def in_npm_prefix(exe, env): + """True when `exe` lives under npm's global prefix: a copy npm installed, + so `npm uninstall -g` and a reinstall act on that very copy.""" + root = _npm_root(npm_prefix_bin(env)) + if not root or not exe: + return False + root = os.path.realpath(root) + return os.path.realpath(exe).startswith(root + os.sep) + + +def npm_start_problem(cli, env): + """(problem, exe) for the CLI npm just installed: problem says why it does + not start (its `--version` exits non-zero), None when it starts or there + is nothing to check. The copy in npm's prefix is probed (the one this + install wrote), else the copy PATH resolves; with neither, the install + cannot be checked here and install_one names the PATH step. The probe + runs with `env`, the key-free installer environment: the code npm just + fetched never sees a key.""" + exe = None + # On Windows the prefix also holds npm's extensionless sh shim, which + # cannot be run directly: probe the copy PATH resolves (its .cmd) there. + prefix_bin = npm_prefix_bin(env) if common.os_name() != "windows" else None + if prefix_bin and cli.get("executable"): + cand = os.path.join(prefix_bin, cli["executable"]) + if os.path.isfile(cand) and os.access(cand, os.X_OK): + exe = cand + exe = exe or common.resolve_executable(cli, env) + if not exe: + return None, None + status, _, err = common.probe_status([exe, "--version"], timeout=10, env=env) + if status is None or status == 0: + return None, exe # a probe that times out proves nothing either way + return "`%s --version` exits %d%s" % (exe, status, (": " + err) if err else ""), exe + + +def _install_npm(cli_name, inst, tmpdir, env, allow_unverified, cli=None): npm = common.which("npm", env) if not npm: print("%s: npm is not installed — install Node first: %s" % (cli_name, NODE_HINTS.get(common.os_name(), @@ -251,13 +314,40 @@ def _install_npm(cli_name, inst, tmpdir, env, allow_unverified): return False if not _verify(cli_name, tgz, inst.get("integrity"), integrity_of, allow_unverified, inst): return False - argv = [npm, "install", "-g"] + list(inst.get("npm_args", [])) + [tgz] + # --include=optional: a CLI that ships its native binary as a platform + # optional dependency (Codex) does not start without it, whatever an + # inherited `omit` setting says. + argv = [npm, "install", "-g", "--include=optional"] + list(inst.get("npm_args", [])) + [tgz] # Progress goes to sys.stderr: the right home for an install's own # output in both plain and --json runs (the JSON envelope is stdout # only), and a stream with a real fileno the child can inherit — a # caller capturing sys.stdout in a StringIO would otherwise crash the # subprocess setup. - return subprocess.call(argv, env=env, stdout=sys.stderr) == 0 + if subprocess.call(argv, env=env, stdout=sys.stderr) != 0: + return False + if cli is None: + return True + problem, exe = npm_start_problem(cli, env) + if not problem: + return True + if not in_npm_prefix(exe, env): + # Not the copy npm wrote: reinstalling npm's package would not touch + # it. Report it, repair nothing. + print("%s: %s does not start (%s), and it is not the copy npm installed: remove or fix it, " + "or put npm's copy first on PATH" % (cli_name, exe, problem)) + return False + # npm can drop the platform binary on an in-place install; a clean + # uninstall and install is the known repair. Once, then the truth. + print("%s: the installed CLI does not start (%s); reinstalling %s cleanly" + % (cli_name, problem, inst["package"])) + subprocess.call([npm, "uninstall", "-g", inst["package"]], env=env, stdout=sys.stderr) + if subprocess.call(argv, env=env, stdout=sys.stderr) != 0: + return False + problem, _ = npm_start_problem(cli, env) + if problem: + print("%s: still does not start after a clean reinstall (%s)" % (cli_name, problem)) + return False + return True def install_one(model, cli_name, env, allow_unverified=False, plat=None): @@ -274,7 +364,7 @@ def install_one(model, cli_name, env, allow_unverified=False, plat=None): tmpdir = tempfile.mkdtemp(prefix="agentkit-install-") try: if inst["channel"] == "npm": - ok = _install_npm(cli_name, inst, tmpdir, env, allow_unverified) + ok = _install_npm(cli_name, inst, tmpdir, env, allow_unverified, cli) else: ok = _install_binary(cli_name, cli, inst, plat, tmpdir, env, allow_unverified) except (AkError, tarfile.TarError, OSError) as exc: diff --git a/lib/update.py b/lib/update.py index ad3b4e6..8f92c3d 100644 --- a/lib/update.py +++ b/lib/update.py @@ -175,18 +175,8 @@ def _resolved_version(exe): def _npm_prefix_bin(env): - """The directory npm installs global packages into (its prefix's bin), - or None when npm does not say.""" - npm = common.which("npm", env) - if not npm: - return None - out = common._probe([npm, "config", "get", "prefix"], timeout=10).strip().splitlines() - prefix = out[0].strip() if out else "" - if not prefix or not os.path.isdir(prefix): - return None - if common.os_name() == "windows": - return prefix - return os.path.join(prefix, "bin") + """The directory npm installs global packages into (installer.npm_prefix_bin).""" + return installer.npm_prefix_bin(env) _VERSION_OK = re.compile(r"[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?\Z") @@ -460,7 +450,7 @@ def update_one(model, cli_name, opts, env): tmpdir = tempfile.mkdtemp(prefix="agentkit-update-") try: if inst.get("channel") == "npm": - ok = installer._install_npm(cli_name, cand, tmpdir, ienv, False) + ok = installer._install_npm(cli_name, cand, tmpdir, ienv, False, cli) else: ok = installer._install_binary(cli_name, cli, cand, installer.platform_key(), tmpdir, ienv, False) except (AkError, OSError) as exc: diff --git a/skills/agentkit-orchestrate/SKILL.md b/skills/agentkit-orchestrate/SKILL.md index a0bf72c..f836177 100644 --- a/skills/agentkit-orchestrate/SKILL.md +++ b/skills/agentkit-orchestrate/SKILL.md @@ -1,7 +1,7 @@ --- name: agentkit-orchestrate description: Run several terminal coding agents at once across the user's accounts and vendors with coding-agents-kit (`ak`) — take inventory of every account's quota, pick the accounts with room (`ak pick --count`), give each writing agent its own git worktree, fan out headless runs (`ak run`), fail over when an account hits a limit, verify every result before merging, and report what was spent. Use when the user asks to split work across several agents or accounts, to run agents in parallel, to get a second opinion from another vendor, to spread a long task over their accounts, or to know which accounts can take the next batch. -version: "1.5.0" +version: "1.5.1" documentation_url: https://github.com/DailybotHQ/coding-agents-kit metadata: {"requires":{"anyBins":["ak","agentkit"]},"interface":1} --- diff --git a/skills/agentkit-setup/SKILL.md b/skills/agentkit-setup/SKILL.md index 04a48e5..f1946f6 100644 --- a/skills/agentkit-setup/SKILL.md +++ b/skills/agentkit-setup/SKILL.md @@ -1,7 +1,7 @@ --- name: agentkit-setup description: Install, configure, verify, repair and upgrade coding-agents-kit (`ak`) on any machine, server or Docker container — macOS, Linux, WSL and Windows — from a pinned release, with consent before every change, provider keys handled by name only, and a container recipe that verifies a SHA256. Use when the user asks to set up, install, configure, repair or upgrade ak or agentkit on a host or in a container, to prepare a machine for several coding-agent accounts, or to write a Dockerfile or compose file that runs the kit. -version: "1.5.0" +version: "1.5.1" documentation_url: https://github.com/DailybotHQ/coding-agents-kit metadata: {"requires":{"anyBins":["git","python3"]},"interface":1} --- @@ -38,7 +38,7 @@ not ask for. ```bash # test: probe -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit python3 coding-agents-kit/lib/ak.py setup probe --json ``` diff --git a/skills/agentkit-setup/references/windows.md b/skills/agentkit-setup/references/windows.md index d90a0a4..582dba4 100644 --- a/skills/agentkit-setup/references/windows.md +++ b/skills/agentkit-setup/references/windows.md @@ -4,7 +4,7 @@ Requirements: python 3.9 or newer (the `py` launcher), git. WSL users follow flo ## Steps -1. Probe: `py -3 coding-agents-kit\lib\ak.py setup probe --json` (after `git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit`). +1. Probe: `py -3 coding-agents-kit\lib\ak.py setup probe --json` (after `git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit`). 2. Missing git or python: offer `winget install Git.Git` or `winget install Python.Python.3.12` — `[GATE: system package]`; run only after they agree. 3. `[GATE: shell rc]` The installer adds the install's `bin` to the **user** Path unless told not to: ```powershell diff --git a/skills/agentkit/SKILL.md b/skills/agentkit/SKILL.md index 8217249..3d90797 100644 --- a/skills/agentkit/SKILL.md +++ b/skills/agentkit/SKILL.md @@ -1,7 +1,7 @@ --- name: agentkit description: Launch, install and configure terminal coding agents (Claude Code, Codex, Cursor, OpenCode, Pi, Cline, Grok) through coding-agents-kit's `ak` command — accounts per CLI (profiles), provider routes (GLM, Azure, xAI), headless runs with a JSON result (`ak run`), the environment of a profile for other launchers (`ak env`), quota per account and the account with room (`ak usage`, `ak pick`), and a doctor. Use when the user mentions ak, agentkit or coding-agents-kit, asks to start or set up another coding-agent CLI or account, asks which account has room, or asks to run a prompt through another agent non-interactively. -version: "1.5.0" +version: "1.5.1" documentation_url: https://github.com/DailybotHQ/coding-agents-kit metadata: {"requires":{"anyBins":["ak","agentkit"]},"interface":1} --- @@ -38,11 +38,11 @@ If `ak` is missing, tell the user and offer the install — it writes into their home directory, so do it only after they agree: ```bash -git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit && ./coding-agents-kit/install.sh +git clone --branch v1.5.1 https://github.com/DailybotHQ/coding-agents-kit && ./coding-agents-kit/install.sh ``` (This skill itself installs with -`npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.0 --skill agentkit`.) +`npx --yes skills add DailybotHQ/coding-agents-kit@v1.5.1 --skill agentkit`.) `ak --skill` prints the copy of this file that matches the installed kit. ## Kinds diff --git a/tests/py/install_checks.py b/tests/py/install_checks.py index cc54f37..d0ec917 100644 --- a/tests/py/install_checks.py +++ b/tests/py/install_checks.py @@ -164,14 +164,112 @@ def tree(home): # npm: the pinned integrity is checked before npm runs; npm installs that file ok_, out, home, npm_log = run("codex") check("npm: a matching integrity runs npm install -g ", - ok_ and "NPM install -g " in npm_log and npm_log.split("NPM install -g ", 1)[1].split()[0].endswith("codex-0.169.0.tgz"), + ok_ and "NPM install -g " in npm_log and npm_log.split("NPM install -g ", 1)[1].splitlines()[0].split()[-1].endswith("codex-0.169.0.tgz"), npm_log or out) +check("npm: the install always includes optional dependencies (a CLI's platform binary)", + "NPM install -g --include=optional " in npm_log, npm_log) check("npm: npm never sees a key variable", "NPM-ENV" not in npm_log, npm_log) check("npm: no planted key value reaches the output", PLANTED not in out and PLANTED not in npm_log) ok_, out, home, npm_log = run("opencode") check("npm: an integrity mismatch is refused before npm runs", not ok_ and "checksum mismatch" in out and npm_log == "", out + npm_log) +# npm: the installed CLI must start. A fake npm with a real prefix writes a +# codex whose --version fails the way a dropped platform optional dependency +# does; `uninstall` removes it and marks the next install as clean. Mode +# "repair" installs a working copy after the uninstall; mode "broken" never +# does. +def npm_prefix_fake(mode): + bindir = os.path.join(SCRATCH, "bin-npm-%s" % mode) + prefix = os.path.join(SCRATCH, "prefix-npm-%s" % mode) + shutil.rmtree(bindir, ignore_errors=True) + shutil.rmtree(prefix, ignore_errors=True) + os.makedirs(bindir) + os.makedirs(os.path.join(prefix, "bin")) + # Each copy records the names of any key variables it can see. + spy = 'env | grep -E "_API_KEY|_TOKEN" | sed "s/=.*//; s/^/CODEX-ENV /" >> %s\\n' % LOG + good = '#!/bin/sh\\n' + spy + 'echo "codex-cli 0.169.0"\\n' + bad = ('#!/bin/sh\\n' + spy + 'echo "Error: Missing optional dependency @openai/codex-linux-arm64." >&2\\n' + 'exit 1\\n') + with open(os.path.join(bindir, "npm"), "w") as fh: + fh.write("""#!/bin/sh +echo "NPM $*" >> "%(log)s" +case "$1" in + config) echo "%(prefix)s" ;; + uninstall) rm -f "%(prefix)s/bin/codex"; : > "%(prefix)s/.clean" ;; + install) + if [ "%(mode)s" = repair ] && [ -f "%(prefix)s/.clean" ]; then printf '%(good)s' > "%(prefix)s/bin/codex" + else printf '%(bad)s' > "%(prefix)s/bin/codex"; fi + chmod +x "%(prefix)s/bin/codex" ;; +esac +exit 0 +""" % {"log": LOG, "prefix": prefix, "mode": mode, "good": good, "bad": bad}) + os.chmod(os.path.join(bindir, "npm"), 0o755) + return bindir + + +def run_npm_fake(mode): + bindir = npm_prefix_fake(mode) + home = os.path.join(SCRATCH, "home-npm-%s" % mode) + shutil.rmtree(home, ignore_errors=True) + os.makedirs(home) + os.environ["HOME"] = home + if os.path.exists(LOG): + os.remove(LOG) + env = {"HOME": home, "PATH": bindir + ":" + BIN + ":/usr/bin:/bin", "OPENAI_API_KEY": PLANTED, + "GH_TOKEN": PLANTED} + # The key also sits in this process's own environment, the one a probe + # without an explicit env would inherit: only the key-free installer + # environment keeps it from the new CLI. + os.environ["OPENAI_API_KEY"] = PLANTED + out = io.StringIO() + try: + with contextlib.redirect_stdout(out): + result = installer.install_one(model, "codex", env) + finally: + os.environ.pop("OPENAI_API_KEY", None) + return result, out.getvalue(), open(LOG).read() if os.path.exists(LOG) else "" + + +ok_, out, npm_log = run_npm_fake("repair") +check("npm: a CLI that does not start after install is reinstalled cleanly, then counts", + ok_ and "does not start" in out and "reinstalling @openai/codex cleanly" in out + and "NPM uninstall -g @openai/codex" in npm_log and npm_log.count("NPM install -g --include=optional ") == 2, + out + npm_log) +check("npm: the failure names the CLI's own error", "Missing optional dependency" in out, out) +check("npm: the start probe runs the new CLI without any key variable", + "CODEX-ENV" not in npm_log and PLANTED not in out and PLANTED not in npm_log, npm_log) +ok_, out, npm_log = run_npm_fake("broken") +check("npm: still not starting after the clean reinstall is a failed install, never a success", + not ok_ and "still does not start after a clean reinstall" in out and "codex: installed" not in out + and npm_log.count("NPM uninstall -g") == 1, out + npm_log) + +# A broken copy that is NOT npm's (npm names no prefix; PATH resolves another +# codex) is reported, and npm uninstall never runs against it. +shadow_bin = os.path.join(SCRATCH, "bin-shadow") +shutil.rmtree(shadow_bin, ignore_errors=True) +os.makedirs(shadow_bin) +with open(os.path.join(shadow_bin, "npm"), "w") as fh: + fh.write('#!/bin/sh\necho "NPM $*" >> "%s"\nexit 0\n' % LOG) +with open(os.path.join(shadow_bin, "codex"), "w") as fh: + fh.write('#!/bin/sh\necho "broken vendor copy" >&2\nexit 1\n') +for name in ("npm", "codex"): + os.chmod(os.path.join(shadow_bin, name), 0o755) +if os.path.exists(LOG): + os.remove(LOG) +shadow_env = {"HOME": os.path.join(SCRATCH, "home-shadow"), "PATH": shadow_bin + ":" + BIN + ":/usr/bin:/bin"} +os.makedirs(shadow_env["HOME"], exist_ok=True) +tmp_shadow = os.path.join(SCRATCH, "tmp-shadow") +os.makedirs(tmp_shadow, exist_ok=True) +out = io.StringIO() +with contextlib.redirect_stdout(out): + ok_ = installer._install_npm("codex", model.clis["codex"]["install"], tmp_shadow, shadow_env, False, + model.clis["codex"]) +npm_log = open(LOG).read() if os.path.exists(LOG) else "" +check("npm: a broken copy npm did not install is reported, never uninstalled", + not ok_ and "not the copy npm installed" in out.getvalue() and "NPM uninstall" not in npm_log, + out.getvalue() + npm_log) + # an unverified exception needs --allow-unverified ok_, out, home, npm_log = run("cline") check("unverified: refused without --allow-unverified", not ok_ and "--allow-unverified" in out and npm_log == "", out) diff --git a/tests/scopes/dispatch.sh b/tests/scopes/dispatch.sh index 2572b87..8197d63 100644 --- a/tests/scopes/dispatch.sh +++ b/tests/scopes/dispatch.sh @@ -130,7 +130,7 @@ scope_dispatch() { # The verbs around launching. out="$(ak -- --version)" - expect_eq "ak --version" "${out}" "agentkit 1.5.0 (interface 1)" + expect_eq "ak --version" "${out}" "agentkit 1.5.1 (interface 1)" out="$(ak)"; status=$? expect_eq "ak with no arguments lists the kinds" "${status}:$(grep -c '^claude-glm ' <<<"${out}")" "0:1" expect_has "ak with no arguments shows what is installed" "${out}" "${BOX}/bin/claude" diff --git a/tests/scopes/doctor.sh b/tests/scopes/doctor.sh index 88b5280..4764e12 100644 --- a/tests/scopes/doctor.sh +++ b/tests/scopes/doctor.sh @@ -41,7 +41,7 @@ scope_doctor() { out="$("${AK_PY}" "${ROOT}/tests/py/schema_check.py" "${schema}" "${doc}")" expect_eq "doctor --json matches docs/schema/doctor-v1.json" "${out}" "valid" expect_eq "doctor reports interface 1" "$(json_get "${doc}" 'd["interface"]')" 1 - expect_eq "doctor reports the kit version" "$(json_get "${doc}" 'd["version"]')" "1.5.0" + expect_eq "doctor reports the kit version" "$(json_get "${doc}" 'd["version"]')" "1.5.1" expect_eq "doctor reports this OS" "$(json_get "${doc}" 'd["os"] in ("macos", "linux")')" true expect_eq "doctor lists all 20 kinds" "$(json_get "${doc}" 'len(d["kinds"])')" 20 expect_eq "doctor sees the installed CLIs" "$(json_get "${doc}" 'all(v["installed"] for v in d["kinds"].values())')" true @@ -141,6 +141,27 @@ scope_doctor() { "$(json_get "${BOX}/out" 'any("ak update codex" in p for p in d["problems"])')" false out="$(ak -- doctor)" expect_has "text doctor shows the kit pin alongside its version status" "${out}" "kit pin: ${pinned}; version: newer" + # A CLI that is installed but does not start (npm dropped its platform + # binary) is a problem with the exact repair, not just an unknown version. + printf '#!/bin/sh\necho "Error: Missing optional dependency @openai/codex-linux-arm64." >&2\nexit 1\n' > "${BOX}/bin/codex" + chmod +x "${BOX}/bin/codex" + ak_split -- doctor --json + expect_eq "a CLI that does not start is one doctor problem" \ + "$(json_get "${BOX}/out" 'sum("codex: " in p and "does not start" in p for p in d["problems"])')" 1 + expect_has "the problem quotes the CLI's own error" "$(cat "${BOX}/out")" "Missing optional dependency" + expect_has "a copy npm did not install is not sent to npm uninstall" "$(cat "${BOX}/out")" "remove or repair the broken copy at ${BOX}/bin/codex" + expect_eq "its version status stays unknown (schema unchanged)" \ + "$(json_get "${BOX}/out" 'd["kinds"]["codex"]["version_status"]')" unknown + # The same broken copy inside npm's global prefix: the npm repair. + printf '#!/bin/sh\n[ "$1" = config ] && echo "%s"\nexit 0\n' "${BOX}" > "${BOX}/bin/npm" + chmod +x "${BOX}/bin/npm" + ak_split -- doctor --json + expect_has "a copy in npm's prefix names the clean npm reinstall" "$(cat "${BOX}/out")" "npm uninstall -g @openai/codex, then ak install codex" + rm -f "${BOX}/bin/npm" + doctor_version_fake codex "requires Node 99.0.0" + ak_split -- doctor --json + expect_eq "a CLI that starts and prints an odd line is not called broken" \ + "$(json_get "${BOX}/out" 'any("does not start" in p for p in d["problems"])')" false doctor_version_fake codex "requires Node 99.0.0" ak_split -- doctor --json expect_eq "an error mentioning a number is not a CLI version" \ diff --git a/tests/scopes/install.sh b/tests/scopes/install.sh index a80cb86..36802a6 100644 --- a/tests/scopes/install.sh +++ b/tests/scopes/install.sh @@ -43,7 +43,7 @@ scope_install() { check "installed bin/ak is executable" test -x "${dest}/bin/ak" expect_eq "the install root is mode 700" "$(file_mode "${dest}")" 700 out="$(box_run -- "${dest}/bin/ak" --version)" - expect_eq "the installed ak runs" "${out}" "agentkit 1.5.0 (interface 1)" + expect_eq "the installed ak runs" "${out}" "agentkit 1.5.1 (interface 1)" ( cd "${BOX}/work" && env -i HOME="${BOX}/home" PATH="${BOX}/bin:${BASE_PATH}" "${dest}/bin/ak" doctor --json \ "${BOX}/doctor.json" 2>/dev/null ) expect_eq "the installed ak doctor --json reports interface 1 (smoke)" "$(json_get "${BOX}/doctor.json" 'd["interface"]')" 1 @@ -159,7 +159,7 @@ scope_install() { skip "PowerShell parse of install.ps1 (no pwsh here; the CI windows job parses and runs it)" fi out="$(box_run -- env -u AGENTKIT_ENV_LOADED "${AK_PY}" "${ROOT}/lib/ak.py" --version)" - expect_eq "the python core runs without the bash launcher (the Windows path)" "${out}" "agentkit 1.5.0 (interface 1)" + expect_eq "the python core runs without the bash launcher (the Windows path)" "${out}" "agentkit 1.5.1 (interface 1)" box_new install-pyenv box_env_file '# comment' 'export ZAI_CODING_API_KEY="planted-quoted-0x1"' "XAI_API_KEY='planted-single'" 'IGNORED LINE' out="$(box_run FAKE_SHOW_SECRETS=1 -- "${AK_PY}" "${ROOT}/lib/ak.py" claude-glm)" @@ -203,7 +203,7 @@ install_setup_contract() { ( cd "${ROOT}" && tar -cf - bin lib providers.toml skills docs LICENSE README.md CREDITS.md CHANGELOG.md install.sh ) | ( cd "${tar_root}" && tar -xf - ) out="$(box_run -- bash "${tar_root}/install.sh" --no-rc)"; status=$? expect_eq "install setup: install.sh runs from an extracted release tarball layout" "${status}" 0 - expect_eq "install setup: ... and the installed kit works" "$(box_run -- "${BOX}/home/.local/share/agentkit/bin/ak" --version)" "agentkit 1.5.0 (interface 1)" + expect_eq "install setup: ... and the installed kit works" "$(box_run -- "${BOX}/home/.local/share/agentkit/bin/ak" --version)" "agentkit 1.5.1 (interface 1)" expect_eq "install setup: the helper runs from the extracted tarball without installing" \ "$(box_run -- "${AK_PY}" "${tar_root}/lib/ak.py" setup probe --json | "${AK_PY}" -c 'import json,sys; print(json.load(sys.stdin)["schema"])')" "setup-probe-v1" } diff --git a/tests/scopes/setup-skill.sh b/tests/scopes/setup-skill.sh index 267a1d8..69a4ea1 100644 --- a/tests/scopes/setup-skill.sh +++ b/tests/scopes/setup-skill.sh @@ -31,7 +31,7 @@ scope_setup_skill() { setup_skill_scenarios() { local drift copy out status py_checks skill_scenarios.py "${ROOT}" - for drift in "install.sh --no-rc|install.sh --no-rcc" "--branch v1.5.0|--branch v9.9.9" "setup verify --json|setup verify --jsno"; do + for drift in "install.sh --no-rc|install.sh --no-rcc" "--branch v1.5.1|--branch v9.9.9" "setup verify --json|setup verify --jsno"; do copy="${SANDBOX}/skill-drift" rm -rf "${copy}" cp -R "${ROOT}/skills/agentkit-setup" "${copy}" diff --git a/tests/scopes/update.sh b/tests/scopes/update.sh index 1691576..8a29732 100644 --- a/tests/scopes/update.sh +++ b/tests/scopes/update.sh @@ -141,6 +141,8 @@ PY expect_eq "the vendor link is untouched" "$(readlink "${BOX}/bin/codex")" "${BOX}/vendor/codex-standalone/current/bin/codex" check "the registry document was fetched" grep -q 'registry.npmjs.org/@openai/codex/latest' "${FAKE_NET_LOG}" check "the tarball was downloaded and handed to npm" grep -q 'NPM install -g' "${FAKE_NET_LOG}" + check "ak update installs npm CLIs with their optional dependencies" grep -q 'NPM install -g --include=optional ' "${FAKE_NET_LOG}" + check "a CLI that starts after the update is not reinstalled" bash -c "! grep -q '^NPM uninstall' '${FAKE_NET_LOG}'" # --- codex: a tampered artifact refuses before anything moves ----------- printf 'tampered tarball bytes\n' > "$(netfile 'https://registry.npmjs.org/@openai/codex/-/codex-9.9.9.tgz')" @@ -151,6 +153,28 @@ PY check "the pin still did not move" test "$(field_of "${dest}/providers.toml" codex version)" = "${pin0}" expect_eq "the vendor link survived the failed verify" "$(readlink "${BOX}/bin/codex")" "${BOX}/vendor/codex-standalone/current/bin/codex" + # --- codex: a verified release that does not start is a failed update --- + # (npm dropped its platform binary): one clean reinstall, then the truth, + # in one JSON document, and the pin stays. + local bintg + mkdir -p "${BOX}/build-broken/package/bin" + printf '#!/bin/sh\necho "Error: Missing optional dependency @openai/codex-linux-arm64." >&2\nexit 1\n' \ + > "${BOX}/build-broken/package/bin/codex" + chmod +x "${BOX}/build-broken/package/bin/codex" + cp "${BOX}/build/package/package.json" "${BOX}/build-broken/package/" + tar -cf - -C "${BOX}/build-broken" package | gzip -n > "$(netfile 'https://registry.npmjs.org/@openai/codex/-/codex-9.9.9.tgz')" + bintg="$(python3 -c "import hashlib,base64,sys; print('sha512-'+base64.b64encode(hashlib.sha512(open(sys.argv[1],'rb').read()).digest()).decode())" \ + "$(netfile 'https://registry.npmjs.org/@openai/codex/-/codex-9.9.9.tgz')")" + printf '{"version":"9.9.9","dist":{"integrity":"%s"}}\n' "${bintg}" > "$(netfile 'https://registry.npmjs.org/@openai/codex/latest')" + : > "${FAKE_NET_LOG}" + ak_up -- update codex --json; status=$? + expect_eq "a release that does not start fails the update (one JSON document)" \ + "$(json_get "${BOX}/out" 'd["results"][0]["status"]')+$(json_get "${BOX}/out" 'd["results"][0]["pin_written"]')" "failed+false" + expect_eq "exactly one clean reinstall was tried" "$(grep -c '^NPM uninstall -g @openai/codex' "${FAKE_NET_LOG}")" 1 + check "the pin did not move for a CLI that does not start" test "$(field_of "${dest}/providers.toml" codex version)" = "${pin0}" + expect_has "stderr names the CLI's own error" "$(cat "${BOX}/err")" "Missing optional dependency" + printf '{"version":"9.9.9","dist":{"integrity":"%s"}}\n' "${intg}" > "$(netfile 'https://registry.npmjs.org/@openai/codex/latest')" + # --- codex: the take-over lands the verified release and moves the pin -- tar -cf - -C "${BOX}/build" package | gzip -n > "$(netfile 'https://registry.npmjs.org/@openai/codex/-/codex-9.9.9.tgz')" ak_up -- update codex --take-over; status=$?