dsh-aurorix-agentbook 1.9.2 → 1.9.3

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/lib/host.js CHANGED
@@ -54,6 +54,7 @@ import {
54
54
  DEFAULT_MANUAL,
55
55
  DEFAULT_PROTOCOL,
56
56
  resolveStatePath,
57
+ librarySignature,
57
58
  } from './snapshot.js'
58
59
  import { GUIDE, GUIDE_INDEX } from './guide.js'
59
60
  import { CURATION_MANUAL } from './curation.js'
@@ -114,6 +115,8 @@ export function attachHost(ctx, deps) {
114
115
  error: '',
115
116
  loading: false,
116
117
  stats: null,
118
+ // 这份文本对应的库指纹。库没变就不重建,避免每轮往对话里追加新快照把缓存顶掉。
119
+ signature: '',
117
120
  }
118
121
  let disposed = false
119
122
  let refreshTimer
@@ -157,14 +160,42 @@ export function attachHost(ctx, deps) {
157
160
  snapshot.stats = built.stats
158
161
  snapshot.error = ''
159
162
  snapshot.fetchedAt = Date.now()
163
+ // 记下这份文本对应的库指纹:下次库没变就不用重建。
164
+ snapshot.signature = librarySignature(libraryRoot())
160
165
  } catch (error) {
161
166
  snapshot.error = String(error?.message ?? error)
162
167
  }
168
+ // 快照建好了要让界面知道:面板可能早就打开过(那时还没东西可显示),
169
+ // 不通知它就会一直停在那句「还没构建过快照」上。
170
+ try {
171
+ deps.onSnapshot?.()
172
+ } catch {
173
+ // 回调是展示用的,出错不该影响注入本身
174
+ }
175
+ }
176
+
177
+ /** 库根:优先用后端解析出来的,配置里显式给了就用配置的。 */
178
+ const libraryRoot = () => {
179
+ const declared = String(backend?.root ?? '')
180
+ return declared
163
181
  }
164
182
 
165
183
  const refreshIfStale = () => {
166
184
  const current = cfg()
167
185
  if (disposed || snapshot.loading) return
186
+ // 指纹先判:库没变就什么都不做——重建会让宿主在对话尾部追加一条新消息,前缀缓存随之失效。
187
+ // 这一步必须在时间节流之前,否则刚写完记忆的十几秒里快照还是旧的,模型读不到新内容。
188
+ const signature = librarySignature(libraryRoot())
189
+ if (snapshot.text && snapshot.signature && snapshot.signature === signature) {
190
+ lastAttempt = Date.now()
191
+ return
192
+ }
193
+ // 库变了就立刻重建,不受 refreshMs 限制:变化的频率本来就低,缓存该换的时候就得换。
194
+ if (snapshot.signature && signature !== snapshot.signature) {
195
+ void refresh()
196
+ return
197
+ }
198
+ // 还没有可用快照(首次或上次失败)时才按 refreshMs 兜节流,避免失败时反复起子进程。
168
199
  const since = snapshot.fetchedAt || lastAttempt
169
200
  if (since && Date.now() - since < current.refreshMs) return
170
201
  void refresh()
@@ -795,5 +826,32 @@ export function attachHost(ctx, deps) {
795
826
  }, 'dsh-aurorix-agentbook commands')
796
827
  })
797
828
 
798
- return { refresh, snapshot: () => snapshot, access }
829
+ /**
830
+ * 注入状态快照:给界面看「这一轮往模型里放了什么」。
831
+ *
832
+ * 只报事实,不做估算:bytes 是真正那段快照的字节数,changed 是「当前库指纹是否
833
+ * 和这份快照对应的指纹不同」——为真时下一轮会重建,缓存也就会换一次。
834
+ */
835
+ const injectInfo = (locale) => {
836
+ const current = cfg()
837
+ const enabled = current.enabled !== false && current.injectSnapshot !== false
838
+ const text = snapshot.text ?? ''
839
+ const bytes = text === '' ? 0 : Buffer.byteLength(text, 'utf8')
840
+ const currentSig = librarySignature(libraryRoot())
841
+ return {
842
+ enabled,
843
+ bytes,
844
+ text,
845
+ error: snapshot.error || undefined,
846
+ stats: snapshot.stats ?? undefined,
847
+ ageSeconds: snapshot.fetchedAt ? Math.max(0, Math.round((Date.now() - snapshot.fetchedAt) / 1000)) : undefined,
848
+ changed: enabled && snapshot.signature !== '' && currentSig !== '' && currentSig !== snapshot.signature,
849
+ tierLabel: snapshot.stats
850
+ ? `${snapshot.stats.resident}常驻/${snapshot.stats.full}全量/${snapshot.stats.brief}摘要/${snapshot.stats.index}索引`
851
+ : '',
852
+ locale: typeof locale === 'string' ? locale : undefined,
853
+ }
854
+ }
855
+
856
+ return { refresh, snapshot: () => snapshot, access, injectInfo, signature: () => librarySignature(libraryRoot()) }
799
857
  }
