memory-eternal 0.24.0 → 0.25.0
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.md +7 -1
- package/README.zh-CN.md +7 -1
- package/cursor-extension/package.json +1 -1
- package/dsh-tui-plugin/dsh-plugin.json +1 -1
- package/dsh-tui-plugin/package.json +1 -1
- package/lib/api.js +19 -0
- package/lib/client.js +20 -20
- package/lib/star-prompt.js +92 -0
- package/orca-plugin/orca-plugin.json +1 -1
- package/package.json +2 -2
- package/web/app.js +24 -24
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// 记忆核心 · Star 引导:等价值出现再问,而不是装机即求
|
|
2
|
+
//
|
|
3
|
+
// 观察(来自真实数据):star 主要来自插件内的引导,而不是 README。但「首次打开就求 star」
|
|
4
|
+
// 是在用户还没感受到任何好处时提出请求 —— 转化率低,而且显得功利。
|
|
5
|
+
//
|
|
6
|
+
// 所以这里换成一个**价值触发**的提示:
|
|
7
|
+
// · 门槛:账本里累计召回 ≥ 8 次,或主库已有 ≥ 15 张卡(说明它确实被用起来了)
|
|
8
|
+
// · 频次:7 天冷却、最多问 3 次;点「不再提示」永久关闭
|
|
9
|
+
// · 证据:不空喊「求 star」,而是把已经做过的事摆出来(召回次数 / 沉淀卡数 / 注入字符)
|
|
10
|
+
//
|
|
11
|
+
// 状态放在 config 文件旁边(<config>.star.json),与 vault 数据无关,
|
|
12
|
+
// 删掉 vault 不会重置它;写失败也绝不影响面板。
|
|
13
|
+
import fs from 'node:fs'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import { configFilePath } from './capture-run.js'
|
|
16
|
+
import { ledgerSummary } from './ledger.js'
|
|
17
|
+
import { getDb } from './db.js'
|
|
18
|
+
|
|
19
|
+
export const ASK_MIN_RECALLS = 8
|
|
20
|
+
export const ASK_MIN_CARDS = 15
|
|
21
|
+
export const ASK_COOLDOWN_MS = 7 * 86400000
|
|
22
|
+
export const ASK_MAX_TIMES = 3
|
|
23
|
+
|
|
24
|
+
/** 状态文件与 config 同目录,便于用户自己查看/删除。 */
|
|
25
|
+
export function starStateFile(env) {
|
|
26
|
+
return String(configFilePath(env)).replace(/\.json$/i, '.star.json')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function readStarState(env) {
|
|
30
|
+
try {
|
|
31
|
+
const raw = JSON.parse(fs.readFileSync(starStateFile(env), 'utf8'))
|
|
32
|
+
return { asks: Number(raw.asks) || 0, lastAskAt: Number(raw.lastAskAt) || 0, dismissed: !!raw.dismissed }
|
|
33
|
+
} catch {
|
|
34
|
+
return { asks: 0, lastAskAt: 0, dismissed: false }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function writeStarState(env, next) {
|
|
39
|
+
try {
|
|
40
|
+
const file = starStateFile(env)
|
|
41
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
42
|
+
fs.writeFileSync(file, JSON.stringify({ ...next, updatedAt: new Date().toISOString() }, null, 1))
|
|
43
|
+
return true
|
|
44
|
+
} catch { return false }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 纯函数:是否该弹一次 star 提示。抽出来是为了能单测(时间注入,不依赖真实时钟)。
|
|
49
|
+
*/
|
|
50
|
+
export function shouldAsk({ recalls = 0, cards = 0, state = {}, now = Date.now() } = {}) {
|
|
51
|
+
if (state.dismissed) return false
|
|
52
|
+
if (Number(state.asks) >= ASK_MAX_TIMES) return false
|
|
53
|
+
const last = Number(state.lastAskAt) || 0
|
|
54
|
+
if (last && now - last < ASK_COOLDOWN_MS) return false
|
|
55
|
+
return Number(recalls) >= ASK_MIN_RECALLS || Number(cards) >= ASK_MIN_CARDS
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 面板启动时查询:该不该问 + 用来「讲证据」的数字。 */
|
|
59
|
+
export function starPromptStatus({ root, env, now = Date.now() } = {}) {
|
|
60
|
+
const state = readStarState(env)
|
|
61
|
+
let totals = { recalls: 0, captures: 0, injectedChars: 0 }
|
|
62
|
+
try { totals = ledgerSummary(root, { days: 30, now }).totals } catch { /* 账本坏了不影响提示 */ }
|
|
63
|
+
let cards = 0
|
|
64
|
+
try { cards = Number(getDb(root).prepare('SELECT COUNT(*) AS n FROM cards').get().n) || 0 } catch { /* 没库就按 0 算 */ }
|
|
65
|
+
return {
|
|
66
|
+
ok: true,
|
|
67
|
+
shouldAsk: shouldAsk({ recalls: totals.recalls, cards, state, now }),
|
|
68
|
+
dismissed: !!state.dismissed,
|
|
69
|
+
asks: Number(state.asks) || 0,
|
|
70
|
+
nextAskAt: (Number(state.lastAskAt) || 0) + ASK_COOLDOWN_MS,
|
|
71
|
+
evidence: {
|
|
72
|
+
recalls: totals.recalls,
|
|
73
|
+
captures: totals.captures,
|
|
74
|
+
cards,
|
|
75
|
+
injectedChars: totals.injectedChars,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 记录一次动作:
|
|
82
|
+
* shown → 面板确实展示了(计入一次、开始冷却)
|
|
83
|
+
* later → 用户点了「晚点再说」(开始冷却)
|
|
84
|
+
* never → 永久关闭
|
|
85
|
+
*/
|
|
86
|
+
export function markStarAction(env, action, now = Date.now()) {
|
|
87
|
+
const state = readStarState(env)
|
|
88
|
+
const asks = Number(state.asks) || 0
|
|
89
|
+
if (action === 'never') return writeStarState(env, { ...state, dismissed: true, lastAskAt: now })
|
|
90
|
+
if (action === 'shown') return writeStarState(env, { ...state, asks: asks + 1, lastAskAt: now })
|
|
91
|
+
return writeStarState(env, { ...state, lastAskAt: now })
|
|
92
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "memory-eternal",
|
|
4
4
|
"publisher": "eternalnight996",
|
|
5
5
|
"name": "memory-eternal",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.25.0",
|
|
7
7
|
"description": "Memory Atlas for Orca: open the local memory vault, pending review and knowledge graph from a sandboxed Orca panel.",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "EternalNight996",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memory-eternal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
|
|
5
5
|
"icon": "assets/icon.png",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"release": "node scripts/release.mjs",
|
|
71
71
|
"release:dry": "node scripts/release.mjs --dry-run",
|
|
72
72
|
"panel-check": "node scripts/panel-check.mjs",
|
|
73
|
-
"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/graph-force.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/graph-warmup.test.mjs && node tests/loading-hints.test.mjs && node tests/web-entry.test.mjs && node tests/tui-scroll.test.mjs && node tests/tui-audit-scene.test.mjs && node tests/tui-plugin-boot.test.mjs && node tests/capture-session-id.test.mjs && node tests/ssr.test.mjs && node tests/window-controls.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 && node tests/ui-overflow.test.mjs && node tests/version-card-state.test.mjs && node tests/llm-routes-proxy.test.mjs && node tests/model-strikes.test.mjs && node tests/support-bundle.test.mjs && node tests/health-panel.test.mjs && node tests/issue-48-timeout.test.mjs && node tests/setup-node-path.test.mjs && node tests/capture-kind.test.mjs && node tests/core-memory.test.mjs && node tests/skill-cards.test.mjs && node tests/audit-search.test.mjs && node tests/news.test.mjs && node tests/news-feed.test.mjs && node tests/ledger.test.mjs && node tests/issue-55-timezone.test.mjs && node tests/recycle-center.test.mjs && node tests/news-follows.test.mjs && node tests/news-digest.test.mjs && node tests/search-index.test.mjs"
|
|
73
|
+
"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/graph-force.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/graph-warmup.test.mjs && node tests/loading-hints.test.mjs && node tests/web-entry.test.mjs && node tests/tui-scroll.test.mjs && node tests/tui-audit-scene.test.mjs && node tests/tui-plugin-boot.test.mjs && node tests/capture-session-id.test.mjs && node tests/ssr.test.mjs && node tests/window-controls.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 && node tests/ui-overflow.test.mjs && node tests/version-card-state.test.mjs && node tests/llm-routes-proxy.test.mjs && node tests/model-strikes.test.mjs && node tests/support-bundle.test.mjs && node tests/health-panel.test.mjs && node tests/issue-48-timeout.test.mjs && node tests/setup-node-path.test.mjs && node tests/capture-kind.test.mjs && node tests/core-memory.test.mjs && node tests/skill-cards.test.mjs && node tests/audit-search.test.mjs && node tests/news.test.mjs && node tests/news-feed.test.mjs && node tests/ledger.test.mjs && node tests/issue-55-timezone.test.mjs && node tests/recycle-center.test.mjs && node tests/news-follows.test.mjs && node tests/news-digest.test.mjs && node tests/search-index.test.mjs && node tests/star-prompt.test.mjs"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@deepseek-ai/schemastery": "^3.18.1"
|