@ssamurias/dsh-fish 1.1.4 → 1.1.6

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.
Files changed (64) hide show
  1. package/AGENTS.md +13 -3
  2. package/CHANGELOG.md +110 -1
  3. package/README.md +37 -122
  4. package/RELEASE-NOTES-1.1.5.md +49 -0
  5. package/RELEASE-NOTES-1.1.6.md +57 -0
  6. package/lib/ask.js +7 -1
  7. package/lib/becoming.js +70 -0
  8. package/lib/claim.js +23 -0
  9. package/lib/client.js +306 -71
  10. package/lib/cue.js +99 -23
  11. package/lib/decisions.js +207 -0
  12. package/lib/derive.js +148 -13
  13. package/lib/events.js +28 -0
  14. package/lib/guard.js +75 -9
  15. package/lib/handoff.js +9 -1
  16. package/lib/herpeople.js +1 -1
  17. package/lib/home.js +4 -0
  18. package/lib/index.js +9 -3
  19. package/lib/memorymap-html.js +1 -1
  20. package/lib/move.js +68 -8
  21. package/lib/observe-bili.js +32 -2
  22. package/lib/observe-config.js +14 -2
  23. package/lib/observe-data.js +19 -1
  24. package/lib/observe-home.js +13 -3
  25. package/lib/observe-state.js +3 -2
  26. package/lib/people.js +20 -11
  27. package/lib/peopledoc.js +1 -1
  28. package/lib/persona.js +15 -0
  29. package/lib/proactive.js +4 -2
  30. package/lib/quality.js +202 -48
  31. package/lib/recall.js +103 -24
  32. package/lib/reset-pending.js +15 -5
  33. package/lib/reset.js +78 -0
  34. package/lib/retire.js +42 -1
  35. package/lib/say.js +45 -3
  36. package/lib/scheduler.js +69 -30
  37. package/lib/selfdoc.js +1 -1
  38. package/lib/settings.js +148 -31
  39. package/lib/speak.js +10 -5
  40. package/lib/status.js +1 -1
  41. package/lib/timeintent.js +178 -0
  42. package/lib/turns.js +40 -1
  43. package/lib/types.d.ts +1 -0
  44. package/lib/wiki.js +66 -8
  45. package/package.json +4 -1
  46. package/tools/README.md +70 -0
  47. package/tools/recall-bench.mjs +240 -0
  48. package/tools/recall-cases.json +64 -0
  49. package/tools/recall-live-cases.json +20 -0
  50. package/lib/client/00-shell.js +0 -630
  51. package/lib/client/01-state-load.js +0 -962
  52. package/lib/client/02-actions.js +0 -692
  53. package/lib/client/03-widgets-header.js +0 -749
  54. package/lib/client/04-pressure-lab.js +0 -906
  55. package/lib/client/05-pressure-charts.js +0 -431
  56. package/lib/client/06-tab-status-grow.js +0 -479
  57. package/lib/client/07-tab-home-bili.js +0 -610
  58. package/lib/client/08-tab-memory-plugins.js +0 -676
  59. package/lib/client/09-tab-outing.js +0 -797
  60. package/lib/client/10-data-handlers.js +0 -519
  61. package/lib/client/11-tab-data-frame.js +0 -755
  62. package/lib/client/12-pressure-chip-mount.js +0 -579
  63. package/scripts/build-client.mjs +0 -97
  64. package/scripts/sync-pressure-formulas.mjs +0 -14
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
- /[A-Za-z]:[\\/][^\s]*/,
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
- * @returns {{ok:boolean, text:string, why:string}}
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 (looksLikeSecret(s).hit) {
178
- return { ok: false, text: '', why: 'secret' }
179
- }
180
- if (looksLikeLeak(s).hit) {
181
- return { ok: false, text: '', why: 'leak' }
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: s, why: '' }
249
+ return { ok: true, text: clean, why: '', redacted: true }
184
250
  }
package/lib/handoff.js CHANGED
@@ -24,6 +24,7 @@ import { worksForDesk } from './works.js'
24
24
  import { readNotes } from './note.js'
25
25
  import { readAppointments } from './appoint.js'
26
26
  import { recentExchanges } from './talkmem.js'
27
+ import { resetEpoch } from './reset.js'
27
28
  import { fillOwner } from './pronoun.js'
28
29
  import { clipText } from './clip.js'
29
30
 
