Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-changelog-link-to-update-prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Add a clickable changelog link to the update prompt.
4 changes: 4 additions & 0 deletions apps/kimi-code/src/cli/update/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {

import { type InstallSource, type UpdateTarget } from './types';

const CHANGELOG_URL = 'https://moonshotai.github.io/kimi-code/en/release-notes/changelog.html';

export type InstallPromptChoiceValue = 'install' | 'skip';

export interface InstallPromptChoice {
Expand Down Expand Up @@ -66,9 +68,11 @@ function renderInstallPrompt(
const targetVersion = chalk.hex(UPDATE_PROMPT_SUCCESS).bold(options.target.version);
const sourceLabel = chalk.hex(UPDATE_PROMPT_PRIMARY).bold(options.installSource);
const command = chalk.hex(UPDATE_PROMPT_PRIMARY)(options.installCommand);
const changelogText = chalk.hex(UPDATE_PROMPT_PRIMARY).underline(`View changelog: ${CHANGELOG_URL}`);
const lines = [
chalk.hex(UPDATE_PROMPT_PRIMARY).bold('Kimi Code Update Available'),
chalk.hex(UPDATE_PROMPT_MUTED)(`${PRODUCT_NAME} has a newer release ready.`),
`]8;;${CHANGELOG_URL}\\${changelogText}]8;;\\`,
Comment thread
liruifengv marked this conversation as resolved.
'',
`${label('Current')} ${currentVersion}`,
`${label('Target ')} ${targetVersion}`,
Expand Down
42 changes: 42 additions & 0 deletions apps/kimi-code/test/cli/update/prompt.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { EventEmitter } from 'node:events';

import { describe, expect, it } from 'vitest';

import {
createInstallPromptChoices,
getDefaultInstallPromptSelection,
moveInstallPromptSelection,
promptForInstallConfirmation,
} from '#/cli/update/prompt';

describe('install prompt helpers', () => {
Expand All @@ -28,3 +31,42 @@ describe('install prompt helpers', () => {
expect(moveInstallPromptSelection(1, 'down', 2)).toBe(1);
});
});

describe('promptForInstallConfirmation', () => {
it('renders changelog hyperlink in the prompt output', async () => {
const CHANGELOG_URL = 'https://moonshotai.github.io/kimi-code/en/release-notes/changelog.html';

const input = Object.assign(new EventEmitter(), {
isRaw: false,
setRawMode: () => {},
resume: () => {},
off: () => {},
}) as unknown as NodeJS.ReadStream;

const outputChunks: string[] = [];
const output = {
write: (chunk: string) => {
outputChunks.push(chunk);
return true;
},
} as NodeJS.WriteStream;

const promptPromise = promptForInstallConfirmation({
currentVersion: '0.4.0',
target: { version: '0.5.0' },
installCommand: 'npm install -g @moonshot-ai/kimi-code@0.5.0',
installSource: 'npm-global',
input,
output,
});

// Emit keypress to trigger initial render then exit
input.emit('keypress', '', { name: 'escape' });

await promptPromise;

const rendered = outputChunks.join('');
expect(rendered).toContain(CHANGELOG_URL);
expect(rendered).toContain('View changelog');
});
});
Loading