mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 00:35:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,103 +1,96 @@
|
||||
import figures from 'figures'
|
||||
import { homedir } from 'os'
|
||||
import * as React from 'react'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { Step } from '../../projectOnboardingState.js'
|
||||
import {
|
||||
formatCreditAmount,
|
||||
getCachedReferrerReward,
|
||||
} from '../../services/api/referral.js'
|
||||
import type { LogOption } from '../../types/logs.js'
|
||||
import { getCwd } from '../../utils/cwd.js'
|
||||
import { formatRelativeTimeAgo } from '../../utils/format.js'
|
||||
import type { FeedConfig, FeedLine } from './Feed.js'
|
||||
import figures from 'figures';
|
||||
import { homedir } from 'os';
|
||||
import * as React from 'react';
|
||||
import { Box, Text } from '@anthropic/ink';
|
||||
import type { Step } from '../../projectOnboardingState.js';
|
||||
import { formatCreditAmount, getCachedReferrerReward } from '../../services/api/referral.js';
|
||||
import type { LogOption } from '../../types/logs.js';
|
||||
import { getCwd } from '../../utils/cwd.js';
|
||||
import { formatRelativeTimeAgo } from '../../utils/format.js';
|
||||
import type { FeedConfig, FeedLine } from './Feed.js';
|
||||
|
||||
export function createRecentActivityFeed(activities: LogOption[]): FeedConfig {
|
||||
const lines: FeedLine[] = activities.map(log => {
|
||||
const time = formatRelativeTimeAgo(log.modified)
|
||||
const description =
|
||||
log.summary && log.summary !== 'No prompt' ? log.summary : log.firstPrompt
|
||||
const time = formatRelativeTimeAgo(log.modified);
|
||||
const description = log.summary && log.summary !== 'No prompt' ? log.summary : log.firstPrompt;
|
||||
|
||||
return {
|
||||
text: description || '',
|
||||
timestamp: time,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title: 'Recent activity',
|
||||
lines,
|
||||
footer: lines.length > 0 ? '/resume for more' : undefined,
|
||||
emptyMessage: 'No recent activity',
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function createWhatsNewFeed(releaseNotes: string[]): FeedConfig {
|
||||
const lines: FeedLine[] = releaseNotes.map(note => {
|
||||
if (process.env.USER_TYPE === 'ant') {
|
||||
const match = note.match(/^(\d+\s+\w+\s+ago)\s+(.+)$/)
|
||||
const match = note.match(/^(\d+\s+\w+\s+ago)\s+(.+)$/);
|
||||
if (match) {
|
||||
return {
|
||||
timestamp: match[1],
|
||||
text: match[2] || '',
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
text: note,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
const emptyMessage =
|
||||
process.env.USER_TYPE === 'ant'
|
||||
? 'Unable to fetch latest claude-cli-internal commits'
|
||||
: 'Check the Claude Code changelog for updates'
|
||||
: 'Check the Claude Code changelog for updates';
|
||||
|
||||
return {
|
||||
title:
|
||||
process.env.USER_TYPE === 'ant'
|
||||
? "What's new [ANT-ONLY: Latest CC commits]"
|
||||
: "What's new",
|
||||
title: process.env.USER_TYPE === 'ant' ? "What's new [ANT-ONLY: Latest CC commits]" : "What's new",
|
||||
lines,
|
||||
footer: lines.length > 0 ? '/release-notes for more' : undefined,
|
||||
emptyMessage,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function createProjectOnboardingFeed(steps: Step[]): FeedConfig {
|
||||
const enabledSteps = steps
|
||||
.filter(({ isEnabled }) => isEnabled)
|
||||
.sort((a, b) => Number(a.isComplete) - Number(b.isComplete))
|
||||
.sort((a, b) => Number(a.isComplete) - Number(b.isComplete));
|
||||
|
||||
const lines: FeedLine[] = enabledSteps.map(({ text, isComplete }) => {
|
||||
const checkmark = isComplete ? `${figures.tick} ` : ''
|
||||
const checkmark = isComplete ? `${figures.tick} ` : '';
|
||||
return {
|
||||
text: `${checkmark}${text}`,
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
const warningText =
|
||||
getCwd() === homedir()
|
||||
? 'Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead.'
|
||||
: undefined
|
||||
: undefined;
|
||||
|
||||
if (warningText) {
|
||||
lines.push({
|
||||
text: warningText,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
title: 'Tips for getting started',
|
||||
lines,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function createGuestPassesFeed(): FeedConfig {
|
||||
const reward = getCachedReferrerReward()
|
||||
const reward = getCachedReferrerReward();
|
||||
const subtitle = reward
|
||||
? `Share Claude Code and earn ${formatCreditAmount(reward)} of extra usage`
|
||||
: 'Share Claude Code with friends'
|
||||
: 'Share Claude Code with friends';
|
||||
return {
|
||||
title: '3 guest passes',
|
||||
lines: [],
|
||||
@@ -113,5 +106,5 @@ export function createGuestPassesFeed(): FeedConfig {
|
||||
width: 48,
|
||||
},
|
||||
footer: '/passes',
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user