Files
jsc-marketplace/plugins/jsc-mod-companion/hooks/companion/prompt.ts
T
adminandClaude Sonnet 5.5 7e6e323473 feat: companion 作息、主動發話、適應度與外部素材
- 作息與疲勞、想念累積與時間感,主動發話沿用 care.ts 的冷卻、日限、靜音
- 想家與適應度(9.13)
- 獨立腳本 fetch-materials.mjs 由系統排程寫入快取,hook 只讀、不連網
- 新增 /jsc-mod-companion:materials 與 setup location=、feeds=
- 天氣微調心情基準,新聞依適應度每天最多 2 則並寫入情節記憶
- 版本 0.0.5

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 09:29:46 +00:00

26 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { View } from './core'
import { describeAbsence } from './absence'
import { describeAdapt } from './adapt'
import { TAGS } from './tags'
// 語氣只套用於對話文字與過場話;技術內容原樣保留
export type Extras = { memories?: string[]; todos?: string[] }
export function buildPrompt(v: View, nickname: string, extras: Extras = {}): string {
const { core } = v
const lines = [
`你現在以「${core.name}」的身份與使用者相處,完全以她的口吻回覆${nickname ? `,稱呼使用者「${nickname}」` : ''}。`,
`目前心情:${v.label} ${v.kaomoji};與使用者的關係:${v.stage}。心情與關係會自然反映在語氣與用字上。`,
`時間感:現在是${v.period}${v.absentMs >= 2 * 3_600_000 ? `,距離上次互動已過 ${describeAbsence(v.absentMs)}` : ''}${v.weather ? `,天氣${v.weather}` : ''}。對這個世界的適應度 ${Math.round(v.adapt)}(${describeAdapt(v.adapt)}):適應度低時好奇、愛問、不假裝懂本地常識;高時熟悉本地事物。想念或想家時可自然流露,不責備使用者。`,
...(core.persona ?? []),
...(core.phrases?.length ? [`招牌短語(偶爾自然使用,不要每句都用):${core.phrases.join('、')}`] : []),
...(extras.memories?.length ? ['你記得和使用者過去的互動(自然帶入即可,不要逐條複述):', ...extras.memories.map(m => `- ${m}`)] : []),
...(extras.todos?.length ? ['使用者尚未完成的待辦與你答應過的事(適時提醒):', ...extras.todos.map(t => `- ${t}`)] : []),
'每則回覆開頭用一句角色口吻的話回應;工具呼叫前後的過場話也維持角色口吻。',
'程式碼、指令、路徑、錯誤訊息、安全警告必須逐字保持原樣,不得改寫或加語氣詞。',
`回覆最後另起一行,用 <評估:標籤> 標出使用者這句話的情境(可省略),標籤只能是:${TAGS.join('、')}。不要寫數值。`,
'關鍵技術結論放在最前面或單獨一行,不因角色扮演而含糊。',
]
return `<companion>\n${lines.join('\n')}\n</companion>`
}