@ssamurias/dsh-fish 0.9.5 → 0.9.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 (59) hide show
  1. package/AGENTS.md +30 -7
  2. package/CHANGELOG.md +214 -2
  3. package/README.md +6 -2
  4. package/RELEASE-NOTES-0.9.5.md +2 -1
  5. package/RELEASE-NOTES-0.9.6.md +84 -0
  6. package/RELEASE-NOTES-0.9.7.md +143 -0
  7. package/RELEASE.md +2 -2
  8. package/lib/appoint.js +4 -3
  9. package/lib/ask.js +5 -4
  10. package/lib/askinchat.js +2 -1
  11. package/lib/backup.js +344 -37
  12. package/lib/bili.js +16 -4
  13. package/lib/browse.js +93 -16
  14. package/lib/capture.js +3 -1
  15. package/lib/client.js +732 -202
  16. package/lib/clip.js +57 -0
  17. package/lib/comment.js +96 -31
  18. package/lib/deliver.js +6 -4
  19. package/lib/derive.js +110 -18
  20. package/lib/desk.js +2 -2
  21. package/lib/events.js +18 -6
  22. package/lib/generator.js +9 -3
  23. package/lib/hear.js +44 -2
  24. package/lib/herdiary.js +45 -11
  25. package/lib/history.js +23 -4
  26. package/lib/home.js +17 -1
  27. package/lib/hook.js +190 -0
  28. package/lib/import.js +37 -12
  29. package/lib/index.js +8 -6
  30. package/lib/look.js +47 -5
  31. package/lib/move.js +6 -4
  32. package/lib/note.js +11 -11
  33. package/lib/observe.js +485 -201
  34. package/lib/outing.js +140 -29
  35. package/lib/owner.js +7 -1
  36. package/lib/persona.js +111 -20
  37. package/lib/possess.js +4 -3
  38. package/lib/quality.js +4 -1
  39. package/lib/recall.js +15 -1
  40. package/lib/restrict.js +252 -36
  41. package/lib/say.js +5 -1
  42. package/lib/scheduler.js +145 -80
  43. package/lib/schema.js +15 -1
  44. package/lib/selfcheck.js +63 -10
  45. package/lib/selfdoc.js +90 -15
  46. package/lib/selfupdate.js +38 -1
  47. package/lib/settings.js +23 -2
  48. package/lib/speak.js +21 -4
  49. package/lib/stance.js +72 -1
  50. package/lib/store.js +37 -2
  51. package/lib/tenant.js +33 -0
  52. package/lib/tool.js +20 -1
  53. package/lib/toolreg.js +2 -0
  54. package/lib/turns.js +148 -7
  55. package/lib/use.js +70 -18
  56. package/lib/video.js +69 -38
  57. package/lib/watch.js +24 -3
  58. package/lib/wish.js +55 -6
  59. package/package.json +1 -1
package/lib/look.js CHANGED
@@ -15,11 +15,13 @@
15
15
 
16
16
  import { createClient } from './bili.js'
17
17
  import { readMyReplies, renderMyReplies } from './comment.js'
18
- import { absorb, renderMaterial, rankVideos, seenBvids, LOOK_BRIEF, WATCH_RULE } from './browse.js'
18
+ import { absorb, renderMaterial, rankVideos, seenBvids, metaTitle, LOOK_BRIEF, WATCH_RULE } from './browse.js'
19
19
  import { readEvents, rootDir, appendEvent } from './store.js'
20
20
  import { loadConfig, dateKey, biliOn } from './settings.js'
21
21
  // 评论区里别人的话(2026-10-24,用户 m02454)
22
22
  import { recordVoice } from './voices.js'
23
+ // 素材旁边的那一行钩子(2026-11-09,0.9.6 S2)
24
+ import { buildHooks } from './hook.js'
23
25
  import { toJsonSchema } from './toolschema.js'
24
26
  import { guardWrite } from './tenant.js'
25
27
 
