@yolk_vat-y/dsh-project-memory 0.6.3 → 0.6.4
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/CHANGELOG.md +140 -8
- package/README.md +26 -23
- package/README.zh-CN.md +24 -21
- package/client/client.js +272 -138
- package/client/client.js.map +1 -1
- package/package.json +3 -2
- package/scripts/bench-synthetic.mjs +22 -11
- package/src/audit.js +36 -32
- package/src/auto-inject.js +44 -23
- package/src/client/MemoryView.tsx +72 -4
- package/src/client/ShowTaskPanelNode.tsx +8 -5
- package/src/client/TaskCommandNode.tsx +22 -17
- package/src/client/TaskComponents.tsx +18 -3
- package/src/client/TaskPanel.tsx +50 -85
- package/src/client/client.ts +26 -6
- package/src/client/commands.ts +67 -0
- package/src/client/task-ui-store.ts +15 -2
- package/src/commands/task-actions.js +56 -2
- package/src/index.js +12 -0
- package/src/insight-store.js +200 -78
- package/src/lazy.js +3 -1
- package/src/ops.js +1 -1
- package/src/readiness.js +1 -1
- package/src/recall.js +76 -30
- package/src/setup/taskbridge.js +34 -3
- package/src/store.js +315 -44
- package/src/tools/forget.js +11 -8
- package/src/tools/index-doc.js +3 -5
- package/src/tools/index-repo.js +10 -11
- package/src/tools/lesson-tools.js +25 -35
- package/src/tools/query-memory.js +81 -28
- package/src/tools/remember.js +14 -11
- package/src/tools/stats.js +26 -3
- package/src/tools/task-tools.js +11 -12
- package/src/tools/watch-repo.js +3 -5
- package/src/types.js +9 -4
- package/src/util/fs.js +128 -1
- package/src/util/search.js +6 -27
- package/src/vector-index.js +175 -22
- package/src/watch.js +2 -2
package/src/insight-store.js
CHANGED
|
@@ -10,7 +10,7 @@ import { readFileSync, renameSync } from 'node:fs'
|
|
|
10
10
|
import path from 'node:path'
|
|
11
11
|
import os from 'node:os'
|
|
12
12
|
import { normalizedTokenOverlap, findBestOverlapMatch, insightMatchText } from './similarity.js'
|
|
13
|
-
import { writeJsonAtomic } from './util/fs.js'
|
|
13
|
+
import { acquireDirLock, writeJsonAtomic } from './util/fs.js'
|
|
14
14
|
import { backfillDerivedTriggers } from './readiness.js'
|
|
15
15
|
import { vectorText } from './vector-index.js'
|
|
16
16
|
import { tokenize } from './util/search.js'
|
|
@@ -30,7 +30,7 @@ export const SECRET_PATTERNS = [
|
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
/** 检测疑似密钥/token/私钥形态内容;命中返回第一个命中字段名,否则 null。 */
|
|
33
|
-
export function containsSecretFields(ins, fields = ['title', 'body', 'pattern', 'fix', 'problem', 'solution', 'choice', 'reason']) {
|
|
33
|
+
export function containsSecretFields(ins, fields = ['title', 'body', 'pattern', 'fix', 'problem', 'solution', 'choice', 'reason', 'steps']) {
|
|
34
34
|
for (const f of fields) {
|
|
35
35
|
const v = ins && ins[f]
|
|
36
36
|
if (!v) continue
|
|
@@ -44,6 +44,13 @@ function num(v, d) {
|
|
|
44
44
|
return typeof v === 'number' && Number.isFinite(v) ? v : d
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** 两个 ISO 时间戳的先后;缺失/非法一律 0。 */
|
|
48
|
+
function newerIso(a, b) {
|
|
49
|
+
const ta = Date.parse(a || '') || 0
|
|
50
|
+
const tb = Date.parse(b || '') || 0
|
|
51
|
+
return ta - tb
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
/** 合并配置(config.insight 之上补默认)。 */
|
|
48
55
|
export function cfgInsight(config) {
|
|
49
56
|
const c = (config && config.insight) || {}
|
|
@@ -51,11 +58,13 @@ export function cfgInsight(config) {
|
|
|
51
58
|
dedupOverlap: num(c.dedupOverlap, 0.7),
|
|
52
59
|
reinforceBand: num(c.reinforceBand, 0.65),
|
|
53
60
|
// 向量带(需要 leanvec;没装就自动退化成上面的纯词法带)。阈值由真实 store 标定:
|
|
54
|
-
// 47 条 live 条目、1081 对的余弦 max=0.655 / p99=0.531
|
|
61
|
+
// 47 条 live 条目、1081 对的余弦 max=0.655 / p99=0.531;一个本地小模型把同一条知识改写后与
|
|
55
62
|
// 原文的余弦 min=0.688 / p50=0.809。所以:
|
|
56
63
|
// · 0.90 自动覆盖 —— 落在负样本之上 0.245,只会命中逐字级再记录("非常非常相似");
|
|
57
64
|
// · 0.70 提示 —— 在全部 1081 对真实条目上零噪声,而改写后的再记录有 78% 落进来。
|
|
58
65
|
// 0.65 会开始误伤真实条目(1/1081),别往下调:提示是往上下文里加字的。
|
|
66
|
+
// **0 = 关闭**那条带(与仓库其它旋钮一致):`top1 >= 0` 恒真,旧写法把 0 当"总是合并/
|
|
67
|
+
// 总是提示",而用户关掉它的最自然写法恰好就是 0。
|
|
59
68
|
autoMergeCos: num(c.autoMergeCos, 0.9),
|
|
60
69
|
// 自动覆盖还要求"第一名明显领先第二名",否则同一话题撞两条时不知道该覆盖谁。
|
|
61
70
|
autoMergeMargin: num(c.autoMergeMargin, 0.05),
|
|
@@ -97,7 +106,11 @@ export function normalizeInsight(raw, extra = {}) {
|
|
|
97
106
|
id: extra.id || makeInsightId(),
|
|
98
107
|
kind,
|
|
99
108
|
scope: extra.scope || 'project',
|
|
100
|
-
|
|
109
|
+
// 标题推导必须覆盖 `save_lesson` 允许的三种最小输入(title / pattern / choice):少了
|
|
110
|
+
// `choice`,只给 choice 的 decision 会落成 `(untitled)` —— 面板、召回、向量索引三处看到的
|
|
111
|
+
// 都是这个占位符,而唯一能认出它的字段反而不在标题里。顺序与 `vectorText` 的兜底链一致:
|
|
112
|
+
// 写入侧的向量比对文本也走这里(raw → 落盘 title),两边不同源就会在写路径上静默失效。
|
|
113
|
+
title: String(raw.title || raw.pattern || raw.problem || raw.choice || raw.topic || '(untitled)').slice(0, 200),
|
|
101
114
|
source: extra.source || raw.source || 'agent',
|
|
102
115
|
draft: raw.draft === true || extra.draft === true,
|
|
103
116
|
confidence: num(raw.confidence, num(extra.confidence, 0.8)),
|
|
@@ -259,6 +272,9 @@ export function applyUpdate(item, raw, nowIso) {
|
|
|
259
272
|
}
|
|
260
273
|
item.updatedAt = now
|
|
261
274
|
if (item.archived) item.archived = false
|
|
275
|
+
// 显式编辑一条草稿 = 作者确认:不再要求先开面板点“确认”。reflection 产出的 draft
|
|
276
|
+
// 因此可以被 save_lesson 带 id 直接改正文并转正;没有字段变化时也至少完成确认。
|
|
277
|
+
if (item.draft === true) item.draft = false
|
|
262
278
|
return replaced
|
|
263
279
|
}
|
|
264
280
|
|
|
@@ -284,10 +300,17 @@ export function vectorNear(text, items, cosine) {
|
|
|
284
300
|
let top1 = -1
|
|
285
301
|
let top2 = -1
|
|
286
302
|
let item = null
|
|
303
|
+
// 池内分布:给"绝对阈值"做本语料的陈规定标(见 autoMergeTarget)。n ≤ 300,顺路算完。
|
|
304
|
+
let n = 0
|
|
305
|
+
let sum = 0
|
|
306
|
+
let sumSq = 0
|
|
287
307
|
for (const it of items) {
|
|
288
308
|
if (!it || it.archived) continue
|
|
289
309
|
const v = m.get(it.id)
|
|
290
310
|
if (typeof v !== 'number' || !Number.isFinite(v)) continue
|
|
311
|
+
n++
|
|
312
|
+
sum += v
|
|
313
|
+
sumSq += v * v
|
|
291
314
|
if (v > top1) {
|
|
292
315
|
top2 = top1
|
|
293
316
|
top1 = v
|
|
@@ -295,18 +318,47 @@ export function vectorNear(text, items, cosine) {
|
|
|
295
318
|
} else if (v > top2) top2 = v
|
|
296
319
|
}
|
|
297
320
|
if (!item) return null
|
|
298
|
-
|
|
321
|
+
// 分布必须**排除候选自己**:top1 本身就是待检验的那个值,把它算进 μ/σ 会把自己的极端值
|
|
322
|
+
// 摊进方差里(稀疏池里一条 0.92 + 三条 0.2 会把 σ 抬到 0.33,阈值冲上 1 以上,于是永远不合并)。
|
|
323
|
+
// 排除之后 μ/σ 描述的是"池子里随机一条与这段文本有多像"——那才是零假设。
|
|
324
|
+
const restN = n - 1
|
|
325
|
+
const restSum = sum - top1
|
|
326
|
+
const restSumSq = sumSq - top1 * top1
|
|
327
|
+
const mu = restN > 0 ? restSum / restN : 0
|
|
328
|
+
const sigma = restN > 1 ? Math.sqrt(Math.max(0, restSumSq / restN - mu * mu)) : 0
|
|
329
|
+
return { item, top1, top2: top2 < 0 ? 0 : top2, mu, sigma, n }
|
|
299
330
|
}
|
|
300
331
|
|
|
301
|
-
/** 近邻是否够"较高"
|
|
332
|
+
/** 近邻是否够"较高"(提示带);`hintCos <= 0` = 关闭该带。够就返回给调用方回报的形状。 */
|
|
302
333
|
function hintOf(near, cfg) {
|
|
303
|
-
if (!near || near.top1 < cfg.hintCos) return null
|
|
334
|
+
if (!near || !(cfg.hintCos > 0) || near.top1 < cfg.hintCos) return null
|
|
304
335
|
return { id: near.item.id, cos: Number(near.top1.toFixed(3)), title: String(near.item.title || '').slice(0, 40) }
|
|
305
336
|
}
|
|
306
337
|
|
|
307
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* 自动覆盖的"池内相对"系数:题面余弦要同时高于 `μ + k·σ`。
|
|
340
|
+
*
|
|
341
|
+
* 为什么需要:0.9 这个绝对阈值只在**当前语料 + 当前模型**下安全。两种漂移会把它推过界,
|
|
342
|
+
* 而这条带是**破坏性写入**(改写既有条目的正文):
|
|
343
|
+
* · 语料模板化——同一句式的大量条目("修复 X 页脚")会把"最近邻余弦"整体抬到 0.9 附近;
|
|
344
|
+
* · 换模型/换表——同一对文本的余弦尺度整体平移。
|
|
345
|
+
* 取 `max(autoMergeCos, μ + k·σ)` 只可能**收紧**、绝不会放宽:当前真实 store(122 条、
|
|
346
|
+
* 7381 对)的余弦 mean=0.281 / sd=0.104 → μ+3σ ≈ 0.59 < 0.9,行为逐字段不变。
|
|
347
|
+
*
|
|
348
|
+
* k 不是调参项而是零假设的分位数:池子 ≤300 时,"随机撞上"的最大余弦 ≈ μ + 2.9σ
|
|
349
|
+
* (n 次抽样的极值分布),取 3 即"显著高于随机"的边界。k 再大就会在密集语料上退化成
|
|
350
|
+
* "永不自动覆盖"(μ+5σ 在 μ≥0.5 时就已越过 1),k 再小则会开始命中噪声。
|
|
351
|
+
*/
|
|
352
|
+
const AUTO_MERGE_SIGMA = 3
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 自动覆盖判定:够高**且**第一名明显领先第二名(否则不知道该覆盖谁);`autoMergeCos <= 0` = 关闭。
|
|
356
|
+
* 高度门槛取"绝对下限"与"池内 μ+k·σ"的较大者(只收紧不放宽,见 {@link AUTO_MERGE_SIGMA})。
|
|
357
|
+
*/
|
|
308
358
|
function autoMergeTarget(near, cfg) {
|
|
309
|
-
if (!near ||
|
|
359
|
+
if (!near || !(cfg.autoMergeCos > 0)) return null
|
|
360
|
+
const floor = Math.max(cfg.autoMergeCos, near.mu + AUTO_MERGE_SIGMA * near.sigma)
|
|
361
|
+
if (near.top1 < floor) return null
|
|
310
362
|
if (near.top1 - near.top2 < cfg.autoMergeMargin) return null
|
|
311
363
|
return near
|
|
312
364
|
}
|
|
@@ -442,6 +494,9 @@ export function pruneItems(items, max, nowIso) {
|
|
|
442
494
|
|
|
443
495
|
// ---- Global 存储(~/.config/dsh-project-memory/global.json) ----
|
|
444
496
|
|
|
497
|
+
/** 进程内按文件路径复用;整份文档读改写,两个实例会互相覆盖。 */
|
|
498
|
+
const globalStoreCache = new Map()
|
|
499
|
+
|
|
445
500
|
function readJson(file, fallback) {
|
|
446
501
|
let raw
|
|
447
502
|
try {
|
|
@@ -476,14 +531,27 @@ export class GlobalStore {
|
|
|
476
531
|
constructor(file) {
|
|
477
532
|
this.file = file
|
|
478
533
|
this.doc = null
|
|
534
|
+
this._dirty = false
|
|
535
|
+
this._baseIds = new Set()
|
|
536
|
+
this._deletedIds = new Set()
|
|
537
|
+
this._lockWarned = false
|
|
479
538
|
}
|
|
480
539
|
|
|
481
540
|
load() {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
541
|
+
// 整份文档读改写:同一路径必须共用实例,否则两个工具/会话交错时后写覆盖先写。
|
|
542
|
+
// 与 ProjectMemoryStore 的 storeCache 同语义;这里只按路径缓存(global 文件只有一个)。
|
|
543
|
+
const key = path.resolve(this.file)
|
|
544
|
+
const hot = globalStoreCache.get(key)
|
|
545
|
+
if (hot) {
|
|
546
|
+
this.doc = hot.doc
|
|
547
|
+
this._dirty = hot._dirty
|
|
548
|
+
return hot
|
|
486
549
|
}
|
|
550
|
+
this.doc = normalizeDoc(readJson(this.file, null))
|
|
551
|
+
// 与 project 级一致:global 条目也要补派生 trigger(提示通道用它提升召回;确定性、幂等)。
|
|
552
|
+
if (backfillDerivedTriggers(this.doc)) this.markDirty()
|
|
553
|
+
this._baseIds = new Set(this.doc.items.map((it) => it?.id).filter(Boolean))
|
|
554
|
+
globalStoreCache.set(key, this)
|
|
487
555
|
return this
|
|
488
556
|
}
|
|
489
557
|
|
|
@@ -495,12 +563,42 @@ export class GlobalStore {
|
|
|
495
563
|
this._dirty = true
|
|
496
564
|
}
|
|
497
565
|
|
|
498
|
-
/** 变更提交:fn(this.doc)
|
|
566
|
+
/** 变更提交:fn(this.doc) 后加锁、合并另一进程的磁盘状态、原子落盘。 */
|
|
499
567
|
commit(fn) {
|
|
500
568
|
const res = fn ? fn(this.doc, this) : undefined
|
|
501
|
-
if (this._dirty
|
|
569
|
+
if (!this._dirty && res === undefined) return res
|
|
570
|
+
// 本进程从基线里删掉的 id(removeMemory 直接 splice,没有单独的删除 API)。
|
|
571
|
+
const current = new Set(this.doc.items.map((it) => it?.id).filter(Boolean))
|
|
572
|
+
for (const id of this._baseIds) if (!current.has(id)) this._deletedIds.add(id)
|
|
573
|
+
for (const id of current) this._deletedIds.delete(id)
|
|
574
|
+
const release = acquireDirLock(path.dirname(this.file))
|
|
575
|
+
if (!release) {
|
|
576
|
+
if (!this._lockWarned) {
|
|
577
|
+
this._lockWarned = true
|
|
578
|
+
console.error(`[dsh-project-memory] global store ${this.file} is busy (another dsh process is writing); this save was skipped and will retry on the next write.`)
|
|
579
|
+
}
|
|
580
|
+
return res
|
|
581
|
+
}
|
|
582
|
+
try {
|
|
583
|
+
const disk = normalizeDoc(readJson(this.file, null))
|
|
584
|
+
const byId = new Map()
|
|
585
|
+
for (const it of disk.items) if (it?.id) byId.set(it.id, it)
|
|
586
|
+
for (const it of this.doc.items) {
|
|
587
|
+
if (!it?.id) continue
|
|
588
|
+
if (this._deletedIds.has(it.id)) {
|
|
589
|
+
byId.delete(it.id)
|
|
590
|
+
continue
|
|
591
|
+
}
|
|
592
|
+
const prev = byId.get(it.id)
|
|
593
|
+
if (!prev || newerIso(it.updatedAt, prev.updatedAt) >= 0) byId.set(it.id, it)
|
|
594
|
+
}
|
|
595
|
+
for (const id of this._deletedIds) byId.delete(id)
|
|
596
|
+
this.doc.items = [...byId.values()]
|
|
502
597
|
writeJsonAtomic(this.file, this.doc)
|
|
503
598
|
this._dirty = false
|
|
599
|
+
this._baseIds = new Set(this.doc.items.map((it) => it?.id).filter(Boolean))
|
|
600
|
+
} finally {
|
|
601
|
+
release()
|
|
504
602
|
}
|
|
505
603
|
return res
|
|
506
604
|
}
|
|
@@ -737,17 +835,21 @@ export function saveInsight({ store, globalStore, raw, scope, taskId, cfg, sourc
|
|
|
737
835
|
if (raw && raw.id) {
|
|
738
836
|
const found = findInsightAnywhere({ store, globalStore }, raw.id)
|
|
739
837
|
if (!found) return { ok: false, error: `找不到要更新的条目: ${raw.id}(可能已被删除/提升;用 query_memory 重新确认 id)` }
|
|
838
|
+
const wasDraft = found.item.draft === true
|
|
740
839
|
const replaced = applyUpdate(found.item, raw, now)
|
|
741
840
|
if (found.scope === 'global') globalStore.markDirty()
|
|
742
841
|
else if (found.scope === 'task') store.markTasksDirty()
|
|
743
842
|
else store.replaceInsightItems(store.insightItems())
|
|
843
|
+
const hint = replaced.length
|
|
844
|
+
? `已就地更新(覆盖字段:${replaced.join('/')},旧值在 prev)`
|
|
845
|
+
: wasDraft ? '已确认草稿(draft=false)' : '没有字段变化'
|
|
744
846
|
return {
|
|
745
847
|
ok: true,
|
|
746
848
|
action: 'updated',
|
|
747
849
|
id: raw.id,
|
|
748
850
|
scope: found.scope,
|
|
749
851
|
replaced,
|
|
750
|
-
hint: replaced.length ?
|
|
852
|
+
hint: wasDraft && replaced.length ? `${hint};草稿已确认` : hint,
|
|
751
853
|
}
|
|
752
854
|
}
|
|
753
855
|
const s = scope || 'project'
|
|
@@ -828,77 +930,94 @@ function buildHint(res, pruned, promoted) {
|
|
|
828
930
|
// ---- scope = task ----
|
|
829
931
|
|
|
830
932
|
function saveTaskInsight(store, globalStore, task, raw, cfg, now, source, cosine) {
|
|
831
|
-
//
|
|
832
|
-
|
|
933
|
+
// 反思产出是**待确认草稿**:只落在当前任务,绝不参与 project/global/跨任务的自动合并或
|
|
934
|
+
// 自动提升。否则一条 LLM 生成的 draft 可以覆盖作者手写的 project 级知识,草稿审核也就
|
|
935
|
+
// 失去意义。确认走显式编辑(applyUpdate 会清 draft)或面板的 confirm。
|
|
936
|
+
const draftOnly = raw.draft === true || source === 'reflect'
|
|
833
937
|
const base = { ...raw, source, sourceTaskIds: [task.id] }
|
|
834
938
|
const text = insightMatchText(base)
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
const { replaced } = mergeInto(pjHit.item, base, cfg, now)
|
|
848
|
-
store.replaceInsightItems(pjItems)
|
|
849
|
-
applyDecay(pjItems, cfg, now)
|
|
850
|
-
pruneItems(pjItems, cfg.maxProject, now)
|
|
851
|
-
const promoted = promoteProjectToGlobal(store, globalStore, cfg, now)
|
|
852
|
-
return { ok: true, action: 'linked-project', id: pjHit.item.id, scope: 'project', replaced, hint: `该知识已在 project 级,累计第 ${(pjHit.item.sourceTaskIds || []).length} 个任务命中${promoted ? ';已自动提升 global' : ''}` }
|
|
853
|
-
}
|
|
854
|
-
// 2) 已有 global 级知识 → 同样只挂命中
|
|
855
|
-
if (globalStore) {
|
|
856
|
-
const glNear = vectorNear(vectorText(base), globalStore.items(), cosine)
|
|
857
|
-
const glTarget = autoMergeTarget(glNear, cfg)
|
|
858
|
-
if (glTarget) {
|
|
859
|
-
const { replaced } = mergeInto(glTarget.item, base, cfg, now)
|
|
860
|
-
globalStore.markDirty()
|
|
861
|
-
return { ok: true, action: 'auto-merged', id: glTarget.item.id, scope: 'global', replaced, cos: Number(glTarget.top1.toFixed(3)), hint: `相似度 ${glTarget.top1.toFixed(3)},已自动覆盖 global 级既有条目${replaced.length ? `(覆盖字段 ${replaced.join('/')})` : ''}` }
|
|
939
|
+
if (!draftOnly) {
|
|
940
|
+
// 1) 已有 project 级知识 → 挂成员/命中,不再在 task 层重复存
|
|
941
|
+
const pjItems = store.insightItems()
|
|
942
|
+
const pjNear = vectorNear(vectorText(base), pjItems, cosine)
|
|
943
|
+
const pjTarget = autoMergeTarget(pjNear, cfg)
|
|
944
|
+
if (pjTarget) {
|
|
945
|
+
const { replaced } = mergeInto(pjTarget.item, base, cfg, now)
|
|
946
|
+
store.replaceInsightItems(pjItems)
|
|
947
|
+
applyDecay(pjItems, cfg, now)
|
|
948
|
+
pruneItems(pjItems, cfg.maxProject, now)
|
|
949
|
+
const promoted = promoteProjectToGlobal(store, globalStore, cfg, now)
|
|
950
|
+
return { ok: true, action: 'auto-merged', id: pjTarget.item.id, scope: 'project', replaced, cos: Number(pjTarget.top1.toFixed(3)), hint: `相似度 ${pjTarget.top1.toFixed(3)},已自动覆盖 project 级既有条目${replaced.length ? `(覆盖字段 ${replaced.join('/')})` : ''}${promoted ? ';已自动提升 global' : ''}` }
|
|
862
951
|
}
|
|
863
|
-
const
|
|
864
|
-
if (
|
|
865
|
-
const { replaced } = mergeInto(
|
|
866
|
-
|
|
867
|
-
|
|
952
|
+
const pjHit = findBestOverlapMatch(text, pjItems)
|
|
953
|
+
if (pjHit && pjHit.score >= cfg.dedupOverlap) {
|
|
954
|
+
const { replaced } = mergeInto(pjHit.item, base, cfg, now)
|
|
955
|
+
store.replaceInsightItems(pjItems)
|
|
956
|
+
applyDecay(pjItems, cfg, now)
|
|
957
|
+
pruneItems(pjItems, cfg.maxProject, now)
|
|
958
|
+
const promoted = promoteProjectToGlobal(store, globalStore, cfg, now)
|
|
959
|
+
return { ok: true, action: 'linked-project', id: pjHit.item.id, scope: 'project', replaced, hint: `该知识已在 project 级,累计第 ${(pjHit.item.sourceTaskIds || []).length} 个任务命中${promoted ? ';已自动提升 global' : ''}` }
|
|
868
960
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
961
|
+
// 2) 已有 global 级知识 → 同样只挂命中
|
|
962
|
+
if (globalStore) {
|
|
963
|
+
const glNear = vectorNear(vectorText(base), globalStore.items(), cosine)
|
|
964
|
+
const glTarget = autoMergeTarget(glNear, cfg)
|
|
965
|
+
if (glTarget) {
|
|
966
|
+
const { replaced } = mergeInto(glTarget.item, base, cfg, now)
|
|
967
|
+
globalStore.markDirty()
|
|
968
|
+
return { ok: true, action: 'auto-merged', id: glTarget.item.id, scope: 'global', replaced, cos: Number(glTarget.top1.toFixed(3)), hint: `相似度 ${glTarget.top1.toFixed(3)},已自动覆盖 global 级既有条目${replaced.length ? `(覆盖字段 ${replaced.join('/')})` : ''}` }
|
|
969
|
+
}
|
|
970
|
+
const glHit = findBestOverlapMatch(text, globalStore.items())
|
|
971
|
+
if (glHit && glHit.score >= cfg.dedupOverlap) {
|
|
972
|
+
const { replaced } = mergeInto(glHit.item, base, cfg, now)
|
|
973
|
+
globalStore.markDirty()
|
|
974
|
+
return { ok: true, action: 'linked-global', id: glHit.item.id, scope: 'global', replaced, hint: `该知识已在 global 级,累计第 ${(glHit.item.sourceTaskIds || []).length} 个任务命中` }
|
|
975
|
+
}
|
|
881
976
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
const
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
977
|
+
// 3) 跨任务池去重合并(同一坑只留一份,sourceTaskIds 累积)。
|
|
978
|
+
// 草稿不是已确认知识:非草稿写入不得把正文并进一条 draft(那会让新知识永远停在待审状态)。
|
|
979
|
+
const pool = allTaskInsights(store).filter((it) => it.draft !== true)
|
|
980
|
+
const poolNear = vectorNear(vectorText(base), pool, cosine)
|
|
981
|
+
const poolTarget = autoMergeTarget(poolNear, cfg)
|
|
982
|
+
if (poolTarget) {
|
|
983
|
+
const { replaced } = mergeInto(poolTarget.item, base, cfg, now)
|
|
888
984
|
store.markTasksDirty()
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
985
|
+
const holder = taskContaining(store, poolTarget.item.id)
|
|
986
|
+
if (holder) {
|
|
987
|
+
const promoted = promoteAllTasksToProject(store, globalStore, cfg, now)
|
|
988
|
+
return { ok: true, action: 'auto-merged', id: poolTarget.item.id, taskId: holder.id, scope: 'task', replaced, cos: Number(poolTarget.top1.toFixed(3)), hint: `相似度 ${poolTarget.top1.toFixed(3)},已自动覆盖任务 ${holder.id} 的既有条目${replaced.length ? `(覆盖字段 ${replaced.join('/')})` : ''}${promoted ? `;自动提升 project ${promoted} 条` : ''}` }
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
const hit = findBestOverlapMatch(text, pool)
|
|
992
|
+
if (hit && hit.score >= cfg.dedupOverlap) {
|
|
993
|
+
const { replaced } = mergeInto(hit.item, base, cfg, now)
|
|
994
|
+
const holder = taskContaining(store, hit.item.id)
|
|
995
|
+
if (holder) {
|
|
996
|
+
store.markTasksDirty()
|
|
997
|
+
const holderId = holder.id
|
|
998
|
+
const promoted = promoteAllTasksToProject(store, globalStore, cfg, now)
|
|
999
|
+
const size = (hit.item.sourceTaskIds || []).length
|
|
1000
|
+
return {
|
|
1001
|
+
ok: true,
|
|
1002
|
+
action: 'merged',
|
|
1003
|
+
id: hit.item.id,
|
|
1004
|
+
taskId: holderId,
|
|
1005
|
+
replaced,
|
|
1006
|
+
hint: `跨任务去重:并入任务 ${holderId} 既有条目(现 ${size} 个任务命中)${replaced.length ? `,覆盖字段 ${replaced.join('/')}` : ''}${promoted ? `;自动提升 project ${promoted} 条` : ''}`,
|
|
1007
|
+
}
|
|
899
1008
|
}
|
|
900
1009
|
}
|
|
901
1010
|
}
|
|
1011
|
+
if (draftOnly) {
|
|
1012
|
+
// 同一任务的重复反思只保留一份草稿;跨任务不合并(各任务的审核上下文独立)。
|
|
1013
|
+
const existingDrafts = (task.insights || []).filter((it) => it && it.draft === true)
|
|
1014
|
+
const hit = findBestOverlapMatch(text, existingDrafts)
|
|
1015
|
+
if (hit && hit.score >= cfg.dedupOverlap) {
|
|
1016
|
+
const { replaced } = mergeInto(hit.item, base, cfg, now)
|
|
1017
|
+
store.markTasksDirty()
|
|
1018
|
+
return { ok: true, action: 'merged', id: hit.item.id, taskId: task.id, replaced, hint: '已合并到本任务既有草稿' }
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
902
1021
|
// 4) 新建于当前任务
|
|
903
1022
|
if (!Array.isArray(task.insights)) task.insights = []
|
|
904
1023
|
const ins = normalizeInsight(raw, { scope: 'task', source, nowIso: now, sourceTaskIds: [task.id], confidence: raw.confidence })
|
|
@@ -921,6 +1040,8 @@ export function promoteAllTasksToProject(store, globalStore, cfg, now) {
|
|
|
921
1040
|
const list = task.insights || []
|
|
922
1041
|
for (const ins of [...list]) {
|
|
923
1042
|
if (ins.scope && ins.scope !== 'task') continue
|
|
1043
|
+
// 草稿必须先被确认;自动提升绕过审核就等于把 reflection 的猜测变成项目资产。
|
|
1044
|
+
if (ins.draft === true) continue
|
|
924
1045
|
const members = new Set(ins.sourceTaskIds || [])
|
|
925
1046
|
if (members.size < 2) continue
|
|
926
1047
|
if (num(ins.confidence, 0) < cfg.promoteConfidence) continue
|
|
@@ -964,6 +1085,7 @@ export function promoteProjectToGlobal(store, globalStore, cfg, now) {
|
|
|
964
1085
|
let moved = 0
|
|
965
1086
|
for (const ins of [...items]) {
|
|
966
1087
|
if (ins.scope && ins.scope !== 'project') continue
|
|
1088
|
+
if (ins.draft === true) continue
|
|
967
1089
|
const members = new Set(ins.sourceTaskIds || [])
|
|
968
1090
|
if (members.size < cfg.globalPromoteTasks) continue
|
|
969
1091
|
const glItems = globalStore.items()
|
package/src/lazy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { statSync } from 'node:fs'
|
|
3
|
-
import { findProjectRoot, isUnsafeRoot, memoryRootFor, relativePath, storeKey } from './util/fs.js'
|
|
3
|
+
import { findProjectRoot, isGitIgnored, isUnsafeRoot, memoryRootFor, relativePath, storeKey } from './util/fs.js'
|
|
4
4
|
import { DROP, OVERSIZE, UNCHANGED, commitFileUpdates, fileKind, planFileIndex, toFileUpdate } from './index-pipeline.js'
|
|
5
5
|
import { ProjectMemoryStore } from './store.js'
|
|
6
6
|
import { onFileObserved } from './enhancer.js'
|
|
@@ -17,6 +17,8 @@ export async function indexFile(ctx, config, filePath, watchManager = null, sess
|
|
|
17
17
|
const extraRoots = watchManager ? [...watchManager.roots.keys()] : []
|
|
18
18
|
const root = findProjectRoot(filePath, { extraRoots, sessionRoot })
|
|
19
19
|
if (!root || isUnsafeRoot(root)) return false
|
|
20
|
+
// 被 .gitignore 排除的文件(构建产物 / 内部文档)不进语料;显式 index_doc 不受此限。
|
|
21
|
+
if (isGitIgnored(root, filePath)) return false
|
|
20
22
|
|
|
21
23
|
const memoryDir = memoryRootFor(root, config.memoryDir)
|
|
22
24
|
const store = new ProjectMemoryStore(memoryDir).load()
|
package/src/ops.js
CHANGED
package/src/readiness.js
CHANGED
|
@@ -214,7 +214,7 @@ export function intentText(text) {
|
|
|
214
214
|
.replace(/(?:[A-Za-z0-9_.@-]+\/)+[A-Za-z0-9_.@-]+/g, ' ')
|
|
215
215
|
// 带扩展名的**非 ASCII 文件名**(`示例调研.pptx` / `docs/示例.md`):
|
|
216
216
|
// 只挡 ASCII 路径不够——中文文件名整块留下,"调研""面试"这类子串照样触发 when.intents,
|
|
217
|
-
// 正是引号剥离要防的那类假阳性。ASCII 裸名(如
|
|
217
|
+
// 正是引号剥离要防的那类假阳性。ASCII 裸名(如 notes.md)保持原语义,不在这里动。
|
|
218
218
|
.replace(/\S*[^\x00-\x7F]\S*\.[A-Za-z][A-Za-z0-9]{0,7}\b/g, ' ')
|
|
219
219
|
// 仓库里的裸文件名(README / CHANGELOG …)也是语料,不是意图
|
|
220
220
|
.replace(/\b(?:README|CHANGELOG|LICENSE|AGENTS|CONTRIBUTING|Dockerfile|Makefile)\b/g, ' ')
|
package/src/recall.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module dsh-project-memory/recall
|
|
19
19
|
*/
|
|
20
|
-
import { rankEntriesMergedScored, rankEntriesStreaming,
|
|
20
|
+
import { rankEntriesMergedScored, rankEntriesStreaming, tokenizeRaw, CJK_RANGE } from './util/search.js'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* 短拉丁片段不算检索证据(只用于经验/洞察两层)。
|
|
@@ -44,23 +44,28 @@ function gatedQueryText(q) {
|
|
|
44
44
|
* (来自 `git commit --amend --no-edit`),于是单个片段就拿走了 3.13 分。提示通道早就有这条规则
|
|
45
45
|
* (`hintMinMatched`,默认 min(2, 词数)),**工具路径与这两层一直漏着**。
|
|
46
46
|
*
|
|
47
|
-
* ⚠
|
|
47
|
+
* ⚠ **只对没有语义分的条目生效**,而且是**逐条**判——不是"有 rerank 就整条关掉"。这是同查询集
|
|
48
|
+
* A/B 实测出来的(36 条、同一个 store):
|
|
48
49
|
* · 纯词法下加闸门:BM25 的 hit@1/3/5/10 = 39/50/58/69% **完全不变**,只是不再对乱码查询出声;
|
|
49
|
-
* ·
|
|
50
|
+
* · 有向量时对**所有**条目加闸门:融合 hit@5/10 从 64/72% 掉到 58/64%,"完全没召回"从 10 涨到 13。
|
|
50
51
|
* 原因是结构性的:**向量救回来的那批,恰恰就是词法弱到不足 2 个命中的**——用词法的尺子去筛,
|
|
51
|
-
*
|
|
52
|
+
* 等于把向量的全部价值砍掉。所以:拿到语义分的条目豁免,没拿到的照旧过闸。
|
|
53
|
+
*
|
|
54
|
+
* 旧实现按 `Boolean(rerank)` 整条关闸,于是"装了 leanvec 但这一轮给不出余弦"(查询编码失败、
|
|
55
|
+
* embed 抛异常、或者根本没有候选可编码)时,弱命中会漏进来——那不是降级,是**换了行为**:
|
|
56
|
+
* 注释承诺的"逐字段退回纯词法"在那种情况下并不成立。
|
|
52
57
|
*
|
|
53
58
|
* 只作用于 experience / insight 两层:它们是短标题语料,单片段命中几乎没有证据力;
|
|
54
59
|
* doc/symbol 层是代码与路径(`js` / `id` 这类单词查询本来就该命中),不动它。
|
|
55
60
|
* 单词查询不受影响:need = min(2, 1) = 1,与"score>0 即命中"等价。
|
|
56
61
|
*/
|
|
57
|
-
function matchedFloor(scored, queries
|
|
58
|
-
if (hasVector) return scored // 有语义分 → 不用词法的"命中词数"判质量
|
|
62
|
+
function matchedFloor(scored, queries) {
|
|
59
63
|
const qTokens = new Set()
|
|
60
64
|
for (const q of queries) for (const t of tokenizeRaw(String(q ?? ''))) qTokens.add(t)
|
|
61
65
|
const need = Math.min(2, qTokens.size)
|
|
62
66
|
if (need <= 1) return scored
|
|
63
|
-
|
|
67
|
+
// `typeof vector === 'number'` 只在融合真给出了有限余弦时为真(见 fuseVectorHits)。
|
|
68
|
+
return scored.filter((r) => typeof r.vector === 'number' || (r.matched ?? 0) >= need)
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
/** 各层先验:insight 是"踩过的坑",略高于普通文档;经验笔记(同库、kind 区分)留痕价值略低。 */
|
|
@@ -133,6 +138,8 @@ export function insightToEntry(ins) {
|
|
|
133
138
|
kind: ins?.kind,
|
|
134
139
|
scope: ins?.scope,
|
|
135
140
|
confidence: ins?.confidence,
|
|
141
|
+
// 上一版被覆盖的字段:pull 侧要能显示,模型才知道能不能写回。
|
|
142
|
+
prev: ins?.prev && typeof ins.prev === 'object' ? ins.prev : undefined,
|
|
136
143
|
files: Array.isArray(ins?.files) ? ins.files : [],
|
|
137
144
|
symbols: Array.isArray(ins?.symbols) ? ins.symbols : [],
|
|
138
145
|
title: String(ins?.title || '(untitled)'),
|
|
@@ -210,12 +217,20 @@ export function visibleInsights({ store = null, globalStore = null, boundTaskId
|
|
|
210
217
|
* 融合必须在**全量** BM25 序上做(不是先截断再重排),否则"词法排 20 名但语义很近"的条目
|
|
211
218
|
* 永远进不来——那正是向量唯一能补的那类。截断到 limit 发生在融合之后。
|
|
212
219
|
*
|
|
213
|
-
* **边界**:`rankEntriesMergedScored`
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
220
|
+
* **边界**:`rankEntriesMergedScored` 只返回 **BM25 分 > 0** 的条目,所以本函数只能**重排**,
|
|
221
|
+
* **拉不进**零词重叠的条目——那需要"并集"形态(向量 top-k 追加到短名单)。
|
|
222
|
+
*
|
|
223
|
+
* 并集为什么不在这里做(0.6.x 复核过一次,仍不做):
|
|
224
|
+
* · 收益是真的:并集 hit@10 92% vs 81%;
|
|
225
|
+
* · 但它**单独存在时是空操作**:并集候选的词法分是 0,立刻被 `matchedFloor` 挡掉
|
|
226
|
+
* (matched=0 < min(2,词数))。要让它们活下来,必须让"高余弦名次"**替代**词法闸门——
|
|
227
|
+
* 那就是一个向量闸门,而 auto-inject 里那条路已经量过:绝对余弦在两个方向上都不成立
|
|
228
|
+
* (合成池上像样、真实交付上 0.42 会剪掉 45/45;换成相对分/名次也只在名次 ≤4 时有
|
|
229
|
+
* 0.46 vs 0.24 的精度差,代价是误杀 4/10 个真命中)。所以并集不是"再加一段代码",
|
|
230
|
+
* 而是"改准入策略"——需要先有人工金标准,不能顺手带上。
|
|
231
|
+
* · 返回条数翻倍的代价反而是次要的(候选可以并集、交付照样截断到 limit)。
|
|
217
232
|
*
|
|
218
|
-
* @param {{item: object, score: number}[]} scored - 已按 BM25 降序
|
|
233
|
+
* @param {{item: object, score: number, matched?: number}[]} scored - 已按 BM25 降序
|
|
219
234
|
* @param {string[]} queries
|
|
220
235
|
* @param {{score: (q: string, items: object[]) => Map<string, number>, alpha?: number}} [rerank]
|
|
221
236
|
* @returns {{item: object, score: number, vector?: number}[]}
|
|
@@ -232,14 +247,25 @@ function fuseVectorHits(scored, queries, rerank) {
|
|
|
232
247
|
if (!cosOf.has(id) || v > cosOf.get(id)) cosOf.set(id, v) // 与多查询的 BM25 合并同语义:取最高
|
|
233
248
|
}
|
|
234
249
|
}
|
|
235
|
-
if (!cosOf.size) return scored // 查询无法编码 / 没有向量 → 原样返回(降级到纯词法)
|
|
236
250
|
const alpha = Math.max(0, Math.min(1, typeof rerank.alpha === 'number' ? rerank.alpha : 0.5))
|
|
237
251
|
const top0 = scored[0].score || 1
|
|
238
|
-
const
|
|
252
|
+
const rows = scored.map((s) => {
|
|
239
253
|
const v = cosOf.get(s.item?.insightId) ?? cosOf.get(s.item?.id)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
return { s, v: typeof v === 'number' && Number.isFinite(v) ? v : undefined }
|
|
255
|
+
})
|
|
256
|
+
// 一条都没拿到余弦(查询编码失败 / embed 抛异常 / 向量层返回空 Map)→ **原样返回**。
|
|
257
|
+
// 与"整条关掉闸门"不同:这条路径连归一化都不做,于是 matchedFloor 逐条生效,
|
|
258
|
+
// 输出与纯词法逐字段一致(这是勘误:旧行为会在这里漏过词法弱命中)。
|
|
259
|
+
const withVec = rows.filter((r) => r.v !== undefined)
|
|
260
|
+
if (!withVec.length) return scored
|
|
261
|
+
// 缺向量分的条目按**这一轮已有余弦的均值**补(不是拿 0 罚它,也不是留一个隐式 0.5)。
|
|
262
|
+
// 旧写法 `score = rel` 等价于补 α·0.5:真实 store 上 7381 对的余弦中位数只有 0.28、
|
|
263
|
+
// 查询→标题 top-1 也多在 0.51~0.63,于是"有低余弦"的条目会被"完全没有向量"的条目压住,
|
|
264
|
+
// 与注释承诺的"缺向量不等于不相关"正好相反。均值是这里假设最少的补法(缺分=平均水平)。
|
|
265
|
+
const neutral = withVec.reduce((sum, r) => sum + r.v, 0) / withVec.length
|
|
266
|
+
const fused = rows.map(({ s, v }) => {
|
|
267
|
+
const rel = s.score / top0
|
|
268
|
+
return { item: s.item, matched: s.matched, vector: v, score: (1 - alpha) * rel + alpha * (v === undefined ? neutral : v) }
|
|
243
269
|
})
|
|
244
270
|
fused.sort((a, b) => b.score - a.score)
|
|
245
271
|
return fused
|
|
@@ -309,17 +335,35 @@ export function recallItems(opts = {}) {
|
|
|
309
335
|
const expPool = entries !== null
|
|
310
336
|
? entries
|
|
311
337
|
: visibleInsights({ store, globalStore, boundTaskId }).filter((it) => it.kind === 'experience')
|
|
338
|
+
// **与洞察层共用一个适配器**(`insightToEntry`)。这里曾经用 v0.4 的 `{problem,solution}`
|
|
339
|
+
// 形状打分,而统一存储之后 `kind:'experience'` 也能由 `save_lesson` 写出——它的参数表里
|
|
340
|
+
// 没有 problem / solution,于是那种条目的 BM25 文档是三个字面量 `undefined`:任何正常查询
|
|
341
|
+
// 都 0 分,而洞察桶又排除了 experience → 两条拉取路径同时不通,条目在库里但永远查不到。
|
|
342
|
+
// 打分用 entry,命中后再换回原始条目:渲染与记账要 problem / sourceFile / id。
|
|
343
|
+
const byId = new Map(expPool.map((it) => [it?.id, it]))
|
|
344
|
+
const expEntries = expPool.map((it) => (it && typeof it.type === 'string' ? it : insightToEntry(it)))
|
|
312
345
|
// 有向量时在**全量** BM25 序上融合(见 fuseVectorHits 注释),截断到 limit 放到融合之后;
|
|
313
346
|
// 没有向量时沿用原来的 limit 语义,输出与纯词法路径逐字段一致。
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
347
|
+
const ranked = rankEntriesMergedScored(expEntries, qsLayers, rerank ? expEntries.length : limit)
|
|
348
|
+
if (ranked.length) {
|
|
349
|
+
const fused = fuseVectorHits(ranked.map((r) => ({ item: r.entry, score: r.score, matched: r.matched })), qs, rerank)
|
|
350
|
+
// 闸门在融合**之后**、逐条判:拿到语义分的豁免,没拿到的照旧按命中词数筛。
|
|
351
|
+
const scored = matchedFloor(fused, qsLayers).slice(0, limit)
|
|
352
|
+
const top = scored[0]?.score || 1
|
|
353
|
+
if (scored.length) {
|
|
354
|
+
buckets.push({
|
|
355
|
+
layer: 'experience',
|
|
356
|
+
prior: LAYER_PRIORS.experience,
|
|
357
|
+
hits: scored.map(({ item, score, vector }) => ({
|
|
358
|
+
item: byId.get(item?.insightId) || byId.get(item?.id) || item,
|
|
359
|
+
score,
|
|
360
|
+
vector,
|
|
361
|
+
prior: LAYER_PRIORS.experience,
|
|
362
|
+
weightedScore: score,
|
|
363
|
+
rel: score / top,
|
|
364
|
+
})),
|
|
365
|
+
})
|
|
366
|
+
}
|
|
323
367
|
}
|
|
324
368
|
}
|
|
325
369
|
|
|
@@ -327,10 +371,12 @@ export function recallItems(opts = {}) {
|
|
|
327
371
|
const pool = entries !== null
|
|
328
372
|
? entries.filter((e) => e && e.type === 'insight' && e.kind !== 'experience')
|
|
329
373
|
: visibleInsights({ store, globalStore, boundTaskId }).filter((it) => it.kind !== 'experience').map(insightToEntry)
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
374
|
+
const ranked = rankEntriesMergedScored(pool, qsLayers, rerank ? pool.length : limit)
|
|
375
|
+
// 与经验桶同一条顺序:融合 → 逐条闸门 → 截断。闸门在融合之后是刻意的——
|
|
376
|
+
// 融合会把"词法弱但语义近"的条目抬上台面,先闸后融等于先把它们删掉。
|
|
377
|
+
const scored = matchedFloor(fuseVectorHits(ranked.map((r) => ({ item: r.entry, score: r.score, matched: r.matched })), qs, rerank), qsLayers).slice(0, limit)
|
|
378
|
+
const top = scored[0]?.score || 1
|
|
379
|
+
if (scored.length) {
|
|
334
380
|
buckets.push({
|
|
335
381
|
layer: 'insight',
|
|
336
382
|
prior: LAYER_PRIORS.insight,
|