dsh-aurorix-agentbook 1.9.5 → 1.9.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.
package/lib/host.js CHANGED
@@ -73,19 +73,16 @@ function readConfig(config) {
73
73
  enabled: get('enabled', true),
74
74
  injectSection: get('injectSection', false),
75
75
  injectSnapshot: get('injectSnapshot', true),
76
- // 这几个数字是「每轮重发的内容规模」。快照随每轮请求重发,体积直接乘以轮数,
77
- // 所以它们同时是费用上限和信息完整度两件事。
76
+ // 常驻层(soul / profile / explicit)给全量正文,下三层只给标题索引。
78
77
  //
79
- // 体积该省的地方是「同一件事说两遍」和「历史里堆副本」,不是记忆本身:
80
- // 曾经试过把规模砍小来省字节,砍掉的直接是硬规则正文——rules 平面摘要
81
- // 要把具体标识符与阈值带出来才能执行,只留标题等于删内容。实测完整内容
82
- // 68.7KB 装得下,就不该为了好看的数字去截断。
83
- // 这几个值沿用 1.9.3,没有下调。
84
- fullCount: Number(get('fullCount', 6)) || 0,
85
- briefCount: Number(get('briefCount', 12)) || 0,
86
- indexCount: Number(get('indexCount', 120)) || 0,
78
+ // 体积不从这里省:标题索引是「知道库里有什么」的入口,正文一律走检索。
79
+ // 曾经为了省字节把下三层压成摘要档甚至只留标题,前者等于把同一件事说半遍、
80
+ // 真正要正文时还得 recall;后者在 rules 上会删掉执行必需的标识符。现在
81
+ // 结构上就没有摘要档——要么常驻层全量,要么标题。
87
82
  residentLimit: Number(get('residentLimit', 40)) || 40,
88
- briefChars: Number(get('briefChars', 110)) || 110,
83
+ // 0 = 全部标题。下三层 538 条标题共约 37KB,全给也就这么多;截断反而让
84
+ // 模型以为「库里没有这条」而漏检索。
85
+ indexCount: Number(get('indexCount', 0)),
89
86
  decayHalfLifeDays: Number(get('decayHalfLifeDays', 30)),
90
87
  accessBoost: Number(get('accessBoost', 80)),
91
88
  maxContextBytes: Number(get('maxContextBytes', 96000)) || 96000,
@@ -154,11 +151,8 @@ export function attachHost(ctx, deps) {
154
151
  const doRefresh = async (current) => {
155
152
  try {
156
153
  const built = await buildSnapshot((plane) => backend.list(plane, { limit: 2000, full: true }), {
157
- fullCount: current.fullCount,
158
- briefCount: current.briefCount,
159
154
  indexCount: current.indexCount,
160
155
  residentLimit: current.residentLimit,
161
- briefChars: current.briefChars,
162
156
  decayHalfLifeDays: current.decayHalfLifeDays,
163
157
  accessBoost: current.accessBoost,
164
158
  maxContextBytes: current.maxContextBytes,
@@ -305,7 +299,11 @@ export function attachHost(ctx, deps) {
305
299
  '- 上下文被压缩过,或这是跨会话续接\n' +
306
300
  '- 准备写记忆之前(先查有没有同一条,避免重复开新条)\n' +
307
301
  '禁把「这轮简单」「刚聊过」「我应该记得」当跳过理由:漏查的代价是重复踩坑,查一次的代价是一次工具调用。\n' +
308
- '检索词用话题词,不要用整句;推荐先广后窄:先一个词看面上有什么,再收窄。',
302
+ '检索词用话题词,不要用整句;推荐先广后窄:先一个词看面上有什么,再收窄。\n' +
303
+ '\n' +
304
+ '注入的快照里下三层(rules / long_term / episodic)只有标题,正文不注入。\n' +
305
+ '看到相关标题后要正文,用 `aurorix_abook` 按 ID 取:`["memory","read","--id","<id>","--json"]`。\n' +
306
+ '本工具返回的 preview 只截前 220 字,够判断是不是这条,不够当正文用。',
309
307
  parameters: {
310
308
  type: 'object',
311
309
  properties: {
package/lib/snapshot.js CHANGED
@@ -21,11 +21,6 @@ const PLANE_LABEL = {
21
21
  // 排序基准:身份/规则/偏好在最前,经验其次,过程记录最轻。
22
22
  const PLANE_BASE = { soul: 1000, rules: 900, profile: 800, explicit: 700, long_term: 300, episodic: 120 }
23
23
 
24
- // 约束类永不完全淡出:最低保到摘要档,避免规则被排到只剩标题。
25
- const PLANE_FLOOR = { rules: 'brief' }
26
-
27
- const TIER_ORDER = { index: 0, brief: 1, full: 2 }
28
-
29
24
  // 每步注入的记忆说明:只在装了本插件的环境里出现。
30
25
  // 系统提示词里不再提记忆——没装插件的环境本就没有这个能力,不该被暗示。
31
26
  //
@@ -146,28 +141,6 @@ function scoreOf(record, access, now, halfLifeDays, accessBoost) {
146
141
  return base + boost - decay
147
142
  }
148
143
 
149
- // 各平面摘要长度:给足能认出「是不是这条」的上下文。
150
- // 曾经按 rules 标题已足够概括为由只列标题,结果把执行时必需的标识符删了——
151
- // 「记忆机制分类与固定黑名单」这个标题看不到 `ENVIRONMENT_MEMORY` /
152
- // `AURORIX_MEMORY` 两个分类名。体积不从记忆内容里省。
153
- const BRIEF_CHARS_BY_PLANE = {}
154
-
155
- function renderTier(record, tier, briefChars) {
156
- const limit = BRIEF_CHARS_BY_PLANE[record.plane] ?? briefChars
157
- const title = record.title || '(无标题)'
158
- const content = String(record.content || '').trim()
159
- if (tier === 'full') return `- 【${title}】${content}`
160
- if (tier === 'brief') {
161
- // 限额为 0:标题即摘要。不附正文,也不附结构目录(同一个道理,标题已经说明是什么)。
162
- if (limit <= 0) return `- ${title}`
163
- const gist = gistOf(content, limit)
164
- const heads = headingsOf(content)
165
- const structure = heads.length > 1 ? `\n └ ${heads.slice(0, 5).join(' / ')}` : ''
166
- return `- 【${title}】${gist}${structure}`
167
- }
168
- return title
169
- }
170
-
171
144
  /** 热度状态:记录哪个 ID 被真正用过。只影响排序,不影响库。 */
172
145
  export function createAccessStore(statePath) {
173
146
  let store = { version: 1, records: {} }
@@ -276,11 +249,8 @@ export function librarySignature(root) {
276
249
  */
277
250
  export async function buildSnapshot(listPlane, options = {}) {
278
251
  const {
279
- fullCount = 6,
280
- briefCount = 12,
281
- indexCount = 120,
252
+ indexCount = 0, // 0 = 全部标题,不截断
282
253
  residentLimit = 40,
283
- briefChars = 140,
284
254
  decayHalfLifeDays = 30,
285
255
  accessBoost = 80,
286
256
  access = { records: () => ({}) },
@@ -307,6 +277,7 @@ export async function buildSnapshot(listPlane, options = {}) {
307
277
  const accessMap = access.records()
308
278
  const now = Math.floor(Date.now() / 1000)
309
279
 
280
+ // 常驻层:全量正文。这几层是身份、画像和用户明确交代的短要点,每轮都该看得见全文。
310
281
  const resident = RESIDENT_PLANES.map((plane) => {
311
282
  const rows = records.filter((r) => r.plane === plane).slice(0, residentLimit)
312
283
  if (rows.length === 0) return ''
@@ -314,6 +285,12 @@ export async function buildSnapshot(listPlane, options = {}) {
314
285
  return `**${PLANE_LABEL[plane]}**(${rows.length} 条)\n${body}`
315
286
  }).filter(Boolean).join('\n\n')
316
287
 
288
+ // 下三层:只给标题索引,一条正文都不注入。
289
+ //
290
+ // 之前把这里做成「前几条全量 + 一批摘要 + 其余标题」的三档,摘要档吃掉 26.9KB,
291
+ // 而摘要的价值很低——标题本来就说清了「这条讲什么」,摘要只是把同一件事再说半遍;
292
+ // 真正要正文的时候一定会去 recall,注入的摘要在那一刻也用不上。
293
+ // 只留标题后:体积降下来,语义也干净——注入负责「知道有什么」,检索负责「读什么」。
317
294
  const decay = records
318
295
  .filter((r) => DECAY_PLANES.includes(r.plane))
319
296
  .map((r) => ({ record: r, score: scoreOf(r, accessMap[r.id], now, decayHalfLifeDays, accessBoost) }))
@@ -321,40 +298,18 @@ export async function buildSnapshot(listPlane, options = {}) {
321
298
  // 而输入顺序一变快照就变、又会让上下文多一份副本。ID 是稳定的。
322
299
  .sort((a, b) => b.score - a.score || String(a.record.id).localeCompare(String(b.record.id)))
323
300
 
324
- const tiers = new Map()
325
- decay.forEach((entry, index) => {
326
- let tier = index < fullCount ? 'full' : index < fullCount + briefCount ? 'brief' : 'index'
327
- const floor = PLANE_FLOOR[entry.record.plane]
328
- if (floor && TIER_ORDER[tier] < TIER_ORDER[floor]) tier = floor
329
- tiers.set(entry.record.id, tier)
330
- })
331
-
332
- const fullRows = []
333
- const briefByPlane = new Map()
334
301
  const indexByPlane = new Map()
335
302
  for (const entry of decay) {
336
- const tier = tiers.get(entry.record.id)
337
303
  const record = entry.record
338
- if (tier === 'full') fullRows.push(renderTier(record, 'full', briefChars))
339
- else if (tier === 'brief') {
340
- if (!briefByPlane.has(record.plane)) briefByPlane.set(record.plane, [])
341
- briefByPlane.get(record.plane).push(renderTier(record, 'brief', briefChars))
342
- } else {
343
- if (!indexByPlane.has(record.plane)) indexByPlane.set(record.plane, [])
344
- indexByPlane.get(record.plane).push(record.title || '(无标题)')
345
- }
304
+ if (!indexByPlane.has(record.plane)) indexByPlane.set(record.plane, [])
305
+ indexByPlane.get(record.plane).push(record.title || '(无标题)')
346
306
  }
347
307
 
348
- const briefBlock = DECAY_PLANES
349
- .filter((plane) => briefByPlane.has(plane))
350
- .map((plane) => `**${PLANE_LABEL[plane]}**\n${briefByPlane.get(plane).join('\n')}`)
351
- .join('\n\n')
352
-
353
308
  const indexBlock = DECAY_PLANES
354
309
  .filter((plane) => indexByPlane.has(plane))
355
310
  .map((plane) => {
356
311
  const titles = indexByPlane.get(plane)
357
- const shown = titles.slice(0, indexCount)
312
+ const shown = indexCount > 0 ? titles.slice(0, indexCount) : titles
358
313
  const rest = titles.length - shown.length
359
314
  return `**${PLANE_LABEL[plane]}**(${titles.length} 条):${shown.join(' | ')}${rest > 0 ? ` …另有 ${rest} 条` : ''}`
360
315
  })
@@ -363,11 +318,7 @@ export async function buildSnapshot(listPlane, options = {}) {
363
318
  const parts = [
364
319
  '### 常驻层(永久全量:soul / profile / explicit)',
365
320
  resident,
366
- fullRows.length ? '### 活跃记忆(全量正文)' : '',
367
- fullRows.join('\n'),
368
- briefBlock ? '### 摘要(原文在库里,需要细节就检索)' : '',
369
- briefBlock,
370
- indexBlock ? '### 可召回索引(仅标题,用 aurorix_recall 取正文)' : '',
321
+ indexBlock ? '### 可召回索引(仅标题;正文用 aurorix_abook ["memory","read","--id","<id>","--json"] 取)' : '',
371
322
  indexBlock,
372
323
  ].filter((part) => part && part.length > 0)
373
324
 
@@ -376,9 +327,7 @@ export async function buildSnapshot(listPlane, options = {}) {
376
327
  stats: {
377
328
  total: records.length,
378
329
  resident: records.filter((r) => RESIDENT_PLANES.includes(r.plane)).length,
379
- full: fullRows.length,
380
- brief: [...tiers.values()].filter((t) => t === 'brief').length,
381
- index: [...tiers.values()].filter((t) => t === 'index').length,
330
+ index: records.filter((r) => DECAY_PLANES.includes(r.plane)).length,
382
331
  },
383
332
  }
384
333
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aurorix-agentbook",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "description": "dsh-aurorix-agentbook:给 dsh-go 与 Harness Web 接通 Aurorix 记忆库——原生界面(状态条/胶囊/菜单/面板/保险箱)与 Web 顶栏槽位面板,加宿主侧提示词注入、分层快照与八个工具。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",