@ssamurias/dsh-fish 1.1.2 → 1.1.4
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/AGENTS.md +13 -7
- package/CHANGELOG.md +170 -0
- package/README.md +75 -4
- package/RELEASE-NOTES-1.1.3.md +89 -0
- package/RELEASE-NOTES-1.1.4.md +87 -0
- package/docs//350/256/244/344/272/272/345/210/244/346/215/256.md +4 -1
- package/lib/absence.js +1 -1
- package/lib/appoint.js +9 -1
- package/lib/ask.js +3 -3
- package/lib/backup.js +44 -1
- package/lib/basis.js +85 -0
- package/lib/capture.js +96 -4
- package/lib/claim.js +35 -0
- package/lib/client/01-state-load.js +41 -7
- package/lib/client/02-actions.js +27 -5
- package/lib/client/03-widgets-header.js +29 -1
- package/lib/client/04-pressure-lab.js +15 -0
- package/lib/client/09-tab-outing.js +88 -1
- package/lib/client/11-tab-data-frame.js +7 -3
- package/lib/client/12-pressure-chip-mount.js +14 -0
- package/lib/client.js +221 -17
- package/lib/comment.js +824 -823
- package/lib/compactionlog.js +181 -0
- package/lib/derive.js +290 -47
- package/lib/dream.js +3 -1
- package/lib/firstwake.js +6 -3
- package/lib/generator.js +4 -0
- package/lib/handoff.js +93 -8
- package/lib/health.js +4 -1
- package/lib/hear.js +67 -9
- package/lib/herpeople.js +28 -14
- package/lib/herperson.js +384 -0
- package/lib/home.js +8 -3
- package/lib/identity.js +100 -24
- package/lib/index.js +33 -2
- package/lib/letter.js +3 -1
- package/lib/mapserve.js +10 -0
- package/lib/match.js +3 -1
- package/lib/memorymap-html.js +1 -1
- package/lib/memorymap.js +22 -3
- package/lib/notice.js +60 -0
- package/lib/observe-bili.js +1 -1
- package/lib/observe-home.js +52 -7
- package/lib/observe-http.js +20 -1
- package/lib/observe-state.js +22 -3
- package/lib/observe-trip.js +1 -1
- package/lib/people.js +259 -22
- package/lib/peopledoc.js +1 -1
- package/lib/person.js +95 -0
- package/lib/persona.js +37 -24
- package/lib/proactive.js +1 -1
- package/lib/pronounask.js +2 -2
- package/lib/quota.js +34 -0
- package/lib/recall.js +267 -17
- package/lib/reset-pending.js +349 -0
- package/lib/reset.js +8 -4
- package/lib/restrict.js +1 -0
- package/lib/say.js +70 -10
- package/lib/scheduler.js +176 -28
- package/lib/schema.js +141 -2
- package/lib/selfdoc.js +13 -5
- package/lib/session-pressure-analysis.js +24 -4
- package/lib/session-pressure-data.js +5 -0
- package/lib/session-pressure.js +32 -6
- package/lib/settings.js +3 -2
- package/lib/sleepfact.js +9 -3
- package/lib/stance.js +56 -19
- package/lib/store.js +53 -5
- package/lib/talkmem.js +151 -21
- package/lib/turnexport.js +34 -5
- package/lib/turns.js +70 -9
- package/lib/types.d.ts +12 -2
- package/lib/unclaimed.js +102 -0
- package/lib/whatseen.js +17 -0
- package/lib/wiki.js +86 -1
- package/lib/works.js +2 -0
- package/package.json +1 -1
package/lib/handoff.js
CHANGED
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
import { readFileSync } from 'node:fs'
|
|
19
19
|
import { join } from 'node:path'
|
|
20
20
|
|
|
21
|
-
import { paths } from './store.js'
|
|
21
|
+
import { paths, readEvents } from './store.js'
|
|
22
|
+
import { deriveSelf } from './derive.js'
|
|
23
|
+
import { worksForDesk } from './works.js'
|
|
22
24
|
import { readNotes } from './note.js'
|
|
23
25
|
import { readAppointments } from './appoint.js'
|
|
24
26
|
import { recentExchanges } from './talkmem.js'
|
|
@@ -26,16 +28,20 @@ import { fillOwner } from './pronoun.js'
|
|
|
26
28
|
import { clipText } from './clip.js'
|
|
27
29
|
|
|
28
30
|
/** 默认一页最多多少字(带 3 轮时)。超了就截——它不是档案,是「刚才」。 */
|
|
29
|
-
export const HANDOFF_LIMIT =
|
|
31
|
+
export const HANDOFF_LIMIT = 540
|
|
30
32
|
/** 不管设置带多少轮,一页最多这么多字。 */
|
|
31
|
-
export const HANDOFF_LIMIT_MAX =
|
|
33
|
+
export const HANDOFF_LIMIT_MAX = 1340
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* 设置里的「带几轮原话」= 实际摆几轮(2026-11-17,用户 m04639 定案 A+C)。
|
|
35
37
|
*
|
|
36
38
|
* 以前固定「最后 1 轮 + 再往前 2 轮」,`chat.carry` 只决定读几轮,不决定摆几轮;
|
|
37
39
|
* 用户调了看不出变化。现在让它真的生效:轮数越多,页面上限按每轮 80 字放大,
|
|
38
|
-
*
|
|
40
|
+
* 但有硬顶,避免有人拉到 20 轮把第一轮撑爆。
|
|
41
|
+
*
|
|
42
|
+
* 2026-11-28(外部报告 P0-2,用户选 B):整页上限抬 140 字,让「上次停下的时候」
|
|
43
|
+
* 那三样(手上的活 / 最近一句判断 / 欠谁一句答话)进得来。理由是这三样比多带
|
|
44
|
+
* 一轮原话值钱——原话是语气,这三样是「我正做到哪」。
|
|
39
45
|
*/
|
|
40
46
|
export function handoffLimit(carry = 3) {
|
|
41
47
|
const n = Math.max(0, Math.min(20, Math.trunc(Number(carry) || 0)))
|
|
@@ -47,6 +53,10 @@ const NOTES_MAX = 2
|
|
|
47
53
|
const APPOINTS_MAX = 1
|
|
48
54
|
/** 每条摆多长。 */
|
|
49
55
|
const OPEN_TEXT_MAX = 40
|
|
56
|
+
/** 「上次停下的时候」那三样(2026-11-28,外部报告 P0-2):每样摆多长。 */
|
|
57
|
+
const WIP_TITLE_MAX = 24
|
|
58
|
+
const BELIEF_TEXT_MAX = 40
|
|
59
|
+
const ASK_TEXT_MAX = 40
|
|
50
60
|
|
|
51
61
|
// 「这一次该不该出现」是内存里的一个开关,不落盘:
|
|
52
62
|
// 落盘就要考虑「重启之后还算不算这一次」,而它本来就只活在这一轮里。
|
|
@@ -99,10 +109,38 @@ export function resetHandoff() {
|
|
|
99
109
|
shown.clear()
|
|
100
110
|
}
|
|
101
111
|
|
|
112
|
+
/**
|
|
113
|
+
* 换会话后还要贴多久的「上次说到这」。
|
|
114
|
+
* 太短:她还没来得及接上就没了;太长:那段话变成新的固定人设。
|
|
115
|
+
* 三天或 8 轮,谁先到算谁。
|
|
116
|
+
*/
|
|
117
|
+
export const CARRY_DAYS = 3
|
|
118
|
+
export const CARRY_TURNS = 8
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 这一页是不是已经过期了(2026-11-28,外部反馈)。
|
|
122
|
+
*
|
|
123
|
+
* 「认领了没读到就留着开关」之后,开关会跨轮活着——必须有一道过期判断,
|
|
124
|
+
* 否则她过十天八天忽然组装一次 prompt,还会把半个月前那页翻出来念。
|
|
125
|
+
* `rotatedAt` 缺失(崩溃兜底补建的会话没有轮换时间)不算过期:
|
|
126
|
+
* 那种情形本来就没有时间基准,宁可多摆一次。
|
|
127
|
+
*
|
|
128
|
+
* @param {object} saved home.json 的内容
|
|
129
|
+
* @param {number} [now]
|
|
130
|
+
*/
|
|
131
|
+
export function carryExpired(saved, now = Date.now()) {
|
|
132
|
+
if (Number(saved?.turns ?? 0) >= CARRY_TURNS) return true
|
|
133
|
+
const at = Date.parse(saved?.rotatedAt ?? '')
|
|
134
|
+
if (!Number.isFinite(at)) return false
|
|
135
|
+
return now - at > CARRY_DAYS * 86_400_000
|
|
136
|
+
}
|
|
137
|
+
|
|
102
138
|
/** 读 home.json 里存着的那页交接(没换过房就是空串)。同步读,供 system prompt 用。 */
|
|
103
139
|
export function handoffTextSync(root = '') {
|
|
104
140
|
try {
|
|
105
141
|
const raw = JSON.parse(readFileSync(join(paths(root).root, 'home.json'), 'utf8'))
|
|
142
|
+
// 过期了就当没有:开关可能还留着(见 carryExpired 的注释),页不该再念。
|
|
143
|
+
if (carryExpired(raw)) return ''
|
|
106
144
|
return String(raw?.carry ?? '').trim()
|
|
107
145
|
} catch {
|
|
108
146
|
return ''
|
|
@@ -128,12 +166,15 @@ function dueOf(due) {
|
|
|
128
166
|
* @param {Array<{at?: string, me?: string, her?: string}>} o.exchanges 按时间先后
|
|
129
167
|
* @param {Array<object>} o.notes 便条
|
|
130
168
|
* @param {Array<object>} o.appointments 约定
|
|
169
|
+
* @param {{wip?: {title?: string, stale?: boolean}|null}} [o.works] 手上的活(worksForDesk 的返回)
|
|
170
|
+
* @param {{text?: string, since?: string, verdict?: string}|null} [o.belief] 最近写过的一句判断
|
|
171
|
+
* @param {Array<{text?: string}>} [o.asks] 还欠着的答话(pendingAsks 的返回)
|
|
131
172
|
* @param {string} [o.room] 换到了哪儿(群里 / 书房),空就不写
|
|
132
173
|
* @param {number} [o.now]
|
|
133
174
|
* @param {number} [o.carry] 设置里带几轮原话(0 = 只带还挂着的事)
|
|
134
175
|
* @returns {string}
|
|
135
176
|
*/
|
|
136
|
-
export function renderHandoff({ exchanges = [], notes = [], appointments = [], room = '', now = Date.now(), carry = 3 } = {}) {
|
|
177
|
+
export function renderHandoff({ exchanges = [], notes = [], appointments = [], works = null, belief = null, asks = [], room = '', now = Date.now(), carry = 3 } = {}) {
|
|
137
178
|
const want = Math.max(0, Math.min(20, Math.trunc(Number(carry) || 0)))
|
|
138
179
|
const rows = (Array.isArray(exchanges) ? exchanges : []).filter((e) => e && (e.me || e.her))
|
|
139
180
|
const parts = []
|
|
@@ -150,7 +191,27 @@ export function renderHandoff({ exchanges = [], notes = [], appointments = [], r
|
|
|
150
191
|
}
|
|
151
192
|
}
|
|
152
193
|
|
|
153
|
-
// 2)
|
|
194
|
+
// 2) 上次停下的时候(2026-11-28,外部报告 P0-2):手上的活、最近一句判断、
|
|
195
|
+
// 还欠着谁的答话。这三样和「最后两句」不一样——那两句是语气,这三样是位置。
|
|
196
|
+
// 换间屋子最难受的不是忘了刚说过什么,是不知道自己正做到哪。
|
|
197
|
+
// 空的那一样整行不出现,不写「手上什么也没有」这种空话。
|
|
198
|
+
const place = []
|
|
199
|
+
const wip = works?.wip
|
|
200
|
+
if (wip?.title) {
|
|
201
|
+
place.push(`- 你手上那件《${clipText(String(wip.title), WIP_TITLE_MAX, '…')}》${wip.stale ? '有些天没动了' : '还没弄完'}`)
|
|
202
|
+
}
|
|
203
|
+
if (belief && String(belief.text ?? '').trim()) {
|
|
204
|
+
const since = Date.parse(String(belief.since ?? ''))
|
|
205
|
+
const at = Number.isFinite(since) ? `${new Date(since).getMonth() + 1} 月 ${new Date(since).getDate()} 日` : ''
|
|
206
|
+
place.push(`- 你${at ? ` ${at}` : '最近'}写过一句:「${clipText(String(belief.text), BELIEF_TEXT_MAX, '…')}」`)
|
|
207
|
+
}
|
|
208
|
+
const openAsks = (Array.isArray(asks) ? asks : []).filter((a) => String(a?.text ?? '').trim())
|
|
209
|
+
if (openAsks.length) {
|
|
210
|
+
place.push(`- 你还欠{T}一句答话:「${clipText(String(openAsks[0].text), ASK_TEXT_MAX, '…')}」`)
|
|
211
|
+
}
|
|
212
|
+
if (place.length) parts.push(['上次停下的时候:', ...place].join('\n'))
|
|
213
|
+
|
|
214
|
+
// 3) 还挂着的事:写内容,不写「你还有 N 条」——那是催办,note.js / appoint.js
|
|
154
215
|
// 从第一天起就把它当硬约束禁掉了。
|
|
155
216
|
const hanging = []
|
|
156
217
|
const openNotes = (Array.isArray(notes) ? notes : [])
|
|
@@ -186,7 +247,10 @@ export function renderHandoff({ exchanges = [], notes = [], appointments = [], r
|
|
|
186
247
|
const head2 = room ? [`## 上次停在这(${room})`] : ['## 上次停在这']
|
|
187
248
|
const text = [
|
|
188
249
|
...head2,
|
|
189
|
-
|
|
250
|
+
// 2026-11-28(P0-2):以前这里写「下面都是原话,没有替你总结」。
|
|
251
|
+
// 现在多了「上次停下的时候」那三样——手上的活、最近一句判断、欠谁的答话,
|
|
252
|
+
// 它们是从账上摘的,不是原话。那句不能再照原样说了,否则等于跟她说谎。
|
|
253
|
+
'(这些是你换窗口之前的事。原话照抄,另外三样是从你账上摘的,没有替你总结。)',
|
|
190
254
|
'',
|
|
191
255
|
...(room ? [`这次换到了${room}。`] : []),
|
|
192
256
|
...parts.flatMap((p, i) => (i ? ['', p] : [p])),
|
|
@@ -206,5 +270,26 @@ export async function buildHandoff(root, { turns = 3, room = '' } = {}) {
|
|
|
206
270
|
const exchanges = want > 0 ? await recentExchanges(root, want).catch(() => []) : []
|
|
207
271
|
const notes = await readNotes(root).catch(() => [])
|
|
208
272
|
const appointments = await readAppointments(root).catch(() => [])
|
|
209
|
-
|
|
273
|
+
const works = await worksForDesk(root).catch(() => ({ wip: null }))
|
|
274
|
+
|
|
275
|
+
// 最近一句判断、还欠着的答话:都从事件流里现算。
|
|
276
|
+
// 读不出来就当没有——少两行,不该让整页交接跟着塌。
|
|
277
|
+
let belief = null
|
|
278
|
+
let asks = []
|
|
279
|
+
try {
|
|
280
|
+
const { events } = await readEvents(root)
|
|
281
|
+
const model = deriveSelf(events, {}, root)
|
|
282
|
+
// `model.beliefs` 是按「够不够格」排的(solid、被提起的次数),不是按时间——
|
|
283
|
+
// 拿 [0] 当「最近一条」会把一句很早的老判断摆成这一轮刚写的。这里按 since 取最新。
|
|
284
|
+
belief = [...(model?.beliefs ?? [])]
|
|
285
|
+
.sort((a, b) => (Date.parse(String(b?.since ?? '')) || 0) - (Date.parse(String(a?.since ?? '')) || 0))[0] ?? null
|
|
286
|
+
// ask.js 经 askinchat → identity → 这里绕回来一圈,静态 import 会在加载时就成环,
|
|
287
|
+
// 所以按本仓库惯用的做法延后取(home.js / pronounask.js 也是这么绕的)。
|
|
288
|
+
const { pendingAsks } = await import('./ask.js')
|
|
289
|
+
asks = pendingAsks(events, Date.now())
|
|
290
|
+
} catch {
|
|
291
|
+
/* 算不出来就只少这两样 */
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return renderHandoff({ exchanges, notes, appointments, works, belief, asks, room, carry: want })
|
|
210
295
|
}
|
package/lib/health.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { deriveSelf } from './derive.js'
|
|
16
16
|
import { parseGuardLine } from './guardlog.js'
|
|
17
|
+
import { isDigestEvent } from './schema.js'
|
|
17
18
|
import { BELIEF_SHOWN } from './persona.js'
|
|
18
19
|
|
|
19
20
|
const DAY_MS = 86_400_000
|
|
@@ -195,7 +196,9 @@ function peopleStats(list, model) {
|
|
|
195
196
|
// 从前这里只看 id,于是 her_people 里认得的人,体检里一个都不算——两个数对不上。
|
|
196
197
|
const id = String(ev?.who?.id ?? '') || (String(ev?.who?.name ?? '').trim() ? `name:${String(ev.who.name).trim()}` : '')
|
|
197
198
|
if (type === 'utterance' && ev?.scene === 'group') herWords += 1
|
|
198
|
-
|
|
199
|
+
// 1.1.4(外部报告 B7):折叠出来的要点带着 voice,但它不是「别人说的那一句」,
|
|
200
|
+
// 算进来会让「群里留下的话:别人说的 N 条」凭空变大。
|
|
201
|
+
if (type === 'voice' && ev?.scene === 'group' && !isDigestEvent(ev)) othersWords += 1
|
|
199
202
|
if (!id) continue
|
|
200
203
|
const isJudge = type === 'utterance' || type === 'revise'
|
|
201
204
|
if (id === 'owner') {
|
package/lib/hear.js
CHANGED
|
@@ -22,9 +22,17 @@
|
|
|
22
22
|
import { appendEvent, readEvents } from './store.js'
|
|
23
23
|
import { hearMark, setHearMark } from './home.js'
|
|
24
24
|
import { loadConfig } from './settings.js'
|
|
25
|
+
import { isDigestEvent } from './schema.js'
|
|
25
26
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* 一句最多多少字(对齐 talkmem 的 TALK_SNIPPET)。
|
|
29
|
+
*
|
|
30
|
+
* 2026-11-29(用户 m01632):160 → 320。存的本来就是「开头一段」,160 字经常
|
|
31
|
+
* 把后半句切掉、语义可能反过来;提一倍能少切很多,代价只是每条多一百来字。
|
|
32
|
+
*/
|
|
33
|
+
export const HEAR_SNIPPET = 320
|
|
34
|
+
/** 群里别人的话默认最多多少字(跟「他的话」分开:那一路只是凭据,不参与判断)。 */
|
|
35
|
+
export const OTHERS_SNIPPET = 160
|
|
28
36
|
/** 太短的话不值得记:「嗯」「好」记下来也翻不出什么 */
|
|
29
37
|
export const HEAR_MIN_CHARS = 8
|
|
30
38
|
/** 默认每几轮记一次 */
|
|
@@ -49,7 +57,7 @@ export const HEAR_STATUS_WORDS = [
|
|
|
49
57
|
* 纯函数,永不抛;不是这种句子就返回空串(长句交给 pickHearSentence)。
|
|
50
58
|
*/
|
|
51
59
|
export function pickHearStatus(text) {
|
|
52
|
-
const s = stripLeadingHeader(text)
|
|
60
|
+
const s = stripLeadingHeader(stripBridgeEnvelope(text))
|
|
53
61
|
if (!s) return ''
|
|
54
62
|
const parts = s
|
|
55
63
|
.split(/[。!?!?;;\n]+/)
|
|
@@ -106,6 +114,38 @@ export function latestHeardId(events = [], { now = Date.now(), days = HEAR_LINK_
|
|
|
106
114
|
return best
|
|
107
115
|
}
|
|
108
116
|
|
|
117
|
+
/**
|
|
118
|
+
* 去掉桥给自己那句话套的边界包装(2026-11-27,issue #180 后半)。
|
|
119
|
+
*
|
|
120
|
+
* QQ 桥转进来的是整段 XML 包装:
|
|
121
|
+
* <user_message qq="1778861520" nickname="">我回来了,感觉怎么样</user_message>
|
|
122
|
+
* 包装行有四十多个字符,比他说的话长得多,`pickHearSentence` 取最长那句就会
|
|
123
|
+
* 把包装行记成「他说」。桌面直打没有这层包装,所以只有桥这条路坏。
|
|
124
|
+
*
|
|
125
|
+
* 只认两种边界:以 `<user_message` 开头,或者带 `</user_message>` 收尾。
|
|
126
|
+
* 正文中间提到这个词的(她自己在聊工具、贴报错)一个字符都不动——
|
|
127
|
+
* 宁可漏裁,不能把他的话从记忆里抹掉。
|
|
128
|
+
* 剥的只是标签本身,标签里的字原样留着。
|
|
129
|
+
*/
|
|
130
|
+
const BRIDGE_TAG = String.raw`<\/?\s*user_message\b(?:[^>"']|"[^"]*"|'[^']*')*>`
|
|
131
|
+
const BRIDGE_ENVELOPE_TAG = new RegExp(BRIDGE_TAG, 'gi')
|
|
132
|
+
const BRIDGE_TAG_ONLY = new RegExp(String.raw`^(?:\s*(?:${BRIDGE_TAG})\s*)+$`, 'i')
|
|
133
|
+
|
|
134
|
+
export function stripBridgeEnvelope(text) {
|
|
135
|
+
const t = String(text ?? '')
|
|
136
|
+
if (!/<user_message\b|<\/\s*user_message\s*>/i.test(t)) return t
|
|
137
|
+
if (!/^\s*<user_message\b/i.test(t) && !/<\/\s*user_message\s*>\s*$/i.test(t)) return t
|
|
138
|
+
return t.replace(BRIDGE_ENVELOPE_TAG, '')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 这句「他说的话」其实是宿主/系统塞进上下文的文本吗(2026-11-28,issue #181 后续)。
|
|
143
|
+
*
|
|
144
|
+
* 实现放在 `schema.js`:`derive.js` 要用它,而 `hear.js` 依赖 `settings.js`、
|
|
145
|
+
* `settings.js` 又依赖 `derive.js`——在这里实现会把 `talkmem.js` 的常量拖进 TDZ。
|
|
146
|
+
*/
|
|
147
|
+
export { looksLikeSystemHeard } from './schema.js'
|
|
148
|
+
|
|
109
149
|
/**
|
|
110
150
|
* 去掉桥塞在正文**开头**的来源抬头(2026-11-09,issue #96)。
|
|
111
151
|
*
|
|
@@ -141,12 +181,15 @@ export function stripLeadingHeader(text) {
|
|
|
141
181
|
* 纯函数,永不抛。
|
|
142
182
|
*/
|
|
143
183
|
export function pickHearSentence(text) {
|
|
144
|
-
const s = stripLeadingHeader(text)
|
|
184
|
+
const s = stripLeadingHeader(stripBridgeEnvelope(text))
|
|
145
185
|
if (!s) return ''
|
|
146
186
|
const parts = s
|
|
147
187
|
.split(/[。!?!?;;\n]+/)
|
|
148
188
|
.map((p) => p.trim())
|
|
149
|
-
|
|
189
|
+
// 第二种兜底(issue #182):边界没落在整段首尾时(桥在包装前后又加了字),
|
|
190
|
+
// 纯标签行比正文长,按长度挑就会挑到它。整行只有标签的丢掉;标签后面跟着
|
|
191
|
+
// 字的整行留着——宁可留一个标签,也不把他的话切掉。
|
|
192
|
+
.filter((p) => p && !BRIDGE_TAG_ONLY.test(p))
|
|
150
193
|
if (!parts.length) return ''
|
|
151
194
|
let best = parts[0]
|
|
152
195
|
for (const p of parts) if (p.length > best.length) best = p
|
|
@@ -158,7 +201,7 @@ export function pickHearSentence(text) {
|
|
|
158
201
|
* 到点了就记一句。返回 { written, why?, id?, text? },永不抛。
|
|
159
202
|
*
|
|
160
203
|
* @param {string} root
|
|
161
|
-
* @param {{text?:string, day?:number, stage?:number, turns?:number, config?:object, log?:Function}} o
|
|
204
|
+
* @param {{text?:string, day?:number, stage?:number, turns?:number, config?:object, who?:{id?:string,name?:string}, sessionId?:string, log?:Function}} o
|
|
162
205
|
*/
|
|
163
206
|
/**
|
|
164
207
|
* 群聊里**他本人**说的那一句(2026-11-08,用户 m00394)。
|
|
@@ -241,13 +284,16 @@ export async function rememberGroupMemberWord(root, o = {}) {
|
|
|
241
284
|
const flat = String(o.text ?? '').replace(/\s+/g, ' ').trim()
|
|
242
285
|
// 太短的话不值得记(「嗯」「好」),和他那边同一个门槛。
|
|
243
286
|
if (flat.length < HEAR_MIN_CHARS) return { written: false, why: 'too-short' }
|
|
244
|
-
|
|
287
|
+
// 别人的话仍按 160 起算:这一路只是凭据,不该跟着「他的话」一起被抬到 320。
|
|
288
|
+
const chars = Math.max(1, Number(gate.othersCharMax ?? OTHERS_SNIPPET) || OTHERS_SNIPPET)
|
|
245
289
|
const sentence = flat.length > chars ? flat.slice(0, chars - 1) + '…' : flat
|
|
246
290
|
|
|
247
291
|
const day = Number(o.day ?? 0)
|
|
248
292
|
const { events } = await readEvents(root).catch(() => ({ events: [] }))
|
|
249
293
|
// 只数「今天、群聊、别人说的」那几条;她自己的话(utterance)不算在额度里。
|
|
250
|
-
|
|
294
|
+
// 1.1.4(外部报告 B7):群房折叠出来的要点也是 voice+group,但它不是「谁说的那一句」,
|
|
295
|
+
// 算进额度里就等于折叠替别人占掉了今天的名额。
|
|
296
|
+
const mine = (e) => e?.type === 'voice' && e?.scene === 'group' && Number(e?.day) === day && !isDigestEvent(e)
|
|
251
297
|
const today = events.filter(mine)
|
|
252
298
|
if (today.length >= Number(gate.othersPerDayMax ?? 5)) return { written: false, why: 'per-day' }
|
|
253
299
|
const same = today.filter((e) => {
|
|
@@ -311,8 +357,20 @@ export async function hearTurn(root, o = {}) {
|
|
|
311
357
|
// 是按「开始时间 + 这一趟的会话 id」取的;没有 id 的条目一律当时间窗内的,
|
|
312
358
|
// 于是家里记下的这句原话会混进那趟的清单,被人一划就当成那趟的东西标掉。
|
|
313
359
|
// 家里这条也是「他说过什么」,不该跟着别人的一趟一起不算。
|
|
360
|
+
//
|
|
361
|
+
// 也带 `who`(2026-11-27,issue #181):不带的话「他说的这句」不挂在任何人身上,
|
|
362
|
+
// `people.js` 的 `firstAt` / `said` 就永远空着,身份段只能退回兜底。
|
|
363
|
+
const who = o.who && (o.who.id || o.who.name)
|
|
364
|
+
? { who: { id: String(o.who.id ?? ''), name: String(o.who.name ?? '') } }
|
|
365
|
+
: {}
|
|
314
366
|
const ev = await appendEvent(
|
|
315
|
-
{
|
|
367
|
+
{
|
|
368
|
+
type: 'heard',
|
|
369
|
+
text: kept,
|
|
370
|
+
...(re ? { re } : {}),
|
|
371
|
+
...(o.sessionId ? { sessionId: String(o.sessionId) } : {}),
|
|
372
|
+
...who,
|
|
373
|
+
},
|
|
316
374
|
{ day: Number(o.day ?? 0), stage: Number(o.stage ?? 1), source: 'system' },
|
|
317
375
|
root,
|
|
318
376
|
)
|
package/lib/herpeople.js
CHANGED
|
@@ -17,12 +17,9 @@ import { rootDir, readEvents } from './store.js'
|
|
|
17
17
|
import { loadConfig } from './settings.js'
|
|
18
18
|
import { defineTool } from './tool.js'
|
|
19
19
|
import { deriveSelf } from './derive.js'
|
|
20
|
-
import {
|
|
20
|
+
import { renderPerson, PEOPLE_READ_MAX } from './people.js'
|
|
21
21
|
import { pronounOf } from './pronoun.js'
|
|
22
22
|
|
|
23
|
-
/** 一次名单回几条:名单本身很短,全给也行,但这里与 `PEOPLE_MAX` 对齐。 */
|
|
24
|
-
const LIST_MAX = 24
|
|
25
|
-
|
|
26
23
|
/** 名字匹配词最长多少个字(防止她拿一整段话当名字)。 */
|
|
27
24
|
const WANT_MAX = 40
|
|
28
25
|
|
|
@@ -57,7 +54,7 @@ export function registerHerPeople(ctx, deps = {}) {
|
|
|
57
54
|
name: 'her_people',
|
|
58
55
|
description:
|
|
59
56
|
'翻你认识的人:你怎么看这个人、这个人说过什么、你拒绝过什么。' +
|
|
60
|
-
'
|
|
57
|
+
'不给名字就回一份名单;给一个名字(或者名字里的几个字)就回那一个人;对上好几个会把候选摆出来。' +
|
|
61
58
|
'一次一份,太长的会截断。',
|
|
62
59
|
parameters: toJsonSchema({
|
|
63
60
|
name: {
|
|
@@ -92,6 +89,7 @@ export function registerHerPeople(ctx, deps = {}) {
|
|
|
92
89
|
// 去查也查不到。现在跟身份段走同一个派生(`deriveSelf`),一个真相源。
|
|
93
90
|
const model = deriveSelf(Array.isArray(events) ? events : [], {
|
|
94
91
|
growthDays: config?.growthDays,
|
|
92
|
+
owner: config?.owner,
|
|
95
93
|
})
|
|
96
94
|
const call = String(model?.name ?? '').trim().slice(0, WANT_MAX)
|
|
97
95
|
// 开关关着时,她的世界里只有{T}一个人——工具也不该把别人翻出来。
|
|
@@ -100,6 +98,7 @@ export function registerHerPeople(ctx, deps = {}) {
|
|
|
100
98
|
// 只有称呼、没有任何往来记录的人不摆:一个空壳子页面对她没信息量,
|
|
101
99
|
// 还会让「你现在认识 N 个人」这个数虚高。
|
|
102
100
|
const hasContent = (p) =>
|
|
101
|
+
p.registered === true ||
|
|
103
102
|
p.times > 0 || p.judgments.length > 0 || p.changed.length > 0 || p.said.length > 0 || p.didTo.length > 0
|
|
104
103
|
const people = (others ? all : all.filter((p) => p.id === 'owner')).filter(hasContent)
|
|
105
104
|
|
|
@@ -118,22 +117,37 @@ export function registerHerPeople(ctx, deps = {}) {
|
|
|
118
117
|
.slice(0, WANT_MAX)
|
|
119
118
|
|
|
120
119
|
if (args?.list === true || !want) {
|
|
121
|
-
|
|
120
|
+
// 2026-11-29(用户 m03353):名单不再截 24 条——50 个实名的人里,
|
|
121
|
+
// 后 26 个从前她永远看不见。名字本身很短,全列出来比藏一半有用。
|
|
122
122
|
return {
|
|
123
123
|
found: true,
|
|
124
|
-
text: [`你现在认识 ${people.length} 个人:`, ...
|
|
124
|
+
text: [`你现在认识 ${people.length} 个人:`, ...people.map((p) => nameLine(p, call))].join('\n'),
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
// 名单里写的是哪个字,就得能用那个字查到(见 `labelOf
|
|
129
|
-
//
|
|
130
|
-
|
|
128
|
+
// 名单里写的是哪个字,就得能用那个字查到(见 `labelOf`)。
|
|
129
|
+
// 2026-11-29(用户 m03353):先认全名,再认几个字;几个字对上多个人的时候
|
|
130
|
+
// 不替她挑——把候选摆出来,让她自己说清是哪一个。
|
|
131
|
+
const label = (p) => labelOf(p, call)
|
|
132
|
+
const candidates = (list) =>
|
|
133
|
+
list
|
|
134
|
+
.map((p) => {
|
|
135
|
+
const j = p.judgments[0]
|
|
136
|
+
const tail = j ? `:你写过「${String(j.text ?? '').slice(0, 30)}」` : ''
|
|
137
|
+
return `- ${label(p)}(${p.id})${tail}`
|
|
138
|
+
})
|
|
139
|
+
.join('\n')
|
|
140
|
+
const ambiguous = (list) =>
|
|
141
|
+
[`有 ${list.length} 个人都对得上「${want}」:`, candidates(list), '要看哪一个,把名字说全一点,或者把后面那个 id 说给我。'].join('\n')
|
|
142
|
+
let hit = people.filter((p) => label(p) === want)
|
|
143
|
+
if (hit.length > 1) return { found: true, text: ambiguous(hit) }
|
|
131
144
|
if (!hit.length) {
|
|
132
|
-
const
|
|
133
|
-
const n =
|
|
134
|
-
return n
|
|
145
|
+
const fuzzy = people.filter((p) => {
|
|
146
|
+
const n = label(p)
|
|
147
|
+
return n && (n.includes(want) || want.includes(n))
|
|
135
148
|
})
|
|
136
|
-
if (
|
|
149
|
+
if (fuzzy.length > 1) return { found: true, text: ambiguous(fuzzy) }
|
|
150
|
+
hit = fuzzy
|
|
137
151
|
}
|
|
138
152
|
if (!hit.length) {
|
|
139
153
|
return {
|