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

Function runShell

apps/kimi-code/src/cli/run-shell.ts:34–232  ·  view source on GitHub ↗
(
  opts: CLIOptions,
  version: string,
  runOptions: { readonly migrateOnly?: boolean } = {},
)

Source from the content-addressed store, hash-verified

32import { createKimiCodeHostIdentity } from './version';
33
34export async function runShell(
35 opts: CLIOptions,
36 version: string,
37 runOptions: { readonly migrateOnly?: boolean } = {},
38): Promise<void> {
39 const startedAt = Date.now();
40 const configStartedAt = startedAt;
41 let tuiConfig: TuiConfig;
42 let configWarning: string | undefined;
43 try {
44 tuiConfig = await loadTuiConfig();
45 } catch (error) {
46 if (!(error instanceof TuiConfigParseError)) throw error;
47 tuiConfig = error.fallback;
48 configWarning = error.message;
49 }
50
51 // Initialise the global Theme singleton before pi-tui grabs stdin.
52 const palette = await getColorPalette(tuiConfig.theme);
53 currentTheme.setPalette(palette);
54
55 const workDir = process.cwd();
56 const telemetryBootstrap = createCliTelemetryBootstrap();
57 const telemetryClient: TelemetryClient = {
58 track,
59 withContext: withTelemetryContext,
60 setContext: setTelemetryContext,
61 };
62 const harness = createKimiHarness({
63 homeDir: telemetryBootstrap.homeDir,
64 identity: createKimiCodeHostIdentity(version),
65 telemetry: telemetryClient,
66 onOAuthRefresh: (outcome) => {
67 if (outcome.success) {
68 track('oauth_refresh', { outcome: 'success' });
69 return;
70 }
71 track('oauth_refresh', {
72 outcome: 'error',
73 reason: outcome.reason,
74 });
75 },
76 sessionStartedProperties: { yolo: opts.yolo, auto: opts.auto, plan: opts.plan, afk: false },
77 });
78 log.info('kimi-code starting', {
79 version,
80 uiMode: CLI_UI_MODE,
81 nodeVersion: process.version,
82 platform: `${process.platform}/${process.arch}`,
83 workDir,
84 });
85
86 await harness.ensureConfigFile();
87 const migrationPlan = await detectPendingMigration({
88 sourceHome: join(homedir(), '.kimi'),
89 targetHome: harness.homeDir,
90 ignoreMarker: runOptions.migrateOnly,
91 });

Callers 3

run-shell.test.tsFile · 0.90
handleMainCommandFunction · 0.90
handleMigrateCommandFunction · 0.90

Calls 15

getCurrentSessionIdMethod · 0.95
hasSessionContentMethod · 0.95
startMethod · 0.95
getStartupMcpMsMethod · 0.95
loadTuiConfigFunction · 0.90
getColorPaletteFunction · 0.90
combineStartupNoticeFunction · 0.90
initializeCliTelemetryFunction · 0.90
toTerminalHyperlinkFunction · 0.90
createKimiHarnessFunction · 0.85

Tested by

no test coverage detected