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

Function renderInstallPrompt

apps/kimi-code/src/cli/update/prompt.ts:61–100  ·  view source on GitHub ↗
(
  options: InstallPromptOptions,
  choices: readonly InstallPromptChoice[],
  selectedIndex: number,
)

Source from the content-addressed store, hash-verified

59}
60
61function renderInstallPrompt(
62 options: InstallPromptOptions,
63 choices: readonly InstallPromptChoice[],
64 selectedIndex: number,
65): readonly string[] {
66 const label = chalk.hex(UPDATE_PROMPT_TEXT_DIM).bold;
67 const currentVersion = chalk.hex(UPDATE_PROMPT_WARNING).bold(options.currentVersion);
68 const targetVersion = chalk.hex(UPDATE_PROMPT_SUCCESS).bold(options.target.version);
69 const sourceLabel = chalk.hex(UPDATE_PROMPT_PRIMARY).bold(options.installSource);
70 const command = chalk.hex(UPDATE_PROMPT_PRIMARY)(options.installCommand);
71 const changelogText = chalk.hex(UPDATE_PROMPT_PRIMARY).underline(`View changelog: ${CHANGELOG_URL}`);
72 const lines = [
73 chalk.hex(UPDATE_PROMPT_PRIMARY).bold('Kimi Code Update Available'),
74 chalk.hex(UPDATE_PROMPT_MUTED)(`${PRODUCT_NAME} has a newer release ready.`),
75 `]8;;${CHANGELOG_URL}\\${changelogText}]8;;\\`,
76 '',
77 `${label('Current')} ${currentVersion}`,
78 `${label('Target ')} ${targetVersion}`,
79 `${label('Source ')} ${sourceLabel}`,
80 `${label('Command')} ${command}`,
81 '',
82 chalk.hex(UPDATE_PROMPT_MUTED)('↑↓ choose · Enter confirm · Esc continue'),
83 '',
84 ];
85
86 for (let i = 0; i < choices.length; i++) {
87 const choice = choices[i];
88 if (choice === undefined) continue;
89 const isSelected = i === selectedIndex;
90 const pointer = isSelected ? '❯' : ' ';
91 const content = ` ${pointer} ${choice.label}`;
92 if (isSelected) {
93 lines.push(chalk.hex(UPDATE_PROMPT_PRIMARY).bold(content));
94 continue;
95 }
96 lines.push(chalk.hex(UPDATE_PROMPT_TEXT_DIM)(content));
97 }
98
99 return lines;
100}
101
102function writePromptFrame(
103 output: NodeJS.WriteStream,

Callers 1

renderFunction · 0.85

Calls 4

boldMethod · 0.80
underlineMethod · 0.80
labelFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected