@ssamurias/dsh-fish 1.1.3 → 1.1.5
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 -6
- package/CHANGELOG.md +137 -0
- package/README.md +32 -101
- package/RELEASE-NOTES-1.1.4.md +87 -0
- package/RELEASE-NOTES-1.1.5.md +49 -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/ask.js +3 -3
- package/lib/backup.js +44 -1
- package/lib/basis.js +85 -0
- package/lib/becoming.js +70 -0
- package/lib/capture.js +16 -2
- package/lib/claim.js +35 -0
- package/lib/client/01-state-load.js +21 -0
- 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 +59 -0
- package/lib/client/12-pressure-chip-mount.js +14 -0
- package/lib/client.js +197 -1
- package/lib/comment.js +824 -823
- package/lib/compactionlog.js +181 -0
- package/lib/decisions.js +207 -0
- package/lib/derive.js +384 -53
- package/lib/dream.js +1 -1
- package/lib/firstwake.js +6 -3
- package/lib/generator.js +4 -0
- package/lib/guard.js +75 -9
- package/lib/handoff.js +65 -8
- package/lib/health.js +4 -1
- package/lib/hear.js +15 -4
- package/lib/herpeople.js +29 -15
- package/lib/herperson.js +126 -31
- package/lib/identity.js +11 -3
- package/lib/index.js +17 -2
- package/lib/letter.js +1 -1
- package/lib/match.js +3 -1
- package/lib/memorymap.js +3 -1
- package/lib/notice.js +60 -0
- package/lib/observe-bili.js +1 -1
- package/lib/observe-data.js +16 -0
- package/lib/observe-home.js +1 -1
- 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 +76 -20
- package/lib/peopledoc.js +2 -2
- package/lib/person.js +13 -1
- package/lib/persona.js +49 -24
- package/lib/proactive.js +1 -1
- package/lib/pronounask.js +2 -2
- package/lib/recall.js +301 -18
- package/lib/say.js +76 -6
- package/lib/scheduler.js +144 -25
- package/lib/schema.js +54 -5
- package/lib/selfdoc.js +10 -3
- 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/speak.js +10 -5
- 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 +86 -7
- package/lib/types.d.ts +2 -1
- package/lib/unclaimed.js +102 -0
- package/lib/whatseen.js +17 -0
- package/lib/wiki.js +89 -1
- package/package.json +1 -1
package/lib/dream.js
CHANGED
|
@@ -103,7 +103,7 @@ export async function writeDream(root, { text = '', refs = [], sessionId = '', l
|
|
|
103
103
|
if (config?.dream?.enabled === false) {
|
|
104
104
|
return { ok: false, id: '', note: '梦这一项关着。想记的话先说一声。' }
|
|
105
105
|
}
|
|
106
|
-
const model = deriveSelf(events, { growthDays: config.growthDays })
|
|
106
|
+
const model = deriveSelf(events, { growthDays: config.growthDays, owner: config.owner })
|
|
107
107
|
|
|
108
108
|
// 一天一条按成长日算(从 seed 的钟点起每 24 小时一格),和本地日期对不齐:
|
|
109
109
|
// 本地已经换了日期、成长日还没翻时也会走到这里,所以这句不说「今天」,说是第几天。
|
package/lib/firstwake.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* 没有基线(事件流里一条活动都没有)时不猜,返回 false。
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { tsMs } from './schema.js'
|
|
20
|
+
import { tsMs, isContactEvent } from './schema.js'
|
|
21
21
|
|
|
22
22
|
/** 早于这个整点醒来,不算「早上那一次」。 */
|
|
23
23
|
export const FIRST_WAKE_HOUR = 4
|
|
@@ -62,8 +62,11 @@ export function firstWakeOfDay(events = [], now = Date.now()) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// 活动 = 醒来,或任何不是 meta 的事件(她写下的话、他说的、听到的)。
|
|
65
|
-
// meta 里的
|
|
66
|
-
|
|
65
|
+
// meta 里的 quiet:/sleep: 都是记账,不代表她那时醒着。
|
|
66
|
+
// `seen:` 例外(2026-11-23):它是他开口那一刻(isContactEvent,和 sleepfact.js 同一份判定),
|
|
67
|
+
// 正是上面第 3 条要挡的「他刚说完话」。走 /say 的桥、桥房里,他来过之后事件流常常只有这一行;
|
|
68
|
+
// 不认它,他七点半刚聊完、九点照样说「你刚醒」。
|
|
69
|
+
if (isWake || e?.type !== 'meta' || isContactEvent(e)) {
|
|
67
70
|
if (t > lastAt) lastAt = t
|
|
68
71
|
}
|
|
69
72
|
}
|
package/lib/generator.js
CHANGED
|
@@ -128,6 +128,10 @@ export function cardContext(model, events = [], now = Date.now(), notes = []) {
|
|
|
128
128
|
for (let i = all.length - 1; i >= 0; i--) {
|
|
129
129
|
const e = all[i]
|
|
130
130
|
if (e?.type !== 'heard' || !e?.text || e?.scene === 'group') continue
|
|
131
|
+
// 1.1.4(用户 m02973):别人的话不进「他最近对我说」。
|
|
132
|
+
// 老账本没有 who 的仍按主人算——那时候只有他这一条来源。
|
|
133
|
+
const wid = String(e?.who?.id ?? '').trim()
|
|
134
|
+
if (wid && wid !== 'owner') continue
|
|
131
135
|
out.hisLine = { text: String(e.text).slice(0, 120), at: Date.parse(e.ts || '') || 0 }
|
|
132
136
|
break
|
|
133
137
|
}
|
package/lib/guard.js
CHANGED
|
@@ -140,8 +140,9 @@ export function looksMojibake(text) {
|
|
|
140
140
|
* @returns {{hit:boolean, why:string}}
|
|
141
141
|
*/
|
|
142
142
|
const LEAK_PATTERNS = [
|
|
143
|
-
// Windows 盘符路径 / UNC /
|
|
144
|
-
|
|
143
|
+
// Windows 盘符路径 / UNC / 用户目录。
|
|
144
|
+
// 前面不能是字母:`https://` 里的 `s:/` 也长成盘符,但它是网址,不是门牌。
|
|
145
|
+
/(?<![A-Za-z])[A-Za-z]:[\\/][^\s]*/,
|
|
145
146
|
/\\\\[^\s]+\\[^\s]*/,
|
|
146
147
|
/(?:^|[\s((])\/(?:Users|home|root|tmp|var)\/[^\s]*/,
|
|
147
148
|
// 状态库与家用目录名:命中即说明她在念家里的东西
|
|
@@ -168,17 +169,82 @@ export function looksLikeLeak(text) {
|
|
|
168
169
|
return { hit: false, why: '' }
|
|
169
170
|
}
|
|
170
171
|
|
|
172
|
+
/**
|
|
173
|
+
* 只抹掉那一段,不动整句。
|
|
174
|
+
*
|
|
175
|
+
* 为什么不是整条丢(2026-11-29,用户 m00311):一句「这个我回头问一下,
|
|
176
|
+
* Cookie 是 SESSDATA=abc」里真正不能出门的只有后半段。整条丢掉,她明明
|
|
177
|
+
* 说了一句正常的话,却只收到「这句先不说了」——她不知道哪一段出了问题,
|
|
178
|
+
* 下一次还会照原样说。所以先按片段换掉,换完再复查。
|
|
179
|
+
*
|
|
180
|
+
* 占位词用〔凭据〕/〔地址〕/〔本机〕这类**事实**,不用「敏感信息」——
|
|
181
|
+
* 后者等于告诉她「这里有审查」,而且会教她下次换个写法绕。
|
|
182
|
+
*/
|
|
183
|
+
const REDACTIONS = [
|
|
184
|
+
// 登录凭据:连键带值一起换,避免留下 `SESSDATA=` 又命中一次。
|
|
185
|
+
[/\b(?:SESSDATA|bili_jct|DedeUserID(?:__ckMd5)?|buvid3)\s*=\s*[^\s;,。;、))]*/gi, '〔凭据〕'],
|
|
186
|
+
[/\bsk-[A-Za-z0-9_-]{16,}\b/g, '〔凭据〕'],
|
|
187
|
+
[/\bBearer\s+[A-Za-z0-9._-]{20,}/gi, '〔凭据〕'],
|
|
188
|
+
[/\b(?:api[_-]?key|access[_-]?token|secret[_-]?key|password|passwd|cookie)\b\s*[:=]\s*[^\s;,。;、))]*/gi, '〔凭据〕'],
|
|
189
|
+
[/\b[A-Za-z0-9_-]{32,}\b/g, '〔凭据〕'],
|
|
190
|
+
// 门牌:盘符 / UNC / Unix 家目录。和 LEAK_PATTERNS 的判据保持同一条边界。
|
|
191
|
+
[/(?<![A-Za-z])[A-Za-z]:[\\/][^\s,。;、))]*/g, '〔地址〕'],
|
|
192
|
+
[/\\\\[^\s]+\\[^\s,。;、))]*/g, '〔地址〕'],
|
|
193
|
+
[/(?<![\w])\/(?:Users|home|root|tmp|var)\/[^\s,。;、))]*/g, '〔地址〕'],
|
|
194
|
+
// 家里的文件名与目录名。
|
|
195
|
+
[/(?:AGENTS|IDENTITY)\.md/gi, '〔本机〕'],
|
|
196
|
+
[/(?:events\.jsonl|config\.json|owner\.json|state\.json|inbox\.md)/gi, '〔本机〕'],
|
|
197
|
+
[/\.dsh-fish/gi, '〔本机〕'],
|
|
198
|
+
[/\.dsh(?![a-z-])/gi, '〔本机〕'],
|
|
199
|
+
// 账号数字 / 私聊字样 / 邮箱 / 手机号。
|
|
200
|
+
[/\b(?:uid|mid)\s*[::=]?\s*\d{3,}/gi, '〔账号〕'],
|
|
201
|
+
[/(?:私聊|聊天记录|我们(?:的)?对话|我跟(?:你|他)说)/g, '〔私事〕'],
|
|
202
|
+
[/[\w.+-]+@[\w-]+\.[\w.]+/g, '〔邮箱〕'],
|
|
203
|
+
[/(?<!\d)1[3-9]\d{9}(?!\d)/g, '〔电话〕'],
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
/** 把一句话里像凭据/门牌的片段换成占位词,其余原样。 */
|
|
207
|
+
function redactSensitive(text) {
|
|
208
|
+
let out = String(text ?? '')
|
|
209
|
+
for (const [re, to] of REDACTIONS) out = out.replace(re, to)
|
|
210
|
+
return out
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 抹完之后还剩不剩一句真话。
|
|
215
|
+
*
|
|
216
|
+
* 只有占位词和标点(`SESSDATA=abc` 这种整句就是凭据的),不该把
|
|
217
|
+
* 「〔凭据〕」当评论发出去——那不是改写,是发了一句谁也看不懂的空话。
|
|
218
|
+
*/
|
|
219
|
+
function hasContentAfterRedaction(text) {
|
|
220
|
+
const rest = String(text ?? '')
|
|
221
|
+
.replace(/〔(?:凭据|地址|本机|账号|私事|邮箱|电话)〕/g, '')
|
|
222
|
+
.replace(/[\s,。;、!?…—,.!?;:()()"'“”‘’\-]/g, '')
|
|
223
|
+
return rest.length > 0
|
|
224
|
+
}
|
|
225
|
+
|
|
171
226
|
/**
|
|
172
227
|
* 她要说出去的话,出门前过一遍。
|
|
173
|
-
*
|
|
228
|
+
*
|
|
229
|
+
* 两段式(2026-11-29,用户 m00311):
|
|
230
|
+
* 1. 先按片段抹掉凭据/门牌,整句保留;
|
|
231
|
+
* 2. 抹完再复查一遍,仍命中才整条拦下。
|
|
232
|
+
* 拦下时 why 仍是 'secret' / 'leak',调用方据此决定怎么跟她说。
|
|
233
|
+
*
|
|
234
|
+
* @returns {{ok:boolean, text:string, why:string, redacted?:boolean}}
|
|
174
235
|
*/
|
|
175
236
|
export function screenOutgoing(text) {
|
|
176
237
|
const s = String(text ?? '')
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
if (
|
|
181
|
-
|
|
238
|
+
if (!s) return { ok: true, text: s, why: '' }
|
|
239
|
+
const secret = looksLikeSecret(s)
|
|
240
|
+
const leak = secret.hit ? { hit: false, why: '' } : looksLikeLeak(s)
|
|
241
|
+
if (!secret.hit && !leak.hit) return { ok: true, text: s, why: '' }
|
|
242
|
+
|
|
243
|
+
const clean = redactSensitive(s).trim()
|
|
244
|
+
// 抹完复查:占位词自己不能触发规则;仍命中说明有规则没覆盖到的写法,
|
|
245
|
+
// 这时宁可整条不发,也不把半截凭据送出去。
|
|
246
|
+
if (!clean || !hasContentAfterRedaction(clean) || looksLikeSecret(clean).hit || looksLikeLeak(clean).hit) {
|
|
247
|
+
return { ok: false, text: '', why: secret.hit ? 'secret' : 'leak' }
|
|
182
248
|
}
|
|
183
|
-
return { ok: true, text:
|
|
249
|
+
return { ok: true, text: clean, why: '', redacted: true }
|
|
184
250
|
}
|
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
|
// 落盘就要考虑「重启之后还算不算这一次」,而它本来就只活在这一轮里。
|
|
@@ -156,12 +166,15 @@ function dueOf(due) {
|
|
|
156
166
|
* @param {Array<{at?: string, me?: string, her?: string}>} o.exchanges 按时间先后
|
|
157
167
|
* @param {Array<object>} o.notes 便条
|
|
158
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 的返回)
|
|
159
172
|
* @param {string} [o.room] 换到了哪儿(群里 / 书房),空就不写
|
|
160
173
|
* @param {number} [o.now]
|
|
161
174
|
* @param {number} [o.carry] 设置里带几轮原话(0 = 只带还挂着的事)
|
|
162
175
|
* @returns {string}
|
|
163
176
|
*/
|
|
164
|
-
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 } = {}) {
|
|
165
178
|
const want = Math.max(0, Math.min(20, Math.trunc(Number(carry) || 0)))
|
|
166
179
|
const rows = (Array.isArray(exchanges) ? exchanges : []).filter((e) => e && (e.me || e.her))
|
|
167
180
|
const parts = []
|
|
@@ -178,7 +191,27 @@ export function renderHandoff({ exchanges = [], notes = [], appointments = [], r
|
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
193
|
|
|
181
|
-
// 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
|
|
182
215
|
// 从第一天起就把它当硬约束禁掉了。
|
|
183
216
|
const hanging = []
|
|
184
217
|
const openNotes = (Array.isArray(notes) ? notes : [])
|
|
@@ -214,7 +247,10 @@ export function renderHandoff({ exchanges = [], notes = [], appointments = [], r
|
|
|
214
247
|
const head2 = room ? [`## 上次停在这(${room})`] : ['## 上次停在这']
|
|
215
248
|
const text = [
|
|
216
249
|
...head2,
|
|
217
|
-
|
|
250
|
+
// 2026-11-28(P0-2):以前这里写「下面都是原话,没有替你总结」。
|
|
251
|
+
// 现在多了「上次停下的时候」那三样——手上的活、最近一句判断、欠谁的答话,
|
|
252
|
+
// 它们是从账上摘的,不是原话。那句不能再照原样说了,否则等于跟她说谎。
|
|
253
|
+
'(这些是你换窗口之前的事。原话照抄,另外三样是从你账上摘的,没有替你总结。)',
|
|
218
254
|
'',
|
|
219
255
|
...(room ? [`这次换到了${room}。`] : []),
|
|
220
256
|
...parts.flatMap((p, i) => (i ? ['', p] : [p])),
|
|
@@ -234,5 +270,26 @@ export async function buildHandoff(root, { turns = 3, room = '' } = {}) {
|
|
|
234
270
|
const exchanges = want > 0 ? await recentExchanges(root, want).catch(() => []) : []
|
|
235
271
|
const notes = await readNotes(root).catch(() => [])
|
|
236
272
|
const appointments = await readAppointments(root).catch(() => [])
|
|
237
|
-
|
|
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 })
|
|
238
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
|
/** 默认每几轮记一次 */
|
|
@@ -276,13 +284,16 @@ export async function rememberGroupMemberWord(root, o = {}) {
|
|
|
276
284
|
const flat = String(o.text ?? '').replace(/\s+/g, ' ').trim()
|
|
277
285
|
// 太短的话不值得记(「嗯」「好」),和他那边同一个门槛。
|
|
278
286
|
if (flat.length < HEAR_MIN_CHARS) return { written: false, why: 'too-short' }
|
|
279
|
-
|
|
287
|
+
// 别人的话仍按 160 起算:这一路只是凭据,不该跟着「他的话」一起被抬到 320。
|
|
288
|
+
const chars = Math.max(1, Number(gate.othersCharMax ?? OTHERS_SNIPPET) || OTHERS_SNIPPET)
|
|
280
289
|
const sentence = flat.length > chars ? flat.slice(0, chars - 1) + '…' : flat
|
|
281
290
|
|
|
282
291
|
const day = Number(o.day ?? 0)
|
|
283
292
|
const { events } = await readEvents(root).catch(() => ({ events: [] }))
|
|
284
293
|
// 只数「今天、群聊、别人说的」那几条;她自己的话(utterance)不算在额度里。
|
|
285
|
-
|
|
294
|
+
// 1.1.4(外部报告 B7):群房折叠出来的要点也是 voice+group,但它不是「谁说的那一句」,
|
|
295
|
+
// 算进额度里就等于折叠替别人占掉了今天的名额。
|
|
296
|
+
const mine = (e) => e?.type === 'voice' && e?.scene === 'group' && Number(e?.day) === day && !isDigestEvent(e)
|
|
286
297
|
const today = events.filter(mine)
|
|
287
298
|
if (today.length >= Number(gate.othersPerDayMax ?? 5)) return { written: false, why: 'per-day' }
|
|
288
299
|
const same = today.filter((e) => {
|
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 {
|
|
@@ -144,7 +158,7 @@ export function registerHerPeople(ctx, deps = {}) {
|
|
|
144
158
|
'。',
|
|
145
159
|
}
|
|
146
160
|
}
|
|
147
|
-
const text = hit.map((p) => renderPerson(p, { pronoun: pronounOf(config) })).join('\n\n')
|
|
161
|
+
const text = hit.map((p) => renderPerson(p, { pronoun: pronounOf(config), startAt: model?.startAt })).join('\n\n')
|
|
148
162
|
return {
|
|
149
163
|
found: true,
|
|
150
164
|
text: text.length > PEOPLE_READ_MAX ? `${text.slice(0, PEOPLE_READ_MAX)}…` : text,
|