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

Function detectEnvironment

packages/kaos/src/environment.ts:67–89  ·  view source on GitHub ↗
(deps: EnvironmentDeps)

Source from the content-addressed store, hash-verified

65}
66
67export async function detectEnvironment(deps: EnvironmentDeps): Promise<Environment> {
68 const osKind = resolveOsKind(deps.platform);
69 const osArch = deps.arch;
70 const osVersion = deps.release;
71
72 if (deps.platform === 'win32') {
73 const shellPath = await locateWindowsGitBash(deps);
74 return { osKind, osArch, osVersion, shellName: 'bash', shellPath };
75 }
76
77 const candidates: readonly string[] = ['/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash'];
78 let found: string | undefined;
79 for (const p of candidates) {
80 if (await deps.isFile(p)) {
81 found = p;
82 break;
83 }
84 }
85 if (found !== undefined) {
86 return { osKind, osArch, osVersion, shellName: 'bash', shellPath: found };
87 }
88 return { osKind, osArch, osVersion, shellName: 'sh', shellPath: '/bin/sh' };
89}
90
91async function locateWindowsGitBash(deps: EnvironmentDeps): Promise<string> {
92 const checked: string[] = [];

Callers 2

Calls 2

resolveOsKindFunction · 0.85
locateWindowsGitBashFunction · 0.85

Tested by

no test coverage detected