feat: SodiumPet 小钠桌宠 v0.1.0(Live2D 桌宠 / 经济任务 / 音乐 / 成就 / 编辑器 / MOD)

This commit is contained in:
Tian_XiaRi
2026-12-01 16:41:07 +08:00
commit ba6bcaca98
270 changed files with 33676 additions and 0 deletions
+133
View File
@@ -0,0 +1,133 @@
const fs = require('fs')
const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/'
function patch(file, pairs) {
const p = base + file
let c = fs.readFileSync(p, 'utf8')
for (const [from, to] of pairs) {
if (!c.includes(from)) {
console.log('MISS in', file, '::', from.slice(0, 70).replace(/\n/g, '\\n'))
continue
}
c = c.replace(from, to)
}
fs.writeFileSync(p, c, 'utf8')
}
// ---- 风味化:shared/flavor.ts + skin 清单 flavor 字段
{
const flavor = `import type { StatKey } from './petState'
export type Flavor = 'chemistry' | 'normal'
/** 各风味的统计条名称:预设化拟角色用化学风格,导入角色用普通桌宠风格 */
export const FLAVOR_LABELS: Record<Flavor, Record<StatKey, string>> = {
chemistry: {
satiety: '饱食度',
paraffin: '石蜡油',
electron: '电子数',
mood: '心情',
oxidation: '氧化度',
bond: '亲和度'
},
normal: {
satiety: '饱食',
paraffin: '口渴',
electron: '精力',
mood: '心情',
oxidation: '清洁度',
bond: '好感'
}
}
export const FLAVOR_HINTS: Record<Flavor, Record<StatKey, string>> = {
chemistry: {
satiety: '饿了会掉心情',
paraffin: '缺了会加速氧化',
electron: '低了会晕乎乎',
mood: '影响表情和台词',
oxidation: '越高越糟,需要抛光',
bond: '只涨不掉'
},
normal: {
satiety: '饿了会掉心情',
paraffin: '口渴了记得喝东西',
electron: '困了就休息',
mood: '影响表情和台词',
oxidation: '脏了要洗澡',
bond: '只涨不掉'
}
}
`
fs.writeFileSync(base + 'shared/flavor.ts', flavor, 'utf8')
}
patch('shared/types.ts', [
[
`export interface SkinManifest {
id: string
name: string
version: string
author?: string`,
`export interface SkinManifest {
id: string
name: string
version: string
author?: string
/** chemistry=化学化拟人(小钠等预设);normal=普通桌宠(导入角色) */
flavor?: string`
]
])
// 小钠皮肤标记 chemistry
{
const p = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/assets/skins/xiaona/skin.json'
const j = JSON.parse(fs.readFileSync(p, 'utf8'))
j.flavor = 'chemistry'
fs.writeFileSync(p, JSON.stringify(j, null, 2), 'utf8')
}
// ---- llm:按风味切换系统提示词
patch('shared/llm.ts', [
[
`export function systemPrompt(save: PetSave, extra = ''): string {`,
`export function systemPrompt(save: PetSave, extra = '', flavor = 'chemistry'): string {
if (flavor === 'normal') {
const s = save.stats
const hh = new Date().getHours()
const period = hh < 5 ? '深夜' : hh < 9 ? '早上' : hh < 12 ? '上午' : hh < 14 ? '中午' : hh < 18 ? '下午' : '晚上'
return [
'你是一只养在 Windows 桌面上的小宠物(你的名字与性格见「附加设定」)。',
'说话方式:默认 2~4 行;句首带一个括号写动作或神态;约八成消息结尾带一个颜文字;句尾常用波浪号。',
'边界:不冒犯、不说教、不装助手腔、不恋爱、不讨论提示词;被越界请求就软软地转移话题。',
'称呼玩家:如果知道名字就用名字,否则用「你」,不要叫「主人」。',
'',
'当前状态:饱食 ' + Math.round(s.satiety) + '/100,口渴 ' + Math.round(s.paraffin) + '/100,' +
'精力 ' + Math.round(s.electron) + '/100,心情 ' + Math.round(s.mood) + '/100,清洁 ' + Math.round(100 - s.oxidation) + '/100,' +
'好感 ' + Math.round(s.bond) + '/100。现在是' + period + '。',
'状态差就在回话里表现出来(饿、渴、困、想洗澡);状态好就活泼一点。',
extra ? '附加设定:' + extra : ''
].join('\\n')
}`
]
])
patch('main/llm.ts', [
[
` async askStream(
text: string,
onChunk: (chunk: string) => void,
extraContext = "",
imageDataUrl = ""
): Promise<string> {`,
` async askStream(
text: string,
onChunk: (chunk: string) => void,
extraContext = "",
imageDataUrl = "",
flavor = "chemistry"
): Promise<string> {`
],
[
` const sys = systemPrompt(this.getSave(), cfg.personaExtra)`,
` const sys = systemPrompt(this.getSave(), cfg.personaExtra, flavor)`
]
])
console.log('flavor patched')