fix(cli): stop reporting an incomplete install as a missing package

Closed
AG
3mo ago
+90-0

Reported from a real global install:

$ agent-relay file -h
`agent-relay file` needs @relayfile/sdk, which is not installed.
Reinstall agent-relay, or install @relayfile/sdk alongside it.

$ agent-relay --version
12.2.5

@relayfile/sdk@0.10.64 was installed and importable, and the same command worked moments later. The global install was being updated to 12.2.5 at the time, so the package directory existed with its contents still being written.

Why the message was wrong

ERR_MODULE_NOT_FOUND covers two different situations and the code alone cannot separate them. Node's message can:

Cannot find package '@relayfile/sdk' imported from …   → genuinely absent
Cannot find module '/abs/path/…/dist/index.js'         → present, incomplete

We discarded the message and reported both as "not installed", sending the operator to reinstall a package already on disk.

Three outcomes now

Node saysmessage
a file pathinstalled but incomplete — wait for the install to finish; underlying error printed, not swallowed
a package that isn't oursdepends on <x>, which is not installed — reinstalling the product wouldn't fix it
anything elseunchanged "not installed" advice

The detection is deliberately positive

The incomplete case keys on the file-path form, not on the absence of a package name. An unrecognised error shape therefore keeps the old message, which is right far more often than "incomplete" would be.

That choice is load-bearing: my first attempt used absence, and it broke three existing tests that construct the error with a code and no message. Those now pass unchanged.

Verified end to end

Against a real global install (12.2.5 in an isolated prefix, patched with this build), breaking the tree three ways:

healthy              → Usage: agent-relay file [options]

dist/ removed        → `agent-relay file` could not load @relayfile/sdk: it is installed but incomplete.
                       If an install is running, wait for it to finish and retry; otherwise reinstall agent-relay.
                       Cannot find module '…/@relayfile/sdk/dist/relay-cli/index.js' imported from …

package removed      → `agent-relay file` needs @relayfile/sdk, which is not installed.

45 tests pass across product-surfaces and relay-cli-surface; tsc --noEmit clean.

Note

No packaging regression here — 12.2.4 and 12.2.5 declare identical dependencies, and a clean global install of 12.2.5 mounts all three groups correctly. The defect was only ever the diagnosis.

🤖 Generated with Claude Code


[!NOTE]
Low Risk
CLI-only error-message logic for failed product imports; no auth, data, or runtime behavior changes beyond clearer diagnostics.

Overview
Product surface load errors now distinguish three ERR_MODULE_NOT_FOUND shapes instead of always saying the product SDK is “not installed.”

When Node reports a missing file under an absolute path, the CLI tells the operator the package is installed but incomplete (wait for an in-progress install or reinstall agent-relay) and includes the underlying error via describeError. When the message names another package than the product SDK, it says the product depends on that package and suggests repairing the dependency tree. Unrecognized shapes still get the original “needs X, which is not installed” guidance.

Tests in product-surfaces.test.ts lock in the incomplete-install and transitive-dependency messages.

Reviewed by Cursor Bugbot for commit 12e01e98ca95179835dbbe83b78fd2bbc317c4bb. Bugbot is set up for automated code reviews on this repo. Configure here.