package/lib/index.js CHANGED
@@ -46,13 +46,18 @@ export function apply(ctx, config) {
46
46
  attachWeb(ctx, { backend, root: settings.root || undefined })
47
47
 
48
48
  // 宿主层(提示词注入、工具、斜杠命令)和界面层共用这一个 backend。
49
- attachHost(ctx, {
49
+ const host = attachHost(ctx, {
50
50
  backend,
51
51
  config,
52
52
  onWrote: () => {
53
53
  // 写完之后界面上的条数也要跟上,下次打开面板就是新数字。
54
54
  for (const scope of states.keys()) publish()
55
55
  },
56
+ // 快照建好/重建后推一次:面板要看真实注入大小,回合脚注也要补发。
57
+ onSnapshot: () => {
58
+ publish()
59
+ for (const push of notePushes) push()
60
+ },
56
61
  })
57
62
 
58
63
  /** 一个面板实例的状态:分层计数、召回、保险箱、详情、草稿。只活在内存里。 */
@@ -103,6 +108,8 @@ export function apply(ctx, config) {
103
108
  /** 按会话各存一份,两个对话不会互相覆盖。 */
104
109
  const states = new Map()
105
110
  const listeners = new Set()
111
+ // 回合脚注各自的推送函数:快照建好后要重发一次,否则先打开的那轮永远是空的。
112
+ const notePushes = new Set()
106
113
 
107
114
  const keyOf = (scope) => (typeof scope?.sessionId === 'string' ? scope.sessionId : '-')
108
115
  const stateOf = (scope) => {
@@ -248,7 +255,25 @@ export function apply(ctx, config) {
248
255
  return { ok: true }
249
256
  }
250
257
 
251
- const patchOf = (scope, locale) => memoryData(stateOf(scope), { locale })
258
+ const patchOf = (scope, locale) => memoryData(withInject(scope), { locale })
259
+ /**
260
+ * 注入状态在取数那一刻同步读,不进共享状态。
261
+ *
262
+ * 早前是「写进 state 再 publish」,但那要依赖两边看到的 scope key 完全一致、
263
+ * 而且异步刷新不能把它覆盖掉;调试时好时坏就是这种时序依赖。面板数据本来就是
264
+ * 每次 emit 现算的,这里现取一个同步值最简单,也不会被别的刷新冲掉。
265
+ */
266
+ const injectNow = () => {
267
+ try {
268
+ return typeof host?.injectInfo === 'function' ? host.injectInfo() : undefined
269
+ } catch {
270
+ return undefined
271
+ }
272
+ }
273
+
274
+ /** 面板数据 = 面板状态 + 此刻的注入状态。 */
275
+ const withInject = (scope) => ({ ...stateOf(scope), inject: injectNow() })
276
+
252
277
  /** 当前详情一共有多少页:编辑态看页数组,阅读态按正文长度算。 */
253
278
  const totalPagesOf = (state) => {
254
279
  if (Array.isArray(state.detailPages) && state.detailPages.length > 0) return state.detailPages.length
@@ -268,7 +293,7 @@ export function apply(ctx, config) {
268
293
  ctx.dshGo.panel('memory-home', {
269
294
  view: (scope, caps) => memoryView(stateOf(scope), caps),
270
295
  data: (scope, emit, caps) => {
271
- const push = () => emit(memoryData(stateOf(scope), caps))
296
+ const push = () => emit(memoryData(withInject(scope), caps))
272
297
  push()
273
298
  listeners.add(push)
274
299
  if (stateOf(scope).loadedAt === undefined) {
@@ -276,6 +301,7 @@ export function apply(ctx, config) {
276
301
  refreshCounts(scope)
277
302
  refreshVault(scope)
278
303
  }
304
+ // 注入状态随每次 emit 现取,这里不用再单独刷一遍。
279
305
  return () => listeners.delete(push)
280
306
  },
281
307
  actions: {
@@ -573,6 +599,32 @@ export function apply(ctx, config) {
573
599
  return { refresh: 'memory-home' }
574
600
  },
575
601
 
602
+ // 看注入全文:单独取,不进面板数据(面板数据上限 32 KB,25 KB 的全文会把整份数据顶爆)。
603
+ 'inject-detail': (scope, event) => {
604
+ const odd = w(event?.locale)
605
+ const info = injectNow()
606
+ const text = String(info?.text ?? '')
607
+ if (text === '') return { toast: odd.injectNever }
608
+ // 走详情页:复制、翻页都是现成的,不用另做一套。
609
+ const pages = splitPages(text)
610
+ update(scope, {
611
+ detail: {
612
+ id: odd.injectTitle,
613
+ kind: 'inject',
614
+ title: odd.injectTitle,
615
+ plane: '',
616
+ readWhen: '',
617
+ updated: '',
618
+ bytes: Buffer.byteLength(text, 'utf8'),
619
+ body: text,
620
+ },
621
+ detailEditing: false,
622
+ detailPage: 0,
623
+ detailPages: pages,
624
+ })
625
+ return { refresh: 'memory-home' }
626
+ },
627
+
576
628
  'detail-copy': (scope, event) => {
577
629
  const odd = w(event?.locale)
578
630
  const detail = stateOf(scope).detail
@@ -609,6 +661,28 @@ export function apply(ctx, config) {
609
661
  return () => clearInterval(timer)
610
662
  })
611
663
 
664
+ // ── 回合脚注:每轮末尾一行,说明这轮往模型里注入了多少 ────────────
665
+ // 用户不必打开面板就知道插件在工作;注入量变了(库变化后重建)这里也能看出来。
666
+ ctx.dshGo.turnNote('memory-inject', (scope, emit, caps) => {
667
+ const show = () => {
668
+ const info = injectNow()
669
+ if (info === undefined || info.enabled !== true) return
670
+ const bytes = Number(info.bytes) || 0
671
+ if (bytes === 0) return
672
+ const kb = Math.max(1, Math.round(bytes / 1024))
673
+ const text = words(caps?.locale).injectNoteOnTurn(kb)
674
+ // 每段最多 16 字,宿主会截;这里自己先截,不让它显示半句。
675
+ if (text.length > 16) return
676
+ const turnId = typeof scope?.turnId === 'string' ? scope.turnId : ''
677
+ if (turnId === '') return
678
+ emit({ [turnId]: { text, tone: info.changed === true ? 'info' : undefined } })
679
+ }
680
+ show()
681
+ notePushes.add(show)
682
+ // 订阅取消时把自己摘掉,别让旧会话的函数一直挂在表里。
683
+ return () => notePushes.delete(show)
684
+ })
685
+
612
686
  // ── 胶囊「查记忆」:把输入框里的词拿去查,结果插回输入框 ──────────
613
687
  ctx.dshGo.on('mem-recall', (scope, event) => {
614
688
  const odd = w(event?.locale)
package/lib/snapshot.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // 规则:常驻层(soul/profile/explicit)永久全量;其余按“平面基准 + 使用加成 -
4
4
  // 时间衰减”排序,按名次分三档(全量正文 / 摘要 / 仅标题)。注入条数固定,
5
5
  // 所以库再大也不会撑爆上下文;没进快照的原文都还在,用检索取回。
6
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
6
+ import { mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs'
7
7
  import { dirname, join } from 'node:path'
8
8
 
9
9
  export const RESIDENT_PLANES = ['soul', 'profile', 'explicit']
@@ -67,14 +67,21 @@ export const DEFAULT_MANUAL = [
67
67
  "",
68
68
  "路径固定三步:**看快照 → 按话题检索 → 读命中正文**。快照里只有标题的,原文在库里。",
69
69
  "",
70
+ "**检索永远排在大范围搜索之前。** 找不到东西时的第一反应不能是扫全盘、`grep -r` 整个仓库、",
71
+ "或者凭印象猜一个答案——先问一句「这事以前是不是记过」,用 `aurorix_recall` 查一次。",
72
+ "记忆库里全是这个机器、这套代码、这类报错的既往结论;扫盘最贵,记忆最便宜,顺序不能颠倒。",
73
+ "记忆里确实没有、或者查到的已经过时,再去扫;扫完把结论写回库里,下次就不必再扫。",
74
+ "",
70
75
  "禁把这几种说法当跳过理由——它们都不成立:",
71
76
  "",
72
77
  "- 「这轮很简单」:简单轮正是踩重复坑最多的地方",
73
78
  "- 「刚聊过」:刚聊过的是当前上下文,不是历史结论",
74
79
  "- 「我应该记得」:记得的是印象,库里的是原文,两者冲突时以库为准",
75
80
  "- 「先做完再查」:查完再做,比做完再返工便宜",
81
+ "- 「先扫一遍再说」:扫盘是最后的检索手段,不是第一反应",
76
82
  "",
77
83
  "**做完一件有结论的事就顺手写一条**:不是因为用户要求,是因为下轮可能用得上。",
84
+ "宁可多写一条也不要让经验随会话消失——写错可以在库里改,没写的就永远没了。",
78
85
  "",
79
86
  "### 四个工具",
80
87
  "",
@@ -130,6 +137,8 @@ export const DEFAULT_PROTOCOL = `## 记忆库(Aurorix 原生绑定)
130
137
  **这一节是分层后的视图,不是全库。** 常驻层(soul / profile / explicit)永久全量;其余条目按重要度、最近使用和时间衰减排成三档:全量正文、摘要、仅标题。没进全量的条目原文都还在库里,用 \`aurorix_recall\` 按话题检索即可取回——标题档会列出所有可召回项,看到相关的就直接查。
131
138
 
132
139
  **读**:命中主题时先检索取记录 ID,再读正文;不要凭印象代替实读。
140
+ **先查记忆,再扫盘**:找不到东西时不要一上来就扫全盘、整个仓库、整个项目树——先检索记忆库,那里多半有既往结论。扫盘是最贵的检索,记忆是最便宜的,记忆里确实没有再去扫,扫完把结论写回库里。
141
+ **记不住的都该写**:做了决定(尤其排除了别的选项)、被用户纠正、踩坑查明根因、交付一个单元、发现库里某条过时——都属于该写的内容,写进库比留在上下文里可靠。
133
142
 
134
143
  **写**:用户说「记住 / 记下来」且内容是短小关键点时写 explicit;完整经过、根因、可复用结论写 long_term;单次事件与证据写 episodic。写完回读记录 ID。
135
144
 
@@ -250,6 +259,48 @@ export function resolveStatePath(explicit) {
250
259
  return join(home, 'cache', 'dsh-aurorix-agentbook', 'access.json')
251
260
  }
252
261
 
262
+ /**
263
+ * 库指纹:所有平面记录文件的「名字 + 大小 + 修改时间」滚成一个数。
264
+ *
265
+ * 用处是决定快照要不要重建。宿主拿到的新快照只要文本变了,就会往对话尾部追加一条
266
+ * 新消息,前缀缓存跟着失效;所以「库没变就不重建」比「每 15 秒重建一次」重要得多。
267
+ *
268
+ * 只 stat 不读内容:1200 多个文件约 20 毫秒,比调 abook 读全库(300 毫秒以上)便宜一个数量级。
269
+ * 指纹对不上才值得去读全文。
270
+ */
271
+ export function librarySignature(root) {
272
+ if (typeof root !== 'string' || root === '') return ''
273
+ let hash = 2166136261
274
+ let count = 0
275
+ for (const plane of [...RESIDENT_PLANES, ...DECAY_PLANES]) {
276
+ const dir = join(root, 'planes', plane, 'records')
277
+ let files
278
+ try {
279
+ files = readdirSync(dir)
280
+ } catch {
281
+ continue
282
+ }
283
+ files.sort()
284
+ for (const file of files) {
285
+ let stat
286
+ try {
287
+ stat = statSync(join(dir, file))
288
+ } catch {
289
+ continue
290
+ }
291
+ // FNV-1a:够散、够快、不需要 crypto,跨进程稳定。
292
+ hash ^= file.length
293
+ hash = Math.imul(hash, 16777619)
294
+ hash ^= stat.size
295
+ hash = Math.imul(hash, 16777619)
296
+ hash ^= Math.floor(stat.mtimeMs)
297
+ hash = Math.imul(hash, 16777619)
298
+ count++
299
+ }
300
+ }
301
+ return count === 0 ? '0:0' : `${count}:${hash >>> 0}`
302
+ }
303
+
253
304
  /**
254
305
  * 读全库并压成快照文本。
255
306
  * @param {(plane: string) => Promise<{ ok: boolean, items?: object[], reason?: string }>} listPlane
package/lib/view.js CHANGED
@@ -171,6 +171,18 @@ export function memoryView(state, caps = {}) {
171
171
  { type: 'text', text: b('vaultDraftNote'), tone: 'muted' },
172
172
  ] },
173
173
 
174
+ // 五、注入痕迹:这一轮到底往模型里放了什么。改了库、快照重建,这里会跟着变。
175
+ { type: 'divider', size: 'S' },
176
+ { type: 'collapsible', label: w.injectTitle, expanded: false, children: [
177
+ { type: 'text', text: b('inject.note'), tone: 'muted' },
178
+ { type: 'text', text: b('inject.stats'), tone: 'muted' },
179
+ { type: 'text', text: w.injectHint, tone: 'muted' },
180
+ { type: 'actions', items: [
181
+ { label: w.injectDetail, icon: 'document', action: 'inject-detail', style: 'plain' },
182
+ ] },
183
+ ] },
184
+
185
+ { type: 'divider', size: 'S' },
174
186
  { type: 'actions', items: [
175
187
  { label: w.retry, icon: 'refresh', action: 'reload', style: 'plain' },
176
188
  ] },
@@ -183,7 +195,14 @@ function detailView(state, caps) {
183
195
  const w = words(caps?.locale)
184
196
  const d = state.detail
185
197
  const isVault = d.kind === 'vault'
186
- const meta = isVault
198
+ // 注入全文是只读的:它不是库里的一条记录,不能编辑、也不该显示平面与记录 ID。
199
+ const isInject = d.kind === 'inject'
200
+ const meta = isInject
201
+ ? [
202
+ [w.injectTitle, w.injectOn],
203
+ [w.detailBytes, `${Number(d.bytes) || 0} B`],
204
+ ]
205
+ : isVault
187
206
  ? [
188
207
  [w.detailPurpose, d.purpose === '' ? '—' : clip(d.purpose, 160)],
189
208
  [w.detailBytes, `${Number(d.bytes) || 0} B`],
@@ -259,8 +278,8 @@ function detailView(state, caps) {
259
278
  { label: w.nextPage, action: 'detail-page-next', style: 'plain' },
260
279
  ] : []),
261
280
  { label: w.detailBack, action: 'detail-back', style: 'plain' },
262
- // 既然已经点进详情页,就该能就地改——不用退回去重写一条。
263
- ...(hasForm ? [{ label: w.detailEdit, icon: 'pencil', action: 'detail-edit', style: 'plain' }] : []),
281
+ // 既然已经点进详情页,就该能就地改——不用退回去重写一条。注入全文是只读的,不给编辑。
282
+ ...(hasForm && !isInject ? [{ label: w.detailEdit, icon: 'pencil', action: 'detail-edit', style: 'plain' }] : []),
264
283
  { label: w.detailCopy, icon: 'copy', action: 'detail-copy', style: 'primary' },
265
284
  ] })
266
285
 
@@ -361,7 +380,38 @@ export function memoryData(state, caps = {}) {
361
380
  body: state.vaultDraft?.body ?? '',
362
381
  },
363
382
  vaultDraftNote: state.vaultDraftNote ?? '',
383
+ inject: injectModel(state, caps),
384
+ }
385
+ }
386
+
387
+ /**
388
+ * 注入痕迹:把「这一轮往模型里放了什么」变成面板能看到的东西。
389
+ *
390
+ * 只放摘要,不放正文:面板数据上限 32 KB,塞 25 KB 快照全文会把整份数据顶爆,
391
+ * 宿主直接拒收,面板就变成一条数据都没有——那正是「没有及时响应」的真实成因。
392
+ * 全文要看的话走 detail-inject 动作单独取。
393
+ */
394
+ function injectModel(state, caps) {
395
+ const w = words(caps?.locale)
396
+ const info = state.inject
397
+ if (info === undefined || info === null || info.enabled !== true) {
398
+ return { on: false, note: w.injectOff, stats: '', tone: 'muted' }
399
+ }
400
+ const bytes = Number(info.bytes) || 0
401
+ const stats = info.stats
402
+ ? w.injectStats(info.stats.resident, info.stats.full, info.stats.brief, info.stats.index)
403
+ : ''
404
+ if (bytes === 0) {
405
+ return { on: true, note: info.error ? `${w.injectOff}:${info.error}` : w.injectNever, stats, tone: info.error ? 'warn' : 'muted' }
364
406
  }
407
+ const kb = Math.max(1, Math.round(bytes / 1024))
408
+ const age = info.ageSeconds === undefined || info.ageSeconds === null
409
+ ? ''
410
+ : w.injectAge(Number(info.ageSeconds) || 0)
411
+ // 库有没有变:变了下一轮会重建,这是最值得看的一件事。
412
+ const drift = info.changed === true ? w.injectChanged : w.injectSame
413
+ const note = [w.injectOn, `${kb} KB`, age, drift].filter((x) => x !== '').join(' · ')
414
+ return { on: true, kb, note, stats, changed: info.changed === true, tone: info.changed === true ? 'info' : 'muted' }
365
415
  }
366
416
 
367
417
  const hitCountOf = (state) => (Array.isArray(state.hits) ? state.hits.length : 0)
package/lib/words.js CHANGED
@@ -36,6 +36,22 @@ export const WORDS = {
36
36
  unavailableMessage: '确认记忆库装在这台设备上,路径通常是 ~/AgentsBook/abook。',
37
37
  stripText: (total, planes) => `记忆 ${total} 条 · ${planes} 个平面`,
38
38
  stripUnknown: '记忆库读不到',
39
+
40
+ // 注入痕迹:给用户看「这一轮到底往模型里放了什么」
41
+ injectTitle: '本机注入',
42
+ injectOn: '正在注入',
43
+ injectOff: '未启用注入',
44
+ injectSize: (kb, tier) => `${kb} KB · ${tier}`,
45
+ injectStats: (resident, full, brief, index) => `常驻 ${resident} · 全量 ${full} · 摘要 ${brief} · 索引 ${index}`,
46
+ injectAge: (seconds) => seconds < 60 ? `${seconds} 秒前` : `${Math.round(seconds / 60)} 分钟前`,
47
+ injectNever: '还没构建过快照',
48
+ injectChanged: '库有变化,下一轮会重建',
49
+ injectSame: '库无变化,复用同一份快照',
50
+ injectRefresh: '立即重建',
51
+ injectCopied: '已复制本份注入全文',
52
+ injectDetail: '查看注入全文',
53
+ injectHint: '这份内容作为对话尾部的一条快照消息送给模型,不进系统提示词前缀;内容没变就不会追加新消息,缓存不会被顶掉。',
54
+ injectNoteOnTurn: (kb) => `记忆注入 ${kb} KB`,
39
55
  copied: '已复制',
40
56
  copy: '复制正文',
41
57
  detail: '正文',
@@ -148,6 +164,21 @@ export const WORDS = {
148
164
  unavailableMessage: 'Make sure the memory store is installed, usually ~/AgentsBook/abook.',
149
165
  stripText: (total, planes) => `Memory ${total} · ${planes} planes`,
150
166
  stripUnknown: 'Memory unreadable',
167
+
168
+ injectTitle: 'Injected',
169
+ injectOn: 'Injecting',
170
+ injectOff: 'Injection off',
171
+ injectSize: (kb, tier) => `${kb} KB · ${tier}`,
172
+ injectStats: (resident, full, brief, index) => `resident ${resident} · full ${full} · brief ${brief} · index ${index}`,
173
+ injectAge: (seconds) => seconds < 60 ? `${seconds}s ago` : `${Math.round(seconds / 60)}m ago`,
174
+ injectNever: 'No snapshot built yet',
175
+ injectChanged: 'Library changed, rebuilds next turn',
176
+ injectSame: 'Library unchanged, same snapshot reused',
177
+ injectRefresh: 'Rebuild now',
178
+ injectCopied: 'Snapshot copied',
179
+ injectDetail: 'View full snapshot',
180
+ injectHint: 'This goes to the model as one snapshot message at the tail of the conversation, not into the system prefix; an unchanged snapshot adds no message, so the cache survives.',
181
+ injectNoteOnTurn: (kb) => `Memory ${kb} KB`,
151
182
  copied: 'Copied',
152
183
  copy: 'Copy body',
153
184
  detail: 'Body',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aurorix-agentbook",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "dsh-aurorix-agentbook:给 dsh-go 与 Harness Web 接通 Aurorix 记忆库——原生界面(状态条/胶囊/菜单/面板/保险箱)与 Web 顶栏槽位面板,加宿主侧提示词注入、分层快照与八个工具。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -72,6 +72,11 @@
72
72
  ],
73
73
  "presentation": "sheet"
74
74
  }
75
+ ],
76
+ "turn.note": [
77
+ {
78
+ "id": "memory-inject"
79
+ }
75
80
  ]
76
81
  }
77
82
  },