@chenhw7/dsh-memory 0.5.0 → 0.5.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.
- package/README.md +28 -14
- package/README.zh-CN.md +29 -15
- package/lib/notes/index.d.ts +1 -1
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +15 -3
- package/lib/notes/index.js.map +1 -1
- package/lib/notes/scope.d.ts +2 -2
- package/lib/notes/scope.js +2 -2
- package/lib/notes/settings.d.ts +10 -0
- package/lib/notes/settings.d.ts.map +1 -1
- package/lib/notes/settings.js +17 -0
- package/lib/notes/settings.js.map +1 -1
- package/lib/review/accumulator.d.ts +1 -1
- package/lib/review/accumulator.js +1 -1
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cairn
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Cairn** is long-term memory for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), packaged as the `@chenhw7/dsh-memory` profile bundle — facts, preferences, corrections, and lessons survive across sessions and restarts.
|
|
4
4
|
|
|
5
5
|
This is a **self-contained single package** (not a multi-package workspace). It depends on dsh core services as **peer dependencies** (provided by the dsh installation you already have) and ships its own `cordis.patch.yml` so `dsh plugin add` activates it as one profile layer.
|
|
6
6
|
|
|
7
7
|
**English** | [简体中文](README.zh-CN.md)
|
|
8
8
|
|
|
9
|
+
## Interactive Deep-Dive
|
|
10
|
+
|
|
11
|
+
A single-file, zero-dependency illustrated walkthrough of the whole pipeline — signal capture, storage, retrieval, injection, and decay. The figures are not static: the extraction loop, the write-path security gates, the BM25 kernel ported from `src/store/bm25.ts`, and a decay simulator all run live in your browser. It is served from this repo via GitHub Pages:
|
|
12
|
+
|
|
13
|
+
[](https://chenhw7.github.io/dsh-memory/memory-architecture.html)
|
|
14
|
+
|
|
15
|
+
→ **Open the live page: [memory-architecture.html](https://chenhw7.github.io/dsh-memory/memory-architecture.html)** · [简体中文版](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)
|
|
16
|
+
|
|
9
17
|
## Table of Contents
|
|
10
18
|
|
|
19
|
+
- [Interactive Deep-Dive](#interactive-deep-dive)
|
|
11
20
|
- [Features](#features)
|
|
12
21
|
- [Install](#install)
|
|
13
22
|
- [Update](#update)
|
|
@@ -26,18 +35,19 @@ Your dsh agent normally forgets everything when you close a session. This bundle
|
|
|
26
35
|
- **Persistent memory** — facts, preferences, and conventions stored in a durable KV backend with audit logging.
|
|
27
36
|
- **Three-layer scoping** — `global` (cross-project), `project` (per-repo, auto-detected), and `user` (cross-project profile).
|
|
28
37
|
- **Eight model-facing tools** — `memory_search`, `memory_add`, `memory_replace`, `memory_remove`, `memory_list`, `memory_get`, `memory_pin`, `memory_unpin`.
|
|
29
|
-
- **BM25 relevance search** — dependency-free Okapi BM25 over CJK-aware tokenization (Latin word tokens; CJK unigrams + bigrams), pinned entries surfaced ahead of equal-relevance matches.
|
|
30
|
-
- **Automatic learning** — a projection accumulator watches the conversation for explicit remember-intent, corrections, and *verified failure streaks* (repeated same-signature tool failures resolved by a success), then runs LLM extraction when enough candidates accumulate.
|
|
31
|
-
- **In-repo project notes** — coding conventions and a pitfall log render into your repo (`docs/agent-memory/` by default) as git-manageable markdown, inject into every session's system prompt, and stay discoverable via a managed `AGENTS.md` pointer.
|
|
38
|
+
- **BM25 relevance search** — dependency-free Okapi BM25 over CJK-aware tokenization (Latin word tokens; CJK unigrams + bigrams), pinned entries surfaced ahead of equal-relevance matches. Retrieval quality is not vibes: a fixed golden set (24 entries × 24 queries, English + Chinese) is evaluated in CI — success@5 = 100%, MRR = 0.958 — with injection-cost numbers per prompt mode (see [docs/INDEX_MODE_EVALUATION.zh-CN.md](docs/INDEX_MODE_EVALUATION.zh-CN.md)).
|
|
39
|
+
- **Automatic learning** — a projection accumulator watches the conversation for explicit remember-intent, corrections, and *verified failure streaks* (repeated same-signature tool failures resolved by a success), then runs LLM extraction when enough candidates accumulate. Admission rules exclude anything the repository already records (code structure, git history, fixed-bug narratives), and model-handwritten date prefixes are stripped so timestamps always come from the program.
|
|
40
|
+
- **In-repo project notes** — coding conventions and a pitfall log render into your repo (`docs/agent-memory/` by default) as git-manageable markdown, inject into every session's system prompt, and stay discoverable via a managed `AGENTS.md` pointer. A drift guard backs up externally edited notes files instead of silently overwriting them.
|
|
32
41
|
- **Dedup pipeline** — two-stage deduplication (stop-word-filtered Jaccard prefilter + optional LLM judge with bounded merges) prevents near-duplicate accumulation; a low-frequency curator pass re-summarizes oversized entries.
|
|
33
|
-
- **Two-tier memory lifecycle** — pin important memories; overdue project-scoped entries are removed while overdue `global`/`user` entries are soft-decayed (hidden from standing injections, still searchable, un-stamped on recall); every write is audited.
|
|
42
|
+
- **Two-tier memory lifecycle** — pin important memories; overdue project-scoped entries are removed while overdue `global`/`user` entries are soft-decayed (hidden from standing injections, still searchable, un-stamped on recall); entries can also be manually archived from the UI; every write is audited.
|
|
34
43
|
- **Step-level auto recall (opt-in)** — on each agent step, a BM25 search keyed on the step's user text appends a fenced `<recalled-memory>` message without touching the system prompt, keeping the KV-cache prefix stable.
|
|
35
44
|
- **Compaction-aware flush** — when compaction shadows old context, the raw events are scanned for anything worth remembering.
|
|
36
45
|
- **Security scanning, write *and* load time** — API keys, tokens, prompt-injection patterns, and exfiltration attempts are blocked from being saved; anything that slips through is redacted (`[BLOCKED: …]`) wherever it would re-enter a prompt.
|
|
37
46
|
- **Frontend-configurable** — all settings exposed through four cards in the dsh settings UI, apply live.
|
|
38
|
-
- **Optional human review before write** — flip one setting and every extraction
|
|
47
|
+
- **Optional human review before write** — flip one setting (`confirmBeforeWrite`) and every extraction *and* tool write becomes a *proposal* in a pending queue (repeated signals accumulate hits and float up); adopting applies it (with your edits), rejecting discards it. The model never self-promotes: a proposed change to an existing entry rewrites nothing until you accept it.
|
|
39
48
|
- **Memory manager UI** — a dedicated "Memory" section in the dsh settings UI with three tabs: Overview (health dashboard), Review (the pending-proposal queue), and Manage — scope and workspace filters, BM25 search, category chips, a lazily loaded entry list, plus full write actions (edit / pin / archive / delete) — in English and Chinese.
|
|
40
|
-
- **Time-window browsing** — `memory_list` accepts `since`/`until` epoch-ms bounds so "what did we learn last week" pages within the window.
|
|
49
|
+
- **Time-window browsing + smart list view** — `memory_list` returns newest-first with `earliest`/`latest`/`hasStale` metadata, accepts `since`/`until` epoch-ms bounds so "what did we learn last week" pages within the window, and suggests widening the filter when a narrowed query comes back empty over a non-empty store.
|
|
50
|
+
- **Optional summaries for progressive disclosure** — `memory_add`/`memory_replace` accept a `summary`, and extraction can emit a `[summary:…]` tag; index mode and auto-recall render summaries instead of truncated content.
|
|
41
51
|
|
|
42
52
|
## Install
|
|
43
53
|
|
|
@@ -111,8 +121,8 @@ If you'd rather not install from the npm registry, pack a tarball from a checkou
|
|
|
111
121
|
```sh
|
|
112
122
|
cd dsh-memory
|
|
113
123
|
npm install && npm run build
|
|
114
|
-
npm pack # produces chenhw7-dsh-memory-0.
|
|
115
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
124
|
+
npm pack # produces chenhw7-dsh-memory-0.5.0.tgz
|
|
125
|
+
dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
|
|
116
126
|
```
|
|
117
127
|
|
|
118
128
|
## Update
|
|
@@ -205,6 +215,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
205
215
|
| `memoryMode` | `policy-only` | `full`: inject memory content + guidance. `policy-only`: inject guidance only, model searches on demand. `custom`: inject user-defined policy text. `off`: no injection. `index`: inject an existence index (one line per entry) so the model can see what is stored and route to `memory_get`/`memory_search`. |
|
|
206
216
|
| `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
|
|
207
217
|
| `memoryCharLimit` | `5000` | Character budget for the frozen per-session memory snapshot injected in `full` mode (`0` = no content). |
|
|
218
|
+
| `memoryMaxEntries` | `20` | Entry-count cap for the same frozen snapshot (`0` = no limit). The snapshot ends with a `≈N tokens` estimate so injection cost stays visible. |
|
|
208
219
|
| `maxSearchResults` | `50` | Default cap for `memory_search` / `memory_list` when the call omits `limit`; read live by the tool plugin. `0` = no limit. |
|
|
209
220
|
| `decayDays` | `30` | Lifecycle window for entries not recalled within N days; read live by the review plugin's janitor. `0` = disabled. Overdue `project` entries are **removed** (hard decay); overdue `global`/`user` entries are instead **soft-decayed** — stamped `stale`, hidden from injection surfaces and notes files, still searchable, un-stamped automatically once recalled. Pinned entries are always exempt. |
|
|
210
221
|
| `notesEnabled` | `true` | Export project notes (conventions + pitfall log) into the repo and inject them into the system prompt. Entries rendered into the notes files are excluded from the memory section to avoid double injection. |
|
|
@@ -233,6 +244,7 @@ Every namespace resolves in layers: schema defaults → the composition `config:
|
|
|
233
244
|
| `curatorEveryNSessions` | `20` | Run the curator pass every N session creations. |
|
|
234
245
|
| `curatorMaxEntries` | `5` | Max entries selected per curation pass (longest first). |
|
|
235
246
|
| `curatorMinChars` | `400` | Only entries at least this long are selected for re-summarization. |
|
|
247
|
+
| `confirmBeforeWrite` | `false` | Human-review mode: every extraction (review/flush/curator) *and* every `memory_add`/`memory_replace` call lands as a proposal in the pending queue instead of the store, until a human adopts it in the Memory settings section (Review tab). Repeated observations of the same proposal accumulate `hits` and float it to the top; a proposed change to an existing entry carries its id and rewrites nothing until adopted. |
|
|
236
248
|
|
|
237
249
|
> There is deliberately **no separate `tool-memory` settings namespace**: the tool plugin reads `maxSearchResults` live from the `memory` namespace above. Its composition `config.maxSearchResults` only serves as the fallback base when no settings service is mounted.
|
|
238
250
|
|
|
@@ -262,6 +274,7 @@ memory:
|
|
|
262
274
|
memoryMode: policy-only
|
|
263
275
|
memoryPolicyCustomText: ""
|
|
264
276
|
memoryCharLimit: 5000
|
|
277
|
+
memoryMaxEntries: 20
|
|
265
278
|
maxSearchResults: 50
|
|
266
279
|
decayDays: 30
|
|
267
280
|
notesEnabled: true
|
|
@@ -286,6 +299,7 @@ memory-review:
|
|
|
286
299
|
curatorEveryNSessions: 20
|
|
287
300
|
curatorMaxEntries: 5
|
|
288
301
|
curatorMinChars: 400
|
|
302
|
+
confirmBeforeWrite: false
|
|
289
303
|
```
|
|
290
304
|
|
|
291
305
|
`memoryPolicyCustomText` is optional and only used when `memoryMode` is `custom`.
|
|
@@ -319,10 +333,10 @@ The bundle inserts seven rows over `dsh-base`, each pointing at this package's o
|
|
|
319
333
|
| Row | Export | Role |
|
|
320
334
|
|---|---|---|
|
|
321
335
|
| `memory-root` | `@chenhw7/dsh-memory` | No-op root entry for client-module scanner discovery |
|
|
322
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain, registers `ctx.memory` (BM25 search + two-tier decay) |
|
|
323
|
-
| `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools |
|
|
324
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator) and the `memory-review` settings namespace |
|
|
325
|
-
| `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes export (render conventions/pitfalls + atomic write + AGENTS.md pointer), registers `ctx.projectNotes` |
|
|
336
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | Opens the `memory` domain (entries + audit + suggestion-queue tables), registers `ctx.memory` (BM25 search + two-tier decay) |
|
|
337
|
+
| `tool-memory` | `@chenhw7/dsh-memory/tool` | Eight model-facing tools (confirm-mode writes queue as proposals) |
|
|
338
|
+
| `memory-review` | `@chenhw7/dsh-memory/review` | Automatic extraction (projection + failure-streak pitfalls + flush + dedup + janitor + curator + human-review queue) and the `memory-review` settings namespace |
|
|
339
|
+
| `memory-notes` | `@chenhw7/dsh-memory/notes` | Project-notes export (render conventions/pitfalls + atomic write with drift guard + AGENTS.md pointer), registers `ctx.projectNotes` |
|
|
326
340
|
| `memory-context` | `@chenhw7/dsh-memory/context` | System-prompt injection (`memory` @90 + `project-notes` @91), step-level auto recall, owns the `memory` settings namespace |
|
|
327
341
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | `@Remote` service behind the settings UI's Memory section (consumed over the `/api` channel) |
|
|
328
342
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cairn
|
|
2
2
|
|
|
3
3
|
[English](README.md) | **简体中文**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Cairn** 是为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 提供长期记忆能力的 `@chenhw7/dsh-memory` profile bundle —— 事实、偏好、修正和经验在会话与重启后仍然保留。
|
|
6
6
|
|
|
7
7
|
这是一个**自包含的单一包**(不是多包 workspace)。它依赖 dsh 核心服务作为 **peer dependencies**(由你已经安装的 dsh 提供),并通过自带的 `cordis.patch.yml` 让 `dsh plugin add` 将其激活为一个 profile 层。
|
|
8
8
|
|
|
9
|
+
## 交互式技术解析
|
|
10
|
+
|
|
11
|
+
单文件、零依赖的图解技术深潜——完整拆解从信号捕获到存储、检索、注入、衰减的全流水线。图不是静态的:提取循环、写入路径安全闸、从 `src/store/bm25.ts` 移植的 BM25 内核、衰减模拟器,全部在你的浏览器里实时运行。页面由本仓库通过 GitHub Pages 托管:
|
|
12
|
+
|
|
13
|
+
[](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)
|
|
14
|
+
|
|
15
|
+
→ **打开在线页面:[memory-architecture.zh-CN.html](https://chenhw7.github.io/dsh-memory/memory-architecture.zh-CN.html)** · [English version](https://chenhw7.github.io/dsh-memory/memory-architecture.html)
|
|
16
|
+
|
|
9
17
|
## 目录
|
|
10
18
|
|
|
19
|
+
- [交互式技术解析](#交互式技术解析)
|
|
11
20
|
- [功能特性](#功能特性)
|
|
12
21
|
- [安装](#安装)
|
|
13
22
|
- [更新](#更新)
|
|
@@ -23,18 +32,19 @@
|
|
|
23
32
|
- **持久化记忆** — 将事实、偏好和约定存储在持久的 KV 后端中,带审计日志。
|
|
24
33
|
- **三层作用域** — `global`(跨项目)、`project`(按仓库自动检测)、`user`(跨项目 profile)。
|
|
25
34
|
- **八个模型可用工具** — `memory_search`、`memory_add`、`memory_replace`、`memory_remove`、`memory_list`、`memory_get`、`memory_pin`、`memory_unpin`。
|
|
26
|
-
- **BM25 相关性检索** — 零依赖的 Okapi BM25,CJK 感知分词(Latin 逐词;CJK 一元 + 相邻二元 bigram),固定(pin
|
|
27
|
-
- **自动学习** — 投影累加器观察对话中的显式记忆意图、修正语句以及*已验证的失败序列*(同签名连续失败后最终成功),候选足够多时运行 LLM
|
|
28
|
-
- **仓库内项目笔记** — 编码约定与踩坑日志渲染为仓库内可 git 管理的 markdown(默认 `docs/agent-memory/`),每次会话注入 system prompt,并在 `AGENTS.md`
|
|
35
|
+
- **BM25 相关性检索** — 零依赖的 Okapi BM25,CJK 感知分词(Latin 逐词;CJK 一元 + 相邻二元 bigram),固定(pin)条目在同等相关时优先靠前。检索质量不是玄学:固定 golden set(24 条 × 24 组查询,中英混合)在 CI 中实测——success@5 = 100%、MRR = 0.958——并附各注入模式的成本数字(见 [docs/INDEX_MODE_EVALUATION.zh-CN.md](docs/INDEX_MODE_EVALUATION.zh-CN.md))。
|
|
36
|
+
- **自动学习** — 投影累加器观察对话中的显式记忆意图、修正语句以及*已验证的失败序列*(同签名连续失败后最终成功),候选足够多时运行 LLM 提取。准入规则排除一切"仓库已记录的内容"(代码结构、git 历史、已修复 bug 的经过),模型手写的日期前缀会被剥离,时间戳永远由程序盖戳。
|
|
37
|
+
- **仓库内项目笔记** — 编码约定与踩坑日志渲染为仓库内可 git 管理的 markdown(默认 `docs/agent-memory/`),每次会话注入 system prompt,并在 `AGENTS.md` 中维护一行托管指针块供其他工具发现。漂移守卫保证被外部手改过的笔记文件会被备份而非静默覆盖。
|
|
29
38
|
- **去重管线** — 两阶段去重(停用词过滤的 Jaccard 预过滤 + 可选 LLM 裁决,合并长度有上限),防止近似重复条目累积;低频 curator pass 会将过长条目改写为简洁单行。
|
|
30
|
-
- **两层记忆生命周期** — 固定重要记忆;过期的 project 作用域条目被移除,而过期的 `global`/`user`
|
|
39
|
+
- **两层记忆生命周期** — 固定重要记忆;过期的 project 作用域条目被移除,而过期的 `global`/`user` 条目做软衰减(从常驻注入面隐藏但仍可搜索,再次召回即解除);条目也可以从界面手动归档;每次写入都有审计。
|
|
31
40
|
- **步级自动召回(可选)** — 每个 agent step 用该步用户文本对 store 做 BM25 搜索,追加一块带围栏的 `<recalled-memory>` 消息;不触碰 system prompt,保持 KV-cache 前缀稳定。
|
|
32
41
|
- **压缩时自动落盘** — 当压缩使旧上下文失效时,扫描原始事件并保留值得记住的内容。
|
|
33
42
|
- **安全扫描:写入时 + 读取时** — API Key、Token、提示注入模式和泄露尝试会被阻止写入;漏网内容在重新进入 prompt 的任何位置都会被替换为 `[BLOCKED: …]` 占位符。
|
|
34
43
|
- **前端可配置** — 所有设置通过 dsh 设置界面的四张卡片暴露,实时生效。
|
|
35
|
-
- **可选的写入前人工确认** —
|
|
36
|
-
- **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25
|
|
37
|
-
-
|
|
44
|
+
- **可选的写入前人工确认** — 打开一个开关(`confirmBeforeWrite`)后,自动提取*与*工具调用产生的写入一律先进入待确认队列(同一提议反复出现会累计次数并置顶);采纳才落库(可先编辑),拒绝即丢弃。模型永不自我提升:对既有条目的修改提议在你采纳前不会改动原文。
|
|
45
|
+
- **记忆管理中心** — dsh 设置界面新增独立「记忆」区,三个标签页:概览(健康仪表盘)、待确认(提议队列)、管理——作用域与工作区筛选、BM25 搜索、类别筛选、懒加载条目列表,并带完整写操作(编辑 / 置顶 / 归档 / 删除),中英双语。
|
|
46
|
+
- **时间窗浏览 + 智能列表视图** — `memory_list` 默认按最新在前返回,附带 `earliest`/`latest`/`hasStale` 元数据,支持 `since`/`until` 毫秒时间戳边界(「上周学了什么」这类查询直接在窗口内分页);过滤条件命中 0 条但库非空时,会提示放宽过滤条件。
|
|
47
|
+
- **可选摘要(渐进式披露)** — `memory_add`/`memory_replace` 接受 `summary`,提取也可以输出 `[summary:…]` 标签;index 模式与自动召回优先渲染摘要而非截断正文。
|
|
38
48
|
|
|
39
49
|
## 安装
|
|
40
50
|
|
|
@@ -109,8 +119,8 @@ pnpm 不会为 `file:` 依赖运行构建脚本,所以不需要 `allowBuilds`
|
|
|
109
119
|
```sh
|
|
110
120
|
cd dsh-memory
|
|
111
121
|
npm install && npm run build
|
|
112
|
-
npm pack # 生成 chenhw7-dsh-memory-0.
|
|
113
|
-
dsh plugin add --profile web ./chenhw7-dsh-memory-0.
|
|
122
|
+
npm pack # 生成 chenhw7-dsh-memory-0.5.0.tgz
|
|
123
|
+
dsh plugin add --profile web ./chenhw7-dsh-memory-0.5.0.tgz
|
|
114
124
|
```
|
|
115
125
|
|
|
116
126
|
## 更新
|
|
@@ -203,6 +213,7 @@ dsh web
|
|
|
203
213
|
| `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
|
|
204
214
|
| `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
|
|
205
215
|
| `memoryCharLimit` | `5000` | 会话内冻结记忆快照注入 `full` 模式时的字符预算(`0` = 不注入内容)。 |
|
|
216
|
+
| `memoryMaxEntries` | `20` | 同一冻结快照的条目数上限(`0` = 无限制)。快照尾部附 `≈N tokens` 估算,注入成本始终可见。 |
|
|
206
217
|
| `maxSearchResults` | `50` | `memory_search` / `memory_list` 在调用未传 `limit` 时的默认返回条数上限,由工具插件实时读取。`0` = 无限制。 |
|
|
207
218
|
| `decayDays` | `30` | N 天内未召回条目的生命周期窗口,由 review 插件的 janitor 实时读取。`0` = 禁用。过期的 `project` 条目被**移除**(硬衰减);过期的 `global`/`user` 条目改为**软衰减**——打上 `stale` 戳,从注入面和笔记文件中隐藏但仍可搜索,再次召回即自动解除。固定(pin)条目始终豁免。 |
|
|
208
219
|
| `notesEnabled` | `true` | 启用项目笔记的仓库内文件导出与 system prompt 注入。已渲染进笔记文件的条目会从 memory 段落中排除,避免重复注入。 |
|
|
@@ -231,6 +242,7 @@ dsh web
|
|
|
231
242
|
| `curatorEveryNSessions` | `20` | 每 N 次会话创建运行一次 curator pass。 |
|
|
232
243
|
| `curatorMaxEntries` | `5` | 每次 curation 最多选中的条目数(最长优先)。 |
|
|
233
244
|
| `curatorMinChars` | `400` | 只有长度不小于该值的条目才会被选中改写。 |
|
|
245
|
+
| `confirmBeforeWrite` | `false` | 人审模式:所有提取(review/flush/curator)*与*每次 `memory_add`/`memory_replace` 调用都改为在待确认队列中生成提议,而非直接写库,直到有人在设置「记忆」区(待确认页)采纳。同一提议被反复观察会累计 `hits` 并置顶;对既有条目的修改提议携带其 id,在人工采纳前不会改动原文。 |
|
|
234
246
|
|
|
235
247
|
> 特意**没有独立的 `tool-memory` 设置命名空间**:工具插件从上面的 `memory` 命名空间实时读取 `maxSearchResults`。其组合配置 `config.maxSearchResults` 仅作为无 settings 服务挂载时的回退 base。
|
|
236
248
|
|
|
@@ -260,6 +272,7 @@ memory:
|
|
|
260
272
|
memoryMode: policy-only
|
|
261
273
|
memoryPolicyCustomText: ""
|
|
262
274
|
memoryCharLimit: 5000
|
|
275
|
+
memoryMaxEntries: 20
|
|
263
276
|
maxSearchResults: 50
|
|
264
277
|
decayDays: 30
|
|
265
278
|
notesEnabled: true
|
|
@@ -284,6 +297,7 @@ memory-review:
|
|
|
284
297
|
curatorEveryNSessions: 20
|
|
285
298
|
curatorMaxEntries: 5
|
|
286
299
|
curatorMinChars: 400
|
|
300
|
+
confirmBeforeWrite: false
|
|
287
301
|
```
|
|
288
302
|
|
|
289
303
|
`memoryPolicyCustomText` 是可选的,仅在 `memoryMode` 为 `custom` 时使用。
|
|
@@ -317,10 +331,10 @@ memory:
|
|
|
317
331
|
| 行 | 导出 | 作用 |
|
|
318
332
|
|---|---|---|
|
|
319
333
|
| `memory-root` | `@chenhw7/dsh-memory` | 无操作根条目,供 client-module 扫描器发现 |
|
|
320
|
-
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory`
|
|
321
|
-
| `tool-memory` | `@chenhw7/dsh-memory/tool` |
|
|
322
|
-
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator
|
|
323
|
-
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 +
|
|
334
|
+
| `memory-store` | `@chenhw7/dsh-memory/store` | 打开 `memory` 域(entries + audit + 待确认队列三张表),注册 `ctx.memory`(BM25 检索 + 两层衰减) |
|
|
335
|
+
| `tool-memory` | `@chenhw7/dsh-memory/tool` | 八个模型可用工具(人审模式下写入改为入队) |
|
|
336
|
+
| `memory-review` | `@chenhw7/dsh-memory/review` | 自动提取(投影 + 失败序列踩坑 + flush + 去重 + janitor + curator + 人审队列),持有 `memory-review` 设置命名空间 |
|
|
337
|
+
| `memory-notes` | `@chenhw7/dsh-memory/notes` | 项目笔记导出(渲染约定/踩坑 + 带漂移守卫的原子写 + AGENTS.md 指针),注册 `ctx.projectNotes` |
|
|
324
338
|
| `memory-context` | `@chenhw7/dsh-memory/context` | 系统提示注入(`memory` @90 + `project-notes` @91)、步级自动召回,持有 `memory` 设置命名空间 |
|
|
325
339
|
| `memory-remote` | `@chenhw7/dsh-memory/remote-service` | 记忆管理 UI 的 `@Remote` 服务(设置「记忆」区经 `/api` 通道消费) |
|
|
326
340
|
|
package/lib/notes/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@chenhw7/dsh-memory/notes`: the project-notes exporter (docs/PROJECT_NOTES.md).
|
|
2
|
+
* `@chenhw7/dsh-memory/notes`: the project-notes exporter (docs/PROJECT_NOTES.zh-CN.md).
|
|
3
3
|
* A function plugin that renders habit/convention/pitfall entries from the
|
|
4
4
|
* memory store into in-repo markdown files (`docs/agent-memory/` by default)
|
|
5
5
|
* and maintains an AGENTS.md pointer block.
|
package/lib/notes/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAWlD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC5J,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAA;AAC1L,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAElC,4EAA4E;AAC5E,eAAO,MAAM,MAAM,EAAE,MAAM,EAAO,CAAA;AAQlC;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAKD;;;;GAIG;AACH,8BAAsB,mBAAmB;IACvC,cAIC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,oBAAoB,CAAA;CACpE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;Q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xC"}
|
package/lib/notes/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@chenhw7/dsh-memory/notes`: the project-notes exporter (docs/PROJECT_NOTES.md).
|
|
2
|
+
* `@chenhw7/dsh-memory/notes`: the project-notes exporter (docs/PROJECT_NOTES.zh-CN.md).
|
|
3
3
|
* A function plugin that renders habit/convention/pitfall entries from the
|
|
4
4
|
* memory store into in-repo markdown files (`docs/agent-memory/` by default)
|
|
5
5
|
* and maintains an AGENTS.md pointer block.
|
|
@@ -18,7 +18,7 @@ import { scanContent } from '../scanner.js';
|
|
|
18
18
|
import { isRenderedEntry } from './scope.js';
|
|
19
19
|
import { renderConventions, renderPitfalls } from './render.js';
|
|
20
20
|
import { ensureAgentsPointer, writeNotesFile, DriftError } from './writer.js';
|
|
21
|
-
import { resolveNotesSettings } from './settings.js';
|
|
21
|
+
import { resolveNotesSettings, resolveNotesDir } from './settings.js';
|
|
22
22
|
export { isRenderedEntry } from './scope.js';
|
|
23
23
|
export { renderConventions, renderPitfalls } from './render.js';
|
|
24
24
|
export { ensureAgentsPointer, writeFileAtomic, writeNotesFile, DriftError, agentsPointerBlock, AGENTS_POINTER_BEGIN, AGENTS_POINTER_END } from './writer.js';
|
|
@@ -60,6 +60,8 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
60
60
|
driftReported = new Set();
|
|
61
61
|
/** Last store health timestamp already rendered, for the dirty check. */
|
|
62
62
|
renderedHealthTs;
|
|
63
|
+
/** notesDir values already reported as escaping the project root (log-once). */
|
|
64
|
+
traversalReported = new Set();
|
|
63
65
|
/** Debounce timer for activity-triggered re-renders. */
|
|
64
66
|
timer;
|
|
65
67
|
constructor(ctx, settings) {
|
|
@@ -132,7 +134,17 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
132
134
|
}
|
|
133
135
|
/** Persist the snapshot atomically when it differs from the last write. */
|
|
134
136
|
persist(cwd, snapshot, settings) {
|
|
135
|
-
const dir =
|
|
137
|
+
const dir = resolveNotesDir(cwd, settings.notesDir);
|
|
138
|
+
if (dir === undefined) {
|
|
139
|
+
// Containment: an escaping notesDir must never direct writes outside
|
|
140
|
+
// the project. Rendered snapshots keep flowing to the prompt; only the
|
|
141
|
+
// file persistence is skipped.
|
|
142
|
+
if (!this.traversalReported.has(settings.notesDir)) {
|
|
143
|
+
this.traversalReported.add(settings.notesDir);
|
|
144
|
+
console.warn(`[dsh-memory] notesDir "${settings.notesDir}" resolves outside the project root; skipping notes persistence for it.`);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
136
148
|
const previous = this.persisted.get(dir);
|
|
137
149
|
if (previous !== undefined && previous.conventions === snapshot.conventions && previous.pitfalls === snapshot.pitfalls) {
|
|
138
150
|
return;
|
package/lib/notes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAmB,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAE,oBAAoB,EAAsB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,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pC,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/notes/scope.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The scope×category render matrix for project notes (§4 of
|
|
3
|
-
* docs/PROJECT_NOTES.md): which store entries land in the notes files.
|
|
3
|
+
* docs/PROJECT_NOTES.zh-CN.md): which store entries land in the notes files.
|
|
4
4
|
* Pure functions, zero host imports — shared by the notes renderer and by
|
|
5
5
|
* `memory-context` (which excludes the same set from its own snapshot/index
|
|
6
6
|
* injection so content never appears twice in the prompt).
|
|
@@ -18,7 +18,7 @@ export type RenderableEntry = Pick<MemoryEntry, 'scope' | 'category' | 'projectN
|
|
|
18
18
|
export type NotesKind = 'conventions' | 'pitfalls';
|
|
19
19
|
/**
|
|
20
20
|
* Decide whether an entry is rendered into the notes files, and into which
|
|
21
|
-
* one. Rules (docs/PROJECT_NOTES.md §4):
|
|
21
|
+
* one. Rules (docs/PROJECT_NOTES.zh-CN.md §4):
|
|
22
22
|
* - `project`-scoped entries must match the current project name; an unknown
|
|
23
23
|
* project (no cwd) excludes them.
|
|
24
24
|
* - Conventions come from all three scopes (project > global > personal is
|
package/lib/notes/scope.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The scope×category render matrix for project notes (§4 of
|
|
3
|
-
* docs/PROJECT_NOTES.md): which store entries land in the notes files.
|
|
3
|
+
* docs/PROJECT_NOTES.zh-CN.md): which store entries land in the notes files.
|
|
4
4
|
* Pure functions, zero host imports — shared by the notes renderer and by
|
|
5
5
|
* `memory-context` (which excludes the same set from its own snapshot/index
|
|
6
6
|
* injection so content never appears twice in the prompt).
|
|
@@ -13,7 +13,7 @@ export const NOTES_CONVENTION_CATEGORIES = ['convention', 'preference'];
|
|
|
13
13
|
export const NOTES_PITFALL_CATEGORIES = ['failure', 'procedure', 'tool-quirk'];
|
|
14
14
|
/**
|
|
15
15
|
* Decide whether an entry is rendered into the notes files, and into which
|
|
16
|
-
* one. Rules (docs/PROJECT_NOTES.md §4):
|
|
16
|
+
* one. Rules (docs/PROJECT_NOTES.zh-CN.md §4):
|
|
17
17
|
* - `project`-scoped entries must match the current project name; an unknown
|
|
18
18
|
* project (no cwd) excludes them.
|
|
19
19
|
* - Conventions come from all three scopes (project > global > personal is
|
package/lib/notes/settings.d.ts
CHANGED
|
@@ -32,4 +32,14 @@ export interface NotesSettings {
|
|
|
32
32
|
* @returns the fully-resolved notes settings.
|
|
33
33
|
*/
|
|
34
34
|
export declare function resolveNotesSettings(value: unknown): NotesSettings;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve `notesDir` against the project root, requiring containment: absolute
|
|
37
|
+
* values and `../`-style escapes resolve outside the root and are rejected, so
|
|
38
|
+
* a mistyped or hostile settings value cannot direct notes writes out of the
|
|
39
|
+
* project. Lexical check only — symlinks are not resolved.
|
|
40
|
+
* @param cwd - the project root (session working directory).
|
|
41
|
+
* @param notesDir - the settings value (repo-relative by convention).
|
|
42
|
+
* @returns the absolute contained directory, or undefined when rejected.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveNotesDir(cwd: string, notesDir: string): string | undefined;
|
|
35
45
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,OAAO,CAAA;AACzC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,sBAAsB,CAAA;AACpD,6DAA6D;AAC7D,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAC5C,yDAAyD;AACzD,eAAO,MAAM,4BAA4B,OAAO,CAAA;AAChD,0EAA0E;AAC1E,eAAO,MAAM,kCAAkC,MAAM,CAAA;AAErD,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;IACpC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;CACxC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CASlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKjF"}
|
package/lib/notes/settings.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @chenhw7/dsh-memory/notes/settings
|
|
9
9
|
*/
|
|
10
|
+
import path from 'node:path';
|
|
10
11
|
/** Whether notes export + injection are enabled. */
|
|
11
12
|
export const DEFAULT_NOTES_ENABLED = true;
|
|
12
13
|
/** Repo-relative directory holding the generated notes files. */
|
|
@@ -33,4 +34,20 @@ export function resolveNotesSettings(value) {
|
|
|
33
34
|
notesMaxEntriesPerFile: typeof v.notesMaxEntriesPerFile === 'number' && v.notesMaxEntriesPerFile >= 0 ? Math.trunc(v.notesMaxEntriesPerFile) : DEFAULT_NOTES_MAX_ENTRIES_PER_FILE,
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve `notesDir` against the project root, requiring containment: absolute
|
|
39
|
+
* values and `../`-style escapes resolve outside the root and are rejected, so
|
|
40
|
+
* a mistyped or hostile settings value cannot direct notes writes out of the
|
|
41
|
+
* project. Lexical check only — symlinks are not resolved.
|
|
42
|
+
* @param cwd - the project root (session working directory).
|
|
43
|
+
* @param notesDir - the settings value (repo-relative by convention).
|
|
44
|
+
* @returns the absolute contained directory, or undefined when rejected.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveNotesDir(cwd, notesDir) {
|
|
47
|
+
const root = path.resolve(cwd);
|
|
48
|
+
const dir = path.resolve(root, notesDir);
|
|
49
|
+
if (dir !== root && !dir.startsWith(root + path.sep))
|
|
50
|
+
return undefined;
|
|
51
|
+
return dir;
|
|
52
|
+
}
|
|
36
53
|
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AACzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AACpD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAA;AAC5C,yDAAyD;AACzD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAA;AAChD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAA;AAWrD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAA;IAC/F,OAAO;QACL,Y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,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACxC,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACtE,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* the {@link agent/pre-step} listener drains the accumulator once it reaches
|
|
5
5
|
* the configured threshold and runs one extraction call.
|
|
6
6
|
*
|
|
7
|
-
* Signal sources (§5 of docs/PROJECT_NOTES.md):
|
|
7
|
+
* Signal sources (§5 of docs/PROJECT_NOTES.zh-CN.md):
|
|
8
8
|
* - `user/message` — keyword hits (explicit "remember" intent) and corrections
|
|
9
9
|
* (the user revises a prior statement).
|
|
10
10
|
* - `tool/call` + `tool/result` — **failure-streak pairing**: consecutive
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* the {@link agent/pre-step} listener drains the accumulator once it reaches
|
|
5
5
|
* the configured threshold and runs one extraction call.
|
|
6
6
|
*
|
|
7
|
-
* Signal sources (§5 of docs/PROJECT_NOTES.md):
|
|
7
|
+
* Signal sources (§5 of docs/PROJECT_NOTES.zh-CN.md):
|
|
8
8
|
* - `user/message` — keyword hits (explicit "remember" intent) and corrections
|
|
9
9
|
* (the user revises a prior statement).
|
|
10
10
|
* - `tool/call` + `tool/result` — **failure-streak pairing**: consecutive
|
package/package.json
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenhw7/dsh-memory",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Cairn — long-term memory for the DeepSeek Harness: persistent cross-session memory (store, tools, auto-extraction, context injection) as one installable profile bundle",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"homepage": "https://chenhw7.github.io/dsh-memory/",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/chenhw7/dsh-memory.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"deepseek-harness",
|
|
13
|
+
"dsh",
|
|
14
|
+
"memory",
|
|
15
|
+
"long-term-memory",
|
|
16
|
+
"agent-memory",
|
|
17
|
+
"cross-session",
|
|
18
|
+
"bm25",
|
|
19
|
+
"llm-agents",
|
|
20
|
+
"plugin"
|
|
21
|
+
],
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/chenhw7/dsh-memory/issues"
|
|
24
|
+
},
|
|
6
25
|
"main": "lib/index.js",
|
|
7
26
|
"types": "lib/index.d.ts",
|
|
8
27
|
"exports": {
|