@ssamurias/dsh-fish 1.1.5 → 1.1.7

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 (74) hide show
  1. package/AGENTS.md +27 -4
  2. package/CHANGELOG.md +150 -0
  3. package/README.md +31 -4
  4. package/RELEASE-NOTES-1.1.6.md +57 -0
  5. package/RELEASE-NOTES-1.1.7.md +76 -0
  6. package/lib/ask.js +7 -1
  7. package/lib/capture.js +1 -0
  8. package/lib/claim.js +23 -0
  9. package/lib/client.js +329 -79
  10. package/lib/comment.js +18 -10
  11. package/lib/cue.js +99 -23
  12. package/lib/derive.js +215 -49
  13. package/lib/desk.js +5 -2
  14. package/lib/didclaim.js +307 -0
  15. package/lib/events.js +32 -4
  16. package/lib/handoff.js +13 -3
  17. package/lib/health.js +4 -0
  18. package/lib/hear.js +8 -1
  19. package/lib/herperson.js +33 -18
  20. package/lib/home.js +4 -0
  21. package/lib/inbox.js +23 -7
  22. package/lib/index.js +9 -3
  23. package/lib/loadgate.js +48 -0
  24. package/lib/memorymap-html.js +1 -1
  25. package/lib/memorymap.js +22 -2
  26. package/lib/move.js +68 -8
  27. package/lib/observe-bili.js +32 -2
  28. package/lib/observe-config.js +81 -6
  29. package/lib/observe-data.js +3 -1
  30. package/lib/observe-home.js +15 -4
  31. package/lib/observe-http.js +4 -0
  32. package/lib/observe-state.js +3 -2
  33. package/lib/people.js +78 -2
  34. package/lib/persona.js +8 -3
  35. package/lib/proactive.js +11 -4
  36. package/lib/quality.js +207 -48
  37. package/lib/recall.js +73 -24
  38. package/lib/redact.js +27 -0
  39. package/lib/reset-pending.js +15 -5
  40. package/lib/reset.js +78 -0
  41. package/lib/restrict.js +40 -2
  42. package/lib/retire.js +42 -1
  43. package/lib/say.js +60 -13
  44. package/lib/scheduler.js +32 -27
  45. package/lib/schema.js +1 -1
  46. package/lib/selfdoc.js +6 -0
  47. package/lib/settings.js +166 -31
  48. package/lib/status.js +1 -1
  49. package/lib/timeintent.js +178 -0
  50. package/lib/turns.js +86 -28
  51. package/lib/types.d.ts +1 -0
  52. package/lib/wiki.js +72 -9
  53. package/lib/works.js +5 -0
  54. package/media/feedback-qr.jpg +0 -0
  55. package/package.json +4 -1
  56. package/tools/README.md +69 -0
  57. package/tools/recall-bench.mjs +240 -0
  58. package/tools/recall-cases.json +64 -0
  59. package/tools/recall-live-cases.json +20 -0
  60. package/lib/client/00-shell.js +0 -630
  61. package/lib/client/01-state-load.js +0 -968
  62. package/lib/client/02-actions.js +0 -692
  63. package/lib/client/03-widgets-header.js +0 -749
  64. package/lib/client/04-pressure-lab.js +0 -906
  65. package/lib/client/05-pressure-charts.js +0 -431
  66. package/lib/client/06-tab-status-grow.js +0 -479
  67. package/lib/client/07-tab-home-bili.js +0 -610
  68. package/lib/client/08-tab-memory-plugins.js +0 -676
  69. package/lib/client/09-tab-outing.js +0 -797
  70. package/lib/client/10-data-handlers.js +0 -519
  71. package/lib/client/11-tab-data-frame.js +0 -812
  72. package/lib/client/12-pressure-chip-mount.js +0 -579
  73. package/scripts/build-client.mjs +0 -97
  74. package/scripts/sync-pressure-formulas.mjs +0 -14
package/lib/comment.js CHANGED
@@ -27,7 +27,7 @@ import { itemsFromEvents } from './browse.js'
27
27
  import { sanitizeForeign } from './guard.js'
28
28
  import { recordGuard } from './guardlog.js'
