Dashboard › cli › Distillation
51dcba73-75a2-4b82-bdf1-711d91224716["lore_tm_v1_GzJZRUM30b-kshJQlBKFw6RWuCmVybEjC8pNEbk-Ufs"]
Date: Sep 9, 2026
fetchLatestFromNpm() in packages/cli/src/lib/upgrade.ts:433-454 requests ${NPM_REGISTRY_URL}/latest with Accept: application/json; non-OK responses raise UpgradeError("network_error", "Failed to fetch from npm: <status>"), missing version raises UpgradeError("network_error", "No version found in npm registry"), and success returns data.version.fetchLatestNightlyVersion() in packages/cli/src/lib/upgrade.ts:467-484 performs 2 HTTP requests: getAnonymousToken() followed by fetchNightlyManifest(token), then extracts the manifest annotation via getNightlyVersion(manifest); it checks an optional AbortSignal before each network call because the GHCR helpers do not accept the signal.fetchLatestVersion() in packages/cli/src/lib/upgrade.ts:498-508 routes nightly channels to fetchLatestNightlyVersion(), stable curl or brew installs to fetchLatestFromGitHub(), and stable package-manager installs to fetchLatestFromNpm().nightlyVersionExists() in packages/cli/src/lib/upgrade.ts:522-537 gets an anonymous token and calls fetchManifest(token, \nightly-${version}`); it returns falsewhen anUpgradeErrormessage containsHTTP 404orHTTP 403`, while all other errors propagate.versionExists() in packages/cli/src/lib/upgrade.ts:551-575 checks nightly versions through nightlyVersionExists(version); for stable curl/brew versions it sends HEAD to ${GITHUB_RELEASES_URL}/tags/${version} with getGitHubHeaders(), while package-manager versions use HEAD on ${NPM_REGISTRY_URL}/${version}.DownloadResult in packages/cli/src/lib/upgrade.ts:579-587 contains tempBinaryPath, caller-managed lockPath, and optional patchBytes when a delta upgrade was used.writeChunkSync(fd, chunk) in packages/cli/src/lib/upgrade.ts:597-608 loops around writeSync() to handle partial writes and throws if writeSync() returns 0 or a negative value, preventing an infinite no-progress loop.