@@ -267,7 +268,14 @@ export function renderHandoff({ exchanges = [], notes = [], appointments = [], w
267
268
  */
268
269
  export async function buildHandoff(root, { turns = 3, room = '' } = {}) {
269
270
  const want = Math.max(0, Math.min(20, Math.trunc(Number(turns) || 0)))
270
- const exchanges = want > 0 ? await recentExchanges(root, want).catch(() => []) : []
271
+ // 2026-12-01(外部反馈):重开一局之后,交接页不许把上一局的原话再摆出来。
272
+ // talk-recent.json 跟着状态库一起搬走了,正常情况下本来就是空的;这里再按
273
+ // 「这一局的第一天」截一刀,防的是旧档/恢复把时间戳很旧的条目带了回来。
274
+ const epoch = await resetEpoch(root)
275
+ const all = want > 0 ? await recentExchanges(root, want).catch(() => []) : []
276
+ const exchanges = epoch > 0
277
+ ? all.filter((e) => !Number.isFinite(Date.parse(String(e?.at ?? ''))) || Date.parse(String(e.at)) >= epoch)
278
+ : all
271
279
  const notes = await readNotes(root).catch(() => [])
272
280
  const appointments = await readAppointments(root).catch(() => [])
273
281
  const works = await worksForDesk(root).catch(() => ({ wip: null }))
package/lib/herpeople.js CHANGED
@@ -158,7 +158,7 @@ export function registerHerPeople(ctx, deps = {}) {
158
158
  '。',
159
159
  }
160
160
  }
161
- 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')
162
162
  return {
163
163
  found: true,
164
164
  text: text.length > PEOPLE_READ_MAX ? `${text.slice(0, PEOPLE_READ_MAX)}…` : text,
package/lib/home.js CHANGED
@@ -31,6 +31,7 @@ import { armHandoff, buildHandoff, carryExpired, CARRY_DAYS, CARRY_TURNS } from
31
31
  import { freshWakeText } from './wakeconst.js'
32
32
  import { dateKey, loadConfig } from './settings.js'
33
33
  import { asHerSession, rememberHerSession } from './restrict.js'
34
+ import { isRetiredSession } from './claim.js'
34
35
 
35
36
  const TITLE_WORKSPACE = '大肥鱼的家'
36
37
  const TITLE_SESSION = '跟大肥鱼说话'
@@ -1217,6 +1218,9 @@ export async function verifyWoke(ctx, { root = '', sessionId = '', log, delayMs
1217
1218
  export async function adoptTalkSession(root = rootDir(), sessionId = '') {
1218
1219
  const sid = String(sessionId ?? '')
1219
1220
  if (!sid) return false
1221
+ // 2026-12-01(外部反馈):重开一局之前的会话不许再当她的家——它里面住着上一局的话。
1222
+ // 调用方(/say、桥、恢复)手里那个 id 可能很旧;宁可让她另建一间。
1223
+ if (isRetiredSession(sid)) return false
1220
1224
  // 认回来的这条从此就是她的家:先记进身份台账,宿主晚一步发 agent/created
1221
1225
  // 也能按 id 认出来(2026-11-22,与 createTalkSession 的认领同一套判据)。
1222
1226
  rememberHerSession(sid, paths(root).herDir)
package/lib/index.js CHANGED
@@ -50,10 +50,11 @@ import { noteRoot } from './homes.js'
50
50
  import { writeSelfDoc } from './selfdoc.js'
51
51
  import { claimRoot, beatRootState, releaseRoot, HEARTBEAT_MS } from './tenant.js'
52
52
  import { runPendingReset } from './reset-pending.js'
53
+ import { retiredSessionIds } from './reset.js'
53
54
  import { rootMovedAway } from './move.js'
54
55
  import { setRiskLog } from './bili.js'
55
56
  import { registerToolRestrict, seedHerSessions, isHerSessionId } from './restrict.js'
56
- import { setBridgeDirs } from './claim.js'
57
+ import { setBridgeDirs, setRetiredSessions } from './claim.js'
57
58
  // `clearWakeSection` 在 dispose 里用:它挂在 system prompt 段上,是个模块级变量,
58
59
  // 停用时不清的话下次启用会带着上一次的残留(2026-10-25)。
59
60
  import { clearWakeSection, registerIdentity } from './identity.js'
@@ -70,7 +71,7 @@ export const name = 'dsh-fish'
70
71
  * 版本号,必须和 package.json 的 version 一样(test/boot.test.mjs 盯着)。
71
72
  * 不只是日志:升级自检和设置页的「检查更新」拿它当「正在跑的版本」。
72
73
  */
73
- export const VERSION = '1.1.4'
74
+ export const VERSION = '1.1.6'
74
75
 
75
76
  // ⚠️ 一个数组写全,不要拆成对象
76
77
  // 2026-10-30(m02961):`userQuestions` **不再写进 inject**。写进 inject 的东西缺一个,
@@ -144,7 +145,12 @@ export function apply(ctx, baseConfig = {}) {
144
145
  logger.warn(`[dsh-fish] 重开一局这次没搬成(${pending.code}):${pending.why || ''}`)
145
146
  }
146
147
  } catch { /* runPendingReset 不该抛;真抛了也不能挡启动 */ }
147
- logBoot(root, `${VERSION} · ${process.version} · ${process.platform}`)
148
+ // 2026-12-01(外部反馈):把「上一局建出来的会话」灌给认领判据。
149
+ // 排着的重开可能刚在这一步之前搬完(新 root 里有 reset.json),也可能上次就已经搬完,
150
+ // 两种情况都读一次;老档没有这份文件时名单是空的,行为一点不变。
151
+ try {
152
+ setRetiredSessions(await retiredSessionIds(root))
153
+ } catch { /* 读不出来就当没有:宁可漏挡,不能挡启动 */ } logBoot(root, `${VERSION} · ${process.version} · ${process.platform}`)
148
154
  // 宿主兼容探测:`userQuestions` 缺席时不是错误,只是关一条路——但必须留话,
149
155
  // 否则用户只会看到「有个功能没反应」,又回到这次那种查不下去的局面。
150
156
  try {