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

Function detectInstallSource

apps/kimi-code/src/cli/update/source.ts:135–160  ·  view source on GitHub ↗
(
  deps: Partial<DetectInstallSourceDeps> = {},
)

Source from the content-addressed store, hash-verified

133}
134
135export async function detectInstallSource(
136 deps: Partial<DetectInstallSourceDeps> = {},
137): Promise<InstallSource> {
138 const platform = deps.platform ?? process.platform;
139 const resolved: DetectInstallSourceDeps = {
140 getPackageRoot: deps.getPackageRoot ?? getHostPackageRoot,
141 getGlobalPrefix:
142 deps.getGlobalPrefix ??
143 (() => execFileText(npmCommand(platform), ['prefix', '-g']).then((text) => text.trim())),
144 detectNative: deps.detectNative ?? detectNativeInstall,
145 platform,
146 };
147
148 if (resolved.detectNative()) return 'native';
149
150 const packageRoot = resolved.getPackageRoot();
151 const heuristic = classifyByPathHeuristic(packageRoot);
152 if (heuristic !== null) return heuristic;
153
154 try {
155 const globalPrefix = await resolved.getGlobalPrefix();
156 return classifyInstallSource(packageRoot, globalPrefix, resolved.platform);
157 } catch {
158 return 'unsupported';
159 }
160}

Callers 7

source.test.tsFile · 0.90
createDefaultExportDepsFunction · 0.90
createDefaultUpgradeDepsFunction · 0.90
runUpdatePreflightFunction · 0.90

Calls 4

npmCommandFunction · 0.85
classifyByPathHeuristicFunction · 0.85
classifyInstallSourceFunction · 0.85
execFileTextFunction · 0.70

Tested by

no test coverage detected