Skip to content

fix(install): npm CLIs keep their platform binary and must start (v1.5.1) - #56

Merged
xergioalex merged 3 commits into
mainfrom
fix/npm-platform-binary
Nov 19, 2026
Merged

xergioalex merged 3 commits into
mainfrom
fix/npm-platform-binary

Conversation

@xergioalex

Copy link
Copy Markdown
Member

Problem

This was reported from a Linux aarch64 devcontainer. Codex's own in-CLI update ran npm install -g @openai/codex, which dropped the optional dependency that carries the platform binary (@openai/codex-linux-arm64). Every later ak codex then failed with:

Error: Missing optional dependency @openai/codex-linux-arm64. Reinstall Codex: npm install -g @openai/codex@latest

The reported workaround worked: npm uninstall -g @openai/codex && npm install -g @openai/codex@latest --include=optional.

The in-CLI update itself is Codex's, not ak's, so ak cannot verify it. ak's own npm path (ak install, ak update) had the same gap, though: it never passed --include=optional, and it called an install a success without checking that the CLI starts.

Change

  • --include=optional: ak install and ak update now run npm install -g --include=optional <verified tarball>.
  • Start check: after the install, ak probes the installed copy with <cli> --version. It probes npm's prefix copy, or the copy PATH resolves; on Windows only the resolved .cmd.
    • If the CLI does not start, ak runs npm uninstall -g <package> and installs once more.
    • If it still does not start, the install fails with the CLI's own error. It never prints "installed".
  • ak doctor: a CLI that resolves but whose --version exits non-zero becomes a problem. The problem quotes the CLI's error and names the repair: npm uninstall -g <package>, then ak install <cli>. The doctor JSON shape is unchanged: version_status stays unknown, so interface 1 is untouched.
  • Shared helper: npm_prefix_bin moves to installer.py and update.py reuses it.
  • Docs: install.md, update.md, doctor.md and the CHANGELOG [Unreleased] section are updated.

Tests

  • tests/py/install_checks.py:
    • The install always includes optional dependencies.
    • A fake npm whose first install leaves a codex that exits 1 with "Missing optional dependency": ak reinstalls it cleanly and the install counts.
    • A fake npm that stays broken: the install fails after exactly one uninstall.
  • doctor scope: a broken codex is exactly one problem, which quotes the error and names the repair, and version_status stays unknown. A CLI that starts but prints an odd line is not called broken.
  • update scope: the update installs with --include=optional, and a CLI that starts is not reinstalled.
  • Gate: bash tests/run.sh gives 2949 passed, 0 failed, 1 skipped. Public hygiene is clean.

🤖 Generated with Claude Code

Codex ships its native binary as a per-platform optional dependency
(@openai/codex-linux-arm64, ...). An in-place npm install can drop it, and
the CLI then fails with "Missing optional dependency" while the install
reported success.

ak install and ak update now run npm install -g with --include=optional,
then probe the installed copy's --version. A CLI that does not start is
uninstalled and installed once more; still failing, the install fails with
the CLI's own error instead of printing "installed". ak doctor reports a
CLI that resolves but does not start as a problem with the exact repair;
the doctor JSON shape is unchanged (version_status stays unknown).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xergioalex xergioalex added the Ready Ready for review label Nov 19, 2026
Review findings on the start check:

- the post-install --version probe ran the freshly installed CLI (and the
  unpinned dependencies npm fetched for it) with the full process
  environment; it now gets the same key-free environment npm gets
  (common.probe_status takes env), and a test plants a key in the process
  environment to prove it;
- the clean reinstall runs only when the broken copy lives in npm's global
  prefix; a broken copy npm did not install is reported, never reinstalled
  over, and doctor names the npm repair only for a copy in that prefix;
- doctor runs one --version per CLI (version and start problem from the
  same probe), and install and doctor share one rule: a non-zero exit;
- the update scope now covers a release that does not start: a failed
  update, one JSON document, exactly one clean reinstall, the pin kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xergioalex

Copy link
Copy Markdown
Member Author

Self-review: head 6236e09

Verdict: approve. I ran an independent review on the first head (b84d9b4). It found nothing critical: one major finding and five minor ones, all fixed in 6236e09.

# Finding Fix
Major The post-install --version probe ran the new CLI, and the unpinned dependencies npm fetched for it, with every key in the process environment. common.probe_status takes env, and the probe gets the key-free installer_env. The new check plants a key in os.environ. I confirmed it fails when env= is removed.
Minor The repair could reinstall over a copy npm never wrote, for example a vendor copy first on PATH. The uninstall and reinstall run only when the broken copy is under npm's global prefix. Otherwise ak reports the copy and repairs nothing. A new check proves npm uninstall never runs in that case.
Minor Doctor's fix text assumed the broken copy came from npm. Doctor gives the npm repair only for a copy in npm's prefix. Otherwise it says "remove or repair the broken copy at ". Both cases are tested.
Minor A hanging CLI cost doctor two probes. Doctor now takes the version and the start problem from one --version.
Minor Install and doctor used different rules for "does not start". Both use one rule: a non-zero exit.
Minor The update scope had no broken case. New scenario: a verified release that does not start. It produces a failed update, one JSON document, exactly one clean reinstall, and an unchanged pin.

Nits: the note about npm 6 and 7 is now in docs/install.md, and the update.md wrap is fixed.

Unchanged: interface 1 and the doctor-v1 shape (version_status stays unknown). The code uses the stdlib only, and ak itself prints no key value.

Gate: bash tests/run.sh gives 2956 passed, 0 failed, 1 skipped. Public hygiene is clean.

Stamps 1.5.1: lib/common.py VERSION, the skills' versions, every pinned
install line (README, docs/install.md, docs/setup.md, the skills), the
schema $id URLs, the doctor example, the issue template, the addon
registry and AGENTS.md, and the test version checks. CHANGELOG gets the
1.5.1 section and the missing 1.5.0 and 1.5.1 compare links. The
contract scope keeps its historical 1.5.0 reference (the release that
added the tokens field) and the update scope its 1.4.0 references.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xergioalex xergioalex changed the title fix(install): npm CLIs keep their platform binary and must start fix(install): npm CLIs keep their platform binary and must start (v1.5.1) Nov 19, 2026
@xergioalex

Copy link
Copy Markdown
Member Author

Self-review: head 71fd308 (release stamp added)

Verdict: approve. This head adds one commit to 6236e09: the 1.5.1 stamp. It changes no code beyond lib/common.py VERSION.

  • Stamped from 1.5.0 to 1.5.1:
    • VERSION, the three skills' version;
    • every --branch / @v install pin in the README, docs/install.md, docs/setup.md and the skills;
    • the 10 schema $id URLs;
    • the doctor example, the bug-report template placeholder, and the agentkit entry in .dwp/config.json;
    • the AGENTS.md registry note;
    • the test version checks.
  • Kept on purpose: tests/scopes/contract.sh still names 1.5.0, the release that added the tokens field, and tests/scopes/update.sh keeps its historical 1.4.0 references.
  • CHANGELOG: the [1.5.1] - 2026-11-18 section and the compare links. The 1.5.0 compare link was missing and is now added. scripts/release.sh notes 1.5.1 prints the section.
  • Gate: bash tests/run.sh passed 2956, failed 0, skipped 1. Public hygiene is clean.

After the merge, the tag v1.5.1 (annotated) goes on the merge commit. That tag push runs the release workflow.

@xergioalex
xergioalex merged commit 1f31c11 into main Nov 19, 2026
6 checks passed
@xergioalex
xergioalex deleted the fix/npm-platform-binary branch November 19, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant