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

Function formatReadyBanner

apps/kimi-code/src/cli/sub/server/run.ts:426–481  ·  view source on GitHub ↗
(
  origin: string,
  host: string,
  opts: FormatReadyBannerOptions = {},
)

Source from the content-addressed store, hash-verified

424}
425
426function formatReadyBanner(
427 origin: string,
428 host: string,
429 opts: FormatReadyBannerOptions = {},
430): string {
431 const primary = (text: string): string => chalk.hex(darkColors.primary)(text);
432 const title = (text: string): string => chalk.bold.hex(darkColors.primary)(text);
433 const dim = (text: string): string => chalk.hex(darkColors.textDim)(text);
434 const muted = (text: string): string => chalk.hex(darkColors.textMuted)(text);
435 const label = (text: string): string => chalk.bold.hex(darkColors.textDim)(text);
436 const url = (text: string): string => chalk.hex(darkColors.accent)(text);
437 // Render the `#token=…` fragment in a de-emphasized gray so the host/port
438 // stands out while the full URL stays selectable for copying.
439 const urlWithDimToken = (href: string): string => {
440 const [base, frag] = splitTokenFragment(href);
441 return frag === '' ? url(base) : url(base) + dim(frag);
442 };
443
444 const port = Number(new URL(origin).port);
445 // Borderless header: the Kimi sprite (the little mascot with eyes) sits next
446 // to the title, keeping the brand without the enclosing box.
447 const logo = ['▐█▛█▛█▌', '▐█████▌'] as const;
448 const lines: string[] = [
449 '',
450 ` ${primary(logo[0])} ${title('Kimi server ready')} ${dim(getVersion())}`,
451 ` ${primary(logo[1])} ${dim('Local web UI is available from this machine.')}`,
452 '',
453 ];
454
455 // Access links.
456 for (const { label: text, url: href } of accessUrlLines(
457 host,
458 port,
459 opts.token,
460 opts.networkAddresses,
461 )) {
462 lines.push(` ${label(text)}${urlWithDimToken(href)}`);
463 }
464 // On a loopback bind there is no network URL; show how to enable one.
465 if (isLoopbackHost(host)) {
466 lines.push(` ${label('Network: ')}${muted('off')}${dim(' use --host to enable')}`);
467 }
468 if (opts.token !== undefined) {
469 // Set the token off with surrounding whitespace rather than color, so it is
470 // easy to spot without being highlighted.
471 lines.push('');
472 lines.push(` ${label('Token: ')}${opts.token}`);
473 lines.push('');
474 }
475
476 // Auxiliary controls last.
477 lines.push(` ${label('Logs: ')}${muted('off')}${dim(' use --log-level info to enable')}`);
478 lines.push(` ${label('Stop: ')}${muted('kimi server kill')}`);
479 lines.push('');
480 return lines.join('\n');
481}
482
483const DEFAULT_RUN_COMMAND_DEPS: RunCommandDeps = {

Callers 1

writeReadyFunction · 0.85

Calls 10

getVersionFunction · 0.90
accessUrlLinesFunction · 0.90
isLoopbackHostFunction · 0.90
titleFunction · 0.85
urlWithDimTokenFunction · 0.85
primaryFunction · 0.70
dimFunction · 0.70
labelFunction · 0.70
mutedFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected