dsh-aurorix-agentbook 1.10.0 → 1.10.1

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 (2) hide show
  1. package/lib/snapshot.js +46 -34
  2. package/package.json +1 -1
package/lib/snapshot.js CHANGED
@@ -23,6 +23,13 @@ const PLANE_LABEL = {
23
23
  episodic: 'episodic 事件与过程',
24
24
  }
25
25
 
26
+ // 下三层各自的索引渲染方式。
27
+ //
28
+ // rules 是规则类:标题就是规则的索引名,折叠成锚点词会让人看不出是哪几条规则,
29
+ // 等于把硬约束藏进一个词后面。所以规则永远纯标题,逐条列出。
30
+ // 另外两层是经验与过程记录,按主题折叠收益最大。
31
+ const PLANE_INDEX_MODE = { rules: 'titles', long_term: 'cluster', episodic: 'cluster' }
32
+
26
33
  // 排序基准:身份/规则/偏好在最前,经验其次,过程记录最轻。
27
34
  const PLANE_BASE = { soul: 1000, rules: 900, profile: 800, explicit: 700, long_term: 300, episodic: 120 }
28
35
 
@@ -462,47 +469,52 @@ export async function buildSnapshot(listPlane, options = {}) {
462
469
  // 而输入顺序一变快照就变、又会让上下文多一份副本。ID 是稳定的。
463
470
  .sort((a, b) => b.score - a.score || String(a.record.id).localeCompare(String(b.record.id)))
464
471
 
465
- // 按平面归集,并把可验证的主题簇折叠成「锚点词×条数」。
466
- const indexByPlane = new Map()
472
+ // 按平面分别渲染索引。
473
+ //
474
+ // 每个平面怎么渲染由 PLANE_INDEX_MODE 决定,不是一刀切:
475
+ // - rules 是「规则类」,规则标题本身就是规则的索引,折叠成 `aurorix×3`
476
+ // 会让人看不出是哪三条规则——等于把硬约束藏起来。所以规则一律纯标题。
477
+ // - long_term / episodic 是经验与过程记录,按主题折叠收益最大,用锚点词。
478
+ //
479
+ // 分组全部在构建时算出来,不落库、不依赖谁事先预处理:同一份库每次算出的
480
+ // 结果都一样,新增一条记录下一次构建就自动归进对应主题。
467
481
  let foldedTotal = 0
468
482
  const clusterLines = []
469
- if (cluster && typeof probeAnchor === 'function') {
470
- const perPlane = new Map()
471
- for (const entry of decay) {
472
- const plane = entry.record.plane
473
- if (!perPlane.has(plane)) perPlane.set(plane, [])
474
- perPlane.get(plane).push(entry.record)
475
- }
476
- for (const plane of DECAY_PLANES) {
477
- const rows = perPlane.get(plane) || []
478
- if (rows.length === 0) continue
479
- const { clusters, ownerOf, folded } = await clusterTitles(rows, probeAnchor)
480
- foldedTotal += folded
481
- const rest = rows.filter((r) => !ownerOf.has(r.id)).map((r) => r.title || '(无标题)')
482
- const shownRest = indexCount > 0 ? rest.slice(0, indexCount) : rest
483
- const restNote = rest.length - shownRest.length
484
- const head = `**${PLANE_LABEL[plane]}**(${rows.length} 条`
485
- const clusterNote = clusters.length
486
- ? `;${clusters.map((c) => `${c.anchor}×${c.count}`).join(' ')} 可用锚点词检索取回`
487
- : ''
488
- const body = shownRest.length ? `:${shownRest.join(' | ')}` : ''
489
- const tail = restNote > 0 ? ` …另有 ${restNote} 条` : ''
490
- clusterLines.push(`${head}${clusterNote})${body}${tail}`)
491
- }
492
- } else {
493
- for (const entry of decay) {
494
- const plane = entry.record.plane
495
- if (!indexByPlane.has(plane)) indexByPlane.set(plane, [])
496
- indexByPlane.get(plane).push(entry.record.title || '(无标题)')
497
- }
498
- for (const plane of DECAY_PLANES) {
499
- const titles = indexByPlane.get(plane)
500
- if (!titles) continue
483
+ const perPlane = new Map()
484
+ for (const entry of decay) {
485
+ const plane = entry.record.plane
486
+ if (!perPlane.has(plane)) perPlane.set(plane, [])
487
+ perPlane.get(plane).push(entry.record)
488
+ }
489
+
490
+ for (const plane of DECAY_PLANES) {
491
+ const rows = perPlane.get(plane) || []
492
+ if (rows.length === 0) continue
493
+ const mode = PLANE_INDEX_MODE[plane] || 'cluster'
494
+ const wantCluster = cluster && mode === 'cluster' && typeof probeAnchor === 'function'
495
+
496
+ if (!wantCluster) {
497
+ const titles = rows.map((r) => r.title || '(无标题)')
501
498
  const shown = indexCount > 0 ? titles.slice(0, indexCount) : titles
502
499
  const rest = titles.length - shown.length
503
500
  clusterLines.push(`**${PLANE_LABEL[plane]}**(${titles.length} 条):${shown.join(' | ')}${rest > 0 ? ` …另有 ${rest} 条` : ''}`)
501
+ continue
504
502
  }
503
+
504
+ const { clusters, ownerOf, folded } = await clusterTitles(rows, probeAnchor)
505
+ foldedTotal += folded
506
+ // 未成簇的条目按原排序列出;它们没有可靠的检索锚点,必须逐条给标题。
507
+ const rest = rows.filter((r) => !ownerOf.has(r.id)).map((r) => r.title || '(无标题)')
508
+ const shownRest = indexCount > 0 ? rest.slice(0, indexCount) : rest
509
+ const restNote = rest.length - shownRest.length
510
+ const clusterNote = clusters.length
511
+ ? `;主题簇 ${clusters.map((c) => `${c.anchor}×${c.count}`).join(' ')}(用该词检索可取回)`
512
+ : ''
513
+ const body = shownRest.length ? `:${shownRest.join(' | ')}` : ''
514
+ const tail = restNote > 0 ? ` …另有 ${restNote} 条` : ''
515
+ clusterLines.push(`**${PLANE_LABEL[plane]}**(${rows.length} 条${clusterNote})${body}${tail}`)
505
516
  }
517
+
506
518
  const indexBlock = clusterLines.join('\n')
507
519
 
508
520
  const parts = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aurorix-agentbook",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "dsh-aurorix-agentbook:给 dsh-go 与 Harness Web 接通 Aurorix 记忆库——原生界面(状态条/胶囊/菜单/面板/保险箱)与 Web 顶栏槽位面板,加宿主侧提示词注入、分层快照与八个工具。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",