Skip to content
Open
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
37 changes: 37 additions & 0 deletions src/buddy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,40 @@ export const RARITY_COLORS = {
epic: 'autoAccept',
legendary: 'warning',
} as const satisfies Record<Rarity, keyof import('../utils/theme.js').Theme>

export const RARITY_CN = {
common: '普通',
uncommon: '优秀',
rare: '稀有',
epic: '史诗',
legendary: '传说',
} as const satisfies Record<Rarity, string>

export const SPECIES_CN: Record<Species, string> = {
duck: '鸭子',
goose: '鹅',
blob: '史莱姆',
cat: '猫咪',
dragon: '龙',
octopus: '章鱼',
owl: '猫头鹰',
penguin: '企鹅',
turtle: '乌龟',
snail: '蜗牛',
ghost: '幽灵',
axolotl: '美西螈',
capybara: '水豚',
cactus: '仙人掌',
robot: '机器人',
rabbit: '兔子',
mushroom: '蘑菇',
chonk: '胖墩',
}

export const STAT_NAMES_CN: Record<StatName, string> = {
DEBUGGING: '调试',
PATIENCE: '耐心',
CHAOS: '混沌',
WISDOM: '智慧',
SNARK: '毒舌',
}
33 changes: 20 additions & 13 deletions src/commands/buddy/buddy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
RARITY_COLORS,
RARITY_STARS,
STAT_NAMES,
RARITY_CN,
SPECIES_CN,
STAT_NAMES_CN,
type StoredCompanion,
} from '../../buddy/types.js'
import { saveGlobalConfig } from '../../utils/config.js'
Expand Down Expand Up @@ -118,27 +121,31 @@ function CompanionCard({
}
}, [])

const isCN = trimmed === 'info_cn'

// Render companion info
if (!companion) {
const { bones } = roll(companionUserId())
const preview = renderSprite(bones, 0)
const color = RARITY_COLORS[bones.rarity]
return (
<Box flexDirection="column" paddingX={1} paddingY={1} autoFocus={true} onKeyDown={handleKeyDown} tabIndex={0}>
<Text bold>You haven't hatched a companion yet!</Text>
<Text dimColor>Here's a preview of yours:</Text>
<Text bold>{isCN ? '你还没有孵化伙伴!' : "You haven't hatched a companion yet!"}</Text>
<Text dimColor>{isCN ? '这是你的预览:' : "Here's a preview of yours:"}</Text>
<Box flexDirection="column" marginY={1}>
{preview.map((line, i) => (
<Text key={i} color={color}>
{line}
</Text>
))}
<Text italic dimColor>
A {bones.rarity} {bones.species} {RARITY_STARS[bones.rarity]}
{isCN
? `${RARITY_CN[bones.rarity]} ${SPECIES_CN[bones.species]} ${RARITY_STARS[bones.rarity]}`
: `A ${bones.rarity} ${bones.species} ${RARITY_STARS[bones.rarity]}`}
</Text>
</Box>
<Text>Run <Text bold>/buddy hatch</Text> to bring them to life!</Text>
<Text dimColor>Or type <Text bold>q</Text> to dismiss.</Text>
<Text>{isCN ? '运行 ' : 'Run '}<Text bold>/buddy hatch</Text>{isCN ? ' 来孵化它!' : ' to bring them to life!'}</Text>
<Text dimColor>{isCN ? '或按 ' : 'Or type '}<Text bold>q</Text>{isCN ? ' 关闭。' : ' to dismiss.'}</Text>
</Box>
)
}
Expand All @@ -161,21 +168,21 @@ function CompanionCard({
</Box>
<Box flexDirection="column" justifyContent="center">
<Text>
<Text bold>Species:</Text>{' '}
<Text color={color}>{companion.species}</Text>
<Text bold>{isCN ? '物种:' : 'Species:'}</Text>{' '}
<Text color={color}>{isCN ? SPECIES_CN[companion.species] : companion.species}</Text>
</Text>
<Text>
<Text bold>Rarity:</Text>{' '}
<Text bold>{isCN ? '稀有度:' : 'Rarity:'}</Text>{' '}
<Text color={color}>
{companion.rarity} {RARITY_STARS[companion.rarity]}
{isCN ? RARITY_CN[companion.rarity] : companion.rarity} {RARITY_STARS[companion.rarity]}
</Text>
</Text>
{companion.shiny && <Text color="warning">✦ Shiny!</Text>}
{companion.shiny && <Text color="warning">✦ {isCN ? '闪光!' : 'Shiny!'}</Text>}
<Text dimColor>{'─'.repeat(20)}</Text>
<Text bold>Stats:</Text>
<Text bold>{isCN ? '属性:' : 'Stats:'}</Text>
{STAT_NAMES.map(stat => (
<Text key={stat}>
<Text dimColor>{stat}:</Text>{' '}
<Text dimColor>{isCN ? STAT_NAMES_CN[stat] : stat}:</Text>{' '}
<Text color={color}>{companion.stats[stat]}</Text>
</Text>
))}
Expand All @@ -185,7 +192,7 @@ function CompanionCard({
<Text dimColor>
/buddy pet · /buddy mute · /buddy unmute · /buddy release
</Text>
<Text dimColor>Press q or Enter to dismiss</Text>
<Text dimColor>{isCN ? '按 q 或 Enter 关闭' : 'Press q or Enter to dismiss'}</Text>
</Box>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/buddy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const buddyCommand = {
type: 'local-jsx',
name: 'buddy',
description: 'Meet your companion',
argumentHint: '[hatch|pet|mute|unmute|info]',
argumentHint: '[hatch|pet|mute|unmute|info|info_cn]',
load: () => import('./buddy.js'),
} satisfies Command

Expand Down
4 changes: 3 additions & 1 deletion src/server/services/providerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ export class ProviderService {

return {
ANTHROPIC_BASE_URL: baseUrl,
ANTHROPIC_API_KEY: needsProxy ? 'proxy-managed' : provider.apiKey,
...(needsProxy
? { ANTHROPIC_AUTH_TOKEN: 'proxy-managed' }
: { ANTHROPIC_API_KEY: provider.apiKey }),
ANTHROPIC_MODEL: provider.models.main,
ANTHROPIC_DEFAULT_HAIKU_MODEL: provider.models.haiku,
ANTHROPIC_DEFAULT_SONNET_MODEL: provider.models.sonnet,
Expand Down