dsh-cross-memory 0.2.12 → 0.2.14

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 (43) hide show
  1. package/README.md +55 -16
  2. package/docs/DETAIL.md +13 -10
  3. package/docs/DETAIL.zh.md +13 -10
  4. package/lib/backfill.js +32 -1
  5. package/lib/client.js +3 -3
  6. package/lib/consolidate.js +41 -39
  7. package/lib/dense.js +47 -15
  8. package/lib/extract.js +39 -11
  9. package/lib/gate.js +35 -19
  10. package/lib/index.js +221 -131
  11. package/lib/mcp.js +330 -0
  12. package/lib/notify.js +10 -5
  13. package/lib/persona.js +99 -1
  14. package/lib/raw-recall.js +18 -7
  15. package/lib/reflection.js +10 -1
  16. package/lib/state.js +19 -7
  17. package/lib/storage.js +11 -1
  18. package/lib/sync.js +36 -14
  19. package/lib/test/archive.test.js +19 -0
  20. package/lib/test/consolidate.test.js +48 -10
  21. package/lib/test/extract.test.js +30 -1
  22. package/lib/test/loops.test.js +3 -2
  23. package/lib/test/mcp.test.js +103 -0
  24. package/lib/test/notices.test.js +67 -0
  25. package/lib/test/persona.test.js +40 -1
  26. package/lib/test/recall.test.js +54 -1
  27. package/lib/test/reflection.test.js +60 -1
  28. package/lib/test/subagent-contract.test.js +18 -12
  29. package/lib/test/sync.test.js +4 -0
  30. package/lib/tool.js +4 -3
  31. package/lib/types/backfill.d.ts +5 -0
  32. package/lib/types/consolidate.d.ts +34 -51
  33. package/lib/types/dense.d.ts +7 -2
  34. package/lib/types/extract.d.ts +14 -0
  35. package/lib/types/gate.d.ts +4 -0
  36. package/lib/types/index.d.ts +10 -0
  37. package/lib/types/mcp.d.ts +184 -0
  38. package/lib/types/notify.d.ts +3 -2
  39. package/lib/types/persona.d.ts +17 -0
  40. package/lib/types/raw-recall.d.ts +1 -0
  41. package/lib/types/sync.d.ts +7 -5
  42. package/lib/types/test/mcp.test.d.ts +1 -0
  43. package/package.json +14 -7
@@ -20,11 +20,28 @@ export declare function personaLockPath(memoriesDir: string): string;
20
20
  * @returns the markdown body, or `undefined` when it does not exist yet.
21
21
  */
22
22
  export declare function readPersona(memoriesDir: string): Promise<string | undefined>;
23
+ /**
24
+ * Whether two persona bullets express the same rule (rephrased or tightened).
25
+ *
26
+ * A consolidation pass often tightens a bullet's wording on one machine while
27
+ * another machine still holds the older phrasing. Exact-string matching treats
28
+ * both as distinct rules and doubles every section on sync. Token overlap +
29
+ * containment catches rewrites without merging genuinely different rules.
30
+ */
31
+ export declare function isNearDuplicateBullet(left: string, right: string): boolean;
32
+ /**
33
+ * Deduplicate exact and near-duplicate bullets inside each section of a persona
34
+ * markdown document, keeping the earlier bullet when two bullets state the same
35
+ * rule. Also collapses repeated blank lines.
36
+ */
37
+ export declare function dedupePersona(body: string): string;
23
38
  /**
24
39
  * Replace the profile atomically.
25
40
  *
26
41
  * A half-written profile is worse than a stale one — it would be injected into
27
42
  * every conversation — so the write goes through a temp file and a rename.
43
+ * Deduplicates near-identical bullets within each section before persisting so
44
+ * neither consolidation nor multi-machine sync can double the profile.
28
45
  *
29
46
  * @param memoriesDir - the memory store root.
30
47
  * @param body - the new markdown profile.
@@ -99,6 +99,7 @@ export declare function collectRagExcerpts(sessionsDir: string, query: string, l
99
99
  }): Promise<RawExcerpt[]>;
100
100
  /** One user turn and the assistant turns that answered it. */