@@ -158,7 +160,10 @@ export async function lookOnce(o = {}) {
158
160
  const who = { day: Number(o.model?.day ?? 0), stage: Number(o.model?.stage ?? 1), source: 'system' }
159
161
  const stamp = sessionId ? { sessionId } : {}
160
162
  for (const p of packs) {
161
- await appendEvent({ type: 'meta', text: `looked:${p.video.bvid}`, ...stamp }, { ...who }, root).catch(() => {})
163
+ // 0.9.7 T2:标题跟着 `looked:` 落下来。她自己点名看的这条,是「她看过什么」
164
+ // 里最该被她自己翻到的一类;只留 BV 号的话,回忆里只有一串编号。
165
+ const title = metaTitle(p.video?.title)
166
+ await appendEvent({ type: 'meta', text: `looked:${p.video.bvid}${title ? ` ${title}` : ''}`, ...stamp }, { ...who }, root).catch(() => {})
162
167
  // 今天真的看过的那一条:评论闸门认这一行(2026-10-28)。
163
168
  // 与 looked: 的区别是带日期——昨天看过的,今天不能拿去评。
164
169
  //
@@ -180,12 +185,24 @@ export async function lookOnce(o = {}) {
180
185
 
181
186
  // 评论区里别人的话(2026-10-24,用户 m02454):她自己去看的时候也可能读到一句。
182
187
  const voice = await recordVoice({ packs, events, model: o.model, root, cfg, sessionId })
188
+ // 钩子(2026-11-09,0.9.6 S2):她自己点名看的那条也挂——她主动去看的东西,
189
+ // 恰恰最可能是「和以前想过的事有关」才去看的。
190
+ const hooks = buildHooks(o.model, packs)
191
+ if (hooks.size) {
192
+ const lv = [...hooks.values()].some((h) => h.level === 1) ? 1 : 2
193
+ await appendEvent({ type: 'meta', text: `hook:${lv}` }, { ...who }, root).catch(() => {})
194
+ }
183
195
 
196
+ // 「翻到」不是「看见」(2026-11-09,外部用户反馈):她只看列表、从不点开画面,
197
+ // 因为翻完这一趟就算做完了。所以把下一步放在她刚拿到素材的这一刻说,
198
+ // 而不是另写一条规矩。今天已经看过画面的不再念;一条都没剩就不念。
199
+ const material = single
200
+ ? renderMaterial(packs, { head: '这一条。是你自己点名要看的那条。', ...(hooks.size ? { hooks } : {}) })
201
+ : renderMaterial(packs, hooks.size ? { hooks } : {})
202
+ const hint = frameHint(events, dk, packs.map((p) => p.video?.bvid), single)
184
203
  return {
185
204
  ok: true,
186
- text: single
187
- ? renderMaterial(packs, { head: '这一条。是你自己点名要看的那条。' })
188
- : renderMaterial(packs),
205
+ text: hint ? `${material}\n\n${hint}` : material,
189
206
  note: '',
190
207
  voice: voice ? { text: voice.text, why: voice.why, across: voice.across ?? 1 } : null,
191
208
  picks: packs.map((p) => ({
@@ -209,6 +226,31 @@ function describeErr(r) {
209
226
  return `打不开(${code})。`
210
227
  }
211
228
 
229
+ /**
230
+ * 「翻到」不是「看见」(2026-11-09,外部用户反馈)。
231
+ *
232
+ * 列表只给字,画面要另外用 bili_watch 取。她翻完列表就把这一趟当成做完了,
233
+ * 一次都没想起来看画面(日志里 `browse:` 二十几条,`watched:` 一条)。
234
+ * 所以这句要放在她**刚拿到素材**的这一刻,且只在今天还没看过画面的那几条上说。
235
+ * 不劝、不报额度:看几条由她自己定。
236
+ */
237
+ function frameHint(events, dk, bvids, single) {
238
+ const watched = new Set()
239
+ const head = `watched:${dk} `
240
+ for (const e of events ?? []) {
241
+ if (e?.type !== 'meta') continue
242
+ const t = String(e.text ?? '')
243
+ if (!t.startsWith(head)) continue
244
+ const bvid = t.slice(head.length).split(' ')[0]
245
+ if (bvid) watched.add(bvid)
246
+ }
247
+ const left = [...new Set((bvids ?? []).filter((b) => b && !watched.has(b)))]
248
+ if (!left.length) return ''
249
+ return single
250
+ ? `这一条我只翻到了标题和文字,画面还没看。它到底长什么样,用 bili_watch 看一眼——不想看也行。`
251
+ : `这几条我只翻到了标题和文字,画面还没看。哪条让你拿不准它到底长什么样,用 bili_watch 看一眼——不想看也行。`
252
+ }
253
+
212
254
  /**
213
255
  * 她要看的到底是哪一条(2026-10-28)。
214
256
  * BV 号优先;其次他递来的链接(b23.tv 短链交给 client 解析,她不用自己拼)。
package/lib/move.js CHANGED
@@ -69,6 +69,9 @@ export async function planMove(root = rootDir(), target = '') {
69
69
  } catch { /* 没有档 */ }
70
70
  if (!existingArchive) {
71
71
  const sub = join(dir, 'dsh-fish')
72
+ // 原地不动:选的是她现在那个 dsh-fish 的上级,拼回来正好是她自己。
73
+ // 要在「已有非空 dsh-fish」之前判,不然她自己会被说成「已经有一个 dsh-fish 且不是空的」。
74
+ if (norm(sub) === norm(from)) { out.why = '她本来就在这个位置'; return out }
72
75
  try {
73
76
  const s = await fs.stat(sub)
74
77
  if (!s.isDirectory()) { out.why = '目标里有个同名的 dsh-fish,但不是文件夹'; return out }
@@ -81,17 +84,16 @@ export async function planMove(root = rootDir(), target = '') {
81
84
  }
82
85
  }
83
86
 
87
+ // 选的就是她现在住的文件夹(里面有她自己的 events.jsonl):也是原地不动。
88
+ if (norm(asRoot) === norm(from)) { out.why = '她本来就在这个位置'; return out }
84
89
  if (inside(asRoot, from)) { out.why = '不能搬到她现在住的地方里面'; return out }
85
90
  if (inside(from, asRoot)) { out.why = '不能搬到她现在住的地方的上级——那样会连她自己一起套进去'; return out }
86
91
  // issue #65:目标里已经有一份档就拒绝——原来的分支把它当新根,
87
- // copyFile 会把那边的事件流整个盖掉,而且不留备份。
92
+ // copyFile 会把那边的事件流整个盖掉,而且不留备份。现在在这里拦下,两边都不动。
88
93
  if (existingArchive) {
89
94
  out.why = '这个文件夹里已经有一份她的档了(有 events.jsonl)。换一个空文件夹——那边的同名文件会被覆盖。'
90
95
  return out
91
96
  }
92
- if (norm(asRoot) === norm(defaultRoot()) && norm(from) === norm(defaultRoot())) {
93
- out.why = '她本来就在这个位置'; return out
94
- }
95
97
 
96
98
  // 源必须是真目录
97
99
  try {
package/lib/note.js CHANGED
@@ -175,14 +175,14 @@ export function renderNotes(notes, now = new Date()) {
175
175
  due.sort((a, b) => (a.due < b.due ? -1 : a.due > b.due ? 1 : String(a.created).localeCompare(String(b.created))))
176
176
 
177
177
  const shown = due.slice(0, NOTE_SHOW_MAX)
178
- const lines = [`(桌上压着${cnCount(due.length)}张)`]
178
+ const lines = [`(压着${cnCount(due.length)}张便条)`]
179
179
  for (const n of shown) {
180
180
  const mmdd = `${n.due.slice(5, 7)}-${n.due.slice(8, 10)}`
181
181
  const tail = n.late === 0 ? '就是今天。' : `晚了${cnNum(n.late)}天。`
182
182
  lines.push(`${mmdd} ${n.text},${tail}`)
183
183
  }
184
184
  const rest = due.length - shown.length
185
- if (rest > 0) lines.push(`还有${cnCount(rest)}条没列出来,都在桌上。`)
185
+ if (rest > 0) lines.push(`还有${cnCount(rest)}条没列出来,都在便条里。`)
186
186
  return lines.join('\n')
187
187
  }
188
188
 
@@ -207,7 +207,7 @@ export async function addNote(root, { text, due } = {}) {
207
207
  // 而拒绝的话还说「先划掉几张」,桌上根本没有能划的(issue #53 的死锁)。
208
208
  const openCount = notes.filter((n) => n.status === 'open').length
209
209
  if (openCount >= NOTES_MAX) {
210
- return { ok: false, id: '', note: '桌上堆满两百张没动的了,先划掉几张,或者放下几张(放下要写一句为什么)再说。' }
210
+ return { ok: false, id: '', note: '便条堆满两百张没动的了,先划掉几张,或者放下几张(放下要写一句为什么)再说。' }
211
211
  }
212
212
  const note = normalizeNote({
213
213
  id: newNoteId(),
@@ -254,7 +254,7 @@ export async function closeNote(root, { id, text } = {}) {
254
254
  const notes = await readNotes(root)
255
255
  const hit = notes.find((n) => key && n.id === key) ?? findByText(notes, body)
256
256
  if (!hit) {
257
- return { ok: false, id: '', note: '桌上没有这一张。要和当时记的那句话一字不差,前面的日子、后面的晚了几天都不算。' }
257
+ return { ok: false, id: '', note: '便条里没有这一张。要和当时记的那句话一字不差,前面的日子、后面的晚了几天都不算。' }
258
258
  }
259
259
  if (hit.status === 'done') return { ok: true, id: hit.id, note: '已经划掉过了。' }
260
260
  // 放下了的不是「做完了」,别把「放下」改写成「划掉」(issue #82)。
@@ -318,11 +318,11 @@ export function filterNotes(notes, filter = 'open') {
318
318
  }
319
319
 
320
320
  const EMPTY_LIST = {
321
- open: '桌上没有还没划掉的。',
321
+ open: '便条里没有还没划掉的。',
322
322
  due: '没有哪张写着日子。',
323
323
  done: '还没有划掉的。',
324
324
  dropped: '还没有放下的。',
325
- all: '桌上什么都没有。',
325
+ all: '便条里什么都没有。',
326
326
  }
327
327
 
328
328
  /**
@@ -386,7 +386,7 @@ export async function updateNote(root, { id, text, newText, due } = {}) {
386
386
  const notes = await readNotes(root)
387
387
  const hit = locate(notes, { id: key, text: body })
388
388
  if (!hit) {
389
- return { ok: false, id: '', note: '桌上没有这一张。要和当时记的那句话一字不差。' }
389
+ return { ok: false, id: '', note: '便条里没有这一张。要和当时记的那句话一字不差。' }
390
390
  }
391
391
  if (hit.status === 'done') return { ok: false, id: '', note: '这张已经划掉了,改不了。' }
392
392
  if (hit.status === 'dropped') return { ok: false, id: '', note: '这张已经放下了,改不了。' }
@@ -420,7 +420,7 @@ export async function dropNote(root, { id, text, reason } = {}) {
420
420
  const notes = await readNotes(root)
421
421
  const hit = locate(notes, { id: key, text: body })
422
422
  if (!hit) {
423
- return { ok: false, id: '', note: '桌上没有这一张。要和当时记的那句话一字不差。' }
423
+ return { ok: false, id: '', note: '便条里没有这一张。要和当时记的那句话一字不差。' }
424
424
  }
425
425
  if (hit.status === 'dropped') return { ok: true, id: hit.id, note: '之前就放下了。' }
426
426
  if (hit.status === 'done') return { ok: false, id: '', note: '这张已经划掉了,不用再放下。' }
@@ -453,16 +453,16 @@ export function registerNote(ctx, deps = {}) {
453
453
  defineTool({
454
454
  name: 'her_note',
455
455
  description:
456
- '醒来时先看的那张桌子:记一张还没做的事、看看桌上都有什么、划掉做完的、或者放下决定不做的。' +
456
+ '醒来时摆在你最前面的那叠便条:记一张还没做的事、翻一翻有哪些、划掉做完的、或者放下决定不做的。' +
457
457
  '记的时候给 text(和日子 due,可以不给);划掉把当时记的那句话原样放进 text,再加 status:"done";' +
458
- '看桌上有什么给 action:"list"(filter 可以选 open / due / done / dropped / all,列不完用 offset 往后翻);' +
458
+ '看便条有哪些给 action:"list"(filter 可以选 open / due / done / dropped / all,列不完用 offset 往后翻);' +
459
459
  '改一句给 action:"update"(text 指认原来那句,newText 写新的);' +
460
460
  '放下给 action:"drop"(同样用 text 指认,reason 写一句为什么)。',
461
461
  parameters: toJsonSchema({
462
462
  action: {
463
463
  type: 'string',
464
464
  enum: ['add', 'list', 'update', 'drop', 'done'],
465
- description: '要做哪件事:记一张(add,不给就是这个)、翻桌子(list)、改一句(update)、放下(drop)、划掉(done)。',
465
+ description: '要做哪件事:记一张(add,不给就是这个)、翻便条(list)、改一句(update)、放下(drop)、划掉(done)。',
466
466
  },
467
467
  text: {
468
468
  type: 'string',