memory-eternal 0.10.42 → 0.10.44

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/vault.js CHANGED
@@ -263,7 +263,7 @@ function storesFor(want) {
263
263
  * @param stores storesFor() 的结果
264
264
  * @param extra { kind, agent, tail } —— tail 是 ORDER BY / LIMIT 片段(默认按 updated_at 倒序)
265
265
  */
266
- function multiStoreQuery(sel, stores, { kind = '', agent = '', tail = 'ORDER BY updated_at DESC' } = {}) {
266
+ function multiStoreQuery(sel, stores, { kind = '', agent = '', tag = '', tail = 'ORDER BY updated_at DESC' } = {}) {
267
267
  const parts = []
268
268
  const args = []
269
269
  for (const store of stores) {
@@ -275,6 +275,9 @@ function multiStoreQuery(sel, stores, { kind = '', agent = '', tail = 'ORDER BY
275
275
  }
276
276
  if (kind) { where.push('kind = ?'); wargs.push(kind) }
277
277
  if (agent) where.push(agentWhere(agent, wargs))
278
+ // 标签过滤(issue #46 后的界面改进):tags 列是 JSON 数组字符串(["a","b"]),
279
+ // 用 instr 找带引号的完整标签:既不受 LIKE 通配符影响,也不会把 "ab" 匹配成 "a"。
280
+ if (tag) { where.push('instr(lower(tags), lower(?)) > 0'); wargs.push('"' + String(tag) + '"') }
278
281
  parts.push(`SELECT ${sel} FROM ${store.table}${where.length ? ' WHERE ' + where.join(' AND ') : ''}`)
279
282
  args.push(...wargs)
280
283
  }
@@ -312,7 +315,7 @@ export const TITLE_COLLATOR = new Intl.Collator('zh-Hans-CN', { numeric: true, s
312
315
  * @param opts.offset 偏移(配合 limit 做真分页)
313
316
  * @param opts.sort 'recent'(updated_at DESC,默认)| 'title'(拼音升序,跨页全局有序)
314
317
  */
315
- export async function listCards(root, { status, kind, agent, limit, offset = 0, sort = 'recent' } = {}) {
318
+ export async function listCards(root, { status, kind, agent, tag = '', limit, offset = 0, sort = 'recent' } = {}) {
316
319
  const want = status ?? [MAIN_STATUS]
317
320
  const db = getDb(root)
318
321
  const stores = storesFor(want)
@@ -320,7 +323,7 @@ export async function listCards(root, { status, kind, agent, limit, offset = 0,
320
323
  if (sort === 'title') {
321
324
  // SQLite 的 ORDER BY 是 UTF-8 字节序,中文标题看着就是乱的 → 只取 path/title 用拼音排好,
322
325
  // 再回表取这一页的正文(避免为了排序把所有正文读进内存)。
323
- const { sql, args } = multiStoreQuery('path, title', stores, { kind, agent, tail: '' })
326
+ const { sql, args } = multiStoreQuery('path, title', stores, { kind, agent, tag, tail: '' })
324
327
  const light = db.prepare(sql).all(...args)
325
328
  light.sort((a, b) => TITLE_COLLATOR.compare(a.title || '', b.title || ''))
326
329
  const start = Math.max(0, offset | 0)
@@ -344,17 +347,17 @@ export async function listCards(root, { status, kind, agent, limit, offset = 0,
344
347
  const { sql, args } = multiStoreQuery(
345
348
  'id, path, kind, title, tags, body, summary, status, source, submitted_by, severity, reason, created_at, updated_at, deleted_at',
346
349
  stores,
347
- { kind, agent, tail },
350
+ { kind, agent, tag, tail },
348
351
  )
349
352
  const finalArgs = Number.isInteger(limit) && limit > 0 ? [...args, limit, Math.max(0, offset | 0)] : args
350
353
  return db.prepare(sql).all(...finalArgs).map(rowToCard)
351
354
  }
352
355
 
353
356
  /** 计数(分页接口要用 total 判断还有没有下一页)。 */
354
- export async function countCards(root, { status, kind, agent } = {}) {
357
+ export async function countCards(root, { status, kind, agent, tag = '' } = {}) {
355
358
  const db = getDb(root)
356
359
  const stores = storesFor(status ?? [MAIN_STATUS])
357
- const { sql, args } = multiStoreQuery('COUNT(*) n', stores, { kind, agent, tail: '' })
360
+ const { sql, args } = multiStoreQuery('COUNT(*) n', stores, { kind, agent, tag, tail: '' })
358
361
  return db.prepare(`SELECT SUM(n) n FROM (${sql})`).get(...args).n || 0
359
362
  }
360
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-eternal",
3
- "version": "0.10.42",
3
+ "version": "0.10.44",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -64,7 +64,7 @@
64
64
  "prepublishOnly": "node build.mjs",
65
65
  "release": "node scripts/release.mjs",
66
66
  "release:dry": "node scripts/release.mjs --dry-run",
67
- "test": "node build.mjs && node tests/vault.test.mjs && node tests/capture.test.mjs && node tests/capture-route.test.mjs && node tests/stall.test.mjs && node tests/vault-path.test.mjs && node tests/vault-resolve.test.mjs && node tests/minhash.test.mjs && node tests/settings-save.test.mjs && node tests/config-coverage.test.mjs && node tests/config-sync.test.mjs && node tests/config-merge.test.mjs && node tests/sse.test.mjs && node tests/api.test.mjs && node tests/import-roundtrip.test.mjs && node tests/graph-perf.test.mjs && node tests/settings-compat.test.mjs && node tests/node-bin.test.mjs && node tests/watchdog-lock.test.mjs && node tests/markdown.test.mjs && node tests/feedback.test.mjs && node tests/graph-lod.test.mjs && node tests/ssr.test.mjs && node tests/web-assets.test.mjs && node tests/manifests.test.mjs && node tests/two-store.test.mjs && node tests/noise-gate.test.mjs && node tests/e2e-recall.test.mjs && node tests/issue-fixes.test.mjs && node tests/issue-fixes-2.test.mjs && node tests/issue-fixes-3.test.mjs && node tests/watchdog-orphans.test.mjs && node tests/watchdog-restart.test.mjs && node tests/readme-i18n.test.mjs && node tests/issue-fixes-4.test.mjs && node tests/host-drain.test.mjs && node tests/e2e-host-drain.mjs && node tests/issue-fixes-5.test.mjs && node tests/issue-fixes-6.test.mjs && node tests/capture-json-repair.test.mjs && node tests/csrf-origin.test.mjs && node tests/watchdog-orphan-web.test.mjs && node tests/config-validate.test.mjs && node tests/issue-fixes-8.test.mjs && node tests/issue-fixes-9.test.mjs && node tests/release-verify.test.mjs && node tests/refine.test.mjs && node tests/db-restore.test.mjs && node tests/align.test.mjs && node tests/tags-normalize.test.mjs && node tests/resident-state.test.mjs && node tests/llm-route.test.mjs && node tests/host-managed.test.mjs && node tests/replace-claim.test.mjs && node tests/version-check-self.test.mjs && node tests/setup-codex.test.mjs && node tests/listener-netstat.test.mjs && node tests/issue-46-overlay.test.mjs && node tests/graph-initial-zoom.test.mjs && node tests/card-head-actions.test.mjs"
67
+ "test": "node build.mjs && node tests/vault.test.mjs && node tests/capture.test.mjs && node tests/capture-route.test.mjs && node tests/stall.test.mjs && node tests/vault-path.test.mjs && node tests/vault-resolve.test.mjs && node tests/minhash.test.mjs && node tests/settings-save.test.mjs && node tests/config-coverage.test.mjs && node tests/config-sync.test.mjs && node tests/config-merge.test.mjs && node tests/sse.test.mjs && node tests/api.test.mjs && node tests/import-roundtrip.test.mjs && node tests/graph-perf.test.mjs && node tests/settings-compat.test.mjs && node tests/node-bin.test.mjs && node tests/watchdog-lock.test.mjs && node tests/markdown.test.mjs && node tests/feedback.test.mjs && node tests/graph-lod.test.mjs && node tests/ssr.test.mjs && node tests/web-assets.test.mjs && node tests/manifests.test.mjs && node tests/two-store.test.mjs && node tests/noise-gate.test.mjs && node tests/e2e-recall.test.mjs && node tests/issue-fixes.test.mjs && node tests/issue-fixes-2.test.mjs && node tests/issue-fixes-3.test.mjs && node tests/watchdog-orphans.test.mjs && node tests/watchdog-restart.test.mjs && node tests/readme-i18n.test.mjs && node tests/issue-fixes-4.test.mjs && node tests/host-drain.test.mjs && node tests/e2e-host-drain.mjs && node tests/issue-fixes-5.test.mjs && node tests/issue-fixes-6.test.mjs && node tests/capture-json-repair.test.mjs && node tests/csrf-origin.test.mjs && node tests/watchdog-orphan-web.test.mjs && node tests/config-validate.test.mjs && node tests/issue-fixes-8.test.mjs && node tests/issue-fixes-9.test.mjs && node tests/release-verify.test.mjs && node tests/refine.test.mjs && node tests/db-restore.test.mjs && node tests/align.test.mjs && node tests/tags-normalize.test.mjs && node tests/resident-state.test.mjs && node tests/llm-route.test.mjs && node tests/host-managed.test.mjs && node tests/replace-claim.test.mjs && node tests/version-check-self.test.mjs && node tests/setup-codex.test.mjs && node tests/listener-netstat.test.mjs && node tests/issue-46-overlay.test.mjs && node tests/graph-initial-zoom.test.mjs && node tests/card-head-actions.test.mjs && node tests/card-reader-ux.test.mjs && node tests/tag-filter.test.mjs"
68
68
  },
69
69
  "dependencies": {
70
70
  "@deepseek-ai/schemastery": "^3.18.1"