101
101
  export interface TurnChunk {
102
+ readonly sessionId?: string;
102
103
  readonly seq: number;
103
104
  readonly text: string;
104
105
  }
@@ -93,13 +93,14 @@ export declare function sessionNoteStamp(text: string): number;
93
93
  /** Whether one path is a persona file: prose the assistant maintains for the user. */
94
94
  export declare function isPersonaPath(path: string): boolean;
95
95
  /**
96
- * Merge two versions of a persona file as a bullet union.
96
+ * Merge two versions of a persona file as a deduplicated bullet union.
97
97
  *
98
98
  * A persona file is headings plus bullet lists; both machines append their own
99
- * observations, so a line-level union keeps every rule either machine recorded.
100
- * Bullets are matched on their trimmed text (duplicates are dropped), inserted
101
- * after the last bullet of the same section, and a whole section that only
102
- * `theirs` has is appended at the end. Non-bullet lines come from `ours`.
99
+ * observations, so a section-aware union keeps every rule either machine
100
+ * recorded. Bullets are matched not only on exact text but also on near-duplicate
101
+ * token overlap within the same section — otherwise a consolidation pass that
102
+ * tightens wording on one machine causes the next sync to append the older
103
+ * phrasing beside it and double every section. Non-bullet lines come from `ours`.
103
104
  */
104
105
  export declare function mergePersona(ours: string, theirs: string): string;
105
106
  /**
@@ -173,6 +174,7 @@ export declare class MemorySync {
173
174
  private debounce;
174
175
  private pushing;
175
176
  private inflight;
177
+ private dirtyWhileInflight;
176
178
  private lastOutcome;
177
179
  constructor(options: MemorySyncOptions);
178
180
  /** The outcome of the last completed run, when there was one. */
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cross-memory",
3
3
  "description": "Cross-session memory for the DeepSeek Harness: project-scoped and global memories with an explicit memory tool, idle-time background extraction, consolidation, and layered summary injection",
4
- "version": "0.2.12",
4
+ "version": "0.2.14",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -9,6 +9,9 @@
9
9
  "type": "module",
10
10
  "main": "lib/index.js",
11
11
  "types": "lib/types/index.d.ts",
12
+ "bin": {
13
+ "dsh-cross-memory-mcp": "./lib/mcp.js"
14
+ },
12
15
  "exports": {
13
16
  ".": {
14
17
  "types": "./lib/types/index.d.ts",
@@ -17,6 +20,10 @@
17
20
  "./client": {
18
21
  "default": "./lib/client.js"
19
22
  },
23
+ "./mcp": {
24
+ "types": "./lib/types/mcp.d.ts",
25
+ "default": "./lib/mcp.js"
26
+ },
20
27
  "./cordis.patch.yml": "./cordis.patch.yml",
21
28
  "./package.json": "./package.json"
22
29
  },
@@ -95,12 +102,12 @@
95
102
  },
96
103
  "peerDependencies": {
97
104
  "@deepseek-ai/cordis": "^4.0.5 || ^4.0.6-alpha.1",
98
- "@deepseek-ai/dsh-agent": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
99
- "@deepseek-ai/dsh-commands": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
100
- "@deepseek-ai/dsh-home-paths": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
101
- "@deepseek-ai/dsh-llm": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
102
- "@deepseek-ai/dsh-session": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
103
- "@deepseek-ai/dsh-tools": "^0.2.1-rc.2 || ^0.2.2-alpha.2",
105
+ "@deepseek-ai/dsh-agent": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
106
+ "@deepseek-ai/dsh-commands": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
107
+ "@deepseek-ai/dsh-home-paths": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
108
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
109
+ "@deepseek-ai/dsh-session": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
110
+ "@deepseek-ai/dsh-tools": "^0.2.1-rc.2 || ^0.2.2-alpha.2 || ^0.2.3-alpha.1",
104
111
  "@deepseek-ai/schemastery": "^3.18.5 || ^3.18.6-alpha.1"
105
112
  },
106
113
  "devDependencies": {