@lmzhen/dsh-tool-memory 0.3.82 → 0.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 (3) hide show
  1. package/README.md +11 -19
  2. package/lib/index.js +28 -0
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -1,26 +1,18 @@
1
- # @deepseek-ai/dsh-tool-memory
1
+ # @lmzhen/dsh-tool-memory
2
2
 
3
- Model-facing memory tool and prompt context
3
+ Model-facing memory tool and prompt context: it registers the `memory` tool, one fixed
4
+ guidance section and the runtime snapshot of the current memory entries. It owns no store —
5
+ the memory files and their provider do.
4
6
 
5
- ## Model Experience
7
+ ## Model surface
6
8
 
7
- ### Memory tool and runtime snapshot
8
-
9
- #### What the model sees
10
-
11
- The model sees the `memory` tool schema, one fixed guidance section, and a runtime snapshot containing the current memory entries.
12
-
13
- #### Token effect
14
-
15
- Fixed guidance has a constant token cost. The runtime snapshot scales with stored memory entries and is absent when memory is empty.
16
-
17
- #### KV Cache effect
18
-
19
- Guidance text is prefix-stable. The runtime snapshot is replaced after successful memory writes and is otherwise unchanged between requests.
20
-
21
- ## Known Limitations and Deferred Work
9
+ - **Model-visible:** the `memory` tool schema, one fixed guidance section, and a runtime snapshot containing the current memory entries; the snapshot scales with the stored entries and is absent when memory is empty.
10
+ - **Prompt prefix / KV cache:** guidance text is prefix-stable; the runtime snapshot is replaced after successful memory writes and is otherwise unchanged between requests; family rules: `packages/README.md` §"Model-visible prompt prefix and the KV cache".
11
+ - **Mount it?** yes — the `tool-memory` row, carried by the `evolution-all` and one-click `evolution-preset` bundles and by the Evolution agent preset delta.
22
12
 
13
+ ## Known limitations
23
14
 
24
15
  - No known durable consumer gaps at this time. Runtime contracts are covered by package and boundary tests.
16
+ - The pre-approval required-field pre-check and the store's own rejection text are hand-copied twins: the check runs on BOTH paths (every `operations[]` element and the normalized single operation) BEFORE the approval gate, so an approval-enabled deployment never stages a write the approved replay must then fail. Keeping the two texts in step is still manual; unifying them is deferred.
25
17
 
26
- **Runtime invariant:** No companion is published. The platform auto-assembles nothing and the family mounts no `<pkg>/invariant` cordis row, so a companion here would never execute (v37 S2.1 / I-3).
18
+ **Runtime invariant:** No companion is published. The platform auto-assembles nothing and the family mounts no `<pkg>/invariant` cordis row, so a companion here would never execute (v37 S2.1 / I-3).
package/lib/index.js CHANGED
@@ -104,6 +104,14 @@ async function apply(ctx, rawConfig = {}) {
104
104
  limit: result.limit
105
105
  };
106
106
  }
107
+ const requiredFieldRejection = (op, position) => {
108
+ const body = (op.facts ?? op.content ?? "").trim();
109
+ if (op.action === "add") return body ? null : `Operation ${position} (add): facts is required. No operations were applied.`;
110
+ if (op.action !== "remove" && op.action !== "replace") return `Operation ${position}: unknown action "${String(op.action)}" (expected add/remove/replace). No operations were applied.`;
111
+ if (!(op.old_text ?? "").trim()) return `Operation ${position} (${op.action}): old_text is required. No operations were applied.`;
112
+ if (op.action === "replace" && !body) return `Operation ${position} (replace): facts is required.`;
113
+ return null;
114
+ };
107
115
  if (!memoryDisabled) ctx.tools.register(defineTool({
108
116
  name: "memory",
109
117
  description: MEMORY_TOOL_DESCRIPTION,
@@ -234,6 +242,26 @@ async function apply(ctx, rawConfig = {}) {
234
242
  facts: args.facts ?? args.content,
235
243
  old_text: args.old_text
236
244
  };
245
+ if (normalized.operations) for (const [index, op] of normalized.operations.entries()) {
246
+ const rejection = requiredFieldRejection(op, index + 1);
247
+ if (rejection) return {
248
+ ok: false,
249
+ message: rejection,
250
+ entries: [],
251
+ chars: 0,
252
+ limit: 0
253
+ };
254
+ }
255
+ else {
256
+ const rejection = requiredFieldRejection(normalized, 1);
257
+ if (rejection) return {
258
+ ok: false,
259
+ message: rejection,
260
+ entries: [],
261
+ chars: 0,
262
+ limit: 0
263
+ };
264
+ }
237
265
  const targetLabel = target === "memory" ? "" : `${target} `;
238
266
  const origin = resolveExecOrigins(exec).approval;
239
267
  const sessionPolicy = effectiveSessionPolicy(ctx, exec.agent?.session);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-tool-memory",
3
3
  "description": "Model-facing memory tool and prompt context (community build)",
4
- "version": "0.3.82",
4
+ "version": "0.4.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,21 +27,21 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.1",
30
- "@lmzhen/dsh-evolution-approval": "^0.3.82",
31
- "@lmzhen/dsh-evolution-core": "^0.3.82"
30
+ "@lmzhen/dsh-evolution-approval": "^0.4.0",
31
+ "@lmzhen/dsh-evolution-core": "^0.4.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@deepseek-ai/cordis": "^4.0.1",
35
35
  "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
36
36
  "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
37
- "@lmzhen/dsh-memory": "^0.3.82"
37
+ "@lmzhen/dsh-memory": "^0.4.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
41
41
  "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
42
42
  "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.5-rc.2",
43
- "@lmzhen/dsh-evolution-approval": "^0.3.82",
44
- "@lmzhen/dsh-memory": "^0.3.82",
45
- "@lmzhen/dsh-memory-files": "^0.3.82"
43
+ "@lmzhen/dsh-evolution-approval": "^0.4.0",
44
+ "@lmzhen/dsh-memory": "^0.4.0",
45
+ "@lmzhen/dsh-memory-files": "^0.4.0"
46
46
  }
47
47
  }