dsh-engramory 1.3.0 → 1.4.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.
Files changed (5) hide show
  1. package/README.en.md +271 -254
  2. package/README.md +145 -141
  3. package/client.js +1376 -1202
  4. package/index.js +3495 -3402
  5. package/package.json +79 -79
package/README.en.md CHANGED
@@ -1,254 +1,271 @@
1
- [简体中文](README.md) | **English**
2
-
3
- # dsh-engramory
4
-
5
- [![dsh-xray](https://img.shields.io/endpoint?url=https%3A%2F%2Funstone.github.io%2Fdsh-xray%2Fbadge%2Ftinqiao-oss__engramory.json)](https://unstone.github.io/dsh-xray/registry.html#tinqiao-oss__engramory)
6
-
7
- Long-term memory for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
8
- (dsh). What the AI remembers is kept as plain markdown files you can open and edit
9
- at any time. It is the dsh build of [Engramory](https://github.com/tinqiao-oss/engramory),
10
- which is general-purpose agent memory: Claude Code, Codex and others can use the same store.
11
-
12
- ![The memory page](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/memory-page.png)
13
-
14
- ## What it does
15
-
16
- - **The memory index comes along by itself.** The index, `MEMORY.md`, lists the notes
17
- by name. The plugin brings it into the conversation as a message, so the AI knows
18
- what it has saved without reading a file first, and opens a note when it needs the
19
- detail. It is sent again only when it changes (a write, another project, a
20
- compacted conversation): a write shows up on the next request, and a long
21
- conversation does not fill up with copies of it ([social mode](#social-mode) keeps it
22
- in dsh's runtime context, as before). Whatever is past the cap is left out, and the AI
23
- is told to compact.
24
- - **The index has a hard cap.** 200 lines / 25 KB by default. When the AI writes the
25
- index with dsh's file tools and the plugin can work out the result, a write that
26
- would grow it past the cap is refused before it happens, and the AI is told to
27
- compact; compaction still passes. Details in [How the cap decides](#how-the-cap-decides).
28
- - **The rules come with it.** What to save, how, and when to clean up: the rules
29
- (a skill) are registered by the plugin, with no files to install.
30
- - **A reminder to save before dsh compacts.** When a conversation grows long, dsh
31
- compacts what came before into a summary, which need not keep what is worth
32
- remembering later. As a conversation nears that point, the plugin reminds the AI to
33
- save that first; the AI is reminded, not you.
34
- - **A Memory page in the sidebar.** Read-only; it lists the notes by name and opens
35
- one in your computer's default app, with a check-up that flags broken links in the
36
- index and notes left out of it.
37
-
38
- ## Install
39
-
40
- Needs Node.js 18+ and `pnpm` on PATH (dsh's plugin command uses it). In dsh's desktop
41
- app you can also search for `dsh-engramory` on the Plugins page.
42
-
43
- ```sh
44
- dsh plugin --profile <name> add dsh-engramory
45
- ```
46
-
47
- To uninstall, use `remove` instead of `add`. Compatible dsh releases are listed in
48
- `dsh.compatibility.dshReleases` in [`package.json`](https://github.com/tinqiao-oss/engramory/blob/master/adapters/dsh/plugin/package.json); an unlisted release
49
- is unverified.
50
-
51
- **Where the memory lives:**
52
-
53
- - **The global store**, `~/.dsh/.engramory-memory/` (under `$DSH_HOME` when it is set).
54
- With the plugin alone this is the only store; the AI creates it on its first save.
55
- - **A project store** (optional), `.engramory-memory/` in a project's root, is created
56
- by you only: run `python tools/engramory_init.py dsh --project-root <project>` from
57
- the Engramory repo, which also git-ignores it. Where one exists, what holds only in
58
- that project goes there; everything else stays in the global store.
59
-
60
- Only one AI may write a store; two writers overwrite each other. To share it, let the
61
- others read it only: see [one writer, many readers](https://github.com/tinqiao-oss/engramory/blob/master/adapters/reader/README.md). Memories are plain text and carry machine-local detail. Inside a project's git repo
62
- the store must be git-ignored; a dedicated private repo for the store is fine.
63
-
64
- **Without the plugin:** `python tools/engramory_init.py dsh --install-skill` writes the
65
- rules into `$DSH_HOME/AGENTS.md`, installs the skill in `$DSH_HOME/skills/engramory/`
66
- (`$DSH_HOME` defaults to `~/.dsh`) and creates the global store. The AI still keeps memory, but reads the index itself, and
67
- the cap holds only if it runs `engramory_check.py` after each write.
68
-
69
- ## Companion mode (大肥鱼模式)
70
-
71
- For a character you chat with: the community's 大肥鱼, or any persona. Turn on the
72
- companion switch on the settings page, or set `companion: true`.
73
-
74
- ![The memory page in companion mode](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/companion-mode.png)
75
-
76
- - **Three more types for the character's own life** ([SKILL.md §2.2](https://github.com/tinqiao-oss/engramory/blob/master/SKILL.md)):
77
- `moment`, something you shared, with its date, folded into a monthly archive when
78
- the index fills; `upcoming`, something coming up in your life, asked about once its
79
- date passes and rewritten as a moment once you say how it went; `self`, a change in
80
- the character itself, such as a nickname. A moment or self note is deleted only when
81
- you ask it to forget.
82
- - **Recall in character.** Even a greeting may call for recall, and what it remembered,
83
- or failed to save, is told in the character's voice, without naming files or tools.
84
- - **The persona preset needs the file tools.** The memory arrives even under a preset
85
- that turns optional context off (dsh's `minimal`, for one; from dsh 0.2 — 0.1 then sends
86
- no runtime context at all). To save notes, though, the
87
- preset needs dsh's file tools and the skill tool; a preset with only a shell reads the
88
- memory, and its writes go past the cap.
89
-
90
- ## Social mode
91
-
92
- A choice inside companion mode, for a character other people can talk to as well, such
93
- as one wired to QQ, WeChat, Douyin or Bilibili through a bridge plugin. Choose *Social*
94
- under *Memory access* on the settings page, or set `audience: social`. If only you talk
95
- to this dsh, keep the default, *Private*.
96
-
97
- With it on, **only your own conversations get the memory**: one is yours when you have
98
- typed in it in dsh's own window (the desktop app or `dsh web`) and nobody else has.
99
- A subagent goes with its parent. Messages from a bridge plugin (unless it marks them as
100
- the owner's, below), `dsh headless`, other programs, and terminal or editor clients
101
- count as someone else's. Once anyone else has written in a conversation it stays
102
- theirs, and the memory already put into it stays in its history.
103
-
104
- Someone else's conversation gets no index and is not told where the store is; dsh's
105
- file tools there may name files only (every directory is refused), and any path into
106
- a store is refused however it is spelled. This is **not** a security boundary: a shell
107
- tool reads any file, and another profile on the same account can read the store too.
108
- Real isolation needs filesystem permissions or a sandbox. A custom `skill` (see
109
- [Configuration](#configuration)) reaches every conversation as written, someone else's
110
- included, so if it says where the store is, they are told too.
111
-
112
- ### For bridge authors
113
-
114
- With social mode on, every message a bridge submits counts as someone else's. For a
115
- message from the owner's own account (their private QQ chat with the character, say),
116
- put a `speaker` on its source:
117
-
118
- ```js
119
- agent.followup(createUserMessage({
120
- content: [{ type: 'text', text }],
121
- source: { kind: 'plugin:your-bridge', speaker: { role: 'owner' } },
122
- }))
123
- ```
124
-
125
- | `speaker.role` | Meaning |
126
- |---|---|
127
- | `owner` | The owner wrote it: it comes from the account the user set as theirs in your bridge. |
128
- | `guest` | Someone else wrote it, the same as no `speaker` at all. |
129
- | `none` | Nobody wrote it: your plugin's own report, reminder or notice. It does not make the owner's conversation someone else's. |
130
-
131
- In a group chat, add `chat: 'group'` (`{ role: 'owner', chat: 'group' }`): the whole
132
- group reads the reply, so the conversation counts as someone else's even while only the
133
- owner has spoken in it. A private chat may say `chat: 'private'` or leave it out; any
134
- other value counts as a group. A group conversation stays someone else's once anyone else in it
135
- speaks. A program that talks to dsh only through dsh web's API cannot set a source, so its messages count
136
- as someone else's; if it sends `clientTimeZone` with a prompt it is taken for the
137
- owner, so a program forwarding other people's messages must leave it out.
138
-
139
- ## Settings page and memory page
140
-
141
- ![The settings page](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/settings-page.png)
142
-
143
- - **Settings page:** on dsh's *Plugins* page, open *Engramory memory* to set companion
144
- mode, memory access and the index cap. Saving goes through dsh's own profile editor,
145
- which writes your profile's `cordis.patch.yml` and reloads the plugin. Only you, signed
146
- in, can call it, so an agent cannot use it to switch social mode off.
147
- - **Memory page:** *Memory* in the sidebar. A banner at the top says how many notes,
148
- stores and archived files are listed and when they were read, with the switches
149
- (companion mode, and memory access once it is on) that save as you flip them. Below it,
150
- tabs by note type and a filter by name, over the global store and each workspace's
151
- project store (with an absolute `indexPath`, that store alone; with a relative one,
152
- none). Each note is a row: a mark for its type, its name, its type and size; a plan's
153
- row gives its day and how far off it is (a passed date is an outcome to confirm, as a
154
- reminder: nothing is archived), and a note past 12 KB or one the index leaves out is
155
- marked. Beside each store's name: its index fill as a bar (to the nearer of its two
156
- caps), *Open the index* and *Open the folder*. What its check-up finds is listed under
157
- it: the index's links to files that are not there, the notes not in the index (recall
158
- starts from the index, so the AI will not find them unless another note links to
159
- them), notes with no type, notes past 12 KB, an index over the cap; *Copy tidy-up
160
- instructions* copies a request for the AI to paste into a conversation, and the plugin
161
- itself changes no file. The check-up goes by file names and the index's links alone,
162
- never through a symbolic link, and is skipped when the index is over the cap, there is
163
- too much to check, or a file cannot be read; `engramory_doctor.py` still does the full
164
- check. Where the listing was cut short or a store could not be read, the page says so,
165
- rather than counting that as nothing. Read-only, never a note's text; a name, *Open
166
- the index* and *Open the folder* open on the machine dsh runs on; a machine with no
167
- desktop (a headless server, a session over SSH) shows none of them. A short *How to use
168
- it* follows, open while there is no memory yet. At the foot, where to send feedback: a
169
- new GitHub issue (its body pre-filled with the plugin's version and the OS family, no
170
- path and no note), or an email, with a button that copies the address.
171
-
172
- ## Configuration
173
-
174
- Settings the page does not cover go in your profile's `cordis.patch.yml`. Patch the
175
- EXISTING row by id; a second `- insert:` adds another engramory row and leaves the old
176
- caps in force. A patch replaces the row's whole `config`, so list every key you keep:
177
-
178
- ```yaml
179
- - id: engramory
180
- config:
181
- indexName: MEMORY.md
182
- maxLines: 200
183
- maxBytes: 25600
184
- ```
185
-
186
- | Field | Default | Meaning |
187
- |---|---|---|
188
- | `indexName` | `MEMORY.md` | The file name treated as the index. The cap matches it case-insensitively; sending the index needs the exact name on a case-sensitive filesystem (Linux, say). |
189
- | `maxLines` | `200` | Line cap for the index. |
190
- | `maxBytes` | `25600` | UTF-8 byte cap for the index (25 KB). |
191
- | `indexPath` | unset | The one index to use: absolute, or relative to the session's directory. Unset, a `MEMORY.md` in any project is capped as an index; a store outside the default places also needs it to be found. |
192
- | `registerSkill` | `true` | `false` skips the built-in rules; the cap and the index sent along stay. |
193
- | `injectIndex` | `true` | `false` stops sending the index; the AI reads it instead. |
194
- | `compactionReminder` | `true` | `false` stops the reminder to save before dsh compacts. The plugin works out where dsh will compact from dsh's own compaction settings (on dsh 0.2 with DeepSeek's defaults, about 69% of the window, not 80%) and reminds at 85% of that. A best effort: a conversation that grows past the gap in one step goes unreminded; with no compaction, or automatic compaction off, there is no reminder. |
195
- | `language` | dsh's | `zh` (or `zh-CN` and other regional forms) writes the store in Chinese: note names, headings such as `## 用户`, the Why/How labels. Any other string is English; a value that is not a string, or is empty, counts as unset. Unset, it follows dsh's language; a change applies once dsh restarts. Frontmatter keys and `type:` values stay English, so every host reads the store. |
196
- | `companion` | `false` | `true` turns companion mode on. |
197
- | `audience` | `private` | With companion mode on, `social` turns social mode on. |
198
- | `skill` | built-in | Your own markdown in place of the built-in rules; it must then say where the store is. In social mode, others' conversations see it too. |
199
-
200
- ## How the cap decides
201
-
202
- | Case | Decision |
203
- |---|---|
204
- | The index ends within the caps | allow |
205
- | The write grows the index past a cap | **deny**, with the numbers and what to compact |
206
- | The index is over a cap and the write shrinks it or keeps its size | allow, so compaction can go step by step (210 → 205 → 198) |
207
- | A partial edit whose result can be worked out: `edit` (`old_string`/`new_string`), `str_replace_editor`'s replace (`old_str`/`new_str`) and `insert` | its result is worked out first, then judged as above; each tool from the arguments it uses and the way it matches |
208
- | A partial edit whose result cannot be worked out (arguments missing or not recognised) | deny on an over-cap index, else allow |
209
- | The index is missing, unreadable, or not a regular file | a whole-file write is judged as if it were empty; a partial edit passes |
210
- | The index is past the read limit (`min(16 MiB, max(1 MiB, 4 × maxBytes))`) | not read whole: a whole-file write is judged on bytes alone; a partial edit passes |
211
- | Reads, writes to other files, unknown tools or arguments | allow; reads are never blocked, even over the cap |
212
-
213
- Lines and bytes are judged apart: only a dimension that is over its cap AND grew is
214
- refused, so a write with fewer bytes but lines grown past the cap is still refused.
215
- The line count ignores a trailing newline, so an index exactly at the cap stays
216
- writable. This table is pinned by `node --test` in CI.
217
-
218
- ## Known limits
219
-
220
- - **Only dsh's file tools are capped:** `write`, `edit`, and the `str_replace_editor`
221
- some versions and presets carry; a tool of the same name from another plugin is
222
- judged the same way. Shell tools, MCP file tools and external editors go past it: run
223
- `engramory_check.py` after editing the index and `engramory_doctor.py` now and then.
224
- - **Stores are found only where the installer puts them.** Elsewhere, or for a project
225
- store that links out of the project, set `indexPath`. A project's root is found by
226
- its `.git` only, and a project store created mid-session can take ten seconds to appear.
227
- - **Social mode knows you by what dsh's window sends.** Apart from a bridge's owner
228
- messages, only what you type in dsh's own window is yours, and not when the browser's
229
- time zone cannot be read. A kind of
230
- message a later dsh adds counts as someone else's until this plugin knows it: your
231
- conversation may lose the memory, never the other way round.
232
- - **What the memory page opens is checked by path.** dsh's opener resolves the path once
233
- more before the desktop opens it, so a process changing the store's files at that
234
- moment could redirect what opens (as with dsh's own opener for any workspace file).
235
- - **Experimental:** companion mode, social mode, and the settings and memory pages may
236
- change in a minor version.
237
-
238
- ## Feedback
239
-
240
- For a problem or an idea, [open an issue on GitHub](https://github.com/tinqiao-oss/engramory/issues/new)
241
- or email engramory@agent.qq.com. Emails are sorted with the help of an AI assistant, and issues
242
- are public: do not paste your memory notes into either.
243
-
244
- ## Versions
245
-
246
- This package carries Engramory's version: `dsh-engramory@X.Y.Z` is the repo's
247
- `vX.Y.Z`. The cap's decisions (the table above) and the settings outside the
248
- experimental features change incompatibly only in a major version. See Engramory's
249
- [Versioning](https://github.com/tinqiao-oss/engramory/blob/master/README.en.md#versioning); history is in the
250
- [CHANGELOG](https://github.com/tinqiao-oss/engramory/blob/master/CHANGELOG.md).
251
-
252
- ## License
253
-
254
- MIT — see the [Engramory repository](https://github.com/tinqiao-oss/engramory).
1
+ [简体中文](README.md) | **English**
2
+
3
+ # dsh-engramory
4
+
5
+ [![dsh-xray](https://img.shields.io/endpoint?url=https%3A%2F%2Funstone.github.io%2Fdsh-xray%2Fbadge%2Ftinqiao-oss__engramory.json)](https://unstone.github.io/dsh-xray/registry.html#tinqiao-oss__engramory)
6
+
7
+ Long-term memory for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
8
+ (dsh). What the AI remembers is kept as plain markdown files you can open and edit
9
+ at any time. It is the dsh build of [Engramory](https://github.com/tinqiao-oss/engramory),
10
+ which is general-purpose agent memory: Claude Code, Codex and others can use the same store.
11
+
12
+ ![The memory page](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/memory-page.png)
13
+
14
+ ## What it does
15
+
16
+ - **The memory index comes along by itself.** The index, `MEMORY.md`, lists the notes
17
+ by name. The plugin brings it into the conversation as a message, so the AI knows
18
+ what it has saved without reading a file first, and opens a note when it needs the
19
+ detail. It is sent again only when it changes (a write, another project, a
20
+ compacted conversation): a write shows up on the next request, and a long
21
+ conversation does not fill up with copies of it ([social mode](#social-mode) keeps it
22
+ in dsh's runtime context, as before). Whatever is past the cap is left out, and the AI
23
+ is told to compact.
24
+ - **The index has a hard cap.** 200 lines / 25 KB by default. When the AI writes the
25
+ index with dsh's file tools and the plugin can work out the result, a write that
26
+ would grow it past the cap is refused before it happens, and the AI is told to
27
+ compact; compaction still passes. Details in [How the cap decides](#how-the-cap-decides).
28
+ - **The rules come with it.** What to save, how, and when to clean up: the rules
29
+ (a skill) are registered by the plugin, with no files to install.
30
+ - **A reminder to save before dsh compacts.** When a conversation grows long, dsh
31
+ compacts what came before into a summary, which need not keep what is worth
32
+ remembering later. As a conversation nears that point, the plugin reminds the AI to
33
+ save that first; the AI is reminded, not you.
34
+ - **A Memory page in the sidebar.** Read-only; it lists the notes by name and opens
35
+ one in your computer's default app, with a check-up that flags broken links in the
36
+ index and notes left out of it.
37
+
38
+ ## Install
39
+
40
+ Needs Node.js 22.12+ (what dsh itself needs) and `pnpm` on PATH (dsh's plugin command uses
41
+ it). In dsh's desktop app you can also search for `dsh-engramory` on the Plugins page.
42
+
43
+ ```sh
44
+ dsh plugin --profile <name> add dsh-engramory
45
+ ```
46
+
47
+ To uninstall, use `remove` instead of `add`.
48
+
49
+ **Name the version to upgrade**, as in `dsh plugin --profile <name> add
50
+ dsh-engramory@1.4.0`: by name alone, pnpm 11 (the desktop app's own included) by default
51
+ installs only a version published at least 24 hours ago. The desktop app's Plugins page has no *Update*
52
+ for a plugin from outside dsh: uninstall it, search for `dsh-engramory@<version>` and
53
+ install that, then quit dsh from the tray and open it again. Your memory and settings stay.
54
+ *Check for updates* at the foot of the memory page finds the latest version and lists
55
+ these steps.
56
+
57
+ Compatible dsh releases are listed in
58
+ `dsh.compatibility.dshReleases` in [`package.json`](https://github.com/tinqiao-oss/engramory/blob/master/adapters/dsh/plugin/package.json); an unlisted release
59
+ is unverified.
60
+
61
+ **Where the memory lives:**
62
+
63
+ - **The global store**, `~/.dsh/.engramory-memory/` (under `$DSH_HOME` when it is set).
64
+ With the plugin alone this is the only store; the AI creates it on its first save.
65
+ - **A project store** (optional), `.engramory-memory/` in a project's root, is created
66
+ by you only: run `python tools/engramory_init.py dsh --project-root <project>` from
67
+ the Engramory repo, which also git-ignores it. Where one exists, what holds only in
68
+ that project goes there; everything else stays in the global store.
69
+
70
+ Only one AI may write a store; two writers overwrite each other. To share it, let the
71
+ others read it only: see [one writer, many readers](https://github.com/tinqiao-oss/engramory/blob/master/adapters/reader/README.md). Memories are plain text and carry machine-local detail. Inside a project's git repo
72
+ the store must be git-ignored; a dedicated private repo for the store is fine.
73
+
74
+ **Without the plugin:** `python tools/engramory_init.py dsh --install-skill` writes the
75
+ rules into `$DSH_HOME/AGENTS.md`, installs the skill in `$DSH_HOME/skills/engramory/`
76
+ (`$DSH_HOME` defaults to `~/.dsh`) and creates the global store. The AI still keeps memory, but reads the index itself, and
77
+ the cap holds only if it runs `engramory_check.py` after each write.
78
+
79
+ ## Companion mode (大肥鱼模式)
80
+
81
+ For a character you chat with: the community's 大肥鱼, or any persona. Turn on the
82
+ companion switch on the settings page, or set `companion: true`.
83
+
84
+ ![The memory page in companion mode](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/companion-mode.png)
85
+
86
+ - **Three more types for the character's own life** ([SKILL.md §2.2](https://github.com/tinqiao-oss/engramory/blob/master/SKILL.md)):
87
+ `moment`, something you shared, with its date, folded into a monthly archive when
88
+ the index fills; `upcoming`, something coming up in your life, asked about once its
89
+ date passes and rewritten as a moment once you say how it went; `self`, a change in
90
+ the character itself, such as a nickname. A moment or self note is deleted only when
91
+ you ask it to forget.
92
+ - **Recall in character.** Even a greeting may call for recall, and what it remembered,
93
+ or failed to save, is told in the character's voice, without naming files or tools.
94
+ - **The persona preset needs the file tools.** The memory arrives even under a preset
95
+ that turns optional context off (dsh's `minimal`, for one; from dsh 0.2 — 0.1 then sends
96
+ no runtime context at all). To save notes, though, the
97
+ preset needs dsh's file tools and the skill tool; a preset with only a shell reads the
98
+ memory, and its writes go past the cap.
99
+
100
+ ## Social mode
101
+
102
+ A choice inside companion mode, for a character other people can talk to as well, such
103
+ as one wired to QQ, WeChat, Douyin or Bilibili through a bridge plugin. Choose *Social*
104
+ under *Memory access* on the settings page, or set `audience: social`. If only you talk
105
+ to this dsh, keep the default, *Private*.
106
+
107
+ With it on, **only your own conversations get the memory**: one is yours when you have
108
+ typed in it in dsh's own window (the desktop app or `dsh web`) and nobody else has.
109
+ A subagent goes with its parent. Messages from a bridge plugin (unless it marks them as
110
+ the owner's, below), `dsh headless`, other programs, and terminal or editor clients
111
+ count as someone else's. Once anyone else has written in a conversation it stays
112
+ theirs, and the memory already put into it stays in its history.
113
+
114
+ Someone else's conversation gets no index and is not told where the store is; dsh's
115
+ file tools there may name files only (every directory is refused), and any path into
116
+ a store is refused however it is spelled; dsh's session search (an optional, experimental
117
+ feature that reads the records of other conversations in the same directory) is refused
118
+ there outright. This is **not** a security boundary: a shell tool reads any file, and
119
+ another profile on the same account can read the store too. Real isolation needs
120
+ filesystem permissions or a sandbox. A custom `skill` (see
121
+ [Configuration](#configuration)) reaches every conversation as written, someone else's
122
+ included, so if it says where the store is, they are told too.
123
+
124
+ ### For bridge authors
125
+
126
+ With social mode on, every message a bridge submits counts as someone else's. For a
127
+ message from the owner's own account (their private QQ chat with the character, say),
128
+ put a `speaker` on its source:
129
+
130
+ ```js
131
+ agent.followup(createUserMessage({
132
+ content: [{ type: 'text', text }],
133
+ source: { kind: 'plugin:your-bridge', speaker: { role: 'owner' } },
134
+ }))
135
+ ```
136
+
137
+ | `speaker.role` | Meaning |
138
+ |---|---|
139
+ | `owner` | The owner wrote it: it comes from the account the user set as theirs in your bridge. |
140
+ | `guest` | Someone else wrote it, the same as no `speaker` at all. |
141
+ | `none` | Nobody wrote it: your plugin's own report, reminder or notice. It does not make the owner's conversation someone else's. |
142
+
143
+ In a group chat, add `chat: 'group'` (`{ role: 'owner', chat: 'group' }`): the whole
144
+ group reads the reply, so the conversation counts as someone else's even while only the
145
+ owner has spoken in it. A private chat may say `chat: 'private'` or leave it out; any
146
+ other value counts as a group. A group conversation stays someone else's once anyone else in it
147
+ speaks. A program that talks to dsh only through dsh web's API cannot set a source, so its messages count
148
+ as someone else's; if it sends `clientTimeZone` with a prompt it is taken for the
149
+ owner, so a program forwarding other people's messages must leave it out.
150
+
151
+ ## Settings page and memory page
152
+
153
+ ![The settings page](https://raw.githubusercontent.com/tinqiao-oss/engramory/master/adapters/dsh/plugin/screenshots/settings-page.png)
154
+
155
+ - **Settings page:** on dsh's *Plugins* page, open *Engramory memory* to set companion
156
+ mode, memory access and the index cap. Saving goes through dsh's own profile editor,
157
+ which writes your profile's `cordis.patch.yml` and reloads the plugin. Only you, signed
158
+ in, can call it, so an agent cannot use it to switch social mode off.
159
+ - **Memory page:** *Memory* in the sidebar. A banner at the top, the plugin's version
160
+ beside its title, says how many notes, stores and archived files are listed and when
161
+ they were read, with the switches (companion mode, and memory access once it is on)
162
+ that save as you flip them. Below it,
163
+ tabs by note type and a filter by name, over the global store and each workspace's
164
+ project store (with an absolute `indexPath`, that store alone; with a relative one,
165
+ none). Each note is a row: a mark for its type, its name, its type and size; a plan's
166
+ row gives its day and how far off it is (a passed date is an outcome to confirm, as a
167
+ reminder: nothing is archived), and a note past 12 KB or one the index leaves out is
168
+ marked. Beside each store's name: its index fill as a bar (to the nearer of its two
169
+ caps), *Open the index* and *Open the folder*. What its check-up finds is listed under
170
+ it: the index's links to files that are not there, the notes not in the index (recall
171
+ starts from the index, so the AI will not find them unless another note links to
172
+ them), notes with no type, notes past 12 KB, an index over the cap; *Copy tidy-up
173
+ instructions* copies a request for the AI to paste into a conversation, and the plugin
174
+ itself changes no file. The check-up goes by file names and the index's links alone,
175
+ never through a symbolic link, and is skipped when the index is over the cap, there is
176
+ too much to check, or a file cannot be read; `engramory_doctor.py` still does the full
177
+ check. Where the listing was cut short or a store could not be read, the page says so,
178
+ rather than counting that as nothing. Read-only, never a note's text; a name, *Open
179
+ the index* and *Open the folder* open on the machine dsh runs on; a machine with no
180
+ desktop (a headless server, a session over SSH) shows none of them. A short *How to use
181
+ it* follows, open while there is no memory yet. At the foot, the plugin's version and
182
+ *Check for updates*: only when clicked, it asks npm (npmmirror when npm cannot be
183
+ reached) for the latest version number, with nothing from your memory, and lists the
184
+ steps that upgrade to a newer one, the version named. The plugin goes online at no other
185
+ time. Below that, where to send feedback: a new GitHub issue (its body pre-filled with
186
+ the plugin's version and the OS family, no path and no note), or an email, with a button
187
+ that copies the address.
188
+
189
+ ## Configuration
190
+
191
+ Settings the page does not cover go in your profile's `cordis.patch.yml`. Patch the
192
+ EXISTING row by id; a second `- insert:` adds another engramory row and leaves the old
193
+ caps in force. A patch replaces the row's whole `config`, so list every key you keep:
194
+
195
+ ```yaml
196
+ - id: engramory
197
+ config:
198
+ indexName: MEMORY.md
199
+ maxLines: 200
200
+ maxBytes: 25600
201
+ ```
202
+
203
+ | Field | Default | Meaning |
204
+ |---|---|---|
205
+ | `indexName` | `MEMORY.md` | The file name treated as the index. The cap matches it case-insensitively; sending the index needs the exact name on a case-sensitive filesystem (Linux, say). An index not named `.md` is shown in its folder by the memory page's *Open the index*, never opened in the default app. |
206
+ | `maxLines` | `200` | Line cap for the index. |
207
+ | `maxBytes` | `25600` | UTF-8 byte cap for the index (25 KB). |
208
+ | `indexPath` | unset | The one index to use: absolute, or relative to the session's directory. Unset, a `MEMORY.md` in any project is capped as an index; a store outside the default places also needs it to be found. |
209
+ | `registerSkill` | `true` | `false` skips the built-in rules; the cap and the index sent along stay. |
210
+ | `injectIndex` | `true` | `false` stops sending the index; the AI reads it instead. |
211
+ | `compactionReminder` | `true` | `false` stops the reminder to save before dsh compacts. The plugin works out where dsh will compact from dsh's own compaction settings (on dsh 0.2 with DeepSeek's defaults, about 69% of the window, not 80%) and reminds at 85% of that. A best effort: a conversation that grows past the gap in one step goes unreminded; with no compaction, or automatic compaction off, there is no reminder. |
212
+ | `language` | dsh's | `zh` (or `zh-CN` and other regional forms) writes the store in Chinese: note names, headings such as `## 用户`, the Why/How labels. Any other string is English; a value that is not a string, or is empty, counts as unset. Unset, it follows dsh's language; a change applies once dsh restarts. Frontmatter keys and `type:` values stay English, so every host reads the store. |
213
+ | `companion` | `false` | `true` turns companion mode on. |
214
+ | `audience` | `private` | With companion mode on, `social` turns social mode on. |
215
+ | `skill` | built-in | Your own markdown in place of the built-in rules; it must then say where the store is. In social mode, others' conversations see it too. |
216
+
217
+ ## How the cap decides
218
+
219
+ | Case | Decision |
220
+ |---|---|
221
+ | The index ends within the caps | allow |
222
+ | The write grows the index past a cap | **deny**, with the numbers and what to compact |
223
+ | The index is over a cap and the write shrinks it or keeps its size | allow, so compaction can go step by step (210 → 205 → 198) |
224
+ | A partial edit whose result can be worked out: `edit` (`old_string`/`new_string`), `str_replace_editor`'s replace (`old_str`/`new_str`) and `insert` | its result is worked out first, then judged as above; each tool from the arguments it uses and the way it matches |
225
+ | A partial edit whose result cannot be worked out (arguments missing or not recognised) | deny on an over-cap index, else allow |
226
+ | The index is missing, unreadable, or not a regular file | a whole-file write is judged as if it were empty; a partial edit passes |
227
+ | The index is past the read limit (`min(16 MiB, max(1 MiB, 4 × maxBytes))`) | not read whole: a whole-file write is judged on bytes alone; a partial edit passes |
228
+ | Reads, writes to other files, unknown tools or arguments | allow; reads are never blocked, even over the cap |
229
+
230
+ Lines and bytes are judged apart: only a dimension that is over its cap AND grew is
231
+ refused, so a write with fewer bytes but lines grown past the cap is still refused.
232
+ The line count ignores a trailing newline, so an index exactly at the cap stays
233
+ writable. This table is pinned by `node --test` in CI.
234
+
235
+ ## Known limits
236
+
237
+ - **Only dsh's file tools are capped:** `write`, `edit`, and the `str_replace_editor`
238
+ some versions and presets carry; a tool of the same name from another plugin is
239
+ judged the same way. Shell tools, MCP file tools and external editors go past it: run
240
+ `engramory_check.py` after editing the index and `engramory_doctor.py` now and then.
241
+ - **Stores are found only where the installer puts them.** Elsewhere, or for a project
242
+ store that links out of the project, set `indexPath`. A project's root is found by
243
+ its `.git` only, and a project store created mid-session can take ten seconds to appear.
244
+ - **Social mode knows you by what dsh's window sends.** Apart from a bridge's owner
245
+ messages, only what you type in dsh's own window is yours, and not when the browser's
246
+ time zone cannot be read. A kind of
247
+ message a later dsh adds counts as someone else's until this plugin knows it: your
248
+ conversation may lose the memory, never the other way round.
249
+ - **What the memory page opens is checked by path.** dsh's opener resolves the path once
250
+ more before the desktop opens it, so a process changing the store's files at that
251
+ moment could redirect what opens (as with dsh's own opener for any workspace file).
252
+ - **Experimental:** companion mode, social mode, and the settings and memory pages may
253
+ change in a minor version.
254
+
255
+ ## Feedback
256
+
257
+ For a problem or an idea, [open an issue on GitHub](https://github.com/tinqiao-oss/engramory/issues/new)
258
+ or email engramory@agent.qq.com. Emails are sorted with the help of an AI assistant, and issues
259
+ are public: do not paste your memory notes into either.
260
+
261
+ ## Versions
262
+
263
+ This package carries Engramory's version: `dsh-engramory@X.Y.Z` is the repo's
264
+ `vX.Y.Z`. The cap's decisions (the table above) and the settings outside the
265
+ experimental features change incompatibly only in a major version. See Engramory's
266
+ [Versioning](https://github.com/tinqiao-oss/engramory/blob/master/README.en.md#versioning); history is in the
267
+ [CHANGELOG](https://github.com/tinqiao-oss/engramory/blob/master/CHANGELOG.md).
268
+
269
+ ## License
270
+
271
+ MIT — see the [Engramory repository](https://github.com/tinqiao-oss/engramory).