29
29
  import { deriveSelf } from './derive.js'
30
- import { redactOwner } from './redact.js'
30
+ import { redactOwnerAll } from './redact.js'
31
31
  import { fillOwner } from './pronoun.js'
32
32
  import { clipText } from './clip.js'
33
33
 
@@ -46,14 +46,22 @@ async function readOnlyClient(root) {
46
46
  return createClient({ cookie })
47
47
  }
48
48
 
49
- /** 出口脱敏用的名字:派生失败就当没有名字,绝不让一次发布因为派生失败而中断。 */
50
- function safeOwnerName(events, override, config) {
51
- if (override != null) return String(override)
49
+ /**
50
+ * 出口脱敏用的名字:派生失败就当没有名字,绝不让一次发布因为派生失败而中断。
51
+ *
52
+ * 2026-12-02:返回的是**她叫过{T}的每一个称呼**(`model.ownerNames`,最近在前),
53
+ * 不只是现在这个——改口之后旧名字(往往正是写错的那个)还留在她要发的文字里,
54
+ * 只换新名字会把它漏到公开评论区。overrides 仍是单个名字(老调用)。
55
+ */
56
+ function safeOwnerNames(events, override, config) {
57
+ if (override != null) return [String(override)]
52
58
  try {
53
59
  // 带上主人的代称:认称呼时哪个「她 / TA」算指主人,跟着它走(lib/derive.js 的 nameRules)
54
- return String(deriveSelf(events, { owner: config?.owner }).name ?? '')
60
+ const model = deriveSelf(events, { owner: config?.owner })
61
+ const names = Array.isArray(model?.ownerNames) ? model.ownerNames : []
62
+ return names.length ? names : [String(model?.name ?? '')].filter(Boolean)
55
63
  } catch {
56
- return ''
64
+ return []
57
65
  }
58
66
  }
59
67
 
@@ -562,9 +570,9 @@ export async function postComment(o = {}) {
562
570
  if (!inWindow({ window: c.window ?? config.window }, new Date())) return { ok: false, why: '现在不是说话的时候' }
563
571
 
564
572
  const events = (await readEvents(root)).events
565
- const ownerName = safeOwnerName(events, o.ownerName, config)
573
+ const ownerNames = safeOwnerNames(events, o.ownerName, config)
566
574
  // 出口脱敏:只改真正发出去的文字,事件流与提示词都不动。
567
- const safeText = prefix + redactOwner(text, ownerName)
575
+ const safeText = prefix + redactOwnerAll(text, ownerNames)
568
576
  if (safeText.length > 1000) return { ok: false, why: '太长了' }
569
577
  const dk = o.dateKey ?? dateKey()
570
578
  const used = commentCountToday(events, dk)
@@ -627,8 +635,8 @@ export async function postReply(o = {}) {
627
635
  if (!inWindow({ window: c.window ?? config.window }, new Date())) return { ok: false, why: '现在不是说话的时候' }
628
636
 
629
637
  const events = (await readEvents(root)).events
630
- const ownerName = safeOwnerName(events, o.ownerName, config)
631
- const safeText = prefix + redactOwner(text, ownerName)
638
+ const ownerNames = safeOwnerNames(events, o.ownerName, config)
639
+ const safeText = prefix + redactOwnerAll(text, ownerNames)
632
640
  const dk = o.dateKey ?? dateKey()
633
641
 
634
642
  const bvid = String(o.bvid ?? '').trim()
package/lib/cue.js CHANGED
@@ -8,7 +8,8 @@
8
8
  * - 只认她自己的判断(deriveSelf 的 active beliefs),且要和他这句话碰得上;
9
9
  * - 最多 1 条,按主题词/近义词/原话关键词给分,过了门槛才摆;
10
10
  * - 只给她原话和日期,加一句「只是当时说过,不代表现在也这么想」;
11
- * - 「规矩」不摆:规矩是硬约束,不是可对照的旧判断;
11
+ * - 「规矩」和「立场」也进比对(1.1.6,用户 m06547):规矩是硬约束,摆法是
12
+ * 「现在就按这个来」;立场是「这类事上你站住过」。三种东西三种口气,不混成一句。
12
13
  * - 拿不到最新派生(进程刚起、还没写过身份文档)就不摆,不猜。
13
14
  *
14
15
  * 为什么用 memory 里的最新派生,而不是每句话都重算事件流:
@@ -27,6 +28,8 @@ import { lastDerived } from './derive.js'
27
28
  import { logLine } from './log.js'
28
29
  import { loopsCached } from './loops.js'
29
30
  import { pickForText, pickMatch, canShowMore, blockedCached, recordShown } from './match.js'
31
+ import { buildStances } from './stance.js'
32
+ import { rulesOf } from './selfrules.js'
30
33
 
31
34
  const RULE_TOPIC = '规矩'
32
35
  const OLD_TEXT_MAX = 80
@@ -105,6 +108,93 @@ export function cueScore(belief, humanLower) {
105
108
  return null
106
109
  }
107
110
 
111
+ /**
112
+ * 「她说过的那句话」和眼前这件事重合几个二字组(1.1.6,用户 m06547)。
113
+ * 判断那条走 `cueScore`(topic/近义词/原话三路);规矩与立场没有 topic,
114
+ * 只走这一路,门槛和判断那条一样 0.6。宁可少摆:碰不上就不出现,
115
+ * 比每轮都念一遍价值观好。
116
+ */
117
+ function wordsScore(said, lower) {
118
+ const s = String(said ?? '')
119
+ if (!s || !lower) return 0
120
+ const shared = [...bigrams(s)].filter((g) => lower.includes(g)).length
121
+ return shared >= 3 ? 0.6 : 0
122
+ }
123
+
124
+ /** 她站住过的立场 + 自己定的规矩,各自化成候选(1.1.6,用户 m06547)。 */
125
+ export function valueCandidates(model, lower) {
126
+ const out = []
127
+ try {
128
+ for (const s of buildStances(model ?? {}, { limit: 12 })) {
129
+ const text = String(s?.text ?? '').replace(/\s+/g, ' ').trim()
130
+ const score = wordsScore(text, lower)
131
+ if (!text || score < CUE_MIN_SCORE) continue
132
+ out.push({ kind: 'stance', score, via: 'words', text, at: Date.parse(String(s?.since ?? '')) || 0 })
133
+ }
134
+ } catch { /* 立场算不出来,不挡判断那一路 */ }
135
+ try {
136
+ for (const r of rulesOf(model?.beliefs ?? [])) {
137
+ const text = String(r?.text ?? '').replace(/\s+/g, ' ').trim()
138
+ const score = wordsScore(text, lower)
139
+ if (!text || score < CUE_MIN_SCORE) continue
140
+ out.push({ kind: 'rule', score, via: 'words', text, at: Date.parse(String(r?.since ?? '')) || 0 })
141
+ }
142
+ } catch { /* 同上 */ }
143
+ return out
144
+ }
145
+
146
+ /** 同分时谁先摆:规矩(硬约束)> 立场(站住过)> 判断(当时说过)。 */
147
+ const KIND_RANK = { rule: 0, stance: 1, belief: 2 }
148
+
149
+ /**
150
+ * 他这句话碰到的最高分那一条;没有就 null。
151
+ * 纯函数,给测试与日志用(`cueBullet` 只负责把它摆成一行)。
152
+ */
153
+ export function cuePick(model, text) {
154
+ const t = String(text ?? '').trim()
155
+ if (!t) return null
156
+ const lower = t.toLowerCase()
157
+ const cands = []
158
+ for (const b of model?.beliefs ?? []) {
159
+ const hit = cueScore(b, lower)
160
+ if (!hit || hit.score < CUE_MIN_SCORE) continue
161
+ const said = String(b?.text ?? '').replace(/\s+/g, ' ').trim()
162
+ if (!said) continue
163
+ cands.push({
164
+ kind: 'belief',
165
+ score: hit.score,
166
+ via: hit.via,
167
+ text: said,
168
+ at: Date.parse(String(b?.since ?? '')) || 0,
169
+ topic: String(b?.topic ?? ''),
170
+ })
171
+ }
172
+ cands.push(...valueCandidates(model, lower))
173
+ if (!cands.length) return null
174
+ cands.sort((x, y) => (y.score - x.score) || (KIND_RANK[x.kind] - KIND_RANK[y.kind]) || (y.at - x.at))
175
+ return cands[0]
176
+ }
177
+
178
+ /** 摆出来的那一行。三种东西三种口气,别混成一句话。 */
179
+ function renderPick(pick) {
180
+ const said = String(pick?.text ?? '').trim()
181
+ if (!said) return ''
182
+ const clipped = [...said].length > OLD_TEXT_MAX
183
+ ? `${[...said].slice(0, OLD_TEXT_MAX).join('')}…`
184
+ : said
185
+ const at = Number(pick.at ?? 0)
186
+ const when = at > 0 ? dateKey(new Date(at)).slice(5) : ''
187
+ const stamp = when ? `(${when})` : ''
188
+ if (pick.kind === 'rule') {
189
+ // 规矩不是「旧话」:它是她现在就认的那条线,所以不给她「不代表现在也这么想」。
190
+ return `- 这是你自己定下的规矩:「${clipped}」${stamp}。跟眼前这件事对得上就按它来;对不上,按眼前的事。`
191
+ }
192
+ if (pick.kind === 'stance') {
193
+ return `- 这类事上你站住过:「${clipped}」${stamp}。要是这条还算数,就按它来;不算数了,就照眼前的事。`
194
+ }
195
+ return `- 你以前说过:「${clipped}」${stamp}。只是你当时说过,不代表现在也这么想。`
196
+ }
197
+
108
198
  /** 他一开口就记下这句话(同步,能在宿主组装提示词之前跑到)。 */
109
199
  export function rememberHuman(sessionId, text, { at = Date.now() } = {}) {
110
200
  const sid = String(sessionId ?? '')
@@ -175,30 +265,16 @@ export function cueLineFrom(model, text, { root } = {}) {
175
265
 
176
266
  /** 只给那一行(不带小标题),合并出口要用它。 */
177
267
  export function cueBullet(model, text, { root } = {}) {
178
- const t = String(text ?? '').trim()
179
- if (!t) return ''
180
- const lower = t.toLowerCase()
181
- const scored = []
182
- for (const b of model?.beliefs ?? []) {
183
- const hit = cueScore(b, lower)
184
- if (hit && hit.score >= CUE_MIN_SCORE) scored.push({ b, ...hit })
185
- }
186
- if (!scored.length) return ''
187
- scored.sort((x, y) => (y.score - x.score) || ((Date.parse(y.b.since) || 0) - (Date.parse(x.b.since) || 0)))
188
- const { b, score, via } = scored[0]
189
- const said = String(b.text ?? '').replace(/\s+/g, ' ').trim()
190
- if (!said) return ''
191
- // 命中留一行日志:只给通道、分数、主题词,不打他的原话(H,1.0.7)。
268
+ let pick = null
269
+ try { pick = cuePick(model, text) } catch { pick = null }
270
+ if (!pick) return ''
271
+ // 命中留一行日志:只给通道、分数、种类,不打他的原话(H,1.0.7)。
192
272
  try {
193
- if (root) logLine('info', ['cue', `via=${via}`, `score=${score.toFixed(2)}`, `topic=${String(b.topic ?? '')}`], root)
273
+ if (root) {
274
+ logLine('info', ['cue', `via=${pick.via}`, `score=${Number(pick.score).toFixed(2)}`, `kind=${pick.kind}`, `topic=${String(pick.topic ?? '')}`], root)
275
+ }
194
276
  } catch { /* 日志挂了不挡 cue */ }
195
- const clipped = [...said].length > OLD_TEXT_MAX
196
- ? `${[...said].slice(0, OLD_TEXT_MAX).join('')}…`
197
- : said
198
- const at = Date.parse(b.since)
199
- const when = Number.isFinite(at) ? dateKey(new Date(at)).slice(5) : ''
200
- const stamp = when ? `(${when})` : ''
201
- return `- 你以前说过:「${clipped}」${stamp}。只是你当时说过,不代表现在也这么想。`
277
+ return renderPick(pick)
202
278
  }
203
279
 
204
280
  /**