@istarry/spoon-companion 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/prompt.js +8 -2
- package/lib/state.js +27 -1
- package/package.json +1 -1
- package/plugin.js +23 -1
package/lib/prompt.js
CHANGED
|
@@ -168,7 +168,10 @@ export function renderStateBlock(view) {
|
|
|
168
168
|
}
|
|
169
169
|
const look = lookLine(view, view.now)
|
|
170
170
|
if (look) lines.push(look)
|
|
171
|
-
if (view.urge)
|
|
171
|
+
if (view.urge) {
|
|
172
|
+
const note = view.urge.note ? `(${view.urge.note})` : ''
|
|
173
|
+
lines.push(`想做的事:${view.urge.kind === 'share' ? `想把刚才看到的那个说出去${note}` : '想被安慰两句'}`)
|
|
174
|
+
}
|
|
172
175
|
// 感受和表现是两回事:她可以心里翻江倒海,表面照旧嘴硬
|
|
173
176
|
if (emo.hidden) {
|
|
174
177
|
const how = emo.def.mask && emo.def.mask !== '—' ? emo.def.mask : '照常说话,不主动提;问到了就轻描淡写'
|
|
@@ -222,7 +225,10 @@ export function renderMoodReport(view) {
|
|
|
222
225
|
const times = view.scene.events > 1 ? ` · 第 ${view.scene.events} 次` : ''
|
|
223
226
|
lines.push(`场景:${view.scene.word}${times} · 尺度 ${view.intimacyLevel ?? 1}(0 日常 / 1 暧昧 / 2 露骨)`)
|
|
224
227
|
}
|
|
225
|
-
if (view.urge)
|
|
228
|
+
if (view.urge) {
|
|
229
|
+
const note = view.urge.note ? `(${view.urge.note})` : ''
|
|
230
|
+
lines.push(`想做的事:${view.urge.kind === 'share' ? `想把刚才看到的那个说出去${note}` : '想被安慰两句'}`)
|
|
231
|
+
}
|
|
226
232
|
const relation = relationLine(view)
|
|
227
233
|
if (relation) lines.push(`关系:${relation}`)
|
|
228
234
|
if (view.today.length) lines.push(`今天:${view.today.join(';')}`)
|
package/lib/state.js
CHANGED
|
@@ -92,7 +92,11 @@ export function emptyState() {
|
|
|
92
92
|
// 尺度:0 日常 / 1 暧昧 / 2 露骨
|
|
93
93
|
intimacy: { level: 1 },
|
|
94
94
|
// 看屏幕:记「刚才瞧见了什么」,不记图。lastAt 超过 30 分钟就不往提示词里写。
|
|
95
|
-
screen: {
|
|
95
|
+
screen: {
|
|
96
|
+
lastAt: 0, saw: '', scene: '', changed: false, worth: 0, nextAt: 0, today: 0, day: '', path: '', title: '',
|
|
97
|
+
// 「值得说一句」的记账:看过多少、说过几次、上次是什么时候
|
|
98
|
+
talkAt: 0, talkToday: 0, talkDay: '', hook: '',
|
|
99
|
+
},
|
|
96
100
|
affect: [],
|
|
97
101
|
habits: {},
|
|
98
102
|
memories: [],
|
|
@@ -974,6 +978,28 @@ export function lookInterval(state, cfg = {}, now = Date.now()) {
|
|
|
974
978
|
return { minutes: Math.round(minutes * 10) / 10, factor: Math.round(factor * 100) / 100, night }
|
|
975
979
|
}
|
|
976
980
|
|
|
981
|
+
/** 窗口标题里有没有「值得说一句」的钩子。没有就返回空串。 */
|
|
982
|
+
const SCREEN_HOOKS = [
|
|
983
|
+
[/报错|错误|异常|Error|Failed|failed|Exception|Traceback|崩溃/, '屏幕上红了一片'],
|
|
984
|
+
[/直播|Bilibili|哔哩哔哩|YouTube|虎牙|斗鱼/, '在看直播'],
|
|
985
|
+
[/Steam|游戏|原神|Minecraft|WeGame|Switch/, '在打游戏'],
|
|
986
|
+
[/微信|QQ|Telegram|Discord|Slack|飞书|钉钉/, '在跟人说话'],
|
|
987
|
+
[/照片|相册|截图|Photos/, '在看照片'],
|
|
988
|
+
]
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* 一眼看过去,这屏值不值得说一句。
|
|
992
|
+
* 只看窗口标题,不额外调模型 —— 宁可漏,不乱说。
|
|
993
|
+
*/
|
|
994
|
+
export function screenHook(title) {
|
|
995
|
+
const text = String(title ?? '')
|
|
996
|
+
if (!text) return ''
|
|
997
|
+
for (const [pattern, tag] of SCREEN_HOOKS) {
|
|
998
|
+
if (pattern.test(text)) return tag
|
|
999
|
+
}
|
|
1000
|
+
return ''
|
|
1001
|
+
}
|
|
1002
|
+
|
|
977
1003
|
/** 性格用几个词说出来(不是把分数报出来) */
|
|
978
1004
|
export function traitWords(traits = {}) {
|
|
979
1005
|
const words = []
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -30,7 +30,7 @@ import { EMOTION_KEYS, EMOTION_MENU, TRAITS, resolveEmotion, tierOf } from './li
|
|
|
30
30
|
import { appraise } from './lib/appraise.js'
|
|
31
31
|
import {
|
|
32
32
|
applyImpulse, catharsis, circadian, decay, dueRumination, loadState, lookInterval, maybeLifeEvent, maybeMoodRepair,
|
|
33
|
-
nightlyReview, pruneState, remember, saveState, snapshot,
|
|
33
|
+
nightlyReview, pruneState, remember, saveState, screenHook, snapshot,
|
|
34
34
|
} from './lib/state.js'
|
|
35
35
|
import { channelOfSession, lastSpeaker, readUserMessages, reactToMessages, sessionEventsOf } from './lib/react.js'
|
|
36
36
|
import { RULES_TEXT, renderDiary, renderMoodReport, renderMoodSection } from './lib/prompt.js'
|
|
@@ -104,6 +104,10 @@ const DEFAULTS = {
|
|
|
104
104
|
dailyLimit: 120,
|
|
105
105
|
maxEdge: 1280,
|
|
106
106
|
exclude: [],
|
|
107
|
+
// 「值得说一句」的闸门:宁可一天不说,也不说废话
|
|
108
|
+
speak: 'never',
|
|
109
|
+
speakPerDay: 2,
|
|
110
|
+
speakCooldownMin: 120,
|
|
107
111
|
},
|
|
108
112
|
}
|
|
109
113
|
|
|
@@ -1223,6 +1227,24 @@ export function apply(ctx, config = {}) {
|
|
|
1223
1227
|
sc.today = (Number(sc.today) || 0) + 1
|
|
1224
1228
|
sc.fails = 0
|
|
1225
1229
|
sc.nextAt = shot.at + lookInterval(state, settings.screen, shot.at).minutes * 60_000
|
|
1230
|
+
// 值不值得说一句:只看标题,不额外调模型。宁可漏,不乱说。
|
|
1231
|
+
const hook = screenHook(shot.title)
|
|
1232
|
+
if (hook && sc.changed && settings.screen.speak !== 'never') {
|
|
1233
|
+
const today = new Date(now).toDateString()
|
|
1234
|
+
if (sc.talkDay !== today) {
|
|
1235
|
+
sc.talkDay = today
|
|
1236
|
+
sc.talkToday = 0
|
|
1237
|
+
}
|
|
1238
|
+
const cooldownMs = Math.max(10, Number(settings.screen.speakCooldownMin) || 120) * 60_000
|
|
1239
|
+
const perDay = Math.max(1, Number(settings.screen.speakPerDay) || 2)
|
|
1240
|
+
if (now - (Number(sc.talkAt) || 0) > cooldownMs && (Number(sc.talkToday) || 0) < perDay) {
|
|
1241
|
+
sc.talkAt = now
|
|
1242
|
+
sc.talkToday = (Number(sc.talkToday) || 0) + 1
|
|
1243
|
+
sc.hook = hook
|
|
1244
|
+
state.urges = { kind: 'share', until: now + 15 * 60_000, note: hook }
|
|
1245
|
+
audit({ kind: 'screen-worthy', hook, title: String(shot.title ?? '').slice(0, 60) })
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1226
1248
|
audit({ kind: 'screen-look', auto: true, title: String(shot.title ?? '').slice(0, 60) })
|
|
1227
1249
|
commit()
|
|
1228
1250
|
} catch (error) {
|