Skip to content

fix: recommend the CLI invocation that reaches the running build - #898

Merged
admarble merged 1 commit into
mainfrom
fix/cli-invocation-recommendation
Aug 4, 2026
Merged

admarble merged 1 commit into
mainfrom
fix/cli-invocation-recommendation

Conversation

@admarble

@admarble admarble commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Problem

A drift warning whose remediation makes the drift worse:

!  Version current, but 21 file(s) differ from bundled content
   Run: npx sequant sync --force (or npx sequant update)

npx sequant is hardcoded. That's correct for the documented install path — README says npm install sequant then npx sequant init, and with a local dependency npx resolves node_modules/.bin/sequant while a bare sequant isn't on PATH.

It's wrong for a global or npm linked install with no local dependency. Observed in a real project:

sequant dep:               NOT A LOCAL DEP
node_modules/.bin/sequant: absent
~/.npm/_npx cached copies: 2.9.0 (2026-06-15), 2.9.0 (06-18), 2.9.0 (07-29)

With nothing local to resolve, npx sequant falls through to those cached published copies — older than the linked build that just printed the warning. Following the message literally would have written the stale templates back over the current ones and re-armed the same warning on the next run. The remediation fights itself.

Fix

resolveCliInvocation() picks the form that actually reaches this build:

Install shape Recommends
project-local dependency npx sequant
npx cache npx sequant
global / npm linked / dev checkout sequant

Three messages consume it: sync's outdated-skills and content-drift warnings, and doctor's Skills Version check.

A linked checkout resolves through its realpath (Node resolves symlinks unless --preserve-symlinks is set), so it matches neither the global nor the local pattern and correctly lands on the bare form.

isNpxCacheInstall is split out rather than reusing isLocalNodeModulesInstall — that one deliberately excludes the cache because it answers a different question ("is this a dependency the user can npm update"). Its Windows path is pinned by a test, since the sibling predicate checks a \.npm\_npx\ variant after normalizing separators, where it can never match.

What this deliberately does not do

It does not strip npx globally. 13 other call sites keep it, and they're right to — for the documented install shape npx sequant is the only invocation that works.

Verification

Mutation-verified, both directions. Forcing the helper to always return npx sequant:

× recommends bare `sequant` for a global install
× recommends bare `sequant` for an npm-linked dev checkout
  Tests  2 failed | 72 passed (74)

Forcing it to always return sequant:

× recommends `npx sequant` for a project-local dependency
× recommends `npx sequant` when reached through the npx cache
  Tests  2 failed | 72 passed (74)

Each mutation fails exactly the tests that gate it and nothing else.

End-to-end against the linked build — a project with one drifted file:

!  Version current, but 1 file(s) differ from bundled content
   Run: sequant sync --force (or sequant update)

Full suite: 235 files, 4943 passed, 1 expected fail, 2 skipped. Lint and tsc --noEmit clean.

Note for the reviewer

package-lock.json picked up two unrelated changes locally and is excluded from this PR: a legitimate engines.node sync (>=22.12.0 → >=22.13.0, which the lockfile mirror still lags on main) and the known local-npm corruption that strips libc fields from optional deps (documented at worktree-manager.ts:563). The engine-floor lag looks like a real follow-up worth its own change.

sync's outdated/drift warnings and doctor's Skills Version check all
hardcoded `npx sequant`. That is correct for the documented install path
(`npm install sequant`, then `npx sequant ...`), where npx resolves the
project's node_modules/.bin/sequant and a bare `sequant` is not on PATH.

It is wrong for a global or npm-linked install with no local dependency.
There npx cannot resolve locally and falls through to the npx cache,
which can hold an older *published* copy than the build that just printed
the warning -- so the drift warning's own remediation reinstalls the
stale content that raised it and re-arms the warning next run.

resolveCliInvocation() picks per install shape: project-local dependency
or npx cache -> `npx sequant`; global, linked, or dev checkout ->
`sequant`. A linked checkout resolves through its realpath, so it matches
neither the global nor the local pattern and lands on the bare form.

isNpxCacheInstall is split out rather than reusing
isLocalNodeModulesInstall, which deliberately excludes the cache because
it answers a different question ("is this a dependency the user can npm
update"). Its Windows path is pinned by a test: the sibling predicate
checks a `\.npm\_npx\` variant after normalizing separators, where it can
never match.

Mutation-verified, both directions. Forcing the helper to always return
`npx sequant` fails exactly the two bare-form tests (global install,
linked dev checkout) and nothing else; forcing `sequant` fails exactly
the two npx-form tests (project-local dependency, npx cache).

Verified end-to-end against the linked build: a project with one drifted
file now prints `Run: sequant sync --force (or sequant update)`.

Full suite green: 235 files, 4943 passed.

Entire-Checkpoint: b0ecacbf37b4
@admarble
admarble merged commit cf099bc into main Aug 4, 2026
5 checks passed
@admarble
admarble deleted the fix/cli-invocation-recommendation branch August 4, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant