MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / runUpdatePreflight

Function runUpdatePreflight

apps/kimi-code/src/cli/update/preflight.ts:664–806  ·  view source on GitHub ↗
(
  currentVersion: string,
  options: RunUpdatePreflightOptions = {},
)

Source from the content-addressed store, hash-verified

662}
663
664export async function runUpdatePreflight(
665 currentVersion: string,
666 options: RunUpdatePreflightOptions = {},
667): Promise<UpdatePreflightResult> {
668 const stdout = options.stdout ?? process.stdout;
669 const stderr = options.stderr ?? process.stderr;
670 const logger = options.logger ?? log;
671 const platform = process.platform;
672
673 if (isAutoUpdateDisabledByEnv()) {
674 return 'continue';
675 }
676
677 try {
678 const isInteractive =
679 options.isTTY ?? (process.stdin.isTTY && process.stdout.isTTY);
680 const deviceId = resolveUpdateDeviceId();
681 const bypassRollout = isRolloutBypassedByExperimentalEnv();
682 let installState = await readUpdateInstallState().catch(() => emptyUpdateInstallState());
683 if (isInteractive) {
684 installState = await showPendingBackgroundInstallNotice(
685 installState,
686 currentVersion,
687 stdout,
688 options.track,
689 logger,
690 );
691 }
692
693 const cache = await readUpdateCache().catch(() => null);
694 const cachedManifest = cache?.manifest ?? null;
695 const cachedDecision = decidePassiveUpdateTarget(
696 currentVersion,
697 cache?.latest ?? null,
698 cachedManifest,
699 deviceId,
700 new Date(),
701 bypassRollout,
702 );
703 logRolloutDecision('startup-cache', currentVersion, cache?.latest ?? null, cachedManifest, cachedDecision);
704 const target = cachedDecision.target;
705 if (target === null) {
706 refreshAndMaybeInstallInBackground(
707 currentVersion,
708 deviceId,
709 bypassRollout,
710 isInteractive,
711 installState,
712 platform,
713 options.track,
714 logger,
715 );
716 return 'continue';
717 }
718
719 const source: InstallSource =
720 !isInteractive
721 ? 'unsupported'

Callers 2

preflight.test.tsFile · 0.90
handleMainCommandFunction · 0.90

Calls 15

resolveUpdateDeviceIdFunction · 0.90
readUpdateInstallStateFunction · 0.90
readUpdateCacheFunction · 0.90
detectInstallSourceFunction · 0.90
emptyUpdateInstallStateFunction · 0.85
logRolloutDecisionFunction · 0.85
decideUpdateActionFunction · 0.85

Tested by

no test coverage detected